dsh-multigameassistant 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,235 +0,0 @@
1
- var tE=Object.defineProperty;var Sv=e=>{throw TypeError(e)};var nE=(e,t,n)=>t in e?tE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ut=(e,t,n)=>nE(e,typeof t!="symbol"?t+"":t,n),lh=(e,t,n)=>t.has(e)||Sv("Cannot "+n);var Re=(e,t,n)=>(lh(e,t,"read from private field"),n?n.call(e):t.get(e)),Lt=(e,t,n)=>t.has(e)?Sv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Zt=(e,t,n,r)=>(lh(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),xt=(e,t,n)=>(lh(e,t,"access private method"),n);var _v=(e,t,n,r)=>({set _(i){Zt(e,t,i,n)},get _(){return Re(e,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function gm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ch={exports:{}},pl={},uh={exports:{}},mt={};/**
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 Ev;function sE(){if(Ev)return mt;Ev=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function g(V){return V===null||typeof V!="object"?null:(V=m&&V[m]||V["@@iterator"],typeof V=="function"?V:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,S={};function k(V,Y,fe){this.props=V,this.context=Y,this.refs=S,this.updater=fe||v}k.prototype.isReactComponent={},k.prototype.setState=function(V,Y){if(typeof V!="object"&&typeof V!="function"&&V!=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,V,Y,"setState")},k.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function w(){}w.prototype=k.prototype;function A(V,Y,fe){this.props=V,this.context=Y,this.refs=S,this.updater=fe||v}var N=A.prototype=new w;N.constructor=A,y(N,k.prototype),N.isPureReactComponent=!0;var R=Array.isArray,D=Object.prototype.hasOwnProperty,P={current:null},F={key:!0,ref:!0,__self:!0,__source:!0};function W(V,Y,fe){var xe,ge={},ie=null,ke=null;if(Y!=null)for(xe in Y.ref!==void 0&&(ke=Y.ref),Y.key!==void 0&&(ie=""+Y.key),Y)D.call(Y,xe)&&!F.hasOwnProperty(xe)&&(ge[xe]=Y[xe]);var ae=arguments.length-2;if(ae===1)ge.children=fe;else if(1<ae){for(var Ne=Array(ae),Fe=0;Fe<ae;Fe++)Ne[Fe]=arguments[Fe+2];ge.children=Ne}if(V&&V.defaultProps)for(xe in ae=V.defaultProps,ae)ge[xe]===void 0&&(ge[xe]=ae[xe]);return{$$typeof:e,type:V,key:ie,ref:ke,props:ge,_owner:P.current}}function M(V,Y){return{$$typeof:e,type:V.type,key:Y,ref:V.ref,props:V.props,_owner:V._owner}}function O(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function T(V){var Y={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(fe){return Y[fe]})}var Z=/\/+/g;function E(V,Y){return typeof V=="object"&&V!==null&&V.key!=null?T(""+V.key):Y.toString(36)}function C(V,Y,fe,xe,ge){var ie=typeof V;(ie==="undefined"||ie==="boolean")&&(V=null);var ke=!1;if(V===null)ke=!0;else switch(ie){case"string":case"number":ke=!0;break;case"object":switch(V.$$typeof){case e:case t:ke=!0}}if(ke)return ke=V,ge=ge(ke),V=xe===""?"."+E(ke,0):xe,R(ge)?(fe="",V!=null&&(fe=V.replace(Z,"$&/")+"/"),C(ge,Y,fe,"",function(Fe){return Fe})):ge!=null&&(O(ge)&&(ge=M(ge,fe+(!ge.key||ke&&ke.key===ge.key?"":(""+ge.key).replace(Z,"$&/")+"/")+V)),Y.push(ge)),1;if(ke=0,xe=xe===""?".":xe+":",R(V))for(var ae=0;ae<V.length;ae++){ie=V[ae];var Ne=xe+E(ie,ae);ke+=C(ie,Y,fe,Ne,ge)}else if(Ne=g(V),typeof Ne=="function")for(V=Ne.call(V),ae=0;!(ie=V.next()).done;)ie=ie.value,Ne=xe+E(ie,ae++),ke+=C(ie,Y,fe,Ne,ge);else if(ie==="object")throw Y=String(V),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return ke}function $(V,Y,fe){if(V==null)return V;var xe=[],ge=0;return C(V,xe,"","",function(ie){return Y.call(fe,ie,ge++)}),xe}function L(V){if(V._status===-1){var Y=V._result;Y=Y(),Y.then(function(fe){(V._status===0||V._status===-1)&&(V._status=1,V._result=fe)},function(fe){(V._status===0||V._status===-1)&&(V._status=2,V._result=fe)}),V._status===-1&&(V._status=0,V._result=Y)}if(V._status===1)return V._result.default;throw V._result}var B={current:null},H={transition:null},G={ReactCurrentDispatcher:B,ReactCurrentBatchConfig:H,ReactCurrentOwner:P};function K(){throw Error("act(...) is not supported in production builds of React.")}return mt.Children={map:$,forEach:function(V,Y,fe){$(V,function(){Y.apply(this,arguments)},fe)},count:function(V){var Y=0;return $(V,function(){Y++}),Y},toArray:function(V){return $(V,function(Y){return Y})||[]},only:function(V){if(!O(V))throw Error("React.Children.only expected to receive a single React element child.");return V}},mt.Component=k,mt.Fragment=n,mt.Profiler=i,mt.PureComponent=A,mt.StrictMode=r,mt.Suspense=f,mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=G,mt.act=K,mt.cloneElement=function(V,Y,fe){if(V==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+V+".");var xe=y({},V.props),ge=V.key,ie=V.ref,ke=V._owner;if(Y!=null){if(Y.ref!==void 0&&(ie=Y.ref,ke=P.current),Y.key!==void 0&&(ge=""+Y.key),V.type&&V.type.defaultProps)var ae=V.type.defaultProps;for(Ne in Y)D.call(Y,Ne)&&!F.hasOwnProperty(Ne)&&(xe[Ne]=Y[Ne]===void 0&&ae!==void 0?ae[Ne]:Y[Ne])}var Ne=arguments.length-2;if(Ne===1)xe.children=fe;else if(1<Ne){ae=Array(Ne);for(var Fe=0;Fe<Ne;Fe++)ae[Fe]=arguments[Fe+2];xe.children=ae}return{$$typeof:e,type:V.type,key:ge,ref:ie,props:xe,_owner:ke}},mt.createContext=function(V){return V={$$typeof:c,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},V.Provider={$$typeof:o,_context:V},V.Consumer=V},mt.createElement=W,mt.createFactory=function(V){var Y=W.bind(null,V);return Y.type=V,Y},mt.createRef=function(){return{current:null}},mt.forwardRef=function(V){return{$$typeof:u,render:V}},mt.isValidElement=O,mt.lazy=function(V){return{$$typeof:p,_payload:{_status:-1,_result:V},_init:L}},mt.memo=function(V,Y){return{$$typeof:d,type:V,compare:Y===void 0?null:Y}},mt.startTransition=function(V){var Y=H.transition;H.transition={};try{V()}finally{H.transition=Y}},mt.unstable_act=K,mt.useCallback=function(V,Y){return B.current.useCallback(V,Y)},mt.useContext=function(V){return B.current.useContext(V)},mt.useDebugValue=function(){},mt.useDeferredValue=function(V){return B.current.useDeferredValue(V)},mt.useEffect=function(V,Y){return B.current.useEffect(V,Y)},mt.useId=function(){return B.current.useId()},mt.useImperativeHandle=function(V,Y,fe){return B.current.useImperativeHandle(V,Y,fe)},mt.useInsertionEffect=function(V,Y){return B.current.useInsertionEffect(V,Y)},mt.useLayoutEffect=function(V,Y){return B.current.useLayoutEffect(V,Y)},mt.useMemo=function(V,Y){return B.current.useMemo(V,Y)},mt.useReducer=function(V,Y,fe){return B.current.useReducer(V,Y,fe)},mt.useRef=function(V){return B.current.useRef(V)},mt.useState=function(V){return B.current.useState(V)},mt.useSyncExternalStore=function(V,Y,fe){return B.current.useSyncExternalStore(V,Y,fe)},mt.useTransition=function(){return B.current.useTransition()},mt.version="18.3.1",mt}var Cv;function rc(){return Cv||(Cv=1,uh.exports=sE()),uh.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 Iv;function rE(){if(Iv)return pl;Iv=1;var e=rc(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(u,f,d){var p,m={},g=null,v=null;d!==void 0&&(g=""+d),f.key!==void 0&&(g=""+f.key),f.ref!==void 0&&(v=f.ref);for(p in f)r.call(f,p)&&!o.hasOwnProperty(p)&&(m[p]=f[p]);if(u&&u.defaultProps)for(p in f=u.defaultProps,f)m[p]===void 0&&(m[p]=f[p]);return{$$typeof:t,type:u,key:g,ref:v,props:m,_owner:i.current}}return pl.Fragment=n,pl.jsx=c,pl.jsxs=c,pl}var Av;function iE(){return Av||(Av=1,ch.exports=rE()),ch.exports}var s=iE(),du={},dh={exports:{}},gs={},fh={exports:{}},hh={};/**
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 Tv;function aE(){return Tv||(Tv=1,(function(e){function t(H,G){var K=H.length;H.push(G);e:for(;0<K;){var V=K-1>>>1,Y=H[V];if(0<i(Y,G))H[V]=G,H[K]=Y,K=V;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var G=H[0],K=H.pop();if(K!==G){H[0]=K;e:for(var V=0,Y=H.length,fe=Y>>>1;V<fe;){var xe=2*(V+1)-1,ge=H[xe],ie=xe+1,ke=H[ie];if(0>i(ge,K))ie<Y&&0>i(ke,ge)?(H[V]=ke,H[ie]=K,V=ie):(H[V]=ge,H[xe]=K,V=xe);else if(ie<Y&&0>i(ke,K))H[V]=ke,H[ie]=K,V=ie;else break e}}return G}function i(H,G){var K=H.sortIndex-G.sortIndex;return K!==0?K:H.id-G.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var f=[],d=[],p=1,m=null,g=3,v=!1,y=!1,S=!1,k=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function N(H){for(var G=n(d);G!==null;){if(G.callback===null)r(d);else if(G.startTime<=H)r(d),G.sortIndex=G.expirationTime,t(f,G);else break;G=n(d)}}function R(H){if(S=!1,N(H),!y)if(n(f)!==null)y=!0,L(D);else{var G=n(d);G!==null&&B(R,G.startTime-H)}}function D(H,G){y=!1,S&&(S=!1,w(W),W=-1),v=!0;var K=g;try{for(N(G),m=n(f);m!==null&&(!(m.expirationTime>G)||H&&!T());){var V=m.callback;if(typeof V=="function"){m.callback=null,g=m.priorityLevel;var Y=V(m.expirationTime<=G);G=e.unstable_now(),typeof Y=="function"?m.callback=Y:m===n(f)&&r(f),N(G)}else r(f);m=n(f)}if(m!==null)var fe=!0;else{var xe=n(d);xe!==null&&B(R,xe.startTime-G),fe=!1}return fe}finally{m=null,g=K,v=!1}}var P=!1,F=null,W=-1,M=5,O=-1;function T(){return!(e.unstable_now()-O<M)}function Z(){if(F!==null){var H=e.unstable_now();O=H;var G=!0;try{G=F(!0,H)}finally{G?E():(P=!1,F=null)}}else P=!1}var E;if(typeof A=="function")E=function(){A(Z)};else if(typeof MessageChannel<"u"){var C=new MessageChannel,$=C.port2;C.port1.onmessage=Z,E=function(){$.postMessage(null)}}else E=function(){k(Z,0)};function L(H){F=H,P||(P=!0,E())}function B(H,G){W=k(function(){H(e.unstable_now())},G)}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(H){H.callback=null},e.unstable_continueExecution=function(){y||v||(y=!0,L(D))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):M=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(H){switch(g){case 1:case 2:case 3:var G=3;break;default:G=g}var K=g;g=G;try{return H()}finally{g=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,G){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var K=g;g=H;try{return G()}finally{g=K}},e.unstable_scheduleCallback=function(H,G,K){var V=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?V+K:V):K=V,H){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=K+Y,H={id:p++,callback:G,priorityLevel:H,startTime:K,expirationTime:Y,sortIndex:-1},K>V?(H.sortIndex=K,t(d,H),n(f)===null&&H===n(d)&&(S?(w(W),W=-1):S=!0,B(R,K-V))):(H.sortIndex=Y,t(f,H),y||v||(y=!0,L(D))),H},e.unstable_shouldYield=T,e.unstable_wrapCallback=function(H){var G=g;return function(){var K=g;g=G;try{return H.apply(this,arguments)}finally{g=K}}}})(hh)),hh}var $v;function oE(){return $v||($v=1,fh.exports=aE()),fh.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 Mv;function lE(){if(Mv)return gs;Mv=1;var e=rc(),t=oE();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,h=1;h<arguments.length;h++)l+="&args[]="+encodeURIComponent(arguments[h]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function o(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(i[a]=l,a=0;a<l.length;a++)r.add(l[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=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]*$/,p={},m={};function g(a){return f.call(m,a)?!0:f.call(p,a)?!1:d.test(a)?m[a]=!0:(p[a]=!0,!1)}function v(a,l,h,x){if(h!==null&&h.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return x?!1:h!==null?!h.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function y(a,l,h,x){if(l===null||typeof l>"u"||v(a,l,h,x))return!0;if(x)return!1;if(h!==null)switch(h.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function S(a,l,h,x,j,I,U){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=x,this.attributeNamespace=j,this.mustUseProperty=h,this.propertyName=a,this.type=l,this.sanitizeURL=I,this.removeEmptyString=U}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){k[a]=new S(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];k[l]=new S(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){k[a]=new S(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){k[a]=new S(a,2,!1,a,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(a){k[a]=new S(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){k[a]=new S(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){k[a]=new S(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){k[a]=new S(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){k[a]=new S(a,5,!1,a.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function A(a){return a[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(a){var l=a.replace(w,A);k[l]=new S(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(w,A);k[l]=new S(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(w,A);k[l]=new S(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){k[a]=new S(a,1,!1,a.toLowerCase(),null,!1,!1)}),k.xlinkHref=new S("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){k[a]=new S(a,1,!1,a.toLowerCase(),null,!0,!0)});function N(a,l,h,x){var j=k.hasOwnProperty(l)?k[l]:null;(j!==null?j.type!==0:x||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(y(l,h,j,x)&&(h=null),x||j===null?g(l)&&(h===null?a.removeAttribute(l):a.setAttribute(l,""+h)):j.mustUseProperty?a[j.propertyName]=h===null?j.type===3?!1:"":h:(l=j.attributeName,x=j.attributeNamespace,h===null?a.removeAttribute(l):(j=j.type,h=j===3||j===4&&h===!0?"":""+h,x?a.setAttributeNS(x,l,h):a.setAttribute(l,h))))}var R=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,D=Symbol.for("react.element"),P=Symbol.for("react.portal"),F=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),O=Symbol.for("react.provider"),T=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),B=Symbol.for("react.offscreen"),H=Symbol.iterator;function G(a){return a===null||typeof a!="object"?null:(a=H&&a[H]||a["@@iterator"],typeof a=="function"?a:null)}var K=Object.assign,V;function Y(a){if(V===void 0)try{throw Error()}catch(h){var l=h.stack.trim().match(/\n( *(at )?)/);V=l&&l[1]||""}return`
34
- `+V+a}var fe=!1;function xe(a,l){if(!a||fe)return"";fe=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(de){var x=de}Reflect.construct(a,[],l)}else{try{l.call()}catch(de){x=de}a.call(l.prototype)}else{try{throw Error()}catch(de){x=de}a()}}catch(de){if(de&&x&&typeof de.stack=="string"){for(var j=de.stack.split(`
35
- `),I=x.stack.split(`
36
- `),U=j.length-1,X=I.length-1;1<=U&&0<=X&&j[U]!==I[X];)X--;for(;1<=U&&0<=X;U--,X--)if(j[U]!==I[X]){if(U!==1||X!==1)do if(U--,X--,0>X||j[U]!==I[X]){var J=`
37
- `+j[U].replace(" at new "," at ");return a.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",a.displayName)),J}while(1<=U&&0<=X);break}}}finally{fe=!1,Error.prepareStackTrace=h}return(a=a?a.displayName||a.name:"")?Y(a):""}function ge(a){switch(a.tag){case 5:return Y(a.type);case 16:return Y("Lazy");case 13:return Y("Suspense");case 19:return Y("SuspenseList");case 0:case 2:case 15:return a=xe(a.type,!1),a;case 11:return a=xe(a.type.render,!1),a;case 1:return a=xe(a.type,!0),a;default:return""}}function ie(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case F:return"Fragment";case P:return"Portal";case M:return"Profiler";case W:return"StrictMode";case E:return"Suspense";case C:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case T:return(a.displayName||"Context")+".Consumer";case O:return(a._context.displayName||"Context")+".Provider";case Z:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case $:return l=a.displayName||null,l!==null?l:ie(a.type)||"Memo";case L:l=a._payload,a=a._init;try{return ie(a(l))}catch{}}return null}function ke(a){var l=a.type;switch(a.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=l.render,a=a.displayName||a.name||"",l.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ie(l);case 8:return l===W?"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 l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function ae(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Ne(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Fe(a){var l=Ne(a)?"checked":"value",h=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),x=""+a[l];if(!a.hasOwnProperty(l)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var j=h.get,I=h.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return j.call(this)},set:function(U){x=""+U,I.call(this,U)}}),Object.defineProperty(a,l,{enumerable:h.enumerable}),{getValue:function(){return x},setValue:function(U){x=""+U},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function ce(a){a._valueTracker||(a._valueTracker=Fe(a))}function Se(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var h=l.getValue(),x="";return a&&(x=Ne(a)?a.checked?"true":"false":a.value),a=x,a!==h?(l.setValue(a),!0):!1}function re(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function he(a,l){var h=l.checked;return K({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??a._wrapperState.initialChecked})}function Le(a,l){var h=l.defaultValue==null?"":l.defaultValue,x=l.checked!=null?l.checked:l.defaultChecked;h=ae(l.value!=null?l.value:h),a._wrapperState={initialChecked:x,initialValue:h,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Te(a,l){l=l.checked,l!=null&&N(a,"checked",l,!1)}function Ge(a,l){Te(a,l);var h=ae(l.value),x=l.type;if(h!=null)x==="number"?(h===0&&a.value===""||a.value!=h)&&(a.value=""+h):a.value!==""+h&&(a.value=""+h);else if(x==="submit"||x==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?tt(a,l.type,h):l.hasOwnProperty("defaultValue")&&tt(a,l.type,ae(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function Ie(a,l,h){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var x=l.type;if(!(x!=="submit"&&x!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+a._wrapperState.initialValue,h||l===a.value||(a.value=l),a.defaultValue=l}h=a.name,h!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,h!==""&&(a.name=h)}function tt(a,l,h){(l!=="number"||re(a.ownerDocument)!==a)&&(h==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+h&&(a.defaultValue=""+h))}var et=Array.isArray;function jt(a,l,h,x){if(a=a.options,l){l={};for(var j=0;j<h.length;j++)l["$"+h[j]]=!0;for(h=0;h<a.length;h++)j=l.hasOwnProperty("$"+a[h].value),a[h].selected!==j&&(a[h].selected=j),j&&x&&(a[h].defaultSelected=!0)}else{for(h=""+ae(h),l=null,j=0;j<a.length;j++){if(a[j].value===h){a[j].selected=!0,x&&(a[j].defaultSelected=!0);return}l!==null||a[j].disabled||(l=a[j])}l!==null&&(l.selected=!0)}}function On(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return K({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function sn(a,l){var h=l.value;if(h==null){if(h=l.children,l=l.defaultValue,h!=null){if(l!=null)throw Error(n(92));if(et(h)){if(1<h.length)throw Error(n(93));h=h[0]}l=h}l==null&&(l=""),h=l}a._wrapperState={initialValue:ae(h)}}function ln(a,l){var h=ae(l.value),x=ae(l.defaultValue);h!=null&&(h=""+h,h!==a.value&&(a.value=h),l.defaultValue==null&&a.defaultValue!==h&&(a.defaultValue=h)),x!=null&&(a.defaultValue=""+x)}function cn(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function rn(a){switch(a){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 an(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?rn(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Ft,Bn=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,h,x,j){MSApp.execUnsafeLocalFunction(function(){return a(l,h,x,j)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(Ft=Ft||document.createElement("div"),Ft.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Ft.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function wn(a,l){if(l){var h=a.firstChild;if(h&&h===a.lastChild&&h.nodeType===3){h.nodeValue=l;return}}a.textContent=l}var ws={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},_r=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(a){_r.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),ws[l]=ws[a]})});function Ks(a,l,h){return l==null||typeof l=="boolean"||l===""?"":h||typeof l!="number"||l===0||ws.hasOwnProperty(a)&&ws[a]?(""+l).trim():l+"px"}function Ys(a,l){a=a.style;for(var h in l)if(l.hasOwnProperty(h)){var x=h.indexOf("--")===0,j=Ks(h,l[h],x);h==="float"&&(h="cssFloat"),x?a.setProperty(h,j):a[h]=j}}var Ms=K({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 Rs(a,l){if(l){if(Ms[a]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(n(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(n(61))}if(l.style!=null&&typeof l.style!="object")throw Error(n(62))}}function Os(a,l){if(a.indexOf("-")===-1)return typeof l.is=="string";switch(a){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 zs=null;function Xs(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Qs=null,rs=null,Yn=null;function Nn(a){if(a=Jo(a)){if(typeof Qs!="function")throw Error(n(280));var l=a.stateNode;l&&(l=_c(l),Qs(a.stateNode,a.type,l))}}function Q(a){rs?Yn?Yn.push(a):Yn=[a]:rs=a}function pe(){if(rs){var a=rs,l=Yn;if(Yn=rs=null,Nn(a),l)for(a=0;a<l.length;a++)Nn(l[a])}}function Oe(a,l){return a(l)}function st(){}var It=!1;function $t(a,l,h){if(It)return a(l,h);It=!0;try{return Oe(a,l,h)}finally{It=!1,(rs!==null||Yn!==null)&&(st(),pe())}}function Be(a,l){var h=a.stateNode;if(h===null)return null;var x=_c(h);if(x===null)return null;h=x[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(a=a.type,x=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!x;break e;default:a=!1}if(a)return null;if(h&&typeof h!="function")throw Error(n(231,l,typeof h));return h}var De=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){De=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{De=!1}function bt(a,l,h,x,j,I,U,X,J){var de=Array.prototype.slice.call(arguments,3);try{l.apply(h,de)}catch(Ee){this.onError(Ee)}}var yt=!1,Un=null,is=!1,Js=null,hi={onError:function(a){yt=!0,Un=a}};function er(a,l,h,x,j,I,U,X,J){yt=!1,Un=null,bt.apply(hi,arguments)}function pi(a,l,h,x,j,I,U,X,J){if(er.apply(this,arguments),yt){if(yt){var de=Un;yt=!1,Un=null}else throw Error(n(198));is||(is=!0,Js=de)}}function Hn(a){var l=a,h=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(h=l.return),a=l.return;while(a)}return l.tag===3?h:null}function Br(a){if(a.tag===13){var l=a.memoizedState;if(l===null&&(a=a.alternate,a!==null&&(l=a.memoizedState)),l!==null)return l.dehydrated}return null}function as(a){if(Hn(a)!==a)throw Error(n(188))}function Er(a){var l=a.alternate;if(!l){if(l=Hn(a),l===null)throw Error(n(188));return l!==a?null:a}for(var h=a,x=l;;){var j=h.return;if(j===null)break;var I=j.alternate;if(I===null){if(x=j.return,x!==null){h=x;continue}break}if(j.child===I.child){for(I=j.child;I;){if(I===h)return as(j),a;if(I===x)return as(j),l;I=I.sibling}throw Error(n(188))}if(h.return!==x.return)h=j,x=I;else{for(var U=!1,X=j.child;X;){if(X===h){U=!0,h=j,x=I;break}if(X===x){U=!0,x=j,h=I;break}X=X.sibling}if(!U){for(X=I.child;X;){if(X===h){U=!0,h=I,x=j;break}if(X===x){U=!0,x=I,h=j;break}X=X.sibling}if(!U)throw Error(n(189))}}if(h.alternate!==x)throw Error(n(190))}if(h.tag!==3)throw Error(n(188));return h.stateNode.current===h?a:l}function mi(a){return a=Er(a),a!==null?Rt(a):null}function Rt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=Rt(a);if(l!==null)return l;a=a.sibling}return null}var Ns=t.unstable_scheduleCallback,Xn=t.unstable_cancelCallback,Ur=t.unstable_shouldYield,tr=t.unstable_requestPaint,Ot=t.unstable_now,gi=t.unstable_getCurrentPriorityLevel,Hr=t.unstable_ImmediatePriority,nr=t.unstable_UserBlockingPriority,Cr=t.unstable_NormalPriority,Ae=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,ct=null,ft=null;function At(a){if(ft&&typeof ft.onCommitFiberRoot=="function")try{ft.onCommitFiberRoot(ct,a,void 0,(a.current.flags&128)===128)}catch{}}var zt=Math.clz32?Math.clz32:un,Zn=Math.log,Ps=Math.LN2;function un(a){return a>>>=0,a===0?32:31-(Zn(a)/Ps|0)|0}var jn=64,Ls=4194304;function Ds(a){switch(a&-a){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 a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function os(a,l){var h=a.pendingLanes;if(h===0)return 0;var x=0,j=a.suspendedLanes,I=a.pingedLanes,U=h&268435455;if(U!==0){var X=U&~j;X!==0?x=Ds(X):(I&=U,I!==0&&(x=Ds(I)))}else U=h&~j,U!==0?x=Ds(U):I!==0&&(x=Ds(I));if(x===0)return 0;if(l!==0&&l!==x&&(l&j)===0&&(j=x&-x,I=l&-l,j>=I||j===16&&(I&4194240)!==0))return l;if((x&4)!==0&&(x|=h&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=x;0<l;)h=31-zt(l),j=1<<h,x|=a[h],l&=~j;return x}function Qi(a,l){switch(a){case 1:case 2:case 4:return l+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 l+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 xi(a,l){for(var h=a.suspendedLanes,x=a.pingedLanes,j=a.expirationTimes,I=a.pendingLanes;0<I;){var U=31-zt(I),X=1<<U,J=j[U];J===-1?((X&h)===0||(X&x)!==0)&&(j[U]=Qi(X,l)):J<=l&&(a.expiredLanes|=X),I&=~X}}function Ir(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function vi(){var a=jn;return jn<<=1,(jn&4194240)===0&&(jn=64),a}function Qn(a){for(var l=[],h=0;31>h;h++)l.push(a);return l}function ls(a,l,h){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-zt(l),a[l]=h}function Sn(a,l){var h=a.pendingLanes&~l;a.pendingLanes=l,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=l,a.mutableReadLanes&=l,a.entangledLanes&=l,l=a.entanglements;var x=a.eventTimes;for(a=a.expirationTimes;0<h;){var j=31-zt(h),I=1<<j;l[j]=0,x[j]=-1,a[j]=-1,h&=~I}}function Fs(a,l){var h=a.entangledLanes|=l;for(a=a.entanglements;h;){var x=31-zt(h),j=1<<x;j&l|a[x]&l&&(a[x]|=l),h&=~j}}var vt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var cs,Pt,ht,Zr,Jn,Wr=!1,sr=[],$e=null,Ue=null,ot=null,gt=new Map,Bt=new Map,pn=[],Bo="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 Ji(a,l){switch(a){case"focusin":case"focusout":$e=null;break;case"dragenter":case"dragleave":Ue=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":gt.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bt.delete(l.pointerId)}}function Vr(a,l,h,x,j,I){return a===null||a.nativeEvent!==I?(a={blockedOn:l,domEventName:h,eventSystemFlags:x,nativeEvent:I,targetContainers:[j]},l!==null&&(l=Jo(l),l!==null&&Pt(l)),a):(a.eventSystemFlags|=x,l=a.targetContainers,j!==null&&l.indexOf(j)===-1&&l.push(j),a)}function ea(a,l,h,x,j){switch(l){case"focusin":return $e=Vr($e,a,l,h,x,j),!0;case"dragenter":return Ue=Vr(Ue,a,l,h,x,j),!0;case"mouseover":return ot=Vr(ot,a,l,h,x,j),!0;case"pointerover":var I=j.pointerId;return gt.set(I,Vr(gt.get(I)||null,a,l,h,x,j)),!0;case"gotpointercapture":return I=j.pointerId,Bt.set(I,Vr(Bt.get(I)||null,a,l,h,x,j)),!0}return!1}function Pa(a){var l=ta(a.target);if(l!==null){var h=Hn(l);if(h!==null){if(l=h.tag,l===13){if(l=Br(h),l!==null){a.blockedOn=l,Jn(a.priority,function(){ht(h)});return}}else if(l===3&&h.stateNode.current.memoizedState.isDehydrated){a.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}a.blockedOn=null}function we(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var h=In(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(h===null){h=a.nativeEvent;var x=new h.constructor(h.type,h);zs=x,h.target.dispatchEvent(x),zs=null}else return l=Jo(h),l!==null&&Pt(l),a.blockedOn=h,!1;l.shift()}return!0}function q(a,l,h){we(a)&&h.delete(l)}function ne(){Wr=!1,$e!==null&&we($e)&&($e=null),Ue!==null&&we(Ue)&&(Ue=null),ot!==null&&we(ot)&&(ot=null),gt.forEach(q),Bt.forEach(q)}function ve(a,l){a.blockedOn===l&&(a.blockedOn=null,Wr||(Wr=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ne)))}function ye(a){function l(j){return ve(j,a)}if(0<sr.length){ve(sr[0],a);for(var h=1;h<sr.length;h++){var x=sr[h];x.blockedOn===a&&(x.blockedOn=null)}}for($e!==null&&ve($e,a),Ue!==null&&ve(Ue,a),ot!==null&&ve(ot,a),gt.forEach(l),Bt.forEach(l),h=0;h<pn.length;h++)x=pn[h],x.blockedOn===a&&(x.blockedOn=null);for(;0<pn.length&&(h=pn[0],h.blockedOn===null);)Pa(h),h.blockedOn===null&&pn.shift()}var qe=R.ReactCurrentBatchConfig,nt=!0;function pt(a,l,h,x){var j=vt,I=qe.transition;qe.transition=null;try{vt=1,us(a,l,h,x)}finally{vt=j,qe.transition=I}}function dn(a,l,h,x){var j=vt,I=qe.transition;qe.transition=null;try{vt=4,us(a,l,h,x)}finally{vt=j,qe.transition=I}}function us(a,l,h,x){if(nt){var j=In(a,l,h,x);if(j===null)Xd(a,l,x,mn,h),Ji(a,x);else if(ea(j,a,l,h,x))x.stopPropagation();else if(Ji(a,x),l&4&&-1<Bo.indexOf(a)){for(;j!==null;){var I=Jo(j);if(I!==null&&cs(I),I=In(a,l,h,x),I===null&&Xd(a,l,x,mn,h),I===j)break;j=I}j!==null&&x.stopPropagation()}else Xd(a,l,x,null,h)}}var mn=null;function In(a,l,h,x){if(mn=null,a=Xs(x),a=ta(a),a!==null)if(l=Hn(a),l===null)a=null;else if(h=l.tag,h===13){if(a=Br(l),a!==null)return a;a=null}else if(h===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return mn=a,null}function qr(a){switch(a){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(gi()){case Hr:return 1;case nr:return 4;case Cr:case Ae:return 16;case Ze:return 536870912;default:return 16}default:return 16}}var Qt=null,La=null,mc=null;function fg(){if(mc)return mc;var a,l=La,h=l.length,x,j="value"in Qt?Qt.value:Qt.textContent,I=j.length;for(a=0;a<h&&l[a]===j[a];a++);var U=h-a;for(x=1;x<=U&&l[h-x]===j[I-x];x++);return mc=j.slice(a,1<x?1-x:void 0)}function gc(a){var l=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&l===13&&(a=13)):a=l,a===10&&(a=13),32<=a||a===13?a:0}function xc(){return!0}function hg(){return!1}function js(a){function l(h,x,j,I,U){this._reactName=h,this._targetInst=j,this.type=x,this.nativeEvent=I,this.target=U,this.currentTarget=null;for(var X in a)a.hasOwnProperty(X)&&(h=a[X],this[X]=h?h(I):I[X]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?xc:hg,this.isPropagationStopped=hg,this}return K(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=xc)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=xc)},persist:function(){},isPersistent:xc}),l}var Da={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},zd=js(Da),Uo=K({},Da,{view:0,detail:0}),CS=js(Uo),Pd,Ld,Ho,vc=K({},Uo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Fd,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Ho&&(Ho&&a.type==="mousemove"?(Pd=a.screenX-Ho.screenX,Ld=a.screenY-Ho.screenY):Ld=Pd=0,Ho=a),Pd)},movementY:function(a){return"movementY"in a?a.movementY:Ld}}),pg=js(vc),IS=K({},vc,{dataTransfer:0}),AS=js(IS),TS=K({},Uo,{relatedTarget:0}),Dd=js(TS),$S=K({},Da,{animationName:0,elapsedTime:0,pseudoElement:0}),MS=js($S),RS=K({},Da,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),OS=js(RS),zS=K({},Da,{data:0}),mg=js(zS),PS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},LS={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"},DS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function FS(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=DS[a])?!!l[a]:!1}function Fd(){return FS}var BS=K({},Uo,{key:function(a){if(a.key){var l=PS[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=gc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?LS[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Fd,charCode:function(a){return a.type==="keypress"?gc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?gc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),US=js(BS),HS=K({},vc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),gg=js(HS),ZS=K({},Uo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Fd}),WS=js(ZS),VS=K({},Da,{propertyName:0,elapsedTime:0,pseudoElement:0}),qS=js(VS),GS=K({},vc,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),KS=js(GS),YS=[9,13,27,32],Bd=u&&"CompositionEvent"in window,Zo=null;u&&"documentMode"in document&&(Zo=document.documentMode);var XS=u&&"TextEvent"in window&&!Zo,xg=u&&(!Bd||Zo&&8<Zo&&11>=Zo),vg=" ",yg=!1;function bg(a,l){switch(a){case"keyup":return YS.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kg(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Fa=!1;function QS(a,l){switch(a){case"compositionend":return kg(l);case"keypress":return l.which!==32?null:(yg=!0,vg);case"textInput":return a=l.data,a===vg&&yg?null:a;default:return null}}function JS(a,l){if(Fa)return a==="compositionend"||!Bd&&bg(a,l)?(a=fg(),mc=La=Qt=null,Fa=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return xg&&l.locale!=="ko"?null:l.data;default:return null}}var e_={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 wg(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!e_[a.type]:l==="textarea"}function Ng(a,l,h,x){Q(x),l=Nc(l,"onChange"),0<l.length&&(h=new zd("onChange","change",null,h,x),a.push({event:h,listeners:l}))}var Wo=null,Vo=null;function t_(a){Bg(a,0)}function yc(a){var l=Wa(a);if(Se(l))return a}function n_(a,l){if(a==="change")return l}var jg=!1;if(u){var Ud;if(u){var Hd="oninput"in document;if(!Hd){var Sg=document.createElement("div");Sg.setAttribute("oninput","return;"),Hd=typeof Sg.oninput=="function"}Ud=Hd}else Ud=!1;jg=Ud&&(!document.documentMode||9<document.documentMode)}function _g(){Wo&&(Wo.detachEvent("onpropertychange",Eg),Vo=Wo=null)}function Eg(a){if(a.propertyName==="value"&&yc(Vo)){var l=[];Ng(l,Vo,a,Xs(a)),$t(t_,l)}}function s_(a,l,h){a==="focusin"?(_g(),Wo=l,Vo=h,Wo.attachEvent("onpropertychange",Eg)):a==="focusout"&&_g()}function r_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return yc(Vo)}function i_(a,l){if(a==="click")return yc(l)}function a_(a,l){if(a==="input"||a==="change")return yc(l)}function o_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var rr=typeof Object.is=="function"?Object.is:o_;function qo(a,l){if(rr(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var h=Object.keys(a),x=Object.keys(l);if(h.length!==x.length)return!1;for(x=0;x<h.length;x++){var j=h[x];if(!f.call(l,j)||!rr(a[j],l[j]))return!1}return!0}function Cg(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Ig(a,l){var h=Cg(a);a=0;for(var x;h;){if(h.nodeType===3){if(x=a+h.textContent.length,a<=l&&x>=l)return{node:h,offset:l-a};a=x}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Cg(h)}}function Ag(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Ag(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Tg(){for(var a=window,l=re();l instanceof a.HTMLIFrameElement;){try{var h=typeof l.contentWindow.location.href=="string"}catch{h=!1}if(h)a=l.contentWindow;else break;l=re(a.document)}return l}function Zd(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l&&(l==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||l==="textarea"||a.contentEditable==="true")}function l_(a){var l=Tg(),h=a.focusedElem,x=a.selectionRange;if(l!==h&&h&&h.ownerDocument&&Ag(h.ownerDocument.documentElement,h)){if(x!==null&&Zd(h)){if(l=x.start,a=x.end,a===void 0&&(a=l),"selectionStart"in h)h.selectionStart=l,h.selectionEnd=Math.min(a,h.value.length);else if(a=(l=h.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var j=h.textContent.length,I=Math.min(x.start,j);x=x.end===void 0?I:Math.min(x.end,j),!a.extend&&I>x&&(j=x,x=I,I=j),j=Ig(h,I);var U=Ig(h,x);j&&U&&(a.rangeCount!==1||a.anchorNode!==j.node||a.anchorOffset!==j.offset||a.focusNode!==U.node||a.focusOffset!==U.offset)&&(l=l.createRange(),l.setStart(j.node,j.offset),a.removeAllRanges(),I>x?(a.addRange(l),a.extend(U.node,U.offset)):(l.setEnd(U.node,U.offset),a.addRange(l)))}}for(l=[],a=h;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<l.length;h++)a=l[h],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var c_=u&&"documentMode"in document&&11>=document.documentMode,Ba=null,Wd=null,Go=null,Vd=!1;function $g(a,l,h){var x=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Vd||Ba==null||Ba!==re(x)||(x=Ba,"selectionStart"in x&&Zd(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Go&&qo(Go,x)||(Go=x,x=Nc(Wd,"onSelect"),0<x.length&&(l=new zd("onSelect","select",null,l,h),a.push({event:l,listeners:x}),l.target=Ba)))}function bc(a,l){var h={};return h[a.toLowerCase()]=l.toLowerCase(),h["Webkit"+a]="webkit"+l,h["Moz"+a]="moz"+l,h}var Ua={animationend:bc("Animation","AnimationEnd"),animationiteration:bc("Animation","AnimationIteration"),animationstart:bc("Animation","AnimationStart"),transitionend:bc("Transition","TransitionEnd")},qd={},Mg={};u&&(Mg=document.createElement("div").style,"AnimationEvent"in window||(delete Ua.animationend.animation,delete Ua.animationiteration.animation,delete Ua.animationstart.animation),"TransitionEvent"in window||delete Ua.transitionend.transition);function kc(a){if(qd[a])return qd[a];if(!Ua[a])return a;var l=Ua[a],h;for(h in l)if(l.hasOwnProperty(h)&&h in Mg)return qd[a]=l[h];return a}var Rg=kc("animationend"),Og=kc("animationiteration"),zg=kc("animationstart"),Pg=kc("transitionend"),Lg=new Map,Dg="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 yi(a,l){Lg.set(a,l),o(l,[a])}for(var Gd=0;Gd<Dg.length;Gd++){var Kd=Dg[Gd],u_=Kd.toLowerCase(),d_=Kd[0].toUpperCase()+Kd.slice(1);yi(u_,"on"+d_)}yi(Rg,"onAnimationEnd"),yi(Og,"onAnimationIteration"),yi(zg,"onAnimationStart"),yi("dblclick","onDoubleClick"),yi("focusin","onFocus"),yi("focusout","onBlur"),yi(Pg,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("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 Ko="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(" "),f_=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ko));function Fg(a,l,h){var x=a.type||"unknown-event";a.currentTarget=h,pi(x,l,void 0,a),a.currentTarget=null}function Bg(a,l){l=(l&4)!==0;for(var h=0;h<a.length;h++){var x=a[h],j=x.event;x=x.listeners;e:{var I=void 0;if(l)for(var U=x.length-1;0<=U;U--){var X=x[U],J=X.instance,de=X.currentTarget;if(X=X.listener,J!==I&&j.isPropagationStopped())break e;Fg(j,X,de),I=J}else for(U=0;U<x.length;U++){if(X=x[U],J=X.instance,de=X.currentTarget,X=X.listener,J!==I&&j.isPropagationStopped())break e;Fg(j,X,de),I=J}}}if(is)throw a=Js,is=!1,Js=null,a}function Ut(a,l){var h=l[sf];h===void 0&&(h=l[sf]=new Set);var x=a+"__bubble";h.has(x)||(Ug(l,a,2,!1),h.add(x))}function Yd(a,l,h){var x=0;l&&(x|=4),Ug(h,a,x,l)}var wc="_reactListening"+Math.random().toString(36).slice(2);function Yo(a){if(!a[wc]){a[wc]=!0,r.forEach(function(h){h!=="selectionchange"&&(f_.has(h)||Yd(h,!1,a),Yd(h,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[wc]||(l[wc]=!0,Yd("selectionchange",!1,l))}}function Ug(a,l,h,x){switch(qr(l)){case 1:var j=pt;break;case 4:j=dn;break;default:j=us}h=j.bind(null,l,h,a),j=void 0,!De||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(j=!0),x?j!==void 0?a.addEventListener(l,h,{capture:!0,passive:j}):a.addEventListener(l,h,!0):j!==void 0?a.addEventListener(l,h,{passive:j}):a.addEventListener(l,h,!1)}function Xd(a,l,h,x,j){var I=x;if((l&1)===0&&(l&2)===0&&x!==null)e:for(;;){if(x===null)return;var U=x.tag;if(U===3||U===4){var X=x.stateNode.containerInfo;if(X===j||X.nodeType===8&&X.parentNode===j)break;if(U===4)for(U=x.return;U!==null;){var J=U.tag;if((J===3||J===4)&&(J=U.stateNode.containerInfo,J===j||J.nodeType===8&&J.parentNode===j))return;U=U.return}for(;X!==null;){if(U=ta(X),U===null)return;if(J=U.tag,J===5||J===6){x=I=U;continue e}X=X.parentNode}}x=x.return}$t(function(){var de=I,Ee=Xs(h),Ce=[];e:{var _e=Lg.get(a);if(_e!==void 0){var He=zd,Ve=a;switch(a){case"keypress":if(gc(h)===0)break e;case"keydown":case"keyup":He=US;break;case"focusin":Ve="focus",He=Dd;break;case"focusout":Ve="blur",He=Dd;break;case"beforeblur":case"afterblur":He=Dd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=pg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=AS;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=WS;break;case Rg:case Og:case zg:He=MS;break;case Pg:He=qS;break;case"scroll":He=CS;break;case"wheel":He=KS;break;case"copy":case"cut":case"paste":He=OS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=gg}var Ke=(l&4)!==0,fn=!Ke&&a==="scroll",oe=Ke?_e!==null?_e+"Capture":null:_e;Ke=[];for(var se=de,le;se!==null;){le=se;var Me=le.stateNode;if(le.tag===5&&Me!==null&&(le=Me,oe!==null&&(Me=Be(se,oe),Me!=null&&Ke.push(Xo(se,Me,le)))),fn)break;se=se.return}0<Ke.length&&(_e=new He(_e,Ve,null,h,Ee),Ce.push({event:_e,listeners:Ke}))}}if((l&7)===0){e:{if(_e=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",_e&&h!==zs&&(Ve=h.relatedTarget||h.fromElement)&&(ta(Ve)||Ve[Gr]))break e;if((He||_e)&&(_e=Ee.window===Ee?Ee:(_e=Ee.ownerDocument)?_e.defaultView||_e.parentWindow:window,He?(Ve=h.relatedTarget||h.toElement,He=de,Ve=Ve?ta(Ve):null,Ve!==null&&(fn=Hn(Ve),Ve!==fn||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(He=null,Ve=de),He!==Ve)){if(Ke=pg,Me="onMouseLeave",oe="onMouseEnter",se="mouse",(a==="pointerout"||a==="pointerover")&&(Ke=gg,Me="onPointerLeave",oe="onPointerEnter",se="pointer"),fn=He==null?_e:Wa(He),le=Ve==null?_e:Wa(Ve),_e=new Ke(Me,se+"leave",He,h,Ee),_e.target=fn,_e.relatedTarget=le,Me=null,ta(Ee)===de&&(Ke=new Ke(oe,se+"enter",Ve,h,Ee),Ke.target=le,Ke.relatedTarget=fn,Me=Ke),fn=Me,He&&Ve)t:{for(Ke=He,oe=Ve,se=0,le=Ke;le;le=Ha(le))se++;for(le=0,Me=oe;Me;Me=Ha(Me))le++;for(;0<se-le;)Ke=Ha(Ke),se--;for(;0<le-se;)oe=Ha(oe),le--;for(;se--;){if(Ke===oe||oe!==null&&Ke===oe.alternate)break t;Ke=Ha(Ke),oe=Ha(oe)}Ke=null}else Ke=null;He!==null&&Hg(Ce,_e,He,Ke,!1),Ve!==null&&fn!==null&&Hg(Ce,fn,Ve,Ke,!0)}}e:{if(_e=de?Wa(de):window,He=_e.nodeName&&_e.nodeName.toLowerCase(),He==="select"||He==="input"&&_e.type==="file")var Ye=n_;else if(wg(_e))if(jg)Ye=a_;else{Ye=r_;var rt=s_}else(He=_e.nodeName)&&He.toLowerCase()==="input"&&(_e.type==="checkbox"||_e.type==="radio")&&(Ye=i_);if(Ye&&(Ye=Ye(a,de))){Ng(Ce,Ye,h,Ee);break e}rt&&rt(a,_e,de),a==="focusout"&&(rt=_e._wrapperState)&&rt.controlled&&_e.type==="number"&&tt(_e,"number",_e.value)}switch(rt=de?Wa(de):window,a){case"focusin":(wg(rt)||rt.contentEditable==="true")&&(Ba=rt,Wd=de,Go=null);break;case"focusout":Go=Wd=Ba=null;break;case"mousedown":Vd=!0;break;case"contextmenu":case"mouseup":case"dragend":Vd=!1,$g(Ce,h,Ee);break;case"selectionchange":if(c_)break;case"keydown":case"keyup":$g(Ce,h,Ee)}var it;if(Bd)e:{switch(a){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else Fa?bg(a,h)&&(lt="onCompositionEnd"):a==="keydown"&&h.keyCode===229&&(lt="onCompositionStart");lt&&(xg&&h.locale!=="ko"&&(Fa||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&Fa&&(it=fg()):(Qt=Ee,La="value"in Qt?Qt.value:Qt.textContent,Fa=!0)),rt=Nc(de,lt),0<rt.length&&(lt=new mg(lt,a,null,h,Ee),Ce.push({event:lt,listeners:rt}),it?lt.data=it:(it=kg(h),it!==null&&(lt.data=it)))),(it=XS?QS(a,h):JS(a,h))&&(de=Nc(de,"onBeforeInput"),0<de.length&&(Ee=new mg("onBeforeInput","beforeinput",null,h,Ee),Ce.push({event:Ee,listeners:de}),Ee.data=it))}Bg(Ce,l)})}function Xo(a,l,h){return{instance:a,listener:l,currentTarget:h}}function Nc(a,l){for(var h=l+"Capture",x=[];a!==null;){var j=a,I=j.stateNode;j.tag===5&&I!==null&&(j=I,I=Be(a,h),I!=null&&x.unshift(Xo(a,I,j)),I=Be(a,l),I!=null&&x.push(Xo(a,I,j))),a=a.return}return x}function Ha(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Hg(a,l,h,x,j){for(var I=l._reactName,U=[];h!==null&&h!==x;){var X=h,J=X.alternate,de=X.stateNode;if(J!==null&&J===x)break;X.tag===5&&de!==null&&(X=de,j?(J=Be(h,I),J!=null&&U.unshift(Xo(h,J,X))):j||(J=Be(h,I),J!=null&&U.push(Xo(h,J,X)))),h=h.return}U.length!==0&&a.push({event:l,listeners:U})}var h_=/\r\n?/g,p_=/\u0000|\uFFFD/g;function Zg(a){return(typeof a=="string"?a:""+a).replace(h_,`
38
- `).replace(p_,"")}function jc(a,l,h){if(l=Zg(l),Zg(a)!==l&&h)throw Error(n(425))}function Sc(){}var Qd=null,Jd=null;function ef(a,l){return a==="textarea"||a==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var tf=typeof setTimeout=="function"?setTimeout:void 0,m_=typeof clearTimeout=="function"?clearTimeout:void 0,Wg=typeof Promise=="function"?Promise:void 0,g_=typeof queueMicrotask=="function"?queueMicrotask:typeof Wg<"u"?function(a){return Wg.resolve(null).then(a).catch(x_)}:tf;function x_(a){setTimeout(function(){throw a})}function nf(a,l){var h=l,x=0;do{var j=h.nextSibling;if(a.removeChild(h),j&&j.nodeType===8)if(h=j.data,h==="/$"){if(x===0){a.removeChild(j),ye(l);return}x--}else h!=="$"&&h!=="$?"&&h!=="$!"||x++;h=j}while(h);ye(l)}function bi(a){for(;a!=null;a=a.nextSibling){var l=a.nodeType;if(l===1||l===3)break;if(l===8){if(l=a.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return a}function Vg(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="$"||h==="$!"||h==="$?"){if(l===0)return a;l--}else h==="/$"&&l++}a=a.previousSibling}return null}var Za=Math.random().toString(36).slice(2),Ar="__reactFiber$"+Za,Qo="__reactProps$"+Za,Gr="__reactContainer$"+Za,sf="__reactEvents$"+Za,v_="__reactListeners$"+Za,y_="__reactHandles$"+Za;function ta(a){var l=a[Ar];if(l)return l;for(var h=a.parentNode;h;){if(l=h[Gr]||h[Ar]){if(h=l.alternate,l.child!==null||h!==null&&h.child!==null)for(a=Vg(a);a!==null;){if(h=a[Ar])return h;a=Vg(a)}return l}a=h,h=a.parentNode}return null}function Jo(a){return a=a[Ar]||a[Gr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Wa(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function _c(a){return a[Qo]||null}var rf=[],Va=-1;function ki(a){return{current:a}}function Ht(a){0>Va||(a.current=rf[Va],rf[Va]=null,Va--)}function Dt(a,l){Va++,rf[Va]=a.current,a.current=l}var wi={},Wn=ki(wi),ds=ki(!1),na=wi;function qa(a,l){var h=a.type.contextTypes;if(!h)return wi;var x=a.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===l)return x.__reactInternalMemoizedMaskedChildContext;var j={},I;for(I in h)j[I]=l[I];return x&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=j),j}function fs(a){return a=a.childContextTypes,a!=null}function Ec(){Ht(ds),Ht(Wn)}function qg(a,l,h){if(Wn.current!==wi)throw Error(n(168));Dt(Wn,l),Dt(ds,h)}function Gg(a,l,h){var x=a.stateNode;if(l=l.childContextTypes,typeof x.getChildContext!="function")return h;x=x.getChildContext();for(var j in x)if(!(j in l))throw Error(n(108,ke(a)||"Unknown",j));return K({},h,x)}function Cc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||wi,na=Wn.current,Dt(Wn,a),Dt(ds,ds.current),!0}function Kg(a,l,h){var x=a.stateNode;if(!x)throw Error(n(169));h?(a=Gg(a,l,na),x.__reactInternalMemoizedMergedChildContext=a,Ht(ds),Ht(Wn),Dt(Wn,a)):Ht(ds),Dt(ds,h)}var Kr=null,Ic=!1,af=!1;function Yg(a){Kr===null?Kr=[a]:Kr.push(a)}function b_(a){Ic=!0,Yg(a)}function Ni(){if(!af&&Kr!==null){af=!0;var a=0,l=vt;try{var h=Kr;for(vt=1;a<h.length;a++){var x=h[a];do x=x(!0);while(x!==null)}Kr=null,Ic=!1}catch(j){throw Kr!==null&&(Kr=Kr.slice(a+1)),Ns(Hr,Ni),j}finally{vt=l,af=!1}}return null}var Ga=[],Ka=0,Ac=null,Tc=0,Bs=[],Us=0,sa=null,Yr=1,Xr="";function ra(a,l){Ga[Ka++]=Tc,Ga[Ka++]=Ac,Ac=a,Tc=l}function Xg(a,l,h){Bs[Us++]=Yr,Bs[Us++]=Xr,Bs[Us++]=sa,sa=a;var x=Yr;a=Xr;var j=32-zt(x)-1;x&=~(1<<j),h+=1;var I=32-zt(l)+j;if(30<I){var U=j-j%5;I=(x&(1<<U)-1).toString(32),x>>=U,j-=U,Yr=1<<32-zt(l)+j|h<<j|x,Xr=I+a}else Yr=1<<I|h<<j|x,Xr=a}function of(a){a.return!==null&&(ra(a,1),Xg(a,1,0))}function lf(a){for(;a===Ac;)Ac=Ga[--Ka],Ga[Ka]=null,Tc=Ga[--Ka],Ga[Ka]=null;for(;a===sa;)sa=Bs[--Us],Bs[Us]=null,Xr=Bs[--Us],Bs[Us]=null,Yr=Bs[--Us],Bs[Us]=null}var Ss=null,_s=null,qt=!1,ir=null;function Qg(a,l){var h=Vs(5,null,null,0);h.elementType="DELETED",h.stateNode=l,h.return=a,l=a.deletions,l===null?(a.deletions=[h],a.flags|=16):l.push(h)}function Jg(a,l){switch(a.tag){case 5:var h=a.type;return l=l.nodeType!==1||h.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,Ss=a,_s=bi(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,Ss=a,_s=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(h=sa!==null?{id:Yr,overflow:Xr}:null,a.memoizedState={dehydrated:l,treeContext:h,retryLane:1073741824},h=Vs(18,null,null,0),h.stateNode=l,h.return=a,a.child=h,Ss=a,_s=null,!0):!1;default:return!1}}function cf(a){return(a.mode&1)!==0&&(a.flags&128)===0}function uf(a){if(qt){var l=_s;if(l){var h=l;if(!Jg(a,l)){if(cf(a))throw Error(n(418));l=bi(h.nextSibling);var x=Ss;l&&Jg(a,l)?Qg(x,h):(a.flags=a.flags&-4097|2,qt=!1,Ss=a)}}else{if(cf(a))throw Error(n(418));a.flags=a.flags&-4097|2,qt=!1,Ss=a}}}function ex(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Ss=a}function $c(a){if(a!==Ss)return!1;if(!qt)return ex(a),qt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!ef(a.type,a.memoizedProps)),l&&(l=_s)){if(cf(a))throw tx(),Error(n(418));for(;l;)Qg(a,l),l=bi(l.nextSibling)}if(ex(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,l=0;a;){if(a.nodeType===8){var h=a.data;if(h==="/$"){if(l===0){_s=bi(a.nextSibling);break e}l--}else h!=="$"&&h!=="$!"&&h!=="$?"||l++}a=a.nextSibling}_s=null}}else _s=Ss?bi(a.stateNode.nextSibling):null;return!0}function tx(){for(var a=_s;a;)a=bi(a.nextSibling)}function Ya(){_s=Ss=null,qt=!1}function df(a){ir===null?ir=[a]:ir.push(a)}var k_=R.ReactCurrentBatchConfig;function el(a,l,h){if(a=h.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(n(309));var x=h.stateNode}if(!x)throw Error(n(147,a));var j=x,I=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===I?l.ref:(l=function(U){var X=j.refs;U===null?delete X[I]:X[I]=U},l._stringRef=I,l)}if(typeof a!="string")throw Error(n(284));if(!h._owner)throw Error(n(290,a))}return a}function Mc(a,l){throw a=Object.prototype.toString.call(l),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function nx(a){var l=a._init;return l(a._payload)}function sx(a){function l(oe,se){if(a){var le=oe.deletions;le===null?(oe.deletions=[se],oe.flags|=16):le.push(se)}}function h(oe,se){if(!a)return null;for(;se!==null;)l(oe,se),se=se.sibling;return null}function x(oe,se){for(oe=new Map;se!==null;)se.key!==null?oe.set(se.key,se):oe.set(se.index,se),se=se.sibling;return oe}function j(oe,se){return oe=Ti(oe,se),oe.index=0,oe.sibling=null,oe}function I(oe,se,le){return oe.index=le,a?(le=oe.alternate,le!==null?(le=le.index,le<se?(oe.flags|=2,se):le):(oe.flags|=2,se)):(oe.flags|=1048576,se)}function U(oe){return a&&oe.alternate===null&&(oe.flags|=2),oe}function X(oe,se,le,Me){return se===null||se.tag!==6?(se=nh(le,oe.mode,Me),se.return=oe,se):(se=j(se,le),se.return=oe,se)}function J(oe,se,le,Me){var Ye=le.type;return Ye===F?Ee(oe,se,le.props.children,Me,le.key):se!==null&&(se.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===L&&nx(Ye)===se.type)?(Me=j(se,le.props),Me.ref=el(oe,se,le),Me.return=oe,Me):(Me=su(le.type,le.key,le.props,null,oe.mode,Me),Me.ref=el(oe,se,le),Me.return=oe,Me)}function de(oe,se,le,Me){return se===null||se.tag!==4||se.stateNode.containerInfo!==le.containerInfo||se.stateNode.implementation!==le.implementation?(se=sh(le,oe.mode,Me),se.return=oe,se):(se=j(se,le.children||[]),se.return=oe,se)}function Ee(oe,se,le,Me,Ye){return se===null||se.tag!==7?(se=fa(le,oe.mode,Me,Ye),se.return=oe,se):(se=j(se,le),se.return=oe,se)}function Ce(oe,se,le){if(typeof se=="string"&&se!==""||typeof se=="number")return se=nh(""+se,oe.mode,le),se.return=oe,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case D:return le=su(se.type,se.key,se.props,null,oe.mode,le),le.ref=el(oe,null,se),le.return=oe,le;case P:return se=sh(se,oe.mode,le),se.return=oe,se;case L:var Me=se._init;return Ce(oe,Me(se._payload),le)}if(et(se)||G(se))return se=fa(se,oe.mode,le,null),se.return=oe,se;Mc(oe,se)}return null}function _e(oe,se,le,Me){var Ye=se!==null?se.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Ye!==null?null:X(oe,se,""+le,Me);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case D:return le.key===Ye?J(oe,se,le,Me):null;case P:return le.key===Ye?de(oe,se,le,Me):null;case L:return Ye=le._init,_e(oe,se,Ye(le._payload),Me)}if(et(le)||G(le))return Ye!==null?null:Ee(oe,se,le,Me,null);Mc(oe,le)}return null}function He(oe,se,le,Me,Ye){if(typeof Me=="string"&&Me!==""||typeof Me=="number")return oe=oe.get(le)||null,X(se,oe,""+Me,Ye);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case D:return oe=oe.get(Me.key===null?le:Me.key)||null,J(se,oe,Me,Ye);case P:return oe=oe.get(Me.key===null?le:Me.key)||null,de(se,oe,Me,Ye);case L:var rt=Me._init;return He(oe,se,le,rt(Me._payload),Ye)}if(et(Me)||G(Me))return oe=oe.get(le)||null,Ee(se,oe,Me,Ye,null);Mc(se,Me)}return null}function Ve(oe,se,le,Me){for(var Ye=null,rt=null,it=se,lt=se=0,$n=null;it!==null&&lt<le.length;lt++){it.index>lt?($n=it,it=null):$n=it.sibling;var St=_e(oe,it,le[lt],Me);if(St===null){it===null&&(it=$n);break}a&&it&&St.alternate===null&&l(oe,it),se=I(St,se,lt),rt===null?Ye=St:rt.sibling=St,rt=St,it=$n}if(lt===le.length)return h(oe,it),qt&&ra(oe,lt),Ye;if(it===null){for(;lt<le.length;lt++)it=Ce(oe,le[lt],Me),it!==null&&(se=I(it,se,lt),rt===null?Ye=it:rt.sibling=it,rt=it);return qt&&ra(oe,lt),Ye}for(it=x(oe,it);lt<le.length;lt++)$n=He(it,oe,lt,le[lt],Me),$n!==null&&(a&&$n.alternate!==null&&it.delete($n.key===null?lt:$n.key),se=I($n,se,lt),rt===null?Ye=$n:rt.sibling=$n,rt=$n);return a&&it.forEach(function($i){return l(oe,$i)}),qt&&ra(oe,lt),Ye}function Ke(oe,se,le,Me){var Ye=G(le);if(typeof Ye!="function")throw Error(n(150));if(le=Ye.call(le),le==null)throw Error(n(151));for(var rt=Ye=null,it=se,lt=se=0,$n=null,St=le.next();it!==null&&!St.done;lt++,St=le.next()){it.index>lt?($n=it,it=null):$n=it.sibling;var $i=_e(oe,it,St.value,Me);if($i===null){it===null&&(it=$n);break}a&&it&&$i.alternate===null&&l(oe,it),se=I($i,se,lt),rt===null?Ye=$i:rt.sibling=$i,rt=$i,it=$n}if(St.done)return h(oe,it),qt&&ra(oe,lt),Ye;if(it===null){for(;!St.done;lt++,St=le.next())St=Ce(oe,St.value,Me),St!==null&&(se=I(St,se,lt),rt===null?Ye=St:rt.sibling=St,rt=St);return qt&&ra(oe,lt),Ye}for(it=x(oe,it);!St.done;lt++,St=le.next())St=He(it,oe,lt,St.value,Me),St!==null&&(a&&St.alternate!==null&&it.delete(St.key===null?lt:St.key),se=I(St,se,lt),rt===null?Ye=St:rt.sibling=St,rt=St);return a&&it.forEach(function(eE){return l(oe,eE)}),qt&&ra(oe,lt),Ye}function fn(oe,se,le,Me){if(typeof le=="object"&&le!==null&&le.type===F&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case D:e:{for(var Ye=le.key,rt=se;rt!==null;){if(rt.key===Ye){if(Ye=le.type,Ye===F){if(rt.tag===7){h(oe,rt.sibling),se=j(rt,le.props.children),se.return=oe,oe=se;break e}}else if(rt.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===L&&nx(Ye)===rt.type){h(oe,rt.sibling),se=j(rt,le.props),se.ref=el(oe,rt,le),se.return=oe,oe=se;break e}h(oe,rt);break}else l(oe,rt);rt=rt.sibling}le.type===F?(se=fa(le.props.children,oe.mode,Me,le.key),se.return=oe,oe=se):(Me=su(le.type,le.key,le.props,null,oe.mode,Me),Me.ref=el(oe,se,le),Me.return=oe,oe=Me)}return U(oe);case P:e:{for(rt=le.key;se!==null;){if(se.key===rt)if(se.tag===4&&se.stateNode.containerInfo===le.containerInfo&&se.stateNode.implementation===le.implementation){h(oe,se.sibling),se=j(se,le.children||[]),se.return=oe,oe=se;break e}else{h(oe,se);break}else l(oe,se);se=se.sibling}se=sh(le,oe.mode,Me),se.return=oe,oe=se}return U(oe);case L:return rt=le._init,fn(oe,se,rt(le._payload),Me)}if(et(le))return Ve(oe,se,le,Me);if(G(le))return Ke(oe,se,le,Me);Mc(oe,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,se!==null&&se.tag===6?(h(oe,se.sibling),se=j(se,le),se.return=oe,oe=se):(h(oe,se),se=nh(le,oe.mode,Me),se.return=oe,oe=se),U(oe)):h(oe,se)}return fn}var Xa=sx(!0),rx=sx(!1),Rc=ki(null),Oc=null,Qa=null,ff=null;function hf(){ff=Qa=Oc=null}function pf(a){var l=Rc.current;Ht(Rc),a._currentValue=l}function mf(a,l,h){for(;a!==null;){var x=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,x!==null&&(x.childLanes|=l)):x!==null&&(x.childLanes&l)!==l&&(x.childLanes|=l),a===h)break;a=a.return}}function Ja(a,l){Oc=a,ff=Qa=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(hs=!0),a.firstContext=null)}function Hs(a){var l=a._currentValue;if(ff!==a)if(a={context:a,memoizedValue:l,next:null},Qa===null){if(Oc===null)throw Error(n(308));Qa=a,Oc.dependencies={lanes:0,firstContext:a}}else Qa=Qa.next=a;return l}var ia=null;function gf(a){ia===null?ia=[a]:ia.push(a)}function ix(a,l,h,x){var j=l.interleaved;return j===null?(h.next=h,gf(l)):(h.next=j.next,j.next=h),l.interleaved=h,Qr(a,x)}function Qr(a,l){a.lanes|=l;var h=a.alternate;for(h!==null&&(h.lanes|=l),h=a,a=a.return;a!==null;)a.childLanes|=l,h=a.alternate,h!==null&&(h.childLanes|=l),h=a,a=a.return;return h.tag===3?h.stateNode:null}var ji=!1;function xf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ax(a,l){a=a.updateQueue,l.updateQueue===a&&(l.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Jr(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function Si(a,l,h){var x=a.updateQueue;if(x===null)return null;if(x=x.shared,(kt&2)!==0){var j=x.pending;return j===null?l.next=l:(l.next=j.next,j.next=l),x.pending=l,Qr(a,h)}return j=x.interleaved,j===null?(l.next=l,gf(x)):(l.next=j.next,j.next=l),x.interleaved=l,Qr(a,h)}function zc(a,l,h){if(l=l.updateQueue,l!==null&&(l=l.shared,(h&4194240)!==0)){var x=l.lanes;x&=a.pendingLanes,h|=x,l.lanes=h,Fs(a,h)}}function ox(a,l){var h=a.updateQueue,x=a.alternate;if(x!==null&&(x=x.updateQueue,h===x)){var j=null,I=null;if(h=h.firstBaseUpdate,h!==null){do{var U={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};I===null?j=I=U:I=I.next=U,h=h.next}while(h!==null);I===null?j=I=l:I=I.next=l}else j=I=l;h={baseState:x.baseState,firstBaseUpdate:j,lastBaseUpdate:I,shared:x.shared,effects:x.effects},a.updateQueue=h;return}a=h.lastBaseUpdate,a===null?h.firstBaseUpdate=l:a.next=l,h.lastBaseUpdate=l}function Pc(a,l,h,x){var j=a.updateQueue;ji=!1;var I=j.firstBaseUpdate,U=j.lastBaseUpdate,X=j.shared.pending;if(X!==null){j.shared.pending=null;var J=X,de=J.next;J.next=null,U===null?I=de:U.next=de,U=J;var Ee=a.alternate;Ee!==null&&(Ee=Ee.updateQueue,X=Ee.lastBaseUpdate,X!==U&&(X===null?Ee.firstBaseUpdate=de:X.next=de,Ee.lastBaseUpdate=J))}if(I!==null){var Ce=j.baseState;U=0,Ee=de=J=null,X=I;do{var _e=X.lane,He=X.eventTime;if((x&_e)===_e){Ee!==null&&(Ee=Ee.next={eventTime:He,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Ve=a,Ke=X;switch(_e=l,He=h,Ke.tag){case 1:if(Ve=Ke.payload,typeof Ve=="function"){Ce=Ve.call(He,Ce,_e);break e}Ce=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Ke.payload,_e=typeof Ve=="function"?Ve.call(He,Ce,_e):Ve,_e==null)break e;Ce=K({},Ce,_e);break e;case 2:ji=!0}}X.callback!==null&&X.lane!==0&&(a.flags|=64,_e=j.effects,_e===null?j.effects=[X]:_e.push(X))}else He={eventTime:He,lane:_e,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Ee===null?(de=Ee=He,J=Ce):Ee=Ee.next=He,U|=_e;if(X=X.next,X===null){if(X=j.shared.pending,X===null)break;_e=X,X=_e.next,_e.next=null,j.lastBaseUpdate=_e,j.shared.pending=null}}while(!0);if(Ee===null&&(J=Ce),j.baseState=J,j.firstBaseUpdate=de,j.lastBaseUpdate=Ee,l=j.shared.interleaved,l!==null){j=l;do U|=j.lane,j=j.next;while(j!==l)}else I===null&&(j.shared.lanes=0);la|=U,a.lanes=U,a.memoizedState=Ce}}function lx(a,l,h){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var x=a[l],j=x.callback;if(j!==null){if(x.callback=null,x=h,typeof j!="function")throw Error(n(191,j));j.call(x)}}}var tl={},Tr=ki(tl),nl=ki(tl),sl=ki(tl);function aa(a){if(a===tl)throw Error(n(174));return a}function vf(a,l){switch(Dt(sl,l),Dt(nl,a),Dt(Tr,tl),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:an(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=an(l,a)}Ht(Tr),Dt(Tr,l)}function eo(){Ht(Tr),Ht(nl),Ht(sl)}function cx(a){aa(sl.current);var l=aa(Tr.current),h=an(l,a.type);l!==h&&(Dt(nl,a),Dt(Tr,h))}function yf(a){nl.current===a&&(Ht(Tr),Ht(nl))}var Jt=ki(0);function Lc(a){for(var l=a;l!==null;){if(l.tag===13){var h=l.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var bf=[];function kf(){for(var a=0;a<bf.length;a++)bf[a]._workInProgressVersionPrimary=null;bf.length=0}var Dc=R.ReactCurrentDispatcher,wf=R.ReactCurrentBatchConfig,oa=0,en=null,_n=null,An=null,Fc=!1,rl=!1,il=0,w_=0;function Vn(){throw Error(n(321))}function Nf(a,l){if(l===null)return!1;for(var h=0;h<l.length&&h<a.length;h++)if(!rr(a[h],l[h]))return!1;return!0}function jf(a,l,h,x,j,I){if(oa=I,en=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Dc.current=a===null||a.memoizedState===null?__:E_,a=h(x,j),rl){I=0;do{if(rl=!1,il=0,25<=I)throw Error(n(301));I+=1,An=_n=null,l.updateQueue=null,Dc.current=C_,a=h(x,j)}while(rl)}if(Dc.current=Hc,l=_n!==null&&_n.next!==null,oa=0,An=_n=en=null,Fc=!1,l)throw Error(n(300));return a}function Sf(){var a=il!==0;return il=0,a}function $r(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return An===null?en.memoizedState=An=a:An=An.next=a,An}function Zs(){if(_n===null){var a=en.alternate;a=a!==null?a.memoizedState:null}else a=_n.next;var l=An===null?en.memoizedState:An.next;if(l!==null)An=l,_n=a;else{if(a===null)throw Error(n(310));_n=a,a={memoizedState:_n.memoizedState,baseState:_n.baseState,baseQueue:_n.baseQueue,queue:_n.queue,next:null},An===null?en.memoizedState=An=a:An=An.next=a}return An}function al(a,l){return typeof l=="function"?l(a):l}function _f(a){var l=Zs(),h=l.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=a;var x=_n,j=x.baseQueue,I=h.pending;if(I!==null){if(j!==null){var U=j.next;j.next=I.next,I.next=U}x.baseQueue=j=I,h.pending=null}if(j!==null){I=j.next,x=x.baseState;var X=U=null,J=null,de=I;do{var Ee=de.lane;if((oa&Ee)===Ee)J!==null&&(J=J.next={lane:0,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),x=de.hasEagerState?de.eagerState:a(x,de.action);else{var Ce={lane:Ee,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null};J===null?(X=J=Ce,U=x):J=J.next=Ce,en.lanes|=Ee,la|=Ee}de=de.next}while(de!==null&&de!==I);J===null?U=x:J.next=X,rr(x,l.memoizedState)||(hs=!0),l.memoizedState=x,l.baseState=U,l.baseQueue=J,h.lastRenderedState=x}if(a=h.interleaved,a!==null){j=a;do I=j.lane,en.lanes|=I,la|=I,j=j.next;while(j!==a)}else j===null&&(h.lanes=0);return[l.memoizedState,h.dispatch]}function Ef(a){var l=Zs(),h=l.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=a;var x=h.dispatch,j=h.pending,I=l.memoizedState;if(j!==null){h.pending=null;var U=j=j.next;do I=a(I,U.action),U=U.next;while(U!==j);rr(I,l.memoizedState)||(hs=!0),l.memoizedState=I,l.baseQueue===null&&(l.baseState=I),h.lastRenderedState=I}return[I,x]}function ux(){}function dx(a,l){var h=en,x=Zs(),j=l(),I=!rr(x.memoizedState,j);if(I&&(x.memoizedState=j,hs=!0),x=x.queue,Cf(px.bind(null,h,x,a),[a]),x.getSnapshot!==l||I||An!==null&&An.memoizedState.tag&1){if(h.flags|=2048,ol(9,hx.bind(null,h,x,j,l),void 0,null),Tn===null)throw Error(n(349));(oa&30)!==0||fx(h,l,j)}return j}function fx(a,l,h){a.flags|=16384,a={getSnapshot:l,value:h},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.stores=[a]):(h=l.stores,h===null?l.stores=[a]:h.push(a))}function hx(a,l,h,x){l.value=h,l.getSnapshot=x,mx(l)&&gx(a)}function px(a,l,h){return h(function(){mx(l)&&gx(a)})}function mx(a){var l=a.getSnapshot;a=a.value;try{var h=l();return!rr(a,h)}catch{return!0}}function gx(a){var l=Qr(a,1);l!==null&&cr(l,a,1,-1)}function xx(a){var l=$r();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:al,lastRenderedState:a},l.queue=a,a=a.dispatch=S_.bind(null,en,a),[l.memoizedState,a]}function ol(a,l,h,x){return a={tag:a,create:l,destroy:h,deps:x,next:null},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.lastEffect=a.next=a):(h=l.lastEffect,h===null?l.lastEffect=a.next=a:(x=h.next,h.next=a,a.next=x,l.lastEffect=a)),a}function vx(){return Zs().memoizedState}function Bc(a,l,h,x){var j=$r();en.flags|=a,j.memoizedState=ol(1|l,h,void 0,x===void 0?null:x)}function Uc(a,l,h,x){var j=Zs();x=x===void 0?null:x;var I=void 0;if(_n!==null){var U=_n.memoizedState;if(I=U.destroy,x!==null&&Nf(x,U.deps)){j.memoizedState=ol(l,h,I,x);return}}en.flags|=a,j.memoizedState=ol(1|l,h,I,x)}function yx(a,l){return Bc(8390656,8,a,l)}function Cf(a,l){return Uc(2048,8,a,l)}function bx(a,l){return Uc(4,2,a,l)}function kx(a,l){return Uc(4,4,a,l)}function wx(a,l){if(typeof l=="function")return a=a(),l(a),function(){l(null)};if(l!=null)return a=a(),l.current=a,function(){l.current=null}}function Nx(a,l,h){return h=h!=null?h.concat([a]):null,Uc(4,4,wx.bind(null,l,a),h)}function If(){}function jx(a,l){var h=Zs();l=l===void 0?null:l;var x=h.memoizedState;return x!==null&&l!==null&&Nf(l,x[1])?x[0]:(h.memoizedState=[a,l],a)}function Sx(a,l){var h=Zs();l=l===void 0?null:l;var x=h.memoizedState;return x!==null&&l!==null&&Nf(l,x[1])?x[0]:(a=a(),h.memoizedState=[a,l],a)}function _x(a,l,h){return(oa&21)===0?(a.baseState&&(a.baseState=!1,hs=!0),a.memoizedState=h):(rr(h,l)||(h=vi(),en.lanes|=h,la|=h,a.baseState=!0),l)}function N_(a,l){var h=vt;vt=h!==0&&4>h?h:4,a(!0);var x=wf.transition;wf.transition={};try{a(!1),l()}finally{vt=h,wf.transition=x}}function Ex(){return Zs().memoizedState}function j_(a,l,h){var x=Ii(a);if(h={lane:x,action:h,hasEagerState:!1,eagerState:null,next:null},Cx(a))Ix(l,h);else if(h=ix(a,l,h,x),h!==null){var j=ts();cr(h,a,x,j),Ax(h,l,x)}}function S_(a,l,h){var x=Ii(a),j={lane:x,action:h,hasEagerState:!1,eagerState:null,next:null};if(Cx(a))Ix(l,j);else{var I=a.alternate;if(a.lanes===0&&(I===null||I.lanes===0)&&(I=l.lastRenderedReducer,I!==null))try{var U=l.lastRenderedState,X=I(U,h);if(j.hasEagerState=!0,j.eagerState=X,rr(X,U)){var J=l.interleaved;J===null?(j.next=j,gf(l)):(j.next=J.next,J.next=j),l.interleaved=j;return}}catch{}finally{}h=ix(a,l,j,x),h!==null&&(j=ts(),cr(h,a,x,j),Ax(h,l,x))}}function Cx(a){var l=a.alternate;return a===en||l!==null&&l===en}function Ix(a,l){rl=Fc=!0;var h=a.pending;h===null?l.next=l:(l.next=h.next,h.next=l),a.pending=l}function Ax(a,l,h){if((h&4194240)!==0){var x=l.lanes;x&=a.pendingLanes,h|=x,l.lanes=h,Fs(a,h)}}var Hc={readContext:Hs,useCallback:Vn,useContext:Vn,useEffect:Vn,useImperativeHandle:Vn,useInsertionEffect:Vn,useLayoutEffect:Vn,useMemo:Vn,useReducer:Vn,useRef:Vn,useState:Vn,useDebugValue:Vn,useDeferredValue:Vn,useTransition:Vn,useMutableSource:Vn,useSyncExternalStore:Vn,useId:Vn,unstable_isNewReconciler:!1},__={readContext:Hs,useCallback:function(a,l){return $r().memoizedState=[a,l===void 0?null:l],a},useContext:Hs,useEffect:yx,useImperativeHandle:function(a,l,h){return h=h!=null?h.concat([a]):null,Bc(4194308,4,wx.bind(null,l,a),h)},useLayoutEffect:function(a,l){return Bc(4194308,4,a,l)},useInsertionEffect:function(a,l){return Bc(4,2,a,l)},useMemo:function(a,l){var h=$r();return l=l===void 0?null:l,a=a(),h.memoizedState=[a,l],a},useReducer:function(a,l,h){var x=$r();return l=h!==void 0?h(l):l,x.memoizedState=x.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},x.queue=a,a=a.dispatch=j_.bind(null,en,a),[x.memoizedState,a]},useRef:function(a){var l=$r();return a={current:a},l.memoizedState=a},useState:xx,useDebugValue:If,useDeferredValue:function(a){return $r().memoizedState=a},useTransition:function(){var a=xx(!1),l=a[0];return a=N_.bind(null,a[1]),$r().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,h){var x=en,j=$r();if(qt){if(h===void 0)throw Error(n(407));h=h()}else{if(h=l(),Tn===null)throw Error(n(349));(oa&30)!==0||fx(x,l,h)}j.memoizedState=h;var I={value:h,getSnapshot:l};return j.queue=I,yx(px.bind(null,x,I,a),[a]),x.flags|=2048,ol(9,hx.bind(null,x,I,h,l),void 0,null),h},useId:function(){var a=$r(),l=Tn.identifierPrefix;if(qt){var h=Xr,x=Yr;h=(x&~(1<<32-zt(x)-1)).toString(32)+h,l=":"+l+"R"+h,h=il++,0<h&&(l+="H"+h.toString(32)),l+=":"}else h=w_++,l=":"+l+"r"+h.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},E_={readContext:Hs,useCallback:jx,useContext:Hs,useEffect:Cf,useImperativeHandle:Nx,useInsertionEffect:bx,useLayoutEffect:kx,useMemo:Sx,useReducer:_f,useRef:vx,useState:function(){return _f(al)},useDebugValue:If,useDeferredValue:function(a){var l=Zs();return _x(l,_n.memoizedState,a)},useTransition:function(){var a=_f(al)[0],l=Zs().memoizedState;return[a,l]},useMutableSource:ux,useSyncExternalStore:dx,useId:Ex,unstable_isNewReconciler:!1},C_={readContext:Hs,useCallback:jx,useContext:Hs,useEffect:Cf,useImperativeHandle:Nx,useInsertionEffect:bx,useLayoutEffect:kx,useMemo:Sx,useReducer:Ef,useRef:vx,useState:function(){return Ef(al)},useDebugValue:If,useDeferredValue:function(a){var l=Zs();return _n===null?l.memoizedState=a:_x(l,_n.memoizedState,a)},useTransition:function(){var a=Ef(al)[0],l=Zs().memoizedState;return[a,l]},useMutableSource:ux,useSyncExternalStore:dx,useId:Ex,unstable_isNewReconciler:!1};function ar(a,l){if(a&&a.defaultProps){l=K({},l),a=a.defaultProps;for(var h in a)l[h]===void 0&&(l[h]=a[h]);return l}return l}function Af(a,l,h,x){l=a.memoizedState,h=h(x,l),h=h==null?l:K({},l,h),a.memoizedState=h,a.lanes===0&&(a.updateQueue.baseState=h)}var Zc={isMounted:function(a){return(a=a._reactInternals)?Hn(a)===a:!1},enqueueSetState:function(a,l,h){a=a._reactInternals;var x=ts(),j=Ii(a),I=Jr(x,j);I.payload=l,h!=null&&(I.callback=h),l=Si(a,I,j),l!==null&&(cr(l,a,j,x),zc(l,a,j))},enqueueReplaceState:function(a,l,h){a=a._reactInternals;var x=ts(),j=Ii(a),I=Jr(x,j);I.tag=1,I.payload=l,h!=null&&(I.callback=h),l=Si(a,I,j),l!==null&&(cr(l,a,j,x),zc(l,a,j))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var h=ts(),x=Ii(a),j=Jr(h,x);j.tag=2,l!=null&&(j.callback=l),l=Si(a,j,x),l!==null&&(cr(l,a,x,h),zc(l,a,x))}};function Tx(a,l,h,x,j,I,U){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(x,I,U):l.prototype&&l.prototype.isPureReactComponent?!qo(h,x)||!qo(j,I):!0}function $x(a,l,h){var x=!1,j=wi,I=l.contextType;return typeof I=="object"&&I!==null?I=Hs(I):(j=fs(l)?na:Wn.current,x=l.contextTypes,I=(x=x!=null)?qa(a,j):wi),l=new l(h,I),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=Zc,a.stateNode=l,l._reactInternals=a,x&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=j,a.__reactInternalMemoizedMaskedChildContext=I),l}function Mx(a,l,h,x){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(h,x),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(h,x),l.state!==a&&Zc.enqueueReplaceState(l,l.state,null)}function Tf(a,l,h,x){var j=a.stateNode;j.props=h,j.state=a.memoizedState,j.refs={},xf(a);var I=l.contextType;typeof I=="object"&&I!==null?j.context=Hs(I):(I=fs(l)?na:Wn.current,j.context=qa(a,I)),j.state=a.memoizedState,I=l.getDerivedStateFromProps,typeof I=="function"&&(Af(a,l,I,h),j.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(l=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),l!==j.state&&Zc.enqueueReplaceState(j,j.state,null),Pc(a,h,j,x),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308)}function to(a,l){try{var h="",x=l;do h+=ge(x),x=x.return;while(x);var j=h}catch(I){j=`
39
- Error generating stack: `+I.message+`
40
- `+I.stack}return{value:a,source:l,stack:j,digest:null}}function $f(a,l,h){return{value:a,source:null,stack:h??null,digest:l??null}}function Mf(a,l){try{console.error(l.value)}catch(h){setTimeout(function(){throw h})}}var I_=typeof WeakMap=="function"?WeakMap:Map;function Rx(a,l,h){h=Jr(-1,h),h.tag=3,h.payload={element:null};var x=l.value;return h.callback=function(){Xc||(Xc=!0,Gf=x),Mf(a,l)},h}function Ox(a,l,h){h=Jr(-1,h),h.tag=3;var x=a.type.getDerivedStateFromError;if(typeof x=="function"){var j=l.value;h.payload=function(){return x(j)},h.callback=function(){Mf(a,l)}}var I=a.stateNode;return I!==null&&typeof I.componentDidCatch=="function"&&(h.callback=function(){Mf(a,l),typeof x!="function"&&(Ei===null?Ei=new Set([this]):Ei.add(this));var U=l.stack;this.componentDidCatch(l.value,{componentStack:U!==null?U:""})}),h}function zx(a,l,h){var x=a.pingCache;if(x===null){x=a.pingCache=new I_;var j=new Set;x.set(l,j)}else j=x.get(l),j===void 0&&(j=new Set,x.set(l,j));j.has(h)||(j.add(h),a=H_.bind(null,a,l,h),l.then(a,a))}function Px(a){do{var l;if((l=a.tag===13)&&(l=a.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return a;a=a.return}while(a!==null);return null}function Lx(a,l,h,x,j){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(l=Jr(-1,1),l.tag=2,Si(h,l,1))),h.lanes|=1),a):(a.flags|=65536,a.lanes=j,a)}var A_=R.ReactCurrentOwner,hs=!1;function es(a,l,h,x){l.child=a===null?rx(l,null,h,x):Xa(l,a.child,h,x)}function Dx(a,l,h,x,j){h=h.render;var I=l.ref;return Ja(l,j),x=jf(a,l,h,x,I,j),h=Sf(),a!==null&&!hs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~j,ei(a,l,j)):(qt&&h&&of(l),l.flags|=1,es(a,l,x,j),l.child)}function Fx(a,l,h,x,j){if(a===null){var I=h.type;return typeof I=="function"&&!th(I)&&I.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(l.tag=15,l.type=I,Bx(a,l,I,x,j)):(a=su(h.type,null,x,l,l.mode,j),a.ref=l.ref,a.return=l,l.child=a)}if(I=a.child,(a.lanes&j)===0){var U=I.memoizedProps;if(h=h.compare,h=h!==null?h:qo,h(U,x)&&a.ref===l.ref)return ei(a,l,j)}return l.flags|=1,a=Ti(I,x),a.ref=l.ref,a.return=l,l.child=a}function Bx(a,l,h,x,j){if(a!==null){var I=a.memoizedProps;if(qo(I,x)&&a.ref===l.ref)if(hs=!1,l.pendingProps=x=I,(a.lanes&j)!==0)(a.flags&131072)!==0&&(hs=!0);else return l.lanes=a.lanes,ei(a,l,j)}return Rf(a,l,h,x,j)}function Ux(a,l,h){var x=l.pendingProps,j=x.children,I=a!==null?a.memoizedState:null;if(x.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dt(so,Es),Es|=h;else{if((h&1073741824)===0)return a=I!==null?I.baseLanes|h:h,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Dt(so,Es),Es|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=I!==null?I.baseLanes:h,Dt(so,Es),Es|=x}else I!==null?(x=I.baseLanes|h,l.memoizedState=null):x=h,Dt(so,Es),Es|=x;return es(a,l,j,h),l.child}function Hx(a,l){var h=l.ref;(a===null&&h!==null||a!==null&&a.ref!==h)&&(l.flags|=512,l.flags|=2097152)}function Rf(a,l,h,x,j){var I=fs(h)?na:Wn.current;return I=qa(l,I),Ja(l,j),h=jf(a,l,h,x,I,j),x=Sf(),a!==null&&!hs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~j,ei(a,l,j)):(qt&&x&&of(l),l.flags|=1,es(a,l,h,j),l.child)}function Zx(a,l,h,x,j){if(fs(h)){var I=!0;Cc(l)}else I=!1;if(Ja(l,j),l.stateNode===null)Vc(a,l),$x(l,h,x),Tf(l,h,x,j),x=!0;else if(a===null){var U=l.stateNode,X=l.memoizedProps;U.props=X;var J=U.context,de=h.contextType;typeof de=="object"&&de!==null?de=Hs(de):(de=fs(h)?na:Wn.current,de=qa(l,de));var Ee=h.getDerivedStateFromProps,Ce=typeof Ee=="function"||typeof U.getSnapshotBeforeUpdate=="function";Ce||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(X!==x||J!==de)&&Mx(l,U,x,de),ji=!1;var _e=l.memoizedState;U.state=_e,Pc(l,x,U,j),J=l.memoizedState,X!==x||_e!==J||ds.current||ji?(typeof Ee=="function"&&(Af(l,h,Ee,x),J=l.memoizedState),(X=ji||Tx(l,h,X,x,_e,J,de))?(Ce||typeof U.UNSAFE_componentWillMount!="function"&&typeof U.componentWillMount!="function"||(typeof U.componentWillMount=="function"&&U.componentWillMount(),typeof U.UNSAFE_componentWillMount=="function"&&U.UNSAFE_componentWillMount()),typeof U.componentDidMount=="function"&&(l.flags|=4194308)):(typeof U.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=x,l.memoizedState=J),U.props=x,U.state=J,U.context=de,x=X):(typeof U.componentDidMount=="function"&&(l.flags|=4194308),x=!1)}else{U=l.stateNode,ax(a,l),X=l.memoizedProps,de=l.type===l.elementType?X:ar(l.type,X),U.props=de,Ce=l.pendingProps,_e=U.context,J=h.contextType,typeof J=="object"&&J!==null?J=Hs(J):(J=fs(h)?na:Wn.current,J=qa(l,J));var He=h.getDerivedStateFromProps;(Ee=typeof He=="function"||typeof U.getSnapshotBeforeUpdate=="function")||typeof U.UNSAFE_componentWillReceiveProps!="function"&&typeof U.componentWillReceiveProps!="function"||(X!==Ce||_e!==J)&&Mx(l,U,x,J),ji=!1,_e=l.memoizedState,U.state=_e,Pc(l,x,U,j);var Ve=l.memoizedState;X!==Ce||_e!==Ve||ds.current||ji?(typeof He=="function"&&(Af(l,h,He,x),Ve=l.memoizedState),(de=ji||Tx(l,h,de,x,_e,Ve,J)||!1)?(Ee||typeof U.UNSAFE_componentWillUpdate!="function"&&typeof U.componentWillUpdate!="function"||(typeof U.componentWillUpdate=="function"&&U.componentWillUpdate(x,Ve,J),typeof U.UNSAFE_componentWillUpdate=="function"&&U.UNSAFE_componentWillUpdate(x,Ve,J)),typeof U.componentDidUpdate=="function"&&(l.flags|=4),typeof U.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof U.componentDidUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=1024),l.memoizedProps=x,l.memoizedState=Ve),U.props=x,U.state=Ve,U.context=J,x=de):(typeof U.componentDidUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=4),typeof U.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=1024),x=!1)}return Of(a,l,h,x,I,j)}function Of(a,l,h,x,j,I){Hx(a,l);var U=(l.flags&128)!==0;if(!x&&!U)return j&&Kg(l,h,!1),ei(a,l,I);x=l.stateNode,A_.current=l;var X=U&&typeof h.getDerivedStateFromError!="function"?null:x.render();return l.flags|=1,a!==null&&U?(l.child=Xa(l,a.child,null,I),l.child=Xa(l,null,X,I)):es(a,l,X,I),l.memoizedState=x.state,j&&Kg(l,h,!0),l.child}function Wx(a){var l=a.stateNode;l.pendingContext?qg(a,l.pendingContext,l.pendingContext!==l.context):l.context&&qg(a,l.context,!1),vf(a,l.containerInfo)}function Vx(a,l,h,x,j){return Ya(),df(j),l.flags|=256,es(a,l,h,x),l.child}var zf={dehydrated:null,treeContext:null,retryLane:0};function Pf(a){return{baseLanes:a,cachePool:null,transitions:null}}function qx(a,l,h){var x=l.pendingProps,j=Jt.current,I=!1,U=(l.flags&128)!==0,X;if((X=U)||(X=a!==null&&a.memoizedState===null?!1:(j&2)!==0),X?(I=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(j|=1),Dt(Jt,j&1),a===null)return uf(l),a=l.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((l.mode&1)===0?l.lanes=1:a.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(U=x.children,a=x.fallback,I?(x=l.mode,I=l.child,U={mode:"hidden",children:U},(x&1)===0&&I!==null?(I.childLanes=0,I.pendingProps=U):I=ru(U,x,0,null),a=fa(a,x,h,null),I.return=l,a.return=l,I.sibling=a,l.child=I,l.child.memoizedState=Pf(h),l.memoizedState=zf,a):Lf(l,U));if(j=a.memoizedState,j!==null&&(X=j.dehydrated,X!==null))return T_(a,l,U,x,X,j,h);if(I){I=x.fallback,U=l.mode,j=a.child,X=j.sibling;var J={mode:"hidden",children:x.children};return(U&1)===0&&l.child!==j?(x=l.child,x.childLanes=0,x.pendingProps=J,l.deletions=null):(x=Ti(j,J),x.subtreeFlags=j.subtreeFlags&14680064),X!==null?I=Ti(X,I):(I=fa(I,U,h,null),I.flags|=2),I.return=l,x.return=l,x.sibling=I,l.child=x,x=I,I=l.child,U=a.child.memoizedState,U=U===null?Pf(h):{baseLanes:U.baseLanes|h,cachePool:null,transitions:U.transitions},I.memoizedState=U,I.childLanes=a.childLanes&~h,l.memoizedState=zf,x}return I=a.child,a=I.sibling,x=Ti(I,{mode:"visible",children:x.children}),(l.mode&1)===0&&(x.lanes=h),x.return=l,x.sibling=null,a!==null&&(h=l.deletions,h===null?(l.deletions=[a],l.flags|=16):h.push(a)),l.child=x,l.memoizedState=null,x}function Lf(a,l){return l=ru({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function Wc(a,l,h,x){return x!==null&&df(x),Xa(l,a.child,null,h),a=Lf(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function T_(a,l,h,x,j,I,U){if(h)return l.flags&256?(l.flags&=-257,x=$f(Error(n(422))),Wc(a,l,U,x)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(I=x.fallback,j=l.mode,x=ru({mode:"visible",children:x.children},j,0,null),I=fa(I,j,U,null),I.flags|=2,x.return=l,I.return=l,x.sibling=I,l.child=x,(l.mode&1)!==0&&Xa(l,a.child,null,U),l.child.memoizedState=Pf(U),l.memoizedState=zf,I);if((l.mode&1)===0)return Wc(a,l,U,null);if(j.data==="$!"){if(x=j.nextSibling&&j.nextSibling.dataset,x)var X=x.dgst;return x=X,I=Error(n(419)),x=$f(I,x,void 0),Wc(a,l,U,x)}if(X=(U&a.childLanes)!==0,hs||X){if(x=Tn,x!==null){switch(U&-U){case 4:j=2;break;case 16:j=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:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(x.suspendedLanes|U))!==0?0:j,j!==0&&j!==I.retryLane&&(I.retryLane=j,Qr(a,j),cr(x,a,j,-1))}return eh(),x=$f(Error(n(421))),Wc(a,l,U,x)}return j.data==="$?"?(l.flags|=128,l.child=a.child,l=Z_.bind(null,a),j._reactRetry=l,null):(a=I.treeContext,_s=bi(j.nextSibling),Ss=l,qt=!0,ir=null,a!==null&&(Bs[Us++]=Yr,Bs[Us++]=Xr,Bs[Us++]=sa,Yr=a.id,Xr=a.overflow,sa=l),l=Lf(l,x.children),l.flags|=4096,l)}function Gx(a,l,h){a.lanes|=l;var x=a.alternate;x!==null&&(x.lanes|=l),mf(a.return,l,h)}function Df(a,l,h,x,j){var I=a.memoizedState;I===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:x,tail:h,tailMode:j}:(I.isBackwards=l,I.rendering=null,I.renderingStartTime=0,I.last=x,I.tail=h,I.tailMode=j)}function Kx(a,l,h){var x=l.pendingProps,j=x.revealOrder,I=x.tail;if(es(a,l,x.children,h),x=Jt.current,(x&2)!==0)x=x&1|2,l.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=l.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&Gx(a,h,l);else if(a.tag===19)Gx(a,h,l);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===l)break e;for(;a.sibling===null;){if(a.return===null||a.return===l)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}x&=1}if(Dt(Jt,x),(l.mode&1)===0)l.memoizedState=null;else switch(j){case"forwards":for(h=l.child,j=null;h!==null;)a=h.alternate,a!==null&&Lc(a)===null&&(j=h),h=h.sibling;h=j,h===null?(j=l.child,l.child=null):(j=h.sibling,h.sibling=null),Df(l,!1,j,h,I);break;case"backwards":for(h=null,j=l.child,l.child=null;j!==null;){if(a=j.alternate,a!==null&&Lc(a)===null){l.child=j;break}a=j.sibling,j.sibling=h,h=j,j=a}Df(l,!0,h,null,I);break;case"together":Df(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function Vc(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function ei(a,l,h){if(a!==null&&(l.dependencies=a.dependencies),la|=l.lanes,(h&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(n(153));if(l.child!==null){for(a=l.child,h=Ti(a,a.pendingProps),l.child=h,h.return=l;a.sibling!==null;)a=a.sibling,h=h.sibling=Ti(a,a.pendingProps),h.return=l;h.sibling=null}return l.child}function $_(a,l,h){switch(l.tag){case 3:Wx(l),Ya();break;case 5:cx(l);break;case 1:fs(l.type)&&Cc(l);break;case 4:vf(l,l.stateNode.containerInfo);break;case 10:var x=l.type._context,j=l.memoizedProps.value;Dt(Rc,x._currentValue),x._currentValue=j;break;case 13:if(x=l.memoizedState,x!==null)return x.dehydrated!==null?(Dt(Jt,Jt.current&1),l.flags|=128,null):(h&l.child.childLanes)!==0?qx(a,l,h):(Dt(Jt,Jt.current&1),a=ei(a,l,h),a!==null?a.sibling:null);Dt(Jt,Jt.current&1);break;case 19:if(x=(h&l.childLanes)!==0,(a.flags&128)!==0){if(x)return Kx(a,l,h);l.flags|=128}if(j=l.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),Dt(Jt,Jt.current),x)break;return null;case 22:case 23:return l.lanes=0,Ux(a,l,h)}return ei(a,l,h)}var Yx,Ff,Xx,Qx;Yx=function(a,l){for(var h=l.child;h!==null;){if(h.tag===5||h.tag===6)a.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===l)break;for(;h.sibling===null;){if(h.return===null||h.return===l)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},Ff=function(){},Xx=function(a,l,h,x){var j=a.memoizedProps;if(j!==x){a=l.stateNode,aa(Tr.current);var I=null;switch(h){case"input":j=he(a,j),x=he(a,x),I=[];break;case"select":j=K({},j,{value:void 0}),x=K({},x,{value:void 0}),I=[];break;case"textarea":j=On(a,j),x=On(a,x),I=[];break;default:typeof j.onClick!="function"&&typeof x.onClick=="function"&&(a.onclick=Sc)}Rs(h,x);var U;h=null;for(de in j)if(!x.hasOwnProperty(de)&&j.hasOwnProperty(de)&&j[de]!=null)if(de==="style"){var X=j[de];for(U in X)X.hasOwnProperty(U)&&(h||(h={}),h[U]="")}else de!=="dangerouslySetInnerHTML"&&de!=="children"&&de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&de!=="autoFocus"&&(i.hasOwnProperty(de)?I||(I=[]):(I=I||[]).push(de,null));for(de in x){var J=x[de];if(X=j!=null?j[de]:void 0,x.hasOwnProperty(de)&&J!==X&&(J!=null||X!=null))if(de==="style")if(X){for(U in X)!X.hasOwnProperty(U)||J&&J.hasOwnProperty(U)||(h||(h={}),h[U]="");for(U in J)J.hasOwnProperty(U)&&X[U]!==J[U]&&(h||(h={}),h[U]=J[U])}else h||(I||(I=[]),I.push(de,h)),h=J;else de==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,X=X?X.__html:void 0,J!=null&&X!==J&&(I=I||[]).push(de,J)):de==="children"?typeof J!="string"&&typeof J!="number"||(I=I||[]).push(de,""+J):de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&(i.hasOwnProperty(de)?(J!=null&&de==="onScroll"&&Ut("scroll",a),I||X===J||(I=[])):(I=I||[]).push(de,J))}h&&(I=I||[]).push("style",h);var de=I;(l.updateQueue=de)&&(l.flags|=4)}},Qx=function(a,l,h,x){h!==x&&(l.flags|=4)};function ll(a,l){if(!qt)switch(a.tailMode){case"hidden":l=a.tail;for(var h=null;l!==null;)l.alternate!==null&&(h=l),l=l.sibling;h===null?a.tail=null:h.sibling=null;break;case"collapsed":h=a.tail;for(var x=null;h!==null;)h.alternate!==null&&(x=h),h=h.sibling;x===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:x.sibling=null}}function qn(a){var l=a.alternate!==null&&a.alternate.child===a.child,h=0,x=0;if(l)for(var j=a.child;j!==null;)h|=j.lanes|j.childLanes,x|=j.subtreeFlags&14680064,x|=j.flags&14680064,j.return=a,j=j.sibling;else for(j=a.child;j!==null;)h|=j.lanes|j.childLanes,x|=j.subtreeFlags,x|=j.flags,j.return=a,j=j.sibling;return a.subtreeFlags|=x,a.childLanes=h,l}function M_(a,l,h){var x=l.pendingProps;switch(lf(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return qn(l),null;case 1:return fs(l.type)&&Ec(),qn(l),null;case 3:return x=l.stateNode,eo(),Ht(ds),Ht(Wn),kf(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(a===null||a.child===null)&&($c(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,ir!==null&&(Xf(ir),ir=null))),Ff(a,l),qn(l),null;case 5:yf(l);var j=aa(sl.current);if(h=l.type,a!==null&&l.stateNode!=null)Xx(a,l,h,x,j),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!x){if(l.stateNode===null)throw Error(n(166));return qn(l),null}if(a=aa(Tr.current),$c(l)){x=l.stateNode,h=l.type;var I=l.memoizedProps;switch(x[Ar]=l,x[Qo]=I,a=(l.mode&1)!==0,h){case"dialog":Ut("cancel",x),Ut("close",x);break;case"iframe":case"object":case"embed":Ut("load",x);break;case"video":case"audio":for(j=0;j<Ko.length;j++)Ut(Ko[j],x);break;case"source":Ut("error",x);break;case"img":case"image":case"link":Ut("error",x),Ut("load",x);break;case"details":Ut("toggle",x);break;case"input":Le(x,I),Ut("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!I.multiple},Ut("invalid",x);break;case"textarea":sn(x,I),Ut("invalid",x)}Rs(h,I),j=null;for(var U in I)if(I.hasOwnProperty(U)){var X=I[U];U==="children"?typeof X=="string"?x.textContent!==X&&(I.suppressHydrationWarning!==!0&&jc(x.textContent,X,a),j=["children",X]):typeof X=="number"&&x.textContent!==""+X&&(I.suppressHydrationWarning!==!0&&jc(x.textContent,X,a),j=["children",""+X]):i.hasOwnProperty(U)&&X!=null&&U==="onScroll"&&Ut("scroll",x)}switch(h){case"input":ce(x),Ie(x,I,!0);break;case"textarea":ce(x),cn(x);break;case"select":case"option":break;default:typeof I.onClick=="function"&&(x.onclick=Sc)}x=j,l.updateQueue=x,x!==null&&(l.flags|=4)}else{U=j.nodeType===9?j:j.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=rn(h)),a==="http://www.w3.org/1999/xhtml"?h==="script"?(a=U.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof x.is=="string"?a=U.createElement(h,{is:x.is}):(a=U.createElement(h),h==="select"&&(U=a,x.multiple?U.multiple=!0:x.size&&(U.size=x.size))):a=U.createElementNS(a,h),a[Ar]=l,a[Qo]=x,Yx(a,l,!1,!1),l.stateNode=a;e:{switch(U=Os(h,x),h){case"dialog":Ut("cancel",a),Ut("close",a),j=x;break;case"iframe":case"object":case"embed":Ut("load",a),j=x;break;case"video":case"audio":for(j=0;j<Ko.length;j++)Ut(Ko[j],a);j=x;break;case"source":Ut("error",a),j=x;break;case"img":case"image":case"link":Ut("error",a),Ut("load",a),j=x;break;case"details":Ut("toggle",a),j=x;break;case"input":Le(a,x),j=he(a,x),Ut("invalid",a);break;case"option":j=x;break;case"select":a._wrapperState={wasMultiple:!!x.multiple},j=K({},x,{value:void 0}),Ut("invalid",a);break;case"textarea":sn(a,x),j=On(a,x),Ut("invalid",a);break;default:j=x}Rs(h,j),X=j;for(I in X)if(X.hasOwnProperty(I)){var J=X[I];I==="style"?Ys(a,J):I==="dangerouslySetInnerHTML"?(J=J?J.__html:void 0,J!=null&&Bn(a,J)):I==="children"?typeof J=="string"?(h!=="textarea"||J!=="")&&wn(a,J):typeof J=="number"&&wn(a,""+J):I!=="suppressContentEditableWarning"&&I!=="suppressHydrationWarning"&&I!=="autoFocus"&&(i.hasOwnProperty(I)?J!=null&&I==="onScroll"&&Ut("scroll",a):J!=null&&N(a,I,J,U))}switch(h){case"input":ce(a),Ie(a,x,!1);break;case"textarea":ce(a),cn(a);break;case"option":x.value!=null&&a.setAttribute("value",""+ae(x.value));break;case"select":a.multiple=!!x.multiple,I=x.value,I!=null?jt(a,!!x.multiple,I,!1):x.defaultValue!=null&&jt(a,!!x.multiple,x.defaultValue,!0);break;default:typeof j.onClick=="function"&&(a.onclick=Sc)}switch(h){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return qn(l),null;case 6:if(a&&l.stateNode!=null)Qx(a,l,a.memoizedProps,x);else{if(typeof x!="string"&&l.stateNode===null)throw Error(n(166));if(h=aa(sl.current),aa(Tr.current),$c(l)){if(x=l.stateNode,h=l.memoizedProps,x[Ar]=l,(I=x.nodeValue!==h)&&(a=Ss,a!==null))switch(a.tag){case 3:jc(x.nodeValue,h,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&jc(x.nodeValue,h,(a.mode&1)!==0)}I&&(l.flags|=4)}else x=(h.nodeType===9?h:h.ownerDocument).createTextNode(x),x[Ar]=l,l.stateNode=x}return qn(l),null;case 13:if(Ht(Jt),x=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(qt&&_s!==null&&(l.mode&1)!==0&&(l.flags&128)===0)tx(),Ya(),l.flags|=98560,I=!1;else if(I=$c(l),x!==null&&x.dehydrated!==null){if(a===null){if(!I)throw Error(n(318));if(I=l.memoizedState,I=I!==null?I.dehydrated:null,!I)throw Error(n(317));I[Ar]=l}else Ya(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qn(l),I=!1}else ir!==null&&(Xf(ir),ir=null),I=!0;if(!I)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=h,l):(x=x!==null,x!==(a!==null&&a.memoizedState!==null)&&x&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(Jt.current&1)!==0?En===0&&(En=3):eh())),l.updateQueue!==null&&(l.flags|=4),qn(l),null);case 4:return eo(),Ff(a,l),a===null&&Yo(l.stateNode.containerInfo),qn(l),null;case 10:return pf(l.type._context),qn(l),null;case 17:return fs(l.type)&&Ec(),qn(l),null;case 19:if(Ht(Jt),I=l.memoizedState,I===null)return qn(l),null;if(x=(l.flags&128)!==0,U=I.rendering,U===null)if(x)ll(I,!1);else{if(En!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(U=Lc(a),U!==null){for(l.flags|=128,ll(I,!1),x=U.updateQueue,x!==null&&(l.updateQueue=x,l.flags|=4),l.subtreeFlags=0,x=h,h=l.child;h!==null;)I=h,a=x,I.flags&=14680066,U=I.alternate,U===null?(I.childLanes=0,I.lanes=a,I.child=null,I.subtreeFlags=0,I.memoizedProps=null,I.memoizedState=null,I.updateQueue=null,I.dependencies=null,I.stateNode=null):(I.childLanes=U.childLanes,I.lanes=U.lanes,I.child=U.child,I.subtreeFlags=0,I.deletions=null,I.memoizedProps=U.memoizedProps,I.memoizedState=U.memoizedState,I.updateQueue=U.updateQueue,I.type=U.type,a=U.dependencies,I.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),h=h.sibling;return Dt(Jt,Jt.current&1|2),l.child}a=a.sibling}I.tail!==null&&Ot()>ro&&(l.flags|=128,x=!0,ll(I,!1),l.lanes=4194304)}else{if(!x)if(a=Lc(U),a!==null){if(l.flags|=128,x=!0,h=a.updateQueue,h!==null&&(l.updateQueue=h,l.flags|=4),ll(I,!0),I.tail===null&&I.tailMode==="hidden"&&!U.alternate&&!qt)return qn(l),null}else 2*Ot()-I.renderingStartTime>ro&&h!==1073741824&&(l.flags|=128,x=!0,ll(I,!1),l.lanes=4194304);I.isBackwards?(U.sibling=l.child,l.child=U):(h=I.last,h!==null?h.sibling=U:l.child=U,I.last=U)}return I.tail!==null?(l=I.tail,I.rendering=l,I.tail=l.sibling,I.renderingStartTime=Ot(),l.sibling=null,h=Jt.current,Dt(Jt,x?h&1|2:h&1),l):(qn(l),null);case 22:case 23:return Jf(),x=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==x&&(l.flags|=8192),x&&(l.mode&1)!==0?(Es&1073741824)!==0&&(qn(l),l.subtreeFlags&6&&(l.flags|=8192)):qn(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function R_(a,l){switch(lf(l),l.tag){case 1:return fs(l.type)&&Ec(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return eo(),Ht(ds),Ht(Wn),kf(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return yf(l),null;case 13:if(Ht(Jt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(n(340));Ya()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Ht(Jt),null;case 4:return eo(),null;case 10:return pf(l.type._context),null;case 22:case 23:return Jf(),null;case 24:return null;default:return null}}var qc=!1,Gn=!1,O_=typeof WeakSet=="function"?WeakSet:Set,We=null;function no(a,l){var h=a.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(x){on(a,l,x)}else h.current=null}function Bf(a,l,h){try{h()}catch(x){on(a,l,x)}}var Jx=!1;function z_(a,l){if(Qd=nt,a=Tg(),Zd(a)){if("selectionStart"in a)var h={start:a.selectionStart,end:a.selectionEnd};else e:{h=(h=a.ownerDocument)&&h.defaultView||window;var x=h.getSelection&&h.getSelection();if(x&&x.rangeCount!==0){h=x.anchorNode;var j=x.anchorOffset,I=x.focusNode;x=x.focusOffset;try{h.nodeType,I.nodeType}catch{h=null;break e}var U=0,X=-1,J=-1,de=0,Ee=0,Ce=a,_e=null;t:for(;;){for(var He;Ce!==h||j!==0&&Ce.nodeType!==3||(X=U+j),Ce!==I||x!==0&&Ce.nodeType!==3||(J=U+x),Ce.nodeType===3&&(U+=Ce.nodeValue.length),(He=Ce.firstChild)!==null;)_e=Ce,Ce=He;for(;;){if(Ce===a)break t;if(_e===h&&++de===j&&(X=U),_e===I&&++Ee===x&&(J=U),(He=Ce.nextSibling)!==null)break;Ce=_e,_e=Ce.parentNode}Ce=He}h=X===-1||J===-1?null:{start:X,end:J}}else h=null}h=h||{start:0,end:0}}else h=null;for(Jd={focusedElem:a,selectionRange:h},nt=!1,We=l;We!==null;)if(l=We,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,We=a;else for(;We!==null;){l=We;try{var Ve=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Ke=Ve.memoizedProps,fn=Ve.memoizedState,oe=l.stateNode,se=oe.getSnapshotBeforeUpdate(l.elementType===l.type?Ke:ar(l.type,Ke),fn);oe.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var le=l.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Me){on(l,l.return,Me)}if(a=l.sibling,a!==null){a.return=l.return,We=a;break}We=l.return}return Ve=Jx,Jx=!1,Ve}function cl(a,l,h){var x=l.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var j=x=x.next;do{if((j.tag&a)===a){var I=j.destroy;j.destroy=void 0,I!==void 0&&Bf(l,h,I)}j=j.next}while(j!==x)}}function Gc(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var h=l=l.next;do{if((h.tag&a)===a){var x=h.create;h.destroy=x()}h=h.next}while(h!==l)}}function Uf(a){var l=a.ref;if(l!==null){var h=a.stateNode;switch(a.tag){case 5:a=h;break;default:a=h}typeof l=="function"?l(a):l.current=a}}function ev(a){var l=a.alternate;l!==null&&(a.alternate=null,ev(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[Ar],delete l[Qo],delete l[sf],delete l[v_],delete l[y_])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function tv(a){return a.tag===5||a.tag===3||a.tag===4}function nv(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||tv(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Hf(a,l,h){var x=a.tag;if(x===5||x===6)a=a.stateNode,l?h.nodeType===8?h.parentNode.insertBefore(a,l):h.insertBefore(a,l):(h.nodeType===8?(l=h.parentNode,l.insertBefore(a,h)):(l=h,l.appendChild(a)),h=h._reactRootContainer,h!=null||l.onclick!==null||(l.onclick=Sc));else if(x!==4&&(a=a.child,a!==null))for(Hf(a,l,h),a=a.sibling;a!==null;)Hf(a,l,h),a=a.sibling}function Zf(a,l,h){var x=a.tag;if(x===5||x===6)a=a.stateNode,l?h.insertBefore(a,l):h.appendChild(a);else if(x!==4&&(a=a.child,a!==null))for(Zf(a,l,h),a=a.sibling;a!==null;)Zf(a,l,h),a=a.sibling}var zn=null,or=!1;function _i(a,l,h){for(h=h.child;h!==null;)sv(a,l,h),h=h.sibling}function sv(a,l,h){if(ft&&typeof ft.onCommitFiberUnmount=="function")try{ft.onCommitFiberUnmount(ct,h)}catch{}switch(h.tag){case 5:Gn||no(h,l);case 6:var x=zn,j=or;zn=null,_i(a,l,h),zn=x,or=j,zn!==null&&(or?(a=zn,h=h.stateNode,a.nodeType===8?a.parentNode.removeChild(h):a.removeChild(h)):zn.removeChild(h.stateNode));break;case 18:zn!==null&&(or?(a=zn,h=h.stateNode,a.nodeType===8?nf(a.parentNode,h):a.nodeType===1&&nf(a,h),ye(a)):nf(zn,h.stateNode));break;case 4:x=zn,j=or,zn=h.stateNode.containerInfo,or=!0,_i(a,l,h),zn=x,or=j;break;case 0:case 11:case 14:case 15:if(!Gn&&(x=h.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){j=x=x.next;do{var I=j,U=I.destroy;I=I.tag,U!==void 0&&((I&2)!==0||(I&4)!==0)&&Bf(h,l,U),j=j.next}while(j!==x)}_i(a,l,h);break;case 1:if(!Gn&&(no(h,l),x=h.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=h.memoizedProps,x.state=h.memoizedState,x.componentWillUnmount()}catch(X){on(h,l,X)}_i(a,l,h);break;case 21:_i(a,l,h);break;case 22:h.mode&1?(Gn=(x=Gn)||h.memoizedState!==null,_i(a,l,h),Gn=x):_i(a,l,h);break;default:_i(a,l,h)}}function rv(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var h=a.stateNode;h===null&&(h=a.stateNode=new O_),l.forEach(function(x){var j=W_.bind(null,a,x);h.has(x)||(h.add(x),x.then(j,j))})}}function lr(a,l){var h=l.deletions;if(h!==null)for(var x=0;x<h.length;x++){var j=h[x];try{var I=a,U=l,X=U;e:for(;X!==null;){switch(X.tag){case 5:zn=X.stateNode,or=!1;break e;case 3:zn=X.stateNode.containerInfo,or=!0;break e;case 4:zn=X.stateNode.containerInfo,or=!0;break e}X=X.return}if(zn===null)throw Error(n(160));sv(I,U,j),zn=null,or=!1;var J=j.alternate;J!==null&&(J.return=null),j.return=null}catch(de){on(j,l,de)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)iv(l,a),l=l.sibling}function iv(a,l){var h=a.alternate,x=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(lr(l,a),Mr(a),x&4){try{cl(3,a,a.return),Gc(3,a)}catch(Ke){on(a,a.return,Ke)}try{cl(5,a,a.return)}catch(Ke){on(a,a.return,Ke)}}break;case 1:lr(l,a),Mr(a),x&512&&h!==null&&no(h,h.return);break;case 5:if(lr(l,a),Mr(a),x&512&&h!==null&&no(h,h.return),a.flags&32){var j=a.stateNode;try{wn(j,"")}catch(Ke){on(a,a.return,Ke)}}if(x&4&&(j=a.stateNode,j!=null)){var I=a.memoizedProps,U=h!==null?h.memoizedProps:I,X=a.type,J=a.updateQueue;if(a.updateQueue=null,J!==null)try{X==="input"&&I.type==="radio"&&I.name!=null&&Te(j,I),Os(X,U);var de=Os(X,I);for(U=0;U<J.length;U+=2){var Ee=J[U],Ce=J[U+1];Ee==="style"?Ys(j,Ce):Ee==="dangerouslySetInnerHTML"?Bn(j,Ce):Ee==="children"?wn(j,Ce):N(j,Ee,Ce,de)}switch(X){case"input":Ge(j,I);break;case"textarea":ln(j,I);break;case"select":var _e=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!I.multiple;var He=I.value;He!=null?jt(j,!!I.multiple,He,!1):_e!==!!I.multiple&&(I.defaultValue!=null?jt(j,!!I.multiple,I.defaultValue,!0):jt(j,!!I.multiple,I.multiple?[]:"",!1))}j[Qo]=I}catch(Ke){on(a,a.return,Ke)}}break;case 6:if(lr(l,a),Mr(a),x&4){if(a.stateNode===null)throw Error(n(162));j=a.stateNode,I=a.memoizedProps;try{j.nodeValue=I}catch(Ke){on(a,a.return,Ke)}}break;case 3:if(lr(l,a),Mr(a),x&4&&h!==null&&h.memoizedState.isDehydrated)try{ye(l.containerInfo)}catch(Ke){on(a,a.return,Ke)}break;case 4:lr(l,a),Mr(a);break;case 13:lr(l,a),Mr(a),j=a.child,j.flags&8192&&(I=j.memoizedState!==null,j.stateNode.isHidden=I,!I||j.alternate!==null&&j.alternate.memoizedState!==null||(qf=Ot())),x&4&&rv(a);break;case 22:if(Ee=h!==null&&h.memoizedState!==null,a.mode&1?(Gn=(de=Gn)||Ee,lr(l,a),Gn=de):lr(l,a),Mr(a),x&8192){if(de=a.memoizedState!==null,(a.stateNode.isHidden=de)&&!Ee&&(a.mode&1)!==0)for(We=a,Ee=a.child;Ee!==null;){for(Ce=We=Ee;We!==null;){switch(_e=We,He=_e.child,_e.tag){case 0:case 11:case 14:case 15:cl(4,_e,_e.return);break;case 1:no(_e,_e.return);var Ve=_e.stateNode;if(typeof Ve.componentWillUnmount=="function"){x=_e,h=_e.return;try{l=x,Ve.props=l.memoizedProps,Ve.state=l.memoizedState,Ve.componentWillUnmount()}catch(Ke){on(x,h,Ke)}}break;case 5:no(_e,_e.return);break;case 22:if(_e.memoizedState!==null){lv(Ce);continue}}He!==null?(He.return=_e,We=He):lv(Ce)}Ee=Ee.sibling}e:for(Ee=null,Ce=a;;){if(Ce.tag===5){if(Ee===null){Ee=Ce;try{j=Ce.stateNode,de?(I=j.style,typeof I.setProperty=="function"?I.setProperty("display","none","important"):I.display="none"):(X=Ce.stateNode,J=Ce.memoizedProps.style,U=J!=null&&J.hasOwnProperty("display")?J.display:null,X.style.display=Ks("display",U))}catch(Ke){on(a,a.return,Ke)}}}else if(Ce.tag===6){if(Ee===null)try{Ce.stateNode.nodeValue=de?"":Ce.memoizedProps}catch(Ke){on(a,a.return,Ke)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===a)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===a)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===a)break e;Ee===Ce&&(Ee=null),Ce=Ce.return}Ee===Ce&&(Ee=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:lr(l,a),Mr(a),x&4&&rv(a);break;case 21:break;default:lr(l,a),Mr(a)}}function Mr(a){var l=a.flags;if(l&2){try{e:{for(var h=a.return;h!==null;){if(tv(h)){var x=h;break e}h=h.return}throw Error(n(160))}switch(x.tag){case 5:var j=x.stateNode;x.flags&32&&(wn(j,""),x.flags&=-33);var I=nv(a);Zf(a,I,j);break;case 3:case 4:var U=x.stateNode.containerInfo,X=nv(a);Hf(a,X,U);break;default:throw Error(n(161))}}catch(J){on(a,a.return,J)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function P_(a,l,h){We=a,av(a)}function av(a,l,h){for(var x=(a.mode&1)!==0;We!==null;){var j=We,I=j.child;if(j.tag===22&&x){var U=j.memoizedState!==null||qc;if(!U){var X=j.alternate,J=X!==null&&X.memoizedState!==null||Gn;X=qc;var de=Gn;if(qc=U,(Gn=J)&&!de)for(We=j;We!==null;)U=We,J=U.child,U.tag===22&&U.memoizedState!==null?cv(j):J!==null?(J.return=U,We=J):cv(j);for(;I!==null;)We=I,av(I),I=I.sibling;We=j,qc=X,Gn=de}ov(a)}else(j.subtreeFlags&8772)!==0&&I!==null?(I.return=j,We=I):ov(a)}}function ov(a){for(;We!==null;){var l=We;if((l.flags&8772)!==0){var h=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Gn||Gc(5,l);break;case 1:var x=l.stateNode;if(l.flags&4&&!Gn)if(h===null)x.componentDidMount();else{var j=l.elementType===l.type?h.memoizedProps:ar(l.type,h.memoizedProps);x.componentDidUpdate(j,h.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var I=l.updateQueue;I!==null&&lx(l,I,x);break;case 3:var U=l.updateQueue;if(U!==null){if(h=null,l.child!==null)switch(l.child.tag){case 5:h=l.child.stateNode;break;case 1:h=l.child.stateNode}lx(l,U,h)}break;case 5:var X=l.stateNode;if(h===null&&l.flags&4){h=X;var J=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":J.autoFocus&&h.focus();break;case"img":J.src&&(h.src=J.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var de=l.alternate;if(de!==null){var Ee=de.memoizedState;if(Ee!==null){var Ce=Ee.dehydrated;Ce!==null&&ye(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Gn||l.flags&512&&Uf(l)}catch(_e){on(l,l.return,_e)}}if(l===a){We=null;break}if(h=l.sibling,h!==null){h.return=l.return,We=h;break}We=l.return}}function lv(a){for(;We!==null;){var l=We;if(l===a){We=null;break}var h=l.sibling;if(h!==null){h.return=l.return,We=h;break}We=l.return}}function cv(a){for(;We!==null;){var l=We;try{switch(l.tag){case 0:case 11:case 15:var h=l.return;try{Gc(4,l)}catch(J){on(l,h,J)}break;case 1:var x=l.stateNode;if(typeof x.componentDidMount=="function"){var j=l.return;try{x.componentDidMount()}catch(J){on(l,j,J)}}var I=l.return;try{Uf(l)}catch(J){on(l,I,J)}break;case 5:var U=l.return;try{Uf(l)}catch(J){on(l,U,J)}}}catch(J){on(l,l.return,J)}if(l===a){We=null;break}var X=l.sibling;if(X!==null){X.return=l.return,We=X;break}We=l.return}}var L_=Math.ceil,Kc=R.ReactCurrentDispatcher,Wf=R.ReactCurrentOwner,Ws=R.ReactCurrentBatchConfig,kt=0,Tn=null,gn=null,Pn=0,Es=0,so=ki(0),En=0,ul=null,la=0,Yc=0,Vf=0,dl=null,ps=null,qf=0,ro=1/0,ti=null,Xc=!1,Gf=null,Ei=null,Qc=!1,Ci=null,Jc=0,fl=0,Kf=null,eu=-1,tu=0;function ts(){return(kt&6)!==0?Ot():eu!==-1?eu:eu=Ot()}function Ii(a){return(a.mode&1)===0?1:(kt&2)!==0&&Pn!==0?Pn&-Pn:k_.transition!==null?(tu===0&&(tu=vi()),tu):(a=vt,a!==0||(a=window.event,a=a===void 0?16:qr(a.type)),a)}function cr(a,l,h,x){if(50<fl)throw fl=0,Kf=null,Error(n(185));ls(a,h,x),((kt&2)===0||a!==Tn)&&(a===Tn&&((kt&2)===0&&(Yc|=h),En===4&&Ai(a,Pn)),ms(a,x),h===1&&kt===0&&(l.mode&1)===0&&(ro=Ot()+500,Ic&&Ni()))}function ms(a,l){var h=a.callbackNode;xi(a,l);var x=os(a,a===Tn?Pn:0);if(x===0)h!==null&&Xn(h),a.callbackNode=null,a.callbackPriority=0;else if(l=x&-x,a.callbackPriority!==l){if(h!=null&&Xn(h),l===1)a.tag===0?b_(dv.bind(null,a)):Yg(dv.bind(null,a)),g_(function(){(kt&6)===0&&Ni()}),h=null;else{switch(at(x)){case 1:h=Hr;break;case 4:h=nr;break;case 16:h=Cr;break;case 536870912:h=Ze;break;default:h=Cr}h=yv(h,uv.bind(null,a))}a.callbackPriority=l,a.callbackNode=h}}function uv(a,l){if(eu=-1,tu=0,(kt&6)!==0)throw Error(n(327));var h=a.callbackNode;if(io()&&a.callbackNode!==h)return null;var x=os(a,a===Tn?Pn:0);if(x===0)return null;if((x&30)!==0||(x&a.expiredLanes)!==0||l)l=nu(a,x);else{l=x;var j=kt;kt|=2;var I=hv();(Tn!==a||Pn!==l)&&(ti=null,ro=Ot()+500,ua(a,l));do try{B_();break}catch(X){fv(a,X)}while(!0);hf(),Kc.current=I,kt=j,gn!==null?l=0:(Tn=null,Pn=0,l=En)}if(l!==0){if(l===2&&(j=Ir(a),j!==0&&(x=j,l=Yf(a,j))),l===1)throw h=ul,ua(a,0),Ai(a,x),ms(a,Ot()),h;if(l===6)Ai(a,x);else{if(j=a.current.alternate,(x&30)===0&&!D_(j)&&(l=nu(a,x),l===2&&(I=Ir(a),I!==0&&(x=I,l=Yf(a,I))),l===1))throw h=ul,ua(a,0),Ai(a,x),ms(a,Ot()),h;switch(a.finishedWork=j,a.finishedLanes=x,l){case 0:case 1:throw Error(n(345));case 2:da(a,ps,ti);break;case 3:if(Ai(a,x),(x&130023424)===x&&(l=qf+500-Ot(),10<l)){if(os(a,0)!==0)break;if(j=a.suspendedLanes,(j&x)!==x){ts(),a.pingedLanes|=a.suspendedLanes&j;break}a.timeoutHandle=tf(da.bind(null,a,ps,ti),l);break}da(a,ps,ti);break;case 4:if(Ai(a,x),(x&4194240)===x)break;for(l=a.eventTimes,j=-1;0<x;){var U=31-zt(x);I=1<<U,U=l[U],U>j&&(j=U),x&=~I}if(x=j,x=Ot()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*L_(x/1960))-x,10<x){a.timeoutHandle=tf(da.bind(null,a,ps,ti),x);break}da(a,ps,ti);break;case 5:da(a,ps,ti);break;default:throw Error(n(329))}}}return ms(a,Ot()),a.callbackNode===h?uv.bind(null,a):null}function Yf(a,l){var h=dl;return a.current.memoizedState.isDehydrated&&(ua(a,l).flags|=256),a=nu(a,l),a!==2&&(l=ps,ps=h,l!==null&&Xf(l)),a}function Xf(a){ps===null?ps=a:ps.push.apply(ps,a)}function D_(a){for(var l=a;;){if(l.flags&16384){var h=l.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var x=0;x<h.length;x++){var j=h[x],I=j.getSnapshot;j=j.value;try{if(!rr(I(),j))return!1}catch{return!1}}}if(h=l.child,l.subtreeFlags&16384&&h!==null)h.return=l,l=h;else{if(l===a)break;for(;l.sibling===null;){if(l.return===null||l.return===a)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function Ai(a,l){for(l&=~Vf,l&=~Yc,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var h=31-zt(l),x=1<<h;a[h]=-1,l&=~x}}function dv(a){if((kt&6)!==0)throw Error(n(327));io();var l=os(a,0);if((l&1)===0)return ms(a,Ot()),null;var h=nu(a,l);if(a.tag!==0&&h===2){var x=Ir(a);x!==0&&(l=x,h=Yf(a,x))}if(h===1)throw h=ul,ua(a,0),Ai(a,l),ms(a,Ot()),h;if(h===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,da(a,ps,ti),ms(a,Ot()),null}function Qf(a,l){var h=kt;kt|=1;try{return a(l)}finally{kt=h,kt===0&&(ro=Ot()+500,Ic&&Ni())}}function ca(a){Ci!==null&&Ci.tag===0&&(kt&6)===0&&io();var l=kt;kt|=1;var h=Ws.transition,x=vt;try{if(Ws.transition=null,vt=1,a)return a()}finally{vt=x,Ws.transition=h,kt=l,(kt&6)===0&&Ni()}}function Jf(){Es=so.current,Ht(so)}function ua(a,l){a.finishedWork=null,a.finishedLanes=0;var h=a.timeoutHandle;if(h!==-1&&(a.timeoutHandle=-1,m_(h)),gn!==null)for(h=gn.return;h!==null;){var x=h;switch(lf(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&Ec();break;case 3:eo(),Ht(ds),Ht(Wn),kf();break;case 5:yf(x);break;case 4:eo();break;case 13:Ht(Jt);break;case 19:Ht(Jt);break;case 10:pf(x.type._context);break;case 22:case 23:Jf()}h=h.return}if(Tn=a,gn=a=Ti(a.current,null),Pn=Es=l,En=0,ul=null,Vf=Yc=la=0,ps=dl=null,ia!==null){for(l=0;l<ia.length;l++)if(h=ia[l],x=h.interleaved,x!==null){h.interleaved=null;var j=x.next,I=h.pending;if(I!==null){var U=I.next;I.next=j,x.next=U}h.pending=x}ia=null}return a}function fv(a,l){do{var h=gn;try{if(hf(),Dc.current=Hc,Fc){for(var x=en.memoizedState;x!==null;){var j=x.queue;j!==null&&(j.pending=null),x=x.next}Fc=!1}if(oa=0,An=_n=en=null,rl=!1,il=0,Wf.current=null,h===null||h.return===null){En=1,ul=l,gn=null;break}e:{var I=a,U=h.return,X=h,J=l;if(l=Pn,X.flags|=32768,J!==null&&typeof J=="object"&&typeof J.then=="function"){var de=J,Ee=X,Ce=Ee.tag;if((Ee.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var _e=Ee.alternate;_e?(Ee.updateQueue=_e.updateQueue,Ee.memoizedState=_e.memoizedState,Ee.lanes=_e.lanes):(Ee.updateQueue=null,Ee.memoizedState=null)}var He=Px(U);if(He!==null){He.flags&=-257,Lx(He,U,X,I,l),He.mode&1&&zx(I,de,l),l=He,J=de;var Ve=l.updateQueue;if(Ve===null){var Ke=new Set;Ke.add(J),l.updateQueue=Ke}else Ve.add(J);break e}else{if((l&1)===0){zx(I,de,l),eh();break e}J=Error(n(426))}}else if(qt&&X.mode&1){var fn=Px(U);if(fn!==null){(fn.flags&65536)===0&&(fn.flags|=256),Lx(fn,U,X,I,l),df(to(J,X));break e}}I=J=to(J,X),En!==4&&(En=2),dl===null?dl=[I]:dl.push(I),I=U;do{switch(I.tag){case 3:I.flags|=65536,l&=-l,I.lanes|=l;var oe=Rx(I,J,l);ox(I,oe);break e;case 1:X=J;var se=I.type,le=I.stateNode;if((I.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Ei===null||!Ei.has(le)))){I.flags|=65536,l&=-l,I.lanes|=l;var Me=Ox(I,X,l);ox(I,Me);break e}}I=I.return}while(I!==null)}mv(h)}catch(Ye){l=Ye,gn===h&&h!==null&&(gn=h=h.return);continue}break}while(!0)}function hv(){var a=Kc.current;return Kc.current=Hc,a===null?Hc:a}function eh(){(En===0||En===3||En===2)&&(En=4),Tn===null||(la&268435455)===0&&(Yc&268435455)===0||Ai(Tn,Pn)}function nu(a,l){var h=kt;kt|=2;var x=hv();(Tn!==a||Pn!==l)&&(ti=null,ua(a,l));do try{F_();break}catch(j){fv(a,j)}while(!0);if(hf(),kt=h,Kc.current=x,gn!==null)throw Error(n(261));return Tn=null,Pn=0,En}function F_(){for(;gn!==null;)pv(gn)}function B_(){for(;gn!==null&&!Ur();)pv(gn)}function pv(a){var l=vv(a.alternate,a,Es);a.memoizedProps=a.pendingProps,l===null?mv(a):gn=l,Wf.current=null}function mv(a){var l=a;do{var h=l.alternate;if(a=l.return,(l.flags&32768)===0){if(h=M_(h,l,Es),h!==null){gn=h;return}}else{if(h=R_(h,l),h!==null){h.flags&=32767,gn=h;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{En=6,gn=null;return}}if(l=l.sibling,l!==null){gn=l;return}gn=l=a}while(l!==null);En===0&&(En=5)}function da(a,l,h){var x=vt,j=Ws.transition;try{Ws.transition=null,vt=1,U_(a,l,h,x)}finally{Ws.transition=j,vt=x}return null}function U_(a,l,h,x){do io();while(Ci!==null);if((kt&6)!==0)throw Error(n(327));h=a.finishedWork;var j=a.finishedLanes;if(h===null)return null;if(a.finishedWork=null,a.finishedLanes=0,h===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var I=h.lanes|h.childLanes;if(Sn(a,I),a===Tn&&(gn=Tn=null,Pn=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||Qc||(Qc=!0,yv(Cr,function(){return io(),null})),I=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||I){I=Ws.transition,Ws.transition=null;var U=vt;vt=1;var X=kt;kt|=4,Wf.current=null,z_(a,h),iv(h,a),l_(Jd),nt=!!Qd,Jd=Qd=null,a.current=h,P_(h),tr(),kt=X,vt=U,Ws.transition=I}else a.current=h;if(Qc&&(Qc=!1,Ci=a,Jc=j),I=a.pendingLanes,I===0&&(Ei=null),At(h.stateNode),ms(a,Ot()),l!==null)for(x=a.onRecoverableError,h=0;h<l.length;h++)j=l[h],x(j.value,{componentStack:j.stack,digest:j.digest});if(Xc)throw Xc=!1,a=Gf,Gf=null,a;return(Jc&1)!==0&&a.tag!==0&&io(),I=a.pendingLanes,(I&1)!==0?a===Kf?fl++:(fl=0,Kf=a):fl=0,Ni(),null}function io(){if(Ci!==null){var a=at(Jc),l=Ws.transition,h=vt;try{if(Ws.transition=null,vt=16>a?16:a,Ci===null)var x=!1;else{if(a=Ci,Ci=null,Jc=0,(kt&6)!==0)throw Error(n(331));var j=kt;for(kt|=4,We=a.current;We!==null;){var I=We,U=I.child;if((We.flags&16)!==0){var X=I.deletions;if(X!==null){for(var J=0;J<X.length;J++){var de=X[J];for(We=de;We!==null;){var Ee=We;switch(Ee.tag){case 0:case 11:case 15:cl(8,Ee,I)}var Ce=Ee.child;if(Ce!==null)Ce.return=Ee,We=Ce;else for(;We!==null;){Ee=We;var _e=Ee.sibling,He=Ee.return;if(ev(Ee),Ee===de){We=null;break}if(_e!==null){_e.return=He,We=_e;break}We=He}}}var Ve=I.alternate;if(Ve!==null){var Ke=Ve.child;if(Ke!==null){Ve.child=null;do{var fn=Ke.sibling;Ke.sibling=null,Ke=fn}while(Ke!==null)}}We=I}}if((I.subtreeFlags&2064)!==0&&U!==null)U.return=I,We=U;else e:for(;We!==null;){if(I=We,(I.flags&2048)!==0)switch(I.tag){case 0:case 11:case 15:cl(9,I,I.return)}var oe=I.sibling;if(oe!==null){oe.return=I.return,We=oe;break e}We=I.return}}var se=a.current;for(We=se;We!==null;){U=We;var le=U.child;if((U.subtreeFlags&2064)!==0&&le!==null)le.return=U,We=le;else e:for(U=se;We!==null;){if(X=We,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:Gc(9,X)}}catch(Ye){on(X,X.return,Ye)}if(X===U){We=null;break e}var Me=X.sibling;if(Me!==null){Me.return=X.return,We=Me;break e}We=X.return}}if(kt=j,Ni(),ft&&typeof ft.onPostCommitFiberRoot=="function")try{ft.onPostCommitFiberRoot(ct,a)}catch{}x=!0}return x}finally{vt=h,Ws.transition=l}}return!1}function gv(a,l,h){l=to(h,l),l=Rx(a,l,1),a=Si(a,l,1),l=ts(),a!==null&&(ls(a,1,l),ms(a,l))}function on(a,l,h){if(a.tag===3)gv(a,a,h);else for(;l!==null;){if(l.tag===3){gv(l,a,h);break}else if(l.tag===1){var x=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Ei===null||!Ei.has(x))){a=to(h,a),a=Ox(l,a,1),l=Si(l,a,1),a=ts(),l!==null&&(ls(l,1,a),ms(l,a));break}}l=l.return}}function H_(a,l,h){var x=a.pingCache;x!==null&&x.delete(l),l=ts(),a.pingedLanes|=a.suspendedLanes&h,Tn===a&&(Pn&h)===h&&(En===4||En===3&&(Pn&130023424)===Pn&&500>Ot()-qf?ua(a,0):Vf|=h),ms(a,l)}function xv(a,l){l===0&&((a.mode&1)===0?l=1:(l=Ls,Ls<<=1,(Ls&130023424)===0&&(Ls=4194304)));var h=ts();a=Qr(a,l),a!==null&&(ls(a,l,h),ms(a,h))}function Z_(a){var l=a.memoizedState,h=0;l!==null&&(h=l.retryLane),xv(a,h)}function W_(a,l){var h=0;switch(a.tag){case 13:var x=a.stateNode,j=a.memoizedState;j!==null&&(h=j.retryLane);break;case 19:x=a.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(l),xv(a,h)}var vv;vv=function(a,l,h){if(a!==null)if(a.memoizedProps!==l.pendingProps||ds.current)hs=!0;else{if((a.lanes&h)===0&&(l.flags&128)===0)return hs=!1,$_(a,l,h);hs=(a.flags&131072)!==0}else hs=!1,qt&&(l.flags&1048576)!==0&&Xg(l,Tc,l.index);switch(l.lanes=0,l.tag){case 2:var x=l.type;Vc(a,l),a=l.pendingProps;var j=qa(l,Wn.current);Ja(l,h),j=jf(null,l,x,a,j,h);var I=Sf();return l.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,fs(x)?(I=!0,Cc(l)):I=!1,l.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,xf(l),j.updater=Zc,l.stateNode=j,j._reactInternals=l,Tf(l,x,a,h),l=Of(null,l,x,!0,I,h)):(l.tag=0,qt&&I&&of(l),es(null,l,j,h),l=l.child),l;case 16:x=l.elementType;e:{switch(Vc(a,l),a=l.pendingProps,j=x._init,x=j(x._payload),l.type=x,j=l.tag=q_(x),a=ar(x,a),j){case 0:l=Rf(null,l,x,a,h);break e;case 1:l=Zx(null,l,x,a,h);break e;case 11:l=Dx(null,l,x,a,h);break e;case 14:l=Fx(null,l,x,ar(x.type,a),h);break e}throw Error(n(306,x,""))}return l;case 0:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),Rf(a,l,x,j,h);case 1:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),Zx(a,l,x,j,h);case 3:e:{if(Wx(l),a===null)throw Error(n(387));x=l.pendingProps,I=l.memoizedState,j=I.element,ax(a,l),Pc(l,x,null,h);var U=l.memoizedState;if(x=U.element,I.isDehydrated)if(I={element:x,isDehydrated:!1,cache:U.cache,pendingSuspenseBoundaries:U.pendingSuspenseBoundaries,transitions:U.transitions},l.updateQueue.baseState=I,l.memoizedState=I,l.flags&256){j=to(Error(n(423)),l),l=Vx(a,l,x,h,j);break e}else if(x!==j){j=to(Error(n(424)),l),l=Vx(a,l,x,h,j);break e}else for(_s=bi(l.stateNode.containerInfo.firstChild),Ss=l,qt=!0,ir=null,h=rx(l,null,x,h),l.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(Ya(),x===j){l=ei(a,l,h);break e}es(a,l,x,h)}l=l.child}return l;case 5:return cx(l),a===null&&uf(l),x=l.type,j=l.pendingProps,I=a!==null?a.memoizedProps:null,U=j.children,ef(x,j)?U=null:I!==null&&ef(x,I)&&(l.flags|=32),Hx(a,l),es(a,l,U,h),l.child;case 6:return a===null&&uf(l),null;case 13:return qx(a,l,h);case 4:return vf(l,l.stateNode.containerInfo),x=l.pendingProps,a===null?l.child=Xa(l,null,x,h):es(a,l,x,h),l.child;case 11:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),Dx(a,l,x,j,h);case 7:return es(a,l,l.pendingProps,h),l.child;case 8:return es(a,l,l.pendingProps.children,h),l.child;case 12:return es(a,l,l.pendingProps.children,h),l.child;case 10:e:{if(x=l.type._context,j=l.pendingProps,I=l.memoizedProps,U=j.value,Dt(Rc,x._currentValue),x._currentValue=U,I!==null)if(rr(I.value,U)){if(I.children===j.children&&!ds.current){l=ei(a,l,h);break e}}else for(I=l.child,I!==null&&(I.return=l);I!==null;){var X=I.dependencies;if(X!==null){U=I.child;for(var J=X.firstContext;J!==null;){if(J.context===x){if(I.tag===1){J=Jr(-1,h&-h),J.tag=2;var de=I.updateQueue;if(de!==null){de=de.shared;var Ee=de.pending;Ee===null?J.next=J:(J.next=Ee.next,Ee.next=J),de.pending=J}}I.lanes|=h,J=I.alternate,J!==null&&(J.lanes|=h),mf(I.return,h,l),X.lanes|=h;break}J=J.next}}else if(I.tag===10)U=I.type===l.type?null:I.child;else if(I.tag===18){if(U=I.return,U===null)throw Error(n(341));U.lanes|=h,X=U.alternate,X!==null&&(X.lanes|=h),mf(U,h,l),U=I.sibling}else U=I.child;if(U!==null)U.return=I;else for(U=I;U!==null;){if(U===l){U=null;break}if(I=U.sibling,I!==null){I.return=U.return,U=I;break}U=U.return}I=U}es(a,l,j.children,h),l=l.child}return l;case 9:return j=l.type,x=l.pendingProps.children,Ja(l,h),j=Hs(j),x=x(j),l.flags|=1,es(a,l,x,h),l.child;case 14:return x=l.type,j=ar(x,l.pendingProps),j=ar(x.type,j),Fx(a,l,x,j,h);case 15:return Bx(a,l,l.type,l.pendingProps,h);case 17:return x=l.type,j=l.pendingProps,j=l.elementType===x?j:ar(x,j),Vc(a,l),l.tag=1,fs(x)?(a=!0,Cc(l)):a=!1,Ja(l,h),$x(l,x,j),Tf(l,x,j,h),Of(null,l,x,!0,a,h);case 19:return Kx(a,l,h);case 22:return Ux(a,l,h)}throw Error(n(156,l.tag))};function yv(a,l){return Ns(a,l)}function V_(a,l,h,x){this.tag=a,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Vs(a,l,h,x){return new V_(a,l,h,x)}function th(a){return a=a.prototype,!(!a||!a.isReactComponent)}function q_(a){if(typeof a=="function")return th(a)?1:0;if(a!=null){if(a=a.$$typeof,a===Z)return 11;if(a===$)return 14}return 2}function Ti(a,l){var h=a.alternate;return h===null?(h=Vs(a.tag,l,a.key,a.mode),h.elementType=a.elementType,h.type=a.type,h.stateNode=a.stateNode,h.alternate=a,a.alternate=h):(h.pendingProps=l,h.type=a.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=a.flags&14680064,h.childLanes=a.childLanes,h.lanes=a.lanes,h.child=a.child,h.memoizedProps=a.memoizedProps,h.memoizedState=a.memoizedState,h.updateQueue=a.updateQueue,l=a.dependencies,h.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},h.sibling=a.sibling,h.index=a.index,h.ref=a.ref,h}function su(a,l,h,x,j,I){var U=2;if(x=a,typeof a=="function")th(a)&&(U=1);else if(typeof a=="string")U=5;else e:switch(a){case F:return fa(h.children,j,I,l);case W:U=8,j|=8;break;case M:return a=Vs(12,h,l,j|2),a.elementType=M,a.lanes=I,a;case E:return a=Vs(13,h,l,j),a.elementType=E,a.lanes=I,a;case C:return a=Vs(19,h,l,j),a.elementType=C,a.lanes=I,a;case B:return ru(h,j,I,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case O:U=10;break e;case T:U=9;break e;case Z:U=11;break e;case $:U=14;break e;case L:U=16,x=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return l=Vs(U,h,l,j),l.elementType=a,l.type=x,l.lanes=I,l}function fa(a,l,h,x){return a=Vs(7,a,x,l),a.lanes=h,a}function ru(a,l,h,x){return a=Vs(22,a,x,l),a.elementType=B,a.lanes=h,a.stateNode={isHidden:!1},a}function nh(a,l,h){return a=Vs(6,a,null,l),a.lanes=h,a}function sh(a,l,h){return l=Vs(4,a.children!==null?a.children:[],a.key,l),l.lanes=h,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function G_(a,l,h,x,j){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qn(0),this.expirationTimes=Qn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qn(0),this.identifierPrefix=x,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function rh(a,l,h,x,j,I,U,X,J){return a=new G_(a,l,h,X,J),l===1?(l=1,I===!0&&(l|=8)):l=0,I=Vs(3,null,null,l),a.current=I,I.stateNode=a,I.memoizedState={element:x,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},xf(I),a}function K_(a,l,h){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:x==null?null:""+x,children:a,containerInfo:l,implementation:h}}function bv(a){if(!a)return wi;a=a._reactInternals;e:{if(Hn(a)!==a||a.tag!==1)throw Error(n(170));var l=a;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(fs(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(a.tag===1){var h=a.type;if(fs(h))return Gg(a,h,l)}return l}function kv(a,l,h,x,j,I,U,X,J){return a=rh(h,x,!0,a,j,I,U,X,J),a.context=bv(null),h=a.current,x=ts(),j=Ii(h),I=Jr(x,j),I.callback=l??null,Si(h,I,j),a.current.lanes=j,ls(a,j,x),ms(a,x),a}function iu(a,l,h,x){var j=l.current,I=ts(),U=Ii(j);return h=bv(h),l.context===null?l.context=h:l.pendingContext=h,l=Jr(I,U),l.payload={element:a},x=x===void 0?null:x,x!==null&&(l.callback=x),a=Si(j,l,U),a!==null&&(cr(a,j,U,I),zc(a,j,U)),U}function au(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function wv(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var h=a.retryLane;a.retryLane=h!==0&&h<l?h:l}}function ih(a,l){wv(a,l),(a=a.alternate)&&wv(a,l)}function Y_(){return null}var Nv=typeof reportError=="function"?reportError:function(a){console.error(a)};function ah(a){this._internalRoot=a}ou.prototype.render=ah.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(n(409));iu(a,l,null,null)},ou.prototype.unmount=ah.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ca(function(){iu(null,a,null,null)}),l[Gr]=null}};function ou(a){this._internalRoot=a}ou.prototype.unstable_scheduleHydration=function(a){if(a){var l=Zr();a={blockedOn:null,target:a,priority:l};for(var h=0;h<pn.length&&l!==0&&l<pn[h].priority;h++);pn.splice(h,0,a),h===0&&Pa(a)}};function oh(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function lu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function jv(){}function X_(a,l,h,x,j){if(j){if(typeof x=="function"){var I=x;x=function(){var de=au(U);I.call(de)}}var U=kv(l,x,a,0,null,!1,!1,"",jv);return a._reactRootContainer=U,a[Gr]=U.current,Yo(a.nodeType===8?a.parentNode:a),ca(),U}for(;j=a.lastChild;)a.removeChild(j);if(typeof x=="function"){var X=x;x=function(){var de=au(J);X.call(de)}}var J=rh(a,0,!1,null,null,!1,!1,"",jv);return a._reactRootContainer=J,a[Gr]=J.current,Yo(a.nodeType===8?a.parentNode:a),ca(function(){iu(l,J,h,x)}),J}function cu(a,l,h,x,j){var I=h._reactRootContainer;if(I){var U=I;if(typeof j=="function"){var X=j;j=function(){var J=au(U);X.call(J)}}iu(l,U,a,j)}else U=X_(h,l,a,j,x);return au(U)}cs=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var h=Ds(l.pendingLanes);h!==0&&(Fs(l,h|1),ms(l,Ot()),(kt&6)===0&&(ro=Ot()+500,Ni()))}break;case 13:ca(function(){var x=Qr(a,1);if(x!==null){var j=ts();cr(x,a,1,j)}}),ih(a,1)}},Pt=function(a){if(a.tag===13){var l=Qr(a,134217728);if(l!==null){var h=ts();cr(l,a,134217728,h)}ih(a,134217728)}},ht=function(a){if(a.tag===13){var l=Ii(a),h=Qr(a,l);if(h!==null){var x=ts();cr(h,a,l,x)}ih(a,l)}},Zr=function(){return vt},Jn=function(a,l){var h=vt;try{return vt=a,l()}finally{vt=h}},Qs=function(a,l,h){switch(l){case"input":if(Ge(a,h),l=h.name,h.type==="radio"&&l!=null){for(h=a;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<h.length;l++){var x=h[l];if(x!==a&&x.form===a.form){var j=_c(x);if(!j)throw Error(n(90));Se(x),Ge(x,j)}}}break;case"textarea":ln(a,h);break;case"select":l=h.value,l!=null&&jt(a,!!h.multiple,l,!1)}},Oe=Qf,st=ca;var Q_={usingClientEntryPoint:!1,Events:[Jo,Wa,_c,Q,pe,Qf]},hl={findFiberByHostInstance:ta,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},J_={bundleType:hl.bundleType,version:hl.version,rendererPackageName:hl.rendererPackageName,rendererConfig:hl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:R.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=mi(a),a===null?null:a.stateNode},findFiberByHostInstance:hl.findFiberByHostInstance||Y_,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 uu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!uu.isDisabled&&uu.supportsFiber)try{ct=uu.inject(J_),ft=uu}catch{}}return gs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Q_,gs.createPortal=function(a,l){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!oh(l))throw Error(n(200));return K_(a,l,null,h)},gs.createRoot=function(a,l){if(!oh(a))throw Error(n(299));var h=!1,x="",j=Nv;return l!=null&&(l.unstable_strictMode===!0&&(h=!0),l.identifierPrefix!==void 0&&(x=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),l=rh(a,1,!1,null,null,h,!1,x,j),a[Gr]=l.current,Yo(a.nodeType===8?a.parentNode:a),new ah(l)},gs.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var l=a._reactInternals;if(l===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=mi(l),a=a===null?null:a.stateNode,a},gs.flushSync=function(a){return ca(a)},gs.hydrate=function(a,l,h){if(!lu(l))throw Error(n(200));return cu(null,a,l,!0,h)},gs.hydrateRoot=function(a,l,h){if(!oh(a))throw Error(n(405));var x=h!=null&&h.hydratedSources||null,j=!1,I="",U=Nv;if(h!=null&&(h.unstable_strictMode===!0&&(j=!0),h.identifierPrefix!==void 0&&(I=h.identifierPrefix),h.onRecoverableError!==void 0&&(U=h.onRecoverableError)),l=kv(l,null,a,1,h??null,j,!1,I,U),a[Gr]=l.current,Yo(a),x)for(a=0;a<x.length;a++)h=x[a],j=h._getVersion,j=j(h._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[h,j]:l.mutableSourceEagerHydrationData.push(h,j);return new ou(l)},gs.render=function(a,l,h){if(!lu(l))throw Error(n(200));return cu(null,a,l,!1,h)},gs.unmountComponentAtNode=function(a){if(!lu(a))throw Error(n(40));return a._reactRootContainer?(ca(function(){cu(null,null,a,!1,function(){a._reactRootContainer=null,a[Gr]=null})}),!0):!1},gs.unstable_batchedUpdates=Qf,gs.unstable_renderSubtreeIntoContainer=function(a,l,h,x){if(!lu(h))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return cu(a,l,h,!1,x)},gs.version="18.3.1-next-f1338f8080-20240426",gs}var Rv;function Bb(){if(Rv)return dh.exports;Rv=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(),dh.exports=lE(),dh.exports}var Ov;function cE(){if(Ov)return du;Ov=1;var e=Bb();return du.createRoot=e.createRoot,du.hydrateRoot=e.hydrateRoot,du}var uE=cE(),Li,wo,No;class zr{constructor(t){Lt(this,Li);Lt(this,wo,new Set);Lt(this,No,!1);ut(this,"get",()=>Re(this,Li));ut(this,"subscribe",t=>(Re(this,wo).add(t),()=>{Re(this,wo).delete(t)}));Zt(this,Li,t)}set(t){const n=typeof t=="function"?t(Re(this,Li)):t;Object.is(n,Re(this,Li))||(Zt(this,Li,n),!Re(this,No)&&(Zt(this,No,!0),queueMicrotask(()=>{Zt(this,No,!1);for(const r of[...Re(this,wo)])r()})))}}Li=new WeakMap,wo=new WeakMap,No=new WeakMap;var zv;function me(e,t,n){function r(u,f){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:f,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,f);const d=c.prototype,p=Object.keys(d);for(let m=0;m<p.length;m++){const g=p[m];g in u||(u[g]=d[g].bind(u))}}const i=(n==null?void 0:n.Parent)??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function c(u){var f;const d=n!=null&&n.Parent?new o:this;r(d,u),(f=d._zod).deferred??(f.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(c,"init",{value:r}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>{var f,d;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(d=(f=u==null?void 0:u._zod)==null?void 0:f.traits)==null?void 0:d.has(e)}}),Object.defineProperty(c,"name",{value:e}),c}class xo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ub extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(zv=globalThis).__zod_globalConfig??(zv.__zod_globalConfig={});const xm=globalThis.__zod_globalConfig;function li(e){return xm}function Hb(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function xp(e,t){return typeof t=="bigint"?t.toString():t}function hd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function vm(e){return e==null}function ym(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function dE(e,t){const n=e/t,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const Pv=Symbol("evaluating");function Mt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Pv)return r===void 0&&(r=Pv,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Ra(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Yi(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Lv(e){return JSON.stringify(e)}function fE(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Zb="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ul(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const hE=hd(()=>{var e;if(xm.jitless||typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Io(e){if(Ul(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Ul(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Wb(e){return Io(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const pE=new Set(["string","number","symbol"]);function Ao(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Xi(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function Qe(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function mE(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const gE={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function xE(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Yi(e._zod.def,{get shape(){const c={};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&(c[u]=n.shape[u])}return Ra(this,"shape",c),c},checks:[]});return Xi(e,o)}function vE(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Yi(e._zod.def,{get shape(){const c={...e._zod.def.shape};for(const u in t){if(!(u in n.shape))throw new Error(`Unrecognized key: "${u}"`);t[u]&&delete c[u]}return Ra(this,"shape",c),c},checks:[]});return Xi(e,o)}function yE(e,t){if(!Io(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Yi(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Ra(this,"shape",o),o}});return Xi(e,i)}function bE(e,t){if(!Io(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Yi(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return Ra(this,"shape",r),r}});return Xi(e,n)}function kE(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Yi(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return Ra(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Xi(e,n)}function wE(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=Yi(t._zod.def,{get shape(){const u=t._zod.def.shape,f={...u};if(n)for(const d in n){if(!(d in u))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(f[d]=e?new e({type:"optional",innerType:u[d]}):u[d])}else for(const d in u)f[d]=e?new e({type:"optional",innerType:u[d]}):u[d];return Ra(this,"shape",f),f},checks:[]});return Xi(t,c)}function NE(e,t,n){const r=Yi(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(o[c]=new e({type:"nonoptional",innerType:i[c]}))}else for(const c in i)o[c]=new e({type:"nonoptional",innerType:i[c]});return Ra(this,"shape",o),o}});return Xi(t,r)}function ho(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function jE(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function po(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function fu(e){return typeof e=="string"?e:e==null?void 0:e.message}function ci(e,t,n){var f,d,p,m,g,v;const r=e.message?e.message:fu((p=(d=(f=e.inst)==null?void 0:f._zod.def)==null?void 0:d.error)==null?void 0:p.call(d,e))??fu((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??fu((g=n.customError)==null?void 0:g.call(n,e))??fu((v=n.localeError)==null?void 0:v.call(n,e))??"Invalid input",{inst:i,continue:o,input:c,...u}=e;return u.path??(u.path=[]),u.message=r,t!=null&&t.reportInput&&(u.input=c),u}function bm(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Hl(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Vb=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,xp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},qb=me("$ZodError",Vb),Gb=me("$ZodError",Vb,{Parent:Error});function SE(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function _E(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>r({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")r({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")r({issues:c.issues},[...o,...c.path]);else{const u=[...o,...c.path];if(u.length===0)n._errors.push(t(c));else{let f=n,d=0;for(;d<u.length;){const p=u[d];d===u.length-1?(f[p]=f[p]||{_errors:[]},f[p]._errors.push(t(c))):f[p]=f[p]||{_errors:[]},f=f[p],d++}}}};return r(e),n}const km=e=>(t,n,r,i)=>{const o=r?{...r,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new xo;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(f=>ci(f,o,li())));throw Zb(u,i==null?void 0:i.callee),u}return c.value},wm=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(f=>ci(f,o,li())));throw Zb(u,i==null?void 0:i.callee),u}return c.value},pd=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new xo;return o.issues.length?{success:!1,error:new(e??qb)(o.issues.map(c=>ci(c,i,li())))}:{success:!0,data:o.value}},EE=pd(Gb),md=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>ci(c,i,li())))}:{success:!0,data:o.value}},CE=md(Gb),IE=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return km(e)(t,n,i)},AE=e=>(t,n,r)=>km(e)(t,n,r),TE=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return wm(e)(t,n,i)},$E=e=>async(t,n,r)=>wm(e)(t,n,r),ME=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return pd(e)(t,n,i)},RE=e=>(t,n,r)=>pd(e)(t,n,r),OE=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return md(e)(t,n,i)},zE=e=>async(t,n,r)=>md(e)(t,n,r),PE=/^[cC][0-9a-z]{6,}$/,LE=/^[0-9a-z]+$/,DE=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,FE=/^[0-9a-vA-V]{20}$/,BE=/^[A-Za-z0-9]{27}$/,UE=/^[a-zA-Z0-9_-]{21}$/,HE=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ZE=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Dv=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,WE=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,VE="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function qE(){return new RegExp(VE,"u")}const GE=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,KE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,YE=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,XE=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,QE=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Kb=/^[A-Za-z0-9_-]*$/,JE=/^https?$/,e1=/^\+[1-9]\d{6,14}$/,Yb="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",t1=new RegExp(`^${Yb}$`);function Xb(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function n1(e){return new RegExp(`^${Xb(e)}$`)}function s1(e){const t=Xb({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Yb}T(?:${r})$`)}const r1=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},i1=/^-?\d+$/,Qb=/^-?\d+(?:\.\d+)?$/,a1=/^(?:true|false)$/i,o1=/^null$/i,l1=/^[^A-Z]*$/,c1=/^[^a-z]*$/,ks=me("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Jb={number:"number",bigint:"bigint",object:"date"},ek=me("$ZodCheckLessThan",(e,t)=>{ks.init(e,t);const n=Jb[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tk=me("$ZodCheckGreaterThan",(e,t)=>{ks.init(e,t);const n=Jb[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),u1=me("$ZodCheckMultipleOf",(e,t)=>{ks.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):dE(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),d1=me("$ZodCheckNumberFormat",(e,t)=>{var c;ks.init(e,t),t.format=t.format||"float64";const n=(c=t.format)==null?void 0:c.includes("int"),r=n?"int":"number",[i,o]=gE[t.format];e._zod.onattach.push(u=>{const f=u._zod.bag;f.format=t.format,f.minimum=i,f.maximum=o,n&&(f.pattern=i1)}),e._zod.check=u=>{const f=u.value;if(n){if(!Number.isInteger(f)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:f,inst:e});return}if(!Number.isSafeInteger(f)){f>0?u.issues.push({input:f,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:f,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}f<i&&u.issues.push({origin:"number",input:f,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),f>o&&u.issues.push({origin:"number",input:f,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),f1=me("$ZodCheckMaxLength",(e,t)=>{var n;ks.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!vm(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const c=bm(i);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),h1=me("$ZodCheckMinLength",(e,t)=>{var n;ks.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!vm(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const c=bm(i);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),p1=me("$ZodCheckLengthEquals",(e,t)=>{var n;ks.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!vm(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,o=i.length;if(o===t.length)return;const c=bm(i),u=o>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),gd=me("$ZodCheckStringFormat",(e,t)=>{var n,r;ks.init(e,t),e._zod.onattach.push(i=>{const o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),m1=me("$ZodCheckRegex",(e,t)=>{gd.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),g1=me("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=l1),gd.init(e,t)}),x1=me("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=c1),gd.init(e,t)}),v1=me("$ZodCheckIncludes",(e,t)=>{ks.init(e,t);const n=Ao(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),y1=me("$ZodCheckStartsWith",(e,t)=>{ks.init(e,t);const n=new RegExp(`^${Ao(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),b1=me("$ZodCheckEndsWith",(e,t)=>{ks.init(e,t);const n=new RegExp(`.*${Ao(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),k1=me("$ZodCheckOverwrite",(e,t)=>{ks.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class w1{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
41
- `).filter(c=>c),i=Math.min(...r.map(c=>c.length-c.trimStart().length)),o=r.map(c=>c.slice(i)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...n,i.join(`
42
- `))}}const N1={major:4,minor:4,patch:3},Kt=me("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=N1;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const c of o._zod.onattach)c(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,f,d)=>{let p=ho(u),m;for(const g of f){if(g._zod.def.when){if(jE(u)||!g._zod.def.when(u))continue}else if(p)continue;const v=u.issues.length,y=g._zod.check(u);if(y instanceof Promise&&(d==null?void 0:d.async)===!1)throw new xo;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,u.issues.length!==v&&(p||(p=ho(u,v)))});else{if(u.issues.length===v)continue;p||(p=ho(u,v))}}return m?m.then(()=>u):u},c=(u,f,d)=>{if(ho(u))return u.aborted=!0,u;const p=o(f,r,d);if(p instanceof Promise){if(d.async===!1)throw new xo;return p.then(m=>e._zod.parse(m,d))}return e._zod.parse(p,d)};e._zod.run=(u,f)=>{if(f.skipChecks)return e._zod.parse(u,f);if(f.direction==="backward"){const p=e._zod.parse({value:u.value,issues:[]},{...f,skipChecks:!0});return p instanceof Promise?p.then(m=>c(m,u,f)):c(p,u,f)}const d=e._zod.parse(u,f);if(d instanceof Promise){if(f.async===!1)throw new xo;return d.then(p=>o(p,r,f))}return o(d,r,f)}}Mt(e,"~standard",()=>({validate:o=>{var c;try{const u=EE(e,o);return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}}catch{return CE(e,o).then(f=>{var d;return f.success?{value:f.data}:{issues:(d=f.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}))}),Nm=me("$ZodString",(e,t)=>{var n;Kt.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??r1(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Yt=me("$ZodStringFormat",(e,t)=>{gd.init(e,t),Nm.init(e,t)}),j1=me("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ZE),Yt.init(e,t)}),S1=me("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Dv(r))}else t.pattern??(t.pattern=Dv());Yt.init(e,t)}),_1=me("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=WE),Yt.init(e,t)}),E1=me("$ZodURL",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{var r;try{const i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===JE.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),C1=me("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=qE()),Yt.init(e,t)}),I1=me("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=UE),Yt.init(e,t)}),A1=me("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=PE),Yt.init(e,t)}),T1=me("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=LE),Yt.init(e,t)}),$1=me("$ZodULID",(e,t)=>{t.pattern??(t.pattern=DE),Yt.init(e,t)}),M1=me("$ZodXID",(e,t)=>{t.pattern??(t.pattern=FE),Yt.init(e,t)}),R1=me("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=BE),Yt.init(e,t)}),O1=me("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=s1(t)),Yt.init(e,t)}),z1=me("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=t1),Yt.init(e,t)}),P1=me("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=n1(t)),Yt.init(e,t)}),L1=me("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=HE),Yt.init(e,t)}),D1=me("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=GE),Yt.init(e,t),e._zod.bag.format="ipv4"}),F1=me("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=KE),Yt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),B1=me("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=YE),Yt.init(e,t)}),U1=me("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=XE),Yt.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,o]=r;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function nk(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const H1=me("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=QE),Yt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{nk(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Z1(e){if(!Kb.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return nk(n)}const W1=me("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Kb),Yt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Z1(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),V1=me("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e1),Yt.init(e,t)});function q1(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const G1=me("$ZodJWT",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{q1(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),sk=me("$ZodNumber",(e,t)=>{Kt.init(e,t),e._zod.pattern=e._zod.bag.pattern??Qb,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),K1=me("$ZodNumberFormat",(e,t)=>{d1.init(e,t),sk.init(e,t)}),Y1=me("$ZodBoolean",(e,t)=>{Kt.init(e,t),e._zod.pattern=a1,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),X1=me("$ZodNull",(e,t)=>{Kt.init(e,t),e._zod.pattern=o1,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),Q1=me("$ZodUnknown",(e,t)=>{Kt.init(e,t),e._zod.parse=n=>n}),J1=me("$ZodNever",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Fv(e,t,n){e.issues.length&&t.issues.push(...po(n,e.issues)),t.value[n]=e.value}const eC=me("$ZodArray",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let c=0;c<i.length;c++){const u=i[c],f=t.element._zod.run({value:u,issues:[]},r);f instanceof Promise?o.push(f.then(d=>Fv(d,n,c))):Fv(f,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function Uu(e,t,n,r,i,o){const c=n in r;if(e.issues.length){if(i&&o&&!c)return;t.issues.push(...po(n,e.issues))}if(!c&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?c&&(t.value[n]=void 0):t.value[n]=e.value}function rk(e){var r,i,o,c;const t=Object.keys(e.shape);for(const u of t)if(!((c=(o=(i=(r=e.shape)==null?void 0:r[u])==null?void 0:i._zod)==null?void 0:o.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=mE(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function ik(e,t,n,r,i,o){const c=[],u=i.keySet,f=i.catchall._zod,d=f.def.type,p=f.optin==="optional",m=f.optout==="optional";for(const g in t){if(g==="__proto__"||u.has(g))continue;if(d==="never"){c.push(g);continue}const v=f.run({value:t[g],issues:[]},r);v instanceof Promise?e.push(v.then(y=>Uu(y,n,g,t,p,m))):Uu(v,n,g,t,p,m)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const tC=me("$ZodObject",(e,t)=>{Kt.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const f={...u};return Object.defineProperty(t,"shape",{value:f}),f}})}const r=hd(()=>rk(t));Mt(e._zod,"propValues",()=>{const u=t.shape,f={};for(const d in u){const p=u[d]._zod;if(p.values){f[d]??(f[d]=new Set);for(const m of p.values)f[d].add(m)}}return f});const i=Ul,o=t.catchall;let c;e._zod.parse=(u,f)=>{c??(c=r.value);const d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value={};const p=[],m=c.shape;for(const g of c.keys){const v=m[g],y=v._zod.optin==="optional",S=v._zod.optout==="optional",k=v._zod.run({value:d[g],issues:[]},f);k instanceof Promise?p.push(k.then(w=>Uu(w,u,g,d,y,S))):Uu(k,u,g,d,y,S)}return o?ik(p,d,u,f,r.value,e):p.length?Promise.all(p).then(()=>u):u}}),nC=me("$ZodObjectJIT",(e,t)=>{tC.init(e,t);const n=e._zod.parse,r=hd(()=>rk(t)),i=g=>{var N,R;const v=new w1(["shape","payload","ctx"]),y=r.value,S=D=>{const P=Lv(D);return`shape[${P}]._zod.run({ value: input[${P}], issues: [] }, ctx)`};v.write("const input = payload.value;");const k=Object.create(null);let w=0;for(const D of y.keys)k[D]=`key_${w++}`;v.write("const newResult = {};");for(const D of y.keys){const P=k[D],F=Lv(D),W=g[D],M=((N=W==null?void 0:W._zod)==null?void 0:N.optin)==="optional",O=((R=W==null?void 0:W._zod)==null?void 0:R.optout)==="optional";v.write(`const ${P} = ${S(D)};`),M&&O?v.write(`
43
- if (${P}.issues.length) {
44
- if (${F} in input) {
45
- payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
46
- ...iss,
47
- path: iss.path ? [${F}, ...iss.path] : [${F}]
48
- })));
49
- }
50
- }
51
-
52
- if (${P}.value === undefined) {
53
- if (${F} in input) {
54
- newResult[${F}] = undefined;
55
- }
56
- } else {
57
- newResult[${F}] = ${P}.value;
58
- }
59
-
60
- `):M?v.write(`
61
- if (${P}.issues.length) {
62
- payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
63
- ...iss,
64
- path: iss.path ? [${F}, ...iss.path] : [${F}]
65
- })));
66
- }
67
-
68
- if (${P}.value === undefined) {
69
- if (${F} in input) {
70
- newResult[${F}] = undefined;
71
- }
72
- } else {
73
- newResult[${F}] = ${P}.value;
74
- }
75
-
76
- `):v.write(`
77
- const ${P}_present = ${F} in input;
78
- if (${P}.issues.length) {
79
- payload.issues = payload.issues.concat(${P}.issues.map(iss => ({
80
- ...iss,
81
- path: iss.path ? [${F}, ...iss.path] : [${F}]
82
- })));
83
- }
84
- if (!${P}_present && !${P}.issues.length) {
85
- payload.issues.push({
86
- code: "invalid_type",
87
- expected: "nonoptional",
88
- input: undefined,
89
- path: [${F}]
90
- });
91
- }
92
-
93
- if (${P}_present) {
94
- if (${P}.value === undefined) {
95
- newResult[${F}] = undefined;
96
- } else {
97
- newResult[${F}] = ${P}.value;
98
- }
99
- }
100
-
101
- `)}v.write("payload.value = newResult;"),v.write("return payload;");const A=v.compile();return(D,P)=>A(g,D,P)};let o;const c=Ul,u=!xm.jitless,d=u&&hE.value,p=t.catchall;let m;e._zod.parse=(g,v)=>{m??(m=r.value);const y=g.value;return c(y)?u&&d&&(v==null?void 0:v.async)===!1&&v.jitless!==!0?(o||(o=i(t.shape)),g=o(g,v),p?ik([],y,g,v,m,e):g):n(g,v):(g.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),g)}});function Bv(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!ho(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>ci(c,r,li())))}),t)}const ak=me("$ZodUnion",(e,t)=>{Kt.init(e,t),Mt(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Mt(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Mt(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Mt(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>ym(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const c=[];for(const u of t.options){const f=u._zod.run({value:r.value,issues:[]},i);if(f instanceof Promise)c.push(f),o=!0;else{if(f.issues.length===0)return f;c.push(f)}}return o?Promise.all(c).then(u=>Bv(u,r,e,i)):Bv(c,r,e,i)}}),sC=me("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ak.init(e,t);const n=e._zod.parse;Mt(e._zod,"propValues",()=>{const i={};for(const o of t.options){const c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,f]of Object.entries(c)){i[u]||(i[u]=new Set);for(const d of f)i[u].add(d)}}return i});const r=hd(()=>{var c;const i=t.options,o=new Map;for(const u of i){const f=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!f||f.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const d of f){if(o.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);o.set(d,u)}}return o});e._zod.parse=(i,o)=>{const c=i.value;if(!Ul(c))return i.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),i;const u=r.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:c,path:[t.discriminator],inst:e}),i)}}),rC=me("$ZodIntersection",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),c=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([f,d])=>Uv(n,f,d)):Uv(n,o,c)}});function vp(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Io(e)&&Io(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of r){const c=vp(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};i[o]=c.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],o=t[r],c=vp(i,o);if(!c.valid)return{valid:!1,mergeErrorPath:[r,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Uv(e,t,n){const r=new Map;let i;for(const u of t.issues)if(u.code==="unrecognized_keys"){i??(i=u);for(const f of u.keys)r.has(f)||r.set(f,{}),r.get(f).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const f of u.keys)r.has(f)||r.set(f,{}),r.get(f).r=!0;else e.issues.push(u);const o=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&i&&e.issues.push({...i,keys:o}),ho(e))return e;const c=vp(t.value,n.value);if(!c.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);return e.value=c.data,e}const iC=me("$ZodRecord",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Io(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const d of c)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){u.add(typeof d=="number"?d.toString():d);const p=t.keyType._zod.run({value:d,issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(v=>ci(v,r,li())),input:d,path:[d],inst:e});continue}const m=p.value,g=t.valueType._zod.run({value:i[d],issues:[]},r);g instanceof Promise?o.push(g.then(v=>{v.issues.length&&n.issues.push(...po(d,v.issues)),n.value[m]=v.value})):(g.issues.length&&n.issues.push(...po(d,g.issues)),n.value[m]=g.value)}let f;for(const d in i)u.has(d)||(f=f??[],f.push(d));f&&f.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:f})}else{n.value={};for(const u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Qb.test(u)&&f.issues.length){const m=t.keyType._zod.run({value:Number(u),issues:[]},r);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(f=m)}if(f.issues.length){t.mode==="loose"?n.value[u]=i[u]:n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(m=>ci(m,r,li())),input:u,path:[u],inst:e});continue}const p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?o.push(p.then(m=>{m.issues.length&&n.issues.push(...po(u,m.issues)),n.value[f.value]=m.value})):(p.issues.length&&n.issues.push(...po(u,p.issues)),n.value[f.value]=p.value)}}return o.length?Promise.all(o).then(()=>n):n}}),aC=me("$ZodEnum",(e,t)=>{Kt.init(e,t);const n=Hb(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>pE.has(typeof i)).map(i=>typeof i=="string"?Ao(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),oC=me("$ZodLiteral",(e,t)=>{if(Kt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ao(r):r?Ao(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),lC=me("$ZodTransform",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ub(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(n.value=c,n.fallback=!0,n));if(i instanceof Promise)throw new xo;return n.value=i,n.fallback=!0,n}});function Hv(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const ok=me("$ZodOptional",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ym(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=n.value,o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(c=>Hv(c,i)):Hv(o,i)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),cC=me("$ZodExactOptional",(e,t)=>{ok.init(e,t),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),uC=me("$ZodNullable",(e,t)=>{Kt.init(e,t),Mt(e._zod,"optin",()=>t.innerType._zod.optin),Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ym(n.source)}|null)$`):void 0}),Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),dC=me("$ZodDefault",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Zv(o,t)):Zv(i,t)}});function Zv(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const fC=me("$ZodPrefault",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),hC=me("$ZodNonOptional",(e,t)=>{Kt.init(e,t),Mt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Wv(o,e)):Wv(i,e)}});function Wv(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const pC=me("$ZodCatch",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>ci(c,r,li()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>ci(o,r,li()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),mC=me("$ZodPipe",(e,t)=>{Kt.init(e,t),Mt(e._zod,"values",()=>t.in._zod.values),Mt(e._zod,"optin",()=>t.in._zod.optin),Mt(e._zod,"optout",()=>t.out._zod.optout),Mt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(c=>hu(c,t.in,r)):hu(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>hu(o,t.out,r)):hu(i,t.out,r)}});function hu(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const gC=me("$ZodReadonly",(e,t)=>{Kt.init(e,t),Mt(e._zod,"propValues",()=>t.innerType._zod.propValues),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Mt(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Vv):Vv(i)}});function Vv(e){return e.value=Object.freeze(e.value),e}const xC=me("$ZodCustom",(e,t)=>{ks.init(e,t),Kt.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>qv(o,n,r,e));qv(i,n,r,e)}});function qv(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Hl(i))}}var Gv;class vC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function yC(){return new vC}(Gv=globalThis).__zod_globalRegistry??(Gv.__zod_globalRegistry=yC());const El=globalThis.__zod_globalRegistry;function bC(e,t){return new e({type:"string",...Qe(t)})}function kC(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Qe(t)})}function Kv(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Qe(t)})}function wC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Qe(t)})}function NC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Qe(t)})}function jC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Qe(t)})}function SC(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Qe(t)})}function lk(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Qe(t)})}function _C(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Qe(t)})}function EC(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Qe(t)})}function CC(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Qe(t)})}function IC(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Qe(t)})}function AC(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Qe(t)})}function TC(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Qe(t)})}function $C(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Qe(t)})}function MC(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Qe(t)})}function RC(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Qe(t)})}function OC(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Qe(t)})}function zC(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Qe(t)})}function PC(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Qe(t)})}function LC(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Qe(t)})}function DC(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Qe(t)})}function FC(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Qe(t)})}function BC(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Qe(t)})}function UC(e,t){return new e({type:"string",format:"date",check:"string_format",...Qe(t)})}function HC(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Qe(t)})}function ZC(e,t){return new e({type:"string",format:"duration",check:"string_format",...Qe(t)})}function WC(e,t){return new e({type:"number",checks:[],...Qe(t)})}function VC(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Qe(t)})}function qC(e,t){return new e({type:"boolean",...Qe(t)})}function GC(e,t){return new e({type:"null",...Qe(t)})}function KC(e){return new e({type:"unknown"})}function YC(e,t){return new e({type:"never",...Qe(t)})}function Yv(e,t){return new ek({check:"less_than",...Qe(t),value:e,inclusive:!1})}function ph(e,t){return new ek({check:"less_than",...Qe(t),value:e,inclusive:!0})}function Xv(e,t){return new tk({check:"greater_than",...Qe(t),value:e,inclusive:!1})}function mh(e,t){return new tk({check:"greater_than",...Qe(t),value:e,inclusive:!0})}function Qv(e,t){return new u1({check:"multiple_of",...Qe(t),value:e})}function ck(e,t){return new f1({check:"max_length",...Qe(t),maximum:e})}function Hu(e,t){return new h1({check:"min_length",...Qe(t),minimum:e})}function uk(e,t){return new p1({check:"length_equals",...Qe(t),length:e})}function XC(e,t){return new m1({check:"string_format",format:"regex",...Qe(t),pattern:e})}function QC(e){return new g1({check:"string_format",format:"lowercase",...Qe(e)})}function JC(e){return new x1({check:"string_format",format:"uppercase",...Qe(e)})}function eI(e,t){return new v1({check:"string_format",format:"includes",...Qe(t),includes:e})}function tI(e,t){return new y1({check:"string_format",format:"starts_with",...Qe(t),prefix:e})}function nI(e,t){return new b1({check:"string_format",format:"ends_with",...Qe(t),suffix:e})}function Do(e){return new k1({check:"overwrite",tx:e})}function sI(e){return Do(t=>t.normalize(e))}function rI(){return Do(e=>e.trim())}function iI(){return Do(e=>e.toLowerCase())}function aI(){return Do(e=>e.toUpperCase())}function oI(){return Do(e=>fE(e))}function lI(e,t,n){return new e({type:"array",element:t,...Qe(n)})}function cI(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Qe(n)})}function uI(e,t){const n=dI(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(Hl(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(Hl(o))}},e(r.value,r)),t);return n}function dI(e,t){const n=new ks({check:"custom",...Qe(t)});return n._zod.check=e,n}function dk(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??El,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function bn(e,t,n={path:[],schemaPath:[]}){var p,m;var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=(m=(p=e._zod).toJSONSchema)==null?void 0:m.call(p);if(u)c.schema=u;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,g);else{const y=c.schema,S=t.processors[i.type];if(!S)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);S(e,t,y,g)}const v=e._zod.parent;v&&(c.ref||(c.ref=v),bn(v,t,g),t.seen.get(v).isParent=!0)}const f=t.metadataRegistry.get(e);return f&&Object.assign(c.schema,f),t.io==="input"&&ns(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((r=c.schema).default??(r.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function fk(e,t){var c,u,f,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of e.seen.entries()){const m=(c=e.metadataRegistry.get(p[0]))==null?void 0:c.id;if(m){const g=r.get(m);if(g&&g!==p[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,p[0])}}const i=p=>{var S;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const k=(S=e.external.registry.get(p[0]))==null?void 0:S.id,w=e.external.uri??(N=>N);if(k)return{ref:w(k)};const A=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=A,{defId:A,ref:`${w("__shared")}#/${m}/${A}`}}if(p[1]===n)return{ref:"#"};const v=`#/${m}/`,y=p[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:v+y}},o=p=>{if(p[1].schema.$ref)return;const m=p[1],{ref:g,defId:v}=i(p);m.def={...m.schema},v&&(m.defId=v);const y=m.schema;for(const S in y)delete y[S];y.$ref=g};if(e.cycles==="throw")for(const p of e.seen.entries()){const m=p[1];if(m.cycle)throw new Error(`Cycle detected: #/${(u=m.cycle)==null?void 0:u.join("/")}/<root>
102
-
103
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const m=p[1];if(t===p[0]){o(p);continue}if(e.external){const v=(f=e.external.registry.get(p[0]))==null?void 0:f.id;if(t!==p[0]&&v){o(p);continue}}if((d=e.metadataRegistry.get(p[0]))==null?void 0:d.id){o(p);continue}if(m.cycle){o(p);continue}if(m.count>1&&e.reused==="ref"){o(p);continue}}}function hk(e,t){var u,f,d,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const v=g.def??g.schema,y={...v},S=g.ref;if(g.ref=null,S){r(S);const w=e.seen.get(S),A=w.schema;if(A.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(v.allOf=v.allOf??[],v.allOf.push(A)):Object.assign(v,A),Object.assign(v,y),m._zod.parent===S)for(const R in v)R==="$ref"||R==="allOf"||R in y||delete v[R];if(A.$ref&&w.def)for(const R in v)R==="$ref"||R==="allOf"||R in w.def&&JSON.stringify(v[R])===JSON.stringify(w.def[R])&&delete v[R]}const k=m._zod.parent;if(k&&k!==S){r(k);const w=e.seen.get(k);if(w!=null&&w.schema.$ref&&(v.$ref=w.schema.$ref,w.def))for(const A in v)A==="$ref"||A==="allOf"||A in w.def&&JSON.stringify(v[A])===JSON.stringify(w.def[A])&&delete v[A]}e.override({zodSchema:m,jsonSchema:v,path:g.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const m=(f=e.external.registry.get(t))==null?void 0:f.id;if(!m)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(m)}Object.assign(i,n.def??n.schema);const o=(d=e.metadataRegistry.get(t))==null?void 0:d.id;o!==void 0&&i.id===o&&delete i.id;const c=((p=e.external)==null?void 0:p.defs)??{};for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,c[g.defId]=g.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?i.$defs=c:i.definitions=c);try{const m=JSON.parse(JSON.stringify(i));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:Zu(t,"input",e.processors),output:Zu(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function ns(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ns(r.element,n);if(r.type==="set")return ns(r.valueType,n);if(r.type==="lazy")return ns(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ns(r.innerType,n);if(r.type==="intersection")return ns(r.left,n)||ns(r.right,n);if(r.type==="record"||r.type==="map")return ns(r.keyType,n)||ns(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ns(r.in,n)||ns(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ns(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ns(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ns(i,n))return!0;return!!(r.rest&&ns(r.rest,n))}return!1}const fI=(e,t={})=>n=>{const r=dk({...n,processors:t});return bn(e,r),fk(r,e),hk(r,e)},Zu=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},c=dk({...i??{},target:o,io:t,processors:n});return bn(e,c),fk(c,e),hk(c,e)},hI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},pI=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:c,format:u,patterns:f,contentEncoding:d}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof c=="number"&&(i.maxLength=c),u&&(i.format=hI[u]??u,i.format===""&&delete i.format,u==="time"&&delete i.format),d&&(i.contentEncoding=d),f&&f.size>0){const p=[...f];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},mI=(e,t,n,r)=>{const i=n,{minimum:o,maximum:c,format:u,multipleOf:f,exclusiveMaximum:d,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?i.type="integer":i.type="number";const m=typeof p=="number"&&p>=(o??Number.NEGATIVE_INFINITY),g=typeof d=="number"&&d<=(c??Number.POSITIVE_INFINITY),v=t.target==="draft-04"||t.target==="openapi-3.0";m?v?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p:typeof o=="number"&&(i.minimum=o),g?v?(i.maximum=d,i.exclusiveMaximum=!0):i.exclusiveMaximum=d:typeof c=="number"&&(i.maximum=c),typeof f=="number"&&(i.multipleOf=f)},gI=(e,t,n,r)=>{n.type="boolean"},xI=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},vI=(e,t,n,r)=>{n.not={}},yI=(e,t,n,r)=>{},bI=(e,t,n,r)=>{const i=e._zod.def,o=Hb(i.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},kI=(e,t,n,r)=>{const i=e._zod.def,o=[];for(const c of i.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),o.every(c=>typeof c=="boolean")&&(n.type="boolean"),o.every(c=>c===null)&&(n.type="null"),n.enum=o},wI=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},NI=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jI=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(i.minItems=c),typeof u=="number"&&(i.maxItems=u),i.type="array",i.items=bn(o.element,t,{...r,path:[...r.path,"items"]})},SI=(e,t,n,r)=>{var d;const i=n,o=e._zod.def;i.type="object",i.properties={};const c=o.shape;for(const p in c)i.properties[p]=bn(c[p],t,{...r,path:[...r.path,"properties",p]});const u=new Set(Object.keys(c)),f=new Set([...u].filter(p=>{const m=o.shape[p]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));f.size>0&&(i.required=Array.from(f)),((d=o.catchall)==null?void 0:d._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=bn(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},_I=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,c=i.options.map((u,f)=>bn(u,t,{...r,path:[...r.path,o?"oneOf":"anyOf",f]}));o?n.oneOf=c:n.anyOf=c},EI=(e,t,n,r)=>{const i=e._zod.def,o=bn(i.left,t,{...r,path:[...r.path,"allOf",0]}),c=bn(i.right,t,{...r,path:[...r.path,"allOf",1]}),u=d=>"allOf"in d&&Object.keys(d).length===1,f=[...u(o)?o.allOf:[o],...u(c)?c.allOf:[c]];n.allOf=f},CI=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const c=o.keyType,u=c._zod.bag,f=u==null?void 0:u.patterns;if(o.mode==="loose"&&f&&f.size>0){const p=bn(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const m of f)i.patternProperties[m.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=bn(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=bn(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const d=c._zod.values;if(d){const p=[...d].filter(m=>typeof m=="string"||typeof m=="number");p.length>0&&(i.required=p)}},II=(e,t,n,r)=>{const i=e._zod.def,o=bn(i.innerType,t,r),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},AI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},TI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},$I=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},MI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let c;try{c=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},RI=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?o?i.out:i.in:i.out;bn(c,t,r);const u=t.seen.get(e);u.ref=c},OI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},pk=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},zI=me("ZodISODateTime",(e,t)=>{O1.init(e,t),nn.init(e,t)});function PI(e){return BC(zI,e)}const LI=me("ZodISODate",(e,t)=>{z1.init(e,t),nn.init(e,t)});function DI(e){return UC(LI,e)}const FI=me("ZodISOTime",(e,t)=>{P1.init(e,t),nn.init(e,t)});function BI(e){return HC(FI,e)}const UI=me("ZodISODuration",(e,t)=>{L1.init(e,t),nn.init(e,t)});function HI(e){return ZC(UI,e)}const ZI=(e,t)=>{qb.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>_E(e,n)},flatten:{value:n=>SE(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,xp,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,xp,2)}},isEmpty:{get(){return e.issues.length===0}}})},Gs=me("ZodError",ZI,{Parent:Error}),WI=km(Gs),VI=wm(Gs),qI=pd(Gs),GI=md(Gs),KI=IE(Gs),YI=AE(Gs),XI=TE(Gs),QI=$E(Gs),JI=ME(Gs),eA=RE(Gs),tA=OE(Gs),nA=zE(Gs),Jv=new WeakMap;function ic(e,t,n){const r=Object.getPrototypeOf(e);let i=Jv.get(r);if(i||(i=new Set,Jv.set(r,i)),!i.has(t)){i.add(t);for(const o in n){const c=n[o];Object.defineProperty(r,o,{configurable:!0,enumerable:!1,get(){const u=c.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u}),u},set(u){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u})}})}}}const Xt=me("ZodType",(e,t)=>(Kt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Zu(e,"input"),output:Zu(e,"output")}}),e.toJSONSchema=fI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>WI(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>qI(e,n,r),e.parseAsync=async(n,r)=>VI(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>GI(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>KI(e,n,r),e.decode=(n,r)=>YI(e,n,r),e.encodeAsync=async(n,r)=>XI(e,n,r),e.decodeAsync=async(n,r)=>QI(e,n,r),e.safeEncode=(n,r)=>JI(e,n,r),e.safeDecode=(n,r)=>eA(e,n,r),e.safeEncodeAsync=async(n,r)=>tA(e,n,r),e.safeDecodeAsync=async(n,r)=>nA(e,n,r),ic(e,"ZodType",{check(...n){const r=this.def;return this.clone(Yi(r,{checks:[...r.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return Xi(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(KA(n,r))},superRefine(n,r){return this.check(YA(n,r))},overwrite(n){return this.check(Do(n))},optional(){return s0(this)},exactOptional(){return zA(this)},nullable(){return r0(this)},nullish(){return s0(r0(this))},nonoptional(n){return UA(this,n)},array(){return ue(this)},or(n){return To([this,n])},and(n){return TA(this,n)},transform(n){return i0(this,RA(n))},default(n){return DA(this,n)},prefault(n){return BA(this,n)},catch(n){return ZA(this,n)},pipe(n){return i0(this,n)},readonly(){return qA(this)},describe(n){const r=this.clone();return El.add(r,{description:n}),r},meta(...n){if(n.length===0)return El.get(this);const r=this.clone();return El.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=El.get(e))==null?void 0:n.description},configurable:!0}),e)),mk=me("_ZodString",(e,t)=>{Nm.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(r,i,o)=>pI(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,ic(e,"_ZodString",{regex(...r){return this.check(XC(...r))},includes(...r){return this.check(eI(...r))},startsWith(...r){return this.check(tI(...r))},endsWith(...r){return this.check(nI(...r))},min(...r){return this.check(Hu(...r))},max(...r){return this.check(ck(...r))},length(...r){return this.check(uk(...r))},nonempty(...r){return this.check(Hu(1,...r))},lowercase(r){return this.check(QC(r))},uppercase(r){return this.check(JC(r))},trim(){return this.check(rI())},normalize(...r){return this.check(sI(...r))},toLowerCase(){return this.check(iI())},toUpperCase(){return this.check(aI())},slugify(){return this.check(oI())}})}),sA=me("ZodString",(e,t)=>{Nm.init(e,t),mk.init(e,t),e.email=n=>e.check(kC(rA,n)),e.url=n=>e.check(lk(gk,n)),e.jwt=n=>e.check(FC(yA,n)),e.emoji=n=>e.check(_C(iA,n)),e.guid=n=>e.check(Kv(e0,n)),e.uuid=n=>e.check(wC(pu,n)),e.uuidv4=n=>e.check(NC(pu,n)),e.uuidv6=n=>e.check(jC(pu,n)),e.uuidv7=n=>e.check(SC(pu,n)),e.nanoid=n=>e.check(EC(aA,n)),e.guid=n=>e.check(Kv(e0,n)),e.cuid=n=>e.check(CC(oA,n)),e.cuid2=n=>e.check(IC(lA,n)),e.ulid=n=>e.check(AC(cA,n)),e.base64=n=>e.check(PC(gA,n)),e.base64url=n=>e.check(LC(xA,n)),e.xid=n=>e.check(TC(uA,n)),e.ksuid=n=>e.check($C(dA,n)),e.ipv4=n=>e.check(MC(fA,n)),e.ipv6=n=>e.check(RC(hA,n)),e.cidrv4=n=>e.check(OC(pA,n)),e.cidrv6=n=>e.check(zC(mA,n)),e.e164=n=>e.check(DC(vA,n)),e.datetime=n=>e.check(PI(n)),e.date=n=>e.check(DI(n)),e.time=n=>e.check(BI(n)),e.duration=n=>e.check(HI(n))});function _(e){return bC(sA,e)}const nn=me("ZodStringFormat",(e,t)=>{Yt.init(e,t),mk.init(e,t)}),rA=me("ZodEmail",(e,t)=>{_1.init(e,t),nn.init(e,t)}),e0=me("ZodGUID",(e,t)=>{j1.init(e,t),nn.init(e,t)}),pu=me("ZodUUID",(e,t)=>{S1.init(e,t),nn.init(e,t)}),gk=me("ZodURL",(e,t)=>{E1.init(e,t),nn.init(e,t)});function yp(e){return lk(gk,e)}const iA=me("ZodEmoji",(e,t)=>{C1.init(e,t),nn.init(e,t)}),aA=me("ZodNanoID",(e,t)=>{I1.init(e,t),nn.init(e,t)}),oA=me("ZodCUID",(e,t)=>{A1.init(e,t),nn.init(e,t)}),lA=me("ZodCUID2",(e,t)=>{T1.init(e,t),nn.init(e,t)}),cA=me("ZodULID",(e,t)=>{$1.init(e,t),nn.init(e,t)}),uA=me("ZodXID",(e,t)=>{M1.init(e,t),nn.init(e,t)}),dA=me("ZodKSUID",(e,t)=>{R1.init(e,t),nn.init(e,t)}),fA=me("ZodIPv4",(e,t)=>{D1.init(e,t),nn.init(e,t)}),hA=me("ZodIPv6",(e,t)=>{F1.init(e,t),nn.init(e,t)}),pA=me("ZodCIDRv4",(e,t)=>{B1.init(e,t),nn.init(e,t)}),mA=me("ZodCIDRv6",(e,t)=>{U1.init(e,t),nn.init(e,t)}),gA=me("ZodBase64",(e,t)=>{H1.init(e,t),nn.init(e,t)}),xA=me("ZodBase64URL",(e,t)=>{W1.init(e,t),nn.init(e,t)}),vA=me("ZodE164",(e,t)=>{V1.init(e,t),nn.init(e,t)}),yA=me("ZodJWT",(e,t)=>{G1.init(e,t),nn.init(e,t)}),xk=me("ZodNumber",(e,t)=>{sk.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(r,i,o)=>mI(e,r,i),ic(e,"ZodNumber",{gt(r,i){return this.check(Xv(r,i))},gte(r,i){return this.check(mh(r,i))},min(r,i){return this.check(mh(r,i))},lt(r,i){return this.check(Yv(r,i))},lte(r,i){return this.check(ph(r,i))},max(r,i){return this.check(ph(r,i))},int(r){return this.check(t0(r))},safe(r){return this.check(t0(r))},positive(r){return this.check(Xv(0,r))},nonnegative(r){return this.check(mh(0,r))},negative(r){return this.check(Yv(0,r))},nonpositive(r){return this.check(ph(0,r))},multipleOf(r,i){return this.check(Qv(r,i))},step(r,i){return this.check(Qv(r,i))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function te(e){return WC(xk,e)}const bA=me("ZodNumberFormat",(e,t)=>{K1.init(e,t),xk.init(e,t)});function t0(e){return VC(bA,e)}const kA=me("ZodBoolean",(e,t)=>{Y1.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gI(e,n,r)});function be(e){return qC(kA,e)}const wA=me("ZodNull",(e,t)=>{X1.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xI(e,n,r)});function NA(e){return GC(wA,e)}const jA=me("ZodUnknown",(e,t)=>{Q1.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yI()});function bp(){return KC(jA)}const SA=me("ZodNever",(e,t)=>{J1.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vI(e,n,r)});function _A(e){return YC(SA,e)}const EA=me("ZodArray",(e,t)=>{eC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jI(e,n,r,i),e.element=t.element,ic(e,"ZodArray",{min(n,r){return this.check(Hu(n,r))},nonempty(n){return this.check(Hu(1,n))},max(n,r){return this.check(ck(n,r))},length(n,r){return this.check(uk(n,r))},unwrap(){return this.element}})});function ue(e,t){return lI(EA,e,t)}const CA=me("ZodObject",(e,t)=>{nC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>SI(e,n,r,i),Mt(e,"shape",()=>t.shape),ic(e,"ZodObject",{keyof(){return Pe(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:bp()})},loose(){return this.clone({...this._zod.def,catchall:bp()})},strict(){return this.clone({...this._zod.def,catchall:_A()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return yE(this,n)},safeExtend(n){return bE(this,n)},merge(n){return kE(this,n)},pick(n){return xE(this,n)},omit(n){return vE(this,n)},partial(...n){return wE(yk,this,n[0])},required(...n){return NE(bk,this,n[0])}})});function z(e,t){const n={type:"object",shape:e??{},...Qe(t)};return new CA(n)}const vk=me("ZodUnion",(e,t)=>{ak.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_I(e,n,r,i),e.options=t.options});function To(e,t){return new vk({type:"union",options:e,...Qe(t)})}const IA=me("ZodDiscriminatedUnion",(e,t)=>{vk.init(e,t),sC.init(e,t)});function Oa(e,t,n){return new IA({type:"union",options:t,discriminator:e,...Qe(n)})}const AA=me("ZodIntersection",(e,t)=>{rC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>EI(e,n,r,i)});function TA(e,t){return new AA({type:"intersection",left:e,right:t})}const n0=me("ZodRecord",(e,t)=>{iC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>CI(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function di(e,t,n){return!t||!t._zod?new n0({type:"record",keyType:_(),valueType:e,...Qe(t)}):new n0({type:"record",keyType:e,valueType:t,...Qe(n)})}const kp=me("ZodEnum",(e,t)=>{aC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(r,i,o)=>bI(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const c of r)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new kp({...t,checks:[],...Qe(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const c of r)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new kp({...t,checks:[],...Qe(i),entries:o})}});function Pe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new kp({type:"enum",entries:n,...Qe(t)})}const $A=me("ZodLiteral",(e,t)=>{oC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kI(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function dt(e,t){return new $A({type:"literal",values:Array.isArray(e)?e:[e],...Qe(t)})}const MA=me("ZodTransform",(e,t)=>{lC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>NI(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ub(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Hl(o,n.value,t));else{const c=o;c.fatal&&(c.continue=!1),c.code??(c.code="custom"),c.input??(c.input=n.value),c.inst??(c.inst=e),n.issues.push(Hl(c))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function RA(e){return new MA({type:"transform",transform:e})}const yk=me("ZodOptional",(e,t)=>{ok.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pk(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function s0(e){return new yk({type:"optional",innerType:e})}const OA=me("ZodExactOptional",(e,t)=>{cC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pk(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function zA(e){return new OA({type:"optional",innerType:e})}const PA=me("ZodNullable",(e,t)=>{uC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>II(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function r0(e){return new PA({type:"nullable",innerType:e})}const LA=me("ZodDefault",(e,t)=>{dC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>TI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function DA(e,t){return new LA({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Wb(t)}})}const FA=me("ZodPrefault",(e,t)=>{fC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$I(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function BA(e,t){return new FA({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Wb(t)}})}const bk=me("ZodNonOptional",(e,t)=>{hC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>AI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function UA(e,t){return new bk({type:"nonoptional",innerType:e,...Qe(t)})}const HA=me("ZodCatch",(e,t)=>{pC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>MI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ZA(e,t){return new HA({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const WA=me("ZodPipe",(e,t)=>{mC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>RI(e,n,r,i),e.in=t.in,e.out=t.out});function i0(e,t){return new WA({type:"pipe",in:e,out:t})}const VA=me("ZodReadonly",(e,t)=>{gC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>OI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function qA(e){return new VA({type:"readonly",innerType:e})}const GA=me("ZodCustom",(e,t)=>{xC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wI(e,n)});function KA(e,t={}){return cI(GA,e,t)}function YA(e,t){return uI(e,t)}const gh=Oa("type",[z({type:dt("text"),text:_()}),z({type:dt("reasoning"),text:_()}),z({type:dt("image"),name:_().optional(),mediaType:_().optional(),width:te().optional(),height:te().optional(),attachmentId:_().optional(),bytes:te().optional()}),z({type:dt("file"),name:_().optional(),size:te().optional(),mediaType:_().optional()}),z({type:dt("tool-call"),callId:_(),name:_(),arguments:_()}),z({type:dt("other"),kind:_()})]),a0=z({inputTokens:te(),outputTokens:te(),totalTokens:te().optional(),cacheReadTokens:te().optional(),cacheWriteTokens:te().optional(),reasoningTokens:te().optional()}),o0=z({firstChunkAt:te().optional(),firstTokenAt:te().optional(),lastChunkAt:te().optional(),tokenChunks:te()}),l0=z({message:_(),code:_().optional()}),XA=z({kind:_(),message:_().optional()}),QA=z({kind:_(),human:be(),summary:_().optional()}),Mn={seq:te(),time:te()},wp=Oa("type",[z({...Mn,type:dt("turn/start"),turn:te()}),z({...Mn,type:dt("turn/end"),turn:te(),reason:XA}),z({...Mn,type:dt("step/start"),turn:te(),step:te()}),z({...Mn,type:dt("step/end"),turn:te(),step:te()}),z({...Mn,type:dt("user/message"),messageId:_(),content:ue(gh),origin:QA,requestId:_().optional(),replacesHistory:be().optional()}),z({...Mn,type:dt("system/message"),turn:te(),step:te(),text:_()}),z({...Mn,type:dt("assistant/message"),turn:te(),step:te(),messageId:_(),content:ue(gh),timing:o0,usage:a0.optional(),interrupted:be().optional(),provider:_().optional(),model:_().optional()}),z({...Mn,type:dt("assistant/attempt"),turn:te(),step:te(),timing:o0,error:l0.optional()}),z({...Mn,type:dt("tool/call"),turn:te(),step:te(),callId:_(),name:_(),arguments:_()}),z({...Mn,type:dt("tool/result"),turn:te(),step:te(),callId:_(),isError:be(),content:ue(gh),error:l0.optional()}),z({...Mn,type:dt("request/header"),provider:_().optional(),model:_().optional(),reasoningEffort:_().optional(),toolNames:ue(_()),reason:_()}),z({...Mn,type:dt("compaction/start"),compactionId:_(),turn:te().nullable()}),z({...Mn,type:dt("compaction/summary"),compactionId:_(),shadowedTokenCount:te(),provider:_().optional(),model:_().optional(),usage:a0.optional()}),z({...Mn,type:dt("compaction/end"),compactionId:_(),turn:te().nullable(),error:_().optional()}),z({...Mn,type:dt("approval/asked"),approvalId:_(),toolName:_(),callId:_().optional(),reason:_().optional()}),z({...Mn,type:dt("approval/decided"),approvalId:_(),outcome:_()}),z({...Mn,type:dt("session/title"),title:_()}),z({...Mn,type:dt("unknown"),upstreamType:_(),data:bp()})]),kk=Oa("type",[z({type:dt("start"),attemptId:_(),turn:te(),step:te(),afterSeq:te()}),z({type:dt("delta"),attemptId:_(),time:te(),kind:Pe(["text","reasoning","tool-args"]),index:te(),text:_(),callId:_().optional(),toolName:_().optional()}),z({type:dt("end"),attemptId:_(),outcome:Pe(["committed","abandoned"]),seq:te().optional()})]),JA=z({attemptId:_(),turn:te(),step:te(),afterSeq:te(),deltas:ue(kk.options[1])}),eT=z({index:te().int().min(0),name:_(),running:be(),ready:be(),adb:_().optional()}),tT=z({kind:Pe(["mumu"]),name:_(),manager:_(),version:_().optional(),instances:ue(eT),error:_().optional()}),wk=z({mumuManager:_().optional(),instance:te().int().min(0).max(63),manualAddress:_().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:_().optional(),autoStart:be(),bootTimeoutSeconds:te().int().min(30).max(900)});z({providers:ue(tT),settings:wk,selection:z({label:_(),address:_().optional(),problem:_().optional()})});z({refresh:be().optional()}),z({index:te().int().min(0).optional()}),z({address:_(),label:_()}),z({index:te().int().min(0).optional()}),z({}),wk.partial().extend({mumuManager:_().nullable().optional(),manualAddress:_().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:_().nullable().optional()});z({});const jm=Pe(["maafw-pi","cli","gui-config","generic-process","visual"]),Et=_().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),Rl=_().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),xh=_().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),nT=Oa("kind",[z({kind:dt("github"),repo:_()}),z({kind:dt("mirrorchyan"),rid:_(),platform:be(),os:be().optional(),arch:be().optional()}),z({kind:dt("local"),path:_()})]),sT=z({version:_(),dir:_(),installedAt:te(),asset:z({name:_(),size:te()}).optional(),current:be()}),rT=Pe(["ok","missing","outdated","unknown","unsupported"]),iT=z({kind:_(),label:_(),required:_().optional(),status:rT,found:_().optional(),detail:_().optional(),fix:z({kind:Pe(["auto","installer","manual"]),description:_(),needsAdmin:be()}).optional()}),aT=z({checkedAt:te(),ok:be(),items:ue(iT)}),oT=z({executables:ue(_()),markers:ue(_()),family:jm.optional()}),c0=Pe(["install","pack","known","user"]),lT=z({github:z({repo:_(),from:c0}).optional(),mirrorchyan:z({rid:_(),from:c0}).optional()}),cT=z({version:_(),from:_()}),uT=z({state:Pe(["running","done","failed"]),at:te(),text:_().optional(),sessionId:_().optional()}),dT=z({id:_(),name:_(),source:nT,packId:_().optional(),family:jm.optional(),current:_().optional(),dir:_().optional(),versions:ue(sT),env:aT.optional(),probe:oT.optional(),update:z({latest:_(),available:be(),checkedAt:te()}).optional(),channels:lT,known:_().optional(),localVersion:cT.optional(),undo:z({from:_().optional(),to:_(),at:te()}).optional(),jobId:_().optional(),addedAt:te(),summary:uT.optional(),packReview:z({from:_().optional(),to:_()}).optional(),optimize:z({runs:te(),at:te().optional(),due:Pe(["runs","updated"]).optional()}).optional()}),fT=z({id:_(),name:_(),description:_().optional(),repo:_().optional(),mirrorchyan:_().optional(),family:jm.optional(),builtin:be(),installed:be(),error:_().optional()});z({rid:_(),version:_(),platform:be(),os:be().optional(),arch:be().optional(),name:_().optional(),description:_().optional(),repo:_().optional()});const Np=z({rid:_(),name:_(),description:_(),repo:_().optional(),url:_().optional(),installed:be(),known:be()}),hT=z({id:_(),name:_(),repo:_().optional(),mirrorchyan:_().optional(),installed:be()}),pT=z({name:_(),size:te(),downloadUrl:_(),digest:_().optional()}),mT=z({tag:_(),name:_(),prerelease:be(),publishedAt:_().optional(),url:_().optional(),assets:ue(pT),suggestedAsset:_().optional(),notes:_().optional()}),gT=Pe(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),xT=z({sessionId:_(),state:Pe(["running","failed"]),reason:_().optional()}),vT=z({scriptId:_(),name:_(),kind:Pe(["nsis","inno","kachina"]),version:_(),dir:_(),update:be(),at:te(),agent:xT.optional()}),yT=z({id:_(),kind:Pe(["install","update","env-fix"]),scriptId:_(),phase:gT,message:_().optional(),received:te().optional(),total:te().optional(),version:_().optional(),error:_().optional(),setup:z({kind:Pe(["nsis","inno","kachina"]),dir:_(),sessionId:_().optional()}).optional(),startedAt:te(),endedAt:te().optional()}),u0=z({apiBase:yp({protocol:/^https?$/}),downloadMirror:_().trim().max(300),mirrorFallback:be(),tokenRef:_().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:te().int().min(1).max(10),includePrereleases:be(),cdkRef:_().regex(/^[A-Za-z_][A-Za-z0-9_]*$/)});z({});z({id:Et});z({scripts:ue(dT),packs:ue(fT),known:ue(hT),setups:ue(vT).default([]),toolsDir:_()}),z({query:_().trim().min(1).max(200)}),z({items:ue(z({repo:_(),description:_().optional(),stars:te(),packId:_().optional()}))}),z({repo:Rl,limit:te().int().min(1).max(30).optional()}),z({repo:_(),packId:_().optional(),releases:ue(mT)}),z({repo:Rl.optional(),mirrorchyan:xh.optional(),tag:_().min(1).max(200).optional(),asset:_().min(1).max(300).optional(),branch:_().min(1).max(200).optional(),id:Et.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),z({jobId:_(),scriptId:_()}),z({current:_().optional(),latest:_(),available:be()}),z({jobId:_().optional(),upToDate:be()}),z({id:Et,repo:Rl.nullable().optional(),mirrorchyan:xh.nullable().optional(),reset:ue(Pe(["repo","mirrorchyan"])).optional()}),z({items:ue(Np.extend({by:Pe(["repo","name"])})),from:Pe(["mirrorchyan","builtin"])}),z({rid:xh}),z({query:_().trim().max(100)}),z({items:ue(Np),from:Pe(["mirrorchyan","builtin"]),fetchedAt:te().optional()}),z({id:_(),decision:Pe(["check","keep"])}),z({sessionId:_().optional()}),z({id:Et,version:_().optional()}),z({dir:_()}),z({sessionId:_()}),z({path:_().trim().min(1).max(1e3),id:Et.optional(),name:_().trim().min(1).max(100).optional(),packId:Et.optional()}),z({id:Et,decision:Pe(["run","keep"])}),z({sessionId:_().optional()}),z({id:Et}),z({sessionId:_()}),z({id:Et,deleteFiles:be().optional()}),z({id:Et,kind:_().min(1).max(64)}),z({jobId:_()}),z({items:ue(yT)}),z({jobId:_()}),u0.extend({tokenConfigured:be(),cdkConfigured:be()}),z({ok:be(),message:_(),expiresAt:te().optional()}),u0.partial();z({id:_().optional()});const bT=z({packId:_(),scriptId:_(),proposedAt:te(),sessionId:_().optional(),summary:_(),docs:ue(z({source:_(),used:_()})).optional(),noDocs:_().optional(),manifest:_(),skill:_(),current:z({manifest:_(),skill:_().optional(),builtin:be()}).optional(),tasks:ue(z({id:_(),title:_()}))});z({scriptId:Et.optional()}),z({items:ue(bT)}),z({packId:Et}),z({packId:_(),dir:_()}),z({packId:Et}),z({});z({packId:_().optional()});const kT=z({scriptId:_(),dir:_(),grantedAt:te(),expiresAt:te()});z({}),z({items:ue(kT),blocked:te()}),z({scriptId:Et,minutes:te().int().min(1).max(240)}),z({scriptId:Et}),z({});z({}),z({toolName:_(),target:_(),sessionId:_().optional(),at:te()});const wT=Pe(["error","warning","failed","stalled","overtime"]),NT=z({at:te(),action:Pe(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Pe(["rule","user","agent"]),ok:be(),detail:_()}),jT=z({id:_(),runId:_(),scriptId:_(),scriptName:_(),taskId:_(),taskTitle:_(),kind:wT,severity:Pe(["warning","error"]),tag:_(),title:_(),detail:_(),lines:ue(_()),status:Pe(["open","resolved"]),resolution:_().optional(),createdAt:te(),updatedAt:te(),steps:ue(NT),screenshot:be()}),ST=z({seconds:te().int().min(5).max(24*3600),by:Pe(["learned","agent","user"]),note:_().max(300).optional(),samples:ue(te().min(0)).max(10).default([]),at:te()}),_T=z({defaultStallSeconds:te().int().min(0).max(24*3600),scriptStall:di(_(),ST),notifyWarnings:be(),screenshot:be(),intervene:Pe(["off","diagnose","act"]),interventionsPerDay:te().int().min(0).max(200)});z({status:Pe(["open","all"]).optional(),runId:_().optional(),limit:te().int().min(1).max(500).optional()}),z({items:ue(jT)}),z({incidentId:_(),action:Pe(["stop","retry","resolve","resume"])}),z({incidentId:_()}),z({mime:dt("image/png"),data:_()}),z({}),_T.partial();const ET="ADG_FEISHU_APP_SECRET",CT="ADG_QQBOT_APP_SECRET",jp=z({id:_(),label:_(),ok:be().nullable(),detail:_().optional()}),IT=z({id:_(),name:_(),state:Pe(["off","connecting","ready","error"]),detail:_().optional(),recipients:te().int().min(0),checks:ue(jp)}),AT=z({openId:_().min(1),name:_().optional(),addedAt:te()}),TT=z({enabled:be(),appId:_().optional(),domain:Pe(["feishu","lark"]),allowedUsers:ue(AT),chatId:_().optional(),otherApprovals:be()}),$T=z({openId:_(),at:te(),text:_()});z({settings:TT,secretConfigured:be(),pending:ue($T)});const MT=z({openId:_().min(1),name:_().optional(),addedAt:te()}),RT=z({enabled:be(),appId:_().optional(),allowedUsers:ue(MT)}),OT=z({openId:_(),at:te(),text:_()});z({settings:RT,secretConfigured:be(),pending:ue(OT)});const Nk=z({id:_(),title:_(),text:_(),severity:Pe(["info","success","warning","error"]),at:te(),actions:ue(z({id:_(),label:_(),style:Pe(["primary","danger","default"]).optional()})),channels:ue(_()),image:be().optional(),done:_().optional(),acted:z({by:_(),label:_(),result:_(),at:te()}).optional()});z({}),z({channels:ue(IT)}),z({}),z({items:ue(z({sessionId:_(),channel:_(),user:_()}))}),z({}),z({items:ue(Nk)}),z({noticeId:_(),actionId:_()}),z({result:_()}),z({channel:_().optional()}),z({sent:ue(_()),failed:ue(z({channel:_(),error:_()}))}),z({}),z({enabled:be().optional(),appId:_().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Pe(["feishu","lark"]).optional(),chatId:_().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:be().optional()}),z({openId:_().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:_().max(40).optional()}),z({openId:_()}),z({}),z({checks:ue(jp)}),z({}),z({enabled:be().optional(),appId:_().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),z({openId:_().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:_().max(40).optional()}),z({openId:_()}),z({}),z({checks:ue(jp)});z({}),z({item:Nk});const ga=_().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),Zl=_().regex(/^[A-Za-z0-9_-]{1,40}$/),Sm=_().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),jk=z({retries:te().int().min(0).max(5).default(0),then:Pe(["continue","stop"]).default("continue")}),ha={id:Zl,title:_().max(60).optional(),position:z({x:te(),y:te()}).optional(),onFailure:jk.optional(),waitForAll:be().optional()},zT=Oa("kind",[z({...ha,kind:dt("script-task"),scriptId:Et,taskId:_().min(1).max(64),params:di(_(),To([_(),te(),be()])).default({}),profile:_().min(1).max(64).optional()}),z({...ha,kind:dt("agent"),prompt:_().min(1).max(4e3)}),z({...ha,kind:dt("wait"),minutes:te().int().min(1).max(1440).optional(),until:Sm.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),z({...ha,kind:dt("notify"),text:_().min(1).max(2e3)}),z({...ha,kind:dt("gate"),text:_().min(1).max(2e3)}),z({...ha,kind:dt("start")}),z({...ha,kind:dt("end")})]);function Wi(e){return e.kind==="start"||e.kind==="end"}function PT(e){const t=e.nodes.some(g=>g.kind==="start"),n=e.nodes.some(g=>g.kind==="end");if(t&&n)return e;const r=e.nodes.filter(g=>!Wi(g)),i=new Set(e.nodes.map(g=>g.id)),o=g=>{let v=g;for(let y=2;i.has(v);y++)v=`${g}${y}`;return i.add(v),v},c=r.filter(g=>g.position!==void 0).map(g=>g.position),u=Math.min(...c.map(g=>g.x)),f=Math.max(...c.map(g=>g.x)),d=c.length===0?40:Math.round(c.reduce((g,v)=>g+v.y,0)/c.length),p=[...e.nodes],m=[...e.edges];if(!t){const g=o("start");p.unshift({id:g,kind:"start",...c.length===0?{}:{position:{x:u-240,y:d}}});for(const v of r)e.edges.some(y=>y.to===v.id)||m.push({from:g,to:v.id,when:"success"})}if(!n){const g=o("end");p.push({id:g,kind:"end",...c.length===0?{}:{position:{x:f+300,y:d}}});for(const v of r)e.edges.some(y=>y.from===v.id)||m.push({from:v.id,to:g,when:"always"})}return{...e,nodes:p,edges:m}}const LT=z({from:Zl,to:Zl,when:Pe(["success","failure","always"]).default("success")}),_m=z({enabled:be().default(!1),times:ue(Sm).max(12).default([]),days:ue(te().int().min(0).max(6)).max(7).default([]),catchUpMinutes:te().int().min(0).max(720).default(10),after:ga.optional()}),Sk=Pe(["none","sleep","hibernate","shutdown"]),vh=z({id:ga,name:_().min(1).max(60),description:_().max(500).optional(),nodes:ue(zT).max(60),edges:ue(LT).max(200).default([]),onFailure:jk.default({retries:0,then:"continue"}),schedule:_m.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:be().default(!1),closeGameAfter:be().default(!1),powerAfter:Sk.default("none"),draft:be().optional(),createdAt:te().optional(),updatedAt:te().optional()}),DT=z({level:Pe(["error","warning","info"]),nodeId:_().optional(),message:_()}),FT=z({ok:be(),issues:ue(DT),serialized:ue(z({a:_(),b:_(),resource:_()})),estimateMinutes:te().optional()}),BT=Pe(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),UT=z({state:BT,detail:_().optional(),runIds:ue(_()),attempts:te().int().min(0),startedAt:te().optional(),endedAt:te().optional()}),_k=z({kind:Pe(["manual","schedule","autostart","agent","after"]),detail:_().optional()}),Ek=z({id:_(),pipelineId:_(),pipelineName:_(),trigger:_k,from:_().optional(),state:Pe(["running","succeeded","failed","cancelled"]),stopping:_().optional(),nodes:di(_(),UT),startedAt:te(),endedAt:te().optional(),outcome:_().optional()}),HT=z({id:_(),name:_(),description:_().optional(),nodes:te(),draft:be(),schedule:_m,updatedAt:te().optional(),lastRun:Ek.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),Cl=_().regex(/^task-[a-z0-9]{4,24}$/),d0=z({id:Cl,agent:_().min(1).max(64),title:_().trim().min(1).max(60),prompt:_().trim().min(1).max(4e3),schedule:_m,createdAt:te().optional(),updatedAt:te().optional()}),f0=z({id:_(),taskId:_(),trigger:_k,state:Pe(["running","done","failed"]),outcome:_().optional(),startedAt:te(),endedAt:te().optional()}),Ck=z({autostart:be(),autostartPipelines:ue(ga),autostartDelaySeconds:te().int().min(0).max(1800),skipIfRanToday:be(),firstStartOnly:be().default(!1),wakeToRun:be().default(!1),powerCountdownSeconds:te().int().min(10).max(600).default(60)}),Ik={agent:_().optional()},ZT=z({pipelineId:_(),pipelineName:_(),...Ik,slot:_(),at:te(),outcome:Pe(["fired","missed","skipped","failed"]),detail:_().optional()}),WT=z({awake:be(),pending:z({action:Sk.exclude(["none"]),pipelineName:_(),at:te().optional()}).optional()});z({settings:Ck,autostart:z({available:be(),registered:be(),detail:_().optional()}),autostarted:be(),wake:z({available:be(),registered:be(),next:te().optional(),detail:_().optional()}),power:WT,upcoming:ue(z({pipelineId:_(),pipelineName:_(),at:te(),...Ik})),history:ue(ZT)});z({}),z({items:ue(HT)}),z({id:ga}),z({pipeline:vh}),z({pipeline:vh,check:FT}),z({id:ga}),z({}),z({pipeline:vh}),z({id:ga,from:Zl.optional()}),z({runId:_()}),z({}),z({pipelineId:ga.optional(),limit:te().int().min(1).max(100).optional()}),z({items:ue(Ek)}),z({runId:_(),nodeId:Zl,decision:Pe(["continue","stop"])}),z({}),z({}),Ck.partial(),z({}),z({}),z({agent:_().optional()}),z({items:ue(d0.extend({lastRun:f0.optional()}))}),z({task:d0.extend({id:Cl.optional()})}),z({id:Cl}),z({}),z({id:Cl}),z({id:Cl}),z({items:ue(f0)});z({}),z({}),z({});const VT=Pe(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),qT=z({id:_(),incidentId:_().optional(),runId:_().optional(),title:_(),mode:Pe(["diagnose","act"]),state:VT,sessionId:_().optional(),paused:be(),summary:_().optional(),startedAt:te(),endedAt:te().optional()});z({limit:te().int().min(1).max(100).optional()}),z({items:ue(qT)}),z({id:_()}),z({id:_(),then:Pe(["resume","restart","stop"])});const h0=z({id:_(),game:_(),name:_(),startsAt:te().optional(),endsAt:te().optional(),shopEndsAt:te().optional(),url:_().optional(),kind:_().optional(),description:_().optional(),cover:_().optional(),site:z({source:_(),name:_(),at:te()}).optional(),sources:ue(z({id:_(),name:_(),at:te(),web:be(),endsAt:te().optional()})).optional(),screen:z({at:te(),remaining:_().optional(),endsAt:te().optional(),evidence:be(),image:_().optional(),sessionId:_().optional()}).optional(),todo:ue(_()),done:ue(_()),progress:_().optional(),finished:z({at:te()}).optional(),mismatch:_().optional(),own:z({at:te(),fields:ue(Pe(["name","startsAt","endsAt","kind","description","url","cover"]))}).optional()}),GT=112e5,KT=z({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:_().min(1).max(GT).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),YT=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,XT=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,QT=z({id:_(),name:_(),homepage:_().optional(),auto:be(),added:be().optional()}),JT=z({id:_(),name:_(),aliases:ue(_()),scripts:ue(_()),timezone:_(),screen:z({target:Pe(["emulator","window"]),window:_().optional()}).optional(),sources:ue(QT),builtin:be(),art:_().optional(),followed:be().optional(),version:z({name:_(),title:_().optional(),startsAt:te().optional(),endsAt:te().optional(),cover:_().optional(),source:_(),at:te()}).optional(),pools:ue(z({name:_(),type:_().optional(),startsAt:te().optional(),endsAt:te(),cover:_().optional(),up:ue(_())})).optional(),refreshed:z({at:te(),ok:be(),count:te(),detail:_().optional()}).optional(),reading:z({state:Pe(["running","done","failed"]),at:te(),sessionId:_().optional(),summary:_().optional()}).optional(),webReading:z({state:Pe(["running","done","failed"]),at:te(),sessionId:_().optional(),summary:_().optional()}).optional()}),p0=z({report:z({enabled:be(),at:Sm,games:ue(_()),soonDays:te().int().min(1).max(30),ai:be()}),followed:ue(_())}),e$=z({lastSentAt:te().optional(),lastDay:_().optional(),lastResult:_().optional(),lastText:_().optional(),next:te().optional()});z({}),z({games:ue(JT),activities:ue(h0),settings:p0,report:e$}),z({game:_().optional()}),z({results:ue(z({game:_(),ok:be(),count:te(),detail:_().optional()}))}),z({game:_(),how:Pe(["screen","web"]).optional(),source:_().optional()}),z({sessionId:_()}),z({}),z({title:_(),text:_()}),z({}),z({channels:ue(_()),text:_()}),z({report:p0.shape.report.partial().optional()}),z({activityId:_()}),z({mediaType:_(),data:_()}),z({url:_().refine(e=>YT.test(e)||XT.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),z({mediaType:_(),data:_()}),z({name:_().min(1).max(60)}),z({sessionId:_()}),z({game:_()}),z({items:ue(Np),from:Pe(["mirrorchyan","builtin"])}),z({game:_(),url:_().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:_().max(30).optional()}),z({source:_(),sessionId:_()}),z({game:_(),source:_()}),z({}),z({}),z({games:ue(z({sra:_(),name:_(),followed:be(),pack:_().optional()}))}),z({sra:_(),follow:be()}),z({}),z({activityId:_(),todo:ue(_().min(1).max(80)).max(30).optional(),done:ue(_().min(1).max(80)).max(30).optional(),finished:be().optional()}),z({game:_(),activityId:_().optional(),name:_().trim().min(1).max(60).nullable().optional(),startsAt:te().nullable().optional(),endsAt:te().nullable().optional(),kind:_().trim().max(20).nullable().optional(),description:_().trim().max(500).nullable().optional(),url:_().trim().refine(e=>e===""||/^https?:\/\/\S+$/.test(e),"只能是 http 或 https 网址").nullable().optional(),cover:NA().optional(),image:KT.optional(),todo:ue(_().min(1).max(80)).max(30).optional()}),z({activityId:_()}),z({activity:h0.optional()}),z({activityId:_()}),z({});z({game:_().optional()});const Ak=Pe(["ask","full"]),Tk=Pe(["default","allow","ask","deny"]),t$=[{id:"pipelines-edit",title:"编辑流水线和定时",description:"起草、修改流水线,设定时间(schedule_set),以及 dsh 自己的定时任务。",tools:["pipeline_draft","schedule_set","schedule_create","schedule_update","schedule_delete"]},{id:"run",title:"运行流水线和脚本",description:"启动、停止流水线和脚本任务。",tools:["pipeline_run","script_run","script_stop"]},{id:"scripts-config",title:"改脚本配置",description:"修改脚本的配置副本、导入配置、新建选项、打开脚本自己的设置界面、设置游戏位置。",tools:["script_config_set","script_config_import","script_choice_create","script_settings","game_path_set"]},{id:"scripts-install",title:"安装、更新、删除脚本",description:"从 GitHub 安装、更新、回滚、删除脚本,运行脚本的安装程序,导入本地脚本,修复运行环境,起草脚本包。",tools:["script_install","script_update","script_rollback","script_remove","script_setup_run","script_import","script_env_fix","pack_propose"]},{id:"screen",title:"操作屏幕和模拟器",description:"在游戏窗口或模拟器里点击、输入、按键、滑动、切换窗口(截图不算)。",tools:["screen_tap","screen_type","screen_key","screen_scroll","screen_swipe","window_focus"]},{id:"games",title:"启动、关闭游戏和模拟器",description:"打开、关掉游戏,启动、关闭、安装、设置模拟器。",tools:["game_launch","game_close","emulator_start","emulator_stop","emulator_install","emulator_configure"]},{id:"game-records",title:"记录活动、添加游戏",description:"把读到的活动写进日历,替你添加、修改或去掉活动,给新游戏建游戏包。",tools:["game_record","game_activity_save","game_activity_remove","game_add"]},{id:"skills",title:"保存技能",description:"把做法存成技能,以后的对话都会用到。",tools:["skill_save"]},{id:"web",title:"上网查资料",description:"读网页、搜索。",tools:["web_fetch","web_search"]},{id:"shell",title:"运行命令、改文件",description:"dsh 自带的命令行和文件编辑。只在它请求确认时按这里的设置处理(沙箱里的普通命令不会请求)。",tools:["pwsh","bash","edit","write"],approvalOnly:!0}];z({mode:Ak,since:te().optional(),areas:di(_(),Tk).default({}),recent:ue(z({at:te(),sessionId:_(),toolName:_(),reason:_().optional()}))});z({}),z({mode:Ak}),z({area:_(),policy:Tk});const n$=z({label:_(),description:_().optional()}),s$=z({id:_(),question:_(),detail:_().optional(),header:_().optional(),options:ue(n$).optional(),multiSelect:be().optional()});z({questionId:_(),sessionId:_(),callId:_().optional(),questions:ue(s$)});const $k=z({id:_(),selected:ue(_()),custom:_().optional()}),r$=Pe(["answered","cancelled","unavailable"]);z({questionId:_(),answers:ue($k)}),z({});z({questionId:_(),outcome:r$,answers:ue($k).optional()});const i$=z({pid:te().int(),label:_(),dataDir:_().optional(),startedAt:te(),warnings:ue(_())});z({others:ue(i$)});z({});const Mk=z({scripts:ue(_()).optional(),games:ue(_()).optional()}),m0=z({name:_(),description:_(),whenToUse:_().optional(),source:_(),provider:_(),path:_().optional(),modelInvocable:be(),userInvocable:be(),owner:Mk.optional(),removable:be().optional()}),Rk=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,Sp=48;z({}),z({skills:ue(m0)}),z({name:_()}),m0.extend({content:_()}),z({name:_().regex(Rk).max(Sp),description:_().trim().min(10).max(400),content:_().trim().min(20).max(2e4),scripts:ue(_().min(1).max(64)).max(20).optional(),games:ue(_().min(1).max(64)).max(20).optional(),replace:be().optional()}),z({name:_(),replaced:be()}),z({name:_()}),z({});z({});const yh=z({repo:Rl,branch:_().trim().min(1).max(100).regex(/^[\w./-]+$/)}),g0=z({name:_(),description:_(),title:_().optional(),kind:Pe(["game","script","general"]),games:ue(_()),scripts:ue(_()),repo:_(),path:_(),hash:_(),installed:z({at:te(),modified:be(),update:be()}).optional(),blocked:_().optional()}),bh=z({name:_().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});z({refresh:be().optional()}),z({items:ue(g0),repos:ue(yh),errors:ue(_()),fetchedAt:te().optional()}),bh.extend({repo:Rl.optional()}),bh.extend({resolve:Pe(["keep","replace","merge"]).optional()}),z({state:Pe(["current","updated","kept","conflict","merging"]),item:g0,backup:_().optional(),sessionId:_().optional()}),z({mine:_(),theirs:_()}),z({}),bh.extend({owner:Mk.nullable()}),z({}),z({repos:ue(yh).min(1).max(10)}),z({repos:ue(yh)});z({});const a$=Pe(["default","concise","patient","lively","buddy","butler"]),kh=z({style:a$,name:_().max(20).optional(),callUser:_().max(20).optional(),custom:_().optional()});z({}),z({persona:kh,prompt:_()}),z({persona:kh}),z({persona:kh,prompt:_()});const o$=80,Ok=50,zk=95,_p=z({auto:be(),threshold:te().int().min(Ok).max(zk)});z({settings:_p,applied:_p});z({}),z({settings:_p});const l$=Pe(["starting","running","stopping","succeeded","failed","cancelled"]),c$=z({type:Pe(["string","integer","number","boolean"]),default:To([_(),te(),be()]).optional(),enum:ue(To([_(),te()])).optional(),description:_().optional(),choices:ue(z({value:_(),label:_(),detail:_().optional()})).optional(),canCreate:be().optional()}),u$=z({mode:Pe(["auto","platform","off"]),pcLaunch:Pe(["program","maaend"]).optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:_().optional(),pcProcess:_().optional(),androidPackage:_().optional()});z({settings:u$,game:z({name:_().optional(),androidPackage:_().optional(),pcProcess:_().optional(),selfLaunch:_()}),uses:z({adb:be(),desktop:be()})});const d$=z({id:_(),title:_(),description:_().optional(),utterances:ue(_()),params:di(_(),c$),input:Pe(["desktop","window","adb","none"]),account:_().optional(),expectedDuration:_().optional()}),Rr=_().trim().min(1).max(64),Ep=z({id:_(),name:_(),createdAt:te().optional()}),Pk=z({current:_(),items:ue(Ep)}),f$=z({id:_(),scriptId:_(),scriptName:_(),taskId:_(),taskTitle:_(),params:di(_(),To([_(),te(),be()])),state:l$,outcome:_().optional(),startedAt:te(),endedAt:te().optional(),exitCode:te().optional(),command:ue(_()),resources:ue(_()),tags:ue(_()),warnings:ue(_()),kind:Pe(["task","settings"]),retryOf:_().optional(),halted:be().optional(),profile:_().optional(),profileName:_().optional()}),Lk=z({at:te(),source:_(),text:_(),level:Pe(["info","progress","done","warning","error"]).optional(),tag:_().optional()});z({scriptId:Et,profile:Rr.optional()}),z({tasks:ue(d$),runnable:be(),problem:_().optional()}),z({scriptId:Et,taskId:_().min(1).max(64),params:di(_(),To([_(),te(),be()])).optional(),profile:Rr.optional()}),z({runId:_()}),z({}),z({scriptId:Et.optional()}),z({items:ue(f$)}),z({runId:_(),limit:te().int().min(1).max(2e3).optional()}),z({lines:ue(Lk)}),z({scriptId:Et}),z({scriptId:Et,name:_().trim().min(1).max(30),from:Oa("kind",[z({kind:dt("copy"),profile:Rr}),z({kind:dt("original")}),z({kind:dt("folder"),dir:_().trim().min(1).max(500)})])}),z({profile:Ep,files:ue(_()),list:Pk}),z({scriptId:Et,profile:Rr,name:_().trim().min(1).max(30).optional(),current:dt(!0).optional()}),z({scriptId:Et,profile:Rr}),z({scriptId:Et,profile:Rr.optional()}),z({importedAt:te().optional(),dir:_(),profile:Ep,files:ue(z({file:_(),local:be(),original:be(),changed:be()})),drift:ue(_())}),z({scriptId:Et,file:_().min(1),profile:Rr.optional()}),z({file:_(),content:_(),truncated:be()}),z({scriptId:Et,profile:Rr.optional()}),z({imported:ue(_())}),z({scriptId:Et,profile:Rr.optional()}),z({runId:_()}),z({}),z({scriptId:Et,taskId:_().min(1),param:_().min(1),name:_().trim().min(1).max(40),profile:Rr.optional()}),z({value:_()}),z({scriptId:Et}),z({scriptId:Et,mode:Pe(["auto","platform","off"]).optional(),pcLaunch:Pe(["program","maaend"]).nullable().optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe:_().trim().nullable().optional(),pcProcess:_().trim().nullable().optional(),androidPackage:_().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/,"安卓包名像 com.example.game").nullable().optional()}),z({scriptId:Et}),z({exe:_().optional(),candidates:ue(z({path:_(),source:_()}))});z({scriptId:_(),list:Pk}),z({runId:_(),lines:ue(Lk)});const h$=1,wh=_().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),Dk=z({configured:be(),source:_().optional(),writable:be()}),Cp="DEEPSEEK_API_KEY",p$=z({id:_(),version:te().int().positive()}),Fk=z({id:_(),title:_().nullable(),updatedAt:te(),running:be(),blank:be(),live:be(),cwd:_().optional(),parentId:_().optional(),origin:Pe(["subagent"]).optional(),role:_().optional(),requestedBy:_().optional(),home:_().optional()}),Bk=z({id:_(),name:_(),description:_(),order:te()}),Uk=z({id:_(),requestId:_().optional(),text:_(),images:te().int().optional(),placement:Pe(["next-turn","next-step"])}),Hk=z({contextWindow:te().int().positive(),usedTokens:te().int().nonnegative(),breakdown:z({systemTokens:te().int().nonnegative(),toolsTokens:te().int().nonnegative(),messageTokens:te().int().nonnegative()}).optional()}),m$=z({id:_(),createdAt:te(),cwd:_().optional(),parentId:_().optional(),agentPreset:_().optional()}),xa=z({provider:_(),model:_(),reasoningEffort:_().optional()}),Zk=z({id:_(),fromSession:_(),callId:_().optional(),by:_(),to:_(),toSession:_(),title:_(),task:_(),expecting:_().optional(),state:Pe(["running","done","failed"]),reply:_().optional(),startedAt:te(),endedAt:te().optional()}),g$=z({id:_(),agent:_(),sessionId:_(),title:_(),prompt:_(),rule:_(),repeats:be(),next:te()});z({default:xa,groups:ue(z({id:_(),name:_(),models:ue(z({id:_(),name:_(),description:_().optional(),efforts:ue(z({id:_(),name:_()})),defaultEffort:_().optional()}))})),failures:ue(z({id:_(),name:_(),message:_()}))});const x$=z({lastUsed:xa.nullable(),next:xa.nullable()}),Nh=Pe(["openai-completions","openai-responses","anthropic-messages"]),v$=_().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),Ip=z({id:_().min(1),name:_().optional(),contextWindow:te().int().positive().optional(),maxTokens:te().int().positive().optional(),input:ue(Pe(["text","image"])).optional(),efforts:ue(_().min(1)).optional()}),y$=z({id:_(),displayName:_(),api:_().optional(),baseURL:_().optional(),models:ue(Ip),apiKeyRef:_().optional(),credential:Dk.optional(),declared:be(),active:be(),error:_().optional()}),b$=z({available:be(),balances:ue(z({currency:_(),total:_(),granted:_(),toppedUp:_()}))}),Ap=35e5,k$=z({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp"]),data:_().min(1).max(Ap).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:_().max(200).optional()});z({});z({accepted:dt(!0)});z({protocolVersion:te().int(),client:z({name:_(),version:_()})}),z({protocolVersion:te().int(),server:z({name:_(),version:_(),dsh:_().optional()}),capabilities:ue(p$)}),z({items:ue(Fk)}),z({cwd:_().optional(),focus:z({scripts:ue(_()).optional(),games:ue(_()).optional()}).optional(),role:_().optional()}),z({sessionId:_()}),z({sessionIds:ue(_()).max(60)}),z({items:ue(z({sessionId:_(),text:_().nullable()}))}),z({items:ue(Bk)}),z({agentId:_()}),z({sessionId:_()}),z({sessionId:_()}),z({items:ue(Zk)}),z({id:_()}),z({agent:_().optional()}),z({items:ue(g$)}),z({id:_()}),z({}),z({sessionId:_(),title:_().min(1)}),z({title:_()}),z({sessionId:_(),maxMessages:te().int().positive().optional()}),z({subscriptionId:_(),header:m$,cursor:te(),events:ue(wp),hasMore:be(),title:_().nullable(),live:JA.nullable(),queue:ue(Uk).optional(),context:Hk.optional()}),z({subscriptionId:_()}),z({sessionId:_(),throughSeq:te(),beforeSeq:te(),maxMessages:te().int().positive().optional()}),z({events:ue(wp),hasMore:be()}),z({sessionId:_(),requestId:_(),text:_(),mode:Pe(["queue","steer"]),images:ue(k$).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),z({sessionId:_()}),z({sessionId:_()}),z({compacted:be(),message:_()}),z({sessionId:_(),itemId:_(),action:Pe(["steer","remove"])}),z({attachmentId:_(),mediaType:_(),bytes:te(),width:te(),height:te()}),z({mediaType:_(),data:_()}),z({sessionIds:ue(_())}),z({sessionId:_()}),z({sessionIds:ue(_())}),z({sessionId:_()}),z({sessionIds:ue(_())}),z({model:xa.nullable()}),z({model:xa.nullable()}),z({warning:_().optional()}),xa.extend({sessionId:_()}),z({selected:xa}),z({sessionId:_()}),z({approvalId:_(),decision:Pe(["allow-once","reject"])}),z({refs:ue(wh).min(1).max(64)}),z({items:di(_(),Dk)}),z({ref:wh,value:_().min(1).max(4096)}),z({ref:wh}),z({providers:ue(y$),revision:te(),writable:be(),protocols:ue(Nh),taken:ue(_())}),z({provider:_().optional(),baseURL:yp({protocol:/^https?$/}).optional(),api:Nh.optional(),apiKey:_().min(1).max(4096).optional()}),z({models:ue(Ip)}),z({provider:_().min(1)}),z({balance:b$.nullable()}),z({id:v$,create:be(),displayName:_().max(80).optional(),api:Nh,baseURL:yp({protocol:/^https?$/}),models:ue(Ip).min(1),apiKey:_().min(1).max(4096).optional(),expectedRevision:te().optional()}),z({revision:te(),apiKeyRef:_().optional()}),z({id:_().min(1),removeKey:be().optional(),expectedRevision:te().optional()}),z({revision:te(),defaultReset:be()});Oa("kind",[z({kind:dt("upsert"),item:Fk.partial().extend({id:_()})}),z({kind:dt("removed"),sessionId:_()})]);z({approvalId:_(),sessionId:_(),toolName:_(),callId:_().optional(),reason:_().optional(),displayReason:di(_(),_()).optional()});z({subscriptionId:_(),event:wp}),z({subscriptionId:_(),frame:kk}),z({subscriptionId:_(),reason:_()}),z({sessionId:_(),title:_().nullable()}),z({sessionId:_(),message:_()}),z({sessionId:_(),items:ue(Uk)}),z({sessionId:_(),context:Hk.nullable()}),z({approvalId:_(),outcome:_()}),z({ref:_()}),z({sessionIds:ue(_())}),z({items:ue(Bk)}),z({item:Zk}),z({}),z({}),x$.extend({sessionId:_()});const mu={InternalError:-32603,NotInitialized:-32002};class ml extends Error{constructor(n,r,i){super(r);ut(this,"code");ut(this,"data");this.name="RpcError",this.code=n,this.data=i}toJSON(){return this.data===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,data:this.data}}}function w$(e){if(typeof e!="object"||e===null||e.jsonrpc!=="2.0")return"invalid";const t=e;return typeof t.method=="string"?"id"in t?"request":"notification":"result"in t||"error"in t?"response":"invalid"}function Wk(e){try{const t=JSON.parse(e);for(const r of["command","cmd","path","file_path","pattern","query","url","description","prompt"]){const i=t[r];if(typeof i=="string"&&i!=="")return i.split(`
104
- `)[0].slice(0,160)}const n=Object.values(t).find(r=>typeof r=="string");return typeof n=="string"?n.slice(0,160):""}catch{return e.slice(0,160)}}const Vk=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
105
- `);function N$(e,t,n){return[`优化脚本${e===""?":最近运行过的脚本(script_runs 看最近一周跑过哪些,一个一个来)":`「${e}」`}。把这段时间运行攒下的信息用起来,一次做完下面几件事:`,"1. 重新总结脚本包:script_tasks、script_help 看它现在有哪些任务和参数,script_runs、script_run_log 看最近的运行(成功的看正常流程和用时,失败的看原因);更新过版本就先用 script_changelog 读更新日志。对照它的脚本包,任务、参数、配置文件、完成和出错的日志文字、预计用时有不对或缺的,用原来的脚本包 id 提交 pack_propose(summary 写明依据);都对就不提交;","2. 改善监控时间:monitor_stall_check 看它正常运行时日志的节奏,按建议值和你看日志的判断用 monitor_stall_set 设它多久没新日志算卡住,note 写明依据(例如「战斗中最长 70 秒不输出」);","3. 把做过的步骤总结成技能,分到对应的游戏和脚本:运行和处理这个脚本时反复用到、已经走通的做法(常见报错怎么处理、怎么确认跑完、配置怎么改)用 skill_save 存成技能,scripts 填这个脚本的 id,只给它用;其中和游戏本身有关、别的脚本也用得上的(游戏里的操作、界面、活动、机制)单独存,games 填它玩的游戏 id(game_list 查),不填 scripts;已有的技能就合并更新(replace),不要重复存,没有值得存的就不存;","4. 不要运行脚本、不要改它的配置;最后用几句话告诉我:脚本包改了什么(草稿在「脚本」页等我确认)、卡住时间设成多少、存了或更新了哪些技能。"].join(`
106
- `)}const Em=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>Vk},{name:"资讯",aliases:["news"],title:"上网查游戏资讯:活动、版本、维护公告",arg:"游戏名(可选,不写就查游戏页上的游戏)",expand:e=>[`上网查${e===""?"我游戏页上的游戏":`「${e}」`}最近的资讯,按技能 web-reading:`,"1. 先 game_list、game_activities 看日历里已经有什么,不重复查;","2. 先用公开 API(SRA 公共 API、Wiki 的 api.php),没有再读官网公告列表页,只打开最近的活动、版本和维护公告;","3. 查到起止时间的活动用 game_record(source=site,写上 url)记进日历;","4. 最后按游戏列一下:正在进行、快结束、即将开始的活动,和其他值得知道的消息(新版本、维护、福利、兑换码)。"].join(`
107
- `)},{name:"编排",aliases:["plan","pipeline"],title:"把脚本编成流水线(先起草,我确认后才生效)",arg:"想做什么(可选,例如「每天早上跑完三个游戏的日常」)",expand:e=>[`帮我把脚本编排成流水线:${e===""?"把我装好的各个脚本的日常任务排成每天能自动跑的流程":e}。按技能 pipeline-planning:`,"1. 先 system_info 看电脑配置(能不能同时跑几个游戏),pipeline_list 看已有的流水线,script_tasks 看各脚本有哪些任务;","2. 用 pipeline_draft 起草(草稿,我在「编排」页保存后才会按定时运行):模拟器和前台脚本能并行的并行,失败不要挡住别的;","3. 说清楚为什么这样排、哪些步骤并行、估计多久、建议定在几点跑。"].join(`
108
- `)},{name:"诊断",aliases:["diagnose","why"],title:"分析脚本为什么失败,给出怎么改的建议",arg:"脚本名或运行 id(可选,不写就看最近失败的)",expand:e=>[`分析${e===""?"最近失败的脚本运行":`「${e}」`}为什么失败:`,"1. 用 script_runs 找到失败的那次运行,script_run_log 看日志(先按错误级别筛,再看出错前后);","2. 对照这个脚本包的技能说明原因:是脚本本身、配置、游戏状态(更新、公告、掉线)、模拟器 / ADB,还是电脑环境;","3. 给出怎么改:改哪项配置、游戏里要做什么、要不要重跑。先不要改任何东西、不要重跑,等我决定。"].join(`
109
- `)},{name:"优化脚本",aliases:["optimize"],title:"用运行攒下的信息优化脚本:重新总结脚本包、调监控时间、把做过的步骤存成技能",arg:"脚本名(可选,不写就看最近运行过的)",expand:e=>N$(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function j$(e){var n,r,i;const t=(r=(n=/^\/(\S+)/.exec(e.trim()))==null?void 0:n[1])==null?void 0:r.toLowerCase();return t===void 0||(i=Em.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:i.local}function S$(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function _$(e,t){const n=e.trim(),r=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(n);if(r===null)return n;const i=r[1],o=(r[2]??"").trim(),c=Em.find(f=>f.name===i.toLowerCase()||f.aliases.includes(i.toLowerCase()));if((c==null?void 0:c.local)!==void 0)return n;if(c!==void 0)return`${n}
110
-
111
- ${c.expand(o)}`;const u=t.find(f=>f.name===i);return u===void 0?n:`${n}
112
-
113
- ${S$(u.name,o)}`}function E$(e){if(!e.startsWith("/"))return;const t=e.indexOf(`
114
-
115
- `);return t<0?void 0:{typed:e.slice(0,t),expansion:e.slice(t+2)}}function C$(e,t,n=!1){const r=/^\/(\S*)$/.exec(e);if(r===null)return[];const i=r[1].toLowerCase(),o=Em.filter(f=>(n||f.local===void 0)&&[f.name,...f.aliases].some(d=>d.toLowerCase().includes(i))).map(f=>({kind:"command",name:f.name,description:f.title,...f.arg===void 0?{}:{arg:f.arg},command:f})),c=f=>f.toLowerCase().startsWith(i)?0:1,u=t.filter(f=>f.name.toLowerCase().includes(i)||i.length>0&&f.description.toLowerCase().includes(i)).sort((f,d)=>+(f.group===void 0)-+(d.group===void 0)||(f.group??"").localeCompare(d.group??"")||c(f.name)-c(d.name)||f.name.localeCompare(d.name)).map(f=>({kind:"skill",name:f.name,description:f.description,...f.group===void 0?{}:{group:f.group}}));return[...o,...u]}const I$=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function A$(e){var y,S;const t=e.trim().replace(/^<|>$/g,""),n=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(t);if(n!==null&&!t.includes(":"))return{repo:`${n[1]}/${n[2]}`};const r=/git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/i.exec(t);if(r!==null)return{repo:`${r[1]}/${r[2]}`};const i=k=>{try{return decodeURIComponent(k)}catch{return k}},o=/raw\.githubusercontent\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/([^/?#]+)/i.exec(t);if(o!==null)return{repo:`${o[1]}/${o[2]}`,branch:i(o[3])};const c=/api\.github\.com\/repos\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/i.exec(t);if(c!==null)return{repo:`${c[1]}/${c[2]}`};const u=t.toLowerCase().lastIndexOf("github.com/");if(u===-1)return;const d=t.slice(u+11).split(/[?#]/)[0].replace(/\/+$/,"").split("/");if(d.length<2||!/^[A-Za-z0-9_.-]+$/.test(d[0]))return;const p=d[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(p))return;const m=`${d[0]}/${p}`,[g,...v]=d.slice(2);if(g==="releases")return v[0]==="tag"&&v[1]!==void 0?{repo:m,tag:i(v.slice(1).join("/"))}:v[0]==="download"&&v.length>=3?{repo:m,tag:i(v.slice(1,-1).join("/")),asset:i(v.at(-1))}:{repo:m};if(g==="tree"&&v.length>0)return{repo:m,branch:i(v[0])};if(g==="archive"){const k=v.join("/").replace(/\.(zip|tar\.gz)$/i,""),w=(y=/^refs\/tags\/(.+)$/.exec(k))==null?void 0:y[1];if(w!==void 0)return{repo:m,tag:i(w)};const A=(S=/^refs\/heads\/(.+)$/.exec(k))==null?void 0:S[1];return A!==void 0?{repo:m,branch:i(A)}:{repo:m,tag:i(k)}}return g===void 0||I$.has(g)?{repo:m}:{repo:m}}const qk="你",T$="(不用告诉用户)";function $$(e){return e.replace(/[。.\s]/g,"")===T$}const M$="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)";function R$(e){const[t="",...n]=e.split(`
116
- `),r=/^(你在软件里点的:(.*))$/.exec(t),i=r===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(r===null&&i===null)return;const o=n[0]===M$;return{by:r!==null?qk:i[1],title:r!==null?r[1]:i[2],returns:o,body:(o?n.slice(1):n).join(`
117
- `).trim()}}function O$(e){const[t="",...n]=e.split(`
118
- `),r=/^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(t);if(r===null)return;const i=n.join(`
119
- `).trim(),o=i.lastIndexOf(`
120
-
121
- (`);return{agent:r[1],ok:r[2]==="交回了",asker:r[3],title:r[4],reply:(o===-1?i:i.slice(0,o)).trim()}}function z$(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}function x0(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[L$(t[1])];const n=/^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(e);if(n!==null)try{return JSON.parse(n[1]).map(i=>String(i.reminder_prompt??"")).filter(i=>i!=="")}catch{return[]}}function P$(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>z$(t)).join(";")}`}function L$(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const v0=1;var ii,xs,Di,ka,fd,ur,jo,So,ec,hn,Tp,$p,Mp,Gk,Kk,Rp,Op;class D${constructor(t){Lt(this,hn);ut(this,"status",new zr({state:"idle",attempt:0}));ut(this,"server",new zr(null));Lt(this,ii);Lt(this,xs,null);Lt(this,Di,!1);Lt(this,ka,0);Lt(this,fd,1);Lt(this,ur,new Map);Lt(this,jo,new Map);Lt(this,So,new Set);Lt(this,ec);Zt(this,ii,t)}get generation(){return Re(this,ka)}get ready(){return Re(this,Di)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||xt(this,hn,Mp).call(this)}stop(){clearTimeout(Re(this,ec)),this.status.set({state:"stopped",attempt:0});const t=Re(this,xs);Zt(this,xs,null),xt(this,hn,Rp).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,n){let r=Re(this,jo).get(t);return r===void 0&&Re(this,jo).set(t,r=new Set),r.add(n),()=>{r.delete(n)}}onReady(t){return Re(this,So).add(t),Re(this,Di)&&queueMicrotask(()=>t(Re(this,ka))),()=>{Re(this,So).delete(t)}}call(t,n,r){return!Re(this,Di)&&t!=="initialize"?Promise.reject(new ml(mu.NotInitialized,"not connected to the gateway")):xt(this,hn,Tp).call(this,t,n,r)}}ii=new WeakMap,xs=new WeakMap,Di=new WeakMap,ka=new WeakMap,fd=new WeakMap,ur=new WeakMap,jo=new WeakMap,So=new WeakMap,ec=new WeakMap,hn=new WeakSet,Tp=function(t,n,r){const i=Re(this,xs);if(i===null||i.readyState!==v0)return Promise.reject(new ml(mu.NotInitialized,"not connected to the gateway"));if((r==null?void 0:r.aborted)===!0)return Promise.reject(r.reason??new Error("aborted"));const o=_v(this,fd)._++;return new Promise((c,u)=>{const f=Re(this,ii).callTimeoutMs??6e4,d=f>0?setTimeout(()=>{var g;(g=Re(this,ur).get(o))==null||g.reject(new ml(mu.InternalError,`${t} timed out`))},f):void 0,p=()=>{var g;Re(this,ur).has(o)&&(xt(this,hn,$p).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(g=Re(this,ur).get(o))==null||g.reject((r==null?void 0:r.reason)instanceof Error?r.reason:new Error("aborted")))};r==null||r.addEventListener("abort",p,{once:!0});const m=()=>{clearTimeout(d),r==null||r.removeEventListener("abort",p),Re(this,ur).delete(o)};Re(this,ur).set(o,{resolve:g=>{m(),c(g)},reject:g=>{m(),u(g)},cleanup:m}),xt(this,hn,$p).call(this,{jsonrpc:"2.0",id:o,method:t,params:n})})},$p=function(t){var n;((n=Re(this,xs))==null?void 0:n.readyState)===v0&&Re(this,xs).send(JSON.stringify(t))},Mp=function(){const t=this.status.get();this.status.set({state:t.attempt===0?"connecting":"reconnecting",attempt:t.attempt,...t.error===void 0?{}:{error:t.error}});let n;try{n=(Re(this,ii).createSocket??(r=>new WebSocket(r)))(Re(this,ii).url)}catch(r){xt(this,hn,Op).call(this,r instanceof Error?r.message:String(r));return}Zt(this,xs,n),n.addEventListener("open",()=>{Re(this,xs)===n&&xt(this,hn,Gk).call(this,n)}),n.addEventListener("message",r=>{Re(this,xs)===n&&xt(this,hn,Kk).call(this,String(r.data))}),n.addEventListener("close",r=>{if(Re(this,xs)!==n)return;Zt(this,xs,null),xt(this,hn,Rp).call(this,"connection lost");const i=typeof r.reason=="string"&&r.reason!==""?r.reason:`closed (${r.code??"?"})`;xt(this,hn,Op).call(this,i)}),n.addEventListener("error",()=>{})},Gk=async function(t){try{const n=await xt(this,hn,Tp).call(this,"initialize",{protocolVersion:h$,client:Re(this,ii).clientInfo});if(Re(this,xs)!==t)return;Zt(this,Di,!0),Zt(this,ka,Re(this,ka)+1),this.server.set(n),this.status.set({state:"open",attempt:0});for(const r of[...Re(this,So)])r(Re(this,ka))}catch(n){t.close(4e3,n instanceof Error?n.message:"initialize failed")}},Kk=function(t){let n;try{n=JSON.parse(t)}catch{return}const r=w$(n);if(r==="response"){const i=Re(this,ur).get(n.id);if(i===void 0)return;"error"in n?i.reject(new ml(n.error.code,n.error.message,n.error.data)):i.resolve(n.result)}else if(r==="notification")for(const i of[...Re(this,jo).get(n.method)??[]])try{i(n.params)}catch(o){console.error(`notification handler for ${n.method} failed`,o)}},Rp=function(t){Zt(this,Di,!1);for(const n of[...Re(this,ur).values()])n.reject(new ml(mu.InternalError,t));Re(this,ur).clear()},Op=function(t){if(this.status.get().state==="stopped")return;const n=this.status.get().attempt+1,{initial:r,max:i}=Re(this,ii).backoffMs??{initial:500,max:1e4},o=Math.min(i,r*2**Math.min(n-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:n,error:t}),Zt(this,ec,setTimeout(()=>xt(this,hn,Mp).call(this),o))};const F$={status:"opening",header:null,title:null,events:[],cursor:-1,hasMore:!1,loadingOlder:!1,live:null,pending:[],queue:[],context:null,running:!1,version:0,error:null};var vs,tc,_o,Eo,ai,Fi,nc,sc,Wt,zp,Mu,Kn;class B${constructor(t,n,r){Lt(this,Wt);ut(this,"id");ut(this,"state",new zr(F$));Lt(this,vs);Lt(this,tc);Lt(this,_o,null);Lt(this,Eo,-1);Lt(this,ai,!1);Lt(this,Fi,null);Lt(this,nc);Lt(this,sc);this.id=t,Zt(this,vs,n),Zt(this,tc,r),Zt(this,nc,n.onReady(i=>{i!==Re(this,Eo)&&xt(this,Wt,zp).call(this,i)}))}get subscriptionId(){return Re(this,_o)}async prompt(t,n="queue",r=[]){const i=crypto.randomUUID(),o={requestId:i,text:t,mode:n,sentAt:Date.now(),...r.length===0?{}:{images:r.length}};xt(this,Wt,Kn).call(this,c=>({...c,pending:[...c.pending,o]}));try{await Re(this,vs).call("session/prompt",{sessionId:this.id,requestId:i,text:t,mode:n,...r.length===0?{}:{images:[...r]}})}catch(c){const u=c instanceof Error?c.message:String(c);throw xt(this,Wt,Kn).call(this,f=>({...f,pending:f.pending.map(d=>d.requestId===i?{...d,failed:u}:d)})),c}}dismissPending(t){xt(this,Wt,Kn).call(this,n=>({...n,pending:n.pending.filter(r=>r.requestId!==t)}))}async updateQueue(t,n){await Re(this,vs).call("session/queue/update",{sessionId:this.id,itemId:t,action:n})}async cancel(){await Re(this,vs).call("session/cancel",{sessionId:this.id})}async compact(){return Re(this,vs).call("session/compact",{sessionId:this.id})}async loadOlder(){const t=this.state.get(),n=t.events[0];if(!(!t.hasMore||t.loadingOlder||n===void 0)){xt(this,Wt,Kn).call(this,r=>({...r,loadingOlder:!0}));try{const r=await Re(this,vs).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:n.seq});xt(this,Wt,Kn).call(this,i=>{var u;const o=((u=i.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,c=r.events.filter(f=>f.seq<o);return{...i,events:[...c,...i.events],hasMore:r.hasMore,loadingOlder:!1}})}catch(r){xt(this,Wt,Kn).call(this,i=>({...i,loadingOlder:!1,error:r instanceof Error?r.message:String(r)}))}}}close(){if(Re(this,ai))return;Zt(this,ai,!0),clearTimeout(Re(this,sc)),Re(this,nc).call(this);const t=Re(this,_o);xt(this,Wt,Mu).call(this,null),t!==null&&Re(this,vs).ready&&Re(this,vs).call("session/close",{subscriptionId:t}).catch(()=>{}),xt(this,Wt,Kn).call(this,n=>({...n,status:"closed"}))}receiveEvent(t){xt(this,Wt,Kn).call(this,n=>{const r=n.events.at(-1);if(r!==void 0&&t.seq<=r.seq)return n;let i=n.pending;t.type==="user/message"&&t.requestId!==void 0&&(i=i.filter(f=>f.requestId!==t.requestId));let o=n.live;(t.type==="assistant/message"||t.type==="assistant/attempt")&&o!==null&&o.turn===t.turn&&o.step===t.step&&(o=null);const c=t.type==="session/title"?t.title:n.title,u=[...n.events,t];return{...n,events:u,pending:i,live:o,title:c,running:jh(u,o)}})}receiveLive(t){xt(this,Wt,Kn).call(this,n=>{var r;switch(t.type){case"start":{const i={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...n,live:i,running:!0}}case"delta":{const i=n.live;return i===null||i.attemptId!==t.attemptId?n:(i.deltas.push(t),{...n,live:{...i}})}case"end":return((r=n.live)==null?void 0:r.attemptId)!==t.attemptId?n:{...n,live:null,running:jh(n.events,null)}}})}receiveClosed(t){xt(this,Wt,Mu).call(this,null),!Re(this,ai)&&(xt(this,Wt,Kn).call(this,n=>({...n,status:"error",error:`stream ended: ${t}`})),Zt(this,sc,setTimeout(()=>{!Re(this,ai)&&Re(this,vs).ready&&xt(this,Wt,zp).call(this,Re(this,Eo))},1e3)))}receiveQueue(t){xt(this,Wt,Kn).call(this,n=>({...n,queue:t,pending:y0(n.pending,t)}))}receiveContext(t){xt(this,Wt,Kn).call(this,n=>({...n,context:t}))}receiveTitle(t){xt(this,Wt,Kn).call(this,n=>n.title===t?n:{...n,title:t})}}vs=new WeakMap,tc=new WeakMap,_o=new WeakMap,Eo=new WeakMap,ai=new WeakMap,Fi=new WeakMap,nc=new WeakMap,sc=new WeakMap,Wt=new WeakSet,zp=async function(t){if(!Re(this,ai))return Re(this,Fi)!==null?Re(this,Fi):(Zt(this,Eo,t),Zt(this,Fi,(async()=>{try{const n=await Re(this,vs).call("session/open",{sessionId:this.id});if(Re(this,ai)){Re(this,vs).call("session/close",{subscriptionId:n.subscriptionId}).catch(()=>{});return}xt(this,Wt,Mu).call(this,n.subscriptionId);const r=n.live===null?null:{...n.live,deltas:[...n.live.deltas]};xt(this,Wt,Kn).call(this,i=>{const o=new Set(n.events.flatMap(c=>c.type==="user/message"&&c.requestId!==void 0?[c.requestId]:[]));return{...i,status:"open",header:n.header,title:n.title,events:n.events,cursor:n.cursor,hasMore:n.hasMore,live:r,pending:y0(i.pending.filter(c=>!o.has(c.requestId)),n.queue??[]),queue:n.queue??[],context:n.context??i.context,running:jh(n.events,r),loadingOlder:!1,error:null}})}catch(n){xt(this,Wt,Kn).call(this,r=>({...r,status:"error",error:n instanceof Error?n.message:String(n)}))}finally{Zt(this,Fi,null)}})()),Re(this,Fi))},Mu=function(t){Zt(this,_o,t),Re(this,tc).bindSubscription(this,t)},Kn=function(t){this.state.set(n=>{const r=t(n);return r===n?n:{...r,version:n.version+1}})};function y0(e,t){const n=new Set(t.flatMap(r=>r.requestId===void 0?[]:[r.requestId]));return n.size===0?e:e.filter(r=>!n.has(r.requestId))}function jh(e,t){if(t!==null)return!0;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.type==="turn/end")return!1;if(r.type==="turn/start")return!0}return!1}const b0=(e,t)=>t.updatedAt-e.updatedAt;var Is,Pr,Co,Gi,Ru,Yk;class U${constructor(t){Lt(this,Gi);ut(this,"connection");ut(this,"sessions",new zr({items:[],loaded:!1,error:null}));ut(this,"approvals",new zr([]));ut(this,"questions",new zr([]));ut(this,"capabilities",new zr(new Set));ut(this,"credentialRevision",new zr(0));ut(this,"providersRevision",new zr(0));ut(this,"sessionModels",new zr(new Map));Lt(this,Is,new Map);Lt(this,Pr,new Map);Lt(this,Co,!1);this.connection=new D$({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const n=this.connection;n.onReady(()=>{var r;this.capabilities.set(new Set(((r=n.server.get())==null?void 0:r.capabilities.map(i=>i.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),n.on("sessions/changed",r=>{if(r.kind==="removed"){this.sessions.set(o=>({...o,items:o.items.filter(c=>c.id!==r.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===r.item.id)){xt(this,Gi,Yk).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===r.item.id?{...c,...H$(r.item)}:c).sort(b0)}))}),n.on("session/title",({sessionId:r,title:i})=>{var o;(o=Re(this,Is).get(r))==null||o.handle.receiveTitle(i)}),n.on("session/queue",({sessionId:r,items:i})=>{var o;(o=Re(this,Is).get(r))==null||o.handle.receiveQueue(i)}),n.on("session/context",({sessionId:r,context:i})=>{var o;(o=Re(this,Is).get(r))==null||o.handle.receiveContext(i)}),n.on("session/event",({subscriptionId:r,event:i})=>{var o;return(o=Re(this,Pr).get(r))==null?void 0:o.receiveEvent(i)}),n.on("session/live",({subscriptionId:r,frame:i})=>{var o;return(o=Re(this,Pr).get(r))==null?void 0:o.receiveLive(i)}),n.on("session/closed",({subscriptionId:r,reason:i})=>{const o=Re(this,Pr).get(r);o!==void 0&&o.subscriptionId===r&&o.receiveClosed(i)}),n.on("approval/requested",r=>{this.approvals.set(i=>i.some(o=>o.approvalId===r.approvalId)?i:[...i,r])}),n.on("approval/resolved",({approvalId:r})=>{this.approvals.set(i=>i.filter(o=>o.approvalId!==r))}),n.on("question/requested",r=>{this.questions.set(i=>i.some(o=>o.questionId===r.questionId)?i:[...i,r])}),n.on("question/resolved",({questionId:r})=>{this.questions.set(i=>i.filter(o=>o.questionId!==r))}),n.on("credentials/changed",()=>this.credentialRevision.set(r=>r+1)),n.on("providers/changed",()=>this.providersRevision.set(r=>r+1)),n.on("session/model",({sessionId:r,lastUsed:i,next:o})=>xt(this,Gi,Ru).call(this,r,{lastUsed:i,next:o}))}async describeCredentials(t){const{items:n}=await this.connection.call("credentials/describe",{refs:[...t]});return n}async setCredential(t,n){await this.connection.call("credentials/set",{ref:t,value:n}),this.credentialRevision.set(r=>r+1)}async unsetCredential(t){await this.connection.call("credentials/unset",{ref:t}),this.credentialRevision.set(n=>n+1)}start(){this.connection.start()}stop(){for(const{handle:t}of Re(this,Is).values())t.close();Re(this,Is).clear(),Re(this,Pr).clear(),this.connection.stop()}has(t){return this.capabilities.get().has(t)}async refreshSessions(){try{const{items:t}=await this.connection.call("sessions/list",{});this.sessions.set({items:[...t].sort(b0),loaded:!0,error:null})}catch(t){this.sessions.set(n=>({...n,error:t instanceof Error?t.message:String(t)}))}}async createSession(t,n={}){const{sessionId:r}=await this.connection.call("sessions/create",{...t===void 0?{}:{cwd:t},...n.role===void 0?{}:{role:n.role}});return await this.refreshSessions(),r}async renameSession(t,n){var i;const r=await this.connection.call("sessions/rename",{sessionId:t,title:n});this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===t?{...c,title:r.title}:c)})),(i=Re(this,Is).get(t))==null||i.handle.receiveTitle(r.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const n=await this.connection.call("session/model",{sessionId:t});return xt(this,Gi,Ru).call(this,t,n),n}async selectModel(t,n){var o;const{selected:r}=await this.connection.call("session/selectModel",{sessionId:t,...n}),i=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return xt(this,Gi,Ru).call(this,t,{lastUsed:i,next:r}),r}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,n){const{models:r}=await this.connection.call("providers/discover",t,n);return r}async providerBalance(t){const{balance:n}=await this.connection.call("providers/balance",{provider:t});return n}async saveProvider(t){const n=await this.connection.call("providers/save",t);return this.providersRevision.set(r=>r+1),t.apiKey!==void 0&&this.credentialRevision.set(r=>r+1),n}async removeProvider(t){const n=await this.connection.call("providers/remove",t);return this.providersRevision.set(r=>r+1),t.removeKey===!0&&this.credentialRevision.set(r=>r+1),n}async respondApproval(t,n){await this.connection.call("approval/respond",{approvalId:t,decision:n}),this.approvals.set(r=>r.filter(i=>i.approvalId!==t))}async answerQuestion(t,n){await this.connection.call("question/respond",{questionId:t,answers:[...n]}),this.questions.set(r=>r.filter(i=>i.questionId!==t))}openSession(t){const n=Re(this,Is).get(t);if(n!==void 0)return n.refs+=1,n.handle;const r=new B$(t,this.connection,{bindSubscription:(i,o)=>{for(const[c,u]of Re(this,Pr))u===i&&Re(this,Pr).delete(c);o!==null&&Re(this,Pr).set(o,i)}});return Re(this,Is).set(t,{handle:r,refs:1}),r}release(t){const n=Re(this,Is).get(t.id);n===void 0||n.handle!==t||(n.refs-=1,!(n.refs>0)&&(Re(this,Is).delete(t.id),t.close()))}}Is=new WeakMap,Pr=new WeakMap,Co=new WeakMap,Gi=new WeakSet,Ru=function(t,n){this.sessionModels.set(r=>new Map(r).set(t,n))},Yk=function(){Re(this,Co)||(Zt(this,Co,!0),setTimeout(()=>{Zt(this,Co,!1),this.refreshSessions()},150))};function H$(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Sh=(e,t)=>e.map(n=>n.type===t?n.text:"").join(""),k0=e=>e.flatMap(t=>t.type==="image"&&t.attachmentId!==void 0&&t.mediaType!==void 0&&t.bytes!==void 0&&t.width!==void 0&&t.height!==void 0?[{attachmentId:t.attachmentId,mediaType:t.mediaType,bytes:t.bytes,width:t.width,height:t.height,...t.name===void 0?{}:{name:t.name}}]:[]),Z$=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join("");function W$(e,t,n=[]){var f;const r=[],i=new Map,o=new Set,c=new Map,u=new Map;for(const d of e)switch(d.type){case"user/message":{const p=Sh(d.content,"text");d.origin.human?r.push({kind:"user",id:`u:${d.seq}`,text:p,time:d.time,images:d.content.filter(m=>m.type==="image").length,imageRefs:k0(d.content),files:d.content.filter(m=>m.type==="file").length}):x0(p)!==void 0?r.push({kind:"context",id:`c:${d.seq}`,title:"定时提醒",summary:P$(x0(p)),text:p,startsTurn:!0}):d.replacesHistory===!0?r.push({kind:"context",id:`c:${d.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:p}):d.origin.summary!==void 0&&r.push({kind:"context",id:`c:${d.seq}`,title:d.origin.kind,summary:d.origin.summary,text:p});break}case"assistant/message":{o.add(`${d.turn}:${d.step}`);const p=Sh(d.content,"text"),m=Sh(d.content,"reasoning");(p.trim()!==""||m.trim()!=="")&&r.push({kind:"assistant",id:`a:${d.seq}`,text:p,reasoning:m,live:!1,interrupted:d.interrupted===!0,time:d.time,...d.model===void 0?{}:{model:d.model}});break}case"tool/call":{const p={kind:"tool",id:`t:${d.callId}`,callId:d.callId,name:d.name,arguments:d.arguments,status:"running",time:d.time},m=c.get(d.callId);m!==void 0&&(p.approval=m),i.set(d.callId,p),r.push(p);break}case"tool/result":{const p=i.get(d.callId);if(p===void 0)break;p.result=Z$(d.content);const m=k0(d.content);m.length>0&&(p.images=m),p.status=d.isError?"error":"ok",d.error!==void 0&&(p.error=d.error.message);break}case"approval/asked":if(d.callId!==void 0){u.set(d.approvalId,d.callId),c.set(d.callId,"asked");const p=i.get(d.callId);p!==void 0&&(p.approval="asked")}break;case"approval/decided":{const p=u.get(d.approvalId);if(p===void 0)break;c.set(p,d.outcome);const m=i.get(p);m!==void 0&&(m.approval=d.outcome);break}case"turn/end":for(const p of i.values())p.status==="running"&&(p.status="interrupted");d.reason.kind==="error"?r.push({kind:"notice",id:`e:${d.seq}`,tone:"error",text:d.reason.message??"这一轮出错了"}):d.reason.kind==="aborted"?r.push({kind:"notice",id:`e:${d.seq}`,tone:"info",text:"已停止"}):d.reason.kind==="max-tokens"&&r.push({kind:"notice",id:`e:${d.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":r.push({kind:"notice",id:`k:${d.seq}`,tone:d.error===void 0?"info":"error",text:d.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${d.error}`});break}if(t!==null&&!o.has(`${t.turn}:${t.step}`)){let d="",p="";for(const m of t.deltas)m.kind==="text"?d+=m.text:m.kind==="reasoning"&&(p+=m.text);r.push({kind:"assistant",id:`live:${t.attemptId}`,text:d,reasoning:p,live:!0,interrupted:!1,time:((f=t.deltas[0])==null?void 0:f.time)??Date.now()})}for(const d of n)r.push({kind:"user",id:`p:${d.requestId}`,text:d.text,images:d.images??0,imageRefs:[],files:0,time:d.sentAt,pending:{requestId:d.requestId,...d.failed===void 0?{}:{failed:d.failed}}});return r}var b=rc();const V$=gm(b);function q$(e,t){return e.filter(n=>{var r;return((r=n.available)==null?void 0:r.call(n,t))??!0})}const Bi=new Map,Wu=new Set;function Fn(e){if(Bi.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Bi.set(e.id,e);for(const t of Wu)t();return()=>{if(Bi.get(e.id)===e){Bi.delete(e.id);for(const t of Wu)t()}}}function Xk(e){return Wu.add(e),()=>{Wu.delete(e)}}function G$(e){return[...Bi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.sessionViews??[]).sort((t,n)=>t.order-n.order)}function K$(e){return[...Bi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.settingsPages??[]).sort((t,n)=>t.order-n.order)}function Y$(e){return[...Bi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.pages??[]).sort((t,n)=>t.order-n.order)}function X$(e){return[...Bi.values()].map(t=>({plugin:t,missing:t.requires.filter(n=>!e.has(n))}))}function je(e){return b.useSyncExternalStore(e.subscribe,e.get,e.get)}function Qk(e,t){const[n,r]=b.useState(null);return b.useEffect(()=>{const i=e.openSession(t);return r(i),()=>e.release(i)},[e,t]),n!==null&&n.id===t?n:null}function Jk(e){const t=je(e.capabilities),n=Cm();return b.useMemo(()=>G$(t),[t,n])}function Q$(e){const t=je(e.capabilities),n=Cm();return b.useMemo(()=>K$(t),[t,n])}function J$(e){const t=je(e.capabilities),n=Cm();return b.useMemo(()=>Y$(t),[t,n])}function Cm(){const[e,t]=b.useState(0);return b.useEffect(()=>Xk(()=>t(n=>n+1)),[]),e}function ew(e,t){const n=je(e.credentialRevision),r=je(e.connection.status),i=je(e.capabilities),o=t.join(`
122
- `),[c,u]=b.useState({items:null,error:null});return b.useEffect(()=>{if(r.state!=="open"||!i.has("credentials")||o==="")return;let f=!0;return e.describeCredentials(o.split(`
123
- `)).then(d=>{f&&u({items:d,error:null})}).catch(d=>{f&&u(p=>({...p,error:d instanceof Error?d.message:String(d)}))}),()=>{f=!1}},[e,o,n,r.state,i]),c}function Fo(e){const t=je(e.credentialRevision),n=je(e.providersRevision),r=je(e.connection.status),i=je(e.capabilities),[o,c]=b.useState({catalog:null,error:null});return b.useEffect(()=>{if(r.state!=="open"||!i.has("models"))return;let u=!0;return e.modelCatalog().then(f=>{u&&c({catalog:f,error:null})}).catch(f=>{u&&c(d=>({...d,error:f instanceof Error?f.message:String(f)}))}),()=>{u=!1}},[e,t,n,r.state,i]),o}function Cn(e){const[t,n]=b.useState(()=>Date.now());return b.useEffect(()=>{const r=setInterval(()=>n(Date.now()),e);return()=>clearInterval(r)},[e]),t}function eM(e){const t=je(e.connection.status),n=je(e.capabilities),[r,i]=b.useState(void 0);return b.useEffect(()=>e.connection.on("permissions/changed",o=>i(o.mode)),[e]),b.useEffect(()=>{if(t.state!=="open"||!n.has("permissions"))return;let o=!0;return e.connection.call("permissions/get",{}).then(c=>{o&&i(c.mode)}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),r}const tM={plus:"M12 5v14M5 12h14",chat:"M21 11.5a8.4 8.4 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7a8.4 8.4 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.4 8.4 0 0 1 3.8-.9h.5a8.5 8.5 0 0 1 8 8v.5Z",settings:"M4 7h9m4 0h3M4 17h3m4 0h9M13 4v6M7 14v6",arrow:"M12 19V5m-6 6 6-6 6 6",activity:"M3 12h4l3-8 4 16 3-8h4",layers:"m12 3 9 5-9 5-9-5 9-5Zm-9 9 9 5 9-5M3 16l9 5 9-5",sparkles:"m12 3 2.5 6.5L21 12l-6.5 2.5L12 21l-2.5-6.5L3 12l6.5-2.5L12 3Z",close:"m6 6 12 12M6 18 18 6",gauge:"M12 14l4-4M3.5 15a8.5 8.5 0 1 1 17 0M6.5 19h11",popout:"M14 4h6v6M20 4l-8.5 8.5M18 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 4 18.5v-11A1.5 1.5 0 0 1 5.5 6H10",search:"M11 17.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13ZM20 20l-4-4",check:"m5 12.5 4.5 4.5L19 7.5",pencil:"M4 20h4L18.5 9.5a2.1 2.1 0 0 0-4-4L4 16v4ZM13.5 6.5l4 4",copy:"M10 8h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2ZM16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2",chevron:"m9 6 6 6-6 6","chevron-down":"m6 9 6 6 6-6",back:"M19 12H5M11 6l-6 6 6 6",shield:"M12 3 4 6v6c0 4.5 3.4 8 8 9 4.6-1 8-4.5 8-9V6l-8-3ZM12 9v4M12 16.5v.01",terminal:"M4 17l6-6-6-6M12 19h8",image:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1ZM4 16l5-5 4 4 2-2 5 5M15 9.5v.01",paperclip:"m20 11.5-8.2 8.2a5 5 0 0 1-7-7l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.5 8.5a1.7 1.7 0 0 1-2.4-2.4l7.8-7.8",info:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 11v5M12 7.5v.01",key:"M8 19a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM11 12l8-8M16 7l2 2M14 9l2 2",sidebar:"M6.5 4.5h11a3 3 0 0 1 3 3v9a3 3 0 0 1-3 3h-11a3 3 0 0 1-3-3v-9a3 3 0 0 1 3-3ZM9.5 4.5v15",alert:"M12 4 2.5 20h19L12 4ZM12 10v4M12 17v.01",package:"m12 3 8 4.5v9L12 21l-8-4.5v-9L12 3Zm0 9 8-4.5M12 12v9M12 12 4 7.5",flow:"M5 4h4v4H5zM15 16h4v4h-4zM15 4h4v4h-4zM9 6h6M17 8v8M7 8v6a2 2 0 0 0 2 2h6",monitor:"M4 5h16v11H4zM9 20h6M12 16v4M7 12l2.5-3 2.5 2 3-4 2 2",gamepad:"M7 9v4M5 11h4M15 10.5v.01M17.5 12.5v.01M6.5 6h11a4 4 0 0 1 4 4.4l-.6 5.3a2.6 2.6 0 0 1-4.5 1.4L14.5 15h-5l-1.9 2.1a2.6 2.6 0 0 1-4.5-1.4l-.6-5.3A4 4 0 0 1 6.5 6Z",plug:"M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0V8ZM12 17v4",home:"M4 11 12 4l8 7M6 9.5V20h12V9.5",archive:"M4 5h16v4H4zM5.5 9v10h13V9M10 13h4",refresh:"M20 11a8 8 0 0 0-14.3-4.9L4 8M4 4v4h4M4 13a8 8 0 0 0 14.3 4.9L20 16M20 20v-4h-4",calendar:"M5 5.5h14a1 1 0 0 1 1 1V19a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6.5a1 1 0 0 1 1-1ZM4 10h16M8 3.5v4M16 3.5v4M8 14h2M14 14h2M8 17h2",send:"M20.5 3.5 10 14M20.5 3.5 14 20.5l-4-6.5-6.5-4 17-6.5Z",power:"M12 3.5v8M7.2 6.5a7 7 0 1 0 9.6 0",download:"M12 4v11M7 10.5l5 5 5-5M5 20h14",compress:"M12 3v6M9 6l3 3 3-3M12 21v-6M9 18l3-3 3 3M4 12h16"};function ee({name:e,className:t=""}){return s.jsx("svg",{className:`ui-icon ${t}`,width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:tM[e]})})}function nM(){return s.jsx("svg",{className:"ui-icon stop-glyph",viewBox:"0 0 24 24","aria-hidden":"true",children:s.jsx("rect",{x:"5",y:"5",width:"14",height:"14",rx:"3",fill:"currentColor"})})}function xd({size:e="md"}){return s.jsx("span",{className:`adg-mark ${e}`,"aria-hidden":"true",children:s.jsxs("svg",{className:"ui-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9 7.5v9l7.5-4.5L9 7.5Z"}),s.jsx("path",{d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})}const w0="adg.otherCopies.seen";function sM(e){const t=je(e.connection.status),r=je(e.capabilities).has("instances"),[i,o]=b.useState([]);return b.useEffect(()=>e.connection.on("instances/changed",c=>o(c.others)),[e]),b.useEffect(()=>{if(t.state!=="open"||!r){o([]);return}let c=!0;return e.connection.call("instances/others",{}).then(u=>{c&&o(u.others)}).catch(()=>{}),()=>{c=!1}},[e,t.state,r]),i}function rM({client:e}){const t=sM(e),n=JSON.stringify(t.map(c=>[c.pid,c.warnings])),[r,i]=b.useState(()=>{try{return localStorage.getItem(w0)}catch{return null}});if(t.length===0||r===n)return null;const o=()=>{try{localStorage.setItem(w0,n)}catch{}i(n)};return s.jsxs("div",{className:"approval-card other-copies",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"alert"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("span",{className:"approval-title",children:t.length===1?"另一个多游戏助手也开着":`另外 ${t.length} 个多游戏助手也开着`}),s.jsx("span",{className:"approval-tool",children:t.map(c=>c.label).join("、")})]})]}),s.jsx("ul",{className:"other-copies-list",children:[...new Set(t.flatMap(c=>c.warnings))].map(c=>s.jsx("li",{children:c},c))}),s.jsx("div",{className:"approval-actions",children:s.jsx("button",{onClick:o,children:"知道了"})})]})}const iM={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function aM(e){const t=je(e.connection.status),r=je(e.capabilities).has("schedule"),[i,o]=b.useState(void 0);return b.useEffect(()=>e.connection.on("schedule/power",o),[e]),b.useEffect(()=>{if(t.state!=="open"||!r){o(void 0);return}let c=!0;return e.connection.call("schedule/power",{}).then(u=>{c&&o(u)}).catch(()=>{}),()=>{c=!1}},[e,t.state,r]),i}function oM({client:e,pending:t}){const n=Cn(1e3),[r,i]=b.useState(!1),[o,c]=b.useState(null),u=iM[t.action],f=async()=>{i(!0),c(null);try{await e.connection.call("schedule/power/cancel",{})}catch(p){c(p instanceof Error?p.message:String(p))}finally{i(!1)}},d=t.at===void 0?void 0:Math.max(0,Math.ceil((t.at-n)/1e3));return s.jsxs("div",{className:"approval-card power-card",role:"alertdialog","aria-label":`即将${u}`,children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"power"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:d===void 0?`其他任务结束后${u}`:`${d} 秒后${u}`}),s.jsxs("span",{className:"approval-tool",children:["「",t.pipelineName,"」设置了结束后",u]})]})]}),t.action==="shutdown"&&d!==void 0&&s.jsx("div",{className:"approval-reason",children:"关机会强制关闭所有程序,没保存的内容会丢失。"}),o!==null&&s.jsx("div",{className:"error small",children:o}),s.jsx("div",{className:"approval-actions",children:s.jsxs("button",{className:"inverse",disabled:r,onClick:()=>void f(),children:["取消",u]})})]})}function kr(){return window.adgDesktop}const N0="adg.update.later";function tw(){var r;const e=(r=kr())==null?void 0:r.updates,[t,n]=b.useState(e===void 0?null:void 0);return b.useEffect(()=>{if(e===void 0)return;let i=!0;e.state().then(c=>{i&&n(c)},()=>{i&&n(null)});const o=e.onChange(c=>{i&&n(c)});return()=>{i=!1,o()}},[e]),{bridge:e,state:t}}function _h(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function nw({bridge:e,state:t,extra:n}){var p;const[r,i]=b.useState(null),[o,c]=b.useState(!1),u=t.latest;if(u===void 0)return null;const f=((p=t.download)==null?void 0:p.version)===u.version?t.download:void 0,d=m=>{i(null),m().catch(g=>i(g instanceof Error?g.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(g)))};return s.jsxs("div",{className:"update-actions",children:[(f==null?void 0:f.state)==="downloading"&&s.jsxs("div",{className:"update-progress",children:[s.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":f.total,"aria-valuenow":f.received,children:s.jsx("span",{style:{width:`${f.total>0?Math.min(100,f.received/f.total*100):0}%`}})}),s.jsxs("small",{className:"muted",children:["正在下载 ",_h(f.received)," / ",_h(f.total)]})]}),(f==null?void 0:f.state)==="ready"&&s.jsx("p",{className:"muted small",children:"安装时程序会退出,正在跑的脚本会被中断;装好后自动重新打开,数据和定时任务都在。"}),(f==null?void 0:f.state)==="failed"&&s.jsx("p",{className:"error small",children:f.error}),r!==null&&s.jsx("p",{className:"error small",children:r}),s.jsxs("div",{className:"update-buttons",children:[n,(f==null?void 0:f.state)==="ready"?s.jsx("button",{className:"primary small-button",disabled:o,onClick:()=>{c(!0),d(()=>e.install().finally(()=>c(!1)))},children:o?"正在启动安装…":"退出并安装"}):s.jsx("button",{className:"primary small-button",disabled:(f==null?void 0:f.state)==="downloading",onClick:()=>d(()=>e.download()),children:(f==null?void 0:f.state)==="failed"?"重新下载":(f==null?void 0:f.state)==="downloading"?"正在下载…":`下载更新(${_h(u.size)})`})]})]})}function lM(){var u;const{bridge:e,state:t}=tw(),[n,r]=b.useState(()=>{try{return sessionStorage.getItem(N0)}catch{return null}}),i=t==null?void 0:t.latest;if(e===void 0||t==null||i===void 0)return null;const o=((u=t.download)==null?void 0:u.version)===i.version&&t.download.state!=="failed";if(!o&&(i.version===t.skipped||i.version===n))return null;const c=()=>{try{sessionStorage.setItem(N0,i.version)}catch{}r(i.version)};return s.jsxs("div",{className:"approval-card update-card",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"download"}),s.jsxs("div",{className:"approval-text",children:[s.jsxs("span",{className:"approval-title",children:["MultiGameAssistant ",i.version," 可以更新了"]}),s.jsxs("span",{className:"approval-tool",children:["当前 ",t.current,i.prerelease?" · 预发布版":""," · ",s.jsx("a",{href:i.notesUrl,target:"_blank",rel:"noreferrer",children:"查看更新内容"})]})]}),!o&&s.jsx("button",{className:"ghost icon-button update-close","aria-label":"稍后提醒",title:"稍后(下次启动再提醒)",onClick:c,children:s.jsx(ee,{name:"close"})})]}),s.jsx(nw,{bridge:e,state:t,extra:!o&&s.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(i.version),children:"跳过这个版本"})})]})}function cM({client:e,sessionId:t,onSelect:n}){var p;const r=je(e.approvals),i=je(e.questions),o=(p=aM(e))==null?void 0:p.pending,c=r.filter(m=>m.sessionId===t),u=i.filter(m=>m.sessionId===t),f=[...r,...i].filter(m=>m.sessionId!==t),d=f.some(m=>"approvalId"in m)?f.some(m=>"questionId"in m)?"审批或回答":"审批":"回答";return s.jsxs("div",{className:"approval-dock",children:[o!==void 0&&s.jsx(oM,{client:e,pending:o}),u.map(m=>s.jsx(dM,{client:e,request:m},m.questionId)),c.map(m=>s.jsx(uM,{client:e,request:m},m.approvalId)),f.length>0&&s.jsxs("button",{className:"approval-elsewhere",onClick:()=>n(f[0].sessionId),children:[s.jsx("span",{className:"approval-dot"}),"另有 ",new Set(f.map(m=>m.sessionId)).size," 个会话在等你",d,s.jsx(ee,{name:"chevron"})]}),s.jsx(rM,{client:e}),s.jsx(lM,{})]})}function uM({client:e,request:t}){var f,d,p;const[n,r]=b.useState(!1),[i,o]=b.useState(null),c=((f=t.displayReason)==null?void 0:f.zh)??((d=t.displayReason)==null?void 0:d["zh-CN"])??((p=t.displayReason)==null?void 0:p.en)??t.reason,u=async m=>{r(!0);try{await e.respondApproval(t.approvalId,m)}catch(g){o(g instanceof Error?g.message:String(g)),r(!1)}};return s.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"shield"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:"需要你的批准"}),s.jsx("code",{className:"approval-tool",children:t.toolName})]})]}),c!==void 0&&s.jsx("div",{className:"approval-reason",children:c}),i!==null&&s.jsx("div",{className:"error small",children:i}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:n,onClick:()=>void u("reject"),children:"拒绝"}),s.jsx("button",{className:"inverse",disabled:n,onClick:()=>void u("allow-once"),children:"允许本次"})]})]})}function dM({client:e,request:t}){var S;const[n,r]=b.useState({}),[i,o]=b.useState(!1),[c,u]=b.useState(null),f=t.questions.length===1&&t.questions[0].multiSelect!==!0&&(((S=t.questions[0].options)==null?void 0:S.length)??0)>0,d=k=>n[k]??{selected:[],custom:""},p=async k=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,k)}catch(w){u(w instanceof Error?w.message:String(w)),o(!1)}},m=(k,w)=>{if(f)return void p([{id:k.id,selected:[w]}]);r(A=>{const N=A[k.id]??{selected:[],custom:""},R=k.multiSelect===!0?N.selected.includes(w)?N.selected.filter(D=>D!==w):[...N.selected,w]:N.selected.includes(w)?[]:[w];return{...A,[k.id]:{...N,selected:R}}})},g=(k,w)=>r(A=>({...A,[k.id]:{...A[k.id]??{selected:[]},custom:w}})),v=()=>t.questions.map(k=>{const{selected:w,custom:A}=d(k.id),N=A.trim();return{id:k.id,selected:N!==""&&k.multiSelect!==!0?[]:w,...N===""?{}:{custom:N}}}),y=t.questions.every(k=>d(k.id).selected.length>0||d(k.id).custom.trim()!=="");return s.jsxs("div",{className:"approval-card question-card",role:"alertdialog","aria-label":"agent 在问你",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(ee,{name:"chat"}),s.jsx("div",{className:"approval-text",children:s.jsx("div",{className:"approval-title",children:"agent 在问你"})})]}),t.questions.map(k=>{var w,A;return s.jsxs("div",{className:"question-item",children:[k.header!==void 0&&s.jsx("span",{className:"question-header",children:k.header}),s.jsx("div",{className:"question-text",children:k.question}),k.detail!==void 0&&s.jsx("div",{className:"question-detail",children:k.detail}),(((w=k.options)==null?void 0:w.length)??0)>0&&s.jsx("div",{className:"question-options",role:k.multiSelect===!0?"group":"radiogroup",children:k.options.map(N=>{const R=d(k.id).selected.includes(N.label);return s.jsxs("button",{className:`question-option${R?" on":""}`,disabled:i,role:k.multiSelect===!0?"checkbox":"radio","aria-checked":R,onClick:()=>m(k,N.label),children:[s.jsx("span",{className:"question-option-label",children:N.label}),N.description!==void 0&&s.jsx("span",{className:"question-option-desc",children:N.description})]},N.label)})}),s.jsx("input",{className:"text-input question-custom",value:d(k.id).custom,disabled:i,placeholder:(((A=k.options)==null?void 0:A.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:N=>g(k,N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&y&&p(v())}})]},k.id)}),c!==null&&s.jsx("div",{className:"error small",children:c}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:i,onClick:()=>void p(t.questions.map(k=>({id:k.id,selected:[]}))),children:"跳过"}),s.jsx("button",{className:"inverse",disabled:i||!y,onClick:()=>void p(v()),children:"回答"})]})]})}const xr="main",fM={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},br={id:xr,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function ac(e){return{id:e.id,name:e.name,description:e.description,icon:fM[e.id]??"sparkles"}}function fi(e){const t=je(e.connection.status),[n,r]=b.useState([]);return b.useEffect(()=>{if(t.state!=="open")return;let i=!0;return e.connection.call("roles/list",{}).then(o=>{i&&r(o.items)}).catch(()=>{}),()=>{i=!1}},[e,t.state]),b.useEffect(()=>e.connection.on("roles/changed",i=>r(i.items)),[e]),n}function _a(e,t){return e.role!==void 0&&t.some(n=>n.id===e.role)?e.role:xr}function hM(e){return e==="你"?"你布置的":`来自${e}`}function pM(e,t){const n=je(e.connection.status),[r,i]=b.useState(new Map),o=b.useRef(new Map),c=f=>`${f.updatedAt}${f.running?"+":""}`,u=t.map(f=>`${f.id}@${c(f)}`).join(",");return b.useEffect(()=>{if(n.state!=="open")return;const f=t.filter(d=>o.current.get(d.id)!==c(d)).slice(0,60);if(f.length!==0){for(const d of f)o.current.set(d.id,c(d));e.connection.call("sessions/lastReplies",{sessionIds:f.map(d=>d.id)}).then(d=>{i(p=>{const m=new Map(p);for(const g of d.items)m.set(g.sessionId,g.text);return m})}).catch(()=>{for(const d of f)o.current.delete(d.id)})}},[e,n.state,u]),r}const sw="adg.agentSeen";function mM(){try{const e=JSON.parse(localStorage.getItem(sw)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function gM(){const[e,t]=b.useState(mM);return{seen:e,markSeen:(r,i)=>{t(o=>{if((o[r]??0)>=i)return o;const c={...o,[r]:i};try{localStorage.setItem(sw,JSON.stringify(c))}catch{}return c})}}}function rw(e,t){const n=je(e.connection.status),[r,i]=b.useState({agentId:t,sessionId:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("agents/home",{agentId:t}).then(c=>{o&&i({agentId:t,sessionId:c.sessionId,error:null})},c=>{o&&i({agentId:t,sessionId:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),r.agentId===t?r:{sessionId:null,error:null}}function xM(e,t){const n=je(e.connection.status),r=je(e.capabilities),[i,o]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open"||!r.has("agents"))return;let c=!0;return e.connection.call("handoffs/list",{sessionId:t}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t,n.state,r]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:c})=>{c.fromSession!==t&&c.toSession!==t||o(u=>[...u.filter(f=>f.id!==c.id),c])}),[e,t]),i}const vM={feishu:"飞书"},Eh=30;function iw(e){const t=je(e.connection.status),n=je(e.capabilities),[r,i]=b.useState(new Set),o=n.has("archive");return b.useEffect(()=>{if(t.state!=="open"||!o)return;let c=!0;return e.connection.call("sessions/archived",{}).then(u=>{c&&i(new Set(u.sessionIds))}).catch(()=>{}),()=>{c=!1}},[e,t.state,o]),b.useEffect(()=>e.connection.on("sessions/archived",c=>i(new Set(c.sessionIds))),[e]),r}function yM(e,t){const n=je(e.sessions),r=je(e.approvals),i=je(e.questions),o=fi(e),c=iw(e),{seen:u,markSeen:f}=gM(),d=b.useMemo(()=>[br,...o.map(ac)],[o]),p=b.useMemo(()=>{var v;const g=new Map(d.map(y=>[y.id,[]]));for(const y of n.items)y.origin==="subagent"||y.blank||c.has(y.id)||(v=g.get(_a(y,o)))==null||v.push(y);for(const y of g.values())y.sort((S,k)=>k.updatedAt-S.updatedAt);return g},[n.items,c,d,o]);b.useEffect(()=>{var g,v;if(n.loaded)for(const y of d){const S=(v=(g=p.get(y.id))==null?void 0:g[0])==null?void 0:v.updatedAt;S!==void 0&&(y.id===t||u[y.id]===void 0)&&f(y.id,S)}},[n.loaded,p,t]);const m=g=>{const v=n.items.find(y=>y.id===g);return v===void 0?void 0:_a(v,o)};return d.map(g=>{const v=p.get(g.id)??[],y=v[0];return{agent:g,running:v.filter(S=>S.running).length,unread:g.id!==t&&y!==void 0&&y.updatedAt>(u[g.id]??1/0),waiting:[...r,...i].filter(S=>m(S.sessionId)===g.id).length}})}function bM(e,t){const n=je(e.sessions),r=fi(e);return n.items.some(i=>i.origin!=="subagent"&&!i.blank&&i.home!==t&&_a(i,r)===t)}function kM({client:e,agentId:t,onSelect:n}){const r=je(e.sessions),i=je(e.connection.status),o=je(e.capabilities),c=fi(e),u=iw(e),f=Cn(3e4),[d,p]=b.useState(null),[m,g]=b.useState(""),[v,y]=b.useState(!1),[S,k]=b.useState(!1),[w,A]=b.useState(new Map),[N,R]=b.useState(0),D=o.has("archive");b.useEffect(()=>e.connection.on("notify/changed",()=>R($=>$+1)),[e]),b.useEffect(()=>{if(i.state!=="open"||!o.has("notify"))return;let $=!0;return e.connection.call("notify/conversations",{}).then(L=>{$&&A(new Map(L.items.map(B=>[B.sessionId,{channel:B.channel,user:B.user}])))}).catch(()=>{}),()=>{$=!1}},[e,i.state,o,N]);const P=$=>{const L=w.get($.id);return L!==void 0?vM[L.channel]??L.channel:/^(飞书|feishu):/.test($.title??"")?"飞书":void 0},F=m.trim().toLowerCase(),{earlier:W,archivedItems:M}=b.useMemo(()=>{const $=r.items.filter(L=>L.origin!=="subagent"&&!L.blank&&L.home!==t&&_a(L,c)===t&&(F===""||ao(L).toLowerCase().includes(F))).sort((L,B)=>B.updatedAt-L.updatedAt);return{earlier:$.filter(L=>!u.has(L.id)),archivedItems:$.filter(L=>u.has(L.id))}},[r.items,t,c,u,F]),[O,T]=b.useState(null),Z=async()=>{const $=O;T(null);const L=($==null?void 0:$.value.trim())??"",B=r.items.find(H=>H.id===($==null?void 0:$.id));$===null||B===void 0||L===""||L===ao(B)||await e.renameSession($.id,L).catch(H=>p(H instanceof Error?H.message:String(H)))},E=async($,L)=>{p(null),await e.connection.call(L?"sessions/archive":"sessions/unarchive",{sessionId:$}).catch(B=>p(B instanceof Error?B.message:String(B)))},C=$=>{const L=P($),B=u.has($.id);return s.jsxs("div",{className:"session-row",children:[(O==null?void 0:O.id)===$.id?s.jsx("input",{className:"text-input session-rename",autoFocus:!0,value:O.value,maxLength:80,"aria-label":"会话名称",onFocus:H=>H.target.select(),onChange:H=>T({id:$.id,value:H.target.value}),onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing&&Z(),H.key==="Escape"&&T(null)},onBlur:()=>void Z()}):s.jsxs("button",{className:"nav-item session-item",onClick:()=>n($.id),onDoubleClick:()=>T({id:$.id,value:ao($)}),title:"双击改名",children:[L!==void 0&&s.jsx("span",{className:"channel-badge",children:L}),s.jsx("span",{className:"nav-item-label",children:L!==void 0?ao($).replace(/^(飞书|feishu):/,""):ao($)}),$.running?s.jsx("span",{className:"run-dot",role:"img","aria-label":"运行中"}):s.jsx("span",{className:"session-time",children:Tt($.updatedAt,f)})]}),(O==null?void 0:O.id)!==$.id&&s.jsxs("span",{className:"session-row-actions",children:[s.jsx("button",{className:"session-action",title:"改名","aria-label":"改名",onClick:()=>T({id:$.id,value:ao($)}),children:s.jsx(ee,{name:"pencil"})}),D&&!$.running&&s.jsx("button",{className:"session-action",title:B?"恢复":"归档:从列表里移走,之后可以在「已归档」里找回","aria-label":B?"恢复":"归档",onClick:()=>void E($.id,!B),children:s.jsx(ee,{name:B?"back":"archive"})})]})]},$.id)};return s.jsx("section",{className:"main history-page",children:s.jsxs("div",{className:"history-body",children:[s.jsxs("label",{className:"sidebar-search",children:[s.jsx(ee,{name:"search"}),s.jsx("input",{"aria-label":"搜索以前的对话",placeholder:"搜索以前的对话",value:m,onChange:$=>g($.target.value),onKeyDown:$=>{$.key==="Escape"&&g("")}})]}),d!==null&&s.jsx("div",{className:"error small",children:d}),s.jsxs("nav",{className:"session-list","aria-label":"以前的对话",children:[!r.loaded&&i.state==="open"&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),r.loaded&&W.length===0&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(ee,{name:F===""?"chat":"search"}),s.jsx("span",{children:F===""?"没有以前的对话":"没有匹配的对话"})]}),(S?W:W.slice(0,Eh)).map(C),!S&&W.length>Eh&&s.jsxs("button",{className:"nav-item more-sessions",onClick:()=>k(!0),children:["更多(",W.length-Eh,")"]}),D&&M.length>0&&s.jsxs("div",{className:"archive-entry",children:[s.jsxs("button",{className:"nav-item role-row",onClick:()=>y($=>!$),"aria-expanded":v,children:[s.jsx(ee,{name:"archive"}),s.jsx("span",{className:"nav-item-label",children:"已归档"}),s.jsx("span",{className:"tab-count",children:M.length}),s.jsx(ee,{name:v?"chevron-down":"chevron",className:"role-chevron"})]}),v&&M.map(C)]})]})]})})}function ao(e){return e.title??(e.blank?"新会话":"未命名会话")}function Tt(e,t){const n=Math.max(0,Math.round((t-e)/1e3));return n<60?"刚刚":n<3600?`${Math.floor(n/60)} 分钟前`:n<86400?`${Math.floor(n/3600)} 小时前`:n<86400*7?`${Math.floor(n/86400)} 天前`:new Date(e).toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}function wM({client:e,pages:t,current:n,onAgent:r,onPage:i,onSchedule:o,onSettings:c}){const u=je(e.connection.status),f=je(e.capabilities),d=yM(e,n.kind==="agent"?n.id:void 0),p=m=>s.jsx(Ch,{icon:m.icon,label:m.title,active:n.kind==="page"&&n.id===m.id,onClick:()=>i(m.id)},m.id);return s.jsxs("nav",{className:"rail","aria-label":"功能区",children:[s.jsx("button",{className:"rail-brand",onClick:()=>{var m;return r(((m=d[0])==null?void 0:m.agent.id)??"")},title:"MultiGameAssistant",children:s.jsx(xd,{})}),s.jsxs("div",{className:"rail-items",children:[t.filter(m=>m.order<0).map(p),s.jsx("span",{className:"rail-divider",role:"separator"}),d.map(m=>s.jsx(NM,{state:m,active:n.kind==="agent"&&n.id===m.agent.id,onClick:()=>r(m.agent.id)},m.agent.id)),t.filter(m=>m.order>=0).map(p)]}),s.jsxs("div",{className:"rail-footer",children:[f.has("pipelines")&&s.jsx(Ch,{icon:"calendar",label:"定时",title:"每个 agent 的定时任务,和按时运行的流水线",active:n.kind==="schedule",onClick:o}),s.jsx(Ch,{icon:"settings",label:"设置",active:n.kind==="settings",onClick:c}),s.jsxs("span",{className:`rail-connection ${u.state}`,role:"status",title:j0(u.state,u.attempt,u.error),children:[s.jsx("span",{className:"conn-dot"}),s.jsx("span",{className:"sr-only",children:j0(u.state,u.attempt,u.error)})]})]})]})}function NM({state:e,active:t,onClick:n}){const{agent:r,running:i,unread:o,waiting:c}=e;return s.jsxs("button",{className:`rail-item rail-agent ${t?"active":""}`,"aria-current":t?"page":void 0,onClick:n,title:`${r.name}:${r.description}${i>0?`(进行中${i>1?` ${i}`:""})`:""}`,children:[s.jsxs("span",{className:`agent-avatar rail-avatar agent-${r.id}`,children:[s.jsx(ee,{name:r.icon}),i>0&&s.jsx("span",{className:"agent-busy",role:"img","aria-label":`${i} 个正在运行`})]}),s.jsx("span",{className:`rail-label ${o?"unread":""}`,children:r.name}),c>0?s.jsx("span",{className:"rail-badge","aria-label":`${c} 个等你处理`,children:c}):o&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新结果"})]})}function Ch({icon:e,label:t,title:n=t,active:r,onClick:i,disabled:o=!1}){return s.jsxs("button",{className:`rail-item ${r?"active":""}`,"aria-current":r?"page":void 0,onClick:i,title:n,disabled:o,children:[s.jsx(ee,{name:e}),s.jsx("span",{className:"rail-label",children:t})]})}function j0(e,t,n){const r=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return n===void 0?r:`${r}:${n}`}const Pp="adg.token",Im=/^\/adg(\/|$)/.test(location.pathname);function jM(){var e;for(const t of[window,window.parent])try{const n=(e=t.__DSH_TRANSPORT__)==null?void 0:e.streamBaseUrl;if(typeof n=="string"&&n!=="")return n}catch{}}function aw(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(Pp,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}try{return sessionStorage.getItem(Pp)}catch{return null}}function SM(e){try{sessionStorage.setItem(Pp,e)}catch{}}function _M(e){if(Im){const n=new URL(jM()??location.origin);return`${n.protocol==="https:"?"wss":"ws"}://${n.host}/adg/rpc`}return`${location.protocol==="https:"?"wss":"ws"}://${location.host}/rpc?token=${encodeURIComponent(e??"")}`}function S0(){if(location.hash==="#/settings")return{kind:"settings"};const e=/^#\/settings\/(.+)$/.exec(location.hash);if(e!==null)return{kind:"settings",section:decodeURIComponent(e[1])};const t=/^#\/w\/([^/]+)\/(.+)$/.exec(location.hash);if(t!==null)return{kind:"window",view:decodeURIComponent(t[1]),sessionId:decodeURIComponent(t[2])};const n=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(n!==null)return{kind:"page",id:decodeURIComponent(n[1]),...n[2]===void 0?{}:{arg:decodeURIComponent(n[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const r=/^#\/h\/(.+)$/.exec(location.hash);if(r!==null)return{kind:"handoff",id:decodeURIComponent(r[1])};const i=/^#\/a\/(.+)\/(schedule|history)$/.exec(location.hash);if(i!==null)return{kind:"agent",id:decodeURIComponent(i[1]),tab:i[2]};const o=/^#\/a\/(.+)$/.exec(location.hash);if(o!==null)return{kind:"agent",id:decodeURIComponent(o[1])};const c=/^#\/s\/(.+)$/.exec(location.hash);return c===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(c[1])}}function EM(e,t="push"){const n=e.kind==="window"?`#/w/${encodeURIComponent(e.view)}/${encodeURIComponent(e.sessionId)}`:e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.tab===void 0?"":`/${e.tab}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?"#/schedule":e.kind==="page"?`#/p/${encodeURIComponent(e.id)}${e.arg===void 0?"":`/${encodeURIComponent(e.arg)}`}`:e.kind==="settings"?e.section===void 0?"#/settings":`#/settings/${encodeURIComponent(e.section)}`:e.kind==="home"?"#/chat":"";if(location.hash===n)return;const r=`${location.pathname}${location.search}${n}`;t==="replace"?history.replaceState(history.state,"",r):history.pushState(null,"",r)}function CM(e,t){const n=new URL(location.href),r=aw();return r!==null&&n.searchParams.set("token",r),n.hash=`#/w/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n.href}const Vu="adg.draft.",_0=60,Lp=new Map;function IM(e){try{const t=localStorage.getItem(Vu+e);if(t===null)return"";const n=JSON.parse(t);return typeof n.text=="string"?n.text:""}catch{return""}}function AM(e,t){try{if(t.trim()===""){localStorage.removeItem(Vu+e);return}localStorage.setItem(Vu+e,JSON.stringify({text:t,at:Date.now()})),MM()}catch{}}function TM(e){return Lp.get(e)??[]}function $M(e,t){t.length===0?Lp.delete(e):Lp.set(e,[...t])}function MM(){const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!(n===null||!n.startsWith(Vu)))try{e.push({key:n,at:Number(JSON.parse(localStorage.getItem(n)??"{}").at)||0})}catch{e.push({key:n,at:0})}}if(!(e.length<=_0))for(const t of e.sort((n,r)=>n.at-r.at).slice(0,e.length-_0))localStorage.removeItem(t.key)}const RM={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},E0=(e,t)=>RM[e]??(t!==void 0&&t!==e?t:e);function ow(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function OM(e,t){var n;if(!(e===null||t===null))return(n=e.groups.find(r=>r.id===t.provider))==null?void 0:n.models.find(r=>r.id===t.model)}function zM({client:e,sessionId:t,disabled:n,value:r,onChange:i}){var Z;const{catalog:o,error:c}=Fo(e),u=je(e.sessionModels),f=je(e.connection.status),[d,p]=b.useState(!1),[m,g]=b.useState(null),[v,y]=b.useState(!1),[S,k]=b.useState(""),w=b.useRef(null);b.useEffect(()=>{f.state!=="open"||t===void 0||e.sessionModel(t).catch(()=>{})},[e,t,f.state]),b.useEffect(()=>{if(!v)return;const E=$=>{w.current!==null&&!w.current.contains($.target)&&y(!1)},C=$=>{$.key==="Escape"&&y(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",C)}},[v]);const A=t===void 0?void 0:u.get(t),N=t===void 0?r??(o==null?void 0:o.default)??null:ow(o,A),R=OM(o,N),D=N!==null&&o!==null&&R===void 0,P=async E=>{if(g(null),t===void 0){i==null||i(E);return}p(!0);try{await e.selectModel(t,E)}catch(C){g(C instanceof Error?C.message:String(C))}finally{p(!1)}},F=(E,C)=>{const $=(N==null?void 0:N.reasoningEffort)!==void 0&&C.efforts.some(L=>L.id===N.reasoningEffort)?N.reasoningEffort:C.defaultEffort;P({provider:E,model:C.id,...$===void 0?{}:{reasoningEffort:$}}),C.efforts.length===0&&y(!1)},W=b.useMemo(()=>{const E=S.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(C=>({...C,models:C.models.filter($=>E===""||$.id.toLowerCase().includes(E)||$.name.toLowerCase().includes(E)||C.name.toLowerCase().includes(E))})).filter(C=>C.models.length>0)},[o,S]),M=[m,c,...(o==null?void 0:o.failures.map(E=>`${E.name}:${E.message}`))??[]].filter(Boolean);if(o===null)return null;const O=(N==null?void 0:N.reasoningEffort)??(R==null?void 0:R.defaultEffort),T=(Z=R==null?void 0:R.efforts.find(E=>E.id===O))==null?void 0:Z.name;return s.jsxs("div",{className:`model-picker${m!==null?" has-error":""}`,ref:w,children:[s.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":v,disabled:n||d,title:M.length>0?M.join(`
124
- `):"选择模型和思考强度",onClick:()=>y(E=>!E),children:[s.jsx("span",{className:`model-dot ${D?"off":""}`}),s.jsx("span",{className:"model-name",children:(R==null?void 0:R.name)??(N===null?"选择模型":`${N.model}(不可用)`)}),O!==void 0&&R!==void 0&&R.efforts.length>0&&s.jsx("span",{className:"model-effort",children:E0(O,T)}),s.jsx(ee,{name:"chevron-down"})]}),v&&s.jsxs("div",{className:"model-panel",role:"dialog","aria-label":"选择模型",children:[s.jsx("input",{className:"text-input plain model-search",autoFocus:!0,placeholder:"搜索模型",value:S,onChange:E=>k(E.target.value)}),s.jsxs("div",{className:"model-list",role:"listbox","aria-label":"模型",children:[W.length===0&&s.jsx("div",{className:"muted small pad",children:"没有匹配的模型"}),W.map(E=>s.jsxs("div",{className:"model-group",children:[s.jsx("div",{className:"model-group-name",children:E.name}),E.models.map(C=>{const $=(N==null?void 0:N.provider)===E.id&&N.model===C.id;return s.jsxs("button",{type:"button",role:"option","aria-selected":$,className:`model-option ${$?"active":""}`,onClick:()=>F(E.id,C),children:[s.jsxs("span",{className:"model-option-main",children:[s.jsx("span",{children:C.name}),C.name!==C.id&&s.jsx("span",{className:"muted small",children:C.id})]}),C.efforts.length>0&&s.jsx("span",{className:"model-tag",children:"思考"}),$&&s.jsx(ee,{name:"check"})]},C.id)})]},E.id))]}),R!==void 0&&N!==null&&s.jsxs("div",{className:"model-efforts",children:[s.jsx("span",{className:"field-label",children:"思考强度"}),R.efforts.length===0?s.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:R.efforts.map(E=>s.jsx("button",{type:"button",role:"radio","aria-checked":O===E.id,className:O===E.id?"active":"",onClick:()=>void P({provider:N.provider,model:N.model,reasoningEffort:E.id}),children:E0(E.id,E.name)},E.id))})]}),M.length>0&&s.jsx("div",{className:"error small model-problems",children:M.join(";")})]})]})}function lw(e,t){return t.find(n=>n.scripts.includes(e.packId??e.id)||n.scripts.includes(e.id))}function Dp(e,t){const n=e.toLowerCase();return t.find(r=>[r.id,r.name,...r.aliases].some(i=>i.toLowerCase()===n))}function Fp(e,t,n){const r=[];for(const i of new Set((e==null?void 0:e.scripts)??[])){const o=t.find(u=>u.id===i||u.packId===i),c=o===void 0?n.find(u=>u.scripts.includes(i)):lw(o,n);r.push({script:o===void 0?{id:i,name:i}:{id:o.id,name:o.name},...c===void 0?{}:{game:{id:c.id,name:c.name}}})}if(r.length===0)for(const i of new Set((e==null?void 0:e.games)??[])){const o=Dp(i,n);r.push({game:o===void 0?{id:i,name:i}:{id:o.id,name:o.name}})}return r}function cw(e){var t,n;return[(t=e.game)==null?void 0:t.name,(n=e.script)==null?void 0:n.name].filter(r=>r!==void 0).join(" · ")}let Ih=[];function PM(e){const t=je(e.capabilities),n=t.has("skills"),r=t.has("scripts"),i=t.has("games"),[o,c]=b.useState(Ih),[u,f]=b.useState(0);return b.useEffect(()=>e.connection.on("skills/changed",()=>f(d=>d+1)),[e]),b.useEffect(()=>{if(!n)return;let d=!0;const p=r?e.connection.call("scripts/list",{}).then(g=>g.scripts,()=>[]):Promise.resolve([]),m=i?e.connection.call("games/list",{}).then(g=>g.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),p,m]).then(([g,v,y])=>{Ih=g.skills.filter(S=>S.userInvocable).map(S=>{const k=[...new Set(Fp(S.owner,v,y).map(cw))].join("、");return{name:S.name,description:S.description,...k===""?{}:{group:k}}}),d&&c(Ih)},()=>{}),()=>{d=!1}},[e,n,r,i,u]),o}const Ah=e=>e.kind==="command"?"命令":e.group??"通用技能";function uw({client:e,text:t,setText:n,area:r,submit:i,placement:o="above",inSession:c=!1}){const u=PM(e),[f,d]=b.useState(0),[p,m]=b.useState(!1),g=p?[]:C$(t,u,c),v=t.split(/\s/)[0];b.useEffect(()=>{d(0),m(!1)},[v]);const y=Math.min(f,Math.max(0,g.length-1)),S=N=>{var R;n(`/${N.name} `),m(!0),(R=r.current)==null||R.focus()},k=N=>{var R;if(i!==void 0&&N.kind==="command"&&N.arg===void 0){n(""),i(`/${N.name}`),(R=r.current)==null||R.focus();return}S(N)},w=N=>{if(g.length===0||N.nativeEvent.isComposing)return!1;if(N.key==="ArrowDown"||N.key==="ArrowUp")return N.preventDefault(),d((y+(N.key==="ArrowDown"?1:g.length-1))%g.length),!0;if(N.key==="Tab"||N.key==="Enter"&&!N.shiftKey){N.preventDefault();const R=g[y];return N.key==="Tab"?S(R):k(R),!0}return N.key==="Escape"?(N.preventDefault(),m(!0),!0):!1};return{menu:g.length===0?null:s.jsx(LM,{options:g,active:y,placement:o,onHover:d,onChoose:k}),onKeyDown:w,expand:N=>_$(N,u)}}function LM({options:e,active:t,placement:n,onHover:r,onChoose:i}){const o=b.useRef(null),[c,u]=b.useState(0);b.useLayoutEffect(()=>{var p;const d=(p=o.current)==null?void 0:p.querySelector(`[data-index="${t}"]`);d==null||o.current===null||(d.scrollIntoView({block:"nearest"}),u(d.offsetTop-o.current.scrollTop))},[t,e]);const f=e[t];return s.jsxs("div",{className:`slash-pop ${n}`,children:[s.jsx("div",{ref:o,className:"slash-list",role:"listbox","aria-label":"命令和技能",onScroll:()=>{var p;const d=(p=o.current)==null?void 0:p.querySelector(`[data-index="${t}"]`);d!=null&&o.current!==null&&u(d.offsetTop-o.current.scrollTop)},children:e.map((d,p)=>s.jsxs("div",{children:[(p===0||Ah(e[p-1])!==Ah(d))&&s.jsx("div",{className:"slash-group",children:Ah(d)}),s.jsx("button",{type:"button",role:"option","data-index":p,"aria-selected":p===t,className:`slash-item ${p===t?"active":""}`,onMouseEnter:()=>r(p),onMouseDown:m=>m.preventDefault(),onClick:()=>i(d),children:d.name})]},`${d.kind}:${d.name}`))}),f!==void 0&&s.jsxs("div",{className:"slash-tip",style:{top:c},role:"tooltip",children:[f.kind==="skill"&&s.jsx("span",{className:"slash-tip-kind",children:f.group===void 0?"技能":`${f.group} 的技能`}),f.description,f.kind==="command"&&f.arg!==void 0&&s.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",f.arg]}),f.kind==="skill"&&s.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const Bp=5.5,C0=2*Math.PI*Bp,I0=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function Th(e){return e>=1e6?`${A0(e/1e6)}M`:e>=1e3?`${A0(e/1e3)}k`:String(Math.round(e))}const A0=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function DM({context:e}){const[t,n]=b.useState(!1),r=b.useRef(null);if(b.useEffect(()=>{if(!t)return;const p=g=>{var v;(v=r.current)!=null&&v.contains(g.target)||n(!1)},m=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",m)}},[t]),e===null)return null;const i=Math.min(100,Math.round(e.usedTokens/e.contextWindow*100)),o=i>=90?"high":i>=70?"raised":"normal",c=e.breakdown,u=c===void 0?0:c.systemTokens+c.toolsTokens+c.messageTokens,f=c===void 0||u===0?[{key:"total",tone:"messages",width:i}]:I0.map(p=>({key:p.key,tone:p.tone,width:i*c[p.key]/u})).filter(p=>p.width>0),d=`上下文已用 ${i}%`;return s.jsxs("span",{ref:r,className:`context-meter ${o}`,children:[s.jsxs("button",{type:"button",className:"context-trigger",title:d,"aria-label":d,"aria-haspopup":"dialog","aria-expanded":t,onClick:()=>n(!t),children:[s.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[s.jsx("circle",{className:"context-track",cx:"7",cy:"7",r:Bp}),s.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Bp,strokeDasharray:`${C0*i/100} ${C0}`,transform:"rotate(-90 7 7)"})]}),s.jsxs("span",{children:[i,"%"]})]}),t&&s.jsxs("div",{className:"context-panel",role:"dialog","aria-label":"上下文用量",children:[s.jsxs("div",{className:"context-head",children:[s.jsxs("span",{children:["上下文已用 ",s.jsxs("strong",{children:[i,"%"]})]}),s.jsxs("span",{className:"context-figures",children:["~",Th(e.usedTokens)," / ",Th(e.contextWindow)]})]}),s.jsx("div",{className:"context-bar",children:f.map(p=>s.jsx("span",{className:`context-segment ${p.tone}`,style:{width:`${p.width}%`}},p.key))}),c!==void 0&&s.jsx("dl",{className:"context-rows",children:I0.map(p=>s.jsxs("div",{children:[s.jsxs("dt",{children:[s.jsx("span",{className:`context-swatch ${p.tone}`,"aria-hidden":"true"}),p.label]}),s.jsxs("dd",{children:["~",Th(c[p.key])]})]},p.key))}),s.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",s.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const FM=6e4,BM={CNY:"¥",USD:"$"},Ou=(e,t)=>{const n=BM[e];return n===void 0?`${t} ${e}`:`${n}${t}`};function UM({balances:e}){const t=e.filter(n=>Number(n.total)!==0);return(t.length>0?t:e.slice(0,1)).map(n=>Ou(n.currency,n.total)).join(" / ")}function HM(e){return`DeepSeek 账户余额 ${e.balances.map(n=>`${Ou(n.currency,n.total)}(充值 ${Ou(n.currency,n.toppedUp)},赠送 ${Ou(n.currency,n.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function ZM({client:e,sessionId:t,running:n}){var m;const{catalog:r}=Fo(e),i=je(e.sessionModels).get(t),o=((m=ow(r,i))==null?void 0:m.provider)??null,c=je(e.credentialRevision),u=je(e.connection.status),f=je(e.capabilities),[d,p]=b.useState(null);return b.useEffect(()=>{if(o===null||u.state!=="open"||!f.has("providers"))return;let g=!0;const v=()=>e.providerBalance(o).then(S=>{g&&p({provider:o,balance:S,error:null})},S=>{g&&p({provider:o,balance:null,error:S instanceof Error?S.message:String(S)})});v();const y=n?setInterval(()=>void v(),FM):void 0;return()=>{g=!1,clearInterval(y)}},[e,o,c,u.state,f,n]),d===null||d.provider!==o?null:d.error!==null?s.jsx("span",{className:"balance-chip failed",title:d.error,children:"余额 ?"}):d.balance===null||d.balance.balances.length===0?null:s.jsx("span",{className:`balance-chip ${d.balance.available?"":"low"}`,title:HM(d.balance),children:UM(d.balance)})}function WM({client:e,session:t,running:n,disabled:r,initialPrompt:i,onInitialSent:o}){const c=je(e.capabilities),{queue:u,context:f}=je(t.state),[d,p]=b.useState(()=>IM(t.id)),[m,g]=b.useState(!1),[v,y]=b.useState(null),[S,k]=b.useState(null),w=b.useRef(null),A=b.useRef(null),N=b.useRef(!1),[R,D]=b.useState(()=>TM(t.id));b.useEffect(()=>AM(t.id,d),[t.id,d]),b.useEffect(()=>$M(t.id,R),[t.id,R]);const P=eM(e),[F,W]=b.useState(!1),M=async H=>{const G=H.filter(V=>V.type.startsWith("image/"));if(G.length===0)return;y(null);const K=gl-R.length;if(K<=0){y(`一条消息最多 ${gl} 张图片`);return}try{const V=await Promise.all(G.slice(0,K).map(GM));D(Y=>[...Y,...V].slice(0,gl)),G.length>K&&y(`一条消息最多 ${gl} 张图片,多的没有加上`)}catch(V){y(`图片没能加上:${V instanceof Error?V.message:String(V)}`)}},O=H=>{const G=[...H.clipboardData.items].filter(K=>K.kind==="file"&&K.type.startsWith("image/")).map(K=>K.getAsFile()).filter(K=>K!==null);G.length!==0&&(H.preventDefault(),M(G))},T=H=>{W(!1),H.dataTransfer.files.length!==0&&(H.preventDefault(),M([...H.dataTransfer.files]))};b.useEffect(()=>{var H;i===void 0||N.current||r||(N.current=!0,t.prompt(i,"queue").catch(G=>y(G instanceof Error?G.message:String(G))),o==null||o(),(H=w.current)==null||H.focus())},[i,r,t,o]);const Z=H=>j$(H)!=="compact"?!1:(p(""),y(null),n?(y("agent 正在工作,等它停下再压缩"),!0):(window.confirm(VM)&&(k("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(G=>k(G.message),G=>{k(null),y(G instanceof Error?G.message:String(G))})),!0)),E=uw({client:e,text:d,setText:p,area:w,inSession:!0,submit:H=>{r||Z(H)||(y(null),t.prompt(E.expand(H),n&&m?"steer":"queue").catch(G=>y(G instanceof Error?G.message:String(G))))}}),C=()=>{var K;if(!r&&R.length===0&&Z(d))return;const H=E.expand(d);if(H===""&&R.length===0||r)return;const G=R.map(({url:V,...Y})=>Y);p(""),D([]),y(null),t.prompt(H,n&&m?"steer":"queue",G).catch(V=>y(V instanceof Error?V.message:String(V))),(K=w.current)==null||K.focus()},$=H=>{E.onKeyDown(H)||H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),C())},L=H=>{t.updateQueue(H.id,"remove").then(()=>{d.trim()===""&&H.text!==""&&p(H.text)},G=>y(G instanceof Error?G.message:String(G)))},B=H=>{t.updateQueue(H.id,"steer").catch(G=>y(G instanceof Error?G.message:String(G)))};return s.jsxs("div",{className:"composer",children:[v!==null&&s.jsx("div",{className:"error small composer-error",children:v}),S!==null&&s.jsxs("div",{className:"composer-note small",role:"status",children:[s.jsx("span",{children:S}),s.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>k(null),children:"知道了"})]}),u.length>0&&s.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:u.map(H=>s.jsxs("div",{className:"queue-item",children:[s.jsx("span",{className:`queue-tag ${H.placement}`,children:H.placement==="next-step"?"插入中":"排队中"}),s.jsxs("span",{className:"queue-text",title:H.text,children:[H.text===""?"(图片)":H.text,H.images!==void 0&&s.jsxs("span",{className:"muted",children:[" · ",H.images," 张图片"]})]}),s.jsx("span",{className:"queue-when muted",children:H.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),H.placement==="next-turn"&&n&&s.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>B(H),children:"现在插入"}),s.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>L(H),children:"撤回"})]},H.id))}),s.jsxs("div",{className:"slash-anchor",children:[E.menu,s.jsxs("div",{className:`composer-box ${F?"dragging":""}`,onDragOver:H=>{[...H.dataTransfer.items].some(G=>G.kind==="file")&&(H.preventDefault(),W(!0))},onDragLeave:()=>W(!1),onDrop:T,children:[R.length>0&&s.jsx("div",{className:"composer-images",children:R.map((H,G)=>s.jsxs("span",{className:"composer-image",children:[s.jsx("img",{src:H.url,alt:H.name??`图片 ${G+1}`}),s.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>D(K=>K.filter((V,Y)=>Y!==G)),children:"✕"})]},G))}),s.jsx("textarea",{onPaste:O,ref:w,"aria-label":"消息内容",value:d,onChange:H=>p(H.target.value),onKeyDown:$,rows:Math.min(8,Math.max(2,d.split(`
125
- `).length)),placeholder:r?"未连接到 agent":n?"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:r}),s.jsxs("div",{className:"composer-actions",children:[c.has("models")&&s.jsx(zM,{client:e,sessionId:t.id,disabled:r}),s.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:r||R.length>=gl,onClick:()=>{var H;return(H=A.current)==null?void 0:H.click()},children:s.jsx(ee,{name:"image"})}),s.jsx("input",{ref:A,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:H=>{M([...H.target.files??[]]),H.target.value=""}}),P==="full"&&s.jsxs("button",{type:"button",className:"full-access-chip",title:"agent 做事不再请求确认,点这里修改",onClick:()=>{location.hash="#/settings/permissions"},children:[s.jsx(ee,{name:"alert"}),"完全访问"]}),s.jsx("span",{className:"spacer"}),s.jsx(ZM,{client:e,sessionId:t.id,running:n}),s.jsx(DM,{context:f}),n&&s.jsxs("label",{className:"steer-toggle",title:"把消息插入正在进行的轮次,而不是等下一轮",children:[s.jsx("input",{type:"checkbox",checked:m,onChange:H=>g(H.target.checked)}),"插入当前轮次"]}),n&&s.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(H=>y(String(H))),disabled:r,children:[s.jsx(nM,{}),"停止"]}),s.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:C,disabled:r||d.trim()===""&&R.length===0,children:s.jsx(ee,{name:"arrow"})})]})]})]}),s.jsxs("div",{className:"composer-hint",children:[s.jsxs("span",{children:[s.jsx("kbd",{children:"/"})," 命令和技能"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Enter"})," 发送"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Shift+Enter"})," 换行"]}),s.jsxs("span",{children:[s.jsx("kbd",{children:"Ctrl+V"})," 粘贴图片"]})]})]})}const VM=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。确定压缩吗?"].join(`
126
- `),gl=4,qM=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function GM(e){const t=await new Promise((o,c)=>{const u=new FileReader;u.onload=()=>o(String(u.result)),u.onerror=()=>c(u.error??new Error("读取失败")),u.readAsDataURL(e)}),n=e.name===""||e.name==="image.png"?`粘贴的图片.${e.type.split("/")[1]??"png"}`:e.name,r=t.slice(t.indexOf(",")+1);if(qM.has(e.type)&&r.length<=Ap)return{mediaType:e.type,data:r,name:n,url:t};const i=new Image;i.src=t,await i.decode();for(let o=2560;o>=640;o=Math.round(o*.75)){const c=Math.min(1,o/Math.max(i.naturalWidth,i.naturalHeight)),u=document.createElement("canvas");u.width=Math.max(1,Math.round(i.naturalWidth*c)),u.height=Math.max(1,Math.round(i.naturalHeight*c)),u.getContext("2d").drawImage(i,0,0,u.width,u.height);const f=u.toDataURL("image/jpeg",.88),d=f.slice(f.indexOf(",")+1);if(d.length<=Ap)return{mediaType:"image/jpeg",data:d,name:n.replace(/\.\w+$/,".jpg"),url:f}}throw new Error("图片太大")}function Up({client:e,sessionId:t,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o}){const c=Qk(e,t);return c===null?s.jsx("div",{className:"main empty",children:"正在打开会话…"}):s.jsx(KM,{client:e,session:c,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o})}function KM({client:e,session:t,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o}){const c=je(t.state),u=je(e.connection.status),f=fi(e),d=je(e.sessions).items.find(A=>A.id===t.id),p=d===void 0?xr:_a(d,f),m=f.find(A=>A.id===p),g=m===void 0?br:ac(m),v=(d==null?void 0:d.home)!==void 0,y=q$(Jk(e),c),[S,k]=b.useState(()=>JM()),w=y.find(A=>A.id===S)??y[0];return b.useEffect(()=>eR(S),[S]),s.jsxs("section",{className:"main",children:[s.jsxs("header",{className:"session-header",children:[s.jsxs("div",{className:"session-heading",children:[v?s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${g.id}`,children:s.jsx(ee,{name:g.icon})}),s.jsx("h1",{children:g.name})]}):s.jsxs("div",{className:"breadcrumb",children:[o!==void 0?s.jsx("button",{type:"button",className:"link-button breadcrumb-link",title:`回到「${g.name}」的对话`,onClick:()=>o(p),children:g.name}):s.jsx("span",{children:g.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx(QM,{title:c.title,onRename:A=>e.renameSession(t.id,A)})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(dw,{running:c.running}),v?s.jsx("span",{children:g.description}):s.jsx("span",{children:"以前的对话"}),!v&&p!==xr&&(d==null?void 0:d.requestedBy)!==void 0&&s.jsx("span",{children:hM(d.requestedBy)})]})]}),s.jsxs("div",{className:"session-actions",children:[s.jsx("nav",{className:"tabs",role:"tablist","aria-label":"会话视图",children:y.map(A=>s.jsx("button",{role:"tab","aria-selected":A.id===(w==null?void 0:w.id),className:A.id===(w==null?void 0:w.id)?"active":"",onClick:()=>k(A.id),children:A.title},A.id))}),w!==void 0&&s.jsx("button",{className:"icon-button popout-button",title:`在新窗口打开「${w.title}」`,"aria-label":`在新窗口打开「${w.title}」`,onClick:()=>window.open(CM(w.id,t.id),`dsh-${w.id}-${t.id}`),children:s.jsx(ee,{name:"popout"})})]})]}),c.error!==null&&s.jsx("div",{className:"banner error",children:c.error}),s.jsx("div",{className:"view",children:w===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):s.jsx(w.component,{client:e,session:t,state:c})}),n,s.jsx(WM,{client:e,session:t,running:c.running,disabled:u.state!=="open",initialPrompt:r,onInitialSent:i})]})}function YM({client:e,viewId:t,sessionId:n}){const r=Qk(e,n),i=Jk(e),o=je(e.connection.status),c=i.find(u=>u.id===t);return r===null||c===void 0?s.jsx("div",{className:"popped",children:s.jsx("section",{className:"main empty",children:o.state==="open"&&c===void 0?"当前连接没有提供这个视图。":"正在打开…"})}):s.jsx(XM,{client:e,session:r,view:c})}function XM({client:e,session:t,view:n}){const r=je(t.state);return b.useEffect(()=>{document.title=`${n.title} · ${r.title??"会话"}`},[n.title,r.title]),s.jsx("div",{className:"popped",children:s.jsxs("section",{className:"main",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:n.title}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:r.title??"新会话"})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(dw,{running:r.running}),s.jsx("span",{children:"与主窗口同步更新"})]})]})}),r.error!==null&&s.jsx("div",{className:"banner error",children:r.error}),s.jsx("div",{className:"view",children:s.jsx(n.component,{client:e,session:t,state:r})})]})})}function QM({title:e,onRename:t}){const[n,r]=b.useState(null),[i,o]=b.useState(null),c=e??"新会话",u=async()=>{const f=(n==null?void 0:n.trim())??"";if(f===""||f===e){r(null);return}try{await t(f),r(null),o(null)}catch(d){o(d instanceof Error?d.message:String(d))}};return n!==null?s.jsxs("span",{className:"title-edit",children:[s.jsx("input",{className:"text-input",autoFocus:!0,value:n,maxLength:80,"aria-label":"会话名称",onChange:f=>r(f.target.value),onFocus:f=>f.target.select(),onKeyDown:f=>{f.key==="Enter"&&!f.nativeEvent.isComposing&&u(),f.key==="Escape"&&(r(null),o(null))},onBlur:()=>void u()}),i!==null&&s.jsx("span",{className:"error small",children:i})]}):s.jsxs("span",{className:"session-title",children:[s.jsx("h1",{title:"双击改名",onDoubleClick:()=>r(c),children:c}),s.jsx("button",{type:"button",className:"icon-button rename-button",title:"改名","aria-label":"给这个会话改名",onClick:()=>r(c),children:s.jsx(ee,{name:"pencil"})})]})}function dw({running:e}){return e?s.jsxs("span",{className:"status-pill running",children:[s.jsx("span",{className:"pill-dot"}),"运行中"]}):s.jsx("span",{className:"status-pill",children:"空闲"})}const fw="adg.sessionTab";function JM(){try{return localStorage.getItem(fw)??"chat"}catch{return"chat"}}function eR(e){try{localStorage.setItem(fw,e)}catch{}}const hw="adg.theme",Hp=new Set;let Ol=tR();function tR(){try{const e=localStorage.getItem(hw);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function pw(){var e,t;Ol==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=Ol,(t=(e=kr())==null?void 0:e.setTheme)==null||t.call(e,Ol).catch(()=>{})}function nR(e){Ol=e;try{localStorage.setItem(hw,e)}catch{}pw();for(const t of Hp)t()}function mw(){return b.useSyncExternalStore(e=>(Hp.add(e),()=>Hp.delete(e)),()=>Ol)}const sR={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",about:"info"},rR=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function iR({client:e,onClose:t,section:n,onSection:r}){const i=Q$(e),o=mw(),[c,u]=b.useState(null),f=c??n??null,d=m=>{u(m),r==null||r(m)},p=i.find(m=>m.id===f)??i[0];return s.jsxs(s.Fragment,{children:[s.jsxs("aside",{className:"sidebar settings-sidebar",children:[s.jsxs("button",{className:"nav-item back-link",onClick:t,children:[s.jsx(ee,{name:"back"}),s.jsx("span",{className:"nav-item-label",children:"返回"})]}),s.jsx("h1",{className:"settings-title",children:"设置"}),s.jsxs("nav",{className:"page-list","aria-label":"设置分类",children:[s.jsx("div",{className:"sidebar-label",children:"偏好设置"}),i.map(m=>s.jsxs("button",{className:`nav-item ${m.id===(p==null?void 0:p.id)?"active":""}`,"aria-current":m.id===(p==null?void 0:p.id)?"page":void 0,onClick:()=>d(m.id),children:[s.jsx(ee,{name:sR[m.id]??"settings"}),s.jsx("span",{className:"nav-item-label",children:m.title})]},m.id))]}),s.jsxs("div",{className:"page-list",children:[s.jsx("div",{className:"sidebar-label",id:"theme-label",children:"外观"}),s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-labelledby":"theme-label",children:rR.map(([m,g])=>s.jsx("button",{role:"radio","aria-checked":o===m,className:o===m?"active":"",onClick:()=>nR(m),children:g},m))})]})]}),s.jsx("section",{className:"main settings",children:s.jsx("div",{className:"settings-content",children:p===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):s.jsx(p.component,{client:e})})})]})}function Am(e){const t=je(e.connection.status),[n,r]=b.useState({data:null,error:null}),[i,o]=b.useState(0),c=b.useCallback(()=>o(u=>u+1),[]);return b.useEffect(()=>e.connection.on("scripts/changed",()=>c()),[e,c]),b.useEffect(()=>{if(t.state!=="open")return;let u=!0;return e.connection.call("scripts/list",{}).then(f=>{u&&r({data:f,error:null})}).catch(f=>{u&&r(d=>({...d,error:ze(f)}))}),()=>{u=!1}},[e,t.state,i]),{...n,refresh:c}}function aR(e){const t=je(e.connection.status),[n,r]=b.useState(new Map);return b.useEffect(()=>e.connection.on("scripts/job",i=>{r(o=>{const c=o.get(i.scriptId);return c!==void 0&&c.id!==i.id&&c.startedAt>i.startedAt?o:new Map(o).set(i.scriptId,i)})}),[e]),b.useEffect(()=>{if(t.state!=="open")return;let i=!0;return e.connection.call("scripts/jobs",{}).then(({items:o})=>{if(!i)return;const c=new Map;for(const u of[...o].sort((f,d)=>f.startedAt-d.startedAt))c.set(u.scriptId,u);r(c)}).catch(()=>{}),()=>{i=!1}},[e,t.state]),n}function ze(e){return e instanceof Error?e.message:String(e)}function va(e){return e<1024?`${e} B`:e<1024**2?`${(e/1024).toFixed(0)} KB`:e<1024**3?`${(e/1024**2).toFixed(1)} MB`:`${(e/1024**3).toFixed(2)} GB`}const qu={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},gw={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function co(e){return e!==void 0&&e.endedAt===void 0}const xw=["日","一","二","三","四","五","六"],vw=[1,2,3,4,5,6,0];function Tm(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${vw.filter(n=>e.days.includes(n)).map(n=>xw[n]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}function vo(e,t){if(!e.enabled)return;const n=new Date(t);n.setHours(0,0,0,0);for(let r=0;r<8;r++,n.setDate(n.getDate()+1)){if(e.days.length>0&&!e.days.includes(n.getDay()))continue;const i=e.times.map(o=>{const[c,u]=o.split(":").map(Number);return new Date(n.getFullYear(),n.getMonth(),n.getDate(),c,u).getTime()}).filter(o=>o>t).sort((o,c)=>o-c);if(i[0]!==void 0)return i[0]}}const oc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function yw(e,t){const n=je(e.connection.status),[r,i]=b.useState(0),[o,c]=b.useState({items:null,error:null});return b.useEffect(()=>e.connection.on("tasks/changed",()=>i(u=>u+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let u=!0;return e.connection.call("tasks/list",t===void 0?{}:{agent:t}).then(f=>{u&&c({items:f.items,error:null})},f=>{u&&c(d=>({...d,error:ze(f)}))}),()=>{u=!1}},[e,t,n.state,r]),o}function bw(e,t){const n=je(e.connection.status),r=je(e.capabilities),[i,o]=b.useState(0),[c,u]=b.useState([]);return b.useEffect(()=>e.connection.on("reminders/changed",()=>o(f=>f+1)),[e]),b.useEffect(()=>{if(n.state!=="open"||!r.has("agents"))return;let f=!0;return e.connection.call("reminders/list",t===void 0?{}:{agent:t}).then(d=>{f&&u(d.items)}).catch(()=>{}),()=>{f=!1}},[e,t,n.state,r,i]),c}function kw(e){const t=je(e.connection.status),[n,r]=b.useState(0),[i,o]=b.useState([]);return b.useEffect(()=>e.connection.on("pipelines/changed",()=>r(c=>c+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let c=!0;return e.connection.call("pipelines/list",{}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t.state,n]),i}function ww(e){const t=je(e.connection.status),n=je(e.capabilities),[r,i]=b.useState(null);return b.useEffect(()=>{if(t.state!=="open"||!n.has("games"))return;let o=!0;return e.connection.call("games/list",{}).then(c=>{o&&i({schedule:{enabled:c.settings.report.enabled,times:[c.settings.report.at],days:[],catchUpMinutes:0},next:c.report.next})}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),r}function Nw({report:e,now:t}){const n=vo(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:"#/p/games/report",title:"在游戏页的「日报」里设置",children:[s.jsx(ee,{name:"send"}),s.jsx("span",{className:"task-title",children:"每日日报"}),s.jsxs("span",{className:"muted small",children:[Tm(e.schedule),n===void 0?"":` · 下次 ${oc(n)}`," · 发到飞书"]}),s.jsx(ee,{name:"chevron"})]})}function jw(e){const t=fi(e);return b.useMemo(()=>[br,...t.map(ac)],[t])}function oR({client:e,agentId:t}){const n=jw(e),r=n.find(v=>v.id===t)??br,{items:i,error:o}=yw(e,t),c=bw(e,t),u=kw(e),f=ww(e),d=Cn(3e4),[p,m]=b.useState(null),g=u.filter(v=>v.schedule.enabled&&v.draft!==!0);return s.jsxs("section",{className:"main scripts-page agent-schedule",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:r.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"定时任务"})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button primary",onClick:()=>m("new"),disabled:p!==null,children:[s.jsx(ee,{name:"plus"}),"新建定时任务"]})})]}),s.jsxs("div",{className:"schedule-body",children:[s.jsxs("p",{className:"muted small",children:["到点把一段话交给",r.name,"去做,在它的对话里做。",t===xr?"":"做完后,要紧的由助手告诉你。","要跑脚本的多步任务,用「编排」做成流水线。"]}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:o})]}),p==="new"&&s.jsx(Zp,{client:e,agents:n,task:{agent:t},onDone:()=>m(null)}),t==="games"&&f!==null&&s.jsx(Nw,{report:f,now:d}),i!==null&&i.length===0&&c.length===0&&p===null&&s.jsxs("div",{className:"empty-card muted",children:[r.name,"还没有定时任务。"]}),i==null?void 0:i.map(v=>p!=="new"&&(p==null?void 0:p.id)===v.id?s.jsx(Zp,{client:e,agents:n,task:v,onDone:()=>m(null)},v.id):s.jsx(Ew,{client:e,task:v,now:d,onEdit:()=>m(v)},v.id)),c.length>0&&s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{children:[r.name,"在对话里设的提醒"]}),s.jsx("p",{className:"muted small",children:"你在对话里让它「几点提醒我…」时它自己设的。到点后它在对话里接着做,回复也会同步到飞书和 QQ。"}),c.map(v=>s.jsx(_w,{client:e,reminder:v,now:d},v.id))]}),t==="pipelines"&&s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"按时运行的流水线"}),g.length===0&&s.jsx("p",{className:"muted small",children:"没有开着定时的流水线。"}),g.map(v=>s.jsx(Sw,{pipeline:v,now:d},v.id))]})]})]})}function lR({client:e,onAgent:t}){const n=jw(e),{items:r,error:i}=yw(e),o=bw(e),c=kw(e),u=ww(e),f=Cn(3e4),[d,p]=b.useState(!1),m=n.find(y=>y.id==="pipelines"),g=n.find(y=>y.id==="games"),v=b.useMemo(()=>[...u===null?[]:[{key:"daily-report",agent:g,title:"每日日报",at:vo(u.schedule,f)}],...(r??[]).map(y=>({key:y.id,agent:n.find(S=>S.id===y.agent),title:y.title,at:vo(y.schedule,f)})),...c.filter(y=>y.draft!==!0).map(y=>({key:y.id,agent:m,title:`流水线「${y.name}」`,at:vo(y.schedule,f)})),...o.map(y=>({key:y.id,agent:n.find(S=>S.id===y.agent),title:`提醒:${y.title}`,at:y.next}))].filter(y=>y.at!==void 0).sort((y,S)=>y.at-S.at).slice(0,8),[r,o,c,n,m,g,u,f]);return s.jsxs("section",{className:"main scripts-page agent-schedule",children:[s.jsxs("header",{className:"page-header",children:[s.jsx("div",{className:"breadcrumb",children:s.jsx("h1",{children:"定时任务"})}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("a",{className:"small-button",href:"#/settings/schedule",children:[s.jsx(ee,{name:"settings"}),"开机自启与唤醒"]}),s.jsxs("button",{className:"small-button primary",onClick:()=>p(!0),disabled:d,children:[s.jsx(ee,{name:"plus"}),"新建定时任务"]})]})]}),s.jsxs("div",{className:"schedule-body",children:[i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]}),d&&s.jsx(Zp,{client:e,agents:n,task:{agent:xr},chooseAgent:!0,onDone:()=>p(!1)}),s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"接下来"}),v.length===0&&s.jsx("p",{className:"muted small",children:"一周内没有要按时做的事。"}),s.jsx("ol",{className:"schedule-timeline",children:v.map(y=>{var S,k,w;return s.jsxs("li",{children:[s.jsx("span",{className:"schedule-when",children:oc(y.at)}),s.jsx("span",{className:`agent-avatar small agent-${((S=y.agent)==null?void 0:S.id)??"unknown"}`,children:s.jsx(ee,{name:((k=y.agent)==null?void 0:k.icon)??"sparkles"})}),s.jsx("span",{className:"schedule-who",children:((w=y.agent)==null?void 0:w.name)??"?"}),s.jsx("span",{className:"schedule-what",children:y.title})]},`${y.key}@${y.at}`)})})]}),n.map(y=>{const S=(r??[]).filter(N=>N.agent===y.id),k=o.filter(N=>N.agent===y.id),w=y.id==="pipelines"?c.filter(N=>N.schedule.enabled&&N.draft!==!0):[],A=y.id==="games"&&(u==null?void 0:u.schedule.enabled)===!0?u:null;return S.length===0&&k.length===0&&w.length===0&&A===null?null:s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{className:"schedule-agent",children:[s.jsx("span",{className:`agent-avatar small agent-${y.id}`,children:s.jsx(ee,{name:y.icon})}),y.name,s.jsx("span",{className:"tab-count",children:S.length+k.length+w.length+(A===null?0:1)}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button",onClick:()=>t(y.id),children:"管理"})]}),A!==null&&s.jsx(Nw,{report:A,now:f}),S.map(N=>s.jsx(Ew,{client:e,task:N,now:f},N.id)),k.map(N=>s.jsx(_w,{client:e,reminder:N,now:f},N.id)),w.map(N=>s.jsx(Sw,{pipeline:N,now:f},N.id))]},y.id)})]})]})}function Sw({pipeline:e,now:t}){const n=vo(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[s.jsx(ee,{name:"flow"}),s.jsx("span",{className:"task-title",children:e.name}),s.jsxs("span",{className:"muted small",children:[Tm(e.schedule),n===void 0?"":` · 下次 ${oc(n)}`]}),s.jsx(ee,{name:"chevron"})]})}function _w({client:e,reminder:t,now:n}){const[r,i]=b.useState(null),o=()=>{confirm(`删除提醒「${t.title}」?`)&&(i(null),e.connection.call("reminders/remove",{id:t.id}).catch(c=>i(ze(c))))};return s.jsxs("div",{className:"task-card reminder-card",children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx(ee,{name:"calendar"}),s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[t.rule==="一次"?"":`${t.rule} · `,t.repeats?"下次 ":"",oc(t.next),t.next>n?`(${cR(t.next-n)}后)`:""]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"icon-button",onClick:o,title:"删除这个提醒","aria-label":"删除",children:s.jsx(ee,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}function cR(e){const t=Math.max(1,Math.round(e/6e4));if(t<60)return`${t} 分钟`;const n=Math.round(t/60);return n<48?`${n} 小时`:`${Math.round(n/24)} 天`}function Ew({client:e,task:t,now:n,onEdit:r}){const[i,o]=b.useState(null),c=vo(t.schedule,n),u=t.lastRun,f=p=>{o(null),e.connection.call(p,{id:t.id}).catch(m=>o(ze(m)))},d=()=>{o(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(p=>o(ze(p)))};return s.jsxs("div",{className:`task-card ${t.schedule.enabled?"":"paused"}`,children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[Tm(t.schedule),c===void 0?"":` · 下次 ${oc(c)}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>f("tasks/run"),disabled:(u==null?void 0:u.state)==="running",title:"现在就交给它做一次",children:(u==null?void 0:u.state)==="running"?"在做":"立即运行"}),s.jsx("button",{className:"small-button",onClick:d,children:t.schedule.enabled?"暂停":"开启"}),r!==void 0&&s.jsx("button",{className:"icon-button",onClick:r,title:"修改","aria-label":"修改",children:s.jsx(ee,{name:"pencil"})}),r!==void 0&&s.jsx("button",{className:"icon-button",onClick:()=>{confirm(`删除定时任务「${t.title}」?`)&&f("tasks/remove")},title:"删除","aria-label":"删除",children:s.jsx(ee,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),u!==void 0&&s.jsxs("div",{className:`task-run tone-${u.state==="done"?"ok":u.state==="failed"?"failed":"running"}`,children:[u.state==="running"?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(ee,{name:u.state==="done"?"check":"alert"}),s.jsxs("span",{children:[u.state==="running"?"正在做":`${Tt(u.endedAt??u.startedAt,n)}${u.state==="done"?"做完":"没做成"}`,u.outcome===void 0?"":`:${u.outcome.split(`
127
- `)[0]}`]})]}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}function Zp({client:e,agents:t,task:n,chooseAgent:r=!1,onDone:i}){var R,D;const[o,c]=b.useState(n.agent),[u,f]=b.useState(n.title??""),[d,p]=b.useState(n.prompt??""),[m,g]=b.useState((((R=n.schedule)==null?void 0:R.times)??["09:00"]).join(", ")),[v,y]=b.useState(((D=n.schedule)==null?void 0:D.days)??[]),[S,k]=b.useState(!1),[w,A]=b.useState(null),N=async()=>{var P,F;k(!0),A(null);try{const W=m.split(/[,,、\s]+/).filter(M=>M!=="").map(M=>/^\d:\d\d$/.test(M)?`0${M}`:M);await e.connection.call("tasks/save",{task:{...n.id===void 0?{}:{id:n.id},agent:o,title:u,prompt:d,schedule:{enabled:((P=n.schedule)==null?void 0:P.enabled)??!0,times:W,days:[...v],catchUpMinutes:((F=n.schedule)==null?void 0:F.catchUpMinutes)??10}}}),i()}catch(W){A(ze(W))}finally{k(!1)}};return s.jsxs("div",{className:"task-card task-form",children:[r&&s.jsxs("label",{className:"field-label",children:["交给谁",s.jsx("select",{className:"text-input",value:o,onChange:P=>c(P.target.value),children:t.map(P=>s.jsx("option",{value:P.id,children:P.name},P.id))})]}),s.jsxs("label",{className:"field-label",children:["名字",s.jsx("input",{className:"text-input plain",value:u,maxLength:60,onChange:P=>f(P.target.value),placeholder:"例如:看今天结束的活动"})]}),s.jsxs("label",{className:"field-label",children:["交给它的话",s.jsx("textarea",{className:"text-input plain",rows:3,value:d,maxLength:4e3,onChange:P=>p(P.target.value),placeholder:"写完整:要做什么、要交回什么"})]}),s.jsxs("div",{className:"task-form-row",children:[s.jsxs("label",{className:"field-label",children:["时间",s.jsx("input",{className:"text-input plain-mono",value:m,onChange:P=>g(P.target.value),placeholder:"09:00, 21:30"})]}),s.jsxs("div",{className:"field-label",children:["星期",s.jsxs("div",{className:"day-chips",children:[vw.map(P=>s.jsx("button",{type:"button",className:`day-chip ${v.includes(P)?"on":""}`,"aria-pressed":v.includes(P),onClick:()=>y(v.includes(P)?v.filter(F=>F!==P):[...v,P]),children:xw[P]},P)),s.jsx("span",{className:"muted small",children:v.length===0?"不选就是每天":""})]})]})]}),w!==null&&s.jsx("div",{className:"error small",children:w}),s.jsxs("div",{className:"task-form-actions",children:[s.jsx("button",{className:"small-button",onClick:i,disabled:S,children:"取消"}),s.jsx("button",{className:"small-button primary",onClick:()=>void N(),disabled:S||u.trim()===""||d.trim()==="",children:"保存"})]})]})}/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function T0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function uR(e){if(Array.isArray(e))return e}function dR(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,c,u=[],f=!0,d=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(f=(r=o.call(n)).done)&&(u.push(r.value),u.length!==t);f=!0);}catch(p){d=!0,i=p}finally{try{if(!f&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(d)throw i}}return u}}function fR(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
128
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */function hR(e,t){return uR(e)||dR(e,t)||pR(e,t)||fR()}function pR(e,t){if(e){if(typeof e=="string")return T0(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T0(e,t):void 0}}const Cw=Object.entries,$0=Object.setPrototypeOf,mR=Object.isFrozen,Iw=Object.getPrototypeOf,Aw=Object.getOwnPropertyDescriptor;let Rn=Object.freeze,Dn=Object.seal,uo=Object.create,Tw=typeof Reflect<"u"&&Reflect,Wp=Tw.apply,Vp=Tw.construct;Rn||(Rn=function(t){return t});Dn||(Dn=function(t){return t});Wp||(Wp=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return t.apply(n,i)});Vp||(Vp=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new t(...r)});const ni=Gt(Array.prototype.forEach),gR=Gt(Array.prototype.lastIndexOf),M0=Gt(Array.prototype.pop),xl=Gt(Array.prototype.push),xR=Gt(Array.prototype.slice),vR=Gt(Array.prototype.splice),yo=Array.isArray,$h=$w(Set),Mh=Gt(Set.prototype.add),vl=Gt(Set.prototype.has),pa=Gt(String.prototype.toLowerCase),Rh=Gt(String.prototype.toString),R0=Gt(String.prototype.match),yl=Gt(String.prototype.replace),O0=Gt(String.prototype.indexOf),yR=Gt(String.prototype.trim),bR=Gt(Number.prototype.toString),kR=Gt(Boolean.prototype.toString),z0=typeof BigInt>"u"?null:Gt(BigInt.prototype.toString),P0=typeof Symbol>"u"?null:Gt(Symbol.prototype.toString),ys=Gt(Object.prototype.hasOwnProperty),bl=Gt(Object.prototype.toString),Ln=Gt(RegExp.prototype.test),si=$w(TypeError);function Gt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Wp(e,t,r)}}function $w(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Vp(e,n)}}function wt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pa;if($0&&$0(e,null),!yo(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const o=n(i);o!==i&&(mR(t)||(t[r]=o),i=o)}e[i]=!0}return e}function wR(e){for(let t=0;t<e.length;t++)ys(e,t)||(e[t]=null);return e}function Cs(e){const t=uo(null);for(const r of Cw(e)){var n=hR(r,2);const i=n[0],o=n[1];ys(e,i)&&(yo(o)?t[i]=wR(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=Cs(o):t[i]=o)}return t}function NR(e){switch(typeof e){case"string":return e;case"number":return bR(e);case"boolean":return kR(e);case"bigint":return z0?z0(e):"0";case"symbol":return P0?P0(e):"Symbol()";case"undefined":return bl(e);case"function":case"object":{if(e===null)return bl(e);const t=e,n=qs(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:bl(r)}return bl(e)}default:return bl(e)}}function qs(e,t){for(;e!==null;){const r=Aw(e,t);if(r){if(r.get)return Gt(r.get);if(typeof r.value=="function")return Gt(r.value)}e=Iw(e)}function n(){return null}return n}function jR(e,t){for(;e!==null;){const n=Aw(e,t);if(n)return n.get?Gt(n.get):null;e=Iw(e)}return null}function SR(e){try{return Ln(e,""),!0}catch{return!1}}const L0=Rn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Oh=Rn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),zh=Rn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_R=Rn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Ph=Rn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ER=Rn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),D0=Rn(["#text"]),F0=Rn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Lh=Rn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dominant-baseline","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-orientation","text-rendering","textlength","type","u1","u2","unicode","values","vector-effect","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),B0=Rn(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),gu=Rn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),CR=Dn(/{{[\w\W]*|^[\w\W]*}}/g),IR=Dn(/<%[\w\W]*|^[\w\W]*%>/g),AR=Dn(/\${[\w\W]*/g),TR=Dn(/^data-[\-\w.\u00B7-\uFFFF]+$/),$R=Dn(/^aria-[\-\w]+$/),U0=Dn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),MR=Dn(/^(?:\w+script|data):/i),RR=Dn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),OR=Dn(/^html$/i),zR=Dn(/^[a-z][.\w]*(-[.\w]+)+$/i),Dh=Dn(/<[/\w!]/g),H0=Dn(/<[/\w]/g),PR=Dn(/<\/no(script|embed|frames)/i),Z0=Dn(/\/>/i),xn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},LR=Rn(wt({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),DR=function(){return typeof window>"u"?null:window},FR=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},W0=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Mi=function(t,n,r,i){return ys(t,n)&&yo(t[n])?wt(i.base?Cs(i.base):{},t[n],i.transform):r},Fh=function(t,n,r){const i=ys(t,n)?t[n]:void 0;return i&&typeof i=="object"?Cs(i):r()};function Mw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:DR();const t=we=>Mw(we);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==xn.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,i=r.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,c=e.Node,u=e.Element,f=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const d=e.DOMParser,p=e.trustedTypes,m=u.prototype,g=qs(m,"cloneNode"),v=qs(m,"remove"),y=qs(m,"removeAttributeNode"),S=qs(m,"nextSibling"),k=qs(m,"childNodes"),w=qs(m,"parentNode"),A=qs(m,"shadowRoot"),N=qs(m,"attributes"),R=c&&c.prototype?qs(c.prototype,"nodeType"):null,D=c&&c.prototype?qs(c.prototype,"nodeName"):null,P=c&&c.prototype?qs(c.prototype,"ownerDocument"):null,F=function(q){return R?R(q):q.nodeType},W=function(q){return D?D(q):q.nodeName},M=jR(m,"namespaceURI"),O=function(q){return M?M(q):q.namespaceURI};if(typeof o=="function"){const we=n.createElement("template");we.content&&we.content.ownerDocument&&(n=we.content.ownerDocument)}let T,Z="",E,C=!1,$=0;const L=function(){if($>0)throw si('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},B=function(q){L(),$++;try{return T.createHTML(q)}finally{$--}},H=function(q){L(),$++;try{return T.createScriptURL(q)}finally{$--}},G=function(){return C||(E=FR(p,i),C=!0),E},K=n,V=K.implementation,Y=K.createNodeIterator,fe=K.createDocumentFragment,xe=K.getElementsByTagName,ge=r.importNode;let ie=W0();t.isSupported=typeof Cw=="function"&&typeof w=="function"&&V&&V.createHTMLDocument!==void 0;const ke=CR,ae=IR,Ne=AR,Fe=TR,ce=$R,Se=MR,re=RR,he=zR;let Le=U0,Te=null;const Ge=wt({},[...L0,...Oh,...zh,...Ph,...D0]);let Ie=null;const tt=wt({},[...F0,...Lh,...B0,...gu]);let et=Object.seal(uo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),jt=null,On=null;const sn=Object.seal(uo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ln=!0,cn=!0,rn=!1,an=!0,Ft=!1,Bn=!0,wn=!1,ws=!1,_r=null,Ks=null,Ys=!1,Ms=!1,Rs=!1,Os=!1,zs=!0,Xs=!1;const Qs="user-content-";let rs=!0,Yn=!1,Nn=null,Q={},pe=null;const Oe=wt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let st=null;const It=wt({},["audio","video","img","source","image","track"]);let $t=null;const Be=wt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),De="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",bt="http://www.w3.org/1999/xhtml";let yt=bt,Un=!1,is=null;const Js=wt({},[De,Xe,bt],Rh),hi=Rn(["mi","mo","mn","ms","mtext"]);let er=wt({},hi);const pi=Rn(["annotation-xml"]);let Hn=wt({},pi);const Br=wt({},["title","style","font","a","script"]);let as=null;const Er=["application/xhtml+xml","text/html"],mi="text/html";let Rt=null,Ns=null;const Xn=n.createElement("form"),Ur=function(q){return q instanceof RegExp||q instanceof Function},tr=function(){let q=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ns&&Ns===q)return;(!q||typeof q!="object")&&(q={}),q=Cs(q),as=Er.indexOf(q.PARSER_MEDIA_TYPE)===-1?mi:q.PARSER_MEDIA_TYPE,Rt=as==="application/xhtml+xml"?Rh:pa,Te=Mi(q,"ALLOWED_TAGS",Ge,{transform:Rt}),Ie=Mi(q,"ALLOWED_ATTR",tt,{transform:Rt}),is=Mi(q,"ALLOWED_NAMESPACES",Js,{transform:Rh}),$t=Mi(q,"ADD_URI_SAFE_ATTR",Be,{transform:Rt,base:Be}),st=Mi(q,"ADD_DATA_URI_TAGS",It,{transform:Rt,base:It}),pe=Mi(q,"FORBID_CONTENTS",Oe,{transform:Rt}),jt=Mi(q,"FORBID_TAGS",Cs({}),{transform:Rt}),On=Mi(q,"FORBID_ATTR",Cs({}),{transform:Rt}),Q=ys(q,"USE_PROFILES")?q.USE_PROFILES&&typeof q.USE_PROFILES=="object"?Cs(q.USE_PROFILES):q.USE_PROFILES:!1,ln=q.ALLOW_ARIA_ATTR!==!1,cn=q.ALLOW_DATA_ATTR!==!1,rn=q.ALLOW_UNKNOWN_PROTOCOLS||!1,an=q.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ft=q.SAFE_FOR_TEMPLATES||!1,Bn=q.SAFE_FOR_XML!==!1,wn=q.WHOLE_DOCUMENT||!1,Ms=q.RETURN_DOM||!1,Rs=q.RETURN_DOM_FRAGMENT||!1,Os=q.RETURN_TRUSTED_TYPE||!1,Ys=q.FORCE_BODY||!1,zs=q.SANITIZE_DOM!==!1,Xs=q.SANITIZE_NAMED_PROPS||!1,rs=q.KEEP_CONTENT!==!1,Yn=q.IN_PLACE||!1,Le=SR(q.ALLOWED_URI_REGEXP)?q.ALLOWED_URI_REGEXP:U0,yt=typeof q.NAMESPACE=="string"?q.NAMESPACE:bt,er=Fh(q,"MATHML_TEXT_INTEGRATION_POINTS",()=>wt({},hi)),Hn=Fh(q,"HTML_INTEGRATION_POINTS",()=>wt({},pi));const ne=Fh(q,"CUSTOM_ELEMENT_HANDLING",()=>uo(null));if(et=uo(null),ys(ne,"tagNameCheck")&&Ur(ne.tagNameCheck)&&(et.tagNameCheck=ne.tagNameCheck),ys(ne,"attributeNameCheck")&&Ur(ne.attributeNameCheck)&&(et.attributeNameCheck=ne.attributeNameCheck),ys(ne,"allowCustomizedBuiltInElements")&&typeof ne.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=ne.allowCustomizedBuiltInElements),Dn(et),Ft&&(cn=!1),Rs&&(Ms=!0),Q&&(Te=wt({},D0),Ie=uo(null),Q.html===!0&&(wt(Te,L0),wt(Ie,F0)),Q.svg===!0&&(wt(Te,Oh),wt(Ie,Lh),wt(Ie,gu)),Q.svgFilters===!0&&(wt(Te,zh),wt(Ie,Lh),wt(Ie,gu)),Q.mathMl===!0&&(wt(Te,Ph),wt(Ie,B0),wt(Ie,gu))),sn.tagCheck=null,sn.attributeCheck=null,ys(q,"ADD_TAGS")&&(typeof q.ADD_TAGS=="function"?sn.tagCheck=q.ADD_TAGS:yo(q.ADD_TAGS)&&(Te===Ge&&(Te=Cs(Te)),wt(Te,q.ADD_TAGS,Rt))),ys(q,"ADD_ATTR")&&(typeof q.ADD_ATTR=="function"?sn.attributeCheck=q.ADD_ATTR:yo(q.ADD_ATTR)&&(Ie===tt&&(Ie=Cs(Ie)),wt(Ie,q.ADD_ATTR,Rt))),ys(q,"ADD_FORBID_CONTENTS")&&yo(q.ADD_FORBID_CONTENTS)&&(pe===Oe&&(pe=Cs(pe)),wt(pe,q.ADD_FORBID_CONTENTS,Rt)),rs&&(Te["#text"]=!0),wn&&wt(Te,["html","head","body"]),Te.table&&(wt(Te,["tbody"]),delete jt.tbody),q.TRUSTED_TYPES_POLICY){if(typeof q.TRUSTED_TYPES_POLICY.createHTML!="function")throw si('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof q.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw si('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ve=T;T=q.TRUSTED_TYPES_POLICY;try{Z=B("")}catch(ye){throw T=ve,ye}}else q.TRUSTED_TYPES_POLICY===null?(T=void 0,Z=""):(T===void 0&&(T=G()),T&&typeof Z=="string"&&(Z=B("")));Rn&&Rn(q),Ns=q},Ot=wt({},[...Oh,...zh,..._R]),gi=wt({},[...Ph,...ER]),Hr=function(q,ne,ve){return ne.namespaceURI===bt?q==="svg":ne.namespaceURI===De?q==="svg"&&(ve==="annotation-xml"||er[ve]):!!Ot[q]},nr=function(q,ne,ve){return ne.namespaceURI===bt?q==="math":ne.namespaceURI===Xe?q==="math"&&Hn[ve]:!!gi[q]},Cr=function(q,ne,ve){return ne.namespaceURI===Xe&&!Hn[ve]||ne.namespaceURI===De&&!er[ve]?!1:!gi[q]&&(Br[q]||!Ot[q])},Ae=function(q){const ne=O(q),ve=pa(W(q)),ye=w(q);let qe,nt;return ye&&F(ye)===xn.element?(qe={namespaceURI:O(ye)},nt=pa(W(ye))):(qe={namespaceURI:yt},nt="template"),is[ne]?ne===Xe?Hr(ve,qe,nt):ne===De?nr(ve,qe,nt):ne===bt?Cr(ve,qe,nt):!!(as==="application/xhtml+xml"&&is[ne]):!1},Ze=function(q){xl(t.removed,{element:q});try{w(q).removeChild(q)}catch{if(v(q),!w(q))throw si("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ct=function(q,ne,ve){try{y(q,ne)}catch{try{q.removeAttribute(ve)}catch{}}},ft=function(q){Ps(q);const ne=k(q);ne&&ni(xR(ne),ye=>{try{v(ye)}catch{}});const ve=F(q)===xn.element?N(q):null;if(ve)for(let ye=ve.length-1;ye>=0;--ye){const qe=ve[ye],nt=qe&&qe.name;typeof nt=="string"&&ct(q,qe,nt)}},At=function(q,ne,ve){if(!ve)try{ve=ne.getAttributeNode(q)}catch{ve=null}xl(t.removed,{attribute:ve||null,from:ne});try{ve?y(ne,ve):ne.removeAttribute(q)}catch{try{ne.removeAttribute(q)}catch{}}if(q==="is")if(Ms||Rs)try{Ze(ne)}catch{}else try{ne.setAttribute(q,"")}catch{}},zt=function(q){const ne=N(q);if(ne)for(let ve=ne.length-1;ve>=0;--ve){const ye=ne[ve],qe=ye&&ye.name;typeof qe!="string"||Ie[Rt(qe)]||ct(q,ye,qe)}},Zn=function(q,ne){let ve=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const ye=[q];for(;ye.length>0;){const qe=ye.pop();if(ne(qe)===!1)continue;if(ve&&F(qe)===xn.element){const pt=A(qe);cs(pt)&&ye.push(pt)}const nt=k(qe);if(nt)for(let pt=nt.length-1;pt>=0;--pt)ye.push(nt[pt])}},Ps=function(q){Zn(q,ne=>{F(ne)===xn.element&&zt(ne)})},un=function(q){const ne=[];return Zn(q,ve=>{ne.push(ve)},!0),ne},jn=function(q,ne){const ve=$h();ni(un(q),ye=>{F(ye)===xn.element&&Mh(ve,ye)}),ni(ne,ye=>{F(ye)===xn.element&&!vl(ve,ye)&&zt(ye)})},Ls=function(q,ne){let ve=!1;return ni(t.removed,ye=>{ye.element&&(ve=ve||ye.element===q,Ps(ye.element))}),jn(q,ne),ve},Ds=8,os=function(q,ne){const ve=Nn;let ye=null;const qe=()=>(ye||(ye=$h(),ni(ne,nt=>{Mh(ye,nt)})),ye);for(let nt=0;;nt++){const pt=un(q),dn=[q];let us=!1;if(ni(pt,mn=>{F(mn)===xn.documentFragment?xl(dn,mn):!us&&!vl(ve,mn)&&(us=vl(qe(),mn))}),!us)return;if(nt>=Ds)throw si("the tree kept changing during in-place sanitization; refusing to return it");ni(dn,(mn,In)=>{Qi(mn,In>0,q,qe())})}},Qi=function(q,ne,ve,ye){const qe=ls(q);let nt;for(;nt=qe.nextNode();)!vl(ye,nt)||vl(Nn,nt)||(ne&&ht(ie.uponSanitizeShadowNode,nt,null),Ue(nt,ve),Vr(nt,ve),cs(nt.content)&&ea(nt.content))},xi=function(q){Nn&&Mh(Nn,q)},Ir=function(q,ne){return Bn?q==="patchsrc"?!0:q==="for"&&ne!=="label"&&ne!=="output":!1},vi=function(q){Bn&&Zn(q,ne=>{const ve=F(ne);if(ve===xn.processingInstruction||ve===xn.comment&&Ln(H0,ne.data)){try{v(ne)}catch{}return!1}if(ve===xn.element){const ye=ne,qe=Rt(W(ne));try{ye.hasAttribute&&ye.hasAttribute("patchsrc")&&ye.removeAttribute("patchsrc"),ye.hasAttribute&&ye.hasAttribute("for")&&Ir("for",qe)&&ye.removeAttribute("for")}catch{}}return!0})},Qn=function(q){let ne=null,ve=null;if(Ys)q="<remove></remove>"+q;else{const nt=R0(q,/^[\r\n\t ]+/);ve=nt&&nt[0]}as==="application/xhtml+xml"&&yt===bt&&(q='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+q+"</body></html>");const ye=T?B(q):q;if(yt===bt)try{ne=new d().parseFromString(ye,as)}catch{}if(!ne||!ne.documentElement){ne=V.createDocument(yt,"template",null);try{ne.documentElement.innerHTML=Un?Z:ye}catch{}}const qe=ne.body||ne.documentElement;return q&&ve&&qe.insertBefore(n.createTextNode(ve),qe.childNodes[0]||null),yt===bt?xe.call(ne,wn?"html":"body")[0]:wn?ne.documentElement:qe},ls=function(q){const ne=P?P(q):q.ownerDocument;return Y.call(ne||q,q,f.SHOW_ELEMENT|f.SHOW_COMMENT|f.SHOW_TEXT|f.SHOW_PROCESSING_INSTRUCTION|f.SHOW_CDATA_SECTION,null)},Sn=function(q){return q=yl(q,ke," "),q=yl(q,ae," "),q=yl(q,Ne," "),q},Fs=function(q){var ne;vt(q);const ve=(ne=q.querySelectorAll)===null||ne===void 0?void 0:ne.call(q,"template");ve&&ni(ve,ye=>{cs(ye.content)&&Fs(ye.content)})},vt=function(q){q.normalize();const ne=P?P(q):q.ownerDocument,ve=Y.call(ne||q,q,f.SHOW_TEXT|f.SHOW_COMMENT|f.SHOW_CDATA_SECTION|f.SHOW_PROCESSING_INSTRUCTION,null);let ye=ve.nextNode();for(;ye;)ye.data=Sn(ye.data),ye=ve.nextNode()},at=function(q){const ne=D?D(q):null;return typeof ne!="string"||Rt(ne)!=="form"?!1:typeof q.nodeName!="string"||typeof q.textContent!="string"||typeof q.removeChild!="function"||q.attributes!==N(q)||typeof q.removeAttribute!="function"||typeof q.removeAttributeNode!="function"||typeof q.getAttributeNode!="function"||typeof q.setAttribute!="function"||typeof q.namespaceURI!="string"||typeof q.insertBefore!="function"||typeof q.hasChildNodes!="function"||q.nodeType!==R(q)||q.childNodes!==k(q)},cs=function(q){if(!R||typeof q!="object"||q===null)return!1;try{return R(q)===xn.documentFragment}catch{return!1}},Pt=function(q){if(!R||typeof q!="object"||q===null)return!1;try{return typeof R(q)=="number"}catch{return!1}};function ht(we,q,ne){we.length!==0&&ni(we,ve=>{ve.call(t,q,ne,Ns)})}const Zr=function(q,ne){return!!(Bn&&q.hasChildNodes()&&!Pt(q.firstElementChild)&&Ln(Dh,q.textContent)&&Ln(Dh,q.innerHTML)||Bn&&LR[ne]&&F(q)===xn.element&&O(q)===bt&&(Pt(q.firstElementChild)||typeof q.textContent=="string"&&Ln(Dh,q.textContent))||q.nodeType===xn.processingInstruction||Bn&&q.nodeType===xn.comment&&Ln(H0,q.data))},Jn=function(q,ne){if(q instanceof RegExp)return Ln(q,ne);if(q instanceof Function){for(var ve=arguments.length,ye=new Array(ve>2?ve-2:0),qe=2;qe<ve;qe++)ye[qe-2]=arguments[qe];return!!q(ne,...ye)}return!1},Wr=function(q,ne,ve){if(!jt[ne]&&Bt(ne)&&Jn(et.tagNameCheck,ne))return!1;if(rs&&!pe[ne]&&!pe[pa(ne)]){const ye=w(q),qe=k(q);if(qe&&ye){const nt=qe.length;for(let pt=nt-1;pt>=0;--pt){const dn=q===ve?g(qe[pt],!0):qe[pt];ye.insertBefore(dn,S(q))}}}return Ze(q),!0},sr=function(q,ne,ve,ye){return q.length===0?ne:ne===ve||ne===ye?Cs(ne):ne},$e=function(q,ne){return q===ne||w(q)!==null?!1:(Yn&&Ps(q),!0)},Ue=function(q,ne){if(xi(q),ht(ie.beforeSanitizeElements,q,null),$e(q,ne))return!0;if(at(q))return Ze(q),!0;const ve=Rt(W(q));if(Te=sr(ie.uponSanitizeElement,Te,Ge,_r),ht(ie.uponSanitizeElement,q,{tagName:ve,allowedTags:Te}),$e(q,ne))return!0;if(Zr(q,ve))return Ze(q),!0;if(jt[ve]||!(sn.tagCheck instanceof Function&&sn.tagCheck(ve))&&!Te[ve]){const ye=Wr(q,ve,ne);return ye===!1&&(ht(ie.afterSanitizeElements,q,null),$e(q,ne))?!0:ye}if(F(q)===xn.element&&!Ae(q)||(ve==="noscript"||ve==="noembed"||ve==="noframes")&&Ln(PR,q.innerHTML))return Ze(q),!0;if(Ft&&q.nodeType===xn.text){const ye=Sn(q.textContent);q.textContent!==ye&&(xl(t.removed,{element:q.cloneNode()}),q.textContent=ye)}return ht(ie.afterSanitizeElements,q,null),$e(q,ne)},ot=function(q,ne,ve){if(On[ne]||Ir(ne,q)||zs&&(ne==="id"||ne==="name")&&(ve in n||ve in Xn))return!1;const ye=Ie[ne]||sn.attributeCheck instanceof Function&&sn.attributeCheck(ne,q);return cn&&Ln(Fe,ne)||ln&&Ln(ce,ne)?!0:ye?$t[ne]||Ln(Le,yl(ve,re,""))||(ne==="src"||ne==="xlink:href"||ne==="href")&&q!=="script"&&O0(ve,"data:")===0&&st[q]||rn&&!Ln(Se,yl(ve,re,""))?!0:!ve:Bt(q)&&Jn(et.tagNameCheck,q)&&Jn(et.attributeNameCheck,ne,q)||ne==="is"&&et.allowCustomizedBuiltInElements&&Jn(et.tagNameCheck,ve)},gt=wt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Bt=function(q){return!gt[pa(q)]&&Ln(he,q)},pn=function(q,ne,ve,ye){if(T&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!ve)switch(p.getAttributeType(q,ne)){case"TrustedHTML":return B(ye);case"TrustedScriptURL":return H(ye)}return ye},Bo=function(q,ne,ve,ye){try{return ve?q.setAttributeNS(ve,ne,ye):q.setAttribute(ne,ye),at(q)?(Ze(q),!1):!0}catch{return At(ne,q),!1}},Ji=function(q,ne){return Bn&&Ln(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ne)?!0:pa(q)==="attributename"&&R0(ne,"href")!==null},Vr=function(q,ne){if(ht(ie.beforeSanitizeAttributes,q,null),$e(q,ne))return;const ve=q.attributes;if(!ve||at(q))return;Ie=sr(ie.uponSanitizeAttribute,Ie,tt,Ks);const ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ie,forceKeepAttr:void 0};let qe=ve.length;const nt=Rt(q.nodeName);for(;qe--;){const pt=ve[qe],dn=pt.name,us=pt.namespaceURI,mn=pt.value,In=Rt(dn),qr=mn;let Qt=dn==="value"?qr:yR(qr),La=!1;if(ye.attrName=In,ye.attrValue=Qt,ye.keepAttr=!0,ye.forceKeepAttr=void 0,ht(ie.uponSanitizeAttribute,q,ye),Qt=ye.attrValue,Xs&&(In==="id"||In==="name")&&O0(Qt,Qs)!==0&&(At(dn,q,pt),Qt=Qs+Qt,La=!0),Ji(dn,Qt)){At(dn,q,pt);continue}if(!ye.forceKeepAttr){if(!ye.keepAttr){At(dn,q,pt);continue}if(!an&&Ln(Z0,Qt)){At(dn,q,pt);continue}if(Ft&&(Qt=Sn(Qt)),!ot(nt,In,Qt)){At(dn,q,pt);continue}Qt=pn(nt,In,us,Qt),Qt!==qr&&Bo(q,dn,us,Qt)&&La&&M0(t.removed)}}ht(ie.afterSanitizeAttributes,q,null),$e(q,ne)},ea=function(q){let ne=null;const ve=ls(q);for(ht(ie.beforeSanitizeShadowDOM,q,null);ne=ve.nextNode();)if(ht(ie.uponSanitizeShadowNode,ne,null),Ue(ne,q),Vr(ne,q),cs(ne.content)&&ea(ne.content),F(ne)===xn.element){const ye=A(ne);cs(ye)&&(Pa(ye),ea(ye))}Ft&&vt(q),ht(ie.afterSanitizeShadowDOM,q,null)},Pa=function(q){const ne=[{node:q,shadow:null}];for(;ne.length>0;){const ve=ne.pop();if(ve.shadow){ea(ve.shadow);continue}const ye=ve.node,qe=F(ye)===xn.element,nt=k(ye);if(nt)for(let pt=nt.length-1;pt>=0;--pt)ne.push({node:nt[pt],shadow:null});if(qe){const pt=D?D(ye):null;if(typeof pt=="string"&&Rt(pt)==="template"){const dn=ye.content;cs(dn)&&ne.push({node:dn,shadow:null})}}if(qe){const pt=A(ye);cs(pt)&&ne.push({node:null,shadow:pt},{node:pt,shadow:null})}}};return t.sanitize=function(we){let q=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ne=null,ve=null,ye=null,qe=null;if(Un=!we,Un&&(we="<!-->"),typeof we!="string"&&!Pt(we)&&(we=NR(we),typeof we!="string"))throw si("dirty is not a string, aborting");if(!t.isSupported)return we;ws?(Te=_r,Ie=Ks):tr(q),(ie.uponSanitizeElement.length>0||ie.uponSanitizeAttribute.length>0)&&(Te=Cs(Te)),ie.uponSanitizeAttribute.length>0&&(Ie=Cs(Ie)),t.removed=[];const nt=Yn&&typeof we!="string"&&Pt(we);let pt=[];const dn=Nn;if(nt){vi(we);const In=W(we);if(typeof In=="string"){const qr=Rt(In);if(!Te[qr]||jt[qr])throw ft(we),si("root node is forbidden and cannot be sanitized in-place")}if(at(we))throw ft(we),si("root node is clobbered and cannot be sanitized in-place");pt=un(we),Nn=$h()}else if(Pt(we))ne=Qn("<!---->"),ve=ne.ownerDocument.importNode(we,!0),ve.nodeType===xn.element&&ve.nodeName==="BODY"||ve.nodeName==="HTML"?ne=ve:ne.appendChild(ve),Pa(ne);else{if(!Ms&&!Ft&&!wn&&we.indexOf("<")===-1)return T&&Os?B(we):we;if(ne=Qn(we),!ne)return Ms?null:Os?Z:""}ne&&Ys&&Ze(ne.firstChild);const us=nt?we:ne;try{nt&&Pa(we);const In=ls(us);for(;ye=In.nextNode();)Ue(ye,us),Vr(ye,us),cs(ye.content)&&ea(ye.content);nt&&os(we,pt)}catch(In){throw nt&&(ft(we),Ls(we,pt)),In}finally{Nn=dn}if(nt){if(Ls(we,pt))throw si("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ft&&Fs(we),we}if(Ms){if(Ft&&Fs(ne),Rs)for(qe=fe.call(ne.ownerDocument);ne.firstChild;)qe.appendChild(ne.firstChild);else qe=ne;return(Ie.shadowroot||Ie.shadowrootmode)&&(qe=ge.call(r,qe,!0)),qe}let mn=wn?ne.outerHTML:ne.innerHTML;return wn&&Te["!doctype"]&&ne.ownerDocument&&ne.ownerDocument.doctype&&ne.ownerDocument.doctype.name&&Ln(OR,ne.ownerDocument.doctype.name)&&(mn="<!DOCTYPE "+ne.ownerDocument.doctype.name+`>
129
- `+mn),Ft&&(mn=Sn(mn)),T&&Os?B(mn):mn},t.setConfig=function(){let we=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};tr(we),ws=!0,_r=Te,Ks=Ie},t.clearConfig=function(){Ns=null,ws=!1,_r=null,Ks=null,T=E,Z=""},t.isValidAttribute=function(we,q,ne){Ns||tr({});const ve=Rt(we),ye=Rt(q);return typeof ne=="string"&&(Ji(q,ne)||!an&&Ln(Z0,ne))?!1:ot(ve,ye,ne)},t.addHook=function(we,q){typeof q=="function"&&ys(ie,we)&&xl(ie[we],q)},t.removeHook=function(we,q){if(ys(ie,we)){if(q!==void 0){const ne=gR(ie[we],q);return ne===-1?void 0:vR(ie[we],ne,1)[0]}return M0(ie[we])}},t.removeHooks=function(we){ys(ie,we)&&(ie[we]=[])},t.removeAllHooks=function(){ie=W0()},t}var $m=Mw();function Mm(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var za=Mm();function Rw(e){za=e}var zl={exec:()=>null};function _t(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,o)=>{let c=typeof o=="string"?o:o.source;return c=c.replace(ss.caret,"$1"),n=n.replace(i,c),r},getRegex:()=>new RegExp(n,t)};return r}var BR=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),ss={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},UR=/^(?:[ \t]*(?:\n|$))+/,HR=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ZR=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,lc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,WR=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Rm=/(?:[*+-]|\d{1,9}[.)])/,Ow=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zw=_t(Ow).replace(/bull/g,Rm).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),VR=_t(Ow).replace(/bull/g,Rm).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Om=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,qR=/^[^\n]+/,zm=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,GR=_t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",zm).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),KR=_t(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Rm).getRegex(),vd="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Pm=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,YR=_t("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Pm).replace("tag",vd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Pw=_t(Om).replace("hr",lc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vd).getRegex(),XR=_t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Pw).getRegex(),Lm={blockquote:XR,code:HR,def:GR,fences:ZR,heading:WR,hr:lc,html:YR,lheading:zw,list:KR,newline:UR,paragraph:Pw,table:zl,text:qR},V0=_t("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",lc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vd).getRegex(),QR={...Lm,lheading:VR,table:V0,paragraph:_t(Om).replace("hr",lc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",V0).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",vd).getRegex()},JR={...Lm,html:_t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Pm).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:zl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_t(Om).replace("hr",lc).replace("heading",` *#{1,6} *[^
130
- ]`).replace("lheading",zw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},eO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,tO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Lw=/^( {2,}|\\)\n(?!\s*$)/,nO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,yd=/[\p{P}\p{S}]/u,Dm=/[\s\p{P}\p{S}]/u,Dw=/[^\s\p{P}\p{S}]/u,sO=_t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Dm).getRegex(),Fw=/(?!~)[\p{P}\p{S}]/u,rO=/(?!~)[\s\p{P}\p{S}]/u,iO=/(?:[^\s\p{P}\p{S}]|~)/u,aO=_t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",BR?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Bw=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,oO=_t(Bw,"u").replace(/punct/g,yd).getRegex(),lO=_t(Bw,"u").replace(/punct/g,Fw).getRegex(),Uw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",cO=_t(Uw,"gu").replace(/notPunctSpace/g,Dw).replace(/punctSpace/g,Dm).replace(/punct/g,yd).getRegex(),uO=_t(Uw,"gu").replace(/notPunctSpace/g,iO).replace(/punctSpace/g,rO).replace(/punct/g,Fw).getRegex(),dO=_t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Dw).replace(/punctSpace/g,Dm).replace(/punct/g,yd).getRegex(),fO=_t(/\\(punct)/,"gu").replace(/punct/g,yd).getRegex(),hO=_t(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),pO=_t(Pm).replace("(?:-->|$)","-->").getRegex(),mO=_t("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",pO).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Gu=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,gO=_t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Gu).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Hw=_t(/^!?\[(label)\]\[(ref)\]/).replace("label",Gu).replace("ref",zm).getRegex(),Zw=_t(/^!?\[(ref)\](?:\[\])?/).replace("ref",zm).getRegex(),xO=_t("reflink|nolink(?!\\()","g").replace("reflink",Hw).replace("nolink",Zw).getRegex(),q0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Fm={_backpedal:zl,anyPunctuation:fO,autolink:hO,blockSkip:aO,br:Lw,code:tO,del:zl,emStrongLDelim:oO,emStrongRDelimAst:cO,emStrongRDelimUnd:dO,escape:eO,link:gO,nolink:Zw,punctuation:sO,reflink:Hw,reflinkSearch:xO,tag:mO,text:nO,url:zl},vO={...Fm,link:_t(/^!?\[(label)\]\((.*?)\)/).replace("label",Gu).getRegex(),reflink:_t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Gu).getRegex()},qp={...Fm,emStrongRDelimAst:uO,emStrongLDelim:lO,url:_t(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",q0).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:_t(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",q0).getRegex()},yO={...qp,br:_t(Lw).replace("{2,}","*").getRegex(),text:_t(qp.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},xu={normal:Lm,gfm:QR,pedantic:JR},kl={normal:Fm,gfm:qp,breaks:yO,pedantic:vO},bO={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},G0=e=>bO[e];function Or(e,t){if(t){if(ss.escapeTest.test(e))return e.replace(ss.escapeReplace,G0)}else if(ss.escapeTestNoEncode.test(e))return e.replace(ss.escapeReplaceNoEncode,G0);return e}function K0(e){try{e=encodeURI(e).replace(ss.percentDecode,"%")}catch{return null}return e}function Y0(e,t){var o;let n=e.replace(ss.findPipe,(c,u,f)=>{let d=!1,p=u;for(;--p>=0&&f[p]==="\\";)d=!d;return d?"|":" |"}),r=n.split(ss.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((o=r.at(-1))!=null&&o.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(ss.slashPipe,"|");return r}function wl(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function kO(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function X0(e,t,n,r,i){let o=t.href,c=t.title||null,u=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let f={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:c,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,f}function wO(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
131
- `).map(o=>{let c=o.match(n.other.beginningSpace);if(c===null)return o;let[u]=c;return u.length>=i.length?o.slice(i.length):o}).join(`
132
- `)}var Ku=class{constructor(e){ut(this,"options");ut(this,"rules");ut(this,"lexer");this.options=e||za}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:wl(n,`
133
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=wO(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=wl(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:wl(t[0],`
134
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=wl(t[0],`
135
- `).split(`
136
- `),r="",i="",o=[];for(;n.length>0;){let c=!1,u=[],f;for(f=0;f<n.length;f++)if(this.rules.other.blockquoteStart.test(n[f]))u.push(n[f]),c=!0;else if(!c)u.push(n[f]);else break;n=n.slice(f);let d=u.join(`
137
- `),p=d.replace(this.rules.other.blockquoteSetextReplace,`
138
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
139
- ${d}`:d,i=i?`${i}
140
- ${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,o,!0),this.lexer.state.top=m,n.length===0)break;let g=o.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let v=g,y=v.raw+`
141
- `+n.join(`
142
- `),S=this.blockquote(y);o[o.length-1]=S,r=r.substring(0,r.length-v.raw.length)+S.raw,i=i.substring(0,i.length-v.text.length)+S.text;break}else if((g==null?void 0:g.type)==="list"){let v=g,y=v.raw+`
143
- `+n.join(`
144
- `),S=this.list(y);o[o.length-1]=S,r=r.substring(0,r.length-g.raw.length)+S.raw,i=i.substring(0,i.length-v.raw.length)+S.raw,n=y.substring(o.at(-1).raw.length).split(`
145
- `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),c=!1;for(;e;){let f=!1,d="",p="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let m=t[2].split(`
146
- `,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),g=e.split(`
147
- `,1)[0],v=!m.trim(),y=0;if(this.options.pedantic?(y=2,p=m.trimStart()):v?y=t[1].length+1:(y=t[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,p=m.slice(y),y+=t[1].length),v&&this.rules.other.blankLine.test(g)&&(d+=g+`
148
- `,e=e.substring(g.length+1),f=!0),!f){let w=this.rules.other.nextBulletRegex(y),A=this.rules.other.hrRegex(y),N=this.rules.other.fencesBeginRegex(y),R=this.rules.other.headingBeginRegex(y),D=this.rules.other.htmlBeginRegex(y);for(;e;){let P=e.split(`
149
- `,1)[0],F;if(g=P,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),F=g):F=g.replace(this.rules.other.tabCharGlobal," "),N.test(g)||R.test(g)||D.test(g)||w.test(g)||A.test(g))break;if(F.search(this.rules.other.nonSpaceChar)>=y||!g.trim())p+=`
150
- `+F.slice(y);else{if(v||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(m)||R.test(m)||A.test(m))break;p+=`
151
- `+g}!v&&!g.trim()&&(v=!0),d+=P+`
152
- `,e=e.substring(P.length+1),m=F.slice(y)}}i.loose||(c?i.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(c=!0));let S=null,k;this.options.gfm&&(S=this.rules.other.listIsTask.exec(p),S&&(k=S[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:d,task:!!S,checked:k,loose:!1,text:p,tokens:[]}),i.raw+=d}let u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let f=0;f<i.items.length;f++)if(this.lexer.state.top=!1,i.items[f].tokens=this.lexer.blockTokens(i.items[f].text,[]),!i.loose){let d=i.items[f].tokens.filter(m=>m.type==="space"),p=d.length>0&&d.some(m=>this.rules.other.anyLine.test(m.raw));i.loose=p}if(i.loose)for(let f=0;f<i.items.length;f++)i.items[f].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Y0(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
153
- `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?o.align.push("right"):this.rules.other.tableAlignCenter.test(u)?o.align.push("center"):this.rules.other.tableAlignLeft.test(u)?o.align.push("left"):o.align.push(null);for(let u=0;u<n.length;u++)o.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:o.align[u]});for(let u of i)o.rows.push(Y0(u,o.header.length).map((f,d)=>({text:f,tokens:this.lexer.inline(f),header:!1,align:o.align[d]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
154
- `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=wl(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=kO(t[2],"()");if(o===-2)return;if(o>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),X0(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return X0(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,c,u=i,f=0,d=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(c=[...o].length,r[3]||r[4]){u+=c;continue}else if((r[5]||r[6])&&i%3&&!((i+c)%3)){f+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+f);let p=[...r[0]][0].length,m=e.slice(0,i+r.index+p+c);if(Math.min(i,c)%2){let v=m.slice(1,-1);return{type:"em",raw:m,text:v,tokens:this.lexer.inlineTokens(v)}}let g=m.slice(2,-2);return{type:"strong",raw:m,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},hr=class Gp{constructor(t){ut(this,"tokens");ut(this,"options");ut(this,"state");ut(this,"tokenizer");ut(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||za,this.options.tokenizer=this.options.tokenizer||new Ku,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:ss,block:xu.normal,inline:kl.normal};this.options.pedantic?(n.block=xu.pedantic,n.inline=kl.pedantic):this.options.gfm&&(n.block=xu.gfm,this.options.breaks?n.inline=kl.breaks:n.inline=kl.gfm),this.tokenizer.rules=n}static get rules(){return{block:xu,inline:kl}}static lex(t,n){return new Gp(n).lex(t)}static lexInline(t,n){return new Gp(n).inlineTokens(t)}lex(t){t=t.replace(ss.carriageReturn,`
155
- `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,o,c;for(this.options.pedantic&&(t=t.replace(ss.tabCharGlobal," ").replace(ss.spaceLine,""));t;){let u;if((o=(i=this.options.extensions)==null?void 0:i.block)!=null&&o.some(d=>(u=d.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let d=n.at(-1);u.raw.length===1&&d!==void 0?d.raw+=`
156
- `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
157
- `)?"":`
158
- `)+u.raw,d.text+=`
159
- `+u.text,this.inlineQueue.at(-1).src=d.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
160
- `)?"":`
161
- `)+u.raw,d.text+=`
162
- `+u.raw,this.inlineQueue.at(-1).src=d.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let f=t;if((c=this.options.extensions)!=null&&c.startBlock){let d=1/0,p=t.slice(1),m;this.options.extensions.startBlock.forEach(g=>{m=g.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(f=t.substring(0,d+1))}if(this.state.top&&(u=this.tokenizer.paragraph(f))){let d=n.at(-1);r&&(d==null?void 0:d.type)==="paragraph"?(d.raw+=(d.raw.endsWith(`
163
- `)?"":`
164
- `)+u.raw,d.text+=`
165
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(u),r=f.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
166
- `)?"":`
167
- `)+u.raw,d.text+=`
168
- `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(u);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var f,d,p,m,g;let r=t,i=null;if(this.tokens.links){let v=Object.keys(this.tokens.links);if(v.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)v.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)o=i[2]?i[2].length:0,r=r.slice(0,i.index+o)+"["+"a".repeat(i[0].length-o-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((d=(f=this.options.hooks)==null?void 0:f.emStrongMask)==null?void 0:d.call({lexer:this},r))??r;let c=!1,u="";for(;t;){c||(u=""),c=!1;let v;if((m=(p=this.options.extensions)==null?void 0:p.inline)!=null&&m.some(S=>(v=S.call({lexer:this},t,n))?(t=t.substring(v.raw.length),n.push(v),!0):!1))continue;if(v=this.tokenizer.escape(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.tag(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.link(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(v.raw.length);let S=n.at(-1);v.type==="text"&&(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(v=this.tokenizer.emStrong(t,r,u)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.codespan(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.br(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.del(t)){t=t.substring(v.raw.length),n.push(v);continue}if(v=this.tokenizer.autolink(t)){t=t.substring(v.raw.length),n.push(v);continue}if(!this.state.inLink&&(v=this.tokenizer.url(t))){t=t.substring(v.raw.length),n.push(v);continue}let y=t;if((g=this.options.extensions)!=null&&g.startInline){let S=1/0,k=t.slice(1),w;this.options.extensions.startInline.forEach(A=>{w=A.call({lexer:this},k),typeof w=="number"&&w>=0&&(S=Math.min(S,w))}),S<1/0&&S>=0&&(y=t.substring(0,S+1))}if(v=this.tokenizer.inlineText(y)){t=t.substring(v.raw.length),v.raw.slice(-1)!=="_"&&(u=v.raw.slice(-1)),c=!0;let S=n.at(-1);(S==null?void 0:S.type)==="text"?(S.raw+=v.raw,S.text+=v.text):n.push(v);continue}if(t){let S="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(S);break}else throw new Error(S)}}return n}},Yu=class{constructor(e){ut(this,"options");ut(this,"parser");this.options=e||za}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let r=(o=(t||"").match(ss.notSpaceStart))==null?void 0:o[0],i=e.replace(ss.endingNewline,"")+`
169
- `;return r?'<pre><code class="language-'+Or(r)+'">'+(n?i:Or(i,!0))+`</code></pre>
170
- `:"<pre><code>"+(n?i:Or(i,!0))+`</code></pre>
171
- `}blockquote({tokens:e}){return`<blockquote>
172
- ${this.parser.parse(e)}</blockquote>
173
- `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
174
- `}hr(e){return`<hr>
175
- `}list(e){let t=e.ordered,n=e.start,r="";for(let c=0;c<e.items.length;c++){let u=e.items[c];r+=this.listitem(u)}let i=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
176
- `+r+"</"+i+`>
177
- `}listitem(e){var n;let t="";if(e.task){let r=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.type)==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+Or(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):t+=r+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
178
- `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
179
- `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let o=e.rows[i];n="";for(let c=0;c<o.length;c++)n+=this.tablecell(o[c]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
180
- <thead>
181
- `+t+`</thead>
182
- `+r+`</table>
183
- `}tablerow({text:e}){return`<tr>
184
- ${e}</tr>
185
- `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
186
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Or(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=K0(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+Or(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=K0(e);if(i===null)return Or(n);e=i;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Or(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Or(e.text)}},Bm=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}},pr=class Kp{constructor(t){ut(this,"options");ut(this,"renderer");ut(this,"textRenderer");this.options=t||za,this.options.renderer=this.options.renderer||new Yu,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Bm}static parse(t,n){return new Kp(n).parse(t)}static parseInline(t,n){return new Kp(n).parseInline(t)}parse(t,n=!0){var i,o;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[u.type]){let d=u,p=this.options.extensions.renderers[d.type].call({parser:this},d);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){r+=p||"";continue}}let f=u;switch(f.type){case"space":{r+=this.renderer.space(f);continue}case"hr":{r+=this.renderer.hr(f);continue}case"heading":{r+=this.renderer.heading(f);continue}case"code":{r+=this.renderer.code(f);continue}case"table":{r+=this.renderer.table(f);continue}case"blockquote":{r+=this.renderer.blockquote(f);continue}case"list":{r+=this.renderer.list(f);continue}case"html":{r+=this.renderer.html(f);continue}case"def":{r+=this.renderer.def(f);continue}case"paragraph":{r+=this.renderer.paragraph(f);continue}case"text":{let d=f,p=this.renderer.text(d);for(;c+1<t.length&&t[c+1].type==="text";)d=t[++c],p+=`
187
- `+this.renderer.text(d);n?r+=this.renderer.paragraph({type:"paragraph",raw:p,text:p,tokens:[{type:"text",raw:p,text:p,escaped:!0}]}):r+=p;continue}default:{let d='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}parseInline(t,n=this.renderer){var i,o;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[u.type]){let d=this.options.extensions.renderers[u.type].call({parser:this},u);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){r+=d||"";continue}}let f=u;switch(f.type){case"escape":{r+=n.text(f);break}case"html":{r+=n.html(f);break}case"link":{r+=n.link(f);break}case"image":{r+=n.image(f);break}case"strong":{r+=n.strong(f);break}case"em":{r+=n.em(f);break}case"codespan":{r+=n.codespan(f);break}case"br":{r+=n.br(f);break}case"del":{r+=n.del(f);break}case"text":{r+=n.text(f);break}default:{let d='Token with "'+f.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}},$u,Il=($u=class{constructor(e){ut(this,"options");ut(this,"block");this.options=e||za}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?hr.lex:hr.lexInline}provideParser(){return this.block?pr.parse:pr.parseInline}},ut($u,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ut($u,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),$u),NO=class{constructor(...e){ut(this,"defaults",Mm());ut(this,"options",this.setOptions);ut(this,"parse",this.parseMarkdown(!0));ut(this,"parseInline",this.parseMarkdown(!1));ut(this,"Parser",pr);ut(this,"Renderer",Yu);ut(this,"TextRenderer",Bm);ut(this,"Lexer",hr);ut(this,"Tokenizer",Ku);ut(this,"Hooks",Il);this.use(...e)}walkTokens(e,t){var r,i;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let c=o;for(let u of c.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of c.rows)for(let f of u)n=n.concat(this.walkTokens(f.tokens,t));break}case"list":{let c=o;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=o;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let f=c[u].flat(1/0);n=n.concat(this.walkTokens(f,t))}):c.tokens&&(n=n.concat(this.walkTokens(c.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=t.renderers[i.name];o?t.renderers[i.name]=function(...c){let u=i.renderer.apply(this,c);return u===!1&&(u=o.apply(this,c)),u}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new Yu(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let c=o,u=n.renderer[c],f=i[c];i[c]=(...d)=>{let p=u.apply(i,d);return p===!1&&(p=f.apply(i,d)),p||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Ku(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let c=o,u=n.tokenizer[c],f=i[c];i[c]=(...d)=>{let p=u.apply(i,d);return p===!1&&(p=f.apply(i,d)),p}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Il;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let c=o,u=n.hooks[c],f=i[c];Il.passThroughHooks.has(o)?i[c]=d=>{if(this.defaults.async&&Il.passThroughHooksRespectAsync.has(o))return(async()=>{let m=await u.call(i,d);return f.call(i,m)})();let p=u.call(i,d);return f.call(i,p)}:i[c]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await u.apply(i,d);return m===!1&&(m=await f.apply(i,d)),m})();let p=u.apply(i,d);return p===!1&&(p=f.apply(i,d)),p}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(c){let u=[];return u.push(o.call(this,c)),i&&(u=u.concat(i.call(this,c))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return hr.lex(e,t??this.defaults)}parser(e,t){return pr.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let c=i.hooks?await i.hooks.preprocess(t):t,u=await(i.hooks?await i.hooks.provideLexer():e?hr.lex:hr.lexInline)(c,i),f=i.hooks?await i.hooks.processAllTokens(u):u;i.walkTokens&&await Promise.all(this.walkTokens(f,i.walkTokens));let d=await(i.hooks?await i.hooks.provideParser():e?pr.parse:pr.parseInline)(f,i);return i.hooks?await i.hooks.postprocess(d):d})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let c=(i.hooks?i.hooks.provideLexer():e?hr.lex:hr.lexInline)(t,i);i.hooks&&(c=i.hooks.processAllTokens(c)),i.walkTokens&&this.walkTokens(c,i.walkTokens);let u=(i.hooks?i.hooks.provideParser():e?pr.parse:pr.parseInline)(c,i);return i.hooks&&(u=i.hooks.postprocess(u)),u}catch(c){return o(c)}}}onError(e,t){return n=>{if(n.message+=`
188
- Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Or(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ea=new NO;function Ct(e,t){return Ea.parse(e,t)}Ct.options=Ct.setOptions=function(e){return Ea.setOptions(e),Ct.defaults=Ea.defaults,Rw(Ct.defaults),Ct};Ct.getDefaults=Mm;Ct.defaults=za;Ct.use=function(...e){return Ea.use(...e),Ct.defaults=Ea.defaults,Rw(Ct.defaults),Ct};Ct.walkTokens=function(e,t){return Ea.walkTokens(e,t)};Ct.parseInline=Ea.parseInline;Ct.Parser=pr;Ct.parser=pr.parse;Ct.Renderer=Yu;Ct.TextRenderer=Bm;Ct.Lexer=hr;Ct.lexer=hr.lex;Ct.Tokenizer=Ku;Ct.Hooks=Il;Ct.parse=Ct;Ct.options;Ct.setOptions;Ct.use;Ct.walkTokens;Ct.parseInline;pr.parse;hr.lex;var Bh,Q0;function jO(){if(Q0)return Bh;Q0=1;function e(Q){return Q instanceof Map?Q.clear=Q.delete=Q.set=function(){throw new Error("map is read-only")}:Q instanceof Set&&(Q.add=Q.clear=Q.delete=function(){throw new Error("set is read-only")}),Object.freeze(Q),Object.getOwnPropertyNames(Q).forEach(pe=>{const Oe=Q[pe],st=typeof Oe;(st==="object"||st==="function")&&!Object.isFrozen(Oe)&&e(Oe)}),Q}class t{constructor(pe){pe.data===void 0&&(pe.data={}),this.data=pe.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Q){return Q.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(Q,...pe){const Oe=Object.create(null);for(const st in Q)Oe[st]=Q[st];return pe.forEach(function(st){for(const It in st)Oe[It]=st[It]}),Oe}const i="</span>",o=Q=>!!Q.scope,c=(Q,{prefix:pe})=>{if(Q.startsWith("language:"))return Q.replace("language:","language-");if(Q.includes(".")){const Oe=Q.split(".");return[`${pe}${Oe.shift()}`,...Oe.map((st,It)=>`${st}${"_".repeat(It+1)}`)].join(" ")}return`${pe}${Q}`};class u{constructor(pe,Oe){this.buffer="",this.classPrefix=Oe.classPrefix,pe.walk(this)}addText(pe){this.buffer+=n(pe)}openNode(pe){if(!o(pe))return;const Oe=c(pe.scope,{prefix:this.classPrefix});this.span(Oe)}closeNode(pe){o(pe)&&(this.buffer+=i)}value(){return this.buffer}span(pe){this.buffer+=`<span class="${pe}">`}}const f=(Q={})=>{const pe={children:[]};return Object.assign(pe,Q),pe};class d{constructor(){this.rootNode=f(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(pe){this.top.children.push(pe)}openNode(pe){const Oe=f({scope:pe});this.add(Oe),this.stack.push(Oe)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(pe){return this.constructor._walk(pe,this.rootNode)}static _walk(pe,Oe){return typeof Oe=="string"?pe.addText(Oe):Oe.children&&(pe.openNode(Oe),Oe.children.forEach(st=>this._walk(pe,st)),pe.closeNode(Oe)),pe}static _collapse(pe){typeof pe!="string"&&pe.children&&(pe.children.every(Oe=>typeof Oe=="string")?pe.children=[pe.children.join("")]:pe.children.forEach(Oe=>{d._collapse(Oe)}))}}class p extends d{constructor(pe){super(),this.options=pe}addText(pe){pe!==""&&this.add(pe)}startScope(pe){this.openNode(pe)}endScope(){this.closeNode()}__addSublanguage(pe,Oe){const st=pe.root;Oe&&(st.scope=`language:${Oe}`),this.add(st)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(Q){return Q?typeof Q=="string"?Q:Q.source:null}function g(Q){return S("(?=",Q,")")}function v(Q){return S("(?:",Q,")*")}function y(Q){return S("(?:",Q,")?")}function S(...Q){return Q.map(Oe=>m(Oe)).join("")}function k(Q){const pe=Q[Q.length-1];return typeof pe=="object"&&pe.constructor===Object?(Q.splice(Q.length-1,1),pe):{}}function w(...Q){return"("+(k(Q).capture?"":"?:")+Q.map(st=>m(st)).join("|")+")"}function A(Q){return new RegExp(Q.toString()+"|").exec("").length-1}function N(Q,pe){const Oe=Q&&Q.exec(pe);return Oe&&Oe.index===0}const R=new RegExp(w(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function D(Q,{joinWith:pe}){let Oe=0;return Q.map(st=>{Oe+=1;const It=Oe;let $t=m(st),Be="";for(;$t.length>0;){const De=R.exec($t);if(!De){Be+=$t;break}Be+=$t.substring(0,De.index),$t=$t.substring(De.index+De[0].length),De[0][0]==="\\"&&De[1]?Be+="\\"+String(Number(De[1])+It):(Be+=De[0],(De[0]==="("||/^\(\?[<']/.test(De[0]))&&Oe++)}return Be}).map(st=>`(${st})`).join(pe)}const P=/\b\B/,F="[a-zA-Z]\\w*",W="[a-zA-Z_]\\w*",M="\\b\\d+(\\.\\d+)?",O="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",T="\\b(0b[01]+)",Z="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",E=(Q={})=>{const pe=/^#![ ]*\//;return Q.binary&&(Q.begin=S(pe,/.*\b/,Q.binary,/\b.*/)),r({scope:"meta",begin:pe,end:/$/,relevance:0,"on:begin":(Oe,st)=>{Oe.index!==0&&st.ignoreMatch()}},Q)},C={begin:"\\\\[\\s\\S]",relevance:0},$={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[C]},L={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[C]},B={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},H=function(Q,pe,Oe={}){const st=r({scope:"comment",begin:Q,end:pe,contains:[]},Oe);st.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const It=w("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return st.contains.push({begin:S(/[ ]+/,"(",It,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),st},G=H("//","$"),K=H("/\\*","\\*/"),V=H("#","$"),Y={scope:"number",begin:M,relevance:0},fe={scope:"number",begin:O,relevance:0},xe={scope:"number",begin:T,relevance:0},ge={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[C,{begin:/\[/,end:/\]/,relevance:0,contains:[C]}]},ie={scope:"title",begin:F,relevance:0},ke={scope:"title",begin:W,relevance:0},ae={begin:"\\.\\s*"+W,relevance:0};var Fe=Object.freeze({__proto__:null,APOS_STRING_MODE:$,BACKSLASH_ESCAPE:C,BINARY_NUMBER_MODE:xe,BINARY_NUMBER_RE:T,COMMENT:H,C_BLOCK_COMMENT_MODE:K,C_LINE_COMMENT_MODE:G,C_NUMBER_MODE:fe,C_NUMBER_RE:O,END_SAME_AS_BEGIN:function(Q){return Object.assign(Q,{"on:begin":(pe,Oe)=>{Oe.data._beginMatch=pe[1]},"on:end":(pe,Oe)=>{Oe.data._beginMatch!==pe[1]&&Oe.ignoreMatch()}})},HASH_COMMENT_MODE:V,IDENT_RE:F,MATCH_NOTHING_RE:P,METHOD_GUARD:ae,NUMBER_MODE:Y,NUMBER_RE:M,PHRASAL_WORDS_MODE:B,QUOTE_STRING_MODE:L,REGEXP_MODE:ge,RE_STARTERS_RE:Z,SHEBANG:E,TITLE_MODE:ie,UNDERSCORE_IDENT_RE:W,UNDERSCORE_TITLE_MODE:ke});function ce(Q,pe){Q.input[Q.index-1]==="."&&pe.ignoreMatch()}function Se(Q,pe){Q.className!==void 0&&(Q.scope=Q.className,delete Q.className)}function re(Q,pe){pe&&Q.beginKeywords&&(Q.begin="\\b("+Q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Q.__beforeBegin=ce,Q.keywords=Q.keywords||Q.beginKeywords,delete Q.beginKeywords,Q.relevance===void 0&&(Q.relevance=0))}function he(Q,pe){Array.isArray(Q.illegal)&&(Q.illegal=w(...Q.illegal))}function Le(Q,pe){if(Q.match){if(Q.begin||Q.end)throw new Error("begin & end are not supported with match");Q.begin=Q.match,delete Q.match}}function Te(Q,pe){Q.relevance===void 0&&(Q.relevance=1)}const Ge=(Q,pe)=>{if(!Q.beforeMatch)return;if(Q.starts)throw new Error("beforeMatch cannot be used with starts");const Oe=Object.assign({},Q);Object.keys(Q).forEach(st=>{delete Q[st]}),Q.keywords=Oe.keywords,Q.begin=S(Oe.beforeMatch,g(Oe.begin)),Q.starts={relevance:0,contains:[Object.assign(Oe,{endsParent:!0})]},Q.relevance=0,delete Oe.beforeMatch},Ie=["of","and","for","in","not","or","if","then","parent","list","value"],tt="keyword";function et(Q,pe,Oe=tt){const st=Object.create(null);return typeof Q=="string"?It(Oe,Q.split(" ")):Array.isArray(Q)?It(Oe,Q):Object.keys(Q).forEach(function($t){Object.assign(st,et(Q[$t],pe,$t))}),st;function It($t,Be){pe&&(Be=Be.map(De=>De.toLowerCase())),Be.forEach(function(De){const Xe=De.split("|");st[Xe[0]]=[$t,jt(Xe[0],Xe[1])]})}}function jt(Q,pe){return pe?Number(pe):On(Q)?0:1}function On(Q){return Ie.includes(Q.toLowerCase())}const sn={},ln=Q=>{console.error(Q)},cn=(Q,...pe)=>{console.log(`WARN: ${Q}`,...pe)},rn=(Q,pe)=>{sn[`${Q}/${pe}`]||(console.log(`Deprecated as of ${Q}. ${pe}`),sn[`${Q}/${pe}`]=!0)},an=new Error;function Ft(Q,pe,{key:Oe}){let st=0;const It=Q[Oe],$t={},Be={};for(let De=1;De<=pe.length;De++)Be[De+st]=It[De],$t[De+st]=!0,st+=A(pe[De-1]);Q[Oe]=Be,Q[Oe]._emit=$t,Q[Oe]._multi=!0}function Bn(Q){if(Array.isArray(Q.begin)){if(Q.skip||Q.excludeBegin||Q.returnBegin)throw ln("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),an;if(typeof Q.beginScope!="object"||Q.beginScope===null)throw ln("beginScope must be object"),an;Ft(Q,Q.begin,{key:"beginScope"}),Q.begin=D(Q.begin,{joinWith:""})}}function wn(Q){if(Array.isArray(Q.end)){if(Q.skip||Q.excludeEnd||Q.returnEnd)throw ln("skip, excludeEnd, returnEnd not compatible with endScope: {}"),an;if(typeof Q.endScope!="object"||Q.endScope===null)throw ln("endScope must be object"),an;Ft(Q,Q.end,{key:"endScope"}),Q.end=D(Q.end,{joinWith:""})}}function ws(Q){Q.scope&&typeof Q.scope=="object"&&Q.scope!==null&&(Q.beginScope=Q.scope,delete Q.scope)}function _r(Q){ws(Q),typeof Q.beginScope=="string"&&(Q.beginScope={_wrap:Q.beginScope}),typeof Q.endScope=="string"&&(Q.endScope={_wrap:Q.endScope}),Bn(Q),wn(Q)}function Ks(Q){function pe(Be,De){return new RegExp(m(Be),"m"+(Q.case_insensitive?"i":"")+(Q.unicodeRegex?"u":"")+(De?"g":""))}class Oe{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(De,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,De]),this.matchAt+=A(De)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const De=this.regexes.map(Xe=>Xe[1]);this.matcherRe=pe(D(De,{joinWith:"|"}),!0),this.lastIndex=0}exec(De){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(De);if(!Xe)return null;const bt=Xe.findIndex((Un,is)=>is>0&&Un!==void 0),yt=this.matchIndexes[bt];return Xe.splice(0,bt),Object.assign(Xe,yt)}}class st{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(De){if(this.multiRegexes[De])return this.multiRegexes[De];const Xe=new Oe;return this.rules.slice(De).forEach(([bt,yt])=>Xe.addRule(bt,yt)),Xe.compile(),this.multiRegexes[De]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(De,Xe){this.rules.push([De,Xe]),Xe.type==="begin"&&this.count++}exec(De){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let bt=Xe.exec(De);if(this.resumingScanAtSamePosition()&&!(bt&&bt.index===this.lastIndex)){const yt=this.getMatcher(0);yt.lastIndex=this.lastIndex+1,bt=yt.exec(De)}return bt&&(this.regexIndex+=bt.position+1,this.regexIndex===this.count&&this.considerAll()),bt}}function It(Be){const De=new st;return Be.contains.forEach(Xe=>De.addRule(Xe.begin,{rule:Xe,type:"begin"})),Be.terminatorEnd&&De.addRule(Be.terminatorEnd,{type:"end"}),Be.illegal&&De.addRule(Be.illegal,{type:"illegal"}),De}function $t(Be,De){const Xe=Be;if(Be.isCompiled)return Xe;[Se,Le,_r,Ge].forEach(yt=>yt(Be,De)),Q.compilerExtensions.forEach(yt=>yt(Be,De)),Be.__beforeBegin=null,[re,he,Te].forEach(yt=>yt(Be,De)),Be.isCompiled=!0;let bt=null;return typeof Be.keywords=="object"&&Be.keywords.$pattern&&(Be.keywords=Object.assign({},Be.keywords),bt=Be.keywords.$pattern,delete Be.keywords.$pattern),bt=bt||/\w+/,Be.keywords&&(Be.keywords=et(Be.keywords,Q.case_insensitive)),Xe.keywordPatternRe=pe(bt,!0),De&&(Be.begin||(Be.begin=/\B|\b/),Xe.beginRe=pe(Xe.begin),!Be.end&&!Be.endsWithParent&&(Be.end=/\B|\b/),Be.end&&(Xe.endRe=pe(Xe.end)),Xe.terminatorEnd=m(Xe.end)||"",Be.endsWithParent&&De.terminatorEnd&&(Xe.terminatorEnd+=(Be.end?"|":"")+De.terminatorEnd)),Be.illegal&&(Xe.illegalRe=pe(Be.illegal)),Be.contains||(Be.contains=[]),Be.contains=[].concat(...Be.contains.map(function(yt){return Ms(yt==="self"?Be:yt)})),Be.contains.forEach(function(yt){$t(yt,Xe)}),Be.starts&&$t(Be.starts,De),Xe.matcher=It(Xe),Xe}if(Q.compilerExtensions||(Q.compilerExtensions=[]),Q.contains&&Q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Q.classNameAliases=r(Q.classNameAliases||{}),$t(Q)}function Ys(Q){return Q?Q.endsWithParent||Ys(Q.starts):!1}function Ms(Q){return Q.variants&&!Q.cachedVariants&&(Q.cachedVariants=Q.variants.map(function(pe){return r(Q,{variants:null},pe)})),Q.cachedVariants?Q.cachedVariants:Ys(Q)?r(Q,{starts:Q.starts?r(Q.starts):null}):Object.isFrozen(Q)?r(Q):Q}var Rs="11.12.0";class Os extends Error{constructor(pe,Oe){super(pe),this.name="HTMLInjectionError",this.html=Oe}}const zs=n,Xs=r,Qs=Symbol("nomatch"),rs=7,Yn=function(Q){const pe=Object.create(null),Oe=Object.create(null),st=[];let It=!0;const $t="Could not find the language '{}', did you forget to load/include a language module?",Be={disableAutodetect:!0,name:"Plain text",contains:[]};let De={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Xe(Ae){return De.noHighlightRe.test(Ae)}function bt(Ae){let Ze=Ae.className+" ";Ze+=Ae.parentNode?Ae.parentNode.className:"";const ct=De.languageDetectRe.exec(Ze);if(ct){const ft=Xn(ct[1]);return ft||(cn($t.replace("{}",ct[1])),cn("Falling back to no-highlight mode for this block.",Ae)),ft?ct[1]:"no-highlight"}return Ze.split(/\s+/).find(ft=>Xe(ft)||Xn(ft))}function yt(Ae,Ze,ct){let ft="",At="";typeof Ze=="object"?(ft=Ae,ct=Ze.ignoreIllegals,At=Ze.language):(rn("10.7.0","highlight(lang, code, ...args) has been deprecated."),rn("10.7.0",`Please use highlight(code, options) instead.
189
- https://github.com/highlightjs/highlight.js/issues/2277`),At=Ae,ft=Ze),ct===void 0&&(ct=!0);const zt={code:ft,language:At};nr("before:highlight",zt);const Zn=zt.result?zt.result:Un(zt.language,zt.code,ct);return Zn.code=zt.code,nr("after:highlight",Zn),Zn}function Un(Ae,Ze,ct,ft){const At=Object.create(null);function zt($e,Ue){return $e.keywords[Ue]}function Zn(){if(!at.keywords){Pt.addText(ht);return}let $e=0;at.keywordPatternRe.lastIndex=0;let Ue=at.keywordPatternRe.exec(ht),ot="";for(;Ue;){ot+=ht.substring($e,Ue.index);const gt=Sn.case_insensitive?Ue[0].toLowerCase():Ue[0],Bt=zt(at,gt);if(Bt){const[pn,Bo]=Bt;if(Pt.addText(ot),ot="",At[gt]=(At[gt]||0)+1,At[gt]<=rs&&(Zr+=Bo),pn.startsWith("_"))ot+=Ue[0];else{const Ji=Sn.classNameAliases[pn]||pn;jn(Ue[0],Ji)}}else ot+=Ue[0];$e=at.keywordPatternRe.lastIndex,Ue=at.keywordPatternRe.exec(ht)}ot+=ht.substring($e),Pt.addText(ot)}function Ps(){if(ht==="")return;let $e=null;if(typeof at.subLanguage=="string"){if(!pe[at.subLanguage]){Pt.addText(ht);return}$e=Un(at.subLanguage,ht,!0,cs[at.subLanguage]),cs[at.subLanguage]=$e._top}else $e=Js(ht,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Zr+=$e.relevance),Pt.__addSublanguage($e._emitter,$e.language)}function un(){at.subLanguage!=null?Ps():Zn(),ht=""}function jn($e,Ue){$e!==""&&(Pt.startScope(Ue),Pt.addText($e),Pt.endScope())}function Ls($e,Ue){let ot=1;const gt=Ue.length-1;for(;ot<=gt;){if(!$e._emit[ot]){ot++;continue}const Bt=Sn.classNameAliases[$e[ot]]||$e[ot],pn=Ue[ot];Bt?jn(pn,Bt):(ht=pn,Zn(),ht=""),ot++}}function Ds($e,Ue){return $e.scope&&typeof $e.scope=="string"&&Pt.openNode(Sn.classNameAliases[$e.scope]||$e.scope),$e.beginScope&&($e.beginScope._wrap?(jn(ht,Sn.classNameAliases[$e.beginScope._wrap]||$e.beginScope._wrap),ht=""):$e.beginScope._multi&&(Ls($e.beginScope,Ue),ht="")),at=Object.create($e,{parent:{value:at}}),at}function os($e,Ue,ot){let gt=N($e.endRe,ot);if(gt){if($e["on:end"]){const Bt=new t($e);$e["on:end"](Ue,Bt),Bt.isMatchIgnored&&(gt=!1)}if(gt){for(;$e.endsParent&&$e.parent;)$e=$e.parent;return $e}}if($e.endsWithParent)return os($e.parent,Ue,ot)}function Qi($e){return at.matcher.regexIndex===0?(ht+=$e[0],1):(sr=!0,0)}function xi($e){const Ue=$e[0],ot=$e.rule,gt=new t(ot),Bt=[ot.__beforeBegin,ot["on:begin"]];for(const pn of Bt)if(pn&&(pn($e,gt),gt.isMatchIgnored))return Qi(Ue);return ot.skip?ht+=Ue:(ot.excludeBegin&&(ht+=Ue),un(),!ot.returnBegin&&!ot.excludeBegin&&(ht=Ue)),Ds(ot,$e),ot.returnBegin?0:Ue.length}function Ir($e){const Ue=$e[0],ot=Ze.substring($e.index),gt=os(at,$e,ot);if(!gt)return Qs;const Bt=at;at.endScope&&at.endScope._wrap?(un(),jn(Ue,at.endScope._wrap)):at.endScope&&at.endScope._multi?(un(),Ls(at.endScope,$e)):Bt.skip?ht+=Ue:(Bt.returnEnd||Bt.excludeEnd||(ht+=Ue),un(),Bt.excludeEnd&&(ht=Ue));do at.scope&&Pt.closeNode(),!at.skip&&!at.subLanguage&&(Zr+=at.relevance),at=at.parent;while(at!==gt.parent);return gt.starts&&Ds(gt.starts,$e),Bt.returnEnd?0:Ue.length}function vi(){const $e=[];for(let Ue=at;Ue!==Sn;Ue=Ue.parent)Ue.scope&&$e.unshift(Ue.scope);$e.forEach(Ue=>Pt.openNode(Ue))}let Qn={};function ls($e,Ue){const ot=Ue&&Ue[0];if(ht+=$e,ot==null)return un(),0;if(Qn.type==="begin"&&Ue.type==="end"&&Qn.index===Ue.index&&ot===""){if(ht+=Ze.slice(Ue.index,Ue.index+1),!It){const gt=new Error(`0 width match regex (${Ae})`);throw gt.languageName=Ae,gt.badRule=Qn.rule,gt}return 1}if(Qn=Ue,Ue.type==="begin")return xi(Ue);if(Ue.type==="illegal"&&!ct){const gt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw gt.mode=at,gt}else if(Ue.type==="end"){const gt=Ir(Ue);if(gt!==Qs)return gt}if(Ue.type==="illegal"&&ot==="")return Ue.index===Ze.length||(ht+=`
190
- `),1;if(Wr>1e5&&Wr>Ue.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ht+=ot,ot.length}const Sn=Xn(Ae);if(!Sn)throw ln($t.replace("{}",Ae)),new Error('Unknown language: "'+Ae+'"');const Fs=Ks(Sn);let vt="",at=ft||Fs;const cs={},Pt=new De.__emitter(De);vi();let ht="",Zr=0,Jn=0,Wr=0,sr=!1;try{if(Sn.__emitTokens)Sn.__emitTokens(Ze,Pt);else{for(at.matcher.considerAll();;){Wr++,sr?sr=!1:at.matcher.considerAll(),at.matcher.lastIndex=Jn;const $e=at.matcher.exec(Ze);if(!$e)break;const Ue=Ze.substring(Jn,$e.index),ot=ls(Ue,$e);Jn=$e.index+ot}ls(Ze.substring(Jn))}return Pt.finalize(),vt=Pt.toHTML(),{language:Ae,value:vt,relevance:Zr,illegal:!1,_emitter:Pt,_top:at}}catch($e){if($e.message&&$e.message.includes("Illegal"))return{language:Ae,value:zs(Ze),illegal:!0,relevance:0,_illegalBy:{message:$e.message,index:Jn,context:Ze.slice(Jn-100,Jn+100),mode:$e.mode,resultSoFar:vt},_emitter:Pt};if(It)return{language:Ae,value:zs(Ze),illegal:!1,relevance:0,errorRaised:$e,_emitter:Pt,_top:at};throw $e}}function is(Ae){const Ze={value:zs(Ae),illegal:!1,relevance:0,_top:Be,_emitter:new De.__emitter(De)};return Ze._emitter.addText(Ae),Ze}function Js(Ae,Ze){Ze=Ze||De.languages||Object.keys(pe);const ct=is(Ae),ft=Ze.filter(Xn).filter(tr).map(un=>Un(un,Ae,!1));ft.unshift(ct);const At=ft.sort((un,jn)=>{if(un.relevance!==jn.relevance)return jn.relevance-un.relevance;if(un.language&&jn.language){if(Xn(un.language).supersetOf===jn.language)return 1;if(Xn(jn.language).supersetOf===un.language)return-1}return 0}),[zt,Zn]=At,Ps=zt;return Ps.secondBest=Zn,Ps}function hi(Ae,Ze,ct){const ft=Ze&&Oe[Ze]||ct;Ae.classList.add("hljs"),Ae.classList.add(`language-${ft}`)}function er(Ae){let Ze=null;const ct=bt(Ae);if(Xe(ct))return;if(nr("before:highlightElement",{el:Ae,language:ct}),Ae.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ae);return}if(Ae.children.length>0&&(De.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Ae)),De.throwUnescapedHTML))throw new Os("One of your code blocks includes unescaped HTML.",Ae.innerHTML);Ze=Ae;const ft=Ze.textContent,At=ct?yt(ft,{language:ct,ignoreIllegals:!0}):Js(ft);Ae.innerHTML=At.value,Ae.dataset.highlighted="yes",hi(Ae,ct,At.language),Ae.result={language:At.language,re:At.relevance,relevance:At.relevance},At.secondBest&&(Ae.secondBest={language:At.secondBest.language,relevance:At.secondBest.relevance}),nr("after:highlightElement",{el:Ae,result:At,text:ft})}function pi(Ae){De=Xs(De,Ae)}const Hn=()=>{Er(),rn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Br(){Er(),rn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let as=!1;function Er(){function Ae(){Er()}if(document.readyState==="loading"){as||window.addEventListener("DOMContentLoaded",Ae,!1),as=!0;return}document.querySelectorAll(De.cssSelector).forEach(er)}function mi(Ae,Ze){let ct=null;try{ct=Ze(Q)}catch(ft){if(ln("Language definition for '{}' could not be registered.".replace("{}",Ae)),It)ln(ft);else throw ft;ct=Be}ct.name||(ct.name=Ae),pe[Ae]=ct,ct.rawDefinition=Ze.bind(null,Q),ct.aliases&&Ur(ct.aliases,{languageName:Ae})}function Rt(Ae){delete pe[Ae];for(const Ze of Object.keys(Oe))Oe[Ze]===Ae&&delete Oe[Ze]}function Ns(){return Object.keys(pe)}function Xn(Ae){return Ae=(Ae||"").toLowerCase(),pe[Ae]||pe[Oe[Ae]]}function Ur(Ae,{languageName:Ze}){typeof Ae=="string"&&(Ae=[Ae]),Ae.forEach(ct=>{Oe[ct.toLowerCase()]=Ze})}function tr(Ae){const Ze=Xn(Ae);return Ze&&!Ze.disableAutodetect}function Ot(Ae){Ae["before:highlightBlock"]&&!Ae["before:highlightElement"]&&(Ae["before:highlightElement"]=Ze=>{Ae["before:highlightBlock"](Object.assign({block:Ze.el},Ze))}),Ae["after:highlightBlock"]&&!Ae["after:highlightElement"]&&(Ae["after:highlightElement"]=Ze=>{Ae["after:highlightBlock"](Object.assign({block:Ze.el},Ze))})}function gi(Ae){Ot(Ae),st.push(Ae)}function Hr(Ae){const Ze=st.indexOf(Ae);Ze!==-1&&st.splice(Ze,1)}function nr(Ae,Ze){const ct=Ae;st.forEach(function(ft){ft[ct]&&ft[ct](Ze)})}function Cr(Ae){return rn("10.7.0","highlightBlock will be removed entirely in v12.0"),rn("10.7.0","Please use highlightElement now."),er(Ae)}Object.assign(Q,{highlight:yt,highlightAuto:Js,highlightAll:Er,highlightElement:er,highlightBlock:Cr,configure:pi,initHighlighting:Hn,initHighlightingOnLoad:Br,registerLanguage:mi,unregisterLanguage:Rt,listLanguages:Ns,getLanguage:Xn,registerAliases:Ur,autoDetection:tr,inherit:Xs,addPlugin:gi,removePlugin:Hr}),Q.debugMode=function(){It=!1},Q.safeMode=function(){It=!0},Q.versionString=Rs,Q.regex={concat:S,lookahead:g,either:w,optional:y,anyNumberOfTimes:v};for(const Ae in Fe)typeof Fe[Ae]=="object"&&e(Fe[Ae]);return Object.assign(Q,Fe),Q},Nn=Yn({});return Nn.newInstance=()=>Yn({}),Bh=Nn,Nn.HighlightJS=Nn,Nn.default=Nn,Bh}var SO=jO();const wr=gm(SO);function _O(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(u);const f={match:/\\"/},d={className:"string",begin:/'/,end:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},S=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],k=["true","false"],w={match:/(\/[a-z._-]+)+/},A=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],N=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],R=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],D=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:S,literal:k,built_in:[...A,...N,"set","shopt",...R,...D]},contains:[v,e.SHEBANG(),y,m,o,c,w,u,f,d,p,n]}}const EO=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,5}(-[0-9A-Fa-f][0-9A-Fa-f]{0,5})?/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),CO=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],IO=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],AO=[...CO,...IO],TO=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),$O=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),MO=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),RO=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","corner-bottom-left-shape","corner-bottom-right-shape","corner-shape","corner-top-left-shape","corner-top-right-shape","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","unicode-range","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function OO(e){const t=e.regex,n=EO(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",o=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",u=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+$O.join("|")+")"},{begin:":(:)?("+MO.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+RO.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:TO.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+AO.join("|")+")\\b"}]}}function zO(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+,\d+ +\+\d+ +@@/,/^@@ +-\d+ +\+\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function PO(e){const o={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:o,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\b0[bB](_?[01])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:o,illegal:/["']/}]}]}}var fo="[0-9](_*[0-9])*",vu=`\\.(${fo})`,yu="[0-9a-fA-F](_*[0-9a-fA-F])*",J0={className:"number",variants:[{begin:`(\\b(${fo})((${vu})|\\.)?|(${vu}))[eE][+-]?(${fo})[fFdD]?\\b`},{begin:`\\b(${fo})((${vu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${vu})[fFdD]?\\b`},{begin:`\\b(${fo})[fFdD]\\b`},{begin:`\\b0[xX]((${yu})\\.?|(${yu})?\\.(${yu}))[pP][+-]?(${fo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${yu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Ww(e,t,n){return n===-1?"":e.replace(t,r=>Ww(e,t,n-1))}function LO(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r="(?:(?:\\s*\\[\\s*])+)?",i=n+"<@@@>"+r,c="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+i+")?")+"|"+i+")",u=Ww("(?:\\s*<\\s*"+c+"(?:\\s*,\\s*"+c+")*\\s*>)?",/<@@@>/g,2),g={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},v={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},y={className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:g,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{beginKeywords:"new throw return else yield assert",relevance:0},{begin:[n,t.concat(u,r,/\s+/),n,r,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[n,t.concat(u,r,/\s+/),n,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:g,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[v,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,J0,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},J0,v]}}const ey="[A-Za-z$_][0-9A-Za-z$_]*",DO=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],FO=["true","false","null","undefined","NaN","Infinity"],Vw=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],qw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Gw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],BO=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],UO=[].concat(Gw,Vw,qw);function HO(e){const t=e.regex,n=(H,{after:G})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,G)!==-1},r=ey,i={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,G)=>{const K=H[0].length+H.index,V=H.input[K];if(V==="<"||V===","){G.ignoreMatch();return}V===">"&&(n(H,{after:K})||G.ignoreMatch());let Y;const fe=H.input.substring(K);if(Y=fe.match(/^\s*=/)){G.ignoreMatch();return}if((Y=fe.match(/^\s+extends\s+/))&&Y.index===0){G.ignoreMatch();return}}},u={$pattern:ey,keyword:DO,literal:FO,built_in:UO,"variable.language":BO},f="[0-9](_?[0-9])*",d=`\\.(${f})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${d})|\\.)?|(${d}))[eE][+-]?(${f})\\b`},{begin:`\\b(${p})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},S={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},A={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(N)});const R=[].concat(A,g.contains),D=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(R)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D},F={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},W={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Vw,...qw]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},O={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},T={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z(H){return t.concat("(?!",H.join("|"),")")}const E={match:t.concat(/\b/,Z([...Gw,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},C={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},$={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",B={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:D,CLASS_REFERENCE:W},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,A,{match:/\$\d+/},m,W,{scope:"attr",match:r+t.lookahead(":"),relevance:0},B,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[A,e.REGEXP_MODE,{className:"function",begin:L,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},O,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},E,T,F,$,{match:/\$[(.]/}]}}const ZO="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",WO={scope:"number",match:ZO,relevance:0};function VO(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,WO,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function qO(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,f={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},d={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(d,{contains:[]}),g=e.inherit(p,{contains:[]});d.contains.push(g),p.contains.push(m);let v=[n,f];return[d,p,m,g].forEach(w=>{w.contains=w.contains.concat(v)}),v=v.concat(d,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,o,r,d,p,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},i,f,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function GO(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},f={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,f],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,f,p,d]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,f,p,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,d]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,d]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",v=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,S={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${v}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${v})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},k={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},w={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",f,S,m,e.HASH_COMMENT_MODE]}]};return d.contains=[m,S,f],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[f,S,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,k,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[w]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[S,w,m]}]}}function KO(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),o={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,i,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],f=["true","false","Some","None","Ok","Err"],d=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:u,literal:f,built_in:d},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:d,type:p}},{scope:"punctuation",begin:"->"},o]}}function YO(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],f=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],g=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],v=p,y=[...d,...f].filter(D=>!p.includes(D)),S={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},k={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},w={match:t.concat(/\b/,t.either(...v),/\s*\(/),relevance:0,keywords:{built_in:v}};function A(D){return t.concat(/\b/,t.either(...D.map(P=>P.replace(/\s+/,"\\s+"))),/\b/)}const N={scope:"keyword",match:A(g),relevance:0};function R(D,{exceptions:P,when:F}={}){const W=F;return P=P||[],D.map(M=>M.match(/\|\d+$/)||P.includes(M)?M:W(M)?`${M}|0`:M)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:R(y,{when:D=>D.length<3}),literal:o,type:u,built_in:m},contains:[{scope:"type",match:A(c)},N,w,S,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,k]}}const Xu="[A-Za-z$_][0-9A-Za-z$_]*",Kw=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Yw=["true","false","null","undefined","NaN","Infinity"],Xw=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Qw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Jw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],eN=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],tN=[].concat(Jw,Xw,Qw);function XO(e){const t=e.regex,n=(H,{after:G})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,G)!==-1},r=Xu,i={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,G)=>{const K=H[0].length+H.index,V=H.input[K];if(V==="<"||V===","){G.ignoreMatch();return}V===">"&&(n(H,{after:K})||G.ignoreMatch());let Y;const fe=H.input.substring(K);if(Y=fe.match(/^\s*=/)){G.ignoreMatch();return}if((Y=fe.match(/^\s+extends\s+/))&&Y.index===0){G.ignoreMatch();return}}},u={$pattern:Xu,keyword:Kw,literal:Yw,built_in:tN,"variable.language":eN},f="[0-9](_?[0-9])*",d=`\\.(${f})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${d})|\\.)?|(${d}))[eE][+-]?(${f})\\b`},{begin:`\\b(${p})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},S={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},A={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},N=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,{match:/\$\d+/},m];g.contains=N.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(N)});const R=[].concat(A,g.contains),D=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(R)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D},F={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},W={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Xw,...Qw]}},M={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},O={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},T={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Z(H){return t.concat("(?!",H.join("|"),")")}const E={match:t.concat(/\b/,Z([...Jw,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},C={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},$={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",B={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:D,CLASS_REFERENCE:W},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),M,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,v,y,S,k,A,{match:/\$\d+/},m,W,{scope:"attr",match:r+t.lookahead(":"),relevance:0},B,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[A,e.REGEXP_MODE,{className:"function",begin:L,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:D}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},O,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},E,T,F,$,{match:/\$[(.]/}]}}function QO(e){const t=e.regex,n=XO(e),r=Xu,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},f=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:Xu,keyword:Kw.concat(f),literal:Yw,built_in:tN.concat(i),"variable.language":eN},p={className:"meta",begin:"@"+r},m=(S,k,w)=>{const A=S.contains.findIndex(N=>N.label===k);if(A===-1)throw new Error("can not find mode to replace");S.contains.splice(A,1,w)};Object.assign(n.keywords,d),n.exports.PARAMS_CONTAINS.push(p);const g=n.contains.find(S=>S.scope==="attr"),v=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,v]),n.contains=n.contains.concat([p,o,c,v]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",u);const y=n.contains.find(S=>S.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function JO(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(o,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),f=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,f,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,c,f,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[f]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:d}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function e2(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},S={begin:"\\[",end:"\\]",contains:[v],illegal:"\\n",relevance:0},k=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,S,o,c],w=[...k];return w.pop(),w.push(u),v.contains=w,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:k}}for(const[e,t]of Object.entries({bash:_O,css:OO,diff:zO,go:PO,java:LO,javascript:HO,json:VO,markdown:qO,python:GO,rust:KO,sql:YO,typescript:QO,xml:JO,yaml:e2}))wr.registerLanguage(e,t);wr.registerAliases(["sh","shell","zsh","console"],{languageName:"bash"});wr.registerAliases(["ts","tsx","mts","cts"],{languageName:"typescript"});wr.registerAliases(["js","jsx","mjs","cjs"],{languageName:"javascript"});wr.registerAliases(["html","svg","vue"],{languageName:"xml"});wr.registerAliases(["py"],{languageName:"python"});wr.registerAliases(["yml"],{languageName:"yaml"});wr.registerAliases(["rs"],{languageName:"rust"});wr.registerAliases(["md"],{languageName:"markdown"});const ty=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");Ct.setOptions({gfm:!0,breaks:!1});Ct.use({renderer:{code({text:e,lang:t}){const n=(t??"").trim().split(/\s+/)[0]??"",i=n!==""&&wr.getLanguage(n)!==void 0?wr.highlight(e,{language:n,ignoreIllegals:!0}).value:ty(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${ty(n===""?"text":n)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${i}</code></pre></div>`}}});function t2(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/{2,3}/i,""))}catch{return}/^[A-Za-z]:/.test(t)===!1&&/^[^/]+\//.test(t)&&(t=`//${t}`)}const n=/^\/([A-Za-z])\/(.*)$/.exec(t);if(n!==null&&(t=`${n[1].toUpperCase()}:/${n[2]}`),!(!/^[A-Za-z]:[\\/]/.test(t)&&!/^(\\\\|\/\/)[^\\/]/.test(t)))return t.replace(/\//g,"\\").replace(/[#?].*$/,"")}$m.addHook("beforeSanitizeAttributes",e=>{if(e.tagName!=="A")return;const t=t2(e.getAttribute("href")??"");t!==void 0&&(e.removeAttribute("href"),e.setAttribute("data-local-path",t),e.setAttribute("title",t),e.classList.add("local-path"))});$m.addHook("afterSanitizeAttributes",e=>{if(e.tagName==="A"&&/^#\/(p|s|settings)(\/|$)/.test(e.getAttribute("href")??"")){e.classList.add("app-link");return}e.tagName==="A"&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))});function n2(e){var o;const t=e.dataset.localPath;if(t===void 0)return;const n=c=>{e.dataset.note=c,setTimeout(()=>{delete e.dataset.note},2200)},r=kr();if((r==null?void 0:r.openPath)!==void 0){r.openPath(t).then(c=>n(c==="missing"?"找不到这个文件":c==="revealed"?"已在文件夹中显示":"已打开"),()=>n("打不开"));return}(((o=navigator.clipboard)==null?void 0:o.writeText(t))??Promise.reject(new Error("no clipboard"))).then(()=>n("浏览器里打不开本地文件,路径已复制"),()=>n(nN(t)?"浏览器里打不开本地文件,路径已复制":t))}function s2(e){var u,f;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),n2(t);return}const n=e.target.closest("button[data-copy]"),r=(u=n==null?void 0:n.closest(".code-block"))==null?void 0:u.querySelector("pre");if(n==null||r==null)return;const i=r.innerText,o=d=>{n.textContent=d?"已复制":"复制失败",n.classList.toggle("copied",d),setTimeout(()=>{n.textContent="复制",n.classList.remove("copied")},1600)};(((f=navigator.clipboard)==null?void 0:f.writeText(i))??Promise.reject(new Error("no clipboard"))).then(()=>o(!0),()=>o(nN(i)))}function nN(e){const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{t.remove()}}const Ki=b.memo(function({text:t,className:n}){const r=b.useMemo(()=>$m.sanitize(Ct.parse(t,{async:!1})),[t]);return s.jsx("div",{className:`markdown ${n??""}`,onClick:s2,dangerouslySetInnerHTML:{__html:r}})}),ny="agent_delegate",sN=b.createContext([]);function bd(e){return`#/h/${encodeURIComponent(e.id)}`}function r2(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function Ca(e,t){const r=fi(e).find(i=>i.name===t||i.id===t);return r===void 0?t===br.name||t===br.id?br:void 0:ac(r)}const wa={running:{label:"进行中",tone:"running"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function kd({from:e,to:t,avatar:n,title:r,state:i,href:o}){const c=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`agent-avatar small agent-${(n==null?void 0:n.id)??"unknown"}`,children:s.jsx(ee,{name:(n==null?void 0:n.icon)??"sparkles"})}),s.jsxs("span",{className:"exchange-who",children:[e,s.jsx(ee,{name:"arrow",className:"delegation-arrow"}),s.jsx("strong",{children:t})]}),s.jsx("span",{className:"exchange-title",title:r,children:r}),i!==void 0&&s.jsxs("span",{className:`delegation-state tone-${i.tone}`,children:[i.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),i.label]}),o!==void 0&&s.jsx(ee,{name:"chevron",className:"exchange-open"})]});return o===void 0?s.jsx("div",{className:`exchange-line tone-${(i==null?void 0:i.tone)??""}`,children:c}):s.jsx("a",{className:`exchange-line tone-${(i==null?void 0:i.tone)??""}`,href:o,title:"看它们说了什么",children:c})}function i2({client:e,item:t,handOffs:n}){const{agent:r,task:i}=b.useMemo(()=>r2(t.arguments),[t.arguments]),o=Ca(e,r),c=n.find(d=>d.callId===t.callId),u=t.status==="error"||t.status==="interrupted",f=u?wa.failed:c===void 0?t.status==="running"?wa.running:void 0:wa[c.state];return s.jsxs("div",{className:"delegation",children:[s.jsx(kd,{from:br.name,to:(o==null?void 0:o.name)??r,avatar:o,title:(c==null?void 0:c.title)??i.split(`
191
- `)[0]??"",state:f,href:c===void 0?void 0:bd(c)}),u&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(ee,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function a2({client:e,handOff:t}){const n=Ca(e,t.to);return s.jsx("div",{className:"delegation app-handoff",children:s.jsx(kd,{from:t.by,to:(n==null?void 0:n.name)??t.to,avatar:n,title:t.title,state:wa.running,href:bd(t)})})}function o2({client:e,note:t,handOffs:n}){const r=Ca(e,t.agent),i=n.filter(c=>c.state!=="running"&&c.title===t.title&&(c.to===(r==null?void 0:r.id)||c.to===t.agent)).at(-1),o=i!==void 0?bd(i):r!==void 0?`#/a/${encodeURIComponent(r.id)}`:void 0;return s.jsx("div",{className:"delegation relay-line",children:s.jsx(kd,{from:t.agent,to:br.name,avatar:r,title:t.title,state:t.ok?wa.done:{label:"没有做完",tone:"failed"},href:o})})}function l2({client:e,note:t,handOffs:n}){const[r,i]=b.useState(!1),o=n.filter(f=>f.by===t.by&&f.title===t.title).at(-1),c=Ca(e,t.by),u=Ca(e,(o==null?void 0:o.to)??"");return t.by===qk?s.jsxs("div",{className:"msg user delegated",children:[s.jsx("div",{className:"msg-from",children:"你在软件里点的"}),s.jsx("div",{className:"bubble",children:s.jsxs("details",{className:"task-note",children:[s.jsx("summary",{children:t.title}),s.jsx("div",{className:"task-note-body",children:t.body})]})})]}):o!==void 0?s.jsx("div",{className:"delegation task-line",children:s.jsx(kd,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:c,title:t.title,state:wa[o.state],href:bd(o)})}):s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:"exchange-line",onClick:()=>i(f=>!f),"aria-expanded":r,title:r?"收起":"看交给了什么",children:[s.jsx("span",{className:`agent-avatar small agent-${(c==null?void 0:c.id)??"unknown"}`,children:s.jsx(ee,{name:(c==null?void 0:c.icon)??"calendar"})}),s.jsxs("span",{className:"exchange-who",children:[t.by,"交给的事"]}),s.jsx("span",{className:"exchange-title",title:t.title,children:t.title}),s.jsx(ee,{name:r?"chevron-down":"chevron",className:"exchange-open"})]}),r&&s.jsx("div",{className:"exchange-msg-body task-unfolded",children:s.jsx(Ki,{text:t.body})})]})}function c2({client:e,handOff:t,name:n}){const r=je(e.sessions).items.find(f=>f.id===t.toSession),i=pM(e,r===void 0?[]:[{id:r.id,updatedAt:r.updatedAt,running:r.running}]),o=r===void 0?void 0:i.get(r.id),c=b.useRef(void 0);c.current===void 0&&o!==void 0&&(c.current=o);const u=o!=null&&o!==""&&o!==c.current?o:void 0;return s.jsxs("div",{className:"delegation-now",children:[s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"进行中"}),s.jsx("span",{children:(r==null?void 0:r.running)===!0?u??`${n} 正在做…`:`排在 ${n} 手上的事后面`})]})}function u2(e,t){const n=je(e.connection.status),[r,i]=b.useState({item:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("handoffs/get",{id:t}).then(c=>{o&&i({item:c,error:null})},c=>{o&&i({item:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:o})=>{o.id===t&&i({item:o,error:null})}),[e,t]),r}function d2({client:e,id:t,onClose:n}){const{item:r,error:i}=u2(e,t),o=Ca(e,(r==null?void 0:r.by)??""),c=Ca(e,(r==null?void 0:r.to)??"");if(r===null)return s.jsx("section",{className:"main empty",children:i??"正在打开…"});const u=(c==null?void 0:c.name)??r.to,f=wa[r.state];return s.jsxs("section",{className:"main exchange-page",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${(o==null?void 0:o.id)??"unknown"}`,children:s.jsx(ee,{name:(o==null?void 0:o.icon)??"calendar"})}),s.jsx("span",{children:r.by}),s.jsx(ee,{name:"arrow",className:"delegation-arrow"}),s.jsx("span",{className:`agent-avatar small agent-${(c==null?void 0:c.id)??"unknown"}`,children:s.jsx(ee,{name:(c==null?void 0:c.icon)??"sparkles"})}),s.jsx("h1",{children:u})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx("span",{className:`delegation-state tone-${f.tone}`,children:f.label}),s.jsx("span",{children:r.title}),s.jsx("span",{children:new Date(r.startedAt).toLocaleString()})]})]})}),s.jsx("div",{className:"view",children:s.jsx("div",{className:"chat",children:s.jsxs("div",{className:"chat-inner",children:[s.jsxs(Uh,{who:r.by,agent:o,children:[s.jsx(Ki,{text:r.task}),r.expecting!==void 0&&s.jsxs("div",{className:"delegation-expecting",children:["要交回:",r.expecting]})]}),r.state==="running"?s.jsx(Uh,{who:u,agent:c,children:s.jsx(c2,{client:e,handOff:r,name:u})}):s.jsx(Uh,{who:u,agent:c,failed:r.state==="failed",children:s.jsx(Ki,{text:r.reply??(r.state==="failed"?"没有做完":"它没有留下回复")})})]})})}),s.jsx("footer",{className:"exchange-footer",children:s.jsxs("button",{className:"small-button",onClick:n,children:[s.jsx(ee,{name:"close"}),"关闭"]})})]})}function Uh({who:e,agent:t,failed:n=!1,children:r}){return s.jsxs("div",{className:`exchange-msg ${n?"failed":""}`,children:[s.jsxs("div",{className:"exchange-msg-head",children:[s.jsx("span",{className:`agent-avatar small agent-${(t==null?void 0:t.id)??"unknown"}`,children:s.jsx(ee,{name:(t==null?void 0:t.icon)??"calendar"})}),s.jsx("strong",{children:e})]}),s.jsx("div",{className:"exchange-msg-body",children:r})]})}const f2=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。现在切换吗?"].join(`
192
- `),rN="adg.officialIntro";function h2(){var c;const e=(c=kr())==null?void 0:c.uiMode,[t,n]=b.useState(null);if(b.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(d=>{u&&n(d)},()=>{});const f=e.onChange(n);return()=>{u=!1,f()}},[e]),e===void 0||t===null)return null;const r=t.mode==="official",i=()=>{if(r){e.set("adg");return}!p2()&&!window.confirm(f2)||(m2(),e.set("official"))},o=t.starting?"正在启动官方界面…":r?"返回 MultiGameAssistant":"dsh 官方界面";return s.jsxs("div",{className:"ui-switch",children:[s.jsxs("button",{type:"button",className:`ui-switch-button ${r?"active":""}`,disabled:t.starting,onClick:i,title:r?"切回 MultiGameAssistant 的界面":"切换到 DeepSeek Harness 自带的界面(聊天记录分开)",children:[s.jsx(ee,{name:r?"back":"layers"}),s.jsx("span",{children:o})]}),t.error!==void 0&&s.jsxs("span",{className:"ui-switch-error",role:"alert",title:t.error,children:[s.jsx("span",{children:t.error}),s.jsx("button",{type:"button",className:"icon-button","aria-label":"关闭",onClick:()=>void e.set("adg"),children:s.jsx(ee,{name:"close"})})]})]})}function p2(){try{return localStorage.getItem(rN)==="1"}catch{return!1}}function m2(){try{localStorage.setItem(rN,"1")}catch{}}const Hh="games";function g2({client:e}){const[t,n]=b.useState(()=>S0()),r=je(e.sessions),i=J$(e),o=je(e.connection.status),c=fi(e),u=b.useRef(!1),f=b.useRef(null);b.useEffect(()=>{EM(t,u.current?"replace":"push"),u.current=!1,t.kind!=="handoff"&&t.kind!=="window"&&(f.current=t)},[t]),b.useEffect(()=>{const T=()=>n(S0());return window.addEventListener("hashchange",T),()=>window.removeEventListener("hashchange",T)},[]);const d=b.useRef(new Set);b.useEffect(()=>{for(const E of r.items)d.current.add(E.id);if(t.kind!=="session"||!r.loaded||r.items.some(E=>E.id===t.id))return;const T=()=>{u.current=!0,n(E=>E.kind==="session"&&E.id===t.id?{kind:"home"}:E)};if(d.current.has(t.id)){T();return}const Z=setTimeout(T,8e3);return()=>clearTimeout(Z)},[t,r]),b.useEffect(()=>{t.kind!=="start"||o.state!=="open"||(u.current=!0,n(i.some(T=>T.id===Hh)?{kind:"page",id:Hh}:{kind:"home"}))},[t,o.state,i]);const p=T=>n({kind:"session",id:T}),m=T=>n({kind:"settings",...T===void 0?{}:{section:T}}),g=T=>n({kind:"page",id:T}),v=t.kind==="session"?t.id:null,y=v===null?void 0:r.items.find(T=>T.id===v),S=t.kind==="start"?{kind:"page",id:Hh}:t,k=S.kind==="page"?i.find(T=>T.id===S.id):void 0,w=T=>T.agent===void 0?void 0:c.some(Z=>Z.id===T.agent)?T.agent:xr,A=k===void 0?void 0:w(k),N=T=>n({kind:"agent",id:T}),R=()=>N(xr),D=s.jsx(y2,{client:e,onSettings:()=>m("api-keys")}),P=t.kind==="home"?xr:t.kind==="agent"?t.id:t.kind==="session"?y===void 0?void 0:_a(y,c):A,F=(T,Z)=>n(Z==="chat"?{kind:"agent",id:T}:Z==="schedule"||Z==="history"?{kind:"agent",id:T,tab:Z}:{kind:"page",id:Z});if(t.kind==="window")return s.jsx(YM,{client:e,viewId:t.view,sessionId:t.sessionId});const W=t.kind==="settings"?{kind:"settings"}:t.kind==="schedule"?{kind:"schedule"}:P!==void 0?{kind:"agent",id:P}:S.kind==="page"?{kind:"page",id:S.id}:{kind:"none"},M=k===void 0?null:s.jsx(k.component,{client:e,openSession:p,openSettings:m,openPage:g,arg:S.kind==="page"?S.arg:void 0},k.id),O=P===void 0?null:s.jsx(x2,{client:e,agentId:P,pages:i.filter(T=>w(T)===P),current:t.kind==="agent"&&t.tab!==void 0?t.tab:t.kind==="session"?"history":S.kind==="page"?S.id:"chat",onTab:T=>F(P,T)});return s.jsxs("div",{className:`app ${t.kind==="settings"?"with-sidebar":""}`,children:[s.jsx(wM,{client:e,pages:i.filter(T=>T.agent===void 0),current:W,onAgent:N,onPage:g,onSchedule:()=>n({kind:"schedule"}),onSettings:()=>m()}),t.kind==="settings"&&s.jsx(iR,{client:e,onClose:R,section:t.section,onSection:T=>n({kind:"settings",section:T})}),S.kind==="page"&&A===void 0&&(M??s.jsx("section",{className:"main empty",children:o.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),P!==void 0&&s.jsxs("div",{className:"agent-area",children:[O,A!==void 0?M:t.kind==="agent"&&t.tab==="schedule"?s.jsx(oR,{client:e,agentId:t.id},t.id):t.kind==="agent"&&t.tab==="history"?s.jsx(kM,{client:e,agentId:t.id,onSelect:p},t.id):t.kind==="session"?s.jsx(Up,{client:e,sessionId:t.id,onAgent:N,reminder:D},t.id):s.jsx(v2,{client:e,agentId:P,onMain:R,onAgent:N,reminder:D},P)]}),t.kind==="handoff"&&s.jsx(d2,{client:e,id:t.id,onClose:()=>n(f.current??{kind:"agent",id:xr})},t.id),t.kind==="schedule"&&s.jsx(lR,{client:e,onAgent:T=>n({kind:"agent",id:T,tab:"schedule"})}),t.kind==="session"&&P===void 0&&s.jsx(Up,{client:e,sessionId:t.id,onAgent:N,reminder:D},t.id),s.jsx(cM,{client:e,sessionId:v,onSelect:p}),s.jsx(h2,{})]})}function x2({client:e,agentId:t,pages:n,current:r,onTab:i}){const o=fi(e),c=je(e.capabilities),u=o.find(m=>m.id===t),f=u===void 0?br:ac(u),d=bM(e,t)||r==="history",p=[{id:"chat",title:"对话",icon:"chat"},...c.has("pipelines")?[{id:"schedule",title:"定时",icon:"calendar"}]:[],...[...n].sort((m,g)=>m.order-g.order).map(m=>({id:m.id,title:m.title,icon:m.icon})),...d?[{id:"history",title:"以前的对话",icon:"archive"}]:[]];return p.length===1?null:s.jsx("nav",{className:"agent-tabs",role:"tablist","aria-label":f.name,children:p.map(m=>s.jsxs("button",{role:"tab","aria-selected":m.id===r,className:m.id===r?"active":"",onClick:()=>i(m.id),children:[s.jsx(ee,{name:m.icon}),m.title]},m.id))})}function v2({client:e,agentId:t,onMain:n,onAgent:r,reminder:i}){const{sessionId:o,error:c}=rw(e,t);return c!==null?s.jsx("section",{className:"main empty",children:s.jsxs("span",{children:[c,s.jsx("button",{className:"link-button",onClick:n,children:"回到助手"})]})}):o===null?s.jsx("section",{className:"main empty",children:"正在打开…"}):s.jsx(Up,{client:e,sessionId:o,onAgent:r,reminder:i},o)}function y2({client:e,onSettings:t}){var o;const{items:n}=ew(e,[Cp]),{catalog:r}=Fo(e),i=(r==null?void 0:r.groups.some(c=>c.id!=="deepseek-official"&&c.models.length>0))??!1;return((o=n==null?void 0:n[Cp])==null?void 0:o.configured)!==!1||i?null:s.jsxs("div",{className:"reminder",children:[s.jsx(ee,{name:"key"}),s.jsx("span",{children:"还没有可用的模型:请填写 DeepSeek API Key,或添加一个自定义 API(Claude、ChatGPT 等)。"}),s.jsx("button",{className:"primary small-button",onClick:t,children:"去设置"})]})}function b2({onSubmit:e}){const[t,n]=b.useState("");return s.jsx("div",{className:"token-prompt",children:s.jsxs("form",{onSubmit:r=>{r.preventDefault(),t.trim()!==""&&e(t.trim())},children:[s.jsx(xd,{size:"lg"}),s.jsxs("div",{className:"token-heading",children:[s.jsx("p",{className:"eyebrow",children:"MULTI GAME ASSISTANT"}),s.jsx("h1",{children:"连接 agent"}),s.jsxs("p",{className:"muted",children:["输入后端启动时打印的连接 token(",s.jsx("code",{children:"adg gateway: …?token="})," 后面的部分)。"]})]}),s.jsx("label",{className:"field-label",htmlFor:"adg-token",children:"连接 Token"}),s.jsx("input",{id:"adg-token",className:"text-input",autoFocus:!0,value:t,onChange:r=>n(r.target.value),placeholder:"粘贴连接 token"}),s.jsx("button",{className:"primary",type:"submit",disabled:t.trim()==="",children:"连接"})]})})}const k2=["准备环境","启动服务","载入界面","连接 agent"],w2=8e3,N2=400;function j2({client:e}){const t=je(e.connection.status),n=je(e.sessions),[r,i]=b.useState("shown"),[o,c]=b.useState(!1),u=t.state==="open"&&n.loaded;if(b.useEffect(()=>{const p=setTimeout(()=>c(!0),w2);return()=>clearTimeout(p)},[]),b.useEffect(()=>{u&&i(p=>p==="shown"?"leaving":p)},[u]),b.useEffect(()=>{if(r!=="leaving")return;const p=setTimeout(()=>i("gone"),N2);return()=>clearTimeout(p)},[r]),r==="gone")return null;const f=t.state==="open"?"正在读取对话":t.state==="reconnecting"?`连不上 agent,正在重试(第 ${t.attempt} 次)`:t.state==="connecting"?"正在连接 agent":"没有连上 agent",d=o?t.error!==void 0?`连接出错:${t.error}`:"比平时慢一些,agent 服务可能还在启动。":"";return s.jsxs("div",{className:`boot${r==="leaving"?" leaving":""}`,"aria-hidden":r==="leaving",children:[s.jsxs("div",{className:"boot-center",children:[s.jsxs("div",{className:"boot-mark","aria-hidden":"true",children:[s.jsxs("svg",{className:"boot-orbit",viewBox:"0 0 132 132",children:[s.jsx("circle",{className:"track",cx:"66",cy:"66",r:"62"}),s.jsx("circle",{className:"comet",cx:"66",cy:"66",r:"62"})]}),s.jsx("span",{className:"boot-tile",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9.5 8.3v7.4l6.2-3.7-6.2-3.7Z"}),s.jsx("path",{className:"loop",d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})]}),s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"status","aria-live":"polite",children:s.jsx("span",{children:f})}),s.jsx("ol",{className:"boot-steps",children:k2.map((p,m)=>s.jsxs("li",{className:m<3?"done":"now",children:[s.jsx("i",{}),s.jsx("span",{children:p})]},p))}),s.jsx("p",{className:`boot-hint${d!==""?" shown":""}`,children:d}),o&&s.jsx("button",{type:"button",className:"boot-skip",onClick:()=>i("leaving"),children:"先进入界面"})]}),s.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class S2 extends b.Component{constructor(){super(...arguments);ut(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n:new Error(String(n))}}componentDidCatch(n,r){console.error(`界面出错:${n instanceof Error?n.stack??n.message:String(n)}${r.componentStack??""}`)}render(){const{error:n}=this.state;if(n===null)return this.props.children;const r=`${n.message}
193
-
194
- ${(n.stack??"").split(`
195
- `).slice(1,8).join(`
196
- `)}`;return s.jsx("div",{className:"boot failed",children:s.jsxs("div",{className:"boot-center",children:[s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"alert",children:s.jsx("span",{children:"界面出错了"})}),s.jsx("div",{className:"boot-detail",children:s.jsx("pre",{tabIndex:0,children:r})}),s.jsxs("div",{className:"boot-actions",children:[s.jsx("button",{type:"button",className:"primary",onClick:()=>location.reload(),children:"重新载入"}),s.jsx("button",{type:"button",onClick:()=>{var i;return void((i=navigator.clipboard)==null?void 0:i.writeText(r))},children:"复制错误信息"})]})]})})}}function iN(e){const t=b.useRef(!0),n=b.useRef(0);return{following:t,onScroll:r=>{const i=r.currentTarget,o=i.scrollHeight-i.scrollTop-i.clientHeight,c=i.scrollTop<n.current-1;n.current=i.scrollTop,o<=2?t.current=!0:c?t.current=!1:o<e&&(t.current=!0)},onWheel:r=>{r.deltaY<0&&(t.current=!1)}}}const _2=160;function Pl(e,t=_2){var r;const n=((r=e.split(/\r?\n/).find(i=>i.trim()!==""))==null?void 0:r.trim())??"";return n.length>t?`${n.slice(0,t-1)}…`:n}function sy(e,t="text"){return e.filter(n=>n.type===t).map(n=>n.text).join("")}function Al(e){const t=Pl(sy(e));if(t!=="")return t;const n=Pl(sy(e,"reasoning"));if(n!=="")return n;const r=e.filter(c=>c.type==="tool-call").map(c=>c.name);if(r.length>0)return`→ ${r.join(", ")}`;const i=e.filter(c=>c.type==="image").length,o=e.filter(c=>c.type==="file").length;return[i>0?`${i} image(s)`:"",o>0?`${o} file(s)`:""].filter(Boolean).join(" · ")}function E2(e,t=null,n={}){var P,F,W,M,O,T,Z;const r=[],i=new Map,o=[],c=new Map,u=new Map,f=new Map;let d=null,p=null,m=null,g=0,v=0;const y=(E,C)=>{let $=i.get(E);return $===void 0&&($=Zh(`t:${E}`,E,C,!0),i.set(E,$),r.push($)),p=null,$},S=(E,C)=>d!==null?d:(p===null&&(p=Zh(`b:${C}`,null,E,!1),r.push(p)),p),k=(E,C,$,L)=>{let B=E.steps.get($);return B===void 0&&(B={turn:C,step:$,start:L,startKnown:!1,end:null,records:[],retries:0},E.steps.set($,B),E.stepOrder.push($)),B},w=(E,C,$)=>{E.records.push($),C==null||C.records.push($),o.push($)},A=E=>(E.requestIndex??(E.requestIndex=++g),E.requestIndex),N=new Set;for(const E of e)switch(v=Math.max(v,E.time),E.type){case"turn/start":{const C=Zh(`t:${E.turn}`,E.turn,E.time,!1);i.set(E.turn,C),r.push(C),d=C,p=null;break}case"turn/end":{const C=y(E.turn,E.time);C.end=E.time,C.reason=E.reason;for(const $ of C.steps.values())$.end??($.end=E.time);for(const $ of c.values())$.turn===E.turn&&$.status==="running"&&($.status="interrupted",$.end=E.time);d===C&&(d=null);break}case"step/start":{const C=y(E.turn,E.time),$=k(C,E.turn,E.step,E.time);$.start=E.time,$.startKnown=!0;break}case"step/end":{const C=y(E.turn,E.time);k(C,E.turn,E.step,E.time).end=E.time;break}case"user/message":{const C=S(E.time,E.seq);w(C,null,C2(E,C.turn));break}case"system/message":{if(E.text.trim()==="")break;const C=y(E.turn,E.time),$=k(C,E.turn,E.step,E.time),L={kind:"system",id:`system:${E.seq}`,seq:E.seq,turn:E.turn,step:E.step,start:E.time,end:E.time,status:"ok",title:"System prompt",preview:Pl(E.text),text:E.text};w(C,$,L);break}case"request/header":{m={...E.provider===void 0?{}:{provider:E.provider},...E.model===void 0?{}:{model:E.model},...E.reasoningEffort===void 0?{}:{reasoningEffort:E.reasoningEffort},toolCount:E.toolNames.length};break}case"assistant/attempt":{const C=y(E.turn,E.time),$=k(C,E.turn,E.step,E.time);Wh($,E.timing.firstTokenAt),$.retries+=1,E.error!==void 0&&($.lastRetryError=E.error);const L={kind:"attempt",id:`attempt:${E.seq}`,seq:E.seq,turn:E.turn,step:E.step,start:E.timing.firstChunkAt??$.start,end:E.timing.lastChunkAt??E.time,status:"error",title:"Failed attempt",preview:((P=E.error)==null?void 0:P.message)??"attempt ended without output",...E.error===void 0?{}:{error:E.error}};w(C,$,L);break}case"assistant/message":{const C=y(E.turn,E.time),$=k(C,E.turn,E.step,E.time);Wh($,E.timing.firstTokenAt),N.add(`${E.turn}:${E.step}`);const L=E.timing.firstTokenAt,B=E.timing.lastChunkAt,H=L!==void 0&&B!==void 0?B-L:void 0,G=E.model??(m==null?void 0:m.model),K=E.provider??(m==null?void 0:m.provider),V={kind:"assistant",id:`assistant:${E.seq}`,seq:E.seq,turn:E.turn,step:E.step,start:$.start,end:B??E.time,status:E.interrupted===!0?"interrupted":"ok",title:G===void 0?"Assistant":`Assistant · ${G}`,preview:Al(E.content),content:E.content,live:!1,interrupted:E.interrupted===!0,request:iy({index:A($),provider:K,model:G,reasoningEffort:m==null?void 0:m.reasoningEffort,toolCount:m==null?void 0:m.toolCount,ttftMs:ry($),decodeMs:H,tokensPerSecond:I2((F=E.usage)==null?void 0:F.outputTokens,H),usage:E.usage,retries:$.retries,lastRetryError:$.lastRetryError})};w(C,$,V);break}case"tool/call":{const C=y(E.turn,E.time),$=k(C,E.turn,E.step,E.time),L=f.get(E.callId),B={kind:"tool",id:`tool:${E.callId}`,seq:E.seq,turn:E.turn,step:E.step,start:E.time,end:null,status:C.end===null?"running":"interrupted",title:E.name,preview:Pl(E.arguments),name:E.name,callId:E.callId,arguments:E.arguments,isError:!1,...L===void 0?{}:{approval:{approvalId:L}}};c.set(E.callId,B),w(C,$,B);break}case"tool/result":{const C=c.get(E.callId);if(C===void 0){const L=y(E.turn,E.time),B=k(L,E.turn,E.step,E.time),H={kind:"tool",id:`tool:${E.callId}`,seq:E.seq,turn:E.turn,step:E.step,start:E.time,end:E.time,status:E.isError?"error":"ok",title:"tool result",preview:Al(E.content),name:"tool result",callId:E.callId,arguments:"",result:E.content,isError:E.isError,...E.error===void 0?{}:{error:E.error}};w(L,B,H);break}C.end=E.time,C.result=E.content,C.isError=E.isError,C.status=E.isError?"error":"ok",E.error!==void 0&&(C.error=E.error);const $=Al(E.content);$!==""&&(C.preview=`${Pl(C.arguments,80)} ⇒ ${$}`);break}case"approval/asked":{if(E.callId===void 0)break;f.set(E.callId,E.approvalId);const C=c.get(E.callId);C!==void 0&&(C.approval={approvalId:E.approvalId,...E.reason===void 0?{}:{reason:E.reason}});break}case"approval/decided":{for(const C of c.values())((W=C.approval)==null?void 0:W.approvalId)===E.approvalId&&(C.approval={...C.approval,outcome:E.outcome});break}case"compaction/start":{const C=E.turn===null?S(E.time,E.seq):y(E.turn,E.time),$={kind:"compaction",id:`compaction:${E.compactionId}`,seq:E.seq,turn:C.turn,step:null,start:E.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:E.compactionId};u.set(E.compactionId,$),w(C,null,$);break}case"compaction/summary":{const C=u.get(E.compactionId);if(C===void 0)break;C.shadowedTokenCount=E.shadowedTokenCount,E.usage!==void 0&&(C.usage=E.usage),C.preview=`${E.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const C=u.get(E.compactionId);if(C===void 0)break;C.end=E.time,C.status=E.error===void 0?"ok":"error",E.error!==void 0&&(C.error=E.error,C.preview=E.error);break}}if(t!==null&&!N.has(`${t.turn}:${t.step}`)){const E=y(t.turn,((M=t.deltas[0])==null?void 0:M.time)??n.now??v),C=k(E,t.turn,t.step,((O=t.deltas[0])==null?void 0:O.time)??n.now??v),$=(T=t.deltas.find(G=>G.text!==""||G.toolName!==void 0))==null?void 0:T.time;Wh(C,$);const L=A2(t.deltas),B=(Z=t.deltas.at(-1))==null?void 0:Z.time;B!==void 0&&(v=Math.max(v,B));const H={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:C.start,end:null,status:"running",title:(m==null?void 0:m.model)===void 0?"Assistant":`Assistant · ${m.model}`,preview:Al(L)||"waiting for output…",content:L,live:!0,interrupted:!1,request:iy({index:A(C),provider:m==null?void 0:m.provider,model:m==null?void 0:m.model,reasoningEffort:m==null?void 0:m.reasoningEffort,toolCount:m==null?void 0:m.toolCount,ttftMs:ry(C),retries:C.retries,lastRetryError:C.lastRetryError})};w(E,C,H)}const R=r.map(E=>({key:E.key,turn:E.turn,start:E.start,end:E.end,partialStart:E.partialStart,...E.reason===void 0?{}:{reason:E.reason},steps:E.stepOrder.map(C=>{const $=E.steps.get(C);return{turn:$.turn,step:$.step,start:$.start,end:$.end,records:$.records}}),records:E.records})),D=n.now??v;return{groups:R,records:o,totals:T2(o),span:$2(o,D)}}function Zh(e,t,n,r){return{key:e,turn:t,start:n,end:null,partialStart:r,steps:new Map,stepOrder:[],records:[]}}function C2(e,t){const n=e.origin.human,r=n?"user":"context",i=e.content.filter(u=>u.type==="image").length,o=e.content.filter(u=>u.type==="file").length,c=n?"User":e.replacesHistory===!0?"Compacted history":`Context · ${e.origin.kind}`;return{kind:r,id:`user:${e.seq}`,seq:e.seq,turn:t,step:null,start:e.time,end:e.time,status:"ok",title:c,preview:e.origin.summary??Al(e.content),content:e.content,origin:e.origin,imageCount:i,fileCount:o}}function Wh(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function ry(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function I2(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function A2(e){const t=new Map;for(const n of e){const r=t.get(n.index);if(n.kind==="tool-args"){const i=(r==null?void 0:r.type)==="tool-call"?r:void 0;t.set(n.index,{type:"tool-call",callId:n.callId??(i==null?void 0:i.callId)??"",name:n.toolName??(i==null?void 0:i.name)??"",arguments:((i==null?void 0:i.arguments)??"")+n.text})}else{const i=n.kind==="text"?"text":"reasoning",o=(r==null?void 0:r.type)===i?r.text:"";t.set(n.index,{type:i,text:o+n.text})}}return[...t.entries()].sort((n,r)=>n[0]-r[0]).map(([,n])=>n)}function T2(e){const t={requests:0,toolCalls:0,errors:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0};for(const n of e){n.status==="error"&&(t.errors+=1),n.kind==="tool"&&(t.toolCalls+=1);const r=n.kind==="assistant"?n.request.usage:n.kind==="compaction"?n.usage:void 0;n.kind==="assistant"&&(t.requests+=1),r!==void 0&&(t.inputTokens+=r.inputTokens,t.outputTokens+=r.outputTokens,t.cacheReadTokens+=r.cacheReadTokens??0,t.cacheWriteTokens+=r.cacheWriteTokens??0,t.reasoningTokens+=r.reasoningTokens??0)}return t}function $2(e,t){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)n=Math.min(n,i.start),r=Math.max(r,i.end??Math.max(i.start,t));return Number.isFinite(n)?{start:n,end:Math.max(n,r)}:null}function iy(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const aN=[{id:"input",kinds:["user","context","system"],label:"Input"},{id:"model",kinds:["assistant","attempt"],label:"Model"},{id:"tool",kinds:["tool"],label:"Tools"},{id:"compaction",kinds:["compaction"],label:"Compaction"}],M2=new Map(aN.flatMap((e,t)=>e.kinds.map(n=>[n,t])));function R2(e){return e.records.map(t=>{const n=t.end===null||t.end<=t.start,r={record:t,lane:M2.get(t.kind)??0,start:t.start,end:t.end===null?t.start:Math.max(t.start,t.end),instant:n};return t.kind==="assistant"&&t.request.ttftMs!==void 0&&t.end!==null?{...r,firstTokenAt:t.start+t.request.ttftMs}:r})}function O2(e,t){const n=e.end??e.start;return e.start<=t.end&&n>=t.start}function z2(e,t,n,r){const o=Math.max(10,(e.end-e.start)*n),c=e.end===e.start?.5:(t-e.start)/(e.end-e.start);let u=t-o*c,f=u+o;return f-u>=r.end-r.start?r:(u<r.start&&(f+=r.start-u,u=r.start),f>r.end&&(u-=f-r.end,f=r.end),{start:u,end:f})}function P2(e,t,n){const r=e.end-e.start,i=Math.min(Math.max(n.start,e.start+t),n.end-r);return{start:i,end:i+r}}function L2(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(r=>r.title.toLowerCase().includes(n)||r.preview.toLowerCase().includes(n)?!0:r.kind==="tool"?r.arguments.toLowerCase().includes(n):!1)}function Ts(e){if(e==null||!Number.isFinite(e))return"—";if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?2:1)} s`;const n=Math.floor(t/60);return n<60?`${n}m ${String(Math.floor(t%60)).padStart(2,"0")}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,"0")}m`}function vn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Ui(e){const t=new Date(e),n=(r,i=2)=>String(r).padStart(i,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(),3)}`}function Um(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var Hm=Bb();const ay=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],D2=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],oy=[[2,"细"],[4,"中"],[7,"粗"]],F2=.05,ly=16,cy=44;function oN({src:e,width:t,height:n,name:r,onClose:i}){const[o,c]=b.useState({src:e,width:t,height:n}),{src:u,width:f,height:d}=o,p=b.useRef(null),m=b.useRef(null),[g,v]=b.useState(()=>B2(t,n)),[y,S]=b.useState({scale:1,x:0,y:0}),[k,w]=b.useState(!1),[A,N]=b.useState("rect"),[R,D]=b.useState(ay[0]),[P,F]=b.useState(oy[0][0]),[W,M]=b.useState([]),[O,T]=b.useState(null),[Z,E]=b.useState(!0),[C,$]=b.useState(null),L=b.useRef(null),B=b.useRef(null),H=b.useCallback(()=>{var Le;const re=(Le=p.current)==null?void 0:Le.getBoundingClientRect();if(re===void 0||re.width===0)return;const he=Math.min(ly,(re.width-24)/f,(re.height-24)/d);S({scale:he,x:(re.width-f*he)/2,y:(re.height-d*he)/2})},[f,d]);b.useLayoutEffect(H,[H]),b.useEffect(()=>{const re=p.current;if(re===null||typeof ResizeObserver>"u")return;const he=new ResizeObserver(()=>H());return he.observe(re),()=>he.disconnect()},[H]);const G=(re,he,Le)=>{var tt;const Te=(tt=p.current)==null?void 0:tt.getBoundingClientRect();if(Te===void 0)return;const Ge=he??Te.width/2,Ie=Le??Te.height/2;S(et=>{const jt=Math.min(ly,Math.max(F2,et.scale*re)),On=jt/et.scale;return{scale:jt,x:Ge-(Ge-et.x)*On,y:Ie-(Ie-et.y)*On}})},K=()=>{var he;const re=(he=p.current)==null?void 0:he.getBoundingClientRect();re!==void 0&&S({scale:1,x:(re.width-f)/2,y:(re.height-d)/2})};b.useEffect(()=>{const re=p.current;if(re===null)return;const he=Le=>{Le.preventDefault();const Te=re.getBoundingClientRect();G(Math.exp(-Le.deltaY*.0015),Le.clientX-Te.left,Le.clientY-Te.top)};return re.addEventListener("wheel",he,{passive:!1}),()=>re.removeEventListener("wheel",he)});const V=re=>{$(re),setTimeout(()=>$(he=>he===re?null:he),1800)},Y=b.useCallback(async(re,he=0)=>{const Le=new Image;Le.src=u,await Le.decode();const Te=document.createElement("canvas");Te.width=f,Te.height=d;const Ge=Te.getContext("2d");Ge.drawImage(Le,0,0,f,d);for(const et of re)Z2(Ge,et);if(he===0)return Te;const Ie=document.createElement("canvas");Ie.width=d,Ie.height=f;const tt=Ie.getContext("2d");return tt.translate(d/2,f/2),tt.rotate(he),tt.drawImage(Te,-f/2,-d/2),Ie},[u,f,d]),fe=b.useCallback(async re=>{try{const he=await Y(re),Le=await new Promise((Te,Ge)=>he.toBlob(Ie=>Ie===null?Ge(new Error("没能生成图片")):Te(Ie),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":Le})])}catch(Te){const Ge=kr();if((Ge==null?void 0:Ge.copyImage)===void 0)throw Te;await Ge.copyImage(he.toDataURL("image/png"))}V(re.length>0?"已复制(带标注)":"已复制")}catch(he){V(`复制失败:${he instanceof Error?he.message:String(he)}`)}},[Y]),xe=async()=>{const re=await Y(W),he=document.createElement("a");he.href=re.toDataURL("image/png"),he.download=`${r.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${W.length>0?"-标注":""}.png`,he.click()},ge=async()=>{const re=await Y(W,Math.PI/2);M([]),c({src:re.toDataURL("image/png"),width:re.width,height:re.height})},ie=()=>M(re=>re.slice(0,-1));b.useEffect(()=>{const re=he=>{if(!(m.current===null||!m.current.contains(document.activeElement))){if(he.key==="Escape"){O!==null?(T(null),L.current=null):k?w(!1):i();return}if((he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="z"){he.preventDefault(),ie();return}if((he.ctrlKey||he.metaKey)&&he.key.toLowerCase()==="c"){he.preventDefault(),fe(W);return}he.key==="0"&&H(),(he.key==="+"||he.key==="=")&&G(1.25),he.key==="-"&&G(.8)}};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)});const ke=re=>{const he=p.current.getBoundingClientRect(),Le=(re.clientX-he.left-y.x)/y.scale,Te=(re.clientY-he.top-y.y)/y.scale;return[Math.max(0,Math.min(f,Le)),Math.max(0,Math.min(d,Te))]},ae=re=>{if(re.button!==0&&re.button!==1)return;if(re.currentTarget.setPointerCapture(re.pointerId),!k||re.button===1){L.current={kind:"pan",sx:re.clientX,sy:re.clientY,ox:y.x,oy:y.y};return}const[he,Le]=ke(re),Te=P/y.scale;L.current={kind:"mark"},T(A==="pen"?{kind:"pen",points:[[he,Le]],color:R,width:Te}:{kind:A,x1:he,y1:Le,x2:he,y2:Le,color:R,width:Te})},Ne=re=>{const he=L.current;if(he===null)return;if(he.kind==="pan"){S(Ge=>({...Ge,x:he.ox+re.clientX-he.sx,y:he.oy+re.clientY-he.sy}));return}const[Le,Te]=ke(re);T(Ge=>Ge===null?Ge:Ge.kind==="pen"?{...Ge,points:[...Ge.points,[Le,Te]]}:{...Ge,x2:Le,y2:Te})},Fe=()=>{const re=L.current;if(L.current=null,(re==null?void 0:re.kind)!=="mark"||O===null||(T(null),(O.kind==="pen"?O.points.length>2?99:0:Math.hypot(O.x2-O.x1,O.y2-O.y1)*y.scale)<4))return;const Le=[...W,O];M(Le),Z&&fe(Le)},ce=re=>{if(re.target.closest("button")!==null)return;re.currentTarget.setPointerCapture(re.pointerId),B.current={sx:re.clientX,sy:re.clientY,ox:g.x,oy:g.y};const he=m.current;he!==null&&v(Le=>({...Le,w:he.offsetWidth,h:he.offsetHeight}))},Se=re=>{const he=B.current;he!==null&&v(Le=>({...Le,x:Math.max(-Le.w+120,Math.min(window.innerWidth-120,he.ox+re.clientX-he.sx)),y:Math.max(0,Math.min(window.innerHeight-40,he.oy+re.clientY-he.sy))}))};return b.useEffect(()=>{var re;(re=m.current)==null||re.focus()},[]),Hm.createPortal(s.jsxs("div",{ref:m,className:"image-viewer",role:"dialog","aria-label":r,tabIndex:-1,style:{left:g.x,top:g.y,width:g.w,height:g.h},children:[s.jsxs("div",{className:"viewer-title",onPointerDown:ce,onPointerMove:Se,onPointerUp:()=>{B.current=null},onDoubleClick:H,children:[s.jsx("span",{className:"viewer-name",children:r}),s.jsxs("span",{className:"viewer-dim",children:[f,"×",d]}),s.jsx("button",{className:"viewer-icon",onClick:i,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),s.jsxs("div",{ref:p,className:`viewer-stage ${k?"marking":""}`,onPointerDown:ae,onPointerMove:Ne,onPointerUp:Fe,onPointerCancel:Fe,children:[s.jsxs("div",{className:"viewer-canvas",style:{width:f,height:d,transform:`translate(${y.x}px, ${y.y}px) scale(${y.scale})`},children:[s.jsx("img",{src:u,alt:r,width:f,height:d,draggable:!1}),s.jsx("svg",{viewBox:`0 0 ${f} ${d}`,width:f,height:d,"aria-hidden":"true",children:[...W,...O===null?[]:[O]].map((re,he)=>s.jsx(H2,{mark:re},he))})]}),C!==null&&s.jsx("div",{className:"viewer-toast",role:"status",children:C})]}),k&&s.jsxs("div",{className:"viewer-marks",children:[s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:D2.map(([re,he])=>s.jsx("button",{role:"radio","aria-checked":A===re,className:`viewer-icon ${A===re?"active":""}`,title:he,onClick:()=>N(re),children:s.jsx(U2,{tool:re})},re))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:oy.map(([re,he])=>s.jsx("button",{role:"radio","aria-checked":P===re,className:`viewer-icon ${P===re?"active":""}`,title:he,onClick:()=>F(re),children:s.jsx("span",{className:"width-dot",style:{width:re+3,height:re+3}})},re))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:ay.map(re=>s.jsx("button",{role:"radio","aria-checked":R===re,"aria-label":re,className:`swatch ${R===re?"active":""}`,style:{background:re},onClick:()=>D(re)},re))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",disabled:W.length===0,onClick:ie,title:"撤销(Ctrl+Z)",children:"↶"}),s.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[s.jsx("input",{type:"checkbox",checked:Z,onChange:re=>E(re.target.checked)}),"自动复制"]})]}),s.jsxs("div",{className:"viewer-bar",children:[s.jsx("button",{className:"viewer-icon",onClick:()=>G(.8),title:"缩小",children:"-"}),s.jsxs("button",{className:"viewer-zoom",onClick:H,title:"适应窗口(0)",children:[Math.round(y.scale*100),"%"]}),s.jsx("button",{className:"viewer-icon",onClick:()=>G(1.25),title:"放大",children:"+"}),s.jsx("button",{className:"viewer-icon",onClick:K,title:"原始大小",children:"1:1"}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void ge(),title:"旋转",children:"⟳"}),s.jsx("button",{className:`viewer-icon ${k?"active":""}`,onClick:()=>w(re=>!re),title:"标注:画框、箭头、直线",children:"✎"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void fe(W),title:"复制(Ctrl+C)",children:"⧉"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void xe(),title:"保存",children:"⤓"})]})]}),document.body)}function B2(e,t){const n=Math.round(window.innerWidth*.7),r=Math.round(window.innerHeight*.78)-cy*2,i=Math.min(1,n/e,r/t),o=Math.max(420,Math.round(e*i)+24),c=Math.max(300,Math.round(t*i)+24+cy*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-c)/2)),w:o,h:c}}function U2({tool:e}){const t={rect:"M5 6h14v12H5z",arrow:"M5 19 19 5M10 5h9v9",line:"M5 19 19 5",pen:"M4 20c3-1 4-5 7-8s6-6 9-8"}[e];return s.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:s.jsx("path",{d:t})})}function lN(e){const t=Math.atan2(e.y2-e.y1,e.x2-e.x1),n=e.width*4.5;return[-.5,.5].map(r=>[e.x2-n*Math.cos(t+r),e.y2-n*Math.sin(t+r)])}function H2({mark:e}){const t={stroke:e.color,strokeWidth:e.width,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};if(e.kind==="pen")return s.jsx("polyline",{...t,points:e.points.map(r=>r.join(",")).join(" ")});if(e.kind==="rect")return s.jsx("rect",{...t,x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)});const n=e.kind==="arrow"?lN(e):[];return s.jsxs("g",{...t,children:[s.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}),n.length>0&&s.jsx("polyline",{points:`${n[0][0]},${n[0][1]} ${e.x2},${e.y2} ${n[1][0]},${n[1][1]}`})]})}function Z2(e,t){if(e.strokeStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",e.beginPath(),t.kind==="pen")t.points.forEach(([n,r],i)=>i===0?e.moveTo(n,r):e.lineTo(n,r));else if(t.kind==="rect")e.rect(Math.min(t.x1,t.x2),Math.min(t.y1,t.y2),Math.abs(t.x2-t.x1),Math.abs(t.y2-t.y1));else if(e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),t.kind==="arrow"){const[n,r]=lN(t);e.moveTo(n[0],n[1]),e.lineTo(t.x2,t.y2),e.lineTo(r[0],r[1])}e.stroke()}const Zm=b.createContext(null),Vh=new Map;function W2(e,t){let n=Vh.get(t.attachmentId);if(n===void 0){const{attachmentId:r,mediaType:i,bytes:o,width:c,height:u}=t;n=e.connection.call("attachments/image",{attachmentId:r,mediaType:i,bytes:o,width:c,height:u}).then(f=>`data:${f.mediaType};base64,${f.data}`),n.catch(()=>Vh.delete(t.attachmentId)),Vh.set(t.attachmentId,n)}return n}function cN({image:e}){const t=b.useContext(Zm),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!1),f=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;b.useEffect(()=>{if(t===null||!f)return;let p=!0;return W2(t,e).then(m=>{p&&r(m)},m=>{p&&o(m instanceof Error?m.message:String(m))}),()=>{p=!1}},[t,f,e]);const d=e.name??`${e.width}×${e.height} 图片`;return f?i!==null?s.jsxs("span",{className:"stored-image missing",children:[d,"没能加载:",i]}):n===null?s.jsx("span",{className:"stored-image loading",style:{aspectRatio:`${e.width} / ${e.height}`}}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:s.jsx("img",{src:n,alt:d,width:e.width,height:e.height})}),c&&s.jsx(oN,{src:n,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):s.jsxs("span",{className:"stored-image missing",children:[d,"(当前后端不支持显示图片)"]})}const V2=3,q2=/^(编排|游戏信息|干预)[::]/,uy="adg:skill-offer:off",dy=e=>`adg:skill-offer:${e}`;function fy(e){try{return localStorage.getItem(e)}catch{return null}}function hy(e,t){try{localStorage.setItem(e,t)}catch{}}function G2(e){var i;let t=e.length-1;for(;t>=0&&e[t].kind!=="user";)t--;if(t<0)return;const n=e.slice(t+1),r=n.filter(o=>o.kind==="tool");if(!r.some(o=>o.name==="skill"||o.name==="skill_save"||o.status!=="ok")&&!n.some(o=>o.kind==="notice"&&o.tone==="error")&&!n.some(o=>o.kind==="context")&&!(r.length<V2||((i=n.at(-1))==null?void 0:i.kind)!=="assistant"))return e[t].id}function K2({session:e,title:t,items:n}){const r=G2(n),[i,o]=b.useState(()=>fy(uy)==="1"),[c,u]=b.useState(()=>fy(dy(e.id))),[f,d]=b.useState(!1);if(r===void 0||i||c===r||t!==null&&q2.test(t))return null;const p=()=>{hy(dy(e.id),r),u(r)},m=async()=>{d(!0);try{await e.prompt(Vk),p()}finally{d(!1)}};return s.jsxs("div",{className:"skill-offer",role:"region","aria-label":"存成技能",children:[s.jsx(ee,{name:"sparkles"}),s.jsxs("div",{className:"skill-offer-text",children:[s.jsx("strong",{children:"要把这次的做法存成技能吗?"}),s.jsx("span",{children:"agent 会把刚才走通的步骤浓缩成一份技能;下次做同样的事直接照着做,不用重新摸索,少调用模型。"})]}),s.jsxs("div",{className:"skill-offer-actions",children:[s.jsx("button",{className:"link-button small",onClick:()=>{hy(uy,"1"),o(!0)},children:"不再提示"}),s.jsx("button",{className:"small-button",disabled:f,onClick:p,children:"这次不用"}),s.jsx("button",{className:"small-button primary",disabled:f,onClick:()=>void m(),children:"存成技能"})]})]})}function Y2(e,t){const n=je(e.connection.status),r=je(e.capabilities),[i,o]=b.useState([]),c=t&&r.has("notify");return b.useEffect(()=>{if(!c||n.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(f=>{u&&o(f.items)}).catch(()=>{}),()=>{u=!1}},[e,c,n.state]),b.useEffect(()=>{if(c)return e.connection.on("notify/notice",({item:u})=>o(f=>f.findIndex(p=>p.id===u.id)<0?[...f,u]:f.map(p=>p.id===u.id?u:p)))},[e,c]),c?i:[]}function X2(e,t,n,r){const i=t.filter(d=>d.at>=n);if(i.length===0)return[...e];const o=new Array(e.length);let c=1/0;for(let d=e.length-1;d>=0;d--){const p=e[d];"time"in p&&typeof p.time=="number"&&(c=p.time),o[d]=c}const u=[];let f=0;for(e.forEach((d,p)=>{if(r(d))for(;f<i.length&&i[f].at<o[p];)u.push(py(i[f++]));u.push(d)});f<i.length;)u.push(py(i[f++]));return u}function py(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const Q2={info:"send",success:"check",warning:"alert",error:"alert"};function J2({client:e,notice:t}){const[n,r]=b.useState(null),[i,o]=b.useState(null),c=t.acted===void 0&&t.done===void 0&&t.actions.length>0,u=d=>{r(d),o(null),e.connection.call("notify/act",{noticeId:t.id,actionId:d}).catch(p=>o(ze(p))).finally(()=>r(null))},f=new Date(t.at).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"});return s.jsxs("div",{className:`sent-notice ${t.severity}`,children:[s.jsxs("div",{className:"sent-notice-head",children:[s.jsx(ee,{name:Q2[t.severity]}),s.jsx("span",{className:"sent-notice-title",children:t.title}),s.jsx("span",{className:"spacer"}),s.jsxs("span",{className:"muted small",children:[t.channels.length>0?`发到${t.channels.join("、")}`:"只在软件里"," · ",f]})]}),s.jsx("div",{className:"sent-notice-text",children:t.text}),t.image===!0&&s.jsx("div",{className:"muted small",children:"(附了一张截图,在聊天软件里看)"}),c&&s.jsxs("div",{className:"sent-notice-actions",children:[t.actions.map(d=>s.jsx("button",{className:`small-button ${d.style==="primary"?"primary":d.style==="danger"?"danger-outline":""}`,disabled:n!==null,onClick:()=>u(d.id),children:n===d.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),d.label]}):d.label},d.id)),s.jsx("span",{className:"muted small",children:"也可以直接跟助手说"})]}),t.acted!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(ee,{name:"check"}),t.acted.by,"选了「",t.acted.label,"」——",t.acted.result]}),t.acted===void 0&&t.done!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(ee,{name:"check"}),t.done]}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}const ez=80;function tz({client:e,session:t,state:n}){var N,R,D;const r=b.useMemo(()=>W$(n.events,n.live,n.pending),[n.events,n.live,n.pending,n.version]),i=rw(e,xr),o=Y2(e,i.sessionId===t.id),c=n.hasMore?((N=n.events[0])==null?void 0:N.time)??0:0,u=b.useMemo(()=>nz(X2(r,o,c,uN)),[r,o,c]),f=fi(e),d=je(e.sessions).items.find(P=>P.id===t.id),p=((R=f.find(P=>P.id===(d===void 0?void 0:_a(d,f))))==null?void 0:R.name)??br.name,m=xM(e,t.id),g=m.filter(P=>P.fromSession===t.id&&P.callId===void 0&&P.state==="running"),v=b.useRef(null),y=iN(ez),S=y.following,k=P=>{y.onScroll(P),P.currentTarget.scrollTop<40&&n.hasMore&&!n.loadingOlder&&t.loadOlder()};b.useLayoutEffect(()=>{const P=v.current;P!==null&&S.current&&(P.scrollTop=P.scrollHeight)},[r,o]);const w=(D=n.events[0])==null?void 0:D.seq,A=b.useRef(0);return b.useLayoutEffect(()=>{const P=v.current;P!==null&&(A.current!==0&&!S.current&&(P.scrollTop+=P.scrollHeight-A.current),A.current=P.scrollHeight)},[w]),s.jsx(Zm.Provider,{value:e,children:s.jsx(sN.Provider,{value:m,children:s.jsx("div",{className:"chat",ref:v,onScroll:k,onWheel:y.onWheel,children:s.jsxs("div",{className:"chat-inner",children:[n.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:n.loadingOlder,onClick:()=>void t.loadOlder(),children:n.loadingOlder?"加载中…":"加载更早的消息"}),n.status==="opening"&&r.length===0&&s.jsx("div",{className:"empty",children:"正在打开会话…"}),n.status!=="opening"&&r.length===0&&s.jsxs("div",{className:"empty chat-empty",children:[s.jsx(xd,{size:"lg"}),s.jsx("h2",{children:"今天,我们一起完成什么?"}),s.jsxs("p",{children:["一个问题、一段代码,或一个还不成熟的想法。",s.jsx("br",{}),"在下方写下来,让对话开始。"]})]}),u.map((P,F)=>P.kind==="sent"?s.jsx(J2,{client:e,notice:P.item.notice},P.item.id):P.kind==="tools"?s.jsx(bu,{name:p,header:P.header,children:s.jsx(fN,{tools:P.tools})},P.id):P.kind==="delegation"?s.jsx(bu,{name:p,header:P.header,children:s.jsx(i2,{client:e,item:P.item,handOffs:m})},P.item.id):P.kind==="process"?s.jsx(bu,{name:p,header:P.header,children:s.jsx(lz,{items:P.items,active:n.running&&F===u.length-1,onDismiss:W=>t.dismissPending(W)})},P.id):s.jsx(bu,{name:p,header:P.header,children:s.jsx(dN,{item:P.item,onDismiss:W=>t.dismissPending(W)})},P.item.id)),g.map(P=>s.jsx(a2,{client:e,handOff:P},P.id)),n.running&&n.live===null&&s.jsxs("div",{className:"thinking",children:[s.jsxs("span",{className:"dot-pulse",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}),"正在处理…"]}),!n.running&&n.queue.length===0&&s.jsx(K2,{session:t,title:n.title,items:r})]})})})})}function nz(e){const t=[];let n=0;for(let r=0;r<=e.length;r++){const i=e[r];i!==void 0&&i.kind!=="sent"&&!uN(i)||(sz(e.slice(n,r),t),i!==void 0&&t.push(i.kind==="sent"?{kind:"sent",item:i}:{kind:"item",item:i,header:null}),n=r+1)}return t}function uN(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function sz(e,t){let n=!1;const r=e.find(d=>d.kind==="assistant"&&d.model!==void 0),i=()=>n?null:(n=!0,{model:(r==null?void 0:r.kind)==="assistant"?r.model:void 0}),o=d=>{if(d.kind==="tool"&&d.name===ny)t.push({kind:"delegation",item:d,header:i()});else if(d.kind==="tool"){const p=t.at(-1);(p==null?void 0:p.kind)==="tools"?t[t.length-1]={...p,tools:[...p.tools,d]}:t.push({kind:"tools",id:`tools-${d.id}`,tools:[d],header:i()})}else t.push({kind:"item",item:d,header:d.kind==="assistant"?i():null})};let c=[];const u=()=>{if(c.some(d=>d.kind==="tool"))t.push({kind:"process",id:`process-${c[0].id}`,items:c,header:i()});else for(const d of c)o(d);c=[]};let f=e.length;for(let d=e.length-1;d>=0;d--){const p=e[d];if(p.kind==="assistant"&&p.text.trim()!==""){f=d;break}}for(let d=0;d<f;d++){const p=e[d];p.kind==="notice"||p.kind==="context"||p.kind==="tool"&&(p.approval==="asked"||p.name===ny)?(u(),o(p)):c.push(p)}u();for(let d=f;d<e.length;d++)o(e[d])}function bu({name:e,header:t,children:n}){return t===null?s.jsx(s.Fragment,{children:n}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"turn-header",children:[s.jsx(xd,{size:"sm"}),s.jsx("span",{className:"turn-name",children:e}),t.model!==void 0&&s.jsx("span",{className:"turn-model",children:t.model})]}),n]})}function rz({text:e}){const t=E$(e);return t===void 0?s.jsx(s.Fragment,{children:e}):s.jsxs(s.Fragment,{children:[t.typed,s.jsxs("details",{className:"slash-expansion",children:[s.jsx("summary",{children:"发给 agent 的完整指令"}),t.expansion]})]})}const iz=/^(这条消息来自([^。)]+)。[^\n]*)\n/,az=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function oz(e){const t=iz.exec(e),n=(t===null?e:e.slice(t[0].length)).replace(az,"");return t===null?{text:n}:{text:n,channel:t[1]}}const dN=b.memo(function({item:t,onDismiss:n}){var o;const r=b.useContext(Zm),i=b.useContext(sN);switch(t.kind){case"user":{const c=t.pending===void 0?O$(t.text):void 0;if(c!==void 0&&r!==null)return s.jsx(o2,{client:r,note:c,handOffs:i});const u=t.pending===void 0?R$(t.text):void 0;if(u!==void 0&&r!==null)return s.jsx(l2,{client:r,note:u,handOffs:i});const f=oz(t.text);return s.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,children:[f.channel!==void 0&&s.jsxs("div",{className:"msg-from",children:["来自",f.channel]}),s.jsxs("div",{className:"bubble",children:[s.jsx(rz,{text:f.text}),t.imageRefs.length>0&&s.jsx("div",{className:"chat-images",children:t.imageRefs.map(d=>s.jsx(cN,{image:d},d.attachmentId))}),(t.images>t.imageRefs.length||t.files>0)&&s.jsxs("div",{className:"attachments",children:[t.images>t.imageRefs.length&&s.jsxs("span",{children:[s.jsx(ee,{name:"image"}),t.images-t.imageRefs.length," 张图片"]}),t.files>0&&s.jsxs("span",{children:[s.jsx(ee,{name:"paperclip"}),t.files," 个文件"]})]})]}),((o=t.pending)==null?void 0:o.failed)!==void 0&&s.jsxs("div",{className:"send-failed",children:["发送失败:",t.pending.failed,s.jsx("button",{className:"link-button",onClick:()=>n(t.pending.requestId),children:"移除"})]})]})}case"assistant":return!t.live&&$$(t.text)?s.jsxs("div",{className:"quiet-reply",children:[s.jsx(ee,{name:"check"}),"看过了,没有要告诉你的"]}):s.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,children:[t.reasoning.trim()!==""&&s.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[s.jsxs("summary",{children:[s.jsx(ee,{name:"chevron"}),t.live&&t.text===""?s.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),s.jsx(Ki,{text:t.reasoning})]}),t.text!==""&&s.jsx(Ki,{text:t.text}),t.live&&s.jsx("span",{className:"cursor"}),t.interrupted&&s.jsx("div",{className:"muted small",children:"(已中断)"})]});case"tool":return s.jsx(fN,{tools:[t]});case"context":return s.jsxs("details",{className:"context-row",children:[s.jsxs("summary",{children:[s.jsx(ee,{name:"info"}),t.summary!==""?t.summary:t.title]}),s.jsx("pre",{children:t.text})]});case"notice":return s.jsxs("div",{className:`notice ${t.tone}`,children:[t.tone==="error"&&s.jsx(ee,{name:"alert"}),t.text]})}});function lz({items:e,active:t,onDismiss:n}){const r=e.filter(d=>d.kind==="tool"),i=r.filter(d=>d.status==="running").length,o=r.filter(d=>d.status==="error").length,[c,u]=b.useState(!1),f=t&&!c?cz(e.at(-1)):void 0;return s.jsxs("div",{className:"tool-group process-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>u(!c),"aria-expanded":c,children:[s.jsx(ee,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:`执行了 ${r.length} 个步骤`}),f!==void 0&&f!==""&&s.jsx("span",{className:"process-now",children:f}),s.jsxs("span",{className:"tool-group-meta",children:[i>0&&s.jsxs("span",{className:"tone-running",children:[i," 个进行中"]}),o>0&&s.jsxs("span",{className:"tone-failed",children:[o," 个失败"]})]}),s.jsx(ee,{name:"chevron-down",className:`chevron-icon ${c?"open":""}`})]}),c&&e.map(d=>d.kind==="tool"?s.jsx(pN,{item:d},d.id):s.jsx("div",{className:"process-note",children:s.jsx(dN,{item:d,onDismiss:n})},d.id))]})}function cz(e){return e.kind==="tool"?`${e.name} ${Wk(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
197
- `)[0]||"正在思考…":""}function fN({tools:e}){const t=e.filter(c=>c.status==="running").length,n=e.filter(c=>c.status==="error").length,[r,i]=b.useState(null),o=r??(t>0||n>0||e.length<=4);return s.jsxs("div",{className:"tool-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>i(!o),"aria-expanded":o,children:[s.jsx(ee,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:e.length===1?"执行了 1 个步骤":`执行了 ${e.length} 个步骤`}),s.jsxs("span",{className:"tool-group-meta",children:[t>0&&s.jsxs("span",{className:"tone-running",children:[t," 个进行中"]}),n>0&&s.jsxs("span",{className:"tone-failed",children:[n," 个失败"]})]}),s.jsx(ee,{name:"chevron-down",className:`chevron-icon ${o?"open":""}`})]}),o&&e.map(c=>s.jsx(pN,{item:c},c.id))]})}const hN={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function pN({item:e}){const[t,n]=b.useState(!1),r=b.useMemo(()=>Wk(e.arguments),[e.arguments]);return b.useEffect(()=>{e.status==="error"&&n(!0)},[e.status]),s.jsxs("div",{className:`tool ${e.status}`,children:[s.jsxs("button",{className:"tool-head",onClick:()=>n(i=>!i),"aria-expanded":t,children:[s.jsx(uz,{status:e.status}),s.jsx("span",{className:"tool-name",children:e.name}),s.jsx("span",{className:"tool-summary",children:r}),e.approval!==void 0&&s.jsx("span",{className:`badge approval-${e.approval}`,children:dz(e.approval)}),s.jsx("span",{className:"tool-status",children:hN[e.status]})]}),e.images!==void 0&&s.jsx("div",{className:"chat-images tool-images",children:e.images.map(i=>s.jsx(cN,{image:i},i.attachmentId))}),t&&s.jsxs("div",{className:"tool-body",children:[s.jsx("div",{className:"label",children:"参数"}),s.jsx("pre",{children:Um(e.arguments)}),e.result!==void 0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"label",children:["结果",e.error!==void 0?` · ${e.error}`:""]}),s.jsx("pre",{children:e.result})]})]})]})}function uz({status:e}){return e==="running"?s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"运行中"}):e==="ok"?s.jsx("span",{className:"tool-icon ok",role:"img","aria-label":"完成",children:s.jsx(ee,{name:"check"})}):e==="error"?s.jsx("span",{className:"tool-icon error",role:"img","aria-label":"失败",children:s.jsx(ee,{name:"close"})}):s.jsx("span",{className:"tool-icon",role:"img","aria-label":hN[e]??e,children:s.jsx(ee,{name:"info"})})}function dz(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const fz={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:tz}]},hz=[],qh=320,ku=4;function yn({value:e,options:t,onChange:n,id:r,disabled:i,placeholder:o="请选择",inline:c,className:u,...f}){const d=b.useId(),p=b.useRef(null),m=b.useRef(null),[g,v]=b.useState(!1),[y,S]=b.useState(-1),[k,w]=b.useState({}),A=t.findIndex(T=>T.value===e),N=A===-1?void 0:t[A],R=T=>t[T]!==void 0&&t[T].disabled!==!0,D=(T,Z)=>{for(let E=T+Z;E>=0&&E<t.length;E+=Z)if(R(E))return E;return T},P=(T=A)=>{i!==!0&&(S(R(T)?T:D(-1,1)),v(!0))},F=(T=!0)=>{var Z;v(!1),T&&((Z=p.current)==null||Z.focus())},W=T=>{R(T)&&(t[T].value!==e&&n(t[T].value),F())};b.useLayoutEffect(()=>{if(!g)return;const T=()=>{var B,H;const Z=(B=p.current)==null?void 0:B.getBoundingClientRect();if(Z===void 0)return;const E=window.innerHeight-Z.bottom-ku-8,C=Z.top-ku-8,$=E<Math.min(qh,((H=m.current)==null?void 0:H.scrollHeight)??qh)&&C>E,L=Math.max(Z.width,180);w({left:Math.max(8,Math.min(Z.left,window.innerWidth-L-8)),minWidth:L,maxWidth:Math.max(L,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(qh,$?C:E),...$?{bottom:window.innerHeight-Z.top+ku}:{top:Z.bottom+ku}})};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[g]),b.useEffect(()=>{var Z;if(!g)return;(Z=m.current)==null||Z.focus({preventScroll:!0});const T=E=>{var $,L;const C=E.target;!(($=m.current)!=null&&$.contains(C))&&!((L=p.current)!=null&&L.contains(C))&&F(!1)};return document.addEventListener("pointerdown",T,!0),()=>document.removeEventListener("pointerdown",T,!0)},[g]),b.useEffect(()=>{var T,Z;g&&y>=0&&((Z=(T=m.current)==null?void 0:T.querySelector(`[data-index="${y}"]`))==null||Z.scrollIntoView({block:"nearest"}))},[g,y]);const M=T=>{(T.key==="ArrowDown"||T.key==="ArrowUp"||T.key==="Enter"||T.key===" ")&&(T.preventDefault(),P())},O=T=>{const E={ArrowDown:()=>S(C=>D(C,1)),ArrowUp:()=>S(C=>D(C,-1)),Home:()=>S(D(-1,1)),End:()=>S(D(t.length,-1)),Enter:()=>W(y)," ":()=>W(y),Escape:()=>F(),Tab:()=>F()}[T.key];if(E!==void 0){T.key!=="Tab"&&T.preventDefault(),E();return}if(T.key.length===1&&!T.ctrlKey&&!T.metaKey&&!T.altKey){const C=T.key.toLowerCase();for(let $=1;$<=t.length;$++){const L=(y+$)%t.length;if(R(L)&&t[L].label.toLowerCase().startsWith(C)){S(L);break}}}};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:p,id:r,type:"button",disabled:i,className:`select-trigger text-input plain ${c===!0?"inline":""} ${g?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?d:void 0,"aria-label":f["aria-label"],onClick:()=>g?F():P(),onKeyDown:M,children:s.jsx("span",{className:`select-value ${N===void 0?"placeholder":""}`,children:(N==null?void 0:N.label)??o})}),g&&Hm.createPortal(s.jsxs("ul",{ref:m,id:d,role:"listbox",tabIndex:-1,className:"select-list",style:k,"aria-label":f["aria-label"],"aria-activedescendant":y>=0?`${d}-${y}`:void 0,onKeyDown:O,children:[t.map((T,Z)=>{var E;return s.jsxs("li",{role:"presentation",children:[T.group!==void 0&&T.group!==((E=t[Z-1])==null?void 0:E.group)&&s.jsx("div",{className:"select-group",children:T.group}),s.jsxs("div",{id:`${d}-${Z}`,"data-index":Z,role:"option","aria-selected":Z===A,"aria-disabled":T.disabled===!0,className:`select-option ${Z===y?"active":""} ${Z===A?"selected":""} ${T.disabled===!0?"disabled":""}`,onPointerMove:()=>{R(Z)&&Z!==y&&S(Z)},onClick:()=>W(Z),children:[s.jsxs("span",{className:"select-text",children:[s.jsx("span",{children:T.label}),T.hint!==void 0&&s.jsx("span",{className:"select-hint",children:T.hint})]}),Z===A&&s.jsx(ee,{name:"check",className:"select-check"})]})]},`${T.group??""}\0${T.value}`)}),t.length===0&&s.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const pz={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function mz({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(null),[u,f]=b.useState(0),[d,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(""),[w,A]=b.useState(""),[N,R]=b.useState(""),[D,P]=b.useState(""),[F,W]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>f($=>$+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let $=!0;return e.connection.call("feishu/settings",{}).then(L=>{$&&(i(L),k(B=>B===""?L.settings.appId??"":B),R(B=>B===""?L.settings.chatId??"":B))}).catch(L=>{$&&g(ze(L))}),e.connection.call("notify/status",{}).then(L=>{$&&c(L.channels.find(B=>B.id==="feishu")??null)}).catch(()=>{}),()=>{$=!1}},[e,t.state,u]);const M=async($,L,B)=>{p($),g(null),y(null);try{const H=await L();H!==null&&typeof H=="object"&&"settings"in H&&i(H),B!==void 0&&y(B),f(G=>G+1)}catch(H){g(ze(H))}finally{p(null)}},O=()=>M("credentials",async()=>(w.trim()!==""&&await e.setCredential(ET,w.trim()),A(""),e.connection.call("feishu/settings/set",{appId:S.trim()===""?null:S.trim(),enabled:!0})),"已保存,正在连接…"),T=()=>M("test",async()=>{const $=await e.connection.call("notify/test",{channel:"feishu"});if($.failed.length>0)throw new Error($.failed.map(L=>L.error).join(";"))},"测试消息已发送,去飞书看看"),Z=r==null?void 0:r.settings,[E,C]=pz[(o==null?void 0:o.state)??"off"];return s.jsxs("div",{className:"remote-section",children:[s.jsx("p",{className:"muted",children:"脚本出问题的通知带截图和「停止 / 重试 / 忽略」按钮;agent 需要你确认的操作也会发成卡片,在飞书或这里先回答的生效。"}),s.jsxs("details",{className:"card guide",children:[s.jsx("summary",{children:s.jsx("strong",{children:"第一次使用:在飞书开放平台创建应用(约 5 分钟)"})}),s.jsxs("ol",{className:"guide-steps",children:[s.jsxs("li",{children:["打开 ",s.jsx("a",{href:"https://open.feishu.cn/app",target:"_blank",rel:"noreferrer",children:"open.feishu.cn/app"}),"(国际版 Lark 用 open.larksuite.com/app),「创建企业自建应用」。"]}),s.jsx("li",{children:"「添加应用能力」→ 添加「机器人」。"}),s.jsxs("li",{children:["「权限管理」开通:",s.jsx("code",{children:"im:message"}),"(获取与发送单聊、群组消息)、",s.jsx("code",{children:"im:message:send_as_bot"}),"、",s.jsx("code",{children:"im:message.p2p_msg:readonly"}),"(读取用户发给机器人的单聊消息)、",s.jsx("code",{children:"im:message.group_at_msg:readonly"}),"(接收群聊中 @ 机器人的消息,可选)、",s.jsx("code",{children:"im:resource"}),"(上传截图)。"]}),s.jsxs("li",{children:["「事件与回调」→「事件配置」:订阅方式选",s.jsx("strong",{children:"使用长连接接收事件"}),",添加事件 ",s.jsx("code",{children:"im.message.receive_v1"}),"(接收消息)。"]}),s.jsxs("li",{children:["「事件与回调」→「回调配置」:订阅方式同样选",s.jsx("strong",{children:"使用长连接接收回调"}),",添加回调 ",s.jsx("code",{children:"card.action.trigger"}),"(卡片回传交互)。"]}),s.jsx("li",{children:"「版本管理与发布」创建版本并发布,可用范围包含你自己。权限或事件改过以后都要重新发布才生效。"}),s.jsx("li",{children:"把「凭证与基础信息」里的 App ID 和 App Secret 填到下面;保存后在飞书里搜索机器人名字,给它发一条消息,再回到这里「允许」自己。"})]}),s.jsx("p",{className:"muted small",children:"先保存凭证再配置长连接:飞书要求应用在线时才能保存「长连接」订阅方式。"})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"连接"}),s.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知会发给 ${o.recipients} 个接收方`:"…")})]}),s.jsx("span",{className:`badge ${E}`,children:C})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map($=>s.jsxs("li",{className:$.ok===!0?"ok":$.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:$.ok===!0?"✓":$.ok===!1?"✗":"…"}),s.jsx("span",{children:$.label}),$.detail!==void 0&&s.jsx("span",{className:"muted small",children:$.detail})]},$.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void M("check",()=>e.connection.call("feishu/check",{})),children:d==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:d!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void T(),children:"发送测试消息"}),Z!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:Z.enabled,disabled:d!==null,onChange:$=>void M("enable",()=>e.connection.call("feishu/settings/set",{enabled:$.target.checked}))}),"启用飞书"]})]})]}),Z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"应用凭证"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),s.jsx(yn,{id:"feishu-domain",value:Z.domain,disabled:d!==null,onChange:$=>void M("domain",()=>e.connection.call("feishu/settings/set",{domain:$})),options:[{value:"feishu",label:"飞书",hint:"open.feishu.cn"},{value:"lark",label:"Lark 国际版",hint:"open.larksuite.com"}]}),s.jsx("label",{className:"field-label",htmlFor:"feishu-app-id",children:"App ID"}),s.jsx("input",{id:"feishu-app-id",className:"text-input",value:S,onChange:$=>k($.target.value),placeholder:"cli_xxxxxxxx",spellCheck:!1}),s.jsxs("label",{className:"field-label",htmlFor:"feishu-secret",children:["App Secret ",(r==null?void 0:r.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"feishu-secret",className:"text-input",type:"password",value:w,onChange:$=>A($.target.value),placeholder:(r==null?void 0:r.secretConfigured)===!0?"留空则保持不变":"在「凭证与基础信息」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"App Secret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:d!==null||S.trim()==="",onClick:()=>void O(),children:d==="credentials"?"保存中…":"保存并连接"})]})]}),Z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),Z.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:Z.allowedUsers.map($=>s.jsxs("li",{children:[s.jsx("span",{children:$.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:$.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void M(`rm-${$.openId}`,()=>e.connection.call("feishu/users/remove",{openId:$.openId})),children:"移除"})]},$.openId))}),((r==null?void 0:r.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:r.pending.map($=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:$.openId}),s.jsxs("span",{className:"muted small",children:["「",$.text,"」 · ",Tt($.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:F[$.openId]??"",onChange:L=>W(B=>({...B,[$.openId]:L.target.value}))}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void M(`dismiss-${$.openId}`,()=>e.connection.call("feishu/users/remove",{openId:$.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:d!==null,onClick:()=>void M(`allow-${$.openId}`,()=>{var L;return e.connection.call("feishu/users/allow",{openId:$.openId,...(L=F[$.openId])!=null&&L.trim()?{name:F[$.openId].trim()}:{}})}),children:"允许"})]},$.openId))})]}),s.jsx("label",{className:"field-label",htmlFor:"feishu-manual",children:"手动添加 open_id"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"feishu-manual",className:"text-input",value:D,onChange:$=>P($.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:d!==null||D.trim()==="",onClick:()=>void M("manual",async()=>{const $=await e.connection.call("feishu/users/allow",{openId:D.trim()});return P(""),$}),children:"添加"})]})]}),Z!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"通知"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:Z.otherApprovals,disabled:d!==null,onChange:$=>void M("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:$.target.checked}))}),"软件里的会话(对话、定时运行、游戏读取)需要确认或 agent 提问时也发到飞书"]}),s.jsx("p",{className:"muted small",children:"在飞书里和 agent 的对话需要确认、或 agent 有问题问你时,只发给发消息的那个人(直接回复文字也算回答);软件里的会话默认只在界面里问。两边都能回答,先回答的生效。"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-chat",children:"同时发到群(可选,填群 ID,机器人需要在群里)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"feishu-chat",className:"text-input",value:N,onChange:$=>R($.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void M("chat",()=>e.connection.call("feishu/settings/set",{chatId:N.trim()===""?null:N.trim()})),children:"保存"})]})]}),v!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(ee,{name:"check"}),s.jsx("span",{children:v})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:m})]})]})}const gz={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function xz({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(null),[u,f]=b.useState(0),[d,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(""),[w,A]=b.useState(""),[N,R]=b.useState(""),[D,P]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>f(E=>E+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let E=!0;return e.connection.call("qqbot/settings",{}).then(C=>{E&&(i(C),k($=>$===""?C.settings.appId??"":$))}).catch(C=>{E&&g(ze(C))}),e.connection.call("notify/status",{}).then(C=>{E&&c(C.channels.find($=>$.id==="qq")??null)}).catch(()=>{}),()=>{E=!1}},[e,t.state,u]);const F=async(E,C,$)=>{p(E),g(null),y(null);try{const L=await C();L!==null&&typeof L=="object"&&"settings"in L&&i(L),$!==void 0&&y($),f(B=>B+1)}catch(L){g(ze(L))}finally{p(null)}},W=()=>F("credentials",async()=>(w.trim()!==""&&await e.setCredential(CT,w.trim()),A(""),e.connection.call("qqbot/settings/set",{appId:S.trim()===""?null:S.trim(),enabled:!0})),"已保存,正在连接…"),M=()=>F("test",async()=>{const E=await e.connection.call("notify/test",{channel:"qq"});if(E.failed.length>0)throw new Error(E.failed.map(C=>C.error).join(";"))},"测试消息已发送,去 QQ 看看"),O=r==null?void 0:r.settings,[T,Z]=gz[(o==null?void 0:o.state)??"off"];return s.jsxs("div",{className:"remote-section",children:[s.jsx("p",{className:"muted",children:"QQ 官方机器人:在 QQ 里和它单聊。消息用 markdown 显示;通知、需要你确认的操作和助手问你的问题下面有按钮,点一下就是回复,也可以直接打字。机器人没有按钮权限时会改成文字,告诉你回复什么。"}),s.jsxs("details",{className:"card guide",children:[s.jsx("summary",{children:s.jsx("strong",{children:"第一次使用:在 QQ 开放平台创建机器人(约 10 分钟)"})}),s.jsxs("ol",{className:"guide-steps",children:[s.jsxs("li",{children:["打开 ",s.jsx("a",{href:"https://bot.q.qq.com/open",target:"_blank",rel:"noreferrer",children:"QQ 开放平台"}),",用 QQ 扫码登录,创建一个机器人。"]}),s.jsxs("li",{children:["在机器人的「开发设置」里复制 ",s.jsx("strong",{children:"AppID"})," 和 ",s.jsx("strong",{children:"AppSecret"}),",填到下面。"]}),s.jsxs("li",{children:["「功能配置」里开启",s.jsx("strong",{children:"单聊"}),"(消息走 WebSocket,不用填回调地址)。还在沙箱阶段的机器人,要把自己的 QQ 加进「沙箱配置」的测试成员。"]}),s.jsx("li",{children:"保存后用手机 QQ 找到机器人(资料卡或沙箱二维码),给它发一条消息,再回到这里「允许」自己。"})]}),s.jsx("p",{className:"muted small",children:"机器人发给你的不是回复的消息(同步的对话、通知)算「主动消息」:在机器人资料卡里要开着「允许主动发送」。"})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"连接"}),s.jsx("p",{className:"muted small",children:(o==null?void 0:o.detail)??((o==null?void 0:o.state)==="ready"?`通知和对话会发给 ${o.recipients} 个人`:"…")})]}),s.jsx("span",{className:`badge ${T}`,children:Z})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(E=>s.jsxs("li",{className:E.ok===!0?"ok":E.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:E.ok===!0?"✓":E.ok===!1?"✗":"…"}),s.jsx("span",{children:E.label}),E.detail!==void 0&&s.jsx("span",{className:"muted small",children:E.detail})]},E.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void F("check",()=>e.connection.call("qqbot/check",{})),children:d==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:d!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void M(),children:"发送测试消息"}),O!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:O.enabled,disabled:d!==null,onChange:E=>void F("enable",()=>e.connection.call("qqbot/settings/set",{enabled:E.target.checked}))}),"启用 QQ 机器人"]})]})]}),O!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"机器人凭证"}),s.jsx("label",{className:"field-label",htmlFor:"qq-app-id",children:"AppID"}),s.jsx("input",{id:"qq-app-id",className:"text-input",value:S,onChange:E=>k(E.target.value),placeholder:"102xxxxxx",spellCheck:!1,inputMode:"numeric"}),s.jsxs("label",{className:"field-label",htmlFor:"qq-secret",children:["AppSecret ",(r==null?void 0:r.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"qq-secret",className:"text-input",type:"password",value:w,onChange:E=>A(E.target.value),placeholder:(r==null?void 0:r.secretConfigured)===!0?"留空则保持不变":"在「开发设置」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"AppSecret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:d!==null||S.trim()==="",onClick:()=>void W(),children:d==="credentials"?"保存中…":"保存并连接"})]})]}),O!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),O.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:O.allowedUsers.map(E=>s.jsxs("li",{children:[s.jsx("span",{children:E.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:E.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void F(`rm-${E.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:E.openId})),children:"移除"})]},E.openId))}),((r==null?void 0:r.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:r.pending.map(E=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:E.openId}),s.jsxs("span",{className:"muted small",children:["「",E.text,"」 · ",Tt(E.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:D[E.openId]??"",onChange:C=>P($=>({...$,[E.openId]:C.target.value}))}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void F(`dismiss-${E.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:E.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:d!==null,onClick:()=>void F(`allow-${E.openId}`,()=>{var C;return e.connection.call("qqbot/users/allow",{openId:E.openId,...(C=D[E.openId])!=null&&C.trim()?{name:D[E.openId].trim()}:{}})}),children:"允许"})]},E.openId))})]}),s.jsx("label",{className:"field-label",htmlFor:"qq-manual",children:"手动添加 user_openid"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"qq-manual",className:"text-input",value:N,onChange:E=>R(E.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:d!==null||N.trim()==="",onClick:()=>void F("manual",async()=>{const E=await e.connection.call("qqbot/users/allow",{openId:N.trim()});return R(""),E}),children:"添加"})]})]}),v!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(ee,{name:"check"}),s.jsx("span",{children:v})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:m})]})]})}const vz=[{id:"feishu",title:"飞书",capability:"feishu",component:mz},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:xz}];function yz({client:e}){var c;const t=je(e.capabilities),n=vz.filter(u=>t.has(u.capability)),[r,i]=b.useState(((c=n[0])==null?void 0:c.id)??"feishu"),o=n.find(u=>u.id===r)??n[0];return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"远程连接"}),s.jsx("p",{children:"不在电脑前也能用:在飞书或 QQ 里和助手说话。和助手的对话两边完全一样——在软件里说的、在聊天软件里说的、助手和其他 agent 之间的往来、助手的回复,都会同步过去;脚本出问题的通知也发到那里,在聊天软件里点按钮或直接回复就能处理。"}),n.length>1&&s.jsx("nav",{className:"agent-tabs remote-tabs",role:"tablist","aria-label":"远程连接方式",children:n.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===(o==null?void 0:o.id),className:u.id===(o==null?void 0:o.id)?"active":"",onClick:()=>i(u.id),children:u.title},u.id))}),o===void 0?s.jsx("p",{className:"muted",children:"当前连接没有提供远程连接。"}):s.jsx(o.component,{client:e},o.id)]})}const bz=(e,t)=>{try{const n=localStorage.getItem(`adg.fold.${e}`);return n===null?t:n==="1"}catch{return t}};function kz(e,t=!0){const[n,r]=b.useState(()=>bz(e,t));return[n,()=>r(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function wz({open:e,onToggle:t,children:n,count:r,className:i=""}){return s.jsxs("button",{type:"button",className:`fold-head ${i}`,"aria-expanded":e,onClick:t,children:[s.jsx(ee,{name:"chevron",className:`fold-chevron ${e?"open":""}`}),s.jsx("span",{className:"fold-title",children:n}),r!==void 0&&s.jsx("span",{className:"fold-count",children:r})]})}function Na({id:e,title:t,count:n,initial:r=!0,children:i,className:o=""}){const[c,u]=kz(e,r);return s.jsxs("div",{className:`fold ${o}`,children:[s.jsx(wz,{open:c,onToggle:u,...n===void 0?{}:{count:n},children:t}),c&&i]})}function mN({client:e,scriptId:t,taskId:n,name:r,spec:i,value:o,onChange:c,onCreated:u,profile:f}){const[d,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(!1),S=async()=>{const w=(m==null?void 0:m.trim())??"";if(w!==""){p(null),y(!0);try{const{value:A}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:n,param:r,name:w,...f===void 0?{}:{profile:f}});g(null),u==null||u(),c(A)}catch(A){p(ze(A))}finally{y(!1)}}};let k;if(i.choices!==void 0){const w=i.choices.some(A=>A.value===o);k=s.jsx(yn,{"aria-label":r,value:w?o:"",placeholder:i.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:A=>{A==="\0new"?g(N=>N??"MultiGameAssistant"):c(A)},options:[...i.choices.map(A=>({value:A.value,label:A.label,...A.detail===void 0?{}:{hint:A.detail}})),...i.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else i.type==="boolean"?k=s.jsx(yn,{"aria-label":r,value:o,onChange:c,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):i.enum!==void 0?k=s.jsx(yn,{"aria-label":r,value:o,onChange:c,options:i.enum.map(w=>({value:String(w),label:String(w)}))}):k=s.jsx("input",{className:"text-input plain","aria-label":r,value:o,placeholder:i.default===void 0?"必填":String(i.default),inputMode:i.type==="string"?"text":"numeric",onChange:w=>c(w.target.value)});return s.jsxs("div",{className:"param-row",role:"group","aria-label":r,children:[s.jsxs("span",{className:"field-label",children:[r,i.description===void 0?"":` · ${i.description}`]}),k,m!==null&&s.jsxs("span",{className:"param-new",children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,value:m,"aria-label":"新项的名字",onChange:w=>g(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),S()):w.key==="Escape"&&g(null)}}),s.jsx("button",{type:"button",className:"primary small-button",disabled:v||m.trim()==="",onClick:()=>void S(),children:v?"新建中…":"新建"}),s.jsx("button",{type:"button",className:"small-button",disabled:v,onClick:()=>{g(null),p(null)},children:"取消"}),s.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),d!==null&&s.jsx("span",{className:"error small",children:d})]})}function gN(e,t,n=!0){const r=je(e.connection.status),[i,o]=b.useState(null);return b.useEffect(()=>{if(o(null),t===void 0||!n||r.state!=="open")return;let c=!0;e.connection.call("configs/profiles",{scriptId:t}).then(f=>{c&&o(f)},()=>{});const u=e.connection.on("configs/profiles/changed",f=>{f.scriptId===t&&o(f.list)});return()=>{c=!1,u()}},[e,t,n,r.state]),i}function xN({list:e,value:t,onChange:n,id:r,label:i="配置"}){if(e===null||e.items.length<2)return null;const o=e.items.find(u=>u.id===e.current),c=t!==void 0&&!e.items.some(u=>u.id===t);return s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:r,children:i}),s.jsx(yn,{id:r,value:t??"",onChange:u=>n(u===""?void 0:u),options:[{value:"",label:"跟随当前使用的",hint:`现在是「${(o==null?void 0:o.name)??"默认"}」`},...e.items.map(u=>({value:u.id,label:u.name})),...c?[{value:t,label:"已删除的配置",disabled:!0}]:[]]}),c&&s.jsx("span",{className:"muted small",children:"这份配置已经删了,运行时会失败;请重新选一份。"})]})}const Wm={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},Nz={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function jz({client:e,scriptId:t,packId:n}){const r=je(e.connection.status),i=Cn(3e4),[o,c]=b.useState(null),[u,f]=b.useState([]),[d,p]=b.useState(""),[m,g]=b.useState({}),[v,y]=b.useState(!1),[S,k]=b.useState(null),[w,A]=b.useState(null),[N,R]=b.useState(0),D=gN(e,t,n!==void 0),[P,F]=b.useState(void 0);b.useEffect(()=>{if(r.state!=="open")return;let Z=!0;return e.connection.call("runs/tasks",{scriptId:t,...P===void 0?{}:{profile:P}}).then(E=>{Z&&(c(E),p(C=>{var $;return C===""?(($=E.tasks[0])==null?void 0:$.id)??"":C}))}).catch(E=>{Z&&k(ze(E))}),e.connection.call("runs/list",{scriptId:t}).then(E=>{Z&&f(E.items)}).catch(()=>{}),()=>{Z=!1}},[e,t,n,r.state,N,P,D==null?void 0:D.current]),b.useEffect(()=>e.connection.on("runs/state",Z=>{Z.scriptId===t&&f(E=>[Z,...E.filter(C=>C.id!==Z.id)].sort((C,$)=>$.startedAt-C.startedAt))}),[e,t]);const W=o==null?void 0:o.tasks.find(Z=>Z.id===d);b.useEffect(()=>{W!==void 0&&g(Object.fromEntries(Object.entries(W.params).map(([Z,E])=>{var C;return[Z,E.default!==void 0?String(E.default):((C=E.choices)==null?void 0:C.length)===1?E.choices[0].value:""]})))},[W==null?void 0:W.id]);const M=u.find(Z=>Z.endedAt===void 0),O=u.find(Z=>{var E;return Z.id===(w??(M==null?void 0:M.id)??((E=u[0])==null?void 0:E.id))}),T=async()=>{if(W!==void 0){y(!0),k(null);try{const Z={};for(const[C,$]of Object.entries(W.params)){const L=m[C]??"";L!==""&&(Z[C]=$.type==="boolean"?L==="true":$.type==="integer"||$.type==="number"?Number(L):L)}const E=await e.connection.call("runs/start",{scriptId:t,taskId:W.id,params:Z,...P===void 0?{}:{profile:P}});A(E.id),E.state==="failed"&&k(E.outcome??"运行失败")}catch(Z){k(ze(Z))}finally{y(!1)}}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"任务"}),s.jsx("p",{className:"muted small",children:"按脚本包运行,使用本地配置;原项目的配置在运行结束后会还原。"})]})}),o===null&&S===null&&s.jsx("div",{className:"muted small",children:"加载中…"}),o!==null&&!o.runnable&&s.jsx("div",{className:"notice info left small",children:o.problem}),o!==null&&o.tasks.length>0&&s.jsxs("div",{className:"run-form",children:[s.jsx("label",{className:"field-label",htmlFor:"task-select",children:"任务"}),s.jsx(yn,{id:"task-select",value:d,onChange:p,options:o.tasks.map(Z=>({value:Z.id,label:Z.title,hint:Z.id}))}),W!==void 0&&s.jsxs("div",{className:"task-facts muted small",children:[s.jsx("span",{className:"badge",children:Nz[W.input]}),W.account!==void 0&&s.jsxs("span",{className:"badge",children:["账号 ",W.account]}),W.expectedDuration!==void 0&&s.jsxs("span",{children:["约 ",W.expectedDuration]}),W.description!==void 0&&s.jsx("span",{children:W.description})]}),s.jsx(xN,{id:"run-profile",list:D,value:P,onChange:F}),W!==void 0&&Object.entries(W.params).map(([Z,E])=>s.jsx(mN,{client:e,scriptId:t,taskId:W.id,name:Z,spec:E,profile:P,value:m[Z]??"",onChange:C=>g($=>({...$,[Z]:C})),onCreated:()=>R(C=>C+1)},Z)),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),M!==void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:M.id}).catch(Z=>k(ze(Z))),children:"停止当前运行"}),s.jsxs("button",{className:"primary small-button",disabled:v||!o.runnable||M!==void 0,onClick:()=>void T(),children:[s.jsx(ee,{name:"arrow"}),v?"启动中…":"运行"]})]})]}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]}),u.length>0&&s.jsxs(Na,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(Z=>{const[E,C]=Wm[Z.state];return s.jsxs("button",{className:`run-row ${Z.id===(O==null?void 0:O.id)?"active":""}`,"aria-expanded":Z.id===(O==null?void 0:O.id),onClick:()=>A($=>$===Z.id||$===null&&Z.id===(O==null?void 0:O.id)?"":Z.id),children:[s.jsx("span",{className:`badge ${E}`,children:C}),s.jsxs("span",{className:"run-title",children:[Z.taskTitle,Z.profileName!==void 0&&((D==null?void 0:D.items.length)??0)>1&&s.jsxs("span",{className:"muted small",children:[" · ",Z.profileName]})]}),s.jsx("span",{className:"muted small run-outcome",children:Z.outcome??Z.resources.join(" · ")}),s.jsx("span",{className:"session-time",children:Tt(Z.startedAt,i)})]},Z.id)}),O!==void 0&&s.jsx(vN,{client:e,run:O},O.id)]})]})}function vN({client:e,run:t}){const[n,r]=b.useState([]),i=b.useRef(null);b.useEffect(()=>{let d=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(m=>{d&&r(m.lines)}).catch(()=>{});const p=e.connection.on("runs/log",m=>{m.runId===t.id&&r(g=>[...g,...m.lines].slice(-1e3))});return()=>{d=!1,p()}},[e,t.id]),b.useEffect(()=>{const d=i.current;d!==null&&(d.scrollTop=d.scrollHeight)},[n.length]);const o=b.useMemo(()=>t.warnings,[t.warnings]),[c,u]=b.useState(null),f=async()=>{let d=n;try{d=(await e.connection.call("runs/logs",{runId:t.id,limit:2e3})).lines}catch{}const p=[`${t.scriptName} · ${t.taskTitle}(${t.id})${t.outcome===void 0?"":` — ${t.outcome}`}`,...d.map(g=>`${new Date(g.at).toLocaleTimeString("zh-CN",{hour12:!1})} [${g.source==="adg"?"平台":g.source}]${g.level===void 0?"":` [${g.level}]`} ${g.text}`)].join(`
198
- `),m=await Sz(p);u(m?`已复制 ${d.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return s.jsxs("div",{className:"run-log-wrap",children:[o.map(d=>s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:d})]},d)),s.jsxs("div",{className:"run-log-bar",children:[s.jsxs("span",{className:"muted small",children:[n.length," 行",n.length>=1e3?"(只显示最近的)":""]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{type:"button",className:"small-button",disabled:n.length===0,onClick:()=>void f(),title:"复制整次运行的日志(最多 2000 行),方便发给别人或 agent",children:[s.jsx(ee,{name:"copy"}),c??"复制日志"]})]}),s.jsxs("div",{className:"run-log",ref:i,role:"log","aria-label":"运行日志",children:[n.length===0&&s.jsx("div",{className:"muted small",children:"还没有日志"}),n.map((d,p)=>s.jsxs("div",{className:`log-line ${d.level===void 0?"":`lv-${d.level}`} ${d.source==="adg"?"adg":""}`,children:[s.jsx("span",{className:"log-time",children:new Date(d.at).toLocaleTimeString()}),s.jsx("span",{className:"log-source",children:d.source==="adg"?"平台":d.source}),s.jsx("span",{className:"log-text",children:d.text})]},p))]})]})}async function Sz(e){try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}catch{return!1}finally{t.remove()}}}const yN=b.createContext({byIncident:new Map,openSession:()=>{}}),_z={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},Ez={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function Cz({client:e,openSettings:t,openSession:n}){const r=je(e.connection.status),i=Cn(3e4),[o,c]=b.useState([]),[u,f]=b.useState([]),[d,p]=b.useState(null),[m,g]=b.useState(!1),[v,y]=b.useState(null),[S,k]=b.useState([]),w=je(e.capabilities);b.useEffect(()=>{if(r.state!=="open"||!w.has("intervene"))return;let M=!0;return e.connection.call("intervene/list",{limit:100}).then(O=>{M&&k(O.items)}).catch(()=>{}),()=>{M=!1}},[e,r.state,w]),b.useEffect(()=>e.connection.on("intervene/changed",M=>{k(O=>[M,...O.filter(T=>T.id!==M.id)])}),[e]);const A=b.useMemo(()=>{const M=new Map;for(const O of[...S].sort((T,Z)=>T.startedAt-Z.startedAt))O.incidentId!==void 0&&M.set(O.incidentId,O);return{byIncident:M,openSession:n}},[S,n]);b.useEffect(()=>{if(r.state!=="open")return;let M=!0;return e.connection.call("runs/list",{}).then(O=>{M&&c(O.items)}).catch(O=>{M&&y(ze(O))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(O=>{M&&f(O.items)}).catch(()=>{}),()=>{M=!1}},[e,r.state]),b.useEffect(()=>e.connection.on("runs/state",M=>{c(O=>[M,...O.filter(T=>T.id!==M.id)].sort((T,Z)=>Z.startedAt-T.startedAt))}),[e]),b.useEffect(()=>e.connection.on("monitor/incident",M=>{f(O=>[M,...O.filter(T=>T.id!==M.id)].sort((T,Z)=>Z.createdAt-T.createdAt))}),[e]);const N=o.filter(M=>M.endedAt===void 0),R=o.filter(M=>M.endedAt!==void 0).slice(0,30),D=u.filter(M=>M.status==="open"),P=o.find(M=>{var O,T;return M.id===(d??((O=N[0])==null?void 0:O.id)??((T=o[0])==null?void 0:T.id))}),F=b.useMemo(()=>{const M=new Map;for(const O of D)M.set(O.runId,(M.get(O.runId)??0)+1);return M},[D]),W=M=>{const[O,T]=Wm[M.state],Z=F.get(M.id)??0;return s.jsxs("button",{className:`script-row ${M.id===(P==null?void 0:P.id)?"active":""}`,onClick:()=>p(M.id),children:[s.jsxs("span",{className:"script-row-main",children:[s.jsxs("span",{className:"script-row-name",children:[M.scriptName," · ",M.taskTitle]}),s.jsxs("span",{className:"muted small",children:[M.kind==="settings"?"设置会话 · ":"",Tt(M.startedAt,i),M.retryOf===void 0?"":" · 重新运行"]})]}),Z>0?s.jsxs("span",{className:"badge warn",children:["异常 ",Z]}):s.jsx("span",{className:`badge ${O}`,children:T})]},M.id)};return s.jsx(yN.Provider,{value:A,children:s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"运行"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"运行监控"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("feishu"),children:[s.jsx(ee,{name:"plug"}),"消息通知"]}),s.jsxs("button",{className:`small-button ${m?"primary":""}`,onClick:()=>g(M=>!M),children:[s.jsx(ee,{name:"settings"}),"监控设置"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"运行列表",children:[v!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:v})]}),s.jsxs(Na,{id:"monitor.active",title:"正在运行",count:N.length,className:"list-fold",children:[N.length===0&&s.jsx("div",{className:"muted small pad",children:"没有正在运行的任务"}),N.map(W)]}),R.length>0&&s.jsx(Na,{id:"monitor.recent",title:"最近",count:R.length,className:"list-fold",children:R.map(W)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[m&&s.jsx(Az,{client:e}),D.length>0&&s.jsx("section",{className:"card",children:s.jsxs(Na,{id:"monitor.open-incidents",title:s.jsxs("h3",{children:["待处理的异常(",D.length,")"]}),className:"card-fold",children:[s.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),s.jsx("div",{className:"incident-list",children:D.map(M=>s.jsx(bN,{client:e,incident:M,now:i,onOpen:()=>p(M.runId)},M.id))})]})}),P===void 0&&D.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"monitor"}),s.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),P!==void 0&&s.jsx(Iz,{client:e,run:P,incidents:u.filter(M=>M.runId===P.id),now:i,openRun:p})]})})]})]})})}function Iz({client:e,run:t,incidents:n,now:r,openRun:i}){const[o,c]=Wm[t.state],[u,f]=b.useState(null);return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[t.scriptName," · ",t.taskTitle]}),s.jsxs("p",{className:"muted small",children:[new Date(t.startedAt).toLocaleString("zh-CN",{hour12:!1}),t.endedAt===void 0?"":` → ${new Date(t.endedAt).toLocaleTimeString("zh-CN",{hour12:!1})}`,t.resources.length>0?` · ${t.resources.join(" · ")}`:""]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:`badge ${o}`,children:c}),t.endedAt===void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:t.id}).catch(d=>f(ze(d))),children:"停止"})]})]}),t.outcome!==void 0&&s.jsxs("div",{className:"muted small",children:["结果:",t.outcome]}),t.retryOf!==void 0&&s.jsxs("button",{className:"link-button small",onClick:()=>i(t.retryOf),children:["这是 ",t.retryOf," 的重新运行"]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx(Na,{id:"monitor.run-log",title:"日志",children:s.jsx(vN,{client:e,run:t},t.id)}),n.length>0&&s.jsx(Na,{id:"monitor.run-incidents",title:"这次运行的异常",count:n.length,children:s.jsx("div",{className:"incident-list",children:n.map(d=>s.jsx(bN,{client:e,incident:d,now:r},d.id))})})]})}function bN({client:e,incident:t,now:n,onOpen:r}){const{byIncident:i,openSession:o}=b.useContext(yN),c=i.get(t.id),[u,f]=b.useState(!1),[d,p]=b.useState(null),[m,g]=b.useState(null),v=async()=>{if(c!==void 0){f(!0),p(null);try{await e.connection.call("intervene/takeover",{id:c.id})}catch(k){p(ze(k))}finally{f(!1)}}},y=async k=>{f(!0),p(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:k})}catch(w){p(ze(w))}finally{f(!1)}},S=async()=>{if(m!==null)return g(null);try{const k=await e.connection.call("monitor/screenshot",{incidentId:t.id});g(`data:${k.mime};base64,${k.data}`)}catch(k){p(ze(k))}};return s.jsxs("div",{className:`incident ${t.severity} ${t.status}`,children:[s.jsxs("div",{className:"incident-head",children:[s.jsx("span",{className:`badge ${t.severity==="error"?"warn":""}`,children:Ez[t.kind]}),r===void 0?s.jsx("span",{className:"incident-title",children:t.title}):s.jsx("button",{className:"link-button incident-title",onClick:r,children:t.title}),s.jsx("span",{className:"session-time",children:Tt(t.createdAt,n)})]}),s.jsx("div",{className:"incident-detail",children:t.detail}),t.steps.length>0&&s.jsx("ul",{className:"incident-steps",children:t.steps.filter(k=>(c==null?void 0:c.summary)===void 0||c.state==="running"||!k.detail.endsWith(c.summary)).map((k,w)=>s.jsxs("li",{className:k.ok?"ok":"failed",children:[k.ok?"✓":"✗"," ",k.detail]},w))}),t.status==="resolved"&&s.jsxs("div",{className:"muted small",children:["已处理:",t.resolution]}),c!==void 0&&s.jsxs("div",{className:`agent-line ${c.state}`,children:[s.jsxs("span",{className:"badge",children:[_z[c.state],c.mode==="diagnose"?"(只诊断)":""]}),c.summary!==void 0&&s.jsx("span",{className:"small",children:c.summary}),c.paused&&s.jsx("span",{className:"badge warn",children:"脚本暂停中"}),s.jsx("span",{className:"spacer"}),c.sessionId!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(c.sessionId),children:"看 agent 的处理过程"}),c.state==="running"&&s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void v(),children:"我来接管"})]}),t.status==="open"&&s.jsxs("div",{className:"key-actions",children:[t.screenshot&&s.jsxs("button",{className:"small-button",onClick:()=>void S(),children:[s.jsx(ee,{name:"image"}),m===null?"截图":"收起截图"]}),s.jsx("span",{className:"spacer"}),(c==null?void 0:c.paused)===!0&&s.jsx("button",{className:"primary small-button",disabled:u,onClick:()=>void y("resume"),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void y("stop"),children:"停止"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("retry"),children:"重试"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("resolve"),children:"忽略"})]}),m!==null&&s.jsx("img",{className:"incident-shot",src:m,alt:"异常时的截图"}),d!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]})]})}function Az({client:e}){var f;const[t,n]=b.useState(null),[r,i]=b.useState(null);b.useEffect(()=>{e.connection.call("monitor/settings",{}).then(n).catch(d=>i(ze(d)))},[e]);const o=d=>e.connection.call("monitor/settings/set",d).then(n).catch(p=>i(ze(p))),c=((f=Am(e).data)==null?void 0:f.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([d],[p])=>d.localeCompare(p));return s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"监控设置"}),t!==null&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"stall-seconds",children:"多少秒没有新日志算卡住、交给干预(默认值;0 = 不检测)"}),s.jsx("input",{id:"stall-seconds",className:"text-input plain",type:"number",min:0,max:86400,defaultValue:t.defaultStallSeconds,onBlur:d=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(d.target.value)||0)))})}),s.jsx("p",{className:"muted small",children:"每个脚本会从自己跑成功的记录里学:卡住时间取最近几次里最长安静时间的 1.5 倍(不低于上面的默认值);agent 看过日志节奏后也会替它调。"}),u.length>0&&s.jsx("ul",{className:"stall-list",children:u.map(([d,p])=>{var m;return s.jsxs("li",{children:[s.jsx("span",{children:((m=c.find(g=>g.id===d))==null?void 0:m.name)??d}),s.jsxs("span",{className:"muted small",children:[p.seconds," 秒 · ",p.by==="learned"?"学到的":p.by==="agent"?"agent 设的":"你设的",p.note===void 0?"":`:${p.note}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button small",onClick:()=>{const{[d]:g,...v}=t.scriptStall;o({scriptStall:v})},children:"恢复自动"})]},d)})}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:d=>void o({screenshot:d.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:d=>void o({notifyWarnings:d.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),s.jsx(yn,{id:"intervene-mode",value:t.intervene,onChange:d=>void o({intervene:d}),options:[{value:"act",label:"诊断并处理(推荐)",hint:"暂停脚本,agent 看屏幕、点击和输入来解决"},{value:"diagnose",label:"只诊断",hint:"agent 看截图说明原因,由你决定"},{value:"off",label:"关闭",hint:"直接通知我"}]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-cap",children:"每天最多交给 agent 几次(控制模型费用)"}),s.jsx("input",{id:"intervene-cap",className:"text-input plain",type:"number",min:0,max:200,defaultValue:t.interventionsPerDay,onBlur:d=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(d.target.value)||0)))})})]}),r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:r})]})]})}const Tz={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:Cz}]},$z={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:yz}]};function kn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=kn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Mz={value:()=>{}};function wd(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new zu(n)}function zu(e){this._=e}function Rz(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}zu.prototype=wd.prototype={constructor:zu,on:function(e,t){var n=this._,r=Rz(e+"",n),i,o=-1,c=r.length;if(arguments.length<2){for(;++o<c;)if((i=(e=r[o]).type)&&(i=Oz(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<c;)if(i=(e=r[o]).type)n[i]=my(n[i],e.name,t);else if(t==null)for(i in n)n[i]=my(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new zu(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function Oz(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function my(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Mz,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Yp="http://www.w3.org/1999/xhtml";const gy={svg:"http://www.w3.org/2000/svg",xhtml:Yp,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Nd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),gy.hasOwnProperty(t)?{space:gy[t],local:e}:e}function zz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Yp&&t.documentElement.namespaceURI===Yp?t.createElement(e):t.createElementNS(n,e)}}function Pz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function kN(e){var t=Nd(e);return(t.local?Pz:zz)(t)}function Lz(){}function Vm(e){return e==null?Lz:function(){return this.querySelector(e)}}function Dz(e){typeof e!="function"&&(e=Vm(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=new Array(c),f,d,p=0;p<c;++p)(f=o[p])&&(d=e.call(f,f.__data__,p,o))&&("__data__"in f&&(d.__data__=f.__data__),u[p]=d);return new $s(r,this._parents)}function Fz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Bz(){return[]}function wN(e){return e==null?Bz:function(){return this.querySelectorAll(e)}}function Uz(e){return function(){return Fz(e.apply(this,arguments))}}function Hz(e){typeof e=="function"?e=Uz(e):e=wN(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var c=t[o],u=c.length,f,d=0;d<u;++d)(f=c[d])&&(r.push(e.call(f,f.__data__,d,c)),i.push(f));return new $s(r,i)}function NN(e){return function(){return this.matches(e)}}function jN(e){return function(t){return t.matches(e)}}var Zz=Array.prototype.find;function Wz(e){return function(){return Zz.call(this.children,e)}}function Vz(){return this.firstElementChild}function qz(e){return this.select(e==null?Vz:Wz(typeof e=="function"?e:jN(e)))}var Gz=Array.prototype.filter;function Kz(){return Array.from(this.children)}function Yz(e){return function(){return Gz.call(this.children,e)}}function Xz(e){return this.selectAll(e==null?Kz:Yz(typeof e=="function"?e:jN(e)))}function Qz(e){typeof e!="function"&&(e=NN(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=[],f,d=0;d<c;++d)(f=o[d])&&e.call(f,f.__data__,d,o)&&u.push(f);return new $s(r,this._parents)}function SN(e){return new Array(e.length)}function Jz(){return new $s(this._enter||this._groups.map(SN),this._parents)}function Qu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Qu.prototype={constructor:Qu,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 eP(e){return function(){return e}}function tP(e,t,n,r,i,o){for(var c=0,u,f=t.length,d=o.length;c<d;++c)(u=t[c])?(u.__data__=o[c],r[c]=u):n[c]=new Qu(e,o[c]);for(;c<f;++c)(u=t[c])&&(i[c]=u)}function nP(e,t,n,r,i,o,c){var u,f,d=new Map,p=t.length,m=o.length,g=new Array(p),v;for(u=0;u<p;++u)(f=t[u])&&(g[u]=v=c.call(f,f.__data__,u,t)+"",d.has(v)?i[u]=f:d.set(v,f));for(u=0;u<m;++u)v=c.call(e,o[u],u,o)+"",(f=d.get(v))?(r[u]=f,f.__data__=o[u],d.delete(v)):n[u]=new Qu(e,o[u]);for(u=0;u<p;++u)(f=t[u])&&d.get(g[u])===f&&(i[u]=f)}function sP(e){return e.__data__}function rP(e,t){if(!arguments.length)return Array.from(this,sP);var n=t?nP:tP,r=this._parents,i=this._groups;typeof e!="function"&&(e=eP(e));for(var o=i.length,c=new Array(o),u=new Array(o),f=new Array(o),d=0;d<o;++d){var p=r[d],m=i[d],g=m.length,v=iP(e.call(p,p&&p.__data__,d,r)),y=v.length,S=u[d]=new Array(y),k=c[d]=new Array(y),w=f[d]=new Array(g);n(p,m,S,k,w,v,t);for(var A=0,N=0,R,D;A<y;++A)if(R=S[A]){for(A>=N&&(N=A+1);!(D=k[N])&&++N<y;);R._next=D||null}}return c=new $s(c,r),c._enter=u,c._exit=f,c}function iP(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function aP(){return new $s(this._exit||this._groups.map(SN),this._parents)}function oP(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function lP(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,c=Math.min(i,o),u=new Array(i),f=0;f<c;++f)for(var d=n[f],p=r[f],m=d.length,g=u[f]=new Array(m),v,y=0;y<m;++y)(v=d[y]||p[y])&&(g[y]=v);for(;f<i;++f)u[f]=n[f];return new $s(u,this._parents)}function cP(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],c;--i>=0;)(c=r[i])&&(o&&c.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(c,o),o=c);return this}function uP(e){e||(e=dP);function t(m,g){return m&&g?e(m.__data__,g.__data__):!m-!g}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var c=n[o],u=c.length,f=i[o]=new Array(u),d,p=0;p<u;++p)(d=c[p])&&(f[p]=d);f.sort(t)}return new $s(i,this._parents).order()}function dP(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function fP(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function hP(){return Array.from(this)}function pP(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var c=r[i];if(c)return c}return null}function mP(){let e=0;for(const t of this)++e;return e}function gP(){return!this.node()}function xP(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,c=i.length,u;o<c;++o)(u=i[o])&&e.call(u,u.__data__,o,i);return this}function vP(e){return function(){this.removeAttribute(e)}}function yP(e){return function(){this.removeAttributeNS(e.space,e.local)}}function bP(e,t){return function(){this.setAttribute(e,t)}}function kP(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function wP(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function NP(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 jP(e,t){var n=Nd(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?yP:vP:typeof t=="function"?n.local?NP:wP:n.local?kP:bP)(n,t))}function _N(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function SP(e){return function(){this.style.removeProperty(e)}}function _P(e,t,n){return function(){this.style.setProperty(e,t,n)}}function EP(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function CP(e,t,n){return arguments.length>1?this.each((t==null?SP:typeof t=="function"?EP:_P)(e,t,n??"")):$o(this.node(),e)}function $o(e,t){return e.style.getPropertyValue(t)||_N(e).getComputedStyle(e,null).getPropertyValue(t)}function IP(e){return function(){delete this[e]}}function AP(e,t){return function(){this[e]=t}}function TP(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function $P(e,t){return arguments.length>1?this.each((t==null?IP:typeof t=="function"?TP:AP)(e,t)):this.node()[e]}function EN(e){return e.trim().split(/^|\s+/)}function qm(e){return e.classList||new CN(e)}function CN(e){this._node=e,this._names=EN(e.getAttribute("class")||"")}CN.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 IN(e,t){for(var n=qm(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function AN(e,t){for(var n=qm(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function MP(e){return function(){IN(this,e)}}function RP(e){return function(){AN(this,e)}}function OP(e,t){return function(){(t.apply(this,arguments)?IN:AN)(this,e)}}function zP(e,t){var n=EN(e+"");if(arguments.length<2){for(var r=qm(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?OP:t?MP:RP)(n,t))}function PP(){this.textContent=""}function LP(e){return function(){this.textContent=e}}function DP(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function FP(e){return arguments.length?this.each(e==null?PP:(typeof e=="function"?DP:LP)(e)):this.node().textContent}function BP(){this.innerHTML=""}function UP(e){return function(){this.innerHTML=e}}function HP(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ZP(e){return arguments.length?this.each(e==null?BP:(typeof e=="function"?HP:UP)(e)):this.node().innerHTML}function WP(){this.nextSibling&&this.parentNode.appendChild(this)}function VP(){return this.each(WP)}function qP(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function GP(){return this.each(qP)}function KP(e){var t=typeof e=="function"?e:kN(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function YP(){return null}function XP(e,t){var n=typeof e=="function"?e:kN(e),r=t==null?YP:typeof t=="function"?t:Vm(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function QP(){var e=this.parentNode;e&&e.removeChild(this)}function JP(){return this.each(QP)}function eL(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tL(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nL(e){return this.select(e?tL:eL)}function sL(e){return arguments.length?this.property("__data__",e):this.node().__data__}function rL(e){return function(t){e.call(this,t,this.__data__)}}function iL(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function aL(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function oL(e,t,n){return function(){var r=this.__on,i,o=rL(t);if(r){for(var c=0,u=r.length;c<u;++c)if((i=r[c]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function lL(e,t,n){var r=iL(e+""),i,o=r.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var f=0,d=u.length,p;f<d;++f)for(i=0,p=u[f];i<o;++i)if((c=r[i]).type===p.type&&c.name===p.name)return p.value}return}for(u=t?oL:aL,i=0;i<o;++i)this.each(u(r[i],t,n));return this}function TN(e,t,n){var r=_N(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function cL(e,t){return function(){return TN(this,e,t)}}function uL(e,t){return function(){return TN(this,e,t.apply(this,arguments))}}function dL(e,t){return this.each((typeof t=="function"?uL:cL)(e,t))}function*fL(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,c;i<o;++i)(c=r[i])&&(yield c)}var $N=[null];function $s(e,t){this._groups=e,this._parents=t}function cc(){return new $s([[document.documentElement]],$N)}function hL(){return this}$s.prototype=cc.prototype={constructor:$s,select:Dz,selectAll:Hz,selectChild:qz,selectChildren:Xz,filter:Qz,data:rP,enter:Jz,exit:aP,join:oP,merge:lP,selection:hL,order:cP,sort:uP,call:fP,nodes:hP,node:pP,size:mP,empty:gP,each:xP,attr:jP,style:CP,property:$P,classed:zP,text:FP,html:ZP,raise:VP,lower:GP,append:KP,insert:XP,remove:JP,clone:nL,datum:sL,on:lL,dispatch:dL,[Symbol.iterator]:fL};function As(e){return typeof e=="string"?new $s([[document.querySelector(e)]],[document.documentElement]):new $s([[e]],$N)}function pL(e){let t;for(;t=e.sourceEvent;)e=t;return e}function dr(e,t){if(e=pL(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const mL={passive:!1},Wl={capture:!0,passive:!1};function Gh(e){e.stopImmediatePropagation()}function bo(e){e.preventDefault(),e.stopImmediatePropagation()}function MN(e){var t=e.document.documentElement,n=As(e).on("dragstart.drag",bo,Wl);"onselectstart"in t?n.on("selectstart.drag",bo,Wl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function RN(e,t){var n=e.document.documentElement,r=As(e).on("dragstart.drag",null);t&&(r.on("click.drag",bo,Wl),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const wu=e=>()=>e;function Xp(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:c,y:u,dx:f,dy:d,dispatch:p}){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:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:p}})}Xp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gL(e){return!e.ctrlKey&&!e.button}function xL(){return this.parentNode}function vL(e,t){return t??{x:e.x,y:e.y}}function yL(){return navigator.maxTouchPoints||"ontouchstart"in this}function ON(){var e=gL,t=xL,n=vL,r=yL,i={},o=wd("start","drag","end"),c=0,u,f,d,p,m=0;function g(R){R.on("mousedown.drag",v).filter(r).on("touchstart.drag",k).on("touchmove.drag",w,mL).on("touchend.drag touchcancel.drag",A).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(R,D){if(!(p||!e.call(this,R,D))){var P=N(this,t.call(this,R,D),R,D,"mouse");P&&(As(R.view).on("mousemove.drag",y,Wl).on("mouseup.drag",S,Wl),MN(R.view),Gh(R),d=!1,u=R.clientX,f=R.clientY,P("start",R))}}function y(R){if(bo(R),!d){var D=R.clientX-u,P=R.clientY-f;d=D*D+P*P>m}i.mouse("drag",R)}function S(R){As(R.view).on("mousemove.drag mouseup.drag",null),RN(R.view,d),bo(R),i.mouse("end",R)}function k(R,D){if(e.call(this,R,D)){var P=R.changedTouches,F=t.call(this,R,D),W=P.length,M,O;for(M=0;M<W;++M)(O=N(this,F,R,D,P[M].identifier,P[M]))&&(Gh(R),O("start",R,P[M]))}}function w(R){var D=R.changedTouches,P=D.length,F,W;for(F=0;F<P;++F)(W=i[D[F].identifier])&&(bo(R),W("drag",R,D[F]))}function A(R){var D=R.changedTouches,P=D.length,F,W;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),F=0;F<P;++F)(W=i[D[F].identifier])&&(Gh(R),W("end",R,D[F]))}function N(R,D,P,F,W,M){var O=o.copy(),T=dr(M||P,D),Z,E,C;if((C=n.call(R,new Xp("beforestart",{sourceEvent:P,target:g,identifier:W,active:c,x:T[0],y:T[1],dx:0,dy:0,dispatch:O}),F))!=null)return Z=C.x-T[0]||0,E=C.y-T[1]||0,function $(L,B,H){var G=T,K;switch(L){case"start":i[W]=$,K=c++;break;case"end":delete i[W],--c;case"drag":T=dr(H||B,D),K=c;break}O.call(L,R,new Xp(L,{sourceEvent:B,subject:C,target:g,identifier:W,active:K,x:T[0]+Z,y:T[1]+E,dx:T[0]-G[0],dy:T[1]-G[1],dispatch:O}),F)}}return g.filter=function(R){return arguments.length?(e=typeof R=="function"?R:wu(!!R),g):e},g.container=function(R){return arguments.length?(t=typeof R=="function"?R:wu(R),g):t},g.subject=function(R){return arguments.length?(n=typeof R=="function"?R:wu(R),g):n},g.touchable=function(R){return arguments.length?(r=typeof R=="function"?R:wu(!!R),g):r},g.on=function(){var R=o.on.apply(o,arguments);return R===o?g:R},g.clickDistance=function(R){return arguments.length?(m=(R=+R)*R,g):Math.sqrt(m)},g}function Gm(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function zN(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function uc(){}var Vl=.7,Ju=1/Vl,ko="\\s*([+-]?\\d+)\\s*",ql="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Dr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bL=/^#([0-9a-f]{3,8})$/,kL=new RegExp(`^rgb\\(${ko},${ko},${ko}\\)$`),wL=new RegExp(`^rgb\\(${Dr},${Dr},${Dr}\\)$`),NL=new RegExp(`^rgba\\(${ko},${ko},${ko},${ql}\\)$`),jL=new RegExp(`^rgba\\(${Dr},${Dr},${Dr},${ql}\\)$`),SL=new RegExp(`^hsl\\(${ql},${Dr},${Dr}\\)$`),_L=new RegExp(`^hsla\\(${ql},${Dr},${Dr},${ql}\\)$`),xy={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};Gm(uc,Ia,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:vy,formatHex:vy,formatHex8:EL,formatHsl:CL,formatRgb:yy,toString:yy});function vy(){return this.rgb().formatHex()}function EL(){return this.rgb().formatHex8()}function CL(){return PN(this).formatHsl()}function yy(){return this.rgb().formatRgb()}function Ia(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=bL.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?by(t):n===3?new bs(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nu(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=kL.exec(e))?new bs(t[1],t[2],t[3],1):(t=wL.exec(e))?new bs(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=NL.exec(e))?Nu(t[1],t[2],t[3],t[4]):(t=jL.exec(e))?Nu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=SL.exec(e))?Ny(t[1],t[2]/100,t[3]/100,1):(t=_L.exec(e))?Ny(t[1],t[2]/100,t[3]/100,t[4]):xy.hasOwnProperty(e)?by(xy[e]):e==="transparent"?new bs(NaN,NaN,NaN,0):null}function by(e){return new bs(e>>16&255,e>>8&255,e&255,1)}function Nu(e,t,n,r){return r<=0&&(e=t=n=NaN),new bs(e,t,n,r)}function IL(e){return e instanceof uc||(e=Ia(e)),e?(e=e.rgb(),new bs(e.r,e.g,e.b,e.opacity)):new bs}function Qp(e,t,n,r){return arguments.length===1?IL(e):new bs(e,t,n,r??1)}function bs(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Gm(bs,Qp,zN(uc,{brighter(e){return e=e==null?Ju:Math.pow(Ju,e),new bs(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Vl:Math.pow(Vl,e),new bs(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new bs(ja(this.r),ja(this.g),ja(this.b),ed(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:ky,formatHex:ky,formatHex8:AL,formatRgb:wy,toString:wy}));function ky(){return`#${ya(this.r)}${ya(this.g)}${ya(this.b)}`}function AL(){return`#${ya(this.r)}${ya(this.g)}${ya(this.b)}${ya((isNaN(this.opacity)?1:this.opacity)*255)}`}function wy(){const e=ed(this.opacity);return`${e===1?"rgb(":"rgba("}${ja(this.r)}, ${ja(this.g)}, ${ja(this.b)}${e===1?")":`, ${e})`}`}function ed(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ja(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ya(e){return e=ja(e),(e<16?"0":"")+e.toString(16)}function Ny(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new mr(e,t,n,r)}function PN(e){if(e instanceof mr)return new mr(e.h,e.s,e.l,e.opacity);if(e instanceof uc||(e=Ia(e)),!e)return new mr;if(e instanceof mr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),c=NaN,u=o-i,f=(o+i)/2;return u?(t===o?c=(n-r)/u+(n<r)*6:n===o?c=(r-t)/u+2:c=(t-n)/u+4,u/=f<.5?o+i:2-o-i,c*=60):u=f>0&&f<1?0:c,new mr(c,u,f,e.opacity)}function TL(e,t,n,r){return arguments.length===1?PN(e):new mr(e,t,n,r??1)}function mr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gm(mr,TL,zN(uc,{brighter(e){return e=e==null?Ju:Math.pow(Ju,e),new mr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Vl:Math.pow(Vl,e),new mr(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,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new bs(Kh(e>=240?e-240:e+120,i,r),Kh(e,i,r),Kh(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new mr(jy(this.h),ju(this.s),ju(this.l),ed(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=ed(this.opacity);return`${e===1?"hsl(":"hsla("}${jy(this.h)}, ${ju(this.s)*100}%, ${ju(this.l)*100}%${e===1?")":`, ${e})`}`}}));function jy(e){return e=(e||0)%360,e<0?e+360:e}function ju(e){return Math.max(0,Math.min(1,e||0))}function Kh(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 Km=e=>()=>e;function $L(e,t){return function(n){return e+n*t}}function ML(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function RL(e){return(e=+e)==1?LN:function(t,n){return n-t?ML(t,n,e):Km(isNaN(t)?n:t)}}function LN(e,t){var n=t-e;return n?$L(e,n):Km(isNaN(e)?t:e)}const td=(function e(t){var n=RL(t);function r(i,o){var c=n((i=Qp(i)).r,(o=Qp(o)).r),u=n(i.g,o.g),f=n(i.b,o.b),d=LN(i.opacity,o.opacity);return function(p){return i.r=c(p),i.g=u(p),i.b=f(p),i.opacity=d(p),i+""}}return r.gamma=e,r})(1);function OL(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=e[i]*(1-o)+t[i]*o;return r}}function zL(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function PL(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),o=new Array(n),c;for(c=0;c<r;++c)i[c]=Ll(e[c],t[c]);for(;c<n;++c)o[c]=t[c];return function(u){for(c=0;c<r;++c)o[c]=i[c](u);return o}}function LL(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Lr(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function DL(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=Ll(e[i],t[i]):r[i]=t[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var Jp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yh=new RegExp(Jp.source,"g");function FL(e){return function(){return e}}function BL(e){return function(t){return e(t)+""}}function DN(e,t){var n=Jp.lastIndex=Yh.lastIndex=0,r,i,o,c=-1,u=[],f=[];for(e=e+"",t=t+"";(r=Jp.exec(e))&&(i=Yh.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(r=r[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,f.push({i:c,x:Lr(r,i)})),n=Yh.lastIndex;return n<t.length&&(o=t.slice(n),u[c]?u[c]+=o:u[++c]=o),u.length<2?f[0]?BL(f[0].x):FL(t):(t=f.length,function(d){for(var p=0,m;p<t;++p)u[(m=f[p]).i]=m.x(d);return u.join("")})}function Ll(e,t){var n=typeof t,r;return t==null||n==="boolean"?Km(t):(n==="number"?Lr:n==="string"?(r=Ia(t))?(t=r,td):DN:t instanceof Ia?td:t instanceof Date?LL:zL(t)?OL:Array.isArray(t)?PL:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?DL:Lr)(e,t)}var Sy=180/Math.PI,em={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function FN(e,t,n,r,i,o){var c,u,f;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(f=e*n+t*r)&&(n-=e*f,r-=t*f),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,f/=u),e*r<t*n&&(e=-e,t=-t,f=-f,c=-c),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*Sy,skewX:Math.atan(f)*Sy,scaleX:c,scaleY:u}}var Su;function UL(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?em:FN(t.a,t.b,t.c,t.d,t.e,t.f)}function HL(e){return e==null||(Su||(Su=document.createElementNS("http://www.w3.org/2000/svg","g")),Su.setAttribute("transform",e),!(e=Su.transform.baseVal.consolidate()))?em:(e=e.matrix,FN(e.a,e.b,e.c,e.d,e.e,e.f))}function BN(e,t,n,r){function i(d){return d.length?d.pop()+" ":""}function o(d,p,m,g,v,y){if(d!==m||p!==g){var S=v.push("translate(",null,t,null,n);y.push({i:S-4,x:Lr(d,m)},{i:S-2,x:Lr(p,g)})}else(m||g)&&v.push("translate("+m+t+g+n)}function c(d,p,m,g){d!==p?(d-p>180?p+=360:p-d>180&&(d+=360),g.push({i:m.push(i(m)+"rotate(",null,r)-2,x:Lr(d,p)})):p&&m.push(i(m)+"rotate("+p+r)}function u(d,p,m,g){d!==p?g.push({i:m.push(i(m)+"skewX(",null,r)-2,x:Lr(d,p)}):p&&m.push(i(m)+"skewX("+p+r)}function f(d,p,m,g,v,y){if(d!==m||p!==g){var S=v.push(i(v)+"scale(",null,",",null,")");y.push({i:S-4,x:Lr(d,m)},{i:S-2,x:Lr(p,g)})}else(m!==1||g!==1)&&v.push(i(v)+"scale("+m+","+g+")")}return function(d,p){var m=[],g=[];return d=e(d),p=e(p),o(d.translateX,d.translateY,p.translateX,p.translateY,m,g),c(d.rotate,p.rotate,m,g),u(d.skewX,p.skewX,m,g),f(d.scaleX,d.scaleY,p.scaleX,p.scaleY,m,g),d=p=null,function(v){for(var y=-1,S=g.length,k;++y<S;)m[(k=g[y]).i]=k.x(v);return m.join("")}}}var ZL=BN(UL,"px, ","px)","deg)"),WL=BN(HL,", ",")",")"),VL=1e-12;function _y(e){return((e=Math.exp(e))+1/e)/2}function qL(e){return((e=Math.exp(e))-1/e)/2}function GL(e){return((e=Math.exp(2*e))-1)/(e+1)}const Pu=(function e(t,n,r){function i(o,c){var u=o[0],f=o[1],d=o[2],p=c[0],m=c[1],g=c[2],v=p-u,y=m-f,S=v*v+y*y,k,w;if(S<VL)w=Math.log(g/d)/t,k=function(F){return[u+F*v,f+F*y,d*Math.exp(t*F*w)]};else{var A=Math.sqrt(S),N=(g*g-d*d+r*S)/(2*d*n*A),R=(g*g-d*d-r*S)/(2*g*n*A),D=Math.log(Math.sqrt(N*N+1)-N),P=Math.log(Math.sqrt(R*R+1)-R);w=(P-D)/t,k=function(F){var W=F*w,M=_y(D),O=d/(n*A)*(M*GL(t*W+D)-qL(D));return[u+O*v,f+O*y,d*M/_y(t*W+D)]}}return k.duration=w*1e3*t/Math.SQRT2,k}return i.rho=function(o){var c=Math.max(.001,+o),u=c*c,f=u*u;return e(c,u,f)},i})(Math.SQRT2,2,4);var Mo=0,Tl=0,Nl=0,UN=1e3,nd,$l,sd=0,Aa=0,jd=0,Gl=typeof performance=="object"&&performance.now?performance:Date,HN=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ym(){return Aa||(HN(KL),Aa=Gl.now()+jd)}function KL(){Aa=0}function rd(){this._call=this._time=this._next=null}rd.prototype=ZN.prototype={constructor:rd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Ym():+n)+(t==null?0:+t),!this._next&&$l!==this&&($l?$l._next=this:nd=this,$l=this),this._call=e,this._time=n,tm()},stop:function(){this._call&&(this._call=null,this._time=1/0,tm())}};function ZN(e,t,n){var r=new rd;return r.restart(e,t,n),r}function YL(){Ym(),++Mo;for(var e=nd,t;e;)(t=Aa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mo}function Ey(){Aa=(sd=Gl.now())+jd,Mo=Tl=0;try{YL()}finally{Mo=0,QL(),Aa=0}}function XL(){var e=Gl.now(),t=e-sd;t>UN&&(jd-=t,sd=e)}function QL(){for(var e,t=nd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:nd=n);$l=e,tm(r)}function tm(e){if(!Mo){Tl&&(Tl=clearTimeout(Tl));var t=e-Aa;t>24?(e<1/0&&(Tl=setTimeout(Ey,e-Gl.now()-jd)),Nl&&(Nl=clearInterval(Nl))):(Nl||(sd=Gl.now(),Nl=setInterval(XL,UN)),Mo=1,HN(Ey))}}function Cy(e,t,n){var r=new rd;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var JL=wd("start","end","cancel","interrupt"),eD=[],WN=0,Iy=1,nm=2,Lu=3,Ay=4,sm=5,Du=6;function Sd(e,t,n,r,i,o){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;tD(e,n,{name:t,index:r,group:i,on:JL,tween:eD,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:WN})}function Xm(e,t){var n=jr(e,t);if(n.state>WN)throw new Error("too late; already scheduled");return n}function Fr(e,t){var n=jr(e,t);if(n.state>Lu)throw new Error("too late; already running");return n}function jr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function tD(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=ZN(o,0,n.time);function o(d){n.state=Iy,n.timer.restart(c,n.delay,n.time),n.delay<=d&&c(d-n.delay)}function c(d){var p,m,g,v;if(n.state!==Iy)return f();for(p in r)if(v=r[p],v.name===n.name){if(v.state===Lu)return Cy(c);v.state===Ay?(v.state=Du,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[p]):+p<t&&(v.state=Du,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[p])}if(Cy(function(){n.state===Lu&&(n.state=Ay,n.timer.restart(u,n.delay,n.time),u(d))}),n.state=nm,n.on.call("start",e,e.__data__,n.index,n.group),n.state===nm){for(n.state=Lu,i=new Array(g=n.tween.length),p=0,m=-1;p<g;++p)(v=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(i[++m]=v);i.length=m+1}}function u(d){for(var p=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(f),n.state=sm,1),m=-1,g=i.length;++m<g;)i[m].call(e,p);n.state===sm&&(n.on.call("end",e,e.__data__,n.index,n.group),f())}function f(){n.state=Du,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Fu(e,t){var n=e.__transition,r,i,o=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((r=n[c]).name!==t){o=!1;continue}i=r.state>nm&&r.state<sm,r.state=Du,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[c]}o&&delete e.__transition}}function nD(e){return this.each(function(){Fu(this,e)})}function sD(e,t){var n,r;return function(){var i=Fr(this,e),o=i.tween;if(o!==n){r=n=o;for(var c=0,u=r.length;c<u;++c)if(r[c].name===t){r=r.slice(),r.splice(c,1);break}}i.tween=r}}function rD(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Fr(this,e),c=o.tween;if(c!==r){i=(r=c).slice();for(var u={name:t,value:n},f=0,d=i.length;f<d;++f)if(i[f].name===t){i[f]=u;break}f===d&&i.push(u)}o.tween=i}}function iD(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=jr(this.node(),n).tween,i=0,o=r.length,c;i<o;++i)if((c=r[i]).name===e)return c.value;return null}return this.each((t==null?sD:rD)(n,e,t))}function Qm(e,t,n){var r=e._id;return e.each(function(){var i=Fr(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return jr(i,r).value[t]}}function VN(e,t){var n;return(typeof t=="number"?Lr:t instanceof Ia?td:(n=Ia(t))?(t=n,td):DN)(e,t)}function aD(e){return function(){this.removeAttribute(e)}}function oD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lD(e,t,n){var r,i=n+"",o;return function(){var c=this.getAttribute(e);return c===i?null:c===r?o:o=t(r=c,n)}}function cD(e,t,n){var r,i=n+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===i?null:c===r?o:o=t(r=c,n)}}function uD(e,t,n){var r,i,o;return function(){var c,u=n(this),f;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),f=u+"",c===f?null:c===r&&f===i?o:(i=f,o=t(r=c,u)))}}function dD(e,t,n){var r,i,o;return function(){var c,u=n(this),f;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),f=u+"",c===f?null:c===r&&f===i?o:(i=f,o=t(r=c,u)))}}function fD(e,t){var n=Nd(e),r=n==="transform"?WL:VN;return this.attrTween(e,typeof t=="function"?(n.local?dD:uD)(n,r,Qm(this,"attr."+e,t)):t==null?(n.local?oD:aD)(n):(n.local?cD:lD)(n,r,t))}function hD(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function pD(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function mD(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&pD(e,o)),n}return i._value=t,i}function gD(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&hD(e,o)),n}return i._value=t,i}function xD(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 r=Nd(e);return this.tween(n,(r.local?mD:gD)(r,t))}function vD(e,t){return function(){Xm(this,e).delay=+t.apply(this,arguments)}}function yD(e,t){return t=+t,function(){Xm(this,e).delay=t}}function bD(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vD:yD)(t,e)):jr(this.node(),t).delay}function kD(e,t){return function(){Fr(this,e).duration=+t.apply(this,arguments)}}function wD(e,t){return t=+t,function(){Fr(this,e).duration=t}}function ND(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?kD:wD)(t,e)):jr(this.node(),t).duration}function jD(e,t){if(typeof t!="function")throw new Error;return function(){Fr(this,e).ease=t}}function SD(e){var t=this._id;return arguments.length?this.each(jD(t,e)):jr(this.node(),t).ease}function _D(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Fr(this,e).ease=n}}function ED(e){if(typeof e!="function")throw new Error;return this.each(_D(this._id,e))}function CD(e){typeof e!="function"&&(e=NN(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=[],f,d=0;d<c;++d)(f=o[d])&&e.call(f,f.__data__,d,o)&&u.push(f);return new ui(r,this._parents,this._name,this._id)}function ID(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),c=new Array(r),u=0;u<o;++u)for(var f=t[u],d=n[u],p=f.length,m=c[u]=new Array(p),g,v=0;v<p;++v)(g=f[v]||d[v])&&(m[v]=g);for(;u<r;++u)c[u]=t[u];return new ui(c,this._parents,this._name,this._id)}function AD(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 TD(e,t,n){var r,i,o=AD(t)?Xm:Fr;return function(){var c=o(this,e),u=c.on;u!==r&&(i=(r=u).copy()).on(t,n),c.on=i}}function $D(e,t){var n=this._id;return arguments.length<2?jr(this.node(),n).on.on(e):this.each(TD(n,e,t))}function MD(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RD(){return this.on("end.remove",MD(this._id))}function OD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Vm(e));for(var r=this._groups,i=r.length,o=new Array(i),c=0;c<i;++c)for(var u=r[c],f=u.length,d=o[c]=new Array(f),p,m,g=0;g<f;++g)(p=u[g])&&(m=e.call(p,p.__data__,g,u))&&("__data__"in p&&(m.__data__=p.__data__),d[g]=m,Sd(d[g],t,n,g,d,jr(p,n)));return new ui(o,this._parents,t,n)}function zD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=wN(e));for(var r=this._groups,i=r.length,o=[],c=[],u=0;u<i;++u)for(var f=r[u],d=f.length,p,m=0;m<d;++m)if(p=f[m]){for(var g=e.call(p,p.__data__,m,f),v,y=jr(p,n),S=0,k=g.length;S<k;++S)(v=g[S])&&Sd(v,t,n,S,g,y);o.push(g),c.push(p)}return new ui(o,c,t,n)}var PD=cc.prototype.constructor;function LD(){return new PD(this._groups,this._parents)}function DD(e,t){var n,r,i;return function(){var o=$o(this,e),c=(this.style.removeProperty(e),$o(this,e));return o===c?null:o===n&&c===r?i:i=t(n=o,r=c)}}function qN(e){return function(){this.style.removeProperty(e)}}function FD(e,t,n){var r,i=n+"",o;return function(){var c=$o(this,e);return c===i?null:c===r?o:o=t(r=c,n)}}function BD(e,t,n){var r,i,o;return function(){var c=$o(this,e),u=n(this),f=u+"";return u==null&&(f=u=(this.style.removeProperty(e),$o(this,e))),c===f?null:c===r&&f===i?o:(i=f,o=t(r=c,u))}}function UD(e,t){var n,r,i,o="style."+t,c="end."+o,u;return function(){var f=Fr(this,e),d=f.on,p=f.value[o]==null?u||(u=qN(t)):void 0;(d!==n||i!==p)&&(r=(n=d).copy()).on(c,i=p),f.on=r}}function HD(e,t,n){var r=(e+="")=="transform"?ZL:VN;return t==null?this.styleTween(e,DD(e,r)).on("end.style."+e,qN(e)):typeof t=="function"?this.styleTween(e,BD(e,r,Qm(this,"style."+e,t))).each(UD(this._id,e)):this.styleTween(e,FD(e,r,t),n).on("end.style."+e,null)}function ZD(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function WD(e,t,n){var r,i;function o(){var c=t.apply(this,arguments);return c!==i&&(r=(i=c)&&ZD(e,c,n)),r}return o._value=t,o}function VD(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,WD(e,t,n??""))}function qD(e){return function(){this.textContent=e}}function GD(e){return function(){var t=e(this);this.textContent=t??""}}function KD(e){return this.tween("text",typeof e=="function"?GD(Qm(this,"text",e)):qD(e==null?"":e+""))}function YD(e){return function(t){this.textContent=e.call(this,t)}}function XD(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&YD(i)),t}return r._value=e,r}function QD(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,XD(e))}function JD(){for(var e=this._name,t=this._id,n=GN(),r=this._groups,i=r.length,o=0;o<i;++o)for(var c=r[o],u=c.length,f,d=0;d<u;++d)if(f=c[d]){var p=jr(f,t);Sd(f,e,n,d,c,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new ui(r,this._parents,e,n)}function e3(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,c){var u={value:c},f={value:function(){--i===0&&o()}};n.each(function(){var d=Fr(this,r),p=d.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(f)),d.on=t}),i===0&&o()})}var t3=0;function ui(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function GN(){return++t3}var ri=cc.prototype;ui.prototype={constructor:ui,select:OD,selectAll:zD,selectChild:ri.selectChild,selectChildren:ri.selectChildren,filter:CD,merge:ID,selection:LD,transition:JD,call:ri.call,nodes:ri.nodes,node:ri.node,size:ri.size,empty:ri.empty,each:ri.each,on:$D,attr:fD,attrTween:xD,style:HD,styleTween:VD,text:KD,textTween:QD,remove:RD,tween:iD,delay:bD,duration:ND,ease:SD,easeVarying:ED,end:e3,[Symbol.iterator]:ri[Symbol.iterator]};function n3(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var s3={time:null,delay:0,duration:250,ease:n3};function r3(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 i3(e){var t,n;e instanceof ui?(t=e._id,e=e._name):(t=GN(),(n=s3).time=Ym(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var c=r[o],u=c.length,f,d=0;d<u;++d)(f=c[d])&&Sd(f,e,t,d,c,n||r3(f,t));return new ui(r,this._parents,e,t)}cc.prototype.interrupt=nD;cc.prototype.transition=i3;const _u=e=>()=>e;function a3(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:r,enumerable:!0,configurable:!0},_:{value:i}})}function oi(e,t,n){this.k=e,this.x=t,this.y=n}oi.prototype={constructor:oi,scale:function(e){return e===1?this:new oi(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new oi(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 _d=new oi(1,0,0);KN.prototype=oi.prototype;function KN(e){for(;!e.__zoom;)if(!(e=e.parentNode))return _d;return e.__zoom}function Xh(e){e.stopImmediatePropagation()}function jl(e){e.preventDefault(),e.stopImmediatePropagation()}function o3(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function l3(){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 Ty(){return this.__zoom||_d}function c3(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function u3(){return navigator.maxTouchPoints||"ontouchstart"in this}function d3(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),c>o?(o+c)/2:Math.min(0,o)||Math.max(0,c))}function YN(){var e=o3,t=l3,n=d3,r=c3,i=u3,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,f=Pu,d=wd("start","zoom","end"),p,m,g,v=500,y=150,S=0,k=10;function w(C){C.property("__zoom",Ty).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",O).filter(i).on("touchstart.zoom",T).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",E).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(C,$,L,B){var H=C.selection?C.selection():C;H.property("__zoom",Ty),C!==H?D(C,$,L,B):H.interrupt().each(function(){P(this,arguments).event(B).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},w.scaleBy=function(C,$,L,B){w.scaleTo(C,function(){var H=this.__zoom.k,G=typeof $=="function"?$.apply(this,arguments):$;return H*G},L,B)},w.scaleTo=function(C,$,L,B){w.transform(C,function(){var H=t.apply(this,arguments),G=this.__zoom,K=L==null?R(H):typeof L=="function"?L.apply(this,arguments):L,V=G.invert(K),Y=typeof $=="function"?$.apply(this,arguments):$;return n(N(A(G,Y),K,V),H,c)},L,B)},w.translateBy=function(C,$,L,B){w.transform(C,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof L=="function"?L.apply(this,arguments):L),t.apply(this,arguments),c)},null,B)},w.translateTo=function(C,$,L,B,H){w.transform(C,function(){var G=t.apply(this,arguments),K=this.__zoom,V=B==null?R(G):typeof B=="function"?B.apply(this,arguments):B;return n(_d.translate(V[0],V[1]).scale(K.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof L=="function"?-L.apply(this,arguments):-L),G,c)},B,H)};function A(C,$){return $=Math.max(o[0],Math.min(o[1],$)),$===C.k?C:new oi($,C.x,C.y)}function N(C,$,L){var B=$[0]-L[0]*C.k,H=$[1]-L[1]*C.k;return B===C.x&&H===C.y?C:new oi(C.k,B,H)}function R(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function D(C,$,L,B){C.on("start.zoom",function(){P(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(B).end()}).tween("zoom",function(){var H=this,G=arguments,K=P(H,G).event(B),V=t.apply(H,G),Y=L==null?R(V):typeof L=="function"?L.apply(H,G):L,fe=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),xe=H.__zoom,ge=typeof $=="function"?$.apply(H,G):$,ie=f(xe.invert(Y).concat(fe/xe.k),ge.invert(Y).concat(fe/ge.k));return function(ke){if(ke===1)ke=ge;else{var ae=ie(ke),Ne=fe/ae[2];ke=new oi(Ne,Y[0]-ae[0]*Ne,Y[1]-ae[1]*Ne)}K.zoom(null,ke)}})}function P(C,$,L){return!L&&C.__zooming||new F(C,$)}function F(C,$){this.that=C,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,$),this.taps=0}F.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,$){return this.mouse&&C!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var $=As(this.that).datum();d.call(C,this.that,new a3(C,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:d}),$)}};function W(C,...$){if(!e.apply(this,arguments))return;var L=P(this,$).event(C),B=this.__zoom,H=Math.max(o[0],Math.min(o[1],B.k*Math.pow(2,r.apply(this,arguments)))),G=dr(C);if(L.wheel)(L.mouse[0][0]!==G[0]||L.mouse[0][1]!==G[1])&&(L.mouse[1]=B.invert(L.mouse[0]=G)),clearTimeout(L.wheel);else{if(B.k===H)return;L.mouse=[G,B.invert(G)],Fu(this),L.start()}jl(C),L.wheel=setTimeout(K,y),L.zoom("mouse",n(N(A(B,H),L.mouse[0],L.mouse[1]),L.extent,c));function K(){L.wheel=null,L.end()}}function M(C,...$){if(g||!e.apply(this,arguments))return;var L=C.currentTarget,B=P(this,$,!0).event(C),H=As(C.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",fe,!0),G=dr(C,L),K=C.clientX,V=C.clientY;MN(C.view),Xh(C),B.mouse=[G,this.__zoom.invert(G)],Fu(this),B.start();function Y(xe){if(jl(xe),!B.moved){var ge=xe.clientX-K,ie=xe.clientY-V;B.moved=ge*ge+ie*ie>S}B.event(xe).zoom("mouse",n(N(B.that.__zoom,B.mouse[0]=dr(xe,L),B.mouse[1]),B.extent,c))}function fe(xe){H.on("mousemove.zoom mouseup.zoom",null),RN(xe.view,B.moved),jl(xe),B.event(xe).end()}}function O(C,...$){if(e.apply(this,arguments)){var L=this.__zoom,B=dr(C.changedTouches?C.changedTouches[0]:C,this),H=L.invert(B),G=L.k*(C.shiftKey?.5:2),K=n(N(A(L,G),B,H),t.apply(this,$),c);jl(C),u>0?As(this).transition().duration(u).call(D,K,B,C):As(this).call(w.transform,K,B,C)}}function T(C,...$){if(e.apply(this,arguments)){var L=C.touches,B=L.length,H=P(this,$,C.changedTouches.length===B).event(C),G,K,V,Y;for(Xh(C),K=0;K<B;++K)V=L[K],Y=dr(V,this),Y=[Y,this.__zoom.invert(Y),V.identifier],H.touch0?!H.touch1&&H.touch0[2]!==Y[2]&&(H.touch1=Y,H.taps=0):(H.touch0=Y,G=!0,H.taps=1+!!p);p&&(p=clearTimeout(p)),G&&(H.taps<2&&(m=Y[0],p=setTimeout(function(){p=null},v)),Fu(this),H.start())}}function Z(C,...$){if(this.__zooming){var L=P(this,$).event(C),B=C.changedTouches,H=B.length,G,K,V,Y;for(jl(C),G=0;G<H;++G)K=B[G],V=dr(K,this),L.touch0&&L.touch0[2]===K.identifier?L.touch0[0]=V:L.touch1&&L.touch1[2]===K.identifier&&(L.touch1[0]=V);if(K=L.that.__zoom,L.touch1){var fe=L.touch0[0],xe=L.touch0[1],ge=L.touch1[0],ie=L.touch1[1],ke=(ke=ge[0]-fe[0])*ke+(ke=ge[1]-fe[1])*ke,ae=(ae=ie[0]-xe[0])*ae+(ae=ie[1]-xe[1])*ae;K=A(K,Math.sqrt(ke/ae)),V=[(fe[0]+ge[0])/2,(fe[1]+ge[1])/2],Y=[(xe[0]+ie[0])/2,(xe[1]+ie[1])/2]}else if(L.touch0)V=L.touch0[0],Y=L.touch0[1];else return;L.zoom("touch",n(N(K,V,Y),L.extent,c))}}function E(C,...$){if(this.__zooming){var L=P(this,$).event(C),B=C.changedTouches,H=B.length,G,K;for(Xh(C),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),G=0;G<H;++G)K=B[G],L.touch0&&L.touch0[2]===K.identifier?delete L.touch0:L.touch1&&L.touch1[2]===K.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(K=dr(K,this),Math.hypot(m[0]-K[0],m[1]-K[1])<k)){var V=As(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return w.wheelDelta=function(C){return arguments.length?(r=typeof C=="function"?C:_u(+C),w):r},w.filter=function(C){return arguments.length?(e=typeof C=="function"?C:_u(!!C),w):e},w.touchable=function(C){return arguments.length?(i=typeof C=="function"?C:_u(!!C),w):i},w.extent=function(C){return arguments.length?(t=typeof C=="function"?C:_u([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),w):t},w.scaleExtent=function(C){return arguments.length?(o[0]=+C[0],o[1]=+C[1],w):[o[0],o[1]]},w.translateExtent=function(C){return arguments.length?(c[0][0]=+C[0][0],c[1][0]=+C[1][0],c[0][1]=+C[0][1],c[1][1]=+C[1][1],w):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},w.constrain=function(C){return arguments.length?(n=C,w):n},w.duration=function(C){return arguments.length?(u=+C,w):u},w.interpolate=function(C){return arguments.length?(f=C,w):f},w.on=function(){var C=d.on.apply(d,arguments);return C===d?w:C},w.clickDistance=function(C){return arguments.length?(S=(C=+C)*C,w):Math.sqrt(S)},w.tapDistance=function(C){return arguments.length?(k=+C,w):k},w}const Nr={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 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,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,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.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Kl=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],XN=["Enter"," ","Escape"],QN={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ro;(function(e){e.Strict="strict",e.Loose="loose"})(Ro||(Ro={}));var Sa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Sa||(Sa={}));var Yl;(function(e){e.Partial="partial",e.Full="full"})(Yl||(Yl={}));const JN={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Pi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Pi||(Pi={}));var id;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(id||(id={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const $y={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top},ej=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,f3=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Jm=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),dc=(e,t=[0,0])=>{const{width:n,height:r}=Sr(e),i=e.origin??t,o=n*i[0],c=r*i[1];return{x:e.position.x-o,y:e.position.y-c}},h3=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((i,o)=>{const c=typeof o=="string";let u=!t.nodeLookup&&!c?o:void 0;return t.nodeLookup&&(u=c?t.nodeLookup.get(o):Jm(o)?o:t.nodeLookup.get(o.id)),u?(n=!0,Ed(i,ad(u,t.nodeOrigin))):i},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Cd(r):{x:0,y:0,width:0,height:0}},fc=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=Ed(n,ad(i)),r=!0)}),r?Cd(n):{x:0,y:0,width:0,height:0}},eg=(e,t,[n,r,i]=[0,0,1],o=!1,c=!1)=>{const u=(t.x-n)/i,f=(t.y-r)/i,d=t.width/i,p=t.height/i,m=[];for(const g of e.values()){const{measured:v,selectable:y=!0,hidden:S=!1}=g;if(c&&!y||S)continue;const k=v.width??g.width??g.initialWidth??0,w=v.height??g.height??g.initialHeight??0,{x:A,y:N}=g.internals.positionAbsolute,R=rj(u,f,d,p,A,N,k,w),D=k*w,P=o&&R>0;(!g.internals.handleBounds||P||R>=D||g.dragging)&&m.push(g)}return m},p3=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function m3(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{let o;if(t!=null&&t.includeHiddenNodes){const{width:c,height:u}=Sr(i);o=c>0&&u>0}else o=!!(i.measured.width&&i.measured.height&&!i.hidden);o&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function g3({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:o},c){if(e.size===0)return!0;const u=m3(e,c),f=fc(u),d=ng(f,t,n,(c==null?void 0:c.minZoom)??i,(c==null?void 0:c.maxZoom)??o,(c==null?void 0:c.padding)??.1);return await r.setViewport(d,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function tj({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const c=n.get(e),u=c.parentId?n.get(c.parentId):void 0,{x:f,y:d}=u?u.internals.positionAbsolute:{x:0,y:0},p=c.origin??r;let m=c.extent||i;if(c.extent==="parent"&&!c.expandParent)if(!u)o==null||o("005",Nr.error005());else{const{width:v,height:y}=Sr(u);v&&y&&(m=[[f,d],[f+v,d+y]])}else u&&$a(c.extent)&&(m=[[c.extent[0][0]+f,c.extent[0][1]+d],[c.extent[1][0]+f,c.extent[1][1]+d]]);const g=$a(m)?Ta(t,m,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",Nr.error015())),{position:{x:g.x-f+(c.measured.width??0)*p[0],y:g.y-d+(c.measured.height??0)*p[1]},positionAbsolute:g}}async function x3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const o=new Set(e.map(g=>g.id)),c=[];for(const g of n){if(g.deletable===!1)continue;const v=o.has(g.id),y=!v&&g.parentId&&c.find(S=>S.id===g.parentId);(v||y)&&c.push(g)}const u=new Set(t.map(g=>g.id)),f=r.filter(g=>g.deletable!==!1),p=p3(c,f);for(const g of f)u.has(g.id)&&!p.find(y=>y.id===g.id)&&p.push(g);if(!i)return{edges:p,nodes:c};const m=await i({nodes:c,edges:p});return typeof m=="boolean"?m?{edges:p,nodes:c}:{edges:[],nodes:[]}:m}const Oo=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ta=(e={x:0,y:0},t,n)=>({x:Oo(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Oo(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function nj(e,t,n){const{width:r,height:i}=Sr(n),{x:o,y:c}=n.internals.positionAbsolute;return Ta(e,[[o,c],[o+r,c+i]],t)}const My=(e,t,n)=>e<t?Oo(Math.abs(e-t),1,t)/t:e>n?-Oo(Math.abs(e-n),1,t)/t:0,tg=(e,t,n=15,r=40)=>{const i=My(e.x,r,t.width-r)*n,o=My(e.y,r,t.height-r)*n;return[i,o]},Ed=(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)}),rm=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Cd=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Xl=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=Jm(e)?e.internals.positionAbsolute:dc(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},ad=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=Jm(e)?e.internals.positionAbsolute:dc(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},sj=(e,t)=>Cd(Ed(rm(e),rm(t))),rj=(e,t,n,r,i,o,c,u)=>{const f=Math.max(0,Math.min(e+n,i+c)-Math.max(e,i)),d=Math.max(0,Math.min(t+r,o+u)-Math.max(t,o));return Math.ceil(f*d)},od=(e,t)=>rj(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ry=e=>vr(e.width)&&vr(e.height)&&vr(e.x)&&vr(e.y),vr=e=>!isNaN(e)&&isFinite(e),ij=(e,t)=>(n,r)=>{},hc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),pc=({x:e,y:t},[n,r,i],o=!1,c=[1,1])=>{const u={x:(e-n)/i,y:(t-r)/i};return o?hc(u,c):u},zo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function oo(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function v3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=oo(e,n),i=oo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=oo(e.top??e.y??0,n),i=oo(e.bottom??e.y??0,n),o=oo(e.left??e.x??0,t),c=oo(e.right??e.x??0,t);return{top:r,right:c,bottom:i,left:o,x:o+c,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function y3(e,t,n,r,i,o){const{x:c,y:u}=zo(e,[t,n,r]),{x:f,y:d}=zo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=i-f,m=o-d;return{left:Math.floor(c),top:Math.floor(u),right:Math.floor(p),bottom:Math.floor(m)}}const ng=(e,t,n,r,i,o)=>{const c=v3(o,t,n),u=(t-c.x)/e.width,f=(n-c.y)/e.height,d=Math.min(u,f),p=Oo(d,r,i),m=e.x+e.width/2,g=e.y+e.height/2,v=t/2-m*p,y=n/2-g*p,S=y3(e,v,y,p,t,n),k={left:Math.min(S.left-c.left,0),top:Math.min(S.top-c.top,0),right:Math.min(S.right-c.right,0),bottom:Math.min(S.bottom-c.bottom,0)};return{x:v-k.left+k.right,y:y-k.top+k.bottom,zoom:p}},Ql=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function $a(e){return e!=null&&e!=="parent"}function Sr(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function aj(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function oj(e,t={width:0,height:0},n,r,i){const o={...e},c=r.get(n);if(c){const u=c.origin||i;o.x+=c.internals.positionAbsolute.x-(t.width??0)*u[0],o.y+=c.internals.positionAbsolute.y-(t.height??0)*u[1]}return o}function Oy(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function b3(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function k3(e){return{...QN,...e||{}}}function lj(e){return e===null?null:e?"valid":"invalid"}function Dl(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:o,y:c}=yr(e),u=pc({x:o-((i==null?void 0:i.left)??0),y:c-((i==null?void 0:i.top)??0)},r),{x:f,y:d}=n?hc(u,t):u;return{xSnapped:f,ySnapped:d,...u}}const sg=e=>({width:e.offsetWidth,height:e.offsetHeight}),cj=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},w3=["INPUT","SELECT","TEXTAREA"];function uj(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:w3.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const dj=e=>"clientX"in e,yr=(e,t)=>{var o,c;const n=dj(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,i=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},zy=(e,t,n,r,i)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(c=>{const u=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:i,position:c.getAttribute("data-handlepos"),x:(u.left-n.left)/r,y:(u.top-n.top)/r,...sg(c)}})};function fj({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:c,targetControlY:u}){const f=e*.125+i*.375+c*.375+n*.125,d=t*.125+o*.375+u*.375+r*.125,p=Math.abs(f-e),m=Math.abs(d-t);return[f,d,p,m]}function Eu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Py({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Je.Left:return[t-Eu(t-r,o),n];case Je.Right:return[t+Eu(r-t,o),n];case Je.Top:return[t,n-Eu(n-i,o)];case Je.Bottom:return[t,n+Eu(i-n,o)]}}function hj({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:i,targetPosition:o=Je.Top,curvature:c=.25}){const[u,f]=Py({pos:n,x1:e,y1:t,x2:r,y2:i,c}),[d,p]=Py({pos:o,x1:r,y1:i,x2:e,y2:t,c}),[m,g,v,y]=fj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:u,sourceControlY:f,targetControlX:d,targetControlY:p});return[`M${e},${t} C${u},${f} ${d},${p} ${r},${i}`,m,g,v,y]}function pj({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n<e?n+i:n-i,c=Math.abs(r-t)/2,u=r<t?r+c:r-c;return[o,u,i,c]}function N3({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const c=i&&n?r+1e3:r,u=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return c+u}function j3({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){const o=Ed(ad(e),ad(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const c={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return od(c,Cd(o))>0}const S3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,_3=(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)),E3=(e,t,n={})=>{var o;if(!e.source||!e.target)return(o=n.onError)==null||o.call(n,"006",Nr.error006()),t;const r=n.getEdgeId||S3;let i;return ej(e)?i={...e}:i={...e,id:r(e)},_3(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function mj({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,c,u]=pj({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,c,u]}const Ly={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},C3=({source:e,sourcePosition:t=Je.Bottom,target:n})=>t===Je.Left||t===Je.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},Dy=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function I3({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:r=Je.Top,center:i,offset:o,stepPosition:c}){const u=Ly[t],f=Ly[r],d={x:e.x+u.x*o,y:e.y+u.y*o},p={x:n.x+f.x*o,y:n.y+f.y*o},m=C3({source:d,sourcePosition:t,target:p}),g=m.x!==0?"x":"y",v=m[g];let y=[],S,k;const w={x:0,y:0},A={x:0,y:0},[,,N,R]=pj({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[g]*f[g]===-1){g==="x"?(S=i.x??d.x+(p.x-d.x)*c,k=i.y??(d.y+p.y)/2):(S=i.x??(d.x+p.x)/2,k=i.y??d.y+(p.y-d.y)*c);const W=[{x:S,y:d.y},{x:S,y:p.y}],M=[{x:d.x,y:k},{x:p.x,y:k}];u[g]===v?y=g==="x"?W:M:y=g==="x"?M:W}else{const W=[{x:d.x,y:p.y}],M=[{x:p.x,y:d.y}];if(g==="x"?y=u.x===v?M:W:y=u.y===v?W:M,t===r){const C=Math.abs(e[g]-n[g]);if(C<=o){const $=Math.min(o-1,o-C);u[g]===v?w[g]=(d[g]>e[g]?-1:1)*$:A[g]=(p[g]>n[g]?-1:1)*$}}if(t!==r){const C=g==="x"?"y":"x",$=u[g]===f[C],L=d[C]>p[C],B=d[C]<p[C];(u[g]===1&&(!$&&L||$&&B)||u[g]!==1&&(!$&&B||$&&L))&&(y=g==="x"?W:M)}const O={x:d.x+w.x,y:d.y+w.y},T={x:p.x+A.x,y:p.y+A.y},Z=Math.max(Math.abs(O.x-y[0].x),Math.abs(T.x-y[0].x)),E=Math.max(Math.abs(O.y-y[0].y),Math.abs(T.y-y[0].y));Z>=E?(S=(O.x+T.x)/2,k=y[0].y):(S=y[0].x,k=(O.y+T.y)/2)}const D={x:d.x+w.x,y:d.y+w.y},P={x:p.x+A.x,y:p.y+A.y};return[[e,...D.x!==y[0].x||D.y!==y[0].y?[D]:[],...y,...P.x!==y[y.length-1].x||P.y!==y[y.length-1].y?[P]:[],n],S,k,N,R]}function A3(e,t,n,r){const i=Math.min(Dy(e,t)/2,Dy(t,n)/2,r),{x:o,y:c}=t;if(e.x===o&&o===n.x||e.y===c&&c===n.y)return`L${o} ${c}`;if(e.y===c){const d=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+i*d},${c}Q ${o},${c} ${o},${c+i*p}`}const u=e.x<n.x?1:-1,f=e.y<n.y?-1:1;return`L ${o},${c+i*f}Q ${o},${c} ${o+i*u},${c}`}function im({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:i,targetPosition:o=Je.Top,borderRadius:c=5,centerX:u,centerY:f,offset:d=20,stepPosition:p=.5}){const[m,g,v,y,S]=I3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:u,y:f},offset:d,stepPosition:p});let k=`M${m[0].x} ${m[0].y}`;for(let w=1;w<m.length-1;w++)k+=A3(m[w-1],m[w],m[w+1],c);return k+=`L${m[m.length-1].x} ${m[m.length-1].y}`,[k,g,v,y,S]}function Fy(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function T3(e){var m;const{sourceNode:t,targetNode:n}=e;if(!Fy(t)||!Fy(n))return null;const r=t.internals.handleBounds||By(t.handles),i=n.internals.handleBounds||By(n.handles),o=Uy((r==null?void 0:r.source)??[],e.sourceHandle),c=Uy(e.connectionMode===Ro.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),e.targetHandle);if(!o||!c)return(m=e.onError)==null||m.call(e,"008",Nr.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||Je.Bottom,f=(c==null?void 0:c.position)||Je.Top,d=Ma(t,o,u),p=Ma(n,c,f);return{sourceX:d.x,sourceY:d.y,targetX:p.x,targetY:p.y,sourcePosition:u,targetPosition:f}}function By(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Ma(e,t,n=Je.Left,r=!1){const i=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:c,height:u}=t??Sr(e);if(r)return{x:i+c/2,y:o+u/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:i+c/2,y:o};case Je.Right:return{x:i+c,y:o+u/2};case Je.Bottom:return{x:i+c/2,y:o+u};case Je.Left:return{x:i,y:o+u/2}}}function Uy(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function am(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function $3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((c,u)=>([u.markerStart||r,u.markerEnd||i].forEach(f=>{if(f&&typeof f=="object"){const d=am(f,t);o.has(d)||(c.push({id:d,color:f.color||n,...f}),o.add(d))}}),c),[]).sort((c,u)=>c.id.localeCompare(u.id))}const gj=1e3,M3=10,rg={nodeOrigin:[0,0],nodeExtent:Kl,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},R3={...rg,checkEquality:!0};function ig(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function O3(e,t,n){const r=ig(rg,n);for(const i of e.values())if(i.parentId)og(i,e,t,r);else{const o=dc(i,r.nodeOrigin),c=$a(i.extent)?i.extent:r.nodeExtent,u=Ta(o,c,Sr(i));i.internals.positionAbsolute=u}}function z3(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(o):i.type==="target"&&r.push(o)}return{source:n,target:r}}function ag(e){return e==="manual"}function om(e,t,n,r={}){var p,m;const i=ig(R3,r),o={i:0},c=new Map(t),u=i!=null&&i.elevateNodesOnSelect&&!ag(i.zIndexMode)?gj:0;let f=e.length>0,d=!1;t.clear(),n.clear();for(const g of e){let v=c.get(g.id);if(i.checkEquality&&g===(v==null?void 0:v.internals.userNode))t.set(g.id,v);else{const y=dc(g,i.nodeOrigin),S=$a(g.extent)?g.extent:i.nodeExtent,k=Ta(y,S,Sr(g));v={...i.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(m=g.measured)==null?void 0:m.height},internals:{positionAbsolute:k,handleBounds:z3(g,v),z:xj(g,u,i.zIndexMode),userNode:g}},t.set(g.id,v)}(v.measured===void 0||v.measured.width===void 0||v.measured.height===void 0)&&!v.hidden&&(f=!1),g.parentId&&og(v,t,n,r,o),d||(d=g.selected??!1)}return{nodesInitialized:f,hasSelectedNodes:d}}function P3(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function og(e,t,n,r,i){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:u,zIndexMode:f}=ig(rg,r),d=e.parentId,p=t.get(d);if(!p){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}P3(e,n),i&&!p.parentId&&p.internals.rootParentIndex===void 0&&f==="auto"&&(p.internals.rootParentIndex=++i.i,p.internals.z=p.internals.z+i.i*M3),i&&p.internals.rootParentIndex!==void 0&&(i.i=p.internals.rootParentIndex);const m=o&&!ag(f)?gj:0,{x:g,y:v,z:y}=L3(e,p,c,u,m,f),{positionAbsolute:S}=e.internals,k=g!==S.x||v!==S.y;(k||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:g,y:v}:S,z:y}})}function xj(e,t,n){const r=vr(e.zIndex)?e.zIndex:0;return ag(n)?r:r+(e.selected?t:0)}function L3(e,t,n,r,i,o){const{x:c,y:u}=t.internals.positionAbsolute,f=Sr(e),d=dc(e,n),p=$a(e.extent)?Ta(d,e.extent,f):d;let m=Ta({x:c+p.x,y:u+p.y},r,f);e.extent==="parent"&&(m=nj(m,f,t));const g=xj(e,i,o),v=t.internals.z??0;return{x:m.x,y:m.y,z:v>=g?v+1:g}}function lg(e,t,n,r=[0,0]){var c;const i=[],o=new Map;for(const u of e){const f=t.get(u.parentId);if(!f)continue;const d=((c=o.get(u.parentId))==null?void 0:c.expandedRect)??Xl(f),p=sj(d,u.rect);o.set(u.parentId,{expandedRect:p,parent:f})}return o.size>0&&o.forEach(({expandedRect:u,parent:f},d)=>{var N;const p=f.internals.positionAbsolute,m=Sr(f),g=f.origin??r,v=u.x<p.x?Math.round(Math.abs(p.x-u.x)):0,y=u.y<p.y?Math.round(Math.abs(p.y-u.y)):0,S=Math.max(m.width,Math.round(u.width)),k=Math.max(m.height,Math.round(u.height)),w=(S-m.width)*g[0],A=(k-m.height)*g[1];(v>0||y>0||w||A)&&(i.push({id:d,type:"position",position:{x:f.position.x-v+w,y:f.position.y-y+A}}),(N=n.get(d))==null||N.forEach(R=>{e.some(D=>D.id===R.id)||i.push({id:R.id,type:"position",position:{x:R.position.x+v,y:R.position.y+y}})})),(m.width<u.width||m.height<u.height||v||y)&&i.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:S+(v?g[0]*v-w:0),height:k+(y?g[1]*y-A:0)}})}),i}function D3(e,t,n,r,i,o,c){const u=r==null?void 0:r.querySelector(".xyflow__viewport");let f=!1;if(!u)return{changes:[],updatedInternals:f};const d=[],p=window.getComputedStyle(u),{m22:m}=new window.DOMMatrixReadOnly(p.transform),g=[];for(const v of e.values()){const y=t.get(v.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),f=!0;continue}const S=sg(v.nodeElement),k=y.measured.width!==S.width||y.measured.height!==S.height;if(!!(S.width&&S.height&&(k||!y.internals.handleBounds||v.force))){const A=v.nodeElement.getBoundingClientRect(),N=$a(y.extent)?y.extent:o;let{positionAbsolute:R}=y.internals;if(y.parentId&&y.extent==="parent"){const P=t.get(y.parentId);P&&(R=nj(R,S,P))}else N&&(R=Ta(R,N,S));const D={...y,measured:S,internals:{...y.internals,positionAbsolute:R,handleBounds:{source:zy("source",v.nodeElement,A,m,y.id),target:zy("target",v.nodeElement,A,m,y.id)}}};t.set(y.id,D),y.parentId&&og(D,t,n,{nodeOrigin:i,zIndexMode:c}),f=!0,k&&(d.push({id:y.id,type:"dimensions",dimensions:S}),y.expandParent&&y.parentId&&g.push({id:y.id,parentId:y.parentId,rect:Xl(D,i)}))}}if(g.length>0){const v=lg(g,t,n,i);d.push(...v)}return{changes:d,updatedInternals:f}}async function F3({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:o}){if(!t||!e.x&&!e.y)return!1;const c=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,o]],r);return!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2])}function Hy(e,t,n,r,i,o){let c=i;const u=r.get(c)||new Map;r.set(c,u.set(n,t)),c=`${i}-${e}`;const f=r.get(c)||new Map;if(r.set(c,f.set(n,t)),o){c=`${i}-${e}-${o}`;const d=r.get(c)||new Map;r.set(c,d.set(n,t))}}function vj(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:o,sourceHandle:c=null,targetHandle:u=null}=r,f={edgeId:r.id,source:i,target:o,sourceHandle:c,targetHandle:u},d=`${i}-${c}--${o}-${u}`,p=`${o}-${u}--${i}-${c}`;Hy("source",f,p,e,i,c),Hy("target",f,d,e,o,u),t.set(r.id,r)}}function yj(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:yj(n,t):!1}function Zy(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function B3(e,t,n,r){const i=new Map;for(const[o,c]of e)if((c.selected||c.id===r)&&(!c.parentId||!yj(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const u=e.get(o);u&&i.set(o,{id:o,position:u.position||{x:0,y:0},distance:{x:n.x-u.internals.positionAbsolute.x,y:n.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return i}function Qh({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var c,u,f;const i=[];for(const[d,p]of t){const m=(c=n.get(d))==null?void 0:c.internals.userNode;m&&i.push({...m,position:p.position,dragging:r})}if(!e)return[i[0],i];const o=(u=n.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((f=t.get(e))==null?void 0:f.position)||o.position,dragging:r}:i[0],i]}function U3({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:n-i.distance.x,y:r-i.distance.y},c=hc(o,t);return{x:c.x-o.x,y:c.y-o.y}}function H3({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let o={x:null,y:null},c=0,u=new Map,f=!1,d={x:0,y:0},p=null,m=!1,g=null,v=!1,y=!1,S=null;function k({noDragClassName:A,handleSelector:N,domNode:R,isSelectable:D,nodeId:P,nodeClickDistance:F=0}){g=As(R);function W({x:Z,y:E}){const{nodeLookup:C,nodeExtent:$,snapGrid:L,snapToGrid:B,nodeOrigin:H,onNodeDrag:G,onSelectionDrag:K,onError:V,updateNodePositions:Y}=t();o={x:Z,y:E};let fe=!1;const xe=u.size>1,ge=xe&&$?rm(fc(u)):null,ie=xe&&B?U3({dragItems:u,snapGrid:L,x:Z,y:E}):null;for(const[ke,ae]of u){if(!C.has(ke))continue;let Ne={x:Z-ae.distance.x,y:E-ae.distance.y};B&&(Ne=ie?{x:Math.round(Ne.x+ie.x),y:Math.round(Ne.y+ie.y)}:hc(Ne,L));let Fe=null;if(xe&&$&&!ae.extent&&ge){const{positionAbsolute:re}=ae.internals,he=re.x-ge.x+$[0][0],Le=re.x+ae.measured.width-ge.x2+$[1][0],Te=re.y-ge.y+$[0][1],Ge=re.y+ae.measured.height-ge.y2+$[1][1];Fe=[[he,Te],[Le,Ge]]}const{position:ce,positionAbsolute:Se}=tj({nodeId:ke,nextPosition:Ne,nodeLookup:C,nodeExtent:Fe||$,nodeOrigin:H,onError:V});fe=fe||ae.position.x!==ce.x||ae.position.y!==ce.y,ae.position=ce,ae.internals.positionAbsolute=Se}if(y=y||fe,!!fe&&(Y(u,!0),S&&(r||G||!P&&K))){const[ke,ae]=Qh({nodeId:P,dragItems:u,nodeLookup:C});r==null||r(S,u,ke,ae),G==null||G(S,ke,ae),P||K==null||K(S,ae)}}async function M(){if(!p)return;const{transform:Z,panBy:E,autoPanSpeed:C,autoPanOnNodeDrag:$}=t();if(!$){f=!1,cancelAnimationFrame(c);return}const[L,B]=tg(d,p,C);(L!==0||B!==0)&&(o.x=(o.x??0)-L/Z[2],o.y=(o.y??0)-B/Z[2],await E({x:L,y:B})&&W(o)),c=requestAnimationFrame(M)}function O(Z){var xe;const{nodeLookup:E,multiSelectionActive:C,nodesDraggable:$,transform:L,snapGrid:B,snapToGrid:H,selectNodesOnDrag:G,onNodeDragStart:K,onSelectionDragStart:V,unselectNodesAndEdges:Y}=t();m=!0,(!G||!D)&&!C&&P&&((xe=E.get(P))!=null&&xe.selected||Y()),D&&G&&P&&(e==null||e(P));const fe=Dl(Z.sourceEvent,{transform:L,snapGrid:B,snapToGrid:H,containerBounds:p});if(o=fe,u=B3(E,$,fe,P),u.size>0&&(n||K||!P&&V)){const[ge,ie]=Qh({nodeId:P,dragItems:u,nodeLookup:E});n==null||n(Z.sourceEvent,u,ge,ie),K==null||K(Z.sourceEvent,ge,ie),P||V==null||V(Z.sourceEvent,ie)}}const T=ON().clickDistance(F).on("start",Z=>{const{domNode:E,nodeDragThreshold:C,transform:$,snapGrid:L,snapToGrid:B}=t();p=(E==null?void 0:E.getBoundingClientRect())||null,v=!1,y=!1,S=Z.sourceEvent,C===0&&O(Z),o=Dl(Z.sourceEvent,{transform:$,snapGrid:L,snapToGrid:B,containerBounds:p}),d=yr(Z.sourceEvent,p)}).on("drag",Z=>{const{autoPanOnNodeDrag:E,transform:C,snapGrid:$,snapToGrid:L,nodeDragThreshold:B,nodeLookup:H}=t(),G=Dl(Z.sourceEvent,{transform:C,snapGrid:$,snapToGrid:L,containerBounds:p});if(S=Z.sourceEvent,(Z.sourceEvent.type==="touchmove"&&Z.sourceEvent.touches.length>1||P&&!H.has(P))&&(v=!0),!v){if(!f&&E&&m&&(f=!0,M()),!m){const K=yr(Z.sourceEvent,p),V=K.x-d.x,Y=K.y-d.y;Math.sqrt(V*V+Y*Y)>B&&O(Z)}(o.x!==G.xSnapped||o.y!==G.ySnapped)&&u&&m&&(d=yr(Z.sourceEvent,p),W(G))}}).on("end",Z=>{if(!m||v){v&&u.size>0&&t().updateNodePositions(u,!1);return}if(f=!1,m=!1,cancelAnimationFrame(c),u.size>0){const{nodeLookup:E,updateNodePositions:C,onNodeDragStop:$,onSelectionDragStop:L}=t();if(y&&(C(u,!1),y=!1),i||$||!P&&L){const[B,H]=Qh({nodeId:P,dragItems:u,nodeLookup:E,dragging:!1});i==null||i(Z.sourceEvent,u,B,H),$==null||$(Z.sourceEvent,B,H),P||L==null||L(Z.sourceEvent,H)}}}).filter(Z=>{const E=Z.target;return!Z.button&&(!A||!Zy(E,`.${A}`,R))&&(!N||Zy(E,N,R))});g.call(T)}function w(){g==null||g.on(".drag",null)}return{update:k,destroy:w}}function Z3(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())od(i,Xl(o))>0&&r.push(o);return r}const W3=250;function V3(e,t,n,r){var u,f;let i=[],o=1/0;const c=Z3(e,n,t+W3);for(const d of c){const p=[...((u=d.internals.handleBounds)==null?void 0:u.source)??[],...((f=d.internals.handleBounds)==null?void 0:f.target)??[]];for(const m of p){if(r.nodeId===m.nodeId&&r.type===m.type&&r.id===m.id)continue;const{x:g,y:v}=Ma(d,m,m.position,!0),y=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(v-e.y,2));y>t||(y<o?(i=[{...m,x:g,y:v}],o=y):y===o&&i.push({...m,x:g,y:v}))}}if(!i.length)return null;if(i.length>1){const d=r.type==="source"?"target":"source";return i.find(p=>p.type===d)??i[0]}return i[0]}function bj(e,t,n,r,i,o=!1){var d,p,m;const c=r.get(e);if(!c)return null;const u=i==="strict"?(d=c.internals.handleBounds)==null?void 0:d[t]:[...((p=c.internals.handleBounds)==null?void 0:p.source)??[],...((m=c.internals.handleBounds)==null?void 0:m.target)??[]],f=(n?u==null?void 0:u.find(g=>g.id===n):u==null?void 0:u[0])??null;return f&&o?{...f,...Ma(c,f,f.position,!0)}:f}function kj(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function q3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const wj=()=>!0;function G3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:c,domNode:u,nodeLookup:f,lib:d,autoPanOnConnect:p,flowId:m,panBy:g,cancelConnection:v,onConnectStart:y,onConnect:S,onConnectEnd:k,isValidConnection:w=wj,onReconnectEnd:A,updateConnection:N,getTransform:R,getFromHandle:D,autoPanSpeed:P,dragThreshold:F=1,handleDomNode:W}){const M=cj(e.target);let O=0,T;const{x:Z,y:E}=yr(e),C=kj(o,W),$=u==null?void 0:u.getBoundingClientRect();let L=!1;if(!$||!C)return;const B=bj(i,C,r,f,t);if(!B)return;let H=yr(e,$),G=!1,K=null,V=!1,Y=null;function fe(){if(!p||!$)return;const[ce,Se]=tg(H,$,P);g({x:ce,y:Se}),O=requestAnimationFrame(fe)}const xe={...B,nodeId:i,type:C,position:B.position},ge=f.get(i);let ke={inProgress:!0,isValid:null,from:Ma(ge,xe,Je.Left,!0),fromHandle:xe,fromPosition:xe.position,fromNode:ge,to:H,toHandle:null,toPosition:$y[xe.position],toNode:null,pointer:H};function ae(){L=!0,N(ke),y==null||y(e,{nodeId:i,handleId:r,handleType:C})}F===0&&ae();function Ne(ce){if(!L){const{x:Ge,y:Ie}=yr(ce),tt=Ge-Z,et=Ie-E;if(!(tt*tt+et*et>F*F))return;ae()}if(!D()||!xe){Fe(ce);return}const Se=R();H=yr(ce,$),T=V3(pc(H,Se,!1,[1,1]),n,f,xe),G||(fe(),G=!0);const re=Nj(ce,{handle:T,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:c?"target":"source",isValidConnection:w,doc:M,lib:d,flowId:m,nodeLookup:f});Y=re.handleDomNode,K=re.connection,V=q3(!!T,re.isValid);const he=f.get(i),Le=he?Ma(he,xe,Je.Left,!0):ke.from,Te={...ke,from:Le,isValid:V,to:re.toHandle&&V?zo({x:re.toHandle.x,y:re.toHandle.y},Se):H,toHandle:re.toHandle,toPosition:V&&re.toHandle?re.toHandle.position:$y[xe.position],toNode:re.toHandle?f.get(re.toHandle.nodeId):null,pointer:H};N(Te),ke=Te}function Fe(ce){if(!("touches"in ce&&ce.touches.length>0)){if(L){(T||Y)&&K&&V&&(S==null||S(K));const{inProgress:Se,...re}=ke,he={...re,toPosition:ke.toHandle?ke.toPosition:null};k==null||k(ce,he),o&&(A==null||A(ce,he))}v(),cancelAnimationFrame(O),G=!1,V=!1,K=null,Y=null,M.removeEventListener("mousemove",Ne),M.removeEventListener("mouseup",Fe),M.removeEventListener("touchmove",Ne),M.removeEventListener("touchend",Fe)}}M.addEventListener("mousemove",Ne),M.addEventListener("mouseup",Fe),M.addEventListener("touchmove",Ne),M.addEventListener("touchend",Fe)}function Nj(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:o,doc:c,lib:u,flowId:f,isValidConnection:d=wj,nodeLookup:p}){const m=o==="target",g=t?c.querySelector(`.${u}-flow__handle[data-id="${f}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:v,y}=yr(e),S=c.elementFromPoint(v,y),k=S!=null&&S.classList.contains(`${u}-flow__handle`)?S:g,w={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const A=kj(void 0,k),N=k.getAttribute("data-nodeid"),R=k.getAttribute("data-handleid"),D=k.classList.contains("connectable"),P=k.classList.contains("connectableend");if(!N||!A)return w;const F={source:m?N:r,sourceHandle:m?R:i,target:m?r:N,targetHandle:m?i:R};w.connection=F;const M=D&&P&&(n===Ro.Strict?m&&A==="source"||!m&&A==="target":N!==r||R!==i);w.isValid=M&&d(F),w.toHandle=bj(N,A,R,p,n,!0)}return w}const lm={onPointerDown:G3,isValid:Nj};function K3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=As(e);function o({translateExtent:u,width:f,height:d,zoomStep:p=1,pannable:m=!0,zoomable:g=!0,inversePan:v=!1}){const y=N=>{if(N.sourceEvent.type!=="wheel"||!t)return;const R=n(),D=N.sourceEvent.ctrlKey&&Ql()?10:1,P=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*p,F=R[2]*Math.pow(2,P*D);t.scaleTo(F)};let S=[0,0];const k=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(S=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},w=N=>{const R=n();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!t)return;const D=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],P=[D[0]-S[0],D[1]-S[1]];S=D;const F=r()*Math.max(R[2],Math.log(R[2]))*(v?-1:1),W={x:R[0]-P[0]*F,y:R[1]-P[1]*F},M=[[0,0],[f,d]];t.setViewportConstrained({x:W.x,y:W.y,zoom:R[2]},M,u)},A=YN().on("start",k).on("zoom",m?w:null).on("zoom.wheel",g?y:null);i.call(A,{})}function c(){i.on("zoom",null)}return{update:o,destroy:c,pointer:dr}}const Id=e=>({x:e.x,y:e.y,zoom:e.k}),Jh=({x:e,y:t,zoom:n})=>_d.translate(e,t).scale(n),zi=(e,t)=>e.target.closest(`.${t}`),jj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Y3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ep=(e,t=0,n=Y3,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},Sj=e=>{const t=e.ctrlKey&&Ql()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function X3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:c,onPanZoomStart:u,onPanZoom:f,onPanZoomEnd:d}){return p=>{if(zi(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const m=n.property("__zoom").k||1;if(p.ctrlKey&&c){const k=dr(p),w=Sj(p),A=m*Math.pow(2,w);r.scaleTo(n,A,k,p);return}const g=p.deltaMode===1?20:1;let v=i===Sa.Vertical?0:p.deltaX*g,y=i===Sa.Horizontal?0:p.deltaY*g;!Ql()&&p.shiftKey&&i!==Sa.Vertical&&(v=p.deltaY*g,y=0),r.translateBy(n,-(v/m)*o,-(y/m)*o,{internal:!0});const S=Id(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?f==null||f(p,S):(e.isPanScrolling=!0,u==null||u(p,S)),e.panScrollTimeout=setTimeout(()=>{d==null||d(p,S),e.isPanScrolling=!1},150)}}function Q3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const o=r.type==="wheel",c=!t&&o&&!r.ctrlKey,u=zi(r,e);if(r.ctrlKey&&o&&u&&r.preventDefault(),c||u)return null;r.preventDefault(),n.call(this,r,i)}}function J3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,c,u;if((o=r.sourceEvent)!=null&&o.internal)return;const i=Id(r.transform);e.mouseButton=((c=r.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((u=r.sourceEvent)==null?void 0:u.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function e4({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return o=>{var c,u;e.usedRightMouseButton=!!(n&&jj(t,e.mouseButton??0)),(c=o.sourceEvent)!=null&&c.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!((u=o.sourceEvent)!=null&&u.internal)&&(i==null||i(o.sourceEvent,Id(o.transform)))}}function t4({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return c=>{var u;if(!((u=c.sourceEvent)!=null&&u.internal)&&(e.isZoomingOrPanning=!1,o&&jj(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const f=Id(c.transform);e.prevViewport=f,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(c.sourceEvent,f)},n?150:0)}}}function n4({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:o,zoomOnDoubleClick:c,userSelectionActive:u,noWheelClassName:f,noPanClassName:d,lib:p,connectionInProgress:m}){return g=>{var w;const v=t||n,y=r&&g.ctrlKey,S=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(zi(g,`${p}-flow__node`)||zi(g,`${p}-flow__edge`)||zi(g,`${p}-flow__selection`)||zi(g,`${p}-flow__nodesselection`)))return!0;if(!i&&!v&&!o&&!c&&!r||u||m&&!S||zi(g,f)&&S||zi(g,d)&&(!S||o&&S&&!t)||!r&&g.ctrlKey&&S)return!1;if(!r&&g.type==="touchstart"&&((w=g.touches)==null?void 0:w.length)>1)return g.preventDefault(),!1;if(!v&&!o&&!y&&S||!i&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(i)&&!i.includes(g.button)&&g.type==="mousedown")return!1;const k=Array.isArray(i)&&i.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||S||e)&&k}}function s4({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:c,onPanZoomEnd:u,onDraggingChange:f}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect();let m=[[0,0],[p.width,p.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(E=>{const C=E[0];C&&(m=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;g==null||g.observe(e);const v=YN().extent(()=>m).scaleExtent([t,n]).translateExtent(r),y=As(e).call(v);R({x:i.x,y:i.y,zoom:Oo(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const S=y.on("wheel.zoom"),k=y.on("dblclick.zoom");v.wheelDelta(Sj);async function w(E,C){return y?new Promise($=>{v==null||v.interpolate((C==null?void 0:C.interpolate)==="linear"?Ll:Pu).transform(ep(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>$(!0)),E)}):!1}function A({noWheelClassName:E,noPanClassName:C,onPaneContextMenu:$,userSelectionActive:L,panOnScroll:B,panOnDrag:H,panOnScrollMode:G,panOnScrollSpeed:K,preventScrolling:V,zoomOnPinch:Y,zoomOnScroll:fe,zoomOnDoubleClick:xe,panActivationKeyPressed:ge=!1,zoomActivationKeyPressed:ie,lib:ke,onTransformChange:ae,connectionInProgress:Ne,paneClickDistance:Fe,selectionOnDrag:ce}){L&&!d.isZoomingOrPanning&&N();const Se=B&&!ie&&!L;v.clickDistance(ce?1/0:!vr(Fe)||Fe<0?0:Fe);const re=Se?X3({zoomPanValues:d,noWheelClassName:E,d3Selection:y,d3Zoom:v,panOnScrollMode:G,panOnScrollSpeed:K,zoomOnPinch:Y,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:u}):Q3({noWheelClassName:E,preventScrolling:V,d3ZoomHandler:S});y.on("wheel.zoom",re,{passive:!1});const he=J3({zoomPanValues:d,onDraggingChange:f,onPanZoomStart:c});v.on("start",he);const Le=e4({zoomPanValues:d,panOnDrag:H,onPaneContextMenu:!!$,onPanZoom:o,onTransformChange:ae});v.on("zoom",Le);const Te=t4({zoomPanValues:d,panOnDrag:H,panOnScroll:B,onPaneContextMenu:$,onPanZoomEnd:u,onDraggingChange:f});v.on("end",Te);const Ge=n4({panActivationKeyPressed:ge,zoomActivationKeyPressed:ie,panOnDrag:H,zoomOnScroll:fe,panOnScroll:B,zoomOnDoubleClick:xe,zoomOnPinch:Y,userSelectionActive:L,noPanClassName:C,noWheelClassName:E,lib:ke,connectionInProgress:Ne});v.filter(Ge),xe?y.on("dblclick.zoom",k):y.on("dblclick.zoom",null)}function N(){v.on("zoom",null)}async function R(E,C,$){const L=Jh(E),B=v==null?void 0:v.constrain()(L,C,$);return B&&await w(B),B}async function D(E,C){const $=Jh(E);return await w($,C),$}function P(E){if(y){const C=Jh(E),$=y.property("__zoom");($.k!==E.zoom||$.x!==E.x||$.y!==E.y)&&(v==null||v.transform(y,C,null,{sync:!0}))}}function F(){const E=y?KN(y.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}async function W(E,C){return y?new Promise($=>{v==null||v.interpolate((C==null?void 0:C.interpolate)==="linear"?Ll:Pu).scaleTo(ep(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>$(!0)),E)}):!1}async function M(E,C){return y?new Promise($=>{v==null||v.interpolate((C==null?void 0:C.interpolate)==="linear"?Ll:Pu).scaleBy(ep(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>$(!0)),E)}):!1}function O(E){v==null||v.scaleExtent(E)}function T(E){v==null||v.translateExtent(E)}function Z(E){const C=!vr(E)||E<0?0:E;v==null||v.clickDistance(C)}return{update:A,destroy:N,setViewport:D,setViewportConstrained:R,getViewport:F,scaleTo:W,scaleBy:M,setScaleExtent:O,setTranslateExtent:T,syncViewport:P,setClickDistance:Z}}var Po;(function(e){e.Line="line",e.Handle="handle"})(Po||(Po={}));function r4({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:o}){const c=e-t,u=n-r,f=[c>0?1:c<0?-1:0,u>0?1:u<0?-1:0];return c&&i&&(f[0]=f[0]*-1),u&&o&&(f[1]=f[1]*-1),f}function Wy(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function Ri(e,t){return Math.max(0,t-e)}function Oi(e,t){return Math.max(0,e-t)}function Cu(e,t,n){return Math.max(0,t-e,e-n)}function Vy(e,t){return e?!t:t}function i4(e,t,n,r,i,o,c,u){let{affectsX:f,affectsY:d}=t;const{isHorizontal:p,isVertical:m}=t,g=p&&m,{xSnapped:v,ySnapped:y}=n,{minWidth:S,maxWidth:k,minHeight:w,maxHeight:A}=r,{x:N,y:R,width:D,height:P,aspectRatio:F}=e;let W=Math.floor(p?v-e.pointerX:0),M=Math.floor(m?y-e.pointerY:0);const O=D+(f?-W:W),T=P+(d?-M:M),Z=-o[0]*D,E=-o[1]*P;let C=Cu(O,S,k),$=Cu(T,w,A);if(c){let H=0,G=0;f&&W<0?H=Ri(N+W+Z,c[0][0]):!f&&W>0&&(H=Oi(N+O+Z,c[1][0])),d&&M<0?G=Ri(R+M+E,c[0][1]):!d&&M>0&&(G=Oi(R+T+E,c[1][1])),C=Math.max(C,H),$=Math.max($,G)}if(u){let H=0,G=0;f&&W>0?H=Oi(N+W,u[0][0]):!f&&W<0&&(H=Ri(N+O,u[1][0])),d&&M>0?G=Oi(R+M,u[0][1]):!d&&M<0&&(G=Ri(R+T,u[1][1])),C=Math.max(C,H),$=Math.max($,G)}if(i){if(p){const H=Cu(O/F,w,A)*F;if(C=Math.max(C,H),c){let G=0;!f&&!d||f&&!d&&g?G=Oi(R+E+O/F,c[1][1])*F:G=Ri(R+E+(f?W:-W)/F,c[0][1])*F,C=Math.max(C,G)}if(u){let G=0;!f&&!d||f&&!d&&g?G=Ri(R+O/F,u[1][1])*F:G=Oi(R+(f?W:-W)/F,u[0][1])*F,C=Math.max(C,G)}}if(m){const H=Cu(T*F,S,k)/F;if($=Math.max($,H),c){let G=0;!f&&!d||d&&!f&&g?G=Oi(N+T*F+Z,c[1][0])/F:G=Ri(N+(d?M:-M)*F+Z,c[0][0])/F,$=Math.max($,G)}if(u){let G=0;!f&&!d||d&&!f&&g?G=Ri(N+T*F,u[1][0])/F:G=Oi(N+(d?M:-M)*F,u[0][0])/F,$=Math.max($,G)}}}M=M+(M<0?$:-$),W=W+(W<0?C:-C),i&&(g?O>T*F?M=(Vy(f,d)?-W:W)/F:W=(Vy(f,d)?-M:M)*F:p?(M=W/F,d=f):(W=M*F,f=d));const L=f?N+W:N,B=d?R+M:R;return{width:D+(f?-W:W),height:P+(d?-M:M),x:o[0]*W*(f?-1:1)+L,y:o[1]*M*(d?-1:1)+B}}const _j={width:0,height:0,x:0,y:0},a4={..._j,pointerX:0,pointerY:0,aspectRatio:1};function o4(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,o=e.measured.width??0,c=e.measured.height??0,u=n[0]*o,f=n[1]*c;return[[r-u,i-f],[r+o-u,i+c-f]]}function l4({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const o=As(e);let c={controlDirection:Wy("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:d,boundaries:p,keepAspectRatio:m,resizeDirection:g,onResizeStart:v,onResize:y,onResizeEnd:S,shouldResize:k}){let w={..._j},A={...a4};c={boundaries:p,resizeDirection:g,keepAspectRatio:m,controlDirection:Wy(d)};let N,R=null,D=[],P,F,W,M=!1;const O=ON().on("start",T=>{const{nodeLookup:Z,transform:E,snapGrid:C,snapToGrid:$,nodeOrigin:L,paneDomNode:B}=n();if(N=Z.get(t),!N)return;R=(B==null?void 0:B.getBoundingClientRect())??null;const{xSnapped:H,ySnapped:G}=Dl(T.sourceEvent,{transform:E,snapGrid:C,snapToGrid:$,containerBounds:R});w={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},A={...w,pointerX:H,pointerY:G,aspectRatio:w.width/w.height},P=void 0,F=$a(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&(P=Z.get(N.parentId)),P&&N.extent==="parent"&&(F=[[0,0],[P.measured.width,P.measured.height]]),D=[],W=void 0;for(const[K,V]of Z)if(V.parentId===t&&(D.push({id:K,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const Y=o4(V,N,V.origin??L);W?W=[[Math.min(Y[0][0],W[0][0]),Math.min(Y[0][1],W[0][1])],[Math.max(Y[1][0],W[1][0]),Math.max(Y[1][1],W[1][1])]]:W=Y}v==null||v(T,{...w})}).on("drag",T=>{const{transform:Z,snapGrid:E,snapToGrid:C,nodeOrigin:$}=n(),L=Dl(T.sourceEvent,{transform:Z,snapGrid:E,snapToGrid:C,containerBounds:R}),B=[];if(!N)return;const{x:H,y:G,width:K,height:V}=w,Y={},fe=N.origin??$,{width:xe,height:ge,x:ie,y:ke}=i4(A,c.controlDirection,L,c.boundaries,c.keepAspectRatio,fe,F,W),ae=xe!==K,Ne=ge!==V,Fe=ie!==H&&ae,ce=ke!==G&&Ne;if(!Fe&&!ce&&!ae&&!Ne)return;if((Fe||ce||fe[0]===1||fe[1]===1)&&(Y.x=Fe?ie:w.x,Y.y=ce?ke:w.y,w.x=Y.x,w.y=Y.y,D.length>0)){const Le=ie-H,Te=ke-G;for(const Ge of D)Ge.position={x:Ge.position.x-Le+fe[0]*(xe-K),y:Ge.position.y-Te+fe[1]*(ge-V)},B.push(Ge)}if((ae||Ne)&&(Y.width=ae&&(!c.resizeDirection||c.resizeDirection==="horizontal")?xe:w.width,Y.height=Ne&&(!c.resizeDirection||c.resizeDirection==="vertical")?ge:w.height,w.width=Y.width,w.height=Y.height),P&&N.expandParent){const Le=fe[0]*(Y.width??0);Y.x&&Y.x<Le&&(w.x=Le,A.x=A.x-(Y.x-Le));const Te=fe[1]*(Y.height??0);Y.y&&Y.y<Te&&(w.y=Te,A.y=A.y-(Y.y-Te))}const Se=r4({width:w.width,prevWidth:K,height:w.height,prevHeight:V,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),re={...w,direction:Se};(k==null?void 0:k(T,re))!==!1&&(M=!0,y==null||y(T,re),r(Y,B))}).on("end",T=>{M&&(S==null||S(T,{...w}),i==null||i({...w}),M=!1)});o.call(O)}function f(){o.on(".drag",null)}return{update:u,destroy:f}}var tp={exports:{}},np={},sp={exports:{}},rp={};/**
199
- * @license React
200
- * use-sync-external-store-shim.production.js
201
- *
202
- * Copyright (c) Meta Platforms, Inc. and affiliates.
203
- *
204
- * This source code is licensed under the MIT license found in the
205
- * LICENSE file in the root directory of this source tree.
206
- */var qy;function c4(){if(qy)return rp;qy=1;var e=rc();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(m,g){var v=g(),y=r({inst:{value:v,getSnapshot:g}}),S=y[0].inst,k=y[1];return o(function(){S.value=v,S.getSnapshot=g,f(S)&&k({inst:S})},[m,v,g]),i(function(){return f(S)&&k({inst:S}),m(function(){f(S)&&k({inst:S})})},[m]),c(v),v}function f(m){var g=m.getSnapshot;m=m.value;try{var v=g();return!n(m,v)}catch{return!0}}function d(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:u;return rp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,rp}var Gy;function u4(){return Gy||(Gy=1,sp.exports=c4()),sp.exports}/**
207
- * @license React
208
- * use-sync-external-store-shim/with-selector.production.js
209
- *
210
- * Copyright (c) Meta Platforms, Inc. and affiliates.
211
- *
212
- * This source code is licensed under the MIT license found in the
213
- * LICENSE file in the root directory of this source tree.
214
- */var Ky;function d4(){if(Ky)return np;Ky=1;var e=rc(),t=u4();function n(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,f=e.useDebugValue;return np.useSyncExternalStoreWithSelector=function(d,p,m,g,v){var y=o(null);if(y.current===null){var S={hasValue:!1,value:null};y.current=S}else S=y.current;y=u(function(){function w(P){if(!A){if(A=!0,N=P,P=g(P),v!==void 0&&S.hasValue){var F=S.value;if(v(F,P))return R=F}return R=P}if(F=R,r(N,P))return F;var W=g(P);return v!==void 0&&v(F,W)?(N=P,F):(N=P,R=W)}var A=!1,N,R,D=m===void 0?null:m;return[function(){return w(p())},D===null?void 0:function(){return w(D())}]},[p,m,g,v]);var k=i(d,y[0],y[1]);return c(function(){S.hasValue=!0,S.value=k},[k]),f(k),k},np}var Yy;function f4(){return Yy||(Yy=1,tp.exports=d4()),tp.exports}var h4=f4();const p4=gm(h4),m4={},Xy=e=>{let t;const n=new Set,r=(p,m)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const v=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(y=>y(t,v))}},i=()=>t,f={setState:r,getState:i,getInitialState:()=>d,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(m4?"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(r,i,f);return f},g4=e=>e?Xy(e):Xy,{useDebugValue:x4}=V$,{useSyncExternalStoreWithSelector:v4}=p4,y4=e=>e;function Ej(e,t=y4,n){const r=v4(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return x4(r),r}const Qy=(e,t)=>{const n=g4(e),r=(i,o=t)=>Ej(n,i,o);return Object.assign(r,n),r},b4=(e,t)=>e?Qy(e,t):Qy;function tn(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[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Ad=b.createContext(null),k4=Ad.Provider,Cj=Nr.error001("react");function Nt(e,t){const n=b.useContext(Ad);if(n===null)throw new Error(Cj);return Ej(n,e,t)}function Vt(){const e=b.useContext(Ad);if(e===null)throw new Error(Cj);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Jy={display:"none"},w4={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ij="react-flow__node-desc",Aj="react-flow__edge-desc",N4="react-flow__aria-live",j4=e=>e.ariaLiveMessage,S4=e=>e.ariaLabelConfig;function _4({rfId:e}){const t=Nt(j4);return s.jsx("div",{id:`${N4}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:w4,children:t})}function E4({rfId:e,disableKeyboardA11y:t}){const n=Nt(S4);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${Ij}-${e}`,style:Jy,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${Aj}-${e}`,style:Jy,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(_4,{rfId:e})]})}const Td=b.forwardRef(({position:e="top-left",children:t,className:n,style:r,...i},o)=>{const c=`${e}`.split("-");return s.jsx("div",{className:kn(["react-flow__panel",n,...c]),style:r,ref:o,...i,children:t})});Td.displayName="Panel";const eb="https://reactflow.dev?utm_source=attribution";function C4({proOptions:e,position:t="bottom-right"}){return b.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:s.jsx(Td,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${eb}`,children:s.jsx("a",{href:eb,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const I4=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Iu=e=>e.id;function A4(e,t){return tn(e.selectedNodes.map(Iu),t.selectedNodes.map(Iu))&&tn(e.selectedEdges.map(Iu),t.selectedEdges.map(Iu))}function T4({onSelectionChange:e}){const t=Vt(),{selectedNodes:n,selectedEdges:r}=Nt(I4,A4);return b.useEffect(()=>{const i={nodes:n,edges:r};e==null||e(i),t.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[n,r,e]),null}const $4=e=>!!e.onSelectionChangeHandlers;function M4({onSelectionChange:e}){const t=Nt($4);return e||t?s.jsx(T4,{onSelectionChange:e}):null}const Tj=[0,0],R4={x:0,y:0,zoom:1},O4=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],tb=[...O4,"rfId"],z4=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),nb={translateExtent:Kl,nodeOrigin:Tj,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function P4(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:c,reset:u,setDefaultNodesAndEdges:f}=Nt(z4,tn),d=Vt();b.useEffect(()=>(f(e.defaultNodes,e.defaultEdges),()=>{p.current=nb,u()}),[]);const p=b.useRef(nb);return b.useEffect(()=>{for(const m of tb){const g=e[m],v=p.current[m];g!==v&&(typeof e[m]>"u"||(m==="nodes"?t(g):m==="edges"?n(g):m==="minZoom"?r(g):m==="maxZoom"?i(g):m==="translateExtent"?o(g):m==="nodeExtent"?c(g):m==="ariaLabelConfig"?d.setState({ariaLabelConfig:k3(g)}):m==="fitView"?d.setState({fitViewQueued:g}):m==="fitViewOptions"?d.setState({fitViewOptions:g}):d.setState({[m]:g})))}p.current=e},tb.map(m=>e[m])),null}function sb(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function L4(e){var r;const[t,n]=b.useState(e==="system"?null:e);return b.useEffect(()=>{if(e!=="system"){n(e);return}const i=sb(),o=()=>n(i!=null&&i.matches?"dark":"light");return o(),i==null||i.addEventListener("change",o),()=>{i==null||i.removeEventListener("change",o)}},[e]),t!==null?t:(r=sb())!=null&&r.matches?"dark":"light"}const rb=typeof document<"u"?document:null;function Jl(e=null,t={target:rb,actInsideInputWithModifier:!0}){const[n,r]=b.useState(!1),i=b.useRef(!1),o=b.useRef(new Set([])),[c,u]=b.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.replace(/\+/g,`
215
- `).replace(`
216
-
217
- `,`
218
- +`).split(`
219
- `)),p=d.reduce((m,g)=>m.concat(...g),[]);return[d,p]}return[[],[]]},[e]);return b.useEffect(()=>{const f=(t==null?void 0:t.target)??rb,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=v=>{var k,w;if(i.current=v.ctrlKey||v.metaKey||v.shiftKey||v.altKey,(!i.current||i.current&&!d)&&uj(v))return!1;const S=ab(v.code,u);if(o.current.add(v[S]),ib(c,o.current,!1)){const A=((w=(k=v.composedPath)==null?void 0:k.call(v))==null?void 0:w[0])||v.target,N=(A==null?void 0:A.nodeName)==="BUTTON"||(A==null?void 0:A.nodeName)==="A";t.preventDefault!==!1&&(i.current||!N)&&v.preventDefault(),r(!0)}},m=v=>{const y=ab(v.code,u);ib(c,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(v[y]),v.key==="Meta"&&o.current.clear(),i.current=!1},g=()=>{o.current.clear(),r(!1)};return f==null||f.addEventListener("keydown",p),f==null||f.addEventListener("keyup",m),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{f==null||f.removeEventListener("keydown",p),f==null||f.removeEventListener("keyup",m),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function ib(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function ab(e,t){return t.includes(e)?"code":"key"}const D4=()=>{const e=Vt();return b.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:c,panZoom:u}=e.getState(),f=ng(t,r,i,o,c,(n==null?void 0:n.padding)??.1);return u?(await u.setViewport(f,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:c}=e.getState();if(!c)return t;const{x:u,y:f}=c.getBoundingClientRect(),d={x:t.x-u,y:t.y-f},p=n.snapGrid??i,m=n.snapToGrid??o;return pc(d,r,m,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),c=zo(t,n);return{x:c.x+i,y:c.y+o}}}),[])};function $j(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const c=r.get(o.id);c?c.push(o):r.set(o.id,[o])}for(const o of t){const c=r.get(o.id);if(!c){n.push(o);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){n.push({...c[0].item});continue}const u={...o};for(const f of c)F4(f,u);n.push(u)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function F4(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function B4(e,t){return $j(e,t)}function U4(e,t){return $j(e,t)}function ma(e,t){return{id:e,type:"select",selected:t}}function mo(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const c=t.has(i);!(o.selected===void 0&&!c)&&o.selected!==c&&(n&&(o.selected=c),r.push(ma(o.id,c)))}return r}function ob({items:e=[],lookup:t}){var i;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const u=t.get(c.id),f=((i=u==null?void 0:u.internals)==null?void 0:i.userNode)??u;f!==void 0&&f!==c&&n.push({id:c.id,item:c,type:"replace"}),f===void 0&&n.push({item:c,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function lb(e){return{id:e.id,type:"remove"}}const H4=ij();function Z4(e,t,n={}){return E3(e,t,{...n,onError:n.onError??H4})}const cb=e=>f3(e),W4=e=>ej(e);function Mj(e){return b.forwardRef(e)}const Rj=typeof window<"u"?b.useLayoutEffect:b.useEffect;function ub(e){const[t,n]=b.useState(BigInt(0)),[r]=b.useState(()=>V4(()=>n(i=>i+BigInt(1))));return Rj(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function V4(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Oj=b.createContext(null);function q4({children:e}){const t=Vt(),n=b.useCallback(u=>{const{nodes:f=[],setNodes:d,hasDefaultNodes:p,onNodesChange:m,nodeLookup:g,fitViewQueued:v,onNodesChangeMiddlewareMap:y}=t.getState();let S=f;for(const w of u)S=typeof w=="function"?w(S):w;let k=ob({items:S,lookup:g});for(const w of y.values())k=w(k);p&&d(S),k.length>0?m==null||m(k):v&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:A,setNodes:N}=t.getState();w&&N(A)})},[]),r=ub(n),i=b.useCallback(u=>{const{edges:f=[],setEdges:d,hasDefaultEdges:p,onEdgesChange:m,edgeLookup:g}=t.getState();let v=f;for(const y of u)v=typeof y=="function"?y(v):y;p?d(v):m&&m(ob({items:v,lookup:g}))},[]),o=ub(i),c=b.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return s.jsx(Oj.Provider,{value:c,children:e})}function G4(){const e=b.useContext(Oj);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const K4=e=>!!e.panZoom;function cg(){const e=D4(),t=Vt(),n=G4(),r=Nt(K4),i=b.useMemo(()=>{const o=m=>t.getState().nodeLookup.get(m),c=m=>{n.nodeQueue.push(m)},u=m=>{n.edgeQueue.push(m)},f=m=>{var w,A;const{nodeLookup:g,nodeOrigin:v}=t.getState(),y=cb(m)?m:g.get(m.id),S=y.parentId?oj(y.position,y.measured,y.parentId,g,v):y.position,k={...y,position:S,width:((w=y.measured)==null?void 0:w.width)??y.width,height:((A=y.measured)==null?void 0:A.height)??y.height};return Xl(k)},d=(m,g,v={replace:!1})=>{c(y=>y.map(S=>{if(S.id===m){const k=typeof g=="function"?g(S):g;return v.replace&&cb(k)?k:{...S,...k}}return S}))},p=(m,g,v={replace:!1})=>{u(y=>y.map(S=>{if(S.id===m){const k=typeof g=="function"?g(S):g;return v.replace&&W4(k)?k:{...S,...k}}return S}))};return{getNodes:()=>t.getState().nodes.map(m=>({...m})),getNode:m=>{var g;return(g=o(m))==null?void 0:g.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:m=[]}=t.getState();return m.map(g=>({...g}))},getEdge:m=>t.getState().edgeLookup.get(m),setNodes:c,setEdges:u,addNodes:m=>{const g=Array.isArray(m)?m:[m];n.nodeQueue.push(v=>[...v,...g])},addEdges:m=>{const g=Array.isArray(m)?m:[m];n.edgeQueue.push(v=>[...v,...g])},toObject:()=>{const{nodes:m=[],edges:g=[],transform:v}=t.getState(),[y,S,k]=v;return{nodes:m.map(w=>({...w})),edges:g.map(w=>({...w})),viewport:{x:y,y:S,zoom:k}}},deleteElements:async({nodes:m=[],edges:g=[]})=>{const{nodes:v,edges:y,onNodesDelete:S,onEdgesDelete:k,triggerNodeChanges:w,triggerEdgeChanges:A,onDelete:N,onBeforeDelete:R}=t.getState(),{nodes:D,edges:P}=await x3({nodesToRemove:m,edgesToRemove:g,nodes:v,edges:y,onBeforeDelete:R}),F=P.length>0,W=D.length>0;if(F){const M=P.map(lb);k==null||k(P),A(M)}if(W){const M=D.map(lb);S==null||S(D),w(M)}return(W||F)&&(N==null||N({nodes:D,edges:P})),{deletedNodes:D,deletedEdges:P}},getIntersectingNodes:(m,g=!0,v)=>{const y=Ry(m),S=y?m:f(m),k=v!==void 0;return S?(v||t.getState().nodes).filter(w=>{const A=t.getState().nodeLookup.get(w.id);if(A&&!y&&(w.id===m.id||!A.internals.positionAbsolute))return!1;const N=Xl(k?w:A),R=od(N,S);return g&&R>0||R>=N.width*N.height||R>=S.width*S.height}):[]},isNodeIntersecting:(m,g,v=!0)=>{const S=Ry(m)?m:f(m);if(!S)return!1;const k=od(S,g);return v&&k>0||k>=g.width*g.height||k>=S.width*S.height},updateNode:d,updateNodeData:(m,g,v={replace:!1})=>{d(m,y=>{const S=typeof g=="function"?g(y):g;return v.replace?{...y,data:S}:{...y,data:{...y.data,...S}}},v)},updateEdge:p,updateEdgeData:(m,g,v={replace:!1})=>{p(m,y=>{const S=typeof g=="function"?g(y):g;return v.replace?{...y,data:S}:{...y,data:{...y.data,...S}}},v)},getNodesBounds:m=>{const{nodeLookup:g,nodeOrigin:v}=t.getState();return h3(m,{nodeLookup:g,nodeOrigin:v})},getHandleConnections:({type:m,id:g,nodeId:v})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${v}-${m}${g?`-${g}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:m,handleId:g,nodeId:v})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${v}${m?g?`-${m}-${g}`:`-${m}`:""}`))==null?void 0:y.values())??[])},fitView:async m=>{const g=t.getState().fitViewResolver??b3();return t.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:g}),n.nodeQueue.push(v=>[...v]),g.promise}}},[]);return b.useMemo(()=>({...i,...e,viewportInitialized:r}),[r])}const db=e=>e.selected,Y4=typeof window<"u"?window:void 0;function X4({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Vt(),{deleteElements:r}=cg(),i=Jl(e,{actInsideInputWithModifier:!1}),o=Jl(t,{target:Y4});b.useEffect(()=>{if(i){const{edges:c,nodes:u}=n.getState();r({nodes:u.filter(db),edges:c.filter(db)}),n.setState({nodesSelectionActive:!1})}},[i]),b.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function Q4(e){const t=Vt();b.useEffect(()=>{const n=()=>{var i,o,c,u;if(!e.current||!(((o=(i=e.current).checkVisibility)==null?void 0:o.call(i))??!0))return!1;const r=sg(e.current);(r.height===0||r.width===0)&&((u=(c=t.getState()).onError)==null||u.call(c,"004",Nr.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const $d={position:"absolute",width:"100%",height:"100%",top:0,left:0},J4=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function eF({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:o=.5,panOnScrollMode:c=Sa.Free,zoomOnDoubleClick:u=!0,panOnDrag:f=!0,defaultViewport:d,translateExtent:p,minZoom:m,maxZoom:g,zoomActivationKeyCode:v,preventScrolling:y=!0,children:S,noWheelClassName:k,noPanClassName:w,onViewportChange:A,isControlledViewport:N,paneClickDistance:R,selectionOnDrag:D}){const P=Vt(),F=b.useRef(null),{userSelectionActive:W,lib:M,connectionInProgress:O}=Nt(J4,tn),T=Jl(v),Z=b.useRef();Q4(F);const E=b.useCallback(C=>{A==null||A({x:C[0],y:C[1],zoom:C[2]}),N||P.setState({transform:C})},[A,N]);return b.useEffect(()=>{if(F.current){Z.current=s4({domNode:F.current,minZoom:m,maxZoom:g,translateExtent:p,viewport:d,onDraggingChange:B=>P.setState(H=>H.paneDragging===B?H:{paneDragging:B}),onPanZoomStart:(B,H)=>{const{onViewportChangeStart:G,onMoveStart:K}=P.getState();K==null||K(B,H),G==null||G(H)},onPanZoom:(B,H)=>{const{onViewportChange:G,onMove:K}=P.getState();K==null||K(B,H),G==null||G(H)},onPanZoomEnd:(B,H)=>{const{onViewportChangeEnd:G,onMoveEnd:K}=P.getState();K==null||K(B,H),G==null||G(H)}});const{x:C,y:$,zoom:L}=Z.current.getViewport();return P.setState({panZoom:Z.current,transform:[C,$,L],domNode:F.current.closest(".react-flow")}),()=>{var B;(B=Z.current)==null||B.destroy()}}},[]),b.useEffect(()=>{var C;(C=Z.current)==null||C.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:o,panOnScrollMode:c,zoomOnDoubleClick:u,panOnDrag:f,zoomActivationKeyPressed:T,preventScrolling:y,noPanClassName:w,userSelectionActive:W,noWheelClassName:k,lib:M,onTransformChange:E,connectionInProgress:O,selectionOnDrag:D,paneClickDistance:R})},[e,t,n,r,i,o,c,u,f,T,y,w,W,k,M,E,O,D,R]),s.jsx("div",{className:"react-flow__renderer",ref:F,style:$d,children:S})}const tF=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function nF(){const{userSelectionActive:e,userSelectionRect:t}=Nt(tF,tn);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const ip=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},sF=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function rF({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Yl.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:o,selectionOnDrag:c,onSelectionStart:u,onSelectionEnd:f,onPaneClick:d,onPaneContextMenu:p,onPaneScroll:m,onPaneMouseEnter:g,onPaneMouseMove:v,onPaneMouseLeave:y,children:S}){const k=b.useRef(0),w=Vt(),{userSelectionActive:A,elementsSelectable:N,dragging:R,panBy:D,autoPanSpeed:P}=Nt(sF,tn),F=N&&(e||A),W=b.useRef(null),M=b.useRef(),O=b.useRef(new Set),T=b.useRef(new Set),Z=b.useRef(!1),E=b.useRef(!1),C=b.useRef({x:0,y:0}),$=b.useRef(!1),L=ae=>{if(E.current||Z.current||w.getState().connection.inProgress){E.current=!1,Z.current=!1;return}d==null||d(ae),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},B=ae=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){ae.preventDefault();return}p==null||p(ae)},H=m?ae=>m(ae):void 0,G=ae=>{E.current&&(ae.stopPropagation(),E.current=!1)},K=ae=>{var Ge,Ie;if(ae.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:Ne,transform:Fe}=w.getState();if(M.current=Ne==null?void 0:Ne.getBoundingClientRect(),!M.current)return;const ce=ae.target===W.current;if(!ce&&!!ae.target.closest(".nokey")||!e||!(c&&ce||t)||ae.button!==0||!ae.isPrimary)return;(Ie=(Ge=ae.target)==null?void 0:Ge.setPointerCapture)==null||Ie.call(Ge,ae.pointerId),E.current=!1;const{x:he,y:Le}=yr(ae.nativeEvent,M.current),Te=pc({x:he,y:Le},Fe);w.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:he,y:Le}}),ce||(ae.stopPropagation(),ae.preventDefault())};function V(ae,Ne){const{userSelectionRect:Fe}=w.getState();if(!Fe)return;const{transform:ce,nodeLookup:Se,edgeLookup:re,connectionLookup:he,triggerNodeChanges:Le,triggerEdgeChanges:Te,defaultEdgeOptions:Ge}=w.getState(),Ie={x:Fe.startX,y:Fe.startY},{x:tt,y:et}=zo(Ie,ce),jt={startX:Ie.x,startY:Ie.y,x:ae<tt?ae:tt,y:Ne<et?Ne:et,width:Math.abs(ae-tt),height:Math.abs(Ne-et)},On=O.current,sn=T.current;O.current=new Set(eg(Se,jt,ce,n===Yl.Partial,!0).map(cn=>cn.id)),T.current=new Set;const ln=(Ge==null?void 0:Ge.selectable)??!0;for(const cn of O.current){const rn=he.get(cn);if(rn)for(const{edgeId:an}of rn.values()){const Ft=re.get(an);Ft&&(Ft.selectable??ln)&&T.current.add(an)}}if(!Oy(On,O.current)){const cn=mo(Se,O.current,!0);Le(cn)}if(!Oy(sn,T.current)){const cn=mo(re,T.current);Te(cn)}w.setState({userSelectionRect:jt,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!i||!M.current)return;const[ae,Ne]=tg(C.current,M.current,P);D({x:ae,y:Ne}).then(Fe=>{if(!E.current||!Fe){k.current=requestAnimationFrame(Y);return}const{x:ce,y:Se}=C.current;V(ce,Se),k.current=requestAnimationFrame(Y)})}const fe=()=>{cancelAnimationFrame(k.current),k.current=0,$.current=!1};b.useEffect(()=>()=>fe(),[]);const xe=ae=>{const{userSelectionRect:Ne,transform:Fe,resetSelectedElements:ce}=w.getState();if(!M.current||!Ne)return;const{x:Se,y:re}=yr(ae.nativeEvent,M.current);C.current={x:Se,y:re};const he=zo({x:Ne.startX,y:Ne.startY},Fe);if(!E.current){const Le=t?0:o;if(Math.hypot(Se-he.x,re-he.y)<=Le)return;ce(),u==null||u(ae)}E.current=!0,$.current||(Y(),$.current=!0),V(Se,re)},ge=ae=>{var Ne,Fe;if(!F){ae.target===W.current&&w.getState().connection.inProgress&&(Z.current=!0);return}ae.button===0&&((Fe=(Ne=ae.target)==null?void 0:Ne.releasePointerCapture)==null||Fe.call(Ne,ae.pointerId),!A&&ae.target===W.current&&w.getState().userSelectionRect&&(L==null||L(ae)),w.setState({userSelectionActive:!1,userSelectionRect:null}),E.current&&(f==null||f(ae),w.setState({nodesSelectionActive:O.current.size>0})),fe())},ie=ae=>{var Ne,Fe;(Fe=(Ne=ae.target)==null?void 0:Ne.releasePointerCapture)==null||Fe.call(Ne,ae.pointerId),fe()},ke=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:kn(["react-flow__pane",{draggable:ke,dragging:R,selection:e}]),onClick:F?void 0:ip(L,W),onContextMenu:ip(B,W),onWheel:ip(H,W),onPointerEnter:F?void 0:g,onPointerMove:F?xe:v,onPointerUp:ge,onPointerCancel:F?ie:void 0,onPointerDownCapture:F?K:void 0,onClickCapture:F?G:void 0,onPointerLeave:y,ref:W,style:$d,children:[S,s.jsx(nF,{})]})}function cm({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:c,nodeLookup:u,onError:f}=t.getState(),d=u.get(e);if(!d){f==null||f("012",Nr.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&c)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):i([e])}function zj({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,nodeClickDistance:c}){const u=Vt(),[f,d]=b.useState(!1),p=b.useRef();return b.useEffect(()=>{if(!t)return p.current=H3({getStoreItems:()=>u.getState(),onNodeMouseDown:m=>{cm({id:m,store:u,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{var m;(m=p.current)==null||m.destroy(),p.current=void 0}},[t,u,e]),b.useEffect(()=>{t||!e.current||!p.current||p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:i,nodeClickDistance:c})},[n,r,t,o,e,i,c]),f}const iF=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Pj(){const e=Vt();return b.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:o,nodesDraggable:c,onError:u,updateNodePositions:f,nodeLookup:d,nodeOrigin:p}=e.getState(),m=new Map,g=iF(c),v=i?o[0]:5,y=i?o[1]:5,S=n.direction.x*v*n.factor,k=n.direction.y*y*n.factor;for(const[,w]of d){if(!g(w))continue;let A={x:w.internals.positionAbsolute.x+S,y:w.internals.positionAbsolute.y+k};i&&(A=hc(A,o));const{position:N,positionAbsolute:R}=tj({nodeId:w.id,nextPosition:A,nodeLookup:d,nodeExtent:r,nodeOrigin:p,onError:u});w.position=N,w.internals.positionAbsolute=R,m.set(w.id,w)}f(m)},[])}const ug=b.createContext(null),aF=ug.Provider;ug.Consumer;const Lj=()=>b.useContext(ug),oF=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Dj=b.createContext(null);function lF({children:e}){const t=Nt(oF,tn);return s.jsx(Dj.Provider,{value:t,children:e})}function cF(){const e=b.useContext(Dj);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const uF={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},dF=(e,t,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:o,connection:c}=r,{fromHandle:u,toHandle:f,isValid:d}=c;if(!u&&!i)return uF;const p=(f==null?void 0:f.nodeId)===e&&(f==null?void 0:f.id)===t&&(f==null?void 0:f.type)===n;return{connectingFrom:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n,connectingTo:p,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.id)===t&&(i==null?void 0:i.type)===n,isPossibleEndHandle:o===Ro.Strict?(u==null?void 0:u.type)!==n:e!==(u==null?void 0:u.nodeId)||t!==(u==null?void 0:u.id),connectionInProcess:!!u,clickConnectionInProcess:!!i,valid:p&&d}};function fF({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:c,onConnect:u,children:f,className:d,onMouseDown:p,onTouchStart:m,...g},v){var $,L;const y=c||null,S=e==="target",k=Vt(),w=Lj(),{connectOnClick:A,noPanClassName:N,rfId:R}=cF(),{connectingFrom:D,connectingTo:P,clickConnecting:F,isPossibleEndHandle:W,connectionInProcess:M,clickConnectionInProcess:O,valid:T}=Nt(dF(w,y,e),tn);w||(L=($=k.getState()).onError)==null||L.call($,"010",Nr.error010());const Z=B=>{const{defaultEdgeOptions:H,onConnect:G,hasDefaultEdges:K}=k.getState(),V={...H,...B};if(K){const{edges:Y,setEdges:fe,onError:xe}=k.getState();fe(Z4(V,Y,{onError:xe}))}G==null||G(V),u==null||u(V)},E=B=>{if(!w)return;const H=dj(B.nativeEvent);if(i&&(H&&B.button===0||!H)){const G=k.getState();lm.onPointerDown(B.nativeEvent,{handleDomNode:B.currentTarget,autoPanOnConnect:G.autoPanOnConnect,connectionMode:G.connectionMode,connectionRadius:G.connectionRadius,domNode:G.domNode,nodeLookup:G.nodeLookup,lib:G.lib,isTarget:S,handleId:y,nodeId:w,flowId:G.rfId,panBy:G.panBy,cancelConnection:G.cancelConnection,onConnectStart:G.onConnectStart,onConnectEnd:(...K)=>{var V,Y;return(Y=(V=k.getState()).onConnectEnd)==null?void 0:Y.call(V,...K)},updateConnection:G.updateConnection,onConnect:Z,isValidConnection:n||((...K)=>{var V,Y;return((Y=(V=k.getState()).isValidConnection)==null?void 0:Y.call(V,...K))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:G.autoPanSpeed,dragThreshold:G.connectionDragThreshold})}H?p==null||p(B):m==null||m(B)},C=B=>{const{onClickConnectStart:H,onClickConnectEnd:G,connectionClickStartHandle:K,connectionMode:V,isValidConnection:Y,lib:fe,rfId:xe,nodeLookup:ge,connection:ie}=k.getState();if(!w||!K&&!i)return;if(!K){H==null||H(B.nativeEvent,{nodeId:w,handleId:y,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:w,type:e,id:y}});return}const ke=cj(B.target),ae=n||Y,{connection:Ne,isValid:Fe}=lm.isValid(B.nativeEvent,{handle:{nodeId:w,id:y,type:e},connectionMode:V,fromNodeId:K.nodeId,fromHandleId:K.id||null,fromType:K.type,isValidConnection:ae,flowId:xe,doc:ke,lib:fe,nodeLookup:ge});Fe&&Ne&&Z(Ne);const ce=structuredClone(ie);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,G==null||G(B,ce),k.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":t,"data-id":`${R}-${w}-${y}-${e}`,className:kn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,d,{source:!S,target:S,connectable:r,connectablestart:i,connectableend:o,clickconnecting:F,connectingfrom:D,connectingto:P,valid:T,connectionindicator:r&&(!M||W)&&(M||O?o:i)}]),onMouseDown:E,onTouchStart:E,onClick:A?C:void 0,ref:v,...g,children:f})}const Hi=b.memo(Mj(fF));function hF({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(Hi,{type:"source",position:n,isConnectable:t})]})}function pF({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:r=Je.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(Hi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(Hi,{type:"source",position:r,isConnectable:t})]})}function mF(){return null}function gF({data:e,isConnectable:t,targetPosition:n=Je.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(Hi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const ld={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},fb={input:hF,default:pF,output:gF,group:mF};function xF(e){var t,n,r,i;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((i=e.style)==null?void 0:i.height)}}const vF=e=>{const{width:t,height:n,x:r,y:i}=fc(e.nodeLookup,{filter:o=>!!o.selected});return{width:vr(t)?t:null,height:vr(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function yF({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Vt(),{width:i,height:o,transformString:c,userSelectionActive:u}=Nt(vF,tn),f=Pj(),d=b.useRef(null);b.useEffect(()=>{var v;n||(v=d.current)==null||v.focus({preventScroll:!0})},[n]);const p=!u&&i!==null&&o!==null;if(zj({nodeRef:d,disabled:!p}),!p)return null;const m=e?v=>{const y=r.getState().nodes.filter(S=>S.selected);e(v,y)}:void 0,g=v=>{Object.prototype.hasOwnProperty.call(ld,v.key)&&(v.preventDefault(),f({direction:ld[v.key],factor:v.shiftKey?4:1}))};return s.jsx("div",{className:kn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:s.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:i,height:o}})})}const hb=typeof window<"u"?window:void 0,bF=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Fj({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:u,deleteKeyCode:f,selectionKeyCode:d,selectionOnDrag:p,selectionMode:m,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:y,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:w,zoomOnScroll:A,zoomOnPinch:N,panOnScroll:R,panOnScrollSpeed:D,panOnScrollMode:P,zoomOnDoubleClick:F,panOnDrag:W,autoPanOnSelection:M,defaultViewport:O,translateExtent:T,minZoom:Z,maxZoom:E,preventScrolling:C,onSelectionContextMenu:$,noWheelClassName:L,noPanClassName:B,disableKeyboardA11y:H,onViewportChange:G,isControlledViewport:K}){const{nodesSelectionActive:V,userSelectionActive:Y}=Nt(bF,tn),fe=Jl(d,{target:hb}),xe=Jl(S,{target:hb}),ge=xe||W,ie=xe||R,ke=p&&ge!==!0,ae=fe||Y||ke;return X4({deleteKeyCode:f,multiSelectionKeyCode:y}),s.jsx(eF,{onPaneContextMenu:o,elementsSelectable:w,zoomOnScroll:A,zoomOnPinch:N,panOnScroll:ie,panActivationKeyPressed:xe,panOnScrollSpeed:D,panOnScrollMode:P,zoomOnDoubleClick:F,panOnDrag:!fe&&ge,defaultViewport:O,translateExtent:T,minZoom:Z,maxZoom:E,zoomActivationKeyCode:k,preventScrolling:C,noWheelClassName:L,noPanClassName:B,onViewportChange:G,isControlledViewport:K,paneClickDistance:u,selectionOnDrag:ke,children:s.jsxs(rF,{onSelectionStart:g,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:ge,autoPanOnSelection:M,isSelecting:!!ae,selectionMode:m,selectionKeyPressed:fe,paneClickDistance:u,selectionOnDrag:ke,children:[e,V&&s.jsx(yF,{onSelectionContextMenu:$,noPanClassName:B,disableKeyboardA11y:H})]})})}Fj.displayName="FlowRenderer";const kF=b.memo(Fj),wF=e=>t=>e?eg(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function NF(e){return Nt(b.useCallback(wF(e),[e]),tn)}const jF=e=>e.updateNodeInternals;function SF(){const e=Nt(jF),[t]=b.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(i=>{const o=i.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:i.target,force:!0})}),e(r)}));return b.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function _F({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const i=Vt(),o=b.useRef(null),c=b.useRef(null),u=b.useRef(e.sourcePosition),f=b.useRef(e.targetPosition),d=b.useRef(t),p=n&&!!e.internals.handleBounds;return b.useEffect(()=>{o.current&&!e.hidden&&(!p||c.current!==o.current)&&(c.current&&(r==null||r.unobserve(c.current)),r==null||r.observe(o.current),c.current=o.current)},[p,e.hidden]),b.useEffect(()=>()=>{c.current&&(r==null||r.unobserve(c.current),c.current=null)},[]),b.useEffect(()=>{if(o.current){const m=d.current!==t,g=u.current!==e.sourcePosition,v=f.current!==e.targetPosition;(m||g||v)&&(d.current=t,u.current=e.sourcePosition,f.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function EF({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:o,onDoubleClick:c,nodesDraggable:u,elementsSelectable:f,nodesConnectable:d,nodesFocusable:p,resizeObserver:m,noDragClassName:g,noPanClassName:v,disableKeyboardA11y:y,rfId:S,nodeTypes:k,nodeClickDistance:w,onError:A}){const{node:N,internals:R,isParent:D}=Nt(ae=>{const Ne=ae.nodeLookup.get(e),Fe=ae.parentLookup.has(e);return{node:Ne,internals:Ne.internals,isParent:Fe}},tn);let P=N.type||"default",F=(k==null?void 0:k[P])||fb[P];F===void 0&&(A==null||A("003",Nr.error003(P)),P="default",F=(k==null?void 0:k.default)||fb.default);const W=!!(N.draggable||u&&typeof N.draggable>"u"),M=!!(N.selectable||f&&typeof N.selectable>"u"),O=!!(N.connectable||d&&typeof N.connectable>"u"),T=!!(N.focusable||p&&typeof N.focusable>"u"),Z=Vt(),E=aj(N),C=_F({node:N,nodeType:P,hasDimensions:E,resizeObserver:m}),$=zj({nodeRef:C,disabled:N.hidden||!W,noDragClassName:g,handleSelector:N.dragHandle,nodeId:e,isSelectable:M,nodeClickDistance:w}),L=Pj();if(N.hidden)return null;const B=Sr(N),H=xF(N),G=M||W||t||n||r||i,K=n?ae=>n(ae,{...R.userNode}):void 0,V=r?ae=>r(ae,{...R.userNode}):void 0,Y=i?ae=>i(ae,{...R.userNode}):void 0,fe=o?ae=>o(ae,{...R.userNode}):void 0,xe=c?ae=>c(ae,{...R.userNode}):void 0,ge=ae=>{const{selectNodesOnDrag:Ne,nodeDragThreshold:Fe}=Z.getState();M&&(!Ne||!W||Fe>0)&&cm({id:e,store:Z,nodeRef:C}),t&&t(ae,{...R.userNode})},ie=ae=>{if(!(uj(ae.nativeEvent)||y)){if(XN.includes(ae.key)&&M){const Ne=ae.key==="Escape";cm({id:e,store:Z,unselect:Ne,nodeRef:C})}else if(W&&N.selected&&Object.prototype.hasOwnProperty.call(ld,ae.key)){ae.preventDefault();const{ariaLabelConfig:Ne}=Z.getState();Z.setState({ariaLiveMessage:Ne["node.a11yDescription.ariaLiveMessage"]({direction:ae.key.replace("Arrow","").toLowerCase(),x:~~R.positionAbsolute.x,y:~~R.positionAbsolute.y})}),L({direction:ld[ae.key],factor:ae.shiftKey?4:1})}}},ke=()=>{var he;if(y||!((he=C.current)!=null&&he.matches(":focus-visible")))return;const{transform:ae,width:Ne,height:Fe,autoPanOnNodeFocus:ce,setCenter:Se}=Z.getState();if(!ce)return;eg(new Map([[e,N]]),{x:0,y:0,width:Ne,height:Fe},ae,!0).length>0||Se(N.position.x+B.width/2,N.position.y+B.height/2,{zoom:ae[2]})};return s.jsx("div",{className:kn(["react-flow__node",`react-flow__node-${P}`,{[v]:W},N.className,{selected:N.selected,selectable:M,parent:D,draggable:W,dragging:$}]),ref:C,style:{zIndex:R.z,transform:`translate(${R.positionAbsolute.x}px,${R.positionAbsolute.y}px)`,pointerEvents:G?"all":"none",visibility:E?"visible":"hidden",...N.style,...H},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:K,onMouseMove:V,onMouseLeave:Y,onContextMenu:fe,onClick:ge,onDoubleClick:xe,onKeyDown:T?ie:void 0,tabIndex:T?0:void 0,onFocus:T?ke:void 0,role:N.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${Ij}-${S}`,"aria-label":N.ariaLabel,...N.domAttributes,children:s.jsx(aF,{value:e,children:s.jsx(F,{id:e,data:N.data,type:P,positionAbsoluteX:R.positionAbsolute.x,positionAbsoluteY:R.positionAbsolute.y,selected:N.selected??!1,selectable:M,draggable:W,deletable:N.deletable??!0,isConnectable:O,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:$,dragHandle:N.dragHandle,zIndex:R.z,parentId:N.parentId,...B})})})}var CF=b.memo(EF);const IF=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Bj(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=Nt(IF,tn),o=NF(e.onlyRenderVisibleElements),c=SF();return s.jsx("div",{className:"react-flow__nodes",style:$d,children:o.map(u=>s.jsx(CF,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}Bj.displayName="NodeRenderer";const AF=b.memo(Bj);function TF(e){return Nt(b.useCallback(n=>{if(!e)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const o=n.nodeLookup.get(i.source),c=n.nodeLookup.get(i.target);o&&c&&j3({sourceNode:o,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),tn)}const $F=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},MF=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},pb={[id.Arrow]:$F,[id.ArrowClosed]:MF};function RF(e){const t=Vt();return b.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(pb,e)?pb[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",Nr.error009(e)),null)},[e])}const OF=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const f=RF(t);return f?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0",children:s.jsx(f,{color:n,strokeWidth:c})}):null},Uj=({defaultColor:e,rfId:t})=>{const n=Nt(o=>o.edges),r=Nt(o=>o.defaultEdgeOptions),i=b.useMemo(()=>$3(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return i.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:i.map(o=>s.jsx(OF,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};Uj.displayName="MarkerDefinitions";var zF=b.memo(Uj);function Hj({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:o,labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:f,className:d,...p}){const[m,g]=b.useState({x:1,y:0,width:0,height:0}),v=kn(["react-flow__edge-textwrapper",d]),y=b.useRef(null);return b.useEffect(()=>{if(y.current){const S=y.current.getBBox();g({x:S.x,y:S.y,width:S.width,height:S.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:v,visibility:m.width?"visible":"hidden",...p,children:[i&&s.jsx("rect",{width:m.width+2*c[0],x:-c[0],y:-c[1],height:m.height+2*c[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),s.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:y,style:r,children:n}),f]}):null}Hj.displayName="EdgeText";const PF=b.memo(Hj);function Md({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,interactionWidth:d=20,...p}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...p,d:e,fill:"none",className:kn(["react-flow__edge-path",p.className])}),d?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&vr(t)&&vr(n)?s.jsx(PF,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f}):null]})}function mb({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Je.Left||e===Je.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function Zj({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:i,targetPosition:o=Je.Top}){const[c,u]=mb({pos:n,x1:e,y1:t,x2:r,y2:i}),[f,d]=mb({pos:o,x1:r,y1:i,x2:e,y2:t}),[p,m,g,v]=fj({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:c,sourceControlY:u,targetControlX:f,targetControlY:d});return[`M${e},${t} C${c},${u} ${f},${d} ${r},${i}`,p,m,g,v]}function Wj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:c,targetPosition:u,label:f,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,interactionWidth:w})=>{const[A,N,R]=Zj({sourceX:n,sourceY:r,sourcePosition:c,targetX:i,targetY:o,targetPosition:u}),D=e.isInternal?void 0:t;return s.jsx(Md,{id:D,path:A,labelX:N,labelY:R,label:f,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,interactionWidth:w})})}const LF=Wj({isInternal:!1}),Vj=Wj({isInternal:!0});LF.displayName="SimpleBezierEdge";Vj.displayName="SimpleBezierEdgeInternal";function qj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,sourcePosition:v=Je.Bottom,targetPosition:y=Je.Top,markerEnd:S,markerStart:k,pathOptions:w,interactionWidth:A})=>{const[N,R,D]=im({sourceX:n,sourceY:r,sourcePosition:v,targetX:i,targetY:o,targetPosition:y,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),P=e.isInternal?void 0:t;return s.jsx(Md,{id:P,path:N,labelX:R,labelY:D,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:S,markerStart:k,interactionWidth:A})})}const Gj=qj({isInternal:!1}),Kj=qj({isInternal:!0});Gj.displayName="SmoothStepEdge";Kj.displayName="SmoothStepEdgeInternal";function Yj(e){return b.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(Gj,{...n,id:r,pathOptions:b.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const DF=Yj({isInternal:!1}),Xj=Yj({isInternal:!0});DF.displayName="StepEdge";Xj.displayName="StepEdgeInternal";function Qj(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:v,markerStart:y,interactionWidth:S})=>{const[k,w,A]=mj({sourceX:n,sourceY:r,targetX:i,targetY:o}),N=e.isInternal?void 0:t;return s.jsx(Md,{id:N,path:k,labelX:w,labelY:A,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:v,markerStart:y,interactionWidth:S})})}const FF=Qj({isInternal:!1}),Jj=Qj({isInternal:!0});FF.displayName="StraightEdge";Jj.displayName="StraightEdgeInternal";function eS(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:c=Je.Bottom,targetPosition:u=Je.Top,label:f,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,pathOptions:w,interactionWidth:A})=>{const[N,R,D]=hj({sourceX:n,sourceY:r,sourcePosition:c,targetX:i,targetY:o,targetPosition:u,curvature:w==null?void 0:w.curvature}),P=e.isInternal?void 0:t;return s.jsx(Md,{id:P,path:N,labelX:R,labelY:D,label:f,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:v,style:y,markerEnd:S,markerStart:k,interactionWidth:A})})}const BF=eS({isInternal:!1}),tS=eS({isInternal:!0});BF.displayName="BezierEdge";tS.displayName="BezierEdgeInternal";const gb={default:tS,straight:Jj,step:Xj,smoothstep:Kj,simplebezier:Vj},xb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},UF=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,HF=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,vb="react-flow__edgeupdater";function yb({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:c,type:u}){return s.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:c,className:kn([vb,`${vb}-${u}`]),cx:UF(t,r,e),cy:HF(n,r,e),r,stroke:"transparent",fill:"transparent"})}function ZF({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:o,targetY:c,sourcePosition:u,targetPosition:f,onReconnect:d,onReconnectStart:p,onReconnectEnd:m,setReconnecting:g,setUpdateHover:v}){const y=Vt(),S=(R,D)=>{if(R.button!==0)return;const{autoPanOnConnect:P,domNode:F,connectionMode:W,connectionRadius:M,lib:O,onConnectStart:T,cancelConnection:Z,nodeLookup:E,rfId:C,panBy:$,updateConnection:L}=y.getState(),B=D.type==="target",H=(V,Y)=>{g(!1),m==null||m(V,n,D.type,Y)},G=V=>d==null?void 0:d(n,V),K=(V,Y)=>{g(!0),p==null||p(R,n,D.type),T==null||T(V,Y)};lm.onPointerDown(R.nativeEvent,{autoPanOnConnect:P,connectionMode:W,connectionRadius:M,domNode:F,handleId:D.id,nodeId:D.nodeId,nodeLookup:E,isTarget:B,edgeUpdaterType:D.type,lib:O,flowId:C,cancelConnection:Z,panBy:$,isValidConnection:(...V)=>{var Y,fe;return((fe=(Y=y.getState()).isValidConnection)==null?void 0:fe.call(Y,...V))??!0},onConnect:G,onConnectStart:K,onConnectEnd:(...V)=>{var Y,fe;return(fe=(Y=y.getState()).onConnectEnd)==null?void 0:fe.call(Y,...V)},onReconnectEnd:H,updateConnection:L,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:R.currentTarget})},k=R=>S(R,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),w=R=>S(R,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),A=()=>v(!0),N=()=>v(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(yb,{position:u,centerX:r,centerY:i,radius:t,onMouseDown:k,onMouseEnter:A,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&s.jsx(yb,{position:f,centerX:o,centerY:c,radius:t,onMouseDown:w,onMouseEnter:A,onMouseOut:N,type:"target"})]})}function WF({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:o,onContextMenu:c,onMouseEnter:u,onMouseMove:f,onMouseLeave:d,reconnectRadius:p,onReconnect:m,onReconnectStart:g,onReconnectEnd:v,rfId:y,edgeTypes:S,noPanClassName:k,onError:w,disableKeyboardA11y:A}){let N=Nt(Se=>Se.edgeLookup.get(e));const R=Nt(Se=>Se.defaultEdgeOptions);N=R?{...R,...N}:N;let D=N.type||"default",P=(S==null?void 0:S[D])||gb[D];P===void 0&&(w==null||w("011",Nr.error011(D)),D="default",P=(S==null?void 0:S.default)||gb.default);const F=!!(N.focusable||t&&typeof N.focusable>"u"),W=typeof m<"u"&&(N.reconnectable||n&&typeof N.reconnectable>"u"),M=!!(N.selectable||r&&typeof N.selectable>"u"),O=b.useRef(null),[T,Z]=b.useState(!1),[E,C]=b.useState(!1),$=Vt(),{zIndex:L=N.zIndex,sourceX:B,sourceY:H,targetX:G,targetY:K,sourcePosition:V,targetPosition:Y}=Nt(b.useCallback(Se=>{const re=Se.nodeLookup.get(N.source),he=Se.nodeLookup.get(N.target);if(!re||!he)return xb;const Le=T3({id:e,sourceNode:re,targetNode:he,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:Se.connectionMode,onError:w}),Te=N3({selected:N.selected,zIndex:N.zIndex,sourceNode:re,targetNode:he,elevateOnSelect:Se.elevateEdgesOnSelect,zIndexMode:Se.zIndexMode});return{...Le||xb,zIndex:Te}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,w]),tn),fe=b.useMemo(()=>N.markerStart?`url('#${am(N.markerStart,y)}')`:void 0,[N.markerStart,y]),xe=b.useMemo(()=>N.markerEnd?`url('#${am(N.markerEnd,y)}')`:void 0,[N.markerEnd,y]);if(N.hidden||B===null||H===null||G===null||K===null)return null;const ge=Se=>{var Te;const{addSelectedEdges:re,unselectNodesAndEdges:he,multiSelectionActive:Le}=$.getState();M&&($.setState({nodesSelectionActive:!1}),N.selected&&Le?(he({nodes:[],edges:[N]}),(Te=O.current)==null||Te.blur()):re([e])),i&&i(Se,N)},ie=o?Se=>{o(Se,{...N})}:void 0,ke=c?Se=>{c(Se,{...N})}:void 0,ae=u?Se=>{u(Se,{...N})}:void 0,Ne=f?Se=>{f(Se,{...N})}:void 0,Fe=d?Se=>{d(Se,{...N})}:void 0,ce=Se=>{var re;if(!A&&XN.includes(Se.key)&&M){const{unselectNodesAndEdges:he,addSelectedEdges:Le}=$.getState();Se.key==="Escape"?((re=O.current)==null||re.blur(),he({edges:[N]})):Le([e])}};return s.jsx("svg",{style:{zIndex:L},children:s.jsxs("g",{className:kn(["react-flow__edge",`react-flow__edge-${D}`,N.className,k,{selected:N.selected,animated:N.animated,inactive:!M&&!i,updating:T,selectable:M}]),onClick:ge,onDoubleClick:ie,onContextMenu:ke,onMouseEnter:ae,onMouseMove:Ne,onMouseLeave:Fe,onKeyDown:F?ce:void 0,tabIndex:F?0:void 0,role:N.ariaRole??(F?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":N.ariaLabel===null?void 0:N.ariaLabel||`Edge from ${N.source} to ${N.target}`,"aria-describedby":F?`${Aj}-${y}`:void 0,ref:O,...N.domAttributes,children:[!E&&s.jsx(P,{id:e,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:M,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:B,sourceY:H,targetX:G,targetY:K,sourcePosition:V,targetPosition:Y,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:fe,markerEnd:xe,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),W&&s.jsx(ZF,{edge:N,isReconnectable:W,reconnectRadius:p,onReconnect:m,onReconnectStart:g,onReconnectEnd:v,sourceX:B,sourceY:H,targetX:G,targetY:K,sourcePosition:V,targetPosition:Y,setUpdateHover:Z,setReconnecting:C})]})})}var VF=b.memo(WF);const qF=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function nS({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:u,onEdgeMouseMove:f,onEdgeMouseLeave:d,onEdgeClick:p,reconnectRadius:m,onEdgeDoubleClick:g,onReconnectStart:v,onReconnectEnd:y,disableKeyboardA11y:S}){const{edgesFocusable:k,edgesReconnectable:w,elementsSelectable:A,onError:N}=Nt(qF,tn),R=TF(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(zF,{defaultColor:e,rfId:n}),R.map(D=>s.jsx(VF,{id:D,edgesFocusable:k,edgesReconnectable:w,elementsSelectable:A,noPanClassName:i,onReconnect:o,onContextMenu:c,onMouseEnter:u,onMouseMove:f,onMouseLeave:d,onClick:p,reconnectRadius:m,onDoubleClick:g,onReconnectStart:v,onReconnectEnd:y,rfId:n,onError:N,edgeTypes:r,disableKeyboardA11y:S},D))]})}nS.displayName="EdgeRenderer";const GF=b.memo(nS),bb=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function KF({children:e}){const t=Vt(),n=b.useRef(null),[r]=b.useState(()=>t.getState().transform);return Rj(()=>{let i=null;const o=()=>{const c=t.getState().transform;i&&c[0]===i[0]&&c[1]===i[1]&&c[2]===i[2]||(i=c,n.current&&(n.current.style.transform=bb(c)))};return o(),t.subscribe(o)},[t]),s.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:bb(r)},children:e})}function YF(e){const t=cg(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const XF=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function QF(e){const t=Nt(XF),n=Vt();return b.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function JF(e){return e.connection.inProgress?{...e.connection,to:pc(e.connection.to,e.transform)}:{...e.connection}}function e6(e){return JF}function t6(e){const t=e6();return Nt(t,tn)}const n6=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function s6({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:c,isValid:u,inProgress:f}=Nt(n6,tn);return!(o&&i&&f)?null:s.jsx("svg",{style:e,width:o,height:c,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:kn(["react-flow__connection",lj(u)]),children:s.jsx(sS,{style:t,type:n,CustomComponent:r,isValid:u})})})}const sS=({style:e,type:t=Pi.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:o,fromNode:c,fromHandle:u,fromPosition:f,to:d,toNode:p,toHandle:m,toPosition:g,pointer:v}=t6();if(!i)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:u,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:f,toPosition:g,connectionStatus:lj(r),toNode:p,toHandle:m,pointer:v});let y="";const S={sourceX:o.x,sourceY:o.y,sourcePosition:f,targetX:d.x,targetY:d.y,targetPosition:g};switch(t){case Pi.Bezier:[y]=hj(S);break;case Pi.SimpleBezier:[y]=Zj(S);break;case Pi.Step:[y]=im({...S,borderRadius:0});break;case Pi.SmoothStep:[y]=im(S);break;default:[y]=mj(S)}return s.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};sS.displayName="ConnectionLine";const r6={};function kb(e=r6){b.useRef(e),Vt(),b.useEffect(()=>{},[e])}function i6(){Vt(),b.useRef(!1),b.useEffect(()=>{},[])}function rS({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:v,connectionLineType:y,connectionLineStyle:S,connectionLineComponent:k,connectionLineContainerStyle:w,selectionKeyCode:A,selectionOnDrag:N,selectionMode:R,multiSelectionKeyCode:D,panActivationKeyCode:P,zoomActivationKeyCode:F,deleteKeyCode:W,onlyRenderVisibleElements:M,elementsSelectable:O,defaultViewport:T,translateExtent:Z,minZoom:E,maxZoom:C,preventScrolling:$,defaultMarkerColor:L,zoomOnScroll:B,zoomOnPinch:H,panOnScroll:G,panOnScrollSpeed:K,panOnScrollMode:V,zoomOnDoubleClick:Y,panOnDrag:fe,autoPanOnSelection:xe,onPaneClick:ge,onPaneMouseEnter:ie,onPaneMouseMove:ke,onPaneMouseLeave:ae,onPaneScroll:Ne,onPaneContextMenu:Fe,paneClickDistance:ce,nodeClickDistance:Se,onEdgeContextMenu:re,onEdgeMouseEnter:he,onEdgeMouseMove:Le,onEdgeMouseLeave:Te,reconnectRadius:Ge,onReconnect:Ie,onReconnectStart:tt,onReconnectEnd:et,noDragClassName:jt,noWheelClassName:On,noPanClassName:sn,disableKeyboardA11y:ln,nodeExtent:cn,rfId:rn,viewport:an,onViewportChange:Ft,nodesDraggable:Bn}){return kb(e),kb(t),i6(),YF(n),QF(an),s.jsx(kF,{onPaneClick:ge,onPaneMouseEnter:ie,onPaneMouseMove:ke,onPaneMouseLeave:ae,onPaneContextMenu:Fe,onPaneScroll:Ne,paneClickDistance:ce,deleteKeyCode:W,selectionKeyCode:A,selectionOnDrag:N,selectionMode:R,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:D,panActivationKeyCode:P,zoomActivationKeyCode:F,elementsSelectable:O,zoomOnScroll:B,zoomOnPinch:H,zoomOnDoubleClick:Y,panOnScroll:G,panOnScrollSpeed:K,panOnScrollMode:V,panOnDrag:fe,autoPanOnSelection:xe,defaultViewport:T,translateExtent:Z,minZoom:E,maxZoom:C,onSelectionContextMenu:m,preventScrolling:$,noDragClassName:jt,noWheelClassName:On,noPanClassName:sn,disableKeyboardA11y:ln,onViewportChange:Ft,isControlledViewport:!!an,children:s.jsxs(KF,{children:[s.jsx(GF,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:c,onReconnect:Ie,onReconnectStart:tt,onReconnectEnd:et,onlyRenderVisibleElements:M,onEdgeContextMenu:re,onEdgeMouseEnter:he,onEdgeMouseMove:Le,onEdgeMouseLeave:Te,reconnectRadius:Ge,defaultMarkerColor:L,noPanClassName:sn,disableKeyboardA11y:ln,rfId:rn}),s.jsx(s6,{style:S,type:y,component:k,containerStyle:w}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(AF,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:f,onNodeMouseLeave:d,onNodeContextMenu:p,nodeClickDistance:Se,onlyRenderVisibleElements:M,noPanClassName:sn,noDragClassName:jt,disableKeyboardA11y:ln,nodeExtent:cn,rfId:rn,nodesDraggable:Bn}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}rS.displayName="GraphView";const a6=b.memo(rS),o6=ij(),wb=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:f=.5,maxZoom:d=2,nodeOrigin:p,nodeExtent:m,zIndexMode:g="basic"}={})=>{const v=new Map,y=new Map,S=new Map,k=new Map,w=r??t??[],A=n??e??[],N=p??[0,0],R=m??Kl;vj(S,k,w);const{nodesInitialized:D}=om(A,v,y,{nodeOrigin:N,nodeExtent:R,zIndexMode:g});let P=[0,0,1];if(c&&i&&o){const F=fc(v,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:W,y:M,zoom:O}=ng(F,i,o,f,d,(u==null?void 0:u.padding)??.1);P=[W,M,O]}return{rfId:"1",width:i??0,height:o??0,transform:P,nodes:A,nodesInitialized:D,nodeLookup:v,parentLookup:y,edges:w,edgeLookup:k,connectionLookup:S,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:f,maxZoom:d,translateExtent:Kl,nodeExtent:R,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ro.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:N,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:c??!1,fitViewOptions:u,fitViewResolver:null,connection:{...JN},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:o6,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:QN,zIndexMode:g,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},l6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:f,maxZoom:d,nodeOrigin:p,nodeExtent:m,zIndexMode:g})=>b4((v,y)=>{async function S(){const{nodeLookup:k,panZoom:w,fitViewOptions:A,fitViewResolver:N,width:R,height:D,minZoom:P,maxZoom:F}=y();w&&(await g3({nodes:k,width:R,height:D,panZoom:w,minZoom:P,maxZoom:F},A),N==null||N.resolve(!0),v({fitViewResolver:null}))}return{...wb({nodes:e,edges:t,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:f,maxZoom:d,nodeOrigin:p,nodeExtent:m,defaultNodes:n,defaultEdges:r,zIndexMode:g}),setNodes:k=>{const{nodeLookup:w,parentLookup:A,nodeOrigin:N,nodeExtent:R,elevateNodesOnSelect:D,fitViewQueued:P,zIndexMode:F,nodesSelectionActive:W}=y(),{nodesInitialized:M,hasSelectedNodes:O}=om(k,w,A,{nodeOrigin:N,nodeExtent:R,elevateNodesOnSelect:D,checkEquality:!0,zIndexMode:F}),T=W&&O;P&&M?(S(),v({nodes:k,nodesInitialized:M,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:T})):v({nodes:k,nodesInitialized:M,nodesSelectionActive:T})},setEdges:k=>{const{connectionLookup:w,edgeLookup:A}=y();vj(w,A,k),v({edges:k})},setDefaultNodesAndEdges:(k,w)=>{if(k){const{setNodes:A}=y();A(k),v({hasDefaultNodes:!0})}if(w){const{setEdges:A}=y();A(w),v({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:w,nodeLookup:A,parentLookup:N,domNode:R,nodeOrigin:D,nodeExtent:P,debug:F,fitViewQueued:W,zIndexMode:M}=y(),{changes:O,updatedInternals:T}=D3(k,A,N,R,D,P,M);T&&(O3(A,N,{nodeOrigin:D,nodeExtent:P,zIndexMode:M}),W?(S(),v({fitViewQueued:!1,fitViewOptions:void 0})):v({}),(O==null?void 0:O.length)>0&&(F&&console.log("React Flow: trigger node changes",O),w==null||w(O)))},updateNodePositions:(k,w=!1)=>{const A=[];let N=[];const{nodeLookup:R,triggerNodeChanges:D,connection:P,updateConnection:F,onNodesChangeMiddlewareMap:W}=y();for(const[M,O]of k){const T=R.get(M),Z=!!(T!=null&&T.expandParent&&(T!=null&&T.parentId)&&(O!=null&&O.position)),E={id:M,type:"position",position:Z?{x:Math.max(0,O.position.x),y:Math.max(0,O.position.y)}:O.position,dragging:w};if(T&&P.inProgress&&P.fromNode.id===T.id){const C=Ma(T,P.fromHandle,Je.Left,!0);F({...P,from:C})}Z&&T.parentId&&A.push({id:M,parentId:T.parentId,rect:{...O.internals.positionAbsolute,width:O.measured.width??0,height:O.measured.height??0}}),N.push(E)}if(A.length>0){const{parentLookup:M,nodeOrigin:O}=y(),T=lg(A,R,M,O);N.push(...T)}for(const M of W.values())N=M(N);D(N)},triggerNodeChanges:k=>{const{onNodesChange:w,setNodes:A,nodes:N,hasDefaultNodes:R,debug:D}=y();if(k!=null&&k.length){if(R){const P=B4(k,N);A(P)}D&&console.log("React Flow: trigger node changes",k),w==null||w(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:w,setEdges:A,edges:N,hasDefaultEdges:R,debug:D}=y();if(k!=null&&k.length){if(R){const P=U4(k,N);A(P)}D&&console.log("React Flow: trigger edge changes",k),w==null||w(k)}},addSelectedNodes:k=>{const{multiSelectionActive:w,edgeLookup:A,nodeLookup:N,triggerNodeChanges:R,triggerEdgeChanges:D}=y();if(w){const P=k.map(F=>ma(F,!0));R(P);return}R(mo(N,new Set([...k]),!0)),D(mo(A))},addSelectedEdges:k=>{const{multiSelectionActive:w,edgeLookup:A,nodeLookup:N,triggerNodeChanges:R,triggerEdgeChanges:D}=y();if(w){const P=k.map(F=>ma(F,!0));D(P);return}D(mo(A,new Set([...k]))),R(mo(N,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:w}={})=>{const{edges:A,nodes:N,nodeLookup:R,triggerNodeChanges:D,triggerEdgeChanges:P}=y(),F=k||N,W=w||A,M=[];for(const T of F){if(!T.selected)continue;const Z=R.get(T.id);Z&&(Z.selected=!1),M.push(ma(T.id,!1))}const O=[];for(const T of W)T.selected&&O.push(ma(T.id,!1));D(M),P(O)},setMinZoom:k=>{const{panZoom:w,maxZoom:A}=y();w==null||w.setScaleExtent([k,A]),v({minZoom:k})},setMaxZoom:k=>{const{panZoom:w,minZoom:A}=y();w==null||w.setScaleExtent([A,k]),v({maxZoom:k})},setTranslateExtent:k=>{var w;(w=y().panZoom)==null||w.setTranslateExtent(k),v({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:w,triggerNodeChanges:A,triggerEdgeChanges:N,elementsSelectable:R}=y();if(!R)return;const D=w.reduce((F,W)=>W.selected?[...F,ma(W.id,!1)]:F,[]),P=k.reduce((F,W)=>W.selected?[...F,ma(W.id,!1)]:F,[]);A(D),N(P)},setNodeExtent:k=>{const{nodes:w,nodeLookup:A,parentLookup:N,nodeOrigin:R,elevateNodesOnSelect:D,nodeExtent:P,zIndexMode:F}=y();k[0][0]===P[0][0]&&k[0][1]===P[0][1]&&k[1][0]===P[1][0]&&k[1][1]===P[1][1]||(om(w,A,N,{nodeOrigin:R,nodeExtent:k,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:F}),v({nodeExtent:k}))},panBy:k=>{const{transform:w,width:A,height:N,panZoom:R,translateExtent:D}=y();return F3({delta:k,panZoom:R,transform:w,translateExtent:D,width:A,height:N})},setCenter:async(k,w,A)=>{const{width:N,height:R,maxZoom:D,panZoom:P}=y();if(!P)return!1;const F=typeof(A==null?void 0:A.zoom)<"u"?A.zoom:D;return await P.setViewport({x:N/2-k*F,y:R/2-w*F,zoom:F},{duration:A==null?void 0:A.duration,ease:A==null?void 0:A.ease,interpolate:A==null?void 0:A.interpolate}),!0},cancelConnection:()=>{v({connection:{...JN}})},updateConnection:k=>{v({connection:k})},reset:()=>v({...wb()})}},Object.is);function c6({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:o,initialMinZoom:c,initialMaxZoom:u,initialFitViewOptions:f,fitView:d,nodeOrigin:p,nodeExtent:m,zIndexMode:g,children:v}){const[y]=b.useState(()=>l6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:d,minZoom:c,maxZoom:u,fitViewOptions:f,nodeOrigin:p,nodeExtent:m,zIndexMode:g}));return s.jsx(k4,{value:y,children:s.jsx(q4,{children:s.jsx(lF,{children:v})})})}function u6({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:o,height:c,fitView:u,fitViewOptions:f,minZoom:d,maxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:v}){return b.useContext(Ad)?s.jsx(s.Fragment,{children:e}):s.jsx(c6,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:o,initialHeight:c,fitView:u,initialFitViewOptions:f,initialMinZoom:d,initialMaxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:v,children:e})}const d6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function f6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o,edgeTypes:c,onNodeClick:u,onEdgeClick:f,onInit:d,onMove:p,onMoveStart:m,onMoveEnd:g,onConnect:v,onConnectStart:y,onConnectEnd:S,onClickConnectStart:k,onClickConnectEnd:w,onNodeMouseEnter:A,onNodeMouseMove:N,onNodeMouseLeave:R,onNodeContextMenu:D,onNodeDoubleClick:P,onNodeDragStart:F,onNodeDrag:W,onNodeDragStop:M,onNodesDelete:O,onEdgesDelete:T,onDelete:Z,onSelectionChange:E,onSelectionDragStart:C,onSelectionDrag:$,onSelectionDragStop:L,onSelectionContextMenu:B,onSelectionStart:H,onSelectionEnd:G,onBeforeDelete:K,connectionMode:V,connectionLineType:Y=Pi.Bezier,connectionLineStyle:fe,connectionLineComponent:xe,connectionLineContainerStyle:ge,deleteKeyCode:ie="Backspace",selectionKeyCode:ke="Shift",selectionOnDrag:ae=!1,selectionMode:Ne=Yl.Full,panActivationKeyCode:Fe="Space",multiSelectionKeyCode:ce=Ql()?"Meta":"Control",zoomActivationKeyCode:Se=Ql()?"Meta":"Control",snapToGrid:re,snapGrid:he,onlyRenderVisibleElements:Le=!1,selectNodesOnDrag:Te,nodesDraggable:Ge,autoPanOnNodeFocus:Ie,nodesConnectable:tt,nodesFocusable:et,nodeOrigin:jt=Tj,edgesFocusable:On,edgesReconnectable:sn,elementsSelectable:ln=!0,defaultViewport:cn=R4,minZoom:rn=.5,maxZoom:an=2,translateExtent:Ft=Kl,preventScrolling:Bn=!0,nodeExtent:wn,defaultMarkerColor:ws="#b1b1b7",zoomOnScroll:_r=!0,zoomOnPinch:Ks=!0,panOnScroll:Ys=!1,panOnScrollSpeed:Ms=.5,panOnScrollMode:Rs=Sa.Free,zoomOnDoubleClick:Os=!0,panOnDrag:zs=!0,onPaneClick:Xs,onPaneMouseEnter:Qs,onPaneMouseMove:rs,onPaneMouseLeave:Yn,onPaneScroll:Nn,onPaneContextMenu:Q,paneClickDistance:pe=1,nodeClickDistance:Oe=0,children:st,onReconnect:It,onReconnectStart:$t,onReconnectEnd:Be,onEdgeContextMenu:De,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Un,reconnectRadius:is=10,onNodesChange:Js,onEdgesChange:hi,noDragClassName:er="nodrag",noWheelClassName:pi="nowheel",noPanClassName:Hn="nopan",fitView:Br,fitViewOptions:as,connectOnClick:Er,attributionPosition:mi,proOptions:Rt,defaultEdgeOptions:Ns,elevateNodesOnSelect:Xn=!0,elevateEdgesOnSelect:Ur=!1,disableKeyboardA11y:tr=!1,autoPanOnConnect:Ot,autoPanOnNodeDrag:gi,autoPanOnSelection:Hr=!0,autoPanSpeed:nr,connectionRadius:Cr,isValidConnection:Ae,onError:Ze,style:ct,id:ft,nodeDragThreshold:At,connectionDragThreshold:zt,viewport:Zn,onViewportChange:Ps,width:un,height:jn,colorMode:Ls="light",debug:Ds,onScroll:os,ariaLabelConfig:Qi,zIndexMode:xi="basic",...Ir},vi){const Qn=ft||"1",ls=L4(Ls),Sn=b.useCallback(Fs=>{Fs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),os==null||os(Fs)},[os]);return s.jsx("div",{"data-testid":"rf__wrapper",...Ir,onScroll:Sn,style:{...ct,...d6},ref:vi,className:kn(["react-flow",i,ls]),id:ft,role:"application",children:s.jsxs(u6,{nodes:e,edges:t,width:un,height:jn,fitView:Br,fitViewOptions:as,minZoom:rn,maxZoom:an,nodeOrigin:jt,nodeExtent:wn,zIndexMode:xi,children:[s.jsx(P4,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:y,onConnectEnd:S,onClickConnectStart:k,onClickConnectEnd:w,nodesDraggable:Ge,autoPanOnNodeFocus:Ie,nodesConnectable:tt,nodesFocusable:et,edgesFocusable:On,edgesReconnectable:sn,elementsSelectable:ln,elevateNodesOnSelect:Xn,elevateEdgesOnSelect:Ur,minZoom:rn,maxZoom:an,nodeExtent:wn,onNodesChange:Js,onEdgesChange:hi,snapToGrid:re,snapGrid:he,connectionMode:V,translateExtent:Ft,connectOnClick:Er,defaultEdgeOptions:Ns,fitView:Br,fitViewOptions:as,onNodesDelete:O,onEdgesDelete:T,onDelete:Z,onNodeDragStart:F,onNodeDrag:W,onNodeDragStop:M,onSelectionDrag:$,onSelectionDragStart:C,onSelectionDragStop:L,onMove:p,onMoveStart:m,onMoveEnd:g,noPanClassName:Hn,nodeOrigin:jt,rfId:Qn,autoPanOnConnect:Ot,autoPanOnNodeDrag:gi,autoPanSpeed:nr,onError:Ze,connectionRadius:Cr,isValidConnection:Ae,selectNodesOnDrag:Te,nodeDragThreshold:At,connectionDragThreshold:zt,onBeforeDelete:K,debug:Ds,ariaLabelConfig:Qi,zIndexMode:xi}),s.jsx(a6,{onInit:d,onNodeClick:u,onEdgeClick:f,onNodeMouseEnter:A,onNodeMouseMove:N,onNodeMouseLeave:R,onNodeContextMenu:D,onNodeDoubleClick:P,nodeTypes:o,edgeTypes:c,connectionLineType:Y,connectionLineStyle:fe,connectionLineComponent:xe,connectionLineContainerStyle:ge,selectionKeyCode:ke,selectionOnDrag:ae,selectionMode:Ne,deleteKeyCode:ie,multiSelectionKeyCode:ce,panActivationKeyCode:Fe,zoomActivationKeyCode:Se,onlyRenderVisibleElements:Le,defaultViewport:cn,translateExtent:Ft,minZoom:rn,maxZoom:an,preventScrolling:Bn,zoomOnScroll:_r,zoomOnPinch:Ks,zoomOnDoubleClick:Os,panOnScroll:Ys,panOnScrollSpeed:Ms,panOnScrollMode:Rs,panOnDrag:zs,autoPanOnSelection:Hr,onPaneClick:Xs,onPaneMouseEnter:Qs,onPaneMouseMove:rs,onPaneMouseLeave:Yn,onPaneScroll:Nn,onPaneContextMenu:Q,paneClickDistance:pe,nodeClickDistance:Oe,onSelectionContextMenu:B,onSelectionStart:H,onSelectionEnd:G,onReconnect:It,onReconnectStart:$t,onReconnectEnd:Be,onEdgeContextMenu:De,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Un,reconnectRadius:is,defaultMarkerColor:ws,noDragClassName:er,noWheelClassName:pi,noPanClassName:Hn,rfId:Qn,disableKeyboardA11y:tr,nodeExtent:wn,viewport:Zn,onViewportChange:Ps,nodesDraggable:Ge}),s.jsx(M4,{onSelectionChange:E}),st,s.jsx(C4,{proOptions:Rt,position:mi}),s.jsx(E4,{rfId:Qn,disableKeyboardA11y:tr})]})})}var h6=Mj(f6);function p6({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:kn(["react-flow__background-pattern",n,r])})}function m6({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:kn(["react-flow__background-pattern","dots",t])})}var Vi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Vi||(Vi={}));const g6={[Vi.Dots]:1,[Vi.Lines]:1,[Vi.Cross]:6},x6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function iS({id:e,variant:t=Vi.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=0,color:c,bgColor:u,style:f,className:d,patternClassName:p}){const m=b.useRef(null),{transform:g,patternId:v}=Nt(x6,tn),y=r||g6[t],S=t===Vi.Dots,k=t===Vi.Cross,w=Array.isArray(n)?n:[n,n],A=[w[0]*g[2]||1,w[1]*g[2]||1],N=y*g[2],R=Array.isArray(o)?o:[o,o],D=k?[N,N]:A,P=[R[0]*g[2]+D[0]/2,R[1]*g[2]+D[1]/2],F=`${v}${e||""}`;return s.jsxs("svg",{className:kn(["react-flow__background",d]),style:{...f,...$d,"--xy-background-color-props":u,"--xy-background-pattern-color-props":c},ref:m,"data-testid":"rf__background",children:[s.jsx("pattern",{id:F,x:g[0]%A[0],y:g[1]%A[1],width:A[0],height:A[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${P[0]},-${P[1]})`,children:S?s.jsx(m6,{radius:N/2,className:p}):s.jsx(p6,{dimensions:D,lineWidth:i,variant:t,className:p})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${F})`})]})}iS.displayName="Background";const v6=b.memo(iS);function y6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function b6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function k6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.jsx("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 w6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("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 N6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.jsx("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"})})}function Au({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:kn(["react-flow__controls-button",t]),...n,children:e})}const j6=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function aS({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:c,onFitView:u,onInteractiveChange:f,className:d,children:p,position:m="bottom-left",orientation:g="vertical","aria-label":v}){const y=Vt(),{isInteractive:S,minZoomReached:k,maxZoomReached:w,ariaLabelConfig:A}=Nt(j6,tn),{zoomIn:N,zoomOut:R,fitView:D}=cg(),P=()=>{N(),o==null||o()},F=()=>{R(),c==null||c()},W=()=>{D(i),u==null||u()},M=()=>{y.setState({nodesDraggable:!S,nodesConnectable:!S,elementsSelectable:!S}),f==null||f(!S)},O=g==="horizontal"?"horizontal":"vertical";return s.jsxs(Td,{className:kn(["react-flow__controls",O,d]),position:m,style:e,"data-testid":"rf__controls","aria-label":v??A["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Au,{onClick:P,className:"react-flow__controls-zoomin",title:A["controls.zoomIn.ariaLabel"],"aria-label":A["controls.zoomIn.ariaLabel"],disabled:w,children:s.jsx(y6,{})}),s.jsx(Au,{onClick:F,className:"react-flow__controls-zoomout",title:A["controls.zoomOut.ariaLabel"],"aria-label":A["controls.zoomOut.ariaLabel"],disabled:k,children:s.jsx(b6,{})})]}),n&&s.jsx(Au,{className:"react-flow__controls-fitview",onClick:W,title:A["controls.fitView.ariaLabel"],"aria-label":A["controls.fitView.ariaLabel"],children:s.jsx(k6,{})}),r&&s.jsx(Au,{className:"react-flow__controls-interactive",onClick:M,title:A["controls.interactive.ariaLabel"],"aria-label":A["controls.interactive.ariaLabel"],children:S?s.jsx(N6,{}):s.jsx(w6,{})}),p]})}aS.displayName="Controls";const S6=b.memo(aS);function _6({id:e,x:t,y:n,width:r,height:i,style:o,color:c,strokeColor:u,strokeWidth:f,className:d,borderRadius:p,shapeRendering:m,selected:g,onClick:v}){const{background:y,backgroundColor:S}=o||{},k=c||y||S;return s.jsx("rect",{className:kn(["react-flow__minimap-node",{selected:g},d]),x:t,y:n,rx:p,ry:p,width:r,height:i,style:{fill:k,stroke:u,strokeWidth:f},shapeRendering:m,onClick:v?w=>v(w,e):void 0})}const E6=b.memo(_6),C6=e=>e.nodes.map(t=>t.id),ap=e=>e instanceof Function?e:()=>e;function I6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=E6,onClick:c}){const u=Nt(C6,tn),f=ap(t),d=ap(e),p=ap(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:u.map(g=>s.jsx(T6,{id:g,nodeColorFunc:f,nodeStrokeColorFunc:d,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:c,shapeRendering:m},g))})}function A6({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:u,onClick:f}){const{node:d,x:p,y:m,width:g,height:v}=Nt(y=>{const S=y.nodeLookup.get(e);if(!S)return{node:void 0,x:0,y:0,width:0,height:0};const k=S.internals.userNode,{x:w,y:A}=S.internals.positionAbsolute,{width:N,height:R}=Sr(k);return{node:k,x:w,y:A,width:N,height:R}},tn);return!d||d.hidden||!aj(d)?null:s.jsx(u,{x:p,y:m,width:g,height:v,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:i,strokeColor:n(d),strokeWidth:o,shapeRendering:c,onClick:f,id:d.id})}const T6=b.memo(A6);var $6=b.memo(I6);const M6=200,R6=150,O6=e=>!e.hidden,z6=e=>{const t={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]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?sj(fc(e.nodeLookup,{filter:O6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Nb=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,P6=(e,t)=>Nb(e.viewBB,t.viewBB)&&Nb(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,L6="react-flow__minimap-desc";function oS({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:f,maskColor:d,maskStrokeColor:p,maskStrokeWidth:m,position:g="bottom-right",onClick:v,onNodeClick:y,pannable:S=!1,zoomable:k=!1,ariaLabel:w,inversePan:A,zoomStep:N=1,offsetScale:R=5}){const D=Vt(),P=b.useRef(null),{boundingRect:F,panZoom:W,viewBB:M,rfId:O,translateExtent:T,flowWidth:Z,flowHeight:E,ariaLabelConfig:C}=Nt(z6,P6),$=(e==null?void 0:e.width)??M6,L=(e==null?void 0:e.height)??R6,B=F.width/$,H=F.height/L,G=Math.max(B,H),K=G*$,V=G*L,Y=R*G,fe=F.x-(K-F.width)/2-Y,xe=F.y-(V-F.height)/2-Y,ge=K+Y*2,ie=V+Y*2,ke=`${L6}-${O}`,ae=b.useRef(0),Ne=b.useRef();ae.current=G,b.useEffect(()=>{const he=D.getState().panZoom;if(P.current&&he)return Ne.current=K3({domNode:P.current,panZoom:he,getTransform:()=>D.getState().transform,getViewScale:()=>ae.current}),()=>{var Le;(Le=Ne.current)==null||Le.destroy()}},[W]),b.useEffect(()=>{var he;(he=Ne.current)==null||he.update({translateExtent:T,width:Z,height:E,inversePan:A,pannable:S,zoomStep:N,zoomable:k})},[S,k,A,N,T,Z,E]);const Fe=v?he=>{var Ge;const[Le,Te]=((Ge=Ne.current)==null?void 0:Ge.pointer(he))||[0,0];v(he,{x:Le,y:Te})}:void 0,ce=b.useCallback((he,Le)=>{const Te=D.getState().nodeLookup.get(Le).internals.userNode;y==null||y(he,Te)},[y]),Se=y?ce:void 0,re=w??C["minimap.ariaLabel"];return s.jsx(Td,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*G:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:kn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:$,height:L,viewBox:`${fe} ${xe} ${ge} ${ie}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ke,ref:P,onClick:Fe,children:[re&&s.jsx("title",{id:ke,children:re}),s.jsx($6,{onClick:Se,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:c,nodeComponent:u}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${fe-Y},${xe-Y}h${ge+Y*2}v${ie+Y*2}h${-ge-Y*2}z
220
- M${M.x},${M.y}h${M.width}v${M.height}h${-M.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}oS.displayName="MiniMap";b.memo(oS);const D6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,F6={[Po.Line]:"right",[Po.Handle]:"bottom-right"};function B6({nodeId:e,position:t,variant:n=Po.Handle,className:r,style:i=void 0,children:o,color:c,minWidth:u=10,minHeight:f=10,maxWidth:d=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:g,autoScale:v=!0,shouldResize:y,onResizeStart:S,onResize:k,onResizeEnd:w}){const A=Lj(),N=typeof e=="string"?e:A,R=Vt(),D=b.useRef(null),P=n===Po.Handle,F=Nt(b.useCallback(D6(P&&v),[P,v]),tn),W=b.useRef(null),M=t??F6[n];b.useEffect(()=>{if(!(!D.current||!N))return W.current||(W.current=l4({domNode:D.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:T,transform:Z,snapGrid:E,snapToGrid:C,nodeOrigin:$,domNode:L}=R.getState();return{nodeLookup:T,transform:Z,snapGrid:E,snapToGrid:C,nodeOrigin:$,paneDomNode:L}},onChange:(T,Z)=>{const{triggerNodeChanges:E,nodeLookup:C,parentLookup:$,nodeOrigin:L}=R.getState(),B=[],H={x:T.x,y:T.y},G=C.get(N);if(G&&G.expandParent&&G.parentId){const K=G.origin??L,V=T.width??G.measured.width??0,Y=T.height??G.measured.height??0,fe={id:G.id,parentId:G.parentId,rect:{width:V,height:Y,...oj({x:T.x??G.position.x,y:T.y??G.position.y},{width:V,height:Y},G.parentId,C,K)}},xe=lg([fe],C,$,L);B.push(...xe),H.x=T.x?Math.max(K[0]*V,T.x):void 0,H.y=T.y?Math.max(K[1]*Y,T.y):void 0}if(H.x!==void 0&&H.y!==void 0){const K={id:N,type:"position",position:{...H}};B.push(K)}if(T.width!==void 0&&T.height!==void 0){const V={id:N,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};B.push(V)}for(const K of Z){const V={...K,type:"position"};B.push(V)}E(B)},onEnd:({width:T,height:Z})=>{const E={id:N,type:"dimensions",resizing:!1,dimensions:{width:T,height:Z}};R.getState().triggerNodeChanges([E])}})),W.current.update({controlPosition:M,boundaries:{minWidth:u,minHeight:f,maxWidth:d,maxHeight:p},keepAspectRatio:m,resizeDirection:g,onResizeStart:S,onResize:k,onResizeEnd:w,shouldResize:y}),()=>{var T;(T=W.current)==null||T.destroy()}},[M,u,f,d,p,m,S,k,w,y]);const O=M.split("-");return s.jsx("div",{className:kn(["react-flow__resize-control","nodrag",...O,n,r]),ref:D,style:{...i,scale:F,...c&&{[P?"backgroundColor":"borderColor"]:c}},children:o})}b.memo(B6);function U6(e,t=0){const n=je(e.connection.status),[r,i]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return(async()=>{const{scripts:c}=await e.connection.call("scripts/list",{}),u=[];for(const f of c){if(f.packId===void 0)continue;const d=await e.connection.call("runs/tasks",{scriptId:f.id}).catch(()=>{});if(d===void 0||d.tasks.length===0)continue;const p=await e.connection.call("configs/profiles",{scriptId:f.id}).catch(()=>{});u.push({scriptId:f.id,scriptName:f.name,tasks:d.tasks,profiles:p})}o&&i(u)})().catch(()=>{}),()=>{o=!1}},[e,n.state,t]),b.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{i(c=>c.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),r}const lS=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),cS=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],Lo={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},um={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},H6={success:"成功后",failure:"失败后",always:"结束后"},op={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function Z6({data:e,selected:t}){var r,i,o,c;const n=(r=e.state)==null?void 0:r.state;return Wi(e.node)?s.jsxs("div",{className:`step-node marker ${e.node.kind} ${n??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&s.jsx(Hi,{type:"target",position:Je.Left}),s.jsx("span",{children:Lo[e.node.kind]}),e.node.kind==="end"&&n!==void 0&&n!=="pending"&&s.jsx("span",{className:`step-state ${n}`,children:((i=e.state)==null?void 0:i.detail)??um[n]}),e.node.kind==="start"&&s.jsx(Hi,{type:"source",position:Je.Right})]}):s.jsxs("div",{className:`step-node ${n??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[s.jsx(Hi,{type:"target",position:Je.Left}),s.jsxs("div",{className:"step-kind",children:[s.jsx("span",{children:Lo[e.node.kind]}),e.input!==""&&s.jsx("span",{className:"badge",children:e.input}),e.node.waitForAll===!0&&s.jsx("span",{className:"badge",title:"等前面的节点全部结束再开始",children:"等全部"}),n!==void 0&&s.jsxs("span",{className:`step-state ${n}`,children:[um[n],(((o=e.state)==null?void 0:o.attempts)??0)>1?` · 第 ${e.state.attempts} 次`:""]})]}),s.jsx("div",{className:"step-title",children:e.label}),e.sub!==""&&s.jsx("div",{className:"step-sub",children:e.sub}),((c=e.state)==null?void 0:c.detail)!==void 0&&e.state.detail!==""&&s.jsx("div",{className:"step-detail",children:e.state.detail}),e.issue!==void 0&&e.state===void 0&&s.jsx("div",{className:"step-detail issue",children:e.issue}),s.jsx(Hi,{type:"source",position:Je.Right})]})}const W6={step:Z6};function V6(e){const t=new Map,n=(o,c)=>{if(t.has(o))return t.get(o);if(c.has(o))return 0;c.add(o);const u=e.edges.filter(d=>d.to===o).map(d=>n(d.from,c)+1),f=Math.max(0,...u);return t.set(o,f),f};for(const o of e.nodes)n(o.id,new Set);const r=new Map,i=new Map;for(const o of e.nodes){if(o.position!==void 0){i.set(o.id,o.position);continue}const c=t.get(o.id)??0,u=r.get(c)??0;r.set(c,u+1),i.set(o.id,{x:40+c*280,y:40+u*130})}return i}let q6=0;const Sl=(e,t)=>{for(;;){const n=`${e}${++q6}`;if(!t.nodes.some(r=>r.id===n))return n}};function G6({client:e,pipeline:t,onChange:n,run:r,check:i,runFrom:o,idle:c}){var T,Z;const u=mw(),[f,d]=b.useState(0),p=U6(e,f),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState({}),w=b.useCallback(E=>{var C,$;if(E.kind==="script-task"){const L=p.find(K=>K.scriptId===E.scriptId),B=L==null?void 0:L.tasks.find(K=>K.id===E.taskId),H=Object.entries(E.params).map(([K,V])=>`${K}=${String(V)}`).join(" "),G=E.profile===void 0?void 0:(($=(C=L==null?void 0:L.profiles)==null?void 0:C.items.find(K=>K.id===E.profile))==null?void 0:$.name)??"已删除的配置";return{label:E.title??`${(L==null?void 0:L.scriptName)??E.scriptId} · ${(B==null?void 0:B.title)??E.taskId}`,sub:[G===void 0?"":`配置:${G}`,H].filter(Boolean).join(" · "),input:op[(B==null?void 0:B.input)??"none"]??""}}return E.kind==="wait"?{label:E.title??(E.minutes!==void 0?`等 ${E.minutes} 分钟`:`等到 ${E.until}`),sub:"",input:""}:E.kind==="agent"?{label:E.title??"agent 步骤",sub:E.prompt.slice(0,40),input:""}:Wi(E)?{label:Lo[E.kind],sub:"",input:""}:{label:E.title??Lo[E.kind],sub:E.text.slice(0,40),input:""}},[p]),A=b.useMemo(()=>V6(t),[t]),N=b.useMemo(()=>t.nodes.map(E=>{var C;return{id:E.id,type:"step",position:A.get(E.id),selected:E.id===m,...S[E.id]===void 0?{}:{measured:S[E.id]},data:{node:E,...w(E),state:r==null?void 0:r.nodes[E.id],issue:(C=i==null?void 0:i.issues.find($=>$.nodeId===E.id&&$.level==="error"))==null?void 0:C.message}}}),[t,A,w,r,i,m,S]),R=b.useMemo(()=>t.edges.map((E,C)=>{var $;return{id:`e${C}`,source:E.from,target:E.to,label:H6[E.when],selected:C===v,animated:(($=r==null?void 0:r.nodes[E.from])==null?void 0:$.state)==="running",className:`edge-${E.when}`}}),[t.edges,v,r]),D=b.useCallback(E=>{let C=t;const $={};for(const L of E)if(L.type==="dimensions"&&L.dimensions!==void 0)$[L.id]=L.dimensions;else if(L.type==="position"&&L.position!==void 0)C={...C,nodes:C.nodes.map(B=>B.id===L.id?{...B,position:{x:Math.round(L.position.x),y:Math.round(L.position.y)}}:B)};else if(L.type==="remove"){if(C.nodes.some(B=>B.id===L.id&&Wi(B)))continue;C={...C,nodes:C.nodes.filter(B=>B.id!==L.id),edges:C.edges.filter(B=>B.from!==L.id&&B.to!==L.id)},g(null)}Object.keys($).length>0&&k(L=>({...L,...$})),C!==t&&n(C)},[t,n]),P=b.useCallback(E=>{var $;if(E.source===E.target||t.edges.some(L=>L.from===E.source&&L.to===E.target))return;const C=t.nodes.find(L=>L.id===E.target);(C==null?void 0:C.kind)==="start"||(($=t.nodes.find(L=>L.id===E.source))==null?void 0:$.kind)==="end"||n({...t,edges:[...t.edges,{from:E.source,to:E.target,when:(C==null?void 0:C.kind)==="end"?"always":"success"}]})},[t,n]),F=E=>{const C=t.nodes.find(Y=>Y.kind==="start"),$=t.nodes.find(Y=>Y.kind==="end"),L=t.nodes.find(Y=>Y.id===m&&Y.kind!=="end")??C,B=L===void 0?void 0:A.get(L.id),H=[...A.entries()].filter(([Y])=>Y!==($==null?void 0:$.id)).map(([,Y])=>Y),G=B===void 0?Math.max(0,...H.map(Y=>Y.x))+280:B.x+280;let K=(B==null?void 0:B.y)??40;for(;H.some(Y=>Math.abs(Y.x-G)<200&&Math.abs(Y.y-K)<100);)K+=130;const V=[...t.nodes.map(Y=>{var fe,xe;return Y.kind==="end"?{...Y,position:{x:Math.max(((fe=A.get(Y.id))==null?void 0:fe.x)??0,G+300),y:((xe=A.get(Y.id))==null?void 0:xe.y)??K}}:Y}),{...E,position:{x:G,y:K}}];n({...t,nodes:V}),g(E.id),y(null)},W=t.nodes.find(E=>E.id===m),M=v===null?void 0:t.edges[v],O=E=>n({...t,nodes:t.nodes.map(C=>C.id===E.id?E:C)});return s.jsxs("div",{className:"pipeline-editor",children:[s.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[s.jsx("div",{className:"sidebar-label",children:"脚本任务"}),p.length===0&&s.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),p.map(E=>s.jsxs("details",{className:"palette-group",open:p.length<=3,children:[s.jsx("summary",{children:E.scriptName}),E.tasks.map(C=>s.jsxs("button",{className:"palette-item",title:C.description??C.title,onClick:()=>F({id:Sl(E.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:E.scriptId,taskId:C.id,params:{}}),children:[s.jsx("span",{children:C.title}),op[C.input]!==""&&s.jsx("span",{className:"badge",children:op[C.input]})]},C.id))]},E.scriptId)),s.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:Sl("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:Sl("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:Sl("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),s.jsx("button",{className:"palette-item",onClick:()=>F({id:Sl("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),s.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),s.jsxs("div",{className:"pipeline-canvas",children:[s.jsxs(h6,{nodes:N,edges:R,nodeTypes:W6,onNodesChange:D,onConnect:P,onNodeClick:(E,C)=>{g(C.id),y(null)},onEdgeClick:(E,C)=>{y(Number(C.id.slice(1))),g(null)},onPaneClick:()=>{g(null),y(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[s.jsx(v6,{gap:20}),s.jsx(S6,{showInteractive:!1})]}),!t.nodes.some(E=>!Wi(E))&&s.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),s.jsxs("aside",{className:"pipeline-inspector",children:[W!==void 0&&s.jsx(Y6,{client:e,node:W,pipeline:t,run:r,scripts:p,onChange:O,onTasksChanged:()=>d(E=>E+1),runFrom:o,onRemove:()=>{n({...t,nodes:t.nodes.filter(E=>E.id!==W.id),edges:t.edges.filter(E=>E.from!==W.id&&E.to!==W.id)}),g(null)}}),M!==void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:"连线"}),s.jsxs("p",{className:"muted small",children:["「",((T=t.nodes.find(E=>E.id===M.from))==null?void 0:T.title)??M.from,"」→「",((Z=t.nodes.find(E=>E.id===M.to))==null?void 0:Z.title)??M.to,"」"]}),s.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),s.jsx(yn,{id:"edge-when",value:M.when,onChange:E=>n({...t,edges:t.edges.map((C,$)=>$===v?{...C,when:E}:C)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>{n({...t,edges:t.edges.filter((E,C)=>C!==v)}),y(null)},children:"删除连线"})]}),W===void 0&&M===void 0&&(c??s.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除。"})),(W!==void 0||M!==void 0)&&c!==void 0&&s.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{g(null),y(null)},children:"← 流水线设置"})]})]})}function K6({client:e,value:t,onChange:n}){const r=b.useRef(null),i=uw({client:e,text:t,setText:n,area:r,placement:"below"});return s.jsxs("div",{className:"slash-anchor",children:[s.jsx("textarea",{id:"node-prompt",ref:r,className:"text-input plain",rows:4,value:t,placeholder:"例如:/game-arknights 看看活动商店还剩什么没换",onChange:o=>n(o.target.value),onKeyDown:o=>{i.onKeyDown(o)}}),i.menu,s.jsx("p",{className:"muted small",children:"输入 / 可以选命令或技能,运行时展开成完整的指令。"})]})}function Y6({client:e,node:t,pipeline:n,run:r,scripts:i,onChange:o,onRemove:c,onTasksChanged:u,runFrom:f}){var y,S;const[d,p]=b.useState(null),m=r==null?void 0:r.nodes[t.id],g=t.kind==="script-task"?(y=i.find(k=>k.scriptId===t.scriptId))==null?void 0:y.tasks.find(k=>k.id===t.taskId):void 0,v=t.onFailure;return Wi(t)?s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Lo[t.kind]}),s.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(m==null?void 0:m.detail)!==void 0&&s.jsx("div",{className:"muted small",children:m.detail})]}):s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Lo[t.kind]}),s.jsx("label",{className:"field-label",htmlFor:"node-title",children:"名称(可选)"}),s.jsx("input",{id:"node-title",className:"text-input plain",value:t.title??"",maxLength:60,onChange:k=>{const{title:w,...A}=t;o(k.target.value===""?A:{...A,title:k.target.value})}}),t.kind==="script-task"&&s.jsx(xN,{id:"node-profile",label:"用哪份配置",list:((S=i.find(k=>k.scriptId===t.scriptId))==null?void 0:S.profiles)??null,value:t.profile,onChange:k=>{const{profile:w,...A}=t;o(k===void 0?A:{...A,profile:k})}}),t.kind==="script-task"&&g!==void 0&&Object.entries(g.params).map(([k,w])=>s.jsx(mN,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:k,spec:w,profile:t.profile,value:String(t.params[k]??(w.type==="boolean"?w.default??!1:"")),onCreated:u,onChange:A=>{const{[k]:N,...R}=t.params,D=w.type==="boolean"?A==="true":w.type==="integer"||w.type==="number"?Number(A):A;o({...t,params:A===""?R:{...R,[k]:D}})}},k)),t.kind==="agent"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),s.jsx(K6,{client:e,value:t.prompt,onChange:k=>o({...t,prompt:k})})]}),(t.kind==="notify"||t.kind==="gate")&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-text",children:t.kind==="notify"?"消息内容":"确认时显示的话"}),s.jsx("textarea",{id:"node-text",className:"text-input plain",rows:3,value:t.text,onChange:k=>o({...t,text:k.target.value})})]}),t.kind==="wait"&&s.jsxs("div",{className:"key-input",children:[s.jsx(yn,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:k=>o(k==="minutes"?{id:t.id,kind:"wait",minutes:10,...t.title===void 0?{}:{title:t.title},...t.position===void 0?{}:{position:t.position}}:{id:t.id,kind:"wait",until:"05:00",...t.title===void 0?{}:{title:t.title},...t.position===void 0?{}:{position:t.position}})}),t.minutes!==void 0?s.jsx("input",{className:"text-input plain",type:"number",min:1,max:1440,value:t.minutes,onChange:k=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(k.target.value)||1)))})}):s.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:k=>o({...t,until:k.target.value})})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:k=>{const{waitForAll:w,...A}=t;o(k.target.checked?{...A,waitForAll:!0}:A)}}),"等前面的节点全部结束再开始"]}),s.jsx("p",{className:"muted small",children:"不只等连进来的线:画布上不在它后面的节点(其他分支也算)都结束了(成功、失败、跳过都算)才开始。用来让并行的几条分支汇合。"}),t.kind!=="gate"&&t.kind!=="notify"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-retries",children:"失败时"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(yn,{id:"node-retries","aria-label":"重试次数",value:v===void 0?"inherit":String(v.retries),options:[{value:"inherit",label:"按流水线的设置"},...lS],onChange:k=>{const{onFailure:w,...A}=t;if(k==="inherit")return o(A);o({...A,onFailure:{retries:Number(k),then:(v==null?void 0:v.then)??n.onFailure.then}})}}),s.jsx(yn,{"aria-label":"仍失败时",disabled:v===void 0,value:(v??n.onFailure).then,options:cS,onChange:k=>o({...t,onFailure:{retries:(v==null?void 0:v.retries)??n.onFailure.retries,then:k}})})]}),v===void 0&&s.jsxs("p",{className:"muted small",children:["流水线的设置:",n.onFailure.retries>0?`重试 ${n.onFailure.retries} 次,`:"不重试,","然后",n.onFailure.then==="stop"?"停止流水线":"继续其他分支"]})]}),m!==void 0&&s.jsxs("div",{className:"inspector-run",children:[s.jsx("div",{className:"sidebar-label",children:"这次运行"}),s.jsxs("div",{children:[um[m.state],m.attempts>1?` · 第 ${m.attempts} 次`:""]}),m.detail!==void 0&&s.jsx("div",{className:"muted small",children:m.detail}),m.runIds.length>0&&s.jsxs("div",{className:"muted small",children:["脚本运行:",m.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&m.state==="running"&&r!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:r.id,nodeId:t.id,decision:"continue"}).catch(k=>p(ze(k))),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:r.id,nodeId:t.id,decision:"stop"}).catch(k=>p(ze(k))),children:"停止"})]})]}),d!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]}),f!==void 0&&s.jsxs("div",{className:"run-from",children:[s.jsxs("button",{className:"small-button",onClick:()=>f(t.id),children:[s.jsx(ee,{name:"arrow"}),"从这里开始运行"]}),s.jsx("span",{className:"muted small",children:"这一步和它后面的会运行,前面的不运行(例如前面已经跑过了)"})]}),s.jsx("button",{className:"danger-outline small-button",onClick:c,children:"删除这个节点"})]})}const cd={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},X6=()=>({id:`pipeline-${Date.now().toString(36)}`,name:"新流水线",nodes:[{id:"start",kind:"start",position:{x:40,y:120}},{id:"end",kind:"end",position:{x:360,y:120}}],edges:[],onFailure:{retries:0,then:"continue"},schedule:{enabled:!1,times:[],days:[],catchUpMinutes:10},stopEmulatorAfter:!1,closeGameAfter:!1,powerAfter:"none"});function Q6({client:e,openSettings:t,arg:n}){const r=je(e.connection.status),i=Cn(3e4),[o,c]=b.useState(null),[u,f]=b.useState(null),[d,p]=b.useState(null),[m,g]=b.useState(""),[v,y]=b.useState([]),[S,k]=b.useState(null),[w,A]=b.useState(null),[N,R]=b.useState(null),[D,P]=b.useState(null),[F,W]=b.useState(0);b.useEffect(()=>e.connection.on("pipelines/changed",()=>W(ie=>ie+1)),[e]);const M=je(e.capabilities),[O,T]=b.useState(null),[Z,E]=b.useState(0);b.useEffect(()=>e.connection.on("schedule/changed",()=>E(ie=>ie+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!M.has("schedule"))return;let ie=!0;return e.connection.call("schedule/status",{}).then(ke=>{ie&&T(ke.settings)}).catch(()=>{}),()=>{ie=!1}},[e,r.state,M,Z]);const C=async ie=>{try{T((await e.connection.call("schedule/settings/set",ie)).settings)}catch(ke){P(ze(ke))}};b.useEffect(()=>{n!==void 0&&f(n)},[n]),b.useEffect(()=>{if(r.state!=="open")return;let ie=!0;return e.connection.call("pipelines/list",{}).then(ke=>{ie&&(c(ke.items),f(ae=>{var Ne;return ae??((Ne=ke.items[0])==null?void 0:Ne.id)??null}))}).catch(ke=>{ie&&P(ze(ke))}),()=>{ie=!1}},[e,r.state,F]),b.useEffect(()=>{if(u===null||r.state!=="open"||(d==null?void 0:d.id)===u&&(o!=null&&o.every(ke=>ke.id!==u)))return;let ie=!0;return e.connection.call("pipelines/get",{id:u}).then(ke=>{if(!ie)return;const ae=PT(ke);p(ae),g(JSON.stringify(ae)),A(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(ke=>{ie&&y(ke.items)}).catch(()=>{}),k(null),()=>{ie=!1}},[e,u,r.state,F]),b.useEffect(()=>e.connection.on("pipelines/run",ie=>{ie.pipelineId===u&&y(ke=>[ie,...ke.filter(ae=>ae.id!==ie.id)].sort((ae,Ne)=>Ne.startedAt-ae.startedAt).slice(0,10))}),[e,u]);const $=d!==null&&JSON.stringify(d)!==m,L=d!==null&&o!==null&&o.every(ie=>ie.id!==d.id),B=v.find(ie=>{var ke;return ie.id===(S??((ke=v[0])==null?void 0:ke.id))}),H=v.find(ie=>ie.state==="running"),G=H!==void 0&&(H.stopping!==void 0||N==="cancel");b.useEffect(()=>{if(d===null||!d.nodes.some(ke=>!Wi(ke))){A(null);return}const ie=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:d}).then(A).catch(()=>{})},400);return()=>clearTimeout(ie)},[e,d]);const K=async(ie,ke)=>{R(ie),P(null);try{await ke()}catch(ae){P(ze(ae))}finally{R(null)}},V=()=>K("save",async()=>{if(d===null)return;const ie=await e.connection.call("pipelines/save",{pipeline:d});p(ie.pipeline),g(JSON.stringify(ie.pipeline)),A(ie.check),f(ie.pipeline.id)}),Y=ie=>K("run",async()=>{if(d===null)return;($||L)&&await V();const ke=await e.connection.call("pipelines/run",{id:d.id,...ie===void 0?{}:{from:ie}});k(ke.id)}),fe=()=>K("remove",async()=>{d!==null&&(L||await e.connection.call("pipelines/remove",{id:d.id}),p(null),f(null))}),xe=b.useCallback(ie=>p(ie),[]),ge=()=>{const ie=X6();p(ie),g(""),f(ie.id),y([]),A(null)};return s.jsxs("section",{className:"main scripts-page pipelines-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"编排"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"流水线"})]}),s.jsx(tB,{list:o??[],current:d,isNew:L,now:i,onPick:f}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("schedule"),children:[s.jsx(ee,{name:"settings"}),"定时与自启"]}),s.jsxs("button",{className:"primary small-button",onClick:ge,children:[s.jsx(ee,{name:"plus"}),"新建流水线"]})]})]}),s.jsx("div",{className:"pipeline-main",children:d===null?s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"flow"}),o!==null&&o.length===0?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"还没有流水线。"}),s.jsx("p",{className:"muted small",children:"新建一条,或对 agent 说「先跑方舟日常,同时跑三月七,都完了发飞书」"})]}):s.jsx("p",{children:"在上面选一条流水线,或新建一条。"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"pipeline-toolbar",children:[s.jsx("input",{className:"text-input plain pipeline-name",value:d.name,maxLength:60,"aria-label":"流水线名称",onChange:ie=>p({...d,name:ie.target.value})}),d.draft===!0&&s.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),$&&s.jsx("span",{className:"muted small",children:"未保存"}),s.jsx("span",{className:"spacer"}),G?s.jsxs("button",{className:"danger-outline small-button stopping",disabled:!0,"aria-busy":"true",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),"正在停止…"]}):H!==void 0?s.jsx("button",{className:"danger-outline small-button",disabled:N!==null,onClick:()=>void K("cancel",()=>e.connection.call("pipelines/cancel",{runId:H.id})),children:"取消运行"}):s.jsxs("button",{className:"small-button",disabled:N!==null||!d.nodes.some(ie=>!Wi(ie))||(w==null?void 0:w.ok)===!1,onClick:()=>void Y(),children:[s.jsx(ee,{name:"arrow"}),"运行"]}),s.jsx("button",{className:"primary small-button",disabled:N!==null||!$&&!L&&d.draft!==!0,onClick:()=>void V(),children:N==="save"?"保存中…":d.draft===!0&&!$?"确认并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:N!==null||H!==void 0,onClick:()=>{confirm(`删除流水线「${d.name}」?`)&&fe()},children:"删除"})]}),G&&s.jsxs("div",{className:"notice info left small pipeline-stopping",role:"status",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),s.jsxs("span",{children:["已收到停止指令。",H.stopping??"正在通知正在运行的步骤…"]})]}),D!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:D})]}),s.jsx(G6,{client:e,pipeline:d,onChange:xe,run:B,check:w,runFrom:H!==void 0||N!==null||(w==null?void 0:w.ok)===!1?void 0:ie=>void Y(ie),idle:s.jsx(nB,{pipeline:d,check:w,runs:v,shownRun:B==null?void 0:B.id,onShowRun:k,others:o??[],onChange:xe,now:i,startup:O,onStartup:ie=>void C(ie)})},d.id)]})})]})}function J6({check:e,pipeline:t}){if(e===null)return null;const n=r=>{const i=t.nodes.find(o=>o.id===r);return i===void 0?"":`${i.title??i.id}:`};return s.jsxs("section",{className:"side-pane",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行前检查"}),s.jsx("p",{className:"muted small",children:e.estimateMinutes===void 0?"部分任务没有预计时长":`预计约 ${e.estimateMinutes} 分钟`})]}),s.jsx("span",{className:`badge ${e.ok?"ok":"warn"}`,children:e.ok?"可以运行":"有问题"})]}),e.issues.length===0&&s.jsx("div",{className:"muted small",children:"没有发现问题。"}),s.jsx("ul",{className:"incident-steps",children:e.issues.map((r,i)=>s.jsxs("li",{className:r.level==="error"||r.level==="warning"?"failed":"",children:[r.level==="error"?"✗":r.level==="warning"?"!":"ℹ"," ",n(r.nodeId),r.message]},i))})]})}function eB({runs:e,shown:t,onShow:n,now:r}){if(e.length===0)return s.jsx("section",{className:"side-pane",children:s.jsx("p",{className:"muted small",children:"还没有运行过。"})});const i={manual:"手动",schedule:"定时",autostart:"启动时",agent:"agent",after:"接续"};return s.jsxs("section",{className:"side-pane",children:[s.jsx("div",{className:"run-history",children:e.map(o=>s.jsxs("button",{className:`run-row ${o.id===t?"active":""}`,onClick:()=>n(o.id),children:[s.jsx("span",{className:`badge ${cd[o.state][0]}`,children:cd[o.state][1]}),s.jsx("span",{className:"run-title",children:i[o.trigger.kind]??o.trigger.kind}),s.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),s.jsx("span",{className:"session-time",children:Tt(o.startedAt,r)})]},o.id))}),s.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function tB({list:e,current:t,isNew:n,now:r,onPick:i}){const[o,c]=b.useState(!1),u=b.useRef(null);return b.useEffect(()=>{if(!o)return;const f=d=>{u.current!==null&&!u.current.contains(d.target)&&c(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[o]),e.length===0&&t===null?s.jsx("span",{className:"spacer"}):s.jsxs("div",{className:"pipeline-switcher",ref:u,children:[s.jsxs("button",{className:"small-button switcher-button","aria-haspopup":"listbox","aria-expanded":o,onClick:()=>c(f=>!f),children:[s.jsx(ee,{name:"flow"}),s.jsxs("span",{className:"switcher-name",children:[(t==null?void 0:t.name)??"选择流水线",n?"(未保存)":""]}),s.jsxs("span",{className:"muted small",children:[e.length," 条"]}),s.jsx(ee,{name:"chevron-down"})]}),o&&s.jsxs("div",{className:"switcher-menu",role:"listbox","aria-label":"流水线",children:[e.map(f=>s.jsxs("button",{role:"option","aria-selected":f.id===(t==null?void 0:t.id),className:`switcher-item ${f.id===(t==null?void 0:t.id)&&!n?"active":""}`,onClick:()=>{i(f.id),c(!1)},children:[s.jsxs("span",{className:"switcher-item-main",children:[s.jsx("span",{children:f.name}),s.jsxs("span",{className:"muted small",children:[f.nodes," 个步骤",f.schedule.enabled&&f.schedule.times.length>0?` · 每天 ${f.schedule.times.join("、")}`:"",f.lastRun===void 0?"":` · ${Tt(f.lastRun.startedAt,r)}`]})]}),f.draft?s.jsx("span",{className:"badge warn",children:"草稿"}):f.lastRun!==void 0?s.jsx("span",{className:`badge ${cd[f.lastRun.state][0]}`,children:cd[f.lastRun.state][1]}):null]},f.id)),e.length===0&&s.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function nB({pipeline:e,check:t,runs:n,shownRun:r,onShowRun:i,others:o,onChange:c,now:u,startup:f,onStartup:d}){const[p,m]=b.useState(n.some(v=>v.state==="running")?"runs":"check"),g=(t==null?void 0:t.issues.filter(v=>v.level==="error").length)??0;return s.jsxs("div",{className:"pipeline-side",children:[s.jsxs("nav",{className:"tabs side-tabs",role:"tablist","aria-label":"流水线",children:[s.jsxs("button",{role:"tab","aria-selected":p==="check",className:p==="check"?"active":"",onClick:()=>m("check"),children:["检查",g>0?` · ${g}`:""]}),s.jsx("button",{role:"tab","aria-selected":p==="runs",className:p==="runs"?"active":"",onClick:()=>m("runs"),children:"运行记录"}),s.jsx("button",{role:"tab","aria-selected":p==="schedule",className:p==="schedule"?"active":"",onClick:()=>m("schedule"),children:"定时与失败"})]}),p==="check"&&(t===null?s.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):s.jsx(J6,{check:t,pipeline:e})),p==="runs"&&s.jsx(eB,{runs:n,shown:r,onShow:i,now:u}),p==="schedule"&&s.jsx(rB,{pipeline:e,others:o,onChange:c,startup:f,onStartup:d}),s.jsx("p",{className:"muted small pad",children:"点画布上的节点或连线来修改它;选中后按 Delete 删除。"})]})}const sB=["日","一","二","三","四","五","六"],jb={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function rB({pipeline:e,others:t,onChange:n,startup:r,onStartup:i}){const o=(r==null?void 0:r.autostartPipelines.includes(e.id))===!0,c=e.schedule,[u,f]=b.useState(c.times.join(","));b.useEffect(()=>f(c.times.join(",")),[e.id]);const d=g=>n({...e,schedule:{...c,...g}}),p=b.useMemo(()=>u.split(/[,,\s]+/).map(g=>g.trim()).filter(Boolean).map(g=>/^\d:\d\d$/.test(g)?`0${g}`:g),[u]),m=p.filter(g=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(g));return s.jsxs("section",{className:"side-pane",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,onChange:g=>d({enabled:g.target.checked})}),"按定时自动运行",e.draft===!0?"(草稿要先保存)":""]}),s.jsx("label",{className:"field-label",htmlFor:"pl-times",children:"时间(24 小时制,多个用逗号分开)"}),s.jsx("input",{id:"pl-times",className:"text-input",value:u,placeholder:"04:30,16:30",onChange:g=>f(g.target.value),onBlur:()=>{m.length===0&&d({times:[...new Set(p)].sort()})}}),m.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["时间写成 HH:MM:",m.join("、")]})]}),s.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[sB.map((g,v)=>s.jsxs("button",{className:`chip ${c.days.includes(v)?"active":""}`,onClick:()=>d({days:c.days.includes(v)?c.days.filter(y=>y!==v):[...c.days,v].sort()}),children:["周",g]},g)),s.jsx("span",{className:"muted small",children:c.days.length===0?"不选=每天":""})]}),r!==null&&s.jsxs("div",{className:"startup-box",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:o,disabled:e.draft===!0,onChange:g=>i({autostartPipelines:g.target.checked?[...r.autostartPipelines,e.id]:r.autostartPipelines.filter(v=>v!==e.id)})}),"软件启动时运行",e.draft===!0?"(草稿要先保存)":""]}),o&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:r.firstStartOnly,onChange:g=>i({firstStartOnly:g.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:r.skipIfRanToday,onChange:g=>i({skipIfRanToday:g.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),s.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",r.autostart?`开机自启时等 ${r.autostartDelaySeconds} 秒、自己打开时等 10 秒`:"等 10 秒","再运行;dsh 崩溃后自动重启不算。和游戏一样,每天从 4:00 算起:凌晨 2 点启动还算前一天。这两项对所有「软件启动时运行」的流水线生效。"]})]})]}),s.jsx("label",{className:"field-label",htmlFor:"pl-catchup",children:"错过多少分钟以内还补跑(睡眠、刚开机)"}),s.jsx("input",{id:"pl-catchup",className:"text-input plain",type:"number",min:0,max:720,value:c.catchUpMinutes,onChange:g=>d({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(g.target.value)||0)))})}),s.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),s.jsx(yn,{id:"pl-after",value:c.after??"",onChange:g=>{const{after:v,...y}=c;n({...e,schedule:g===""?y:{...y,after:g}})},options:[{value:"",label:"不接续"},...t.filter(g=>g.id!==e.id).map(g=>({value:g.id,label:g.name}))]}),s.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(yn,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:lS,onChange:g=>n({...e,onFailure:{...e.onFailure,retries:Number(g)}})}),s.jsx(yn,{"aria-label":"仍失败时",value:e.onFailure.then,options:cS,onChange:g=>n({...e,onFailure:{...e.onFailure,then:g}})})]}),s.jsx("div",{className:"field-label",children:"结束后"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:g=>n({...e,closeGameAfter:g.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:g=>n({...e,stopEmulatorAfter:g.target.checked})}),"关闭模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),s.jsx(yn,{id:"pl-power",value:e.powerAfter,onChange:g=>n({...e,powerAfter:g}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&s.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",r===null?"":` ${r.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",jb[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",jb[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const Sb=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),_b={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function iB({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(0),[u,f]=b.useState(!1),[d,p]=b.useState(null);b.useEffect(()=>e.connection.on("schedule/changed",()=>c(v=>v+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/changed",()=>c(v=>v+1)),[e]),b.useEffect(()=>e.connection.on("schedule/power",v=>i(y=>y===null?y:{...y,power:v})),[e]),b.useEffect(()=>{if(t.state!=="open")return;let v=!0;return e.connection.call("schedule/status",{}).then(y=>{v&&i(y)}).catch(y=>{v&&p(ze(y))}),()=>{v=!1}},[e,t.state,o]);const m=async v=>{f(!0),p(null);try{i(await e.connection.call("schedule/settings/set",v))}catch(y){p(ze(y))}finally{f(!1)}},g=r==null?void 0:r.settings;return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"定时与自启"}),s.jsx("p",{children:"每条流水线的运行时间和结束后做什么(关游戏、关模拟器、睡眠或关机)在「编排」页里设置。这里设置电脑开机登录后是否自动启动 MultiGameAssistant,以及电脑睡着时要不要按时醒来。关掉窗口后程序在托盘里继续运行,定时照常执行。"}),r!==null&&g!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"开机自启"}),s.jsx("p",{className:"muted small",children:r.autostart.detail??(r.autostart.registered?"已在 Windows 任务计划程序中注册(登录后启动,最小化到托盘)":"登录 Windows 后自动启动并最小化到托盘")})]}),s.jsx("span",{className:`badge ${r.autostart.registered?"ok":""}`,children:r.autostart.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:g.autostart,disabled:u||!r.autostart.available,onChange:v=>void m({autostart:v.target.checked})}),"登录 Windows 后自动启动"]}),s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:["软件启动时运行哪些流水线、是否只在每天第一次启动时运行,在「编排」页每条流水线的「定时与失败」里设置。",g.autostartPipelines.length>0?`现在有 ${g.autostartPipelines.length} 条。`:""]})]}),s.jsx("label",{className:"field-label",htmlFor:"autostart-delay",children:"开机自启后等待多少秒再运行流水线(等网络、桌面和显卡驱动就绪)"}),s.jsx("input",{id:"autostart-delay",className:"text-input plain",type:"number",min:0,max:1800,defaultValue:g.autostartDelaySeconds,onBlur:v=>void m({autostartDelaySeconds:Math.max(0,Math.min(1800,Math.round(Number(v.target.value)||0)))})}),r.autostarted&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:"这次是开机自动启动的。"})]})]}),r!==null&&g!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"定时唤醒"}),s.jsx("p",{className:"muted small",children:r.wake.detail??(r.wake.registered&&r.wake.next!==void 0?`已在 Windows 任务计划程序中注册,下次在 ${Sb(r.wake.next)} 唤醒`:"电脑睡眠(或休眠)时,在定时任务开始前 2 分钟把它唤醒")})]}),s.jsx("span",{className:`badge ${r.wake.registered?"ok":""}`,children:r.wake.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:g.wakeToRun,disabled:u||!r.wake.available,onChange:v=>void m({wakeToRun:v.target.checked})}),"睡眠时按定时唤醒电脑"]}),s.jsx("p",{className:"muted small",children:"关机后不能唤醒。程序没开着时,唤醒会顺便把它在托盘里打开(不运行「软件启动时运行」的流水线)。要在 Windows 电源选项里允许唤醒定时器:控制面板 → 电源选项 → 更改计划设置 → 更改高级电源设置 → 睡眠 → 允许使用唤醒定时器 → 启用(笔记本的「使用电池」也要改)。"}),s.jsx("h3",{children:"运行时防睡眠"}),s.jsxs("p",{className:"muted small",children:["流水线或脚本运行时,电脑不会自己睡眠;前台脚本(用鼠标键盘的)运行时屏幕也保持亮着。全部结束后恢复 Windows 自己的设置。",r.power.awake?"现在正在防睡眠。":""]}),s.jsx("label",{className:"field-label",htmlFor:"power-countdown",children:"流水线结束后睡眠、休眠或关机前倒计时多少秒(这段时间里可以取消)"}),s.jsx("input",{id:"power-countdown",className:"text-input plain",type:"number",min:10,max:600,defaultValue:g.powerCountdownSeconds,onBlur:v=>void m({powerCountdownSeconds:Math.max(10,Math.min(600,Math.round(Number(v.target.value)||60)))})})]}),r!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"接下来"}),r.upcoming.length===0&&s.jsx("div",{className:"muted small",children:"没有开启定时的流水线。"}),s.jsx("ul",{className:"version-list",children:r.upcoming.map((v,y)=>s.jsxs("li",{children:[s.jsx("span",{className:"version-name",children:Sb(v.at)}),s.jsx("span",{children:v.pipelineName})]},y))})]}),r!==null&&r.history.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"最近的定时记录"}),s.jsx("ul",{className:"version-list",children:r.history.map((v,y)=>{var S,k;return s.jsxs("li",{children:[s.jsx("span",{className:`badge ${((S=_b[v.outcome])==null?void 0:S[0])??""}`,children:((k=_b[v.outcome])==null?void 0:k[1])??v.outcome}),s.jsx("span",{children:v.pipelineName}),s.jsxs("span",{className:"muted small",children:[v.slot,v.detail===void 0?"":` · ${v.detail}`]}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:Tt(v.at,n)})]},y)})})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"无人值守检查清单"}),s.jsxs("ul",{className:"guide-steps",children:[s.jsxs("li",{children:["前台脚本(如三月七)需要已登录、没有锁屏的桌面:在 Windows 里设置自动登录(运行 ",s.jsx("code",{children:"netplwiz"}),"),关闭屏幕保护程序;睡眠唤醒后不要求登录(设置 → 帐户 → 登录选项 →「需要登录」选「从不」)。"]}),s.jsx("li",{children:"模拟器脚本(如 MAA)不受锁屏影响。"}),s.jsx("li",{children:"运行期间程序会阻止电脑睡眠;想让睡着的电脑按时醒来跑定时任务,打开上面的「定时唤醒」。关机后的电脑不能被唤醒,可以在主板 BIOS 里设置定时开机,再配合开机自启。"}),s.jsx("li",{children:"没接显示器时,游戏可能以很小的分辨率启动;可以接一个 HDMI 假负载(显卡欺骗器)。"}),s.jsx("li",{children:"想在手机上收到结果,先在「设置 → 飞书」接好飞书。"})]})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]})]})}const aB={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:Q6}]},oB={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:iB}]},lp=new Map;function uS(e,t){let n=lp.get(t);return n===void 0&&(n=e.connection.call("games/image",{url:t}).then(r=>`data:${r.mediaType};base64,${r.data}`),n.catch(()=>lp.delete(t)),lp.set(t,n)),n}function lB(e,t){const[n,r]=b.useState(void 0),i=t.filter(o=>o!==void 0).filter((o,c,u)=>u.indexOf(o)===c);return b.useEffect(()=>{r(void 0);let o=!0;return(async()=>{for(const c of i){const u=await uS(e,c).catch(()=>{});if(u!==void 0){o&&r(u);return}}})(),()=>{o=!1}},[e,i.join(`
221
- `)]),n}function dg(e,t){const[n,r]=b.useState(void 0);return b.useEffect(()=>{if(r(void 0),t===void 0)return;let i=!0;return uS(e,t).then(o=>{i&&r(o)},()=>{}),()=>{i=!1}},[e,t]),n}const dS=["image/png","image/jpeg","image/gif","image/webp","image/avif"],cB=8*1024*1024;function dm(e,t){const n=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)).map(r=>[r.type,Number(r.value)]));return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3}function uB(e){var n;return(((n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date).find(r=>r.type==="timeZoneName"))==null?void 0:n.value)??"").replace("GMT","UTC")||e}function Eb(e,t){return e===void 0?"":new Date(e+dm(e,t)).toISOString().slice(0,16)}function Cb(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);if(n===null)return;const r=Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]),Number(n[4]),Number(n[5]));return r-dm(r-dm(r,t),t)}function dB(e){return new Promise((t,n)=>{if(!dS.includes(e.type)){n(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>cB){n(new Error("图片太大(最多 8 MB)"));return}const r=new FileReader;r.onload=()=>{const i=String(r.result);t({image:{mediaType:e.type,data:i.slice(i.indexOf(",")+1)},src:i})},r.onerror=()=>n(new Error("图片读不出来")),r.readAsDataURL(e)})}function fS({client:e,game:t,activity:n,onDone:r,onCancel:i}){var O;const o=t.timezone,c={name:(n==null?void 0:n.name)??"",kind:(n==null?void 0:n.kind)??"",startsAt:Eb(n==null?void 0:n.startsAt,o),endsAt:Eb(n==null?void 0:n.endsAt,o),url:(n==null?void 0:n.url)??"",description:(n==null?void 0:n.description)??""},[u,f]=b.useState(c),[d,p]=b.useState(null),[m,g]=b.useState(!1),[v,y]=b.useState(!1),[S,k]=b.useState(null),w=b.useRef(null),A=((O=n==null?void 0:n.own)==null?void 0:O.fields.includes("cover"))===!0,N=dg(e,m||n==null?void 0:n.cover),R=(d==null?void 0:d.src)??N,D=n!==void 0&&(n.sources!==void 0||n.screen!==void 0);b.useEffect(()=>{k(null)},[u]);const P=T=>Z=>f(E=>({...E,[T]:Z.target.value})),F=T=>{T!==void 0&&dB(T).then(Z=>{p(Z),g(!1)},Z=>k(ze(Z)))},W=T=>{const Z=[...T.clipboardData.files].find(E=>E.type.startsWith("image/"));Z!==void 0&&(T.preventDefault(),F(Z))},M=async()=>{if(u.name.trim()===""){k("活动要有名字");return}const T=u.startsAt===""?null:Cb(u.startsAt,o)??null,Z=u.endsAt===""?null:Cb(u.endsAt,o)??null;if(T!==null&&Z!==null&&Z<=T){k("结束时间要晚于开始时间");return}const E=L=>n===void 0||u[L]!==c[L],C=L=>E(L)?{[L]:u[L].trim()===""?null:u[L].trim()}:{},$={game:t.id,...n===void 0?{}:{activityId:n.id},...C("name"),...C("kind"),...C("url"),...C("description"),...E("startsAt")?{startsAt:T}:{},...E("endsAt")?{endsAt:Z}:{},...d!==null?{image:d.image}:m?{cover:null}:{}};y(!0),k(null);try{r(await e.connection.call("games/activity/save",$))}catch(L){k(ze(L))}finally{y(!1)}};return s.jsxs("form",{className:"activity-editor",onSubmit:T=>{T.preventDefault(),M()},onPaste:W,onKeyDown:T=>{T.key==="Escape"&&i()},children:[s.jsxs("div",{className:"activity-editor-head",children:[s.jsx("strong",{children:n===void 0?`添加${t.name}的活动`:"编辑活动"}),D&&s.jsx("span",{className:"muted small",children:"你改的内容比数据站优先,刷新不会改掉;没改的照来源走。"})]}),s.jsxs("div",{className:"activity-editor-body",children:[s.jsxs("div",{className:"activity-editor-image",children:[s.jsx("button",{type:"button",className:`activity-image-pick ${R===void 0?"empty":""}`,onClick:()=>{var T;return(T=w.current)==null?void 0:T.click()},title:"选一张图片(也可以直接粘贴)",children:R!==void 0?s.jsx("img",{src:R,alt:""}):s.jsxs(s.Fragment,{children:[s.jsx(ee,{name:"image"}),s.jsx("span",{children:"选图片"}),s.jsx("small",{children:"或粘贴"})]})}),s.jsx("input",{ref:w,type:"file",accept:dS.join(","),hidden:!0,onChange:T=>{var Z;F((Z=T.target.files)==null?void 0:Z[0]),T.target.value=""}}),(d!==null||A&&!m)&&s.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{p(null),A&&g(!0)},children:d!==null?"不用这张":D?"用回来源的图":"去掉图片"})]}),s.jsxs("div",{className:"activity-editor-fields",children:[s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field wide",children:[s.jsx("span",{className:"field-title",children:"活动名"}),s.jsx("input",{className:"text-input plain",autoFocus:n===void 0,maxLength:60,value:u.name,onChange:P("name"),placeholder:"例如:周年庆签到"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"类型"}),s.jsx("input",{className:"text-input plain",maxLength:20,value:u.kind,onChange:P("kind"),placeholder:"签到、SideStory…"})]})]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"开始"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.startsAt,onChange:P("startsAt")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"结束"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.endsAt,onChange:P("endsAt")})]})]}),s.jsxs("span",{className:"muted small",children:["时间按游戏服务器时间(",uB(o),")",u.endsAt===""?";不填结束时间的会一直留着,直到你去掉它":""]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"活动页面(可选)"}),s.jsx("input",{className:"text-input plain",type:"url",value:u.url,onChange:P("url"),placeholder:"https://…"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"说明(可选)"}),s.jsx("textarea",{className:"text-input plain",rows:2,maxLength:500,value:u.description,onChange:P("description"),placeholder:"要做什么、奖励是什么"})]})]})]}),s.jsxs("div",{className:"activity-editor-actions",children:[s.jsx("button",{className:"small-button primary",type:"submit",disabled:v,children:v?"保存中…":n===void 0?"添加":"保存"}),s.jsx("button",{className:"small-button",type:"button",disabled:v,onClick:i,children:"取消"}),S!==null&&s.jsx("span",{className:"tone-error small",children:S})]})]})}const fr=864e5,Ib={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},cp=2,fB=28,Fl=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],Ab="adg:games:overview:shown",Tb="adg:games:overview:mode";function $b(e,t){try{const n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function Mb(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function gr(e){const t=e.todo.length+e.done.length;return e.finished!==void 0?{state:"finished",done:t,total:t}:t===0?{state:"unknown",done:0,total:0}:{state:e.todo.length===0?"finished":"partial",done:e.done.length,total:t}}function hB(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function up(e,t){const n=e-t;return n<=0?"已结束":n<fr?`${Math.max(1,Math.floor(n/36e5))} 小时`:`${Math.floor(n/fr)} 天`}function pB({client:e,games:t,activities:n,now:r,soonDays:i,onOpenGame:o,onChanged:c}){const[u,f]=b.useState(()=>$b(Ab,null)),[d,p]=b.useState(()=>$b(Tb,"time")),[m,g]=b.useState(null);b.useEffect(()=>Mb(Ab,u),[u]),b.useEffect(()=>Mb(Tb,d),[d]);const v=b.useMemo(()=>new Map(t.map((T,Z)=>[T.id,Fl[Z%Fl.length]])),[t]),y=T=>u===null||u.includes(T),S=T=>f(Z=>{const E=Z??t.map($=>$.id),C=E.includes(T)?E.filter($=>$!==T):[...E,T];return C.length===t.length?null:C}),k=new Date(r-cp*fr).setHours(0,0,0,0),w=k+(cp+fB)*fr,A=T=>Math.min(100,Math.max(0,(T-k)/(w-k)*100)),N=n.filter(T=>y(T.game)&&(T.endsAt===void 0||Math.max(T.endsAt,T.shopEndsAt??0)>r)),R=(T,Z)=>(T.endsAt??1/0)-(Z.endsAt??1/0)||T.name.localeCompare(Z.name),D=N.filter(T=>(T.startsAt??0)<=r),P=N.filter(T=>T.startsAt!==void 0&&T.startsAt>r).sort((T,Z)=>T.startsAt-Z.startsAt),F=[];if(d==="time"){const T=k+(cp+7)*fr,Z=D.filter($=>$.endsAt!==void 0&&$.endsAt-r<i*fr).sort(R),E=D.filter($=>!Z.includes($)&&$.endsAt!==void 0&&$.endsAt<T).sort(R),C=D.filter($=>!Z.includes($)&&!E.includes($)).sort(R);F.push({key:"soon",title:"快结束",hint:`${i} 天内`,rows:Z},{key:"week",title:"本周内结束",rows:E},{key:"later",title:"之后结束",rows:C},{key:"upcoming",title:"即将开始",rows:P})}else for(const T of t){if(!y(T.id))continue;const Z=[...D.filter(E=>E.game===T.id).sort(R),...P.filter(E=>E.game===T.id)];F.push({key:T.id,title:T.name,rows:Z,game:T})}const W=D.reduce((T,Z)=>{const E=gr(Z);return{...T,[E.state]:T[E.state]+1}},{finished:0,partial:0,unknown:0}),M=D.filter(T=>T.endsAt!==void 0&&T.endsAt-r<i*fr&&gr(T).state!=="finished").length,O=[];for(let T=k;T<=w;T+=fr){const Z=Math.round((T-new Date(r).setHours(0,0,0,0))/fr);O.push({at:T,...Z>0&&Z%7===0?{label:hB(T,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}return s.jsxs("div",{className:"games-overview",children:[s.jsxs("section",{className:"card games-overview-head",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"全部活动"}),s.jsxs("p",{className:"muted small",children:["进行中 ",D.length," 个 · ",s.jsxs("span",{className:M>0?"tone-warn":"",children:[M," 个快结束还没做完"]})," · 做完 ",W.finished," 个 · 做了一部分 ",W.partial," 个 · 没记录 ",W.unknown," 个"]})]}),s.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[s.jsx("button",{className:d==="time"?"active":"","aria-pressed":d==="time",onClick:()=>p("time"),children:"按时间"}),s.jsx("button",{className:d==="game"?"active":"","aria-pressed":d==="game",onClick:()=>p("game"),children:"按游戏"})]})]}),s.jsx("div",{className:"chip-row games-overview-games",role:"group","aria-label":"显示哪些游戏",children:t.map(T=>s.jsxs("button",{className:`chip chip-button game-chip ${y(T.id)?"active":""}`,style:{"--game":v.get(T.id)},"aria-pressed":y(T.id),onClick:()=>S(T.id),children:[s.jsx("span",{className:"game-dot"}),T.name]},T.id))})]}),s.jsx("section",{className:"card games-overview-board",children:s.jsxs("div",{className:"ov-grid",children:[s.jsxs("div",{className:"ov-row ov-axis","aria-hidden":"true",children:[s.jsx("div",{className:"ov-label"}),s.jsx("div",{className:"ov-track",children:O.map(T=>s.jsx("span",{className:`ov-tick ${T.label!==void 0?"major":""}`,style:{left:`${A(T.at)}%`},children:T.label!==void 0&&s.jsx("em",{children:T.label})},T.at))}),s.jsx("div",{className:"ov-side"})]}),F.every(T=>T.rows.length===0)&&s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"calendar"}),s.jsx("p",{children:t.length===0?"没有游戏。":"选中的游戏现在没有活动。点「刷新全部数据站」读取,或在上面多选几个游戏。"})]}),F.filter(T=>T.rows.length>0).map(T=>{var Z;return s.jsxs("div",{className:"ov-section",children:[s.jsxs("div",{className:"ov-section-title",children:[T.game!==void 0&&s.jsx("span",{className:"game-dot",style:{"--game":v.get(T.game.id)}}),s.jsx("span",{children:T.title}),T.hint!==void 0&&s.jsx("span",{className:"muted small",children:T.hint}),((Z=T.game)==null?void 0:Z.version)!==void 0&&s.jsxs("span",{className:"muted small",children:["版本 ",T.game.version.name,T.game.version.title===void 0?"":`「${T.game.version.title}」`]}),s.jsxs("span",{className:"muted small",children:[T.rows.length," 个"]}),T.game!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(T.game.id),children:"打开"})]}),T.rows.map(E=>{const C=t.find($=>$.id===E.game);return s.jsx(mB,{client:e,activity:E,game:C,color:v.get(E.game)??Fl[0],showGame:d==="time",now:r,soonDays:i,x:A,open:m===E.id,onToggle:()=>g($=>$===E.id?null:E.id),onOpenGame:()=>o(E.game),onChanged:c},E.id)})]},T.key)}),s.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${A(r)/100})`},"aria-hidden":"true",children:s.jsx("span",{children:"今天"})})]})})]})}function mB({client:e,activity:t,game:n,color:r,showGame:i,now:o,soonDays:c,x:u,open:f,onToggle:d,onOpenGame:p,onChanged:m}){const g=gr(t),v=(t.startsAt??0)<=o,y=t.endsAt,S=v&&y!==void 0&&y-o<c*fr&&g.state!=="finished",k=u(t.startsAt??o-30*fr),w=y===void 0?100:u(y),A=t.shopEndsAt===void 0||y===void 0||t.shopEndsAt<=y?void 0:u(t.shopEndsAt);return s.jsxs("div",{className:`ov-item ${f?"open":""}`,style:{"--game":r},children:[s.jsxs("button",{className:`ov-row ${S?"soon":""} ${g.state==="finished"?"finished":""}`,onClick:d,"aria-expanded":f,children:[s.jsxs("div",{className:"ov-label",children:[s.jsx("span",{className:"ov-name",children:t.name}),s.jsxs("span",{className:"ov-meta",children:[i&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"game-dot"}),(n==null?void 0:n.name)??t.game]}),t.kind!==void 0&&s.jsx("span",{className:"ov-kind",children:t.kind})]})]}),s.jsxs("div",{className:"ov-track",children:[s.jsx("span",{className:`ov-bar ${v?"":"future"} ${k<=0?"cut-left":""} ${y===void 0||w>=100?"cut-right":""}`,style:{left:`${k}%`,width:`${Math.max(1.2,w-k)}%`},children:g.total>0&&s.jsx("span",{className:"ov-bar-done",style:{width:`${g.done/g.total*100}%`}})}),A!==void 0&&s.jsx("span",{className:"ov-shop",style:{left:`${w}%`,width:`${Math.max(.6,A-w)}%`},title:"之后只开商店"})]}),s.jsxs("div",{className:"ov-side",children:[s.jsx("span",{className:`ov-left ${S?"tone-warn":""}`,children:v?y===void 0?"时间未知":y<=o&&t.shopEndsAt!==void 0?`商店 ${up(t.shopEndsAt,o)}`:up(y,o):`${up(t.startsAt,o)}后开始`}),s.jsx(hS,{progress:g})]})]}),f&&s.jsx(pS,{client:e,activity:t,game:n,onOpenGame:p,onChanged:m})]})}function hS({progress:e}){return e.state==="finished"?s.jsxs("span",{className:"ov-progress done",children:[s.jsx(ee,{name:"check"}),"做完了"]}):e.state==="unknown"?s.jsx("span",{className:"ov-progress unknown",children:"未记录"}):s.jsxs("span",{className:"ov-progress partial",title:`做了 ${e.done} 项,还剩 ${e.total-e.done} 项`,children:[s.jsx("span",{className:"ov-ring",style:{"--pct":`${e.done/e.total*100}%`}}),e.done,"/",e.total]})}function gB({activity:e}){var i,o;const t=Cn(6e4),n=e.sources??(e.site===void 0?[]:[{id:e.site.source,name:e.site.name,at:e.site.at,web:!1}]);if(n.length===0&&e.screen===void 0&&e.own===void 0)return null;const r=((i=e.own)==null?void 0:i.fields.includes("endsAt"))===!0||(o=e.site)==null?void 0:o.name;return s.jsxs("div",{className:"activity-sources",children:[s.jsx("span",{className:"muted small",children:"来源"}),n.map(c=>s.jsxs("span",{className:`fact-chip ${c.web?"web":"site"}`,title:c.web?"网页上读到的;刷新数据站不会删掉它":"数据站,每次刷新更新",children:[c.name,s.jsxs("small",{children:[c.web?"网页":"数据站"," · ",Tt(c.at,t)]}),n.length>1&&c.name===r&&s.jsx("small",{className:"fact-main",children:"时间以它为准"})]},c.id)),e.screen!==void 0&&s.jsxs("span",{className:"fact-chip screen",title:"agent 进游戏看到的剩余时间和进度",children:["游戏画面",s.jsxs("small",{children:["agent 看过 · ",Tt(e.screen.at,t)]})]}),e.own!==void 0&&s.jsxs("span",{className:"fact-chip own",title:n.length===0&&e.screen===void 0?"你自己添加的活动":`你改过:${e.own.fields.map(c=>Ib[c]).join("、")};比来源优先,刷新不会改掉`,children:[n.length===0&&e.screen===void 0?"我添加的":"我改过",s.jsxs("small",{children:[n.length===0&&e.screen===void 0?"":`${e.own.fields.map(c=>Ib[c]).join("、")} · `,Tt(e.own.at,t)]})]})]})}function pS({client:e,activity:t,game:n,onOpenGame:r,onChanged:i,openSession:o}){var W,M;const[c,u]=b.useState(null),[f,d]=b.useState(!1),[p,m]=b.useState(""),[g,v]=b.useState(!1),[y,S]=b.useState(null),k=(n==null?void 0:n.timezone)??"Asia/Shanghai",w=O=>new Date(O).toLocaleString("zh-CN",{timeZone:k,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),A=async O=>{v(!0),S(null);try{await e.connection.call("games/activity/progress",{activityId:t.id,...O}),i()}catch(T){S(ze(T))}finally{v(!1)}},N=O=>void A({todo:t.todo.filter(T=>T!==O),done:[...t.done,O]}),R=O=>void A({todo:[...t.todo,O],done:t.done.filter(T=>T!==O)}),D=()=>{const O=p.trim();O===""||t.todo.includes(O)||t.done.includes(O)||(m(""),A({todo:[...t.todo,O]}))},P=t.sources!==void 0||t.screen!==void 0,F=()=>{v(!0),S(null),e.connection.call("games/activity/reset",{activityId:t.id}).then(i,O=>S(ze(O))).finally(()=>v(!1))};return f&&n!==void 0?s.jsx("div",{className:"ov-detail",children:s.jsx(fS,{client:e,game:n,activity:t,onDone:()=>{d(!1),i()},onCancel:()=>d(!1)})}):s.jsxs("div",{className:"ov-detail",children:[t.description!==void 0&&s.jsx("p",{className:"ov-description",children:t.description}),s.jsxs("div",{className:"activity-dates muted small",children:[t.startsAt!==void 0&&s.jsxs("span",{children:[w(t.startsAt)," 开始"]}),t.endsAt!==void 0&&s.jsxs("span",{children:[w(t.endsAt)," 结束"]}),t.shopEndsAt!==void 0&&s.jsxs("span",{children:["商店开到 ",w(t.shopEndsAt)]})]}),s.jsx(gB,{activity:t}),s.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[t.todo.map(O=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:g,onChange:()=>N(O)}),O]},`t${O}`)),t.done.map(O=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:g,onChange:()=>R(O)}),O]},`d${O}`)),t.todo.length+t.done.length===0&&s.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」「剧情通关」),或者在游戏页让 agent 进游戏读一次。"})]}),s.jsxs("div",{className:"ov-add",children:[s.jsx("input",{className:"text-input plain",value:p,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:g,onChange:O=>m(O.target.value),onKeyDown:O=>{O.key==="Enter"&&D()}}),s.jsxs("button",{className:"small-button",disabled:g||p.trim()==="",onClick:D,children:[s.jsx(ee,{name:"plus"}),"添加"]})]}),s.jsxs("div",{className:"ov-detail-actions",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.finished!==void 0,disabled:g,onChange:O=>void A({finished:O.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),((W=t.screen)==null?void 0:W.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:t.id}).then(O=>{const T=`data:${O.mediaType};base64,${O.data}`,Z=new Image;Z.onload=()=>u({src:T,width:Z.naturalWidth,height:Z.naturalHeight}),Z.src=T},O=>S(ze(O))),children:"看游戏截图"}),((M=t.screen)==null?void 0:M.sessionId)!==void 0&&o!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(t.screen.sessionId),children:"agent 的对话"}),t.url!==void 0&&s.jsx("a",{className:"link-button small",href:t.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),r!==void 0&&s.jsxs("button",{className:"link-button small",onClick:r,children:["去",(n==null?void 0:n.name)??"游戏"]}),n!==void 0&&s.jsxs("button",{className:"link-button small",disabled:g,onClick:()=>d(!0),children:[s.jsx(ee,{name:"pencil"}),"编辑"]}),t.own!==void 0&&P&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:g,onClick:F,children:"恢复来源的内容"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:g,onClick:()=>void e.connection.call("games/activity/remove",{activityId:t.id}).then(i,O=>S(ze(O))),children:"从日历去掉"})]}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:y})]}),c!==null&&s.jsx(oN,{src:c.src,width:c.width,height:c.height,name:`${t.name}.png`,onClose:()=>u(null)})]})}function xB({client:e,onChanged:t,onDiscover:n}){const[r,i]=b.useState(null),[o,c]=b.useState(""),[u,f]=b.useState(null),[d,p]=b.useState(null),[m,g]=b.useState(0);b.useEffect(()=>{let y=!0;return e.connection.call("games/catalog",{}).then(S=>{y&&i(S.games)}).catch(S=>{y&&p(ze(S))}),()=>{y=!1}},[e,m]);const v=async(y,S)=>{f(y),p(null);try{await e.connection.call("games/follow",{sra:y,follow:S}),g(k=>k+1),t()}catch(k){p(ze(k))}finally{f(null)}};return s.jsxs("div",{className:"catalog-picker",children:[s.jsxs("p",{className:"muted small",children:["这些游戏的活动来自 ",s.jsx("a",{href:"https://starrailassistant.top/reference/public-api/",target:"_blank",rel:"noreferrer",children:"SRA 公共 API"}),"(社区按官方公告整理,免费,不用模型)。勾上的游戏每天自动读一次。"]}),r===null&&d===null&&s.jsx("p",{className:"muted small",children:"正在读取…"}),s.jsx("div",{className:"catalog-grid",children:r==null?void 0:r.map(y=>s.jsxs("label",{className:`check-label ${y.pack!==void 0?"muted":""}`,title:y.pack!==void 0?"已经有游戏包在读它":void 0,children:[s.jsx("input",{type:"checkbox",checked:y.pack!==void 0||y.followed,disabled:y.pack!==void 0||u!==null,onChange:S=>void v(y.sra,S.target.checked)}),y.name,y.pack!==void 0?"(已有)":u===y.sra?"…":""]},y.sra))}),n!==void 0&&s.jsxs("form",{className:"discover-row",onSubmit:y=>{y.preventDefault();const S=o.trim();S!==""&&(n(S),c(""))},children:[s.jsx("span",{className:"field-title",children:"列表里没有?"}),s.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:y=>c(y.target.value)}),s.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[s.jsx(ee,{name:"search"}),"让 agent 去找"]}),s.jsx("span",{className:"muted small",children:"agent 会找它的 Wiki、官网公告等来源,建一个游戏包加到游戏页。"})]}),d!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]})]})}const qi=864e5,ba=36e5,fm=6e4;function Rd(e,t){const n=e-t;return n<=0?"已结束":n>=qi?`${Math.floor(n/qi)} 天 ${Math.floor(n%qi/ba)} 时`:`${Math.floor(n/ba)} 时 ${Math.floor(n%ba/fm)} 分`}function vB(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=qi?{value:String(Math.floor(e/qi)),unit:"天",rest:`${Math.floor(e%qi/ba)} 时`}:e>=ba?{value:String(Math.floor(e/ba)),unit:"时",rest:`${Math.floor(e%ba/fm)} 分`}:{value:String(Math.max(1,Math.floor(e/fm))),unit:"分",rest:""}}function hm(e,t){const n=Object.fromEntries(new Intl.DateTimeFormat("en-CA",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).formatToParts(new Date(e)).map(r=>[r.type,r.value]));return`${n.year}/${n.month}/${n.day} ${n.hour}:${n.minute}`}function mS(e,t){var r;return(((r=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date(t)).find(i=>i.type==="timeZoneName"))==null?void 0:r.value)??"").replace("GMT","UTC")||e}function yB({client:e,game:t,activities:n,color:r,now:i,soonDays:o,busy:c,onRefresh:u,onRead:f,onReadWeb:d,onUnfollow:p,onChanged:m,openSession:g,openScripts:v}){var $,L;const[y,S]=b.useState(null),[k,w]=b.useState(!1),[A,N]=b.useState(!1),R=n.filter(B=>Math.max(B.endsAt??1/0,B.shopEndsAt??0)>i),D=(B,H)=>(B.endsAt??1/0)-(H.endsAt??1/0),P=R.filter(B=>(B.startsAt??0)<=i).sort(D),F=R.filter(B=>B.startsAt!==void 0&&B.startsAt>i).sort((B,H)=>B.startsAt-H.startsAt),W=P.filter(B=>gr(B).state!=="finished"&&(B.endsAt??1/0)-i<o*qi),M=t.sources.some(B=>B.auto),O={partial:0,unknown:1,finished:2},T=P.filter(B=>!W.includes(B)&&gr(B).state!=="finished").sort((B,H)=>O[gr(B).state]-O[gr(H).state]||D(B,H)),Z=P.filter(B=>gr(B).state==="finished"),E=[{key:"soon",title:"需要关注",hint:`${o} 天内结束,还没做完`,rows:W,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:T},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:F}],C=B=>s.jsxs("div",{className:`schedule-item ${y===B.id?"open":""}`,children:[s.jsx(SB,{client:e,activity:B,game:t,now:i,soonDays:o,onClick:()=>S(H=>H===B.id?null:B.id),expanded:y===B.id}),y===B.id&&s.jsx(pS,{client:e,activity:B,game:t,onChanged:m,openSession:g})]},B.id);return s.jsxs("div",{className:"game-view",style:{"--game":r},children:[s.jsxs("div",{className:"game-main",children:[s.jsx(bB,{client:e,game:t,now:i,covers:P.map(B=>B.cover).filter(B=>(B==null?void 0:B.startsWith("shot:"))!==!0)}),s.jsx(wB,{client:e,game:t,running:P,soon:W,now:i,busy:c,onRead:f,onReadWeb:d,onUnfollow:p,openSession:g,openScripts:v}),((($=t.pools)==null?void 0:$.length)??0)>0&&s.jsxs("section",{className:"card pools-card",children:[s.jsx("h3",{children:"卡池"}),s.jsx("div",{className:"pool-list",children:t.pools.map(B=>s.jsx(_B,{client:e,pool:B,game:t,now:i},`${B.name}-${B.endsAt}`))})]}),s.jsxs("div",{className:"game-sources",children:[t.sources.map(B=>{var H;return s.jsxs("span",{className:`source-chip ${B.auto?"auto":"agent"}`,children:[B.auto?s.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[s.jsx("span",{className:"source-dot auto"}),B.name]}):s.jsxs("button",{className:"source-name",disabled:c!==null||((H=t.webReading)==null?void 0:H.state)==="running",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>d(B.id),children:[s.jsx("span",{className:"source-dot"}),B.name,s.jsx("span",{className:"source-action",children:"agent 读"})]}),B.homepage!==void 0&&s.jsx("a",{className:"source-open",href:B.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${B.name}`,children:s.jsx(ee,{name:"popout"})}),B.added===!0&&s.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${B.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:B.id}).then(m,()=>{}),children:s.jsx(ee,{name:"close"})})]},B.id)}),s.jsx(kB,{client:e,game:t,onAdded:m}),t.refreshed!==void 0&&s.jsxs("span",{className:"muted small",children:[Tt(t.refreshed.at,i),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&s.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]}),s.jsxs("aside",{className:"card game-schedule","aria-label":"活动日程",children:[s.jsxs("div",{className:"schedule-head",children:[s.jsx("h3",{children:"活动日程"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"muted small",children:((L=t.sources.find(B=>B.auto))==null?void 0:L.name)??"数据站"}),s.jsx("button",{className:"icon-button",title:"自己添加一个活动","aria-label":"添加活动","aria-pressed":k,onClick:()=>w(B=>!B),children:s.jsx(ee,{name:"plus"})}),s.jsx("button",{className:"icon-button",title:M?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:c!==null||!M,onClick:u,children:s.jsx(ee,{name:"refresh"})})]}),s.jsxs("div",{className:"schedule-list",children:[k&&s.jsx("div",{className:"schedule-item open",children:s.jsx(fS,{client:e,game:t,onCancel:()=>w(!1),onDone:B=>{w(!1),S(B.id),m()}})}),R.length===0&&!k&&s.jsx("p",{className:"muted small schedule-empty",children:M?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),E.filter(B=>B.rows.length>0).map(B=>s.jsxs("section",{className:`schedule-group ${B.tone??""}`,children:[s.jsxs("div",{className:"schedule-group-title",children:[s.jsx("span",{children:B.title}),s.jsx("span",{className:"count",children:B.rows.length}),s.jsx("span",{className:"muted small",children:B.hint})]}),B.rows.map(C)]},B.key)),Z.length>0&&s.jsxs("section",{className:"schedule-group done",children:[s.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":A,onClick:()=>N(B=>!B),children:[s.jsx("span",{children:"已做完"}),s.jsx("span",{className:"count",children:Z.length}),s.jsx("span",{className:"muted small",children:A?"收起":"展开"}),s.jsx(ee,{name:"chevron-down",className:`chevron-icon ${A?"open":""}`})]}),A&&Z.map(C)]})]})]})]})}function bB({client:e,game:t,now:n,covers:r}){const i=t.version,o=lB(e,[i==null?void 0:i.cover,t.art,...r]),c=(i==null?void 0:i.startsAt)!==void 0&&i.endsAt!==void 0?i.endsAt-i.startsAt:void 0,u=c===void 0||c<=0?void 0:Math.min(1,Math.max(0,(n-i.startsAt)/c)),f=d=>new Date(d).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return s.jsxs("section",{className:"version-card",children:[s.jsxs("div",{className:`version-hero ${o===void 0?"no-art":""}`,children:[o!==void 0&&s.jsx("img",{className:"version-art",src:o,alt:""}),s.jsx("div",{className:"version-shade"}),s.jsxs("div",{className:"version-caption",children:[s.jsxs("span",{className:"version-kicker",children:[t.name,i===void 0?"":s.jsxs(s.Fragment,{children:[" · ",s.jsx("b",{children:i.name})," 版本"]})]}),s.jsx("h2",{children:(i==null?void 0:i.title)??t.name})]})]}),s.jsxs("div",{className:"version-strip",children:[i===void 0&&s.jsx("span",{className:"muted small",children:t.sources.some(d=>d.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),i!==void 0&&u!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-end",children:f(i.startsAt)}),s.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:[s.jsx("span",{className:"version-fill",style:{width:`${u*100}%`}}),s.jsx("span",{className:"version-now",style:{left:`${u*100}%`}})]}),s.jsx("span",{className:"version-end",children:f(i.endsAt)})]}),(i==null?void 0:i.endsAt)!==void 0&&s.jsx("span",{className:"version-remaining",children:i.endsAt>n?s.jsxs(s.Fragment,{children:["还剩 ",s.jsx("strong",{children:Rd(i.endsAt,n)})]}):"本版本已结束"})]})]})}function kB({client:e,game:t,onAdded:n}){const[r,i]=b.useState(!1),[o,c]=b.useState(""),[u,f]=b.useState(!1),[d,p]=b.useState(null);if(!r)return s.jsxs("button",{className:"source-add",onClick:()=>i(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[s.jsx(ee,{name:"plus"}),"添加网址"]});const m=async()=>{const g=o.trim();if(g!==""){f(!0),p(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(g)?g:`https://${g}`}),c(""),i(!1),n()}catch(v){p(ze(v))}finally{f(!1)}}};return s.jsxs("form",{className:"source-form",onSubmit:g=>{g.preventDefault(),m()},children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,type:"text",inputMode:"url",placeholder:"https://… 官网公告、Wiki 页面、帖子",value:o,disabled:u,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&i(!1)}}),s.jsx("button",{className:"small-button primary",type:"submit",disabled:u||o.trim()==="",children:u?"添加中…":"添加并读取"}),s.jsx("button",{className:"small-button",type:"button",onClick:()=>{i(!1),p(null)},children:"取消"}),d!==null&&s.jsx("span",{className:"tone-error small",children:d})]})}function wB({client:e,game:t,running:n,soon:r,now:i,busy:o,onRead:c,onReadWeb:u,onUnfollow:f,openSession:d,openScripts:p}){var k,w;const m=n.map(gr),g=m.filter(A=>A.state==="finished").length,v=m.filter(A=>A.state==="partial").length,y=m.filter(A=>A.state==="unknown").length,S=t.reading;return s.jsxs("section",{className:"card status-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"我的状态"}),s.jsx("p",{className:"muted small",children:"进度来自你在活动卡片里勾的,和 agent 进游戏读到的。"})]}),s.jsxs("div",{className:"game-actions",children:[s.jsxs("button",{className:"small-button",disabled:o!==null||((k=t.webReading)==null?void 0:k.state)==="running",title:"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>u(),children:[s.jsx(ee,{name:"search"}),((w=t.webReading)==null?void 0:w.state)==="running"?"agent 正在查…":"让 agent 上网查活动"]}),t.followed===!0?s.jsx("button",{className:"small-button",disabled:o!==null,title:"不再显示这个游戏",onClick:f,children:"取消关注"}):s.jsxs("button",{className:"small-button primary",disabled:o!==null||(S==null?void 0:S.state)==="running",title:"agent 会看游戏画面,进活动页读取剩余时间和没做完的事;只看不花东西",onClick:c,children:[s.jsx(ee,{name:"gamepad"}),(S==null?void 0:S.state)==="running"?"agent 正在读…":"让 agent 进游戏读取"]})]})]}),s.jsxs("div",{className:"status-stats",children:[s.jsxs("div",{className:"stat",children:[s.jsx("strong",{children:n.length}),s.jsx("span",{children:"进行中"})]}),s.jsxs("div",{className:`stat ${r.length>0?"warn":""}`,children:[s.jsx("strong",{children:r.length}),s.jsx("span",{children:"快结束未做完"})]}),s.jsxs("div",{className:"stat ok",children:[s.jsx("strong",{children:g}),s.jsx("span",{children:"已做完"})]}),s.jsxs("div",{className:"stat",children:[s.jsx("strong",{children:v}),s.jsx("span",{children:"做了一部分"})]}),s.jsxs("div",{className:"stat muted",children:[s.jsx("strong",{children:y}),s.jsx("span",{children:"没记录"})]})]}),r.length>0&&s.jsx("ul",{className:"soon-list",children:r.slice(0,4).map(A=>s.jsxs("li",{children:[s.jsx("span",{className:"tone-warn",children:Rd(A.endsAt,i)}),s.jsx("span",{children:A.name}),A.todo.length>0&&s.jsxs("span",{className:"muted small",children:["还没做:",A.todo.slice(0,3).join("、")]})]},A.id))}),S!==void 0&&s.jsx(Rb,{what:"进游戏",reading:S,now:i,openSession:d}),t.webReading!==void 0&&s.jsx(Rb,{what:"上网查",reading:t.webReading,now:i,openSession:d}),s.jsx(jB,{client:e,game:t,now:i,openScripts:p})]})}function Rb({what:e,reading:t,now:n,openSession:r}){var o;const i=(o=t.summary)==null?void 0:o.replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return s.jsxs("div",{className:`reading ${t.state}`,children:[s.jsxs("div",{className:"reading-head",children:[s.jsx("span",{className:`badge ${t.state==="done"?"ok":t.state==="failed"?"warn":""}`,children:t.state==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),s.jsx("span",{className:"muted small",children:Tt(t.at,n)}),s.jsx("span",{className:"spacer"}),t.sessionId!==void 0&&s.jsxs("button",{className:"link-button small reading-open",onClick:()=>r(t.sessionId),children:["查看对话",s.jsx(ee,{name:"chevron"})]})]}),i!==void 0&&i!==""&&s.jsx("p",{className:"reading-summary",title:i,children:i})]})}function NB({client:e,game:t}){const n=je(e.capabilities),[r,i]=b.useState(null);return b.useEffect(()=>{if(!n.has("scripts"))return;let o=!0;return e.connection.call("games/mirrorchyan",{game:t.id}).then(c=>{o&&i(c.items)},()=>{o&&i([])}),()=>{o=!1}},[e,t.id,n.has("scripts")]),r===null||r.length===0?null:s.jsxs("div",{className:"mirror-tools",children:[s.jsx("div",{className:"muted small",children:"Mirror酱 上有这些玩它的工具:"}),s.jsx("ul",{children:r.slice(0,5).map(o=>s.jsxs("li",{children:[s.jsx("a",{href:`#/p/scripts/${encodeURIComponent(`mirror:${o.rid}`)}`,children:o.name}),s.jsx("span",{className:"chip subtle",children:o.rid}),o.description!==""&&s.jsx("span",{className:"muted small",children:o.description})]},o.rid))})]})}function jB({client:e,game:t,now:n,openScripts:r}){const i=je(e.capabilities),o=je(e.connection.status),[c,u]=b.useState(null),[f,d]=b.useState([]),[p,m]=b.useState(0),[g,v]=b.useState(null),[y,S]=b.useState(null),k=i.has("pipelines");b.useEffect(()=>e.connection.on("pipelines/changed",()=>m(N=>N+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/run",N=>{N.state!=="running"&&m(R=>R+1)}),[e]),b.useEffect(()=>{if(o.state!=="open"||!k||t.scripts.length===0){u([]);return}let N=!0;return(async()=>{const{items:R}=await e.connection.call("pipelines/list",{}),P=(await Promise.all(R.filter(W=>!W.draft).map(async W=>({summary:W,pipeline:await e.connection.call("pipelines/get",{id:W.id})})))).filter(({pipeline:W})=>W.nodes.some(M=>M.kind==="script-task"&&t.scripts.includes(M.scriptId))),F=i.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;N&&(u(P),d((F==null?void 0:F.upcoming)??[]))})().catch(R=>{N&&S(ze(R))}),()=>{N=!1}},[e,o.state,k,t.id,t.scripts.join(","),p]);const w=async N=>{v(N),S(null);try{await e.connection.call("pipelines/run",{id:N}),m(R=>R+1)}catch(R){S(ze(R))}finally{v(null)}},A={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]};return s.jsxs("div",{className:"game-schedule-runs",children:[s.jsx("div",{className:"field-title",children:"日程"}),t.scripts.length===0&&s.jsxs("p",{className:"muted small",children:["还没有玩它的脚本。在",s.jsx("button",{className:"link-button",onClick:r,children:"脚本页"}),"安装或导入后,名字或仓库里提到这个游戏的脚本会自动对上。"]}),t.scripts.length===0&&s.jsx(NB,{client:e,game:t}),t.scripts.length>0&&s.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((N,R)=>s.jsxs("span",{children:[R>0?"、":"",s.jsx("button",{className:"link-button",onClick:r,children:N})]},N))]}),c!==null&&t.scripts.length>0&&c.length===0&&s.jsxs("p",{className:"muted small",children:["还没有自动跑这个游戏的流水线。在 ",s.jsx("a",{href:"#/p/pipelines",children:"编排"})," 里建一条并设上定时,日常就会每天自己跑。"]}),c!==null&&c.length>0&&s.jsx("ul",{className:"run-list",children:c.map(({summary:N})=>{var P,F;const R=f.filter(W=>W.pipelineId===N.id).map(W=>W.at).sort((W,M)=>W-M)[0],D=N.lastRun;return s.jsxs("li",{children:[s.jsx("a",{className:"run-name",href:`#/p/pipelines/${encodeURIComponent(N.id)}`,children:N.name}),s.jsx("span",{className:"muted small",children:R!==void 0?`下次 ${new Date(R).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:N.schedule.enabled?"定时已开":"没有定时"}),D!==void 0&&s.jsxs("span",{className:`badge ${((P=A[D.state])==null?void 0:P[0])??""}`,title:new Date(D.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((F=A[D.state])==null?void 0:F[1])??D.state," · ",Tt(D.endedAt??D.startedAt,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:g!==null||(D==null?void 0:D.state)==="running",onClick:()=>void w(N.id),children:(D==null?void 0:D.state)==="running"?"运行中…":g===N.id?"启动中…":"运行"})]},N.id)})}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:y})]})]})}function SB({client:e,activity:t,game:n,now:r,soonDays:i,onClick:o,expanded:c}){var N,R,D,P;const u=dg(e,t.cover),f=gr(t),d=(t.startsAt??0)<=r,p=d&&t.endsAt!==void 0&&t.endsAt<=r,m=p?t.shopEndsAt:t.endsAt,g=d&&m!==void 0&&m-r<i*qi&&f.state!=="finished",v=t.startsAt!==void 0&&m!==void 0?m-t.startsAt:void 0,y=v===void 0||v<=0||!d?void 0:Math.min(1,Math.max(0,(r-t.startsAt)/v)),S=f.state==="finished"?["done","已做完"]:d?p?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],k=mS(n.timezone,r),w=d?m:t.startsAt,A=w===void 0?{value:"",unit:"",rest:""}:vB(w-r);return s.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${g?"soon":""}`,onClick:o,"aria-expanded":c,children:[u!==void 0&&s.jsx("img",{className:`sched-art ${((N=t.cover)==null?void 0:N.startsWith("shot:"))===!0?"shot":""}`,src:u,alt:"",title:((R=t.cover)==null?void 0:R.startsWith("shot:"))===!0?"没有活动图,用的是 agent 读这个活动时的游戏截图":void 0}),s.jsx("span",{className:"sched-shade"}),s.jsxs("span",{className:"sched-count","aria-label":w===void 0?"时间未知":`${d?"剩余":"距开始"}${Rd(w,r)}`,children:[w===void 0?s.jsx("b",{children:"?"}):s.jsxs(s.Fragment,{children:[s.jsx("b",{children:A.value}),s.jsx("small",{children:A.unit}),A.rest!==""&&s.jsx("em",{children:A.rest})]}),s.jsx("i",{children:d?p?"商店":"剩余":"后开始"})]}),s.jsxs("span",{className:"sched-body",children:[s.jsxs("span",{className:"sched-top",children:[s.jsx("span",{className:`sched-tag ${S[0]}`,children:S[1]}),t.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:t.kind}),t.own!==void 0&&s.jsx("span",{className:"sched-kind",title:t.sources===void 0&&t.screen===void 0?"你自己添加的活动":"你改过这个活动",children:t.sources===void 0&&t.screen===void 0?"我添加的":"我改过"}),((D=t.sources)==null?void 0:D.some(F=>F.web))===!0&&s.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(F=>F.name).join("、")}`,children:t.sources.every(F=>F.web)?"网页读到":"数据站 + 网页"}),s.jsx("span",{className:"spacer"}),s.jsx(hS,{progress:f})]}),s.jsx("span",{className:"sched-name",children:t.name}),s.jsx("span",{className:"sched-when",children:!d&&t.startsAt!==void 0?`${hm(t.startsAt,n.timezone)} 开始 · ${k}`:m!==void 0?`${hm(m,n.timezone)} ${p?"商店关闭":"结束"} · ${k}`:`结束时间未知${((P=t.screen)==null?void 0:P.remaining)===void 0?"":`,游戏里显示「${t.screen.remaining}」`}`})]}),y!==void 0&&s.jsx("span",{className:"sched-elapsed",style:{width:`${y*100}%`}})]})}function _B({client:e,pool:t,game:n,now:r}){const i=dg(e,t.cover),o=(t.startsAt??0)<=r;return s.jsxs("article",{className:"pool-card",children:[s.jsx("div",{className:"pool-art",children:i===void 0?s.jsx(ee,{name:"sparkles"}):s.jsx("img",{src:i,alt:""})}),s.jsxs("div",{className:"pool-main",children:[t.type!==void 0&&s.jsx("span",{className:"muted small",children:t.type}),s.jsx("strong",{children:t.name}),t.up.length>0&&s.jsxs("span",{className:"small",children:["UP:",t.up.join("、")]}),s.jsxs("span",{className:"small",children:[o?"剩余":"距开始"," ",s.jsx("strong",{className:"pool-left",children:Rd(o?t.endsAt:t.startsAt,r)})]}),s.jsxs("span",{className:"muted small",children:[hm(t.endsAt,n.timezone)," 结束 (",mS(n.timezone,r),")"]})]})]})}function EB(e,t){return b.useMemo(()=>new Map(e.map((n,r)=>[n.id,t[r%t.length]])),[e,t])}const CB=864e5;function IB({client:e,openSession:t,openSettings:n,openPage:r,arg:i}){const o=je(e.connection.status),c=Cn(3e4),[u,f]=b.useState(null),[d,p]=b.useState(0),[m,g]=b.useState(i??""),[v,y]=b.useState(null),[S,k]=b.useState(null),[w,A]=b.useState(null),[N,R]=b.useState(!1);b.useEffect(()=>{i!==void 0&&g(i)},[i]),b.useEffect(()=>e.connection.on("games/changed",()=>p(C=>C+1)),[e]),b.useEffect(()=>{if(o.state!=="open")return;let C=!0;return e.connection.call("games/list",{}).then($=>{C&&f($)}).catch($=>{C&&k(ze($))}),()=>{C=!1}},[e,o.state,d]);const D=(u==null?void 0:u.games)??[],P=EB(D,Fl),F=m==="report",W=F?void 0:D.find(C=>C.id===m),M=!F&&W===void 0,O=C=>{g(C),A(null),k(null)},T=async(C,$)=>{y(C),k(null),A(null);try{const L=await $();typeof L=="string"&&A(L)}catch(L){k(ze(L))}finally{y(null),p(L=>L+1)}},Z=C=>T(`refresh:${C??""}`,async()=>{const{results:$}=await e.connection.call("games/refresh",C===void 0?{}:{game:C}),L=G=>{var K;return((K=D.find(V=>V.id===G))==null?void 0:K.name)??G},B=G=>{var K;return((K=D.find(V=>V.id===G))==null?void 0:K.sources.some(V=>V.auto))===!0},H=$.filter(G=>B(G.game)&&!G.ok);if(H.length>0)throw new Error(H.map(G=>`${L(G.game)}没读到:${G.detail??"未知原因"}`).join(";"));return C===void 0?`刷新完成:${$.filter(G=>B(G.game)).map(G=>`${L(G.game)} ${G.count} 个活动`).join(";")}`:void 0}),E=C=>{const $=((u==null?void 0:u.activities)??[]).filter(B=>B.game===C.id&&(B.startsAt??0)<=c&&Math.max(B.endsAt??1/0,B.shopEndsAt??0)>c),L=$.filter(B=>gr(B).state!=="finished"&&B.endsAt!==void 0&&B.endsAt>c&&B.endsAt-c<((u==null?void 0:u.settings.report.soonDays)??3)*CB).length;return s.jsxs("button",{role:"tab","aria-selected":(W==null?void 0:W.id)===C.id,className:`game-tab ${(W==null?void 0:W.id)===C.id?"active":""}`,style:{"--game":P.get(C.id)},title:`${$.length} 个进行中${C.refreshed===void 0?"":` · ${Tt(C.refreshed.at,c)}刷新`}${C.followed===!0?" · 关注的游戏":""}`,onClick:()=>O(C.id),children:[s.jsx("span",{className:"game-dot"}),C.name,L>0&&s.jsx("span",{className:"game-tab-badge",title:`${L} 个快结束还没做完`,children:L})]},C.id)};return s.jsxs("section",{className:"main games-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"游戏"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:F?"每日日报":(W==null?void 0:W.name)??"全部活动"})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button",disabled:v!==null||D.length===0,onClick:()=>void Z(),children:[s.jsx(ee,{name:"refresh"}),v==="refresh:"?"刷新中…":"刷新全部"]})})]}),s.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[s.jsxs("button",{role:"tab","aria-selected":M,className:`game-tab ${M?"active":""}`,onClick:()=>O(""),children:[s.jsx(ee,{name:"calendar"}),"全部活动"]}),s.jsx("span",{className:"game-tabs-divider"}),D.map(E),s.jsxs("button",{className:`game-tab add ${N?"active":""}`,"aria-expanded":N,title:"关注更多游戏(SRA 公共 API)",onClick:()=>R(C=>!C),children:[s.jsx(ee,{name:"plus"}),"更多游戏"]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{role:"tab","aria-selected":F,className:`game-tab ${F?"active":""}`,onClick:()=>O("report"),children:[s.jsx(ee,{name:"send"}),"日报"]})]}),s.jsxs("div",{className:"games-body",children:[N&&s.jsx("section",{className:"card",children:s.jsx(xB,{client:e,onChanged:()=>p(C=>C+1),onDiscover:C=>void T("discover",async()=>{const{sessionId:$}=await e.connection.call("games/discover",{name:C});t($)})})}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]}),w!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:w})]}),u!==null&&D.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(ee,{name:"gamepad"}),s.jsx("p",{children:"没有游戏。点「更多游戏」关注几个。"})]}),u!==null&&M&&D.length>0&&s.jsx(pB,{client:e,games:D,activities:u.activities,now:c,soonDays:u.settings.report.soonDays,onOpenGame:O,onChanged:()=>p(C=>C+1)}),u!==null&&F&&s.jsx(AB,{client:e,data:u,games:D,now:c,openSettings:n,onChanged:()=>p(C=>C+1)}),u!==null&&W!==void 0&&s.jsx(yB,{client:e,game:W,activities:u.activities.filter(C=>C.game===W.id),color:P.get(W.id)??Fl[0],now:c,soonDays:u.settings.report.soonDays,busy:v,onRefresh:()=>void Z(W.id),onRead:()=>void T(`read:${W.id}`,async()=>{const{sessionId:C}=await e.connection.call("games/read",{game:W.id});t(C)}),onReadWeb:C=>void T(`read-web:${W.id}`,async()=>{const{sessionId:$}=await e.connection.call("games/read",{game:W.id,how:"web",...C===void 0?{}:{source:C}});t($)}),onUnfollow:()=>void T(`unfollow:${W.id}`,async()=>(await e.connection.call("games/follow",{sra:W.id.replace(/^sra-/,""),follow:!1}),g(""),`不再关注${W.name}`)),onChanged:()=>p(C=>C+1),openSession:t,openScripts:()=>r("scripts")},W.id)]})]})}function AB({client:e,data:t,games:n,now:r,openSettings:i,onChanged:o}){const c=t.settings.report,[u,f]=b.useState(null),[d,p]=b.useState(!1),[m,g]=b.useState(null),[v,y]=b.useState(null);b.useEffect(()=>{let w=!0;return e.connection.call("games/report/preview",{}).then(A=>{w&&f(A)}).catch(()=>{}),()=>{w=!1}},[e,t]);const S=async w=>{p(!0),g(null);try{await e.connection.call("games/settings/set",{report:w}),o()}catch(A){g(ze(A))}finally{p(!1)}},k=async()=>{p(!0),g(null),y(null);try{const{channels:w}=await e.connection.call("games/report/send",{});y(w.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${w.join("、")}。`),o()}catch(w){g(ze(w))}finally{p(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"每日日报"}),s.jsx("p",{className:"muted small",children:"每天先读一遍数据站,再把各游戏的活动、剩余天数和没做完的事发到飞书。进度来自 agent 最近一次进游戏读取(可以在编排里加一个 agent 节点,日常跑完后读一次)。"})]}),s.jsx("span",{className:`badge ${c.enabled?"ok":""}`,children:c.enabled?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,disabled:d,onChange:w=>void S({enabled:w.target.checked})}),"每天定时发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.ai,disabled:d,onChange:w=>void S({ai:w.target.checked})}),"用 AI 总结,只说近期的事(刚开始、快结束、即将开始),语气按「设置 → 回复风格」;agent 不可用时发下面的完整列表"]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"发送时间"}),s.jsx("input",{className:"text-input plain",type:"time",defaultValue:c.at,disabled:d,onBlur:w=>{/^\d{2}:\d{2}$/.test(w.target.value)&&w.target.value!==c.at&&S({at:w.target.value})}},c.at)]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"剩余几天以内标成「快结束」"}),s.jsx("input",{className:"text-input plain",type:"number",min:1,max:30,defaultValue:c.soonDays,disabled:d,onBlur:w=>{const A=Math.max(1,Math.min(30,Math.round(Number(w.target.value)||3)));A!==c.soonDays&&S({soonDays:A})}},c.soonDays)]})]}),s.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),s.jsx("div",{className:"chip-row",children:n.map(w=>{const A=c.games.includes(w.id);return s.jsx("button",{className:`chip chip-button ${A?"active":""}`,disabled:d,onClick:()=>void S({games:A?c.games.filter(N=>N!==w.id):[...c.games,w.id]}),children:w.name},w.id)})}),s.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${Tt(t.report.lastSentAt,r)}。`,t.report.lastResult===void 0?"":` ${t.report.lastResult}。`,c.enabled&&t.report.next!==void 0&&` 下一次:${new Date(t.report.next).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}。`," ",s.jsx("button",{className:"link-button",onClick:()=>i("feishu"),children:"远程连接"})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:m})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"今天的日报"}),s.jsx("p",{className:"muted small",children:c.ai?"完整列表。发送时 agent 从里面挑出近期的事写成总结,写不出来就发这份。":"发到飞书的就是这份。"})]}),s.jsxs("button",{className:"small-button primary",disabled:d,onClick:()=>void k(),children:[s.jsx(ee,{name:"send"}),d?"发送中…":"现在发送"]})]}),v!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:v})]}),u!==null&&s.jsxs("div",{className:"report-preview",children:[s.jsx("strong",{children:u.title}),`
222
-
223
- `,u.text]})]}),t.report.lastText!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"上次发出的"}),t.report.lastSentAt!==void 0&&s.jsx("p",{className:"muted small",children:Tt(t.report.lastSentAt,r)})]})}),s.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const TB={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"gamepad",order:-10,component:IB}]},$B={game:"游戏",script:"脚本",general:"通用"};function MB({client:e,focus:t,openSession:n,openSkill:r}){const i=Cn(6e4),o=je(e.capabilities),[c,u]=b.useState(null),[f,d]=b.useState({games:new Set,scripts:new Set}),[p,m]=b.useState(null),[g,v]=b.useState(null),[y,S]=b.useState(null),[k,w]=b.useState(null),[A,N]=b.useState(!1),R=async(M=!1)=>{m(M?"refresh":p);try{u(await e.connection.call("skillhub/list",M?{refresh:!0}:{})),v(null)}catch(O){v(ze(O))}finally{M&&m(null)}};b.useEffect(()=>{R()},[e]),b.useEffect(()=>e.connection.on("skillhub/changed",()=>void R()),[e]),b.useEffect(()=>{let M=!0;return(async()=>{var Z,E;const O=o.has("games")?((Z=await e.connection.call("games/list",{}).catch(()=>{}))==null?void 0:Z.games.map(C=>C.id))??[]:[],T=o.has("scripts")?((E=await e.connection.call("scripts/list",{}).catch(()=>{}))==null?void 0:E.scripts.flatMap(C=>[C.id,C.packId,C.known].filter($=>$!==void 0)))??[]:[];M&&d({games:new Set(O),scripts:new Set(T)})})(),()=>{M=!1}},[e,o.has("games"),o.has("scripts")]);const D=async(M,O)=>{m(M),v(null),S(null);try{const T=await O();typeof T=="string"&&S(T),await R()}catch(T){v(ze(T))}finally{m(null)}},P=M=>M.games.some(O=>f.games.has(O))||M.scripts.some(O=>f.scripts.has(O)),F=b.useMemo(()=>{const M=[...(c==null?void 0:c.items)??[]].sort((O,T)=>+(T.name===t)-+(O.name===t)||O.name.localeCompare(T.name));return[{label:"已下载",items:M.filter(O=>O.installed!==void 0)},{label:"推荐给你",hint:"你关注的游戏、装了的脚本",items:M.filter(O=>O.installed===void 0&&P(O))},{label:"其他",items:M.filter(O=>O.installed===void 0&&!P(O))}].filter(O=>O.items.length>0)},[c,f,t]),W=(M,O)=>D(`update:${M.name}`,async()=>{const T=await e.connection.call("skillhub/update",{name:M.name,...O===void 0?{}:{resolve:O}});return w(null),T.state==="merging"&&T.sessionId!==void 0?(n(T.sessionId),"agent 正在合并,合并完会写回你的这份技能"):T.state==="conflict"?"你改过这个技能:选「保留我的」「用新版」或「让 agent 合并」":T.state==="kept"?"已保留你的版本,这个新版本不再提示":T.state==="updated"?T.backup===void 0?`${M.name} 已更新`:`${M.name} 已更新,你原来的那份备份在 ${T.backup}`:"已是最新"});return s.jsxs("div",{className:"skill-hub",children:[s.jsxs("section",{className:"card skill-hub-head",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"技能库"}),s.jsxs("p",{className:"muted small",children:["游戏和脚本的技能放在 ",(c==null?void 0:c.repos.map(M=>M.repo).join("、"))??"MultiGameAssistant/skills",",按需下载;下载的可以改,更新时不会覆盖你的改动。软件自带的核心技能受保护,随软件更新。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(c==null?void 0:c.fetchedAt)===void 0?"":`${Tt(c.fetchedAt,i)}读取`}),s.jsxs("button",{className:"small-button",disabled:p!==null,onClick:()=>void R(!0),children:[s.jsx(ee,{name:"refresh"}),p==="refresh"?"读取中…":"检查更新"]}),s.jsx("button",{className:"ghost small-button",onClick:()=>N(M=>!M),children:"仓库"})]})]}),A&&c!==null&&s.jsx(RB,{repos:c.repos,disabled:p!==null,onSave:M=>D("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:M}),N(!1),await e.connection.call("skillhub/list",{refresh:!0}),"已保存,按新的仓库读取"))}),c==null?void 0:c.errors.map(M=>s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["读不到:",M,c.items.length>0?"(下面是之前读到的)":""]})]},M))]}),y!==null&&s.jsx("div",{className:"notice info",children:y}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:g})]}),c===null&&g===null&&s.jsx("p",{className:"muted",children:"正在读取技能库…"}),c!==null&&c.items.length===0&&c.errors.length===0&&s.jsx("p",{className:"muted",children:"技能库里还没有技能。"}),F.map(M=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"sidebar-label",children:[M.label,s.jsx("span",{className:"skills-count",children:M.items.length}),"hint"in M&&s.jsxs("span",{children:["· ",M.hint]})]}),s.jsx("ul",{className:"hub-list",children:M.items.map(O=>{var T,Z,E,C;return s.jsxs("li",{className:O.name===t?"focused":"",children:[s.jsxs("div",{className:"hub-main",children:[s.jsxs("div",{className:"hub-title",children:[s.jsx("strong",{children:O.title??O.name}),O.title!==void 0&&s.jsx("code",{className:"muted small",children:O.name}),s.jsx("span",{className:"badge",children:$B[O.kind]}),((T=O.installed)==null?void 0:T.modified)===!0&&s.jsx("span",{className:"badge",title:"你改过这个技能;更新时不会覆盖",children:"你改过"}),((Z=O.installed)==null?void 0:Z.update)===!0&&s.jsx("span",{className:"badge ok",children:"有新版"})]}),s.jsx("span",{className:"muted small",children:O.description}),O.blocked!==void 0&&s.jsxs("span",{className:"muted small",children:[O.blocked,",没有下载(以你已有的为准)"]})]}),s.jsxs("div",{className:"hub-actions",children:[O.installed===void 0&&O.blocked===void 0&&s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void D(`install:${O.name}`,async()=>(await e.connection.call("skillhub/install",{name:O.name,repo:O.repo}),`已下载 ${O.name},agent 现在就能用`)),children:p===`install:${O.name}`?"下载中…":"下载"}),((E=O.installed)==null?void 0:E.update)===!0&&O.installed.modified!==!0&&s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void W(O),children:"更新"}),((C=O.installed)==null?void 0:C.update)===!0&&O.installed.modified===!0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void D(`diff:${O.name}`,async()=>w({name:O.name,...await e.connection.call("skillhub/diff",{name:O.name})})),children:"看看哪里不同"}),s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void W(O,"keep"),children:"保留我的"}),s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void W(O,"replace"),children:"用新版"}),s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void W(O,"merge"),children:"让 agent 合并"})]}),O.installed!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:()=>r(O.name),children:"查看"}),s.jsx("button",{className:"ghost small-button",disabled:p!==null,onClick:()=>void D(`remove:${O.name}`,async()=>(await e.connection.call("skillhub/remove",{name:O.name}),`已删除下载的 ${O.name}`)),children:"删除"})]})]}),(k==null?void 0:k.name)===O.name&&s.jsx(OB,{mine:k.mine,theirs:k.theirs,onClose:()=>w(null)})]},`${O.repo}/${O.name}`)})})]},M.label))]})}function RB({repos:e,disabled:t,onSave:n}){const[r,i]=b.useState(e.map(u=>u.branch==="main"?u.repo:`${u.repo}@${u.branch}`).join(`
224
- `)),o=r.split(/\r?\n/).map(u=>u.trim()).filter(Boolean).map(u=>{const[f,d]=u.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:f??"",branch:d??"main"}}),c=o.length>0&&o.every(u=>/^[\w.-]+\/[\w.-]+$/.test(u.repo)&&/^[\w./-]+$/.test(u.branch));return s.jsxs("div",{className:"hub-repos",children:[s.jsx("label",{className:"field-label",htmlFor:"hub-repos",children:"技能仓库(一行一个 owner/repo,可以写 @分支;前面的同名技能优先)"}),s.jsx("textarea",{id:"hub-repos",className:"text-input plain",rows:3,value:r,onChange:u=>i(u.target.value),spellCheck:!1}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"别的仓库里的技能会让 agent 照着做,只加你信得过的。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:t,onClick:()=>i("MultiGameAssistant/skills"),children:"恢复默认"}),s.jsx("button",{className:"primary small-button",disabled:t||!c,onClick:()=>n(o),children:"保存"})]})]})}function OB({mine:e,theirs:t,onClose:n}){const r=b.useMemo(()=>zB(e.split(/\r?\n/),t.split(/\r?\n/)),[e,t]);return s.jsxs("div",{className:"hub-diff",children:[s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[s.jsx("span",{className:"diff-del",children:"− 只在你的版本里"})," ",s.jsx("span",{className:"diff-add",children:"+ 只在新版本里"})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"ghost small-button",onClick:n,children:"收起"})]}),s.jsx("pre",{children:r.map((i,o)=>s.jsxs("div",{className:i.kind==="-"?"diff-del":i.kind==="+"?"diff-add":"muted",children:[i.kind," ",i.text]},o))})]})}function zB(e,t){var p;const n=e.length,r=t.length,i=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let m=n-1;m>=0;m--)for(let g=r-1;g>=0;g--)i[m][g]=e[m]===t[g]?i[m+1][g+1]+1:Math.max(i[m+1][g],i[m][g+1]);const o=[];let c=0,u=0;for(;c<n||u<r;)c<n&&u<r&&e[c]===t[u]?(o.push({kind:" ",text:e[c]}),c++,u++):u<r&&(c===n||i[c][u+1]>=i[c+1][u])?(o.push({kind:"+",text:t[u]}),u++):(o.push({kind:"-",text:e[c]}),c++);const f=m=>o.slice(Math.max(0,m-2),m+3).some(g=>g.kind!==" "),d=[];for(let m=0;m<o.length;m++)o[m].kind!==" "||f(m)?d.push(o[m]):((p=d.at(-1))==null?void 0:p.text)!=="…"&&d.push({kind:" ",text:"…"});return d}const PB=[{label:"本应用自带 · 受保护",match:e=>e==="bundled"},{label:"从技能库下载的",match:e=>e==="hub"},{label:"脚本包和游戏包",match:e=>e==="custom"},{label:"你的技能文件夹",match:e=>e.startsWith("user-")},{label:"工作文件夹里的",match:e=>e.startsWith("project-")}];function LB(e){var t;return e.removable===!0?"在这里存的":((t=PB.find(n=>n.match(e.source)))==null?void 0:t.label)??"其他"}const DB="通用",gS="adg:skills:folded";function FB(){try{return new Set(JSON.parse(localStorage.getItem(gS)??"[]"))}catch{return new Set}}function BB(e){try{localStorage.setItem(gS,JSON.stringify([...e]))}catch{}}const UB=e=>e.startsWith("game:")?"gamepad":e.startsWith("script:")?"package":"layers";function HB({client:e,arg:t,openSession:n}){var ke,ae,Ne,Fe;const r=je(e.connection.status),i=je(e.capabilities),[o,c]=b.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),u=(t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):void 0,[f,d]=b.useState(null),[p,m]=b.useState(""),[g,v]=b.useState(t??""),[y,S]=b.useState(null),[k,w]=b.useState(null),[A,N]=b.useState(0),[R,D]=b.useState(!1),[P,F]=b.useState(null),[W,M]=b.useState(FB),[O,T]=b.useState(!1),Z=ce=>M(Se=>{const re=new Set(Se);return re.delete(ce)||re.add(ce),BB(re),re}),E=((ke=Am(e).data)==null?void 0:ke.scripts)??[],[C,$]=b.useState([]);b.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?c("hub"):(c("mine"),v(t)))},[t]),b.useEffect(()=>e.connection.on("skills/changed",()=>N(ce=>ce+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!i.has("games"))return;let ce=!0;return e.connection.call("games/list",{}).then(Se=>{ce&&$(Se.games)},()=>{}),()=>{ce=!1}},[e,r.state,i]),b.useEffect(()=>{if(r.state!=="open")return;let ce=!0;return e.connection.call("skills/list",{}).then(Se=>{ce&&(d(Se.skills),w(null))},Se=>{ce&&w(ze(Se))}),()=>{ce=!1}},[e,r.state,A,o]);const L=p.trim().toLowerCase(),B=b.useMemo(()=>(f??[]).filter(ce=>L===""||`${ce.name} ${ce.description} ${ce.whenToUse??""}`.toLowerCase().includes(L)),[f,L]),H=b.useMemo(()=>{const ce=new Map,Se=(Ie,tt,et)=>{const jt=ce.get(Ie)??{key:Ie,label:tt,items:[],subs:[],...et};return ce.set(Ie,jt),jt},re=Ie=>Se(`game:${Ie.id}`,Ie.name,{game:Ie.id}),he=(Ie,tt)=>{const et=Ie.subs.find(jt=>jt.script===tt.id)??{key:`${Ie.key}/${tt.id}`,label:tt.name,script:tt.id,items:[]};return Ie.subs.includes(et)||Ie.subs.push(et),et},Le=(Ie,tt)=>{Ie.includes(tt)||Ie.push(tt)};if(L===""){for(const Ie of C)re(Ie);for(const Ie of E){const tt=lw(Ie,C);tt===void 0?Se(`script:${Ie.id}`,Ie.name,{script:Ie.id}):he(re(tt),Ie)}}for(const Ie of B){const tt=Fp(Ie.owner,E,C);tt.length===0&&Le(Se("general",DB,{}).items,Ie);for(const et of tt)et.game!==void 0&&et.script!==void 0?Le(he(re(et.game),et.script).items,Ie):et.game!==void 0?Le(re(et.game).items,Ie):et.script!==void 0&&Le(Se(`script:${et.script.id}`,et.script.name,{script:et.script.id}).items,Ie)}const Te=(Ie,tt)=>Ie.name.localeCompare(tt.name),Ge=Ie=>Ie.key.startsWith("game:")?0:Ie.key.startsWith("script:")?1:2;return[...ce.values()].map(Ie=>({...Ie,items:Ie.items.sort(Te),subs:Ie.subs.map(tt=>({...tt,items:tt.items.sort(Te)})).sort((tt,et)=>tt.label.localeCompare(et.label))})).sort((Ie,tt)=>Ge(Ie)-Ge(tt)||Ie.label.localeCompare(tt.label))},[B,E,C,L]),G=H.flatMap(ce=>[...ce.items,...ce.subs.flatMap(Se=>Se.items)])[0],K=B.find(ce=>ce.name===g)??G;b.useEffect(()=>{if(T(!1),K===void 0){S(null);return}let ce=!0;return D(!1),e.connection.call("skills/get",{name:K.name}).then(Se=>{ce&&S(Se)},Se=>{ce&&w(ze(Se))}),()=>{ce=!1}},[e,K==null?void 0:K.name,A]);const V=ce=>{var Se;(Se=navigator.clipboard)==null||Se.writeText(`/${ce} `).then(()=>D(!0),()=>{})},Y=async ce=>{if(confirm(`删除技能「${ce.name}」?它的文件夹会一起删掉,agent 以后就用不到它了。`))try{await e.connection.call("skills/remove",{name:ce.name}),v(""),N(Se=>Se+1)}catch(Se){w(ze(Se))}},fe=ce=>[...new Set(Fp(ce.owner,E,C).map(cw))],xe=ce=>({name:"",description:"",content:"",scripts:ce.script===void 0?[]:[ce.script],games:ce.script===void 0&&ce.game!==void 0?[ce.game]:[]}),ge=ce=>s.jsxs("button",{className:`script-row skill-row ${P===null&&(K==null?void 0:K.name)===ce.name?"active":""}`,onClick:()=>{F(null),v(ce.name)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:ce.name}),s.jsx("span",{className:"muted small skills-row-desc",children:ce.description})]}),ce.removable===!0&&s.jsx("span",{className:"skill-row-mark",title:"在这里存的:可以编辑和删除",children:s.jsx(ee,{name:"pencil"})})]},ce.name),ie=(ce,Se,re)=>s.jsx("button",{className:"icon-button skills-add",title:re,"aria-label":`在${ce}下新建技能`,disabled:r.state!=="open",onClick:()=>F(xe(Se)),children:s.jsx(ee,{name:"plus"})});return s.jsxs("section",{className:"main scripts-page skills-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"技能"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:o==="hub"?"技能库":"agent 的技能"})]}),s.jsxs("div",{className:"page-actions",children:[i.has("skillhub")&&s.jsxs("div",{className:"tabs",role:"tablist",children:[s.jsx("button",{role:"tab","aria-selected":o==="mine",className:o==="mine"?"active":"",onClick:()=>c("mine"),children:"已有的技能"}),s.jsx("button",{role:"tab","aria-selected":o==="hub",className:o==="hub"?"active":"",onClick:()=>c("hub"),children:"技能库"})]}),o==="mine"&&s.jsxs("button",{className:"small-button",disabled:r.state!=="open",onClick:()=>F(xe({})),children:[s.jsx(ee,{name:"plus"}),"新建技能"]}),o==="mine"&&s.jsxs("button",{className:"small-button",onClick:()=>N(ce=>ce+1),children:[s.jsx(ee,{name:"refresh"}),"刷新"]})]})]}),o==="hub"&&i.has("skillhub")?s.jsx("div",{className:"skill-hub-body",children:s.jsx(MB,{client:e,focus:u,openSession:n,openSkill:ce=>{v(ce),c("mine")}})}):s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"技能列表",children:[s.jsxs("div",{className:"skills-search",children:[s.jsx(ee,{name:"search"}),s.jsx("input",{className:"text-input",value:p,onChange:ce=>m(ce.target.value),placeholder:"搜索技能","aria-label":"搜索技能"})]}),f!==null&&L!==""&&s.jsx("p",{className:"muted small skills-found",children:B.length===0?"没有匹配的技能。":`找到 ${B.length} 个技能`}),f!==null&&L===""&&B.length===0&&s.jsx("p",{className:"muted small pad",children:"还没有技能。"}),H.map(ce=>{const Se=L!==""||!W.has(ce.key);return s.jsxs("div",{className:`skills-group ${Se?"":"folded"}`,children:[s.jsxs("div",{className:"skills-section-head",children:[s.jsxs("button",{className:"skills-fold","aria-expanded":Se,onClick:()=>Z(ce.key),children:[s.jsx(ee,{name:"chevron-down",className:"skills-chevron"}),s.jsx(ee,{name:UB(ce.key),className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:ce.label}),s.jsx("span",{className:"skills-count",children:new Set([...ce.items,...ce.subs.flatMap(re=>re.items)]).size})]}),ie(ce.label,ce,ce.game!==void 0?`给游戏「${ce.label}」新建一个技能(处理这个游戏的对话都能用)`:ce.script!==void 0?`给「${ce.label}」新建一个技能(只给它用)`:"新建一个通用技能")]}),Se&&s.jsxs(s.Fragment,{children:[ce.items.map(ge),ce.script!==void 0&&ce.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),ce.game!==void 0&&ce.items.length===0&&ce.subs.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有这个游戏的技能"}),ce.subs.map(re=>s.jsxs("div",{className:"skills-sub",children:[s.jsxs("div",{className:"skills-sub-label",children:[s.jsx(ee,{name:"package",className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:re.label}),s.jsx("span",{className:"skills-count",children:re.items.length}),s.jsx("span",{className:"spacer"}),ie(re.label,{script:re.script},`给「${re.label}」新建一个技能(只给它用)`)]}),re.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),re.items.map(ge)]},re.key))]})]},ce.key)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]}),P!==null?s.jsx(ZB,{client:e,draft:P,scripts:E,games:C,onCancel:()=>F(null),onSaved:ce=>{F(null),v(ce),w(null),N(Se=>Se+1)}}):s.jsxs(s.Fragment,{children:[f===null&&k===null&&s.jsx("p",{className:"muted",children:"正在读取…"}),f!==null&&K===void 0&&s.jsxs("div",{className:"skills-blank",children:[s.jsx(ee,{name:"sparkles"}),s.jsx("strong",{children:"还没有技能"}),s.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),s.jsxs("button",{className:"small-button primary",disabled:r.state!=="open",onClick:()=>F(xe({})),children:[s.jsx(ee,{name:"plus"}),"新建技能"]})]}),K!==void 0&&s.jsxs("article",{className:"card skill-card",children:[s.jsxs("header",{className:"skill-top",children:[s.jsxs("div",{className:"skill-title",children:[s.jsx("h2",{children:K.name}),s.jsxs("div",{className:"skill-meta",children:[fe(K).length===0?s.jsxs("span",{className:"badge",title:"所有对话都看得到、用得了",children:[s.jsx(ee,{name:"layers"}),"通用"]}):s.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了这个技能",children:[s.jsx(ee,{name:(Ne=(ae=K.owner)==null?void 0:ae.scripts)!=null&&Ne.length?"package":"gamepad"}),"只给 ",fe(K).join("、")," 用"]}),K.modelInvocable&&s.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读这个技能",children:"agent 自动使用"}),s.jsxs("span",{className:"badge",title:K.removable===!0?"存在这个软件的技能文件夹里,可以编辑和删除":`在这里不能改和删${K.source==="hub"?",到「技能库」里卸载":""}`,children:[LB(K),K.removable===!0?"":" · 只读"]})]})]}),s.jsxs("div",{className:"skill-buttons",children:[K.userInvocable&&s.jsxs("button",{className:"small-button",onClick:()=>V(K.name),title:"复制后粘贴到对话框,后面写要它做的事",children:[s.jsx(ee,{name:R?"check":"copy"}),R?"已复制":`/${K.name}`]}),(K.removable===!0||K.source==="hub")&&s.jsxs("button",{className:"small-button","aria-expanded":O,onClick:()=>T(ce=>!ce),title:"放错了游戏或脚本时,换到对的那个",children:[s.jsx(ee,{name:"gamepad"}),"更换游戏和脚本"]}),K.removable===!0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"small-button",disabled:(y==null?void 0:y.name)!==K.name,onClick:()=>{var ce,Se;return F({original:K.name,name:K.name,description:K.description,content:(y==null?void 0:y.content)??"",scripts:[...((ce=K.owner)==null?void 0:ce.scripts)??[]],games:[...((Se=K.owner)==null?void 0:Se.games)??[]]})},children:[s.jsx(ee,{name:"pencil"}),"编辑"]}),s.jsx("button",{className:"small-button danger-outline",onClick:()=>void Y(K),children:"删除"})]}),K.path!==void 0&&((Fe=kr())==null?void 0:Fe.openPath)!==void 0&&s.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${K.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var ce,Se;return void((Se=(ce=kr())==null?void 0:ce.openPath)==null?void 0:Se.call(ce,K.path.replace(/[\\/][^\\/]+$/,"")))},children:s.jsx(ee,{name:"layers"})})]})]}),O&&s.jsx(WB,{client:e,skill:K,content:(y==null?void 0:y.name)===K.name?y.content:void 0,scripts:E,games:C,onCancel:()=>T(!1),onMoved:()=>{T(!1),w(null),N(ce=>ce+1)}},K.name),s.jsx("p",{className:"skill-desc",children:K.description}),K.whenToUse!==void 0&&s.jsxs("p",{className:"muted small",children:["什么时候用:",K.whenToUse]}),s.jsxs("section",{className:"skill-body","aria-label":"技能内容",children:[s.jsx("div",{className:"skill-body-label",children:"技能内容"}),(y==null?void 0:y.name)===K.name?s.jsx(Ki,{text:y.content}):s.jsx("p",{className:"muted",children:"正在读取…"})]}),K.path!==void 0&&s.jsx("code",{className:"muted small skill-path",title:K.path,children:K.path})]})]})]})})]})]})}function ZB({client:e,draft:t,scripts:n,games:r,onCancel:i,onSaved:o}){const[c,u]=b.useState(t),[f,d]=b.useState(!1),[p,m]=b.useState(null);b.useEffect(()=>{u(t),m(null)},[t]);const g=t.original!==void 0,v=Rk.test(c.name)&&c.name.length<=Sp,y=v&&c.description.trim().length>=10&&c.content.trim().length>=20,S=async()=>{d(!0),m(null);try{await e.connection.call("skills/save",{name:c.name,description:c.description.trim(),content:c.content.trim(),...c.scripts.length===0?{}:{scripts:c.scripts},...c.games.length===0?{}:{games:c.games},...g?{replace:!0}:{}}),o(c.name)}catch(k){m(ze(k))}finally{d(!1)}};return s.jsxs("article",{className:"card skill-card skill-form",children:[s.jsx("div",{className:"skill-head",children:s.jsx("h2",{children:g?`编辑 ${t.original}`:"新建技能"})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"名字(在对话里用 /名字 调用它)"}),s.jsx("input",{className:"text-input",value:c.name,disabled:g,maxLength:Sp,autoFocus:!g,onChange:k=>u(w=>({...w,name:k.target.value.trim().toLowerCase()})),placeholder:"例:maa-daily-check"}),c.name!==""&&!v&&s.jsx("span",{className:"error small",children:"只能用小写英文字母、数字和短横线,例如 maa-daily-check"})]}),s.jsx(xS,{scripts:n,games:r,value:c,onChange:k=>u(w=>({...w,...k}))}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"说明:做什么、什么时候用(agent 靠它决定什么时候用,10–400 字)"}),s.jsx("textarea",{className:"text-input",rows:2,maxLength:400,value:c.description,onChange:k=>u(w=>({...w,description:k.target.value})),placeholder:"例:MAA 日常跑完后检查理智和基建是否都处理了;用户问「MAA 跑完了吗」时用。"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"内容(Markdown):适用场景、一步一步的做法、怎样算成功、注意事项"}),s.jsx("textarea",{className:"text-input skill-content-input",rows:16,maxLength:2e4,value:c.content,onChange:k=>u(w=>({...w,content:k.target.value}))})]}),p!==null&&s.jsx("p",{className:"error small",children:p}),s.jsxs("div",{className:"skill-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:f,onClick:i,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:f||!y,onClick:()=>void S(),children:f?"保存中…":"保存"})]})]})}function xS({scripts:e,games:t,value:n,onChange:r}){const[i]=b.useState(n),o=[...new Set([...i.scripts,...n.scripts])].filter(p=>!e.some(m=>m.id===p)),c=[...new Set([...i.games,...n.games])].filter(p=>Dp(p,t)===void 0),u=(p,m)=>{var g;return p===m||((g=Dp(p,t))==null?void 0:g.id)===m},f=p=>r({...n,scripts:n.scripts.includes(p)?n.scripts.filter(m=>m!==p):[...n.scripts,p]}),d=p=>r({...n,games:n.games.some(m=>u(m,p))?n.games.filter(m=>!u(m,p)):[...n.games,p]});return s.jsxs(s.Fragment,{children:[(t.length>0||c.length>0)&&s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个游戏用(和游戏本身有关、换个脚本也用得上的:游戏里的操作、界面、活动、机制)"}),s.jsxs("div",{className:"skill-owner-list",children:[t.map(p=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.games.some(m=>u(m,p.id)),onChange:()=>d(p.id)}),p.name]},p.id)),c.map(p=>s.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[s.jsx("input",{type:"checkbox",checked:n.games.includes(p),onChange:()=>d(p)}),p]},p))]})]}),s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个脚本用(只在用这个脚本时才用得上的做法:它的配置、报错、日志)"}),e.length===0&&o.length===0&&s.jsx("span",{className:"muted small",children:"还没有装脚本。"}),s.jsxs("div",{className:"skill-owner-list",children:[e.map(p=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(p.id),onChange:()=>f(p.id)}),p.name]},p.id)),o.map(p=>s.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(p),onChange:()=>f(p)}),p]},p))]})]}),s.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function WB({client:e,skill:t,content:n,scripts:r,games:i,onCancel:o,onMoved:c}){var S,k;const[u,f]=b.useState({scripts:[...((S=t.owner)==null?void 0:S.scripts)??[]],games:[...((k=t.owner)==null?void 0:k.games)??[]]}),[d,p]=b.useState(!1),[m,g]=b.useState(null),v=t.source==="hub",y=async w=>{p(!0),g(null);try{if(v)await e.connection.call("skillhub/owner",{name:t.name,owner:w});else{if(n===void 0||w===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:n,replace:!0,...w.scripts.length===0?{}:{scripts:w.scripts},...w.games.length===0?{}:{games:w.games}})}c()}catch(A){g(ze(A))}finally{p(!1)}};return s.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[s.jsx(xS,{scripts:r,games:i,value:u,onChange:f}),v&&s.jsx("p",{className:"muted small",children:"这是从技能库下载的技能:你选的会一直保留,技能库更新它也不变。"}),m!==null&&s.jsx("p",{className:"error small",children:m}),s.jsxs("div",{className:"skill-actions",children:[v&&s.jsx("button",{className:"link-button small",disabled:d,onClick:()=>void y(null),children:"恢复成技能库里的"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d,onClick:o,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:d||!v&&n===void 0,onClick:()=>void y(u),children:d?"保存中…":"保存"})]})]})}const VB={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:HB}]};function qB({client:e}){const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(0),[c,u]=b.useState(null),[f,d]=b.useState(null),[p,m]=b.useState(""),[g,v]=b.useState("");b.useEffect(()=>e.connection.on("emulators/changed",()=>o(k=>k+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let k=!0;return e.connection.call("emulators/status",{refresh:i===0}).then(w=>{k&&(r(w),m(w.settings.manualAddress??""),v(w.settings.adbPath??""))}).catch(w=>{k&&d(ze(w))}),()=>{k=!1}},[e,t.state,i]);const y=async(k,w)=>{u(k),d(null);try{await w(),o(A=>A+1)}catch(A){d(ze(A))}finally{u(null)}},S=k=>y("settings",()=>e.connection.call("emulators/settings/set",k));return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模拟器"}),s.jsx("p",{children:"需要安卓模拟器的任务(如 MAA)运行前,会自动启动这里选定的实例并取得 ADB 地址。分辨率请设为 16:9(如 1280×720)。"}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"当前使用"}),s.jsx("p",{className:"muted small",children:(n==null?void 0:n.selection.label)??"…"})]}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y("refresh",()=>e.connection.call("emulators/status",{refresh:!0})),children:"重新检测"})]}),(n==null?void 0:n.selection.problem)!==void 0&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:[n.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),n==null?void 0:n.providers.map(k=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[k.name,k.version===void 0?"":` ${k.version}`]}),s.jsx("p",{className:"muted small",children:k.manager})]}),n.settings.mumuManager===k.manager&&s.jsx("span",{className:"badge ok",children:"已指定"})]}),k.error!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k.error})]}),s.jsx("ul",{className:"version-list",children:k.instances.map(w=>s.jsxs("li",{className:w.index===n.settings.instance?"current":"",children:[s.jsx("span",{className:"version-name",children:w.index}),s.jsx("span",{children:w.name}),s.jsx("span",{className:`badge ${w.ready?"ok":""}`,children:w.ready?"已启动":w.running?"启动中":"未运行"}),w.adb!==void 0&&s.jsx("span",{className:"muted small",children:w.adb}),s.jsx("span",{className:"spacer"}),w.index!==n.settings.instance&&s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({instance:w.index}),children:"任务用这个"}),w.ready?s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`stop-${w.index}`,()=>e.connection.call("emulators/stop",{index:w.index})),children:"关闭"}):s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`start-${w.index}`,()=>e.connection.call("emulators/start",{index:w.index})),children:c===`start-${w.index}`?"启动中…":"启动"})]},w.index))})]},k.manager)),n!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"设置"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.autoStart,onChange:k=>void S({autoStart:k.target.checked})}),"任务需要时自动启动模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"manual-adb",children:"手动 ADB 地址(其他模拟器或真机,可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"manual-adb",className:"text-input plain",value:p,onChange:k=>m(k.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({manualAddress:p.trim()===""?null:p.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"adb-path",children:"adb.exe 位置(可选,出错时重连模拟器、截图用;默认用 MuMu 自带的)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"adb-path",className:"text-input plain",value:g,onChange:k=>v(k.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void S({adbPath:g.trim()===""?null:g.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"boot-timeout",children:"等待安卓启动的最长时间(秒)"}),s.jsx("input",{id:"boot-timeout",className:"text-input plain",type:"number",min:30,max:900,defaultValue:n.settings.bootTimeoutSeconds,onBlur:k=>void S({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(k.target.value)||180))})})]}),f!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]})]})}function GB({client:e}){const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(""),[f,d]=b.useState(""),[p,m]=b.useState(null),[g,v]=b.useState(!1),[y,S]=b.useState(null),[k,w]=b.useState(null),A=()=>e.connection.call("scripts/settings",{}).then(P=>{r(P),o(P)}).catch(P=>w(ze(P)));if(b.useEffect(()=>{t.state==="open"&&A()},[e,t.state]),i===null||n===null)return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),k===null?s.jsx("p",{children:"加载中…"}):s.jsx("div",{className:"notice error left",children:k})]});const N=(P,F)=>o({...i,[P]:F}),R=async()=>{v(!0),w(null),S(null);try{const{tokenConfigured:P,cdkConfigured:F,...W}=n,M=Object.fromEntries(Object.entries(i).filter(([O,T])=>W[O]!==T));Object.keys(M).length>0&&await e.connection.call("scripts/settings/set",M),c.trim()!==""&&await e.connection.call("credentials/set",{ref:i.tokenRef,value:c.trim()}),u(""),f.trim()!==""&&(await e.connection.call("credentials/set",{ref:i.cdkRef,value:f.trim()}),d(""),D()),await A(),S("已保存,下一次安装起生效")}catch(P){w(ze(P))}finally{v(!1)}},D=async()=>{m("checking");try{m(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(P){m({ok:!1,message:ze(P)})}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),s.jsx("p",{children:"从 GitHub 发布页下载脚本时使用的设置。国内网络下载慢或失败时,可以填写下载镜像前缀。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"下载镜像"}),s.jsx("input",{className:"text-input plain",value:i.downloadMirror,onChange:P=>N("downloadMirror",P.target.value),placeholder:"留空直接下载;例如 https://ghfast.top/",spellCheck:!1}),s.jsx("p",{className:"muted small",children:"镜像只用于 GitHub 上的文件:下载地址前面加上这个前缀。微软、Google 等官方组件始终直接下载。"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:i.mirrorFallback,onChange:P=>N("mirrorFallback",P.target.checked)}),"镜像失败时改为直接下载"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"Mirror酱"}),s.jsxs("p",{className:"muted small",children:["在 ",s.jsx("a",{href:"https://mirrorchyan.com?source=multigameassistant_settings",target:"_blank",rel:"noreferrer",children:"Mirror酱"})," 发布的脚本(MAA、MaaEnd、三月七小助手、M9A、BetterGI 等)填了 CDK 后从 Mirror酱 更新:国内下载快,而且只下载改动的文件(增量更新)。不填照常从 GitHub 下载;CDK 过期、次数用完时也会自动改回 GitHub。"]}),s.jsx("label",{className:"field-label",htmlFor:"mc-cdk",children:"CDK"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"mc-cdk",className:"text-input",type:"password",value:f,onChange:P=>d(P.target.value),placeholder:n.cdkConfigured?"已配置;输入新值可替换":"在 Mirror酱 购买后得到的 CDK",autoComplete:"off"}),n.cdkConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"}),n.cdkConfigured&&s.jsx("button",{className:"small-button",disabled:p==="checking",onClick:()=>void D(),children:p==="checking"?"检查中…":"检查"})]}),p!==null&&p!=="checking"&&s.jsx("p",{className:"small",style:{color:p.ok?"var(--ok)":"var(--error)"},children:p.message}),s.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",i.cdkRef,"),界面和日志里都不会显示它。"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"GitHub 访问"}),s.jsx("label",{className:"field-label",htmlFor:"gh-token",children:"GitHub Token(可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"gh-token",className:"text-input",type:"password",value:c,onChange:P=>u(P.target.value),placeholder:n.tokenConfigured?"已配置;输入新值可替换":"不填也能用;填写后请求上限从每小时 60 次提高到 5000 次",autoComplete:"off"}),n.tokenConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"})]}),s.jsxs("p",{className:"muted small",children:["只需要读取公开仓库的权限。保存在 dsh 的凭据文件里(",i.tokenRef,"),界面不会显示它的内容。"]}),s.jsx("label",{className:"field-label",htmlFor:"gh-api",children:"API 地址"}),s.jsx("input",{id:"gh-api",className:"text-input plain",value:i.apiBase,onChange:P=>N("apiBase",P.target.value),spellCheck:!1})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"版本"}),s.jsx("label",{className:"field-label",htmlFor:"keep-versions",children:"每个脚本保留的版本数(含当前版本)"}),s.jsx("input",{id:"keep-versions",className:"text-input plain",type:"number",min:1,max:10,value:i.keepVersions,onChange:P=>N("keepVersions",Math.max(1,Math.min(10,Number(P.target.value)||1)))}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:i.includePrereleases,onChange:P=>N("includePrereleases",P.target.checked)}),"没有正式版时使用预发布版本"]})]}),s.jsxs("div",{className:"key-actions",children:[y!==null&&s.jsx("span",{className:"muted small",children:y}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",disabled:g,onClick:()=>void R(),children:g?"保存中…":"保存"})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]})]})}function KB({client:e,initialRepo:t,jobs:n,onDone:r,openSession:i,onClose:o}){const[c,u]=b.useState(t??""),[f,d]=b.useState(null),[p,m]=b.useState(""),[g,v]=b.useState(""),[y,S]=b.useState(!1),[k,w]=b.useState(null),[A,N]=b.useState(null),R=async(M=c)=>{var T;const O=A$(M);if(O===void 0){w("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}S(!0),w(null);try{const Z=await e.connection.call("scripts/releases",{repo:O.repo,limit:10});u(O.repo),d({...Z,branch:O.branch});const E=Z.releases.find($=>$.tag===O.tag),C=E??Z.releases.find($=>!$.prerelease)??Z.releases[0];m((C==null?void 0:C.tag)??""),v(((T=C==null?void 0:C.assets.find($=>$.name===O.asset))==null?void 0:T.name)??(C==null?void 0:C.suggestedAsset)??""),O.tag!==void 0&&E===void 0&&Z.releases.length>0&&w(`最近的发布里没有 ${O.tag},已改选最新版本`)}catch(Z){d(null),w(ze(Z))}finally{S(!1)}};b.useEffect(()=>{t!==void 0&&R(t)},[t]);const D=f==null?void 0:f.releases.find(M=>M.tag===p),P=f!==null&&(f.branch!==void 0||f.releases.length===0),F=async()=>{if(f!==null){S(!0),w(null);try{const{jobId:M,scriptId:O}=await e.connection.call("scripts/install",{repo:f.repo,...f.branch===void 0?{}:{branch:f.branch}});N({jobId:M,scriptId:O,tag:f.branch===void 0?"默认分支":`${f.branch} 分支`,asset:"源码压缩包"})}catch(M){w(ze(M))}finally{S(!1)}}},W=async()=>{var M;if(!(f===null||D===void 0||g==="")){S(!0),w(null);try{const{jobId:O,scriptId:T}=await e.connection.call("scripts/install",{repo:f.repo,tag:D.tag,asset:g});N({jobId:O,scriptId:T,tag:D.tag,asset:g,size:(M=D.assets.find(Z=>Z.name===g))==null?void 0:M.size})}catch(O){w(ze(O))}finally{S(!1)}}};if(A!==null&&f!==null){const M=n.get(A.scriptId);return s.jsx(vS,{client:e,repo:f.repo,...A,job:(M==null?void 0:M.id)===A.jobId?M:void 0,onDone:()=>r(A.scriptId),openSession:i,onRetry:()=>N(null),onClose:o})}return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"从 GitHub 安装"}),s.jsx("p",{className:"muted small",children:"优先使用发布版本;文件会放进统一的工具目录,旧版本保留用于回滚。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:o,children:s.jsx(ee,{name:"close"})})]}),s.jsxs("form",{className:"field-row",onSubmit:M=>{M.preventDefault(),R()},children:[s.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:c,onChange:M=>u(M.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:y}),s.jsx("button",{type:"submit",disabled:y||c.trim()==="",children:y&&f===null?"读取中…":"读取发布"})]}),P&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:f.branch!==void 0?`链接指向 ${f.branch} 分支:会下载这个分支当前的源码,之后跟着它更新。`:"这个仓库还没有发布版本:可以下载默认分支当前的源码,之后跟着这个分支更新。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:f.releases.length===0?"primary":"",onClick:()=>void F(),disabled:y,children:["安装",f.branch===void 0?"源码":` ${f.branch} 分支`]})]}),f!==null&&f.releases.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",f.packId!==void 0&&s.jsxs("span",{className:"chip subtle",children:["内置脚本包 ",f.packId]})]}),s.jsx(yn,{id:"release-select",value:p,disabled:y,onChange:M=>{var O;m(M),v(((O=f.releases.find(T=>T.tag===M))==null?void 0:O.suggestedAsset)??"")},options:f.releases.map(M=>({value:M.tag,label:`${M.tag}${M.prerelease?"(预发布)":""}`,...M.publishedAt===void 0?{}:{hint:`${M.publishedAt.slice(0,10)} 发布`}}))}),D!==void 0&&s.jsxs("fieldset",{className:"asset-list",disabled:y,children:[s.jsx("legend",{className:"field-label",children:"下载文件"}),D.assets.length===0&&s.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...D.assets].sort((M,O)=>+(O.name===D.suggestedAsset)-+(M.name===D.suggestedAsset)).map(M=>s.jsxs("label",{className:`asset-option ${M.name===g?"active":""}`,children:[s.jsx("input",{type:"radio",name:"asset",value:M.name,checked:M.name===g,onChange:()=>v(M.name)}),s.jsx("span",{className:"asset-name",children:M.name}),M.name===D.suggestedAsset&&s.jsx("span",{className:"badge ok",children:"推荐"}),s.jsx("span",{className:"muted small",children:va(M.size)})]},M.name))]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(D==null?void 0:D.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"primary",onClick:()=>void W(),disabled:y||g==="",children:["安装 ",D==null?void 0:D.tag]})]})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]})]})}function YB({client:e,initialRid:t,jobs:n,onDone:r,openSession:i,onGitHub:o,onClose:c}){const[u,f]=b.useState(""),d=XB(e,u),[p,m]=b.useState(null),[g,v]=b.useState(null),[y,S]=b.useState(!1),[k,w]=b.useState(null),[A,N]=b.useState(null);b.useEffect(()=>{e.connection.call("scripts/settings",{}).then(W=>v(W.cdkConfigured),()=>v(null))},[e]);const R=async W=>{S(!0),w(null);try{m(await e.connection.call("scripts/mirrorchyan/lookup",{rid:W}))}catch(M){m(null),w(ze(M))}finally{S(!1)}};b.useEffect(()=>{t!==void 0&&R(t)},[t]);const D=async()=>{if(p!==null){S(!0),w(null);try{N(await e.connection.call("scripts/install",{mirrorchyan:p.rid}))}catch(W){w(ze(W))}finally{S(!1)}}};if(A!==null&&p!==null){const W=n.get(A.scriptId);return s.jsx(vS,{client:e,repo:`Mirror酱 · ${p.rid}`,tag:p.version,asset:`${p.name??p.rid}(Mirror酱 完整包)`,job:(W==null?void 0:W.id)===A.jobId?W:void 0,onDone:()=>r(A.scriptId),openSession:i,onRetry:()=>N(null),onClose:c})}const P=u.trim(),F=/^[\w.-]{1,100}$/.test(P)&&!(d.items??[]).some(W=>W.rid.toLowerCase()===P.toLowerCase());return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"从 Mirror酱 安装"}),s.jsx("p",{className:"muted small",children:"按游戏名、工具名或资源 id 查找(查找和查询版本都不需要 CDK);下载需要在「设置 → 脚本安装」填写 CDK,以后的更新有增量包。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:c,children:s.jsx(ee,{name:"close"})})]}),s.jsx("input",{className:"text-input plain","aria-label":"搜索 Mirror酱",value:u,onChange:W=>f(W.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),s.jsx(QB,{results:d,selected:p==null?void 0:p.rid,disabled:y,onPick:W=>void R(W)}),F&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"small-button",disabled:y,onClick:()=>void R(P),children:["按资源 id 查询 ",P]})]}),p!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"install-file",children:[s.jsx(ee,{name:"package"}),s.jsx("span",{className:"asset-name",children:p.name??p.rid}),s.jsxs("span",{className:"badge",children:["Mirror酱 ",p.rid]}),s.jsxs("span",{className:"muted small",children:["最新 ",p.version]})]}),p.description!==void 0&&s.jsx("p",{className:"muted small mirror-desc",children:p.description}),g===!1&&s.jsx("div",{className:"notice info left small",children:s.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",p.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:p.repo===void 0?"":`GitHub:${p.repo}`}),s.jsx("span",{className:"spacer"}),p.repo!==void 0&&s.jsx("button",{className:"small-button",disabled:y,onClick:()=>o(p.repo),children:"从 GitHub 安装"}),s.jsxs("button",{className:"primary",onClick:()=>void D(),disabled:y||g===!1,children:["安装 ",p.version]})]})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:k})]})]})}function XB(e,t){const[n,r]=b.useState({loading:!0});return b.useEffect(()=>{let i=!0;r(c=>({...c,loading:!0}));const o=setTimeout(()=>{e.connection.call("scripts/mirrorchyan/search",{query:t.trim()}).then(c=>{i&&r({items:c.items,from:c.from,loading:!1})}).catch(c=>{i&&r({error:ze(c),loading:!1})})},t.trim()===""?0:250);return()=>{i=!1,clearTimeout(o)}},[e,t]),n}function QB({results:e,selected:t,disabled:n,limit:r=8,onPick:i,pickLabel:o="选择"}){const[c,u]=b.useState(!1);if(e.error!==void 0)return s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:e.error})]});const f=e.items??[];if(f.length===0)return s.jsx("div",{className:"muted small mirror-empty",children:e.loading?"查找中…":"没有找到。可以换个说法(游戏简称、英文名),或直接输入资源 id。"});const d=c?f:f.slice(0,r);return s.jsxs(s.Fragment,{children:[e.from==="builtin"&&s.jsx("div",{className:"muted small mirror-empty",children:"读不到 Mirror酱 的项目列表,下面是已知的几个;也可以直接输入资源 id 查询。"}),s.jsx("ul",{className:"mirror-results",children:d.map(p=>s.jsxs("li",{className:p.rid===t?"active":"",children:[s.jsxs("div",{className:"mirror-result-main",children:[s.jsxs("span",{className:"mirror-result-name",children:[p.name,s.jsx("span",{className:"chip subtle",children:p.rid}),p.installed&&s.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),p.description!==""&&s.jsx("span",{className:"muted small",children:p.description})]}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>i(p.rid),children:o})]},p.rid))}),!c&&f.length>r&&s.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",f.length-r," 个"]})]})}const Ob=["resolving","downloading","verifying","extracting","checking","done"];function vS({client:e,repo:t,tag:n,asset:r,size:i,job:o,onDone:c,openSession:u,onRetry:f,onClose:d}){const p=(o==null?void 0:o.phase)??"queued",m=p==="done"?o==null?void 0:o.setup:void 0,g=o===void 0||o.endedAt===void 0,v=JB(o==null?void 0:o.received),y=(o==null?void 0:o.total)??i,S=y!==void 0&&y>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/y):void 0,k=b.useRef(-1),w=Ob.indexOf(p);w>k.current&&(k.current=w);const A=m!==void 0?"交给 agent 安装":p==="done"?"安装完成":p==="failed"?"安装失败":p==="cancelled"?"已取消安装":"正在安装",N=R=>p==="done"||R<k.current?"done":R===k.current?g?"active":"stopped":"todo";return s.jsxs("section",{className:"card panel-card install-progress","aria-live":"polite",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:A}),s.jsxs("p",{className:"muted small",children:[t," · ",n]})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:g?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:d,children:s.jsx(ee,{name:"close"})})]}),s.jsxs("div",{className:"install-file",children:[s.jsx(ee,{name:"package"}),s.jsx("span",{className:"asset-name",children:r}),i!==void 0&&s.jsx("span",{className:"muted small",children:va(i)})]}),s.jsx("ol",{className:"install-steps",children:Ob.slice(0,-1).map((R,D)=>{const P=N(D);return s.jsxs("li",{className:`install-step ${P}`,children:[s.jsx("span",{className:"install-step-mark",children:P==="done"?s.jsx(ee,{name:"check"}):P==="stopped"?s.jsx(ee,{name:"close"}):D+1}),s.jsx("span",{children:qu[R]})]},R)})}),g&&s.jsxs("div",{className:"install-bar",children:[s.jsx("div",{className:`progress ${p==="downloading"&&S!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:s.jsx("span",{style:p==="downloading"&&S!==void 0?{width:`${(S*100).toFixed(1)}%`}:void 0})}),s.jsxs("div",{className:"install-numbers muted small",children:[s.jsx("span",{children:o===void 0?"等待开始…":o.message??qu[p]}),p==="downloading"&&(o==null?void 0:o.received)!==void 0&&s.jsxs("span",{className:"install-bytes",children:[va(o.received),y!==void 0?` / ${va(y)}`:"",S!==void 0?` · ${Math.floor(S*100)}%`:"",v!==void 0?` · ${va(Math.round(v))}/s`:"",v!==void 0&&v>0&&y!==void 0?` · 还要 ${eU((y-o.received)/v)}`:""]})]})]}),(o==null?void 0:o.error)!==void 0&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:o.error})]}),m!==void 0&&s.jsxs("div",{className:"notice left",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:[o==null?void 0:o.message,"。它也在左边「等待安装」里:没配好模型时可以在那里自己安装。装好后脚本会出现在列表里。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:g?"可以关掉这个面板,安装会在后台继续。":m!==void 0?`下载好了 ${(o==null?void 0:o.version)??n} 的安装程序。`:p==="done"?`已安装 ${(o==null?void 0:o.version)??n}。`:""}),s.jsx("span",{className:"spacer"}),g&&o!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(p==="failed"||p==="cancelled")&&s.jsx("button",{className:"small-button",onClick:f,children:"重新选择"}),(m==null?void 0:m.sessionId)!==void 0&&s.jsx("button",{className:"primary small-button",onClick:()=>u(m.sessionId),children:"查看对话"}),p==="done"&&m===void 0&&s.jsx("button",{className:"primary small-button",onClick:c,children:"查看脚本"})]})]})}function JB(e){const t=b.useRef([]),[n,r]=b.useState(void 0);return b.useEffect(()=>{if(e===void 0)return;const i=Date.now(),o=[...t.current.filter(u=>i-u.at<=4e3&&u.bytes<=e),{at:i,bytes:e}];t.current=o;const c=o[0];i-c.at>=500&&r((e-c.bytes)/((i-c.at)/1e3))},[e]),n}function eU(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function tU({client:e,onImported:t,onClose:n}){const[r,i]=b.useState(""),[o,c]=b.useState(""),[u,f]=b.useState(!1),[d,p]=b.useState(null),m=async()=>{f(!0),p(null);try{const g=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(g.id)}catch(g){p(ze(g)),f(!1)}};return s.jsxs("section",{className:"card panel-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"导入本地项目"}),s.jsx("p",{className:"muted small",children:"登记电脑上已有的脚本目录,原地使用:不移动、不复制、不修改,移除时也不会删除。"})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",onClick:n,children:s.jsx(ee,{name:"close"})})]}),s.jsxs("form",{className:"import-form",onSubmit:g=>{g.preventDefault(),m()},children:[s.jsx("label",{className:"field-label",htmlFor:"import-path",children:"目录路径"}),s.jsx("input",{id:"import-path",className:"text-input plain",value:r,onChange:g=>i(g.target.value),placeholder:"例如 D:\\Games\\MAA",spellCheck:!1,disabled:u}),s.jsx("label",{className:"field-label",htmlFor:"import-name",children:"显示名称(可选)"}),s.jsx("input",{id:"import-name",className:"text-input plain",value:o,onChange:g=>c(g.target.value),placeholder:"留空则按脚本包或目录名",disabled:u}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"会按内置脚本包自动识别是哪个脚本。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",type:"submit",disabled:u||r.trim()==="",children:u?"导入中…":"导入"})]})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]})]})}function pm({client:e,job:t,compact:n=!1}){const r=t.endedAt===void 0,i=t.total!==void 0&&t.total>0&&t.received!==void 0?Math.min(1,t.received/t.total):void 0,o=t.kind==="env-fix"?"修复环境":t.kind==="update"?"更新":"安装";return s.jsxs("div",{className:`job ${t.phase}${n?" compact":""}`,role:"status",children:[s.jsxs("div",{className:"job-line",children:[s.jsxs("span",{className:"job-phase",children:[o," · ",t.setup!==void 0&&t.phase==="done"?"已交给 agent 安装":qu[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),i!==void 0&&r&&s.jsxs("span",{className:"job-bytes",children:[va(t.received??0)," / ",va(t.total??0)]}),r&&s.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),r&&s.jsx("div",{className:`progress ${i===void 0?"indeterminate":""}`,"aria-hidden":"true",children:s.jsx("span",{style:i===void 0?void 0:{width:`${(i*100).toFixed(1)}%`}})}),!n&&t.message!==void 0&&(r||t.setup!==void 0)&&s.jsx("div",{className:"job-message muted small",children:t.message}),t.error!==void 0&&s.jsx("div",{className:"job-error small",children:t.error})]})}const nU={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function yS({client:e,script:t,disabled:n,act:r}){const[i,o]=b.useState(null),[c,u]=b.useState(""),[f,d]=b.useState(null),p=t.channels.github,m=t.channels.mirrorchyan,g=(k,w)=>r("channel",async()=>{await e.connection.call("scripts/source/set",w==="reset"?{id:t.id,reset:[k]}:k==="repo"?{id:t.id,repo:w}:{id:t.id,mirrorchyan:w}),o(null);const A=k==="repo"?"GitHub":"Mirror酱";return w===null?`已不再从 ${A} 更新`:w==="reset"?`${A} 更新渠道已恢复自动`:`${A} 更新渠道已设为 ${w}`}),v=()=>r("mirror-match",async()=>{const k=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return d({items:k.items,checked:!0}),k.items.length===0?`Mirror酱 上没有找到它${k.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),y=(k,w)=>k==="repo"?/^[\w.-]+\/[\w.-]+$/.test(w):/^[\w.-]{1,100}$/.test(w),S=(k,w,A,N,R)=>s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:w}),s.jsx("dd",{children:i!==k?s.jsxs(s.Fragment,{children:[A!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:A.text}),s.jsxs("span",{className:"muted small",children:["(",nU[A.from],")"]})]}):s.jsx("span",{className:"muted small",children:N}),(A==null?void 0:A.from)!=="install"&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>{u((A==null?void 0:A.text)??""),o(k)},children:A===void 0?"设置":"修改"}),k==="mirrorchyan"&&A===void 0&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>void v(),children:"查询是否接入"})]}):s.jsxs("span",{className:"local-source-edit",children:[s.jsx("input",{className:"text-input plain","aria-label":`${w}更新渠道`,value:c,onChange:D=>u(D.target.value),placeholder:R,spellCheck:!1,autoFocus:!0}),s.jsx("button",{className:"primary small-button",disabled:n||!y(k,c.trim()),onClick:()=>void g(k,c.trim()),children:k==="mirrorchyan"?"查询并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g(k,"reset"),children:"恢复自动"}),A!==void 0&&s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g(k,null),children:"不用"}),s.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return s.jsxs(s.Fragment,{children:[S("repo","GitHub",p===void 0?void 0:{text:p.repo,from:p.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),S("mirrorchyan","Mirror酱",m===void 0?void 0:{text:m.rid,from:m.from},"未设置:在 Mirror酱 发布的脚本填它的资源 id","资源 id,例如 BGI、MAA"),m===void 0&&f!==null&&f.items.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{}),s.jsxs("dd",{className:"mirror-matches",children:[s.jsx("span",{className:"muted small",children:"Mirror酱 上可能是它:"}),f.items.slice(0,5).map(k=>s.jsxs("span",{className:"mirror-match",children:[s.jsx("span",{children:k.name}),s.jsx("span",{className:"chip subtle",children:k.rid}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g("mirrorchyan",k.rid).then(()=>d(null)),children:"用这个"})]},k.rid))]})]})]})}function sU({client:e,script:t,disabled:n,busy:r,now:i,act:o}){const[c,u]=b.useState(!1),f=t.localVersion,d=t.update,p=t.channels.github!==void 0||t.channels.mirrorchyan!==void 0;return s.jsxs("div",{className:"local-update",children:[s.jsxs("dl",{className:"local-facts",children:[s.jsx("dt",{children:"当前版本"}),s.jsx("dd",{children:f!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-name",children:f.version}),s.jsx("span",{className:"muted small",children:f.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${f.from})`})]}):s.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),s.jsx(yS,{client:e,script:t,disabled:n,act:o})]}),c?s.jsxs("div",{className:"local-confirm",children:[s.jsxs("p",{className:"small",children:["将在 ",s.jsx("code",{children:t.dir})," 里更新到 ",d==null?void 0:d.latest,":被替换的程序文件先备份到工具目录(可以撤销),已有的配置文件不动。请先关闭这个脚本。"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>u(!1),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:n,onClick:()=>void o("update",async()=>(u(!1),(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0)),children:"确认更新"})]})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[d===void 0?"还没有检查过更新":d.available?`有新版本 ${d.latest}`:`已是最新(${d.latest})`,d!==void 0&&` · ${Tt(d.checkedAt,i)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n||!p,onClick:()=>void o("check",async()=>{const m=await e.connection.call("scripts/checkUpdate",{id:t.id});return m.available?`发现新版本 ${m.latest}${m.current===void 0?"(认不出当前版本)":`,当前 ${m.current}`}`:"已是最新版本"}),children:r==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:n||(d==null?void 0:d.available)!==!0,onClick:()=>u(!0),children:"更新"})]}),t.undo!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["上次更新:",t.undo.from??"(未知版本)"," → ",t.undo.to," · ",Tt(t.undo.at,i)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void o("restore",async()=>{const m=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${m.localVersion===void 0?"":`(${m.localVersion.version})`}`}),children:r==="restore"?"撤销中…":"撤销上次更新"})]})]})}function rU({client:e,script:t,openSession:n}){var P,F,W;const r=je(e.connection.status),i=je(e.capabilities),o=Cn(6e4),[c,u]=b.useState([]),[f,d]=b.useState(0),[p,m]=b.useState(!1),[g,v]=b.useState(null),[y,S]=b.useState(null);b.useEffect(()=>e.connection.on("packs/changed",()=>d(M=>M+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!i.has("packs"))return;let M=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(O=>{M&&u(O.items)}).catch(()=>{}),()=>{M=!1}},[e,t.id,r.state,i,f]);const k=async M=>{m(!0),v(null);try{await M()}catch(O){v(ze(O))}finally{m(!1)}},w=()=>k(async()=>{const{sessionId:M}=await e.connection.call("sessions/create",{focus:{scripts:[t.id]}});await e.connection.call("session/prompt",{sessionId:M,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),${t.packId===void 0?"为它生成":"检查并改进它的"}脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。用 pack_propose 提交草稿,docs 里写明依据的文档。`}),n(M)}),A=M=>k(async()=>{const{sessionId:O}=await e.connection.call("scripts/packReview",{id:t.id,decision:M});O!==void 0&&n(O)}),N=M=>k(async()=>{const{sessionId:O}=await e.connection.call("scripts/optimize",{id:t.id,decision:M});O!==void 0&&n(O)}),R=c[0],D=(P=t.optimize)==null?void 0:P.due;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"脚本包"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"还没有脚本包:agent 还不知道怎么运行它。":`使用脚本包 ${t.packId}。`})]}),s.jsxs("span",{className:"key-actions",children:[t.packId!==void 0&&s.jsxs("button",{className:"small-button",disabled:p||r.state!=="open",onClick:()=>void N("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[s.jsx(ee,{name:"sparkles"}),"优化脚本"]}),s.jsxs("button",{className:"small-button",disabled:p||r.state!=="open",onClick:()=>void w(),children:[s.jsx(ee,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&R===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(ee,{name:"refresh"}),s.jsxs("span",{children:[t.name," 从 ",t.packReview.from??"旧版本"," 更新到了 ",t.packReview.to,",脚本包是按旧版本写的。要让 agent 先读这次的更新日志,再检查脚本包要不要改吗?"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void A("keep"),children:"不用改"}),s.jsx("button",{className:"primary small-button",disabled:p||r.state!=="open",onClick:()=>void A("check"),children:"让 agent 检查"})]})]}),D!==void 0&&t.packReview===void 0&&R===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(ee,{name:"sparkles"}),s.jsxs("span",{children:[D==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((F=t.optimize)==null?void 0:F.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((W=t.optimize)==null?void 0:W.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void N("keep"),children:"这次不用"}),s.jsx("button",{className:"primary small-button",disabled:p||r.state!=="open",onClick:()=>void N("run"),children:"优化脚本"})]})]}),R!==void 0&&s.jsxs("div",{className:"draft",children:[s.jsxs("div",{className:"draft-head",children:[s.jsx("span",{className:"badge warn",children:"待确认的草稿"}),s.jsxs("span",{className:"muted small",children:[Tt(R.proposedAt,o),"提交 · 任务:",R.tasks.map(M=>M.title).join("、")||"无"]})]}),s.jsx("p",{className:"draft-summary",children:R.summary}),R.docs!==void 0&&R.docs.length>0&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["依据的文档(",R.docs.length,")"]}),s.jsx("ul",{children:R.docs.map(M=>s.jsxs("li",{children:[s.jsx("code",{children:M.source}),":",M.used]},M.source))})]}),R.noDocs!==void 0&&s.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",R.noDocs]}),R.current!==void 0&&s.jsxs("p",{className:"muted small",children:["接受后会替换当前的",R.current.builtin?"内置":"","脚本包(之前的版本会保留在历史里)。"]}),s.jsxs("div",{className:"segmented draft-tabs",children:[s.jsxs("label",{className:y==="manifest"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="manifest",onChange:()=>S(M=>M==="manifest"?null:"manifest")}),"adg.script.yaml"]}),s.jsxs("label",{className:y==="skill"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="skill",onChange:()=>S(M=>M==="skill"?null:"skill")}),"SKILL.md"]})]}),y!==null&&s.jsx("pre",{className:"draft-text",children:y==="manifest"?R.manifest:R.skill}),s.jsxs("div",{className:"key-actions",children:[R.sessionId!==void 0&&s.jsx("button",{className:"link-button",onClick:()=>n(R.sessionId),children:"查看分析过程"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void k(()=>e.connection.call("packs/reject",{packId:R.packId})),children:"拒绝"}),s.jsx("button",{className:"primary small-button",disabled:p,onClick:()=>void k(()=>e.connection.call("packs/accept",{packId:R.packId})),children:"接受并使用"})]})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:g})]})]})}function iU({client:e,script:t}){const n=je(e.connection.status),r=Cn(15e3),[i,o]=b.useState(void 0),[c,u]=b.useState(0),[f,d]=b.useState(30),[p,m]=b.useState(null);b.useEffect(()=>e.connection.on("guard/changed",()=>u(y=>y+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let y=!0;return e.connection.call("guard/grants",{}).then(S=>{y&&o(S.items.find(k=>k.scriptId===t.id))}).catch(()=>{}),()=>{y=!1}},[e,t.id,n.state,c]);const g=i!==void 0&&i.expiresAt>r?i:void 0,v=y=>{m(null),y().catch(S=>m(ze(S)))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"修改脚本文件"}),s.jsx("p",{className:"muted small",children:"默认禁止:agent 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),g===void 0?s.jsx("span",{className:"badge ok",children:"受保护"}):s.jsx("span",{className:"badge warn",children:"已允许"})]}),g===void 0?s.jsxs("div",{className:"key-actions",children:[s.jsxs("label",{className:"check-label",children:["允许 agent 修改",s.jsx(yn,{inline:!0,"aria-label":"允许多久",value:String(f),onChange:y=>d(Number(y)),options:[15,30,60,120].map(y=>({value:String(y),label:`${y} 分钟`}))})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>v(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:f})),children:"临时允许"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((g.expiresAt-r)/6e4))," 分钟"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>v(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]})]})}function aU({client:e,script:t}){const n=je(e.connection.status),r=Cn(6e4),i=gN(e,t.id),[o,c]=b.useState(void 0),[u,f]=b.useState(null),[d,p]=b.useState(0),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(null),[w,A]=b.useState(!1),[N,R]=b.useState(null),[D,P]=b.useState(null),[F,W]=b.useState(null),M=(i==null?void 0:i.items.find(L=>L.id===o))??(i==null?void 0:i.items.find(L=>L.id===i.current));b.useEffect(()=>{g(null),k(null)},[M==null?void 0:M.id]),b.useEffect(()=>e.connection.on("runs/state",L=>{L.scriptId!==t.id||L.endedAt===void 0||(p(B=>B+1),W(B=>B===null||B.runId!==L.id?B:(R(L.state==="succeeded"?`修改已同步到「${B.profile}」`:L.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${L.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const O=async L=>{if(F!==null){W({...F,finishing:L});try{L==="done"?await e.connection.call("configs/done",{runId:F.runId}):await e.connection.call("runs/stop",{runId:F.runId})}catch(B){P(ze(B)),W(null)}}};b.useEffect(()=>{if(n.state!=="open"||M===void 0)return;let L=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:M.id}).then(B=>{L&&(f(B),P(null))}).catch(B=>{L&&P(ze(B))}),()=>{L=!1}},[e,t.id,t.packId,n.state,d,M==null?void 0:M.id]);const T=async L=>{A(!0),P(null),R(null);try{const B=await L();typeof B=="string"&&R(B),p(H=>H+1)}catch(B){P(ze(B))}finally{A(!1)}},Z=((i==null?void 0:i.items.length)??0)>1,E=M!==void 0&&M.id===(i==null?void 0:i.current),C=(u==null?void 0:u.files.filter(L=>L.local))??[],$=u!==null&&u.profile.id===(M==null?void 0:M.id)?u:null;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"配置"}),s.jsx("p",{className:"muted small",children:"通过本应用运行时,用的是本地保存的配置;原项目里的配置不会被改动,你自己打开脚本时仍是它原来的设置。可以存几份(比如两个账号),运行和编排时选用哪一份。"})]}),s.jsxs("button",{className:"small-button",disabled:w||F!==null||n.state!=="open"||M===void 0,onClick:()=>void T(async()=>{const L=await e.connection.call("configs/open",{scriptId:t.id,profile:M.id});if(L.endedAt===void 0)W({runId:L.id,profile:M.name,finishing:null});else if(L.state!=="succeeded")throw new Error(L.outcome??"没能打开脚本的设置界面")}),children:[s.jsx(ee,{name:"settings"}),"打开脚本修改设置"]})]}),i!==null&&(Z||((u==null?void 0:u.files.length)??0)>0)&&s.jsxs("div",{className:"profile-bar",children:[s.jsxs("div",{className:"profile-chips",role:"tablist","aria-label":"配置",children:[i.items.map(L=>s.jsxs("button",{role:"tab","aria-selected":L.id===(M==null?void 0:M.id),className:`profile-chip ${L.id===(M==null?void 0:M.id)?"active":""}`,onClick:()=>c(L.id),children:[L.name,L.id===i.current&&Z&&s.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},L.id)),s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>y(L=>L===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),M!==void 0&&Z&&S===null&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:E?"运行时没有指定配置就用这一份":"在编排或运行时选它才会用到"}),s.jsx("span",{className:"spacer"}),!E&&s.jsx("button",{className:"small-button",disabled:w,onClick:()=>void T(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:M.id,current:!0}),`现在默认使用「${M.name}」`)),children:"设为当前使用"}),s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>k(M.name),children:"改名"}),M.id!=="default"&&(m==="remove"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"用了这份配置的编排步骤会运行失败"}),s.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),s.jsx("button",{className:"danger-outline small-button",disabled:w,onClick:()=>void T(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:M.id}),g(null),c(void 0),`已删除「${M.name}」`)),children:"确认删除"})]}):s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>g("remove"),children:"删除"}))]}),M!==void 0&&S!==null&&s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain","aria-label":"新名字",value:S,maxLength:30,autoFocus:!0,onChange:L=>k(L.target.value)}),s.jsx("button",{className:"small-button",onClick:()=>k(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w||S.trim()==="",onClick:()=>void T(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:M.id,name:S.trim()}),k(null)}),children:"保存"})]}),v!==null&&M!==void 0&&s.jsxs("div",{className:"profile-save",children:[s.jsx("label",{className:"field-label",htmlFor:"profile-name",children:"新配置的名字"}),s.jsx("input",{id:"profile-name",className:"text-input plain",placeholder:"例如:小号、只清体力",value:v.name,maxLength:30,autoFocus:!0,onChange:L=>y({...v,name:L.target.value})}),s.jsxs("fieldset",{className:"asset-list",disabled:w,children:[s.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${M.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(L=>L.file).join("、"))||"脚本包声明的配置文件"}`]].map(([L,B,H])=>s.jsxs("label",{className:`asset-option choice-option ${v.source===L?"active":""}`,children:[s.jsx("input",{type:"radio",name:"profile-source",value:L,checked:v.source===L,onChange:()=>y({...v,source:L})}),s.jsxs("span",{className:"choice-text",children:[s.jsx("span",{children:B}),s.jsx("span",{className:"muted small",children:H})]})]},L))]}),v.source==="folder"&&s.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:v.dir,onChange:L=>y({...v,dir:L.target.value})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w||v.name.trim()===""||v.source==="folder"&&v.dir.trim()==="",onClick:()=>void T(async()=>{const L=v.source==="copy"?{kind:"copy",profile:M.id}:v.source==="original"?{kind:"original"}:{kind:"folder",dir:v.dir.trim()},B=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:v.name.trim(),from:L});return y(null),c(B.profile.id),`已保存「${B.profile.name}」:${B.files.length>0?B.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),$!==null&&s.jsxs(s.Fragment,{children:[$.drift.length>0&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:["原项目的配置在导入后改过(",$.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",$.profile.name,"」运行;需要的话可以导入。"]})]}),s.jsx(Na,{id:`config.files.${t.id}`,title:"配置文件",count:$.files.length,children:s.jsxs("ul",{className:"version-list",children:[$.files.map(L=>s.jsx(oU,{client:e,scriptId:t.id,profile:$.profile.id,file:L},`${$.profile.id}:${L.file}`)),$.files.length===0&&s.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[$.importedAt===void 0?"还没有导入":`${Tt($.importedAt,r)}${Z?`存的「${$.profile.name}」`:"从原项目导入"}`,C.length>0&&" · ",C.length>0&&s.jsx("button",{className:"link-button",onClick:()=>{var L;return void((L=navigator.clipboard)==null?void 0:L.writeText($.dir))},children:"复制本地配置目录"})]}),s.jsx("span",{className:"spacer"}),m!=="import"?s.jsx("button",{className:"small-button",disabled:w,onClick:()=>g("import"),children:"导入原项目设置"}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",$.profile.name,"」"]}),s.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w,onClick:()=>void T(async()=>{const L=await e.connection.call("configs/import",{scriptId:t.id,profile:$.profile.id});return g(null),L.imported.length>0?`已导入到「${$.profile.name}」:${L.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),N!==null&&s.jsx("div",{className:"notice info left small",children:N}),F!==null&&s.jsx("div",{className:"dialog-backdrop",children:s.jsxs("div",{className:"dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"config-edit-title",children:[s.jsxs("h3",{id:"config-edit-title",children:[s.jsx(ee,{name:"settings"}),"正在用脚本自己的界面修改设置"]}),s.jsxs("p",{children:[t.name," 的设置窗口已经打开,用的是本地配置「",F.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",F.profile,"」,之后的运行和编排都用它。"]}),s.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),F.finishing!==null&&s.jsxs("p",{className:"dialog-progress",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),F.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:F.finishing!==null,onClick:()=>void O("discard"),children:"放弃修改"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:F.finishing!==null,onClick:()=>void O("done"),children:F.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),D!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:D})]})]})}function oU({client:e,scriptId:t,profile:n,file:r}){const[i,o]=b.useState(!1),[c,u]=b.useState(null),[f,d]=b.useState(null),p=()=>{o(m=>!m),!(c!==null||!r.local)&&e.connection.call("configs/read",{scriptId:t,file:r.file,profile:n}).then(u,m=>d(ze(m)))};return s.jsxs("li",{className:`config-file ${i?"open":""}`,children:[s.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":i,onClick:p,disabled:!r.local,title:r.local?"展开看本地配置的内容":"本地还没有这个文件",children:[s.jsx(ee,{name:"chevron",className:`fold-chevron ${i?"open":""}`}),s.jsx("span",{className:"version-name",children:r.file}),r.local?s.jsx("span",{className:"badge ok",children:"本地已保存"}):s.jsx("span",{className:"badge",children:"本地没有"}),r.changed&&s.jsx("span",{className:"badge warn",children:"原项目已改动"}),!r.original&&s.jsx("span",{className:"muted small",children:"原项目里没有"})]}),i&&(f!==null?s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f})]}):c===null?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsxs("pre",{className:"config-preview",children:[c.content,c.truncated?`
225
- …(太长,只显示前一部分)`:""]}))]})}function lU({client:e,scriptId:t,scriptName:n,openSession:r}){const i=je(e.connection.status),[o,c]=b.useState(null),[u,f]=b.useState(""),[d,p]=b.useState(""),[m,g]=b.useState(""),[v,y]=b.useState(!1),[S,k]=b.useState(null),[w,A]=b.useState(!1),[N,R]=b.useState(null),[D,P]=b.useState(!1);b.useEffect(()=>{if(i.state!=="open")return;let $=!0;return e.connection.call("configs/launch",{scriptId:t}).then(L=>{$&&(c(L),f(L.settings.pcExe??""),p(L.settings.pcProcess??""),g(L.settings.androidPackage??""))}).catch(L=>{$&&k(ze(L))}),()=>{$=!1}},[e,t,i.state]);const F=async $=>{y(!0),k(null),A(!1);try{c(await e.connection.call("configs/launch/set",{scriptId:t,...$})),A(!0)}catch(L){k(ze(L))}finally{y(!1)}},W=async $=>{f($),await F({pcExe:$})},M=async()=>{P(!0),k(null),A(!1),R(null);try{const $=await e.connection.call("configs/launch/locate",{scriptId:t});R($),$.candidates.length===1&&await W($.candidates[0].path)}catch($){k(ze($))}finally{P(!1)}},O=async()=>{k(null);try{const{sessionId:$}=await e.connection.call("sessions/create",{focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:$,requestId:`locate-${Date.now()}`,mode:"queue",text:`帮我找到「${n}」(脚本 id: ${t})要玩的 PC 游戏${(o==null?void 0:o.game.name)===void 0?"":`「${o.game.name}」`}装在哪里:先用 game_locate;没找到就在各个磁盘上搜索名为 ${(N==null?void 0:N.exe)??(o==null?void 0:o.game.pcProcess)??"游戏进程名"} 的程序(可以问我装在哪个盘)。找到后告诉我路径和你怎么确认的,再用 game_path_set 保存。`}),r($)}catch($){k(ze($))}},T=async()=>{const $=kr();if($===void 0)return;const L=await $.pickFile({title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});L!==null&&await W(L)};if(o===null)return S===null?null:s.jsx("section",{className:"card",children:s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]})});const{settings:Z,game:E,uses:C}=o;return!C.adb&&!C.desktop?null:s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:["启动游戏",E.name===void 0?"":`:${E.name}`]}),s.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",E.selfLaunch,"。"]})]})}),s.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),s.jsx(yn,{id:`launch-mode-${t}`,value:Z.mode,disabled:v,onChange:$=>void F({mode:$}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),Z.mode!=="off"&&C.adb&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-pkg-${t}`,children:"模拟器里的游戏包名(模拟器任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-pkg-${t}`,className:"text-input plain",value:m,onChange:$=>g($.target.value),placeholder:E.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:v,onClick:()=>void F({androidPackage:m.trim()===""?null:m.trim()}),children:"保存"})]}),E.androidPackage!==void 0&&s.jsxs("p",{className:"muted small",children:["默认 ",E.androidPackage,";B 服、国际服等版本的包名不同时在这里改。"]})]}),Z.mode!=="off"&&C.desktop&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-exe-${t}`,children:"PC 游戏程序位置(占用鼠标键盘的任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-exe-${t}`,className:"text-input",value:u,onChange:$=>f($.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:v,onClick:()=>void F({pcExe:u.trim()===""?null:u.trim().replace(/^"|"$/g,"")}),children:"保存"})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{className:"small-button",disabled:v||D,onClick:()=>void M(),children:D?"正在查找…":"自动查找"}),kr()!==void 0&&s.jsx("button",{className:"small-button",disabled:v||D,onClick:()=>void T(),children:"选择文件…"}),s.jsx("button",{className:"link-button small",disabled:D,onClick:()=>void O(),children:"让 agent 找"})]}),N!==null&&N.exe===void 0&&s.jsx("p",{className:"muted small",children:"脚本包没有写游戏的进程名:先在下面填进程名,或用「选择文件…」/ 让 agent 找。"}),N!==null&&N.exe!==void 0&&N.candidates.length===0&&s.jsxs("p",{className:"muted small",children:["没找到 ",N.exe,"(查了正在运行的程序、已安装程序、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 agent 找」在整个磁盘上搜。"]}),N!==null&&N.candidates.length===1&&s.jsxs("p",{className:"muted small",children:["找到并保存了:",N.candidates[0].path,"(",N.candidates[0].source,")"]}),N!==null&&N.candidates.length>1&&s.jsxs("div",{className:"candidate-list",children:[s.jsxs("span",{className:"muted small",children:["找到 ",N.candidates.length," 个,选一个:"]}),N.candidates.map($=>s.jsxs("button",{className:`candidate ${Z.pcExe===$.path?"chosen":""}`,disabled:v,onClick:()=>void W($.path),children:[s.jsx("span",{className:"mono",children:$.path}),s.jsx("span",{className:"muted small",children:$.source})]},$.path))]}),s.jsx("label",{className:"field-label",htmlFor:`launch-proc-${t}`,children:"游戏进程名(判断游戏是否已经开着)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-proc-${t}`,className:"text-input",value:d,onChange:$=>p($.target.value),placeholder:E.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:v,onClick:()=>void F({pcProcess:d.trim()===""?null:d.trim()}),children:"保存"})]}),s.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),w&&s.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),S!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:S})]})]})}const cU=15*6e4;function uU({client:e,script:t,openSession:n}){const r=Cn(3e4),[i,o]=b.useState(!1),[c,u]=b.useState(null),f=t.summary,d=(f==null?void 0:f.state)==="running"&&r-f.at<cU,p=(f==null?void 0:f.state)==="failed"||f==null?void 0:f.text,m=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(g){u(ze(g))}finally{o(!1)}};return s.jsxs("section",{className:"card script-summary",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"简介"}),s.jsx("p",{className:"muted small",children:d?"agent 正在看它的说明和文件…":f===void 0?"让 AI 看看它的说明(README)、文件和脚本包,用几句话说清楚它是什么、能做什么。":f.state==="failed"||f.state==="running"?"上次总结没有完成":`AI 总结 · ${Tt(f.at,r)}`})]}),s.jsxs("div",{className:"key-actions",children:[(f==null?void 0:f.sessionId)!==void 0&&s.jsx("button",{className:"ghost small-button",onClick:()=>n(f.sessionId),children:d?"看看进度":"查看对话"}),s.jsxs("button",{className:`${f===void 0?"primary ":""}small-button`,disabled:i||d,onClick:()=>void m(),children:[s.jsx(ee,{name:"sparkles"}),d?"总结中…":f===void 0?"让 AI 总结":"重新总结"]})]})]}),p!==void 0&&s.jsx("p",{className:`summary-text ${d?"muted":""}`,children:p}),(f==null?void 0:f.state)==="failed"&&f.text!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:f.text})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:c})]})]})}const dU={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function bS({client:e,setup:t,openSession:n,onImported:r}){const[i,o]=b.useState(t.dir),[c,u]=b.useState(!1),[f,d]=b.useState(null),[p,m]=b.useState(null),[g,v]=b.useState(!1),y=t.agent,S=async(k,w)=>{d(k),m(null);try{await w()}catch(A){m(ze(A))}finally{d(null)}};return s.jsxs("section",{className:"card setup-card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:[t.update?"更新":"安装"," ",t.name," ",t.version]}),s.jsxs("p",{className:"muted small",children:["下载到的是 ",dU[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(y==null?void 0:y.state)==="running"&&s.jsxs("div",{className:"notice left",children:[s.jsx(ee,{name:"info"}),s.jsx("span",{children:"agent 正在安装。也可以不等它,按下面的步骤自己装。"}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),(y==null?void 0:y.state)==="failed"&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["agent 没能装好:",y.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),s.jsxs("ol",{className:"setup-steps",children:[s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsx("span",{children:"打开安装程序,按它的提示装完。安装位置已经填好,保持不变;最后不用勾选「立即运行」。"}),s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void S("open",async()=>{await e.connection.call("scripts/setup/open",{id:t.scriptId}),u(!0)}),children:f==="open"?"正在打开…":c?"再打开一次":"打开安装程序"})]})}),s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsxs("span",{children:["装好后导入装好的文件夹。",t.update?"":"改了安装位置的话,填你选的文件夹。"]}),s.jsxs("form",{className:"setup-import",onSubmit:k=>{k.preventDefault(),S("import",async()=>{const w=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),id:t.scriptId});r(w.id)})},children:[s.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:i,onChange:k=>o(k.target.value),spellCheck:!1,disabled:f!==null}),s.jsx("button",{className:"primary small-button",type:"submit",disabled:f!==null||i.trim()==="",children:f==="import"?"导入中…":"装好了,导入"})]})]})})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]}),s.jsx("div",{className:"key-actions",children:g?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>v(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:f!==null,onClick:()=>void S("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):s.jsxs(s.Fragment,{children:[(y==null?void 0:y.state)!=="running"&&s.jsx("button",{className:"small-button",disabled:f!==null,onClick:()=>void S("agent",async()=>{const{sessionId:k}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});n(k)}),children:f==="agent"?"正在交给 agent…":"让 agent 安装"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:f!==null,onClick:()=>v(!0),children:"不装了"})]})})]})}const fU={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function hU({client:e,script:t,job:n,setup:r,onRemoved:i,openSession:o}){var P;const c=Cn(6e4),[u,f]=b.useState(null),[d,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(!1),[S,k]=b.useState(!1),w=n!==void 0&&(n.endedAt===void 0||n.startedAt>=t.addedAt-1e3)?n:void 0,A=co(w),N=je(e.capabilities),R=t.source.kind!=="local",D=async(F,W)=>{f(F),p(null),g(null);try{const M=await W();typeof M=="string"&&g(M)}catch(M){p(ze(M))}finally{f(null)}};return s.jsxs("div",{className:"script-detail",children:[s.jsx("header",{className:"script-detail-head",children:s.jsxs("div",{children:[s.jsx("h2",{children:t.name}),s.jsxs("div",{className:"script-meta",children:[s.jsx("span",{className:"chip",children:t.id}),t.family!==void 0&&s.jsx("span",{className:"badge",children:gw[t.family]??t.family}),t.packId!==void 0?s.jsxs("span",{className:"badge ok",children:["脚本包 ",t.packId]}):s.jsx("span",{className:"badge warn",children:"无脚本包"}),t.channels.mirrorchyan!==void 0&&s.jsxs("span",{className:"badge",title:"填了 Mirror酱 CDK 后从 Mirror酱 更新(增量)",children:["Mirror酱 ",t.channels.mirrorchyan.rid]}),s.jsx("span",{className:"muted small",children:t.source.kind==="github"?`GitHub · ${t.source.repo}`:t.source.kind==="mirrorchyan"?`Mirror酱 · ${t.source.rid}`:"本地导入"})]})]})}),w!==void 0&&s.jsx(pm,{client:e,job:w}),r!==void 0&&s.jsx(bS,{client:e,setup:r,openSession:o,onImported:()=>{}}),t.dir!==void 0&&s.jsx(uU,{client:e,script:t,openSession:o}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"位置与版本"}),s.jsx("p",{className:"muted small",children:t.dir??"(无)"})]}),t.dir!==void 0&&s.jsxs("button",{className:"ghost small-button",onClick:()=>{var F;return void((F=navigator.clipboard)==null?void 0:F.writeText(t.dir))},children:[s.jsx(ee,{name:"copy"}),"复制路径"]})]}),R?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"version-list",children:t.versions.map(F=>{var W;return s.jsxs("li",{className:F.current?"current":"",children:[s.jsx("span",{className:"version-name",children:F.version}),F.current&&s.jsx("span",{className:"badge ok",children:"当前"}),s.jsxs("span",{className:"muted small",children:[((W=F.asset)==null?void 0:W.name)??""," · ",Tt(F.installedAt,c)]}),s.jsx("span",{className:"spacer"}),!F.current&&s.jsx("button",{className:"small-button",disabled:A||u!==null,onClick:()=>void D("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:F.version}),`已切换到 ${F.version}`)),children:"切换到此版本"})]},F.version)})}),s.jsx("dl",{className:"local-facts channel-facts",children:s.jsx(yS,{client:e,script:t,disabled:A||u!==null,act:D})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[t.update===void 0?"还没有检查过更新":t.update.available?`有新版本 ${t.update.latest}`:`已是最新(${t.update.latest})`,t.update!==void 0&&` · ${Tt(t.update.checkedAt,c)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:A||u!==null,onClick:()=>void D("check",async()=>{const F=await e.connection.call("scripts/checkUpdate",{id:t.id});return F.available?`发现新版本 ${F.latest}`:"已是最新版本"}),children:u==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:A||u!==null||((P=t.update)==null?void 0:P.available)!==!0,onClick:()=>void D("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):s.jsx(sU,{client:e,script:t,disabled:A||u!==null,busy:u,now:c,act:D})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行环境"}),s.jsx("p",{className:"muted small",children:t.env===void 0?t.packId===void 0?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${Tt(t.env.checkedAt,c)}检查`})]}),s.jsx("button",{className:"small-button",disabled:A||u!==null,onClick:()=>void D("env",async()=>(await e.connection.call("scripts/envCheck",{id:t.id})).ok?"运行环境满足":"有依赖需要处理"),children:u==="env"?"检查中…":"重新检查"})]}),t.env!==void 0&&t.env.items.length===0&&s.jsx("div",{className:"muted small",children:"脚本包没有声明额外依赖。"}),t.env!==void 0&&t.env.items.length>0&&s.jsx("ul",{className:"env-list",children:t.env.items.map(F=>{const[W,M]=fU[F.status];return s.jsxs("li",{children:[s.jsxs("div",{className:"env-main",children:[s.jsx("span",{className:"env-label",children:F.label}),s.jsx("span",{className:`badge ${W}`,children:M}),F.found!==void 0&&s.jsx("span",{className:"muted small",children:F.found})]}),F.detail!==void 0&&s.jsx("div",{className:"muted small",children:F.detail}),F.fix!==void 0&&s.jsxs("div",{className:"env-fix",children:[s.jsx("span",{className:"muted small",children:F.fix.description}),F.fix.kind!=="manual"&&s.jsx("button",{className:"small-button",disabled:A||u!==null,onClick:()=>void D(`fix-${F.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:F.kind})}),children:F.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},F.kind)})})]}),N.has("runs")&&t.dir!==void 0&&s.jsx(jz,{client:e,scriptId:t.id,packId:t.packId}),N.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(aU,{client:e,script:t}),N.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(lU,{client:e,scriptId:t.id,scriptName:t.name,openSession:o},t.id),N.has("packs")&&s.jsx(rU,{client:e,script:t,openSession:o}),t.probe!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"目录概况"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"只是快速看一眼;启动方式、任务和配置的完整分析请用上面的「让 agent 分析」。":"导入时快速看到的文件;脚本怎么运行以脚本包为准。"})]})}),s.jsxs("div",{className:"probe-grid",children:[s.jsx("span",{className:"field-label",children:"可执行文件"}),s.jsx("div",{className:"chip-row",children:t.probe.executables.length===0?s.jsx("span",{className:"muted small",children:"未发现"}):t.probe.executables.map(F=>s.jsx("span",{className:"chip",children:F},F))}),s.jsx("span",{className:"field-label",children:"标志文件"}),s.jsx("div",{className:"chip-row",children:t.probe.markers.length===0?s.jsx("span",{className:"muted small",children:"未发现"}):t.probe.markers.map(F=>s.jsx("span",{className:"chip",children:F},F))})]})]}),N.has("guard")&&s.jsx(iU,{client:e,script:t}),s.jsx("section",{className:"card danger-zone",children:v?s.jsxs("div",{className:"key-actions",children:[R&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:F=>k(F.target.checked)}),"同时删除所有已安装版本"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:u!==null,onClick:()=>void D("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:R&&S}),i()}),children:"确认移除"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:R?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:A,onClick:()=>y(!0),children:"移除"})]})}),m!==null&&s.jsx("div",{className:"notice info",children:m}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:d})]})]})}function pU({client:e,openSession:t,arg:n}){const{data:r,error:i}=Am(e),o=aR(e),[c,u]=b.useState(null),[f,d]=b.useState(null);b.useEffect(()=>{(n==null?void 0:n.startsWith("mirror:"))===!0&&d({kind:"mirror",rid:n.slice(7)})},[n]);const p=(r==null?void 0:r.scripts)??[],m=((r==null?void 0:r.packs)??[]).filter(N=>!N.installed&&N.repo!==void 0&&N.error===void 0),g=((r==null?void 0:r.packs)??[]).filter(N=>N.error!==void 0),v=((r==null?void 0:r.known)??[]).filter(N=>!N.installed),y=(r==null?void 0:r.setups)??[],S=y.filter(N=>!p.some(R=>R.id===N.scriptId)),k=f===null?S.find(N=>N.scriptId===c):void 0,w=c===null||p.some(N=>N.id===c)||k!==void 0?void 0:o.get(c),A=p.find(N=>N.id===c)??(f===null&&w===void 0&&k===void 0?p[0]:void 0);return s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"脚本"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"脚本库"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>d({kind:"import"}),children:[s.jsx(ee,{name:"paperclip"}),"导入本地项目"]}),s.jsxs("button",{className:"small-button",onClick:()=>d({kind:"mirror"}),children:[s.jsx(ee,{name:"plus"}),"从 Mirror酱 安装"]}),s.jsxs("button",{className:"primary small-button",onClick:()=>d({kind:"install"}),children:[s.jsx(ee,{name:"plus"}),"从 GitHub 安装"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"脚本列表",children:[i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]}),r===null&&i===null&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),r!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sidebar-label",children:["我的脚本(",p.length,")"]}),p.length===0&&![...o.values()].some(co)&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(ee,{name:"package"}),s.jsx("span",{children:"还没有脚本"}),s.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),p.map(N=>{var P,F;const R=o.get(N.id),D=((P=N.env)==null?void 0:P.items.filter(W=>W.status!=="ok"&&W.status!=="unsupported").length)??0;return s.jsxs("button",{className:`script-row ${N.id===(A==null?void 0:A.id)&&f===null?"active":""}`,onClick:()=>{u(N.id),d(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsxs("span",{className:"muted small",children:[N.source.kind==="local"?"本地":N.current??"未安装",N.family===void 0?"":` · ${gw[N.family]??N.family}`]})]}),co(R)?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):y.some(W=>W.scriptId===N.id)?s.jsx("span",{className:"badge warn",children:"待安装"}):((F=N.update)==null?void 0:F.available)===!0?s.jsx("span",{className:"badge ok",children:"可更新"}):D>0?s.jsxs("span",{className:"badge warn",children:["环境 ",D]}):null]},N.id)}),S.length>0&&s.jsxs("div",{className:"sidebar-label",children:["等待安装(",S.length,")"]}),S.map(N=>{var R,D,P;return s.jsxs("button",{className:`script-row ${N===k?"active":""}`,onClick:()=>{u(N.scriptId),d(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsxs("span",{className:"muted small",children:[N.version," · ",((R=N.agent)==null?void 0:R.state)==="running"?"agent 正在安装":((D=N.agent)==null?void 0:D.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((P=N.agent)==null?void 0:P.state)==="running"?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):s.jsx("span",{className:"badge warn",children:"待安装"})]},N.scriptId)}),[...o.values()].filter(N=>co(N)&&!p.some(R=>R.id===N.scriptId)).map(N=>s.jsxs("button",{className:`script-row ${c===N.scriptId&&f===null?"active":""}`,onClick:()=>{u(N.scriptId),d(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.scriptId}),s.jsxs("span",{className:"muted small",children:["正在安装 · ",qu[N.phase],N.total!==void 0&&N.received!==void 0&&N.total>0?` ${Math.floor(N.received/N.total*100)}%`:""]})]}),s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},N.id)),(m.length>0||v.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),m.map(N=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsx("span",{className:"muted small",children:N.description??N.repo})]}),s.jsx("button",{className:"small-button",onClick:()=>d({kind:"install",repo:N.repo}),children:"安装"})]},N.id)),v.map(N=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:N.name}),s.jsx("span",{className:"muted small",children:[N.mirrorchyan===void 0?void 0:`Mirror酱 ${N.mirrorchyan}`,N.repo].filter(Boolean).join(" · ")})]}),s.jsx("button",{className:"small-button",onClick:()=>d(N.mirrorchyan!==void 0?{kind:"mirror",rid:N.mirrorchyan}:{kind:"install",repo:N.repo}),children:"安装"})]},N.id))]}),g.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:[g.length," 个脚本包无法读取:",g.map(N=>N.id).join("、")]})]})]})]}),s.jsxs("div",{className:"scripts-detail",children:[(f==null?void 0:f.kind)==="install"&&s.jsx(KB,{client:e,jobs:o,...f.repo===void 0?{}:{initialRepo:f.repo},onClose:()=>d(null),onDone:N=>{u(N),d(null)},openSession:t},f.repo??"blank"),(f==null?void 0:f.kind)==="mirror"&&s.jsx(YB,{client:e,jobs:o,...f.rid===void 0?{}:{initialRid:f.rid},onClose:()=>d(null),onDone:N=>{u(N),d(null)},openSession:t,onGitHub:N=>d({kind:"install",repo:N})},f.rid??"blank"),(f==null?void 0:f.kind)==="import"&&s.jsx(tU,{client:e,onClose:()=>d(null),onImported:N=>{u(N),d(null)}}),f===null&&A!==void 0&&s.jsx(hU,{client:e,script:A,job:o.get(A.id),setup:y.find(N=>N.scriptId===A.id),onRemoved:()=>u(null),openSession:t},A.id),k!==void 0&&s.jsx(bS,{client:e,setup:k,openSession:t,onImported:N=>u(N)},k.scriptId),f===null&&A===void 0&&w!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:w.scriptId}),s.jsx("p",{className:"muted small",children:co(w)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),s.jsx(pm,{client:e,job:w})]}),f===null&&A===void 0&&w===void 0&&k===void 0&&r!==null&&s.jsxs("div",{className:"empty",children:[[...o.values()].filter(N=>co(N)&&!p.some(R=>R.id===N.scriptId)).map(N=>s.jsxs("div",{className:"pending-install",children:[s.jsx("strong",{children:N.scriptId}),s.jsx(pm,{client:e,job:N})]},N.id)),s.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),r!==null&&s.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",r.toolsDir]})]})]})]})}const mU={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:pU}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:GB}]},gU={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:qB}]},dp="https://github.com/haaahhhis/MultiGameAssistant";function xU(){const[e,t]=b.useState(void 0);b.useEffect(()=>{var o;const r=(o=kr())==null?void 0:o.appInfo;if(r===void 0){t(null);return}let i=!0;return r().then(c=>{i&&t(c)},()=>{i&&t(null)}),()=>{i=!1}},[]);const n=e===void 0?"…":e===null?"在浏览器里打开(版本见桌面版)":e.fromSource?`从源码运行(${e.arch})`:`${e.version??"未知版本"}(${e.arch}${e.commit===void 0?"":` · ${e.commit}`})`;return s.jsxs("div",{className:"settings-page about-page",children:[s.jsx("h2",{children:"关于"}),s.jsx("p",{children:"MultiGameAssistant(多游戏助手):让 agent 替你管好各个游戏的日常脚本。"}),s.jsx("section",{className:"card about-card",children:s.jsxs("dl",{className:"about-facts",children:[s.jsx("dt",{children:"版本"}),s.jsx("dd",{children:n}),s.jsx("dt",{children:"源代码"}),s.jsx("dd",{children:s.jsx("a",{href:dp,target:"_blank",rel:"noreferrer",children:dp.replace("https://","")})}),s.jsx("dt",{children:"许可证"}),s.jsx("dd",{children:s.jsx("a",{href:`${dp}/blob/main/LICENSE`,target:"_blank",rel:"noreferrer",children:"GNU AGPL-3.0-only"})})]})}),(e==null?void 0:e.fromSource)===!0?s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"更新"}),s.jsx("p",{className:"muted",children:"从源码运行:在项目目录 git pull 后重新构建(pnpm install、pnpm build)。"})]}):e!=null&&s.jsx(vU,{}),s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"许可证"}),s.jsx("p",{children:"Copyright (C) 2026 MultiGameAssistant contributors"}),s.jsx("p",{children:"本程序是自由软件:你可以按自由软件基金会发布的 GNU Affero 通用公共许可证第 3 版(AGPL-3.0-only)再分发和修改它。分发修改后的版本,或让别人通过网络使用修改后的版本时,要以同样的许可证提供它的完整源代码。"}),s.jsx("p",{children:"发布本程序是希望它有用,但不提供任何担保,也没有适销性或特定用途适用性的默示担保。详见许可证全文。"}),s.jsx("p",{className:"muted small",children:"附带的第三方组件(Electron、DeepSeek Harness 等)遵循各自的许可证,许可证文件在程序的安装目录里。本程序安装和调度的游戏脚本是各自独立的项目,不属于本程序。"})]})]})}function vU(){const{bridge:e,state:t}=tw();if(e===void 0||t===null)return null;const n=t==null?void 0:t.latest,r=t===void 0?"…":t.checking?"正在检查…":t.error!==void 0?t.error:n!==void 0?`有新版本 ${n.version}${n.prerelease?"(预发布版)":""}${n.version===t.skipped?",已跳过":""}`:t.checkedAt!==void 0?`已经是最新版本(${new Date(t.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return s.jsxs("section",{className:"card about-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"更新"}),s.jsxs("p",{className:(t==null?void 0:t.error)!==void 0&&!t.checking?"error small":"muted small",children:[r,n!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:n.notesUrl,target:"_blank",rel:"noreferrer",children:"查看更新内容"})]})]})]}),s.jsxs("button",{className:"small-button",disabled:t===void 0||t.checking,onClick:()=>void e.check(),children:[s.jsx(ee,{name:"refresh"}),"检查更新"]})]}),t!==void 0&&s.jsx(nw,{bridge:e,state:t}),t!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.auto,onChange:i=>void e.setAuto(i.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}const Ml=e=>e.replace(/\/+$/,""),zb=e=>{const t=Ml(e);return t.endsWith("/v1")?t.slice(0,-3):t},kS=[{id:"openai-completions",title:"OpenAI 兼容",subtitle:"Chat Completions",hint:"绝大多数第三方网关和本地服务都用这种:OneAPI / NewAPI、OpenRouter、硅基流动、vLLM、Ollama、LM Studio 等。",placeholder:"https://api.example.com/v1",requestPath:e=>`${Ml(e)}/chat/completions`,listPath:e=>`${Ml(e)}/models`},{id:"openai-responses",title:"OpenAI Responses",subtitle:"Responses API",hint:"OpenAI 的新一代接口,支持推理摘要等能力;仅在服务方明确支持 /responses 时使用。",placeholder:"https://api.openai.com/v1",requestPath:e=>`${Ml(e)}/responses`,listPath:e=>`${Ml(e)}/models`},{id:"anthropic-messages",title:"Anthropic 兼容",subtitle:"Messages API",hint:"Claude 官方接口以及兼容 Anthropic 格式的网关。地址写到域名即可,末尾的 /v1 可有可无。",placeholder:"https://api.anthropic.com",requestPath:e=>`${zb(e)}/v1/messages`,listPath:e=>`${zb(e)}/v1/models`}];function mm(e){return kS.find(t=>t.id===e)}function yU(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function bU(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const kU=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function wU(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function go(e){return e===void 0?null:e%1048576===0?`${e/1048576}M`:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e%1024===0?`${e/1024}K`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function NU({client:e,profile:t,preset:n,taken:r,revision:i,readOnly:o,onDone:c}){var xe;const u=t===void 0,f=n===void 0||n.id===""?"":r.includes(n.id)?`${n.id}-2`:n.id,[d,p]=b.useState(()=>{var ge;return((ge=mm((t==null?void 0:t.api)??(n==null?void 0:n.api)))==null?void 0:ge.id)??"openai-completions"}),[m,g]=b.useState((t==null?void 0:t.displayName)??((n==null?void 0:n.baseURL)===""?"":(n==null?void 0:n.name)??"")),[v,y]=b.useState((t==null?void 0:t.id)??f),[S,k]=b.useState(!u||f!==""),[w,A]=b.useState((t==null?void 0:t.baseURL)??(n==null?void 0:n.baseURL)??""),[N,R]=b.useState(""),[D,P]=b.useState((t==null?void 0:t.models)??[]),[F,W]=b.useState(!1),[M,O]=b.useState(null),T=mm(d),Z=w.trim(),E=Z!==""&&!wU(Z),C=v!==""&&!kU.test(v),$=u&&r.includes(v),L=NS(N),B=(t==null?void 0:t.apiKeyRef)??(v===""?null:bU(v)),H=((xe=t==null?void 0:t.credential)==null?void 0:xe.configured)===!0,G=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,K=v===""?"请填写标识":C?"标识格式不正确":$?"这个标识已被占用":Z===""?"请填写 Base URL":E?"Base URL 需要以 http:// 或 https:// 开头":L!==null?L:D.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,V=ge=>{g(ge),S||y(yU(ge))},Y=async()=>{if(K===null){W(!0),O(null);try{await e.saveProvider({id:v,create:u,...m.trim()===""?{}:{displayName:m.trim()},api:d,baseURL:Z,models:[...D],...N.trim()===""?{}:{apiKey:N.trim()},expectedRevision:i}),c()}catch(ge){const ie=ge instanceof Error?ge.message:String(ge);O(/SETTINGS_CONFLICT|conflict/i.test(ie)?"配置在别处被修改过了,请返回列表后重试。":ie)}finally{W(!1)}}},fe=F||o;return s.jsxs("form",{className:"provider-editor",onSubmit:ge=>{ge.preventDefault(),Y()},children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:u?n!==void 0&&n.baseURL!==""?`添加 ${n.name}`:"添加模型服务":`编辑「${t.displayName}」`}),s.jsx("button",{type:"button",className:"ghost",onClick:c,disabled:F,children:"返回"})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{className:"field-title",children:"接口模式"}),s.jsx("div",{className:"mode-grid",role:"radiogroup","aria-label":"接口模式",children:kS.map(ge=>s.jsxs("button",{type:"button",role:"radio","aria-checked":d===ge.id,"aria-label":`${ge.title}(${ge.subtitle})`,className:`mode-option${d===ge.id?" selected":""}`,onClick:()=>p(ge.id),disabled:fe,children:[s.jsx("span",{className:"mode-title",children:ge.title}),s.jsx("span",{className:"mode-subtitle",children:ge.subtitle})]},ge.id))}),s.jsx("div",{className:"muted small",children:T.hint})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"名称"}),s.jsx("input",{className:"text-input plain",value:m,onChange:ge=>V(ge.target.value),placeholder:"例如:我的中转站",disabled:fe})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"标识"}),s.jsx("input",{className:"text-input",value:v,onChange:ge=>{y(ge.target.value.trim()),k(!0)},placeholder:"my-gateway",disabled:fe||!u,spellCheck:!1})]})]}),s.jsx("div",{className:C||$?"error small":"muted small",children:C?"标识只能用小写字母、数字和单个连字符,并以字母开头。":$?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"Base URL"}),s.jsx("input",{className:"text-input",value:w,onChange:ge=>A(ge.target.value),placeholder:T.placeholder,disabled:fe,spellCheck:!1})]}),E?s.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):Z!==""&&s.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",s.jsxs("code",{children:["POST ",T.requestPath(Z)]}),s.jsx("br",{}),"模型列表 ",s.jsxs("code",{children:["GET ",T.listPath(Z)]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"API Key"}),s.jsx("input",{className:"text-input",type:"password",value:N,onChange:ge=>R(ge.target.value),placeholder:G?"由启动环境变量提供,无法在此修改":H?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:fe||G,spellCheck:!1})]}),L!==null?s.jsx("div",{className:"error small",children:L}):B!==null&&s.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",s.jsx("code",{children:B})," 中,界面不会再显示 Key 的内容。",(n==null?void 0:n.keyUrl)!==void 0&&s.jsxs(s.Fragment,{children:[" ",s.jsx("a",{href:n.keyUrl,target:"_blank",rel:"noopener noreferrer",children:"获取 Key ↗"})]})]}),(n==null?void 0:n.vision)!==void 0&&s.jsxs("div",{className:"muted small",children:["截图诊断、读游戏信息需要能看图的模型:",n.vision,"。"]})]}),s.jsx(jU,{client:e,models:D,onChange:P,probe:{...t===void 0?{}:{provider:t.id},api:d,baseURL:Z,apiKey:N.trim()},probeBlocked:Z===""?"先填写 Base URL":E?"Base URL 无效":L,disabled:fe}),M!==null&&s.jsx("div",{className:"banner error",children:M}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:K}),s.jsx("span",{className:"spacer"}),s.jsx("button",{type:"button",onClick:c,disabled:F,children:"取消"}),s.jsx("button",{type:"submit",className:"primary",disabled:fe||K!==null,children:F?"保存中…":u?"创建":"保存"})]})]})}function jU({client:e,models:t,onChange:n,probe:r,probeBlocked:i,disabled:o}){const[c,u]=b.useState(null),[f,d]=b.useState(""),[p,m]=b.useState(""),[g,v]=b.useState(!1),[y,S]=b.useState(null),k=b.useRef(null),w=b.useMemo(()=>new Set(t.map(M=>M.id)),[t]),A=async()=>{var O;(O=k.current)==null||O.abort();const M=new AbortController;k.current=M,v(!0),S(null);try{const T=await e.discoverModels({...r.provider===void 0?{}:{provider:r.provider},api:r.api,baseURL:r.baseURL,...r.apiKey===""?{}:{apiKey:r.apiKey}},M.signal);if(M.signal.aborted)return;u([...T].sort((Z,E)=>Z.id.localeCompare(E.id))),T.length===0&&S("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(T){M.signal.aborted||S(T instanceof Error?T.message:String(T))}finally{k.current===M&&(k.current=null,v(!1))}},N=M=>{n(w.has(M.id)?t.filter(O=>O.id!==M.id):[...t,M])},R=M=>{n(t.map(O=>{if(O.id!==M)return O;if(O.efforts!==void 0&&O.efforts.length>0){const{efforts:T,...Z}=O;return Z}return{...O,efforts:["off","low","medium","high"]}}))},D=M=>{n(t.map(O=>{var T;return O.id!==M?O:{...O,input:((T=O.input)==null?void 0:T.includes("image"))===!0?["text"]:["text","image"]}}))},P=b.useMemo(()=>{const M=f.trim().toLowerCase();return(c??[]).filter(O=>M===""||O.id.toLowerCase().includes(M)||(O.name??"").toLowerCase().includes(M))},[c,f]),F=M=>{if(M){const O=P.filter(T=>!w.has(T.id));n([...t,...O])}else{const O=new Set(P.map(T=>T.id));n(t.filter(T=>!O.has(T.id)))}},W=()=>{const M=p.split(/[\s,,]+/).map(O=>O.trim()).filter(O=>O!==""&&!w.has(O));M.length!==0&&(n([...t,...M.map(O=>(c==null?void 0:c.find(T=>T.id===O))??{id:O})]),m(""))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"模型"}),s.jsxs("div",{className:"muted small",children:["已选 ",t.length," 个。只有选中的模型会出现在模型选择器里。能看图的模型点亮「图片」,否则 dsh 会拒绝发送图片;支持调思考强度的模型(如 GPT-5、o 系列、Claude、DeepSeek R 系列)点亮「思考」,对话里就能选强度。"]})]}),s.jsx("button",{type:"button",onClick:()=>void A(),disabled:o||g||i!==null,title:i??void 0,children:g?"拉取中…":c===null?"拉取模型列表":"重新拉取"})]}),y!==null&&s.jsx("div",{className:"error small",children:y}),t.length>0&&s.jsx("div",{className:"model-chips",children:t.map(M=>{var O,T,Z,E,C,$;return s.jsxs("span",{className:"chip removable",children:[M.id,go(M.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",go(M.contextWindow)]}),s.jsx("button",{type:"button",className:`chip-flag${((O=M.input)==null?void 0:O.includes("image"))===!0?" on":""}`,onClick:()=>D(M.id),disabled:o,"aria-pressed":((T=M.input)==null?void 0:T.includes("image"))===!0,title:((Z=M.input)==null?void 0:Z.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),s.jsx("button",{type:"button",className:`chip-flag${(((E=M.efforts)==null?void 0:E.length)??0)>0?" on":""}`,onClick:()=>R(M.id),disabled:o,"aria-pressed":(((C=M.efforts)==null?void 0:C.length)??0)>0,title:((($=M.efforts)==null?void 0:$.length)??0)>0?`可选思考强度:${M.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),s.jsx("button",{type:"button",className:"chip-x",onClick:()=>n(t.filter(L=>L.id!==M.id)),disabled:o,"aria-label":`移除 ${M.id}`,children:"×"})]},M.id)})}),c!==null&&c.length>0&&s.jsxs("div",{className:"candidates",children:[s.jsxs("div",{className:"candidates-bar",children:[s.jsx("input",{className:"text-input plain",value:f,onChange:M=>d(M.target.value),placeholder:`搜索 ${c.length} 个模型`}),s.jsxs("button",{type:"button",className:"small-button",onClick:()=>F(!0),disabled:o,children:["全选",f!==""?"筛选结果":""]}),s.jsx("button",{type:"button",className:"small-button",onClick:()=>F(!1),disabled:o,children:"全不选"})]}),s.jsxs("ul",{className:"candidate-list",children:[P.map(M=>{var O;return s.jsx("li",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:w.has(M.id),onChange:()=>N(M),disabled:o}),s.jsx("span",{className:"mono",children:M.id}),M.name!==void 0&&s.jsxs("span",{className:"muted",children:[" ",M.name]}),s.jsx("span",{className:"spacer"}),((O=M.input)==null?void 0:O.includes("image"))===!0&&s.jsx("span",{className:"badge",children:"图像"}),go(M.contextWindow)!==null&&s.jsxs("span",{className:"muted small",children:[go(M.contextWindow)," 上下文"]})]})},M.id)}),P.length===0&&s.jsx("li",{className:"muted small",children:"没有匹配的模型。"})]})]}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain-mono",value:p,onChange:M=>m(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),W())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),s.jsx("button",{type:"button",onClick:W,disabled:o||p.trim()==="",children:"添加"})]})]})}const SU=[{key:"anthropic",name:"Claude(Anthropic)",note:"看图和工具调用都很强",api:"anthropic-messages",baseURL:"https://api.anthropic.com",id:"claude",keyUrl:"https://console.anthropic.com/settings/keys",vision:"所有 Claude 模型都能看图"},{key:"openai",name:"ChatGPT(OpenAI)",note:"GPT 系列",api:"openai-completions",baseURL:"https://api.openai.com/v1",id:"chatgpt",keyUrl:"https://platform.openai.com/api-keys",vision:"gpt-4o、gpt-4.1 等能看图"},{key:"gemini",name:"Gemini(Google)",note:"OpenAI 兼容接口",api:"openai-completions",baseURL:"https://generativelanguage.googleapis.com/v1beta/openai",id:"gemini",keyUrl:"https://aistudio.google.com/apikey",vision:"Gemini 模型都能看图"},{key:"openrouter",name:"OpenRouter",note:"一个 Key 用很多家的模型",api:"openai-completions",baseURL:"https://openrouter.ai/api/v1",id:"openrouter",keyUrl:"https://openrouter.ai/keys"},{key:"siliconflow",name:"硅基流动",note:"国内,开源模型多",api:"openai-completions",baseURL:"https://api.siliconflow.cn/v1",id:"siliconflow",keyUrl:"https://cloud.siliconflow.cn/account/ak"},{key:"dashscope",name:"阿里云百炼(通义千问)",note:"国内",api:"openai-completions",baseURL:"https://dashscope.aliyuncs.com/compatible-mode/v1",id:"dashscope",keyUrl:"https://bailian.console.aliyun.com/?apiKey=1",vision:"qwen-vl 系列能看图"},{key:"moonshot",name:"Kimi(月之暗面)",note:"国内",api:"openai-completions",baseURL:"https://api.moonshot.cn/v1",id:"moonshot",keyUrl:"https://platform.moonshot.cn/console/api-keys"},{key:"zhipu",name:"智谱 GLM",note:"国内",api:"openai-completions",baseURL:"https://open.bigmodel.cn/api/paas/v4",id:"zhipu",keyUrl:"https://open.bigmodel.cn/usercenter/apikeys",vision:"glm-4v 系列能看图"},{key:"ark",name:"火山方舟(豆包)",note:"国内",api:"openai-completions",baseURL:"https://ark.cn-beijing.volces.com/api/v3",id:"ark",keyUrl:"https://console.volcengine.com/ark"},{key:"ollama",name:"Ollama(本机)",note:"在自己电脑上跑开源模型,不需要 Key",api:"openai-completions",baseURL:"http://127.0.0.1:11434/v1",id:"ollama"},{key:"custom",name:"其他服务",note:"中转站、自建网关等任何 OpenAI / Anthropic 兼容接口",api:"openai-completions",baseURL:"",id:""}],fp=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:Cp,keyUrl:"https://platform.deepseek.com/api_keys"}];function _U({client:e}){const{catalog:t}=Fo(e),[n,r]=b.useState(!1),[i,o]=b.useState(void 0),c=je(e.providersRevision),u=je(e.credentialRevision),f=je(e.connection.status),[d,p]=b.useState(null),[m,g]=b.useState(null),[v,y]=b.useState(null),[S,k]=b.useState(null),w=b.useCallback(()=>{e.listProviders().then(N=>{p(N),g(null)}).catch(N=>g(N instanceof Error?N.message:String(N)))},[e]);if(b.useEffect(()=>{f.state==="open"&&w()},[w,c,u,f.state]),v!==null&&d!==null){const N=v==="new"?void 0:d.providers.find(R=>R.id===v);return s.jsx("section",{className:"providers-section",children:s.jsx(NU,{client:e,profile:N,preset:v==="new"?i:void 0,taken:d.taken,revision:d.revision,readOnly:!d.writable,onDone:()=>{y(null),o(void 0),w()}},v)})}if(n)return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"添加模型服务"}),s.jsx("button",{className:"ghost",onClick:()=>r(!1),children:"返回"})]}),s.jsxs("div",{className:"preset-grid",children:[fp.map(N=>s.jsxs("button",{className:"preset-option",onClick:()=>{var R;r(!1),(R=document.getElementById(`builtin-${N.id}`))==null||R.scrollIntoView({behavior:"smooth"})},children:[s.jsx("span",{className:"mode-title",children:N.name}),s.jsx("span",{className:"mode-subtitle",children:N.note})]},N.id)),SU.map(N=>s.jsxs("button",{className:"preset-option",disabled:d===null||!d.writable,onClick:()=>{o(N),r(!1),y("new")},children:[s.jsx("span",{className:"mode-title",children:N.name}),s.jsx("span",{className:"mode-subtitle",children:N.note})]},N.key))]})]});const A=new Set((d==null?void 0:d.providers.map(N=>N.id))??[]);return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"模型服务"}),s.jsx("button",{className:"primary",onClick:()=>r(!0),disabled:d===null,children:"+ 添加模型服务"})]}),s.jsx("p",{className:"muted",children:"每个服务填一次 Key,它的模型就会出现在输入框旁的模型选择器里。Claude、ChatGPT、Gemini、国内各家和本机的 Ollama 都可以接;需要看截图的功能请选能看图的模型。Key 保存在本机 dsh 的凭据文件里,界面不会再显示。"}),fp.map(N=>s.jsx(IU,{client:e,provider:N,catalog:t},N.id)),t==null?void 0:t.groups.filter(N=>!A.has(N.id)&&!fp.some(R=>R.id===N.id)).map(N=>s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:N.name}),s.jsx("div",{className:"muted small",children:s.jsx("code",{children:N.id})})]}),s.jsx("span",{className:"badge",children:"内置"})]}),s.jsx("div",{className:"model-chips",children:N.models.map(R=>s.jsx("span",{className:"chip",children:R.name},R.id))})]},N.id)),m!==null&&s.jsx("div",{className:"banner error",children:m}),S!==null&&s.jsx("div",{className:"success small",children:S}),d!==null&&!d.writable&&s.jsx("div",{className:"notice info left",children:"当前 profile 是只读的,无法在界面中修改提供方。"}),d===null&&m===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),d==null?void 0:d.providers.map(N=>s.jsx(EU,{client:e,profile:N,revision:d.revision,readOnly:!d.writable,onEdit:()=>y(N.id),onRemoved:R=>{k(R?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),w()}},N.id))]})}function EU({client:e,profile:t,revision:n,readOnly:r,onEdit:i,onRemoved:o}){const[c,u]=b.useState(!1),[f,d]=b.useState(null),p=mm(t.api),m=async()=>{var v,y;const g=t.apiKeyRef!==void 0&&((v=t.credential)==null?void 0:v.source)==="file"?`
226
-
227
- 同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(window.confirm(`确定删除「${t.displayName}」吗?使用它的会话需要换一个模型。${g}`)){u(!0),d(null);try{const{defaultReset:S}=await e.removeProvider({id:t.id,removeKey:((y=t.credential)==null?void 0:y.source)==="file",expectedRevision:n});o(S)}catch(S){d(S instanceof Error?S.message:String(S))}finally{u(!1)}}};return s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.displayName}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id}),t.baseURL!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("span",{className:"mono",children:t.baseURL})]})]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:p===void 0?t.api??"内置目录":`${p.title} · ${p.subtitle}`}),s.jsx(CU,{profile:t}),t.active?s.jsx("span",{className:"badge ok",children:"已生效"}):s.jsx("span",{className:"badge warn",title:t.error,children:"未生效"})]})]}),t.error!==void 0&&s.jsx("div",{className:"error small",children:t.error}),t.models.length>0?s.jsx("div",{className:"model-chips",children:t.models.map(g=>s.jsxs("span",{className:"chip",title:g.name??g.id,children:[g.id,go(g.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",go(g.contextWindow)]})]},g.id))}):s.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),f!==null&&s.jsx("div",{className:"error small",children:f}),s.jsxs("div",{className:"key-actions",children:[!t.declared&&s.jsx("span",{className:"muted small",children:"这是 dsh 内置提供方的配置,请在 dsh 官方模型页面编辑。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline",onClick:()=>void m(),disabled:c||r,children:"删除"}),t.declared&&s.jsx("button",{onClick:i,disabled:c||r,children:"编辑"})]})]})}function CU({profile:e}){return e.apiKeyRef===void 0?s.jsx("span",{className:"badge",children:"无 Key"}):e.credential===void 0?s.jsxs("span",{className:"badge",children:["Key:",e.apiKeyRef]}):e.credential.configured?s.jsx("span",{className:"badge ok",title:e.apiKeyRef,children:"Key 已配置"}):s.jsx("span",{className:"badge warn",title:e.apiKeyRef,children:"Key 未配置"})}function IU({client:e,provider:t,catalog:n}){const{items:r}=ew(e,[t.keyRef]),i=(r==null?void 0:r[t.keyRef])??null,o=n==null?void 0:n.groups.find(u=>u.id===t.id),c=n==null?void 0:n.failures.find(u=>u.id===t.id);return s.jsxs("section",{className:"card provider-card",id:`builtin-${t.id}`,children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.name}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id})," · ",t.note]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:"内置"}),i===null?null:i.configured?s.jsx("span",{className:"badge ok",children:"Key 已配置"}):s.jsx("span",{className:"badge warn",children:"Key 未配置"})]})]}),o!==void 0&&o.models.length>0&&s.jsx("div",{className:"model-chips",children:o.models.map(u=>s.jsx("span",{className:"chip",title:u.description,children:u.name},u.id))}),c!==void 0&&s.jsx("div",{className:"error small",children:c.message}),s.jsx(TU,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:i,bare:!0})]})}const wS={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function NS(e){const t=e.trim();return e.length>0&&t.length===0?"API Key 不能只包含空白字符。":t===""?null:/^[A-Z][A-Z0-9_]*=[^=]/.test(t)?'看起来粘贴了 "名称=值" 的整行,请只粘贴 Key 本身。':/^(["'`]).+\1$/.test(t)?"请去掉 Key 两侧的引号。":/^[\x21-\x7E]+$/.test(t)?null:"API Key 只能包含可见的 ASCII 字符,不能有空格或中文。"}function AU({client:e}){const t=je(e.capabilities);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模型"}),s.jsx("p",{className:"muted",children:"agent 用哪个模型、接哪些模型服务都在这里。保存后立即生效;新对话和飞书对话默认用下面选的模型,软件自己开的会话(干预、游戏等)可以另选一个;每个对话也可以在输入框旁边单独换。"}),s.jsx(MU,{client:e}),t.has("role-model")&&s.jsx(RU,{client:e}),t.has("providers")&&s.jsx(_U,{client:e})]})}function TU({client:e,refName:t,title:n,description:r,helpUrl:i,info:o,placeholder:c,bare:u=!1}){const[f,d]=b.useState(""),[p,m]=b.useState(!1),[g,v]=b.useState(!1),[y,S]=b.useState(null),k=NS(f),w=o!==null&&!o.writable,A=async()=>{if(!(f.trim()===""||k!==null)){v(!0),S(null);try{await e.setCredential(t,f.trim()),d(""),m(!1),S({tone:"ok",text:"已保存,立即生效。"})}catch(D){S({tone:"error",text:D instanceof Error?D.message:String(D)})}finally{v(!1)}}},N=async()=>{if(window.confirm(`确定要删除已保存的 ${n} 吗?删除后需要重新填写才能使用对应模型。`)){v(!0),S(null);try{await e.unsetCredential(t),S({tone:"ok",text:"已删除。"})}catch(D){S({tone:"error",text:D instanceof Error?D.message:String(D)})}finally{v(!1)}}},R=u?"div":"section";return s.jsxs(R,{className:u?"credential-inline":"card",children:[!u&&s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsxs("div",{className:"muted small",children:[r," ",s.jsx("code",{children:t})]})]}),s.jsx($U,{info:o})]}),w?s.jsxs("div",{className:"notice info left",children:["当前 Key 来自",wS[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",s.jsx("code",{children:t})," 再重新启动。"]}):s.jsxs("form",{className:"key-form",onSubmit:D=>{D.preventDefault(),A()},children:[s.jsxs("div",{className:"key-input",children:[s.jsx("input",{type:p?"text":"password",value:f,onChange:D=>{d(D.target.value),S(null)},placeholder:(o==null?void 0:o.configured)===!0?"已配置。输入新的 Key 可替换":c??"粘贴你的 API Key(sk-…)",autoComplete:"off",spellCheck:!1,"aria-label":n,disabled:g}),s.jsx("button",{type:"button",className:"ghost",onClick:()=>m(D=>!D),disabled:f==="",children:p?"隐藏":"显示"})]}),k!==null&&s.jsx("div",{className:"error small",children:k}),s.jsxs("div",{className:"key-actions",children:[i!==void 0&&s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"small",children:"获取 API Key ↗"}),s.jsx("span",{className:"spacer"}),(o==null?void 0:o.configured)===!0&&o.source==="file"&&s.jsx("button",{type:"button",className:"danger-outline",onClick:()=>void N(),disabled:g,children:"删除"}),s.jsx("button",{type:"submit",className:"primary",disabled:g||f.trim()===""||k!==null,children:g?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),y!==null&&s.jsx("div",{className:y.tone==="ok"?"success small":"error small",children:y.text})]})}function $U({info:e}){return e===null?s.jsx("span",{className:"badge",children:"读取中…"}):e.configured?s.jsxs("span",{className:"badge ok",children:["已配置 · ",wS[e.source??""]??e.source??"未知来源"]}):s.jsx("span",{className:"badge warn",children:"未配置"})}function MU({client:e}){const{catalog:t,error:n}=Fo(e),r=je(e.capabilities),[i,o]=b.useState(!1),[c,u]=b.useState(null),f=t===null?"":`${t.default.provider}/${t.default.model}`,d=async m=>{const[g,...v]=m.split("/");o(!0),u(null);try{await e.connection.call("models/setDefault",{provider:g,model:v.join("/")}),u("已设为默认,新对话会用它。")}catch(y){u(y instanceof Error?y.message:String(y))}finally{o(!1)}},p=(t==null?void 0:t.groups.some(m=>m.models.some(g=>`${m.id}/${g.id}`===f)))??!1;return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"默认模型"}),s.jsx("p",{className:"muted small",children:"先在下面的模型服务里填好 Key,这里就能选它的模型。"})]})}),n!==null&&s.jsx("div",{className:"error small",children:n}),t===null&&n===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),t!==null&&s.jsx(yn,{"aria-label":"默认模型",value:f,disabled:i||!r.has("model-default"),onChange:m=>void d(m),options:[...p?[]:[{value:f,label:`${t.default.provider} / ${t.default.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(m=>m.models.map(g=>({value:`${m.id}/${g.id}`,label:g.name,group:m.name})))]}),t==null?void 0:t.failures.map(m=>s.jsxs("div",{className:"error small",children:[m.name,":",m.message]},m.id)),c!==null&&s.jsx("div",{className:"muted small",children:c})]})}function RU({client:e}){const{catalog:t}=Fo(e),n=je(e.connection.status),[r,i]=b.useState(void 0),[o,c]=b.useState(!1),[u,f]=b.useState(null);b.useEffect(()=>{if(n.state!=="open")return;let g=!0;return e.connection.call("models/roleModel",{}).then(v=>{g&&i(v.model)}).catch(()=>{}),()=>{g=!1}},[e,n.state]);const d=r==null?"":`${r.provider}/${r.model}`,p=async g=>{const[v,...y]=g.split("/"),S=g===""?null:{provider:v,model:y.join("/")};c(!0),f(null);try{const{warning:k}=await e.connection.call("models/setRoleModel",{model:S});i(S),f(k!==void 0?{tone:"warn",text:k}:{tone:"ok",text:S===null?"角色 agent 和以前一样,用默认模型。":"之后新开的干预、游戏、脚本、编排会话用它;已经开着的会话不变。"})}catch(k){f({tone:"warn",text:k instanceof Error?k.message:String(k)})}finally{c(!1)}},m=d===""||((t==null?void 0:t.groups.some(g=>g.models.some(v=>`${g.id}/${v.id}`===d)))??!1);return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"角色 agent 的模型"}),s.jsx("p",{className:"muted small",children:"干预、游戏、脚本、编排这些软件自己开的会话用它。它们主要是截图、看日志、点击,选一个便宜、能看图的模型可以省用量;你自己的对话仍用上面的默认模型。"})]})}),t===null||r===void 0?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsx(yn,{"aria-label":"角色 agent 的模型",value:d,disabled:o,onChange:g=>void p(g),options:[{value:"",label:"和默认模型一样"},...m?[]:[{value:d,label:`${r.provider} / ${r.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(g=>g.models.map(v=>({value:`${g.id}/${v.id}`,label:v.name,group:g.name})))]}),u!==null&&s.jsx("div",{className:u.tone==="ok"?"muted small":"error small",children:u.text})]})}const OU=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold;function zU({client:e}){var v;const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!1),[f,d]=b.useState(null),p=(v=kr())==null?void 0:v.restartService;b.useEffect(()=>{if(f===null||n===null)return;if(f===n.settings.threshold){d(null);return}const y=setTimeout(()=>void m({...n.settings,threshold:f}).then(()=>d(null)),400);return()=>clearTimeout(y)},[f,n]),b.useEffect(()=>{if(t.state!=="open")return;let y=!0;return e.connection.call("compaction/get",{}).then(S=>{y&&r(S)}).catch(S=>{y&&o(ze(S))}),()=>{y=!1}},[e,t.state]);const m=async y=>{if(!(!y.auto&&(n==null?void 0:n.settings.auto)===!0&&!window.confirm(`关掉自动压缩后,对话超过模型的上下文长度时会直接出错,要手动压缩或开新对话才能继续。
228
-
229
- 确定关掉吗?`))){u(!0),o(null);try{r(await e.connection.call("compaction/set",{settings:y}))}catch(S){o(ze(S))}finally{u(!1)}}},g=async()=>{p===void 0||!window.confirm(`重启 agent 服务:正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。
230
-
231
- 确定现在重启吗?`)||await p()};return s.jsxs("div",{className:"settings-page compaction-page",children:[s.jsx("h2",{children:"对话压缩"}),s.jsx("p",{children:"对话很长时,模型一次看不下全部内容。压缩会把较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:"}),s.jsxs("ul",{className:"compaction-costs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"会丢失记忆"}),":早先的细节(具体的命令和输出、日志、截图、你说过的原话)agent 不再记得;"]}),s.jsx("li",{children:"摘要可能漏掉或写错内容,而且不能撤销;"}),s.jsx("li",{children:"界面上的聊天记录还在,只是 agent 看不到了。"})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.auto,disabled:c,onChange:y=>void m({...n.settings,auto:y.target.checked})}),"对话太长时自动压缩"]}),s.jsx("p",{className:"muted small",children:n.settings.auto?"关掉后不会自动压缩:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。":"已关闭:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。"}),s.jsxs("label",{className:"field compaction-threshold",children:[s.jsxs("span",{className:"field-title",children:["占满上下文的多少时压缩:",s.jsxs("strong",{children:[f??n.settings.threshold,"%"]}),(f??n.settings.threshold)===o$?"(默认)":""]}),s.jsx("input",{type:"range",min:Ok,max:zk,step:5,value:f??n.settings.threshold,disabled:!n.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:y=>d(Number(y.target.value))}),s.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。"})]}),!OU(n.settings,n.applied)&&s.jsxs("div",{className:"notice left",children:[s.jsx(ee,{name:"info"}),s.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",n.applied.auto?`自动压缩,${n.applied.threshold}%`:"不自动压缩",")。",p===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),p!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void g(),children:"重启 agent 服务"})]}),i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"手动压缩"}),s.jsxs("p",{className:"muted small",children:["在对话框里输入 ",s.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),n===null&&i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:i})]})]})}const Pb=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],PU=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function LU({client:e,state:t,onState:n}){const r=je(e.capabilities),[i,o]=b.useState(null),[c,u]=b.useState(null),[f,d]=b.useState(null),p=r.has("monitor");b.useEffect(()=>{if(!p)return;let v=!0;return e.connection.call("monitor/settings",{}).then(y=>{v&&d(y)}).catch(()=>{}),()=>{v=!1}},[e,p]);const m=async(v,y)=>{o(v),u(null);try{n(await e.connection.call("permissions/area/set",{area:v,policy:y}))}catch(S){u(ze(S))}finally{o(null)}},g=async v=>{o("intervene"),u(null);try{d(await e.connection.call("monitor/settings/set",{intervene:v}))}catch(y){u(ze(y))}finally{o(null)}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"按范围设置"}),s.jsxs("p",{className:"muted small",children:["agent 能自己做的事,一项一项决定:",Pb.map(v=>`「${v.label}」${v.hint}`).join(";"),"。"]})]})}),s.jsxs("div",{className:"area-list",children:[p&&f!==null&&s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:"主动干预出问题的脚本"}),s.jsx("span",{className:"muted small",children:"脚本卡住、报错,自动处理解决不了时交给 agent:「诊断并处理」会暂停脚本、看屏幕、点击输入来解决;「只诊断」只说明原因由你决定。"})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":"主动干预",children:PU.map(v=>s.jsx("button",{role:"radio","aria-checked":f.intervene===v.value,className:f.intervene===v.value?"active":"",disabled:i!==null,onClick:()=>void g(v.value),children:v.label},v.value))})]}),t$.map(v=>{const y=t.areas[v.id]??"default";return s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:v.title}),s.jsx("span",{className:"muted small",children:v.description})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":v.title,children:Pb.map(S=>s.jsx("button",{role:"radio","aria-checked":y===S.policy,title:S.hint,className:`${y===S.policy?"active":""} ${S.policy}`,disabled:i!==null,onClick:()=>void m(v.id,S.policy),children:S.label},S.policy))})]},v.id)})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:c})]})]})}const DU=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function FU({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(!1),[u,f]=b.useState(null);b.useEffect(()=>e.connection.on("permissions/changed",p=>i(p)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let p=!0;return e.connection.call("permissions/get",{}).then(m=>{p&&i(m)}).catch(m=>{p&&f(ze(m))}),()=>{p=!1}},[e,t.state]);const d=async p=>{if((r==null?void 0:r.mode)!==p&&!(p==="full"&&!window.confirm(`打开「完全访问」后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。只在你信任当前模型、并且需要它自己完成整件事时打开。
232
-
233
- 确定打开吗?`))){c(!0),f(null);try{i(await e.connection.call("permissions/set",{mode:p}))}catch(m){f(ze(m))}finally{c(!1)}}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"权限"}),s.jsx("p",{children:"决定 agent 做事之前要不要先问你。对所有会话都有效,包括飞书里的对话、异常处理和流水线里的 agent 步骤。"}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"permission-options",role:"radiogroup","aria-label":"权限",children:DU.map(p=>s.jsxs("button",{role:"radio","aria-checked":(r==null?void 0:r.mode)===p.mode,disabled:o||r===null,className:`permission-option ${p.mode} ${(r==null?void 0:r.mode)===p.mode?"active":""}`,onClick:()=>void d(p.mode),children:[s.jsx("span",{className:"permission-dot","aria-hidden":"true"}),s.jsxs("span",{className:"permission-text",children:[s.jsx("strong",{children:p.title}),s.jsx("span",{children:p.text})]})]},p.mode))}),(r==null?void 0:r.mode)==="full"&&s.jsxs("div",{className:"notice warn-note left small",children:[s.jsx(ee,{name:"alert"}),s.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",r.since===void 0?"":`(${BU(r.since,n)})`,"。agent 不会再请求确认;它仍然不会替你输入密码、验证码或付款。"]})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:u})]})]}),r!==null&&s.jsx(LU,{client:e,state:r,onState:i}),r!==null&&r.recent.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"没问你就允许了的操作"}),s.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",r.recent.length," 条。"]}),s.jsx("ul",{className:"version-list",children:r.recent.map((p,m)=>s.jsxs("li",{children:[s.jsx("span",{className:"badge",children:p.toolName}),s.jsx("span",{className:"permission-reason",children:p.reason??"(没有说明)"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:Tt(p.at,n)})]},m))})]})]})}function BU(e,t){const n=Tt(e,t);return n==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(n)?`${n}前打开`:`${n} 打开`}const UU=[{style:"default",title:"默认",sample:"不加设定,按模型自己的说话方式。"},{style:"concise",title:"简洁干练",sample:"「日常跑完了,3 个成功 1 个失败:MAA 刷理智没体力了。」"},{style:"patient",title:"耐心细致",sample:"「我先帮你看了 MAA 的日志,失败是因为理智不够——这不是脚本坏了,等理智恢复再跑就行。」"},{style:"lively",title:"活泼可爱",sample:"「搞定啦~日常都跑完了!就是理智又见底了 (。•́︿•̀。)」"},{style:"buddy",title:"游戏搭子",sample:"「日常清完了,理智又被榨干了哈哈,活动商店还差两样,明天接着肝。」"},{style:"butler",title:"稳重管家",sample:"「今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?」"}];function HU({client:e}){const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(""),[c,u]=b.useState(!1),[f,d]=b.useState(!1),[p,m]=b.useState(null),[g,v]=b.useState(!1);b.useEffect(()=>{if(t.state!=="open")return;let k=!0;return e.connection.call("persona/get",{}).then(w=>{k&&(r(w.persona),o(w.prompt))}).catch(w=>{k&&m(ze(w))}),()=>{k=!1}},[e,t.state]);const y=k=>{r(w=>w===null?w:{...w,...k}),u(!0),v(!1)},S=async(k=n)=>{if(k!==null){d(!0),m(null);try{const w=await e.connection.call("persona/set",{persona:k});r(w.persona),o(w.prompt),u(!1),v(!0)}catch(w){m(ze(w))}finally{d(!1)}}};return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),s.jsx("p",{children:"agent 说话的方式和人设,对所有对话都有效:软件里的对话、飞书里的回复、流水线里的 agent 步骤。只改说话方式,不改做事的规则:该确认的照样确认,密码、验证码和付款照样不碰。"}),n!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"风格"}),s.jsx("div",{className:"persona-styles",role:"radiogroup","aria-label":"风格",children:UU.map(k=>s.jsxs("button",{role:"radio","aria-checked":n.style===k.style,className:`mode-option persona-style ${n.style===k.style?"selected":""}`,onClick:()=>y({style:k.style}),children:[s.jsx("strong",{children:k.title}),s.jsx("span",{className:"muted small",children:k.sample})]},k.style))})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"人设"}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"agent 的名字(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:小助",value:n.name??"",onChange:k=>y({name:k.target.value})})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"怎么称呼你(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:博士、开拓者、指挥官",value:n.callUser??"",onChange:k=>y({callUser:k.target.value})})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"其他要求(可选)"}),s.jsx("textarea",{className:"text-input plain",rows:6,placeholder:"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用英文缩写。",value:n.custom??"",onChange:k=>y({custom:k.target.value})})]}),s.jsxs("div",{className:"persona-actions",children:[s.jsx("button",{className:"primary",disabled:f||!c,onClick:()=>void S(),children:f?"保存中…":"保存"}),s.jsx("button",{disabled:f,onClick:()=>void S({style:"default"}),children:"恢复默认"}),g&&!c&&s.jsx("span",{className:"muted small",children:"已保存,下一句回复开始生效。"})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"加到 agent 提示词里的内容"}),i===""?s.jsx("p",{className:"muted small",children:"现在是默认风格,什么都不加。"}):s.jsx("pre",{className:"persona-prompt",children:i}),c&&s.jsx("p",{className:"muted small",children:"保存后更新。"})]})]}),n===null&&p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(ee,{name:"alert"}),s.jsx("span",{children:p})]})]})}const ZU={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:AU}]},WU={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:FU}]},VU={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:HU}]},qU={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:zU}]},GU={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:xU}]};function KU({client:e}){const t=je(e.capabilities),n=je(e.connection.server),[r,i]=b.useState(0);b.useEffect(()=>Xk(()=>i(f=>f+1)),[]);const o=b.useMemo(()=>X$(t),[t,r]),c=o.filter(f=>f.missing.length===0),u=o.filter(f=>f.missing.length>0);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"插件状态"}),s.jsx("p",{children:"界面插件只在后端提供了它需要的能力时启用。后端少装一个插件,对应的界面就自动隐藏。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"后端能力"}),s.jsx("p",{className:"muted small",children:n===null?"尚未连接":`${n.server.name} ${n.server.version}${n.server.dsh===void 0?"":` · dsh ${n.server.dsh}`}`}),s.jsxs("div",{className:"chip-row",children:[[...t].sort().map(f=>s.jsx("span",{className:"chip",children:f},f)),t.size===0&&s.jsx("span",{className:"muted small",children:"无"})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("h3",{children:["已启用(",c.length,")"]}),s.jsx("ul",{className:"plugin-list",children:c.map(({plugin:f})=>s.jsxs("li",{children:[s.jsx("span",{className:"plugin-name",children:f.title}),s.jsx("span",{className:"muted small",children:f.requires.length===0?"无需后端能力":f.requires.join(" · ")})]},f.id))})]}),u.length>0&&s.jsxs("section",{className:"card",children:[s.jsxs("h3",{children:["等待后端能力(",u.length,")"]}),s.jsx("ul",{className:"plugin-list",children:u.map(({plugin:f,missing:d})=>s.jsxs("li",{children:[s.jsxs("span",{className:"plugin-name",children:[f.title,f.milestone!==void 0&&s.jsx("span",{className:"chip subtle",children:f.milestone})]}),s.jsxs("span",{className:"muted small",children:["缺少:",d.join(" · ")]})]},f.id))})]})]})}const YU={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:KU}]};function XU(e,t,n){const r=new Array(e);return new Proxy(r,{get(i,o,c){if(typeof o=="string"){const u=o.charCodeAt(0);if(u>=48&&u<=57){const f=+o;if(Number.isInteger(f)&&f>=0&&f<e){let d=i[f];if(!d){const p=t[f*2];d=i[f]={index:f,key:n(f),start:p,size:t[f*2+1],end:p+t[f*2+1],lane:0}}return d}}if(o==="length")return e}return Reflect.get(i,o,c)}})}function lo(e,t,n){let r=n.initialDeps??[],i,o=!0;function c(){const u=e();return(u.length!==r.length||u.some((d,p)=>r[p]!==d))&&(r=u,i=t(...u),n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(i),o=!1),i}return c.updateDeps=u=>{r=u},c}function Lb(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const QU=(e,t)=>Math.abs(e-t)<1.01,JU=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};let _l;const hp=()=>{if(_l!==void 0)return _l;if(typeof navigator>"u")return _l=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return _l=!0;const e=navigator.maxTouchPoints;return _l=navigator.platform==="MacIntel"&&e!==void 0&&e>0},Db=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},e5=e=>e,t5=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,i=new Array(r);for(let o=0;o<r;o++)i[o]=t+o;return i},n5=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=c=>{const{width:u,height:f}=c;t({width:Math.round(u),height:Math.round(f)})};if(i(Db(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(c=>{const u=()=>{const f=c[0];if(f!=null&&f.borderBoxSize){const d=f.borderBoxSize[0];if(d){i({width:d.inlineSize,height:d.blockSize});return}}i(Db(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},ud={passive:!0},s5=typeof window>"u"?!0:"onscrollend"in window,r5=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const o=e.options.useScrollendEvent&&s5;let c=0;const u=o?null:JU(i,()=>t(c,!1),e.options.isScrollingResetDelay),f=m=>()=>{c=n(r),u==null||u(),t(c,m)},d=f(!0),p=f(!1);return r.addEventListener("scroll",d,ud),o&&r.addEventListener("scrollend",p,ud),()=>{r.removeEventListener("scroll",d),o&&r.removeEventListener("scrollend",p),u==null||u.cancel()}},i5=(e,t)=>r5(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),a5=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),i=n.options.getItemKey(r);return n.itemSizeCache.get(i)??n.options.estimateSize(r)}if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),i=n.options.getItemKey(r),o=n.itemSizeCache.get(i);if(o!==void 0)return o}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},o5=(e,{adjustments:t=0,behavior:n},r)=>{var i,o;(o=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},l5=o5;class c5{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const c=()=>{const u=o.target,f=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);for(const[d,p]of this.elementsCache)if(p===u){this.elementsCache.delete(d);break}return}this.isIndexInRange(f)&&this.shouldMeasureDuringScroll(f)&&this.resizeItem(f,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var o;return(o=r())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=r())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{var r,i;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:e5,rangeExtractor:t5,onChange:()=>{},measureElement:a5,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const g in n){const v=n[g];v!==void 0&&(o[g]=v)}const c=this.options;let u=null,f=null,d=!1;if(c!==void 0&&c.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const g=c.count,v=o.count,y=this.getMeasurements(),S=g>0?((r=y[0])==null?void 0:r.key)??c.getItemKey(0):null,k=g>0?((i=y[g-1])==null?void 0:i.key)??c.getItemKey(g-1):null;if(v!==g||g>0&&v>0&&(o.getItemKey(0)!==S||o.getItemKey(v-1)!==k)){d=!0;const N=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;N&&(u=[N.key,this.getScrollOffset()-N.start]);const R=o.followOnAppend===!0?"auto":o.followOnAppend||null;R&&v>g&&this.isAtEnd(c.scrollEndThreshold)&&(g===0||o.getItemKey(v-1)!==k)&&(f=R)}}this.options=o,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let p=!1,m=0;if(u&&this.scrollOffset!==null){const[g,v]=u,y=this.getMeasurements(),{count:S,getItemKey:k}=this.options;let w=0;for(;w<S&&k(w)!==g;)w++;if(w<S){const A=y[w];if(A){const N=Math.max(0,A.start+v);N!==this.scrollOffset&&(m=N-this.scrollOffset,this.scrollOffset=N,p=!0)}}}(p||f)&&(this.pendingScrollAnchor=[p?u[0]:null,p?u[1]:0,f,m])},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=lo(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,c)=>{if(c&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const u=this.getScrollOffset();this.scrollDirection=c?u===o?this.scrollDirection:u<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!hp()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",c,ud),o.addEventListener("touchend",u,ud),this.unsubs.push(()=>{o.removeEventListener("touchstart",c),o.removeEventListener("touchend",u),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[o,c,u,f]=i;o!==null&&!u&&(hp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?f!==0&&(this._iosDeferredAdjustment+=f):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),u&&this.scrollToEnd({behavior:u})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;if(this._iosDeferredAdjustment<0&&n>=r-1){this._iosDeferredAdjustment=0;return}const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=lo(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,r,i,o,c,u,f,d)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:i,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:f,gap:d}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=lo(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:i,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:f,gap:d},p)=>{const m=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const w of this.laneAssignments.keys())w>=n&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const g=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),u===1){const w=n*2;let A=this._flatMeasurements;if(!A||A.length<w){const D=new Float64Array(w);A&&g>0&&D.set(A.subarray(0,g*2)),A=D,this._flatMeasurements=A}let N;if(g===0)N=r+i;else{const D=g-1;N=A[D*2]+A[D*2+1]+d}for(let D=g;D<n;D++){const P=o(D),F=m.get(P),W=typeof F=="number"?F:this.options.estimateSize(D);A[D*2]=N,A[D*2+1]=W,N+=W+d}const R=XU(n,A,o);return this.measurementsCache=R,R}const v=this.measurementsCache.slice(0,g),y=new Array(u).fill(void 0),S=new Float64Array(u);let k=0;for(let w=0;w<g;w++){const A=v[w];A&&(y[A.lane]===void 0&&k++,y[A.lane]=w,S[A.lane]=A.end)}for(let w=g;w<n;w++){const A=o(w),N=this.laneAssignments.get(w);let R,D;const P=f==="estimate"||m.has(A);if(N!==void 0&&this.options.lanes>1){R=N;const O=y[R],T=O!==void 0?v[O]:void 0;D=T?T.end+d:r+i}else if(k===u){let O=0,T=S[0],Z=y[0];for(let E=1;E<u;E++){const C=S[E];(C<T||C===T&&y[E]<Z)&&(O=E,T=C,Z=y[E])}R=O,D=T+d,P&&this.laneAssignments.set(w,R)}else R=w%this.options.lanes,D=r+i,P&&this.laneAssignments.set(w,R);const F=m.get(A),W=typeof F=="number"?F:this.options.estimateSize(w),M=D+W;v[w]={index:w,start:D,size:W,end:M,key:A,lane:R},y[R]===void 0&&k++,y[R]=w,S[R]=M}return this.measurementsCache=v,v},{key:!1,debug:()=>this.options.debug}),this.calculateRange=lo(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,i,o)=>n.length===0||r===0?(this.range=null,null):(this.range=d5(n,r,i,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=lo(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,o,c)=>o===null||c===null?[]:n({startIndex:o,endIndex:c,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,i-o),u=Math.min(this.options.count-1,i+o);return n>=c&&n<=u}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((c,u)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(u))});return}const r=this.indexFromElement(n);if(!this.isIndexInRange(r))return;const i=this.options.getItemKey(r),o=this.elementsCache.get(i);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(i,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var i,o;if(!this.isIndexInRange(n))return;let c,u,f;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)f=this.options.getItemKey(n),u=d[n*2],c=d[n*2+1];else{const g=this.measurementsCache[n];if(!g)return;f=g.key,u=g.start,c=g.size}const p=this.itemSizeCache.get(f)??c,m=r-p;if(m!==0){const g=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,v=g?this.getTotalSize():0,y=this.getScrollOffset()+this.scrollAdjustments,k=!this.itemSizeCache.has(f)?u<y:u+p<=y&&this.scrollDirection!=="backward",w=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:f,start:u,size:c,end:u+c,lane:0},m,this):k);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(f,r),this.itemSizeCacheVersion++;let A=!1;g?A=this.applyScrollAdjustment(this.getTotalSize()-v):w&&(A=this.applyScrollAdjustment(m)),this.notify(A)}},this.getVirtualItems=lo(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let o=0,c=n.length;o<c;o++){const u=n[o],f=r[u];i.push(f)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const i=this._flatMeasurements,o=this.options.lanes===1&&i!=null,c=jS(0,r.length-1,o?u=>i[u*2]:u=>Lb(r[u]).start,n);return Lb(r[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,i=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),c=this.getScrollOffset();r==="auto"&&(r=n>=c+o?"end":"start"),r==="center"?n+=(i-o)/2:r==="end"&&(n-=o);const u=this.getMaxScrollOffset();return Math.max(Math.min(u,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getSize(),o=this.getScrollOffset(),c=this.measurementsCache[n];if(!c)return;if(r==="auto")if(c.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(c.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const u=r==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(u,r,c.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(n,r),c=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,r);if(!o)return;const[c,u]=o,f=this.now();this.scrollState={index:n,align:u,behavior:i,startedAt:f,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,c=this._flatMeasurements;c!=null?i=c[o*2]+c[o*2+1]:i=((n=r[o])==null?void 0:n.end)??0}else{const o=Array(this.options.lanes).fill(null);let c=r.length-1;for(;c>=0&&o.some(u=>u===null);){const u=r[c];o[u.lane]===null&&(o[u.lane]=u.end),c--}i=Math.max(...o.filter(u=>u!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const i of r)i&&this.itemSizeCache.has(i.key)&&n.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){return t===0?!1:hp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,o=1,c=i!==this.scrollState.lastTargetOffset;if(!c&&QU(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const u=this.getSize()||600,f=Math.abs(i-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&f>u;this.scrollState.lastTargetOffset=i,d||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const jS=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,o=n(i);if(o<r)e=i+1;else if(o>r)t=i-1;else return i}return e>0?e-1:0};function u5(e,t,n){let r=0;for(;r<=t;){const i=(r+t)/2|0,o=e[i*2];if(o<n)r=i+1;else if(o>n)t=i-1;else return i}return r>0?r-1:0}function d5(e,t,n,r,i){const o=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:o};if(r===1&&i!==null){const d=u5(i,o,n);let p=d;const m=n+t;for(;p<o&&i[p*2]+i[p*2+1]<m;)p++;return{startIndex:d,endIndex:p}}let u=jS(0,o,d=>e[d].start,n),f=u;if(r===1)for(;f<o&&e[f].end<n+t;)f++;else if(r>1){const d=Array(r).fill(0);for(;f<o&&d.some(m=>m<n+t);){const m=e[f];d[m.lane]=m.end,f++}const p=Array(r).fill(n+t);for(;u>=0&&p.some(m=>m>=n);){const m=e[u];p[m.lane]=m.start,u--}u=Math.max(0,u-u%r),f=Math.min(o,f+(r-1-f%r))}return{startIndex:u,endIndex:f}}const pp=typeof document<"u"?b.useLayoutEffect:b.useEffect;function f5({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const i=b.useReducer(p=>p+1,0)[1],o=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=n;const c=p=>{const m=o.current;if(!m.enabled||!m.container)return;const g=p.getTotalSize();if(g!==m.lastSize){m.lastSize=g;const v=p.options.horizontal?"width":"height";m.container.style[v]=`${g}px`}},u=p=>{const m=o.current;if(!m.enabled||!m.container)return;c(p);const g=!!p.options.horizontal,v=m.mode==="transform",y=g?"left":"top",S=p.options.scrollMargin,k=p.getVirtualItems();for(const w of k){const A=w.start-S,N=p.elementsCache.get(w.key);N&&m.lastPositions.get(N)!==A&&(m.lastPositions.set(N,A),v?N.style.transform=g?`translate3d(${A}px, 0, 0)`:`translate3d(0, ${A}px, 0)`:N.style[y]=`${A}px`)}},f={...r,onChange:(p,m)=>{var g;const v=o.current;let y=!0;if(v.enabled){u(p);const S=p.range,k=v.prevRange;y=!k||k.isScrolling!==p.isScrolling||k.startIndex!==(S==null?void 0:S.startIndex)||k.endIndex!==(S==null?void 0:S.endIndex),y&&(v.prevRange=S?{startIndex:S.startIndex,endIndex:S.endIndex,isScrolling:p.isScrolling}:null)}y&&(e&&m?Hm.flushSync(i):i()),(g=r.onChange)==null||g.call(r,p,m)}},[d]=b.useState(()=>{const p=new c5(f);return Object.assign(p,{containerRef:m=>{const g=o.current;if(g.container=m,g.lastSize=null,m&&g.enabled){const v=p.getTotalSize();g.lastSize=v;const y=p.options.horizontal?"width":"height";m.style[y]=`${v}px`}}})});return d.setOptions(f),pp(()=>d._didMount(),[]),pp(()=>(c(d),d._willUpdate())),pp(()=>{u(d)}),d}function h5(e){return f5({observeElementRect:n5,observeElementOffset:i5,scrollToFn:l5,...e})}const Od={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},SS={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},p5={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function m5(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function g5(e){return e.end===null?"进行中":e.reason===void 0?"":p5[e.reason.kind]??e.reason.kind}function _S(e){if(e.kind!=="assistant"||e.request.usage===void 0)return;const t=e.request.usage;return t.inputTokens+(t.cacheReadTokens??0)+(t.cacheWriteTokens??0)}function Bl(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function dd(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function x5({record:e,totals:t,onClose:n}){const r=y5(e,t),[i,o]=b.useState(r[0].id),c=r.find(u=>u.id===i)??r[0];return s.jsxs("aside",{className:"inspector","aria-label":"事件详情",children:[s.jsxs("header",{className:"inspector-head",children:[s.jsx("span",{className:`kind-badge kind-${e.kind}`,children:Od[e.kind]}),s.jsx("span",{className:"inspector-title",title:e.title,children:v5(e)}),s.jsx("button",{className:"ghost icon",onClick:n,"aria-label":"关闭详情",children:s.jsx(ee,{name:"close"})})]}),s.jsx("nav",{className:"inspector-tabs",role:"tablist",children:r.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===c.id,className:u.id===c.id?"active":"",onClick:()=>o(u.id),children:u.label},u.id))}),s.jsx("div",{className:"inspector-body",children:c.render()})]})}function v5(e){switch(e.kind){case"assistant":return`请求 #${e.request.index}${e.request.model===void 0?"":` · ${e.request.model}`}`;case"tool":return e.name;case"context":return e.title==="Compacted history"?"已压缩的历史":`上下文 · ${e.origin.kind}`;case"system":return"系统提示词";case"attempt":return"失败的模型尝试";default:return Od[e.kind]}}function y5(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>s.jsx(b5,{record:e})},{id:"raw",label:"原始输出",render:()=>s.jsx(mp,{content:e.content})},{id:"usage",label:"用量",render:()=>s.jsx(k5,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>s.jsx(w5,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>s.jsx(Zi,{rows:[["状态",s.jsx(Bu,{record:e})],["工具",s.jsx("code",{children:e.name})],["调用 ID",s.jsx("code",{children:e.callId})],["开始时间",Ui(e.start)],["时长",e.end===null?"运行中":Ts(Bl(e))],["审批",e.approval===void 0?"无需审批":e.approval.outcome??"等待中"],["错误",e.error===void 0?void 0:`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})},{id:"payload",label:"参数",render:()=>s.jsx("pre",{className:"payload",children:e.arguments===""?"未捕获参数":Um(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?s.jsx("p",{className:"muted",children:"未捕获结果"}):s.jsx(mp,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>s.jsxs(s.Fragment,{children:[s.jsx(Zi,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Ui(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),s.jsx("div",{className:"label",children:"预览"}),s.jsx(mp,{content:e.content})]})},{id:"raw",label:"原始内容",render:()=>s.jsx("pre",{className:"payload",children:JSON.stringify(e.content,null,2)})}];case"system":return[{id:"prompt",label:"系统提示词",render:()=>s.jsx("pre",{className:"payload",children:e.text})}];case"attempt":return[{id:"summary",label:"概述",render:()=>s.jsx(Zi,{rows:[["状态",s.jsx(Bu,{record:e})],["开始时间",Ui(e.start)],["时长",Ts(Bl(e))],["错误",e.error===void 0?"尝试在没有输出的情况下结束":`${e.error.message}${e.error.code===void 0?"":` (${e.error.code})`}`]]})}];case"compaction":return[{id:"summary",label:"概述",render:()=>s.jsx(Zi,{rows:[["状态",s.jsx(Bu,{record:e})],["开始时间",Ui(e.start)],["时长",e.end===null?"运行中":Ts(Bl(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${vn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${vn(e.usage.inputTokens)} / ${vn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function Bu({record:e}){return s.jsx("span",{className:`status-text status-${e.status}`,children:SS[e.status]})}function Zi({rows:e}){return s.jsx("dl",{className:"facts",children:e.filter(([,t])=>t!==void 0&&t!=="").map(([t,n])=>s.jsxs("div",{className:"fact",children:[s.jsx("dt",{children:t}),s.jsx("dd",{children:n})]},t))})}function b5({record:e}){const t=e.request,n=e.content.filter(i=>i.type==="text").map(i=>i.type==="text"?i.text:"").join(""),r=e.content.filter(i=>i.type==="tool-call");return s.jsxs(s.Fragment,{children:[s.jsx(Zi,{rows:[["状态",s.jsx(Bu,{record:e})],["请求",`#${t.index}`],["提供方",t.provider],["模型",t.model],["推理强度",t.reasoningEffort],["可用工具",t.toolCount===void 0?void 0:String(t.toolCount)],["工具调用",r.length===0?void 0:String(r.length)],["重试",t.retries===0?void 0:String(t.retries)],["上次尝试错误",t.lastRetryError===void 0?void 0:`${t.lastRetryError.message}${t.lastRetryError.code===void 0?"":` (${t.lastRetryError.code})`}`]]}),n.trim()!==""&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"助手消息"}),s.jsx(Ki,{text:n,className:"inspector-markdown"})]}),n.trim()===""&&r.length>0&&s.jsx("p",{className:"muted small",children:"(仅工具调用)"}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"工具调用"}),s.jsx("ul",{className:"call-list",children:r.map(i=>s.jsxs("li",{children:[s.jsx("code",{children:i.name})," ",s.jsx("span",{className:"muted",children:i.arguments.slice(0,120)})]},i.callId))})]})]})}function mp({content:e}){return e.length===0?s.jsx("p",{className:"muted",children:"无内容"}):s.jsx("div",{className:"raw-blocks",children:e.map((t,n)=>{switch(t.type){case"reasoning":return s.jsxs("details",{className:"raw-block reasoning-block",children:[s.jsx("summary",{children:"思考"}),s.jsx(Ki,{text:t.text,className:"inspector-markdown"})]},n);case"text":return s.jsx("pre",{className:"payload",children:t.text},n);case"tool-call":return s.jsxs("div",{className:"raw-block",children:[s.jsxs("div",{className:"label",children:["工具调用 · ",s.jsx("code",{children:t.name})]}),s.jsx("pre",{className:"payload",children:Um(t.arguments)})]},n);case"image":return s.jsxs("div",{className:"raw-block muted small",children:["🖼 ",t.name??`图片 ${n+1}`," ",t.width!==void 0?`${t.width}×${t.height}`:""]},n);case"file":return s.jsxs("div",{className:"raw-block muted small",children:["📎 ",t.name??"文件"," ",t.size===void 0?"":`${vn(t.size)}B`]},n);default:return s.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},n)}})})}function k5({record:e,totals:t}){const n=e.request.usage;return s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"usage-heading",children:"本次请求"}),n===void 0?s.jsx("p",{className:"muted",children:"未报告用量"}):s.jsx(Zi,{rows:[["输入(未缓存)",`${vn(n.inputTokens)} tok`],["缓存读取",n.cacheReadTokens===void 0?void 0:`${vn(n.cacheReadTokens)} tok`],["缓存写入",n.cacheWriteTokens===void 0?void 0:`${vn(n.cacheWriteTokens)} tok`],["输入合计",`${vn(_S(e))} tok`],["输出",`${vn(n.outputTokens)} tok`],["其中推理",n.reasoningTokens===void 0?void 0:`${vn(n.reasoningTokens)} tok`],["总计",n.totalTokens===void 0?void 0:`${vn(n.totalTokens)} tok`]]}),s.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),s.jsx(Zi,{rows:[["请求数",String(t.requests)],["输入(未缓存)",`${vn(t.inputTokens)} tok`],["缓存读取",`${vn(t.cacheReadTokens)} tok`],["输出",`${vn(t.outputTokens)} tok`],["其中推理",`${vn(t.reasoningTokens)} tok`]]})]})}function w5({record:e}){const[t,n]=b.useState(!1),r=e.request;return s.jsx(Zi,{rows:[["开始时间",s.jsx("button",{className:"link-button",onClick:()=>n(i=>!i),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Ui(e.start)})],["总时长",e.end===null?"运行中":Ts(Bl(e))],["首 token 延迟",r.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Ts(r.ttftMs)],["生成",r.decodeMs===void 0?e.live?"运行中":"不可用":Ts(r.decodeMs)],["吞吐量",r.tokensPerSecond===void 0?r.usage===void 0?"用量不可用":"时长过短":`${r.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",dd(e)===0?void 0:String(dd(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const Tu=14,N5=b.memo(function({model:t,mode:n,brush:r,selectedId:i,onBrush:o,onSelect:c}){const u=b.useMemo(()=>R2(t),[t]),f=b.useMemo(()=>aN.map((O,T)=>({...O,index:T})).filter(O=>O.id!=="compaction"||u.some(T=>T.lane===O.index)),[u]),d=new Map(f.map((O,T)=>[O.index,T])),p=t.span,[m,g]=b.useState(null),v=n==="actual"&&p!==null?j5(m,p):null,y=b.useRef(null),[S,k]=b.useState(null),w=b.useRef(null),A=t.records.length,N=(O,T)=>n==="equal"?A===0?0:O/A:v===null||v.end===v.start?0:(T-v.start)/(v.end-v.start),R=O=>{var Z;const T=(Z=y.current)==null?void 0:Z.getBoundingClientRect();return T===void 0||T.width===0?0:Math.min(1,Math.max(0,(O-T.left)/T.width))},D=O=>{if(O.button===2&&v!==null&&p!==null&&(v.start>p.start||v.end<p.end)){w.current={x:O.clientX,view:v};return}if(O.button!==0)return;const T=R(O.clientX);k({x0:T,x1:T})},P=O=>{if(w.current!==null&&p!==null&&y.current!==null){const T=(O.clientX-w.current.x)/y.current.clientWidth,Z=w.current.view.end-w.current.view.start;g(P2(w.current.view,-T*Z,p));return}S!==null&&k({...S,x1:R(O.clientX)})},F=()=>{if(w.current=null,S===null)return;const[O,T]=S.x0<S.x1?[S.x0,S.x1]:[S.x1,S.x0];if(k(null),!(T-O<.005)){if(n==="equal")o({mode:"equal",from:Math.floor(O*A),to:Math.max(Math.floor(O*A),Math.ceil(T*A)-1)});else if(v!==null){const Z=v.end-v.start;o({mode:"actual",range:{start:v.start+O*Z,end:v.start+T*Z}})}}},W=O=>{if(n!=="actual"||v===null||p===null)return;const T=v.end-v.start;g(z2(v,v.start+R(O.clientX)*T,O.deltaY>0?1.25:.8,p))};if(A===0||p===null)return s.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const M=r===null?null:r.mode==="equal"?n==="equal"?{left:r.from/A,right:(r.to+1)/A}:null:n==="actual"?{left:N(0,r.range.start),right:N(0,r.range.end)}:null;return s.jsxs("div",{className:"overview",onContextMenu:O=>{O.preventDefault(),w.current===null&&o(null)},children:[s.jsx("div",{className:"overview-lanes",children:f.map(O=>s.jsx("div",{className:"lane-label",style:{height:Tu},children:S5(O.id)},O.id))}),s.jsxs("div",{className:"overview-track",ref:y,style:{height:f.length*(Tu+2)},onMouseDown:D,onMouseMove:P,onMouseUp:F,onMouseLeave:F,onWheel:W,children:[u.map((O,T)=>{const Z=d.get(O.lane)??0,E=N(T,O.start),C=n==="equal"?(T+1)/A:N(T,O.end);if(C<0||E>1)return null;const $=O.record,L=Math.max(0,Math.min(1,C)-Math.max(0,E)),B=n==="actual"&&O.firstTokenAt!==void 0&&O.end>O.start?(O.firstTokenAt-O.start)/(O.end-O.start):null;return s.jsx("div",{className:`bar kind-${$.kind} status-${$.status} ${O.instant&&n==="actual"?"instant":""} ${$.id===i?"selected":""}`,style:{left:`${Math.max(0,E)*100}%`,width:n==="equal"?`calc(${L*100}% - 1px)`:`max(2px, ${L*100}%)`,top:Z*(Tu+2),height:Tu,...B===null?{}:{"--ttft":`${Math.min(100,Math.max(0,B*100))}%`}},title:_5($,O.firstTokenAt),onMouseUp:H=>{S!==null&&Math.abs(S.x1-S.x0)<.005&&H.button===0&&c($)}},$.id)}),M!==null&&s.jsx("div",{className:"brush",style:{left:`${Math.max(0,M.left)*100}%`,width:`${(Math.min(1,M.right)-Math.max(0,M.left))*100}%`}}),S!==null&&s.jsx("div",{className:"brush dragging",style:{left:`${Math.min(S.x0,S.x1)*100}%`,width:`${Math.abs(S.x1-S.x0)*100}%`}})]}),s.jsx("div",{className:"overview-scale muted",children:n==="actual"&&v!==null?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ui(v.start)}),s.jsxs("span",{children:["总计 ",Ts(p.end-p.start),m!==null?" · 已缩放":""]}),s.jsx("span",{children:Ui(v.end)})]}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:[A," 条记录(等宽)"]}),s.jsxs("span",{children:["总计 ",Ts(p.end-p.start)]}),s.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function j5(e,t){if(e===null)return t;const n=Math.max(t.start,e.start),r=Math.min(t.end,e.end);return r>n?{start:n,end:r}:t}function S5(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function _5(e,t){const n=[`${Od[e.kind]} · ${e.title}`,`开始于 ${Ui(e.start)}`];return e.end===null?n.push("进行中(只显示开始标记)"):n.push(`总计 ${Ts(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&n.push(`首 token ${Ts(t-e.start)} · 解码 ${Ts(e.end-t)}`),n.join(`
234
- `)}const E5=32,C5=34,I5=60;function A5({session:e,state:t}){const n=b.useMemo(()=>E2(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[r,i]=b.useState("equal"),[o,c]=b.useState(null),[u,f]=b.useState(""),[d,p]=b.useState(new Set),[m,g]=b.useState(!0),[v,y]=b.useState(null),S=n.records.find(O=>O.id===v)??null,k=b.useMemo(()=>T5(n,{brush:o,query:u,collapsed:d,showCalls:m}),[n,o,u,d,m]),w=b.useMemo(()=>k.flatMap(O=>O.type==="record"?[O.record]:[]),[k]),A=b.useRef(null),N=iN(I5),R=N.following,D=h5({count:k.length,getScrollElement:()=>A.current,estimateSize:O=>{var T;return((T=k[O])==null?void 0:T.type)==="group"?C5:E5},getItemKey:O=>{var T;return((T=k[O])==null?void 0:T.key)??O},overscan:12});b.useLayoutEffect(()=>{R.current&&k.length>0&&D.scrollToIndex(k.length-1,{align:"end"})},[k.length,t.version,D]),b.useEffect(()=>{if(v===null)return;const O=k.findIndex(T=>T.type==="record"&&T.record.id===v);O!==-1&&D.scrollToIndex(O,{align:"auto"})},[v]);const P=O=>p(T=>{const Z=new Set(T);return Z.has(O)?Z.delete(O):Z.add(O),Z}),F=n.groups.length>0&&n.groups.every(O=>d.has(O.key)),W=O=>{if(O.key!=="ArrowDown"&&O.key!=="ArrowUp"&&O.key!=="Escape")return;if(O.preventDefault(),O.key==="Escape"){y(null);return}const T=w.findIndex(E=>E.id===v),Z=w[O.key==="ArrowDown"?Math.min(w.length-1,T+1):Math.max(0,T-1)];Z!==void 0&&y(Z.id)},M=n.totals;return s.jsxs("div",{className:"trajectory",children:[s.jsxs("div",{className:"traj-toolbar",role:"toolbar","aria-label":"轨迹工具栏",children:[s.jsxs("button",{className:`toggle ${r==="actual"?"on":""}`,onClick:()=>{i(O=>O==="equal"?"actual":"equal"),c(null)},title:r==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",r==="equal"?"等宽":"实际时间"]}),s.jsxs("button",{className:"toggle",onClick:()=>p(F?new Set:new Set(n.groups.map(O=>O.key))),children:["⊟ ",F?"展开所有轮次":"收起所有轮次"]}),s.jsxs("button",{className:`toggle ${m?"":"on"}`,onClick:()=>g(O=>!O),children:["⊟ ",m?"收起所有调用":"展开所有调用"]}),s.jsx("input",{className:"traj-search",value:u,onChange:O=>f(O.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),s.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[M.requests," 次请求 · 输入 ",vn(M.inputTokens+M.cacheReadTokens+M.cacheWriteTokens)," · 输出 ",vn(M.outputTokens)," · ",M.toolCalls," 次工具调用",M.errors>0?` · ${M.errors} 个错误`:""]})]}),s.jsx(N5,{model:n,mode:r,brush:o,selectedId:v,onBrush:c,onSelect:O=>y(O.id)}),o!==null&&s.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",w.length," 条记录 ",s.jsx("button",{className:"link-button",onClick:()=>c(null),children:"清除"})]}),s.jsxs("div",{className:"traj-main",children:[s.jsxs("div",{className:"ledger",ref:A,onScroll:N.onScroll,onWheel:N.onWheel,tabIndex:0,onKeyDown:W,role:"grid","aria-label":"轨迹事件表",children:[s.jsxs("div",{className:"ledger-head",role:"row",children:[s.jsx("span",{}),s.jsx("span",{children:"类型"}),s.jsx("span",{children:"内容"}),s.jsx("span",{className:"num",children:"输入"}),s.jsx("span",{className:"num",children:"输出"}),s.jsx("span",{className:"num",children:"思考"}),s.jsx("span",{className:"num",children:"时间"}),s.jsx("span",{children:"模型"}),s.jsx("span",{className:"num",children:"工具"})]}),t.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:t.loadingOlder,onClick:()=>void e.loadOlder(),children:t.loadingOlder?"正在加载更早的历史…":"加载更早的历史"}),k.length===0&&s.jsx("div",{className:"empty",children:t.status==="opening"?"正在加载轨迹…":u!==""?"没有匹配的记录":"还没有记录"}),s.jsx("div",{style:{height:D.getTotalSize(),position:"relative"},children:D.getVirtualItems().map(O=>{const T=k[O.index];return s.jsx("div",{className:"vrow",style:{transform:`translateY(${O.start}px)`,height:O.size},children:T.type==="group"?s.jsx($5,{row:T,onToggle:()=>P(T.group.key)}):s.jsx(M5,{row:T,selected:T.record.id===v,onSelect:()=>y(Z=>Z===T.record.id?null:T.record.id)})},O.key)})})]}),S!==null&&s.jsx(x5,{record:S,totals:n.totals,onClose:()=>y(null)},S.id)]})]})}function T5(e,t){const n=new Set;let r=e.records;if(t.brush!==null){const c=t.brush;r=c.mode==="equal"?r.slice(c.from,c.to+1):r.filter(u=>O2(u,c.range))}for(const c of L2(r,t.query))n.add(c.id);const i=t.brush!==null||t.query.trim()!=="",o=[];for(const c of e.groups){const u=c.records.filter(p=>n.has(p.id)&&(t.showCalls||p.kind!=="tool"));if(i&&u.length===0)continue;const f=t.collapsed.has(c.key);if(o.push({type:"group",key:`g:${c.key}`,group:c,collapsed:f,matches:u.length}),f)continue;let d=null;for(const p of u){const m=p.step!==null&&p.step!==d?p.step:null;p.step!==null&&(d=p.step),o.push({type:"record",key:p.id,record:p,stepStart:m})}}return o}const $5=b.memo(function({row:t,onToggle:n}){var u,f;const r=t.group,i=r.records.filter(d=>d.kind==="tool").length,o=r.end===null?null:r.end-r.start,c=g5(r);return s.jsxs("button",{className:`group-row ${r.end===null?"open":""} reason-${((u=r.reason)==null?void 0:u.kind)??"none"}`,onClick:n,"aria-expanded":!t.collapsed,children:[s.jsx("span",{className:"chevron",children:t.collapsed?"▸":"▾"}),s.jsx("span",{className:"group-title",children:m5(r)}),s.jsxs("span",{className:"muted small",children:[r.steps.length>0&&`${r.steps.length} 个步骤`,i>0&&` · ${i} 个工具调用`,o!==null&&` · ${Ts(o)}`,r.partialStart&&" · 开头在已加载范围之外"]}),c!==""&&s.jsx("span",{className:`group-reason reason-${r.end===null?"running":((f=r.reason)==null?void 0:f.kind)??"none"}`,children:c})]})}),M5=b.memo(function({row:t,selected:n,onSelect:r}){var u;const i=t.record,o=i.kind==="assistant",c=Bl(i);return s.jsxs("div",{className:`record-row kind-${i.kind} status-${i.status} ${n?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:r,role:"row","aria-selected":n,children:[s.jsx("span",{className:"gutter muted",children:t.stepStart!==null?`第 ${t.stepStart} 步`:""}),s.jsx("span",{children:s.jsx("span",{className:`kind-badge kind-${i.kind}`,children:o?`#${i.request.index}`:Od[i.kind]})}),s.jsxs("span",{className:"record-content",title:i.preview,children:[i.status==="running"&&s.jsx("span",{className:"running-dot"}),i.status==="error"&&s.jsxs("span",{className:"status-text status-error",children:[SS.error," · "]}),i.kind==="tool"?s.jsxs(s.Fragment,{children:[s.jsx("code",{className:"tool-name-inline",children:i.name})," ",s.jsx("span",{className:"muted",children:i.preview})]}):i.preview||s.jsx("span",{className:"muted",children:"(无内容)"})]}),s.jsx("span",{className:"num",children:o?vn(_S(i)):""}),s.jsx("span",{className:"num",children:o&&i.request.usage!==void 0?vn(i.request.usage.outputTokens):""}),s.jsx("span",{className:"num",children:o&&((u=i.request.usage)==null?void 0:u.reasoningTokens)!==void 0?vn(i.request.usage.reasoningTokens):""}),s.jsx("span",{className:"num",children:i.status==="running"?"…":c!==void 0&&(o||i.kind==="tool"||i.kind==="compaction"||i.kind==="attempt")?Ts(c):""}),s.jsx("span",{className:"model-cell",children:o?i.request.model??"":""}),s.jsx("span",{className:"num",children:o&&dd(i)>0?dd(i):""})]})}),R5={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:A5}]};pw();Fn(fz);Fn(R5);Fn(ZU);Fn(WU);Fn(VU);Fn(qU);Fn(GU);Fn(YU);Fn(mU);Fn(gU);Fn(Tz);Fn($z);Fn(aB);Fn(oB);Fn(TB);Fn(VB);for(const e of hz)Fn(e);const ES=uE.createRoot(document.getElementById("root"));function gp(e){const t=new U$({url:_M(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),ES.render(s.jsxs(S2,{children:[s.jsx(g2,{client:t}),s.jsx(j2,{client:t})]}))}const Fb=Im?null:aw();Im?gp(null):Fb===null?ES.render(s.jsx(b2,{onSubmit:e=>{SM(e),gp(e)}})):gp(Fb);
235
- //# sourceMappingURL=index-Baf6Mpe9.js.map