dsh-multigameassistant 2.0.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/cordis.patch.yml +178 -4
  2. package/lib/analyzer.js +135 -26
  3. package/lib/browser.js +279 -0
  4. package/lib/{chunk-XHP3SLMO.js → chunk-77ZYHRN7.js} +292 -6
  5. package/lib/{chunk-UOVFYP7C.js → chunk-EOWM56PA.js} +398 -58
  6. package/lib/chunk-FH64SAZU.js +605 -0
  7. package/lib/{chunk-IZENRXQ6.js → chunk-MEKSHT6V.js} +1797 -575
  8. package/lib/chunk-RESS7WVY.js +157 -0
  9. package/lib/{chunk-SA72K6M2.js → chunk-SHTX4AGU.js} +1 -3572
  10. package/lib/{chunk-4PNYIZVU.js → chunk-TWUATN5X.js} +13 -9
  11. package/lib/chunk-V2X4PLF5.js +3730 -0
  12. package/lib/emulator.js +5 -3
  13. package/lib/feishu.js +8 -5
  14. package/lib/game-intel.js +91 -8
  15. package/lib/gateway.js +9 -5
  16. package/lib/guard.js +5 -3
  17. package/lib/intervene.js +62 -17
  18. package/lib/low-context.js +71 -87
  19. package/lib/monitor.js +90 -10
  20. package/lib/notify.js +6 -4
  21. package/lib/orchestrator.js +97 -27
  22. package/lib/packs/maa/adg.script.yaml +119 -1
  23. package/lib/packs/maaend/adg.script.yaml +74 -4
  24. package/lib/packs/march7th/adg.script.yaml +116 -0
  25. package/lib/qqbot.js +8 -5
  26. package/lib/runner.js +18 -5
  27. package/lib/scheduler.js +4 -2
  28. package/lib/script-registry.js +203 -214
  29. package/package.json +5 -4
  30. package/skills/pipeline-planning.md +8 -5
  31. package/skills/script-analysis.md +70 -10
  32. package/skills/web-reading.md +2 -0
  33. package/web/assets/index-C-csjWiw.js +244 -0
  34. package/web/assets/index-C-csjWiw.js.map +1 -0
  35. package/web/assets/index-CjtVfcDS.css +1 -0
  36. package/web/index.html +2 -2
  37. package/lib/chunk-CCAB6XXZ.js +0 -34
  38. package/web/assets/index-BqeCz6LB.css +0 -1
  39. package/web/assets/index-CCaVm9ks.js +0 -242
  40. package/web/assets/index-CCaVm9ks.js.map +0 -1
@@ -0,0 +1,244 @@
1
+ var EC=Object.defineProperty;var B0=e=>{throw TypeError(e)};var CC=(e,t,n)=>t in e?EC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ct=(e,t,n)=>CC(e,typeof t!="symbol"?t+"":t,n),Df=(e,t,n)=>t.has(e)||B0("Cannot "+n);var ze=(e,t,n)=>(Df(e,t,"read from private field"),n?n.call(e):t.get(e)),Lt=(e,t,n)=>t.has(e)?B0("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Wt=(e,t,n,i)=>(Df(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),pt=(e,t,n)=>(Df(e,t,"access private method"),n);var H0=(e,t,n,i)=>({set _(r){Wt(e,t,r,n)},get _(){return ze(e,t,i)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const o of r)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&i(c)}).observe(document,{childList:!0,subtree:!0});function n(r){const o={};return r.integrity&&(o.integrity=r.integrity),r.referrerPolicy&&(o.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?o.credentials="include":r.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(r){if(r.ep)return;r.ep=!0;const o=n(r);fetch(r.href,o)}})();function pg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ff={exports:{}},Al={},Uf={exports:{}},gt={};/**
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 Z0;function AC(){if(Z0)return gt;Z0=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.iterator;function p(Z){return Z===null||typeof Z!="object"?null:(Z=g&&Z[g]||Z["@@iterator"],typeof Z=="function"?Z:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,k={};function w(Z,Y,X){this.props=Z,this.context=Y,this.refs=k,this.updater=X||x}w.prototype.isReactComponent={},w.prototype.setState=function(Z,Y){if(typeof Z!="object"&&typeof Z!="function"&&Z!=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,Z,Y,"setState")},w.prototype.forceUpdate=function(Z){this.updater.enqueueForceUpdate(this,Z,"forceUpdate")};function j(){}j.prototype=w.prototype;function E(Z,Y,X){this.props=Z,this.context=Y,this.refs=k,this.updater=X||x}var N=E.prototype=new j;N.constructor=E,b(N,w.prototype),N.isPureReactComponent=!0;var C=Array.isArray,L=Object.prototype.hasOwnProperty,$={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function W(Z,Y,X){var re,ee={},te=null,ne=null;if(Y!=null)for(re in Y.ref!==void 0&&(ne=Y.ref),Y.key!==void 0&&(te=""+Y.key),Y)L.call(Y,re)&&!O.hasOwnProperty(re)&&(ee[re]=Y[re]);var se=arguments.length-2;if(se===1)ee.children=X;else if(1<se){for(var oe=Array(se),de=0;de<se;de++)oe[de]=arguments[de+2];ee.children=oe}if(Z&&Z.defaultProps)for(re in se=Z.defaultProps,se)ee[re]===void 0&&(ee[re]=se[re]);return{$$typeof:e,type:Z,key:te,ref:ne,props:ee,_owner:$.current}}function B(Z,Y){return{$$typeof:e,type:Z.type,key:Y,ref:Z.ref,props:Z.props,_owner:Z._owner}}function U(Z){return typeof Z=="object"&&Z!==null&&Z.$$typeof===e}function D(Z){var Y={"=":"=0",":":"=2"};return"$"+Z.replace(/[=:]/g,function(X){return Y[X]})}var F=/\/+/g;function A(Z,Y){return typeof Z=="object"&&Z!==null&&Z.key!=null?D(""+Z.key):Y.toString(36)}function T(Z,Y,X,re,ee){var te=typeof Z;(te==="undefined"||te==="boolean")&&(Z=null);var ne=!1;if(Z===null)ne=!0;else switch(te){case"string":case"number":ne=!0;break;case"object":switch(Z.$$typeof){case e:case t:ne=!0}}if(ne)return ne=Z,ee=ee(ne),Z=re===""?"."+A(ne,0):re,C(ee)?(X="",Z!=null&&(X=Z.replace(F,"$&/")+"/"),T(ee,Y,X,"",function(de){return de})):ee!=null&&(U(ee)&&(ee=B(ee,X+(!ee.key||ne&&ne.key===ee.key?"":(""+ee.key).replace(F,"$&/")+"/")+Z)),Y.push(ee)),1;if(ne=0,re=re===""?".":re+":",C(Z))for(var se=0;se<Z.length;se++){te=Z[se];var oe=re+A(te,se);ne+=T(te,Y,X,oe,ee)}else if(oe=p(Z),typeof oe=="function")for(Z=oe.call(Z),se=0;!(te=Z.next()).done;)te=te.value,oe=re+A(te,se++),ne+=T(te,Y,X,oe,ee);else if(te==="object")throw Y=String(Z),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(Z).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return ne}function M(Z,Y,X){if(Z==null)return Z;var re=[],ee=0;return T(Z,re,"","",function(te){return Y.call(X,te,ee++)}),re}function P(Z){if(Z._status===-1){var Y=Z._result;Y=Y(),Y.then(function(X){(Z._status===0||Z._status===-1)&&(Z._status=1,Z._result=X)},function(X){(Z._status===0||Z._status===-1)&&(Z._status=2,Z._result=X)}),Z._status===-1&&(Z._status=0,Z._result=Y)}if(Z._status===1)return Z._result.default;throw Z._result}var V={current:null},z={transition:null},H={ReactCurrentDispatcher:V,ReactCurrentBatchConfig:z,ReactCurrentOwner:$};function G(){throw Error("act(...) is not supported in production builds of React.")}return gt.Children={map:M,forEach:function(Z,Y,X){M(Z,function(){Y.apply(this,arguments)},X)},count:function(Z){var Y=0;return M(Z,function(){Y++}),Y},toArray:function(Z){return M(Z,function(Y){return Y})||[]},only:function(Z){if(!U(Z))throw Error("React.Children.only expected to receive a single React element child.");return Z}},gt.Component=w,gt.Fragment=n,gt.Profiler=r,gt.PureComponent=E,gt.StrictMode=i,gt.Suspense=d,gt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,gt.act=G,gt.cloneElement=function(Z,Y,X){if(Z==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+Z+".");var re=b({},Z.props),ee=Z.key,te=Z.ref,ne=Z._owner;if(Y!=null){if(Y.ref!==void 0&&(te=Y.ref,ne=$.current),Y.key!==void 0&&(ee=""+Y.key),Z.type&&Z.type.defaultProps)var se=Z.type.defaultProps;for(oe in Y)L.call(Y,oe)&&!O.hasOwnProperty(oe)&&(re[oe]=Y[oe]===void 0&&se!==void 0?se[oe]:Y[oe])}var oe=arguments.length-2;if(oe===1)re.children=X;else if(1<oe){se=Array(oe);for(var de=0;de<oe;de++)se[de]=arguments[de+2];re.children=se}return{$$typeof:e,type:Z.type,key:ee,ref:te,props:re,_owner:ne}},gt.createContext=function(Z){return Z={$$typeof:c,_currentValue:Z,_currentValue2:Z,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},Z.Provider={$$typeof:o,_context:Z},Z.Consumer=Z},gt.createElement=W,gt.createFactory=function(Z){var Y=W.bind(null,Z);return Y.type=Z,Y},gt.createRef=function(){return{current:null}},gt.forwardRef=function(Z){return{$$typeof:u,render:Z}},gt.isValidElement=U,gt.lazy=function(Z){return{$$typeof:f,_payload:{_status:-1,_result:Z},_init:P}},gt.memo=function(Z,Y){return{$$typeof:h,type:Z,compare:Y===void 0?null:Y}},gt.startTransition=function(Z){var Y=z.transition;z.transition={};try{Z()}finally{z.transition=Y}},gt.unstable_act=G,gt.useCallback=function(Z,Y){return V.current.useCallback(Z,Y)},gt.useContext=function(Z){return V.current.useContext(Z)},gt.useDebugValue=function(){},gt.useDeferredValue=function(Z){return V.current.useDeferredValue(Z)},gt.useEffect=function(Z,Y){return V.current.useEffect(Z,Y)},gt.useId=function(){return V.current.useId()},gt.useImperativeHandle=function(Z,Y,X){return V.current.useImperativeHandle(Z,Y,X)},gt.useInsertionEffect=function(Z,Y){return V.current.useInsertionEffect(Z,Y)},gt.useLayoutEffect=function(Z,Y){return V.current.useLayoutEffect(Z,Y)},gt.useMemo=function(Z,Y){return V.current.useMemo(Z,Y)},gt.useReducer=function(Z,Y,X){return V.current.useReducer(Z,Y,X)},gt.useRef=function(Z){return V.current.useRef(Z)},gt.useState=function(Z){return V.current.useState(Z)},gt.useSyncExternalStore=function(Z,Y,X){return V.current.useSyncExternalStore(Z,Y,X)},gt.useTransition=function(){return V.current.useTransition()},gt.version="18.3.1",gt}var W0;function Ic(){return W0||(W0=1,Uf.exports=AC()),Uf.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 V0;function IC(){if(V0)return Al;V0=1;var e=Ic(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(u,d,h){var f,g={},p=null,x=null;h!==void 0&&(p=""+h),d.key!==void 0&&(p=""+d.key),d.ref!==void 0&&(x=d.ref);for(f in d)i.call(d,f)&&!o.hasOwnProperty(f)&&(g[f]=d[f]);if(u&&u.defaultProps)for(f in d=u.defaultProps,d)g[f]===void 0&&(g[f]=d[f]);return{$$typeof:t,type:u,key:p,ref:x,props:g,_owner:r.current}}return Al.Fragment=n,Al.jsx=c,Al.jsxs=c,Al}var q0;function TC(){return q0||(q0=1,Ff.exports=IC()),Ff.exports}var s=TC(),Lu={},Bf={exports:{}},ys={},Hf={exports:{}},Zf={};/**
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 G0;function $C(){return G0||(G0=1,(function(e){function t(z,H){var G=z.length;z.push(H);e:for(;0<G;){var Z=G-1>>>1,Y=z[Z];if(0<r(Y,H))z[Z]=H,z[G]=Y,G=Z;else break e}}function n(z){return z.length===0?null:z[0]}function i(z){if(z.length===0)return null;var H=z[0],G=z.pop();if(G!==H){z[0]=G;e:for(var Z=0,Y=z.length,X=Y>>>1;Z<X;){var re=2*(Z+1)-1,ee=z[re],te=re+1,ne=z[te];if(0>r(ee,G))te<Y&&0>r(ne,ee)?(z[Z]=ne,z[te]=G,Z=te):(z[Z]=ee,z[re]=G,Z=re);else if(te<Y&&0>r(ne,G))z[Z]=ne,z[te]=G,Z=te;else break e}}return H}function r(z,H){var G=z.sortIndex-H.sortIndex;return G!==0?G:z.id-H.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 d=[],h=[],f=1,g=null,p=3,x=!1,b=!1,k=!1,w=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,E=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(z){for(var H=n(h);H!==null;){if(H.callback===null)i(h);else if(H.startTime<=z)i(h),H.sortIndex=H.expirationTime,t(d,H);else break;H=n(h)}}function C(z){if(k=!1,N(z),!b)if(n(d)!==null)b=!0,P(L);else{var H=n(h);H!==null&&V(C,H.startTime-z)}}function L(z,H){b=!1,k&&(k=!1,j(W),W=-1),x=!0;var G=p;try{for(N(H),g=n(d);g!==null&&(!(g.expirationTime>H)||z&&!D());){var Z=g.callback;if(typeof Z=="function"){g.callback=null,p=g.priorityLevel;var Y=Z(g.expirationTime<=H);H=e.unstable_now(),typeof Y=="function"?g.callback=Y:g===n(d)&&i(d),N(H)}else i(d);g=n(d)}if(g!==null)var X=!0;else{var re=n(h);re!==null&&V(C,re.startTime-H),X=!1}return X}finally{g=null,p=G,x=!1}}var $=!1,O=null,W=-1,B=5,U=-1;function D(){return!(e.unstable_now()-U<B)}function F(){if(O!==null){var z=e.unstable_now();U=z;var H=!0;try{H=O(!0,z)}finally{H?A():($=!1,O=null)}}else $=!1}var A;if(typeof E=="function")A=function(){E(F)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,M=T.port2;T.port1.onmessage=F,A=function(){M.postMessage(null)}}else A=function(){w(F,0)};function P(z){O=z,$||($=!0,A())}function V(z,H){W=w(function(){z(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(z){z.callback=null},e.unstable_continueExecution=function(){b||x||(b=!0,P(L))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(z){switch(p){case 1:case 2:case 3:var H=3;break;default:H=p}var G=p;p=H;try{return z()}finally{p=G}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,H){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var G=p;p=z;try{return H()}finally{p=G}},e.unstable_scheduleCallback=function(z,H,G){var Z=e.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?Z+G:Z):G=Z,z){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=G+Y,z={id:f++,callback:H,priorityLevel:z,startTime:G,expirationTime:Y,sortIndex:-1},G>Z?(z.sortIndex=G,t(h,z),n(d)===null&&z===n(h)&&(k?(j(W),W=-1):k=!0,V(C,G-Z))):(z.sortIndex=Y,t(d,z),b||x||(b=!0,P(L))),z},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(z){var H=p;return function(){var G=p;p=H;try{return z.apply(this,arguments)}finally{p=G}}}})(Zf)),Zf}var K0;function MC(){return K0||(K0=1,Hf.exports=$C()),Hf.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 Y0;function RC(){if(Y0)return ys;Y0=1;var e=Ic(),t=MC();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,m=1;m<arguments.length;m++)l+="&args[]="+encodeURIComponent(arguments[m]);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 i=new Set,r={};function o(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(r[a]=l,a=0;a<l.length;a++)i.add(l[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},g={};function p(a){return d.call(g,a)?!0:d.call(f,a)?!1:h.test(a)?g[a]=!0:(f[a]=!0,!1)}function x(a,l,m,v){if(m!==null&&m.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return v?!1:m!==null?!m.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function b(a,l,m,v){if(l===null||typeof l>"u"||x(a,l,m,v))return!0;if(v)return!1;if(m!==null)switch(m.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 k(a,l,m,v,_,I,q){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=v,this.attributeNamespace=_,this.mustUseProperty=m,this.propertyName=a,this.type=l,this.sanitizeURL=I,this.removeEmptyString=q}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){w[a]=new k(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];w[l]=new k(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){w[a]=new k(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){w[a]=new k(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){w[a]=new k(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){w[a]=new k(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){w[a]=new k(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){w[a]=new k(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){w[a]=new k(a,5,!1,a.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function E(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(j,E);w[l]=new k(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(j,E);w[l]=new k(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(j,E);w[l]=new k(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!1,!1)}),w.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!0,!0)});function N(a,l,m,v){var _=w.hasOwnProperty(l)?w[l]:null;(_!==null?_.type!==0:v||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(b(l,m,_,v)&&(m=null),v||_===null?p(l)&&(m===null?a.removeAttribute(l):a.setAttribute(l,""+m)):_.mustUseProperty?a[_.propertyName]=m===null?_.type===3?!1:"":m:(l=_.attributeName,v=_.attributeNamespace,m===null?a.removeAttribute(l):(_=_.type,m=_===3||_===4&&m===!0?"":""+m,v?a.setAttributeNS(v,l,m):a.setAttribute(l,m))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,L=Symbol.for("react.element"),$=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),W=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),D=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),V=Symbol.for("react.offscreen"),z=Symbol.iterator;function H(a){return a===null||typeof a!="object"?null:(a=z&&a[z]||a["@@iterator"],typeof a=="function"?a:null)}var G=Object.assign,Z;function Y(a){if(Z===void 0)try{throw Error()}catch(m){var l=m.stack.trim().match(/\n( *(at )?)/);Z=l&&l[1]||""}return`
34
+ `+Z+a}var X=!1;function re(a,l){if(!a||X)return"";X=!0;var m=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(ge){var v=ge}Reflect.construct(a,[],l)}else{try{l.call()}catch(ge){v=ge}a.call(l.prototype)}else{try{throw Error()}catch(ge){v=ge}a()}}catch(ge){if(ge&&v&&typeof ge.stack=="string"){for(var _=ge.stack.split(`
35
+ `),I=v.stack.split(`
36
+ `),q=_.length-1,J=I.length-1;1<=q&&0<=J&&_[q]!==I[J];)J--;for(;1<=q&&0<=J;q--,J--)if(_[q]!==I[J]){if(q!==1||J!==1)do if(q--,J--,0>J||_[q]!==I[J]){var ae=`
37
+ `+_[q].replace(" at new "," at ");return a.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",a.displayName)),ae}while(1<=q&&0<=J);break}}}finally{X=!1,Error.prepareStackTrace=m}return(a=a?a.displayName||a.name:"")?Y(a):""}function ee(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=re(a.type,!1),a;case 11:return a=re(a.type.render,!1),a;case 1:return a=re(a.type,!0),a;default:return""}}function te(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 O:return"Fragment";case $:return"Portal";case B:return"Profiler";case W:return"StrictMode";case A:return"Suspense";case T:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case D:return(a.displayName||"Context")+".Consumer";case U:return(a._context.displayName||"Context")+".Provider";case F:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case M:return l=a.displayName||null,l!==null?l:te(a.type)||"Memo";case P:l=a._payload,a=a._init;try{return te(a(l))}catch{}}return null}function ne(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 te(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 se(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function oe(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function de(a){var l=oe(a)?"checked":"value",m=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),v=""+a[l];if(!a.hasOwnProperty(l)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var _=m.get,I=m.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return _.call(this)},set:function(q){v=""+q,I.call(this,q)}}),Object.defineProperty(a,l,{enumerable:m.enumerable}),{getValue:function(){return v},setValue:function(q){v=""+q},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function we(a){a._valueTracker||(a._valueTracker=de(a))}function Se(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var m=l.getValue(),v="";return a&&(v=oe(a)?a.checked?"true":"false":a.value),a=v,a!==m?(l.setValue(a),!0):!1}function fe(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 xe(a,l){var m=l.checked;return G({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??a._wrapperState.initialChecked})}function De(a,l){var m=l.defaultValue==null?"":l.defaultValue,v=l.checked!=null?l.checked:l.defaultChecked;m=se(l.value!=null?l.value:m),a._wrapperState={initialChecked:v,initialValue:m,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Me(a,l){l=l.checked,l!=null&&N(a,"checked",l,!1)}function Ce(a,l){Me(a,l);var m=se(l.value),v=l.type;if(m!=null)v==="number"?(m===0&&a.value===""||a.value!=m)&&(a.value=""+m):a.value!==""+m&&(a.value=""+m);else if(v==="submit"||v==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?ot(a,l.type,m):l.hasOwnProperty("defaultValue")&&ot(a,l.type,se(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function Fe(a,l,m){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var v=l.type;if(!(v!=="submit"&&v!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+a._wrapperState.initialValue,m||l===a.value||(a.value=l),a.defaultValue=l}m=a.name,m!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,m!==""&&(a.name=m)}function ot(a,l,m){(l!=="number"||fe(a.ownerDocument)!==a)&&(m==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+m&&(a.defaultValue=""+m))}var ht=Array.isArray;function Pt(a,l,m,v){if(a=a.options,l){l={};for(var _=0;_<m.length;_++)l["$"+m[_]]=!0;for(m=0;m<a.length;m++)_=l.hasOwnProperty("$"+a[m].value),a[m].selected!==_&&(a[m].selected=_),_&&v&&(a[m].defaultSelected=!0)}else{for(m=""+se(m),l=null,_=0;_<a.length;_++){if(a[_].value===m){a[_].selected=!0,v&&(a[_].defaultSelected=!0);return}l!==null||a[_].disabled||(l=a[_])}l!==null&&(l.selected=!0)}}function Ln(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return G({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function an(a,l){var m=l.value;if(m==null){if(m=l.children,l=l.defaultValue,m!=null){if(l!=null)throw Error(n(92));if(ht(m)){if(1<m.length)throw Error(n(93));m=m[0]}l=m}l==null&&(l=""),m=l}a._wrapperState={initialValue:se(m)}}function dn(a,l){var m=se(l.value),v=se(l.defaultValue);m!=null&&(m=""+m,m!==a.value&&(a.value=m),l.defaultValue==null&&a.defaultValue!==m&&(a.defaultValue=m)),v!=null&&(a.defaultValue=""+v)}function hn(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function on(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 ln(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?on(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Ut,Hn=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,m,v,_){MSApp.execUnsafeLocalFunction(function(){return a(l,m,v,_)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(Ut=Ut||document.createElement("div"),Ut.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Ut.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function wn(a,l){if(l){var m=a.firstChild;if(m&&m===a.lastChild&&m.nodeType===3){m.nodeValue=l;return}}a.textContent=l}var Ss={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},Ii=["Webkit","ms","Moz","O"];Object.keys(Ss).forEach(function(a){Ii.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),Ss[l]=Ss[a]})});function ii(a,l,m){return l==null||typeof l=="boolean"||l===""?"":m||typeof l!="number"||l===0||Ss.hasOwnProperty(a)&&Ss[a]?(""+l).trim():l+"px"}function ri(a,l){a=a.style;for(var m in l)if(l.hasOwnProperty(m)){var v=m.indexOf("--")===0,_=ii(m,l[m],v);m==="float"&&(m="cssFloat"),v?a.setProperty(m,_):a[m]=_}}var Ds=G({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 Fs(a,l){if(l){if(Ds[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 Us(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 Bs=null;function ai(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var oi=null,os=null,Qn=null;function Sn(a){if(a=ml(a)){if(typeof oi!="function")throw Error(n(280));var l=a.stateNode;l&&(l=Jc(l),oi(a.stateNode,a.type,l))}}function ie(a){os?Qn?Qn.push(a):Qn=[a]:os=a}function ye(){if(os){var a=os,l=Qn;if(Qn=os=null,Sn(a),l)for(a=0;a<l.length;a++)Sn(l[a])}}function Le(a,l){return a(l)}function tt(){}var At=!1;function Tt(a,l,m){if(At)return a(l,m);At=!0;try{return Le(a,l,m)}finally{At=!1,(os!==null||Qn!==null)&&(tt(),ye())}}function Be(a,l){var m=a.stateNode;if(m===null)return null;var v=Jc(m);if(v===null)return null;m=v[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":(v=!v.disabled)||(a=a.type,v=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!v;break e;default:a=!1}if(a)return null;if(m&&typeof m!="function")throw Error(n(231,l,typeof m));return m}var Ue=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){Ue=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{Ue=!1}function kt(a,l,m,v,_,I,q,J,ae){var ge=Array.prototype.slice.call(arguments,3);try{l.apply(m,ge)}catch(Ae){this.onError(Ae)}}var bt=!1,Zn=null,ls=!1,li=null,vr={onError:function(a){bt=!0,Zn=a}};function ci(a,l,m,v,_,I,q,J,ae){bt=!1,Zn=null,kt.apply(vr,arguments)}function yr(a,l,m,v,_,I,q,J,ae){if(ci.apply(this,arguments),bt){if(bt){var ge=Zn;bt=!1,Zn=null}else throw Error(n(198));ls||(ls=!0,li=ge)}}function Wn(a){var l=a,m=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(m=l.return),a=l.return;while(a)}return l.tag===3?m:null}function Vi(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 cs(a){if(Wn(a)!==a)throw Error(n(188))}function Ti(a){var l=a.alternate;if(!l){if(l=Wn(a),l===null)throw Error(n(188));return l!==a?null:a}for(var m=a,v=l;;){var _=m.return;if(_===null)break;var I=_.alternate;if(I===null){if(v=_.return,v!==null){m=v;continue}break}if(_.child===I.child){for(I=_.child;I;){if(I===m)return cs(_),a;if(I===v)return cs(_),l;I=I.sibling}throw Error(n(188))}if(m.return!==v.return)m=_,v=I;else{for(var q=!1,J=_.child;J;){if(J===m){q=!0,m=_,v=I;break}if(J===v){q=!0,v=_,m=I;break}J=J.sibling}if(!q){for(J=I.child;J;){if(J===m){q=!0,m=I,v=_;break}if(J===v){q=!0,v=I,m=_;break}J=J.sibling}if(!q)throw Error(n(189))}}if(m.alternate!==v)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?a:l}function br(a){return a=Ti(a),a!==null?Mt(a):null}function Mt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=Mt(a);if(l!==null)return l;a=a.sibling}return null}var _s=t.unstable_scheduleCallback,Jn=t.unstable_cancelCallback,qi=t.unstable_shouldYield,ui=t.unstable_requestPaint,Rt=t.unstable_now,kr=t.unstable_getCurrentPriorityLevel,Gi=t.unstable_ImmediatePriority,di=t.unstable_UserBlockingPriority,$i=t.unstable_NormalPriority,$e=t.unstable_LowPriority,We=t.unstable_IdlePriority,lt=null,dt=null;function It(a){if(dt&&typeof dt.onCommitFiberRoot=="function")try{dt.onCommitFiberRoot(lt,a,void 0,(a.current.flags&128)===128)}catch{}}var Ot=Math.clz32?Math.clz32:fn,Vn=Math.log,Hs=Math.LN2;function fn(a){return a>>>=0,a===0?32:31-(Vn(a)/Hs|0)|0}var _n=64,Zs=4194304;function Ws(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 us(a,l){var m=a.pendingLanes;if(m===0)return 0;var v=0,_=a.suspendedLanes,I=a.pingedLanes,q=m&268435455;if(q!==0){var J=q&~_;J!==0?v=Ws(J):(I&=q,I!==0&&(v=Ws(I)))}else q=m&~_,q!==0?v=Ws(q):I!==0&&(v=Ws(I));if(v===0)return 0;if(l!==0&&l!==v&&(l&_)===0&&(_=v&-v,I=l&-l,_>=I||_===16&&(I&4194240)!==0))return l;if((v&4)!==0&&(v|=m&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=v;0<l;)m=31-Ot(l),_=1<<m,v|=a[m],l&=~_;return v}function ia(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 Nr(a,l){for(var m=a.suspendedLanes,v=a.pingedLanes,_=a.expirationTimes,I=a.pendingLanes;0<I;){var q=31-Ot(I),J=1<<q,ae=_[q];ae===-1?((J&m)===0||(J&v)!==0)&&(_[q]=ia(J,l)):ae<=l&&(a.expiredLanes|=J),I&=~J}}function Mi(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function jr(){var a=_n;return _n<<=1,(_n&4194240)===0&&(_n=64),a}function es(a){for(var l=[],m=0;31>m;m++)l.push(a);return l}function ds(a,l,m){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-Ot(l),a[l]=m}function En(a,l){var m=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 v=a.eventTimes;for(a=a.expirationTimes;0<m;){var _=31-Ot(m),I=1<<_;l[_]=0,v[_]=-1,a[_]=-1,m&=~I}}function Vs(a,l){var m=a.entangledLanes|=l;for(a=a.entanglements;m;){var v=31-Ot(m),_=1<<v;_&l|a[v]&l&&(a[v]|=l),m&=~_}}var vt=0;function it(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var hs,zt,ft,Ki,ts,Yi=!1,hi=[],Re=null,He=null,rt=null,xt=new Map,Bt=new Map,xn=[],nl="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 ra(a,l){switch(a){case"focusin":case"focusout":Re=null;break;case"dragenter":case"dragleave":He=null;break;case"mouseover":case"mouseout":rt=null;break;case"pointerover":case"pointerout":xt.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bt.delete(l.pointerId)}}function Xi(a,l,m,v,_,I){return a===null||a.nativeEvent!==I?(a={blockedOn:l,domEventName:m,eventSystemFlags:v,nativeEvent:I,targetContainers:[_]},l!==null&&(l=ml(l),l!==null&&zt(l)),a):(a.eventSystemFlags|=v,l=a.targetContainers,_!==null&&l.indexOf(_)===-1&&l.push(_),a)}function aa(a,l,m,v,_){switch(l){case"focusin":return Re=Xi(Re,a,l,m,v,_),!0;case"dragenter":return He=Xi(He,a,l,m,v,_),!0;case"mouseover":return rt=Xi(rt,a,l,m,v,_),!0;case"pointerover":var I=_.pointerId;return xt.set(I,Xi(xt.get(I)||null,a,l,m,v,_)),!0;case"gotpointercapture":return I=_.pointerId,Bt.set(I,Xi(Bt.get(I)||null,a,l,m,v,_)),!0}return!1}function Ka(a){var l=oa(a.target);if(l!==null){var m=Wn(l);if(m!==null){if(l=m.tag,l===13){if(l=Vi(m),l!==null){a.blockedOn=l,ts(a.priority,function(){ft(m)});return}}else if(l===3&&m.stateNode.current.memoizedState.isDehydrated){a.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}a.blockedOn=null}function _e(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var m=In(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(m===null){m=a.nativeEvent;var v=new m.constructor(m.type,m);Bs=v,m.target.dispatchEvent(v),Bs=null}else return l=ml(m),l!==null&&zt(l),a.blockedOn=m,!1;l.shift()}return!0}function K(a,l,m){_e(a)&&m.delete(l)}function ce(){Yi=!1,Re!==null&&_e(Re)&&(Re=null),He!==null&&_e(He)&&(He=null),rt!==null&&_e(rt)&&(rt=null),xt.forEach(K),Bt.forEach(K)}function ke(a,l){a.blockedOn===l&&(a.blockedOn=null,Yi||(Yi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ce)))}function Ne(a){function l(_){return ke(_,a)}if(0<hi.length){ke(hi[0],a);for(var m=1;m<hi.length;m++){var v=hi[m];v.blockedOn===a&&(v.blockedOn=null)}}for(Re!==null&&ke(Re,a),He!==null&&ke(He,a),rt!==null&&ke(rt,a),xt.forEach(l),Bt.forEach(l),m=0;m<xn.length;m++)v=xn[m],v.blockedOn===a&&(v.blockedOn=null);for(;0<xn.length&&(m=xn[0],m.blockedOn===null);)Ka(m),m.blockedOn===null&&xn.shift()}var Ge=C.ReactCurrentBatchConfig,et=!0;function mt(a,l,m,v){var _=vt,I=Ge.transition;Ge.transition=null;try{vt=1,fs(a,l,m,v)}finally{vt=_,Ge.transition=I}}function mn(a,l,m,v){var _=vt,I=Ge.transition;Ge.transition=null;try{vt=4,fs(a,l,m,v)}finally{vt=_,Ge.transition=I}}function fs(a,l,m,v){if(et){var _=In(a,l,m,v);if(_===null)Ch(a,l,v,vn,m),ra(a,v);else if(aa(_,a,l,m,v))v.stopPropagation();else if(ra(a,v),l&4&&-1<nl.indexOf(a)){for(;_!==null;){var I=ml(_);if(I!==null&&hs(I),I=In(a,l,m,v),I===null&&Ch(a,l,v,vn,m),I===_)break;_=I}_!==null&&v.stopPropagation()}else Ch(a,l,v,null,m)}}var vn=null;function In(a,l,m,v){if(vn=null,a=ai(v),a=oa(a),a!==null)if(l=Wn(a),l===null)a=null;else if(m=l.tag,m===13){if(a=Vi(l),a!==null)return a;a=null}else if(m===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return vn=a,null}function Qi(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(kr()){case Gi:return 1;case di:return 4;case $i:case $e:return 16;case We:return 536870912;default:return 16}default:return 16}}var Jt=null,Ya=null,Bc=null;function Ax(){if(Bc)return Bc;var a,l=Ya,m=l.length,v,_="value"in Jt?Jt.value:Jt.textContent,I=_.length;for(a=0;a<m&&l[a]===_[a];a++);var q=m-a;for(v=1;v<=q&&l[m-v]===_[I-v];v++);return Bc=_.slice(a,1<v?1-v:void 0)}function Hc(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 Zc(){return!0}function Ix(){return!1}function Es(a){function l(m,v,_,I,q){this._reactName=m,this._targetInst=_,this.type=v,this.nativeEvent=I,this.target=q,this.currentTarget=null;for(var J in a)a.hasOwnProperty(J)&&(m=a[J],this[J]=m?m(I):I[J]);return this.isDefaultPrevented=(I.defaultPrevented!=null?I.defaultPrevented:I.returnValue===!1)?Zc:Ix,this.isPropagationStopped=Ix,this}return G(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Zc)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Zc)},persist:function(){},isPersistent:Zc}),l}var Xa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fh=Es(Xa),sl=G({},Xa,{view:0,detail:0}),e1=Es(sl),mh,ph,il,Wc=G({},sl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xh,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!==il&&(il&&a.type==="mousemove"?(mh=a.screenX-il.screenX,ph=a.screenY-il.screenY):ph=mh=0,il=a),mh)},movementY:function(a){return"movementY"in a?a.movementY:ph}}),Tx=Es(Wc),t1=G({},Wc,{dataTransfer:0}),n1=Es(t1),s1=G({},sl,{relatedTarget:0}),gh=Es(s1),i1=G({},Xa,{animationName:0,elapsedTime:0,pseudoElement:0}),r1=Es(i1),a1=G({},Xa,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),o1=Es(a1),l1=G({},Xa,{data:0}),$x=Es(l1),c1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},u1={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"},d1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function h1(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=d1[a])?!!l[a]:!1}function xh(){return h1}var f1=G({},sl,{key:function(a){if(a.key){var l=c1[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Hc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?u1[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xh,charCode:function(a){return a.type==="keypress"?Hc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Hc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),m1=Es(f1),p1=G({},Wc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Mx=Es(p1),g1=G({},sl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xh}),x1=Es(g1),v1=G({},Xa,{propertyName:0,elapsedTime:0,pseudoElement:0}),y1=Es(v1),b1=G({},Wc,{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}),k1=Es(b1),N1=[9,13,27,32],vh=u&&"CompositionEvent"in window,rl=null;u&&"documentMode"in document&&(rl=document.documentMode);var j1=u&&"TextEvent"in window&&!rl,Rx=u&&(!vh||rl&&8<rl&&11>=rl),Ox=" ",Px=!1;function zx(a,l){switch(a){case"keyup":return N1.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Lx(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Qa=!1;function w1(a,l){switch(a){case"compositionend":return Lx(l);case"keypress":return l.which!==32?null:(Px=!0,Ox);case"textInput":return a=l.data,a===Ox&&Px?null:a;default:return null}}function S1(a,l){if(Qa)return a==="compositionend"||!vh&&zx(a,l)?(a=Ax(),Bc=Ya=Jt=null,Qa=!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 Rx&&l.locale!=="ko"?null:l.data;default:return null}}var _1={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 Dx(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!_1[a.type]:l==="textarea"}function Fx(a,l,m,v){ie(v),l=Yc(l,"onChange"),0<l.length&&(m=new fh("onChange","change",null,m,v),a.push({event:m,listeners:l}))}var al=null,ol=null;function E1(a){iv(a,0)}function Vc(a){var l=so(a);if(Se(l))return a}function C1(a,l){if(a==="change")return l}var Ux=!1;if(u){var yh;if(u){var bh="oninput"in document;if(!bh){var Bx=document.createElement("div");Bx.setAttribute("oninput","return;"),bh=typeof Bx.oninput=="function"}yh=bh}else yh=!1;Ux=yh&&(!document.documentMode||9<document.documentMode)}function Hx(){al&&(al.detachEvent("onpropertychange",Zx),ol=al=null)}function Zx(a){if(a.propertyName==="value"&&Vc(ol)){var l=[];Fx(l,ol,a,ai(a)),Tt(E1,l)}}function A1(a,l,m){a==="focusin"?(Hx(),al=l,ol=m,al.attachEvent("onpropertychange",Zx)):a==="focusout"&&Hx()}function I1(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Vc(ol)}function T1(a,l){if(a==="click")return Vc(l)}function $1(a,l){if(a==="input"||a==="change")return Vc(l)}function M1(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var fi=typeof Object.is=="function"?Object.is:M1;function ll(a,l){if(fi(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var m=Object.keys(a),v=Object.keys(l);if(m.length!==v.length)return!1;for(v=0;v<m.length;v++){var _=m[v];if(!d.call(l,_)||!fi(a[_],l[_]))return!1}return!0}function Wx(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Vx(a,l){var m=Wx(a);a=0;for(var v;m;){if(m.nodeType===3){if(v=a+m.textContent.length,a<=l&&v>=l)return{node:m,offset:l-a};a=v}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=Wx(m)}}function qx(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?qx(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Gx(){for(var a=window,l=fe();l instanceof a.HTMLIFrameElement;){try{var m=typeof l.contentWindow.location.href=="string"}catch{m=!1}if(m)a=l.contentWindow;else break;l=fe(a.document)}return l}function kh(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 R1(a){var l=Gx(),m=a.focusedElem,v=a.selectionRange;if(l!==m&&m&&m.ownerDocument&&qx(m.ownerDocument.documentElement,m)){if(v!==null&&kh(m)){if(l=v.start,a=v.end,a===void 0&&(a=l),"selectionStart"in m)m.selectionStart=l,m.selectionEnd=Math.min(a,m.value.length);else if(a=(l=m.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var _=m.textContent.length,I=Math.min(v.start,_);v=v.end===void 0?I:Math.min(v.end,_),!a.extend&&I>v&&(_=v,v=I,I=_),_=Vx(m,I);var q=Vx(m,v);_&&q&&(a.rangeCount!==1||a.anchorNode!==_.node||a.anchorOffset!==_.offset||a.focusNode!==q.node||a.focusOffset!==q.offset)&&(l=l.createRange(),l.setStart(_.node,_.offset),a.removeAllRanges(),I>v?(a.addRange(l),a.extend(q.node,q.offset)):(l.setEnd(q.node,q.offset),a.addRange(l)))}}for(l=[],a=m;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<l.length;m++)a=l[m],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var O1=u&&"documentMode"in document&&11>=document.documentMode,Ja=null,Nh=null,cl=null,jh=!1;function Kx(a,l,m){var v=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;jh||Ja==null||Ja!==fe(v)||(v=Ja,"selectionStart"in v&&kh(v)?v={start:v.selectionStart,end:v.selectionEnd}:(v=(v.ownerDocument&&v.ownerDocument.defaultView||window).getSelection(),v={anchorNode:v.anchorNode,anchorOffset:v.anchorOffset,focusNode:v.focusNode,focusOffset:v.focusOffset}),cl&&ll(cl,v)||(cl=v,v=Yc(Nh,"onSelect"),0<v.length&&(l=new fh("onSelect","select",null,l,m),a.push({event:l,listeners:v}),l.target=Ja)))}function qc(a,l){var m={};return m[a.toLowerCase()]=l.toLowerCase(),m["Webkit"+a]="webkit"+l,m["Moz"+a]="moz"+l,m}var eo={animationend:qc("Animation","AnimationEnd"),animationiteration:qc("Animation","AnimationIteration"),animationstart:qc("Animation","AnimationStart"),transitionend:qc("Transition","TransitionEnd")},wh={},Yx={};u&&(Yx=document.createElement("div").style,"AnimationEvent"in window||(delete eo.animationend.animation,delete eo.animationiteration.animation,delete eo.animationstart.animation),"TransitionEvent"in window||delete eo.transitionend.transition);function Gc(a){if(wh[a])return wh[a];if(!eo[a])return a;var l=eo[a],m;for(m in l)if(l.hasOwnProperty(m)&&m in Yx)return wh[a]=l[m];return a}var Xx=Gc("animationend"),Qx=Gc("animationiteration"),Jx=Gc("animationstart"),ev=Gc("transitionend"),tv=new Map,nv="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 wr(a,l){tv.set(a,l),o(l,[a])}for(var Sh=0;Sh<nv.length;Sh++){var _h=nv[Sh],P1=_h.toLowerCase(),z1=_h[0].toUpperCase()+_h.slice(1);wr(P1,"on"+z1)}wr(Xx,"onAnimationEnd"),wr(Qx,"onAnimationIteration"),wr(Jx,"onAnimationStart"),wr("dblclick","onDoubleClick"),wr("focusin","onFocus"),wr("focusout","onBlur"),wr(ev,"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 ul="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(" "),L1=new Set("cancel close invalid load scroll toggle".split(" ").concat(ul));function sv(a,l,m){var v=a.type||"unknown-event";a.currentTarget=m,yr(v,l,void 0,a),a.currentTarget=null}function iv(a,l){l=(l&4)!==0;for(var m=0;m<a.length;m++){var v=a[m],_=v.event;v=v.listeners;e:{var I=void 0;if(l)for(var q=v.length-1;0<=q;q--){var J=v[q],ae=J.instance,ge=J.currentTarget;if(J=J.listener,ae!==I&&_.isPropagationStopped())break e;sv(_,J,ge),I=ae}else for(q=0;q<v.length;q++){if(J=v[q],ae=J.instance,ge=J.currentTarget,J=J.listener,ae!==I&&_.isPropagationStopped())break e;sv(_,J,ge),I=ae}}}if(ls)throw a=li,ls=!1,li=null,a}function Ht(a,l){var m=l[Rh];m===void 0&&(m=l[Rh]=new Set);var v=a+"__bubble";m.has(v)||(rv(l,a,2,!1),m.add(v))}function Eh(a,l,m){var v=0;l&&(v|=4),rv(m,a,v,l)}var Kc="_reactListening"+Math.random().toString(36).slice(2);function dl(a){if(!a[Kc]){a[Kc]=!0,i.forEach(function(m){m!=="selectionchange"&&(L1.has(m)||Eh(m,!1,a),Eh(m,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Kc]||(l[Kc]=!0,Eh("selectionchange",!1,l))}}function rv(a,l,m,v){switch(Qi(l)){case 1:var _=mt;break;case 4:_=mn;break;default:_=fs}m=_.bind(null,l,m,a),_=void 0,!Ue||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(_=!0),v?_!==void 0?a.addEventListener(l,m,{capture:!0,passive:_}):a.addEventListener(l,m,!0):_!==void 0?a.addEventListener(l,m,{passive:_}):a.addEventListener(l,m,!1)}function Ch(a,l,m,v,_){var I=v;if((l&1)===0&&(l&2)===0&&v!==null)e:for(;;){if(v===null)return;var q=v.tag;if(q===3||q===4){var J=v.stateNode.containerInfo;if(J===_||J.nodeType===8&&J.parentNode===_)break;if(q===4)for(q=v.return;q!==null;){var ae=q.tag;if((ae===3||ae===4)&&(ae=q.stateNode.containerInfo,ae===_||ae.nodeType===8&&ae.parentNode===_))return;q=q.return}for(;J!==null;){if(q=oa(J),q===null)return;if(ae=q.tag,ae===5||ae===6){v=I=q;continue e}J=J.parentNode}}v=v.return}Tt(function(){var ge=I,Ae=ai(m),Te=[];e:{var Ee=tv.get(a);if(Ee!==void 0){var Ze=fh,qe=a;switch(a){case"keypress":if(Hc(m)===0)break e;case"keydown":case"keyup":Ze=m1;break;case"focusin":qe="focus",Ze=gh;break;case"focusout":qe="blur",Ze=gh;break;case"beforeblur":case"afterblur":Ze=gh;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ze=Tx;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ze=n1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ze=x1;break;case Xx:case Qx:case Jx:Ze=r1;break;case ev:Ze=y1;break;case"scroll":Ze=e1;break;case"wheel":Ze=k1;break;case"copy":case"cut":case"paste":Ze=o1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ze=Mx}var Ke=(l&4)!==0,pn=!Ke&&a==="scroll",me=Ke?Ee!==null?Ee+"Capture":null:Ee;Ke=[];for(var ue=ge,pe;ue!==null;){pe=ue;var Oe=pe.stateNode;if(pe.tag===5&&Oe!==null&&(pe=Oe,me!==null&&(Oe=Be(ue,me),Oe!=null&&Ke.push(hl(ue,Oe,pe)))),pn)break;ue=ue.return}0<Ke.length&&(Ee=new Ze(Ee,qe,null,m,Ae),Te.push({event:Ee,listeners:Ke}))}}if((l&7)===0){e:{if(Ee=a==="mouseover"||a==="pointerover",Ze=a==="mouseout"||a==="pointerout",Ee&&m!==Bs&&(qe=m.relatedTarget||m.fromElement)&&(oa(qe)||qe[Ji]))break e;if((Ze||Ee)&&(Ee=Ae.window===Ae?Ae:(Ee=Ae.ownerDocument)?Ee.defaultView||Ee.parentWindow:window,Ze?(qe=m.relatedTarget||m.toElement,Ze=ge,qe=qe?oa(qe):null,qe!==null&&(pn=Wn(qe),qe!==pn||qe.tag!==5&&qe.tag!==6)&&(qe=null)):(Ze=null,qe=ge),Ze!==qe)){if(Ke=Tx,Oe="onMouseLeave",me="onMouseEnter",ue="mouse",(a==="pointerout"||a==="pointerover")&&(Ke=Mx,Oe="onPointerLeave",me="onPointerEnter",ue="pointer"),pn=Ze==null?Ee:so(Ze),pe=qe==null?Ee:so(qe),Ee=new Ke(Oe,ue+"leave",Ze,m,Ae),Ee.target=pn,Ee.relatedTarget=pe,Oe=null,oa(Ae)===ge&&(Ke=new Ke(me,ue+"enter",qe,m,Ae),Ke.target=pe,Ke.relatedTarget=pn,Oe=Ke),pn=Oe,Ze&&qe)t:{for(Ke=Ze,me=qe,ue=0,pe=Ke;pe;pe=to(pe))ue++;for(pe=0,Oe=me;Oe;Oe=to(Oe))pe++;for(;0<ue-pe;)Ke=to(Ke),ue--;for(;0<pe-ue;)me=to(me),pe--;for(;ue--;){if(Ke===me||me!==null&&Ke===me.alternate)break t;Ke=to(Ke),me=to(me)}Ke=null}else Ke=null;Ze!==null&&av(Te,Ee,Ze,Ke,!1),qe!==null&&pn!==null&&av(Te,pn,qe,Ke,!0)}}e:{if(Ee=ge?so(ge):window,Ze=Ee.nodeName&&Ee.nodeName.toLowerCase(),Ze==="select"||Ze==="input"&&Ee.type==="file")var Ye=C1;else if(Dx(Ee))if(Ux)Ye=$1;else{Ye=I1;var nt=A1}else(Ze=Ee.nodeName)&&Ze.toLowerCase()==="input"&&(Ee.type==="checkbox"||Ee.type==="radio")&&(Ye=T1);if(Ye&&(Ye=Ye(a,ge))){Fx(Te,Ye,m,Ae);break e}nt&&nt(a,Ee,ge),a==="focusout"&&(nt=Ee._wrapperState)&&nt.controlled&&Ee.type==="number"&&ot(Ee,"number",Ee.value)}switch(nt=ge?so(ge):window,a){case"focusin":(Dx(nt)||nt.contentEditable==="true")&&(Ja=nt,Nh=ge,cl=null);break;case"focusout":cl=Nh=Ja=null;break;case"mousedown":jh=!0;break;case"contextmenu":case"mouseup":case"dragend":jh=!1,Kx(Te,m,Ae);break;case"selectionchange":if(O1)break;case"keydown":case"keyup":Kx(Te,m,Ae)}var st;if(vh)e:{switch(a){case"compositionstart":var at="onCompositionStart";break e;case"compositionend":at="onCompositionEnd";break e;case"compositionupdate":at="onCompositionUpdate";break e}at=void 0}else Qa?zx(a,m)&&(at="onCompositionEnd"):a==="keydown"&&m.keyCode===229&&(at="onCompositionStart");at&&(Rx&&m.locale!=="ko"&&(Qa||at!=="onCompositionStart"?at==="onCompositionEnd"&&Qa&&(st=Ax()):(Jt=Ae,Ya="value"in Jt?Jt.value:Jt.textContent,Qa=!0)),nt=Yc(ge,at),0<nt.length&&(at=new $x(at,a,null,m,Ae),Te.push({event:at,listeners:nt}),st?at.data=st:(st=Lx(m),st!==null&&(at.data=st)))),(st=j1?w1(a,m):S1(a,m))&&(ge=Yc(ge,"onBeforeInput"),0<ge.length&&(Ae=new $x("onBeforeInput","beforeinput",null,m,Ae),Te.push({event:Ae,listeners:ge}),Ae.data=st))}iv(Te,l)})}function hl(a,l,m){return{instance:a,listener:l,currentTarget:m}}function Yc(a,l){for(var m=l+"Capture",v=[];a!==null;){var _=a,I=_.stateNode;_.tag===5&&I!==null&&(_=I,I=Be(a,m),I!=null&&v.unshift(hl(a,I,_)),I=Be(a,l),I!=null&&v.push(hl(a,I,_))),a=a.return}return v}function to(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function av(a,l,m,v,_){for(var I=l._reactName,q=[];m!==null&&m!==v;){var J=m,ae=J.alternate,ge=J.stateNode;if(ae!==null&&ae===v)break;J.tag===5&&ge!==null&&(J=ge,_?(ae=Be(m,I),ae!=null&&q.unshift(hl(m,ae,J))):_||(ae=Be(m,I),ae!=null&&q.push(hl(m,ae,J)))),m=m.return}q.length!==0&&a.push({event:l,listeners:q})}var D1=/\r\n?/g,F1=/\u0000|\uFFFD/g;function ov(a){return(typeof a=="string"?a:""+a).replace(D1,`
38
+ `).replace(F1,"")}function Xc(a,l,m){if(l=ov(l),ov(a)!==l&&m)throw Error(n(425))}function Qc(){}var Ah=null,Ih=null;function Th(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 $h=typeof setTimeout=="function"?setTimeout:void 0,U1=typeof clearTimeout=="function"?clearTimeout:void 0,lv=typeof Promise=="function"?Promise:void 0,B1=typeof queueMicrotask=="function"?queueMicrotask:typeof lv<"u"?function(a){return lv.resolve(null).then(a).catch(H1)}:$h;function H1(a){setTimeout(function(){throw a})}function Mh(a,l){var m=l,v=0;do{var _=m.nextSibling;if(a.removeChild(m),_&&_.nodeType===8)if(m=_.data,m==="/$"){if(v===0){a.removeChild(_),Ne(l);return}v--}else m!=="$"&&m!=="$?"&&m!=="$!"||v++;m=_}while(m);Ne(l)}function Sr(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 cv(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var m=a.data;if(m==="$"||m==="$!"||m==="$?"){if(l===0)return a;l--}else m==="/$"&&l++}a=a.previousSibling}return null}var no=Math.random().toString(36).slice(2),Ri="__reactFiber$"+no,fl="__reactProps$"+no,Ji="__reactContainer$"+no,Rh="__reactEvents$"+no,Z1="__reactListeners$"+no,W1="__reactHandles$"+no;function oa(a){var l=a[Ri];if(l)return l;for(var m=a.parentNode;m;){if(l=m[Ji]||m[Ri]){if(m=l.alternate,l.child!==null||m!==null&&m.child!==null)for(a=cv(a);a!==null;){if(m=a[Ri])return m;a=cv(a)}return l}a=m,m=a.parentNode}return null}function ml(a){return a=a[Ri]||a[Ji],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function so(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function Jc(a){return a[fl]||null}var Oh=[],io=-1;function _r(a){return{current:a}}function Zt(a){0>io||(a.current=Oh[io],Oh[io]=null,io--)}function Ft(a,l){io++,Oh[io]=a.current,a.current=l}var Er={},qn=_r(Er),ms=_r(!1),la=Er;function ro(a,l){var m=a.type.contextTypes;if(!m)return Er;var v=a.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===l)return v.__reactInternalMemoizedMaskedChildContext;var _={},I;for(I in m)_[I]=l[I];return v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=_),_}function ps(a){return a=a.childContextTypes,a!=null}function eu(){Zt(ms),Zt(qn)}function uv(a,l,m){if(qn.current!==Er)throw Error(n(168));Ft(qn,l),Ft(ms,m)}function dv(a,l,m){var v=a.stateNode;if(l=l.childContextTypes,typeof v.getChildContext!="function")return m;v=v.getChildContext();for(var _ in v)if(!(_ in l))throw Error(n(108,ne(a)||"Unknown",_));return G({},m,v)}function tu(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Er,la=qn.current,Ft(qn,a),Ft(ms,ms.current),!0}function hv(a,l,m){var v=a.stateNode;if(!v)throw Error(n(169));m?(a=dv(a,l,la),v.__reactInternalMemoizedMergedChildContext=a,Zt(ms),Zt(qn),Ft(qn,a)):Zt(ms),Ft(ms,m)}var er=null,nu=!1,Ph=!1;function fv(a){er===null?er=[a]:er.push(a)}function V1(a){nu=!0,fv(a)}function Cr(){if(!Ph&&er!==null){Ph=!0;var a=0,l=vt;try{var m=er;for(vt=1;a<m.length;a++){var v=m[a];do v=v(!0);while(v!==null)}er=null,nu=!1}catch(_){throw er!==null&&(er=er.slice(a+1)),_s(Gi,Cr),_}finally{vt=l,Ph=!1}}return null}var ao=[],oo=0,su=null,iu=0,qs=[],Gs=0,ca=null,tr=1,nr="";function ua(a,l){ao[oo++]=iu,ao[oo++]=su,su=a,iu=l}function mv(a,l,m){qs[Gs++]=tr,qs[Gs++]=nr,qs[Gs++]=ca,ca=a;var v=tr;a=nr;var _=32-Ot(v)-1;v&=~(1<<_),m+=1;var I=32-Ot(l)+_;if(30<I){var q=_-_%5;I=(v&(1<<q)-1).toString(32),v>>=q,_-=q,tr=1<<32-Ot(l)+_|m<<_|v,nr=I+a}else tr=1<<I|m<<_|v,nr=a}function zh(a){a.return!==null&&(ua(a,1),mv(a,1,0))}function Lh(a){for(;a===su;)su=ao[--oo],ao[oo]=null,iu=ao[--oo],ao[oo]=null;for(;a===ca;)ca=qs[--Gs],qs[Gs]=null,nr=qs[--Gs],qs[Gs]=null,tr=qs[--Gs],qs[Gs]=null}var Cs=null,As=null,Gt=!1,mi=null;function pv(a,l){var m=Qs(5,null,null,0);m.elementType="DELETED",m.stateNode=l,m.return=a,l=a.deletions,l===null?(a.deletions=[m],a.flags|=16):l.push(m)}function gv(a,l){switch(a.tag){case 5:var m=a.type;return l=l.nodeType!==1||m.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,Cs=a,As=Sr(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,Cs=a,As=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(m=ca!==null?{id:tr,overflow:nr}:null,a.memoizedState={dehydrated:l,treeContext:m,retryLane:1073741824},m=Qs(18,null,null,0),m.stateNode=l,m.return=a,a.child=m,Cs=a,As=null,!0):!1;default:return!1}}function Dh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Fh(a){if(Gt){var l=As;if(l){var m=l;if(!gv(a,l)){if(Dh(a))throw Error(n(418));l=Sr(m.nextSibling);var v=Cs;l&&gv(a,l)?pv(v,m):(a.flags=a.flags&-4097|2,Gt=!1,Cs=a)}}else{if(Dh(a))throw Error(n(418));a.flags=a.flags&-4097|2,Gt=!1,Cs=a}}}function xv(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Cs=a}function ru(a){if(a!==Cs)return!1;if(!Gt)return xv(a),Gt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!Th(a.type,a.memoizedProps)),l&&(l=As)){if(Dh(a))throw vv(),Error(n(418));for(;l;)pv(a,l),l=Sr(l.nextSibling)}if(xv(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 m=a.data;if(m==="/$"){if(l===0){As=Sr(a.nextSibling);break e}l--}else m!=="$"&&m!=="$!"&&m!=="$?"||l++}a=a.nextSibling}As=null}}else As=Cs?Sr(a.stateNode.nextSibling):null;return!0}function vv(){for(var a=As;a;)a=Sr(a.nextSibling)}function lo(){As=Cs=null,Gt=!1}function Uh(a){mi===null?mi=[a]:mi.push(a)}var q1=C.ReactCurrentBatchConfig;function pl(a,l,m){if(a=m.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var v=m.stateNode}if(!v)throw Error(n(147,a));var _=v,I=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===I?l.ref:(l=function(q){var J=_.refs;q===null?delete J[I]:J[I]=q},l._stringRef=I,l)}if(typeof a!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,a))}return a}function au(a,l){throw a=Object.prototype.toString.call(l),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function yv(a){var l=a._init;return l(a._payload)}function bv(a){function l(me,ue){if(a){var pe=me.deletions;pe===null?(me.deletions=[ue],me.flags|=16):pe.push(ue)}}function m(me,ue){if(!a)return null;for(;ue!==null;)l(me,ue),ue=ue.sibling;return null}function v(me,ue){for(me=new Map;ue!==null;)ue.key!==null?me.set(ue.key,ue):me.set(ue.index,ue),ue=ue.sibling;return me}function _(me,ue){return me=Pr(me,ue),me.index=0,me.sibling=null,me}function I(me,ue,pe){return me.index=pe,a?(pe=me.alternate,pe!==null?(pe=pe.index,pe<ue?(me.flags|=2,ue):pe):(me.flags|=2,ue)):(me.flags|=1048576,ue)}function q(me){return a&&me.alternate===null&&(me.flags|=2),me}function J(me,ue,pe,Oe){return ue===null||ue.tag!==6?(ue=Mf(pe,me.mode,Oe),ue.return=me,ue):(ue=_(ue,pe),ue.return=me,ue)}function ae(me,ue,pe,Oe){var Ye=pe.type;return Ye===O?Ae(me,ue,pe.props.children,Oe,pe.key):ue!==null&&(ue.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===P&&yv(Ye)===ue.type)?(Oe=_(ue,pe.props),Oe.ref=pl(me,ue,pe),Oe.return=me,Oe):(Oe=Iu(pe.type,pe.key,pe.props,null,me.mode,Oe),Oe.ref=pl(me,ue,pe),Oe.return=me,Oe)}function ge(me,ue,pe,Oe){return ue===null||ue.tag!==4||ue.stateNode.containerInfo!==pe.containerInfo||ue.stateNode.implementation!==pe.implementation?(ue=Rf(pe,me.mode,Oe),ue.return=me,ue):(ue=_(ue,pe.children||[]),ue.return=me,ue)}function Ae(me,ue,pe,Oe,Ye){return ue===null||ue.tag!==7?(ue=va(pe,me.mode,Oe,Ye),ue.return=me,ue):(ue=_(ue,pe),ue.return=me,ue)}function Te(me,ue,pe){if(typeof ue=="string"&&ue!==""||typeof ue=="number")return ue=Mf(""+ue,me.mode,pe),ue.return=me,ue;if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case L:return pe=Iu(ue.type,ue.key,ue.props,null,me.mode,pe),pe.ref=pl(me,null,ue),pe.return=me,pe;case $:return ue=Rf(ue,me.mode,pe),ue.return=me,ue;case P:var Oe=ue._init;return Te(me,Oe(ue._payload),pe)}if(ht(ue)||H(ue))return ue=va(ue,me.mode,pe,null),ue.return=me,ue;au(me,ue)}return null}function Ee(me,ue,pe,Oe){var Ye=ue!==null?ue.key:null;if(typeof pe=="string"&&pe!==""||typeof pe=="number")return Ye!==null?null:J(me,ue,""+pe,Oe);if(typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case L:return pe.key===Ye?ae(me,ue,pe,Oe):null;case $:return pe.key===Ye?ge(me,ue,pe,Oe):null;case P:return Ye=pe._init,Ee(me,ue,Ye(pe._payload),Oe)}if(ht(pe)||H(pe))return Ye!==null?null:Ae(me,ue,pe,Oe,null);au(me,pe)}return null}function Ze(me,ue,pe,Oe,Ye){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return me=me.get(pe)||null,J(ue,me,""+Oe,Ye);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case L:return me=me.get(Oe.key===null?pe:Oe.key)||null,ae(ue,me,Oe,Ye);case $:return me=me.get(Oe.key===null?pe:Oe.key)||null,ge(ue,me,Oe,Ye);case P:var nt=Oe._init;return Ze(me,ue,pe,nt(Oe._payload),Ye)}if(ht(Oe)||H(Oe))return me=me.get(pe)||null,Ae(ue,me,Oe,Ye,null);au(ue,Oe)}return null}function qe(me,ue,pe,Oe){for(var Ye=null,nt=null,st=ue,at=ue=0,Mn=null;st!==null&&at<pe.length;at++){st.index>at?(Mn=st,st=null):Mn=st.sibling;var _t=Ee(me,st,pe[at],Oe);if(_t===null){st===null&&(st=Mn);break}a&&st&&_t.alternate===null&&l(me,st),ue=I(_t,ue,at),nt===null?Ye=_t:nt.sibling=_t,nt=_t,st=Mn}if(at===pe.length)return m(me,st),Gt&&ua(me,at),Ye;if(st===null){for(;at<pe.length;at++)st=Te(me,pe[at],Oe),st!==null&&(ue=I(st,ue,at),nt===null?Ye=st:nt.sibling=st,nt=st);return Gt&&ua(me,at),Ye}for(st=v(me,st);at<pe.length;at++)Mn=Ze(st,me,at,pe[at],Oe),Mn!==null&&(a&&Mn.alternate!==null&&st.delete(Mn.key===null?at:Mn.key),ue=I(Mn,ue,at),nt===null?Ye=Mn:nt.sibling=Mn,nt=Mn);return a&&st.forEach(function(zr){return l(me,zr)}),Gt&&ua(me,at),Ye}function Ke(me,ue,pe,Oe){var Ye=H(pe);if(typeof Ye!="function")throw Error(n(150));if(pe=Ye.call(pe),pe==null)throw Error(n(151));for(var nt=Ye=null,st=ue,at=ue=0,Mn=null,_t=pe.next();st!==null&&!_t.done;at++,_t=pe.next()){st.index>at?(Mn=st,st=null):Mn=st.sibling;var zr=Ee(me,st,_t.value,Oe);if(zr===null){st===null&&(st=Mn);break}a&&st&&zr.alternate===null&&l(me,st),ue=I(zr,ue,at),nt===null?Ye=zr:nt.sibling=zr,nt=zr,st=Mn}if(_t.done)return m(me,st),Gt&&ua(me,at),Ye;if(st===null){for(;!_t.done;at++,_t=pe.next())_t=Te(me,_t.value,Oe),_t!==null&&(ue=I(_t,ue,at),nt===null?Ye=_t:nt.sibling=_t,nt=_t);return Gt&&ua(me,at),Ye}for(st=v(me,st);!_t.done;at++,_t=pe.next())_t=Ze(st,me,at,_t.value,Oe),_t!==null&&(a&&_t.alternate!==null&&st.delete(_t.key===null?at:_t.key),ue=I(_t,ue,at),nt===null?Ye=_t:nt.sibling=_t,nt=_t);return a&&st.forEach(function(_C){return l(me,_C)}),Gt&&ua(me,at),Ye}function pn(me,ue,pe,Oe){if(typeof pe=="object"&&pe!==null&&pe.type===O&&pe.key===null&&(pe=pe.props.children),typeof pe=="object"&&pe!==null){switch(pe.$$typeof){case L:e:{for(var Ye=pe.key,nt=ue;nt!==null;){if(nt.key===Ye){if(Ye=pe.type,Ye===O){if(nt.tag===7){m(me,nt.sibling),ue=_(nt,pe.props.children),ue.return=me,me=ue;break e}}else if(nt.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===P&&yv(Ye)===nt.type){m(me,nt.sibling),ue=_(nt,pe.props),ue.ref=pl(me,nt,pe),ue.return=me,me=ue;break e}m(me,nt);break}else l(me,nt);nt=nt.sibling}pe.type===O?(ue=va(pe.props.children,me.mode,Oe,pe.key),ue.return=me,me=ue):(Oe=Iu(pe.type,pe.key,pe.props,null,me.mode,Oe),Oe.ref=pl(me,ue,pe),Oe.return=me,me=Oe)}return q(me);case $:e:{for(nt=pe.key;ue!==null;){if(ue.key===nt)if(ue.tag===4&&ue.stateNode.containerInfo===pe.containerInfo&&ue.stateNode.implementation===pe.implementation){m(me,ue.sibling),ue=_(ue,pe.children||[]),ue.return=me,me=ue;break e}else{m(me,ue);break}else l(me,ue);ue=ue.sibling}ue=Rf(pe,me.mode,Oe),ue.return=me,me=ue}return q(me);case P:return nt=pe._init,pn(me,ue,nt(pe._payload),Oe)}if(ht(pe))return qe(me,ue,pe,Oe);if(H(pe))return Ke(me,ue,pe,Oe);au(me,pe)}return typeof pe=="string"&&pe!==""||typeof pe=="number"?(pe=""+pe,ue!==null&&ue.tag===6?(m(me,ue.sibling),ue=_(ue,pe),ue.return=me,me=ue):(m(me,ue),ue=Mf(pe,me.mode,Oe),ue.return=me,me=ue),q(me)):m(me,ue)}return pn}var co=bv(!0),kv=bv(!1),ou=_r(null),lu=null,uo=null,Bh=null;function Hh(){Bh=uo=lu=null}function Zh(a){var l=ou.current;Zt(ou),a._currentValue=l}function Wh(a,l,m){for(;a!==null;){var v=a.alternate;if((a.childLanes&l)!==l?(a.childLanes|=l,v!==null&&(v.childLanes|=l)):v!==null&&(v.childLanes&l)!==l&&(v.childLanes|=l),a===m)break;a=a.return}}function ho(a,l){lu=a,Bh=uo=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(gs=!0),a.firstContext=null)}function Ks(a){var l=a._currentValue;if(Bh!==a)if(a={context:a,memoizedValue:l,next:null},uo===null){if(lu===null)throw Error(n(308));uo=a,lu.dependencies={lanes:0,firstContext:a}}else uo=uo.next=a;return l}var da=null;function Vh(a){da===null?da=[a]:da.push(a)}function Nv(a,l,m,v){var _=l.interleaved;return _===null?(m.next=m,Vh(l)):(m.next=_.next,_.next=m),l.interleaved=m,sr(a,v)}function sr(a,l){a.lanes|=l;var m=a.alternate;for(m!==null&&(m.lanes|=l),m=a,a=a.return;a!==null;)a.childLanes|=l,m=a.alternate,m!==null&&(m.childLanes|=l),m=a,a=a.return;return m.tag===3?m.stateNode:null}var Ar=!1;function qh(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function jv(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 ir(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function Ir(a,l,m){var v=a.updateQueue;if(v===null)return null;if(v=v.shared,(Nt&2)!==0){var _=v.pending;return _===null?l.next=l:(l.next=_.next,_.next=l),v.pending=l,sr(a,m)}return _=v.interleaved,_===null?(l.next=l,Vh(v)):(l.next=_.next,_.next=l),v.interleaved=l,sr(a,m)}function cu(a,l,m){if(l=l.updateQueue,l!==null&&(l=l.shared,(m&4194240)!==0)){var v=l.lanes;v&=a.pendingLanes,m|=v,l.lanes=m,Vs(a,m)}}function wv(a,l){var m=a.updateQueue,v=a.alternate;if(v!==null&&(v=v.updateQueue,m===v)){var _=null,I=null;if(m=m.firstBaseUpdate,m!==null){do{var q={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};I===null?_=I=q:I=I.next=q,m=m.next}while(m!==null);I===null?_=I=l:I=I.next=l}else _=I=l;m={baseState:v.baseState,firstBaseUpdate:_,lastBaseUpdate:I,shared:v.shared,effects:v.effects},a.updateQueue=m;return}a=m.lastBaseUpdate,a===null?m.firstBaseUpdate=l:a.next=l,m.lastBaseUpdate=l}function uu(a,l,m,v){var _=a.updateQueue;Ar=!1;var I=_.firstBaseUpdate,q=_.lastBaseUpdate,J=_.shared.pending;if(J!==null){_.shared.pending=null;var ae=J,ge=ae.next;ae.next=null,q===null?I=ge:q.next=ge,q=ae;var Ae=a.alternate;Ae!==null&&(Ae=Ae.updateQueue,J=Ae.lastBaseUpdate,J!==q&&(J===null?Ae.firstBaseUpdate=ge:J.next=ge,Ae.lastBaseUpdate=ae))}if(I!==null){var Te=_.baseState;q=0,Ae=ge=ae=null,J=I;do{var Ee=J.lane,Ze=J.eventTime;if((v&Ee)===Ee){Ae!==null&&(Ae=Ae.next={eventTime:Ze,lane:0,tag:J.tag,payload:J.payload,callback:J.callback,next:null});e:{var qe=a,Ke=J;switch(Ee=l,Ze=m,Ke.tag){case 1:if(qe=Ke.payload,typeof qe=="function"){Te=qe.call(Ze,Te,Ee);break e}Te=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Ke.payload,Ee=typeof qe=="function"?qe.call(Ze,Te,Ee):qe,Ee==null)break e;Te=G({},Te,Ee);break e;case 2:Ar=!0}}J.callback!==null&&J.lane!==0&&(a.flags|=64,Ee=_.effects,Ee===null?_.effects=[J]:Ee.push(J))}else Ze={eventTime:Ze,lane:Ee,tag:J.tag,payload:J.payload,callback:J.callback,next:null},Ae===null?(ge=Ae=Ze,ae=Te):Ae=Ae.next=Ze,q|=Ee;if(J=J.next,J===null){if(J=_.shared.pending,J===null)break;Ee=J,J=Ee.next,Ee.next=null,_.lastBaseUpdate=Ee,_.shared.pending=null}}while(!0);if(Ae===null&&(ae=Te),_.baseState=ae,_.firstBaseUpdate=ge,_.lastBaseUpdate=Ae,l=_.shared.interleaved,l!==null){_=l;do q|=_.lane,_=_.next;while(_!==l)}else I===null&&(_.shared.lanes=0);ma|=q,a.lanes=q,a.memoizedState=Te}}function Sv(a,l,m){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var v=a[l],_=v.callback;if(_!==null){if(v.callback=null,v=m,typeof _!="function")throw Error(n(191,_));_.call(v)}}}var gl={},Oi=_r(gl),xl=_r(gl),vl=_r(gl);function ha(a){if(a===gl)throw Error(n(174));return a}function Gh(a,l){switch(Ft(vl,l),Ft(xl,a),Ft(Oi,gl),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:ln(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=ln(l,a)}Zt(Oi),Ft(Oi,l)}function fo(){Zt(Oi),Zt(xl),Zt(vl)}function _v(a){ha(vl.current);var l=ha(Oi.current),m=ln(l,a.type);l!==m&&(Ft(xl,a),Ft(Oi,m))}function Kh(a){xl.current===a&&(Zt(Oi),Zt(xl))}var en=_r(0);function du(a){for(var l=a;l!==null;){if(l.tag===13){var m=l.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.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 Yh=[];function Xh(){for(var a=0;a<Yh.length;a++)Yh[a]._workInProgressVersionPrimary=null;Yh.length=0}var hu=C.ReactCurrentDispatcher,Qh=C.ReactCurrentBatchConfig,fa=0,tn=null,Cn=null,Tn=null,fu=!1,yl=!1,bl=0,G1=0;function Gn(){throw Error(n(321))}function Jh(a,l){if(l===null)return!1;for(var m=0;m<l.length&&m<a.length;m++)if(!fi(a[m],l[m]))return!1;return!0}function ef(a,l,m,v,_,I){if(fa=I,tn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,hu.current=a===null||a.memoizedState===null?Q1:J1,a=m(v,_),yl){I=0;do{if(yl=!1,bl=0,25<=I)throw Error(n(301));I+=1,Tn=Cn=null,l.updateQueue=null,hu.current=eC,a=m(v,_)}while(yl)}if(hu.current=gu,l=Cn!==null&&Cn.next!==null,fa=0,Tn=Cn=tn=null,fu=!1,l)throw Error(n(300));return a}function tf(){var a=bl!==0;return bl=0,a}function Pi(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tn===null?tn.memoizedState=Tn=a:Tn=Tn.next=a,Tn}function Ys(){if(Cn===null){var a=tn.alternate;a=a!==null?a.memoizedState:null}else a=Cn.next;var l=Tn===null?tn.memoizedState:Tn.next;if(l!==null)Tn=l,Cn=a;else{if(a===null)throw Error(n(310));Cn=a,a={memoizedState:Cn.memoizedState,baseState:Cn.baseState,baseQueue:Cn.baseQueue,queue:Cn.queue,next:null},Tn===null?tn.memoizedState=Tn=a:Tn=Tn.next=a}return Tn}function kl(a,l){return typeof l=="function"?l(a):l}function nf(a){var l=Ys(),m=l.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=a;var v=Cn,_=v.baseQueue,I=m.pending;if(I!==null){if(_!==null){var q=_.next;_.next=I.next,I.next=q}v.baseQueue=_=I,m.pending=null}if(_!==null){I=_.next,v=v.baseState;var J=q=null,ae=null,ge=I;do{var Ae=ge.lane;if((fa&Ae)===Ae)ae!==null&&(ae=ae.next={lane:0,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null}),v=ge.hasEagerState?ge.eagerState:a(v,ge.action);else{var Te={lane:Ae,action:ge.action,hasEagerState:ge.hasEagerState,eagerState:ge.eagerState,next:null};ae===null?(J=ae=Te,q=v):ae=ae.next=Te,tn.lanes|=Ae,ma|=Ae}ge=ge.next}while(ge!==null&&ge!==I);ae===null?q=v:ae.next=J,fi(v,l.memoizedState)||(gs=!0),l.memoizedState=v,l.baseState=q,l.baseQueue=ae,m.lastRenderedState=v}if(a=m.interleaved,a!==null){_=a;do I=_.lane,tn.lanes|=I,ma|=I,_=_.next;while(_!==a)}else _===null&&(m.lanes=0);return[l.memoizedState,m.dispatch]}function sf(a){var l=Ys(),m=l.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=a;var v=m.dispatch,_=m.pending,I=l.memoizedState;if(_!==null){m.pending=null;var q=_=_.next;do I=a(I,q.action),q=q.next;while(q!==_);fi(I,l.memoizedState)||(gs=!0),l.memoizedState=I,l.baseQueue===null&&(l.baseState=I),m.lastRenderedState=I}return[I,v]}function Ev(){}function Cv(a,l){var m=tn,v=Ys(),_=l(),I=!fi(v.memoizedState,_);if(I&&(v.memoizedState=_,gs=!0),v=v.queue,rf(Tv.bind(null,m,v,a),[a]),v.getSnapshot!==l||I||Tn!==null&&Tn.memoizedState.tag&1){if(m.flags|=2048,Nl(9,Iv.bind(null,m,v,_,l),void 0,null),$n===null)throw Error(n(349));(fa&30)!==0||Av(m,l,_)}return _}function Av(a,l,m){a.flags|=16384,a={getSnapshot:l,value:m},l=tn.updateQueue,l===null?(l={lastEffect:null,stores:null},tn.updateQueue=l,l.stores=[a]):(m=l.stores,m===null?l.stores=[a]:m.push(a))}function Iv(a,l,m,v){l.value=m,l.getSnapshot=v,$v(l)&&Mv(a)}function Tv(a,l,m){return m(function(){$v(l)&&Mv(a)})}function $v(a){var l=a.getSnapshot;a=a.value;try{var m=l();return!fi(a,m)}catch{return!0}}function Mv(a){var l=sr(a,1);l!==null&&vi(l,a,1,-1)}function Rv(a){var l=Pi();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:kl,lastRenderedState:a},l.queue=a,a=a.dispatch=X1.bind(null,tn,a),[l.memoizedState,a]}function Nl(a,l,m,v){return a={tag:a,create:l,destroy:m,deps:v,next:null},l=tn.updateQueue,l===null?(l={lastEffect:null,stores:null},tn.updateQueue=l,l.lastEffect=a.next=a):(m=l.lastEffect,m===null?l.lastEffect=a.next=a:(v=m.next,m.next=a,a.next=v,l.lastEffect=a)),a}function Ov(){return Ys().memoizedState}function mu(a,l,m,v){var _=Pi();tn.flags|=a,_.memoizedState=Nl(1|l,m,void 0,v===void 0?null:v)}function pu(a,l,m,v){var _=Ys();v=v===void 0?null:v;var I=void 0;if(Cn!==null){var q=Cn.memoizedState;if(I=q.destroy,v!==null&&Jh(v,q.deps)){_.memoizedState=Nl(l,m,I,v);return}}tn.flags|=a,_.memoizedState=Nl(1|l,m,I,v)}function Pv(a,l){return mu(8390656,8,a,l)}function rf(a,l){return pu(2048,8,a,l)}function zv(a,l){return pu(4,2,a,l)}function Lv(a,l){return pu(4,4,a,l)}function Dv(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 Fv(a,l,m){return m=m!=null?m.concat([a]):null,pu(4,4,Dv.bind(null,l,a),m)}function af(){}function Uv(a,l){var m=Ys();l=l===void 0?null:l;var v=m.memoizedState;return v!==null&&l!==null&&Jh(l,v[1])?v[0]:(m.memoizedState=[a,l],a)}function Bv(a,l){var m=Ys();l=l===void 0?null:l;var v=m.memoizedState;return v!==null&&l!==null&&Jh(l,v[1])?v[0]:(a=a(),m.memoizedState=[a,l],a)}function Hv(a,l,m){return(fa&21)===0?(a.baseState&&(a.baseState=!1,gs=!0),a.memoizedState=m):(fi(m,l)||(m=jr(),tn.lanes|=m,ma|=m,a.baseState=!0),l)}function K1(a,l){var m=vt;vt=m!==0&&4>m?m:4,a(!0);var v=Qh.transition;Qh.transition={};try{a(!1),l()}finally{vt=m,Qh.transition=v}}function Zv(){return Ys().memoizedState}function Y1(a,l,m){var v=Rr(a);if(m={lane:v,action:m,hasEagerState:!1,eagerState:null,next:null},Wv(a))Vv(l,m);else if(m=Nv(a,l,m,v),m!==null){var _=ss();vi(m,a,v,_),qv(m,l,v)}}function X1(a,l,m){var v=Rr(a),_={lane:v,action:m,hasEagerState:!1,eagerState:null,next:null};if(Wv(a))Vv(l,_);else{var I=a.alternate;if(a.lanes===0&&(I===null||I.lanes===0)&&(I=l.lastRenderedReducer,I!==null))try{var q=l.lastRenderedState,J=I(q,m);if(_.hasEagerState=!0,_.eagerState=J,fi(J,q)){var ae=l.interleaved;ae===null?(_.next=_,Vh(l)):(_.next=ae.next,ae.next=_),l.interleaved=_;return}}catch{}finally{}m=Nv(a,l,_,v),m!==null&&(_=ss(),vi(m,a,v,_),qv(m,l,v))}}function Wv(a){var l=a.alternate;return a===tn||l!==null&&l===tn}function Vv(a,l){yl=fu=!0;var m=a.pending;m===null?l.next=l:(l.next=m.next,m.next=l),a.pending=l}function qv(a,l,m){if((m&4194240)!==0){var v=l.lanes;v&=a.pendingLanes,m|=v,l.lanes=m,Vs(a,m)}}var gu={readContext:Ks,useCallback:Gn,useContext:Gn,useEffect:Gn,useImperativeHandle:Gn,useInsertionEffect:Gn,useLayoutEffect:Gn,useMemo:Gn,useReducer:Gn,useRef:Gn,useState:Gn,useDebugValue:Gn,useDeferredValue:Gn,useTransition:Gn,useMutableSource:Gn,useSyncExternalStore:Gn,useId:Gn,unstable_isNewReconciler:!1},Q1={readContext:Ks,useCallback:function(a,l){return Pi().memoizedState=[a,l===void 0?null:l],a},useContext:Ks,useEffect:Pv,useImperativeHandle:function(a,l,m){return m=m!=null?m.concat([a]):null,mu(4194308,4,Dv.bind(null,l,a),m)},useLayoutEffect:function(a,l){return mu(4194308,4,a,l)},useInsertionEffect:function(a,l){return mu(4,2,a,l)},useMemo:function(a,l){var m=Pi();return l=l===void 0?null:l,a=a(),m.memoizedState=[a,l],a},useReducer:function(a,l,m){var v=Pi();return l=m!==void 0?m(l):l,v.memoizedState=v.baseState=l,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:l},v.queue=a,a=a.dispatch=Y1.bind(null,tn,a),[v.memoizedState,a]},useRef:function(a){var l=Pi();return a={current:a},l.memoizedState=a},useState:Rv,useDebugValue:af,useDeferredValue:function(a){return Pi().memoizedState=a},useTransition:function(){var a=Rv(!1),l=a[0];return a=K1.bind(null,a[1]),Pi().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,m){var v=tn,_=Pi();if(Gt){if(m===void 0)throw Error(n(407));m=m()}else{if(m=l(),$n===null)throw Error(n(349));(fa&30)!==0||Av(v,l,m)}_.memoizedState=m;var I={value:m,getSnapshot:l};return _.queue=I,Pv(Tv.bind(null,v,I,a),[a]),v.flags|=2048,Nl(9,Iv.bind(null,v,I,m,l),void 0,null),m},useId:function(){var a=Pi(),l=$n.identifierPrefix;if(Gt){var m=nr,v=tr;m=(v&~(1<<32-Ot(v)-1)).toString(32)+m,l=":"+l+"R"+m,m=bl++,0<m&&(l+="H"+m.toString(32)),l+=":"}else m=G1++,l=":"+l+"r"+m.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},J1={readContext:Ks,useCallback:Uv,useContext:Ks,useEffect:rf,useImperativeHandle:Fv,useInsertionEffect:zv,useLayoutEffect:Lv,useMemo:Bv,useReducer:nf,useRef:Ov,useState:function(){return nf(kl)},useDebugValue:af,useDeferredValue:function(a){var l=Ys();return Hv(l,Cn.memoizedState,a)},useTransition:function(){var a=nf(kl)[0],l=Ys().memoizedState;return[a,l]},useMutableSource:Ev,useSyncExternalStore:Cv,useId:Zv,unstable_isNewReconciler:!1},eC={readContext:Ks,useCallback:Uv,useContext:Ks,useEffect:rf,useImperativeHandle:Fv,useInsertionEffect:zv,useLayoutEffect:Lv,useMemo:Bv,useReducer:sf,useRef:Ov,useState:function(){return sf(kl)},useDebugValue:af,useDeferredValue:function(a){var l=Ys();return Cn===null?l.memoizedState=a:Hv(l,Cn.memoizedState,a)},useTransition:function(){var a=sf(kl)[0],l=Ys().memoizedState;return[a,l]},useMutableSource:Ev,useSyncExternalStore:Cv,useId:Zv,unstable_isNewReconciler:!1};function pi(a,l){if(a&&a.defaultProps){l=G({},l),a=a.defaultProps;for(var m in a)l[m]===void 0&&(l[m]=a[m]);return l}return l}function of(a,l,m,v){l=a.memoizedState,m=m(v,l),m=m==null?l:G({},l,m),a.memoizedState=m,a.lanes===0&&(a.updateQueue.baseState=m)}var xu={isMounted:function(a){return(a=a._reactInternals)?Wn(a)===a:!1},enqueueSetState:function(a,l,m){a=a._reactInternals;var v=ss(),_=Rr(a),I=ir(v,_);I.payload=l,m!=null&&(I.callback=m),l=Ir(a,I,_),l!==null&&(vi(l,a,_,v),cu(l,a,_))},enqueueReplaceState:function(a,l,m){a=a._reactInternals;var v=ss(),_=Rr(a),I=ir(v,_);I.tag=1,I.payload=l,m!=null&&(I.callback=m),l=Ir(a,I,_),l!==null&&(vi(l,a,_,v),cu(l,a,_))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var m=ss(),v=Rr(a),_=ir(m,v);_.tag=2,l!=null&&(_.callback=l),l=Ir(a,_,v),l!==null&&(vi(l,a,v,m),cu(l,a,v))}};function Gv(a,l,m,v,_,I,q){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(v,I,q):l.prototype&&l.prototype.isPureReactComponent?!ll(m,v)||!ll(_,I):!0}function Kv(a,l,m){var v=!1,_=Er,I=l.contextType;return typeof I=="object"&&I!==null?I=Ks(I):(_=ps(l)?la:qn.current,v=l.contextTypes,I=(v=v!=null)?ro(a,_):Er),l=new l(m,I),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=xu,a.stateNode=l,l._reactInternals=a,v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=_,a.__reactInternalMemoizedMaskedChildContext=I),l}function Yv(a,l,m,v){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(m,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(m,v),l.state!==a&&xu.enqueueReplaceState(l,l.state,null)}function lf(a,l,m,v){var _=a.stateNode;_.props=m,_.state=a.memoizedState,_.refs={},qh(a);var I=l.contextType;typeof I=="object"&&I!==null?_.context=Ks(I):(I=ps(l)?la:qn.current,_.context=ro(a,I)),_.state=a.memoizedState,I=l.getDerivedStateFromProps,typeof I=="function"&&(of(a,l,I,m),_.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(l=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),l!==_.state&&xu.enqueueReplaceState(_,_.state,null),uu(a,m,_,v),_.state=a.memoizedState),typeof _.componentDidMount=="function"&&(a.flags|=4194308)}function mo(a,l){try{var m="",v=l;do m+=ee(v),v=v.return;while(v);var _=m}catch(I){_=`
39
+ Error generating stack: `+I.message+`
40
+ `+I.stack}return{value:a,source:l,stack:_,digest:null}}function cf(a,l,m){return{value:a,source:null,stack:m??null,digest:l??null}}function uf(a,l){try{console.error(l.value)}catch(m){setTimeout(function(){throw m})}}var tC=typeof WeakMap=="function"?WeakMap:Map;function Xv(a,l,m){m=ir(-1,m),m.tag=3,m.payload={element:null};var v=l.value;return m.callback=function(){wu||(wu=!0,Sf=v),uf(a,l)},m}function Qv(a,l,m){m=ir(-1,m),m.tag=3;var v=a.type.getDerivedStateFromError;if(typeof v=="function"){var _=l.value;m.payload=function(){return v(_)},m.callback=function(){uf(a,l)}}var I=a.stateNode;return I!==null&&typeof I.componentDidCatch=="function"&&(m.callback=function(){uf(a,l),typeof v!="function"&&($r===null?$r=new Set([this]):$r.add(this));var q=l.stack;this.componentDidCatch(l.value,{componentStack:q!==null?q:""})}),m}function Jv(a,l,m){var v=a.pingCache;if(v===null){v=a.pingCache=new tC;var _=new Set;v.set(l,_)}else _=v.get(l),_===void 0&&(_=new Set,v.set(l,_));_.has(m)||(_.add(m),a=pC.bind(null,a,l,m),l.then(a,a))}function e0(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 t0(a,l,m,v,_){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(l=ir(-1,1),l.tag=2,Ir(m,l,1))),m.lanes|=1),a):(a.flags|=65536,a.lanes=_,a)}var nC=C.ReactCurrentOwner,gs=!1;function ns(a,l,m,v){l.child=a===null?kv(l,null,m,v):co(l,a.child,m,v)}function n0(a,l,m,v,_){m=m.render;var I=l.ref;return ho(l,_),v=ef(a,l,m,v,I,_),m=tf(),a!==null&&!gs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~_,rr(a,l,_)):(Gt&&m&&zh(l),l.flags|=1,ns(a,l,v,_),l.child)}function s0(a,l,m,v,_){if(a===null){var I=m.type;return typeof I=="function"&&!$f(I)&&I.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(l.tag=15,l.type=I,i0(a,l,I,v,_)):(a=Iu(m.type,null,v,l,l.mode,_),a.ref=l.ref,a.return=l,l.child=a)}if(I=a.child,(a.lanes&_)===0){var q=I.memoizedProps;if(m=m.compare,m=m!==null?m:ll,m(q,v)&&a.ref===l.ref)return rr(a,l,_)}return l.flags|=1,a=Pr(I,v),a.ref=l.ref,a.return=l,l.child=a}function i0(a,l,m,v,_){if(a!==null){var I=a.memoizedProps;if(ll(I,v)&&a.ref===l.ref)if(gs=!1,l.pendingProps=v=I,(a.lanes&_)!==0)(a.flags&131072)!==0&&(gs=!0);else return l.lanes=a.lanes,rr(a,l,_)}return df(a,l,m,v,_)}function r0(a,l,m){var v=l.pendingProps,_=v.children,I=a!==null?a.memoizedState:null;if(v.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Ft(go,Is),Is|=m;else{if((m&1073741824)===0)return a=I!==null?I.baseLanes|m:m,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Ft(go,Is),Is|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=I!==null?I.baseLanes:m,Ft(go,Is),Is|=v}else I!==null?(v=I.baseLanes|m,l.memoizedState=null):v=m,Ft(go,Is),Is|=v;return ns(a,l,_,m),l.child}function a0(a,l){var m=l.ref;(a===null&&m!==null||a!==null&&a.ref!==m)&&(l.flags|=512,l.flags|=2097152)}function df(a,l,m,v,_){var I=ps(m)?la:qn.current;return I=ro(l,I),ho(l,_),m=ef(a,l,m,v,I,_),v=tf(),a!==null&&!gs?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~_,rr(a,l,_)):(Gt&&v&&zh(l),l.flags|=1,ns(a,l,m,_),l.child)}function o0(a,l,m,v,_){if(ps(m)){var I=!0;tu(l)}else I=!1;if(ho(l,_),l.stateNode===null)yu(a,l),Kv(l,m,v),lf(l,m,v,_),v=!0;else if(a===null){var q=l.stateNode,J=l.memoizedProps;q.props=J;var ae=q.context,ge=m.contextType;typeof ge=="object"&&ge!==null?ge=Ks(ge):(ge=ps(m)?la:qn.current,ge=ro(l,ge));var Ae=m.getDerivedStateFromProps,Te=typeof Ae=="function"||typeof q.getSnapshotBeforeUpdate=="function";Te||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(J!==v||ae!==ge)&&Yv(l,q,v,ge),Ar=!1;var Ee=l.memoizedState;q.state=Ee,uu(l,v,q,_),ae=l.memoizedState,J!==v||Ee!==ae||ms.current||Ar?(typeof Ae=="function"&&(of(l,m,Ae,v),ae=l.memoizedState),(J=Ar||Gv(l,m,J,v,Ee,ae,ge))?(Te||typeof q.UNSAFE_componentWillMount!="function"&&typeof q.componentWillMount!="function"||(typeof q.componentWillMount=="function"&&q.componentWillMount(),typeof q.UNSAFE_componentWillMount=="function"&&q.UNSAFE_componentWillMount()),typeof q.componentDidMount=="function"&&(l.flags|=4194308)):(typeof q.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=v,l.memoizedState=ae),q.props=v,q.state=ae,q.context=ge,v=J):(typeof q.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{q=l.stateNode,jv(a,l),J=l.memoizedProps,ge=l.type===l.elementType?J:pi(l.type,J),q.props=ge,Te=l.pendingProps,Ee=q.context,ae=m.contextType,typeof ae=="object"&&ae!==null?ae=Ks(ae):(ae=ps(m)?la:qn.current,ae=ro(l,ae));var Ze=m.getDerivedStateFromProps;(Ae=typeof Ze=="function"||typeof q.getSnapshotBeforeUpdate=="function")||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(J!==Te||Ee!==ae)&&Yv(l,q,v,ae),Ar=!1,Ee=l.memoizedState,q.state=Ee,uu(l,v,q,_);var qe=l.memoizedState;J!==Te||Ee!==qe||ms.current||Ar?(typeof Ze=="function"&&(of(l,m,Ze,v),qe=l.memoizedState),(ge=Ar||Gv(l,m,ge,v,Ee,qe,ae)||!1)?(Ae||typeof q.UNSAFE_componentWillUpdate!="function"&&typeof q.componentWillUpdate!="function"||(typeof q.componentWillUpdate=="function"&&q.componentWillUpdate(v,qe,ae),typeof q.UNSAFE_componentWillUpdate=="function"&&q.UNSAFE_componentWillUpdate(v,qe,ae)),typeof q.componentDidUpdate=="function"&&(l.flags|=4),typeof q.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof q.componentDidUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(l.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=qe),q.props=v,q.state=qe,q.context=ae,v=ge):(typeof q.componentDidUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(l.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(l.flags|=1024),v=!1)}return hf(a,l,m,v,I,_)}function hf(a,l,m,v,_,I){a0(a,l);var q=(l.flags&128)!==0;if(!v&&!q)return _&&hv(l,m,!1),rr(a,l,I);v=l.stateNode,nC.current=l;var J=q&&typeof m.getDerivedStateFromError!="function"?null:v.render();return l.flags|=1,a!==null&&q?(l.child=co(l,a.child,null,I),l.child=co(l,null,J,I)):ns(a,l,J,I),l.memoizedState=v.state,_&&hv(l,m,!0),l.child}function l0(a){var l=a.stateNode;l.pendingContext?uv(a,l.pendingContext,l.pendingContext!==l.context):l.context&&uv(a,l.context,!1),Gh(a,l.containerInfo)}function c0(a,l,m,v,_){return lo(),Uh(_),l.flags|=256,ns(a,l,m,v),l.child}var ff={dehydrated:null,treeContext:null,retryLane:0};function mf(a){return{baseLanes:a,cachePool:null,transitions:null}}function u0(a,l,m){var v=l.pendingProps,_=en.current,I=!1,q=(l.flags&128)!==0,J;if((J=q)||(J=a!==null&&a.memoizedState===null?!1:(_&2)!==0),J?(I=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(_|=1),Ft(en,_&1),a===null)return Fh(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):(q=v.children,a=v.fallback,I?(v=l.mode,I=l.child,q={mode:"hidden",children:q},(v&1)===0&&I!==null?(I.childLanes=0,I.pendingProps=q):I=Tu(q,v,0,null),a=va(a,v,m,null),I.return=l,a.return=l,I.sibling=a,l.child=I,l.child.memoizedState=mf(m),l.memoizedState=ff,a):pf(l,q));if(_=a.memoizedState,_!==null&&(J=_.dehydrated,J!==null))return sC(a,l,q,v,J,_,m);if(I){I=v.fallback,q=l.mode,_=a.child,J=_.sibling;var ae={mode:"hidden",children:v.children};return(q&1)===0&&l.child!==_?(v=l.child,v.childLanes=0,v.pendingProps=ae,l.deletions=null):(v=Pr(_,ae),v.subtreeFlags=_.subtreeFlags&14680064),J!==null?I=Pr(J,I):(I=va(I,q,m,null),I.flags|=2),I.return=l,v.return=l,v.sibling=I,l.child=v,v=I,I=l.child,q=a.child.memoizedState,q=q===null?mf(m):{baseLanes:q.baseLanes|m,cachePool:null,transitions:q.transitions},I.memoizedState=q,I.childLanes=a.childLanes&~m,l.memoizedState=ff,v}return I=a.child,a=I.sibling,v=Pr(I,{mode:"visible",children:v.children}),(l.mode&1)===0&&(v.lanes=m),v.return=l,v.sibling=null,a!==null&&(m=l.deletions,m===null?(l.deletions=[a],l.flags|=16):m.push(a)),l.child=v,l.memoizedState=null,v}function pf(a,l){return l=Tu({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function vu(a,l,m,v){return v!==null&&Uh(v),co(l,a.child,null,m),a=pf(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function sC(a,l,m,v,_,I,q){if(m)return l.flags&256?(l.flags&=-257,v=cf(Error(n(422))),vu(a,l,q,v)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(I=v.fallback,_=l.mode,v=Tu({mode:"visible",children:v.children},_,0,null),I=va(I,_,q,null),I.flags|=2,v.return=l,I.return=l,v.sibling=I,l.child=v,(l.mode&1)!==0&&co(l,a.child,null,q),l.child.memoizedState=mf(q),l.memoizedState=ff,I);if((l.mode&1)===0)return vu(a,l,q,null);if(_.data==="$!"){if(v=_.nextSibling&&_.nextSibling.dataset,v)var J=v.dgst;return v=J,I=Error(n(419)),v=cf(I,v,void 0),vu(a,l,q,v)}if(J=(q&a.childLanes)!==0,gs||J){if(v=$n,v!==null){switch(q&-q){case 4:_=2;break;case 16:_=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:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(v.suspendedLanes|q))!==0?0:_,_!==0&&_!==I.retryLane&&(I.retryLane=_,sr(a,_),vi(v,a,_,-1))}return Tf(),v=cf(Error(n(421))),vu(a,l,q,v)}return _.data==="$?"?(l.flags|=128,l.child=a.child,l=gC.bind(null,a),_._reactRetry=l,null):(a=I.treeContext,As=Sr(_.nextSibling),Cs=l,Gt=!0,mi=null,a!==null&&(qs[Gs++]=tr,qs[Gs++]=nr,qs[Gs++]=ca,tr=a.id,nr=a.overflow,ca=l),l=pf(l,v.children),l.flags|=4096,l)}function d0(a,l,m){a.lanes|=l;var v=a.alternate;v!==null&&(v.lanes|=l),Wh(a.return,l,m)}function gf(a,l,m,v,_){var I=a.memoizedState;I===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:m,tailMode:_}:(I.isBackwards=l,I.rendering=null,I.renderingStartTime=0,I.last=v,I.tail=m,I.tailMode=_)}function h0(a,l,m){var v=l.pendingProps,_=v.revealOrder,I=v.tail;if(ns(a,l,v.children,m),v=en.current,(v&2)!==0)v=v&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&&d0(a,m,l);else if(a.tag===19)d0(a,m,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}v&=1}if(Ft(en,v),(l.mode&1)===0)l.memoizedState=null;else switch(_){case"forwards":for(m=l.child,_=null;m!==null;)a=m.alternate,a!==null&&du(a)===null&&(_=m),m=m.sibling;m=_,m===null?(_=l.child,l.child=null):(_=m.sibling,m.sibling=null),gf(l,!1,_,m,I);break;case"backwards":for(m=null,_=l.child,l.child=null;_!==null;){if(a=_.alternate,a!==null&&du(a)===null){l.child=_;break}a=_.sibling,_.sibling=m,m=_,_=a}gf(l,!0,m,null,I);break;case"together":gf(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function yu(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function rr(a,l,m){if(a!==null&&(l.dependencies=a.dependencies),ma|=l.lanes,(m&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(n(153));if(l.child!==null){for(a=l.child,m=Pr(a,a.pendingProps),l.child=m,m.return=l;a.sibling!==null;)a=a.sibling,m=m.sibling=Pr(a,a.pendingProps),m.return=l;m.sibling=null}return l.child}function iC(a,l,m){switch(l.tag){case 3:l0(l),lo();break;case 5:_v(l);break;case 1:ps(l.type)&&tu(l);break;case 4:Gh(l,l.stateNode.containerInfo);break;case 10:var v=l.type._context,_=l.memoizedProps.value;Ft(ou,v._currentValue),v._currentValue=_;break;case 13:if(v=l.memoizedState,v!==null)return v.dehydrated!==null?(Ft(en,en.current&1),l.flags|=128,null):(m&l.child.childLanes)!==0?u0(a,l,m):(Ft(en,en.current&1),a=rr(a,l,m),a!==null?a.sibling:null);Ft(en,en.current&1);break;case 19:if(v=(m&l.childLanes)!==0,(a.flags&128)!==0){if(v)return h0(a,l,m);l.flags|=128}if(_=l.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),Ft(en,en.current),v)break;return null;case 22:case 23:return l.lanes=0,r0(a,l,m)}return rr(a,l,m)}var f0,xf,m0,p0;f0=function(a,l){for(var m=l.child;m!==null;){if(m.tag===5||m.tag===6)a.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===l)break;for(;m.sibling===null;){if(m.return===null||m.return===l)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},xf=function(){},m0=function(a,l,m,v){var _=a.memoizedProps;if(_!==v){a=l.stateNode,ha(Oi.current);var I=null;switch(m){case"input":_=xe(a,_),v=xe(a,v),I=[];break;case"select":_=G({},_,{value:void 0}),v=G({},v,{value:void 0}),I=[];break;case"textarea":_=Ln(a,_),v=Ln(a,v),I=[];break;default:typeof _.onClick!="function"&&typeof v.onClick=="function"&&(a.onclick=Qc)}Fs(m,v);var q;m=null;for(ge in _)if(!v.hasOwnProperty(ge)&&_.hasOwnProperty(ge)&&_[ge]!=null)if(ge==="style"){var J=_[ge];for(q in J)J.hasOwnProperty(q)&&(m||(m={}),m[q]="")}else ge!=="dangerouslySetInnerHTML"&&ge!=="children"&&ge!=="suppressContentEditableWarning"&&ge!=="suppressHydrationWarning"&&ge!=="autoFocus"&&(r.hasOwnProperty(ge)?I||(I=[]):(I=I||[]).push(ge,null));for(ge in v){var ae=v[ge];if(J=_!=null?_[ge]:void 0,v.hasOwnProperty(ge)&&ae!==J&&(ae!=null||J!=null))if(ge==="style")if(J){for(q in J)!J.hasOwnProperty(q)||ae&&ae.hasOwnProperty(q)||(m||(m={}),m[q]="");for(q in ae)ae.hasOwnProperty(q)&&J[q]!==ae[q]&&(m||(m={}),m[q]=ae[q])}else m||(I||(I=[]),I.push(ge,m)),m=ae;else ge==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,J=J?J.__html:void 0,ae!=null&&J!==ae&&(I=I||[]).push(ge,ae)):ge==="children"?typeof ae!="string"&&typeof ae!="number"||(I=I||[]).push(ge,""+ae):ge!=="suppressContentEditableWarning"&&ge!=="suppressHydrationWarning"&&(r.hasOwnProperty(ge)?(ae!=null&&ge==="onScroll"&&Ht("scroll",a),I||J===ae||(I=[])):(I=I||[]).push(ge,ae))}m&&(I=I||[]).push("style",m);var ge=I;(l.updateQueue=ge)&&(l.flags|=4)}},p0=function(a,l,m,v){m!==v&&(l.flags|=4)};function jl(a,l){if(!Gt)switch(a.tailMode){case"hidden":l=a.tail;for(var m=null;l!==null;)l.alternate!==null&&(m=l),l=l.sibling;m===null?a.tail=null:m.sibling=null;break;case"collapsed":m=a.tail;for(var v=null;m!==null;)m.alternate!==null&&(v=m),m=m.sibling;v===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:v.sibling=null}}function Kn(a){var l=a.alternate!==null&&a.alternate.child===a.child,m=0,v=0;if(l)for(var _=a.child;_!==null;)m|=_.lanes|_.childLanes,v|=_.subtreeFlags&14680064,v|=_.flags&14680064,_.return=a,_=_.sibling;else for(_=a.child;_!==null;)m|=_.lanes|_.childLanes,v|=_.subtreeFlags,v|=_.flags,_.return=a,_=_.sibling;return a.subtreeFlags|=v,a.childLanes=m,l}function rC(a,l,m){var v=l.pendingProps;switch(Lh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kn(l),null;case 1:return ps(l.type)&&eu(),Kn(l),null;case 3:return v=l.stateNode,fo(),Zt(ms),Zt(qn),Xh(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(a===null||a.child===null)&&(ru(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,mi!==null&&(Cf(mi),mi=null))),xf(a,l),Kn(l),null;case 5:Kh(l);var _=ha(vl.current);if(m=l.type,a!==null&&l.stateNode!=null)m0(a,l,m,v,_),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!v){if(l.stateNode===null)throw Error(n(166));return Kn(l),null}if(a=ha(Oi.current),ru(l)){v=l.stateNode,m=l.type;var I=l.memoizedProps;switch(v[Ri]=l,v[fl]=I,a=(l.mode&1)!==0,m){case"dialog":Ht("cancel",v),Ht("close",v);break;case"iframe":case"object":case"embed":Ht("load",v);break;case"video":case"audio":for(_=0;_<ul.length;_++)Ht(ul[_],v);break;case"source":Ht("error",v);break;case"img":case"image":case"link":Ht("error",v),Ht("load",v);break;case"details":Ht("toggle",v);break;case"input":De(v,I),Ht("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!I.multiple},Ht("invalid",v);break;case"textarea":an(v,I),Ht("invalid",v)}Fs(m,I),_=null;for(var q in I)if(I.hasOwnProperty(q)){var J=I[q];q==="children"?typeof J=="string"?v.textContent!==J&&(I.suppressHydrationWarning!==!0&&Xc(v.textContent,J,a),_=["children",J]):typeof J=="number"&&v.textContent!==""+J&&(I.suppressHydrationWarning!==!0&&Xc(v.textContent,J,a),_=["children",""+J]):r.hasOwnProperty(q)&&J!=null&&q==="onScroll"&&Ht("scroll",v)}switch(m){case"input":we(v),Fe(v,I,!0);break;case"textarea":we(v),hn(v);break;case"select":case"option":break;default:typeof I.onClick=="function"&&(v.onclick=Qc)}v=_,l.updateQueue=v,v!==null&&(l.flags|=4)}else{q=_.nodeType===9?_:_.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=on(m)),a==="http://www.w3.org/1999/xhtml"?m==="script"?(a=q.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof v.is=="string"?a=q.createElement(m,{is:v.is}):(a=q.createElement(m),m==="select"&&(q=a,v.multiple?q.multiple=!0:v.size&&(q.size=v.size))):a=q.createElementNS(a,m),a[Ri]=l,a[fl]=v,f0(a,l,!1,!1),l.stateNode=a;e:{switch(q=Us(m,v),m){case"dialog":Ht("cancel",a),Ht("close",a),_=v;break;case"iframe":case"object":case"embed":Ht("load",a),_=v;break;case"video":case"audio":for(_=0;_<ul.length;_++)Ht(ul[_],a);_=v;break;case"source":Ht("error",a),_=v;break;case"img":case"image":case"link":Ht("error",a),Ht("load",a),_=v;break;case"details":Ht("toggle",a),_=v;break;case"input":De(a,v),_=xe(a,v),Ht("invalid",a);break;case"option":_=v;break;case"select":a._wrapperState={wasMultiple:!!v.multiple},_=G({},v,{value:void 0}),Ht("invalid",a);break;case"textarea":an(a,v),_=Ln(a,v),Ht("invalid",a);break;default:_=v}Fs(m,_),J=_;for(I in J)if(J.hasOwnProperty(I)){var ae=J[I];I==="style"?ri(a,ae):I==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,ae!=null&&Hn(a,ae)):I==="children"?typeof ae=="string"?(m!=="textarea"||ae!=="")&&wn(a,ae):typeof ae=="number"&&wn(a,""+ae):I!=="suppressContentEditableWarning"&&I!=="suppressHydrationWarning"&&I!=="autoFocus"&&(r.hasOwnProperty(I)?ae!=null&&I==="onScroll"&&Ht("scroll",a):ae!=null&&N(a,I,ae,q))}switch(m){case"input":we(a),Fe(a,v,!1);break;case"textarea":we(a),hn(a);break;case"option":v.value!=null&&a.setAttribute("value",""+se(v.value));break;case"select":a.multiple=!!v.multiple,I=v.value,I!=null?Pt(a,!!v.multiple,I,!1):v.defaultValue!=null&&Pt(a,!!v.multiple,v.defaultValue,!0);break;default:typeof _.onClick=="function"&&(a.onclick=Qc)}switch(m){case"button":case"input":case"select":case"textarea":v=!!v.autoFocus;break e;case"img":v=!0;break e;default:v=!1}}v&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return Kn(l),null;case 6:if(a&&l.stateNode!=null)p0(a,l,a.memoizedProps,v);else{if(typeof v!="string"&&l.stateNode===null)throw Error(n(166));if(m=ha(vl.current),ha(Oi.current),ru(l)){if(v=l.stateNode,m=l.memoizedProps,v[Ri]=l,(I=v.nodeValue!==m)&&(a=Cs,a!==null))switch(a.tag){case 3:Xc(v.nodeValue,m,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Xc(v.nodeValue,m,(a.mode&1)!==0)}I&&(l.flags|=4)}else v=(m.nodeType===9?m:m.ownerDocument).createTextNode(v),v[Ri]=l,l.stateNode=v}return Kn(l),null;case 13:if(Zt(en),v=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Gt&&As!==null&&(l.mode&1)!==0&&(l.flags&128)===0)vv(),lo(),l.flags|=98560,I=!1;else if(I=ru(l),v!==null&&v.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[Ri]=l}else lo(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Kn(l),I=!1}else mi!==null&&(Cf(mi),mi=null),I=!0;if(!I)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=m,l):(v=v!==null,v!==(a!==null&&a.memoizedState!==null)&&v&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(en.current&1)!==0?An===0&&(An=3):Tf())),l.updateQueue!==null&&(l.flags|=4),Kn(l),null);case 4:return fo(),xf(a,l),a===null&&dl(l.stateNode.containerInfo),Kn(l),null;case 10:return Zh(l.type._context),Kn(l),null;case 17:return ps(l.type)&&eu(),Kn(l),null;case 19:if(Zt(en),I=l.memoizedState,I===null)return Kn(l),null;if(v=(l.flags&128)!==0,q=I.rendering,q===null)if(v)jl(I,!1);else{if(An!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(q=du(a),q!==null){for(l.flags|=128,jl(I,!1),v=q.updateQueue,v!==null&&(l.updateQueue=v,l.flags|=4),l.subtreeFlags=0,v=m,m=l.child;m!==null;)I=m,a=v,I.flags&=14680066,q=I.alternate,q===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=q.childLanes,I.lanes=q.lanes,I.child=q.child,I.subtreeFlags=0,I.deletions=null,I.memoizedProps=q.memoizedProps,I.memoizedState=q.memoizedState,I.updateQueue=q.updateQueue,I.type=q.type,a=q.dependencies,I.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),m=m.sibling;return Ft(en,en.current&1|2),l.child}a=a.sibling}I.tail!==null&&Rt()>xo&&(l.flags|=128,v=!0,jl(I,!1),l.lanes=4194304)}else{if(!v)if(a=du(q),a!==null){if(l.flags|=128,v=!0,m=a.updateQueue,m!==null&&(l.updateQueue=m,l.flags|=4),jl(I,!0),I.tail===null&&I.tailMode==="hidden"&&!q.alternate&&!Gt)return Kn(l),null}else 2*Rt()-I.renderingStartTime>xo&&m!==1073741824&&(l.flags|=128,v=!0,jl(I,!1),l.lanes=4194304);I.isBackwards?(q.sibling=l.child,l.child=q):(m=I.last,m!==null?m.sibling=q:l.child=q,I.last=q)}return I.tail!==null?(l=I.tail,I.rendering=l,I.tail=l.sibling,I.renderingStartTime=Rt(),l.sibling=null,m=en.current,Ft(en,v?m&1|2:m&1),l):(Kn(l),null);case 22:case 23:return If(),v=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==v&&(l.flags|=8192),v&&(l.mode&1)!==0?(Is&1073741824)!==0&&(Kn(l),l.subtreeFlags&6&&(l.flags|=8192)):Kn(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function aC(a,l){switch(Lh(l),l.tag){case 1:return ps(l.type)&&eu(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return fo(),Zt(ms),Zt(qn),Xh(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return Kh(l),null;case 13:if(Zt(en),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(n(340));lo()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Zt(en),null;case 4:return fo(),null;case 10:return Zh(l.type._context),null;case 22:case 23:return If(),null;case 24:return null;default:return null}}var bu=!1,Yn=!1,oC=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function po(a,l){var m=a.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(v){cn(a,l,v)}else m.current=null}function vf(a,l,m){try{m()}catch(v){cn(a,l,v)}}var g0=!1;function lC(a,l){if(Ah=et,a=Gx(),kh(a)){if("selectionStart"in a)var m={start:a.selectionStart,end:a.selectionEnd};else e:{m=(m=a.ownerDocument)&&m.defaultView||window;var v=m.getSelection&&m.getSelection();if(v&&v.rangeCount!==0){m=v.anchorNode;var _=v.anchorOffset,I=v.focusNode;v=v.focusOffset;try{m.nodeType,I.nodeType}catch{m=null;break e}var q=0,J=-1,ae=-1,ge=0,Ae=0,Te=a,Ee=null;t:for(;;){for(var Ze;Te!==m||_!==0&&Te.nodeType!==3||(J=q+_),Te!==I||v!==0&&Te.nodeType!==3||(ae=q+v),Te.nodeType===3&&(q+=Te.nodeValue.length),(Ze=Te.firstChild)!==null;)Ee=Te,Te=Ze;for(;;){if(Te===a)break t;if(Ee===m&&++ge===_&&(J=q),Ee===I&&++Ae===v&&(ae=q),(Ze=Te.nextSibling)!==null)break;Te=Ee,Ee=Te.parentNode}Te=Ze}m=J===-1||ae===-1?null:{start:J,end:ae}}else m=null}m=m||{start:0,end:0}}else m=null;for(Ih={focusedElem:a,selectionRange:m},et=!1,Ve=l;Ve!==null;)if(l=Ve,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,Ve=a;else for(;Ve!==null;){l=Ve;try{var qe=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(qe!==null){var Ke=qe.memoizedProps,pn=qe.memoizedState,me=l.stateNode,ue=me.getSnapshotBeforeUpdate(l.elementType===l.type?Ke:pi(l.type,Ke),pn);me.__reactInternalSnapshotBeforeUpdate=ue}break;case 3:var pe=l.stateNode.containerInfo;pe.nodeType===1?pe.textContent="":pe.nodeType===9&&pe.documentElement&&pe.removeChild(pe.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){cn(l,l.return,Oe)}if(a=l.sibling,a!==null){a.return=l.return,Ve=a;break}Ve=l.return}return qe=g0,g0=!1,qe}function wl(a,l,m){var v=l.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var _=v=v.next;do{if((_.tag&a)===a){var I=_.destroy;_.destroy=void 0,I!==void 0&&vf(l,m,I)}_=_.next}while(_!==v)}}function ku(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var m=l=l.next;do{if((m.tag&a)===a){var v=m.create;m.destroy=v()}m=m.next}while(m!==l)}}function yf(a){var l=a.ref;if(l!==null){var m=a.stateNode;switch(a.tag){case 5:a=m;break;default:a=m}typeof l=="function"?l(a):l.current=a}}function x0(a){var l=a.alternate;l!==null&&(a.alternate=null,x0(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[Ri],delete l[fl],delete l[Rh],delete l[Z1],delete l[W1])),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 v0(a){return a.tag===5||a.tag===3||a.tag===4}function y0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||v0(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 bf(a,l,m){var v=a.tag;if(v===5||v===6)a=a.stateNode,l?m.nodeType===8?m.parentNode.insertBefore(a,l):m.insertBefore(a,l):(m.nodeType===8?(l=m.parentNode,l.insertBefore(a,m)):(l=m,l.appendChild(a)),m=m._reactRootContainer,m!=null||l.onclick!==null||(l.onclick=Qc));else if(v!==4&&(a=a.child,a!==null))for(bf(a,l,m),a=a.sibling;a!==null;)bf(a,l,m),a=a.sibling}function kf(a,l,m){var v=a.tag;if(v===5||v===6)a=a.stateNode,l?m.insertBefore(a,l):m.appendChild(a);else if(v!==4&&(a=a.child,a!==null))for(kf(a,l,m),a=a.sibling;a!==null;)kf(a,l,m),a=a.sibling}var Dn=null,gi=!1;function Tr(a,l,m){for(m=m.child;m!==null;)b0(a,l,m),m=m.sibling}function b0(a,l,m){if(dt&&typeof dt.onCommitFiberUnmount=="function")try{dt.onCommitFiberUnmount(lt,m)}catch{}switch(m.tag){case 5:Yn||po(m,l);case 6:var v=Dn,_=gi;Dn=null,Tr(a,l,m),Dn=v,gi=_,Dn!==null&&(gi?(a=Dn,m=m.stateNode,a.nodeType===8?a.parentNode.removeChild(m):a.removeChild(m)):Dn.removeChild(m.stateNode));break;case 18:Dn!==null&&(gi?(a=Dn,m=m.stateNode,a.nodeType===8?Mh(a.parentNode,m):a.nodeType===1&&Mh(a,m),Ne(a)):Mh(Dn,m.stateNode));break;case 4:v=Dn,_=gi,Dn=m.stateNode.containerInfo,gi=!0,Tr(a,l,m),Dn=v,gi=_;break;case 0:case 11:case 14:case 15:if(!Yn&&(v=m.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){_=v=v.next;do{var I=_,q=I.destroy;I=I.tag,q!==void 0&&((I&2)!==0||(I&4)!==0)&&vf(m,l,q),_=_.next}while(_!==v)}Tr(a,l,m);break;case 1:if(!Yn&&(po(m,l),v=m.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=m.memoizedProps,v.state=m.memoizedState,v.componentWillUnmount()}catch(J){cn(m,l,J)}Tr(a,l,m);break;case 21:Tr(a,l,m);break;case 22:m.mode&1?(Yn=(v=Yn)||m.memoizedState!==null,Tr(a,l,m),Yn=v):Tr(a,l,m);break;default:Tr(a,l,m)}}function k0(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var m=a.stateNode;m===null&&(m=a.stateNode=new oC),l.forEach(function(v){var _=xC.bind(null,a,v);m.has(v)||(m.add(v),v.then(_,_))})}}function xi(a,l){var m=l.deletions;if(m!==null)for(var v=0;v<m.length;v++){var _=m[v];try{var I=a,q=l,J=q;e:for(;J!==null;){switch(J.tag){case 5:Dn=J.stateNode,gi=!1;break e;case 3:Dn=J.stateNode.containerInfo,gi=!0;break e;case 4:Dn=J.stateNode.containerInfo,gi=!0;break e}J=J.return}if(Dn===null)throw Error(n(160));b0(I,q,_),Dn=null,gi=!1;var ae=_.alternate;ae!==null&&(ae.return=null),_.return=null}catch(ge){cn(_,l,ge)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)N0(l,a),l=l.sibling}function N0(a,l){var m=a.alternate,v=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(xi(l,a),zi(a),v&4){try{wl(3,a,a.return),ku(3,a)}catch(Ke){cn(a,a.return,Ke)}try{wl(5,a,a.return)}catch(Ke){cn(a,a.return,Ke)}}break;case 1:xi(l,a),zi(a),v&512&&m!==null&&po(m,m.return);break;case 5:if(xi(l,a),zi(a),v&512&&m!==null&&po(m,m.return),a.flags&32){var _=a.stateNode;try{wn(_,"")}catch(Ke){cn(a,a.return,Ke)}}if(v&4&&(_=a.stateNode,_!=null)){var I=a.memoizedProps,q=m!==null?m.memoizedProps:I,J=a.type,ae=a.updateQueue;if(a.updateQueue=null,ae!==null)try{J==="input"&&I.type==="radio"&&I.name!=null&&Me(_,I),Us(J,q);var ge=Us(J,I);for(q=0;q<ae.length;q+=2){var Ae=ae[q],Te=ae[q+1];Ae==="style"?ri(_,Te):Ae==="dangerouslySetInnerHTML"?Hn(_,Te):Ae==="children"?wn(_,Te):N(_,Ae,Te,ge)}switch(J){case"input":Ce(_,I);break;case"textarea":dn(_,I);break;case"select":var Ee=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!I.multiple;var Ze=I.value;Ze!=null?Pt(_,!!I.multiple,Ze,!1):Ee!==!!I.multiple&&(I.defaultValue!=null?Pt(_,!!I.multiple,I.defaultValue,!0):Pt(_,!!I.multiple,I.multiple?[]:"",!1))}_[fl]=I}catch(Ke){cn(a,a.return,Ke)}}break;case 6:if(xi(l,a),zi(a),v&4){if(a.stateNode===null)throw Error(n(162));_=a.stateNode,I=a.memoizedProps;try{_.nodeValue=I}catch(Ke){cn(a,a.return,Ke)}}break;case 3:if(xi(l,a),zi(a),v&4&&m!==null&&m.memoizedState.isDehydrated)try{Ne(l.containerInfo)}catch(Ke){cn(a,a.return,Ke)}break;case 4:xi(l,a),zi(a);break;case 13:xi(l,a),zi(a),_=a.child,_.flags&8192&&(I=_.memoizedState!==null,_.stateNode.isHidden=I,!I||_.alternate!==null&&_.alternate.memoizedState!==null||(wf=Rt())),v&4&&k0(a);break;case 22:if(Ae=m!==null&&m.memoizedState!==null,a.mode&1?(Yn=(ge=Yn)||Ae,xi(l,a),Yn=ge):xi(l,a),zi(a),v&8192){if(ge=a.memoizedState!==null,(a.stateNode.isHidden=ge)&&!Ae&&(a.mode&1)!==0)for(Ve=a,Ae=a.child;Ae!==null;){for(Te=Ve=Ae;Ve!==null;){switch(Ee=Ve,Ze=Ee.child,Ee.tag){case 0:case 11:case 14:case 15:wl(4,Ee,Ee.return);break;case 1:po(Ee,Ee.return);var qe=Ee.stateNode;if(typeof qe.componentWillUnmount=="function"){v=Ee,m=Ee.return;try{l=v,qe.props=l.memoizedProps,qe.state=l.memoizedState,qe.componentWillUnmount()}catch(Ke){cn(v,m,Ke)}}break;case 5:po(Ee,Ee.return);break;case 22:if(Ee.memoizedState!==null){S0(Te);continue}}Ze!==null?(Ze.return=Ee,Ve=Ze):S0(Te)}Ae=Ae.sibling}e:for(Ae=null,Te=a;;){if(Te.tag===5){if(Ae===null){Ae=Te;try{_=Te.stateNode,ge?(I=_.style,typeof I.setProperty=="function"?I.setProperty("display","none","important"):I.display="none"):(J=Te.stateNode,ae=Te.memoizedProps.style,q=ae!=null&&ae.hasOwnProperty("display")?ae.display:null,J.style.display=ii("display",q))}catch(Ke){cn(a,a.return,Ke)}}}else if(Te.tag===6){if(Ae===null)try{Te.stateNode.nodeValue=ge?"":Te.memoizedProps}catch(Ke){cn(a,a.return,Ke)}}else if((Te.tag!==22&&Te.tag!==23||Te.memoizedState===null||Te===a)&&Te.child!==null){Te.child.return=Te,Te=Te.child;continue}if(Te===a)break e;for(;Te.sibling===null;){if(Te.return===null||Te.return===a)break e;Ae===Te&&(Ae=null),Te=Te.return}Ae===Te&&(Ae=null),Te.sibling.return=Te.return,Te=Te.sibling}}break;case 19:xi(l,a),zi(a),v&4&&k0(a);break;case 21:break;default:xi(l,a),zi(a)}}function zi(a){var l=a.flags;if(l&2){try{e:{for(var m=a.return;m!==null;){if(v0(m)){var v=m;break e}m=m.return}throw Error(n(160))}switch(v.tag){case 5:var _=v.stateNode;v.flags&32&&(wn(_,""),v.flags&=-33);var I=y0(a);kf(a,I,_);break;case 3:case 4:var q=v.stateNode.containerInfo,J=y0(a);bf(a,J,q);break;default:throw Error(n(161))}}catch(ae){cn(a,a.return,ae)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function cC(a,l,m){Ve=a,j0(a)}function j0(a,l,m){for(var v=(a.mode&1)!==0;Ve!==null;){var _=Ve,I=_.child;if(_.tag===22&&v){var q=_.memoizedState!==null||bu;if(!q){var J=_.alternate,ae=J!==null&&J.memoizedState!==null||Yn;J=bu;var ge=Yn;if(bu=q,(Yn=ae)&&!ge)for(Ve=_;Ve!==null;)q=Ve,ae=q.child,q.tag===22&&q.memoizedState!==null?_0(_):ae!==null?(ae.return=q,Ve=ae):_0(_);for(;I!==null;)Ve=I,j0(I),I=I.sibling;Ve=_,bu=J,Yn=ge}w0(a)}else(_.subtreeFlags&8772)!==0&&I!==null?(I.return=_,Ve=I):w0(a)}}function w0(a){for(;Ve!==null;){var l=Ve;if((l.flags&8772)!==0){var m=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Yn||ku(5,l);break;case 1:var v=l.stateNode;if(l.flags&4&&!Yn)if(m===null)v.componentDidMount();else{var _=l.elementType===l.type?m.memoizedProps:pi(l.type,m.memoizedProps);v.componentDidUpdate(_,m.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var I=l.updateQueue;I!==null&&Sv(l,I,v);break;case 3:var q=l.updateQueue;if(q!==null){if(m=null,l.child!==null)switch(l.child.tag){case 5:m=l.child.stateNode;break;case 1:m=l.child.stateNode}Sv(l,q,m)}break;case 5:var J=l.stateNode;if(m===null&&l.flags&4){m=J;var ae=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ae.autoFocus&&m.focus();break;case"img":ae.src&&(m.src=ae.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ge=l.alternate;if(ge!==null){var Ae=ge.memoizedState;if(Ae!==null){var Te=Ae.dehydrated;Te!==null&&Ne(Te)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Yn||l.flags&512&&yf(l)}catch(Ee){cn(l,l.return,Ee)}}if(l===a){Ve=null;break}if(m=l.sibling,m!==null){m.return=l.return,Ve=m;break}Ve=l.return}}function S0(a){for(;Ve!==null;){var l=Ve;if(l===a){Ve=null;break}var m=l.sibling;if(m!==null){m.return=l.return,Ve=m;break}Ve=l.return}}function _0(a){for(;Ve!==null;){var l=Ve;try{switch(l.tag){case 0:case 11:case 15:var m=l.return;try{ku(4,l)}catch(ae){cn(l,m,ae)}break;case 1:var v=l.stateNode;if(typeof v.componentDidMount=="function"){var _=l.return;try{v.componentDidMount()}catch(ae){cn(l,_,ae)}}var I=l.return;try{yf(l)}catch(ae){cn(l,I,ae)}break;case 5:var q=l.return;try{yf(l)}catch(ae){cn(l,q,ae)}}}catch(ae){cn(l,l.return,ae)}if(l===a){Ve=null;break}var J=l.sibling;if(J!==null){J.return=l.return,Ve=J;break}Ve=l.return}}var uC=Math.ceil,Nu=C.ReactCurrentDispatcher,Nf=C.ReactCurrentOwner,Xs=C.ReactCurrentBatchConfig,Nt=0,$n=null,yn=null,Fn=0,Is=0,go=_r(0),An=0,Sl=null,ma=0,ju=0,jf=0,_l=null,xs=null,wf=0,xo=1/0,ar=null,wu=!1,Sf=null,$r=null,Su=!1,Mr=null,_u=0,El=0,_f=null,Eu=-1,Cu=0;function ss(){return(Nt&6)!==0?Rt():Eu!==-1?Eu:Eu=Rt()}function Rr(a){return(a.mode&1)===0?1:(Nt&2)!==0&&Fn!==0?Fn&-Fn:q1.transition!==null?(Cu===0&&(Cu=jr()),Cu):(a=vt,a!==0||(a=window.event,a=a===void 0?16:Qi(a.type)),a)}function vi(a,l,m,v){if(50<El)throw El=0,_f=null,Error(n(185));ds(a,m,v),((Nt&2)===0||a!==$n)&&(a===$n&&((Nt&2)===0&&(ju|=m),An===4&&Or(a,Fn)),vs(a,v),m===1&&Nt===0&&(l.mode&1)===0&&(xo=Rt()+500,nu&&Cr()))}function vs(a,l){var m=a.callbackNode;Nr(a,l);var v=us(a,a===$n?Fn:0);if(v===0)m!==null&&Jn(m),a.callbackNode=null,a.callbackPriority=0;else if(l=v&-v,a.callbackPriority!==l){if(m!=null&&Jn(m),l===1)a.tag===0?V1(C0.bind(null,a)):fv(C0.bind(null,a)),B1(function(){(Nt&6)===0&&Cr()}),m=null;else{switch(it(v)){case 1:m=Gi;break;case 4:m=di;break;case 16:m=$i;break;case 536870912:m=We;break;default:m=$i}m=P0(m,E0.bind(null,a))}a.callbackPriority=l,a.callbackNode=m}}function E0(a,l){if(Eu=-1,Cu=0,(Nt&6)!==0)throw Error(n(327));var m=a.callbackNode;if(vo()&&a.callbackNode!==m)return null;var v=us(a,a===$n?Fn:0);if(v===0)return null;if((v&30)!==0||(v&a.expiredLanes)!==0||l)l=Au(a,v);else{l=v;var _=Nt;Nt|=2;var I=I0();($n!==a||Fn!==l)&&(ar=null,xo=Rt()+500,ga(a,l));do try{fC();break}catch(J){A0(a,J)}while(!0);Hh(),Nu.current=I,Nt=_,yn!==null?l=0:($n=null,Fn=0,l=An)}if(l!==0){if(l===2&&(_=Mi(a),_!==0&&(v=_,l=Ef(a,_))),l===1)throw m=Sl,ga(a,0),Or(a,v),vs(a,Rt()),m;if(l===6)Or(a,v);else{if(_=a.current.alternate,(v&30)===0&&!dC(_)&&(l=Au(a,v),l===2&&(I=Mi(a),I!==0&&(v=I,l=Ef(a,I))),l===1))throw m=Sl,ga(a,0),Or(a,v),vs(a,Rt()),m;switch(a.finishedWork=_,a.finishedLanes=v,l){case 0:case 1:throw Error(n(345));case 2:xa(a,xs,ar);break;case 3:if(Or(a,v),(v&130023424)===v&&(l=wf+500-Rt(),10<l)){if(us(a,0)!==0)break;if(_=a.suspendedLanes,(_&v)!==v){ss(),a.pingedLanes|=a.suspendedLanes&_;break}a.timeoutHandle=$h(xa.bind(null,a,xs,ar),l);break}xa(a,xs,ar);break;case 4:if(Or(a,v),(v&4194240)===v)break;for(l=a.eventTimes,_=-1;0<v;){var q=31-Ot(v);I=1<<q,q=l[q],q>_&&(_=q),v&=~I}if(v=_,v=Rt()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*uC(v/1960))-v,10<v){a.timeoutHandle=$h(xa.bind(null,a,xs,ar),v);break}xa(a,xs,ar);break;case 5:xa(a,xs,ar);break;default:throw Error(n(329))}}}return vs(a,Rt()),a.callbackNode===m?E0.bind(null,a):null}function Ef(a,l){var m=_l;return a.current.memoizedState.isDehydrated&&(ga(a,l).flags|=256),a=Au(a,l),a!==2&&(l=xs,xs=m,l!==null&&Cf(l)),a}function Cf(a){xs===null?xs=a:xs.push.apply(xs,a)}function dC(a){for(var l=a;;){if(l.flags&16384){var m=l.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var v=0;v<m.length;v++){var _=m[v],I=_.getSnapshot;_=_.value;try{if(!fi(I(),_))return!1}catch{return!1}}}if(m=l.child,l.subtreeFlags&16384&&m!==null)m.return=l,l=m;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 Or(a,l){for(l&=~jf,l&=~ju,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var m=31-Ot(l),v=1<<m;a[m]=-1,l&=~v}}function C0(a){if((Nt&6)!==0)throw Error(n(327));vo();var l=us(a,0);if((l&1)===0)return vs(a,Rt()),null;var m=Au(a,l);if(a.tag!==0&&m===2){var v=Mi(a);v!==0&&(l=v,m=Ef(a,v))}if(m===1)throw m=Sl,ga(a,0),Or(a,l),vs(a,Rt()),m;if(m===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,xa(a,xs,ar),vs(a,Rt()),null}function Af(a,l){var m=Nt;Nt|=1;try{return a(l)}finally{Nt=m,Nt===0&&(xo=Rt()+500,nu&&Cr())}}function pa(a){Mr!==null&&Mr.tag===0&&(Nt&6)===0&&vo();var l=Nt;Nt|=1;var m=Xs.transition,v=vt;try{if(Xs.transition=null,vt=1,a)return a()}finally{vt=v,Xs.transition=m,Nt=l,(Nt&6)===0&&Cr()}}function If(){Is=go.current,Zt(go)}function ga(a,l){a.finishedWork=null,a.finishedLanes=0;var m=a.timeoutHandle;if(m!==-1&&(a.timeoutHandle=-1,U1(m)),yn!==null)for(m=yn.return;m!==null;){var v=m;switch(Lh(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&eu();break;case 3:fo(),Zt(ms),Zt(qn),Xh();break;case 5:Kh(v);break;case 4:fo();break;case 13:Zt(en);break;case 19:Zt(en);break;case 10:Zh(v.type._context);break;case 22:case 23:If()}m=m.return}if($n=a,yn=a=Pr(a.current,null),Fn=Is=l,An=0,Sl=null,jf=ju=ma=0,xs=_l=null,da!==null){for(l=0;l<da.length;l++)if(m=da[l],v=m.interleaved,v!==null){m.interleaved=null;var _=v.next,I=m.pending;if(I!==null){var q=I.next;I.next=_,v.next=q}m.pending=v}da=null}return a}function A0(a,l){do{var m=yn;try{if(Hh(),hu.current=gu,fu){for(var v=tn.memoizedState;v!==null;){var _=v.queue;_!==null&&(_.pending=null),v=v.next}fu=!1}if(fa=0,Tn=Cn=tn=null,yl=!1,bl=0,Nf.current=null,m===null||m.return===null){An=1,Sl=l,yn=null;break}e:{var I=a,q=m.return,J=m,ae=l;if(l=Fn,J.flags|=32768,ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var ge=ae,Ae=J,Te=Ae.tag;if((Ae.mode&1)===0&&(Te===0||Te===11||Te===15)){var Ee=Ae.alternate;Ee?(Ae.updateQueue=Ee.updateQueue,Ae.memoizedState=Ee.memoizedState,Ae.lanes=Ee.lanes):(Ae.updateQueue=null,Ae.memoizedState=null)}var Ze=e0(q);if(Ze!==null){Ze.flags&=-257,t0(Ze,q,J,I,l),Ze.mode&1&&Jv(I,ge,l),l=Ze,ae=ge;var qe=l.updateQueue;if(qe===null){var Ke=new Set;Ke.add(ae),l.updateQueue=Ke}else qe.add(ae);break e}else{if((l&1)===0){Jv(I,ge,l),Tf();break e}ae=Error(n(426))}}else if(Gt&&J.mode&1){var pn=e0(q);if(pn!==null){(pn.flags&65536)===0&&(pn.flags|=256),t0(pn,q,J,I,l),Uh(mo(ae,J));break e}}I=ae=mo(ae,J),An!==4&&(An=2),_l===null?_l=[I]:_l.push(I),I=q;do{switch(I.tag){case 3:I.flags|=65536,l&=-l,I.lanes|=l;var me=Xv(I,ae,l);wv(I,me);break e;case 1:J=ae;var ue=I.type,pe=I.stateNode;if((I.flags&128)===0&&(typeof ue.getDerivedStateFromError=="function"||pe!==null&&typeof pe.componentDidCatch=="function"&&($r===null||!$r.has(pe)))){I.flags|=65536,l&=-l,I.lanes|=l;var Oe=Qv(I,J,l);wv(I,Oe);break e}}I=I.return}while(I!==null)}$0(m)}catch(Ye){l=Ye,yn===m&&m!==null&&(yn=m=m.return);continue}break}while(!0)}function I0(){var a=Nu.current;return Nu.current=gu,a===null?gu:a}function Tf(){(An===0||An===3||An===2)&&(An=4),$n===null||(ma&268435455)===0&&(ju&268435455)===0||Or($n,Fn)}function Au(a,l){var m=Nt;Nt|=2;var v=I0();($n!==a||Fn!==l)&&(ar=null,ga(a,l));do try{hC();break}catch(_){A0(a,_)}while(!0);if(Hh(),Nt=m,Nu.current=v,yn!==null)throw Error(n(261));return $n=null,Fn=0,An}function hC(){for(;yn!==null;)T0(yn)}function fC(){for(;yn!==null&&!qi();)T0(yn)}function T0(a){var l=O0(a.alternate,a,Is);a.memoizedProps=a.pendingProps,l===null?$0(a):yn=l,Nf.current=null}function $0(a){var l=a;do{var m=l.alternate;if(a=l.return,(l.flags&32768)===0){if(m=rC(m,l,Is),m!==null){yn=m;return}}else{if(m=aC(m,l),m!==null){m.flags&=32767,yn=m;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{An=6,yn=null;return}}if(l=l.sibling,l!==null){yn=l;return}yn=l=a}while(l!==null);An===0&&(An=5)}function xa(a,l,m){var v=vt,_=Xs.transition;try{Xs.transition=null,vt=1,mC(a,l,m,v)}finally{Xs.transition=_,vt=v}return null}function mC(a,l,m,v){do vo();while(Mr!==null);if((Nt&6)!==0)throw Error(n(327));m=a.finishedWork;var _=a.finishedLanes;if(m===null)return null;if(a.finishedWork=null,a.finishedLanes=0,m===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var I=m.lanes|m.childLanes;if(En(a,I),a===$n&&(yn=$n=null,Fn=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||Su||(Su=!0,P0($i,function(){return vo(),null})),I=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||I){I=Xs.transition,Xs.transition=null;var q=vt;vt=1;var J=Nt;Nt|=4,Nf.current=null,lC(a,m),N0(m,a),R1(Ih),et=!!Ah,Ih=Ah=null,a.current=m,cC(m),ui(),Nt=J,vt=q,Xs.transition=I}else a.current=m;if(Su&&(Su=!1,Mr=a,_u=_),I=a.pendingLanes,I===0&&($r=null),It(m.stateNode),vs(a,Rt()),l!==null)for(v=a.onRecoverableError,m=0;m<l.length;m++)_=l[m],v(_.value,{componentStack:_.stack,digest:_.digest});if(wu)throw wu=!1,a=Sf,Sf=null,a;return(_u&1)!==0&&a.tag!==0&&vo(),I=a.pendingLanes,(I&1)!==0?a===_f?El++:(El=0,_f=a):El=0,Cr(),null}function vo(){if(Mr!==null){var a=it(_u),l=Xs.transition,m=vt;try{if(Xs.transition=null,vt=16>a?16:a,Mr===null)var v=!1;else{if(a=Mr,Mr=null,_u=0,(Nt&6)!==0)throw Error(n(331));var _=Nt;for(Nt|=4,Ve=a.current;Ve!==null;){var I=Ve,q=I.child;if((Ve.flags&16)!==0){var J=I.deletions;if(J!==null){for(var ae=0;ae<J.length;ae++){var ge=J[ae];for(Ve=ge;Ve!==null;){var Ae=Ve;switch(Ae.tag){case 0:case 11:case 15:wl(8,Ae,I)}var Te=Ae.child;if(Te!==null)Te.return=Ae,Ve=Te;else for(;Ve!==null;){Ae=Ve;var Ee=Ae.sibling,Ze=Ae.return;if(x0(Ae),Ae===ge){Ve=null;break}if(Ee!==null){Ee.return=Ze,Ve=Ee;break}Ve=Ze}}}var qe=I.alternate;if(qe!==null){var Ke=qe.child;if(Ke!==null){qe.child=null;do{var pn=Ke.sibling;Ke.sibling=null,Ke=pn}while(Ke!==null)}}Ve=I}}if((I.subtreeFlags&2064)!==0&&q!==null)q.return=I,Ve=q;else e:for(;Ve!==null;){if(I=Ve,(I.flags&2048)!==0)switch(I.tag){case 0:case 11:case 15:wl(9,I,I.return)}var me=I.sibling;if(me!==null){me.return=I.return,Ve=me;break e}Ve=I.return}}var ue=a.current;for(Ve=ue;Ve!==null;){q=Ve;var pe=q.child;if((q.subtreeFlags&2064)!==0&&pe!==null)pe.return=q,Ve=pe;else e:for(q=ue;Ve!==null;){if(J=Ve,(J.flags&2048)!==0)try{switch(J.tag){case 0:case 11:case 15:ku(9,J)}}catch(Ye){cn(J,J.return,Ye)}if(J===q){Ve=null;break e}var Oe=J.sibling;if(Oe!==null){Oe.return=J.return,Ve=Oe;break e}Ve=J.return}}if(Nt=_,Cr(),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(lt,a)}catch{}v=!0}return v}finally{vt=m,Xs.transition=l}}return!1}function M0(a,l,m){l=mo(m,l),l=Xv(a,l,1),a=Ir(a,l,1),l=ss(),a!==null&&(ds(a,1,l),vs(a,l))}function cn(a,l,m){if(a.tag===3)M0(a,a,m);else for(;l!==null;){if(l.tag===3){M0(l,a,m);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&($r===null||!$r.has(v))){a=mo(m,a),a=Qv(l,a,1),l=Ir(l,a,1),a=ss(),l!==null&&(ds(l,1,a),vs(l,a));break}}l=l.return}}function pC(a,l,m){var v=a.pingCache;v!==null&&v.delete(l),l=ss(),a.pingedLanes|=a.suspendedLanes&m,$n===a&&(Fn&m)===m&&(An===4||An===3&&(Fn&130023424)===Fn&&500>Rt()-wf?ga(a,0):jf|=m),vs(a,l)}function R0(a,l){l===0&&((a.mode&1)===0?l=1:(l=Zs,Zs<<=1,(Zs&130023424)===0&&(Zs=4194304)));var m=ss();a=sr(a,l),a!==null&&(ds(a,l,m),vs(a,m))}function gC(a){var l=a.memoizedState,m=0;l!==null&&(m=l.retryLane),R0(a,m)}function xC(a,l){var m=0;switch(a.tag){case 13:var v=a.stateNode,_=a.memoizedState;_!==null&&(m=_.retryLane);break;case 19:v=a.stateNode;break;default:throw Error(n(314))}v!==null&&v.delete(l),R0(a,m)}var O0;O0=function(a,l,m){if(a!==null)if(a.memoizedProps!==l.pendingProps||ms.current)gs=!0;else{if((a.lanes&m)===0&&(l.flags&128)===0)return gs=!1,iC(a,l,m);gs=(a.flags&131072)!==0}else gs=!1,Gt&&(l.flags&1048576)!==0&&mv(l,iu,l.index);switch(l.lanes=0,l.tag){case 2:var v=l.type;yu(a,l),a=l.pendingProps;var _=ro(l,qn.current);ho(l,m),_=ef(null,l,v,a,_,m);var I=tf();return l.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,ps(v)?(I=!0,tu(l)):I=!1,l.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,qh(l),_.updater=xu,l.stateNode=_,_._reactInternals=l,lf(l,v,a,m),l=hf(null,l,v,!0,I,m)):(l.tag=0,Gt&&I&&zh(l),ns(null,l,_,m),l=l.child),l;case 16:v=l.elementType;e:{switch(yu(a,l),a=l.pendingProps,_=v._init,v=_(v._payload),l.type=v,_=l.tag=yC(v),a=pi(v,a),_){case 0:l=df(null,l,v,a,m);break e;case 1:l=o0(null,l,v,a,m);break e;case 11:l=n0(null,l,v,a,m);break e;case 14:l=s0(null,l,v,pi(v.type,a),m);break e}throw Error(n(306,v,""))}return l;case 0:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:pi(v,_),df(a,l,v,_,m);case 1:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:pi(v,_),o0(a,l,v,_,m);case 3:e:{if(l0(l),a===null)throw Error(n(387));v=l.pendingProps,I=l.memoizedState,_=I.element,jv(a,l),uu(l,v,null,m);var q=l.memoizedState;if(v=q.element,I.isDehydrated)if(I={element:v,isDehydrated:!1,cache:q.cache,pendingSuspenseBoundaries:q.pendingSuspenseBoundaries,transitions:q.transitions},l.updateQueue.baseState=I,l.memoizedState=I,l.flags&256){_=mo(Error(n(423)),l),l=c0(a,l,v,m,_);break e}else if(v!==_){_=mo(Error(n(424)),l),l=c0(a,l,v,m,_);break e}else for(As=Sr(l.stateNode.containerInfo.firstChild),Cs=l,Gt=!0,mi=null,m=kv(l,null,v,m),l.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(lo(),v===_){l=rr(a,l,m);break e}ns(a,l,v,m)}l=l.child}return l;case 5:return _v(l),a===null&&Fh(l),v=l.type,_=l.pendingProps,I=a!==null?a.memoizedProps:null,q=_.children,Th(v,_)?q=null:I!==null&&Th(v,I)&&(l.flags|=32),a0(a,l),ns(a,l,q,m),l.child;case 6:return a===null&&Fh(l),null;case 13:return u0(a,l,m);case 4:return Gh(l,l.stateNode.containerInfo),v=l.pendingProps,a===null?l.child=co(l,null,v,m):ns(a,l,v,m),l.child;case 11:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:pi(v,_),n0(a,l,v,_,m);case 7:return ns(a,l,l.pendingProps,m),l.child;case 8:return ns(a,l,l.pendingProps.children,m),l.child;case 12:return ns(a,l,l.pendingProps.children,m),l.child;case 10:e:{if(v=l.type._context,_=l.pendingProps,I=l.memoizedProps,q=_.value,Ft(ou,v._currentValue),v._currentValue=q,I!==null)if(fi(I.value,q)){if(I.children===_.children&&!ms.current){l=rr(a,l,m);break e}}else for(I=l.child,I!==null&&(I.return=l);I!==null;){var J=I.dependencies;if(J!==null){q=I.child;for(var ae=J.firstContext;ae!==null;){if(ae.context===v){if(I.tag===1){ae=ir(-1,m&-m),ae.tag=2;var ge=I.updateQueue;if(ge!==null){ge=ge.shared;var Ae=ge.pending;Ae===null?ae.next=ae:(ae.next=Ae.next,Ae.next=ae),ge.pending=ae}}I.lanes|=m,ae=I.alternate,ae!==null&&(ae.lanes|=m),Wh(I.return,m,l),J.lanes|=m;break}ae=ae.next}}else if(I.tag===10)q=I.type===l.type?null:I.child;else if(I.tag===18){if(q=I.return,q===null)throw Error(n(341));q.lanes|=m,J=q.alternate,J!==null&&(J.lanes|=m),Wh(q,m,l),q=I.sibling}else q=I.child;if(q!==null)q.return=I;else for(q=I;q!==null;){if(q===l){q=null;break}if(I=q.sibling,I!==null){I.return=q.return,q=I;break}q=q.return}I=q}ns(a,l,_.children,m),l=l.child}return l;case 9:return _=l.type,v=l.pendingProps.children,ho(l,m),_=Ks(_),v=v(_),l.flags|=1,ns(a,l,v,m),l.child;case 14:return v=l.type,_=pi(v,l.pendingProps),_=pi(v.type,_),s0(a,l,v,_,m);case 15:return i0(a,l,l.type,l.pendingProps,m);case 17:return v=l.type,_=l.pendingProps,_=l.elementType===v?_:pi(v,_),yu(a,l),l.tag=1,ps(v)?(a=!0,tu(l)):a=!1,ho(l,m),Kv(l,v,_),lf(l,v,_,m),hf(null,l,v,!0,a,m);case 19:return h0(a,l,m);case 22:return r0(a,l,m)}throw Error(n(156,l.tag))};function P0(a,l){return _s(a,l)}function vC(a,l,m,v){this.tag=a,this.key=m,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=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qs(a,l,m,v){return new vC(a,l,m,v)}function $f(a){return a=a.prototype,!(!a||!a.isReactComponent)}function yC(a){if(typeof a=="function")return $f(a)?1:0;if(a!=null){if(a=a.$$typeof,a===F)return 11;if(a===M)return 14}return 2}function Pr(a,l){var m=a.alternate;return m===null?(m=Qs(a.tag,l,a.key,a.mode),m.elementType=a.elementType,m.type=a.type,m.stateNode=a.stateNode,m.alternate=a,a.alternate=m):(m.pendingProps=l,m.type=a.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=a.flags&14680064,m.childLanes=a.childLanes,m.lanes=a.lanes,m.child=a.child,m.memoizedProps=a.memoizedProps,m.memoizedState=a.memoizedState,m.updateQueue=a.updateQueue,l=a.dependencies,m.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},m.sibling=a.sibling,m.index=a.index,m.ref=a.ref,m}function Iu(a,l,m,v,_,I){var q=2;if(v=a,typeof a=="function")$f(a)&&(q=1);else if(typeof a=="string")q=5;else e:switch(a){case O:return va(m.children,_,I,l);case W:q=8,_|=8;break;case B:return a=Qs(12,m,l,_|2),a.elementType=B,a.lanes=I,a;case A:return a=Qs(13,m,l,_),a.elementType=A,a.lanes=I,a;case T:return a=Qs(19,m,l,_),a.elementType=T,a.lanes=I,a;case V:return Tu(m,_,I,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case U:q=10;break e;case D:q=9;break e;case F:q=11;break e;case M:q=14;break e;case P:q=16,v=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return l=Qs(q,m,l,_),l.elementType=a,l.type=v,l.lanes=I,l}function va(a,l,m,v){return a=Qs(7,a,v,l),a.lanes=m,a}function Tu(a,l,m,v){return a=Qs(22,a,v,l),a.elementType=V,a.lanes=m,a.stateNode={isHidden:!1},a}function Mf(a,l,m){return a=Qs(6,a,null,l),a.lanes=m,a}function Rf(a,l,m){return l=Qs(4,a.children!==null?a.children:[],a.key,l),l.lanes=m,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function bC(a,l,m,v,_){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=es(0),this.expirationTimes=es(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=es(0),this.identifierPrefix=v,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function Of(a,l,m,v,_,I,q,J,ae){return a=new bC(a,l,m,J,ae),l===1?(l=1,I===!0&&(l|=8)):l=0,I=Qs(3,null,null,l),a.current=I,I.stateNode=a,I.memoizedState={element:v,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},qh(I),a}function kC(a,l,m){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:v==null?null:""+v,children:a,containerInfo:l,implementation:m}}function z0(a){if(!a)return Er;a=a._reactInternals;e:{if(Wn(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(ps(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(n(171))}if(a.tag===1){var m=a.type;if(ps(m))return dv(a,m,l)}return l}function L0(a,l,m,v,_,I,q,J,ae){return a=Of(m,v,!0,a,_,I,q,J,ae),a.context=z0(null),m=a.current,v=ss(),_=Rr(m),I=ir(v,_),I.callback=l??null,Ir(m,I,_),a.current.lanes=_,ds(a,_,v),vs(a,v),a}function $u(a,l,m,v){var _=l.current,I=ss(),q=Rr(_);return m=z0(m),l.context===null?l.context=m:l.pendingContext=m,l=ir(I,q),l.payload={element:a},v=v===void 0?null:v,v!==null&&(l.callback=v),a=Ir(_,l,q),a!==null&&(vi(a,_,q,I),cu(a,_,q)),q}function Mu(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 D0(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var m=a.retryLane;a.retryLane=m!==0&&m<l?m:l}}function Pf(a,l){D0(a,l),(a=a.alternate)&&D0(a,l)}function NC(){return null}var F0=typeof reportError=="function"?reportError:function(a){console.error(a)};function zf(a){this._internalRoot=a}Ru.prototype.render=zf.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(n(409));$u(a,l,null,null)},Ru.prototype.unmount=zf.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;pa(function(){$u(null,a,null,null)}),l[Ji]=null}};function Ru(a){this._internalRoot=a}Ru.prototype.unstable_scheduleHydration=function(a){if(a){var l=Ki();a={blockedOn:null,target:a,priority:l};for(var m=0;m<xn.length&&l!==0&&l<xn[m].priority;m++);xn.splice(m,0,a),m===0&&Ka(a)}};function Lf(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Ou(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function U0(){}function jC(a,l,m,v,_){if(_){if(typeof v=="function"){var I=v;v=function(){var ge=Mu(q);I.call(ge)}}var q=L0(l,v,a,0,null,!1,!1,"",U0);return a._reactRootContainer=q,a[Ji]=q.current,dl(a.nodeType===8?a.parentNode:a),pa(),q}for(;_=a.lastChild;)a.removeChild(_);if(typeof v=="function"){var J=v;v=function(){var ge=Mu(ae);J.call(ge)}}var ae=Of(a,0,!1,null,null,!1,!1,"",U0);return a._reactRootContainer=ae,a[Ji]=ae.current,dl(a.nodeType===8?a.parentNode:a),pa(function(){$u(l,ae,m,v)}),ae}function Pu(a,l,m,v,_){var I=m._reactRootContainer;if(I){var q=I;if(typeof _=="function"){var J=_;_=function(){var ae=Mu(q);J.call(ae)}}$u(l,q,a,_)}else q=jC(m,l,a,_,v);return Mu(q)}hs=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var m=Ws(l.pendingLanes);m!==0&&(Vs(l,m|1),vs(l,Rt()),(Nt&6)===0&&(xo=Rt()+500,Cr()))}break;case 13:pa(function(){var v=sr(a,1);if(v!==null){var _=ss();vi(v,a,1,_)}}),Pf(a,1)}},zt=function(a){if(a.tag===13){var l=sr(a,134217728);if(l!==null){var m=ss();vi(l,a,134217728,m)}Pf(a,134217728)}},ft=function(a){if(a.tag===13){var l=Rr(a),m=sr(a,l);if(m!==null){var v=ss();vi(m,a,l,v)}Pf(a,l)}},Ki=function(){return vt},ts=function(a,l){var m=vt;try{return vt=a,l()}finally{vt=m}},oi=function(a,l,m){switch(l){case"input":if(Ce(a,m),l=m.name,m.type==="radio"&&l!=null){for(m=a;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<m.length;l++){var v=m[l];if(v!==a&&v.form===a.form){var _=Jc(v);if(!_)throw Error(n(90));Se(v),Ce(v,_)}}}break;case"textarea":dn(a,m);break;case"select":l=m.value,l!=null&&Pt(a,!!m.multiple,l,!1)}},Le=Af,tt=pa;var wC={usingClientEntryPoint:!1,Events:[ml,so,Jc,ie,ye,Af]},Cl={findFiberByHostInstance:oa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},SC={bundleType:Cl.bundleType,version:Cl.version,rendererPackageName:Cl.rendererPackageName,rendererConfig:Cl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=br(a),a===null?null:a.stateNode},findFiberByHostInstance:Cl.findFiberByHostInstance||NC,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 zu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zu.isDisabled&&zu.supportsFiber)try{lt=zu.inject(SC),dt=zu}catch{}}return ys.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wC,ys.createPortal=function(a,l){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Lf(l))throw Error(n(200));return kC(a,l,null,m)},ys.createRoot=function(a,l){if(!Lf(a))throw Error(n(299));var m=!1,v="",_=F0;return l!=null&&(l.unstable_strictMode===!0&&(m=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(_=l.onRecoverableError)),l=Of(a,1,!1,null,null,m,!1,v,_),a[Ji]=l.current,dl(a.nodeType===8?a.parentNode:a),new zf(l)},ys.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=br(l),a=a===null?null:a.stateNode,a},ys.flushSync=function(a){return pa(a)},ys.hydrate=function(a,l,m){if(!Ou(l))throw Error(n(200));return Pu(null,a,l,!0,m)},ys.hydrateRoot=function(a,l,m){if(!Lf(a))throw Error(n(405));var v=m!=null&&m.hydratedSources||null,_=!1,I="",q=F0;if(m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(I=m.identifierPrefix),m.onRecoverableError!==void 0&&(q=m.onRecoverableError)),l=L0(l,null,a,1,m??null,_,!1,I,q),a[Ji]=l.current,dl(a),v)for(a=0;a<v.length;a++)m=v[a],_=m._getVersion,_=_(m._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[m,_]:l.mutableSourceEagerHydrationData.push(m,_);return new Ru(l)},ys.render=function(a,l,m){if(!Ou(l))throw Error(n(200));return Pu(null,a,l,!1,m)},ys.unmountComponentAtNode=function(a){if(!Ou(a))throw Error(n(40));return a._reactRootContainer?(pa(function(){Pu(null,null,a,!1,function(){a._reactRootContainer=null,a[Ji]=null})}),!0):!1},ys.unstable_batchedUpdates=Af,ys.unstable_renderSubtreeIntoContainer=function(a,l,m,v){if(!Ou(m))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Pu(a,l,m,!1,v)},ys.version="18.3.1-next-f1338f8080-20240426",ys}var X0;function MN(){if(X0)return Bf.exports;X0=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(),Bf.exports=RC(),Bf.exports}var Q0;function OC(){if(Q0)return Lu;Q0=1;var e=MN();return Lu.createRoot=e.createRoot,Lu.hydrateRoot=e.hydrateRoot,Lu}var PC=OC(),Wr,Oo,Po;class Fi{constructor(t){Lt(this,Wr);Lt(this,Oo,new Set);Lt(this,Po,!1);ct(this,"get",()=>ze(this,Wr));ct(this,"subscribe",t=>(ze(this,Oo).add(t),()=>{ze(this,Oo).delete(t)}));Wt(this,Wr,t)}set(t){const n=typeof t=="function"?t(ze(this,Wr)):t;Object.is(n,ze(this,Wr))||(Wt(this,Wr,n),!ze(this,Po)&&(Wt(this,Po,!0),queueMicrotask(()=>{Wt(this,Po,!1);for(const i of[...ze(this,Oo)])i()})))}}Wr=new WeakMap,Oo=new WeakMap,Po=new WeakMap;var J0;function be(e,t,n){function i(u,d){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:d,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,d);const h=c.prototype,f=Object.keys(h);for(let g=0;g<f.length;g++){const p=f[g];p in u||(u[p]=h[p].bind(u))}}const r=(n==null?void 0:n.Parent)??Object;class o extends r{}Object.defineProperty(o,"name",{value:e});function c(u){var d;const h=n!=null&&n.Parent?new o:this;i(h,u),(d=h._zod).deferred??(d.deferred=[]);for(const f of h._zod.deferred)f();return h}return Object.defineProperty(c,"init",{value:i}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>{var d,h;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(h=(d=u==null?void 0:u._zod)==null?void 0:d.traits)==null?void 0:h.has(e)}}),Object.defineProperty(c,"name",{value:e}),c}class Co extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class RN extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(J0=globalThis).__zod_globalConfig??(J0.__zod_globalConfig={});const gg=globalThis.__zod_globalConfig;function pr(e){return gg}function ON(e){const t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function tp(e,t){return typeof t=="bigint"?t.toString():t}function Bd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function xg(e){return e==null}function vg(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function zC(e,t){const n=e/t,i=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}const ey=Symbol("evaluating");function $t(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==ey)return i===void 0&&(i=ey,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function Za(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function na(...e){const t={};for(const n of e){const i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function ty(e){return JSON.stringify(e)}function LC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const PN="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const DC=Bd(()=>{var e;if(gg.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 Bo(e){if(dc(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(dc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function zN(e){return Bo(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const FC=new Set(["string","number","symbol"]);function Ho(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sa(e,t,n){const i=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(i._zod.parent=e),i}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 UC(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const BC={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 HC(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=na(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 Za(this,"shape",c),c},checks:[]});return sa(e,o)}function ZC(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=na(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 Za(this,"shape",c),c},checks:[]});return sa(e,o)}function WC(e,t){if(!Bo(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 r=na(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Za(this,"shape",o),o}});return sa(e,r)}function VC(e,t){if(!Bo(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=na(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return Za(this,"shape",i),i}});return sa(e,n)}function qC(e,t){var i;if((i=e._zod.def.checks)!=null&&i.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=na(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return Za(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return sa(e,n)}function GC(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=na(t._zod.def,{get shape(){const u=t._zod.def.shape,d={...u};if(n)for(const h in n){if(!(h in u))throw new Error(`Unrecognized key: "${h}"`);n[h]&&(d[h]=e?new e({type:"optional",innerType:u[h]}):u[h])}else for(const h in u)d[h]=e?new e({type:"optional",innerType:u[h]}):u[h];return Za(this,"shape",d),d},checks:[]});return sa(t,c)}function KC(e,t,n){const i=na(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};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:r[c]}))}else for(const c in r)o[c]=new e({type:"nonoptional",innerType:r[c]});return Za(this,"shape",o),o}});return sa(t,i)}function So(e,t=0){var n;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((n=e.issues[i])==null?void 0:n.continue)!==!0)return!0;return!1}function YC(e,t=0){var n;if(e.aborted===!0)return!0;for(let i=t;i<e.issues.length;i++)if(((n=e.issues[i])==null?void 0:n.continue)===!1)return!0;return!1}function _o(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function Du(e){return typeof e=="string"?e:e==null?void 0:e.message}function gr(e,t,n){var d,h,f,g,p,x;const i=e.message?e.message:Du((f=(h=(d=e.inst)==null?void 0:d._zod.def)==null?void 0:h.error)==null?void 0:f.call(h,e))??Du((g=t==null?void 0:t.error)==null?void 0:g.call(t,e))??Du((p=n.customError)==null?void 0:p.call(n,e))??Du((x=n.localeError)==null?void 0:x.call(n,e))??"Invalid input",{inst:r,continue:o,input:c,...u}=e;return u.path??(u.path=[]),u.message=i,t!=null&&t.reportInput&&(u.input=c),u}function yg(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function hc(...e){const[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}const LN=(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,tp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},DN=be("$ZodError",LN),FN=be("$ZodError",LN,{Parent:Error});function XC(e,t=n=>n.message){const n={},i=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):i.push(t(r));return{formErrors:i,fieldErrors:n}}function QC(e,t=n=>n.message){const n={_errors:[]},i=(r,o=[])=>{for(const c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>i({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")i({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")i({issues:c.issues},[...o,...c.path]);else{const u=[...o,...c.path];if(u.length===0)n._errors.push(t(c));else{let d=n,h=0;for(;h<u.length;){const f=u[h];h===u.length-1?(d[f]=d[f]||{_errors:[]},d[f]._errors.push(t(c))):d[f]=d[f]||{_errors:[]},d=d[f],h++}}}};return i(e),n}const bg=e=>(t,n,i,r)=>{const o=i?{...i,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new Co;if(c.issues.length){const u=new((r==null?void 0:r.Err)??e)(c.issues.map(d=>gr(d,o,pr())));throw PN(u,r==null?void 0:r.callee),u}return c.value},kg=e=>async(t,n,i,r)=>{const o=i?{...i,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((r==null?void 0:r.Err)??e)(c.issues.map(d=>gr(d,o,pr())));throw PN(u,r==null?void 0:r.callee),u}return c.value},Hd=e=>(t,n,i)=>{const r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new Co;return o.issues.length?{success:!1,error:new(e??DN)(o.issues.map(c=>gr(c,r,pr())))}:{success:!0,data:o.value}},JC=Hd(FN),Zd=e=>async(t,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>gr(c,r,pr())))}:{success:!0,data:o.value}},eA=Zd(FN),tA=e=>(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return bg(e)(t,n,r)},nA=e=>(t,n,i)=>bg(e)(t,n,i),sA=e=>async(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return kg(e)(t,n,r)},iA=e=>async(t,n,i)=>kg(e)(t,n,i),rA=e=>(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Hd(e)(t,n,r)},aA=e=>(t,n,i)=>Hd(e)(t,n,i),oA=e=>async(t,n,i)=>{const r=i?{...i,direction:"backward"}:{direction:"backward"};return Zd(e)(t,n,r)},lA=e=>async(t,n,i)=>Zd(e)(t,n,i),cA=/^[cC][0-9a-z]{6,}$/,uA=/^[0-9a-z]+$/,dA=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,hA=/^[0-9a-vA-V]{20}$/,fA=/^[A-Za-z0-9]{27}$/,mA=/^[a-zA-Z0-9_-]{21}$/,pA=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,gA=/^([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})$/,ny=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)$/,xA=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,vA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function yA(){return new RegExp(vA,"u")}const bA=/^(?:(?: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])$/,kA=/^(([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}|:))$/,NA=/^((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])$/,jA=/^(([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])$/,wA=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,UN=/^[A-Za-z0-9_-]*$/,SA=/^https?$/,_A=/^\+[1-9]\d{6,14}$/,BN="(?:(?:\\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])))",EA=new RegExp(`^${BN}$`);function HN(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 CA(e){return new RegExp(`^${HN(e)}$`)}function AA(e){const t=HN({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${n.join("|")})`;return new RegExp(`^${BN}T(?:${i})$`)}const IA=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}$`)},TA=/^-?\d+$/,ZN=/^-?\d+(?:\.\d+)?$/,$A=/^(?:true|false)$/i,MA=/^null$/i,RA=/^[^A-Z]*$/,OA=/^[^a-z]*$/,ws=be("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),WN={number:"number",bigint:"bigint",object:"date"},VN=be("$ZodCheckLessThan",(e,t)=>{ws.init(e,t);const n=WN[typeof t.value];e._zod.onattach.push(i=>{const r=i._zod.bag,o=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),qN=be("$ZodCheckGreaterThan",(e,t)=>{ws.init(e,t);const n=WN[typeof t.value];e._zod.onattach.push(i=>{const r=i._zod.bag,o=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),PA=be("$ZodCheckMultipleOf",(e,t)=>{ws.init(e,t),e._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.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):zC(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})}}),zA=be("$ZodCheckNumberFormat",(e,t)=>{var c;ws.init(e,t),t.format=t.format||"float64";const n=(c=t.format)==null?void 0:c.includes("int"),i=n?"int":"number",[r,o]=BC[t.format];e._zod.onattach.push(u=>{const d=u._zod.bag;d.format=t.format,d.minimum=r,d.maximum=o,n&&(d.pattern=TA)}),e._zod.check=u=>{const d=u.value;if(n){if(!Number.isInteger(d)){u.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:d,inst:e});return}if(!Number.isSafeInteger(d)){d>0?u.issues.push({input:d,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):u.issues.push({input:d,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}d<r&&u.issues.push({origin:"number",input:d,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),d>o&&u.issues.push({origin:"number",input:d,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),LA=be("$ZodCheckMaxLength",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=i=>{const r=i.value;return!xg(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{const r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{const r=i.value;if(r.length<=t.maximum)return;const c=yg(r);i.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),DA=be("$ZodCheckMinLength",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=i=>{const r=i.value;return!xg(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{const r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{const r=i.value;if(r.length>=t.minimum)return;const c=yg(r);i.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),FA=be("$ZodCheckLengthEquals",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=i=>{const r=i.value;return!xg(r)&&r.length!==void 0}),e._zod.onattach.push(i=>{const r=i._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=i=>{const r=i.value,o=r.length;if(o===t.length)return;const c=yg(r),u=o>t.length;i.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Wd=be("$ZodCheckStringFormat",(e,t)=>{var n,i;ws.init(e,t),e._zod.onattach.push(r=>{const o=r._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=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),UA=be("$ZodCheckRegex",(e,t)=>{Wd.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})}}),BA=be("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=RA),Wd.init(e,t)}),HA=be("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=OA),Wd.init(e,t)}),ZA=be("$ZodCheckIncludes",(e,t)=>{ws.init(e,t);const n=Ho(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),WA=be("$ZodCheckStartsWith",(e,t)=>{ws.init(e,t);const n=new RegExp(`^${Ho(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),VA=be("$ZodCheckEndsWith",(e,t)=>{ws.init(e,t);const n=new RegExp(`.*${Ho(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{const r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}}),qA=be("$ZodCheckOverwrite",(e,t)=>{ws.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class GA{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 i=t.split(`
41
+ `).filter(c=>c),r=Math.min(...i.map(c=>c.length-c.trimStart().length)),o=i.map(c=>c.slice(r)).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,r=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...n,r.join(`
42
+ `))}}const KA={major:4,minor:4,patch:3},Yt=be("$ZodType",(e,t)=>{var r;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=KA;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const o of i)for(const c of o._zod.onattach)c(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),(r=e._zod.deferred)==null||r.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,d,h)=>{let f=So(u),g;for(const p of d){if(p._zod.def.when){if(YC(u)||!p._zod.def.when(u))continue}else if(f)continue;const x=u.issues.length,b=p._zod.check(u);if(b instanceof Promise&&(h==null?void 0:h.async)===!1)throw new Co;if(g||b instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await b,u.issues.length!==x&&(f||(f=So(u,x)))});else{if(u.issues.length===x)continue;f||(f=So(u,x))}}return g?g.then(()=>u):u},c=(u,d,h)=>{if(So(u))return u.aborted=!0,u;const f=o(d,i,h);if(f instanceof Promise){if(h.async===!1)throw new Co;return f.then(g=>e._zod.parse(g,h))}return e._zod.parse(f,h)};e._zod.run=(u,d)=>{if(d.skipChecks)return e._zod.parse(u,d);if(d.direction==="backward"){const f=e._zod.parse({value:u.value,issues:[]},{...d,skipChecks:!0});return f instanceof Promise?f.then(g=>c(g,u,d)):c(f,u,d)}const h=e._zod.parse(u,d);if(h instanceof Promise){if(d.async===!1)throw new Co;return h.then(f=>o(f,i,d))}return o(h,i,d)}}$t(e,"~standard",()=>({validate:o=>{var c;try{const u=JC(e,o);return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}}catch{return eA(e,o).then(d=>{var h;return d.success?{value:d.data}:{issues:(h=d.error)==null?void 0:h.issues}})}},vendor:"zod",version:1}))}),Ng=be("$ZodString",(e,t)=>{var n;Yt.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??IA(e._zod.bag),e._zod.parse=(i,r)=>{if(t.coerce)try{i.value=String(i.value)}catch{}return typeof i.value=="string"||i.issues.push({expected:"string",code:"invalid_type",input:i.value,inst:e}),i}}),Xt=be("$ZodStringFormat",(e,t)=>{Wd.init(e,t),Ng.init(e,t)}),YA=be("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=gA),Xt.init(e,t)}),XA=be("$ZodUUID",(e,t)=>{if(t.version){const i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ny(i))}else t.pattern??(t.pattern=ny());Xt.init(e,t)}),QA=be("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=xA),Xt.init(e,t)}),JA=be("$ZodURL",(e,t)=>{Xt.init(e,t),e._zod.check=n=>{var i;try{const r=n.value.trim();if(!t.normalize&&((i=t.protocol)==null?void 0:i.source)===SA.source&&!/^https?:\/\//i.test(r)){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(r);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=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),eI=be("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=yA()),Xt.init(e,t)}),tI=be("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=mA),Xt.init(e,t)}),nI=be("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cA),Xt.init(e,t)}),sI=be("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=uA),Xt.init(e,t)}),iI=be("$ZodULID",(e,t)=>{t.pattern??(t.pattern=dA),Xt.init(e,t)}),rI=be("$ZodXID",(e,t)=>{t.pattern??(t.pattern=hA),Xt.init(e,t)}),aI=be("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=fA),Xt.init(e,t)}),oI=be("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=AA(t)),Xt.init(e,t)}),lI=be("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=EA),Xt.init(e,t)}),cI=be("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=CA(t)),Xt.init(e,t)}),uI=be("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pA),Xt.init(e,t)}),dI=be("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=bA),Xt.init(e,t),e._zod.bag.format="ipv4"}),hI=be("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=kA),Xt.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})}}}),fI=be("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=NA),Xt.init(e,t)}),mI=be("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=jA),Xt.init(e,t),e._zod.check=n=>{const i=n.value.split("/");try{if(i.length!==2)throw new Error;const[r,o]=i;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://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function GN(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const pI=be("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=wA),Xt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{GN(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function gI(e){if(!UN.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return GN(n)}const xI=be("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=UN),Xt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{gI(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),vI=be("$ZodE164",(e,t)=>{t.pattern??(t.pattern=_A),Xt.init(e,t)});function yI(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const bI=be("$ZodJWT",(e,t)=>{Xt.init(e,t),e._zod.check=n=>{yI(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),KN=be("$ZodNumber",(e,t)=>{Yt.init(e,t),e._zod.pattern=e._zod.bag.pattern??ZN,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),kI=be("$ZodNumberFormat",(e,t)=>{zA.init(e,t),KN.init(e,t)}),NI=be("$ZodBoolean",(e,t)=>{Yt.init(e,t),e._zod.pattern=$A,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),jI=be("$ZodNull",(e,t)=>{Yt.init(e,t),e._zod.pattern=MA,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),wI=be("$ZodUnknown",(e,t)=>{Yt.init(e,t),e._zod.parse=n=>n}),SI=be("$ZodNever",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function sy(e,t,n){e.issues.length&&t.issues.push(..._o(n,e.issues)),t.value[n]=e.value}const _I=be("$ZodArray",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const o=[];for(let c=0;c<r.length;c++){const u=r[c],d=t.element._zod.run({value:u,issues:[]},i);d instanceof Promise?o.push(d.then(h=>sy(h,n,c))):sy(d,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function vd(e,t,n,i,r,o){const c=n in i;if(e.issues.length){if(r&&o&&!c)return;t.issues.push(..._o(n,e.issues))}if(!c&&!r){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 YN(e){var i,r,o,c;const t=Object.keys(e.shape);for(const u of t)if(!((c=(o=(r=(i=e.shape)==null?void 0:i[u])==null?void 0:r._zod)==null?void 0:o.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=UC(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function XN(e,t,n,i,r,o){const c=[],u=r.keySet,d=r.catchall._zod,h=d.def.type,f=d.optin==="optional",g=d.optout==="optional";for(const p in t){if(p==="__proto__"||u.has(p))continue;if(h==="never"){c.push(p);continue}const x=d.run({value:t[p],issues:[]},i);x instanceof Promise?e.push(x.then(b=>vd(b,n,p,t,f,g))):vd(x,n,p,t,f,g)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const EI=be("$ZodObject",(e,t)=>{Yt.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const d={...u};return Object.defineProperty(t,"shape",{value:d}),d}})}const i=Bd(()=>YN(t));$t(e._zod,"propValues",()=>{const u=t.shape,d={};for(const h in u){const f=u[h]._zod;if(f.values){d[h]??(d[h]=new Set);for(const g of f.values)d[h].add(g)}}return d});const r=dc,o=t.catchall;let c;e._zod.parse=(u,d)=>{c??(c=i.value);const h=u.value;if(!r(h))return u.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),u;u.value={};const f=[],g=c.shape;for(const p of c.keys){const x=g[p],b=x._zod.optin==="optional",k=x._zod.optout==="optional",w=x._zod.run({value:h[p],issues:[]},d);w instanceof Promise?f.push(w.then(j=>vd(j,u,p,h,b,k))):vd(w,u,p,h,b,k)}return o?XN(f,h,u,d,i.value,e):f.length?Promise.all(f).then(()=>u):u}}),CI=be("$ZodObjectJIT",(e,t)=>{EI.init(e,t);const n=e._zod.parse,i=Bd(()=>YN(t)),r=p=>{var N,C;const x=new GA(["shape","payload","ctx"]),b=i.value,k=L=>{const $=ty(L);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};x.write("const input = payload.value;");const w=Object.create(null);let j=0;for(const L of b.keys)w[L]=`key_${j++}`;x.write("const newResult = {};");for(const L of b.keys){const $=w[L],O=ty(L),W=p[L],B=((N=W==null?void 0:W._zod)==null?void 0:N.optin)==="optional",U=((C=W==null?void 0:W._zod)==null?void 0:C.optout)==="optional";x.write(`const ${$} = ${k(L)};`),B&&U?x.write(`
43
+ if (${$}.issues.length) {
44
+ if (${O} in input) {
45
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
46
+ ...iss,
47
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
48
+ })));
49
+ }
50
+ }
51
+
52
+ if (${$}.value === undefined) {
53
+ if (${O} in input) {
54
+ newResult[${O}] = undefined;
55
+ }
56
+ } else {
57
+ newResult[${O}] = ${$}.value;
58
+ }
59
+
60
+ `):B?x.write(`
61
+ if (${$}.issues.length) {
62
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
63
+ ...iss,
64
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
65
+ })));
66
+ }
67
+
68
+ if (${$}.value === undefined) {
69
+ if (${O} in input) {
70
+ newResult[${O}] = undefined;
71
+ }
72
+ } else {
73
+ newResult[${O}] = ${$}.value;
74
+ }
75
+
76
+ `):x.write(`
77
+ const ${$}_present = ${O} in input;
78
+ if (${$}.issues.length) {
79
+ payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
80
+ ...iss,
81
+ path: iss.path ? [${O}, ...iss.path] : [${O}]
82
+ })));
83
+ }
84
+ if (!${$}_present && !${$}.issues.length) {
85
+ payload.issues.push({
86
+ code: "invalid_type",
87
+ expected: "nonoptional",
88
+ input: undefined,
89
+ path: [${O}]
90
+ });
91
+ }
92
+
93
+ if (${$}_present) {
94
+ if (${$}.value === undefined) {
95
+ newResult[${O}] = undefined;
96
+ } else {
97
+ newResult[${O}] = ${$}.value;
98
+ }
99
+ }
100
+
101
+ `)}x.write("payload.value = newResult;"),x.write("return payload;");const E=x.compile();return(L,$)=>E(p,L,$)};let o;const c=dc,u=!gg.jitless,h=u&&DC.value,f=t.catchall;let g;e._zod.parse=(p,x)=>{g??(g=i.value);const b=p.value;return c(b)?u&&h&&(x==null?void 0:x.async)===!1&&x.jitless!==!0?(o||(o=r(t.shape)),p=o(p,x),f?XN([],b,p,x,g,e):p):n(p,x):(p.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),p)}});function iy(e,t,n,i){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const r=e.filter(o=>!So(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>gr(c,i,pr())))}),t)}const QN=be("$ZodUnion",(e,t)=>{Yt.init(e,t),$t(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),$t(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),$t(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),$t(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>vg(r.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let o=!1;const c=[];for(const u of t.options){const d=u._zod.run({value:i.value,issues:[]},r);if(d instanceof Promise)c.push(d),o=!0;else{if(d.issues.length===0)return d;c.push(d)}}return o?Promise.all(c).then(u=>iy(u,i,e,r)):iy(c,i,e,r)}}),AI=be("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,QN.init(e,t);const n=e._zod.parse;$t(e._zod,"propValues",()=>{const r={};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,d]of Object.entries(c)){r[u]||(r[u]=new Set);for(const h of d)r[u].add(h)}}return r});const i=Bd(()=>{var c;const r=t.options,o=new Map;for(const u of r){const d=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!d||d.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const h of d){if(o.has(h))throw new Error(`Duplicate discriminator value "${String(h)}"`);o.set(h,u)}}return o});e._zod.parse=(r,o)=>{const c=r.value;if(!dc(c))return r.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),r;const u=i.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(r,o):t.unionFallback||o.direction==="backward"?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()),input:c,path:[t.discriminator],inst:e}),r)}}),II=be("$ZodIntersection",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>{const r=n.value,o=t.left._zod.run({value:r,issues:[]},i),c=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([d,h])=>ry(n,d,h)):ry(n,o,c)}});function np(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(Bo(e)&&Bo(t)){const n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};for(const o of i){const c=np(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};r[o]=c.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const r=e[i],o=t[i],c=np(r,o);if(!c.valid)return{valid:!1,mergeErrorPath:[i,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ry(e,t,n){const i=new Map;let r;for(const u of t.issues)if(u.code==="unrecognized_keys"){r??(r=u);for(const d of u.keys)i.has(d)||i.set(d,{}),i.get(d).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const d of u.keys)i.has(d)||i.set(d,{}),i.get(d).r=!0;else e.issues.push(u);const o=[...i].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&r&&e.issues.push({...r,keys:o}),So(e))return e;const c=np(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 TI=be("$ZodRecord",(e,t)=>{Yt.init(e,t),e._zod.parse=(n,i)=>{const r=n.value;if(!Bo(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const h of c)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){u.add(typeof h=="number"?h.toString():h);const f=t.keyType._zod.run({value:h,issues:[]},i);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(x=>gr(x,i,pr())),input:h,path:[h],inst:e});continue}const g=f.value,p=t.valueType._zod.run({value:r[h],issues:[]},i);p instanceof Promise?o.push(p.then(x=>{x.issues.length&&n.issues.push(..._o(h,x.issues)),n.value[g]=x.value})):(p.issues.length&&n.issues.push(..._o(h,p.issues)),n.value[g]=p.value)}let d;for(const h in r)u.has(h)||(d=d??[],d.push(h));d&&d.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:d})}else{n.value={};for(const u of Reflect.ownKeys(r)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,u))continue;let d=t.keyType._zod.run({value:u,issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&ZN.test(u)&&d.issues.length){const g=t.keyType._zod.run({value:Number(u),issues:[]},i);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(d=g)}if(d.issues.length){t.mode==="loose"?n.value[u]=r[u]:n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(g=>gr(g,i,pr())),input:u,path:[u],inst:e});continue}const f=t.valueType._zod.run({value:r[u],issues:[]},i);f instanceof Promise?o.push(f.then(g=>{g.issues.length&&n.issues.push(..._o(u,g.issues)),n.value[d.value]=g.value})):(f.issues.length&&n.issues.push(..._o(u,f.issues)),n.value[d.value]=f.value)}}return o.length?Promise.all(o).then(()=>n):n}}),$I=be("$ZodEnum",(e,t)=>{Yt.init(e,t);const n=ON(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(r=>FC.has(typeof r)).map(r=>typeof r=="string"?Ho(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const c=r.value;return i.has(c)||r.issues.push({code:"invalid_value",values:n,input:c,inst:e}),r}}),MI=be("$ZodLiteral",(e,t)=>{if(Yt.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(i=>typeof i=="string"?Ho(i):i?Ho(i.toString()):String(i)).join("|")})$`),e._zod.parse=(i,r)=>{const o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),RI=be("$ZodTransform",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new RN(e.constructor.name);const r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(c=>(n.value=c,n.fallback=!0,n));if(r instanceof Promise)throw new Co;return n.value=r,n.fallback=!0,n}});function ay(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const JN=be("$ZodOptional",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$t(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$t(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${vg(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){const r=n.value,o=t.innerType._zod.run(n,i);return o instanceof Promise?o.then(c=>ay(c,r)):ay(o,r)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),OI=be("$ZodExactOptional",(e,t)=>{JN.init(e,t),$t(e._zod,"values",()=>t.innerType._zod.values),$t(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),PI=be("$ZodNullable",(e,t)=>{Yt.init(e,t),$t(e._zod,"optin",()=>t.innerType._zod.optin),$t(e._zod,"optout",()=>t.innerType._zod.optout),$t(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${vg(n.source)}|null)$`):void 0}),$t(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),zI=be("$ZodDefault",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",$t(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>oy(o,t)):oy(r,t)}});function oy(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const LI=be("$ZodPrefault",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",$t(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),DI=be("$ZodNonOptional",(e,t)=>{Yt.init(e,t),$t(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,i)=>{const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>ly(o,e)):ly(r,e)}});function ly(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 FI=be("$ZodCatch",(e,t)=>{Yt.init(e,t),e._zod.optin="optional",$t(e._zod,"optout",()=>t.innerType._zod.optout),$t(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>gr(c,i,pr()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(o=>gr(o,i,pr()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),UI=be("$ZodPipe",(e,t)=>{Yt.init(e,t),$t(e._zod,"values",()=>t.in._zod.values),$t(e._zod,"optin",()=>t.in._zod.optin),$t(e._zod,"optout",()=>t.out._zod.optout),$t(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){const o=t.out._zod.run(n,i);return o instanceof Promise?o.then(c=>Fu(c,t.in,i)):Fu(o,t.in,i)}const r=t.in._zod.run(n,i);return r instanceof Promise?r.then(o=>Fu(o,t.out,i)):Fu(r,t.out,i)}});function Fu(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 BI=be("$ZodReadonly",(e,t)=>{Yt.init(e,t),$t(e._zod,"propValues",()=>t.innerType._zod.propValues),$t(e._zod,"values",()=>t.innerType._zod.values),$t(e._zod,"optin",()=>{var n,i;return(i=(n=t.innerType)==null?void 0:n._zod)==null?void 0:i.optin}),$t(e._zod,"optout",()=>{var n,i;return(i=(n=t.innerType)==null?void 0:n._zod)==null?void 0:i.optout}),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);const r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(cy):cy(r)}});function cy(e){return e.value=Object.freeze(e.value),e}const HI=be("$ZodCustom",(e,t)=>{ws.init(e,t),Yt.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{const i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>uy(o,n,i,e));uy(r,n,i,e)}});function uy(e,t,n,i){if(!e){const r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(hc(r))}}var dy;class ZI{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const i=n[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.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 i={...this.get(n)??{}};delete i.id;const r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function WI(){return new ZI}(dy=globalThis).__zod_globalRegistry??(dy.__zod_globalRegistry=WI());const Vl=globalThis.__zod_globalRegistry;function VI(e,t){return new e({type:"string",...Qe(t)})}function qI(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Qe(t)})}function hy(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Qe(t)})}function GI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Qe(t)})}function KI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Qe(t)})}function YI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Qe(t)})}function XI(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Qe(t)})}function ej(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Qe(t)})}function QI(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Qe(t)})}function JI(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Qe(t)})}function eT(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Qe(t)})}function tT(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Qe(t)})}function nT(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Qe(t)})}function sT(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Qe(t)})}function iT(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Qe(t)})}function rT(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Qe(t)})}function aT(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Qe(t)})}function oT(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Qe(t)})}function lT(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Qe(t)})}function cT(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Qe(t)})}function uT(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Qe(t)})}function dT(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Qe(t)})}function hT(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Qe(t)})}function fT(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Qe(t)})}function mT(e,t){return new e({type:"string",format:"date",check:"string_format",...Qe(t)})}function pT(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Qe(t)})}function gT(e,t){return new e({type:"string",format:"duration",check:"string_format",...Qe(t)})}function xT(e,t){return new e({type:"number",checks:[],...Qe(t)})}function vT(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Qe(t)})}function yT(e,t){return new e({type:"boolean",...Qe(t)})}function bT(e,t){return new e({type:"null",...Qe(t)})}function kT(e){return new e({type:"unknown"})}function NT(e,t){return new e({type:"never",...Qe(t)})}function fy(e,t){return new VN({check:"less_than",...Qe(t),value:e,inclusive:!1})}function Wf(e,t){return new VN({check:"less_than",...Qe(t),value:e,inclusive:!0})}function my(e,t){return new qN({check:"greater_than",...Qe(t),value:e,inclusive:!1})}function Vf(e,t){return new qN({check:"greater_than",...Qe(t),value:e,inclusive:!0})}function py(e,t){return new PA({check:"multiple_of",...Qe(t),value:e})}function tj(e,t){return new LA({check:"max_length",...Qe(t),maximum:e})}function yd(e,t){return new DA({check:"min_length",...Qe(t),minimum:e})}function nj(e,t){return new FA({check:"length_equals",...Qe(t),length:e})}function jT(e,t){return new UA({check:"string_format",format:"regex",...Qe(t),pattern:e})}function wT(e){return new BA({check:"string_format",format:"lowercase",...Qe(e)})}function ST(e){return new HA({check:"string_format",format:"uppercase",...Qe(e)})}function _T(e,t){return new ZA({check:"string_format",format:"includes",...Qe(t),includes:e})}function ET(e,t){return new WA({check:"string_format",format:"starts_with",...Qe(t),prefix:e})}function CT(e,t){return new VA({check:"string_format",format:"ends_with",...Qe(t),suffix:e})}function Jo(e){return new qA({check:"overwrite",tx:e})}function AT(e){return Jo(t=>t.normalize(e))}function IT(){return Jo(e=>e.trim())}function TT(){return Jo(e=>e.toLowerCase())}function $T(){return Jo(e=>e.toUpperCase())}function MT(){return Jo(e=>LC(e))}function RT(e,t,n){return new e({type:"array",element:t,...Qe(n)})}function OT(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Qe(n)})}function PT(e,t){const n=zT(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(hc(r,i.value,n._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=i.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),i.issues.push(hc(o))}},e(i.value,i)),t);return n}function zT(e,t){const n=new ws({check:"custom",...Qe(t)});return n._zod.check=e,n}function sj(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)??Vl,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 Nn(e,t,n={path:[],schemaPath:[]}){var f,g;var i;const r=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=(g=(f=e._zod).toJSONSchema)==null?void 0:g.call(f);if(u)c.schema=u;else{const p={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,p);else{const b=c.schema,k=t.processors[r.type];if(!k)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);k(e,t,b,p)}const x=e._zod.parent;x&&(c.ref||(c.ref=x),Nn(x,t,p),t.seen.get(x).isParent=!0)}const d=t.metadataRegistry.get(e);return d&&Object.assign(c.schema,d),t.io==="input"&&is(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((i=c.schema).default??(i.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function ij(e,t){var c,u,d,h;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const f of e.seen.entries()){const g=(c=e.metadataRegistry.get(f[0]))==null?void 0:c.id;if(g){const p=i.get(g);if(p&&p!==f[0])throw new Error(`Duplicate schema id "${g}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(g,f[0])}}const r=f=>{var k;const g=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const w=(k=e.external.registry.get(f[0]))==null?void 0:k.id,j=e.external.uri??(N=>N);if(w)return{ref:j(w)};const E=f[1].defId??f[1].schema.id??`schema${e.counter++}`;return f[1].defId=E,{defId:E,ref:`${j("__shared")}#/${g}/${E}`}}if(f[1]===n)return{ref:"#"};const x=`#/${g}/`,b=f[1].schema.id??`__schema${e.counter++}`;return{defId:b,ref:x+b}},o=f=>{if(f[1].schema.$ref)return;const g=f[1],{ref:p,defId:x}=r(f);g.def={...g.schema},x&&(g.defId=x);const b=g.schema;for(const k in b)delete b[k];b.$ref=p};if(e.cycles==="throw")for(const f of e.seen.entries()){const g=f[1];if(g.cycle)throw new Error(`Cycle detected: #/${(u=g.cycle)==null?void 0:u.join("/")}/<root>
102
+
103
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of e.seen.entries()){const g=f[1];if(t===f[0]){o(f);continue}if(e.external){const x=(d=e.external.registry.get(f[0]))==null?void 0:d.id;if(t!==f[0]&&x){o(f);continue}}if((h=e.metadataRegistry.get(f[0]))==null?void 0:h.id){o(f);continue}if(g.cycle){o(f);continue}if(g.count>1&&e.reused==="ref"){o(f);continue}}}function rj(e,t){var u,d,h,f;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=g=>{const p=e.seen.get(g);if(p.ref===null)return;const x=p.def??p.schema,b={...x},k=p.ref;if(p.ref=null,k){i(k);const j=e.seen.get(k),E=j.schema;if(E.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(x.allOf=x.allOf??[],x.allOf.push(E)):Object.assign(x,E),Object.assign(x,b),g._zod.parent===k)for(const C in x)C==="$ref"||C==="allOf"||C in b||delete x[C];if(E.$ref&&j.def)for(const C in x)C==="$ref"||C==="allOf"||C in j.def&&JSON.stringify(x[C])===JSON.stringify(j.def[C])&&delete x[C]}const w=g._zod.parent;if(w&&w!==k){i(w);const j=e.seen.get(w);if(j!=null&&j.schema.$ref&&(x.$ref=j.schema.$ref,j.def))for(const E in x)E==="$ref"||E==="allOf"||E in j.def&&JSON.stringify(x[E])===JSON.stringify(j.def[E])&&delete x[E]}e.override({zodSchema:g,jsonSchema:x,path:p.path??[]})};for(const g of[...e.seen.entries()].reverse())i(g[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const g=(d=e.external.registry.get(t))==null?void 0:d.id;if(!g)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(g)}Object.assign(r,n.def??n.schema);const o=(h=e.metadataRegistry.get(t))==null?void 0:h.id;o!==void 0&&r.id===o&&delete r.id;const c=((f=e.external)==null?void 0:f.defs)??{};for(const g of e.seen.entries()){const p=g[1];p.def&&p.defId&&(p.def.id===p.defId&&delete p.def.id,c[p.defId]=p.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?r.$defs=c:r.definitions=c);try{const g=JSON.parse(JSON.stringify(r));return Object.defineProperty(g,"~standard",{value:{...t["~standard"],jsonSchema:{input:bd(t,"input",e.processors),output:bd(t,"output",e.processors)}},enumerable:!1,writable:!1}),g}catch{throw new Error("Error converting schema to JSON.")}}function is(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return is(i.element,n);if(i.type==="set")return is(i.valueType,n);if(i.type==="lazy")return is(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return is(i.innerType,n);if(i.type==="intersection")return is(i.left,n)||is(i.right,n);if(i.type==="record"||i.type==="map")return is(i.keyType,n)||is(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:is(i.in,n)||is(i.out,n);if(i.type==="object"){for(const r in i.shape)if(is(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(const r of i.options)if(is(r,n))return!0;return!1}if(i.type==="tuple"){for(const r of i.items)if(is(r,n))return!0;return!!(i.rest&&is(i.rest,n))}return!1}const LT=(e,t={})=>n=>{const i=sj({...n,processors:t});return Nn(e,i),ij(i,e),rj(i,e)},bd=(e,t,n={})=>i=>{const{libraryOptions:r,target:o}=i??{},c=sj({...r??{},target:o,io:t,processors:n});return Nn(e,c),ij(c,e),rj(c,e)},DT={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},FT=(e,t,n,i)=>{const r=n;r.type="string";const{minimum:o,maximum:c,format:u,patterns:d,contentEncoding:h}=e._zod.bag;if(typeof o=="number"&&(r.minLength=o),typeof c=="number"&&(r.maxLength=c),u&&(r.format=DT[u]??u,r.format===""&&delete r.format,u==="time"&&delete r.format),h&&(r.contentEncoding=h),d&&d.size>0){const f=[...d];f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},UT=(e,t,n,i)=>{const r=n,{minimum:o,maximum:c,format:u,multipleOf:d,exclusiveMaximum:h,exclusiveMinimum:f}=e._zod.bag;typeof u=="string"&&u.includes("int")?r.type="integer":r.type="number";const g=typeof f=="number"&&f>=(o??Number.NEGATIVE_INFINITY),p=typeof h=="number"&&h<=(c??Number.POSITIVE_INFINITY),x=t.target==="draft-04"||t.target==="openapi-3.0";g?x?(r.minimum=f,r.exclusiveMinimum=!0):r.exclusiveMinimum=f:typeof o=="number"&&(r.minimum=o),p?x?(r.maximum=h,r.exclusiveMaximum=!0):r.exclusiveMaximum=h:typeof c=="number"&&(r.maximum=c),typeof d=="number"&&(r.multipleOf=d)},BT=(e,t,n,i)=>{n.type="boolean"},HT=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ZT=(e,t,n,i)=>{n.not={}},WT=(e,t,n,i)=>{},VT=(e,t,n,i)=>{const r=e._zod.def,o=ON(r.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},qT=(e,t,n,i)=>{const r=e._zod.def,o=[];for(const c of r.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},GT=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},KT=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},YT=(e,t,n,i)=>{const r=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(r.minItems=c),typeof u=="number"&&(r.maxItems=u),r.type="array",r.items=Nn(o.element,t,{...i,path:[...i.path,"items"]})},XT=(e,t,n,i)=>{var h;const r=n,o=e._zod.def;r.type="object",r.properties={};const c=o.shape;for(const f in c)r.properties[f]=Nn(c[f],t,{...i,path:[...i.path,"properties",f]});const u=new Set(Object.keys(c)),d=new Set([...u].filter(f=>{const g=o.shape[f]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));d.size>0&&(r.required=Array.from(d)),((h=o.catchall)==null?void 0:h._zod.def.type)==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=Nn(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},QT=(e,t,n,i)=>{const r=e._zod.def,o=r.inclusive===!1,c=r.options.map((u,d)=>Nn(u,t,{...i,path:[...i.path,o?"oneOf":"anyOf",d]}));o?n.oneOf=c:n.anyOf=c},JT=(e,t,n,i)=>{const r=e._zod.def,o=Nn(r.left,t,{...i,path:[...i.path,"allOf",0]}),c=Nn(r.right,t,{...i,path:[...i.path,"allOf",1]}),u=h=>"allOf"in h&&Object.keys(h).length===1,d=[...u(o)?o.allOf:[o],...u(c)?c.allOf:[c]];n.allOf=d},e$=(e,t,n,i)=>{const r=n,o=e._zod.def;r.type="object";const c=o.keyType,u=c._zod.bag,d=u==null?void 0:u.patterns;if(o.mode==="loose"&&d&&d.size>0){const f=Nn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(const g of d)r.patternProperties[g.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=Nn(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=Nn(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const h=c._zod.values;if(h){const f=[...h].filter(g=>typeof g=="string"||typeof g=="number");f.length>0&&(r.required=f)}},t$=(e,t,n,i)=>{const r=e._zod.def,o=Nn(r.innerType,t,i),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},n$=(e,t,n,i)=>{const r=e._zod.def;Nn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},s$=(e,t,n,i)=>{const r=e._zod.def;Nn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},i$=(e,t,n,i)=>{const r=e._zod.def;Nn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},r$=(e,t,n,i)=>{const r=e._zod.def;Nn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType;let c;try{c=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},a$=(e,t,n,i)=>{const r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?o?r.out:r.in:r.out;Nn(c,t,i);const u=t.seen.get(e);u.ref=c},o$=(e,t,n,i)=>{const r=e._zod.def;Nn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},aj=(e,t,n,i)=>{const r=e._zod.def;Nn(r.innerType,t,i);const o=t.seen.get(e);o.ref=r.innerType},l$=be("ZodISODateTime",(e,t)=>{oI.init(e,t),rn.init(e,t)});function c$(e){return fT(l$,e)}const u$=be("ZodISODate",(e,t)=>{lI.init(e,t),rn.init(e,t)});function d$(e){return mT(u$,e)}const h$=be("ZodISOTime",(e,t)=>{cI.init(e,t),rn.init(e,t)});function f$(e){return pT(h$,e)}const m$=be("ZodISODuration",(e,t)=>{uI.init(e,t),rn.init(e,t)});function p$(e){return gT(m$,e)}const g$=(e,t)=>{DN.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>QC(e,n)},flatten:{value:n=>XC(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,tp,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,tp,2)}},isEmpty:{get(){return e.issues.length===0}}})},si=be("ZodError",g$,{Parent:Error}),x$=bg(si),v$=kg(si),y$=Hd(si),b$=Zd(si),k$=tA(si),N$=nA(si),j$=sA(si),w$=iA(si),S$=rA(si),_$=aA(si),E$=oA(si),C$=lA(si),gy=new WeakMap;function Tc(e,t,n){const i=Object.getPrototypeOf(e);let r=gy.get(i);if(r||(r=new Set,gy.set(i,r)),!r.has(t)){r.add(t);for(const o in n){const c=n[o];Object.defineProperty(i,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 Qt=be("ZodType",(e,t)=>(Yt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:bd(e,"input"),output:bd(e,"output")}}),e.toJSONSchema=LT(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,i)=>x$(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>y$(e,n,i),e.parseAsync=async(n,i)=>v$(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>b$(e,n,i),e.spa=e.safeParseAsync,e.encode=(n,i)=>k$(e,n,i),e.decode=(n,i)=>N$(e,n,i),e.encodeAsync=async(n,i)=>j$(e,n,i),e.decodeAsync=async(n,i)=>w$(e,n,i),e.safeEncode=(n,i)=>S$(e,n,i),e.safeDecode=(n,i)=>_$(e,n,i),e.safeEncodeAsync=async(n,i)=>E$(e,n,i),e.safeDecodeAsync=async(n,i)=>C$(e,n,i),Tc(e,"ZodType",{check(...n){const i=this.def;return this.clone(na(i,{checks:[...i.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,i){return sa(this,n,i)},brand(){return this},register(n,i){return n.add(this,i),this},refine(n,i){return this.check(kM(n,i))},superRefine(n,i){return this.check(NM(n,i))},overwrite(n){return this.check(Jo(n))},optional(){return by(this)},exactOptional(){return lM(this)},nullable(){return ky(this)},nullish(){return by(ky(this))},nonoptional(n){return mM(this,n)},array(){return he(this)},or(n){return Zo([this,n])},and(n){return sM(this,n)},transform(n){return Ny(this,aM(n))},default(n){return dM(this,n)},prefault(n){return fM(this,n)},catch(n){return gM(this,n)},pipe(n){return Ny(this,n)},readonly(){return yM(this)},describe(n){const i=this.clone();return Vl.add(i,{description:n}),i},meta(...n){if(n.length===0)return Vl.get(this);const i=this.clone();return Vl.add(i,n[0]),i},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=Vl.get(e))==null?void 0:n.description},configurable:!0}),e)),oj=be("_ZodString",(e,t)=>{Ng.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>FT(e,i,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Tc(e,"_ZodString",{regex(...i){return this.check(jT(...i))},includes(...i){return this.check(_T(...i))},startsWith(...i){return this.check(ET(...i))},endsWith(...i){return this.check(CT(...i))},min(...i){return this.check(yd(...i))},max(...i){return this.check(tj(...i))},length(...i){return this.check(nj(...i))},nonempty(...i){return this.check(yd(1,...i))},lowercase(i){return this.check(wT(i))},uppercase(i){return this.check(ST(i))},trim(){return this.check(IT())},normalize(...i){return this.check(AT(...i))},toLowerCase(){return this.check(TT())},toUpperCase(){return this.check($T())},slugify(){return this.check(MT())}})}),A$=be("ZodString",(e,t)=>{Ng.init(e,t),oj.init(e,t),e.email=n=>e.check(qI(I$,n)),e.url=n=>e.check(ej(lj,n)),e.jwt=n=>e.check(hT(W$,n)),e.emoji=n=>e.check(QI(T$,n)),e.guid=n=>e.check(hy(xy,n)),e.uuid=n=>e.check(GI(Uu,n)),e.uuidv4=n=>e.check(KI(Uu,n)),e.uuidv6=n=>e.check(YI(Uu,n)),e.uuidv7=n=>e.check(XI(Uu,n)),e.nanoid=n=>e.check(JI($$,n)),e.guid=n=>e.check(hy(xy,n)),e.cuid=n=>e.check(eT(M$,n)),e.cuid2=n=>e.check(tT(R$,n)),e.ulid=n=>e.check(nT(O$,n)),e.base64=n=>e.check(cT(B$,n)),e.base64url=n=>e.check(uT(H$,n)),e.xid=n=>e.check(sT(P$,n)),e.ksuid=n=>e.check(iT(z$,n)),e.ipv4=n=>e.check(rT(L$,n)),e.ipv6=n=>e.check(aT(D$,n)),e.cidrv4=n=>e.check(oT(F$,n)),e.cidrv6=n=>e.check(lT(U$,n)),e.e164=n=>e.check(dT(Z$,n)),e.datetime=n=>e.check(c$(n)),e.date=n=>e.check(d$(n)),e.time=n=>e.check(f$(n)),e.duration=n=>e.check(p$(n))});function S(e){return VI(A$,e)}const rn=be("ZodStringFormat",(e,t)=>{Xt.init(e,t),oj.init(e,t)}),I$=be("ZodEmail",(e,t)=>{QA.init(e,t),rn.init(e,t)}),xy=be("ZodGUID",(e,t)=>{YA.init(e,t),rn.init(e,t)}),Uu=be("ZodUUID",(e,t)=>{XA.init(e,t),rn.init(e,t)}),lj=be("ZodURL",(e,t)=>{JA.init(e,t),rn.init(e,t)});function sp(e){return ej(lj,e)}const T$=be("ZodEmoji",(e,t)=>{eI.init(e,t),rn.init(e,t)}),$$=be("ZodNanoID",(e,t)=>{tI.init(e,t),rn.init(e,t)}),M$=be("ZodCUID",(e,t)=>{nI.init(e,t),rn.init(e,t)}),R$=be("ZodCUID2",(e,t)=>{sI.init(e,t),rn.init(e,t)}),O$=be("ZodULID",(e,t)=>{iI.init(e,t),rn.init(e,t)}),P$=be("ZodXID",(e,t)=>{rI.init(e,t),rn.init(e,t)}),z$=be("ZodKSUID",(e,t)=>{aI.init(e,t),rn.init(e,t)}),L$=be("ZodIPv4",(e,t)=>{dI.init(e,t),rn.init(e,t)}),D$=be("ZodIPv6",(e,t)=>{hI.init(e,t),rn.init(e,t)}),F$=be("ZodCIDRv4",(e,t)=>{fI.init(e,t),rn.init(e,t)}),U$=be("ZodCIDRv6",(e,t)=>{mI.init(e,t),rn.init(e,t)}),B$=be("ZodBase64",(e,t)=>{pI.init(e,t),rn.init(e,t)}),H$=be("ZodBase64URL",(e,t)=>{xI.init(e,t),rn.init(e,t)}),Z$=be("ZodE164",(e,t)=>{vI.init(e,t),rn.init(e,t)}),W$=be("ZodJWT",(e,t)=>{bI.init(e,t),rn.init(e,t)}),cj=be("ZodNumber",(e,t)=>{KN.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>UT(e,i,r),Tc(e,"ZodNumber",{gt(i,r){return this.check(my(i,r))},gte(i,r){return this.check(Vf(i,r))},min(i,r){return this.check(Vf(i,r))},lt(i,r){return this.check(fy(i,r))},lte(i,r){return this.check(Wf(i,r))},max(i,r){return this.check(Wf(i,r))},int(i){return this.check(vy(i))},safe(i){return this.check(vy(i))},positive(i){return this.check(my(0,i))},nonnegative(i){return this.check(Vf(0,i))},negative(i){return this.check(fy(0,i))},nonpositive(i){return this.check(Wf(0,i))},multipleOf(i,r){return this.check(py(i,r))},step(i,r){return this.check(py(i,r))},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 le(e){return xT(cj,e)}const V$=be("ZodNumberFormat",(e,t)=>{kI.init(e,t),cj.init(e,t)});function vy(e){return vT(V$,e)}const q$=be("ZodBoolean",(e,t)=>{NI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>BT(e,n,i)});function ve(e){return yT(q$,e)}const G$=be("ZodNull",(e,t)=>{jI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>HT(e,n,i)});function K$(e){return bT(G$,e)}const Y$=be("ZodUnknown",(e,t)=>{wI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>WT()});function ip(){return kT(Y$)}const X$=be("ZodNever",(e,t)=>{SI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ZT(e,n,i)});function Q$(e){return NT(X$,e)}const J$=be("ZodArray",(e,t)=>{_I.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>YT(e,n,i,r),e.element=t.element,Tc(e,"ZodArray",{min(n,i){return this.check(yd(n,i))},nonempty(n){return this.check(yd(1,n))},max(n,i){return this.check(tj(n,i))},length(n,i){return this.check(nj(n,i))},unwrap(){return this.element}})});function he(e,t){return RT(J$,e,t)}const eM=be("ZodObject",(e,t)=>{CI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>XT(e,n,i,r),$t(e,"shape",()=>t.shape),Tc(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:ip()})},loose(){return this.clone({...this._zod.def,catchall:ip()})},strict(){return this.clone({...this._zod.def,catchall:Q$()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return WC(this,n)},safeExtend(n){return VC(this,n)},merge(n){return qC(this,n)},pick(n){return HC(this,n)},omit(n){return ZC(this,n)},partial(...n){return GC(dj,this,n[0])},required(...n){return KC(hj,this,n[0])}})});function R(e,t){const n={type:"object",shape:e??{},...Qe(t)};return new eM(n)}const uj=be("ZodUnion",(e,t)=>{QN.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>QT(e,n,i,r),e.options=t.options});function Zo(e,t){return new uj({type:"union",options:e,...Qe(t)})}const tM=be("ZodDiscriminatedUnion",(e,t)=>{uj.init(e,t),AI.init(e,t)});function Wa(e,t,n){return new tM({type:"union",options:t,discriminator:e,...Qe(n)})}const nM=be("ZodIntersection",(e,t)=>{II.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>JT(e,n,i,r)});function sM(e,t){return new nM({type:"intersection",left:e,right:t})}const yy=be("ZodRecord",(e,t)=>{TI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>e$(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function Os(e,t,n){return!t||!t._zod?new yy({type:"record",keyType:S(),valueType:e,...Qe(t)}):new yy({type:"record",keyType:e,valueType:t,...Qe(n)})}const rp=be("ZodEnum",(e,t)=>{$I.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>VT(e,i,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{const o={};for(const c of i)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new rp({...t,checks:[],...Qe(r),entries:o})},e.exclude=(i,r)=>{const o={...t.entries};for(const c of i)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new rp({...t,checks:[],...Qe(r),entries:o})}});function Pe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new rp({type:"enum",entries:n,...Qe(t)})}const iM=be("ZodLiteral",(e,t)=>{MI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qT(e,n,i),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 ut(e,t){return new iM({type:"literal",values:Array.isArray(e)?e:[e],...Qe(t)})}const rM=be("ZodTransform",(e,t)=>{RI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>KT(e,n),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new RN(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(hc(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(hc(c))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function aM(e){return new rM({type:"transform",transform:e})}const dj=be("ZodOptional",(e,t)=>{JN.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>aj(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function by(e){return new dj({type:"optional",innerType:e})}const oM=be("ZodExactOptional",(e,t)=>{OI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>aj(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function lM(e){return new oM({type:"optional",innerType:e})}const cM=be("ZodNullable",(e,t)=>{PI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>t$(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ky(e){return new cM({type:"nullable",innerType:e})}const uM=be("ZodDefault",(e,t)=>{zI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s$(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dM(e,t){return new uM({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():zN(t)}})}const hM=be("ZodPrefault",(e,t)=>{LI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>i$(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function fM(e,t){return new hM({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():zN(t)}})}const hj=be("ZodNonOptional",(e,t)=>{DI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>n$(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function mM(e,t){return new hj({type:"nonoptional",innerType:e,...Qe(t)})}const pM=be("ZodCatch",(e,t)=>{FI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>r$(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gM(e,t){return new pM({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const xM=be("ZodPipe",(e,t)=>{UI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a$(e,n,i,r),e.in=t.in,e.out=t.out});function Ny(e,t){return new xM({type:"pipe",in:e,out:t})}const vM=be("ZodReadonly",(e,t)=>{BI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o$(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function yM(e){return new vM({type:"readonly",innerType:e})}const bM=be("ZodCustom",(e,t)=>{HI.init(e,t),Qt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>GT(e,n)});function kM(e,t={}){return OT(bM,e,t)}function NM(e,t){return PT(e,t)}const qf=Wa("type",[R({type:ut("text"),text:S()}),R({type:ut("reasoning"),text:S()}),R({type:ut("image"),name:S().optional(),mediaType:S().optional(),width:le().optional(),height:le().optional(),attachmentId:S().optional(),bytes:le().optional()}),R({type:ut("file"),name:S().optional(),size:le().optional(),mediaType:S().optional()}),R({type:ut("tool-call"),callId:S(),name:S(),arguments:S()}),R({type:ut("other"),kind:S()})]),jy=R({inputTokens:le(),outputTokens:le(),totalTokens:le().optional(),cacheReadTokens:le().optional(),cacheWriteTokens:le().optional(),reasoningTokens:le().optional()}),wy=R({firstChunkAt:le().optional(),firstTokenAt:le().optional(),lastChunkAt:le().optional(),tokenChunks:le()}),Sy=R({message:S(),code:S().optional()}),jM=R({kind:S(),message:S().optional()}),wM=R({kind:S(),human:ve(),summary:S().optional()}),Rn={seq:le(),time:le()},ap=Wa("type",[R({...Rn,type:ut("turn/start"),turn:le()}),R({...Rn,type:ut("turn/end"),turn:le(),reason:jM}),R({...Rn,type:ut("step/start"),turn:le(),step:le()}),R({...Rn,type:ut("step/end"),turn:le(),step:le()}),R({...Rn,type:ut("user/message"),messageId:S(),content:he(qf),origin:wM,requestId:S().optional(),replacesHistory:ve().optional()}),R({...Rn,type:ut("system/message"),turn:le(),step:le(),text:S()}),R({...Rn,type:ut("assistant/message"),turn:le(),step:le(),messageId:S(),content:he(qf),timing:wy,usage:jy.optional(),interrupted:ve().optional(),provider:S().optional(),model:S().optional()}),R({...Rn,type:ut("assistant/attempt"),turn:le(),step:le(),timing:wy,error:Sy.optional()}),R({...Rn,type:ut("tool/call"),turn:le(),step:le(),callId:S(),name:S(),arguments:S()}),R({...Rn,type:ut("tool/result"),turn:le(),step:le(),callId:S(),isError:ve(),content:he(qf),error:Sy.optional()}),R({...Rn,type:ut("request/header"),provider:S().optional(),model:S().optional(),reasoningEffort:S().optional(),toolNames:he(S()),reason:S()}),R({...Rn,type:ut("compaction/start"),compactionId:S(),turn:le().nullable()}),R({...Rn,type:ut("compaction/summary"),compactionId:S(),shadowedTokenCount:le(),provider:S().optional(),model:S().optional(),usage:jy.optional()}),R({...Rn,type:ut("compaction/end"),compactionId:S(),turn:le().nullable(),error:S().optional()}),R({...Rn,type:ut("approval/asked"),approvalId:S(),toolName:S(),callId:S().optional(),reason:S().optional()}),R({...Rn,type:ut("approval/decided"),approvalId:S(),outcome:S()}),R({...Rn,type:ut("session/title"),title:S()}),R({...Rn,type:ut("unknown"),upstreamType:S(),data:ip()})]),fj=Wa("type",[R({type:ut("start"),attemptId:S(),turn:le(),step:le(),afterSeq:le()}),R({type:ut("delta"),attemptId:S(),time:le(),kind:Pe(["text","reasoning","tool-args"]),index:le(),text:S(),callId:S().optional(),toolName:S().optional()}),R({type:ut("end"),attemptId:S(),outcome:Pe(["committed","abandoned"]),seq:le().optional()})]),SM=R({attemptId:S(),turn:le(),step:le(),afterSeq:le(),deltas:he(fj.options[1])}),_M=R({index:le().int().min(0),name:S(),running:ve(),ready:ve(),adb:S().optional()}),EM=R({kind:Pe(["mumu"]),name:S(),manager:S(),version:S().optional(),instances:he(_M),error:S().optional()}),mj=R({mumuManager:S().optional(),instance:le().int().min(0).max(63),manualAddress:S().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:S().optional(),autoStart:ve(),bootTimeoutSeconds:le().int().min(30).max(900)});R({providers:he(EM),settings:mj,selection:R({label:S(),address:S().optional(),problem:S().optional()})});R({refresh:ve().optional()}),R({index:le().int().min(0).optional()}),R({address:S(),label:S()}),R({index:le().int().min(0).optional()}),R({}),mj.partial().extend({mumuManager:S().nullable().optional(),manualAddress:S().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:S().nullable().optional()});R({});const jg=Pe(["maafw-pi","cli","gui-config","generic-process","visual"]),wt=S().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),tc=S().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),Gf=S().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),CM=Wa("kind",[R({kind:ut("github"),repo:S()}),R({kind:ut("mirrorchyan"),rid:S(),platform:ve(),os:ve().optional(),arch:ve().optional()}),R({kind:ut("local"),path:S()})]),AM=R({version:S(),dir:S(),installedAt:le(),asset:R({name:S(),size:le()}).optional(),current:ve()}),IM=Pe(["ok","missing","outdated","unknown","unsupported"]),TM=R({kind:S(),label:S(),required:S().optional(),status:IM,found:S().optional(),detail:S().optional(),fix:R({kind:Pe(["auto","installer","manual"]),description:S(),needsAdmin:ve()}).optional()}),$M=R({checkedAt:le(),ok:ve(),items:he(TM)}),MM=R({executables:he(S()),markers:he(S()),family:jg.optional()}),_y=Pe(["install","pack","known","user"]),RM=R({github:R({repo:S(),from:_y}).optional(),mirrorchyan:R({rid:S(),from:_y}).optional()}),OM=R({version:S(),from:S()}),PM=R({state:Pe(["running","done","failed"]),at:le(),text:S().optional(),sessionId:S().optional()}),zM=R({id:S(),name:S(),source:CM,packId:S().optional(),family:jg.optional(),current:S().optional(),dir:S().optional(),versions:he(AM),env:$M.optional(),probe:MM.optional(),update:R({latest:S(),available:ve(),checkedAt:le()}).optional(),channels:RM,known:S().optional(),localVersion:OM.optional(),undo:R({from:S().optional(),to:S(),at:le()}).optional(),jobId:S().optional(),addedAt:le(),summary:PM.optional(),packReview:R({from:S().optional(),to:S()}).optional(),optimize:R({runs:le(),at:le().optional(),due:Pe(["runs","updated"]).optional()}).optional()}),LM=R({id:S(),name:S(),description:S().optional(),repo:S().optional(),mirrorchyan:S().optional(),family:jg.optional(),builtin:ve(),installed:ve(),error:S().optional()}),DM=R({packId:S(),name:S(),builtin:ve(),written:ve(),overview:S().optional(),tasks:he(R({id:S(),title:S(),description:S().optional(),utterances:he(S()),input:Pe(["desktop","window","adb","none"]),expectedDuration:S().optional(),params:he(R({name:S(),type:Pe(["string","integer","number","boolean"]),description:S().optional(),default:S().optional(),values:S().optional()}))})),setup:he(S()),checks:he(S()),features:he(R({title:S(),description:S().optional(),enable:S(),config:he(R({file:S(),key:S(),value:S()})),tasks:he(S())})),config:he(R({file:S(),about:S().optional(),keys:he(R({key:S(),meaning:S(),values:S().optional(),default:S().optional(),advice:S().optional()})),changes:he(R({key:S(),value:S(),note:S().optional(),when:S().optional(),tasks:he(S())}))})),troubleshooting:he(R({problem:S(),cause:S().optional(),fix:S()}))});R({rid:S(),version:S(),platform:ve(),os:ve().optional(),arch:ve().optional(),name:S().optional(),description:S().optional(),repo:S().optional()});const op=R({rid:S(),name:S(),description:S(),repo:S().optional(),url:S().optional(),installed:ve(),known:ve()}),FM=R({id:S(),name:S(),repo:S().optional(),mirrorchyan:S().optional(),installed:ve()}),UM=R({name:S(),size:le(),downloadUrl:S(),digest:S().optional()}),BM=R({tag:S(),name:S(),prerelease:ve(),publishedAt:S().optional(),url:S().optional(),assets:he(UM),suggestedAsset:S().optional(),notes:S().optional()}),HM=Pe(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),ZM=R({sessionId:S(),state:Pe(["running","failed"]),reason:S().optional()}),WM=R({scriptId:S(),name:S(),kind:Pe(["nsis","inno","kachina"]),version:S(),dir:S(),update:ve(),at:le(),agent:ZM.optional()}),VM=R({id:S(),kind:Pe(["install","update","env-fix"]),scriptId:S(),phase:HM,message:S().optional(),received:le().optional(),total:le().optional(),version:S().optional(),error:S().optional(),setup:R({kind:Pe(["nsis","inno","kachina"]),dir:S(),sessionId:S().optional()}).optional(),startedAt:le(),endedAt:le().optional()}),qM=Pe(["auto","ask","off"]),Ey=R({apiBase:sp({protocol:/^https?$/}),downloadMirror:S().trim().max(300),mirrorFallback:ve(),tokenRef:S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:le().int().min(1).max(10),includePrereleases:ve(),cdkRef:S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),autoUpdate:qM});R({});R({id:wt});R({scripts:he(zM),packs:he(LM),known:he(FM),setups:he(WM).default([]),toolsDir:S()}),R({guide:DM.nullable()}),R({icon:R({mediaType:S(),data:S()}).optional()}),R({query:S().trim().min(1).max(200)}),R({items:he(R({repo:S(),description:S().optional(),stars:le(),packId:S().optional()}))}),R({repo:tc,limit:le().int().min(1).max(30).optional()}),R({repo:S(),packId:S().optional(),releases:he(BM)}),R({repo:tc.optional(),mirrorchyan:Gf.optional(),tag:S().min(1).max(200).optional(),asset:S().min(1).max(300).optional(),branch:S().min(1).max(200).optional(),id:wt.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),R({jobId:S(),scriptId:S()}),R({current:S().optional(),latest:S(),available:ve()}),R({jobId:S().optional(),upToDate:ve()}),R({id:wt,repo:tc.nullable().optional(),mirrorchyan:Gf.nullable().optional(),reset:he(Pe(["repo","mirrorchyan"])).optional()}),R({items:he(op.extend({by:Pe(["repo","name"])})),from:Pe(["mirrorchyan","builtin"])}),R({rid:Gf}),R({query:S().trim().max(100)}),R({items:he(op),from:Pe(["mirrorchyan","builtin"]),fetchedAt:le().optional()}),R({id:S(),decision:Pe(["check","keep"])}),R({sessionId:S().optional()}),R({id:wt,version:S().optional()}),R({dir:S()}),R({sessionId:S()}),R({path:S().trim().min(1).max(1e3),id:wt.optional(),name:S().trim().min(1).max(100).optional(),packId:wt.optional()}),R({id:wt,decision:Pe(["run","keep"])}),R({sessionId:S().optional()}),R({id:wt}),R({sessionId:S()}),R({id:wt,deleteFiles:ve().optional()}),R({id:wt,kind:S().min(1).max(64)}),R({jobId:S()}),R({items:he(VM)}),R({jobId:S()}),Ey.extend({tokenConfigured:ve(),cdkConfigured:ve()}),R({ok:ve(),message:S(),expiresAt:le().optional()}),Ey.partial();R({id:S().optional()});const GM=R({packId:S(),scriptId:S(),proposedAt:le(),sessionId:S().optional(),summary:S(),docs:he(R({source:S(),used:S()})).optional(),noDocs:S().optional(),manifest:S(),skill:S(),current:R({manifest:S(),skill:S().optional(),builtin:ve()}).optional(),tasks:he(R({id:S(),title:S()}))}),KM=R({id:S(),at:le().optional(),builtin:ve().optional(),tasks:he(R({id:S(),title:S()}))});R({packId:wt}),R({items:he(KM)}),R({packId:wt,version:S().min(1).max(64)}),R({}),R({scriptId:wt.optional()}),R({items:he(GM)}),R({packId:wt}),R({packId:S(),dir:S()}),R({packId:wt}),R({});R({packId:S().optional()});const YM=R({scriptId:S(),dir:S(),grantedAt:le(),expiresAt:le()});R({}),R({items:he(YM),blocked:le()}),R({scriptId:wt,minutes:le().int().min(1).max(240)}),R({scriptId:wt}),R({});R({}),R({toolName:S(),target:S(),sessionId:S().optional(),at:le()});const XM=Pe(["error","warning","failed","stalled","overtime"]),QM=R({at:le(),action:Pe(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Pe(["rule","user","agent"]),ok:ve(),detail:S()}),JM=R({id:S(),runId:S(),scriptId:S(),scriptName:S(),taskId:S(),taskTitle:S(),kind:XM,severity:Pe(["warning","error"]),tag:S(),title:S(),detail:S(),lines:he(S()),status:Pe(["open","resolved"]),resolution:S().optional(),createdAt:le(),updatedAt:le(),steps:he(QM),screenshot:ve()}),eR=R({seconds:le().int().min(5).max(24*3600),by:Pe(["learned","agent","user"]),note:S().max(300).optional(),samples:he(le().min(0)).max(10).default([]),at:le()}),tR=R({defaultStallSeconds:le().int().min(0).max(24*3600),scriptStall:Os(S(),eR),notifyWarnings:ve(),screenshot:ve(),intervene:Pe(["off","diagnose","act"]),interventionsPerDay:le().int().min(0).max(200)});R({status:Pe(["open","all"]).optional(),runId:S().optional(),limit:le().int().min(1).max(500).optional()}),R({items:he(JM)}),R({incidentId:S(),action:Pe(["stop","retry","resolve","resume"])}),R({incidentId:S()}),R({mime:ut("image/png"),data:S()}),R({}),tR.partial();const nR="ADG_FEISHU_APP_SECRET",sR="ADG_QQBOT_APP_SECRET",lp=R({id:S(),label:S(),ok:ve().nullable(),detail:S().optional()}),iR=R({id:S(),name:S(),state:Pe(["off","connecting","ready","error"]),detail:S().optional(),recipients:le().int().min(0),checks:he(lp)}),rR=R({openId:S().min(1),name:S().optional(),addedAt:le()}),aR=R({enabled:ve(),appId:S().optional(),domain:Pe(["feishu","lark"]),allowedUsers:he(rR),chatId:S().optional(),otherApprovals:ve()}),oR=R({openId:S(),at:le(),text:S()});R({settings:aR,secretConfigured:ve(),pending:he(oR)});const lR=R({openId:S().min(1),name:S().optional(),addedAt:le()}),cR=R({enabled:ve(),appId:S().optional(),allowedUsers:he(lR)}),uR=R({openId:S(),at:le(),text:S()});R({settings:cR,secretConfigured:ve(),pending:he(uR)});const pj=R({id:S(),title:S(),text:S(),severity:Pe(["info","success","warning","error"]),at:le(),actions:he(R({id:S(),label:S(),style:Pe(["primary","danger","default"]).optional()})),channels:he(S()),image:ve().optional(),done:S().optional(),acted:R({by:S(),label:S(),result:S(),at:le()}).optional()});R({}),R({channels:he(iR)}),R({}),R({items:he(R({sessionId:S(),channel:S(),user:S()}))}),R({}),R({items:he(pj)}),R({noticeId:S(),actionId:S()}),R({result:S()}),R({channel:S().optional()}),R({sent:he(S()),failed:he(R({channel:S(),error:S()}))}),R({}),R({enabled:ve().optional(),appId:S().trim().regex(/^cli_[0-9a-fA-F]{16}$/,"App ID 是 cli_ 加 16 位字母数字,在「凭证与基础信息」里复制").nullable().optional(),domain:Pe(["feishu","lark"]).optional(),chatId:S().trim().regex(/^oc_[A-Za-z0-9]+$/,"群 ID 以 oc_ 开头").nullable().optional(),otherApprovals:ve().optional()}),R({openId:S().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:S().max(40).optional()}),R({openId:S()}),R({}),R({checks:he(lp)}),R({}),R({enabled:ve().optional(),appId:S().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),R({openId:S().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:S().max(40).optional()}),R({openId:S()}),R({}),R({checks:he(lp)});R({}),R({item:pj});const _a=S().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),fc=S().regex(/^[A-Za-z0-9_-]{1,40}$/),wg=S().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),gj=R({retries:le().int().min(0).max(5).default(0),then:Pe(["continue","stop"]).default("continue")}),ya={id:fc,title:S().max(60).optional(),position:R({x:le(),y:le()}).optional(),onFailure:gj.optional(),waitForAll:ve().optional()},dR=Wa("kind",[R({...ya,kind:ut("script-task"),scriptId:wt,taskId:S().min(1).max(64),params:Os(S(),Zo([S(),le(),ve()])).default({}),profile:S().min(1).max(64).optional()}),R({...ya,kind:ut("agent"),prompt:S().min(1).max(4e3)}),R({...ya,kind:ut("wait"),minutes:le().int().min(1).max(1440).optional(),until:wg.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),R({...ya,kind:ut("notify"),text:S().min(1).max(2e3)}),R({...ya,kind:ut("gate"),text:S().min(1).max(2e3)}),R({...ya,kind:ut("start")}),R({...ya,kind:ut("end")})]);function Hi(e){return e.kind==="start"||e.kind==="end"}function hR(e){const t=e.nodes.some(p=>p.kind==="start"),n=e.nodes.some(p=>p.kind==="end");if(t&&n)return e;const i=e.nodes.filter(p=>!Hi(p)),r=new Set(e.nodes.map(p=>p.id)),o=p=>{let x=p;for(let b=2;r.has(x);b++)x=`${p}${b}`;return r.add(x),x},c=i.filter(p=>p.position!==void 0).map(p=>p.position),u=Math.min(...c.map(p=>p.x)),d=Math.max(...c.map(p=>p.x)),h=c.length===0?40:Math.round(c.reduce((p,x)=>p+x.y,0)/c.length),f=[...e.nodes],g=[...e.edges];if(!t){const p=o("start");f.unshift({id:p,kind:"start",...c.length===0?{}:{position:{x:u-240,y:h}}});for(const x of i)e.edges.some(b=>b.to===x.id)||g.push({from:p,to:x.id,when:"success"})}if(!n){const p=o("end");f.push({id:p,kind:"end",...c.length===0?{}:{position:{x:d+300,y:h}}});for(const x of i)e.edges.some(b=>b.from===x.id)||g.push({from:x.id,to:p,when:"always"})}return{...e,nodes:f,edges:g}}const fR=R({from:fc,to:fc,when:Pe(["success","failure","always"]).default("success")}),Sg=R({enabled:ve().default(!1),times:he(wg).max(12).default([]),days:he(le().int().min(0).max(6)).max(7).default([]),catchUpMinutes:le().int().min(0).max(720).default(10),after:_a.optional()}),xj=Pe(["none","sleep","hibernate","shutdown"]),Kf=R({id:_a,name:S().min(1).max(60),description:S().max(500).optional(),nodes:he(dR).max(60),edges:he(fR).max(200).default([]),onFailure:gj.default({retries:0,then:"continue"}),schedule:Sg.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:ve().default(!1),closeGameAfter:ve().default(!1),powerAfter:xj.default("none"),draft:ve().optional(),createdAt:le().optional(),updatedAt:le().optional()}),mR=R({level:Pe(["error","warning","info"]),nodeId:S().optional(),message:S()}),pR=R({ok:ve(),issues:he(mR),serialized:he(R({a:S(),b:S(),resource:S()})),estimateMinutes:le().optional()}),gR=Pe(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),xR=R({state:gR,detail:S().optional(),runIds:he(S()),attempts:le().int().min(0),startedAt:le().optional(),endedAt:le().optional()}),vj=R({kind:Pe(["manual","schedule","autostart","agent","after"]),detail:S().optional()}),yj=R({id:S(),pipelineId:S(),pipelineName:S(),trigger:vj,from:S().optional(),state:Pe(["running","succeeded","failed","cancelled"]),stopping:S().optional(),nodes:Os(S(),xR),startedAt:le(),endedAt:le().optional(),outcome:S().optional()}),vR=R({id:S(),name:S(),description:S().optional(),nodes:le(),draft:ve(),schedule:Sg,updatedAt:le().optional(),lastRun:yj.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),ql=S().regex(/^task-[a-z0-9]{4,24}$/),Cy=R({id:ql,agent:S().min(1).max(64),title:S().trim().min(1).max(60),prompt:S().trim().min(1).max(4e3),schedule:Sg,createdAt:le().optional(),updatedAt:le().optional()}),Ay=R({id:S(),taskId:S(),trigger:vj,state:Pe(["running","done","failed"]),outcome:S().optional(),startedAt:le(),endedAt:le().optional()}),bj=R({autostart:ve(),autostartPipelines:he(_a),autostartDelaySeconds:le().int().min(0).max(1800),skipIfRanToday:ve(),firstStartOnly:ve().default(!1),wakeToRun:ve().default(!1),powerCountdownSeconds:le().int().min(10).max(600).default(60)}),kj={agent:S().optional()},yR=R({pipelineId:S(),pipelineName:S(),...kj,slot:S(),at:le(),outcome:Pe(["fired","missed","skipped","failed"]),detail:S().optional()}),bR=R({awake:ve(),pending:R({action:xj.exclude(["none"]),pipelineName:S(),at:le().optional()}).optional()});R({settings:bj,autostart:R({available:ve(),registered:ve(),detail:S().optional()}),autostarted:ve(),wake:R({available:ve(),registered:ve(),next:le().optional(),detail:S().optional()}),power:bR,upcoming:he(R({pipelineId:S(),pipelineName:S(),at:le(),...kj})),history:he(yR)});R({}),R({items:he(vR)}),R({id:_a}),R({pipeline:Kf}),R({pipeline:Kf,check:pR}),R({id:_a}),R({}),R({pipeline:Kf}),R({id:_a,from:fc.optional()}),R({runId:S()}),R({}),R({pipelineId:_a.optional(),limit:le().int().min(1).max(100).optional()}),R({items:he(yj)}),R({runId:S(),nodeId:fc,decision:Pe(["continue","stop"])}),R({}),R({}),bj.partial(),R({}),R({}),R({agent:S().optional()}),R({items:he(Cy.extend({lastRun:Ay.optional()}))}),R({task:Cy.extend({id:ql.optional()})}),R({id:ql}),R({}),R({id:ql}),R({id:ql}),R({items:he(Ay)});R({}),R({}),R({});const kR=Pe(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),NR=R({id:S(),incidentId:S().optional(),runId:S().optional(),title:S(),mode:Pe(["diagnose","act"]),state:kR,sessionId:S().optional(),paused:ve(),summary:S().optional(),startedAt:le(),endedAt:le().optional()});R({limit:le().int().min(1).max(100).optional()}),R({items:he(NR)}),R({id:S()}),R({id:S(),then:Pe(["resume","restart","stop"])});const Iy=R({id:S(),game:S(),name:S(),startsAt:le().optional(),endsAt:le().optional(),shopEndsAt:le().optional(),url:S().optional(),kind:S().optional(),description:S().optional(),cover:S().optional(),site:R({source:S(),name:S(),at:le()}).optional(),sources:he(R({id:S(),name:S(),at:le(),web:ve(),startsAt:le().optional(),endsAt:le().optional(),shopEndsAt:le().optional(),cover:S().optional()})).optional(),chosen:S().optional(),shown:R({cover:S().optional(),startsAt:S().optional(),endsAt:S().optional()}).optional(),screen:R({at:le(),remaining:S().optional(),endsAt:le().optional(),evidence:ve(),image:S().optional(),sessionId:S().optional()}).optional(),todo:he(S()),done:he(S()),progress:S().optional(),finished:R({at:le()}).optional(),mismatch:S().optional(),own:R({at:le(),fields:he(Pe(["name","startsAt","endsAt","kind","description","url","cover"])),startsAt:le().optional(),endsAt:le().optional(),cover:S().optional()}).optional()}),Ao="@own",nc="@screen",jR=112e5,wR=R({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:S().min(1).max(jR).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),SR=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,_R=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,ER=R({id:S(),name:S(),homepage:S().optional(),auto:ve(),added:ve().optional()}),CR=R({id:S(),name:S(),aliases:he(S()),scripts:he(S()),timezone:S(),screen:R({target:Pe(["emulator","window"]),window:S().optional()}).optional(),sources:he(ER),builtin:ve(),art:S().optional(),followed:ve().optional(),version:R({name:S(),title:S().optional(),startsAt:le().optional(),endsAt:le().optional(),cover:S().optional(),source:S(),at:le()}).optional(),pools:he(R({name:S(),type:S().optional(),startsAt:le().optional(),endsAt:le(),cover:S().optional(),up:he(S())})).optional(),refreshed:R({at:le(),ok:ve(),count:le(),detail:S().optional()}).optional(),reading:R({state:Pe(["running","done","failed"]),at:le(),sessionId:S().optional(),summary:S().optional()}).optional(),webReading:R({state:Pe(["running","done","failed"]),at:le(),sessionId:S().optional(),summary:S().optional()}).optional()}),Ty=R({report:R({enabled:ve(),at:wg,games:he(S()),soonDays:le().int().min(1).max(30),ai:ve()}),followed:he(S())}),AR=R({lastSentAt:le().optional(),lastDay:S().optional(),lastResult:S().optional(),lastText:S().optional(),next:le().optional()});R({}),R({games:he(CR),activities:he(Iy),settings:Ty,report:AR}),R({game:S().optional()}),R({results:he(R({game:S(),ok:ve(),count:le(),detail:S().optional()}))}),R({game:S(),how:Pe(["screen","web"]).optional(),source:S().optional()}),R({sessionId:S()}),R({}),R({title:S(),text:S()}),R({}),R({channels:he(S()),text:S()}),R({report:Ty.shape.report.partial().optional()}),R({activityId:S()}),R({mediaType:S(),data:S()}),R({url:S().refine(e=>SR.test(e)||_R.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),R({mediaType:S(),data:S()}),R({game:S().min(1)}),R({icon:R({mediaType:S(),data:S()}).optional()}),R({name:S().min(1).max(60)}),R({sessionId:S()}),R({game:S()}),R({items:he(op),from:Pe(["mirrorchyan","builtin"])}),R({game:S(),url:S().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:S().max(30).optional()}),R({source:S(),sessionId:S()}),R({game:S(),source:S()}),R({}),R({}),R({games:he(R({sra:S(),name:S(),followed:ve(),pack:S().optional()}))}),R({sra:S(),follow:ve()}),R({}),R({activityId:S(),todo:he(S().min(1).max(80)).max(30).optional(),done:he(S().min(1).max(80)).max(30).optional(),finished:ve().optional()}),R({game:S(),activityId:S().optional(),name:S().trim().min(1).max(60).nullable().optional(),startsAt:le().nullable().optional(),endsAt:le().nullable().optional(),kind:S().trim().max(20).nullable().optional(),description:S().trim().max(500).nullable().optional(),url:S().trim().refine(e=>e===""||/^https?:\/\/\S+$/.test(e),"只能是 http 或 https 网址").nullable().optional(),cover:K$().optional(),image:wR.optional(),todo:he(S().min(1).max(80)).max(30).optional()}),R({activityId:S(),source:S().nullable()}),R({activityId:S()}),R({activity:Iy.optional()}),R({activityId:S()}),R({});R({game:S().optional()});const Nj=Pe(["ask","full"]),jj=Pe(["default","allow","ask","deny"]),IR=[{id:"pipelines-edit",title:"编辑流水线和定时",description:"起草流水线,「编排」直接修改、保存流水线(pipeline_save),设定时间(schedule_set),以及 dsh 自己的定时任务。",tools:["pipeline_draft","pipeline_save","schedule_set","schedule_create","schedule_edit"]},{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 安装、更新、回滚、删除脚本,运行脚本的安装程序,导入本地脚本,修复运行环境,写、改脚本包(pack_propose,直接生效)。",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:"browser",title:"操作内置浏览器",description:"在内置浏览器里打开网页、点击、输入、按键、滚动、切换标签页(读页面和截图不算)。",tools:["browser_navigate","browser_click","browser_type","browser_press","browser_scroll","browser_tabs"]},{id:"shell",title:"运行命令、改文件",description:"dsh 自带的命令行和文件编辑。只在它请求确认时按这里的设置处理(沙箱里的普通命令不会请求)。",tools:["pwsh","bash","edit","write"],approvalOnly:!0}];R({mode:Nj,since:le().optional(),areas:Os(S(),jj).default({}),recent:he(R({at:le(),sessionId:S(),toolName:S(),reason:S().optional()}))});R({}),R({mode:Nj}),R({area:S(),policy:jj});const TR=R({label:S(),description:S().optional()}),$R=R({id:S(),question:S(),detail:S().optional(),header:S().optional(),options:he(TR).optional(),multiSelect:ve().optional()});R({questionId:S(),sessionId:S(),callId:S().optional(),questions:he($R)});const wj=R({id:S(),selected:he(S()),custom:S().optional()}),MR=Pe(["answered","cancelled","unavailable"]);R({questionId:S(),answers:he(wj)}),R({});R({questionId:S(),outcome:MR,answers:he(wj).optional()});const RR=R({pid:le().int(),label:S(),dataDir:S().optional(),startedAt:le(),warnings:he(S())});R({others:he(RR)});R({});const Sj=R({scripts:he(S()).optional(),games:he(S()).optional()}),$y=R({name:S(),description:S(),whenToUse:S().optional(),source:S(),provider:S(),path:S().optional(),modelInvocable:ve(),userInvocable:ve(),owner:Sj.optional(),removable:ve().optional()}),_j=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,cp=48;R({}),R({skills:he($y)}),R({name:S()}),$y.extend({content:S()}),R({name:S().regex(_j).max(cp),description:S().trim().min(10).max(400),content:S().trim().min(20).max(2e4),scripts:he(S().min(1).max(64)).max(20).optional(),games:he(S().min(1).max(64)).max(20).optional(),replace:ve().optional()}),R({name:S(),replaced:ve()}),R({name:S()}),R({});R({});const Yf=R({repo:tc,branch:S().trim().min(1).max(100).regex(/^[\w./-]+$/)}),My=R({name:S(),description:S(),title:S().optional(),kind:Pe(["game","script","general"]),games:he(S()),scripts:he(S()),repo:S(),path:S(),hash:S(),installed:R({at:le(),update:ve()}).optional(),blocked:S().optional()}),Ry=R({name:S().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});R({refresh:ve().optional()}),R({items:he(My),repos:he(Yf),errors:he(S()),fetchedAt:le().optional()}),Ry.extend({repo:tc.optional()}),R({state:Pe(["current","updated"]),item:My}),R({}),Ry.extend({owner:Sj.nullable()}),R({}),R({repos:he(Yf).min(1).max(10)}),R({repos:he(Yf)});R({});const _g="你",Ej="(不用告诉用户)",Oy=e=>e.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu,"");function OR(e){return Oy(e)===Oy(Ej)}const PR="(你这一轮的最后一段回复会作为结论交回去。在那之前要让对方知道的,用 agent_message 的 update 说,马上送到,说几次都行;交回结论以后还有话,同样发到这条线索:你的普通回复对方看不到。)",zR="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)",LR=/^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/,DR=/^(你和.{1,20}之前的来往,/,FR=")";function Cj(e){var f;const[t="",...n]=e.split(`
104
+ `),i=/^(你在软件里点的:(.*))$/.exec(t),r=i===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(i===null&&r===null)return;const o=n[0]===PR||n[0]===zR,c=o?n.slice(1):n,u=(f=LR.exec(c[0]??""))==null?void 0:f[1],d=u===void 0?c:c.slice(1),h=DR.test(d[0]??"")?d.indexOf(FR):-1;return{by:i!==null?_g:r[1],title:i!==null?i[1]:r[2],returns:o,...u===void 0?{}:{thread:u},body:d.slice(h+1).join(`
105
+ `).trim()}}function Aj(e){const[t="",...n]=e.split(`
106
+ `),i=/^(「([^」]+)」在线索 (\S+) 里(问你|回答了你|告诉你):(.*))$/.exec(t);if(i===null)return;const r=n.join(`
107
+ `).trim(),o=r.lastIndexOf(`
108
+
109
+ (`);return{from:i[1],thread:i[2],kind:i[3]==="问你"?"question":i[3]==="告诉你"?"update":"answer",title:i[4],text:(o===-1?r:r.slice(0,o)).trim()}}function Ij(e){const[t="",...n]=e.split(`
110
+ `),i=/^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(t);if(i===null)return;const r=n.join(`
111
+ `).trim(),o=r.lastIndexOf(`
112
+
113
+ (`);return{agent:i[1],ok:i[2]==="交回了",asker:i[3],title:i[4],reply:(o===-1?r:r.slice(0,o)).trim()}}function UR(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}const Py=/\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;function zy(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[HR(t[1]).replace(Py,"")];const n=/^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(e);if(n!==null)try{return JSON.parse(n[1]).map(r=>String(r.reminder_prompt??"").replace(Py,"")).filter(r=>r!=="")}catch{return[]}}function BR(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>UR(t)).join(";")}`}function HR(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const ZR=Pe(["default","concise","patient","lively","buddy","butler"]),WR=Pe(["plain","same"]),Tj=R({style:ZR,callUser:S().max(20).optional(),custom:S().optional(),peerStyle:WR.optional()}),VR=Tj.partial().extend({name:S().max(20).optional()}),qR=R({persona:Tj,agents:Os(S(),VR)});qR.extend({prompt:S(),prompts:Os(S(),S())});const Ly={default:"",concise:"回答简短直接:先给结论,再给必要的细节;少寒暄,不用表情。",patient:"耐心、讲清楚:每一步说明为什么这么做,用对方听得懂的话,像教一个刚接触的人。",lively:"语气轻松活泼,可以用一点语气词和表情,但信息要准确、不啰嗦。",buddy:"像一起玩游戏的老朋友那样说话:熟悉游戏里的说法,可以适当吐槽和鼓励,但不夸张、不油腻。",butler:"像一位稳重周到的管家:礼貌、条理清楚,主动汇报进度和需要对方决定的事。"};function Dy(e,t){const n=Object.entries(e.agents[t]??{}).filter(([,i])=>i!==void 0);return{...e.persona,...Object.fromEntries(n)}}function Fy(e){const t=[];return e.name!==void 0&&e.name.trim()!==""&&t.push(`你的名字是「${e.name.trim()}」,自称时用这个名字。`),e.callUser!==void 0&&e.callUser.trim()!==""&&t.push(`称呼用户为「${e.callUser.trim()}」。`),Ly[e.style]!==""&&t.push(Ly[e.style]),e.custom!==void 0&&e.custom.trim()!==""&&t.push(`用户对你说话方式的要求:${e.custom.trim()}`),t.length===0?"":(t.push(e.peerStyle==="same"?"和其他 agent 说话时也用这个方式。":"上面是对用户说话的方式。和其他 agent 说话(agent_delegate、agent_message、交回去的结论)用平实的话,直接说事,不用人设和称呼:它们要读的是内容。"),t.push(`软件约定的固定写法(比如「${Ej}」这一句、线索编号、工具的参数)一字不差照写,不加语气词和表情。`),["# 回复风格",...t,"这些只影响你说话的方式,不改变做事的规则:确认、安全限制和不能做的事都照旧;在飞书里回复也一样。"].join(`
114
+ `))}R({});const GR=80,$j=5,Mj=100,KR=30,YR=1,XR=365,QR=[3,7,14,30],up=R({auto:ve(),threshold:le().int().min($j).max(Mj),lowContext:ve(),archiveDays:le().int().min(YR).max(XR).nullable().default(null),ptcSubagents:ve().default(!0)});R({settings:up,applied:up});R({}),R({settings:up});const ba="shared",dp=Pe(["profile","journal","core"]),Eg=2e3,JR=R({agent:S(),sessionId:S(),seq:le().int().min(0)}),Cg=600,Xf=R({id:S(),kind:dp,scope:S(),text:S(),createdAt:S(),updatedAt:S(),by:S(),source:JR.optional()}),eO=R({auto:ve(),model:R({provider:S(),model:S(),reasoningEffort:S().optional()}).nullable()}),Uy=S().trim().min(1).max(Cg);R({}),R({items:he(Xf)}),R({kind:dp,scope:S().min(1).max(64),text:Uy}),R({item:Xf}),R({id:S(),text:Uy,kind:dp.optional(),scope:S().min(1).max(64).optional()}),R({item:Xf}),R({}),eO.extend({forced:ve().optional()}),R({id:S()}),R({removed:ve()});R({});const tO=Pe(["starting","running","stopping","succeeded","failed","cancelled"]),nO=R({type:Pe(["string","integer","number","boolean"]),default:Zo([S(),le(),ve()]).optional(),enum:he(Zo([S(),le()])).optional(),description:S().optional(),choices:he(R({value:S(),label:S(),detail:S().optional()})).optional(),canCreate:ve().optional()}),sO=R({mode:Pe(["auto","platform","off"]),pcLaunch:Pe(["program","maaend"]).optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).optional(),pcExe:S().optional(),pcProcess:S().optional(),androidPackage:S().optional()});R({settings:sO,game:R({name:S().optional(),androidPackage:S().optional(),pcProcess:S().optional(),selfLaunch:S()}),uses:R({adb:ve(),desktop:ve()})});const iO=R({id:S(),title:S(),description:S().optional(),utterances:he(S()),params:Os(S(),nO),input:Pe(["desktop","window","adb","none"]),account:S().optional(),expectedDuration:S().optional()}),Li=S().trim().min(1).max(64),hp=R({id:S(),name:S(),createdAt:le().optional()}),Rj=R({current:S(),items:he(hp)}),rO=R({id:S(),scriptId:S(),scriptName:S(),taskId:S(),taskTitle:S(),params:Os(S(),Zo([S(),le(),ve()])),state:tO,outcome:S().optional(),startedAt:le(),endedAt:le().optional(),exitCode:le().optional(),command:he(S()),resources:he(S()),tags:he(S()),warnings:he(S()),kind:Pe(["task","settings"]),retryOf:S().optional(),halted:ve().optional(),profile:S().optional(),profileName:S().optional()}),Oj=R({at:le(),source:S(),text:S(),level:Pe(["info","progress","done","warning","error"]).optional(),tag:S().optional()});R({scriptId:wt,profile:Li.optional()}),R({tasks:he(iO),runnable:ve(),problem:S().optional()}),R({scriptId:wt,taskId:S().min(1).max(64),params:Os(S(),Zo([S(),le(),ve()])).optional(),profile:Li.optional()}),R({runId:S()}),R({}),R({scriptId:wt.optional()}),R({items:he(rO)}),R({runId:S(),limit:le().int().min(1).max(2e3).optional()}),R({lines:he(Oj)}),R({scriptId:wt}),R({scriptId:wt,name:S().trim().min(1).max(30),from:Wa("kind",[R({kind:ut("copy"),profile:Li}),R({kind:ut("original")}),R({kind:ut("folder"),dir:S().trim().min(1).max(500)})])}),R({profile:hp,files:he(S()),list:Rj}),R({scriptId:wt,profile:Li,name:S().trim().min(1).max(30).optional(),current:ut(!0).optional()}),R({scriptId:wt,profile:Li}),R({scriptId:wt,profile:Li.optional()}),R({importedAt:le().optional(),dir:S(),profile:hp,files:he(R({file:S(),local:ve(),original:ve(),changed:ve()})),drift:he(S())}),R({scriptId:wt,file:S().min(1),profile:Li.optional()}),R({file:S(),content:S(),truncated:ve()}),R({scriptId:wt,profile:Li.optional()}),R({imported:he(S())}),R({scriptId:wt,profile:Li.optional()}),R({runId:S()}),R({}),R({scriptId:wt,taskId:S().min(1),param:S().min(1),name:S().trim().min(1).max(40),profile:Li.optional()}),R({value:S()}),R({scriptId:wt}),R({scriptId:wt,mode:Pe(["auto","platform","off"]).optional(),pcLaunch:Pe(["program","maaend"]).nullable().optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe:S().trim().nullable().optional(),pcProcess:S().trim().nullable().optional(),androidPackage:S().trim().regex(/^[A-Za-z][\w]*(\.[A-Za-z_][\w]*)+$/,"安卓包名像 com.example.game").nullable().optional()}),R({scriptId:wt}),R({exe:S().optional(),candidates:he(R({path:S(),source:S()}))});R({scriptId:S(),list:Rj}),R({runId:S(),lines:he(Oj)});const aO=1,Qf=S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),Pj=R({configured:ve(),source:S().optional(),writable:ve()}),fp="DEEPSEEK_API_KEY",oO=R({id:S(),version:le().int().positive()}),zj=R({id:S(),title:S().nullable(),updatedAt:le(),running:ve(),blank:ve(),live:ve(),cwd:S().optional(),parentId:S().optional(),origin:Pe(["subagent"]).optional(),role:S().optional(),requestedBy:S().optional(),home:S().optional()}),Lj=R({id:S(),name:S(),description:S(),order:le()}),Dj=R({id:S(),requestId:S().optional(),text:S(),images:le().int().optional(),placement:Pe(["next-turn","next-step"])}),Fj=R({contextWindow:le().int().positive(),usedTokens:le().int().nonnegative(),breakdown:R({systemTokens:le().int().nonnegative(),toolsTokens:le().int().nonnegative(),messageTokens:le().int().nonnegative()}).optional()}),lO=R({id:S(),createdAt:le(),cwd:S().optional(),parentId:S().optional(),agentPreset:S().optional()}),fr=R({provider:S(),model:S(),reasoningEffort:S().optional()});R({agents:Os(S(),fr),subAgents:fr.nullable(),subAgentsOf:Os(S(),fr)});const cO=R({from:S(),kind:Pe(["question","answer","update","done"]),text:S(),at:le()}),mp=R({id:S(),messages:he(cO).optional(),chain:he(S()).optional(),parent:S().optional(),fromSession:S(),callId:S().optional(),by:S(),to:S(),toSession:S(),title:S(),task:S(),expecting:S().optional(),state:Pe(["running","waiting","done","failed"]),reply:S().optional(),startedAt:le(),endedAt:le().optional()}),uO=R({id:S(),agent:S(),sessionId:S(),title:S(),prompt:S(),rule:S(),repeats:ve(),next:le()});R({default:fr,groups:he(R({id:S(),name:S(),models:he(R({id:S(),name:S(),description:S().optional(),efforts:he(R({id:S(),name:S()})),defaultEffort:S().optional()}))})),failures:he(R({id:S(),name:S(),message:S()}))});const dO=R({lastUsed:fr.nullable(),next:fr.nullable()}),Jf=Pe(["openai-completions","openai-responses","anthropic-messages"]),hO=S().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),pp=R({id:S().min(1),name:S().optional(),contextWindow:le().int().positive().optional(),maxTokens:le().int().positive().optional(),input:he(Pe(["text","image"])).optional(),efforts:he(S().min(1)).optional()}),fO=R({id:S(),displayName:S(),api:S().optional(),baseURL:S().optional(),models:he(pp),apiKeyRef:S().optional(),credential:Pj.optional(),declared:ve(),active:ve(),error:S().optional()}),mO=R({available:ve(),balances:he(R({currency:S(),total:S(),granted:S(),toppedUp:S()}))}),gp=35e5,pO=R({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp"]),data:S().min(1).max(gp).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:S().max(200).optional()}),gO=R({version:S(),title:S().optional(),publishedAt:S().optional(),url:S(),body:S()});R({});R({accepted:ut(!0)});R({protocolVersion:le().int(),client:R({name:S(),version:S()})}),R({protocolVersion:le().int(),server:R({name:S(),version:S(),dsh:S().optional()}),capabilities:he(oO)}),R({items:he(zj)}),R({cwd:S().optional(),focus:R({scripts:he(S()).optional(),games:he(S()).optional()}).optional(),role:S().optional()}),R({sessionId:S()}),R({sessionIds:he(S()).max(60)}),R({items:he(R({sessionId:S(),text:S().nullable()}))}),R({items:he(Lj)}),R({agentId:S()}),R({sessionId:S()}),R({sessionId:S()}),R({items:he(mp)}),R({sessionId:S()}),R({a:S(),b:S()}),R({items:he(mp)}),R({id:S()}),R({agent:S().optional()}),R({items:he(uO)}),R({id:S()}),R({}),R({sessionId:S(),title:S().min(1)}),R({title:S()}),R({sessionId:S(),maxMessages:le().int().positive().optional()}),R({subscriptionId:S(),header:lO,cursor:le(),events:he(ap),hasMore:ve(),title:S().nullable(),live:SM.nullable(),queue:he(Dj).optional(),context:Fj.optional()}),R({subscriptionId:S()}),R({sessionId:S(),throughSeq:le(),beforeSeq:le(),maxMessages:le().int().positive().optional()}),R({events:he(ap),hasMore:ve()}),R({sessionId:S(),requestId:S(),text:S(),mode:Pe(["queue","steer"]),images:he(pO).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),R({sessionId:S()}),R({sessionId:S()}),R({compacted:ve(),message:S()}),R({sessionId:S(),itemId:S(),action:Pe(["steer","remove"])}),R({attachmentId:S(),mediaType:S(),bytes:le(),width:le(),height:le()}),R({mediaType:S(),data:S()}),R({path:S().min(1)}),R({mediaType:S(),data:S(),path:S()}),R({kind:Pe(["file","folder"]),title:S().max(200).optional(),defaultPath:S().max(1e3).optional(),filterName:S().max(60).optional(),extensions:he(S().regex(/^\w+$/)).max(20).optional()}),R({path:S().optional()}),R({sessionIds:he(S())}),R({sessionId:S()}),R({sessionIds:he(S())}),R({sessionId:S()}),R({sessionIds:he(S())}),R({agentId:S().optional(),sub:ve().optional(),model:fr.nullable()}),R({warning:S().optional()}),fr.extend({sessionId:S()}),R({selected:fr}),R({sessionId:S()}),R({approvalId:S(),decision:Pe(["allow-once","reject"])}),R({refs:he(Qf).min(1).max(64)}),R({items:Os(S(),Pj)}),R({ref:Qf,value:S().min(1).max(4096)}),R({ref:Qf}),R({edition:Pe(["plugin","other"]),version:S().optional()}),R({current:S(),latest:R({version:S(),prerelease:ve(),notesUrl:S(),onNpm:ve().optional(),notes:he(gO).optional()}).optional(),checkedAt:le()}),R({providers:he(fO),revision:le(),writable:ve(),protocols:he(Jf),taken:he(S())}),R({provider:S().optional(),baseURL:sp({protocol:/^https?$/}).optional(),api:Jf.optional(),apiKey:S().min(1).max(4096).optional()}),R({models:he(pp)}),R({provider:S().min(1)}),R({balance:mO.nullable()}),R({id:hO,create:ve(),displayName:S().max(80).optional(),api:Jf,baseURL:sp({protocol:/^https?$/}),models:he(pp).min(1),apiKey:S().min(1).max(4096).optional(),expectedRevision:le().optional()}),R({revision:le(),apiKeyRef:S().optional()}),R({id:S().min(1),removeKey:ve().optional(),expectedRevision:le().optional()}),R({revision:le(),defaultReset:ve()});Wa("kind",[R({kind:ut("upsert"),item:zj.partial().extend({id:S()})}),R({kind:ut("removed"),sessionId:S()})]);R({approvalId:S(),sessionId:S(),toolName:S(),callId:S().optional(),reason:S().optional(),displayReason:Os(S(),S()).optional()});R({subscriptionId:S(),event:ap}),R({subscriptionId:S(),frame:fj}),R({subscriptionId:S(),reason:S()}),R({sessionId:S(),title:S().nullable()}),R({sessionId:S(),message:S()}),R({sessionId:S(),items:he(Dj)}),R({sessionId:S(),context:Fj.nullable()}),R({approvalId:S(),outcome:S()}),R({ref:S()}),R({sessionIds:he(S())}),R({items:he(Lj)}),R({item:mp}),R({}),R({}),dO.extend({sessionId:S()});const Bu={InternalError:-32603,NotInitialized:-32002};class Il extends Error{constructor(n,i,r){super(i);ct(this,"code");ct(this,"data");this.name="RpcError",this.code=n,this.data=r}toJSON(){return this.data===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,data:this.data}}}function xO(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 Ag(e){try{const t=JSON.parse(e);for(const i of["command","cmd","path","file_path","pattern","query","url","description","prompt"]){const r=t[i];if(typeof r=="string"&&r!=="")return r.split(`
115
+ `)[0].slice(0,160)}const n=Object.values(t).find(i=>typeof i=="string");return typeof n=="string"?n.slice(0,160):""}catch{return e.slice(0,160)}}const Uj=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
116
+ `);function vO(e,t,n){return[`优化脚本${e===""?":最近运行过的脚本(script_runs 看最近一周跑过哪些,一个一个来)":`「${e}」`}。把这段时间运行攒下的信息用起来,一次做完下面几件事:`,"1. 重新总结脚本包:script_tasks、script_help 看它现在有哪些任务和参数,script_runs、script_run_log 看最近的运行(成功的看正常流程和用时,失败的看原因);更新过版本就先用 script_changelog 读更新日志。对照它的脚本包,任务、参数、配置文件、完成和出错的日志文字、预计用时有不对或缺的,或者使用说明(guide:功能怎么开启、配置怎么设、运行前检查、常见问题)缺了、过时了、能用运行里遇到的报错补上的,用原来的脚本包 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(`
117
+ `)}const Ig=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>Uj},{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(`
118
+ `)},{name:"编排",aliases:["plan","pipeline"],title:"把脚本编成流水线",arg:"想做什么(可选,例如「每天早上跑完三个游戏的日常」)",expand:e=>[`帮我把脚本编排成流水线:${e===""?"把我装好的各个脚本的日常任务排成每天能自动跑的流程":e}。按技能 pipeline-planning:`,"1. 先 system_info 看电脑配置(能不能同时跑几个游戏),pipeline_list 看已有的流水线,script_tasks 看各脚本有哪些任务;","2. 排好后保存:你是「编排」就用 pipeline_save 直接保存;不是就用 pipeline_draft 起草(草稿,我在「编排」页保存后才会按定时运行),或者交给「编排」。模拟器和前台脚本能并行的并行,失败不要挡住别的;","3. 说清楚为什么这样排、哪些步骤并行、估计多久、建议定在几点跑。"].join(`
119
+ `)},{name:"诊断",aliases:["diagnose","why"],title:"分析脚本为什么失败,给出怎么改的建议",arg:"脚本名或运行 id(可选,不写就看最近失败的)",expand:e=>[`分析${e===""?"最近失败的脚本运行":`「${e}」`}为什么失败:`,"1. 用 script_runs 找到失败的那次运行,script_run_log 看日志(先按错误级别筛,再看出错前后);","2. 对照这个脚本包的技能说明原因:是脚本本身、配置、游戏状态(更新、公告、掉线)、模拟器 / ADB,还是电脑环境;","3. 给出怎么改:改哪项配置、游戏里要做什么、要不要重跑。先不要改任何东西、不要重跑,等我决定。"].join(`
120
+ `)},{name:"优化脚本",aliases:["optimize"],title:"用运行攒下的信息优化脚本:重新总结脚本包、调监控时间、把做过的步骤存成技能",arg:"脚本名(可选,不写就看最近运行过的)",expand:e=>vO(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function yO(e){var n,i,r;const t=(i=(n=/^\/(\S+)/.exec(e.trim()))==null?void 0:n[1])==null?void 0:i.toLowerCase();return t===void 0||(r=Ig.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:r.local}function bO(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function kO(e,t){const n=e.trim(),i=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(n);if(i===null)return n;const r=i[1],o=(i[2]??"").trim(),c=Ig.find(d=>d.name===r.toLowerCase()||d.aliases.includes(r.toLowerCase()));if((c==null?void 0:c.local)!==void 0)return n;if(c!==void 0)return`${n}
121
+
122
+ ${c.expand(o)}`;const u=t.find(d=>d.name===r);return u===void 0?n:`${n}
123
+
124
+ ${bO(u.name,o)}`}function NO(e){if(!e.startsWith("/"))return;const t=e.indexOf(`
125
+
126
+ `);return t<0?void 0:{typed:e.slice(0,t),expansion:e.slice(t+2)}}function jO(e,t,n=!1){const i=/^\/(\S*)$/.exec(e);if(i===null)return[];const r=i[1].toLowerCase(),o=Ig.filter(d=>(n||d.local===void 0)&&[d.name,...d.aliases].some(h=>h.toLowerCase().includes(r))).map(d=>({kind:"command",name:d.name,description:d.title,...d.arg===void 0?{}:{arg:d.arg},command:d})),c=d=>d.toLowerCase().startsWith(r)?0:1,u=t.filter(d=>d.name.toLowerCase().includes(r)||r.length>0&&d.description.toLowerCase().includes(r)).sort((d,h)=>+(d.group===void 0)-+(h.group===void 0)||(d.group??"").localeCompare(h.group??"")||c(d.name)-c(h.name)||d.name.localeCompare(h.name)).map(d=>({kind:"skill",name:d.name,description:d.description,...d.group===void 0?{}:{group:d.group}}));return[...o,...u]}const wO=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function SO(e){var b,k;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 i=/git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/i.exec(t);if(i!==null)return{repo:`${i[1]}/${i[2]}`};const r=w=>{try{return decodeURIComponent(w)}catch{return w}},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:r(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 h=t.slice(u+11).split(/[?#]/)[0].replace(/\/+$/,"").split("/");if(h.length<2||!/^[A-Za-z0-9_.-]+$/.test(h[0]))return;const f=h[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(f))return;const g=`${h[0]}/${f}`,[p,...x]=h.slice(2);if(p==="releases")return x[0]==="tag"&&x[1]!==void 0?{repo:g,tag:r(x.slice(1).join("/"))}:x[0]==="download"&&x.length>=3?{repo:g,tag:r(x.slice(1,-1).join("/")),asset:r(x.at(-1))}:{repo:g};if(p==="tree"&&x.length>0)return{repo:g,branch:r(x[0])};if(p==="archive"){const w=x.join("/").replace(/\.(zip|tar\.gz)$/i,""),j=(b=/^refs\/tags\/(.+)$/.exec(w))==null?void 0:b[1];if(j!==void 0)return{repo:g,tag:r(j)};const E=(k=/^refs\/heads\/(.+)$/.exec(w))==null?void 0:k[1];return E!==void 0?{repo:g,branch:r(E)}:{repo:g,tag:r(w)}}return p===void 0||wO.has(p)?{repo:g}:{repo:g}}const By=1;var ur,bs,Vr,$a,Ud,yi,zo,Lo,_c,gn,xp,vp,yp,Bj,Hj,bp,kp;class _O{constructor(t){Lt(this,gn);ct(this,"status",new Fi({state:"idle",attempt:0}));ct(this,"server",new Fi(null));Lt(this,ur);Lt(this,bs,null);Lt(this,Vr,!1);Lt(this,$a,0);Lt(this,Ud,1);Lt(this,yi,new Map);Lt(this,zo,new Map);Lt(this,Lo,new Set);Lt(this,_c);Wt(this,ur,t)}get generation(){return ze(this,$a)}get ready(){return ze(this,Vr)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||pt(this,gn,yp).call(this)}stop(){clearTimeout(ze(this,_c)),this.status.set({state:"stopped",attempt:0});const t=ze(this,bs);Wt(this,bs,null),pt(this,gn,bp).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,n){let i=ze(this,zo).get(t);return i===void 0&&ze(this,zo).set(t,i=new Set),i.add(n),()=>{i.delete(n)}}onReady(t){return ze(this,Lo).add(t),ze(this,Vr)&&queueMicrotask(()=>t(ze(this,$a))),()=>{ze(this,Lo).delete(t)}}call(t,n,i){return!ze(this,Vr)&&t!=="initialize"?Promise.reject(new Il(Bu.NotInitialized,"not connected to the gateway")):pt(this,gn,xp).call(this,t,n,i)}}ur=new WeakMap,bs=new WeakMap,Vr=new WeakMap,$a=new WeakMap,Ud=new WeakMap,yi=new WeakMap,zo=new WeakMap,Lo=new WeakMap,_c=new WeakMap,gn=new WeakSet,xp=function(t,n,i){const r=ze(this,bs);if(r===null||r.readyState!==By)return Promise.reject(new Il(Bu.NotInitialized,"not connected to the gateway"));if((i==null?void 0:i.aborted)===!0)return Promise.reject(i.reason??new Error("aborted"));const o=H0(this,Ud)._++;return new Promise((c,u)=>{const d=ze(this,ur).callTimeoutMs??6e4,h=d>0?setTimeout(()=>{var p;(p=ze(this,yi).get(o))==null||p.reject(new Il(Bu.InternalError,`${t} timed out`))},d):void 0,f=()=>{var p;ze(this,yi).has(o)&&(pt(this,gn,vp).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(p=ze(this,yi).get(o))==null||p.reject((i==null?void 0:i.reason)instanceof Error?i.reason:new Error("aborted")))};i==null||i.addEventListener("abort",f,{once:!0});const g=()=>{clearTimeout(h),i==null||i.removeEventListener("abort",f),ze(this,yi).delete(o)};ze(this,yi).set(o,{resolve:p=>{g(),c(p)},reject:p=>{g(),u(p)},cleanup:g}),pt(this,gn,vp).call(this,{jsonrpc:"2.0",id:o,method:t,params:n})})},vp=function(t){var n;((n=ze(this,bs))==null?void 0:n.readyState)===By&&ze(this,bs).send(JSON.stringify(t))},yp=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=(ze(this,ur).createSocket??(i=>new WebSocket(i)))(ze(this,ur).url)}catch(i){pt(this,gn,kp).call(this,i instanceof Error?i.message:String(i));return}Wt(this,bs,n),n.addEventListener("open",()=>{ze(this,bs)===n&&pt(this,gn,Bj).call(this,n)}),n.addEventListener("message",i=>{ze(this,bs)===n&&pt(this,gn,Hj).call(this,String(i.data))}),n.addEventListener("close",i=>{if(ze(this,bs)!==n)return;Wt(this,bs,null),pt(this,gn,bp).call(this,"connection lost");const r=typeof i.reason=="string"&&i.reason!==""?i.reason:`closed (${i.code??"?"})`;pt(this,gn,kp).call(this,r)}),n.addEventListener("error",()=>{})},Bj=async function(t){try{const n=await pt(this,gn,xp).call(this,"initialize",{protocolVersion:aO,client:ze(this,ur).clientInfo});if(ze(this,bs)!==t)return;Wt(this,Vr,!0),Wt(this,$a,ze(this,$a)+1),this.server.set(n),this.status.set({state:"open",attempt:0});for(const i of[...ze(this,Lo)])i(ze(this,$a))}catch(n){t.close(4e3,n instanceof Error?n.message:"initialize failed")}},Hj=function(t){let n;try{n=JSON.parse(t)}catch{return}const i=xO(n);if(i==="response"){const r=ze(this,yi).get(n.id);if(r===void 0)return;"error"in n?r.reject(new Il(n.error.code,n.error.message,n.error.data)):r.resolve(n.result)}else if(i==="notification")for(const r of[...ze(this,zo).get(n.method)??[]])try{r(n.params)}catch(o){console.error(`notification handler for ${n.method} failed`,o)}},bp=function(t){Wt(this,Vr,!1);for(const n of[...ze(this,yi).values()])n.reject(new Il(Bu.InternalError,t));ze(this,yi).clear()},kp=function(t){if(this.status.get().state==="stopped")return;const n=this.status.get().attempt+1,{initial:i,max:r}=ze(this,ur).backoffMs??{initial:500,max:1e4},o=Math.min(r,i*2**Math.min(n-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:n,error:t}),Wt(this,_c,setTimeout(()=>pt(this,gn,yp).call(this),o))};const EO={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 ks,Ec,Do,Fo,dr,qr,Cc,Ac,Vt,Np,ld,Xn;class CO{constructor(t,n,i){Lt(this,Vt);ct(this,"id");ct(this,"state",new Fi(EO));Lt(this,ks);Lt(this,Ec);Lt(this,Do,null);Lt(this,Fo,-1);Lt(this,dr,!1);Lt(this,qr,null);Lt(this,Cc);Lt(this,Ac);this.id=t,Wt(this,ks,n),Wt(this,Ec,i),Wt(this,Cc,n.onReady(r=>{r!==ze(this,Fo)&&pt(this,Vt,Np).call(this,r)}))}get subscriptionId(){return ze(this,Do)}async prompt(t,n="queue",i=[]){const r=crypto.randomUUID(),o={requestId:r,text:t,mode:n,sentAt:Date.now(),...i.length===0?{}:{images:i.length}};pt(this,Vt,Xn).call(this,c=>({...c,pending:[...c.pending,o]}));try{await ze(this,ks).call("session/prompt",{sessionId:this.id,requestId:r,text:t,mode:n,...i.length===0?{}:{images:[...i]}})}catch(c){const u=c instanceof Error?c.message:String(c);throw pt(this,Vt,Xn).call(this,d=>({...d,pending:d.pending.map(h=>h.requestId===r?{...h,failed:u}:h)})),c}}dismissPending(t){pt(this,Vt,Xn).call(this,n=>({...n,pending:n.pending.filter(i=>i.requestId!==t)}))}async updateQueue(t,n){await ze(this,ks).call("session/queue/update",{sessionId:this.id,itemId:t,action:n})}async cancel(){await ze(this,ks).call("session/cancel",{sessionId:this.id})}async compact(){return ze(this,ks).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)){pt(this,Vt,Xn).call(this,i=>({...i,loadingOlder:!0}));try{const i=await ze(this,ks).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:n.seq});pt(this,Vt,Xn).call(this,r=>{var u;const o=((u=r.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,c=i.events.filter(d=>d.seq<o);return{...r,events:[...c,...r.events],hasMore:i.hasMore,loadingOlder:!1}})}catch(i){pt(this,Vt,Xn).call(this,r=>({...r,loadingOlder:!1,error:i instanceof Error?i.message:String(i)}))}}}close(){if(ze(this,dr))return;Wt(this,dr,!0),clearTimeout(ze(this,Ac)),ze(this,Cc).call(this);const t=ze(this,Do);pt(this,Vt,ld).call(this,null),t!==null&&ze(this,ks).ready&&ze(this,ks).call("session/close",{subscriptionId:t}).catch(()=>{}),pt(this,Vt,Xn).call(this,n=>({...n,status:"closed"}))}receiveEvent(t){pt(this,Vt,Xn).call(this,n=>{const i=n.events.at(-1);if(i!==void 0&&t.seq<=i.seq)return n;let r=n.pending;t.type==="user/message"&&t.requestId!==void 0&&(r=r.filter(d=>d.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:r,live:o,title:c,running:em(u,o)}})}receiveLive(t){pt(this,Vt,Xn).call(this,n=>{var i;switch(t.type){case"start":{const r={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...n,live:r,running:!0}}case"delta":{const r=n.live;return r===null||r.attemptId!==t.attemptId?n:(r.deltas.push(t),{...n,live:{...r}})}case"end":return((i=n.live)==null?void 0:i.attemptId)!==t.attemptId?n:{...n,live:null,running:em(n.events,null)}}})}receiveClosed(t){pt(this,Vt,ld).call(this,null),!ze(this,dr)&&(pt(this,Vt,Xn).call(this,n=>({...n,status:"error",error:`stream ended: ${t}`})),Wt(this,Ac,setTimeout(()=>{!ze(this,dr)&&ze(this,ks).ready&&pt(this,Vt,Np).call(this,ze(this,Fo))},1e3)))}receiveQueue(t){pt(this,Vt,Xn).call(this,n=>({...n,queue:t,pending:Hy(n.pending,t)}))}receiveContext(t){pt(this,Vt,Xn).call(this,n=>({...n,context:t}))}receiveTitle(t){pt(this,Vt,Xn).call(this,n=>n.title===t?n:{...n,title:t})}}ks=new WeakMap,Ec=new WeakMap,Do=new WeakMap,Fo=new WeakMap,dr=new WeakMap,qr=new WeakMap,Cc=new WeakMap,Ac=new WeakMap,Vt=new WeakSet,Np=async function(t){if(!ze(this,dr))return ze(this,qr)!==null?ze(this,qr):(Wt(this,Fo,t),Wt(this,qr,(async()=>{try{const n=await ze(this,ks).call("session/open",{sessionId:this.id});if(ze(this,dr)){ze(this,ks).call("session/close",{subscriptionId:n.subscriptionId}).catch(()=>{});return}pt(this,Vt,ld).call(this,n.subscriptionId);const i=n.live===null?null:{...n.live,deltas:[...n.live.deltas]};pt(this,Vt,Xn).call(this,r=>{const o=new Set(n.events.flatMap(c=>c.type==="user/message"&&c.requestId!==void 0?[c.requestId]:[]));return{...r,status:"open",header:n.header,title:n.title,events:n.events,cursor:n.cursor,hasMore:n.hasMore,live:i,pending:Hy(r.pending.filter(c=>!o.has(c.requestId)),n.queue??[]),queue:n.queue??[],context:n.context??r.context,running:em(n.events,i),loadingOlder:!1,error:null}})}catch(n){pt(this,Vt,Xn).call(this,i=>({...i,status:"error",error:n instanceof Error?n.message:String(n)}))}finally{Wt(this,qr,null)}})()),ze(this,qr))},ld=function(t){Wt(this,Do,t),ze(this,Ec).bindSubscription(this,t)},Xn=function(t){this.state.set(n=>{const i=t(n);return i===n?n:{...i,version:n.version+1}})};function Hy(e,t){const n=new Set(t.flatMap(i=>i.requestId===void 0?[]:[i.requestId]));return n.size===0?e:e.filter(i=>!n.has(i.requestId))}function em(e,t){if(t!==null)return!0;for(let n=e.length-1;n>=0;n-=1){const i=e[n];if(i.type==="turn/end")return!1;if(i.type==="turn/start")return!0}return!1}const Zy=(e,t)=>t.updatedAt-e.updatedAt;var $s,Ui,Uo,mr,cd,jp;class AO{constructor(t){Lt(this,mr);ct(this,"connection");ct(this,"sessions",new Fi({items:[],loaded:!1,error:null}));ct(this,"approvals",new Fi([]));ct(this,"questions",new Fi([]));ct(this,"capabilities",new Fi(new Set));ct(this,"credentialRevision",new Fi(0));ct(this,"providersRevision",new Fi(0));ct(this,"sessionModels",new Fi(new Map));Lt(this,$s,new Map);Lt(this,Ui,new Map);Lt(this,Uo,!1);this.connection=new _O({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const n=this.connection;n.onReady(()=>{var i;this.capabilities.set(new Set(((i=n.server.get())==null?void 0:i.capabilities.map(r=>r.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),n.on("sessions/changed",i=>{if(i.kind==="removed"){if(this.sessions.get().items.some(o=>o.id===i.sessionId&&o.origin==="subagent")){this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===i.sessionId?{...c,running:!1,live:!1}:c)})),pt(this,mr,jp).call(this);return}this.sessions.set(o=>({...o,items:o.items.filter(c=>c.id!==i.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===i.item.id)){pt(this,mr,jp).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===i.item.id?{...c,...IO(i.item)}:c).sort(Zy)}))}),n.on("session/title",({sessionId:i,title:r})=>{var o;(o=ze(this,$s).get(i))==null||o.handle.receiveTitle(r)}),n.on("session/queue",({sessionId:i,items:r})=>{var o;(o=ze(this,$s).get(i))==null||o.handle.receiveQueue(r)}),n.on("session/context",({sessionId:i,context:r})=>{var o;(o=ze(this,$s).get(i))==null||o.handle.receiveContext(r)}),n.on("session/event",({subscriptionId:i,event:r})=>{var o;return(o=ze(this,Ui).get(i))==null?void 0:o.receiveEvent(r)}),n.on("session/live",({subscriptionId:i,frame:r})=>{var o;return(o=ze(this,Ui).get(i))==null?void 0:o.receiveLive(r)}),n.on("session/closed",({subscriptionId:i,reason:r})=>{const o=ze(this,Ui).get(i);o!==void 0&&o.subscriptionId===i&&o.receiveClosed(r)}),n.on("approval/requested",i=>{this.approvals.set(r=>r.some(o=>o.approvalId===i.approvalId)?r:[...r,i])}),n.on("approval/resolved",({approvalId:i})=>{this.approvals.set(r=>r.filter(o=>o.approvalId!==i))}),n.on("question/requested",i=>{this.questions.set(r=>r.some(o=>o.questionId===i.questionId)?r:[...r,i])}),n.on("question/resolved",({questionId:i})=>{this.questions.set(r=>r.filter(o=>o.questionId!==i))}),n.on("credentials/changed",()=>this.credentialRevision.set(i=>i+1)),n.on("providers/changed",()=>this.providersRevision.set(i=>i+1)),n.on("session/model",({sessionId:i,lastUsed:r,next:o})=>pt(this,mr,cd).call(this,i,{lastUsed:r,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(i=>i+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 ze(this,$s).values())t.close();ze(this,$s).clear(),ze(this,Ui).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(Zy),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:i}=await this.connection.call("sessions/create",{...t===void 0?{}:{cwd:t},...n.role===void 0?{}:{role:n.role}});return await this.refreshSessions(),i}async renameSession(t,n){var r;const i=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:i.title}:c)})),(r=ze(this,$s).get(t))==null||r.handle.receiveTitle(i.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const n=await this.connection.call("session/model",{sessionId:t});return pt(this,mr,cd).call(this,t,n),n}async selectModel(t,n){var o;const{selected:i}=await this.connection.call("session/selectModel",{sessionId:t,...n}),r=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return pt(this,mr,cd).call(this,t,{lastUsed:r,next:i}),i}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,n){const{models:i}=await this.connection.call("providers/discover",t,n);return i}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(i=>i+1),t.apiKey!==void 0&&this.credentialRevision.set(i=>i+1),n}async removeProvider(t){const n=await this.connection.call("providers/remove",t);return this.providersRevision.set(i=>i+1),t.removeKey===!0&&this.credentialRevision.set(i=>i+1),n}async respondApproval(t,n){await this.connection.call("approval/respond",{approvalId:t,decision:n}),this.approvals.set(i=>i.filter(r=>r.approvalId!==t))}async answerQuestion(t,n){await this.connection.call("question/respond",{questionId:t,answers:[...n]}),this.questions.set(i=>i.filter(r=>r.questionId!==t))}openSession(t){const n=ze(this,$s).get(t);if(n!==void 0)return n.refs+=1,n.handle;const i=new CO(t,this.connection,{bindSubscription:(r,o)=>{for(const[c,u]of ze(this,Ui))u===r&&ze(this,Ui).delete(c);o!==null&&ze(this,Ui).set(o,r)}});return ze(this,$s).set(t,{handle:i,refs:1}),i}release(t){const n=ze(this,$s).get(t.id);n===void 0||n.handle!==t||(n.refs-=1,!(n.refs>0)&&(ze(this,$s).delete(t.id),t.close()))}}$s=new WeakMap,Ui=new WeakMap,Uo=new WeakMap,mr=new WeakSet,cd=function(t,n){this.sessionModels.set(i=>new Map(i).set(t,n))},jp=function(){ze(this,Uo)||(Wt(this,Uo,!0),setTimeout(()=>{Wt(this,Uo,!1),this.refreshSessions()},150))};function IO(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const tm=(e,t)=>e.map(n=>n.type===t?n.text:"").join(""),nm=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}}]:[]),TO=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join(""),$O="run_code",MO="ptc-mode";function Vd(e,t,n=[]){var h;const i=[],r=new Map;let o;const c=new Set,u=new Map,d=new Map;for(const f of e)switch(f.type){case"user/message":{const g=tm(f.content,"text");if(f.origin.human)i.push({kind:"user",id:`u:${f.seq}`,text:g,time:f.time,images:f.content.filter(p=>p.type==="image").length,imageRefs:nm(f.content),files:f.content.filter(p=>p.type==="file").length});else if(zy(g)!==void 0)i.push({kind:"context",id:`c:${f.seq}`,title:"定时提醒",summary:BR(zy(g)),text:g,startsTurn:!0});else if(f.replacesHistory===!0)i.push({kind:"context",id:`c:${f.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:g});else if(f.origin.summary!==void 0)i.push({kind:"context",id:`c:${f.seq}`,title:f.origin.kind,summary:f.origin.summary,text:g});else if(f.origin.kind===MO&&o!==void 0){const p=nm(f.content).filter(x=>{var b;return((b=o.images)==null?void 0:b.some(k=>k.attachmentId===x.attachmentId))!==!0});p.length>0&&(o.images=[...o.images??[],...p])}break}case"assistant/message":{c.add(`${f.turn}:${f.step}`);const g=tm(f.content,"text"),p=tm(f.content,"reasoning");(g.trim()!==""||p.trim()!=="")&&i.push({kind:"assistant",id:`a:${f.seq}`,text:g,reasoning:p,live:!1,interrupted:f.interrupted===!0,time:f.time,...f.model===void 0?{}:{model:f.model}});break}case"tool/call":{const g={kind:"tool",id:`t:${f.callId}`,callId:f.callId,name:f.name,arguments:f.arguments,status:"running",time:f.time},p=u.get(f.callId);p!==void 0&&(g.approval=p),r.set(f.callId,g),i.push(g),f.name===$O&&(o=g);break}case"tool/result":{const g=r.get(f.callId);if(g===void 0)break;g.result=TO(f.content);const p=nm(f.content);p.length>0&&(g.images=p),g.status=f.isError?"error":"ok",f.error!==void 0&&(g.error=f.error.message);break}case"approval/asked":if(f.callId!==void 0){d.set(f.approvalId,f.callId),u.set(f.callId,"asked");const g=r.get(f.callId);g!==void 0&&(g.approval="asked")}break;case"approval/decided":{const g=d.get(f.approvalId);if(g===void 0)break;u.set(g,f.outcome);const p=r.get(g);p!==void 0&&(p.approval=f.outcome);break}case"turn/end":for(const g of r.values())g.status==="running"&&(g.status="interrupted");f.reason.kind==="error"?i.push({kind:"notice",id:`e:${f.seq}`,tone:"error",text:f.reason.message??"这一轮出错了"}):f.reason.kind==="aborted"?i.push({kind:"notice",id:`e:${f.seq}`,tone:"info",text:"已停止"}):f.reason.kind==="max-tokens"&&i.push({kind:"notice",id:`e:${f.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":i.push({kind:"notice",id:`k:${f.seq}`,tone:f.error===void 0?"info":"error",text:f.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${f.error}`});break}if(t!==null&&!c.has(`${t.turn}:${t.step}`)){let f="",g="";for(const p of t.deltas)p.kind==="text"?f+=p.text:p.kind==="reasoning"&&(g+=p.text);i.push({kind:"assistant",id:`live:${t.attemptId}`,text:f,reasoning:g,live:!0,interrupted:!1,time:((h=t.deltas[0])==null?void 0:h.time)??Date.now()})}for(const f of n)i.push({kind:"user",id:`p:${f.requestId}`,text:f.text,images:f.images??0,imageRefs:[],files:0,time:f.sentAt,pending:{requestId:f.requestId,...f.failed===void 0?{}:{failed:f.failed}}});return i}var y=Ic();const RO=pg(y);var Va=MN();function OO(e,t){return e.filter(n=>{var i;return((i=n.available)==null?void 0:i.call(n,t))??!0})}const Gr=new Map,kd=new Set;function zn(e){if(Gr.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Gr.set(e.id,e);for(const t of kd)t();return()=>{if(Gr.get(e.id)===e){Gr.delete(e.id);for(const t of kd)t()}}}function Zj(e){return kd.add(e),()=>{kd.delete(e)}}function PO(e){return[...Gr.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.sessionViews??[]).sort((t,n)=>t.order-n.order)}function zO(e){return[...Gr.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.settingsPages??[]).sort((t,n)=>t.order-n.order)}function LO(e){return[...Gr.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.pages??[]).sort((t,n)=>t.order-n.order)}function DO(e){return[...Gr.values()].map(t=>({plugin:t,missing:t.requires.filter(n=>!e.has(n))}))}function je(e){return y.useSyncExternalStore(e.subscribe,e.get,e.get)}function qd(e,t){const[n,i]=y.useState(null);return y.useEffect(()=>{const r=e.openSession(t);return i(r),()=>e.release(r)},[e,t]),n!==null&&n.id===t?n:null}function FO(e){const t=je(e.capabilities),n=Tg();return y.useMemo(()=>PO(t),[t,n])}function UO(e){const t=je(e.capabilities),n=Tg();return y.useMemo(()=>zO(t),[t,n])}function BO(e){const t=je(e.capabilities),n=Tg();return y.useMemo(()=>LO(t),[t,n])}function Tg(){const[e,t]=y.useState(0);return y.useEffect(()=>Zj(()=>t(n=>n+1)),[]),e}function Wj(e,t){const n=je(e.credentialRevision),i=je(e.connection.status),r=je(e.capabilities),o=t.join(`
127
+ `),[c,u]=y.useState({items:null,error:null});return y.useEffect(()=>{if(i.state!=="open"||!r.has("credentials")||o==="")return;let d=!0;return e.describeCredentials(o.split(`
128
+ `)).then(h=>{d&&u({items:h,error:null})}).catch(h=>{d&&u(f=>({...f,error:h instanceof Error?h.message:String(h)}))}),()=>{d=!1}},[e,o,n,i.state,r]),c}function el(e){const t=je(e.credentialRevision),n=je(e.providersRevision),i=je(e.connection.status),r=je(e.capabilities),[o,c]=y.useState({catalog:null,error:null});return y.useEffect(()=>{if(i.state!=="open"||!r.has("models"))return;let u=!0;return e.modelCatalog().then(d=>{u&&c({catalog:d,error:null})}).catch(d=>{u&&c(h=>({...h,error:d instanceof Error?d.message:String(d)}))}),()=>{u=!1}},[e,t,n,i.state,r]),o}function un(e){const[t,n]=y.useState(()=>Date.now());return y.useEffect(()=>{const i=setInterval(()=>n(Date.now()),e);return()=>clearInterval(i)},[e]),t}function HO(e){const t=je(e.connection.status),n=je(e.capabilities),[i,r]=y.useState(void 0);return y.useEffect(()=>e.connection.on("permissions/changed",o=>r(o.mode)),[e]),y.useEffect(()=>{if(t.state!=="open"||!n.has("permissions"))return;let o=!0;return e.connection.call("permissions/get",{}).then(c=>{o&&r(c.mode)}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),i}const ZO={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",eye:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z","eye-off":"M3 3l18 18M10.6 5.1A10 10 0 0 1 12 5c6.5 0 10 7 10 7a17 17 0 0 1-3.1 3.9M6.6 6.6A17 17 0 0 0 2 12s3.5 7 10 7a10 10 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2",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",globe:"M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM3.5 9h17M3.5 15h17M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9c-2.5-2.5-3.5-5.5-3.5-9s1-6.5 3.5-9Z",list:"M9 6h11M9 12h11M9 18h11M4.5 6v.01M4.5 12v.01M4.5 18v.01",more:"M5.5 12h.01M12 12h.01M18.5 12h.01",blank:""};function Q({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:ZO[e]})})}function WO(){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 $g({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 Wy="adg.otherCopies.seen";function VO(e){const t=je(e.connection.status),i=je(e.capabilities).has("instances"),[r,o]=y.useState([]);return y.useEffect(()=>e.connection.on("instances/changed",c=>o(c.others)),[e]),y.useEffect(()=>{if(t.state!=="open"||!i){o([]);return}let c=!0;return e.connection.call("instances/others",{}).then(u=>{c&&o(u.others)}).catch(()=>{}),()=>{c=!1}},[e,t.state,i]),r}function qO({client:e}){const t=VO(e),n=JSON.stringify(t.map(c=>[c.pid,c.warnings])),[i,r]=y.useState(()=>{try{return localStorage.getItem(Wy)}catch{return null}});if(t.length===0||i===n)return null;const o=()=>{try{localStorage.setItem(Wy,n)}catch{}r(n)};return s.jsxs("div",{className:"approval-card other-copies",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(Q,{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 GO={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function KO(e){const t=je(e.connection.status),i=je(e.capabilities).has("schedule"),[r,o]=y.useState(void 0);return y.useEffect(()=>e.connection.on("schedule/power",o),[e]),y.useEffect(()=>{if(t.state!=="open"||!i){o(void 0);return}let c=!0;return e.connection.call("schedule/power",{}).then(u=>{c&&o(u)}).catch(()=>{}),()=>{c=!1}},[e,t.state,i]),r}function YO({client:e,pending:t}){const n=un(1e3),[i,r]=y.useState(!1),[o,c]=y.useState(null),u=GO[t.action],d=async()=>{r(!0),c(null);try{await e.connection.call("schedule/power/cancel",{})}catch(f){c(f instanceof Error?f.message:String(f))}finally{r(!1)}},h=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(Q,{name:"power"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:h===void 0?`其他任务结束后${u}`:`${h} 秒后${u}`}),s.jsxs("span",{className:"approval-tool",children:["「",t.pipelineName,"」设置了结束后",u]})]})]}),t.action==="shutdown"&&h!==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:i,onClick:()=>void d(),children:["取消",u]})})]})}function Gd(e){const t=je(e.connection.status),[n,i]=y.useState({data:null,error:null}),[r,o]=y.useState(0),c=y.useCallback(()=>o(u=>u+1),[]);return y.useEffect(()=>e.connection.on("scripts/changed",()=>c()),[e,c]),y.useEffect(()=>{if(t.state!=="open")return;let u=!0;return e.connection.call("scripts/list",{}).then(d=>{u&&i({data:d,error:null})}).catch(d=>{u&&i(h=>({...h,error:Ie(d)}))}),()=>{u=!1}},[e,t.state,r]),{...n,refresh:c}}function Vj(e){const t=je(e.connection.status),[n,i]=y.useState(new Map);return y.useEffect(()=>e.connection.on("scripts/job",r=>{i(o=>{const c=o.get(r.scriptId);return c!==void 0&&c.id!==r.id&&c.startedAt>r.startedAt?o:new Map(o).set(r.scriptId,r)})}),[e]),y.useEffect(()=>{if(t.state!=="open")return;let r=!0;return e.connection.call("scripts/jobs",{}).then(({items:o})=>{if(!r)return;const c=new Map;for(const u of[...o].sort((d,h)=>d.startedAt-h.startedAt))c.set(u.scriptId,u);i(c)}).catch(()=>{}),()=>{r=!1}},[e,t.state]),n}function Ie(e){return e instanceof Error?e.message:String(e)}function Ea(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 mc={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},qj={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function wa(e){return e!==void 0&&e.endedAt===void 0}const Gj="adg.scriptUpdate.later",Vy=9e3;function qy(){try{return JSON.parse(localStorage.getItem(Gj)??"{}")}catch{return{}}}function XO({client:e}){return je(e.capabilities).has("scripts")?s.jsx(e2,{client:e}):null}function QO({client:e}){return je(e.capabilities).has("scripts")?s.jsx(JO,{client:e}):null}function JO({client:e}){const{data:t}=Gd(e),n=Vj(e),[i,r]=y.useState(null),[o,c]=y.useState(qy),[u,d]=y.useState(new Map);if(y.useEffect(()=>{if(t===null)return;let p=!0;return e.connection.call("scripts/settings",{}).then(x=>{p&&r(x.autoUpdate)}).catch(()=>{}),()=>{p=!1}},[e,t]),t===null||i!=="ask")return null;const h=t.scripts.filter(p=>{var x;return((x=p.update)==null?void 0:x.available)===!0&&o[p.id]!==p.update.latest});if(h.length===0)return null;const f=(p,x)=>{const b={...qy(),[p]:x};try{localStorage.setItem(Gj,JSON.stringify(b))}catch{}c(b)},g=p=>{d(x=>{const b=new Map(x);return b.delete(p),b}),e.connection.call("scripts/update",{id:p}).catch(x=>d(b=>new Map(b).set(p,Ie(x))))};return h.map(p=>{var j;const x=n.get(p.id),b=wa(x),k=p.source.kind==="local"?(j=p.localVersion)==null?void 0:j.version:p.current,w=u.get(p.id);return s.jsxs("div",{className:"reminder script-update-note",role:"status",children:[s.jsx(Q,{name:"download"}),s.jsxs("span",{children:[s.jsx("strong",{children:p.name})," 有新版本 ",p.update.latest,"(当前 ",k??"认不出的版本","),要现在更新吗?",w!==void 0&&s.jsxs("span",{className:"error",children:[" 没有更新成功:",w]})]}),b?s.jsxs("span",{className:"script-update-progress muted",children:[s.jsx("span",{className:"spinner"}),x.message??mc[x.phase],"…"]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"ghost small-button",title:"有更新的版本时再问",onClick:()=>f(p.id,p.update.latest),children:"以后再说"}),s.jsx("button",{type:"button",className:"primary small-button",onClick:()=>g(p.id),children:"更新"})]})]},p.id)})}function e2({client:e}){const[t,n]=y.useState([]),i=y.useRef(new Set);y.useEffect(()=>e.connection.on("scripts/job",o=>{o.phase!=="done"||o.setup!==void 0||o.kind==="env-fix"||i.current.has(o.id)||(i.current.add(o.id),e.connection.call("scripts/get",{id:o.scriptId}).then(c=>c.name,()=>o.scriptId).then(c=>n(u=>[...u,{job:o,name:c}])))}),[e]);const r=o=>n(c=>c.filter(u=>u.job.id!==o));return t.map(o=>s.jsx(t2,{done:o,onClose:()=>r(o.job.id)},o.job.id))}function t2({done:e,onClose:t}){const[n,i]=y.useState(!1);y.useEffect(()=>{if(n)return;const u=setTimeout(t,Vy);return()=>clearTimeout(u)},[n,t]);const{job:r,name:o}=e,c=r.kind==="update";return s.jsxs("div",{className:"approval-card done-card",role:"status",onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),children:[s.jsxs("div",{className:"approval-head",children:[s.jsx("span",{className:"done-badge","aria-hidden":"true",children:s.jsxs("svg",{viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M7.5 12.5l3 3 6-6.5"})]})}),s.jsxs("div",{className:"approval-text",children:[s.jsx("span",{className:"approval-title",children:c?"更新成功":"安装成功"}),s.jsxs("span",{className:"done-line",children:[o,r.version===void 0?"":c?` 已更新到 ${r.version}`:` ${r.version} 已装好`]})]}),s.jsx("button",{className:"ghost icon-button update-close","aria-label":"关闭",onClick:t,children:s.jsx(Q,{name:"close"})})]}),!n&&s.jsx("span",{className:"done-timer",style:{animationDuration:`${Vy}ms`}})]})}function ni(){return window.adgDesktop}/*! @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 Gy(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function n2(e){if(Array.isArray(e))return e}function s2(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,c,u=[],d=!0,h=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(d=(i=o.call(n)).done)&&(u.push(i.value),u.length!==t);d=!0);}catch(f){h=!0,r=f}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(h)throw r}}return u}}function i2(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
129
+ 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 r2(e,t){return n2(e)||s2(e,t)||a2(e,t)||i2()}function a2(e,t){if(e){if(typeof e=="string")return Gy(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)?Gy(e,t):void 0}}const Kj=Object.entries,Ky=Object.setPrototypeOf,o2=Object.isFrozen,Yj=Object.getPrototypeOf,Xj=Object.getOwnPropertyDescriptor;let Pn=Object.freeze,Bn=Object.seal,jo=Object.create,Qj=typeof Reflect<"u"&&Reflect,wp=Qj.apply,Sp=Qj.construct;Pn||(Pn=function(t){return t});Bn||(Bn=function(t){return t});wp||(wp=function(t,n){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return t.apply(n,r)});Sp||(Sp=function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return new t(...i)});const or=Kt(Array.prototype.forEach),l2=Kt(Array.prototype.lastIndexOf),Yy=Kt(Array.prototype.pop),Tl=Kt(Array.prototype.push),c2=Kt(Array.prototype.slice),u2=Kt(Array.prototype.splice),Io=Array.isArray,sm=Jj(Set),im=Kt(Set.prototype.add),$l=Kt(Set.prototype.has),ka=Kt(String.prototype.toLowerCase),rm=Kt(String.prototype.toString),Xy=Kt(String.prototype.match),Ml=Kt(String.prototype.replace),Qy=Kt(String.prototype.indexOf),d2=Kt(String.prototype.trim),h2=Kt(Number.prototype.toString),f2=Kt(Boolean.prototype.toString),Jy=typeof BigInt>"u"?null:Kt(BigInt.prototype.toString),eb=typeof Symbol>"u"?null:Kt(Symbol.prototype.toString),Ns=Kt(Object.prototype.hasOwnProperty),Rl=Kt(Object.prototype.toString),Un=Kt(RegExp.prototype.test),lr=Jj(TypeError);function Kt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return wp(e,t,i)}}function Jj(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return Sp(e,n)}}function jt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ka;if(Ky&&Ky(e,null),!Io(t))return e;let i=t.length;for(;i--;){let r=t[i];if(typeof r=="string"){const o=n(r);o!==r&&(o2(t)||(t[i]=o),r=o)}e[r]=!0}return e}function m2(e){for(let t=0;t<e.length;t++)Ns(e,t)||(e[t]=null);return e}function Ts(e){const t=jo(null);for(const i of Kj(e)){var n=r2(i,2);const r=n[0],o=n[1];Ns(e,r)&&(Io(o)?t[r]=m2(o):o&&typeof o=="object"&&o.constructor===Object?t[r]=Ts(o):t[r]=o)}return t}function p2(e){switch(typeof e){case"string":return e;case"number":return h2(e);case"boolean":return f2(e);case"bigint":return Jy?Jy(e):"0";case"symbol":return eb?eb(e):"Symbol()";case"undefined":return Rl(e);case"function":case"object":{if(e===null)return Rl(e);const t=e,n=Js(t,"toString");if(typeof n=="function"){const i=n(t);return typeof i=="string"?i:Rl(i)}return Rl(e)}default:return Rl(e)}}function Js(e,t){for(;e!==null;){const i=Xj(e,t);if(i){if(i.get)return Kt(i.get);if(typeof i.value=="function")return Kt(i.value)}e=Yj(e)}function n(){return null}return n}function g2(e,t){for(;e!==null;){const n=Xj(e,t);if(n)return n.get?Kt(n.get):null;e=Yj(e)}return null}function x2(e){try{return Un(e,""),!0}catch{return!1}}const tb=Pn(["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"]),am=Pn(["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"]),om=Pn(["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"]),v2=Pn(["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"]),lm=Pn(["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"]),y2=Pn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),nb=Pn(["#text"]),sb=Pn(["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"]),cm=Pn(["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"]),ib=Pn(["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"]),Hu=Pn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),b2=Bn(/{{[\w\W]*|^[\w\W]*}}/g),k2=Bn(/<%[\w\W]*|^[\w\W]*%>/g),N2=Bn(/\${[\w\W]*/g),j2=Bn(/^data-[\-\w.\u00B7-\uFFFF]+$/),w2=Bn(/^aria-[\-\w]+$/),rb=Bn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),S2=Bn(/^(?:\w+script|data):/i),_2=Bn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),E2=Bn(/^html$/i),C2=Bn(/^[a-z][.\w]*(-[.\w]+)+$/i),um=Bn(/<[/\w!]/g),ab=Bn(/<[/\w]/g),A2=Bn(/<\/no(script|embed|frames)/i),ob=Bn(/\/>/i),bn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},I2=Pn(jt({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),T2=function(){return typeof window>"u"?null:window},$2=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let i=null;const r="data-tt-policy-suffix";n&&n.hasAttribute(r)&&(i=n.getAttribute(r));const o="dompurify"+(i?"#"+i:"");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}},lb=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Lr=function(t,n,i,r){return Ns(t,n)&&Io(t[n])?jt(r.base?Ts(r.base):{},t[n],r.transform):i},dm=function(t,n,i){const r=Ns(t,n)?t[n]:void 0;return r&&typeof r=="object"?Ts(r):i()};function ew(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:T2();const t=_e=>ew(_e);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==bn.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const i=n,r=i.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,c=e.Node,u=e.Element,d=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const h=e.DOMParser,f=e.trustedTypes,g=u.prototype,p=Js(g,"cloneNode"),x=Js(g,"remove"),b=Js(g,"removeAttributeNode"),k=Js(g,"nextSibling"),w=Js(g,"childNodes"),j=Js(g,"parentNode"),E=Js(g,"shadowRoot"),N=Js(g,"attributes"),C=c&&c.prototype?Js(c.prototype,"nodeType"):null,L=c&&c.prototype?Js(c.prototype,"nodeName"):null,$=c&&c.prototype?Js(c.prototype,"ownerDocument"):null,O=function(K){return C?C(K):K.nodeType},W=function(K){return L?L(K):K.nodeName},B=g2(g,"namespaceURI"),U=function(K){return B?B(K):K.namespaceURI};if(typeof o=="function"){const _e=n.createElement("template");_e.content&&_e.content.ownerDocument&&(n=_e.content.ownerDocument)}let D,F="",A,T=!1,M=0;const P=function(){if(M>0)throw lr('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.')},V=function(K){P(),M++;try{return D.createHTML(K)}finally{M--}},z=function(K){P(),M++;try{return D.createScriptURL(K)}finally{M--}},H=function(){return T||(A=$2(f,r),T=!0),A},G=n,Z=G.implementation,Y=G.createNodeIterator,X=G.createDocumentFragment,re=G.getElementsByTagName,ee=i.importNode;let te=lb();t.isSupported=typeof Kj=="function"&&typeof j=="function"&&Z&&Z.createHTMLDocument!==void 0;const ne=b2,se=k2,oe=N2,de=j2,we=w2,Se=S2,fe=_2,xe=C2;let De=rb,Me=null;const Ce=jt({},[...tb,...am,...om,...lm,...nb]);let Fe=null;const ot=jt({},[...sb,...cm,...ib,...Hu]);let ht=Object.seal(jo(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}})),Pt=null,Ln=null;const an=Object.seal(jo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let dn=!0,hn=!0,on=!1,ln=!0,Ut=!1,Hn=!0,wn=!1,Ss=!1,Ii=null,ii=null,ri=!1,Ds=!1,Fs=!1,Us=!1,Bs=!0,ai=!1;const oi="user-content-";let os=!0,Qn=!1,Sn=null,ie={},ye=null;const Le=jt({},["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 tt=null;const At=jt({},["audio","video","img","source","image","track"]);let Tt=null;const Be=jt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ue="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",kt="http://www.w3.org/1999/xhtml";let bt=kt,Zn=!1,ls=null;const li=jt({},[Ue,Xe,kt],rm),vr=Pn(["mi","mo","mn","ms","mtext"]);let ci=jt({},vr);const yr=Pn(["annotation-xml"]);let Wn=jt({},yr);const Vi=jt({},["title","style","font","a","script"]);let cs=null;const Ti=["application/xhtml+xml","text/html"],br="text/html";let Mt=null,_s=null;const Jn=n.createElement("form"),qi=function(K){return K instanceof RegExp||K instanceof Function},ui=function(){let K=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(_s&&_s===K)return;(!K||typeof K!="object")&&(K={}),K=Ts(K),cs=Ti.indexOf(K.PARSER_MEDIA_TYPE)===-1?br:K.PARSER_MEDIA_TYPE,Mt=cs==="application/xhtml+xml"?rm:ka,Me=Lr(K,"ALLOWED_TAGS",Ce,{transform:Mt}),Fe=Lr(K,"ALLOWED_ATTR",ot,{transform:Mt}),ls=Lr(K,"ALLOWED_NAMESPACES",li,{transform:rm}),Tt=Lr(K,"ADD_URI_SAFE_ATTR",Be,{transform:Mt,base:Be}),tt=Lr(K,"ADD_DATA_URI_TAGS",At,{transform:Mt,base:At}),ye=Lr(K,"FORBID_CONTENTS",Le,{transform:Mt}),Pt=Lr(K,"FORBID_TAGS",Ts({}),{transform:Mt}),Ln=Lr(K,"FORBID_ATTR",Ts({}),{transform:Mt}),ie=Ns(K,"USE_PROFILES")?K.USE_PROFILES&&typeof K.USE_PROFILES=="object"?Ts(K.USE_PROFILES):K.USE_PROFILES:!1,dn=K.ALLOW_ARIA_ATTR!==!1,hn=K.ALLOW_DATA_ATTR!==!1,on=K.ALLOW_UNKNOWN_PROTOCOLS||!1,ln=K.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ut=K.SAFE_FOR_TEMPLATES||!1,Hn=K.SAFE_FOR_XML!==!1,wn=K.WHOLE_DOCUMENT||!1,Ds=K.RETURN_DOM||!1,Fs=K.RETURN_DOM_FRAGMENT||!1,Us=K.RETURN_TRUSTED_TYPE||!1,ri=K.FORCE_BODY||!1,Bs=K.SANITIZE_DOM!==!1,ai=K.SANITIZE_NAMED_PROPS||!1,os=K.KEEP_CONTENT!==!1,Qn=K.IN_PLACE||!1,De=x2(K.ALLOWED_URI_REGEXP)?K.ALLOWED_URI_REGEXP:rb,bt=typeof K.NAMESPACE=="string"?K.NAMESPACE:kt,ci=dm(K,"MATHML_TEXT_INTEGRATION_POINTS",()=>jt({},vr)),Wn=dm(K,"HTML_INTEGRATION_POINTS",()=>jt({},yr));const ce=dm(K,"CUSTOM_ELEMENT_HANDLING",()=>jo(null));if(ht=jo(null),Ns(ce,"tagNameCheck")&&qi(ce.tagNameCheck)&&(ht.tagNameCheck=ce.tagNameCheck),Ns(ce,"attributeNameCheck")&&qi(ce.attributeNameCheck)&&(ht.attributeNameCheck=ce.attributeNameCheck),Ns(ce,"allowCustomizedBuiltInElements")&&typeof ce.allowCustomizedBuiltInElements=="boolean"&&(ht.allowCustomizedBuiltInElements=ce.allowCustomizedBuiltInElements),Bn(ht),Ut&&(hn=!1),Fs&&(Ds=!0),ie&&(Me=jt({},nb),Fe=jo(null),ie.html===!0&&(jt(Me,tb),jt(Fe,sb)),ie.svg===!0&&(jt(Me,am),jt(Fe,cm),jt(Fe,Hu)),ie.svgFilters===!0&&(jt(Me,om),jt(Fe,cm),jt(Fe,Hu)),ie.mathMl===!0&&(jt(Me,lm),jt(Fe,ib),jt(Fe,Hu))),an.tagCheck=null,an.attributeCheck=null,Ns(K,"ADD_TAGS")&&(typeof K.ADD_TAGS=="function"?an.tagCheck=K.ADD_TAGS:Io(K.ADD_TAGS)&&(Me===Ce&&(Me=Ts(Me)),jt(Me,K.ADD_TAGS,Mt))),Ns(K,"ADD_ATTR")&&(typeof K.ADD_ATTR=="function"?an.attributeCheck=K.ADD_ATTR:Io(K.ADD_ATTR)&&(Fe===ot&&(Fe=Ts(Fe)),jt(Fe,K.ADD_ATTR,Mt))),Ns(K,"ADD_FORBID_CONTENTS")&&Io(K.ADD_FORBID_CONTENTS)&&(ye===Le&&(ye=Ts(ye)),jt(ye,K.ADD_FORBID_CONTENTS,Mt)),os&&(Me["#text"]=!0),wn&&jt(Me,["html","head","body"]),Me.table&&(jt(Me,["tbody"]),delete Pt.tbody),K.TRUSTED_TYPES_POLICY){if(typeof K.TRUSTED_TYPES_POLICY.createHTML!="function")throw lr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof K.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw lr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const ke=D;D=K.TRUSTED_TYPES_POLICY;try{F=V("")}catch(Ne){throw D=ke,Ne}}else K.TRUSTED_TYPES_POLICY===null?(D=void 0,F=""):(D===void 0&&(D=H()),D&&typeof F=="string"&&(F=V("")));Pn&&Pn(K),_s=K},Rt=jt({},[...am,...om,...v2]),kr=jt({},[...lm,...y2]),Gi=function(K,ce,ke){return ce.namespaceURI===kt?K==="svg":ce.namespaceURI===Ue?K==="svg"&&(ke==="annotation-xml"||ci[ke]):!!Rt[K]},di=function(K,ce,ke){return ce.namespaceURI===kt?K==="math":ce.namespaceURI===Xe?K==="math"&&Wn[ke]:!!kr[K]},$i=function(K,ce,ke){return ce.namespaceURI===Xe&&!Wn[ke]||ce.namespaceURI===Ue&&!ci[ke]?!1:!kr[K]&&(Vi[K]||!Rt[K])},$e=function(K){const ce=U(K),ke=ka(W(K)),Ne=j(K);let Ge,et;return Ne&&O(Ne)===bn.element?(Ge={namespaceURI:U(Ne)},et=ka(W(Ne))):(Ge={namespaceURI:bt},et="template"),ls[ce]?ce===Xe?Gi(ke,Ge,et):ce===Ue?di(ke,Ge,et):ce===kt?$i(ke,Ge,et):!!(cs==="application/xhtml+xml"&&ls[ce]):!1},We=function(K){Tl(t.removed,{element:K});try{j(K).removeChild(K)}catch{if(x(K),!j(K))throw lr("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},lt=function(K,ce,ke){try{b(K,ce)}catch{try{K.removeAttribute(ke)}catch{}}},dt=function(K){Hs(K);const ce=w(K);ce&&or(c2(ce),Ne=>{try{x(Ne)}catch{}});const ke=O(K)===bn.element?N(K):null;if(ke)for(let Ne=ke.length-1;Ne>=0;--Ne){const Ge=ke[Ne],et=Ge&&Ge.name;typeof et=="string"&&lt(K,Ge,et)}},It=function(K,ce,ke){if(!ke)try{ke=ce.getAttributeNode(K)}catch{ke=null}Tl(t.removed,{attribute:ke||null,from:ce});try{ke?b(ce,ke):ce.removeAttribute(K)}catch{try{ce.removeAttribute(K)}catch{}}if(K==="is")if(Ds||Fs)try{We(ce)}catch{}else try{ce.setAttribute(K,"")}catch{}},Ot=function(K){const ce=N(K);if(ce)for(let ke=ce.length-1;ke>=0;--ke){const Ne=ce[ke],Ge=Ne&&Ne.name;typeof Ge!="string"||Fe[Mt(Ge)]||lt(K,Ne,Ge)}},Vn=function(K,ce){let ke=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const Ne=[K];for(;Ne.length>0;){const Ge=Ne.pop();if(ce(Ge)===!1)continue;if(ke&&O(Ge)===bn.element){const mt=E(Ge);hs(mt)&&Ne.push(mt)}const et=w(Ge);if(et)for(let mt=et.length-1;mt>=0;--mt)Ne.push(et[mt])}},Hs=function(K){Vn(K,ce=>{O(ce)===bn.element&&Ot(ce)})},fn=function(K){const ce=[];return Vn(K,ke=>{ce.push(ke)},!0),ce},_n=function(K,ce){const ke=sm();or(fn(K),Ne=>{O(Ne)===bn.element&&im(ke,Ne)}),or(ce,Ne=>{O(Ne)===bn.element&&!$l(ke,Ne)&&Ot(Ne)})},Zs=function(K,ce){let ke=!1;return or(t.removed,Ne=>{Ne.element&&(ke=ke||Ne.element===K,Hs(Ne.element))}),_n(K,ce),ke},Ws=8,us=function(K,ce){const ke=Sn;let Ne=null;const Ge=()=>(Ne||(Ne=sm(),or(ce,et=>{im(Ne,et)})),Ne);for(let et=0;;et++){const mt=fn(K),mn=[K];let fs=!1;if(or(mt,vn=>{O(vn)===bn.documentFragment?Tl(mn,vn):!fs&&!$l(ke,vn)&&(fs=$l(Ge(),vn))}),!fs)return;if(et>=Ws)throw lr("the tree kept changing during in-place sanitization; refusing to return it");or(mn,(vn,In)=>{ia(vn,In>0,K,Ge())})}},ia=function(K,ce,ke,Ne){const Ge=ds(K);let et;for(;et=Ge.nextNode();)!$l(Ne,et)||$l(Sn,et)||(ce&&ft(te.uponSanitizeShadowNode,et,null),He(et,ke),Xi(et,ke),hs(et.content)&&aa(et.content))},Nr=function(K){Sn&&im(Sn,K)},Mi=function(K,ce){return Hn?K==="patchsrc"?!0:K==="for"&&ce!=="label"&&ce!=="output":!1},jr=function(K){Hn&&Vn(K,ce=>{const ke=O(ce);if(ke===bn.processingInstruction||ke===bn.comment&&Un(ab,ce.data)){try{x(ce)}catch{}return!1}if(ke===bn.element){const Ne=ce,Ge=Mt(W(ce));try{Ne.hasAttribute&&Ne.hasAttribute("patchsrc")&&Ne.removeAttribute("patchsrc"),Ne.hasAttribute&&Ne.hasAttribute("for")&&Mi("for",Ge)&&Ne.removeAttribute("for")}catch{}}return!0})},es=function(K){let ce=null,ke=null;if(ri)K="<remove></remove>"+K;else{const et=Xy(K,/^[\r\n\t ]+/);ke=et&&et[0]}cs==="application/xhtml+xml"&&bt===kt&&(K='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+K+"</body></html>");const Ne=D?V(K):K;if(bt===kt)try{ce=new h().parseFromString(Ne,cs)}catch{}if(!ce||!ce.documentElement){ce=Z.createDocument(bt,"template",null);try{ce.documentElement.innerHTML=Zn?F:Ne}catch{}}const Ge=ce.body||ce.documentElement;return K&&ke&&Ge.insertBefore(n.createTextNode(ke),Ge.childNodes[0]||null),bt===kt?re.call(ce,wn?"html":"body")[0]:wn?ce.documentElement:Ge},ds=function(K){const ce=$?$(K):K.ownerDocument;return Y.call(ce||K,K,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},En=function(K){return K=Ml(K,ne," "),K=Ml(K,se," "),K=Ml(K,oe," "),K},Vs=function(K){var ce;vt(K);const ke=(ce=K.querySelectorAll)===null||ce===void 0?void 0:ce.call(K,"template");ke&&or(ke,Ne=>{hs(Ne.content)&&Vs(Ne.content)})},vt=function(K){K.normalize();const ce=$?$(K):K.ownerDocument,ke=Y.call(ce||K,K,d.SHOW_TEXT|d.SHOW_COMMENT|d.SHOW_CDATA_SECTION|d.SHOW_PROCESSING_INSTRUCTION,null);let Ne=ke.nextNode();for(;Ne;)Ne.data=En(Ne.data),Ne=ke.nextNode()},it=function(K){const ce=L?L(K):null;return typeof ce!="string"||Mt(ce)!=="form"?!1:typeof K.nodeName!="string"||typeof K.textContent!="string"||typeof K.removeChild!="function"||K.attributes!==N(K)||typeof K.removeAttribute!="function"||typeof K.removeAttributeNode!="function"||typeof K.getAttributeNode!="function"||typeof K.setAttribute!="function"||typeof K.namespaceURI!="string"||typeof K.insertBefore!="function"||typeof K.hasChildNodes!="function"||K.nodeType!==C(K)||K.childNodes!==w(K)},hs=function(K){if(!C||typeof K!="object"||K===null)return!1;try{return C(K)===bn.documentFragment}catch{return!1}},zt=function(K){if(!C||typeof K!="object"||K===null)return!1;try{return typeof C(K)=="number"}catch{return!1}};function ft(_e,K,ce){_e.length!==0&&or(_e,ke=>{ke.call(t,K,ce,_s)})}const Ki=function(K,ce){return!!(Hn&&K.hasChildNodes()&&!zt(K.firstElementChild)&&Un(um,K.textContent)&&Un(um,K.innerHTML)||Hn&&I2[ce]&&O(K)===bn.element&&U(K)===kt&&(zt(K.firstElementChild)||typeof K.textContent=="string"&&Un(um,K.textContent))||K.nodeType===bn.processingInstruction||Hn&&K.nodeType===bn.comment&&Un(ab,K.data))},ts=function(K,ce){if(K instanceof RegExp)return Un(K,ce);if(K instanceof Function){for(var ke=arguments.length,Ne=new Array(ke>2?ke-2:0),Ge=2;Ge<ke;Ge++)Ne[Ge-2]=arguments[Ge];return!!K(ce,...Ne)}return!1},Yi=function(K,ce,ke){if(!Pt[ce]&&Bt(ce)&&ts(ht.tagNameCheck,ce))return!1;if(os&&!ye[ce]&&!ye[ka(ce)]){const Ne=j(K),Ge=w(K);if(Ge&&Ne){const et=Ge.length;for(let mt=et-1;mt>=0;--mt){const mn=K===ke?p(Ge[mt],!0):Ge[mt];Ne.insertBefore(mn,k(K))}}}return We(K),!0},hi=function(K,ce,ke,Ne){return K.length===0?ce:ce===ke||ce===Ne?Ts(ce):ce},Re=function(K,ce){return K===ce||j(K)!==null?!1:(Qn&&Hs(K),!0)},He=function(K,ce){if(Nr(K),ft(te.beforeSanitizeElements,K,null),Re(K,ce))return!0;if(it(K))return We(K),!0;const ke=Mt(W(K));if(Me=hi(te.uponSanitizeElement,Me,Ce,Ii),ft(te.uponSanitizeElement,K,{tagName:ke,allowedTags:Me}),Re(K,ce))return!0;if(Ki(K,ke))return We(K),!0;if(Pt[ke]||!(an.tagCheck instanceof Function&&an.tagCheck(ke))&&!Me[ke]){const Ne=Yi(K,ke,ce);return Ne===!1&&(ft(te.afterSanitizeElements,K,null),Re(K,ce))?!0:Ne}if(O(K)===bn.element&&!$e(K)||(ke==="noscript"||ke==="noembed"||ke==="noframes")&&Un(A2,K.innerHTML))return We(K),!0;if(Ut&&K.nodeType===bn.text){const Ne=En(K.textContent);K.textContent!==Ne&&(Tl(t.removed,{element:K.cloneNode()}),K.textContent=Ne)}return ft(te.afterSanitizeElements,K,null),Re(K,ce)},rt=function(K,ce,ke){if(Ln[ce]||Mi(ce,K)||Bs&&(ce==="id"||ce==="name")&&(ke in n||ke in Jn))return!1;const Ne=Fe[ce]||an.attributeCheck instanceof Function&&an.attributeCheck(ce,K);return hn&&Un(de,ce)||dn&&Un(we,ce)?!0:Ne?Tt[ce]||Un(De,Ml(ke,fe,""))||(ce==="src"||ce==="xlink:href"||ce==="href")&&K!=="script"&&Qy(ke,"data:")===0&&tt[K]||on&&!Un(Se,Ml(ke,fe,""))?!0:!ke:Bt(K)&&ts(ht.tagNameCheck,K)&&ts(ht.attributeNameCheck,ce,K)||ce==="is"&&ht.allowCustomizedBuiltInElements&&ts(ht.tagNameCheck,ke)},xt=jt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Bt=function(K){return!xt[ka(K)]&&Un(xe,K)},xn=function(K,ce,ke,Ne){if(D&&typeof f=="object"&&typeof f.getAttributeType=="function"&&!ke)switch(f.getAttributeType(K,ce)){case"TrustedHTML":return V(Ne);case"TrustedScriptURL":return z(Ne)}return Ne},nl=function(K,ce,ke,Ne){try{return ke?K.setAttributeNS(ke,ce,Ne):K.setAttribute(ce,Ne),it(K)?(We(K),!1):!0}catch{return It(ce,K),!1}},ra=function(K,ce){return Hn&&Un(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ce)?!0:ka(K)==="attributename"&&Xy(ce,"href")!==null},Xi=function(K,ce){if(ft(te.beforeSanitizeAttributes,K,null),Re(K,ce))return;const ke=K.attributes;if(!ke||it(K))return;Fe=hi(te.uponSanitizeAttribute,Fe,ot,ii);const Ne={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Fe,forceKeepAttr:void 0};let Ge=ke.length;const et=Mt(K.nodeName);for(;Ge--;){const mt=ke[Ge],mn=mt.name,fs=mt.namespaceURI,vn=mt.value,In=Mt(mn),Qi=vn;let Jt=mn==="value"?Qi:d2(Qi),Ya=!1;if(Ne.attrName=In,Ne.attrValue=Jt,Ne.keepAttr=!0,Ne.forceKeepAttr=void 0,ft(te.uponSanitizeAttribute,K,Ne),Jt=Ne.attrValue,ai&&(In==="id"||In==="name")&&Qy(Jt,oi)!==0&&(It(mn,K,mt),Jt=oi+Jt,Ya=!0),ra(mn,Jt)){It(mn,K,mt);continue}if(!Ne.forceKeepAttr){if(!Ne.keepAttr){It(mn,K,mt);continue}if(!ln&&Un(ob,Jt)){It(mn,K,mt);continue}if(Ut&&(Jt=En(Jt)),!rt(et,In,Jt)){It(mn,K,mt);continue}Jt=xn(et,In,fs,Jt),Jt!==Qi&&nl(K,mn,fs,Jt)&&Ya&&Yy(t.removed)}}ft(te.afterSanitizeAttributes,K,null),Re(K,ce)},aa=function(K){let ce=null;const ke=ds(K);for(ft(te.beforeSanitizeShadowDOM,K,null);ce=ke.nextNode();)if(ft(te.uponSanitizeShadowNode,ce,null),He(ce,K),Xi(ce,K),hs(ce.content)&&aa(ce.content),O(ce)===bn.element){const Ne=E(ce);hs(Ne)&&(Ka(Ne),aa(Ne))}Ut&&vt(K),ft(te.afterSanitizeShadowDOM,K,null)},Ka=function(K){const ce=[{node:K,shadow:null}];for(;ce.length>0;){const ke=ce.pop();if(ke.shadow){aa(ke.shadow);continue}const Ne=ke.node,Ge=O(Ne)===bn.element,et=w(Ne);if(et)for(let mt=et.length-1;mt>=0;--mt)ce.push({node:et[mt],shadow:null});if(Ge){const mt=L?L(Ne):null;if(typeof mt=="string"&&Mt(mt)==="template"){const mn=Ne.content;hs(mn)&&ce.push({node:mn,shadow:null})}}if(Ge){const mt=E(Ne);hs(mt)&&ce.push({node:null,shadow:mt},{node:mt,shadow:null})}}};return t.sanitize=function(_e){let K=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ce=null,ke=null,Ne=null,Ge=null;if(Zn=!_e,Zn&&(_e="<!-->"),typeof _e!="string"&&!zt(_e)&&(_e=p2(_e),typeof _e!="string"))throw lr("dirty is not a string, aborting");if(!t.isSupported)return _e;Ss?(Me=Ii,Fe=ii):ui(K),(te.uponSanitizeElement.length>0||te.uponSanitizeAttribute.length>0)&&(Me=Ts(Me)),te.uponSanitizeAttribute.length>0&&(Fe=Ts(Fe)),t.removed=[];const et=Qn&&typeof _e!="string"&&zt(_e);let mt=[];const mn=Sn;if(et){jr(_e);const In=W(_e);if(typeof In=="string"){const Qi=Mt(In);if(!Me[Qi]||Pt[Qi])throw dt(_e),lr("root node is forbidden and cannot be sanitized in-place")}if(it(_e))throw dt(_e),lr("root node is clobbered and cannot be sanitized in-place");mt=fn(_e),Sn=sm()}else if(zt(_e))ce=es("<!---->"),ke=ce.ownerDocument.importNode(_e,!0),ke.nodeType===bn.element&&ke.nodeName==="BODY"||ke.nodeName==="HTML"?ce=ke:ce.appendChild(ke),Ka(ce);else{if(!Ds&&!Ut&&!wn&&_e.indexOf("<")===-1)return D&&Us?V(_e):_e;if(ce=es(_e),!ce)return Ds?null:Us?F:""}ce&&ri&&We(ce.firstChild);const fs=et?_e:ce;try{et&&Ka(_e);const In=ds(fs);for(;Ne=In.nextNode();)He(Ne,fs),Xi(Ne,fs),hs(Ne.content)&&aa(Ne.content);et&&us(_e,mt)}catch(In){throw et&&(dt(_e),Zs(_e,mt)),In}finally{Sn=mn}if(et){if(Zs(_e,mt))throw lr("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ut&&Vs(_e),_e}if(Ds){if(Ut&&Vs(ce),Fs)for(Ge=X.call(ce.ownerDocument);ce.firstChild;)Ge.appendChild(ce.firstChild);else Ge=ce;return(Fe.shadowroot||Fe.shadowrootmode)&&(Ge=ee.call(i,Ge,!0)),Ge}let vn=wn?ce.outerHTML:ce.innerHTML;return wn&&Me["!doctype"]&&ce.ownerDocument&&ce.ownerDocument.doctype&&ce.ownerDocument.doctype.name&&Un(E2,ce.ownerDocument.doctype.name)&&(vn="<!DOCTYPE "+ce.ownerDocument.doctype.name+`>
130
+ `+vn),Ut&&(vn=En(vn)),D&&Us?V(vn):vn},t.setConfig=function(){let _e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ui(_e),Ss=!0,Ii=Me,ii=Fe},t.clearConfig=function(){_s=null,Ss=!1,Ii=null,ii=null,D=A,F=""},t.isValidAttribute=function(_e,K,ce){_s||ui({});const ke=Mt(_e),Ne=Mt(K);return typeof ce=="string"&&(ra(K,ce)||!ln&&Un(ob,ce))?!1:rt(ke,Ne,ce)},t.addHook=function(_e,K){typeof K=="function"&&Ns(te,_e)&&Tl(te[_e],K)},t.removeHook=function(_e,K){if(Ns(te,_e)){if(K!==void 0){const ce=l2(te[_e],K);return ce===-1?void 0:u2(te[_e],ce,1)[0]}return Yy(te[_e])}},t.removeHooks=function(_e){Ns(te,_e)&&(te[_e]=[])},t.removeAllHooks=function(){te=lb()},t}var Mg=ew();function Rg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var qa=Rg();function tw(e){qa=e}var sc={exec:()=>null};function Et(e,t=""){let n=typeof e=="string"?e:e.source,i={replace:(r,o)=>{let c=typeof o=="string"?o:o.source;return c=c.replace(as.caret,"$1"),n=n.replace(r,c),i},getRegex:()=>new RegExp(n,t)};return i}var M2=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),as={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")},R2=/^(?:[ \t]*(?:\n|$))+/,O2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,P2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,$c=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,z2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Og=/(?:[*+-]|\d{1,9}[.)])/,nw=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,sw=Et(nw).replace(/bull/g,Og).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(),L2=Et(nw).replace(/bull/g,Og).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(),Pg=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,D2=/^[^\n]+/,zg=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,F2=Et(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",zg).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),U2=Et(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Og).getRegex(),Kd="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",Lg=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,B2=Et("^ {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",Lg).replace("tag",Kd).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),iw=Et(Pg).replace("hr",$c).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",Kd).getRegex(),H2=Et(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",iw).getRegex(),Dg={blockquote:H2,code:O2,def:F2,fences:P2,heading:z2,hr:$c,html:B2,lheading:sw,list:U2,newline:R2,paragraph:iw,table:sc,text:D2},cb=Et("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",$c).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",Kd).getRegex(),Z2={...Dg,lheading:L2,table:cb,paragraph:Et(Pg).replace("hr",$c).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",cb).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",Kd).getRegex()},W2={...Dg,html:Et(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Lg).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:sc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Et(Pg).replace("hr",$c).replace("heading",` *#{1,6} *[^
131
+ ]`).replace("lheading",sw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},V2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,q2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,rw=/^( {2,}|\\)\n(?!\s*$)/,G2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Yd=/[\p{P}\p{S}]/u,Fg=/[\s\p{P}\p{S}]/u,aw=/[^\s\p{P}\p{S}]/u,K2=Et(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Fg).getRegex(),ow=/(?!~)[\p{P}\p{S}]/u,Y2=/(?!~)[\s\p{P}\p{S}]/u,X2=/(?:[^\s\p{P}\p{S}]|~)/u,Q2=Et(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",M2?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),lw=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,J2=Et(lw,"u").replace(/punct/g,Yd).getRegex(),eP=Et(lw,"u").replace(/punct/g,ow).getRegex(),cw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",tP=Et(cw,"gu").replace(/notPunctSpace/g,aw).replace(/punctSpace/g,Fg).replace(/punct/g,Yd).getRegex(),nP=Et(cw,"gu").replace(/notPunctSpace/g,X2).replace(/punctSpace/g,Y2).replace(/punct/g,ow).getRegex(),sP=Et("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,aw).replace(/punctSpace/g,Fg).replace(/punct/g,Yd).getRegex(),iP=Et(/\\(punct)/,"gu").replace(/punct/g,Yd).getRegex(),rP=Et(/^<(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(),aP=Et(Lg).replace("(?:-->|$)","-->").getRegex(),oP=Et("^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",aP).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Nd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,lP=Et(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Nd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),uw=Et(/^!?\[(label)\]\[(ref)\]/).replace("label",Nd).replace("ref",zg).getRegex(),dw=Et(/^!?\[(ref)\](?:\[\])?/).replace("ref",zg).getRegex(),cP=Et("reflink|nolink(?!\\()","g").replace("reflink",uw).replace("nolink",dw).getRegex(),ub=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ug={_backpedal:sc,anyPunctuation:iP,autolink:rP,blockSkip:Q2,br:rw,code:q2,del:sc,emStrongLDelim:J2,emStrongRDelimAst:tP,emStrongRDelimUnd:sP,escape:V2,link:lP,nolink:dw,punctuation:K2,reflink:uw,reflinkSearch:cP,tag:oP,text:G2,url:sc},uP={...Ug,link:Et(/^!?\[(label)\]\((.*?)\)/).replace("label",Nd).getRegex(),reflink:Et(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Nd).getRegex()},_p={...Ug,emStrongRDelimAst:nP,emStrongLDelim:eP,url:Et(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",ub).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:Et(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",ub).getRegex()},dP={..._p,br:Et(rw).replace("{2,}","*").getRegex(),text:Et(_p.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Zu={normal:Dg,gfm:Z2,pedantic:W2},Ol={normal:Ug,gfm:_p,breaks:dP,pedantic:uP},hP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},db=e=>hP[e];function Di(e,t){if(t){if(as.escapeTest.test(e))return e.replace(as.escapeReplace,db)}else if(as.escapeTestNoEncode.test(e))return e.replace(as.escapeReplaceNoEncode,db);return e}function hb(e){try{e=encodeURI(e).replace(as.percentDecode,"%")}catch{return null}return e}function fb(e,t){var o;let n=e.replace(as.findPipe,(c,u,d)=>{let h=!1,f=u;for(;--f>=0&&d[f]==="\\";)h=!h;return h?"|":" |"}),i=n.split(as.splitPipe),r=0;if(i[0].trim()||i.shift(),i.length>0&&!((o=i.at(-1))!=null&&o.trim())&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push("");for(;r<i.length;r++)i[r]=i[r].trim().replace(as.slashPipe,"|");return i}function Pl(e,t,n){let i=e.length;if(i===0)return"";let r=0;for(;r<i&&e.charAt(i-r-1)===t;)r++;return e.slice(0,i-r)}function fP(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let i=0;i<e.length;i++)if(e[i]==="\\")i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}function mb(e,t,n,i,r){let o=t.href,c=t.title||null,u=e[1].replace(r.other.outputLinkReplace,"$1");i.state.inLink=!0;let d={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:c,text:u,tokens:i.inlineTokens(u)};return i.state.inLink=!1,d}function mP(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(i===null)return t;let r=i[1];return t.split(`
132
+ `).map(o=>{let c=o.match(n.other.beginningSpace);if(c===null)return o;let[u]=c;return u.length>=r.length?o.slice(r.length):o}).join(`
133
+ `)}var jd=class{constructor(e){ct(this,"options");ct(this,"rules");ct(this,"lexer");this.options=e||qa}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:Pl(n,`
134
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],i=mP(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:i}}}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 i=Pl(n,"#");(this.options.pedantic||!i||this.rules.other.endingSpaceChar.test(i))&&(n=i.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:Pl(t[0],`
135
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Pl(t[0],`
136
+ `).split(`
137
+ `),i="",r="",o=[];for(;n.length>0;){let c=!1,u=[],d;for(d=0;d<n.length;d++)if(this.rules.other.blockquoteStart.test(n[d]))u.push(n[d]),c=!0;else if(!c)u.push(n[d]);else break;n=n.slice(d);let h=u.join(`
138
+ `),f=h.replace(this.rules.other.blockquoteSetextReplace,`
139
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");i=i?`${i}
140
+ ${h}`:h,r=r?`${r}
141
+ ${f}`:f;let g=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(f,o,!0),this.lexer.state.top=g,n.length===0)break;let p=o.at(-1);if((p==null?void 0:p.type)==="code")break;if((p==null?void 0:p.type)==="blockquote"){let x=p,b=x.raw+`
142
+ `+n.join(`
143
+ `),k=this.blockquote(b);o[o.length-1]=k,i=i.substring(0,i.length-x.raw.length)+k.raw,r=r.substring(0,r.length-x.text.length)+k.text;break}else if((p==null?void 0:p.type)==="list"){let x=p,b=x.raw+`
144
+ `+n.join(`
145
+ `),k=this.list(b);o[o.length-1]=k,i=i.substring(0,i.length-p.raw.length)+k.raw,r=r.substring(0,r.length-x.raw.length)+k.raw,n=b.substring(o.at(-1).raw.length).split(`
146
+ `);continue}}return{type:"blockquote",raw:i,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,r={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let o=this.rules.other.listItemRegex(n),c=!1;for(;e;){let d=!1,h="",f="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;h=t[0],e=e.substring(h.length);let g=t[2].split(`
147
+ `,1)[0].replace(this.rules.other.listReplaceTabs,j=>" ".repeat(3*j.length)),p=e.split(`
148
+ `,1)[0],x=!g.trim(),b=0;if(this.options.pedantic?(b=2,f=g.trimStart()):x?b=t[1].length+1:(b=t[2].search(this.rules.other.nonSpaceChar),b=b>4?1:b,f=g.slice(b),b+=t[1].length),x&&this.rules.other.blankLine.test(p)&&(h+=p+`
149
+ `,e=e.substring(p.length+1),d=!0),!d){let j=this.rules.other.nextBulletRegex(b),E=this.rules.other.hrRegex(b),N=this.rules.other.fencesBeginRegex(b),C=this.rules.other.headingBeginRegex(b),L=this.rules.other.htmlBeginRegex(b);for(;e;){let $=e.split(`
150
+ `,1)[0],O;if(p=$,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),O=p):O=p.replace(this.rules.other.tabCharGlobal," "),N.test(p)||C.test(p)||L.test(p)||j.test(p)||E.test(p))break;if(O.search(this.rules.other.nonSpaceChar)>=b||!p.trim())f+=`
151
+ `+O.slice(b);else{if(x||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||N.test(g)||C.test(g)||E.test(g))break;f+=`
152
+ `+p}!x&&!p.trim()&&(x=!0),h+=$+`
153
+ `,e=e.substring($.length+1),g=O.slice(b)}}r.loose||(c?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(c=!0));let k=null,w;this.options.gfm&&(k=this.rules.other.listIsTask.exec(f),k&&(w=k[0]!=="[ ] ",f=f.replace(this.rules.other.listReplaceTask,""))),r.items.push({type:"list_item",raw:h,task:!!k,checked:w,loose:!1,text:f,tokens:[]}),r.raw+=h}let u=r.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let d=0;d<r.items.length;d++)if(this.lexer.state.top=!1,r.items[d].tokens=this.lexer.blockTokens(r.items[d].text,[]),!r.loose){let h=r.items[d].tokens.filter(g=>g.type==="space"),f=h.length>0&&h.some(g=>this.rules.other.anyLine.test(g.raw));r.loose=f}if(r.loose)for(let d=0;d<r.items.length;d++)r.items[d].loose=!0;return r}}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," "),i=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=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:i,title:r}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=fb(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
154
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let u of i)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 r)o.rows.push(fb(u,o.header.length).map((d,h)=>({text:d,tokens:this.lexer.inline(d),header:!1,align:o.align[h]})));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)===`
155
+ `?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=Pl(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=fP(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 i=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(i);o&&(i=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return i=i.trim(),this.rules.other.startAngleBracket.test(i)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?i=i.slice(1):i=i.slice(1,-1)),mb(t,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.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 i=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[i.toLowerCase()];if(!r){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return mb(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){let r=[...i[0]].length-1,o,c,u=r,d=0,h=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,t=t.slice(-1*e.length+r);(i=h.exec(t))!=null;){if(o=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!o)continue;if(c=[...o].length,i[3]||i[4]){u+=c;continue}else if((i[5]||i[6])&&r%3&&!((r+c)%3)){d+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+d);let f=[...i[0]][0].length,g=e.slice(0,r+i.index+f+c);if(Math.min(r,c)%2){let x=g.slice(1,-1);return{type:"em",raw:g,text:x,tokens:this.lexer.inlineTokens(x)}}let p=g.slice(2,-2);return{type:"strong",raw:g,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),i=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return i&&r&&(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,i;return t[2]==="@"?(n=t[1],i="mailto:"+n):(n=t[1],i=n),{type:"link",raw:t[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let i,r;if(t[2]==="@")i=t[0],r="mailto:"+i;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]);i=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0]}return{type:"link",raw:t[0],text:i,href:r,tokens:[{type:"text",raw:i,text:i}]}}}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}}}},ki=class Ep{constructor(t){ct(this,"tokens");ct(this,"options");ct(this,"state");ct(this,"tokenizer");ct(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||qa,this.options.tokenizer=this.options.tokenizer||new jd,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:as,block:Zu.normal,inline:Ol.normal};this.options.pedantic?(n.block=Zu.pedantic,n.inline=Ol.pedantic):this.options.gfm&&(n.block=Zu.gfm,this.options.breaks?n.inline=Ol.breaks:n.inline=Ol.gfm),this.tokenizer.rules=n}static get rules(){return{block:Zu,inline:Ol}}static lex(t,n){return new Ep(n).lex(t)}static lexInline(t,n){return new Ep(n).inlineTokens(t)}lex(t){t=t.replace(as.carriageReturn,`
156
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let i=this.inlineQueue[n];this.inlineTokens(i.src,i.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],i=!1){var r,o,c;for(this.options.pedantic&&(t=t.replace(as.tabCharGlobal," ").replace(as.spaceLine,""));t;){let u;if((o=(r=this.options.extensions)==null?void 0:r.block)!=null&&o.some(h=>(u=h.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 h=n.at(-1);u.raw.length===1&&h!==void 0?h.raw+=`
157
+ `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
158
+ `)?"":`
159
+ `)+u.raw,h.text+=`
160
+ `+u.text,this.inlineQueue.at(-1).src=h.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 h=n.at(-1);(h==null?void 0:h.type)==="paragraph"||(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
161
+ `)?"":`
162
+ `)+u.raw,h.text+=`
163
+ `+u.raw,this.inlineQueue.at(-1).src=h.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 d=t;if((c=this.options.extensions)!=null&&c.startBlock){let h=1/0,f=t.slice(1),g;this.options.extensions.startBlock.forEach(p=>{g=p.call({lexer:this},f),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(d=t.substring(0,h+1))}if(this.state.top&&(u=this.tokenizer.paragraph(d))){let h=n.at(-1);i&&(h==null?void 0:h.type)==="paragraph"?(h.raw+=(h.raw.endsWith(`
164
+ `)?"":`
165
+ `)+u.raw,h.text+=`
166
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u),i=d.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let h=n.at(-1);(h==null?void 0:h.type)==="text"?(h.raw+=(h.raw.endsWith(`
167
+ `)?"":`
168
+ `)+u.raw,h.text+=`
169
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=h.text):n.push(u);continue}if(t){let h="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var d,h,f,g,p;let i=t,r=null;if(this.tokens.links){let x=Object.keys(this.tokens.links);if(x.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(i))!=null;)x.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(i))!=null;)i=i.slice(0,r.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(i))!=null;)o=r[2]?r[2].length:0,i=i.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=((h=(d=this.options.hooks)==null?void 0:d.emStrongMask)==null?void 0:h.call({lexer:this},i))??i;let c=!1,u="";for(;t;){c||(u=""),c=!1;let x;if((g=(f=this.options.extensions)==null?void 0:f.inline)!=null&&g.some(k=>(x=k.call({lexer:this},t,n))?(t=t.substring(x.raw.length),n.push(x),!0):!1))continue;if(x=this.tokenizer.escape(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.tag(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.link(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(x.raw.length);let k=n.at(-1);x.type==="text"&&(k==null?void 0:k.type)==="text"?(k.raw+=x.raw,k.text+=x.text):n.push(x);continue}if(x=this.tokenizer.emStrong(t,i,u)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.codespan(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.br(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.del(t)){t=t.substring(x.raw.length),n.push(x);continue}if(x=this.tokenizer.autolink(t)){t=t.substring(x.raw.length),n.push(x);continue}if(!this.state.inLink&&(x=this.tokenizer.url(t))){t=t.substring(x.raw.length),n.push(x);continue}let b=t;if((p=this.options.extensions)!=null&&p.startInline){let k=1/0,w=t.slice(1),j;this.options.extensions.startInline.forEach(E=>{j=E.call({lexer:this},w),typeof j=="number"&&j>=0&&(k=Math.min(k,j))}),k<1/0&&k>=0&&(b=t.substring(0,k+1))}if(x=this.tokenizer.inlineText(b)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(u=x.raw.slice(-1)),c=!0;let k=n.at(-1);(k==null?void 0:k.type)==="text"?(k.raw+=x.raw,k.text+=x.text):n.push(x);continue}if(t){let k="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(k);break}else throw new Error(k)}}return n}},wd=class{constructor(e){ct(this,"options");ct(this,"parser");this.options=e||qa}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let i=(o=(t||"").match(as.notSpaceStart))==null?void 0:o[0],r=e.replace(as.endingNewline,"")+`
170
+ `;return i?'<pre><code class="language-'+Di(i)+'">'+(n?r:Di(r,!0))+`</code></pre>
171
+ `:"<pre><code>"+(n?r:Di(r,!0))+`</code></pre>
172
+ `}blockquote({tokens:e}){return`<blockquote>
173
+ ${this.parser.parse(e)}</blockquote>
174
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
175
+ `}hr(e){return`<hr>
176
+ `}list(e){let t=e.ordered,n=e.start,i="";for(let c=0;c<e.items.length;c++){let u=e.items[c];i+=this.listitem(u)}let r=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+r+o+`>
177
+ `+i+"</"+r+`>
178
+ `}listitem(e){var n;let t="";if(e.task){let i=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.type)==="paragraph"?(e.tokens[0].text=i+" "+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=i+" "+Di(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:i+" ",text:i+" ",escaped:!0}):t+=i+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
179
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
180
+ `}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let i="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];n="";for(let c=0;c<o.length;c++)n+=this.tablecell(o[c]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),`<table>
181
+ <thead>
182
+ `+t+`</thead>
183
+ `+i+`</table>
184
+ `}tablerow({text:e}){return`<tr>
185
+ ${e}</tr>
186
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
187
+ `}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>${Di(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 i=this.parser.parseInline(n),r=hb(e);if(r===null)return i;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+Di(t)+'"'),o+=">"+i+"</a>",o}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=hb(e);if(r===null)return Di(n);e=r;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Di(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Di(e.text)}},Bg=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""}},Ni=class Cp{constructor(t){ct(this,"options");ct(this,"renderer");ct(this,"textRenderer");this.options=t||qa,this.options.renderer=this.options.renderer||new wd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Bg}static parse(t,n){return new Cp(n).parse(t)}static parseInline(t,n){return new Cp(n).parseInline(t)}parse(t,n=!0){var r,o;let i="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[u.type]){let h=u,f=this.options.extensions.renderers[h.type].call({parser:this},h);if(f!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(h.type)){i+=f||"";continue}}let d=u;switch(d.type){case"space":{i+=this.renderer.space(d);continue}case"hr":{i+=this.renderer.hr(d);continue}case"heading":{i+=this.renderer.heading(d);continue}case"code":{i+=this.renderer.code(d);continue}case"table":{i+=this.renderer.table(d);continue}case"blockquote":{i+=this.renderer.blockquote(d);continue}case"list":{i+=this.renderer.list(d);continue}case"html":{i+=this.renderer.html(d);continue}case"def":{i+=this.renderer.def(d);continue}case"paragraph":{i+=this.renderer.paragraph(d);continue}case"text":{let h=d,f=this.renderer.text(h);for(;c+1<t.length&&t[c+1].type==="text";)h=t[++c],f+=`
188
+ `+this.renderer.text(h);n?i+=this.renderer.paragraph({type:"paragraph",raw:f,text:f,tokens:[{type:"text",raw:f,text:f,escaped:!0}]}):i+=f;continue}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}parseInline(t,n=this.renderer){var r,o;let i="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&o[u.type]){let h=this.options.extensions.renderers[u.type].call({parser:this},u);if(h!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){i+=h||"";continue}}let d=u;switch(d.type){case"escape":{i+=n.text(d);break}case"html":{i+=n.html(d);break}case"link":{i+=n.link(d);break}case"image":{i+=n.image(d);break}case"strong":{i+=n.strong(d);break}case"em":{i+=n.em(d);break}case"codespan":{i+=n.codespan(d);break}case"br":{i+=n.br(d);break}case"del":{i+=n.del(d);break}case"text":{i+=n.text(d);break}default:{let h='Token with "'+d.type+'" type was not found.';if(this.options.silent)return console.error(h),"";throw new Error(h)}}}return i}},od,Gl=(od=class{constructor(e){ct(this,"options");ct(this,"block");this.options=e||qa}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?ki.lex:ki.lexInline}provideParser(){return this.block?Ni.parse:Ni.parseInline}},ct(od,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ct(od,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),od),pP=class{constructor(...e){ct(this,"defaults",Rg());ct(this,"options",this.setOptions);ct(this,"parse",this.parseMarkdown(!0));ct(this,"parseInline",this.parseMarkdown(!1));ct(this,"Parser",Ni);ct(this,"Renderer",wd);ct(this,"TextRenderer",Bg);ct(this,"Lexer",ki);ct(this,"Tokenizer",jd);ct(this,"Hooks",Gl);this.use(...e)}walkTokens(e,t){var i,r;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 d of u)n=n.concat(this.walkTokens(d.tokens,t));break}case"list":{let c=o;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=o;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let d=c[u].flat(1/0);n=n.concat(this.walkTokens(d,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 i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...c){let u=r.renderer.apply(this,c);return u===!1&&(u=o.apply(this,c)),u}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),i.extensions=t),n.renderer){let r=this.defaults.renderer||new wd(this.defaults);for(let o in n.renderer){if(!(o in r))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let c=o,u=n.renderer[c],d=r[c];r[c]=(...h)=>{let f=u.apply(r,h);return f===!1&&(f=d.apply(r,h)),f||""}}i.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new jd(this.defaults);for(let o in n.tokenizer){if(!(o in r))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let c=o,u=n.tokenizer[c],d=r[c];r[c]=(...h)=>{let f=u.apply(r,h);return f===!1&&(f=d.apply(r,h)),f}}i.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Gl;for(let o in n.hooks){if(!(o in r))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let c=o,u=n.hooks[c],d=r[c];Gl.passThroughHooks.has(o)?r[c]=h=>{if(this.defaults.async&&Gl.passThroughHooksRespectAsync.has(o))return(async()=>{let g=await u.call(r,h);return d.call(r,g)})();let f=u.call(r,h);return d.call(r,f)}:r[c]=(...h)=>{if(this.defaults.async)return(async()=>{let g=await u.apply(r,h);return g===!1&&(g=await d.apply(r,h)),g})();let f=u.apply(r,h);return f===!1&&(f=d.apply(r,h)),f}}i.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,o=n.walkTokens;i.walkTokens=function(c){let u=[];return u.push(o.call(this,c)),r&&(u=u.concat(r.call(this,c))),u}}this.defaults={...this.defaults,...i}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ki.lex(e,t??this.defaults)}parser(e,t){return Ni.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.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(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let c=r.hooks?await r.hooks.preprocess(t):t,u=await(r.hooks?await r.hooks.provideLexer():e?ki.lex:ki.lexInline)(c,r),d=r.hooks?await r.hooks.processAllTokens(u):u;r.walkTokens&&await Promise.all(this.walkTokens(d,r.walkTokens));let h=await(r.hooks?await r.hooks.provideParser():e?Ni.parse:Ni.parseInline)(d,r);return r.hooks?await r.hooks.postprocess(h):h})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let c=(r.hooks?r.hooks.provideLexer():e?ki.lex:ki.lexInline)(t,r);r.hooks&&(c=r.hooks.processAllTokens(c)),r.walkTokens&&this.walkTokens(c,r.walkTokens);let u=(r.hooks?r.hooks.provideParser():e?Ni.parse:Ni.parseInline)(c,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(c){return o(c)}}}onError(e,t){return n=>{if(n.message+=`
189
+ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error occurred:</p><pre>"+Di(n.message+"",!0)+"</pre>";return t?Promise.resolve(i):i}if(t)return Promise.reject(n);throw n}}},za=new pP;function Ct(e,t){return za.parse(e,t)}Ct.options=Ct.setOptions=function(e){return za.setOptions(e),Ct.defaults=za.defaults,tw(Ct.defaults),Ct};Ct.getDefaults=Rg;Ct.defaults=qa;Ct.use=function(...e){return za.use(...e),Ct.defaults=za.defaults,tw(Ct.defaults),Ct};Ct.walkTokens=function(e,t){return za.walkTokens(e,t)};Ct.parseInline=za.parseInline;Ct.Parser=Ni;Ct.parser=Ni.parse;Ct.Renderer=wd;Ct.TextRenderer=Bg;Ct.Lexer=ki;Ct.lexer=ki.lex;Ct.Tokenizer=jd;Ct.Hooks=Gl;Ct.parse=Ct;Ct.options;Ct.setOptions;Ct.use;Ct.walkTokens;Ct.parseInline;Ni.parse;ki.lex;const pb=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],gP=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],gb=[[2,"细"],[4,"中"],[7,"粗"]],xP=.05,xb=16,vb=44;function Xd({src:e,width:t,height:n,name:i,onClose:r}){const[o,c]=y.useState({src:e,width:t,height:n}),{src:u,width:d,height:h}=o,f=y.useRef(null),g=y.useRef(null),[p,x]=y.useState(()=>vP(t,n)),[b,k]=y.useState({scale:1,x:0,y:0}),[w,j]=y.useState(!1),[E,N]=y.useState("rect"),[C,L]=y.useState(pb[0]),[$,O]=y.useState(gb[0][0]),[W,B]=y.useState([]),[U,D]=y.useState(null),[F,A]=y.useState(!0),[T,M]=y.useState(null),P=y.useRef(null),V=y.useRef(null),z=y.useCallback(()=>{var De;const fe=(De=f.current)==null?void 0:De.getBoundingClientRect();if(fe===void 0||fe.width===0)return;const xe=Math.min(xb,(fe.width-24)/d,(fe.height-24)/h);k({scale:xe,x:(fe.width-d*xe)/2,y:(fe.height-h*xe)/2})},[d,h]);y.useLayoutEffect(z,[z]),y.useEffect(()=>{const fe=f.current;if(fe===null||typeof ResizeObserver>"u")return;const xe=new ResizeObserver(()=>z());return xe.observe(fe),()=>xe.disconnect()},[z]);const H=(fe,xe,De)=>{var ot;const Me=(ot=f.current)==null?void 0:ot.getBoundingClientRect();if(Me===void 0)return;const Ce=xe??Me.width/2,Fe=De??Me.height/2;k(ht=>{const Pt=Math.min(xb,Math.max(xP,ht.scale*fe)),Ln=Pt/ht.scale;return{scale:Pt,x:Ce-(Ce-ht.x)*Ln,y:Fe-(Fe-ht.y)*Ln}})},G=()=>{var xe;const fe=(xe=f.current)==null?void 0:xe.getBoundingClientRect();fe!==void 0&&k({scale:1,x:(fe.width-d)/2,y:(fe.height-h)/2})};y.useEffect(()=>{const fe=f.current;if(fe===null)return;const xe=De=>{De.preventDefault();const Me=fe.getBoundingClientRect();H(Math.exp(-De.deltaY*.0015),De.clientX-Me.left,De.clientY-Me.top)};return fe.addEventListener("wheel",xe,{passive:!1}),()=>fe.removeEventListener("wheel",xe)});const Z=fe=>{M(fe),setTimeout(()=>M(xe=>xe===fe?null:xe),1800)},Y=y.useCallback(async(fe,xe=0)=>{const De=new Image;De.src=u,await De.decode();const Me=document.createElement("canvas");Me.width=d,Me.height=h;const Ce=Me.getContext("2d");Ce.drawImage(De,0,0,d,h);for(const ht of fe)kP(Ce,ht);if(xe===0)return Me;const Fe=document.createElement("canvas");Fe.width=h,Fe.height=d;const ot=Fe.getContext("2d");return ot.translate(h/2,d/2),ot.rotate(xe),ot.drawImage(Me,-d/2,-h/2),Fe},[u,d,h]),X=y.useCallback(async fe=>{try{const xe=await Y(fe),De=await new Promise((Me,Ce)=>xe.toBlob(Fe=>Fe===null?Ce(new Error("没能生成图片")):Me(Fe),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":De})])}catch(Me){const Ce=ni();if((Ce==null?void 0:Ce.copyImage)===void 0)throw Me;await Ce.copyImage(xe.toDataURL("image/png"))}Z(fe.length>0?"已复制(带标注)":"已复制")}catch(xe){Z(`复制失败:${xe instanceof Error?xe.message:String(xe)}`)}},[Y]),re=async()=>{const fe=await Y(W),xe=document.createElement("a");xe.href=fe.toDataURL("image/png"),xe.download=`${i.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${W.length>0?"-标注":""}.png`,xe.click()},ee=async()=>{const fe=await Y(W,Math.PI/2);B([]),c({src:fe.toDataURL("image/png"),width:fe.width,height:fe.height})},te=()=>B(fe=>fe.slice(0,-1));y.useEffect(()=>{const fe=xe=>{if(!(g.current===null||!g.current.contains(document.activeElement))){if(xe.key==="Escape"){U!==null?(D(null),P.current=null):w?j(!1):r();return}if((xe.ctrlKey||xe.metaKey)&&xe.key.toLowerCase()==="z"){xe.preventDefault(),te();return}if((xe.ctrlKey||xe.metaKey)&&xe.key.toLowerCase()==="c"){xe.preventDefault(),X(W);return}xe.key==="0"&&z(),(xe.key==="+"||xe.key==="=")&&H(1.25),xe.key==="-"&&H(.8)}};return window.addEventListener("keydown",fe),()=>window.removeEventListener("keydown",fe)});const ne=fe=>{const xe=f.current.getBoundingClientRect(),De=(fe.clientX-xe.left-b.x)/b.scale,Me=(fe.clientY-xe.top-b.y)/b.scale;return[Math.max(0,Math.min(d,De)),Math.max(0,Math.min(h,Me))]},se=fe=>{if(fe.button!==0&&fe.button!==1)return;if(fe.currentTarget.setPointerCapture(fe.pointerId),!w||fe.button===1){P.current={kind:"pan",sx:fe.clientX,sy:fe.clientY,ox:b.x,oy:b.y};return}const[xe,De]=ne(fe),Me=$/b.scale;P.current={kind:"mark"},D(E==="pen"?{kind:"pen",points:[[xe,De]],color:C,width:Me}:{kind:E,x1:xe,y1:De,x2:xe,y2:De,color:C,width:Me})},oe=fe=>{const xe=P.current;if(xe===null)return;if(xe.kind==="pan"){k(Ce=>({...Ce,x:xe.ox+fe.clientX-xe.sx,y:xe.oy+fe.clientY-xe.sy}));return}const[De,Me]=ne(fe);D(Ce=>Ce===null?Ce:Ce.kind==="pen"?{...Ce,points:[...Ce.points,[De,Me]]}:{...Ce,x2:De,y2:Me})},de=()=>{const fe=P.current;if(P.current=null,(fe==null?void 0:fe.kind)!=="mark"||U===null||(D(null),(U.kind==="pen"?U.points.length>2?99:0:Math.hypot(U.x2-U.x1,U.y2-U.y1)*b.scale)<4))return;const De=[...W,U];B(De),F&&X(De)},we=fe=>{if(fe.target.closest("button")!==null)return;fe.currentTarget.setPointerCapture(fe.pointerId),V.current={sx:fe.clientX,sy:fe.clientY,ox:p.x,oy:p.y};const xe=g.current;xe!==null&&x(De=>({...De,w:xe.offsetWidth,h:xe.offsetHeight}))},Se=fe=>{const xe=V.current;xe!==null&&x(De=>({...De,x:Math.max(-De.w+120,Math.min(window.innerWidth-120,xe.ox+fe.clientX-xe.sx)),y:Math.max(0,Math.min(window.innerHeight-40,xe.oy+fe.clientY-xe.sy))}))};return y.useEffect(()=>{var fe;(fe=g.current)==null||fe.focus()},[]),Va.createPortal(s.jsxs("div",{ref:g,className:"image-viewer",role:"dialog","aria-label":i,tabIndex:-1,style:{left:p.x,top:p.y,width:p.w,height:p.h},children:[s.jsxs("div",{className:"viewer-title",onPointerDown:we,onPointerMove:Se,onPointerUp:()=>{V.current=null},onDoubleClick:z,children:[s.jsx("span",{className:"viewer-name",children:i}),s.jsxs("span",{className:"viewer-dim",children:[d,"×",h]}),s.jsx("button",{className:"viewer-icon",onClick:r,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),s.jsxs("div",{ref:f,className:`viewer-stage ${w?"marking":""}`,onPointerDown:se,onPointerMove:oe,onPointerUp:de,onPointerCancel:de,children:[s.jsxs("div",{className:"viewer-canvas",style:{width:d,height:h,transform:`translate(${b.x}px, ${b.y}px) scale(${b.scale})`},children:[s.jsx("img",{src:u,alt:i,width:d,height:h,draggable:!1}),s.jsx("svg",{viewBox:`0 0 ${d} ${h}`,width:d,height:h,"aria-hidden":"true",children:[...W,...U===null?[]:[U]].map((fe,xe)=>s.jsx(bP,{mark:fe},xe))})]}),T!==null&&s.jsx("div",{className:"viewer-toast",role:"status",children:T})]}),w&&s.jsxs("div",{className:"viewer-marks",children:[s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:gP.map(([fe,xe])=>s.jsx("button",{role:"radio","aria-checked":E===fe,className:`viewer-icon ${E===fe?"active":""}`,title:xe,onClick:()=>N(fe),children:s.jsx(yP,{tool:fe})},fe))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:gb.map(([fe,xe])=>s.jsx("button",{role:"radio","aria-checked":$===fe,className:`viewer-icon ${$===fe?"active":""}`,title:xe,onClick:()=>O(fe),children:s.jsx("span",{className:"width-dot",style:{width:fe+3,height:fe+3}})},fe))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:pb.map(fe=>s.jsx("button",{role:"radio","aria-checked":C===fe,"aria-label":fe,className:`swatch ${C===fe?"active":""}`,style:{background:fe},onClick:()=>L(fe)},fe))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",disabled:W.length===0,onClick:te,title:"撤销(Ctrl+Z)",children:"↶"}),s.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[s.jsx("input",{type:"checkbox",checked:F,onChange:fe=>A(fe.target.checked)}),"自动复制"]})]}),s.jsxs("div",{className:"viewer-bar",children:[s.jsx("button",{className:"viewer-icon",onClick:()=>H(.8),title:"缩小",children:"-"}),s.jsxs("button",{className:"viewer-zoom",onClick:z,title:"适应窗口(0)",children:[Math.round(b.scale*100),"%"]}),s.jsx("button",{className:"viewer-icon",onClick:()=>H(1.25),title:"放大",children:"+"}),s.jsx("button",{className:"viewer-icon",onClick:G,title:"原始大小",children:"1:1"}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void ee(),title:"旋转",children:"⟳"}),s.jsx("button",{className:`viewer-icon ${w?"active":""}`,onClick:()=>j(fe=>!fe),title:"标注:画框、箭头、直线",children:"✎"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void X(W),title:"复制(Ctrl+C)",children:"⧉"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void re(),title:"保存",children:"⤓"})]})]}),document.body)}function vP(e,t){const n=Math.round(window.innerWidth*.7),i=Math.round(window.innerHeight*.78)-vb*2,r=Math.min(1,n/e,i/t),o=Math.max(420,Math.round(e*r)+24),c=Math.max(300,Math.round(t*r)+24+vb*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-c)/2)),w:o,h:c}}function yP({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 hw(e){const t=Math.atan2(e.y2-e.y1,e.x2-e.x1),n=e.width*4.5;return[-.5,.5].map(i=>[e.x2-n*Math.cos(t+i),e.y2-n*Math.sin(t+i)])}function bP({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(i=>i.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"?hw(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 kP(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,i],r)=>r===0?e.moveTo(n,i):e.lineTo(n,i));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,i]=hw(t);e.moveTo(n[0],n[1]),e.lineTo(t.x2,t.y2),e.lineTo(i[0],i[1])}e.stroke()}const Qd=y.createContext(null),hm=new Map;function NP(e,t){let n=hm.get(t.attachmentId);if(n===void 0){const{attachmentId:i,mediaType:r,bytes:o,width:c,height:u}=t;n=e.connection.call("attachments/image",{attachmentId:i,mediaType:r,bytes:o,width:c,height:u}).then(d=>`data:${d.mediaType};base64,${d.data}`),n.catch(()=>hm.delete(t.attachmentId)),hm.set(t.attachmentId,n)}return n}function fw({image:e}){const t=y.useContext(Qd),[n,i]=y.useState(null),[r,o]=y.useState(null),[c,u]=y.useState(!1),d=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;y.useEffect(()=>{if(t===null||!d)return;let f=!0;return NP(t,e).then(g=>{f&&i(g)},g=>{f&&o(g instanceof Error?g.message:String(g))}),()=>{f=!1}},[t,d,e]);const h=e.name??`${e.width}×${e.height} 图片`;return d?r!==null?s.jsxs("span",{className:"stored-image missing",children:[h,"没能加载:",r]}):n===null?s.jsx("span",{className:"stored-image loading",style:{width:e.width+2,aspectRatio:`${e.width+2} / ${e.height+2}`}}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:s.jsx("img",{src:n,alt:h,width:e.width,height:e.height})}),c&&s.jsx(Xd,{src:n,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):s.jsxs("span",{className:"stored-image missing",children:[h,"(当前后端不支持显示图片)"]})}var fm,yb;function jP(){if(yb)return fm;yb=1;function e(ie){return ie instanceof Map?ie.clear=ie.delete=ie.set=function(){throw new Error("map is read-only")}:ie instanceof Set&&(ie.add=ie.clear=ie.delete=function(){throw new Error("set is read-only")}),Object.freeze(ie),Object.getOwnPropertyNames(ie).forEach(ye=>{const Le=ie[ye],tt=typeof Le;(tt==="object"||tt==="function")&&!Object.isFrozen(Le)&&e(Le)}),ie}class t{constructor(ye){ye.data===void 0&&(ye.data={}),this.data=ye.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(ie){return ie.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function i(ie,...ye){const Le=Object.create(null);for(const tt in ie)Le[tt]=ie[tt];return ye.forEach(function(tt){for(const At in tt)Le[At]=tt[At]}),Le}const r="</span>",o=ie=>!!ie.scope,c=(ie,{prefix:ye})=>{if(ie.startsWith("language:"))return ie.replace("language:","language-");if(ie.includes(".")){const Le=ie.split(".");return[`${ye}${Le.shift()}`,...Le.map((tt,At)=>`${tt}${"_".repeat(At+1)}`)].join(" ")}return`${ye}${ie}`};class u{constructor(ye,Le){this.buffer="",this.classPrefix=Le.classPrefix,ye.walk(this)}addText(ye){this.buffer+=n(ye)}openNode(ye){if(!o(ye))return;const Le=c(ye.scope,{prefix:this.classPrefix});this.span(Le)}closeNode(ye){o(ye)&&(this.buffer+=r)}value(){return this.buffer}span(ye){this.buffer+=`<span class="${ye}">`}}const d=(ie={})=>{const ye={children:[]};return Object.assign(ye,ie),ye};class h{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ye){this.top.children.push(ye)}openNode(ye){const Le=d({scope:ye});this.add(Le),this.stack.push(Le)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ye){return this.constructor._walk(ye,this.rootNode)}static _walk(ye,Le){return typeof Le=="string"?ye.addText(Le):Le.children&&(ye.openNode(Le),Le.children.forEach(tt=>this._walk(ye,tt)),ye.closeNode(Le)),ye}static _collapse(ye){typeof ye!="string"&&ye.children&&(ye.children.every(Le=>typeof Le=="string")?ye.children=[ye.children.join("")]:ye.children.forEach(Le=>{h._collapse(Le)}))}}class f extends h{constructor(ye){super(),this.options=ye}addText(ye){ye!==""&&this.add(ye)}startScope(ye){this.openNode(ye)}endScope(){this.closeNode()}__addSublanguage(ye,Le){const tt=ye.root;Le&&(tt.scope=`language:${Le}`),this.add(tt)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(ie){return ie?typeof ie=="string"?ie:ie.source:null}function p(ie){return k("(?=",ie,")")}function x(ie){return k("(?:",ie,")*")}function b(ie){return k("(?:",ie,")?")}function k(...ie){return ie.map(Le=>g(Le)).join("")}function w(ie){const ye=ie[ie.length-1];return typeof ye=="object"&&ye.constructor===Object?(ie.splice(ie.length-1,1),ye):{}}function j(...ie){return"("+(w(ie).capture?"":"?:")+ie.map(tt=>g(tt)).join("|")+")"}function E(ie){return new RegExp(ie.toString()+"|").exec("").length-1}function N(ie,ye){const Le=ie&&ie.exec(ye);return Le&&Le.index===0}const C=new RegExp(j(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function L(ie,{joinWith:ye}){let Le=0;return ie.map(tt=>{Le+=1;const At=Le;let Tt=g(tt),Be="";for(;Tt.length>0;){const Ue=C.exec(Tt);if(!Ue){Be+=Tt;break}Be+=Tt.substring(0,Ue.index),Tt=Tt.substring(Ue.index+Ue[0].length),Ue[0][0]==="\\"&&Ue[1]?Be+="\\"+String(Number(Ue[1])+At):(Be+=Ue[0],(Ue[0]==="("||/^\(\?[<']/.test(Ue[0]))&&Le++)}return Be}).map(tt=>`(${tt})`).join(ye)}const $=/\b\B/,O="[a-zA-Z]\\w*",W="[a-zA-Z_]\\w*",B="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D="\\b(0b[01]+)",F="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",A=(ie={})=>{const ye=/^#![ ]*\//;return ie.binary&&(ie.begin=k(ye,/.*\b/,ie.binary,/\b.*/)),i({scope:"meta",begin:ye,end:/$/,relevance:0,"on:begin":(Le,tt)=>{Le.index!==0&&tt.ignoreMatch()}},ie)},T={begin:"\\\\[\\s\\S]",relevance:0},M={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[T]},P={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[T]},V={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/},z=function(ie,ye,Le={}){const tt=i({scope:"comment",begin:ie,end:ye,contains:[]},Le);tt.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 At=j("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 tt.contains.push({begin:k(/[ ]+/,"(",At,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),tt},H=z("//","$"),G=z("/\\*","\\*/"),Z=z("#","$"),Y={scope:"number",begin:B,relevance:0},X={scope:"number",begin:U,relevance:0},re={scope:"number",begin:D,relevance:0},ee={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[T,{begin:/\[/,end:/\]/,relevance:0,contains:[T]}]},te={scope:"title",begin:O,relevance:0},ne={scope:"title",begin:W,relevance:0},se={begin:"\\.\\s*"+W,relevance:0};var de=Object.freeze({__proto__:null,APOS_STRING_MODE:M,BACKSLASH_ESCAPE:T,BINARY_NUMBER_MODE:re,BINARY_NUMBER_RE:D,COMMENT:z,C_BLOCK_COMMENT_MODE:G,C_LINE_COMMENT_MODE:H,C_NUMBER_MODE:X,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(ie){return Object.assign(ie,{"on:begin":(ye,Le)=>{Le.data._beginMatch=ye[1]},"on:end":(ye,Le)=>{Le.data._beginMatch!==ye[1]&&Le.ignoreMatch()}})},HASH_COMMENT_MODE:Z,IDENT_RE:O,MATCH_NOTHING_RE:$,METHOD_GUARD:se,NUMBER_MODE:Y,NUMBER_RE:B,PHRASAL_WORDS_MODE:V,QUOTE_STRING_MODE:P,REGEXP_MODE:ee,RE_STARTERS_RE:F,SHEBANG:A,TITLE_MODE:te,UNDERSCORE_IDENT_RE:W,UNDERSCORE_TITLE_MODE:ne});function we(ie,ye){ie.input[ie.index-1]==="."&&ye.ignoreMatch()}function Se(ie,ye){ie.className!==void 0&&(ie.scope=ie.className,delete ie.className)}function fe(ie,ye){ye&&ie.beginKeywords&&(ie.begin="\\b("+ie.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",ie.__beforeBegin=we,ie.keywords=ie.keywords||ie.beginKeywords,delete ie.beginKeywords,ie.relevance===void 0&&(ie.relevance=0))}function xe(ie,ye){Array.isArray(ie.illegal)&&(ie.illegal=j(...ie.illegal))}function De(ie,ye){if(ie.match){if(ie.begin||ie.end)throw new Error("begin & end are not supported with match");ie.begin=ie.match,delete ie.match}}function Me(ie,ye){ie.relevance===void 0&&(ie.relevance=1)}const Ce=(ie,ye)=>{if(!ie.beforeMatch)return;if(ie.starts)throw new Error("beforeMatch cannot be used with starts");const Le=Object.assign({},ie);Object.keys(ie).forEach(tt=>{delete ie[tt]}),ie.keywords=Le.keywords,ie.begin=k(Le.beforeMatch,p(Le.begin)),ie.starts={relevance:0,contains:[Object.assign(Le,{endsParent:!0})]},ie.relevance=0,delete Le.beforeMatch},Fe=["of","and","for","in","not","or","if","then","parent","list","value"],ot="keyword";function ht(ie,ye,Le=ot){const tt=Object.create(null);return typeof ie=="string"?At(Le,ie.split(" ")):Array.isArray(ie)?At(Le,ie):Object.keys(ie).forEach(function(Tt){Object.assign(tt,ht(ie[Tt],ye,Tt))}),tt;function At(Tt,Be){ye&&(Be=Be.map(Ue=>Ue.toLowerCase())),Be.forEach(function(Ue){const Xe=Ue.split("|");tt[Xe[0]]=[Tt,Pt(Xe[0],Xe[1])]})}}function Pt(ie,ye){return ye?Number(ye):Ln(ie)?0:1}function Ln(ie){return Fe.includes(ie.toLowerCase())}const an={},dn=ie=>{console.error(ie)},hn=(ie,...ye)=>{console.log(`WARN: ${ie}`,...ye)},on=(ie,ye)=>{an[`${ie}/${ye}`]||(console.log(`Deprecated as of ${ie}. ${ye}`),an[`${ie}/${ye}`]=!0)},ln=new Error;function Ut(ie,ye,{key:Le}){let tt=0;const At=ie[Le],Tt={},Be={};for(let Ue=1;Ue<=ye.length;Ue++)Be[Ue+tt]=At[Ue],Tt[Ue+tt]=!0,tt+=E(ye[Ue-1]);ie[Le]=Be,ie[Le]._emit=Tt,ie[Le]._multi=!0}function Hn(ie){if(Array.isArray(ie.begin)){if(ie.skip||ie.excludeBegin||ie.returnBegin)throw dn("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ln;if(typeof ie.beginScope!="object"||ie.beginScope===null)throw dn("beginScope must be object"),ln;Ut(ie,ie.begin,{key:"beginScope"}),ie.begin=L(ie.begin,{joinWith:""})}}function wn(ie){if(Array.isArray(ie.end)){if(ie.skip||ie.excludeEnd||ie.returnEnd)throw dn("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ln;if(typeof ie.endScope!="object"||ie.endScope===null)throw dn("endScope must be object"),ln;Ut(ie,ie.end,{key:"endScope"}),ie.end=L(ie.end,{joinWith:""})}}function Ss(ie){ie.scope&&typeof ie.scope=="object"&&ie.scope!==null&&(ie.beginScope=ie.scope,delete ie.scope)}function Ii(ie){Ss(ie),typeof ie.beginScope=="string"&&(ie.beginScope={_wrap:ie.beginScope}),typeof ie.endScope=="string"&&(ie.endScope={_wrap:ie.endScope}),Hn(ie),wn(ie)}function ii(ie){function ye(Be,Ue){return new RegExp(g(Be),"m"+(ie.case_insensitive?"i":"")+(ie.unicodeRegex?"u":"")+(Ue?"g":""))}class Le{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ue,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,Ue]),this.matchAt+=E(Ue)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ue=this.regexes.map(Xe=>Xe[1]);this.matcherRe=ye(L(Ue,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ue){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(Ue);if(!Xe)return null;const kt=Xe.findIndex((Zn,ls)=>ls>0&&Zn!==void 0),bt=this.matchIndexes[kt];return Xe.splice(0,kt),Object.assign(Xe,bt)}}class tt{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ue){if(this.multiRegexes[Ue])return this.multiRegexes[Ue];const Xe=new Le;return this.rules.slice(Ue).forEach(([kt,bt])=>Xe.addRule(kt,bt)),Xe.compile(),this.multiRegexes[Ue]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ue,Xe){this.rules.push([Ue,Xe]),Xe.type==="begin"&&this.count++}exec(Ue){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let kt=Xe.exec(Ue);if(this.resumingScanAtSamePosition()&&!(kt&&kt.index===this.lastIndex)){const bt=this.getMatcher(0);bt.lastIndex=this.lastIndex+1,kt=bt.exec(Ue)}return kt&&(this.regexIndex+=kt.position+1,this.regexIndex===this.count&&this.considerAll()),kt}}function At(Be){const Ue=new tt;return Be.contains.forEach(Xe=>Ue.addRule(Xe.begin,{rule:Xe,type:"begin"})),Be.terminatorEnd&&Ue.addRule(Be.terminatorEnd,{type:"end"}),Be.illegal&&Ue.addRule(Be.illegal,{type:"illegal"}),Ue}function Tt(Be,Ue){const Xe=Be;if(Be.isCompiled)return Xe;[Se,De,Ii,Ce].forEach(bt=>bt(Be,Ue)),ie.compilerExtensions.forEach(bt=>bt(Be,Ue)),Be.__beforeBegin=null,[fe,xe,Me].forEach(bt=>bt(Be,Ue)),Be.isCompiled=!0;let kt=null;return typeof Be.keywords=="object"&&Be.keywords.$pattern&&(Be.keywords=Object.assign({},Be.keywords),kt=Be.keywords.$pattern,delete Be.keywords.$pattern),kt=kt||/\w+/,Be.keywords&&(Be.keywords=ht(Be.keywords,ie.case_insensitive)),Xe.keywordPatternRe=ye(kt,!0),Ue&&(Be.begin||(Be.begin=/\B|\b/),Xe.beginRe=ye(Xe.begin),!Be.end&&!Be.endsWithParent&&(Be.end=/\B|\b/),Be.end&&(Xe.endRe=ye(Xe.end)),Xe.terminatorEnd=g(Xe.end)||"",Be.endsWithParent&&Ue.terminatorEnd&&(Xe.terminatorEnd+=(Be.end?"|":"")+Ue.terminatorEnd)),Be.illegal&&(Xe.illegalRe=ye(Be.illegal)),Be.contains||(Be.contains=[]),Be.contains=[].concat(...Be.contains.map(function(bt){return Ds(bt==="self"?Be:bt)})),Be.contains.forEach(function(bt){Tt(bt,Xe)}),Be.starts&&Tt(Be.starts,Ue),Xe.matcher=At(Xe),Xe}if(ie.compilerExtensions||(ie.compilerExtensions=[]),ie.contains&&ie.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return ie.classNameAliases=i(ie.classNameAliases||{}),Tt(ie)}function ri(ie){return ie?ie.endsWithParent||ri(ie.starts):!1}function Ds(ie){return ie.variants&&!ie.cachedVariants&&(ie.cachedVariants=ie.variants.map(function(ye){return i(ie,{variants:null},ye)})),ie.cachedVariants?ie.cachedVariants:ri(ie)?i(ie,{starts:ie.starts?i(ie.starts):null}):Object.isFrozen(ie)?i(ie):ie}var Fs="11.12.0";class Us extends Error{constructor(ye,Le){super(ye),this.name="HTMLInjectionError",this.html=Le}}const Bs=n,ai=i,oi=Symbol("nomatch"),os=7,Qn=function(ie){const ye=Object.create(null),Le=Object.create(null),tt=[];let At=!0;const Tt="Could not find the language '{}', did you forget to load/include a language module?",Be={disableAutodetect:!0,name:"Plain text",contains:[]};let Ue={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function Xe($e){return Ue.noHighlightRe.test($e)}function kt($e){let We=$e.className+" ";We+=$e.parentNode?$e.parentNode.className:"";const lt=Ue.languageDetectRe.exec(We);if(lt){const dt=Jn(lt[1]);return dt||(hn(Tt.replace("{}",lt[1])),hn("Falling back to no-highlight mode for this block.",$e)),dt?lt[1]:"no-highlight"}return We.split(/\s+/).find(dt=>Xe(dt)||Jn(dt))}function bt($e,We,lt){let dt="",It="";typeof We=="object"?(dt=$e,lt=We.ignoreIllegals,It=We.language):(on("10.7.0","highlight(lang, code, ...args) has been deprecated."),on("10.7.0",`Please use highlight(code, options) instead.
190
+ https://github.com/highlightjs/highlight.js/issues/2277`),It=$e,dt=We),lt===void 0&&(lt=!0);const Ot={code:dt,language:It};di("before:highlight",Ot);const Vn=Ot.result?Ot.result:Zn(Ot.language,Ot.code,lt);return Vn.code=Ot.code,di("after:highlight",Vn),Vn}function Zn($e,We,lt,dt){const It=Object.create(null);function Ot(Re,He){return Re.keywords[He]}function Vn(){if(!it.keywords){zt.addText(ft);return}let Re=0;it.keywordPatternRe.lastIndex=0;let He=it.keywordPatternRe.exec(ft),rt="";for(;He;){rt+=ft.substring(Re,He.index);const xt=En.case_insensitive?He[0].toLowerCase():He[0],Bt=Ot(it,xt);if(Bt){const[xn,nl]=Bt;if(zt.addText(rt),rt="",It[xt]=(It[xt]||0)+1,It[xt]<=os&&(Ki+=nl),xn.startsWith("_"))rt+=He[0];else{const ra=En.classNameAliases[xn]||xn;_n(He[0],ra)}}else rt+=He[0];Re=it.keywordPatternRe.lastIndex,He=it.keywordPatternRe.exec(ft)}rt+=ft.substring(Re),zt.addText(rt)}function Hs(){if(ft==="")return;let Re=null;if(typeof it.subLanguage=="string"){if(!ye[it.subLanguage]){zt.addText(ft);return}Re=Zn(it.subLanguage,ft,!0,hs[it.subLanguage]),hs[it.subLanguage]=Re._top}else Re=li(ft,it.subLanguage.length?it.subLanguage:null);it.relevance>0&&(Ki+=Re.relevance),zt.__addSublanguage(Re._emitter,Re.language)}function fn(){it.subLanguage!=null?Hs():Vn(),ft=""}function _n(Re,He){Re!==""&&(zt.startScope(He),zt.addText(Re),zt.endScope())}function Zs(Re,He){let rt=1;const xt=He.length-1;for(;rt<=xt;){if(!Re._emit[rt]){rt++;continue}const Bt=En.classNameAliases[Re[rt]]||Re[rt],xn=He[rt];Bt?_n(xn,Bt):(ft=xn,Vn(),ft=""),rt++}}function Ws(Re,He){return Re.scope&&typeof Re.scope=="string"&&zt.openNode(En.classNameAliases[Re.scope]||Re.scope),Re.beginScope&&(Re.beginScope._wrap?(_n(ft,En.classNameAliases[Re.beginScope._wrap]||Re.beginScope._wrap),ft=""):Re.beginScope._multi&&(Zs(Re.beginScope,He),ft="")),it=Object.create(Re,{parent:{value:it}}),it}function us(Re,He,rt){let xt=N(Re.endRe,rt);if(xt){if(Re["on:end"]){const Bt=new t(Re);Re["on:end"](He,Bt),Bt.isMatchIgnored&&(xt=!1)}if(xt){for(;Re.endsParent&&Re.parent;)Re=Re.parent;return Re}}if(Re.endsWithParent)return us(Re.parent,He,rt)}function ia(Re){return it.matcher.regexIndex===0?(ft+=Re[0],1):(hi=!0,0)}function Nr(Re){const He=Re[0],rt=Re.rule,xt=new t(rt),Bt=[rt.__beforeBegin,rt["on:begin"]];for(const xn of Bt)if(xn&&(xn(Re,xt),xt.isMatchIgnored))return ia(He);return rt.skip?ft+=He:(rt.excludeBegin&&(ft+=He),fn(),!rt.returnBegin&&!rt.excludeBegin&&(ft=He)),Ws(rt,Re),rt.returnBegin?0:He.length}function Mi(Re){const He=Re[0],rt=We.substring(Re.index),xt=us(it,Re,rt);if(!xt)return oi;const Bt=it;it.endScope&&it.endScope._wrap?(fn(),_n(He,it.endScope._wrap)):it.endScope&&it.endScope._multi?(fn(),Zs(it.endScope,Re)):Bt.skip?ft+=He:(Bt.returnEnd||Bt.excludeEnd||(ft+=He),fn(),Bt.excludeEnd&&(ft=He));do it.scope&&zt.closeNode(),!it.skip&&!it.subLanguage&&(Ki+=it.relevance),it=it.parent;while(it!==xt.parent);return xt.starts&&Ws(xt.starts,Re),Bt.returnEnd?0:He.length}function jr(){const Re=[];for(let He=it;He!==En;He=He.parent)He.scope&&Re.unshift(He.scope);Re.forEach(He=>zt.openNode(He))}let es={};function ds(Re,He){const rt=He&&He[0];if(ft+=Re,rt==null)return fn(),0;if(es.type==="begin"&&He.type==="end"&&es.index===He.index&&rt===""){if(ft+=We.slice(He.index,He.index+1),!At){const xt=new Error(`0 width match regex (${$e})`);throw xt.languageName=$e,xt.badRule=es.rule,xt}return 1}if(es=He,He.type==="begin")return Nr(He);if(He.type==="illegal"&&!lt){const xt=new Error('Illegal lexeme "'+rt+'" for mode "'+(it.scope||"<unnamed>")+'"');throw xt.mode=it,xt}else if(He.type==="end"){const xt=Mi(He);if(xt!==oi)return xt}if(He.type==="illegal"&&rt==="")return He.index===We.length||(ft+=`
191
+ `),1;if(Yi>1e5&&Yi>He.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ft+=rt,rt.length}const En=Jn($e);if(!En)throw dn(Tt.replace("{}",$e)),new Error('Unknown language: "'+$e+'"');const Vs=ii(En);let vt="",it=dt||Vs;const hs={},zt=new Ue.__emitter(Ue);jr();let ft="",Ki=0,ts=0,Yi=0,hi=!1;try{if(En.__emitTokens)En.__emitTokens(We,zt);else{for(it.matcher.considerAll();;){Yi++,hi?hi=!1:it.matcher.considerAll(),it.matcher.lastIndex=ts;const Re=it.matcher.exec(We);if(!Re)break;const He=We.substring(ts,Re.index),rt=ds(He,Re);ts=Re.index+rt}ds(We.substring(ts))}return zt.finalize(),vt=zt.toHTML(),{language:$e,value:vt,relevance:Ki,illegal:!1,_emitter:zt,_top:it}}catch(Re){if(Re.message&&Re.message.includes("Illegal"))return{language:$e,value:Bs(We),illegal:!0,relevance:0,_illegalBy:{message:Re.message,index:ts,context:We.slice(ts-100,ts+100),mode:Re.mode,resultSoFar:vt},_emitter:zt};if(At)return{language:$e,value:Bs(We),illegal:!1,relevance:0,errorRaised:Re,_emitter:zt,_top:it};throw Re}}function ls($e){const We={value:Bs($e),illegal:!1,relevance:0,_top:Be,_emitter:new Ue.__emitter(Ue)};return We._emitter.addText($e),We}function li($e,We){We=We||Ue.languages||Object.keys(ye);const lt=ls($e),dt=We.filter(Jn).filter(ui).map(fn=>Zn(fn,$e,!1));dt.unshift(lt);const It=dt.sort((fn,_n)=>{if(fn.relevance!==_n.relevance)return _n.relevance-fn.relevance;if(fn.language&&_n.language){if(Jn(fn.language).supersetOf===_n.language)return 1;if(Jn(_n.language).supersetOf===fn.language)return-1}return 0}),[Ot,Vn]=It,Hs=Ot;return Hs.secondBest=Vn,Hs}function vr($e,We,lt){const dt=We&&Le[We]||lt;$e.classList.add("hljs"),$e.classList.add(`language-${dt}`)}function ci($e){let We=null;const lt=kt($e);if(Xe(lt))return;if(di("before:highlightElement",{el:$e,language:lt}),$e.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",$e);return}if($e.children.length>0&&(Ue.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($e)),Ue.throwUnescapedHTML))throw new Us("One of your code blocks includes unescaped HTML.",$e.innerHTML);We=$e;const dt=We.textContent,It=lt?bt(dt,{language:lt,ignoreIllegals:!0}):li(dt);$e.innerHTML=It.value,$e.dataset.highlighted="yes",vr($e,lt,It.language),$e.result={language:It.language,re:It.relevance,relevance:It.relevance},It.secondBest&&($e.secondBest={language:It.secondBest.language,relevance:It.secondBest.relevance}),di("after:highlightElement",{el:$e,result:It,text:dt})}function yr($e){Ue=ai(Ue,$e)}const Wn=()=>{Ti(),on("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Vi(){Ti(),on("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let cs=!1;function Ti(){function $e(){Ti()}if(document.readyState==="loading"){cs||window.addEventListener("DOMContentLoaded",$e,!1),cs=!0;return}document.querySelectorAll(Ue.cssSelector).forEach(ci)}function br($e,We){let lt=null;try{lt=We(ie)}catch(dt){if(dn("Language definition for '{}' could not be registered.".replace("{}",$e)),At)dn(dt);else throw dt;lt=Be}lt.name||(lt.name=$e),ye[$e]=lt,lt.rawDefinition=We.bind(null,ie),lt.aliases&&qi(lt.aliases,{languageName:$e})}function Mt($e){delete ye[$e];for(const We of Object.keys(Le))Le[We]===$e&&delete Le[We]}function _s(){return Object.keys(ye)}function Jn($e){return $e=($e||"").toLowerCase(),ye[$e]||ye[Le[$e]]}function qi($e,{languageName:We}){typeof $e=="string"&&($e=[$e]),$e.forEach(lt=>{Le[lt.toLowerCase()]=We})}function ui($e){const We=Jn($e);return We&&!We.disableAutodetect}function Rt($e){$e["before:highlightBlock"]&&!$e["before:highlightElement"]&&($e["before:highlightElement"]=We=>{$e["before:highlightBlock"](Object.assign({block:We.el},We))}),$e["after:highlightBlock"]&&!$e["after:highlightElement"]&&($e["after:highlightElement"]=We=>{$e["after:highlightBlock"](Object.assign({block:We.el},We))})}function kr($e){Rt($e),tt.push($e)}function Gi($e){const We=tt.indexOf($e);We!==-1&&tt.splice(We,1)}function di($e,We){const lt=$e;tt.forEach(function(dt){dt[lt]&&dt[lt](We)})}function $i($e){return on("10.7.0","highlightBlock will be removed entirely in v12.0"),on("10.7.0","Please use highlightElement now."),ci($e)}Object.assign(ie,{highlight:bt,highlightAuto:li,highlightAll:Ti,highlightElement:ci,highlightBlock:$i,configure:yr,initHighlighting:Wn,initHighlightingOnLoad:Vi,registerLanguage:br,unregisterLanguage:Mt,listLanguages:_s,getLanguage:Jn,registerAliases:qi,autoDetection:ui,inherit:ai,addPlugin:kr,removePlugin:Gi}),ie.debugMode=function(){At=!1},ie.safeMode=function(){At=!0},ie.versionString=Fs,ie.regex={concat:k,lookahead:p,either:j,optional:b,anyNumberOfTimes:x};for(const $e in de)typeof de[$e]=="object"&&e(de[$e]);return Object.assign(ie,de),ie},Sn=Qn({});return Sn.newInstance=()=>Qn({}),fm=Sn,Sn.HighlightJS=Sn,Sn.default=Sn,fm}var wP=jP();const _i=pg(wP);function SP(e){const t=e.regex,n={},i={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},i]});const r={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,r]};r.contains.push(u);const d={match:/\\"/},h={className:"string",begin:/'/,end:/'/},f={match:/\\'/},g={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},p=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${p.join("|")})`,relevance:10}),b={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],w=["true","false"],j={match:/(\/[a-z._-]+)+/},E=["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"],C=["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"],L=["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:k,literal:w,built_in:[...E,...N,"set","shopt",...C,...L]},contains:[x,e.SHEBANG(),b,g,o,c,j,u,d,h,f,n]}}const _P=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_-]*/}}),EP=["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"],CP=["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"],AP=[...EP,...CP],IP=["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(),TP=["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(),$P=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),MP=["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 RP(e){const t=e.regex,n=_P(e),i={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},r="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,i,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:":("+TP.join("|")+")"},{begin:":(:)?("+$P.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+MP.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:r,attribute:IP.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+AP.join("|")+")\\b"}]}}function OP(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 PP(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 wo="[0-9](_*[0-9])*",Wu=`\\.(${wo})`,Vu="[0-9a-fA-F](_*[0-9a-fA-F])*",bb={className:"number",variants:[{begin:`(\\b(${wo})((${Wu})|\\.)?|(${Wu}))[eE][+-]?(${wo})[fFdD]?\\b`},{begin:`\\b(${wo})((${Wu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Wu})[fFdD]?\\b`},{begin:`\\b(${wo})[fFdD]\\b`},{begin:`\\b0[xX]((${Vu})\\.?|(${Vu})?\\.(${Vu}))[pP][+-]?(${wo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Vu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function mw(e,t,n){return n===-1?"":e.replace(t,i=>mw(e,t,n-1))}function zP(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",i="(?:(?:\\s*\\[\\s*])+)?",r=n+"<@@@>"+i,c="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+r+")?")+"|"+r+")",u=mw("(?:\\s*<\\s*"+c+"(?:\\s*,\\s*"+c+")*\\s*>)?",/<@@@>/g,2),p={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"]},x={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},b={className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:p,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,i,/\s+/),n,i,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[b,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[n,t.concat(u,i,/\s+/),n,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:p,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[x,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,bb,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},bb,x]}}const kb="[A-Za-z$_][0-9A-Za-z$_]*",LP=["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"],DP=["true","false","null","undefined","NaN","Infinity"],pw=["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"],gw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],xw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],FP=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],UP=[].concat(xw,pw,gw);function BP(e){const t=e.regex,n=(z,{after:H})=>{const G="</"+z[0].slice(1);return z.input.indexOf(G,H)!==-1},i=kb,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(z,H)=>{const G=z[0].length+z.index,Z=z.input[G];if(Z==="<"||Z===","){H.ignoreMatch();return}Z===">"&&(n(z,{after:G})||H.ignoreMatch());let Y;const X=z.input.substring(G);if(Y=X.match(/^\s*=/)){H.ignoreMatch();return}if((Y=X.match(/^\s+extends\s+/))&&Y.index===0){H.ignoreMatch();return}}},u={$pattern:kb,keyword:LP,literal:DP,built_in:UP,"variable.language":FP},d="[0-9](_?[0-9])*",h=`\\.(${d})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\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},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},E={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:i+"(?=\\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,x,b,k,w,{match:/\$\d+/},g];p.contains=N.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(N)});const C=[].concat(E,p.contains),L=C.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(C)}]),$={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:L},O={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],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:{_:[...pw,...gw]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[$],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(z){return t.concat("(?!",z.join("|"),")")}const A={match:t.concat(/\b/,F([...xw,"super","import","await"].map(z=>`${z}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},T={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},$]},P="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(P)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[$]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:L,CLASS_REFERENCE:W},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,b,k,w,E,{match:/\$\d+/},g,W,{scope:"attr",match:i+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:P,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:L}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.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"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[$,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},T,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[$]},A,D,O,M,{match:/\$[(.]/}]}}const HP="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",ZP={scope:"number",match:HP,relevance:0};function WP(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},i=["true","false","null"],r={scope:"literal",beginKeywords:i.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:i},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,r,ZP,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function VP(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},i={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},r={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+.-]*/,d={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}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(h,{contains:[]}),p=e.inherit(f,{contains:[]});h.contains.push(p),f.contains.push(g);let x=[n,d];return[h,f,g,p].forEach(j=>{j.contains=j.contains.concat(x)}),x=x.concat(h,f),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},n,o,i,h,f,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},r,d,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function qP(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["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:i,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"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},f={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,d,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,d,f,h]},{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,f,h]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},p="[0-9](_?[0-9])*",x=`(\\b(${p}))?\\.(${p})|\\b(${p})\\.`,b=`\\b|${i.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${p})|(${x}))[eE][+-]?(${p})[jJ]?(?=${b})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${p})[jJ](?=${b})`}]},w={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},j={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",d,k,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,k,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[d,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,w,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[j]},{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:[k,j,g]}]}}function GP(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),r=t.concat(n,e.IDENT_RE),o={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,r,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"],d=["true","false","Some","None","Ok","Err"],h=["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!"],f=["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:f,keyword:u,literal:d,built_in:h},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+/,i],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,i],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,i,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,i],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,i],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:f}},{scope:"punctuation",begin:"->"},o]}}function KP(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},r={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"],d=["add","asc","collation","desc","final","first","last","view"],h=["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"],f=["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"],g=["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"],p=["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"],x=f,b=[...h,...d].filter(L=>!f.includes(L)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},j={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function E(L){return t.concat(/\b/,t.either(...L.map($=>$.replace(/\s+/,"\\s+"))),/\b/)}const N={scope:"keyword",match:E(p),relevance:0};function C(L,{exceptions:$,when:O}={}){const W=O;return $=$||[],L.map(B=>B.match(/\|\d+$/)||$.includes(B)?B:W(B)?`${B}|0`:B)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:C(b,{when:L=>L.length<3}),literal:o,type:u,built_in:g},contains:[{scope:"type",match:E(c)},N,j,k,i,r,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,w]}}const Sd="[A-Za-z$_][0-9A-Za-z$_]*",vw=["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"],bw=["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"],kw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Nw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],jw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],ww=[].concat(Nw,bw,kw);function YP(e){const t=e.regex,n=(z,{after:H})=>{const G="</"+z[0].slice(1);return z.input.indexOf(G,H)!==-1},i=Sd,r={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(z,H)=>{const G=z[0].length+z.index,Z=z.input[G];if(Z==="<"||Z===","){H.ignoreMatch();return}Z===">"&&(n(z,{after:G})||H.ignoreMatch());let Y;const X=z.input.substring(G);if(Y=X.match(/^\s*=/)){H.ignoreMatch();return}if((Y=X.match(/^\s+extends\s+/))&&Y.index===0){H.ignoreMatch();return}}},u={$pattern:Sd,keyword:vw,literal:yw,built_in:ww,"variable.language":jw},d="[0-9](_?[0-9])*",h=`\\.(${d})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${f})((${h})|\\.)?|(${h}))[eE][+-]?(${d})\\b`},{begin:`\\b(${f})\\b((${h})\\b|\\.)?|(${h})\\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},p={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,p],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,p]},E={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:i+"(?=\\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,x,b,k,w,{match:/\$\d+/},g];p.contains=N.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(N)});const C=[].concat(E,p.contains),L=C.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(C)}]),$={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:L},O={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],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:{_:[...bw,...kw]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[$],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(z){return t.concat("(?!",z.join("|"),")")}const A={match:t.concat(/\b/,F([...Nw,"super","import","await"].map(z=>`${z}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},T={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},M={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},$]},P="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",V={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(P)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[$]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:L,CLASS_REFERENCE:W},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,b,k,w,E,{match:/\$\d+/},g,W,{scope:"attr",match:i+t.lookahead(":"),relevance:0},V,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,e.REGEXP_MODE,{className:"function",begin:P,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:L}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:r.begin,end:r.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"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[$,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},T,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[$]},A,D,O,M,{match:/\$[(.]/}]}}function XP(e){const t=e.regex,n=YP(e),i=Sd,r=["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:r},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:Sd,keyword:vw.concat(d),literal:yw,built_in:ww.concat(r),"variable.language":jw},f={className:"meta",begin:"@"+i},g=(k,w,j)=>{const E=k.contains.findIndex(N=>N.label===w);if(E===-1)throw new Error("can not find mode to replace");k.contains.splice(E,1,j)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(f);const p=n.contains.find(k=>k.scope==="attr"),x=Object.assign({},p,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,p,x]),n.contains=n.contains.concat([f,o,c,x]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",u);const b=n.contains.find(k=>k.label==="func.def");return b.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function QP(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={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"}),d=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:i,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{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,d,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,c,d,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],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:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function JP(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},r={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,r]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),p={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"},x={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},b={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},k={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},w=[i,{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}},p,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},b,k,o,c],j=[...w];return j.pop(),j.push(u),x.contains=j,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}for(const[e,t]of Object.entries({bash:SP,css:RP,diff:OP,go:PP,java:zP,javascript:BP,json:WP,markdown:VP,python:qP,rust:GP,sql:KP,typescript:XP,xml:QP,yaml:JP}))_i.registerLanguage(e,t);_i.registerAliases(["sh","shell","zsh","console"],{languageName:"bash"});_i.registerAliases(["ts","tsx","mts","cts"],{languageName:"typescript"});_i.registerAliases(["js","jsx","mjs","cjs"],{languageName:"javascript"});_i.registerAliases(["html","svg","vue"],{languageName:"xml"});_i.registerAliases(["py"],{languageName:"python"});_i.registerAliases(["yml"],{languageName:"yaml"});_i.registerAliases(["rs"],{languageName:"rust"});_i.registerAliases(["md"],{languageName:"markdown"});const Nb=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]??"",r=n!==""&&_i.getLanguage(n)!==void 0?_i.highlight(e,{language:n,ignoreIllegals:!0}).value:Nb(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${Nb(n===""?"text":n)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${r}</code></pre></div>`}}});function Sw(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(/[#?].*$/,"")}const jb=/\.(png|jpe?g|gif|webp|bmp)$/i,ez=/^(#|\?|\/\/|[a-z][a-z0-9+.-]*:)/i;function wb(e){const t=e.trim(),n=Sw(t);if(n!==void 0)return n;if(!(t===""||ez.test(t)))return t}Mg.addHook("beforeSanitizeAttributes",e=>{if(e.tagName==="IMG"){const r=e.getAttribute("src")??"";if(/^data:image\//i.test(r))return;e.removeAttribute("src"),e.classList.add("md-image");const o=wb(r);o!==void 0?e.setAttribute("data-local-image",o):/^https?:/i.test(r)&&e.setAttribute("data-remote-image",r);return}if(e.tagName!=="A")return;const t=e.getAttribute("href")??"",n=Sw(t);if(n!==void 0){e.removeAttribute("href"),e.setAttribute("data-local-path",n),e.setAttribute("title",n),e.classList.add("local-path"),jb.test(n)&&e.setAttribute("data-image-preview",n);return}const i=wb(t);i!==void 0&&jb.test(i)&&(e.removeAttribute("href"),e.setAttribute("data-image-preview",i),e.setAttribute("title",i),e.classList.add("local-path"))});Mg.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 tz(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)},i=ni();if((i==null?void 0:i.openPath)!==void 0){i.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(Ew(t)?"浏览器里打不开本地文件,路径已复制":t))}function nz(e){var o;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),tz(t);return}const n=e.target.closest("button[data-copy]"),i=(o=n==null?void 0:n.closest(".code-block"))==null?void 0:o.querySelector("pre");if(n==null||i==null)return;const r=c=>{n.textContent=c?"已复制":"复制失败",n.classList.toggle("copied",c),setTimeout(()=>{n.textContent="复制",n.classList.remove("copied")},1600)};_w(i.innerText).then(r)}function _w(e){var n;return(((n=navigator.clipboard)==null?void 0:n.writeText(e))??Promise.reject(new Error("no clipboard"))).then(()=>!0,()=>Ew(e))}function Ew(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 mm=new Map;function sz(e,t){let n=mm.get(t);return n===void 0&&(n=e.connection.call("attachments/file",{path:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),n.catch(()=>mm.delete(t)),mm.set(t,n)),n}function iz(e,t){var o;let n=!0;const i=(t==null?void 0:t.capabilities.get().has("attachments"))===!0,r=(c,u)=>{if(!i||t===null){c.replaceWith(Sb(u,"当前后端不支持显示图片"));return}c.classList.add("loading"),sz(t,u).then(d=>{n&&(c.src=d,c.classList.remove("loading"))},d=>{n&&c.replaceWith(Sb(u,d instanceof Error?d.message:String(d)))})};for(const c of e.querySelectorAll("img[data-local-image]"))c.src===""&&r(c,c.dataset.localImage);for(const c of e.querySelectorAll("a[data-image-preview]")){if(((o=c.nextElementSibling)==null?void 0:o.classList.contains("md-link-preview"))===!0)continue;const u=document.createElement("img");u.className="md-image md-link-preview",u.alt=c.textContent??"",u.dataset.localImage=c.dataset.imagePreview,c.after(u),r(u,u.dataset.localImage)}for(const c of e.querySelectorAll("img[data-remote-image]")){const u=document.createElement("a");u.href=c.dataset.remoteImage,u.target="_blank",u.rel="noopener noreferrer",u.textContent=`🖼 ${c.alt!==""?c.alt:"网络图片"}`,u.title=u.href,c.replaceWith(u)}return()=>{n=!1}}function Sb(e,t){const n=document.createElement("span");return n.className="md-image-missing",n.textContent=`图片没能显示:${t}`,n.title=e,n}const ti=y.memo(function({text:t,className:n}){const i=y.useMemo(()=>Mg.sanitize(Ct.parse(t,{async:!1})),[t]),r=y.useContext(Qd),o=y.useRef(null),[c,u]=y.useState(null);y.useEffect(()=>o.current===null?void 0:iz(o.current,r),[i,r]);const d=h=>{const f=h.target,g=f.closest("a[data-image-preview]:not([data-local-path])"),p=f instanceof HTMLImageElement&&f.classList.contains("md-image")&&f.src!==""?f:(g==null?void 0:g.nextElementSibling)instanceof HTMLImageElement&&g.nextElementSibling.src!==""?g.nextElementSibling:null;if(p!==null){h.preventDefault();const x=p.dataset.localImage??"";u({src:p.src,width:p.naturalWidth,height:p.naturalHeight,name:x.split(/[\\/]/).pop()||"image.png"});return}nz(h)};return s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:o,className:`markdown ${n??""}`,onClick:d,dangerouslySetInnerHTML:{__html:i}}),c!==null&&s.jsx(Xd,{src:c.src,width:c.width,height:c.height,name:c.name,onClose:()=>u(null)})]})}),_b="adg.update.later",rz=360*6e4,Cw="https://github.com/haaahhhis/MultiGameAssistant/releases",pm="dsh-multigameassistant";function Hg(){var i;const e=(i=ni())==null?void 0:i.updates,[t,n]=y.useState(e===void 0?null:void 0);return y.useEffect(()=>{if(e===void 0)return;let r=!0;e.state().then(c=>{r&&n(c)},()=>{r&&n(null)});const o=e.onChange(c=>{r&&n(c)});return()=>{r=!1,o()}},[e]),{bridge:e,state:t}}const Eb=new WeakMap;function az(e){let t=Eb.get(e);if(t!==void 0)return t;let n={checking:!1};const i=new Set,r=d=>{n=d;for(const h of i)h()};let o=0,c;const u=()=>{n.checking||(r({...n,checking:!0}),e.connection.call("about/checkUpdate",{}).then(d=>r({checking:!1,result:d}),d=>r({checking:!1,...n.result===void 0?{}:{result:n.result},error:d instanceof Error?d.message:String(d)})))};return t={get:()=>n,subscribe(d){return i.add(d),()=>{i.delete(d)}},check:u,watch(){return o++===0&&(n.result===void 0&&!n.checking&&u(),c=setInterval(u,rz)),()=>{--o===0&&c!==void 0&&(clearInterval(c),c=void 0)}}},Eb.set(e,t),t}function Aw(e){const t=je(e.capabilities),n=je(e.connection.status),i=t.has("about"),[r,o]=y.useState(void 0);if(y.useEffect(()=>{if(n.state!=="open")return;if(!i){o(null);return}let c=!0;return e.connection.call("about/info",{}).then(u=>{c&&o(u)},()=>{c&&o(null)}),()=>{c=!1}},[e,i,n.state]),r!==void 0)return(r==null?void 0:r.edition)==="plugin"&&r.version!==void 0?{version:r.version}:!1}function Iw(e,t){const n=az(e),i=y.useSyncExternalStore(n.subscribe,n.get);return y.useEffect(()=>t?n.watch():void 0,[n,t]),{...i,check:n.check}}function Tw(e){var c;const{bridge:t,state:n}=Hg(),i=Aw(e),r=Iw(e,t===void 0&&i!==!1&&i!==void 0);if(t!==void 0){const u=n==null?void 0:n.latest;return n==null||u===void 0||u.version===n.skipped?null:{kind:"desktop",current:n.current,version:u.version,prerelease:u.prerelease,notesUrl:u.notesUrl,notes:u.notes??[],bridge:t,state:n}}const o=(c=r.result)==null?void 0:c.latest;return i===!1||i===void 0||o===void 0||r.result===void 0?null:{kind:"plugin",current:r.result.current,version:o.version,prerelease:o.prerelease,notesUrl:o.notesUrl||Cw,notes:o.notes??[],...o.onNpm===void 0?{}:{onNpm:o.onNpm}}}function oz(e,t=3){var r,o,c;const n=((r=e[0])==null?void 0:r.body)??"",i=[];for(const u of n.split(`
192
+ `)){const d=(o=/^\s*[-*]\s+(.+)$/.exec(u))==null?void 0:o[1];if(d===void 0)continue;const f=(((c=/^\*\*(.+?)\*\*/.exec(d))==null?void 0:c[1])??d).replace(/\*\*|`|\[([^\]]*)\]\([^)]*\)/g,(g,p)=>p??"").replace(/[::。]\s*$/,"").trim();if(f!==""&&!i.includes(f)&&i.push(f.length>40?`${f.slice(0,40)}…`:f),i.length>=t)break}return i}function lz(e){if(e===void 0)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"})}function Zg({notes:e,notesUrl:t}){return e.length===0?s.jsxs("p",{className:"muted small",children:["发布页没有写这次的更新说明。",s.jsx("a",{href:t,target:"_blank",rel:"noreferrer",children:"在 GitHub 上看"})]}):s.jsx("div",{className:"release-notes",children:e.map(n=>s.jsxs("section",{className:"release-note",children:[s.jsxs("div",{className:"release-note-head",children:[s.jsx("strong",{children:n.title!==void 0&&n.title!==`v${n.version}`?n.title:`版本 ${n.version}`}),s.jsx("span",{className:"muted small",children:lz(n.publishedAt)}),n.url!==""&&s.jsx("a",{className:"small",href:n.url,target:"_blank",rel:"noreferrer",children:"发布页"})]}),n.body===""?s.jsx("p",{className:"muted small",children:"这个版本没有写更新说明。"}):s.jsx(ti,{className:"release-note-body",text:n.body})]},n.version))})}let $w=!1;const Ap=new Set,Ip=e=>{$w=e;for(const t of Ap)t()},cz=e=>(Ap.add(e),()=>{Ap.delete(e)});function Mw(){Ip(!0)}function uz({client:e}){const t=y.useSyncExternalStore(cz,()=>$w),n=Tw(e);if(y.useEffect(()=>{if(!t)return;const r=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),Ip(!1))};return document.addEventListener("keydown",r,!0),()=>document.removeEventListener("keydown",r,!0)},[t]),!t||n===null)return null;const i=()=>Ip(!1);return s.jsx("div",{className:"dialog-backdrop",onPointerDown:r=>{r.target===r.currentTarget&&i()},children:s.jsxs("div",{className:"dialog update-notes-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"update-notes-title",children:[s.jsxs("div",{className:"update-notes-head",children:[s.jsxs("h3",{id:"update-notes-title",children:[s.jsx(Q,{name:"download"}),"MultiGameAssistant ",n.version," 可以更新了"]}),s.jsx("button",{className:"ghost icon-button","aria-label":"关闭",title:"关闭",onClick:i,children:s.jsx(Q,{name:"close"})})]}),s.jsxs("p",{className:"muted small",children:["当前版本 ",n.current,n.prerelease?" · 新版本是预发布版":"",n.notes.length>1?` · 更新后会带上下面 ${n.notes.length} 个版本的改动`:""]}),s.jsx("div",{className:"update-notes-body",children:s.jsx(Zg,{notes:n.notes,notesUrl:n.notesUrl})}),n.kind==="desktop"?s.jsx(Wg,{bridge:n.bridge,state:n.state,extra:s.jsx("button",{className:"ghost small-button",onClick:()=>{n.bridge.skip(n.version),i()},children:"跳过这个版本"})}):s.jsx(Rw,{version:n.version,onNpm:n.onNpm})]})})}function gm(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function Wg({bridge:e,state:t,extra:n}){var f;const[i,r]=y.useState(null),[o,c]=y.useState(!1),u=t.latest;if(u===void 0)return null;const d=((f=t.download)==null?void 0:f.version)===u.version?t.download:void 0,h=g=>{r(null),g().catch(p=>r(p instanceof Error?p.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(p)))};return s.jsxs("div",{className:"update-actions",children:[(d==null?void 0:d.state)==="downloading"&&s.jsxs("div",{className:"update-progress",children:[s.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":d.total,"aria-valuenow":d.received,children:s.jsx("span",{style:{width:`${d.total>0?Math.min(100,d.received/d.total*100):0}%`}})}),s.jsxs("small",{className:"muted",children:["正在下载 ",gm(d.received)," / ",gm(d.total)]})]}),(d==null?void 0:d.state)==="ready"&&s.jsx("p",{className:"muted small",children:"安装时程序会退出,正在跑的脚本会被中断;装好后自动重新打开,数据和定时任务都在。"}),(d==null?void 0:d.state)==="failed"&&s.jsx("p",{className:"error small",children:d.error}),i!==null&&s.jsx("p",{className:"error small",children:i}),s.jsxs("div",{className:"update-buttons",children:[n,(d==null?void 0:d.state)==="ready"?s.jsx("button",{className:"primary small-button",disabled:o,onClick:()=>{c(!0),h(()=>e.install().finally(()=>c(!1)))},children:o?"正在启动安装…":"退出并安装"}):s.jsx("button",{className:"primary small-button",disabled:(d==null?void 0:d.state)==="downloading",onClick:()=>h(()=>e.download()),children:(d==null?void 0:d.state)==="failed"?"重新下载":(d==null?void 0:d.state)==="downloading"?"正在下载…":`下载更新(${gm(u.size)})`})]})]})}function Rw({version:e,onNpm:t}){const n=`${Cw}/download/v${e}/${pm}.tgz`;return s.jsxs("div",{className:"plugin-update",children:[t!==!1&&s.jsxs("p",{children:["在 dsh 的「Plugins」→「Add plugin」里再填一次 ",s.jsx(xm,{text:pm})," 安装(命令行的 dsh:",s.jsx(xm,{text:`dsh plugin add ${pm}`}),")。",t===void 0&&"没连上 npm,不知道那边有没有这个版本;装完版本没变的话,用下面的链接。"]}),t!==!0&&s.jsxs("p",{children:[t===!1&&"npm 上还没有这个版本(要等发布者批准)。","在「Add plugin」里填这个链接安装:",s.jsx(xm,{text:n})]}),s.jsx("p",{className:"muted small",children:"装好后刷新这个页面。你的数据、脚本和定时任务都在 dsh 的数据目录里,重新安装不会丢。"})]})}function xm({text:e}){const[t,n]=y.useState(!1),i=()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),1500)},()=>{})};return s.jsxs("span",{className:"copy-code",children:[s.jsx("code",{children:e}),s.jsx("button",{type:"button",className:"link-button",onClick:i,title:"复制",children:t?s.jsx(Q,{name:"check"}):s.jsx(Q,{name:"copy"})})]})}function dz(){var d;const{bridge:e,state:t}=Hg(),[n,i]=y.useState(()=>{try{return sessionStorage.getItem(_b)}catch{return null}}),r=t==null?void 0:t.latest;if(e===void 0||t==null||r===void 0)return null;const o=((d=t.download)==null?void 0:d.version)===r.version&&t.download.state!=="failed";if(!o&&(r.version===t.skipped||r.version===n))return null;const c=()=>{try{sessionStorage.setItem(_b,r.version)}catch{}i(r.version)},u=oz(r.notes??[]);return s.jsxs("div",{className:"approval-card update-card",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(Q,{name:"download"}),s.jsxs("div",{className:"approval-text",children:[s.jsxs("span",{className:"approval-title",children:["MultiGameAssistant ",r.version," 可以更新了"]}),s.jsxs("span",{className:"approval-tool",children:["当前 ",t.current,r.prerelease?" · 预发布版":""]})]}),!o&&s.jsx("button",{className:"ghost icon-button update-close","aria-label":"稍后提醒",title:"稍后(下次启动再提醒)",onClick:c,children:s.jsx(Q,{name:"close"})})]}),u.length>0&&s.jsx("ul",{className:"update-highlights",children:u.map(h=>s.jsx("li",{children:h},h))}),s.jsx(Wg,{bridge:e,state:t,extra:s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:Mw,children:"更新介绍"}),!o&&s.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(r.version),children:"跳过这个版本"})]})})]})}function hz({client:e,sessionId:t,onSelect:n}){var f;const i=je(e.approvals),r=je(e.questions),o=(f=KO(e))==null?void 0:f.pending,c=i.filter(g=>g.sessionId===t),u=r.filter(g=>g.sessionId===t),d=[...i,...r].filter(g=>g.sessionId!==t),h=d.some(g=>"approvalId"in g)?d.some(g=>"questionId"in g)?"审批或回答":"审批":"回答";return s.jsxs("div",{className:"approval-dock",children:[o!==void 0&&s.jsx(YO,{client:e,pending:o}),u.map(g=>s.jsx(mz,{client:e,request:g},g.questionId)),c.map(g=>s.jsx(fz,{client:e,request:g},g.approvalId)),d.length>0&&s.jsxs("button",{className:"approval-elsewhere",onClick:()=>n(d[0].sessionId),children:[s.jsx("span",{className:"approval-dot"}),"另有 ",new Set(d.map(g=>g.sessionId)).size," 个会话在等你",h,s.jsx(Q,{name:"chevron"})]}),s.jsx(XO,{client:e}),s.jsx(qO,{client:e}),s.jsx(dz,{})]})}function fz({client:e,request:t}){var d,h,f;const[n,i]=y.useState(!1),[r,o]=y.useState(null),c=((d=t.displayReason)==null?void 0:d.zh)??((h=t.displayReason)==null?void 0:h["zh-CN"])??((f=t.displayReason)==null?void 0:f.en)??t.reason,u=async g=>{i(!0);try{await e.respondApproval(t.approvalId,g)}catch(p){o(p instanceof Error?p.message:String(p)),i(!1)}};return s.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(Q,{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}),r!==null&&s.jsx("div",{className:"error small",children:r}),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 mz({client:e,request:t}){var k;const[n,i]=y.useState({}),[r,o]=y.useState(!1),[c,u]=y.useState(null),d=t.questions.length===1&&t.questions[0].multiSelect!==!0&&(((k=t.questions[0].options)==null?void 0:k.length)??0)>0,h=w=>n[w]??{selected:[],custom:""},f=async w=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,w)}catch(j){u(j instanceof Error?j.message:String(j)),o(!1)}},g=(w,j)=>{if(d)return void f([{id:w.id,selected:[j]}]);i(E=>{const N=E[w.id]??{selected:[],custom:""},C=w.multiSelect===!0?N.selected.includes(j)?N.selected.filter(L=>L!==j):[...N.selected,j]:N.selected.includes(j)?[]:[j];return{...E,[w.id]:{...N,selected:C}}})},p=(w,j)=>i(E=>({...E,[w.id]:{...E[w.id]??{selected:[]},custom:j}})),x=()=>t.questions.map(w=>{const{selected:j,custom:E}=h(w.id),N=E.trim();return{id:w.id,selected:N!==""&&w.multiSelect!==!0?[]:j,...N===""?{}:{custom:N}}}),b=t.questions.every(w=>h(w.id).selected.length>0||h(w.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(Q,{name:"chat"}),s.jsx("div",{className:"approval-text",children:s.jsx("div",{className:"approval-title",children:"agent 在问你"})})]}),t.questions.map(w=>{var j,E;return s.jsxs("div",{className:"question-item",children:[w.header!==void 0&&s.jsx("span",{className:"question-header",children:w.header}),s.jsx("div",{className:"question-text",children:w.question}),w.detail!==void 0&&s.jsx("div",{className:"question-detail",children:w.detail}),(((j=w.options)==null?void 0:j.length)??0)>0&&s.jsx("div",{className:"question-options",role:w.multiSelect===!0?"group":"radiogroup",children:w.options.map(N=>{const C=h(w.id).selected.includes(N.label);return s.jsxs("button",{className:`question-option${C?" on":""}`,disabled:r,role:w.multiSelect===!0?"checkbox":"radio","aria-checked":C,onClick:()=>g(w,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:h(w.id).custom,disabled:r,placeholder:(((E=w.options)==null?void 0:E.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:N=>p(w,N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.nativeEvent.isComposing&&b&&f(x())}})]},w.id)}),c!==null&&s.jsx("div",{className:"error small",children:c}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:r,onClick:()=>void f(t.questions.map(w=>({id:w.id,selected:[]}))),children:"跳过"}),s.jsx("button",{className:"inverse",disabled:r||!b,onClick:()=>void f(x()),children:"回答"})]})]})}const On="main",pz={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},nn={id:On,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function Ga(e){return{id:e.id,name:e.name,description:e.description,icon:pz[e.id]??"sparkles"}}function Ls(e){const t=je(e.connection.status),[n,i]=y.useState([]);return y.useEffect(()=>{if(t.state!=="open")return;let r=!0;return e.connection.call("roles/list",{}).then(o=>{r&&i(o.items)}).catch(()=>{}),()=>{r=!1}},[e,t.state]),y.useEffect(()=>e.connection.on("roles/changed",r=>i(r.items)),[e]),n}function La(e,t){return e.role!==void 0&&t.some(n=>n.id===e.role)?e.role:On}function gz(e){return e==="你"?"你布置的":`来自${e}`}function Vg(e,t){const n=je(e.connection.status),[i,r]=y.useState(new Map),o=y.useRef(new Map),c=d=>`${d.updatedAt}${d.running?"+":""}`,u=t.map(d=>`${d.id}@${c(d)}`).join(",");return y.useEffect(()=>{if(n.state!=="open")return;const d=t.filter(h=>o.current.get(h.id)!==c(h)).slice(0,60);if(d.length!==0){for(const h of d)o.current.set(h.id,c(h));e.connection.call("sessions/lastReplies",{sessionIds:d.map(h=>h.id)}).then(h=>{r(f=>{const g=new Map(f);for(const p of h.items)g.set(p.sessionId,p.text);return g})}).catch(()=>{for(const h of d)o.current.delete(h.id)})}},[e,n.state,u]),i}const Ow="adg.agentSeen";function xz(){try{const e=JSON.parse(localStorage.getItem(Ow)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function vz(){const[e,t]=y.useState(xz);return{seen:e,markSeen:(i,r)=>{t(o=>{if((o[i]??0)>=r)return o;const c={...o,[i]:r};try{localStorage.setItem(Ow,JSON.stringify(c))}catch{}return c})}}}function Pw(e,t){const n=je(e.connection.status),[i,r]=y.useState({agentId:t,sessionId:null,error:null});return y.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("agents/home",{agentId:t}).then(c=>{o&&r({agentId:t,sessionId:c.sessionId,error:null})},c=>{o&&r({agentId:t,sessionId:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),i.agentId===t?i:{sessionId:null,error:null}}function yz(e,t){const n=je(e.connection.status),i=je(e.capabilities),[r,o]=y.useState([]);return y.useEffect(()=>{if(n.state!=="open"||!i.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,i]),y.useEffect(()=>e.connection.on("handoffs/changed",({item:c})=>{c.fromSession!==t&&c.toSession!==t||o(u=>[...u.filter(d=>d.id!==c.id),c])}),[e,t]),r}const bz={feishu:"飞书"},vm=30;function zw(e){const t=je(e.connection.status),n=je(e.capabilities),[i,r]=y.useState(new Set),o=n.has("archive");return y.useEffect(()=>{if(t.state!=="open"||!o)return;let c=!0;return e.connection.call("sessions/archived",{}).then(u=>{c&&r(new Set(u.sessionIds))}).catch(()=>{}),()=>{c=!1}},[e,t.state,o]),y.useEffect(()=>e.connection.on("sessions/archived",c=>r(new Set(c.sessionIds))),[e]),i}function kz(e,t){const n=je(e.sessions),i=je(e.approvals),r=je(e.questions),o=Ls(e),c=zw(e),{seen:u,markSeen:d}=vz(),h=y.useMemo(()=>[nn,...o.map(Ga)],[o]),f=y.useMemo(()=>{var x;const p=new Map(h.map(b=>[b.id,[]]));for(const b of n.items)b.origin==="subagent"||b.blank||c.has(b.id)||(x=p.get(La(b,o)))==null||x.push(b);for(const b of p.values())b.sort((k,w)=>w.updatedAt-k.updatedAt);return p},[n.items,c,h,o]);y.useEffect(()=>{var p,x;if(n.loaded)for(const b of h){const k=(x=(p=f.get(b.id))==null?void 0:p[0])==null?void 0:x.updatedAt;k!==void 0&&(b.id===t||u[b.id]===void 0)&&d(b.id,k)}},[n.loaded,f,t]);const g=p=>{const x=n.items.find(b=>b.id===p);return x===void 0?void 0:La(x,o)};return h.map(p=>{const x=f.get(p.id)??[],b=x[0];return{agent:p,running:x.filter(k=>k.running).length,unread:p.id!==t&&b!==void 0&&b.updatedAt>(u[p.id]??1/0),waiting:[...i,...r].filter(k=>g(k.sessionId)===p.id).length,last:x.find(k=>k.home===p.id)??b}})}function Nz(e,t){const n=je(e.sessions),i=Ls(e);return n.items.some(r=>r.origin!=="subagent"&&!r.blank&&r.home!==t&&La(r,i)===t)}function jz({client:e,agentId:t,onSelect:n}){const i=je(e.sessions),r=je(e.connection.status),o=je(e.capabilities),c=Ls(e),u=zw(e),d=un(3e4),[h,f]=y.useState(null),[g,p]=y.useState(""),[x,b]=y.useState(!1),[k,w]=y.useState(!1),[j,E]=y.useState(new Map),[N,C]=y.useState(0),L=o.has("archive");y.useEffect(()=>e.connection.on("notify/changed",()=>C(M=>M+1)),[e]),y.useEffect(()=>{if(r.state!=="open"||!o.has("notify"))return;let M=!0;return e.connection.call("notify/conversations",{}).then(P=>{M&&E(new Map(P.items.map(V=>[V.sessionId,{channel:V.channel,user:V.user}])))}).catch(()=>{}),()=>{M=!1}},[e,r.state,o,N]);const $=M=>{const P=j.get(M.id);return P!==void 0?bz[P.channel]??P.channel:/^(飞书|feishu):/.test(M.title??"")?"飞书":void 0},O=g.trim().toLowerCase(),{earlier:W,archivedItems:B}=y.useMemo(()=>{const M=i.items.filter(P=>P.origin!=="subagent"&&!P.blank&&P.home!==t&&La(P,c)===t&&(O===""||yo(P).toLowerCase().includes(O))).sort((P,V)=>V.updatedAt-P.updatedAt);return{earlier:M.filter(P=>!u.has(P.id)),archivedItems:M.filter(P=>u.has(P.id))}},[i.items,t,c,u,O]),[U,D]=y.useState(null),F=async()=>{const M=U;D(null);const P=(M==null?void 0:M.value.trim())??"",V=i.items.find(z=>z.id===(M==null?void 0:M.id));M===null||V===void 0||P===""||P===yo(V)||await e.renameSession(M.id,P).catch(z=>f(z instanceof Error?z.message:String(z)))},A=async(M,P)=>{f(null),await e.connection.call(P?"sessions/archive":"sessions/unarchive",{sessionId:M}).catch(V=>f(V instanceof Error?V.message:String(V)))},T=M=>{const P=$(M),V=u.has(M.id);return s.jsxs("div",{className:"session-row",children:[(U==null?void 0:U.id)===M.id?s.jsx("input",{className:"text-input session-rename",autoFocus:!0,value:U.value,maxLength:80,"aria-label":"会话名称",onFocus:z=>z.target.select(),onChange:z=>D({id:M.id,value:z.target.value}),onKeyDown:z=>{z.key==="Enter"&&!z.nativeEvent.isComposing&&F(),z.key==="Escape"&&D(null)},onBlur:()=>void F()}):s.jsxs("button",{className:"nav-item session-item",onClick:()=>n(M.id),onDoubleClick:()=>D({id:M.id,value:yo(M)}),title:"双击改名",children:[P!==void 0&&s.jsx("span",{className:"channel-badge",children:P}),s.jsx("span",{className:"nav-item-label",children:P!==void 0?yo(M).replace(/^(飞书|feishu):/,""):yo(M)}),M.running?s.jsx("span",{className:"run-dot",role:"img","aria-label":"运行中"}):s.jsx("span",{className:"session-time",children:yt(M.updatedAt,d)})]}),(U==null?void 0:U.id)!==M.id&&s.jsxs("span",{className:"session-row-actions",children:[s.jsx("button",{className:"session-action",title:"改名","aria-label":"改名",onClick:()=>D({id:M.id,value:yo(M)}),children:s.jsx(Q,{name:"pencil"})}),L&&!M.running&&s.jsx("button",{className:"session-action",title:V?"恢复":"归档:从列表里移走,之后可以在「已归档」里找回","aria-label":V?"恢复":"归档",onClick:()=>void A(M.id,!V),children:s.jsx(Q,{name:V?"back":"archive"})})]})]},M.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(Q,{name:"search"}),s.jsx("input",{"aria-label":"搜索以前的对话",placeholder:"搜索以前的对话",value:g,onChange:M=>p(M.target.value),onKeyDown:M=>{M.key==="Escape"&&p("")}})]}),h!==null&&s.jsx("div",{className:"error small",children:h}),s.jsxs("nav",{className:"session-list","aria-label":"以前的对话",children:[!i.loaded&&r.state==="open"&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),i.loaded&&W.length===0&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(Q,{name:O===""?"chat":"search"}),s.jsx("span",{children:O===""?"没有以前的对话":"没有匹配的对话"})]}),(k?W:W.slice(0,vm)).map(T),!k&&W.length>vm&&s.jsxs("button",{className:"nav-item more-sessions",onClick:()=>w(!0),children:["更多(",W.length-vm,")"]}),L&&B.length>0&&s.jsxs("div",{className:"archive-entry",children:[s.jsxs("button",{className:"nav-item role-row",onClick:()=>b(M=>!M),"aria-expanded":x,children:[s.jsx(Q,{name:"archive"}),s.jsx("span",{className:"nav-item-label",children:"已归档"}),s.jsx("span",{className:"tab-count",children:B.length}),s.jsx(Q,{name:x?"chevron-down":"chevron",className:"role-chevron"})]}),x&&B.map(T)]})]})]})})}function yo(e){return e.title??(e.blank?"新会话":"未命名会话")}function yt(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 wz({client:e,pages:t,current:n,onAgent:i,onPage:r,onSchedule:o,onSettings:c,width:u,onWidth:d,slot:h}){const f=je(e.connection.status),g=je(e.capabilities),p=kz(e,n.kind==="agent"?n.id:void 0),x=Tw(e),b=u>=To,k=p.find(O=>O.agent.id===On),w=p.filter(O=>O.agent.id!==On),j=t.filter(O=>O.order<0),E=n.kind==="page"?j.find(O=>O.id===n.id):void 0,N=Vg(e,b?p.flatMap(O=>O.last===void 0?[]:[{id:O.last.id,updatedAt:O.last.updatedAt,running:O.last.running}]):[]),C=O=>O.last===void 0?void 0:N.get(O.last.id)??void 0,L=O=>s.jsx(Aa,{icon:O.icon,label:O.title,active:n.kind==="page"&&n.id===O.id,onClick:()=>r(O.id)},O.id),$=O=>s.jsx(Cz,{state:O,wide:b,reply:C(O),active:n.kind==="agent"&&n.id===O.agent.id,onClick:()=>i(O.agent.id)},O.agent.id);return s.jsxs("nav",{className:`rail${b?" wide":""}`,"aria-label":"功能区",children:[s.jsx("div",{className:"rail-top",children:k!==void 0&&$(k)}),s.jsx("span",{className:"rail-divider",role:"separator"}),E!==void 0?s.jsx("div",{className:"rail-items rail-slot",ref:h,"aria-label":E.title}):s.jsxs("div",{className:"rail-items",children:[w.map($),t.filter(O=>O.order>=0).map(L)]}),s.jsxs("div",{className:"rail-footer",children:[x!==null&&s.jsx(Aa,{icon:"download",label:"更新",title:`MultiGameAssistant ${x.version} 可以更新了:点开看更新了什么`,active:!1,onClick:Mw,dot:!0}),j.map(L),g.has("pipelines")&&s.jsx(Aa,{icon:"calendar",label:"定时",title:"每个 agent 的定时任务,和按时运行的流水线",active:n.kind==="schedule",onClick:o}),s.jsx(Aa,{icon:"settings",label:"设置",active:n.kind==="settings",onClick:c}),f.state!=="open"&&s.jsxs("span",{className:`rail-connection ${f.state}`,role:"status",title:Ib(f.state,f.attempt,f.error),children:[s.jsx("span",{className:"conn-dot"}),s.jsx("span",{className:"sr-only",children:Ib(f.state,f.attempt,f.error)})]})]}),s.jsx(Ez,{width:u,onWidth:d}),s.jsx(uz,{client:e})]})}const To=150,Ca=68,Sz=360,Cb="adg.railWidth";function _z(){const[e,t]=y.useState(()=>{try{return Ab(Number(localStorage.getItem(Cb)??Ca))}catch{return Ca}});return y.useEffect(()=>{const n=setTimeout(()=>{try{localStorage.setItem(Cb,String(e))}catch{}},200);return()=>clearTimeout(n)},[e]),[e,n=>t(Ab(n))]}function Ab(e){if(!Number.isFinite(e))return Ca;const t=Math.min(Sz,Math.max(Ca,Math.round(e)));return t<To?t<(Ca+To)/2?Ca:To:t}function Ez({width:e,onWidth:t}){const n=y.useRef(null),i=c=>{c.preventDefault(),n.current={x:c.clientX,width:e},c.currentTarget.setPointerCapture(c.pointerId)},r=c=>{n.current!==null&&t(n.current.width+c.clientX-n.current.x)},o=()=>{n.current=null};return s.jsx("div",{className:"rail-resizer",role:"separator","aria-orientation":"vertical","aria-label":"调整侧边栏宽度",title:"拖动调整宽度;双击展开或收起",onPointerDown:i,onPointerMove:r,onPointerUp:o,onPointerCancel:o,onDoubleClick:()=>t(e>=To?Ca:220)})}function Cz({state:e,wide:t,reply:n,active:i,onClick:r}){const{agent:o,running:c,unread:u,waiting:d}=e,h=n==null?void 0:n.replace(/\s+/g," ").trim();return s.jsxs("button",{className:`rail-item rail-agent ${i?"active":""}`,"aria-current":i?"page":void 0,onClick:r,title:`${o.name}:${o.description}${c>0?`(进行中${c>1?` ${c}`:""})`:""}`,children:[s.jsxs("span",{className:`agent-avatar rail-avatar agent-${o.id}`,children:[s.jsx(Q,{name:o.icon}),c>0&&s.jsx("span",{className:"agent-busy",role:"img","aria-label":`${c} 个正在运行`})]}),t?s.jsxs("span",{className:"rail-text",children:[s.jsx("span",{className:`rail-label ${u?"unread":""}`,children:o.name}),s.jsx("span",{className:"rail-preview",children:c>0?"正在处理…":h!==void 0&&h!==""?h:o.description})]}):s.jsx("span",{className:`rail-label ${u?"unread":""}`,children:o.name}),d>0?s.jsx("span",{className:"rail-badge","aria-label":`${d} 个等你处理`,children:d}):u&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新结果"})]})}function Aa({icon:e,label:t,title:n=t,active:i,onClick:r,disabled:o=!1,dot:c=!1}){return s.jsxs("button",{className:`rail-item ${i?"active":""} ${c?"rail-new":""}`,"aria-current":i?"page":void 0,onClick:r,title:n,disabled:o,children:[s.jsx(Q,{name:e}),s.jsx("span",{className:"rail-label",children:t}),c&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新版本"})]})}function Ib(e,t,n){const i=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return n===void 0?i:`${i}:${n}`}const Lw=y.createContext(null),Az=y.createContext(!1);function Iz({bridge:e,onClose:t}){const[n,i]=y.useState(null),[r,o]=y.useState(null),c=y.useRef(null),u=y.useRef(null),[d,h]=y.useState(""),[f,g]=y.useState(!1),[p,x]=y.useState(null),b=y.useRef(null),k=y.useRef(null),w=y.useRef(!1),j=y.useRef(0),E=n==null?void 0:n.tabs.find(z=>z.id===n.shown);y.useEffect(()=>{f||h((E==null?void 0:E.url)==="about:blank"?"":(E==null?void 0:E.url)??"")},[E==null?void 0:E.url,f]),y.useEffect(()=>{let z=!0;e.state().then(Z=>{z&&Z!==null&&i(Z)});const H=e.onChange(i),G=e.onFrame(Z=>{createImageBitmap(new Blob([Z.data],{type:"image/jpeg"})).then(Y=>{var X;if(!z)return Y.close();(X=u.current)==null||X.close(),u.current=Y,N(),o(re=>(re==null?void 0:re.width)===Z.width&&re.height===Z.height?re:{width:Z.width,height:Z.height})},()=>{})});return()=>{var Z;z=!1,H(),G(),(Z=u.current)==null||Z.close(),u.current=null}},[e]),y.useEffect(()=>{const z=b.current;if(z===null)return;const H=()=>{const{width:Z,height:Y}=z.getBoundingClientRect();e.show(Z>50&&Y>50?{width:Math.floor(Z),height:Math.floor(Y)}:null)},G=new ResizeObserver(H);return G.observe(z),H(),()=>{G.disconnect(),e.show(null)}},[e]);function N(){var G;const z=c.current,H=u.current;z===null||H===null||((z.width!==H.width||z.height!==H.height)&&(z.width=H.width,z.height=H.height),(G=z.getContext("2d"))==null||G.drawImage(H,0,0))}y.useEffect(N,[r]);const C=z=>{x(null),z.catch(H=>x(H instanceof Error?H.message:String(H)))},L=z=>{const H=z.currentTarget.getBoundingClientRect(),G=r===null?1:r.width/H.width,Z=r===null?1:r.height/H.height;return{x:Math.round((z.clientX-H.left)*G),y:Math.round((z.clientY-H.top)*Z)}},$=z=>[z.shiftKey&&"shift",z.ctrlKey&&"control",z.altKey&&"alt",z.metaKey&&"meta"].filter(H=>H!==!1),O=z=>z===1?"middle":z===2?"right":"left",W=z=>e.input(z),B=z=>{var H;z.preventDefault(),(H=k.current)==null||H.focus(),W({type:"mouseDown",...L(z),button:O(z.button),clickCount:z.detail,modifiers:$(z)})},U=z=>W({type:"mouseUp",...L(z),button:O(z.button),clickCount:z.detail,modifiers:$(z)}),D=z=>{const H=Date.now();z.buttons===0&&H-j.current<50||(j.current=H,W({type:"mouseMove",...L(z),modifiers:$(z)}))},F=z=>W({type:"mouseWheel",...L(z),deltaX:-z.deltaX,deltaY:-z.deltaY,canScroll:!0,modifiers:$(z)}),A=z=>{if(w.current||z.nativeEvent.isComposing)return;const H={Enter:"Enter",Backspace:"Backspace",Tab:"Tab",Escape:"Escape",Delete:"Delete",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right"},G=(z.ctrlKey||z.metaKey||z.altKey)&&z.key.length===1,Z=H[z.key]??(G?z.key.toUpperCase():void 0);if(Z===void 0)return;z.preventDefault();const Y=$(z);W({type:"keyDown",keyCode:Z,modifiers:Y}),Z==="Enter"&&W({type:"char",keyCode:"\r",modifiers:Y}),W({type:"keyUp",keyCode:Z,modifiers:Y})},T=()=>{const z=k.current;if(z===null||z.value==="")return;const H=z.value;z.value="",e.text(H)},M=()=>{const z=d.trim();z!==""&&(g(!1),C(e.navigate({url:z,...E===void 0?{newTab:!0}:{}})))},P=n!==null&&Date.now()-n.agentAt<5e3,[,V]=y.useState(0);return y.useEffect(()=>{if(!P||n===null)return;const z=setTimeout(()=>V(H=>H+1),n.agentAt+5e3-Date.now()+50);return()=>clearTimeout(z)},[P,n]),s.jsxs("aside",{className:"browser-panel","aria-label":"内置浏览器",children:[s.jsxs("div",{className:"browser-toolbar",children:[s.jsx("button",{type:"button",className:"icon-button",title:"后退","aria-label":"后退",disabled:(E==null?void 0:E.canGoBack)!==!0,onClick:()=>C(e.navigate({action:"back"})),children:s.jsx(Q,{name:"back"})}),s.jsx("button",{type:"button",className:"icon-button",title:"前进","aria-label":"前进",disabled:(E==null?void 0:E.canGoForward)!==!0,onClick:()=>C(e.navigate({action:"forward"})),children:s.jsx(Q,{name:"chevron"})}),s.jsx("button",{type:"button",className:"icon-button",title:"刷新","aria-label":"刷新",disabled:E===void 0,onClick:()=>C(e.navigate({action:"reload"})),children:s.jsx(Q,{name:"refresh"})}),s.jsx("input",{className:"text-input browser-address",value:d,placeholder:"输入网址,回车打开","aria-label":"网址",onFocus:z=>{g(!0),z.target.select()},onBlur:()=>g(!1),onChange:z=>h(z.target.value),onKeyDown:z=>{z.key==="Enter"&&!z.nativeEvent.isComposing&&M(),z.key==="Escape"&&z.target.blur()}}),s.jsx("button",{type:"button",className:"icon-button",title:"关闭浏览器面板(页面保留)","aria-label":"关闭浏览器面板",onClick:t,children:s.jsx(Q,{name:"close"})})]}),n!==null&&n.tabs.length>0&&s.jsxs("div",{className:"browser-tabs",role:"tablist","aria-label":"标签页",children:[n.tabs.map(z=>s.jsxs("span",{className:`browser-tab${z.id===n.shown?" active":""}`,children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":z.id===n.shown,title:z.url,onClick:()=>C(e.select(z.id)),children:[z.loading&&s.jsx("span",{className:"pill-dot"}),z.title===""?z.url:z.title]}),s.jsx("button",{type:"button",className:"browser-tab-close",title:"关闭标签页","aria-label":`关闭 ${z.title}`,onClick:()=>C(e.close(z.id)),children:s.jsx(Q,{name:"close"})})]},z.id)),s.jsx("button",{type:"button",className:"browser-tab-new",title:"新标签页","aria-label":"新标签页",onClick:()=>{h(""),C(e.navigate({url:"about:blank",newTab:!0}))},children:s.jsx(Q,{name:"plus"})})]}),P&&s.jsxs("div",{className:"browser-status",children:[s.jsx("span",{className:"pill-dot"}),"agent 正在操作这个页面,你也可以直接接手"]}),p!==null&&s.jsx("div",{className:"banner error",children:p}),s.jsxs("div",{className:"browser-viewport",ref:b,children:[E===void 0?s.jsxs("div",{className:"empty",children:["还没有打开网页:在上面输入网址,或者让 agent 去打开。",s.jsx("br",{}),"内置浏览器不保存登录,也不能下载文件。"]}):r===null?s.jsx("div",{className:"empty",children:"正在载入…"}):s.jsx("canvas",{ref:c,className:"browser-frame","aria-label":E.title,onMouseDown:B,onMouseUp:U,onMouseMove:D,onWheel:F,onContextMenu:z=>z.preventDefault()}),s.jsx("textarea",{ref:k,className:"browser-typing","aria-label":"在页面里输入",tabIndex:-1,onKeyDown:A,onCompositionStart:()=>{w.current=!0},onCompositionEnd:()=>{w.current=!1,T()},onInput:()=>{w.current||T()}})]})]})}const _d="adg.draft.",Tb=60,Tp=new Map;function Tz(e){try{const t=localStorage.getItem(_d+e);if(t===null)return"";const n=JSON.parse(t);return typeof n.text=="string"?n.text:""}catch{return""}}function $z(e,t){try{if(t.trim()===""){localStorage.removeItem(_d+e);return}localStorage.setItem(_d+e,JSON.stringify({text:t,at:Date.now()})),Oz()}catch{}}function Mz(e){return Tp.get(e)??[]}function Rz(e,t){t.length===0?Tp.delete(e):Tp.set(e,[...t])}function Oz(){const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!(n===null||!n.startsWith(_d)))try{e.push({key:n,at:Number(JSON.parse(localStorage.getItem(n)??"{}").at)||0})}catch{e.push({key:n,at:0})}}if(!(e.length<=Tb))for(const t of e.sort((n,i)=>n.at-i.at).slice(0,e.length-Tb))localStorage.removeItem(t.key)}const Pz={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},$b=(e,t)=>Pz[e]??(t!==void 0&&t!==e?t:e);function Dw(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function zz(e,t){var n;if(!(e===null||t===null))return(n=e.groups.find(i=>i.id===t.provider))==null?void 0:n.models.find(i=>i.id===t.model)}function Lz({client:e,sessionId:t,disabled:n,value:i,onChange:r}){var F;const{catalog:o,error:c}=el(e),u=je(e.sessionModels),d=je(e.connection.status),[h,f]=y.useState(!1),[g,p]=y.useState(null),[x,b]=y.useState(!1),[k,w]=y.useState(""),j=y.useRef(null);y.useEffect(()=>{d.state!=="open"||t===void 0||e.sessionModel(t).catch(()=>{})},[e,t,d.state]),y.useEffect(()=>{if(!x)return;const A=M=>{j.current!==null&&!j.current.contains(M.target)&&b(!1)},T=M=>{M.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",A),document.addEventListener("keydown",T),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",T)}},[x]);const E=t===void 0?void 0:u.get(t),N=t===void 0?i??(o==null?void 0:o.default)??null:Dw(o,E),C=zz(o,N),L=N!==null&&o!==null&&C===void 0,$=async A=>{if(p(null),t===void 0){r==null||r(A);return}f(!0);try{await e.selectModel(t,A)}catch(T){p(T instanceof Error?T.message:String(T))}finally{f(!1)}},O=(A,T)=>{const M=(N==null?void 0:N.reasoningEffort)!==void 0&&T.efforts.some(P=>P.id===N.reasoningEffort)?N.reasoningEffort:T.defaultEffort;$({provider:A,model:T.id,...M===void 0?{}:{reasoningEffort:M}}),T.efforts.length===0&&b(!1)},W=y.useMemo(()=>{const A=k.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(T=>({...T,models:T.models.filter(M=>A===""||M.id.toLowerCase().includes(A)||M.name.toLowerCase().includes(A)||T.name.toLowerCase().includes(A))})).filter(T=>T.models.length>0)},[o,k]),B=[g,c,...(o==null?void 0:o.failures.map(A=>`${A.name}:${A.message}`))??[]].filter(Boolean);if(o===null)return null;const U=(N==null?void 0:N.reasoningEffort)??(C==null?void 0:C.defaultEffort),D=(F=C==null?void 0:C.efforts.find(A=>A.id===U))==null?void 0:F.name;return s.jsxs("div",{className:`model-picker${g!==null?" has-error":""}`,ref:j,children:[s.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":x,disabled:n||h,title:B.length>0?B.join(`
193
+ `):"选择模型和思考强度",onClick:()=>b(A=>!A),children:[s.jsx("span",{className:`model-dot ${L?"off":""}`}),s.jsx("span",{className:"model-name",children:(C==null?void 0:C.name)??(N===null?"选择模型":`${N.model}(不可用)`)}),U!==void 0&&C!==void 0&&C.efforts.length>0&&s.jsx("span",{className:"model-effort",children:$b(U,D)}),s.jsx(Q,{name:"chevron-down"})]}),x&&s.jsxs("div",{className:"model-panel",role:"dialog","aria-label":"选择模型",children:[s.jsx("input",{className:"text-input plain model-search",autoFocus:!0,placeholder:"搜索模型",value:k,onChange:A=>w(A.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(A=>s.jsxs("div",{className:"model-group",children:[s.jsx("div",{className:"model-group-name",children:A.name}),A.models.map(T=>{const M=(N==null?void 0:N.provider)===A.id&&N.model===T.id;return s.jsxs("button",{type:"button",role:"option","aria-selected":M,className:`model-option ${M?"active":""}`,onClick:()=>O(A.id,T),children:[s.jsxs("span",{className:"model-option-main",children:[s.jsx("span",{children:T.name}),T.name!==T.id&&s.jsx("span",{className:"muted small",children:T.id})]}),T.efforts.length>0&&s.jsx("span",{className:"model-tag",children:"思考"}),M&&s.jsx(Q,{name:"check"})]},T.id)})]},A.id))]}),C!==void 0&&N!==null&&s.jsxs("div",{className:"model-efforts",children:[s.jsx("span",{className:"field-label",children:"思考强度"}),C.efforts.length===0?s.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:C.efforts.map(A=>s.jsx("button",{type:"button",role:"radio","aria-checked":U===A.id,className:U===A.id?"active":"",onClick:()=>void $({provider:N.provider,model:N.model,reasoningEffort:A.id}),children:$b(A.id,A.name)},A.id))})]}),B.length>0&&s.jsx("div",{className:"error small model-problems",children:B.join(";")})]})]})}let Kl=[],Dz=1;const $p=new Set,Mb=()=>{for(const e of $p)e()},Fz=e=>($p.add(e),()=>{$p.delete(e)}),Uz=()=>Kl[0];function Bz(e,t){return new Promise(n=>{const i=Dz++;Kl=[...Kl,{...e,id:i,single:t,settle:r=>{Kl=Kl.filter(o=>o.id!==i),Mb(),n(r)}}],Mb()})}function Ps(e){return Bz(e,!1)}function Hz(){const e=y.useSyncExternalStore(Fz,Uz);return e===void 0?null:s.jsx(Zz,{pending:e},e.id)}function Zz({pending:e}){const{title:t,message:n,quote:i,confirmLabel:r="确定",cancelLabel:o="取消",danger:c=!1,icon:u,single:d,settle:h}=e,f=y.useRef(null),g=y.useRef(null),p=y.useRef(null),x=`confirm-title-${e.id}`,b=`confirm-body-${e.id}`;return y.useEffect(()=>{var w;const k=document.activeElement;return(w=(c&&!d?p:g).current)==null||w.focus({preventScroll:!0}),()=>{k instanceof HTMLElement&&k.isConnected&&k.focus({preventScroll:!0})}},[c,d]),y.useEffect(()=>{const k=w=>{if(w.key==="Escape"){w.preventDefault(),w.stopPropagation(),h(!1);return}if(w.key!=="Tab"||f.current===null)return;const j=[...f.current.querySelectorAll("button:not(:disabled)")],E=j.indexOf(document.activeElement);w.preventDefault();const N=j[(E+(w.shiftKey?-1:1)+j.length)%j.length];N==null||N.focus()};return document.addEventListener("keydown",k,!0),()=>document.removeEventListener("keydown",k,!0)},[h]),s.jsx("div",{className:"dialog-backdrop confirm-backdrop",onPointerDown:k=>{k.target===k.currentTarget&&h(!1)},children:s.jsxs("div",{ref:f,className:`dialog confirm-dialog ${c?"danger":""}`,role:d?"dialog":"alertdialog","aria-modal":"true","aria-labelledby":x,"aria-describedby":n===void 0&&i===void 0?void 0:b,children:[s.jsxs("h3",{id:x,children:[(u!==void 0||c)&&s.jsx(Q,{name:u??"alert"}),t]}),(n!==void 0||i!==void 0)&&s.jsxs("div",{id:b,className:"confirm-body",children:[typeof n=="string"?s.jsx(Wz,{text:n}):n,i!==void 0&&s.jsx("blockquote",{className:"confirm-quote",children:i})]}),s.jsxs("div",{className:"confirm-actions",children:[!d&&s.jsx("button",{ref:p,type:"button",onClick:()=>h(!1),children:o}),s.jsx("button",{ref:g,type:"button",className:c?"danger":"primary",onClick:()=>h(!0),children:r})]})]})})}function Wz({text:e}){return s.jsx(s.Fragment,{children:e.split(/\n\s*\n/).map((t,n)=>{const i=t.split(`
194
+ `).filter(r=>r.trim()!=="");return i.length>0&&i.every(r=>r.startsWith("· "))?s.jsx("ul",{children:i.map((r,o)=>s.jsx("li",{children:r.slice(2)},o))},n):s.jsx("p",{children:t},n)})})}function Fw(e,t){return t.find(n=>n.scripts.includes(e.packId??e.id)||n.scripts.includes(e.id))}function Mp(e,t){const n=e.toLowerCase();return t.find(i=>[i.id,i.name,...i.aliases].some(r=>r.toLowerCase()===n))}function Rp(e,t,n){const i=[];for(const r of new Set((e==null?void 0:e.scripts)??[])){const o=t.find(u=>u.id===r||u.packId===r),c=o===void 0?n.find(u=>u.scripts.includes(r)):Fw(o,n);i.push({script:o===void 0?{id:r,name:r}:{id:o.id,name:o.name},...c===void 0?{}:{game:{id:c.id,name:c.name}}})}if(i.length===0)for(const r of new Set((e==null?void 0:e.games)??[])){const o=Mp(r,n);i.push({game:o===void 0?{id:r,name:r}:{id:o.id,name:o.name}})}return i}function Uw(e){var t,n;return[(t=e.game)==null?void 0:t.name,(n=e.script)==null?void 0:n.name].filter(i=>i!==void 0).join(" · ")}let ym=[];function Vz(e){const t=je(e.capabilities),n=t.has("skills"),i=t.has("scripts"),r=t.has("games"),[o,c]=y.useState(ym),[u,d]=y.useState(0);return y.useEffect(()=>e.connection.on("skills/changed",()=>d(h=>h+1)),[e]),y.useEffect(()=>{if(!n)return;let h=!0;const f=i?e.connection.call("scripts/list",{}).then(p=>p.scripts,()=>[]):Promise.resolve([]),g=r?e.connection.call("games/list",{}).then(p=>p.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),f,g]).then(([p,x,b])=>{ym=p.skills.filter(k=>k.userInvocable).map(k=>{const w=[...new Set(Rp(k.owner,x,b).map(Uw))].join("、");return{name:k.name,description:k.description,...w===""?{}:{group:w}}}),h&&c(ym)},()=>{}),()=>{h=!1}},[e,n,i,r,u]),o}const bm=e=>e.kind==="command"?"命令":e.group??"通用技能";function Bw({client:e,text:t,setText:n,area:i,submit:r,placement:o="above",inSession:c=!1}){const u=Vz(e),[d,h]=y.useState(0),[f,g]=y.useState(!1),p=f?[]:jO(t,u,c),x=t.split(/\s/)[0];y.useEffect(()=>{h(0),g(!1)},[x]);const b=Math.min(d,Math.max(0,p.length-1)),k=N=>{var C;n(`/${N.name} `),g(!0),(C=i.current)==null||C.focus()},w=N=>{var C;if(r!==void 0&&N.kind==="command"&&N.arg===void 0){n(""),r(`/${N.name}`),(C=i.current)==null||C.focus();return}k(N)},j=N=>{if(p.length===0||N.nativeEvent.isComposing)return!1;if(N.key==="ArrowDown"||N.key==="ArrowUp")return N.preventDefault(),h((b+(N.key==="ArrowDown"?1:p.length-1))%p.length),!0;if(N.key==="Tab"||N.key==="Enter"&&!N.shiftKey){N.preventDefault();const C=p[b];return N.key==="Tab"?k(C):w(C),!0}return N.key==="Escape"?(N.preventDefault(),g(!0),!0):!1};return{menu:p.length===0?null:s.jsx(qz,{options:p,active:b,placement:o,onHover:h,onChoose:w}),onKeyDown:j,expand:N=>kO(N,u)}}function qz({options:e,active:t,placement:n,onHover:i,onChoose:r}){const o=y.useRef(null),[c,u]=y.useState(0);y.useLayoutEffect(()=>{var f;const h=(f=o.current)==null?void 0:f.querySelector(`[data-index="${t}"]`);h==null||o.current===null||(h.scrollIntoView({block:"nearest"}),u(h.offsetTop-o.current.scrollTop))},[t,e]);const d=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 f;const h=(f=o.current)==null?void 0:f.querySelector(`[data-index="${t}"]`);h!=null&&o.current!==null&&u(h.offsetTop-o.current.scrollTop)},children:e.map((h,f)=>s.jsxs("div",{children:[(f===0||bm(e[f-1])!==bm(h))&&s.jsx("div",{className:"slash-group",children:bm(h)}),s.jsx("button",{type:"button",role:"option","data-index":f,"aria-selected":f===t,className:`slash-item ${f===t?"active":""}`,onMouseEnter:()=>i(f),onMouseDown:g=>g.preventDefault(),onClick:()=>r(h),children:h.name})]},`${h.kind}:${h.name}`))}),d!==void 0&&s.jsxs("div",{className:"slash-tip",style:{top:c},role:"tooltip",children:[d.kind==="skill"&&s.jsx("span",{className:"slash-tip-kind",children:d.group===void 0?"技能":`${d.group} 的技能`}),d.description,d.kind==="command"&&d.arg!==void 0&&s.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",d.arg]}),d.kind==="skill"&&s.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const Op=5.5,Rb=2*Math.PI*Op,Ob=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function km(e){return e>=1e6?`${Pb(e/1e6)}M`:e>=1e3?`${Pb(e/1e3)}k`:String(Math.round(e))}const Pb=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function Gz({context:e}){const[t,n]=y.useState(!1),i=y.useRef(null);if(y.useEffect(()=>{if(!t)return;const f=p=>{var x;(x=i.current)!=null&&x.contains(p.target)||n(!1)},g=p=>{p.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",g),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",g)}},[t]),e===null)return null;const r=Math.min(100,Math.round(e.usedTokens/e.contextWindow*100)),o=r>=90?"high":r>=70?"raised":"normal",c=e.breakdown,u=c===void 0?0:c.systemTokens+c.toolsTokens+c.messageTokens,d=c===void 0||u===0?[{key:"total",tone:"messages",width:r}]:Ob.map(f=>({key:f.key,tone:f.tone,width:r*c[f.key]/u})).filter(f=>f.width>0),h=`上下文已用 ${r}%`;return s.jsxs("span",{ref:i,className:`context-meter ${o}`,children:[s.jsxs("button",{type:"button",className:"context-trigger",title:h,"aria-label":h,"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:Op}),s.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Op,strokeDasharray:`${Rb*r/100} ${Rb}`,transform:"rotate(-90 7 7)"})]}),s.jsxs("span",{children:[r,"%"]})]}),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:[r,"%"]})]}),s.jsxs("span",{className:"context-figures",children:["~",km(e.usedTokens)," / ",km(e.contextWindow)]})]}),s.jsx("div",{className:"context-bar",children:d.map(f=>s.jsx("span",{className:`context-segment ${f.tone}`,style:{width:`${f.width}%`}},f.key))}),c!==void 0&&s.jsx("dl",{className:"context-rows",children:Ob.map(f=>s.jsxs("div",{children:[s.jsxs("dt",{children:[s.jsx("span",{className:`context-swatch ${f.tone}`,"aria-hidden":"true"}),f.label]}),s.jsxs("dd",{children:["~",km(c[f.key])]})]},f.key))}),s.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",s.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const Kz=6e4,Yz={CNY:"¥",USD:"$"},ud=(e,t)=>{const n=Yz[e];return n===void 0?`${t} ${e}`:`${n}${t}`};function Xz({balances:e}){const t=e.filter(n=>Number(n.total)!==0);return(t.length>0?t:e.slice(0,1)).map(n=>ud(n.currency,n.total)).join(" / ")}function Qz(e){return`DeepSeek 账户余额 ${e.balances.map(n=>`${ud(n.currency,n.total)}(充值 ${ud(n.currency,n.toppedUp)},赠送 ${ud(n.currency,n.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function Jz({client:e,sessionId:t,running:n}){var g;const{catalog:i}=el(e),r=je(e.sessionModels).get(t),o=((g=Dw(i,r))==null?void 0:g.provider)??null,c=je(e.credentialRevision),u=je(e.connection.status),d=je(e.capabilities),[h,f]=y.useState(null);return y.useEffect(()=>{if(o===null||u.state!=="open"||!d.has("providers"))return;let p=!0;const x=()=>e.providerBalance(o).then(k=>{p&&f({provider:o,balance:k,error:null})},k=>{p&&f({provider:o,balance:null,error:k instanceof Error?k.message:String(k)})});x();const b=n?setInterval(()=>void x(),Kz):void 0;return()=>{p=!1,clearInterval(b)}},[e,o,c,u.state,d,n]),h===null||h.provider!==o?null:h.error!==null?s.jsx("span",{className:"balance-chip failed",title:h.error,children:"余额 ?"}):h.balance===null||h.balance.balances.length===0?null:s.jsx("span",{className:`balance-chip ${h.balance.available?"":"low"}`,title:Qz(h.balance),children:Xz(h.balance)})}function eL({client:e,session:t,running:n,disabled:i,initialPrompt:r,onInitialSent:o,reminder:c}){const u=je(e.capabilities),{queue:d,context:h}=je(t.state),[f,g]=y.useState(()=>Tz(t.id)),[p,x]=y.useState(!0),[b,k]=y.useState(null),[w,j]=y.useState(null),E=y.useRef(null),N=y.useRef(null),C=y.useRef(!1),[L,$]=y.useState(()=>Mz(t.id));y.useEffect(()=>$z(t.id,f),[t.id,f]),y.useEffect(()=>Rz(t.id,L),[t.id,L]);const O=HO(e),[W,B]=y.useState(!1),U=async H=>{const G=H.filter(Y=>Y.type.startsWith("image/"));if(G.length===0)return;k(null);const Z=zl-L.length;if(Z<=0){k(`一条消息最多 ${zl} 张图片`);return}try{const Y=await Promise.all(G.slice(0,Z).map(sL));$(X=>[...X,...Y].slice(0,zl)),G.length>Z&&k(`一条消息最多 ${zl} 张图片,多的没有加上`)}catch(Y){k(`图片没能加上:${Y instanceof Error?Y.message:String(Y)}`)}},D=H=>{const G=[...H.clipboardData.items].filter(Z=>Z.kind==="file"&&Z.type.startsWith("image/")).map(Z=>Z.getAsFile()).filter(Z=>Z!==null);G.length!==0&&(H.preventDefault(),U(G))},F=H=>{B(!1),H.dataTransfer.files.length!==0&&(H.preventDefault(),U([...H.dataTransfer.files]))};y.useEffect(()=>{var H;r===void 0||C.current||i||(C.current=!0,t.prompt(r,"queue").catch(G=>k(G instanceof Error?G.message:String(G))),o==null||o(),(H=E.current)==null||H.focus())},[r,i,t,o]);const A=H=>yO(H)!=="compact"?!1:(g(""),k(null),n?(k("agent 正在工作,等它停下再压缩"),!0):(Ps({title:"压缩这个对话?",message:tL,confirmLabel:"压缩",danger:!0}).then(G=>{G&&(j("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(Z=>j(Z.message),Z=>{j(null),k(Z instanceof Error?Z.message:String(Z))}))}),!0)),T=Bw({client:e,text:f,setText:g,area:E,inSession:!0,submit:H=>{i||A(H)||(k(null),t.prompt(T.expand(H),n&&p?"steer":"queue").catch(G=>k(G instanceof Error?G.message:String(G))))}}),M=()=>{var Z;if(!i&&L.length===0&&A(f))return;const H=T.expand(f);if(H===""&&L.length===0||i)return;const G=L.map(({url:Y,...X})=>X);g(""),$([]),k(null),t.prompt(H,n&&p?"steer":"queue",G).catch(Y=>k(Y instanceof Error?Y.message:String(Y))),(Z=E.current)==null||Z.focus()},P=H=>{T.onKeyDown(H)||H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),M())},V=H=>{t.updateQueue(H.id,"remove").then(()=>{f.trim()===""&&H.text!==""&&g(H.text)},G=>k(G instanceof Error?G.message:String(G)))},z=H=>{t.updateQueue(H.id,"steer").catch(G=>k(G instanceof Error?G.message:String(G)))};return s.jsxs("div",{className:"composer",children:[b!==null&&s.jsx("div",{className:"error small composer-error",children:b}),d.length>0&&s.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:d.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:()=>z(H),children:"现在插入"}),s.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>V(H),children:"撤回"})]},H.id))}),c,w!==null&&s.jsxs("div",{className:"composer-note small",role:"status",children:[s.jsx("span",{children:w}),s.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>j(null),children:"知道了"})]}),s.jsxs("div",{className:"slash-anchor",children:[T.menu,s.jsxs("div",{className:`composer-box ${W?"dragging":""}`,onDragOver:H=>{[...H.dataTransfer.items].some(G=>G.kind==="file")&&(H.preventDefault(),B(!0))},onDragLeave:()=>B(!1),onDrop:F,children:[L.length>0&&s.jsx("div",{className:"composer-images",children:L.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:()=>$(Z=>Z.filter((Y,X)=>X!==G)),children:"✕"})]},G))}),s.jsx("textarea",{onPaste:D,ref:E,"aria-label":"消息内容",value:f,onChange:H=>g(H.target.value),onKeyDown:P,rows:Math.min(8,Math.max(2,f.split(`
195
+ `).length)),placeholder:i?"未连接到 agent":n?p?"运行中:发出去会插进这一轮,改主意了直接说":"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:i}),s.jsxs("div",{className:"composer-actions",children:[u.has("models")&&s.jsx(Lz,{client:e,sessionId:t.id,disabled:i}),s.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:i||L.length>=zl,onClick:()=>{var H;return(H=N.current)==null?void 0:H.click()},children:s.jsx(Q,{name:"image"})}),s.jsx("input",{ref:N,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:H=>{U([...H.target.files??[]]),H.target.value=""}}),O==="full"&&s.jsxs("button",{type:"button",className:"full-access-chip",title:"agent 做事不再请求确认,点这里修改",onClick:()=>{location.hash="#/settings/permissions"},children:[s.jsx(Q,{name:"alert"}),"完全访问"]}),s.jsx("span",{className:"spacer"}),s.jsx(Jz,{client:e,sessionId:t.id,running:n}),s.jsx(Gz,{context:h}),n&&s.jsxs("label",{className:"steer-toggle",title:"这一步做完 agent 就会看到;不勾选就等这一轮结束再发",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:H=>x(H.target.checked)}),"插入当前轮次"]}),n&&s.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(H=>k(String(H))),disabled:i,children:[s.jsx(WO,{}),"停止"]}),s.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:M,disabled:i||f.trim()===""&&L.length===0,children:s.jsx(Q,{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 tL=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。"].join(`
196
+ `),zl=4,nL=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function sL(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,i=t.slice(t.indexOf(",")+1);if(nL.has(e.type)&&i.length<=gp)return{mediaType:e.type,data:i,name:n,url:t};const r=new Image;r.src=t,await r.decode();for(let o=2560;o>=640;o=Math.round(o*.75)){const c=Math.min(1,o/Math.max(r.naturalWidth,r.naturalHeight)),u=document.createElement("canvas");u.width=Math.max(1,Math.round(r.naturalWidth*c)),u.height=Math.max(1,Math.round(r.naturalHeight*c)),u.getContext("2d").drawImage(r,0,0,u.width,u.height);const d=u.toDataURL("image/jpeg",.88),h=d.slice(d.indexOf(",")+1);if(h.length<=gp)return{mediaType:"image/jpeg",data:h,name:n.replace(/\.\w+$/,".jpg"),url:d}}throw new Error("图片太大")}const Pp=y.createContext(null);function iL(e,t){y.useLayoutEffect(()=>{const n=e.current;if(n===null||typeof ResizeObserver>"u")return;let i=-1/0;const r=()=>{i=performance.now()},o=new ResizeObserver(()=>{!t.current||n.scrollHeight-n.scrollTop-n.clientHeight<=2||(performance.now()-i<rL?t.current=!1:n.scrollTop=n.scrollHeight)});o.observe(n);for(const c of n.children)o.observe(c);return n.addEventListener("pointerdown",r,!0),n.addEventListener("keydown",r,!0),()=>{o.disconnect(),n.removeEventListener("pointerdown",r,!0),n.removeEventListener("keydown",r,!0)}},[e,t])}const rL=400;function Hw(e){const t=y.useRef(!0),n=y.useRef(0);return{following:t,onScroll:i=>{const r=i.currentTarget,o=r.scrollHeight-r.scrollTop-r.clientHeight,c=r.scrollTop<n.current-1;n.current=r.scrollTop,o<=2?t.current=!0:c?t.current=!1:o<e&&(t.current=!0)},onWheel:i=>{i.deltaY<0&&(t.current=!1)}}}const aL=160;function ic(e,t=aL){var i;const n=((i=e.split(/\r?\n/).find(r=>r.trim()!==""))==null?void 0:i.trim())??"";return n.length>t?`${n.slice(0,t-1)}…`:n}function zb(e,t="text"){return e.filter(n=>n.type===t).map(n=>n.text).join("")}function Yl(e){const t=ic(zb(e));if(t!=="")return t;const n=ic(zb(e,"reasoning"));if(n!=="")return n;const i=e.filter(c=>c.type==="tool-call").map(c=>c.name);if(i.length>0)return`→ ${i.join(", ")}`;const r=e.filter(c=>c.type==="image").length,o=e.filter(c=>c.type==="file").length;return[r>0?`${r} image(s)`:"",o>0?`${o} file(s)`:""].filter(Boolean).join(" · ")}function oL(e,t=null,n={}){var $,O,W,B,U,D,F;const i=[],r=new Map,o=[],c=new Map,u=new Map,d=new Map;let h=null,f=null,g=null,p=0,x=0;const b=(A,T)=>{let M=r.get(A);return M===void 0&&(M=Nm(`t:${A}`,A,T,!0),r.set(A,M),i.push(M)),f=null,M},k=(A,T)=>h!==null?h:(f===null&&(f=Nm(`b:${T}`,null,A,!1),i.push(f)),f),w=(A,T,M,P)=>{let V=A.steps.get(M);return V===void 0&&(V={turn:T,step:M,start:P,startKnown:!1,end:null,records:[],retries:0},A.steps.set(M,V),A.stepOrder.push(M)),V},j=(A,T,M)=>{A.records.push(M),T==null||T.records.push(M),o.push(M)},E=A=>(A.requestIndex??(A.requestIndex=++p),A.requestIndex),N=new Set;for(const A of e)switch(x=Math.max(x,A.time),A.type){case"turn/start":{const T=Nm(`t:${A.turn}`,A.turn,A.time,!1);r.set(A.turn,T),i.push(T),h=T,f=null;break}case"turn/end":{const T=b(A.turn,A.time);T.end=A.time,T.reason=A.reason;for(const M of T.steps.values())M.end??(M.end=A.time);for(const M of c.values())M.turn===A.turn&&M.status==="running"&&(M.status="interrupted",M.end=A.time);h===T&&(h=null);break}case"step/start":{const T=b(A.turn,A.time),M=w(T,A.turn,A.step,A.time);M.start=A.time,M.startKnown=!0;break}case"step/end":{const T=b(A.turn,A.time);w(T,A.turn,A.step,A.time).end=A.time;break}case"user/message":{const T=k(A.time,A.seq);j(T,null,lL(A,T.turn));break}case"system/message":{if(A.text.trim()==="")break;const T=b(A.turn,A.time),M=w(T,A.turn,A.step,A.time),P={kind:"system",id:`system:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:A.time,status:"ok",title:"System prompt",preview:ic(A.text),text:A.text};j(T,M,P);break}case"request/header":{g={...A.provider===void 0?{}:{provider:A.provider},...A.model===void 0?{}:{model:A.model},...A.reasoningEffort===void 0?{}:{reasoningEffort:A.reasoningEffort},toolCount:A.toolNames.length};break}case"assistant/attempt":{const T=b(A.turn,A.time),M=w(T,A.turn,A.step,A.time);jm(M,A.timing.firstTokenAt),M.retries+=1,A.error!==void 0&&(M.lastRetryError=A.error);const P={kind:"attempt",id:`attempt:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:A.timing.firstChunkAt??M.start,end:A.timing.lastChunkAt??A.time,status:"error",title:"Failed attempt",preview:(($=A.error)==null?void 0:$.message)??"attempt ended without output",...A.error===void 0?{}:{error:A.error}};j(T,M,P);break}case"assistant/message":{const T=b(A.turn,A.time),M=w(T,A.turn,A.step,A.time);jm(M,A.timing.firstTokenAt),N.add(`${A.turn}:${A.step}`);const P=A.timing.firstTokenAt,V=A.timing.lastChunkAt,z=P!==void 0&&V!==void 0?V-P:void 0,H=A.model??(g==null?void 0:g.model),G=A.provider??(g==null?void 0:g.provider),Z={kind:"assistant",id:`assistant:${A.seq}`,seq:A.seq,turn:A.turn,step:A.step,start:M.start,end:V??A.time,status:A.interrupted===!0?"interrupted":"ok",title:H===void 0?"Assistant":`Assistant · ${H}`,preview:Yl(A.content),content:A.content,live:!1,interrupted:A.interrupted===!0,request:Db({index:E(M),provider:G,model:H,reasoningEffort:g==null?void 0:g.reasoningEffort,toolCount:g==null?void 0:g.toolCount,ttftMs:Lb(M),decodeMs:z,tokensPerSecond:cL((O=A.usage)==null?void 0:O.outputTokens,z),usage:A.usage,retries:M.retries,lastRetryError:M.lastRetryError})};j(T,M,Z);break}case"tool/call":{const T=b(A.turn,A.time),M=w(T,A.turn,A.step,A.time),P=d.get(A.callId),V={kind:"tool",id:`tool:${A.callId}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:null,status:T.end===null?"running":"interrupted",title:A.name,preview:ic(A.arguments),name:A.name,callId:A.callId,arguments:A.arguments,isError:!1,...P===void 0?{}:{approval:{approvalId:P}}};c.set(A.callId,V),j(T,M,V);break}case"tool/result":{const T=c.get(A.callId);if(T===void 0){const P=b(A.turn,A.time),V=w(P,A.turn,A.step,A.time),z={kind:"tool",id:`tool:${A.callId}`,seq:A.seq,turn:A.turn,step:A.step,start:A.time,end:A.time,status:A.isError?"error":"ok",title:"tool result",preview:Yl(A.content),name:"tool result",callId:A.callId,arguments:"",result:A.content,isError:A.isError,...A.error===void 0?{}:{error:A.error}};j(P,V,z);break}T.end=A.time,T.result=A.content,T.isError=A.isError,T.status=A.isError?"error":"ok",A.error!==void 0&&(T.error=A.error);const M=Yl(A.content);M!==""&&(T.preview=`${ic(T.arguments,80)} ⇒ ${M}`);break}case"approval/asked":{if(A.callId===void 0)break;d.set(A.callId,A.approvalId);const T=c.get(A.callId);T!==void 0&&(T.approval={approvalId:A.approvalId,...A.reason===void 0?{}:{reason:A.reason}});break}case"approval/decided":{for(const T of c.values())((W=T.approval)==null?void 0:W.approvalId)===A.approvalId&&(T.approval={...T.approval,outcome:A.outcome});break}case"compaction/start":{const T=A.turn===null?k(A.time,A.seq):b(A.turn,A.time),M={kind:"compaction",id:`compaction:${A.compactionId}`,seq:A.seq,turn:T.turn,step:null,start:A.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:A.compactionId};u.set(A.compactionId,M),j(T,null,M);break}case"compaction/summary":{const T=u.get(A.compactionId);if(T===void 0)break;T.shadowedTokenCount=A.shadowedTokenCount,A.usage!==void 0&&(T.usage=A.usage),T.preview=`${A.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const T=u.get(A.compactionId);if(T===void 0)break;T.end=A.time,T.status=A.error===void 0?"ok":"error",A.error!==void 0&&(T.error=A.error,T.preview=A.error);break}}if(t!==null&&!N.has(`${t.turn}:${t.step}`)){const A=b(t.turn,((B=t.deltas[0])==null?void 0:B.time)??n.now??x),T=w(A,t.turn,t.step,((U=t.deltas[0])==null?void 0:U.time)??n.now??x),M=(D=t.deltas.find(H=>H.text!==""||H.toolName!==void 0))==null?void 0:D.time;jm(T,M);const P=uL(t.deltas),V=(F=t.deltas.at(-1))==null?void 0:F.time;V!==void 0&&(x=Math.max(x,V));const z={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:T.start,end:null,status:"running",title:(g==null?void 0:g.model)===void 0?"Assistant":`Assistant · ${g.model}`,preview:Yl(P)||"waiting for output…",content:P,live:!0,interrupted:!1,request:Db({index:E(T),provider:g==null?void 0:g.provider,model:g==null?void 0:g.model,reasoningEffort:g==null?void 0:g.reasoningEffort,toolCount:g==null?void 0:g.toolCount,ttftMs:Lb(T),retries:T.retries,lastRetryError:T.lastRetryError})};j(A,T,z)}const C=i.map(A=>({key:A.key,turn:A.turn,start:A.start,end:A.end,partialStart:A.partialStart,...A.reason===void 0?{}:{reason:A.reason},steps:A.stepOrder.map(T=>{const M=A.steps.get(T);return{turn:M.turn,step:M.step,start:M.start,end:M.end,records:M.records}}),records:A.records})),L=n.now??x;return{groups:C,records:o,totals:dL(o),span:hL(o,L)}}function Nm(e,t,n,i){return{key:e,turn:t,start:n,end:null,partialStart:i,steps:new Map,stepOrder:[],records:[]}}function lL(e,t){const n=e.origin.human,i=n?"user":"context",r=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:i,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??Yl(e.content),content:e.content,origin:e.origin,imageCount:r,fileCount:o}}function jm(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function Lb(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function cL(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function uL(e){const t=new Map;for(const n of e){const i=t.get(n.index);if(n.kind==="tool-args"){const r=(i==null?void 0:i.type)==="tool-call"?i:void 0;t.set(n.index,{type:"tool-call",callId:n.callId??(r==null?void 0:r.callId)??"",name:n.toolName??(r==null?void 0:r.name)??"",arguments:((r==null?void 0:r.arguments)??"")+n.text})}else{const r=n.kind==="text"?"text":"reasoning",o=(i==null?void 0:i.type)===r?i.text:"";t.set(n.index,{type:r,text:o+n.text})}}return[...t.entries()].sort((n,i)=>n[0]-i[0]).map(([,n])=>n)}function dL(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 i=n.kind==="assistant"?n.request.usage:n.kind==="compaction"?n.usage:void 0;n.kind==="assistant"&&(t.requests+=1),i!==void 0&&(t.inputTokens+=i.inputTokens,t.outputTokens+=i.outputTokens,t.cacheReadTokens+=i.cacheReadTokens??0,t.cacheWriteTokens+=i.cacheWriteTokens??0,t.reasoningTokens+=i.reasoningTokens??0)}return t}function hL(e,t){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;for(const r of e)n=Math.min(n,r.start),i=Math.max(i,r.end??Math.max(r.start,t));return Number.isFinite(n)?{start:n,end:Math.max(n,i)}:null}function Db(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Zw=[{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"}],fL=new Map(Zw.flatMap((e,t)=>e.kinds.map(n=>[n,t])));function mL(e){return e.records.map(t=>{const n=t.end===null||t.end<=t.start,i={record:t,lane:fL.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?{...i,firstTokenAt:t.start+t.request.ttftMs}:i})}function pL(e,t){const n=e.end??e.start;return e.start<=t.end&&n>=t.start}function gL(e,t,n,i){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,d=u+o;return d-u>=i.end-i.start?i:(u<i.start&&(d+=i.start-u,u=i.start),d>i.end&&(u-=d-i.end,d=i.end),{start:u,end:d})}function xL(e,t,n){const i=e.end-e.start,r=Math.min(Math.max(n.start,e.start+t),n.end-i);return{start:r,end:r+i}}function vL(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(i=>i.title.toLowerCase().includes(n)||i.preview.toLowerCase().includes(n)?!0:i.kind==="tool"?i.arguments.toLowerCase().includes(n):!1)}function Rs(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 kn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Kr(e){const t=new Date(e),n=(i,r=2)=>String(i).padStart(r,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(),3)}`}function qg(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}const yL=5*6e4,Ww=["周日","周一","周二","周三","周四","周五","周六"],Fb=e=>{const t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},Gg=e=>`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`;function zp(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${Ww[t.getDay()]} ${Gg(t)}:${String(t.getSeconds()).padStart(2,"0")}`}function Vw(e,t){return e===void 0?!1:t===void 0||e-t>=yL||Fb(e)!==Fb(t)}function bL(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${Ww[t.getDay()]} ${Gg(t)}`}function qw({at:e}){return s.jsxs("div",{className:"time-divider",children:[s.jsx("span",{className:"time-short",children:Gg(new Date(e))}),s.jsx("span",{className:"time-full","aria-hidden":!0,children:bL(e)})]})}const Ub="agent_delegate",Gw=y.createContext([]),Wo=y.createContext(nn.name);function Mc(e){return`#/h/${encodeURIComponent(e.id)}`}function kL(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function ta(e,t){const i=Ls(e).find(r=>r.name===t||r.id===t);return i===void 0?t===nn.name||t===nn.id?nn:void 0:Ga(i)}const Ma={running:{label:"进行中",tone:"running"},waiting:{label:"等回答",tone:"running"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function Rc({from:e,to:t,avatar:n,title:i,state:r,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(Q,{name:(n==null?void 0:n.icon)??"sparkles"})}),s.jsxs("span",{className:"exchange-who",children:[e,s.jsx(Q,{name:"arrow",className:"delegation-arrow"}),s.jsx("strong",{children:t})]}),s.jsx("span",{className:"exchange-title",title:i,children:i}),r!==void 0&&s.jsxs("span",{className:`delegation-state tone-${r.tone}`,children:[r.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),r.label]}),o!==void 0&&s.jsx(Q,{name:"chevron",className:"exchange-open"})]});return o===void 0?s.jsx("div",{className:`exchange-line tone-${(r==null?void 0:r.tone)??""}`,children:c}):s.jsx("a",{className:`exchange-line tone-${(r==null?void 0:r.tone)??""}`,href:o,title:"看它们说了什么",children:c})}function NL({client:e,item:t,handOffs:n}){const{agent:i,task:r}=y.useMemo(()=>kL(t.arguments),[t.arguments]),o=ta(e,i),c=y.useContext(Wo),u=n.find(f=>f.callId===t.callId),d=t.status==="error"||t.status==="interrupted",h=d?Ma.failed:u===void 0?t.status==="running"?Ma.running:void 0:Ma[u.state];return s.jsxs("div",{className:"delegation",children:[s.jsx(Rc,{from:c,to:(o==null?void 0:o.name)??i,avatar:o,title:(u==null?void 0:u.title)??r.split(`
197
+ `)[0]??"",state:h,href:u===void 0?void 0:Mc(u)}),d&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(Q,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function jL({client:e,handOff:t}){const n=ta(e,t.to);return s.jsx("div",{className:"delegation app-handoff",children:s.jsx(Rc,{from:t.by,to:(n==null?void 0:n.name)??t.to,avatar:n,title:t.title,state:Ma[t.state],href:Mc(t)})})}function wL({client:e,note:t,handOffs:n}){const i=ta(e,t.agent),r=y.useContext(Wo),o=n.filter(u=>u.state!=="running"&&u.title===t.title&&(u.to===(i==null?void 0:i.id)||u.to===t.agent)).at(-1),c=o!==void 0?Mc(o):i!==void 0?`#/a/${encodeURIComponent(i.id)}`:void 0;return s.jsx("div",{className:"delegation relay-line",children:s.jsx(Rc,{from:t.agent,to:r,avatar:i,title:t.title,state:t.ok?Ma.done:{label:"没有做完",tone:"failed"},href:c})})}function SL({client:e,note:t,handOffs:n}){const i=ta(e,t.from),r=y.useContext(Wo),o=n.find(c=>c.id===t.thread);return s.jsx("div",{className:"delegation task-line",children:s.jsx(Rc,{from:t.from,to:r,avatar:i,title:t.text.split(`
198
+ `)[0]??t.title,state:{label:Kw[t.kind],tone:t.kind==="question"?"asked":"ok"},href:o===void 0?void 0:Mc(o)})})}function _L({client:e,note:t,handOffs:n}){const[i,r]=y.useState(!1),o=n.filter(d=>d.by===t.by&&d.title===t.title).at(-1),c=ta(e,t.by),u=ta(e,(o==null?void 0:o.to)??"");return t.by===_g?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(Rc,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:c,title:t.title,state:Ma[o.state],href:Mc(o)})}):s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:"exchange-line",onClick:()=>r(d=>!d),"aria-expanded":i,title:i?"收起":"看交给了什么",children:[s.jsx("span",{className:`agent-avatar small agent-${(c==null?void 0:c.id)??"unknown"}`,children:s.jsx(Q,{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(Q,{name:i?"chevron-down":"chevron",className:"exchange-open"})]}),i&&s.jsx("div",{className:"exchange-msg-body task-unfolded",children:s.jsx(ti,{text:t.body})})]})}function EL({client:e,handOff:t,name:n}){const i=je(e.sessions).items.find(d=>d.id===t.toSession),r=Vg(e,i===void 0?[]:[{id:i.id,updatedAt:i.updatedAt,running:i.running}]),o=i===void 0?void 0:r.get(i.id),c=y.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:(i==null?void 0:i.running)===!0?u??`${n} 正在做…`:`排在 ${n} 手上的事后面`})]})}function CL(e,t){const n=je(e.connection.status),[i,r]=y.useState({item:null,error:null});return y.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("handoffs/get",{id:t}).then(c=>{o&&r({item:c,error:null})},c=>{o&&r({item:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),y.useEffect(()=>e.connection.on("handoffs/changed",({item:o})=>{o.id===t&&r({item:o,error:null})}),[e,t]),i}function AL(e,t){var h,f;const n=(h=t==null?void 0:t.chain)==null?void 0:h.at(-2),i=(f=t==null?void 0:t.chain)==null?void 0:f.at(-1),[r,o]=y.useState([]),[c,u]=y.useState(!1);return y.useEffect(()=>{if(t===null)return;if(n===void 0||i===void 0){u(!0);return}let g=!0;return e.connection.call("handoffs/between",{a:n,b:i}).then(p=>{g&&(o(p.items),u(!0))},()=>{g&&u(!0)}),()=>{g=!1}},[e,n,i,t===null]),y.useEffect(()=>e.connection.on("handoffs/changed",({item:g})=>{var b,k;const p=(b=g.chain)==null?void 0:b.at(-2),x=(k=g.chain)==null?void 0:k.at(-1);(p===n&&x===i||p===i&&x===n)&&o(w=>w.some(j=>j.id===g.id)?w.map(j=>j.id===g.id?g:j):[...w,g])}),[e,n,i]),t===null?{threads:[],ready:!1}:{threads:[...r.some(g=>g.id===t.id)?r:[...r,t]].sort((g,p)=>g.startedAt-p.startedAt),ready:c}}function IL(e,t,n,i){const r=[];for(const o of t){const c=n(o.by),u=n(o.to);r.push({kind:"said",key:`${o.id}:task`,thread:o.id,at:o.startedAt,who:c,body:s.jsxs(s.Fragment,{children:[s.jsx(ti,{text:o.task}),o.expecting!==void 0&&s.jsxs("div",{className:"delegation-expecting",children:["要交回:",o.expecting]})]})}),r.push({kind:"aside",key:`${o.id}:subtasks`,thread:o.id,at:o.startedAt+1,body:s.jsx(pD,{client:e,session:o.toSession,from:o.startedAt,to:o.endedAt,onOpen:i})}),(o.messages??[]).forEach((h,f)=>{h.kind!=="done"&&r.push({kind:"said",key:`${o.id}:${f}`,thread:o.id,at:h.at,who:n(h.from),kindOf:h.kind,body:s.jsx(ti,{text:h.text})})}),o.state!=="running"&&o.state!=="waiting"?r.push({kind:"said",key:`${o.id}:reply`,thread:o.id,at:o.endedAt??o.startedAt,who:u,failed:o.state==="failed",body:s.jsxs(s.Fragment,{children:[s.jsx(ti,{text:o.reply??(o.state==="failed"?"没有做完":"它没有留下回复")}),o.state==="failed"&&o.reply!==void 0&&s.jsx("div",{className:"muted small",children:"(没有做完)"})]})}):r.push({kind:"said",key:`${o.id}:now`,thread:o.id,at:Number.MAX_SAFE_INTEGER,who:u,body:o.state==="waiting"?s.jsxs("div",{className:"delegation-now",children:[s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"等回答"}),s.jsxs("span",{children:["等",c,"回答"]})]}):s.jsx(EL,{client:e,handOff:o,name:u})})}return r.map((o,c)=>[o,c]).sort(([o,c],[u,d])=>o.at-u.at||c-d).map(([o])=>o)}function TL({client:e,id:t,onClose:n}){const{item:i,error:r}=CL(e,t),[o,c]=y.useState(null),u=Ls(e),d=ta(e,(i==null?void 0:i.by)??""),h=ta(e,(i==null?void 0:i.to)??""),{threads:f,ready:g}=AL(e,i),p=mD(e,f),x=$=>{var O;return((O=u.find(W=>W.id===$))==null?void 0:O.name)??($===nn.id?nn.name:$)},b=$=>{const O=u.find(W=>W.name===$||W.id===$);return O===void 0?$===nn.name||$===nn.id?nn:void 0:Ga(O)},k=i===null?[]:IL(e,f,x,c),w=y.useRef(null),j=y.useRef(!1);if(y.useLayoutEffect(()=>{const $=w.current;if(j.current||$===null||i===null||!g)return;j.current=!0;const O=$.querySelector(`[data-thread="${CSS.escape(i.id)}"]`);$.scrollTop=O===null?$.scrollHeight:$.scrollTop+O.getBoundingClientRect().top-$.getBoundingClientRect().top-12},[i,f,g]),y.useEffect(()=>{const $=O=>{O.key==="Escape"&&o===null&&n()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n,o]),i===null)return s.jsx("section",{className:"main empty exchange-page",children:r??"正在打开…"});const E=(h==null?void 0:h.name)??i.to,N=Ma[i.state],C=[];let L;for(const $ of k){const O=$.at===Number.MAX_SAFE_INTEGER?void 0:$.at;if(O!==void 0&&Vw(O,L)&&C.push(s.jsx(qw,{at:O},`t:${$.key}`)),O!==void 0&&(L=O),$.kind==="aside"){C.push(s.jsx("div",{className:"exchange-aside","data-thread":$.thread,children:$.body},$.key));continue}const W=b($.who);C.push(s.jsxs("div",{className:`exchange-msg ${$.failed===!0?"failed":""}`,"data-thread":$.thread,title:O===void 0?void 0:zp(O),children:[s.jsxs("div",{className:"exchange-msg-head",children:[s.jsx("span",{className:`agent-avatar small agent-${(W==null?void 0:W.id)??"unknown"}`,children:s.jsx(Q,{name:(W==null?void 0:W.icon)??"sparkles"})}),s.jsx("strong",{children:$.kindOf===void 0||$.kindOf==="done"?$.who:`${$.who} · ${Kw[$.kindOf]}`})]}),s.jsx("div",{className:"exchange-msg-body",children:$.body})]},$.key))}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-${(d==null?void 0:d.id)??"unknown"}`,children:s.jsx(Q,{name:(d==null?void 0:d.icon)??"calendar"})}),s.jsx("span",{children:i.by}),s.jsx(Q,{name:"arrow",className:"delegation-arrow"}),s.jsx("span",{className:`agent-avatar small agent-${(h==null?void 0:h.id)??"unknown"}`,children:s.jsx(Q,{name:(h==null?void 0:h.icon)??"sparkles"})}),s.jsx("h1",{children:E})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx("span",{className:`delegation-state tone-${N.tone}`,children:N.label}),s.jsx("span",{children:i.title}),s.jsx("span",{children:new Date(i.startedAt).toLocaleString()})]})]})}),s.jsx("div",{className:"view",children:s.jsx(Qg.Provider,{value:c,children:s.jsxs("div",{className:`chat-split ${o===null?"":"with-pane"}`,children:[p.length>0&&s.jsx("div",{className:"chat-corner",children:s.jsx(mS,{tasks:p,labels:$L,current:o==null?void 0:o.id,onOpen:c})}),s.jsx("div",{className:"chat",ref:w,children:s.jsx("div",{className:"chat-inner",children:C})}),o!==null&&s.jsx(ex,{client:e,task:o,parent:E,trail:i.by===E?[]:[i.by],onClose:()=>c(null)},o.id)]})})}),s.jsx("footer",{className:"exchange-footer",children:s.jsxs("button",{className:"small-button",onClick:n,children:[s.jsx(Q,{name:"close"}),"关闭"]})})]})}const $L=new Map,Kw={question:"问",answer:"答",update:"说",done:"结论"};function wm({text:e,label:t="复制"}){const[n,i]=y.useState("idle"),r=y.useRef(void 0);y.useEffect(()=>()=>clearTimeout(r.current),[]);const o=async()=>{const u=await _w(e);i(u?"copied":"failed"),clearTimeout(r.current),r.current=setTimeout(()=>i("idle"),1500)},c=n==="copied"?"已复制":n==="failed"?"复制失败":t;return s.jsx("button",{type:"button",className:`msg-action ${n==="idle"?"":n}`,title:c,"aria-label":c,onClick:()=>void o(),children:s.jsx(Q,{name:n==="copied"?"check":"copy"})})}const ML=3,RL=/^(编排|游戏信息|干预)[::]/,Bb="adg:skill-offer:off",Hb=e=>`adg:skill-offer:${e}`;function Zb(e){try{return localStorage.getItem(e)}catch{return null}}function Wb(e,t){try{localStorage.setItem(e,t)}catch{}}function OL(e){var r;let t=e.length-1;for(;t>=0&&e[t].kind!=="user";)t--;if(t<0)return;const n=e.slice(t+1),i=n.filter(o=>o.kind==="tool");if(!i.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")&&!(i.length<ML||((r=n.at(-1))==null?void 0:r.kind)!=="assistant"))return e[t].id}function PL({session:e,title:t,items:n}){const i=OL(n),[r,o]=y.useState(()=>Zb(Bb)==="1"),[c,u]=y.useState(()=>Zb(Hb(e.id))),[d,h]=y.useState(!1);if(i===void 0||r||c===i||t!==null&&RL.test(t))return null;const f=()=>{Wb(Hb(e.id),i),u(i)},g=async()=>{h(!0);try{await e.prompt(Uj),f()}finally{h(!1)}};return s.jsxs("div",{className:"skill-offer",role:"region","aria-label":"存成技能",children:[s.jsx(Q,{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:()=>{Wb(Bb,"1"),o(!0)},children:"不再提示"}),s.jsx("button",{className:"small-button",disabled:d,onClick:f,children:"这次不用"}),s.jsx("button",{className:"small-button primary",disabled:d,onClick:()=>void g(),children:"存成技能"})]})]})}function zL(e,t){const n=je(e.connection.status),i=je(e.capabilities),[r,o]=y.useState(null),c=t&&i.has("notify");return y.useEffect(()=>{if(!c||n.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(d=>{u&&o(d.items)},()=>{u&&o(d=>d??[])}),()=>{u=!1}},[e,c,n.state]),y.useEffect(()=>{if(c)return e.connection.on("notify/notice",({item:u})=>o(d=>d===null?d:d.findIndex(f=>f.id===u.id)<0?[...d,u]:d.map(f=>f.id===u.id?u:f)))},[e,c]),c?r:LL}const LL=[];function DL(e,t,n,i){const r=t.filter(h=>h.at>=n);if(r.length===0)return[...e];const o=new Array(e.length);let c=1/0;for(let h=e.length-1;h>=0;h--){const f=e[h];"time"in f&&typeof f.time=="number"&&(c=f.time),o[h]=c}const u=[];let d=0;for(e.forEach((h,f)=>{if(i(h))for(;d<r.length&&r[d].at<o[f];)u.push(Vb(r[d++]));u.push(h)});d<r.length;)u.push(Vb(r[d++]));return u}function Vb(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const FL={info:"send",success:"check",warning:"alert",error:"alert"};function UL({client:e,notice:t}){const[n,i]=y.useState(null),[r,o]=y.useState(null),c=t.acted===void 0&&t.done===void 0&&t.actions.length>0,u=h=>{i(h),o(null),e.connection.call("notify/act",{noticeId:t.id,actionId:h}).catch(f=>o(Ie(f))).finally(()=>i(null))},d=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(Q,{name:FL[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("、")}`:"只在软件里"," · ",d]})]}),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(h=>s.jsx("button",{className:`small-button ${h.style==="primary"?"primary":h.style==="danger"?"danger-outline":""}`,disabled:n!==null,onClick:()=>u(h.id),children:n===h.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),h.label]}):h.label},h.id)),s.jsx("span",{className:"muted small",children:"也可以直接跟助手说"})]}),t.acted!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(Q,{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(Q,{name:"check"}),t.done]}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}const BL=80,HL=[];function Yw({client:e,session:t,state:n,readOnly:i}){var te,ne,se;const r=y.useMemo(()=>Vd(n.events,n.live,n.pending),[n.events,n.live,n.pending,n.version]),o=y.useMemo(()=>r.filter(oe=>!oS(oe)),[r]),c=y.useMemo(()=>iS(n.events),[n.events]),u=y.useMemo(()=>aS(r,c),[r,c]),d=y.useMemo(()=>dS(r,c),[r,c]),h=hS(e,t.id),f=Ls(e),g=je(e.sessions).items.find(oe=>oe.id===t.id),p=g===void 0?On:La(g,f),x=Pw(e,On),b=zL(e,g!==void 0?g.home===On:x.sessionId===t.id),[k,w]=y.useState(!1),j=k||(n.status==="open"?b!==null:n.status!=="opening");j&&!k&&w(!0);const E=j&&b!==null?b:HL,N=n.hasMore?((te=n.events[0])==null?void 0:te.time)??0:0,C=y.useMemo(()=>GL(DL(o,E,N,Qw)),[o,E,N]),L=y.useContext(Xg),$=y.useContext(Wo),O=L!==null?$:((ne=f.find(oe=>oe.id===p))==null?void 0:ne.name)??nn.name,[W,B]=dD((g==null?void 0:g.role)??On),U=L===null?W:3,D=y.useMemo(()=>qL(C,U),[C,U]),F=y.useMemo(()=>{let oe;return D.map(de=>{const we=WL(de),Se=Vw(we,oe)?we:void 0;return we!==void 0&&(oe=we),Se})},[D]),[A,T]=y.useState(null),M=y.useContext(Pp),P=j&&L===null&&M===null?s.jsx(mS,{tasks:h,labels:d,current:A==null?void 0:A.id,onOpen:T}):null,V=j&&L===null&&C.some(oe=>Xw(oe)>1),z=yz(e,t.id),H=z.filter(oe=>oe.fromSession===t.id&&oe.callId===void 0&&(oe.state==="running"||oe.state==="waiting")),G=y.useRef(null),Z=Hw(BL),Y=Z.following,X=oe=>{Z.onScroll(oe),oe.currentTarget.scrollTop<40&&n.hasMore&&!n.loadingOlder&&t.loadOlder()};y.useLayoutEffect(()=>{const oe=G.current;oe!==null&&Y.current&&(oe.scrollTop=oe.scrollHeight)},[o,E,j]),iL(G,Y);const re=(se=n.events[0])==null?void 0:se.seq,ee=y.useRef(0);return y.useLayoutEffect(()=>{const oe=G.current;oe!==null&&(ee.current!==0&&!Y.current&&(oe.scrollTop+=oe.scrollHeight-ee.current),ee.current=oe.scrollHeight)},[re]),s.jsx(Qd.Provider,{value:e,children:s.jsx(Gw.Provider,{value:z,children:s.jsx(Wo.Provider,{value:O,children:s.jsx(Qg.Provider,{value:(M==null?void 0:M.openTask)??T,children:s.jsx(Yg.Provider,{value:u,children:s.jsx(rS.Provider,{value:c,children:s.jsxs("div",{className:`chat-split ${A===null?"":"with-pane"}`,children:[(V||P!==null)&&s.jsxs("div",{className:"chat-corner",children:[P,V&&s.jsx(fD,{detail:W,onChange:B})]}),s.jsx("div",{className:"chat",ref:G,onScroll:X,onWheel:Z.onWheel,children:s.jsxs("div",{className:"chat-inner",children:[j&&n.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:n.loadingOlder,onClick:()=>void t.loadOlder(),children:n.loadingOlder?"加载中…":"加载更早的消息"}),!j&&s.jsx("div",{className:"empty",children:"正在打开会话…"}),j&&n.status!=="opening"&&o.length===0&&s.jsxs("div",{className:"empty chat-empty",children:[s.jsx($g,{size:"lg"}),s.jsx("h2",{children:"今天,先从哪个游戏开始?"}),s.jsxs("p",{children:["问问哪些活动快结束、新版本有什么,或者让它把今天的日常清掉。",s.jsx("br",{}),"在下方写下来就行。"]})]}),j&&D.map((oe,de)=>s.jsx(VL,{at:F[de],children:oe.kind==="sent"?s.jsx(UL,{client:e,notice:oe.item.notice},oe.item.id):oe.kind==="tools"?s.jsx(Ll,{name:O,header:oe.header,children:s.jsx(eS,{tools:oe.tools})},oe.id):oe.kind==="delegation"?s.jsx(Ll,{name:O,header:oe.header,children:s.jsx(NL,{client:e,item:oe.item,handOffs:z})},oe.item.id):oe.kind==="subtask"?s.jsx(Ll,{name:O,header:oe.header,children:s.jsx(cD,{client:e,item:oe.item})},oe.item.id):oe.kind==="process"?s.jsx(Ll,{name:O,header:oe.header,children:s.jsx(eD,{items:oe.items,active:n.running&&de===D.length-1,onDismiss:we=>t.dismissPending(we)})},oe.id):s.jsx(Ll,{name:O,header:oe.header,children:s.jsx(Jw,{item:oe.item,onDismiss:we=>t.dismissPending(we)})},oe.item.id)},ZL(oe))),j&&H.map(oe=>s.jsx(jL,{client:e,handOff:oe},oe.id)),j&&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",{})]}),"正在处理…"]}),j&&i!==!0&&!n.running&&n.queue.length===0&&s.jsx(PL,{session:t,title:n.title,items:o})]})}),A!==null&&M===null&&s.jsx(ex,{client:e,task:A,parent:O,trail:p===On?[]:[nn.name],onClose:()=>T(null)},A.id)]})})})})})})})}function ZL(e){return e.kind==="sent"?e.item.id:e.kind==="tools"||e.kind==="process"?e.id:e.item.id}function WL(e){var n;const t=i=>"time"in i?i.time:void 0;switch(e.kind){case"sent":return e.item.notice.at;case"tools":return(n=e.tools[0])==null?void 0:n.time;case"process":return e.items.map(t).find(i=>i!==void 0);default:return t(e.item)}}function VL({at:e,children:t}){return s.jsxs(s.Fragment,{children:[e!==void 0&&s.jsx(qw,{at:e}),t]})}function Xw(e){switch(e.kind){case"subtask":return 3;case"delegation":case"process":return 2;case"tools":return e.tools.some(t=>t.approval==="asked")?1:2;case"sent":return 1;case"item":{if(e.item.kind!=="user"||e.item.pending!==void 0)return 1;const t=Cj(e.item.text);return Ij(e.item.text)!==void 0||Aj(e.item.text)!==void 0||t!==void 0&&t.by!==_g?2:1}}}function qL(e,t){if(t>1)return e;const n=[];let i=null;for(const r of e)r.kind==="sent"?n.push(r):Xw(r)>1?i=r.header??i:r.kind==="item"&&r.item.kind==="user"?(i=null,n.push(r)):i!==null&&r.header===null&&!(r.kind==="item"&&(r.item.kind==="notice"||r.item.kind==="context"))?(n.push({...r,header:i}),i=null):n.push(r);return n}function GL(e){const t=[];let n=0;for(let i=0;i<=e.length;i++){const r=e[i];r!==void 0&&r.kind!=="sent"&&!Qw(r)||(KL(e.slice(n,i),t),r!==void 0&&t.push(r.kind==="sent"?{kind:"sent",item:r}:{kind:"item",item:r,header:null}),n=i+1)}return t}function Qw(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function KL(e,t){let n=!1;const i=e.find(h=>h.kind==="assistant"&&h.model!==void 0),r=()=>n?null:(n=!0,{model:(i==null?void 0:i.kind)==="assistant"?i.model:void 0}),o=h=>{if(h.kind==="tool"&&h.name===Ub)t.push({kind:"delegation",item:h,header:r()});else if(h.kind==="tool"&&h.name===Lp)t.push({kind:"subtask",item:h,header:r()});else if(h.kind==="tool"){const f=t.at(-1);(f==null?void 0:f.kind)==="tools"?t[t.length-1]={...f,tools:[...f.tools,h]}:t.push({kind:"tools",id:`tools-${h.id}`,tools:[h],header:r()})}else t.push({kind:"item",item:h,header:h.kind==="assistant"?r():null})};let c=[];const u=()=>{if(c.some(h=>h.kind==="tool"))t.push({kind:"process",id:`process-${c[0].id}`,items:c,header:r()});else for(const h of c)o(h);c=[]};let d=e.length;for(let h=e.length-1;h>=0;h--){const f=e[h];if(f.kind==="assistant"&&f.text.trim()!==""){d=h;break}}for(let h=0;h<d;h++){const f=e[h];f.kind==="notice"||f.kind==="context"||f.kind==="tool"&&(f.approval==="asked"||f.name===Ub||f.name===Lp)?(u(),o(f)):c.push(f)}u();for(let h=d;h<e.length;h++)o(e[h])}function Ll({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($g,{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 YL({text:e}){const t=NO(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 XL=/^(这条消息来自([^。)]+)。[^\n]*)\n/,QL=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function JL(e){const t=XL.exec(e),n=(t===null?e:e.slice(t[0].length)).replace(QL,"");return t===null?{text:n}:{text:n,channel:t[1]}}const Jw=y.memo(function({item:t,onDismiss:n}){var c;const i=y.useContext(Qd),r=y.useContext(Gw),o=y.useContext(Xg);switch(t.kind){case"user":{if(o!==null)return s.jsxs("div",{className:"msg user delegated",children:[s.jsxs("div",{className:"msg-from",children:[o,"交给的事"]}),s.jsx("div",{className:"bubble",children:s.jsx(ti,{text:pc(t.text)})}),s.jsx("div",{className:"msg-actions",children:s.jsx(wm,{text:pc(t.text)})})]});const u=t.pending===void 0?Ij(t.text):void 0;if(u!==void 0&&i!==null)return s.jsx(wL,{client:i,note:u,handOffs:r});const d=t.pending===void 0?Aj(t.text):void 0;if(d!==void 0&&i!==null)return s.jsx(SL,{client:i,note:d,handOffs:r});const h=t.pending===void 0?Cj(t.text):void 0;if(h!==void 0&&i!==null)return s.jsx(_L,{client:i,note:h,handOffs:r});const f=JL(t.text);return s.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,title:zp(t.time),children:[f.channel!==void 0&&s.jsxs("div",{className:"msg-from",children:["来自",f.channel]}),s.jsxs("div",{className:"bubble",children:[s.jsx(YL,{text:f.text}),t.imageRefs.length>0&&s.jsx("div",{className:"chat-images",children:t.imageRefs.map(g=>s.jsx(fw,{image:g},g.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(Q,{name:"image"}),t.images-t.imageRefs.length," 张图片"]}),t.files>0&&s.jsxs("span",{children:[s.jsx(Q,{name:"paperclip"}),t.files," 个文件"]})]})]}),((c=t.pending)==null?void 0:c.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:"移除"})]}),f.text.trim()!==""&&s.jsx("div",{className:"msg-actions",children:s.jsx(wm,{text:f.text})})]})}case"assistant":return!t.live&&OR(t.text)?s.jsxs("div",{className:"quiet-reply",children:[s.jsx(Q,{name:"check"}),"看过了,没有要告诉你的"]}):s.jsxs("div",{className:`msg assistant ${t.live?"live":""}`,title:t.live?void 0:zp(t.time),children:[t.reasoning.trim()!==""&&s.jsxs("details",{className:"reasoning",open:t.live&&t.text==="",children:[s.jsxs("summary",{children:[s.jsx(Q,{name:"chevron"}),t.live&&t.text===""?s.jsx("span",{className:"shimmer",children:"正在思考…"}):"思考过程"]}),s.jsx(ti,{text:t.reasoning})]}),t.text!==""&&s.jsx(ti,{text:t.text}),t.live&&s.jsx("span",{className:"cursor"}),t.interrupted&&s.jsx("div",{className:"muted small",children:"(已中断)"}),!t.live&&t.text.trim()!==""&&s.jsx("div",{className:"msg-actions",children:s.jsx(wm,{text:t.text})})]});case"tool":return s.jsx(eS,{tools:[t]});case"context":return s.jsxs("details",{className:"context-row",children:[s.jsxs("summary",{children:[s.jsx(Q,{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(Q,{name:"alert"}),t.text]})}});function eD({items:e,active:t,onDismiss:n}){const i=e.filter(h=>h.kind==="tool"),r=i.filter(h=>h.status==="running").length,o=i.filter(h=>h.status==="error").length,[c,u]=y.useState(!1),d=t&&!c?tD(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(Q,{name:"terminal"}),s.jsx("span",{className:"tool-group-title",children:`执行了 ${i.length} 个步骤`}),d!==void 0&&d!==""&&s.jsx("span",{className:"process-now",children:d}),s.jsxs("span",{className:"tool-group-meta",children:[r>0&&s.jsxs("span",{className:"tone-running",children:[r," 个进行中"]}),o>0&&s.jsxs("span",{className:"tone-failed",children:[o," 个失败"]})]}),s.jsx(Q,{name:"chevron-down",className:`chevron-icon ${c?"open":""}`})]}),c&&e.map(h=>h.kind==="tool"?s.jsx(nS,{item:h},h.id):s.jsx("div",{className:"process-note",children:s.jsx(Jw,{item:h,onDismiss:n})},h.id))]})}function tD(e){return e.kind==="tool"?`${e.name} ${Ag(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
199
+ `)[0]||"正在思考…":""}function eS({tools:e}){const t=e.filter(c=>c.status==="running").length,n=e.filter(c=>c.status==="error").length,[i,r]=y.useState(null),o=i??(t>0||n>0||e.length<=4);return s.jsxs("div",{className:"tool-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>r(!o),"aria-expanded":o,children:[s.jsx(Q,{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(Q,{name:"chevron-down",className:`chevron-icon ${o?"open":""}`})]}),o&&e.map(c=>s.jsx(nS,{item:c},c.id))]})}const tS={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function nS({item:e}){const[t,n]=y.useState(!1),i=y.useMemo(()=>Ag(e.arguments),[e.arguments]);return y.useEffect(()=>{e.status==="error"&&n(!0)},[e.status]),s.jsxs("div",{className:`tool ${e.status}`,children:[s.jsxs("button",{className:"tool-head",onClick:()=>n(r=>!r),"aria-expanded":t,children:[s.jsx(nD,{status:e.status}),s.jsx("span",{className:"tool-name",children:e.name}),s.jsx("span",{className:"tool-summary",children:i}),e.approval!==void 0&&s.jsx("span",{className:`badge approval-${e.approval}`,children:sD(e.approval)}),s.jsx("span",{className:"tool-status",children:tS[e.status]})]}),e.images!==void 0&&s.jsx("div",{className:"chat-images tool-images",children:e.images.map(r=>s.jsx(fw,{image:r},r.attachmentId))}),t&&s.jsxs("div",{className:"tool-body",children:[s.jsx("div",{className:"label",children:"参数"}),s.jsx("pre",{children:qg(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 nD({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(Q,{name:"check"})}):e==="error"?s.jsx("span",{className:"tool-icon error",role:"img","aria-label":"失败",children:s.jsx(Q,{name:"close"})}):s.jsx("span",{className:"tool-icon",role:"img","aria-label":tS[e]??e,children:s.jsx(Q,{name:"info"})})}function sD(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const Lp="subagent",sS=/started subagent (\S+)/;function iS(e){const t=new Map;for(const n of e){if(n.type!=="unknown"||n.upstreamType!=="subagent/catalog")continue;const i=n.data;typeof(i==null?void 0:i.childId)=="string"&&typeof i.name=="string"&&t.set(i.name,i.childId)}return t}const rS=y.createContext(new Map),Kg=(e,t)=>e===void 0?void 0:t.get(e)??e,iD=/\s*Your (?:parent agent\b|final answe)[\s\S]*$/;function pc(e){return e.replace(iD,"")}const rD=/^Background subagent (\S+) (finished|was stopped)?/;function aS(e,t){const n=new Map;for(const i of e){if(!oS(i))continue;const r=rD.exec(i.summary);r!==null&&n.set(Kg(r[1],t),r[2]==="finished"?gc:r[2]==="was stopped"?aD:uS)}return n}function oS(e){return e.kind==="context"&&e.title==="subagent-settled"}const Yg=y.createContext(new Map),Xg=y.createContext(null),Qg=y.createContext(()=>{});function lS(e){try{const t=JSON.parse(e);return{description:String(t.description??""),prompt:String(t.prompt??"")}}catch{return{description:"",prompt:e}}}function cS(e,t){return je(e.sessions).items.find(n=>n.id===t)}const Jg={label:"进行中",tone:"running"},gc={label:"完成",tone:"ok"},aD={label:"已停止",tone:"failed"},uS={label:"没做成",tone:"failed"};function oD({client:e,id:t,running:n}){const i=qd(e,t);return i===null?s.jsx("div",{className:"subtask-steps muted small",children:"正在打开…"}):s.jsx(lD,{handle:i,running:n})}function lD({handle:e,running:t}){const n=je(e.state),i=y.useMemo(()=>Vd(n.events,n.live,n.pending).filter(o=>o.kind==="tool"),[n.events,n.live,n.pending,n.version]);if(i.length===0)return s.jsx("div",{className:"subtask-steps muted small",children:t?"正在开始…":"没有用工具"});const r=t?i.slice(-4):i;return s.jsx("ol",{className:"subtask-steps",children:r.map(o=>s.jsxs("li",{className:o.status==="error"?"failed":"",children:[o.status==="running"?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(Q,{name:o.status==="error"?"alert":"check"}),s.jsx("span",{className:"subtask-step-name",children:o.name}),s.jsx("span",{className:"subtask-step-args",children:Ag(o.arguments)})]},o.id))})}function cD({client:e,item:t}){var E;const n=y.useContext(Qg),{description:i,prompt:r}=y.useMemo(()=>lS(t.arguments),[t.arguments]),o=Kg((E=sS.exec(t.result??""))==null?void 0:E[1],y.useContext(rS)),c=cS(e,o),u=t.status==="error"||t.status==="interrupted",d=!u&&((c==null?void 0:c.running)??t.status==="running"),h=y.useContext(Yg),f=u?uS:d?Jg:(o===void 0?void 0:h.get(o))??gc,g=Vg(e,c===void 0?[]:[{id:c.id,updatedAt:c.updatedAt,running:c.running}]),p=o===void 0?void 0:g.get(o),[x,b]=y.useState(!1),k=i!==""?i:r.split(`
200
+ `)[0]??"子任务",w=s.jsxs("span",{className:`delegation-state tone-${f.tone}`,children:[f.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),f.label]}),j=o!==void 0&&(d||x);return s.jsxs("div",{className:`subtask tone-${f.tone}`,children:[s.jsxs("div",{className:"subtask-head",children:[s.jsx(Q,{name:"flow"}),s.jsx("strong",{className:"subtask-label",title:r,children:k}),w,o!==void 0&&s.jsx("button",{className:"link-button subtask-open",onClick:()=>n({id:o,label:k}),children:"看完整过程"})]}),u&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(Q,{name:"alert"}),t.result??t.error??"没有开起来"]}),j&&s.jsx(oD,{client:e,id:o,running:d}),!d&&p!=null&&p!==""&&s.jsx("div",{className:"subtask-answer",children:s.jsx(ti,{text:p})}),!d&&o!==void 0&&s.jsxs("button",{className:"link-button subtask-fold","aria-expanded":x,onClick:()=>b(N=>!N),children:[s.jsx(Q,{name:x?"chevron-down":"chevron"}),x?"收起步骤":"看步骤"]})]})}function ex({client:e,task:t,parent:n,trail:i,onClose:r}){const o=qd(e,t.id),c=cS(e,t.id),[u,d]=y.useState(null),h=(c==null?void 0:c.running)===!0,f=()=>e.connection.call("subagents/stop",{sessionId:t.id}).then(()=>d(null),g=>d(g instanceof Error?g.message:String(g)));return s.jsxs("aside",{className:"subagent-pane","aria-label":`子任务:${t.label}`,children:[s.jsxs("header",{className:"subagent-pane-head",children:[s.jsxs("div",{className:"subagent-trail",children:[[...i,n].map((g,p)=>s.jsxs("span",{children:[g,s.jsx("span",{className:"subagent-trail-sep",children:"›"})]},p)),s.jsx("strong",{title:t.label,children:t.label})]}),h&&s.jsxs("button",{className:"small-button",onClick:()=>void f(),children:[s.jsx(Q,{name:"close"}),"停止"]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:"关闭",onClick:r,children:s.jsx(Q,{name:"close"})})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx("div",{className:"subagent-pane-body",children:o===null?s.jsx("div",{className:"empty",children:"正在打开…"}):s.jsx(uD,{client:e,handle:o,parent:n})})]})}function uD({client:e,handle:t,parent:n}){const i=je(t.state);return s.jsx(Xg.Provider,{value:n,children:s.jsx(Wo.Provider,{value:`${n}的子 agent`,children:s.jsx(Yw,{client:e,session:t,state:i,readOnly:!0})})})}const qb="adg.chatDetail.";function dD(e){const t=()=>{try{return Number(localStorage.getItem(qb+e))===1?1:3}catch{return 3}},[n,i]=y.useState(()=>({agentId:e,detail:t()}));return[n.agentId===e?n.detail:t(),o=>{i({agentId:e,detail:o});try{localStorage.setItem(qb+e,String(o))}catch{}}]}const hD=[{level:1,label:"汇报",hint:"只看它和你说的话"},{level:3,label:"全部",hint:"加上 agent 之间的往来和子任务的步骤、答案"}];function fD({detail:e,onChange:t}){return s.jsx("div",{className:"chat-detail segmented-control",role:"radiogroup","aria-label":"显示多少",children:hD.map(n=>s.jsx("button",{role:"radio","aria-checked":e===n.level,className:e===n.level?"active":"",title:n.hint,onClick:()=>t(n.level),children:n.label},n.level))})}function dS(e,t){var i;const n=new Map;for(const r of e){if(r.kind!=="tool"||r.name!==Lp)continue;const o=Kg((i=sS.exec(r.result??""))==null?void 0:i[1],t);if(o===void 0)continue;const{description:c,prompt:u}=lS(r.arguments),d=c!==""?c:u.split(`
201
+ `)[0]??"";d!==""&&n.set(o,d)}return n}function hS(e,t){const n=je(e.sessions).items;return y.useMemo(()=>n.filter(i=>i.origin==="subagent"&&i.parentId===t),[n,t])}function fS(e,t,n,i){return e.origin==="subagent"&&e.parentId===t&&e.updatedAt>=n&&(i===void 0||e.updatedAt<=i+2e3)}function mD(e,t){const n=je(e.sessions).items;return y.useMemo(()=>n.filter(i=>t.some(r=>fS(i,r.toSession,r.startedAt,r.endedAt))),[n,t])}const Sm=30;function mS({tasks:e,labels:t,current:n,onOpen:i}){const r=y.useContext(Yg),[o,c]=y.useState(!1),u=y.useRef(null),d=un(6e4);y.useEffect(()=>{if(!o)return;const k=j=>{var E;(E=u.current)!=null&&E.contains(j.target)||c(!1)},w=j=>{j.key==="Escape"&&c(!1)};return document.addEventListener("pointerdown",k),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",w)}},[o]);const h=[...e].sort((k,w)=>w.updatedAt-k.updatedAt),f=h.filter(k=>k.running),g=h.filter(k=>!k.running);if(e.length===0)return null;const p=k=>t.get(k.id)??(pc(k.title??"")||"子任务"),x=k=>{const w=k.running?Jg:r.get(k.id)??gc,j=p(k);return s.jsx("li",{children:s.jsxs("button",{className:`subtask-tracker-row ${k.id===n?"active":""}`,title:j,onClick:()=>{c(!1),i({id:k.id,label:j})},children:[k.running?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(Q,{name:w===gc?"check":"alert",className:`tone-${w.tone}`}),s.jsx("span",{className:"subtask-tracker-label",children:j}),s.jsx("span",{className:`delegation-state tone-${w.tone}`,children:k.running?w.label:`${w.label} · ${yt(k.updatedAt,d)}`}),s.jsx(Q,{name:"chevron",className:"exchange-open"})]})},k.id)},b=f.length>0?`${f.length} 个子任务在跑`:"子任务";return s.jsxs("div",{ref:u,className:"subtask-tracker",children:[s.jsxs("button",{type:"button",className:`subtask-tracker-toggle ${f.length>0?"tone-running":""}`,"aria-haspopup":"dialog","aria-expanded":o,title:`进行中 ${f.length} 个,已结束 ${g.length} 个;点开看每一个的窗口`,onClick:()=>c(k=>!k),children:[f.length>0?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(Q,{name:"flow"}),s.jsx("span",{children:b}),g.length>0&&s.jsxs("span",{className:"subtask-tracker-ended",children:["已结束 ",g.length]}),s.jsx(Q,{name:"chevron-down",className:"subtask-tracker-chevron"})]}),o&&s.jsxs("div",{className:"subtask-tracker-panel",role:"dialog","aria-label":"子任务",children:[s.jsxs("section",{children:[s.jsxs("div",{className:"subtask-tracker-head",children:["进行中",s.jsx("span",{className:"skills-count",children:f.length})]}),f.length===0?s.jsx("p",{className:"muted small subtask-tracker-empty",children:"现在没有在跑的子任务"}):s.jsx("ul",{children:f.map(x)})]}),g.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"subtask-tracker-head",children:["已结束",s.jsx("span",{className:"skills-count",children:g.length})]}),s.jsx("ul",{children:g.slice(0,Sm).map(x)}),g.length>Sm&&s.jsxs("p",{className:"muted small subtask-tracker-empty",children:["更早的 ",g.length-Sm," 个在对话里"]})]})]})]})}function pD({client:e,session:t,from:n,to:i,onOpen:r}){const o=je(e.sessions).items.filter(c=>fS(c,t,n,i));return o.length===0?null:s.jsx("div",{className:"delegation thread-subtasks",children:o.map(c=>{const u=pc(c.title??"")||"子任务",d=c.running?Jg:gc;return s.jsxs("button",{className:`exchange-line subtask-line tone-${d.tone}`,onClick:()=>r({id:c.id,label:u}),children:[s.jsx(Q,{name:"flow"}),s.jsx("span",{className:"exchange-who",children:"子任务"}),s.jsx("span",{className:"exchange-title",children:u}),s.jsxs("span",{className:`delegation-state tone-${d.tone}`,children:[d.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),d.label]}),s.jsx(Q,{name:"chevron",className:"exchange-open"})]},c.id)})})}const pS=[{id:"tasks",icon:"list",title:"子任务",hint:"子任务:正在做和做完的,点开看每一个的对话"},{id:"commands",icon:"terminal",title:"命令",hint:"命令:这个对话和它的子任务运行的命令和程序"},{id:"browser",icon:"globe",title:"浏览器",hint:"内置浏览器:看 agent 操作网页,也可以自己接手"}];function Gb({title:e,actions:t,onClose:n,children:i}){return s.jsxs("aside",{className:"side-panel","aria-label":e,children:[s.jsxs("header",{className:"side-panel-head",children:[s.jsx("h2",{children:e}),t,s.jsx("button",{type:"button",className:"icon-button",title:"关闭侧栏","aria-label":"关闭侧栏",onClick:n,children:s.jsx(Q,{name:"close"})})]}),s.jsx("div",{className:"side-panel-body",children:i})]})}const gD={label:"进行中",tone:"running"},Kb={label:"完成",tone:"ok"};function gS(e,t){return t.get(e.id)??(pc(e.title??"")||"子任务")}function xD({tasks:e,labels:t,settled:n,onOpen:i}){const r=un(6e4),o=[...e].sort((h,f)=>f.updatedAt-h.updatedAt),c=o.filter(h=>h.running),u=o.filter(h=>!h.running),d=h=>{const f=h.running?gD:n.get(h.id)??Kb,g=gS(h,t);return s.jsx("li",{children:s.jsxs("button",{className:"subtask-tracker-row",title:g,onClick:()=>i({id:h.id,label:g}),children:[h.running?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(Q,{name:f===Kb?"check":"alert",className:`tone-${f.tone}`}),s.jsx("span",{className:"subtask-tracker-label",children:g}),s.jsx("span",{className:`delegation-state tone-${f.tone}`,children:h.running?f.label:`${f.label} · ${yt(h.updatedAt,r)}`}),s.jsx(Q,{name:"chevron",className:"exchange-open"})]})},h.id)};return e.length===0?s.jsxs("div",{className:"side-empty",children:["这个对话还没有开过子任务。",s.jsx("br",{}),"agent 把具体的活交给子 agent 时,会列在这里。"]}):s.jsxs("div",{className:"side-list",children:[s.jsxs("section",{children:[s.jsxs("div",{className:"subtask-tracker-head",children:["进行中",s.jsx("span",{className:"skills-count",children:c.length})]}),c.length===0?s.jsx("p",{className:"muted small subtask-tracker-empty",children:"现在没有在跑的子任务"}):s.jsx("ul",{children:c.map(d)})]}),u.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"subtask-tracker-head",children:["已结束",s.jsx("span",{className:"skills-count",children:u.length})]}),s.jsx("ul",{children:u.map(d)})]})]})}const vD=new Set(["pwsh","bash","run_code"]);function yD(e){let t={};try{t=JSON.parse(e.arguments)}catch{}const n=e.name==="run_code";return{text:typeof(n?t.code:t.command)=="string"?String(n?t.code:t.command):"",description:typeof t.description=="string"?t.description:"",program:n}}function xS(e){return e.filter(t=>t.kind==="tool"&&vD.has(t.name))}function bD({client:e,own:t,tasks:n,labels:i}){const r=y.useMemo(()=>[...n].sort((o,c)=>Number(c.running)-Number(o.running)||c.updatedAt-o.updatedAt).slice(0,_m),[n]);return s.jsxs("div",{className:"side-list commands",children:[r.map(o=>s.jsx(kD,{client:e,task:o,label:gS(o,i)},o.id)),s.jsx(tx,{title:"这个对话",running:!1,commands:t,empty:"这个对话自己没有运行命令(命令多由子任务运行)"}),n.length>_m&&s.jsxs("p",{className:"muted small side-note",children:["更早的 ",n.length-_m," 个子任务的命令在它们的对话里(子任务面板)"]})]})}const _m=8;function kD({client:e,task:t,label:n}){const i=qd(e,t.id);return i===null?s.jsx(tx,{title:n,running:t.running,commands:[],empty:"正在打开…"}):s.jsx(ND,{handle:i,label:n,running:t.running})}function ND({handle:e,label:t,running:n}){const i=je(e.state),r=y.useMemo(()=>xS(Vd(i.events,i.live,i.pending)),[i.events,i.live,i.pending,i.version]);return r.length===0&&!n?null:s.jsx(tx,{title:t,running:n,commands:r,empty:"还没有运行命令"})}function tx({title:e,running:t,commands:n,empty:i}){const[r,o]=y.useState(null),c=r??(t||n.some(u=>u.status==="running")||e==="这个对话");return s.jsxs("section",{className:"command-group",children:[s.jsxs("button",{type:"button",className:"command-group-head","aria-expanded":c,onClick:()=>o(!c),children:[s.jsx(Q,{name:c?"chevron-down":"chevron"}),s.jsx("span",{className:"command-group-title",title:e,children:e}),t&&s.jsx("span",{className:"tool-spinner","aria-label":"进行中"}),s.jsx("span",{className:"skills-count",children:n.length})]}),c&&(n.length===0?s.jsx("p",{className:"muted small side-note",children:i}):s.jsx("ol",{className:"command-list",children:n.map(u=>s.jsx(jD,{item:u},u.id))}))]})}function jD({item:e}){const{text:t,description:n,program:i}=yD(e),[r,o]=y.useState(e.status==="error"),c=un(e.status==="running"?1e3:6e4),u=(e.result??e.error??"").trimEnd();return s.jsxs("li",{className:`command-row status-${e.status}`,children:[s.jsxs("div",{className:"command-row-head",children:[e.status==="running"?s.jsx("span",{className:"tool-spinner","aria-hidden":!0}):s.jsx(Q,{name:e.status==="error"?"alert":"check"}),s.jsx("span",{className:"command-desc",children:n!==""?n:i?"运行程序":"运行命令"}),s.jsx("span",{className:"command-time",children:e.status==="running"?`运行中 ${Math.max(0,Math.round((c-e.time)/1e3))} 秒`:yt(e.time,c)})]}),s.jsxs("pre",{className:"command-text",children:[s.jsx("span",{className:"command-prompt",children:i?"ts":e.name==="bash"?"$":"PS>"}),t]}),u!==""&&s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"link-button command-output-toggle",onClick:()=>o(!r),children:r?"收起输出":"看输出"}),r&&s.jsx("pre",{className:"command-output",children:u.length>Yb?`…
202
+ ${u.slice(-Yb)}`:u})]})]})}const Yb=6e3;function Dp({client:e,sessionId:t,reminder:n,initialPrompt:i,onInitialSent:r,onAgent:o}){const c=qd(e,t);return c===null?s.jsx("div",{className:"main empty",children:"正在打开会话…"}):s.jsx(SD,{client:e,session:c,reminder:n,initialPrompt:i,onInitialSent:r,onAgent:o})}function wD(e,t){const[n,i]=y.useState(!1);return t&&!n&&i(!0),e!==void 0&&e.home===void 0&&e.blank!==!0&&!t&&!n}function SD({client:e,session:t,reminder:n,initialPrompt:i,onInitialSent:r,onAgent:o}){const c=je(t.state),u=je(e.connection.status),d=Ls(e),h=je(e.sessions).items.find(T=>T.id===t.id),f=h===void 0?On:La(h,d),g=d.find(T=>T.id===f),p=g===void 0?nn:Ga(g),x=(h==null?void 0:h.home)!==void 0,b=OO(FO(e),c),[k,w]=y.useState(()=>$D()),j=b.find(T=>T.id===k)??b[0];y.useEffect(()=>MD(k),[k]);const E=wD(h,c.running||c.queue.length>0||i!==void 0),N=ED(),C=hS(e,t.id),L=C.filter(T=>T.running).length,$=N.panel==="tasks"||N.panel==="commands",O=y.useMemo(()=>$?Vd(c.events,c.live,c.pending):_D,[$,c.events,c.live,c.pending,c.version]),W=y.useMemo(()=>iS(c.events),[c.events]),B=y.useMemo(()=>dS(O,W),[O,W]),U=y.useMemo(()=>aS(O,W),[O,W]),D=y.useMemo(()=>xS(O),[O]),F=y.useMemo(()=>({openTask:N.openTask}),[N.openTask]),A=s.jsxs("div",{className:"title-tools in-title-bar",role:"toolbar","aria-label":"侧栏",children:[pS.filter(T=>T.id!=="browser"||N.bridge!==void 0).map(T=>{const M=N.panel===T.id,P=T.id==="tasks"&&L>0?`子任务:${L} 个进行中`:T.id==="browser"&&N.working?"agent 正在操作内置浏览器":T.hint;return s.jsxs("button",{type:"button",className:`side-icon${M?" active":""}`,"aria-pressed":M,"aria-label":T.title,title:P,onClick:()=>N.setPanel(M?null:T.id),children:[s.jsx(Q,{name:T.icon}),T.id==="tasks"&&L>0&&s.jsx("span",{className:"side-icon-badge",children:L}),T.id==="browser"&&N.working&&s.jsx("span",{className:"side-icon-dot"})]},T.id)}),s.jsx(TD,{views:b,onSelect:w})]});return s.jsxs("section",{className:"main",children:[!x&&s.jsx("div",{className:"session-bar",children:!x&&s.jsxs("div",{className:"breadcrumb session-crumb",children:[o!==void 0?s.jsx("button",{type:"button",className:"link-button breadcrumb-link",title:`回到「${p.name}」的对话`,onClick:()=>o(f),children:p.name}):s.jsx("span",{children:p.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx(ID,{title:c.title,onRename:T=>e.renameSession(t.id,T)}),s.jsxs("span",{className:"session-crumb-note",children:["以前的对话",f!==On&&(h==null?void 0:h.requestedBy)!==void 0?` · ${gz(h.requestedBy)}`:""]})]})}),Va.createPortal(A,document.body),c.error!==null&&s.jsx("div",{className:"banner error",children:c.error}),s.jsxs("div",{className:`session-body${N.panel!==null?" with-side":""}`,children:[s.jsxs("div",{className:"session-column",children:[s.jsxs("div",{className:"view",children:[j!==void 0&&b[0]!==void 0&&j.id!==b[0].id&&s.jsxs("div",{className:"view-back",children:[s.jsxs("button",{type:"button",className:"small-button",onClick:()=>w(b[0].id),children:[s.jsx(Q,{name:"back"}),"返回",b[0].title]}),s.jsx("span",{className:"view-back-title",children:j.title})]}),j===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):s.jsx(Pp.Provider,{value:F,children:s.jsx(j.component,{client:e,session:t,state:c,readOnly:E})})]}),E?s.jsxs("div",{className:"session-readonly",children:[s.jsx(Q,{name:"archive"}),s.jsx("span",{children:"这是以前的对话,只能查看,不能继续。"}),o!==void 0&&s.jsxs("button",{type:"button",className:"small-button",onClick:()=>o(f),children:["回到「",p.name,"」的对话"]})]}):s.jsx(s.Fragment,{children:s.jsx(eL,{client:e,session:t,running:c.running,disabled:u.state!=="open",initialPrompt:i,onInitialSent:r,reminder:n})})]}),N.panel!==null&&s.jsx("div",{className:`side-slot side-${N.panel}`,children:N.panel==="browser"&&N.bridge!==void 0?s.jsx(Iz,{bridge:N.bridge,onClose:()=>N.setPanel(null)}):N.panel==="tasks"&&N.task!==null?s.jsx(Pp.Provider,{value:F,children:s.jsx(ex,{client:e,task:N.task,parent:p.name,trail:f===On?[]:[nn.name],onClose:()=>N.openTask(null)},N.task.id)}):N.panel==="tasks"?s.jsx(Gb,{title:"子任务",onClose:()=>N.setPanel(null),children:s.jsx(xD,{tasks:C,labels:B,settled:U,onOpen:N.openTask})}):s.jsx(Gb,{title:"命令",onClose:()=>N.setPanel(null),children:s.jsx(bD,{client:e,own:D,tasks:C,labels:B})})})]})]})}const _D=[];function ED(){var b;const e=(b=ni())==null?void 0:b.browser,[t,n]=y.useState(()=>AD()),i=t==="browser"&&e===void 0?null:t,[r,o]=y.useState(null),c=y.useRef(0),u=y.useRef(i);u.current=i;const d=k=>{u.current==="browser"&&k!=="browser"&&(c.current=Date.now()),n(k),o(null),Qb(k)},h=y.useMemo(()=>k=>{o(k),k!==null&&(n("tasks"),Qb("tasks"))},[]),[f,g]=y.useState(0);y.useEffect(()=>{if(e===void 0)return;let k;return e.onChange(w=>{const j=k!==void 0&&w.agentAt>k;k=w.agentAt,g(w.agentAt),j&&u.current===null&&Date.now()-c.current>CD&&n("browser")})},[e]);const p=Date.now()-f<Xb,[,x]=y.useState(0);return y.useEffect(()=>{if(!p)return;const k=setTimeout(()=>x(w=>w+1),f+Xb-Date.now()+50);return()=>clearTimeout(k)},[p,f]),{bridge:e,panel:i,setPanel:d,task:i==="tasks"?r:null,openTask:h,working:p}}const vS="adg.sidePanel",CD=3*6e4,Xb=5e3;function AD(){try{const e=localStorage.getItem(vS);return e===null?localStorage.getItem("adg.browserPanel")==="1"?"browser":null:pS.some(t=>t.id===e)?e:null}catch{return null}}function Qb(e){try{localStorage.setItem(vS,e??"")}catch{}}function ID({title:e,onRename:t}){const[n,i]=y.useState(null),[r,o]=y.useState(null),c=e??"新会话",u=async()=>{const d=(n==null?void 0:n.trim())??"";if(d===""||d===e){i(null);return}try{await t(d),i(null),o(null)}catch(h){o(h instanceof Error?h.message:String(h))}};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:d=>i(d.target.value),onFocus:d=>d.target.select(),onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&u(),d.key==="Escape"&&(i(null),o(null))},onBlur:()=>void u()}),r!==null&&s.jsx("span",{className:"error small",children:r})]}):s.jsxs("span",{className:"session-title",children:[s.jsx("h1",{title:"双击改名",onDoubleClick:()=>i(c),children:c}),s.jsx("button",{type:"button",className:"icon-button rename-button",title:"改名","aria-label":"给这个会话改名",onClick:()=>i(c),children:s.jsx(Q,{name:"pencil"})})]})}function TD({views:e,onSelect:t}){const[n,i]=y.useState(!1),r=y.useRef(null);y.useEffect(()=>{if(!n)return;const c=d=>{var h;((h=r.current)==null?void 0:h.contains(d.target))!==!0&&i(!1)},u=d=>{d.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",u)}},[n]);const o=e.slice(1);return o.length===0?null:s.jsxs("div",{className:"view-menu",ref:r,children:[s.jsx("button",{type:"button",className:`side-icon${n?" active":""}`,"aria-haspopup":"menu","aria-expanded":n,"aria-label":"更多",title:"更多",onClick:()=>i(!n),children:s.jsx(Q,{name:"more"})}),n&&s.jsx("div",{className:"view-menu-list",role:"menu",children:o.map(c=>s.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{t(c.id),i(!1)},children:[s.jsx(Q,{name:c.id==="trajectory"?"flow":"eye"}),c.title]},c.id))})]})}const yS="adg.sessionTab";function $D(){try{return localStorage.getItem(yS)??"chat"}catch{return"chat"}}function MD(e){try{localStorage.setItem(yS,e)}catch{}}const bS="adg.showEarlier",Fp=new Set;function RD(){try{return localStorage.getItem(bS)!=="0"}catch{return!0}}let kS=RD();function OD(e){kS=e;try{localStorage.setItem(bS,e?"1":"0")}catch{}for(const t of Fp)t()}function nx(){return y.useSyncExternalStore(e=>(Fp.add(e),()=>{Fp.delete(e)}),()=>kS)}const NS="adg.theme",Up=new Set;let rc=PD();function PD(){try{const e=localStorage.getItem(NS);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function jS(){var e,t;rc==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=rc,(t=(e=ni())==null?void 0:e.setTheme)==null||t.call(e,rc).catch(()=>{})}function zD(e){rc=e;try{localStorage.setItem(NS,e)}catch{}jS();for(const t of Up)t()}function wS(){return y.useSyncExternalStore(e=>(Up.add(e),()=>Up.delete(e)),()=>rc)}const LD={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",memory:"archive",about:"info"},DD=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function FD({client:e,onClose:t,section:n,onSection:i}){const r=UO(e),o=wS(),c=nx(),[u,d]=y.useState(null),h=u??n??null,f=p=>{d(p),i==null||i(p)},g=r.find(p=>p.id===h)??r[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(Q,{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:"偏好设置"}),r.map(p=>s.jsxs("button",{className:`nav-item ${p.id===(g==null?void 0:g.id)?"active":""}`,"aria-current":p.id===(g==null?void 0:g.id)?"page":void 0,onClick:()=>f(p.id),children:[s.jsx(Q,{name:LD[p.id]??"settings"}),s.jsx("span",{className:"nav-item-label",children:p.title})]},p.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:DD.map(([p,x])=>s.jsx("button",{role:"radio","aria-checked":o===p,className:o===p?"active":"",onClick:()=>zD(p),children:x},p))}),s.jsxs("label",{className:"check-label settings-toggle",title:"关了之后不显示这个按钮;对话记录不会删除。没有以前的对话时,开着也不显示",children:[s.jsx("input",{type:"checkbox",checked:c,onChange:p=>OD(p.target.checked)}),"显示「以前的对话」"]})]})]}),s.jsx("section",{className:"main settings",children:s.jsx("div",{className:"settings-content",children:g===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):s.jsx(g.component,{client:e})})})]})}const Em=320,qu=4;function Dt({value:e,options:t,onChange:n,id:i,disabled:r,placeholder:o="请选择",inline:c,className:u,...d}){const h=y.useId(),f=y.useRef(null),g=y.useRef(null),[p,x]=y.useState(!1),[b,k]=y.useState(-1),[w,j]=y.useState({}),E=t.findIndex(D=>D.value===e),N=E===-1?void 0:t[E],C=D=>t[D]!==void 0&&t[D].disabled!==!0,L=(D,F)=>{for(let A=D+F;A>=0&&A<t.length;A+=F)if(C(A))return A;return D},$=(D=E)=>{r!==!0&&(k(C(D)?D:L(-1,1)),x(!0))},O=(D=!0)=>{var F;x(!1),D&&((F=f.current)==null||F.focus())},W=D=>{C(D)&&(t[D].value!==e&&n(t[D].value),O())};y.useLayoutEffect(()=>{if(!p)return;const D=()=>{var V,z;const F=(V=f.current)==null?void 0:V.getBoundingClientRect();if(F===void 0)return;const A=window.innerHeight-F.bottom-qu-8,T=F.top-qu-8,M=A<Math.min(Em,((z=g.current)==null?void 0:z.scrollHeight)??Em)&&T>A,P=Math.max(F.width,180);j({left:Math.max(8,Math.min(F.left,window.innerWidth-P-8)),minWidth:P,maxWidth:Math.max(P,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(Em,M?T:A),...M?{bottom:window.innerHeight-F.top+qu}:{top:F.bottom+qu}})};return D(),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[p]),y.useEffect(()=>{var F;if(!p)return;(F=g.current)==null||F.focus({preventScroll:!0});const D=A=>{var M,P;const T=A.target;!((M=g.current)!=null&&M.contains(T))&&!((P=f.current)!=null&&P.contains(T))&&O(!1)};return document.addEventListener("pointerdown",D,!0),()=>document.removeEventListener("pointerdown",D,!0)},[p]),y.useEffect(()=>{var D,F;p&&b>=0&&((F=(D=g.current)==null?void 0:D.querySelector(`[data-index="${b}"]`))==null||F.scrollIntoView({block:"nearest"}))},[p,b]);const B=D=>{(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter"||D.key===" ")&&(D.preventDefault(),$())},U=D=>{const A={ArrowDown:()=>k(T=>L(T,1)),ArrowUp:()=>k(T=>L(T,-1)),Home:()=>k(L(-1,1)),End:()=>k(L(t.length,-1)),Enter:()=>W(b)," ":()=>W(b),Escape:()=>O(),Tab:()=>O()}[D.key];if(A!==void 0){D.key!=="Tab"&&D.preventDefault(),A();return}if(D.key.length===1&&!D.ctrlKey&&!D.metaKey&&!D.altKey){const T=D.key.toLowerCase();for(let M=1;M<=t.length;M++){const P=(b+M)%t.length;if(C(P)&&t[P].label.toLowerCase().startsWith(T)){k(P);break}}}};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:f,id:i,type:"button",disabled:r,className:`select-trigger text-input plain ${c===!0?"inline":""} ${p?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":p,"aria-controls":p?h:void 0,"aria-label":d["aria-label"],onClick:()=>p?O():$(),onKeyDown:B,children:s.jsx("span",{className:`select-value ${N===void 0?"placeholder":""}`,children:(N==null?void 0:N.label)??o})}),p&&Va.createPortal(s.jsxs("ul",{ref:g,id:h,role:"listbox",tabIndex:-1,className:"select-list",style:w,"aria-label":d["aria-label"],"aria-activedescendant":b>=0?`${h}-${b}`:void 0,onKeyDown:U,children:[t.map((D,F)=>{var A;return s.jsxs("li",{role:"presentation",children:[D.group!==void 0&&D.group!==((A=t[F-1])==null?void 0:A.group)&&s.jsx("div",{className:"select-group",children:D.group}),s.jsxs("div",{id:`${h}-${F}`,"data-index":F,role:"option","aria-selected":F===E,"aria-disabled":D.disabled===!0,className:`select-option ${F===b?"active":""} ${F===E?"selected":""} ${D.disabled===!0?"disabled":""}`,onPointerMove:()=>{C(F)&&F!==b&&k(F)},onClick:()=>W(F),children:[s.jsxs("span",{className:"select-text",children:[s.jsx("span",{children:D.label}),D.hint!==void 0&&s.jsx("span",{className:"select-hint",children:D.hint})]}),F===E&&s.jsx(Q,{name:"check",className:"select-check"})]})]},`${D.group??""}\0${D.value}`)}),t.length===0&&s.jsx("li",{role:"presentation",className:"select-empty",children:"没有可选的"})]}),document.body)]})}const SS=["日","一","二","三","四","五","六"],_S=[1,2,3,4,5,6,0];function sx(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${_S.filter(n=>e.days.includes(n)).map(n=>SS[n]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}function $o(e,t){if(!e.enabled)return;const n=new Date(t);n.setHours(0,0,0,0);for(let i=0;i<8;i++,n.setDate(n.getDate()+1)){if(e.days.length>0&&!e.days.includes(n.getDay()))continue;const r=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(r[0]!==void 0)return r[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 ES(e,t){const n=je(e.connection.status),[i,r]=y.useState(0),[o,c]=y.useState({items:null,error:null});return y.useEffect(()=>e.connection.on("tasks/changed",()=>r(u=>u+1)),[e]),y.useEffect(()=>{if(n.state!=="open")return;let u=!0;return e.connection.call("tasks/list",t===void 0?{}:{agent:t}).then(d=>{u&&c({items:d.items,error:null})},d=>{u&&c(h=>({...h,error:Ie(d)}))}),()=>{u=!1}},[e,t,n.state,i]),o}function CS(e,t){const n=je(e.connection.status),i=je(e.capabilities),[r,o]=y.useState(0),[c,u]=y.useState([]);return y.useEffect(()=>e.connection.on("reminders/changed",()=>o(d=>d+1)),[e]),y.useEffect(()=>{if(n.state!=="open"||!i.has("agents"))return;let d=!0;return e.connection.call("reminders/list",t===void 0?{}:{agent:t}).then(h=>{d&&u(h.items)}).catch(()=>{}),()=>{d=!1}},[e,t,n.state,i,r]),c}function AS(e){const t=je(e.connection.status),[n,i]=y.useState(0),[r,o]=y.useState([]);return y.useEffect(()=>e.connection.on("pipelines/changed",()=>i(c=>c+1)),[e]),y.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]),r}function IS(e){const t=je(e.connection.status),n=je(e.capabilities),[i,r]=y.useState(null);return y.useEffect(()=>{if(t.state!=="open"||!n.has("games"))return;let o=!0;return e.connection.call("games/list",{}).then(c=>{o&&r({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]),i}function TS({report:e,now:t}){const n=$o(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:"#/p/games/report",title:"在游戏页的「日报」里设置",children:[s.jsx(Q,{name:"send"}),s.jsx("span",{className:"task-title",children:"每日日报"}),s.jsxs("span",{className:"muted small",children:[sx(e.schedule),n===void 0?"":` · 下次 ${Oc(n)}`," · 发到飞书"]}),s.jsx(Q,{name:"chevron"})]})}function $S(e){const t=Ls(e);return y.useMemo(()=>[nn,...t.map(Ga)],[t])}function UD({client:e,agentId:t}){const n=$S(e),i=n.find(x=>x.id===t)??nn,{items:r,error:o}=ES(e,t),c=CS(e,t),u=AS(e),d=IS(e),h=un(3e4),[f,g]=y.useState(null),p=u.filter(x=>x.schedule.enabled&&x.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:i.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:()=>g("new"),disabled:f!==null,children:[s.jsx(Q,{name:"plus"}),"新建定时任务"]})})]}),s.jsxs("div",{className:"schedule-body",children:[s.jsxs("p",{className:"muted small",children:["到点把一段话交给",i.name,"去做,在它的对话里做。",t===On?"":"做完后,要紧的由助手告诉你。","要跑脚本的多步任务,用「编排」做成流水线。"]}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:o})]}),f==="new"&&s.jsx(Bp,{client:e,agents:n,task:{agent:t},onDone:()=>g(null)}),t==="games"&&d!==null&&s.jsx(TS,{report:d,now:h}),r!==null&&r.length===0&&c.length===0&&f===null&&s.jsxs("div",{className:"empty-card muted",children:[i.name,"还没有定时任务。"]}),r==null?void 0:r.map(x=>f!=="new"&&(f==null?void 0:f.id)===x.id?s.jsx(Bp,{client:e,agents:n,task:x,onDone:()=>g(null)},x.id):s.jsx(OS,{client:e,task:x,now:h,onEdit:()=>g(x)},x.id)),c.length>0&&s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{children:[i.name,"在对话里设的提醒"]}),s.jsx("p",{className:"muted small",children:"你在对话里让它「几点提醒我…」时它自己设的。到点后它在对话里接着做,回复也会同步到飞书和 QQ。"}),c.map(x=>s.jsx(RS,{client:e,reminder:x,now:h},x.id))]}),t==="pipelines"&&s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"按时运行的流水线"}),p.length===0&&s.jsx("p",{className:"muted small",children:"没有开着定时的流水线。"}),p.map(x=>s.jsx(MS,{pipeline:x,now:h},x.id))]})]})]})}function BD({client:e,onAgent:t}){const n=$S(e),{items:i,error:r}=ES(e),o=CS(e),c=AS(e),u=IS(e),d=un(3e4),[h,f]=y.useState(!1),g=n.find(b=>b.id==="pipelines"),p=n.find(b=>b.id==="games"),x=y.useMemo(()=>[...u===null?[]:[{key:"daily-report",agent:p,title:"每日日报",at:$o(u.schedule,d)}],...(i??[]).map(b=>({key:b.id,agent:n.find(k=>k.id===b.agent),title:b.title,at:$o(b.schedule,d)})),...c.filter(b=>b.draft!==!0).map(b=>({key:b.id,agent:g,title:`流水线「${b.name}」`,at:$o(b.schedule,d)})),...o.map(b=>({key:b.id,agent:n.find(k=>k.id===b.agent),title:`提醒:${b.title}`,at:b.next}))].filter(b=>b.at!==void 0).sort((b,k)=>b.at-k.at).slice(0,8),[i,o,c,n,g,p,u,d]);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(Q,{name:"settings"}),"开机自启与唤醒"]}),s.jsxs("button",{className:"small-button primary",onClick:()=>f(!0),disabled:h,children:[s.jsx(Q,{name:"plus"}),"新建定时任务"]})]})]}),s.jsxs("div",{className:"schedule-body",children:[r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:r})]}),h&&s.jsx(Bp,{client:e,agents:n,task:{agent:On},chooseAgent:!0,onDone:()=>f(!1)}),s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"接下来"}),x.length===0&&s.jsx("p",{className:"muted small",children:"一周内没有要按时做的事。"}),s.jsx("ol",{className:"schedule-timeline",children:x.map(b=>{var k,w,j;return s.jsxs("li",{children:[s.jsx("span",{className:"schedule-when",children:Oc(b.at)}),s.jsx("span",{className:`agent-avatar small agent-${((k=b.agent)==null?void 0:k.id)??"unknown"}`,children:s.jsx(Q,{name:((w=b.agent)==null?void 0:w.icon)??"sparkles"})}),s.jsx("span",{className:"schedule-who",children:((j=b.agent)==null?void 0:j.name)??"?"}),s.jsx("span",{className:"schedule-what",children:b.title})]},`${b.key}@${b.at}`)})})]}),n.map(b=>{const k=(i??[]).filter(N=>N.agent===b.id),w=o.filter(N=>N.agent===b.id),j=b.id==="pipelines"?c.filter(N=>N.schedule.enabled&&N.draft!==!0):[],E=b.id==="games"&&(u==null?void 0:u.schedule.enabled)===!0?u:null;return k.length===0&&w.length===0&&j.length===0&&E===null?null:s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{className:"schedule-agent",children:[s.jsx("span",{className:`agent-avatar small agent-${b.id}`,children:s.jsx(Q,{name:b.icon})}),b.name,s.jsx("span",{className:"tab-count",children:k.length+w.length+j.length+(E===null?0:1)}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button",onClick:()=>t(b.id),children:"管理"})]}),E!==null&&s.jsx(TS,{report:E,now:d}),k.map(N=>s.jsx(OS,{client:e,task:N,now:d},N.id)),w.map(N=>s.jsx(RS,{client:e,reminder:N,now:d},N.id)),j.map(N=>s.jsx(MS,{pipeline:N,now:d},N.id))]},b.id)})]})]})}function MS({pipeline:e,now:t}){const n=$o(e.schedule,t);return s.jsxs("a",{className:"task-card pipeline-line",href:`#/p/pipelines/${encodeURIComponent(e.id)}`,children:[s.jsx(Q,{name:"flow"}),s.jsx("span",{className:"task-title",children:e.name}),s.jsxs("span",{className:"muted small",children:[sx(e.schedule),n===void 0?"":` · 下次 ${Oc(n)}`]}),s.jsx(Q,{name:"chevron"})]})}function RS({client:e,reminder:t,now:n}){const[i,r]=y.useState(null),o=async()=>{await Ps({title:"删除这个提醒?",message:"agent 到时候就不会再被叫起来做这件事。要改时间,直接在对话里跟它说。",quote:t.title,confirmLabel:"删除",danger:!0})&&(r(null),e.connection.call("reminders/remove",{id:t.id}).catch(c=>r(Ie(c))))};return s.jsxs("div",{className:"task-card reminder-card",children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx(Q,{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?`(${HD(t.next-n)}后)`:""]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"icon-button",onClick:()=>void o(),title:"删除这个提醒","aria-label":"删除",children:s.jsx(Q,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}function HD(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 OS({client:e,task:t,now:n,onEdit:i}){const[r,o]=y.useState(null),c=$o(t.schedule,n),u=t.lastRun,d=f=>{o(null),e.connection.call(f,{id:t.id}).catch(g=>o(Ie(g)))},h=()=>{o(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(f=>o(Ie(f)))};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:[sx(t.schedule),c===void 0?"":` · 下次 ${Oc(c)}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>d("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:h,children:t.schedule.enabled?"暂停":"开启"}),i!==void 0&&s.jsx("button",{className:"icon-button",onClick:i,title:"修改","aria-label":"修改",children:s.jsx(Q,{name:"pencil"})}),i!==void 0&&s.jsx("button",{className:"icon-button",onClick:()=>void Ps({title:"删除这个定时任务?",message:"删掉后到点不会再交给 agent 做,不能撤销。",quote:t.title,confirmLabel:"删除",danger:!0}).then(f=>{f&&d("tasks/remove")}),title:"删除","aria-label":"删除",children:s.jsx(Q,{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(Q,{name:u.state==="done"?"check":"alert"}),s.jsxs("span",{children:[u.state==="running"?"正在做":`${yt(u.endedAt??u.startedAt,n)}${u.state==="done"?"做完":"没做成"}`,u.outcome===void 0?"":`:${u.outcome.split(`
203
+ `)[0]}`]})]}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}function Bp({client:e,agents:t,task:n,chooseAgent:i=!1,onDone:r}){var C,L;const[o,c]=y.useState(n.agent),[u,d]=y.useState(n.title??""),[h,f]=y.useState(n.prompt??""),[g,p]=y.useState((((C=n.schedule)==null?void 0:C.times)??["09:00"]).join(", ")),[x,b]=y.useState(((L=n.schedule)==null?void 0:L.days)??[]),[k,w]=y.useState(!1),[j,E]=y.useState(null),N=async()=>{var $,O;w(!0),E(null);try{const W=g.split(/[,,、\s]+/).filter(B=>B!=="").map(B=>/^\d:\d\d$/.test(B)?`0${B}`:B);await e.connection.call("tasks/save",{task:{...n.id===void 0?{}:{id:n.id},agent:o,title:u,prompt:h,schedule:{enabled:(($=n.schedule)==null?void 0:$.enabled)??!0,times:W,days:[...x],catchUpMinutes:((O=n.schedule)==null?void 0:O.catchUpMinutes)??10}}}),r()}catch(W){E(Ie(W))}finally{w(!1)}};return s.jsxs("div",{className:"task-card task-form",children:[i&&s.jsxs("div",{className:"field-label",children:["交给谁",s.jsx(Dt,{"aria-label":"交给谁",value:o,onChange:c,options:t.map($=>({value:$.id,label:$.name}))})]}),s.jsxs("label",{className:"field-label",children:["名字",s.jsx("input",{className:"text-input plain",value:u,maxLength:60,onChange:$=>d($.target.value),placeholder:"例如:看今天结束的活动"})]}),s.jsxs("label",{className:"field-label",children:["交给它的话",s.jsx("textarea",{className:"text-input plain",rows:3,value:h,maxLength:4e3,onChange:$=>f($.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:g,onChange:$=>p($.target.value),placeholder:"09:00, 21:30"})]}),s.jsxs("div",{className:"field-label",children:["星期",s.jsxs("div",{className:"day-chips",children:[_S.map($=>s.jsx("button",{type:"button",className:`day-chip ${x.includes($)?"on":""}`,"aria-pressed":x.includes($),onClick:()=>b(x.includes($)?x.filter(O=>O!==$):[...x,$]),children:SS[$]},$)),s.jsx("span",{className:"muted small",children:x.length===0?"不选就是每天":""})]})]})]}),j!==null&&s.jsx("div",{className:"error small",children:j}),s.jsxs("div",{className:"task-form-actions",children:[s.jsx("button",{className:"small-button",onClick:r,disabled:k,children:"取消"}),s.jsx("button",{className:"small-button primary",onClick:()=>void N(),disabled:k||u.trim()===""||h.trim()==="",children:"保存"})]})]})}const ZD=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。"].join(`
204
+ `),PS="adg.officialIntro";function WD(){var c;const e=(c=ni())==null?void 0:c.uiMode,[t,n]=y.useState(null);if(y.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(h=>{u&&n(h)},()=>{});const d=e.onChange(n);return()=>{u=!1,d()}},[e]),e===void 0||t===null)return null;const i=t.mode==="official",r=()=>{if(i){e.set("adg");return}const u=()=>{qD(),e.set("official")};if(VD()){u();return}Ps({title:"切换到 dsh 官方界面?",message:ZD,confirmLabel:"切换",icon:"popout"}).then(d=>{d&&u()})},o=t.starting?"正在启动官方界面…":i?"返回 MultiGameAssistant":"dsh 官方界面";return s.jsxs("div",{className:"ui-switch",children:[s.jsxs("button",{type:"button",className:`ui-switch-button ${i?"active":""}`,disabled:t.starting,onClick:r,title:i?"切回 MultiGameAssistant 的界面":"切换到 DeepSeek Harness 自带的界面(聊天记录分开)",children:[s.jsx(Q,{name:i?"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(Q,{name:"close"})})]})]})}function VD(){try{return localStorage.getItem(PS)==="1"}catch{return!1}}function qD(){try{localStorage.setItem(PS,"1")}catch{}}const Hp="adg.token",Jd=/^\/adg(\/|$)/.test(location.pathname);function GD(){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 KD(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(Hp,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}try{return sessionStorage.getItem(Hp)}catch{return null}}function YD(e){try{sessionStorage.setItem(Hp,e)}catch{}}function XD(e){if(Jd){const n=new URL(GD()??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 Jb(){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=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(t!==null)return{kind:"page",id:decodeURIComponent(t[1]),...t[2]===void 0?{}:{arg:decodeURIComponent(t[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const n=/^#\/h\/(.+)$/.exec(location.hash);if(n!==null)return{kind:"handoff",id:decodeURIComponent(n[1])};const i=/^#\/a\/(.+)\/(schedule|history)$/.exec(location.hash);if(i!==null)return{kind:"agent",id:decodeURIComponent(i[1]),tab:i[2]};const r=/^#\/a\/(.+)$/.exec(location.hash);if(r!==null)return{kind:"agent",id:decodeURIComponent(r[1])};const o=/^#\/s\/(.+)$/.exec(location.hash);return o===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(o[1])}}function QD(e,t="push"){const n=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 i=`${location.pathname}${location.search}${n}`;t==="replace"?history.replaceState(history.state,"",i):history.pushState(null,"",i)}const Cm="games";function JD({client:e}){const[t,n]=y.useState(()=>Jb()),[i,r]=_z(),[o,c]=y.useState(null),u=je(e.sessions),d=BO(e),h=je(e.connection.status),f=Ls(e),g=y.useRef(!1),p=y.useRef(null);y.useEffect(()=>{QD(t,g.current?"replace":"push"),g.current=!1,t.kind!=="handoff"&&(p.current=t)},[t]);const x=t.kind==="handoff"?t:null,b=p.current,k=x===null?t:b!==null&&b.kind!=="settings"?b:{kind:"agent",id:On};y.useEffect(()=>{const G=()=>n(Jb());return window.addEventListener("hashchange",G),()=>window.removeEventListener("hashchange",G)},[]);const w=y.useRef(new Set);y.useEffect(()=>{for(const Y of u.items)w.current.add(Y.id);if(t.kind!=="session"||!u.loaded||u.items.some(Y=>Y.id===t.id))return;const G=()=>{g.current=!0,n(Y=>Y.kind==="session"&&Y.id===t.id?{kind:"home"}:Y)};if(w.current.has(t.id)){G();return}const Z=setTimeout(G,8e3);return()=>clearTimeout(Z)},[t,u]),y.useEffect(()=>{t.kind!=="start"||h.state!=="open"||(g.current=!0,n(d.some(G=>G.id===Cm)?{kind:"page",id:Cm}:{kind:"home"}))},[t,h.state,d]);const j=nx(),E=k.kind==="agent"&&(k.tab!=="history"||j)?k.tab:void 0,N=G=>n({kind:"session",id:G}),C=G=>n({kind:"settings",...G===void 0?{}:{section:G}}),L=G=>n({kind:"page",id:G}),$=k.kind==="session"?k.id:null,O=$===null?void 0:u.items.find(G=>G.id===$),W=k.kind==="start"?{kind:"page",id:Cm}:k,B=W.kind==="page"?d.find(G=>G.id===W.id):void 0,U=G=>G.agent===void 0?void 0:f.some(Z=>Z.id===G.agent)?G.agent:On,D=B===void 0?void 0:U(B),F=G=>n({kind:"agent",id:G}),A=()=>F(On),T=s.jsxs(s.Fragment,{children:[s.jsx(n3,{client:e,onSettings:()=>C("api-keys")}),s.jsx(QO,{client:e})]}),M=k.kind==="home"?On:k.kind==="agent"?k.id:k.kind==="session"?O===void 0?void 0:La(O,f):D,P=(G,Z)=>n(Z==="chat"?{kind:"agent",id:G}:Z==="schedule"||Z==="history"?{kind:"agent",id:G,tab:Z}:{kind:"page",id:Z}),V=k.kind==="settings"?{kind:"settings"}:k.kind==="schedule"?{kind:"schedule"}:M!==void 0?{kind:"agent",id:M}:W.kind==="page"?{kind:"page",id:W.id}:{kind:"none"},z=B===void 0?null:s.jsx(B.component,{client:e,openSession:N,openSettings:C,openPage:L,arg:W.kind==="page"?W.arg:void 0},B.id),H=M===void 0?null:s.jsx(e3,{client:e,agentId:M,pages:d.filter(G=>U(G)===M),current:E!==void 0?E:k.kind==="session"?"history":W.kind==="page"?W.id:"chat",onTab:G=>P(M,G)});return s.jsx(Lw.Provider,{value:o,children:s.jsx(Az.Provider,{value:i>=To,children:s.jsxs("div",{className:`app ${k.kind==="settings"?"with-sidebar":""}`,style:{"--rail-width":`${i}px`},children:[s.jsx(wz,{client:e,pages:d.filter(G=>G.agent===void 0),current:V,onAgent:F,onPage:L,onSchedule:()=>n({kind:"schedule"}),onSettings:()=>C(),width:i,onWidth:r,slot:c}),k.kind==="settings"&&s.jsx(FD,{client:e,onClose:A,section:k.section,onSection:G=>n({kind:"settings",section:G})}),k.kind!=="settings"&&s.jsxs("div",{className:`app-main ${x===null?"":"under-exchange"}`,children:[W.kind==="page"&&D===void 0&&(z??s.jsx("section",{className:"main empty",children:h.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),M!==void 0&&s.jsxs("div",{className:"agent-area",children:[H,D!==void 0?z:k.kind==="agent"&&E==="schedule"?s.jsx(UD,{client:e,agentId:k.id},k.id):k.kind==="agent"&&E==="history"?s.jsx(jz,{client:e,agentId:k.id,onSelect:N},k.id):k.kind==="session"?s.jsx(Dp,{client:e,sessionId:k.id,onAgent:F,reminder:T},k.id):s.jsx(t3,{client:e,agentId:M,onMain:A,onAgent:F,reminder:T},M)]}),k.kind==="schedule"&&s.jsx(BD,{client:e,onAgent:G=>n({kind:"agent",id:G,tab:"schedule"})}),k.kind==="session"&&M===void 0&&s.jsx(Dp,{client:e,sessionId:k.id,onAgent:F,reminder:T},k.id),x!==null&&s.jsx(TL,{client:e,id:x.id,onClose:()=>n(k)},x.id)]}),s.jsx(hz,{client:e,sessionId:$,onSelect:N}),s.jsx(WD,{})]})})})}function e3({client:e,agentId:t,pages:n,current:i,onTab:r}){const o=Ls(e),c=je(e.capabilities),u=o.find(x=>x.id===t),d=u===void 0?nn:Ga(u),h=Nz(e,t),f=nx()&&(h||i==="history"),g=[{id:"chat",title:"对话",icon:"chat"},...c.has("pipelines")?[{id:"schedule",title:"定时",icon:"calendar"}]:[],...[...n].sort((x,b)=>x.order-b.order).map(x=>({id:x.id,title:x.title,icon:x.icon})),...f?[{id:"history",title:"以前的对话",icon:"archive"}]:[]];if(g.length===1)return null;const p=s.jsx("nav",{className:"agent-tabs in-title-bar",role:"tablist","aria-label":d.name,children:g.map(x=>s.jsxs("button",{role:"tab","aria-selected":x.id===i,className:x.id===i?"active":"",onClick:()=>r(x.id),children:[s.jsx(Q,{name:x.icon}),x.title]},x.id))});return Va.createPortal(p,document.body)}function t3({client:e,agentId:t,onMain:n,onAgent:i,reminder:r}){const{sessionId:o,error:c}=Pw(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(Dp,{client:e,sessionId:o,onAgent:i,reminder:r},o)}function n3({client:e,onSettings:t}){var o;const{items:n}=Wj(e,[fp]),{catalog:i}=el(e),r=(i==null?void 0:i.groups.some(c=>c.id!=="deepseek-official"&&c.models.length>0))??!1;return((o=n==null?void 0:n[fp])==null?void 0:o.configured)!==!1||r?null:s.jsxs("div",{className:"reminder",children:[s.jsx(Q,{name:"key"}),s.jsx("span",{children:"还没有可用的模型:请填写 DeepSeek API Key,或添加一个自定义 API(Claude、ChatGPT 等)。"}),s.jsx("button",{className:"primary small-button",onClick:t,children:"去设置"})]})}function s3({onSubmit:e}){const[t,n]=y.useState("");return s.jsx("div",{className:"token-prompt",children:s.jsxs("form",{onSubmit:i=>{i.preventDefault(),t.trim()!==""&&e(t.trim())},children:[s.jsx($g,{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:i=>n(i.target.value),placeholder:"粘贴连接 token"}),s.jsx("button",{className:"primary",type:"submit",disabled:t.trim()==="",children:"连接"})]})})}const i3=["准备环境","启动服务","载入界面","连接 agent"],r3=8e3,a3=400;function o3({client:e}){const t=je(e.connection.status),n=je(e.sessions),[i,r]=y.useState("shown"),[o,c]=y.useState(!1),u=t.state==="open"&&n.loaded;if(y.useEffect(()=>{const f=setTimeout(()=>c(!0),r3);return()=>clearTimeout(f)},[]),y.useEffect(()=>{u&&r(f=>f==="shown"?"leaving":f)},[u]),y.useEffect(()=>{if(i!=="leaving")return;const f=setTimeout(()=>r("gone"),a3);return()=>clearTimeout(f)},[i]),i==="gone")return null;const d=t.state==="open"?"正在读取对话":t.state==="reconnecting"?`连不上 agent,正在重试(第 ${t.attempt} 次)`:t.state==="connecting"?"正在连接 agent":"没有连上 agent",h=o?t.error!==void 0?`连接出错:${t.error}`:"比平时慢一些,agent 服务可能还在启动。":"";return s.jsxs("div",{className:`boot${i==="leaving"?" leaving":""}`,"aria-hidden":i==="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:d})}),s.jsx("ol",{className:"boot-steps",children:i3.map((f,g)=>s.jsxs("li",{className:g<3?"done":"now",children:[s.jsx("i",{}),s.jsx("span",{children:f})]},f))}),s.jsx("p",{className:`boot-hint${h!==""?" shown":""}`,children:h}),o&&s.jsx("button",{type:"button",className:"boot-skip",onClick:()=>r("leaving"),children:"先进入界面"})]}),s.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class l3 extends y.Component{constructor(){super(...arguments);ct(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n:new Error(String(n))}}componentDidCatch(n,i){console.error(`界面出错:${n instanceof Error?n.stack??n.message:String(n)}${i.componentStack??""}`)}render(){const{error:n}=this.state;if(n===null)return this.props.children;const i=`${n.message}
205
+
206
+ ${(n.stack??"").split(`
207
+ `).slice(1,8).join(`
208
+ `)}`;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:i})}),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 r;return void((r=navigator.clipboard)==null?void 0:r.writeText(i))},children:"复制错误信息"})]})]})})}}const c3=450,Gu=6,Dl=8,Am="data-tip";function u3(){return Number.parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--title-bar"))||0}function d3(){const[e,t]=y.useState(null),n=y.useRef(null),[i,r]=y.useState(null);return y.useEffect(()=>{let o=null,c;const u=()=>{if(window.clearTimeout(c),c=void 0,o!==null){const f=o.getAttribute(Am);o.removeAttribute(Am),f!==null&&!o.hasAttribute("title")&&o.setAttribute("title",f)}o=null,t(null)},d=f=>{var x,b,k,w;if(f.pointerType==="touch")return;if(o!==null&&o.contains(f.target)){const j=(b=(x=f.target).closest)==null?void 0:b.call(x,"[title]");if(j==null||!o.contains(j))return}const g=((w=(k=f.target)==null?void 0:k.closest)==null?void 0:w.call(k,"[title]"))??null;if(g===o||(u(),g===null))return;const p=g.getAttribute("title")??"";p.trim()!==""&&(o=g,g.setAttribute(Am,p),g.removeAttribute("title"),c=window.setTimeout(()=>{o===g&&g.isConnected&&t({text:p,anchor:g.getBoundingClientRect(),side:g.closest(".rail")!==null?"right":"auto"})},c3))},h=f=>{if(o===null)return;const g=f.relatedTarget;(g===null||!o.contains(g))&&u()};return document.addEventListener("pointerover",d,!0),document.addEventListener("pointerout",h,!0),document.addEventListener("pointerdown",u,!0),document.addEventListener("keydown",u,!0),window.addEventListener("scroll",u,!0),window.addEventListener("blur",u),()=>{u(),document.removeEventListener("pointerover",d,!0),document.removeEventListener("pointerout",h,!0),document.removeEventListener("pointerdown",u,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("scroll",u,!0),window.removeEventListener("blur",u)}},[]),y.useLayoutEffect(()=>{if(e===null||n.current===null){r(null);return}const{width:o,height:c}=n.current.getBoundingClientRect(),u=e.anchor,d=g=>Math.max(Dl,Math.min(g,window.innerHeight-c-Dl));if(e.side==="right"){r({left:u.right+Gu,top:d(u.top+u.height/2-c/2),side:"right"});return}const h=u.top-Gu-c<Dl+u3(),f=Math.max(Dl,Math.min(u.left+u.width/2-o/2,window.innerWidth-o-Dl));r({left:f,top:h?u.bottom+Gu:u.top-Gu-c,side:h?"below":"above"})},[e]),e===null?null:Va.createPortal(s.jsx("div",{ref:n,className:`app-tooltip ${(i==null?void 0:i.side)??""}`,role:"tooltip",style:i===null?{left:0,top:0,visibility:"hidden"}:{left:i.left,top:i.top},children:e.text}),document.body)}const h3={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:Yw}]},f3=[],m3={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function p3({client:e}){const t=je(e.connection.status),n=un(3e4),[i,r]=y.useState(null),[o,c]=y.useState(null),[u,d]=y.useState(0),[h,f]=y.useState(null),[g,p]=y.useState(null),[x,b]=y.useState(null),[k,w]=y.useState(""),[j,E]=y.useState(""),[N,C]=y.useState(""),[L,$]=y.useState(""),[O,W]=y.useState({});y.useEffect(()=>e.connection.on("notify/changed",()=>d(M=>M+1)),[e]),y.useEffect(()=>{if(t.state!=="open")return;let M=!0;return e.connection.call("feishu/settings",{}).then(P=>{M&&(r(P),w(V=>V===""?P.settings.appId??"":V),C(V=>V===""?P.settings.chatId??"":V))}).catch(P=>{M&&p(Ie(P))}),e.connection.call("notify/status",{}).then(P=>{M&&c(P.channels.find(V=>V.id==="feishu")??null)}).catch(()=>{}),()=>{M=!1}},[e,t.state,u]);const B=async(M,P,V)=>{f(M),p(null),b(null);try{const z=await P();z!==null&&typeof z=="object"&&"settings"in z&&r(z),V!==void 0&&b(V),d(H=>H+1)}catch(z){p(Ie(z))}finally{f(null)}},U=()=>B("credentials",async()=>(j.trim()!==""&&await e.setCredential(nR,j.trim()),E(""),e.connection.call("feishu/settings/set",{appId:k.trim()===""?null:k.trim(),enabled:!0})),"已保存,正在连接…"),D=()=>B("test",async()=>{const M=await e.connection.call("notify/test",{channel:"feishu"});if(M.failed.length>0)throw new Error(M.failed.map(P=>P.error).join(";"))},"测试消息已发送,去飞书看看"),F=i==null?void 0:i.settings,[A,T]=m3[(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 ${A}`,children:T})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(M=>s.jsxs("li",{className:M.ok===!0?"ok":M.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:M.ok===!0?"✓":M.ok===!1?"✗":"…"}),s.jsx("span",{children:M.label}),M.detail!==void 0&&s.jsx("span",{className:"muted small",children:M.detail})]},M.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B("check",()=>e.connection.call("feishu/check",{})),children:h==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:h!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void D(),children:"发送测试消息"}),F!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:F.enabled,disabled:h!==null,onChange:M=>void B("enable",()=>e.connection.call("feishu/settings/set",{enabled:M.target.checked}))}),"启用飞书"]})]})]}),F!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"应用凭证"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),s.jsx(Dt,{id:"feishu-domain",value:F.domain,disabled:h!==null,onChange:M=>void B("domain",()=>e.connection.call("feishu/settings/set",{domain:M})),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:k,onChange:M=>w(M.target.value),placeholder:"cli_xxxxxxxx",spellCheck:!1}),s.jsxs("label",{className:"field-label",htmlFor:"feishu-secret",children:["App Secret ",(i==null?void 0:i.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"feishu-secret",className:"text-input",type:"password",value:j,onChange:M=>E(M.target.value),placeholder:(i==null?void 0:i.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:h!==null||k.trim()==="",onClick:()=>void U(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),F!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),F.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:F.allowedUsers.map(M=>s.jsxs("li",{children:[s.jsx("span",{children:M.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:M.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B(`rm-${M.openId}`,()=>e.connection.call("feishu/users/remove",{openId:M.openId})),children:"移除"})]},M.openId))}),((i==null?void 0:i.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:i.pending.map(M=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:M.openId}),s.jsxs("span",{className:"muted small",children:["「",M.text,"」 · ",yt(M.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:O[M.openId]??"",onChange:P=>W(V=>({...V,[M.openId]:P.target.value}))}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B(`dismiss-${M.openId}`,()=>e.connection.call("feishu/users/remove",{openId:M.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void B(`allow-${M.openId}`,()=>{var P;return e.connection.call("feishu/users/allow",{openId:M.openId,...(P=O[M.openId])!=null&&P.trim()?{name:O[M.openId].trim()}:{}})}),children:"允许"})]},M.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:L,onChange:M=>$(M.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:h!==null||L.trim()==="",onClick:()=>void B("manual",async()=>{const M=await e.connection.call("feishu/users/allow",{openId:L.trim()});return $(""),M}),children:"添加"})]})]}),F!==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:F.otherApprovals,disabled:h!==null,onChange:M=>void B("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:M.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:M=>C(M.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void B("chat",()=>e.connection.call("feishu/settings/set",{chatId:N.trim()===""?null:N.trim()})),children:"保存"})]})]}),x!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(Q,{name:"check"}),s.jsx("span",{children:x})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]})]})}const g3={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function x3({client:e}){const t=je(e.connection.status),n=un(3e4),[i,r]=y.useState(null),[o,c]=y.useState(null),[u,d]=y.useState(0),[h,f]=y.useState(null),[g,p]=y.useState(null),[x,b]=y.useState(null),[k,w]=y.useState(""),[j,E]=y.useState(""),[N,C]=y.useState(""),[L,$]=y.useState({});y.useEffect(()=>e.connection.on("notify/changed",()=>d(A=>A+1)),[e]),y.useEffect(()=>{if(t.state!=="open")return;let A=!0;return e.connection.call("qqbot/settings",{}).then(T=>{A&&(r(T),w(M=>M===""?T.settings.appId??"":M))}).catch(T=>{A&&p(Ie(T))}),e.connection.call("notify/status",{}).then(T=>{A&&c(T.channels.find(M=>M.id==="qq")??null)}).catch(()=>{}),()=>{A=!1}},[e,t.state,u]);const O=async(A,T,M)=>{f(A),p(null),b(null);try{const P=await T();P!==null&&typeof P=="object"&&"settings"in P&&r(P),M!==void 0&&b(M),d(V=>V+1)}catch(P){p(Ie(P))}finally{f(null)}},W=()=>O("credentials",async()=>(j.trim()!==""&&await e.setCredential(sR,j.trim()),E(""),e.connection.call("qqbot/settings/set",{appId:k.trim()===""?null:k.trim(),enabled:!0})),"已保存,正在连接…"),B=()=>O("test",async()=>{const A=await e.connection.call("notify/test",{channel:"qq"});if(A.failed.length>0)throw new Error(A.failed.map(T=>T.error).join(";"))},"测试消息已发送,去 QQ 看看"),U=i==null?void 0:i.settings,[D,F]=g3[(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 ${D}`,children:F})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(A=>s.jsxs("li",{className:A.ok===!0?"ok":A.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:A.ok===!0?"✓":A.ok===!1?"✗":"…"}),s.jsx("span",{children:A.label}),A.detail!==void 0&&s.jsx("span",{className:"muted small",children:A.detail})]},A.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O("check",()=>e.connection.call("qqbot/check",{})),children:h==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:h!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void B(),children:"发送测试消息"}),U!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:U.enabled,disabled:h!==null,onChange:A=>void O("enable",()=>e.connection.call("qqbot/settings/set",{enabled:A.target.checked}))}),"启用 QQ 机器人"]})]})]}),U!==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:k,onChange:A=>w(A.target.value),placeholder:"102xxxxxx",spellCheck:!1,inputMode:"numeric"}),s.jsxs("label",{className:"field-label",htmlFor:"qq-secret",children:["AppSecret ",(i==null?void 0:i.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"qq-secret",className:"text-input",type:"password",value:j,onChange:A=>E(A.target.value),placeholder:(i==null?void 0:i.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:h!==null||k.trim()==="",onClick:()=>void W(),children:h==="credentials"?"保存中…":"保存并连接"})]})]}),U!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),U.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:U.allowedUsers.map(A=>s.jsxs("li",{children:[s.jsx("span",{children:A.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:A.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O(`rm-${A.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:A.openId})),children:"移除"})]},A.openId))}),((i==null?void 0:i.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:i.pending.map(A=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:A.openId}),s.jsxs("span",{className:"muted small",children:["「",A.text,"」 · ",yt(A.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:L[A.openId]??"",onChange:T=>$(M=>({...M,[A.openId]:T.target.value}))}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void O(`dismiss-${A.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:A.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void O(`allow-${A.openId}`,()=>{var T;return e.connection.call("qqbot/users/allow",{openId:A.openId,...(T=L[A.openId])!=null&&T.trim()?{name:L[A.openId].trim()}:{}})}),children:"允许"})]},A.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:A=>C(A.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:h!==null||N.trim()==="",onClick:()=>void O("manual",async()=>{const A=await e.connection.call("qqbot/users/allow",{openId:N.trim()});return C(""),A}),children:"添加"})]})]}),x!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(Q,{name:"check"}),s.jsx("span",{children:x})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]})]})}const v3=[{id:"feishu",title:"飞书",capability:"feishu",component:p3},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:x3}];function y3({client:e}){var c;const t=je(e.capabilities),n=v3.filter(u=>t.has(u.capability)),[i,r]=y.useState(((c=n[0])==null?void 0:c.id)??"feishu"),o=n.find(u=>u.id===i)??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:()=>r(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 b3=(e,t)=>{try{const n=localStorage.getItem(`adg.fold.${e}`);return n===null?t:n==="1"}catch{return t}};function k3(e,t=!0){const[n,i]=y.useState(()=>b3(e,t));return[n,()=>i(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function N3({open:e,onToggle:t,children:n,count:i,className:r=""}){return s.jsxs("button",{type:"button",className:`fold-head ${r}`,"aria-expanded":e,onClick:t,children:[s.jsx(Q,{name:"chevron",className:`fold-chevron ${e?"open":""}`}),s.jsx("span",{className:"fold-title",children:n}),i!==void 0&&s.jsx("span",{className:"fold-count",children:i})]})}function Ra({id:e,title:t,count:n,initial:i=!0,children:r,className:o=""}){const[c,u]=k3(e,i);return s.jsxs("div",{className:`fold ${o}`,children:[s.jsx(N3,{open:c,onToggle:u,...n===void 0?{}:{count:n},children:t}),c&&r]})}function zS({client:e,scriptId:t,taskId:n,name:i,spec:r,value:o,onChange:c,onCreated:u,profile:d}){const[h,f]=y.useState(null),[g,p]=y.useState(null),[x,b]=y.useState(!1),k=async()=>{const j=(g==null?void 0:g.trim())??"";if(j!==""){f(null),b(!0);try{const{value:E}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:n,param:i,name:j,...d===void 0?{}:{profile:d}});p(null),u==null||u(),c(E)}catch(E){f(Ie(E))}finally{b(!1)}}};let w;if(r.choices!==void 0){const j=r.choices.some(E=>E.value===o);w=s.jsx(Dt,{"aria-label":i,value:j?o:"",placeholder:r.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:E=>{E==="\0new"?p(N=>N??"MultiGameAssistant"):c(E)},options:[...r.choices.map(E=>({value:E.value,label:E.label,...E.detail===void 0?{}:{hint:E.detail}})),...r.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else r.type==="boolean"?w=s.jsx(Dt,{"aria-label":i,value:o,onChange:c,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):r.enum!==void 0?w=s.jsx(Dt,{"aria-label":i,value:o,onChange:c,options:r.enum.map(j=>({value:String(j),label:String(j)}))}):w=s.jsx("input",{className:"text-input plain","aria-label":i,value:o,placeholder:r.default===void 0?"必填":String(r.default),inputMode:r.type==="string"?"text":"numeric",onChange:j=>c(j.target.value)});return s.jsxs("div",{className:"param-row",role:"group","aria-label":i,children:[s.jsxs("span",{className:"field-label",children:[i,r.description===void 0?"":` · ${r.description}`]}),w,g!==null&&s.jsxs("span",{className:"param-new",children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,value:g,"aria-label":"新项的名字",onChange:j=>p(j.target.value),onKeyDown:j=>{j.key==="Enter"?(j.preventDefault(),k()):j.key==="Escape"&&p(null)}}),s.jsx("button",{type:"button",className:"primary small-button",disabled:x||g.trim()==="",onClick:()=>void k(),children:x?"新建中…":"新建"}),s.jsx("button",{type:"button",className:"small-button",disabled:x,onClick:()=>{p(null),f(null)},children:"取消"}),s.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),h!==null&&s.jsx("span",{className:"error small",children:h})]})}function LS(e,t,n=!0){const i=je(e.connection.status),[r,o]=y.useState(null);return y.useEffect(()=>{if(o(null),t===void 0||!n||i.state!=="open")return;let c=!0;e.connection.call("configs/profiles",{scriptId:t}).then(d=>{c&&o(d)},()=>{});const u=e.connection.on("configs/profiles/changed",d=>{d.scriptId===t&&o(d.list)});return()=>{c=!1,u()}},[e,t,n,i.state]),r}function DS({list:e,value:t,onChange:n,id:i,label:r="配置"}){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:i,children:r}),s.jsx(Dt,{id:i,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 ix={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},j3={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function w3({client:e,scriptId:t,packId:n}){const i=je(e.connection.status),r=un(3e4),[o,c]=y.useState(null),[u,d]=y.useState([]),[h,f]=y.useState(""),[g,p]=y.useState({}),[x,b]=y.useState(!1),[k,w]=y.useState(null),[j,E]=y.useState(null),[N,C]=y.useState(0),L=LS(e,t,n!==void 0),[$,O]=y.useState(void 0);y.useEffect(()=>{if(i.state!=="open")return;let F=!0;return e.connection.call("runs/tasks",{scriptId:t,...$===void 0?{}:{profile:$}}).then(A=>{F&&(c(A),f(T=>{var M;return T===""?((M=A.tasks[0])==null?void 0:M.id)??"":T}))}).catch(A=>{F&&w(Ie(A))}),e.connection.call("runs/list",{scriptId:t}).then(A=>{F&&d(A.items)}).catch(()=>{}),()=>{F=!1}},[e,t,n,i.state,N,$,L==null?void 0:L.current]),y.useEffect(()=>e.connection.on("runs/state",F=>{F.scriptId===t&&d(A=>[F,...A.filter(T=>T.id!==F.id)].sort((T,M)=>M.startedAt-T.startedAt))}),[e,t]);const W=o==null?void 0:o.tasks.find(F=>F.id===h);y.useEffect(()=>{W!==void 0&&p(Object.fromEntries(Object.entries(W.params).map(([F,A])=>{var T;return[F,A.default!==void 0?String(A.default):((T=A.choices)==null?void 0:T.length)===1?A.choices[0].value:""]})))},[W==null?void 0:W.id]);const B=u.find(F=>F.endedAt===void 0),U=u.find(F=>{var A;return F.id===(j??(B==null?void 0:B.id)??((A=u[0])==null?void 0:A.id))}),D=async()=>{if(W!==void 0){b(!0),w(null);try{const F={};for(const[T,M]of Object.entries(W.params)){const P=g[T]??"";P!==""&&(F[T]=M.type==="boolean"?P==="true":M.type==="integer"||M.type==="number"?Number(P):P)}const A=await e.connection.call("runs/start",{scriptId:t,taskId:W.id,params:F,...$===void 0?{}:{profile:$}});E(A.id),A.state==="failed"&&w(A.outcome??"运行失败")}catch(F){w(Ie(F))}finally{b(!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&&k===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(Dt,{id:"task-select",value:h,onChange:f,options:o.tasks.map(F=>({value:F.id,label:F.title,hint:F.id}))}),W!==void 0&&s.jsxs("div",{className:"task-facts muted small",children:[s.jsx("span",{className:"badge",children:j3[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(DS,{id:"run-profile",list:L,value:$,onChange:O}),W!==void 0&&Object.entries(W.params).map(([F,A])=>s.jsx(zS,{client:e,scriptId:t,taskId:W.id,name:F,spec:A,profile:$,value:g[F]??"",onChange:T=>p(M=>({...M,[F]:T})),onCreated:()=>C(T=>T+1)},F)),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),B!==void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:B.id}).catch(F=>w(Ie(F))),children:"停止当前运行"}),s.jsxs("button",{className:"primary small-button",disabled:x||!o.runnable||B!==void 0,onClick:()=>void D(),children:[s.jsx(Q,{name:"arrow"}),x?"启动中…":"运行"]})]})]}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:k})]}),u.length>0&&s.jsxs(Ra,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(F=>{const[A,T]=ix[F.state];return s.jsxs("button",{className:`run-row ${F.id===(U==null?void 0:U.id)?"active":""}`,"aria-expanded":F.id===(U==null?void 0:U.id),onClick:()=>E(M=>M===F.id||M===null&&F.id===(U==null?void 0:U.id)?"":F.id),children:[s.jsx("span",{className:`badge ${A}`,children:T}),s.jsxs("span",{className:"run-title",children:[F.taskTitle,F.profileName!==void 0&&((L==null?void 0:L.items.length)??0)>1&&s.jsxs("span",{className:"muted small",children:[" · ",F.profileName]})]}),s.jsx("span",{className:"muted small run-outcome",children:F.outcome??F.resources.join(" · ")}),s.jsx("span",{className:"session-time",children:yt(F.startedAt,r)})]},F.id)}),U!==void 0&&s.jsx(FS,{client:e,run:U},U.id)]})]})}function FS({client:e,run:t}){const[n,i]=y.useState([]),r=y.useRef(null);y.useEffect(()=>{let h=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(g=>{h&&i(g.lines)}).catch(()=>{});const f=e.connection.on("runs/log",g=>{g.runId===t.id&&i(p=>[...p,...g.lines].slice(-1e3))});return()=>{h=!1,f()}},[e,t.id]),y.useEffect(()=>{const h=r.current;h!==null&&(h.scrollTop=h.scrollHeight)},[n.length]);const o=y.useMemo(()=>t.warnings,[t.warnings]),[c,u]=y.useState(null),d=async()=>{let h=n;try{h=(await e.connection.call("runs/logs",{runId:t.id,limit:2e3})).lines}catch{}const f=[`${t.scriptName} · ${t.taskTitle}(${t.id})${t.outcome===void 0?"":` — ${t.outcome}`}`,...h.map(p=>`${new Date(p.at).toLocaleTimeString("zh-CN",{hour12:!1})} [${p.source==="adg"?"平台":p.source}]${p.level===void 0?"":` [${p.level}]`} ${p.text}`)].join(`
209
+ `),g=await S3(f);u(g?`已复制 ${h.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return s.jsxs("div",{className:"run-log-wrap",children:[o.map(h=>s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:h})]},h)),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 d(),title:"复制整次运行的日志(最多 2000 行),方便发给别人或 agent",children:[s.jsx(Q,{name:"copy"}),c??"复制日志"]})]}),s.jsxs("div",{className:"run-log",ref:r,role:"log","aria-label":"运行日志",children:[n.length===0&&s.jsx("div",{className:"muted small",children:"还没有日志"}),n.map((h,f)=>s.jsxs("div",{className:`log-line ${h.level===void 0?"":`lv-${h.level}`} ${h.source==="adg"?"adg":""}`,children:[s.jsx("span",{className:"log-time",children:new Date(h.at).toLocaleTimeString()}),s.jsx("span",{className:"log-source",children:h.source==="adg"?"平台":h.source}),s.jsx("span",{className:"log-text",children:h.text})]},f))]})]})}async function S3(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 US=y.createContext({byIncident:new Map,openSession:()=>{}}),_3={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},E3={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function C3({client:e,openSettings:t,openSession:n}){const i=je(e.connection.status),r=un(3e4),[o,c]=y.useState([]),[u,d]=y.useState([]),[h,f]=y.useState(null),[g,p]=y.useState(!1),[x,b]=y.useState(null),[k,w]=y.useState([]),j=je(e.capabilities);y.useEffect(()=>{if(i.state!=="open"||!j.has("intervene"))return;let B=!0;return e.connection.call("intervene/list",{limit:100}).then(U=>{B&&w(U.items)}).catch(()=>{}),()=>{B=!1}},[e,i.state,j]),y.useEffect(()=>e.connection.on("intervene/changed",B=>{w(U=>[B,...U.filter(D=>D.id!==B.id)])}),[e]);const E=y.useMemo(()=>{const B=new Map;for(const U of[...k].sort((D,F)=>D.startedAt-F.startedAt))U.incidentId!==void 0&&B.set(U.incidentId,U);return{byIncident:B,openSession:n}},[k,n]);y.useEffect(()=>{if(i.state!=="open")return;let B=!0;return e.connection.call("runs/list",{}).then(U=>{B&&c(U.items)}).catch(U=>{B&&b(Ie(U))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(U=>{B&&d(U.items)}).catch(()=>{}),()=>{B=!1}},[e,i.state]),y.useEffect(()=>e.connection.on("runs/state",B=>{c(U=>[B,...U.filter(D=>D.id!==B.id)].sort((D,F)=>F.startedAt-D.startedAt))}),[e]),y.useEffect(()=>e.connection.on("monitor/incident",B=>{d(U=>[B,...U.filter(D=>D.id!==B.id)].sort((D,F)=>F.createdAt-D.createdAt))}),[e]);const N=o.filter(B=>B.endedAt===void 0),C=o.filter(B=>B.endedAt!==void 0).slice(0,30),L=u.filter(B=>B.status==="open"),$=o.find(B=>{var U,D;return B.id===(h??((U=N[0])==null?void 0:U.id)??((D=o[0])==null?void 0:D.id))}),O=y.useMemo(()=>{const B=new Map;for(const U of L)B.set(U.runId,(B.get(U.runId)??0)+1);return B},[L]),W=B=>{const[U,D]=ix[B.state],F=O.get(B.id)??0;return s.jsxs("button",{className:`script-row ${B.id===($==null?void 0:$.id)?"active":""}`,onClick:()=>f(B.id),children:[s.jsxs("span",{className:"script-row-main",children:[s.jsxs("span",{className:"script-row-name",children:[B.scriptName," · ",B.taskTitle]}),s.jsxs("span",{className:"muted small",children:[B.kind==="settings"?"设置会话 · ":"",yt(B.startedAt,r),B.retryOf===void 0?"":" · 重新运行"]})]}),F>0?s.jsxs("span",{className:"badge warn",children:["异常 ",F]}):s.jsx("span",{className:`badge ${U}`,children:D})]},B.id)};return s.jsx(US.Provider,{value:E,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(Q,{name:"plug"}),"消息通知"]}),s.jsxs("button",{className:`small-button ${g?"primary":""}`,onClick:()=>p(B=>!B),children:[s.jsx(Q,{name:"settings"}),"监控设置"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"运行列表",children:[x!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:x})]}),s.jsxs(Ra,{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)]}),C.length>0&&s.jsx(Ra,{id:"monitor.recent",title:"最近",count:C.length,className:"list-fold",children:C.map(W)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[g&&s.jsx(I3,{client:e}),L.length>0&&s.jsx("section",{className:"card",children:s.jsxs(Ra,{id:"monitor.open-incidents",title:s.jsxs("h3",{children:["待处理的异常(",L.length,")"]}),className:"card-fold",children:[s.jsx("p",{className:"muted small",children:"脚本包里写了自动处理的(如重连模拟器、重新运行)会先自动处理;处理不了的才推送到飞书。"}),s.jsx("div",{className:"incident-list",children:L.map(B=>s.jsx(BS,{client:e,incident:B,now:r,onOpen:()=>f(B.runId)},B.id))})]})}),$===void 0&&L.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(Q,{name:"monitor"}),s.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),$!==void 0&&s.jsx(A3,{client:e,run:$,incidents:u.filter(B=>B.runId===$.id),now:r,openRun:f})]})})]})]})})}function A3({client:e,run:t,incidents:n,now:i,openRun:r}){const[o,c]=ix[t.state],[u,d]=y.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(h=>d(Ie(h))),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:()=>r(t.retryOf),children:["这是 ",t.retryOf," 的重新运行"]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx(Ra,{id:"monitor.run-log",title:"日志",children:s.jsx(FS,{client:e,run:t},t.id)}),n.length>0&&s.jsx(Ra,{id:"monitor.run-incidents",title:"这次运行的异常",count:n.length,children:s.jsx("div",{className:"incident-list",children:n.map(h=>s.jsx(BS,{client:e,incident:h,now:i},h.id))})})]})}function BS({client:e,incident:t,now:n,onOpen:i}){const{byIncident:r,openSession:o}=y.useContext(US),c=r.get(t.id),[u,d]=y.useState(!1),[h,f]=y.useState(null),[g,p]=y.useState(null),x=async()=>{if(c!==void 0){d(!0),f(null);try{await e.connection.call("intervene/takeover",{id:c.id})}catch(w){f(Ie(w))}finally{d(!1)}}},b=async w=>{d(!0),f(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:w})}catch(j){f(Ie(j))}finally{d(!1)}},k=async()=>{if(g!==null)return p(null);try{const w=await e.connection.call("monitor/screenshot",{incidentId:t.id});p(`data:${w.mime};base64,${w.data}`)}catch(w){f(Ie(w))}};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:E3[t.kind]}),i===void 0?s.jsx("span",{className:"incident-title",children:t.title}):s.jsx("button",{className:"link-button incident-title",onClick:i,children:t.title}),s.jsx("span",{className:"session-time",children:yt(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(w=>(c==null?void 0:c.summary)===void 0||c.state==="running"||!w.detail.endsWith(c.summary)).map((w,j)=>s.jsxs("li",{className:w.ok?"ok":"failed",children:[w.ok?"✓":"✗"," ",w.detail]},j))}),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:[_3[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 x(),children:"我来接管"})]}),t.status==="open"&&s.jsxs("div",{className:"key-actions",children:[t.screenshot&&s.jsxs("button",{className:"small-button",onClick:()=>void k(),children:[s.jsx(Q,{name:"image"}),g===null?"截图":"收起截图"]}),s.jsx("span",{className:"spacer"}),(c==null?void 0:c.paused)===!0&&s.jsx("button",{className:"primary small-button",disabled:u,onClick:()=>void b("resume"),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void b("stop"),children:"停止"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void b("retry"),children:"重试"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void b("resolve"),children:"忽略"})]}),g!==null&&s.jsx("img",{className:"incident-shot",src:g,alt:"异常时的截图"}),h!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]})]})}function I3({client:e}){var d;const[t,n]=y.useState(null),[i,r]=y.useState(null);y.useEffect(()=>{e.connection.call("monitor/settings",{}).then(n).catch(h=>r(Ie(h)))},[e]);const o=h=>e.connection.call("monitor/settings/set",h).then(n).catch(f=>r(Ie(f))),c=((d=Gd(e).data)==null?void 0:d.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([h],[f])=>h.localeCompare(f));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:h=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(h.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(([h,f])=>{var g;return s.jsxs("li",{children:[s.jsx("span",{children:((g=c.find(p=>p.id===h))==null?void 0:g.name)??h}),s.jsxs("span",{className:"muted small",children:[f.seconds," 秒 · ",f.by==="learned"?"学到的":f.by==="agent"?"agent 设的":"你设的",f.note===void 0?"":`:${f.note}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button small",onClick:()=>{const{[h]:p,...x}=t.scriptStall;o({scriptStall:x})},children:"恢复自动"})]},h)})}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:h=>void o({screenshot:h.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:h=>void o({notifyWarnings:h.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),s.jsx(Dt,{id:"intervene-mode",value:t.intervene,onChange:h=>void o({intervene:h}),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:h=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(h.target.value)||0)))})})]}),i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:i})]})]})}const T3={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:C3}]},$3={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:y3}]};function jn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,i;n<e.length;n++)(i=jn(e[n]))!==""&&(t+=(t&&" ")+i);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var M3={value:()=>{}};function eh(){for(var e=0,t=arguments.length,n={},i;e<t;++e){if(!(i=arguments[e]+"")||i in n||/[\s.]/.test(i))throw new Error("illegal type: "+i);n[i]=[]}return new dd(n)}function dd(e){this._=e}function R3(e,t){return e.trim().split(/^|\s+/).map(function(n){var i="",r=n.indexOf(".");if(r>=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}dd.prototype=eh.prototype={constructor:dd,on:function(e,t){var n=this._,i=R3(e+"",n),r,o=-1,c=i.length;if(arguments.length<2){for(;++o<c;)if((r=(e=i[o]).type)&&(r=O3(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<c;)if(r=(e=i[o]).type)n[r]=ek(n[r],e.name,t);else if(t==null)for(r in n)n[r]=ek(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new dd(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),i=0,r,o;i<r;++i)n[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],i=0,r=o.length;i<r;++i)o[i].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],r=0,o=i.length;r<o;++r)i[r].value.apply(t,n)}};function O3(e,t){for(var n=0,i=e.length,r;n<i;++n)if((r=e[n]).name===t)return r.value}function ek(e,t,n){for(var i=0,r=e.length;i<r;++i)if(e[i].name===t){e[i]=M3,e=e.slice(0,i).concat(e.slice(i+1));break}return n!=null&&e.push({name:t,value:n}),e}var Zp="http://www.w3.org/1999/xhtml";const tk={svg:"http://www.w3.org/2000/svg",xhtml:Zp,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function th(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),tk.hasOwnProperty(t)?{space:tk[t],local:e}:e}function P3(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Zp&&t.documentElement.namespaceURI===Zp?t.createElement(e):t.createElementNS(n,e)}}function z3(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function HS(e){var t=th(e);return(t.local?z3:P3)(t)}function L3(){}function rx(e){return e==null?L3:function(){return this.querySelector(e)}}function D3(e){typeof e!="function"&&(e=rx(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],c=o.length,u=i[r]=new Array(c),d,h,f=0;f<c;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),u[f]=h);return new zs(i,this._parents)}function F3(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function U3(){return[]}function ZS(e){return e==null?U3:function(){return this.querySelectorAll(e)}}function B3(e){return function(){return F3(e.apply(this,arguments))}}function H3(e){typeof e=="function"?e=B3(e):e=ZS(e);for(var t=this._groups,n=t.length,i=[],r=[],o=0;o<n;++o)for(var c=t[o],u=c.length,d,h=0;h<u;++h)(d=c[h])&&(i.push(e.call(d,d.__data__,h,c)),r.push(d));return new zs(i,r)}function WS(e){return function(){return this.matches(e)}}function VS(e){return function(t){return t.matches(e)}}var Z3=Array.prototype.find;function W3(e){return function(){return Z3.call(this.children,e)}}function V3(){return this.firstElementChild}function q3(e){return this.select(e==null?V3:W3(typeof e=="function"?e:VS(e)))}var G3=Array.prototype.filter;function K3(){return Array.from(this.children)}function Y3(e){return function(){return G3.call(this.children,e)}}function X3(e){return this.selectAll(e==null?K3:Y3(typeof e=="function"?e:VS(e)))}function Q3(e){typeof e!="function"&&(e=WS(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],c=o.length,u=i[r]=[],d,h=0;h<c;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new zs(i,this._parents)}function qS(e){return new Array(e.length)}function J3(){return new zs(this._enter||this._groups.map(qS),this._parents)}function Ed(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ed.prototype={constructor:Ed,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 e4(e){return function(){return e}}function t4(e,t,n,i,r,o){for(var c=0,u,d=t.length,h=o.length;c<h;++c)(u=t[c])?(u.__data__=o[c],i[c]=u):n[c]=new Ed(e,o[c]);for(;c<d;++c)(u=t[c])&&(r[c]=u)}function n4(e,t,n,i,r,o,c){var u,d,h=new Map,f=t.length,g=o.length,p=new Array(f),x;for(u=0;u<f;++u)(d=t[u])&&(p[u]=x=c.call(d,d.__data__,u,t)+"",h.has(x)?r[u]=d:h.set(x,d));for(u=0;u<g;++u)x=c.call(e,o[u],u,o)+"",(d=h.get(x))?(i[u]=d,d.__data__=o[u],h.delete(x)):n[u]=new Ed(e,o[u]);for(u=0;u<f;++u)(d=t[u])&&h.get(p[u])===d&&(r[u]=d)}function s4(e){return e.__data__}function i4(e,t){if(!arguments.length)return Array.from(this,s4);var n=t?n4:t4,i=this._parents,r=this._groups;typeof e!="function"&&(e=e4(e));for(var o=r.length,c=new Array(o),u=new Array(o),d=new Array(o),h=0;h<o;++h){var f=i[h],g=r[h],p=g.length,x=r4(e.call(f,f&&f.__data__,h,i)),b=x.length,k=u[h]=new Array(b),w=c[h]=new Array(b),j=d[h]=new Array(p);n(f,g,k,w,j,x,t);for(var E=0,N=0,C,L;E<b;++E)if(C=k[E]){for(E>=N&&(N=E+1);!(L=w[N])&&++N<b;);C._next=L||null}}return c=new zs(c,i),c._enter=u,c._exit=d,c}function r4(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function a4(){return new zs(this._exit||this._groups.map(qS),this._parents)}function o4(e,t,n){var i=this.enter(),r=this,o=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?o.remove():n(o),i&&r?i.merge(r).order():r}function l4(e){for(var t=e.selection?e.selection():e,n=this._groups,i=t._groups,r=n.length,o=i.length,c=Math.min(r,o),u=new Array(r),d=0;d<c;++d)for(var h=n[d],f=i[d],g=h.length,p=u[d]=new Array(g),x,b=0;b<g;++b)(x=h[b]||f[b])&&(p[b]=x);for(;d<r;++d)u[d]=n[d];return new zs(u,this._parents)}function c4(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var i=e[t],r=i.length-1,o=i[r],c;--r>=0;)(c=i[r])&&(o&&c.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(c,o),o=c);return this}function u4(e){e||(e=d4);function t(g,p){return g&&p?e(g.__data__,p.__data__):!g-!p}for(var n=this._groups,i=n.length,r=new Array(i),o=0;o<i;++o){for(var c=n[o],u=c.length,d=r[o]=new Array(u),h,f=0;f<u;++f)(h=c[f])&&(d[f]=h);d.sort(t)}return new zs(r,this._parents).order()}function d4(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function h4(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function f4(){return Array.from(this)}function m4(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length;r<o;++r){var c=i[r];if(c)return c}return null}function p4(){let e=0;for(const t of this)++e;return e}function g4(){return!this.node()}function x4(e){for(var t=this._groups,n=0,i=t.length;n<i;++n)for(var r=t[n],o=0,c=r.length,u;o<c;++o)(u=r[o])&&e.call(u,u.__data__,o,r);return this}function v4(e){return function(){this.removeAttribute(e)}}function y4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function b4(e,t){return function(){this.setAttribute(e,t)}}function k4(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function N4(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function j4(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 w4(e,t){var n=th(e);if(arguments.length<2){var i=this.node();return n.local?i.getAttributeNS(n.space,n.local):i.getAttribute(n)}return this.each((t==null?n.local?y4:v4:typeof t=="function"?n.local?j4:N4:n.local?k4:b4)(n,t))}function GS(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function S4(e){return function(){this.style.removeProperty(e)}}function _4(e,t,n){return function(){this.style.setProperty(e,t,n)}}function E4(e,t,n){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,n)}}function C4(e,t,n){return arguments.length>1?this.each((t==null?S4:typeof t=="function"?E4:_4)(e,t,n??"")):Vo(this.node(),e)}function Vo(e,t){return e.style.getPropertyValue(t)||GS(e).getComputedStyle(e,null).getPropertyValue(t)}function A4(e){return function(){delete this[e]}}function I4(e,t){return function(){this[e]=t}}function T4(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function $4(e,t){return arguments.length>1?this.each((t==null?A4:typeof t=="function"?T4:I4)(e,t)):this.node()[e]}function KS(e){return e.trim().split(/^|\s+/)}function ax(e){return e.classList||new YS(e)}function YS(e){this._node=e,this._names=KS(e.getAttribute("class")||"")}YS.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 XS(e,t){for(var n=ax(e),i=-1,r=t.length;++i<r;)n.add(t[i])}function QS(e,t){for(var n=ax(e),i=-1,r=t.length;++i<r;)n.remove(t[i])}function M4(e){return function(){XS(this,e)}}function R4(e){return function(){QS(this,e)}}function O4(e,t){return function(){(t.apply(this,arguments)?XS:QS)(this,e)}}function P4(e,t){var n=KS(e+"");if(arguments.length<2){for(var i=ax(this.node()),r=-1,o=n.length;++r<o;)if(!i.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?O4:t?M4:R4)(n,t))}function z4(){this.textContent=""}function L4(e){return function(){this.textContent=e}}function D4(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function F4(e){return arguments.length?this.each(e==null?z4:(typeof e=="function"?D4:L4)(e)):this.node().textContent}function U4(){this.innerHTML=""}function B4(e){return function(){this.innerHTML=e}}function H4(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Z4(e){return arguments.length?this.each(e==null?U4:(typeof e=="function"?H4:B4)(e)):this.node().innerHTML}function W4(){this.nextSibling&&this.parentNode.appendChild(this)}function V4(){return this.each(W4)}function q4(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function G4(){return this.each(q4)}function K4(e){var t=typeof e=="function"?e:HS(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Y4(){return null}function X4(e,t){var n=typeof e=="function"?e:HS(e),i=t==null?Y4:typeof t=="function"?t:rx(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),i.apply(this,arguments)||null)})}function Q4(){var e=this.parentNode;e&&e.removeChild(this)}function J4(){return this.each(Q4)}function eF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nF(e){return this.select(e?tF:eF)}function sF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function iF(e){return function(t){e.call(this,t,this.__data__)}}function rF(e){return e.trim().split(/^|\s+/).map(function(t){var n="",i=t.indexOf(".");return i>=0&&(n=t.slice(i+1),t=t.slice(0,i)),{type:t,name:n}})}function aF(e){return function(){var t=this.__on;if(t){for(var n=0,i=-1,r=t.length,o;n<r;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++i]=o;++i?t.length=i:delete this.__on}}}function oF(e,t,n){return function(){var i=this.__on,r,o=iF(t);if(i){for(var c=0,u=i.length;c<u;++c)if((r=i[c]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=n),r.value=t;return}}this.addEventListener(e.type,o,n),r={type:e.type,name:e.name,value:t,listener:o,options:n},i?i.push(r):this.__on=[r]}}function lF(e,t,n){var i=rF(e+""),r,o=i.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var d=0,h=u.length,f;d<h;++d)for(r=0,f=u[d];r<o;++r)if((c=i[r]).type===f.type&&c.name===f.name)return f.value}return}for(u=t?oF:aF,r=0;r<o;++r)this.each(u(i[r],t,n));return this}function JS(e,t,n){var i=GS(e),r=i.CustomEvent;typeof r=="function"?r=new r(t,n):(r=i.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function cF(e,t){return function(){return JS(this,e,t)}}function uF(e,t){return function(){return JS(this,e,t.apply(this,arguments))}}function dF(e,t){return this.each((typeof t=="function"?uF:cF)(e,t))}function*hF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var i=e[t],r=0,o=i.length,c;r<o;++r)(c=i[r])&&(yield c)}var e_=[null];function zs(e,t){this._groups=e,this._parents=t}function Pc(){return new zs([[document.documentElement]],e_)}function fF(){return this}zs.prototype=Pc.prototype={constructor:zs,select:D3,selectAll:H3,selectChild:q3,selectChildren:X3,filter:Q3,data:i4,enter:J3,exit:a4,join:o4,merge:l4,selection:fF,order:c4,sort:u4,call:h4,nodes:f4,node:m4,size:p4,empty:g4,each:x4,attr:w4,style:C4,property:$4,classed:P4,text:F4,html:Z4,raise:V4,lower:G4,append:K4,insert:X4,remove:J4,clone:nF,datum:sF,on:lF,dispatch:dF,[Symbol.iterator]:hF};function Ms(e){return typeof e=="string"?new zs([[document.querySelector(e)]],[document.documentElement]):new zs([[e]],e_)}function mF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function bi(e,t){if(e=mF(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var i=n.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const pF={passive:!1},xc={capture:!0,passive:!1};function Im(e){e.stopImmediatePropagation()}function Mo(e){e.preventDefault(),e.stopImmediatePropagation()}function t_(e){var t=e.document.documentElement,n=Ms(e).on("dragstart.drag",Mo,xc);"onselectstart"in t?n.on("selectstart.drag",Mo,xc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function n_(e,t){var n=e.document.documentElement,i=Ms(e).on("dragstart.drag",null);t&&(i.on("click.drag",Mo,xc),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in n?i.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Ku=e=>()=>e;function Wp(e,{sourceEvent:t,subject:n,target:i,identifier:r,active:o,x:c,y:u,dx:d,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,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:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Wp.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gF(e){return!e.ctrlKey&&!e.button}function xF(){return this.parentNode}function vF(e,t){return t??{x:e.x,y:e.y}}function yF(){return navigator.maxTouchPoints||"ontouchstart"in this}function s_(){var e=gF,t=xF,n=vF,i=yF,r={},o=eh("start","drag","end"),c=0,u,d,h,f,g=0;function p(C){C.on("mousedown.drag",x).filter(i).on("touchstart.drag",w).on("touchmove.drag",j,pF).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(C,L){if(!(f||!e.call(this,C,L))){var $=N(this,t.call(this,C,L),C,L,"mouse");$&&(Ms(C.view).on("mousemove.drag",b,xc).on("mouseup.drag",k,xc),t_(C.view),Im(C),h=!1,u=C.clientX,d=C.clientY,$("start",C))}}function b(C){if(Mo(C),!h){var L=C.clientX-u,$=C.clientY-d;h=L*L+$*$>g}r.mouse("drag",C)}function k(C){Ms(C.view).on("mousemove.drag mouseup.drag",null),n_(C.view,h),Mo(C),r.mouse("end",C)}function w(C,L){if(e.call(this,C,L)){var $=C.changedTouches,O=t.call(this,C,L),W=$.length,B,U;for(B=0;B<W;++B)(U=N(this,O,C,L,$[B].identifier,$[B]))&&(Im(C),U("start",C,$[B]))}}function j(C){var L=C.changedTouches,$=L.length,O,W;for(O=0;O<$;++O)(W=r[L[O].identifier])&&(Mo(C),W("drag",C,L[O]))}function E(C){var L=C.changedTouches,$=L.length,O,W;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),O=0;O<$;++O)(W=r[L[O].identifier])&&(Im(C),W("end",C,L[O]))}function N(C,L,$,O,W,B){var U=o.copy(),D=bi(B||$,L),F,A,T;if((T=n.call(C,new Wp("beforestart",{sourceEvent:$,target:p,identifier:W,active:c,x:D[0],y:D[1],dx:0,dy:0,dispatch:U}),O))!=null)return F=T.x-D[0]||0,A=T.y-D[1]||0,function M(P,V,z){var H=D,G;switch(P){case"start":r[W]=M,G=c++;break;case"end":delete r[W],--c;case"drag":D=bi(z||V,L),G=c;break}U.call(P,C,new Wp(P,{sourceEvent:V,subject:T,target:p,identifier:W,active:G,x:D[0]+F,y:D[1]+A,dx:D[0]-H[0],dy:D[1]-H[1],dispatch:U}),O)}}return p.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Ku(!!C),p):e},p.container=function(C){return arguments.length?(t=typeof C=="function"?C:Ku(C),p):t},p.subject=function(C){return arguments.length?(n=typeof C=="function"?C:Ku(C),p):n},p.touchable=function(C){return arguments.length?(i=typeof C=="function"?C:Ku(!!C),p):i},p.on=function(){var C=o.on.apply(o,arguments);return C===o?p:C},p.clickDistance=function(C){return arguments.length?(g=(C=+C)*C,p):Math.sqrt(g)},p}function ox(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function i_(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function zc(){}var vc=.7,Cd=1/vc,Ro="\\s*([+-]?\\d+)\\s*",yc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Zi="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bF=/^#([0-9a-f]{3,8})$/,kF=new RegExp(`^rgb\\(${Ro},${Ro},${Ro}\\)$`),NF=new RegExp(`^rgb\\(${Zi},${Zi},${Zi}\\)$`),jF=new RegExp(`^rgba\\(${Ro},${Ro},${Ro},${yc}\\)$`),wF=new RegExp(`^rgba\\(${Zi},${Zi},${Zi},${yc}\\)$`),SF=new RegExp(`^hsl\\(${yc},${Zi},${Zi}\\)$`),_F=new RegExp(`^hsla\\(${yc},${Zi},${Zi},${yc}\\)$`),nk={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};ox(zc,Da,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sk,formatHex:sk,formatHex8:EF,formatHsl:CF,formatRgb:ik,toString:ik});function sk(){return this.rgb().formatHex()}function EF(){return this.rgb().formatHex8()}function CF(){return r_(this).formatHsl()}function ik(){return this.rgb().formatRgb()}function Da(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=bF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?rk(t):n===3?new js(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Yu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Yu(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=kF.exec(e))?new js(t[1],t[2],t[3],1):(t=NF.exec(e))?new js(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=jF.exec(e))?Yu(t[1],t[2],t[3],t[4]):(t=wF.exec(e))?Yu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=SF.exec(e))?lk(t[1],t[2]/100,t[3]/100,1):(t=_F.exec(e))?lk(t[1],t[2]/100,t[3]/100,t[4]):nk.hasOwnProperty(e)?rk(nk[e]):e==="transparent"?new js(NaN,NaN,NaN,0):null}function rk(e){return new js(e>>16&255,e>>8&255,e&255,1)}function Yu(e,t,n,i){return i<=0&&(e=t=n=NaN),new js(e,t,n,i)}function AF(e){return e instanceof zc||(e=Da(e)),e?(e=e.rgb(),new js(e.r,e.g,e.b,e.opacity)):new js}function Vp(e,t,n,i){return arguments.length===1?AF(e):new js(e,t,n,i??1)}function js(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}ox(js,Vp,i_(zc,{brighter(e){return e=e==null?Cd:Math.pow(Cd,e),new js(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vc:Math.pow(vc,e),new js(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new js(Oa(this.r),Oa(this.g),Oa(this.b),Ad(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:ak,formatHex:ak,formatHex8:IF,formatRgb:ok,toString:ok}));function ak(){return`#${Ia(this.r)}${Ia(this.g)}${Ia(this.b)}`}function IF(){return`#${Ia(this.r)}${Ia(this.g)}${Ia(this.b)}${Ia((isNaN(this.opacity)?1:this.opacity)*255)}`}function ok(){const e=Ad(this.opacity);return`${e===1?"rgb(":"rgba("}${Oa(this.r)}, ${Oa(this.g)}, ${Oa(this.b)}${e===1?")":`, ${e})`}`}function Ad(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Oa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ia(e){return e=Oa(e),(e<16?"0":"")+e.toString(16)}function lk(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ji(e,t,n,i)}function r_(e){if(e instanceof ji)return new ji(e.h,e.s,e.l,e.opacity);if(e instanceof zc||(e=Da(e)),!e)return new ji;if(e instanceof ji)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),o=Math.max(t,n,i),c=NaN,u=o-r,d=(o+r)/2;return u?(t===o?c=(n-i)/u+(n<i)*6:n===o?c=(i-t)/u+2:c=(t-n)/u+4,u/=d<.5?o+r:2-o-r,c*=60):u=d>0&&d<1?0:c,new ji(c,u,d,e.opacity)}function TF(e,t,n,i){return arguments.length===1?r_(e):new ji(e,t,n,i??1)}function ji(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}ox(ji,TF,i_(zc,{brighter(e){return e=e==null?Cd:Math.pow(Cd,e),new ji(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vc:Math.pow(vc,e),new ji(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,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new js(Tm(e>=240?e-240:e+120,r,i),Tm(e,r,i),Tm(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new ji(ck(this.h),Xu(this.s),Xu(this.l),Ad(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=Ad(this.opacity);return`${e===1?"hsl(":"hsla("}${ck(this.h)}, ${Xu(this.s)*100}%, ${Xu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ck(e){return e=(e||0)%360,e<0?e+360:e}function Xu(e){return Math.max(0,Math.min(1,e||0))}function Tm(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 lx=e=>()=>e;function $F(e,t){return function(n){return e+n*t}}function MF(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function RF(e){return(e=+e)==1?a_:function(t,n){return n-t?MF(t,n,e):lx(isNaN(t)?n:t)}}function a_(e,t){var n=t-e;return n?$F(e,n):lx(isNaN(e)?t:e)}const Id=(function e(t){var n=RF(t);function i(r,o){var c=n((r=Vp(r)).r,(o=Vp(o)).r),u=n(r.g,o.g),d=n(r.b,o.b),h=a_(r.opacity,o.opacity);return function(f){return r.r=c(f),r.g=u(f),r.b=d(f),r.opacity=h(f),r+""}}return i.gamma=e,i})(1);function OF(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,i=t.slice(),r;return function(o){for(r=0;r<n;++r)i[r]=e[r]*(1-o)+t[r]*o;return i}}function PF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function zF(e,t){var n=t?t.length:0,i=e?Math.min(n,e.length):0,r=new Array(i),o=new Array(n),c;for(c=0;c<i;++c)r[c]=ac(e[c],t[c]);for(;c<n;++c)o[c]=t[c];return function(u){for(c=0;c<i;++c)o[c]=r[c](u);return o}}function LF(e,t){var n=new Date;return e=+e,t=+t,function(i){return n.setTime(e*(1-i)+t*i),n}}function Bi(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function DF(e,t){var n={},i={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=ac(e[r],t[r]):i[r]=t[r];return function(o){for(r in n)i[r]=n[r](o);return i}}var qp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$m=new RegExp(qp.source,"g");function FF(e){return function(){return e}}function UF(e){return function(t){return e(t)+""}}function o_(e,t){var n=qp.lastIndex=$m.lastIndex=0,i,r,o,c=-1,u=[],d=[];for(e=e+"",t=t+"";(i=qp.exec(e))&&(r=$m.exec(t));)(o=r.index)>n&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(i=i[0])===(r=r[0])?u[c]?u[c]+=r:u[++c]=r:(u[++c]=null,d.push({i:c,x:Bi(i,r)})),n=$m.lastIndex;return n<t.length&&(o=t.slice(n),u[c]?u[c]+=o:u[++c]=o),u.length<2?d[0]?UF(d[0].x):FF(t):(t=d.length,function(h){for(var f=0,g;f<t;++f)u[(g=d[f]).i]=g.x(h);return u.join("")})}function ac(e,t){var n=typeof t,i;return t==null||n==="boolean"?lx(t):(n==="number"?Bi:n==="string"?(i=Da(t))?(t=i,Id):o_:t instanceof Da?Id:t instanceof Date?LF:PF(t)?OF:Array.isArray(t)?zF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?DF:Bi)(e,t)}var uk=180/Math.PI,Gp={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function l_(e,t,n,i,r,o){var c,u,d;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(d=e*n+t*i)&&(n-=e*d,i-=t*d),(u=Math.sqrt(n*n+i*i))&&(n/=u,i/=u,d/=u),e*i<t*n&&(e=-e,t=-t,d=-d,c=-c),{translateX:r,translateY:o,rotate:Math.atan2(t,e)*uk,skewX:Math.atan(d)*uk,scaleX:c,scaleY:u}}var Qu;function BF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Gp:l_(t.a,t.b,t.c,t.d,t.e,t.f)}function HF(e){return e==null||(Qu||(Qu=document.createElementNS("http://www.w3.org/2000/svg","g")),Qu.setAttribute("transform",e),!(e=Qu.transform.baseVal.consolidate()))?Gp:(e=e.matrix,l_(e.a,e.b,e.c,e.d,e.e,e.f))}function c_(e,t,n,i){function r(h){return h.length?h.pop()+" ":""}function o(h,f,g,p,x,b){if(h!==g||f!==p){var k=x.push("translate(",null,t,null,n);b.push({i:k-4,x:Bi(h,g)},{i:k-2,x:Bi(f,p)})}else(g||p)&&x.push("translate("+g+t+p+n)}function c(h,f,g,p){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),p.push({i:g.push(r(g)+"rotate(",null,i)-2,x:Bi(h,f)})):f&&g.push(r(g)+"rotate("+f+i)}function u(h,f,g,p){h!==f?p.push({i:g.push(r(g)+"skewX(",null,i)-2,x:Bi(h,f)}):f&&g.push(r(g)+"skewX("+f+i)}function d(h,f,g,p,x,b){if(h!==g||f!==p){var k=x.push(r(x)+"scale(",null,",",null,")");b.push({i:k-4,x:Bi(h,g)},{i:k-2,x:Bi(f,p)})}else(g!==1||p!==1)&&x.push(r(x)+"scale("+g+","+p+")")}return function(h,f){var g=[],p=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,g,p),c(h.rotate,f.rotate,g,p),u(h.skewX,f.skewX,g,p),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,g,p),h=f=null,function(x){for(var b=-1,k=p.length,w;++b<k;)g[(w=p[b]).i]=w.x(x);return g.join("")}}}var ZF=c_(BF,"px, ","px)","deg)"),WF=c_(HF,", ",")",")"),VF=1e-12;function dk(e){return((e=Math.exp(e))+1/e)/2}function qF(e){return((e=Math.exp(e))-1/e)/2}function GF(e){return((e=Math.exp(2*e))-1)/(e+1)}const hd=(function e(t,n,i){function r(o,c){var u=o[0],d=o[1],h=o[2],f=c[0],g=c[1],p=c[2],x=f-u,b=g-d,k=x*x+b*b,w,j;if(k<VF)j=Math.log(p/h)/t,w=function(O){return[u+O*x,d+O*b,h*Math.exp(t*O*j)]};else{var E=Math.sqrt(k),N=(p*p-h*h+i*k)/(2*h*n*E),C=(p*p-h*h-i*k)/(2*p*n*E),L=Math.log(Math.sqrt(N*N+1)-N),$=Math.log(Math.sqrt(C*C+1)-C);j=($-L)/t,w=function(O){var W=O*j,B=dk(L),U=h/(n*E)*(B*GF(t*W+L)-qF(L));return[u+U*x,d+U*b,h*B/dk(t*W+L)]}}return w.duration=j*1e3*t/Math.SQRT2,w}return r.rho=function(o){var c=Math.max(.001,+o),u=c*c,d=u*u;return e(c,u,d)},r})(Math.SQRT2,2,4);var qo=0,Xl=0,Fl=0,u_=1e3,Td,Ql,$d=0,Fa=0,nh=0,bc=typeof performance=="object"&&performance.now?performance:Date,d_=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function cx(){return Fa||(d_(KF),Fa=bc.now()+nh)}function KF(){Fa=0}function Md(){this._call=this._time=this._next=null}Md.prototype=h_.prototype={constructor:Md,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?cx():+n)+(t==null?0:+t),!this._next&&Ql!==this&&(Ql?Ql._next=this:Td=this,Ql=this),this._call=e,this._time=n,Kp()},stop:function(){this._call&&(this._call=null,this._time=1/0,Kp())}};function h_(e,t,n){var i=new Md;return i.restart(e,t,n),i}function YF(){cx(),++qo;for(var e=Td,t;e;)(t=Fa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--qo}function hk(){Fa=($d=bc.now())+nh,qo=Xl=0;try{YF()}finally{qo=0,QF(),Fa=0}}function XF(){var e=bc.now(),t=e-$d;t>u_&&(nh-=t,$d=e)}function QF(){for(var e,t=Td,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Td=n);Ql=e,Kp(i)}function Kp(e){if(!qo){Xl&&(Xl=clearTimeout(Xl));var t=e-Fa;t>24?(e<1/0&&(Xl=setTimeout(hk,e-bc.now()-nh)),Fl&&(Fl=clearInterval(Fl))):(Fl||($d=bc.now(),Fl=setInterval(XF,u_)),qo=1,d_(hk))}}function fk(e,t,n){var i=new Md;return t=t==null?0:+t,i.restart(r=>{i.stop(),e(r+t)},t,n),i}var JF=eh("start","end","cancel","interrupt"),eU=[],f_=0,mk=1,Yp=2,fd=3,pk=4,Xp=5,md=6;function sh(e,t,n,i,r,o){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;tU(e,n,{name:t,index:i,group:r,on:JF,tween:eU,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:f_})}function ux(e,t){var n=Ci(e,t);if(n.state>f_)throw new Error("too late; already scheduled");return n}function Wi(e,t){var n=Ci(e,t);if(n.state>fd)throw new Error("too late; already running");return n}function Ci(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function tU(e,t,n){var i=e.__transition,r;i[t]=n,n.timer=h_(o,0,n.time);function o(h){n.state=mk,n.timer.restart(c,n.delay,n.time),n.delay<=h&&c(h-n.delay)}function c(h){var f,g,p,x;if(n.state!==mk)return d();for(f in i)if(x=i[f],x.name===n.name){if(x.state===fd)return fk(c);x.state===pk?(x.state=md,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete i[f]):+f<t&&(x.state=md,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete i[f])}if(fk(function(){n.state===fd&&(n.state=pk,n.timer.restart(u,n.delay,n.time),u(h))}),n.state=Yp,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Yp){for(n.state=fd,r=new Array(p=n.tween.length),f=0,g=-1;f<p;++f)(x=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(r[++g]=x);r.length=g+1}}function u(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=Xp,1),g=-1,p=r.length;++g<p;)r[g].call(e,f);n.state===Xp&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=md,n.timer.stop(),delete i[t];for(var h in i)return;delete e.__transition}}function pd(e,t){var n=e.__transition,i,r,o=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((i=n[c]).name!==t){o=!1;continue}r=i.state>Yp&&i.state<Xp,i.state=md,i.timer.stop(),i.on.call(r?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete n[c]}o&&delete e.__transition}}function nU(e){return this.each(function(){pd(this,e)})}function sU(e,t){var n,i;return function(){var r=Wi(this,e),o=r.tween;if(o!==n){i=n=o;for(var c=0,u=i.length;c<u;++c)if(i[c].name===t){i=i.slice(),i.splice(c,1);break}}r.tween=i}}function iU(e,t,n){var i,r;if(typeof n!="function")throw new Error;return function(){var o=Wi(this,e),c=o.tween;if(c!==i){r=(i=c).slice();for(var u={name:t,value:n},d=0,h=r.length;d<h;++d)if(r[d].name===t){r[d]=u;break}d===h&&r.push(u)}o.tween=r}}function rU(e,t){var n=this._id;if(e+="",arguments.length<2){for(var i=Ci(this.node(),n).tween,r=0,o=i.length,c;r<o;++r)if((c=i[r]).name===e)return c.value;return null}return this.each((t==null?sU:iU)(n,e,t))}function dx(e,t,n){var i=e._id;return e.each(function(){var r=Wi(this,i);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Ci(r,i).value[t]}}function m_(e,t){var n;return(typeof t=="number"?Bi:t instanceof Da?Id:(n=Da(t))?(t=n,Id):o_)(e,t)}function aU(e){return function(){this.removeAttribute(e)}}function oU(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lU(e,t,n){var i,r=n+"",o;return function(){var c=this.getAttribute(e);return c===r?null:c===i?o:o=t(i=c,n)}}function cU(e,t,n){var i,r=n+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===r?null:c===i?o:o=t(i=c,n)}}function uU(e,t,n){var i,r,o;return function(){var c,u=n(this),d;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),d=u+"",c===d?null:c===i&&d===r?o:(r=d,o=t(i=c,u)))}}function dU(e,t,n){var i,r,o;return function(){var c,u=n(this),d;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),d=u+"",c===d?null:c===i&&d===r?o:(r=d,o=t(i=c,u)))}}function hU(e,t){var n=th(e),i=n==="transform"?WF:m_;return this.attrTween(e,typeof t=="function"?(n.local?dU:uU)(n,i,dx(this,"attr."+e,t)):t==null?(n.local?oU:aU)(n):(n.local?cU:lU)(n,i,t))}function fU(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function mU(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function pU(e,t){var n,i;function r(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&mU(e,o)),n}return r._value=t,r}function gU(e,t){var n,i;function r(){var o=t.apply(this,arguments);return o!==i&&(n=(i=o)&&fU(e,o)),n}return r._value=t,r}function xU(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 i=th(e);return this.tween(n,(i.local?pU:gU)(i,t))}function vU(e,t){return function(){ux(this,e).delay=+t.apply(this,arguments)}}function yU(e,t){return t=+t,function(){ux(this,e).delay=t}}function bU(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?vU:yU)(t,e)):Ci(this.node(),t).delay}function kU(e,t){return function(){Wi(this,e).duration=+t.apply(this,arguments)}}function NU(e,t){return t=+t,function(){Wi(this,e).duration=t}}function jU(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?kU:NU)(t,e)):Ci(this.node(),t).duration}function wU(e,t){if(typeof t!="function")throw new Error;return function(){Wi(this,e).ease=t}}function SU(e){var t=this._id;return arguments.length?this.each(wU(t,e)):Ci(this.node(),t).ease}function _U(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Wi(this,e).ease=n}}function EU(e){if(typeof e!="function")throw new Error;return this.each(_U(this._id,e))}function CU(e){typeof e!="function"&&(e=WS(e));for(var t=this._groups,n=t.length,i=new Array(n),r=0;r<n;++r)for(var o=t[r],c=o.length,u=i[r]=[],d,h=0;h<c;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&u.push(d);return new xr(i,this._parents,this._name,this._id)}function AU(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,i=t.length,r=n.length,o=Math.min(i,r),c=new Array(i),u=0;u<o;++u)for(var d=t[u],h=n[u],f=d.length,g=c[u]=new Array(f),p,x=0;x<f;++x)(p=d[x]||h[x])&&(g[x]=p);for(;u<i;++u)c[u]=t[u];return new xr(c,this._parents,this._name,this._id)}function IU(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 TU(e,t,n){var i,r,o=IU(t)?ux:Wi;return function(){var c=o(this,e),u=c.on;u!==i&&(r=(i=u).copy()).on(t,n),c.on=r}}function $U(e,t){var n=this._id;return arguments.length<2?Ci(this.node(),n).on.on(e):this.each(TU(n,e,t))}function MU(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RU(){return this.on("end.remove",MU(this._id))}function OU(e){var t=this._name,n=this._id;typeof e!="function"&&(e=rx(e));for(var i=this._groups,r=i.length,o=new Array(r),c=0;c<r;++c)for(var u=i[c],d=u.length,h=o[c]=new Array(d),f,g,p=0;p<d;++p)(f=u[p])&&(g=e.call(f,f.__data__,p,u))&&("__data__"in f&&(g.__data__=f.__data__),h[p]=g,sh(h[p],t,n,p,h,Ci(f,n)));return new xr(o,this._parents,t,n)}function PU(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ZS(e));for(var i=this._groups,r=i.length,o=[],c=[],u=0;u<r;++u)for(var d=i[u],h=d.length,f,g=0;g<h;++g)if(f=d[g]){for(var p=e.call(f,f.__data__,g,d),x,b=Ci(f,n),k=0,w=p.length;k<w;++k)(x=p[k])&&sh(x,t,n,k,p,b);o.push(p),c.push(f)}return new xr(o,c,t,n)}var zU=Pc.prototype.constructor;function LU(){return new zU(this._groups,this._parents)}function DU(e,t){var n,i,r;return function(){var o=Vo(this,e),c=(this.style.removeProperty(e),Vo(this,e));return o===c?null:o===n&&c===i?r:r=t(n=o,i=c)}}function p_(e){return function(){this.style.removeProperty(e)}}function FU(e,t,n){var i,r=n+"",o;return function(){var c=Vo(this,e);return c===r?null:c===i?o:o=t(i=c,n)}}function UU(e,t,n){var i,r,o;return function(){var c=Vo(this,e),u=n(this),d=u+"";return u==null&&(d=u=(this.style.removeProperty(e),Vo(this,e))),c===d?null:c===i&&d===r?o:(r=d,o=t(i=c,u))}}function BU(e,t){var n,i,r,o="style."+t,c="end."+o,u;return function(){var d=Wi(this,e),h=d.on,f=d.value[o]==null?u||(u=p_(t)):void 0;(h!==n||r!==f)&&(i=(n=h).copy()).on(c,r=f),d.on=i}}function HU(e,t,n){var i=(e+="")=="transform"?ZF:m_;return t==null?this.styleTween(e,DU(e,i)).on("end.style."+e,p_(e)):typeof t=="function"?this.styleTween(e,UU(e,i,dx(this,"style."+e,t))).each(BU(this._id,e)):this.styleTween(e,FU(e,i,t),n).on("end.style."+e,null)}function ZU(e,t,n){return function(i){this.style.setProperty(e,t.call(this,i),n)}}function WU(e,t,n){var i,r;function o(){var c=t.apply(this,arguments);return c!==r&&(i=(r=c)&&ZU(e,c,n)),i}return o._value=t,o}function VU(e,t,n){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,WU(e,t,n??""))}function qU(e){return function(){this.textContent=e}}function GU(e){return function(){var t=e(this);this.textContent=t??""}}function KU(e){return this.tween("text",typeof e=="function"?GU(dx(this,"text",e)):qU(e==null?"":e+""))}function YU(e){return function(t){this.textContent=e.call(this,t)}}function XU(e){var t,n;function i(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&YU(r)),t}return i._value=e,i}function QU(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,XU(e))}function JU(){for(var e=this._name,t=this._id,n=g_(),i=this._groups,r=i.length,o=0;o<r;++o)for(var c=i[o],u=c.length,d,h=0;h<u;++h)if(d=c[h]){var f=Ci(d,t);sh(d,e,n,h,c,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new xr(i,this._parents,e,n)}function e6(){var e,t,n=this,i=n._id,r=n.size();return new Promise(function(o,c){var u={value:c},d={value:function(){--r===0&&o()}};n.each(function(){var h=Wi(this,i),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(d)),h.on=t}),r===0&&o()})}var t6=0;function xr(e,t,n,i){this._groups=e,this._parents=t,this._name=n,this._id=i}function g_(){return++t6}var cr=Pc.prototype;xr.prototype={constructor:xr,select:OU,selectAll:PU,selectChild:cr.selectChild,selectChildren:cr.selectChildren,filter:CU,merge:AU,selection:LU,transition:JU,call:cr.call,nodes:cr.nodes,node:cr.node,size:cr.size,empty:cr.empty,each:cr.each,on:$U,attr:hU,attrTween:xU,style:HU,styleTween:VU,text:KU,textTween:QU,remove:RU,tween:rU,delay:bU,duration:jU,ease:SU,easeVarying:EU,end:e6,[Symbol.iterator]:cr[Symbol.iterator]};function n6(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var s6={time:null,delay:0,duration:250,ease:n6};function i6(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 r6(e){var t,n;e instanceof xr?(t=e._id,e=e._name):(t=g_(),(n=s6).time=cx(),e=e==null?null:e+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var c=i[o],u=c.length,d,h=0;h<u;++h)(d=c[h])&&sh(d,e,t,h,c,n||i6(d,t));return new xr(i,this._parents,e,t)}Pc.prototype.interrupt=nU;Pc.prototype.transition=r6;const Ju=e=>()=>e;function a6(e,{sourceEvent:t,target:n,transform:i,dispatch:r}){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:i,enumerable:!0,configurable:!0},_:{value:r}})}function hr(e,t,n){this.k=e,this.x=t,this.y=n}hr.prototype={constructor:hr,scale:function(e){return e===1?this:new hr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new hr(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 ih=new hr(1,0,0);x_.prototype=hr.prototype;function x_(e){for(;!e.__zoom;)if(!(e=e.parentNode))return ih;return e.__zoom}function Mm(e){e.stopImmediatePropagation()}function Ul(e){e.preventDefault(),e.stopImmediatePropagation()}function o6(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function l6(){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 gk(){return this.__zoom||ih}function c6(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function u6(){return navigator.maxTouchPoints||"ontouchstart"in this}function d6(e,t,n){var i=e.invertX(t[0][0])-n[0][0],r=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(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),c>o?(o+c)/2:Math.min(0,o)||Math.max(0,c))}function v_(){var e=o6,t=l6,n=d6,i=c6,r=u6,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,d=hd,h=eh("start","zoom","end"),f,g,p,x=500,b=150,k=0,w=10;function j(T){T.property("__zoom",gk).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",U).filter(r).on("touchstart.zoom",D).on("touchmove.zoom",F).on("touchend.zoom touchcancel.zoom",A).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(T,M,P,V){var z=T.selection?T.selection():T;z.property("__zoom",gk),T!==z?L(T,M,P,V):z.interrupt().each(function(){$(this,arguments).event(V).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},j.scaleBy=function(T,M,P,V){j.scaleTo(T,function(){var z=this.__zoom.k,H=typeof M=="function"?M.apply(this,arguments):M;return z*H},P,V)},j.scaleTo=function(T,M,P,V){j.transform(T,function(){var z=t.apply(this,arguments),H=this.__zoom,G=P==null?C(z):typeof P=="function"?P.apply(this,arguments):P,Z=H.invert(G),Y=typeof M=="function"?M.apply(this,arguments):M;return n(N(E(H,Y),G,Z),z,c)},P,V)},j.translateBy=function(T,M,P,V){j.transform(T,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),c)},null,V)},j.translateTo=function(T,M,P,V,z){j.transform(T,function(){var H=t.apply(this,arguments),G=this.__zoom,Z=V==null?C(H):typeof V=="function"?V.apply(this,arguments):V;return n(ih.translate(Z[0],Z[1]).scale(G.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof P=="function"?-P.apply(this,arguments):-P),H,c)},V,z)};function E(T,M){return M=Math.max(o[0],Math.min(o[1],M)),M===T.k?T:new hr(M,T.x,T.y)}function N(T,M,P){var V=M[0]-P[0]*T.k,z=M[1]-P[1]*T.k;return V===T.x&&z===T.y?T:new hr(T.k,V,z)}function C(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function L(T,M,P,V){T.on("start.zoom",function(){$(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(V).end()}).tween("zoom",function(){var z=this,H=arguments,G=$(z,H).event(V),Z=t.apply(z,H),Y=P==null?C(Z):typeof P=="function"?P.apply(z,H):P,X=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),re=z.__zoom,ee=typeof M=="function"?M.apply(z,H):M,te=d(re.invert(Y).concat(X/re.k),ee.invert(Y).concat(X/ee.k));return function(ne){if(ne===1)ne=ee;else{var se=te(ne),oe=X/se[2];ne=new hr(oe,Y[0]-se[0]*oe,Y[1]-se[1]*oe)}G.zoom(null,ne)}})}function $(T,M,P){return!P&&T.__zooming||new O(T,M)}function O(T,M){this.that=T,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,M),this.taps=0}O.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,M){return this.mouse&&T!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var M=Ms(this.that).datum();h.call(T,this.that,new a6(T,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:h}),M)}};function W(T,...M){if(!e.apply(this,arguments))return;var P=$(this,M).event(T),V=this.__zoom,z=Math.max(o[0],Math.min(o[1],V.k*Math.pow(2,i.apply(this,arguments)))),H=bi(T);if(P.wheel)(P.mouse[0][0]!==H[0]||P.mouse[0][1]!==H[1])&&(P.mouse[1]=V.invert(P.mouse[0]=H)),clearTimeout(P.wheel);else{if(V.k===z)return;P.mouse=[H,V.invert(H)],pd(this),P.start()}Ul(T),P.wheel=setTimeout(G,b),P.zoom("mouse",n(N(E(V,z),P.mouse[0],P.mouse[1]),P.extent,c));function G(){P.wheel=null,P.end()}}function B(T,...M){if(p||!e.apply(this,arguments))return;var P=T.currentTarget,V=$(this,M,!0).event(T),z=Ms(T.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",X,!0),H=bi(T,P),G=T.clientX,Z=T.clientY;t_(T.view),Mm(T),V.mouse=[H,this.__zoom.invert(H)],pd(this),V.start();function Y(re){if(Ul(re),!V.moved){var ee=re.clientX-G,te=re.clientY-Z;V.moved=ee*ee+te*te>k}V.event(re).zoom("mouse",n(N(V.that.__zoom,V.mouse[0]=bi(re,P),V.mouse[1]),V.extent,c))}function X(re){z.on("mousemove.zoom mouseup.zoom",null),n_(re.view,V.moved),Ul(re),V.event(re).end()}}function U(T,...M){if(e.apply(this,arguments)){var P=this.__zoom,V=bi(T.changedTouches?T.changedTouches[0]:T,this),z=P.invert(V),H=P.k*(T.shiftKey?.5:2),G=n(N(E(P,H),V,z),t.apply(this,M),c);Ul(T),u>0?Ms(this).transition().duration(u).call(L,G,V,T):Ms(this).call(j.transform,G,V,T)}}function D(T,...M){if(e.apply(this,arguments)){var P=T.touches,V=P.length,z=$(this,M,T.changedTouches.length===V).event(T),H,G,Z,Y;for(Mm(T),G=0;G<V;++G)Z=P[G],Y=bi(Z,this),Y=[Y,this.__zoom.invert(Y),Z.identifier],z.touch0?!z.touch1&&z.touch0[2]!==Y[2]&&(z.touch1=Y,z.taps=0):(z.touch0=Y,H=!0,z.taps=1+!!f);f&&(f=clearTimeout(f)),H&&(z.taps<2&&(g=Y[0],f=setTimeout(function(){f=null},x)),pd(this),z.start())}}function F(T,...M){if(this.__zooming){var P=$(this,M).event(T),V=T.changedTouches,z=V.length,H,G,Z,Y;for(Ul(T),H=0;H<z;++H)G=V[H],Z=bi(G,this),P.touch0&&P.touch0[2]===G.identifier?P.touch0[0]=Z:P.touch1&&P.touch1[2]===G.identifier&&(P.touch1[0]=Z);if(G=P.that.__zoom,P.touch1){var X=P.touch0[0],re=P.touch0[1],ee=P.touch1[0],te=P.touch1[1],ne=(ne=ee[0]-X[0])*ne+(ne=ee[1]-X[1])*ne,se=(se=te[0]-re[0])*se+(se=te[1]-re[1])*se;G=E(G,Math.sqrt(ne/se)),Z=[(X[0]+ee[0])/2,(X[1]+ee[1])/2],Y=[(re[0]+te[0])/2,(re[1]+te[1])/2]}else if(P.touch0)Z=P.touch0[0],Y=P.touch0[1];else return;P.zoom("touch",n(N(G,Z,Y),P.extent,c))}}function A(T,...M){if(this.__zooming){var P=$(this,M).event(T),V=T.changedTouches,z=V.length,H,G;for(Mm(T),p&&clearTimeout(p),p=setTimeout(function(){p=null},x),H=0;H<z;++H)G=V[H],P.touch0&&P.touch0[2]===G.identifier?delete P.touch0:P.touch1&&P.touch1[2]===G.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(G=bi(G,this),Math.hypot(g[0]-G[0],g[1]-G[1])<w)){var Z=Ms(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return j.wheelDelta=function(T){return arguments.length?(i=typeof T=="function"?T:Ju(+T),j):i},j.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Ju(!!T),j):e},j.touchable=function(T){return arguments.length?(r=typeof T=="function"?T:Ju(!!T),j):r},j.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Ju([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),j):t},j.scaleExtent=function(T){return arguments.length?(o[0]=+T[0],o[1]=+T[1],j):[o[0],o[1]]},j.translateExtent=function(T){return arguments.length?(c[0][0]=+T[0][0],c[1][0]=+T[1][0],c[0][1]=+T[0][1],c[1][1]=+T[1][1],j):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},j.constrain=function(T){return arguments.length?(n=T,j):n},j.duration=function(T){return arguments.length?(u=+T,j):u},j.interpolate=function(T){return arguments.length?(d=T,j):d},j.on=function(){var T=h.on.apply(h,arguments);return T===h?j:T},j.clickDistance=function(T){return arguments.length?(k=(T=+T)*T,j):Math.sqrt(k)},j.tapDistance=function(T){return arguments.length?(w=+T,j):w},j}const Ei={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:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", 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.`},kc=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],y_=["Enter"," ","Escape"],b_={"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 Go;(function(e){e.Strict="strict",e.Loose="loose"})(Go||(Go={}));var Pa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Pa||(Pa={}));var Nc;(function(e){e.Partial="partial",e.Full="full"})(Nc||(Nc={}));const k_={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Zr;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Zr||(Zr={}));var Rd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Rd||(Rd={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const xk={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top},N_=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,h6=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),hx=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Lc=(e,t=[0,0])=>{const{width:n,height:i}=Ai(e),r=e.origin??t,o=n*r[0],c=i*r[1];return{x:e.position.x-o,y:e.position.y-c}},f6=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const i=e.reduce((r,o)=>{const c=typeof o=="string";let u=!t.nodeLookup&&!c?o:void 0;return t.nodeLookup&&(u=c?t.nodeLookup.get(o):hx(o)?o:t.nodeLookup.get(o.id)),u?(n=!0,rh(r,Od(u,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?ah(i):{x:0,y:0,width:0,height:0}},Dc=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=rh(n,Od(r)),i=!0)}),i?ah(n):{x:0,y:0,width:0,height:0}},fx=(e,t,[n,i,r]=[0,0,1],o=!1,c=!1)=>{const u=(t.x-n)/r,d=(t.y-i)/r,h=t.width/r,f=t.height/r,g=[];for(const p of e.values()){const{measured:x,selectable:b=!0,hidden:k=!1}=p;if(c&&!b||k)continue;const w=x.width??p.width??p.initialWidth??0,j=x.height??p.height??p.initialHeight??0,{x:E,y:N}=p.internals.positionAbsolute,C=__(u,d,h,f,E,N,w,j),L=w*j,$=o&&C>0;(!p.internals.handleBounds||$||C>=L||p.dragging)&&g.push(p)}return g},m6=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function p6(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let o;if(t!=null&&t.includeHiddenNodes){const{width:c,height:u}=Ai(r);o=c>0&&u>0}else o=!!(r.measured.width&&r.measured.height&&!r.hidden);o&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function g6({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:o},c){if(e.size===0)return!0;const u=p6(e,c),d=Dc(u),h=px(d,t,n,(c==null?void 0:c.minZoom)??r,(c==null?void 0:c.maxZoom)??o,(c==null?void 0:c.padding)??.1);return await i.setViewport(h,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function j_({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const c=n.get(e),u=c.parentId?n.get(c.parentId):void 0,{x:d,y:h}=u?u.internals.positionAbsolute:{x:0,y:0},f=c.origin??i;let g=c.extent||r;if(c.extent==="parent"&&!c.expandParent)if(!u)o==null||o("005",Ei.error005());else{const{width:x,height:b}=Ai(u);x&&b&&(g=[[d,h],[d+x,h+b]])}else u&&Ba(c.extent)&&(g=[[c.extent[0][0]+d,c.extent[0][1]+h],[c.extent[1][0]+d,c.extent[1][1]+h]]);const p=Ba(g)?Ua(t,g,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",Ei.error015())),{position:{x:p.x-d+(c.measured.width??0)*f[0],y:p.y-h+(c.measured.height??0)*f[1]},positionAbsolute:p}}async function x6({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const o=new Set(e.map(p=>p.id)),c=[];for(const p of n){if(p.deletable===!1)continue;const x=o.has(p.id),b=!x&&p.parentId&&c.find(k=>k.id===p.parentId);(x||b)&&c.push(p)}const u=new Set(t.map(p=>p.id)),d=i.filter(p=>p.deletable!==!1),f=m6(c,d);for(const p of d)u.has(p.id)&&!f.find(b=>b.id===p.id)&&f.push(p);if(!r)return{edges:f,nodes:c};const g=await r({nodes:c,edges:f});return typeof g=="boolean"?g?{edges:f,nodes:c}:{edges:[],nodes:[]}:g}const Ko=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ua=(e={x:0,y:0},t,n)=>({x:Ko(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Ko(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function w_(e,t,n){const{width:i,height:r}=Ai(n),{x:o,y:c}=n.internals.positionAbsolute;return Ua(e,[[o,c],[o+i,c+r]],t)}const vk=(e,t,n)=>e<t?Ko(Math.abs(e-t),1,t)/t:e>n?-Ko(Math.abs(e-n),1,t)/t:0,mx=(e,t,n=15,i=40)=>{const r=vk(e.x,i,t.width-i)*n,o=vk(e.y,i,t.height-i)*n;return[r,o]},rh=(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)}),Qp=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),ah=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),jc=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=hx(e)?e.internals.positionAbsolute:Lc(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Od=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=hx(e)?e.internals.positionAbsolute:Lc(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},S_=(e,t)=>ah(rh(Qp(e),Qp(t))),__=(e,t,n,i,r,o,c,u)=>{const d=Math.max(0,Math.min(e+n,r+c)-Math.max(e,r)),h=Math.max(0,Math.min(t+i,o+u)-Math.max(t,o));return Math.ceil(d*h)},Pd=(e,t)=>__(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),yk=e=>wi(e.width)&&wi(e.height)&&wi(e.x)&&wi(e.y),wi=e=>!isNaN(e)&&isFinite(e),E_=(e,t)=>(n,i)=>{},Fc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Uc=({x:e,y:t},[n,i,r],o=!1,c=[1,1])=>{const u={x:(e-n)/r,y:(t-i)/r};return o?Fc(u,c):u},Yo=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function bo(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 v6(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=bo(e,n),r=bo(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=bo(e.top??e.y??0,n),r=bo(e.bottom??e.y??0,n),o=bo(e.left??e.x??0,t),c=bo(e.right??e.x??0,t);return{top:i,right:c,bottom:r,left:o,x:o+c,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function y6(e,t,n,i,r,o){const{x:c,y:u}=Yo(e,[t,n,i]),{x:d,y:h}=Yo({x:e.x+e.width,y:e.y+e.height},[t,n,i]),f=r-d,g=o-h;return{left:Math.floor(c),top:Math.floor(u),right:Math.floor(f),bottom:Math.floor(g)}}const px=(e,t,n,i,r,o)=>{const c=v6(o,t,n),u=(t-c.x)/e.width,d=(n-c.y)/e.height,h=Math.min(u,d),f=Ko(h,i,r),g=e.x+e.width/2,p=e.y+e.height/2,x=t/2-g*f,b=n/2-p*f,k=y6(e,x,b,f,t,n),w={left:Math.min(k.left-c.left,0),top:Math.min(k.top-c.top,0),right:Math.min(k.right-c.right,0),bottom:Math.min(k.bottom-c.bottom,0)};return{x:x-w.left+w.right,y:b-w.top+w.bottom,zoom:f}},wc=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ba(e){return e!=null&&e!=="parent"}function Ai(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 C_(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 A_(e,t={width:0,height:0},n,i,r){const o={...e},c=i.get(n);if(c){const u=c.origin||r;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 bk(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function b6(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function k6(e){return{...b_,...e||{}}}function I_(e){return e===null?null:e?"valid":"invalid"}function oc(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:o,y:c}=Si(e),u=Uc({x:o-((r==null?void 0:r.left)??0),y:c-((r==null?void 0:r.top)??0)},i),{x:d,y:h}=n?Fc(u,t):u;return{xSnapped:d,ySnapped:h,...u}}const gx=e=>({width:e.offsetWidth,height:e.offsetHeight}),T_=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},N6=["INPUT","SELECT","TEXTAREA"];function $_(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:N6.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const M_=e=>"clientX"in e,Si=(e,t)=>{var o,c;const n=M_(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},kk=(e,t,n,i,r)=>{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:r,position:c.getAttribute("data-handlepos"),x:(u.left-n.left)/i,y:(u.top-n.top)/i,...gx(c)}})};function R_({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:c,targetControlY:u}){const d=e*.125+r*.375+c*.375+n*.125,h=t*.125+o*.375+u*.375+i*.125,f=Math.abs(d-e),g=Math.abs(h-t);return[d,h,f,g]}function ed(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Nk({pos:e,x1:t,y1:n,x2:i,y2:r,c:o}){switch(e){case Je.Left:return[t-ed(t-i,o),n];case Je.Right:return[t+ed(i-t,o),n];case Je.Top:return[t,n-ed(n-r,o)];case Je.Bottom:return[t,n+ed(r-n,o)]}}function O_({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:r,targetPosition:o=Je.Top,curvature:c=.25}){const[u,d]=Nk({pos:n,x1:e,y1:t,x2:i,y2:r,c}),[h,f]=Nk({pos:o,x1:i,y1:r,x2:e,y2:t,c}),[g,p,x,b]=R_({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:u,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${u},${d} ${h},${f} ${i},${r}`,g,p,x,b]}function P_({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,c=Math.abs(i-t)/2,u=i<t?i+c:i-c;return[o,u,r,c]}function j6({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const c=r&&n?i+1e3:i,u=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return c+u}function w6({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const o=rh(Od(e),Od(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const c={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return Pd(c,ah(o))>0}const S6=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,_6=(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)),E6=(e,t,n={})=>{var o;if(!e.source||!e.target)return(o=n.onError)==null||o.call(n,"006",Ei.error006()),t;const i=n.getEdgeId||S6;let r;return N_(e)?r={...e}:r={...e,id:i(e)},_6(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function z_({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,o,c,u]=P_({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,o,c,u]}const jk={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},C6=({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},wk=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function A6({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:i=Je.Top,center:r,offset:o,stepPosition:c}){const u=jk[t],d=jk[i],h={x:e.x+u.x*o,y:e.y+u.y*o},f={x:n.x+d.x*o,y:n.y+d.y*o},g=C6({source:h,sourcePosition:t,target:f}),p=g.x!==0?"x":"y",x=g[p];let b=[],k,w;const j={x:0,y:0},E={x:0,y:0},[,,N,C]=P_({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[p]*d[p]===-1){p==="x"?(k=r.x??h.x+(f.x-h.x)*c,w=r.y??(h.y+f.y)/2):(k=r.x??(h.x+f.x)/2,w=r.y??h.y+(f.y-h.y)*c);const W=[{x:k,y:h.y},{x:k,y:f.y}],B=[{x:h.x,y:w},{x:f.x,y:w}];u[p]===x?b=p==="x"?W:B:b=p==="x"?B:W}else{const W=[{x:h.x,y:f.y}],B=[{x:f.x,y:h.y}];if(p==="x"?b=u.x===x?B:W:b=u.y===x?W:B,t===i){const T=Math.abs(e[p]-n[p]);if(T<=o){const M=Math.min(o-1,o-T);u[p]===x?j[p]=(h[p]>e[p]?-1:1)*M:E[p]=(f[p]>n[p]?-1:1)*M}}if(t!==i){const T=p==="x"?"y":"x",M=u[p]===d[T],P=h[T]>f[T],V=h[T]<f[T];(u[p]===1&&(!M&&P||M&&V)||u[p]!==1&&(!M&&V||M&&P))&&(b=p==="x"?W:B)}const U={x:h.x+j.x,y:h.y+j.y},D={x:f.x+E.x,y:f.y+E.y},F=Math.max(Math.abs(U.x-b[0].x),Math.abs(D.x-b[0].x)),A=Math.max(Math.abs(U.y-b[0].y),Math.abs(D.y-b[0].y));F>=A?(k=(U.x+D.x)/2,w=b[0].y):(k=b[0].x,w=(U.y+D.y)/2)}const L={x:h.x+j.x,y:h.y+j.y},$={x:f.x+E.x,y:f.y+E.y};return[[e,...L.x!==b[0].x||L.y!==b[0].y?[L]:[],...b,...$.x!==b[b.length-1].x||$.y!==b[b.length-1].y?[$]:[],n],k,w,N,C]}function I6(e,t,n,i){const r=Math.min(wk(e,t)/2,wk(t,n)/2,i),{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 h=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+r*h},${c}Q ${o},${c} ${o},${c+r*f}`}const u=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${c+r*d}Q ${o},${c} ${o+r*u},${c}`}function Jp({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:r,targetPosition:o=Je.Top,borderRadius:c=5,centerX:u,centerY:d,offset:h=20,stepPosition:f=.5}){const[g,p,x,b,k]=A6({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:o,center:{x:u,y:d},offset:h,stepPosition:f});let w=`M${g[0].x} ${g[0].y}`;for(let j=1;j<g.length-1;j++)w+=I6(g[j-1],g[j],g[j+1],c);return w+=`L${g[g.length-1].x} ${g[g.length-1].y}`,[w,p,x,b,k]}function Sk(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function T6(e){var g;const{sourceNode:t,targetNode:n}=e;if(!Sk(t)||!Sk(n))return null;const i=t.internals.handleBounds||_k(t.handles),r=n.internals.handleBounds||_k(n.handles),o=Ek((i==null?void 0:i.source)??[],e.sourceHandle),c=Ek(e.connectionMode===Go.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!c)return(g=e.onError)==null||g.call(e,"008",Ei.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||Je.Bottom,d=(c==null?void 0:c.position)||Je.Top,h=Ha(t,o,u),f=Ha(n,c,d);return{sourceX:h.x,sourceY:h.y,targetX:f.x,targetY:f.y,sourcePosition:u,targetPosition:d}}function _k(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function Ha(e,t,n=Je.Left,i=!1){const r=((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??Ai(e);if(i)return{x:r+c/2,y:o+u/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:r+c/2,y:o};case Je.Right:return{x:r+c,y:o+u/2};case Je.Bottom:return{x:r+c/2,y:o+u};case Je.Left:return{x:r,y:o+u/2}}}function Ek(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function eg(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function $6(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((c,u)=>([u.markerStart||i,u.markerEnd||r].forEach(d=>{if(d&&typeof d=="object"){const h=eg(d,t);o.has(h)||(c.push({id:h,color:d.color||n,...d}),o.add(h))}}),c),[]).sort((c,u)=>c.id.localeCompare(u.id))}const L_=1e3,M6=10,xx={nodeOrigin:[0,0],nodeExtent:kc,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},R6={...xx,checkEquality:!0};function vx(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function O6(e,t,n){const i=vx(xx,n);for(const r of e.values())if(r.parentId)bx(r,e,t,i);else{const o=Lc(r,i.nodeOrigin),c=Ba(r.extent)?r.extent:i.nodeExtent,u=Ua(o,c,Ai(r));r.internals.positionAbsolute=u}}function P6(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const o={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(o):r.type==="target"&&i.push(o)}return{source:n,target:i}}function yx(e){return e==="manual"}function tg(e,t,n,i={}){var f,g;const r=vx(R6,i),o={i:0},c=new Map(t),u=r!=null&&r.elevateNodesOnSelect&&!yx(r.zIndexMode)?L_:0;let d=e.length>0,h=!1;t.clear(),n.clear();for(const p of e){let x=c.get(p.id);if(r.checkEquality&&p===(x==null?void 0:x.internals.userNode))t.set(p.id,x);else{const b=Lc(p,r.nodeOrigin),k=Ba(p.extent)?p.extent:r.nodeExtent,w=Ua(b,k,Ai(p));x={...r.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(g=p.measured)==null?void 0:g.height},internals:{positionAbsolute:w,handleBounds:P6(p,x),z:D_(p,u,r.zIndexMode),userNode:p}},t.set(p.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(d=!1),p.parentId&&bx(x,t,n,i,o),h||(h=p.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:h}}function z6(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 bx(e,t,n,i,r){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:u,zIndexMode:d}=vx(xx,i),h=e.parentId,f=t.get(h);if(!f){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}z6(e,n),r&&!f.parentId&&f.internals.rootParentIndex===void 0&&d==="auto"&&(f.internals.rootParentIndex=++r.i,f.internals.z=f.internals.z+r.i*M6),r&&f.internals.rootParentIndex!==void 0&&(r.i=f.internals.rootParentIndex);const g=o&&!yx(d)?L_:0,{x:p,y:x,z:b}=L6(e,f,c,u,g,d),{positionAbsolute:k}=e.internals,w=p!==k.x||x!==k.y;(w||b!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:p,y:x}:k,z:b}})}function D_(e,t,n){const i=wi(e.zIndex)?e.zIndex:0;return yx(n)?i:i+(e.selected?t:0)}function L6(e,t,n,i,r,o){const{x:c,y:u}=t.internals.positionAbsolute,d=Ai(e),h=Lc(e,n),f=Ba(e.extent)?Ua(h,e.extent,d):h;let g=Ua({x:c+f.x,y:u+f.y},i,d);e.extent==="parent"&&(g=w_(g,d,t));const p=D_(e,r,o),x=t.internals.z??0;return{x:g.x,y:g.y,z:x>=p?x+1:p}}function kx(e,t,n,i=[0,0]){var c;const r=[],o=new Map;for(const u of e){const d=t.get(u.parentId);if(!d)continue;const h=((c=o.get(u.parentId))==null?void 0:c.expandedRect)??jc(d),f=S_(h,u.rect);o.set(u.parentId,{expandedRect:f,parent:d})}return o.size>0&&o.forEach(({expandedRect:u,parent:d},h)=>{var N;const f=d.internals.positionAbsolute,g=Ai(d),p=d.origin??i,x=u.x<f.x?Math.round(Math.abs(f.x-u.x)):0,b=u.y<f.y?Math.round(Math.abs(f.y-u.y)):0,k=Math.max(g.width,Math.round(u.width)),w=Math.max(g.height,Math.round(u.height)),j=(k-g.width)*p[0],E=(w-g.height)*p[1];(x>0||b>0||j||E)&&(r.push({id:h,type:"position",position:{x:d.position.x-x+j,y:d.position.y-b+E}}),(N=n.get(h))==null||N.forEach(C=>{e.some(L=>L.id===C.id)||r.push({id:C.id,type:"position",position:{x:C.position.x+x,y:C.position.y+b}})})),(g.width<u.width||g.height<u.height||x||b)&&r.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:k+(x?p[0]*x-j:0),height:w+(b?p[1]*b-E:0)}})}),r}function D6(e,t,n,i,r,o,c){const u=i==null?void 0:i.querySelector(".xyflow__viewport");let d=!1;if(!u)return{changes:[],updatedInternals:d};const h=[],f=window.getComputedStyle(u),{m22:g}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const x of e.values()){const b=t.get(x.id);if(!b)continue;if(b.hidden){t.set(b.id,{...b,internals:{...b.internals,handleBounds:void 0}}),d=!0;continue}const k=gx(x.nodeElement),w=b.measured.width!==k.width||b.measured.height!==k.height;if(!!(k.width&&k.height&&(w||!b.internals.handleBounds||x.force))){const E=x.nodeElement.getBoundingClientRect(),N=Ba(b.extent)?b.extent:o;let{positionAbsolute:C}=b.internals;if(b.parentId&&b.extent==="parent"){const $=t.get(b.parentId);$&&(C=w_(C,k,$))}else N&&(C=Ua(C,N,k));const L={...b,measured:k,internals:{...b.internals,positionAbsolute:C,handleBounds:{source:kk("source",x.nodeElement,E,g,b.id),target:kk("target",x.nodeElement,E,g,b.id)}}};t.set(b.id,L),b.parentId&&bx(L,t,n,{nodeOrigin:r,zIndexMode:c}),d=!0,w&&(h.push({id:b.id,type:"dimensions",dimensions:k}),b.expandParent&&b.parentId&&p.push({id:b.id,parentId:b.parentId,rect:jc(L,r)}))}}if(p.length>0){const x=kx(p,t,n,r);h.push(...x)}return{changes:h,updatedInternals:d}}async function F6({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,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],[r,o]],i);return!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2])}function Ck(e,t,n,i,r,o){let c=r;const u=i.get(c)||new Map;i.set(c,u.set(n,t)),c=`${r}-${e}`;const d=i.get(c)||new Map;if(i.set(c,d.set(n,t)),o){c=`${r}-${e}-${o}`;const h=i.get(c)||new Map;i.set(c,h.set(n,t))}}function F_(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:o,sourceHandle:c=null,targetHandle:u=null}=i,d={edgeId:i.id,source:r,target:o,sourceHandle:c,targetHandle:u},h=`${r}-${c}--${o}-${u}`,f=`${o}-${u}--${r}-${c}`;Ck("source",d,f,e,r,c),Ck("target",d,h,e,o,u),t.set(i.id,i)}}function U_(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:U_(n,t):!1}function Ak(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function U6(e,t,n,i){const r=new Map;for(const[o,c]of e)if((c.selected||c.id===i)&&(!c.parentId||!U_(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const u=e.get(o);u&&r.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 r}function Rm({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var c,u,d;const r=[];for(const[h,f]of t){const g=(c=n.get(h))==null?void 0:c.internals.userNode;g&&r.push({...g,position:f.position,dragging:i})}if(!e)return[r[0],r];const o=(u=n.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((d=t.get(e))==null?void 0:d.position)||o.position,dragging:i}:r[0],r]}function B6({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:n-r.distance.x,y:i-r.distance.y},c=Fc(o,t);return{x:c.x-o.x,y:c.y-o.y}}function H6({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let o={x:null,y:null},c=0,u=new Map,d=!1,h={x:0,y:0},f=null,g=!1,p=null,x=!1,b=!1,k=null;function w({noDragClassName:E,handleSelector:N,domNode:C,isSelectable:L,nodeId:$,nodeClickDistance:O=0}){p=Ms(C);function W({x:F,y:A}){const{nodeLookup:T,nodeExtent:M,snapGrid:P,snapToGrid:V,nodeOrigin:z,onNodeDrag:H,onSelectionDrag:G,onError:Z,updateNodePositions:Y}=t();o={x:F,y:A};let X=!1;const re=u.size>1,ee=re&&M?Qp(Dc(u)):null,te=re&&V?B6({dragItems:u,snapGrid:P,x:F,y:A}):null;for(const[ne,se]of u){if(!T.has(ne))continue;let oe={x:F-se.distance.x,y:A-se.distance.y};V&&(oe=te?{x:Math.round(oe.x+te.x),y:Math.round(oe.y+te.y)}:Fc(oe,P));let de=null;if(re&&M&&!se.extent&&ee){const{positionAbsolute:fe}=se.internals,xe=fe.x-ee.x+M[0][0],De=fe.x+se.measured.width-ee.x2+M[1][0],Me=fe.y-ee.y+M[0][1],Ce=fe.y+se.measured.height-ee.y2+M[1][1];de=[[xe,Me],[De,Ce]]}const{position:we,positionAbsolute:Se}=j_({nodeId:ne,nextPosition:oe,nodeLookup:T,nodeExtent:de||M,nodeOrigin:z,onError:Z});X=X||se.position.x!==we.x||se.position.y!==we.y,se.position=we,se.internals.positionAbsolute=Se}if(b=b||X,!!X&&(Y(u,!0),k&&(i||H||!$&&G))){const[ne,se]=Rm({nodeId:$,dragItems:u,nodeLookup:T});i==null||i(k,u,ne,se),H==null||H(k,ne,se),$||G==null||G(k,se)}}async function B(){if(!f)return;const{transform:F,panBy:A,autoPanSpeed:T,autoPanOnNodeDrag:M}=t();if(!M){d=!1,cancelAnimationFrame(c);return}const[P,V]=mx(h,f,T);(P!==0||V!==0)&&(o.x=(o.x??0)-P/F[2],o.y=(o.y??0)-V/F[2],await A({x:P,y:V})&&W(o)),c=requestAnimationFrame(B)}function U(F){var re;const{nodeLookup:A,multiSelectionActive:T,nodesDraggable:M,transform:P,snapGrid:V,snapToGrid:z,selectNodesOnDrag:H,onNodeDragStart:G,onSelectionDragStart:Z,unselectNodesAndEdges:Y}=t();g=!0,(!H||!L)&&!T&&$&&((re=A.get($))!=null&&re.selected||Y()),L&&H&&$&&(e==null||e($));const X=oc(F.sourceEvent,{transform:P,snapGrid:V,snapToGrid:z,containerBounds:f});if(o=X,u=U6(A,M,X,$),u.size>0&&(n||G||!$&&Z)){const[ee,te]=Rm({nodeId:$,dragItems:u,nodeLookup:A});n==null||n(F.sourceEvent,u,ee,te),G==null||G(F.sourceEvent,ee,te),$||Z==null||Z(F.sourceEvent,te)}}const D=s_().clickDistance(O).on("start",F=>{const{domNode:A,nodeDragThreshold:T,transform:M,snapGrid:P,snapToGrid:V}=t();f=(A==null?void 0:A.getBoundingClientRect())||null,x=!1,b=!1,k=F.sourceEvent,T===0&&U(F),o=oc(F.sourceEvent,{transform:M,snapGrid:P,snapToGrid:V,containerBounds:f}),h=Si(F.sourceEvent,f)}).on("drag",F=>{const{autoPanOnNodeDrag:A,transform:T,snapGrid:M,snapToGrid:P,nodeDragThreshold:V,nodeLookup:z}=t(),H=oc(F.sourceEvent,{transform:T,snapGrid:M,snapToGrid:P,containerBounds:f});if(k=F.sourceEvent,(F.sourceEvent.type==="touchmove"&&F.sourceEvent.touches.length>1||$&&!z.has($))&&(x=!0),!x){if(!d&&A&&g&&(d=!0,B()),!g){const G=Si(F.sourceEvent,f),Z=G.x-h.x,Y=G.y-h.y;Math.sqrt(Z*Z+Y*Y)>V&&U(F)}(o.x!==H.xSnapped||o.y!==H.ySnapped)&&u&&g&&(h=Si(F.sourceEvent,f),W(H))}}).on("end",F=>{if(!g||x){x&&u.size>0&&t().updateNodePositions(u,!1);return}if(d=!1,g=!1,cancelAnimationFrame(c),u.size>0){const{nodeLookup:A,updateNodePositions:T,onNodeDragStop:M,onSelectionDragStop:P}=t();if(b&&(T(u,!1),b=!1),r||M||!$&&P){const[V,z]=Rm({nodeId:$,dragItems:u,nodeLookup:A,dragging:!1});r==null||r(F.sourceEvent,u,V,z),M==null||M(F.sourceEvent,V,z),$||P==null||P(F.sourceEvent,z)}}}).filter(F=>{const A=F.target;return!F.button&&(!E||!Ak(A,`.${E}`,C))&&(!N||Ak(A,N,C))});p.call(D)}function j(){p==null||p.on(".drag",null)}return{update:w,destroy:j}}function Z6(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())Pd(r,jc(o))>0&&i.push(o);return i}const W6=250;function V6(e,t,n,i){var u,d;let r=[],o=1/0;const c=Z6(e,n,t+W6);for(const h of c){const f=[...((u=h.internals.handleBounds)==null?void 0:u.source)??[],...((d=h.internals.handleBounds)==null?void 0:d.target)??[]];for(const g of f){if(i.nodeId===g.nodeId&&i.type===g.type&&i.id===g.id)continue;const{x:p,y:x}=Ha(h,g,g.position,!0),b=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(x-e.y,2));b>t||(b<o?(r=[{...g,x:p,y:x}],o=b):b===o&&r.push({...g,x:p,y:x}))}}if(!r.length)return null;if(r.length>1){const h=i.type==="source"?"target":"source";return r.find(f=>f.type===h)??r[0]}return r[0]}function B_(e,t,n,i,r,o=!1){var h,f,g;const c=i.get(e);if(!c)return null;const u=r==="strict"?(h=c.internals.handleBounds)==null?void 0:h[t]:[...((f=c.internals.handleBounds)==null?void 0:f.source)??[],...((g=c.internals.handleBounds)==null?void 0:g.target)??[]],d=(n?u==null?void 0:u.find(p=>p.id===n):u==null?void 0:u[0])??null;return d&&o?{...d,...Ha(c,d,d.position,!0)}:d}function H_(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function q6(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Z_=()=>!0;function G6(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:c,domNode:u,nodeLookup:d,lib:h,autoPanOnConnect:f,flowId:g,panBy:p,cancelConnection:x,onConnectStart:b,onConnect:k,onConnectEnd:w,isValidConnection:j=Z_,onReconnectEnd:E,updateConnection:N,getTransform:C,getFromHandle:L,autoPanSpeed:$,dragThreshold:O=1,handleDomNode:W}){const B=T_(e.target);let U=0,D;const{x:F,y:A}=Si(e),T=H_(o,W),M=u==null?void 0:u.getBoundingClientRect();let P=!1;if(!M||!T)return;const V=B_(r,T,i,d,t);if(!V)return;let z=Si(e,M),H=!1,G=null,Z=!1,Y=null;function X(){if(!f||!M)return;const[we,Se]=mx(z,M,$);p({x:we,y:Se}),U=requestAnimationFrame(X)}const re={...V,nodeId:r,type:T,position:V.position},ee=d.get(r);let ne={inProgress:!0,isValid:null,from:Ha(ee,re,Je.Left,!0),fromHandle:re,fromPosition:re.position,fromNode:ee,to:z,toHandle:null,toPosition:xk[re.position],toNode:null,pointer:z};function se(){P=!0,N(ne),b==null||b(e,{nodeId:r,handleId:i,handleType:T})}O===0&&se();function oe(we){if(!P){const{x:Ce,y:Fe}=Si(we),ot=Ce-F,ht=Fe-A;if(!(ot*ot+ht*ht>O*O))return;se()}if(!L()||!re){de(we);return}const Se=C();z=Si(we,M),D=V6(Uc(z,Se,!1,[1,1]),n,d,re),H||(X(),H=!0);const fe=W_(we,{handle:D,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:c?"target":"source",isValidConnection:j,doc:B,lib:h,flowId:g,nodeLookup:d});Y=fe.handleDomNode,G=fe.connection,Z=q6(!!D,fe.isValid);const xe=d.get(r),De=xe?Ha(xe,re,Je.Left,!0):ne.from,Me={...ne,from:De,isValid:Z,to:fe.toHandle&&Z?Yo({x:fe.toHandle.x,y:fe.toHandle.y},Se):z,toHandle:fe.toHandle,toPosition:Z&&fe.toHandle?fe.toHandle.position:xk[re.position],toNode:fe.toHandle?d.get(fe.toHandle.nodeId):null,pointer:z};N(Me),ne=Me}function de(we){if(!("touches"in we&&we.touches.length>0)){if(P){(D||Y)&&G&&Z&&(k==null||k(G));const{inProgress:Se,...fe}=ne,xe={...fe,toPosition:ne.toHandle?ne.toPosition:null};w==null||w(we,xe),o&&(E==null||E(we,xe))}x(),cancelAnimationFrame(U),H=!1,Z=!1,G=null,Y=null,B.removeEventListener("mousemove",oe),B.removeEventListener("mouseup",de),B.removeEventListener("touchmove",oe),B.removeEventListener("touchend",de)}}B.addEventListener("mousemove",oe),B.addEventListener("mouseup",de),B.addEventListener("touchmove",oe),B.addEventListener("touchend",de)}function W_(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:o,doc:c,lib:u,flowId:d,isValidConnection:h=Z_,nodeLookup:f}){const g=o==="target",p=t?c.querySelector(`.${u}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x,y:b}=Si(e),k=c.elementFromPoint(x,b),w=k!=null&&k.classList.contains(`${u}-flow__handle`)?k:p,j={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const E=H_(void 0,w),N=w.getAttribute("data-nodeid"),C=w.getAttribute("data-handleid"),L=w.classList.contains("connectable"),$=w.classList.contains("connectableend");if(!N||!E)return j;const O={source:g?N:i,sourceHandle:g?C:r,target:g?i:N,targetHandle:g?r:C};j.connection=O;const B=L&&$&&(n===Go.Strict?g&&E==="source"||!g&&E==="target":N!==i||C!==r);j.isValid=B&&h(O),j.toHandle=B_(N,E,C,f,n,!0)}return j}const ng={onPointerDown:G6,isValid:W_};function K6({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=Ms(e);function o({translateExtent:u,width:d,height:h,zoomStep:f=1,pannable:g=!0,zoomable:p=!0,inversePan:x=!1}){const b=N=>{if(N.sourceEvent.type!=="wheel"||!t)return;const C=n(),L=N.sourceEvent.ctrlKey&&wc()?10:1,$=-N.sourceEvent.deltaY*(N.sourceEvent.deltaMode===1?.05:N.sourceEvent.deltaMode?1:.002)*f,O=C[2]*Math.pow(2,$*L);t.scaleTo(O)};let k=[0,0];const w=N=>{(N.sourceEvent.type==="mousedown"||N.sourceEvent.type==="touchstart")&&(k=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY])},j=N=>{const C=n();if(N.sourceEvent.type!=="mousemove"&&N.sourceEvent.type!=="touchmove"||!t)return;const L=[N.sourceEvent.clientX??N.sourceEvent.touches[0].clientX,N.sourceEvent.clientY??N.sourceEvent.touches[0].clientY],$=[L[0]-k[0],L[1]-k[1]];k=L;const O=i()*Math.max(C[2],Math.log(C[2]))*(x?-1:1),W={x:C[0]-$[0]*O,y:C[1]-$[1]*O},B=[[0,0],[d,h]];t.setViewportConstrained({x:W.x,y:W.y,zoom:C[2]},B,u)},E=v_().on("start",w).on("zoom",g?j:null).on("zoom.wheel",p?b:null);r.call(E,{})}function c(){r.on("zoom",null)}return{update:o,destroy:c,pointer:bi}}const oh=e=>({x:e.x,y:e.y,zoom:e.k}),Om=({x:e,y:t,zoom:n})=>ih.translate(e,t).scale(n),Hr=(e,t)=>e.target.closest(`.${t}`),V_=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Y6=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Pm=(e,t=0,n=Y6,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},q_=e=>{const t=e.ctrlKey&&wc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function X6({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:c,onPanZoomStart:u,onPanZoom:d,onPanZoomEnd:h}){return f=>{if(Hr(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const g=n.property("__zoom").k||1;if(f.ctrlKey&&c){const w=bi(f),j=q_(f),E=g*Math.pow(2,j);i.scaleTo(n,E,w,f);return}const p=f.deltaMode===1?20:1;let x=r===Pa.Vertical?0:f.deltaX*p,b=r===Pa.Horizontal?0:f.deltaY*p;!wc()&&f.shiftKey&&r!==Pa.Vertical&&(x=f.deltaY*p,b=0),i.translateBy(n,-(x/g)*o,-(b/g)*o,{internal:!0});const k=oh(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?d==null||d(f,k):(e.isPanScrolling=!0,u==null||u(f,k)),e.panScrollTimeout=setTimeout(()=>{h==null||h(f,k),e.isPanScrolling=!1},150)}}function Q6({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const o=i.type==="wheel",c=!t&&o&&!i.ctrlKey,u=Hr(i,e);if(i.ctrlKey&&o&&u&&i.preventDefault(),c||u)return null;i.preventDefault(),n.call(this,i,r)}}function J6({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,c,u;if((o=i.sourceEvent)!=null&&o.internal)return;const r=oh(i.transform);e.mouseButton=((c=i.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((u=i.sourceEvent)==null?void 0:u.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function eB({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return o=>{var c,u;e.usedRightMouseButton=!!(n&&V_(t,e.mouseButton??0)),(c=o.sourceEvent)!=null&&c.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((u=o.sourceEvent)!=null&&u.internal)&&(r==null||r(o.sourceEvent,oh(o.transform)))}}function tB({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return c=>{var u;if(!((u=c.sourceEvent)!=null&&u.internal)&&(e.isZoomingOrPanning=!1,o&&V_(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const d=oh(c.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(c.sourceEvent,d)},n?150:0)}}}function nB({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:i,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:c,userSelectionActive:u,noWheelClassName:d,noPanClassName:h,lib:f,connectionInProgress:g}){return p=>{var j;const x=t||n,b=i&&p.ctrlKey,k=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(Hr(p,`${f}-flow__node`)||Hr(p,`${f}-flow__edge`)||Hr(p,`${f}-flow__selection`)||Hr(p,`${f}-flow__nodesselection`)))return!0;if(!r&&!x&&!o&&!c&&!i||u||g&&!k||Hr(p,d)&&k||Hr(p,h)&&(!k||o&&k&&!t)||!i&&p.ctrlKey&&k)return!1;if(!i&&p.type==="touchstart"&&((j=p.touches)==null?void 0:j.length)>1)return p.preventDefault(),!1;if(!x&&!o&&!b&&k||!r&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(r)&&!r.includes(p.button)&&p.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||k||e)&&w}}function sB({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:c,onPanZoomEnd:u,onDraggingChange:d}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect();let g=[[0,0],[f.width,f.height]];const p=typeof ResizeObserver<"u"?new ResizeObserver(A=>{const T=A[0];T&&(g=[[0,0],[T.contentRect.width,T.contentRect.height]])}):null;p==null||p.observe(e);const x=v_().extent(()=>g).scaleExtent([t,n]).translateExtent(i),b=Ms(e).call(x);C({x:r.x,y:r.y,zoom:Ko(r.zoom,t,n)},[[0,0],[f.width,f.height]],i);const k=b.on("wheel.zoom"),w=b.on("dblclick.zoom");x.wheelDelta(q_);async function j(A,T){return b?new Promise(M=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?ac:hd).transform(Pm(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>M(!0)),A)}):!1}function E({noWheelClassName:A,noPanClassName:T,onPaneContextMenu:M,userSelectionActive:P,panOnScroll:V,panOnDrag:z,panOnScrollMode:H,panOnScrollSpeed:G,preventScrolling:Z,zoomOnPinch:Y,zoomOnScroll:X,zoomOnDoubleClick:re,panActivationKeyPressed:ee=!1,zoomActivationKeyPressed:te,lib:ne,onTransformChange:se,connectionInProgress:oe,paneClickDistance:de,selectionOnDrag:we}){P&&!h.isZoomingOrPanning&&N();const Se=V&&!te&&!P;x.clickDistance(we?1/0:!wi(de)||de<0?0:de);const fe=Se?X6({zoomPanValues:h,noWheelClassName:A,d3Selection:b,d3Zoom:x,panOnScrollMode:H,panOnScrollSpeed:G,zoomOnPinch:Y,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:u}):Q6({noWheelClassName:A,preventScrolling:Z,d3ZoomHandler:k});b.on("wheel.zoom",fe,{passive:!1});const xe=J6({zoomPanValues:h,onDraggingChange:d,onPanZoomStart:c});x.on("start",xe);const De=eB({zoomPanValues:h,panOnDrag:z,onPaneContextMenu:!!M,onPanZoom:o,onTransformChange:se});x.on("zoom",De);const Me=tB({zoomPanValues:h,panOnDrag:z,panOnScroll:V,onPaneContextMenu:M,onPanZoomEnd:u,onDraggingChange:d});x.on("end",Me);const Ce=nB({panActivationKeyPressed:ee,zoomActivationKeyPressed:te,panOnDrag:z,zoomOnScroll:X,panOnScroll:V,zoomOnDoubleClick:re,zoomOnPinch:Y,userSelectionActive:P,noPanClassName:T,noWheelClassName:A,lib:ne,connectionInProgress:oe});x.filter(Ce),re?b.on("dblclick.zoom",w):b.on("dblclick.zoom",null)}function N(){x.on("zoom",null)}async function C(A,T,M){const P=Om(A),V=x==null?void 0:x.constrain()(P,T,M);return V&&await j(V),V}async function L(A,T){const M=Om(A);return await j(M,T),M}function $(A){if(b){const T=Om(A),M=b.property("__zoom");(M.k!==A.zoom||M.x!==A.x||M.y!==A.y)&&(x==null||x.transform(b,T,null,{sync:!0}))}}function O(){const A=b?x_(b.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}async function W(A,T){return b?new Promise(M=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?ac:hd).scaleTo(Pm(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>M(!0)),A)}):!1}async function B(A,T){return b?new Promise(M=>{x==null||x.interpolate((T==null?void 0:T.interpolate)==="linear"?ac:hd).scaleBy(Pm(b,T==null?void 0:T.duration,T==null?void 0:T.ease,()=>M(!0)),A)}):!1}function U(A){x==null||x.scaleExtent(A)}function D(A){x==null||x.translateExtent(A)}function F(A){const T=!wi(A)||A<0?0:A;x==null||x.clickDistance(T)}return{update:E,destroy:N,setViewport:L,setViewportConstrained:C,getViewport:O,scaleTo:W,scaleBy:B,setScaleExtent:U,setTranslateExtent:D,syncViewport:$,setClickDistance:F}}var Xo;(function(e){e.Line="line",e.Handle="handle"})(Xo||(Xo={}));function iB({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){const c=e-t,u=n-i,d=[c>0?1:c<0?-1:0,u>0?1:u<0?-1:0];return c&&r&&(d[0]=d[0]*-1),u&&o&&(d[1]=d[1]*-1),d}function Ik(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Dr(e,t){return Math.max(0,t-e)}function Fr(e,t){return Math.max(0,e-t)}function td(e,t,n){return Math.max(0,t-e,e-n)}function Tk(e,t){return e?!t:t}function rB(e,t,n,i,r,o,c,u){let{affectsX:d,affectsY:h}=t;const{isHorizontal:f,isVertical:g}=t,p=f&&g,{xSnapped:x,ySnapped:b}=n,{minWidth:k,maxWidth:w,minHeight:j,maxHeight:E}=i,{x:N,y:C,width:L,height:$,aspectRatio:O}=e;let W=Math.floor(f?x-e.pointerX:0),B=Math.floor(g?b-e.pointerY:0);const U=L+(d?-W:W),D=$+(h?-B:B),F=-o[0]*L,A=-o[1]*$;let T=td(U,k,w),M=td(D,j,E);if(c){let z=0,H=0;d&&W<0?z=Dr(N+W+F,c[0][0]):!d&&W>0&&(z=Fr(N+U+F,c[1][0])),h&&B<0?H=Dr(C+B+A,c[0][1]):!h&&B>0&&(H=Fr(C+D+A,c[1][1])),T=Math.max(T,z),M=Math.max(M,H)}if(u){let z=0,H=0;d&&W>0?z=Fr(N+W,u[0][0]):!d&&W<0&&(z=Dr(N+U,u[1][0])),h&&B>0?H=Fr(C+B,u[0][1]):!h&&B<0&&(H=Dr(C+D,u[1][1])),T=Math.max(T,z),M=Math.max(M,H)}if(r){if(f){const z=td(U/O,j,E)*O;if(T=Math.max(T,z),c){let H=0;!d&&!h||d&&!h&&p?H=Fr(C+A+U/O,c[1][1])*O:H=Dr(C+A+(d?W:-W)/O,c[0][1])*O,T=Math.max(T,H)}if(u){let H=0;!d&&!h||d&&!h&&p?H=Dr(C+U/O,u[1][1])*O:H=Fr(C+(d?W:-W)/O,u[0][1])*O,T=Math.max(T,H)}}if(g){const z=td(D*O,k,w)/O;if(M=Math.max(M,z),c){let H=0;!d&&!h||h&&!d&&p?H=Fr(N+D*O+F,c[1][0])/O:H=Dr(N+(h?B:-B)*O+F,c[0][0])/O,M=Math.max(M,H)}if(u){let H=0;!d&&!h||h&&!d&&p?H=Dr(N+D*O,u[1][0])/O:H=Fr(N+(h?B:-B)*O,u[0][0])/O,M=Math.max(M,H)}}}B=B+(B<0?M:-M),W=W+(W<0?T:-T),r&&(p?U>D*O?B=(Tk(d,h)?-W:W)/O:W=(Tk(d,h)?-B:B)*O:f?(B=W/O,h=d):(W=B*O,d=h));const P=d?N+W:N,V=h?C+B:C;return{width:L+(d?-W:W),height:$+(h?-B:B),x:o[0]*W*(d?-1:1)+P,y:o[1]*B*(h?-1:1)+V}}const G_={width:0,height:0,x:0,y:0},aB={...G_,pointerX:0,pointerY:0,aspectRatio:1};function oB(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,c=e.measured.height??0,u=n[0]*o,d=n[1]*c;return[[i-u,r-d],[i+o-u,r+c-d]]}function lB({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const o=Ms(e);let c={controlDirection:Ik("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:h,boundaries:f,keepAspectRatio:g,resizeDirection:p,onResizeStart:x,onResize:b,onResizeEnd:k,shouldResize:w}){let j={...G_},E={...aB};c={boundaries:f,resizeDirection:p,keepAspectRatio:g,controlDirection:Ik(h)};let N,C=null,L=[],$,O,W,B=!1;const U=s_().on("start",D=>{const{nodeLookup:F,transform:A,snapGrid:T,snapToGrid:M,nodeOrigin:P,paneDomNode:V}=n();if(N=F.get(t),!N)return;C=(V==null?void 0:V.getBoundingClientRect())??null;const{xSnapped:z,ySnapped:H}=oc(D.sourceEvent,{transform:A,snapGrid:T,snapToGrid:M,containerBounds:C});j={width:N.measured.width??0,height:N.measured.height??0,x:N.position.x??0,y:N.position.y??0},E={...j,pointerX:z,pointerY:H,aspectRatio:j.width/j.height},$=void 0,O=Ba(N.extent)?N.extent:void 0,N.parentId&&(N.extent==="parent"||N.expandParent)&&($=F.get(N.parentId)),$&&N.extent==="parent"&&(O=[[0,0],[$.measured.width,$.measured.height]]),L=[],W=void 0;for(const[G,Z]of F)if(Z.parentId===t&&(L.push({id:G,position:{...Z.position},extent:Z.extent}),Z.extent==="parent"||Z.expandParent)){const Y=oB(Z,N,Z.origin??P);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}x==null||x(D,{...j})}).on("drag",D=>{const{transform:F,snapGrid:A,snapToGrid:T,nodeOrigin:M}=n(),P=oc(D.sourceEvent,{transform:F,snapGrid:A,snapToGrid:T,containerBounds:C}),V=[];if(!N)return;const{x:z,y:H,width:G,height:Z}=j,Y={},X=N.origin??M,{width:re,height:ee,x:te,y:ne}=rB(E,c.controlDirection,P,c.boundaries,c.keepAspectRatio,X,O,W),se=re!==G,oe=ee!==Z,de=te!==z&&se,we=ne!==H&&oe;if(!de&&!we&&!se&&!oe)return;if((de||we||X[0]===1||X[1]===1)&&(Y.x=de?te:j.x,Y.y=we?ne:j.y,j.x=Y.x,j.y=Y.y,L.length>0)){const De=te-z,Me=ne-H;for(const Ce of L)Ce.position={x:Ce.position.x-De+X[0]*(re-G),y:Ce.position.y-Me+X[1]*(ee-Z)},V.push(Ce)}if((se||oe)&&(Y.width=se&&(!c.resizeDirection||c.resizeDirection==="horizontal")?re:j.width,Y.height=oe&&(!c.resizeDirection||c.resizeDirection==="vertical")?ee:j.height,j.width=Y.width,j.height=Y.height),$&&N.expandParent){const De=X[0]*(Y.width??0);Y.x&&Y.x<De&&(j.x=De,E.x=E.x-(Y.x-De));const Me=X[1]*(Y.height??0);Y.y&&Y.y<Me&&(j.y=Me,E.y=E.y-(Y.y-Me))}const Se=iB({width:j.width,prevWidth:G,height:j.height,prevHeight:Z,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),fe={...j,direction:Se};(w==null?void 0:w(D,fe))!==!1&&(B=!0,b==null||b(D,fe),i(Y,V))}).on("end",D=>{B&&(k==null||k(D,{...j}),r==null||r({...j}),B=!1)});o.call(U)}function d(){o.on(".drag",null)}return{update:u,destroy:d}}var zm={exports:{}},Lm={},Dm={exports:{}},Fm={};/**
210
+ * @license React
211
+ * use-sync-external-store-shim.production.js
212
+ *
213
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
214
+ *
215
+ * This source code is licensed under the MIT license found in the
216
+ * LICENSE file in the root directory of this source tree.
217
+ */var $k;function cB(){if($k)return Fm;$k=1;var e=Ic();function t(g,p){return g===p&&(g!==0||1/g===1/p)||g!==g&&p!==p}var n=typeof Object.is=="function"?Object.is:t,i=e.useState,r=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(g,p){var x=p(),b=i({inst:{value:x,getSnapshot:p}}),k=b[0].inst,w=b[1];return o(function(){k.value=x,k.getSnapshot=p,d(k)&&w({inst:k})},[g,x,p]),r(function(){return d(k)&&w({inst:k}),g(function(){d(k)&&w({inst:k})})},[g]),c(x),x}function d(g){var p=g.getSnapshot;g=g.value;try{var x=p();return!n(g,x)}catch{return!0}}function h(g,p){return p()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:u;return Fm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Fm}var Mk;function uB(){return Mk||(Mk=1,Dm.exports=cB()),Dm.exports}/**
218
+ * @license React
219
+ * use-sync-external-store-shim/with-selector.production.js
220
+ *
221
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
222
+ *
223
+ * This source code is licensed under the MIT license found in the
224
+ * LICENSE file in the root directory of this source tree.
225
+ */var Rk;function dB(){if(Rk)return Lm;Rk=1;var e=Ic(),t=uB();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var i=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,d=e.useDebugValue;return Lm.useSyncExternalStoreWithSelector=function(h,f,g,p,x){var b=o(null);if(b.current===null){var k={hasValue:!1,value:null};b.current=k}else k=b.current;b=u(function(){function j($){if(!E){if(E=!0,N=$,$=p($),x!==void 0&&k.hasValue){var O=k.value;if(x(O,$))return C=O}return C=$}if(O=C,i(N,$))return O;var W=p($);return x!==void 0&&x(O,W)?(N=$,O):(N=$,C=W)}var E=!1,N,C,L=g===void 0?null:g;return[function(){return j(f())},L===null?void 0:function(){return j(L())}]},[f,g,p,x]);var w=r(h,b[0],b[1]);return c(function(){k.hasValue=!0,k.value=w},[w]),d(w),w},Lm}var Ok;function hB(){return Ok||(Ok=1,zm.exports=dB()),zm.exports}var fB=hB();const mB=pg(fB),pB={},Pk=e=>{let t;const n=new Set,i=(f,g)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const x=t;t=g??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(b=>b(t,x))}},r=()=>t,d={setState:i,getState:r,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(pB?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=t=e(i,r,d);return d},gB=e=>e?Pk(e):Pk,{useDebugValue:xB}=RO,{useSyncExternalStoreWithSelector:vB}=mB,yB=e=>e;function K_(e,t=yB,n){const i=vB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return xB(i),i}const zk=(e,t)=>{const n=gB(e),i=(r,o=t)=>K_(n,r,o);return Object.assign(i,n),i},bB=(e,t)=>e?zk(e,t):zk;function sn(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[i,r]of e)if(!Object.is(r,t.get(i)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(t,i)||!Object.is(e[i],t[i]))return!1;return!0}const lh=y.createContext(null),kB=lh.Provider,Y_=Ei.error001("react");function St(e,t){const n=y.useContext(lh);if(n===null)throw new Error(Y_);return K_(n,e,t)}function qt(){const e=y.useContext(lh);if(e===null)throw new Error(Y_);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Lk={display:"none"},NB={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},X_="react-flow__node-desc",Q_="react-flow__edge-desc",jB="react-flow__aria-live",wB=e=>e.ariaLiveMessage,SB=e=>e.ariaLabelConfig;function _B({rfId:e}){const t=St(wB);return s.jsx("div",{id:`${jB}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:NB,children:t})}function EB({rfId:e,disableKeyboardA11y:t}){const n=St(SB);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${X_}-${e}`,style:Lk,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${Q_}-${e}`,style:Lk,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(_B,{rfId:e})]})}const ch=y.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},o)=>{const c=`${e}`.split("-");return s.jsx("div",{className:jn(["react-flow__panel",n,...c]),style:i,ref:o,...r,children:t})});ch.displayName="Panel";const Dk="https://reactflow.dev?utm_source=attribution";function CB({proOptions:e,position:t="bottom-right"}){return y.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:s.jsx(ch,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Dk}`,children:s.jsx("a",{href:Dk,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const AB=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},nd=e=>e.id;function IB(e,t){return sn(e.selectedNodes.map(nd),t.selectedNodes.map(nd))&&sn(e.selectedEdges.map(nd),t.selectedEdges.map(nd))}function TB({onSelectionChange:e}){const t=qt(),{selectedNodes:n,selectedEdges:i}=St(AB,IB);return y.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[n,i,e]),null}const $B=e=>!!e.onSelectionChangeHandlers;function MB({onSelectionChange:e}){const t=St($B);return e||t?s.jsx(TB,{onSelectionChange:e}):null}const J_=[0,0],RB={x:0,y:0,zoom:1},OB=["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"],Fk=[...OB,"rfId"],PB=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}),Uk={translateExtent:kc,nodeOrigin:J_,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function zB(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:c,reset:u,setDefaultNodesAndEdges:d}=St(PB,sn),h=qt();y.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{f.current=Uk,u()}),[]);const f=y.useRef(Uk);return y.useEffect(()=>{for(const g of Fk){const p=e[g],x=f.current[g];p!==x&&(typeof e[g]>"u"||(g==="nodes"?t(p):g==="edges"?n(p):g==="minZoom"?i(p):g==="maxZoom"?r(p):g==="translateExtent"?o(p):g==="nodeExtent"?c(p):g==="ariaLabelConfig"?h.setState({ariaLabelConfig:k6(p)}):g==="fitView"?h.setState({fitViewQueued:p}):g==="fitViewOptions"?h.setState({fitViewOptions:p}):h.setState({[g]:p})))}f.current=e},Fk.map(g=>e[g])),null}function Bk(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function LB(e){var i;const[t,n]=y.useState(e==="system"?null:e);return y.useEffect(()=>{if(e!=="system"){n(e);return}const r=Bk(),o=()=>n(r!=null&&r.matches?"dark":"light");return o(),r==null||r.addEventListener("change",o),()=>{r==null||r.removeEventListener("change",o)}},[e]),t!==null?t:(i=Bk())!=null&&i.matches?"dark":"light"}const Hk=typeof document<"u"?document:null;function Sc(e=null,t={target:Hk,actInsideInputWithModifier:!0}){const[n,i]=y.useState(!1),r=y.useRef(!1),o=y.useRef(new Set([])),[c,u]=y.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(g=>typeof g=="string").map(g=>g.replace(/\+/g,`
226
+ `).replace(`
227
+
228
+ `,`
229
+ +`).split(`
230
+ `)),f=h.reduce((g,p)=>g.concat(...p),[]);return[h,f]}return[[],[]]},[e]);return y.useEffect(()=>{const d=(t==null?void 0:t.target)??Hk,h=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=x=>{var w,j;if(r.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!r.current||r.current&&!h)&&$_(x))return!1;const k=Wk(x.code,u);if(o.current.add(x[k]),Zk(c,o.current,!1)){const E=((j=(w=x.composedPath)==null?void 0:w.call(x))==null?void 0:j[0])||x.target,N=(E==null?void 0:E.nodeName)==="BUTTON"||(E==null?void 0:E.nodeName)==="A";t.preventDefault!==!1&&(r.current||!N)&&x.preventDefault(),i(!0)}},g=x=>{const b=Wk(x.code,u);Zk(c,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(x[b]),x.key==="Meta"&&o.current.clear(),r.current=!1},p=()=>{o.current.clear(),i(!1)};return d==null||d.addEventListener("keydown",f),d==null||d.addEventListener("keyup",g),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{d==null||d.removeEventListener("keydown",f),d==null||d.removeEventListener("keyup",g),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,i]),n}function Zk(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function Wk(e,t){return t.includes(e)?"code":"key"}const DB=()=>{const e=qt();return y.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:i}=e.getState();return i?i.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,o],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??o},n),!0):!1},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:o,maxZoom:c,panZoom:u}=e.getState(),d=px(t,i,r,o,c,(n==null?void 0:n.padding)??.1);return u?(await u.setViewport(d,{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:i,snapGrid:r,snapToGrid:o,domNode:c}=e.getState();if(!c)return t;const{x:u,y:d}=c.getBoundingClientRect(),h={x:t.x-u,y:t.y-d},f=n.snapGrid??r,g=n.snapToGrid??o;return Uc(h,i,g,f)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),c=Yo(t,n);return{x:c.x+r,y:c.y+o}}}),[])};function eE(e,t){const n=[],i=new Map,r=[];for(const o of e)if(o.type==="add"){r.push(o);continue}else if(o.type==="remove"||o.type==="replace")i.set(o.id,[o]);else{const c=i.get(o.id);c?c.push(o):i.set(o.id,[o])}for(const o of t){const c=i.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 d of c)FB(d,u);n.push(u)}return r.length&&r.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function FB(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 UB(e,t){return eE(e,t)}function BB(e,t){return eE(e,t)}function Na(e,t){return{id:e,type:"select",selected:t}}function Eo(e,t=new Set,n=!1){const i=[];for(const[r,o]of e){const c=t.has(r);!(o.selected===void 0&&!c)&&o.selected!==c&&(n&&(o.selected=c),i.push(Na(o.id,c)))}return i}function Vk({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const u=t.get(c.id),d=((r=u==null?void 0:u.internals)==null?void 0:r.userNode)??u;d!==void 0&&d!==c&&n.push({id:c.id,item:c,type:"replace"}),d===void 0&&n.push({item:c,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function qk(e){return{id:e.id,type:"remove"}}const HB=E_();function ZB(e,t,n={}){return E6(e,t,{...n,onError:n.onError??HB})}const Gk=e=>h6(e),WB=e=>N_(e);function tE(e){return y.forwardRef(e)}const nE=typeof window<"u"?y.useLayoutEffect:y.useEffect;function Kk(e){const[t,n]=y.useState(BigInt(0)),[i]=y.useState(()=>VB(()=>n(r=>r+BigInt(1))));return nE(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function VB(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const sE=y.createContext(null);function qB({children:e}){const t=qt(),n=y.useCallback(u=>{const{nodes:d=[],setNodes:h,hasDefaultNodes:f,onNodesChange:g,nodeLookup:p,fitViewQueued:x,onNodesChangeMiddlewareMap:b}=t.getState();let k=d;for(const j of u)k=typeof j=="function"?j(k):j;let w=Vk({items:k,lookup:p});for(const j of b.values())w=j(w);f&&h(k),w.length>0?g==null||g(w):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:j,nodes:E,setNodes:N}=t.getState();j&&N(E)})},[]),i=Kk(n),r=y.useCallback(u=>{const{edges:d=[],setEdges:h,hasDefaultEdges:f,onEdgesChange:g,edgeLookup:p}=t.getState();let x=d;for(const b of u)x=typeof b=="function"?b(x):b;f?h(x):g&&g(Vk({items:x,lookup:p}))},[]),o=Kk(r),c=y.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return s.jsx(sE.Provider,{value:c,children:e})}function GB(){const e=y.useContext(sE);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const KB=e=>!!e.panZoom;function Nx(){const e=DB(),t=qt(),n=GB(),i=St(KB),r=y.useMemo(()=>{const o=g=>t.getState().nodeLookup.get(g),c=g=>{n.nodeQueue.push(g)},u=g=>{n.edgeQueue.push(g)},d=g=>{var j,E;const{nodeLookup:p,nodeOrigin:x}=t.getState(),b=Gk(g)?g:p.get(g.id),k=b.parentId?A_(b.position,b.measured,b.parentId,p,x):b.position,w={...b,position:k,width:((j=b.measured)==null?void 0:j.width)??b.width,height:((E=b.measured)==null?void 0:E.height)??b.height};return jc(w)},h=(g,p,x={replace:!1})=>{c(b=>b.map(k=>{if(k.id===g){const w=typeof p=="function"?p(k):p;return x.replace&&Gk(w)?w:{...k,...w}}return k}))},f=(g,p,x={replace:!1})=>{u(b=>b.map(k=>{if(k.id===g){const w=typeof p=="function"?p(k):p;return x.replace&&WB(w)?w:{...k,...w}}return k}))};return{getNodes:()=>t.getState().nodes.map(g=>({...g})),getNode:g=>{var p;return(p=o(g))==null?void 0:p.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:g=[]}=t.getState();return g.map(p=>({...p}))},getEdge:g=>t.getState().edgeLookup.get(g),setNodes:c,setEdges:u,addNodes:g=>{const p=Array.isArray(g)?g:[g];n.nodeQueue.push(x=>[...x,...p])},addEdges:g=>{const p=Array.isArray(g)?g:[g];n.edgeQueue.push(x=>[...x,...p])},toObject:()=>{const{nodes:g=[],edges:p=[],transform:x}=t.getState(),[b,k,w]=x;return{nodes:g.map(j=>({...j})),edges:p.map(j=>({...j})),viewport:{x:b,y:k,zoom:w}}},deleteElements:async({nodes:g=[],edges:p=[]})=>{const{nodes:x,edges:b,onNodesDelete:k,onEdgesDelete:w,triggerNodeChanges:j,triggerEdgeChanges:E,onDelete:N,onBeforeDelete:C}=t.getState(),{nodes:L,edges:$}=await x6({nodesToRemove:g,edgesToRemove:p,nodes:x,edges:b,onBeforeDelete:C}),O=$.length>0,W=L.length>0;if(O){const B=$.map(qk);w==null||w($),E(B)}if(W){const B=L.map(qk);k==null||k(L),j(B)}return(W||O)&&(N==null||N({nodes:L,edges:$})),{deletedNodes:L,deletedEdges:$}},getIntersectingNodes:(g,p=!0,x)=>{const b=yk(g),k=b?g:d(g),w=x!==void 0;return k?(x||t.getState().nodes).filter(j=>{const E=t.getState().nodeLookup.get(j.id);if(E&&!b&&(j.id===g.id||!E.internals.positionAbsolute))return!1;const N=jc(w?j:E),C=Pd(N,k);return p&&C>0||C>=N.width*N.height||C>=k.width*k.height}):[]},isNodeIntersecting:(g,p,x=!0)=>{const k=yk(g)?g:d(g);if(!k)return!1;const w=Pd(k,p);return x&&w>0||w>=p.width*p.height||w>=k.width*k.height},updateNode:h,updateNodeData:(g,p,x={replace:!1})=>{h(g,b=>{const k=typeof p=="function"?p(b):p;return x.replace?{...b,data:k}:{...b,data:{...b.data,...k}}},x)},updateEdge:f,updateEdgeData:(g,p,x={replace:!1})=>{f(g,b=>{const k=typeof p=="function"?p(b):p;return x.replace?{...b,data:k}:{...b,data:{...b.data,...k}}},x)},getNodesBounds:g=>{const{nodeLookup:p,nodeOrigin:x}=t.getState();return f6(g,{nodeLookup:p,nodeOrigin:x})},getHandleConnections:({type:g,id:p,nodeId:x})=>{var b;return Array.from(((b=t.getState().connectionLookup.get(`${x}-${g}${p?`-${p}`:""}`))==null?void 0:b.values())??[])},getNodeConnections:({type:g,handleId:p,nodeId:x})=>{var b;return Array.from(((b=t.getState().connectionLookup.get(`${x}${g?p?`-${g}-${p}`:`-${g}`:""}`))==null?void 0:b.values())??[])},fitView:async g=>{const p=t.getState().fitViewResolver??b6();return t.setState({fitViewQueued:!0,fitViewOptions:g,fitViewResolver:p}),n.nodeQueue.push(x=>[...x]),p.promise}}},[]);return y.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const Yk=e=>e.selected,YB=typeof window<"u"?window:void 0;function XB({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=qt(),{deleteElements:i}=Nx(),r=Sc(e,{actInsideInputWithModifier:!1}),o=Sc(t,{target:YB});y.useEffect(()=>{if(r){const{edges:c,nodes:u}=n.getState();i({nodes:u.filter(Yk),edges:c.filter(Yk)}),n.setState({nodesSelectionActive:!1})}},[r]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function QB(e){const t=qt();y.useEffect(()=>{const n=()=>{var r,o,c,u;if(!e.current||!(((o=(r=e.current).checkVisibility)==null?void 0:o.call(r))??!0))return!1;const i=gx(e.current);(i.height===0||i.width===0)&&((u=(c=t.getState()).onError)==null||u.call(c,"004",Ei.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const uh={position:"absolute",width:"100%",height:"100%",top:0,left:0},JB=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function e5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panActivationKeyPressed:r,panOnScrollSpeed:o=.5,panOnScrollMode:c=Pa.Free,zoomOnDoubleClick:u=!0,panOnDrag:d=!0,defaultViewport:h,translateExtent:f,minZoom:g,maxZoom:p,zoomActivationKeyCode:x,preventScrolling:b=!0,children:k,noWheelClassName:w,noPanClassName:j,onViewportChange:E,isControlledViewport:N,paneClickDistance:C,selectionOnDrag:L}){const $=qt(),O=y.useRef(null),{userSelectionActive:W,lib:B,connectionInProgress:U}=St(JB,sn),D=Sc(x),F=y.useRef();QB(O);const A=y.useCallback(T=>{E==null||E({x:T[0],y:T[1],zoom:T[2]}),N||$.setState({transform:T})},[E,N]);return y.useEffect(()=>{if(O.current){F.current=sB({domNode:O.current,minZoom:g,maxZoom:p,translateExtent:f,viewport:h,onDraggingChange:V=>$.setState(z=>z.paneDragging===V?z:{paneDragging:V}),onPanZoomStart:(V,z)=>{const{onViewportChangeStart:H,onMoveStart:G}=$.getState();G==null||G(V,z),H==null||H(z)},onPanZoom:(V,z)=>{const{onViewportChange:H,onMove:G}=$.getState();G==null||G(V,z),H==null||H(z)},onPanZoomEnd:(V,z)=>{const{onViewportChangeEnd:H,onMoveEnd:G}=$.getState();G==null||G(V,z),H==null||H(z)}});const{x:T,y:M,zoom:P}=F.current.getViewport();return $.setState({panZoom:F.current,transform:[T,M,P],domNode:O.current.closest(".react-flow")}),()=>{var V;(V=F.current)==null||V.destroy()}}},[]),y.useEffect(()=>{var T;(T=F.current)==null||T.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panActivationKeyPressed:r,panOnScrollSpeed:o,panOnScrollMode:c,zoomOnDoubleClick:u,panOnDrag:d,zoomActivationKeyPressed:D,preventScrolling:b,noPanClassName:j,userSelectionActive:W,noWheelClassName:w,lib:B,onTransformChange:A,connectionInProgress:U,selectionOnDrag:L,paneClickDistance:C})},[e,t,n,i,r,o,c,u,d,D,b,j,W,w,B,A,U,L,C]),s.jsx("div",{className:"react-flow__renderer",ref:O,style:uh,children:k})}const t5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function n5(){const{userSelectionActive:e,userSelectionRect:t}=St(t5,sn);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 Um=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},s5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function i5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Nc.Full,panOnDrag:i,autoPanOnSelection:r,paneClickDistance:o,selectionOnDrag:c,onSelectionStart:u,onSelectionEnd:d,onPaneClick:h,onPaneContextMenu:f,onPaneScroll:g,onPaneMouseEnter:p,onPaneMouseMove:x,onPaneMouseLeave:b,children:k}){const w=y.useRef(0),j=qt(),{userSelectionActive:E,elementsSelectable:N,dragging:C,panBy:L,autoPanSpeed:$}=St(s5,sn),O=N&&(e||E),W=y.useRef(null),B=y.useRef(),U=y.useRef(new Set),D=y.useRef(new Set),F=y.useRef(!1),A=y.useRef(!1),T=y.useRef({x:0,y:0}),M=y.useRef(!1),P=se=>{if(A.current||F.current||j.getState().connection.inProgress){A.current=!1,F.current=!1;return}h==null||h(se),j.getState().resetSelectedElements(),j.setState({nodesSelectionActive:!1})},V=se=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){se.preventDefault();return}f==null||f(se)},z=g?se=>g(se):void 0,H=se=>{A.current&&(se.stopPropagation(),A.current=!1)},G=se=>{var Ce,Fe;if(se.pointerType==="touch"&&i!==!1&&!t)return;const{domNode:oe,transform:de}=j.getState();if(B.current=oe==null?void 0:oe.getBoundingClientRect(),!B.current)return;const we=se.target===W.current;if(!we&&!!se.target.closest(".nokey")||!e||!(c&&we||t)||se.button!==0||!se.isPrimary)return;(Fe=(Ce=se.target)==null?void 0:Ce.setPointerCapture)==null||Fe.call(Ce,se.pointerId),A.current=!1;const{x:xe,y:De}=Si(se.nativeEvent,B.current),Me=Uc({x:xe,y:De},de);j.setState({userSelectionRect:{width:0,height:0,startX:Me.x,startY:Me.y,x:xe,y:De}}),we||(se.stopPropagation(),se.preventDefault())};function Z(se,oe){const{userSelectionRect:de}=j.getState();if(!de)return;const{transform:we,nodeLookup:Se,edgeLookup:fe,connectionLookup:xe,triggerNodeChanges:De,triggerEdgeChanges:Me,defaultEdgeOptions:Ce}=j.getState(),Fe={x:de.startX,y:de.startY},{x:ot,y:ht}=Yo(Fe,we),Pt={startX:Fe.x,startY:Fe.y,x:se<ot?se:ot,y:oe<ht?oe:ht,width:Math.abs(se-ot),height:Math.abs(oe-ht)},Ln=U.current,an=D.current;U.current=new Set(fx(Se,Pt,we,n===Nc.Partial,!0).map(hn=>hn.id)),D.current=new Set;const dn=(Ce==null?void 0:Ce.selectable)??!0;for(const hn of U.current){const on=xe.get(hn);if(on)for(const{edgeId:ln}of on.values()){const Ut=fe.get(ln);Ut&&(Ut.selectable??dn)&&D.current.add(ln)}}if(!bk(Ln,U.current)){const hn=Eo(Se,U.current,!0);De(hn)}if(!bk(an,D.current)){const hn=Eo(fe,D.current);Me(hn)}j.setState({userSelectionRect:Pt,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!r||!B.current)return;const[se,oe]=mx(T.current,B.current,$);L({x:se,y:oe}).then(de=>{if(!A.current||!de){w.current=requestAnimationFrame(Y);return}const{x:we,y:Se}=T.current;Z(we,Se),w.current=requestAnimationFrame(Y)})}const X=()=>{cancelAnimationFrame(w.current),w.current=0,M.current=!1};y.useEffect(()=>()=>X(),[]);const re=se=>{const{userSelectionRect:oe,transform:de,resetSelectedElements:we}=j.getState();if(!B.current||!oe)return;const{x:Se,y:fe}=Si(se.nativeEvent,B.current);T.current={x:Se,y:fe};const xe=Yo({x:oe.startX,y:oe.startY},de);if(!A.current){const De=t?0:o;if(Math.hypot(Se-xe.x,fe-xe.y)<=De)return;we(),u==null||u(se)}A.current=!0,M.current||(Y(),M.current=!0),Z(Se,fe)},ee=se=>{var oe,de;if(!O){se.target===W.current&&j.getState().connection.inProgress&&(F.current=!0);return}se.button===0&&((de=(oe=se.target)==null?void 0:oe.releasePointerCapture)==null||de.call(oe,se.pointerId),!E&&se.target===W.current&&j.getState().userSelectionRect&&(P==null||P(se)),j.setState({userSelectionActive:!1,userSelectionRect:null}),A.current&&(d==null||d(se),j.setState({nodesSelectionActive:U.current.size>0})),X())},te=se=>{var oe,de;(de=(oe=se.target)==null?void 0:oe.releasePointerCapture)==null||de.call(oe,se.pointerId),X()},ne=i===!0||Array.isArray(i)&&i.includes(0);return s.jsxs("div",{className:jn(["react-flow__pane",{draggable:ne,dragging:C,selection:e}]),onClick:O?void 0:Um(P,W),onContextMenu:Um(V,W),onWheel:Um(z,W),onPointerEnter:O?void 0:p,onPointerMove:O?re:x,onPointerUp:ee,onPointerCancel:O?te:void 0,onPointerDownCapture:O?G:void 0,onClickCapture:O?H:void 0,onPointerLeave:b,ref:W,style:uh,children:[k,s.jsx(n5,{})]})}function sg({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:c,nodeLookup:u,onError:d}=t.getState(),h=u.get(e);if(!h){d==null||d("012",Ei.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&c)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=i==null?void 0:i.current)==null?void 0:f.blur()})):r([e])}function iE({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:c}){const u=qt(),[d,h]=y.useState(!1),f=y.useRef();return y.useEffect(()=>{if(!t)return f.current=H6({getStoreItems:()=>u.getState(),onNodeMouseDown:g=>{sg({id:g,store:u,nodeRef:e})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var g;(g=f.current)==null||g.destroy(),f.current=void 0}},[t,u,e]),y.useEffect(()=>{t||!e.current||!f.current||f.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:c})},[n,i,t,o,e,r,c]),d}const r5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function rE(){const e=qt();return y.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:c,onError:u,updateNodePositions:d,nodeLookup:h,nodeOrigin:f}=e.getState(),g=new Map,p=r5(c),x=r?o[0]:5,b=r?o[1]:5,k=n.direction.x*x*n.factor,w=n.direction.y*b*n.factor;for(const[,j]of h){if(!p(j))continue;let E={x:j.internals.positionAbsolute.x+k,y:j.internals.positionAbsolute.y+w};r&&(E=Fc(E,o));const{position:N,positionAbsolute:C}=j_({nodeId:j.id,nextPosition:E,nodeLookup:h,nodeExtent:i,nodeOrigin:f,onError:u});j.position=N,j.internals.positionAbsolute=C,g.set(j.id,j)}d(g)},[])}const jx=y.createContext(null),a5=jx.Provider;jx.Consumer;const aE=()=>y.useContext(jx),o5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),oE=y.createContext(null);function l5({children:e}){const t=St(o5,sn);return s.jsx(oE.Provider,{value:t,children:e})}function c5(){const e=y.useContext(oE);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const u5={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},d5=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:c}=i,{fromHandle:u,toHandle:d,isValid:h}=c;if(!u&&!r)return u5;const f=(d==null?void 0:d.nodeId)===e&&(d==null?void 0:d.id)===t&&(d==null?void 0:d.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:f,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:o===Go.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:!!r,valid:f&&h}};function h5({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:c,onConnect:u,children:d,className:h,onMouseDown:f,onTouchStart:g,...p},x){var M,P;const b=c||null,k=e==="target",w=qt(),j=aE(),{connectOnClick:E,noPanClassName:N,rfId:C}=c5(),{connectingFrom:L,connectingTo:$,clickConnecting:O,isPossibleEndHandle:W,connectionInProcess:B,clickConnectionInProcess:U,valid:D}=St(d5(j,b,e),sn);j||(P=(M=w.getState()).onError)==null||P.call(M,"010",Ei.error010());const F=V=>{const{defaultEdgeOptions:z,onConnect:H,hasDefaultEdges:G}=w.getState(),Z={...z,...V};if(G){const{edges:Y,setEdges:X,onError:re}=w.getState();X(ZB(Z,Y,{onError:re}))}H==null||H(Z),u==null||u(Z)},A=V=>{if(!j)return;const z=M_(V.nativeEvent);if(r&&(z&&V.button===0||!z)){const H=w.getState();ng.onPointerDown(V.nativeEvent,{handleDomNode:V.currentTarget,autoPanOnConnect:H.autoPanOnConnect,connectionMode:H.connectionMode,connectionRadius:H.connectionRadius,domNode:H.domNode,nodeLookup:H.nodeLookup,lib:H.lib,isTarget:k,handleId:b,nodeId:j,flowId:H.rfId,panBy:H.panBy,cancelConnection:H.cancelConnection,onConnectStart:H.onConnectStart,onConnectEnd:(...G)=>{var Z,Y;return(Y=(Z=w.getState()).onConnectEnd)==null?void 0:Y.call(Z,...G)},updateConnection:H.updateConnection,onConnect:F,isValidConnection:n||((...G)=>{var Z,Y;return((Y=(Z=w.getState()).isValidConnection)==null?void 0:Y.call(Z,...G))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:H.autoPanSpeed,dragThreshold:H.connectionDragThreshold})}z?f==null||f(V):g==null||g(V)},T=V=>{const{onClickConnectStart:z,onClickConnectEnd:H,connectionClickStartHandle:G,connectionMode:Z,isValidConnection:Y,lib:X,rfId:re,nodeLookup:ee,connection:te}=w.getState();if(!j||!G&&!r)return;if(!G){z==null||z(V.nativeEvent,{nodeId:j,handleId:b,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:j,type:e,id:b}});return}const ne=T_(V.target),se=n||Y,{connection:oe,isValid:de}=ng.isValid(V.nativeEvent,{handle:{nodeId:j,id:b,type:e},connectionMode:Z,fromNodeId:G.nodeId,fromHandleId:G.id||null,fromType:G.type,isValidConnection:se,flowId:re,doc:ne,lib:X,nodeLookup:ee});de&&oe&&F(oe);const we=structuredClone(te);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,H==null||H(V,we),w.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":b,"data-nodeid":j,"data-handlepos":t,"data-id":`${C}-${j}-${b}-${e}`,className:jn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",N,h,{source:!k,target:k,connectable:i,connectablestart:r,connectableend:o,clickconnecting:O,connectingfrom:L,connectingto:$,valid:D,connectionindicator:i&&(!B||W)&&(B||U?o:r)}]),onMouseDown:A,onTouchStart:A,onClick:E?T:void 0,ref:x,...p,children:d})}const Yr=y.memo(tE(h5));function f5({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(Yr,{type:"source",position:n,isConnectable:t})]})}function m5({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:i=Je.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(Yr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(Yr,{type:"source",position:i,isConnectable:t})]})}function p5(){return null}function g5({data:e,isConnectable:t,targetPosition:n=Je.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(Yr,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const zd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Xk={input:f5,default:m5,output:g5,group:p5};function x5(e){var t,n,i,r;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??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const v5=e=>{const{width:t,height:n,x:i,y:r}=Dc(e.nodeLookup,{filter:o=>!!o.selected});return{width:wi(t)?t:null,height:wi(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function y5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=qt(),{width:r,height:o,transformString:c,userSelectionActive:u}=St(v5,sn),d=rE(),h=y.useRef(null);y.useEffect(()=>{var x;n||(x=h.current)==null||x.focus({preventScroll:!0})},[n]);const f=!u&&r!==null&&o!==null;if(iE({nodeRef:h,disabled:!f}),!f)return null;const g=e?x=>{const b=i.getState().nodes.filter(k=>k.selected);e(x,b)}:void 0,p=x=>{Object.prototype.hasOwnProperty.call(zd,x.key)&&(x.preventDefault(),d({direction:zd[x.key],factor:x.shiftKey?4:1}))};return s.jsx("div",{className:jn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:s.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:r,height:o}})})}const Qk=typeof window<"u"?window:void 0,b5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function lE({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:u,deleteKeyCode:d,selectionKeyCode:h,selectionOnDrag:f,selectionMode:g,onSelectionStart:p,onSelectionEnd:x,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:w,elementsSelectable:j,zoomOnScroll:E,zoomOnPinch:N,panOnScroll:C,panOnScrollSpeed:L,panOnScrollMode:$,zoomOnDoubleClick:O,panOnDrag:W,autoPanOnSelection:B,defaultViewport:U,translateExtent:D,minZoom:F,maxZoom:A,preventScrolling:T,onSelectionContextMenu:M,noWheelClassName:P,noPanClassName:V,disableKeyboardA11y:z,onViewportChange:H,isControlledViewport:G}){const{nodesSelectionActive:Z,userSelectionActive:Y}=St(b5,sn),X=Sc(h,{target:Qk}),re=Sc(k,{target:Qk}),ee=re||W,te=re||C,ne=f&&ee!==!0,se=X||Y||ne;return XB({deleteKeyCode:d,multiSelectionKeyCode:b}),s.jsx(e5,{onPaneContextMenu:o,elementsSelectable:j,zoomOnScroll:E,zoomOnPinch:N,panOnScroll:te,panActivationKeyPressed:re,panOnScrollSpeed:L,panOnScrollMode:$,zoomOnDoubleClick:O,panOnDrag:!X&&ee,defaultViewport:U,translateExtent:D,minZoom:F,maxZoom:A,zoomActivationKeyCode:w,preventScrolling:T,noWheelClassName:P,noPanClassName:V,onViewportChange:H,isControlledViewport:G,paneClickDistance:u,selectionOnDrag:ne,children:s.jsxs(i5,{onSelectionStart:p,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:ee,autoPanOnSelection:B,isSelecting:!!se,selectionMode:g,selectionKeyPressed:X,paneClickDistance:u,selectionOnDrag:ne,children:[e,Z&&s.jsx(y5,{onSelectionContextMenu:M,noPanClassName:V,disableKeyboardA11y:z})]})})}lE.displayName="FlowRenderer";const k5=y.memo(lE),N5=e=>t=>e?fx(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 j5(e){return St(y.useCallback(N5(e),[e]),sn)}const w5=e=>e.updateNodeInternals;function S5(){const e=St(w5),[t]=y.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const o=r.target.getAttribute("data-id");i.set(o,{id:o,nodeElement:r.target,force:!0})}),e(i)}));return y.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function _5({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=qt(),o=y.useRef(null),c=y.useRef(null),u=y.useRef(e.sourcePosition),d=y.useRef(e.targetPosition),h=y.useRef(t),f=n&&!!e.internals.handleBounds;return y.useEffect(()=>{o.current&&!e.hidden&&(!f||c.current!==o.current)&&(c.current&&(i==null||i.unobserve(c.current)),i==null||i.observe(o.current),c.current=o.current)},[f,e.hidden]),y.useEffect(()=>()=>{c.current&&(i==null||i.unobserve(c.current),c.current=null)},[]),y.useEffect(()=>{if(o.current){const g=h.current!==t,p=u.current!==e.sourcePosition,x=d.current!==e.targetPosition;(g||p||x)&&(h.current=t,u.current=e.sourcePosition,d.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function E5({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:c,nodesDraggable:u,elementsSelectable:d,nodesConnectable:h,nodesFocusable:f,resizeObserver:g,noDragClassName:p,noPanClassName:x,disableKeyboardA11y:b,rfId:k,nodeTypes:w,nodeClickDistance:j,onError:E}){const{node:N,internals:C,isParent:L}=St(se=>{const oe=se.nodeLookup.get(e),de=se.parentLookup.has(e);return{node:oe,internals:oe.internals,isParent:de}},sn);let $=N.type||"default",O=(w==null?void 0:w[$])||Xk[$];O===void 0&&(E==null||E("003",Ei.error003($)),$="default",O=(w==null?void 0:w.default)||Xk.default);const W=!!(N.draggable||u&&typeof N.draggable>"u"),B=!!(N.selectable||d&&typeof N.selectable>"u"),U=!!(N.connectable||h&&typeof N.connectable>"u"),D=!!(N.focusable||f&&typeof N.focusable>"u"),F=qt(),A=C_(N),T=_5({node:N,nodeType:$,hasDimensions:A,resizeObserver:g}),M=iE({nodeRef:T,disabled:N.hidden||!W,noDragClassName:p,handleSelector:N.dragHandle,nodeId:e,isSelectable:B,nodeClickDistance:j}),P=rE();if(N.hidden)return null;const V=Ai(N),z=x5(N),H=B||W||t||n||i||r,G=n?se=>n(se,{...C.userNode}):void 0,Z=i?se=>i(se,{...C.userNode}):void 0,Y=r?se=>r(se,{...C.userNode}):void 0,X=o?se=>o(se,{...C.userNode}):void 0,re=c?se=>c(se,{...C.userNode}):void 0,ee=se=>{const{selectNodesOnDrag:oe,nodeDragThreshold:de}=F.getState();B&&(!oe||!W||de>0)&&sg({id:e,store:F,nodeRef:T}),t&&t(se,{...C.userNode})},te=se=>{if(!($_(se.nativeEvent)||b)){if(y_.includes(se.key)&&B){const oe=se.key==="Escape";sg({id:e,store:F,unselect:oe,nodeRef:T})}else if(W&&N.selected&&Object.prototype.hasOwnProperty.call(zd,se.key)){se.preventDefault();const{ariaLabelConfig:oe}=F.getState();F.setState({ariaLiveMessage:oe["node.a11yDescription.ariaLiveMessage"]({direction:se.key.replace("Arrow","").toLowerCase(),x:~~C.positionAbsolute.x,y:~~C.positionAbsolute.y})}),P({direction:zd[se.key],factor:se.shiftKey?4:1})}}},ne=()=>{var xe;if(b||!((xe=T.current)!=null&&xe.matches(":focus-visible")))return;const{transform:se,width:oe,height:de,autoPanOnNodeFocus:we,setCenter:Se}=F.getState();if(!we)return;fx(new Map([[e,N]]),{x:0,y:0,width:oe,height:de},se,!0).length>0||Se(N.position.x+V.width/2,N.position.y+V.height/2,{zoom:se[2]})};return s.jsx("div",{className:jn(["react-flow__node",`react-flow__node-${$}`,{[x]:W},N.className,{selected:N.selected,selectable:B,parent:L,draggable:W,dragging:M}]),ref:T,style:{zIndex:C.z,transform:`translate(${C.positionAbsolute.x}px,${C.positionAbsolute.y}px)`,pointerEvents:H?"all":"none",visibility:A?"visible":"hidden",...N.style,...z},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:G,onMouseMove:Z,onMouseLeave:Y,onContextMenu:X,onClick:ee,onDoubleClick:re,onKeyDown:D?te:void 0,tabIndex:D?0:void 0,onFocus:D?ne:void 0,role:N.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":b?void 0:`${X_}-${k}`,"aria-label":N.ariaLabel,...N.domAttributes,children:s.jsx(a5,{value:e,children:s.jsx(O,{id:e,data:N.data,type:$,positionAbsoluteX:C.positionAbsolute.x,positionAbsoluteY:C.positionAbsolute.y,selected:N.selected??!1,selectable:B,draggable:W,deletable:N.deletable??!0,isConnectable:U,sourcePosition:N.sourcePosition,targetPosition:N.targetPosition,dragging:M,dragHandle:N.dragHandle,zIndex:C.z,parentId:N.parentId,...V})})})}var C5=y.memo(E5);const A5=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function cE(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:i,onError:r}=St(A5,sn),o=j5(e.onlyRenderVisibleElements),c=S5();return s.jsx("div",{className:"react-flow__nodes",style:uh,children:o.map(u=>s.jsx(C5,{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:i,nodeClickDistance:e.nodeClickDistance,onError:r},u))})}cE.displayName="NodeRenderer";const I5=y.memo(cE);function T5(e){return St(y.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const o=n.nodeLookup.get(r.source),c=n.nodeLookup.get(r.target);o&&c&&w6({sourceNode:o,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),sn)}const $5=({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"})},M5=({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"})},Jk={[Rd.Arrow]:$5,[Rd.ArrowClosed]:M5};function R5(e){const t=qt();return y.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(Jk,e)?Jk[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Ei.error009(e)),null)},[e])}const O5=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:o="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const d=R5(t);return d?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0",children:s.jsx(d,{color:n,strokeWidth:c})}):null},uE=({defaultColor:e,rfId:t})=>{const n=St(o=>o.edges),i=St(o=>o.defaultEdgeOptions),r=y.useMemo(()=>$6(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:r.map(o=>s.jsx(O5,{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};uE.displayName="MarkerDefinitions";var P5=y.memo(uE);function dE({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:d,className:h,...f}){const[g,p]=y.useState({x:1,y:0,width:0,height:0}),x=jn(["react-flow__edge-textwrapper",h]),b=y.useRef(null);return y.useEffect(()=>{if(b.current){const k=b.current.getBBox();p({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:x,visibility:g.width?"visible":"hidden",...f,children:[r&&s.jsx("rect",{width:g.width+2*c[0],x:-c[0],y:-c[1],height:g.height+2*c[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),s.jsx("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:b,style:i,children:n}),d]}):null}dE.displayName="EdgeText";const z5=y.memo(dE);function dh({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d,interactionWidth:h=20,...f}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...f,d:e,fill:"none",className:jn(["react-flow__edge-path",f.className])}),h?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,i&&wi(t)&&wi(n)?s.jsx(z5,{x:t,y:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:d}):null]})}function eN({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===Je.Left||e===Je.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function hE({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:r,targetPosition:o=Je.Top}){const[c,u]=eN({pos:n,x1:e,y1:t,x2:i,y2:r}),[d,h]=eN({pos:o,x1:i,y1:r,x2:e,y2:t}),[f,g,p,x]=R_({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:c,sourceControlY:u,targetControlX:d,targetControlY:h});return[`M${e},${t} C${c},${u} ${d},${h} ${i},${r}`,f,g,p,x]}function fE(e){return y.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:c,targetPosition:u,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:w,interactionWidth:j})=>{const[E,N,C]=hE({sourceX:n,sourceY:i,sourcePosition:c,targetX:r,targetY:o,targetPosition:u}),L=e.isInternal?void 0:t;return s.jsx(dh,{id:L,path:E,labelX:N,labelY:C,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:w,interactionWidth:j})})}const L5=fE({isInternal:!1}),mE=fE({isInternal:!0});L5.displayName="SimpleBezierEdge";mE.displayName="SimpleBezierEdgeInternal";function pE(e){return y.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:p,sourcePosition:x=Je.Bottom,targetPosition:b=Je.Top,markerEnd:k,markerStart:w,pathOptions:j,interactionWidth:E})=>{const[N,C,L]=Jp({sourceX:n,sourceY:i,sourcePosition:x,targetX:r,targetY:o,targetPosition:b,borderRadius:j==null?void 0:j.borderRadius,offset:j==null?void 0:j.offset,stepPosition:j==null?void 0:j.stepPosition}),$=e.isInternal?void 0:t;return s.jsx(dh,{id:$,path:N,labelX:C,labelY:L,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:p,markerEnd:k,markerStart:w,interactionWidth:E})})}const gE=pE({isInternal:!1}),xE=pE({isInternal:!0});gE.displayName="SmoothStepEdge";xE.displayName="SmoothStepEdgeInternal";function vE(e){return y.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return s.jsx(gE,{...n,id:i,pathOptions:y.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const D5=vE({isInternal:!1}),yE=vE({isInternal:!0});D5.displayName="StepEdge";yE.displayName="StepEdgeInternal";function bE(e){return y.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:p,markerEnd:x,markerStart:b,interactionWidth:k})=>{const[w,j,E]=z_({sourceX:n,sourceY:i,targetX:r,targetY:o}),N=e.isInternal?void 0:t;return s.jsx(dh,{id:N,path:w,labelX:j,labelY:E,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:p,markerEnd:x,markerStart:b,interactionWidth:k})})}const F5=bE({isInternal:!1}),kE=bE({isInternal:!0});F5.displayName="StraightEdge";kE.displayName="StraightEdgeInternal";function NE(e){return y.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:c=Je.Bottom,targetPosition:u=Je.Top,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:w,pathOptions:j,interactionWidth:E})=>{const[N,C,L]=O_({sourceX:n,sourceY:i,sourcePosition:c,targetX:r,targetY:o,targetPosition:u,curvature:j==null?void 0:j.curvature}),$=e.isInternal?void 0:t;return s.jsx(dh,{id:$,path:N,labelX:C,labelY:L,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:g,labelBgPadding:p,labelBgBorderRadius:x,style:b,markerEnd:k,markerStart:w,interactionWidth:E})})}const U5=NE({isInternal:!1}),jE=NE({isInternal:!0});U5.displayName="BezierEdge";jE.displayName="BezierEdgeInternal";const tN={default:jE,straight:kE,step:yE,smoothstep:xE,simplebezier:mE},nN={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},B5=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,H5=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,sN="react-flow__edgeupdater";function iN({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:o,onMouseOut:c,type:u}){return s.jsx("circle",{onMouseDown:r,onMouseEnter:o,onMouseOut:c,className:jn([sN,`${sN}-${u}`]),cx:B5(t,i,e),cy:H5(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Z5({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:o,targetY:c,sourcePosition:u,targetPosition:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:g,setReconnecting:p,setUpdateHover:x}){const b=qt(),k=(C,L)=>{if(C.button!==0)return;const{autoPanOnConnect:$,domNode:O,connectionMode:W,connectionRadius:B,lib:U,onConnectStart:D,cancelConnection:F,nodeLookup:A,rfId:T,panBy:M,updateConnection:P}=b.getState(),V=L.type==="target",z=(Z,Y)=>{p(!1),g==null||g(Z,n,L.type,Y)},H=Z=>h==null?void 0:h(n,Z),G=(Z,Y)=>{p(!0),f==null||f(C,n,L.type),D==null||D(Z,Y)};ng.onPointerDown(C.nativeEvent,{autoPanOnConnect:$,connectionMode:W,connectionRadius:B,domNode:O,handleId:L.id,nodeId:L.nodeId,nodeLookup:A,isTarget:V,edgeUpdaterType:L.type,lib:U,flowId:T,cancelConnection:F,panBy:M,isValidConnection:(...Z)=>{var Y,X;return((X=(Y=b.getState()).isValidConnection)==null?void 0:X.call(Y,...Z))??!0},onConnect:H,onConnectStart:G,onConnectEnd:(...Z)=>{var Y,X;return(X=(Y=b.getState()).onConnectEnd)==null?void 0:X.call(Y,...Z)},onReconnectEnd:z,updateConnection:P,getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,dragThreshold:b.getState().connectionDragThreshold,handleDomNode:C.currentTarget})},w=C=>k(C,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),j=C=>k(C,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>x(!0),N=()=>x(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(iN,{position:u,centerX:i,centerY:r,radius:t,onMouseDown:w,onMouseEnter:E,onMouseOut:N,type:"source"}),(e===!0||e==="target")&&s.jsx(iN,{position:d,centerX:o,centerY:c,radius:t,onMouseDown:j,onMouseEnter:E,onMouseOut:N,type:"target"})]})}function W5({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:c,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,reconnectRadius:f,onReconnect:g,onReconnectStart:p,onReconnectEnd:x,rfId:b,edgeTypes:k,noPanClassName:w,onError:j,disableKeyboardA11y:E}){let N=St(Se=>Se.edgeLookup.get(e));const C=St(Se=>Se.defaultEdgeOptions);N=C?{...C,...N}:N;let L=N.type||"default",$=(k==null?void 0:k[L])||tN[L];$===void 0&&(j==null||j("011",Ei.error011(L)),L="default",$=(k==null?void 0:k.default)||tN.default);const O=!!(N.focusable||t&&typeof N.focusable>"u"),W=typeof g<"u"&&(N.reconnectable||n&&typeof N.reconnectable>"u"),B=!!(N.selectable||i&&typeof N.selectable>"u"),U=y.useRef(null),[D,F]=y.useState(!1),[A,T]=y.useState(!1),M=qt(),{zIndex:P=N.zIndex,sourceX:V,sourceY:z,targetX:H,targetY:G,sourcePosition:Z,targetPosition:Y}=St(y.useCallback(Se=>{const fe=Se.nodeLookup.get(N.source),xe=Se.nodeLookup.get(N.target);if(!fe||!xe)return nN;const De=T6({id:e,sourceNode:fe,targetNode:xe,sourceHandle:N.sourceHandle||null,targetHandle:N.targetHandle||null,connectionMode:Se.connectionMode,onError:j}),Me=j6({selected:N.selected,zIndex:N.zIndex,sourceNode:fe,targetNode:xe,elevateOnSelect:Se.elevateEdgesOnSelect,zIndexMode:Se.zIndexMode});return{...De||nN,zIndex:Me}},[N.source,N.target,N.sourceHandle,N.targetHandle,N.selected,N.zIndex,j]),sn),X=y.useMemo(()=>N.markerStart?`url('#${eg(N.markerStart,b)}')`:void 0,[N.markerStart,b]),re=y.useMemo(()=>N.markerEnd?`url('#${eg(N.markerEnd,b)}')`:void 0,[N.markerEnd,b]);if(N.hidden||V===null||z===null||H===null||G===null)return null;const ee=Se=>{var Me;const{addSelectedEdges:fe,unselectNodesAndEdges:xe,multiSelectionActive:De}=M.getState();B&&(M.setState({nodesSelectionActive:!1}),N.selected&&De?(xe({nodes:[],edges:[N]}),(Me=U.current)==null||Me.blur()):fe([e])),r&&r(Se,N)},te=o?Se=>{o(Se,{...N})}:void 0,ne=c?Se=>{c(Se,{...N})}:void 0,se=u?Se=>{u(Se,{...N})}:void 0,oe=d?Se=>{d(Se,{...N})}:void 0,de=h?Se=>{h(Se,{...N})}:void 0,we=Se=>{var fe;if(!E&&y_.includes(Se.key)&&B){const{unselectNodesAndEdges:xe,addSelectedEdges:De}=M.getState();Se.key==="Escape"?((fe=U.current)==null||fe.blur(),xe({edges:[N]})):De([e])}};return s.jsx("svg",{style:{zIndex:P},children:s.jsxs("g",{className:jn(["react-flow__edge",`react-flow__edge-${L}`,N.className,w,{selected:N.selected,animated:N.animated,inactive:!B&&!r,updating:D,selectable:B}]),onClick:ee,onDoubleClick:te,onContextMenu:ne,onMouseEnter:se,onMouseMove:oe,onMouseLeave:de,onKeyDown:O?we:void 0,tabIndex:O?0:void 0,role:N.ariaRole??(O?"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":O?`${Q_}-${b}`:void 0,ref:U,...N.domAttributes,children:[!A&&s.jsx($,{id:e,source:N.source,target:N.target,type:N.type,selected:N.selected,animated:N.animated,selectable:B,deletable:N.deletable??!0,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,sourceX:V,sourceY:z,targetX:H,targetY:G,sourcePosition:Z,targetPosition:Y,data:N.data,style:N.style,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerStart:X,markerEnd:re,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth}),W&&s.jsx(Z5,{edge:N,isReconnectable:W,reconnectRadius:f,onReconnect:g,onReconnectStart:p,onReconnectEnd:x,sourceX:V,sourceY:z,targetX:H,targetY:G,sourcePosition:Z,targetPosition:Y,setUpdateHover:F,setReconnecting:T})]})})}var V5=y.memo(W5);const q5=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function wE({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:u,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,reconnectRadius:g,onEdgeDoubleClick:p,onReconnectStart:x,onReconnectEnd:b,disableKeyboardA11y:k}){const{edgesFocusable:w,edgesReconnectable:j,elementsSelectable:E,onError:N}=St(q5,sn),C=T5(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(P5,{defaultColor:e,rfId:n}),C.map(L=>s.jsx(V5,{id:L,edgesFocusable:w,edgesReconnectable:j,elementsSelectable:E,noPanClassName:r,onReconnect:o,onContextMenu:c,onMouseEnter:u,onMouseMove:d,onMouseLeave:h,onClick:f,reconnectRadius:g,onDoubleClick:p,onReconnectStart:x,onReconnectEnd:b,rfId:n,onError:N,edgeTypes:i,disableKeyboardA11y:k},L))]})}wE.displayName="EdgeRenderer";const G5=y.memo(wE),rN=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function K5({children:e}){const t=qt(),n=y.useRef(null),[i]=y.useState(()=>t.getState().transform);return nE(()=>{let r=null;const o=()=>{const c=t.getState().transform;r&&c[0]===r[0]&&c[1]===r[1]&&c[2]===r[2]||(r=c,n.current&&(n.current.style.transform=rN(c)))};return o(),t.subscribe(o)},[t]),s.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:rN(i)},children:e})}function Y5(e){const t=Nx(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const X5=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Q5(e){const t=St(X5),n=qt();return y.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function J5(e){return e.connection.inProgress?{...e.connection,to:Uc(e.connection.to,e.transform)}:{...e.connection}}function eH(e){return J5}function tH(e){const t=eH();return St(t,sn)}const nH=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function sH({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:o,height:c,isValid:u,inProgress:d}=St(nH,sn);return!(o&&r&&d)?null:s.jsx("svg",{style:e,width:o,height:c,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:jn(["react-flow__connection",I_(u)]),children:s.jsx(SE,{style:t,type:n,CustomComponent:i,isValid:u})})})}const SE=({style:e,type:t=Zr.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:o,fromNode:c,fromHandle:u,fromPosition:d,to:h,toNode:f,toHandle:g,toPosition:p,pointer:x}=tH();if(!r)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:u,fromX:o.x,fromY:o.y,toX:h.x,toY:h.y,fromPosition:d,toPosition:p,connectionStatus:I_(i),toNode:f,toHandle:g,pointer:x});let b="";const k={sourceX:o.x,sourceY:o.y,sourcePosition:d,targetX:h.x,targetY:h.y,targetPosition:p};switch(t){case Zr.Bezier:[b]=O_(k);break;case Zr.SimpleBezier:[b]=hE(k);break;case Zr.Step:[b]=Jp({...k,borderRadius:0});break;case Zr.SmoothStep:[b]=Jp(k);break;default:[b]=z_(k)}return s.jsx("path",{d:b,fill:"none",className:"react-flow__connection-path",style:e})};SE.displayName="ConnectionLine";const iH={};function aN(e=iH){y.useRef(e),qt(),y.useEffect(()=>{},[e])}function rH(){qt(),y.useRef(!1),y.useEffect(()=>{},[])}function _E({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:f,onSelectionContextMenu:g,onSelectionStart:p,onSelectionEnd:x,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:w,connectionLineContainerStyle:j,selectionKeyCode:E,selectionOnDrag:N,selectionMode:C,multiSelectionKeyCode:L,panActivationKeyCode:$,zoomActivationKeyCode:O,deleteKeyCode:W,onlyRenderVisibleElements:B,elementsSelectable:U,defaultViewport:D,translateExtent:F,minZoom:A,maxZoom:T,preventScrolling:M,defaultMarkerColor:P,zoomOnScroll:V,zoomOnPinch:z,panOnScroll:H,panOnScrollSpeed:G,panOnScrollMode:Z,zoomOnDoubleClick:Y,panOnDrag:X,autoPanOnSelection:re,onPaneClick:ee,onPaneMouseEnter:te,onPaneMouseMove:ne,onPaneMouseLeave:se,onPaneScroll:oe,onPaneContextMenu:de,paneClickDistance:we,nodeClickDistance:Se,onEdgeContextMenu:fe,onEdgeMouseEnter:xe,onEdgeMouseMove:De,onEdgeMouseLeave:Me,reconnectRadius:Ce,onReconnect:Fe,onReconnectStart:ot,onReconnectEnd:ht,noDragClassName:Pt,noWheelClassName:Ln,noPanClassName:an,disableKeyboardA11y:dn,nodeExtent:hn,rfId:on,viewport:ln,onViewportChange:Ut,nodesDraggable:Hn}){return aN(e),aN(t),rH(),Y5(n),Q5(ln),s.jsx(k5,{onPaneClick:ee,onPaneMouseEnter:te,onPaneMouseMove:ne,onPaneMouseLeave:se,onPaneContextMenu:de,onPaneScroll:oe,paneClickDistance:we,deleteKeyCode:W,selectionKeyCode:E,selectionOnDrag:N,selectionMode:C,onSelectionStart:p,onSelectionEnd:x,multiSelectionKeyCode:L,panActivationKeyCode:$,zoomActivationKeyCode:O,elementsSelectable:U,zoomOnScroll:V,zoomOnPinch:z,zoomOnDoubleClick:Y,panOnScroll:H,panOnScrollSpeed:G,panOnScrollMode:Z,panOnDrag:X,autoPanOnSelection:re,defaultViewport:D,translateExtent:F,minZoom:A,maxZoom:T,onSelectionContextMenu:g,preventScrolling:M,noDragClassName:Pt,noWheelClassName:Ln,noPanClassName:an,disableKeyboardA11y:dn,onViewportChange:Ut,isControlledViewport:!!ln,children:s.jsxs(K5,{children:[s.jsx(G5,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:c,onReconnect:Fe,onReconnectStart:ot,onReconnectEnd:ht,onlyRenderVisibleElements:B,onEdgeContextMenu:fe,onEdgeMouseEnter:xe,onEdgeMouseMove:De,onEdgeMouseLeave:Me,reconnectRadius:Ce,defaultMarkerColor:P,noPanClassName:an,disableKeyboardA11y:dn,rfId:on}),s.jsx(sH,{style:k,type:b,component:w,containerStyle:j}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(I5,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:f,nodeClickDistance:Se,onlyRenderVisibleElements:B,noPanClassName:an,noDragClassName:Pt,disableKeyboardA11y:dn,nodeExtent:hn,rfId:on,nodesDraggable:Hn}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}_E.displayName="GraphView";const aH=y.memo(_E),oH=E_(),oN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:d=.5,maxZoom:h=2,nodeOrigin:f,nodeExtent:g,zIndexMode:p="basic"}={})=>{const x=new Map,b=new Map,k=new Map,w=new Map,j=i??t??[],E=n??e??[],N=f??[0,0],C=g??kc;F_(k,w,j);const{nodesInitialized:L}=tg(E,x,b,{nodeOrigin:N,nodeExtent:C,zIndexMode:p});let $=[0,0,1];if(c&&r&&o){const O=Dc(x,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:W,y:B,zoom:U}=px(O,r,o,d,h,(u==null?void 0:u.padding)??.1);$=[W,B,U]}return{rfId:"1",width:r??0,height:o??0,transform:$,nodes:E,nodesInitialized:L,nodeLookup:x,parentLookup:b,edges:j,edgeLookup:w,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:d,maxZoom:h,translateExtent:kc,nodeExtent:C,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Go.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:{...k_},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:oH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:b_,zIndexMode:p,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}},lH=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:f,nodeExtent:g,zIndexMode:p})=>bB((x,b)=>{async function k(){const{nodeLookup:w,panZoom:j,fitViewOptions:E,fitViewResolver:N,width:C,height:L,minZoom:$,maxZoom:O}=b();j&&(await g6({nodes:w,width:C,height:L,panZoom:j,minZoom:$,maxZoom:O},E),N==null||N.resolve(!0),x({fitViewResolver:null}))}return{...oN({nodes:e,edges:t,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:d,maxZoom:h,nodeOrigin:f,nodeExtent:g,defaultNodes:n,defaultEdges:i,zIndexMode:p}),setNodes:w=>{const{nodeLookup:j,parentLookup:E,nodeOrigin:N,nodeExtent:C,elevateNodesOnSelect:L,fitViewQueued:$,zIndexMode:O,nodesSelectionActive:W}=b(),{nodesInitialized:B,hasSelectedNodes:U}=tg(w,j,E,{nodeOrigin:N,nodeExtent:C,elevateNodesOnSelect:L,checkEquality:!0,zIndexMode:O}),D=W&&U;$&&B?(k(),x({nodes:w,nodesInitialized:B,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:D})):x({nodes:w,nodesInitialized:B,nodesSelectionActive:D})},setEdges:w=>{const{connectionLookup:j,edgeLookup:E}=b();F_(j,E,w),x({edges:w})},setDefaultNodesAndEdges:(w,j)=>{if(w){const{setNodes:E}=b();E(w),x({hasDefaultNodes:!0})}if(j){const{setEdges:E}=b();E(j),x({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:j,nodeLookup:E,parentLookup:N,domNode:C,nodeOrigin:L,nodeExtent:$,debug:O,fitViewQueued:W,zIndexMode:B}=b(),{changes:U,updatedInternals:D}=D6(w,E,N,C,L,$,B);D&&(O6(E,N,{nodeOrigin:L,nodeExtent:$,zIndexMode:B}),W?(k(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(U==null?void 0:U.length)>0&&(O&&console.log("React Flow: trigger node changes",U),j==null||j(U)))},updateNodePositions:(w,j=!1)=>{const E=[];let N=[];const{nodeLookup:C,triggerNodeChanges:L,connection:$,updateConnection:O,onNodesChangeMiddlewareMap:W}=b();for(const[B,U]of w){const D=C.get(B),F=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(U!=null&&U.position)),A={id:B,type:"position",position:F?{x:Math.max(0,U.position.x),y:Math.max(0,U.position.y)}:U.position,dragging:j};if(D&&$.inProgress&&$.fromNode.id===D.id){const T=Ha(D,$.fromHandle,Je.Left,!0);O({...$,from:T})}F&&D.parentId&&E.push({id:B,parentId:D.parentId,rect:{...U.internals.positionAbsolute,width:U.measured.width??0,height:U.measured.height??0}}),N.push(A)}if(E.length>0){const{parentLookup:B,nodeOrigin:U}=b(),D=kx(E,C,B,U);N.push(...D)}for(const B of W.values())N=B(N);L(N)},triggerNodeChanges:w=>{const{onNodesChange:j,setNodes:E,nodes:N,hasDefaultNodes:C,debug:L}=b();if(w!=null&&w.length){if(C){const $=UB(w,N);E($)}L&&console.log("React Flow: trigger node changes",w),j==null||j(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:j,setEdges:E,edges:N,hasDefaultEdges:C,debug:L}=b();if(w!=null&&w.length){if(C){const $=BB(w,N);E($)}L&&console.log("React Flow: trigger edge changes",w),j==null||j(w)}},addSelectedNodes:w=>{const{multiSelectionActive:j,edgeLookup:E,nodeLookup:N,triggerNodeChanges:C,triggerEdgeChanges:L}=b();if(j){const $=w.map(O=>Na(O,!0));C($);return}C(Eo(N,new Set([...w]),!0)),L(Eo(E))},addSelectedEdges:w=>{const{multiSelectionActive:j,edgeLookup:E,nodeLookup:N,triggerNodeChanges:C,triggerEdgeChanges:L}=b();if(j){const $=w.map(O=>Na(O,!0));L($);return}L(Eo(E,new Set([...w]))),C(Eo(N,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:j}={})=>{const{edges:E,nodes:N,nodeLookup:C,triggerNodeChanges:L,triggerEdgeChanges:$}=b(),O=w||N,W=j||E,B=[];for(const D of O){if(!D.selected)continue;const F=C.get(D.id);F&&(F.selected=!1),B.push(Na(D.id,!1))}const U=[];for(const D of W)D.selected&&U.push(Na(D.id,!1));L(B),$(U)},setMinZoom:w=>{const{panZoom:j,maxZoom:E}=b();j==null||j.setScaleExtent([w,E]),x({minZoom:w})},setMaxZoom:w=>{const{panZoom:j,minZoom:E}=b();j==null||j.setScaleExtent([E,w]),x({maxZoom:w})},setTranslateExtent:w=>{var j;(j=b().panZoom)==null||j.setTranslateExtent(w),x({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:j,triggerNodeChanges:E,triggerEdgeChanges:N,elementsSelectable:C}=b();if(!C)return;const L=j.reduce((O,W)=>W.selected?[...O,Na(W.id,!1)]:O,[]),$=w.reduce((O,W)=>W.selected?[...O,Na(W.id,!1)]:O,[]);E(L),N($)},setNodeExtent:w=>{const{nodes:j,nodeLookup:E,parentLookup:N,nodeOrigin:C,elevateNodesOnSelect:L,nodeExtent:$,zIndexMode:O}=b();w[0][0]===$[0][0]&&w[0][1]===$[0][1]&&w[1][0]===$[1][0]&&w[1][1]===$[1][1]||(tg(j,E,N,{nodeOrigin:C,nodeExtent:w,elevateNodesOnSelect:L,checkEquality:!1,zIndexMode:O}),x({nodeExtent:w}))},panBy:w=>{const{transform:j,width:E,height:N,panZoom:C,translateExtent:L}=b();return F6({delta:w,panZoom:C,transform:j,translateExtent:L,width:E,height:N})},setCenter:async(w,j,E)=>{const{width:N,height:C,maxZoom:L,panZoom:$}=b();if(!$)return!1;const O=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:L;return await $.setViewport({x:N/2-w*O,y:C/2-j*O,zoom:O},{duration:E==null?void 0:E.duration,ease:E==null?void 0:E.ease,interpolate:E==null?void 0:E.interpolate}),!0},cancelConnection:()=>{x({connection:{...k_}})},updateConnection:w=>{x({connection:w})},reset:()=>x({...oN()})}},Object.is);function cH({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:c,initialMaxZoom:u,initialFitViewOptions:d,fitView:h,nodeOrigin:f,nodeExtent:g,zIndexMode:p,children:x}){const[b]=y.useState(()=>lH({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:h,minZoom:c,maxZoom:u,fitViewOptions:d,nodeOrigin:f,nodeExtent:g,zIndexMode:p}));return s.jsx(kB,{value:b,children:s.jsx(qB,{children:s.jsx(l5,{children:x})})})}function uH({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:o,height:c,fitView:u,fitViewOptions:d,minZoom:h,maxZoom:f,nodeOrigin:g,nodeExtent:p,zIndexMode:x}){return y.useContext(lh)?s.jsx(s.Fragment,{children:e}):s.jsx(cH,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:c,fitView:u,initialFitViewOptions:d,initialMinZoom:h,initialMaxZoom:f,nodeOrigin:g,nodeExtent:p,zIndexMode:x,children:e})}const dH={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function hH({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:c,onNodeClick:u,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:g,onMoveEnd:p,onConnect:x,onConnectStart:b,onConnectEnd:k,onClickConnectStart:w,onClickConnectEnd:j,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:C,onNodeContextMenu:L,onNodeDoubleClick:$,onNodeDragStart:O,onNodeDrag:W,onNodeDragStop:B,onNodesDelete:U,onEdgesDelete:D,onDelete:F,onSelectionChange:A,onSelectionDragStart:T,onSelectionDrag:M,onSelectionDragStop:P,onSelectionContextMenu:V,onSelectionStart:z,onSelectionEnd:H,onBeforeDelete:G,connectionMode:Z,connectionLineType:Y=Zr.Bezier,connectionLineStyle:X,connectionLineComponent:re,connectionLineContainerStyle:ee,deleteKeyCode:te="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:se=!1,selectionMode:oe=Nc.Full,panActivationKeyCode:de="Space",multiSelectionKeyCode:we=wc()?"Meta":"Control",zoomActivationKeyCode:Se=wc()?"Meta":"Control",snapToGrid:fe,snapGrid:xe,onlyRenderVisibleElements:De=!1,selectNodesOnDrag:Me,nodesDraggable:Ce,autoPanOnNodeFocus:Fe,nodesConnectable:ot,nodesFocusable:ht,nodeOrigin:Pt=J_,edgesFocusable:Ln,edgesReconnectable:an,elementsSelectable:dn=!0,defaultViewport:hn=RB,minZoom:on=.5,maxZoom:ln=2,translateExtent:Ut=kc,preventScrolling:Hn=!0,nodeExtent:wn,defaultMarkerColor:Ss="#b1b1b7",zoomOnScroll:Ii=!0,zoomOnPinch:ii=!0,panOnScroll:ri=!1,panOnScrollSpeed:Ds=.5,panOnScrollMode:Fs=Pa.Free,zoomOnDoubleClick:Us=!0,panOnDrag:Bs=!0,onPaneClick:ai,onPaneMouseEnter:oi,onPaneMouseMove:os,onPaneMouseLeave:Qn,onPaneScroll:Sn,onPaneContextMenu:ie,paneClickDistance:ye=1,nodeClickDistance:Le=0,children:tt,onReconnect:At,onReconnectStart:Tt,onReconnectEnd:Be,onEdgeContextMenu:Ue,onEdgeDoubleClick:Xe,onEdgeMouseEnter:kt,onEdgeMouseMove:bt,onEdgeMouseLeave:Zn,reconnectRadius:ls=10,onNodesChange:li,onEdgesChange:vr,noDragClassName:ci="nodrag",noWheelClassName:yr="nowheel",noPanClassName:Wn="nopan",fitView:Vi,fitViewOptions:cs,connectOnClick:Ti,attributionPosition:br,proOptions:Mt,defaultEdgeOptions:_s,elevateNodesOnSelect:Jn=!0,elevateEdgesOnSelect:qi=!1,disableKeyboardA11y:ui=!1,autoPanOnConnect:Rt,autoPanOnNodeDrag:kr,autoPanOnSelection:Gi=!0,autoPanSpeed:di,connectionRadius:$i,isValidConnection:$e,onError:We,style:lt,id:dt,nodeDragThreshold:It,connectionDragThreshold:Ot,viewport:Vn,onViewportChange:Hs,width:fn,height:_n,colorMode:Zs="light",debug:Ws,onScroll:us,ariaLabelConfig:ia,zIndexMode:Nr="basic",...Mi},jr){const es=dt||"1",ds=LB(Zs),En=y.useCallback(Vs=>{Vs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),us==null||us(Vs)},[us]);return s.jsx("div",{"data-testid":"rf__wrapper",...Mi,onScroll:En,style:{...lt,...dH},ref:jr,className:jn(["react-flow",r,ds]),id:dt,role:"application",children:s.jsxs(uH,{nodes:e,edges:t,width:fn,height:_n,fitView:Vi,fitViewOptions:cs,minZoom:on,maxZoom:ln,nodeOrigin:Pt,nodeExtent:wn,zIndexMode:Nr,children:[s.jsx(zB,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:x,onConnectStart:b,onConnectEnd:k,onClickConnectStart:w,onClickConnectEnd:j,nodesDraggable:Ce,autoPanOnNodeFocus:Fe,nodesConnectable:ot,nodesFocusable:ht,edgesFocusable:Ln,edgesReconnectable:an,elementsSelectable:dn,elevateNodesOnSelect:Jn,elevateEdgesOnSelect:qi,minZoom:on,maxZoom:ln,nodeExtent:wn,onNodesChange:li,onEdgesChange:vr,snapToGrid:fe,snapGrid:xe,connectionMode:Z,translateExtent:Ut,connectOnClick:Ti,defaultEdgeOptions:_s,fitView:Vi,fitViewOptions:cs,onNodesDelete:U,onEdgesDelete:D,onDelete:F,onNodeDragStart:O,onNodeDrag:W,onNodeDragStop:B,onSelectionDrag:M,onSelectionDragStart:T,onSelectionDragStop:P,onMove:f,onMoveStart:g,onMoveEnd:p,noPanClassName:Wn,nodeOrigin:Pt,rfId:es,autoPanOnConnect:Rt,autoPanOnNodeDrag:kr,autoPanSpeed:di,onError:We,connectionRadius:$i,isValidConnection:$e,selectNodesOnDrag:Me,nodeDragThreshold:It,connectionDragThreshold:Ot,onBeforeDelete:G,debug:Ws,ariaLabelConfig:ia,zIndexMode:Nr}),s.jsx(aH,{onInit:h,onNodeClick:u,onEdgeClick:d,onNodeMouseEnter:E,onNodeMouseMove:N,onNodeMouseLeave:C,onNodeContextMenu:L,onNodeDoubleClick:$,nodeTypes:o,edgeTypes:c,connectionLineType:Y,connectionLineStyle:X,connectionLineComponent:re,connectionLineContainerStyle:ee,selectionKeyCode:ne,selectionOnDrag:se,selectionMode:oe,deleteKeyCode:te,multiSelectionKeyCode:we,panActivationKeyCode:de,zoomActivationKeyCode:Se,onlyRenderVisibleElements:De,defaultViewport:hn,translateExtent:Ut,minZoom:on,maxZoom:ln,preventScrolling:Hn,zoomOnScroll:Ii,zoomOnPinch:ii,zoomOnDoubleClick:Us,panOnScroll:ri,panOnScrollSpeed:Ds,panOnScrollMode:Fs,panOnDrag:Bs,autoPanOnSelection:Gi,onPaneClick:ai,onPaneMouseEnter:oi,onPaneMouseMove:os,onPaneMouseLeave:Qn,onPaneScroll:Sn,onPaneContextMenu:ie,paneClickDistance:ye,nodeClickDistance:Le,onSelectionContextMenu:V,onSelectionStart:z,onSelectionEnd:H,onReconnect:At,onReconnectStart:Tt,onReconnectEnd:Be,onEdgeContextMenu:Ue,onEdgeDoubleClick:Xe,onEdgeMouseEnter:kt,onEdgeMouseMove:bt,onEdgeMouseLeave:Zn,reconnectRadius:ls,defaultMarkerColor:Ss,noDragClassName:ci,noWheelClassName:yr,noPanClassName:Wn,rfId:es,disableKeyboardA11y:ui,nodeExtent:wn,viewport:Vn,onViewportChange:Hs,nodesDraggable:Ce}),s.jsx(MB,{onSelectionChange:A}),tt,s.jsx(CB,{proOptions:Mt,position:br}),s.jsx(EB,{rfId:es,disableKeyboardA11y:ui})]})})}var fH=tE(hH);function mH({dimensions:e,lineWidth:t,variant:n,className:i}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:jn(["react-flow__background-pattern",n,i])})}function pH({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:jn(["react-flow__background-pattern","dots",t])})}var Jr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Jr||(Jr={}));const gH={[Jr.Dots]:1,[Jr.Lines]:1,[Jr.Cross]:6},xH=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function EE({id:e,variant:t=Jr.Dots,gap:n=20,size:i,lineWidth:r=1,offset:o=0,color:c,bgColor:u,style:d,className:h,patternClassName:f}){const g=y.useRef(null),{transform:p,patternId:x}=St(xH,sn),b=i||gH[t],k=t===Jr.Dots,w=t===Jr.Cross,j=Array.isArray(n)?n:[n,n],E=[j[0]*p[2]||1,j[1]*p[2]||1],N=b*p[2],C=Array.isArray(o)?o:[o,o],L=w?[N,N]:E,$=[C[0]*p[2]+L[0]/2,C[1]*p[2]+L[1]/2],O=`${x}${e||""}`;return s.jsxs("svg",{className:jn(["react-flow__background",h]),style:{...d,...uh,"--xy-background-color-props":u,"--xy-background-pattern-color-props":c},ref:g,"data-testid":"rf__background",children:[s.jsx("pattern",{id:O,x:p[0]%E[0],y:p[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:k?s.jsx(pH,{radius:N/2,className:f}):s.jsx(mH,{dimensions:L,lineWidth:r,variant:t,className:f})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${O})`})]})}EE.displayName="Background";const vH=y.memo(EE);function yH(){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 bH(){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 kH(){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 NH(){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 jH(){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 sd({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:jn(["react-flow__controls-button",t]),...n,children:e})}const wH=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function CE({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:c,onFitView:u,onInteractiveChange:d,className:h,children:f,position:g="bottom-left",orientation:p="vertical","aria-label":x}){const b=qt(),{isInteractive:k,minZoomReached:w,maxZoomReached:j,ariaLabelConfig:E}=St(wH,sn),{zoomIn:N,zoomOut:C,fitView:L}=Nx(),$=()=>{N(),o==null||o()},O=()=>{C(),c==null||c()},W=()=>{L(r),u==null||u()},B=()=>{b.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),d==null||d(!k)},U=p==="horizontal"?"horizontal":"vertical";return s.jsxs(ch,{className:jn(["react-flow__controls",U,h]),position:g,style:e,"data-testid":"rf__controls","aria-label":x??E["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(sd,{onClick:$,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:j,children:s.jsx(yH,{})}),s.jsx(sd,{onClick:O,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:w,children:s.jsx(bH,{})})]}),n&&s.jsx(sd,{className:"react-flow__controls-fitview",onClick:W,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:s.jsx(kH,{})}),i&&s.jsx(sd,{className:"react-flow__controls-interactive",onClick:B,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:k?s.jsx(jH,{}):s.jsx(NH,{})}),f]})}CE.displayName="Controls";const SH=y.memo(CE);function _H({id:e,x:t,y:n,width:i,height:r,style:o,color:c,strokeColor:u,strokeWidth:d,className:h,borderRadius:f,shapeRendering:g,selected:p,onClick:x}){const{background:b,backgroundColor:k}=o||{},w=c||b||k;return s.jsx("rect",{className:jn(["react-flow__minimap-node",{selected:p},h]),x:t,y:n,rx:f,ry:f,width:i,height:r,style:{fill:w,stroke:u,strokeWidth:d},shapeRendering:g,onClick:x?j=>x(j,e):void 0})}const EH=y.memo(_H),CH=e=>e.nodes.map(t=>t.id),Bm=e=>e instanceof Function?e:()=>e;function AH({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=EH,onClick:c}){const u=St(CH,sn),d=Bm(t),h=Bm(e),f=Bm(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:u.map(p=>s.jsx(TH,{id:p,nodeColorFunc:d,nodeStrokeColorFunc:h,nodeClassNameFunc:f,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:c,shapeRendering:g},p))})}function IH({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:u,onClick:d}){const{node:h,x:f,y:g,width:p,height:x}=St(b=>{const k=b.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const w=k.internals.userNode,{x:j,y:E}=k.internals.positionAbsolute,{width:N,height:C}=Ai(w);return{node:w,x:j,y:E,width:N,height:C}},sn);return!h||h.hidden||!C_(h)?null:s.jsx(u,{x:f,y:g,width:p,height:x,style:h.style,selected:!!h.selected,className:i(h),color:t(h),borderRadius:r,strokeColor:n(h),strokeWidth:o,shapeRendering:c,onClick:d,id:h.id})}const TH=y.memo(IH);var $H=y.memo(AH);const MH=200,RH=150,OH=e=>!e.hidden,PH=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 i of e.nodeLookup.values())if(!i.hidden){n=!0;break}return{viewBB:t,boundingRect:n?S_(Dc(e.nodeLookup,{filter:OH}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},lN=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,zH=(e,t)=>lN(e.viewBB,t.viewBB)&&lN(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,LH="react-flow__minimap-desc";function AE({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:d,maskColor:h,maskStrokeColor:f,maskStrokeWidth:g,position:p="bottom-right",onClick:x,onNodeClick:b,pannable:k=!1,zoomable:w=!1,ariaLabel:j,inversePan:E,zoomStep:N=1,offsetScale:C=5}){const L=qt(),$=y.useRef(null),{boundingRect:O,panZoom:W,viewBB:B,rfId:U,translateExtent:D,flowWidth:F,flowHeight:A,ariaLabelConfig:T}=St(PH,zH),M=(e==null?void 0:e.width)??MH,P=(e==null?void 0:e.height)??RH,V=O.width/M,z=O.height/P,H=Math.max(V,z),G=H*M,Z=H*P,Y=C*H,X=O.x-(G-O.width)/2-Y,re=O.y-(Z-O.height)/2-Y,ee=G+Y*2,te=Z+Y*2,ne=`${LH}-${U}`,se=y.useRef(0),oe=y.useRef();se.current=H,y.useEffect(()=>{const xe=L.getState().panZoom;if($.current&&xe)return oe.current=K6({domNode:$.current,panZoom:xe,getTransform:()=>L.getState().transform,getViewScale:()=>se.current}),()=>{var De;(De=oe.current)==null||De.destroy()}},[W]),y.useEffect(()=>{var xe;(xe=oe.current)==null||xe.update({translateExtent:D,width:F,height:A,inversePan:E,pannable:k,zoomStep:N,zoomable:w})},[k,w,E,N,D,F,A]);const de=x?xe=>{var Ce;const[De,Me]=((Ce=oe.current)==null?void 0:Ce.pointer(xe))||[0,0];x(xe,{x:De,y:Me})}:void 0,we=y.useCallback((xe,De)=>{const Me=L.getState().nodeLookup.get(De).internals.userNode;b==null||b(xe,Me)},[b]),Se=b?we:void 0,fe=j??T["minimap.ariaLabel"];return s.jsx(ch,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof g=="number"?g*H:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i: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:jn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:M,height:P,viewBox:`${X} ${re} ${ee} ${te}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:$,onClick:de,children:[fe&&s.jsx("title",{id:ne,children:fe}),s.jsx($H,{onClick:Se,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:c,nodeComponent:u}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${X-Y},${re-Y}h${ee+Y*2}v${te+Y*2}h${-ee-Y*2}z
231
+ M${B.x},${B.y}h${B.width}v${B.height}h${-B.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}AE.displayName="MiniMap";y.memo(AE);const DH=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,FH={[Xo.Line]:"right",[Xo.Handle]:"bottom-right"};function UH({nodeId:e,position:t,variant:n=Xo.Handle,className:i,style:r=void 0,children:o,color:c,minWidth:u=10,minHeight:d=10,maxWidth:h=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:g=!1,resizeDirection:p,autoScale:x=!0,shouldResize:b,onResizeStart:k,onResize:w,onResizeEnd:j}){const E=aE(),N=typeof e=="string"?e:E,C=qt(),L=y.useRef(null),$=n===Xo.Handle,O=St(y.useCallback(DH($&&x),[$,x]),sn),W=y.useRef(null),B=t??FH[n];y.useEffect(()=>{if(!(!L.current||!N))return W.current||(W.current=lB({domNode:L.current,nodeId:N,getStoreItems:()=>{const{nodeLookup:D,transform:F,snapGrid:A,snapToGrid:T,nodeOrigin:M,domNode:P}=C.getState();return{nodeLookup:D,transform:F,snapGrid:A,snapToGrid:T,nodeOrigin:M,paneDomNode:P}},onChange:(D,F)=>{const{triggerNodeChanges:A,nodeLookup:T,parentLookup:M,nodeOrigin:P}=C.getState(),V=[],z={x:D.x,y:D.y},H=T.get(N);if(H&&H.expandParent&&H.parentId){const G=H.origin??P,Z=D.width??H.measured.width??0,Y=D.height??H.measured.height??0,X={id:H.id,parentId:H.parentId,rect:{width:Z,height:Y,...A_({x:D.x??H.position.x,y:D.y??H.position.y},{width:Z,height:Y},H.parentId,T,G)}},re=kx([X],T,M,P);V.push(...re),z.x=D.x?Math.max(G[0]*Z,D.x):void 0,z.y=D.y?Math.max(G[1]*Y,D.y):void 0}if(z.x!==void 0&&z.y!==void 0){const G={id:N,type:"position",position:{...z}};V.push(G)}if(D.width!==void 0&&D.height!==void 0){const Z={id:N,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};V.push(Z)}for(const G of F){const Z={...G,type:"position"};V.push(Z)}A(V)},onEnd:({width:D,height:F})=>{const A={id:N,type:"dimensions",resizing:!1,dimensions:{width:D,height:F}};C.getState().triggerNodeChanges([A])}})),W.current.update({controlPosition:B,boundaries:{minWidth:u,minHeight:d,maxWidth:h,maxHeight:f},keepAspectRatio:g,resizeDirection:p,onResizeStart:k,onResize:w,onResizeEnd:j,shouldResize:b}),()=>{var D;(D=W.current)==null||D.destroy()}},[B,u,d,h,f,g,k,w,j,b]);const U=B.split("-");return s.jsx("div",{className:jn(["react-flow__resize-control","nodrag",...U,n,i]),ref:L,style:{...r,scale:O,...c&&{[$?"backgroundColor":"borderColor"]:c}},children:o})}y.memo(UH);function BH(e,t=0){const n=je(e.connection.status),[i,r]=y.useState([]);return y.useEffect(()=>{if(n.state!=="open")return;let o=!0;return(async()=>{const{scripts:c}=await e.connection.call("scripts/list",{}),u=[];for(const d of c){if(d.packId===void 0)continue;const h=await e.connection.call("runs/tasks",{scriptId:d.id}).catch(()=>{});if(h===void 0||h.tasks.length===0)continue;const f=await e.connection.call("configs/profiles",{scriptId:d.id}).catch(()=>{});u.push({scriptId:d.id,scriptName:d.name,tasks:h.tasks,profiles:f})}o&&r(u)})().catch(()=>{}),()=>{o=!1}},[e,n.state,t]),y.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{r(c=>c.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),i}const IE=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),TE=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],Qo={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},ig={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},HH={success:"成功后",failure:"失败后",always:"结束后"},Hm={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function ZH({data:e,selected:t}){var i,r,o,c;const n=(i=e.state)==null?void 0:i.state;return Hi(e.node)?s.jsxs("div",{className:`step-node marker ${e.node.kind} ${n??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&s.jsx(Yr,{type:"target",position:Je.Left}),s.jsx("span",{children:Qo[e.node.kind]}),e.node.kind==="end"&&n!==void 0&&n!=="pending"&&s.jsx("span",{className:`step-state ${n}`,children:((r=e.state)==null?void 0:r.detail)??ig[n]}),e.node.kind==="start"&&s.jsx(Yr,{type:"source",position:Je.Right})]}):s.jsxs("div",{className:`step-node ${n??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[s.jsx(Yr,{type:"target",position:Je.Left}),s.jsxs("div",{className:"step-kind",children:[s.jsx("span",{children:Qo[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:[ig[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(Yr,{type:"source",position:Je.Right})]})}const WH={step:ZH};function VH(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(h=>h.to===o).map(h=>n(h.from,c)+1),d=Math.max(0,...u);return t.set(o,d),d};for(const o of e.nodes)n(o.id,new Set);const i=new Map,r=new Map;for(const o of e.nodes){if(o.position!==void 0){r.set(o.id,o.position);continue}const c=t.get(o.id)??0,u=i.get(c)??0;i.set(c,u+1),r.set(o.id,{x:40+c*280,y:40+u*130})}return r}let qH=0;const ko=(e,t,n=new Set)=>{for(;;){const i=`${e}${++qH}`;if(!n.has(i)&&!t.nodes.some(r=>r.id===i))return i}};function GH(e,t){return e.nodes.every(n=>n.position!==void 0)?e:{...e,nodes:e.nodes.map(n=>n.position!==void 0||!t.has(n.id)?n:{...n,position:t.get(n.id)})}}let Ur=null;const KH=e=>e instanceof HTMLElement&&e.closest('input, textarea, select, [contenteditable=""], [contenteditable="true"]')!==null;function YH({client:e,pipeline:t,onChange:n,run:i,check:r,runFrom:o,idle:c}){var Z,Y;const u=wS(),[d,h]=y.useState(0),f=BH(e,d),[g,p]=y.useState([]),x=g.length===1?g[0]:null,b=X=>p(X===null?[]:[X]),[k,w]=y.useState(null),j=y.useRef(null),[E,N]=y.useState({}),C=y.useCallback(X=>{var re,ee;if(X.kind==="script-task"){const te=f.find(de=>de.scriptId===X.scriptId),ne=te==null?void 0:te.tasks.find(de=>de.id===X.taskId),se=Object.entries(X.params).map(([de,we])=>`${de}=${String(we)}`).join(" "),oe=X.profile===void 0?void 0:((ee=(re=te==null?void 0:te.profiles)==null?void 0:re.items.find(de=>de.id===X.profile))==null?void 0:ee.name)??"已删除的配置";return{label:X.title??`${(te==null?void 0:te.scriptName)??X.scriptId} · ${(ne==null?void 0:ne.title)??X.taskId}`,sub:[oe===void 0?"":`配置:${oe}`,se].filter(Boolean).join(" · "),input:Hm[(ne==null?void 0:ne.input)??"none"]??""}}return X.kind==="wait"?{label:X.title??(X.minutes!==void 0?`等 ${X.minutes} 分钟`:`等到 ${X.until}`),sub:"",input:""}:X.kind==="agent"?{label:X.title??"agent 步骤",sub:X.prompt.slice(0,40),input:""}:Hi(X)?{label:Qo[X.kind],sub:"",input:""}:{label:X.title??Qo[X.kind],sub:X.text.slice(0,40),input:""}},[f]),L=y.useMemo(()=>VH(t),[t]),$=y.useMemo(()=>t.nodes.map(X=>{var re;return{id:X.id,type:"step",position:L.get(X.id),selected:g.includes(X.id),...E[X.id]===void 0?{}:{measured:E[X.id]},data:{node:X,...C(X),state:i==null?void 0:i.nodes[X.id],issue:(re=r==null?void 0:r.issues.find(ee=>ee.nodeId===X.id&&ee.level==="error"))==null?void 0:re.message}}}),[t,L,C,i,r,g,E]),O=y.useMemo(()=>t.edges.map((X,re)=>{var ee;return{id:`e${re}`,source:X.from,target:X.to,label:HH[X.when],selected:re===k,animated:((ee=i==null?void 0:i.nodes[X.from])==null?void 0:ee.state)==="running",className:`edge-${X.when}`}}),[t.edges,k,i]),W=y.useRef({past:[],future:[],at:0}),B=y.useCallback((X,re)=>{const ee=W.current,te=Date.now();(re===void 0||re!==ee.group||te-ee.at>1e3)&&(ee.past=[...ee.past.slice(-99),{nodes:t.nodes,edges:t.edges}]),ee.future=[],ee.group=re,ee.at=te,n(GH(X,L))},[t,L,n]),U=X=>{const re=W.current,ee=X==="past"?"future":"past",te=re[X].pop();te!==void 0&&(re[ee].push({nodes:t.nodes,edges:t.edges}),re.group=void 0,n({...t,...te}),p(ne=>ne.filter(se=>te.nodes.some(oe=>oe.id===se))),w(null))},D=y.useCallback(X=>{let re=t,ee;const te={},ne=new Map;for(const se of X)if(se.type==="dimensions"&&se.dimensions!==void 0)te[se.id]=se.dimensions;else if(se.type==="select")ne.set(se.id,se.selected);else if(se.type==="position"&&se.position!==void 0)re={...re,nodes:re.nodes.map(oe=>oe.id===se.id?{...oe,position:{x:Math.round(se.position.x),y:Math.round(se.position.y)}}:oe)},ee="move";else if(se.type==="remove"){if(re.nodes.some(oe=>oe.id===se.id&&Hi(oe)))continue;re={...re,nodes:re.nodes.filter(oe=>oe.id!==se.id),edges:re.edges.filter(oe=>oe.from!==se.id&&oe.to!==se.id)},ne.set(se.id,!1),ee=void 0}Object.keys(te).length>0&&N(se=>({...se,...te})),ne.size>0&&(p(se=>[...se.filter(oe=>ne.get(oe)!==!1),...[...ne].filter(([oe,de])=>de&&!se.includes(oe)).map(([oe])=>oe)]),[...ne.values()].some(Boolean)&&w(null)),re!==t&&B(re,ee)},[t,B]),F=y.useCallback(X=>{var ee;if(X.source===X.target||t.edges.some(te=>te.from===X.source&&te.to===X.target))return;const re=t.nodes.find(te=>te.id===X.target);(re==null?void 0:re.kind)==="start"||((ee=t.nodes.find(te=>te.id===X.source))==null?void 0:ee.kind)==="end"||B({...t,edges:[...t.edges,{from:X.source,to:X.target,when:(re==null?void 0:re.kind)==="end"?"always":"success"}]})},[t,B]),A=()=>{const X=t.nodes.filter(ee=>g.includes(ee.id)&&!Hi(ee));if(X.length===0)return!1;const re=new Set(X.map(ee=>ee.id));return Ur={nodes:X.map(ee=>({...ee,position:L.get(ee.id)??{x:40,y:40}})),edges:t.edges.filter(ee=>re.has(ee.from)&&re.has(ee.to)),pasted:0},!0},T=()=>{if(Ur===null||t.nodes.length+Ur.nodes.length>60)return;const X=++Ur.pasted,re=new Map;for(const ne of Ur.nodes)re.set(ne.id,ko(ne.id.replace(/\d+$/,"")||"step",t,new Set(re.values())));const ee=Ur.nodes.map(ne=>{var se,oe;return{...ne,id:re.get(ne.id),position:{x:(((se=ne.position)==null?void 0:se.x)??40)+40*X,y:(((oe=ne.position)==null?void 0:oe.y)??40)+120*X}}}),te=Ur.edges.map(ne=>({...ne,from:re.get(ne.from),to:re.get(ne.to)}));B({...t,nodes:[...t.nodes,...ee],edges:[...t.edges,...te]}),p(ee.map(ne=>ne.id)),w(null)},M=()=>{const X=new Set(t.nodes.filter(re=>g.includes(re.id)&&!Hi(re)).map(re=>re.id));X.size!==0&&(B({...t,nodes:t.nodes.filter(re=>!X.has(re.id)),edges:t.edges.filter(re=>!X.has(re.from)&&!X.has(re.to))}),p([]))},P=y.useRef(()=>{});P.current=X=>{var ee;if(!(X.ctrlKey||X.metaKey)||X.altKey||KH(X.target)||j.current===null||j.current.offsetParent===null)return;const re=X.key.toLowerCase();re==="z"&&!X.shiftKey?(X.preventDefault(),U("past")):re==="y"||re==="z"&&X.shiftKey?(X.preventDefault(),U("future")):re==="c"?(((ee=window.getSelection())==null?void 0:ee.toString())??"")===""&&A()&&X.preventDefault():re==="v"&&Ur!==null&&(X.preventDefault(),T())},y.useEffect(()=>{const X=re=>P.current(re);return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[]);const V=X=>{const re=t.nodes.find(Se=>Se.kind==="start"),ee=t.nodes.find(Se=>Se.kind==="end"),te=t.nodes.find(Se=>Se.id===x&&Se.kind!=="end")??re,ne=te===void 0?void 0:L.get(te.id),se=[...L.entries()].filter(([Se])=>Se!==(ee==null?void 0:ee.id)).map(([,Se])=>Se),oe=ne===void 0?Math.max(0,...se.map(Se=>Se.x))+280:ne.x+280;let de=(ne==null?void 0:ne.y)??40;for(;se.some(Se=>Math.abs(Se.x-oe)<200&&Math.abs(Se.y-de)<100);)de+=130;const we=[...t.nodes.map(Se=>{var fe,xe;return Se.kind==="end"?{...Se,position:{x:Math.max(((fe=L.get(Se.id))==null?void 0:fe.x)??0,oe+300),y:((xe=L.get(Se.id))==null?void 0:xe.y)??de}}:Se}),{...X,position:{x:oe,y:de}}];B({...t,nodes:we}),b(X.id),w(null)},z=t.nodes.find(X=>X.id===x),H=k===null?void 0:t.edges[k],G=X=>B({...t,nodes:t.nodes.map(re=>re.id===X.id?X:re)},`node:${X.id}`);return s.jsxs("div",{className:"pipeline-editor",ref:j,children:[s.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[s.jsx("div",{className:"sidebar-label",children:"脚本任务"}),f.length===0&&s.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),f.map(X=>s.jsxs("details",{className:"palette-group",open:f.length<=3,children:[s.jsx("summary",{children:X.scriptName}),X.tasks.map(re=>s.jsxs("button",{className:"palette-item",title:re.description??re.title,onClick:()=>V({id:ko(X.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:X.scriptId,taskId:re.id,params:{}}),children:[s.jsx("span",{children:re.title}),Hm[re.input]!==""&&s.jsx("span",{className:"badge",children:Hm[re.input]})]},re.id))]},X.scriptId)),s.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),s.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),s.jsx("button",{className:"palette-item",onClick:()=>V({id:ko("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),s.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),s.jsxs("div",{className:"pipeline-canvas",children:[s.jsxs(fH,{nodes:$,edges:O,nodeTypes:WH,onNodesChange:D,onConnect:F,onNodeClick:()=>w(null),onEdgeClick:(X,re)=>{w(Number(re.id.slice(1))),b(null)},onPaneClick:()=>{b(null),w(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[s.jsx(vH,{gap:20}),s.jsx(SH,{showInteractive:!1})]}),!t.nodes.some(X=>!Hi(X))&&s.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),s.jsxs("aside",{className:"pipeline-inspector",children:[z!==void 0&&s.jsx(QH,{client:e,node:z,pipeline:t,run:i,scripts:f,onChange:G,onTasksChanged:()=>h(X=>X+1),runFrom:o,onRemove:M}),H!==void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:"连线"}),s.jsxs("p",{className:"muted small",children:["「",((Z=t.nodes.find(X=>X.id===H.from))==null?void 0:Z.title)??H.from,"」→「",((Y=t.nodes.find(X=>X.id===H.to))==null?void 0:Y.title)??H.to,"」"]}),s.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),s.jsx(Dt,{id:"edge-when",value:H.when,onChange:X=>B({...t,edges:t.edges.map((re,ee)=>ee===k?{...re,when:X}:re)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>{B({...t,edges:t.edges.filter((X,re)=>re!==k)}),w(null)},children:"删除连线"})]}),g.length>1&&H===void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsxs("h4",{children:["已选 ",g.length," 个节点"]}),s.jsx("p",{className:"muted small",children:"Ctrl+C 复制、Ctrl+V 粘贴(连同它们之间的连线),Delete 删除,Ctrl+Z 撤销。开始和结束不会被复制或删除。"}),s.jsx("button",{className:"danger-outline small-button",onClick:M,children:"删除这些节点"})]}),z===void 0&&H===void 0&&g.length<=1&&(c??s.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销。"})),(z!==void 0||H!==void 0||g.length>1)&&c!==void 0&&s.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{b(null),w(null)},children:"← 流水线设置"})]})]})}function XH({client:e,value:t,onChange:n}){const i=y.useRef(null),r=Bw({client:e,text:t,setText:n,area:i,placement:"below"});return s.jsxs("div",{className:"slash-anchor",children:[s.jsx("textarea",{id:"node-prompt",ref:i,className:"text-input plain",rows:4,value:t,placeholder:"例如:/game-arknights 看看活动商店还剩什么没换",onChange:o=>n(o.target.value),onKeyDown:o=>{r.onKeyDown(o)}}),r.menu,s.jsx("p",{className:"muted small",children:"输入 / 可以选命令或技能,运行时展开成完整的指令。"})]})}function QH({client:e,node:t,pipeline:n,run:i,scripts:r,onChange:o,onRemove:c,onTasksChanged:u,runFrom:d}){var b,k;const[h,f]=y.useState(null),g=i==null?void 0:i.nodes[t.id],p=t.kind==="script-task"?(b=r.find(w=>w.scriptId===t.scriptId))==null?void 0:b.tasks.find(w=>w.id===t.taskId):void 0,x=t.onFailure;return Hi(t)?s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Qo[t.kind]}),s.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(g==null?void 0:g.detail)!==void 0&&s.jsx("div",{className:"muted small",children:g.detail})]}):s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Qo[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:w=>{const{title:j,...E}=t;o(w.target.value===""?E:{...E,title:w.target.value})}}),t.kind==="script-task"&&s.jsx(DS,{id:"node-profile",label:"用哪份配置",list:((k=r.find(w=>w.scriptId===t.scriptId))==null?void 0:k.profiles)??null,value:t.profile,onChange:w=>{const{profile:j,...E}=t;o(w===void 0?E:{...E,profile:w})}}),t.kind==="script-task"&&p!==void 0&&Object.entries(p.params).map(([w,j])=>s.jsx(zS,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:w,spec:j,profile:t.profile,value:String(t.params[w]??(j.type==="boolean"?j.default??!1:"")),onCreated:u,onChange:E=>{const{[w]:N,...C}=t.params,L=j.type==="boolean"?E==="true":j.type==="integer"||j.type==="number"?Number(E):E;o({...t,params:E===""?C:{...C,[w]:L}})}},w)),t.kind==="agent"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),s.jsx(XH,{client:e,value:t.prompt,onChange:w=>o({...t,prompt:w})})]}),(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:w=>o({...t,text:w.target.value})})]}),t.kind==="wait"&&s.jsxs("div",{className:"key-input",children:[s.jsx(Dt,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:w=>o(w==="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:w=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(w.target.value)||1)))})}):s.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:w=>o({...t,until:w.target.value})})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:w=>{const{waitForAll:j,...E}=t;o(w.target.checked?{...E,waitForAll:!0}:E)}}),"等前面的节点全部结束再开始"]}),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(Dt,{id:"node-retries","aria-label":"重试次数",value:x===void 0?"inherit":String(x.retries),options:[{value:"inherit",label:"按流水线的设置"},...IE],onChange:w=>{const{onFailure:j,...E}=t;if(w==="inherit")return o(E);o({...E,onFailure:{retries:Number(w),then:(x==null?void 0:x.then)??n.onFailure.then}})}}),s.jsx(Dt,{"aria-label":"仍失败时",disabled:x===void 0,value:(x??n.onFailure).then,options:TE,onChange:w=>o({...t,onFailure:{retries:(x==null?void 0:x.retries)??n.onFailure.retries,then:w}})})]}),x===void 0&&s.jsxs("p",{className:"muted small",children:["流水线的设置:",n.onFailure.retries>0?`重试 ${n.onFailure.retries} 次,`:"不重试,","然后",n.onFailure.then==="stop"?"停止流水线":"继续其他分支"]})]}),g!==void 0&&s.jsxs("div",{className:"inspector-run",children:[s.jsx("div",{className:"sidebar-label",children:"这次运行"}),s.jsxs("div",{children:[ig[g.state],g.attempts>1?` · 第 ${g.attempts} 次`:""]}),g.detail!==void 0&&s.jsx("div",{className:"muted small",children:g.detail}),g.runIds.length>0&&s.jsxs("div",{className:"muted small",children:["脚本运行:",g.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&g.state==="running"&&i!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"continue"}).catch(w=>f(Ie(w))),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:i.id,nodeId:t.id,decision:"stop"}).catch(w=>f(Ie(w))),children:"停止"})]})]}),h!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]}),d!==void 0&&s.jsxs("div",{className:"run-from",children:[s.jsxs("button",{className:"small-button",onClick:()=>d(t.id),children:[s.jsx(Q,{name:"arrow"}),"从这里开始运行"]}),s.jsx("span",{className:"muted small",children:"这一步和它后面的会运行,前面的不运行(例如前面已经跑过了)"})]}),s.jsx("button",{className:"danger-outline small-button",onClick:c,children:"删除这个节点"})]})}const Ld={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},JH=()=>({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"}),e9=(e,t)=>{var n,i;return(((n=t.lastRun)==null?void 0:n.startedAt)??-1)-(((i=e.lastRun)==null?void 0:i.startedAt)??-1)||(t.updatedAt??0)-(e.updatedAt??0)||e.name.localeCompare(t.name,"zh-CN")},$E="adg.pipelines.last",t9=()=>{try{return localStorage.getItem($E)}catch{return null}},n9=e=>{try{localStorage.setItem($E,e)}catch{}};function s9({client:e,openSettings:t,arg:n}){const i=je(e.connection.status),r=un(3e4),[o,c]=y.useState(null),[u,d]=y.useState(null),[h,f]=y.useState(null),[g,p]=y.useState(""),[x,b]=y.useState([]),[k,w]=y.useState(null),[j,E]=y.useState(null),[N,C]=y.useState(null),[L,$]=y.useState(null),[O,W]=y.useState(0);y.useEffect(()=>e.connection.on("pipelines/changed",()=>W(te=>te+1)),[e]);const B=je(e.capabilities),[U,D]=y.useState(null),[F,A]=y.useState(0);y.useEffect(()=>e.connection.on("schedule/changed",()=>A(te=>te+1)),[e]),y.useEffect(()=>{if(i.state!=="open"||!B.has("schedule"))return;let te=!0;return e.connection.call("schedule/status",{}).then(ne=>{te&&D(ne.settings)}).catch(()=>{}),()=>{te=!1}},[e,i.state,B,F]);const T=async te=>{try{D((await e.connection.call("schedule/settings/set",te)).settings)}catch(ne){$(Ie(ne))}};y.useEffect(()=>{n!==void 0&&d(n)},[n]),y.useEffect(()=>{if(i.state!=="open")return;let te=!0;return e.connection.call("pipelines/list",{}).then(ne=>{if(!te)return;const se=[...ne.items].sort(e9);c(se);const oe=t9();d(de=>{var we,Se;return de??((we=se.find(fe=>fe.id===oe))==null?void 0:we.id)??((Se=se[0])==null?void 0:Se.id)??null})}).catch(ne=>{te&&$(Ie(ne))}),()=>{te=!1}},[e,i.state,O]),y.useEffect(()=>{if(u===null||i.state!=="open"||(h==null?void 0:h.id)===u&&(o!=null&&o.every(ne=>ne.id!==u)))return;let te=!0;return e.connection.call("pipelines/get",{id:u}).then(ne=>{if(!te)return;const se=hR(ne);n9(se.id),f(se),p(JSON.stringify(se)),E(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(ne=>{te&&b(ne.items)}).catch(()=>{}),w(null),()=>{te=!1}},[e,u,i.state,O]),y.useEffect(()=>e.connection.on("pipelines/run",te=>{te.pipelineId===u&&b(ne=>[te,...ne.filter(se=>se.id!==te.id)].sort((se,oe)=>oe.startedAt-se.startedAt).slice(0,10))}),[e,u]);const M=h!==null&&JSON.stringify(h)!==g,P=h!==null&&o!==null&&o.every(te=>te.id!==h.id),V=x.find(te=>{var ne;return te.id===(k??((ne=x[0])==null?void 0:ne.id))}),z=x.find(te=>te.state==="running"),H=z!==void 0&&(z.stopping!==void 0||N==="cancel");y.useEffect(()=>{if(h===null||!h.nodes.some(ne=>!Hi(ne))){E(null);return}const te=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:h}).then(E).catch(()=>{})},400);return()=>clearTimeout(te)},[e,h]);const G=async(te,ne)=>{C(te),$(null);try{await ne()}catch(se){$(Ie(se))}finally{C(null)}},Z=()=>G("save",async()=>{if(h===null)return;const te=await e.connection.call("pipelines/save",{pipeline:h});f(te.pipeline),p(JSON.stringify(te.pipeline)),E(te.check),d(te.pipeline.id)}),Y=te=>G("run",async()=>{if(h===null)return;(M||P)&&await Z();const ne=await e.connection.call("pipelines/run",{id:h.id,...te===void 0?{}:{from:te}});w(ne.id)}),X=()=>G("remove",async()=>{h!==null&&(P||await e.connection.call("pipelines/remove",{id:h.id}),f(null),d(null))}),re=y.useCallback(te=>f(te),[]),ee=()=>{const te=JH();f(te),p(""),d(te.id),b([]),E(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(a9,{list:o??[],current:h,isNew:P,now:r,onPick:d}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>t("schedule"),children:[s.jsx(Q,{name:"settings"}),"定时与自启"]}),s.jsxs("button",{className:"primary small-button",onClick:ee,children:[s.jsx(Q,{name:"plus"}),"新建流水线"]})]})]}),s.jsx("div",{className:"pipeline-main",children:h===null?s.jsxs("div",{className:"empty",children:[s.jsx(Q,{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:h.name,maxLength:60,"aria-label":"流水线名称",onChange:te=>f({...h,name:te.target.value})}),h.draft===!0&&s.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),M&&s.jsx("span",{className:"muted small",children:"未保存"}),s.jsx("span",{className:"spacer"}),H?s.jsxs("button",{className:"danger-outline small-button stopping",disabled:!0,"aria-busy":"true",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),"正在停止…"]}):z!==void 0?s.jsx("button",{className:"danger-outline small-button",disabled:N!==null,onClick:()=>void G("cancel",()=>e.connection.call("pipelines/cancel",{runId:z.id})),children:"取消运行"}):s.jsxs("button",{className:"small-button",disabled:N!==null||!h.nodes.some(te=>!Hi(te))||(j==null?void 0:j.ok)===!1,onClick:()=>void Y(),children:[s.jsx(Q,{name:"arrow"}),"运行"]}),s.jsx("button",{className:"primary small-button",disabled:N!==null||!M&&!P&&h.draft!==!0,onClick:()=>void Z(),children:N==="save"?"保存中…":h.draft===!0&&!M?"确认并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:N!==null||z!==void 0,onClick:()=>void Ps({title:`删除流水线「${h.name}」?`,message:"它的步骤和定时都会删掉,不能撤销。",confirmLabel:"删除",danger:!0}).then(te=>{te&&X()}),children:"删除"})]}),H&&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:["已收到停止指令。",z.stopping??"正在通知正在运行的步骤…"]})]}),L!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:L})]}),s.jsx(YH,{client:e,pipeline:h,onChange:re,run:V,check:j,runFrom:z!==void 0||N!==null||(j==null?void 0:j.ok)===!1?void 0:te=>void Y(te),idle:s.jsx(o9,{pipeline:h,check:j,runs:x,shownRun:V==null?void 0:V.id,onShowRun:w,others:o??[],onChange:re,now:r,startup:U,onStartup:te=>void T(te)})},h.id)]})})]})}function i9({check:e,pipeline:t}){if(e===null)return null;const n=i=>{const r=t.nodes.find(o=>o.id===i);return r===void 0?"":`${r.title??r.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((i,r)=>s.jsxs("li",{className:i.level==="error"||i.level==="warning"?"failed":"",children:[i.level==="error"?"✗":i.level==="warning"?"!":"ℹ"," ",n(i.nodeId),i.message]},r))})]})}function r9({runs:e,shown:t,onShow:n,now:i}){if(e.length===0)return s.jsx("section",{className:"side-pane",children:s.jsx("p",{className:"muted small",children:"还没有运行过。"})});const r={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 ${Ld[o.state][0]}`,children:Ld[o.state][1]}),s.jsx("span",{className:"run-title",children:r[o.trigger.kind]??o.trigger.kind}),s.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),s.jsx("span",{className:"session-time",children:yt(o.startedAt,i)})]},o.id))}),s.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function a9({list:e,current:t,isNew:n,now:i,onPick:r}){const[o,c]=y.useState(!1),u=y.useRef(null);return y.useEffect(()=>{if(!o)return;const d=h=>{u.current!==null&&!u.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[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(d=>!d),children:[s.jsx(Q,{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(Q,{name:"chevron-down"})]}),o&&s.jsxs("div",{className:"switcher-menu",role:"listbox","aria-label":"流水线",children:[e.map(d=>s.jsxs("button",{role:"option","aria-selected":d.id===(t==null?void 0:t.id),className:`switcher-item ${d.id===(t==null?void 0:t.id)&&!n?"active":""}`,onClick:()=>{r(d.id),c(!1)},children:[s.jsxs("span",{className:"switcher-item-main",children:[s.jsx("span",{children:d.name}),s.jsxs("span",{className:"muted small",children:[d.nodes," 个步骤",d.schedule.enabled&&d.schedule.times.length>0?` · 每天 ${d.schedule.times.join("、")}`:"",d.lastRun===void 0?"":` · ${yt(d.lastRun.startedAt,i)}`]})]}),d.draft?s.jsx("span",{className:"badge warn",children:"草稿"}):d.lastRun!==void 0?s.jsx("span",{className:`badge ${Ld[d.lastRun.state][0]}`,children:Ld[d.lastRun.state][1]}):null]},d.id)),e.length===0&&s.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function o9({pipeline:e,check:t,runs:n,shownRun:i,onShowRun:r,others:o,onChange:c,now:u,startup:d,onStartup:h}){const[f,g]=y.useState(n.some(x=>x.state==="running")?"runs":"check"),p=(t==null?void 0:t.issues.filter(x=>x.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":f==="check",className:f==="check"?"active":"",onClick:()=>g("check"),children:["检查",p>0?` · ${p}`:""]}),s.jsx("button",{role:"tab","aria-selected":f==="runs",className:f==="runs"?"active":"",onClick:()=>g("runs"),children:"运行记录"}),s.jsx("button",{role:"tab","aria-selected":f==="schedule",className:f==="schedule"?"active":"",onClick:()=>g("schedule"),children:"定时与失败"})]}),f==="check"&&(t===null?s.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):s.jsx(i9,{check:t,pipeline:e})),f==="runs"&&s.jsx(r9,{runs:n,shown:i,onShow:r,now:u}),f==="schedule"&&s.jsx(c9,{pipeline:e,others:o,onChange:c,startup:d,onStartup:h}),s.jsx("p",{className:"muted small pad",children:"点画布上的节点或连线来修改它;选中后按 Delete 删除。Ctrl+点击或按住 Shift 拖动可以选多个节点,Ctrl+C / Ctrl+V 复制粘贴,Ctrl+Z 撤销、Ctrl+Y 重做。"})]})}const l9=["日","一","二","三","四","五","六"],cN={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function c9({pipeline:e,others:t,onChange:n,startup:i,onStartup:r}){const o=(i==null?void 0:i.autostartPipelines.includes(e.id))===!0,c=e.schedule,[u,d]=y.useState(c.times.join(","));y.useEffect(()=>d(c.times.join(",")),[e.id]);const h=p=>n({...e,schedule:{...c,...p}}),f=y.useMemo(()=>u.split(/[,,\s]+/).map(p=>p.trim()).filter(Boolean).map(p=>/^\d:\d\d$/.test(p)?`0${p}`:p),[u]),g=f.filter(p=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(p));return s.jsxs("section",{className:"side-pane",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,onChange:p=>h({enabled:p.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:p=>d(p.target.value),onBlur:()=>{g.length===0&&h({times:[...new Set(f)].sort()})}}),g.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["时间写成 HH:MM:",g.join("、")]})]}),s.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[l9.map((p,x)=>s.jsxs("button",{className:`chip ${c.days.includes(x)?"active":""}`,onClick:()=>h({days:c.days.includes(x)?c.days.filter(b=>b!==x):[...c.days,x].sort()}),children:["周",p]},p)),s.jsx("span",{className:"muted small",children:c.days.length===0?"不选=每天":""})]}),i!==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:p=>r({autostartPipelines:p.target.checked?[...i.autostartPipelines,e.id]:i.autostartPipelines.filter(x=>x!==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:i.firstStartOnly,onChange:p=>r({firstStartOnly:p.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:i.skipIfRanToday,onChange:p=>r({skipIfRanToday:p.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),s.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",i.autostart?`开机自启时等 ${i.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:p=>h({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(p.target.value)||0)))})}),s.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),s.jsx(Dt,{id:"pl-after",value:c.after??"",onChange:p=>{const{after:x,...b}=c;n({...e,schedule:p===""?b:{...b,after:p}})},options:[{value:"",label:"不接续"},...t.filter(p=>p.id!==e.id).map(p=>({value:p.id,label:p.name}))]}),s.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(Dt,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:IE,onChange:p=>n({...e,onFailure:{...e.onFailure,retries:Number(p)}})}),s.jsx(Dt,{"aria-label":"仍失败时",value:e.onFailure.then,options:TE,onChange:p=>n({...e,onFailure:{...e.onFailure,then:p}})})]}),s.jsx("div",{className:"field-label",children:"结束后"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:p=>n({...e,closeGameAfter:p.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:p=>n({...e,stopEmulatorAfter:p.target.checked})}),"关闭模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),s.jsx(Dt,{id:"pl-power",value:e.powerAfter,onChange:p=>n({...e,powerAfter:p}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&s.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",i===null?"":` ${i.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",cN[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",cN[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const uN=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),dN={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function u9({client:e}){const t=je(e.connection.status),n=un(3e4),[i,r]=y.useState(null),[o,c]=y.useState(0),[u,d]=y.useState(!1),[h,f]=y.useState(null);y.useEffect(()=>e.connection.on("schedule/changed",()=>c(x=>x+1)),[e]),y.useEffect(()=>e.connection.on("pipelines/changed",()=>c(x=>x+1)),[e]),y.useEffect(()=>e.connection.on("schedule/power",x=>r(b=>b===null?b:{...b,power:x})),[e]),y.useEffect(()=>{if(t.state!=="open")return;let x=!0;return e.connection.call("schedule/status",{}).then(b=>{x&&r(b)}).catch(b=>{x&&f(Ie(b))}),()=>{x=!1}},[e,t.state,o]);const g=async x=>{d(!0),f(null);try{r(await e.connection.call("schedule/settings/set",x))}catch(b){f(Ie(b))}finally{d(!1)}},p=i==null?void 0:i.settings;return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"定时与自启"}),s.jsx("p",{children:"每条流水线的运行时间和结束后做什么(关游戏、关模拟器、睡眠或关机)在「编排」页里设置。这里设置电脑开机登录后是否自动启动 MultiGameAssistant,以及电脑睡着时要不要按时醒来。关掉窗口后程序在托盘里继续运行,定时照常执行。"}),i!==null&&p!==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:i.autostart.detail??(i.autostart.registered?"已在 Windows 任务计划程序中注册(登录后启动,最小化到托盘)":"登录 Windows 后自动启动并最小化到托盘")})]}),s.jsx("span",{className:`badge ${i.autostart.registered?"ok":""}`,children:i.autostart.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:p.autostart,disabled:u||!i.autostart.available,onChange:x=>void g({autostart:x.target.checked})}),"登录 Windows 后自动启动"]}),s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:["软件启动时运行哪些流水线、是否只在每天第一次启动时运行,在「编排」页每条流水线的「定时与失败」里设置。",p.autostartPipelines.length>0?`现在有 ${p.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:p.autostartDelaySeconds,onBlur:x=>void g({autostartDelaySeconds:Math.max(0,Math.min(1800,Math.round(Number(x.target.value)||0)))})}),i.autostarted&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:"这次是开机自动启动的。"})]})]}),i!==null&&p!==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:i.wake.detail??(i.wake.registered&&i.wake.next!==void 0?`已在 Windows 任务计划程序中注册,下次在 ${uN(i.wake.next)} 唤醒`:"电脑睡眠(或休眠)时,在定时任务开始前 2 分钟把它唤醒")})]}),s.jsx("span",{className:`badge ${i.wake.registered?"ok":""}`,children:i.wake.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:p.wakeToRun,disabled:u||!i.wake.available,onChange:x=>void g({wakeToRun:x.target.checked})}),"睡眠时按定时唤醒电脑"]}),s.jsx("p",{className:"muted small",children:"关机后不能唤醒。程序没开着时,唤醒会顺便把它在托盘里打开(不运行「软件启动时运行」的流水线)。要在 Windows 电源选项里允许唤醒定时器:控制面板 → 电源选项 → 更改计划设置 → 更改高级电源设置 → 睡眠 → 允许使用唤醒定时器 → 启用(笔记本的「使用电池」也要改)。"}),s.jsx("h3",{children:"运行时防睡眠"}),s.jsxs("p",{className:"muted small",children:["流水线或脚本运行时,电脑不会自己睡眠;前台脚本(用鼠标键盘的)运行时屏幕也保持亮着。全部结束后恢复 Windows 自己的设置。",i.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:p.powerCountdownSeconds,onBlur:x=>void g({powerCountdownSeconds:Math.max(10,Math.min(600,Math.round(Number(x.target.value)||60)))})})]}),i!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"接下来"}),i.upcoming.length===0&&s.jsx("div",{className:"muted small",children:"没有开启定时的流水线。"}),s.jsx("ul",{className:"version-list",children:i.upcoming.map((x,b)=>s.jsxs("li",{children:[s.jsx("span",{className:"version-name",children:uN(x.at)}),s.jsx("span",{children:x.pipelineName})]},b))})]}),i!==null&&i.history.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"最近的定时记录"}),s.jsx("ul",{className:"version-list",children:i.history.map((x,b)=>{var k,w;return s.jsxs("li",{children:[s.jsx("span",{className:`badge ${((k=dN[x.outcome])==null?void 0:k[0])??""}`,children:((w=dN[x.outcome])==null?void 0:w[1])??x.outcome}),s.jsx("span",{children:x.pipelineName}),s.jsxs("span",{className:"muted small",children:[x.slot,x.detail===void 0?"":` · ${x.detail}`]}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:yt(x.at,n)})]},b)})})]}),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:"想在手机上收到结果,先在「设置 → 飞书」接好飞书。"})]})]}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]})]})}const d9={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:s9}]},h9={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:u9}]},Zm=new Map;function ME(e,t){let n=Zm.get(t);return n===void 0&&(n=e.connection.call("games/image",{url:t}).then(i=>`data:${i.mediaType};base64,${i.data}`),n.catch(()=>Zm.delete(t)),Zm.set(t,n)),n}function RE(e,t){const[n,i]=y.useState(void 0),r=t.filter(o=>o!==void 0).filter((o,c,u)=>u.indexOf(o)===c);return y.useEffect(()=>{i(void 0);let o=!0;return(async()=>{for(const c of r){const u=await ME(e,c).catch(()=>{});if(u!==void 0){o&&i(u);return}}})(),()=>{o=!1}},[e,r.join(`
232
+ `)]),n}function tl(e,t){const[n,i]=y.useState(void 0);return y.useEffect(()=>{if(i(void 0),t===void 0)return;let r=!0;return ME(e,t).then(o=>{r&&i(o)},()=>{}),()=>{r=!1}},[e,t]),n}const OE=["image/png","image/jpeg","image/gif","image/webp","image/avif"],f9=8*1024*1024;function rg(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(i=>[i.type,Number(i.value)]));return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3}function m9(e){var n;return(((n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date).find(i=>i.type==="timeZoneName"))==null?void 0:n.value)??"").replace("GMT","UTC")||e}function hN(e,t){return e===void 0?"":new Date(e+rg(e,t)).toISOString().slice(0,16)}function fN(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);if(n===null)return;const i=Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]),Number(n[4]),Number(n[5]));return i-rg(i-rg(i,t),t)}function p9(e){return new Promise((t,n)=>{if(!OE.includes(e.type)){n(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>f9){n(new Error("图片太大(最多 8 MB)"));return}const i=new FileReader;i.onload=()=>{const r=String(i.result);t({image:{mediaType:e.type,data:r.slice(r.indexOf(",")+1)},src:r})},i.onerror=()=>n(new Error("图片读不出来")),i.readAsDataURL(e)})}function wx({client:e,game:t,activity:n,onDone:i,onCancel:r}){var U;const o=t.timezone,c={name:(n==null?void 0:n.name)??"",kind:(n==null?void 0:n.kind)??"",startsAt:hN(n==null?void 0:n.startsAt,o),endsAt:hN(n==null?void 0:n.endsAt,o),url:(n==null?void 0:n.url)??"",description:(n==null?void 0:n.description)??""},[u,d]=y.useState(c),[h,f]=y.useState(null),[g,p]=y.useState(!1),[x,b]=y.useState(!1),[k,w]=y.useState(null),j=y.useRef(null),E=((U=n==null?void 0:n.own)==null?void 0:U.fields.includes("cover"))===!0,N=tl(e,g||n==null?void 0:n.cover),C=(h==null?void 0:h.src)??N,L=n!==void 0&&(n.sources!==void 0||n.screen!==void 0);y.useEffect(()=>{w(null)},[u]);const $=D=>F=>d(A=>({...A,[D]:F.target.value})),O=D=>{D!==void 0&&p9(D).then(F=>{f(F),p(!1)},F=>w(Ie(F)))},W=D=>{const F=[...D.clipboardData.files].find(A=>A.type.startsWith("image/"));F!==void 0&&(D.preventDefault(),O(F))},B=async()=>{if(u.name.trim()===""){w("活动要有名字");return}const D=u.startsAt===""?null:fN(u.startsAt,o)??null,F=u.endsAt===""?null:fN(u.endsAt,o)??null;if(D!==null&&F!==null&&F<=D){w("结束时间要晚于开始时间");return}const A=P=>n===void 0||u[P]!==c[P],T=P=>A(P)?{[P]:u[P].trim()===""?null:u[P].trim()}:{},M={game:t.id,...n===void 0?{}:{activityId:n.id},...T("name"),...T("kind"),...T("url"),...T("description"),...A("startsAt")?{startsAt:D}:{},...A("endsAt")?{endsAt:F}:{},...h!==null?{image:h.image}:g?{cover:null}:{}};b(!0),w(null);try{i(await e.connection.call("games/activity/save",M))}catch(P){w(Ie(P))}finally{b(!1)}};return s.jsxs("form",{className:"activity-editor",onSubmit:D=>{D.preventDefault(),B()},onPaste:W,onKeyDown:D=>{D.key==="Escape"&&r()},children:[s.jsxs("div",{className:"activity-editor-head",children:[s.jsx("strong",{children:n===void 0?`添加${t.name}的活动`:"编辑活动"}),L&&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 ${C===void 0?"empty":""}`,onClick:()=>{var D;return(D=j.current)==null?void 0:D.click()},title:"选一张图片(也可以直接粘贴)",children:C!==void 0?s.jsx("img",{src:C,alt:""}):s.jsxs(s.Fragment,{children:[s.jsx(Q,{name:"image"}),s.jsx("span",{children:"选图片"}),s.jsx("small",{children:"或粘贴"})]})}),s.jsx("input",{ref:j,type:"file",accept:OE.join(","),hidden:!0,onChange:D=>{var F;O((F=D.target.files)==null?void 0:F[0]),D.target.value=""}}),s.jsxs("div",{className:"activity-image-tools",children:[s.jsx("span",{className:"muted small",children:C===void 0?"点上面选图,或直接粘贴":"点图片换一张,或直接粘贴"}),(h!==null||E&&!g)&&s.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{f(null),E&&p(!0)},children:h!==null?"不用这张":L?"用回来源的图":"去掉图片"})]})]}),s.jsxs("div",{className:"activity-editor-fields top",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:$("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:$("kind"),placeholder:"签到、SideStory…"})]})]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field date",children:[s.jsx("span",{className:"field-title",children:"开始"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.startsAt,onChange:$("startsAt")})]}),s.jsxs("label",{className:"field date",children:[s.jsx("span",{className:"field-title",children:"结束"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.endsAt,onChange:$("endsAt")})]})]}),s.jsxs("span",{className:"muted small",children:["时间按游戏服务器时间(",m9(o),")",u.endsAt===""?";不填结束时间的会一直留着,直到你去掉它":""]})]}),s.jsxs("div",{className:"activity-editor-fields full",children:[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:$("url"),placeholder:"https://…"})]}),s.jsxs("label",{className:"field description",children:[s.jsxs("span",{className:"field-title",children:["说明(可选)",s.jsxs("small",{className:"muted",children:[u.description.length,"/500"]})]}),s.jsx("textarea",{className:"text-input plain",rows:8,maxLength:500,value:u.description,onChange:$("description"),placeholder:"要做什么、奖励是什么"})]})]})]}),s.jsxs("div",{className:"activity-editor-actions",children:[s.jsx("button",{className:"small-button primary",type:"submit",disabled:x,children:x?"保存中…":n===void 0?"添加":"保存"}),s.jsx("button",{className:"small-button",type:"button",disabled:x,onClick:r,children:"取消"}),k!==null&&s.jsx("span",{className:"tone-error small",children:k})]})]})}const ei=864e5,mN={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},Wm=2,g9=28,Xr=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],pN="adg:games:overview:shown",gN="adg:games:overview:mode";function xN(e,t){try{const n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function vN(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}function rs(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 x9(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function gd(e,t){const n=e-t;return n<=0?"已结束":n<ei?`${Math.max(1,Math.floor(n/36e5))} 小时`:`${Math.floor(n/ei)} 天`}function v9({client:e,games:t,activities:n,now:i,soonDays:r,onOpenGame:o,onChanged:c}){const[u,d]=y.useState(()=>xN(pN,null)),[h,f]=y.useState(()=>xN(gN,"time")),[g,p]=y.useState(null);y.useEffect(()=>vN(pN,u),[u]),y.useEffect(()=>vN(gN,h),[h]);const x=y.useMemo(()=>new Map(t.map((F,A)=>[F.id,Xr[A%Xr.length]])),[t]),b=F=>u===null||u.includes(F),k=F=>d(A=>{const T=A??t.map(P=>P.id),M=T.includes(F)?T.filter(P=>P!==F):[...T,F];return M.length===t.length?null:M}),w=new Date(i-Wm*ei).setHours(0,0,0,0),j=w+(Wm+g9)*ei,E=F=>Math.min(100,Math.max(0,(F-w)/(j-w)*100)),N=n.filter(F=>b(F.game)&&(F.endsAt===void 0||Math.max(F.endsAt,F.shopEndsAt??0)>i)),C=(F,A)=>(F.endsAt??1/0)-(A.endsAt??1/0)||F.name.localeCompare(A.name),L=N.filter(F=>(F.startsAt??0)<=i),$=N.filter(F=>F.startsAt!==void 0&&F.startsAt>i).sort((F,A)=>F.startsAt-A.startsAt),O=[];if(h==="time"){const F=w+(Wm+7)*ei,A=L.filter(P=>P.endsAt!==void 0&&P.endsAt-i<r*ei).sort(C),T=L.filter(P=>!A.includes(P)&&P.endsAt!==void 0&&P.endsAt<F).sort(C),M=L.filter(P=>!A.includes(P)&&!T.includes(P)).sort(C);O.push({key:"soon",title:"快结束",hint:`${r} 天内`,rows:A},{key:"week",title:"本周内结束",rows:T},{key:"later",title:"之后结束",rows:M},{key:"upcoming",title:"即将开始",rows:$})}else for(const F of t){if(!b(F.id))continue;const A=[...L.filter(T=>T.game===F.id).sort(C),...$.filter(T=>T.game===F.id)];O.push({key:F.id,title:F.name,rows:A,game:F})}const W=L.reduce((F,A)=>{const T=rs(A);return{...F,[T.state]:F[T.state]+1}},{finished:0,partial:0,unknown:0}),B=L.filter(F=>F.endsAt!==void 0&&F.endsAt-i<r*ei&&rs(F).state!=="finished").length,U=[];for(let F=w;F<=j;F+=ei){const A=Math.round((F-new Date(i).setHours(0,0,0,0))/ei);U.push({at:F,...A>0&&A%7===0?{label:x9(F,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}const D=F=>n.filter(A=>A.game===F&&(A.startsAt??0)<=i&&(A.endsAt===void 0||Math.max(A.endsAt,A.shopEndsAt??0)>i));return s.jsxs("div",{className:"games-overview",children:[s.jsx("div",{className:"game-tiles",role:"group","aria-label":"各游戏",children:t.map(F=>{const A=D(F.id);return s.jsx(y9,{client:e,game:F,color:x.get(F.id)??Xr[0],now:i,shown:b(F.id),running:A.length,soon:A.filter(T=>T.endsAt!==void 0&&T.endsAt-i<r*ei&&rs(T).state!=="finished").length,covers:A.map(T=>T.cover).filter(T=>(T==null?void 0:T.startsWith("shot:"))!==!0).slice(0,6),onOpen:()=>o(F.id),onToggle:()=>k(F.id)},F.id)})}),s.jsxs("section",{className:"card games-overview-board",children:[s.jsxs("div",{className:"ov-toolbar",children:[s.jsxs("div",{className:"ov-stats",children:[s.jsx(Bl,{value:L.length,label:"进行中"}),s.jsx(Bl,{value:B,label:"快结束未做完",tone:B>0?"warn":void 0}),s.jsx(Bl,{value:W.finished,label:"做完"}),s.jsx(Bl,{value:W.partial,label:"做了一部分"}),s.jsx(Bl,{value:W.unknown,label:"没记录"})]}),s.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[s.jsx("button",{className:h==="time"?"active":"","aria-pressed":h==="time",onClick:()=>f("time"),children:"按时间"}),s.jsx("button",{className:h==="game"?"active":"","aria-pressed":h==="game",onClick:()=>f("game"),children:"按游戏"})]})]}),s.jsxs("div",{className:"ov-grid",children:[s.jsx("div",{className:"ov-lines","aria-hidden":"true",children:U.filter(F=>F.label!==void 0).map(F=>s.jsx("i",{style:{left:`${E(F.at)}%`}},F.at))}),s.jsxs("div",{className:"ov-row ov-axis","aria-hidden":"true",children:[s.jsx("div",{className:"ov-label"}),s.jsxs("div",{className:"ov-track",children:[U.map(F=>s.jsx("span",{className:`ov-tick ${F.label!==void 0?"major":""}`,style:{left:`${E(F.at)}%`},children:F.label!==void 0&&s.jsx("em",{children:F.label})},F.at)),s.jsx("span",{className:"ov-today-label",style:{left:`${E(i)}%`},children:"今天"})]}),s.jsx("div",{className:"ov-side"})]}),O.every(F=>F.rows.length===0)&&s.jsxs("div",{className:"empty",children:[s.jsx(Q,{name:"calendar"}),s.jsx("p",{children:t.length===0?"没有游戏。":"显示的游戏现在没有活动。点「刷新全部」读取,或点上面游戏卡片的眼睛多显示几个。"})]}),O.filter(F=>F.rows.length>0).map(F=>{var A;return s.jsxs("div",{className:`ov-section ${F.key==="soon"?"warn":""} ${F.game!==void 0?"by-game":""}`,style:F.game===void 0?void 0:{"--game":x.get(F.game.id)},children:[s.jsxs("div",{className:"ov-section-title",children:[F.game!==void 0&&s.jsx("span",{className:"game-dot"}),s.jsx("span",{className:"ov-section-name",children:F.title}),s.jsx("span",{className:"ov-section-count",children:F.rows.length}),F.hint!==void 0&&s.jsx("span",{className:"muted small",children:F.hint}),((A=F.game)==null?void 0:A.version)!==void 0&&s.jsxs("span",{className:"muted small ov-section-version",children:[F.game.version.name,F.game.version.title===void 0?"":`「${F.game.version.title}」`]}),F.game!==void 0&&s.jsxs("button",{className:"link-button small ov-section-open",onClick:()=>o(F.game.id),children:["打开",s.jsx(Q,{name:"chevron"})]})]}),F.rows.map(T=>{const M=t.find(P=>P.id===T.game);return s.jsx(b9,{client:e,activity:T,game:M,color:x.get(T.game)??Xr[0],showGame:h==="time",now:i,soonDays:r,x:E,open:g===T.id,onToggle:()=>p(P=>P===T.id?null:T.id),onOpenGame:()=>o(T.game),onChanged:c},T.id)})]},F.key)}),s.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${E(i)/100})`},"aria-hidden":"true"})]})]})]})}function Bl({value:e,label:t,tone:n}){return s.jsxs("span",{className:`ov-stat ${n??""} ${e===0?"zero":""}`,children:[s.jsx("strong",{children:e}),t]})}function y9({client:e,game:t,color:n,covers:i,now:r,running:o,soon:c,shown:u,onOpen:d,onToggle:h}){const f=t.version,g=RE(e,[f==null?void 0:f.cover,t.art,...i]),p=(f==null?void 0:f.endsAt)!==void 0&&f.endsAt>r?` · 还剩 ${gd(f.endsAt,r)}`:"";return s.jsxs("article",{className:`game-tile ${g===void 0?"no-art":""} ${u?"":"off"}`,style:{"--game":n},children:[g!==void 0&&s.jsx("img",{className:"game-tile-art",src:g,alt:""}),s.jsx("span",{className:"game-tile-shade"}),s.jsxs("button",{className:"game-tile-open",title:`打开${t.name}`,onClick:d,children:[s.jsxs("span",{className:"game-tile-name",children:[s.jsx("span",{className:"game-dot"}),t.name]}),s.jsx("span",{className:"game-tile-version",children:f===void 0?"没有版本信息":`${f.name}${f.title===void 0?"":`「${f.title}」`}${p}`}),s.jsxs("span",{className:"game-tile-counts",children:[s.jsxs("span",{children:[s.jsx("b",{children:o})," 进行中"]}),c>0&&s.jsxs("span",{className:"soon",children:[s.jsx("b",{children:c})," 快结束"]})]})]}),s.jsx("button",{className:"game-tile-eye","aria-pressed":u,"aria-label":`在时间线上显示${t.name}`,title:u?"在时间线上隐藏":"在时间线上显示",onClick:h,children:s.jsx(Q,{name:u?"eye":"eye-off"})})]})}function b9({client:e,activity:t,game:n,color:i,showGame:r,now:o,soonDays:c,x:u,open:d,onToggle:h,onOpenGame:f,onChanged:g}){const p=rs(t),x=(t.startsAt??0)<=o,b=t.endsAt,k=x&&b!==void 0&&b-o<c*ei&&p.state!=="finished",w=u(t.startsAt??o-30*ei),j=b===void 0?100:u(b),E=t.shopEndsAt===void 0||b===void 0||t.shopEndsAt<=b?void 0:u(t.shopEndsAt),N=tl(e,t.cover);return s.jsxs("div",{className:`ov-item ${d?"open":""}`,style:{"--game":i},children:[s.jsxs("button",{className:`ov-row ${k?"soon":""} ${p.state==="finished"?"finished":""}`,onClick:h,"aria-expanded":d,children:[s.jsxs("div",{className:"ov-label",children:[s.jsx("span",{className:"ov-thumb",children:N!==void 0&&s.jsx("img",{src:N,alt:"",decoding:"async"})}),s.jsxs("span",{className:"ov-text",children:[s.jsx("span",{className:"ov-name",title:t.name,children:t.name}),(r||t.kind!==void 0)&&s.jsxs("span",{className:"ov-meta",children:[r&&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 ${x?"":"future"} ${w<=0?"cut-left":""} ${b===void 0||j>=100?"cut-right":""}`,style:{left:`${w}%`,width:`${Math.max(1.2,j-w)}%`},children:p.total>0&&s.jsx("span",{className:"ov-bar-done",style:{width:`${p.done/p.total*100}%`}})}),E!==void 0&&s.jsx("span",{className:"ov-shop",style:{left:`${j}%`,width:`${Math.max(.6,E-j)}%`},title:"之后只开商店"})]}),s.jsxs("div",{className:"ov-side",children:[s.jsx("span",{className:`ov-left ${k?"tone-warn":""}`,children:x?b===void 0?"时间未知":b<=o&&t.shopEndsAt!==void 0?`商店 ${gd(t.shopEndsAt,o)}`:gd(b,o):`${gd(t.startsAt,o)}后开始`}),s.jsx(Sx,{progress:p})]})]}),d&&s.jsx(N9,{client:e,activity:t,game:n,onOpenGame:f,onChanged:g})]})}function Sx({progress:e}){return e.state==="finished"?s.jsxs("span",{className:"ov-progress done",children:[s.jsx(Q,{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 k9({activity:e,game:t,chosen:n,onChoose:i}){const r=un(6e4),o=e.sources??(e.site===void 0?[]:[{id:e.site.source,name:e.site.name,at:e.site.at,web:!1,startsAt:void 0,endsAt:void 0,cover:void 0}]);if(o.length===0&&e.screen===void 0&&e.own===void 0)return null;const c=(t==null?void 0:t.timezone)??"Asia/Shanghai",u=x=>new Date(x).toLocaleString("zh-CN",{timeZone:c,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),d=x=>`${x.startsAt===void 0&&x.endsAt===void 0?"没有时间":`${x.startsAt===void 0?"?":u(x.startsAt)} – ${x.endsAt===void 0?"?":u(x.endsAt)}`},${x.cover===void 0?"没有图片":"有图片"}`,h=x=>i(n===x?null:x),f=o.length===0&&e.screen===void 0,g=e.own!==void 0&&(e.own.startsAt!==void 0||e.own.endsAt!==void 0||e.own.cover!==void 0),p=e.screen!==void 0&&(e.screen.endsAt!==void 0||e.screen.image!==void 0);return s.jsxs("div",{className:"activity-sources",children:[s.jsx("span",{className:"muted small",children:"来源"}),o.map(x=>{var b;return s.jsxs("button",{className:`fact-chip ${x.web?"web":"site"} ${n===x.id?"on":""}`,"aria-pressed":n===x.id,title:`${d(x)}。点一下用它的图片和时间`,onClick:()=>h(x.id),children:[x.name,s.jsxs("small",{children:[x.web?"网页":"数据站"," · ",yt(x.at,r)]}),o.length>1&&((b=e.shown)==null?void 0:b.endsAt)===x.id&&s.jsx("small",{className:"fact-main",children:"时间以它为准"})]},x.id)}),e.screen!==void 0&&s.jsxs("button",{className:`fact-chip screen ${n===nc?"on":""}`,"aria-pressed":n===nc,disabled:!p,title:`agent 进游戏看到的。${d({endsAt:e.screen.endsAt,cover:e.screen.image})}`,onClick:()=>h(nc),children:["游戏画面",s.jsxs("small",{children:["agent 看过 · ",yt(e.screen.at,r)]})]}),e.own!==void 0&&s.jsxs("button",{className:`fact-chip own ${n===Ao?"on":""}`,"aria-pressed":n===Ao,disabled:!g||f,title:f?"你自己添加的活动":`你改过:${e.own.fields.map(x=>mN[x]).join("、")};比来源优先,刷新不会改掉`,onClick:()=>h(Ao),children:[f?"我添加的":"我改过",s.jsxs("small",{children:[f?"":`${e.own.fields.map(x=>mN[x]).join("、")} · `,yt(e.own.at,r)]})]}),n!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>i(null),children:"恢复默认"})]})}function N9({client:e,activity:t,game:n,onOpenGame:i,onChanged:r,openSession:o}){var T,M;const[c,u]=y.useState(null),[d,h]=y.useState(!1),[f,g]=y.useState(""),[p,x]=y.useState(!1),[b,k]=y.useState(null),[w,j]=y.useState(void 0);y.useEffect(()=>j(void 0),[t]);const E=w??t,[N,C]=y.useState(void 0);y.useEffect(()=>C(void 0),[E.chosen]);const L=P=>{C(P),k(null),e.connection.call("games/activity/source",{activityId:E.id,source:P}).then(V=>{j(V),r()},V=>{C(void 0),k(Ie(V))})},$=(n==null?void 0:n.timezone)??"Asia/Shanghai",O=P=>new Date(P).toLocaleString("zh-CN",{timeZone:$,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),W=async P=>{x(!0),k(null);try{await e.connection.call("games/activity/progress",{activityId:E.id,...P}),r()}catch(V){k(Ie(V))}finally{x(!1)}},B=P=>void W({todo:E.todo.filter(V=>V!==P),done:[...E.done,P]}),U=P=>void W({todo:[...E.todo,P],done:E.done.filter(V=>V!==P)}),D=()=>{const P=f.trim();P===""||E.todo.includes(P)||E.done.includes(P)||(g(""),W({todo:[...E.todo,P]}))},F=E.sources!==void 0||E.screen!==void 0,A=()=>{x(!0),k(null),e.connection.call("games/activity/reset",{activityId:E.id}).then(r,P=>k(Ie(P))).finally(()=>x(!1))};return d&&n!==void 0?s.jsx("div",{className:"ov-detail",children:s.jsx(wx,{client:e,game:n,activity:E,onDone:()=>{h(!1),r()},onCancel:()=>h(!1)})}):s.jsxs("div",{className:"ov-detail",children:[E.description!==void 0&&s.jsx("p",{className:"ov-description",children:E.description}),s.jsxs("div",{className:"activity-dates muted small",children:[E.startsAt!==void 0&&s.jsxs("span",{children:[O(E.startsAt)," 开始"]}),E.endsAt!==void 0&&s.jsxs("span",{children:[O(E.endsAt)," 结束"]}),E.shopEndsAt!==void 0&&s.jsxs("span",{children:["商店开到 ",O(E.shopEndsAt)]})]}),s.jsx(k9,{activity:E,game:n,chosen:N!==void 0?N??void 0:E.chosen,onChoose:L}),s.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[E.todo.map(P=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:p,onChange:()=>B(P)}),P]},`t${P}`)),E.done.map(P=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:p,onChange:()=>U(P)}),P]},`d${P}`)),E.todo.length+E.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:f,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:p,onChange:P=>g(P.target.value),onKeyDown:P=>{P.key==="Enter"&&D()}}),s.jsxs("button",{className:"small-button",disabled:p||f.trim()==="",onClick:D,children:[s.jsx(Q,{name:"plus"}),"添加"]})]}),s.jsxs("div",{className:"ov-detail-actions",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:E.finished!==void 0,disabled:p,onChange:P=>void W({finished:P.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),((T=E.screen)==null?void 0:T.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:E.id}).then(P=>{const V=`data:${P.mediaType};base64,${P.data}`,z=new Image;z.onload=()=>u({src:V,width:z.naturalWidth,height:z.naturalHeight}),z.src=V},P=>k(Ie(P))),children:"看游戏截图"}),((M=E.screen)==null?void 0:M.sessionId)!==void 0&&o!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(E.screen.sessionId),children:"agent 的对话"}),E.url!==void 0&&s.jsx("a",{className:"link-button small",href:E.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),i!==void 0&&s.jsxs("button",{className:"link-button small",onClick:i,children:["去",(n==null?void 0:n.name)??"游戏"]}),n!==void 0&&s.jsxs("button",{className:"link-button small",disabled:p,onClick:()=>h(!0),children:[s.jsx(Q,{name:"pencil"}),"编辑"]}),E.own!==void 0&&F&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:p,onClick:A,children:"恢复来源的内容"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:p,onClick:()=>void e.connection.call("games/activity/remove",{activityId:E.id}).then(r,P=>k(Ie(P))),children:"从日历去掉"})]}),b!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:b})]}),c!==null&&s.jsx(Xd,{src:c.src,width:c.width,height:c.height,name:`${E.name}.png`,onClose:()=>u(null)})]})}function j9({client:e,onChanged:t,onDiscover:n}){const[i,r]=y.useState(null),[o,c]=y.useState(""),[u,d]=y.useState(null),[h,f]=y.useState(null),[g,p]=y.useState(0);y.useEffect(()=>{let b=!0;return e.connection.call("games/catalog",{}).then(k=>{b&&r(k.games)}).catch(k=>{b&&f(Ie(k))}),()=>{b=!1}},[e,g]);const x=async(b,k)=>{d(b),f(null);try{await e.connection.call("games/follow",{sra:b,follow:k}),p(w=>w+1),t()}catch(w){f(Ie(w))}finally{d(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"}),"(社区按官方公告整理,免费,不用模型)。勾上的游戏每天自动读一次。"]}),i===null&&h===null&&s.jsx("p",{className:"muted small",children:"正在读取…"}),s.jsx("div",{className:"catalog-grid",children:i==null?void 0:i.map(b=>s.jsxs("label",{className:`check-label ${b.pack!==void 0?"muted":""}`,title:b.pack!==void 0?"已经有游戏包在读它":void 0,children:[s.jsx("input",{type:"checkbox",checked:b.pack!==void 0||b.followed,disabled:b.pack!==void 0||u!==null,onChange:k=>void x(b.sra,k.target.checked)}),b.name,b.pack!==void 0?"(已有)":u===b.sra?"…":""]},b.sra))}),n!==void 0&&s.jsxs("form",{className:"discover-row",onSubmit:b=>{b.preventDefault();const k=o.trim();k!==""&&(n(k),c(""))},children:[s.jsx("span",{className:"field-title",children:"列表里没有?"}),s.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:b=>c(b.target.value)}),s.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[s.jsx(Q,{name:"search"}),"让 agent 去找"]}),s.jsx("span",{className:"muted small",children:"agent 会找它的 Wiki、官网公告等来源,建一个游戏包加到游戏页。"})]}),h!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]})]})}const ea=864e5,Ta=36e5,ag=6e4;function _x(e,t){const n=e-t;return n<=0?"已结束":n>=ea?`${Math.floor(n/ea)} 天 ${Math.floor(n%ea/Ta)} 时`:`${Math.floor(n/Ta)} 时 ${Math.floor(n%Ta/ag)} 分`}function w9(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=ea?{value:String(Math.floor(e/ea)),unit:"天",rest:`${Math.floor(e%ea/Ta)} 时`}:e>=Ta?{value:String(Math.floor(e/Ta)),unit:"时",rest:`${Math.floor(e%Ta/ag)} 分`}:{value:String(Math.max(1,Math.floor(e/ag))),unit:"分",rest:""}}function og(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(i=>[i.type,i.value]));return`${n.year}/${n.month}/${n.day} ${n.hour}:${n.minute}`}function Ex(e,t){var i;return(((i=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date(t)).find(r=>r.type==="timeZoneName"))==null?void 0:i.value)??"").replace("GMT","UTC")||e}function S9({client:e,game:t,activities:n,color:i,now:r,soonDays:o,busy:c,open:u,adding:d,onOpen:h,onAdd:f,onRefresh:g,onRead:p,onReadWeb:x,onUnfollow:b,onChanged:k,openSession:w,openScripts:j}){var M,P;const[E,N]=y.useState(!1),C=n.filter(V=>Math.max(V.endsAt??1/0,V.shopEndsAt??0)>r),L=(V,z)=>(V.endsAt??1/0)-(z.endsAt??1/0),$=C.filter(V=>(V.startsAt??0)<=r).sort(L),O=C.filter(V=>V.startsAt!==void 0&&V.startsAt>r).sort((V,z)=>V.startsAt-z.startsAt),W=$.filter(V=>rs(V).state!=="finished"&&(V.endsAt??1/0)-r<o*ea),B=t.sources.some(V=>V.auto),U={partial:0,unknown:1,finished:2},D=$.filter(V=>!W.includes(V)&&rs(V).state!=="finished").sort((V,z)=>U[rs(V).state]-U[rs(z).state]||L(V,z)),F=$.filter(V=>rs(V).state==="finished"),A=[{key:"soon",title:"需要关注",hint:`${o} 天内结束,还没做完`,rows:W,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:D},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:O}],T=V=>s.jsx("div",{className:"schedule-item",children:s.jsx(T9,{client:e,activity:V,game:t,now:r,soonDays:o,onClick:()=>h(V.id),expanded:u===V.id})},V.id);return s.jsxs("div",{className:"game-view",style:{"--game":i},children:[s.jsx(_9,{client:e,game:t,now:r,covers:$.map(V=>V.cover).filter(V=>(V==null?void 0:V.startsWith("shot:"))!==!0)}),s.jsxs("div",{className:"game-columns",children:[s.jsxs("div",{className:"game-main",children:[(((M=t.pools)==null?void 0:M.length)??0)>0&&s.jsxs("section",{className:"game-section pools-card",children:[s.jsxs("div",{className:"game-section-head",children:[s.jsx("h3",{children:"卡池"}),s.jsx("span",{className:"count",children:t.pools.length})]}),s.jsx("div",{className:"pool-list",children:t.pools.map(V=>s.jsx($9,{client:e,pool:V,game:t,now:r},`${V.name}-${V.endsAt}`))})]}),s.jsxs("section",{className:"game-section game-events","aria-label":"活动日程",children:[s.jsxs("div",{className:"game-section-head",children:[s.jsx("h3",{children:"活动日程"}),s.jsx("span",{className:"count",children:C.length}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"muted small",children:((P=t.sources.find(V=>V.auto))==null?void 0:P.name)??"数据站"}),s.jsx("button",{className:"icon-button",title:"自己添加一个活动","aria-label":"添加活动","aria-pressed":d,onClick:f,children:s.jsx(Q,{name:"plus"})}),s.jsx("button",{className:"icon-button",title:B?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:c!==null||!B,onClick:g,children:s.jsx(Q,{name:"refresh"})})]}),C.length===0&&s.jsx("p",{className:"muted small schedule-empty",children:B?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),A.filter(V=>V.rows.length>0).map(V=>s.jsxs("section",{className:`schedule-group ${V.tone??""}`,children:[s.jsxs("div",{className:"schedule-group-title",children:[s.jsx("span",{children:V.title}),s.jsx("span",{className:"count",children:V.rows.length}),s.jsx("span",{className:"muted small",children:V.hint})]}),s.jsx("div",{className:"schedule-grid",children:V.rows.map(T)})]},V.key)),F.length>0&&s.jsxs("section",{className:"schedule-group done",children:[s.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":E,onClick:()=>N(V=>!V),children:[s.jsx("span",{children:"已做完"}),s.jsx("span",{className:"count",children:F.length}),s.jsx("span",{className:"muted small",children:E?"收起":"展开"}),s.jsx(Q,{name:"chevron-down",className:`chevron-icon ${E?"open":""}`})]}),E&&s.jsx("div",{className:"schedule-grid",children:F.map(T)})]})]})]}),s.jsxs("aside",{className:"game-side",children:[s.jsx(C9,{game:t,running:$,soon:W,now:r,busy:c,onRead:p,onReadWeb:x,onUnfollow:b,openSession:w}),s.jsx("section",{className:"card game-runs-card",children:s.jsx(I9,{client:e,game:t,now:r,openScripts:j})}),s.jsxs("section",{className:"card game-sources-card",children:[s.jsx("h3",{children:"数据来源"}),s.jsxs("div",{className:"game-sources",children:[t.sources.map(V=>{var z;return s.jsxs("span",{className:`source-chip ${V.auto?"auto":"agent"}`,children:[V.auto?s.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[s.jsx("span",{className:"source-dot auto"}),V.name]}):s.jsxs("button",{className:"source-name",disabled:c!==null||((z=t.webReading)==null?void 0:z.state)==="running",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>x(V.id),children:[s.jsx("span",{className:"source-dot"}),V.name,s.jsx("span",{className:"source-action",children:"agent 读"})]}),V.homepage!==void 0&&s.jsx("a",{className:"source-open",href:V.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${V.name}`,children:s.jsx(Q,{name:"popout"})}),V.added===!0&&s.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${V.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:V.id}).then(k,()=>{}),children:s.jsx(Q,{name:"close"})})]},V.id)}),s.jsx(E9,{client:e,game:t,onAdded:k})]}),t.refreshed!==void 0&&s.jsxs("span",{className:"muted small",children:[yt(t.refreshed.at,r),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&s.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]})]})]})}function _9({client:e,game:t,now:n,covers:i}){const r=t.version,o=RE(e,[r==null?void 0:r.cover,t.art,...i]),c=(r==null?void 0:r.startsAt)!==void 0&&r.endsAt!==void 0?r.endsAt-r.startsAt:void 0,u=c===void 0||c<=0?void 0:Math.min(1,Math.max(0,(n-r.startsAt)/c)),d=h=>new Date(h).toLocaleDateString("zh-CN",{timeZone:t.timezone,month:"numeric",day:"numeric"});return s.jsxs("section",{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,r===void 0?"":s.jsxs(s.Fragment,{children:[" · ",s.jsx("b",{children:r.name})," 版本"]})]}),s.jsx("h2",{children:(r==null?void 0:r.title)??t.name})]}),s.jsxs("div",{className:"version-strip",children:[r===void 0&&s.jsx("span",{className:"small version-none",children:t.sources.some(h=>h.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),r!==void 0&&u!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-end",children:d(r.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:d(r.endsAt)})]}),(r==null?void 0:r.endsAt)!==void 0&&s.jsx("span",{className:"version-remaining",children:r.endsAt>n?s.jsxs(s.Fragment,{children:["还剩 ",s.jsx("strong",{children:_x(r.endsAt,n)})]}):"本版本已结束"})]})]})}function E9({client:e,game:t,onAdded:n}){const[i,r]=y.useState(!1),[o,c]=y.useState(""),[u,d]=y.useState(!1),[h,f]=y.useState(null);if(!i)return s.jsxs("button",{className:"source-add",onClick:()=>r(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[s.jsx(Q,{name:"plus"}),"添加网址"]});const g=async()=>{const p=o.trim();if(p!==""){d(!0),f(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(p)?p:`https://${p}`}),c(""),r(!1),n()}catch(x){f(Ie(x))}finally{d(!1)}}};return s.jsxs("form",{className:"source-form",onSubmit:p=>{p.preventDefault(),g()},children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,type:"text",inputMode:"url",placeholder:"https://… 官网公告、Wiki 页面、帖子",value:o,disabled:u,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Escape"&&r(!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:()=>{r(!1),f(null)},children:"取消"}),h!==null&&s.jsx("span",{className:"tone-error small",children:h})]})}function C9({game:e,running:t,soon:n,now:i,busy:r,onRead:o,onReadWeb:c,onUnfollow:u,openSession:d}){var b,k;const h=t.map(rs),f=h.filter(w=>w.state==="finished").length,g=h.filter(w=>w.state==="partial").length,p=h.filter(w=>w.state==="unknown").length,x=e.reading;return s.jsxs("section",{className:"card status-card",children:[s.jsx("h3",{children:"我的状态"}),s.jsxs("div",{className:"status-figures",children:[s.jsxs("div",{className:"status-figure",children:[s.jsx("strong",{children:t.length}),s.jsx("span",{children:"进行中"})]}),s.jsxs("div",{className:`status-figure ${n.length>0?"warn":""}`,children:[s.jsx("strong",{children:n.length}),s.jsx("span",{children:"快结束未做完"})]})]}),t.length>0&&s.jsxs("div",{className:"status-bar",role:"img","aria-label":`已做完 ${f} 个,做了一部分 ${g} 个,没记录 ${p} 个`,children:[f>0&&s.jsx("span",{className:"done",style:{flexGrow:f}}),g>0&&s.jsx("span",{className:"partial",style:{flexGrow:g}}),p>0&&s.jsx("span",{className:"unknown",style:{flexGrow:p}})]}),s.jsxs("ul",{className:"status-legend",children:[s.jsxs("li",{children:[s.jsx("i",{className:"done"}),"已做完",s.jsx("b",{children:f})]}),s.jsxs("li",{children:[s.jsx("i",{className:"partial"}),"做了一部分",s.jsx("b",{children:g})]}),s.jsxs("li",{children:[s.jsx("i",{className:"unknown"}),"没记录",s.jsx("b",{children:p})]})]}),s.jsx("p",{className:"muted small",children:"进度来自你在活动卡片里勾的,和 agent 进游戏读到的。"}),s.jsxs("div",{className:"game-actions",children:[e.followed!==!0&&s.jsxs("button",{className:"small-button primary",disabled:r!==null||(x==null?void 0:x.state)==="running",title:"agent 会看游戏画面,进活动页读取剩余时间和没做完的事;只看不花东西",onClick:o,children:[s.jsx(Q,{name:"gamepad"}),(x==null?void 0:x.state)==="running"?"agent 正在读…":"让 agent 进游戏读取"]}),s.jsxs("button",{className:"small-button",disabled:r!==null||((b=e.webReading)==null?void 0:b.state)==="running",title:"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>c(),children:[s.jsx(Q,{name:"search"}),((k=e.webReading)==null?void 0:k.state)==="running"?"agent 正在查…":"让 agent 上网查活动"]}),e.followed===!0&&s.jsx("button",{className:"small-button",disabled:r!==null,title:"不再显示这个游戏",onClick:u,children:"取消关注"})]}),x!==void 0&&s.jsx(yN,{what:"进游戏",reading:x,now:i,openSession:d}),e.webReading!==void 0&&s.jsx(yN,{what:"上网查",reading:e.webReading,now:i,openSession:d})]})}function yN({what:e,reading:t,now:n,openSession:i}){var o;const r=(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:yt(t.at,n)}),s.jsx("span",{className:"spacer"}),t.sessionId!==void 0&&s.jsxs("button",{className:"link-button small reading-open",onClick:()=>i(t.sessionId),children:["查看对话",s.jsx(Q,{name:"chevron"})]})]}),r!==void 0&&r!==""&&s.jsx("p",{className:"reading-summary",title:r,children:r})]})}function A9({client:e,game:t}){const n=je(e.capabilities),[i,r]=y.useState(null);return y.useEffect(()=>{if(!n.has("scripts"))return;let o=!0;return e.connection.call("games/mirrorchyan",{game:t.id}).then(c=>{o&&r(c.items)},()=>{o&&r([])}),()=>{o=!1}},[e,t.id,n.has("scripts")]),i===null||i.length===0?null:s.jsxs("div",{className:"mirror-tools",children:[s.jsx("div",{className:"muted small",children:"Mirror酱 上有这些玩它的工具:"}),s.jsx("ul",{children:i.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 I9({client:e,game:t,now:n,openScripts:i}){const r=je(e.capabilities),o=je(e.connection.status),[c,u]=y.useState(null),[d,h]=y.useState([]),[f,g]=y.useState(0),[p,x]=y.useState(null),[b,k]=y.useState(null),w=r.has("pipelines");y.useEffect(()=>e.connection.on("pipelines/changed",()=>g(N=>N+1)),[e]),y.useEffect(()=>e.connection.on("pipelines/run",N=>{N.state!=="running"&&g(C=>C+1)}),[e]),y.useEffect(()=>{if(o.state!=="open"||!w||t.scripts.length===0){u([]);return}let N=!0;return(async()=>{const{items:C}=await e.connection.call("pipelines/list",{}),$=(await Promise.all(C.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(B=>B.kind==="script-task"&&t.scripts.includes(B.scriptId))),O=r.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;N&&(u($),h((O==null?void 0:O.upcoming)??[]))})().catch(C=>{N&&k(Ie(C))}),()=>{N=!1}},[e,o.state,w,t.id,t.scripts.join(","),f]);const j=async N=>{x(N),k(null);try{await e.connection.call("pipelines/run",{id:N}),g(C=>C+1)}catch(C){k(Ie(C))}finally{x(null)}},E={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]};return s.jsxs("div",{className:"game-schedule-runs",children:[s.jsx("h3",{children:"自动日程"}),t.scripts.length===0&&s.jsxs("p",{className:"muted small",children:["还没有玩它的脚本。在",s.jsx("button",{className:"link-button",onClick:i,children:"脚本页"}),"安装或导入后,名字或仓库里提到这个游戏的脚本会自动对上。"]}),t.scripts.length===0&&s.jsx(A9,{client:e,game:t}),t.scripts.length>0&&s.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((N,C)=>s.jsxs("span",{children:[C>0?"、":"",s.jsx("button",{className:"link-button",onClick:i,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 $,O;const C=d.filter(W=>W.pipelineId===N.id).map(W=>W.at).sort((W,B)=>W-B)[0],L=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:C!==void 0?`下次 ${new Date(C).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:N.schedule.enabled?"定时已开":"没有定时"}),L!==void 0&&s.jsxs("span",{className:`badge ${(($=E[L.state])==null?void 0:$[0])??""}`,title:new Date(L.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((O=E[L.state])==null?void 0:O[1])??L.state," · ",yt(L.endedAt??L.startedAt,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:p!==null||(L==null?void 0:L.state)==="running",onClick:()=>void j(N.id),children:(L==null?void 0:L.state)==="running"?"运行中…":p===N.id?"启动中…":"运行"})]},N.id)})}),b!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:b})]})]})}function PE(e,t,n){const i=(e.startsAt??0)<=t,r=i&&e.endsAt!==void 0&&e.endsAt<=t,o=r?e.shopEndsAt:e.endsAt,c=i&&o!==void 0&&o-t<n*ea&&rs(e).state!=="finished";return{started:i,shopOnly:r,end:o,soon:c,target:i?o:e.startsAt}}function zE({activity:e,art:t,now:n,soonDays:i}){var b;const{started:r,shopOnly:o,end:c,soon:u,target:d}=PE(e,n,i),h=e.startsAt!==void 0&&c!==void 0?c-e.startsAt:void 0,f=h===void 0||h<=0||!r?void 0:Math.min(1,Math.max(0,(n-e.startsAt)/h)),g=rs(e).state==="finished"?["done","已做完"]:r?o?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],p=d===void 0?{value:"",unit:"",rest:""}:w9(d-n),x=((b=e.cover)==null?void 0:b.startsWith("shot:"))===!0;return s.jsxs("span",{className:`sched-media ${u?"soon":""}`,children:[t!==void 0&&s.jsx("img",{className:`sched-art ${x?"shot":""}`,src:t,alt:"",title:x?"没有别的活动图,用的是 agent 读这个活动时的游戏截图":void 0},e.cover),s.jsx("span",{className:"sched-shade"}),s.jsx("span",{className:`sched-tag ${g[0]}`,children:g[1]}),s.jsxs("span",{className:"sched-count","aria-label":d===void 0?"时间未知":`${r?"剩余":"距开始"}${_x(d,n)}`,children:[d===void 0?s.jsx("b",{children:"?"}):s.jsxs(s.Fragment,{children:[s.jsx("b",{children:p.value}),s.jsx("small",{children:p.unit}),p.rest!==""&&s.jsx("em",{children:p.rest})]}),s.jsx("i",{children:r?o?"商店":"剩余":"后开始"})]}),f!==void 0&&s.jsx("span",{className:"sched-elapsed",style:{width:`${f*100}%`}})]})}function T9({client:e,activity:t,game:n,now:i,soonDays:r,onClick:o,expanded:c}){var k,w,j,E;const u=tl(e,t.cover),d=rs(t),{started:h,shopOnly:f,end:g,soon:p}=PE(t,i,r),x=Ex(n.timezone,i),b=t.chosen===void 0?void 0:t.chosen===Ao?"我设的":t.chosen===nc?"游戏画面":(w=(k=t.sources)==null?void 0:k.find(N=>N.id===t.chosen))==null?void 0:w.name;return s.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${p?"soon":""}`,onClick:o,"aria-expanded":c,children:[s.jsx(zE,{activity:t,art:u,now:i,soonDays:r}),s.jsxs("span",{className:"sched-body",children:[s.jsx("span",{className:"sched-name",title:t.name,children:t.name}),s.jsx("span",{className:"sched-when",children:!h&&t.startsAt!==void 0?`${og(t.startsAt,n.timezone)} 开始 · ${x}`:g!==void 0?`${og(g,n.timezone)} ${f?"商店关闭":"结束"} · ${x}`:`结束时间未知${((j=t.screen)==null?void 0:j.remaining)===void 0?"":`,游戏里显示「${t.screen.remaining}」`}`}),t.todo.length>0&&d.state!=="finished"&&s.jsxs("span",{className:"sched-todo",title:t.todo.join("、"),children:["还没做:",t.todo.slice(0,3).join("、")]}),s.jsxs("span",{className:"sched-foot",children:[s.jsxs("span",{className:"sched-kinds",children:[t.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:t.kind}),b!==void 0&&s.jsxs("span",{className:"sched-kind",title:`你选了用「${b}」的图片和时间`,children:["用 ",b]}),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?"我添加的":"我改过"}),((E=t.sources)==null?void 0:E.some(N=>N.web))===!0&&s.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(N=>N.name).join("、")}`,children:t.sources.every(N=>N.web)?"网页读到":"数据站 + 网页"})]}),s.jsx(Sx,{progress:d})]})]})]})}function $9({client:e,pool:t,game:n,now:i}){const r=tl(e,t.cover),o=(t.startsAt??0)<=i;return s.jsxs("article",{className:"pool-card",children:[s.jsx("div",{className:"pool-art",children:r===void 0?s.jsx(Q,{name:"sparkles"}):s.jsx("img",{src:r,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:_x(o?t.endsAt:t.startsAt,i)})]}),s.jsxs("span",{className:"muted small",children:[og(t.endsAt,n.timezone)," 结束 (",Ex(n.timezone,i),")"]})]})]})}function M9(e,t){return y.useMemo(()=>new Map(e.map((n,i)=>[n.id,t[i%t.length]])),[e,t])}function bN({color:e,label:t,onClose:n,children:i}){const r=y.useRef(null),o=()=>{var c;return((c=r.current)==null?void 0:c.querySelector("form.activity-editor"))!==null};return y.useEffect(()=>{var u;const c=document.activeElement;return(u=r.current)==null||u.focus({preventScroll:!0}),()=>{c instanceof HTMLElement&&c.isConnected&&c.focus({preventScroll:!0})}},[]),y.useEffect(()=>{const c=u=>{if(document.querySelector(".image-viewer")!==null||(u.key==="Escape"&&!o()&&n(),u.key!=="Tab"||r.current===null))return;const d=[...r.current.querySelectorAll("a[href], button:not(:disabled), input:not(:disabled):not([hidden]), textarea:not(:disabled)")],h=d[0],f=d[d.length-1],g=document.activeElement;h===void 0||f===void 0||(u.shiftKey&&(g===h||g===r.current)?(u.preventDefault(),f.focus()):!u.shiftKey&&g===f&&(u.preventDefault(),h.focus()))};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[n]),s.jsx("div",{className:"activity-scrim",onPointerDown:c=>{c.target===c.currentTarget&&!o()&&n()},children:s.jsx("div",{ref:r,className:"activity-dialog",role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,style:{"--game":e},children:i})})}function R9(e,t){const n=u=>yt(u,t),i=e.sources??[],r=e.own,o=u=>u.startsAt!==void 0||u.endsAt!==void 0||u.cover!==void 0,c=u=>({id:u.id,name:u.name,note:`${u.web?"网页":"数据站"} · ${n(u.at)}`,title:u.web?"agent 在网页上读到的;刷新数据站不会删掉它":"数据站,每次刷新更新",startsAt:u.startsAt,endsAt:u.endsAt,shopEndsAt:u.shopEndsAt,cover:u.cover,blank:!o(u)&&u.shopEndsAt===void 0});return[{id:Ao,name:"我设的",note:r===void 0?"":n(r.at),title:"你自己填的:刷新不会改掉",startsAt:r==null?void 0:r.startsAt,endsAt:r==null?void 0:r.endsAt,cover:r==null?void 0:r.cover,blank:r===void 0||!o(r)},...i.filter(u=>!u.web).map(c),...i.filter(u=>u.web).map(c),...e.screen===void 0?[]:[{id:nc,name:"游戏画面",note:`agent 看过 · ${n(e.screen.at)}`,title:"agent 进游戏看到的剩余时间和截图",endsAt:e.screen.endsAt,cover:e.screen.image,blank:e.screen.endsAt===void 0&&e.screen.image===void 0}]]}function O9(e,t){var r,o,c;const n=((r=e.shown)==null?void 0:r.startsAt)===t,i=((o=e.shown)==null?void 0:o.endsAt)===t;return[...((c=e.shown)==null?void 0:c.cover)===t?["图片"]:[],...n&&i?["时间"]:n?["开始时间"]:i?["结束时间"]:[]]}function P9({client:e,url:t}){const n=tl(e,t);return s.jsx("span",{className:`source-thumb ${t===void 0?"none":""}`,children:n!==void 0?s.jsx("img",{src:n,alt:"",decoding:"async"}):t===void 0?"无图":null})}function z9({client:e,activity:t,game:n,now:i,soonDays:r,onClose:o,onChanged:c,openSession:u}){var re,ee,te;const[d,h]=y.useState(null),[f,g]=y.useState(!1),[p,x]=y.useState(""),[b,k]=y.useState(!1),[w,j]=y.useState(null),[E,N]=y.useState(void 0);y.useEffect(()=>N(void 0),[t]);const C=E??t,[L,$]=y.useState(void 0);y.useEffect(()=>$(void 0),[C.chosen]);const O=L!==void 0?L??void 0:C.chosen,W=tl(e,C.cover),B=y.useRef(void 0);W!==void 0&&(B.current=W);const U=C.cover===void 0?void 0:W??B.current,D=(n==null?void 0:n.timezone)??"Asia/Shanghai",F=ne=>new Date(ne).toLocaleString("zh-CN",{timeZone:D,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),A=R9(C,i),T=C.shopEndsAt!==void 0||A.some(ne=>ne.shopEndsAt!==void 0),M=C.sources!==void 0||C.screen!==void 0,P=(ne,se)=>{k(!0),j(null),ne.then(()=>{c(),se==null||se()},oe=>j(Ie(oe))).finally(()=>k(!1))},V=ne=>P(e.connection.call("games/activity/progress",{activityId:C.id,...ne})),z=ne=>V({todo:C.todo.filter(se=>se!==ne),done:[...C.done,ne]}),H=ne=>V({todo:[...C.todo,ne],done:C.done.filter(se=>se!==ne)}),G=()=>{const ne=p.trim();ne===""||C.todo.includes(ne)||C.done.includes(ne)||(x(""),V({todo:[...C.todo,ne]}))},Z=ne=>{$(ne),j(null),e.connection.call("games/activity/source",{activityId:C.id,source:ne}).then(se=>{N(se),c()},se=>{$(void 0),j(Ie(se))})},Y=(ne,se)=>{const oe=new Image;oe.onload=()=>h({src:ne,width:oe.naturalWidth,height:oe.naturalHeight,name:se}),oe.src=ne},X=()=>{k(!0),j(null),e.connection.call("games/activity/reset",{activityId:C.id}).then(ne=>{c(),ne.activity===void 0&&o()},ne=>j(Ie(ne))).finally(()=>k(!1))};return f&&n!==void 0?s.jsx("div",{className:"dialog-form",children:s.jsx(wx,{client:e,game:n,activity:C,onDone:()=>{g(!1),c()},onCancel:()=>g(!1)})}):s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"dialog-head",children:[s.jsxs("div",{className:"dialog-title",children:[s.jsx("h3",{title:C.name,children:C.name}),s.jsxs("div",{className:"dialog-meta",children:[s.jsxs("span",{className:"dialog-game",children:[s.jsx("span",{className:"game-dot"}),(n==null?void 0:n.name)??C.game]}),C.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:C.kind})]})]}),s.jsx(Sx,{progress:rs(C)}),s.jsx("button",{className:"dialog-close","aria-label":"关闭详情",title:"关闭(Esc)",onClick:o,children:s.jsx(Q,{name:"close"})})]}),s.jsxs("div",{className:"dialog-cols",children:[s.jsxs("div",{className:"dialog-col side",children:[s.jsx("button",{className:"dialog-media",disabled:U===void 0,title:U===void 0?void 0:"看大图","aria-label":"看大图",onClick:()=>{U!==void 0&&Y(U,`${C.name}.png`)},children:s.jsx(zE,{activity:C,art:U,now:i,soonDays:r})}),s.jsxs("div",{className:"dialog-facts",children:[s.jsxs("dl",{className:"dialog-dates",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"开始"}),s.jsx("dd",{children:C.startsAt===void 0?"未知":F(C.startsAt)})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"结束"}),s.jsx("dd",{children:C.endsAt===void 0?"未知":F(C.endsAt)})]}),T&&s.jsxs("div",{className:"wide",children:[s.jsx("dt",{children:"商店开到"}),s.jsx("dd",{children:C.shopEndsAt===void 0?"—":F(C.shopEndsAt)})]})]}),s.jsxs("span",{className:"muted small",children:[Ex(D,i),",游戏服务器时间",((re=C.screen)==null?void 0:re.remaining)===void 0?"":`;游戏里显示「${C.screen.remaining}」`]}),C.description!==void 0&&s.jsx("p",{className:"ov-description",children:C.description})]})]}),s.jsxs("div",{className:"dialog-col main",children:[s.jsxs("section",{className:"dialog-section","aria-label":"信息来源",children:[s.jsxs("div",{className:"dialog-section-head",children:[s.jsx("h4",{children:"信息来源"}),s.jsx("span",{className:"spacer"}),O!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>Z(null),children:"恢复默认"})]}),s.jsx("div",{className:"source-rows",children:A.map(ne=>{const se=ne.id===Ao,oe=O===ne.id;return s.jsxs("button",{className:`source-row ${oe?"on":""}`,"aria-pressed":oe,disabled:ne.blank&&!se,title:ne.title,onClick:()=>{ne.blank&&se?g(!0):Z(oe?null:ne.id)},children:[s.jsx(P9,{client:e,url:ne.cover}),s.jsxs("span",{className:"source-row-main",children:[s.jsxs("span",{className:"source-row-name",children:[s.jsx("b",{children:ne.name}),oe&&s.jsx(Q,{name:"check"}),ne.note!==""&&s.jsx("small",{children:ne.note})]}),ne.blank?s.jsx("span",{className:"source-row-dates muted",children:se?"还没填,点这里设置图片和时间":"没有时间和图片"}):s.jsxs("span",{className:"source-row-dates",children:[s.jsx("span",{children:ne.startsAt===void 0&&ne.endsAt===void 0?"没有时间":`${ne.startsAt===void 0?"?":F(ne.startsAt)} – ${ne.endsAt===void 0?"?":F(ne.endsAt)}`}),ne.shopEndsAt!==void 0&&s.jsxs("em",{children:["商店到 ",F(ne.shopEndsAt)]})]})]}),s.jsx("span",{className:"source-row-uses",children:O9(C,ne.id).map(de=>s.jsx("i",{children:de},de))})]},ne.id)})}),s.jsx("p",{className:"muted small dialog-hint",children:"默认图片按 我设的 › 数据站和网页 › 游戏截图 显示。点一个来源,图片和时间就用它的;它没有的还按默认。"})]}),s.jsxs("section",{className:"dialog-section","aria-label":"要做的事",children:[s.jsxs("div",{className:"dialog-section-head",children:[s.jsx("h4",{children:"要做的事"}),C.todo.length+C.done.length>0&&s.jsxs("span",{className:"count",children:[C.done.length,"/",C.todo.length+C.done.length]})]}),s.jsxs("div",{className:"ov-checklist",role:"list",children:[C.todo.map(ne=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:b,onChange:()=>z(ne)}),ne]},`t${ne}`)),C.done.map(ne=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:b,onChange:()=>H(ne)}),ne]},`d${ne}`)),C.todo.length+C.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:b,onChange:ne=>x(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&G()}}),s.jsxs("button",{className:"small-button",disabled:b||p.trim()==="",onClick:G,children:[s.jsx(Q,{name:"plus"}),"添加"]})]})]}),s.jsxs("div",{className:"dialog-section dialog-links",children:[C.url!==void 0&&s.jsx("a",{className:"link-button small",href:C.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),((ee=C.screen)==null?void 0:ee.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:C.id}).then(ne=>Y(`data:${ne.mediaType};base64,${ne.data}`,`${C.name}-截图.png`),ne=>j(Ie(ne))),children:"看游戏截图"}),((te=C.screen)==null?void 0:te.sessionId)!==void 0&&u!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>u(C.screen.sessionId),children:"agent 的对话"}),s.jsx("span",{className:"spacer"}),C.own!==void 0&&M&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:b,onClick:X,children:"清除我设的"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:b,onClick:()=>P(e.connection.call("games/activity/remove",{activityId:C.id}),o),children:"从日历去掉"})]}),w!==null&&s.jsx("div",{className:"dialog-section",children:s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:w})]})})]})]}),s.jsxs("footer",{className:"dialog-foot",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:C.finished!==void 0,disabled:b,onChange:ne=>V({finished:ne.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),n!==void 0&&s.jsxs("button",{className:"small-button",disabled:b,onClick:()=>g(!0),children:[s.jsx(Q,{name:"pencil"}),"编辑"]})]}),d!==null&&s.jsx(Xd,{src:d.src,width:d.width,height:d.height,name:d.name,onClose:()=>h(null)})]})}const ja=new Map;let lg=0;const cg=new Set;function L9(e,t){let n=ja.get(e);if(n===void 0){n=t().then(r=>r.icon===void 0?null:`data:${r.icon.mediaType};base64,${r.icon.data}`);const i=n;n.then(r=>{r===null&&ja.get(e)===i&&ja.delete(e)},()=>{ja.get(e)===i&&ja.delete(e)}),ja.set(e,n)}return n}function LE(){ja.clear(),lg++;for(const e of cg)e()}const Vm=new Map;function D9(e){let t=Vm.get(e);if(t===void 0){const i=["games/changed","scripts/changed","packs/changed"].map(r=>e.connection.on(r,LE));t={count:0,off:()=>{for(const r of i)r()}},Vm.set(e,t)}t.count++;const n=t;return()=>{--n.count===0&&(n.off(),Vm.delete(e))}}function DE({client:e,iconKey:t,load:n,name:i,className:r=""}){const o=je(e.connection.status),[c,u]=y.useState(null),[d,h]=y.useState(lg);return y.useEffect(()=>{const f=()=>h(lg);return cg.add(f),()=>{cg.delete(f)}},[]),y.useEffect(()=>D9(e),[e]),y.useEffect(()=>{if(o.state!=="open")return;let f=!0;return L9(t,n).then(g=>{f&&u(g)},()=>{}),()=>{f=!1}},[t,o.state,d]),s.jsx("span",{className:`program-avatar${c===null?"":" with-icon"} ${r}`,children:c===null?[...i][0]??"?":s.jsx("img",{src:c,alt:"",draggable:!1,onError:()=>u(null)})})}function F9({client:e,game:t,className:n=""}){return s.jsx(DE,{client:e,iconKey:`game:${t.id}`,name:t.name,className:`rail-avatar game-avatar ${n}`,load:()=>e.connection.call("games/icon",{game:t.id})})}const U9=864e5;function B9({client:e,openSession:t,openSettings:n,openPage:i,arg:r}){const o=je(e.connection.status),c=un(3e4),[u,d]=y.useState(null),[h,f]=y.useState(0),[g,p]=y.useState(r??""),[x,b]=y.useState(null),[k,w]=y.useState(null),[j,E]=y.useState(null),[N,C]=y.useState(!1),[L,$]=y.useState(null),O=y.useCallback(()=>$(null),[]);y.useEffect(()=>{r!==void 0&&p(r)},[r]),y.useEffect(()=>e.connection.on("games/changed",()=>f(Z=>Z+1)),[e]),y.useEffect(()=>{if(o.state!=="open")return;let Z=!0;return e.connection.call("games/list",{}).then(Y=>{Z&&d(Y)}).catch(Y=>{Z&&w(Ie(Y))}),()=>{Z=!1}},[e,o.state,h]);const W=(u==null?void 0:u.games)??[],B=M9(W,Xr),U=g==="report",D=U?void 0:W.find(Z=>Z.id===g),F=!U&&D===void 0,A=Z=>{p(Z),$(null),E(null),w(null)},T=async(Z,Y)=>{b(Z),w(null),E(null);try{const X=await Y();typeof X=="string"&&E(X)}catch(X){w(Ie(X))}finally{b(null),f(X=>X+1)}},M=Z=>T(`refresh:${Z??""}`,async()=>{const{results:Y}=await e.connection.call("games/refresh",Z===void 0?{}:{game:Z}),X=te=>{var ne;return((ne=W.find(se=>se.id===te))==null?void 0:ne.name)??te},re=te=>{var ne;return((ne=W.find(se=>se.id===te))==null?void 0:ne.sources.some(se=>se.auto))===!0},ee=Y.filter(te=>re(te.game)&&!te.ok);if(ee.length>0)throw new Error(ee.map(te=>`${X(te.game)}没读到:${te.detail??"未知原因"}`).join(";"));return Z===void 0?`刷新完成:${Y.filter(te=>re(te.game)).map(te=>`${X(te.game)} ${te.count} 个活动`).join(";")}`:void 0}),P=Z=>{const Y=((u==null?void 0:u.activities)??[]).filter(ee=>ee.game===Z.id&&(ee.startsAt??0)<=c&&Math.max(ee.endsAt??1/0,ee.shopEndsAt??0)>c),X=Y.filter(ee=>rs(ee).state!=="finished"&&ee.endsAt!==void 0&&ee.endsAt>c&&ee.endsAt-c<((u==null?void 0:u.settings.report.soonDays)??3)*U9).length,re=`${Y.length} 个进行中${Z.refreshed===void 0?"":` · ${yt(Z.refreshed.at,c)}刷新`}${Z.followed===!0?" · 关注的游戏":""}`;return{mine:Y,soon:X,title:re}},V=y.useContext(Lw),z=V===null?null:s.jsxs("div",{className:"rail-games",role:"tablist","aria-label":"游戏",children:[s.jsx(Aa,{icon:"calendar",label:"全部活动",active:F,onClick:()=>A("")}),W.map(Z=>{const{soon:Y,title:X}=P(Z);return s.jsxs("button",{role:"tab","aria-selected":(D==null?void 0:D.id)===Z.id,className:`rail-item rail-game ${(D==null?void 0:D.id)===Z.id?"active":""}`,style:{"--game":B.get(Z.id)},title:`${Z.name}:${X}`,onClick:()=>A(Z.id),children:[s.jsx(F9,{client:e,game:Z}),s.jsx("span",{className:"rail-label",children:Z.name}),Y>0&&s.jsx("span",{className:"rail-badge",title:`${Y} 个快结束还没做完`,children:Y})]},Z.id)}),s.jsx(Aa,{icon:"plus",label:"更多游戏",title:"关注更多游戏(SRA 公共 API)",active:N,onClick:()=>C(Z=>!Z)}),s.jsx(Aa,{icon:"send",label:"日报",active:U,onClick:()=>A("report")})]}),H=U?"日报":(D==null?void 0:D.name)??"全部活动",G=Z=>{const{mine:Y,soon:X}=P(Z);return s.jsxs("button",{role:"tab","aria-selected":(D==null?void 0:D.id)===Z.id,className:`game-tab ${(D==null?void 0:D.id)===Z.id?"active":""}`,style:{"--game":B.get(Z.id)},title:`${Y.length} 个进行中${Z.refreshed===void 0?"":` · ${yt(Z.refreshed.at,c)}刷新`}${Z.followed===!0?" · 关注的游戏":""}`,onClick:()=>A(Z.id),children:[s.jsx("span",{className:"game-dot"}),Z.name,X>0&&s.jsx("span",{className:"game-tab-badge",title:`${X} 个快结束还没做完`,children:X})]},Z.id)};return s.jsxs("section",{className:"main games-page",children:[V!==null&&z!==null&&Va.createPortal(z,V),s.jsxs("header",{className:"page-header games-header",children:[s.jsx("div",{className:"breadcrumb",children:s.jsx("h1",{children:V===null?"游戏":H})}),V===null?s.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[s.jsxs("button",{role:"tab","aria-selected":F,className:`game-tab ${F?"active":""}`,onClick:()=>A(""),children:[s.jsx(Q,{name:"calendar"}),"全部活动"]}),s.jsx("span",{className:"game-tabs-divider"}),W.map(G),s.jsxs("button",{className:`game-tab add ${N?"active":""}`,"aria-expanded":N,title:"关注更多游戏(SRA 公共 API)",onClick:()=>C(Z=>!Z),children:[s.jsx(Q,{name:"plus"}),"更多游戏"]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{role:"tab","aria-selected":U,className:`game-tab ${U?"active":""}`,onClick:()=>A("report"),children:[s.jsx(Q,{name:"send"}),"日报"]})]}):s.jsx("span",{className:"spacer"}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button",disabled:x!==null||W.length===0,onClick:()=>void M(),children:[s.jsx(Q,{name:"refresh"}),x==="refresh:"?"刷新中…":"刷新全部"]})})]}),s.jsxs("div",{className:"games-body",children:[N&&s.jsx("section",{className:"card",children:s.jsx(j9,{client:e,onChanged:()=>f(Z=>Z+1),onDiscover:Z=>void T("discover",async()=>{const{sessionId:Y}=await e.connection.call("games/discover",{name:Z});t(Y)})})}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:k})]}),j!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:j})]}),u!==null&&W.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(Q,{name:"gamepad"}),s.jsx("p",{children:"没有游戏。点「更多游戏」关注几个。"})]}),u!==null&&F&&W.length>0&&s.jsx(v9,{client:e,games:W,activities:u.activities,now:c,soonDays:u.settings.report.soonDays,onOpenGame:A,onChanged:()=>f(Z=>Z+1)}),u!==null&&U&&s.jsx(H9,{client:e,data:u,games:W,now:c,openSettings:n,onChanged:()=>f(Z=>Z+1)}),u!==null&&D!==void 0&&s.jsx(S9,{client:e,game:D,activities:u.activities.filter(Z=>Z.game===D.id),color:B.get(D.id)??Xr[0],now:c,soonDays:u.settings.report.soonDays,busy:x,open:(L==null?void 0:L.kind)==="activity"?L.id:null,adding:(L==null?void 0:L.kind)==="add",onOpen:Z=>$({kind:"activity",id:Z}),onAdd:()=>$({kind:"add",game:D.id}),onRefresh:()=>void M(D.id),onRead:()=>void T(`read:${D.id}`,async()=>{const{sessionId:Z}=await e.connection.call("games/read",{game:D.id});t(Z)}),onReadWeb:Z=>void T(`read-web:${D.id}`,async()=>{const{sessionId:Y}=await e.connection.call("games/read",{game:D.id,how:"web",...Z===void 0?{}:{source:Z}});t(Y)}),onUnfollow:()=>void T(`unfollow:${D.id}`,async()=>(await e.connection.call("games/follow",{sra:D.id.replace(/^sra-/,""),follow:!1}),p(""),`不再关注${D.name}`)),onChanged:()=>f(Z=>Z+1),openSession:t,openScripts:()=>i("scripts")},D.id)]}),u!==null&&L!==null&&(()=>{const Z=()=>f(X=>X+1);if(L.kind==="add"){const X=W.find(re=>re.id===L.game);return X===void 0?null:s.jsx(bN,{color:B.get(X.id)??Xr[0],label:"添加活动",onClose:O,children:s.jsx("div",{className:"dialog-form",children:s.jsx(wx,{client:e,game:X,onCancel:O,onDone:re=>{$({kind:"activity",id:re.id,saved:re}),Z()}})})})}const Y=u.activities.find(X=>X.id===L.id)??L.saved;return Y===void 0?null:s.jsx(bN,{color:B.get(Y.game)??Xr[0],label:`${Y.name}的详情`,onClose:O,children:s.jsx(z9,{client:e,activity:Y,game:W.find(X=>X.id===Y.game),now:c,soonDays:u.settings.report.soonDays,onClose:O,onChanged:Z,openSession:t},Y.id)})})()]})}function H9({client:e,data:t,games:n,now:i,openSettings:r,onChanged:o}){const c=t.settings.report,[u,d]=y.useState(null),[h,f]=y.useState(!1),[g,p]=y.useState(null),[x,b]=y.useState(null);y.useEffect(()=>{let j=!0;return e.connection.call("games/report/preview",{}).then(E=>{j&&d(E)}).catch(()=>{}),()=>{j=!1}},[e,t]);const k=async j=>{f(!0),p(null);try{await e.connection.call("games/settings/set",{report:j}),o()}catch(E){p(Ie(E))}finally{f(!1)}},w=async()=>{f(!0),p(null),b(null);try{const{channels:j}=await e.connection.call("games/report/send",{});b(j.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${j.join("、")}。`),o()}catch(j){p(Ie(j))}finally{f(!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:h,onChange:j=>void k({enabled:j.target.checked})}),"每天定时发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.ai,disabled:h,onChange:j=>void k({ai:j.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:h,onBlur:j=>{/^\d{2}:\d{2}$/.test(j.target.value)&&j.target.value!==c.at&&k({at:j.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:h,onBlur:j=>{const E=Math.max(1,Math.min(30,Math.round(Number(j.target.value)||3)));E!==c.soonDays&&k({soonDays:E})}},c.soonDays)]})]}),s.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),s.jsx("div",{className:"chip-row",children:n.map(j=>{const E=c.games.includes(j.id);return s.jsx("button",{className:`chip chip-button ${E?"active":""}`,disabled:h,onClick:()=>void k({games:E?c.games.filter(N=>N!==j.id):[...c.games,j.id]}),children:j.name},j.id)})}),s.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${yt(t.report.lastSentAt,i)}。`,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:()=>r("feishu"),children:"远程连接"})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]})]}),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:h,onClick:()=>void w(),children:[s.jsx(Q,{name:"send"}),h?"发送中…":"现在发送"]})]}),x!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:x})]}),u!==null&&s.jsxs("div",{className:"report-preview",children:[s.jsx("strong",{children:u.title}),`
233
+
234
+ `,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:yt(t.report.lastSentAt,i)})]})}),s.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const Z9={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"gamepad",order:-10,component:B9}]},W9={game:"游戏",script:"脚本",general:"通用"};function V9({client:e,focus:t,openSkill:n}){const i=un(6e4),r=je(e.capabilities),[o,c]=y.useState(null),[u,d]=y.useState({games:new Set,scripts:new Set}),[h,f]=y.useState(null),[g,p]=y.useState(null),[x,b]=y.useState(null),[k,w]=y.useState(!1),j=async($=!1)=>{f($?"refresh":h);try{c(await e.connection.call("skillhub/list",$?{refresh:!0}:{})),p(null)}catch(O){p(Ie(O))}finally{$&&f(null)}};y.useEffect(()=>{j()},[e]),y.useEffect(()=>e.connection.on("skillhub/changed",()=>void j()),[e]),y.useEffect(()=>{let $=!0;return(async()=>{var B,U;const O=r.has("games")?((B=await e.connection.call("games/list",{}).catch(()=>{}))==null?void 0:B.games.map(D=>D.id))??[]:[],W=r.has("scripts")?((U=await e.connection.call("scripts/list",{}).catch(()=>{}))==null?void 0:U.scripts.flatMap(D=>[D.id,D.packId,D.known].filter(F=>F!==void 0)))??[]:[];$&&d({games:new Set(O),scripts:new Set(W)})})(),()=>{$=!1}},[e,r.has("games"),r.has("scripts")]);const E=async($,O)=>{f($),p(null),b(null);try{const W=await O();typeof W=="string"&&b(W),await j()}catch(W){p(Ie(W))}finally{f(null)}},N=$=>$.games.some(O=>u.games.has(O))||$.scripts.some(O=>u.scripts.has(O)),C=y.useMemo(()=>{const $=[...(o==null?void 0:o.items)??[]].sort((O,W)=>+(W.name===t)-+(O.name===t)||O.name.localeCompare(W.name));return[{label:"已下载",items:$.filter(O=>O.installed!==void 0)},{label:"推荐给你",hint:"你关注的游戏、装了的脚本",items:$.filter(O=>O.installed===void 0&&N(O))},{label:"其他",items:$.filter(O=>O.installed===void 0&&!N(O))}].filter(O=>O.items.length>0)},[o,u,t]),L=$=>E(`update:${$.name}`,async()=>(await e.connection.call("skillhub/update",{name:$.name})).state==="updated"?`${$.name} 已更新`:"已是最新");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:["游戏和脚本的技能放在 ",(o==null?void 0:o.repos.map($=>$.repo).join("、"))??"MultiGameAssistant/skills",",按需下载;下载的跟着技能库走,更新时整个换成新版本。要留下自己的做法,另存成自己的技能。软件自带的核心技能受保护,随软件更新。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(o==null?void 0:o.fetchedAt)===void 0?"":`${yt(o.fetchedAt,i)}读取`}),s.jsxs("button",{className:"small-button",disabled:h!==null,onClick:()=>void j(!0),children:[s.jsx(Q,{name:"refresh"}),h==="refresh"?"读取中…":"检查更新"]}),s.jsx("button",{className:"ghost small-button",onClick:()=>w($=>!$),children:"仓库"})]})]}),k&&o!==null&&s.jsx(q9,{repos:o.repos,disabled:h!==null,onSave:$=>E("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:$}),w(!1),await e.connection.call("skillhub/list",{refresh:!0}),"已保存,按新的仓库读取"))}),o==null?void 0:o.errors.map($=>s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["读不到:",$,o.items.length>0?"(下面是之前读到的)":""]})]},$))]}),x!==null&&s.jsx("div",{className:"notice info",children:x}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]}),o===null&&g===null&&s.jsx("p",{className:"muted",children:"正在读取技能库…"}),o!==null&&o.items.length===0&&o.errors.length===0&&s.jsx("p",{className:"muted",children:"技能库里还没有技能。"}),C.map($=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"sidebar-label",children:[$.label,s.jsx("span",{className:"skills-count",children:$.items.length}),"hint"in $&&s.jsxs("span",{children:["· ",$.hint]})]}),s.jsx("ul",{className:"hub-list",children:$.items.map(O=>{var W,B;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:W9[O.kind]}),((W=O.installed)==null?void 0:W.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:h!==null,onClick:()=>void E(`install:${O.name}`,async()=>(await e.connection.call("skillhub/install",{name:O.name,repo:O.repo}),`已下载 ${O.name},agent 现在就能用`)),children:h===`install:${O.name}`?"下载中…":"下载"}),((B=O.installed)==null?void 0:B.update)===!0&&s.jsx("button",{className:"primary small-button",disabled:h!==null,onClick:()=>void L(O),children:h===`update:${O.name}`?"更新中…":"更新"}),O.installed!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:()=>n(O.name),children:"查看"}),s.jsx("button",{className:"ghost small-button",disabled:h!==null,onClick:()=>void E(`remove:${O.name}`,async()=>(await e.connection.call("skillhub/remove",{name:O.name}),`已删除下载的 ${O.name}`)),children:"删除"})]})]})]},`${O.repo}/${O.name}`)})})]},$.label))]})}function q9({repos:e,disabled:t,onSave:n}){const[i,r]=y.useState(e.map(u=>u.branch==="main"?u.repo:`${u.repo}@${u.branch}`).join(`
235
+ `)),o=i.split(/\r?\n/).map(u=>u.trim()).filter(Boolean).map(u=>{const[d,h]=u.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:d??"",branch:h??"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:i,onChange:u=>r(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:()=>r("MultiGameAssistant/skills"),children:"恢复默认"}),s.jsx("button",{className:"primary small-button",disabled:t||!c,onClick:()=>n(o),children:"保存"})]})]})}const G9=[{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 K9(e){var t;return e.removable===!0?"在这里存的":((t=G9.find(n=>n.match(e.source)))==null?void 0:t.label)??"其他"}const Y9="通用",FE="adg:skills:folded";function X9(){try{return new Set(JSON.parse(localStorage.getItem(FE)??"[]"))}catch{return new Set}}function Q9(e){try{localStorage.setItem(FE,JSON.stringify([...e]))}catch{}}const J9=e=>e.startsWith("game:")?"gamepad":e.startsWith("script:")?"package":"layers";function e8({client:e,arg:t}){var te,ne,se,oe;const n=je(e.connection.status),i=je(e.capabilities),[r,o]=y.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),c=(t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):void 0,[u,d]=y.useState(null),[h,f]=y.useState(""),[g,p]=y.useState(t??""),[x,b]=y.useState(null),[k,w]=y.useState(null),[j,E]=y.useState(0),[N,C]=y.useState(!1),[L,$]=y.useState(null),[O,W]=y.useState(X9),[B,U]=y.useState(!1),D=de=>W(we=>{const Se=new Set(we);return Se.delete(de)||Se.add(de),Q9(Se),Se}),F=((te=Gd(e).data)==null?void 0:te.scripts)??[],[A,T]=y.useState([]);y.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?o("hub"):(o("mine"),p(t)))},[t]),y.useEffect(()=>e.connection.on("skills/changed",()=>E(de=>de+1)),[e]),y.useEffect(()=>{if(n.state!=="open"||!i.has("games"))return;let de=!0;return e.connection.call("games/list",{}).then(we=>{de&&T(we.games)},()=>{}),()=>{de=!1}},[e,n.state,i]),y.useEffect(()=>{if(n.state!=="open")return;let de=!0;return e.connection.call("skills/list",{}).then(we=>{de&&(d(we.skills),w(null))},we=>{de&&w(Ie(we))}),()=>{de=!1}},[e,n.state,j,r]);const M=h.trim().toLowerCase(),P=y.useMemo(()=>(u??[]).filter(de=>M===""||`${de.name} ${de.description} ${de.whenToUse??""}`.toLowerCase().includes(M)),[u,M]),V=y.useMemo(()=>{const de=new Map,we=(Ce,Fe,ot)=>{const ht=de.get(Ce)??{key:Ce,label:Fe,items:[],subs:[],...ot};return de.set(Ce,ht),ht},Se=Ce=>we(`game:${Ce.id}`,Ce.name,{game:Ce.id}),fe=(Ce,Fe)=>{const ot=Ce.subs.find(ht=>ht.script===Fe.id)??{key:`${Ce.key}/${Fe.id}`,label:Fe.name,script:Fe.id,items:[]};return Ce.subs.includes(ot)||Ce.subs.push(ot),ot},xe=(Ce,Fe)=>{Ce.includes(Fe)||Ce.push(Fe)};if(M===""){for(const Ce of A)Se(Ce);for(const Ce of F){const Fe=Fw(Ce,A);Fe===void 0?we(`script:${Ce.id}`,Ce.name,{script:Ce.id}):fe(Se(Fe),Ce)}}for(const Ce of P){const Fe=Rp(Ce.owner,F,A);Fe.length===0&&xe(we("general",Y9,{}).items,Ce);for(const ot of Fe)ot.game!==void 0&&ot.script!==void 0?xe(fe(Se(ot.game),ot.script).items,Ce):ot.game!==void 0?xe(Se(ot.game).items,Ce):ot.script!==void 0&&xe(we(`script:${ot.script.id}`,ot.script.name,{script:ot.script.id}).items,Ce)}const De=(Ce,Fe)=>Ce.name.localeCompare(Fe.name),Me=Ce=>Ce.key.startsWith("game:")?0:Ce.key.startsWith("script:")?1:2;return[...de.values()].map(Ce=>({...Ce,items:Ce.items.sort(De),subs:Ce.subs.map(Fe=>({...Fe,items:Fe.items.sort(De)})).sort((Fe,ot)=>Fe.label.localeCompare(ot.label))})).sort((Ce,Fe)=>Me(Ce)-Me(Fe)||Ce.label.localeCompare(Fe.label))},[P,F,A,M]),z=V.flatMap(de=>[...de.items,...de.subs.flatMap(we=>we.items)])[0],H=P.find(de=>de.name===g)??z;y.useEffect(()=>{if(U(!1),H===void 0){b(null);return}let de=!0;return C(!1),e.connection.call("skills/get",{name:H.name}).then(we=>{de&&b(we)},we=>{de&&w(Ie(we))}),()=>{de=!1}},[e,H==null?void 0:H.name,j]);const G=de=>{var we;(we=navigator.clipboard)==null||we.writeText(`/${de} `).then(()=>C(!0),()=>{})},Z=async de=>{if(await Ps({title:`删除技能「${de.name}」?`,message:"它的文件夹会一起删掉,agent 以后就用不到它了。",confirmLabel:"删除",danger:!0}))try{await e.connection.call("skills/remove",{name:de.name}),p(""),E(we=>we+1)}catch(we){w(Ie(we))}},Y=de=>[...new Set(Rp(de.owner,F,A).map(Uw))],X=de=>({name:"",description:"",content:"",scripts:de.script===void 0?[]:[de.script],games:de.script===void 0&&de.game!==void 0?[de.game]:[]}),re=de=>s.jsxs("button",{className:`script-row skill-row ${L===null&&(H==null?void 0:H.name)===de.name?"active":""}`,onClick:()=>{$(null),p(de.name)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:de.name}),s.jsx("span",{className:"muted small skills-row-desc",children:de.description})]}),de.removable===!0&&s.jsx("span",{className:"skill-row-mark",title:"在这里存的:可以编辑和删除",children:s.jsx(Q,{name:"pencil"})})]},de.name),ee=(de,we,Se)=>s.jsx("button",{className:"icon-button skills-add",title:Se,"aria-label":`在${de}下新建技能`,disabled:n.state!=="open",onClick:()=>$(X(we)),children:s.jsx(Q,{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:r==="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":r==="mine",className:r==="mine"?"active":"",onClick:()=>o("mine"),children:"已有的技能"}),s.jsx("button",{role:"tab","aria-selected":r==="hub",className:r==="hub"?"active":"",onClick:()=>o("hub"),children:"技能库"})]}),r==="mine"&&s.jsxs("button",{className:"small-button",disabled:n.state!=="open",onClick:()=>$(X({})),children:[s.jsx(Q,{name:"plus"}),"新建技能"]}),r==="mine"&&s.jsxs("button",{className:"small-button",onClick:()=>E(de=>de+1),children:[s.jsx(Q,{name:"refresh"}),"刷新"]})]})]}),r==="hub"&&i.has("skillhub")?s.jsx("div",{className:"skill-hub-body",children:s.jsx(V9,{client:e,focus:c,openSkill:de=>{p(de),o("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(Q,{name:"search"}),s.jsx("input",{className:"text-input",value:h,onChange:de=>f(de.target.value),placeholder:"搜索技能","aria-label":"搜索技能"})]}),u!==null&&M!==""&&s.jsx("p",{className:"muted small skills-found",children:P.length===0?"没有匹配的技能。":`找到 ${P.length} 个技能`}),u!==null&&M===""&&P.length===0&&s.jsx("p",{className:"muted small pad",children:"还没有技能。"}),V.map(de=>{const we=M!==""||!O.has(de.key);return s.jsxs("div",{className:`skills-group ${we?"":"folded"}`,children:[s.jsxs("div",{className:"skills-section-head",children:[s.jsxs("button",{className:"skills-fold","aria-expanded":we,onClick:()=>D(de.key),children:[s.jsx(Q,{name:"chevron-down",className:"skills-chevron"}),s.jsx(Q,{name:J9(de.key),className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:de.label}),s.jsx("span",{className:"skills-count",children:new Set([...de.items,...de.subs.flatMap(Se=>Se.items)]).size})]}),ee(de.label,de,de.game!==void 0?`给游戏「${de.label}」新建一个技能(处理这个游戏的对话都能用)`:de.script!==void 0?`给「${de.label}」新建一个技能(只给它用)`:"新建一个通用技能")]}),we&&s.jsxs(s.Fragment,{children:[de.items.map(re),de.script!==void 0&&de.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),de.game!==void 0&&de.items.length===0&&de.subs.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有这个游戏的技能"}),de.subs.map(Se=>s.jsxs("div",{className:"skills-sub",children:[s.jsxs("div",{className:"skills-sub-label",children:[s.jsx(Q,{name:"package",className:"skills-section-icon"}),s.jsx("span",{className:"skills-group-name",children:Se.label}),s.jsx("span",{className:"skills-count",children:Se.items.length}),s.jsx("span",{className:"spacer"}),ee(Se.label,{script:Se.script},`给「${Se.label}」新建一个技能(只给它用)`)]}),Se.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),Se.items.map(re)]},Se.key))]})]},de.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(Q,{name:"alert"}),s.jsx("span",{children:k})]}),L!==null?s.jsx(t8,{client:e,draft:L,scripts:F,games:A,onCancel:()=>$(null),onSaved:de=>{$(null),p(de),w(null),E(we=>we+1)}}):s.jsxs(s.Fragment,{children:[u===null&&k===null&&s.jsx("p",{className:"muted",children:"正在读取…"}),u!==null&&H===void 0&&s.jsxs("div",{className:"skills-blank",children:[s.jsx(Q,{name:"sparkles"}),s.jsx("strong",{children:"还没有技能"}),s.jsx("span",{className:"muted small",children:"agent 做成一件事后会提议存成技能;也可以自己写一个。"}),s.jsxs("button",{className:"small-button primary",disabled:n.state!=="open",onClick:()=>$(X({})),children:[s.jsx(Q,{name:"plus"}),"新建技能"]})]}),H!==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:H.name}),s.jsxs("div",{className:"skill-meta",children:[Y(H).length===0?s.jsxs("span",{className:"badge",title:"所有对话都看得到、用得了",children:[s.jsx(Q,{name:"layers"}),"通用"]}):s.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了这个技能",children:[s.jsx(Q,{name:(se=(ne=H.owner)==null?void 0:ne.scripts)!=null&&se.length?"package":"gamepad"}),"只给 ",Y(H).join("、")," 用"]}),H.modelInvocable&&s.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读这个技能",children:"agent 自动使用"}),s.jsxs("span",{className:"badge",title:H.removable===!0?"存在这个软件的技能文件夹里,可以编辑和删除":`在这里不能改和删${H.source==="hub"?",到「技能库」里卸载":""}`,children:[K9(H),H.removable===!0?"":" · 只读"]})]})]}),s.jsxs("div",{className:"skill-buttons",children:[H.userInvocable&&s.jsxs("button",{className:"small-button",onClick:()=>G(H.name),title:"复制后粘贴到对话框,后面写要它做的事",children:[s.jsx(Q,{name:N?"check":"copy"}),N?"已复制":`/${H.name}`]}),(H.removable===!0||H.source==="hub")&&s.jsxs("button",{className:"small-button","aria-expanded":B,onClick:()=>U(de=>!de),title:"放错了游戏或脚本时,换到对的那个",children:[s.jsx(Q,{name:"gamepad"}),"更换游戏和脚本"]}),H.removable===!0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"small-button",disabled:(x==null?void 0:x.name)!==H.name,onClick:()=>{var de,we;return $({original:H.name,name:H.name,description:H.description,content:(x==null?void 0:x.content)??"",scripts:[...((de=H.owner)==null?void 0:de.scripts)??[]],games:[...((we=H.owner)==null?void 0:we.games)??[]]})},children:[s.jsx(Q,{name:"pencil"}),"编辑"]}),s.jsx("button",{className:"small-button danger-outline",onClick:()=>void Z(H),children:"删除"})]}),H.path!==void 0&&((oe=ni())==null?void 0:oe.openPath)!==void 0&&s.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${H.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var de,we;return void((we=(de=ni())==null?void 0:de.openPath)==null?void 0:we.call(de,H.path.replace(/[\\/][^\\/]+$/,"")))},children:s.jsx(Q,{name:"layers"})})]})]}),B&&s.jsx(n8,{client:e,skill:H,content:(x==null?void 0:x.name)===H.name?x.content:void 0,scripts:F,games:A,onCancel:()=>U(!1),onMoved:()=>{U(!1),w(null),E(de=>de+1)}},H.name),s.jsx("p",{className:"skill-desc",children:H.description}),H.whenToUse!==void 0&&s.jsxs("p",{className:"muted small",children:["什么时候用:",H.whenToUse]}),s.jsxs("section",{className:"skill-body","aria-label":"技能内容",children:[s.jsx("div",{className:"skill-body-label",children:"技能内容"}),(x==null?void 0:x.name)===H.name?s.jsx(ti,{text:x.content}):s.jsx("p",{className:"muted",children:"正在读取…"})]}),H.path!==void 0&&s.jsx("code",{className:"muted small skill-path",title:H.path,children:H.path})]})]})]})})]})]})}function t8({client:e,draft:t,scripts:n,games:i,onCancel:r,onSaved:o}){const[c,u]=y.useState(t),[d,h]=y.useState(!1),[f,g]=y.useState(null);y.useEffect(()=>{u(t),g(null)},[t]);const p=t.original!==void 0,x=_j.test(c.name)&&c.name.length<=cp,b=x&&c.description.trim().length>=10&&c.content.trim().length>=20,k=async()=>{h(!0),g(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},...p?{replace:!0}:{}}),o(c.name)}catch(w){g(Ie(w))}finally{h(!1)}};return s.jsxs("article",{className:"card skill-card skill-form",children:[s.jsx("div",{className:"skill-head",children:s.jsx("h2",{children:p?`编辑 ${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:p,maxLength:cp,autoFocus:!p,onChange:w=>u(j=>({...j,name:w.target.value.trim().toLowerCase()})),placeholder:"例:maa-daily-check"}),c.name!==""&&!x&&s.jsx("span",{className:"error small",children:"只能用小写英文字母、数字和短横线,例如 maa-daily-check"})]}),s.jsx(UE,{scripts:n,games:i,value:c,onChange:w=>u(j=>({...j,...w}))}),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:w=>u(j=>({...j,description:w.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:w=>u(j=>({...j,content:w.target.value}))})]}),f!==null&&s.jsx("p",{className:"error small",children:f}),s.jsxs("div",{className:"skill-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d,onClick:r,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:d||!b,onClick:()=>void k(),children:d?"保存中…":"保存"})]})]})}function UE({scripts:e,games:t,value:n,onChange:i}){const[r]=y.useState(n),o=[...new Set([...r.scripts,...n.scripts])].filter(f=>!e.some(g=>g.id===f)),c=[...new Set([...r.games,...n.games])].filter(f=>Mp(f,t)===void 0),u=(f,g)=>{var p;return f===g||((p=Mp(f,t))==null?void 0:p.id)===g},d=f=>i({...n,scripts:n.scripts.includes(f)?n.scripts.filter(g=>g!==f):[...n.scripts,f]}),h=f=>i({...n,games:n.games.some(g=>u(g,f))?n.games.filter(g=>!u(g,f)):[...n.games,f]});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(f=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.games.some(g=>u(g,f.id)),onChange:()=>h(f.id)}),f.name]},f.id)),c.map(f=>s.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[s.jsx("input",{type:"checkbox",checked:n.games.includes(f),onChange:()=>h(f)}),f]},f))]})]}),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(f=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(f.id),onChange:()=>d(f.id)}),f.name]},f.id)),o.map(f=>s.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(f),onChange:()=>d(f)}),f]},f))]})]}),s.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function n8({client:e,skill:t,content:n,scripts:i,games:r,onCancel:o,onMoved:c}){var k,w;const[u,d]=y.useState({scripts:[...((k=t.owner)==null?void 0:k.scripts)??[]],games:[...((w=t.owner)==null?void 0:w.games)??[]]}),[h,f]=y.useState(!1),[g,p]=y.useState(null),x=t.source==="hub",b=async j=>{f(!0),p(null);try{if(x)await e.connection.call("skillhub/owner",{name:t.name,owner:j});else{if(n===void 0||j===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:n,replace:!0,...j.scripts.length===0?{}:{scripts:j.scripts},...j.games.length===0?{}:{games:j.games}})}c()}catch(E){p(Ie(E))}finally{f(!1)}};return s.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[s.jsx(UE,{scripts:i,games:r,value:u,onChange:d}),x&&s.jsx("p",{className:"muted small",children:"这是从技能库下载的技能:你选的会一直保留,技能库更新它也不变。"}),g!==null&&s.jsx("p",{className:"error small",children:g}),s.jsxs("div",{className:"skill-actions",children:[x&&s.jsx("button",{className:"link-button small",disabled:h,onClick:()=>void b(null),children:"恢复成技能库里的"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h,onClick:o,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:h||!x&&n===void 0,onClick:()=>void b(u),children:h?"保存中…":"保存"})]})]})}const s8={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:e8}]};async function Cx(e,t){const n=ni();if(n!==void 0){const{kind:r,...o}=t;return n.pickFile({...o,folder:r==="folder"})}const{path:i}=await e.connection.call("files/pick",{kind:t.kind,...t.title===void 0?{}:{title:t.title},...t.defaultPath===void 0||t.defaultPath===""?{}:{defaultPath:t.defaultPath},...t.filterName===void 0?{}:{filterName:t.filterName},...t.extensions===void 0?{}:{extensions:t.extensions}});return i??null}function i8({client:e}){const t=je(e.connection.status),[n,i]=y.useState(null),[r,o]=y.useState(0),[c,u]=y.useState(null),[d,h]=y.useState(null),[f,g]=y.useState(""),[p,x]=y.useState("");y.useEffect(()=>e.connection.on("emulators/changed",()=>o(w=>w+1)),[e]),y.useEffect(()=>{if(t.state!=="open")return;let w=!0;return e.connection.call("emulators/status",{refresh:r===0}).then(j=>{w&&(i(j),g(j.settings.manualAddress??""),x(j.settings.adbPath??""))}).catch(j=>{w&&h(Ie(j))}),()=>{w=!1}},[e,t.state,r]);const b=async(w,j)=>{u(w),h(null);try{await j(),o(E=>E+1)}catch(E){h(Ie(E))}finally{u(null)}},k=w=>b("settings",()=>e.connection.call("emulators/settings/set",w));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 b("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(Q,{name:"info"}),s.jsxs("span",{children:[n.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),n==null?void 0:n.providers.map(w=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[w.name,w.version===void 0?"":` ${w.version}`]}),s.jsx("p",{className:"muted small",children:w.manager})]}),n.settings.mumuManager===w.manager&&s.jsx("span",{className:"badge ok",children:"已指定"})]}),w.error!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:w.error})]}),s.jsx("ul",{className:"version-list",children:w.instances.map(j=>s.jsxs("li",{className:j.index===n.settings.instance?"current":"",children:[s.jsx("span",{className:"version-name",children:j.index}),s.jsx("span",{children:j.name}),s.jsx("span",{className:`badge ${j.ready?"ok":""}`,children:j.ready?"已启动":j.running?"启动中":"未运行"}),j.adb!==void 0&&s.jsx("span",{className:"muted small",children:j.adb}),s.jsx("span",{className:"spacer"}),j.index!==n.settings.instance&&s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void k({instance:j.index}),children:"任务用这个"}),j.ready?s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void b(`stop-${j.index}`,()=>e.connection.call("emulators/stop",{index:j.index})),children:"关闭"}):s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void b(`start-${j.index}`,()=>e.connection.call("emulators/start",{index:j.index})),children:c===`start-${j.index}`?"启动中…":"启动"})]},j.index))})]},w.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:w=>void k({autoStart:w.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:f,onChange:w=>g(w.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void k({manualAddress:f.trim()===""?null:f.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:p,onChange:w=>x(w.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void k({adbPath:p.trim()===""?null:p.trim()}),children:"保存"}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void Cx(e,{kind:"file",title:"选择 adb.exe",defaultPath:p.trim(),filterName:"程序",extensions:["exe"]}).then(w=>{w!==null&&(x(w),k({adbPath:w}))},w=>h(Ie(w))),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:w=>void k({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(w.target.value)||180))})})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]})]})}function r8({client:e}){const t=je(e.connection.status),[n,i]=y.useState(null),[r,o]=y.useState(null),[c,u]=y.useState(""),[d,h]=y.useState(""),[f,g]=y.useState(null),[p,x]=y.useState(!1),[b,k]=y.useState(null),[w,j]=y.useState(null),E=()=>e.connection.call("scripts/settings",{}).then($=>{i($),o($)}).catch($=>j(Ie($)));if(y.useEffect(()=>{t.state==="open"&&E()},[e,t.state]),r===null||n===null)return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),w===null?s.jsx("p",{children:"加载中…"}):s.jsx("div",{className:"notice error left",children:w})]});const N=($,O)=>o({...r,[$]:O}),C=async()=>{x(!0),j(null),k(null);try{const{tokenConfigured:$,cdkConfigured:O,...W}=n,B=Object.fromEntries(Object.entries(r).filter(([U,D])=>W[U]!==D));Object.keys(B).length>0&&await e.connection.call("scripts/settings/set",B),c.trim()!==""&&await e.connection.call("credentials/set",{ref:r.tokenRef,value:c.trim()}),u(""),d.trim()!==""&&(await e.connection.call("credentials/set",{ref:r.cdkRef,value:d.trim()}),h(""),L()),await E(),k("已保存,下一次安装起生效")}catch($){j(Ie($))}finally{x(!1)}},L=async()=>{g("checking");try{g(await e.connection.call("scripts/mirrorchyan/check",{}))}catch($){g({ok:!1,message:Ie($)})}};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:r.downloadMirror,onChange:$=>N("downloadMirror",$.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:r.mirrorFallback,onChange:$=>N("mirrorFallback",$.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:d,onChange:$=>h($.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:f==="checking",onClick:()=>void L(),children:f==="checking"?"检查中…":"检查"})]}),f!==null&&f!=="checking"&&s.jsx("p",{className:"small",style:{color:f.ok?"var(--ok)":"var(--error)"},children:f.message}),s.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",r.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:$=>u($.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 的凭据文件里(",r.tokenRef,"),界面不会显示它的内容。"]}),s.jsx("label",{className:"field-label",htmlFor:"gh-api",children:"API 地址"}),s.jsx("input",{id:"gh-api",className:"text-input plain",value:r.apiBase,onChange:$=>N("apiBase",$.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:r.keepVersions,onChange:$=>N("keepVersions",Math.max(1,Math.min(10,Number($.target.value)||1)))}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:r.includePrereleases,onChange:$=>N("includePrereleases",$.target.checked)}),"没有正式版时使用预发布版本"]})]}),s.jsxs("div",{className:"key-actions",children:[b!==null&&s.jsx("span",{className:"muted small",children:b}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",disabled:p,onClick:()=>void C(),children:p?"保存中…":"保存"})]}),w!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:w})]})]})}function a8({client:e,initialRepo:t,jobs:n,onDone:i,openSession:r,onClose:o}){const[c,u]=y.useState(t??""),[d,h]=y.useState(null),[f,g]=y.useState(""),[p,x]=y.useState(""),[b,k]=y.useState(!1),[w,j]=y.useState(null),[E,N]=y.useState(null),C=async(B=c)=>{var D;const U=SO(B);if(U===void 0){j("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}k(!0),j(null);try{const F=await e.connection.call("scripts/releases",{repo:U.repo,limit:10});u(U.repo),h({...F,branch:U.branch});const A=F.releases.find(M=>M.tag===U.tag),T=A??F.releases.find(M=>!M.prerelease)??F.releases[0];g((T==null?void 0:T.tag)??""),x(((D=T==null?void 0:T.assets.find(M=>M.name===U.asset))==null?void 0:D.name)??(T==null?void 0:T.suggestedAsset)??""),U.tag!==void 0&&A===void 0&&F.releases.length>0&&j(`最近的发布里没有 ${U.tag},已改选最新版本`)}catch(F){h(null),j(Ie(F))}finally{k(!1)}};y.useEffect(()=>{t!==void 0&&C(t)},[t]);const L=d==null?void 0:d.releases.find(B=>B.tag===f),$=d!==null&&(d.branch!==void 0||d.releases.length===0),O=async()=>{if(d!==null){k(!0),j(null);try{const{jobId:B,scriptId:U}=await e.connection.call("scripts/install",{repo:d.repo,...d.branch===void 0?{}:{branch:d.branch}});N({jobId:B,scriptId:U,tag:d.branch===void 0?"默认分支":`${d.branch} 分支`,asset:"源码压缩包"})}catch(B){j(Ie(B))}finally{k(!1)}}},W=async()=>{var B;if(!(d===null||L===void 0||p==="")){k(!0),j(null);try{const{jobId:U,scriptId:D}=await e.connection.call("scripts/install",{repo:d.repo,tag:L.tag,asset:p});N({jobId:U,scriptId:D,tag:L.tag,asset:p,size:(B=L.assets.find(F=>F.name===p))==null?void 0:B.size})}catch(U){j(Ie(U))}finally{k(!1)}}};if(E!==null&&d!==null){const B=n.get(E.scriptId);return s.jsx(BE,{client:e,repo:d.repo,...E,job:(B==null?void 0:B.id)===E.jobId?B:void 0,onDone:()=>i(E.scriptId),openSession:r,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(Q,{name:"close"})})]}),s.jsxs("form",{className:"field-row",onSubmit:B=>{B.preventDefault(),C()},children:[s.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:c,onChange:B=>u(B.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:b}),s.jsx("button",{type:"submit",disabled:b||c.trim()==="",children:b&&d===null?"读取中…":"读取发布"})]}),$&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:d.branch!==void 0?`链接指向 ${d.branch} 分支:会下载这个分支当前的源码,之后跟着它更新。`:"这个仓库还没有发布版本:可以下载默认分支当前的源码,之后跟着这个分支更新。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:d.releases.length===0?"primary":"",onClick:()=>void O(),disabled:b,children:["安装",d.branch===void 0?"源码":` ${d.branch} 分支`]})]}),d!==null&&d.releases.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",d.packId!==void 0&&s.jsxs("span",{className:"chip subtle",children:["内置脚本包 ",d.packId]})]}),s.jsx(Dt,{id:"release-select",value:f,disabled:b,onChange:B=>{var U;g(B),x(((U=d.releases.find(D=>D.tag===B))==null?void 0:U.suggestedAsset)??"")},options:d.releases.map(B=>({value:B.tag,label:`${B.tag}${B.prerelease?"(预发布)":""}`,...B.publishedAt===void 0?{}:{hint:`${B.publishedAt.slice(0,10)} 发布`}}))}),L!==void 0&&s.jsxs("fieldset",{className:"asset-list",disabled:b,children:[s.jsx("legend",{className:"field-label",children:"下载文件"}),L.assets.length===0&&s.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...L.assets].sort((B,U)=>+(U.name===L.suggestedAsset)-+(B.name===L.suggestedAsset)).map(B=>s.jsxs("label",{className:`asset-option ${B.name===p?"active":""}`,children:[s.jsx("input",{type:"radio",name:"asset",value:B.name,checked:B.name===p,onChange:()=>x(B.name)}),s.jsx("span",{className:"asset-name",children:B.name}),B.name===L.suggestedAsset&&s.jsx("span",{className:"badge ok",children:"推荐"}),s.jsx("span",{className:"muted small",children:Ea(B.size)})]},B.name))]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(L==null?void 0:L.suggestedAsset)===void 0?"没有自动匹配到适合本机的文件,请手动选择。":"已按本机(Windows x64)选好文件。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"primary",onClick:()=>void W(),disabled:b||p==="",children:["安装 ",L==null?void 0:L.tag]})]})]}),w!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:w})]})]})}function o8({client:e,initialRid:t,jobs:n,onDone:i,openSession:r,onGitHub:o,onClose:c}){const[u,d]=y.useState(""),h=l8(e,u),[f,g]=y.useState(null),[p,x]=y.useState(null),[b,k]=y.useState(!1),[w,j]=y.useState(null),[E,N]=y.useState(null);y.useEffect(()=>{e.connection.call("scripts/settings",{}).then(W=>x(W.cdkConfigured),()=>x(null))},[e]);const C=async W=>{k(!0),j(null);try{g(await e.connection.call("scripts/mirrorchyan/lookup",{rid:W}))}catch(B){g(null),j(Ie(B))}finally{k(!1)}};y.useEffect(()=>{t!==void 0&&C(t)},[t]);const L=async()=>{if(f!==null){k(!0),j(null);try{N(await e.connection.call("scripts/install",{mirrorchyan:f.rid}))}catch(W){j(Ie(W))}finally{k(!1)}}};if(E!==null&&f!==null){const W=n.get(E.scriptId);return s.jsx(BE,{client:e,repo:`Mirror酱 · ${f.rid}`,tag:f.version,asset:`${f.name??f.rid}(Mirror酱 完整包)`,job:(W==null?void 0:W.id)===E.jobId?W:void 0,onDone:()=>i(E.scriptId),openSession:r,onRetry:()=>N(null),onClose:c})}const $=u.trim(),O=/^[\w.-]{1,100}$/.test($)&&!(h.items??[]).some(W=>W.rid.toLowerCase()===$.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(Q,{name:"close"})})]}),s.jsx("input",{className:"text-input plain","aria-label":"搜索 Mirror酱",value:u,onChange:W=>d(W.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),s.jsx(c8,{results:h,selected:f==null?void 0:f.rid,disabled:b,onPick:W=>void C(W)}),O&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"small-button",disabled:b,onClick:()=>void C($),children:["按资源 id 查询 ",$]})]}),f!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"install-file",children:[s.jsx(Q,{name:"package"}),s.jsx("span",{className:"asset-name",children:f.name??f.rid}),s.jsxs("span",{className:"badge",children:["Mirror酱 ",f.rid]}),s.jsxs("span",{className:"muted small",children:["最新 ",f.version]})]}),f.description!==void 0&&s.jsx("p",{className:"muted small mirror-desc",children:f.description}),p===!1&&s.jsx("div",{className:"notice info left small",children:s.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",f.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:f.repo===void 0?"":`GitHub:${f.repo}`}),s.jsx("span",{className:"spacer"}),f.repo!==void 0&&s.jsx("button",{className:"small-button",disabled:b,onClick:()=>o(f.repo),children:"从 GitHub 安装"}),s.jsxs("button",{className:"primary",onClick:()=>void L(),disabled:b||p===!1,children:["安装 ",f.version]})]})]}),w!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:w})]})]})}function l8(e,t){const[n,i]=y.useState({loading:!0});return y.useEffect(()=>{let r=!0;i(c=>({...c,loading:!0}));const o=setTimeout(()=>{e.connection.call("scripts/mirrorchyan/search",{query:t.trim()}).then(c=>{r&&i({items:c.items,from:c.from,loading:!1})}).catch(c=>{r&&i({error:Ie(c),loading:!1})})},t.trim()===""?0:250);return()=>{r=!1,clearTimeout(o)}},[e,t]),n}function c8({results:e,selected:t,disabled:n,limit:i=8,onPick:r,pickLabel:o="选择"}){const[c,u]=y.useState(!1);if(e.error!==void 0)return s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:e.error})]});const d=e.items??[];if(d.length===0)return s.jsx("div",{className:"muted small mirror-empty",children:e.loading?"查找中…":"没有找到。可以换个说法(游戏简称、英文名),或直接输入资源 id。"});const h=c?d:d.slice(0,i);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:h.map(f=>s.jsxs("li",{className:f.rid===t?"active":"",children:[s.jsxs("div",{className:"mirror-result-main",children:[s.jsxs("span",{className:"mirror-result-name",children:[f.name,s.jsx("span",{className:"chip subtle",children:f.rid}),f.installed&&s.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),f.description!==""&&s.jsx("span",{className:"muted small",children:f.description})]}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>r(f.rid),children:o})]},f.rid))}),!c&&d.length>i&&s.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",d.length-i," 个"]})]})}const kN=["resolving","downloading","verifying","extracting","checking","done"];function BE({client:e,repo:t,tag:n,asset:i,size:r,job:o,onDone:c,openSession:u,onRetry:d,onClose:h}){const f=(o==null?void 0:o.phase)??"queued",g=f==="done"?o==null?void 0:o.setup:void 0,p=o===void 0||o.endedAt===void 0,x=u8(o==null?void 0:o.received),b=(o==null?void 0:o.total)??r,k=b!==void 0&&b>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/b):void 0,w=y.useRef(-1),j=kN.indexOf(f);j>w.current&&(w.current=j);const E=g!==void 0?"交给 agent 安装":f==="done"?"安装完成":f==="failed"?"安装失败":f==="cancelled"?"已取消安装":"正在安装",N=C=>f==="done"||C<w.current?"done":C===w.current?p?"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:E}),s.jsxs("p",{className:"muted small",children:[t," · ",n]})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:p?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:h,children:s.jsx(Q,{name:"close"})})]}),s.jsxs("div",{className:"install-file",children:[s.jsx(Q,{name:"package"}),s.jsx("span",{className:"asset-name",children:i}),r!==void 0&&s.jsx("span",{className:"muted small",children:Ea(r)})]}),s.jsx("ol",{className:"install-steps",children:kN.slice(0,-1).map((C,L)=>{const $=N(L);return s.jsxs("li",{className:`install-step ${$}`,children:[s.jsx("span",{className:"install-step-mark",children:$==="done"?s.jsx(Q,{name:"check"}):$==="stopped"?s.jsx(Q,{name:"close"}):L+1}),s.jsx("span",{children:mc[C]})]},C)})}),p&&s.jsxs("div",{className:"install-bar",children:[s.jsx("div",{className:`progress ${f==="downloading"&&k!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:s.jsx("span",{style:f==="downloading"&&k!==void 0?{width:`${(k*100).toFixed(1)}%`}:void 0})}),s.jsxs("div",{className:"install-numbers muted small",children:[s.jsx("span",{children:o===void 0?"等待开始…":o.message??mc[f]}),f==="downloading"&&(o==null?void 0:o.received)!==void 0&&s.jsxs("span",{className:"install-bytes",children:[Ea(o.received),b!==void 0?` / ${Ea(b)}`:"",k!==void 0?` · ${Math.floor(k*100)}%`:"",x!==void 0?` · ${Ea(Math.round(x))}/s`:"",x!==void 0&&x>0&&b!==void 0?` · 还要 ${d8((b-o.received)/x)}`:""]})]})]}),(o==null?void 0:o.error)!==void 0&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:o.error})]}),g!==void 0&&s.jsxs("div",{className:"notice left",children:[s.jsx(Q,{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:p?"可以关掉这个面板,安装会在后台继续。":g!==void 0?`下载好了 ${(o==null?void 0:o.version)??n} 的安装程序。`:f==="done"?`已安装 ${(o==null?void 0:o.version)??n}。`:""}),s.jsx("span",{className:"spacer"}),p&&o!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(f==="failed"||f==="cancelled")&&s.jsx("button",{className:"small-button",onClick:d,children:"重新选择"}),(g==null?void 0:g.sessionId)!==void 0&&s.jsx("button",{className:"primary small-button",onClick:()=>u(g.sessionId),children:"查看对话"}),f==="done"&&g===void 0&&s.jsx("button",{className:"primary small-button",onClick:c,children:"查看脚本"})]})]})}function u8(e){const t=y.useRef([]),[n,i]=y.useState(void 0);return y.useEffect(()=>{if(e===void 0)return;const r=Date.now(),o=[...t.current.filter(u=>r-u.at<=4e3&&u.bytes<=e),{at:r,bytes:e}];t.current=o;const c=o[0];r-c.at>=500&&i((e-c.bytes)/((r-c.at)/1e3))},[e]),n}function d8(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function h8({client:e,onImported:t,onClose:n}){const[i,r]=y.useState(""),[o,c]=y.useState(""),[u,d]=y.useState(!1),[h,f]=y.useState(null),g=async()=>{f(null);try{const x=await Cx(e,{kind:"folder",title:"选择脚本所在的文件夹",defaultPath:i.trim().replace(/^"|"$/g,"")});x!==null&&r(x)}catch(x){f(Ie(x))}},p=async()=>{d(!0),f(null);try{const x=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(x.id)}catch(x){f(Ie(x)),d(!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(Q,{name:"close"})})]}),s.jsxs("form",{className:"import-form",onSubmit:x=>{x.preventDefault(),p()},children:[s.jsx("label",{className:"field-label",htmlFor:"import-path",children:"目录路径"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"import-path",className:"text-input plain",value:i,onChange:x=>r(x.target.value),placeholder:"例如 D:\\Games\\MAA",spellCheck:!1,disabled:u}),s.jsx("button",{className:"small-button",type:"button",disabled:u,onClick:()=>void g(),children:"选择文件夹…"})]}),s.jsx("label",{className:"field-label",htmlFor:"import-name",children:"显示名称(可选)"}),s.jsx("input",{id:"import-name",className:"text-input plain",value:o,onChange:x=>c(x.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||i.trim()==="",children:u?"导入中…":"导入"})]})]}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]})]})}function ug({client:e,job:t,compact:n=!1}){const i=t.endedAt===void 0,r=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 安装":mc[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),r!==void 0&&i&&s.jsxs("span",{className:"job-bytes",children:[Ea(t.received??0)," / ",Ea(t.total??0)]}),i&&s.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),i&&s.jsx("div",{className:`progress ${r===void 0?"indeterminate":""}`,"aria-hidden":"true",children:s.jsx("span",{style:r===void 0?void 0:{width:`${(r*100).toFixed(1)}%`}})}),!n&&t.message!==void 0&&(i||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 f8={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function HE({client:e,script:t,disabled:n,act:i}){const[r,o]=y.useState(null),[c,u]=y.useState(""),[d,h]=y.useState(null),f=t.channels.github,g=t.channels.mirrorchyan,p=(w,j)=>i("channel",async()=>{await e.connection.call("scripts/source/set",j==="reset"?{id:t.id,reset:[w]}:w==="repo"?{id:t.id,repo:j}:{id:t.id,mirrorchyan:j}),o(null);const E=w==="repo"?"GitHub":"Mirror酱";return j===null?`已不再从 ${E} 更新`:j==="reset"?`${E} 更新渠道已恢复自动`:`${E} 更新渠道已设为 ${j}`}),x=()=>i("mirror-match",async()=>{const w=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return h({items:w.items,checked:!0}),w.items.length===0?`Mirror酱 上没有找到它${w.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),b=(w,j)=>w==="repo"?/^[\w.-]+\/[\w.-]+$/.test(j):/^[\w.-]{1,100}$/.test(j),k=(w,j,E,N,C)=>s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:j}),s.jsx("dd",{children:r!==w?s.jsxs(s.Fragment,{children:[E!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:E.text}),s.jsxs("span",{className:"muted small",children:["(",f8[E.from],")"]})]}):s.jsx("span",{className:"muted small",children:N}),(E==null?void 0:E.from)!=="install"&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>{u((E==null?void 0:E.text)??""),o(w)},children:E===void 0?"设置":"修改"}),w==="mirrorchyan"&&E===void 0&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>void x(),children:"查询是否接入"})]}):s.jsxs("span",{className:"local-source-edit",children:[s.jsx("input",{className:"text-input plain","aria-label":`${j}更新渠道`,value:c,onChange:L=>u(L.target.value),placeholder:C,spellCheck:!1,autoFocus:!0}),s.jsx("button",{className:"primary small-button",disabled:n||!b(w,c.trim()),onClick:()=>void p(w,c.trim()),children:w==="mirrorchyan"?"查询并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void p(w,"reset"),children:"恢复自动"}),E!==void 0&&s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void p(w,null),children:"不用"}),s.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return s.jsxs(s.Fragment,{children:[k("repo","GitHub",f===void 0?void 0:{text:f.repo,from:f.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),k("mirrorchyan","Mirror酱",g===void 0?void 0:{text:g.rid,from:g.from},"未设置:在 Mirror酱 发布的脚本填它的资源 id","资源 id,例如 BGI、MAA"),g===void 0&&d!==null&&d.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酱 上可能是它:"}),d.items.slice(0,5).map(w=>s.jsxs("span",{className:"mirror-match",children:[s.jsx("span",{children:w.name}),s.jsx("span",{className:"chip subtle",children:w.rid}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void p("mirrorchyan",w.rid).then(()=>h(null)),children:"用这个"})]},w.rid))]})]})]})}function m8({client:e,script:t,disabled:n,busy:i,now:r,act:o}){const[c,u]=y.useState(!1),d=t.localVersion,h=t.update,f=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:d!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-name",children:d.version}),s.jsx("span",{className:"muted small",children:d.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${d.from})`})]}):s.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),s.jsx(HE,{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})," 里更新到 ",h==null?void 0:h.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:[h===void 0?"还没有检查过更新":h.available?`有新版本 ${h.latest}`:`已是最新(${h.latest})`,h!==void 0&&` · ${yt(h.checkedAt,r)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n||!f,onClick:()=>void o("check",async()=>{const g=await e.connection.call("scripts/checkUpdate",{id:t.id});return g.available?`发现新版本 ${g.latest}${g.current===void 0?"(认不出当前版本)":`,当前 ${g.current}`}`:"已是最新版本"}),children:i==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:n||(h==null?void 0:h.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," · ",yt(t.undo.at,r)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void o("restore",async()=>{const g=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${g.localVersion===void 0?"":`(${g.localVersion.version})`}`}),children:i==="restore"?"撤销中…":"撤销上次更新"})]})]})}function p8({client:e,script:t,openSession:n}){var A,T,M;const i=je(e.connection.status),r=je(e.capabilities),o=un(6e4),[c,u]=y.useState([]),[d,h]=y.useState(0),[f,g]=y.useState(!1),[p,x]=y.useState(null),[b,k]=y.useState(null),[w,j]=y.useState([]),[E,N]=y.useState(!1);y.useEffect(()=>e.connection.on("packs/changed",()=>h(P=>P+1)),[e]),y.useEffect(()=>{if(i.state!=="open"||!r.has("packs"))return;let P=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(V=>{P&&u(V.items)}).catch(()=>{}),()=>{P=!1}},[e,t.id,i.state,r,d]),y.useEffect(()=>{if(i.state!=="open"||!r.has("packs")||t.packId===void 0){j([]);return}let P=!0;return e.connection.call("packs/history",{packId:t.packId}).then(V=>{P&&j(V.items)}).catch(()=>{P&&j([])}),()=>{P=!1}},[e,t.packId,i.state,r,d]);const C=async P=>{g(!0),x(null);try{await P()}catch(V){x(Ie(V))}finally{g(!1)}},L=()=>C(async()=>{const{sessionId:P}=await e.connection.call("sessions/create",{focus:{scripts:[t.id]},role:"scripts"});await e.connection.call("session/prompt",{sessionId:P,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),${t.packId===void 0?"为它生成":"检查并改进它的"}脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。写好给我看的使用说明(每个任务和参数是什么、每个功能怎么开启、配置文件怎么设置、运行前检查什么、常见问题),给 agent 的备注写进 SKILL.md。用 pack_propose 保存(直接生效),docs 里写明依据的文档。`}),n(P)}),$=P=>C(async()=>{const{sessionId:V}=await e.connection.call("scripts/packReview",{id:t.id,decision:P});V!==void 0&&n(V)}),O=P=>C(async()=>{const{sessionId:V}=await e.connection.call("scripts/optimize",{id:t.id,decision:P});V!==void 0&&n(V)}),W=P=>C(async()=>{N(!1),await e.connection.call("packs/restore",{packId:t.packId,version:P.id}),N(!0)}),B=P=>`${P.builtin===!0?"内置脚本包":`${yt(P.at??o,o)}被替换`} · 任务:${P.tasks.map(V=>V.title).join("、")||"无"}`,U=c[0],D=w[0],F=(A=t.optimize)==null?void 0:A.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:f||i.state!=="open",onClick:()=>void O("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[s.jsx(Q,{name:"sparkles"}),"优化脚本"]}),s.jsxs("button",{className:"small-button",disabled:f||i.state!=="open",onClick:()=>void L(),children:[s.jsx(Q,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&U===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(Q,{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:f,onClick:()=>void $("keep"),children:"不用改"}),s.jsx("button",{className:"primary small-button",disabled:f||i.state!=="open",onClick:()=>void $("check"),children:"让 agent 检查"})]})]}),F!==void 0&&t.packReview===void 0&&U===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(Q,{name:"sparkles"}),s.jsxs("span",{children:[F==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((T=t.optimize)==null?void 0:T.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((M=t.optimize)==null?void 0:M.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:f,onClick:()=>void O("keep"),children:"这次不用"}),s.jsx("button",{className:"primary small-button",disabled:f||i.state!=="open",onClick:()=>void O("run"),children:"优化脚本"})]})]}),D!==void 0&&s.jsxs("div",{className:"pack-history",children:[s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[D.builtin===!0?"现在用的是自己写的脚本包,可以换回":"上一版脚本包:",B(D)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:f||i.state!=="open",title:"现在用的这一版会留在历史里,可以再恢复回来",onClick:()=>void W(D),children:D.builtin===!0?"恢复内置的":"恢复上一版"})]}),w.length>1&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["更早的版本(",w.length-1,")"]}),s.jsx("ul",{children:w.slice(1).map(P=>s.jsxs("li",{children:[B(P)," ",s.jsx("button",{className:"link-button",disabled:f||i.state!=="open",onClick:()=>void W(P),children:"恢复"})]},P.id))})]}),E&&s.jsx("p",{className:"muted small",children:"已恢复。刚才用的那一版留在历史里,可以再恢复回来。"})]}),U!==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:[yt(U.proposedAt,o),"提交 · 任务:",U.tasks.map(P=>P.title).join("、")||"无"]})]}),s.jsx("p",{className:"draft-summary",children:U.summary}),U.docs!==void 0&&U.docs.length>0&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["依据的文档(",U.docs.length,")"]}),s.jsx("ul",{children:U.docs.map(P=>s.jsxs("li",{children:[s.jsx("code",{children:P.source}),":",P.used]},P.source))})]}),U.noDocs!==void 0&&s.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",U.noDocs]}),U.current!==void 0&&s.jsxs("p",{className:"muted small",children:["接受后会替换当前的",U.current.builtin?"内置":"","脚本包(之前的版本会保留在历史里)。"]}),s.jsxs("div",{className:"segmented draft-tabs",children:[s.jsxs("label",{className:b==="manifest"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:b==="manifest",onChange:()=>k(P=>P==="manifest"?null:"manifest")}),"adg.script.yaml"]}),s.jsxs("label",{className:b==="skill"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:b==="skill",onChange:()=>k(P=>P==="skill"?null:"skill")}),"SKILL.md"]})]}),b!==null&&s.jsx("pre",{className:"draft-text",children:b==="manifest"?U.manifest:U.skill}),s.jsxs("div",{className:"key-actions",children:[U.sessionId!==void 0&&s.jsx("button",{className:"link-button",onClick:()=>n(U.sessionId),children:"查看分析过程"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:f,onClick:()=>void C(()=>e.connection.call("packs/reject",{packId:U.packId})),children:"拒绝"}),s.jsx("button",{className:"primary small-button",disabled:f,onClick:()=>void C(()=>e.connection.call("packs/accept",{packId:U.packId})),children:"接受并使用"})]})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:p})]})]})}function g8({client:e,script:t}){const n=je(e.connection.status),i=un(15e3),[r,o]=y.useState(void 0),[c,u]=y.useState(0),[d,h]=y.useState(30),[f,g]=y.useState(null);y.useEffect(()=>e.connection.on("guard/changed",()=>u(b=>b+1)),[e]),y.useEffect(()=>{if(n.state!=="open")return;let b=!0;return e.connection.call("guard/grants",{}).then(k=>{b&&o(k.items.find(w=>w.scriptId===t.id))}).catch(()=>{}),()=>{b=!1}},[e,t.id,n.state,c]);const p=r!==void 0&&r.expiresAt>i?r:void 0,x=b=>{g(null),b().catch(k=>g(Ie(k)))};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 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),p===void 0?s.jsx("span",{className:"badge ok",children:"受保护"}):s.jsx("span",{className:"badge warn",children:"已允许"})]}),p===void 0?s.jsxs("div",{className:"key-actions",children:[s.jsxs("label",{className:"check-label",children:["允许 agent 修改",s.jsx(Dt,{inline:!0,"aria-label":"允许多久",value:String(d),onChange:b=>h(Number(b)),options:[15,30,60,120].map(b=>({value:String(b),label:`${b} 分钟`}))})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>x(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:d})),children:"临时允许"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((p.expiresAt-i)/6e4))," 分钟"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>x(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),f!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:f})]})]})}function x8({client:e,script:t}){const n=je(e.connection.status),i=un(6e4),r=LS(e,t.id),[o,c]=y.useState(void 0),[u,d]=y.useState(null),[h,f]=y.useState(0),[g,p]=y.useState(null),[x,b]=y.useState(null),[k,w]=y.useState(null),[j,E]=y.useState(!1),[N,C]=y.useState(null),[L,$]=y.useState(null),[O,W]=y.useState(null),B=(r==null?void 0:r.items.find(P=>P.id===o))??(r==null?void 0:r.items.find(P=>P.id===r.current));y.useEffect(()=>{p(null),w(null)},[B==null?void 0:B.id]),y.useEffect(()=>e.connection.on("runs/state",P=>{P.scriptId!==t.id||P.endedAt===void 0||(f(V=>V+1),W(V=>V===null||V.runId!==P.id?V:(C(P.state==="succeeded"?`修改已同步到「${V.profile}」`:P.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${P.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const U=async P=>{if(O!==null){W({...O,finishing:P});try{P==="done"?await e.connection.call("configs/done",{runId:O.runId}):await e.connection.call("runs/stop",{runId:O.runId})}catch(V){$(Ie(V)),W(null)}}};y.useEffect(()=>{if(n.state!=="open"||B===void 0)return;let P=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:B.id}).then(V=>{P&&(d(V),$(null))}).catch(V=>{P&&$(Ie(V))}),()=>{P=!1}},[e,t.id,t.packId,n.state,h,B==null?void 0:B.id]);const D=async P=>{E(!0),$(null),C(null);try{const V=await P();typeof V=="string"&&C(V),f(z=>z+1)}catch(V){$(Ie(V))}finally{E(!1)}},F=((r==null?void 0:r.items.length)??0)>1,A=B!==void 0&&B.id===(r==null?void 0:r.current),T=(u==null?void 0:u.files.filter(P=>P.local))??[],M=u!==null&&u.profile.id===(B==null?void 0:B.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:j||O!==null||n.state!=="open"||B===void 0,onClick:()=>void D(async()=>{const P=await e.connection.call("configs/open",{scriptId:t.id,profile:B.id});if(P.endedAt===void 0)W({runId:P.id,profile:B.name,finishing:null});else if(P.state!=="succeeded")throw new Error(P.outcome??"没能打开脚本的设置界面")}),children:[s.jsx(Q,{name:"settings"}),"打开脚本修改设置"]})]}),r!==null&&(F||((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:[r.items.map(P=>s.jsxs("button",{role:"tab","aria-selected":P.id===(B==null?void 0:B.id),className:`profile-chip ${P.id===(B==null?void 0:B.id)?"active":""}`,onClick:()=>c(P.id),children:[P.name,P.id===r.current&&F&&s.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},P.id)),s.jsx("button",{className:"ghost small-button",disabled:j,onClick:()=>b(P=>P===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),B!==void 0&&F&&k===null&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:A?"运行时没有指定配置就用这一份":"在编排或运行时选它才会用到"}),s.jsx("span",{className:"spacer"}),!A&&s.jsx("button",{className:"small-button",disabled:j,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:B.id,current:!0}),`现在默认使用「${B.name}」`)),children:"设为当前使用"}),s.jsx("button",{className:"ghost small-button",disabled:j,onClick:()=>w(B.name),children:"改名"}),B.id!=="default"&&(g==="remove"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"用了这份配置的编排步骤会运行失败"}),s.jsx("button",{className:"small-button",onClick:()=>p(null),children:"取消"}),s.jsx("button",{className:"danger-outline small-button",disabled:j,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:B.id}),p(null),c(void 0),`已删除「${B.name}」`)),children:"确认删除"})]}):s.jsx("button",{className:"ghost small-button",disabled:j,onClick:()=>p("remove"),children:"删除"}))]}),B!==void 0&&k!==null&&s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain","aria-label":"新名字",value:k,maxLength:30,autoFocus:!0,onChange:P=>w(P.target.value)}),s.jsx("button",{className:"small-button",onClick:()=>w(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:j||k.trim()==="",onClick:()=>void D(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:B.id,name:k.trim()}),w(null)}),children:"保存"})]}),x!==null&&B!==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:x.name,maxLength:30,autoFocus:!0,onChange:P=>b({...x,name:P.target.value})}),s.jsxs("fieldset",{className:"asset-list",disabled:j,children:[s.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${B.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(P=>P.file).join("、"))||"脚本包声明的配置文件"}`]].map(([P,V,z])=>s.jsxs("label",{className:`asset-option choice-option ${x.source===P?"active":""}`,children:[s.jsx("input",{type:"radio",name:"profile-source",value:P,checked:x.source===P,onChange:()=>b({...x,source:P})}),s.jsxs("span",{className:"choice-text",children:[s.jsx("span",{children:V}),s.jsx("span",{className:"muted small",children:z})]})]},P))]}),x.source==="folder"&&s.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:x.dir,onChange:P=>b({...x,dir:P.target.value})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>b(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:j||x.name.trim()===""||x.source==="folder"&&x.dir.trim()==="",onClick:()=>void D(async()=>{const P=x.source==="copy"?{kind:"copy",profile:B.id}:x.source==="original"?{kind:"original"}:{kind:"folder",dir:x.dir.trim()},V=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:x.name.trim(),from:P});return b(null),c(V.profile.id),`已保存「${V.profile.name}」:${V.files.length>0?V.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),M!==null&&s.jsxs(s.Fragment,{children:[M.drift.length>0&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:["原项目的配置在导入后改过(",M.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",M.profile.name,"」运行;需要的话可以导入。"]})]}),s.jsx(Ra,{id:`config.files.${t.id}`,title:"配置文件",count:M.files.length,children:s.jsxs("ul",{className:"version-list",children:[M.files.map(P=>s.jsx(v8,{client:e,scriptId:t.id,profile:M.profile.id,file:P},`${M.profile.id}:${P.file}`)),M.files.length===0&&s.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[M.importedAt===void 0?"还没有导入":`${yt(M.importedAt,i)}${F?`存的「${M.profile.name}」`:"从原项目导入"}`,T.length>0&&" · ",T.length>0&&s.jsx("button",{className:"link-button",onClick:()=>{var P;return void((P=navigator.clipboard)==null?void 0:P.writeText(M.dir))},children:"复制本地配置目录"})]}),s.jsx("span",{className:"spacer"}),g!=="import"?s.jsx("button",{className:"small-button",disabled:j,onClick:()=>p("import"),children:"导入原项目设置"}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",M.profile.name,"」"]}),s.jsx("button",{className:"small-button",onClick:()=>p(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:j,onClick:()=>void D(async()=>{const P=await e.connection.call("configs/import",{scriptId:t.id,profile:M.profile.id});return p(null),P.imported.length>0?`已导入到「${M.profile.name}」:${P.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),N!==null&&s.jsx("div",{className:"notice info left small",children:N}),O!==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(Q,{name:"settings"}),"正在用脚本自己的界面修改设置"]}),s.jsxs("p",{children:[t.name," 的设置窗口已经打开,用的是本地配置「",O.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",O.profile,"」,之后的运行和编排都用它。"]}),s.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),O.finishing!==null&&s.jsxs("p",{className:"dialog-progress",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),O.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:O.finishing!==null,onClick:()=>void U("discard"),children:"放弃修改"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:O.finishing!==null,onClick:()=>void U("done"),children:O.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),L!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:L})]})]})}function v8({client:e,scriptId:t,profile:n,file:i}){const[r,o]=y.useState(!1),[c,u]=y.useState(null),[d,h]=y.useState(null),f=()=>{o(g=>!g),!(c!==null||!i.local)&&e.connection.call("configs/read",{scriptId:t,file:i.file,profile:n}).then(u,g=>h(Ie(g)))};return s.jsxs("li",{className:`config-file ${r?"open":""}`,children:[s.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":r,onClick:f,disabled:!i.local,title:i.local?"展开看本地配置的内容":"本地还没有这个文件",children:[s.jsx(Q,{name:"chevron",className:`fold-chevron ${r?"open":""}`}),s.jsx("span",{className:"version-name",children:i.file}),i.local?s.jsx("span",{className:"badge ok",children:"本地已保存"}):s.jsx("span",{className:"badge",children:"本地没有"}),i.changed&&s.jsx("span",{className:"badge warn",children:"原项目已改动"}),!i.original&&s.jsx("span",{className:"muted small",children:"原项目里没有"})]}),r&&(d!==null?s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]}):c===null?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsxs("pre",{className:"config-preview",children:[c.content,c.truncated?`
236
+ …(太长,只显示前一部分)`:""]}))]})}function y8({client:e,scriptId:t,scriptName:n,openSession:i}){const r=je(e.connection.status),[o,c]=y.useState(null),[u,d]=y.useState(""),[h,f]=y.useState(""),[g,p]=y.useState(""),[x,b]=y.useState(!1),[k,w]=y.useState(null),[j,E]=y.useState(!1),[N,C]=y.useState(null),[L,$]=y.useState(!1);y.useEffect(()=>{if(r.state!=="open")return;let M=!0;return e.connection.call("configs/launch",{scriptId:t}).then(P=>{M&&(c(P),d(P.settings.pcExe??""),f(P.settings.pcProcess??""),p(P.settings.androidPackage??""))}).catch(P=>{M&&w(Ie(P))}),()=>{M=!1}},[e,t,r.state]);const O=async M=>{b(!0),w(null),E(!1);try{c(await e.connection.call("configs/launch/set",{scriptId:t,...M})),E(!0),"pcExe"in M&&LE()}catch(P){w(Ie(P))}finally{b(!1)}},W=async M=>{d(M),await O({pcExe:M})},B=async()=>{$(!0),w(null),E(!1),C(null);try{const M=await e.connection.call("configs/launch/locate",{scriptId:t});C(M),M.candidates.length===1&&await W(M.candidates[0].path)}catch(M){w(Ie(M))}finally{$(!1)}},U=async()=>{w(null);try{const{sessionId:M}=await e.connection.call("sessions/create",{focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:M,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 保存。`}),i(M)}catch(M){w(Ie(M))}},D=async()=>{w(null);try{const M=await Cx(e,{kind:"file",title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});M!==null&&await W(M)}catch(M){w(Ie(M))}};if(o===null)return k===null?null:s.jsx("section",{className:"card",children:s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:k})]})});const{settings:F,game:A,uses:T}=o;return!T.adb&&!T.desktop?null:s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:["启动游戏",A.name===void 0?"":`:${A.name}`]}),s.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",A.selfLaunch,"。"]})]})}),s.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),s.jsx(Dt,{id:`launch-mode-${t}`,value:F.mode,disabled:x,onChange:M=>void O({mode:M}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),F.mode!=="off"&&T.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:g,onChange:M=>p(M.target.value),placeholder:A.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void O({androidPackage:g.trim()===""?null:g.trim()}),children:"保存"})]}),A.androidPackage!==void 0&&s.jsxs("p",{className:"muted small",children:["默认 ",A.androidPackage,";B 服、国际服等版本的包名不同时在这里改。"]})]}),F.mode!=="off"&&T.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:M=>d(M.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void O({pcExe:u.trim()===""?null:u.trim().replace(/^"|"$/g,"")}),children:"保存"})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{className:"small-button",disabled:x||L,onClick:()=>void B(),children:L?"正在查找…":"自动查找"}),s.jsx("button",{className:"small-button",disabled:x||L,onClick:()=>void D(),children:"选择文件…"}),s.jsx("button",{className:"link-button small",disabled:L,onClick:()=>void U(),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,"(查了正在运行的程序、以前运行过的程序、Windows 搜索、已安装程序、游戏启动器记下的目录、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 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(M=>s.jsxs("button",{className:`candidate ${F.pcExe===M.path?"chosen":""}`,disabled:x,onClick:()=>void W(M.path),children:[s.jsx("span",{className:"mono",children:M.path}),s.jsx("span",{className:"muted small",children:M.source})]},M.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:h,onChange:M=>f(M.target.value),placeholder:A.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void O({pcProcess:h.trim()===""?null:h.trim()}),children:"保存"})]}),s.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),j&&s.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:k})]})]})}const b8=15*6e4;function k8({client:e,script:t,openSession:n}){const i=un(3e4),[r,o]=y.useState(!1),[c,u]=y.useState(null),d=t.summary,h=(d==null?void 0:d.state)==="running"&&i-d.at<b8,f=(d==null?void 0:d.state)==="failed"||d==null?void 0:d.text,g=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(p){u(Ie(p))}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:h?"agent 正在看它的说明和文件…":d===void 0?"让 AI 看看它的说明(README)、文件和脚本包,用几句话说清楚它是什么、能做什么。":d.state==="failed"||d.state==="running"?"上次总结没有完成":`AI 总结 · ${yt(d.at,i)}`})]}),s.jsxs("div",{className:"key-actions",children:[(d==null?void 0:d.sessionId)!==void 0&&s.jsx("button",{className:"ghost small-button",onClick:()=>n(d.sessionId),children:h?"看看进度":"查看对话"}),s.jsxs("button",{className:`${d===void 0?"primary ":""}small-button`,disabled:r||h,onClick:()=>void g(),children:[s.jsx(Q,{name:"sparkles"}),h?"总结中…":d===void 0?"让 AI 总结":"重新总结"]})]})]}),f!==void 0&&s.jsx("p",{className:`summary-text ${h?"muted":""}`,children:f}),(d==null?void 0:d.state)==="failed"&&d.text!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d.text})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:c})]})]})}const N8={desktop:"占用鼠标键盘",adb:"用模拟器,不占鼠标",window:"后台操作游戏窗口",none:"不占用"};function j8(e){const t=/^(\d+)(s|m|h)$/.exec(e);return t===null?e:`约 ${t[1]} ${t[2]==="s"?"秒":t[2]==="m"?"分钟":"小时"}`}function dg({items:e}){const t=e.filter(n=>n[1]!==void 0&&n[1]!=="");return t.length===0?null:s.jsx("div",{className:"guide-facts muted small",children:t.map(([n,i])=>s.jsxs("span",{children:[n,":",i]},n))})}function w8({client:e,script:t}){const n=je(e.connection.status),[i,r]=y.useState(void 0),[o,c]=y.useState(null),[u,d]=y.useState(0),[h,f]=y.useState("tasks");if(y.useEffect(()=>e.connection.on("packs/changed",()=>d(b=>b+1)),[e]),y.useEffect(()=>{if(n.state!=="open"||t.packId===void 0)return;let b=!0;return e.connection.call("scripts/guide",{id:t.id}).then(k=>{b&&(r(k.guide),c(null))}).catch(k=>{b&&c(Ie(k))}),()=>{b=!1}},[e,t.id,t.packId,n.state,u]),t.packId===void 0||i===null)return null;const p=(i===void 0?[]:[["tasks",`任务与参数(${i.tasks.length})`,!0],["features",`功能开启(${i.features.length})`,i.features.length>0],["config","配置文件",i.config.length>0],["before","运行前",i.setup.length+i.checks.length>0],["problems",`常见问题(${i.troubleshooting.length})`,i.troubleshooting.length>0]]).filter(([,,b])=>b),x=p.some(([b])=>b===h)?h:"tasks";return s.jsxs("section",{className:"card script-guide",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"使用说明"}),s.jsx("p",{className:"muted small",children:i===void 0?"读取中…":i.written?`脚本包 ${i.packId} 的说明${i.builtin?"(内置)":""}`:"这个脚本包还没有写使用说明,下面只有任务和运行时的临时修改;可以在「脚本包」里点「让 agent 改进」补上。"})]})}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:o})]}),i!==void 0&&s.jsxs(s.Fragment,{children:[i.overview!==void 0&&s.jsx("p",{className:"guide-overview",children:i.overview}),p.length>1&&s.jsx("div",{className:"segmented guide-tabs",role:"tablist",children:p.map(([b,k])=>s.jsxs("label",{className:x===b?"active":"",children:[s.jsx("input",{type:"radio",name:`guide-${t.id}`,checked:x===b,onChange:()=>f(b)}),k]},b))}),x==="tasks"&&s.jsx(S8,{guide:i}),x==="features"&&s.jsx(_8,{guide:i}),x==="config"&&s.jsx(E8,{guide:i}),x==="before"&&s.jsx(C8,{guide:i}),x==="problems"&&s.jsx(A8,{guide:i})]})]})}function S8({guide:e}){return e.tasks.length===0?s.jsx("p",{className:"muted small",children:"脚本包没有声明任务。"}):s.jsx("ul",{className:"guide-list",children:e.tasks.map(t=>s.jsxs("li",{children:[s.jsxs("div",{className:"guide-item-head",children:[s.jsx("strong",{children:t.title}),s.jsx("span",{className:"chip",children:t.id}),s.jsx("span",{className:"badge",children:N8[t.input]}),t.expectedDuration!==void 0&&s.jsx("span",{className:"muted small",children:j8(t.expectedDuration)})]}),t.description!==void 0&&s.jsx("p",{children:t.description}),t.utterances.length>0&&s.jsxs("p",{className:"muted small",children:["可以这样说:",t.utterances.map(n=>`「${n}」`).join("")]}),t.params.length===0?s.jsx("p",{className:"muted small",children:"没有参数。"}):s.jsx("dl",{className:"guide-keys",children:t.params.map(n=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:n.name})}),s.jsxs("dd",{children:[s.jsx("span",{children:n.description??"(没有说明)"}),s.jsx(dg,{items:[["可选值",n.values],["默认",n.default??(n.values===void 0?"无,运行时必须填":void 0)]]})]})]},n.name))})]},t.id))})}function _8({guide:e}){return s.jsx("ul",{className:"guide-list",children:e.features.map(t=>s.jsxs("li",{children:[s.jsxs("div",{className:"guide-item-head",children:[s.jsx("strong",{children:t.title}),t.tasks.length>0&&s.jsxs("span",{className:"muted small",children:["任务:",t.tasks.join("、")]})]}),t.description!==void 0&&s.jsx("p",{children:t.description}),s.jsxs("p",{children:[s.jsx("span",{className:"guide-label",children:"怎么开启"}),t.enable]}),t.config.length>0&&s.jsx("div",{className:"guide-facts muted small",children:t.config.map(n=>s.jsxs("span",{children:["配置:",s.jsx("code",{children:n.file})," 里 ",s.jsx("code",{children:n.key})," 设为 ",s.jsx("code",{children:n.value})]},`${n.file}:${n.key}`))})]},t.title))})}function E8({guide:e}){return s.jsx("div",{className:"guide-files",children:e.config.map(t=>s.jsxs("div",{className:"guide-file",children:[s.jsx("div",{className:"guide-item-head",children:s.jsx("code",{className:"guide-file-name",children:t.file})}),t.about!==void 0&&s.jsx("p",{children:t.about}),t.keys.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"field-label",children:"重要的键"}),s.jsx("dl",{className:"guide-keys",children:t.keys.map(n=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:n.key})}),s.jsxs("dd",{children:[s.jsx("span",{children:n.meaning}),s.jsx(dg,{items:[["取值",n.values],["默认",n.default]]}),n.advice!==void 0&&s.jsxs("span",{className:"guide-advice",children:["建议:",n.advice]})]})]},n.key))})]}),t.changes.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"field-label",children:"运行时本应用临时修改的键(只改本应用用的那份配置,运行结束后还原)"}),s.jsx("dl",{className:"guide-keys",children:t.changes.map(n=>s.jsxs("div",{children:[s.jsx("dt",{children:s.jsx("code",{children:n.key})}),s.jsxs("dd",{children:[s.jsxs("span",{children:["设为 ",s.jsx("code",{children:n.value}),n.note===void 0?"":`:${n.note}`]}),s.jsx(dg,{items:[["条件",n.when],["任务",n.tasks.join("、")]]})]})]},`${n.key}=${n.value}:${n.when??""}`))})]})]},t.file))})}function C8({guide:e}){return s.jsxs("div",{className:"guide-before",children:[e.setup.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"field-label",children:"第一次使用前"}),s.jsx("ol",{className:"guide-steps",children:e.setup.map((t,n)=>s.jsx("li",{children:t},n))})]}),e.checks.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"field-label",children:"每次运行前检查"}),s.jsx("ul",{className:"guide-steps checks",children:e.checks.map((t,n)=>s.jsx("li",{children:t},n))})]})]})}function A8({guide:e}){return s.jsx("ul",{className:"guide-list",children:e.troubleshooting.map((t,n)=>s.jsxs("li",{children:[s.jsx("strong",{children:t.problem}),t.cause!==void 0&&s.jsxs("p",{children:[s.jsx("span",{className:"guide-label",children:"原因"}),t.cause]}),s.jsxs("p",{children:[s.jsx("span",{className:"guide-label",children:"怎么办"}),t.fix]})]},n))})}const I8={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function ZE({client:e,setup:t,openSession:n,onImported:i}){const[r,o]=y.useState(t.dir),[c,u]=y.useState(!1),[d,h]=y.useState(null),[f,g]=y.useState(null),[p,x]=y.useState(!1),b=t.agent,k=async(w,j)=>{h(w),g(null);try{await j()}catch(E){g(Ie(E))}finally{h(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:["下载到的是 ",I8[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(b==null?void 0:b.state)==="running"&&s.jsxs("div",{className:"notice left",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:"agent 正在安装。也可以不等它,按下面的步骤自己装。"}),s.jsx("button",{className:"link-button",onClick:()=>n(b.sessionId),children:"查看对话"})]}),(b==null?void 0:b.state)==="failed"&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["agent 没能装好:",b.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),s.jsx("button",{className:"link-button",onClick:()=>n(b.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:d!==null,onClick:()=>void k("open",async()=>{await e.connection.call("scripts/setup/open",{id:t.scriptId}),u(!0)}),children:d==="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:w=>{w.preventDefault(),k("import",async()=>{const j=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),id:t.scriptId});i(j.id)})},children:[s.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:r,onChange:w=>o(w.target.value),spellCheck:!1,disabled:d!==null}),s.jsx("button",{className:"primary small-button",type:"submit",disabled:d!==null||r.trim()==="",children:d==="import"?"导入中…":"装好了,导入"})]})]})})]}),f!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:f})]}),s.jsx("div",{className:"key-actions",children:p?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>x(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:d!==null,onClick:()=>void k("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):s.jsxs(s.Fragment,{children:[(b==null?void 0:b.state)!=="running"&&s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void k("agent",async()=>{const{sessionId:w}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});n(w)}),children:d==="agent"?"正在交给 agent…":"让 agent 安装"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:d!==null,onClick:()=>x(!0),children:"不装了"})]})})]})}const T8={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function $8({client:e,script:t,job:n,setup:i,onRemoved:r,openSession:o}){var $;const c=un(6e4),[u,d]=y.useState(null),[h,f]=y.useState(null),[g,p]=y.useState(null),[x,b]=y.useState(!1),[k,w]=y.useState(!1),j=n!==void 0&&(n.endedAt===void 0||n.startedAt>=t.addedAt-1e3)?n:void 0,E=wa(j),N=je(e.capabilities),C=t.source.kind!=="local",L=async(O,W)=>{d(O),f(null),p(null);try{const B=await W();typeof B=="string"&&p(B)}catch(B){f(Ie(B))}finally{d(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:qj[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}`:"本地导入"})]})]})}),j!==void 0&&s.jsx(ug,{client:e,job:j}),i!==void 0&&s.jsx(ZE,{client:e,setup:i,openSession:o,onImported:()=>{}}),t.dir!==void 0&&s.jsx(k8,{client:e,script:t,openSession:o}),t.packId!==void 0&&s.jsx(w8,{client:e,script:t},`guide:${t.id}`),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 O;return void((O=navigator.clipboard)==null?void 0:O.writeText(t.dir))},children:[s.jsx(Q,{name:"copy"}),"复制路径"]})]}),C?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"version-list",children:t.versions.map(O=>{var W;return s.jsxs("li",{className:O.current?"current":"",children:[s.jsx("span",{className:"version-name",children:O.version}),O.current&&s.jsx("span",{className:"badge ok",children:"当前"}),s.jsxs("span",{className:"muted small",children:[((W=O.asset)==null?void 0:W.name)??""," · ",yt(O.installedAt,c)]}),s.jsx("span",{className:"spacer"}),!O.current&&s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void L("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:O.version}),`已切换到 ${O.version}`)),children:"切换到此版本"})]},O.version)})}),s.jsx("dl",{className:"local-facts channel-facts",children:s.jsx(HE,{client:e,script:t,disabled:E||u!==null,act:L})}),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&&` · ${yt(t.update.checkedAt,c)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void L("check",async()=>{const O=await e.connection.call("scripts/checkUpdate",{id:t.id});return O.available?`发现新版本 ${O.latest}`:"已是最新版本"}),children:u==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:E||u!==null||(($=t.update)==null?void 0:$.available)!==!0,onClick:()=>void L("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):s.jsx(m8,{client:e,script:t,disabled:E||u!==null,busy:u,now:c,act:L})]}),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?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${yt(t.env.checkedAt,c)}检查`})]}),s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void L("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(O=>{const[W,B]=T8[O.status];return s.jsxs("li",{children:[s.jsxs("div",{className:"env-main",children:[s.jsx("span",{className:"env-label",children:O.label}),s.jsx("span",{className:`badge ${W}`,children:B}),O.found!==void 0&&s.jsx("span",{className:"muted small",children:O.found})]}),O.detail!==void 0&&s.jsx("div",{className:"muted small",children:O.detail}),O.fix!==void 0&&s.jsxs("div",{className:"env-fix",children:[s.jsx("span",{className:"muted small",children:O.fix.description}),O.fix.kind!=="manual"&&s.jsx("button",{className:"small-button",disabled:E||u!==null,onClick:()=>void L(`fix-${O.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:O.kind})}),children:O.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},O.kind)})})]}),N.has("runs")&&t.dir!==void 0&&s.jsx(w3,{client:e,scriptId:t.id,packId:t.packId}),N.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(x8,{client:e,script:t}),N.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(y8,{client:e,scriptId:t.id,scriptName:t.name,openSession:o},t.id),N.has("packs")&&s.jsx(p8,{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(O=>s.jsx("span",{className:"chip",children:O},O))}),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(O=>s.jsx("span",{className:"chip",children:O},O))})]})]}),N.has("guard")&&s.jsx(g8,{client:e,script:t}),s.jsx("section",{className:"card danger-zone",children:x?s.jsxs("div",{className:"key-actions",children:[C&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:k,onChange:O=>w(O.target.checked)}),"同时删除所有已安装版本"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>b(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:u!==null,onClick:()=>void L("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:C&&k}),r()}),children:"确认移除"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:C?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:E,onClick:()=>b(!0),children:"移除"})]})}),g!==null&&s.jsx("div",{className:"notice info",children:g}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]})]})}function M8({client:e,openSession:t,arg:n}){const{data:i,error:r}=Gd(e),o=Vj(e),[c,u]=y.useState(null),[d,h]=y.useState(null);y.useEffect(()=>{(n==null?void 0:n.startsWith("mirror:"))===!0&&h({kind:"mirror",rid:n.slice(7)})},[n]);const f=(i==null?void 0:i.scripts)??[],g=((i==null?void 0:i.packs)??[]).filter(N=>!N.installed&&N.repo!==void 0&&N.error===void 0),p=((i==null?void 0:i.packs)??[]).filter(N=>N.error!==void 0),x=((i==null?void 0:i.known)??[]).filter(N=>!N.installed),b=(i==null?void 0:i.setups)??[],k=b.filter(N=>!f.some(C=>C.id===N.scriptId)),w=d===null?k.find(N=>N.scriptId===c):void 0,j=c===null||f.some(N=>N.id===c)||w!==void 0?void 0:o.get(c),E=f.find(N=>N.id===c)??(d===null&&j===void 0&&w===void 0?f[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:()=>h({kind:"import"}),children:[s.jsx(Q,{name:"paperclip"}),"导入本地项目"]}),s.jsxs("button",{className:"small-button",onClick:()=>h({kind:"mirror"}),children:[s.jsx(Q,{name:"plus"}),"从 Mirror酱 安装"]}),s.jsxs("button",{className:"primary small-button",onClick:()=>h({kind:"install"}),children:[s.jsx(Q,{name:"plus"}),"从 GitHub 安装"]})]})]}),s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"脚本列表",children:[r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:r})]}),i===null&&r===null&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),i!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sidebar-label",children:["我的脚本(",f.length,")"]}),f.length===0&&![...o.values()].some(wa)&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(Q,{name:"package"}),s.jsx("span",{children:"还没有脚本"}),s.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),f.map(N=>{var $,O;const C=o.get(N.id),L=(($=N.env)==null?void 0:$.items.filter(W=>W.status!=="ok"&&W.status!=="unsupported").length)??0;return s.jsxs("button",{className:`script-row ${N.id===(E==null?void 0:E.id)&&d===null?"active":""}`,onClick:()=>{u(N.id),h(null)},children:[s.jsx(DE,{client:e,iconKey:`script:${N.id}:${N.current??""}`,name:N.name,className:"script-avatar",load:()=>e.connection.call("scripts/icon",{id:N.id})}),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?"":` · ${qj[N.family]??N.family}`]})]}),wa(C)?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):b.some(W=>W.scriptId===N.id)?s.jsx("span",{className:"badge warn",children:"待安装"}):((O=N.update)==null?void 0:O.available)===!0?s.jsx("span",{className:"badge ok",children:"可更新"}):L>0?s.jsxs("span",{className:"badge warn",children:["环境 ",L]}):null]},N.id)}),k.length>0&&s.jsxs("div",{className:"sidebar-label",children:["等待安装(",k.length,")"]}),k.map(N=>{var C,L,$;return s.jsxs("button",{className:`script-row ${N===w?"active":""}`,onClick:()=>{u(N.scriptId),h(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," · ",((C=N.agent)==null?void 0:C.state)==="running"?"agent 正在安装":((L=N.agent)==null?void 0:L.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),(($=N.agent)==null?void 0:$.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=>wa(N)&&!f.some(C=>C.id===N.scriptId)).map(N=>s.jsxs("button",{className:`script-row ${c===N.scriptId&&d===null?"active":""}`,onClick:()=>{u(N.scriptId),h(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:["正在安装 · ",mc[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)),(g.length>0||x.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),g.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:()=>h({kind:"install",repo:N.repo}),children:"安装"})]},N.id)),x.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:()=>h(N.mirrorchyan!==void 0?{kind:"mirror",rid:N.mirrorchyan}:{kind:"install",repo:N.repo}),children:"安装"})]},N.id))]}),p.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:[p.length," 个脚本包无法读取:",p.map(N=>N.id).join("、")]})]})]})]}),s.jsxs("div",{className:"scripts-detail",children:[(d==null?void 0:d.kind)==="install"&&s.jsx(a8,{client:e,jobs:o,...d.repo===void 0?{}:{initialRepo:d.repo},onClose:()=>h(null),onDone:N=>{u(N),h(null)},openSession:t},d.repo??"blank"),(d==null?void 0:d.kind)==="mirror"&&s.jsx(o8,{client:e,jobs:o,...d.rid===void 0?{}:{initialRid:d.rid},onClose:()=>h(null),onDone:N=>{u(N),h(null)},openSession:t,onGitHub:N=>h({kind:"install",repo:N})},d.rid??"blank"),(d==null?void 0:d.kind)==="import"&&s.jsx(h8,{client:e,onClose:()=>h(null),onImported:N=>{u(N),h(null)}}),d===null&&E!==void 0&&s.jsx($8,{client:e,script:E,job:o.get(E.id),setup:b.find(N=>N.scriptId===E.id),onRemoved:()=>u(null),openSession:t},E.id),w!==void 0&&s.jsx(ZE,{client:e,setup:w,openSession:t,onImported:N=>u(N)},w.scriptId),d===null&&E===void 0&&j!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:j.scriptId}),s.jsx("p",{className:"muted small",children:wa(j)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),s.jsx(ug,{client:e,job:j})]}),d===null&&E===void 0&&j===void 0&&w===void 0&&i!==null&&s.jsxs("div",{className:"empty",children:[[...o.values()].filter(N=>wa(N)&&!f.some(C=>C.id===N.scriptId)).map(N=>s.jsxs("div",{className:"pending-install",children:[s.jsx("strong",{children:N.scriptId}),s.jsx(ug,{client:e,job:N})]},N.id)),s.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),i!==null&&s.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",i.toolsDir]})]})]})]})}const R8={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:M8}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:r8}]},O8={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:i8}]},qm="https://github.com/haaahhhis/MultiGameAssistant";function P8({client:e}){const[t,n]=y.useState(void 0),i=Aw(e),r=t===null?i===void 0?void 0:i===!1?null:i.version:null;y.useEffect(()=>{var d;const c=(d=ni())==null?void 0:d.appInfo;if(c===void 0){n(null);return}let u=!0;return c().then(h=>{u&&n(h)},()=>{u&&n(null)}),()=>{u=!1}},[]);const o=t===void 0?"…":t===null?r===void 0?"…":r===null?"在浏览器里打开(版本见桌面版)":`${r}(dsh 插件版)`:t.fromSource?`从源码运行(${t.arch})`:`${t.version??"未知版本"}(${t.arch}${t.commit===void 0?"":` · ${t.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:o}),s.jsx("dt",{children:"源代码"}),s.jsx("dd",{children:s.jsx("a",{href:qm,target:"_blank",rel:"noreferrer",children:qm.replace("https://","")})}),s.jsx("dt",{children:"许可证"}),s.jsx("dd",{children:s.jsx("a",{href:`${qm}/blob/main/LICENSE`,target:"_blank",rel:"noreferrer",children:"GNU AGPL-3.0-only"})})]})}),(t==null?void 0:t.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)。"})]}):t!=null?s.jsx(z8,{}):typeof r=="string"&&s.jsx(L8,{client:e}),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 z8(){const{bridge:e,state:t}=Hg();if(e===void 0||t===null)return null;const n=t==null?void 0:t.latest,i=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.jsx("p",{className:(t==null?void 0:t.error)!==void 0&&!t.checking?"error small":"muted small",children:i})]}),s.jsxs("button",{className:"small-button",disabled:t===void 0||t.checking,onClick:()=>void e.check(),children:[s.jsx(Q,{name:"refresh"}),"检查更新"]})]}),n!==void 0&&s.jsx("div",{className:"about-release-notes",children:s.jsx(Zg,{notes:n.notes??[],notesUrl:n.notesUrl})}),t!==void 0&&s.jsx(Wg,{bridge:e,state:t}),t!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.auto,onChange:r=>void e.setAuto(r.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}function L8({client:e}){var r;const t=Iw(e,!0),n=(r=t.result)==null?void 0:r.latest,i=t.checking?"正在检查…":t.error!==void 0?t.error:n!==void 0?`有新版本 ${n.version}${n.prerelease?"(预发布版)":""}`:t.result!==void 0?`已经是最新版本(${new Date(t.result.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.jsx("p",{className:t.error!==void 0&&!t.checking?"error small":"muted small",children:i})]}),s.jsxs("button",{className:"small-button",disabled:t.checking,onClick:t.check,children:[s.jsx(Q,{name:"refresh"}),"检查更新"]})]}),n!==void 0&&!t.checking&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"about-release-notes",children:s.jsx(Zg,{notes:n.notes??[],notesUrl:n.notesUrl})}),s.jsx(Rw,{version:n.version,onNpm:n.onNpm})]})]})}const Jl=e=>e.replace(/\/+$/,""),NN=e=>{const t=Jl(e);return t.endsWith("/v1")?t.slice(0,-3):t},WE=[{id:"openai-completions",title:"OpenAI 兼容",subtitle:"Chat Completions",hint:"绝大多数第三方网关和本地服务都用这种:OneAPI / NewAPI、OpenRouter、硅基流动、vLLM、Ollama、LM Studio 等。",placeholder:"https://api.example.com/v1",requestPath:e=>`${Jl(e)}/chat/completions`,listPath:e=>`${Jl(e)}/models`},{id:"openai-responses",title:"OpenAI Responses",subtitle:"Responses API",hint:"OpenAI 的新一代接口,支持推理摘要等能力;仅在服务方明确支持 /responses 时使用。",placeholder:"https://api.openai.com/v1",requestPath:e=>`${Jl(e)}/responses`,listPath:e=>`${Jl(e)}/models`},{id:"anthropic-messages",title:"Anthropic 兼容",subtitle:"Messages API",hint:"Claude 官方接口以及兼容 Anthropic 格式的网关。地址写到域名即可,末尾的 /v1 可有可无。",placeholder:"https://api.anthropic.com",requestPath:e=>`${NN(e)}/v1/messages`,listPath:e=>`${NN(e)}/v1/models`}];function hg(e){return WE.find(t=>t.id===e)}function D8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function F8(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const U8=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function B8(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function Sa(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)}const VE=1e6,Hl=e=>(e.contextWindow??0)>=VE;function H8({client:e,profile:t,preset:n,taken:i,revision:r,readOnly:o,onDone:c}){var re;const u=t===void 0,d=n===void 0||n.id===""?"":i.includes(n.id)?`${n.id}-2`:n.id,[h,f]=y.useState(()=>{var ee;return((ee=hg((t==null?void 0:t.api)??(n==null?void 0:n.api)))==null?void 0:ee.id)??"openai-completions"}),[g,p]=y.useState((t==null?void 0:t.displayName)??((n==null?void 0:n.baseURL)===""?"":(n==null?void 0:n.name)??"")),[x,b]=y.useState((t==null?void 0:t.id)??d),[k,w]=y.useState(!u||d!==""),[j,E]=y.useState((t==null?void 0:t.baseURL)??(n==null?void 0:n.baseURL)??""),[N,C]=y.useState(""),[L,$]=y.useState((t==null?void 0:t.models)??[]),[O,W]=y.useState(!1),[B,U]=y.useState(null),D=hg(h),F=j.trim(),A=F!==""&&!B8(F),T=x!==""&&!U8.test(x),M=u&&i.includes(x),P=GE(N),V=(t==null?void 0:t.apiKeyRef)??(x===""?null:F8(x)),z=((re=t==null?void 0:t.credential)==null?void 0:re.configured)===!0,H=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,G=x===""?"请填写标识":T?"标识格式不正确":M?"这个标识已被占用":F===""?"请填写 Base URL":A?"Base URL 需要以 http:// 或 https:// 开头":P!==null?P:L.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,Z=ee=>{p(ee),k||b(D8(ee))},Y=async()=>{if(G===null){W(!0),U(null);try{await e.saveProvider({id:x,create:u,...g.trim()===""?{}:{displayName:g.trim()},api:h,baseURL:F,models:[...L],...N.trim()===""?{}:{apiKey:N.trim()},expectedRevision:r}),c()}catch(ee){const te=ee instanceof Error?ee.message:String(ee);U(/SETTINGS_CONFLICT|conflict/i.test(te)?"配置在别处被修改过了,请返回列表后重试。":te)}finally{W(!1)}}},X=O||o;return s.jsxs("form",{className:"provider-editor",onSubmit:ee=>{ee.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:O,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:WE.map(ee=>s.jsxs("button",{type:"button",role:"radio","aria-checked":h===ee.id,"aria-label":`${ee.title}(${ee.subtitle})`,className:`mode-option${h===ee.id?" selected":""}`,onClick:()=>f(ee.id),disabled:X,children:[s.jsx("span",{className:"mode-title",children:ee.title}),s.jsx("span",{className:"mode-subtitle",children:ee.subtitle})]},ee.id))}),s.jsx("div",{className:"muted small",children:D.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:g,onChange:ee=>Z(ee.target.value),placeholder:"例如:我的中转站",disabled:X})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"标识"}),s.jsx("input",{className:"text-input",value:x,onChange:ee=>{b(ee.target.value.trim()),w(!0)},placeholder:"my-gateway",disabled:X||!u,spellCheck:!1})]})]}),s.jsx("div",{className:T||M?"error small":"muted small",children:T?"标识只能用小写字母、数字和单个连字符,并以字母开头。":M?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"Base URL"}),s.jsx("input",{className:"text-input",value:j,onChange:ee=>E(ee.target.value),placeholder:D.placeholder,disabled:X,spellCheck:!1})]}),A?s.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):F!==""&&s.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",s.jsxs("code",{children:["POST ",D.requestPath(F)]}),s.jsx("br",{}),"模型列表 ",s.jsxs("code",{children:["GET ",D.listPath(F)]})]}),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:ee=>C(ee.target.value),placeholder:H?"由启动环境变量提供,无法在此修改":z?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:X||H,spellCheck:!1})]}),P!==null?s.jsx("div",{className:"error small",children:P}):V!==null&&s.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",s.jsx("code",{children:V})," 中,界面不会再显示 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(Z8,{client:e,models:L,onChange:$,probe:{...t===void 0?{}:{provider:t.id},api:h,baseURL:F,apiKey:N.trim()},probeBlocked:F===""?"先填写 Base URL":A?"Base URL 无效":P,disabled:X}),B!==null&&s.jsx("div",{className:"banner error",children:B}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:G}),s.jsx("span",{className:"spacer"}),s.jsx("button",{type:"button",onClick:c,disabled:O,children:"取消"}),s.jsx("button",{type:"submit",className:"primary",disabled:X||G!==null,children:O?"保存中…":u?"创建":"保存"})]})]})}function Z8({client:e,models:t,onChange:n,probe:i,probeBlocked:r,disabled:o}){const[c,u]=y.useState(null),[d,h]=y.useState(""),[f,g]=y.useState(""),[p,x]=y.useState(!1),[b,k]=y.useState(null),w=y.useRef(null),j=y.useMemo(()=>new Set(t.map(U=>U.id)),[t]),E=async()=>{var D;(D=w.current)==null||D.abort();const U=new AbortController;w.current=U,x(!0),k(null);try{const F=await e.discoverModels({...i.provider===void 0?{}:{provider:i.provider},api:i.api,baseURL:i.baseURL,...i.apiKey===""?{}:{apiKey:i.apiKey}},U.signal);if(U.signal.aborted)return;u([...F].sort((A,T)=>A.id.localeCompare(T.id))),F.length===0&&k("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(F){U.signal.aborted||k(F instanceof Error?F.message:String(F))}finally{w.current===U&&(w.current=null,x(!1))}},N=U=>{n(j.has(U.id)?t.filter(D=>D.id!==U.id):[...t,U])},C=U=>{n(t.map(D=>{if(D.id!==U)return D;if(D.efforts!==void 0&&D.efforts.length>0){const{efforts:F,...A}=D;return A}return{...D,efforts:["off","low","medium","high"]}}))},L=U=>{n(t.map(D=>{var F;return D.id!==U?D:{...D,input:((F=D.input)==null?void 0:F.includes("image"))===!0?["text"]:["text","image"]}}))},$=U=>{n(t.map(D=>{if(D.id!==U)return D;if(Hl(D)){const{contextWindow:F,...A}=D;return A}return{...D,contextWindow:VE}}))},O=y.useMemo(()=>{const U=d.trim().toLowerCase();return(c??[]).filter(D=>U===""||D.id.toLowerCase().includes(U)||(D.name??"").toLowerCase().includes(U))},[c,d]),W=U=>{if(U){const D=O.filter(F=>!j.has(F.id));n([...t,...D])}else{const D=new Set(O.map(F=>F.id));n(t.filter(F=>!D.has(F.id)))}},B=()=>{const U=f.split(/[\s,,]+/).map(D=>D.trim()).filter(D=>D!==""&&!j.has(D));U.length!==0&&(n([...t,...U.map(D=>(c==null?void 0:c.find(F=>F.id===D))??{id:D})]),g(""))};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 系列)点亮「思考」,对话里就能选强度;支持 1M 上下文的模型(如 gpt-4.1、Gemini)点亮「1M」,对话按 1M 计算、快满才压缩,模型本身不支持时别点亮,否则对话会超长出错。"]})]}),s.jsx("button",{type:"button",onClick:()=>void E(),disabled:o||p||r!==null,title:r??void 0,children:p?"拉取中…":c===null?"拉取模型列表":"重新拉取"})]}),b!==null&&s.jsx("div",{className:"error small",children:b}),t.length>0&&s.jsx("div",{className:"model-chips",children:t.map(U=>{var D,F,A,T,M,P;return s.jsxs("span",{className:"chip removable",children:[U.id,!Hl(U)&&Sa(U.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",Sa(U.contextWindow)]}),s.jsx("button",{type:"button",className:`chip-flag${((D=U.input)==null?void 0:D.includes("image"))===!0?" on":""}`,onClick:()=>L(U.id),disabled:o,"aria-pressed":((F=U.input)==null?void 0:F.includes("image"))===!0,title:((A=U.input)==null?void 0:A.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),s.jsx("button",{type:"button",className:`chip-flag${(((T=U.efforts)==null?void 0:T.length)??0)>0?" on":""}`,onClick:()=>C(U.id),disabled:o,"aria-pressed":(((M=U.efforts)==null?void 0:M.length)??0)>0,title:(((P=U.efforts)==null?void 0:P.length)??0)>0?`可选思考强度:${U.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),s.jsx("button",{type:"button",className:`chip-flag${Hl(U)?" on":""}`,onClick:()=>$(U.id),disabled:o,"aria-pressed":Hl(U),title:Hl(U)?"按 1M 上下文计算,快满时才压缩(点击关闭)":U.contextWindow!==void 0?`上下文 ${Sa(U.contextWindow)}(点击改为 1M)`:"上下文大小未知,dsh 默认按 1M 计算(点击写明 1M)",children:"1M"}),s.jsx("button",{type:"button",className:"chip-x",onClick:()=>n(t.filter(V=>V.id!==U.id)),disabled:o,"aria-label":`移除 ${U.id}`,children:"×"})]},U.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:d,onChange:U=>h(U.target.value),placeholder:`搜索 ${c.length} 个模型`}),s.jsxs("button",{type:"button",className:"small-button",onClick:()=>W(!0),disabled:o,children:["全选",d!==""?"筛选结果":""]}),s.jsx("button",{type:"button",className:"small-button",onClick:()=>W(!1),disabled:o,children:"全不选"})]}),s.jsxs("ul",{className:"candidate-list",children:[O.map(U=>{var D;return s.jsx("li",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:j.has(U.id),onChange:()=>N(U),disabled:o}),s.jsx("span",{className:"mono",children:U.id}),U.name!==void 0&&s.jsxs("span",{className:"muted",children:[" ",U.name]}),s.jsx("span",{className:"spacer"}),((D=U.input)==null?void 0:D.includes("image"))===!0&&s.jsx("span",{className:"badge",children:"图像"}),Sa(U.contextWindow)!==null&&s.jsxs("span",{className:"muted small",children:[Sa(U.contextWindow)," 上下文"]})]})},U.id)}),O.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:f,onChange:U=>g(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),B())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),s.jsx("button",{type:"button",onClick:B,disabled:o||f.trim()==="",children:"添加"})]})]})}const W8=[{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:""}],Gm=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:fp,keyUrl:"https://platform.deepseek.com/api_keys"}];function V8({client:e}){const{catalog:t}=el(e),[n,i]=y.useState(!1),[r,o]=y.useState(void 0),c=je(e.providersRevision),u=je(e.credentialRevision),d=je(e.connection.status),[h,f]=y.useState(null),[g,p]=y.useState(null),[x,b]=y.useState(null),[k,w]=y.useState(null),j=y.useCallback(()=>{e.listProviders().then(N=>{f(N),p(null)}).catch(N=>p(N instanceof Error?N.message:String(N)))},[e]);if(y.useEffect(()=>{d.state==="open"&&j()},[j,c,u,d.state]),x!==null&&h!==null){const N=x==="new"?void 0:h.providers.find(C=>C.id===x);return s.jsx("section",{className:"providers-section",children:s.jsx(H8,{client:e,profile:N,preset:x==="new"?r:void 0,taken:h.taken,revision:h.revision,readOnly:!h.writable,onDone:()=>{b(null),o(void 0),j()}},x)})}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:()=>i(!1),children:"返回"})]}),s.jsxs("div",{className:"preset-grid",children:[Gm.map(N=>s.jsxs("button",{className:"preset-option",onClick:()=>{var C;i(!1),(C=document.getElementById(`builtin-${N.id}`))==null||C.scrollIntoView({behavior:"smooth"})},children:[s.jsx("span",{className:"mode-title",children:N.name}),s.jsx("span",{className:"mode-subtitle",children:N.note})]},N.id)),W8.map(N=>s.jsxs("button",{className:"preset-option",disabled:h===null||!h.writable,onClick:()=>{o(N),i(!1),b("new")},children:[s.jsx("span",{className:"mode-title",children:N.name}),s.jsx("span",{className:"mode-subtitle",children:N.note})]},N.key))]})]});const E=new Set((h==null?void 0:h.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:()=>i(!0),disabled:h===null,children:"+ 添加模型服务"})]}),s.jsx("p",{className:"muted",children:"每个服务填一次 Key,它的模型就会出现在输入框旁的模型选择器里。Claude、ChatGPT、Gemini、国内各家和本机的 Ollama 都可以接;需要看截图的功能请选能看图的模型。Key 保存在本机 dsh 的凭据文件里,界面不会再显示。"}),Gm.map(N=>s.jsx(K8,{client:e,provider:N,catalog:t},N.id)),t==null?void 0:t.groups.filter(N=>!E.has(N.id)&&!Gm.some(C=>C.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(C=>s.jsx("span",{className:"chip",children:C.name},C.id))})]},N.id)),g!==null&&s.jsx("div",{className:"banner error",children:g}),k!==null&&s.jsx("div",{className:"success small",children:k}),h!==null&&!h.writable&&s.jsx("div",{className:"notice info left",children:"当前 profile 是只读的,无法在界面中修改提供方。"}),h===null&&g===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),h==null?void 0:h.providers.map(N=>s.jsx(q8,{client:e,profile:N,revision:h.revision,readOnly:!h.writable,onEdit:()=>b(N.id),onRemoved:C=>{w(C?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),j()}},N.id))]})}function q8({client:e,profile:t,revision:n,readOnly:i,onEdit:r,onRemoved:o}){const[c,u]=y.useState(!1),[d,h]=y.useState(null),f=hg(t.api),g=async()=>{var x,b;const p=t.apiKeyRef!==void 0&&((x=t.credential)==null?void 0:x.source)==="file"?`
237
+
238
+ 同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(await Ps({title:`删除「${t.displayName}」?`,message:`使用它的会话需要换一个模型。${p}`,confirmLabel:"删除",danger:!0})){u(!0),h(null);try{const{defaultReset:k}=await e.removeProvider({id:t.id,removeKey:((b=t.credential)==null?void 0:b.source)==="file",expectedRevision:n});o(k)}catch(k){h(k instanceof Error?k.message:String(k))}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:f===void 0?t.api??"内置目录":`${f.title} · ${f.subtitle}`}),s.jsx(G8,{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(p=>s.jsxs("span",{className:"chip",title:p.name??p.id,children:[p.id,Sa(p.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",Sa(p.contextWindow)]})]},p.id))}):s.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),d!==null&&s.jsx("div",{className:"error small",children:d}),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 g(),disabled:c||i,children:"删除"}),t.declared&&s.jsx("button",{onClick:r,disabled:c||i,children:"编辑"})]})]})}function G8({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 K8({client:e,provider:t,catalog:n}){const{items:i}=Wj(e,[t.keyRef]),r=(i==null?void 0:i[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:"内置"}),r===null?null:r.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(J8,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:r,bare:!0})]})}const lc="",ec=e=>e==null?lc:`${e.provider}/${e.model}`;function jN(e){if(e===lc)return null;const[t,...n]=e.split("/");return{provider:t,model:n.join("/")}}function Zl(e,t){var n,i;return((i=(n=e.groups.find(r=>r.id===t.provider))==null?void 0:n.models.find(r=>r.id===t.model))==null?void 0:i.name)??t.model}function id(e,t){return[...t==null||e.groups.some(i=>i.id===t.provider&&i.models.some(r=>r.id===t.model))?[]:[{value:ec(t),label:`${t.provider} / ${t.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...e.groups.flatMap(i=>i.models.map(r=>({value:`${i.id}/${r.id}`,label:r.name,group:i.name})))]}function Y8({client:e}){const{catalog:t,error:n}=el(e),i=je(e.capabilities),r=je(e.connection.status),o=Ls(e),[c,u]=y.useState(null),[d,h]=y.useState(!1),[f,g]=y.useState(null),p=i.has("agent-models");y.useEffect(()=>{if(r.state!=="open"||!p)return;let E=!0;return e.connection.call("models/agentModels",{}).then(N=>{E&&u(N)}).catch(()=>{}),()=>{E=!1}},[e,r.state,p]),y.useEffect(()=>e.connection.on("models/agentModelsChanged",u),[e]);const x=async E=>{h(!0),g(null);try{g(await E())}catch(N){g({tone:"warn",text:N instanceof Error?N.message:String(N)})}finally{h(!1)}},b=E=>void x(async()=>{const N=jN(E);return await e.connection.call("models/setDefault",N),{tone:"ok",text:`默认模型换成了 ${Zl(t,N)}:助手和跟随默认的 agent 从下一句起用它。`}}),k=(E,N,C)=>void x(async()=>{const L=jN(C),{warning:$}=await e.connection.call("models/setAgentModel",{...E===void 0?{}:{agentId:E.id},...N?{sub:!0}:{},model:L});if(u(B=>B===null?B:X8(B,E==null?void 0:E.id,N,L)),$!==void 0)return{tone:"warn",text:$};const O=L===null?void 0:Zl(t,L);if(!N)return{tone:"ok",text:O===void 0?`「${E.name}」改回跟随默认模型,从下一句起生效。`:`「${E.name}」的对话从下一句起用 ${O}。`};const W=E===void 0?"没单独设的子 agent":`「${E.name}」新开的子 agent`;return{tone:"ok",text:O===void 0?`${W}改回跟随,正在干活的不受影响。`:`${W}用 ${O},正在干活的不受影响。`}}),w=[nn,...o.map(Ga)],j=t!==null&&(c!==null||!p);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:"「对话」是 agent 自己做判断、和你说话用的模型;「子 agent」是它派去干具体活(运行命令、截图点击、装脚本)用的模型,活多、看图多,可以选便宜些、能看图的。 没单独设的会跟着上一级:agent 跟默认模型,子 agent 跟「所有子 agent」,那里也没设就和开它的 agent 用同一个。先在下面的模型服务里填好 Key,这里才能选它的模型。"})]})}),n!==null&&s.jsx("div",{className:"error small",children:n}),!j&&n===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),j&&s.jsxs("div",{className:"agent-models",role:"table","aria-label":"每个 agent 用的模型",children:[s.jsxs("div",{className:"agent-models-row head",role:"row",children:[s.jsx("span",{role:"columnheader",children:"agent"}),s.jsx("span",{role:"columnheader",children:"对话"}),p&&s.jsx("span",{role:"columnheader",children:"子 agent"})]}),p&&s.jsxs("div",{className:"agent-models-row all",role:"row",children:[s.jsxs("div",{className:"agent-models-name",role:"cell",children:[s.jsx("strong",{children:"所有子 agent"}),s.jsx("span",{className:"muted small",children:"下面没单独设子 agent 模型的,都用这个"})]}),s.jsx("div",{className:"agent-models-cell empty",role:"cell"}),s.jsxs("div",{className:"agent-models-cell",role:"cell",children:[s.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),s.jsx(Dt,{"aria-label":"所有子 agent 的模型",value:ec(c.subAgents),disabled:d,onChange:E=>k(void 0,!0,E),options:[{value:lc,label:"和开它的 agent 一样"},...id(t,c.subAgents)]})]})]}),w.map(E=>{const N=E.id===nn.id,C=N?t.default:(c==null?void 0:c.agents[E.id])??null,L=C??t.default,$=(c==null?void 0:c.subAgentsOf[E.id])??null,O=(c==null?void 0:c.subAgents)==null?`和${E.name}一样(${Zl(t,L)})`:`跟随上面(${Zl(t,c.subAgents)})`;return s.jsxs("div",{className:"agent-models-row",role:"row",children:[s.jsxs("div",{className:"agent-models-name",role:"cell",children:[s.jsx("strong",{children:E.name}),s.jsx("span",{className:"muted small",children:N?"它用的就是默认模型":E.description})]}),s.jsxs("div",{className:"agent-models-cell",role:"cell",children:[s.jsx("span",{className:"agent-models-cell-label",children:"对话"}),N?s.jsx(Dt,{"aria-label":"默认模型(助手)",value:ec(C),disabled:d||!i.has("model-default"),onChange:b,options:id(t,C)}):s.jsx(Dt,{"aria-label":`${E.name}的模型`,value:ec(C),disabled:d||!p,onChange:W=>k(E,!1,W),options:[{value:lc,label:`跟随默认(${Zl(t,t.default)})`},...id(t,C)]})]}),p&&s.jsxs("div",{className:"agent-models-cell",role:"cell",children:[s.jsx("span",{className:"agent-models-cell-label",children:"子 agent"}),s.jsx(Dt,{"aria-label":`${E.name}的子 agent 的模型`,value:ec($),disabled:d,onChange:W=>k(E,!0,W),options:[{value:lc,label:O},...id(t,$)]})]})]},E.id)})]}),t==null?void 0:t.failures.map(E=>s.jsxs("div",{className:"error small",children:[E.name,":",E.message]},E.id)),f!==null&&s.jsx("div",{className:f.tone==="ok"?"muted small":"error small",children:f.text})]})}function X8(e,t,n,i){const r=(o,c)=>{const{[c]:u,...d}=o;return i===null?d:{...d,[c]:i}};return n?t===void 0?{...e,subAgents:i}:{...e,subAgentsOf:r(e.subAgentsOf,t)}:{...e,agents:r(e.agents,t)}}const qE={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function GE(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 Q8({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 用哪个模型、接哪些模型服务都在这里。改了立即生效:agent 的对话从下一句起换过去,子 agent 在新开时用上。只想换一个对话的模型,在它输入框旁边换就行,不会改这里的设置。"}),s.jsx(Y8,{client:e}),t.has("providers")&&s.jsx(V8,{client:e})]})}function J8({client:e,refName:t,title:n,description:i,helpUrl:r,info:o,placeholder:c,bare:u=!1}){const[d,h]=y.useState(""),[f,g]=y.useState(!1),[p,x]=y.useState(!1),[b,k]=y.useState(null),w=GE(d),j=o!==null&&!o.writable,E=async()=>{if(!(d.trim()===""||w!==null)){x(!0),k(null);try{await e.setCredential(t,d.trim()),h(""),g(!1),k({tone:"ok",text:"已保存,立即生效。"})}catch(L){k({tone:"error",text:L instanceof Error?L.message:String(L)})}finally{x(!1)}}},N=async()=>{if(await Ps({title:`删除已保存的 ${n}?`,message:"删除后需要重新填写才能使用对应模型。",confirmLabel:"删除",danger:!0})){x(!0),k(null);try{await e.unsetCredential(t),k({tone:"ok",text:"已删除。"})}catch(L){k({tone:"error",text:L instanceof Error?L.message:String(L)})}finally{x(!1)}}},C=u?"div":"section";return s.jsxs(C,{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:[i," ",s.jsx("code",{children:t})]})]}),s.jsx(eZ,{info:o})]}),j?s.jsxs("div",{className:"notice info left",children:["当前 Key 来自",qE[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",s.jsx("code",{children:t})," 再重新启动。"]}):s.jsxs("form",{className:"key-form",onSubmit:L=>{L.preventDefault(),E()},children:[s.jsxs("div",{className:"key-input",children:[s.jsx("input",{type:f?"text":"password",value:d,onChange:L=>{h(L.target.value),k(null)},placeholder:(o==null?void 0:o.configured)===!0?"已配置。输入新的 Key 可替换":c??"粘贴你的 API Key(sk-…)",autoComplete:"off",spellCheck:!1,"aria-label":n,disabled:p}),s.jsx("button",{type:"button",className:"ghost",onClick:()=>g(L=>!L),disabled:d==="",children:f?"隐藏":"显示"})]}),w!==null&&s.jsx("div",{className:"error small",children:w}),s.jsxs("div",{className:"key-actions",children:[r!==void 0&&s.jsx("a",{href:r,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:p,children:"删除"}),s.jsx("button",{type:"submit",className:"primary",disabled:p||d.trim()===""||w!==null,children:p?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),b!==null&&s.jsx("div",{className:b.tone==="ok"?"success small":"error small",children:b.text})]})}function eZ({info:e}){return e===null?s.jsx("span",{className:"badge",children:"读取中…"}):e.configured?s.jsxs("span",{className:"badge ok",children:["已配置 · ",qE[e.source??""]??e.source??"未知来源"]}):s.jsx("span",{className:"badge warn",children:"未配置"})}const tZ=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold;function nZ({client:e}){var x;const t=je(e.connection.status),[n,i]=y.useState(null),[r,o]=y.useState(null),[c,u]=y.useState(!1),[d,h]=y.useState(null),f=(x=ni())==null?void 0:x.restartService;y.useEffect(()=>{if(d===null||n===null)return;if(d===n.settings.threshold){h(null);return}const b=setTimeout(()=>void g({...n.settings,threshold:d}).then(()=>h(null)),400);return()=>clearTimeout(b)},[d,n]),y.useEffect(()=>{if(t.state!=="open")return;let b=!0;return e.connection.call("compaction/get",{}).then(k=>{b&&i(k)}).catch(k=>{b&&o(Ie(k))}),()=>{b=!1}},[e,t.state]);const g=async b=>{if(!(!b.auto&&(n==null?void 0:n.settings.auto)===!0&&!await Ps({title:"关掉自动压缩?",message:"关掉后,对话超过模型的上下文长度时会直接出错,要手动压缩或开新对话才能继续。",confirmLabel:"关掉",danger:!0}))){u(!0),o(null);try{i(await e.connection.call("compaction/set",{settings:b}))}catch(k){o(Ie(k))}finally{u(!1)}}},p=async()=>{f===void 0||!await Ps({title:"现在重启 agent 服务?",message:"正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。",confirmLabel:"重启",danger:!0,icon:"refresh"})||await f()};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:b=>void g({...n.settings,auto:b.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:[d??n.settings.threshold,"%"]}),(d??n.settings.threshold)===GR?"(默认)":""]}),s.jsx("input",{type:"range",min:$j,max:Mj,step:5,value:d??n.settings.threshold,disabled:!n.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:b=>h(Number(b.target.value))}),s.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。100% 是到上下文快满时才压缩(会留出回复的空间)。"}),(d??n.settings.threshold)<KR&&n.settings.auto&&s.jsxs("span",{className:"notice warn-box left small compaction-warn",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:"这么低时,光是系统提示和工具说明就可能接近这个用量,几乎每一步都会压缩一次,每次都要调用模型写摘要。想让上下文保持很短,用下面的「低上下文模式」更合适。"})]})]}),!tZ(n.settings,n.applied)&&s.jsxs("div",{className:"notice left",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",n.applied.auto?`自动压缩,${n.applied.threshold}%`:"不自动压缩",")。",f===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),f!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void p(),children:"重启 agent 服务"})]}),r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:r})]})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.lowContext,disabled:c,onChange:b=>void g({...n.settings,lowContext:b.target.checked})}),"低上下文模式"]}),s.jsx("p",{className:"muted small",children:"只保留最近 12 小时的对话,更早的在任务做完后压缩成摘要;对话安静超过 4 小时后再来新消息,会先把之前的内容压成摘要再开始,agent 从摘要起步、需要时再查原文。任务做完时,过长的工具输出(日志、运行记录)也会截成头尾。"}),s.jsxs("label",{className:"check-label compaction-archive",children:[s.jsx("input",{type:"checkbox",checked:n.settings.archiveDays!==null,disabled:c||!n.settings.lowContext,onChange:b=>void g({...n.settings,archiveDays:b.target.checked?7:null})}),"摘要也归档"]}),n.settings.archiveDays!==null&&s.jsxs("label",{className:"field compaction-archive-days",children:[s.jsx("span",{className:"field-title",children:"对话过了多久,它的摘要就移出上下文"}),s.jsx(Dt,{"aria-label":"多久以后归档",value:String(n.settings.archiveDays),disabled:c||!n.settings.lowContext,onChange:b=>void g({...n.settings,archiveDays:Number(b)}),options:[...new Set([...QR,n.settings.archiveDays])].sort((b,k)=>b-k).map(b=>({value:String(b),label:`${b} 天`}))})]}),s.jsx("p",{className:"muted small",children:n.settings.lowContext?"打开后,每一段较早的对话单独写一份摘要(攒到大约一天写一次,不会把摘要再压成摘要);对话过了上面的天数,它的摘要也移出上下文,只留一行说明。做过的事在「记忆」的日记里,agent 需要细节时会去查归档的摘要和原话。上下文最短,但 agent 要靠查才想得起来以前的事。":"要先打开低上下文模式。"})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.ptcSubagents,disabled:c,onChange:b=>void g({...n.settings,ptcSubagents:b.target.checked})}),"子 agent 用代码调用工具"]}),s.jsx("p",{className:"muted small",children:"子 agent 写一小段程序来调用工具:等脚本跑完、翻日志、查运行记录都在程序里做,只把结果交回对话,不用每一步都把整段日志重新发给模型,用量少很多。关掉后子 agent 一次调用一个工具。各个 agent 自己的对话不受影响。不是「完全访问」时程序在沙箱里运行,如果子 agent 说代码执行环境起不来(Windows 文件权限挡住了),先关掉这个开关。"}),n.settings.ptcSubagents!==n.applied.ptcSubagents&&s.jsxs("div",{className:"notice left",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:["改动要重启 agent 服务才生效(现在还是:",n.applied.ptcSubagents?"用代码调用工具":"一次调用一个工具",")。",f===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),f!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void p(),children:"重启 agent 服务"})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"手动压缩"}),s.jsxs("p",{className:"muted small",children:["在对话框里输入 ",s.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),n===null&&r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:r})]})]})}const fg=[{kind:"core",title:"核心",hint:`你最在意的要求和偏好:每个 agent 每次都会带上,不会被挤掉;所有核心一共最多 ${Eg} 字,总是共享`},{kind:"profile",title:"资料",hint:"长期有效的事实和偏好"},{kind:"journal",title:"日记",hint:"某一天做过或决定的事"}],sZ={core:"核心",profile:"资料",journal:"日记"},Br="",iZ=["周日","周一","周二","周三","周四","周五","周六"];function rZ(e){const t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function aZ(e){const[t,n,i]=e.split("-").map(Number),r=new Date(t,n-1,i),o=new Date,c=Math.round((new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime()-r.getTime())/864e5),u=`${t===o.getFullYear()?"":`${t}年`}${n}月${i}日 ${iZ[r.getDay()]}`;return c===0?`今天 · ${u}`:c===1?`昨天 · ${u}`:u}const cc=e=>e.kind==="journal"?e.createdAt:e.updatedAt,KE=(e,t)=>n=>{n.key==="Enter"&&(n.ctrlKey||n.metaKey)?(n.preventDefault(),e()):n.key==="Escape"&&(n.preventDefault(),t())};function oZ({client:e}){var P,V;const t=je(e.connection.status),n=Ls(e),[i,r]=y.useState(null),[o,c]=y.useState(0),[u,d]=y.useState(ba),[h,f]=y.useState(Br),[g,p]=y.useState(""),[x,b]=y.useState(!1),[k,w]=y.useState(null);y.useEffect(()=>e.connection.on("memory/changed",()=>c(z=>z+1)),[e]),y.useEffect(()=>{if(t.state!=="open")return;let z=!0;return e.connection.call("memory/list",{}).then(H=>{z&&(r(H.items),w(null))}).catch(H=>{z&&w(Ie(H))}),()=>{z=!1}},[e,t.state,o]);const j=y.useMemo(()=>[{id:nn.id,name:nn.name},...n.map(z=>({id:z.id,name:z.name}))],[n]),E=z=>{var H;return z===ba?"共享":z==="user"?"你":z==="auto"?"自动整理":((H=j.find(G=>G.id===z))==null?void 0:H.name)??z},N=g.trim().toLowerCase().split(/\s+/).filter(z=>z!==""),C=z=>(i??[]).filter(H=>H.scope===z).length,L=(i??[]).filter(z=>z.scope===u),$=(i??[]).filter(z=>z.kind==="core").reduce((z,H)=>z+H.text.length,0),O=L.filter(z=>(h===Br||z.kind===h)&&N.every(H=>z.text.toLowerCase().includes(H))).sort((z,H)=>cc(H).localeCompare(cc(z))),W=O.filter(z=>z.kind==="core"),B=[];for(const z of O.filter(H=>H.kind!=="core")){const H=rZ(cc(z));((P=B.at(-1))==null?void 0:P.day)===H?B.at(-1).entries.push(z):B.push({day:H,entries:[z]})}const U=[{id:ba,name:"共享"},...j],D=((V=U.find(z=>z.id===u))==null?void 0:V.name)??u,F=u===ba,A=N.length>0||h!==Br,T=async z=>{w(null);try{return await z(),c(H=>H+1),!0}catch(H){return w(Ie(H)),!1}},M=async(z,H)=>{const G=z==="core"?ba:u;return await T(()=>e.connection.call("memory/add",{kind:z,scope:G,text:H}))?(G!==u&&d(G),h!==Br&&h!==z&&f(Br),p(""),b(!1),!0):!1};return s.jsxs("div",{className:"settings-page memory-page",children:[s.jsx("h2",{children:"记忆"}),s.jsx("p",{children:"agent 在对话里记下的关于你的事,新开的对话也记得。「共享」的每个 agent 都看得到,其余的只有那个 agent 自己看得到。「核心」是你最在意的要求和偏好,每个 agent 每次都会带上,不会因为记得多了或时间久了被挤掉;只有你自己(或你明确让 agent 记)才会写进去。你也可以在这里记一条、改掉或删掉。密码、验证码、密钥不会被记下。怎么一步步做一件事是另一回事,存在「技能」里。"}),i!==null&&s.jsxs(s.Fragment,{children:[s.jsx(lZ,{client:e}),s.jsxs("section",{className:"card memory-browse",children:[s.jsxs("div",{className:"card-head memory-head",children:[s.jsxs("div",{className:"memory-whose",children:[s.jsx(Dt,{className:"scope-select","aria-label":"谁的记忆",value:u,onChange:d,options:U.map(z=>({value:z.id,label:z.id===ba?"共享的记忆":`「${z.name}」的记忆`,hint:C(z.id)===0?"还没有":`${C(z.id)} 条`,...z.id===ba?{}:{group:"一个 agent 自己的"}}))}),s.jsx("span",{className:"muted small",children:F?"每个 agent 都看得到":`只有「${D}」自己看得到`})]}),!x&&s.jsxs("button",{className:"small-button",onClick:()=>b(!0),children:[s.jsx(Q,{name:"plus"}),"记一条"]})]}),x&&s.jsx(cZ,{to:F?"共享":`「${D}」`,coreUsed:$,onAdd:M,onClose:()=>b(!1)}),k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:k})]}),L.length>0&&s.jsxs("div",{className:"memory-filters",children:[s.jsx("div",{className:"memory-kinds",role:"radiogroup","aria-label":"种类",children:[{kind:Br,title:"全部"},...fg].map(z=>s.jsxs("button",{role:"radio","aria-checked":h===z.kind,className:`filter-chip ${h===z.kind?"active":""}`,onClick:()=>f(z.kind),children:[z.title,s.jsx("span",{className:"memory-kind-count",children:z.kind===Br?L.length:L.filter(H=>H.kind===z.kind).length})]},z.kind))}),s.jsxs("label",{className:"memory-search",children:[s.jsx(Q,{name:"search"}),s.jsx("input",{className:"text-input plain",type:"search",placeholder:"搜索(空格分开几个词)",value:g,onChange:z=>p(z.target.value),"aria-label":"搜索记忆"})]})]}),W.length>0&&s.jsxs("div",{className:"memory-day memory-core",children:[s.jsx("h4",{className:"memory-day-title",children:s.jsxs("span",{children:["核心 · 每次都带上(",$," / ",Eg," 字)"]})}),s.jsx("ul",{className:"memory-list",children:W.map(z=>s.jsx(wN,{entry:z,nameOf:E,onSave:H=>T(()=>e.connection.call("memory/update",{id:z.id,text:H})),onForget:()=>void Ps({title:"删掉这条核心记忆?",message:"之后 agent 就不会每次都带上它了,不能撤销。",quote:z.text,confirmLabel:"删掉",danger:!0}).then(H=>{H&&T(()=>e.connection.call("memory/remove",{id:z.id}))})},z.id))})]}),B.length===0&&W.length===0?s.jsxs("div",{className:"memory-empty",children:[s.jsx("p",{className:"muted",children:A?"没有找到。":`「${D}」还没有记忆。`}),A?s.jsx("button",{className:"link-button small",onClick:()=>{f(Br),p("")},children:"清除筛选"}):s.jsx("p",{className:"muted small",children:"agent 干活时会自己记下,你也可以点「记一条」写给它。"})]}):B.map(z=>s.jsxs("div",{className:"memory-day",children:[s.jsx("h4",{className:"memory-day-title",children:s.jsx("span",{children:aZ(z.day)})}),s.jsx("ul",{className:"memory-list",children:z.entries.map(H=>s.jsx(wN,{entry:H,nameOf:E,onSave:G=>T(()=>e.connection.call("memory/update",{id:H.id,text:G})),onForget:()=>void Ps({title:"忘掉这条记忆?",message:"之后 agent 就不记得了,不能撤销。",quote:H.text,confirmLabel:"忘掉",danger:!0}).then(G=>{G&&T(()=>e.connection.call("memory/remove",{id:H.id}))})},H.id))})]},z.day))]})]}),i===null&&k!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:k})]})]})}function lZ({client:e}){const t=je(e.connection.status),{catalog:n}=el(e),[i,r]=y.useState(null),[o,c]=y.useState(!1),[u,d]=y.useState(null);y.useEffect(()=>{if(t.state!=="open")return;let b=!0;return e.connection.call("memory/auto/get",{}).then(k=>{b&&(r(k),d(null))}).catch(k=>{b&&d(Ie(k))}),()=>{b=!1}},[e,t.state]);const h=async b=>{c(!0),d(null);try{const k=await e.connection.call("memory/auto/set",{auto:b.auto,model:b.model});r({...k,...(i==null?void 0:i.forced)===!0?{forced:!0}:{}})}catch(k){d(Ie(k))}finally{c(!1)}};if(i===null)return u===null?null:s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:u})]});const f=i.auto||i.forced===!0,g=i.model===null?"":`${i.model.provider}/${i.model.model}`,p=g===""||((n==null?void 0:n.groups.some(b=>b.models.some(k=>`${b.id}/${k.id}`===g)))??!1),x=b=>{const[k,...w]=b.split("/");h({...i,model:b===""?null:{provider:k,model:w.join("/")}})};return s.jsxs("section",{className:"card memory-auto",children:[s.jsxs("div",{className:"memory-auto-row",children:[s.jsxs("label",{className:"check-label memory-auto-check",children:[s.jsx("input",{type:"checkbox",checked:f,disabled:o||i.forced===!0,onChange:b=>void h({...i,auto:b.target.checked})}),s.jsxs("span",{className:"memory-auto-text",children:[s.jsx("strong",{children:"自动整理"}),s.jsxs("span",{className:"muted small",children:["对话停下几分钟后,自动把没记下的偏好和做过的事整理进记忆",i.forced===!0?"。低上下文模式开着,自动整理会一直开着。":""]})]})]}),f&&s.jsxs("label",{className:"field memory-auto-model",children:[s.jsx("span",{className:"field-title",children:"整理用的模型"}),n===null?s.jsx("span",{className:"muted small",children:"读取中…"}):s.jsx(Dt,{"aria-label":"整理用的模型",value:g,disabled:o,onChange:x,options:[{value:"",label:"和默认模型一样"},...p?[]:[{value:g,label:`${i.model.provider} / ${i.model.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...n.groups.flatMap(b=>b.models.map(k=>({value:`${b.id}/${k.id}`,label:k.name,group:b.name})))]})]})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:u})]})]})}function cZ({to:e,coreUsed:t,onAdd:n,onClose:i}){var b;const[r,o]=y.useState(""),[c,u]=y.useState("profile"),[d,h]=y.useState(!1),f=Eg-t,g=c==="core"&&r.trim().length>f,p=!d&&r.trim()!==""&&!g,x=async()=>{p&&(h(!0),await n(c,r.trim()),h(!1))};return s.jsxs("div",{className:"memory-compose",children:[s.jsx("textarea",{className:"text-input plain",rows:3,maxLength:Cg,autoFocus:!0,"aria-label":"要记下的事",placeholder:"一句话写一件事,例如:日报只要告诉我有没有失败的;明日方舟只玩 B 服。",value:r,onChange:k=>o(k.target.value),onKeyDown:KE(()=>void x(),i)}),s.jsxs("div",{className:"memory-compose-foot",children:[s.jsx("div",{className:"segmented-control memory-kind",role:"radiogroup","aria-label":"种类",children:fg.map(k=>s.jsx("button",{role:"radio","aria-checked":c===k.kind,className:c===k.kind?"active":"",onClick:()=>u(k.kind),children:k.title},k.kind))}),s.jsxs("span",{className:`small memory-compose-hint ${g?"warn-text":"muted"}`,children:[(b=fg.find(k=>k.kind===c))==null?void 0:b.hint,c==="core"&&(g?`。核心只剩 ${Math.max(0,f)} 字了:先合并或删掉几条,或记成资料。`:`(还能写 ${f} 字)`)]}),s.jsxs("span",{className:"memory-compose-actions",children:[s.jsx("button",{disabled:d,onClick:i,children:"取消"}),s.jsx("button",{className:"primary",disabled:!p,onClick:()=>void x(),children:d?"记下中…":c==="core"?"记成核心":`记到${e}`})]})]})]})}function wN({entry:e,nameOf:t,onSave:n,onForget:i}){const[r,o]=y.useState(null),[c,u]=y.useState(!1),d=!c&&r!==null&&r.trim()!=="",h=async()=>{d&&(u(!0),await n(r.trim())&&o(null),u(!1))};return s.jsxs("li",{className:`memory-row ${r===null?"":"editing"}`,children:[s.jsx("time",{className:"memory-time",dateTime:cc(e),title:e.kind==="journal"?"记下的时间":"最后更新的时间",children:new Date(cc(e)).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}),s.jsxs("div",{className:"memory-body",children:[r===null?s.jsx("div",{className:"memory-text",children:e.text}):s.jsx("textarea",{className:"text-input plain",rows:3,maxLength:Cg,value:r,onChange:f=>o(f.target.value),onKeyDown:KE(()=>void h(),()=>o(null)),"aria-label":"修改记忆",autoFocus:!0}),s.jsxs("div",{className:"memory-meta",children:[s.jsx("span",{className:`memory-kind-tag ${e.kind}`,children:sZ[e.kind]}),s.jsx("span",{className:"muted small",children:e.by==="user"?"你记的":e.by==="auto"?"自动整理出来的":`${t(e.by)}记的`}),r!==null&&s.jsxs("span",{className:"memory-edit-actions",children:[s.jsx("button",{className:"small-button",disabled:c,onClick:()=>o(null),children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:!d,onClick:()=>void h(),children:c?"保存中…":"保存"})]})]})]}),r===null&&s.jsxs("span",{className:"memory-actions",children:[s.jsx("button",{className:"link-button small",onClick:()=>o(e.text),children:"修改"}),s.jsx("button",{className:"link-button small memory-forget",onClick:i,children:"忘掉"})]})]})}const SN=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],uZ=[{value:"auto",label:"自动更新"},{value:"ask",label:"先问我"},{value:"off",label:"不自动更新"}],dZ=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function hZ({client:e,state:t,onState:n}){const i=je(e.capabilities),[r,o]=y.useState(null),[c,u]=y.useState(null),[d,h]=y.useState(null),f=i.has("monitor"),g=i.has("scripts"),[p,x]=y.useState(null);y.useEffect(()=>{if(!g)return;let j=!0;return e.connection.call("scripts/settings",{}).then(E=>{j&&x(E.autoUpdate)}).catch(()=>{}),()=>{j=!1}},[e,g]),y.useEffect(()=>{if(!f)return;let j=!0;return e.connection.call("monitor/settings",{}).then(E=>{j&&h(E)}).catch(()=>{}),()=>{j=!1}},[e,f]);const b=async(j,E)=>{o(j),u(null);try{n(await e.connection.call("permissions/area/set",{area:j,policy:E}))}catch(N){u(Ie(N))}finally{o(null)}},k=async j=>{o("autoUpdate"),u(null);try{x((await e.connection.call("scripts/settings/set",{autoUpdate:j})).autoUpdate)}catch(E){u(Ie(E))}finally{o(null)}},w=async j=>{o("intervene"),u(null);try{h(await e.connection.call("monitor/settings/set",{intervene:j}))}catch(E){u(Ie(E))}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 能自己做的事,一项一项决定:",SN.map(j=>`「${j.label}」${j.hint}`).join(";"),"。"]})]})}),s.jsxs("div",{className:"area-list",children:[f&&d!==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:dZ.map(j=>s.jsx("button",{role:"radio","aria-checked":d.intervene===j.value,className:d.intervene===j.value?"active":"",disabled:r!==null,onClick:()=>void w(j.value),children:j.label},j.value))})]}),g&&p!==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:uZ.map(j=>s.jsx("button",{role:"radio","aria-checked":p===j.value,className:p===j.value?"active":"",disabled:r!==null,onClick:()=>void k(j.value),children:j.label},j.value))})]}),IR.map(j=>{const E=t.areas[j.id]??"default";return s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:j.title}),s.jsx("span",{className:"muted small",children:j.description})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":j.title,children:SN.map(N=>s.jsx("button",{role:"radio","aria-checked":E===N.policy,title:N.hint,className:`${E===N.policy?"active":""} ${N.policy}`,disabled:r!==null,onClick:()=>void b(j.id,N.policy),children:N.label},N.policy))})]},j.id)})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:c})]})]})}const fZ=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function mZ({client:e}){const t=je(e.connection.status),n=un(3e4),[i,r]=y.useState(null),[o,c]=y.useState(!1),[u,d]=y.useState(null);y.useEffect(()=>e.connection.on("permissions/changed",f=>r(f)),[e]),y.useEffect(()=>{if(t.state!=="open")return;let f=!0;return e.connection.call("permissions/get",{}).then(g=>{f&&r(g)}).catch(g=>{f&&d(Ie(g))}),()=>{f=!1}},[e,t.state]);const h=async f=>{if((i==null?void 0:i.mode)!==f&&!(f==="full"&&!await Ps({title:"打开「完全访问」?",icon:"shield",confirmLabel:"打开",danger:!0,message:`打开后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。
239
+
240
+ 只在你信任当前模型、并且需要它自己完成整件事时打开。`}))){c(!0),d(null);try{r(await e.connection.call("permissions/set",{mode:f}))}catch(g){d(Ie(g))}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:fZ.map(f=>s.jsxs("button",{role:"radio","aria-checked":(i==null?void 0:i.mode)===f.mode,disabled:o||i===null,className:`permission-option ${f.mode} ${(i==null?void 0:i.mode)===f.mode?"active":""}`,onClick:()=>void h(f.mode),children:[s.jsx("span",{className:"permission-dot","aria-hidden":"true"}),s.jsxs("span",{className:"permission-text",children:[s.jsx("strong",{children:f.title}),s.jsx("span",{children:f.text})]})]},f.mode))}),(i==null?void 0:i.mode)==="full"&&s.jsxs("div",{className:"notice warn-note left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",i.since===void 0?"":`(${pZ(i.since,n)})`,"。agent 不会再请求确认;它仍然不会替你输入密码、验证码或付款。agent 之间可以互相交事情,这时也不会有人拦:比如读网页时读到的内容,可能经别的 agent 变成运行或安装。"]})]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:u})]})]}),i!==null&&s.jsx(hZ,{client:e,state:i,onState:r}),i!==null&&i.recent.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"没问你就允许了的操作"}),s.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",i.recent.length," 条。"]}),s.jsx("ul",{className:"version-list",children:i.recent.map((f,g)=>s.jsxs("li",{children:[s.jsx("span",{className:"badge",children:f.toolName}),s.jsx("span",{className:"permission-reason",children:f.reason??"(没有说明)"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:yt(f.at,n)})]},g))})]})]})}function pZ(e,t){const n=yt(e,t);return n==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(n)?`${n}前打开`:`${n} 打开`}const mg=[{style:"default",title:"默认",note:"模型自己的说话方式",sample:""},{style:"concise",title:"简洁干练",note:"先说结论,少寒暄",sample:"日常跑完了,3 个成功 1 个失败:MAA 刷理智没体力了。"},{style:"patient",title:"耐心细致",note:"每一步讲清楚为什么",sample:"我先帮你看了 MAA 的日志,失败是因为理智不够——这不是脚本坏了,等理智恢复再跑就行。"},{style:"lively",title:"活泼可爱",note:"轻松,带点语气词和表情",sample:"搞定啦~日常都跑完了!就是理智又见底了 (。•́︿•̀。)"},{style:"buddy",title:"游戏搭子",note:"像一起玩的老朋友",sample:"日常清完了,理智又被榨干了哈哈,活动商店还差两样,明天接着肝。"},{style:"butler",title:"稳重管家",note:"礼貌周到,主动汇报",sample:"今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?"}],Km=[{style:"plain",title:"平实",text:"直接说事,不带人设和称呼:它们要读的是内容。推荐。"},{style:"same",title:"和对你一样",text:"人设也带到 agent 之间的往来里,你在「全部」里看到的就是这个语气。"}],Ym="",_N=e=>{var t;return((t=mg.find(n=>n.style===e))==null?void 0:t.title)??e};function EN(e){return e===void 0||e.style===void 0&&e.callUser===void 0&&e.custom===void 0&&e.peerStyle===void 0}const CN=e=>{var t,n,i;return[e.style??"",((t=e.name)==null?void 0:t.trim())??"",((n=e.callUser)==null?void 0:n.trim())??"",((i=e.custom)==null?void 0:i.trim())??"",e.peerStyle??""]};function rd(e){const t=Object.entries(e.agents).map(([n,i])=>[n,CN(i)]).filter(([,n])=>n.some(i=>i!=="")).sort(([n],[i])=>n.localeCompare(i));return JSON.stringify([CN({...e.persona,peerStyle:e.persona.peerStyle??"plain"}),t])}function gZ({client:e}){var G,Z,Y,X,re;const t=je(e.connection.status),n=Ls(e),[i,r]=y.useState(null),[o,c]=y.useState(null),[u,d]=y.useState(Ym),[h,f]=y.useState(!1),[g,p]=y.useState(null),[x,b]=y.useState(!1),k=ee=>{const te={persona:ee.persona,agents:ee.agents};r(te),c(te)};if(y.useEffect(()=>{if(t.state!=="open")return;let ee=!0;return e.connection.call("persona/get",{}).then(te=>{ee&&k(te)}).catch(te=>{ee&&p(Ie(te))}),()=>{ee=!1}},[e,t.state]),o===null||i===null)return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]})]});const w=rd(o)!==rd(i),j=ee=>{c(ee),b(!1)},E=async()=>{f(!0),p(null);try{k(await e.connection.call("persona/set",o)),b(!0)}catch(ee){p(Ie(ee))}finally{f(!1)}},N=[{id:nn.id,name:nn.name},...n.map(ee=>({id:ee.id,name:ee.name}))],C=u===Ym,L=o.persona,$=C?void 0:o.agents[u],O=((G=N.find(ee=>ee.id===u))==null?void 0:G.name)??u,W=ee=>j({...o,persona:{...L,...ee}}),B=ee=>{const te=Object.fromEntries(Object.entries({...$,...ee}).filter(([,ne])=>ne!==void 0&&(typeof ne!="string"||ne.trim()!=="")));j({...o,agents:{...o.agents,[u]:te}})},U=C?W:B,D=C?L:Dy(o,u),F=Fy(D),A=new Set(Fy(C?i.persona:Dy(i,u)).split(`
241
+ `)),T=((Z=mg.find(ee=>ee.style===D.style))==null?void 0:Z.sample)??"",M=C?L.style:$==null?void 0:$.style,P=C?L.peerStyle??"plain":$==null?void 0:$.peerStyle,V=(ee,te)=>C?te:ee===void 0||ee===""?"留空:跟随统一(现在没有设置)":`留空:跟随统一(${ee})`,z=C?rd({persona:L,agents:{}})!==rd({persona:{style:"default"},agents:{}}):!EN($),H=()=>j(C?{...o,persona:{style:"default"}}:{...o,agents:{...o.agents,[u]:($==null?void 0:$.name)===void 0?{}:{name:$.name}}});return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),s.jsx("p",{children:"agent 说话的方式和人设:可以统一设置,也可以给某个 agent 单独设置。软件里的对话、飞书里的回复、流水线里的 agent 步骤都算。只改说话方式:它们能做什么、该做什么、什么要问你,都不变。子 agent 不用设置,它们只把结果交回给开它们的 agent。"}),s.jsxs("section",{className:"card persona-board",children:[s.jsxs("header",{className:"persona-bar",children:[s.jsxs("label",{className:"persona-who",children:[s.jsx("span",{className:"field-title",children:"设置给"}),s.jsx(Dt,{className:"scope-select","aria-label":"设置给谁",value:u,onChange:d,options:[{value:Ym,label:"所有 agent",hint:"统一设置"},...N.map(ee=>{var se;const te=o.agents[ee.id],ne=(se=te==null?void 0:te.name)==null?void 0:se.trim();return{value:ee.id,label:ne?`${ee.name}(${ne})`:ee.name,hint:EN(te)?"跟随统一":"有单独设置",group:"只给一个 agent"}})]})]}),s.jsx("span",{className:`persona-state ${w?"dirty":""}`,role:"status",children:w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"persona-dot"}),"有没保存的改动"]}):x?s.jsxs(s.Fragment,{children:[s.jsx(Q,{name:"check"}),"已保存,下一句回复开始生效"]}):null}),w&&s.jsx("button",{disabled:h,onClick:()=>j(i),children:"撤销"}),s.jsx("button",{className:"primary",disabled:h||!w,onClick:()=>void E(),children:h?"保存中…":"保存"})]}),g!==null&&s.jsxs("div",{className:"notice error left persona-error",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]}),s.jsxs("div",{className:"persona-panes",children:[s.jsxs("div",{className:"persona-form",children:[s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:"风格"}),s.jsxs("div",{className:"persona-tiles",role:"radiogroup","aria-label":"风格",children:[!C&&s.jsx(AN,{wide:!0,title:"跟随统一",note:`现在是「${_N(L.style)}」`,selected:M===void 0,onClick:()=>B({style:void 0})}),mg.map(ee=>s.jsx(AN,{title:ee.title,note:ee.note,selected:M===ee.style,onClick:()=>U({style:ee.style})},ee.style))]})]}),s.jsxs("div",{className:"persona-pair",children:[!C&&s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"它的名字(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:"例如:小助",value:($==null?void 0:$.name)??"",onChange:ee=>B({name:ee.target.value}),title:"它自称时用这个名字;别的 agent 也会知道你这么叫它。"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"怎么称呼你(可选)"}),s.jsx("input",{className:"text-input plain",maxLength:20,placeholder:V(L.callUser,"例如:博士、开拓者、指挥官"),value:(C?L.callUser:$==null?void 0:$.callUser)??"",onChange:ee=>U({callUser:ee.target.value})})]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"其他要求(可选)"}),s.jsx("textarea",{className:"text-input plain persona-custom",rows:4,placeholder:V(L.custom,"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用表情。"),value:(C?L.custom:$==null?void 0:$.custom)??"",onChange:ee=>U({custom:ee.target.value})})]}),s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:"对其他 agent 说话"}),s.jsxs("div",{className:"segmented-control persona-peer",role:"radiogroup","aria-label":"对其他 agent 说话",children:[!C&&s.jsx("button",{role:"radio","aria-checked":P===void 0,className:P===void 0?"active":"",onClick:()=>B({peerStyle:void 0}),children:"跟随统一"}),Km.map(ee=>s.jsx("button",{role:"radio","aria-checked":P===ee.style,className:P===ee.style?"active":"",onClick:()=>U({peerStyle:ee.style}),children:ee.title},ee.style))]}),s.jsx("span",{className:"muted small",children:P===void 0?`和统一设置一样:${(Y=Km.find(ee=>ee.style===(L.peerStyle??"plain")))==null?void 0:Y.title}。`:(X=Km.find(ee=>ee.style===P))==null?void 0:X.text})]}),s.jsxs("div",{className:"persona-foot muted small",children:[s.jsx("span",{children:C?"没有单独设置的 agent 都按这里的来。":"没改的地方跟随「所有 agent」的设置。"}),z&&s.jsx("button",{className:"link-button small",onClick:H,children:C?"恢复默认":"全部改回跟随统一"})]})]}),s.jsx("aside",{className:"persona-preview","aria-label":"预览",children:s.jsxs("div",{className:"persona-preview-in",children:[s.jsxs("div",{className:"persona-preview-head",children:[s.jsx("strong",{children:"预览"}),s.jsx("span",{className:"muted small",children:w?"跟着左边的选择变,保存后生效":"现在生效的设置"})]}),s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:"说出来大概这样"}),T===""?s.jsx("p",{className:"persona-sample none",children:"不加风格,按模型自己的说话方式。"}):s.jsxs("div",{className:"persona-sample",children:[s.jsx("span",{className:"persona-sample-who",children:((re=D.name)==null?void 0:re.trim())||(C?"agent":O)}),s.jsx("p",{children:T})]}),s.jsxs("span",{className:"muted small",children:["只是「",_N(D.style),"」的示例;实际怎么说,模型照下面这段来。"]})]}),s.jsxs("div",{className:"field",children:[s.jsx("span",{className:"field-title",children:C?"加到 agent 提示词里的内容":`加到「${O}」提示词里的内容`}),F===""?s.jsx("p",{className:"persona-prompt empty-prompt",children:"什么都不加。"}):s.jsx("div",{className:"persona-prompt",children:F.split(`
242
+ `).map((ee,te)=>s.jsx("div",{className:A.has(ee)?"":"changed",children:ee},te))})]})]})})]})]})]})}function AN({title:e,note:t,selected:n,wide:i,onClick:r}){return s.jsxs("button",{role:"radio","aria-checked":n,className:`persona-tile ${n?"selected":""} ${i===!0?"wide":""}`,onClick:r,children:[s.jsxs("strong",{children:[e,n&&s.jsx(Q,{name:"check"})]}),s.jsx("span",{className:"muted small",children:t})]})}const xZ={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:Q8}]},vZ={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:mZ}]},yZ={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:gZ}]},bZ={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:nZ}]},kZ={id:"memory",title:"记忆",requires:["memory"],settingsPages:[{id:"memory",title:"记忆",order:2.5,component:oZ}]},NZ={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:P8}]};function jZ({client:e}){const t=je(e.capabilities),n=je(e.connection.server),[i,r]=y.useState(0);y.useEffect(()=>Zj(()=>r(d=>d+1)),[]);const o=y.useMemo(()=>DO(t),[t,i]),c=o.filter(d=>d.missing.length===0),u=o.filter(d=>d.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(d=>s.jsx("span",{className:"chip",children:d},d)),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:d})=>s.jsxs("li",{children:[s.jsx("span",{className:"plugin-name",children:d.title}),s.jsx("span",{className:"muted small",children:d.requires.length===0?"无需后端能力":d.requires.join(" · ")})]},d.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:d,missing:h})=>s.jsxs("li",{children:[s.jsxs("span",{className:"plugin-name",children:[d.title,d.milestone!==void 0&&s.jsx("span",{className:"chip subtle",children:d.milestone})]}),s.jsxs("span",{className:"muted small",children:["缺少:",h.join(" · ")]})]},d.id))})]})]})}const wZ={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:jZ}]};function SZ(e,t,n){const i=new Array(e);return new Proxy(i,{get(r,o,c){if(typeof o=="string"){const u=o.charCodeAt(0);if(u>=48&&u<=57){const d=+o;if(Number.isInteger(d)&&d>=0&&d<e){let h=r[d];if(!h){const f=t[d*2];h=r[d]={index:d,key:n(d),start:f,size:t[d*2+1],end:f+t[d*2+1],lane:0}}return h}}if(o==="length")return e}return Reflect.get(r,o,c)}})}function No(e,t,n){let i=n.initialDeps??[],r,o=!0;function c(){const u=e();return(u.length!==i.length||u.some((h,f)=>i[f]!==h))&&(i=u,r=t(...u),n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(r),o=!1),r}return c.updateDeps=u=>{i=u},c}function IN(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const _Z=(e,t)=>Math.abs(e-t)<1.01,EZ=(e,t,n)=>{let i;return Object.assign(function(...r){e.clearTimeout(i),i=e.setTimeout(()=>t.apply(this,r),n)},{cancel:()=>{e.clearTimeout(i)}})};let Wl;const Xm=()=>{if(Wl!==void 0)return Wl;if(typeof navigator>"u")return Wl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Wl=!0;const e=navigator.maxTouchPoints;return Wl=navigator.platform==="MacIntel"&&e!==void 0&&e>0},TN=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},CZ=e=>e,AZ=e=>{const t=Math.max(e.startIndex-e.overscan,0),i=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(i);for(let o=0;o<i;o++)r[o]=t+o;return r},IZ=(e,t)=>{const n=e.scrollElement;if(!n)return;const i=e.targetWindow;if(!i)return;const r=c=>{const{width:u,height:d}=c;t({width:Math.round(u),height:Math.round(d)})};if(r(TN(n)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(c=>{const u=()=>{const d=c[0];if(d!=null&&d.borderBoxSize){const h=d.borderBoxSize[0];if(h){r({width:h.inlineSize,height:h.blockSize});return}}r(TN(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},Dd={passive:!0},TZ=typeof window>"u"?!0:"onscrollend"in window,$Z=(e,t,n)=>{const i=e.scrollElement;if(!i)return;const r=e.targetWindow;if(!r)return;const o=e.options.useScrollendEvent&&TZ;let c=0;const u=o?null:EZ(r,()=>t(c,!1),e.options.isScrollingResetDelay),d=g=>()=>{c=n(i),u==null||u(),t(c,g)},h=d(!0),f=d(!1);return i.addEventListener("scroll",h,Dd),o&&i.addEventListener("scrollend",f,Dd),()=>{i.removeEventListener("scroll",h),o&&i.removeEventListener("scrollend",f),u==null||u.cancel()}},MZ=(e,t)=>$Z(e,t,n=>{const{horizontal:i,isRtl:r}=e.options;return i?n.scrollLeft*(r&&-1||1):n.scrollTop}),RZ=(e,t,n)=>{if(n.options.useCachedMeasurements){const i=n.indexFromElement(e),r=n.options.getItemKey(i);return n.itemSizeCache.get(r)??n.options.estimateSize(i)}if(t!=null&&t.borderBoxSize){const i=t.borderBoxSize[0];if(i)return Math.round(i[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const i=n.indexFromElement(e),r=n.options.getItemKey(i),o=n.itemSizeCache.get(r);if(o!==void 0)return o}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},OZ=(e,{adjustments:t=0,behavior:n},i)=>{var r,o;(o=(r=i.scrollElement)==null?void 0:r.scrollTo)==null||o.call(r,{[i.options.horizontal?"left":"top"]:e+t,behavior:n})},PZ=OZ;class zZ{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,i,r;return((r=(i=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:i.now)==null?void 0:r.call(i))??Date.now()},this.observer=(()=>{let n=null;const i=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(o=>{const c=()=>{const u=o.target,d=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);for(const[h,f]of this.elementsCache)if(f===u){this.elementsCache.delete(h);break}return}this.isIndexInRange(d)&&this.shouldMeasureDuringScroll(d)&&this.resizeItem(d,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var r;(r=i())==null||r.disconnect(),n=null},observe:r=>{var o;return(o=i())==null?void 0:o.observe(r,{box:"border-box"})},unobserve:r=>{var o;return(o=i())==null?void 0:o.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var i,r;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:CZ,rangeExtractor:AZ,onChange:()=>{},measureElement:RZ,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 p in n){const x=n[p];x!==void 0&&(o[p]=x)}const c=this.options;let u=null,d=null,h=!1;if(c!==void 0&&c.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const p=c.count,x=o.count,b=this.getMeasurements(),k=p>0?((i=b[0])==null?void 0:i.key)??c.getItemKey(0):null,w=p>0?((r=b[p-1])==null?void 0:r.key)??c.getItemKey(p-1):null;if(x!==p||p>0&&x>0&&(o.getItemKey(0)!==k||o.getItemKey(x-1)!==w)){h=!0;const N=p>0?this.getVirtualItemForOffset(this.getScrollOffset())??b[0]:null;N&&(u=[N.key,this.getScrollOffset()-N.start]);const C=o.followOnAppend===!0?"auto":o.followOnAppend||null;C&&x>p&&this.isAtEnd(c.scrollEndThreshold)&&(p===0||o.getItemKey(x-1)!==w)&&(d=C)}}this.options=o,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let f=!1,g=0;if(u&&this.scrollOffset!==null){const[p,x]=u,b=this.getMeasurements(),{count:k,getItemKey:w}=this.options;let j=0;for(;j<k&&w(j)!==p;)j++;if(j<k){const E=b[j];if(E){const N=Math.max(0,E.start+x);N!==this.scrollOffset&&(g=N-this.scrollOffset,this.scrollOffset=N,f=!0)}}}(f||d)&&(this.pendingScrollAnchor=[f?u[0]:null,f?u[1]:0,d,g])},this.notify=n=>{var i,r;(r=(i=this.options).onChange)==null||r.call(i,this,n)},this.maybeNotify=No(()=>(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 i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}if(this.scrollElement=i,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,!(!Xm()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",c,Dd),o.addEventListener("touchend",u,Dd),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 r=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,r&&this.scrollElement&&this.options.enabled){const[o,c,u,d]=r;o!==null&&!u&&(Xm()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):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(),i=this.getMaxScrollOffset();if(n<0||n>i)return;if(this._iosDeferredAdjustment<0&&n>=i-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,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=No(()=>[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,i,r,o,c,u,d,h)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:n,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:d,gap:h}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=No(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:i,scrollMargin:r,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:d,gap:h},f)=>{const g=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const j of this.laneAssignments.keys())j>=n&&this.laneAssignments.delete(j);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(j=>{this.itemSizeCache.set(j.key,j.size)}));const p=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),u===1){const j=n*2;let E=this._flatMeasurements;if(!E||E.length<j){const L=new Float64Array(j);E&&p>0&&L.set(E.subarray(0,p*2)),E=L,this._flatMeasurements=E}let N;if(p===0)N=i+r;else{const L=p-1;N=E[L*2]+E[L*2+1]+h}for(let L=p;L<n;L++){const $=o(L),O=g.get($),W=typeof O=="number"?O:this.options.estimateSize(L);E[L*2]=N,E[L*2+1]=W,N+=W+h}const C=SZ(n,E,o);return this.measurementsCache=C,C}const x=this.measurementsCache.slice(0,p),b=new Array(u).fill(void 0),k=new Float64Array(u);let w=0;for(let j=0;j<p;j++){const E=x[j];E&&(b[E.lane]===void 0&&w++,b[E.lane]=j,k[E.lane]=E.end)}for(let j=p;j<n;j++){const E=o(j),N=this.laneAssignments.get(j);let C,L;const $=d==="estimate"||g.has(E);if(N!==void 0&&this.options.lanes>1){C=N;const U=b[C],D=U!==void 0?x[U]:void 0;L=D?D.end+h:i+r}else if(w===u){let U=0,D=k[0],F=b[0];for(let A=1;A<u;A++){const T=k[A];(T<D||T===D&&b[A]<F)&&(U=A,D=T,F=b[A])}C=U,L=D+h,$&&this.laneAssignments.set(j,C)}else C=j%this.options.lanes,L=i+r,$&&this.laneAssignments.set(j,C);const O=g.get(E),W=typeof O=="number"?O:this.options.estimateSize(j),B=L+W;x[j]={index:j,start:L,size:W,end:B,key:E,lane:C},b[C]===void 0&&w++,b[C]=j,k[C]=B}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=No(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,i,r,o)=>n.length===0||i===0?(this.range=null,null):(this.range=DZ(n,i,r,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=No(()=>{let n=null,i=null;const r=this.calculateRange();return r&&(n=r.startIndex,i=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,i]},(n,i,r,o,c)=>o===null||c===null?[]:n({startIndex:o,endIndex:c,overscan:i,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const i=this.options.indexAttribute,r=n.getAttribute(i);return r?parseInt(r,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(r!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,r-o),u=Math.min(this.options.count-1,r+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 i=this.indexFromElement(n);if(!this.isIndexInRange(i))return;const r=this.options.getItemKey(i),o=this.elementsCache.get(r);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(r,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,i)=>{var r,o;if(!this.isIndexInRange(n))return;let c,u,d;const h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)d=this.options.getItemKey(n),u=h[n*2],c=h[n*2+1];else{const p=this.measurementsCache[n];if(!p)return;d=p.key,u=p.start,c=p.size}const f=this.itemSizeCache.get(d)??c,g=i-f;if(g!==0){const p=this.options.anchorTo==="end"&&((r=this.scrollState)==null?void 0:r.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=p?this.getTotalSize():0,b=this.getScrollOffset()+this.scrollAdjustments,w=!this.itemSizeCache.has(d)?u<b:u+f<=b&&this.scrollDirection!=="backward",j=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:d,start:u,size:c,end:u+c,lane:0},g,this):w);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(d,i),this.itemSizeCacheVersion++;let E=!1;p?E=this.applyScrollAdjustment(this.getTotalSize()-x):j&&(E=this.applyScrollAdjustment(g)),this.notify(E)}},this.getVirtualItems=No(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,i)=>{const r=[];for(let o=0,c=n.length;o<c;o++){const u=n[o],d=i[u];r.push(d)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const i=this.getMeasurements();if(i.length===0)return;const r=this._flatMeasurements,o=this.options.lanes===1&&r!=null,c=YE(0,i.length-1,o?u=>r[u*2]:u=>IN(i[u]).start,n);return IN(i[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,i,r=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),c=this.getScrollOffset();i==="auto"&&(i=n>=c+o?"end":"start"),i==="center"?n+=(r-o)/2:i==="end"&&(n-=o);const u=this.getMaxScrollOffset();return Math.max(Math.min(u,n),0)},this.getOffsetForIndex=(n,i="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),o=this.getScrollOffset(),c=this.measurementsCache[n];if(!c)return;if(i==="auto")if(c.end>=o+r-this.options.scrollPaddingEnd)i="end";else if(c.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];if(i==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),i];const u=i==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(u,i,c.size),i]},this.scrollToOffset=(n,{align:i="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(n,i),c=this.now();this.scrollState={index:null,align:i,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:i="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,i);if(!o)return;const[c,u]=o,d=this.now();this.scrollState={index:n,align:u,behavior:r,startedAt:d,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:i="auto"}={})=>{const r=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:o,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:i}),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 i=this.getMeasurements();let r;if(i.length===0)r=this.options.paddingStart;else if(this.options.lanes===1){const o=i.length-1,c=this._flatMeasurements;c!=null?r=c[o*2]+c[o*2+1]:r=((n=i[o])==null?void 0:n.end)??0}else{const o=Array(this.options.lanes).fill(null);let c=i.length-1;for(;c>=0&&o.some(u=>u===null);){const u=i[c];o[u.lane]===null&&(o[u.lane]=u.end),c--}r=Math.max(...o.filter(u=>u!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const i=this.getMeasurements();for(const r of i)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:i,behavior:r})=>{this._intendedScrollOffset=n+(i??0),this.options.scrollToFn(n,{behavior:r,adjustments:i},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:Xm()&&(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 i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,r=i?i[0]:this.scrollState.lastTargetOffset,o=1,c=r!==this.scrollState.lastTargetOffset;if(!c&&_Z(r,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==r&&this._scrollToOffset(r,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const u=this.getSize()||600,d=Math.abs(r-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&d>u;this.scrollState.lastTargetOffset=r,h||(this.scrollState.behavior="auto"),this._scrollToOffset(r,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}}const YE=(e,t,n,i)=>{for(;e<=t;){const r=(e+t)/2|0,o=n(r);if(o<i)e=r+1;else if(o>i)t=r-1;else return r}return e>0?e-1:0};function LZ(e,t,n){let i=0;for(;i<=t;){const r=(i+t)/2|0,o=e[r*2];if(o<n)i=r+1;else if(o>n)t=r-1;else return r}return i>0?i-1:0}function DZ(e,t,n,i,r){const o=e.length-1;if(e.length<=i)return{startIndex:0,endIndex:o};if(i===1&&r!==null){const h=LZ(r,o,n);let f=h;const g=n+t;for(;f<o&&r[f*2]+r[f*2+1]<g;)f++;return{startIndex:h,endIndex:f}}let u=YE(0,o,h=>e[h].start,n),d=u;if(i===1)for(;d<o&&e[d].end<n+t;)d++;else if(i>1){const h=Array(i).fill(0);for(;d<o&&h.some(g=>g<n+t);){const g=e[d];h[g.lane]=g.end,d++}const f=Array(i).fill(n+t);for(;u>=0&&f.some(g=>g>=n);){const g=e[u];f[g.lane]=g.start,u--}u=Math.max(0,u-u%i),d=Math.min(o,d+(i-1-d%i))}return{startIndex:u,endIndex:d}}const Qm=typeof document<"u"?y.useLayoutEffect:y.useEffect;function FZ({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...i}){const r=y.useReducer(f=>f+1,0)[1],o=y.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=n;const c=f=>{const g=o.current;if(!g.enabled||!g.container)return;const p=f.getTotalSize();if(p!==g.lastSize){g.lastSize=p;const x=f.options.horizontal?"width":"height";g.container.style[x]=`${p}px`}},u=f=>{const g=o.current;if(!g.enabled||!g.container)return;c(f);const p=!!f.options.horizontal,x=g.mode==="transform",b=p?"left":"top",k=f.options.scrollMargin,w=f.getVirtualItems();for(const j of w){const E=j.start-k,N=f.elementsCache.get(j.key);N&&g.lastPositions.get(N)!==E&&(g.lastPositions.set(N,E),x?N.style.transform=p?`translate3d(${E}px, 0, 0)`:`translate3d(0, ${E}px, 0)`:N.style[b]=`${E}px`)}},d={...i,onChange:(f,g)=>{var p;const x=o.current;let b=!0;if(x.enabled){u(f);const k=f.range,w=x.prevRange;b=!w||w.isScrolling!==f.isScrolling||w.startIndex!==(k==null?void 0:k.startIndex)||w.endIndex!==(k==null?void 0:k.endIndex),b&&(x.prevRange=k?{startIndex:k.startIndex,endIndex:k.endIndex,isScrolling:f.isScrolling}:null)}b&&(e&&g?Va.flushSync(r):r()),(p=i.onChange)==null||p.call(i,f,g)}},[h]=y.useState(()=>{const f=new zZ(d);return Object.assign(f,{containerRef:g=>{const p=o.current;if(p.container=g,p.lastSize=null,g&&p.enabled){const x=f.getTotalSize();p.lastSize=x;const b=f.options.horizontal?"width":"height";g.style[b]=`${x}px`}}})});return h.setOptions(d),Qm(()=>h._didMount(),[]),Qm(()=>(c(h),h._willUpdate())),Qm(()=>{u(h)}),h}function UZ(e){return FZ({observeElementRect:IZ,observeElementOffset:MZ,scrollToFn:PZ,...e})}const hh={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},XE={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},BZ={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function HZ(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function ZZ(e){return e.end===null?"进行中":e.reason===void 0?"":BZ[e.reason.kind]??e.reason.kind}function QE(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 uc(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function Fd(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function WZ({record:e,totals:t,onClose:n}){const i=qZ(e,t),[r,o]=y.useState(i[0].id),c=i.find(u=>u.id===r)??i[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:hh[e.kind]}),s.jsx("span",{className:"inspector-title",title:e.title,children:VZ(e)}),s.jsx("button",{className:"ghost icon",onClick:n,"aria-label":"关闭详情",children:s.jsx(Q,{name:"close"})})]}),s.jsx("nav",{className:"inspector-tabs",role:"tablist",children:i.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 VZ(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 hh[e.kind]}}function qZ(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>s.jsx(GZ,{record:e})},{id:"raw",label:"原始输出",render:()=>s.jsx(Jm,{content:e.content})},{id:"usage",label:"用量",render:()=>s.jsx(KZ,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>s.jsx(YZ,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>s.jsx(Qr,{rows:[["状态",s.jsx(xd,{record:e})],["工具",s.jsx("code",{children:e.name})],["调用 ID",s.jsx("code",{children:e.callId})],["开始时间",Kr(e.start)],["时长",e.end===null?"运行中":Rs(uc(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===""?"未捕获参数":qg(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?s.jsx("p",{className:"muted",children:"未捕获结果"}):s.jsx(Jm,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>s.jsxs(s.Fragment,{children:[s.jsx(Qr,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Kr(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),s.jsx("div",{className:"label",children:"预览"}),s.jsx(Jm,{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(Qr,{rows:[["状态",s.jsx(xd,{record:e})],["开始时间",Kr(e.start)],["时长",Rs(uc(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(Qr,{rows:[["状态",s.jsx(xd,{record:e})],["开始时间",Kr(e.start)],["时长",e.end===null?"运行中":Rs(uc(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${kn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${kn(e.usage.inputTokens)} / ${kn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function xd({record:e}){return s.jsx("span",{className:`status-text status-${e.status}`,children:XE[e.status]})}function Qr({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 GZ({record:e}){const t=e.request,n=e.content.filter(r=>r.type==="text").map(r=>r.type==="text"?r.text:"").join(""),i=e.content.filter(r=>r.type==="tool-call");return s.jsxs(s.Fragment,{children:[s.jsx(Qr,{rows:[["状态",s.jsx(xd,{record:e})],["请求",`#${t.index}`],["提供方",t.provider],["模型",t.model],["推理强度",t.reasoningEffort],["可用工具",t.toolCount===void 0?void 0:String(t.toolCount)],["工具调用",i.length===0?void 0:String(i.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(ti,{text:n,className:"inspector-markdown"})]}),n.trim()===""&&i.length>0&&s.jsx("p",{className:"muted small",children:"(仅工具调用)"}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"工具调用"}),s.jsx("ul",{className:"call-list",children:i.map(r=>s.jsxs("li",{children:[s.jsx("code",{children:r.name})," ",s.jsx("span",{className:"muted",children:r.arguments.slice(0,120)})]},r.callId))})]})]})}function Jm({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(ti,{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:qg(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?"":`${kn(t.size)}B`]},n);default:return s.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},n)}})})}function KZ({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(Qr,{rows:[["输入(未缓存)",`${kn(n.inputTokens)} tok`],["缓存读取",n.cacheReadTokens===void 0?void 0:`${kn(n.cacheReadTokens)} tok`],["缓存写入",n.cacheWriteTokens===void 0?void 0:`${kn(n.cacheWriteTokens)} tok`],["输入合计",`${kn(QE(e))} tok`],["输出",`${kn(n.outputTokens)} tok`],["其中推理",n.reasoningTokens===void 0?void 0:`${kn(n.reasoningTokens)} tok`],["总计",n.totalTokens===void 0?void 0:`${kn(n.totalTokens)} tok`]]}),s.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),s.jsx(Qr,{rows:[["请求数",String(t.requests)],["输入(未缓存)",`${kn(t.inputTokens)} tok`],["缓存读取",`${kn(t.cacheReadTokens)} tok`],["输出",`${kn(t.outputTokens)} tok`],["其中推理",`${kn(t.reasoningTokens)} tok`]]})]})}function YZ({record:e}){const[t,n]=y.useState(!1),i=e.request;return s.jsx(Qr,{rows:[["开始时间",s.jsx("button",{className:"link-button",onClick:()=>n(r=>!r),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Kr(e.start)})],["总时长",e.end===null?"运行中":Rs(uc(e))],["首 token 延迟",i.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Rs(i.ttftMs)],["生成",i.decodeMs===void 0?e.live?"运行中":"不可用":Rs(i.decodeMs)],["吞吐量",i.tokensPerSecond===void 0?i.usage===void 0?"用量不可用":"时长过短":`${i.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",Fd(e)===0?void 0:String(Fd(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const ad=14,XZ=y.memo(function({model:t,mode:n,brush:i,selectedId:r,onBrush:o,onSelect:c}){const u=y.useMemo(()=>mL(t),[t]),d=y.useMemo(()=>Zw.map((U,D)=>({...U,index:D})).filter(U=>U.id!=="compaction"||u.some(D=>D.lane===U.index)),[u]),h=new Map(d.map((U,D)=>[U.index,D])),f=t.span,[g,p]=y.useState(null),x=n==="actual"&&f!==null?QZ(g,f):null,b=y.useRef(null),[k,w]=y.useState(null),j=y.useRef(null),E=t.records.length,N=(U,D)=>n==="equal"?E===0?0:U/E:x===null||x.end===x.start?0:(D-x.start)/(x.end-x.start),C=U=>{var F;const D=(F=b.current)==null?void 0:F.getBoundingClientRect();return D===void 0||D.width===0?0:Math.min(1,Math.max(0,(U-D.left)/D.width))},L=U=>{if(U.button===2&&x!==null&&f!==null&&(x.start>f.start||x.end<f.end)){j.current={x:U.clientX,view:x};return}if(U.button!==0)return;const D=C(U.clientX);w({x0:D,x1:D})},$=U=>{if(j.current!==null&&f!==null&&b.current!==null){const D=(U.clientX-j.current.x)/b.current.clientWidth,F=j.current.view.end-j.current.view.start;p(xL(j.current.view,-D*F,f));return}k!==null&&w({...k,x1:C(U.clientX)})},O=()=>{if(j.current=null,k===null)return;const[U,D]=k.x0<k.x1?[k.x0,k.x1]:[k.x1,k.x0];if(w(null),!(D-U<.005)){if(n==="equal")o({mode:"equal",from:Math.floor(U*E),to:Math.max(Math.floor(U*E),Math.ceil(D*E)-1)});else if(x!==null){const F=x.end-x.start;o({mode:"actual",range:{start:x.start+U*F,end:x.start+D*F}})}}},W=U=>{if(n!=="actual"||x===null||f===null)return;const D=x.end-x.start;p(gL(x,x.start+C(U.clientX)*D,U.deltaY>0?1.25:.8,f))};if(E===0||f===null)return s.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const B=i===null?null:i.mode==="equal"?n==="equal"?{left:i.from/E,right:(i.to+1)/E}:null:n==="actual"?{left:N(0,i.range.start),right:N(0,i.range.end)}:null;return s.jsxs("div",{className:"overview",onContextMenu:U=>{U.preventDefault(),j.current===null&&o(null)},children:[s.jsx("div",{className:"overview-lanes",children:d.map(U=>s.jsx("div",{className:"lane-label",style:{height:ad},children:JZ(U.id)},U.id))}),s.jsxs("div",{className:"overview-track",ref:b,style:{height:d.length*(ad+2)},onMouseDown:L,onMouseMove:$,onMouseUp:O,onMouseLeave:O,onWheel:W,children:[u.map((U,D)=>{const F=h.get(U.lane)??0,A=N(D,U.start),T=n==="equal"?(D+1)/E:N(D,U.end);if(T<0||A>1)return null;const M=U.record,P=Math.max(0,Math.min(1,T)-Math.max(0,A)),V=n==="actual"&&U.firstTokenAt!==void 0&&U.end>U.start?(U.firstTokenAt-U.start)/(U.end-U.start):null;return s.jsx("div",{className:`bar kind-${M.kind} status-${M.status} ${U.instant&&n==="actual"?"instant":""} ${M.id===r?"selected":""}`,style:{left:`${Math.max(0,A)*100}%`,width:n==="equal"?`calc(${P*100}% - 1px)`:`max(2px, ${P*100}%)`,top:F*(ad+2),height:ad,...V===null?{}:{"--ttft":`${Math.min(100,Math.max(0,V*100))}%`}},title:eW(M,U.firstTokenAt),onMouseUp:z=>{k!==null&&Math.abs(k.x1-k.x0)<.005&&z.button===0&&c(M)}},M.id)}),B!==null&&s.jsx("div",{className:"brush",style:{left:`${Math.max(0,B.left)*100}%`,width:`${(Math.min(1,B.right)-Math.max(0,B.left))*100}%`}}),k!==null&&s.jsx("div",{className:"brush dragging",style:{left:`${Math.min(k.x0,k.x1)*100}%`,width:`${Math.abs(k.x1-k.x0)*100}%`}})]}),s.jsx("div",{className:"overview-scale muted",children:n==="actual"&&x!==null?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Kr(x.start)}),s.jsxs("span",{children:["总计 ",Rs(f.end-f.start),g!==null?" · 已缩放":""]}),s.jsx("span",{children:Kr(x.end)})]}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:[E," 条记录(等宽)"]}),s.jsxs("span",{children:["总计 ",Rs(f.end-f.start)]}),s.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function QZ(e,t){if(e===null)return t;const n=Math.max(t.start,e.start),i=Math.min(t.end,e.end);return i>n?{start:n,end:i}:t}function JZ(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function eW(e,t){const n=[`${hh[e.kind]} · ${e.title}`,`开始于 ${Kr(e.start)}`];return e.end===null?n.push("进行中(只显示开始标记)"):n.push(`总计 ${Rs(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&n.push(`首 token ${Rs(t-e.start)} · 解码 ${Rs(e.end-t)}`),n.join(`
243
+ `)}const tW=32,nW=34,sW=60;function iW({session:e,state:t}){const n=y.useMemo(()=>oL(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[i,r]=y.useState("equal"),[o,c]=y.useState(null),[u,d]=y.useState(""),[h,f]=y.useState(new Set),[g,p]=y.useState(!0),[x,b]=y.useState(null),k=n.records.find(U=>U.id===x)??null,w=y.useMemo(()=>rW(n,{brush:o,query:u,collapsed:h,showCalls:g}),[n,o,u,h,g]),j=y.useMemo(()=>w.flatMap(U=>U.type==="record"?[U.record]:[]),[w]),E=y.useRef(null),N=Hw(sW),C=N.following,L=UZ({count:w.length,getScrollElement:()=>E.current,estimateSize:U=>{var D;return((D=w[U])==null?void 0:D.type)==="group"?nW:tW},getItemKey:U=>{var D;return((D=w[U])==null?void 0:D.key)??U},overscan:12});y.useLayoutEffect(()=>{C.current&&w.length>0&&L.scrollToIndex(w.length-1,{align:"end"})},[w.length,t.version,L]),y.useEffect(()=>{if(x===null)return;const U=w.findIndex(D=>D.type==="record"&&D.record.id===x);U!==-1&&L.scrollToIndex(U,{align:"auto"})},[x]);const $=U=>f(D=>{const F=new Set(D);return F.has(U)?F.delete(U):F.add(U),F}),O=n.groups.length>0&&n.groups.every(U=>h.has(U.key)),W=U=>{if(U.key!=="ArrowDown"&&U.key!=="ArrowUp"&&U.key!=="Escape")return;if(U.preventDefault(),U.key==="Escape"){b(null);return}const D=j.findIndex(A=>A.id===x),F=j[U.key==="ArrowDown"?Math.min(j.length-1,D+1):Math.max(0,D-1)];F!==void 0&&b(F.id)},B=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 ${i==="actual"?"on":""}`,onClick:()=>{r(U=>U==="equal"?"actual":"equal"),c(null)},title:i==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",i==="equal"?"等宽":"实际时间"]}),s.jsxs("button",{className:"toggle",onClick:()=>f(O?new Set:new Set(n.groups.map(U=>U.key))),children:["⊟ ",O?"展开所有轮次":"收起所有轮次"]}),s.jsxs("button",{className:`toggle ${g?"":"on"}`,onClick:()=>p(U=>!U),children:["⊟ ",g?"收起所有调用":"展开所有调用"]}),s.jsx("input",{className:"traj-search",value:u,onChange:U=>d(U.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),s.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[B.requests," 次请求 · 输入 ",kn(B.inputTokens+B.cacheReadTokens+B.cacheWriteTokens)," · 输出 ",kn(B.outputTokens)," · ",B.toolCalls," 次工具调用",B.errors>0?` · ${B.errors} 个错误`:""]})]}),s.jsx(XZ,{model:n,mode:i,brush:o,selectedId:x,onBrush:c,onSelect:U=>b(U.id)}),o!==null&&s.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",j.length," 条记录 ",s.jsx("button",{className:"link-button",onClick:()=>c(null),children:"清除"})]}),s.jsxs("div",{className:"traj-main",children:[s.jsxs("div",{className:"ledger",ref:E,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?"正在加载更早的历史…":"加载更早的历史"}),w.length===0&&s.jsx("div",{className:"empty",children:t.status==="opening"?"正在加载轨迹…":u!==""?"没有匹配的记录":"还没有记录"}),s.jsx("div",{style:{height:L.getTotalSize(),position:"relative"},children:L.getVirtualItems().map(U=>{const D=w[U.index];return s.jsx("div",{className:"vrow",style:{transform:`translateY(${U.start}px)`,height:U.size},children:D.type==="group"?s.jsx(aW,{row:D,onToggle:()=>$(D.group.key)}):s.jsx(oW,{row:D,selected:D.record.id===x,onSelect:()=>b(F=>F===D.record.id?null:D.record.id)})},U.key)})})]}),k!==null&&s.jsx(WZ,{record:k,totals:n.totals,onClose:()=>b(null)},k.id)]})]})}function rW(e,t){const n=new Set;let i=e.records;if(t.brush!==null){const c=t.brush;i=c.mode==="equal"?i.slice(c.from,c.to+1):i.filter(u=>pL(u,c.range))}for(const c of vL(i,t.query))n.add(c.id);const r=t.brush!==null||t.query.trim()!=="",o=[];for(const c of e.groups){const u=c.records.filter(f=>n.has(f.id)&&(t.showCalls||f.kind!=="tool"));if(r&&u.length===0)continue;const d=t.collapsed.has(c.key);if(o.push({type:"group",key:`g:${c.key}`,group:c,collapsed:d,matches:u.length}),d)continue;let h=null;for(const f of u){const g=f.step!==null&&f.step!==h?f.step:null;f.step!==null&&(h=f.step),o.push({type:"record",key:f.id,record:f,stepStart:g})}}return o}const aW=y.memo(function({row:t,onToggle:n}){var u,d;const i=t.group,r=i.records.filter(h=>h.kind==="tool").length,o=i.end===null?null:i.end-i.start,c=ZZ(i);return s.jsxs("button",{className:`group-row ${i.end===null?"open":""} reason-${((u=i.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:HZ(i)}),s.jsxs("span",{className:"muted small",children:[i.steps.length>0&&`${i.steps.length} 个步骤`,r>0&&` · ${r} 个工具调用`,o!==null&&` · ${Rs(o)}`,i.partialStart&&" · 开头在已加载范围之外"]}),c!==""&&s.jsx("span",{className:`group-reason reason-${i.end===null?"running":((d=i.reason)==null?void 0:d.kind)??"none"}`,children:c})]})}),oW=y.memo(function({row:t,selected:n,onSelect:i}){var u;const r=t.record,o=r.kind==="assistant",c=uc(r);return s.jsxs("div",{className:`record-row kind-${r.kind} status-${r.status} ${n?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:i,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-${r.kind}`,children:o?`#${r.request.index}`:hh[r.kind]})}),s.jsxs("span",{className:"record-content",title:r.preview,children:[r.status==="running"&&s.jsx("span",{className:"running-dot"}),r.status==="error"&&s.jsxs("span",{className:"status-text status-error",children:[XE.error," · "]}),r.kind==="tool"?s.jsxs(s.Fragment,{children:[s.jsx("code",{className:"tool-name-inline",children:r.name})," ",s.jsx("span",{className:"muted",children:r.preview})]}):r.preview||s.jsx("span",{className:"muted",children:"(无内容)"})]}),s.jsx("span",{className:"num",children:o?kn(QE(r)):""}),s.jsx("span",{className:"num",children:o&&r.request.usage!==void 0?kn(r.request.usage.outputTokens):""}),s.jsx("span",{className:"num",children:o&&((u=r.request.usage)==null?void 0:u.reasoningTokens)!==void 0?kn(r.request.usage.reasoningTokens):""}),s.jsx("span",{className:"num",children:r.status==="running"?"…":c!==void 0&&(o||r.kind==="tool"||r.kind==="compaction"||r.kind==="attempt")?Rs(c):""}),s.jsx("span",{className:"model-cell",children:o?r.request.model??"":""}),s.jsx("span",{className:"num",children:o&&Fd(r)>0?Fd(r):""})]})}),lW={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:iW}]};jS();ni()===void 0&&document.documentElement.classList.add("own-title-bar");Jd&&document.documentElement.classList.add("in-dsh");zn(h3);zn(lW);zn(xZ);zn(vZ);zn(yZ);zn(kZ);zn(bZ);zn(NZ);zn(wZ);zn(R8);zn(O8);zn(T3);zn($3);zn(d9);zn(h9);zn(Z9);zn(s8);for(const e of f3)zn(e);const JE=PC.createRoot(document.getElementById("root"));function ep(e){const t=new AO({url:XD(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),JE.render(s.jsxs(l3,{children:[s.jsx(JD,{client:t}),s.jsx(o3,{client:t}),s.jsx(Hz,{}),s.jsx(d3,{})]}))}const $N=Jd?null:KD();Jd?ep(null):$N===null?JE.render(s.jsx(s3,{onSubmit:e=>{YD(e),ep(e)}})):ep($N);
244
+ //# sourceMappingURL=index-C-csjWiw.js.map