dsh-multigameassistant 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,241 @@
1
+ var HE=Object.defineProperty;var Zv=e=>{throw TypeError(e)};var ZE=(e,t,n)=>t in e?HE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ut=(e,t,n)=>ZE(e,typeof t!="symbol"?t+"":t,n),vf=(e,t,n)=>t.has(e)||Zv("Cannot "+n);var Oe=(e,t,n)=>(vf(e,t,"read from private field"),n?n.call(e):t.get(e)),Lt=(e,t,n)=>t.has(e)?Zv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Zt=(e,t,n,r)=>(vf(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),xt=(e,t,n)=>(vf(e,t,"access private method"),n);var Wv=(e,t,n,r)=>({set _(i){Zt(e,t,i,n)},get _(){return Oe(e,t,r)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function Sm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var yf={exports:{}},bl={},bf={exports:{}},mt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Vv;function WE(){if(Vv)return mt;Vv=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function g(q){return q===null||typeof q!="object"?null:(q=m&&q[m]||q["@@iterator"],typeof q=="function"?q:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,E={};function N(q,Y,fe){this.props=q,this.context=Y,this.refs=E,this.updater=fe||x}N.prototype.isReactComponent={},N.prototype.setState=function(q,Y){if(typeof q!="object"&&typeof q!="function"&&q!=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,q,Y,"setState")},N.prototype.forceUpdate=function(q){this.updater.enqueueForceUpdate(this,q,"forceUpdate")};function w(){}w.prototype=N.prototype;function T(q,Y,fe){this.props=q,this.context=Y,this.refs=E,this.updater=fe||x}var k=T.prototype=new w;k.constructor=T,y(k,N.prototype),k.isPureReactComponent=!0;var I=Array.isArray,L=Object.prototype.hasOwnProperty,z={current:null},U={key:!0,ref:!0,__self:!0,__source:!0};function V(q,Y,fe){var me,xe={},oe=null,re=null;if(Y!=null)for(me in Y.ref!==void 0&&(re=Y.ref),Y.key!==void 0&&(oe=""+Y.key),Y)L.call(Y,me)&&!U.hasOwnProperty(me)&&(xe[me]=Y[me]);var ie=arguments.length-2;if(ie===1)xe.children=fe;else if(1<ie){for(var ye=Array(ie),De=0;De<ie;De++)ye[De]=arguments[De+2];xe.children=ye}if(q&&q.defaultProps)for(me in ie=q.defaultProps,ie)xe[me]===void 0&&(xe[me]=ie[me]);return{$$typeof:e,type:q,key:oe,ref:re,props:xe,_owner:z.current}}function $(q,Y){return{$$typeof:e,type:q.type,key:Y,ref:q.ref,props:q.props,_owner:q._owner}}function P(q){return typeof q=="object"&&q!==null&&q.$$typeof===e}function D(q){var Y={"=":"=0",":":"=2"};return"$"+q.replace(/[=:]/g,function(fe){return Y[fe]})}var B=/\/+/g;function _(q,Y){return typeof q=="object"&&q!==null&&q.key!=null?D(""+q.key):Y.toString(36)}function C(q,Y,fe,me,xe){var oe=typeof q;(oe==="undefined"||oe==="boolean")&&(q=null);var re=!1;if(q===null)re=!0;else switch(oe){case"string":case"number":re=!0;break;case"object":switch(q.$$typeof){case e:case t:re=!0}}if(re)return re=q,xe=xe(re),q=me===""?"."+_(re,0):me,I(xe)?(fe="",q!=null&&(fe=q.replace(B,"$&/")+"/"),C(xe,Y,fe,"",function(De){return De})):xe!=null&&(P(xe)&&(xe=$(xe,fe+(!xe.key||re&&re.key===xe.key?"":(""+xe.key).replace(B,"$&/")+"/")+q)),Y.push(xe)),1;if(re=0,me=me===""?".":me+":",I(q))for(var ie=0;ie<q.length;ie++){oe=q[ie];var ye=me+_(oe,ie);re+=C(oe,Y,fe,ye,xe)}else if(ye=g(q),typeof ye=="function")for(q=ye.call(q),ie=0;!(oe=q.next()).done;)oe=oe.value,ye=me+_(oe,ie++),re+=C(oe,Y,fe,ye,xe);else if(oe==="object")throw Y=String(q),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(q).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.");return re}function R(q,Y,fe){if(q==null)return q;var me=[],xe=0;return C(q,me,"","",function(oe){return Y.call(fe,oe,xe++)}),me}function M(q){if(q._status===-1){var Y=q._result;Y=Y(),Y.then(function(fe){(q._status===0||q._status===-1)&&(q._status=1,q._result=fe)},function(fe){(q._status===0||q._status===-1)&&(q._status=2,q._result=fe)}),q._status===-1&&(q._status=0,q._result=Y)}if(q._status===1)return q._result.default;throw q._result}var F={current:null},H={transition:null},W={ReactCurrentDispatcher:F,ReactCurrentBatchConfig:H,ReactCurrentOwner:z};function K(){throw Error("act(...) is not supported in production builds of React.")}return mt.Children={map:R,forEach:function(q,Y,fe){R(q,function(){Y.apply(this,arguments)},fe)},count:function(q){var Y=0;return R(q,function(){Y++}),Y},toArray:function(q){return R(q,function(Y){return Y})||[]},only:function(q){if(!P(q))throw Error("React.Children.only expected to receive a single React element child.");return q}},mt.Component=N,mt.Fragment=n,mt.Profiler=i,mt.PureComponent=T,mt.StrictMode=r,mt.Suspense=h,mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=W,mt.act=K,mt.cloneElement=function(q,Y,fe){if(q==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+q+".");var me=y({},q.props),xe=q.key,oe=q.ref,re=q._owner;if(Y!=null){if(Y.ref!==void 0&&(oe=Y.ref,re=z.current),Y.key!==void 0&&(xe=""+Y.key),q.type&&q.type.defaultProps)var ie=q.type.defaultProps;for(ye in Y)L.call(Y,ye)&&!U.hasOwnProperty(ye)&&(me[ye]=Y[ye]===void 0&&ie!==void 0?ie[ye]:Y[ye])}var ye=arguments.length-2;if(ye===1)me.children=fe;else if(1<ye){ie=Array(ye);for(var De=0;De<ye;De++)ie[De]=arguments[De+2];me.children=ie}return{$$typeof:e,type:q.type,key:xe,ref:oe,props:me,_owner:re}},mt.createContext=function(q){return q={$$typeof:c,_currentValue:q,_currentValue2:q,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},q.Provider={$$typeof:o,_context:q},q.Consumer=q},mt.createElement=V,mt.createFactory=function(q){var Y=V.bind(null,q);return Y.type=q,Y},mt.createRef=function(){return{current:null}},mt.forwardRef=function(q){return{$$typeof:u,render:q}},mt.isValidElement=P,mt.lazy=function(q){return{$$typeof:p,_payload:{_status:-1,_result:q},_init:M}},mt.memo=function(q,Y){return{$$typeof:d,type:q,compare:Y===void 0?null:Y}},mt.startTransition=function(q){var Y=H.transition;H.transition={};try{q()}finally{H.transition=Y}},mt.unstable_act=K,mt.useCallback=function(q,Y){return F.current.useCallback(q,Y)},mt.useContext=function(q){return F.current.useContext(q)},mt.useDebugValue=function(){},mt.useDeferredValue=function(q){return F.current.useDeferredValue(q)},mt.useEffect=function(q,Y){return F.current.useEffect(q,Y)},mt.useId=function(){return F.current.useId()},mt.useImperativeHandle=function(q,Y,fe){return F.current.useImperativeHandle(q,Y,fe)},mt.useInsertionEffect=function(q,Y){return F.current.useInsertionEffect(q,Y)},mt.useLayoutEffect=function(q,Y){return F.current.useLayoutEffect(q,Y)},mt.useMemo=function(q,Y){return F.current.useMemo(q,Y)},mt.useReducer=function(q,Y,fe){return F.current.useReducer(q,Y,fe)},mt.useRef=function(q){return F.current.useRef(q)},mt.useState=function(q){return F.current.useState(q)},mt.useSyncExternalStore=function(q,Y,fe){return F.current.useSyncExternalStore(q,Y,fe)},mt.useTransition=function(){return F.current.useTransition()},mt.version="18.3.1",mt}var qv;function hc(){return qv||(qv=1,bf.exports=WE()),bf.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 Gv;function VE(){if(Gv)return bl;Gv=1;var e=hc(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(u,h,d){var p,m={},g=null,x=null;d!==void 0&&(g=""+d),h.key!==void 0&&(g=""+h.key),h.ref!==void 0&&(x=h.ref);for(p in h)r.call(h,p)&&!o.hasOwnProperty(p)&&(m[p]=h[p]);if(u&&u.defaultProps)for(p in h=u.defaultProps,h)m[p]===void 0&&(m[p]=h[p]);return{$$typeof:t,type:u,key:g,ref:x,props:m,_owner:i.current}}return bl.Fragment=n,bl.jsx=c,bl.jsxs=c,bl}var Kv;function qE(){return Kv||(Kv=1,yf.exports=VE()),yf.exports}var s=qE(),bu={},kf={exports:{}},vs={},Nf={exports:{}},wf={};/**
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 Yv;function GE(){return Yv||(Yv=1,(function(e){function t(H,W){var K=H.length;H.push(W);e:for(;0<K;){var q=K-1>>>1,Y=H[q];if(0<i(Y,W))H[q]=W,H[K]=Y,K=q;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var W=H[0],K=H.pop();if(K!==W){H[0]=K;e:for(var q=0,Y=H.length,fe=Y>>>1;q<fe;){var me=2*(q+1)-1,xe=H[me],oe=me+1,re=H[oe];if(0>i(xe,K))oe<Y&&0>i(re,xe)?(H[q]=re,H[oe]=K,q=oe):(H[q]=xe,H[me]=K,q=me);else if(oe<Y&&0>i(re,K))H[q]=re,H[oe]=K,q=oe;else break e}}return W}function i(H,W){var K=H.sortIndex-W.sortIndex;return K!==0?K:H.id-W.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 h=[],d=[],p=1,m=null,g=3,x=!1,y=!1,E=!1,N=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(H){for(var W=n(d);W!==null;){if(W.callback===null)r(d);else if(W.startTime<=H)r(d),W.sortIndex=W.expirationTime,t(h,W);else break;W=n(d)}}function I(H){if(E=!1,k(H),!y)if(n(h)!==null)y=!0,M(L);else{var W=n(d);W!==null&&F(I,W.startTime-H)}}function L(H,W){y=!1,E&&(E=!1,w(V),V=-1),x=!0;var K=g;try{for(k(W),m=n(h);m!==null&&(!(m.expirationTime>W)||H&&!D());){var q=m.callback;if(typeof q=="function"){m.callback=null,g=m.priorityLevel;var Y=q(m.expirationTime<=W);W=e.unstable_now(),typeof Y=="function"?m.callback=Y:m===n(h)&&r(h),k(W)}else r(h);m=n(h)}if(m!==null)var fe=!0;else{var me=n(d);me!==null&&F(I,me.startTime-W),fe=!1}return fe}finally{m=null,g=K,x=!1}}var z=!1,U=null,V=-1,$=5,P=-1;function D(){return!(e.unstable_now()-P<$)}function B(){if(U!==null){var H=e.unstable_now();P=H;var W=!0;try{W=U(!0,H)}finally{W?_():(z=!1,U=null)}}else z=!1}var _;if(typeof T=="function")_=function(){T(B)};else if(typeof MessageChannel<"u"){var C=new MessageChannel,R=C.port2;C.port1.onmessage=B,_=function(){R.postMessage(null)}}else _=function(){N(B,0)};function M(H){U=H,z||(z=!0,_())}function F(H,W){V=N(function(){H(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_continueExecution=function(){y||x||(y=!0,M(L))},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(h)},e.unstable_next=function(H){switch(g){case 1:case 2:case 3:var W=3;break;default:W=g}var K=g;g=W;try{return H()}finally{g=K}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(H,W){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var K=g;g=H;try{return W()}finally{g=K}},e.unstable_scheduleCallback=function(H,W,K){var q=e.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?q+K:q):K=q,H){case 1:var Y=-1;break;case 2:Y=250;break;case 5:Y=1073741823;break;case 4:Y=1e4;break;default:Y=5e3}return Y=K+Y,H={id:p++,callback:W,priorityLevel:H,startTime:K,expirationTime:Y,sortIndex:-1},K>q?(H.sortIndex=K,t(d,H),n(h)===null&&H===n(d)&&(E?(w(V),V=-1):E=!0,F(I,K-q))):(H.sortIndex=Y,t(h,H),y||x||(y=!0,M(L))),H},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(H){var W=g;return function(){var K=g;g=W;try{return H.apply(this,arguments)}finally{g=K}}}})(wf)),wf}var Xv;function KE(){return Xv||(Xv=1,Nf.exports=GE()),Nf.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 Qv;function YE(){if(Qv)return vs;Qv=1;var e=hc(),t=KE();function n(a){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+a,f=1;f<arguments.length;f++)l+="&args[]="+encodeURIComponent(arguments[f]);return"Minified React error #"+a+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,i={};function o(a,l){c(a,l),c(a+"Capture",l)}function c(a,l){for(i[a]=l,a=0;a<l.length;a++)r.add(l[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),h=Object.prototype.hasOwnProperty,d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function g(a){return h.call(m,a)?!0:h.call(p,a)?!1:d.test(a)?m[a]=!0:(p[a]=!0,!1)}function x(a,l,f,v){if(f!==null&&f.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return v?!1:f!==null?!f.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function y(a,l,f,v){if(l===null||typeof l>"u"||x(a,l,f,v))return!0;if(v)return!1;if(f!==null)switch(f.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 E(a,l,f,v,j,A,Z){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=v,this.attributeNamespace=j,this.mustUseProperty=f,this.propertyName=a,this.type=l,this.sanitizeURL=A,this.removeEmptyString=Z}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){N[a]=new E(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var l=a[0];N[l]=new E(l,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){N[a]=new E(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){N[a]=new E(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){N[a]=new E(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){N[a]=new E(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){N[a]=new E(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){N[a]=new E(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){N[a]=new E(a,5,!1,a.toLowerCase(),null,!1,!1)});var w=/[\-:]([a-z])/g;function T(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var l=a.replace(w,T);N[l]=new E(l,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var l=a.replace(w,T);N[l]=new E(l,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var l=a.replace(w,T);N[l]=new E(l,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){N[a]=new E(a,1,!1,a.toLowerCase(),null,!1,!1)}),N.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){N[a]=new E(a,1,!1,a.toLowerCase(),null,!0,!0)});function k(a,l,f,v){var j=N.hasOwnProperty(l)?N[l]:null;(j!==null?j.type!==0:v||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(y(l,f,j,v)&&(f=null),v||j===null?g(l)&&(f===null?a.removeAttribute(l):a.setAttribute(l,""+f)):j.mustUseProperty?a[j.propertyName]=f===null?j.type===3?!1:"":f:(l=j.attributeName,v=j.attributeNamespace,f===null?a.removeAttribute(l):(j=j.type,f=j===3||j===4&&f===!0?"":""+f,v?a.setAttributeNS(v,l,f):a.setAttribute(l,f))))}var I=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,L=Symbol.for("react.element"),z=Symbol.for("react.portal"),U=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),P=Symbol.for("react.provider"),D=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),F=Symbol.for("react.offscreen"),H=Symbol.iterator;function W(a){return a===null||typeof a!="object"?null:(a=H&&a[H]||a["@@iterator"],typeof a=="function"?a:null)}var K=Object.assign,q;function Y(a){if(q===void 0)try{throw Error()}catch(f){var l=f.stack.trim().match(/\n( *(at )?)/);q=l&&l[1]||""}return`
34
+ `+q+a}var fe=!1;function me(a,l){if(!a||fe)return"";fe=!0;var f=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(he){var v=he}Reflect.construct(a,[],l)}else{try{l.call()}catch(he){v=he}a.call(l.prototype)}else{try{throw Error()}catch(he){v=he}a()}}catch(he){if(he&&v&&typeof he.stack=="string"){for(var j=he.stack.split(`
35
+ `),A=v.stack.split(`
36
+ `),Z=j.length-1,X=A.length-1;1<=Z&&0<=X&&j[Z]!==A[X];)X--;for(;1<=Z&&0<=X;Z--,X--)if(j[Z]!==A[X]){if(Z!==1||X!==1)do if(Z--,X--,0>X||j[Z]!==A[X]){var ee=`
37
+ `+j[Z].replace(" at new "," at ");return a.displayName&&ee.includes("<anonymous>")&&(ee=ee.replace("<anonymous>",a.displayName)),ee}while(1<=Z&&0<=X);break}}}finally{fe=!1,Error.prepareStackTrace=f}return(a=a?a.displayName||a.name:"")?Y(a):""}function xe(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=me(a.type,!1),a;case 11:return a=me(a.type.render,!1),a;case 1:return a=me(a.type,!0),a;default:return""}}function oe(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 U:return"Fragment";case z:return"Portal";case $:return"Profiler";case V:return"StrictMode";case _:return"Suspense";case C:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case D:return(a.displayName||"Context")+".Consumer";case P:return(a._context.displayName||"Context")+".Provider";case B:var l=a.render;return a=a.displayName,a||(a=l.displayName||l.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case R:return l=a.displayName||null,l!==null?l:oe(a.type)||"Memo";case M:l=a._payload,a=a._init;try{return oe(a(l))}catch{}}return null}function re(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 oe(l);case 8:return l===V?"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 ie(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ye(a){var l=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function De(a){var l=ye(a)?"checked":"value",f=Object.getOwnPropertyDescriptor(a.constructor.prototype,l),v=""+a[l];if(!a.hasOwnProperty(l)&&typeof f<"u"&&typeof f.get=="function"&&typeof f.set=="function"){var j=f.get,A=f.set;return Object.defineProperty(a,l,{configurable:!0,get:function(){return j.call(this)},set:function(Z){v=""+Z,A.call(this,Z)}}),Object.defineProperty(a,l,{enumerable:f.enumerable}),{getValue:function(){return v},setValue:function(Z){v=""+Z},stopTracking:function(){a._valueTracker=null,delete a[l]}}}}function de(a){a._valueTracker||(a._valueTracker=De(a))}function Se(a){if(!a)return!1;var l=a._valueTracker;if(!l)return!0;var f=l.getValue(),v="";return a&&(v=ye(a)?a.checked?"true":"false":a.value),a=v,a!==f?(l.setValue(a),!0):!1}function ae(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 pe(a,l){var f=l.checked;return K({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:f??a._wrapperState.initialChecked})}function Le(a,l){var f=l.defaultValue==null?"":l.defaultValue,v=l.checked!=null?l.checked:l.defaultChecked;f=ie(l.value!=null?l.value:f),a._wrapperState={initialChecked:v,initialValue:f,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Te(a,l){l=l.checked,l!=null&&k(a,"checked",l,!1)}function Ge(a,l){Te(a,l);var f=ie(l.value),v=l.type;if(f!=null)v==="number"?(f===0&&a.value===""||a.value!=f)&&(a.value=""+f):a.value!==""+f&&(a.value=""+f);else if(v==="submit"||v==="reset"){a.removeAttribute("value");return}l.hasOwnProperty("value")?tt(a,l.type,f):l.hasOwnProperty("defaultValue")&&tt(a,l.type,ie(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(a.defaultChecked=!!l.defaultChecked)}function Ae(a,l,f){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,f||l===a.value||(a.value=l),a.defaultValue=l}f=a.name,f!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,f!==""&&(a.name=f)}function tt(a,l,f){(l!=="number"||ae(a.ownerDocument)!==a)&&(f==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+f&&(a.defaultValue=""+f))}var et=Array.isArray;function jt(a,l,f,v){if(a=a.options,l){l={};for(var j=0;j<f.length;j++)l["$"+f[j]]=!0;for(f=0;f<a.length;f++)j=l.hasOwnProperty("$"+a[f].value),a[f].selected!==j&&(a[f].selected=j),j&&v&&(a[f].defaultSelected=!0)}else{for(f=""+ie(f),l=null,j=0;j<a.length;j++){if(a[j].value===f){a[j].selected=!0,v&&(a[j].defaultSelected=!0);return}l!==null||a[j].disabled||(l=a[j])}l!==null&&(l.selected=!0)}}function zn(a,l){if(l.dangerouslySetInnerHTML!=null)throw Error(n(91));return K({},l,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function sn(a,l){var f=l.value;if(f==null){if(f=l.children,l=l.defaultValue,f!=null){if(l!=null)throw Error(n(92));if(et(f)){if(1<f.length)throw Error(n(93));f=f[0]}l=f}l==null&&(l=""),f=l}a._wrapperState={initialValue:ie(f)}}function ln(a,l){var f=ie(l.value),v=ie(l.defaultValue);f!=null&&(f=""+f,f!==a.value&&(a.value=f),l.defaultValue==null&&a.defaultValue!==f&&(a.defaultValue=f)),v!=null&&(a.defaultValue=""+v)}function cn(a){var l=a.textContent;l===a._wrapperState.initialValue&&l!==""&&l!==null&&(a.value=l)}function rn(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function an(a,l){return a==null||a==="http://www.w3.org/1999/xhtml"?rn(l):a==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var Ft,Un=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,f,v,j){MSApp.execUnsafeLocalFunction(function(){return a(l,f,v,j)})}:a})(function(a,l){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=l;else{for(Ft=Ft||document.createElement("div"),Ft.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Ft.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}});function Nn(a,l){if(l){var f=a.firstChild;if(f&&f===a.lastChild&&f.nodeType===3){f.nodeValue=l;return}}a.textContent=l}var js={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},Ir=["Webkit","ms","Moz","O"];Object.keys(js).forEach(function(a){Ir.forEach(function(l){l=l+a.charAt(0).toUpperCase()+a.substring(1),js[l]=js[a]})});function er(a,l,f){return l==null||typeof l=="boolean"||l===""?"":f||typeof l!="number"||l===0||js.hasOwnProperty(a)&&js[a]?(""+l).trim():l+"px"}function tr(a,l){a=a.style;for(var f in l)if(l.hasOwnProperty(f)){var v=f.indexOf("--")===0,j=er(f,l[f],v);f==="float"&&(f="cssFloat"),v?a.setProperty(f,j):a[f]=j}}var Ps=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ls(a,l){if(l){if(Ps[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 Ds(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 Fs=null;function nr(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var sr=null,as=null,Xn=null;function wn(a){if(a=il(a)){if(typeof sr!="function")throw Error(n(280));var l=a.stateNode;l&&(l=Oc(l),sr(a.stateNode,a.type,l))}}function J(a){as?Xn?Xn.push(a):Xn=[a]:as=a}function ge(){if(as){var a=as,l=Xn;if(Xn=as=null,wn(a),l)for(a=0;a<l.length;a++)wn(l[a])}}function ze(a,l){return a(l)}function st(){}var It=!1;function $t(a,l,f){if(It)return a(l,f);It=!0;try{return ze(a,l,f)}finally{It=!1,(as!==null||Xn!==null)&&(st(),ge())}}function Be(a,l){var f=a.stateNode;if(f===null)return null;var v=Oc(f);if(v===null)return null;f=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(f&&typeof f!="function")throw Error(n(231,l,typeof f));return f}var Fe=!1;if(u)try{var Xe={};Object.defineProperty(Xe,"passive",{get:function(){Fe=!0}}),window.addEventListener("test",Xe,Xe),window.removeEventListener("test",Xe,Xe)}catch{Fe=!1}function bt(a,l,f,v,j,A,Z,X,ee){var he=Array.prototype.slice.call(arguments,3);try{l.apply(f,he)}catch(Ee){this.onError(Ee)}}var yt=!1,Hn=null,os=!1,rr=null,mi={onError:function(a){yt=!0,Hn=a}};function ir(a,l,f,v,j,A,Z,X,ee){yt=!1,Hn=null,bt.apply(mi,arguments)}function gi(a,l,f,v,j,A,Z,X,ee){if(ir.apply(this,arguments),yt){if(yt){var he=Hn;yt=!1,Hn=null}else throw Error(n(198));os||(os=!0,rr=he)}}function Zn(a){var l=a,f=a;if(a.alternate)for(;l.return;)l=l.return;else{a=l;do l=a,(l.flags&4098)!==0&&(f=l.return),a=l.return;while(a)}return l.tag===3?f:null}function Wr(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 ls(a){if(Zn(a)!==a)throw Error(n(188))}function Tr(a){var l=a.alternate;if(!l){if(l=Zn(a),l===null)throw Error(n(188));return l!==a?null:a}for(var f=a,v=l;;){var j=f.return;if(j===null)break;var A=j.alternate;if(A===null){if(v=j.return,v!==null){f=v;continue}break}if(j.child===A.child){for(A=j.child;A;){if(A===f)return ls(j),a;if(A===v)return ls(j),l;A=A.sibling}throw Error(n(188))}if(f.return!==v.return)f=j,v=A;else{for(var Z=!1,X=j.child;X;){if(X===f){Z=!0,f=j,v=A;break}if(X===v){Z=!0,v=j,f=A;break}X=X.sibling}if(!Z){for(X=A.child;X;){if(X===f){Z=!0,f=A,v=j;break}if(X===v){Z=!0,v=A,f=j;break}X=X.sibling}if(!Z)throw Error(n(189))}}if(f.alternate!==v)throw Error(n(190))}if(f.tag!==3)throw Error(n(188));return f.stateNode.current===f?a:l}function xi(a){return a=Tr(a),a!==null?Rt(a):null}function Rt(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var l=Rt(a);if(l!==null)return l;a=a.sibling}return null}var Ss=t.unstable_scheduleCallback,Qn=t.unstable_cancelCallback,Vr=t.unstable_shouldYield,ar=t.unstable_requestPaint,Ot=t.unstable_now,vi=t.unstable_getCurrentPriorityLevel,qr=t.unstable_ImmediatePriority,or=t.unstable_UserBlockingPriority,$r=t.unstable_NormalPriority,Ie=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,ct=null,ht=null;function Tt(a){if(ht&&typeof ht.onCommitFiberRoot=="function")try{ht.onCommitFiberRoot(ct,a,void 0,(a.current.flags&128)===128)}catch{}}var zt=Math.clz32?Math.clz32:un,Wn=Math.log,Bs=Math.LN2;function un(a){return a>>>=0,a===0?32:31-(Wn(a)/Bs|0)|0}var jn=64,Us=4194304;function Hs(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 cs(a,l){var f=a.pendingLanes;if(f===0)return 0;var v=0,j=a.suspendedLanes,A=a.pingedLanes,Z=f&268435455;if(Z!==0){var X=Z&~j;X!==0?v=Hs(X):(A&=Z,A!==0&&(v=Hs(A)))}else Z=f&~j,Z!==0?v=Hs(Z):A!==0&&(v=Hs(A));if(v===0)return 0;if(l!==0&&l!==v&&(l&j)===0&&(j=v&-v,A=l&-l,j>=A||j===16&&(A&4194240)!==0))return l;if((v&4)!==0&&(v|=f&16),l=a.entangledLanes,l!==0)for(a=a.entanglements,l&=v;0<l;)f=31-zt(l),j=1<<f,v|=a[f],l&=~j;return v}function ta(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 yi(a,l){for(var f=a.suspendedLanes,v=a.pingedLanes,j=a.expirationTimes,A=a.pendingLanes;0<A;){var Z=31-zt(A),X=1<<Z,ee=j[Z];ee===-1?((X&f)===0||(X&v)!==0)&&(j[Z]=ta(X,l)):ee<=l&&(a.expiredLanes|=X),A&=~X}}function Mr(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function bi(){var a=jn;return jn<<=1,(jn&4194240)===0&&(jn=64),a}function Jn(a){for(var l=[],f=0;31>f;f++)l.push(a);return l}function us(a,l,f){a.pendingLanes|=l,l!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,l=31-zt(l),a[l]=f}function Sn(a,l){var f=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<f;){var j=31-zt(f),A=1<<j;l[j]=0,v[j]=-1,a[j]=-1,f&=~A}}function Zs(a,l){var f=a.entangledLanes|=l;for(a=a.entanglements;f;){var v=31-zt(f),j=1<<v;j&l|a[v]&l&&(a[v]|=l),f&=~j}}var vt=0;function at(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ds,Pt,ft,Gr,es,Kr=!1,lr=[],$e=null,Ue=null,ot=null,gt=new Map,Bt=new Map,pn=[],qo="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 na(a,l){switch(a){case"focusin":case"focusout":$e=null;break;case"dragenter":case"dragleave":Ue=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":gt.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Bt.delete(l.pointerId)}}function Yr(a,l,f,v,j,A){return a===null||a.nativeEvent!==A?(a={blockedOn:l,domEventName:f,eventSystemFlags:v,nativeEvent:A,targetContainers:[j]},l!==null&&(l=il(l),l!==null&&Pt(l)),a):(a.eventSystemFlags|=v,l=a.targetContainers,j!==null&&l.indexOf(j)===-1&&l.push(j),a)}function sa(a,l,f,v,j){switch(l){case"focusin":return $e=Yr($e,a,l,f,v,j),!0;case"dragenter":return Ue=Yr(Ue,a,l,f,v,j),!0;case"mouseover":return ot=Yr(ot,a,l,f,v,j),!0;case"pointerover":var A=j.pointerId;return gt.set(A,Yr(gt.get(A)||null,a,l,f,v,j)),!0;case"gotpointercapture":return A=j.pointerId,Bt.set(A,Yr(Bt.get(A)||null,a,l,f,v,j)),!0}return!1}function Da(a){var l=ra(a.target);if(l!==null){var f=Zn(l);if(f!==null){if(l=f.tag,l===13){if(l=Wr(f),l!==null){a.blockedOn=l,es(a.priority,function(){ft(f)});return}}else if(l===3&&f.stateNode.current.memoizedState.isDehydrated){a.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}a.blockedOn=null}function we(a){if(a.blockedOn!==null)return!1;for(var l=a.targetContainers;0<l.length;){var f=An(a.domEventName,a.eventSystemFlags,l[0],a.nativeEvent);if(f===null){f=a.nativeEvent;var v=new f.constructor(f.type,f);Fs=v,f.target.dispatchEvent(v),Fs=null}else return l=il(f),l!==null&&Pt(l),a.blockedOn=f,!1;l.shift()}return!0}function G(a,l,f){we(a)&&f.delete(l)}function ne(){Kr=!1,$e!==null&&we($e)&&($e=null),Ue!==null&&we(Ue)&&(Ue=null),ot!==null&&we(ot)&&(ot=null),gt.forEach(G),Bt.forEach(G)}function be(a,l){a.blockedOn===l&&(a.blockedOn=null,Kr||(Kr=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,ne)))}function ke(a){function l(j){return be(j,a)}if(0<lr.length){be(lr[0],a);for(var f=1;f<lr.length;f++){var v=lr[f];v.blockedOn===a&&(v.blockedOn=null)}}for($e!==null&&be($e,a),Ue!==null&&be(Ue,a),ot!==null&&be(ot,a),gt.forEach(l),Bt.forEach(l),f=0;f<pn.length;f++)v=pn[f],v.blockedOn===a&&(v.blockedOn=null);for(;0<pn.length&&(f=pn[0],f.blockedOn===null);)Da(f),f.blockedOn===null&&pn.shift()}var qe=I.ReactCurrentBatchConfig,nt=!0;function pt(a,l,f,v){var j=vt,A=qe.transition;qe.transition=null;try{vt=1,hs(a,l,f,v)}finally{vt=j,qe.transition=A}}function dn(a,l,f,v){var j=vt,A=qe.transition;qe.transition=null;try{vt=4,hs(a,l,f,v)}finally{vt=j,qe.transition=A}}function hs(a,l,f,v){if(nt){var j=An(a,l,f,v);if(j===null)oh(a,l,v,mn,f),na(a,v);else if(sa(j,a,l,f,v))v.stopPropagation();else if(na(a,v),l&4&&-1<qo.indexOf(a)){for(;j!==null;){var A=il(j);if(A!==null&&ds(A),A=An(a,l,f,v),A===null&&oh(a,l,v,mn,f),A===j)break;j=A}j!==null&&v.stopPropagation()}else oh(a,l,v,null,f)}}var mn=null;function An(a,l,f,v){if(mn=null,a=nr(v),a=ra(a),a!==null)if(l=Zn(a),l===null)a=null;else if(f=l.tag,f===13){if(a=Wr(l),a!==null)return a;a=null}else if(f===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;a=null}else l!==a&&(a=null);return mn=a,null}function Xr(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(vi()){case qr:return 1;case or:return 4;case $r:case Ie:return 16;case Ze:return 536870912;default:return 16}default:return 16}}var Qt=null,Fa=null,jc=null;function Tg(){if(jc)return jc;var a,l=Fa,f=l.length,v,j="value"in Qt?Qt.value:Qt.textContent,A=j.length;for(a=0;a<f&&l[a]===j[a];a++);var Z=f-a;for(v=1;v<=Z&&l[f-v]===j[A-v];v++);return jc=j.slice(a,1<v?1-v:void 0)}function Sc(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 _c(){return!0}function $g(){return!1}function _s(a){function l(f,v,j,A,Z){this._reactName=f,this._targetInst=j,this.type=v,this.nativeEvent=A,this.target=Z,this.currentTarget=null;for(var X in a)a.hasOwnProperty(X)&&(f=a[X],this[X]=f?f(A):A[X]);return this.isDefaultPrevented=(A.defaultPrevented!=null?A.defaultPrevented:A.returnValue===!1)?_c:$g,this.isPropagationStopped=$g,this}return K(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=_c)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=_c)},persist:function(){},isPersistent:_c}),l}var Ba={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vd=_s(Ba),Go=K({},Ba,{view:0,detail:0}),g_=_s(Go),qd,Gd,Ko,Ec=K({},Go,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Yd,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!==Ko&&(Ko&&a.type==="mousemove"?(qd=a.screenX-Ko.screenX,Gd=a.screenY-Ko.screenY):Gd=qd=0,Ko=a),qd)},movementY:function(a){return"movementY"in a?a.movementY:Gd}}),Mg=_s(Ec),x_=K({},Ec,{dataTransfer:0}),v_=_s(x_),y_=K({},Go,{relatedTarget:0}),Kd=_s(y_),b_=K({},Ba,{animationName:0,elapsedTime:0,pseudoElement:0}),k_=_s(b_),N_=K({},Ba,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),w_=_s(N_),j_=K({},Ba,{data:0}),Rg=_s(j_),S_={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},__={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"},E_={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function C_(a){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(a):(a=E_[a])?!!l[a]:!1}function Yd(){return C_}var A_=K({},Go,{key:function(a){if(a.key){var l=S_[a.key]||a.key;if(l!=="Unidentified")return l}return a.type==="keypress"?(a=Sc(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?__[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Yd,charCode:function(a){return a.type==="keypress"?Sc(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Sc(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),I_=_s(A_),T_=K({},Ec,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Og=_s(T_),$_=K({},Go,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Yd}),M_=_s($_),R_=K({},Ba,{propertyName:0,elapsedTime:0,pseudoElement:0}),O_=_s(R_),z_=K({},Ec,{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}),P_=_s(z_),L_=[9,13,27,32],Xd=u&&"CompositionEvent"in window,Yo=null;u&&"documentMode"in document&&(Yo=document.documentMode);var D_=u&&"TextEvent"in window&&!Yo,zg=u&&(!Xd||Yo&&8<Yo&&11>=Yo),Pg=" ",Lg=!1;function Dg(a,l){switch(a){case"keyup":return L_.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fg(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var Ua=!1;function F_(a,l){switch(a){case"compositionend":return Fg(l);case"keypress":return l.which!==32?null:(Lg=!0,Pg);case"textInput":return a=l.data,a===Pg&&Lg?null:a;default:return null}}function B_(a,l){if(Ua)return a==="compositionend"||!Xd&&Dg(a,l)?(a=Tg(),jc=Fa=Qt=null,Ua=!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 zg&&l.locale!=="ko"?null:l.data;default:return null}}var U_={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 Bg(a){var l=a&&a.nodeName&&a.nodeName.toLowerCase();return l==="input"?!!U_[a.type]:l==="textarea"}function Ug(a,l,f,v){J(v),l=$c(l,"onChange"),0<l.length&&(f=new Vd("onChange","change",null,f,v),a.push({event:f,listeners:l}))}var Xo=null,Qo=null;function H_(a){ax(a,0)}function Cc(a){var l=qa(a);if(Se(l))return a}function Z_(a,l){if(a==="change")return l}var Hg=!1;if(u){var Qd;if(u){var Jd="oninput"in document;if(!Jd){var Zg=document.createElement("div");Zg.setAttribute("oninput","return;"),Jd=typeof Zg.oninput=="function"}Qd=Jd}else Qd=!1;Hg=Qd&&(!document.documentMode||9<document.documentMode)}function Wg(){Xo&&(Xo.detachEvent("onpropertychange",Vg),Qo=Xo=null)}function Vg(a){if(a.propertyName==="value"&&Cc(Qo)){var l=[];Ug(l,Qo,a,nr(a)),$t(H_,l)}}function W_(a,l,f){a==="focusin"?(Wg(),Xo=l,Qo=f,Xo.attachEvent("onpropertychange",Vg)):a==="focusout"&&Wg()}function V_(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Cc(Qo)}function q_(a,l){if(a==="click")return Cc(l)}function G_(a,l){if(a==="input"||a==="change")return Cc(l)}function K_(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var cr=typeof Object.is=="function"?Object.is:K_;function Jo(a,l){if(cr(a,l))return!0;if(typeof a!="object"||a===null||typeof l!="object"||l===null)return!1;var f=Object.keys(a),v=Object.keys(l);if(f.length!==v.length)return!1;for(v=0;v<f.length;v++){var j=f[v];if(!h.call(l,j)||!cr(a[j],l[j]))return!1}return!0}function qg(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Gg(a,l){var f=qg(a);a=0;for(var v;f;){if(f.nodeType===3){if(v=a+f.textContent.length,a<=l&&v>=l)return{node:f,offset:l-a};a=v}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=qg(f)}}function Kg(a,l){return a&&l?a===l?!0:a&&a.nodeType===3?!1:l&&l.nodeType===3?Kg(a,l.parentNode):"contains"in a?a.contains(l):a.compareDocumentPosition?!!(a.compareDocumentPosition(l)&16):!1:!1}function Yg(){for(var a=window,l=ae();l instanceof a.HTMLIFrameElement;){try{var f=typeof l.contentWindow.location.href=="string"}catch{f=!1}if(f)a=l.contentWindow;else break;l=ae(a.document)}return l}function eh(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 Y_(a){var l=Yg(),f=a.focusedElem,v=a.selectionRange;if(l!==f&&f&&f.ownerDocument&&Kg(f.ownerDocument.documentElement,f)){if(v!==null&&eh(f)){if(l=v.start,a=v.end,a===void 0&&(a=l),"selectionStart"in f)f.selectionStart=l,f.selectionEnd=Math.min(a,f.value.length);else if(a=(l=f.ownerDocument||document)&&l.defaultView||window,a.getSelection){a=a.getSelection();var j=f.textContent.length,A=Math.min(v.start,j);v=v.end===void 0?A:Math.min(v.end,j),!a.extend&&A>v&&(j=v,v=A,A=j),j=Gg(f,A);var Z=Gg(f,v);j&&Z&&(a.rangeCount!==1||a.anchorNode!==j.node||a.anchorOffset!==j.offset||a.focusNode!==Z.node||a.focusOffset!==Z.offset)&&(l=l.createRange(),l.setStart(j.node,j.offset),a.removeAllRanges(),A>v?(a.addRange(l),a.extend(Z.node,Z.offset)):(l.setEnd(Z.node,Z.offset),a.addRange(l)))}}for(l=[],a=f;a=a.parentNode;)a.nodeType===1&&l.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof f.focus=="function"&&f.focus(),f=0;f<l.length;f++)a=l[f],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var X_=u&&"documentMode"in document&&11>=document.documentMode,Ha=null,th=null,el=null,nh=!1;function Xg(a,l,f){var v=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;nh||Ha==null||Ha!==ae(v)||(v=Ha,"selectionStart"in v&&eh(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}),el&&Jo(el,v)||(el=v,v=$c(th,"onSelect"),0<v.length&&(l=new Vd("onSelect","select",null,l,f),a.push({event:l,listeners:v}),l.target=Ha)))}function Ac(a,l){var f={};return f[a.toLowerCase()]=l.toLowerCase(),f["Webkit"+a]="webkit"+l,f["Moz"+a]="moz"+l,f}var Za={animationend:Ac("Animation","AnimationEnd"),animationiteration:Ac("Animation","AnimationIteration"),animationstart:Ac("Animation","AnimationStart"),transitionend:Ac("Transition","TransitionEnd")},sh={},Qg={};u&&(Qg=document.createElement("div").style,"AnimationEvent"in window||(delete Za.animationend.animation,delete Za.animationiteration.animation,delete Za.animationstart.animation),"TransitionEvent"in window||delete Za.transitionend.transition);function Ic(a){if(sh[a])return sh[a];if(!Za[a])return a;var l=Za[a],f;for(f in l)if(l.hasOwnProperty(f)&&f in Qg)return sh[a]=l[f];return a}var Jg=Ic("animationend"),ex=Ic("animationiteration"),tx=Ic("animationstart"),nx=Ic("transitionend"),sx=new Map,rx="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 ki(a,l){sx.set(a,l),o(l,[a])}for(var rh=0;rh<rx.length;rh++){var ih=rx[rh],Q_=ih.toLowerCase(),J_=ih[0].toUpperCase()+ih.slice(1);ki(Q_,"on"+J_)}ki(Jg,"onAnimationEnd"),ki(ex,"onAnimationIteration"),ki(tx,"onAnimationStart"),ki("dblclick","onDoubleClick"),ki("focusin","onFocus"),ki("focusout","onBlur"),ki(nx,"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 tl="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(" "),eE=new Set("cancel close invalid load scroll toggle".split(" ").concat(tl));function ix(a,l,f){var v=a.type||"unknown-event";a.currentTarget=f,gi(v,l,void 0,a),a.currentTarget=null}function ax(a,l){l=(l&4)!==0;for(var f=0;f<a.length;f++){var v=a[f],j=v.event;v=v.listeners;e:{var A=void 0;if(l)for(var Z=v.length-1;0<=Z;Z--){var X=v[Z],ee=X.instance,he=X.currentTarget;if(X=X.listener,ee!==A&&j.isPropagationStopped())break e;ix(j,X,he),A=ee}else for(Z=0;Z<v.length;Z++){if(X=v[Z],ee=X.instance,he=X.currentTarget,X=X.listener,ee!==A&&j.isPropagationStopped())break e;ix(j,X,he),A=ee}}}if(os)throw a=rr,os=!1,rr=null,a}function Ut(a,l){var f=l[fh];f===void 0&&(f=l[fh]=new Set);var v=a+"__bubble";f.has(v)||(ox(l,a,2,!1),f.add(v))}function ah(a,l,f){var v=0;l&&(v|=4),ox(f,a,v,l)}var Tc="_reactListening"+Math.random().toString(36).slice(2);function nl(a){if(!a[Tc]){a[Tc]=!0,r.forEach(function(f){f!=="selectionchange"&&(eE.has(f)||ah(f,!1,a),ah(f,!0,a))});var l=a.nodeType===9?a:a.ownerDocument;l===null||l[Tc]||(l[Tc]=!0,ah("selectionchange",!1,l))}}function ox(a,l,f,v){switch(Xr(l)){case 1:var j=pt;break;case 4:j=dn;break;default:j=hs}f=j.bind(null,l,f,a),j=void 0,!Fe||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(j=!0),v?j!==void 0?a.addEventListener(l,f,{capture:!0,passive:j}):a.addEventListener(l,f,!0):j!==void 0?a.addEventListener(l,f,{passive:j}):a.addEventListener(l,f,!1)}function oh(a,l,f,v,j){var A=v;if((l&1)===0&&(l&2)===0&&v!==null)e:for(;;){if(v===null)return;var Z=v.tag;if(Z===3||Z===4){var X=v.stateNode.containerInfo;if(X===j||X.nodeType===8&&X.parentNode===j)break;if(Z===4)for(Z=v.return;Z!==null;){var ee=Z.tag;if((ee===3||ee===4)&&(ee=Z.stateNode.containerInfo,ee===j||ee.nodeType===8&&ee.parentNode===j))return;Z=Z.return}for(;X!==null;){if(Z=ra(X),Z===null)return;if(ee=Z.tag,ee===5||ee===6){v=A=Z;continue e}X=X.parentNode}}v=v.return}$t(function(){var he=A,Ee=nr(f),Ce=[];e:{var _e=sx.get(a);if(_e!==void 0){var He=Vd,Ve=a;switch(a){case"keypress":if(Sc(f)===0)break e;case"keydown":case"keyup":He=I_;break;case"focusin":Ve="focus",He=Kd;break;case"focusout":Ve="blur",He=Kd;break;case"beforeblur":case"afterblur":He=Kd;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=Mg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=v_;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=M_;break;case Jg:case ex:case tx:He=k_;break;case nx:He=O_;break;case"scroll":He=g_;break;case"wheel":He=P_;break;case"copy":case"cut":case"paste":He=w_;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=Og}var Ke=(l&4)!==0,hn=!Ke&&a==="scroll",le=Ke?_e!==null?_e+"Capture":null:_e;Ke=[];for(var se=he,ce;se!==null;){ce=se;var Me=ce.stateNode;if(ce.tag===5&&Me!==null&&(ce=Me,le!==null&&(Me=Be(se,le),Me!=null&&Ke.push(sl(se,Me,ce)))),hn)break;se=se.return}0<Ke.length&&(_e=new He(_e,Ve,null,f,Ee),Ce.push({event:_e,listeners:Ke}))}}if((l&7)===0){e:{if(_e=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",_e&&f!==Fs&&(Ve=f.relatedTarget||f.fromElement)&&(ra(Ve)||Ve[Qr]))break e;if((He||_e)&&(_e=Ee.window===Ee?Ee:(_e=Ee.ownerDocument)?_e.defaultView||_e.parentWindow:window,He?(Ve=f.relatedTarget||f.toElement,He=he,Ve=Ve?ra(Ve):null,Ve!==null&&(hn=Zn(Ve),Ve!==hn||Ve.tag!==5&&Ve.tag!==6)&&(Ve=null)):(He=null,Ve=he),He!==Ve)){if(Ke=Mg,Me="onMouseLeave",le="onMouseEnter",se="mouse",(a==="pointerout"||a==="pointerover")&&(Ke=Og,Me="onPointerLeave",le="onPointerEnter",se="pointer"),hn=He==null?_e:qa(He),ce=Ve==null?_e:qa(Ve),_e=new Ke(Me,se+"leave",He,f,Ee),_e.target=hn,_e.relatedTarget=ce,Me=null,ra(Ee)===he&&(Ke=new Ke(le,se+"enter",Ve,f,Ee),Ke.target=ce,Ke.relatedTarget=hn,Me=Ke),hn=Me,He&&Ve)t:{for(Ke=He,le=Ve,se=0,ce=Ke;ce;ce=Wa(ce))se++;for(ce=0,Me=le;Me;Me=Wa(Me))ce++;for(;0<se-ce;)Ke=Wa(Ke),se--;for(;0<ce-se;)le=Wa(le),ce--;for(;se--;){if(Ke===le||le!==null&&Ke===le.alternate)break t;Ke=Wa(Ke),le=Wa(le)}Ke=null}else Ke=null;He!==null&&lx(Ce,_e,He,Ke,!1),Ve!==null&&hn!==null&&lx(Ce,hn,Ve,Ke,!0)}}e:{if(_e=he?qa(he):window,He=_e.nodeName&&_e.nodeName.toLowerCase(),He==="select"||He==="input"&&_e.type==="file")var Ye=Z_;else if(Bg(_e))if(Hg)Ye=G_;else{Ye=V_;var rt=W_}else(He=_e.nodeName)&&He.toLowerCase()==="input"&&(_e.type==="checkbox"||_e.type==="radio")&&(Ye=q_);if(Ye&&(Ye=Ye(a,he))){Ug(Ce,Ye,f,Ee);break e}rt&&rt(a,_e,he),a==="focusout"&&(rt=_e._wrapperState)&&rt.controlled&&_e.type==="number"&&tt(_e,"number",_e.value)}switch(rt=he?qa(he):window,a){case"focusin":(Bg(rt)||rt.contentEditable==="true")&&(Ha=rt,th=he,el=null);break;case"focusout":el=th=Ha=null;break;case"mousedown":nh=!0;break;case"contextmenu":case"mouseup":case"dragend":nh=!1,Xg(Ce,f,Ee);break;case"selectionchange":if(X_)break;case"keydown":case"keyup":Xg(Ce,f,Ee)}var it;if(Xd)e:{switch(a){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else Ua?Dg(a,f)&&(lt="onCompositionEnd"):a==="keydown"&&f.keyCode===229&&(lt="onCompositionStart");lt&&(zg&&f.locale!=="ko"&&(Ua||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&Ua&&(it=Tg()):(Qt=Ee,Fa="value"in Qt?Qt.value:Qt.textContent,Ua=!0)),rt=$c(he,lt),0<rt.length&&(lt=new Rg(lt,a,null,f,Ee),Ce.push({event:lt,listeners:rt}),it?lt.data=it:(it=Fg(f),it!==null&&(lt.data=it)))),(it=D_?F_(a,f):B_(a,f))&&(he=$c(he,"onBeforeInput"),0<he.length&&(Ee=new Rg("onBeforeInput","beforeinput",null,f,Ee),Ce.push({event:Ee,listeners:he}),Ee.data=it))}ax(Ce,l)})}function sl(a,l,f){return{instance:a,listener:l,currentTarget:f}}function $c(a,l){for(var f=l+"Capture",v=[];a!==null;){var j=a,A=j.stateNode;j.tag===5&&A!==null&&(j=A,A=Be(a,f),A!=null&&v.unshift(sl(a,A,j)),A=Be(a,l),A!=null&&v.push(sl(a,A,j))),a=a.return}return v}function Wa(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function lx(a,l,f,v,j){for(var A=l._reactName,Z=[];f!==null&&f!==v;){var X=f,ee=X.alternate,he=X.stateNode;if(ee!==null&&ee===v)break;X.tag===5&&he!==null&&(X=he,j?(ee=Be(f,A),ee!=null&&Z.unshift(sl(f,ee,X))):j||(ee=Be(f,A),ee!=null&&Z.push(sl(f,ee,X)))),f=f.return}Z.length!==0&&a.push({event:l,listeners:Z})}var tE=/\r\n?/g,nE=/\u0000|\uFFFD/g;function cx(a){return(typeof a=="string"?a:""+a).replace(tE,`
38
+ `).replace(nE,"")}function Mc(a,l,f){if(l=cx(l),cx(a)!==l&&f)throw Error(n(425))}function Rc(){}var lh=null,ch=null;function uh(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 dh=typeof setTimeout=="function"?setTimeout:void 0,sE=typeof clearTimeout=="function"?clearTimeout:void 0,ux=typeof Promise=="function"?Promise:void 0,rE=typeof queueMicrotask=="function"?queueMicrotask:typeof ux<"u"?function(a){return ux.resolve(null).then(a).catch(iE)}:dh;function iE(a){setTimeout(function(){throw a})}function hh(a,l){var f=l,v=0;do{var j=f.nextSibling;if(a.removeChild(f),j&&j.nodeType===8)if(f=j.data,f==="/$"){if(v===0){a.removeChild(j),ke(l);return}v--}else f!=="$"&&f!=="$?"&&f!=="$!"||v++;f=j}while(f);ke(l)}function Ni(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 dx(a){a=a.previousSibling;for(var l=0;a;){if(a.nodeType===8){var f=a.data;if(f==="$"||f==="$!"||f==="$?"){if(l===0)return a;l--}else f==="/$"&&l++}a=a.previousSibling}return null}var Va=Math.random().toString(36).slice(2),Rr="__reactFiber$"+Va,rl="__reactProps$"+Va,Qr="__reactContainer$"+Va,fh="__reactEvents$"+Va,aE="__reactListeners$"+Va,oE="__reactHandles$"+Va;function ra(a){var l=a[Rr];if(l)return l;for(var f=a.parentNode;f;){if(l=f[Qr]||f[Rr]){if(f=l.alternate,l.child!==null||f!==null&&f.child!==null)for(a=dx(a);a!==null;){if(f=a[Rr])return f;a=dx(a)}return l}a=f,f=a.parentNode}return null}function il(a){return a=a[Rr]||a[Qr],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function qa(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function Oc(a){return a[rl]||null}var ph=[],Ga=-1;function wi(a){return{current:a}}function Ht(a){0>Ga||(a.current=ph[Ga],ph[Ga]=null,Ga--)}function Dt(a,l){Ga++,ph[Ga]=a.current,a.current=l}var ji={},Vn=wi(ji),fs=wi(!1),ia=ji;function Ka(a,l){var f=a.type.contextTypes;if(!f)return ji;var v=a.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===l)return v.__reactInternalMemoizedMaskedChildContext;var j={},A;for(A in f)j[A]=l[A];return v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=l,a.__reactInternalMemoizedMaskedChildContext=j),j}function ps(a){return a=a.childContextTypes,a!=null}function zc(){Ht(fs),Ht(Vn)}function hx(a,l,f){if(Vn.current!==ji)throw Error(n(168));Dt(Vn,l),Dt(fs,f)}function fx(a,l,f){var v=a.stateNode;if(l=l.childContextTypes,typeof v.getChildContext!="function")return f;v=v.getChildContext();for(var j in v)if(!(j in l))throw Error(n(108,re(a)||"Unknown",j));return K({},f,v)}function Pc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||ji,ia=Vn.current,Dt(Vn,a),Dt(fs,fs.current),!0}function px(a,l,f){var v=a.stateNode;if(!v)throw Error(n(169));f?(a=fx(a,l,ia),v.__reactInternalMemoizedMergedChildContext=a,Ht(fs),Ht(Vn),Dt(Vn,a)):Ht(fs),Dt(fs,f)}var Jr=null,Lc=!1,mh=!1;function mx(a){Jr===null?Jr=[a]:Jr.push(a)}function lE(a){Lc=!0,mx(a)}function Si(){if(!mh&&Jr!==null){mh=!0;var a=0,l=vt;try{var f=Jr;for(vt=1;a<f.length;a++){var v=f[a];do v=v(!0);while(v!==null)}Jr=null,Lc=!1}catch(j){throw Jr!==null&&(Jr=Jr.slice(a+1)),Ss(qr,Si),j}finally{vt=l,mh=!1}}return null}var Ya=[],Xa=0,Dc=null,Fc=0,Ws=[],Vs=0,aa=null,ei=1,ti="";function oa(a,l){Ya[Xa++]=Fc,Ya[Xa++]=Dc,Dc=a,Fc=l}function gx(a,l,f){Ws[Vs++]=ei,Ws[Vs++]=ti,Ws[Vs++]=aa,aa=a;var v=ei;a=ti;var j=32-zt(v)-1;v&=~(1<<j),f+=1;var A=32-zt(l)+j;if(30<A){var Z=j-j%5;A=(v&(1<<Z)-1).toString(32),v>>=Z,j-=Z,ei=1<<32-zt(l)+j|f<<j|v,ti=A+a}else ei=1<<A|f<<j|v,ti=a}function gh(a){a.return!==null&&(oa(a,1),gx(a,1,0))}function xh(a){for(;a===Dc;)Dc=Ya[--Xa],Ya[Xa]=null,Fc=Ya[--Xa],Ya[Xa]=null;for(;a===aa;)aa=Ws[--Vs],Ws[Vs]=null,ti=Ws[--Vs],Ws[Vs]=null,ei=Ws[--Vs],Ws[Vs]=null}var Es=null,Cs=null,qt=!1,ur=null;function xx(a,l){var f=Ys(5,null,null,0);f.elementType="DELETED",f.stateNode=l,f.return=a,l=a.deletions,l===null?(a.deletions=[f],a.flags|=16):l.push(f)}function vx(a,l){switch(a.tag){case 5:var f=a.type;return l=l.nodeType!==1||f.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(a.stateNode=l,Es=a,Cs=Ni(l.firstChild),!0):!1;case 6:return l=a.pendingProps===""||l.nodeType!==3?null:l,l!==null?(a.stateNode=l,Es=a,Cs=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(f=aa!==null?{id:ei,overflow:ti}:null,a.memoizedState={dehydrated:l,treeContext:f,retryLane:1073741824},f=Ys(18,null,null,0),f.stateNode=l,f.return=a,a.child=f,Es=a,Cs=null,!0):!1;default:return!1}}function vh(a){return(a.mode&1)!==0&&(a.flags&128)===0}function yh(a){if(qt){var l=Cs;if(l){var f=l;if(!vx(a,l)){if(vh(a))throw Error(n(418));l=Ni(f.nextSibling);var v=Es;l&&vx(a,l)?xx(v,f):(a.flags=a.flags&-4097|2,qt=!1,Es=a)}}else{if(vh(a))throw Error(n(418));a.flags=a.flags&-4097|2,qt=!1,Es=a}}}function yx(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;Es=a}function Bc(a){if(a!==Es)return!1;if(!qt)return yx(a),qt=!0,!1;var l;if((l=a.tag!==3)&&!(l=a.tag!==5)&&(l=a.type,l=l!=="head"&&l!=="body"&&!uh(a.type,a.memoizedProps)),l&&(l=Cs)){if(vh(a))throw bx(),Error(n(418));for(;l;)xx(a,l),l=Ni(l.nextSibling)}if(yx(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 f=a.data;if(f==="/$"){if(l===0){Cs=Ni(a.nextSibling);break e}l--}else f!=="$"&&f!=="$!"&&f!=="$?"||l++}a=a.nextSibling}Cs=null}}else Cs=Es?Ni(a.stateNode.nextSibling):null;return!0}function bx(){for(var a=Cs;a;)a=Ni(a.nextSibling)}function Qa(){Cs=Es=null,qt=!1}function bh(a){ur===null?ur=[a]:ur.push(a)}var cE=I.ReactCurrentBatchConfig;function al(a,l,f){if(a=f.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(f._owner){if(f=f._owner,f){if(f.tag!==1)throw Error(n(309));var v=f.stateNode}if(!v)throw Error(n(147,a));var j=v,A=""+a;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===A?l.ref:(l=function(Z){var X=j.refs;Z===null?delete X[A]:X[A]=Z},l._stringRef=A,l)}if(typeof a!="string")throw Error(n(284));if(!f._owner)throw Error(n(290,a))}return a}function Uc(a,l){throw a=Object.prototype.toString.call(l),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":a))}function kx(a){var l=a._init;return l(a._payload)}function Nx(a){function l(le,se){if(a){var ce=le.deletions;ce===null?(le.deletions=[se],le.flags|=16):ce.push(se)}}function f(le,se){if(!a)return null;for(;se!==null;)l(le,se),se=se.sibling;return null}function v(le,se){for(le=new Map;se!==null;)se.key!==null?le.set(se.key,se):le.set(se.index,se),se=se.sibling;return le}function j(le,se){return le=Mi(le,se),le.index=0,le.sibling=null,le}function A(le,se,ce){return le.index=ce,a?(ce=le.alternate,ce!==null?(ce=ce.index,ce<se?(le.flags|=2,se):ce):(le.flags|=2,se)):(le.flags|=1048576,se)}function Z(le){return a&&le.alternate===null&&(le.flags|=2),le}function X(le,se,ce,Me){return se===null||se.tag!==6?(se=hf(ce,le.mode,Me),se.return=le,se):(se=j(se,ce),se.return=le,se)}function ee(le,se,ce,Me){var Ye=ce.type;return Ye===U?Ee(le,se,ce.props.children,Me,ce.key):se!==null&&(se.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===M&&kx(Ye)===se.type)?(Me=j(se,ce.props),Me.ref=al(le,se,ce),Me.return=le,Me):(Me=hu(ce.type,ce.key,ce.props,null,le.mode,Me),Me.ref=al(le,se,ce),Me.return=le,Me)}function he(le,se,ce,Me){return se===null||se.tag!==4||se.stateNode.containerInfo!==ce.containerInfo||se.stateNode.implementation!==ce.implementation?(se=ff(ce,le.mode,Me),se.return=le,se):(se=j(se,ce.children||[]),se.return=le,se)}function Ee(le,se,ce,Me,Ye){return se===null||se.tag!==7?(se=ma(ce,le.mode,Me,Ye),se.return=le,se):(se=j(se,ce),se.return=le,se)}function Ce(le,se,ce){if(typeof se=="string"&&se!==""||typeof se=="number")return se=hf(""+se,le.mode,ce),se.return=le,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case L:return ce=hu(se.type,se.key,se.props,null,le.mode,ce),ce.ref=al(le,null,se),ce.return=le,ce;case z:return se=ff(se,le.mode,ce),se.return=le,se;case M:var Me=se._init;return Ce(le,Me(se._payload),ce)}if(et(se)||W(se))return se=ma(se,le.mode,ce,null),se.return=le,se;Uc(le,se)}return null}function _e(le,se,ce,Me){var Ye=se!==null?se.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return Ye!==null?null:X(le,se,""+ce,Me);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case L:return ce.key===Ye?ee(le,se,ce,Me):null;case z:return ce.key===Ye?he(le,se,ce,Me):null;case M:return Ye=ce._init,_e(le,se,Ye(ce._payload),Me)}if(et(ce)||W(ce))return Ye!==null?null:Ee(le,se,ce,Me,null);Uc(le,ce)}return null}function He(le,se,ce,Me,Ye){if(typeof Me=="string"&&Me!==""||typeof Me=="number")return le=le.get(ce)||null,X(se,le,""+Me,Ye);if(typeof Me=="object"&&Me!==null){switch(Me.$$typeof){case L:return le=le.get(Me.key===null?ce:Me.key)||null,ee(se,le,Me,Ye);case z:return le=le.get(Me.key===null?ce:Me.key)||null,he(se,le,Me,Ye);case M:var rt=Me._init;return He(le,se,ce,rt(Me._payload),Ye)}if(et(Me)||W(Me))return le=le.get(ce)||null,Ee(se,le,Me,Ye,null);Uc(se,Me)}return null}function Ve(le,se,ce,Me){for(var Ye=null,rt=null,it=se,lt=se=0,$n=null;it!==null&&lt<ce.length;lt++){it.index>lt?($n=it,it=null):$n=it.sibling;var St=_e(le,it,ce[lt],Me);if(St===null){it===null&&(it=$n);break}a&&it&&St.alternate===null&&l(le,it),se=A(St,se,lt),rt===null?Ye=St:rt.sibling=St,rt=St,it=$n}if(lt===ce.length)return f(le,it),qt&&oa(le,lt),Ye;if(it===null){for(;lt<ce.length;lt++)it=Ce(le,ce[lt],Me),it!==null&&(se=A(it,se,lt),rt===null?Ye=it:rt.sibling=it,rt=it);return qt&&oa(le,lt),Ye}for(it=v(le,it);lt<ce.length;lt++)$n=He(it,le,lt,ce[lt],Me),$n!==null&&(a&&$n.alternate!==null&&it.delete($n.key===null?lt:$n.key),se=A($n,se,lt),rt===null?Ye=$n:rt.sibling=$n,rt=$n);return a&&it.forEach(function(Ri){return l(le,Ri)}),qt&&oa(le,lt),Ye}function Ke(le,se,ce,Me){var Ye=W(ce);if(typeof Ye!="function")throw Error(n(150));if(ce=Ye.call(ce),ce==null)throw Error(n(151));for(var rt=Ye=null,it=se,lt=se=0,$n=null,St=ce.next();it!==null&&!St.done;lt++,St=ce.next()){it.index>lt?($n=it,it=null):$n=it.sibling;var Ri=_e(le,it,St.value,Me);if(Ri===null){it===null&&(it=$n);break}a&&it&&Ri.alternate===null&&l(le,it),se=A(Ri,se,lt),rt===null?Ye=Ri:rt.sibling=Ri,rt=Ri,it=$n}if(St.done)return f(le,it),qt&&oa(le,lt),Ye;if(it===null){for(;!St.done;lt++,St=ce.next())St=Ce(le,St.value,Me),St!==null&&(se=A(St,se,lt),rt===null?Ye=St:rt.sibling=St,rt=St);return qt&&oa(le,lt),Ye}for(it=v(le,it);!St.done;lt++,St=ce.next())St=He(it,le,lt,St.value,Me),St!==null&&(a&&St.alternate!==null&&it.delete(St.key===null?lt:St.key),se=A(St,se,lt),rt===null?Ye=St:rt.sibling=St,rt=St);return a&&it.forEach(function(UE){return l(le,UE)}),qt&&oa(le,lt),Ye}function hn(le,se,ce,Me){if(typeof ce=="object"&&ce!==null&&ce.type===U&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case L:e:{for(var Ye=ce.key,rt=se;rt!==null;){if(rt.key===Ye){if(Ye=ce.type,Ye===U){if(rt.tag===7){f(le,rt.sibling),se=j(rt,ce.props.children),se.return=le,le=se;break e}}else if(rt.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===M&&kx(Ye)===rt.type){f(le,rt.sibling),se=j(rt,ce.props),se.ref=al(le,rt,ce),se.return=le,le=se;break e}f(le,rt);break}else l(le,rt);rt=rt.sibling}ce.type===U?(se=ma(ce.props.children,le.mode,Me,ce.key),se.return=le,le=se):(Me=hu(ce.type,ce.key,ce.props,null,le.mode,Me),Me.ref=al(le,se,ce),Me.return=le,le=Me)}return Z(le);case z:e:{for(rt=ce.key;se!==null;){if(se.key===rt)if(se.tag===4&&se.stateNode.containerInfo===ce.containerInfo&&se.stateNode.implementation===ce.implementation){f(le,se.sibling),se=j(se,ce.children||[]),se.return=le,le=se;break e}else{f(le,se);break}else l(le,se);se=se.sibling}se=ff(ce,le.mode,Me),se.return=le,le=se}return Z(le);case M:return rt=ce._init,hn(le,se,rt(ce._payload),Me)}if(et(ce))return Ve(le,se,ce,Me);if(W(ce))return Ke(le,se,ce,Me);Uc(le,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,se!==null&&se.tag===6?(f(le,se.sibling),se=j(se,ce),se.return=le,le=se):(f(le,se),se=hf(ce,le.mode,Me),se.return=le,le=se),Z(le)):f(le,se)}return hn}var Ja=Nx(!0),wx=Nx(!1),Hc=wi(null),Zc=null,eo=null,kh=null;function Nh(){kh=eo=Zc=null}function wh(a){var l=Hc.current;Ht(Hc),a._currentValue=l}function jh(a,l,f){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===f)break;a=a.return}}function to(a,l){Zc=a,kh=eo=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&l)!==0&&(ms=!0),a.firstContext=null)}function qs(a){var l=a._currentValue;if(kh!==a)if(a={context:a,memoizedValue:l,next:null},eo===null){if(Zc===null)throw Error(n(308));eo=a,Zc.dependencies={lanes:0,firstContext:a}}else eo=eo.next=a;return l}var la=null;function Sh(a){la===null?la=[a]:la.push(a)}function jx(a,l,f,v){var j=l.interleaved;return j===null?(f.next=f,Sh(l)):(f.next=j.next,j.next=f),l.interleaved=f,ni(a,v)}function ni(a,l){a.lanes|=l;var f=a.alternate;for(f!==null&&(f.lanes|=l),f=a,a=a.return;a!==null;)a.childLanes|=l,f=a.alternate,f!==null&&(f.childLanes|=l),f=a,a=a.return;return f.tag===3?f.stateNode:null}var _i=!1;function _h(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sx(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 si(a,l){return{eventTime:a,lane:l,tag:0,payload:null,callback:null,next:null}}function Ei(a,l,f){var v=a.updateQueue;if(v===null)return null;if(v=v.shared,(kt&2)!==0){var j=v.pending;return j===null?l.next=l:(l.next=j.next,j.next=l),v.pending=l,ni(a,f)}return j=v.interleaved,j===null?(l.next=l,Sh(v)):(l.next=j.next,j.next=l),v.interleaved=l,ni(a,f)}function Wc(a,l,f){if(l=l.updateQueue,l!==null&&(l=l.shared,(f&4194240)!==0)){var v=l.lanes;v&=a.pendingLanes,f|=v,l.lanes=f,Zs(a,f)}}function _x(a,l){var f=a.updateQueue,v=a.alternate;if(v!==null&&(v=v.updateQueue,f===v)){var j=null,A=null;if(f=f.firstBaseUpdate,f!==null){do{var Z={eventTime:f.eventTime,lane:f.lane,tag:f.tag,payload:f.payload,callback:f.callback,next:null};A===null?j=A=Z:A=A.next=Z,f=f.next}while(f!==null);A===null?j=A=l:A=A.next=l}else j=A=l;f={baseState:v.baseState,firstBaseUpdate:j,lastBaseUpdate:A,shared:v.shared,effects:v.effects},a.updateQueue=f;return}a=f.lastBaseUpdate,a===null?f.firstBaseUpdate=l:a.next=l,f.lastBaseUpdate=l}function Vc(a,l,f,v){var j=a.updateQueue;_i=!1;var A=j.firstBaseUpdate,Z=j.lastBaseUpdate,X=j.shared.pending;if(X!==null){j.shared.pending=null;var ee=X,he=ee.next;ee.next=null,Z===null?A=he:Z.next=he,Z=ee;var Ee=a.alternate;Ee!==null&&(Ee=Ee.updateQueue,X=Ee.lastBaseUpdate,X!==Z&&(X===null?Ee.firstBaseUpdate=he:X.next=he,Ee.lastBaseUpdate=ee))}if(A!==null){var Ce=j.baseState;Z=0,Ee=he=ee=null,X=A;do{var _e=X.lane,He=X.eventTime;if((v&_e)===_e){Ee!==null&&(Ee=Ee.next={eventTime:He,lane:0,tag:X.tag,payload:X.payload,callback:X.callback,next:null});e:{var Ve=a,Ke=X;switch(_e=l,He=f,Ke.tag){case 1:if(Ve=Ke.payload,typeof Ve=="function"){Ce=Ve.call(He,Ce,_e);break e}Ce=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Ke.payload,_e=typeof Ve=="function"?Ve.call(He,Ce,_e):Ve,_e==null)break e;Ce=K({},Ce,_e);break e;case 2:_i=!0}}X.callback!==null&&X.lane!==0&&(a.flags|=64,_e=j.effects,_e===null?j.effects=[X]:_e.push(X))}else He={eventTime:He,lane:_e,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Ee===null?(he=Ee=He,ee=Ce):Ee=Ee.next=He,Z|=_e;if(X=X.next,X===null){if(X=j.shared.pending,X===null)break;_e=X,X=_e.next,_e.next=null,j.lastBaseUpdate=_e,j.shared.pending=null}}while(!0);if(Ee===null&&(ee=Ce),j.baseState=ee,j.firstBaseUpdate=he,j.lastBaseUpdate=Ee,l=j.shared.interleaved,l!==null){j=l;do Z|=j.lane,j=j.next;while(j!==l)}else A===null&&(j.shared.lanes=0);da|=Z,a.lanes=Z,a.memoizedState=Ce}}function Ex(a,l,f){if(a=l.effects,l.effects=null,a!==null)for(l=0;l<a.length;l++){var v=a[l],j=v.callback;if(j!==null){if(v.callback=null,v=f,typeof j!="function")throw Error(n(191,j));j.call(v)}}}var ol={},Or=wi(ol),ll=wi(ol),cl=wi(ol);function ca(a){if(a===ol)throw Error(n(174));return a}function Eh(a,l){switch(Dt(cl,l),Dt(ll,a),Dt(Or,ol),a=l.nodeType,a){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:an(null,"");break;default:a=a===8?l.parentNode:l,l=a.namespaceURI||null,a=a.tagName,l=an(l,a)}Ht(Or),Dt(Or,l)}function no(){Ht(Or),Ht(ll),Ht(cl)}function Cx(a){ca(cl.current);var l=ca(Or.current),f=an(l,a.type);l!==f&&(Dt(ll,a),Dt(Or,f))}function Ch(a){ll.current===a&&(Ht(Or),Ht(ll))}var Jt=wi(0);function qc(a){for(var l=a;l!==null;){if(l.tag===13){var f=l.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||f.data==="$?"||f.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 Ah=[];function Ih(){for(var a=0;a<Ah.length;a++)Ah[a]._workInProgressVersionPrimary=null;Ah.length=0}var Gc=I.ReactCurrentDispatcher,Th=I.ReactCurrentBatchConfig,ua=0,en=null,_n=null,In=null,Kc=!1,ul=!1,dl=0,uE=0;function qn(){throw Error(n(321))}function $h(a,l){if(l===null)return!1;for(var f=0;f<l.length&&f<a.length;f++)if(!cr(a[f],l[f]))return!1;return!0}function Mh(a,l,f,v,j,A){if(ua=A,en=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,Gc.current=a===null||a.memoizedState===null?pE:mE,a=f(v,j),ul){A=0;do{if(ul=!1,dl=0,25<=A)throw Error(n(301));A+=1,In=_n=null,l.updateQueue=null,Gc.current=gE,a=f(v,j)}while(ul)}if(Gc.current=Qc,l=_n!==null&&_n.next!==null,ua=0,In=_n=en=null,Kc=!1,l)throw Error(n(300));return a}function Rh(){var a=dl!==0;return dl=0,a}function zr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return In===null?en.memoizedState=In=a:In=In.next=a,In}function Gs(){if(_n===null){var a=en.alternate;a=a!==null?a.memoizedState:null}else a=_n.next;var l=In===null?en.memoizedState:In.next;if(l!==null)In=l,_n=a;else{if(a===null)throw Error(n(310));_n=a,a={memoizedState:_n.memoizedState,baseState:_n.baseState,baseQueue:_n.baseQueue,queue:_n.queue,next:null},In===null?en.memoizedState=In=a:In=In.next=a}return In}function hl(a,l){return typeof l=="function"?l(a):l}function Oh(a){var l=Gs(),f=l.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=a;var v=_n,j=v.baseQueue,A=f.pending;if(A!==null){if(j!==null){var Z=j.next;j.next=A.next,A.next=Z}v.baseQueue=j=A,f.pending=null}if(j!==null){A=j.next,v=v.baseState;var X=Z=null,ee=null,he=A;do{var Ee=he.lane;if((ua&Ee)===Ee)ee!==null&&(ee=ee.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),v=he.hasEagerState?he.eagerState:a(v,he.action);else{var Ce={lane:Ee,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};ee===null?(X=ee=Ce,Z=v):ee=ee.next=Ce,en.lanes|=Ee,da|=Ee}he=he.next}while(he!==null&&he!==A);ee===null?Z=v:ee.next=X,cr(v,l.memoizedState)||(ms=!0),l.memoizedState=v,l.baseState=Z,l.baseQueue=ee,f.lastRenderedState=v}if(a=f.interleaved,a!==null){j=a;do A=j.lane,en.lanes|=A,da|=A,j=j.next;while(j!==a)}else j===null&&(f.lanes=0);return[l.memoizedState,f.dispatch]}function zh(a){var l=Gs(),f=l.queue;if(f===null)throw Error(n(311));f.lastRenderedReducer=a;var v=f.dispatch,j=f.pending,A=l.memoizedState;if(j!==null){f.pending=null;var Z=j=j.next;do A=a(A,Z.action),Z=Z.next;while(Z!==j);cr(A,l.memoizedState)||(ms=!0),l.memoizedState=A,l.baseQueue===null&&(l.baseState=A),f.lastRenderedState=A}return[A,v]}function Ax(){}function Ix(a,l){var f=en,v=Gs(),j=l(),A=!cr(v.memoizedState,j);if(A&&(v.memoizedState=j,ms=!0),v=v.queue,Ph(Mx.bind(null,f,v,a),[a]),v.getSnapshot!==l||A||In!==null&&In.memoizedState.tag&1){if(f.flags|=2048,fl(9,$x.bind(null,f,v,j,l),void 0,null),Tn===null)throw Error(n(349));(ua&30)!==0||Tx(f,l,j)}return j}function Tx(a,l,f){a.flags|=16384,a={getSnapshot:l,value:f},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.stores=[a]):(f=l.stores,f===null?l.stores=[a]:f.push(a))}function $x(a,l,f,v){l.value=f,l.getSnapshot=v,Rx(l)&&Ox(a)}function Mx(a,l,f){return f(function(){Rx(l)&&Ox(a)})}function Rx(a){var l=a.getSnapshot;a=a.value;try{var f=l();return!cr(a,f)}catch{return!0}}function Ox(a){var l=ni(a,1);l!==null&&pr(l,a,1,-1)}function zx(a){var l=zr();return typeof a=="function"&&(a=a()),l.memoizedState=l.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:hl,lastRenderedState:a},l.queue=a,a=a.dispatch=fE.bind(null,en,a),[l.memoizedState,a]}function fl(a,l,f,v){return a={tag:a,create:l,destroy:f,deps:v,next:null},l=en.updateQueue,l===null?(l={lastEffect:null,stores:null},en.updateQueue=l,l.lastEffect=a.next=a):(f=l.lastEffect,f===null?l.lastEffect=a.next=a:(v=f.next,f.next=a,a.next=v,l.lastEffect=a)),a}function Px(){return Gs().memoizedState}function Yc(a,l,f,v){var j=zr();en.flags|=a,j.memoizedState=fl(1|l,f,void 0,v===void 0?null:v)}function Xc(a,l,f,v){var j=Gs();v=v===void 0?null:v;var A=void 0;if(_n!==null){var Z=_n.memoizedState;if(A=Z.destroy,v!==null&&$h(v,Z.deps)){j.memoizedState=fl(l,f,A,v);return}}en.flags|=a,j.memoizedState=fl(1|l,f,A,v)}function Lx(a,l){return Yc(8390656,8,a,l)}function Ph(a,l){return Xc(2048,8,a,l)}function Dx(a,l){return Xc(4,2,a,l)}function Fx(a,l){return Xc(4,4,a,l)}function Bx(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 Ux(a,l,f){return f=f!=null?f.concat([a]):null,Xc(4,4,Bx.bind(null,l,a),f)}function Lh(){}function Hx(a,l){var f=Gs();l=l===void 0?null:l;var v=f.memoizedState;return v!==null&&l!==null&&$h(l,v[1])?v[0]:(f.memoizedState=[a,l],a)}function Zx(a,l){var f=Gs();l=l===void 0?null:l;var v=f.memoizedState;return v!==null&&l!==null&&$h(l,v[1])?v[0]:(a=a(),f.memoizedState=[a,l],a)}function Wx(a,l,f){return(ua&21)===0?(a.baseState&&(a.baseState=!1,ms=!0),a.memoizedState=f):(cr(f,l)||(f=bi(),en.lanes|=f,da|=f,a.baseState=!0),l)}function dE(a,l){var f=vt;vt=f!==0&&4>f?f:4,a(!0);var v=Th.transition;Th.transition={};try{a(!1),l()}finally{vt=f,Th.transition=v}}function Vx(){return Gs().memoizedState}function hE(a,l,f){var v=Ti(a);if(f={lane:v,action:f,hasEagerState:!1,eagerState:null,next:null},qx(a))Gx(l,f);else if(f=jx(a,l,f,v),f!==null){var j=ns();pr(f,a,v,j),Kx(f,l,v)}}function fE(a,l,f){var v=Ti(a),j={lane:v,action:f,hasEagerState:!1,eagerState:null,next:null};if(qx(a))Gx(l,j);else{var A=a.alternate;if(a.lanes===0&&(A===null||A.lanes===0)&&(A=l.lastRenderedReducer,A!==null))try{var Z=l.lastRenderedState,X=A(Z,f);if(j.hasEagerState=!0,j.eagerState=X,cr(X,Z)){var ee=l.interleaved;ee===null?(j.next=j,Sh(l)):(j.next=ee.next,ee.next=j),l.interleaved=j;return}}catch{}finally{}f=jx(a,l,j,v),f!==null&&(j=ns(),pr(f,a,v,j),Kx(f,l,v))}}function qx(a){var l=a.alternate;return a===en||l!==null&&l===en}function Gx(a,l){ul=Kc=!0;var f=a.pending;f===null?l.next=l:(l.next=f.next,f.next=l),a.pending=l}function Kx(a,l,f){if((f&4194240)!==0){var v=l.lanes;v&=a.pendingLanes,f|=v,l.lanes=f,Zs(a,f)}}var Qc={readContext:qs,useCallback:qn,useContext:qn,useEffect:qn,useImperativeHandle:qn,useInsertionEffect:qn,useLayoutEffect:qn,useMemo:qn,useReducer:qn,useRef:qn,useState:qn,useDebugValue:qn,useDeferredValue:qn,useTransition:qn,useMutableSource:qn,useSyncExternalStore:qn,useId:qn,unstable_isNewReconciler:!1},pE={readContext:qs,useCallback:function(a,l){return zr().memoizedState=[a,l===void 0?null:l],a},useContext:qs,useEffect:Lx,useImperativeHandle:function(a,l,f){return f=f!=null?f.concat([a]):null,Yc(4194308,4,Bx.bind(null,l,a),f)},useLayoutEffect:function(a,l){return Yc(4194308,4,a,l)},useInsertionEffect:function(a,l){return Yc(4,2,a,l)},useMemo:function(a,l){var f=zr();return l=l===void 0?null:l,a=a(),f.memoizedState=[a,l],a},useReducer:function(a,l,f){var v=zr();return l=f!==void 0?f(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=hE.bind(null,en,a),[v.memoizedState,a]},useRef:function(a){var l=zr();return a={current:a},l.memoizedState=a},useState:zx,useDebugValue:Lh,useDeferredValue:function(a){return zr().memoizedState=a},useTransition:function(){var a=zx(!1),l=a[0];return a=dE.bind(null,a[1]),zr().memoizedState=a,[l,a]},useMutableSource:function(){},useSyncExternalStore:function(a,l,f){var v=en,j=zr();if(qt){if(f===void 0)throw Error(n(407));f=f()}else{if(f=l(),Tn===null)throw Error(n(349));(ua&30)!==0||Tx(v,l,f)}j.memoizedState=f;var A={value:f,getSnapshot:l};return j.queue=A,Lx(Mx.bind(null,v,A,a),[a]),v.flags|=2048,fl(9,$x.bind(null,v,A,f,l),void 0,null),f},useId:function(){var a=zr(),l=Tn.identifierPrefix;if(qt){var f=ti,v=ei;f=(v&~(1<<32-zt(v)-1)).toString(32)+f,l=":"+l+"R"+f,f=dl++,0<f&&(l+="H"+f.toString(32)),l+=":"}else f=uE++,l=":"+l+"r"+f.toString(32)+":";return a.memoizedState=l},unstable_isNewReconciler:!1},mE={readContext:qs,useCallback:Hx,useContext:qs,useEffect:Ph,useImperativeHandle:Ux,useInsertionEffect:Dx,useLayoutEffect:Fx,useMemo:Zx,useReducer:Oh,useRef:Px,useState:function(){return Oh(hl)},useDebugValue:Lh,useDeferredValue:function(a){var l=Gs();return Wx(l,_n.memoizedState,a)},useTransition:function(){var a=Oh(hl)[0],l=Gs().memoizedState;return[a,l]},useMutableSource:Ax,useSyncExternalStore:Ix,useId:Vx,unstable_isNewReconciler:!1},gE={readContext:qs,useCallback:Hx,useContext:qs,useEffect:Ph,useImperativeHandle:Ux,useInsertionEffect:Dx,useLayoutEffect:Fx,useMemo:Zx,useReducer:zh,useRef:Px,useState:function(){return zh(hl)},useDebugValue:Lh,useDeferredValue:function(a){var l=Gs();return _n===null?l.memoizedState=a:Wx(l,_n.memoizedState,a)},useTransition:function(){var a=zh(hl)[0],l=Gs().memoizedState;return[a,l]},useMutableSource:Ax,useSyncExternalStore:Ix,useId:Vx,unstable_isNewReconciler:!1};function dr(a,l){if(a&&a.defaultProps){l=K({},l),a=a.defaultProps;for(var f in a)l[f]===void 0&&(l[f]=a[f]);return l}return l}function Dh(a,l,f,v){l=a.memoizedState,f=f(v,l),f=f==null?l:K({},l,f),a.memoizedState=f,a.lanes===0&&(a.updateQueue.baseState=f)}var Jc={isMounted:function(a){return(a=a._reactInternals)?Zn(a)===a:!1},enqueueSetState:function(a,l,f){a=a._reactInternals;var v=ns(),j=Ti(a),A=si(v,j);A.payload=l,f!=null&&(A.callback=f),l=Ei(a,A,j),l!==null&&(pr(l,a,j,v),Wc(l,a,j))},enqueueReplaceState:function(a,l,f){a=a._reactInternals;var v=ns(),j=Ti(a),A=si(v,j);A.tag=1,A.payload=l,f!=null&&(A.callback=f),l=Ei(a,A,j),l!==null&&(pr(l,a,j,v),Wc(l,a,j))},enqueueForceUpdate:function(a,l){a=a._reactInternals;var f=ns(),v=Ti(a),j=si(f,v);j.tag=2,l!=null&&(j.callback=l),l=Ei(a,j,v),l!==null&&(pr(l,a,v,f),Wc(l,a,v))}};function Yx(a,l,f,v,j,A,Z){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(v,A,Z):l.prototype&&l.prototype.isPureReactComponent?!Jo(f,v)||!Jo(j,A):!0}function Xx(a,l,f){var v=!1,j=ji,A=l.contextType;return typeof A=="object"&&A!==null?A=qs(A):(j=ps(l)?ia:Vn.current,v=l.contextTypes,A=(v=v!=null)?Ka(a,j):ji),l=new l(f,A),a.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=Jc,a.stateNode=l,l._reactInternals=a,v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=j,a.__reactInternalMemoizedMaskedChildContext=A),l}function Qx(a,l,f,v){a=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(f,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(f,v),l.state!==a&&Jc.enqueueReplaceState(l,l.state,null)}function Fh(a,l,f,v){var j=a.stateNode;j.props=f,j.state=a.memoizedState,j.refs={},_h(a);var A=l.contextType;typeof A=="object"&&A!==null?j.context=qs(A):(A=ps(l)?ia:Vn.current,j.context=Ka(a,A)),j.state=a.memoizedState,A=l.getDerivedStateFromProps,typeof A=="function"&&(Dh(a,l,A,f),j.state=a.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(l=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),l!==j.state&&Jc.enqueueReplaceState(j,j.state,null),Vc(a,f,j,v),j.state=a.memoizedState),typeof j.componentDidMount=="function"&&(a.flags|=4194308)}function so(a,l){try{var f="",v=l;do f+=xe(v),v=v.return;while(v);var j=f}catch(A){j=`
39
+ Error generating stack: `+A.message+`
40
+ `+A.stack}return{value:a,source:l,stack:j,digest:null}}function Bh(a,l,f){return{value:a,source:null,stack:f??null,digest:l??null}}function Uh(a,l){try{console.error(l.value)}catch(f){setTimeout(function(){throw f})}}var xE=typeof WeakMap=="function"?WeakMap:Map;function Jx(a,l,f){f=si(-1,f),f.tag=3,f.payload={element:null};var v=l.value;return f.callback=function(){au||(au=!0,sf=v),Uh(a,l)},f}function ev(a,l,f){f=si(-1,f),f.tag=3;var v=a.type.getDerivedStateFromError;if(typeof v=="function"){var j=l.value;f.payload=function(){return v(j)},f.callback=function(){Uh(a,l)}}var A=a.stateNode;return A!==null&&typeof A.componentDidCatch=="function"&&(f.callback=function(){Uh(a,l),typeof v!="function"&&(Ai===null?Ai=new Set([this]):Ai.add(this));var Z=l.stack;this.componentDidCatch(l.value,{componentStack:Z!==null?Z:""})}),f}function tv(a,l,f){var v=a.pingCache;if(v===null){v=a.pingCache=new xE;var j=new Set;v.set(l,j)}else j=v.get(l),j===void 0&&(j=new Set,v.set(l,j));j.has(f)||(j.add(f),a=TE.bind(null,a,l,f),l.then(a,a))}function nv(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 sv(a,l,f,v,j){return(a.mode&1)===0?(a===l?a.flags|=65536:(a.flags|=128,f.flags|=131072,f.flags&=-52805,f.tag===1&&(f.alternate===null?f.tag=17:(l=si(-1,1),l.tag=2,Ei(f,l,1))),f.lanes|=1),a):(a.flags|=65536,a.lanes=j,a)}var vE=I.ReactCurrentOwner,ms=!1;function ts(a,l,f,v){l.child=a===null?wx(l,null,f,v):Ja(l,a.child,f,v)}function rv(a,l,f,v,j){f=f.render;var A=l.ref;return to(l,j),v=Mh(a,l,f,v,A,j),f=Rh(),a!==null&&!ms?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~j,ri(a,l,j)):(qt&&f&&gh(l),l.flags|=1,ts(a,l,v,j),l.child)}function iv(a,l,f,v,j){if(a===null){var A=f.type;return typeof A=="function"&&!df(A)&&A.defaultProps===void 0&&f.compare===null&&f.defaultProps===void 0?(l.tag=15,l.type=A,av(a,l,A,v,j)):(a=hu(f.type,null,v,l,l.mode,j),a.ref=l.ref,a.return=l,l.child=a)}if(A=a.child,(a.lanes&j)===0){var Z=A.memoizedProps;if(f=f.compare,f=f!==null?f:Jo,f(Z,v)&&a.ref===l.ref)return ri(a,l,j)}return l.flags|=1,a=Mi(A,v),a.ref=l.ref,a.return=l,l.child=a}function av(a,l,f,v,j){if(a!==null){var A=a.memoizedProps;if(Jo(A,v)&&a.ref===l.ref)if(ms=!1,l.pendingProps=v=A,(a.lanes&j)!==0)(a.flags&131072)!==0&&(ms=!0);else return l.lanes=a.lanes,ri(a,l,j)}return Hh(a,l,f,v,j)}function ov(a,l,f){var v=l.pendingProps,j=v.children,A=a!==null?a.memoizedState:null;if(v.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},Dt(io,As),As|=f;else{if((f&1073741824)===0)return a=A!==null?A.baseLanes|f:f,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:a,cachePool:null,transitions:null},l.updateQueue=null,Dt(io,As),As|=a,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=A!==null?A.baseLanes:f,Dt(io,As),As|=v}else A!==null?(v=A.baseLanes|f,l.memoizedState=null):v=f,Dt(io,As),As|=v;return ts(a,l,j,f),l.child}function lv(a,l){var f=l.ref;(a===null&&f!==null||a!==null&&a.ref!==f)&&(l.flags|=512,l.flags|=2097152)}function Hh(a,l,f,v,j){var A=ps(f)?ia:Vn.current;return A=Ka(l,A),to(l,j),f=Mh(a,l,f,v,A,j),v=Rh(),a!==null&&!ms?(l.updateQueue=a.updateQueue,l.flags&=-2053,a.lanes&=~j,ri(a,l,j)):(qt&&v&&gh(l),l.flags|=1,ts(a,l,f,j),l.child)}function cv(a,l,f,v,j){if(ps(f)){var A=!0;Pc(l)}else A=!1;if(to(l,j),l.stateNode===null)tu(a,l),Xx(l,f,v),Fh(l,f,v,j),v=!0;else if(a===null){var Z=l.stateNode,X=l.memoizedProps;Z.props=X;var ee=Z.context,he=f.contextType;typeof he=="object"&&he!==null?he=qs(he):(he=ps(f)?ia:Vn.current,he=Ka(l,he));var Ee=f.getDerivedStateFromProps,Ce=typeof Ee=="function"||typeof Z.getSnapshotBeforeUpdate=="function";Ce||typeof Z.UNSAFE_componentWillReceiveProps!="function"&&typeof Z.componentWillReceiveProps!="function"||(X!==v||ee!==he)&&Qx(l,Z,v,he),_i=!1;var _e=l.memoizedState;Z.state=_e,Vc(l,v,Z,j),ee=l.memoizedState,X!==v||_e!==ee||fs.current||_i?(typeof Ee=="function"&&(Dh(l,f,Ee,v),ee=l.memoizedState),(X=_i||Yx(l,f,X,v,_e,ee,he))?(Ce||typeof Z.UNSAFE_componentWillMount!="function"&&typeof Z.componentWillMount!="function"||(typeof Z.componentWillMount=="function"&&Z.componentWillMount(),typeof Z.UNSAFE_componentWillMount=="function"&&Z.UNSAFE_componentWillMount()),typeof Z.componentDidMount=="function"&&(l.flags|=4194308)):(typeof Z.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=v,l.memoizedState=ee),Z.props=v,Z.state=ee,Z.context=he,v=X):(typeof Z.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{Z=l.stateNode,Sx(a,l),X=l.memoizedProps,he=l.type===l.elementType?X:dr(l.type,X),Z.props=he,Ce=l.pendingProps,_e=Z.context,ee=f.contextType,typeof ee=="object"&&ee!==null?ee=qs(ee):(ee=ps(f)?ia:Vn.current,ee=Ka(l,ee));var He=f.getDerivedStateFromProps;(Ee=typeof He=="function"||typeof Z.getSnapshotBeforeUpdate=="function")||typeof Z.UNSAFE_componentWillReceiveProps!="function"&&typeof Z.componentWillReceiveProps!="function"||(X!==Ce||_e!==ee)&&Qx(l,Z,v,ee),_i=!1,_e=l.memoizedState,Z.state=_e,Vc(l,v,Z,j);var Ve=l.memoizedState;X!==Ce||_e!==Ve||fs.current||_i?(typeof He=="function"&&(Dh(l,f,He,v),Ve=l.memoizedState),(he=_i||Yx(l,f,he,v,_e,Ve,ee)||!1)?(Ee||typeof Z.UNSAFE_componentWillUpdate!="function"&&typeof Z.componentWillUpdate!="function"||(typeof Z.componentWillUpdate=="function"&&Z.componentWillUpdate(v,Ve,ee),typeof Z.UNSAFE_componentWillUpdate=="function"&&Z.UNSAFE_componentWillUpdate(v,Ve,ee)),typeof Z.componentDidUpdate=="function"&&(l.flags|=4),typeof Z.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof Z.componentDidUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=4),typeof Z.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=Ve),Z.props=v,Z.state=Ve,Z.context=ee,v=he):(typeof Z.componentDidUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=4),typeof Z.getSnapshotBeforeUpdate!="function"||X===a.memoizedProps&&_e===a.memoizedState||(l.flags|=1024),v=!1)}return Zh(a,l,f,v,A,j)}function Zh(a,l,f,v,j,A){lv(a,l);var Z=(l.flags&128)!==0;if(!v&&!Z)return j&&px(l,f,!1),ri(a,l,A);v=l.stateNode,vE.current=l;var X=Z&&typeof f.getDerivedStateFromError!="function"?null:v.render();return l.flags|=1,a!==null&&Z?(l.child=Ja(l,a.child,null,A),l.child=Ja(l,null,X,A)):ts(a,l,X,A),l.memoizedState=v.state,j&&px(l,f,!0),l.child}function uv(a){var l=a.stateNode;l.pendingContext?hx(a,l.pendingContext,l.pendingContext!==l.context):l.context&&hx(a,l.context,!1),Eh(a,l.containerInfo)}function dv(a,l,f,v,j){return Qa(),bh(j),l.flags|=256,ts(a,l,f,v),l.child}var Wh={dehydrated:null,treeContext:null,retryLane:0};function Vh(a){return{baseLanes:a,cachePool:null,transitions:null}}function hv(a,l,f){var v=l.pendingProps,j=Jt.current,A=!1,Z=(l.flags&128)!==0,X;if((X=Z)||(X=a!==null&&a.memoizedState===null?!1:(j&2)!==0),X?(A=!0,l.flags&=-129):(a===null||a.memoizedState!==null)&&(j|=1),Dt(Jt,j&1),a===null)return yh(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):(Z=v.children,a=v.fallback,A?(v=l.mode,A=l.child,Z={mode:"hidden",children:Z},(v&1)===0&&A!==null?(A.childLanes=0,A.pendingProps=Z):A=fu(Z,v,0,null),a=ma(a,v,f,null),A.return=l,a.return=l,A.sibling=a,l.child=A,l.child.memoizedState=Vh(f),l.memoizedState=Wh,a):qh(l,Z));if(j=a.memoizedState,j!==null&&(X=j.dehydrated,X!==null))return yE(a,l,Z,v,X,j,f);if(A){A=v.fallback,Z=l.mode,j=a.child,X=j.sibling;var ee={mode:"hidden",children:v.children};return(Z&1)===0&&l.child!==j?(v=l.child,v.childLanes=0,v.pendingProps=ee,l.deletions=null):(v=Mi(j,ee),v.subtreeFlags=j.subtreeFlags&14680064),X!==null?A=Mi(X,A):(A=ma(A,Z,f,null),A.flags|=2),A.return=l,v.return=l,v.sibling=A,l.child=v,v=A,A=l.child,Z=a.child.memoizedState,Z=Z===null?Vh(f):{baseLanes:Z.baseLanes|f,cachePool:null,transitions:Z.transitions},A.memoizedState=Z,A.childLanes=a.childLanes&~f,l.memoizedState=Wh,v}return A=a.child,a=A.sibling,v=Mi(A,{mode:"visible",children:v.children}),(l.mode&1)===0&&(v.lanes=f),v.return=l,v.sibling=null,a!==null&&(f=l.deletions,f===null?(l.deletions=[a],l.flags|=16):f.push(a)),l.child=v,l.memoizedState=null,v}function qh(a,l){return l=fu({mode:"visible",children:l},a.mode,0,null),l.return=a,a.child=l}function eu(a,l,f,v){return v!==null&&bh(v),Ja(l,a.child,null,f),a=qh(l,l.pendingProps.children),a.flags|=2,l.memoizedState=null,a}function yE(a,l,f,v,j,A,Z){if(f)return l.flags&256?(l.flags&=-257,v=Bh(Error(n(422))),eu(a,l,Z,v)):l.memoizedState!==null?(l.child=a.child,l.flags|=128,null):(A=v.fallback,j=l.mode,v=fu({mode:"visible",children:v.children},j,0,null),A=ma(A,j,Z,null),A.flags|=2,v.return=l,A.return=l,v.sibling=A,l.child=v,(l.mode&1)!==0&&Ja(l,a.child,null,Z),l.child.memoizedState=Vh(Z),l.memoizedState=Wh,A);if((l.mode&1)===0)return eu(a,l,Z,null);if(j.data==="$!"){if(v=j.nextSibling&&j.nextSibling.dataset,v)var X=v.dgst;return v=X,A=Error(n(419)),v=Bh(A,v,void 0),eu(a,l,Z,v)}if(X=(Z&a.childLanes)!==0,ms||X){if(v=Tn,v!==null){switch(Z&-Z){case 4:j=2;break;case 16:j=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:j=32;break;case 536870912:j=268435456;break;default:j=0}j=(j&(v.suspendedLanes|Z))!==0?0:j,j!==0&&j!==A.retryLane&&(A.retryLane=j,ni(a,j),pr(v,a,j,-1))}return uf(),v=Bh(Error(n(421))),eu(a,l,Z,v)}return j.data==="$?"?(l.flags|=128,l.child=a.child,l=$E.bind(null,a),j._reactRetry=l,null):(a=A.treeContext,Cs=Ni(j.nextSibling),Es=l,qt=!0,ur=null,a!==null&&(Ws[Vs++]=ei,Ws[Vs++]=ti,Ws[Vs++]=aa,ei=a.id,ti=a.overflow,aa=l),l=qh(l,v.children),l.flags|=4096,l)}function fv(a,l,f){a.lanes|=l;var v=a.alternate;v!==null&&(v.lanes|=l),jh(a.return,l,f)}function Gh(a,l,f,v,j){var A=a.memoizedState;A===null?a.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:f,tailMode:j}:(A.isBackwards=l,A.rendering=null,A.renderingStartTime=0,A.last=v,A.tail=f,A.tailMode=j)}function pv(a,l,f){var v=l.pendingProps,j=v.revealOrder,A=v.tail;if(ts(a,l,v.children,f),v=Jt.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&&fv(a,f,l);else if(a.tag===19)fv(a,f,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(Dt(Jt,v),(l.mode&1)===0)l.memoizedState=null;else switch(j){case"forwards":for(f=l.child,j=null;f!==null;)a=f.alternate,a!==null&&qc(a)===null&&(j=f),f=f.sibling;f=j,f===null?(j=l.child,l.child=null):(j=f.sibling,f.sibling=null),Gh(l,!1,j,f,A);break;case"backwards":for(f=null,j=l.child,l.child=null;j!==null;){if(a=j.alternate,a!==null&&qc(a)===null){l.child=j;break}a=j.sibling,j.sibling=f,f=j,j=a}Gh(l,!0,f,null,A);break;case"together":Gh(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function tu(a,l){(l.mode&1)===0&&a!==null&&(a.alternate=null,l.alternate=null,l.flags|=2)}function ri(a,l,f){if(a!==null&&(l.dependencies=a.dependencies),da|=l.lanes,(f&l.childLanes)===0)return null;if(a!==null&&l.child!==a.child)throw Error(n(153));if(l.child!==null){for(a=l.child,f=Mi(a,a.pendingProps),l.child=f,f.return=l;a.sibling!==null;)a=a.sibling,f=f.sibling=Mi(a,a.pendingProps),f.return=l;f.sibling=null}return l.child}function bE(a,l,f){switch(l.tag){case 3:uv(l),Qa();break;case 5:Cx(l);break;case 1:ps(l.type)&&Pc(l);break;case 4:Eh(l,l.stateNode.containerInfo);break;case 10:var v=l.type._context,j=l.memoizedProps.value;Dt(Hc,v._currentValue),v._currentValue=j;break;case 13:if(v=l.memoizedState,v!==null)return v.dehydrated!==null?(Dt(Jt,Jt.current&1),l.flags|=128,null):(f&l.child.childLanes)!==0?hv(a,l,f):(Dt(Jt,Jt.current&1),a=ri(a,l,f),a!==null?a.sibling:null);Dt(Jt,Jt.current&1);break;case 19:if(v=(f&l.childLanes)!==0,(a.flags&128)!==0){if(v)return pv(a,l,f);l.flags|=128}if(j=l.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),Dt(Jt,Jt.current),v)break;return null;case 22:case 23:return l.lanes=0,ov(a,l,f)}return ri(a,l,f)}var mv,Kh,gv,xv;mv=function(a,l){for(var f=l.child;f!==null;){if(f.tag===5||f.tag===6)a.appendChild(f.stateNode);else if(f.tag!==4&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===l)break;for(;f.sibling===null;){if(f.return===null||f.return===l)return;f=f.return}f.sibling.return=f.return,f=f.sibling}},Kh=function(){},gv=function(a,l,f,v){var j=a.memoizedProps;if(j!==v){a=l.stateNode,ca(Or.current);var A=null;switch(f){case"input":j=pe(a,j),v=pe(a,v),A=[];break;case"select":j=K({},j,{value:void 0}),v=K({},v,{value:void 0}),A=[];break;case"textarea":j=zn(a,j),v=zn(a,v),A=[];break;default:typeof j.onClick!="function"&&typeof v.onClick=="function"&&(a.onclick=Rc)}Ls(f,v);var Z;f=null;for(he in j)if(!v.hasOwnProperty(he)&&j.hasOwnProperty(he)&&j[he]!=null)if(he==="style"){var X=j[he];for(Z in X)X.hasOwnProperty(Z)&&(f||(f={}),f[Z]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(i.hasOwnProperty(he)?A||(A=[]):(A=A||[]).push(he,null));for(he in v){var ee=v[he];if(X=j!=null?j[he]:void 0,v.hasOwnProperty(he)&&ee!==X&&(ee!=null||X!=null))if(he==="style")if(X){for(Z in X)!X.hasOwnProperty(Z)||ee&&ee.hasOwnProperty(Z)||(f||(f={}),f[Z]="");for(Z in ee)ee.hasOwnProperty(Z)&&X[Z]!==ee[Z]&&(f||(f={}),f[Z]=ee[Z])}else f||(A||(A=[]),A.push(he,f)),f=ee;else he==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,X=X?X.__html:void 0,ee!=null&&X!==ee&&(A=A||[]).push(he,ee)):he==="children"?typeof ee!="string"&&typeof ee!="number"||(A=A||[]).push(he,""+ee):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(i.hasOwnProperty(he)?(ee!=null&&he==="onScroll"&&Ut("scroll",a),A||X===ee||(A=[])):(A=A||[]).push(he,ee))}f&&(A=A||[]).push("style",f);var he=A;(l.updateQueue=he)&&(l.flags|=4)}},xv=function(a,l,f,v){f!==v&&(l.flags|=4)};function pl(a,l){if(!qt)switch(a.tailMode){case"hidden":l=a.tail;for(var f=null;l!==null;)l.alternate!==null&&(f=l),l=l.sibling;f===null?a.tail=null:f.sibling=null;break;case"collapsed":f=a.tail;for(var v=null;f!==null;)f.alternate!==null&&(v=f),f=f.sibling;v===null?l||a.tail===null?a.tail=null:a.tail.sibling=null:v.sibling=null}}function Gn(a){var l=a.alternate!==null&&a.alternate.child===a.child,f=0,v=0;if(l)for(var j=a.child;j!==null;)f|=j.lanes|j.childLanes,v|=j.subtreeFlags&14680064,v|=j.flags&14680064,j.return=a,j=j.sibling;else for(j=a.child;j!==null;)f|=j.lanes|j.childLanes,v|=j.subtreeFlags,v|=j.flags,j.return=a,j=j.sibling;return a.subtreeFlags|=v,a.childLanes=f,l}function kE(a,l,f){var v=l.pendingProps;switch(xh(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gn(l),null;case 1:return ps(l.type)&&zc(),Gn(l),null;case 3:return v=l.stateNode,no(),Ht(fs),Ht(Vn),Ih(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(a===null||a.child===null)&&(Bc(l)?l.flags|=4:a===null||a.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,ur!==null&&(of(ur),ur=null))),Kh(a,l),Gn(l),null;case 5:Ch(l);var j=ca(cl.current);if(f=l.type,a!==null&&l.stateNode!=null)gv(a,l,f,v,j),a.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!v){if(l.stateNode===null)throw Error(n(166));return Gn(l),null}if(a=ca(Or.current),Bc(l)){v=l.stateNode,f=l.type;var A=l.memoizedProps;switch(v[Rr]=l,v[rl]=A,a=(l.mode&1)!==0,f){case"dialog":Ut("cancel",v),Ut("close",v);break;case"iframe":case"object":case"embed":Ut("load",v);break;case"video":case"audio":for(j=0;j<tl.length;j++)Ut(tl[j],v);break;case"source":Ut("error",v);break;case"img":case"image":case"link":Ut("error",v),Ut("load",v);break;case"details":Ut("toggle",v);break;case"input":Le(v,A),Ut("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!A.multiple},Ut("invalid",v);break;case"textarea":sn(v,A),Ut("invalid",v)}Ls(f,A),j=null;for(var Z in A)if(A.hasOwnProperty(Z)){var X=A[Z];Z==="children"?typeof X=="string"?v.textContent!==X&&(A.suppressHydrationWarning!==!0&&Mc(v.textContent,X,a),j=["children",X]):typeof X=="number"&&v.textContent!==""+X&&(A.suppressHydrationWarning!==!0&&Mc(v.textContent,X,a),j=["children",""+X]):i.hasOwnProperty(Z)&&X!=null&&Z==="onScroll"&&Ut("scroll",v)}switch(f){case"input":de(v),Ae(v,A,!0);break;case"textarea":de(v),cn(v);break;case"select":case"option":break;default:typeof A.onClick=="function"&&(v.onclick=Rc)}v=j,l.updateQueue=v,v!==null&&(l.flags|=4)}else{Z=j.nodeType===9?j:j.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=rn(f)),a==="http://www.w3.org/1999/xhtml"?f==="script"?(a=Z.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof v.is=="string"?a=Z.createElement(f,{is:v.is}):(a=Z.createElement(f),f==="select"&&(Z=a,v.multiple?Z.multiple=!0:v.size&&(Z.size=v.size))):a=Z.createElementNS(a,f),a[Rr]=l,a[rl]=v,mv(a,l,!1,!1),l.stateNode=a;e:{switch(Z=Ds(f,v),f){case"dialog":Ut("cancel",a),Ut("close",a),j=v;break;case"iframe":case"object":case"embed":Ut("load",a),j=v;break;case"video":case"audio":for(j=0;j<tl.length;j++)Ut(tl[j],a);j=v;break;case"source":Ut("error",a),j=v;break;case"img":case"image":case"link":Ut("error",a),Ut("load",a),j=v;break;case"details":Ut("toggle",a),j=v;break;case"input":Le(a,v),j=pe(a,v),Ut("invalid",a);break;case"option":j=v;break;case"select":a._wrapperState={wasMultiple:!!v.multiple},j=K({},v,{value:void 0}),Ut("invalid",a);break;case"textarea":sn(a,v),j=zn(a,v),Ut("invalid",a);break;default:j=v}Ls(f,j),X=j;for(A in X)if(X.hasOwnProperty(A)){var ee=X[A];A==="style"?tr(a,ee):A==="dangerouslySetInnerHTML"?(ee=ee?ee.__html:void 0,ee!=null&&Un(a,ee)):A==="children"?typeof ee=="string"?(f!=="textarea"||ee!=="")&&Nn(a,ee):typeof ee=="number"&&Nn(a,""+ee):A!=="suppressContentEditableWarning"&&A!=="suppressHydrationWarning"&&A!=="autoFocus"&&(i.hasOwnProperty(A)?ee!=null&&A==="onScroll"&&Ut("scroll",a):ee!=null&&k(a,A,ee,Z))}switch(f){case"input":de(a),Ae(a,v,!1);break;case"textarea":de(a),cn(a);break;case"option":v.value!=null&&a.setAttribute("value",""+ie(v.value));break;case"select":a.multiple=!!v.multiple,A=v.value,A!=null?jt(a,!!v.multiple,A,!1):v.defaultValue!=null&&jt(a,!!v.multiple,v.defaultValue,!0);break;default:typeof j.onClick=="function"&&(a.onclick=Rc)}switch(f){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 Gn(l),null;case 6:if(a&&l.stateNode!=null)xv(a,l,a.memoizedProps,v);else{if(typeof v!="string"&&l.stateNode===null)throw Error(n(166));if(f=ca(cl.current),ca(Or.current),Bc(l)){if(v=l.stateNode,f=l.memoizedProps,v[Rr]=l,(A=v.nodeValue!==f)&&(a=Es,a!==null))switch(a.tag){case 3:Mc(v.nodeValue,f,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Mc(v.nodeValue,f,(a.mode&1)!==0)}A&&(l.flags|=4)}else v=(f.nodeType===9?f:f.ownerDocument).createTextNode(v),v[Rr]=l,l.stateNode=v}return Gn(l),null;case 13:if(Ht(Jt),v=l.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(qt&&Cs!==null&&(l.mode&1)!==0&&(l.flags&128)===0)bx(),Qa(),l.flags|=98560,A=!1;else if(A=Bc(l),v!==null&&v.dehydrated!==null){if(a===null){if(!A)throw Error(n(318));if(A=l.memoizedState,A=A!==null?A.dehydrated:null,!A)throw Error(n(317));A[Rr]=l}else Qa(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;Gn(l),A=!1}else ur!==null&&(of(ur),ur=null),A=!0;if(!A)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=f,l):(v=v!==null,v!==(a!==null&&a.memoizedState!==null)&&v&&(l.child.flags|=8192,(l.mode&1)!==0&&(a===null||(Jt.current&1)!==0?En===0&&(En=3):uf())),l.updateQueue!==null&&(l.flags|=4),Gn(l),null);case 4:return no(),Kh(a,l),a===null&&nl(l.stateNode.containerInfo),Gn(l),null;case 10:return wh(l.type._context),Gn(l),null;case 17:return ps(l.type)&&zc(),Gn(l),null;case 19:if(Ht(Jt),A=l.memoizedState,A===null)return Gn(l),null;if(v=(l.flags&128)!==0,Z=A.rendering,Z===null)if(v)pl(A,!1);else{if(En!==0||a!==null&&(a.flags&128)!==0)for(a=l.child;a!==null;){if(Z=qc(a),Z!==null){for(l.flags|=128,pl(A,!1),v=Z.updateQueue,v!==null&&(l.updateQueue=v,l.flags|=4),l.subtreeFlags=0,v=f,f=l.child;f!==null;)A=f,a=v,A.flags&=14680066,Z=A.alternate,Z===null?(A.childLanes=0,A.lanes=a,A.child=null,A.subtreeFlags=0,A.memoizedProps=null,A.memoizedState=null,A.updateQueue=null,A.dependencies=null,A.stateNode=null):(A.childLanes=Z.childLanes,A.lanes=Z.lanes,A.child=Z.child,A.subtreeFlags=0,A.deletions=null,A.memoizedProps=Z.memoizedProps,A.memoizedState=Z.memoizedState,A.updateQueue=Z.updateQueue,A.type=Z.type,a=Z.dependencies,A.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),f=f.sibling;return Dt(Jt,Jt.current&1|2),l.child}a=a.sibling}A.tail!==null&&Ot()>ao&&(l.flags|=128,v=!0,pl(A,!1),l.lanes=4194304)}else{if(!v)if(a=qc(Z),a!==null){if(l.flags|=128,v=!0,f=a.updateQueue,f!==null&&(l.updateQueue=f,l.flags|=4),pl(A,!0),A.tail===null&&A.tailMode==="hidden"&&!Z.alternate&&!qt)return Gn(l),null}else 2*Ot()-A.renderingStartTime>ao&&f!==1073741824&&(l.flags|=128,v=!0,pl(A,!1),l.lanes=4194304);A.isBackwards?(Z.sibling=l.child,l.child=Z):(f=A.last,f!==null?f.sibling=Z:l.child=Z,A.last=Z)}return A.tail!==null?(l=A.tail,A.rendering=l,A.tail=l.sibling,A.renderingStartTime=Ot(),l.sibling=null,f=Jt.current,Dt(Jt,v?f&1|2:f&1),l):(Gn(l),null);case 22:case 23:return cf(),v=l.memoizedState!==null,a!==null&&a.memoizedState!==null!==v&&(l.flags|=8192),v&&(l.mode&1)!==0?(As&1073741824)!==0&&(Gn(l),l.subtreeFlags&6&&(l.flags|=8192)):Gn(l),null;case 24:return null;case 25:return null}throw Error(n(156,l.tag))}function NE(a,l){switch(xh(l),l.tag){case 1:return ps(l.type)&&zc(),a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 3:return no(),Ht(fs),Ht(Vn),Ih(),a=l.flags,(a&65536)!==0&&(a&128)===0?(l.flags=a&-65537|128,l):null;case 5:return Ch(l),null;case 13:if(Ht(Jt),a=l.memoizedState,a!==null&&a.dehydrated!==null){if(l.alternate===null)throw Error(n(340));Qa()}return a=l.flags,a&65536?(l.flags=a&-65537|128,l):null;case 19:return Ht(Jt),null;case 4:return no(),null;case 10:return wh(l.type._context),null;case 22:case 23:return cf(),null;case 24:return null;default:return null}}var nu=!1,Kn=!1,wE=typeof WeakSet=="function"?WeakSet:Set,We=null;function ro(a,l){var f=a.ref;if(f!==null)if(typeof f=="function")try{f(null)}catch(v){on(a,l,v)}else f.current=null}function Yh(a,l,f){try{f()}catch(v){on(a,l,v)}}var vv=!1;function jE(a,l){if(lh=nt,a=Yg(),eh(a)){if("selectionStart"in a)var f={start:a.selectionStart,end:a.selectionEnd};else e:{f=(f=a.ownerDocument)&&f.defaultView||window;var v=f.getSelection&&f.getSelection();if(v&&v.rangeCount!==0){f=v.anchorNode;var j=v.anchorOffset,A=v.focusNode;v=v.focusOffset;try{f.nodeType,A.nodeType}catch{f=null;break e}var Z=0,X=-1,ee=-1,he=0,Ee=0,Ce=a,_e=null;t:for(;;){for(var He;Ce!==f||j!==0&&Ce.nodeType!==3||(X=Z+j),Ce!==A||v!==0&&Ce.nodeType!==3||(ee=Z+v),Ce.nodeType===3&&(Z+=Ce.nodeValue.length),(He=Ce.firstChild)!==null;)_e=Ce,Ce=He;for(;;){if(Ce===a)break t;if(_e===f&&++he===j&&(X=Z),_e===A&&++Ee===v&&(ee=Z),(He=Ce.nextSibling)!==null)break;Ce=_e,_e=Ce.parentNode}Ce=He}f=X===-1||ee===-1?null:{start:X,end:ee}}else f=null}f=f||{start:0,end:0}}else f=null;for(ch={focusedElem:a,selectionRange:f},nt=!1,We=l;We!==null;)if(l=We,a=l.child,(l.subtreeFlags&1028)!==0&&a!==null)a.return=l,We=a;else for(;We!==null;){l=We;try{var Ve=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(Ve!==null){var Ke=Ve.memoizedProps,hn=Ve.memoizedState,le=l.stateNode,se=le.getSnapshotBeforeUpdate(l.elementType===l.type?Ke:dr(l.type,Ke),hn);le.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var ce=l.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Me){on(l,l.return,Me)}if(a=l.sibling,a!==null){a.return=l.return,We=a;break}We=l.return}return Ve=vv,vv=!1,Ve}function ml(a,l,f){var v=l.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var j=v=v.next;do{if((j.tag&a)===a){var A=j.destroy;j.destroy=void 0,A!==void 0&&Yh(l,f,A)}j=j.next}while(j!==v)}}function su(a,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var f=l=l.next;do{if((f.tag&a)===a){var v=f.create;f.destroy=v()}f=f.next}while(f!==l)}}function Xh(a){var l=a.ref;if(l!==null){var f=a.stateNode;switch(a.tag){case 5:a=f;break;default:a=f}typeof l=="function"?l(a):l.current=a}}function yv(a){var l=a.alternate;l!==null&&(a.alternate=null,yv(l)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(l=a.stateNode,l!==null&&(delete l[Rr],delete l[rl],delete l[fh],delete l[aE],delete l[oE])),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 bv(a){return a.tag===5||a.tag===3||a.tag===4}function kv(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||bv(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 Qh(a,l,f){var v=a.tag;if(v===5||v===6)a=a.stateNode,l?f.nodeType===8?f.parentNode.insertBefore(a,l):f.insertBefore(a,l):(f.nodeType===8?(l=f.parentNode,l.insertBefore(a,f)):(l=f,l.appendChild(a)),f=f._reactRootContainer,f!=null||l.onclick!==null||(l.onclick=Rc));else if(v!==4&&(a=a.child,a!==null))for(Qh(a,l,f),a=a.sibling;a!==null;)Qh(a,l,f),a=a.sibling}function Jh(a,l,f){var v=a.tag;if(v===5||v===6)a=a.stateNode,l?f.insertBefore(a,l):f.appendChild(a);else if(v!==4&&(a=a.child,a!==null))for(Jh(a,l,f),a=a.sibling;a!==null;)Jh(a,l,f),a=a.sibling}var Pn=null,hr=!1;function Ci(a,l,f){for(f=f.child;f!==null;)Nv(a,l,f),f=f.sibling}function Nv(a,l,f){if(ht&&typeof ht.onCommitFiberUnmount=="function")try{ht.onCommitFiberUnmount(ct,f)}catch{}switch(f.tag){case 5:Kn||ro(f,l);case 6:var v=Pn,j=hr;Pn=null,Ci(a,l,f),Pn=v,hr=j,Pn!==null&&(hr?(a=Pn,f=f.stateNode,a.nodeType===8?a.parentNode.removeChild(f):a.removeChild(f)):Pn.removeChild(f.stateNode));break;case 18:Pn!==null&&(hr?(a=Pn,f=f.stateNode,a.nodeType===8?hh(a.parentNode,f):a.nodeType===1&&hh(a,f),ke(a)):hh(Pn,f.stateNode));break;case 4:v=Pn,j=hr,Pn=f.stateNode.containerInfo,hr=!0,Ci(a,l,f),Pn=v,hr=j;break;case 0:case 11:case 14:case 15:if(!Kn&&(v=f.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){j=v=v.next;do{var A=j,Z=A.destroy;A=A.tag,Z!==void 0&&((A&2)!==0||(A&4)!==0)&&Yh(f,l,Z),j=j.next}while(j!==v)}Ci(a,l,f);break;case 1:if(!Kn&&(ro(f,l),v=f.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=f.memoizedProps,v.state=f.memoizedState,v.componentWillUnmount()}catch(X){on(f,l,X)}Ci(a,l,f);break;case 21:Ci(a,l,f);break;case 22:f.mode&1?(Kn=(v=Kn)||f.memoizedState!==null,Ci(a,l,f),Kn=v):Ci(a,l,f);break;default:Ci(a,l,f)}}function wv(a){var l=a.updateQueue;if(l!==null){a.updateQueue=null;var f=a.stateNode;f===null&&(f=a.stateNode=new wE),l.forEach(function(v){var j=ME.bind(null,a,v);f.has(v)||(f.add(v),v.then(j,j))})}}function fr(a,l){var f=l.deletions;if(f!==null)for(var v=0;v<f.length;v++){var j=f[v];try{var A=a,Z=l,X=Z;e:for(;X!==null;){switch(X.tag){case 5:Pn=X.stateNode,hr=!1;break e;case 3:Pn=X.stateNode.containerInfo,hr=!0;break e;case 4:Pn=X.stateNode.containerInfo,hr=!0;break e}X=X.return}if(Pn===null)throw Error(n(160));Nv(A,Z,j),Pn=null,hr=!1;var ee=j.alternate;ee!==null&&(ee.return=null),j.return=null}catch(he){on(j,l,he)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)jv(l,a),l=l.sibling}function jv(a,l){var f=a.alternate,v=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(fr(l,a),Pr(a),v&4){try{ml(3,a,a.return),su(3,a)}catch(Ke){on(a,a.return,Ke)}try{ml(5,a,a.return)}catch(Ke){on(a,a.return,Ke)}}break;case 1:fr(l,a),Pr(a),v&512&&f!==null&&ro(f,f.return);break;case 5:if(fr(l,a),Pr(a),v&512&&f!==null&&ro(f,f.return),a.flags&32){var j=a.stateNode;try{Nn(j,"")}catch(Ke){on(a,a.return,Ke)}}if(v&4&&(j=a.stateNode,j!=null)){var A=a.memoizedProps,Z=f!==null?f.memoizedProps:A,X=a.type,ee=a.updateQueue;if(a.updateQueue=null,ee!==null)try{X==="input"&&A.type==="radio"&&A.name!=null&&Te(j,A),Ds(X,Z);var he=Ds(X,A);for(Z=0;Z<ee.length;Z+=2){var Ee=ee[Z],Ce=ee[Z+1];Ee==="style"?tr(j,Ce):Ee==="dangerouslySetInnerHTML"?Un(j,Ce):Ee==="children"?Nn(j,Ce):k(j,Ee,Ce,he)}switch(X){case"input":Ge(j,A);break;case"textarea":ln(j,A);break;case"select":var _e=j._wrapperState.wasMultiple;j._wrapperState.wasMultiple=!!A.multiple;var He=A.value;He!=null?jt(j,!!A.multiple,He,!1):_e!==!!A.multiple&&(A.defaultValue!=null?jt(j,!!A.multiple,A.defaultValue,!0):jt(j,!!A.multiple,A.multiple?[]:"",!1))}j[rl]=A}catch(Ke){on(a,a.return,Ke)}}break;case 6:if(fr(l,a),Pr(a),v&4){if(a.stateNode===null)throw Error(n(162));j=a.stateNode,A=a.memoizedProps;try{j.nodeValue=A}catch(Ke){on(a,a.return,Ke)}}break;case 3:if(fr(l,a),Pr(a),v&4&&f!==null&&f.memoizedState.isDehydrated)try{ke(l.containerInfo)}catch(Ke){on(a,a.return,Ke)}break;case 4:fr(l,a),Pr(a);break;case 13:fr(l,a),Pr(a),j=a.child,j.flags&8192&&(A=j.memoizedState!==null,j.stateNode.isHidden=A,!A||j.alternate!==null&&j.alternate.memoizedState!==null||(nf=Ot())),v&4&&wv(a);break;case 22:if(Ee=f!==null&&f.memoizedState!==null,a.mode&1?(Kn=(he=Kn)||Ee,fr(l,a),Kn=he):fr(l,a),Pr(a),v&8192){if(he=a.memoizedState!==null,(a.stateNode.isHidden=he)&&!Ee&&(a.mode&1)!==0)for(We=a,Ee=a.child;Ee!==null;){for(Ce=We=Ee;We!==null;){switch(_e=We,He=_e.child,_e.tag){case 0:case 11:case 14:case 15:ml(4,_e,_e.return);break;case 1:ro(_e,_e.return);var Ve=_e.stateNode;if(typeof Ve.componentWillUnmount=="function"){v=_e,f=_e.return;try{l=v,Ve.props=l.memoizedProps,Ve.state=l.memoizedState,Ve.componentWillUnmount()}catch(Ke){on(v,f,Ke)}}break;case 5:ro(_e,_e.return);break;case 22:if(_e.memoizedState!==null){Ev(Ce);continue}}He!==null?(He.return=_e,We=He):Ev(Ce)}Ee=Ee.sibling}e:for(Ee=null,Ce=a;;){if(Ce.tag===5){if(Ee===null){Ee=Ce;try{j=Ce.stateNode,he?(A=j.style,typeof A.setProperty=="function"?A.setProperty("display","none","important"):A.display="none"):(X=Ce.stateNode,ee=Ce.memoizedProps.style,Z=ee!=null&&ee.hasOwnProperty("display")?ee.display:null,X.style.display=er("display",Z))}catch(Ke){on(a,a.return,Ke)}}}else if(Ce.tag===6){if(Ee===null)try{Ce.stateNode.nodeValue=he?"":Ce.memoizedProps}catch(Ke){on(a,a.return,Ke)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===a)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===a)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===a)break e;Ee===Ce&&(Ee=null),Ce=Ce.return}Ee===Ce&&(Ee=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:fr(l,a),Pr(a),v&4&&wv(a);break;case 21:break;default:fr(l,a),Pr(a)}}function Pr(a){var l=a.flags;if(l&2){try{e:{for(var f=a.return;f!==null;){if(bv(f)){var v=f;break e}f=f.return}throw Error(n(160))}switch(v.tag){case 5:var j=v.stateNode;v.flags&32&&(Nn(j,""),v.flags&=-33);var A=kv(a);Jh(a,A,j);break;case 3:case 4:var Z=v.stateNode.containerInfo,X=kv(a);Qh(a,X,Z);break;default:throw Error(n(161))}}catch(ee){on(a,a.return,ee)}a.flags&=-3}l&4096&&(a.flags&=-4097)}function SE(a,l,f){We=a,Sv(a)}function Sv(a,l,f){for(var v=(a.mode&1)!==0;We!==null;){var j=We,A=j.child;if(j.tag===22&&v){var Z=j.memoizedState!==null||nu;if(!Z){var X=j.alternate,ee=X!==null&&X.memoizedState!==null||Kn;X=nu;var he=Kn;if(nu=Z,(Kn=ee)&&!he)for(We=j;We!==null;)Z=We,ee=Z.child,Z.tag===22&&Z.memoizedState!==null?Cv(j):ee!==null?(ee.return=Z,We=ee):Cv(j);for(;A!==null;)We=A,Sv(A),A=A.sibling;We=j,nu=X,Kn=he}_v(a)}else(j.subtreeFlags&8772)!==0&&A!==null?(A.return=j,We=A):_v(a)}}function _v(a){for(;We!==null;){var l=We;if((l.flags&8772)!==0){var f=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:Kn||su(5,l);break;case 1:var v=l.stateNode;if(l.flags&4&&!Kn)if(f===null)v.componentDidMount();else{var j=l.elementType===l.type?f.memoizedProps:dr(l.type,f.memoizedProps);v.componentDidUpdate(j,f.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var A=l.updateQueue;A!==null&&Ex(l,A,v);break;case 3:var Z=l.updateQueue;if(Z!==null){if(f=null,l.child!==null)switch(l.child.tag){case 5:f=l.child.stateNode;break;case 1:f=l.child.stateNode}Ex(l,Z,f)}break;case 5:var X=l.stateNode;if(f===null&&l.flags&4){f=X;var ee=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ee.autoFocus&&f.focus();break;case"img":ee.src&&(f.src=ee.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var he=l.alternate;if(he!==null){var Ee=he.memoizedState;if(Ee!==null){var Ce=Ee.dehydrated;Ce!==null&&ke(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Kn||l.flags&512&&Xh(l)}catch(_e){on(l,l.return,_e)}}if(l===a){We=null;break}if(f=l.sibling,f!==null){f.return=l.return,We=f;break}We=l.return}}function Ev(a){for(;We!==null;){var l=We;if(l===a){We=null;break}var f=l.sibling;if(f!==null){f.return=l.return,We=f;break}We=l.return}}function Cv(a){for(;We!==null;){var l=We;try{switch(l.tag){case 0:case 11:case 15:var f=l.return;try{su(4,l)}catch(ee){on(l,f,ee)}break;case 1:var v=l.stateNode;if(typeof v.componentDidMount=="function"){var j=l.return;try{v.componentDidMount()}catch(ee){on(l,j,ee)}}var A=l.return;try{Xh(l)}catch(ee){on(l,A,ee)}break;case 5:var Z=l.return;try{Xh(l)}catch(ee){on(l,Z,ee)}}}catch(ee){on(l,l.return,ee)}if(l===a){We=null;break}var X=l.sibling;if(X!==null){X.return=l.return,We=X;break}We=l.return}}var _E=Math.ceil,ru=I.ReactCurrentDispatcher,ef=I.ReactCurrentOwner,Ks=I.ReactCurrentBatchConfig,kt=0,Tn=null,gn=null,Ln=0,As=0,io=wi(0),En=0,gl=null,da=0,iu=0,tf=0,xl=null,gs=null,nf=0,ao=1/0,ii=null,au=!1,sf=null,Ai=null,ou=!1,Ii=null,lu=0,vl=0,rf=null,cu=-1,uu=0;function ns(){return(kt&6)!==0?Ot():cu!==-1?cu:cu=Ot()}function Ti(a){return(a.mode&1)===0?1:(kt&2)!==0&&Ln!==0?Ln&-Ln:cE.transition!==null?(uu===0&&(uu=bi()),uu):(a=vt,a!==0||(a=window.event,a=a===void 0?16:Xr(a.type)),a)}function pr(a,l,f,v){if(50<vl)throw vl=0,rf=null,Error(n(185));us(a,f,v),((kt&2)===0||a!==Tn)&&(a===Tn&&((kt&2)===0&&(iu|=f),En===4&&$i(a,Ln)),xs(a,v),f===1&&kt===0&&(l.mode&1)===0&&(ao=Ot()+500,Lc&&Si()))}function xs(a,l){var f=a.callbackNode;yi(a,l);var v=cs(a,a===Tn?Ln:0);if(v===0)f!==null&&Qn(f),a.callbackNode=null,a.callbackPriority=0;else if(l=v&-v,a.callbackPriority!==l){if(f!=null&&Qn(f),l===1)a.tag===0?lE(Iv.bind(null,a)):mx(Iv.bind(null,a)),rE(function(){(kt&6)===0&&Si()}),f=null;else{switch(at(v)){case 1:f=qr;break;case 4:f=or;break;case 16:f=$r;break;case 536870912:f=Ze;break;default:f=$r}f=Lv(f,Av.bind(null,a))}a.callbackPriority=l,a.callbackNode=f}}function Av(a,l){if(cu=-1,uu=0,(kt&6)!==0)throw Error(n(327));var f=a.callbackNode;if(oo()&&a.callbackNode!==f)return null;var v=cs(a,a===Tn?Ln:0);if(v===0)return null;if((v&30)!==0||(v&a.expiredLanes)!==0||l)l=du(a,v);else{l=v;var j=kt;kt|=2;var A=$v();(Tn!==a||Ln!==l)&&(ii=null,ao=Ot()+500,fa(a,l));do try{AE();break}catch(X){Tv(a,X)}while(!0);Nh(),ru.current=A,kt=j,gn!==null?l=0:(Tn=null,Ln=0,l=En)}if(l!==0){if(l===2&&(j=Mr(a),j!==0&&(v=j,l=af(a,j))),l===1)throw f=gl,fa(a,0),$i(a,v),xs(a,Ot()),f;if(l===6)$i(a,v);else{if(j=a.current.alternate,(v&30)===0&&!EE(j)&&(l=du(a,v),l===2&&(A=Mr(a),A!==0&&(v=A,l=af(a,A))),l===1))throw f=gl,fa(a,0),$i(a,v),xs(a,Ot()),f;switch(a.finishedWork=j,a.finishedLanes=v,l){case 0:case 1:throw Error(n(345));case 2:pa(a,gs,ii);break;case 3:if($i(a,v),(v&130023424)===v&&(l=nf+500-Ot(),10<l)){if(cs(a,0)!==0)break;if(j=a.suspendedLanes,(j&v)!==v){ns(),a.pingedLanes|=a.suspendedLanes&j;break}a.timeoutHandle=dh(pa.bind(null,a,gs,ii),l);break}pa(a,gs,ii);break;case 4:if($i(a,v),(v&4194240)===v)break;for(l=a.eventTimes,j=-1;0<v;){var Z=31-zt(v);A=1<<Z,Z=l[Z],Z>j&&(j=Z),v&=~A}if(v=j,v=Ot()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*_E(v/1960))-v,10<v){a.timeoutHandle=dh(pa.bind(null,a,gs,ii),v);break}pa(a,gs,ii);break;case 5:pa(a,gs,ii);break;default:throw Error(n(329))}}}return xs(a,Ot()),a.callbackNode===f?Av.bind(null,a):null}function af(a,l){var f=xl;return a.current.memoizedState.isDehydrated&&(fa(a,l).flags|=256),a=du(a,l),a!==2&&(l=gs,gs=f,l!==null&&of(l)),a}function of(a){gs===null?gs=a:gs.push.apply(gs,a)}function EE(a){for(var l=a;;){if(l.flags&16384){var f=l.updateQueue;if(f!==null&&(f=f.stores,f!==null))for(var v=0;v<f.length;v++){var j=f[v],A=j.getSnapshot;j=j.value;try{if(!cr(A(),j))return!1}catch{return!1}}}if(f=l.child,l.subtreeFlags&16384&&f!==null)f.return=l,l=f;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 $i(a,l){for(l&=~tf,l&=~iu,a.suspendedLanes|=l,a.pingedLanes&=~l,a=a.expirationTimes;0<l;){var f=31-zt(l),v=1<<f;a[f]=-1,l&=~v}}function Iv(a){if((kt&6)!==0)throw Error(n(327));oo();var l=cs(a,0);if((l&1)===0)return xs(a,Ot()),null;var f=du(a,l);if(a.tag!==0&&f===2){var v=Mr(a);v!==0&&(l=v,f=af(a,v))}if(f===1)throw f=gl,fa(a,0),$i(a,l),xs(a,Ot()),f;if(f===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=l,pa(a,gs,ii),xs(a,Ot()),null}function lf(a,l){var f=kt;kt|=1;try{return a(l)}finally{kt=f,kt===0&&(ao=Ot()+500,Lc&&Si())}}function ha(a){Ii!==null&&Ii.tag===0&&(kt&6)===0&&oo();var l=kt;kt|=1;var f=Ks.transition,v=vt;try{if(Ks.transition=null,vt=1,a)return a()}finally{vt=v,Ks.transition=f,kt=l,(kt&6)===0&&Si()}}function cf(){As=io.current,Ht(io)}function fa(a,l){a.finishedWork=null,a.finishedLanes=0;var f=a.timeoutHandle;if(f!==-1&&(a.timeoutHandle=-1,sE(f)),gn!==null)for(f=gn.return;f!==null;){var v=f;switch(xh(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&zc();break;case 3:no(),Ht(fs),Ht(Vn),Ih();break;case 5:Ch(v);break;case 4:no();break;case 13:Ht(Jt);break;case 19:Ht(Jt);break;case 10:wh(v.type._context);break;case 22:case 23:cf()}f=f.return}if(Tn=a,gn=a=Mi(a.current,null),Ln=As=l,En=0,gl=null,tf=iu=da=0,gs=xl=null,la!==null){for(l=0;l<la.length;l++)if(f=la[l],v=f.interleaved,v!==null){f.interleaved=null;var j=v.next,A=f.pending;if(A!==null){var Z=A.next;A.next=j,v.next=Z}f.pending=v}la=null}return a}function Tv(a,l){do{var f=gn;try{if(Nh(),Gc.current=Qc,Kc){for(var v=en.memoizedState;v!==null;){var j=v.queue;j!==null&&(j.pending=null),v=v.next}Kc=!1}if(ua=0,In=_n=en=null,ul=!1,dl=0,ef.current=null,f===null||f.return===null){En=1,gl=l,gn=null;break}e:{var A=a,Z=f.return,X=f,ee=l;if(l=Ln,X.flags|=32768,ee!==null&&typeof ee=="object"&&typeof ee.then=="function"){var he=ee,Ee=X,Ce=Ee.tag;if((Ee.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var _e=Ee.alternate;_e?(Ee.updateQueue=_e.updateQueue,Ee.memoizedState=_e.memoizedState,Ee.lanes=_e.lanes):(Ee.updateQueue=null,Ee.memoizedState=null)}var He=nv(Z);if(He!==null){He.flags&=-257,sv(He,Z,X,A,l),He.mode&1&&tv(A,he,l),l=He,ee=he;var Ve=l.updateQueue;if(Ve===null){var Ke=new Set;Ke.add(ee),l.updateQueue=Ke}else Ve.add(ee);break e}else{if((l&1)===0){tv(A,he,l),uf();break e}ee=Error(n(426))}}else if(qt&&X.mode&1){var hn=nv(Z);if(hn!==null){(hn.flags&65536)===0&&(hn.flags|=256),sv(hn,Z,X,A,l),bh(so(ee,X));break e}}A=ee=so(ee,X),En!==4&&(En=2),xl===null?xl=[A]:xl.push(A),A=Z;do{switch(A.tag){case 3:A.flags|=65536,l&=-l,A.lanes|=l;var le=Jx(A,ee,l);_x(A,le);break e;case 1:X=ee;var se=A.type,ce=A.stateNode;if((A.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Ai===null||!Ai.has(ce)))){A.flags|=65536,l&=-l,A.lanes|=l;var Me=ev(A,X,l);_x(A,Me);break e}}A=A.return}while(A!==null)}Rv(f)}catch(Ye){l=Ye,gn===f&&f!==null&&(gn=f=f.return);continue}break}while(!0)}function $v(){var a=ru.current;return ru.current=Qc,a===null?Qc:a}function uf(){(En===0||En===3||En===2)&&(En=4),Tn===null||(da&268435455)===0&&(iu&268435455)===0||$i(Tn,Ln)}function du(a,l){var f=kt;kt|=2;var v=$v();(Tn!==a||Ln!==l)&&(ii=null,fa(a,l));do try{CE();break}catch(j){Tv(a,j)}while(!0);if(Nh(),kt=f,ru.current=v,gn!==null)throw Error(n(261));return Tn=null,Ln=0,En}function CE(){for(;gn!==null;)Mv(gn)}function AE(){for(;gn!==null&&!Vr();)Mv(gn)}function Mv(a){var l=Pv(a.alternate,a,As);a.memoizedProps=a.pendingProps,l===null?Rv(a):gn=l,ef.current=null}function Rv(a){var l=a;do{var f=l.alternate;if(a=l.return,(l.flags&32768)===0){if(f=kE(f,l,As),f!==null){gn=f;return}}else{if(f=NE(f,l),f!==null){f.flags&=32767,gn=f;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{En=6,gn=null;return}}if(l=l.sibling,l!==null){gn=l;return}gn=l=a}while(l!==null);En===0&&(En=5)}function pa(a,l,f){var v=vt,j=Ks.transition;try{Ks.transition=null,vt=1,IE(a,l,f,v)}finally{Ks.transition=j,vt=v}return null}function IE(a,l,f,v){do oo();while(Ii!==null);if((kt&6)!==0)throw Error(n(327));f=a.finishedWork;var j=a.finishedLanes;if(f===null)return null;if(a.finishedWork=null,a.finishedLanes=0,f===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var A=f.lanes|f.childLanes;if(Sn(a,A),a===Tn&&(gn=Tn=null,Ln=0),(f.subtreeFlags&2064)===0&&(f.flags&2064)===0||ou||(ou=!0,Lv($r,function(){return oo(),null})),A=(f.flags&15990)!==0,(f.subtreeFlags&15990)!==0||A){A=Ks.transition,Ks.transition=null;var Z=vt;vt=1;var X=kt;kt|=4,ef.current=null,jE(a,f),jv(f,a),Y_(ch),nt=!!lh,ch=lh=null,a.current=f,SE(f),ar(),kt=X,vt=Z,Ks.transition=A}else a.current=f;if(ou&&(ou=!1,Ii=a,lu=j),A=a.pendingLanes,A===0&&(Ai=null),Tt(f.stateNode),xs(a,Ot()),l!==null)for(v=a.onRecoverableError,f=0;f<l.length;f++)j=l[f],v(j.value,{componentStack:j.stack,digest:j.digest});if(au)throw au=!1,a=sf,sf=null,a;return(lu&1)!==0&&a.tag!==0&&oo(),A=a.pendingLanes,(A&1)!==0?a===rf?vl++:(vl=0,rf=a):vl=0,Si(),null}function oo(){if(Ii!==null){var a=at(lu),l=Ks.transition,f=vt;try{if(Ks.transition=null,vt=16>a?16:a,Ii===null)var v=!1;else{if(a=Ii,Ii=null,lu=0,(kt&6)!==0)throw Error(n(331));var j=kt;for(kt|=4,We=a.current;We!==null;){var A=We,Z=A.child;if((We.flags&16)!==0){var X=A.deletions;if(X!==null){for(var ee=0;ee<X.length;ee++){var he=X[ee];for(We=he;We!==null;){var Ee=We;switch(Ee.tag){case 0:case 11:case 15:ml(8,Ee,A)}var Ce=Ee.child;if(Ce!==null)Ce.return=Ee,We=Ce;else for(;We!==null;){Ee=We;var _e=Ee.sibling,He=Ee.return;if(yv(Ee),Ee===he){We=null;break}if(_e!==null){_e.return=He,We=_e;break}We=He}}}var Ve=A.alternate;if(Ve!==null){var Ke=Ve.child;if(Ke!==null){Ve.child=null;do{var hn=Ke.sibling;Ke.sibling=null,Ke=hn}while(Ke!==null)}}We=A}}if((A.subtreeFlags&2064)!==0&&Z!==null)Z.return=A,We=Z;else e:for(;We!==null;){if(A=We,(A.flags&2048)!==0)switch(A.tag){case 0:case 11:case 15:ml(9,A,A.return)}var le=A.sibling;if(le!==null){le.return=A.return,We=le;break e}We=A.return}}var se=a.current;for(We=se;We!==null;){Z=We;var ce=Z.child;if((Z.subtreeFlags&2064)!==0&&ce!==null)ce.return=Z,We=ce;else e:for(Z=se;We!==null;){if(X=We,(X.flags&2048)!==0)try{switch(X.tag){case 0:case 11:case 15:su(9,X)}}catch(Ye){on(X,X.return,Ye)}if(X===Z){We=null;break e}var Me=X.sibling;if(Me!==null){Me.return=X.return,We=Me;break e}We=X.return}}if(kt=j,Si(),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(ct,a)}catch{}v=!0}return v}finally{vt=f,Ks.transition=l}}return!1}function Ov(a,l,f){l=so(f,l),l=Jx(a,l,1),a=Ei(a,l,1),l=ns(),a!==null&&(us(a,1,l),xs(a,l))}function on(a,l,f){if(a.tag===3)Ov(a,a,f);else for(;l!==null;){if(l.tag===3){Ov(l,a,f);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Ai===null||!Ai.has(v))){a=so(f,a),a=ev(l,a,1),l=Ei(l,a,1),a=ns(),l!==null&&(us(l,1,a),xs(l,a));break}}l=l.return}}function TE(a,l,f){var v=a.pingCache;v!==null&&v.delete(l),l=ns(),a.pingedLanes|=a.suspendedLanes&f,Tn===a&&(Ln&f)===f&&(En===4||En===3&&(Ln&130023424)===Ln&&500>Ot()-nf?fa(a,0):tf|=f),xs(a,l)}function zv(a,l){l===0&&((a.mode&1)===0?l=1:(l=Us,Us<<=1,(Us&130023424)===0&&(Us=4194304)));var f=ns();a=ni(a,l),a!==null&&(us(a,l,f),xs(a,f))}function $E(a){var l=a.memoizedState,f=0;l!==null&&(f=l.retryLane),zv(a,f)}function ME(a,l){var f=0;switch(a.tag){case 13:var v=a.stateNode,j=a.memoizedState;j!==null&&(f=j.retryLane);break;case 19:v=a.stateNode;break;default:throw Error(n(314))}v!==null&&v.delete(l),zv(a,f)}var Pv;Pv=function(a,l,f){if(a!==null)if(a.memoizedProps!==l.pendingProps||fs.current)ms=!0;else{if((a.lanes&f)===0&&(l.flags&128)===0)return ms=!1,bE(a,l,f);ms=(a.flags&131072)!==0}else ms=!1,qt&&(l.flags&1048576)!==0&&gx(l,Fc,l.index);switch(l.lanes=0,l.tag){case 2:var v=l.type;tu(a,l),a=l.pendingProps;var j=Ka(l,Vn.current);to(l,f),j=Mh(null,l,v,a,j,f);var A=Rh();return l.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,ps(v)?(A=!0,Pc(l)):A=!1,l.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,_h(l),j.updater=Jc,l.stateNode=j,j._reactInternals=l,Fh(l,v,a,f),l=Zh(null,l,v,!0,A,f)):(l.tag=0,qt&&A&&gh(l),ts(null,l,j,f),l=l.child),l;case 16:v=l.elementType;e:{switch(tu(a,l),a=l.pendingProps,j=v._init,v=j(v._payload),l.type=v,j=l.tag=OE(v),a=dr(v,a),j){case 0:l=Hh(null,l,v,a,f);break e;case 1:l=cv(null,l,v,a,f);break e;case 11:l=rv(null,l,v,a,f);break e;case 14:l=iv(null,l,v,dr(v.type,a),f);break e}throw Error(n(306,v,""))}return l;case 0:return v=l.type,j=l.pendingProps,j=l.elementType===v?j:dr(v,j),Hh(a,l,v,j,f);case 1:return v=l.type,j=l.pendingProps,j=l.elementType===v?j:dr(v,j),cv(a,l,v,j,f);case 3:e:{if(uv(l),a===null)throw Error(n(387));v=l.pendingProps,A=l.memoizedState,j=A.element,Sx(a,l),Vc(l,v,null,f);var Z=l.memoizedState;if(v=Z.element,A.isDehydrated)if(A={element:v,isDehydrated:!1,cache:Z.cache,pendingSuspenseBoundaries:Z.pendingSuspenseBoundaries,transitions:Z.transitions},l.updateQueue.baseState=A,l.memoizedState=A,l.flags&256){j=so(Error(n(423)),l),l=dv(a,l,v,f,j);break e}else if(v!==j){j=so(Error(n(424)),l),l=dv(a,l,v,f,j);break e}else for(Cs=Ni(l.stateNode.containerInfo.firstChild),Es=l,qt=!0,ur=null,f=wx(l,null,v,f),l.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling;else{if(Qa(),v===j){l=ri(a,l,f);break e}ts(a,l,v,f)}l=l.child}return l;case 5:return Cx(l),a===null&&yh(l),v=l.type,j=l.pendingProps,A=a!==null?a.memoizedProps:null,Z=j.children,uh(v,j)?Z=null:A!==null&&uh(v,A)&&(l.flags|=32),lv(a,l),ts(a,l,Z,f),l.child;case 6:return a===null&&yh(l),null;case 13:return hv(a,l,f);case 4:return Eh(l,l.stateNode.containerInfo),v=l.pendingProps,a===null?l.child=Ja(l,null,v,f):ts(a,l,v,f),l.child;case 11:return v=l.type,j=l.pendingProps,j=l.elementType===v?j:dr(v,j),rv(a,l,v,j,f);case 7:return ts(a,l,l.pendingProps,f),l.child;case 8:return ts(a,l,l.pendingProps.children,f),l.child;case 12:return ts(a,l,l.pendingProps.children,f),l.child;case 10:e:{if(v=l.type._context,j=l.pendingProps,A=l.memoizedProps,Z=j.value,Dt(Hc,v._currentValue),v._currentValue=Z,A!==null)if(cr(A.value,Z)){if(A.children===j.children&&!fs.current){l=ri(a,l,f);break e}}else for(A=l.child,A!==null&&(A.return=l);A!==null;){var X=A.dependencies;if(X!==null){Z=A.child;for(var ee=X.firstContext;ee!==null;){if(ee.context===v){if(A.tag===1){ee=si(-1,f&-f),ee.tag=2;var he=A.updateQueue;if(he!==null){he=he.shared;var Ee=he.pending;Ee===null?ee.next=ee:(ee.next=Ee.next,Ee.next=ee),he.pending=ee}}A.lanes|=f,ee=A.alternate,ee!==null&&(ee.lanes|=f),jh(A.return,f,l),X.lanes|=f;break}ee=ee.next}}else if(A.tag===10)Z=A.type===l.type?null:A.child;else if(A.tag===18){if(Z=A.return,Z===null)throw Error(n(341));Z.lanes|=f,X=Z.alternate,X!==null&&(X.lanes|=f),jh(Z,f,l),Z=A.sibling}else Z=A.child;if(Z!==null)Z.return=A;else for(Z=A;Z!==null;){if(Z===l){Z=null;break}if(A=Z.sibling,A!==null){A.return=Z.return,Z=A;break}Z=Z.return}A=Z}ts(a,l,j.children,f),l=l.child}return l;case 9:return j=l.type,v=l.pendingProps.children,to(l,f),j=qs(j),v=v(j),l.flags|=1,ts(a,l,v,f),l.child;case 14:return v=l.type,j=dr(v,l.pendingProps),j=dr(v.type,j),iv(a,l,v,j,f);case 15:return av(a,l,l.type,l.pendingProps,f);case 17:return v=l.type,j=l.pendingProps,j=l.elementType===v?j:dr(v,j),tu(a,l),l.tag=1,ps(v)?(a=!0,Pc(l)):a=!1,to(l,f),Xx(l,v,j),Fh(l,v,j,f),Zh(null,l,v,!0,a,f);case 19:return pv(a,l,f);case 22:return ov(a,l,f)}throw Error(n(156,l.tag))};function Lv(a,l){return Ss(a,l)}function RE(a,l,f,v){this.tag=a,this.key=f,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 Ys(a,l,f,v){return new RE(a,l,f,v)}function df(a){return a=a.prototype,!(!a||!a.isReactComponent)}function OE(a){if(typeof a=="function")return df(a)?1:0;if(a!=null){if(a=a.$$typeof,a===B)return 11;if(a===R)return 14}return 2}function Mi(a,l){var f=a.alternate;return f===null?(f=Ys(a.tag,l,a.key,a.mode),f.elementType=a.elementType,f.type=a.type,f.stateNode=a.stateNode,f.alternate=a,a.alternate=f):(f.pendingProps=l,f.type=a.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=a.flags&14680064,f.childLanes=a.childLanes,f.lanes=a.lanes,f.child=a.child,f.memoizedProps=a.memoizedProps,f.memoizedState=a.memoizedState,f.updateQueue=a.updateQueue,l=a.dependencies,f.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},f.sibling=a.sibling,f.index=a.index,f.ref=a.ref,f}function hu(a,l,f,v,j,A){var Z=2;if(v=a,typeof a=="function")df(a)&&(Z=1);else if(typeof a=="string")Z=5;else e:switch(a){case U:return ma(f.children,j,A,l);case V:Z=8,j|=8;break;case $:return a=Ys(12,f,l,j|2),a.elementType=$,a.lanes=A,a;case _:return a=Ys(13,f,l,j),a.elementType=_,a.lanes=A,a;case C:return a=Ys(19,f,l,j),a.elementType=C,a.lanes=A,a;case F:return fu(f,j,A,l);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case P:Z=10;break e;case D:Z=9;break e;case B:Z=11;break e;case R:Z=14;break e;case M:Z=16,v=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return l=Ys(Z,f,l,j),l.elementType=a,l.type=v,l.lanes=A,l}function ma(a,l,f,v){return a=Ys(7,a,v,l),a.lanes=f,a}function fu(a,l,f,v){return a=Ys(22,a,v,l),a.elementType=F,a.lanes=f,a.stateNode={isHidden:!1},a}function hf(a,l,f){return a=Ys(6,a,null,l),a.lanes=f,a}function ff(a,l,f){return l=Ys(4,a.children!==null?a.children:[],a.key,l),l.lanes=f,l.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},l}function zE(a,l,f,v,j){this.tag=l,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Jn(0),this.expirationTimes=Jn(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Jn(0),this.identifierPrefix=v,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function pf(a,l,f,v,j,A,Z,X,ee){return a=new zE(a,l,f,X,ee),l===1?(l=1,A===!0&&(l|=8)):l=0,A=Ys(3,null,null,l),a.current=A,A.stateNode=a,A.memoizedState={element:v,isDehydrated:f,cache:null,transitions:null,pendingSuspenseBoundaries:null},_h(A),a}function PE(a,l,f){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:z,key:v==null?null:""+v,children:a,containerInfo:l,implementation:f}}function Dv(a){if(!a)return ji;a=a._reactInternals;e:{if(Zn(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 f=a.type;if(ps(f))return fx(a,f,l)}return l}function Fv(a,l,f,v,j,A,Z,X,ee){return a=pf(f,v,!0,a,j,A,Z,X,ee),a.context=Dv(null),f=a.current,v=ns(),j=Ti(f),A=si(v,j),A.callback=l??null,Ei(f,A,j),a.current.lanes=j,us(a,j,v),xs(a,v),a}function pu(a,l,f,v){var j=l.current,A=ns(),Z=Ti(j);return f=Dv(f),l.context===null?l.context=f:l.pendingContext=f,l=si(A,Z),l.payload={element:a},v=v===void 0?null:v,v!==null&&(l.callback=v),a=Ei(j,l,Z),a!==null&&(pr(a,j,Z,A),Wc(a,j,Z)),Z}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 Bv(a,l){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var f=a.retryLane;a.retryLane=f!==0&&f<l?f:l}}function mf(a,l){Bv(a,l),(a=a.alternate)&&Bv(a,l)}function LE(){return null}var Uv=typeof reportError=="function"?reportError:function(a){console.error(a)};function gf(a){this._internalRoot=a}gu.prototype.render=gf.prototype.render=function(a){var l=this._internalRoot;if(l===null)throw Error(n(409));pu(a,l,null,null)},gu.prototype.unmount=gf.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var l=a.containerInfo;ha(function(){pu(null,a,null,null)}),l[Qr]=null}};function gu(a){this._internalRoot=a}gu.prototype.unstable_scheduleHydration=function(a){if(a){var l=Gr();a={blockedOn:null,target:a,priority:l};for(var f=0;f<pn.length&&l!==0&&l<pn[f].priority;f++);pn.splice(f,0,a),f===0&&Da(a)}};function xf(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function xu(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function Hv(){}function DE(a,l,f,v,j){if(j){if(typeof v=="function"){var A=v;v=function(){var he=mu(Z);A.call(he)}}var Z=Fv(l,v,a,0,null,!1,!1,"",Hv);return a._reactRootContainer=Z,a[Qr]=Z.current,nl(a.nodeType===8?a.parentNode:a),ha(),Z}for(;j=a.lastChild;)a.removeChild(j);if(typeof v=="function"){var X=v;v=function(){var he=mu(ee);X.call(he)}}var ee=pf(a,0,!1,null,null,!1,!1,"",Hv);return a._reactRootContainer=ee,a[Qr]=ee.current,nl(a.nodeType===8?a.parentNode:a),ha(function(){pu(l,ee,f,v)}),ee}function vu(a,l,f,v,j){var A=f._reactRootContainer;if(A){var Z=A;if(typeof j=="function"){var X=j;j=function(){var ee=mu(Z);X.call(ee)}}pu(l,Z,a,j)}else Z=DE(f,l,a,j,v);return mu(Z)}ds=function(a){switch(a.tag){case 3:var l=a.stateNode;if(l.current.memoizedState.isDehydrated){var f=Hs(l.pendingLanes);f!==0&&(Zs(l,f|1),xs(l,Ot()),(kt&6)===0&&(ao=Ot()+500,Si()))}break;case 13:ha(function(){var v=ni(a,1);if(v!==null){var j=ns();pr(v,a,1,j)}}),mf(a,1)}},Pt=function(a){if(a.tag===13){var l=ni(a,134217728);if(l!==null){var f=ns();pr(l,a,134217728,f)}mf(a,134217728)}},ft=function(a){if(a.tag===13){var l=Ti(a),f=ni(a,l);if(f!==null){var v=ns();pr(f,a,l,v)}mf(a,l)}},Gr=function(){return vt},es=function(a,l){var f=vt;try{return vt=a,l()}finally{vt=f}},sr=function(a,l,f){switch(l){case"input":if(Ge(a,f),l=f.name,f.type==="radio"&&l!=null){for(f=a;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<f.length;l++){var v=f[l];if(v!==a&&v.form===a.form){var j=Oc(v);if(!j)throw Error(n(90));Se(v),Ge(v,j)}}}break;case"textarea":ln(a,f);break;case"select":l=f.value,l!=null&&jt(a,!!f.multiple,l,!1)}},ze=lf,st=ha;var FE={usingClientEntryPoint:!1,Events:[il,qa,Oc,J,ge,lf]},yl={findFiberByHostInstance:ra,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},BE={bundleType:yl.bundleType,version:yl.version,rendererPackageName:yl.rendererPackageName,rendererConfig:yl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:I.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=xi(a),a===null?null:a.stateNode},findFiberByHostInstance:yl.findFiberByHostInstance||LE,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 yu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yu.isDisabled&&yu.supportsFiber)try{ct=yu.inject(BE),ht=yu}catch{}}return vs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=FE,vs.createPortal=function(a,l){var f=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!xf(l))throw Error(n(200));return PE(a,l,null,f)},vs.createRoot=function(a,l){if(!xf(a))throw Error(n(299));var f=!1,v="",j=Uv;return l!=null&&(l.unstable_strictMode===!0&&(f=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(j=l.onRecoverableError)),l=pf(a,1,!1,null,null,f,!1,v,j),a[Qr]=l.current,nl(a.nodeType===8?a.parentNode:a),new gf(l)},vs.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=xi(l),a=a===null?null:a.stateNode,a},vs.flushSync=function(a){return ha(a)},vs.hydrate=function(a,l,f){if(!xu(l))throw Error(n(200));return vu(null,a,l,!0,f)},vs.hydrateRoot=function(a,l,f){if(!xf(a))throw Error(n(405));var v=f!=null&&f.hydratedSources||null,j=!1,A="",Z=Uv;if(f!=null&&(f.unstable_strictMode===!0&&(j=!0),f.identifierPrefix!==void 0&&(A=f.identifierPrefix),f.onRecoverableError!==void 0&&(Z=f.onRecoverableError)),l=Fv(l,null,a,1,f??null,j,!1,A,Z),a[Qr]=l.current,nl(a),v)for(a=0;a<v.length;a++)f=v[a],j=f._getVersion,j=j(f._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[f,j]:l.mutableSourceEagerHydrationData.push(f,j);return new gu(l)},vs.render=function(a,l,f){if(!xu(l))throw Error(n(200));return vu(null,a,l,!1,f)},vs.unmountComponentAtNode=function(a){if(!xu(a))throw Error(n(40));return a._reactRootContainer?(ha(function(){vu(null,null,a,!1,function(){a._reactRootContainer=null,a[Qr]=null})}),!0):!1},vs.unstable_batchedUpdates=lf,vs.unstable_renderSubtreeIntoContainer=function(a,l,f,v){if(!xu(f))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return vu(a,l,f,!1,v)},vs.version="18.3.1-next-f1338f8080-20240426",vs}var Jv;function hk(){if(Jv)return kf.exports;Jv=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(),kf.exports=YE(),kf.exports}var e0;function XE(){if(e0)return bu;e0=1;var e=hk();return bu.createRoot=e.createRoot,bu.hydrateRoot=e.hydrateRoot,bu}var QE=XE(),Fi,So,_o;class Fr{constructor(t){Lt(this,Fi);Lt(this,So,new Set);Lt(this,_o,!1);ut(this,"get",()=>Oe(this,Fi));ut(this,"subscribe",t=>(Oe(this,So).add(t),()=>{Oe(this,So).delete(t)}));Zt(this,Fi,t)}set(t){const n=typeof t=="function"?t(Oe(this,Fi)):t;Object.is(n,Oe(this,Fi))||(Zt(this,Fi,n),!Oe(this,_o)&&(Zt(this,_o,!0),queueMicrotask(()=>{Zt(this,_o,!1);for(const r of[...Oe(this,So)])r()})))}}Fi=new WeakMap,So=new WeakMap,_o=new WeakMap;var t0;function ve(e,t,n){function r(u,h){if(u._zod||Object.defineProperty(u,"_zod",{value:{def:h,constr:c,traits:new Set},enumerable:!1}),u._zod.traits.has(e))return;u._zod.traits.add(e),t(u,h);const d=c.prototype,p=Object.keys(d);for(let m=0;m<p.length;m++){const g=p[m];g in u||(u[g]=d[g].bind(u))}}const i=(n==null?void 0:n.Parent)??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function c(u){var h;const d=n!=null&&n.Parent?new o:this;r(d,u),(h=d._zod).deferred??(h.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(c,"init",{value:r}),Object.defineProperty(c,Symbol.hasInstance,{value:u=>{var h,d;return n!=null&&n.Parent&&u instanceof n.Parent?!0:(d=(h=u==null?void 0:u._zod)==null?void 0:h.traits)==null?void 0:d.has(e)}}),Object.defineProperty(c,"name",{value:e}),c}class yo extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class fk extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(t0=globalThis).__zod_globalConfig??(t0.__zod_globalConfig={});const _m=globalThis.__zod_globalConfig;function hi(e){return _m}function pk(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function jp(e,t){return typeof t=="bigint"?t.toString():t}function Sd(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Em(e){return e==null}function Cm(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function JE(e,t){const n=e/t,r=Math.round(n),i=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const n0=Symbol("evaluating");function Mt(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==n0)return r===void 0&&(r=n0,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function za(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ji(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function s0(e){return JSON.stringify(e)}function e1(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const mk="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const t1=Sd(()=>{var e;if(_m.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 $o(e){if(Yl(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yl(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function gk(e){return $o(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const n1=new Set(["string","number","symbol"]);function Mo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ea(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function Qe(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0:t.error)!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function s1(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const r1={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 i1(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Ji(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 ea(e,o)}function a1(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Ji(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 ea(e,o)}function o1(e,t){if(!$o(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const c in t)if(Object.getOwnPropertyDescriptor(o,c)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Ji(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return za(this,"shape",o),o}});return ea(e,i)}function l1(e,t){if(!$o(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ji(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return za(this,"shape",r),r}});return ea(e,n)}function c1(e,t){var r;if((r=e._zod.def.checks)!=null&&r.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=Ji(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return za(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ea(e,n)}function u1(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const c=Ji(t._zod.def,{get shape(){const u=t._zod.def.shape,h={...u};if(n)for(const d in n){if(!(d in u))throw new Error(`Unrecognized key: "${d}"`);n[d]&&(h[d]=e?new e({type:"optional",innerType:u[d]}):u[d])}else for(const d in u)h[d]=e?new e({type:"optional",innerType:u[d]}):u[d];return za(this,"shape",h),h},checks:[]});return ea(t,c)}function d1(e,t,n){const r=Ji(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};if(n)for(const c in n){if(!(c in o))throw new Error(`Unrecognized key: "${c}"`);n[c]&&(o[c]=new e({type:"nonoptional",innerType:i[c]}))}else for(const c in i)o[c]=new e({type:"nonoptional",innerType:i[c]});return za(this,"shape",o),o}});return ea(t,r)}function mo(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function h1(e,t=0){var n;if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)===!1)return!0;return!1}function go(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function ku(e){return typeof e=="string"?e:e==null?void 0:e.message}function fi(e,t,n){var h,d,p,m,g,x;const r=e.message?e.message:ku((p=(d=(h=e.inst)==null?void 0:h._zod.def)==null?void 0:d.error)==null?void 0:p.call(d,e))??ku((m=t==null?void 0:t.error)==null?void 0:m.call(t,e))??ku((g=n.customError)==null?void 0:g.call(n,e))??ku((x=n.localeError)==null?void 0:x.call(n,e))??"Invalid input",{inst:i,continue:o,input:c,...u}=e;return u.path??(u.path=[]),u.message=r,t!=null&&t.reportInput&&(u.input=c),u}function Am(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Xl(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const xk=(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,jp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},vk=ve("$ZodError",xk),yk=ve("$ZodError",xk,{Parent:Error});function f1(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function p1(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const c of i.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>r({issues:u},[...o,...c.path]));else if(c.code==="invalid_key")r({issues:c.issues},[...o,...c.path]);else if(c.code==="invalid_element")r({issues:c.issues},[...o,...c.path]);else{const u=[...o,...c.path];if(u.length===0)n._errors.push(t(c));else{let h=n,d=0;for(;d<u.length;){const p=u[d];d===u.length-1?(h[p]=h[p]||{_errors:[]},h[p]._errors.push(t(c))):h[p]=h[p]||{_errors:[]},h=h[p],d++}}}};return r(e),n}const Im=e=>(t,n,r,i)=>{const o=r?{...r,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new yo;if(c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>fi(h,o,hi())));throw mk(u,i==null?void 0:i.callee),u}return c.value},Tm=e=>async(t,n,r,i)=>{const o=r?{...r,async:!0}:{async:!0};let c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise&&(c=await c),c.issues.length){const u=new((i==null?void 0:i.Err)??e)(c.issues.map(h=>fi(h,o,hi())));throw mk(u,i==null?void 0:i.callee),u}return c.value},_d=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new yo;return o.issues.length?{success:!1,error:new(e??vk)(o.issues.map(c=>fi(c,i,hi())))}:{success:!0,data:o.value}},m1=_d(yk),Ed=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(c=>fi(c,i,hi())))}:{success:!0,data:o.value}},g1=Ed(yk),x1=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Im(e)(t,n,i)},v1=e=>(t,n,r)=>Im(e)(t,n,r),y1=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Tm(e)(t,n,i)},b1=e=>async(t,n,r)=>Tm(e)(t,n,r),k1=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return _d(e)(t,n,i)},N1=e=>(t,n,r)=>_d(e)(t,n,r),w1=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Ed(e)(t,n,i)},j1=e=>async(t,n,r)=>Ed(e)(t,n,r),S1=/^[cC][0-9a-z]{6,}$/,_1=/^[0-9a-z]+$/,E1=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,C1=/^[0-9a-vA-V]{20}$/,A1=/^[A-Za-z0-9]{27}$/,I1=/^[a-zA-Z0-9_-]{21}$/,T1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$1=/^([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})$/,r0=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)$/,M1=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,R1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function O1(){return new RegExp(R1,"u")}const z1=/^(?:(?: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])$/,P1=/^(([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}|:))$/,L1=/^((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])$/,D1=/^(([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])$/,F1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bk=/^[A-Za-z0-9_-]*$/,B1=/^https?$/,U1=/^\+[1-9]\d{6,14}$/,kk="(?:(?:\\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])))",H1=new RegExp(`^${kk}$`);function Nk(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 Z1(e){return new RegExp(`^${Nk(e)}$`)}function W1(e){const t=Nk({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${kk}T(?:${r})$`)}const V1=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}$`)},q1=/^-?\d+$/,wk=/^-?\d+(?:\.\d+)?$/,G1=/^(?:true|false)$/i,K1=/^null$/i,Y1=/^[^A-Z]*$/,X1=/^[^a-z]*$/,ws=ve("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jk={number:"number",bigint:"bigint",object:"date"},Sk=ve("$ZodCheckLessThan",(e,t)=>{ws.init(e,t);const n=jk[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_k=ve("$ZodCheckGreaterThan",(e,t)=>{ws.init(e,t);const n=jk[typeof t.value];e._zod.onattach.push(r=>{const i=r._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Q1=ve("$ZodCheckMultipleOf",(e,t)=>{ws.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):JE(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})}}),J1=ve("$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"),r=n?"int":"number",[i,o]=r1[t.format];e._zod.onattach.push(u=>{const h=u._zod.bag;h.format=t.format,h.minimum=i,h.maximum=o,n&&(h.pattern=q1)}),e._zod.check=u=>{const h=u.value;if(n){if(!Number.isInteger(h)){u.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:h,inst:e});return}if(!Number.isSafeInteger(h)){h>0?u.issues.push({input:h,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):u.issues.push({input:h,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}h<i&&u.issues.push({origin:"number",input:h,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),h>o&&u.issues.push({origin:"number",input:h,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),eC=ve("$ZodCheckMaxLength",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Em(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const i=r.value;if(i.length<=t.maximum)return;const c=Am(i);r.issues.push({origin:c,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),tC=ve("$ZodCheckMinLength",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Em(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const i=r.value;if(i.length>=t.minimum)return;const c=Am(i);r.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),nC=ve("$ZodCheckLengthEquals",(e,t)=>{var n;ws.init(e,t),(n=e._zod.def).when??(n.when=r=>{const i=r.value;return!Em(i)&&i.length!==void 0}),e._zod.onattach.push(r=>{const i=r._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=r=>{const i=r.value,o=i.length;if(o===t.length)return;const c=Am(i),u=o>t.length;r.issues.push({origin:c,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Cd=ve("$ZodCheckStringFormat",(e,t)=>{var n,r;ws.init(e,t),e._zod.onattach.push(i=>{const o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),sC=ve("$ZodCheckRegex",(e,t)=>{Cd.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})}}),rC=ve("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Y1),Cd.init(e,t)}),iC=ve("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=X1),Cd.init(e,t)}),aC=ve("$ZodCheckIncludes",(e,t)=>{ws.init(e,t);const n=Mo(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),oC=ve("$ZodCheckStartsWith",(e,t)=>{ws.init(e,t);const n=new RegExp(`^${Mo(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),lC=ve("$ZodCheckEndsWith",(e,t)=>{ws.init(e,t);const n=new RegExp(`.*${Mo(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),cC=ve("$ZodCheckOverwrite",(e,t)=>{ws.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class uC{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
41
+ `).filter(c=>c),i=Math.min(...r.map(c=>c.length-c.trimStart().length)),o=r.map(c=>c.slice(i)).map(c=>" ".repeat(this.indent*2)+c);for(const c of o)this.content.push(c)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...n,i.join(`
42
+ `))}}const dC={major:4,minor:4,patch:3},Kt=ve("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=dC;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const c of o._zod.onattach)c(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const o=(u,h,d)=>{let p=mo(u),m;for(const g of h){if(g._zod.def.when){if(h1(u)||!g._zod.def.when(u))continue}else if(p)continue;const x=u.issues.length,y=g._zod.check(u);if(y instanceof Promise&&(d==null?void 0:d.async)===!1)throw new yo;if(m||y instanceof Promise)m=(m??Promise.resolve()).then(async()=>{await y,u.issues.length!==x&&(p||(p=mo(u,x)))});else{if(u.issues.length===x)continue;p||(p=mo(u,x))}}return m?m.then(()=>u):u},c=(u,h,d)=>{if(mo(u))return u.aborted=!0,u;const p=o(h,r,d);if(p instanceof Promise){if(d.async===!1)throw new yo;return p.then(m=>e._zod.parse(m,d))}return e._zod.parse(p,d)};e._zod.run=(u,h)=>{if(h.skipChecks)return e._zod.parse(u,h);if(h.direction==="backward"){const p=e._zod.parse({value:u.value,issues:[]},{...h,skipChecks:!0});return p instanceof Promise?p.then(m=>c(m,u,h)):c(p,u,h)}const d=e._zod.parse(u,h);if(d instanceof Promise){if(h.async===!1)throw new yo;return d.then(p=>o(p,r,h))}return o(d,r,h)}}Mt(e,"~standard",()=>({validate:o=>{var c;try{const u=m1(e,o);return u.success?{value:u.data}:{issues:(c=u.error)==null?void 0:c.issues}}catch{return g1(e,o).then(h=>{var d;return h.success?{value:h.data}:{issues:(d=h.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}))}),$m=ve("$ZodString",(e,t)=>{var n;Kt.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??V1(e._zod.bag),e._zod.parse=(r,i)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Yt=ve("$ZodStringFormat",(e,t)=>{Cd.init(e,t),$m.init(e,t)}),hC=ve("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=$1),Yt.init(e,t)}),fC=ve("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=r0(r))}else t.pattern??(t.pattern=r0());Yt.init(e,t)}),pC=ve("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=M1),Yt.init(e,t)}),mC=ve("$ZodURL",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{var r;try{const i=n.value.trim();if(!t.normalize&&((r=t.protocol)==null?void 0:r.source)===B1.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),gC=ve("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=O1()),Yt.init(e,t)}),xC=ve("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=I1),Yt.init(e,t)}),vC=ve("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=S1),Yt.init(e,t)}),yC=ve("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=_1),Yt.init(e,t)}),bC=ve("$ZodULID",(e,t)=>{t.pattern??(t.pattern=E1),Yt.init(e,t)}),kC=ve("$ZodXID",(e,t)=>{t.pattern??(t.pattern=C1),Yt.init(e,t)}),NC=ve("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=A1),Yt.init(e,t)}),wC=ve("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=W1(t)),Yt.init(e,t)}),jC=ve("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=H1),Yt.init(e,t)}),SC=ve("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Z1(t)),Yt.init(e,t)}),_C=ve("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=T1),Yt.init(e,t)}),EC=ve("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=z1),Yt.init(e,t),e._zod.bag.format="ipv4"}),CC=ve("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=P1),Yt.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),AC=ve("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=L1),Yt.init(e,t)}),IC=ve("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=D1),Yt.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[i,o]=r;if(!o)throw new Error;const c=Number(o);if(`${c}`!==o)throw new Error;if(c<0||c>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ek(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const TC=ve("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=F1),Yt.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ek(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function $C(e){if(!bk.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ek(n)}const MC=ve("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=bk),Yt.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{$C(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),RC=ve("$ZodE164",(e,t)=>{t.pattern??(t.pattern=U1),Yt.init(e,t)});function OC(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const zC=ve("$ZodJWT",(e,t)=>{Yt.init(e,t),e._zod.check=n=>{OC(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ck=ve("$ZodNumber",(e,t)=>{Kt.init(e,t),e._zod.pattern=e._zod.bag.pattern??wk,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),PC=ve("$ZodNumberFormat",(e,t)=>{J1.init(e,t),Ck.init(e,t)}),LC=ve("$ZodBoolean",(e,t)=>{Kt.init(e,t),e._zod.pattern=G1,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),DC=ve("$ZodNull",(e,t)=>{Kt.init(e,t),e._zod.pattern=K1,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),FC=ve("$ZodUnknown",(e,t)=>{Kt.init(e,t),e._zod.parse=n=>n}),BC=ve("$ZodNever",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function i0(e,t,n){e.issues.length&&t.issues.push(...go(n,e.issues)),t.value[n]=e.value}const UC=ve("$ZodArray",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let c=0;c<i.length;c++){const u=i[c],h=t.element._zod.run({value:u,issues:[]},r);h instanceof Promise?o.push(h.then(d=>i0(d,n,c))):i0(h,n,c)}return o.length?Promise.all(o).then(()=>n):n}});function Qu(e,t,n,r,i,o){const c=n in r;if(e.issues.length){if(i&&o&&!c)return;t.issues.push(...go(n,e.issues))}if(!c&&!i){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?c&&(t.value[n]=void 0):t.value[n]=e.value}function Ak(e){var r,i,o,c;const t=Object.keys(e.shape);for(const u of t)if(!((c=(o=(i=(r=e.shape)==null?void 0:r[u])==null?void 0:i._zod)==null?void 0:o.traits)!=null&&c.has("$ZodType")))throw new Error(`Invalid element at key "${u}": expected a Zod schema`);const n=s1(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ik(e,t,n,r,i,o){const c=[],u=i.keySet,h=i.catchall._zod,d=h.def.type,p=h.optin==="optional",m=h.optout==="optional";for(const g in t){if(g==="__proto__"||u.has(g))continue;if(d==="never"){c.push(g);continue}const x=h.run({value:t[g],issues:[]},r);x instanceof Promise?e.push(x.then(y=>Qu(y,n,g,t,p,m))):Qu(x,n,g,t,p,m)}return c.length&&n.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const HC=ve("$ZodObject",(e,t)=>{Kt.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const u=t.shape;Object.defineProperty(t,"shape",{get:()=>{const h={...u};return Object.defineProperty(t,"shape",{value:h}),h}})}const r=Sd(()=>Ak(t));Mt(e._zod,"propValues",()=>{const u=t.shape,h={};for(const d in u){const p=u[d]._zod;if(p.values){h[d]??(h[d]=new Set);for(const m of p.values)h[d].add(m)}}return h});const i=Yl,o=t.catchall;let c;e._zod.parse=(u,h)=>{c??(c=r.value);const d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value={};const p=[],m=c.shape;for(const g of c.keys){const x=m[g],y=x._zod.optin==="optional",E=x._zod.optout==="optional",N=x._zod.run({value:d[g],issues:[]},h);N instanceof Promise?p.push(N.then(w=>Qu(w,u,g,d,y,E))):Qu(N,u,g,d,y,E)}return o?Ik(p,d,u,h,r.value,e):p.length?Promise.all(p).then(()=>u):u}}),ZC=ve("$ZodObjectJIT",(e,t)=>{HC.init(e,t);const n=e._zod.parse,r=Sd(()=>Ak(t)),i=g=>{var k,I;const x=new uC(["shape","payload","ctx"]),y=r.value,E=L=>{const z=s0(L);return`shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`};x.write("const input = payload.value;");const N=Object.create(null);let w=0;for(const L of y.keys)N[L]=`key_${w++}`;x.write("const newResult = {};");for(const L of y.keys){const z=N[L],U=s0(L),V=g[L],$=((k=V==null?void 0:V._zod)==null?void 0:k.optin)==="optional",P=((I=V==null?void 0:V._zod)==null?void 0:I.optout)==="optional";x.write(`const ${z} = ${E(L)};`),$&&P?x.write(`
43
+ if (${z}.issues.length) {
44
+ if (${U} in input) {
45
+ payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
46
+ ...iss,
47
+ path: iss.path ? [${U}, ...iss.path] : [${U}]
48
+ })));
49
+ }
50
+ }
51
+
52
+ if (${z}.value === undefined) {
53
+ if (${U} in input) {
54
+ newResult[${U}] = undefined;
55
+ }
56
+ } else {
57
+ newResult[${U}] = ${z}.value;
58
+ }
59
+
60
+ `):$?x.write(`
61
+ if (${z}.issues.length) {
62
+ payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
63
+ ...iss,
64
+ path: iss.path ? [${U}, ...iss.path] : [${U}]
65
+ })));
66
+ }
67
+
68
+ if (${z}.value === undefined) {
69
+ if (${U} in input) {
70
+ newResult[${U}] = undefined;
71
+ }
72
+ } else {
73
+ newResult[${U}] = ${z}.value;
74
+ }
75
+
76
+ `):x.write(`
77
+ const ${z}_present = ${U} in input;
78
+ if (${z}.issues.length) {
79
+ payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
80
+ ...iss,
81
+ path: iss.path ? [${U}, ...iss.path] : [${U}]
82
+ })));
83
+ }
84
+ if (!${z}_present && !${z}.issues.length) {
85
+ payload.issues.push({
86
+ code: "invalid_type",
87
+ expected: "nonoptional",
88
+ input: undefined,
89
+ path: [${U}]
90
+ });
91
+ }
92
+
93
+ if (${z}_present) {
94
+ if (${z}.value === undefined) {
95
+ newResult[${U}] = undefined;
96
+ } else {
97
+ newResult[${U}] = ${z}.value;
98
+ }
99
+ }
100
+
101
+ `)}x.write("payload.value = newResult;"),x.write("return payload;");const T=x.compile();return(L,z)=>T(g,L,z)};let o;const c=Yl,u=!_m.jitless,d=u&&t1.value,p=t.catchall;let m;e._zod.parse=(g,x)=>{m??(m=r.value);const y=g.value;return c(y)?u&&d&&(x==null?void 0:x.async)===!1&&x.jitless!==!0?(o||(o=i(t.shape)),g=o(g,x),p?Ik([],y,g,x,m,e):g):n(g,x):(g.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),g)}});function a0(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!mo(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(c=>fi(c,r,hi())))}),t)}const Tk=ve("$ZodUnion",(e,t)=>{Kt.init(e,t),Mt(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Mt(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Mt(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),Mt(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${r.map(i=>Cm(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const c=[];for(const u of t.options){const h=u._zod.run({value:r.value,issues:[]},i);if(h instanceof Promise)c.push(h),o=!0;else{if(h.issues.length===0)return h;c.push(h)}}return o?Promise.all(c).then(u=>a0(u,r,e,i)):a0(c,r,e,i)}}),WC=ve("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Tk.init(e,t);const n=e._zod.parse;Mt(e._zod,"propValues",()=>{const i={};for(const o of t.options){const c=o._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[u,h]of Object.entries(c)){i[u]||(i[u]=new Set);for(const d of h)i[u].add(d)}}return i});const r=Sd(()=>{var c;const i=t.options,o=new Map;for(const u of i){const h=(c=u._zod.propValues)==null?void 0:c[t.discriminator];if(!h||h.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(const d of h){if(o.has(d))throw new Error(`Duplicate discriminator value "${String(d)}"`);o.set(d,u)}}return o});e._zod.parse=(i,o)=>{const c=i.value;if(!Yl(c))return i.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),i;const u=r.value.get(c==null?void 0:c[t.discriminator]);return u?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:c,path:[t.discriminator],inst:e}),i)}}),VC=ve("$ZodIntersection",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),c=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||c instanceof Promise?Promise.all([o,c]).then(([h,d])=>o0(n,h,d)):o0(n,o,c)}});function Sp(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($o(e)&&$o(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of r){const c=Sp(e[o],t[o]);if(!c.valid)return{valid:!1,mergeErrorPath:[o,...c.mergeErrorPath]};i[o]=c.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const i=e[r],o=t[r],c=Sp(i,o);if(!c.valid)return{valid:!1,mergeErrorPath:[r,...c.mergeErrorPath]};n.push(c.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function o0(e,t,n){const r=new Map;let i;for(const u of t.issues)if(u.code==="unrecognized_keys"){i??(i=u);for(const h of u.keys)r.has(h)||r.set(h,{}),r.get(h).l=!0}else e.issues.push(u);for(const u of n.issues)if(u.code==="unrecognized_keys")for(const h of u.keys)r.has(h)||r.set(h,{}),r.get(h).r=!0;else e.issues.push(u);const o=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(o.length&&i&&e.issues.push({...i,keys:o}),mo(e))return e;const c=Sp(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 qC=ve("$ZodRecord",(e,t)=>{Kt.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;if(!$o(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],c=t.keyType._zod.values;if(c){n.value={};const u=new Set;for(const d of c)if(typeof d=="string"||typeof d=="number"||typeof d=="symbol"){u.add(typeof d=="number"?d.toString():d);const p=t.keyType._zod.run({value:d,issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(p.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map(x=>fi(x,r,hi())),input:d,path:[d],inst:e});continue}const m=p.value,g=t.valueType._zod.run({value:i[d],issues:[]},r);g instanceof Promise?o.push(g.then(x=>{x.issues.length&&n.issues.push(...go(d,x.issues)),n.value[m]=x.value})):(g.issues.length&&n.issues.push(...go(d,g.issues)),n.value[m]=g.value)}let h;for(const d in i)u.has(d)||(h=h??[],h.push(d));h&&h.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:h})}else{n.value={};for(const u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let h=t.keyType._zod.run({value:u,issues:[]},r);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&wk.test(u)&&h.issues.length){const m=t.keyType._zod.run({value:Number(u),issues:[]},r);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(h=m)}if(h.issues.length){t.mode==="loose"?n.value[u]=i[u]:n.issues.push({code:"invalid_key",origin:"record",issues:h.issues.map(m=>fi(m,r,hi())),input:u,path:[u],inst:e});continue}const p=t.valueType._zod.run({value:i[u],issues:[]},r);p instanceof Promise?o.push(p.then(m=>{m.issues.length&&n.issues.push(...go(u,m.issues)),n.value[h.value]=m.value})):(p.issues.length&&n.issues.push(...go(u,p.issues)),n.value[h.value]=p.value)}}return o.length?Promise.all(o).then(()=>n):n}}),GC=ve("$ZodEnum",(e,t)=>{Kt.init(e,t);const n=pk(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(i=>n1.has(typeof i)).map(i=>typeof i=="string"?Mo(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const c=i.value;return r.has(c)||i.issues.push({code:"invalid_value",values:n,input:c,inst:e}),i}}),KC=ve("$ZodLiteral",(e,t)=>{if(Kt.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Mo(r):r?Mo(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),YC=ve("$ZodTransform",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new fk(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(n.value=c,n.fallback=!0,n));if(i instanceof Promise)throw new yo;return n.value=i,n.fallback=!0,n}});function l0(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const $k=ve("$ZodOptional",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",e._zod.optout="optional",Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Cm(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const i=n.value,o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(c=>l0(c,i)):l0(o,i)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),XC=ve("$ZodExactOptional",(e,t)=>{$k.init(e,t),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),QC=ve("$ZodNullable",(e,t)=>{Kt.init(e,t),Mt(e._zod,"optin",()=>t.innerType._zod.optin),Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Cm(n.source)}|null)$`):void 0}),Mt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),JC=ve("$ZodDefault",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>c0(o,t)):c0(i,t)}});function c0(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const eA=ve("$ZodPrefault",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),tA=ve("$ZodNonOptional",(e,t)=>{Kt.init(e,t),Mt(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>u0(o,e)):u0(i,e)}});function u0(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 nA=ve("$ZodCatch",(e,t)=>{Kt.init(e,t),e._zod.optin="optional",Mt(e._zod,"optout",()=>t.innerType._zod.optout),Mt(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(c=>fi(c,r,hi()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>fi(o,r,hi()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),sA=ve("$ZodPipe",(e,t)=>{Kt.init(e,t),Mt(e._zod,"values",()=>t.in._zod.values),Mt(e._zod,"optin",()=>t.in._zod.optin),Mt(e._zod,"optout",()=>t.out._zod.optout),Mt(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(c=>Nu(c,t.in,r)):Nu(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>Nu(o,t.out,r)):Nu(i,t.out,r)}});function Nu(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 rA=ve("$ZodReadonly",(e,t)=>{Kt.init(e,t),Mt(e._zod,"propValues",()=>t.innerType._zod.propValues),Mt(e._zod,"values",()=>t.innerType._zod.values),Mt(e._zod,"optin",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optin}),Mt(e._zod,"optout",()=>{var n,r;return(r=(n=t.innerType)==null?void 0:n._zod)==null?void 0:r.optout}),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(d0):d0(i)}});function d0(e){return e.value=Object.freeze(e.value),e}const iA=ve("$ZodCustom",(e,t)=>{ws.init(e,t),Kt.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>h0(o,n,r,e));h0(i,n,r,e)}});function h0(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(Xl(i))}}var f0;class aA{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function oA(){return new aA}(f0=globalThis).__zod_globalRegistry??(f0.__zod_globalRegistry=oA());const Ol=globalThis.__zod_globalRegistry;function lA(e,t){return new e({type:"string",...Qe(t)})}function cA(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Qe(t)})}function p0(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Qe(t)})}function uA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Qe(t)})}function dA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Qe(t)})}function hA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Qe(t)})}function fA(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Qe(t)})}function Mk(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Qe(t)})}function pA(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Qe(t)})}function mA(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Qe(t)})}function gA(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Qe(t)})}function xA(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Qe(t)})}function vA(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Qe(t)})}function yA(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Qe(t)})}function bA(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Qe(t)})}function kA(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Qe(t)})}function NA(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Qe(t)})}function wA(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Qe(t)})}function jA(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Qe(t)})}function SA(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Qe(t)})}function _A(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Qe(t)})}function EA(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Qe(t)})}function CA(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Qe(t)})}function AA(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Qe(t)})}function IA(e,t){return new e({type:"string",format:"date",check:"string_format",...Qe(t)})}function TA(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Qe(t)})}function $A(e,t){return new e({type:"string",format:"duration",check:"string_format",...Qe(t)})}function MA(e,t){return new e({type:"number",checks:[],...Qe(t)})}function RA(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Qe(t)})}function OA(e,t){return new e({type:"boolean",...Qe(t)})}function zA(e,t){return new e({type:"null",...Qe(t)})}function PA(e){return new e({type:"unknown"})}function LA(e,t){return new e({type:"never",...Qe(t)})}function m0(e,t){return new Sk({check:"less_than",...Qe(t),value:e,inclusive:!1})}function jf(e,t){return new Sk({check:"less_than",...Qe(t),value:e,inclusive:!0})}function g0(e,t){return new _k({check:"greater_than",...Qe(t),value:e,inclusive:!1})}function Sf(e,t){return new _k({check:"greater_than",...Qe(t),value:e,inclusive:!0})}function x0(e,t){return new Q1({check:"multiple_of",...Qe(t),value:e})}function Rk(e,t){return new eC({check:"max_length",...Qe(t),maximum:e})}function Ju(e,t){return new tC({check:"min_length",...Qe(t),minimum:e})}function Ok(e,t){return new nC({check:"length_equals",...Qe(t),length:e})}function DA(e,t){return new sC({check:"string_format",format:"regex",...Qe(t),pattern:e})}function FA(e){return new rC({check:"string_format",format:"lowercase",...Qe(e)})}function BA(e){return new iC({check:"string_format",format:"uppercase",...Qe(e)})}function UA(e,t){return new aC({check:"string_format",format:"includes",...Qe(t),includes:e})}function HA(e,t){return new oC({check:"string_format",format:"starts_with",...Qe(t),prefix:e})}function ZA(e,t){return new lC({check:"string_format",format:"ends_with",...Qe(t),suffix:e})}function Ho(e){return new cC({check:"overwrite",tx:e})}function WA(e){return Ho(t=>t.normalize(e))}function VA(){return Ho(e=>e.trim())}function qA(){return Ho(e=>e.toLowerCase())}function GA(){return Ho(e=>e.toUpperCase())}function KA(){return Ho(e=>e1(e))}function YA(e,t,n){return new e({type:"array",element:t,...Qe(n)})}function XA(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Qe(n)})}function QA(e,t){const n=JA(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(Xl(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(Xl(o))}},e(r.value,r)),t);return n}function JA(e,t){const n=new ws({check:"custom",...Qe(t)});return n._zod.check=e,n}function zk(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)??Ol,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function bn(e,t,n={path:[],schemaPath:[]}){var p,m;var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const c={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,c);const u=(m=(p=e._zod).toJSONSchema)==null?void 0:m.call(p);if(u)c.schema=u;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,c.schema,g);else{const y=c.schema,E=t.processors[i.type];if(!E)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);E(e,t,y,g)}const x=e._zod.parent;x&&(c.ref||(c.ref=x),bn(x,t,g),t.seen.get(x).isParent=!0)}const h=t.metadataRegistry.get(e);return h&&Object.assign(c.schema,h),t.io==="input"&&ss(e)&&(delete c.schema.examples,delete c.schema.default),t.io==="input"&&"_prefault"in c.schema&&((r=c.schema).default??(r.default=c.schema._prefault)),delete c.schema._prefault,t.seen.get(e).schema}function Pk(e,t){var c,u,h,d;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const p of e.seen.entries()){const m=(c=e.metadataRegistry.get(p[0]))==null?void 0:c.id;if(m){const g=r.get(m);if(g&&g!==p[0])throw new Error(`Duplicate schema id "${m}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(m,p[0])}}const i=p=>{var E;const m=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const N=(E=e.external.registry.get(p[0]))==null?void 0:E.id,w=e.external.uri??(k=>k);if(N)return{ref:w(N)};const T=p[1].defId??p[1].schema.id??`schema${e.counter++}`;return p[1].defId=T,{defId:T,ref:`${w("__shared")}#/${m}/${T}`}}if(p[1]===n)return{ref:"#"};const x=`#/${m}/`,y=p[1].schema.id??`__schema${e.counter++}`;return{defId:y,ref:x+y}},o=p=>{if(p[1].schema.$ref)return;const m=p[1],{ref:g,defId:x}=i(p);m.def={...m.schema},x&&(m.defId=x);const y=m.schema;for(const E in y)delete y[E];y.$ref=g};if(e.cycles==="throw")for(const p of e.seen.entries()){const m=p[1];if(m.cycle)throw new Error(`Cycle detected: #/${(u=m.cycle)==null?void 0:u.join("/")}/<root>
102
+
103
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const p of e.seen.entries()){const m=p[1];if(t===p[0]){o(p);continue}if(e.external){const x=(h=e.external.registry.get(p[0]))==null?void 0:h.id;if(t!==p[0]&&x){o(p);continue}}if((d=e.metadataRegistry.get(p[0]))==null?void 0:d.id){o(p);continue}if(m.cycle){o(p);continue}if(m.count>1&&e.reused==="ref"){o(p);continue}}}function Lk(e,t){var u,h,d,p;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=m=>{const g=e.seen.get(m);if(g.ref===null)return;const x=g.def??g.schema,y={...x},E=g.ref;if(g.ref=null,E){r(E);const w=e.seen.get(E),T=w.schema;if(T.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(x.allOf=x.allOf??[],x.allOf.push(T)):Object.assign(x,T),Object.assign(x,y),m._zod.parent===E)for(const I in x)I==="$ref"||I==="allOf"||I in y||delete x[I];if(T.$ref&&w.def)for(const I in x)I==="$ref"||I==="allOf"||I in w.def&&JSON.stringify(x[I])===JSON.stringify(w.def[I])&&delete x[I]}const N=m._zod.parent;if(N&&N!==E){r(N);const w=e.seen.get(N);if(w!=null&&w.schema.$ref&&(x.$ref=w.schema.$ref,w.def))for(const T in x)T==="$ref"||T==="allOf"||T in w.def&&JSON.stringify(x[T])===JSON.stringify(w.def[T])&&delete x[T]}e.override({zodSchema:m,jsonSchema:x,path:g.path??[]})};for(const m of[...e.seen.entries()].reverse())r(m[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(u=e.external)!=null&&u.uri){const m=(h=e.external.registry.get(t))==null?void 0:h.id;if(!m)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(m)}Object.assign(i,n.def??n.schema);const o=(d=e.metadataRegistry.get(t))==null?void 0:d.id;o!==void 0&&i.id===o&&delete i.id;const c=((p=e.external)==null?void 0:p.defs)??{};for(const m of e.seen.entries()){const g=m[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,c[g.defId]=g.def)}e.external||Object.keys(c).length>0&&(e.target==="draft-2020-12"?i.$defs=c:i.definitions=c);try{const m=JSON.parse(JSON.stringify(i));return Object.defineProperty(m,"~standard",{value:{...t["~standard"],jsonSchema:{input:ed(t,"input",e.processors),output:ed(t,"output",e.processors)}},enumerable:!1,writable:!1}),m}catch{throw new Error("Error converting schema to JSON.")}}function ss(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ss(r.element,n);if(r.type==="set")return ss(r.valueType,n);if(r.type==="lazy")return ss(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ss(r.innerType,n);if(r.type==="intersection")return ss(r.left,n)||ss(r.right,n);if(r.type==="record"||r.type==="map")return ss(r.keyType,n)||ss(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ss(r.in,n)||ss(r.out,n);if(r.type==="object"){for(const i in r.shape)if(ss(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(ss(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(ss(i,n))return!0;return!!(r.rest&&ss(r.rest,n))}return!1}const eI=(e,t={})=>n=>{const r=zk({...n,processors:t});return bn(e,r),Pk(r,e),Lk(r,e)},ed=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},c=zk({...i??{},target:o,io:t,processors:n});return bn(e,c),Pk(c,e),Lk(c,e)},tI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nI=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:c,format:u,patterns:h,contentEncoding:d}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof c=="number"&&(i.maxLength=c),u&&(i.format=tI[u]??u,i.format===""&&delete i.format,u==="time"&&delete i.format),d&&(i.contentEncoding=d),h&&h.size>0){const p=[...h];p.length===1?i.pattern=p[0].source:p.length>1&&(i.allOf=[...p.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},sI=(e,t,n,r)=>{const i=n,{minimum:o,maximum:c,format:u,multipleOf:h,exclusiveMaximum:d,exclusiveMinimum:p}=e._zod.bag;typeof u=="string"&&u.includes("int")?i.type="integer":i.type="number";const m=typeof p=="number"&&p>=(o??Number.NEGATIVE_INFINITY),g=typeof d=="number"&&d<=(c??Number.POSITIVE_INFINITY),x=t.target==="draft-04"||t.target==="openapi-3.0";m?x?(i.minimum=p,i.exclusiveMinimum=!0):i.exclusiveMinimum=p:typeof o=="number"&&(i.minimum=o),g?x?(i.maximum=d,i.exclusiveMaximum=!0):i.exclusiveMaximum=d:typeof c=="number"&&(i.maximum=c),typeof h=="number"&&(i.multipleOf=h)},rI=(e,t,n,r)=>{n.type="boolean"},iI=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},aI=(e,t,n,r)=>{n.not={}},oI=(e,t,n,r)=>{},lI=(e,t,n,r)=>{const i=e._zod.def,o=pk(i.entries);o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),n.enum=o},cI=(e,t,n,r)=>{const i=e._zod.def,o=[];for(const c of i.values)if(c===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof c=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(c))}else o.push(c);if(o.length!==0)if(o.length===1){const c=o[0];n.type=c===null?"null":typeof c,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[c]:n.const=c}else o.every(c=>typeof c=="number")&&(n.type="number"),o.every(c=>typeof c=="string")&&(n.type="string"),o.every(c=>typeof c=="boolean")&&(n.type="boolean"),o.every(c=>c===null)&&(n.type="null"),n.enum=o},uI=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},dI=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},hI=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:c,maximum:u}=e._zod.bag;typeof c=="number"&&(i.minItems=c),typeof u=="number"&&(i.maxItems=u),i.type="array",i.items=bn(o.element,t,{...r,path:[...r.path,"items"]})},fI=(e,t,n,r)=>{var d;const i=n,o=e._zod.def;i.type="object",i.properties={};const c=o.shape;for(const p in c)i.properties[p]=bn(c[p],t,{...r,path:[...r.path,"properties",p]});const u=new Set(Object.keys(c)),h=new Set([...u].filter(p=>{const m=o.shape[p]._zod;return t.io==="input"?m.optin===void 0:m.optout===void 0}));h.size>0&&(i.required=Array.from(h)),((d=o.catchall)==null?void 0:d._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=bn(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},pI=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,c=i.options.map((u,h)=>bn(u,t,{...r,path:[...r.path,o?"oneOf":"anyOf",h]}));o?n.oneOf=c:n.anyOf=c},mI=(e,t,n,r)=>{const i=e._zod.def,o=bn(i.left,t,{...r,path:[...r.path,"allOf",0]}),c=bn(i.right,t,{...r,path:[...r.path,"allOf",1]}),u=d=>"allOf"in d&&Object.keys(d).length===1,h=[...u(o)?o.allOf:[o],...u(c)?c.allOf:[c]];n.allOf=h},gI=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const c=o.keyType,u=c._zod.bag,h=u==null?void 0:u.patterns;if(o.mode==="loose"&&h&&h.size>0){const p=bn(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const m of h)i.patternProperties[m.source]=p}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=bn(o.keyType,t,{...r,path:[...r.path,"propertyNames"]})),i.additionalProperties=bn(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const d=c._zod.values;if(d){const p=[...d].filter(m=>typeof m=="string"||typeof m=="number");p.length>0&&(i.required=p)}},xI=(e,t,n,r)=>{const i=e._zod.def,o=bn(i.innerType,t,r),c=t.seen.get(e);t.target==="openapi-3.0"?(c.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},vI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},yI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},bI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},kI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let c;try{c=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=c},NI=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),c=t.io==="input"?o?i.out:i.in:i.out;bn(c,t,r);const u=t.seen.get(e);u.ref=c},wI=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Dk=(e,t,n,r)=>{const i=e._zod.def;bn(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},jI=ve("ZodISODateTime",(e,t)=>{wC.init(e,t),nn.init(e,t)});function SI(e){return AA(jI,e)}const _I=ve("ZodISODate",(e,t)=>{jC.init(e,t),nn.init(e,t)});function EI(e){return IA(_I,e)}const CI=ve("ZodISOTime",(e,t)=>{SC.init(e,t),nn.init(e,t)});function AI(e){return TA(CI,e)}const II=ve("ZodISODuration",(e,t)=>{_C.init(e,t),nn.init(e,t)});function TI(e){return $A(II,e)}const $I=(e,t)=>{vk.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>p1(e,n)},flatten:{value:n=>f1(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,jp,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,jp,2)}},isEmpty:{get(){return e.issues.length===0}}})},Js=ve("ZodError",$I,{Parent:Error}),MI=Im(Js),RI=Tm(Js),OI=_d(Js),zI=Ed(Js),PI=x1(Js),LI=v1(Js),DI=y1(Js),FI=b1(Js),BI=k1(Js),UI=N1(Js),HI=w1(Js),ZI=j1(Js),v0=new WeakMap;function fc(e,t,n){const r=Object.getPrototypeOf(e);let i=v0.get(r);if(i||(i=new Set,v0.set(r,i)),!i.has(t)){i.add(t);for(const o in n){const c=n[o];Object.defineProperty(r,o,{configurable:!0,enumerable:!1,get(){const u=c.bind(this);return Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u}),u},set(u){Object.defineProperty(this,o,{configurable:!0,writable:!0,enumerable:!0,value:u})}})}}}const Xt=ve("ZodType",(e,t)=>(Kt.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ed(e,"input"),output:ed(e,"output")}}),e.toJSONSchema=eI(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>MI(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>OI(e,n,r),e.parseAsync=async(n,r)=>RI(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>zI(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>PI(e,n,r),e.decode=(n,r)=>LI(e,n,r),e.encodeAsync=async(n,r)=>DI(e,n,r),e.decodeAsync=async(n,r)=>FI(e,n,r),e.safeEncode=(n,r)=>BI(e,n,r),e.safeDecode=(n,r)=>UI(e,n,r),e.safeEncodeAsync=async(n,r)=>HI(e,n,r),e.safeDecodeAsync=async(n,r)=>ZI(e,n,r),fc(e,"ZodType",{check(...n){const r=this.def;return this.clone(Ji(r,{checks:[...r.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ea(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(PT(n,r))},superRefine(n,r){return this.check(LT(n,r))},overwrite(n){return this.check(Ho(n))},optional(){return N0(this)},exactOptional(){return jT(this)},nullable(){return w0(this)},nullish(){return N0(w0(this))},nonoptional(n){return IT(this,n)},array(){return ue(this)},or(n){return Ro([this,n])},and(n){return yT(this,n)},transform(n){return j0(this,NT(n))},default(n){return ET(this,n)},prefault(n){return AT(this,n)},catch(n){return $T(this,n)},pipe(n){return j0(this,n)},readonly(){return OT(this)},describe(n){const r=this.clone();return Ol.add(r,{description:n}),r},meta(...n){if(n.length===0)return Ol.get(this);const r=this.clone();return Ol.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){var n;return(n=Ol.get(e))==null?void 0:n.description},configurable:!0}),e)),Fk=ve("_ZodString",(e,t)=>{$m.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(r,i,o)=>nI(e,r,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,fc(e,"_ZodString",{regex(...r){return this.check(DA(...r))},includes(...r){return this.check(UA(...r))},startsWith(...r){return this.check(HA(...r))},endsWith(...r){return this.check(ZA(...r))},min(...r){return this.check(Ju(...r))},max(...r){return this.check(Rk(...r))},length(...r){return this.check(Ok(...r))},nonempty(...r){return this.check(Ju(1,...r))},lowercase(r){return this.check(FA(r))},uppercase(r){return this.check(BA(r))},trim(){return this.check(VA())},normalize(...r){return this.check(WA(...r))},toLowerCase(){return this.check(qA())},toUpperCase(){return this.check(GA())},slugify(){return this.check(KA())}})}),WI=ve("ZodString",(e,t)=>{$m.init(e,t),Fk.init(e,t),e.email=n=>e.check(cA(VI,n)),e.url=n=>e.check(Mk(Bk,n)),e.jwt=n=>e.check(CA(oT,n)),e.emoji=n=>e.check(pA(qI,n)),e.guid=n=>e.check(p0(y0,n)),e.uuid=n=>e.check(uA(wu,n)),e.uuidv4=n=>e.check(dA(wu,n)),e.uuidv6=n=>e.check(hA(wu,n)),e.uuidv7=n=>e.check(fA(wu,n)),e.nanoid=n=>e.check(mA(GI,n)),e.guid=n=>e.check(p0(y0,n)),e.cuid=n=>e.check(gA(KI,n)),e.cuid2=n=>e.check(xA(YI,n)),e.ulid=n=>e.check(vA(XI,n)),e.base64=n=>e.check(SA(rT,n)),e.base64url=n=>e.check(_A(iT,n)),e.xid=n=>e.check(yA(QI,n)),e.ksuid=n=>e.check(bA(JI,n)),e.ipv4=n=>e.check(kA(eT,n)),e.ipv6=n=>e.check(NA(tT,n)),e.cidrv4=n=>e.check(wA(nT,n)),e.cidrv6=n=>e.check(jA(sT,n)),e.e164=n=>e.check(EA(aT,n)),e.datetime=n=>e.check(SI(n)),e.date=n=>e.check(EI(n)),e.time=n=>e.check(AI(n)),e.duration=n=>e.check(TI(n))});function S(e){return lA(WI,e)}const nn=ve("ZodStringFormat",(e,t)=>{Yt.init(e,t),Fk.init(e,t)}),VI=ve("ZodEmail",(e,t)=>{pC.init(e,t),nn.init(e,t)}),y0=ve("ZodGUID",(e,t)=>{hC.init(e,t),nn.init(e,t)}),wu=ve("ZodUUID",(e,t)=>{fC.init(e,t),nn.init(e,t)}),Bk=ve("ZodURL",(e,t)=>{mC.init(e,t),nn.init(e,t)});function _p(e){return Mk(Bk,e)}const qI=ve("ZodEmoji",(e,t)=>{gC.init(e,t),nn.init(e,t)}),GI=ve("ZodNanoID",(e,t)=>{xC.init(e,t),nn.init(e,t)}),KI=ve("ZodCUID",(e,t)=>{vC.init(e,t),nn.init(e,t)}),YI=ve("ZodCUID2",(e,t)=>{yC.init(e,t),nn.init(e,t)}),XI=ve("ZodULID",(e,t)=>{bC.init(e,t),nn.init(e,t)}),QI=ve("ZodXID",(e,t)=>{kC.init(e,t),nn.init(e,t)}),JI=ve("ZodKSUID",(e,t)=>{NC.init(e,t),nn.init(e,t)}),eT=ve("ZodIPv4",(e,t)=>{EC.init(e,t),nn.init(e,t)}),tT=ve("ZodIPv6",(e,t)=>{CC.init(e,t),nn.init(e,t)}),nT=ve("ZodCIDRv4",(e,t)=>{AC.init(e,t),nn.init(e,t)}),sT=ve("ZodCIDRv6",(e,t)=>{IC.init(e,t),nn.init(e,t)}),rT=ve("ZodBase64",(e,t)=>{TC.init(e,t),nn.init(e,t)}),iT=ve("ZodBase64URL",(e,t)=>{MC.init(e,t),nn.init(e,t)}),aT=ve("ZodE164",(e,t)=>{RC.init(e,t),nn.init(e,t)}),oT=ve("ZodJWT",(e,t)=>{zC.init(e,t),nn.init(e,t)}),Uk=ve("ZodNumber",(e,t)=>{Ck.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(r,i,o)=>sI(e,r,i),fc(e,"ZodNumber",{gt(r,i){return this.check(g0(r,i))},gte(r,i){return this.check(Sf(r,i))},min(r,i){return this.check(Sf(r,i))},lt(r,i){return this.check(m0(r,i))},lte(r,i){return this.check(jf(r,i))},max(r,i){return this.check(jf(r,i))},int(r){return this.check(b0(r))},safe(r){return this.check(b0(r))},positive(r){return this.check(g0(0,r))},nonnegative(r){return this.check(Sf(0,r))},negative(r){return this.check(m0(0,r))},nonpositive(r){return this.check(jf(0,r))},multipleOf(r,i){return this.check(x0(r,i))},step(r,i){return this.check(x0(r,i))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function te(e){return MA(Uk,e)}const lT=ve("ZodNumberFormat",(e,t)=>{PC.init(e,t),Uk.init(e,t)});function b0(e){return RA(lT,e)}const cT=ve("ZodBoolean",(e,t)=>{LC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rI(e,n,r)});function Ne(e){return OA(cT,e)}const uT=ve("ZodNull",(e,t)=>{DC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>iI(e,n,r)});function dT(e){return zA(uT,e)}const hT=ve("ZodUnknown",(e,t)=>{FC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>oI()});function Ep(){return PA(hT)}const fT=ve("ZodNever",(e,t)=>{BC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>aI(e,n,r)});function pT(e){return LA(fT,e)}const mT=ve("ZodArray",(e,t)=>{UC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hI(e,n,r,i),e.element=t.element,fc(e,"ZodArray",{min(n,r){return this.check(Ju(n,r))},nonempty(n){return this.check(Ju(1,n))},max(n,r){return this.check(Rk(n,r))},length(n,r){return this.check(Ok(n,r))},unwrap(){return this.element}})});function ue(e,t){return YA(mT,e,t)}const gT=ve("ZodObject",(e,t)=>{ZC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fI(e,n,r,i),Mt(e,"shape",()=>t.shape),fc(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:Ep()})},loose(){return this.clone({...this._zod.def,catchall:Ep()})},strict(){return this.clone({...this._zod.def,catchall:pT()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return o1(this,n)},safeExtend(n){return l1(this,n)},merge(n){return c1(this,n)},pick(n){return i1(this,n)},omit(n){return a1(this,n)},partial(...n){return u1(Zk,this,n[0])},required(...n){return d1(Wk,this,n[0])}})});function O(e,t){const n={type:"object",shape:e??{},...Qe(t)};return new gT(n)}const Hk=ve("ZodUnion",(e,t)=>{Tk.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pI(e,n,r,i),e.options=t.options});function Ro(e,t){return new Hk({type:"union",options:e,...Qe(t)})}const xT=ve("ZodDiscriminatedUnion",(e,t)=>{Hk.init(e,t),WC.init(e,t)});function Pa(e,t,n){return new xT({type:"union",options:t,discriminator:e,...Qe(n)})}const vT=ve("ZodIntersection",(e,t)=>{VC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mI(e,n,r,i)});function yT(e,t){return new vT({type:"intersection",left:e,right:t})}const k0=ve("ZodRecord",(e,t)=>{qC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gI(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function _r(e,t,n){return!t||!t._zod?new k0({type:"record",keyType:S(),valueType:e,...Qe(t)}):new k0({type:"record",keyType:e,valueType:t,...Qe(n)})}const Cp=ve("ZodEnum",(e,t)=>{GC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(r,i,o)=>lI(e,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const c of r)if(n.has(c))o[c]=t.entries[c];else throw new Error(`Key ${c} not found in enum`);return new Cp({...t,checks:[],...Qe(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const c of r)if(n.has(c))delete o[c];else throw new Error(`Key ${c} not found in enum`);return new Cp({...t,checks:[],...Qe(i),entries:o})}});function Pe(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Cp({type:"enum",entries:n,...Qe(t)})}const bT=ve("ZodLiteral",(e,t)=>{KC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cI(e,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function dt(e,t){return new bT({type:"literal",values:Array.isArray(e)?e:[e],...Qe(t)})}const kT=ve("ZodTransform",(e,t)=>{YC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>dI(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new fk(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Xl(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(Xl(c))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function NT(e){return new kT({type:"transform",transform:e})}const Zk=ve("ZodOptional",(e,t)=>{$k.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Dk(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function N0(e){return new Zk({type:"optional",innerType:e})}const wT=ve("ZodExactOptional",(e,t)=>{XC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Dk(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function jT(e){return new wT({type:"optional",innerType:e})}const ST=ve("ZodNullable",(e,t)=>{QC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function w0(e){return new ST({type:"nullable",innerType:e})}const _T=ve("ZodDefault",(e,t)=>{JC.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ET(e,t){return new _T({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():gk(t)}})}const CT=ve("ZodPrefault",(e,t)=>{eA.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function AT(e,t){return new CT({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():gk(t)}})}const Wk=ve("ZodNonOptional",(e,t)=>{tA.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function IT(e,t){return new Wk({type:"nonoptional",innerType:e,...Qe(t)})}const TT=ve("ZodCatch",(e,t)=>{nA.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $T(e,t){return new TT({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const MT=ve("ZodPipe",(e,t)=>{sA.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>NI(e,n,r,i),e.in=t.in,e.out=t.out});function j0(e,t){return new MT({type:"pipe",in:e,out:t})}const RT=ve("ZodReadonly",(e,t)=>{rA.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wI(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function OT(e){return new RT({type:"readonly",innerType:e})}const zT=ve("ZodCustom",(e,t)=>{iA.init(e,t),Xt.init(e,t),e._zod.processJSONSchema=(n,r,i)=>uI(e,n)});function PT(e,t={}){return XA(zT,e,t)}function LT(e,t){return QA(e,t)}const _f=Pa("type",[O({type:dt("text"),text:S()}),O({type:dt("reasoning"),text:S()}),O({type:dt("image"),name:S().optional(),mediaType:S().optional(),width:te().optional(),height:te().optional(),attachmentId:S().optional(),bytes:te().optional()}),O({type:dt("file"),name:S().optional(),size:te().optional(),mediaType:S().optional()}),O({type:dt("tool-call"),callId:S(),name:S(),arguments:S()}),O({type:dt("other"),kind:S()})]),S0=O({inputTokens:te(),outputTokens:te(),totalTokens:te().optional(),cacheReadTokens:te().optional(),cacheWriteTokens:te().optional(),reasoningTokens:te().optional()}),_0=O({firstChunkAt:te().optional(),firstTokenAt:te().optional(),lastChunkAt:te().optional(),tokenChunks:te()}),E0=O({message:S(),code:S().optional()}),DT=O({kind:S(),message:S().optional()}),FT=O({kind:S(),human:Ne(),summary:S().optional()}),Mn={seq:te(),time:te()},Ap=Pa("type",[O({...Mn,type:dt("turn/start"),turn:te()}),O({...Mn,type:dt("turn/end"),turn:te(),reason:DT}),O({...Mn,type:dt("step/start"),turn:te(),step:te()}),O({...Mn,type:dt("step/end"),turn:te(),step:te()}),O({...Mn,type:dt("user/message"),messageId:S(),content:ue(_f),origin:FT,requestId:S().optional(),replacesHistory:Ne().optional()}),O({...Mn,type:dt("system/message"),turn:te(),step:te(),text:S()}),O({...Mn,type:dt("assistant/message"),turn:te(),step:te(),messageId:S(),content:ue(_f),timing:_0,usage:S0.optional(),interrupted:Ne().optional(),provider:S().optional(),model:S().optional()}),O({...Mn,type:dt("assistant/attempt"),turn:te(),step:te(),timing:_0,error:E0.optional()}),O({...Mn,type:dt("tool/call"),turn:te(),step:te(),callId:S(),name:S(),arguments:S()}),O({...Mn,type:dt("tool/result"),turn:te(),step:te(),callId:S(),isError:Ne(),content:ue(_f),error:E0.optional()}),O({...Mn,type:dt("request/header"),provider:S().optional(),model:S().optional(),reasoningEffort:S().optional(),toolNames:ue(S()),reason:S()}),O({...Mn,type:dt("compaction/start"),compactionId:S(),turn:te().nullable()}),O({...Mn,type:dt("compaction/summary"),compactionId:S(),shadowedTokenCount:te(),provider:S().optional(),model:S().optional(),usage:S0.optional()}),O({...Mn,type:dt("compaction/end"),compactionId:S(),turn:te().nullable(),error:S().optional()}),O({...Mn,type:dt("approval/asked"),approvalId:S(),toolName:S(),callId:S().optional(),reason:S().optional()}),O({...Mn,type:dt("approval/decided"),approvalId:S(),outcome:S()}),O({...Mn,type:dt("session/title"),title:S()}),O({...Mn,type:dt("unknown"),upstreamType:S(),data:Ep()})]),Vk=Pa("type",[O({type:dt("start"),attemptId:S(),turn:te(),step:te(),afterSeq:te()}),O({type:dt("delta"),attemptId:S(),time:te(),kind:Pe(["text","reasoning","tool-args"]),index:te(),text:S(),callId:S().optional(),toolName:S().optional()}),O({type:dt("end"),attemptId:S(),outcome:Pe(["committed","abandoned"]),seq:te().optional()})]),BT=O({attemptId:S(),turn:te(),step:te(),afterSeq:te(),deltas:ue(Vk.options[1])}),UT=O({index:te().int().min(0),name:S(),running:Ne(),ready:Ne(),adb:S().optional()}),HT=O({kind:Pe(["mumu"]),name:S(),manager:S(),version:S().optional(),instances:ue(UT),error:S().optional()}),qk=O({mumuManager:S().optional(),instance:te().int().min(0).max(63),manualAddress:S().regex(/^[\w.-]+:\d{1,5}$/).optional(),adbPath:S().optional(),autoStart:Ne(),bootTimeoutSeconds:te().int().min(30).max(900)});O({providers:ue(HT),settings:qk,selection:O({label:S(),address:S().optional(),problem:S().optional()})});O({refresh:Ne().optional()}),O({index:te().int().min(0).optional()}),O({address:S(),label:S()}),O({index:te().int().min(0).optional()}),O({}),qk.partial().extend({mumuManager:S().nullable().optional(),manualAddress:S().regex(/^[\w.-]+:\d{1,5}$/).nullable().optional(),adbPath:S().nullable().optional()});O({});const Mm=Pe(["maafw-pi","cli","gui-config","generic-process","visual"]),Et=S().regex(/^[a-z0-9][a-z0-9._-]{0,63}$/,"use lowercase letters, digits, dot, dash or underscore (max 64)"),Ul=S().trim().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,"use owner/repo"),Ef=S().trim().regex(/^[A-Za-z0-9_.-]{1,100}$/,"use the resource id, e.g. MAA or BGI"),ZT=Pa("kind",[O({kind:dt("github"),repo:S()}),O({kind:dt("mirrorchyan"),rid:S(),platform:Ne(),os:Ne().optional(),arch:Ne().optional()}),O({kind:dt("local"),path:S()})]),WT=O({version:S(),dir:S(),installedAt:te(),asset:O({name:S(),size:te()}).optional(),current:Ne()}),VT=Pe(["ok","missing","outdated","unknown","unsupported"]),qT=O({kind:S(),label:S(),required:S().optional(),status:VT,found:S().optional(),detail:S().optional(),fix:O({kind:Pe(["auto","installer","manual"]),description:S(),needsAdmin:Ne()}).optional()}),GT=O({checkedAt:te(),ok:Ne(),items:ue(qT)}),KT=O({executables:ue(S()),markers:ue(S()),family:Mm.optional()}),C0=Pe(["install","pack","known","user"]),YT=O({github:O({repo:S(),from:C0}).optional(),mirrorchyan:O({rid:S(),from:C0}).optional()}),XT=O({version:S(),from:S()}),QT=O({state:Pe(["running","done","failed"]),at:te(),text:S().optional(),sessionId:S().optional()}),JT=O({id:S(),name:S(),source:ZT,packId:S().optional(),family:Mm.optional(),current:S().optional(),dir:S().optional(),versions:ue(WT),env:GT.optional(),probe:KT.optional(),update:O({latest:S(),available:Ne(),checkedAt:te()}).optional(),channels:YT,known:S().optional(),localVersion:XT.optional(),undo:O({from:S().optional(),to:S(),at:te()}).optional(),jobId:S().optional(),addedAt:te(),summary:QT.optional(),packReview:O({from:S().optional(),to:S()}).optional(),optimize:O({runs:te(),at:te().optional(),due:Pe(["runs","updated"]).optional()}).optional()}),e$=O({id:S(),name:S(),description:S().optional(),repo:S().optional(),mirrorchyan:S().optional(),family:Mm.optional(),builtin:Ne(),installed:Ne(),error:S().optional()});O({rid:S(),version:S(),platform:Ne(),os:Ne().optional(),arch:Ne().optional(),name:S().optional(),description:S().optional(),repo:S().optional()});const Ip=O({rid:S(),name:S(),description:S(),repo:S().optional(),url:S().optional(),installed:Ne(),known:Ne()}),t$=O({id:S(),name:S(),repo:S().optional(),mirrorchyan:S().optional(),installed:Ne()}),n$=O({name:S(),size:te(),downloadUrl:S(),digest:S().optional()}),s$=O({tag:S(),name:S(),prerelease:Ne(),publishedAt:S().optional(),url:S().optional(),assets:ue(n$),suggestedAsset:S().optional(),notes:S().optional()}),r$=Pe(["queued","resolving","downloading","verifying","extracting","checking","running","done","failed","cancelled"]),i$=O({sessionId:S(),state:Pe(["running","failed"]),reason:S().optional()}),a$=O({scriptId:S(),name:S(),kind:Pe(["nsis","inno","kachina"]),version:S(),dir:S(),update:Ne(),at:te(),agent:i$.optional()}),o$=O({id:S(),kind:Pe(["install","update","env-fix"]),scriptId:S(),phase:r$,message:S().optional(),received:te().optional(),total:te().optional(),version:S().optional(),error:S().optional(),setup:O({kind:Pe(["nsis","inno","kachina"]),dir:S(),sessionId:S().optional()}).optional(),startedAt:te(),endedAt:te().optional()}),A0=O({apiBase:_p({protocol:/^https?$/}),downloadMirror:S().trim().max(300),mirrorFallback:Ne(),tokenRef:S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),keepVersions:te().int().min(1).max(10),includePrereleases:Ne(),cdkRef:S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/)});O({});O({id:Et});O({scripts:ue(JT),packs:ue(e$),known:ue(t$),setups:ue(a$).default([]),toolsDir:S()}),O({query:S().trim().min(1).max(200)}),O({items:ue(O({repo:S(),description:S().optional(),stars:te(),packId:S().optional()}))}),O({repo:Ul,limit:te().int().min(1).max(30).optional()}),O({repo:S(),packId:S().optional(),releases:ue(s$)}),O({repo:Ul.optional(),mirrorchyan:Ef.optional(),tag:S().min(1).max(200).optional(),asset:S().min(1).max(300).optional(),branch:S().min(1).max(200).optional(),id:Et.optional()}).refine(e=>e.repo===void 0!=(e.mirrorchyan===void 0),"give either repo or mirrorchyan"),O({jobId:S(),scriptId:S()}),O({current:S().optional(),latest:S(),available:Ne()}),O({jobId:S().optional(),upToDate:Ne()}),O({id:Et,repo:Ul.nullable().optional(),mirrorchyan:Ef.nullable().optional(),reset:ue(Pe(["repo","mirrorchyan"])).optional()}),O({items:ue(Ip.extend({by:Pe(["repo","name"])})),from:Pe(["mirrorchyan","builtin"])}),O({rid:Ef}),O({query:S().trim().max(100)}),O({items:ue(Ip),from:Pe(["mirrorchyan","builtin"]),fetchedAt:te().optional()}),O({id:S(),decision:Pe(["check","keep"])}),O({sessionId:S().optional()}),O({id:Et,version:S().optional()}),O({dir:S()}),O({sessionId:S()}),O({path:S().trim().min(1).max(1e3),id:Et.optional(),name:S().trim().min(1).max(100).optional(),packId:Et.optional()}),O({id:Et,decision:Pe(["run","keep"])}),O({sessionId:S().optional()}),O({id:Et}),O({sessionId:S()}),O({id:Et,deleteFiles:Ne().optional()}),O({id:Et,kind:S().min(1).max(64)}),O({jobId:S()}),O({items:ue(o$)}),O({jobId:S()}),A0.extend({tokenConfigured:Ne(),cdkConfigured:Ne()}),O({ok:Ne(),message:S(),expiresAt:te().optional()}),A0.partial();O({id:S().optional()});const l$=O({packId:S(),scriptId:S(),proposedAt:te(),sessionId:S().optional(),summary:S(),docs:ue(O({source:S(),used:S()})).optional(),noDocs:S().optional(),manifest:S(),skill:S(),current:O({manifest:S(),skill:S().optional(),builtin:Ne()}).optional(),tasks:ue(O({id:S(),title:S()}))});O({scriptId:Et.optional()}),O({items:ue(l$)}),O({packId:Et}),O({packId:S(),dir:S()}),O({packId:Et}),O({});O({packId:S().optional()});const c$=O({scriptId:S(),dir:S(),grantedAt:te(),expiresAt:te()});O({}),O({items:ue(c$),blocked:te()}),O({scriptId:Et,minutes:te().int().min(1).max(240)}),O({scriptId:Et}),O({});O({}),O({toolName:S(),target:S(),sessionId:S().optional(),at:te()});const u$=Pe(["error","warning","failed","stalled","overtime"]),d$=O({at:te(),action:Pe(["reconnect-adb","restart","stop","screenshot","notify","resolve","intervene"]),by:Pe(["rule","user","agent"]),ok:Ne(),detail:S()}),h$=O({id:S(),runId:S(),scriptId:S(),scriptName:S(),taskId:S(),taskTitle:S(),kind:u$,severity:Pe(["warning","error"]),tag:S(),title:S(),detail:S(),lines:ue(S()),status:Pe(["open","resolved"]),resolution:S().optional(),createdAt:te(),updatedAt:te(),steps:ue(d$),screenshot:Ne()}),f$=O({seconds:te().int().min(5).max(24*3600),by:Pe(["learned","agent","user"]),note:S().max(300).optional(),samples:ue(te().min(0)).max(10).default([]),at:te()}),p$=O({defaultStallSeconds:te().int().min(0).max(24*3600),scriptStall:_r(S(),f$),notifyWarnings:Ne(),screenshot:Ne(),intervene:Pe(["off","diagnose","act"]),interventionsPerDay:te().int().min(0).max(200)});O({status:Pe(["open","all"]).optional(),runId:S().optional(),limit:te().int().min(1).max(500).optional()}),O({items:ue(h$)}),O({incidentId:S(),action:Pe(["stop","retry","resolve","resume"])}),O({incidentId:S()}),O({mime:dt("image/png"),data:S()}),O({}),p$.partial();const m$="ADG_FEISHU_APP_SECRET",g$="ADG_QQBOT_APP_SECRET",Tp=O({id:S(),label:S(),ok:Ne().nullable(),detail:S().optional()}),x$=O({id:S(),name:S(),state:Pe(["off","connecting","ready","error"]),detail:S().optional(),recipients:te().int().min(0),checks:ue(Tp)}),v$=O({openId:S().min(1),name:S().optional(),addedAt:te()}),y$=O({enabled:Ne(),appId:S().optional(),domain:Pe(["feishu","lark"]),allowedUsers:ue(v$),chatId:S().optional(),otherApprovals:Ne()}),b$=O({openId:S(),at:te(),text:S()});O({settings:y$,secretConfigured:Ne(),pending:ue(b$)});const k$=O({openId:S().min(1),name:S().optional(),addedAt:te()}),N$=O({enabled:Ne(),appId:S().optional(),allowedUsers:ue(k$)}),w$=O({openId:S(),at:te(),text:S()});O({settings:N$,secretConfigured:Ne(),pending:ue(w$)});const Gk=O({id:S(),title:S(),text:S(),severity:Pe(["info","success","warning","error"]),at:te(),actions:ue(O({id:S(),label:S(),style:Pe(["primary","danger","default"]).optional()})),channels:ue(S()),image:Ne().optional(),done:S().optional(),acted:O({by:S(),label:S(),result:S(),at:te()}).optional()});O({}),O({channels:ue(x$)}),O({}),O({items:ue(O({sessionId:S(),channel:S(),user:S()}))}),O({}),O({items:ue(Gk)}),O({noticeId:S(),actionId:S()}),O({result:S()}),O({channel:S().optional()}),O({sent:ue(S()),failed:ue(O({channel:S(),error:S()}))}),O({}),O({enabled:Ne().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:Ne().optional()}),O({openId:S().trim().regex(/^ou_[A-Za-z0-9]+$/,"open_id 以 ou_ 开头"),name:S().max(40).optional()}),O({openId:S()}),O({}),O({checks:ue(Tp)}),O({}),O({enabled:Ne().optional(),appId:S().trim().regex(/^\d{6,20}$/,"AppID 是一串数字,在 QQ 开放平台「开发设置」里复制").nullable().optional()}),O({openId:S().trim().regex(/^[0-9A-Za-z_-]{8,64}$/,"user_openid 是一串字母数字(机器人回复你的那条消息里有)"),name:S().max(40).optional()}),O({openId:S()}),O({}),O({checks:ue(Tp)});O({}),O({item:Gk});const ya=S().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/,"小写字母、数字和短横线").max(64),Ql=S().regex(/^[A-Za-z0-9_-]{1,40}$/),Rm=S().regex(/^([01]\d|2[0-3]):[0-5]\d$/,"时间写成 HH:MM,例如 04:30"),Kk=O({retries:te().int().min(0).max(5).default(0),then:Pe(["continue","stop"]).default("continue")}),ga={id:Ql,title:S().max(60).optional(),position:O({x:te(),y:te()}).optional(),onFailure:Kk.optional(),waitForAll:Ne().optional()},j$=Pa("kind",[O({...ga,kind:dt("script-task"),scriptId:Et,taskId:S().min(1).max(64),params:_r(S(),Ro([S(),te(),Ne()])).default({}),profile:S().min(1).max(64).optional()}),O({...ga,kind:dt("agent"),prompt:S().min(1).max(4e3)}),O({...ga,kind:dt("wait"),minutes:te().int().min(1).max(1440).optional(),until:Rm.optional()}).refine(e=>e.minutes===void 0!=(e.until===void 0),"等待节点写分钟数或时间其中一个"),O({...ga,kind:dt("notify"),text:S().min(1).max(2e3)}),O({...ga,kind:dt("gate"),text:S().min(1).max(2e3)}),O({...ga,kind:dt("start")}),O({...ga,kind:dt("end")})]);function Gi(e){return e.kind==="start"||e.kind==="end"}function S$(e){const t=e.nodes.some(g=>g.kind==="start"),n=e.nodes.some(g=>g.kind==="end");if(t&&n)return e;const r=e.nodes.filter(g=>!Gi(g)),i=new Set(e.nodes.map(g=>g.id)),o=g=>{let x=g;for(let y=2;i.has(x);y++)x=`${g}${y}`;return i.add(x),x},c=r.filter(g=>g.position!==void 0).map(g=>g.position),u=Math.min(...c.map(g=>g.x)),h=Math.max(...c.map(g=>g.x)),d=c.length===0?40:Math.round(c.reduce((g,x)=>g+x.y,0)/c.length),p=[...e.nodes],m=[...e.edges];if(!t){const g=o("start");p.unshift({id:g,kind:"start",...c.length===0?{}:{position:{x:u-240,y:d}}});for(const x of r)e.edges.some(y=>y.to===x.id)||m.push({from:g,to:x.id,when:"success"})}if(!n){const g=o("end");p.push({id:g,kind:"end",...c.length===0?{}:{position:{x:h+300,y:d}}});for(const x of r)e.edges.some(y=>y.from===x.id)||m.push({from:x.id,to:g,when:"always"})}return{...e,nodes:p,edges:m}}const _$=O({from:Ql,to:Ql,when:Pe(["success","failure","always"]).default("success")}),Om=O({enabled:Ne().default(!1),times:ue(Rm).max(12).default([]),days:ue(te().int().min(0).max(6)).max(7).default([]),catchUpMinutes:te().int().min(0).max(720).default(10),after:ya.optional()}),Yk=Pe(["none","sleep","hibernate","shutdown"]),Cf=O({id:ya,name:S().min(1).max(60),description:S().max(500).optional(),nodes:ue(j$).max(60),edges:ue(_$).max(200).default([]),onFailure:Kk.default({retries:0,then:"continue"}),schedule:Om.default({enabled:!1,times:[],days:[],catchUpMinutes:10}),stopEmulatorAfter:Ne().default(!1),closeGameAfter:Ne().default(!1),powerAfter:Yk.default("none"),draft:Ne().optional(),createdAt:te().optional(),updatedAt:te().optional()}),E$=O({level:Pe(["error","warning","info"]),nodeId:S().optional(),message:S()}),C$=O({ok:Ne(),issues:ue(E$),serialized:ue(O({a:S(),b:S(),resource:S()})),estimateMinutes:te().optional()}),A$=Pe(["pending","waiting","running","succeeded","failed","skipped","cancelled"]),I$=O({state:A$,detail:S().optional(),runIds:ue(S()),attempts:te().int().min(0),startedAt:te().optional(),endedAt:te().optional()}),Xk=O({kind:Pe(["manual","schedule","autostart","agent","after"]),detail:S().optional()}),Qk=O({id:S(),pipelineId:S(),pipelineName:S(),trigger:Xk,from:S().optional(),state:Pe(["running","succeeded","failed","cancelled"]),stopping:S().optional(),nodes:_r(S(),I$),startedAt:te(),endedAt:te().optional(),outcome:S().optional()}),T$=O({id:S(),name:S(),description:S().optional(),nodes:te(),draft:Ne(),schedule:Om,updatedAt:te().optional(),lastRun:Qk.pick({id:!0,state:!0,startedAt:!0,endedAt:!0}).optional()}),zl=S().regex(/^task-[a-z0-9]{4,24}$/),I0=O({id:zl,agent:S().min(1).max(64),title:S().trim().min(1).max(60),prompt:S().trim().min(1).max(4e3),schedule:Om,createdAt:te().optional(),updatedAt:te().optional()}),T0=O({id:S(),taskId:S(),trigger:Xk,state:Pe(["running","done","failed"]),outcome:S().optional(),startedAt:te(),endedAt:te().optional()}),Jk=O({autostart:Ne(),autostartPipelines:ue(ya),autostartDelaySeconds:te().int().min(0).max(1800),skipIfRanToday:Ne(),firstStartOnly:Ne().default(!1),wakeToRun:Ne().default(!1),powerCountdownSeconds:te().int().min(10).max(600).default(60)}),eN={agent:S().optional()},$$=O({pipelineId:S(),pipelineName:S(),...eN,slot:S(),at:te(),outcome:Pe(["fired","missed","skipped","failed"]),detail:S().optional()}),M$=O({awake:Ne(),pending:O({action:Yk.exclude(["none"]),pipelineName:S(),at:te().optional()}).optional()});O({settings:Jk,autostart:O({available:Ne(),registered:Ne(),detail:S().optional()}),autostarted:Ne(),wake:O({available:Ne(),registered:Ne(),next:te().optional(),detail:S().optional()}),power:M$,upcoming:ue(O({pipelineId:S(),pipelineName:S(),at:te(),...eN})),history:ue($$)});O({}),O({items:ue(T$)}),O({id:ya}),O({pipeline:Cf}),O({pipeline:Cf,check:C$}),O({id:ya}),O({}),O({pipeline:Cf}),O({id:ya,from:Ql.optional()}),O({runId:S()}),O({}),O({pipelineId:ya.optional(),limit:te().int().min(1).max(100).optional()}),O({items:ue(Qk)}),O({runId:S(),nodeId:Ql,decision:Pe(["continue","stop"])}),O({}),O({}),Jk.partial(),O({}),O({}),O({agent:S().optional()}),O({items:ue(I0.extend({lastRun:T0.optional()}))}),O({task:I0.extend({id:zl.optional()})}),O({id:zl}),O({}),O({id:zl}),O({id:zl}),O({items:ue(T0)});O({}),O({}),O({});const R$=Pe(["running","resolved","retried","gave-up","taken-over","timeout","failed"]),O$=O({id:S(),incidentId:S().optional(),runId:S().optional(),title:S(),mode:Pe(["diagnose","act"]),state:R$,sessionId:S().optional(),paused:Ne(),summary:S().optional(),startedAt:te(),endedAt:te().optional()});O({limit:te().int().min(1).max(100).optional()}),O({items:ue(O$)}),O({id:S()}),O({id:S(),then:Pe(["resume","restart","stop"])});const $0=O({id:S(),game:S(),name:S(),startsAt:te().optional(),endsAt:te().optional(),shopEndsAt:te().optional(),url:S().optional(),kind:S().optional(),description:S().optional(),cover:S().optional(),site:O({source:S(),name:S(),at:te()}).optional(),sources:ue(O({id:S(),name:S(),at:te(),web:Ne(),startsAt:te().optional(),endsAt:te().optional(),shopEndsAt:te().optional(),cover:S().optional()})).optional(),chosen:S().optional(),shown:O({cover:S().optional(),startsAt:S().optional(),endsAt:S().optional()}).optional(),screen:O({at:te(),remaining:S().optional(),endsAt:te().optional(),evidence:Ne(),image:S().optional(),sessionId:S().optional()}).optional(),todo:ue(S()),done:ue(S()),progress:S().optional(),finished:O({at:te()}).optional(),mismatch:S().optional(),own:O({at:te(),fields:ue(Pe(["name","startsAt","endsAt","kind","description","url","cover"])),startsAt:te().optional(),endsAt:te().optional(),cover:S().optional()}).optional()}),bo="@own",Hl="@screen",z$=112e5,P$=O({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp","image/avif"]),data:S().min(1).max(z$).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix")}),L$=/^own:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,D$=/^shot:[0-9a-f]{32}\.(?:png|jpg|gif|webp|avif)$/,F$=O({id:S(),name:S(),homepage:S().optional(),auto:Ne(),added:Ne().optional()}),B$=O({id:S(),name:S(),aliases:ue(S()),scripts:ue(S()),timezone:S(),screen:O({target:Pe(["emulator","window"]),window:S().optional()}).optional(),sources:ue(F$),builtin:Ne(),art:S().optional(),followed:Ne().optional(),version:O({name:S(),title:S().optional(),startsAt:te().optional(),endsAt:te().optional(),cover:S().optional(),source:S(),at:te()}).optional(),pools:ue(O({name:S(),type:S().optional(),startsAt:te().optional(),endsAt:te(),cover:S().optional(),up:ue(S())})).optional(),refreshed:O({at:te(),ok:Ne(),count:te(),detail:S().optional()}).optional(),reading:O({state:Pe(["running","done","failed"]),at:te(),sessionId:S().optional(),summary:S().optional()}).optional(),webReading:O({state:Pe(["running","done","failed"]),at:te(),sessionId:S().optional(),summary:S().optional()}).optional()}),M0=O({report:O({enabled:Ne(),at:Rm,games:ue(S()),soonDays:te().int().min(1).max(30),ai:Ne()}),followed:ue(S())}),U$=O({lastSentAt:te().optional(),lastDay:S().optional(),lastResult:S().optional(),lastText:S().optional(),next:te().optional()});O({}),O({games:ue(B$),activities:ue($0),settings:M0,report:U$}),O({game:S().optional()}),O({results:ue(O({game:S(),ok:Ne(),count:te(),detail:S().optional()}))}),O({game:S(),how:Pe(["screen","web"]).optional(),source:S().optional()}),O({sessionId:S()}),O({}),O({title:S(),text:S()}),O({}),O({channels:ue(S()),text:S()}),O({report:M0.shape.report.partial().optional()}),O({activityId:S()}),O({mediaType:S(),data:S()}),O({url:S().refine(e=>L$.test(e)||D$.test(e)||/^https?:\/\/\S+$/.test(e),"不是图片地址")}),O({mediaType:S(),data:S()}),O({name:S().min(1).max(60)}),O({sessionId:S()}),O({game:S()}),O({items:ue(Ip),from:Pe(["mirrorchyan","builtin"])}),O({game:S(),url:S().url().refine(e=>/^https?:\/\//.test(e),"只能是 http 或 https 网址"),name:S().max(30).optional()}),O({source:S(),sessionId:S()}),O({game:S(),source:S()}),O({}),O({}),O({games:ue(O({sra:S(),name:S(),followed:Ne(),pack:S().optional()}))}),O({sra:S(),follow:Ne()}),O({}),O({activityId:S(),todo:ue(S().min(1).max(80)).max(30).optional(),done:ue(S().min(1).max(80)).max(30).optional(),finished:Ne().optional()}),O({game:S(),activityId:S().optional(),name:S().trim().min(1).max(60).nullable().optional(),startsAt:te().nullable().optional(),endsAt:te().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:dT().optional(),image:P$.optional(),todo:ue(S().min(1).max(80)).max(30).optional()}),O({activityId:S(),source:S().nullable()}),O({activityId:S()}),O({activity:$0.optional()}),O({activityId:S()}),O({});O({game:S().optional()});const tN=Pe(["ask","full"]),nN=Pe(["default","allow","ask","deny"]),H$=[{id:"pipelines-edit",title:"编辑流水线和定时",description:"起草、修改流水线,设定时间(schedule_set),以及 dsh 自己的定时任务。",tools:["pipeline_draft","schedule_set","schedule_create","schedule_update","schedule_delete"]},{id:"run",title:"运行流水线和脚本",description:"启动、停止流水线和脚本任务。",tools:["pipeline_run","script_run","script_stop"]},{id:"scripts-config",title:"改脚本配置",description:"修改脚本的配置副本、导入配置、新建选项、打开脚本自己的设置界面、设置游戏位置。",tools:["script_config_set","script_config_import","script_choice_create","script_settings","game_path_set"]},{id:"scripts-install",title:"安装、更新、删除脚本",description:"从 GitHub 安装、更新、回滚、删除脚本,运行脚本的安装程序,导入本地脚本,修复运行环境,起草脚本包。",tools:["script_install","script_update","script_rollback","script_remove","script_setup_run","script_import","script_env_fix","pack_propose"]},{id:"screen",title:"操作屏幕和模拟器",description:"在游戏窗口或模拟器里点击、输入、按键、滑动、切换窗口(截图不算)。",tools:["screen_tap","screen_type","screen_key","screen_scroll","screen_swipe","window_focus"]},{id:"games",title:"启动、关闭游戏和模拟器",description:"打开、关掉游戏,启动、关闭、安装、设置模拟器。",tools:["game_launch","game_close","emulator_start","emulator_stop","emulator_install","emulator_configure"]},{id:"game-records",title:"记录活动、添加游戏",description:"把读到的活动写进日历,替你添加、修改或去掉活动,给新游戏建游戏包。",tools:["game_record","game_activity_save","game_activity_remove","game_add"]},{id:"skills",title:"保存技能",description:"把做法存成技能,以后的对话都会用到。",tools:["skill_save"]},{id:"web",title:"上网查资料",description:"读网页、搜索。",tools:["web_fetch","web_search"]},{id:"shell",title:"运行命令、改文件",description:"dsh 自带的命令行和文件编辑。只在它请求确认时按这里的设置处理(沙箱里的普通命令不会请求)。",tools:["pwsh","bash","edit","write"],approvalOnly:!0}];O({mode:tN,since:te().optional(),areas:_r(S(),nN).default({}),recent:ue(O({at:te(),sessionId:S(),toolName:S(),reason:S().optional()}))});O({}),O({mode:tN}),O({area:S(),policy:nN});const Z$=O({label:S(),description:S().optional()}),W$=O({id:S(),question:S(),detail:S().optional(),header:S().optional(),options:ue(Z$).optional(),multiSelect:Ne().optional()});O({questionId:S(),sessionId:S(),callId:S().optional(),questions:ue(W$)});const sN=O({id:S(),selected:ue(S()),custom:S().optional()}),V$=Pe(["answered","cancelled","unavailable"]);O({questionId:S(),answers:ue(sN)}),O({});O({questionId:S(),outcome:V$,answers:ue(sN).optional()});const q$=O({pid:te().int(),label:S(),dataDir:S().optional(),startedAt:te(),warnings:ue(S())});O({others:ue(q$)});O({});const rN=O({scripts:ue(S()).optional(),games:ue(S()).optional()}),R0=O({name:S(),description:S(),whenToUse:S().optional(),source:S(),provider:S(),path:S().optional(),modelInvocable:Ne(),userInvocable:Ne(),owner:rN.optional(),removable:Ne().optional()}),iN=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,$p=48;O({}),O({skills:ue(R0)}),O({name:S()}),R0.extend({content:S()}),O({name:S().regex(iN).max($p),description:S().trim().min(10).max(400),content:S().trim().min(20).max(2e4),scripts:ue(S().min(1).max(64)).max(20).optional(),games:ue(S().min(1).max(64)).max(20).optional(),replace:Ne().optional()}),O({name:S(),replaced:Ne()}),O({name:S()}),O({});O({});const Af=O({repo:Ul,branch:S().trim().min(1).max(100).regex(/^[\w./-]+$/)}),O0=O({name:S(),description:S(),title:S().optional(),kind:Pe(["game","script","general"]),games:ue(S()),scripts:ue(S()),repo:S(),path:S(),hash:S(),installed:O({at:te(),modified:Ne(),update:Ne()}).optional(),blocked:S().optional()}),If=O({name:S().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});O({refresh:Ne().optional()}),O({items:ue(O0),repos:ue(Af),errors:ue(S()),fetchedAt:te().optional()}),If.extend({repo:Ul.optional()}),If.extend({resolve:Pe(["keep","replace","merge"]).optional()}),O({state:Pe(["current","updated","kept","conflict","merging"]),item:O0,backup:S().optional(),sessionId:S().optional()}),O({mine:S(),theirs:S()}),O({}),If.extend({owner:rN.nullable()}),O({}),O({repos:ue(Af).min(1).max(10)}),O({repos:ue(Af)});O({});const G$=Pe(["default","concise","patient","lively","buddy","butler"]),K$=Pe(["plain","same"]),aN=O({style:G$,callUser:S().max(20).optional(),custom:S().optional(),peerStyle:K$.optional()}),Y$=aN.partial().extend({name:S().max(20).optional()}),X$=O({persona:aN,agents:_r(S(),Y$)});X$.extend({prompt:S(),prompts:_r(S(),S())});O({});const Q$=80,oN=50,lN=95,Mp=O({auto:Ne(),threshold:te().int().min(oN).max(lN)});O({settings:Mp,applied:Mp});O({}),O({settings:Mp});const J$=Pe(["starting","running","stopping","succeeded","failed","cancelled"]),eM=O({type:Pe(["string","integer","number","boolean"]),default:Ro([S(),te(),Ne()]).optional(),enum:ue(Ro([S(),te()])).optional(),description:S().optional(),choices:ue(O({value:S(),label:S(),detail:S().optional()})).optional(),canCreate:Ne().optional()}),tM=O({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()});O({settings:tM,game:O({name:S().optional(),androidPackage:S().optional(),pcProcess:S().optional(),selfLaunch:S()}),uses:O({adb:Ne(),desktop:Ne()})});const nM=O({id:S(),title:S(),description:S().optional(),utterances:ue(S()),params:_r(S(),eM),input:Pe(["desktop","window","adb","none"]),account:S().optional(),expectedDuration:S().optional()}),Lr=S().trim().min(1).max(64),Rp=O({id:S(),name:S(),createdAt:te().optional()}),cN=O({current:S(),items:ue(Rp)}),sM=O({id:S(),scriptId:S(),scriptName:S(),taskId:S(),taskTitle:S(),params:_r(S(),Ro([S(),te(),Ne()])),state:J$,outcome:S().optional(),startedAt:te(),endedAt:te().optional(),exitCode:te().optional(),command:ue(S()),resources:ue(S()),tags:ue(S()),warnings:ue(S()),kind:Pe(["task","settings"]),retryOf:S().optional(),halted:Ne().optional(),profile:S().optional(),profileName:S().optional()}),uN=O({at:te(),source:S(),text:S(),level:Pe(["info","progress","done","warning","error"]).optional(),tag:S().optional()});O({scriptId:Et,profile:Lr.optional()}),O({tasks:ue(nM),runnable:Ne(),problem:S().optional()}),O({scriptId:Et,taskId:S().min(1).max(64),params:_r(S(),Ro([S(),te(),Ne()])).optional(),profile:Lr.optional()}),O({runId:S()}),O({}),O({scriptId:Et.optional()}),O({items:ue(sM)}),O({runId:S(),limit:te().int().min(1).max(2e3).optional()}),O({lines:ue(uN)}),O({scriptId:Et}),O({scriptId:Et,name:S().trim().min(1).max(30),from:Pa("kind",[O({kind:dt("copy"),profile:Lr}),O({kind:dt("original")}),O({kind:dt("folder"),dir:S().trim().min(1).max(500)})])}),O({profile:Rp,files:ue(S()),list:cN}),O({scriptId:Et,profile:Lr,name:S().trim().min(1).max(30).optional(),current:dt(!0).optional()}),O({scriptId:Et,profile:Lr}),O({scriptId:Et,profile:Lr.optional()}),O({importedAt:te().optional(),dir:S(),profile:Rp,files:ue(O({file:S(),local:Ne(),original:Ne(),changed:Ne()})),drift:ue(S())}),O({scriptId:Et,file:S().min(1),profile:Lr.optional()}),O({file:S(),content:S(),truncated:Ne()}),O({scriptId:Et,profile:Lr.optional()}),O({imported:ue(S())}),O({scriptId:Et,profile:Lr.optional()}),O({runId:S()}),O({}),O({scriptId:Et,taskId:S().min(1),param:S().min(1),name:S().trim().min(1).max(40),profile:Lr.optional()}),O({value:S()}),O({scriptId:Et}),O({scriptId:Et,mode:Pe(["auto","platform","off"]).optional(),pcLaunch:Pe(["program","maaend"]).nullable().optional(),pcRegion:Pe(["CN","Global","Bilibili","TapTap","Steam","Epic"]).nullable().optional(),pcExe: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()}),O({scriptId:Et}),O({exe:S().optional(),candidates:ue(O({path:S(),source:S()}))});O({scriptId:S(),list:cN}),O({runId:S(),lines:ue(uN)});const rM=1,Tf=S().regex(/^[A-Za-z_][A-Za-z0-9_]*$/,"credential names use letters, digits and underscores"),dN=O({configured:Ne(),source:S().optional(),writable:Ne()}),Op="DEEPSEEK_API_KEY",iM=O({id:S(),version:te().int().positive()}),hN=O({id:S(),title:S().nullable(),updatedAt:te(),running:Ne(),blank:Ne(),live:Ne(),cwd:S().optional(),parentId:S().optional(),origin:Pe(["subagent"]).optional(),role:S().optional(),requestedBy:S().optional(),home:S().optional()}),fN=O({id:S(),name:S(),description:S(),order:te()}),pN=O({id:S(),requestId:S().optional(),text:S(),images:te().int().optional(),placement:Pe(["next-turn","next-step"])}),mN=O({contextWindow:te().int().positive(),usedTokens:te().int().nonnegative(),breakdown:O({systemTokens:te().int().nonnegative(),toolsTokens:te().int().nonnegative(),messageTokens:te().int().nonnegative()}).optional()}),aM=O({id:S(),createdAt:te(),cwd:S().optional(),parentId:S().optional(),agentPreset:S().optional()}),ba=O({provider:S(),model:S(),reasoningEffort:S().optional()}),oM=O({from:S(),kind:Pe(["question","answer","update","done"]),text:S(),at:te()}),zp=O({id:S(),messages:ue(oM).optional(),chain:ue(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:te(),endedAt:te().optional()}),lM=O({id:S(),agent:S(),sessionId:S(),title:S(),prompt:S(),rule:S(),repeats:Ne(),next:te()});O({default:ba,groups:ue(O({id:S(),name:S(),models:ue(O({id:S(),name:S(),description:S().optional(),efforts:ue(O({id:S(),name:S()})),defaultEffort:S().optional()}))})),failures:ue(O({id:S(),name:S(),message:S()}))});const cM=O({lastUsed:ba.nullable(),next:ba.nullable()}),$f=Pe(["openai-completions","openai-responses","anthropic-messages"]),uM=S().regex(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,"use lowercase letters, digits and single hyphens, starting with a letter"),Pp=O({id:S().min(1),name:S().optional(),contextWindow:te().int().positive().optional(),maxTokens:te().int().positive().optional(),input:ue(Pe(["text","image"])).optional(),efforts:ue(S().min(1)).optional()}),dM=O({id:S(),displayName:S(),api:S().optional(),baseURL:S().optional(),models:ue(Pp),apiKeyRef:S().optional(),credential:dN.optional(),declared:Ne(),active:Ne(),error:S().optional()}),hM=O({available:Ne(),balances:ue(O({currency:S(),total:S(),granted:S(),toppedUp:S()}))}),Lp=35e5,fM=O({mediaType:Pe(["image/png","image/jpeg","image/gif","image/webp"]),data:S().min(1).max(Lp).regex(/^[A-Za-z0-9+/]+={0,2}$/,"base64 without a data: prefix"),name:S().max(200).optional()});O({});O({accepted:dt(!0)});O({protocolVersion:te().int(),client:O({name:S(),version:S()})}),O({protocolVersion:te().int(),server:O({name:S(),version:S(),dsh:S().optional()}),capabilities:ue(iM)}),O({items:ue(hN)}),O({cwd:S().optional(),focus:O({scripts:ue(S()).optional(),games:ue(S()).optional()}).optional(),role:S().optional()}),O({sessionId:S()}),O({sessionIds:ue(S()).max(60)}),O({items:ue(O({sessionId:S(),text:S().nullable()}))}),O({items:ue(fN)}),O({agentId:S()}),O({sessionId:S()}),O({sessionId:S()}),O({items:ue(zp)}),O({sessionId:S()}),O({a:S(),b:S()}),O({items:ue(zp)}),O({id:S()}),O({agent:S().optional()}),O({items:ue(lM)}),O({id:S()}),O({}),O({sessionId:S(),title:S().min(1)}),O({title:S()}),O({sessionId:S(),maxMessages:te().int().positive().optional()}),O({subscriptionId:S(),header:aM,cursor:te(),events:ue(Ap),hasMore:Ne(),title:S().nullable(),live:BT.nullable(),queue:ue(pN).optional(),context:mN.optional()}),O({subscriptionId:S()}),O({sessionId:S(),throughSeq:te(),beforeSeq:te(),maxMessages:te().int().positive().optional()}),O({events:ue(Ap),hasMore:Ne()}),O({sessionId:S(),requestId:S(),text:S(),mode:Pe(["queue","steer"]),images:ue(fM).max(4).optional()}).refine(e=>{var t;return e.text.trim()!==""||(((t=e.images)==null?void 0:t.length)??0)>0},"消息是空的"),O({sessionId:S()}),O({sessionId:S()}),O({compacted:Ne(),message:S()}),O({sessionId:S(),itemId:S(),action:Pe(["steer","remove"])}),O({attachmentId:S(),mediaType:S(),bytes:te(),width:te(),height:te()}),O({mediaType:S(),data:S()}),O({sessionIds:ue(S())}),O({sessionId:S()}),O({sessionIds:ue(S())}),O({sessionId:S()}),O({sessionIds:ue(S())}),O({model:ba.nullable()}),O({model:ba.nullable()}),O({warning:S().optional()}),ba.extend({sessionId:S()}),O({selected:ba}),O({sessionId:S()}),O({approvalId:S(),decision:Pe(["allow-once","reject"])}),O({refs:ue(Tf).min(1).max(64)}),O({items:_r(S(),dN)}),O({ref:Tf,value:S().min(1).max(4096)}),O({ref:Tf}),O({providers:ue(dM),revision:te(),writable:Ne(),protocols:ue($f),taken:ue(S())}),O({provider:S().optional(),baseURL:_p({protocol:/^https?$/}).optional(),api:$f.optional(),apiKey:S().min(1).max(4096).optional()}),O({models:ue(Pp)}),O({provider:S().min(1)}),O({balance:hM.nullable()}),O({id:uM,create:Ne(),displayName:S().max(80).optional(),api:$f,baseURL:_p({protocol:/^https?$/}),models:ue(Pp).min(1),apiKey:S().min(1).max(4096).optional(),expectedRevision:te().optional()}),O({revision:te(),apiKeyRef:S().optional()}),O({id:S().min(1),removeKey:Ne().optional(),expectedRevision:te().optional()}),O({revision:te(),defaultReset:Ne()});Pa("kind",[O({kind:dt("upsert"),item:hN.partial().extend({id:S()})}),O({kind:dt("removed"),sessionId:S()})]);O({approvalId:S(),sessionId:S(),toolName:S(),callId:S().optional(),reason:S().optional(),displayReason:_r(S(),S()).optional()});O({subscriptionId:S(),event:Ap}),O({subscriptionId:S(),frame:Vk}),O({subscriptionId:S(),reason:S()}),O({sessionId:S(),title:S().nullable()}),O({sessionId:S(),message:S()}),O({sessionId:S(),items:ue(pN)}),O({sessionId:S(),context:mN.nullable()}),O({approvalId:S(),outcome:S()}),O({ref:S()}),O({sessionIds:ue(S())}),O({items:ue(fN)}),O({item:zp}),O({}),O({}),cM.extend({sessionId:S()});const ju={InternalError:-32603,NotInitialized:-32002};class kl extends Error{constructor(n,r,i){super(r);ut(this,"code");ut(this,"data");this.name="RpcError",this.code=n,this.data=i}toJSON(){return this.data===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,data:this.data}}}function pM(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 zm(e){try{const t=JSON.parse(e);for(const r of["command","cmd","path","file_path","pattern","query","url","description","prompt"]){const i=t[r];if(typeof i=="string"&&i!=="")return i.split(`
104
+ `)[0].slice(0,160)}const n=Object.values(t).find(r=>typeof r=="string");return typeof n=="string"?n.slice(0,160):""}catch{return e.slice(0,160)}}const gN=["把这次走通的做法保存成技能(用 skill_save),让下次同样的事可以直接照着做、少调用模型。要求:","- 只写最后成功的路径,不写失败的尝试和闲聊;","- 写清楚适用场景(用户会怎么说)、一步一步的操作(用到的工具、命令、路径、参数照实写,会变的写成「把 X 换成…」)、怎样算成功、注意事项和踩过的坑;","- 名字用简短的英文小写加短横线,description 一两句话说清楚做什么、什么时候用;","- 分到对应的游戏和脚本:只有用某个脚本时才用得上的(它的配置、报错、日志),scripts 填脚本 id;和游戏本身有关、换个脚本也用得上的(游戏里的操作、界面、活动、机制),games 填游戏 id(用 game_list 查);和哪个游戏都无关才当通用技能;","- 保存后告诉我技能名,以及以后我说什么时会用到它。"].join(`
105
+ `);function mM(e,t,n){return[`优化脚本${e===""?":最近运行过的脚本(script_runs 看最近一周跑过哪些,一个一个来)":`「${e}」`}。把这段时间运行攒下的信息用起来,一次做完下面几件事:`,"1. 重新总结脚本包:script_tasks、script_help 看它现在有哪些任务和参数,script_runs、script_run_log 看最近的运行(成功的看正常流程和用时,失败的看原因);更新过版本就先用 script_changelog 读更新日志。对照它的脚本包,任务、参数、配置文件、完成和出错的日志文字、预计用时有不对或缺的,用原来的脚本包 id 提交 pack_propose(summary 写明依据);都对就不提交;","2. 改善监控时间:monitor_stall_check 看它正常运行时日志的节奏,按建议值和你看日志的判断用 monitor_stall_set 设它多久没新日志算卡住,note 写明依据(例如「战斗中最长 70 秒不输出」);","3. 把做过的步骤总结成技能,分到对应的游戏和脚本:运行和处理这个脚本时反复用到、已经走通的做法(常见报错怎么处理、怎么确认跑完、配置怎么改)用 skill_save 存成技能,scripts 填这个脚本的 id,只给它用;其中和游戏本身有关、别的脚本也用得上的(游戏里的操作、界面、活动、机制)单独存,games 填它玩的游戏 id(game_list 查),不填 scripts;已有的技能就合并更新(replace),不要重复存,没有值得存的就不存;","4. 不要运行脚本、不要改它的配置;最后用几句话告诉我:脚本包改了什么(草稿在「脚本」页等我确认)、卡住时间设成多少、存了或更新了哪些技能。"].join(`
106
+ `)}const Pm=[{name:"技能",aliases:["skill"],title:"把刚才走通的做法存成技能,下次少调用模型",expand:()=>gN},{name:"资讯",aliases:["news"],title:"上网查游戏资讯:活动、版本、维护公告",arg:"游戏名(可选,不写就查游戏页上的游戏)",expand:e=>[`上网查${e===""?"我游戏页上的游戏":`「${e}」`}最近的资讯,按技能 web-reading:`,"1. 先 game_list、game_activities 看日历里已经有什么,不重复查;","2. 先用公开 API(SRA 公共 API、Wiki 的 api.php),没有再读官网公告列表页,只打开最近的活动、版本和维护公告;","3. 查到起止时间的活动用 game_record(source=site,写上 url)记进日历;","4. 最后按游戏列一下:正在进行、快结束、即将开始的活动,和其他值得知道的消息(新版本、维护、福利、兑换码)。"].join(`
107
+ `)},{name:"编排",aliases:["plan","pipeline"],title:"把脚本编成流水线(先起草,我确认后才生效)",arg:"想做什么(可选,例如「每天早上跑完三个游戏的日常」)",expand:e=>[`帮我把脚本编排成流水线:${e===""?"把我装好的各个脚本的日常任务排成每天能自动跑的流程":e}。按技能 pipeline-planning:`,"1. 先 system_info 看电脑配置(能不能同时跑几个游戏),pipeline_list 看已有的流水线,script_tasks 看各脚本有哪些任务;","2. 用 pipeline_draft 起草(草稿,我在「编排」页保存后才会按定时运行):模拟器和前台脚本能并行的并行,失败不要挡住别的;","3. 说清楚为什么这样排、哪些步骤并行、估计多久、建议定在几点跑。"].join(`
108
+ `)},{name:"诊断",aliases:["diagnose","why"],title:"分析脚本为什么失败,给出怎么改的建议",arg:"脚本名或运行 id(可选,不写就看最近失败的)",expand:e=>[`分析${e===""?"最近失败的脚本运行":`「${e}」`}为什么失败:`,"1. 用 script_runs 找到失败的那次运行,script_run_log 看日志(先按错误级别筛,再看出错前后);","2. 对照这个脚本包的技能说明原因:是脚本本身、配置、游戏状态(更新、公告、掉线)、模拟器 / ADB,还是电脑环境;","3. 给出怎么改:改哪项配置、游戏里要做什么、要不要重跑。先不要改任何东西、不要重跑,等我决定。"].join(`
109
+ `)},{name:"优化脚本",aliases:["optimize"],title:"用运行攒下的信息优化脚本:重新总结脚本包、调监控时间、把做过的步骤存成技能",arg:"脚本名(可选,不写就看最近运行过的)",expand:e=>mM(e)},{name:"压缩",aliases:["compact"],title:"压缩这个对话:较早的部分换成摘要,agent 会忘掉其中的细节",expand:()=>"",local:"compact"}];function gM(e){var n,r,i;const t=(r=(n=/^\/(\S+)/.exec(e.trim()))==null?void 0:n[1])==null?void 0:r.toLowerCase();return t===void 0||(i=Pm.find(o=>o.local!==void 0&&(o.name===t||o.aliases.includes(t))))==null?void 0:i.local}function xM(e,t){return`使用技能「${e}」:先用 skill 工具加载它,再按它的说明做${t===""?"。":`:${t}`}`}function vM(e,t){const n=e.trim(),r=/^\/(\S+)(?:\s+([\s\S]*))?$/.exec(n);if(r===null)return n;const i=r[1],o=(r[2]??"").trim(),c=Pm.find(h=>h.name===i.toLowerCase()||h.aliases.includes(i.toLowerCase()));if((c==null?void 0:c.local)!==void 0)return n;if(c!==void 0)return`${n}
110
+
111
+ ${c.expand(o)}`;const u=t.find(h=>h.name===i);return u===void 0?n:`${n}
112
+
113
+ ${xM(u.name,o)}`}function yM(e){if(!e.startsWith("/"))return;const t=e.indexOf(`
114
+
115
+ `);return t<0?void 0:{typed:e.slice(0,t),expansion:e.slice(t+2)}}function bM(e,t,n=!1){const r=/^\/(\S*)$/.exec(e);if(r===null)return[];const i=r[1].toLowerCase(),o=Pm.filter(h=>(n||h.local===void 0)&&[h.name,...h.aliases].some(d=>d.toLowerCase().includes(i))).map(h=>({kind:"command",name:h.name,description:h.title,...h.arg===void 0?{}:{arg:h.arg},command:h})),c=h=>h.toLowerCase().startsWith(i)?0:1,u=t.filter(h=>h.name.toLowerCase().includes(i)||i.length>0&&h.description.toLowerCase().includes(i)).sort((h,d)=>+(h.group===void 0)-+(d.group===void 0)||(h.group??"").localeCompare(d.group??"")||c(h.name)-c(d.name)||h.name.localeCompare(d.name)).map(h=>({kind:"skill",name:h.name,description:h.description,...h.group===void 0?{}:{group:h.group}}));return[...o,...u]}const kM=new Set(["issues","pulls","wiki","actions","discussions","blob","commits","commit","compare","security","pulse","graphs","network","settings","projects","stargazers","forks","watchers","tags","branches"]);function NM(e){var y,E;const t=e.trim().replace(/^<|>$/g,""),n=/^([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?$/.exec(t);if(n!==null&&!t.includes(":"))return{repo:`${n[1]}/${n[2]}`};const r=/git@github\.com:([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/i.exec(t);if(r!==null)return{repo:`${r[1]}/${r[2]}`};const i=N=>{try{return decodeURIComponent(N)}catch{return N}},o=/raw\.githubusercontent\.com\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)\/([^/?#]+)/i.exec(t);if(o!==null)return{repo:`${o[1]}/${o[2]}`,branch:i(o[3])};const c=/api\.github\.com\/repos\/([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+)/i.exec(t);if(c!==null)return{repo:`${c[1]}/${c[2]}`};const u=t.toLowerCase().lastIndexOf("github.com/");if(u===-1)return;const d=t.slice(u+11).split(/[?#]/)[0].replace(/\/+$/,"").split("/");if(d.length<2||!/^[A-Za-z0-9_.-]+$/.test(d[0]))return;const p=d[1].replace(/\.git$/i,"");if(!/^[A-Za-z0-9_.-]+$/.test(p))return;const m=`${d[0]}/${p}`,[g,...x]=d.slice(2);if(g==="releases")return x[0]==="tag"&&x[1]!==void 0?{repo:m,tag:i(x.slice(1).join("/"))}:x[0]==="download"&&x.length>=3?{repo:m,tag:i(x.slice(1,-1).join("/")),asset:i(x.at(-1))}:{repo:m};if(g==="tree"&&x.length>0)return{repo:m,branch:i(x[0])};if(g==="archive"){const N=x.join("/").replace(/\.(zip|tar\.gz)$/i,""),w=(y=/^refs\/tags\/(.+)$/.exec(N))==null?void 0:y[1];if(w!==void 0)return{repo:m,tag:i(w)};const T=(E=/^refs\/heads\/(.+)$/.exec(N))==null?void 0:E[1];return T!==void 0?{repo:m,branch:i(T)}:{repo:m,tag:i(N)}}return g===void 0||kM.has(g)?{repo:m}:{repo:m}}const Lm="你",wM="(不用告诉用户)",z0=e=>e.replace(/[^\p{Script=Han}a-zA-Z0-9]/gu,"");function jM(e){return z0(e)===z0(wM)}const SM="(你这一轮的最后一段回复会作为结论交回去。在那之前要让对方知道的,用 agent_message 的 update 说,马上送到,说几次都行;交回结论以后还有话,同样发到这条线索:你的普通回复对方看不到。)",_M="(做完后你这一轮的最后一段回复会原样交回去:把结论写在那里。)",EM=/^(这件事的线索是 (\S+):做的过程中要问清楚什么,用 agent_message 问,thread 填它;不要猜。)$/,CM=/^(你和.{1,20}之前的来往,/,AM=")";function xN(e){var p;const[t="",...n]=e.split(`
116
+ `),r=/^(你在软件里点的:(.*))$/.exec(t),i=r===null?/^(([^():]{1,20})交给你的事:(.*))$/.exec(t):null;if(r===null&&i===null)return;const o=n[0]===SM||n[0]===_M,c=o?n.slice(1):n,u=(p=EM.exec(c[0]??""))==null?void 0:p[1],h=u===void 0?c:c.slice(1),d=CM.test(h[0]??"")?h.indexOf(AM):-1;return{by:r!==null?Lm:i[1],title:r!==null?r[1]:i[2],returns:o,...u===void 0?{}:{thread:u},body:h.slice(d+1).join(`
117
+ `).trim()}}function vN(e){const[t="",...n]=e.split(`
118
+ `),r=/^(「([^」]+)」在线索 (\S+) 里(问你|回答了你|告诉你):(.*))$/.exec(t);if(r===null)return;const i=n.join(`
119
+ `).trim(),o=i.lastIndexOf(`
120
+
121
+ (`);return{from:r[1],thread:r[2],kind:r[3]==="问你"?"question":r[3]==="告诉你"?"update":"answer",title:r[4],text:(o===-1?i:i.slice(0,o)).trim()}}function yN(e){const[t="",...n]=e.split(`
122
+ `),r=/^(「([^」]+)」(交回了|没有做完)([^()]{1,20}?)交给它的事:(.*))$/.exec(t);if(r===null)return;const i=n.join(`
123
+ `).trim(),o=i.lastIndexOf(`
124
+
125
+ (`);return{agent:r[1],ok:r[2]==="交回了",asker:r[3],title:r[4],reply:(o===-1?i:i.slice(0,o)).trim()}}function IM(e){return e.replace(/\s+/g," ").replace(/[()]/g,t=>t==="("?"(":")").trim()}const P0=/\n\n(这是你在线索 \S+ 上定的提醒:[^)]*)$/;function L0(e){const t=/^\[SCHEDULE REMINDER\]\n[\s\S]*?^reminder_prompt_json: (.*)$/m.exec(e);if(t!==null)return[$M(t[1]).replace(P0,"")];const n=/^\[SCHEDULE REMINDER BATCH\]\n[\s\S]*?^reminders_json: (.*)$/m.exec(e);if(n!==null)try{return JSON.parse(n[1]).map(i=>String(i.reminder_prompt??"").replace(P0,"")).filter(i=>i!=="")}catch{return[]}}function TM(e){return e.length===0?"定时提醒":`定时提醒:${e.map(t=>IM(t)).join(";")}`}function $M(e){try{const t=JSON.parse(e);return typeof t=="string"?t:e}catch{return e}}const D0=1;var ci,ys,Bi,ja,jd,mr,Eo,Co,lc,fn,Dp,Fp,Bp,bN,kN,Up,Hp;class MM{constructor(t){Lt(this,fn);ut(this,"status",new Fr({state:"idle",attempt:0}));ut(this,"server",new Fr(null));Lt(this,ci);Lt(this,ys,null);Lt(this,Bi,!1);Lt(this,ja,0);Lt(this,jd,1);Lt(this,mr,new Map);Lt(this,Eo,new Map);Lt(this,Co,new Set);Lt(this,lc);Zt(this,ci,t)}get generation(){return Oe(this,ja)}get ready(){return Oe(this,Bi)}start(){this.status.get().state!=="idle"&&this.status.get().state!=="stopped"||xt(this,fn,Bp).call(this)}stop(){clearTimeout(Oe(this,lc)),this.status.set({state:"stopped",attempt:0});const t=Oe(this,ys);Zt(this,ys,null),xt(this,fn,Up).call(this,"connection stopped"),t==null||t.close(1e3,"client stopped")}on(t,n){let r=Oe(this,Eo).get(t);return r===void 0&&Oe(this,Eo).set(t,r=new Set),r.add(n),()=>{r.delete(n)}}onReady(t){return Oe(this,Co).add(t),Oe(this,Bi)&&queueMicrotask(()=>t(Oe(this,ja))),()=>{Oe(this,Co).delete(t)}}call(t,n,r){return!Oe(this,Bi)&&t!=="initialize"?Promise.reject(new kl(ju.NotInitialized,"not connected to the gateway")):xt(this,fn,Dp).call(this,t,n,r)}}ci=new WeakMap,ys=new WeakMap,Bi=new WeakMap,ja=new WeakMap,jd=new WeakMap,mr=new WeakMap,Eo=new WeakMap,Co=new WeakMap,lc=new WeakMap,fn=new WeakSet,Dp=function(t,n,r){const i=Oe(this,ys);if(i===null||i.readyState!==D0)return Promise.reject(new kl(ju.NotInitialized,"not connected to the gateway"));if((r==null?void 0:r.aborted)===!0)return Promise.reject(r.reason??new Error("aborted"));const o=Wv(this,jd)._++;return new Promise((c,u)=>{const h=Oe(this,ci).callTimeoutMs??6e4,d=h>0?setTimeout(()=>{var g;(g=Oe(this,mr).get(o))==null||g.reject(new kl(ju.InternalError,`${t} timed out`))},h):void 0,p=()=>{var g;Oe(this,mr).has(o)&&(xt(this,fn,Fp).call(this,{jsonrpc:"2.0",method:"$/cancelRequest",params:{id:o}}),(g=Oe(this,mr).get(o))==null||g.reject((r==null?void 0:r.reason)instanceof Error?r.reason:new Error("aborted")))};r==null||r.addEventListener("abort",p,{once:!0});const m=()=>{clearTimeout(d),r==null||r.removeEventListener("abort",p),Oe(this,mr).delete(o)};Oe(this,mr).set(o,{resolve:g=>{m(),c(g)},reject:g=>{m(),u(g)},cleanup:m}),xt(this,fn,Fp).call(this,{jsonrpc:"2.0",id:o,method:t,params:n})})},Fp=function(t){var n;((n=Oe(this,ys))==null?void 0:n.readyState)===D0&&Oe(this,ys).send(JSON.stringify(t))},Bp=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=(Oe(this,ci).createSocket??(r=>new WebSocket(r)))(Oe(this,ci).url)}catch(r){xt(this,fn,Hp).call(this,r instanceof Error?r.message:String(r));return}Zt(this,ys,n),n.addEventListener("open",()=>{Oe(this,ys)===n&&xt(this,fn,bN).call(this,n)}),n.addEventListener("message",r=>{Oe(this,ys)===n&&xt(this,fn,kN).call(this,String(r.data))}),n.addEventListener("close",r=>{if(Oe(this,ys)!==n)return;Zt(this,ys,null),xt(this,fn,Up).call(this,"connection lost");const i=typeof r.reason=="string"&&r.reason!==""?r.reason:`closed (${r.code??"?"})`;xt(this,fn,Hp).call(this,i)}),n.addEventListener("error",()=>{})},bN=async function(t){try{const n=await xt(this,fn,Dp).call(this,"initialize",{protocolVersion:rM,client:Oe(this,ci).clientInfo});if(Oe(this,ys)!==t)return;Zt(this,Bi,!0),Zt(this,ja,Oe(this,ja)+1),this.server.set(n),this.status.set({state:"open",attempt:0});for(const r of[...Oe(this,Co)])r(Oe(this,ja))}catch(n){t.close(4e3,n instanceof Error?n.message:"initialize failed")}},kN=function(t){let n;try{n=JSON.parse(t)}catch{return}const r=pM(n);if(r==="response"){const i=Oe(this,mr).get(n.id);if(i===void 0)return;"error"in n?i.reject(new kl(n.error.code,n.error.message,n.error.data)):i.resolve(n.result)}else if(r==="notification")for(const i of[...Oe(this,Eo).get(n.method)??[]])try{i(n.params)}catch(o){console.error(`notification handler for ${n.method} failed`,o)}},Up=function(t){Zt(this,Bi,!1);for(const n of[...Oe(this,mr).values()])n.reject(new kl(ju.InternalError,t));Oe(this,mr).clear()},Hp=function(t){if(this.status.get().state==="stopped")return;const n=this.status.get().attempt+1,{initial:r,max:i}=Oe(this,ci).backoffMs??{initial:500,max:1e4},o=Math.min(i,r*2**Math.min(n-1,10))*(.8+Math.random()*.4);this.status.set({state:"reconnecting",attempt:n,error:t}),Zt(this,lc,setTimeout(()=>xt(this,fn,Bp).call(this),o))};const RM={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 bs,cc,Ao,Io,ui,Ui,uc,dc,Wt,Zp,Bu,Yn;class OM{constructor(t,n,r){Lt(this,Wt);ut(this,"id");ut(this,"state",new Fr(RM));Lt(this,bs);Lt(this,cc);Lt(this,Ao,null);Lt(this,Io,-1);Lt(this,ui,!1);Lt(this,Ui,null);Lt(this,uc);Lt(this,dc);this.id=t,Zt(this,bs,n),Zt(this,cc,r),Zt(this,uc,n.onReady(i=>{i!==Oe(this,Io)&&xt(this,Wt,Zp).call(this,i)}))}get subscriptionId(){return Oe(this,Ao)}async prompt(t,n="queue",r=[]){const i=crypto.randomUUID(),o={requestId:i,text:t,mode:n,sentAt:Date.now(),...r.length===0?{}:{images:r.length}};xt(this,Wt,Yn).call(this,c=>({...c,pending:[...c.pending,o]}));try{await Oe(this,bs).call("session/prompt",{sessionId:this.id,requestId:i,text:t,mode:n,...r.length===0?{}:{images:[...r]}})}catch(c){const u=c instanceof Error?c.message:String(c);throw xt(this,Wt,Yn).call(this,h=>({...h,pending:h.pending.map(d=>d.requestId===i?{...d,failed:u}:d)})),c}}dismissPending(t){xt(this,Wt,Yn).call(this,n=>({...n,pending:n.pending.filter(r=>r.requestId!==t)}))}async updateQueue(t,n){await Oe(this,bs).call("session/queue/update",{sessionId:this.id,itemId:t,action:n})}async cancel(){await Oe(this,bs).call("session/cancel",{sessionId:this.id})}async compact(){return Oe(this,bs).call("session/compact",{sessionId:this.id})}async loadOlder(){const t=this.state.get(),n=t.events[0];if(!(!t.hasMore||t.loadingOlder||n===void 0)){xt(this,Wt,Yn).call(this,r=>({...r,loadingOlder:!0}));try{const r=await Oe(this,bs).call("session/history",{sessionId:this.id,throughSeq:t.cursor,beforeSeq:n.seq});xt(this,Wt,Yn).call(this,i=>{var u;const o=((u=i.events[0])==null?void 0:u.seq)??Number.POSITIVE_INFINITY,c=r.events.filter(h=>h.seq<o);return{...i,events:[...c,...i.events],hasMore:r.hasMore,loadingOlder:!1}})}catch(r){xt(this,Wt,Yn).call(this,i=>({...i,loadingOlder:!1,error:r instanceof Error?r.message:String(r)}))}}}close(){if(Oe(this,ui))return;Zt(this,ui,!0),clearTimeout(Oe(this,dc)),Oe(this,uc).call(this);const t=Oe(this,Ao);xt(this,Wt,Bu).call(this,null),t!==null&&Oe(this,bs).ready&&Oe(this,bs).call("session/close",{subscriptionId:t}).catch(()=>{}),xt(this,Wt,Yn).call(this,n=>({...n,status:"closed"}))}receiveEvent(t){xt(this,Wt,Yn).call(this,n=>{const r=n.events.at(-1);if(r!==void 0&&t.seq<=r.seq)return n;let i=n.pending;t.type==="user/message"&&t.requestId!==void 0&&(i=i.filter(h=>h.requestId!==t.requestId));let o=n.live;(t.type==="assistant/message"||t.type==="assistant/attempt")&&o!==null&&o.turn===t.turn&&o.step===t.step&&(o=null);const c=t.type==="session/title"?t.title:n.title,u=[...n.events,t];return{...n,events:u,pending:i,live:o,title:c,running:Mf(u,o)}})}receiveLive(t){xt(this,Wt,Yn).call(this,n=>{var r;switch(t.type){case"start":{const i={attemptId:t.attemptId,turn:t.turn,step:t.step,afterSeq:t.afterSeq,deltas:[]};return{...n,live:i,running:!0}}case"delta":{const i=n.live;return i===null||i.attemptId!==t.attemptId?n:(i.deltas.push(t),{...n,live:{...i}})}case"end":return((r=n.live)==null?void 0:r.attemptId)!==t.attemptId?n:{...n,live:null,running:Mf(n.events,null)}}})}receiveClosed(t){xt(this,Wt,Bu).call(this,null),!Oe(this,ui)&&(xt(this,Wt,Yn).call(this,n=>({...n,status:"error",error:`stream ended: ${t}`})),Zt(this,dc,setTimeout(()=>{!Oe(this,ui)&&Oe(this,bs).ready&&xt(this,Wt,Zp).call(this,Oe(this,Io))},1e3)))}receiveQueue(t){xt(this,Wt,Yn).call(this,n=>({...n,queue:t,pending:F0(n.pending,t)}))}receiveContext(t){xt(this,Wt,Yn).call(this,n=>({...n,context:t}))}receiveTitle(t){xt(this,Wt,Yn).call(this,n=>n.title===t?n:{...n,title:t})}}bs=new WeakMap,cc=new WeakMap,Ao=new WeakMap,Io=new WeakMap,ui=new WeakMap,Ui=new WeakMap,uc=new WeakMap,dc=new WeakMap,Wt=new WeakSet,Zp=async function(t){if(!Oe(this,ui))return Oe(this,Ui)!==null?Oe(this,Ui):(Zt(this,Io,t),Zt(this,Ui,(async()=>{try{const n=await Oe(this,bs).call("session/open",{sessionId:this.id});if(Oe(this,ui)){Oe(this,bs).call("session/close",{subscriptionId:n.subscriptionId}).catch(()=>{});return}xt(this,Wt,Bu).call(this,n.subscriptionId);const r=n.live===null?null:{...n.live,deltas:[...n.live.deltas]};xt(this,Wt,Yn).call(this,i=>{const o=new Set(n.events.flatMap(c=>c.type==="user/message"&&c.requestId!==void 0?[c.requestId]:[]));return{...i,status:"open",header:n.header,title:n.title,events:n.events,cursor:n.cursor,hasMore:n.hasMore,live:r,pending:F0(i.pending.filter(c=>!o.has(c.requestId)),n.queue??[]),queue:n.queue??[],context:n.context??i.context,running:Mf(n.events,r),loadingOlder:!1,error:null}})}catch(n){xt(this,Wt,Yn).call(this,r=>({...r,status:"error",error:n instanceof Error?n.message:String(n)}))}finally{Zt(this,Ui,null)}})()),Oe(this,Ui))},Bu=function(t){Zt(this,Ao,t),Oe(this,cc).bindSubscription(this,t)},Yn=function(t){this.state.set(n=>{const r=t(n);return r===n?n:{...r,version:n.version+1}})};function F0(e,t){const n=new Set(t.flatMap(r=>r.requestId===void 0?[]:[r.requestId]));return n.size===0?e:e.filter(r=>!n.has(r.requestId))}function Mf(e,t){if(t!==null)return!0;for(let n=e.length-1;n>=0;n-=1){const r=e[n];if(r.type==="turn/end")return!1;if(r.type==="turn/start")return!0}return!1}const B0=(e,t)=>t.updatedAt-e.updatedAt;var $s,Br,To,Xi,Uu,NN;class zM{constructor(t){Lt(this,Xi);ut(this,"connection");ut(this,"sessions",new Fr({items:[],loaded:!1,error:null}));ut(this,"approvals",new Fr([]));ut(this,"questions",new Fr([]));ut(this,"capabilities",new Fr(new Set));ut(this,"credentialRevision",new Fr(0));ut(this,"providersRevision",new Fr(0));ut(this,"sessionModels",new Fr(new Map));Lt(this,$s,new Map);Lt(this,Br,new Map);Lt(this,To,!1);this.connection=new MM({...t,clientInfo:t.clientInfo??{name:"adg-client",version:"0.1.0"}});const n=this.connection;n.onReady(()=>{var r;this.capabilities.set(new Set(((r=n.server.get())==null?void 0:r.capabilities.map(i=>i.id))??[])),this.approvals.set([]),this.questions.set([]),this.refreshSessions()}),n.on("sessions/changed",r=>{if(r.kind==="removed"){this.sessions.set(o=>({...o,items:o.items.filter(c=>c.id!==r.sessionId)}));return}if(!this.sessions.get().items.some(o=>o.id===r.item.id)){xt(this,Xi,NN).call(this);return}this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===r.item.id?{...c,...PM(r.item)}:c).sort(B0)}))}),n.on("session/title",({sessionId:r,title:i})=>{var o;(o=Oe(this,$s).get(r))==null||o.handle.receiveTitle(i)}),n.on("session/queue",({sessionId:r,items:i})=>{var o;(o=Oe(this,$s).get(r))==null||o.handle.receiveQueue(i)}),n.on("session/context",({sessionId:r,context:i})=>{var o;(o=Oe(this,$s).get(r))==null||o.handle.receiveContext(i)}),n.on("session/event",({subscriptionId:r,event:i})=>{var o;return(o=Oe(this,Br).get(r))==null?void 0:o.receiveEvent(i)}),n.on("session/live",({subscriptionId:r,frame:i})=>{var o;return(o=Oe(this,Br).get(r))==null?void 0:o.receiveLive(i)}),n.on("session/closed",({subscriptionId:r,reason:i})=>{const o=Oe(this,Br).get(r);o!==void 0&&o.subscriptionId===r&&o.receiveClosed(i)}),n.on("approval/requested",r=>{this.approvals.set(i=>i.some(o=>o.approvalId===r.approvalId)?i:[...i,r])}),n.on("approval/resolved",({approvalId:r})=>{this.approvals.set(i=>i.filter(o=>o.approvalId!==r))}),n.on("question/requested",r=>{this.questions.set(i=>i.some(o=>o.questionId===r.questionId)?i:[...i,r])}),n.on("question/resolved",({questionId:r})=>{this.questions.set(i=>i.filter(o=>o.questionId!==r))}),n.on("credentials/changed",()=>this.credentialRevision.set(r=>r+1)),n.on("providers/changed",()=>this.providersRevision.set(r=>r+1)),n.on("session/model",({sessionId:r,lastUsed:i,next:o})=>xt(this,Xi,Uu).call(this,r,{lastUsed:i,next:o}))}async describeCredentials(t){const{items:n}=await this.connection.call("credentials/describe",{refs:[...t]});return n}async setCredential(t,n){await this.connection.call("credentials/set",{ref:t,value:n}),this.credentialRevision.set(r=>r+1)}async unsetCredential(t){await this.connection.call("credentials/unset",{ref:t}),this.credentialRevision.set(n=>n+1)}start(){this.connection.start()}stop(){for(const{handle:t}of Oe(this,$s).values())t.close();Oe(this,$s).clear(),Oe(this,Br).clear(),this.connection.stop()}has(t){return this.capabilities.get().has(t)}async refreshSessions(){try{const{items:t}=await this.connection.call("sessions/list",{});this.sessions.set({items:[...t].sort(B0),loaded:!0,error:null})}catch(t){this.sessions.set(n=>({...n,error:t instanceof Error?t.message:String(t)}))}}async createSession(t,n={}){const{sessionId:r}=await this.connection.call("sessions/create",{...t===void 0?{}:{cwd:t},...n.role===void 0?{}:{role:n.role}});return await this.refreshSessions(),r}async renameSession(t,n){var i;const r=await this.connection.call("sessions/rename",{sessionId:t,title:n});this.sessions.set(o=>({...o,items:o.items.map(c=>c.id===t?{...c,title:r.title}:c)})),(i=Oe(this,$s).get(t))==null||i.handle.receiveTitle(r.title)}modelCatalog(){return this.connection.call("models/catalog",{})}async sessionModel(t){const n=await this.connection.call("session/model",{sessionId:t});return xt(this,Xi,Uu).call(this,t,n),n}async selectModel(t,n){var o;const{selected:r}=await this.connection.call("session/selectModel",{sessionId:t,...n}),i=((o=this.sessionModels.get().get(t))==null?void 0:o.lastUsed)??null;return xt(this,Xi,Uu).call(this,t,{lastUsed:i,next:r}),r}listProviders(){return this.connection.call("providers/list",{})}async discoverModels(t,n){const{models:r}=await this.connection.call("providers/discover",t,n);return r}async providerBalance(t){const{balance:n}=await this.connection.call("providers/balance",{provider:t});return n}async saveProvider(t){const n=await this.connection.call("providers/save",t);return this.providersRevision.set(r=>r+1),t.apiKey!==void 0&&this.credentialRevision.set(r=>r+1),n}async removeProvider(t){const n=await this.connection.call("providers/remove",t);return this.providersRevision.set(r=>r+1),t.removeKey===!0&&this.credentialRevision.set(r=>r+1),n}async respondApproval(t,n){await this.connection.call("approval/respond",{approvalId:t,decision:n}),this.approvals.set(r=>r.filter(i=>i.approvalId!==t))}async answerQuestion(t,n){await this.connection.call("question/respond",{questionId:t,answers:[...n]}),this.questions.set(r=>r.filter(i=>i.questionId!==t))}openSession(t){const n=Oe(this,$s).get(t);if(n!==void 0)return n.refs+=1,n.handle;const r=new OM(t,this.connection,{bindSubscription:(i,o)=>{for(const[c,u]of Oe(this,Br))u===i&&Oe(this,Br).delete(c);o!==null&&Oe(this,Br).set(o,i)}});return Oe(this,$s).set(t,{handle:r,refs:1}),r}release(t){const n=Oe(this,$s).get(t.id);n===void 0||n.handle!==t||(n.refs-=1,!(n.refs>0)&&(Oe(this,$s).delete(t.id),t.close()))}}$s=new WeakMap,Br=new WeakMap,To=new WeakMap,Xi=new WeakSet,Uu=function(t,n){this.sessionModels.set(r=>new Map(r).set(t,n))},NN=function(){Oe(this,To)||(Zt(this,To,!0),setTimeout(()=>{Zt(this,To,!1),this.refreshSessions()},150))};function PM(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Rf=(e,t)=>e.map(n=>n.type===t?n.text:"").join(""),U0=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}}]:[]),LM=e=>e.map(t=>t.type==="text"?t.text:t.type==="image"?"[image]":t.type==="file"?`[file ${t.name??""}]`:"").join("");function wN(e,t,n=[]){var h;const r=[],i=new Map,o=new Set,c=new Map,u=new Map;for(const d of e)switch(d.type){case"user/message":{const p=Rf(d.content,"text");d.origin.human?r.push({kind:"user",id:`u:${d.seq}`,text:p,time:d.time,images:d.content.filter(m=>m.type==="image").length,imageRefs:U0(d.content),files:d.content.filter(m=>m.type==="file").length}):L0(p)!==void 0?r.push({kind:"context",id:`c:${d.seq}`,title:"定时提醒",summary:TM(L0(p)),text:p,startsTurn:!0}):d.replacesHistory===!0?r.push({kind:"context",id:`c:${d.seq}`,title:"较早的对话已压缩成摘要(agent 只记得摘要里的内容)",summary:"",text:p}):d.origin.summary!==void 0&&r.push({kind:"context",id:`c:${d.seq}`,title:d.origin.kind,summary:d.origin.summary,text:p});break}case"assistant/message":{o.add(`${d.turn}:${d.step}`);const p=Rf(d.content,"text"),m=Rf(d.content,"reasoning");(p.trim()!==""||m.trim()!=="")&&r.push({kind:"assistant",id:`a:${d.seq}`,text:p,reasoning:m,live:!1,interrupted:d.interrupted===!0,time:d.time,...d.model===void 0?{}:{model:d.model}});break}case"tool/call":{const p={kind:"tool",id:`t:${d.callId}`,callId:d.callId,name:d.name,arguments:d.arguments,status:"running",time:d.time},m=c.get(d.callId);m!==void 0&&(p.approval=m),i.set(d.callId,p),r.push(p);break}case"tool/result":{const p=i.get(d.callId);if(p===void 0)break;p.result=LM(d.content);const m=U0(d.content);m.length>0&&(p.images=m),p.status=d.isError?"error":"ok",d.error!==void 0&&(p.error=d.error.message);break}case"approval/asked":if(d.callId!==void 0){u.set(d.approvalId,d.callId),c.set(d.callId,"asked");const p=i.get(d.callId);p!==void 0&&(p.approval="asked")}break;case"approval/decided":{const p=u.get(d.approvalId);if(p===void 0)break;c.set(p,d.outcome);const m=i.get(p);m!==void 0&&(m.approval=d.outcome);break}case"turn/end":for(const p of i.values())p.status==="running"&&(p.status="interrupted");d.reason.kind==="error"?r.push({kind:"notice",id:`e:${d.seq}`,tone:"error",text:d.reason.message??"这一轮出错了"}):d.reason.kind==="aborted"?r.push({kind:"notice",id:`e:${d.seq}`,tone:"info",text:"已停止"}):d.reason.kind==="max-tokens"&&r.push({kind:"notice",id:`e:${d.seq}`,tone:"info",text:"回复太长,达到了输出上限"});break;case"compaction/end":r.push({kind:"notice",id:`k:${d.seq}`,tone:d.error===void 0?"info":"error",text:d.error===void 0?"对话太长,较早的内容已压缩成摘要":`压缩对话历史失败:${d.error}`});break}if(t!==null&&!o.has(`${t.turn}:${t.step}`)){let d="",p="";for(const m of t.deltas)m.kind==="text"?d+=m.text:m.kind==="reasoning"&&(p+=m.text);r.push({kind:"assistant",id:`live:${t.attemptId}`,text:d,reasoning:p,live:!0,interrupted:!1,time:((h=t.deltas[0])==null?void 0:h.time)??Date.now()})}for(const d of n)r.push({kind:"user",id:`p:${d.requestId}`,text:d.text,images:d.images??0,imageRefs:[],files:0,time:d.sentAt,pending:{requestId:d.requestId,...d.failed===void 0?{}:{failed:d.failed}}});return r}var b=hc();const DM=Sm(b);function FM(e,t){return e.filter(n=>{var r;return((r=n.available)==null?void 0:r.call(n,t))??!0})}const Hi=new Map,td=new Set;function Bn(e){if(Hi.has(e.id))throw new Error(`UI plugin "${e.id}" is already registered`);Hi.set(e.id,e);for(const t of td)t();return()=>{if(Hi.get(e.id)===e){Hi.delete(e.id);for(const t of td)t()}}}function jN(e){return td.add(e),()=>{td.delete(e)}}function BM(e){return[...Hi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.sessionViews??[]).sort((t,n)=>t.order-n.order)}function UM(e){return[...Hi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.settingsPages??[]).sort((t,n)=>t.order-n.order)}function HM(e){return[...Hi.values()].filter(t=>t.requires.every(n=>e.has(n))).flatMap(t=>t.pages??[]).sort((t,n)=>t.order-n.order)}function ZM(e){return[...Hi.values()].map(t=>({plugin:t,missing:t.requires.filter(n=>!e.has(n))}))}function je(e){return b.useSyncExternalStore(e.subscribe,e.get,e.get)}function Ad(e,t){const[n,r]=b.useState(null);return b.useEffect(()=>{const i=e.openSession(t);return r(i),()=>e.release(i)},[e,t]),n!==null&&n.id===t?n:null}function SN(e){const t=je(e.capabilities),n=Dm();return b.useMemo(()=>BM(t),[t,n])}function WM(e){const t=je(e.capabilities),n=Dm();return b.useMemo(()=>UM(t),[t,n])}function VM(e){const t=je(e.capabilities),n=Dm();return b.useMemo(()=>HM(t),[t,n])}function Dm(){const[e,t]=b.useState(0);return b.useEffect(()=>jN(()=>t(n=>n+1)),[]),e}function _N(e,t){const n=je(e.credentialRevision),r=je(e.connection.status),i=je(e.capabilities),o=t.join(`
126
+ `),[c,u]=b.useState({items:null,error:null});return b.useEffect(()=>{if(r.state!=="open"||!i.has("credentials")||o==="")return;let h=!0;return e.describeCredentials(o.split(`
127
+ `)).then(d=>{h&&u({items:d,error:null})}).catch(d=>{h&&u(p=>({...p,error:d instanceof Error?d.message:String(d)}))}),()=>{h=!1}},[e,o,n,r.state,i]),c}function Zo(e){const t=je(e.credentialRevision),n=je(e.providersRevision),r=je(e.connection.status),i=je(e.capabilities),[o,c]=b.useState({catalog:null,error:null});return b.useEffect(()=>{if(r.state!=="open"||!i.has("models"))return;let u=!0;return e.modelCatalog().then(h=>{u&&c({catalog:h,error:null})}).catch(h=>{u&&c(d=>({...d,error:h instanceof Error?h.message:String(h)}))}),()=>{u=!1}},[e,t,n,r.state,i]),o}function Cn(e){const[t,n]=b.useState(()=>Date.now());return b.useEffect(()=>{const r=setInterval(()=>n(Date.now()),e);return()=>clearInterval(r)},[e]),t}function qM(e){const t=je(e.connection.status),n=je(e.capabilities),[r,i]=b.useState(void 0);return b.useEffect(()=>e.connection.on("permissions/changed",o=>i(o.mode)),[e]),b.useEffect(()=>{if(t.state!=="open"||!n.has("permissions"))return;let o=!0;return e.connection.call("permissions/get",{}).then(c=>{o&&i(c.mode)}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),r}const GM={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"};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:GM[e]})})}function KM(){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 Id({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 H0="adg.otherCopies.seen";function YM(e){const t=je(e.connection.status),r=je(e.capabilities).has("instances"),[i,o]=b.useState([]);return b.useEffect(()=>e.connection.on("instances/changed",c=>o(c.others)),[e]),b.useEffect(()=>{if(t.state!=="open"||!r){o([]);return}let c=!0;return e.connection.call("instances/others",{}).then(u=>{c&&o(u.others)}).catch(()=>{}),()=>{c=!1}},[e,t.state,r]),i}function XM({client:e}){const t=YM(e),n=JSON.stringify(t.map(c=>[c.pid,c.warnings])),[r,i]=b.useState(()=>{try{return localStorage.getItem(H0)}catch{return null}});if(t.length===0||r===n)return null;const o=()=>{try{localStorage.setItem(H0,n)}catch{}i(n)};return s.jsxs("div",{className:"approval-card other-copies",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(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 QM={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function JM(e){const t=je(e.connection.status),r=je(e.capabilities).has("schedule"),[i,o]=b.useState(void 0);return b.useEffect(()=>e.connection.on("schedule/power",o),[e]),b.useEffect(()=>{if(t.state!=="open"||!r){o(void 0);return}let c=!0;return e.connection.call("schedule/power",{}).then(u=>{c&&o(u)}).catch(()=>{}),()=>{c=!1}},[e,t.state,r]),i}function eR({client:e,pending:t}){const n=Cn(1e3),[r,i]=b.useState(!1),[o,c]=b.useState(null),u=QM[t.action],h=async()=>{i(!0),c(null);try{await e.connection.call("schedule/power/cancel",{})}catch(p){c(p instanceof Error?p.message:String(p))}finally{i(!1)}},d=t.at===void 0?void 0:Math.max(0,Math.ceil((t.at-n)/1e3));return s.jsxs("div",{className:"approval-card power-card",role:"alertdialog","aria-label":`即将${u}`,children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(Q,{name:"power"}),s.jsxs("div",{className:"approval-text",children:[s.jsx("div",{className:"approval-title",children:d===void 0?`其他任务结束后${u}`:`${d} 秒后${u}`}),s.jsxs("span",{className:"approval-tool",children:["「",t.pipelineName,"」设置了结束后",u]})]})]}),t.action==="shutdown"&&d!==void 0&&s.jsx("div",{className:"approval-reason",children:"关机会强制关闭所有程序,没保存的内容会丢失。"}),o!==null&&s.jsx("div",{className:"error small",children:o}),s.jsx("div",{className:"approval-actions",children:s.jsxs("button",{className:"inverse",disabled:r,onClick:()=>void h(),children:["取消",u]})})]})}function wr(){return window.adgDesktop}const Z0="adg.update.later";function EN(){var r;const e=(r=wr())==null?void 0:r.updates,[t,n]=b.useState(e===void 0?null:void 0);return b.useEffect(()=>{if(e===void 0)return;let i=!0;e.state().then(c=>{i&&n(c)},()=>{i&&n(null)});const o=e.onChange(c=>{i&&n(c)});return()=>{i=!1,o()}},[e]),{bridge:e,state:t}}function Of(e){return e>=1024*1024?`${Math.round(e/1024/1024)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function CN({bridge:e,state:t,extra:n}){var p;const[r,i]=b.useState(null),[o,c]=b.useState(!1),u=t.latest;if(u===void 0)return null;const h=((p=t.download)==null?void 0:p.version)===u.version?t.download:void 0,d=m=>{i(null),m().catch(g=>i(g instanceof Error?g.message.replace(/^Error invoking remote method '[^']+': (Error: )?/,""):String(g)))};return s.jsxs("div",{className:"update-actions",children:[(h==null?void 0:h.state)==="downloading"&&s.jsxs("div",{className:"update-progress",children:[s.jsx("div",{className:"progress",role:"progressbar","aria-label":"下载进度","aria-valuemin":0,"aria-valuemax":h.total,"aria-valuenow":h.received,children:s.jsx("span",{style:{width:`${h.total>0?Math.min(100,h.received/h.total*100):0}%`}})}),s.jsxs("small",{className:"muted",children:["正在下载 ",Of(h.received)," / ",Of(h.total)]})]}),(h==null?void 0:h.state)==="ready"&&s.jsx("p",{className:"muted small",children:"安装时程序会退出,正在跑的脚本会被中断;装好后自动重新打开,数据和定时任务都在。"}),(h==null?void 0:h.state)==="failed"&&s.jsx("p",{className:"error small",children:h.error}),r!==null&&s.jsx("p",{className:"error small",children:r}),s.jsxs("div",{className:"update-buttons",children:[n,(h==null?void 0:h.state)==="ready"?s.jsx("button",{className:"primary small-button",disabled:o,onClick:()=>{c(!0),d(()=>e.install().finally(()=>c(!1)))},children:o?"正在启动安装…":"退出并安装"}):s.jsx("button",{className:"primary small-button",disabled:(h==null?void 0:h.state)==="downloading",onClick:()=>d(()=>e.download()),children:(h==null?void 0:h.state)==="failed"?"重新下载":(h==null?void 0:h.state)==="downloading"?"正在下载…":`下载更新(${Of(u.size)})`})]})]})}function tR(){var u;const{bridge:e,state:t}=EN(),[n,r]=b.useState(()=>{try{return sessionStorage.getItem(Z0)}catch{return null}}),i=t==null?void 0:t.latest;if(e===void 0||t==null||i===void 0)return null;const o=((u=t.download)==null?void 0:u.version)===i.version&&t.download.state!=="failed";if(!o&&(i.version===t.skipped||i.version===n))return null;const c=()=>{try{sessionStorage.setItem(Z0,i.version)}catch{}r(i.version)};return s.jsxs("div",{className:"approval-card update-card",role:"status",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(Q,{name:"download"}),s.jsxs("div",{className:"approval-text",children:[s.jsxs("span",{className:"approval-title",children:["MultiGameAssistant ",i.version," 可以更新了"]}),s.jsxs("span",{className:"approval-tool",children:["当前 ",t.current,i.prerelease?" · 预发布版":""," · ",s.jsx("a",{href:i.notesUrl,target:"_blank",rel:"noreferrer",children:"查看更新内容"})]})]}),!o&&s.jsx("button",{className:"ghost icon-button update-close","aria-label":"稍后提醒",title:"稍后(下次启动再提醒)",onClick:c,children:s.jsx(Q,{name:"close"})})]}),s.jsx(CN,{bridge:e,state:t,extra:!o&&s.jsx("button",{className:"ghost small-button",onClick:()=>void e.skip(i.version),children:"跳过这个版本"})})]})}function nR({client:e,sessionId:t,onSelect:n}){var p;const r=je(e.approvals),i=je(e.questions),o=(p=JM(e))==null?void 0:p.pending,c=r.filter(m=>m.sessionId===t),u=i.filter(m=>m.sessionId===t),h=[...r,...i].filter(m=>m.sessionId!==t),d=h.some(m=>"approvalId"in m)?h.some(m=>"questionId"in m)?"审批或回答":"审批":"回答";return s.jsxs("div",{className:"approval-dock",children:[o!==void 0&&s.jsx(eR,{client:e,pending:o}),u.map(m=>s.jsx(rR,{client:e,request:m},m.questionId)),c.map(m=>s.jsx(sR,{client:e,request:m},m.approvalId)),h.length>0&&s.jsxs("button",{className:"approval-elsewhere",onClick:()=>n(h[0].sessionId),children:[s.jsx("span",{className:"approval-dot"}),"另有 ",new Set(h.map(m=>m.sessionId)).size," 个会话在等你",d,s.jsx(Q,{name:"chevron"})]}),s.jsx(XM,{client:e}),s.jsx(tR,{})]})}function sR({client:e,request:t}){var h,d,p;const[n,r]=b.useState(!1),[i,o]=b.useState(null),c=((h=t.displayReason)==null?void 0:h.zh)??((d=t.displayReason)==null?void 0:d["zh-CN"])??((p=t.displayReason)==null?void 0:p.en)??t.reason,u=async m=>{r(!0);try{await e.respondApproval(t.approvalId,m)}catch(g){o(g instanceof Error?g.message:String(g)),r(!1)}};return s.jsxs("div",{className:"approval-card",role:"alertdialog","aria-label":"需要审批",children:[s.jsxs("div",{className:"approval-head",children:[s.jsx(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}),i!==null&&s.jsx("div",{className:"error small",children:i}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:n,onClick:()=>void u("reject"),children:"拒绝"}),s.jsx("button",{className:"inverse",disabled:n,onClick:()=>void u("allow-once"),children:"允许本次"})]})]})}function rR({client:e,request:t}){var E;const[n,r]=b.useState({}),[i,o]=b.useState(!1),[c,u]=b.useState(null),h=t.questions.length===1&&t.questions[0].multiSelect!==!0&&(((E=t.questions[0].options)==null?void 0:E.length)??0)>0,d=N=>n[N]??{selected:[],custom:""},p=async N=>{o(!0),u(null);try{await e.answerQuestion(t.questionId,N)}catch(w){u(w instanceof Error?w.message:String(w)),o(!1)}},m=(N,w)=>{if(h)return void p([{id:N.id,selected:[w]}]);r(T=>{const k=T[N.id]??{selected:[],custom:""},I=N.multiSelect===!0?k.selected.includes(w)?k.selected.filter(L=>L!==w):[...k.selected,w]:k.selected.includes(w)?[]:[w];return{...T,[N.id]:{...k,selected:I}}})},g=(N,w)=>r(T=>({...T,[N.id]:{...T[N.id]??{selected:[]},custom:w}})),x=()=>t.questions.map(N=>{const{selected:w,custom:T}=d(N.id),k=T.trim();return{id:N.id,selected:k!==""&&N.multiSelect!==!0?[]:w,...k===""?{}:{custom:k}}}),y=t.questions.every(N=>d(N.id).selected.length>0||d(N.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(N=>{var w,T;return s.jsxs("div",{className:"question-item",children:[N.header!==void 0&&s.jsx("span",{className:"question-header",children:N.header}),s.jsx("div",{className:"question-text",children:N.question}),N.detail!==void 0&&s.jsx("div",{className:"question-detail",children:N.detail}),(((w=N.options)==null?void 0:w.length)??0)>0&&s.jsx("div",{className:"question-options",role:N.multiSelect===!0?"group":"radiogroup",children:N.options.map(k=>{const I=d(N.id).selected.includes(k.label);return s.jsxs("button",{className:`question-option${I?" on":""}`,disabled:i,role:N.multiSelect===!0?"checkbox":"radio","aria-checked":I,onClick:()=>m(N,k.label),children:[s.jsx("span",{className:"question-option-label",children:k.label}),k.description!==void 0&&s.jsx("span",{className:"question-option-desc",children:k.description})]},k.label)})}),s.jsx("input",{className:"text-input question-custom",value:d(N.id).custom,disabled:i,placeholder:(((T=N.options)==null?void 0:T.length)??0)>0?"或者直接写你的回答":"写下你的回答",onChange:k=>g(N,k.target.value),onKeyDown:k=>{k.key==="Enter"&&!k.nativeEvent.isComposing&&y&&p(x())}})]},N.id)}),c!==null&&s.jsx("div",{className:"error small",children:c}),s.jsxs("div",{className:"approval-actions",children:[s.jsx("button",{disabled:i,onClick:()=>void p(t.questions.map(N=>({id:N.id,selected:[]}))),children:"跳过"}),s.jsx("button",{className:"inverse",disabled:i||!y,onClick:()=>void p(x()),children:"回答"})]})]})}const Rs="main",iR={intervene:"alert",games:"gamepad",scripts:"package",pipelines:"flow"},Rn={id:Rs,name:"助手",description:"和你对话、替你安排;飞书里的消息也到这里",icon:"chat"};function Wo(e){return{id:e.id,name:e.name,description:e.description,icon:iR[e.id]??"sparkles"}}function Er(e){const t=je(e.connection.status),[n,r]=b.useState([]);return b.useEffect(()=>{if(t.state!=="open")return;let i=!0;return e.connection.call("roles/list",{}).then(o=>{i&&r(o.items)}).catch(()=>{}),()=>{i=!1}},[e,t.state]),b.useEffect(()=>e.connection.on("roles/changed",i=>r(i.items)),[e]),n}function Aa(e,t){return e.role!==void 0&&t.some(n=>n.id===e.role)?e.role:Rs}function aR(e){return e==="你"?"你布置的":`来自${e}`}function AN(e,t){const n=je(e.connection.status),[r,i]=b.useState(new Map),o=b.useRef(new Map),c=h=>`${h.updatedAt}${h.running?"+":""}`,u=t.map(h=>`${h.id}@${c(h)}`).join(",");return b.useEffect(()=>{if(n.state!=="open")return;const h=t.filter(d=>o.current.get(d.id)!==c(d)).slice(0,60);if(h.length!==0){for(const d of h)o.current.set(d.id,c(d));e.connection.call("sessions/lastReplies",{sessionIds:h.map(d=>d.id)}).then(d=>{i(p=>{const m=new Map(p);for(const g of d.items)m.set(g.sessionId,g.text);return m})}).catch(()=>{for(const d of h)o.current.delete(d.id)})}},[e,n.state,u]),r}const IN="adg.agentSeen";function oR(){try{const e=JSON.parse(localStorage.getItem(IN)??"{}");return e!==null&&typeof e=="object"?e:{}}catch{return{}}}function lR(){const[e,t]=b.useState(oR);return{seen:e,markSeen:(r,i)=>{t(o=>{if((o[r]??0)>=i)return o;const c={...o,[r]:i};try{localStorage.setItem(IN,JSON.stringify(c))}catch{}return c})}}}function TN(e,t){const n=je(e.connection.status),[r,i]=b.useState({agentId:t,sessionId:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("agents/home",{agentId:t}).then(c=>{o&&i({agentId:t,sessionId:c.sessionId,error:null})},c=>{o&&i({agentId:t,sessionId:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),r.agentId===t?r:{sessionId:null,error:null}}function cR(e,t){const n=je(e.connection.status),r=je(e.capabilities),[i,o]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open"||!r.has("agents"))return;let c=!0;return e.connection.call("handoffs/list",{sessionId:t}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t,n.state,r]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:c})=>{c.fromSession!==t&&c.toSession!==t||o(u=>[...u.filter(h=>h.id!==c.id),c])}),[e,t]),i}const uR={feishu:"飞书"},zf=30;function $N(e){const t=je(e.connection.status),n=je(e.capabilities),[r,i]=b.useState(new Set),o=n.has("archive");return b.useEffect(()=>{if(t.state!=="open"||!o)return;let c=!0;return e.connection.call("sessions/archived",{}).then(u=>{c&&i(new Set(u.sessionIds))}).catch(()=>{}),()=>{c=!1}},[e,t.state,o]),b.useEffect(()=>e.connection.on("sessions/archived",c=>i(new Set(c.sessionIds))),[e]),r}function dR(e,t){const n=je(e.sessions),r=je(e.approvals),i=je(e.questions),o=Er(e),c=$N(e),{seen:u,markSeen:h}=lR(),d=b.useMemo(()=>[Rn,...o.map(Wo)],[o]),p=b.useMemo(()=>{var x;const g=new Map(d.map(y=>[y.id,[]]));for(const y of n.items)y.origin==="subagent"||y.blank||c.has(y.id)||(x=g.get(Aa(y,o)))==null||x.push(y);for(const y of g.values())y.sort((E,N)=>N.updatedAt-E.updatedAt);return g},[n.items,c,d,o]);b.useEffect(()=>{var g,x;if(n.loaded)for(const y of d){const E=(x=(g=p.get(y.id))==null?void 0:g[0])==null?void 0:x.updatedAt;E!==void 0&&(y.id===t||u[y.id]===void 0)&&h(y.id,E)}},[n.loaded,p,t]);const m=g=>{const x=n.items.find(y=>y.id===g);return x===void 0?void 0:Aa(x,o)};return d.map(g=>{const x=p.get(g.id)??[],y=x[0];return{agent:g,running:x.filter(E=>E.running).length,unread:g.id!==t&&y!==void 0&&y.updatedAt>(u[g.id]??1/0),waiting:[...r,...i].filter(E=>m(E.sessionId)===g.id).length}})}function hR(e,t){const n=je(e.sessions),r=Er(e);return n.items.some(i=>i.origin!=="subagent"&&!i.blank&&i.home!==t&&Aa(i,r)===t)}function fR({client:e,agentId:t,onSelect:n}){const r=je(e.sessions),i=je(e.connection.status),o=je(e.capabilities),c=Er(e),u=$N(e),h=Cn(3e4),[d,p]=b.useState(null),[m,g]=b.useState(""),[x,y]=b.useState(!1),[E,N]=b.useState(!1),[w,T]=b.useState(new Map),[k,I]=b.useState(0),L=o.has("archive");b.useEffect(()=>e.connection.on("notify/changed",()=>I(R=>R+1)),[e]),b.useEffect(()=>{if(i.state!=="open"||!o.has("notify"))return;let R=!0;return e.connection.call("notify/conversations",{}).then(M=>{R&&T(new Map(M.items.map(F=>[F.sessionId,{channel:F.channel,user:F.user}])))}).catch(()=>{}),()=>{R=!1}},[e,i.state,o,k]);const z=R=>{const M=w.get(R.id);return M!==void 0?uR[M.channel]??M.channel:/^(飞书|feishu):/.test(R.title??"")?"飞书":void 0},U=m.trim().toLowerCase(),{earlier:V,archivedItems:$}=b.useMemo(()=>{const R=r.items.filter(M=>M.origin!=="subagent"&&!M.blank&&M.home!==t&&Aa(M,c)===t&&(U===""||lo(M).toLowerCase().includes(U))).sort((M,F)=>F.updatedAt-M.updatedAt);return{earlier:R.filter(M=>!u.has(M.id)),archivedItems:R.filter(M=>u.has(M.id))}},[r.items,t,c,u,U]),[P,D]=b.useState(null),B=async()=>{const R=P;D(null);const M=(R==null?void 0:R.value.trim())??"",F=r.items.find(H=>H.id===(R==null?void 0:R.id));R===null||F===void 0||M===""||M===lo(F)||await e.renameSession(R.id,M).catch(H=>p(H instanceof Error?H.message:String(H)))},_=async(R,M)=>{p(null),await e.connection.call(M?"sessions/archive":"sessions/unarchive",{sessionId:R}).catch(F=>p(F instanceof Error?F.message:String(F)))},C=R=>{const M=z(R),F=u.has(R.id);return s.jsxs("div",{className:"session-row",children:[(P==null?void 0:P.id)===R.id?s.jsx("input",{className:"text-input session-rename",autoFocus:!0,value:P.value,maxLength:80,"aria-label":"会话名称",onFocus:H=>H.target.select(),onChange:H=>D({id:R.id,value:H.target.value}),onKeyDown:H=>{H.key==="Enter"&&!H.nativeEvent.isComposing&&B(),H.key==="Escape"&&D(null)},onBlur:()=>void B()}):s.jsxs("button",{className:"nav-item session-item",onClick:()=>n(R.id),onDoubleClick:()=>D({id:R.id,value:lo(R)}),title:"双击改名",children:[M!==void 0&&s.jsx("span",{className:"channel-badge",children:M}),s.jsx("span",{className:"nav-item-label",children:M!==void 0?lo(R).replace(/^(飞书|feishu):/,""):lo(R)}),R.running?s.jsx("span",{className:"run-dot",role:"img","aria-label":"运行中"}):s.jsx("span",{className:"session-time",children:At(R.updatedAt,h)})]}),(P==null?void 0:P.id)!==R.id&&s.jsxs("span",{className:"session-row-actions",children:[s.jsx("button",{className:"session-action",title:"改名","aria-label":"改名",onClick:()=>D({id:R.id,value:lo(R)}),children:s.jsx(Q,{name:"pencil"})}),L&&!R.running&&s.jsx("button",{className:"session-action",title:F?"恢复":"归档:从列表里移走,之后可以在「已归档」里找回","aria-label":F?"恢复":"归档",onClick:()=>void _(R.id,!F),children:s.jsx(Q,{name:F?"back":"archive"})})]})]},R.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:m,onChange:R=>g(R.target.value),onKeyDown:R=>{R.key==="Escape"&&g("")}})]}),d!==null&&s.jsx("div",{className:"error small",children:d}),s.jsxs("nav",{className:"session-list","aria-label":"以前的对话",children:[!r.loaded&&i.state==="open"&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),r.loaded&&V.length===0&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(Q,{name:U===""?"chat":"search"}),s.jsx("span",{children:U===""?"没有以前的对话":"没有匹配的对话"})]}),(E?V:V.slice(0,zf)).map(C),!E&&V.length>zf&&s.jsxs("button",{className:"nav-item more-sessions",onClick:()=>N(!0),children:["更多(",V.length-zf,")"]}),L&&$.length>0&&s.jsxs("div",{className:"archive-entry",children:[s.jsxs("button",{className:"nav-item role-row",onClick:()=>y(R=>!R),"aria-expanded":x,children:[s.jsx(Q,{name:"archive"}),s.jsx("span",{className:"nav-item-label",children:"已归档"}),s.jsx("span",{className:"tab-count",children:$.length}),s.jsx(Q,{name:x?"chevron-down":"chevron",className:"role-chevron"})]}),x&&$.map(C)]})]})]})})}function lo(e){return e.title??(e.blank?"新会话":"未命名会话")}function At(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 pR({client:e,pages:t,current:n,onAgent:r,onPage:i,onSchedule:o,onSettings:c}){const u=je(e.connection.status),h=je(e.capabilities),d=dR(e,n.kind==="agent"?n.id:void 0),p=m=>s.jsx(Pf,{icon:m.icon,label:m.title,active:n.kind==="page"&&n.id===m.id,onClick:()=>i(m.id)},m.id);return s.jsxs("nav",{className:"rail","aria-label":"功能区",children:[s.jsx("button",{className:"rail-brand",onClick:()=>{var m;return r(((m=d[0])==null?void 0:m.agent.id)??"")},title:"MultiGameAssistant",children:s.jsx(Id,{})}),s.jsxs("div",{className:"rail-items",children:[t.filter(m=>m.order<0).map(p),s.jsx("span",{className:"rail-divider",role:"separator"}),d.map(m=>s.jsx(mR,{state:m,active:n.kind==="agent"&&n.id===m.agent.id,onClick:()=>r(m.agent.id)},m.agent.id)),t.filter(m=>m.order>=0).map(p)]}),s.jsxs("div",{className:"rail-footer",children:[h.has("pipelines")&&s.jsx(Pf,{icon:"calendar",label:"定时",title:"每个 agent 的定时任务,和按时运行的流水线",active:n.kind==="schedule",onClick:o}),s.jsx(Pf,{icon:"settings",label:"设置",active:n.kind==="settings",onClick:c}),s.jsxs("span",{className:`rail-connection ${u.state}`,role:"status",title:W0(u.state,u.attempt,u.error),children:[s.jsx("span",{className:"conn-dot"}),s.jsx("span",{className:"sr-only",children:W0(u.state,u.attempt,u.error)})]})]})]})}function mR({state:e,active:t,onClick:n}){const{agent:r,running:i,unread:o,waiting:c}=e;return s.jsxs("button",{className:`rail-item rail-agent ${t?"active":""}`,"aria-current":t?"page":void 0,onClick:n,title:`${r.name}:${r.description}${i>0?`(进行中${i>1?` ${i}`:""})`:""}`,children:[s.jsxs("span",{className:`agent-avatar rail-avatar agent-${r.id}`,children:[s.jsx(Q,{name:r.icon}),i>0&&s.jsx("span",{className:"agent-busy",role:"img","aria-label":`${i} 个正在运行`})]}),s.jsx("span",{className:`rail-label ${o?"unread":""}`,children:r.name}),c>0?s.jsx("span",{className:"rail-badge","aria-label":`${c} 个等你处理`,children:c}):o&&s.jsx("span",{className:"rail-unread",role:"img","aria-label":"有新结果"})]})}function Pf({icon:e,label:t,title:n=t,active:r,onClick:i,disabled:o=!1}){return s.jsxs("button",{className:`rail-item ${r?"active":""}`,"aria-current":r?"page":void 0,onClick:i,title:n,disabled:o,children:[s.jsx(Q,{name:e}),s.jsx("span",{className:"rail-label",children:t})]})}function W0(e,t,n){const r=e==="open"?"已连接 agent":e==="connecting"?"正在连接…":e==="reconnecting"?`重连中(第 ${t} 次)`:"未连接";return n===void 0?r:`${r}:${n}`}const Wp="adg.token",Fm=/^\/adg(\/|$)/.test(location.pathname);function gR(){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 MN(){const e=new URL(location.href),t=e.searchParams.get("token");if(t!==null&&t!==""){try{sessionStorage.setItem(Wp,t)}catch{}return e.searchParams.delete("token"),history.replaceState(history.state,"",e),t}try{return sessionStorage.getItem(Wp)}catch{return null}}function xR(e){try{sessionStorage.setItem(Wp,e)}catch{}}function vR(e){if(Fm){const n=new URL(gR()??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 V0(){if(location.hash==="#/settings")return{kind:"settings"};const e=/^#\/settings\/(.+)$/.exec(location.hash);if(e!==null)return{kind:"settings",section:decodeURIComponent(e[1])};const t=/^#\/w\/([^/]+)\/(.+)$/.exec(location.hash);if(t!==null)return{kind:"window",view:decodeURIComponent(t[1]),sessionId:decodeURIComponent(t[2])};const n=/^#\/p\/([^/]+)(?:\/(.+))?$/.exec(location.hash);if(n!==null)return{kind:"page",id:decodeURIComponent(n[1]),...n[2]===void 0?{}:{arg:decodeURIComponent(n[2])}};if(location.hash==="#/chat")return{kind:"home"};if(location.hash==="#/schedule")return{kind:"schedule"};const r=/^#\/h\/(.+)$/.exec(location.hash);if(r!==null)return{kind:"handoff",id:decodeURIComponent(r[1])};const i=/^#\/a\/(.+)\/(schedule|history)$/.exec(location.hash);if(i!==null)return{kind:"agent",id:decodeURIComponent(i[1]),tab:i[2]};const o=/^#\/a\/(.+)$/.exec(location.hash);if(o!==null)return{kind:"agent",id:decodeURIComponent(o[1])};const c=/^#\/s\/(.+)$/.exec(location.hash);return c===null?{kind:"start"}:{kind:"session",id:decodeURIComponent(c[1])}}function yR(e,t="push"){const n=e.kind==="window"?`#/w/${encodeURIComponent(e.view)}/${encodeURIComponent(e.sessionId)}`:e.kind==="session"?`#/s/${encodeURIComponent(e.id)}`:e.kind==="agent"?`#/a/${encodeURIComponent(e.id)}${e.tab===void 0?"":`/${e.tab}`}`:e.kind==="handoff"?`#/h/${encodeURIComponent(e.id)}`:e.kind==="schedule"?"#/schedule":e.kind==="page"?`#/p/${encodeURIComponent(e.id)}${e.arg===void 0?"":`/${encodeURIComponent(e.arg)}`}`:e.kind==="settings"?e.section===void 0?"#/settings":`#/settings/${encodeURIComponent(e.section)}`:e.kind==="home"?"#/chat":"";if(location.hash===n)return;const r=`${location.pathname}${location.search}${n}`;t==="replace"?history.replaceState(history.state,"",r):history.pushState(null,"",r)}function bR(e,t){const n=new URL(location.href),r=MN();return r!==null&&n.searchParams.set("token",r),n.hash=`#/w/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,n.href}const nd="adg.draft.",q0=60,Vp=new Map;function kR(e){try{const t=localStorage.getItem(nd+e);if(t===null)return"";const n=JSON.parse(t);return typeof n.text=="string"?n.text:""}catch{return""}}function NR(e,t){try{if(t.trim()===""){localStorage.removeItem(nd+e);return}localStorage.setItem(nd+e,JSON.stringify({text:t,at:Date.now()})),SR()}catch{}}function wR(e){return Vp.get(e)??[]}function jR(e,t){t.length===0?Vp.delete(e):Vp.set(e,[...t])}function SR(){const e=[];for(let t=0;t<localStorage.length;t++){const n=localStorage.key(t);if(!(n===null||!n.startsWith(nd)))try{e.push({key:n,at:Number(JSON.parse(localStorage.getItem(n)??"{}").at)||0})}catch{e.push({key:n,at:0})}}if(!(e.length<=q0))for(const t of e.sort((n,r)=>n.at-r.at).slice(0,e.length-q0))localStorage.removeItem(t.key)}const _R={off:"不思考",none:"不思考",minimal:"最少",low:"低",medium:"中",high:"高",xhigh:"很高",max:"最大"},G0=(e,t)=>_R[e]??(t!==void 0&&t!==e?t:e);function RN(e,t){return(t==null?void 0:t.next)??(t==null?void 0:t.lastUsed)??(e==null?void 0:e.default)??null}function ER(e,t){var n;if(!(e===null||t===null))return(n=e.groups.find(r=>r.id===t.provider))==null?void 0:n.models.find(r=>r.id===t.model)}function CR({client:e,sessionId:t,disabled:n,value:r,onChange:i}){var B;const{catalog:o,error:c}=Zo(e),u=je(e.sessionModels),h=je(e.connection.status),[d,p]=b.useState(!1),[m,g]=b.useState(null),[x,y]=b.useState(!1),[E,N]=b.useState(""),w=b.useRef(null);b.useEffect(()=>{h.state!=="open"||t===void 0||e.sessionModel(t).catch(()=>{})},[e,t,h.state]),b.useEffect(()=>{if(!x)return;const _=R=>{w.current!==null&&!w.current.contains(R.target)&&y(!1)},C=R=>{R.key==="Escape"&&y(!1)};return document.addEventListener("mousedown",_),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("keydown",C)}},[x]);const T=t===void 0?void 0:u.get(t),k=t===void 0?r??(o==null?void 0:o.default)??null:RN(o,T),I=ER(o,k),L=k!==null&&o!==null&&I===void 0,z=async _=>{if(g(null),t===void 0){i==null||i(_);return}p(!0);try{await e.selectModel(t,_)}catch(C){g(C instanceof Error?C.message:String(C))}finally{p(!1)}},U=(_,C)=>{const R=(k==null?void 0:k.reasoningEffort)!==void 0&&C.efforts.some(M=>M.id===k.reasoningEffort)?k.reasoningEffort:C.defaultEffort;z({provider:_,model:C.id,...R===void 0?{}:{reasoningEffort:R}}),C.efforts.length===0&&y(!1)},V=b.useMemo(()=>{const _=E.trim().toLowerCase();return((o==null?void 0:o.groups)??[]).map(C=>({...C,models:C.models.filter(R=>_===""||R.id.toLowerCase().includes(_)||R.name.toLowerCase().includes(_)||C.name.toLowerCase().includes(_))})).filter(C=>C.models.length>0)},[o,E]),$=[m,c,...(o==null?void 0:o.failures.map(_=>`${_.name}:${_.message}`))??[]].filter(Boolean);if(o===null)return null;const P=(k==null?void 0:k.reasoningEffort)??(I==null?void 0:I.defaultEffort),D=(B=I==null?void 0:I.efforts.find(_=>_.id===P))==null?void 0:B.name;return s.jsxs("div",{className:`model-picker${m!==null?" has-error":""}`,ref:w,children:[s.jsxs("button",{type:"button",className:"model-trigger","aria-haspopup":"dialog","aria-expanded":x,disabled:n||d,title:$.length>0?$.join(`
128
+ `):"选择模型和思考强度",onClick:()=>y(_=>!_),children:[s.jsx("span",{className:`model-dot ${L?"off":""}`}),s.jsx("span",{className:"model-name",children:(I==null?void 0:I.name)??(k===null?"选择模型":`${k.model}(不可用)`)}),P!==void 0&&I!==void 0&&I.efforts.length>0&&s.jsx("span",{className:"model-effort",children:G0(P,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:E,onChange:_=>N(_.target.value)}),s.jsxs("div",{className:"model-list",role:"listbox","aria-label":"模型",children:[V.length===0&&s.jsx("div",{className:"muted small pad",children:"没有匹配的模型"}),V.map(_=>s.jsxs("div",{className:"model-group",children:[s.jsx("div",{className:"model-group-name",children:_.name}),_.models.map(C=>{const R=(k==null?void 0:k.provider)===_.id&&k.model===C.id;return s.jsxs("button",{type:"button",role:"option","aria-selected":R,className:`model-option ${R?"active":""}`,onClick:()=>U(_.id,C),children:[s.jsxs("span",{className:"model-option-main",children:[s.jsx("span",{children:C.name}),C.name!==C.id&&s.jsx("span",{className:"muted small",children:C.id})]}),C.efforts.length>0&&s.jsx("span",{className:"model-tag",children:"思考"}),R&&s.jsx(Q,{name:"check"})]},C.id)})]},_.id))]}),I!==void 0&&k!==null&&s.jsxs("div",{className:"model-efforts",children:[s.jsx("span",{className:"field-label",children:"思考强度"}),I.efforts.length===0?s.jsx("span",{className:"muted small",children:"这个模型没有可选的思考强度(在「设置 → 模型」里给模型打开「思考」)"}):s.jsx("div",{className:"segmented-control",role:"radiogroup","aria-label":"思考强度",children:I.efforts.map(_=>s.jsx("button",{type:"button",role:"radio","aria-checked":P===_.id,className:P===_.id?"active":"",onClick:()=>void z({provider:k.provider,model:k.model,reasoningEffort:_.id}),children:G0(_.id,_.name)},_.id))})]}),$.length>0&&s.jsx("div",{className:"error small model-problems",children:$.join(";")})]})]})}function ON(e,t){return t.find(n=>n.scripts.includes(e.packId??e.id)||n.scripts.includes(e.id))}function qp(e,t){const n=e.toLowerCase();return t.find(r=>[r.id,r.name,...r.aliases].some(i=>i.toLowerCase()===n))}function Gp(e,t,n){const r=[];for(const i of new Set((e==null?void 0:e.scripts)??[])){const o=t.find(u=>u.id===i||u.packId===i),c=o===void 0?n.find(u=>u.scripts.includes(i)):ON(o,n);r.push({script:o===void 0?{id:i,name:i}:{id:o.id,name:o.name},...c===void 0?{}:{game:{id:c.id,name:c.name}}})}if(r.length===0)for(const i of new Set((e==null?void 0:e.games)??[])){const o=qp(i,n);r.push({game:o===void 0?{id:i,name:i}:{id:o.id,name:o.name}})}return r}function zN(e){var t,n;return[(t=e.game)==null?void 0:t.name,(n=e.script)==null?void 0:n.name].filter(r=>r!==void 0).join(" · ")}let Lf=[];function AR(e){const t=je(e.capabilities),n=t.has("skills"),r=t.has("scripts"),i=t.has("games"),[o,c]=b.useState(Lf),[u,h]=b.useState(0);return b.useEffect(()=>e.connection.on("skills/changed",()=>h(d=>d+1)),[e]),b.useEffect(()=>{if(!n)return;let d=!0;const p=r?e.connection.call("scripts/list",{}).then(g=>g.scripts,()=>[]):Promise.resolve([]),m=i?e.connection.call("games/list",{}).then(g=>g.games,()=>[]):Promise.resolve([]);return Promise.all([e.connection.call("skills/list",{}),p,m]).then(([g,x,y])=>{Lf=g.skills.filter(E=>E.userInvocable).map(E=>{const N=[...new Set(Gp(E.owner,x,y).map(zN))].join("、");return{name:E.name,description:E.description,...N===""?{}:{group:N}}}),d&&c(Lf)},()=>{}),()=>{d=!1}},[e,n,r,i,u]),o}const Df=e=>e.kind==="command"?"命令":e.group??"通用技能";function PN({client:e,text:t,setText:n,area:r,submit:i,placement:o="above",inSession:c=!1}){const u=AR(e),[h,d]=b.useState(0),[p,m]=b.useState(!1),g=p?[]:bM(t,u,c),x=t.split(/\s/)[0];b.useEffect(()=>{d(0),m(!1)},[x]);const y=Math.min(h,Math.max(0,g.length-1)),E=k=>{var I;n(`/${k.name} `),m(!0),(I=r.current)==null||I.focus()},N=k=>{var I;if(i!==void 0&&k.kind==="command"&&k.arg===void 0){n(""),i(`/${k.name}`),(I=r.current)==null||I.focus();return}E(k)},w=k=>{if(g.length===0||k.nativeEvent.isComposing)return!1;if(k.key==="ArrowDown"||k.key==="ArrowUp")return k.preventDefault(),d((y+(k.key==="ArrowDown"?1:g.length-1))%g.length),!0;if(k.key==="Tab"||k.key==="Enter"&&!k.shiftKey){k.preventDefault();const I=g[y];return k.key==="Tab"?E(I):N(I),!0}return k.key==="Escape"?(k.preventDefault(),m(!0),!0):!1};return{menu:g.length===0?null:s.jsx(IR,{options:g,active:y,placement:o,onHover:d,onChoose:N}),onKeyDown:w,expand:k=>vM(k,u)}}function IR({options:e,active:t,placement:n,onHover:r,onChoose:i}){const o=b.useRef(null),[c,u]=b.useState(0);b.useLayoutEffect(()=>{var p;const d=(p=o.current)==null?void 0:p.querySelector(`[data-index="${t}"]`);d==null||o.current===null||(d.scrollIntoView({block:"nearest"}),u(d.offsetTop-o.current.scrollTop))},[t,e]);const h=e[t];return s.jsxs("div",{className:`slash-pop ${n}`,children:[s.jsx("div",{ref:o,className:"slash-list",role:"listbox","aria-label":"命令和技能",onScroll:()=>{var p;const d=(p=o.current)==null?void 0:p.querySelector(`[data-index="${t}"]`);d!=null&&o.current!==null&&u(d.offsetTop-o.current.scrollTop)},children:e.map((d,p)=>s.jsxs("div",{children:[(p===0||Df(e[p-1])!==Df(d))&&s.jsx("div",{className:"slash-group",children:Df(d)}),s.jsx("button",{type:"button",role:"option","data-index":p,"aria-selected":p===t,className:`slash-item ${p===t?"active":""}`,onMouseEnter:()=>r(p),onMouseDown:m=>m.preventDefault(),onClick:()=>i(d),children:d.name})]},`${d.kind}:${d.name}`))}),h!==void 0&&s.jsxs("div",{className:"slash-tip",style:{top:c},role:"tooltip",children:[h.kind==="skill"&&s.jsx("span",{className:"slash-tip-kind",children:h.group===void 0?"技能":`${h.group} 的技能`}),h.description,h.kind==="command"&&h.arg!==void 0&&s.jsxs("span",{className:"slash-tip-arg",children:["后面可以接:",h.arg]}),h.kind==="skill"&&s.jsx("span",{className:"slash-tip-arg",children:"后面写要它做的事"})]})]})}const Kp=5.5,K0=2*Math.PI*Kp,Y0=[{key:"systemTokens",label:"系统提示词",tone:"system"},{key:"toolsTokens",label:"工具定义",tone:"tools"},{key:"messageTokens",label:"对话消息",tone:"messages"}];function Ff(e){return e>=1e6?`${X0(e/1e6)}M`:e>=1e3?`${X0(e/1e3)}k`:String(Math.round(e))}const X0=e=>e>=100?Math.round(e).toString():e.toFixed(1).replace(/\.0$/,"");function TR({context:e}){const[t,n]=b.useState(!1),r=b.useRef(null);if(b.useEffect(()=>{if(!t)return;const p=g=>{var x;(x=r.current)!=null&&x.contains(g.target)||n(!1)},m=g=>{g.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",m)}},[t]),e===null)return null;const i=Math.min(100,Math.round(e.usedTokens/e.contextWindow*100)),o=i>=90?"high":i>=70?"raised":"normal",c=e.breakdown,u=c===void 0?0:c.systemTokens+c.toolsTokens+c.messageTokens,h=c===void 0||u===0?[{key:"total",tone:"messages",width:i}]:Y0.map(p=>({key:p.key,tone:p.tone,width:i*c[p.key]/u})).filter(p=>p.width>0),d=`上下文已用 ${i}%`;return s.jsxs("span",{ref:r,className:`context-meter ${o}`,children:[s.jsxs("button",{type:"button",className:"context-trigger",title:d,"aria-label":d,"aria-haspopup":"dialog","aria-expanded":t,onClick:()=>n(!t),children:[s.jsxs("svg",{viewBox:"0 0 14 14",width:"14",height:"14","aria-hidden":"true",children:[s.jsx("circle",{className:"context-track",cx:"7",cy:"7",r:Kp}),s.jsx("circle",{className:"context-fill",cx:"7",cy:"7",r:Kp,strokeDasharray:`${K0*i/100} ${K0}`,transform:"rotate(-90 7 7)"})]}),s.jsxs("span",{children:[i,"%"]})]}),t&&s.jsxs("div",{className:"context-panel",role:"dialog","aria-label":"上下文用量",children:[s.jsxs("div",{className:"context-head",children:[s.jsxs("span",{children:["上下文已用 ",s.jsxs("strong",{children:[i,"%"]})]}),s.jsxs("span",{className:"context-figures",children:["~",Ff(e.usedTokens)," / ",Ff(e.contextWindow)]})]}),s.jsx("div",{className:"context-bar",children:h.map(p=>s.jsx("span",{className:`context-segment ${p.tone}`,style:{width:`${p.width}%`}},p.key))}),c!==void 0&&s.jsx("dl",{className:"context-rows",children:Y0.map(p=>s.jsxs("div",{children:[s.jsxs("dt",{children:[s.jsx("span",{className:`context-swatch ${p.tone}`,"aria-hidden":"true"}),p.label]}),s.jsxs("dd",{children:["~",Ff(c[p.key])]})]},p.key))}),s.jsxs("p",{className:"context-tip",children:["快满时会自动压缩(「设置 → 对话压缩」)。也可以输入 ",s.jsx("kbd",{children:"/压缩"})," 手动压缩:较早的部分换成摘要,agent 会忘掉其中的细节。"]})]})]})}const $R=6e4,MR={CNY:"¥",USD:"$"},Hu=(e,t)=>{const n=MR[e];return n===void 0?`${t} ${e}`:`${n}${t}`};function RR({balances:e}){const t=e.filter(n=>Number(n.total)!==0);return(t.length>0?t:e.slice(0,1)).map(n=>Hu(n.currency,n.total)).join(" / ")}function OR(e){return`DeepSeek 账户余额 ${e.balances.map(n=>`${Hu(n.currency,n.total)}(充值 ${Hu(n.currency,n.toppedUp)},赠送 ${Hu(n.currency,n.granted)})`).join("、")}${e.available?"":"。余额不足,调用模型会失败"}`}function zR({client:e,sessionId:t,running:n}){var m;const{catalog:r}=Zo(e),i=je(e.sessionModels).get(t),o=((m=RN(r,i))==null?void 0:m.provider)??null,c=je(e.credentialRevision),u=je(e.connection.status),h=je(e.capabilities),[d,p]=b.useState(null);return b.useEffect(()=>{if(o===null||u.state!=="open"||!h.has("providers"))return;let g=!0;const x=()=>e.providerBalance(o).then(E=>{g&&p({provider:o,balance:E,error:null})},E=>{g&&p({provider:o,balance:null,error:E instanceof Error?E.message:String(E)})});x();const y=n?setInterval(()=>void x(),$R):void 0;return()=>{g=!1,clearInterval(y)}},[e,o,c,u.state,h,n]),d===null||d.provider!==o?null:d.error!==null?s.jsx("span",{className:"balance-chip failed",title:d.error,children:"余额 ?"}):d.balance===null||d.balance.balances.length===0?null:s.jsx("span",{className:`balance-chip ${d.balance.available?"":"low"}`,title:OR(d.balance),children:RR(d.balance)})}function PR({client:e,session:t,running:n,disabled:r,initialPrompt:i,onInitialSent:o}){const c=je(e.capabilities),{queue:u,context:h}=je(t.state),[d,p]=b.useState(()=>kR(t.id)),[m,g]=b.useState(!0),[x,y]=b.useState(null),[E,N]=b.useState(null),w=b.useRef(null),T=b.useRef(null),k=b.useRef(!1),[I,L]=b.useState(()=>wR(t.id));b.useEffect(()=>NR(t.id,d),[t.id,d]),b.useEffect(()=>jR(t.id,I),[t.id,I]);const z=qM(e),[U,V]=b.useState(!1),$=async H=>{const W=H.filter(q=>q.type.startsWith("image/"));if(W.length===0)return;y(null);const K=Nl-I.length;if(K<=0){y(`一条消息最多 ${Nl} 张图片`);return}try{const q=await Promise.all(W.slice(0,K).map(FR));L(Y=>[...Y,...q].slice(0,Nl)),W.length>K&&y(`一条消息最多 ${Nl} 张图片,多的没有加上`)}catch(q){y(`图片没能加上:${q instanceof Error?q.message:String(q)}`)}},P=H=>{const W=[...H.clipboardData.items].filter(K=>K.kind==="file"&&K.type.startsWith("image/")).map(K=>K.getAsFile()).filter(K=>K!==null);W.length!==0&&(H.preventDefault(),$(W))},D=H=>{V(!1),H.dataTransfer.files.length!==0&&(H.preventDefault(),$([...H.dataTransfer.files]))};b.useEffect(()=>{var H;i===void 0||k.current||r||(k.current=!0,t.prompt(i,"queue").catch(W=>y(W instanceof Error?W.message:String(W))),o==null||o(),(H=w.current)==null||H.focus())},[i,r,t,o]);const B=H=>gM(H)!=="compact"?!1:(p(""),y(null),n?(y("agent 正在工作,等它停下再压缩"),!0):(window.confirm(LR)&&(N("正在压缩对话:模型在写摘要,可能要一两分钟…"),t.compact().then(W=>N(W.message),W=>{N(null),y(W instanceof Error?W.message:String(W))})),!0)),_=PN({client:e,text:d,setText:p,area:w,inSession:!0,submit:H=>{r||B(H)||(y(null),t.prompt(_.expand(H),n&&m?"steer":"queue").catch(W=>y(W instanceof Error?W.message:String(W))))}}),C=()=>{var K;if(!r&&I.length===0&&B(d))return;const H=_.expand(d);if(H===""&&I.length===0||r)return;const W=I.map(({url:q,...Y})=>Y);p(""),L([]),y(null),t.prompt(H,n&&m?"steer":"queue",W).catch(q=>y(q instanceof Error?q.message:String(q))),(K=w.current)==null||K.focus()},R=H=>{_.onKeyDown(H)||H.key==="Enter"&&!H.shiftKey&&!H.nativeEvent.isComposing&&(H.preventDefault(),C())},M=H=>{t.updateQueue(H.id,"remove").then(()=>{d.trim()===""&&H.text!==""&&p(H.text)},W=>y(W instanceof Error?W.message:String(W)))},F=H=>{t.updateQueue(H.id,"steer").catch(W=>y(W instanceof Error?W.message:String(W)))};return s.jsxs("div",{className:"composer",children:[x!==null&&s.jsx("div",{className:"error small composer-error",children:x}),E!==null&&s.jsxs("div",{className:"composer-note small",role:"status",children:[s.jsx("span",{children:E}),s.jsx("button",{type:"button",className:"ghost small-button",onClick:()=>N(null),children:"知道了"})]}),u.length>0&&s.jsx("div",{className:"queue","aria-label":"等待发送的消息",children:u.map(H=>s.jsxs("div",{className:"queue-item",children:[s.jsx("span",{className:`queue-tag ${H.placement}`,children:H.placement==="next-step"?"插入中":"排队中"}),s.jsxs("span",{className:"queue-text",title:H.text,children:[H.text===""?"(图片)":H.text,H.images!==void 0&&s.jsxs("span",{className:"muted",children:[" · ",H.images," 张图片"]})]}),s.jsx("span",{className:"queue-when muted",children:H.placement==="next-step"?"这一步做完就交给 agent":"这一轮结束后发送"}),H.placement==="next-turn"&&n&&s.jsx("button",{type:"button",className:"small-button",title:"不等这一轮结束,现在就交给 agent",onClick:()=>F(H),children:"现在插入"}),s.jsx("button",{type:"button",className:"small-button",title:"撤回这条消息",onClick:()=>M(H),children:"撤回"})]},H.id))}),s.jsxs("div",{className:"slash-anchor",children:[_.menu,s.jsxs("div",{className:`composer-box ${U?"dragging":""}`,onDragOver:H=>{[...H.dataTransfer.items].some(W=>W.kind==="file")&&(H.preventDefault(),V(!0))},onDragLeave:()=>V(!1),onDrop:D,children:[I.length>0&&s.jsx("div",{className:"composer-images",children:I.map((H,W)=>s.jsxs("span",{className:"composer-image",children:[s.jsx("img",{src:H.url,alt:H.name??`图片 ${W+1}`}),s.jsx("button",{type:"button","aria-label":"移除这张图片",onClick:()=>L(K=>K.filter((q,Y)=>Y!==W)),children:"✕"})]},W))}),s.jsx("textarea",{onPaste:P,ref:w,"aria-label":"消息内容",value:d,onChange:H=>p(H.target.value),onKeyDown:R,rows:Math.min(8,Math.max(2,d.split(`
129
+ `).length)),placeholder:r?"未连接到 agent":n?m?"运行中:发出去会插进这一轮,改主意了直接说":"运行中:消息会排队到下一轮":"继续追问,或描述下一步要做的事",disabled:r}),s.jsxs("div",{className:"composer-actions",children:[c.has("models")&&s.jsx(CR,{client:e,sessionId:t.id,disabled:r}),s.jsx("button",{type:"button",className:"attach-button",title:"添加图片(也可以直接粘贴或拖进来)","aria-label":"添加图片",disabled:r||I.length>=Nl,onClick:()=>{var H;return(H=T.current)==null?void 0:H.click()},children:s.jsx(Q,{name:"image"})}),s.jsx("input",{ref:T,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",multiple:!0,hidden:!0,onChange:H=>{$([...H.target.files??[]]),H.target.value=""}}),z==="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(zR,{client:e,sessionId:t.id,running:n}),s.jsx(TR,{context:h}),n&&s.jsxs("label",{className:"steer-toggle",title:"这一步做完 agent 就会看到;不勾选就等这一轮结束再发",children:[s.jsx("input",{type:"checkbox",checked:m,onChange:H=>g(H.target.checked)}),"插入当前轮次"]}),n&&s.jsxs("button",{className:"stop-button",onClick:()=>void t.cancel().catch(H=>y(String(H))),disabled:r,children:[s.jsx(KM,{}),"停止"]}),s.jsx("button",{className:"send-button","aria-label":"发送",title:"发送(Enter)",onClick:C,disabled:r||d.trim()===""&&I.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 LR=["压缩会把这个对话较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:","","· 会丢失记忆:早先的细节 agent 不再记得(具体的命令和输出、日志、截图、你说过的原话);","· 摘要可能漏掉或写错内容;","· 不能撤销。界面上的聊天记录还在,但 agent 看不到了。","","对话很长、回复变慢或报上下文超长时再压缩。确定压缩吗?"].join(`
130
+ `),Nl=4,DR=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function FR(e){const t=await new Promise((o,c)=>{const u=new FileReader;u.onload=()=>o(String(u.result)),u.onerror=()=>c(u.error??new Error("读取失败")),u.readAsDataURL(e)}),n=e.name===""||e.name==="image.png"?`粘贴的图片.${e.type.split("/")[1]??"png"}`:e.name,r=t.slice(t.indexOf(",")+1);if(DR.has(e.type)&&r.length<=Lp)return{mediaType:e.type,data:r,name:n,url:t};const i=new Image;i.src=t,await i.decode();for(let o=2560;o>=640;o=Math.round(o*.75)){const c=Math.min(1,o/Math.max(i.naturalWidth,i.naturalHeight)),u=document.createElement("canvas");u.width=Math.max(1,Math.round(i.naturalWidth*c)),u.height=Math.max(1,Math.round(i.naturalHeight*c)),u.getContext("2d").drawImage(i,0,0,u.width,u.height);const h=u.toDataURL("image/jpeg",.88),d=h.slice(h.indexOf(",")+1);if(d.length<=Lp)return{mediaType:"image/jpeg",data:d,name:n.replace(/\.\w+$/,".jpg"),url:h}}throw new Error("图片太大")}function Yp({client:e,sessionId:t,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o}){const c=Ad(e,t);return c===null?s.jsx("div",{className:"main empty",children:"正在打开会话…"}):s.jsx(BR,{client:e,session:c,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o})}function LN(e,t){const[n,r]=b.useState(!1);return t&&!n&&r(!0),e!==void 0&&e.home===void 0&&e.blank!==!0&&!t&&!n}function BR({client:e,session:t,reminder:n,initialPrompt:r,onInitialSent:i,onAgent:o}){const c=je(t.state),u=je(e.connection.status),h=Er(e),d=je(e.sessions).items.find(k=>k.id===t.id),p=d===void 0?Rs:Aa(d,h),m=h.find(k=>k.id===p),g=m===void 0?Rn:Wo(m),x=(d==null?void 0:d.home)!==void 0,y=FM(SN(e),c),[E,N]=b.useState(()=>WR()),w=y.find(k=>k.id===E)??y[0];b.useEffect(()=>VR(E),[E]);const T=LN(d,c.running||c.queue.length>0||r!==void 0);return s.jsxs("section",{className:"main",children:[s.jsxs("header",{className:"session-header",children:[s.jsxs("div",{className:"session-heading",children:[x?s.jsxs("div",{className:"breadcrumb agent-heading",children:[s.jsx("span",{className:`agent-avatar small agent-${g.id}`,children:s.jsx(Q,{name:g.icon})}),s.jsx("h1",{children:g.name})]}):s.jsxs("div",{className:"breadcrumb",children:[o!==void 0?s.jsx("button",{type:"button",className:"link-button breadcrumb-link",title:`回到「${g.name}」的对话`,onClick:()=>o(p),children:g.name}):s.jsx("span",{children:g.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx(ZR,{title:c.title,onRename:k=>e.renameSession(t.id,k)})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(DN,{running:c.running}),x?s.jsx("span",{children:g.description}):s.jsx("span",{children:"以前的对话"}),!x&&p!==Rs&&(d==null?void 0:d.requestedBy)!==void 0&&s.jsx("span",{children:aR(d.requestedBy)})]})]}),s.jsxs("div",{className:"session-actions",children:[s.jsx("nav",{className:"tabs",role:"tablist","aria-label":"会话视图",children:y.map(k=>s.jsx("button",{role:"tab","aria-selected":k.id===(w==null?void 0:w.id),className:k.id===(w==null?void 0:w.id)?"active":"",onClick:()=>N(k.id),children:k.title},k.id))}),w!==void 0&&s.jsx("button",{className:"icon-button popout-button",title:`在新窗口打开「${w.title}」`,"aria-label":`在新窗口打开「${w.title}」`,onClick:()=>window.open(bR(w.id,t.id),`dsh-${w.id}-${t.id}`),children:s.jsx(Q,{name:"popout"})})]})]}),c.error!==null&&s.jsx("div",{className:"banner error",children:c.error}),s.jsx("div",{className:"view",children:w===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可用的视图插件。"}):s.jsx(w.component,{client:e,session:t,state:c,readOnly:T})}),T?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(p),children:["回到「",g.name,"」的对话"]})]}):s.jsxs(s.Fragment,{children:[n,s.jsx(PR,{client:e,session:t,running:c.running,disabled:u.state!=="open",initialPrompt:r,onInitialSent:i})]})]})}function UR({client:e,viewId:t,sessionId:n}){const r=Ad(e,n),i=SN(e),o=je(e.connection.status),c=i.find(u=>u.id===t);return r===null||c===void 0?s.jsx("div",{className:"popped",children:s.jsx("section",{className:"main empty",children:o.state==="open"&&c===void 0?"当前连接没有提供这个视图。":"正在打开…"})}):s.jsx(HR,{client:e,session:r,view:c})}function HR({client:e,session:t,view:n}){const r=je(t.state),i=je(e.sessions).items.find(c=>c.id===t.id),o=LN(i,r.running||r.queue.length>0);return b.useEffect(()=>{document.title=`${n.title} · ${r.title??"会话"}`},[n.title,r.title]),s.jsx("div",{className:"popped",children:s.jsxs("section",{className:"main",children:[s.jsx("header",{className:"session-header",children:s.jsxs("div",{className:"session-heading",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:n.title}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:r.title??"新会话"})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx(DN,{running:r.running}),s.jsx("span",{children:"与主窗口同步更新"})]})]})}),r.error!==null&&s.jsx("div",{className:"banner error",children:r.error}),s.jsx("div",{className:"view",children:s.jsx(n.component,{client:e,session:t,state:r,readOnly:o})})]})})}function ZR({title:e,onRename:t}){const[n,r]=b.useState(null),[i,o]=b.useState(null),c=e??"新会话",u=async()=>{const h=(n==null?void 0:n.trim())??"";if(h===""||h===e){r(null);return}try{await t(h),r(null),o(null)}catch(d){o(d instanceof Error?d.message:String(d))}};return n!==null?s.jsxs("span",{className:"title-edit",children:[s.jsx("input",{className:"text-input",autoFocus:!0,value:n,maxLength:80,"aria-label":"会话名称",onChange:h=>r(h.target.value),onFocus:h=>h.target.select(),onKeyDown:h=>{h.key==="Enter"&&!h.nativeEvent.isComposing&&u(),h.key==="Escape"&&(r(null),o(null))},onBlur:()=>void u()}),i!==null&&s.jsx("span",{className:"error small",children:i})]}):s.jsxs("span",{className:"session-title",children:[s.jsx("h1",{title:"双击改名",onDoubleClick:()=>r(c),children:c}),s.jsx("button",{type:"button",className:"icon-button rename-button",title:"改名","aria-label":"给这个会话改名",onClick:()=>r(c),children:s.jsx(Q,{name:"pencil"})})]})}function DN({running:e}){return e?s.jsxs("span",{className:"status-pill running",children:[s.jsx("span",{className:"pill-dot"}),"运行中"]}):s.jsx("span",{className:"status-pill",children:"空闲"})}const FN="adg.sessionTab";function WR(){try{return localStorage.getItem(FN)??"chat"}catch{return"chat"}}function VR(e){try{localStorage.setItem(FN,e)}catch{}}const BN="adg.showEarlier",Xp=new Set;function qR(){try{return localStorage.getItem(BN)!=="0"}catch{return!0}}let UN=qR();function GR(e){UN=e;try{localStorage.setItem(BN,e?"1":"0")}catch{}for(const t of Xp)t()}function Bm(){return b.useSyncExternalStore(e=>(Xp.add(e),()=>{Xp.delete(e)}),()=>UN)}const HN="adg.theme",Qp=new Set;let Zl=KR();function KR(){try{const e=localStorage.getItem(HN);return e==="light"||e==="dark"?e:"system"}catch{return"system"}}function ZN(){var e,t;Zl==="system"?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=Zl,(t=(e=wr())==null?void 0:e.setTheme)==null||t.call(e,Zl).catch(()=>{})}function YR(e){Zl=e;try{localStorage.setItem(HN,e)}catch{}ZN();for(const t of Qp)t()}function WN(){return b.useSyncExternalStore(e=>(Qp.add(e),()=>Qp.delete(e)),()=>Zl)}const XR={"api-keys":"key",permissions:"shield",plugins:"plug","script-install":"package",emulators:"monitor",schedule:"calendar",feishu:"send",compaction:"compress",about:"info"},QR=[["light","浅色"],["dark","深色"],["system","跟随系统"]];function JR({client:e,onClose:t,section:n,onSection:r}){const i=WM(e),o=WN(),c=Bm(),[u,h]=b.useState(null),d=u??n??null,p=g=>{h(g),r==null||r(g)},m=i.find(g=>g.id===d)??i[0];return s.jsxs(s.Fragment,{children:[s.jsxs("aside",{className:"sidebar settings-sidebar",children:[s.jsxs("button",{className:"nav-item back-link",onClick:t,children:[s.jsx(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:"偏好设置"}),i.map(g=>s.jsxs("button",{className:`nav-item ${g.id===(m==null?void 0:m.id)?"active":""}`,"aria-current":g.id===(m==null?void 0:m.id)?"page":void 0,onClick:()=>p(g.id),children:[s.jsx(Q,{name:XR[g.id]??"settings"}),s.jsx("span",{className:"nav-item-label",children:g.title})]},g.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:QR.map(([g,x])=>s.jsx("button",{role:"radio","aria-checked":o===g,className:o===g?"active":"",onClick:()=>YR(g),children:x},g))}),s.jsxs("label",{className:"check-label settings-toggle",title:"关了之后不显示这个按钮;对话记录不会删除。没有以前的对话时,开着也不显示",children:[s.jsx("input",{type:"checkbox",checked:c,onChange:g=>GR(g.target.checked)}),"显示「以前的对话」"]})]})]}),s.jsx("section",{className:"main settings",children:s.jsx("div",{className:"settings-content",children:m===void 0?s.jsx("div",{className:"empty",children:"当前连接没有提供可配置的项目。"}):s.jsx(m.component,{client:e})})})]})}function Um(e){const t=je(e.connection.status),[n,r]=b.useState({data:null,error:null}),[i,o]=b.useState(0),c=b.useCallback(()=>o(u=>u+1),[]);return b.useEffect(()=>e.connection.on("scripts/changed",()=>c()),[e,c]),b.useEffect(()=>{if(t.state!=="open")return;let u=!0;return e.connection.call("scripts/list",{}).then(h=>{u&&r({data:h,error:null})}).catch(h=>{u&&r(d=>({...d,error:Re(h)}))}),()=>{u=!1}},[e,t.state,i]),{...n,refresh:c}}function eO(e){const t=je(e.connection.status),[n,r]=b.useState(new Map);return b.useEffect(()=>e.connection.on("scripts/job",i=>{r(o=>{const c=o.get(i.scriptId);return c!==void 0&&c.id!==i.id&&c.startedAt>i.startedAt?o:new Map(o).set(i.scriptId,i)})}),[e]),b.useEffect(()=>{if(t.state!=="open")return;let i=!0;return e.connection.call("scripts/jobs",{}).then(({items:o})=>{if(!i)return;const c=new Map;for(const u of[...o].sort((h,d)=>h.startedAt-d.startedAt))c.set(u.scriptId,u);r(c)}).catch(()=>{}),()=>{i=!1}},[e,t.state]),n}function Re(e){return e instanceof Error?e.message:String(e)}function ka(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 sd={queued:"排队中",resolving:"读取发布信息",downloading:"下载中",verifying:"校验中",extracting:"解压中",checking:"检查环境",running:"处理中",done:"完成",failed:"失败",cancelled:"已取消"},VN={"maafw-pi":"MaaFramework",cli:"命令行","gui-config":"配置驱动 GUI","generic-process":"通用程序",visual:"界面操作"};function ho(e){return e!==void 0&&e.endedAt===void 0}const qN=["日","一","二","三","四","五","六"],GN=[1,2,3,4,5,6,0];function Hm(e){return e.enabled?e.times.length===0?e.after===void 0?"没有设时间":`「${e.after}」跑完后`:`${e.days.length===0||e.days.length===7?"每天":`每周${GN.filter(n=>e.days.includes(n)).map(n=>qN[n]).join("、")}`} ${[...e.times].sort().join("、")}`:"已暂停"}function ko(e,t){if(!e.enabled)return;const n=new Date(t);n.setHours(0,0,0,0);for(let r=0;r<8;r++,n.setDate(n.getDate()+1)){if(e.days.length>0&&!e.days.includes(n.getDay()))continue;const i=e.times.map(o=>{const[c,u]=o.split(":").map(Number);return new Date(n.getFullYear(),n.getMonth(),n.getDate(),c,u).getTime()}).filter(o=>o>t).sort((o,c)=>o-c);if(i[0]!==void 0)return i[0]}}const pc=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"});function KN(e,t){const n=je(e.connection.status),[r,i]=b.useState(0),[o,c]=b.useState({items:null,error:null});return b.useEffect(()=>e.connection.on("tasks/changed",()=>i(u=>u+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let u=!0;return e.connection.call("tasks/list",t===void 0?{}:{agent:t}).then(h=>{u&&c({items:h.items,error:null})},h=>{u&&c(d=>({...d,error:Re(h)}))}),()=>{u=!1}},[e,t,n.state,r]),o}function YN(e,t){const n=je(e.connection.status),r=je(e.capabilities),[i,o]=b.useState(0),[c,u]=b.useState([]);return b.useEffect(()=>e.connection.on("reminders/changed",()=>o(h=>h+1)),[e]),b.useEffect(()=>{if(n.state!=="open"||!r.has("agents"))return;let h=!0;return e.connection.call("reminders/list",t===void 0?{}:{agent:t}).then(d=>{h&&u(d.items)}).catch(()=>{}),()=>{h=!1}},[e,t,n.state,r,i]),c}function XN(e){const t=je(e.connection.status),[n,r]=b.useState(0),[i,o]=b.useState([]);return b.useEffect(()=>e.connection.on("pipelines/changed",()=>r(c=>c+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let c=!0;return e.connection.call("pipelines/list",{}).then(u=>{c&&o(u.items)}).catch(()=>{}),()=>{c=!1}},[e,t.state,n]),i}function QN(e){const t=je(e.connection.status),n=je(e.capabilities),[r,i]=b.useState(null);return b.useEffect(()=>{if(t.state!=="open"||!n.has("games"))return;let o=!0;return e.connection.call("games/list",{}).then(c=>{o&&i({schedule:{enabled:c.settings.report.enabled,times:[c.settings.report.at],days:[],catchUpMinutes:0},next:c.report.next})}).catch(()=>{}),()=>{o=!1}},[e,t.state,n]),r}function JN({report:e,now:t}){const n=ko(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:[Hm(e.schedule),n===void 0?"":` · 下次 ${pc(n)}`," · 发到飞书"]}),s.jsx(Q,{name:"chevron"})]})}function ew(e){const t=Er(e);return b.useMemo(()=>[Rn,...t.map(Wo)],[t])}function tO({client:e,agentId:t}){const n=ew(e),r=n.find(x=>x.id===t)??Rn,{items:i,error:o}=KN(e,t),c=YN(e,t),u=XN(e),h=QN(e),d=Cn(3e4),[p,m]=b.useState(null),g=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:r.name}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"定时任务"})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button primary",onClick:()=>m("new"),disabled:p!==null,children:[s.jsx(Q,{name:"plus"}),"新建定时任务"]})})]}),s.jsxs("div",{className:"schedule-body",children:[s.jsxs("p",{className:"muted small",children:["到点把一段话交给",r.name,"去做,在它的对话里做。",t===Rs?"":"做完后,要紧的由助手告诉你。","要跑脚本的多步任务,用「编排」做成流水线。"]}),o!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:o})]}),p==="new"&&s.jsx(Jp,{client:e,agents:n,task:{agent:t},onDone:()=>m(null)}),t==="games"&&h!==null&&s.jsx(JN,{report:h,now:d}),i!==null&&i.length===0&&c.length===0&&p===null&&s.jsxs("div",{className:"empty-card muted",children:[r.name,"还没有定时任务。"]}),i==null?void 0:i.map(x=>p!=="new"&&(p==null?void 0:p.id)===x.id?s.jsx(Jp,{client:e,agents:n,task:x,onDone:()=>m(null)},x.id):s.jsx(sw,{client:e,task:x,now:d,onEdit:()=>m(x)},x.id)),c.length>0&&s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{children:[r.name,"在对话里设的提醒"]}),s.jsx("p",{className:"muted small",children:"你在对话里让它「几点提醒我…」时它自己设的。到点后它在对话里接着做,回复也会同步到飞书和 QQ。"}),c.map(x=>s.jsx(nw,{client:e,reminder:x,now:d},x.id))]}),t==="pipelines"&&s.jsxs("section",{className:"schedule-group",children:[s.jsx("h3",{children:"按时运行的流水线"}),g.length===0&&s.jsx("p",{className:"muted small",children:"没有开着定时的流水线。"}),g.map(x=>s.jsx(tw,{pipeline:x,now:d},x.id))]})]})]})}function nO({client:e,onAgent:t}){const n=ew(e),{items:r,error:i}=KN(e),o=YN(e),c=XN(e),u=QN(e),h=Cn(3e4),[d,p]=b.useState(!1),m=n.find(y=>y.id==="pipelines"),g=n.find(y=>y.id==="games"),x=b.useMemo(()=>[...u===null?[]:[{key:"daily-report",agent:g,title:"每日日报",at:ko(u.schedule,h)}],...(r??[]).map(y=>({key:y.id,agent:n.find(E=>E.id===y.agent),title:y.title,at:ko(y.schedule,h)})),...c.filter(y=>y.draft!==!0).map(y=>({key:y.id,agent:m,title:`流水线「${y.name}」`,at:ko(y.schedule,h)})),...o.map(y=>({key:y.id,agent:n.find(E=>E.id===y.agent),title:`提醒:${y.title}`,at:y.next}))].filter(y=>y.at!==void 0).sort((y,E)=>y.at-E.at).slice(0,8),[r,o,c,n,m,g,u,h]);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:()=>p(!0),disabled:d,children:[s.jsx(Q,{name:"plus"}),"新建定时任务"]})]})]}),s.jsxs("div",{className:"schedule-body",children:[i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:i})]}),d&&s.jsx(Jp,{client:e,agents:n,task:{agent:Rs},chooseAgent:!0,onDone:()=>p(!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(y=>{var E,N,w;return s.jsxs("li",{children:[s.jsx("span",{className:"schedule-when",children:pc(y.at)}),s.jsx("span",{className:`agent-avatar small agent-${((E=y.agent)==null?void 0:E.id)??"unknown"}`,children:s.jsx(Q,{name:((N=y.agent)==null?void 0:N.icon)??"sparkles"})}),s.jsx("span",{className:"schedule-who",children:((w=y.agent)==null?void 0:w.name)??"?"}),s.jsx("span",{className:"schedule-what",children:y.title})]},`${y.key}@${y.at}`)})})]}),n.map(y=>{const E=(r??[]).filter(k=>k.agent===y.id),N=o.filter(k=>k.agent===y.id),w=y.id==="pipelines"?c.filter(k=>k.schedule.enabled&&k.draft!==!0):[],T=y.id==="games"&&(u==null?void 0:u.schedule.enabled)===!0?u:null;return E.length===0&&N.length===0&&w.length===0&&T===null?null:s.jsxs("section",{className:"schedule-group",children:[s.jsxs("h3",{className:"schedule-agent",children:[s.jsx("span",{className:`agent-avatar small agent-${y.id}`,children:s.jsx(Q,{name:y.icon})}),y.name,s.jsx("span",{className:"tab-count",children:E.length+N.length+w.length+(T===null?0:1)}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button",onClick:()=>t(y.id),children:"管理"})]}),T!==null&&s.jsx(JN,{report:T,now:h}),E.map(k=>s.jsx(sw,{client:e,task:k,now:h},k.id)),N.map(k=>s.jsx(nw,{client:e,reminder:k,now:h},k.id)),w.map(k=>s.jsx(tw,{pipeline:k,now:h},k.id))]},y.id)})]})]})}function tw({pipeline:e,now:t}){const n=ko(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:[Hm(e.schedule),n===void 0?"":` · 下次 ${pc(n)}`]}),s.jsx(Q,{name:"chevron"})]})}function nw({client:e,reminder:t,now:n}){const[r,i]=b.useState(null),o=()=>{confirm(`删除提醒「${t.title}」?`)&&(i(null),e.connection.call("reminders/remove",{id:t.id}).catch(c=>i(Re(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?"下次 ":"",pc(t.next),t.next>n?`(${sO(t.next-n)}后)`:""]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"icon-button",onClick:o,title:"删除这个提醒","aria-label":"删除",children:s.jsx(Q,{name:"close"})})]}),s.jsx("div",{className:"task-prompt",children:t.prompt}),r!==null&&s.jsx("div",{className:"error small",children:r})]})}function sO(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 sw({client:e,task:t,now:n,onEdit:r}){const[i,o]=b.useState(null),c=ko(t.schedule,n),u=t.lastRun,h=p=>{o(null),e.connection.call(p,{id:t.id}).catch(m=>o(Re(m)))},d=()=>{o(null),e.connection.call("tasks/save",{task:{...t,schedule:{...t.schedule,enabled:!t.schedule.enabled}}}).catch(p=>o(Re(p)))};return s.jsxs("div",{className:`task-card ${t.schedule.enabled?"":"paused"}`,children:[s.jsxs("div",{className:"task-card-head",children:[s.jsx("span",{className:"task-title",children:t.title}),s.jsxs("span",{className:"muted small",children:[Hm(t.schedule),c===void 0?"":` · 下次 ${pc(c)}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>h("tasks/run"),disabled:(u==null?void 0:u.state)==="running",title:"现在就交给它做一次",children:(u==null?void 0:u.state)==="running"?"在做":"立即运行"}),s.jsx("button",{className:"small-button",onClick:d,children:t.schedule.enabled?"暂停":"开启"}),r!==void 0&&s.jsx("button",{className:"icon-button",onClick:r,title:"修改","aria-label":"修改",children:s.jsx(Q,{name:"pencil"})}),r!==void 0&&s.jsx("button",{className:"icon-button",onClick:()=>{confirm(`删除定时任务「${t.title}」?`)&&h("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"?"正在做":`${At(u.endedAt??u.startedAt,n)}${u.state==="done"?"做完":"没做成"}`,u.outcome===void 0?"":`:${u.outcome.split(`
131
+ `)[0]}`]})]}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}function Jp({client:e,agents:t,task:n,chooseAgent:r=!1,onDone:i}){var I,L;const[o,c]=b.useState(n.agent),[u,h]=b.useState(n.title??""),[d,p]=b.useState(n.prompt??""),[m,g]=b.useState((((I=n.schedule)==null?void 0:I.times)??["09:00"]).join(", ")),[x,y]=b.useState(((L=n.schedule)==null?void 0:L.days)??[]),[E,N]=b.useState(!1),[w,T]=b.useState(null),k=async()=>{var z,U;N(!0),T(null);try{const V=m.split(/[,,、\s]+/).filter($=>$!=="").map($=>/^\d:\d\d$/.test($)?`0${$}`:$);await e.connection.call("tasks/save",{task:{...n.id===void 0?{}:{id:n.id},agent:o,title:u,prompt:d,schedule:{enabled:((z=n.schedule)==null?void 0:z.enabled)??!0,times:V,days:[...x],catchUpMinutes:((U=n.schedule)==null?void 0:U.catchUpMinutes)??10}}}),i()}catch(V){T(Re(V))}finally{N(!1)}};return s.jsxs("div",{className:"task-card task-form",children:[r&&s.jsxs("label",{className:"field-label",children:["交给谁",s.jsx("select",{className:"text-input",value:o,onChange:z=>c(z.target.value),children:t.map(z=>s.jsx("option",{value:z.id,children:z.name},z.id))})]}),s.jsxs("label",{className:"field-label",children:["名字",s.jsx("input",{className:"text-input plain",value:u,maxLength:60,onChange:z=>h(z.target.value),placeholder:"例如:看今天结束的活动"})]}),s.jsxs("label",{className:"field-label",children:["交给它的话",s.jsx("textarea",{className:"text-input plain",rows:3,value:d,maxLength:4e3,onChange:z=>p(z.target.value),placeholder:"写完整:要做什么、要交回什么"})]}),s.jsxs("div",{className:"task-form-row",children:[s.jsxs("label",{className:"field-label",children:["时间",s.jsx("input",{className:"text-input plain-mono",value:m,onChange:z=>g(z.target.value),placeholder:"09:00, 21:30"})]}),s.jsxs("div",{className:"field-label",children:["星期",s.jsxs("div",{className:"day-chips",children:[GN.map(z=>s.jsx("button",{type:"button",className:`day-chip ${x.includes(z)?"on":""}`,"aria-pressed":x.includes(z),onClick:()=>y(x.includes(z)?x.filter(U=>U!==z):[...x,z]),children:qN[z]},z)),s.jsx("span",{className:"muted small",children:x.length===0?"不选就是每天":""})]})]})]}),w!==null&&s.jsx("div",{className:"error small",children:w}),s.jsxs("div",{className:"task-form-actions",children:[s.jsx("button",{className:"small-button",onClick:i,disabled:E,children:"取消"}),s.jsx("button",{className:"small-button primary",onClick:()=>void k(),disabled:E||u.trim()===""||d.trim()==="",children:"保存"})]})]})}/*! @license DOMPurify 3.4.17 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.17/LICENSE */function Q0(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function rO(e){if(Array.isArray(e))return e}function iO(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,c,u=[],h=!0,d=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(h=(r=o.call(n)).done)&&(u.push(r.value),u.length!==t);h=!0);}catch(p){d=!0,i=p}finally{try{if(!h&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(d)throw i}}return u}}function aO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
132
+ 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 oO(e,t){return rO(e)||iO(e,t)||lO(e,t)||aO()}function lO(e,t){if(e){if(typeof e=="string")return Q0(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)?Q0(e,t):void 0}}const rw=Object.entries,J0=Object.setPrototypeOf,cO=Object.isFrozen,iw=Object.getPrototypeOf,aw=Object.getOwnPropertyDescriptor;let On=Object.freeze,Fn=Object.seal,fo=Object.create,ow=typeof Reflect<"u"&&Reflect,em=ow.apply,tm=ow.construct;On||(On=function(t){return t});Fn||(Fn=function(t){return t});em||(em=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return t.apply(n,i)});tm||(tm=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new t(...r)});const ai=Gt(Array.prototype.forEach),uO=Gt(Array.prototype.lastIndexOf),ey=Gt(Array.prototype.pop),wl=Gt(Array.prototype.push),dO=Gt(Array.prototype.slice),hO=Gt(Array.prototype.splice),No=Array.isArray,Bf=lw(Set),Uf=Gt(Set.prototype.add),jl=Gt(Set.prototype.has),xa=Gt(String.prototype.toLowerCase),Hf=Gt(String.prototype.toString),ty=Gt(String.prototype.match),Sl=Gt(String.prototype.replace),ny=Gt(String.prototype.indexOf),fO=Gt(String.prototype.trim),pO=Gt(Number.prototype.toString),mO=Gt(Boolean.prototype.toString),sy=typeof BigInt>"u"?null:Gt(BigInt.prototype.toString),ry=typeof Symbol>"u"?null:Gt(Symbol.prototype.toString),ks=Gt(Object.prototype.hasOwnProperty),_l=Gt(Object.prototype.toString),Dn=Gt(RegExp.prototype.test),oi=lw(TypeError);function Gt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return em(e,t,r)}}function lw(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return tm(e,n)}}function Nt(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xa;if(J0&&J0(e,null),!No(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const o=n(i);o!==i&&(cO(t)||(t[r]=o),i=o)}e[i]=!0}return e}function gO(e){for(let t=0;t<e.length;t++)ks(e,t)||(e[t]=null);return e}function Ts(e){const t=fo(null);for(const r of rw(e)){var n=oO(r,2);const i=n[0],o=n[1];ks(e,i)&&(No(o)?t[i]=gO(o):o&&typeof o=="object"&&o.constructor===Object?t[i]=Ts(o):t[i]=o)}return t}function xO(e){switch(typeof e){case"string":return e;case"number":return pO(e);case"boolean":return mO(e);case"bigint":return sy?sy(e):"0";case"symbol":return ry?ry(e):"Symbol()";case"undefined":return _l(e);case"function":case"object":{if(e===null)return _l(e);const t=e,n=Xs(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:_l(r)}return _l(e)}default:return _l(e)}}function Xs(e,t){for(;e!==null;){const r=aw(e,t);if(r){if(r.get)return Gt(r.get);if(typeof r.value=="function")return Gt(r.value)}e=iw(e)}function n(){return null}return n}function vO(e,t){for(;e!==null;){const n=aw(e,t);if(n)return n.get?Gt(n.get):null;e=iw(e)}return null}function yO(e){try{return Dn(e,""),!0}catch{return!1}}const iy=On(["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"]),Zf=On(["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"]),Wf=On(["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"]),bO=On(["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"]),Vf=On(["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"]),kO=On(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ay=On(["#text"]),oy=On(["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"]),qf=On(["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"]),ly=On(["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"]),Su=On(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),NO=Fn(/{{[\w\W]*|^[\w\W]*}}/g),wO=Fn(/<%[\w\W]*|^[\w\W]*%>/g),jO=Fn(/\${[\w\W]*/g),SO=Fn(/^data-[\-\w.\u00B7-\uFFFF]+$/),_O=Fn(/^aria-[\-\w]+$/),cy=Fn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),EO=Fn(/^(?:\w+script|data):/i),CO=Fn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),AO=Fn(/^html$/i),IO=Fn(/^[a-z][.\w]*(-[.\w]+)+$/i),Gf=Fn(/<[/\w!]/g),uy=Fn(/<[/\w]/g),TO=Fn(/<\/no(script|embed|frames)/i),dy=Fn(/\/>/i),xn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},$O=On(Nt({},["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"])),MO=function(){return typeof window>"u"?null:window},RO=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML(c){return c},createScriptURL(c){return c}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},hy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Oi=function(t,n,r,i){return ks(t,n)&&No(t[n])?Nt(i.base?Ts(i.base):{},t[n],i.transform):r},Kf=function(t,n,r){const i=ks(t,n)?t[n]:void 0;return i&&typeof i=="object"?Ts(i):r()};function cw(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:MO();const t=we=>cw(we);if(t.version="3.4.17",t.removed=[],!e||!e.document||e.document.nodeType!==xn.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,i=r.currentScript;e.DocumentFragment;const o=e.HTMLTemplateElement,c=e.Node,u=e.Element,h=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const d=e.DOMParser,p=e.trustedTypes,m=u.prototype,g=Xs(m,"cloneNode"),x=Xs(m,"remove"),y=Xs(m,"removeAttributeNode"),E=Xs(m,"nextSibling"),N=Xs(m,"childNodes"),w=Xs(m,"parentNode"),T=Xs(m,"shadowRoot"),k=Xs(m,"attributes"),I=c&&c.prototype?Xs(c.prototype,"nodeType"):null,L=c&&c.prototype?Xs(c.prototype,"nodeName"):null,z=c&&c.prototype?Xs(c.prototype,"ownerDocument"):null,U=function(G){return I?I(G):G.nodeType},V=function(G){return L?L(G):G.nodeName},$=vO(m,"namespaceURI"),P=function(G){return $?$(G):G.namespaceURI};if(typeof o=="function"){const we=n.createElement("template");we.content&&we.content.ownerDocument&&(n=we.content.ownerDocument)}let D,B="",_,C=!1,R=0;const M=function(){if(R>0)throw oi('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.')},F=function(G){M(),R++;try{return D.createHTML(G)}finally{R--}},H=function(G){M(),R++;try{return D.createScriptURL(G)}finally{R--}},W=function(){return C||(_=RO(p,i),C=!0),_},K=n,q=K.implementation,Y=K.createNodeIterator,fe=K.createDocumentFragment,me=K.getElementsByTagName,xe=r.importNode;let oe=hy();t.isSupported=typeof rw=="function"&&typeof w=="function"&&q&&q.createHTMLDocument!==void 0;const re=NO,ie=wO,ye=jO,De=SO,de=_O,Se=EO,ae=CO,pe=IO;let Le=cy,Te=null;const Ge=Nt({},[...iy,...Zf,...Wf,...Vf,...ay]);let Ae=null;const tt=Nt({},[...oy,...qf,...ly,...Su]);let et=Object.seal(fo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),jt=null,zn=null;const sn=Object.seal(fo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ln=!0,cn=!0,rn=!1,an=!0,Ft=!1,Un=!0,Nn=!1,js=!1,Ir=null,er=null,tr=!1,Ps=!1,Ls=!1,Ds=!1,Fs=!0,nr=!1;const sr="user-content-";let as=!0,Xn=!1,wn=null,J={},ge=null;const ze=Nt({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let st=null;const It=Nt({},["audio","video","img","source","image","track"]);let $t=null;const Be=Nt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Fe="http://www.w3.org/1998/Math/MathML",Xe="http://www.w3.org/2000/svg",bt="http://www.w3.org/1999/xhtml";let yt=bt,Hn=!1,os=null;const rr=Nt({},[Fe,Xe,bt],Hf),mi=On(["mi","mo","mn","ms","mtext"]);let ir=Nt({},mi);const gi=On(["annotation-xml"]);let Zn=Nt({},gi);const Wr=Nt({},["title","style","font","a","script"]);let ls=null;const Tr=["application/xhtml+xml","text/html"],xi="text/html";let Rt=null,Ss=null;const Qn=n.createElement("form"),Vr=function(G){return G instanceof RegExp||G instanceof Function},ar=function(){let G=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ss&&Ss===G)return;(!G||typeof G!="object")&&(G={}),G=Ts(G),ls=Tr.indexOf(G.PARSER_MEDIA_TYPE)===-1?xi:G.PARSER_MEDIA_TYPE,Rt=ls==="application/xhtml+xml"?Hf:xa,Te=Oi(G,"ALLOWED_TAGS",Ge,{transform:Rt}),Ae=Oi(G,"ALLOWED_ATTR",tt,{transform:Rt}),os=Oi(G,"ALLOWED_NAMESPACES",rr,{transform:Hf}),$t=Oi(G,"ADD_URI_SAFE_ATTR",Be,{transform:Rt,base:Be}),st=Oi(G,"ADD_DATA_URI_TAGS",It,{transform:Rt,base:It}),ge=Oi(G,"FORBID_CONTENTS",ze,{transform:Rt}),jt=Oi(G,"FORBID_TAGS",Ts({}),{transform:Rt}),zn=Oi(G,"FORBID_ATTR",Ts({}),{transform:Rt}),J=ks(G,"USE_PROFILES")?G.USE_PROFILES&&typeof G.USE_PROFILES=="object"?Ts(G.USE_PROFILES):G.USE_PROFILES:!1,ln=G.ALLOW_ARIA_ATTR!==!1,cn=G.ALLOW_DATA_ATTR!==!1,rn=G.ALLOW_UNKNOWN_PROTOCOLS||!1,an=G.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ft=G.SAFE_FOR_TEMPLATES||!1,Un=G.SAFE_FOR_XML!==!1,Nn=G.WHOLE_DOCUMENT||!1,Ps=G.RETURN_DOM||!1,Ls=G.RETURN_DOM_FRAGMENT||!1,Ds=G.RETURN_TRUSTED_TYPE||!1,tr=G.FORCE_BODY||!1,Fs=G.SANITIZE_DOM!==!1,nr=G.SANITIZE_NAMED_PROPS||!1,as=G.KEEP_CONTENT!==!1,Xn=G.IN_PLACE||!1,Le=yO(G.ALLOWED_URI_REGEXP)?G.ALLOWED_URI_REGEXP:cy,yt=typeof G.NAMESPACE=="string"?G.NAMESPACE:bt,ir=Kf(G,"MATHML_TEXT_INTEGRATION_POINTS",()=>Nt({},mi)),Zn=Kf(G,"HTML_INTEGRATION_POINTS",()=>Nt({},gi));const ne=Kf(G,"CUSTOM_ELEMENT_HANDLING",()=>fo(null));if(et=fo(null),ks(ne,"tagNameCheck")&&Vr(ne.tagNameCheck)&&(et.tagNameCheck=ne.tagNameCheck),ks(ne,"attributeNameCheck")&&Vr(ne.attributeNameCheck)&&(et.attributeNameCheck=ne.attributeNameCheck),ks(ne,"allowCustomizedBuiltInElements")&&typeof ne.allowCustomizedBuiltInElements=="boolean"&&(et.allowCustomizedBuiltInElements=ne.allowCustomizedBuiltInElements),Fn(et),Ft&&(cn=!1),Ls&&(Ps=!0),J&&(Te=Nt({},ay),Ae=fo(null),J.html===!0&&(Nt(Te,iy),Nt(Ae,oy)),J.svg===!0&&(Nt(Te,Zf),Nt(Ae,qf),Nt(Ae,Su)),J.svgFilters===!0&&(Nt(Te,Wf),Nt(Ae,qf),Nt(Ae,Su)),J.mathMl===!0&&(Nt(Te,Vf),Nt(Ae,ly),Nt(Ae,Su))),sn.tagCheck=null,sn.attributeCheck=null,ks(G,"ADD_TAGS")&&(typeof G.ADD_TAGS=="function"?sn.tagCheck=G.ADD_TAGS:No(G.ADD_TAGS)&&(Te===Ge&&(Te=Ts(Te)),Nt(Te,G.ADD_TAGS,Rt))),ks(G,"ADD_ATTR")&&(typeof G.ADD_ATTR=="function"?sn.attributeCheck=G.ADD_ATTR:No(G.ADD_ATTR)&&(Ae===tt&&(Ae=Ts(Ae)),Nt(Ae,G.ADD_ATTR,Rt))),ks(G,"ADD_FORBID_CONTENTS")&&No(G.ADD_FORBID_CONTENTS)&&(ge===ze&&(ge=Ts(ge)),Nt(ge,G.ADD_FORBID_CONTENTS,Rt)),as&&(Te["#text"]=!0),Nn&&Nt(Te,["html","head","body"]),Te.table&&(Nt(Te,["tbody"]),delete jt.tbody),G.TRUSTED_TYPES_POLICY){if(typeof G.TRUSTED_TYPES_POLICY.createHTML!="function")throw oi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof G.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw oi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const be=D;D=G.TRUSTED_TYPES_POLICY;try{B=F("")}catch(ke){throw D=be,ke}}else G.TRUSTED_TYPES_POLICY===null?(D=void 0,B=""):(D===void 0&&(D=W()),D&&typeof B=="string"&&(B=F("")));On&&On(G),Ss=G},Ot=Nt({},[...Zf,...Wf,...bO]),vi=Nt({},[...Vf,...kO]),qr=function(G,ne,be){return ne.namespaceURI===bt?G==="svg":ne.namespaceURI===Fe?G==="svg"&&(be==="annotation-xml"||ir[be]):!!Ot[G]},or=function(G,ne,be){return ne.namespaceURI===bt?G==="math":ne.namespaceURI===Xe?G==="math"&&Zn[be]:!!vi[G]},$r=function(G,ne,be){return ne.namespaceURI===Xe&&!Zn[be]||ne.namespaceURI===Fe&&!ir[be]?!1:!vi[G]&&(Wr[G]||!Ot[G])},Ie=function(G){const ne=P(G),be=xa(V(G)),ke=w(G);let qe,nt;return ke&&U(ke)===xn.element?(qe={namespaceURI:P(ke)},nt=xa(V(ke))):(qe={namespaceURI:yt},nt="template"),os[ne]?ne===Xe?qr(be,qe,nt):ne===Fe?or(be,qe,nt):ne===bt?$r(be,qe,nt):!!(ls==="application/xhtml+xml"&&os[ne]):!1},Ze=function(G){wl(t.removed,{element:G});try{w(G).removeChild(G)}catch{if(x(G),!w(G))throw oi("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},ct=function(G,ne,be){try{y(G,ne)}catch{try{G.removeAttribute(be)}catch{}}},ht=function(G){Bs(G);const ne=N(G);ne&&ai(dO(ne),ke=>{try{x(ke)}catch{}});const be=U(G)===xn.element?k(G):null;if(be)for(let ke=be.length-1;ke>=0;--ke){const qe=be[ke],nt=qe&&qe.name;typeof nt=="string"&&ct(G,qe,nt)}},Tt=function(G,ne,be){if(!be)try{be=ne.getAttributeNode(G)}catch{be=null}wl(t.removed,{attribute:be||null,from:ne});try{be?y(ne,be):ne.removeAttribute(G)}catch{try{ne.removeAttribute(G)}catch{}}if(G==="is")if(Ps||Ls)try{Ze(ne)}catch{}else try{ne.setAttribute(G,"")}catch{}},zt=function(G){const ne=k(G);if(ne)for(let be=ne.length-1;be>=0;--be){const ke=ne[be],qe=ke&&ke.name;typeof qe!="string"||Ae[Rt(qe)]||ct(G,ke,qe)}},Wn=function(G,ne){let be=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const ke=[G];for(;ke.length>0;){const qe=ke.pop();if(ne(qe)===!1)continue;if(be&&U(qe)===xn.element){const pt=T(qe);ds(pt)&&ke.push(pt)}const nt=N(qe);if(nt)for(let pt=nt.length-1;pt>=0;--pt)ke.push(nt[pt])}},Bs=function(G){Wn(G,ne=>{U(ne)===xn.element&&zt(ne)})},un=function(G){const ne=[];return Wn(G,be=>{ne.push(be)},!0),ne},jn=function(G,ne){const be=Bf();ai(un(G),ke=>{U(ke)===xn.element&&Uf(be,ke)}),ai(ne,ke=>{U(ke)===xn.element&&!jl(be,ke)&&zt(ke)})},Us=function(G,ne){let be=!1;return ai(t.removed,ke=>{ke.element&&(be=be||ke.element===G,Bs(ke.element))}),jn(G,ne),be},Hs=8,cs=function(G,ne){const be=wn;let ke=null;const qe=()=>(ke||(ke=Bf(),ai(ne,nt=>{Uf(ke,nt)})),ke);for(let nt=0;;nt++){const pt=un(G),dn=[G];let hs=!1;if(ai(pt,mn=>{U(mn)===xn.documentFragment?wl(dn,mn):!hs&&!jl(be,mn)&&(hs=jl(qe(),mn))}),!hs)return;if(nt>=Hs)throw oi("the tree kept changing during in-place sanitization; refusing to return it");ai(dn,(mn,An)=>{ta(mn,An>0,G,qe())})}},ta=function(G,ne,be,ke){const qe=us(G);let nt;for(;nt=qe.nextNode();)!jl(ke,nt)||jl(wn,nt)||(ne&&ft(oe.uponSanitizeShadowNode,nt,null),Ue(nt,be),Yr(nt,be),ds(nt.content)&&sa(nt.content))},yi=function(G){wn&&Uf(wn,G)},Mr=function(G,ne){return Un?G==="patchsrc"?!0:G==="for"&&ne!=="label"&&ne!=="output":!1},bi=function(G){Un&&Wn(G,ne=>{const be=U(ne);if(be===xn.processingInstruction||be===xn.comment&&Dn(uy,ne.data)){try{x(ne)}catch{}return!1}if(be===xn.element){const ke=ne,qe=Rt(V(ne));try{ke.hasAttribute&&ke.hasAttribute("patchsrc")&&ke.removeAttribute("patchsrc"),ke.hasAttribute&&ke.hasAttribute("for")&&Mr("for",qe)&&ke.removeAttribute("for")}catch{}}return!0})},Jn=function(G){let ne=null,be=null;if(tr)G="<remove></remove>"+G;else{const nt=ty(G,/^[\r\n\t ]+/);be=nt&&nt[0]}ls==="application/xhtml+xml"&&yt===bt&&(G='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+G+"</body></html>");const ke=D?F(G):G;if(yt===bt)try{ne=new d().parseFromString(ke,ls)}catch{}if(!ne||!ne.documentElement){ne=q.createDocument(yt,"template",null);try{ne.documentElement.innerHTML=Hn?B:ke}catch{}}const qe=ne.body||ne.documentElement;return G&&be&&qe.insertBefore(n.createTextNode(be),qe.childNodes[0]||null),yt===bt?me.call(ne,Nn?"html":"body")[0]:Nn?ne.documentElement:qe},us=function(G){const ne=z?z(G):G.ownerDocument;return Y.call(ne||G,G,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},Sn=function(G){return G=Sl(G,re," "),G=Sl(G,ie," "),G=Sl(G,ye," "),G},Zs=function(G){var ne;vt(G);const be=(ne=G.querySelectorAll)===null||ne===void 0?void 0:ne.call(G,"template");be&&ai(be,ke=>{ds(ke.content)&&Zs(ke.content)})},vt=function(G){G.normalize();const ne=z?z(G):G.ownerDocument,be=Y.call(ne||G,G,h.SHOW_TEXT|h.SHOW_COMMENT|h.SHOW_CDATA_SECTION|h.SHOW_PROCESSING_INSTRUCTION,null);let ke=be.nextNode();for(;ke;)ke.data=Sn(ke.data),ke=be.nextNode()},at=function(G){const ne=L?L(G):null;return typeof ne!="string"||Rt(ne)!=="form"?!1:typeof G.nodeName!="string"||typeof G.textContent!="string"||typeof G.removeChild!="function"||G.attributes!==k(G)||typeof G.removeAttribute!="function"||typeof G.removeAttributeNode!="function"||typeof G.getAttributeNode!="function"||typeof G.setAttribute!="function"||typeof G.namespaceURI!="string"||typeof G.insertBefore!="function"||typeof G.hasChildNodes!="function"||G.nodeType!==I(G)||G.childNodes!==N(G)},ds=function(G){if(!I||typeof G!="object"||G===null)return!1;try{return I(G)===xn.documentFragment}catch{return!1}},Pt=function(G){if(!I||typeof G!="object"||G===null)return!1;try{return typeof I(G)=="number"}catch{return!1}};function ft(we,G,ne){we.length!==0&&ai(we,be=>{be.call(t,G,ne,Ss)})}const Gr=function(G,ne){return!!(Un&&G.hasChildNodes()&&!Pt(G.firstElementChild)&&Dn(Gf,G.textContent)&&Dn(Gf,G.innerHTML)||Un&&$O[ne]&&U(G)===xn.element&&P(G)===bt&&(Pt(G.firstElementChild)||typeof G.textContent=="string"&&Dn(Gf,G.textContent))||G.nodeType===xn.processingInstruction||Un&&G.nodeType===xn.comment&&Dn(uy,G.data))},es=function(G,ne){if(G instanceof RegExp)return Dn(G,ne);if(G instanceof Function){for(var be=arguments.length,ke=new Array(be>2?be-2:0),qe=2;qe<be;qe++)ke[qe-2]=arguments[qe];return!!G(ne,...ke)}return!1},Kr=function(G,ne,be){if(!jt[ne]&&Bt(ne)&&es(et.tagNameCheck,ne))return!1;if(as&&!ge[ne]&&!ge[xa(ne)]){const ke=w(G),qe=N(G);if(qe&&ke){const nt=qe.length;for(let pt=nt-1;pt>=0;--pt){const dn=G===be?g(qe[pt],!0):qe[pt];ke.insertBefore(dn,E(G))}}}return Ze(G),!0},lr=function(G,ne,be,ke){return G.length===0?ne:ne===be||ne===ke?Ts(ne):ne},$e=function(G,ne){return G===ne||w(G)!==null?!1:(Xn&&Bs(G),!0)},Ue=function(G,ne){if(yi(G),ft(oe.beforeSanitizeElements,G,null),$e(G,ne))return!0;if(at(G))return Ze(G),!0;const be=Rt(V(G));if(Te=lr(oe.uponSanitizeElement,Te,Ge,Ir),ft(oe.uponSanitizeElement,G,{tagName:be,allowedTags:Te}),$e(G,ne))return!0;if(Gr(G,be))return Ze(G),!0;if(jt[be]||!(sn.tagCheck instanceof Function&&sn.tagCheck(be))&&!Te[be]){const ke=Kr(G,be,ne);return ke===!1&&(ft(oe.afterSanitizeElements,G,null),$e(G,ne))?!0:ke}if(U(G)===xn.element&&!Ie(G)||(be==="noscript"||be==="noembed"||be==="noframes")&&Dn(TO,G.innerHTML))return Ze(G),!0;if(Ft&&G.nodeType===xn.text){const ke=Sn(G.textContent);G.textContent!==ke&&(wl(t.removed,{element:G.cloneNode()}),G.textContent=ke)}return ft(oe.afterSanitizeElements,G,null),$e(G,ne)},ot=function(G,ne,be){if(zn[ne]||Mr(ne,G)||Fs&&(ne==="id"||ne==="name")&&(be in n||be in Qn))return!1;const ke=Ae[ne]||sn.attributeCheck instanceof Function&&sn.attributeCheck(ne,G);return cn&&Dn(De,ne)||ln&&Dn(de,ne)?!0:ke?$t[ne]||Dn(Le,Sl(be,ae,""))||(ne==="src"||ne==="xlink:href"||ne==="href")&&G!=="script"&&ny(be,"data:")===0&&st[G]||rn&&!Dn(Se,Sl(be,ae,""))?!0:!be:Bt(G)&&es(et.tagNameCheck,G)&&es(et.attributeNameCheck,ne,G)||ne==="is"&&et.allowCustomizedBuiltInElements&&es(et.tagNameCheck,be)},gt=Nt({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Bt=function(G){return!gt[xa(G)]&&Dn(pe,G)},pn=function(G,ne,be,ke){if(D&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!be)switch(p.getAttributeType(G,ne)){case"TrustedHTML":return F(ke);case"TrustedScriptURL":return H(ke)}return ke},qo=function(G,ne,be,ke){try{return be?G.setAttributeNS(be,ne,ke):G.setAttribute(ne,ke),at(G)?(Ze(G),!1):!0}catch{return Tt(ne,G),!1}},na=function(G,ne){return Un&&Dn(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ne)?!0:xa(G)==="attributename"&&ty(ne,"href")!==null},Yr=function(G,ne){if(ft(oe.beforeSanitizeAttributes,G,null),$e(G,ne))return;const be=G.attributes;if(!be||at(G))return;Ae=lr(oe.uponSanitizeAttribute,Ae,tt,er);const ke={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ae,forceKeepAttr:void 0};let qe=be.length;const nt=Rt(G.nodeName);for(;qe--;){const pt=be[qe],dn=pt.name,hs=pt.namespaceURI,mn=pt.value,An=Rt(dn),Xr=mn;let Qt=dn==="value"?Xr:fO(Xr),Fa=!1;if(ke.attrName=An,ke.attrValue=Qt,ke.keepAttr=!0,ke.forceKeepAttr=void 0,ft(oe.uponSanitizeAttribute,G,ke),Qt=ke.attrValue,nr&&(An==="id"||An==="name")&&ny(Qt,sr)!==0&&(Tt(dn,G,pt),Qt=sr+Qt,Fa=!0),na(dn,Qt)){Tt(dn,G,pt);continue}if(!ke.forceKeepAttr){if(!ke.keepAttr){Tt(dn,G,pt);continue}if(!an&&Dn(dy,Qt)){Tt(dn,G,pt);continue}if(Ft&&(Qt=Sn(Qt)),!ot(nt,An,Qt)){Tt(dn,G,pt);continue}Qt=pn(nt,An,hs,Qt),Qt!==Xr&&qo(G,dn,hs,Qt)&&Fa&&ey(t.removed)}}ft(oe.afterSanitizeAttributes,G,null),$e(G,ne)},sa=function(G){let ne=null;const be=us(G);for(ft(oe.beforeSanitizeShadowDOM,G,null);ne=be.nextNode();)if(ft(oe.uponSanitizeShadowNode,ne,null),Ue(ne,G),Yr(ne,G),ds(ne.content)&&sa(ne.content),U(ne)===xn.element){const ke=T(ne);ds(ke)&&(Da(ke),sa(ke))}Ft&&vt(G),ft(oe.afterSanitizeShadowDOM,G,null)},Da=function(G){const ne=[{node:G,shadow:null}];for(;ne.length>0;){const be=ne.pop();if(be.shadow){sa(be.shadow);continue}const ke=be.node,qe=U(ke)===xn.element,nt=N(ke);if(nt)for(let pt=nt.length-1;pt>=0;--pt)ne.push({node:nt[pt],shadow:null});if(qe){const pt=L?L(ke):null;if(typeof pt=="string"&&Rt(pt)==="template"){const dn=ke.content;ds(dn)&&ne.push({node:dn,shadow:null})}}if(qe){const pt=T(ke);ds(pt)&&ne.push({node:null,shadow:pt},{node:pt,shadow:null})}}};return t.sanitize=function(we){let G=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ne=null,be=null,ke=null,qe=null;if(Hn=!we,Hn&&(we="<!-->"),typeof we!="string"&&!Pt(we)&&(we=xO(we),typeof we!="string"))throw oi("dirty is not a string, aborting");if(!t.isSupported)return we;js?(Te=Ir,Ae=er):ar(G),(oe.uponSanitizeElement.length>0||oe.uponSanitizeAttribute.length>0)&&(Te=Ts(Te)),oe.uponSanitizeAttribute.length>0&&(Ae=Ts(Ae)),t.removed=[];const nt=Xn&&typeof we!="string"&&Pt(we);let pt=[];const dn=wn;if(nt){bi(we);const An=V(we);if(typeof An=="string"){const Xr=Rt(An);if(!Te[Xr]||jt[Xr])throw ht(we),oi("root node is forbidden and cannot be sanitized in-place")}if(at(we))throw ht(we),oi("root node is clobbered and cannot be sanitized in-place");pt=un(we),wn=Bf()}else if(Pt(we))ne=Jn("<!---->"),be=ne.ownerDocument.importNode(we,!0),be.nodeType===xn.element&&be.nodeName==="BODY"||be.nodeName==="HTML"?ne=be:ne.appendChild(be),Da(ne);else{if(!Ps&&!Ft&&!Nn&&we.indexOf("<")===-1)return D&&Ds?F(we):we;if(ne=Jn(we),!ne)return Ps?null:Ds?B:""}ne&&tr&&Ze(ne.firstChild);const hs=nt?we:ne;try{nt&&Da(we);const An=us(hs);for(;ke=An.nextNode();)Ue(ke,hs),Yr(ke,hs),ds(ke.content)&&sa(ke.content);nt&&cs(we,pt)}catch(An){throw nt&&(ht(we),Us(we,pt)),An}finally{wn=dn}if(nt){if(Us(we,pt))throw oi("a node selected for removal could not be safely returned; refusing to sanitize in place");return Ft&&Zs(we),we}if(Ps){if(Ft&&Zs(ne),Ls)for(qe=fe.call(ne.ownerDocument);ne.firstChild;)qe.appendChild(ne.firstChild);else qe=ne;return(Ae.shadowroot||Ae.shadowrootmode)&&(qe=xe.call(r,qe,!0)),qe}let mn=Nn?ne.outerHTML:ne.innerHTML;return Nn&&Te["!doctype"]&&ne.ownerDocument&&ne.ownerDocument.doctype&&ne.ownerDocument.doctype.name&&Dn(AO,ne.ownerDocument.doctype.name)&&(mn="<!DOCTYPE "+ne.ownerDocument.doctype.name+`>
133
+ `+mn),Ft&&(mn=Sn(mn)),D&&Ds?F(mn):mn},t.setConfig=function(){let we=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ar(we),js=!0,Ir=Te,er=Ae},t.clearConfig=function(){Ss=null,js=!1,Ir=null,er=null,D=_,B=""},t.isValidAttribute=function(we,G,ne){Ss||ar({});const be=Rt(we),ke=Rt(G);return typeof ne=="string"&&(na(G,ne)||!an&&Dn(dy,ne))?!1:ot(be,ke,ne)},t.addHook=function(we,G){typeof G=="function"&&ks(oe,we)&&wl(oe[we],G)},t.removeHook=function(we,G){if(ks(oe,we)){if(G!==void 0){const ne=uO(oe[we],G);return ne===-1?void 0:hO(oe[we],ne,1)[0]}return ey(oe[we])}},t.removeHooks=function(we){ks(oe,we)&&(oe[we]=[])},t.removeAllHooks=function(){oe=hy()},t}var Zm=cw();function Wm(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var La=Wm();function uw(e){La=e}var Wl={exec:()=>null};function _t(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(i,o)=>{let c=typeof o=="string"?o:o.source;return c=c.replace(is.caret,"$1"),n=n.replace(i,c),r},getRegex:()=>new RegExp(n,t)};return r}var OO=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),is={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")},zO=/^(?:[ \t]*(?:\n|$))+/,PO=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,LO=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,mc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,DO=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Vm=/(?:[*+-]|\d{1,9}[.)])/,dw=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,hw=_t(dw).replace(/bull/g,Vm).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(),FO=_t(dw).replace(/bull/g,Vm).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(),qm=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,BO=/^[^\n]+/,Gm=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,UO=_t(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Gm).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),HO=_t(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,Vm).getRegex(),Td="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",Km=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ZO=_t("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",Km).replace("tag",Td).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),fw=_t(qm).replace("hr",mc).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",Td).getRegex(),WO=_t(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",fw).getRegex(),Ym={blockquote:WO,code:PO,def:UO,fences:LO,heading:DO,hr:mc,html:ZO,lheading:hw,list:HO,newline:zO,paragraph:fw,table:Wl,text:BO},fy=_t("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",mc).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",Td).getRegex(),VO={...Ym,lheading:FO,table:fy,paragraph:_t(qm).replace("hr",mc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",fy).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",Td).getRegex()},qO={...Ym,html:_t(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Km).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:Wl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:_t(qm).replace("hr",mc).replace("heading",` *#{1,6} *[^
134
+ ]`).replace("lheading",hw).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},GO=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,KO=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,pw=/^( {2,}|\\)\n(?!\s*$)/,YO=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,$d=/[\p{P}\p{S}]/u,Xm=/[\s\p{P}\p{S}]/u,mw=/[^\s\p{P}\p{S}]/u,XO=_t(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Xm).getRegex(),gw=/(?!~)[\p{P}\p{S}]/u,QO=/(?!~)[\s\p{P}\p{S}]/u,JO=/(?:[^\s\p{P}\p{S}]|~)/u,e2=_t(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",OO?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),xw=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,t2=_t(xw,"u").replace(/punct/g,$d).getRegex(),n2=_t(xw,"u").replace(/punct/g,gw).getRegex(),vw="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",s2=_t(vw,"gu").replace(/notPunctSpace/g,mw).replace(/punctSpace/g,Xm).replace(/punct/g,$d).getRegex(),r2=_t(vw,"gu").replace(/notPunctSpace/g,JO).replace(/punctSpace/g,QO).replace(/punct/g,gw).getRegex(),i2=_t("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,mw).replace(/punctSpace/g,Xm).replace(/punct/g,$d).getRegex(),a2=_t(/\\(punct)/,"gu").replace(/punct/g,$d).getRegex(),o2=_t(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),l2=_t(Km).replace("(?:-->|$)","-->").getRegex(),c2=_t("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",l2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),rd=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,u2=_t(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",rd).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),yw=_t(/^!?\[(label)\]\[(ref)\]/).replace("label",rd).replace("ref",Gm).getRegex(),bw=_t(/^!?\[(ref)\](?:\[\])?/).replace("ref",Gm).getRegex(),d2=_t("reflink|nolink(?!\\()","g").replace("reflink",yw).replace("nolink",bw).getRegex(),py=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qm={_backpedal:Wl,anyPunctuation:a2,autolink:o2,blockSkip:e2,br:pw,code:KO,del:Wl,emStrongLDelim:t2,emStrongRDelimAst:s2,emStrongRDelimUnd:i2,escape:GO,link:u2,nolink:bw,punctuation:XO,reflink:yw,reflinkSearch:d2,tag:c2,text:YO,url:Wl},h2={...Qm,link:_t(/^!?\[(label)\]\((.*?)\)/).replace("label",rd).getRegex(),reflink:_t(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",rd).getRegex()},nm={...Qm,emStrongRDelimAst:r2,emStrongLDelim:n2,url:_t(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",py).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:_t(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",py).getRegex()},f2={...nm,br:_t(pw).replace("{2,}","*").getRegex(),text:_t(nm.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},_u={normal:Ym,gfm:VO,pedantic:qO},El={normal:Qm,gfm:nm,breaks:f2,pedantic:h2},p2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},my=e=>p2[e];function Dr(e,t){if(t){if(is.escapeTest.test(e))return e.replace(is.escapeReplace,my)}else if(is.escapeTestNoEncode.test(e))return e.replace(is.escapeReplaceNoEncode,my);return e}function gy(e){try{e=encodeURI(e).replace(is.percentDecode,"%")}catch{return null}return e}function xy(e,t){var o;let n=e.replace(is.findPipe,(c,u,h)=>{let d=!1,p=u;for(;--p>=0&&h[p]==="\\";)d=!d;return d?"|":" |"}),r=n.split(is.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!((o=r.at(-1))!=null&&o.trim())&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(is.slashPipe,"|");return r}function Cl(e,t,n){let r=e.length;if(r===0)return"";let i=0;for(;i<r&&e.charAt(r-i-1)===t;)i++;return e.slice(0,r-i)}function m2(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function vy(e,t,n,r,i){let o=t.href,c=t.title||null,u=e[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let h={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:c,text:u,tokens:r.inlineTokens(u)};return r.state.inLink=!1,h}function g2(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
135
+ `).map(o=>{let c=o.match(n.other.beginningSpace);if(c===null)return o;let[u]=c;return u.length>=i.length?o.slice(i.length):o}).join(`
136
+ `)}var id=class{constructor(e){ut(this,"options");ut(this,"rules");ut(this,"lexer");this.options=e||La}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:Cl(n,`
137
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=g2(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=Cl(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:Cl(t[0],`
138
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=Cl(t[0],`
139
+ `).split(`
140
+ `),r="",i="",o=[];for(;n.length>0;){let c=!1,u=[],h;for(h=0;h<n.length;h++)if(this.rules.other.blockquoteStart.test(n[h]))u.push(n[h]),c=!0;else if(!c)u.push(n[h]);else break;n=n.slice(h);let d=u.join(`
141
+ `),p=d.replace(this.rules.other.blockquoteSetextReplace,`
142
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
143
+ ${d}`:d,i=i?`${i}
144
+ ${p}`:p;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(p,o,!0),this.lexer.state.top=m,n.length===0)break;let g=o.at(-1);if((g==null?void 0:g.type)==="code")break;if((g==null?void 0:g.type)==="blockquote"){let x=g,y=x.raw+`
145
+ `+n.join(`
146
+ `),E=this.blockquote(y);o[o.length-1]=E,r=r.substring(0,r.length-x.raw.length)+E.raw,i=i.substring(0,i.length-x.text.length)+E.text;break}else if((g==null?void 0:g.type)==="list"){let x=g,y=x.raw+`
147
+ `+n.join(`
148
+ `),E=this.list(y);o[o.length-1]=E,r=r.substring(0,r.length-g.raw.length)+E.raw,i=i.substring(0,i.length-x.raw.length)+E.raw,n=y.substring(o.at(-1).raw.length).split(`
149
+ `);continue}}return{type:"blockquote",raw:r,tokens:o,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),c=!1;for(;e;){let h=!1,d="",p="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;d=t[0],e=e.substring(d.length);let m=t[2].split(`
150
+ `,1)[0].replace(this.rules.other.listReplaceTabs,w=>" ".repeat(3*w.length)),g=e.split(`
151
+ `,1)[0],x=!m.trim(),y=0;if(this.options.pedantic?(y=2,p=m.trimStart()):x?y=t[1].length+1:(y=t[2].search(this.rules.other.nonSpaceChar),y=y>4?1:y,p=m.slice(y),y+=t[1].length),x&&this.rules.other.blankLine.test(g)&&(d+=g+`
152
+ `,e=e.substring(g.length+1),h=!0),!h){let w=this.rules.other.nextBulletRegex(y),T=this.rules.other.hrRegex(y),k=this.rules.other.fencesBeginRegex(y),I=this.rules.other.headingBeginRegex(y),L=this.rules.other.htmlBeginRegex(y);for(;e;){let z=e.split(`
153
+ `,1)[0],U;if(g=z,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),U=g):U=g.replace(this.rules.other.tabCharGlobal," "),k.test(g)||I.test(g)||L.test(g)||w.test(g)||T.test(g))break;if(U.search(this.rules.other.nonSpaceChar)>=y||!g.trim())p+=`
154
+ `+U.slice(y);else{if(x||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||k.test(m)||I.test(m)||T.test(m))break;p+=`
155
+ `+g}!x&&!g.trim()&&(x=!0),d+=z+`
156
+ `,e=e.substring(z.length+1),m=U.slice(y)}}i.loose||(c?i.loose=!0:this.rules.other.doubleBlankLine.test(d)&&(c=!0));let E=null,N;this.options.gfm&&(E=this.rules.other.listIsTask.exec(p),E&&(N=E[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:d,task:!!E,checked:N,loose:!1,text:p,tokens:[]}),i.raw+=d}let u=i.items.at(-1);if(u)u.raw=u.raw.trimEnd(),u.text=u.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let h=0;h<i.items.length;h++)if(this.lexer.state.top=!1,i.items[h].tokens=this.lexer.blockTokens(i.items[h].text,[]),!i.loose){let d=i.items[h].tokens.filter(m=>m.type==="space"),p=d.length>0&&d.some(m=>this.rules.other.anyLine.test(m.raw));i.loose=p}if(i.loose)for(let h=0;h<i.items.length;h++)i.items[h].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){var c;let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=xy(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=(c=t[3])!=null&&c.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
157
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let u of r)this.rules.other.tableAlignRight.test(u)?o.align.push("right"):this.rules.other.tableAlignCenter.test(u)?o.align.push("center"):this.rules.other.tableAlignLeft.test(u)?o.align.push("left"):o.align.push(null);for(let u=0;u<n.length;u++)o.header.push({text:n[u],tokens:this.lexer.inline(n[u]),header:!0,align:o.align[u]});for(let u of i)o.rows.push(xy(u,o.header.length).map((h,d)=>({text:h,tokens:this.lexer.inline(h),header:!1,align:o.align[d]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
158
+ `?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=Cl(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=m2(t[2],"()");if(o===-2)return;if(o>-1){let c=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,c).trim(),t[3]=""}}let r=t[2],i="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(r);o&&(r=o[1],i=o[3])}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),vy(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return vy(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,o,c,u=i,h=0,d=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(d.lastIndex=0,t=t.slice(-1*e.length+i);(r=d.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(c=[...o].length,r[3]||r[4]){u+=c;continue}else if((r[5]||r[6])&&i%3&&!((i+c)%3)){h+=c;continue}if(u-=c,u>0)continue;c=Math.min(c,c+u+h);let p=[...r[0]][0].length,m=e.slice(0,i+r.index+p+c);if(Math.min(i,c)%2){let x=m.slice(1,-1);return{type:"em",raw:m,text:x,tokens:this.lexer.inlineTokens(x)}}let g=m.slice(2,-2);return{type:"strong",raw:m,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var n;let t;if(t=this.rules.inline.url.exec(e)){let r,i;if(t[2]==="@")r=t[0],i="mailto:"+r;else{let o;do o=t[0],t[0]=((n=this.rules.inline._backpedal.exec(t[0]))==null?void 0:n[0])??"";while(o!==t[0]);r=t[0],t[1]==="www."?i="http://"+t[0]:i=t[0]}return{type:"link",raw:t[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},xr=class sm{constructor(t){ut(this,"tokens");ut(this,"options");ut(this,"state");ut(this,"tokenizer");ut(this,"inlineQueue");this.tokens=[],this.tokens.links=Object.create(null),this.options=t||La,this.options.tokenizer=this.options.tokenizer||new id,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:is,block:_u.normal,inline:El.normal};this.options.pedantic?(n.block=_u.pedantic,n.inline=El.pedantic):this.options.gfm&&(n.block=_u.gfm,this.options.breaks?n.inline=El.breaks:n.inline=El.gfm),this.tokenizer.rules=n}static get rules(){return{block:_u,inline:El}}static lex(t,n){return new sm(n).lex(t)}static lexInline(t,n){return new sm(n).inlineTokens(t)}lex(t){t=t.replace(is.carriageReturn,`
159
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],r=!1){var i,o,c;for(this.options.pedantic&&(t=t.replace(is.tabCharGlobal," ").replace(is.spaceLine,""));t;){let u;if((o=(i=this.options.extensions)==null?void 0:i.block)!=null&&o.some(d=>(u=d.call({lexer:this},t,n))?(t=t.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.space(t)){t=t.substring(u.raw.length);let d=n.at(-1);u.raw.length===1&&d!==void 0?d.raw+=`
160
+ `:n.push(u);continue}if(u=this.tokenizer.code(t)){t=t.substring(u.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
161
+ `)?"":`
162
+ `)+u.raw,d.text+=`
163
+ `+u.text,this.inlineQueue.at(-1).src=d.text):n.push(u);continue}if(u=this.tokenizer.fences(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.heading(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.hr(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.blockquote(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.list(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.html(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.def(t)){t=t.substring(u.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="paragraph"||(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
164
+ `)?"":`
165
+ `)+u.raw,d.text+=`
166
+ `+u.raw,this.inlineQueue.at(-1).src=d.text):this.tokens.links[u.tag]||(this.tokens.links[u.tag]={href:u.href,title:u.title},n.push(u));continue}if(u=this.tokenizer.table(t)){t=t.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.lheading(t)){t=t.substring(u.raw.length),n.push(u);continue}let h=t;if((c=this.options.extensions)!=null&&c.startBlock){let d=1/0,p=t.slice(1),m;this.options.extensions.startBlock.forEach(g=>{m=g.call({lexer:this},p),typeof m=="number"&&m>=0&&(d=Math.min(d,m))}),d<1/0&&d>=0&&(h=t.substring(0,d+1))}if(this.state.top&&(u=this.tokenizer.paragraph(h))){let d=n.at(-1);r&&(d==null?void 0:d.type)==="paragraph"?(d.raw+=(d.raw.endsWith(`
167
+ `)?"":`
168
+ `)+u.raw,d.text+=`
169
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(u),r=h.length!==t.length,t=t.substring(u.raw.length);continue}if(u=this.tokenizer.text(t)){t=t.substring(u.raw.length);let d=n.at(-1);(d==null?void 0:d.type)==="text"?(d.raw+=(d.raw.endsWith(`
170
+ `)?"":`
171
+ `)+u.raw,d.text+=`
172
+ `+u.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=d.text):n.push(u);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw new Error(d)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){var h,d,p,m,g;let r=t,i=null;if(this.tokens.links){let x=Object.keys(this.tokens.links);if(x.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)x.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)o=i[2]?i[2].length:0,r=r.slice(0,i.index+o)+"["+"a".repeat(i[0].length-o-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=((d=(h=this.options.hooks)==null?void 0:h.emStrongMask)==null?void 0:d.call({lexer:this},r))??r;let c=!1,u="";for(;t;){c||(u=""),c=!1;let x;if((m=(p=this.options.extensions)==null?void 0:p.inline)!=null&&m.some(E=>(x=E.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 E=n.at(-1);x.type==="text"&&(E==null?void 0:E.type)==="text"?(E.raw+=x.raw,E.text+=x.text):n.push(x);continue}if(x=this.tokenizer.emStrong(t,r,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 y=t;if((g=this.options.extensions)!=null&&g.startInline){let E=1/0,N=t.slice(1),w;this.options.extensions.startInline.forEach(T=>{w=T.call({lexer:this},N),typeof w=="number"&&w>=0&&(E=Math.min(E,w))}),E<1/0&&E>=0&&(y=t.substring(0,E+1))}if(x=this.tokenizer.inlineText(y)){t=t.substring(x.raw.length),x.raw.slice(-1)!=="_"&&(u=x.raw.slice(-1)),c=!0;let E=n.at(-1);(E==null?void 0:E.type)==="text"?(E.raw+=x.raw,E.text+=x.text):n.push(x);continue}if(t){let E="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(E);break}else throw new Error(E)}}return n}},ad=class{constructor(e){ut(this,"options");ut(this,"parser");this.options=e||La}space(e){return""}code({text:e,lang:t,escaped:n}){var o;let r=(o=(t||"").match(is.notSpaceStart))==null?void 0:o[0],i=e.replace(is.endingNewline,"")+`
173
+ `;return r?'<pre><code class="language-'+Dr(r)+'">'+(n?i:Dr(i,!0))+`</code></pre>
174
+ `:"<pre><code>"+(n?i:Dr(i,!0))+`</code></pre>
175
+ `}blockquote({tokens:e}){return`<blockquote>
176
+ ${this.parser.parse(e)}</blockquote>
177
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
178
+ `}hr(e){return`<hr>
179
+ `}list(e){let t=e.ordered,n=e.start,r="";for(let c=0;c<e.items.length;c++){let u=e.items[c];r+=this.listitem(u)}let i=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+i+o+`>
180
+ `+r+"</"+i+`>
181
+ `}listitem(e){var n;let t="";if(e.task){let r=this.checkbox({checked:!!e.checked});e.loose?((n=e.tokens[0])==null?void 0:n.type)==="paragraph"?(e.tokens[0].text=r+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=r+" "+Dr(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:r+" ",text:r+" ",escaped:!0}):t+=r+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
182
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
183
+ `}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let o=e.rows[i];n="";for(let c=0;c<o.length;c++)n+=this.tablecell(o[c]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
184
+ <thead>
185
+ `+t+`</thead>
186
+ `+r+`</table>
187
+ `}tablerow({text:e}){return`<tr>
188
+ ${e}</tr>
189
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
190
+ `}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>${Dr(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=gy(e);if(i===null)return r;e=i;let o='<a href="'+e+'"';return t&&(o+=' title="'+Dr(t)+'"'),o+=">"+r+"</a>",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=gy(e);if(i===null)return Dr(n);e=i;let o=`<img src="${e}" alt="${n}"`;return t&&(o+=` title="${Dr(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:Dr(e.text)}},Jm=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""}},vr=class rm{constructor(t){ut(this,"options");ut(this,"renderer");ut(this,"textRenderer");this.options=t||La,this.options.renderer=this.options.renderer||new ad,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Jm}static parse(t,n){return new rm(n).parse(t)}static parseInline(t,n){return new rm(n).parseInline(t)}parse(t,n=!0){var i,o;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[u.type]){let d=u,p=this.options.extensions.renderers[d.type].call({parser:this},d);if(p!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(d.type)){r+=p||"";continue}}let h=u;switch(h.type){case"space":{r+=this.renderer.space(h);continue}case"hr":{r+=this.renderer.hr(h);continue}case"heading":{r+=this.renderer.heading(h);continue}case"code":{r+=this.renderer.code(h);continue}case"table":{r+=this.renderer.table(h);continue}case"blockquote":{r+=this.renderer.blockquote(h);continue}case"list":{r+=this.renderer.list(h);continue}case"html":{r+=this.renderer.html(h);continue}case"def":{r+=this.renderer.def(h);continue}case"paragraph":{r+=this.renderer.paragraph(h);continue}case"text":{let d=h,p=this.renderer.text(d);for(;c+1<t.length&&t[c+1].type==="text";)d=t[++c],p+=`
191
+ `+this.renderer.text(d);n?r+=this.renderer.paragraph({type:"paragraph",raw:p,text:p,tokens:[{type:"text",raw:p,text:p,escaped:!0}]}):r+=p;continue}default:{let d='Token with "'+h.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}parseInline(t,n=this.renderer){var i,o;let r="";for(let c=0;c<t.length;c++){let u=t[c];if((o=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&o[u.type]){let d=this.options.extensions.renderers[u.type].call({parser:this},u);if(d!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(u.type)){r+=d||"";continue}}let h=u;switch(h.type){case"escape":{r+=n.text(h);break}case"html":{r+=n.html(h);break}case"link":{r+=n.link(h);break}case"image":{r+=n.image(h);break}case"strong":{r+=n.strong(h);break}case"em":{r+=n.em(h);break}case"codespan":{r+=n.codespan(h);break}case"br":{r+=n.br(h);break}case"del":{r+=n.del(h);break}case"text":{r+=n.text(h);break}default:{let d='Token with "'+h.type+'" type was not found.';if(this.options.silent)return console.error(d),"";throw new Error(d)}}}return r}},Fu,Pl=(Fu=class{constructor(e){ut(this,"options");ut(this,"block");this.options=e||La}preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?xr.lex:xr.lexInline}provideParser(){return this.block?vr.parse:vr.parseInline}},ut(Fu,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ut(Fu,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),Fu),x2=class{constructor(...e){ut(this,"defaults",Wm());ut(this,"options",this.setOptions);ut(this,"parse",this.parseMarkdown(!0));ut(this,"parseInline",this.parseMarkdown(!1));ut(this,"Parser",vr);ut(this,"Renderer",ad);ut(this,"TextRenderer",Jm);ut(this,"Lexer",xr);ut(this,"Tokenizer",id);ut(this,"Hooks",Pl);this.use(...e)}walkTokens(e,t){var r,i;let n=[];for(let o of e)switch(n=n.concat(t.call(this,o)),o.type){case"table":{let c=o;for(let u of c.header)n=n.concat(this.walkTokens(u.tokens,t));for(let u of c.rows)for(let h of u)n=n.concat(this.walkTokens(h.tokens,t));break}case"list":{let c=o;n=n.concat(this.walkTokens(c.items,t));break}default:{let c=o;(i=(r=this.defaults.extensions)==null?void 0:r.childTokens)!=null&&i[c.type]?this.defaults.extensions.childTokens[c.type].forEach(u=>{let h=c[u].flat(1/0);n=n.concat(this.walkTokens(h,t))}):c.tokens&&(n=n.concat(this.walkTokens(c.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let o=t.renderers[i.name];o?t.renderers[i.name]=function(...c){let u=i.renderer.apply(this,c);return u===!1&&(u=o.apply(this,c)),u}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let o=t[i.level];o?o.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new ad(this.defaults);for(let o in n.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let c=o,u=n.renderer[c],h=i[c];i[c]=(...d)=>{let p=u.apply(i,d);return p===!1&&(p=h.apply(i,d)),p||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new id(this.defaults);for(let o in n.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let c=o,u=n.tokenizer[c],h=i[c];i[c]=(...d)=>{let p=u.apply(i,d);return p===!1&&(p=h.apply(i,d)),p}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new Pl;for(let o in n.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let c=o,u=n.hooks[c],h=i[c];Pl.passThroughHooks.has(o)?i[c]=d=>{if(this.defaults.async&&Pl.passThroughHooksRespectAsync.has(o))return(async()=>{let m=await u.call(i,d);return h.call(i,m)})();let p=u.call(i,d);return h.call(i,p)}:i[c]=(...d)=>{if(this.defaults.async)return(async()=>{let m=await u.apply(i,d);return m===!1&&(m=await h.apply(i,d)),m})();let p=u.apply(i,d);return p===!1&&(p=h.apply(i,d)),p}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,o=n.walkTokens;r.walkTokens=function(c){let u=[];return u.push(o.call(this,c)),i&&(u=u.concat(i.call(this,c))),u}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return xr.lex(e,t??this.defaults)}parser(e,t){return vr.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let c=i.hooks?await i.hooks.preprocess(t):t,u=await(i.hooks?await i.hooks.provideLexer():e?xr.lex:xr.lexInline)(c,i),h=i.hooks?await i.hooks.processAllTokens(u):u;i.walkTokens&&await Promise.all(this.walkTokens(h,i.walkTokens));let d=await(i.hooks?await i.hooks.provideParser():e?vr.parse:vr.parseInline)(h,i);return i.hooks?await i.hooks.postprocess(d):d})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let c=(i.hooks?i.hooks.provideLexer():e?xr.lex:xr.lexInline)(t,i);i.hooks&&(c=i.hooks.processAllTokens(c)),i.walkTokens&&this.walkTokens(c,i.walkTokens);let u=(i.hooks?i.hooks.provideParser():e?vr.parse:vr.parseInline)(c,i);return i.hooks&&(u=i.hooks.postprocess(u)),u}catch(c){return o(c)}}}onError(e,t){return n=>{if(n.message+=`
192
+ Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+Dr(n.message+"",!0)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}},Ia=new x2;function Ct(e,t){return Ia.parse(e,t)}Ct.options=Ct.setOptions=function(e){return Ia.setOptions(e),Ct.defaults=Ia.defaults,uw(Ct.defaults),Ct};Ct.getDefaults=Wm;Ct.defaults=La;Ct.use=function(...e){return Ia.use(...e),Ct.defaults=Ia.defaults,uw(Ct.defaults),Ct};Ct.walkTokens=function(e,t){return Ia.walkTokens(e,t)};Ct.parseInline=Ia.parseInline;Ct.Parser=vr;Ct.parser=vr.parse;Ct.Renderer=ad;Ct.TextRenderer=Jm;Ct.Lexer=xr;Ct.lexer=xr.lex;Ct.Tokenizer=id;Ct.Hooks=Pl;Ct.parse=Ct;Ct.options;Ct.setOptions;Ct.use;Ct.walkTokens;Ct.parseInline;vr.parse;xr.lex;var Yf,yy;function v2(){if(yy)return Yf;yy=1;function e(J){return J instanceof Map?J.clear=J.delete=J.set=function(){throw new Error("map is read-only")}:J instanceof Set&&(J.add=J.clear=J.delete=function(){throw new Error("set is read-only")}),Object.freeze(J),Object.getOwnPropertyNames(J).forEach(ge=>{const ze=J[ge],st=typeof ze;(st==="object"||st==="function")&&!Object.isFrozen(ze)&&e(ze)}),J}class t{constructor(ge){ge.data===void 0&&(ge.data={}),this.data=ge.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(J){return J.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(J,...ge){const ze=Object.create(null);for(const st in J)ze[st]=J[st];return ge.forEach(function(st){for(const It in st)ze[It]=st[It]}),ze}const i="</span>",o=J=>!!J.scope,c=(J,{prefix:ge})=>{if(J.startsWith("language:"))return J.replace("language:","language-");if(J.includes(".")){const ze=J.split(".");return[`${ge}${ze.shift()}`,...ze.map((st,It)=>`${st}${"_".repeat(It+1)}`)].join(" ")}return`${ge}${J}`};class u{constructor(ge,ze){this.buffer="",this.classPrefix=ze.classPrefix,ge.walk(this)}addText(ge){this.buffer+=n(ge)}openNode(ge){if(!o(ge))return;const ze=c(ge.scope,{prefix:this.classPrefix});this.span(ze)}closeNode(ge){o(ge)&&(this.buffer+=i)}value(){return this.buffer}span(ge){this.buffer+=`<span class="${ge}">`}}const h=(J={})=>{const ge={children:[]};return Object.assign(ge,J),ge};class d{constructor(){this.rootNode=h(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ge){this.top.children.push(ge)}openNode(ge){const ze=h({scope:ge});this.add(ze),this.stack.push(ze)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ge){return this.constructor._walk(ge,this.rootNode)}static _walk(ge,ze){return typeof ze=="string"?ge.addText(ze):ze.children&&(ge.openNode(ze),ze.children.forEach(st=>this._walk(ge,st)),ge.closeNode(ze)),ge}static _collapse(ge){typeof ge!="string"&&ge.children&&(ge.children.every(ze=>typeof ze=="string")?ge.children=[ge.children.join("")]:ge.children.forEach(ze=>{d._collapse(ze)}))}}class p extends d{constructor(ge){super(),this.options=ge}addText(ge){ge!==""&&this.add(ge)}startScope(ge){this.openNode(ge)}endScope(){this.closeNode()}__addSublanguage(ge,ze){const st=ge.root;ze&&(st.scope=`language:${ze}`),this.add(st)}toHTML(){return new u(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(J){return J?typeof J=="string"?J:J.source:null}function g(J){return E("(?=",J,")")}function x(J){return E("(?:",J,")*")}function y(J){return E("(?:",J,")?")}function E(...J){return J.map(ze=>m(ze)).join("")}function N(J){const ge=J[J.length-1];return typeof ge=="object"&&ge.constructor===Object?(J.splice(J.length-1,1),ge):{}}function w(...J){return"("+(N(J).capture?"":"?:")+J.map(st=>m(st)).join("|")+")"}function T(J){return new RegExp(J.toString()+"|").exec("").length-1}function k(J,ge){const ze=J&&J.exec(ge);return ze&&ze.index===0}const I=new RegExp(w(/\[(?:[^\\\]]|\\.)*\]/,/\(\?<(?![=!])[^>]+>/,/\(\?'[^']+'/,/\(\??/,/\\([1-9][0-9]*)/,/\\./));function L(J,{joinWith:ge}){let ze=0;return J.map(st=>{ze+=1;const It=ze;let $t=m(st),Be="";for(;$t.length>0;){const Fe=I.exec($t);if(!Fe){Be+=$t;break}Be+=$t.substring(0,Fe.index),$t=$t.substring(Fe.index+Fe[0].length),Fe[0][0]==="\\"&&Fe[1]?Be+="\\"+String(Number(Fe[1])+It):(Be+=Fe[0],(Fe[0]==="("||/^\(\?[<']/.test(Fe[0]))&&ze++)}return Be}).map(st=>`(${st})`).join(ge)}const z=/\b\B/,U="[a-zA-Z]\\w*",V="[a-zA-Z_]\\w*",$="\\b\\d+(\\.\\d+)?",P="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D="\\b(0b[01]+)",B="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",_=(J={})=>{const ge=/^#![ ]*\//;return J.binary&&(J.begin=E(ge,/.*\b/,J.binary,/\b.*/)),r({scope:"meta",begin:ge,end:/$/,relevance:0,"on:begin":(ze,st)=>{ze.index!==0&&st.ignoreMatch()}},J)},C={begin:"\\\\[\\s\\S]",relevance:0},R={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[C]},M={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[C]},F={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},H=function(J,ge,ze={}){const st=r({scope:"comment",begin:J,end:ge,contains:[]},ze);st.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const It=w("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return st.contains.push({begin:E(/[ ]+/,"(",It,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),st},W=H("//","$"),K=H("/\\*","\\*/"),q=H("#","$"),Y={scope:"number",begin:$,relevance:0},fe={scope:"number",begin:P,relevance:0},me={scope:"number",begin:D,relevance:0},xe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[C,{begin:/\[/,end:/\]/,relevance:0,contains:[C]}]},oe={scope:"title",begin:U,relevance:0},re={scope:"title",begin:V,relevance:0},ie={begin:"\\.\\s*"+V,relevance:0};var De=Object.freeze({__proto__:null,APOS_STRING_MODE:R,BACKSLASH_ESCAPE:C,BINARY_NUMBER_MODE:me,BINARY_NUMBER_RE:D,COMMENT:H,C_BLOCK_COMMENT_MODE:K,C_LINE_COMMENT_MODE:W,C_NUMBER_MODE:fe,C_NUMBER_RE:P,END_SAME_AS_BEGIN:function(J){return Object.assign(J,{"on:begin":(ge,ze)=>{ze.data._beginMatch=ge[1]},"on:end":(ge,ze)=>{ze.data._beginMatch!==ge[1]&&ze.ignoreMatch()}})},HASH_COMMENT_MODE:q,IDENT_RE:U,MATCH_NOTHING_RE:z,METHOD_GUARD:ie,NUMBER_MODE:Y,NUMBER_RE:$,PHRASAL_WORDS_MODE:F,QUOTE_STRING_MODE:M,REGEXP_MODE:xe,RE_STARTERS_RE:B,SHEBANG:_,TITLE_MODE:oe,UNDERSCORE_IDENT_RE:V,UNDERSCORE_TITLE_MODE:re});function de(J,ge){J.input[J.index-1]==="."&&ge.ignoreMatch()}function Se(J,ge){J.className!==void 0&&(J.scope=J.className,delete J.className)}function ae(J,ge){ge&&J.beginKeywords&&(J.begin="\\b("+J.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",J.__beforeBegin=de,J.keywords=J.keywords||J.beginKeywords,delete J.beginKeywords,J.relevance===void 0&&(J.relevance=0))}function pe(J,ge){Array.isArray(J.illegal)&&(J.illegal=w(...J.illegal))}function Le(J,ge){if(J.match){if(J.begin||J.end)throw new Error("begin & end are not supported with match");J.begin=J.match,delete J.match}}function Te(J,ge){J.relevance===void 0&&(J.relevance=1)}const Ge=(J,ge)=>{if(!J.beforeMatch)return;if(J.starts)throw new Error("beforeMatch cannot be used with starts");const ze=Object.assign({},J);Object.keys(J).forEach(st=>{delete J[st]}),J.keywords=ze.keywords,J.begin=E(ze.beforeMatch,g(ze.begin)),J.starts={relevance:0,contains:[Object.assign(ze,{endsParent:!0})]},J.relevance=0,delete ze.beforeMatch},Ae=["of","and","for","in","not","or","if","then","parent","list","value"],tt="keyword";function et(J,ge,ze=tt){const st=Object.create(null);return typeof J=="string"?It(ze,J.split(" ")):Array.isArray(J)?It(ze,J):Object.keys(J).forEach(function($t){Object.assign(st,et(J[$t],ge,$t))}),st;function It($t,Be){ge&&(Be=Be.map(Fe=>Fe.toLowerCase())),Be.forEach(function(Fe){const Xe=Fe.split("|");st[Xe[0]]=[$t,jt(Xe[0],Xe[1])]})}}function jt(J,ge){return ge?Number(ge):zn(J)?0:1}function zn(J){return Ae.includes(J.toLowerCase())}const sn={},ln=J=>{console.error(J)},cn=(J,...ge)=>{console.log(`WARN: ${J}`,...ge)},rn=(J,ge)=>{sn[`${J}/${ge}`]||(console.log(`Deprecated as of ${J}. ${ge}`),sn[`${J}/${ge}`]=!0)},an=new Error;function Ft(J,ge,{key:ze}){let st=0;const It=J[ze],$t={},Be={};for(let Fe=1;Fe<=ge.length;Fe++)Be[Fe+st]=It[Fe],$t[Fe+st]=!0,st+=T(ge[Fe-1]);J[ze]=Be,J[ze]._emit=$t,J[ze]._multi=!0}function Un(J){if(Array.isArray(J.begin)){if(J.skip||J.excludeBegin||J.returnBegin)throw ln("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),an;if(typeof J.beginScope!="object"||J.beginScope===null)throw ln("beginScope must be object"),an;Ft(J,J.begin,{key:"beginScope"}),J.begin=L(J.begin,{joinWith:""})}}function Nn(J){if(Array.isArray(J.end)){if(J.skip||J.excludeEnd||J.returnEnd)throw ln("skip, excludeEnd, returnEnd not compatible with endScope: {}"),an;if(typeof J.endScope!="object"||J.endScope===null)throw ln("endScope must be object"),an;Ft(J,J.end,{key:"endScope"}),J.end=L(J.end,{joinWith:""})}}function js(J){J.scope&&typeof J.scope=="object"&&J.scope!==null&&(J.beginScope=J.scope,delete J.scope)}function Ir(J){js(J),typeof J.beginScope=="string"&&(J.beginScope={_wrap:J.beginScope}),typeof J.endScope=="string"&&(J.endScope={_wrap:J.endScope}),Un(J),Nn(J)}function er(J){function ge(Be,Fe){return new RegExp(m(Be),"m"+(J.case_insensitive?"i":"")+(J.unicodeRegex?"u":"")+(Fe?"g":""))}class ze{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Fe,Xe){Xe.position=this.position++,this.matchIndexes[this.matchAt]=Xe,this.regexes.push([Xe,Fe]),this.matchAt+=T(Fe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Fe=this.regexes.map(Xe=>Xe[1]);this.matcherRe=ge(L(Fe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Fe){this.matcherRe.lastIndex=this.lastIndex;const Xe=this.matcherRe.exec(Fe);if(!Xe)return null;const bt=Xe.findIndex((Hn,os)=>os>0&&Hn!==void 0),yt=this.matchIndexes[bt];return Xe.splice(0,bt),Object.assign(Xe,yt)}}class st{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Fe){if(this.multiRegexes[Fe])return this.multiRegexes[Fe];const Xe=new ze;return this.rules.slice(Fe).forEach(([bt,yt])=>Xe.addRule(bt,yt)),Xe.compile(),this.multiRegexes[Fe]=Xe,Xe}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Fe,Xe){this.rules.push([Fe,Xe]),Xe.type==="begin"&&this.count++}exec(Fe){const Xe=this.getMatcher(this.regexIndex);Xe.lastIndex=this.lastIndex;let bt=Xe.exec(Fe);if(this.resumingScanAtSamePosition()&&!(bt&&bt.index===this.lastIndex)){const yt=this.getMatcher(0);yt.lastIndex=this.lastIndex+1,bt=yt.exec(Fe)}return bt&&(this.regexIndex+=bt.position+1,this.regexIndex===this.count&&this.considerAll()),bt}}function It(Be){const Fe=new st;return Be.contains.forEach(Xe=>Fe.addRule(Xe.begin,{rule:Xe,type:"begin"})),Be.terminatorEnd&&Fe.addRule(Be.terminatorEnd,{type:"end"}),Be.illegal&&Fe.addRule(Be.illegal,{type:"illegal"}),Fe}function $t(Be,Fe){const Xe=Be;if(Be.isCompiled)return Xe;[Se,Le,Ir,Ge].forEach(yt=>yt(Be,Fe)),J.compilerExtensions.forEach(yt=>yt(Be,Fe)),Be.__beforeBegin=null,[ae,pe,Te].forEach(yt=>yt(Be,Fe)),Be.isCompiled=!0;let bt=null;return typeof Be.keywords=="object"&&Be.keywords.$pattern&&(Be.keywords=Object.assign({},Be.keywords),bt=Be.keywords.$pattern,delete Be.keywords.$pattern),bt=bt||/\w+/,Be.keywords&&(Be.keywords=et(Be.keywords,J.case_insensitive)),Xe.keywordPatternRe=ge(bt,!0),Fe&&(Be.begin||(Be.begin=/\B|\b/),Xe.beginRe=ge(Xe.begin),!Be.end&&!Be.endsWithParent&&(Be.end=/\B|\b/),Be.end&&(Xe.endRe=ge(Xe.end)),Xe.terminatorEnd=m(Xe.end)||"",Be.endsWithParent&&Fe.terminatorEnd&&(Xe.terminatorEnd+=(Be.end?"|":"")+Fe.terminatorEnd)),Be.illegal&&(Xe.illegalRe=ge(Be.illegal)),Be.contains||(Be.contains=[]),Be.contains=[].concat(...Be.contains.map(function(yt){return Ps(yt==="self"?Be:yt)})),Be.contains.forEach(function(yt){$t(yt,Xe)}),Be.starts&&$t(Be.starts,Fe),Xe.matcher=It(Xe),Xe}if(J.compilerExtensions||(J.compilerExtensions=[]),J.contains&&J.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return J.classNameAliases=r(J.classNameAliases||{}),$t(J)}function tr(J){return J?J.endsWithParent||tr(J.starts):!1}function Ps(J){return J.variants&&!J.cachedVariants&&(J.cachedVariants=J.variants.map(function(ge){return r(J,{variants:null},ge)})),J.cachedVariants?J.cachedVariants:tr(J)?r(J,{starts:J.starts?r(J.starts):null}):Object.isFrozen(J)?r(J):J}var Ls="11.12.0";class Ds extends Error{constructor(ge,ze){super(ge),this.name="HTMLInjectionError",this.html=ze}}const Fs=n,nr=r,sr=Symbol("nomatch"),as=7,Xn=function(J){const ge=Object.create(null),ze=Object.create(null),st=[];let It=!0;const $t="Could not find the language '{}', did you forget to load/include a language module?",Be={disableAutodetect:!0,name:"Plain text",contains:[]};let Fe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Xe(Ie){return Fe.noHighlightRe.test(Ie)}function bt(Ie){let Ze=Ie.className+" ";Ze+=Ie.parentNode?Ie.parentNode.className:"";const ct=Fe.languageDetectRe.exec(Ze);if(ct){const ht=Qn(ct[1]);return ht||(cn($t.replace("{}",ct[1])),cn("Falling back to no-highlight mode for this block.",Ie)),ht?ct[1]:"no-highlight"}return Ze.split(/\s+/).find(ht=>Xe(ht)||Qn(ht))}function yt(Ie,Ze,ct){let ht="",Tt="";typeof Ze=="object"?(ht=Ie,ct=Ze.ignoreIllegals,Tt=Ze.language):(rn("10.7.0","highlight(lang, code, ...args) has been deprecated."),rn("10.7.0",`Please use highlight(code, options) instead.
193
+ https://github.com/highlightjs/highlight.js/issues/2277`),Tt=Ie,ht=Ze),ct===void 0&&(ct=!0);const zt={code:ht,language:Tt};or("before:highlight",zt);const Wn=zt.result?zt.result:Hn(zt.language,zt.code,ct);return Wn.code=zt.code,or("after:highlight",Wn),Wn}function Hn(Ie,Ze,ct,ht){const Tt=Object.create(null);function zt($e,Ue){return $e.keywords[Ue]}function Wn(){if(!at.keywords){Pt.addText(ft);return}let $e=0;at.keywordPatternRe.lastIndex=0;let Ue=at.keywordPatternRe.exec(ft),ot="";for(;Ue;){ot+=ft.substring($e,Ue.index);const gt=Sn.case_insensitive?Ue[0].toLowerCase():Ue[0],Bt=zt(at,gt);if(Bt){const[pn,qo]=Bt;if(Pt.addText(ot),ot="",Tt[gt]=(Tt[gt]||0)+1,Tt[gt]<=as&&(Gr+=qo),pn.startsWith("_"))ot+=Ue[0];else{const na=Sn.classNameAliases[pn]||pn;jn(Ue[0],na)}}else ot+=Ue[0];$e=at.keywordPatternRe.lastIndex,Ue=at.keywordPatternRe.exec(ft)}ot+=ft.substring($e),Pt.addText(ot)}function Bs(){if(ft==="")return;let $e=null;if(typeof at.subLanguage=="string"){if(!ge[at.subLanguage]){Pt.addText(ft);return}$e=Hn(at.subLanguage,ft,!0,ds[at.subLanguage]),ds[at.subLanguage]=$e._top}else $e=rr(ft,at.subLanguage.length?at.subLanguage:null);at.relevance>0&&(Gr+=$e.relevance),Pt.__addSublanguage($e._emitter,$e.language)}function un(){at.subLanguage!=null?Bs():Wn(),ft=""}function jn($e,Ue){$e!==""&&(Pt.startScope(Ue),Pt.addText($e),Pt.endScope())}function Us($e,Ue){let ot=1;const gt=Ue.length-1;for(;ot<=gt;){if(!$e._emit[ot]){ot++;continue}const Bt=Sn.classNameAliases[$e[ot]]||$e[ot],pn=Ue[ot];Bt?jn(pn,Bt):(ft=pn,Wn(),ft=""),ot++}}function Hs($e,Ue){return $e.scope&&typeof $e.scope=="string"&&Pt.openNode(Sn.classNameAliases[$e.scope]||$e.scope),$e.beginScope&&($e.beginScope._wrap?(jn(ft,Sn.classNameAliases[$e.beginScope._wrap]||$e.beginScope._wrap),ft=""):$e.beginScope._multi&&(Us($e.beginScope,Ue),ft="")),at=Object.create($e,{parent:{value:at}}),at}function cs($e,Ue,ot){let gt=k($e.endRe,ot);if(gt){if($e["on:end"]){const Bt=new t($e);$e["on:end"](Ue,Bt),Bt.isMatchIgnored&&(gt=!1)}if(gt){for(;$e.endsParent&&$e.parent;)$e=$e.parent;return $e}}if($e.endsWithParent)return cs($e.parent,Ue,ot)}function ta($e){return at.matcher.regexIndex===0?(ft+=$e[0],1):(lr=!0,0)}function yi($e){const Ue=$e[0],ot=$e.rule,gt=new t(ot),Bt=[ot.__beforeBegin,ot["on:begin"]];for(const pn of Bt)if(pn&&(pn($e,gt),gt.isMatchIgnored))return ta(Ue);return ot.skip?ft+=Ue:(ot.excludeBegin&&(ft+=Ue),un(),!ot.returnBegin&&!ot.excludeBegin&&(ft=Ue)),Hs(ot,$e),ot.returnBegin?0:Ue.length}function Mr($e){const Ue=$e[0],ot=Ze.substring($e.index),gt=cs(at,$e,ot);if(!gt)return sr;const Bt=at;at.endScope&&at.endScope._wrap?(un(),jn(Ue,at.endScope._wrap)):at.endScope&&at.endScope._multi?(un(),Us(at.endScope,$e)):Bt.skip?ft+=Ue:(Bt.returnEnd||Bt.excludeEnd||(ft+=Ue),un(),Bt.excludeEnd&&(ft=Ue));do at.scope&&Pt.closeNode(),!at.skip&&!at.subLanguage&&(Gr+=at.relevance),at=at.parent;while(at!==gt.parent);return gt.starts&&Hs(gt.starts,$e),Bt.returnEnd?0:Ue.length}function bi(){const $e=[];for(let Ue=at;Ue!==Sn;Ue=Ue.parent)Ue.scope&&$e.unshift(Ue.scope);$e.forEach(Ue=>Pt.openNode(Ue))}let Jn={};function us($e,Ue){const ot=Ue&&Ue[0];if(ft+=$e,ot==null)return un(),0;if(Jn.type==="begin"&&Ue.type==="end"&&Jn.index===Ue.index&&ot===""){if(ft+=Ze.slice(Ue.index,Ue.index+1),!It){const gt=new Error(`0 width match regex (${Ie})`);throw gt.languageName=Ie,gt.badRule=Jn.rule,gt}return 1}if(Jn=Ue,Ue.type==="begin")return yi(Ue);if(Ue.type==="illegal"&&!ct){const gt=new Error('Illegal lexeme "'+ot+'" for mode "'+(at.scope||"<unnamed>")+'"');throw gt.mode=at,gt}else if(Ue.type==="end"){const gt=Mr(Ue);if(gt!==sr)return gt}if(Ue.type==="illegal"&&ot==="")return Ue.index===Ze.length||(ft+=`
194
+ `),1;if(Kr>1e5&&Kr>Ue.index*3)throw new Error("potential infinite loop, way more iterations than matches");return ft+=ot,ot.length}const Sn=Qn(Ie);if(!Sn)throw ln($t.replace("{}",Ie)),new Error('Unknown language: "'+Ie+'"');const Zs=er(Sn);let vt="",at=ht||Zs;const ds={},Pt=new Fe.__emitter(Fe);bi();let ft="",Gr=0,es=0,Kr=0,lr=!1;try{if(Sn.__emitTokens)Sn.__emitTokens(Ze,Pt);else{for(at.matcher.considerAll();;){Kr++,lr?lr=!1:at.matcher.considerAll(),at.matcher.lastIndex=es;const $e=at.matcher.exec(Ze);if(!$e)break;const Ue=Ze.substring(es,$e.index),ot=us(Ue,$e);es=$e.index+ot}us(Ze.substring(es))}return Pt.finalize(),vt=Pt.toHTML(),{language:Ie,value:vt,relevance:Gr,illegal:!1,_emitter:Pt,_top:at}}catch($e){if($e.message&&$e.message.includes("Illegal"))return{language:Ie,value:Fs(Ze),illegal:!0,relevance:0,_illegalBy:{message:$e.message,index:es,context:Ze.slice(es-100,es+100),mode:$e.mode,resultSoFar:vt},_emitter:Pt};if(It)return{language:Ie,value:Fs(Ze),illegal:!1,relevance:0,errorRaised:$e,_emitter:Pt,_top:at};throw $e}}function os(Ie){const Ze={value:Fs(Ie),illegal:!1,relevance:0,_top:Be,_emitter:new Fe.__emitter(Fe)};return Ze._emitter.addText(Ie),Ze}function rr(Ie,Ze){Ze=Ze||Fe.languages||Object.keys(ge);const ct=os(Ie),ht=Ze.filter(Qn).filter(ar).map(un=>Hn(un,Ie,!1));ht.unshift(ct);const Tt=ht.sort((un,jn)=>{if(un.relevance!==jn.relevance)return jn.relevance-un.relevance;if(un.language&&jn.language){if(Qn(un.language).supersetOf===jn.language)return 1;if(Qn(jn.language).supersetOf===un.language)return-1}return 0}),[zt,Wn]=Tt,Bs=zt;return Bs.secondBest=Wn,Bs}function mi(Ie,Ze,ct){const ht=Ze&&ze[Ze]||ct;Ie.classList.add("hljs"),Ie.classList.add(`language-${ht}`)}function ir(Ie){let Ze=null;const ct=bt(Ie);if(Xe(ct))return;if(or("before:highlightElement",{el:Ie,language:ct}),Ie.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ie);return}if(Ie.children.length>0&&(Fe.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(Ie)),Fe.throwUnescapedHTML))throw new Ds("One of your code blocks includes unescaped HTML.",Ie.innerHTML);Ze=Ie;const ht=Ze.textContent,Tt=ct?yt(ht,{language:ct,ignoreIllegals:!0}):rr(ht);Ie.innerHTML=Tt.value,Ie.dataset.highlighted="yes",mi(Ie,ct,Tt.language),Ie.result={language:Tt.language,re:Tt.relevance,relevance:Tt.relevance},Tt.secondBest&&(Ie.secondBest={language:Tt.secondBest.language,relevance:Tt.secondBest.relevance}),or("after:highlightElement",{el:Ie,result:Tt,text:ht})}function gi(Ie){Fe=nr(Fe,Ie)}const Zn=()=>{Tr(),rn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Wr(){Tr(),rn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let ls=!1;function Tr(){function Ie(){Tr()}if(document.readyState==="loading"){ls||window.addEventListener("DOMContentLoaded",Ie,!1),ls=!0;return}document.querySelectorAll(Fe.cssSelector).forEach(ir)}function xi(Ie,Ze){let ct=null;try{ct=Ze(J)}catch(ht){if(ln("Language definition for '{}' could not be registered.".replace("{}",Ie)),It)ln(ht);else throw ht;ct=Be}ct.name||(ct.name=Ie),ge[Ie]=ct,ct.rawDefinition=Ze.bind(null,J),ct.aliases&&Vr(ct.aliases,{languageName:Ie})}function Rt(Ie){delete ge[Ie];for(const Ze of Object.keys(ze))ze[Ze]===Ie&&delete ze[Ze]}function Ss(){return Object.keys(ge)}function Qn(Ie){return Ie=(Ie||"").toLowerCase(),ge[Ie]||ge[ze[Ie]]}function Vr(Ie,{languageName:Ze}){typeof Ie=="string"&&(Ie=[Ie]),Ie.forEach(ct=>{ze[ct.toLowerCase()]=Ze})}function ar(Ie){const Ze=Qn(Ie);return Ze&&!Ze.disableAutodetect}function Ot(Ie){Ie["before:highlightBlock"]&&!Ie["before:highlightElement"]&&(Ie["before:highlightElement"]=Ze=>{Ie["before:highlightBlock"](Object.assign({block:Ze.el},Ze))}),Ie["after:highlightBlock"]&&!Ie["after:highlightElement"]&&(Ie["after:highlightElement"]=Ze=>{Ie["after:highlightBlock"](Object.assign({block:Ze.el},Ze))})}function vi(Ie){Ot(Ie),st.push(Ie)}function qr(Ie){const Ze=st.indexOf(Ie);Ze!==-1&&st.splice(Ze,1)}function or(Ie,Ze){const ct=Ie;st.forEach(function(ht){ht[ct]&&ht[ct](Ze)})}function $r(Ie){return rn("10.7.0","highlightBlock will be removed entirely in v12.0"),rn("10.7.0","Please use highlightElement now."),ir(Ie)}Object.assign(J,{highlight:yt,highlightAuto:rr,highlightAll:Tr,highlightElement:ir,highlightBlock:$r,configure:gi,initHighlighting:Zn,initHighlightingOnLoad:Wr,registerLanguage:xi,unregisterLanguage:Rt,listLanguages:Ss,getLanguage:Qn,registerAliases:Vr,autoDetection:ar,inherit:nr,addPlugin:vi,removePlugin:qr}),J.debugMode=function(){It=!1},J.safeMode=function(){It=!0},J.versionString=Ls,J.regex={concat:E,lookahead:g,either:w,optional:y,anyNumberOfTimes:x};for(const Ie in De)typeof De[Ie]=="object"&&e(De[Ie]);return Object.assign(J,De),J},wn=Xn({});return wn.newInstance=()=>Xn({}),Yf=wn,wn.HighlightJS=wn,wn.default=wn,Yf}var y2=v2();const jr=Sm(y2);function b2(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},o=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},u={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,i]};i.contains.push(u);const h={match:/\\"/},d={className:"string",begin:/'/,end:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),y={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},E=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],N=["true","false"],w={match:/(\/[a-z._-]+)+/},T=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],k=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],I=["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:E,literal:N,built_in:[...T,...k,"set","shopt",...I,...L]},contains:[x,e.SHEBANG(),y,m,o,c,w,u,h,d,p,n]}}const k2=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_-]*/}}),N2=["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"],w2=["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"],j2=[...N2,...w2],S2=["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(),_2=["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(),E2=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),C2=["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 A2(e){const t=e.regex,n=k2(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",o=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",u=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+_2.join("|")+")"},{begin:":(:)?("+E2.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+C2.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...u,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...u,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:S2.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...u,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+j2.join("|")+")\\b"}]}}function I2(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 T2(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 po="[0-9](_*[0-9])*",Eu=`\\.(${po})`,Cu="[0-9a-fA-F](_*[0-9a-fA-F])*",by={className:"number",variants:[{begin:`(\\b(${po})((${Eu})|\\.)?|(${Eu}))[eE][+-]?(${po})[fFdD]?\\b`},{begin:`\\b(${po})((${Eu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Eu})[fFdD]?\\b`},{begin:`\\b(${po})[fFdD]\\b`},{begin:`\\b0[xX]((${Cu})\\.?|(${Cu})?\\.(${Cu}))[pP][+-]?(${po})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Cu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function kw(e,t,n){return n===-1?"":e.replace(t,r=>kw(e,t,n-1))}function $2(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r="(?:(?:\\s*\\[\\s*])+)?",i=n+"<@@@>"+r,c="(?:"+("\\?(?:\\s+(?:extends|super)\\s+"+i+")?")+"|"+i+")",u=kw("(?:\\s*<\\s*"+c+"(?:\\s*,\\s*"+c+")*\\s*>)?",/<@@@>/g,2),g={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},x={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},y={className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:g,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{beginKeywords:"new throw return else yield assert",relevance:0},{begin:[n,t.concat(u,r,/\s+/),n,r,/\s*/,/=(?!=)/],className:{1:"type",3:"variable",6:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{begin:[n,t.concat(u,r,/\s+/),n,/\s*(?=\()/],className:{1:"type",3:"title.function"},keywords:g,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[x,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,by,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},by,x]}}const ky="[A-Za-z$_][0-9A-Za-z$_]*",M2=["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"],R2=["true","false","null","undefined","NaN","Infinity"],Nw=["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"],ww=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],jw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],O2=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],z2=[].concat(jw,Nw,ww);function P2(e){const t=e.regex,n=(H,{after:W})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,W)!==-1},r=ky,i={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,W)=>{const K=H[0].length+H.index,q=H.input[K];if(q==="<"||q===","){W.ignoreMatch();return}q===">"&&(n(H,{after:K})||W.ignoreMatch());let Y;const fe=H.input.substring(K);if(Y=fe.match(/^\s*=/)){W.ignoreMatch();return}if((Y=fe.match(/^\s+extends\s+/))&&Y.index===0){W.ignoreMatch();return}}},u={$pattern:ky,keyword:M2,literal:R2,built_in:z2,"variable.language":O2},h="[0-9](_?[0-9])*",d=`\\.(${h})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${d})|\\.)?|(${d}))[eE][+-]?(${h})\\b`},{begin:`\\b(${p})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},E={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},T={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},k=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,E,N,{match:/\$\d+/},m];g.contains=k.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(k)});const I=[].concat(T,g.contains),L=I.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(I)}]),z={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:L},U={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},V={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:{_:[...Nw,...ww]}},$={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[z],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function B(H){return t.concat("(?!",H.join("|"),")")}const _={match:t.concat(/\b/,B([...jw,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},C={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},R={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},z]},M="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(M)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[z]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:L,CLASS_REFERENCE:V},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),$,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,E,N,T,{match:/\$\d+/},m,V,{scope:"attr",match:r+t.lookahead(":"),relevance:0},F,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,e.REGEXP_MODE,{className:"function",begin:M,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:i.begin,end:i.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[z,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[z]},_,D,U,R,{match:/\$[(.]/}]}}const L2="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",D2={scope:"number",match:L2,relevance:0};function F2(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,i,D2,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function B2(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={match:/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},u=/[A-Za-z][A-Za-z0-9+.-]*/,h={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,u,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},d={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(d,{contains:[]}),g=e.inherit(p,{contains:[]});d.contains.push(g),p.contains.push(m);let x=[n,h];return[d,p,m,g].forEach(w=>{w.contains=w.contains.concat(x)}),x=x.concat(d,p),{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,r,d,p,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},i,h,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function U2(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","lazy","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],u={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","aiter","all","anext","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozendict","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","sentinel","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},h={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:u,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,h],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,h],relevance:10},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,h,p,d]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,h,p,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,d]},{begin:/([fFtT][rR]|[rR][fFtT]|[fFtT])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,d]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",x=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,y=`\\b|${r.join("|")}`,E={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${x}))[eE][+-]?(${g})[jJ]?(?=${y})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${y})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${y})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${y})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${y})`},{begin:`\\b(${g})[jJ](?=${y})`}]},N={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:u,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},w={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:["self",h,E,m,e.HASH_COMMENT_MODE]}]};return d.contains=[m,E,h],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:u,illegal:/(<\/|\?)|=>/,contains:[h,E,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,N,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[w]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[E,w,m]}]}}function H2(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),o={scope:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!(?:let|for|while|if|else|match)\b)/,i,t.lookahead(/\s*\(/))},c="([ui](8|16|32|64|128|size)|f(16|32|64|128))?",u=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","raw","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],h=["true","false","Some","None","Ok","Err"],d=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f16","f32","f64","f128","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:u,literal:h,built_in:d},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{scope:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|"|\\|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{scope:"number",variants:[{begin:"\\b0b([01_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],relevance:0},{begin:[/\bsafe/,/\s+/,/extern/],scope:{1:"keyword",3:"keyword"}},{begin:[/fn/,/\s+/,r],scope:{1:"keyword",3:"title.function"}},{scope:"meta",begin:"#!?\\[",end:"\\]",contains:[{scope:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],scope:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],scope:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],scope:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:d,type:p}},{scope:"punctuation",begin:"->"},o]}}function Z2(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],c=["double precision","large object","with timezone","without timezone"],u=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],h=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],g=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],x=p,y=[...d,...h].filter(L=>!p.includes(L)),E={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},N={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},w={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function T(L){return t.concat(/\b/,t.either(...L.map(z=>z.replace(/\s+/,"\\s+"))),/\b/)}const k={scope:"keyword",match:T(g),relevance:0};function I(L,{exceptions:z,when:U}={}){const V=U;return z=z||[],L.map($=>$.match(/\|\d+$/)||z.includes($)?$:V($)?`${$}|0`:$)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:I(y,{when:L=>L.length<3}),literal:o,type:u,built_in:m},contains:[{scope:"type",match:T(c)},k,w,E,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,N]}}const od="[A-Za-z$_][0-9A-Za-z$_]*",Sw=["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"],_w=["true","false","null","undefined","NaN","Infinity"],Ew=["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"],Cw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Aw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Iw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","self","global"],Tw=[].concat(Aw,Ew,Cw);function W2(e){const t=e.regex,n=(H,{after:W})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,W)!==-1},r=od,i={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,W)=>{const K=H[0].length+H.index,q=H.input[K];if(q==="<"||q===","){W.ignoreMatch();return}q===">"&&(n(H,{after:K})||W.ignoreMatch());let Y;const fe=H.input.substring(K);if(Y=fe.match(/^\s*=/)){W.ignoreMatch();return}if((Y=fe.match(/^\s+extends\s+/))&&Y.index===0){W.ignoreMatch();return}}},u={$pattern:od,keyword:Sw,literal:_w,built_in:Tw,"variable.language":Iw},h="[0-9](_?[0-9])*",d=`\\.(${h})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${d})|\\.)?|(${d}))[eE][+-]?(${h})\\b`},{begin:`\\b(${p})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:u,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},y={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"css"}},E={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,g]},T={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},k=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,E,N,{match:/\$\d+/},m];g.contains=k.concat({begin:/\{/,end:/\}/,keywords:u,contains:["self"].concat(k)});const I=[].concat(T,g.contains),L=I.concat([{begin:/(\s*)\(/,end:/\)/,keywords:u,contains:["self"].concat(I)}]),z={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:u,contains:L},U={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},V={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:{_:[...Ew,...Cw]}},$={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[z],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function B(H){return t.concat("(?!",H.join("|"),")")}const _={match:t.concat(/\b/,B([...Aw,"super","import","await"].map(H=>`${H}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},C={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},R={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},z]},M="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",F={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(M)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[z]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:u,exports:{PARAMS_CONTAINS:L,CLASS_REFERENCE:V},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),$,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,y,E,N,T,{match:/\$\d+/},m,V,{scope:"attr",match:r+t.lookahead(":"),relevance:0},F,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,e.REGEXP_MODE,{className:"function",begin:M,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:i.begin,end:i.end},{match:o},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},P,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[z,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},C,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[z]},_,D,U,R,{match:/\$[(.]/}]}}function V2(e){const t=e.regex,n=W2(e),r=od,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},u={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},h=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:od,keyword:Sw.concat(h),literal:_w,built_in:Tw.concat(i),"variable.language":Iw},p={className:"meta",begin:"@"+r},m=(E,N,w)=>{const T=E.contains.findIndex(k=>k.label===N);if(T===-1)throw new Error("can not find mode to replace");E.contains.splice(T,1,w)};Object.assign(n.keywords,d),n.exports.PARAMS_CONTAINS.push(p);const g=n.contains.find(E=>E.scope==="attr"),x=Object.assign({},g,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,x]),n.contains=n.contains.concat([p,o,c,x]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",u);const y=n.contains.find(E=>E.label==="func.def");return y.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function q2(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},c=e.inherit(o,{begin:/\(/,end:/\)/}),u=e.inherit(e.APOS_STRING_MODE,{className:"string"}),h=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,h,u,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,c,h,u]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[h]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:"css"}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:"javascript"}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:d}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function G2(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},u=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},x={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},y={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},E={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},N=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},g,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},y,E,o,c],w=[...N];return w.pop(),w.push(u),x.contains=w,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:N}}for(const[e,t]of Object.entries({bash:b2,css:A2,diff:I2,go:T2,java:$2,javascript:P2,json:F2,markdown:B2,python:U2,rust:H2,sql:Z2,typescript:V2,xml:q2,yaml:G2}))jr.registerLanguage(e,t);jr.registerAliases(["sh","shell","zsh","console"],{languageName:"bash"});jr.registerAliases(["ts","tsx","mts","cts"],{languageName:"typescript"});jr.registerAliases(["js","jsx","mjs","cjs"],{languageName:"javascript"});jr.registerAliases(["html","svg","vue"],{languageName:"xml"});jr.registerAliases(["py"],{languageName:"python"});jr.registerAliases(["yml"],{languageName:"yaml"});jr.registerAliases(["rs"],{languageName:"rust"});jr.registerAliases(["md"],{languageName:"markdown"});const Ny=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");Ct.setOptions({gfm:!0,breaks:!1});Ct.use({renderer:{code({text:e,lang:t}){const n=(t??"").trim().split(/\s+/)[0]??"",i=n!==""&&jr.getLanguage(n)!==void 0?jr.highlight(e,{language:n,ignoreIllegals:!0}).value:Ny(e);return`<div class="code-block"><div class="code-head"><span class="code-lang">${Ny(n===""?"text":n)}</span><button type="button" class="code-copy" data-copy="">复制</button></div><pre><code class="hljs">${i}</code></pre></div>`}}});function K2(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(/[#?].*$/,"")}Zm.addHook("beforeSanitizeAttributes",e=>{if(e.tagName!=="A")return;const t=K2(e.getAttribute("href")??"");t!==void 0&&(e.removeAttribute("href"),e.setAttribute("data-local-path",t),e.setAttribute("title",t),e.classList.add("local-path"))});Zm.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 Y2(e){var o;const t=e.dataset.localPath;if(t===void 0)return;const n=c=>{e.dataset.note=c,setTimeout(()=>{delete e.dataset.note},2200)},r=wr();if((r==null?void 0:r.openPath)!==void 0){r.openPath(t).then(c=>n(c==="missing"?"找不到这个文件":c==="revealed"?"已在文件夹中显示":"已打开"),()=>n("打不开"));return}(((o=navigator.clipboard)==null?void 0:o.writeText(t))??Promise.reject(new Error("no clipboard"))).then(()=>n("浏览器里打不开本地文件,路径已复制"),()=>n($w(t)?"浏览器里打不开本地文件,路径已复制":t))}function X2(e){var u,h;const t=e.target.closest("a[data-local-path]");if(t!==null){e.preventDefault(),Y2(t);return}const n=e.target.closest("button[data-copy]"),r=(u=n==null?void 0:n.closest(".code-block"))==null?void 0:u.querySelector("pre");if(n==null||r==null)return;const i=r.innerText,o=d=>{n.textContent=d?"已复制":"复制失败",n.classList.toggle("copied",d),setTimeout(()=>{n.textContent="复制",n.classList.remove("copied")},1600)};(((h=navigator.clipboard)==null?void 0:h.writeText(i))??Promise.reject(new Error("no clipboard"))).then(()=>o(!0),()=>o($w(i)))}function $w(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 Nr=b.memo(function({text:t,className:n}){const r=b.useMemo(()=>Zm.sanitize(Ct.parse(t,{async:!1})),[t]);return s.jsx("div",{className:`markdown ${n??""}`,onClick:X2,dangerouslySetInnerHTML:{__html:r}})}),Q2=5*6e4,Mw=["周日","周一","周二","周三","周四","周五","周六"],ld=e=>{const t=new Date(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()},Zu=e=>`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`;function J2(e,t=Date.now()){const n=new Date(e),r=Math.round((ld(t)-ld(e))/864e5);return r===0?Zu(n):r===1?`昨天 ${Zu(n)}`:`${n.getFullYear()===new Date(t).getFullYear()?"":`${n.getFullYear()}年`}${n.getMonth()+1}月${n.getDate()}日${Mw[n.getDay()]} ${Zu(n)}`}function cd(e){const t=new Date(e);return`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日${Mw[t.getDay()]} ${Zu(t)}:${String(t.getSeconds()).padStart(2,"0")}`}function Rw(e,t){return e===void 0?!1:t===void 0||e-t>=Q2||ld(e)!==ld(t)}function Ow({at:e}){return s.jsx("div",{className:"time-divider",title:cd(e),children:s.jsx("span",{children:J2(e)})})}function zw(e){const t=b.useRef(!0),n=b.useRef(0);return{following:t,onScroll:r=>{const i=r.currentTarget,o=i.scrollHeight-i.scrollTop-i.clientHeight,c=i.scrollTop<n.current-1;n.current=i.scrollTop,o<=2?t.current=!0:c?t.current=!1:o<e&&(t.current=!0)},onWheel:r=>{r.deltaY<0&&(t.current=!1)}}}const ez=160;function Vl(e,t=ez){var r;const n=((r=e.split(/\r?\n/).find(i=>i.trim()!==""))==null?void 0:r.trim())??"";return n.length>t?`${n.slice(0,t-1)}…`:n}function wy(e,t="text"){return e.filter(n=>n.type===t).map(n=>n.text).join("")}function Ll(e){const t=Vl(wy(e));if(t!=="")return t;const n=Vl(wy(e,"reasoning"));if(n!=="")return n;const r=e.filter(c=>c.type==="tool-call").map(c=>c.name);if(r.length>0)return`→ ${r.join(", ")}`;const i=e.filter(c=>c.type==="image").length,o=e.filter(c=>c.type==="file").length;return[i>0?`${i} image(s)`:"",o>0?`${o} file(s)`:""].filter(Boolean).join(" · ")}function tz(e,t=null,n={}){var z,U,V,$,P,D,B;const r=[],i=new Map,o=[],c=new Map,u=new Map,h=new Map;let d=null,p=null,m=null,g=0,x=0;const y=(_,C)=>{let R=i.get(_);return R===void 0&&(R=Xf(`t:${_}`,_,C,!0),i.set(_,R),r.push(R)),p=null,R},E=(_,C)=>d!==null?d:(p===null&&(p=Xf(`b:${C}`,null,_,!1),r.push(p)),p),N=(_,C,R,M)=>{let F=_.steps.get(R);return F===void 0&&(F={turn:C,step:R,start:M,startKnown:!1,end:null,records:[],retries:0},_.steps.set(R,F),_.stepOrder.push(R)),F},w=(_,C,R)=>{_.records.push(R),C==null||C.records.push(R),o.push(R)},T=_=>(_.requestIndex??(_.requestIndex=++g),_.requestIndex),k=new Set;for(const _ of e)switch(x=Math.max(x,_.time),_.type){case"turn/start":{const C=Xf(`t:${_.turn}`,_.turn,_.time,!1);i.set(_.turn,C),r.push(C),d=C,p=null;break}case"turn/end":{const C=y(_.turn,_.time);C.end=_.time,C.reason=_.reason;for(const R of C.steps.values())R.end??(R.end=_.time);for(const R of c.values())R.turn===_.turn&&R.status==="running"&&(R.status="interrupted",R.end=_.time);d===C&&(d=null);break}case"step/start":{const C=y(_.turn,_.time),R=N(C,_.turn,_.step,_.time);R.start=_.time,R.startKnown=!0;break}case"step/end":{const C=y(_.turn,_.time);N(C,_.turn,_.step,_.time).end=_.time;break}case"user/message":{const C=E(_.time,_.seq);w(C,null,nz(_,C.turn));break}case"system/message":{if(_.text.trim()==="")break;const C=y(_.turn,_.time),R=N(C,_.turn,_.step,_.time),M={kind:"system",id:`system:${_.seq}`,seq:_.seq,turn:_.turn,step:_.step,start:_.time,end:_.time,status:"ok",title:"System prompt",preview:Vl(_.text),text:_.text};w(C,R,M);break}case"request/header":{m={..._.provider===void 0?{}:{provider:_.provider},..._.model===void 0?{}:{model:_.model},..._.reasoningEffort===void 0?{}:{reasoningEffort:_.reasoningEffort},toolCount:_.toolNames.length};break}case"assistant/attempt":{const C=y(_.turn,_.time),R=N(C,_.turn,_.step,_.time);Qf(R,_.timing.firstTokenAt),R.retries+=1,_.error!==void 0&&(R.lastRetryError=_.error);const M={kind:"attempt",id:`attempt:${_.seq}`,seq:_.seq,turn:_.turn,step:_.step,start:_.timing.firstChunkAt??R.start,end:_.timing.lastChunkAt??_.time,status:"error",title:"Failed attempt",preview:((z=_.error)==null?void 0:z.message)??"attempt ended without output",..._.error===void 0?{}:{error:_.error}};w(C,R,M);break}case"assistant/message":{const C=y(_.turn,_.time),R=N(C,_.turn,_.step,_.time);Qf(R,_.timing.firstTokenAt),k.add(`${_.turn}:${_.step}`);const M=_.timing.firstTokenAt,F=_.timing.lastChunkAt,H=M!==void 0&&F!==void 0?F-M:void 0,W=_.model??(m==null?void 0:m.model),K=_.provider??(m==null?void 0:m.provider),q={kind:"assistant",id:`assistant:${_.seq}`,seq:_.seq,turn:_.turn,step:_.step,start:R.start,end:F??_.time,status:_.interrupted===!0?"interrupted":"ok",title:W===void 0?"Assistant":`Assistant · ${W}`,preview:Ll(_.content),content:_.content,live:!1,interrupted:_.interrupted===!0,request:Sy({index:T(R),provider:K,model:W,reasoningEffort:m==null?void 0:m.reasoningEffort,toolCount:m==null?void 0:m.toolCount,ttftMs:jy(R),decodeMs:H,tokensPerSecond:sz((U=_.usage)==null?void 0:U.outputTokens,H),usage:_.usage,retries:R.retries,lastRetryError:R.lastRetryError})};w(C,R,q);break}case"tool/call":{const C=y(_.turn,_.time),R=N(C,_.turn,_.step,_.time),M=h.get(_.callId),F={kind:"tool",id:`tool:${_.callId}`,seq:_.seq,turn:_.turn,step:_.step,start:_.time,end:null,status:C.end===null?"running":"interrupted",title:_.name,preview:Vl(_.arguments),name:_.name,callId:_.callId,arguments:_.arguments,isError:!1,...M===void 0?{}:{approval:{approvalId:M}}};c.set(_.callId,F),w(C,R,F);break}case"tool/result":{const C=c.get(_.callId);if(C===void 0){const M=y(_.turn,_.time),F=N(M,_.turn,_.step,_.time),H={kind:"tool",id:`tool:${_.callId}`,seq:_.seq,turn:_.turn,step:_.step,start:_.time,end:_.time,status:_.isError?"error":"ok",title:"tool result",preview:Ll(_.content),name:"tool result",callId:_.callId,arguments:"",result:_.content,isError:_.isError,..._.error===void 0?{}:{error:_.error}};w(M,F,H);break}C.end=_.time,C.result=_.content,C.isError=_.isError,C.status=_.isError?"error":"ok",_.error!==void 0&&(C.error=_.error);const R=Ll(_.content);R!==""&&(C.preview=`${Vl(C.arguments,80)} ⇒ ${R}`);break}case"approval/asked":{if(_.callId===void 0)break;h.set(_.callId,_.approvalId);const C=c.get(_.callId);C!==void 0&&(C.approval={approvalId:_.approvalId,..._.reason===void 0?{}:{reason:_.reason}});break}case"approval/decided":{for(const C of c.values())((V=C.approval)==null?void 0:V.approvalId)===_.approvalId&&(C.approval={...C.approval,outcome:_.outcome});break}case"compaction/start":{const C=_.turn===null?E(_.time,_.seq):y(_.turn,_.time),R={kind:"compaction",id:`compaction:${_.compactionId}`,seq:_.seq,turn:C.turn,step:null,start:_.time,end:null,status:"running",title:"Compaction",preview:"summarizing history…",compactionId:_.compactionId};u.set(_.compactionId,R),w(C,null,R);break}case"compaction/summary":{const C=u.get(_.compactionId);if(C===void 0)break;C.shadowedTokenCount=_.shadowedTokenCount,_.usage!==void 0&&(C.usage=_.usage),C.preview=`${_.shadowedTokenCount.toLocaleString("en-US")} tokens summarized`;break}case"compaction/end":{const C=u.get(_.compactionId);if(C===void 0)break;C.end=_.time,C.status=_.error===void 0?"ok":"error",_.error!==void 0&&(C.error=_.error,C.preview=_.error);break}}if(t!==null&&!k.has(`${t.turn}:${t.step}`)){const _=y(t.turn,(($=t.deltas[0])==null?void 0:$.time)??n.now??x),C=N(_,t.turn,t.step,((P=t.deltas[0])==null?void 0:P.time)??n.now??x),R=(D=t.deltas.find(W=>W.text!==""||W.toolName!==void 0))==null?void 0:D.time;Qf(C,R);const M=rz(t.deltas),F=(B=t.deltas.at(-1))==null?void 0:B.time;F!==void 0&&(x=Math.max(x,F));const H={kind:"assistant",id:`live:${t.attemptId}`,seq:t.afterSeq,turn:t.turn,step:t.step,start:C.start,end:null,status:"running",title:(m==null?void 0:m.model)===void 0?"Assistant":`Assistant · ${m.model}`,preview:Ll(M)||"waiting for output…",content:M,live:!0,interrupted:!1,request:Sy({index:T(C),provider:m==null?void 0:m.provider,model:m==null?void 0:m.model,reasoningEffort:m==null?void 0:m.reasoningEffort,toolCount:m==null?void 0:m.toolCount,ttftMs:jy(C),retries:C.retries,lastRetryError:C.lastRetryError})};w(_,C,H)}const I=r.map(_=>({key:_.key,turn:_.turn,start:_.start,end:_.end,partialStart:_.partialStart,..._.reason===void 0?{}:{reason:_.reason},steps:_.stepOrder.map(C=>{const R=_.steps.get(C);return{turn:R.turn,step:R.step,start:R.start,end:R.end,records:R.records}}),records:_.records})),L=n.now??x;return{groups:I,records:o,totals:iz(o),span:az(o,L)}}function Xf(e,t,n,r){return{key:e,turn:t,start:n,end:null,partialStart:r,steps:new Map,stepOrder:[],records:[]}}function nz(e,t){const n=e.origin.human,r=n?"user":"context",i=e.content.filter(u=>u.type==="image").length,o=e.content.filter(u=>u.type==="file").length,c=n?"User":e.replacesHistory===!0?"Compacted history":`Context · ${e.origin.kind}`;return{kind:r,id:`user:${e.seq}`,seq:e.seq,turn:t,step:null,start:e.time,end:e.time,status:"ok",title:c,preview:e.origin.summary??Ll(e.content),content:e.content,origin:e.origin,imageCount:i,fileCount:o}}function Qf(e,t){t!==void 0&&(e.firstTokenAt===void 0||t<e.firstTokenAt)&&(e.firstTokenAt=t)}function jy(e){if(!e.startKnown||e.firstTokenAt===void 0)return;const t=e.firstTokenAt-e.start;return t>=0?t:void 0}function sz(e,t){if(!(e===void 0||t===void 0||t<=0))return e/(t/1e3)}function rz(e){const t=new Map;for(const n of e){const r=t.get(n.index);if(n.kind==="tool-args"){const i=(r==null?void 0:r.type)==="tool-call"?r:void 0;t.set(n.index,{type:"tool-call",callId:n.callId??(i==null?void 0:i.callId)??"",name:n.toolName??(i==null?void 0:i.name)??"",arguments:((i==null?void 0:i.arguments)??"")+n.text})}else{const i=n.kind==="text"?"text":"reasoning",o=(r==null?void 0:r.type)===i?r.text:"";t.set(n.index,{type:i,text:o+n.text})}}return[...t.entries()].sort((n,r)=>n[0]-r[0]).map(([,n])=>n)}function iz(e){const t={requests:0,toolCalls:0,errors:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,reasoningTokens:0};for(const n of e){n.status==="error"&&(t.errors+=1),n.kind==="tool"&&(t.toolCalls+=1);const r=n.kind==="assistant"?n.request.usage:n.kind==="compaction"?n.usage:void 0;n.kind==="assistant"&&(t.requests+=1),r!==void 0&&(t.inputTokens+=r.inputTokens,t.outputTokens+=r.outputTokens,t.cacheReadTokens+=r.cacheReadTokens??0,t.cacheWriteTokens+=r.cacheWriteTokens??0,t.reasoningTokens+=r.reasoningTokens??0)}return t}function az(e,t){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const i of e)n=Math.min(n,i.start),r=Math.max(r,i.end??Math.max(i.start,t));return Number.isFinite(n)?{start:n,end:Math.max(n,r)}:null}function Sy(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}const Pw=[{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"}],oz=new Map(Pw.flatMap((e,t)=>e.kinds.map(n=>[n,t])));function lz(e){return e.records.map(t=>{const n=t.end===null||t.end<=t.start,r={record:t,lane:oz.get(t.kind)??0,start:t.start,end:t.end===null?t.start:Math.max(t.start,t.end),instant:n};return t.kind==="assistant"&&t.request.ttftMs!==void 0&&t.end!==null?{...r,firstTokenAt:t.start+t.request.ttftMs}:r})}function cz(e,t){const n=e.end??e.start;return e.start<=t.end&&n>=t.start}function uz(e,t,n,r){const o=Math.max(10,(e.end-e.start)*n),c=e.end===e.start?.5:(t-e.start)/(e.end-e.start);let u=t-o*c,h=u+o;return h-u>=r.end-r.start?r:(u<r.start&&(h+=r.start-u,u=r.start),h>r.end&&(u-=h-r.end,h=r.end),{start:u,end:h})}function dz(e,t,n){const r=e.end-e.start,i=Math.min(Math.max(n.start,e.start+t),n.end-r);return{start:i,end:i+r}}function hz(e,t){const n=t.trim().toLowerCase();return n===""?e:e.filter(r=>r.title.toLowerCase().includes(n)||r.preview.toLowerCase().includes(n)?!0:r.kind==="tool"?r.arguments.toLowerCase().includes(n):!1)}function Os(e){if(e==null||!Number.isFinite(e))return"—";if(e<1e3)return`${Math.round(e)} ms`;const t=e/1e3;if(t<60)return`${t.toFixed(t<10?2:1)} s`;const n=Math.floor(t/60);return n<60?`${n}m ${String(Math.floor(t%60)).padStart(2,"0")}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,"0")}m`}function vn(e){return e==null?"—":e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(e<1e4?2:1)}k`:`${(e/1e6).toFixed(2)}M`}function Zi(e){const t=new Date(e),n=(r,i=2)=>String(r).padStart(i,"0");return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(),3)}`}function eg(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}var tg=hk();const _y=["#ff3b30","#ffcc00","#34c759","#0a84ff","#000000","#ffffff"],fz=[["rect","框"],["arrow","箭头"],["line","直线"],["pen","画笔"]],Ey=[[2,"细"],[4,"中"],[7,"粗"]],pz=.05,Cy=16,Ay=44;function ng({src:e,width:t,height:n,name:r,onClose:i}){const[o,c]=b.useState({src:e,width:t,height:n}),{src:u,width:h,height:d}=o,p=b.useRef(null),m=b.useRef(null),[g,x]=b.useState(()=>mz(t,n)),[y,E]=b.useState({scale:1,x:0,y:0}),[N,w]=b.useState(!1),[T,k]=b.useState("rect"),[I,L]=b.useState(_y[0]),[z,U]=b.useState(Ey[0][0]),[V,$]=b.useState([]),[P,D]=b.useState(null),[B,_]=b.useState(!0),[C,R]=b.useState(null),M=b.useRef(null),F=b.useRef(null),H=b.useCallback(()=>{var Le;const ae=(Le=p.current)==null?void 0:Le.getBoundingClientRect();if(ae===void 0||ae.width===0)return;const pe=Math.min(Cy,(ae.width-24)/h,(ae.height-24)/d);E({scale:pe,x:(ae.width-h*pe)/2,y:(ae.height-d*pe)/2})},[h,d]);b.useLayoutEffect(H,[H]),b.useEffect(()=>{const ae=p.current;if(ae===null||typeof ResizeObserver>"u")return;const pe=new ResizeObserver(()=>H());return pe.observe(ae),()=>pe.disconnect()},[H]);const W=(ae,pe,Le)=>{var tt;const Te=(tt=p.current)==null?void 0:tt.getBoundingClientRect();if(Te===void 0)return;const Ge=pe??Te.width/2,Ae=Le??Te.height/2;E(et=>{const jt=Math.min(Cy,Math.max(pz,et.scale*ae)),zn=jt/et.scale;return{scale:jt,x:Ge-(Ge-et.x)*zn,y:Ae-(Ae-et.y)*zn}})},K=()=>{var pe;const ae=(pe=p.current)==null?void 0:pe.getBoundingClientRect();ae!==void 0&&E({scale:1,x:(ae.width-h)/2,y:(ae.height-d)/2})};b.useEffect(()=>{const ae=p.current;if(ae===null)return;const pe=Le=>{Le.preventDefault();const Te=ae.getBoundingClientRect();W(Math.exp(-Le.deltaY*.0015),Le.clientX-Te.left,Le.clientY-Te.top)};return ae.addEventListener("wheel",pe,{passive:!1}),()=>ae.removeEventListener("wheel",pe)});const q=ae=>{R(ae),setTimeout(()=>R(pe=>pe===ae?null:pe),1800)},Y=b.useCallback(async(ae,pe=0)=>{const Le=new Image;Le.src=u,await Le.decode();const Te=document.createElement("canvas");Te.width=h,Te.height=d;const Ge=Te.getContext("2d");Ge.drawImage(Le,0,0,h,d);for(const et of ae)vz(Ge,et);if(pe===0)return Te;const Ae=document.createElement("canvas");Ae.width=d,Ae.height=h;const tt=Ae.getContext("2d");return tt.translate(d/2,h/2),tt.rotate(pe),tt.drawImage(Te,-h/2,-d/2),Ae},[u,h,d]),fe=b.useCallback(async ae=>{try{const pe=await Y(ae),Le=await new Promise((Te,Ge)=>pe.toBlob(Ae=>Ae===null?Ge(new Error("没能生成图片")):Te(Ae),"image/png"));try{await navigator.clipboard.write([new ClipboardItem({"image/png":Le})])}catch(Te){const Ge=wr();if((Ge==null?void 0:Ge.copyImage)===void 0)throw Te;await Ge.copyImage(pe.toDataURL("image/png"))}q(ae.length>0?"已复制(带标注)":"已复制")}catch(pe){q(`复制失败:${pe instanceof Error?pe.message:String(pe)}`)}},[Y]),me=async()=>{const ae=await Y(V),pe=document.createElement("a");pe.href=ae.toDataURL("image/png"),pe.download=`${r.replace(/[\\/:*?"<>|]/g,"_").replace(/\.\w+$/,"")}${V.length>0?"-标注":""}.png`,pe.click()},xe=async()=>{const ae=await Y(V,Math.PI/2);$([]),c({src:ae.toDataURL("image/png"),width:ae.width,height:ae.height})},oe=()=>$(ae=>ae.slice(0,-1));b.useEffect(()=>{const ae=pe=>{if(!(m.current===null||!m.current.contains(document.activeElement))){if(pe.key==="Escape"){P!==null?(D(null),M.current=null):N?w(!1):i();return}if((pe.ctrlKey||pe.metaKey)&&pe.key.toLowerCase()==="z"){pe.preventDefault(),oe();return}if((pe.ctrlKey||pe.metaKey)&&pe.key.toLowerCase()==="c"){pe.preventDefault(),fe(V);return}pe.key==="0"&&H(),(pe.key==="+"||pe.key==="=")&&W(1.25),pe.key==="-"&&W(.8)}};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)});const re=ae=>{const pe=p.current.getBoundingClientRect(),Le=(ae.clientX-pe.left-y.x)/y.scale,Te=(ae.clientY-pe.top-y.y)/y.scale;return[Math.max(0,Math.min(h,Le)),Math.max(0,Math.min(d,Te))]},ie=ae=>{if(ae.button!==0&&ae.button!==1)return;if(ae.currentTarget.setPointerCapture(ae.pointerId),!N||ae.button===1){M.current={kind:"pan",sx:ae.clientX,sy:ae.clientY,ox:y.x,oy:y.y};return}const[pe,Le]=re(ae),Te=z/y.scale;M.current={kind:"mark"},D(T==="pen"?{kind:"pen",points:[[pe,Le]],color:I,width:Te}:{kind:T,x1:pe,y1:Le,x2:pe,y2:Le,color:I,width:Te})},ye=ae=>{const pe=M.current;if(pe===null)return;if(pe.kind==="pan"){E(Ge=>({...Ge,x:pe.ox+ae.clientX-pe.sx,y:pe.oy+ae.clientY-pe.sy}));return}const[Le,Te]=re(ae);D(Ge=>Ge===null?Ge:Ge.kind==="pen"?{...Ge,points:[...Ge.points,[Le,Te]]}:{...Ge,x2:Le,y2:Te})},De=()=>{const ae=M.current;if(M.current=null,(ae==null?void 0:ae.kind)!=="mark"||P===null||(D(null),(P.kind==="pen"?P.points.length>2?99:0:Math.hypot(P.x2-P.x1,P.y2-P.y1)*y.scale)<4))return;const Le=[...V,P];$(Le),B&&fe(Le)},de=ae=>{if(ae.target.closest("button")!==null)return;ae.currentTarget.setPointerCapture(ae.pointerId),F.current={sx:ae.clientX,sy:ae.clientY,ox:g.x,oy:g.y};const pe=m.current;pe!==null&&x(Le=>({...Le,w:pe.offsetWidth,h:pe.offsetHeight}))},Se=ae=>{const pe=F.current;pe!==null&&x(Le=>({...Le,x:Math.max(-Le.w+120,Math.min(window.innerWidth-120,pe.ox+ae.clientX-pe.sx)),y:Math.max(0,Math.min(window.innerHeight-40,pe.oy+ae.clientY-pe.sy))}))};return b.useEffect(()=>{var ae;(ae=m.current)==null||ae.focus()},[]),tg.createPortal(s.jsxs("div",{ref:m,className:"image-viewer",role:"dialog","aria-label":r,tabIndex:-1,style:{left:g.x,top:g.y,width:g.w,height:g.h},children:[s.jsxs("div",{className:"viewer-title",onPointerDown:de,onPointerMove:Se,onPointerUp:()=>{F.current=null},onDoubleClick:H,children:[s.jsx("span",{className:"viewer-name",children:r}),s.jsxs("span",{className:"viewer-dim",children:[h,"×",d]}),s.jsx("button",{className:"viewer-icon",onClick:i,title:"关闭(Esc)","aria-label":"关闭",children:"✕"})]}),s.jsxs("div",{ref:p,className:`viewer-stage ${N?"marking":""}`,onPointerDown:ie,onPointerMove:ye,onPointerUp:De,onPointerCancel:De,children:[s.jsxs("div",{className:"viewer-canvas",style:{width:h,height:d,transform:`translate(${y.x}px, ${y.y}px) scale(${y.scale})`},children:[s.jsx("img",{src:u,alt:r,width:h,height:d,draggable:!1}),s.jsx("svg",{viewBox:`0 0 ${h} ${d}`,width:h,height:d,"aria-hidden":"true",children:[...V,...P===null?[]:[P]].map((ae,pe)=>s.jsx(xz,{mark:ae},pe))})]}),C!==null&&s.jsx("div",{className:"viewer-toast",role:"status",children:C})]}),N&&s.jsxs("div",{className:"viewer-marks",children:[s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"标注工具",children:fz.map(([ae,pe])=>s.jsx("button",{role:"radio","aria-checked":T===ae,className:`viewer-icon ${T===ae?"active":""}`,title:pe,onClick:()=>k(ae),children:s.jsx(gz,{tool:ae})},ae))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"粗细",children:Ey.map(([ae,pe])=>s.jsx("button",{role:"radio","aria-checked":z===ae,className:`viewer-icon ${z===ae?"active":""}`,title:pe,onClick:()=>U(ae),children:s.jsx("span",{className:"width-dot",style:{width:ae+3,height:ae+3}})},ae))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("div",{className:"viewer-group",role:"radiogroup","aria-label":"颜色",children:_y.map(ae=>s.jsx("button",{role:"radio","aria-checked":I===ae,"aria-label":ae,className:`swatch ${I===ae?"active":""}`,style:{background:ae},onClick:()=>L(ae)},ae))}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",disabled:V.length===0,onClick:oe,title:"撤销(Ctrl+Z)",children:"↶"}),s.jsxs("label",{className:"viewer-check",title:"每画完一笔就把带标注的图片复制到剪贴板",children:[s.jsx("input",{type:"checkbox",checked:B,onChange:ae=>_(ae.target.checked)}),"自动复制"]})]}),s.jsxs("div",{className:"viewer-bar",children:[s.jsx("button",{className:"viewer-icon",onClick:()=>W(.8),title:"缩小",children:"-"}),s.jsxs("button",{className:"viewer-zoom",onClick:H,title:"适应窗口(0)",children:[Math.round(y.scale*100),"%"]}),s.jsx("button",{className:"viewer-icon",onClick:()=>W(1.25),title:"放大",children:"+"}),s.jsx("button",{className:"viewer-icon",onClick:K,title:"原始大小",children:"1:1"}),s.jsx("span",{className:"viewer-sep"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void xe(),title:"旋转",children:"⟳"}),s.jsx("button",{className:`viewer-icon ${N?"active":""}`,onClick:()=>w(ae=>!ae),title:"标注:画框、箭头、直线",children:"✎"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void fe(V),title:"复制(Ctrl+C)",children:"⧉"}),s.jsx("button",{className:"viewer-icon",onClick:()=>void me(),title:"保存",children:"⤓"})]})]}),document.body)}function mz(e,t){const n=Math.round(window.innerWidth*.7),r=Math.round(window.innerHeight*.78)-Ay*2,i=Math.min(1,n/e,r/t),o=Math.max(420,Math.round(e*i)+24),c=Math.max(300,Math.round(t*i)+24+Ay*2);return{x:Math.round((window.innerWidth-o)/2),y:Math.max(16,Math.round((window.innerHeight-c)/2)),w:o,h:c}}function gz({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 Lw(e){const t=Math.atan2(e.y2-e.y1,e.x2-e.x1),n=e.width*4.5;return[-.5,.5].map(r=>[e.x2-n*Math.cos(t+r),e.y2-n*Math.sin(t+r)])}function xz({mark:e}){const t={stroke:e.color,strokeWidth:e.width,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"};if(e.kind==="pen")return s.jsx("polyline",{...t,points:e.points.map(r=>r.join(",")).join(" ")});if(e.kind==="rect")return s.jsx("rect",{...t,x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)});const n=e.kind==="arrow"?Lw(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 vz(e,t){if(e.strokeStyle=t.color,e.lineWidth=t.width,e.lineCap="round",e.lineJoin="round",e.beginPath(),t.kind==="pen")t.points.forEach(([n,r],i)=>i===0?e.moveTo(n,r):e.lineTo(n,r));else if(t.kind==="rect")e.rect(Math.min(t.x1,t.x2),Math.min(t.y1,t.y2),Math.abs(t.x2-t.x1),Math.abs(t.y2-t.y1));else if(e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),t.kind==="arrow"){const[n,r]=Lw(t);e.moveTo(n[0],n[1]),e.lineTo(t.x2,t.y2),e.lineTo(r[0],r[1])}e.stroke()}const sg=b.createContext(null),Jf=new Map;function yz(e,t){let n=Jf.get(t.attachmentId);if(n===void 0){const{attachmentId:r,mediaType:i,bytes:o,width:c,height:u}=t;n=e.connection.call("attachments/image",{attachmentId:r,mediaType:i,bytes:o,width:c,height:u}).then(h=>`data:${h.mediaType};base64,${h.data}`),n.catch(()=>Jf.delete(t.attachmentId)),Jf.set(t.attachmentId,n)}return n}function Dw({image:e}){const t=b.useContext(sg),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!1),h=(t==null?void 0:t.capabilities.get().has("attachments"))===!0;b.useEffect(()=>{if(t===null||!h)return;let p=!0;return yz(t,e).then(m=>{p&&r(m)},m=>{p&&o(m instanceof Error?m.message:String(m))}),()=>{p=!1}},[t,h,e]);const d=e.name??`${e.width}×${e.height} 图片`;return h?i!==null?s.jsxs("span",{className:"stored-image missing",children:[d,"没能加载:",i]}):n===null?s.jsx("span",{className:"stored-image loading",style:{aspectRatio:`${e.width} / ${e.height}`}}):s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"stored-image",onClick:()=>u(!0),title:"点击放大、标注、复制",children:s.jsx("img",{src:n,alt:d,width:e.width,height:e.height})}),c&&s.jsx(ng,{src:n,width:e.width,height:e.height,name:e.name??"screenshot.png",onClose:()=>u(!1)})]}):s.jsxs("span",{className:"stored-image missing",children:[d,"(当前后端不支持显示图片)"]})}const bz=3,kz=/^(编排|游戏信息|干预)[::]/,Iy="adg:skill-offer:off",Ty=e=>`adg:skill-offer:${e}`;function $y(e){try{return localStorage.getItem(e)}catch{return null}}function My(e,t){try{localStorage.setItem(e,t)}catch{}}function Nz(e){var i;let t=e.length-1;for(;t>=0&&e[t].kind!=="user";)t--;if(t<0)return;const n=e.slice(t+1),r=n.filter(o=>o.kind==="tool");if(!r.some(o=>o.name==="skill"||o.name==="skill_save"||o.status!=="ok")&&!n.some(o=>o.kind==="notice"&&o.tone==="error")&&!n.some(o=>o.kind==="context")&&!(r.length<bz||((i=n.at(-1))==null?void 0:i.kind)!=="assistant"))return e[t].id}function wz({session:e,title:t,items:n}){const r=Nz(n),[i,o]=b.useState(()=>$y(Iy)==="1"),[c,u]=b.useState(()=>$y(Ty(e.id))),[h,d]=b.useState(!1);if(r===void 0||i||c===r||t!==null&&kz.test(t))return null;const p=()=>{My(Ty(e.id),r),u(r)},m=async()=>{d(!0);try{await e.prompt(gN),p()}finally{d(!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:()=>{My(Iy,"1"),o(!0)},children:"不再提示"}),s.jsx("button",{className:"small-button",disabled:h,onClick:p,children:"这次不用"}),s.jsx("button",{className:"small-button primary",disabled:h,onClick:()=>void m(),children:"存成技能"})]})]})}function jz(e,t){const n=je(e.connection.status),r=je(e.capabilities),[i,o]=b.useState([]),c=t&&r.has("notify");return b.useEffect(()=>{if(!c||n.state!=="open")return;let u=!0;return e.connection.call("notify/notices",{}).then(h=>{u&&o(h.items)}).catch(()=>{}),()=>{u=!1}},[e,c,n.state]),b.useEffect(()=>{if(c)return e.connection.on("notify/notice",({item:u})=>o(h=>h.findIndex(p=>p.id===u.id)<0?[...h,u]:h.map(p=>p.id===u.id?u:p)))},[e,c]),c?i:[]}function Sz(e,t,n,r){const i=t.filter(d=>d.at>=n);if(i.length===0)return[...e];const o=new Array(e.length);let c=1/0;for(let d=e.length-1;d>=0;d--){const p=e[d];"time"in p&&typeof p.time=="number"&&(c=p.time),o[d]=c}const u=[];let h=0;for(e.forEach((d,p)=>{if(r(d))for(;h<i.length&&i[h].at<o[p];)u.push(Ry(i[h++]));u.push(d)});h<i.length;)u.push(Ry(i[h++]));return u}function Ry(e){return{kind:"sent",id:`sent:${e.id}`,notice:e}}const _z={info:"send",success:"check",warning:"alert",error:"alert"};function Ez({client:e,notice:t}){const[n,r]=b.useState(null),[i,o]=b.useState(null),c=t.acted===void 0&&t.done===void 0&&t.actions.length>0,u=d=>{r(d),o(null),e.connection.call("notify/act",{noticeId:t.id,actionId:d}).catch(p=>o(Re(p))).finally(()=>r(null))},h=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:_z[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("、")}`:"只在软件里"," · ",h]})]}),s.jsx("div",{className:"sent-notice-text",children:t.text}),t.image===!0&&s.jsx("div",{className:"muted small",children:"(附了一张截图,在聊天软件里看)"}),c&&s.jsxs("div",{className:"sent-notice-actions",children:[t.actions.map(d=>s.jsx("button",{className:`small-button ${d.style==="primary"?"primary":d.style==="danger"?"danger-outline":""}`,disabled:n!==null,onClick:()=>u(d.id),children:n===d.id?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),d.label]}):d.label},d.id)),s.jsx("span",{className:"muted small",children:"也可以直接跟助手说"})]}),t.acted!==void 0&&s.jsxs("div",{className:"sent-notice-result",children:[s.jsx(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]}),i!==null&&s.jsx("div",{className:"error small",children:i})]})}const Cz=80;function Fw({client:e,session:t,state:n,readOnly:r}){var M,F,H;const i=b.useMemo(()=>wN(n.events,n.live,n.pending),[n.events,n.live,n.pending,n.version]),o=b.useMemo(()=>i.filter(W=>!Gw(W)),[i]),c=b.useMemo(()=>Vz(i),[i]),u=TN(e,Rs),h=jz(e,u.sessionId===t.id),d=n.hasMore?((M=n.events[0])==null?void 0:M.time)??0:0,p=b.useMemo(()=>Mz(Sz(o,h,d,Uw)),[o,h,d]),m=Er(e),g=je(e.sessions).items.find(W=>W.id===t.id),x=g===void 0?Rs:Aa(g,m),y=b.useContext(rg),E=b.useContext(Oo),N=y!==null?E:((F=m.find(W=>W.id===x))==null?void 0:F.name)??Rn.name,[w,T]=Jz(x),k=y===null?w:3,I=b.useMemo(()=>$z(p,k),[p,k]),L=b.useMemo(()=>{let W;return I.map(K=>{const q=Iz(K),Y=Rw(q,W)?q:void 0;return q!==void 0&&(W=q),Y})},[I]),[z,U]=b.useState(null),V=cR(e,t.id),$=V.filter(W=>W.fromSession===t.id&&W.callId===void 0&&(W.state==="running"||W.state==="waiting")),P=b.useRef(null),D=zw(Cz),B=D.following,_=W=>{D.onScroll(W),W.currentTarget.scrollTop<40&&n.hasMore&&!n.loadingOlder&&t.loadOlder()};b.useLayoutEffect(()=>{const W=P.current;W!==null&&B.current&&(W.scrollTop=W.scrollHeight)},[o,h]);const C=(H=n.events[0])==null?void 0:H.seq,R=b.useRef(0);return b.useLayoutEffect(()=>{const W=P.current;W!==null&&(R.current!==0&&!B.current&&(W.scrollTop+=W.scrollHeight-R.current),R.current=W.scrollHeight)},[C]),s.jsx(sg.Provider,{value:e,children:s.jsx(ej.Provider,{value:V,children:s.jsx(Oo.Provider,{value:N,children:s.jsx(ig.Provider,{value:U,children:s.jsx(Kw.Provider,{value:c,children:s.jsxs("div",{className:`chat-split ${z===null?"":"with-pane"}`,children:[y===null&&p.some(W=>Bw(W)>1)&&s.jsx(tP,{detail:w,onChange:T}),s.jsx("div",{className:"chat",ref:P,onScroll:_,onWheel:D.onWheel,children:s.jsxs("div",{className:"chat-inner",children:[n.hasMore&&s.jsx("button",{className:"link-button load-older",disabled:n.loadingOlder,onClick:()=>void t.loadOlder(),children:n.loadingOlder?"加载中…":"加载更早的消息"}),n.status==="opening"&&o.length===0&&s.jsx("div",{className:"empty",children:"正在打开会话…"}),n.status!=="opening"&&o.length===0&&s.jsxs("div",{className:"empty chat-empty",children:[s.jsx(Id,{size:"lg"}),s.jsx("h2",{children:"今天,我们一起完成什么?"}),s.jsxs("p",{children:["一个问题、一段代码,或一个还不成熟的想法。",s.jsx("br",{}),"在下方写下来,让对话开始。"]})]}),I.map((W,K)=>s.jsx(Tz,{at:L[K],children:W.kind==="sent"?s.jsx(Ez,{client:e,notice:W.item.notice},W.item.id):W.kind==="tools"?s.jsx(Al,{name:N,header:W.header,children:s.jsx(Zw,{tools:W.tools})},W.id):W.kind==="delegation"?s.jsx(Al,{name:N,header:W.header,children:s.jsx(rP,{client:e,item:W.item,handOffs:V})},W.item.id):W.kind==="subtask"?s.jsx(Al,{name:N,header:W.header,children:s.jsx(Xz,{client:e,item:W.item,compact:k<3})},W.item.id):W.kind==="process"?s.jsx(Al,{name:N,header:W.header,children:s.jsx(Dz,{items:W.items,active:n.running&&K===I.length-1,onDismiss:q=>t.dismissPending(q)})},W.id):s.jsx(Al,{name:N,header:W.header,children:s.jsx(Hw,{item:W.item,onDismiss:q=>t.dismissPending(q)})},W.item.id)},Az(W))),$.map(W=>s.jsx(iP,{client:e,handOff:W},W.id)),n.running&&n.live===null&&s.jsxs("div",{className:"thinking",children:[s.jsxs("span",{className:"dot-pulse",children:[s.jsx("i",{}),s.jsx("i",{}),s.jsx("i",{})]}),"正在处理…"]}),r!==!0&&!n.running&&n.queue.length===0&&s.jsx(wz,{session:t,title:n.title,items:o})]})}),z!==null&&s.jsx(Jw,{client:e,task:z,parent:N,trail:x===Rs?[]:[Rn.name],onClose:()=>U(null)},z.id)]})})})})})})}function Az(e){return e.kind==="sent"?e.item.id:e.kind==="tools"||e.kind==="process"?e.id:e.item.id}function Iz(e){var n;const t=r=>"time"in r?r.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(r=>r!==void 0);default:return t(e.item)}}function Tz({at:e,children:t}){return s.jsxs(s.Fragment,{children:[e!==void 0&&s.jsx(Ow,{at:e}),t]})}function Bw(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=xN(e.item.text);return yN(e.item.text)!==void 0||vN(e.item.text)!==void 0||t!==void 0&&t.by!==Lm?2:1}}}function $z(e,t){if(t>1)return e;const n=[];let r=null;for(const i of e)i.kind==="sent"?n.push(i):Bw(i)>1?r=i.header??r:i.kind==="item"&&i.item.kind==="user"?(r=null,n.push(i)):r!==null&&i.header===null&&!(i.kind==="item"&&(i.item.kind==="notice"||i.item.kind==="context"))?(n.push({...i,header:r}),r=null):n.push(i);return n}function Mz(e){const t=[];let n=0;for(let r=0;r<=e.length;r++){const i=e[r];i!==void 0&&i.kind!=="sent"&&!Uw(i)||(Rz(e.slice(n,r),t),i!==void 0&&t.push(i.kind==="sent"?{kind:"sent",item:i}:{kind:"item",item:i,header:null}),n=r+1)}return t}function Uw(e){return e.kind==="user"||e.kind==="context"&&e.startsTurn===!0}function Rz(e,t){let n=!1;const r=e.find(d=>d.kind==="assistant"&&d.model!==void 0),i=()=>n?null:(n=!0,{model:(r==null?void 0:r.kind)==="assistant"?r.model:void 0}),o=d=>{if(d.kind==="tool"&&d.name===Py)t.push({kind:"delegation",item:d,header:i()});else if(d.kind==="tool"&&d.name===Oy)t.push({kind:"subtask",item:d,header:i()});else if(d.kind==="tool"){const p=t.at(-1);(p==null?void 0:p.kind)==="tools"?t[t.length-1]={...p,tools:[...p.tools,d]}:t.push({kind:"tools",id:`tools-${d.id}`,tools:[d],header:i()})}else t.push({kind:"item",item:d,header:d.kind==="assistant"?i():null})};let c=[];const u=()=>{if(c.some(d=>d.kind==="tool"))t.push({kind:"process",id:`process-${c[0].id}`,items:c,header:i()});else for(const d of c)o(d);c=[]};let h=e.length;for(let d=e.length-1;d>=0;d--){const p=e[d];if(p.kind==="assistant"&&p.text.trim()!==""){h=d;break}}for(let d=0;d<h;d++){const p=e[d];p.kind==="notice"||p.kind==="context"||p.kind==="tool"&&(p.approval==="asked"||p.name===Py||p.name===Oy)?(u(),o(p)):c.push(p)}u();for(let d=h;d<e.length;d++)o(e[d])}function Al({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(Id,{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 Oz({text:e}){const t=yM(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 zz=/^(这条消息来自([^。)]+)。[^\n]*)\n/,Pz=/^(距离这个对话的上一条消息已经过了[^\n]*)\n/;function Lz(e){const t=zz.exec(e),n=(t===null?e:e.slice(t[0].length)).replace(Pz,"");return t===null?{text:n}:{text:n,channel:t[1]}}const Hw=b.memo(function({item:t,onDismiss:n}){var c;const r=b.useContext(sg),i=b.useContext(ej),o=b.useContext(rg);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(Nr,{text:qw(t.text)})})]});const u=t.pending===void 0?yN(t.text):void 0;if(u!==void 0&&r!==null)return s.jsx(aP,{client:r,note:u,handOffs:i});const h=t.pending===void 0?vN(t.text):void 0;if(h!==void 0&&r!==null)return s.jsx(oP,{client:r,note:h,handOffs:i});const d=t.pending===void 0?xN(t.text):void 0;if(d!==void 0&&r!==null)return s.jsx(lP,{client:r,note:d,handOffs:i});const p=Lz(t.text);return s.jsxs("div",{className:`msg user ${t.pending===void 0?"":"pending"}`,title:cd(t.time),children:[p.channel!==void 0&&s.jsxs("div",{className:"msg-from",children:["来自",p.channel]}),s.jsxs("div",{className:"bubble",children:[s.jsx(Oz,{text:p.text}),t.imageRefs.length>0&&s.jsx("div",{className:"chat-images",children:t.imageRefs.map(m=>s.jsx(Dw,{image:m},m.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:"移除"})]})]})}case"assistant":return!t.live&&jM(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:cd(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(Nr,{text:t.reasoning})]}),t.text!==""&&s.jsx(Nr,{text:t.text}),t.live&&s.jsx("span",{className:"cursor"}),t.interrupted&&s.jsx("div",{className:"muted small",children:"(已中断)"})]});case"tool":return s.jsx(Zw,{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 Dz({items:e,active:t,onDismiss:n}){const r=e.filter(d=>d.kind==="tool"),i=r.filter(d=>d.status==="running").length,o=r.filter(d=>d.status==="error").length,[c,u]=b.useState(!1),h=t&&!c?Fz(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:`执行了 ${r.length} 个步骤`}),h!==void 0&&h!==""&&s.jsx("span",{className:"process-now",children:h}),s.jsxs("span",{className:"tool-group-meta",children:[i>0&&s.jsxs("span",{className:"tone-running",children:[i," 个进行中"]}),o>0&&s.jsxs("span",{className:"tone-failed",children:[o," 个失败"]})]}),s.jsx(Q,{name:"chevron-down",className:`chevron-icon ${c?"open":""}`})]}),c&&e.map(d=>d.kind==="tool"?s.jsx(Vw,{item:d},d.id):s.jsx("div",{className:"process-note",children:s.jsx(Hw,{item:d,onDismiss:n})},d.id))]})}function Fz(e){return e.kind==="tool"?`${e.name} ${zm(e.arguments)}`.trim():e.kind==="assistant"?e.text.trim().split(`
195
+ `)[0]||"正在思考…":""}function Zw({tools:e}){const t=e.filter(c=>c.status==="running").length,n=e.filter(c=>c.status==="error").length,[r,i]=b.useState(null),o=r??(t>0||n>0||e.length<=4);return s.jsxs("div",{className:"tool-group",children:[s.jsxs("button",{className:"tool-group-head",onClick:()=>i(!o),"aria-expanded":o,children:[s.jsx(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(Vw,{item:c},c.id))]})}const Ww={running:"运行中",ok:"完成",error:"失败",interrupted:"已中断"};function Vw({item:e}){const[t,n]=b.useState(!1),r=b.useMemo(()=>zm(e.arguments),[e.arguments]);return b.useEffect(()=>{e.status==="error"&&n(!0)},[e.status]),s.jsxs("div",{className:`tool ${e.status}`,children:[s.jsxs("button",{className:"tool-head",onClick:()=>n(i=>!i),"aria-expanded":t,children:[s.jsx(Bz,{status:e.status}),s.jsx("span",{className:"tool-name",children:e.name}),s.jsx("span",{className:"tool-summary",children:r}),e.approval!==void 0&&s.jsx("span",{className:`badge approval-${e.approval}`,children:Uz(e.approval)}),s.jsx("span",{className:"tool-status",children:Ww[e.status]})]}),e.images!==void 0&&s.jsx("div",{className:"chat-images tool-images",children:e.images.map(i=>s.jsx(Dw,{image:i},i.attachmentId))}),t&&s.jsxs("div",{className:"tool-body",children:[s.jsx("div",{className:"label",children:"参数"}),s.jsx("pre",{children:eg(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 Bz({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":Ww[e]??e,children:s.jsx(Q,{name:"info"})})}function Uz(e){switch(e){case"asked":return"等待审批";case"allowed-once":return"已允许";case"rejected":return"已拒绝";case"cancelled":return"已撤回";default:return e}}const Oy="subagent",Hz=/started subagent (\S+)/,Zz=/\s*Your parent agent\b[\s\S]*$/;function qw(e){return e.replace(Zz,"")}const Wz=/^Background subagent (\S+) (finished|was stopped)?/;function Vz(e){const t=new Map;for(const n of e){if(!Gw(n))continue;const r=Wz.exec(n.summary);r!==null&&t.set(r[1],r[2]==="finished"?ag:r[2]==="was stopped"?Gz:Qw)}return t}function Gw(e){return e.kind==="context"&&e.title==="subagent-settled"}const Kw=b.createContext(new Map),rg=b.createContext(null),ig=b.createContext(()=>{});function qz(e){try{const t=JSON.parse(e);return{description:String(t.description??""),prompt:String(t.prompt??"")}}catch{return{description:"",prompt:e}}}function Yw(e,t){return je(e.sessions).items.find(n=>n.id===t)}const Xw={label:"进行中",tone:"running"},ag={label:"完成",tone:"ok"},Gz={label:"已停止",tone:"failed"},Qw={label:"没做成",tone:"failed"};function Kz({client:e,id:t,running:n}){const r=Ad(e,t);return r===null?s.jsx("div",{className:"subtask-steps muted small",children:"正在打开…"}):s.jsx(Yz,{handle:r,running:n})}function Yz({handle:e,running:t}){const n=je(e.state),r=b.useMemo(()=>wN(n.events,n.live,n.pending).filter(o=>o.kind==="tool"),[n.events,n.live,n.pending,n.version]);if(r.length===0)return s.jsx("div",{className:"subtask-steps muted small",children:t?"正在开始…":"没有用工具"});const i=t?r.slice(-4):r;return s.jsx("ol",{className:"subtask-steps",children:i.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:zm(o.arguments)})]},o.id))})}function Xz({client:e,item:t,compact:n}){var k;const r=b.useContext(ig),{description:i,prompt:o}=b.useMemo(()=>qz(t.arguments),[t.arguments]),c=(k=Hz.exec(t.result??""))==null?void 0:k[1],u=Yw(e,c),h=t.status==="error"||t.status==="interrupted",d=!h&&((u==null?void 0:u.running)??t.status==="running"),p=b.useContext(Kw),m=h?Qw:d?Xw:(c===void 0?void 0:p.get(c))??ag,g=AN(e,u===void 0?[]:[{id:u.id,updatedAt:u.updatedAt,running:u.running}]),x=c===void 0?void 0:g.get(c),[y,E]=b.useState(!1),N=i!==""?i:o.split(`
196
+ `)[0]??"子任务",w=s.jsxs("span",{className:`delegation-state tone-${m.tone}`,children:[m.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),m.label]});if(n)return s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:`exchange-line subtask-line tone-${m.tone}`,disabled:c===void 0,title:o,onClick:()=>{c!==void 0&&r({id:c,label:N})},children:[s.jsx(Q,{name:"flow"}),s.jsx("span",{className:"exchange-who",children:"子任务"}),s.jsx("span",{className:"exchange-title",children:N}),w,c!==void 0&&s.jsx(Q,{name:"chevron",className:"exchange-open"})]}),h&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(Q,{name:"alert"}),t.result??t.error??"没有开起来"]})]});const T=c!==void 0&&(d||y);return s.jsxs("div",{className:`subtask tone-${m.tone}`,children:[s.jsxs("div",{className:"subtask-head",children:[s.jsx(Q,{name:"flow"}),s.jsx("strong",{className:"subtask-label",title:o,children:N}),w,c!==void 0&&s.jsx("button",{className:"link-button subtask-open",onClick:()=>r({id:c,label:N}),children:"看完整过程"})]}),h&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(Q,{name:"alert"}),t.result??t.error??"没有开起来"]}),T&&s.jsx(Kz,{client:e,id:c,running:d}),!d&&x!=null&&x!==""&&s.jsx("div",{className:"subtask-answer",children:s.jsx(Nr,{text:x})}),!d&&c!==void 0&&s.jsxs("button",{className:"link-button subtask-fold","aria-expanded":y,onClick:()=>E(I=>!I),children:[s.jsx(Q,{name:y?"chevron-down":"chevron"}),y?"收起步骤":"看步骤"]})]})}function Jw({client:e,task:t,parent:n,trail:r,onClose:i}){const o=Ad(e,t.id),c=Yw(e,t.id),[u,h]=b.useState(null),d=(c==null?void 0:c.running)===!0,p=()=>e.connection.call("subagents/stop",{sessionId:t.id}).then(()=>h(null),m=>h(m instanceof Error?m.message:String(m)));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:[[...r,n].map((m,g)=>s.jsxs("span",{children:[m,s.jsx("span",{className:"subagent-trail-sep",children:"›"})]},g)),s.jsx("strong",{title:t.label,children:t.label})]}),d&&s.jsxs("button",{className:"small-button",onClick:()=>void p(),children:[s.jsx(Q,{name:"close"}),"停止"]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:"关闭",onClick:i,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(Qz,{client:e,handle:o,parent:n})})]})}function Qz({client:e,handle:t,parent:n}){const r=je(t.state);return s.jsx(rg.Provider,{value:n,children:s.jsx(Oo.Provider,{value:`${n}的子 agent`,children:s.jsx(Fw,{client:e,session:t,state:r,readOnly:!0})})})}const zy="adg.chatDetail.";function Jz(e){const t=()=>{try{const i=Number(localStorage.getItem(zy+e));return i===1||i===3?i:2}catch{return 2}},[n,r]=b.useState(t);return b.useEffect(()=>r(t()),[e]),[n,i=>{r(i);try{localStorage.setItem(zy+e,String(i))}catch{}}]}const eP=[{level:1,label:"汇报",hint:"只看它和你说的话"},{level:2,label:"协作",hint:"加上 agent 之间的往来,子任务一行"},{level:3,label:"全部",hint:"子任务也展开:步骤和答案"}];function tP({detail:e,onChange:t}){return s.jsx("div",{className:"chat-detail segmented-control",role:"radiogroup","aria-label":"显示多少",children:eP.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 nP({client:e,session:t,from:n,to:r,onOpen:i}){const o=je(e.sessions).items.filter(c=>c.origin==="subagent"&&c.parentId===t&&c.updatedAt>=n&&(r===void 0||c.updatedAt<=r+2e3));return o.length===0?null:s.jsx("div",{className:"delegation thread-subtasks",children:o.map(c=>{const u=qw(c.title??"")||"子任务",h=c.running?Xw:ag;return s.jsxs("button",{className:`exchange-line subtask-line tone-${h.tone}`,onClick:()=>i({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-${h.tone}`,children:[h.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),h.label]}),s.jsx(Q,{name:"chevron",className:"exchange-open"})]},c.id)})})}const Py="agent_delegate",ej=b.createContext([]),Oo=b.createContext(Rn.name);function gc(e){return`#/h/${encodeURIComponent(e.id)}`}function sP(e){try{const t=JSON.parse(e);return{agent:String(t.agent??""),task:String(t.task??"")}}catch{return{agent:"",task:e}}}function Qi(e,t){const r=Er(e).find(i=>i.name===t||i.id===t);return r===void 0?t===Rn.name||t===Rn.id?Rn:void 0:Wo(r)}const Sa={running:{label:"进行中",tone:"running"},waiting:{label:"等回答",tone:"running"},done:{label:"交回了",tone:"ok"},failed:{label:"没做成",tone:"failed"}};function xc({from:e,to:t,avatar:n,title:r,state:i,href:o}){const c=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`agent-avatar small agent-${(n==null?void 0:n.id)??"unknown"}`,children:s.jsx(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:r,children:r}),i!==void 0&&s.jsxs("span",{className:`delegation-state tone-${i.tone}`,children:[i.tone==="running"&&s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),i.label]}),o!==void 0&&s.jsx(Q,{name:"chevron",className:"exchange-open"})]});return o===void 0?s.jsx("div",{className:`exchange-line tone-${(i==null?void 0:i.tone)??""}`,children:c}):s.jsx("a",{className:`exchange-line tone-${(i==null?void 0:i.tone)??""}`,href:o,title:"看它们说了什么",children:c})}function rP({client:e,item:t,handOffs:n}){const{agent:r,task:i}=b.useMemo(()=>sP(t.arguments),[t.arguments]),o=Qi(e,r),c=b.useContext(Oo),u=n.find(p=>p.callId===t.callId),h=t.status==="error"||t.status==="interrupted",d=h?Sa.failed:u===void 0?t.status==="running"?Sa.running:void 0:Sa[u.state];return s.jsxs("div",{className:"delegation",children:[s.jsx(xc,{from:c,to:(o==null?void 0:o.name)??r,avatar:o,title:(u==null?void 0:u.title)??i.split(`
197
+ `)[0]??"",state:d,href:u===void 0?void 0:gc(u)}),h&&s.jsxs("div",{className:"delegation-failed",children:[s.jsx(Q,{name:"alert"}),t.result??t.error??"没有交出去"]})]})}function iP({client:e,handOff:t}){const n=Qi(e,t.to);return s.jsx("div",{className:"delegation app-handoff",children:s.jsx(xc,{from:t.by,to:(n==null?void 0:n.name)??t.to,avatar:n,title:t.title,state:Sa[t.state],href:gc(t)})})}function aP({client:e,note:t,handOffs:n}){const r=Qi(e,t.agent),i=b.useContext(Oo),o=n.filter(u=>u.state!=="running"&&u.title===t.title&&(u.to===(r==null?void 0:r.id)||u.to===t.agent)).at(-1),c=o!==void 0?gc(o):r!==void 0?`#/a/${encodeURIComponent(r.id)}`:void 0;return s.jsx("div",{className:"delegation relay-line",children:s.jsx(xc,{from:t.agent,to:i,avatar:r,title:t.title,state:t.ok?Sa.done:{label:"没有做完",tone:"failed"},href:c})})}function oP({client:e,note:t,handOffs:n}){const r=Qi(e,t.from),i=b.useContext(Oo),o=n.find(c=>c.id===t.thread);return s.jsx("div",{className:"delegation task-line",children:s.jsx(xc,{from:t.from,to:i,avatar:r,title:t.text.split(`
198
+ `)[0]??t.title,state:{label:tj[t.kind],tone:t.kind==="question"?"asked":"ok"},href:o===void 0?void 0:gc(o)})})}function lP({client:e,note:t,handOffs:n}){const[r,i]=b.useState(!1),o=n.filter(h=>h.by===t.by&&h.title===t.title).at(-1),c=Qi(e,t.by),u=Qi(e,(o==null?void 0:o.to)??"");return t.by===Lm?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(xc,{from:t.by,to:(u==null?void 0:u.name)??o.to,avatar:c,title:t.title,state:Sa[o.state],href:gc(o)})}):s.jsxs("div",{className:"delegation task-line",children:[s.jsxs("button",{className:"exchange-line",onClick:()=>i(h=>!h),"aria-expanded":r,title:r?"收起":"看交给了什么",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:r?"chevron-down":"chevron",className:"exchange-open"})]}),r&&s.jsx("div",{className:"exchange-msg-body task-unfolded",children:s.jsx(Nr,{text:t.body})})]})}function cP({client:e,handOff:t,name:n}){const r=je(e.sessions).items.find(h=>h.id===t.toSession),i=AN(e,r===void 0?[]:[{id:r.id,updatedAt:r.updatedAt,running:r.running}]),o=r===void 0?void 0:i.get(r.id),c=b.useRef(void 0);c.current===void 0&&o!==void 0&&(c.current=o);const u=o!=null&&o!==""&&o!==c.current?o:void 0;return s.jsxs("div",{className:"delegation-now",children:[s.jsx("span",{className:"tool-spinner",role:"img","aria-label":"进行中"}),s.jsx("span",{children:(r==null?void 0:r.running)===!0?u??`${n} 正在做…`:`排在 ${n} 手上的事后面`})]})}function uP(e,t){const n=je(e.connection.status),[r,i]=b.useState({item:null,error:null});return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return e.connection.call("handoffs/get",{id:t}).then(c=>{o&&i({item:c,error:null})},c=>{o&&i({item:null,error:c instanceof Error?c.message:String(c)})}),()=>{o=!1}},[e,t,n.state]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:o})=>{o.id===t&&i({item:o,error:null})}),[e,t]),r}function dP(e,t){var d,p;const n=(d=t==null?void 0:t.chain)==null?void 0:d.at(-2),r=(p=t==null?void 0:t.chain)==null?void 0:p.at(-1),[i,o]=b.useState([]),[c,u]=b.useState(!1);return b.useEffect(()=>{if(t===null)return;if(n===void 0||r===void 0){u(!0);return}let m=!0;return e.connection.call("handoffs/between",{a:n,b:r}).then(g=>{m&&(o(g.items),u(!0))},()=>{m&&u(!0)}),()=>{m=!1}},[e,n,r,t===null]),b.useEffect(()=>e.connection.on("handoffs/changed",({item:m})=>{var y,E;const g=(y=m.chain)==null?void 0:y.at(-2),x=(E=m.chain)==null?void 0:E.at(-1);(g===n&&x===r||g===r&&x===n)&&o(N=>N.some(w=>w.id===m.id)?N.map(w=>w.id===m.id?m:w):[...N,m])}),[e,n,r]),t===null?{threads:[],ready:!1}:{threads:[...i.some(m=>m.id===t.id)?i:[...i,t]].sort((m,g)=>m.startedAt-g.startedAt),ready:c}}function hP(e,t,n,r){const i=[];for(const o of t){const c=n(o.by),u=n(o.to);i.push({kind:"said",key:`${o.id}:task`,thread:o.id,at:o.startedAt,who:c,body:s.jsxs(s.Fragment,{children:[s.jsx(Nr,{text:o.task}),o.expecting!==void 0&&s.jsxs("div",{className:"delegation-expecting",children:["要交回:",o.expecting]})]})}),i.push({kind:"aside",key:`${o.id}:subtasks`,thread:o.id,at:o.startedAt+1,body:s.jsx(nP,{client:e,session:o.toSession,from:o.startedAt,to:o.endedAt,onOpen:r})}),(o.messages??[]).forEach((d,p)=>{d.kind!=="done"&&i.push({kind:"said",key:`${o.id}:${p}`,thread:o.id,at:d.at,who:n(d.from),kindOf:d.kind,body:s.jsx(Nr,{text:d.text})})}),o.state!=="running"&&o.state!=="waiting"?i.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(Nr,{text:o.reply??(o.state==="failed"?"没有做完":"它没有留下回复")}),o.state==="failed"&&o.reply!==void 0&&s.jsx("div",{className:"muted small",children:"(没有做完)"})]})}):i.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(cP,{client:e,handOff:o,name:u})})}return i.map((o,c)=>[o,c]).sort(([o,c],[u,h])=>o.at-u.at||c-h).map(([o])=>o)}function fP({client:e,id:t,onClose:n}){const{item:r,error:i}=uP(e,t),[o,c]=b.useState(null),u=Er(e),h=Qi(e,(r==null?void 0:r.by)??""),d=Qi(e,(r==null?void 0:r.to)??""),{threads:p,ready:m}=dP(e,r),g=L=>{var z;return((z=u.find(U=>U.id===L))==null?void 0:z.name)??(L===Rn.id?Rn.name:L)},x=L=>{const z=u.find(U=>U.name===L||U.id===L);return z===void 0?L===Rn.name||L===Rn.id?Rn:void 0:Wo(z)},y=r===null?[]:hP(e,p,g,c),E=b.useRef(null),N=b.useRef(!1);if(b.useLayoutEffect(()=>{const L=E.current;if(N.current||L===null||r===null||!m)return;N.current=!0;const z=L.querySelector(`[data-thread="${CSS.escape(r.id)}"]`);L.scrollTop=z===null?L.scrollHeight:L.scrollTop+z.getBoundingClientRect().top-L.getBoundingClientRect().top-12},[r,p,m]),b.useEffect(()=>{const L=z=>{z.key==="Escape"&&o===null&&n()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[n,o]),r===null)return s.jsx("section",{className:"main empty exchange-page",children:i??"正在打开…"});const w=(d==null?void 0:d.name)??r.to,T=Sa[r.state],k=[];let I;for(const L of y){const z=L.at===Number.MAX_SAFE_INTEGER?void 0:L.at;if(z!==void 0&&Rw(z,I)&&k.push(s.jsx(Ow,{at:z},`t:${L.key}`)),z!==void 0&&(I=z),L.kind==="aside"){k.push(s.jsx("div",{className:"exchange-aside","data-thread":L.thread,children:L.body},L.key));continue}const U=x(L.who);k.push(s.jsxs("div",{className:`exchange-msg ${L.failed===!0?"failed":""}`,"data-thread":L.thread,title:z===void 0?void 0:cd(z),children:[s.jsxs("div",{className:"exchange-msg-head",children:[s.jsx("span",{className:`agent-avatar small agent-${(U==null?void 0:U.id)??"unknown"}`,children:s.jsx(Q,{name:(U==null?void 0:U.icon)??"sparkles"})}),s.jsx("strong",{children:L.kindOf===void 0||L.kindOf==="done"?L.who:`${L.who} · ${tj[L.kindOf]}`})]}),s.jsx("div",{className:"exchange-msg-body",children:L.body})]},L.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-${(h==null?void 0:h.id)??"unknown"}`,children:s.jsx(Q,{name:(h==null?void 0:h.icon)??"calendar"})}),s.jsx("span",{children:r.by}),s.jsx(Q,{name:"arrow",className:"delegation-arrow"}),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)??"sparkles"})}),s.jsx("h1",{children:w})]}),s.jsxs("div",{className:"session-meta",children:[s.jsx("span",{className:`delegation-state tone-${T.tone}`,children:T.label}),s.jsx("span",{children:r.title}),s.jsx("span",{children:new Date(r.startedAt).toLocaleString()})]})]})}),s.jsx("div",{className:"view",children:s.jsx(ig.Provider,{value:c,children:s.jsxs("div",{className:`chat-split ${o===null?"":"with-pane"}`,children:[s.jsx("div",{className:"chat",ref:E,children:s.jsx("div",{className:"chat-inner",children:k})}),o!==null&&s.jsx(Jw,{client:e,task:o,parent:w,trail:r.by===w?[]:[r.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 tj={question:"问",answer:"答",update:"说",done:"结论"},pP=["切换到 dsh 官方界面:DeepSeek Harness 自带的原版界面,没有 MultiGameAssistant 的脚本、编排、游戏等功能。","","· 它是另一个独立的 dsh:聊天记录、设置和模型密钥都和这里分开,第一次用要在那边重新填模型密钥;","· 第一次切换要启动它,可能要等一会儿;","· 这边的定时任务和脚本在后台照常运行。","","点标题栏左上角的「返回 MultiGameAssistant」切回来。现在切换吗?"].join(`
199
+ `),nj="adg.officialIntro";function mP(){var c;const e=(c=wr())==null?void 0:c.uiMode,[t,n]=b.useState(null);if(b.useEffect(()=>{if(e===void 0)return;let u=!0;e.state().then(d=>{u&&n(d)},()=>{});const h=e.onChange(n);return()=>{u=!1,h()}},[e]),e===void 0||t===null)return null;const r=t.mode==="official",i=()=>{if(r){e.set("adg");return}!gP()&&!window.confirm(pP)||(xP(),e.set("official"))},o=t.starting?"正在启动官方界面…":r?"返回 MultiGameAssistant":"dsh 官方界面";return s.jsxs("div",{className:"ui-switch",children:[s.jsxs("button",{type:"button",className:`ui-switch-button ${r?"active":""}`,disabled:t.starting,onClick:i,title:r?"切回 MultiGameAssistant 的界面":"切换到 DeepSeek Harness 自带的界面(聊天记录分开)",children:[s.jsx(Q,{name:r?"back":"layers"}),s.jsx("span",{children:o})]}),t.error!==void 0&&s.jsxs("span",{className:"ui-switch-error",role:"alert",title:t.error,children:[s.jsx("span",{children:t.error}),s.jsx("button",{type:"button",className:"icon-button","aria-label":"关闭",onClick:()=>void e.set("adg"),children:s.jsx(Q,{name:"close"})})]})]})}function gP(){try{return localStorage.getItem(nj)==="1"}catch{return!1}}function xP(){try{localStorage.setItem(nj,"1")}catch{}}const ep="games";function vP({client:e}){const[t,n]=b.useState(()=>V0()),r=je(e.sessions),i=VM(e),o=je(e.connection.status),c=Er(e),u=b.useRef(!1),h=b.useRef(null);b.useEffect(()=>{yR(t,u.current?"replace":"push"),u.current=!1,t.kind!=="handoff"&&t.kind!=="window"&&(h.current=t)},[t]);const d=t.kind==="handoff"?t:null,p=h.current,m=d===null?t:p!==null&&p.kind!=="settings"?p:{kind:"agent",id:Rs};b.useEffect(()=>{const M=()=>n(V0());return window.addEventListener("hashchange",M),()=>window.removeEventListener("hashchange",M)},[]);const g=b.useRef(new Set);b.useEffect(()=>{for(const H of r.items)g.current.add(H.id);if(t.kind!=="session"||!r.loaded||r.items.some(H=>H.id===t.id))return;const M=()=>{u.current=!0,n(H=>H.kind==="session"&&H.id===t.id?{kind:"home"}:H)};if(g.current.has(t.id)){M();return}const F=setTimeout(M,8e3);return()=>clearTimeout(F)},[t,r]),b.useEffect(()=>{t.kind!=="start"||o.state!=="open"||(u.current=!0,n(i.some(M=>M.id===ep)?{kind:"page",id:ep}:{kind:"home"}))},[t,o.state,i]);const x=Bm(),y=m.kind==="agent"&&(m.tab!=="history"||x)?m.tab:void 0,E=M=>n({kind:"session",id:M}),N=M=>n({kind:"settings",...M===void 0?{}:{section:M}}),w=M=>n({kind:"page",id:M}),T=m.kind==="session"?m.id:null,k=T===null?void 0:r.items.find(M=>M.id===T),I=m.kind==="start"?{kind:"page",id:ep}:m,L=I.kind==="page"?i.find(M=>M.id===I.id):void 0,z=M=>M.agent===void 0?void 0:c.some(F=>F.id===M.agent)?M.agent:Rs,U=L===void 0?void 0:z(L),V=M=>n({kind:"agent",id:M}),$=()=>V(Rs),P=s.jsx(kP,{client:e,onSettings:()=>N("api-keys")}),D=m.kind==="home"?Rs:m.kind==="agent"?m.id:m.kind==="session"?k===void 0?void 0:Aa(k,c):U,B=(M,F)=>n(F==="chat"?{kind:"agent",id:M}:F==="schedule"||F==="history"?{kind:"agent",id:M,tab:F}:{kind:"page",id:F});if(t.kind==="window")return s.jsx(UR,{client:e,viewId:t.view,sessionId:t.sessionId});const _=m.kind==="settings"?{kind:"settings"}:m.kind==="schedule"?{kind:"schedule"}:D!==void 0?{kind:"agent",id:D}:I.kind==="page"?{kind:"page",id:I.id}:{kind:"none"},C=L===void 0?null:s.jsx(L.component,{client:e,openSession:E,openSettings:N,openPage:w,arg:I.kind==="page"?I.arg:void 0},L.id),R=D===void 0?null:s.jsx(yP,{client:e,agentId:D,pages:i.filter(M=>z(M)===D),current:y!==void 0?y:m.kind==="session"?"history":I.kind==="page"?I.id:"chat",onTab:M=>B(D,M)});return s.jsxs("div",{className:`app ${m.kind==="settings"?"with-sidebar":""}`,children:[s.jsx(pR,{client:e,pages:i.filter(M=>M.agent===void 0),current:_,onAgent:V,onPage:w,onSchedule:()=>n({kind:"schedule"}),onSettings:()=>N()}),m.kind==="settings"&&s.jsx(JR,{client:e,onClose:$,section:m.section,onSection:M=>n({kind:"settings",section:M})}),m.kind!=="settings"&&s.jsxs("div",{className:`app-main ${d===null?"":"under-exchange"}`,children:[I.kind==="page"&&U===void 0&&(C??s.jsx("section",{className:"main empty",children:o.state==="open"?"当前连接没有提供这个功能。":"正在连接…"})),D!==void 0&&s.jsxs("div",{className:"agent-area",children:[R,U!==void 0?C:m.kind==="agent"&&y==="schedule"?s.jsx(tO,{client:e,agentId:m.id},m.id):m.kind==="agent"&&y==="history"?s.jsx(fR,{client:e,agentId:m.id,onSelect:E},m.id):m.kind==="session"?s.jsx(Yp,{client:e,sessionId:m.id,onAgent:V,reminder:P},m.id):s.jsx(bP,{client:e,agentId:D,onMain:$,onAgent:V,reminder:P},D)]}),m.kind==="schedule"&&s.jsx(nO,{client:e,onAgent:M=>n({kind:"agent",id:M,tab:"schedule"})}),m.kind==="session"&&D===void 0&&s.jsx(Yp,{client:e,sessionId:m.id,onAgent:V,reminder:P},m.id),d!==null&&s.jsx(fP,{client:e,id:d.id,onClose:()=>n(m)},d.id)]}),s.jsx(nR,{client:e,sessionId:T,onSelect:E}),s.jsx(mP,{})]})}function yP({client:e,agentId:t,pages:n,current:r,onTab:i}){const o=Er(e),c=je(e.capabilities),u=o.find(g=>g.id===t),h=u===void 0?Rn:Wo(u),d=hR(e,t),p=Bm()&&(d||r==="history"),m=[{id:"chat",title:"对话",icon:"chat"},...c.has("pipelines")?[{id:"schedule",title:"定时",icon:"calendar"}]:[],...[...n].sort((g,x)=>g.order-x.order).map(g=>({id:g.id,title:g.title,icon:g.icon})),...p?[{id:"history",title:"以前的对话",icon:"archive"}]:[]];return m.length===1?null:s.jsx("nav",{className:"agent-tabs",role:"tablist","aria-label":h.name,children:m.map(g=>s.jsxs("button",{role:"tab","aria-selected":g.id===r,className:g.id===r?"active":"",onClick:()=>i(g.id),children:[s.jsx(Q,{name:g.icon}),g.title]},g.id))})}function bP({client:e,agentId:t,onMain:n,onAgent:r,reminder:i}){const{sessionId:o,error:c}=TN(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(Yp,{client:e,sessionId:o,onAgent:r,reminder:i},o)}function kP({client:e,onSettings:t}){var o;const{items:n}=_N(e,[Op]),{catalog:r}=Zo(e),i=(r==null?void 0:r.groups.some(c=>c.id!=="deepseek-official"&&c.models.length>0))??!1;return((o=n==null?void 0:n[Op])==null?void 0:o.configured)!==!1||i?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 NP({onSubmit:e}){const[t,n]=b.useState("");return s.jsx("div",{className:"token-prompt",children:s.jsxs("form",{onSubmit:r=>{r.preventDefault(),t.trim()!==""&&e(t.trim())},children:[s.jsx(Id,{size:"lg"}),s.jsxs("div",{className:"token-heading",children:[s.jsx("p",{className:"eyebrow",children:"MULTI GAME ASSISTANT"}),s.jsx("h1",{children:"连接 agent"}),s.jsxs("p",{className:"muted",children:["输入后端启动时打印的连接 token(",s.jsx("code",{children:"adg gateway: …?token="})," 后面的部分)。"]})]}),s.jsx("label",{className:"field-label",htmlFor:"adg-token",children:"连接 Token"}),s.jsx("input",{id:"adg-token",className:"text-input",autoFocus:!0,value:t,onChange:r=>n(r.target.value),placeholder:"粘贴连接 token"}),s.jsx("button",{className:"primary",type:"submit",disabled:t.trim()==="",children:"连接"})]})})}const wP=["准备环境","启动服务","载入界面","连接 agent"],jP=8e3,SP=400;function _P({client:e}){const t=je(e.connection.status),n=je(e.sessions),[r,i]=b.useState("shown"),[o,c]=b.useState(!1),u=t.state==="open"&&n.loaded;if(b.useEffect(()=>{const p=setTimeout(()=>c(!0),jP);return()=>clearTimeout(p)},[]),b.useEffect(()=>{u&&i(p=>p==="shown"?"leaving":p)},[u]),b.useEffect(()=>{if(r!=="leaving")return;const p=setTimeout(()=>i("gone"),SP);return()=>clearTimeout(p)},[r]),r==="gone")return null;const h=t.state==="open"?"正在读取对话":t.state==="reconnecting"?`连不上 agent,正在重试(第 ${t.attempt} 次)`:t.state==="connecting"?"正在连接 agent":"没有连上 agent",d=o?t.error!==void 0?`连接出错:${t.error}`:"比平时慢一些,agent 服务可能还在启动。":"";return s.jsxs("div",{className:`boot${r==="leaving"?" leaving":""}`,"aria-hidden":r==="leaving",children:[s.jsxs("div",{className:"boot-center",children:[s.jsxs("div",{className:"boot-mark","aria-hidden":"true",children:[s.jsxs("svg",{className:"boot-orbit",viewBox:"0 0 132 132",children:[s.jsx("circle",{className:"track",cx:"66",cy:"66",r:"62"}),s.jsx("circle",{className:"comet",cx:"66",cy:"66",r:"62"})]}),s.jsx("span",{className:"boot-tile",children:s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M9.5 8.3v7.4l6.2-3.7-6.2-3.7Z"}),s.jsx("path",{className:"loop",d:"M4 12a8 8 0 0 1 14.5-4.7M20 12a8 8 0 0 1-14.5 4.7"})]})})]}),s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"status","aria-live":"polite",children:s.jsx("span",{children:h})}),s.jsx("ol",{className:"boot-steps",children:wP.map((p,m)=>s.jsxs("li",{className:m<3?"done":"now",children:[s.jsx("i",{}),s.jsx("span",{children:p})]},p))}),s.jsx("p",{className:`boot-hint${d!==""?" shown":""}`,children:d}),o&&s.jsx("button",{type:"button",className:"boot-skip",onClick:()=>i("leaving"),children:"先进入界面"})]}),s.jsx("p",{className:"boot-foot",children:"日常交给 agent · 在本机运行"})]})}class EP extends b.Component{constructor(){super(...arguments);ut(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n instanceof Error?n:new Error(String(n))}}componentDidCatch(n,r){console.error(`界面出错:${n instanceof Error?n.stack??n.message:String(n)}${r.componentStack??""}`)}render(){const{error:n}=this.state;if(n===null)return this.props.children;const r=`${n.message}
200
+
201
+ ${(n.stack??"").split(`
202
+ `).slice(1,8).join(`
203
+ `)}`;return s.jsx("div",{className:"boot failed",children:s.jsxs("div",{className:"boot-center",children:[s.jsx("h1",{className:"boot-name",children:"MultiGameAssistant"}),s.jsx("p",{className:"boot-stage",role:"alert",children:s.jsx("span",{children:"界面出错了"})}),s.jsx("div",{className:"boot-detail",children:s.jsx("pre",{tabIndex:0,children:r})}),s.jsxs("div",{className:"boot-actions",children:[s.jsx("button",{type:"button",className:"primary",onClick:()=>location.reload(),children:"重新载入"}),s.jsx("button",{type:"button",onClick:()=>{var i;return void((i=navigator.clipboard)==null?void 0:i.writeText(r))},children:"复制错误信息"})]})]})})}}const CP={id:"chat",title:"对话",requires:["sessions","chat"],sessionViews:[{id:"chat",title:"对话",order:0,component:Fw}]},AP=[],tp=320,Au=4;function yn({value:e,options:t,onChange:n,id:r,disabled:i,placeholder:o="请选择",inline:c,className:u,...h}){const d=b.useId(),p=b.useRef(null),m=b.useRef(null),[g,x]=b.useState(!1),[y,E]=b.useState(-1),[N,w]=b.useState({}),T=t.findIndex(D=>D.value===e),k=T===-1?void 0:t[T],I=D=>t[D]!==void 0&&t[D].disabled!==!0,L=(D,B)=>{for(let _=D+B;_>=0&&_<t.length;_+=B)if(I(_))return _;return D},z=(D=T)=>{i!==!0&&(E(I(D)?D:L(-1,1)),x(!0))},U=(D=!0)=>{var B;x(!1),D&&((B=p.current)==null||B.focus())},V=D=>{I(D)&&(t[D].value!==e&&n(t[D].value),U())};b.useLayoutEffect(()=>{if(!g)return;const D=()=>{var F,H;const B=(F=p.current)==null?void 0:F.getBoundingClientRect();if(B===void 0)return;const _=window.innerHeight-B.bottom-Au-8,C=B.top-Au-8,R=_<Math.min(tp,((H=m.current)==null?void 0:H.scrollHeight)??tp)&&C>_,M=Math.max(B.width,180);w({left:Math.max(8,Math.min(B.left,window.innerWidth-M-8)),minWidth:M,maxWidth:Math.max(M,Math.min(520,window.innerWidth-16)),maxHeight:Math.min(tp,R?C:_),...R?{bottom:window.innerHeight-B.top+Au}:{top:B.bottom+Au}})};return D(),window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[g]),b.useEffect(()=>{var B;if(!g)return;(B=m.current)==null||B.focus({preventScroll:!0});const D=_=>{var R,M;const C=_.target;!((R=m.current)!=null&&R.contains(C))&&!((M=p.current)!=null&&M.contains(C))&&U(!1)};return document.addEventListener("pointerdown",D,!0),()=>document.removeEventListener("pointerdown",D,!0)},[g]),b.useEffect(()=>{var D,B;g&&y>=0&&((B=(D=m.current)==null?void 0:D.querySelector(`[data-index="${y}"]`))==null||B.scrollIntoView({block:"nearest"}))},[g,y]);const $=D=>{(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter"||D.key===" ")&&(D.preventDefault(),z())},P=D=>{const _={ArrowDown:()=>E(C=>L(C,1)),ArrowUp:()=>E(C=>L(C,-1)),Home:()=>E(L(-1,1)),End:()=>E(L(t.length,-1)),Enter:()=>V(y)," ":()=>V(y),Escape:()=>U(),Tab:()=>U()}[D.key];if(_!==void 0){D.key!=="Tab"&&D.preventDefault(),_();return}if(D.key.length===1&&!D.ctrlKey&&!D.metaKey&&!D.altKey){const C=D.key.toLowerCase();for(let R=1;R<=t.length;R++){const M=(y+R)%t.length;if(I(M)&&t[M].label.toLowerCase().startsWith(C)){E(M);break}}}};return s.jsxs(s.Fragment,{children:[s.jsx("button",{ref:p,id:r,type:"button",disabled:i,className:`select-trigger text-input plain ${c===!0?"inline":""} ${g?"open":""} ${u??""}`,"aria-haspopup":"listbox","aria-expanded":g,"aria-controls":g?d:void 0,"aria-label":h["aria-label"],onClick:()=>g?U():z(),onKeyDown:$,children:s.jsx("span",{className:`select-value ${k===void 0?"placeholder":""}`,children:(k==null?void 0:k.label)??o})}),g&&tg.createPortal(s.jsxs("ul",{ref:m,id:d,role:"listbox",tabIndex:-1,className:"select-list",style:N,"aria-label":h["aria-label"],"aria-activedescendant":y>=0?`${d}-${y}`:void 0,onKeyDown:P,children:[t.map((D,B)=>{var _;return s.jsxs("li",{role:"presentation",children:[D.group!==void 0&&D.group!==((_=t[B-1])==null?void 0:_.group)&&s.jsx("div",{className:"select-group",children:D.group}),s.jsxs("div",{id:`${d}-${B}`,"data-index":B,role:"option","aria-selected":B===T,"aria-disabled":D.disabled===!0,className:`select-option ${B===y?"active":""} ${B===T?"selected":""} ${D.disabled===!0?"disabled":""}`,onPointerMove:()=>{I(B)&&B!==y&&E(B)},onClick:()=>V(B),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})]}),B===T&&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 IP={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function TP({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(null),[u,h]=b.useState(0),[d,p]=b.useState(null),[m,g]=b.useState(null),[x,y]=b.useState(null),[E,N]=b.useState(""),[w,T]=b.useState(""),[k,I]=b.useState(""),[L,z]=b.useState(""),[U,V]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>h(R=>R+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let R=!0;return e.connection.call("feishu/settings",{}).then(M=>{R&&(i(M),N(F=>F===""?M.settings.appId??"":F),I(F=>F===""?M.settings.chatId??"":F))}).catch(M=>{R&&g(Re(M))}),e.connection.call("notify/status",{}).then(M=>{R&&c(M.channels.find(F=>F.id==="feishu")??null)}).catch(()=>{}),()=>{R=!1}},[e,t.state,u]);const $=async(R,M,F)=>{p(R),g(null),y(null);try{const H=await M();H!==null&&typeof H=="object"&&"settings"in H&&i(H),F!==void 0&&y(F),h(W=>W+1)}catch(H){g(Re(H))}finally{p(null)}},P=()=>$("credentials",async()=>(w.trim()!==""&&await e.setCredential(m$,w.trim()),T(""),e.connection.call("feishu/settings/set",{appId:E.trim()===""?null:E.trim(),enabled:!0})),"已保存,正在连接…"),D=()=>$("test",async()=>{const R=await e.connection.call("notify/test",{channel:"feishu"});if(R.failed.length>0)throw new Error(R.failed.map(M=>M.error).join(";"))},"测试消息已发送,去飞书看看"),B=r==null?void 0:r.settings,[_,C]=IP[(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 ${_}`,children:C})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(R=>s.jsxs("li",{className:R.ok===!0?"ok":R.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:R.ok===!0?"✓":R.ok===!1?"✗":"…"}),s.jsx("span",{children:R.label}),R.detail!==void 0&&s.jsx("span",{className:"muted small",children:R.detail})]},R.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void $("check",()=>e.connection.call("feishu/check",{})),children:d==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:d!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void D(),children:"发送测试消息"}),B!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:B.enabled,disabled:d!==null,onChange:R=>void $("enable",()=>e.connection.call("feishu/settings/set",{enabled:R.target.checked}))}),"启用飞书"]})]})]}),B!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"应用凭证"}),s.jsx("label",{className:"field-label",htmlFor:"feishu-domain",children:"平台"}),s.jsx(yn,{id:"feishu-domain",value:B.domain,disabled:d!==null,onChange:R=>void $("domain",()=>e.connection.call("feishu/settings/set",{domain:R})),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:E,onChange:R=>N(R.target.value),placeholder:"cli_xxxxxxxx",spellCheck:!1}),s.jsxs("label",{className:"field-label",htmlFor:"feishu-secret",children:["App Secret ",(r==null?void 0:r.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"feishu-secret",className:"text-input",type:"password",value:w,onChange:R=>T(R.target.value),placeholder:(r==null?void 0:r.secretConfigured)===!0?"留空则保持不变":"在「凭证与基础信息」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"App Secret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:d!==null||E.trim()==="",onClick:()=>void P(),children:d==="credentials"?"保存中…":"保存并连接"})]})]}),B!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令、按卡片上的按钮;通知也发给他们。"}),B.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:B.allowedUsers.map(R=>s.jsxs("li",{children:[s.jsx("span",{children:R.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:R.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void $(`rm-${R.openId}`,()=>e.connection.call("feishu/users/remove",{openId:R.openId})),children:"移除"})]},R.openId))}),((r==null?void 0:r.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:r.pending.map(R=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:R.openId}),s.jsxs("span",{className:"muted small",children:["「",R.text,"」 · ",At(R.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:U[R.openId]??"",onChange:M=>V(F=>({...F,[R.openId]:M.target.value}))}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void $(`dismiss-${R.openId}`,()=>e.connection.call("feishu/users/remove",{openId:R.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:d!==null,onClick:()=>void $(`allow-${R.openId}`,()=>{var M;return e.connection.call("feishu/users/allow",{openId:R.openId,...(M=U[R.openId])!=null&&M.trim()?{name:U[R.openId].trim()}:{}})}),children:"允许"})]},R.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:R=>z(R.target.value),placeholder:"ou_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:d!==null||L.trim()==="",onClick:()=>void $("manual",async()=>{const R=await e.connection.call("feishu/users/allow",{openId:L.trim()});return z(""),R}),children:"添加"})]})]}),B!==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:B.otherApprovals,disabled:d!==null,onChange:R=>void $("approvals",()=>e.connection.call("feishu/settings/set",{otherApprovals:R.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:k,onChange:R=>I(R.target.value),placeholder:"oc_xxxxxxxx",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void $("chat",()=>e.connection.call("feishu/settings/set",{chatId:k.trim()===""?null:k.trim()})),children:"保存"})]})]}),x!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(Q,{name:"check"}),s.jsx("span",{children:x})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:m})]})]})}const $P={off:["","未启用"],connecting:["","连接中"],ready:["ok","已连接"],error:["warn","有问题"]};function MP({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(null),[u,h]=b.useState(0),[d,p]=b.useState(null),[m,g]=b.useState(null),[x,y]=b.useState(null),[E,N]=b.useState(""),[w,T]=b.useState(""),[k,I]=b.useState(""),[L,z]=b.useState({});b.useEffect(()=>e.connection.on("notify/changed",()=>h(_=>_+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let _=!0;return e.connection.call("qqbot/settings",{}).then(C=>{_&&(i(C),N(R=>R===""?C.settings.appId??"":R))}).catch(C=>{_&&g(Re(C))}),e.connection.call("notify/status",{}).then(C=>{_&&c(C.channels.find(R=>R.id==="qq")??null)}).catch(()=>{}),()=>{_=!1}},[e,t.state,u]);const U=async(_,C,R)=>{p(_),g(null),y(null);try{const M=await C();M!==null&&typeof M=="object"&&"settings"in M&&i(M),R!==void 0&&y(R),h(F=>F+1)}catch(M){g(Re(M))}finally{p(null)}},V=()=>U("credentials",async()=>(w.trim()!==""&&await e.setCredential(g$,w.trim()),T(""),e.connection.call("qqbot/settings/set",{appId:E.trim()===""?null:E.trim(),enabled:!0})),"已保存,正在连接…"),$=()=>U("test",async()=>{const _=await e.connection.call("notify/test",{channel:"qq"});if(_.failed.length>0)throw new Error(_.failed.map(C=>C.error).join(";"))},"测试消息已发送,去 QQ 看看"),P=r==null?void 0:r.settings,[D,B]=$P[(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:B})]}),o!==null&&o.checks.length>0&&s.jsx("ul",{className:"check-list",children:o.checks.map(_=>s.jsxs("li",{className:_.ok===!0?"ok":_.ok===!1?"failed":"",children:[s.jsx("span",{className:"check-mark",children:_.ok===!0?"✓":_.ok===!1?"✗":"…"}),s.jsx("span",{children:_.label}),_.detail!==void 0&&s.jsx("span",{className:"muted small",children:_.detail})]},_.id))}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void U("check",()=>e.connection.call("qqbot/check",{})),children:d==="check"?"检查中…":"重新检查"}),s.jsx("button",{className:"small-button",disabled:d!==null||(o==null?void 0:o.state)!=="ready",onClick:()=>void $(),children:"发送测试消息"}),P!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:P.enabled,disabled:d!==null,onChange:_=>void U("enable",()=>e.connection.call("qqbot/settings/set",{enabled:_.target.checked}))}),"启用 QQ 机器人"]})]})]}),P!==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:E,onChange:_=>N(_.target.value),placeholder:"102xxxxxx",spellCheck:!1,inputMode:"numeric"}),s.jsxs("label",{className:"field-label",htmlFor:"qq-secret",children:["AppSecret ",(r==null?void 0:r.secretConfigured)===!0&&s.jsx("span",{className:"badge ok",children:"已保存"})]}),s.jsx("input",{id:"qq-secret",className:"text-input",type:"password",value:w,onChange:_=>T(_.target.value),placeholder:(r==null?void 0:r.secretConfigured)===!0?"留空则保持不变":"在「开发设置」里复制",spellCheck:!1,autoComplete:"off"}),s.jsx("p",{className:"muted small",children:"AppSecret 存在本机的 dsh 凭据里,不会再显示出来。"}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:d!==null||E.trim()==="",onClick:()=>void V(),children:d==="credentials"?"保存中…":"保存并连接"})]})]}),P!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"允许的用户"}),s.jsx("p",{className:"muted small",children:"只有这些人能给机器人下指令;通知和与助手的对话也发给他们。"}),P.allowedUsers.length===0&&s.jsx("div",{className:"muted small",children:"还没有。在 QQ 里给机器人发一条消息,它会出现在下面的「待允许」里。"}),s.jsx("ul",{className:"version-list",children:P.allowedUsers.map(_=>s.jsxs("li",{children:[s.jsx("span",{children:_.name??"(未命名)"}),s.jsx("span",{className:"muted small",children:_.openId}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void U(`rm-${_.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:_.openId})),children:"移除"})]},_.openId))}),((r==null?void 0:r.pending.length)??0)>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label",children:"待允许(给机器人发过消息的人)"}),s.jsx("ul",{className:"version-list",children:r.pending.map(_=>s.jsxs("li",{children:[s.jsx("span",{className:"muted small",children:_.openId}),s.jsxs("span",{className:"muted small",children:["「",_.text,"」 · ",At(_.at,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("input",{className:"text-input plain inline-name",placeholder:"称呼(可选)",value:L[_.openId]??"",onChange:C=>z(R=>({...R,[_.openId]:C.target.value}))}),s.jsx("button",{className:"small-button",disabled:d!==null,onClick:()=>void U(`dismiss-${_.openId}`,()=>e.connection.call("qqbot/users/remove",{openId:_.openId})),children:"忽略"}),s.jsx("button",{className:"primary small-button",disabled:d!==null,onClick:()=>void U(`allow-${_.openId}`,()=>{var C;return e.connection.call("qqbot/users/allow",{openId:_.openId,...(C=L[_.openId])!=null&&C.trim()?{name:L[_.openId].trim()}:{}})}),children:"允许"})]},_.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:k,onChange:_=>I(_.target.value),placeholder:"机器人回复你的那条消息里有",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:d!==null||k.trim()==="",onClick:()=>void U("manual",async()=>{const _=await e.connection.call("qqbot/users/allow",{openId:k.trim()});return I(""),_}),children:"添加"})]})]}),x!==null&&s.jsxs("div",{className:"notice info left",children:[s.jsx(Q,{name:"check"}),s.jsx("span",{children:x})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:m})]})]})}const RP=[{id:"feishu",title:"飞书",capability:"feishu",component:TP},{id:"qq",title:"QQ 机器人",capability:"qqbot",component:MP}];function OP({client:e}){var c;const t=je(e.capabilities),n=RP.filter(u=>t.has(u.capability)),[r,i]=b.useState(((c=n[0])==null?void 0:c.id)??"feishu"),o=n.find(u=>u.id===r)??n[0];return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"远程连接"}),s.jsx("p",{children:"不在电脑前也能用:在飞书或 QQ 里和助手说话。和助手的对话两边完全一样——在软件里说的、在聊天软件里说的、助手和其他 agent 之间的往来、助手的回复,都会同步过去;脚本出问题的通知也发到那里,在聊天软件里点按钮或直接回复就能处理。"}),n.length>1&&s.jsx("nav",{className:"agent-tabs remote-tabs",role:"tablist","aria-label":"远程连接方式",children:n.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===(o==null?void 0:o.id),className:u.id===(o==null?void 0:o.id)?"active":"",onClick:()=>i(u.id),children:u.title},u.id))}),o===void 0?s.jsx("p",{className:"muted",children:"当前连接没有提供远程连接。"}):s.jsx(o.component,{client:e},o.id)]})}const zP=(e,t)=>{try{const n=localStorage.getItem(`adg.fold.${e}`);return n===null?t:n==="1"}catch{return t}};function PP(e,t=!0){const[n,r]=b.useState(()=>zP(e,t));return[n,()=>r(o=>{try{localStorage.setItem(`adg.fold.${e}`,o?"0":"1")}catch{}return!o})]}function LP({open:e,onToggle:t,children:n,count:r,className:i=""}){return s.jsxs("button",{type:"button",className:`fold-head ${i}`,"aria-expanded":e,onClick:t,children:[s.jsx(Q,{name:"chevron",className:`fold-chevron ${e?"open":""}`}),s.jsx("span",{className:"fold-title",children:n}),r!==void 0&&s.jsx("span",{className:"fold-count",children:r})]})}function _a({id:e,title:t,count:n,initial:r=!0,children:i,className:o=""}){const[c,u]=PP(e,r);return s.jsxs("div",{className:`fold ${o}`,children:[s.jsx(LP,{open:c,onToggle:u,...n===void 0?{}:{count:n},children:t}),c&&i]})}function sj({client:e,scriptId:t,taskId:n,name:r,spec:i,value:o,onChange:c,onCreated:u,profile:h}){const[d,p]=b.useState(null),[m,g]=b.useState(null),[x,y]=b.useState(!1),E=async()=>{const w=(m==null?void 0:m.trim())??"";if(w!==""){p(null),y(!0);try{const{value:T}=await e.connection.call("runs/choices/create",{scriptId:t,taskId:n,param:r,name:w,...h===void 0?{}:{profile:h}});g(null),u==null||u(),c(T)}catch(T){p(Re(T))}finally{y(!1)}}};let N;if(i.choices!==void 0){const w=i.choices.some(T=>T.value===o);N=s.jsx(yn,{"aria-label":r,value:w?o:"",placeholder:i.choices.length===0?"本地配置里还没有,先新建或在脚本里建一个":"请选择",onChange:T=>{T==="\0new"?g(k=>k??"MultiGameAssistant"):c(T)},options:[...i.choices.map(T=>({value:T.value,label:T.label,...T.detail===void 0?{}:{hint:T.detail}})),...i.canCreate===!0?[{value:"\0new",label:"+ 新建…"}]:[]]})}else i.type==="boolean"?N=s.jsx(yn,{"aria-label":r,value:o,onChange:c,options:[{value:"true",label:"是"},{value:"false",label:"否"}]}):i.enum!==void 0?N=s.jsx(yn,{"aria-label":r,value:o,onChange:c,options:i.enum.map(w=>({value:String(w),label:String(w)}))}):N=s.jsx("input",{className:"text-input plain","aria-label":r,value:o,placeholder:i.default===void 0?"必填":String(i.default),inputMode:i.type==="string"?"text":"numeric",onChange:w=>c(w.target.value)});return s.jsxs("div",{className:"param-row",role:"group","aria-label":r,children:[s.jsxs("span",{className:"field-label",children:[r,i.description===void 0?"":` · ${i.description}`]}),N,m!==null&&s.jsxs("span",{className:"param-new",children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,value:m,"aria-label":"新项的名字",onChange:w=>g(w.target.value),onKeyDown:w=>{w.key==="Enter"?(w.preventDefault(),E()):w.key==="Escape"&&g(null)}}),s.jsx("button",{type:"button",className:"primary small-button",disabled:x||m.trim()==="",onClick:()=>void E(),children:x?"新建中…":"新建"}),s.jsx("button",{type:"button",className:"small-button",disabled:x,onClick:()=>{g(null),p(null)},children:"取消"}),s.jsx("span",{className:"muted small",children:"复制一个现有的同类项,只存在本应用的本地配置里,原项目不变"})]}),d!==null&&s.jsx("span",{className:"error small",children:d})]})}function rj(e,t,n=!0){const r=je(e.connection.status),[i,o]=b.useState(null);return b.useEffect(()=>{if(o(null),t===void 0||!n||r.state!=="open")return;let c=!0;e.connection.call("configs/profiles",{scriptId:t}).then(h=>{c&&o(h)},()=>{});const u=e.connection.on("configs/profiles/changed",h=>{h.scriptId===t&&o(h.list)});return()=>{c=!1,u()}},[e,t,n,r.state]),i}function ij({list:e,value:t,onChange:n,id:r,label:i="配置"}){if(e===null||e.items.length<2)return null;const o=e.items.find(u=>u.id===e.current),c=t!==void 0&&!e.items.some(u=>u.id===t);return s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:r,children:i}),s.jsx(yn,{id:r,value:t??"",onChange:u=>n(u===""?void 0:u),options:[{value:"",label:"跟随当前使用的",hint:`现在是「${(o==null?void 0:o.name)??"默认"}」`},...e.items.map(u=>({value:u.id,label:u.name})),...c?[{value:t,label:"已删除的配置",disabled:!0}]:[]]}),c&&s.jsx("span",{className:"muted small",children:"这份配置已经删了,运行时会失败;请重新选一份。"})]})}const og={starting:["","启动中"],running:["","运行中"],stopping:["warn","停止中"],succeeded:["ok","成功"],failed:["warn","失败"],cancelled:["","已停止"]},DP={desktop:"占用鼠标键盘",window:"后台窗口",adb:"模拟器",none:"不占用"};function FP({client:e,scriptId:t,packId:n}){const r=je(e.connection.status),i=Cn(3e4),[o,c]=b.useState(null),[u,h]=b.useState([]),[d,p]=b.useState(""),[m,g]=b.useState({}),[x,y]=b.useState(!1),[E,N]=b.useState(null),[w,T]=b.useState(null),[k,I]=b.useState(0),L=rj(e,t,n!==void 0),[z,U]=b.useState(void 0);b.useEffect(()=>{if(r.state!=="open")return;let B=!0;return e.connection.call("runs/tasks",{scriptId:t,...z===void 0?{}:{profile:z}}).then(_=>{B&&(c(_),p(C=>{var R;return C===""?((R=_.tasks[0])==null?void 0:R.id)??"":C}))}).catch(_=>{B&&N(Re(_))}),e.connection.call("runs/list",{scriptId:t}).then(_=>{B&&h(_.items)}).catch(()=>{}),()=>{B=!1}},[e,t,n,r.state,k,z,L==null?void 0:L.current]),b.useEffect(()=>e.connection.on("runs/state",B=>{B.scriptId===t&&h(_=>[B,..._.filter(C=>C.id!==B.id)].sort((C,R)=>R.startedAt-C.startedAt))}),[e,t]);const V=o==null?void 0:o.tasks.find(B=>B.id===d);b.useEffect(()=>{V!==void 0&&g(Object.fromEntries(Object.entries(V.params).map(([B,_])=>{var C;return[B,_.default!==void 0?String(_.default):((C=_.choices)==null?void 0:C.length)===1?_.choices[0].value:""]})))},[V==null?void 0:V.id]);const $=u.find(B=>B.endedAt===void 0),P=u.find(B=>{var _;return B.id===(w??($==null?void 0:$.id)??((_=u[0])==null?void 0:_.id))}),D=async()=>{if(V!==void 0){y(!0),N(null);try{const B={};for(const[C,R]of Object.entries(V.params)){const M=m[C]??"";M!==""&&(B[C]=R.type==="boolean"?M==="true":R.type==="integer"||R.type==="number"?Number(M):M)}const _=await e.connection.call("runs/start",{scriptId:t,taskId:V.id,params:B,...z===void 0?{}:{profile:z}});T(_.id),_.state==="failed"&&N(_.outcome??"运行失败")}catch(B){N(Re(B))}finally{y(!1)}}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"任务"}),s.jsx("p",{className:"muted small",children:"按脚本包运行,使用本地配置;原项目的配置在运行结束后会还原。"})]})}),o===null&&E===null&&s.jsx("div",{className:"muted small",children:"加载中…"}),o!==null&&!o.runnable&&s.jsx("div",{className:"notice info left small",children:o.problem}),o!==null&&o.tasks.length>0&&s.jsxs("div",{className:"run-form",children:[s.jsx("label",{className:"field-label",htmlFor:"task-select",children:"任务"}),s.jsx(yn,{id:"task-select",value:d,onChange:p,options:o.tasks.map(B=>({value:B.id,label:B.title,hint:B.id}))}),V!==void 0&&s.jsxs("div",{className:"task-facts muted small",children:[s.jsx("span",{className:"badge",children:DP[V.input]}),V.account!==void 0&&s.jsxs("span",{className:"badge",children:["账号 ",V.account]}),V.expectedDuration!==void 0&&s.jsxs("span",{children:["约 ",V.expectedDuration]}),V.description!==void 0&&s.jsx("span",{children:V.description})]}),s.jsx(ij,{id:"run-profile",list:L,value:z,onChange:U}),V!==void 0&&Object.entries(V.params).map(([B,_])=>s.jsx(sj,{client:e,scriptId:t,taskId:V.id,name:B,spec:_,profile:z,value:m[B]??"",onChange:C=>g(R=>({...R,[B]:C})),onCreated:()=>I(C=>C+1)},B)),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),$!==void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:$.id}).catch(B=>N(Re(B))),children:"停止当前运行"}),s.jsxs("button",{className:"primary small-button",disabled:x||!o.runnable||$!==void 0,onClick:()=>void D(),children:[s.jsx(Q,{name:"arrow"}),x?"启动中…":"运行"]})]})]}),E!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:E})]}),u.length>0&&s.jsxs(_a,{id:"scripts.recent-runs",title:"最近运行",count:Math.min(u.length,6),className:"run-history",children:[u.slice(0,6).map(B=>{const[_,C]=og[B.state];return s.jsxs("button",{className:`run-row ${B.id===(P==null?void 0:P.id)?"active":""}`,"aria-expanded":B.id===(P==null?void 0:P.id),onClick:()=>T(R=>R===B.id||R===null&&B.id===(P==null?void 0:P.id)?"":B.id),children:[s.jsx("span",{className:`badge ${_}`,children:C}),s.jsxs("span",{className:"run-title",children:[B.taskTitle,B.profileName!==void 0&&((L==null?void 0:L.items.length)??0)>1&&s.jsxs("span",{className:"muted small",children:[" · ",B.profileName]})]}),s.jsx("span",{className:"muted small run-outcome",children:B.outcome??B.resources.join(" · ")}),s.jsx("span",{className:"session-time",children:At(B.startedAt,i)})]},B.id)}),P!==void 0&&s.jsx(aj,{client:e,run:P},P.id)]})]})}function aj({client:e,run:t}){const[n,r]=b.useState([]),i=b.useRef(null);b.useEffect(()=>{let d=!0;e.connection.call("runs/logs",{runId:t.id,limit:500}).then(m=>{d&&r(m.lines)}).catch(()=>{});const p=e.connection.on("runs/log",m=>{m.runId===t.id&&r(g=>[...g,...m.lines].slice(-1e3))});return()=>{d=!1,p()}},[e,t.id]),b.useEffect(()=>{const d=i.current;d!==null&&(d.scrollTop=d.scrollHeight)},[n.length]);const o=b.useMemo(()=>t.warnings,[t.warnings]),[c,u]=b.useState(null),h=async()=>{let d=n;try{d=(await e.connection.call("runs/logs",{runId:t.id,limit:2e3})).lines}catch{}const p=[`${t.scriptName} · ${t.taskTitle}(${t.id})${t.outcome===void 0?"":` — ${t.outcome}`}`,...d.map(g=>`${new Date(g.at).toLocaleTimeString("zh-CN",{hour12:!1})} [${g.source==="adg"?"平台":g.source}]${g.level===void 0?"":` [${g.level}]`} ${g.text}`)].join(`
204
+ `),m=await BP(p);u(m?`已复制 ${d.length} 行`:"复制失败"),setTimeout(()=>u(null),1800)};return s.jsxs("div",{className:"run-log-wrap",children:[o.map(d=>s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:d})]},d)),s.jsxs("div",{className:"run-log-bar",children:[s.jsxs("span",{className:"muted small",children:[n.length," 行",n.length>=1e3?"(只显示最近的)":""]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{type:"button",className:"small-button",disabled:n.length===0,onClick:()=>void h(),title:"复制整次运行的日志(最多 2000 行),方便发给别人或 agent",children:[s.jsx(Q,{name:"copy"}),c??"复制日志"]})]}),s.jsxs("div",{className:"run-log",ref:i,role:"log","aria-label":"运行日志",children:[n.length===0&&s.jsx("div",{className:"muted small",children:"还没有日志"}),n.map((d,p)=>s.jsxs("div",{className:`log-line ${d.level===void 0?"":`lv-${d.level}`} ${d.source==="adg"?"adg":""}`,children:[s.jsx("span",{className:"log-time",children:new Date(d.at).toLocaleTimeString()}),s.jsx("span",{className:"log-source",children:d.source==="adg"?"平台":d.source}),s.jsx("span",{className:"log-text",children:d.text})]},p))]})]})}async function BP(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 oj=b.createContext({byIncident:new Map,openSession:()=>{}}),UP={running:"agent 正在处理",resolved:"agent 已处理",retried:"agent 处理后重新运行","gave-up":"agent 处理不了","taken-over":"你接管了",timeout:"agent 超时",failed:"agent 没能开始"},HP={error:"出错",warning:"警告",failed:"失败",stalled:"卡住",overtime:"超时"};function ZP({client:e,openSettings:t,openSession:n}){const r=je(e.connection.status),i=Cn(3e4),[o,c]=b.useState([]),[u,h]=b.useState([]),[d,p]=b.useState(null),[m,g]=b.useState(!1),[x,y]=b.useState(null),[E,N]=b.useState([]),w=je(e.capabilities);b.useEffect(()=>{if(r.state!=="open"||!w.has("intervene"))return;let $=!0;return e.connection.call("intervene/list",{limit:100}).then(P=>{$&&N(P.items)}).catch(()=>{}),()=>{$=!1}},[e,r.state,w]),b.useEffect(()=>e.connection.on("intervene/changed",$=>{N(P=>[$,...P.filter(D=>D.id!==$.id)])}),[e]);const T=b.useMemo(()=>{const $=new Map;for(const P of[...E].sort((D,B)=>D.startedAt-B.startedAt))P.incidentId!==void 0&&$.set(P.incidentId,P);return{byIncident:$,openSession:n}},[E,n]);b.useEffect(()=>{if(r.state!=="open")return;let $=!0;return e.connection.call("runs/list",{}).then(P=>{$&&c(P.items)}).catch(P=>{$&&y(Re(P))}),e.connection.call("monitor/incidents",{status:"all",limit:200}).then(P=>{$&&h(P.items)}).catch(()=>{}),()=>{$=!1}},[e,r.state]),b.useEffect(()=>e.connection.on("runs/state",$=>{c(P=>[$,...P.filter(D=>D.id!==$.id)].sort((D,B)=>B.startedAt-D.startedAt))}),[e]),b.useEffect(()=>e.connection.on("monitor/incident",$=>{h(P=>[$,...P.filter(D=>D.id!==$.id)].sort((D,B)=>B.createdAt-D.createdAt))}),[e]);const k=o.filter($=>$.endedAt===void 0),I=o.filter($=>$.endedAt!==void 0).slice(0,30),L=u.filter($=>$.status==="open"),z=o.find($=>{var P,D;return $.id===(d??((P=k[0])==null?void 0:P.id)??((D=o[0])==null?void 0:D.id))}),U=b.useMemo(()=>{const $=new Map;for(const P of L)$.set(P.runId,($.get(P.runId)??0)+1);return $},[L]),V=$=>{const[P,D]=og[$.state],B=U.get($.id)??0;return s.jsxs("button",{className:`script-row ${$.id===(z==null?void 0:z.id)?"active":""}`,onClick:()=>p($.id),children:[s.jsxs("span",{className:"script-row-main",children:[s.jsxs("span",{className:"script-row-name",children:[$.scriptName," · ",$.taskTitle]}),s.jsxs("span",{className:"muted small",children:[$.kind==="settings"?"设置会话 · ":"",At($.startedAt,i),$.retryOf===void 0?"":" · 重新运行"]})]}),B>0?s.jsxs("span",{className:"badge warn",children:["异常 ",B]}):s.jsx("span",{className:`badge ${P}`,children:D})]},$.id)};return s.jsx(oj.Provider,{value:T,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 ${m?"primary":""}`,onClick:()=>g($=>!$),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(_a,{id:"monitor.active",title:"正在运行",count:k.length,className:"list-fold",children:[k.length===0&&s.jsx("div",{className:"muted small pad",children:"没有正在运行的任务"}),k.map(V)]}),I.length>0&&s.jsx(_a,{id:"monitor.recent",title:"最近",count:I.length,className:"list-fold",children:I.map(V)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[m&&s.jsx(VP,{client:e}),L.length>0&&s.jsx("section",{className:"card",children:s.jsxs(_a,{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($=>s.jsx(lj,{client:e,incident:$,now:i,onOpen:()=>p($.runId)},$.id))})]})}),z===void 0&&L.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(Q,{name:"monitor"}),s.jsx("p",{children:"还没有运行记录。在「脚本」页运行一个任务,或对 agent 说「跑一下方舟日常」。"})]}),z!==void 0&&s.jsx(WP,{client:e,run:z,incidents:u.filter($=>$.runId===z.id),now:i,openRun:p})]})})]})]})})}function WP({client:e,run:t,incidents:n,now:r,openRun:i}){const[o,c]=og[t.state],[u,h]=b.useState(null);return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[t.scriptName," · ",t.taskTitle]}),s.jsxs("p",{className:"muted small",children:[new Date(t.startedAt).toLocaleString("zh-CN",{hour12:!1}),t.endedAt===void 0?"":` → ${new Date(t.endedAt).toLocaleTimeString("zh-CN",{hour12:!1})}`,t.resources.length>0?` · ${t.resources.join(" · ")}`:""]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:`badge ${o}`,children:c}),t.endedAt===void 0&&s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("runs/stop",{runId:t.id}).catch(d=>h(Re(d))),children:"停止"})]})]}),t.outcome!==void 0&&s.jsxs("div",{className:"muted small",children:["结果:",t.outcome]}),t.retryOf!==void 0&&s.jsxs("button",{className:"link-button small",onClick:()=>i(t.retryOf),children:["这是 ",t.retryOf," 的重新运行"]}),u!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:u})]}),s.jsx(_a,{id:"monitor.run-log",title:"日志",children:s.jsx(aj,{client:e,run:t},t.id)}),n.length>0&&s.jsx(_a,{id:"monitor.run-incidents",title:"这次运行的异常",count:n.length,children:s.jsx("div",{className:"incident-list",children:n.map(d=>s.jsx(lj,{client:e,incident:d,now:r},d.id))})})]})}function lj({client:e,incident:t,now:n,onOpen:r}){const{byIncident:i,openSession:o}=b.useContext(oj),c=i.get(t.id),[u,h]=b.useState(!1),[d,p]=b.useState(null),[m,g]=b.useState(null),x=async()=>{if(c!==void 0){h(!0),p(null);try{await e.connection.call("intervene/takeover",{id:c.id})}catch(N){p(Re(N))}finally{h(!1)}}},y=async N=>{h(!0),p(null);try{await e.connection.call("monitor/act",{incidentId:t.id,action:N})}catch(w){p(Re(w))}finally{h(!1)}},E=async()=>{if(m!==null)return g(null);try{const N=await e.connection.call("monitor/screenshot",{incidentId:t.id});g(`data:${N.mime};base64,${N.data}`)}catch(N){p(Re(N))}};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:HP[t.kind]}),r===void 0?s.jsx("span",{className:"incident-title",children:t.title}):s.jsx("button",{className:"link-button incident-title",onClick:r,children:t.title}),s.jsx("span",{className:"session-time",children:At(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(N=>(c==null?void 0:c.summary)===void 0||c.state==="running"||!N.detail.endsWith(c.summary)).map((N,w)=>s.jsxs("li",{className:N.ok?"ok":"failed",children:[N.ok?"✓":"✗"," ",N.detail]},w))}),t.status==="resolved"&&s.jsxs("div",{className:"muted small",children:["已处理:",t.resolution]}),c!==void 0&&s.jsxs("div",{className:`agent-line ${c.state}`,children:[s.jsxs("span",{className:"badge",children:[UP[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 E(),children:[s.jsx(Q,{name:"image"}),m===null?"截图":"收起截图"]}),s.jsx("span",{className:"spacer"}),(c==null?void 0:c.paused)===!0&&s.jsx("button",{className:"primary small-button",disabled:u,onClick:()=>void y("resume"),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",disabled:u,onClick:()=>void y("stop"),children:"停止"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("retry"),children:"重试"}),s.jsx("button",{className:"small-button",disabled:u,onClick:()=>void y("resolve"),children:"忽略"})]}),m!==null&&s.jsx("img",{className:"incident-shot",src:m,alt:"异常时的截图"}),d!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]})]})}function VP({client:e}){var h;const[t,n]=b.useState(null),[r,i]=b.useState(null);b.useEffect(()=>{e.connection.call("monitor/settings",{}).then(n).catch(d=>i(Re(d)))},[e]);const o=d=>e.connection.call("monitor/settings/set",d).then(n).catch(p=>i(Re(p))),c=((h=Um(e).data)==null?void 0:h.scripts)??[],u=Object.entries((t==null?void 0:t.scriptStall)??{}).sort(([d],[p])=>d.localeCompare(p));return s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"监控设置"}),t!==null&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"stall-seconds",children:"多少秒没有新日志算卡住、交给干预(默认值;0 = 不检测)"}),s.jsx("input",{id:"stall-seconds",className:"text-input plain",type:"number",min:0,max:86400,defaultValue:t.defaultStallSeconds,onBlur:d=>void o({defaultStallSeconds:Math.max(0,Math.min(86400,Math.round(Number(d.target.value)||0)))})}),s.jsx("p",{className:"muted small",children:"每个脚本会从自己跑成功的记录里学:卡住时间取最近几次里最长安静时间的 1.5 倍(不低于上面的默认值);agent 看过日志节奏后也会替它调。"}),u.length>0&&s.jsx("ul",{className:"stall-list",children:u.map(([d,p])=>{var m;return s.jsxs("li",{children:[s.jsx("span",{children:((m=c.find(g=>g.id===d))==null?void 0:m.name)??d}),s.jsxs("span",{className:"muted small",children:[p.seconds," 秒 · ",p.by==="learned"?"学到的":p.by==="agent"?"agent 设的":"你设的",p.note===void 0?"":`:${p.note}`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"link-button small",onClick:()=>{const{[d]:g,...x}=t.scriptStall;o({scriptStall:x})},children:"恢复自动"})]},d)})}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.screenshot,onChange:d=>void o({screenshot:d.target.checked})}),"出错时截图(模拟器画面或桌面)并随通知发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.notifyWarnings,onChange:d=>void o({notifyWarnings:d.target.checked})}),"警告也推送(默认只推送出错、失败、卡住)"]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-mode",children:"自动处理解决不了的问题,先交给 agent(需要能看图的模型)"}),s.jsx(yn,{id:"intervene-mode",value:t.intervene,onChange:d=>void o({intervene:d}),options:[{value:"act",label:"诊断并处理(推荐)",hint:"暂停脚本,agent 看屏幕、点击和输入来解决"},{value:"diagnose",label:"只诊断",hint:"agent 看截图说明原因,由你决定"},{value:"off",label:"关闭",hint:"直接通知我"}]}),s.jsx("label",{className:"field-label",htmlFor:"intervene-cap",children:"每天最多交给 agent 几次(控制模型费用)"}),s.jsx("input",{id:"intervene-cap",className:"text-input plain",type:"number",min:0,max:200,defaultValue:t.interventionsPerDay,onBlur:d=>void o({interventionsPerDay:Math.max(0,Math.min(200,Math.round(Number(d.target.value)||0)))})})]}),r!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:r})]})]})}const qP={id:"runs",title:"运行监控",milestone:"M3",requires:["runs","monitor"],pages:[{id:"runs",title:"运行",icon:"monitor",order:30,agent:"intervene",component:ZP}]},GP={id:"feishu",title:"远程连接",milestone:"M3",requires:["notify","credentials"],settingsPages:[{id:"feishu",title:"远程连接",order:12,component:OP}]};function kn(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=kn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var KP={value:()=>{}};function Md(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Wu(n)}function Wu(e){this._=e}function YP(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Wu.prototype=Md.prototype={constructor:Wu,on:function(e,t){var n=this._,r=YP(e+"",n),i,o=-1,c=r.length;if(arguments.length<2){for(;++o<c;)if((i=(e=r[o]).type)&&(i=XP(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<c;)if(i=(e=r[o]).type)n[i]=Ly(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ly(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Wu(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function XP(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ly(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=KP,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var im="http://www.w3.org/1999/xhtml";const Dy={svg:"http://www.w3.org/2000/svg",xhtml:im,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Rd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Dy.hasOwnProperty(t)?{space:Dy[t],local:e}:e}function QP(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===im&&t.documentElement.namespaceURI===im?t.createElement(e):t.createElementNS(n,e)}}function JP(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function cj(e){var t=Rd(e);return(t.local?JP:QP)(t)}function eL(){}function lg(e){return e==null?eL:function(){return this.querySelector(e)}}function tL(e){typeof e!="function"&&(e=lg(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=new Array(c),h,d,p=0;p<c;++p)(h=o[p])&&(d=e.call(h,h.__data__,p,o))&&("__data__"in h&&(d.__data__=h.__data__),u[p]=d);return new zs(r,this._parents)}function nL(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function sL(){return[]}function uj(e){return e==null?sL:function(){return this.querySelectorAll(e)}}function rL(e){return function(){return nL(e.apply(this,arguments))}}function iL(e){typeof e=="function"?e=rL(e):e=uj(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var c=t[o],u=c.length,h,d=0;d<u;++d)(h=c[d])&&(r.push(e.call(h,h.__data__,d,c)),i.push(h));return new zs(r,i)}function dj(e){return function(){return this.matches(e)}}function hj(e){return function(t){return t.matches(e)}}var aL=Array.prototype.find;function oL(e){return function(){return aL.call(this.children,e)}}function lL(){return this.firstElementChild}function cL(e){return this.select(e==null?lL:oL(typeof e=="function"?e:hj(e)))}var uL=Array.prototype.filter;function dL(){return Array.from(this.children)}function hL(e){return function(){return uL.call(this.children,e)}}function fL(e){return this.selectAll(e==null?dL:hL(typeof e=="function"?e:hj(e)))}function pL(e){typeof e!="function"&&(e=dj(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=[],h,d=0;d<c;++d)(h=o[d])&&e.call(h,h.__data__,d,o)&&u.push(h);return new zs(r,this._parents)}function fj(e){return new Array(e.length)}function mL(){return new zs(this._enter||this._groups.map(fj),this._parents)}function ud(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ud.prototype={constructor:ud,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 gL(e){return function(){return e}}function xL(e,t,n,r,i,o){for(var c=0,u,h=t.length,d=o.length;c<d;++c)(u=t[c])?(u.__data__=o[c],r[c]=u):n[c]=new ud(e,o[c]);for(;c<h;++c)(u=t[c])&&(i[c]=u)}function vL(e,t,n,r,i,o,c){var u,h,d=new Map,p=t.length,m=o.length,g=new Array(p),x;for(u=0;u<p;++u)(h=t[u])&&(g[u]=x=c.call(h,h.__data__,u,t)+"",d.has(x)?i[u]=h:d.set(x,h));for(u=0;u<m;++u)x=c.call(e,o[u],u,o)+"",(h=d.get(x))?(r[u]=h,h.__data__=o[u],d.delete(x)):n[u]=new ud(e,o[u]);for(u=0;u<p;++u)(h=t[u])&&d.get(g[u])===h&&(i[u]=h)}function yL(e){return e.__data__}function bL(e,t){if(!arguments.length)return Array.from(this,yL);var n=t?vL:xL,r=this._parents,i=this._groups;typeof e!="function"&&(e=gL(e));for(var o=i.length,c=new Array(o),u=new Array(o),h=new Array(o),d=0;d<o;++d){var p=r[d],m=i[d],g=m.length,x=kL(e.call(p,p&&p.__data__,d,r)),y=x.length,E=u[d]=new Array(y),N=c[d]=new Array(y),w=h[d]=new Array(g);n(p,m,E,N,w,x,t);for(var T=0,k=0,I,L;T<y;++T)if(I=E[T]){for(T>=k&&(k=T+1);!(L=N[k])&&++k<y;);I._next=L||null}}return c=new zs(c,r),c._enter=u,c._exit=h,c}function kL(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function NL(){return new zs(this._exit||this._groups.map(fj),this._parents)}function wL(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function jL(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,c=Math.min(i,o),u=new Array(i),h=0;h<c;++h)for(var d=n[h],p=r[h],m=d.length,g=u[h]=new Array(m),x,y=0;y<m;++y)(x=d[y]||p[y])&&(g[y]=x);for(;h<i;++h)u[h]=n[h];return new zs(u,this._parents)}function SL(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],c;--i>=0;)(c=r[i])&&(o&&c.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(c,o),o=c);return this}function _L(e){e||(e=EL);function t(m,g){return m&&g?e(m.__data__,g.__data__):!m-!g}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var c=n[o],u=c.length,h=i[o]=new Array(u),d,p=0;p<u;++p)(d=c[p])&&(h[p]=d);h.sort(t)}return new zs(i,this._parents).order()}function EL(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function CL(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function AL(){return Array.from(this)}function IL(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var c=r[i];if(c)return c}return null}function TL(){let e=0;for(const t of this)++e;return e}function $L(){return!this.node()}function ML(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,c=i.length,u;o<c;++o)(u=i[o])&&e.call(u,u.__data__,o,i);return this}function RL(e){return function(){this.removeAttribute(e)}}function OL(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zL(e,t){return function(){this.setAttribute(e,t)}}function PL(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function LL(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function DL(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 FL(e,t){var n=Rd(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?OL:RL:typeof t=="function"?n.local?DL:LL:n.local?PL:zL)(n,t))}function pj(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function BL(e){return function(){this.style.removeProperty(e)}}function UL(e,t,n){return function(){this.style.setProperty(e,t,n)}}function HL(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function ZL(e,t,n){return arguments.length>1?this.each((t==null?BL:typeof t=="function"?HL:UL)(e,t,n??"")):zo(this.node(),e)}function zo(e,t){return e.style.getPropertyValue(t)||pj(e).getComputedStyle(e,null).getPropertyValue(t)}function WL(e){return function(){delete this[e]}}function VL(e,t){return function(){this[e]=t}}function qL(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function GL(e,t){return arguments.length>1?this.each((t==null?WL:typeof t=="function"?qL:VL)(e,t)):this.node()[e]}function mj(e){return e.trim().split(/^|\s+/)}function cg(e){return e.classList||new gj(e)}function gj(e){this._node=e,this._names=mj(e.getAttribute("class")||"")}gj.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 xj(e,t){for(var n=cg(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function vj(e,t){for(var n=cg(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function KL(e){return function(){xj(this,e)}}function YL(e){return function(){vj(this,e)}}function XL(e,t){return function(){(t.apply(this,arguments)?xj:vj)(this,e)}}function QL(e,t){var n=mj(e+"");if(arguments.length<2){for(var r=cg(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?XL:t?KL:YL)(n,t))}function JL(){this.textContent=""}function eD(e){return function(){this.textContent=e}}function tD(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function nD(e){return arguments.length?this.each(e==null?JL:(typeof e=="function"?tD:eD)(e)):this.node().textContent}function sD(){this.innerHTML=""}function rD(e){return function(){this.innerHTML=e}}function iD(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function aD(e){return arguments.length?this.each(e==null?sD:(typeof e=="function"?iD:rD)(e)):this.node().innerHTML}function oD(){this.nextSibling&&this.parentNode.appendChild(this)}function lD(){return this.each(oD)}function cD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function uD(){return this.each(cD)}function dD(e){var t=typeof e=="function"?e:cj(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function hD(){return null}function fD(e,t){var n=typeof e=="function"?e:cj(e),r=t==null?hD:typeof t=="function"?t:lg(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function pD(){var e=this.parentNode;e&&e.removeChild(this)}function mD(){return this.each(pD)}function gD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vD(e){return this.select(e?xD:gD)}function yD(e){return arguments.length?this.property("__data__",e):this.node().__data__}function bD(e){return function(t){e.call(this,t,this.__data__)}}function kD(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function ND(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function wD(e,t,n){return function(){var r=this.__on,i,o=bD(t);if(r){for(var c=0,u=r.length;c<u;++c)if((i=r[c]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function jD(e,t,n){var r=kD(e+""),i,o=r.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var h=0,d=u.length,p;h<d;++h)for(i=0,p=u[h];i<o;++i)if((c=r[i]).type===p.type&&c.name===p.name)return p.value}return}for(u=t?wD:ND,i=0;i<o;++i)this.each(u(r[i],t,n));return this}function yj(e,t,n){var r=pj(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function SD(e,t){return function(){return yj(this,e,t)}}function _D(e,t){return function(){return yj(this,e,t.apply(this,arguments))}}function ED(e,t){return this.each((typeof t=="function"?_D:SD)(e,t))}function*CD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,c;i<o;++i)(c=r[i])&&(yield c)}var bj=[null];function zs(e,t){this._groups=e,this._parents=t}function vc(){return new zs([[document.documentElement]],bj)}function AD(){return this}zs.prototype=vc.prototype={constructor:zs,select:tL,selectAll:iL,selectChild:cL,selectChildren:fL,filter:pL,data:bL,enter:mL,exit:NL,join:wL,merge:jL,selection:AD,order:SL,sort:_L,call:CL,nodes:AL,node:IL,size:TL,empty:$L,each:ML,attr:FL,style:ZL,property:GL,classed:QL,text:nD,html:aD,raise:lD,lower:uD,append:dD,insert:fD,remove:mD,clone:vD,datum:yD,on:jD,dispatch:ED,[Symbol.iterator]:CD};function Ms(e){return typeof e=="string"?new zs([[document.querySelector(e)]],[document.documentElement]):new zs([[e]],bj)}function ID(e){let t;for(;t=e.sourceEvent;)e=t;return e}function gr(e,t){if(e=ID(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const TD={passive:!1},Jl={capture:!0,passive:!1};function np(e){e.stopImmediatePropagation()}function wo(e){e.preventDefault(),e.stopImmediatePropagation()}function kj(e){var t=e.document.documentElement,n=Ms(e).on("dragstart.drag",wo,Jl);"onselectstart"in t?n.on("selectstart.drag",wo,Jl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Nj(e,t){var n=e.document.documentElement,r=Ms(e).on("dragstart.drag",null);t&&(r.on("click.drag",wo,Jl),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Iu=e=>()=>e;function am(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:c,y:u,dx:h,dy:d,dispatch:p}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:p}})}am.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function $D(e){return!e.ctrlKey&&!e.button}function MD(){return this.parentNode}function RD(e,t){return t??{x:e.x,y:e.y}}function OD(){return navigator.maxTouchPoints||"ontouchstart"in this}function wj(){var e=$D,t=MD,n=RD,r=OD,i={},o=Md("start","drag","end"),c=0,u,h,d,p,m=0;function g(I){I.on("mousedown.drag",x).filter(r).on("touchstart.drag",N).on("touchmove.drag",w,TD).on("touchend.drag touchcancel.drag",T).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(I,L){if(!(p||!e.call(this,I,L))){var z=k(this,t.call(this,I,L),I,L,"mouse");z&&(Ms(I.view).on("mousemove.drag",y,Jl).on("mouseup.drag",E,Jl),kj(I.view),np(I),d=!1,u=I.clientX,h=I.clientY,z("start",I))}}function y(I){if(wo(I),!d){var L=I.clientX-u,z=I.clientY-h;d=L*L+z*z>m}i.mouse("drag",I)}function E(I){Ms(I.view).on("mousemove.drag mouseup.drag",null),Nj(I.view,d),wo(I),i.mouse("end",I)}function N(I,L){if(e.call(this,I,L)){var z=I.changedTouches,U=t.call(this,I,L),V=z.length,$,P;for($=0;$<V;++$)(P=k(this,U,I,L,z[$].identifier,z[$]))&&(np(I),P("start",I,z[$]))}}function w(I){var L=I.changedTouches,z=L.length,U,V;for(U=0;U<z;++U)(V=i[L[U].identifier])&&(wo(I),V("drag",I,L[U]))}function T(I){var L=I.changedTouches,z=L.length,U,V;for(p&&clearTimeout(p),p=setTimeout(function(){p=null},500),U=0;U<z;++U)(V=i[L[U].identifier])&&(np(I),V("end",I,L[U]))}function k(I,L,z,U,V,$){var P=o.copy(),D=gr($||z,L),B,_,C;if((C=n.call(I,new am("beforestart",{sourceEvent:z,target:g,identifier:V,active:c,x:D[0],y:D[1],dx:0,dy:0,dispatch:P}),U))!=null)return B=C.x-D[0]||0,_=C.y-D[1]||0,function R(M,F,H){var W=D,K;switch(M){case"start":i[V]=R,K=c++;break;case"end":delete i[V],--c;case"drag":D=gr(H||F,L),K=c;break}P.call(M,I,new am(M,{sourceEvent:F,subject:C,target:g,identifier:V,active:K,x:D[0]+B,y:D[1]+_,dx:D[0]-W[0],dy:D[1]-W[1],dispatch:P}),U)}}return g.filter=function(I){return arguments.length?(e=typeof I=="function"?I:Iu(!!I),g):e},g.container=function(I){return arguments.length?(t=typeof I=="function"?I:Iu(I),g):t},g.subject=function(I){return arguments.length?(n=typeof I=="function"?I:Iu(I),g):n},g.touchable=function(I){return arguments.length?(r=typeof I=="function"?I:Iu(!!I),g):r},g.on=function(){var I=o.on.apply(o,arguments);return I===o?g:I},g.clickDistance=function(I){return arguments.length?(m=(I=+I)*I,g):Math.sqrt(m)},g}function ug(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function jj(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function yc(){}var ec=.7,dd=1/ec,jo="\\s*([+-]?\\d+)\\s*",tc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Hr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",zD=/^#([0-9a-f]{3,8})$/,PD=new RegExp(`^rgb\\(${jo},${jo},${jo}\\)$`),LD=new RegExp(`^rgb\\(${Hr},${Hr},${Hr}\\)$`),DD=new RegExp(`^rgba\\(${jo},${jo},${jo},${tc}\\)$`),FD=new RegExp(`^rgba\\(${Hr},${Hr},${Hr},${tc}\\)$`),BD=new RegExp(`^hsl\\(${tc},${Hr},${Hr}\\)$`),UD=new RegExp(`^hsla\\(${tc},${Hr},${Hr},${tc}\\)$`),Fy={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};ug(yc,Ta,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:By,formatHex:By,formatHex8:HD,formatHsl:ZD,formatRgb:Uy,toString:Uy});function By(){return this.rgb().formatHex()}function HD(){return this.rgb().formatHex8()}function ZD(){return Sj(this).formatHsl()}function Uy(){return this.rgb().formatRgb()}function Ta(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=zD.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Hy(t):n===3?new Ns(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Tu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Tu(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=PD.exec(e))?new Ns(t[1],t[2],t[3],1):(t=LD.exec(e))?new Ns(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=DD.exec(e))?Tu(t[1],t[2],t[3],t[4]):(t=FD.exec(e))?Tu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=BD.exec(e))?Vy(t[1],t[2]/100,t[3]/100,1):(t=UD.exec(e))?Vy(t[1],t[2]/100,t[3]/100,t[4]):Fy.hasOwnProperty(e)?Hy(Fy[e]):e==="transparent"?new Ns(NaN,NaN,NaN,0):null}function Hy(e){return new Ns(e>>16&255,e>>8&255,e&255,1)}function Tu(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ns(e,t,n,r)}function WD(e){return e instanceof yc||(e=Ta(e)),e?(e=e.rgb(),new Ns(e.r,e.g,e.b,e.opacity)):new Ns}function om(e,t,n,r){return arguments.length===1?WD(e):new Ns(e,t,n,r??1)}function Ns(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ug(Ns,om,jj(yc,{brighter(e){return e=e==null?dd:Math.pow(dd,e),new Ns(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ec:Math.pow(ec,e),new Ns(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ns(Ea(this.r),Ea(this.g),Ea(this.b),hd(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:Zy,formatHex:Zy,formatHex8:VD,formatRgb:Wy,toString:Wy}));function Zy(){return`#${Na(this.r)}${Na(this.g)}${Na(this.b)}`}function VD(){return`#${Na(this.r)}${Na(this.g)}${Na(this.b)}${Na((isNaN(this.opacity)?1:this.opacity)*255)}`}function Wy(){const e=hd(this.opacity);return`${e===1?"rgb(":"rgba("}${Ea(this.r)}, ${Ea(this.g)}, ${Ea(this.b)}${e===1?")":`, ${e})`}`}function hd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ea(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Na(e){return e=Ea(e),(e<16?"0":"")+e.toString(16)}function Vy(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new yr(e,t,n,r)}function Sj(e){if(e instanceof yr)return new yr(e.h,e.s,e.l,e.opacity);if(e instanceof yc||(e=Ta(e)),!e)return new yr;if(e instanceof yr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),c=NaN,u=o-i,h=(o+i)/2;return u?(t===o?c=(n-r)/u+(n<r)*6:n===o?c=(r-t)/u+2:c=(t-n)/u+4,u/=h<.5?o+i:2-o-i,c*=60):u=h>0&&h<1?0:c,new yr(c,u,h,e.opacity)}function qD(e,t,n,r){return arguments.length===1?Sj(e):new yr(e,t,n,r??1)}function yr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ug(yr,qD,jj(yc,{brighter(e){return e=e==null?dd:Math.pow(dd,e),new yr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ec:Math.pow(ec,e),new yr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Ns(sp(e>=240?e-240:e+120,i,r),sp(e,i,r),sp(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new yr(qy(this.h),$u(this.s),$u(this.l),hd(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=hd(this.opacity);return`${e===1?"hsl(":"hsla("}${qy(this.h)}, ${$u(this.s)*100}%, ${$u(this.l)*100}%${e===1?")":`, ${e})`}`}}));function qy(e){return e=(e||0)%360,e<0?e+360:e}function $u(e){return Math.max(0,Math.min(1,e||0))}function sp(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 dg=e=>()=>e;function GD(e,t){return function(n){return e+n*t}}function KD(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function YD(e){return(e=+e)==1?_j:function(t,n){return n-t?KD(t,n,e):dg(isNaN(t)?n:t)}}function _j(e,t){var n=t-e;return n?GD(e,n):dg(isNaN(e)?t:e)}const fd=(function e(t){var n=YD(t);function r(i,o){var c=n((i=om(i)).r,(o=om(o)).r),u=n(i.g,o.g),h=n(i.b,o.b),d=_j(i.opacity,o.opacity);return function(p){return i.r=c(p),i.g=u(p),i.b=h(p),i.opacity=d(p),i+""}}return r.gamma=e,r})(1);function XD(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=e[i]*(1-o)+t[i]*o;return r}}function QD(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function JD(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),o=new Array(n),c;for(c=0;c<r;++c)i[c]=ql(e[c],t[c]);for(;c<n;++c)o[c]=t[c];return function(u){for(c=0;c<r;++c)o[c]=i[c](u);return o}}function e3(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ur(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function t3(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=ql(e[i],t[i]):r[i]=t[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var lm=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,rp=new RegExp(lm.source,"g");function n3(e){return function(){return e}}function s3(e){return function(t){return e(t)+""}}function Ej(e,t){var n=lm.lastIndex=rp.lastIndex=0,r,i,o,c=-1,u=[],h=[];for(e=e+"",t=t+"";(r=lm.exec(e))&&(i=rp.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),u[c]?u[c]+=o:u[++c]=o),(r=r[0])===(i=i[0])?u[c]?u[c]+=i:u[++c]=i:(u[++c]=null,h.push({i:c,x:Ur(r,i)})),n=rp.lastIndex;return n<t.length&&(o=t.slice(n),u[c]?u[c]+=o:u[++c]=o),u.length<2?h[0]?s3(h[0].x):n3(t):(t=h.length,function(d){for(var p=0,m;p<t;++p)u[(m=h[p]).i]=m.x(d);return u.join("")})}function ql(e,t){var n=typeof t,r;return t==null||n==="boolean"?dg(t):(n==="number"?Ur:n==="string"?(r=Ta(t))?(t=r,fd):Ej:t instanceof Ta?fd:t instanceof Date?e3:QD(t)?XD:Array.isArray(t)?JD:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?t3:Ur)(e,t)}var Gy=180/Math.PI,cm={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Cj(e,t,n,r,i,o){var c,u,h;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(h=e*n+t*r)&&(n-=e*h,r-=t*h),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,h/=u),e*r<t*n&&(e=-e,t=-t,h=-h,c=-c),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*Gy,skewX:Math.atan(h)*Gy,scaleX:c,scaleY:u}}var Mu;function r3(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?cm:Cj(t.a,t.b,t.c,t.d,t.e,t.f)}function i3(e){return e==null||(Mu||(Mu=document.createElementNS("http://www.w3.org/2000/svg","g")),Mu.setAttribute("transform",e),!(e=Mu.transform.baseVal.consolidate()))?cm:(e=e.matrix,Cj(e.a,e.b,e.c,e.d,e.e,e.f))}function Aj(e,t,n,r){function i(d){return d.length?d.pop()+" ":""}function o(d,p,m,g,x,y){if(d!==m||p!==g){var E=x.push("translate(",null,t,null,n);y.push({i:E-4,x:Ur(d,m)},{i:E-2,x:Ur(p,g)})}else(m||g)&&x.push("translate("+m+t+g+n)}function c(d,p,m,g){d!==p?(d-p>180?p+=360:p-d>180&&(d+=360),g.push({i:m.push(i(m)+"rotate(",null,r)-2,x:Ur(d,p)})):p&&m.push(i(m)+"rotate("+p+r)}function u(d,p,m,g){d!==p?g.push({i:m.push(i(m)+"skewX(",null,r)-2,x:Ur(d,p)}):p&&m.push(i(m)+"skewX("+p+r)}function h(d,p,m,g,x,y){if(d!==m||p!==g){var E=x.push(i(x)+"scale(",null,",",null,")");y.push({i:E-4,x:Ur(d,m)},{i:E-2,x:Ur(p,g)})}else(m!==1||g!==1)&&x.push(i(x)+"scale("+m+","+g+")")}return function(d,p){var m=[],g=[];return d=e(d),p=e(p),o(d.translateX,d.translateY,p.translateX,p.translateY,m,g),c(d.rotate,p.rotate,m,g),u(d.skewX,p.skewX,m,g),h(d.scaleX,d.scaleY,p.scaleX,p.scaleY,m,g),d=p=null,function(x){for(var y=-1,E=g.length,N;++y<E;)m[(N=g[y]).i]=N.x(x);return m.join("")}}}var a3=Aj(r3,"px, ","px)","deg)"),o3=Aj(i3,", ",")",")"),l3=1e-12;function Ky(e){return((e=Math.exp(e))+1/e)/2}function c3(e){return((e=Math.exp(e))-1/e)/2}function u3(e){return((e=Math.exp(2*e))-1)/(e+1)}const Vu=(function e(t,n,r){function i(o,c){var u=o[0],h=o[1],d=o[2],p=c[0],m=c[1],g=c[2],x=p-u,y=m-h,E=x*x+y*y,N,w;if(E<l3)w=Math.log(g/d)/t,N=function(U){return[u+U*x,h+U*y,d*Math.exp(t*U*w)]};else{var T=Math.sqrt(E),k=(g*g-d*d+r*E)/(2*d*n*T),I=(g*g-d*d-r*E)/(2*g*n*T),L=Math.log(Math.sqrt(k*k+1)-k),z=Math.log(Math.sqrt(I*I+1)-I);w=(z-L)/t,N=function(U){var V=U*w,$=Ky(L),P=d/(n*T)*($*u3(t*V+L)-c3(L));return[u+P*x,h+P*y,d*$/Ky(t*V+L)]}}return N.duration=w*1e3*t/Math.SQRT2,N}return i.rho=function(o){var c=Math.max(.001,+o),u=c*c,h=u*u;return e(c,u,h)},i})(Math.SQRT2,2,4);var Po=0,Dl=0,Il=0,Ij=1e3,pd,Fl,md=0,$a=0,Od=0,nc=typeof performance=="object"&&performance.now?performance:Date,Tj=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function hg(){return $a||(Tj(d3),$a=nc.now()+Od)}function d3(){$a=0}function gd(){this._call=this._time=this._next=null}gd.prototype=$j.prototype={constructor:gd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?hg():+n)+(t==null?0:+t),!this._next&&Fl!==this&&(Fl?Fl._next=this:pd=this,Fl=this),this._call=e,this._time=n,um()},stop:function(){this._call&&(this._call=null,this._time=1/0,um())}};function $j(e,t,n){var r=new gd;return r.restart(e,t,n),r}function h3(){hg(),++Po;for(var e=pd,t;e;)(t=$a-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Po}function Yy(){$a=(md=nc.now())+Od,Po=Dl=0;try{h3()}finally{Po=0,p3(),$a=0}}function f3(){var e=nc.now(),t=e-md;t>Ij&&(Od-=t,md=e)}function p3(){for(var e,t=pd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:pd=n);Fl=e,um(r)}function um(e){if(!Po){Dl&&(Dl=clearTimeout(Dl));var t=e-$a;t>24?(e<1/0&&(Dl=setTimeout(Yy,e-nc.now()-Od)),Il&&(Il=clearInterval(Il))):(Il||(md=nc.now(),Il=setInterval(f3,Ij)),Po=1,Tj(Yy))}}function Xy(e,t,n){var r=new gd;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var m3=Md("start","end","cancel","interrupt"),g3=[],Mj=0,Qy=1,dm=2,qu=3,Jy=4,hm=5,Gu=6;function zd(e,t,n,r,i,o){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;x3(e,n,{name:t,index:r,group:i,on:m3,tween:g3,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Mj})}function fg(e,t){var n=Cr(e,t);if(n.state>Mj)throw new Error("too late; already scheduled");return n}function Zr(e,t){var n=Cr(e,t);if(n.state>qu)throw new Error("too late; already running");return n}function Cr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function x3(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=$j(o,0,n.time);function o(d){n.state=Qy,n.timer.restart(c,n.delay,n.time),n.delay<=d&&c(d-n.delay)}function c(d){var p,m,g,x;if(n.state!==Qy)return h();for(p in r)if(x=r[p],x.name===n.name){if(x.state===qu)return Xy(c);x.state===Jy?(x.state=Gu,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete r[p]):+p<t&&(x.state=Gu,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete r[p])}if(Xy(function(){n.state===qu&&(n.state=Jy,n.timer.restart(u,n.delay,n.time),u(d))}),n.state=dm,n.on.call("start",e,e.__data__,n.index,n.group),n.state===dm){for(n.state=qu,i=new Array(g=n.tween.length),p=0,m=-1;p<g;++p)(x=n.tween[p].value.call(e,e.__data__,n.index,n.group))&&(i[++m]=x);i.length=m+1}}function u(d){for(var p=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(h),n.state=hm,1),m=-1,g=i.length;++m<g;)i[m].call(e,p);n.state===hm&&(n.on.call("end",e,e.__data__,n.index,n.group),h())}function h(){n.state=Gu,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function Ku(e,t){var n=e.__transition,r,i,o=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((r=n[c]).name!==t){o=!1;continue}i=r.state>dm&&r.state<hm,r.state=Gu,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[c]}o&&delete e.__transition}}function v3(e){return this.each(function(){Ku(this,e)})}function y3(e,t){var n,r;return function(){var i=Zr(this,e),o=i.tween;if(o!==n){r=n=o;for(var c=0,u=r.length;c<u;++c)if(r[c].name===t){r=r.slice(),r.splice(c,1);break}}i.tween=r}}function b3(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Zr(this,e),c=o.tween;if(c!==r){i=(r=c).slice();for(var u={name:t,value:n},h=0,d=i.length;h<d;++h)if(i[h].name===t){i[h]=u;break}h===d&&i.push(u)}o.tween=i}}function k3(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Cr(this.node(),n).tween,i=0,o=r.length,c;i<o;++i)if((c=r[i]).name===e)return c.value;return null}return this.each((t==null?y3:b3)(n,e,t))}function pg(e,t,n){var r=e._id;return e.each(function(){var i=Zr(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Cr(i,r).value[t]}}function Rj(e,t){var n;return(typeof t=="number"?Ur:t instanceof Ta?fd:(n=Ta(t))?(t=n,fd):Ej)(e,t)}function N3(e){return function(){this.removeAttribute(e)}}function w3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function j3(e,t,n){var r,i=n+"",o;return function(){var c=this.getAttribute(e);return c===i?null:c===r?o:o=t(r=c,n)}}function S3(e,t,n){var r,i=n+"",o;return function(){var c=this.getAttributeNS(e.space,e.local);return c===i?null:c===r?o:o=t(r=c,n)}}function _3(e,t,n){var r,i,o;return function(){var c,u=n(this),h;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),h=u+"",c===h?null:c===r&&h===i?o:(i=h,o=t(r=c,u)))}}function E3(e,t,n){var r,i,o;return function(){var c,u=n(this),h;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),h=u+"",c===h?null:c===r&&h===i?o:(i=h,o=t(r=c,u)))}}function C3(e,t){var n=Rd(e),r=n==="transform"?o3:Rj;return this.attrTween(e,typeof t=="function"?(n.local?E3:_3)(n,r,pg(this,"attr."+e,t)):t==null?(n.local?w3:N3)(n):(n.local?S3:j3)(n,r,t))}function A3(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function I3(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function T3(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&I3(e,o)),n}return i._value=t,i}function $3(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&A3(e,o)),n}return i._value=t,i}function M3(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Rd(e);return this.tween(n,(r.local?T3:$3)(r,t))}function R3(e,t){return function(){fg(this,e).delay=+t.apply(this,arguments)}}function O3(e,t){return t=+t,function(){fg(this,e).delay=t}}function z3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?R3:O3)(t,e)):Cr(this.node(),t).delay}function P3(e,t){return function(){Zr(this,e).duration=+t.apply(this,arguments)}}function L3(e,t){return t=+t,function(){Zr(this,e).duration=t}}function D3(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?P3:L3)(t,e)):Cr(this.node(),t).duration}function F3(e,t){if(typeof t!="function")throw new Error;return function(){Zr(this,e).ease=t}}function B3(e){var t=this._id;return arguments.length?this.each(F3(t,e)):Cr(this.node(),t).ease}function U3(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Zr(this,e).ease=n}}function H3(e){if(typeof e!="function")throw new Error;return this.each(U3(this._id,e))}function Z3(e){typeof e!="function"&&(e=dj(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],c=o.length,u=r[i]=[],h,d=0;d<c;++d)(h=o[d])&&e.call(h,h.__data__,d,o)&&u.push(h);return new pi(r,this._parents,this._name,this._id)}function W3(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),c=new Array(r),u=0;u<o;++u)for(var h=t[u],d=n[u],p=h.length,m=c[u]=new Array(p),g,x=0;x<p;++x)(g=h[x]||d[x])&&(m[x]=g);for(;u<r;++u)c[u]=t[u];return new pi(c,this._parents,this._name,this._id)}function V3(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 q3(e,t,n){var r,i,o=V3(t)?fg:Zr;return function(){var c=o(this,e),u=c.on;u!==r&&(i=(r=u).copy()).on(t,n),c.on=i}}function G3(e,t){var n=this._id;return arguments.length<2?Cr(this.node(),n).on.on(e):this.each(q3(n,e,t))}function K3(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Y3(){return this.on("end.remove",K3(this._id))}function X3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=lg(e));for(var r=this._groups,i=r.length,o=new Array(i),c=0;c<i;++c)for(var u=r[c],h=u.length,d=o[c]=new Array(h),p,m,g=0;g<h;++g)(p=u[g])&&(m=e.call(p,p.__data__,g,u))&&("__data__"in p&&(m.__data__=p.__data__),d[g]=m,zd(d[g],t,n,g,d,Cr(p,n)));return new pi(o,this._parents,t,n)}function Q3(e){var t=this._name,n=this._id;typeof e!="function"&&(e=uj(e));for(var r=this._groups,i=r.length,o=[],c=[],u=0;u<i;++u)for(var h=r[u],d=h.length,p,m=0;m<d;++m)if(p=h[m]){for(var g=e.call(p,p.__data__,m,h),x,y=Cr(p,n),E=0,N=g.length;E<N;++E)(x=g[E])&&zd(x,t,n,E,g,y);o.push(g),c.push(p)}return new pi(o,c,t,n)}var J3=vc.prototype.constructor;function e4(){return new J3(this._groups,this._parents)}function t4(e,t){var n,r,i;return function(){var o=zo(this,e),c=(this.style.removeProperty(e),zo(this,e));return o===c?null:o===n&&c===r?i:i=t(n=o,r=c)}}function Oj(e){return function(){this.style.removeProperty(e)}}function n4(e,t,n){var r,i=n+"",o;return function(){var c=zo(this,e);return c===i?null:c===r?o:o=t(r=c,n)}}function s4(e,t,n){var r,i,o;return function(){var c=zo(this,e),u=n(this),h=u+"";return u==null&&(h=u=(this.style.removeProperty(e),zo(this,e))),c===h?null:c===r&&h===i?o:(i=h,o=t(r=c,u))}}function r4(e,t){var n,r,i,o="style."+t,c="end."+o,u;return function(){var h=Zr(this,e),d=h.on,p=h.value[o]==null?u||(u=Oj(t)):void 0;(d!==n||i!==p)&&(r=(n=d).copy()).on(c,i=p),h.on=r}}function i4(e,t,n){var r=(e+="")=="transform"?a3:Rj;return t==null?this.styleTween(e,t4(e,r)).on("end.style."+e,Oj(e)):typeof t=="function"?this.styleTween(e,s4(e,r,pg(this,"style."+e,t))).each(r4(this._id,e)):this.styleTween(e,n4(e,r,t),n).on("end.style."+e,null)}function a4(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function o4(e,t,n){var r,i;function o(){var c=t.apply(this,arguments);return c!==i&&(r=(i=c)&&a4(e,c,n)),r}return o._value=t,o}function l4(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,o4(e,t,n??""))}function c4(e){return function(){this.textContent=e}}function u4(e){return function(){var t=e(this);this.textContent=t??""}}function d4(e){return this.tween("text",typeof e=="function"?u4(pg(this,"text",e)):c4(e==null?"":e+""))}function h4(e){return function(t){this.textContent=e.call(this,t)}}function f4(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&h4(i)),t}return r._value=e,r}function p4(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,f4(e))}function m4(){for(var e=this._name,t=this._id,n=zj(),r=this._groups,i=r.length,o=0;o<i;++o)for(var c=r[o],u=c.length,h,d=0;d<u;++d)if(h=c[d]){var p=Cr(h,t);zd(h,e,n,d,c,{time:p.time+p.delay+p.duration,delay:0,duration:p.duration,ease:p.ease})}return new pi(r,this._parents,e,n)}function g4(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,c){var u={value:c},h={value:function(){--i===0&&o()}};n.each(function(){var d=Zr(this,r),p=d.on;p!==e&&(t=(e=p).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(h)),d.on=t}),i===0&&o()})}var x4=0;function pi(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function zj(){return++x4}var li=vc.prototype;pi.prototype={constructor:pi,select:X3,selectAll:Q3,selectChild:li.selectChild,selectChildren:li.selectChildren,filter:Z3,merge:W3,selection:e4,transition:m4,call:li.call,nodes:li.nodes,node:li.node,size:li.size,empty:li.empty,each:li.each,on:G3,attr:C3,attrTween:M3,style:i4,styleTween:l4,text:d4,textTween:p4,remove:Y3,tween:k3,delay:z3,duration:D3,ease:B3,easeVarying:H3,end:g4,[Symbol.iterator]:li[Symbol.iterator]};function v4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var y4={time:null,delay:0,duration:250,ease:v4};function b4(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 k4(e){var t,n;e instanceof pi?(t=e._id,e=e._name):(t=zj(),(n=y4).time=hg(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var c=r[o],u=c.length,h,d=0;d<u;++d)(h=c[d])&&zd(h,e,t,d,c,n||b4(h,t));return new pi(r,this._parents,e,t)}vc.prototype.interrupt=v3;vc.prototype.transition=k4;const Ru=e=>()=>e;function N4(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function di(e,t,n){this.k=e,this.x=t,this.y=n}di.prototype={constructor:di,scale:function(e){return e===1?this:new di(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new di(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 Pd=new di(1,0,0);Pj.prototype=di.prototype;function Pj(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Pd;return e.__zoom}function ip(e){e.stopImmediatePropagation()}function Tl(e){e.preventDefault(),e.stopImmediatePropagation()}function w4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function j4(){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 eb(){return this.__zoom||Pd}function S4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function _4(){return navigator.maxTouchPoints||"ontouchstart"in this}function E4(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),c>o?(o+c)/2:Math.min(0,o)||Math.max(0,c))}function Lj(){var e=w4,t=j4,n=E4,r=S4,i=_4,o=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,h=Vu,d=Md("start","zoom","end"),p,m,g,x=500,y=150,E=0,N=10;function w(C){C.property("__zoom",eb).on("wheel.zoom",V,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",P).filter(i).on("touchstart.zoom",D).on("touchmove.zoom",B).on("touchend.zoom touchcancel.zoom",_).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(C,R,M,F){var H=C.selection?C.selection():C;H.property("__zoom",eb),C!==H?L(C,R,M,F):H.interrupt().each(function(){z(this,arguments).event(F).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},w.scaleBy=function(C,R,M,F){w.scaleTo(C,function(){var H=this.__zoom.k,W=typeof R=="function"?R.apply(this,arguments):R;return H*W},M,F)},w.scaleTo=function(C,R,M,F){w.transform(C,function(){var H=t.apply(this,arguments),W=this.__zoom,K=M==null?I(H):typeof M=="function"?M.apply(this,arguments):M,q=W.invert(K),Y=typeof R=="function"?R.apply(this,arguments):R;return n(k(T(W,Y),K,q),H,c)},M,F)},w.translateBy=function(C,R,M,F){w.transform(C,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),c)},null,F)},w.translateTo=function(C,R,M,F,H){w.transform(C,function(){var W=t.apply(this,arguments),K=this.__zoom,q=F==null?I(W):typeof F=="function"?F.apply(this,arguments):F;return n(Pd.translate(q[0],q[1]).scale(K.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof M=="function"?-M.apply(this,arguments):-M),W,c)},F,H)};function T(C,R){return R=Math.max(o[0],Math.min(o[1],R)),R===C.k?C:new di(R,C.x,C.y)}function k(C,R,M){var F=R[0]-M[0]*C.k,H=R[1]-M[1]*C.k;return F===C.x&&H===C.y?C:new di(C.k,F,H)}function I(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function L(C,R,M,F){C.on("start.zoom",function(){z(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){z(this,arguments).event(F).end()}).tween("zoom",function(){var H=this,W=arguments,K=z(H,W).event(F),q=t.apply(H,W),Y=M==null?I(q):typeof M=="function"?M.apply(H,W):M,fe=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),me=H.__zoom,xe=typeof R=="function"?R.apply(H,W):R,oe=h(me.invert(Y).concat(fe/me.k),xe.invert(Y).concat(fe/xe.k));return function(re){if(re===1)re=xe;else{var ie=oe(re),ye=fe/ie[2];re=new di(ye,Y[0]-ie[0]*ye,Y[1]-ie[1]*ye)}K.zoom(null,re)}})}function z(C,R,M){return!M&&C.__zooming||new U(C,R)}function U(C,R){this.that=C,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,R),this.taps=0}U.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,R){return this.mouse&&C!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var R=Ms(this.that).datum();d.call(C,this.that,new N4(C,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:d}),R)}};function V(C,...R){if(!e.apply(this,arguments))return;var M=z(this,R).event(C),F=this.__zoom,H=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),W=gr(C);if(M.wheel)(M.mouse[0][0]!==W[0]||M.mouse[0][1]!==W[1])&&(M.mouse[1]=F.invert(M.mouse[0]=W)),clearTimeout(M.wheel);else{if(F.k===H)return;M.mouse=[W,F.invert(W)],Ku(this),M.start()}Tl(C),M.wheel=setTimeout(K,y),M.zoom("mouse",n(k(T(F,H),M.mouse[0],M.mouse[1]),M.extent,c));function K(){M.wheel=null,M.end()}}function $(C,...R){if(g||!e.apply(this,arguments))return;var M=C.currentTarget,F=z(this,R,!0).event(C),H=Ms(C.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",fe,!0),W=gr(C,M),K=C.clientX,q=C.clientY;kj(C.view),ip(C),F.mouse=[W,this.__zoom.invert(W)],Ku(this),F.start();function Y(me){if(Tl(me),!F.moved){var xe=me.clientX-K,oe=me.clientY-q;F.moved=xe*xe+oe*oe>E}F.event(me).zoom("mouse",n(k(F.that.__zoom,F.mouse[0]=gr(me,M),F.mouse[1]),F.extent,c))}function fe(me){H.on("mousemove.zoom mouseup.zoom",null),Nj(me.view,F.moved),Tl(me),F.event(me).end()}}function P(C,...R){if(e.apply(this,arguments)){var M=this.__zoom,F=gr(C.changedTouches?C.changedTouches[0]:C,this),H=M.invert(F),W=M.k*(C.shiftKey?.5:2),K=n(k(T(M,W),F,H),t.apply(this,R),c);Tl(C),u>0?Ms(this).transition().duration(u).call(L,K,F,C):Ms(this).call(w.transform,K,F,C)}}function D(C,...R){if(e.apply(this,arguments)){var M=C.touches,F=M.length,H=z(this,R,C.changedTouches.length===F).event(C),W,K,q,Y;for(ip(C),K=0;K<F;++K)q=M[K],Y=gr(q,this),Y=[Y,this.__zoom.invert(Y),q.identifier],H.touch0?!H.touch1&&H.touch0[2]!==Y[2]&&(H.touch1=Y,H.taps=0):(H.touch0=Y,W=!0,H.taps=1+!!p);p&&(p=clearTimeout(p)),W&&(H.taps<2&&(m=Y[0],p=setTimeout(function(){p=null},x)),Ku(this),H.start())}}function B(C,...R){if(this.__zooming){var M=z(this,R).event(C),F=C.changedTouches,H=F.length,W,K,q,Y;for(Tl(C),W=0;W<H;++W)K=F[W],q=gr(K,this),M.touch0&&M.touch0[2]===K.identifier?M.touch0[0]=q:M.touch1&&M.touch1[2]===K.identifier&&(M.touch1[0]=q);if(K=M.that.__zoom,M.touch1){var fe=M.touch0[0],me=M.touch0[1],xe=M.touch1[0],oe=M.touch1[1],re=(re=xe[0]-fe[0])*re+(re=xe[1]-fe[1])*re,ie=(ie=oe[0]-me[0])*ie+(ie=oe[1]-me[1])*ie;K=T(K,Math.sqrt(re/ie)),q=[(fe[0]+xe[0])/2,(fe[1]+xe[1])/2],Y=[(me[0]+oe[0])/2,(me[1]+oe[1])/2]}else if(M.touch0)q=M.touch0[0],Y=M.touch0[1];else return;M.zoom("touch",n(k(K,q,Y),M.extent,c))}}function _(C,...R){if(this.__zooming){var M=z(this,R).event(C),F=C.changedTouches,H=F.length,W,K;for(ip(C),g&&clearTimeout(g),g=setTimeout(function(){g=null},x),W=0;W<H;++W)K=F[W],M.touch0&&M.touch0[2]===K.identifier?delete M.touch0:M.touch1&&M.touch1[2]===K.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(K=gr(K,this),Math.hypot(m[0]-K[0],m[1]-K[1])<N)){var q=Ms(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return w.wheelDelta=function(C){return arguments.length?(r=typeof C=="function"?C:Ru(+C),w):r},w.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Ru(!!C),w):e},w.touchable=function(C){return arguments.length?(i=typeof C=="function"?C:Ru(!!C),w):i},w.extent=function(C){return arguments.length?(t=typeof C=="function"?C:Ru([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),w):t},w.scaleExtent=function(C){return arguments.length?(o[0]=+C[0],o[1]=+C[1],w):[o[0],o[1]]},w.translateExtent=function(C){return arguments.length?(c[0][0]=+C[0][0],c[1][0]=+C[1][0],c[0][1]=+C[0][1],c[1][1]=+C[1][1],w):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},w.constrain=function(C){return arguments.length?(n=C,w):n},w.duration=function(C){return arguments.length?(u=+C,w):u},w.interpolate=function(C){return arguments.length?(h=C,w):h},w.on=function(){var C=d.on.apply(d,arguments);return C===d?w:C},w.clickDistance=function(C){return arguments.length?(E=(C=+C)*C,w):Math.sqrt(E)},w.tapDistance=function(C){return arguments.length?(N=+C,w):N},w}const Sr={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},sc=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Dj=["Enter"," ","Escape"],Fj={"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 Lo;(function(e){e.Strict="strict",e.Loose="loose"})(Lo||(Lo={}));var Ca;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ca||(Ca={}));var rc;(function(e){e.Partial="partial",e.Full="full"})(rc||(rc={}));const Bj={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Di;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Di||(Di={}));var xd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xd||(xd={}));var Je;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Je||(Je={}));const tb={[Je.Left]:Je.Right,[Je.Right]:Je.Left,[Je.Top]:Je.Bottom,[Je.Bottom]:Je.Top},Uj=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,C4=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),mg=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),bc=(e,t=[0,0])=>{const{width:n,height:r}=Ar(e),i=e.origin??t,o=n*i[0],c=r*i[1];return{x:e.position.x-o,y:e.position.y-c}},A4=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const r=e.reduce((i,o)=>{const c=typeof o=="string";let u=!t.nodeLookup&&!c?o:void 0;return t.nodeLookup&&(u=c?t.nodeLookup.get(o):mg(o)?o:t.nodeLookup.get(o.id)),u?(n=!0,Ld(i,vd(u,t.nodeOrigin))):i},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Dd(r):{x:0,y:0,width:0,height:0}},kc=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=Ld(n,vd(i)),r=!0)}),r?Dd(n):{x:0,y:0,width:0,height:0}},gg=(e,t,[n,r,i]=[0,0,1],o=!1,c=!1)=>{const u=(t.x-n)/i,h=(t.y-r)/i,d=t.width/i,p=t.height/i,m=[];for(const g of e.values()){const{measured:x,selectable:y=!0,hidden:E=!1}=g;if(c&&!y||E)continue;const N=x.width??g.width??g.initialWidth??0,w=x.height??g.height??g.initialHeight??0,{x:T,y:k}=g.internals.positionAbsolute,I=Vj(u,h,d,p,T,k,N,w),L=N*w,z=o&&I>0;(!g.internals.handleBounds||z||I>=L||g.dragging)&&m.push(g)}return m},I4=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function T4(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{let o;if(t!=null&&t.includeHiddenNodes){const{width:c,height:u}=Ar(i);o=c>0&&u>0}else o=!!(i.measured.width&&i.measured.height&&!i.hidden);o&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function $4({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:o},c){if(e.size===0)return!0;const u=T4(e,c),h=kc(u),d=vg(h,t,n,(c==null?void 0:c.minZoom)??i,(c==null?void 0:c.maxZoom)??o,(c==null?void 0:c.padding)??.1);return await r.setViewport(d,{duration:c==null?void 0:c.duration,ease:c==null?void 0:c.ease,interpolate:c==null?void 0:c.interpolate}),!0}function Hj({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const c=n.get(e),u=c.parentId?n.get(c.parentId):void 0,{x:h,y:d}=u?u.internals.positionAbsolute:{x:0,y:0},p=c.origin??r;let m=c.extent||i;if(c.extent==="parent"&&!c.expandParent)if(!u)o==null||o("005",Sr.error005());else{const{width:x,height:y}=Ar(u);x&&y&&(m=[[h,d],[h+x,d+y]])}else u&&Ra(c.extent)&&(m=[[c.extent[0][0]+h,c.extent[0][1]+d],[c.extent[1][0]+h,c.extent[1][1]+d]]);const g=Ra(m)?Ma(t,m,c.measured):t;return(c.measured.width===void 0||c.measured.height===void 0)&&(o==null||o("015",Sr.error015())),{position:{x:g.x-h+(c.measured.width??0)*p[0],y:g.y-d+(c.measured.height??0)*p[1]},positionAbsolute:g}}async function M4({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const o=new Set(e.map(g=>g.id)),c=[];for(const g of n){if(g.deletable===!1)continue;const x=o.has(g.id),y=!x&&g.parentId&&c.find(E=>E.id===g.parentId);(x||y)&&c.push(g)}const u=new Set(t.map(g=>g.id)),h=r.filter(g=>g.deletable!==!1),p=I4(c,h);for(const g of h)u.has(g.id)&&!p.find(y=>y.id===g.id)&&p.push(g);if(!i)return{edges:p,nodes:c};const m=await i({nodes:c,edges:p});return typeof m=="boolean"?m?{edges:p,nodes:c}:{edges:[],nodes:[]}:m}const Do=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ma=(e={x:0,y:0},t,n)=>({x:Do(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Do(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Zj(e,t,n){const{width:r,height:i}=Ar(n),{x:o,y:c}=n.internals.positionAbsolute;return Ma(e,[[o,c],[o+r,c+i]],t)}const nb=(e,t,n)=>e<t?Do(Math.abs(e-t),1,t)/t:e>n?-Do(Math.abs(e-n),1,t)/t:0,xg=(e,t,n=15,r=40)=>{const i=nb(e.x,r,t.width-r)*n,o=nb(e.y,r,t.height-r)*n;return[i,o]},Ld=(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)}),fm=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Dd=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),ic=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=mg(e)?e.internals.positionAbsolute:bc(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},vd=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=mg(e)?e.internals.positionAbsolute:bc(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},Wj=(e,t)=>Dd(Ld(fm(e),fm(t))),Vj=(e,t,n,r,i,o,c,u)=>{const h=Math.max(0,Math.min(e+n,i+c)-Math.max(e,i)),d=Math.max(0,Math.min(t+r,o+u)-Math.max(t,o));return Math.ceil(h*d)},yd=(e,t)=>Vj(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),sb=e=>br(e.width)&&br(e.height)&&br(e.x)&&br(e.y),br=e=>!isNaN(e)&&isFinite(e),qj=(e,t)=>(n,r)=>{},Nc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),wc=({x:e,y:t},[n,r,i],o=!1,c=[1,1])=>{const u={x:(e-n)/i,y:(t-r)/i};return o?Nc(u,c):u},Fo=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function co(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 R4(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=co(e,n),i=co(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=co(e.top??e.y??0,n),i=co(e.bottom??e.y??0,n),o=co(e.left??e.x??0,t),c=co(e.right??e.x??0,t);return{top:r,right:c,bottom:i,left:o,x:o+c,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function O4(e,t,n,r,i,o){const{x:c,y:u}=Fo(e,[t,n,r]),{x:h,y:d}=Fo({x:e.x+e.width,y:e.y+e.height},[t,n,r]),p=i-h,m=o-d;return{left:Math.floor(c),top:Math.floor(u),right:Math.floor(p),bottom:Math.floor(m)}}const vg=(e,t,n,r,i,o)=>{const c=R4(o,t,n),u=(t-c.x)/e.width,h=(n-c.y)/e.height,d=Math.min(u,h),p=Do(d,r,i),m=e.x+e.width/2,g=e.y+e.height/2,x=t/2-m*p,y=n/2-g*p,E=O4(e,x,y,p,t,n),N={left:Math.min(E.left-c.left,0),top:Math.min(E.top-c.top,0),right:Math.min(E.right-c.right,0),bottom:Math.min(E.bottom-c.bottom,0)};return{x:x-N.left+N.right,y:y-N.top+N.bottom,zoom:p}},ac=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ra(e){return e!=null&&e!=="parent"}function Ar(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 Gj(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 Kj(e,t={width:0,height:0},n,r,i){const o={...e},c=r.get(n);if(c){const u=c.origin||i;o.x+=c.internals.positionAbsolute.x-(t.width??0)*u[0],o.y+=c.internals.positionAbsolute.y-(t.height??0)*u[1]}return o}function rb(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function z4(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function P4(e){return{...Fj,...e||{}}}function Yj(e){return e===null?null:e?"valid":"invalid"}function Gl(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:o,y:c}=kr(e),u=wc({x:o-((i==null?void 0:i.left)??0),y:c-((i==null?void 0:i.top)??0)},r),{x:h,y:d}=n?Nc(u,t):u;return{xSnapped:h,ySnapped:d,...u}}const yg=e=>({width:e.offsetWidth,height:e.offsetHeight}),Xj=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},L4=["INPUT","SELECT","TEXTAREA"];function Qj(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:L4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Jj=e=>"clientX"in e,kr=(e,t)=>{var o,c;const n=Jj(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,i=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},ib=(e,t,n,r,i)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(c=>{const u=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),type:e,nodeId:i,position:c.getAttribute("data-handlepos"),x:(u.left-n.left)/r,y:(u.top-n.top)/r,...yg(c)}})};function eS({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:c,targetControlY:u}){const h=e*.125+i*.375+c*.375+n*.125,d=t*.125+o*.375+u*.375+r*.125,p=Math.abs(h-e),m=Math.abs(d-t);return[h,d,p,m]}function Ou(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ab({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Je.Left:return[t-Ou(t-r,o),n];case Je.Right:return[t+Ou(r-t,o),n];case Je.Top:return[t,n-Ou(n-i,o)];case Je.Bottom:return[t,n+Ou(i-n,o)]}}function tS({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:i,targetPosition:o=Je.Top,curvature:c=.25}){const[u,h]=ab({pos:n,x1:e,y1:t,x2:r,y2:i,c}),[d,p]=ab({pos:o,x1:r,y1:i,x2:e,y2:t,c}),[m,g,x,y]=eS({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:u,sourceControlY:h,targetControlX:d,targetControlY:p});return[`M${e},${t} C${u},${h} ${d},${p} ${r},${i}`,m,g,x,y]}function nS({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n<e?n+i:n-i,c=Math.abs(r-t)/2,u=r<t?r+c:r-c;return[o,u,i,c]}function D4({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const c=i&&n?r+1e3:r,u=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return c+u}function F4({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){const o=Ld(vd(e),vd(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const c={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return yd(c,Dd(o))>0}const B4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,U4=(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)),H4=(e,t,n={})=>{var o;if(!e.source||!e.target)return(o=n.onError)==null||o.call(n,"006",Sr.error006()),t;const r=n.getEdgeId||B4;let i;return Uj(e)?i={...e}:i={...e,id:r(e)},U4(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function sS({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,c,u]=nS({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,c,u]}const ob={[Je.Left]:{x:-1,y:0},[Je.Right]:{x:1,y:0},[Je.Top]:{x:0,y:-1},[Je.Bottom]:{x:0,y:1}},Z4=({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},lb=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function W4({source:e,sourcePosition:t=Je.Bottom,target:n,targetPosition:r=Je.Top,center:i,offset:o,stepPosition:c}){const u=ob[t],h=ob[r],d={x:e.x+u.x*o,y:e.y+u.y*o},p={x:n.x+h.x*o,y:n.y+h.y*o},m=Z4({source:d,sourcePosition:t,target:p}),g=m.x!==0?"x":"y",x=m[g];let y=[],E,N;const w={x:0,y:0},T={x:0,y:0},[,,k,I]=nS({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[g]*h[g]===-1){g==="x"?(E=i.x??d.x+(p.x-d.x)*c,N=i.y??(d.y+p.y)/2):(E=i.x??(d.x+p.x)/2,N=i.y??d.y+(p.y-d.y)*c);const V=[{x:E,y:d.y},{x:E,y:p.y}],$=[{x:d.x,y:N},{x:p.x,y:N}];u[g]===x?y=g==="x"?V:$:y=g==="x"?$:V}else{const V=[{x:d.x,y:p.y}],$=[{x:p.x,y:d.y}];if(g==="x"?y=u.x===x?$:V:y=u.y===x?V:$,t===r){const C=Math.abs(e[g]-n[g]);if(C<=o){const R=Math.min(o-1,o-C);u[g]===x?w[g]=(d[g]>e[g]?-1:1)*R:T[g]=(p[g]>n[g]?-1:1)*R}}if(t!==r){const C=g==="x"?"y":"x",R=u[g]===h[C],M=d[C]>p[C],F=d[C]<p[C];(u[g]===1&&(!R&&M||R&&F)||u[g]!==1&&(!R&&F||R&&M))&&(y=g==="x"?V:$)}const P={x:d.x+w.x,y:d.y+w.y},D={x:p.x+T.x,y:p.y+T.y},B=Math.max(Math.abs(P.x-y[0].x),Math.abs(D.x-y[0].x)),_=Math.max(Math.abs(P.y-y[0].y),Math.abs(D.y-y[0].y));B>=_?(E=(P.x+D.x)/2,N=y[0].y):(E=y[0].x,N=(P.y+D.y)/2)}const L={x:d.x+w.x,y:d.y+w.y},z={x:p.x+T.x,y:p.y+T.y};return[[e,...L.x!==y[0].x||L.y!==y[0].y?[L]:[],...y,...z.x!==y[y.length-1].x||z.y!==y[y.length-1].y?[z]:[],n],E,N,k,I]}function V4(e,t,n,r){const i=Math.min(lb(e,t)/2,lb(t,n)/2,r),{x:o,y:c}=t;if(e.x===o&&o===n.x||e.y===c&&c===n.y)return`L${o} ${c}`;if(e.y===c){const d=e.x<n.x?-1:1,p=e.y<n.y?1:-1;return`L ${o+i*d},${c}Q ${o},${c} ${o},${c+i*p}`}const u=e.x<n.x?1:-1,h=e.y<n.y?-1:1;return`L ${o},${c+i*h}Q ${o},${c} ${o+i*u},${c}`}function pm({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:i,targetPosition:o=Je.Top,borderRadius:c=5,centerX:u,centerY:h,offset:d=20,stepPosition:p=.5}){const[m,g,x,y,E]=W4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:u,y:h},offset:d,stepPosition:p});let N=`M${m[0].x} ${m[0].y}`;for(let w=1;w<m.length-1;w++)N+=V4(m[w-1],m[w],m[w+1],c);return N+=`L${m[m.length-1].x} ${m[m.length-1].y}`,[N,g,x,y,E]}function cb(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function q4(e){var m;const{sourceNode:t,targetNode:n}=e;if(!cb(t)||!cb(n))return null;const r=t.internals.handleBounds||ub(t.handles),i=n.internals.handleBounds||ub(n.handles),o=db((r==null?void 0:r.source)??[],e.sourceHandle),c=db(e.connectionMode===Lo.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),e.targetHandle);if(!o||!c)return(m=e.onError)==null||m.call(e,"008",Sr.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=(o==null?void 0:o.position)||Je.Bottom,h=(c==null?void 0:c.position)||Je.Top,d=Oa(t,o,u),p=Oa(n,c,h);return{sourceX:d.x,sourceY:d.y,targetX:p.x,targetY:p.y,sourcePosition:u,targetPosition:h}}function ub(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Oa(e,t,n=Je.Left,r=!1){const i=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:c,height:u}=t??Ar(e);if(r)return{x:i+c/2,y:o+u/2};switch((t==null?void 0:t.position)??n){case Je.Top:return{x:i+c/2,y:o};case Je.Right:return{x:i+c,y:o+u/2};case Je.Bottom:return{x:i+c/2,y:o+u};case Je.Left:return{x:i,y:o+u/2}}}function db(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function mm(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function G4(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((c,u)=>([u.markerStart||r,u.markerEnd||i].forEach(h=>{if(h&&typeof h=="object"){const d=mm(h,t);o.has(d)||(c.push({id:d,color:h.color||n,...h}),o.add(d))}}),c),[]).sort((c,u)=>c.id.localeCompare(u.id))}const rS=1e3,K4=10,bg={nodeOrigin:[0,0],nodeExtent:sc,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Y4={...bg,checkEquality:!0};function kg(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function X4(e,t,n){const r=kg(bg,n);for(const i of e.values())if(i.parentId)wg(i,e,t,r);else{const o=bc(i,r.nodeOrigin),c=Ra(i.extent)?i.extent:r.nodeExtent,u=Ma(o,c,Ar(i));i.internals.positionAbsolute=u}}function Q4(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(o):i.type==="target"&&r.push(o)}return{source:n,target:r}}function Ng(e){return e==="manual"}function gm(e,t,n,r={}){var p,m;const i=kg(Y4,r),o={i:0},c=new Map(t),u=i!=null&&i.elevateNodesOnSelect&&!Ng(i.zIndexMode)?rS:0;let h=e.length>0,d=!1;t.clear(),n.clear();for(const g of e){let x=c.get(g.id);if(i.checkEquality&&g===(x==null?void 0:x.internals.userNode))t.set(g.id,x);else{const y=bc(g,i.nodeOrigin),E=Ra(g.extent)?g.extent:i.nodeExtent,N=Ma(y,E,Ar(g));x={...i.defaults,...g,measured:{width:(p=g.measured)==null?void 0:p.width,height:(m=g.measured)==null?void 0:m.height},internals:{positionAbsolute:N,handleBounds:Q4(g,x),z:iS(g,u,i.zIndexMode),userNode:g}},t.set(g.id,x)}(x.measured===void 0||x.measured.width===void 0||x.measured.height===void 0)&&!x.hidden&&(h=!1),g.parentId&&wg(x,t,n,r,o),d||(d=g.selected??!1)}return{nodesInitialized:h,hasSelectedNodes:d}}function J4(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 wg(e,t,n,r,i){const{elevateNodesOnSelect:o,nodeOrigin:c,nodeExtent:u,zIndexMode:h}=kg(bg,r),d=e.parentId,p=t.get(d);if(!p){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}J4(e,n),i&&!p.parentId&&p.internals.rootParentIndex===void 0&&h==="auto"&&(p.internals.rootParentIndex=++i.i,p.internals.z=p.internals.z+i.i*K4),i&&p.internals.rootParentIndex!==void 0&&(i.i=p.internals.rootParentIndex);const m=o&&!Ng(h)?rS:0,{x:g,y:x,z:y}=eF(e,p,c,u,m,h),{positionAbsolute:E}=e.internals,N=g!==E.x||x!==E.y;(N||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:N?{x:g,y:x}:E,z:y}})}function iS(e,t,n){const r=br(e.zIndex)?e.zIndex:0;return Ng(n)?r:r+(e.selected?t:0)}function eF(e,t,n,r,i,o){const{x:c,y:u}=t.internals.positionAbsolute,h=Ar(e),d=bc(e,n),p=Ra(e.extent)?Ma(d,e.extent,h):d;let m=Ma({x:c+p.x,y:u+p.y},r,h);e.extent==="parent"&&(m=Zj(m,h,t));const g=iS(e,i,o),x=t.internals.z??0;return{x:m.x,y:m.y,z:x>=g?x+1:g}}function jg(e,t,n,r=[0,0]){var c;const i=[],o=new Map;for(const u of e){const h=t.get(u.parentId);if(!h)continue;const d=((c=o.get(u.parentId))==null?void 0:c.expandedRect)??ic(h),p=Wj(d,u.rect);o.set(u.parentId,{expandedRect:p,parent:h})}return o.size>0&&o.forEach(({expandedRect:u,parent:h},d)=>{var k;const p=h.internals.positionAbsolute,m=Ar(h),g=h.origin??r,x=u.x<p.x?Math.round(Math.abs(p.x-u.x)):0,y=u.y<p.y?Math.round(Math.abs(p.y-u.y)):0,E=Math.max(m.width,Math.round(u.width)),N=Math.max(m.height,Math.round(u.height)),w=(E-m.width)*g[0],T=(N-m.height)*g[1];(x>0||y>0||w||T)&&(i.push({id:d,type:"position",position:{x:h.position.x-x+w,y:h.position.y-y+T}}),(k=n.get(d))==null||k.forEach(I=>{e.some(L=>L.id===I.id)||i.push({id:I.id,type:"position",position:{x:I.position.x+x,y:I.position.y+y}})})),(m.width<u.width||m.height<u.height||x||y)&&i.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:E+(x?g[0]*x-w:0),height:N+(y?g[1]*y-T:0)}})}),i}function tF(e,t,n,r,i,o,c){const u=r==null?void 0:r.querySelector(".xyflow__viewport");let h=!1;if(!u)return{changes:[],updatedInternals:h};const d=[],p=window.getComputedStyle(u),{m22:m}=new window.DOMMatrixReadOnly(p.transform),g=[];for(const x of e.values()){const y=t.get(x.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),h=!0;continue}const E=yg(x.nodeElement),N=y.measured.width!==E.width||y.measured.height!==E.height;if(!!(E.width&&E.height&&(N||!y.internals.handleBounds||x.force))){const T=x.nodeElement.getBoundingClientRect(),k=Ra(y.extent)?y.extent:o;let{positionAbsolute:I}=y.internals;if(y.parentId&&y.extent==="parent"){const z=t.get(y.parentId);z&&(I=Zj(I,E,z))}else k&&(I=Ma(I,k,E));const L={...y,measured:E,internals:{...y.internals,positionAbsolute:I,handleBounds:{source:ib("source",x.nodeElement,T,m,y.id),target:ib("target",x.nodeElement,T,m,y.id)}}};t.set(y.id,L),y.parentId&&wg(L,t,n,{nodeOrigin:i,zIndexMode:c}),h=!0,N&&(d.push({id:y.id,type:"dimensions",dimensions:E}),y.expandParent&&y.parentId&&g.push({id:y.id,parentId:y.parentId,rect:ic(L,i)}))}}if(g.length>0){const x=jg(g,t,n,i);d.push(...x)}return{changes:d,updatedInternals:h}}async function nF({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:o}){if(!t||!e.x&&!e.y)return!1;const c=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,o]],r);return!!c&&(c.x!==n[0]||c.y!==n[1]||c.k!==n[2])}function hb(e,t,n,r,i,o){let c=i;const u=r.get(c)||new Map;r.set(c,u.set(n,t)),c=`${i}-${e}`;const h=r.get(c)||new Map;if(r.set(c,h.set(n,t)),o){c=`${i}-${e}-${o}`;const d=r.get(c)||new Map;r.set(c,d.set(n,t))}}function aS(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:o,sourceHandle:c=null,targetHandle:u=null}=r,h={edgeId:r.id,source:i,target:o,sourceHandle:c,targetHandle:u},d=`${i}-${c}--${o}-${u}`,p=`${o}-${u}--${i}-${c}`;hb("source",h,p,e,i,c),hb("target",h,d,e,o,u),t.set(r.id,r)}}function oS(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:oS(n,t):!1}function fb(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function sF(e,t,n,r){const i=new Map;for(const[o,c]of e)if((c.selected||c.id===r)&&(!c.parentId||!oS(c,e))&&(c.draggable||t&&typeof c.draggable>"u")){const u=e.get(o);u&&i.set(o,{id:o,position:u.position||{x:0,y:0},distance:{x:n.x-u.internals.positionAbsolute.x,y:n.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return i}function ap({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var c,u,h;const i=[];for(const[d,p]of t){const m=(c=n.get(d))==null?void 0:c.internals.userNode;m&&i.push({...m,position:p.position,dragging:r})}if(!e)return[i[0],i];const o=(u=n.get(e))==null?void 0:u.internals.userNode;return[o?{...o,position:((h=t.get(e))==null?void 0:h.position)||o.position,dragging:r}:i[0],i]}function rF({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:n-i.distance.x,y:r-i.distance.y},c=Nc(o,t);return{x:c.x-o.x,y:c.y-o.y}}function iF({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let o={x:null,y:null},c=0,u=new Map,h=!1,d={x:0,y:0},p=null,m=!1,g=null,x=!1,y=!1,E=null;function N({noDragClassName:T,handleSelector:k,domNode:I,isSelectable:L,nodeId:z,nodeClickDistance:U=0}){g=Ms(I);function V({x:B,y:_}){const{nodeLookup:C,nodeExtent:R,snapGrid:M,snapToGrid:F,nodeOrigin:H,onNodeDrag:W,onSelectionDrag:K,onError:q,updateNodePositions:Y}=t();o={x:B,y:_};let fe=!1;const me=u.size>1,xe=me&&R?fm(kc(u)):null,oe=me&&F?rF({dragItems:u,snapGrid:M,x:B,y:_}):null;for(const[re,ie]of u){if(!C.has(re))continue;let ye={x:B-ie.distance.x,y:_-ie.distance.y};F&&(ye=oe?{x:Math.round(ye.x+oe.x),y:Math.round(ye.y+oe.y)}:Nc(ye,M));let De=null;if(me&&R&&!ie.extent&&xe){const{positionAbsolute:ae}=ie.internals,pe=ae.x-xe.x+R[0][0],Le=ae.x+ie.measured.width-xe.x2+R[1][0],Te=ae.y-xe.y+R[0][1],Ge=ae.y+ie.measured.height-xe.y2+R[1][1];De=[[pe,Te],[Le,Ge]]}const{position:de,positionAbsolute:Se}=Hj({nodeId:re,nextPosition:ye,nodeLookup:C,nodeExtent:De||R,nodeOrigin:H,onError:q});fe=fe||ie.position.x!==de.x||ie.position.y!==de.y,ie.position=de,ie.internals.positionAbsolute=Se}if(y=y||fe,!!fe&&(Y(u,!0),E&&(r||W||!z&&K))){const[re,ie]=ap({nodeId:z,dragItems:u,nodeLookup:C});r==null||r(E,u,re,ie),W==null||W(E,re,ie),z||K==null||K(E,ie)}}async function $(){if(!p)return;const{transform:B,panBy:_,autoPanSpeed:C,autoPanOnNodeDrag:R}=t();if(!R){h=!1,cancelAnimationFrame(c);return}const[M,F]=xg(d,p,C);(M!==0||F!==0)&&(o.x=(o.x??0)-M/B[2],o.y=(o.y??0)-F/B[2],await _({x:M,y:F})&&V(o)),c=requestAnimationFrame($)}function P(B){var me;const{nodeLookup:_,multiSelectionActive:C,nodesDraggable:R,transform:M,snapGrid:F,snapToGrid:H,selectNodesOnDrag:W,onNodeDragStart:K,onSelectionDragStart:q,unselectNodesAndEdges:Y}=t();m=!0,(!W||!L)&&!C&&z&&((me=_.get(z))!=null&&me.selected||Y()),L&&W&&z&&(e==null||e(z));const fe=Gl(B.sourceEvent,{transform:M,snapGrid:F,snapToGrid:H,containerBounds:p});if(o=fe,u=sF(_,R,fe,z),u.size>0&&(n||K||!z&&q)){const[xe,oe]=ap({nodeId:z,dragItems:u,nodeLookup:_});n==null||n(B.sourceEvent,u,xe,oe),K==null||K(B.sourceEvent,xe,oe),z||q==null||q(B.sourceEvent,oe)}}const D=wj().clickDistance(U).on("start",B=>{const{domNode:_,nodeDragThreshold:C,transform:R,snapGrid:M,snapToGrid:F}=t();p=(_==null?void 0:_.getBoundingClientRect())||null,x=!1,y=!1,E=B.sourceEvent,C===0&&P(B),o=Gl(B.sourceEvent,{transform:R,snapGrid:M,snapToGrid:F,containerBounds:p}),d=kr(B.sourceEvent,p)}).on("drag",B=>{const{autoPanOnNodeDrag:_,transform:C,snapGrid:R,snapToGrid:M,nodeDragThreshold:F,nodeLookup:H}=t(),W=Gl(B.sourceEvent,{transform:C,snapGrid:R,snapToGrid:M,containerBounds:p});if(E=B.sourceEvent,(B.sourceEvent.type==="touchmove"&&B.sourceEvent.touches.length>1||z&&!H.has(z))&&(x=!0),!x){if(!h&&_&&m&&(h=!0,$()),!m){const K=kr(B.sourceEvent,p),q=K.x-d.x,Y=K.y-d.y;Math.sqrt(q*q+Y*Y)>F&&P(B)}(o.x!==W.xSnapped||o.y!==W.ySnapped)&&u&&m&&(d=kr(B.sourceEvent,p),V(W))}}).on("end",B=>{if(!m||x){x&&u.size>0&&t().updateNodePositions(u,!1);return}if(h=!1,m=!1,cancelAnimationFrame(c),u.size>0){const{nodeLookup:_,updateNodePositions:C,onNodeDragStop:R,onSelectionDragStop:M}=t();if(y&&(C(u,!1),y=!1),i||R||!z&&M){const[F,H]=ap({nodeId:z,dragItems:u,nodeLookup:_,dragging:!1});i==null||i(B.sourceEvent,u,F,H),R==null||R(B.sourceEvent,F,H),z||M==null||M(B.sourceEvent,H)}}}).filter(B=>{const _=B.target;return!B.button&&(!T||!fb(_,`.${T}`,I))&&(!k||fb(_,k,I))});g.call(D)}function w(){g==null||g.on(".drag",null)}return{update:N,destroy:w}}function aF(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())yd(i,ic(o))>0&&r.push(o);return r}const oF=250;function lF(e,t,n,r){var u,h;let i=[],o=1/0;const c=aF(e,n,t+oF);for(const d of c){const p=[...((u=d.internals.handleBounds)==null?void 0:u.source)??[],...((h=d.internals.handleBounds)==null?void 0:h.target)??[]];for(const m of p){if(r.nodeId===m.nodeId&&r.type===m.type&&r.id===m.id)continue;const{x:g,y:x}=Oa(d,m,m.position,!0),y=Math.sqrt(Math.pow(g-e.x,2)+Math.pow(x-e.y,2));y>t||(y<o?(i=[{...m,x:g,y:x}],o=y):y===o&&i.push({...m,x:g,y:x}))}}if(!i.length)return null;if(i.length>1){const d=r.type==="source"?"target":"source";return i.find(p=>p.type===d)??i[0]}return i[0]}function lS(e,t,n,r,i,o=!1){var d,p,m;const c=r.get(e);if(!c)return null;const u=i==="strict"?(d=c.internals.handleBounds)==null?void 0:d[t]:[...((p=c.internals.handleBounds)==null?void 0:p.source)??[],...((m=c.internals.handleBounds)==null?void 0:m.target)??[]],h=(n?u==null?void 0:u.find(g=>g.id===n):u==null?void 0:u[0])??null;return h&&o?{...h,...Oa(c,h,h.position,!0)}:h}function cS(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function cF(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const uS=()=>!0;function uF(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:c,domNode:u,nodeLookup:h,lib:d,autoPanOnConnect:p,flowId:m,panBy:g,cancelConnection:x,onConnectStart:y,onConnect:E,onConnectEnd:N,isValidConnection:w=uS,onReconnectEnd:T,updateConnection:k,getTransform:I,getFromHandle:L,autoPanSpeed:z,dragThreshold:U=1,handleDomNode:V}){const $=Xj(e.target);let P=0,D;const{x:B,y:_}=kr(e),C=cS(o,V),R=u==null?void 0:u.getBoundingClientRect();let M=!1;if(!R||!C)return;const F=lS(i,C,r,h,t);if(!F)return;let H=kr(e,R),W=!1,K=null,q=!1,Y=null;function fe(){if(!p||!R)return;const[de,Se]=xg(H,R,z);g({x:de,y:Se}),P=requestAnimationFrame(fe)}const me={...F,nodeId:i,type:C,position:F.position},xe=h.get(i);let re={inProgress:!0,isValid:null,from:Oa(xe,me,Je.Left,!0),fromHandle:me,fromPosition:me.position,fromNode:xe,to:H,toHandle:null,toPosition:tb[me.position],toNode:null,pointer:H};function ie(){M=!0,k(re),y==null||y(e,{nodeId:i,handleId:r,handleType:C})}U===0&&ie();function ye(de){if(!M){const{x:Ge,y:Ae}=kr(de),tt=Ge-B,et=Ae-_;if(!(tt*tt+et*et>U*U))return;ie()}if(!L()||!me){De(de);return}const Se=I();H=kr(de,R),D=lF(wc(H,Se,!1,[1,1]),n,h,me),W||(fe(),W=!0);const ae=dS(de,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:c?"target":"source",isValidConnection:w,doc:$,lib:d,flowId:m,nodeLookup:h});Y=ae.handleDomNode,K=ae.connection,q=cF(!!D,ae.isValid);const pe=h.get(i),Le=pe?Oa(pe,me,Je.Left,!0):re.from,Te={...re,from:Le,isValid:q,to:ae.toHandle&&q?Fo({x:ae.toHandle.x,y:ae.toHandle.y},Se):H,toHandle:ae.toHandle,toPosition:q&&ae.toHandle?ae.toHandle.position:tb[me.position],toNode:ae.toHandle?h.get(ae.toHandle.nodeId):null,pointer:H};k(Te),re=Te}function De(de){if(!("touches"in de&&de.touches.length>0)){if(M){(D||Y)&&K&&q&&(E==null||E(K));const{inProgress:Se,...ae}=re,pe={...ae,toPosition:re.toHandle?re.toPosition:null};N==null||N(de,pe),o&&(T==null||T(de,pe))}x(),cancelAnimationFrame(P),W=!1,q=!1,K=null,Y=null,$.removeEventListener("mousemove",ye),$.removeEventListener("mouseup",De),$.removeEventListener("touchmove",ye),$.removeEventListener("touchend",De)}}$.addEventListener("mousemove",ye),$.addEventListener("mouseup",De),$.addEventListener("touchmove",ye),$.addEventListener("touchend",De)}function dS(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:o,doc:c,lib:u,flowId:h,isValidConnection:d=uS,nodeLookup:p}){const m=o==="target",g=t?c.querySelector(`.${u}-flow__handle[data-id="${h}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x,y}=kr(e),E=c.elementFromPoint(x,y),N=E!=null&&E.classList.contains(`${u}-flow__handle`)?E:g,w={handleDomNode:N,isValid:!1,connection:null,toHandle:null};if(N){const T=cS(void 0,N),k=N.getAttribute("data-nodeid"),I=N.getAttribute("data-handleid"),L=N.classList.contains("connectable"),z=N.classList.contains("connectableend");if(!k||!T)return w;const U={source:m?k:r,sourceHandle:m?I:i,target:m?r:k,targetHandle:m?i:I};w.connection=U;const $=L&&z&&(n===Lo.Strict?m&&T==="source"||!m&&T==="target":k!==r||I!==i);w.isValid=$&&d(U),w.toHandle=lS(k,T,I,p,n,!0)}return w}const xm={onPointerDown:uF,isValid:dS};function dF({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=Ms(e);function o({translateExtent:u,width:h,height:d,zoomStep:p=1,pannable:m=!0,zoomable:g=!0,inversePan:x=!1}){const y=k=>{if(k.sourceEvent.type!=="wheel"||!t)return;const I=n(),L=k.sourceEvent.ctrlKey&&ac()?10:1,z=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*p,U=I[2]*Math.pow(2,z*L);t.scaleTo(U)};let E=[0,0];const N=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(E=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},w=k=>{const I=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const L=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],z=[L[0]-E[0],L[1]-E[1]];E=L;const U=r()*Math.max(I[2],Math.log(I[2]))*(x?-1:1),V={x:I[0]-z[0]*U,y:I[1]-z[1]*U},$=[[0,0],[h,d]];t.setViewportConstrained({x:V.x,y:V.y,zoom:I[2]},$,u)},T=Lj().on("start",N).on("zoom",m?w:null).on("zoom.wheel",g?y:null);i.call(T,{})}function c(){i.on("zoom",null)}return{update:o,destroy:c,pointer:gr}}const Fd=e=>({x:e.x,y:e.y,zoom:e.k}),op=({x:e,y:t,zoom:n})=>Pd.translate(e,t).scale(n),Li=(e,t)=>e.target.closest(`.${t}`),hS=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),hF=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,lp=(e,t=0,n=hF,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},fS=e=>{const t=e.ctrlKey&&ac()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function fF({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:c,onPanZoomStart:u,onPanZoom:h,onPanZoomEnd:d}){return p=>{if(Li(p,t))return p.ctrlKey&&p.preventDefault(),!1;p.preventDefault(),p.stopImmediatePropagation();const m=n.property("__zoom").k||1;if(p.ctrlKey&&c){const N=gr(p),w=fS(p),T=m*Math.pow(2,w);r.scaleTo(n,T,N,p);return}const g=p.deltaMode===1?20:1;let x=i===Ca.Vertical?0:p.deltaX*g,y=i===Ca.Horizontal?0:p.deltaY*g;!ac()&&p.shiftKey&&i!==Ca.Vertical&&(x=p.deltaY*g,y=0),r.translateBy(n,-(x/m)*o,-(y/m)*o,{internal:!0});const E=Fd(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?h==null||h(p,E):(e.isPanScrolling=!0,u==null||u(p,E)),e.panScrollTimeout=setTimeout(()=>{d==null||d(p,E),e.isPanScrolling=!1},150)}}function pF({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const o=r.type==="wheel",c=!t&&o&&!r.ctrlKey,u=Li(r,e);if(r.ctrlKey&&o&&u&&r.preventDefault(),c||u)return null;r.preventDefault(),n.call(this,r,i)}}function mF({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,c,u;if((o=r.sourceEvent)!=null&&o.internal)return;const i=Fd(r.transform);e.mouseButton=((c=r.sourceEvent)==null?void 0:c.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((u=r.sourceEvent)==null?void 0:u.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function gF({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return o=>{var c,u;e.usedRightMouseButton=!!(n&&hS(t,e.mouseButton??0)),(c=o.sourceEvent)!=null&&c.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!((u=o.sourceEvent)!=null&&u.internal)&&(i==null||i(o.sourceEvent,Fd(o.transform)))}}function xF({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return c=>{var u;if(!((u=c.sourceEvent)!=null&&u.internal)&&(e.isZoomingOrPanning=!1,o&&hS(t,e.mouseButton??0)&&!e.usedRightMouseButton&&c.sourceEvent&&o(c.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const h=Fd(c.transform);e.prevViewport=h,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(c.sourceEvent,h)},n?150:0)}}}function vF({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:o,zoomOnDoubleClick:c,userSelectionActive:u,noWheelClassName:h,noPanClassName:d,lib:p,connectionInProgress:m}){return g=>{var w;const x=t||n,y=r&&g.ctrlKey,E=g.type==="wheel";if(g.button===1&&g.type==="mousedown"&&(Li(g,`${p}-flow__node`)||Li(g,`${p}-flow__edge`)||Li(g,`${p}-flow__selection`)||Li(g,`${p}-flow__nodesselection`)))return!0;if(!i&&!x&&!o&&!c&&!r||u||m&&!E||Li(g,h)&&E||Li(g,d)&&(!E||o&&E&&!t)||!r&&g.ctrlKey&&E)return!1;if(!r&&g.type==="touchstart"&&((w=g.touches)==null?void 0:w.length)>1)return g.preventDefault(),!1;if(!x&&!o&&!y&&E||!i&&(g.type==="mousedown"||g.type==="touchstart")||Array.isArray(i)&&!i.includes(g.button)&&g.type==="mousedown")return!1;const N=Array.isArray(i)&&i.includes(g.button)||!g.button||g.button<=1;return(!g.ctrlKey||E||e)&&N}}function yF({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:c,onPanZoomEnd:u,onDraggingChange:h}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect();let m=[[0,0],[p.width,p.height]];const g=typeof ResizeObserver<"u"?new ResizeObserver(_=>{const C=_[0];C&&(m=[[0,0],[C.contentRect.width,C.contentRect.height]])}):null;g==null||g.observe(e);const x=Lj().extent(()=>m).scaleExtent([t,n]).translateExtent(r),y=Ms(e).call(x);I({x:i.x,y:i.y,zoom:Do(i.zoom,t,n)},[[0,0],[p.width,p.height]],r);const E=y.on("wheel.zoom"),N=y.on("dblclick.zoom");x.wheelDelta(fS);async function w(_,C){return y?new Promise(R=>{x==null||x.interpolate((C==null?void 0:C.interpolate)==="linear"?ql:Vu).transform(lp(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>R(!0)),_)}):!1}function T({noWheelClassName:_,noPanClassName:C,onPaneContextMenu:R,userSelectionActive:M,panOnScroll:F,panOnDrag:H,panOnScrollMode:W,panOnScrollSpeed:K,preventScrolling:q,zoomOnPinch:Y,zoomOnScroll:fe,zoomOnDoubleClick:me,panActivationKeyPressed:xe=!1,zoomActivationKeyPressed:oe,lib:re,onTransformChange:ie,connectionInProgress:ye,paneClickDistance:De,selectionOnDrag:de}){M&&!d.isZoomingOrPanning&&k();const Se=F&&!oe&&!M;x.clickDistance(de?1/0:!br(De)||De<0?0:De);const ae=Se?fF({zoomPanValues:d,noWheelClassName:_,d3Selection:y,d3Zoom:x,panOnScrollMode:W,panOnScrollSpeed:K,zoomOnPinch:Y,onPanZoomStart:c,onPanZoom:o,onPanZoomEnd:u}):pF({noWheelClassName:_,preventScrolling:q,d3ZoomHandler:E});y.on("wheel.zoom",ae,{passive:!1});const pe=mF({zoomPanValues:d,onDraggingChange:h,onPanZoomStart:c});x.on("start",pe);const Le=gF({zoomPanValues:d,panOnDrag:H,onPaneContextMenu:!!R,onPanZoom:o,onTransformChange:ie});x.on("zoom",Le);const Te=xF({zoomPanValues:d,panOnDrag:H,panOnScroll:F,onPaneContextMenu:R,onPanZoomEnd:u,onDraggingChange:h});x.on("end",Te);const Ge=vF({panActivationKeyPressed:xe,zoomActivationKeyPressed:oe,panOnDrag:H,zoomOnScroll:fe,panOnScroll:F,zoomOnDoubleClick:me,zoomOnPinch:Y,userSelectionActive:M,noPanClassName:C,noWheelClassName:_,lib:re,connectionInProgress:ye});x.filter(Ge),me?y.on("dblclick.zoom",N):y.on("dblclick.zoom",null)}function k(){x.on("zoom",null)}async function I(_,C,R){const M=op(_),F=x==null?void 0:x.constrain()(M,C,R);return F&&await w(F),F}async function L(_,C){const R=op(_);return await w(R,C),R}function z(_){if(y){const C=op(_),R=y.property("__zoom");(R.k!==_.zoom||R.x!==_.x||R.y!==_.y)&&(x==null||x.transform(y,C,null,{sync:!0}))}}function U(){const _=y?Pj(y.node()):{x:0,y:0,k:1};return{x:_.x,y:_.y,zoom:_.k}}async function V(_,C){return y?new Promise(R=>{x==null||x.interpolate((C==null?void 0:C.interpolate)==="linear"?ql:Vu).scaleTo(lp(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>R(!0)),_)}):!1}async function $(_,C){return y?new Promise(R=>{x==null||x.interpolate((C==null?void 0:C.interpolate)==="linear"?ql:Vu).scaleBy(lp(y,C==null?void 0:C.duration,C==null?void 0:C.ease,()=>R(!0)),_)}):!1}function P(_){x==null||x.scaleExtent(_)}function D(_){x==null||x.translateExtent(_)}function B(_){const C=!br(_)||_<0?0:_;x==null||x.clickDistance(C)}return{update:T,destroy:k,setViewport:L,setViewportConstrained:I,getViewport:U,scaleTo:V,scaleBy:$,setScaleExtent:P,setTranslateExtent:D,syncViewport:z,setClickDistance:B}}var Bo;(function(e){e.Line="line",e.Handle="handle"})(Bo||(Bo={}));function bF({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:o}){const c=e-t,u=n-r,h=[c>0?1:c<0?-1:0,u>0?1:u<0?-1:0];return c&&i&&(h[0]=h[0]*-1),u&&o&&(h[1]=h[1]*-1),h}function pb(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function zi(e,t){return Math.max(0,t-e)}function Pi(e,t){return Math.max(0,e-t)}function zu(e,t,n){return Math.max(0,t-e,e-n)}function mb(e,t){return e?!t:t}function kF(e,t,n,r,i,o,c,u){let{affectsX:h,affectsY:d}=t;const{isHorizontal:p,isVertical:m}=t,g=p&&m,{xSnapped:x,ySnapped:y}=n,{minWidth:E,maxWidth:N,minHeight:w,maxHeight:T}=r,{x:k,y:I,width:L,height:z,aspectRatio:U}=e;let V=Math.floor(p?x-e.pointerX:0),$=Math.floor(m?y-e.pointerY:0);const P=L+(h?-V:V),D=z+(d?-$:$),B=-o[0]*L,_=-o[1]*z;let C=zu(P,E,N),R=zu(D,w,T);if(c){let H=0,W=0;h&&V<0?H=zi(k+V+B,c[0][0]):!h&&V>0&&(H=Pi(k+P+B,c[1][0])),d&&$<0?W=zi(I+$+_,c[0][1]):!d&&$>0&&(W=Pi(I+D+_,c[1][1])),C=Math.max(C,H),R=Math.max(R,W)}if(u){let H=0,W=0;h&&V>0?H=Pi(k+V,u[0][0]):!h&&V<0&&(H=zi(k+P,u[1][0])),d&&$>0?W=Pi(I+$,u[0][1]):!d&&$<0&&(W=zi(I+D,u[1][1])),C=Math.max(C,H),R=Math.max(R,W)}if(i){if(p){const H=zu(P/U,w,T)*U;if(C=Math.max(C,H),c){let W=0;!h&&!d||h&&!d&&g?W=Pi(I+_+P/U,c[1][1])*U:W=zi(I+_+(h?V:-V)/U,c[0][1])*U,C=Math.max(C,W)}if(u){let W=0;!h&&!d||h&&!d&&g?W=zi(I+P/U,u[1][1])*U:W=Pi(I+(h?V:-V)/U,u[0][1])*U,C=Math.max(C,W)}}if(m){const H=zu(D*U,E,N)/U;if(R=Math.max(R,H),c){let W=0;!h&&!d||d&&!h&&g?W=Pi(k+D*U+B,c[1][0])/U:W=zi(k+(d?$:-$)*U+B,c[0][0])/U,R=Math.max(R,W)}if(u){let W=0;!h&&!d||d&&!h&&g?W=zi(k+D*U,u[1][0])/U:W=Pi(k+(d?$:-$)*U,u[0][0])/U,R=Math.max(R,W)}}}$=$+($<0?R:-R),V=V+(V<0?C:-C),i&&(g?P>D*U?$=(mb(h,d)?-V:V)/U:V=(mb(h,d)?-$:$)*U:p?($=V/U,d=h):(V=$*U,h=d));const M=h?k+V:k,F=d?I+$:I;return{width:L+(h?-V:V),height:z+(d?-$:$),x:o[0]*V*(h?-1:1)+M,y:o[1]*$*(d?-1:1)+F}}const pS={width:0,height:0,x:0,y:0},NF={...pS,pointerX:0,pointerY:0,aspectRatio:1};function wF(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,o=e.measured.width??0,c=e.measured.height??0,u=n[0]*o,h=n[1]*c;return[[r-u,i-h],[r+o-u,i+c-h]]}function jF({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const o=Ms(e);let c={controlDirection:pb("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function u({controlPosition:d,boundaries:p,keepAspectRatio:m,resizeDirection:g,onResizeStart:x,onResize:y,onResizeEnd:E,shouldResize:N}){let w={...pS},T={...NF};c={boundaries:p,resizeDirection:g,keepAspectRatio:m,controlDirection:pb(d)};let k,I=null,L=[],z,U,V,$=!1;const P=wj().on("start",D=>{const{nodeLookup:B,transform:_,snapGrid:C,snapToGrid:R,nodeOrigin:M,paneDomNode:F}=n();if(k=B.get(t),!k)return;I=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:H,ySnapped:W}=Gl(D.sourceEvent,{transform:_,snapGrid:C,snapToGrid:R,containerBounds:I});w={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},T={...w,pointerX:H,pointerY:W,aspectRatio:w.width/w.height},z=void 0,U=Ra(k.extent)?k.extent:void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(z=B.get(k.parentId)),z&&k.extent==="parent"&&(U=[[0,0],[z.measured.width,z.measured.height]]),L=[],V=void 0;for(const[K,q]of B)if(q.parentId===t&&(L.push({id:K,position:{...q.position},extent:q.extent}),q.extent==="parent"||q.expandParent)){const Y=wF(q,k,q.origin??M);V?V=[[Math.min(Y[0][0],V[0][0]),Math.min(Y[0][1],V[0][1])],[Math.max(Y[1][0],V[1][0]),Math.max(Y[1][1],V[1][1])]]:V=Y}x==null||x(D,{...w})}).on("drag",D=>{const{transform:B,snapGrid:_,snapToGrid:C,nodeOrigin:R}=n(),M=Gl(D.sourceEvent,{transform:B,snapGrid:_,snapToGrid:C,containerBounds:I}),F=[];if(!k)return;const{x:H,y:W,width:K,height:q}=w,Y={},fe=k.origin??R,{width:me,height:xe,x:oe,y:re}=kF(T,c.controlDirection,M,c.boundaries,c.keepAspectRatio,fe,U,V),ie=me!==K,ye=xe!==q,De=oe!==H&&ie,de=re!==W&&ye;if(!De&&!de&&!ie&&!ye)return;if((De||de||fe[0]===1||fe[1]===1)&&(Y.x=De?oe:w.x,Y.y=de?re:w.y,w.x=Y.x,w.y=Y.y,L.length>0)){const Le=oe-H,Te=re-W;for(const Ge of L)Ge.position={x:Ge.position.x-Le+fe[0]*(me-K),y:Ge.position.y-Te+fe[1]*(xe-q)},F.push(Ge)}if((ie||ye)&&(Y.width=ie&&(!c.resizeDirection||c.resizeDirection==="horizontal")?me:w.width,Y.height=ye&&(!c.resizeDirection||c.resizeDirection==="vertical")?xe:w.height,w.width=Y.width,w.height=Y.height),z&&k.expandParent){const Le=fe[0]*(Y.width??0);Y.x&&Y.x<Le&&(w.x=Le,T.x=T.x-(Y.x-Le));const Te=fe[1]*(Y.height??0);Y.y&&Y.y<Te&&(w.y=Te,T.y=T.y-(Y.y-Te))}const Se=bF({width:w.width,prevWidth:K,height:w.height,prevHeight:q,affectsX:c.controlDirection.affectsX,affectsY:c.controlDirection.affectsY}),ae={...w,direction:Se};(N==null?void 0:N(D,ae))!==!1&&($=!0,y==null||y(D,ae),r(Y,F))}).on("end",D=>{$&&(E==null||E(D,{...w}),i==null||i({...w}),$=!1)});o.call(P)}function h(){o.on(".drag",null)}return{update:u,destroy:h}}var cp={exports:{}},up={},dp={exports:{}},hp={};/**
205
+ * @license React
206
+ * use-sync-external-store-shim.production.js
207
+ *
208
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
209
+ *
210
+ * This source code is licensed under the MIT license found in the
211
+ * LICENSE file in the root directory of this source tree.
212
+ */var gb;function SF(){if(gb)return hp;gb=1;var e=hc();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,i=e.useEffect,o=e.useLayoutEffect,c=e.useDebugValue;function u(m,g){var x=g(),y=r({inst:{value:x,getSnapshot:g}}),E=y[0].inst,N=y[1];return o(function(){E.value=x,E.getSnapshot=g,h(E)&&N({inst:E})},[m,x,g]),i(function(){return h(E)&&N({inst:E}),m(function(){h(E)&&N({inst:E})})},[m]),c(x),x}function h(m){var g=m.getSnapshot;m=m.value;try{var x=g();return!n(m,x)}catch{return!0}}function d(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:u;return hp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,hp}var xb;function _F(){return xb||(xb=1,dp.exports=SF()),dp.exports}/**
213
+ * @license React
214
+ * use-sync-external-store-shim/with-selector.production.js
215
+ *
216
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
217
+ *
218
+ * This source code is licensed under the MIT license found in the
219
+ * LICENSE file in the root directory of this source tree.
220
+ */var vb;function EF(){if(vb)return up;vb=1;var e=hc(),t=_F();function n(d,p){return d===p&&(d!==0||1/d===1/p)||d!==d&&p!==p}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,c=e.useEffect,u=e.useMemo,h=e.useDebugValue;return up.useSyncExternalStoreWithSelector=function(d,p,m,g,x){var y=o(null);if(y.current===null){var E={hasValue:!1,value:null};y.current=E}else E=y.current;y=u(function(){function w(z){if(!T){if(T=!0,k=z,z=g(z),x!==void 0&&E.hasValue){var U=E.value;if(x(U,z))return I=U}return I=z}if(U=I,r(k,z))return U;var V=g(z);return x!==void 0&&x(U,V)?(k=z,U):(k=z,I=V)}var T=!1,k,I,L=m===void 0?null:m;return[function(){return w(p())},L===null?void 0:function(){return w(L())}]},[p,m,g,x]);var N=i(d,y[0],y[1]);return c(function(){E.hasValue=!0,E.value=N},[N]),h(N),N},up}var yb;function CF(){return yb||(yb=1,cp.exports=EF()),cp.exports}var AF=CF();const IF=Sm(AF),TF={},bb=e=>{let t;const n=new Set,r=(p,m)=>{const g=typeof p=="function"?p(t):p;if(!Object.is(g,t)){const x=t;t=m??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(y=>y(t,x))}},i=()=>t,h={setState:r,getState:i,getInitialState:()=>d,subscribe:p=>(n.add(p),()=>n.delete(p)),destroy:()=>{(TF?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,i,h);return h},$F=e=>e?bb(e):bb,{useDebugValue:MF}=DM,{useSyncExternalStoreWithSelector:RF}=IF,OF=e=>e;function mS(e,t=OF,n){const r=RF(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return MF(r),r}const kb=(e,t)=>{const n=$F(e),r=(i,o=t)=>mS(n,i,o);return Object.assign(r,n),r},zF=(e,t)=>e?kb(e,t):kb;function tn(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Bd=b.createContext(null),PF=Bd.Provider,gS=Sr.error001("react");function wt(e,t){const n=b.useContext(Bd);if(n===null)throw new Error(gS);return mS(n,e,t)}function Vt(){const e=b.useContext(Bd);if(e===null)throw new Error(gS);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Nb={display:"none"},LF={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},xS="react-flow__node-desc",vS="react-flow__edge-desc",DF="react-flow__aria-live",FF=e=>e.ariaLiveMessage,BF=e=>e.ariaLabelConfig;function UF({rfId:e}){const t=wt(FF);return s.jsx("div",{id:`${DF}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:LF,children:t})}function HF({rfId:e,disableKeyboardA11y:t}){const n=wt(BF);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${xS}-${e}`,style:Nb,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${vS}-${e}`,style:Nb,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(UF,{rfId:e})]})}const Ud=b.forwardRef(({position:e="top-left",children:t,className:n,style:r,...i},o)=>{const c=`${e}`.split("-");return s.jsx("div",{className:kn(["react-flow__panel",n,...c]),style:r,ref:o,...i,children:t})});Ud.displayName="Panel";const wb="https://reactflow.dev?utm_source=attribution";function ZF({proOptions:e,position:t="bottom-right"}){return b.useEffect(()=>{},[]),e!=null&&e.hideAttribution?null:s.jsx(Ud,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${wb}`,children:s.jsx("a",{href:wb,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const WF=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Pu=e=>e.id;function VF(e,t){return tn(e.selectedNodes.map(Pu),t.selectedNodes.map(Pu))&&tn(e.selectedEdges.map(Pu),t.selectedEdges.map(Pu))}function qF({onSelectionChange:e}){const t=Vt(),{selectedNodes:n,selectedEdges:r}=wt(WF,VF);return b.useEffect(()=>{const i={nodes:n,edges:r};e==null||e(i),t.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[n,r,e]),null}const GF=e=>!!e.onSelectionChangeHandlers;function KF({onSelectionChange:e}){const t=wt(GF);return e||t?s.jsx(qF,{onSelectionChange:e}):null}const yS=[0,0],YF={x:0,y:0,zoom:1},XF=["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"],jb=[...XF,"rfId"],QF=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}),Sb={translateExtent:sc,nodeOrigin:yS,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function JF(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:c,reset:u,setDefaultNodesAndEdges:h}=wt(QF,tn),d=Vt();b.useEffect(()=>(h(e.defaultNodes,e.defaultEdges),()=>{p.current=Sb,u()}),[]);const p=b.useRef(Sb);return b.useEffect(()=>{for(const m of jb){const g=e[m],x=p.current[m];g!==x&&(typeof e[m]>"u"||(m==="nodes"?t(g):m==="edges"?n(g):m==="minZoom"?r(g):m==="maxZoom"?i(g):m==="translateExtent"?o(g):m==="nodeExtent"?c(g):m==="ariaLabelConfig"?d.setState({ariaLabelConfig:P4(g)}):m==="fitView"?d.setState({fitViewQueued:g}):m==="fitViewOptions"?d.setState({fitViewOptions:g}):d.setState({[m]:g})))}p.current=e},jb.map(m=>e[m])),null}function _b(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function e6(e){var r;const[t,n]=b.useState(e==="system"?null:e);return b.useEffect(()=>{if(e!=="system"){n(e);return}const i=_b(),o=()=>n(i!=null&&i.matches?"dark":"light");return o(),i==null||i.addEventListener("change",o),()=>{i==null||i.removeEventListener("change",o)}},[e]),t!==null?t:(r=_b())!=null&&r.matches?"dark":"light"}const Eb=typeof document<"u"?document:null;function oc(e=null,t={target:Eb,actInsideInputWithModifier:!0}){const[n,r]=b.useState(!1),i=b.useRef(!1),o=b.useRef(new Set([])),[c,u]=b.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.replace(/\+/g,`
221
+ `).replace(`
222
+
223
+ `,`
224
+ +`).split(`
225
+ `)),p=d.reduce((m,g)=>m.concat(...g),[]);return[d,p]}return[[],[]]},[e]);return b.useEffect(()=>{const h=(t==null?void 0:t.target)??Eb,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=x=>{var N,w;if(i.current=x.ctrlKey||x.metaKey||x.shiftKey||x.altKey,(!i.current||i.current&&!d)&&Qj(x))return!1;const E=Ab(x.code,u);if(o.current.add(x[E]),Cb(c,o.current,!1)){const T=((w=(N=x.composedPath)==null?void 0:N.call(x))==null?void 0:w[0])||x.target,k=(T==null?void 0:T.nodeName)==="BUTTON"||(T==null?void 0:T.nodeName)==="A";t.preventDefault!==!1&&(i.current||!k)&&x.preventDefault(),r(!0)}},m=x=>{const y=Ab(x.code,u);Cb(c,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(x[y]),x.key==="Meta"&&o.current.clear(),i.current=!1},g=()=>{o.current.clear(),r(!1)};return h==null||h.addEventListener("keydown",p),h==null||h.addEventListener("keyup",m),window.addEventListener("blur",g),window.addEventListener("contextmenu",g),()=>{h==null||h.removeEventListener("keydown",p),h==null||h.removeEventListener("keyup",m),window.removeEventListener("blur",g),window.removeEventListener("contextmenu",g)}}},[e,r]),n}function Cb(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function Ab(e,t){return t.includes(e)?"code":"key"}const t6=()=>{const e=Vt();return b.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,i,o],panZoom:c}=e.getState();return c?(await c.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:c,panZoom:u}=e.getState(),h=vg(t,r,i,o,c,(n==null?void 0:n.padding)??.1);return u?(await u.setViewport(h,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:c}=e.getState();if(!c)return t;const{x:u,y:h}=c.getBoundingClientRect(),d={x:t.x-u,y:t.y-h},p=n.snapGrid??i,m=n.snapToGrid??o;return wc(d,r,m,p)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),c=Fo(t,n);return{x:c.x+i,y:c.y+o}}}),[])};function bS(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const c=r.get(o.id);c?c.push(o):r.set(o.id,[o])}for(const o of t){const c=r.get(o.id);if(!c){n.push(o);continue}if(c[0].type==="remove")continue;if(c[0].type==="replace"){n.push({...c[0].item});continue}const u={...o};for(const h of c)n6(h,u);n.push(u)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function n6(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 s6(e,t){return bS(e,t)}function r6(e,t){return bS(e,t)}function va(e,t){return{id:e,type:"select",selected:t}}function xo(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const c=t.has(i);!(o.selected===void 0&&!c)&&o.selected!==c&&(n&&(o.selected=c),r.push(va(o.id,c)))}return r}function Ib({items:e=[],lookup:t}){var i;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,c]of e.entries()){const u=t.get(c.id),h=((i=u==null?void 0:u.internals)==null?void 0:i.userNode)??u;h!==void 0&&h!==c&&n.push({id:c.id,item:c,type:"replace"}),h===void 0&&n.push({item:c,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function Tb(e){return{id:e.id,type:"remove"}}const i6=qj();function a6(e,t,n={}){return H4(e,t,{...n,onError:n.onError??i6})}const $b=e=>C4(e),o6=e=>Uj(e);function kS(e){return b.forwardRef(e)}const NS=typeof window<"u"?b.useLayoutEffect:b.useEffect;function Mb(e){const[t,n]=b.useState(BigInt(0)),[r]=b.useState(()=>l6(()=>n(i=>i+BigInt(1))));return NS(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function l6(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const wS=b.createContext(null);function c6({children:e}){const t=Vt(),n=b.useCallback(u=>{const{nodes:h=[],setNodes:d,hasDefaultNodes:p,onNodesChange:m,nodeLookup:g,fitViewQueued:x,onNodesChangeMiddlewareMap:y}=t.getState();let E=h;for(const w of u)E=typeof w=="function"?w(E):w;let N=Ib({items:E,lookup:g});for(const w of y.values())N=w(N);p&&d(E),N.length>0?m==null||m(N):x&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:T,setNodes:k}=t.getState();w&&k(T)})},[]),r=Mb(n),i=b.useCallback(u=>{const{edges:h=[],setEdges:d,hasDefaultEdges:p,onEdgesChange:m,edgeLookup:g}=t.getState();let x=h;for(const y of u)x=typeof y=="function"?y(x):y;p?d(x):m&&m(Ib({items:x,lookup:g}))},[]),o=Mb(i),c=b.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return s.jsx(wS.Provider,{value:c,children:e})}function u6(){const e=b.useContext(wS);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const d6=e=>!!e.panZoom;function Sg(){const e=t6(),t=Vt(),n=u6(),r=wt(d6),i=b.useMemo(()=>{const o=m=>t.getState().nodeLookup.get(m),c=m=>{n.nodeQueue.push(m)},u=m=>{n.edgeQueue.push(m)},h=m=>{var w,T;const{nodeLookup:g,nodeOrigin:x}=t.getState(),y=$b(m)?m:g.get(m.id),E=y.parentId?Kj(y.position,y.measured,y.parentId,g,x):y.position,N={...y,position:E,width:((w=y.measured)==null?void 0:w.width)??y.width,height:((T=y.measured)==null?void 0:T.height)??y.height};return ic(N)},d=(m,g,x={replace:!1})=>{c(y=>y.map(E=>{if(E.id===m){const N=typeof g=="function"?g(E):g;return x.replace&&$b(N)?N:{...E,...N}}return E}))},p=(m,g,x={replace:!1})=>{u(y=>y.map(E=>{if(E.id===m){const N=typeof g=="function"?g(E):g;return x.replace&&o6(N)?N:{...E,...N}}return E}))};return{getNodes:()=>t.getState().nodes.map(m=>({...m})),getNode:m=>{var g;return(g=o(m))==null?void 0:g.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:m=[]}=t.getState();return m.map(g=>({...g}))},getEdge:m=>t.getState().edgeLookup.get(m),setNodes:c,setEdges:u,addNodes:m=>{const g=Array.isArray(m)?m:[m];n.nodeQueue.push(x=>[...x,...g])},addEdges:m=>{const g=Array.isArray(m)?m:[m];n.edgeQueue.push(x=>[...x,...g])},toObject:()=>{const{nodes:m=[],edges:g=[],transform:x}=t.getState(),[y,E,N]=x;return{nodes:m.map(w=>({...w})),edges:g.map(w=>({...w})),viewport:{x:y,y:E,zoom:N}}},deleteElements:async({nodes:m=[],edges:g=[]})=>{const{nodes:x,edges:y,onNodesDelete:E,onEdgesDelete:N,triggerNodeChanges:w,triggerEdgeChanges:T,onDelete:k,onBeforeDelete:I}=t.getState(),{nodes:L,edges:z}=await M4({nodesToRemove:m,edgesToRemove:g,nodes:x,edges:y,onBeforeDelete:I}),U=z.length>0,V=L.length>0;if(U){const $=z.map(Tb);N==null||N(z),T($)}if(V){const $=L.map(Tb);E==null||E(L),w($)}return(V||U)&&(k==null||k({nodes:L,edges:z})),{deletedNodes:L,deletedEdges:z}},getIntersectingNodes:(m,g=!0,x)=>{const y=sb(m),E=y?m:h(m),N=x!==void 0;return E?(x||t.getState().nodes).filter(w=>{const T=t.getState().nodeLookup.get(w.id);if(T&&!y&&(w.id===m.id||!T.internals.positionAbsolute))return!1;const k=ic(N?w:T),I=yd(k,E);return g&&I>0||I>=k.width*k.height||I>=E.width*E.height}):[]},isNodeIntersecting:(m,g,x=!0)=>{const E=sb(m)?m:h(m);if(!E)return!1;const N=yd(E,g);return x&&N>0||N>=g.width*g.height||N>=E.width*E.height},updateNode:d,updateNodeData:(m,g,x={replace:!1})=>{d(m,y=>{const E=typeof g=="function"?g(y):g;return x.replace?{...y,data:E}:{...y,data:{...y.data,...E}}},x)},updateEdge:p,updateEdgeData:(m,g,x={replace:!1})=>{p(m,y=>{const E=typeof g=="function"?g(y):g;return x.replace?{...y,data:E}:{...y,data:{...y.data,...E}}},x)},getNodesBounds:m=>{const{nodeLookup:g,nodeOrigin:x}=t.getState();return A4(m,{nodeLookup:g,nodeOrigin:x})},getHandleConnections:({type:m,id:g,nodeId:x})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${x}-${m}${g?`-${g}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:m,handleId:g,nodeId:x})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${x}${m?g?`-${m}-${g}`:`-${m}`:""}`))==null?void 0:y.values())??[])},fitView:async m=>{const g=t.getState().fitViewResolver??z4();return t.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:g}),n.nodeQueue.push(x=>[...x]),g.promise}}},[]);return b.useMemo(()=>({...i,...e,viewportInitialized:r}),[r])}const Rb=e=>e.selected,h6=typeof window<"u"?window:void 0;function f6({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Vt(),{deleteElements:r}=Sg(),i=oc(e,{actInsideInputWithModifier:!1}),o=oc(t,{target:h6});b.useEffect(()=>{if(i){const{edges:c,nodes:u}=n.getState();r({nodes:u.filter(Rb),edges:c.filter(Rb)}),n.setState({nodesSelectionActive:!1})}},[i]),b.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function p6(e){const t=Vt();b.useEffect(()=>{const n=()=>{var i,o,c,u;if(!e.current||!(((o=(i=e.current).checkVisibility)==null?void 0:o.call(i))??!0))return!1;const r=yg(e.current);(r.height===0||r.width===0)&&((u=(c=t.getState()).onError)==null||u.call(c,"004",Sr.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Hd={position:"absolute",width:"100%",height:"100%",top:0,left:0},m6=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function g6({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:o=.5,panOnScrollMode:c=Ca.Free,zoomOnDoubleClick:u=!0,panOnDrag:h=!0,defaultViewport:d,translateExtent:p,minZoom:m,maxZoom:g,zoomActivationKeyCode:x,preventScrolling:y=!0,children:E,noWheelClassName:N,noPanClassName:w,onViewportChange:T,isControlledViewport:k,paneClickDistance:I,selectionOnDrag:L}){const z=Vt(),U=b.useRef(null),{userSelectionActive:V,lib:$,connectionInProgress:P}=wt(m6,tn),D=oc(x),B=b.useRef();p6(U);const _=b.useCallback(C=>{T==null||T({x:C[0],y:C[1],zoom:C[2]}),k||z.setState({transform:C})},[T,k]);return b.useEffect(()=>{if(U.current){B.current=yF({domNode:U.current,minZoom:m,maxZoom:g,translateExtent:p,viewport:d,onDraggingChange:F=>z.setState(H=>H.paneDragging===F?H:{paneDragging:F}),onPanZoomStart:(F,H)=>{const{onViewportChangeStart:W,onMoveStart:K}=z.getState();K==null||K(F,H),W==null||W(H)},onPanZoom:(F,H)=>{const{onViewportChange:W,onMove:K}=z.getState();K==null||K(F,H),W==null||W(H)},onPanZoomEnd:(F,H)=>{const{onViewportChangeEnd:W,onMoveEnd:K}=z.getState();K==null||K(F,H),W==null||W(H)}});const{x:C,y:R,zoom:M}=B.current.getViewport();return z.setState({panZoom:B.current,transform:[C,R,M],domNode:U.current.closest(".react-flow")}),()=>{var F;(F=B.current)==null||F.destroy()}}},[]),b.useEffect(()=>{var C;(C=B.current)==null||C.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:o,panOnScrollMode:c,zoomOnDoubleClick:u,panOnDrag:h,zoomActivationKeyPressed:D,preventScrolling:y,noPanClassName:w,userSelectionActive:V,noWheelClassName:N,lib:$,onTransformChange:_,connectionInProgress:P,selectionOnDrag:L,paneClickDistance:I})},[e,t,n,r,i,o,c,u,h,D,y,w,V,N,$,_,P,L,I]),s.jsx("div",{className:"react-flow__renderer",ref:U,style:Hd,children:E})}const x6=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function v6(){const{userSelectionActive:e,userSelectionRect:t}=wt(x6,tn);return e&&t?s.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const fp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},y6=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function b6({isSelecting:e,selectionKeyPressed:t,selectionMode:n=rc.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:o,selectionOnDrag:c,onSelectionStart:u,onSelectionEnd:h,onPaneClick:d,onPaneContextMenu:p,onPaneScroll:m,onPaneMouseEnter:g,onPaneMouseMove:x,onPaneMouseLeave:y,children:E}){const N=b.useRef(0),w=Vt(),{userSelectionActive:T,elementsSelectable:k,dragging:I,panBy:L,autoPanSpeed:z}=wt(y6,tn),U=k&&(e||T),V=b.useRef(null),$=b.useRef(),P=b.useRef(new Set),D=b.useRef(new Set),B=b.useRef(!1),_=b.useRef(!1),C=b.useRef({x:0,y:0}),R=b.useRef(!1),M=ie=>{if(_.current||B.current||w.getState().connection.inProgress){_.current=!1,B.current=!1;return}d==null||d(ie),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},F=ie=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){ie.preventDefault();return}p==null||p(ie)},H=m?ie=>m(ie):void 0,W=ie=>{_.current&&(ie.stopPropagation(),_.current=!1)},K=ie=>{var Ge,Ae;if(ie.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:ye,transform:De}=w.getState();if($.current=ye==null?void 0:ye.getBoundingClientRect(),!$.current)return;const de=ie.target===V.current;if(!de&&!!ie.target.closest(".nokey")||!e||!(c&&de||t)||ie.button!==0||!ie.isPrimary)return;(Ae=(Ge=ie.target)==null?void 0:Ge.setPointerCapture)==null||Ae.call(Ge,ie.pointerId),_.current=!1;const{x:pe,y:Le}=kr(ie.nativeEvent,$.current),Te=wc({x:pe,y:Le},De);w.setState({userSelectionRect:{width:0,height:0,startX:Te.x,startY:Te.y,x:pe,y:Le}}),de||(ie.stopPropagation(),ie.preventDefault())};function q(ie,ye){const{userSelectionRect:De}=w.getState();if(!De)return;const{transform:de,nodeLookup:Se,edgeLookup:ae,connectionLookup:pe,triggerNodeChanges:Le,triggerEdgeChanges:Te,defaultEdgeOptions:Ge}=w.getState(),Ae={x:De.startX,y:De.startY},{x:tt,y:et}=Fo(Ae,de),jt={startX:Ae.x,startY:Ae.y,x:ie<tt?ie:tt,y:ye<et?ye:et,width:Math.abs(ie-tt),height:Math.abs(ye-et)},zn=P.current,sn=D.current;P.current=new Set(gg(Se,jt,de,n===rc.Partial,!0).map(cn=>cn.id)),D.current=new Set;const ln=(Ge==null?void 0:Ge.selectable)??!0;for(const cn of P.current){const rn=pe.get(cn);if(rn)for(const{edgeId:an}of rn.values()){const Ft=ae.get(an);Ft&&(Ft.selectable??ln)&&D.current.add(an)}}if(!rb(zn,P.current)){const cn=xo(Se,P.current,!0);Le(cn)}if(!rb(sn,D.current)){const cn=xo(ae,D.current);Te(cn)}w.setState({userSelectionRect:jt,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!i||!$.current)return;const[ie,ye]=xg(C.current,$.current,z);L({x:ie,y:ye}).then(De=>{if(!_.current||!De){N.current=requestAnimationFrame(Y);return}const{x:de,y:Se}=C.current;q(de,Se),N.current=requestAnimationFrame(Y)})}const fe=()=>{cancelAnimationFrame(N.current),N.current=0,R.current=!1};b.useEffect(()=>()=>fe(),[]);const me=ie=>{const{userSelectionRect:ye,transform:De,resetSelectedElements:de}=w.getState();if(!$.current||!ye)return;const{x:Se,y:ae}=kr(ie.nativeEvent,$.current);C.current={x:Se,y:ae};const pe=Fo({x:ye.startX,y:ye.startY},De);if(!_.current){const Le=t?0:o;if(Math.hypot(Se-pe.x,ae-pe.y)<=Le)return;de(),u==null||u(ie)}_.current=!0,R.current||(Y(),R.current=!0),q(Se,ae)},xe=ie=>{var ye,De;if(!U){ie.target===V.current&&w.getState().connection.inProgress&&(B.current=!0);return}ie.button===0&&((De=(ye=ie.target)==null?void 0:ye.releasePointerCapture)==null||De.call(ye,ie.pointerId),!T&&ie.target===V.current&&w.getState().userSelectionRect&&(M==null||M(ie)),w.setState({userSelectionActive:!1,userSelectionRect:null}),_.current&&(h==null||h(ie),w.setState({nodesSelectionActive:P.current.size>0})),fe())},oe=ie=>{var ye,De;(De=(ye=ie.target)==null?void 0:ye.releasePointerCapture)==null||De.call(ye,ie.pointerId),fe()},re=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:kn(["react-flow__pane",{draggable:re,dragging:I,selection:e}]),onClick:U?void 0:fp(M,V),onContextMenu:fp(F,V),onWheel:fp(H,V),onPointerEnter:U?void 0:g,onPointerMove:U?me:x,onPointerUp:xe,onPointerCancel:U?oe:void 0,onPointerDownCapture:U?K:void 0,onClickCapture:U?W:void 0,onPointerLeave:y,ref:V,style:Hd,children:[E,s.jsx(v6,{})]})}function vm({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:c,nodeLookup:u,onError:h}=t.getState(),d=u.get(e);if(!d){h==null||h("012",Sr.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&c)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):i([e])}function jS({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,nodeClickDistance:c}){const u=Vt(),[h,d]=b.useState(!1),p=b.useRef();return b.useEffect(()=>{if(!t)return p.current=iF({getStoreItems:()=>u.getState(),onNodeMouseDown:m=>{vm({id:m,store:u,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}}),()=>{var m;(m=p.current)==null||m.destroy(),p.current=void 0}},[t,u,e]),b.useEffect(()=>{t||!e.current||!p.current||p.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:i,nodeClickDistance:c})},[n,r,t,o,e,i,c]),h}const k6=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function SS(){const e=Vt();return b.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:o,nodesDraggable:c,onError:u,updateNodePositions:h,nodeLookup:d,nodeOrigin:p}=e.getState(),m=new Map,g=k6(c),x=i?o[0]:5,y=i?o[1]:5,E=n.direction.x*x*n.factor,N=n.direction.y*y*n.factor;for(const[,w]of d){if(!g(w))continue;let T={x:w.internals.positionAbsolute.x+E,y:w.internals.positionAbsolute.y+N};i&&(T=Nc(T,o));const{position:k,positionAbsolute:I}=Hj({nodeId:w.id,nextPosition:T,nodeLookup:d,nodeExtent:r,nodeOrigin:p,onError:u});w.position=k,w.internals.positionAbsolute=I,m.set(w.id,w)}h(m)},[])}const _g=b.createContext(null),N6=_g.Provider;_g.Consumer;const _S=()=>b.useContext(_g),w6=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ES=b.createContext(null);function j6({children:e}){const t=wt(w6,tn);return s.jsx(ES.Provider,{value:t,children:e})}function S6(){const e=b.useContext(ES);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const _6={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},E6=(e,t,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:o,connection:c}=r,{fromHandle:u,toHandle:h,isValid:d}=c;if(!u&&!i)return _6;const p=(h==null?void 0:h.nodeId)===e&&(h==null?void 0:h.id)===t&&(h==null?void 0:h.type)===n;return{connectingFrom:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n,connectingTo:p,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.id)===t&&(i==null?void 0:i.type)===n,isPossibleEndHandle:o===Lo.Strict?(u==null?void 0:u.type)!==n:e!==(u==null?void 0:u.nodeId)||t!==(u==null?void 0:u.id),connectionInProcess:!!u,clickConnectionInProcess:!!i,valid:p&&d}};function C6({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:c,onConnect:u,children:h,className:d,onMouseDown:p,onTouchStart:m,...g},x){var R,M;const y=c||null,E=e==="target",N=Vt(),w=_S(),{connectOnClick:T,noPanClassName:k,rfId:I}=S6(),{connectingFrom:L,connectingTo:z,clickConnecting:U,isPossibleEndHandle:V,connectionInProcess:$,clickConnectionInProcess:P,valid:D}=wt(E6(w,y,e),tn);w||(M=(R=N.getState()).onError)==null||M.call(R,"010",Sr.error010());const B=F=>{const{defaultEdgeOptions:H,onConnect:W,hasDefaultEdges:K}=N.getState(),q={...H,...F};if(K){const{edges:Y,setEdges:fe,onError:me}=N.getState();fe(a6(q,Y,{onError:me}))}W==null||W(q),u==null||u(q)},_=F=>{if(!w)return;const H=Jj(F.nativeEvent);if(i&&(H&&F.button===0||!H)){const W=N.getState();xm.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:E,handleId:y,nodeId:w,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...K)=>{var q,Y;return(Y=(q=N.getState()).onConnectEnd)==null?void 0:Y.call(q,...K)},updateConnection:W.updateConnection,onConnect:B,isValidConnection:n||((...K)=>{var q,Y;return((Y=(q=N.getState()).isValidConnection)==null?void 0:Y.call(q,...K))??!0}),getTransform:()=>N.getState().transform,getFromHandle:()=>N.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}H?p==null||p(F):m==null||m(F)},C=F=>{const{onClickConnectStart:H,onClickConnectEnd:W,connectionClickStartHandle:K,connectionMode:q,isValidConnection:Y,lib:fe,rfId:me,nodeLookup:xe,connection:oe}=N.getState();if(!w||!K&&!i)return;if(!K){H==null||H(F.nativeEvent,{nodeId:w,handleId:y,handleType:e}),N.setState({connectionClickStartHandle:{nodeId:w,type:e,id:y}});return}const re=Xj(F.target),ie=n||Y,{connection:ye,isValid:De}=xm.isValid(F.nativeEvent,{handle:{nodeId:w,id:y,type:e},connectionMode:q,fromNodeId:K.nodeId,fromHandleId:K.id||null,fromType:K.type,isValidConnection:ie,flowId:me,doc:re,lib:fe,nodeLookup:xe});De&&ye&&B(ye);const de=structuredClone(oe);delete de.inProgress,de.toPosition=de.toHandle?de.toHandle.position:null,W==null||W(F,de),N.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":t,"data-id":`${I}-${w}-${y}-${e}`,className:kn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,d,{source:!E,target:E,connectable:r,connectablestart:i,connectableend:o,clickconnecting:U,connectingfrom:L,connectingto:z,valid:D,connectionindicator:r&&(!$||V)&&($||P?o:i)}]),onMouseDown:_,onTouchStart:_,onClick:T?C:void 0,ref:x,...g,children:h})}const Wi=b.memo(kS(C6));function A6({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(Wi,{type:"source",position:n,isConnectable:t})]})}function I6({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:r=Je.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(Wi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(Wi,{type:"source",position:r,isConnectable:t})]})}function T6(){return null}function $6({data:e,isConnectable:t,targetPosition:n=Je.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(Wi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const bd={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ob={input:A6,default:I6,output:$6,group:T6};function M6(e){var t,n,r,i;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((i=e.style)==null?void 0:i.height)}}const R6=e=>{const{width:t,height:n,x:r,y:i}=kc(e.nodeLookup,{filter:o=>!!o.selected});return{width:br(t)?t:null,height:br(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function O6({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Vt(),{width:i,height:o,transformString:c,userSelectionActive:u}=wt(R6,tn),h=SS(),d=b.useRef(null);b.useEffect(()=>{var x;n||(x=d.current)==null||x.focus({preventScroll:!0})},[n]);const p=!u&&i!==null&&o!==null;if(jS({nodeRef:d,disabled:!p}),!p)return null;const m=e?x=>{const y=r.getState().nodes.filter(E=>E.selected);e(x,y)}:void 0,g=x=>{Object.prototype.hasOwnProperty.call(bd,x.key)&&(x.preventDefault(),h({direction:bd[x.key],factor:x.shiftKey?4:1}))};return s.jsx("div",{className:kn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c},children:s.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:i,height:o}})})}const zb=typeof window<"u"?window:void 0,z6=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function CS({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:c,paneClickDistance:u,deleteKeyCode:h,selectionKeyCode:d,selectionOnDrag:p,selectionMode:m,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:y,panActivationKeyCode:E,zoomActivationKeyCode:N,elementsSelectable:w,zoomOnScroll:T,zoomOnPinch:k,panOnScroll:I,panOnScrollSpeed:L,panOnScrollMode:z,zoomOnDoubleClick:U,panOnDrag:V,autoPanOnSelection:$,defaultViewport:P,translateExtent:D,minZoom:B,maxZoom:_,preventScrolling:C,onSelectionContextMenu:R,noWheelClassName:M,noPanClassName:F,disableKeyboardA11y:H,onViewportChange:W,isControlledViewport:K}){const{nodesSelectionActive:q,userSelectionActive:Y}=wt(z6,tn),fe=oc(d,{target:zb}),me=oc(E,{target:zb}),xe=me||V,oe=me||I,re=p&&xe!==!0,ie=fe||Y||re;return f6({deleteKeyCode:h,multiSelectionKeyCode:y}),s.jsx(g6,{onPaneContextMenu:o,elementsSelectable:w,zoomOnScroll:T,zoomOnPinch:k,panOnScroll:oe,panActivationKeyPressed:me,panOnScrollSpeed:L,panOnScrollMode:z,zoomOnDoubleClick:U,panOnDrag:!fe&&xe,defaultViewport:P,translateExtent:D,minZoom:B,maxZoom:_,zoomActivationKeyCode:N,preventScrolling:C,noWheelClassName:M,noPanClassName:F,onViewportChange:W,isControlledViewport:K,paneClickDistance:u,selectionOnDrag:re,children:s.jsxs(b6,{onSelectionStart:g,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:c,panOnDrag:xe,autoPanOnSelection:$,isSelecting:!!ie,selectionMode:m,selectionKeyPressed:fe,paneClickDistance:u,selectionOnDrag:re,children:[e,q&&s.jsx(O6,{onSelectionContextMenu:R,noPanClassName:F,disableKeyboardA11y:H})]})})}CS.displayName="FlowRenderer";const P6=b.memo(CS),L6=e=>t=>e?gg(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 D6(e){return wt(b.useCallback(L6(e),[e]),tn)}const F6=e=>e.updateNodeInternals;function B6(){const e=wt(F6),[t]=b.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(i=>{const o=i.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:i.target,force:!0})}),e(r)}));return b.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function U6({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const i=Vt(),o=b.useRef(null),c=b.useRef(null),u=b.useRef(e.sourcePosition),h=b.useRef(e.targetPosition),d=b.useRef(t),p=n&&!!e.internals.handleBounds;return b.useEffect(()=>{o.current&&!e.hidden&&(!p||c.current!==o.current)&&(c.current&&(r==null||r.unobserve(c.current)),r==null||r.observe(o.current),c.current=o.current)},[p,e.hidden]),b.useEffect(()=>()=>{c.current&&(r==null||r.unobserve(c.current),c.current=null)},[]),b.useEffect(()=>{if(o.current){const m=d.current!==t,g=u.current!==e.sourcePosition,x=h.current!==e.targetPosition;(m||g||x)&&(d.current=t,u.current=e.sourcePosition,h.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function H6({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:o,onDoubleClick:c,nodesDraggable:u,elementsSelectable:h,nodesConnectable:d,nodesFocusable:p,resizeObserver:m,noDragClassName:g,noPanClassName:x,disableKeyboardA11y:y,rfId:E,nodeTypes:N,nodeClickDistance:w,onError:T}){const{node:k,internals:I,isParent:L}=wt(ie=>{const ye=ie.nodeLookup.get(e),De=ie.parentLookup.has(e);return{node:ye,internals:ye.internals,isParent:De}},tn);let z=k.type||"default",U=(N==null?void 0:N[z])||Ob[z];U===void 0&&(T==null||T("003",Sr.error003(z)),z="default",U=(N==null?void 0:N.default)||Ob.default);const V=!!(k.draggable||u&&typeof k.draggable>"u"),$=!!(k.selectable||h&&typeof k.selectable>"u"),P=!!(k.connectable||d&&typeof k.connectable>"u"),D=!!(k.focusable||p&&typeof k.focusable>"u"),B=Vt(),_=Gj(k),C=U6({node:k,nodeType:z,hasDimensions:_,resizeObserver:m}),R=jS({nodeRef:C,disabled:k.hidden||!V,noDragClassName:g,handleSelector:k.dragHandle,nodeId:e,isSelectable:$,nodeClickDistance:w}),M=SS();if(k.hidden)return null;const F=Ar(k),H=M6(k),W=$||V||t||n||r||i,K=n?ie=>n(ie,{...I.userNode}):void 0,q=r?ie=>r(ie,{...I.userNode}):void 0,Y=i?ie=>i(ie,{...I.userNode}):void 0,fe=o?ie=>o(ie,{...I.userNode}):void 0,me=c?ie=>c(ie,{...I.userNode}):void 0,xe=ie=>{const{selectNodesOnDrag:ye,nodeDragThreshold:De}=B.getState();$&&(!ye||!V||De>0)&&vm({id:e,store:B,nodeRef:C}),t&&t(ie,{...I.userNode})},oe=ie=>{if(!(Qj(ie.nativeEvent)||y)){if(Dj.includes(ie.key)&&$){const ye=ie.key==="Escape";vm({id:e,store:B,unselect:ye,nodeRef:C})}else if(V&&k.selected&&Object.prototype.hasOwnProperty.call(bd,ie.key)){ie.preventDefault();const{ariaLabelConfig:ye}=B.getState();B.setState({ariaLiveMessage:ye["node.a11yDescription.ariaLiveMessage"]({direction:ie.key.replace("Arrow","").toLowerCase(),x:~~I.positionAbsolute.x,y:~~I.positionAbsolute.y})}),M({direction:bd[ie.key],factor:ie.shiftKey?4:1})}}},re=()=>{var pe;if(y||!((pe=C.current)!=null&&pe.matches(":focus-visible")))return;const{transform:ie,width:ye,height:De,autoPanOnNodeFocus:de,setCenter:Se}=B.getState();if(!de)return;gg(new Map([[e,k]]),{x:0,y:0,width:ye,height:De},ie,!0).length>0||Se(k.position.x+F.width/2,k.position.y+F.height/2,{zoom:ie[2]})};return s.jsx("div",{className:kn(["react-flow__node",`react-flow__node-${z}`,{[x]:V},k.className,{selected:k.selected,selectable:$,parent:L,draggable:V,dragging:R}]),ref:C,style:{zIndex:I.z,transform:`translate(${I.positionAbsolute.x}px,${I.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:_?"visible":"hidden",...k.style,...H},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:K,onMouseMove:q,onMouseLeave:Y,onContextMenu:fe,onClick:xe,onDoubleClick:me,onKeyDown:D?oe:void 0,tabIndex:D?0:void 0,onFocus:D?re:void 0,role:k.ariaRole??(D?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${xS}-${E}`,"aria-label":k.ariaLabel,...k.domAttributes,children:s.jsx(N6,{value:e,children:s.jsx(U,{id:e,data:k.data,type:z,positionAbsoluteX:I.positionAbsolute.x,positionAbsoluteY:I.positionAbsolute.y,selected:k.selected??!1,selectable:$,draggable:V,deletable:k.deletable??!0,isConnectable:P,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:R,dragHandle:k.dragHandle,zIndex:I.z,parentId:k.parentId,...F})})})}var Z6=b.memo(H6);const W6=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function AS(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=wt(W6,tn),o=D6(e.onlyRenderVisibleElements),c=B6();return s.jsx("div",{className:"react-flow__nodes",style:Hd,children:o.map(u=>s.jsx(Z6,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}AS.displayName="NodeRenderer";const V6=b.memo(AS);function q6(e){return wt(b.useCallback(n=>{if(!e)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const o=n.nodeLookup.get(i.source),c=n.nodeLookup.get(i.target);o&&c&&F4({sourceNode:o,targetNode:c,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),tn)}const G6=({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"})},K6=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Pb={[xd.Arrow]:G6,[xd.ArrowClosed]:K6};function Y6(e){const t=Vt();return b.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(Pb,e)?Pb[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",Sr.error009(e)),null)},[e])}const X6=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const h=Y6(t);return h?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:u,refX:"0",refY:"0",children:s.jsx(h,{color:n,strokeWidth:c})}):null},IS=({defaultColor:e,rfId:t})=>{const n=wt(o=>o.edges),r=wt(o=>o.defaultEdgeOptions),i=b.useMemo(()=>G4(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return i.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:i.map(o=>s.jsx(X6,{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};IS.displayName="MarkerDefinitions";var Q6=b.memo(IS);function TS({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:o,labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:h,className:d,...p}){const[m,g]=b.useState({x:1,y:0,width:0,height:0}),x=kn(["react-flow__edge-textwrapper",d]),y=b.useRef(null);return b.useEffect(()=>{if(y.current){const E=y.current.getBBox();g({x:E.x,y:E.y,width:E.width,height:E.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:x,visibility:m.width?"visible":"hidden",...p,children:[i&&s.jsx("rect",{width:m.width+2*c[0],x:-c[0],y:-c[1],height:m.height+2*c[1],className:"react-flow__edge-textbg",style:o,rx:u,ry:u}),s.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:y,style:r,children:n}),h]}):null}TS.displayName="EdgeText";const J6=b.memo(TS);function Zd({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:h,interactionWidth:d=20,...p}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...p,d:e,fill:"none",className:kn(["react-flow__edge-path",p.className])}),d?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&br(t)&&br(n)?s.jsx(J6,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:h}):null]})}function Lb({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Je.Left||e===Je.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function $S({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:r,targetY:i,targetPosition:o=Je.Top}){const[c,u]=Lb({pos:n,x1:e,y1:t,x2:r,y2:i}),[h,d]=Lb({pos:o,x1:r,y1:i,x2:e,y2:t}),[p,m,g,x]=eS({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:c,sourceControlY:u,targetControlX:h,targetControlY:d});return[`M${e},${t} C${c},${u} ${h},${d} ${r},${i}`,p,m,g,x]}function MS(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:c,targetPosition:u,label:h,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:y,markerEnd:E,markerStart:N,interactionWidth:w})=>{const[T,k,I]=$S({sourceX:n,sourceY:r,sourcePosition:c,targetX:i,targetY:o,targetPosition:u}),L=e.isInternal?void 0:t;return s.jsx(Zd,{id:L,path:T,labelX:k,labelY:I,label:h,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:y,markerEnd:E,markerStart:N,interactionWidth:w})})}const eB=MS({isInternal:!1}),RS=MS({isInternal:!0});eB.displayName="SimpleBezierEdge";RS.displayName="SimpleBezierEdgeInternal";function OS(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,sourcePosition:x=Je.Bottom,targetPosition:y=Je.Top,markerEnd:E,markerStart:N,pathOptions:w,interactionWidth:T})=>{const[k,I,L]=pm({sourceX:n,sourceY:r,sourcePosition:x,targetX:i,targetY:o,targetPosition:y,borderRadius:w==null?void 0:w.borderRadius,offset:w==null?void 0:w.offset,stepPosition:w==null?void 0:w.stepPosition}),z=e.isInternal?void 0:t;return s.jsx(Zd,{id:z,path:k,labelX:I,labelY:L,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:E,markerStart:N,interactionWidth:T})})}const zS=OS({isInternal:!1}),PS=OS({isInternal:!0});zS.displayName="SmoothStepEdge";PS.displayName="SmoothStepEdgeInternal";function LS(e){return b.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(zS,{...n,id:r,pathOptions:b.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const tB=LS({isInternal:!1}),DS=LS({isInternal:!0});tB.displayName="StepEdge";DS.displayName="StepEdgeInternal";function FS(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:x,markerStart:y,interactionWidth:E})=>{const[N,w,T]=sS({sourceX:n,sourceY:r,targetX:i,targetY:o}),k=e.isInternal?void 0:t;return s.jsx(Zd,{id:k,path:N,labelX:w,labelY:T,label:c,labelStyle:u,labelShowBg:h,labelBgStyle:d,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:x,markerStart:y,interactionWidth:E})})}const nB=FS({isInternal:!1}),BS=FS({isInternal:!0});nB.displayName="StraightEdge";BS.displayName="StraightEdgeInternal";function US(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:c=Je.Bottom,targetPosition:u=Je.Top,label:h,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:y,markerEnd:E,markerStart:N,pathOptions:w,interactionWidth:T})=>{const[k,I,L]=tS({sourceX:n,sourceY:r,sourcePosition:c,targetX:i,targetY:o,targetPosition:u,curvature:w==null?void 0:w.curvature}),z=e.isInternal?void 0:t;return s.jsx(Zd,{id:z,path:k,labelX:I,labelY:L,label:h,labelStyle:d,labelShowBg:p,labelBgStyle:m,labelBgPadding:g,labelBgBorderRadius:x,style:y,markerEnd:E,markerStart:N,interactionWidth:T})})}const sB=US({isInternal:!1}),HS=US({isInternal:!0});sB.displayName="BezierEdge";HS.displayName="BezierEdgeInternal";const Db={default:HS,straight:BS,step:DS,smoothstep:PS,simplebezier:RS},Fb={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},rB=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,iB=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,Bb="react-flow__edgeupdater";function Ub({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:c,type:u}){return s.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:c,className:kn([Bb,`${Bb}-${u}`]),cx:rB(t,r,e),cy:iB(n,r,e),r,stroke:"transparent",fill:"transparent"})}function aB({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:o,targetY:c,sourcePosition:u,targetPosition:h,onReconnect:d,onReconnectStart:p,onReconnectEnd:m,setReconnecting:g,setUpdateHover:x}){const y=Vt(),E=(I,L)=>{if(I.button!==0)return;const{autoPanOnConnect:z,domNode:U,connectionMode:V,connectionRadius:$,lib:P,onConnectStart:D,cancelConnection:B,nodeLookup:_,rfId:C,panBy:R,updateConnection:M}=y.getState(),F=L.type==="target",H=(q,Y)=>{g(!1),m==null||m(q,n,L.type,Y)},W=q=>d==null?void 0:d(n,q),K=(q,Y)=>{g(!0),p==null||p(I,n,L.type),D==null||D(q,Y)};xm.onPointerDown(I.nativeEvent,{autoPanOnConnect:z,connectionMode:V,connectionRadius:$,domNode:U,handleId:L.id,nodeId:L.nodeId,nodeLookup:_,isTarget:F,edgeUpdaterType:L.type,lib:P,flowId:C,cancelConnection:B,panBy:R,isValidConnection:(...q)=>{var Y,fe;return((fe=(Y=y.getState()).isValidConnection)==null?void 0:fe.call(Y,...q))??!0},onConnect:W,onConnectStart:K,onConnectEnd:(...q)=>{var Y,fe;return(fe=(Y=y.getState()).onConnectEnd)==null?void 0:fe.call(Y,...q)},onReconnectEnd:H,updateConnection:M,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:I.currentTarget})},N=I=>E(I,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),w=I=>E(I,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),T=()=>x(!0),k=()=>x(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(Ub,{position:u,centerX:r,centerY:i,radius:t,onMouseDown:N,onMouseEnter:T,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&s.jsx(Ub,{position:h,centerX:o,centerY:c,radius:t,onMouseDown:w,onMouseEnter:T,onMouseOut:k,type:"target"})]})}function oB({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:o,onContextMenu:c,onMouseEnter:u,onMouseMove:h,onMouseLeave:d,reconnectRadius:p,onReconnect:m,onReconnectStart:g,onReconnectEnd:x,rfId:y,edgeTypes:E,noPanClassName:N,onError:w,disableKeyboardA11y:T}){let k=wt(Se=>Se.edgeLookup.get(e));const I=wt(Se=>Se.defaultEdgeOptions);k=I?{...I,...k}:k;let L=k.type||"default",z=(E==null?void 0:E[L])||Db[L];z===void 0&&(w==null||w("011",Sr.error011(L)),L="default",z=(E==null?void 0:E.default)||Db.default);const U=!!(k.focusable||t&&typeof k.focusable>"u"),V=typeof m<"u"&&(k.reconnectable||n&&typeof k.reconnectable>"u"),$=!!(k.selectable||r&&typeof k.selectable>"u"),P=b.useRef(null),[D,B]=b.useState(!1),[_,C]=b.useState(!1),R=Vt(),{zIndex:M=k.zIndex,sourceX:F,sourceY:H,targetX:W,targetY:K,sourcePosition:q,targetPosition:Y}=wt(b.useCallback(Se=>{const ae=Se.nodeLookup.get(k.source),pe=Se.nodeLookup.get(k.target);if(!ae||!pe)return Fb;const Le=q4({id:e,sourceNode:ae,targetNode:pe,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:Se.connectionMode,onError:w}),Te=D4({selected:k.selected,zIndex:k.zIndex,sourceNode:ae,targetNode:pe,elevateOnSelect:Se.elevateEdgesOnSelect,zIndexMode:Se.zIndexMode});return{...Le||Fb,zIndex:Te}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex,w]),tn),fe=b.useMemo(()=>k.markerStart?`url('#${mm(k.markerStart,y)}')`:void 0,[k.markerStart,y]),me=b.useMemo(()=>k.markerEnd?`url('#${mm(k.markerEnd,y)}')`:void 0,[k.markerEnd,y]);if(k.hidden||F===null||H===null||W===null||K===null)return null;const xe=Se=>{var Te;const{addSelectedEdges:ae,unselectNodesAndEdges:pe,multiSelectionActive:Le}=R.getState();$&&(R.setState({nodesSelectionActive:!1}),k.selected&&Le?(pe({nodes:[],edges:[k]}),(Te=P.current)==null||Te.blur()):ae([e])),i&&i(Se,k)},oe=o?Se=>{o(Se,{...k})}:void 0,re=c?Se=>{c(Se,{...k})}:void 0,ie=u?Se=>{u(Se,{...k})}:void 0,ye=h?Se=>{h(Se,{...k})}:void 0,De=d?Se=>{d(Se,{...k})}:void 0,de=Se=>{var ae;if(!T&&Dj.includes(Se.key)&&$){const{unselectNodesAndEdges:pe,addSelectedEdges:Le}=R.getState();Se.key==="Escape"?((ae=P.current)==null||ae.blur(),pe({edges:[k]})):Le([e])}};return s.jsx("svg",{style:{zIndex:M},children:s.jsxs("g",{className:kn(["react-flow__edge",`react-flow__edge-${L}`,k.className,N,{selected:k.selected,animated:k.animated,inactive:!$&&!i,updating:D,selectable:$}]),onClick:xe,onDoubleClick:oe,onContextMenu:re,onMouseEnter:ie,onMouseMove:ye,onMouseLeave:De,onKeyDown:U?de:void 0,tabIndex:U?0:void 0,role:k.ariaRole??(U?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":U?`${vS}-${y}`:void 0,ref:P,...k.domAttributes,children:[!_&&s.jsx(z,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:$,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:F,sourceY:H,targetX:W,targetY:K,sourcePosition:q,targetPosition:Y,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:fe,markerEnd:me,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),V&&s.jsx(aB,{edge:k,isReconnectable:V,reconnectRadius:p,onReconnect:m,onReconnectStart:g,onReconnectEnd:x,sourceX:F,sourceY:H,targetX:W,targetY:K,sourcePosition:q,targetPosition:Y,setUpdateHover:B,setReconnecting:C})]})})}var lB=b.memo(oB);const cB=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ZS({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:o,onEdgeContextMenu:c,onEdgeMouseEnter:u,onEdgeMouseMove:h,onEdgeMouseLeave:d,onEdgeClick:p,reconnectRadius:m,onEdgeDoubleClick:g,onReconnectStart:x,onReconnectEnd:y,disableKeyboardA11y:E}){const{edgesFocusable:N,edgesReconnectable:w,elementsSelectable:T,onError:k}=wt(cB,tn),I=q6(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(Q6,{defaultColor:e,rfId:n}),I.map(L=>s.jsx(lB,{id:L,edgesFocusable:N,edgesReconnectable:w,elementsSelectable:T,noPanClassName:i,onReconnect:o,onContextMenu:c,onMouseEnter:u,onMouseMove:h,onMouseLeave:d,onClick:p,reconnectRadius:m,onDoubleClick:g,onReconnectStart:x,onReconnectEnd:y,rfId:n,onError:k,edgeTypes:r,disableKeyboardA11y:E},L))]})}ZS.displayName="EdgeRenderer";const uB=b.memo(ZS),Hb=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function dB({children:e}){const t=Vt(),n=b.useRef(null),[r]=b.useState(()=>t.getState().transform);return NS(()=>{let i=null;const o=()=>{const c=t.getState().transform;i&&c[0]===i[0]&&c[1]===i[1]&&c[2]===i[2]||(i=c,n.current&&(n.current.style.transform=Hb(c)))};return o(),t.subscribe(o)},[t]),s.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Hb(r)},children:e})}function hB(e){const t=Sg(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const fB=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function pB(e){const t=wt(fB),n=Vt();return b.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function mB(e){return e.connection.inProgress?{...e.connection,to:wc(e.connection.to,e.transform)}:{...e.connection}}function gB(e){return mB}function xB(e){const t=gB();return wt(t,tn)}const vB=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function yB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:c,isValid:u,inProgress:h}=wt(vB,tn);return!(o&&i&&h)?null:s.jsx("svg",{style:e,width:o,height:c,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:kn(["react-flow__connection",Yj(u)]),children:s.jsx(WS,{style:t,type:n,CustomComponent:r,isValid:u})})})}const WS=({style:e,type:t=Di.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:o,fromNode:c,fromHandle:u,fromPosition:h,to:d,toNode:p,toHandle:m,toPosition:g,pointer:x}=xB();if(!i)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:c,fromHandle:u,fromX:o.x,fromY:o.y,toX:d.x,toY:d.y,fromPosition:h,toPosition:g,connectionStatus:Yj(r),toNode:p,toHandle:m,pointer:x});let y="";const E={sourceX:o.x,sourceY:o.y,sourcePosition:h,targetX:d.x,targetY:d.y,targetPosition:g};switch(t){case Di.Bezier:[y]=tS(E);break;case Di.SimpleBezier:[y]=$S(E);break;case Di.Step:[y]=pm({...E,borderRadius:0});break;case Di.SmoothStep:[y]=pm(E);break;default:[y]=sS(E)}return s.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};WS.displayName="ConnectionLine";const bB={};function Zb(e=bB){b.useRef(e),Vt(),b.useEffect(()=>{},[e])}function kB(){Vt(),b.useRef(!1),b.useEffect(()=>{},[])}function VS({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:o,onEdgeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:x,connectionLineType:y,connectionLineStyle:E,connectionLineComponent:N,connectionLineContainerStyle:w,selectionKeyCode:T,selectionOnDrag:k,selectionMode:I,multiSelectionKeyCode:L,panActivationKeyCode:z,zoomActivationKeyCode:U,deleteKeyCode:V,onlyRenderVisibleElements:$,elementsSelectable:P,defaultViewport:D,translateExtent:B,minZoom:_,maxZoom:C,preventScrolling:R,defaultMarkerColor:M,zoomOnScroll:F,zoomOnPinch:H,panOnScroll:W,panOnScrollSpeed:K,panOnScrollMode:q,zoomOnDoubleClick:Y,panOnDrag:fe,autoPanOnSelection:me,onPaneClick:xe,onPaneMouseEnter:oe,onPaneMouseMove:re,onPaneMouseLeave:ie,onPaneScroll:ye,onPaneContextMenu:De,paneClickDistance:de,nodeClickDistance:Se,onEdgeContextMenu:ae,onEdgeMouseEnter:pe,onEdgeMouseMove:Le,onEdgeMouseLeave:Te,reconnectRadius:Ge,onReconnect:Ae,onReconnectStart:tt,onReconnectEnd:et,noDragClassName:jt,noWheelClassName:zn,noPanClassName:sn,disableKeyboardA11y:ln,nodeExtent:cn,rfId:rn,viewport:an,onViewportChange:Ft,nodesDraggable:Un}){return Zb(e),Zb(t),kB(),hB(n),pB(an),s.jsx(P6,{onPaneClick:xe,onPaneMouseEnter:oe,onPaneMouseMove:re,onPaneMouseLeave:ie,onPaneContextMenu:De,onPaneScroll:ye,paneClickDistance:de,deleteKeyCode:V,selectionKeyCode:T,selectionOnDrag:k,selectionMode:I,onSelectionStart:g,onSelectionEnd:x,multiSelectionKeyCode:L,panActivationKeyCode:z,zoomActivationKeyCode:U,elementsSelectable:P,zoomOnScroll:F,zoomOnPinch:H,zoomOnDoubleClick:Y,panOnScroll:W,panOnScrollSpeed:K,panOnScrollMode:q,panOnDrag:fe,autoPanOnSelection:me,defaultViewport:D,translateExtent:B,minZoom:_,maxZoom:C,onSelectionContextMenu:m,preventScrolling:R,noDragClassName:jt,noWheelClassName:zn,noPanClassName:sn,disableKeyboardA11y:ln,onViewportChange:Ft,isControlledViewport:!!an,children:s.jsxs(dB,{children:[s.jsx(uB,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:c,onReconnect:Ae,onReconnectStart:tt,onReconnectEnd:et,onlyRenderVisibleElements:$,onEdgeContextMenu:ae,onEdgeMouseEnter:pe,onEdgeMouseMove:Le,onEdgeMouseLeave:Te,reconnectRadius:Ge,defaultMarkerColor:M,noPanClassName:sn,disableKeyboardA11y:ln,rfId:rn}),s.jsx(yB,{style:E,type:y,component:N,containerStyle:w}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(V6,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:d,onNodeContextMenu:p,nodeClickDistance:Se,onlyRenderVisibleElements:$,noPanClassName:sn,noDragClassName:jt,disableKeyboardA11y:ln,nodeExtent:cn,rfId:rn,nodesDraggable:Un}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}VS.displayName="GraphView";const NB=b.memo(VS),wB=qj(),Wb=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:h=.5,maxZoom:d=2,nodeOrigin:p,nodeExtent:m,zIndexMode:g="basic"}={})=>{const x=new Map,y=new Map,E=new Map,N=new Map,w=r??t??[],T=n??e??[],k=p??[0,0],I=m??sc;aS(E,N,w);const{nodesInitialized:L}=gm(T,x,y,{nodeOrigin:k,nodeExtent:I,zIndexMode:g});let z=[0,0,1];if(c&&i&&o){const U=kc(x,{filter:D=>!!((D.width||D.initialWidth)&&(D.height||D.initialHeight))}),{x:V,y:$,zoom:P}=vg(U,i,o,h,d,(u==null?void 0:u.padding)??.1);z=[V,$,P]}return{rfId:"1",width:i??0,height:o??0,transform:z,nodes:T,nodesInitialized:L,nodeLookup:x,parentLookup:y,edges:w,edgeLookup:N,connectionLookup:E,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:h,maxZoom:d,translateExtent:sc,nodeExtent:I,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Lo.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,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:{...Bj},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:wB,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Fj,zIndexMode:g,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},jB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:h,maxZoom:d,nodeOrigin:p,nodeExtent:m,zIndexMode:g})=>zF((x,y)=>{async function E(){const{nodeLookup:N,panZoom:w,fitViewOptions:T,fitViewResolver:k,width:I,height:L,minZoom:z,maxZoom:U}=y();w&&(await $4({nodes:N,width:I,height:L,panZoom:w,minZoom:z,maxZoom:U},T),k==null||k.resolve(!0),x({fitViewResolver:null}))}return{...Wb({nodes:e,edges:t,width:i,height:o,fitView:c,fitViewOptions:u,minZoom:h,maxZoom:d,nodeOrigin:p,nodeExtent:m,defaultNodes:n,defaultEdges:r,zIndexMode:g}),setNodes:N=>{const{nodeLookup:w,parentLookup:T,nodeOrigin:k,nodeExtent:I,elevateNodesOnSelect:L,fitViewQueued:z,zIndexMode:U,nodesSelectionActive:V}=y(),{nodesInitialized:$,hasSelectedNodes:P}=gm(N,w,T,{nodeOrigin:k,nodeExtent:I,elevateNodesOnSelect:L,checkEquality:!0,zIndexMode:U}),D=V&&P;z&&$?(E(),x({nodes:N,nodesInitialized:$,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:D})):x({nodes:N,nodesInitialized:$,nodesSelectionActive:D})},setEdges:N=>{const{connectionLookup:w,edgeLookup:T}=y();aS(w,T,N),x({edges:N})},setDefaultNodesAndEdges:(N,w)=>{if(N){const{setNodes:T}=y();T(N),x({hasDefaultNodes:!0})}if(w){const{setEdges:T}=y();T(w),x({hasDefaultEdges:!0})}},updateNodeInternals:N=>{const{triggerNodeChanges:w,nodeLookup:T,parentLookup:k,domNode:I,nodeOrigin:L,nodeExtent:z,debug:U,fitViewQueued:V,zIndexMode:$}=y(),{changes:P,updatedInternals:D}=tF(N,T,k,I,L,z,$);D&&(X4(T,k,{nodeOrigin:L,nodeExtent:z,zIndexMode:$}),V?(E(),x({fitViewQueued:!1,fitViewOptions:void 0})):x({}),(P==null?void 0:P.length)>0&&(U&&console.log("React Flow: trigger node changes",P),w==null||w(P)))},updateNodePositions:(N,w=!1)=>{const T=[];let k=[];const{nodeLookup:I,triggerNodeChanges:L,connection:z,updateConnection:U,onNodesChangeMiddlewareMap:V}=y();for(const[$,P]of N){const D=I.get($),B=!!(D!=null&&D.expandParent&&(D!=null&&D.parentId)&&(P!=null&&P.position)),_={id:$,type:"position",position:B?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:w};if(D&&z.inProgress&&z.fromNode.id===D.id){const C=Oa(D,z.fromHandle,Je.Left,!0);U({...z,from:C})}B&&D.parentId&&T.push({id:$,parentId:D.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),k.push(_)}if(T.length>0){const{parentLookup:$,nodeOrigin:P}=y(),D=jg(T,I,$,P);k.push(...D)}for(const $ of V.values())k=$(k);L(k)},triggerNodeChanges:N=>{const{onNodesChange:w,setNodes:T,nodes:k,hasDefaultNodes:I,debug:L}=y();if(N!=null&&N.length){if(I){const z=s6(N,k);T(z)}L&&console.log("React Flow: trigger node changes",N),w==null||w(N)}},triggerEdgeChanges:N=>{const{onEdgesChange:w,setEdges:T,edges:k,hasDefaultEdges:I,debug:L}=y();if(N!=null&&N.length){if(I){const z=r6(N,k);T(z)}L&&console.log("React Flow: trigger edge changes",N),w==null||w(N)}},addSelectedNodes:N=>{const{multiSelectionActive:w,edgeLookup:T,nodeLookup:k,triggerNodeChanges:I,triggerEdgeChanges:L}=y();if(w){const z=N.map(U=>va(U,!0));I(z);return}I(xo(k,new Set([...N]),!0)),L(xo(T))},addSelectedEdges:N=>{const{multiSelectionActive:w,edgeLookup:T,nodeLookup:k,triggerNodeChanges:I,triggerEdgeChanges:L}=y();if(w){const z=N.map(U=>va(U,!0));L(z);return}L(xo(T,new Set([...N]))),I(xo(k,new Set,!0))},unselectNodesAndEdges:({nodes:N,edges:w}={})=>{const{edges:T,nodes:k,nodeLookup:I,triggerNodeChanges:L,triggerEdgeChanges:z}=y(),U=N||k,V=w||T,$=[];for(const D of U){if(!D.selected)continue;const B=I.get(D.id);B&&(B.selected=!1),$.push(va(D.id,!1))}const P=[];for(const D of V)D.selected&&P.push(va(D.id,!1));L($),z(P)},setMinZoom:N=>{const{panZoom:w,maxZoom:T}=y();w==null||w.setScaleExtent([N,T]),x({minZoom:N})},setMaxZoom:N=>{const{panZoom:w,minZoom:T}=y();w==null||w.setScaleExtent([T,N]),x({maxZoom:N})},setTranslateExtent:N=>{var w;(w=y().panZoom)==null||w.setTranslateExtent(N),x({translateExtent:N})},resetSelectedElements:()=>{const{edges:N,nodes:w,triggerNodeChanges:T,triggerEdgeChanges:k,elementsSelectable:I}=y();if(!I)return;const L=w.reduce((U,V)=>V.selected?[...U,va(V.id,!1)]:U,[]),z=N.reduce((U,V)=>V.selected?[...U,va(V.id,!1)]:U,[]);T(L),k(z)},setNodeExtent:N=>{const{nodes:w,nodeLookup:T,parentLookup:k,nodeOrigin:I,elevateNodesOnSelect:L,nodeExtent:z,zIndexMode:U}=y();N[0][0]===z[0][0]&&N[0][1]===z[0][1]&&N[1][0]===z[1][0]&&N[1][1]===z[1][1]||(gm(w,T,k,{nodeOrigin:I,nodeExtent:N,elevateNodesOnSelect:L,checkEquality:!1,zIndexMode:U}),x({nodeExtent:N}))},panBy:N=>{const{transform:w,width:T,height:k,panZoom:I,translateExtent:L}=y();return nF({delta:N,panZoom:I,transform:w,translateExtent:L,width:T,height:k})},setCenter:async(N,w,T)=>{const{width:k,height:I,maxZoom:L,panZoom:z}=y();if(!z)return!1;const U=typeof(T==null?void 0:T.zoom)<"u"?T.zoom:L;return await z.setViewport({x:k/2-N*U,y:I/2-w*U,zoom:U},{duration:T==null?void 0:T.duration,ease:T==null?void 0:T.ease,interpolate:T==null?void 0:T.interpolate}),!0},cancelConnection:()=>{x({connection:{...Bj}})},updateConnection:N=>{x({connection:N})},reset:()=>x({...Wb()})}},Object.is);function SB({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:o,initialMinZoom:c,initialMaxZoom:u,initialFitViewOptions:h,fitView:d,nodeOrigin:p,nodeExtent:m,zIndexMode:g,children:x}){const[y]=b.useState(()=>jB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:d,minZoom:c,maxZoom:u,fitViewOptions:h,nodeOrigin:p,nodeExtent:m,zIndexMode:g}));return s.jsx(PF,{value:y,children:s.jsx(c6,{children:s.jsx(j6,{children:x})})})}function _B({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:o,height:c,fitView:u,fitViewOptions:h,minZoom:d,maxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:x}){return b.useContext(Bd)?s.jsx(s.Fragment,{children:e}):s.jsx(SB,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:o,initialHeight:c,fitView:u,initialFitViewOptions:h,initialMinZoom:d,initialMaxZoom:p,nodeOrigin:m,nodeExtent:g,zIndexMode:x,children:e})}const EB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function CB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o,edgeTypes:c,onNodeClick:u,onEdgeClick:h,onInit:d,onMove:p,onMoveStart:m,onMoveEnd:g,onConnect:x,onConnectStart:y,onConnectEnd:E,onClickConnectStart:N,onClickConnectEnd:w,onNodeMouseEnter:T,onNodeMouseMove:k,onNodeMouseLeave:I,onNodeContextMenu:L,onNodeDoubleClick:z,onNodeDragStart:U,onNodeDrag:V,onNodeDragStop:$,onNodesDelete:P,onEdgesDelete:D,onDelete:B,onSelectionChange:_,onSelectionDragStart:C,onSelectionDrag:R,onSelectionDragStop:M,onSelectionContextMenu:F,onSelectionStart:H,onSelectionEnd:W,onBeforeDelete:K,connectionMode:q,connectionLineType:Y=Di.Bezier,connectionLineStyle:fe,connectionLineComponent:me,connectionLineContainerStyle:xe,deleteKeyCode:oe="Backspace",selectionKeyCode:re="Shift",selectionOnDrag:ie=!1,selectionMode:ye=rc.Full,panActivationKeyCode:De="Space",multiSelectionKeyCode:de=ac()?"Meta":"Control",zoomActivationKeyCode:Se=ac()?"Meta":"Control",snapToGrid:ae,snapGrid:pe,onlyRenderVisibleElements:Le=!1,selectNodesOnDrag:Te,nodesDraggable:Ge,autoPanOnNodeFocus:Ae,nodesConnectable:tt,nodesFocusable:et,nodeOrigin:jt=yS,edgesFocusable:zn,edgesReconnectable:sn,elementsSelectable:ln=!0,defaultViewport:cn=YF,minZoom:rn=.5,maxZoom:an=2,translateExtent:Ft=sc,preventScrolling:Un=!0,nodeExtent:Nn,defaultMarkerColor:js="#b1b1b7",zoomOnScroll:Ir=!0,zoomOnPinch:er=!0,panOnScroll:tr=!1,panOnScrollSpeed:Ps=.5,panOnScrollMode:Ls=Ca.Free,zoomOnDoubleClick:Ds=!0,panOnDrag:Fs=!0,onPaneClick:nr,onPaneMouseEnter:sr,onPaneMouseMove:as,onPaneMouseLeave:Xn,onPaneScroll:wn,onPaneContextMenu:J,paneClickDistance:ge=1,nodeClickDistance:ze=0,children:st,onReconnect:It,onReconnectStart:$t,onReconnectEnd:Be,onEdgeContextMenu:Fe,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Hn,reconnectRadius:os=10,onNodesChange:rr,onEdgesChange:mi,noDragClassName:ir="nodrag",noWheelClassName:gi="nowheel",noPanClassName:Zn="nopan",fitView:Wr,fitViewOptions:ls,connectOnClick:Tr,attributionPosition:xi,proOptions:Rt,defaultEdgeOptions:Ss,elevateNodesOnSelect:Qn=!0,elevateEdgesOnSelect:Vr=!1,disableKeyboardA11y:ar=!1,autoPanOnConnect:Ot,autoPanOnNodeDrag:vi,autoPanOnSelection:qr=!0,autoPanSpeed:or,connectionRadius:$r,isValidConnection:Ie,onError:Ze,style:ct,id:ht,nodeDragThreshold:Tt,connectionDragThreshold:zt,viewport:Wn,onViewportChange:Bs,width:un,height:jn,colorMode:Us="light",debug:Hs,onScroll:cs,ariaLabelConfig:ta,zIndexMode:yi="basic",...Mr},bi){const Jn=ht||"1",us=e6(Us),Sn=b.useCallback(Zs=>{Zs.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),cs==null||cs(Zs)},[cs]);return s.jsx("div",{"data-testid":"rf__wrapper",...Mr,onScroll:Sn,style:{...ct,...EB},ref:bi,className:kn(["react-flow",i,us]),id:ht,role:"application",children:s.jsxs(_B,{nodes:e,edges:t,width:un,height:jn,fitView:Wr,fitViewOptions:ls,minZoom:rn,maxZoom:an,nodeOrigin:jt,nodeExtent:Nn,zIndexMode:yi,children:[s.jsx(JF,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:x,onConnectStart:y,onConnectEnd:E,onClickConnectStart:N,onClickConnectEnd:w,nodesDraggable:Ge,autoPanOnNodeFocus:Ae,nodesConnectable:tt,nodesFocusable:et,edgesFocusable:zn,edgesReconnectable:sn,elementsSelectable:ln,elevateNodesOnSelect:Qn,elevateEdgesOnSelect:Vr,minZoom:rn,maxZoom:an,nodeExtent:Nn,onNodesChange:rr,onEdgesChange:mi,snapToGrid:ae,snapGrid:pe,connectionMode:q,translateExtent:Ft,connectOnClick:Tr,defaultEdgeOptions:Ss,fitView:Wr,fitViewOptions:ls,onNodesDelete:P,onEdgesDelete:D,onDelete:B,onNodeDragStart:U,onNodeDrag:V,onNodeDragStop:$,onSelectionDrag:R,onSelectionDragStart:C,onSelectionDragStop:M,onMove:p,onMoveStart:m,onMoveEnd:g,noPanClassName:Zn,nodeOrigin:jt,rfId:Jn,autoPanOnConnect:Ot,autoPanOnNodeDrag:vi,autoPanSpeed:or,onError:Ze,connectionRadius:$r,isValidConnection:Ie,selectNodesOnDrag:Te,nodeDragThreshold:Tt,connectionDragThreshold:zt,onBeforeDelete:K,debug:Hs,ariaLabelConfig:ta,zIndexMode:yi}),s.jsx(NB,{onInit:d,onNodeClick:u,onEdgeClick:h,onNodeMouseEnter:T,onNodeMouseMove:k,onNodeMouseLeave:I,onNodeContextMenu:L,onNodeDoubleClick:z,nodeTypes:o,edgeTypes:c,connectionLineType:Y,connectionLineStyle:fe,connectionLineComponent:me,connectionLineContainerStyle:xe,selectionKeyCode:re,selectionOnDrag:ie,selectionMode:ye,deleteKeyCode:oe,multiSelectionKeyCode:de,panActivationKeyCode:De,zoomActivationKeyCode:Se,onlyRenderVisibleElements:Le,defaultViewport:cn,translateExtent:Ft,minZoom:rn,maxZoom:an,preventScrolling:Un,zoomOnScroll:Ir,zoomOnPinch:er,zoomOnDoubleClick:Ds,panOnScroll:tr,panOnScrollSpeed:Ps,panOnScrollMode:Ls,panOnDrag:Fs,autoPanOnSelection:qr,onPaneClick:nr,onPaneMouseEnter:sr,onPaneMouseMove:as,onPaneMouseLeave:Xn,onPaneScroll:wn,onPaneContextMenu:J,paneClickDistance:ge,nodeClickDistance:ze,onSelectionContextMenu:F,onSelectionStart:H,onSelectionEnd:W,onReconnect:It,onReconnectStart:$t,onReconnectEnd:Be,onEdgeContextMenu:Fe,onEdgeDoubleClick:Xe,onEdgeMouseEnter:bt,onEdgeMouseMove:yt,onEdgeMouseLeave:Hn,reconnectRadius:os,defaultMarkerColor:js,noDragClassName:ir,noWheelClassName:gi,noPanClassName:Zn,rfId:Jn,disableKeyboardA11y:ar,nodeExtent:Nn,viewport:Wn,onViewportChange:Bs,nodesDraggable:Ge}),s.jsx(KF,{onSelectionChange:_}),st,s.jsx(ZF,{proOptions:Rt,position:xi}),s.jsx(HF,{rfId:Jn,disableKeyboardA11y:ar})]})})}var AB=kS(CB);function IB({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:kn(["react-flow__background-pattern",n,r])})}function TB({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:kn(["react-flow__background-pattern","dots",t])})}var Ki;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ki||(Ki={}));const $B={[Ki.Dots]:1,[Ki.Lines]:1,[Ki.Cross]:6},MB=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function qS({id:e,variant:t=Ki.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=0,color:c,bgColor:u,style:h,className:d,patternClassName:p}){const m=b.useRef(null),{transform:g,patternId:x}=wt(MB,tn),y=r||$B[t],E=t===Ki.Dots,N=t===Ki.Cross,w=Array.isArray(n)?n:[n,n],T=[w[0]*g[2]||1,w[1]*g[2]||1],k=y*g[2],I=Array.isArray(o)?o:[o,o],L=N?[k,k]:T,z=[I[0]*g[2]+L[0]/2,I[1]*g[2]+L[1]/2],U=`${x}${e||""}`;return s.jsxs("svg",{className:kn(["react-flow__background",d]),style:{...h,...Hd,"--xy-background-color-props":u,"--xy-background-pattern-color-props":c},ref:m,"data-testid":"rf__background",children:[s.jsx("pattern",{id:U,x:g[0]%T[0],y:g[1]%T[1],width:T[0],height:T[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${z[0]},-${z[1]})`,children:E?s.jsx(TB,{radius:k/2,className:p}):s.jsx(IB,{dimensions:L,lineWidth:i,variant:t,className:p})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${U})`})]})}qS.displayName="Background";const RB=b.memo(qS);function OB(){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 zB(){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 PB(){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 LB(){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 DB(){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 Lu({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:kn(["react-flow__controls-button",t]),...n,children:e})}const FB=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function GS({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:c,onFitView:u,onInteractiveChange:h,className:d,children:p,position:m="bottom-left",orientation:g="vertical","aria-label":x}){const y=Vt(),{isInteractive:E,minZoomReached:N,maxZoomReached:w,ariaLabelConfig:T}=wt(FB,tn),{zoomIn:k,zoomOut:I,fitView:L}=Sg(),z=()=>{k(),o==null||o()},U=()=>{I(),c==null||c()},V=()=>{L(i),u==null||u()},$=()=>{y.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),h==null||h(!E)},P=g==="horizontal"?"horizontal":"vertical";return s.jsxs(Ud,{className:kn(["react-flow__controls",P,d]),position:m,style:e,"data-testid":"rf__controls","aria-label":x??T["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(Lu,{onClick:z,className:"react-flow__controls-zoomin",title:T["controls.zoomIn.ariaLabel"],"aria-label":T["controls.zoomIn.ariaLabel"],disabled:w,children:s.jsx(OB,{})}),s.jsx(Lu,{onClick:U,className:"react-flow__controls-zoomout",title:T["controls.zoomOut.ariaLabel"],"aria-label":T["controls.zoomOut.ariaLabel"],disabled:N,children:s.jsx(zB,{})})]}),n&&s.jsx(Lu,{className:"react-flow__controls-fitview",onClick:V,title:T["controls.fitView.ariaLabel"],"aria-label":T["controls.fitView.ariaLabel"],children:s.jsx(PB,{})}),r&&s.jsx(Lu,{className:"react-flow__controls-interactive",onClick:$,title:T["controls.interactive.ariaLabel"],"aria-label":T["controls.interactive.ariaLabel"],children:E?s.jsx(DB,{}):s.jsx(LB,{})}),p]})}GS.displayName="Controls";const BB=b.memo(GS);function UB({id:e,x:t,y:n,width:r,height:i,style:o,color:c,strokeColor:u,strokeWidth:h,className:d,borderRadius:p,shapeRendering:m,selected:g,onClick:x}){const{background:y,backgroundColor:E}=o||{},N=c||y||E;return s.jsx("rect",{className:kn(["react-flow__minimap-node",{selected:g},d]),x:t,y:n,rx:p,ry:p,width:r,height:i,style:{fill:N,stroke:u,strokeWidth:h},shapeRendering:m,onClick:x?w=>x(w,e):void 0})}const HB=b.memo(UB),ZB=e=>e.nodes.map(t=>t.id),pp=e=>e instanceof Function?e:()=>e;function WB({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=HB,onClick:c}){const u=wt(ZB,tn),h=pp(t),d=pp(e),p=pp(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:u.map(g=>s.jsx(qB,{id:g,nodeColorFunc:h,nodeStrokeColorFunc:d,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:c,shapeRendering:m},g))})}function VB({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:o,shapeRendering:c,NodeComponent:u,onClick:h}){const{node:d,x:p,y:m,width:g,height:x}=wt(y=>{const E=y.nodeLookup.get(e);if(!E)return{node:void 0,x:0,y:0,width:0,height:0};const N=E.internals.userNode,{x:w,y:T}=E.internals.positionAbsolute,{width:k,height:I}=Ar(N);return{node:N,x:w,y:T,width:k,height:I}},tn);return!d||d.hidden||!Gj(d)?null:s.jsx(u,{x:p,y:m,width:g,height:x,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:i,strokeColor:n(d),strokeWidth:o,shapeRendering:c,onClick:h,id:d.id})}const qB=b.memo(VB);var GB=b.memo(WB);const KB=200,YB=150,XB=e=>!e.hidden,QB=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Wj(kc(e.nodeLookup,{filter:XB}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Vb=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,JB=(e,t)=>Vb(e.viewBB,t.viewBB)&&Vb(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,eU="react-flow__minimap-desc";function KS({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:c,nodeComponent:u,bgColor:h,maskColor:d,maskStrokeColor:p,maskStrokeWidth:m,position:g="bottom-right",onClick:x,onNodeClick:y,pannable:E=!1,zoomable:N=!1,ariaLabel:w,inversePan:T,zoomStep:k=1,offsetScale:I=5}){const L=Vt(),z=b.useRef(null),{boundingRect:U,panZoom:V,viewBB:$,rfId:P,translateExtent:D,flowWidth:B,flowHeight:_,ariaLabelConfig:C}=wt(QB,JB),R=(e==null?void 0:e.width)??KB,M=(e==null?void 0:e.height)??YB,F=U.width/R,H=U.height/M,W=Math.max(F,H),K=W*R,q=W*M,Y=I*W,fe=U.x-(K-U.width)/2-Y,me=U.y-(q-U.height)/2-Y,xe=K+Y*2,oe=q+Y*2,re=`${eU}-${P}`,ie=b.useRef(0),ye=b.useRef();ie.current=W,b.useEffect(()=>{const pe=L.getState().panZoom;if(z.current&&pe)return ye.current=dF({domNode:z.current,panZoom:pe,getTransform:()=>L.getState().transform,getViewScale:()=>ie.current}),()=>{var Le;(Le=ye.current)==null||Le.destroy()}},[V]),b.useEffect(()=>{var pe;(pe=ye.current)==null||pe.update({translateExtent:D,width:B,height:_,inversePan:T,pannable:E,zoomStep:k,zoomable:N})},[E,N,T,k,D,B,_]);const De=x?pe=>{var Ge;const[Le,Te]=((Ge=ye.current)==null?void 0:Ge.pointer(pe))||[0,0];x(pe,{x:Le,y:Te})}:void 0,de=b.useCallback((pe,Le)=>{const Te=L.getState().nodeLookup.get(Le).internals.userNode;y==null||y(pe,Te)},[y]),Se=y?de:void 0,ae=w??C["minimap.ariaLabel"];return s.jsx(Ud,{position:g,style:{...e,"--xy-minimap-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*W:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof c=="number"?c:void 0},className:kn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:R,height:M,viewBox:`${fe} ${me} ${xe} ${oe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":re,ref:z,onClick:De,children:[ae&&s.jsx("title",{id:re,children:ae}),s.jsx(GB,{onClick:Se,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:c,nodeComponent:u}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${fe-Y},${me-Y}h${xe+Y*2}v${oe+Y*2}h${-xe-Y*2}z
226
+ M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}KS.displayName="MiniMap";b.memo(KS);const tU=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,nU={[Bo.Line]:"right",[Bo.Handle]:"bottom-right"};function sU({nodeId:e,position:t,variant:n=Bo.Handle,className:r,style:i=void 0,children:o,color:c,minWidth:u=10,minHeight:h=10,maxWidth:d=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:g,autoScale:x=!0,shouldResize:y,onResizeStart:E,onResize:N,onResizeEnd:w}){const T=_S(),k=typeof e=="string"?e:T,I=Vt(),L=b.useRef(null),z=n===Bo.Handle,U=wt(b.useCallback(tU(z&&x),[z,x]),tn),V=b.useRef(null),$=t??nU[n];b.useEffect(()=>{if(!(!L.current||!k))return V.current||(V.current=jF({domNode:L.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:D,transform:B,snapGrid:_,snapToGrid:C,nodeOrigin:R,domNode:M}=I.getState();return{nodeLookup:D,transform:B,snapGrid:_,snapToGrid:C,nodeOrigin:R,paneDomNode:M}},onChange:(D,B)=>{const{triggerNodeChanges:_,nodeLookup:C,parentLookup:R,nodeOrigin:M}=I.getState(),F=[],H={x:D.x,y:D.y},W=C.get(k);if(W&&W.expandParent&&W.parentId){const K=W.origin??M,q=D.width??W.measured.width??0,Y=D.height??W.measured.height??0,fe={id:W.id,parentId:W.parentId,rect:{width:q,height:Y,...Kj({x:D.x??W.position.x,y:D.y??W.position.y},{width:q,height:Y},W.parentId,C,K)}},me=jg([fe],C,R,M);F.push(...me),H.x=D.x?Math.max(K[0]*q,D.x):void 0,H.y=D.y?Math.max(K[1]*Y,D.y):void 0}if(H.x!==void 0&&H.y!==void 0){const K={id:k,type:"position",position:{...H}};F.push(K)}if(D.width!==void 0&&D.height!==void 0){const q={id:k,type:"dimensions",resizing:!0,setAttributes:g?g==="horizontal"?"width":"height":!0,dimensions:{width:D.width,height:D.height}};F.push(q)}for(const K of B){const q={...K,type:"position"};F.push(q)}_(F)},onEnd:({width:D,height:B})=>{const _={id:k,type:"dimensions",resizing:!1,dimensions:{width:D,height:B}};I.getState().triggerNodeChanges([_])}})),V.current.update({controlPosition:$,boundaries:{minWidth:u,minHeight:h,maxWidth:d,maxHeight:p},keepAspectRatio:m,resizeDirection:g,onResizeStart:E,onResize:N,onResizeEnd:w,shouldResize:y}),()=>{var D;(D=V.current)==null||D.destroy()}},[$,u,h,d,p,m,E,N,w,y]);const P=$.split("-");return s.jsx("div",{className:kn(["react-flow__resize-control","nodrag",...P,n,r]),ref:L,style:{...i,scale:U,...c&&{[z?"backgroundColor":"borderColor"]:c}},children:o})}b.memo(sU);function rU(e,t=0){const n=je(e.connection.status),[r,i]=b.useState([]);return b.useEffect(()=>{if(n.state!=="open")return;let o=!0;return(async()=>{const{scripts:c}=await e.connection.call("scripts/list",{}),u=[];for(const h of c){if(h.packId===void 0)continue;const d=await e.connection.call("runs/tasks",{scriptId:h.id}).catch(()=>{});if(d===void 0||d.tasks.length===0)continue;const p=await e.connection.call("configs/profiles",{scriptId:h.id}).catch(()=>{});u.push({scriptId:h.id,scriptName:h.name,tasks:d.tasks,profiles:p})}o&&i(u)})().catch(()=>{}),()=>{o=!1}},[e,n.state,t]),b.useEffect(()=>e.connection.on("configs/profiles/changed",o=>{i(c=>c.map(u=>u.scriptId===o.scriptId?{...u,profiles:o.list}:u))}),[e]),r}const YS=[0,1,2,3,4,5].map(e=>({value:String(e),label:e===0?"不重试":`重试 ${e} 次`})),XS=[{value:"continue",label:"然后继续其他分支"},{value:"stop",label:"然后停止流水线"}],Uo={"script-task":"脚本任务",agent:"agent 步骤",wait:"控制节点",notify:"发消息",gate:"人工确认",start:"开始",end:"结束"},ym={pending:"待运行",waiting:"等待中",running:"运行中",succeeded:"成功",failed:"失败",skipped:"跳过",cancelled:"取消"},iU={success:"成功后",failure:"失败后",always:"结束后"},mp={desktop:"鼠标键盘",adb:"模拟器",window:"后台窗口",none:""};function aU({data:e,selected:t}){var r,i,o,c;const n=(r=e.state)==null?void 0:r.state;return Gi(e.node)?s.jsxs("div",{className:`step-node marker ${e.node.kind} ${n??""} ${t?"selected":""}`,children:[e.node.kind==="end"&&s.jsx(Wi,{type:"target",position:Je.Left}),s.jsx("span",{children:Uo[e.node.kind]}),e.node.kind==="end"&&n!==void 0&&n!=="pending"&&s.jsx("span",{className:`step-state ${n}`,children:((i=e.state)==null?void 0:i.detail)??ym[n]}),e.node.kind==="start"&&s.jsx(Wi,{type:"source",position:Je.Right})]}):s.jsxs("div",{className:`step-node ${n??""} ${t?"selected":""} ${e.issue!==void 0?"has-issue":""}`,children:[s.jsx(Wi,{type:"target",position:Je.Left}),s.jsxs("div",{className:"step-kind",children:[s.jsx("span",{children:Uo[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:[ym[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(Wi,{type:"source",position:Je.Right})]})}const oU={step:aU};function lU(e){const t=new Map,n=(o,c)=>{if(t.has(o))return t.get(o);if(c.has(o))return 0;c.add(o);const u=e.edges.filter(d=>d.to===o).map(d=>n(d.from,c)+1),h=Math.max(0,...u);return t.set(o,h),h};for(const o of e.nodes)n(o.id,new Set);const r=new Map,i=new Map;for(const o of e.nodes){if(o.position!==void 0){i.set(o.id,o.position);continue}const c=t.get(o.id)??0,u=r.get(c)??0;r.set(c,u+1),i.set(o.id,{x:40+c*280,y:40+u*130})}return i}let cU=0;const $l=(e,t)=>{for(;;){const n=`${e}${++cU}`;if(!t.nodes.some(r=>r.id===n))return n}};function uU({client:e,pipeline:t,onChange:n,run:r,check:i,runFrom:o,idle:c}){var D,B;const u=WN(),[h,d]=b.useState(0),p=rU(e,h),[m,g]=b.useState(null),[x,y]=b.useState(null),[E,N]=b.useState({}),w=b.useCallback(_=>{var C,R;if(_.kind==="script-task"){const M=p.find(K=>K.scriptId===_.scriptId),F=M==null?void 0:M.tasks.find(K=>K.id===_.taskId),H=Object.entries(_.params).map(([K,q])=>`${K}=${String(q)}`).join(" "),W=_.profile===void 0?void 0:((R=(C=M==null?void 0:M.profiles)==null?void 0:C.items.find(K=>K.id===_.profile))==null?void 0:R.name)??"已删除的配置";return{label:_.title??`${(M==null?void 0:M.scriptName)??_.scriptId} · ${(F==null?void 0:F.title)??_.taskId}`,sub:[W===void 0?"":`配置:${W}`,H].filter(Boolean).join(" · "),input:mp[(F==null?void 0:F.input)??"none"]??""}}return _.kind==="wait"?{label:_.title??(_.minutes!==void 0?`等 ${_.minutes} 分钟`:`等到 ${_.until}`),sub:"",input:""}:_.kind==="agent"?{label:_.title??"agent 步骤",sub:_.prompt.slice(0,40),input:""}:Gi(_)?{label:Uo[_.kind],sub:"",input:""}:{label:_.title??Uo[_.kind],sub:_.text.slice(0,40),input:""}},[p]),T=b.useMemo(()=>lU(t),[t]),k=b.useMemo(()=>t.nodes.map(_=>{var C;return{id:_.id,type:"step",position:T.get(_.id),selected:_.id===m,...E[_.id]===void 0?{}:{measured:E[_.id]},data:{node:_,...w(_),state:r==null?void 0:r.nodes[_.id],issue:(C=i==null?void 0:i.issues.find(R=>R.nodeId===_.id&&R.level==="error"))==null?void 0:C.message}}}),[t,T,w,r,i,m,E]),I=b.useMemo(()=>t.edges.map((_,C)=>{var R;return{id:`e${C}`,source:_.from,target:_.to,label:iU[_.when],selected:C===x,animated:((R=r==null?void 0:r.nodes[_.from])==null?void 0:R.state)==="running",className:`edge-${_.when}`}}),[t.edges,x,r]),L=b.useCallback(_=>{let C=t;const R={};for(const M of _)if(M.type==="dimensions"&&M.dimensions!==void 0)R[M.id]=M.dimensions;else if(M.type==="position"&&M.position!==void 0)C={...C,nodes:C.nodes.map(F=>F.id===M.id?{...F,position:{x:Math.round(M.position.x),y:Math.round(M.position.y)}}:F)};else if(M.type==="remove"){if(C.nodes.some(F=>F.id===M.id&&Gi(F)))continue;C={...C,nodes:C.nodes.filter(F=>F.id!==M.id),edges:C.edges.filter(F=>F.from!==M.id&&F.to!==M.id)},g(null)}Object.keys(R).length>0&&N(M=>({...M,...R})),C!==t&&n(C)},[t,n]),z=b.useCallback(_=>{var R;if(_.source===_.target||t.edges.some(M=>M.from===_.source&&M.to===_.target))return;const C=t.nodes.find(M=>M.id===_.target);(C==null?void 0:C.kind)==="start"||((R=t.nodes.find(M=>M.id===_.source))==null?void 0:R.kind)==="end"||n({...t,edges:[...t.edges,{from:_.source,to:_.target,when:(C==null?void 0:C.kind)==="end"?"always":"success"}]})},[t,n]),U=_=>{const C=t.nodes.find(Y=>Y.kind==="start"),R=t.nodes.find(Y=>Y.kind==="end"),M=t.nodes.find(Y=>Y.id===m&&Y.kind!=="end")??C,F=M===void 0?void 0:T.get(M.id),H=[...T.entries()].filter(([Y])=>Y!==(R==null?void 0:R.id)).map(([,Y])=>Y),W=F===void 0?Math.max(0,...H.map(Y=>Y.x))+280:F.x+280;let K=(F==null?void 0:F.y)??40;for(;H.some(Y=>Math.abs(Y.x-W)<200&&Math.abs(Y.y-K)<100);)K+=130;const q=[...t.nodes.map(Y=>{var fe,me;return Y.kind==="end"?{...Y,position:{x:Math.max(((fe=T.get(Y.id))==null?void 0:fe.x)??0,W+300),y:((me=T.get(Y.id))==null?void 0:me.y)??K}}:Y}),{..._,position:{x:W,y:K}}];n({...t,nodes:q}),g(_.id),y(null)},V=t.nodes.find(_=>_.id===m),$=x===null?void 0:t.edges[x],P=_=>n({...t,nodes:t.nodes.map(C=>C.id===_.id?_:C)});return s.jsxs("div",{className:"pipeline-editor",children:[s.jsxs("div",{className:"pipeline-palette","aria-label":"节点",children:[s.jsx("div",{className:"sidebar-label",children:"脚本任务"}),p.length===0&&s.jsx("div",{className:"muted small pad",children:"脚本库里还没有带脚本包的脚本"}),p.map(_=>s.jsxs("details",{className:"palette-group",open:p.length<=3,children:[s.jsx("summary",{children:_.scriptName}),_.tasks.map(C=>s.jsxs("button",{className:"palette-item",title:C.description??C.title,onClick:()=>U({id:$l(_.scriptId.replace(/[^A-Za-z0-9_-]/g,"").slice(0,20)||"task",t),kind:"script-task",scriptId:_.scriptId,taskId:C.id,params:{}}),children:[s.jsx("span",{children:C.title}),mp[C.input]!==""&&s.jsx("span",{className:"badge",children:mp[C.input]})]},C.id))]},_.scriptId)),s.jsx("div",{className:"sidebar-label pack-label",children:"其他步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>U({id:$l("agent",t),kind:"agent",prompt:"检查活动还剩几天,快结束的提醒我"}),children:"agent 步骤"}),s.jsx("button",{className:"palette-item",onClick:()=>U({id:$l("wait",t),kind:"wait",minutes:10}),children:"控制节点"}),s.jsx("button",{className:"palette-item",onClick:()=>U({id:$l("notify",t),kind:"notify",text:`${t.name}跑完了`}),children:"发消息"}),s.jsx("button",{className:"palette-item",onClick:()=>U({id:$l("gate",t),kind:"gate",text:"确认后继续"}),children:"人工确认"}),s.jsx("p",{className:"muted small pad",children:"从节点右边的圆点拖到另一个节点左边,表示「这个完成后再运行那个」。没有连线的节点会同时开始;需要同一资源的会自动排队。"})]}),s.jsxs("div",{className:"pipeline-canvas",children:[s.jsxs(AB,{nodes:k,edges:I,nodeTypes:oU,onNodesChange:L,onConnect:z,onNodeClick:(_,C)=>{g(C.id),y(null)},onEdgeClick:(_,C)=>{y(Number(C.id.slice(1))),g(null)},onPaneClick:()=>{g(null),y(null)},deleteKeyCode:["Delete","Backspace"],colorMode:u,fitView:!0,fitViewOptions:{maxZoom:1,padding:.2},proOptions:{hideAttribution:!0},children:[s.jsx(RB,{gap:20}),s.jsx(BB,{showInteractive:!1})]}),!t.nodes.some(_=>!Gi(_))&&s.jsx("div",{className:"canvas-hint",children:"从左边点一个任务加到画布上,再从节点右边的圆点拖到下一个节点,连成先后顺序"})]}),s.jsxs("aside",{className:"pipeline-inspector",children:[V!==void 0&&s.jsx(hU,{client:e,node:V,pipeline:t,run:r,scripts:p,onChange:P,onTasksChanged:()=>d(_=>_+1),runFrom:o,onRemove:()=>{n({...t,nodes:t.nodes.filter(_=>_.id!==V.id),edges:t.edges.filter(_=>_.from!==V.id&&_.to!==V.id)}),g(null)}}),$!==void 0&&s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:"连线"}),s.jsxs("p",{className:"muted small",children:["「",((D=t.nodes.find(_=>_.id===$.from))==null?void 0:D.title)??$.from,"」→「",((B=t.nodes.find(_=>_.id===$.to))==null?void 0:B.title)??$.to,"」"]}),s.jsx("label",{className:"field-label",htmlFor:"edge-when",children:"什么时候运行下一步"}),s.jsx(yn,{id:"edge-when",value:$.when,onChange:_=>n({...t,edges:t.edges.map((C,R)=>R===x?{...C,when:_}:C)}),options:[{value:"success",label:"上一步成功后"},{value:"failure",label:"上一步失败后"},{value:"always",label:"上一步结束后",hint:"不管成败"}]}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>{n({...t,edges:t.edges.filter((_,C)=>C!==x)}),y(null)},children:"删除连线"})]}),V===void 0&&$===void 0&&(c??s.jsx("p",{className:"muted small pad",children:"点一个节点或连线来修改。选中后按 Delete 也能删除。"})),(V!==void 0||$!==void 0)&&c!==void 0&&s.jsx("button",{className:"link-button small back-to-pipeline",onClick:()=>{g(null),y(null)},children:"← 流水线设置"})]})]})}function dU({client:e,value:t,onChange:n}){const r=b.useRef(null),i=PN({client:e,text:t,setText:n,area:r,placement:"below"});return s.jsxs("div",{className:"slash-anchor",children:[s.jsx("textarea",{id:"node-prompt",ref:r,className:"text-input plain",rows:4,value:t,placeholder:"例如:/game-arknights 看看活动商店还剩什么没换",onChange:o=>n(o.target.value),onKeyDown:o=>{i.onKeyDown(o)}}),i.menu,s.jsx("p",{className:"muted small",children:"输入 / 可以选命令或技能,运行时展开成完整的指令。"})]})}function hU({client:e,node:t,pipeline:n,run:r,scripts:i,onChange:o,onRemove:c,onTasksChanged:u,runFrom:h}){var y,E;const[d,p]=b.useState(null),m=r==null?void 0:r.nodes[t.id],g=t.kind==="script-task"?(y=i.find(N=>N.scriptId===t.scriptId))==null?void 0:y.tasks.find(N=>N.id===t.taskId):void 0,x=t.onFailure;return Gi(t)?s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Uo[t.kind]}),s.jsx("p",{className:"muted small",children:t.kind==="start"?"流水线从这里开始。从它连出去的步骤最先运行(没有连线的步骤也会一开始就运行)。":"所有步骤都结束后到这里,不管成败;连到它的线只是为了看得清楚。"}),(m==null?void 0:m.detail)!==void 0&&s.jsx("div",{className:"muted small",children:m.detail})]}):s.jsxs("section",{className:"inspector-section",children:[s.jsx("h4",{children:Uo[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:N=>{const{title:w,...T}=t;o(N.target.value===""?T:{...T,title:N.target.value})}}),t.kind==="script-task"&&s.jsx(ij,{id:"node-profile",label:"用哪份配置",list:((E=i.find(N=>N.scriptId===t.scriptId))==null?void 0:E.profiles)??null,value:t.profile,onChange:N=>{const{profile:w,...T}=t;o(N===void 0?T:{...T,profile:N})}}),t.kind==="script-task"&&g!==void 0&&Object.entries(g.params).map(([N,w])=>s.jsx(sj,{client:e,scriptId:t.scriptId,taskId:t.taskId,name:N,spec:w,profile:t.profile,value:String(t.params[N]??(w.type==="boolean"?w.default??!1:"")),onCreated:u,onChange:T=>{const{[N]:k,...I}=t.params,L=w.type==="boolean"?T==="true":w.type==="integer"||w.type==="number"?Number(T):T;o({...t,params:T===""?I:{...I,[N]:L}})}},N)),t.kind==="agent"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-prompt",children:"让 agent 做什么"}),s.jsx(dU,{client:e,value:t.prompt,onChange:N=>o({...t,prompt:N})})]}),(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:N=>o({...t,text:N.target.value})})]}),t.kind==="wait"&&s.jsxs("div",{className:"key-input",children:[s.jsx(yn,{"aria-label":"等待方式",value:t.minutes!==void 0?"minutes":"until",options:[{value:"minutes",label:"等几分钟"},{value:"until",label:"等到某个时间"}],onChange:N=>o(N==="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:N=>o({...t,minutes:Math.max(1,Math.min(1440,Math.round(Number(N.target.value)||1)))})}):s.jsx("input",{className:"text-input plain",type:"time",value:t.until,onChange:N=>o({...t,until:N.target.value})})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.waitForAll===!0,onChange:N=>{const{waitForAll:w,...T}=t;o(N.target.checked?{...T,waitForAll:!0}:T)}}),"等前面的节点全部结束再开始"]}),s.jsx("p",{className:"muted small",children:"不只等连进来的线:画布上不在它后面的节点(其他分支也算)都结束了(成功、失败、跳过都算)才开始。用来让并行的几条分支汇合。"}),t.kind!=="gate"&&t.kind!=="notify"&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:"node-retries",children:"失败时"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(yn,{id:"node-retries","aria-label":"重试次数",value:x===void 0?"inherit":String(x.retries),options:[{value:"inherit",label:"按流水线的设置"},...YS],onChange:N=>{const{onFailure:w,...T}=t;if(N==="inherit")return o(T);o({...T,onFailure:{retries:Number(N),then:(x==null?void 0:x.then)??n.onFailure.then}})}}),s.jsx(yn,{"aria-label":"仍失败时",disabled:x===void 0,value:(x??n.onFailure).then,options:XS,onChange:N=>o({...t,onFailure:{retries:(x==null?void 0:x.retries)??n.onFailure.retries,then:N}})})]}),x===void 0&&s.jsxs("p",{className:"muted small",children:["流水线的设置:",n.onFailure.retries>0?`重试 ${n.onFailure.retries} 次,`:"不重试,","然后",n.onFailure.then==="stop"?"停止流水线":"继续其他分支"]})]}),m!==void 0&&s.jsxs("div",{className:"inspector-run",children:[s.jsx("div",{className:"sidebar-label",children:"这次运行"}),s.jsxs("div",{children:[ym[m.state],m.attempts>1?` · 第 ${m.attempts} 次`:""]}),m.detail!==void 0&&s.jsx("div",{className:"muted small",children:m.detail}),m.runIds.length>0&&s.jsxs("div",{className:"muted small",children:["脚本运行:",m.runIds.join("、"),"(在「运行」页看日志)"]}),t.kind==="gate"&&m.state==="running"&&r!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"primary small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:r.id,nodeId:t.id,decision:"continue"}).catch(N=>p(Re(N))),children:"继续"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>void e.connection.call("pipelines/gate",{runId:r.id,nodeId:t.id,decision:"stop"}).catch(N=>p(Re(N))),children:"停止"})]})]}),d!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]}),h!==void 0&&s.jsxs("div",{className:"run-from",children:[s.jsxs("button",{className:"small-button",onClick:()=>h(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 kd={running:["","运行中"],succeeded:["ok","成功"],failed:["warn","有失败"],cancelled:["","已取消"]},fU=()=>({id:`pipeline-${Date.now().toString(36)}`,name:"新流水线",nodes:[{id:"start",kind:"start",position:{x:40,y:120}},{id:"end",kind:"end",position:{x:360,y:120}}],edges:[],onFailure:{retries:0,then:"continue"},schedule:{enabled:!1,times:[],days:[],catchUpMinutes:10},stopEmulatorAfter:!1,closeGameAfter:!1,powerAfter:"none"});function pU({client:e,openSettings:t,arg:n}){const r=je(e.connection.status),i=Cn(3e4),[o,c]=b.useState(null),[u,h]=b.useState(null),[d,p]=b.useState(null),[m,g]=b.useState(""),[x,y]=b.useState([]),[E,N]=b.useState(null),[w,T]=b.useState(null),[k,I]=b.useState(null),[L,z]=b.useState(null),[U,V]=b.useState(0);b.useEffect(()=>e.connection.on("pipelines/changed",()=>V(oe=>oe+1)),[e]);const $=je(e.capabilities),[P,D]=b.useState(null),[B,_]=b.useState(0);b.useEffect(()=>e.connection.on("schedule/changed",()=>_(oe=>oe+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!$.has("schedule"))return;let oe=!0;return e.connection.call("schedule/status",{}).then(re=>{oe&&D(re.settings)}).catch(()=>{}),()=>{oe=!1}},[e,r.state,$,B]);const C=async oe=>{try{D((await e.connection.call("schedule/settings/set",oe)).settings)}catch(re){z(Re(re))}};b.useEffect(()=>{n!==void 0&&h(n)},[n]),b.useEffect(()=>{if(r.state!=="open")return;let oe=!0;return e.connection.call("pipelines/list",{}).then(re=>{oe&&(c(re.items),h(ie=>{var ye;return ie??((ye=re.items[0])==null?void 0:ye.id)??null}))}).catch(re=>{oe&&z(Re(re))}),()=>{oe=!1}},[e,r.state,U]),b.useEffect(()=>{if(u===null||r.state!=="open"||(d==null?void 0:d.id)===u&&(o!=null&&o.every(re=>re.id!==u)))return;let oe=!0;return e.connection.call("pipelines/get",{id:u}).then(re=>{if(!oe)return;const ie=S$(re);p(ie),g(JSON.stringify(ie)),T(null)}).catch(()=>{}),e.connection.call("pipelines/runs",{pipelineId:u,limit:10}).then(re=>{oe&&y(re.items)}).catch(()=>{}),N(null),()=>{oe=!1}},[e,u,r.state,U]),b.useEffect(()=>e.connection.on("pipelines/run",oe=>{oe.pipelineId===u&&y(re=>[oe,...re.filter(ie=>ie.id!==oe.id)].sort((ie,ye)=>ye.startedAt-ie.startedAt).slice(0,10))}),[e,u]);const R=d!==null&&JSON.stringify(d)!==m,M=d!==null&&o!==null&&o.every(oe=>oe.id!==d.id),F=x.find(oe=>{var re;return oe.id===(E??((re=x[0])==null?void 0:re.id))}),H=x.find(oe=>oe.state==="running"),W=H!==void 0&&(H.stopping!==void 0||k==="cancel");b.useEffect(()=>{if(d===null||!d.nodes.some(re=>!Gi(re))){T(null);return}const oe=setTimeout(()=>{e.connection.call("pipelines/check",{pipeline:d}).then(T).catch(()=>{})},400);return()=>clearTimeout(oe)},[e,d]);const K=async(oe,re)=>{I(oe),z(null);try{await re()}catch(ie){z(Re(ie))}finally{I(null)}},q=()=>K("save",async()=>{if(d===null)return;const oe=await e.connection.call("pipelines/save",{pipeline:d});p(oe.pipeline),g(JSON.stringify(oe.pipeline)),T(oe.check),h(oe.pipeline.id)}),Y=oe=>K("run",async()=>{if(d===null)return;(R||M)&&await q();const re=await e.connection.call("pipelines/run",{id:d.id,...oe===void 0?{}:{from:oe}});N(re.id)}),fe=()=>K("remove",async()=>{d!==null&&(M||await e.connection.call("pipelines/remove",{id:d.id}),p(null),h(null))}),me=b.useCallback(oe=>p(oe),[]),xe=()=>{const oe=fU();p(oe),g(""),h(oe.id),y([]),T(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(xU,{list:o??[],current:d,isNew:M,now:i,onPick:h}),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:xe,children:[s.jsx(Q,{name:"plus"}),"新建流水线"]})]})]}),s.jsx("div",{className:"pipeline-main",children:d===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:d.name,maxLength:60,"aria-label":"流水线名称",onChange:oe=>p({...d,name:oe.target.value})}),d.draft===!0&&s.jsx("span",{className:"badge warn",title:"agent 生成的草稿:保存后才会按定时运行",children:"agent 草稿"}),R&&s.jsx("span",{className:"muted small",children:"未保存"}),s.jsx("span",{className:"spacer"}),W?s.jsxs("button",{className:"danger-outline small-button stopping",disabled:!0,"aria-busy":"true",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),"正在停止…"]}):H!==void 0?s.jsx("button",{className:"danger-outline small-button",disabled:k!==null,onClick:()=>void K("cancel",()=>e.connection.call("pipelines/cancel",{runId:H.id})),children:"取消运行"}):s.jsxs("button",{className:"small-button",disabled:k!==null||!d.nodes.some(oe=>!Gi(oe))||(w==null?void 0:w.ok)===!1,onClick:()=>void Y(),children:[s.jsx(Q,{name:"arrow"}),"运行"]}),s.jsx("button",{className:"primary small-button",disabled:k!==null||!R&&!M&&d.draft!==!0,onClick:()=>void q(),children:k==="save"?"保存中…":d.draft===!0&&!R?"确认并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:k!==null||H!==void 0,onClick:()=>{confirm(`删除流水线「${d.name}」?`)&&fe()},children:"删除"})]}),W&&s.jsxs("div",{className:"notice info left small pipeline-stopping",role:"status",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),s.jsxs("span",{children:["已收到停止指令。",H.stopping??"正在通知正在运行的步骤…"]})]}),L!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:L})]}),s.jsx(uU,{client:e,pipeline:d,onChange:me,run:F,check:w,runFrom:H!==void 0||k!==null||(w==null?void 0:w.ok)===!1?void 0:oe=>void Y(oe),idle:s.jsx(vU,{pipeline:d,check:w,runs:x,shownRun:F==null?void 0:F.id,onShowRun:N,others:o??[],onChange:me,now:i,startup:P,onStartup:oe=>void C(oe)})},d.id)]})})]})}function mU({check:e,pipeline:t}){if(e===null)return null;const n=r=>{const i=t.nodes.find(o=>o.id===r);return i===void 0?"":`${i.title??i.id}:`};return s.jsxs("section",{className:"side-pane",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"运行前检查"}),s.jsx("p",{className:"muted small",children:e.estimateMinutes===void 0?"部分任务没有预计时长":`预计约 ${e.estimateMinutes} 分钟`})]}),s.jsx("span",{className:`badge ${e.ok?"ok":"warn"}`,children:e.ok?"可以运行":"有问题"})]}),e.issues.length===0&&s.jsx("div",{className:"muted small",children:"没有发现问题。"}),s.jsx("ul",{className:"incident-steps",children:e.issues.map((r,i)=>s.jsxs("li",{className:r.level==="error"||r.level==="warning"?"failed":"",children:[r.level==="error"?"✗":r.level==="warning"?"!":"ℹ"," ",n(r.nodeId),r.message]},i))})]})}function gU({runs:e,shown:t,onShow:n,now:r}){if(e.length===0)return s.jsx("section",{className:"side-pane",children:s.jsx("p",{className:"muted small",children:"还没有运行过。"})});const i={manual:"手动",schedule:"定时",autostart:"启动时",agent:"agent",after:"接续"};return s.jsxs("section",{className:"side-pane",children:[s.jsx("div",{className:"run-history",children:e.map(o=>s.jsxs("button",{className:`run-row ${o.id===t?"active":""}`,onClick:()=>n(o.id),children:[s.jsx("span",{className:`badge ${kd[o.state][0]}`,children:kd[o.state][1]}),s.jsx("span",{className:"run-title",children:i[o.trigger.kind]??o.trigger.kind}),s.jsx("span",{className:"muted small run-outcome",children:o.outcome??"…"}),s.jsx("span",{className:"session-time",children:At(o.startedAt,r)})]},o.id))}),s.jsx("p",{className:"muted small",children:"选中一次运行,画布上的节点会显示它的状态;点节点看详情和对应的脚本运行。"})]})}function xU({list:e,current:t,isNew:n,now:r,onPick:i}){const[o,c]=b.useState(!1),u=b.useRef(null);return b.useEffect(()=>{if(!o)return;const h=d=>{u.current!==null&&!u.current.contains(d.target)&&c(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[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(h=>!h),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(h=>s.jsxs("button",{role:"option","aria-selected":h.id===(t==null?void 0:t.id),className:`switcher-item ${h.id===(t==null?void 0:t.id)&&!n?"active":""}`,onClick:()=>{i(h.id),c(!1)},children:[s.jsxs("span",{className:"switcher-item-main",children:[s.jsx("span",{children:h.name}),s.jsxs("span",{className:"muted small",children:[h.nodes," 个步骤",h.schedule.enabled&&h.schedule.times.length>0?` · 每天 ${h.schedule.times.join("、")}`:"",h.lastRun===void 0?"":` · ${At(h.lastRun.startedAt,r)}`]})]}),h.draft?s.jsx("span",{className:"badge warn",children:"草稿"}):h.lastRun!==void 0?s.jsx("span",{className:`badge ${kd[h.lastRun.state][0]}`,children:kd[h.lastRun.state][1]}):null]},h.id)),e.length===0&&s.jsx("div",{className:"muted small pad",children:"还没有保存的流水线"})]})]})}function vU({pipeline:e,check:t,runs:n,shownRun:r,onShowRun:i,others:o,onChange:c,now:u,startup:h,onStartup:d}){const[p,m]=b.useState(n.some(x=>x.state==="running")?"runs":"check"),g=(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":p==="check",className:p==="check"?"active":"",onClick:()=>m("check"),children:["检查",g>0?` · ${g}`:""]}),s.jsx("button",{role:"tab","aria-selected":p==="runs",className:p==="runs"?"active":"",onClick:()=>m("runs"),children:"运行记录"}),s.jsx("button",{role:"tab","aria-selected":p==="schedule",className:p==="schedule"?"active":"",onClick:()=>m("schedule"),children:"定时与失败"})]}),p==="check"&&(t===null?s.jsx("p",{className:"muted small pad",children:"加上步骤后会自动检查。"}):s.jsx(mU,{check:t,pipeline:e})),p==="runs"&&s.jsx(gU,{runs:n,shown:r,onShow:i,now:u}),p==="schedule"&&s.jsx(bU,{pipeline:e,others:o,onChange:c,startup:h,onStartup:d}),s.jsx("p",{className:"muted small pad",children:"点画布上的节点或连线来修改它;选中后按 Delete 删除。"})]})}const yU=["日","一","二","三","四","五","六"],qb={sleep:"睡眠",hibernate:"休眠",shutdown:"关机"};function bU({pipeline:e,others:t,onChange:n,startup:r,onStartup:i}){const o=(r==null?void 0:r.autostartPipelines.includes(e.id))===!0,c=e.schedule,[u,h]=b.useState(c.times.join(","));b.useEffect(()=>h(c.times.join(",")),[e.id]);const d=g=>n({...e,schedule:{...c,...g}}),p=b.useMemo(()=>u.split(/[,,\s]+/).map(g=>g.trim()).filter(Boolean).map(g=>/^\d:\d\d$/.test(g)?`0${g}`:g),[u]),m=p.filter(g=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(g));return s.jsxs("section",{className:"side-pane",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,onChange:g=>d({enabled:g.target.checked})}),"按定时自动运行",e.draft===!0?"(草稿要先保存)":""]}),s.jsx("label",{className:"field-label",htmlFor:"pl-times",children:"时间(24 小时制,多个用逗号分开)"}),s.jsx("input",{id:"pl-times",className:"text-input",value:u,placeholder:"04:30,16:30",onChange:g=>h(g.target.value),onBlur:()=>{m.length===0&&d({times:[...new Set(p)].sort()})}}),m.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["时间写成 HH:MM:",m.join("、")]})]}),s.jsxs("div",{className:"chip-row",role:"group","aria-label":"星期",children:[yU.map((g,x)=>s.jsxs("button",{className:`chip ${c.days.includes(x)?"active":""}`,onClick:()=>d({days:c.days.includes(x)?c.days.filter(y=>y!==x):[...c.days,x].sort()}),children:["周",g]},g)),s.jsx("span",{className:"muted small",children:c.days.length===0?"不选=每天":""})]}),r!==null&&s.jsxs("div",{className:"startup-box",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:o,disabled:e.draft===!0,onChange:g=>i({autostartPipelines:g.target.checked?[...r.autostartPipelines,e.id]:r.autostartPipelines.filter(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:r.firstStartOnly,onChange:g=>i({firstStartOnly:g.target.checked})}),"只在每天第一次启动时运行(每天从 4:00 算起)"]}),s.jsxs("label",{className:"check-label sub",children:[s.jsx("input",{type:"checkbox",checked:r.skipIfRanToday,onChange:g=>i({skipIfRanToday:g.target.checked})}),"今天(4:00 起)已经成功运行过就跳过"]}),s.jsxs("p",{className:"muted small",children:["打开桌面版(自己打开或开机自启)后",r.autostart?`开机自启时等 ${r.autostartDelaySeconds} 秒、自己打开时等 10 秒`:"等 10 秒","再运行;dsh 崩溃后自动重启不算。和游戏一样,每天从 4:00 算起:凌晨 2 点启动还算前一天。这两项对所有「软件启动时运行」的流水线生效。"]})]})]}),s.jsx("label",{className:"field-label",htmlFor:"pl-catchup",children:"错过多少分钟以内还补跑(睡眠、刚开机)"}),s.jsx("input",{id:"pl-catchup",className:"text-input plain",type:"number",min:0,max:720,value:c.catchUpMinutes,onChange:g=>d({catchUpMinutes:Math.max(0,Math.min(720,Math.round(Number(g.target.value)||0)))})}),s.jsx("label",{className:"field-label",htmlFor:"pl-after",children:"另一条流水线成功后接着运行"}),s.jsx(yn,{id:"pl-after",value:c.after??"",onChange:g=>{const{after:x,...y}=c;n({...e,schedule:g===""?y:{...y,after:g}})},options:[{value:"",label:"不接续"},...t.filter(g=>g.id!==e.id).map(g=>({value:g.id,label:g.name}))]}),s.jsx("label",{className:"field-label",htmlFor:"pl-fail",children:"节点失败时(节点自己没设置时)"}),s.jsxs("div",{className:"select-stack",children:[s.jsx(yn,{id:"pl-fail","aria-label":"重试次数",value:String(e.onFailure.retries),options:YS,onChange:g=>n({...e,onFailure:{...e.onFailure,retries:Number(g)}})}),s.jsx(yn,{"aria-label":"仍失败时",value:e.onFailure.then,options:XS,onChange:g=>n({...e,onFailure:{...e.onFailure,then:g}})})]}),s.jsx("div",{className:"field-label",children:"结束后"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.closeGameAfter,onChange:g=>n({...e,closeGameAfter:g.target.checked})}),"关闭游戏(任务玩过的电脑游戏和模拟器里的游戏)"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:e.stopEmulatorAfter,onChange:g=>n({...e,stopEmulatorAfter:g.target.checked})}),"关闭模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"pl-power",children:"然后电脑"}),s.jsx(yn,{id:"pl-power",value:e.powerAfter,onChange:g=>n({...e,powerAfter:g}),options:[{value:"none",label:"保持开着"},{value:"sleep",label:"睡眠"},{value:"hibernate",label:"休眠",hint:"断电也不丢失进度,唤醒比睡眠慢"},{value:"shutdown",label:"关机"}]}),e.powerAfter!=="none"&&s.jsxs("p",{className:"muted small",children:["等其他任务都结束后先倒计时",r===null?"":` ${r.powerCountdownSeconds} 秒`,",界面和飞书里都可以取消;15 分钟内还有定时任务就不",qb[e.powerAfter],"。在这里手动点运行、或运行被取消时不会",qb[e.powerAfter],"。",e.powerAfter==="shutdown"?"关机会强制关闭所有程序。":"想让电脑按时醒来跑定时任务,在「设置 → 定时与自启」打开定时唤醒。"]})]})}const Gb=e=>new Date(e).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"}),Kb={fired:["ok","已运行"],missed:["warn","错过"],skipped:["","跳过"],failed:["warn","没能运行"]};function kU({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(0),[u,h]=b.useState(!1),[d,p]=b.useState(null);b.useEffect(()=>e.connection.on("schedule/changed",()=>c(x=>x+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/changed",()=>c(x=>x+1)),[e]),b.useEffect(()=>e.connection.on("schedule/power",x=>i(y=>y===null?y:{...y,power:x})),[e]),b.useEffect(()=>{if(t.state!=="open")return;let x=!0;return e.connection.call("schedule/status",{}).then(y=>{x&&i(y)}).catch(y=>{x&&p(Re(y))}),()=>{x=!1}},[e,t.state,o]);const m=async x=>{h(!0),p(null);try{i(await e.connection.call("schedule/settings/set",x))}catch(y){p(Re(y))}finally{h(!1)}},g=r==null?void 0:r.settings;return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"定时与自启"}),s.jsx("p",{children:"每条流水线的运行时间和结束后做什么(关游戏、关模拟器、睡眠或关机)在「编排」页里设置。这里设置电脑开机登录后是否自动启动 MultiGameAssistant,以及电脑睡着时要不要按时醒来。关掉窗口后程序在托盘里继续运行,定时照常执行。"}),r!==null&&g!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"开机自启"}),s.jsx("p",{className:"muted small",children:r.autostart.detail??(r.autostart.registered?"已在 Windows 任务计划程序中注册(登录后启动,最小化到托盘)":"登录 Windows 后自动启动并最小化到托盘")})]}),s.jsx("span",{className:`badge ${r.autostart.registered?"ok":""}`,children:r.autostart.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:g.autostart,disabled:u||!r.autostart.available,onChange:x=>void m({autostart:x.target.checked})}),"登录 Windows 后自动启动"]}),s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:["软件启动时运行哪些流水线、是否只在每天第一次启动时运行,在「编排」页每条流水线的「定时与失败」里设置。",g.autostartPipelines.length>0?`现在有 ${g.autostartPipelines.length} 条。`:""]})]}),s.jsx("label",{className:"field-label",htmlFor:"autostart-delay",children:"开机自启后等待多少秒再运行流水线(等网络、桌面和显卡驱动就绪)"}),s.jsx("input",{id:"autostart-delay",className:"text-input plain",type:"number",min:0,max:1800,defaultValue:g.autostartDelaySeconds,onBlur:x=>void m({autostartDelaySeconds:Math.max(0,Math.min(1800,Math.round(Number(x.target.value)||0)))})}),r.autostarted&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:"这次是开机自动启动的。"})]})]}),r!==null&&g!==void 0&&s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"定时唤醒"}),s.jsx("p",{className:"muted small",children:r.wake.detail??(r.wake.registered&&r.wake.next!==void 0?`已在 Windows 任务计划程序中注册,下次在 ${Gb(r.wake.next)} 唤醒`:"电脑睡眠(或休眠)时,在定时任务开始前 2 分钟把它唤醒")})]}),s.jsx("span",{className:`badge ${r.wake.registered?"ok":""}`,children:r.wake.registered?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:g.wakeToRun,disabled:u||!r.wake.available,onChange:x=>void m({wakeToRun:x.target.checked})}),"睡眠时按定时唤醒电脑"]}),s.jsx("p",{className:"muted small",children:"关机后不能唤醒。程序没开着时,唤醒会顺便把它在托盘里打开(不运行「软件启动时运行」的流水线)。要在 Windows 电源选项里允许唤醒定时器:控制面板 → 电源选项 → 更改计划设置 → 更改高级电源设置 → 睡眠 → 允许使用唤醒定时器 → 启用(笔记本的「使用电池」也要改)。"}),s.jsx("h3",{children:"运行时防睡眠"}),s.jsxs("p",{className:"muted small",children:["流水线或脚本运行时,电脑不会自己睡眠;前台脚本(用鼠标键盘的)运行时屏幕也保持亮着。全部结束后恢复 Windows 自己的设置。",r.power.awake?"现在正在防睡眠。":""]}),s.jsx("label",{className:"field-label",htmlFor:"power-countdown",children:"流水线结束后睡眠、休眠或关机前倒计时多少秒(这段时间里可以取消)"}),s.jsx("input",{id:"power-countdown",className:"text-input plain",type:"number",min:10,max:600,defaultValue:g.powerCountdownSeconds,onBlur:x=>void m({powerCountdownSeconds:Math.max(10,Math.min(600,Math.round(Number(x.target.value)||60)))})})]}),r!==null&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"接下来"}),r.upcoming.length===0&&s.jsx("div",{className:"muted small",children:"没有开启定时的流水线。"}),s.jsx("ul",{className:"version-list",children:r.upcoming.map((x,y)=>s.jsxs("li",{children:[s.jsx("span",{className:"version-name",children:Gb(x.at)}),s.jsx("span",{children:x.pipelineName})]},y))})]}),r!==null&&r.history.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"最近的定时记录"}),s.jsx("ul",{className:"version-list",children:r.history.map((x,y)=>{var E,N;return s.jsxs("li",{children:[s.jsx("span",{className:`badge ${((E=Kb[x.outcome])==null?void 0:E[0])??""}`,children:((N=Kb[x.outcome])==null?void 0:N[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:At(x.at,n)})]},y)})})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"无人值守检查清单"}),s.jsxs("ul",{className:"guide-steps",children:[s.jsxs("li",{children:["前台脚本(如三月七)需要已登录、没有锁屏的桌面:在 Windows 里设置自动登录(运行 ",s.jsx("code",{children:"netplwiz"}),"),关闭屏幕保护程序;睡眠唤醒后不要求登录(设置 → 帐户 → 登录选项 →「需要登录」选「从不」)。"]}),s.jsx("li",{children:"模拟器脚本(如 MAA)不受锁屏影响。"}),s.jsx("li",{children:"运行期间程序会阻止电脑睡眠;想让睡着的电脑按时醒来跑定时任务,打开上面的「定时唤醒」。关机后的电脑不能被唤醒,可以在主板 BIOS 里设置定时开机,再配合开机自启。"}),s.jsx("li",{children:"没接显示器时,游戏可能以很小的分辨率启动;可以接一个 HDMI 假负载(显卡欺骗器)。"}),s.jsx("li",{children:"想在手机上收到结果,先在「设置 → 飞书」接好飞书。"})]})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]})]})}const NU={id:"pipelines",title:"编排",milestone:"M4",requires:["pipelines","scripts","runs"],pages:[{id:"pipelines",title:"编排",icon:"flow",order:20,agent:"pipelines",component:pU}]},wU={id:"schedule",title:"定时与自启",milestone:"M4",requires:["schedule","pipelines"],settingsPages:[{id:"schedule",title:"定时与自启",order:9,component:kU}]},gp=new Map;function QS(e,t){let n=gp.get(t);return n===void 0&&(n=e.connection.call("games/image",{url:t}).then(r=>`data:${r.mediaType};base64,${r.data}`),n.catch(()=>gp.delete(t)),gp.set(t,n)),n}function JS(e,t){const[n,r]=b.useState(void 0),i=t.filter(o=>o!==void 0).filter((o,c,u)=>u.indexOf(o)===c);return b.useEffect(()=>{r(void 0);let o=!0;return(async()=>{for(const c of i){const u=await QS(e,c).catch(()=>{});if(u!==void 0){o&&r(u);return}}})(),()=>{o=!1}},[e,i.join(`
227
+ `)]),n}function Vo(e,t){const[n,r]=b.useState(void 0);return b.useEffect(()=>{if(r(void 0),t===void 0)return;let i=!0;return QS(e,t).then(o=>{i&&r(o)},()=>{}),()=>{i=!1}},[e,t]),n}const e_=["image/png","image/jpeg","image/gif","image/webp","image/avif"],jU=8*1024*1024;function bm(e,t){const n=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)).map(r=>[r.type,Number(r.value)]));return Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second)-Math.floor(e/1e3)*1e3}function SU(e){var n;return(((n=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date).find(r=>r.type==="timeZoneName"))==null?void 0:n.value)??"").replace("GMT","UTC")||e}function Yb(e,t){return e===void 0?"":new Date(e+bm(e,t)).toISOString().slice(0,16)}function Xb(e,t){const n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(e);if(n===null)return;const r=Date.UTC(Number(n[1]),Number(n[2])-1,Number(n[3]),Number(n[4]),Number(n[5]));return r-bm(r-bm(r,t),t)}function _U(e){return new Promise((t,n)=>{if(!e_.includes(e.type)){n(new Error("只支持 png、jpg、gif、webp、avif 图片"));return}if(e.size>jU){n(new Error("图片太大(最多 8 MB)"));return}const r=new FileReader;r.onload=()=>{const i=String(r.result);t({image:{mediaType:e.type,data:i.slice(i.indexOf(",")+1)},src:i})},r.onerror=()=>n(new Error("图片读不出来")),r.readAsDataURL(e)})}function Eg({client:e,game:t,activity:n,onDone:r,onCancel:i}){var P;const o=t.timezone,c={name:(n==null?void 0:n.name)??"",kind:(n==null?void 0:n.kind)??"",startsAt:Yb(n==null?void 0:n.startsAt,o),endsAt:Yb(n==null?void 0:n.endsAt,o),url:(n==null?void 0:n.url)??"",description:(n==null?void 0:n.description)??""},[u,h]=b.useState(c),[d,p]=b.useState(null),[m,g]=b.useState(!1),[x,y]=b.useState(!1),[E,N]=b.useState(null),w=b.useRef(null),T=((P=n==null?void 0:n.own)==null?void 0:P.fields.includes("cover"))===!0,k=Vo(e,m||n==null?void 0:n.cover),I=(d==null?void 0:d.src)??k,L=n!==void 0&&(n.sources!==void 0||n.screen!==void 0);b.useEffect(()=>{N(null)},[u]);const z=D=>B=>h(_=>({..._,[D]:B.target.value})),U=D=>{D!==void 0&&_U(D).then(B=>{p(B),g(!1)},B=>N(Re(B)))},V=D=>{const B=[...D.clipboardData.files].find(_=>_.type.startsWith("image/"));B!==void 0&&(D.preventDefault(),U(B))},$=async()=>{if(u.name.trim()===""){N("活动要有名字");return}const D=u.startsAt===""?null:Xb(u.startsAt,o)??null,B=u.endsAt===""?null:Xb(u.endsAt,o)??null;if(D!==null&&B!==null&&B<=D){N("结束时间要晚于开始时间");return}const _=M=>n===void 0||u[M]!==c[M],C=M=>_(M)?{[M]:u[M].trim()===""?null:u[M].trim()}:{},R={game:t.id,...n===void 0?{}:{activityId:n.id},...C("name"),...C("kind"),...C("url"),...C("description"),..._("startsAt")?{startsAt:D}:{},..._("endsAt")?{endsAt:B}:{},...d!==null?{image:d.image}:m?{cover:null}:{}};y(!0),N(null);try{r(await e.connection.call("games/activity/save",R))}catch(M){N(Re(M))}finally{y(!1)}};return s.jsxs("form",{className:"activity-editor",onSubmit:D=>{D.preventDefault(),$()},onPaste:V,onKeyDown:D=>{D.key==="Escape"&&i()},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 ${I===void 0?"empty":""}`,onClick:()=>{var D;return(D=w.current)==null?void 0:D.click()},title:"选一张图片(也可以直接粘贴)",children:I!==void 0?s.jsx("img",{src:I,alt:""}):s.jsxs(s.Fragment,{children:[s.jsx(Q,{name:"image"}),s.jsx("span",{children:"选图片"}),s.jsx("small",{children:"或粘贴"})]})}),s.jsx("input",{ref:w,type:"file",accept:e_.join(","),hidden:!0,onChange:D=>{var B;U((B=D.target.files)==null?void 0:B[0]),D.target.value=""}}),(d!==null||T&&!m)&&s.jsx("button",{type:"button",className:"link-button small muted",onClick:()=>{p(null),T&&g(!0)},children:d!==null?"不用这张":L?"用回来源的图":"去掉图片"})]}),s.jsxs("div",{className:"activity-editor-fields",children:[s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field wide",children:[s.jsx("span",{className:"field-title",children:"活动名"}),s.jsx("input",{className:"text-input plain",autoFocus:n===void 0,maxLength:60,value:u.name,onChange:z("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:z("kind"),placeholder:"签到、SideStory…"})]})]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"开始"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.startsAt,onChange:z("startsAt")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"结束"}),s.jsx("input",{className:"text-input plain",type:"datetime-local",value:u.endsAt,onChange:z("endsAt")})]})]}),s.jsxs("span",{className:"muted small",children:["时间按游戏服务器时间(",SU(o),")",u.endsAt===""?";不填结束时间的会一直留着,直到你去掉它":""]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"活动页面(可选)"}),s.jsx("input",{className:"text-input plain",type:"url",value:u.url,onChange:z("url"),placeholder:"https://…"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"说明(可选)"}),s.jsx("textarea",{className:"text-input plain",rows:2,maxLength:500,value:u.description,onChange:z("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:i,children:"取消"}),E!==null&&s.jsx("span",{className:"tone-error small",children:E})]})]})}const Qs=864e5,Qb={name:"名字",startsAt:"开始时间",endsAt:"结束时间",kind:"类型",description:"说明",url:"页面",cover:"图片"},xp=2,EU=28,Vi=["#3b82c4","#c0567d","#2f9e7a","#c98a1b","#7a62d6","#d2643c","#4d9a3c","#2a93a8","#a86bb8","#8a7a3a"],Jb="adg:games:overview:shown",ek="adg:games:overview:mode";function tk(e,t){try{const n=localStorage.getItem(e);return n===null?t:JSON.parse(n)}catch{return t}}function nk(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 CU(e,t){return new Date(e).toLocaleDateString("zh-CN",{timeZone:t,month:"numeric",day:"numeric"})}function Yu(e,t){const n=e-t;return n<=0?"已结束":n<Qs?`${Math.max(1,Math.floor(n/36e5))} 小时`:`${Math.floor(n/Qs)} 天`}function AU({client:e,games:t,activities:n,now:r,soonDays:i,onOpenGame:o,onChanged:c}){const[u,h]=b.useState(()=>tk(Jb,null)),[d,p]=b.useState(()=>tk(ek,"time")),[m,g]=b.useState(null);b.useEffect(()=>nk(Jb,u),[u]),b.useEffect(()=>nk(ek,d),[d]);const x=b.useMemo(()=>new Map(t.map((B,_)=>[B.id,Vi[_%Vi.length]])),[t]),y=B=>u===null||u.includes(B),E=B=>h(_=>{const C=_??t.map(M=>M.id),R=C.includes(B)?C.filter(M=>M!==B):[...C,B];return R.length===t.length?null:R}),N=new Date(r-xp*Qs).setHours(0,0,0,0),w=N+(xp+EU)*Qs,T=B=>Math.min(100,Math.max(0,(B-N)/(w-N)*100)),k=n.filter(B=>y(B.game)&&(B.endsAt===void 0||Math.max(B.endsAt,B.shopEndsAt??0)>r)),I=(B,_)=>(B.endsAt??1/0)-(_.endsAt??1/0)||B.name.localeCompare(_.name),L=k.filter(B=>(B.startsAt??0)<=r),z=k.filter(B=>B.startsAt!==void 0&&B.startsAt>r).sort((B,_)=>B.startsAt-_.startsAt),U=[];if(d==="time"){const B=N+(xp+7)*Qs,_=L.filter(M=>M.endsAt!==void 0&&M.endsAt-r<i*Qs).sort(I),C=L.filter(M=>!_.includes(M)&&M.endsAt!==void 0&&M.endsAt<B).sort(I),R=L.filter(M=>!_.includes(M)&&!C.includes(M)).sort(I);U.push({key:"soon",title:"快结束",hint:`${i} 天内`,rows:_},{key:"week",title:"本周内结束",rows:C},{key:"later",title:"之后结束",rows:R},{key:"upcoming",title:"即将开始",rows:z})}else for(const B of t){if(!y(B.id))continue;const _=[...L.filter(C=>C.game===B.id).sort(I),...z.filter(C=>C.game===B.id)];U.push({key:B.id,title:B.name,rows:_,game:B})}const V=L.reduce((B,_)=>{const C=rs(_);return{...B,[C.state]:B[C.state]+1}},{finished:0,partial:0,unknown:0}),$=L.filter(B=>B.endsAt!==void 0&&B.endsAt-r<i*Qs&&rs(B).state!=="finished").length,P=[];for(let B=N;B<=w;B+=Qs){const _=Math.round((B-new Date(r).setHours(0,0,0,0))/Qs);P.push({at:B,..._>0&&_%7===0?{label:CU(B,Intl.DateTimeFormat().resolvedOptions().timeZone)}:{}})}const D=B=>n.filter(_=>_.game===B&&(_.startsAt??0)<=r&&(_.endsAt===void 0||Math.max(_.endsAt,_.shopEndsAt??0)>r));return s.jsxs("div",{className:"games-overview",children:[s.jsx("div",{className:"game-tiles",role:"group","aria-label":"各游戏",children:t.map(B=>{const _=D(B.id);return s.jsx(IU,{client:e,game:B,color:x.get(B.id)??Vi[0],now:r,shown:y(B.id),running:_.length,soon:_.filter(C=>C.endsAt!==void 0&&C.endsAt-r<i*Qs&&rs(C).state!=="finished").length,covers:_.map(C=>C.cover).filter(C=>(C==null?void 0:C.startsWith("shot:"))!==!0).slice(0,6),onOpen:()=>o(B.id),onToggle:()=>E(B.id)},B.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(Ml,{value:L.length,label:"进行中"}),s.jsx(Ml,{value:$,label:"快结束未做完",tone:$>0?"warn":void 0}),s.jsx(Ml,{value:V.finished,label:"做完"}),s.jsx(Ml,{value:V.partial,label:"做了一部分"}),s.jsx(Ml,{value:V.unknown,label:"没记录"})]}),s.jsxs("div",{className:"segmented-control ov-mode",role:"group","aria-label":"排序",children:[s.jsx("button",{className:d==="time"?"active":"","aria-pressed":d==="time",onClick:()=>p("time"),children:"按时间"}),s.jsx("button",{className:d==="game"?"active":"","aria-pressed":d==="game",onClick:()=>p("game"),children:"按游戏"})]})]}),s.jsxs("div",{className:"ov-grid",children:[s.jsx("div",{className:"ov-lines","aria-hidden":"true",children:P.filter(B=>B.label!==void 0).map(B=>s.jsx("i",{style:{left:`${T(B.at)}%`}},B.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:[P.map(B=>s.jsx("span",{className:`ov-tick ${B.label!==void 0?"major":""}`,style:{left:`${T(B.at)}%`},children:B.label!==void 0&&s.jsx("em",{children:B.label})},B.at)),s.jsx("span",{className:"ov-today-label",style:{left:`${T(r)}%`},children:"今天"})]}),s.jsx("div",{className:"ov-side"})]}),U.every(B=>B.rows.length===0)&&s.jsxs("div",{className:"empty",children:[s.jsx(Q,{name:"calendar"}),s.jsx("p",{children:t.length===0?"没有游戏。":"显示的游戏现在没有活动。点「刷新全部」读取,或点上面游戏卡片的眼睛多显示几个。"})]}),U.filter(B=>B.rows.length>0).map(B=>{var _;return s.jsxs("div",{className:`ov-section ${B.key==="soon"?"warn":""} ${B.game!==void 0?"by-game":""}`,style:B.game===void 0?void 0:{"--game":x.get(B.game.id)},children:[s.jsxs("div",{className:"ov-section-title",children:[B.game!==void 0&&s.jsx("span",{className:"game-dot"}),s.jsx("span",{className:"ov-section-name",children:B.title}),s.jsx("span",{className:"ov-section-count",children:B.rows.length}),B.hint!==void 0&&s.jsx("span",{className:"muted small",children:B.hint}),((_=B.game)==null?void 0:_.version)!==void 0&&s.jsxs("span",{className:"muted small ov-section-version",children:[B.game.version.name,B.game.version.title===void 0?"":`「${B.game.version.title}」`]}),B.game!==void 0&&s.jsxs("button",{className:"link-button small ov-section-open",onClick:()=>o(B.game.id),children:["打开",s.jsx(Q,{name:"chevron"})]})]}),B.rows.map(C=>{const R=t.find(M=>M.id===C.game);return s.jsx(TU,{client:e,activity:C,game:R,color:x.get(C.game)??Vi[0],showGame:d==="time",now:r,soonDays:i,x:T,open:m===C.id,onToggle:()=>g(M=>M===C.id?null:C.id),onOpenGame:()=>o(C.game),onChanged:c},C.id)})]},B.key)}),s.jsx("div",{className:"ov-today",style:{left:`calc(var(--ov-label) + (100% - var(--ov-label) - var(--ov-side)) * ${T(r)/100})`},"aria-hidden":"true"})]})]})]})}function Ml({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 IU({client:e,game:t,color:n,covers:r,now:i,running:o,soon:c,shown:u,onOpen:h,onToggle:d}){const p=t.version,m=JS(e,[p==null?void 0:p.cover,t.art,...r]),g=(p==null?void 0:p.endsAt)!==void 0&&p.endsAt>i?` · 还剩 ${Yu(p.endsAt,i)}`:"";return s.jsxs("article",{className:`game-tile ${m===void 0?"no-art":""} ${u?"":"off"}`,style:{"--game":n},children:[m!==void 0&&s.jsx("img",{className:"game-tile-art",src:m,alt:""}),s.jsx("span",{className:"game-tile-shade"}),s.jsxs("button",{className:"game-tile-open",title:`打开${t.name}`,onClick:h,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:p===void 0?"没有版本信息":`${p.name}${p.title===void 0?"":`「${p.title}」`}${g}`}),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:d,children:s.jsx(Q,{name:u?"eye":"eye-off"})})]})}function TU({client:e,activity:t,game:n,color:r,showGame:i,now:o,soonDays:c,x:u,open:h,onToggle:d,onOpenGame:p,onChanged:m}){const g=rs(t),x=(t.startsAt??0)<=o,y=t.endsAt,E=x&&y!==void 0&&y-o<c*Qs&&g.state!=="finished",N=u(t.startsAt??o-30*Qs),w=y===void 0?100:u(y),T=t.shopEndsAt===void 0||y===void 0||t.shopEndsAt<=y?void 0:u(t.shopEndsAt),k=Vo(e,t.cover);return s.jsxs("div",{className:`ov-item ${h?"open":""}`,style:{"--game":r},children:[s.jsxs("button",{className:`ov-row ${E?"soon":""} ${g.state==="finished"?"finished":""}`,onClick:d,"aria-expanded":h,children:[s.jsxs("div",{className:"ov-label",children:[s.jsx("span",{className:"ov-thumb",children:k!==void 0&&s.jsx("img",{src:k,alt:"",decoding:"async"})}),s.jsxs("span",{className:"ov-text",children:[s.jsx("span",{className:"ov-name",title:t.name,children:t.name}),(i||t.kind!==void 0)&&s.jsxs("span",{className:"ov-meta",children:[i&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"game-dot"}),(n==null?void 0:n.name)??t.game]}),t.kind!==void 0&&s.jsx("span",{className:"ov-kind",children:t.kind})]})]})]}),s.jsxs("div",{className:"ov-track",children:[s.jsx("span",{className:`ov-bar ${x?"":"future"} ${N<=0?"cut-left":""} ${y===void 0||w>=100?"cut-right":""}`,style:{left:`${N}%`,width:`${Math.max(1.2,w-N)}%`},children:g.total>0&&s.jsx("span",{className:"ov-bar-done",style:{width:`${g.done/g.total*100}%`}})}),T!==void 0&&s.jsx("span",{className:"ov-shop",style:{left:`${w}%`,width:`${Math.max(.6,T-w)}%`},title:"之后只开商店"})]}),s.jsxs("div",{className:"ov-side",children:[s.jsx("span",{className:`ov-left ${E?"tone-warn":""}`,children:x?y===void 0?"时间未知":y<=o&&t.shopEndsAt!==void 0?`商店 ${Yu(t.shopEndsAt,o)}`:Yu(y,o):`${Yu(t.startsAt,o)}后开始`}),s.jsx(Cg,{progress:g})]})]}),h&&s.jsx(MU,{client:e,activity:t,game:n,onOpenGame:p,onChanged:m})]})}function Cg({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 $U({activity:e,game:t,chosen:n,onChoose:r}){const i=Cn(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"}),h=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?"没有图片":"有图片"}`,d=x=>r(n===x?null:x),p=o.length===0&&e.screen===void 0,m=e.own!==void 0&&(e.own.startsAt!==void 0||e.own.endsAt!==void 0||e.own.cover!==void 0),g=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 y;return s.jsxs("button",{className:`fact-chip ${x.web?"web":"site"} ${n===x.id?"on":""}`,"aria-pressed":n===x.id,title:`${h(x)}。点一下用它的图片和时间`,onClick:()=>d(x.id),children:[x.name,s.jsxs("small",{children:[x.web?"网页":"数据站"," · ",At(x.at,i)]}),o.length>1&&((y=e.shown)==null?void 0:y.endsAt)===x.id&&s.jsx("small",{className:"fact-main",children:"时间以它为准"})]},x.id)}),e.screen!==void 0&&s.jsxs("button",{className:`fact-chip screen ${n===Hl?"on":""}`,"aria-pressed":n===Hl,disabled:!g,title:`agent 进游戏看到的。${h({endsAt:e.screen.endsAt,cover:e.screen.image})}`,onClick:()=>d(Hl),children:["游戏画面",s.jsxs("small",{children:["agent 看过 · ",At(e.screen.at,i)]})]}),e.own!==void 0&&s.jsxs("button",{className:`fact-chip own ${n===bo?"on":""}`,"aria-pressed":n===bo,disabled:!m||p,title:p?"你自己添加的活动":`你改过:${e.own.fields.map(x=>Qb[x]).join("、")};比来源优先,刷新不会改掉`,onClick:()=>d(bo),children:[p?"我添加的":"我改过",s.jsxs("small",{children:[p?"":`${e.own.fields.map(x=>Qb[x]).join("、")} · `,At(e.own.at,i)]})]}),n!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>r(null),children:"恢复默认"})]})}function MU({client:e,activity:t,game:n,onOpenGame:r,onChanged:i,openSession:o}){var C,R;const[c,u]=b.useState(null),[h,d]=b.useState(!1),[p,m]=b.useState(""),[g,x]=b.useState(!1),[y,E]=b.useState(null),[N,w]=b.useState(void 0);b.useEffect(()=>w(void 0),[t]);const T=N??t,[k,I]=b.useState(void 0);b.useEffect(()=>I(void 0),[T.chosen]);const L=M=>{I(M),E(null),e.connection.call("games/activity/source",{activityId:T.id,source:M}).then(F=>{w(F),i()},F=>{I(void 0),E(Re(F))})},z=(n==null?void 0:n.timezone)??"Asia/Shanghai",U=M=>new Date(M).toLocaleString("zh-CN",{timeZone:z,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),V=async M=>{x(!0),E(null);try{await e.connection.call("games/activity/progress",{activityId:T.id,...M}),i()}catch(F){E(Re(F))}finally{x(!1)}},$=M=>void V({todo:T.todo.filter(F=>F!==M),done:[...T.done,M]}),P=M=>void V({todo:[...T.todo,M],done:T.done.filter(F=>F!==M)}),D=()=>{const M=p.trim();M===""||T.todo.includes(M)||T.done.includes(M)||(m(""),V({todo:[...T.todo,M]}))},B=T.sources!==void 0||T.screen!==void 0,_=()=>{x(!0),E(null),e.connection.call("games/activity/reset",{activityId:T.id}).then(i,M=>E(Re(M))).finally(()=>x(!1))};return h&&n!==void 0?s.jsx("div",{className:"ov-detail",children:s.jsx(Eg,{client:e,game:n,activity:T,onDone:()=>{d(!1),i()},onCancel:()=>d(!1)})}):s.jsxs("div",{className:"ov-detail",children:[T.description!==void 0&&s.jsx("p",{className:"ov-description",children:T.description}),s.jsxs("div",{className:"activity-dates muted small",children:[T.startsAt!==void 0&&s.jsxs("span",{children:[U(T.startsAt)," 开始"]}),T.endsAt!==void 0&&s.jsxs("span",{children:[U(T.endsAt)," 结束"]}),T.shopEndsAt!==void 0&&s.jsxs("span",{children:["商店开到 ",U(T.shopEndsAt)]})]}),s.jsx($U,{activity:T,game:n,chosen:k!==void 0?k??void 0:T.chosen,onChoose:L}),s.jsxs("div",{className:"ov-checklist",role:"list","aria-label":"要做的事",children:[T.todo.map(M=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:g,onChange:()=>$(M)}),M]},`t${M}`)),T.done.map(M=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:g,onChange:()=>P(M)}),M]},`d${M}`)),T.todo.length+T.done.length===0&&s.jsx("p",{className:"muted small",children:"还没有要做的事。自己加几项(例如「活动商店换完」「剧情通关」),或者在游戏页让 agent 进游戏读一次。"})]}),s.jsxs("div",{className:"ov-add",children:[s.jsx("input",{className:"text-input plain",value:p,maxLength:80,placeholder:"加一项要做的事,回车添加",disabled:g,onChange:M=>m(M.target.value),onKeyDown:M=>{M.key==="Enter"&&D()}}),s.jsxs("button",{className:"small-button",disabled:g||p.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:T.finished!==void 0,disabled:g,onChange:M=>void V({finished:M.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),((C=T.screen)==null?void 0:C.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:T.id}).then(M=>{const F=`data:${M.mediaType};base64,${M.data}`,H=new Image;H.onload=()=>u({src:F,width:H.naturalWidth,height:H.naturalHeight}),H.src=F},M=>E(Re(M))),children:"看游戏截图"}),((R=T.screen)==null?void 0:R.sessionId)!==void 0&&o!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>o(T.screen.sessionId),children:"agent 的对话"}),T.url!==void 0&&s.jsx("a",{className:"link-button small",href:T.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),r!==void 0&&s.jsxs("button",{className:"link-button small",onClick:r,children:["去",(n==null?void 0:n.name)??"游戏"]}),n!==void 0&&s.jsxs("button",{className:"link-button small",disabled:g,onClick:()=>d(!0),children:[s.jsx(Q,{name:"pencil"}),"编辑"]}),T.own!==void 0&&B&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:g,onClick:_,children:"恢复来源的内容"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:g,onClick:()=>void e.connection.call("games/activity/remove",{activityId:T.id}).then(i,M=>E(Re(M))),children:"从日历去掉"})]}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:y})]}),c!==null&&s.jsx(ng,{src:c.src,width:c.width,height:c.height,name:`${T.name}.png`,onClose:()=>u(null)})]})}function RU({client:e,onChanged:t,onDiscover:n}){const[r,i]=b.useState(null),[o,c]=b.useState(""),[u,h]=b.useState(null),[d,p]=b.useState(null),[m,g]=b.useState(0);b.useEffect(()=>{let y=!0;return e.connection.call("games/catalog",{}).then(E=>{y&&i(E.games)}).catch(E=>{y&&p(Re(E))}),()=>{y=!1}},[e,m]);const x=async(y,E)=>{h(y),p(null);try{await e.connection.call("games/follow",{sra:y,follow:E}),g(N=>N+1),t()}catch(N){p(Re(N))}finally{h(null)}};return s.jsxs("div",{className:"catalog-picker",children:[s.jsxs("p",{className:"muted small",children:["这些游戏的活动来自 ",s.jsx("a",{href:"https://starrailassistant.top/reference/public-api/",target:"_blank",rel:"noreferrer",children:"SRA 公共 API"}),"(社区按官方公告整理,免费,不用模型)。勾上的游戏每天自动读一次。"]}),r===null&&d===null&&s.jsx("p",{className:"muted small",children:"正在读取…"}),s.jsx("div",{className:"catalog-grid",children:r==null?void 0:r.map(y=>s.jsxs("label",{className:`check-label ${y.pack!==void 0?"muted":""}`,title:y.pack!==void 0?"已经有游戏包在读它":void 0,children:[s.jsx("input",{type:"checkbox",checked:y.pack!==void 0||y.followed,disabled:y.pack!==void 0||u!==null,onChange:E=>void x(y.sra,E.target.checked)}),y.name,y.pack!==void 0?"(已有)":u===y.sra?"…":""]},y.sra))}),n!==void 0&&s.jsxs("form",{className:"discover-row",onSubmit:y=>{y.preventDefault();const E=o.trim();E!==""&&(n(E),c(""))},children:[s.jsx("span",{className:"field-title",children:"列表里没有?"}),s.jsx("input",{className:"text-input plain",value:o,maxLength:60,placeholder:"输入游戏名,例如:重返未来:1999",onChange:y=>c(y.target.value)}),s.jsxs("button",{className:"small-button primary",type:"submit",disabled:o.trim()==="",children:[s.jsx(Q,{name:"search"}),"让 agent 去找"]}),s.jsx("span",{className:"muted small",children:"agent 会找它的 Wiki、官网公告等来源,建一个游戏包加到游戏页。"})]}),d!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]})]})}const Yi=864e5,wa=36e5,km=6e4;function Ag(e,t){const n=e-t;return n<=0?"已结束":n>=Yi?`${Math.floor(n/Yi)} 天 ${Math.floor(n%Yi/wa)} 时`:`${Math.floor(n/wa)} 时 ${Math.floor(n%wa/km)} 分`}function OU(e){return e<=0?{value:"0",unit:"时",rest:""}:e>=Yi?{value:String(Math.floor(e/Yi)),unit:"天",rest:`${Math.floor(e%Yi/wa)} 时`}:e>=wa?{value:String(Math.floor(e/wa)),unit:"时",rest:`${Math.floor(e%wa/km)} 分`}:{value:String(Math.max(1,Math.floor(e/km))),unit:"分",rest:""}}function Nm(e,t){const n=Object.fromEntries(new Intl.DateTimeFormat("en-CA",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).formatToParts(new Date(e)).map(r=>[r.type,r.value]));return`${n.year}/${n.month}/${n.day} ${n.hour}:${n.minute}`}function Ig(e,t){var r;return(((r=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"shortOffset"}).formatToParts(new Date(t)).find(i=>i.type==="timeZoneName"))==null?void 0:r.value)??"").replace("GMT","UTC")||e}function zU({client:e,game:t,activities:n,color:r,now:i,soonDays:o,busy:c,open:u,adding:h,onOpen:d,onAdd:p,onRefresh:m,onRead:g,onReadWeb:x,onUnfollow:y,onChanged:E,openSession:N,openScripts:w}){var R,M;const[T,k]=b.useState(!1),I=n.filter(F=>Math.max(F.endsAt??1/0,F.shopEndsAt??0)>i),L=(F,H)=>(F.endsAt??1/0)-(H.endsAt??1/0),z=I.filter(F=>(F.startsAt??0)<=i).sort(L),U=I.filter(F=>F.startsAt!==void 0&&F.startsAt>i).sort((F,H)=>F.startsAt-H.startsAt),V=z.filter(F=>rs(F).state!=="finished"&&(F.endsAt??1/0)-i<o*Yi),$=t.sources.some(F=>F.auto),P={partial:0,unknown:1,finished:2},D=z.filter(F=>!V.includes(F)&&rs(F).state!=="finished").sort((F,H)=>P[rs(F).state]-P[rs(H).state]||L(F,H)),B=z.filter(F=>rs(F).state==="finished"),_=[{key:"soon",title:"需要关注",hint:`${o} 天内结束,还没做完`,rows:V,tone:"warn"},{key:"ongoing",title:"进行中",hint:"做了一部分的在前",rows:D},{key:"upcoming",title:"即将开始",hint:"按开始时间",rows:U}],C=F=>s.jsx("div",{className:"schedule-item",children:s.jsx(UU,{client:e,activity:F,game:t,now:i,soonDays:o,onClick:()=>d(F.id),expanded:u===F.id})},F.id);return s.jsxs("div",{className:"game-view",style:{"--game":r},children:[s.jsx(PU,{client:e,game:t,now:i,covers:z.map(F=>F.cover).filter(F=>(F==null?void 0:F.startsWith("shot:"))!==!0)}),s.jsxs("div",{className:"game-columns",children:[s.jsxs("div",{className:"game-main",children:[(((R=t.pools)==null?void 0:R.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(F=>s.jsx(HU,{client:e,pool:F,game:t,now:i},`${F.name}-${F.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:I.length}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"muted small",children:((M=t.sources.find(F=>F.auto))==null?void 0:M.name)??"数据站"}),s.jsx("button",{className:"icon-button",title:"自己添加一个活动","aria-label":"添加活动","aria-pressed":h,onClick:p,children:s.jsx(Q,{name:"plus"})}),s.jsx("button",{className:"icon-button",title:$?"刷新数据站(不用模型)":"这个游戏没有能自动读的数据站",disabled:c!==null||!$,onClick:m,children:s.jsx(Q,{name:"refresh"})})]}),I.length===0&&s.jsx("p",{className:"muted small schedule-empty",children:$?"还没有活动。点右上角刷新,或点「+」自己添加。":"这个游戏没有能自动读的数据站:让 agent 进游戏读一次,或点「+」自己添加。"}),_.filter(F=>F.rows.length>0).map(F=>s.jsxs("section",{className:`schedule-group ${F.tone??""}`,children:[s.jsxs("div",{className:"schedule-group-title",children:[s.jsx("span",{children:F.title}),s.jsx("span",{className:"count",children:F.rows.length}),s.jsx("span",{className:"muted small",children:F.hint})]}),s.jsx("div",{className:"schedule-grid",children:F.rows.map(C)})]},F.key)),B.length>0&&s.jsxs("section",{className:"schedule-group done",children:[s.jsxs("button",{className:"schedule-group-title toggle","aria-expanded":T,onClick:()=>k(F=>!F),children:[s.jsx("span",{children:"已做完"}),s.jsx("span",{className:"count",children:B.length}),s.jsx("span",{className:"muted small",children:T?"收起":"展开"}),s.jsx(Q,{name:"chevron-down",className:`chevron-icon ${T?"open":""}`})]}),T&&s.jsx("div",{className:"schedule-grid",children:B.map(C)})]})]})]}),s.jsxs("aside",{className:"game-side",children:[s.jsx(DU,{game:t,running:z,soon:V,now:i,busy:c,onRead:g,onReadWeb:x,onUnfollow:y,openSession:N}),s.jsx("section",{className:"card game-runs-card",children:s.jsx(BU,{client:e,game:t,now:i,openScripts:w})}),s.jsxs("section",{className:"card game-sources-card",children:[s.jsx("h3",{children:"数据来源"}),s.jsxs("div",{className:"game-sources",children:[t.sources.map(F=>{var H;return s.jsxs("span",{className:`source-chip ${F.auto?"auto":"agent"}`,children:[F.auto?s.jsxs("span",{className:"source-name",title:"每天自动读取(不用模型)",children:[s.jsx("span",{className:"source-dot auto"}),F.name]}):s.jsxs("button",{className:"source-name",disabled:c!==null||((H=t.webReading)==null?void 0:H.state)==="running",title:"让 agent 读这个来源,把活动记进日历",onClick:()=>x(F.id),children:[s.jsx("span",{className:"source-dot"}),F.name,s.jsx("span",{className:"source-action",children:"agent 读"})]}),F.homepage!==void 0&&s.jsx("a",{className:"source-open",href:F.homepage,target:"_blank",rel:"noreferrer",title:"在浏览器里打开","aria-label":`打开${F.name}`,children:s.jsx(Q,{name:"popout"})}),F.added===!0&&s.jsx("button",{className:"source-open",title:"不再读这个网址","aria-label":`删除${F.name}`,onClick:()=>void e.connection.call("games/source/remove",{game:t.id,source:F.id}).then(E,()=>{}),children:s.jsx(Q,{name:"close"})})]},F.id)}),s.jsx(LU,{client:e,game:t,onAdded:E})]}),t.refreshed!==void 0&&s.jsxs("span",{className:"muted small",children:[At(t.refreshed.at,i),"刷新"]}),t.refreshed!==void 0&&!t.refreshed.ok&&s.jsxs("span",{className:"tone-error small",children:["上次没读到:",t.refreshed.detail]})]})]})]})]})}function PU({client:e,game:t,now:n,covers:r}){const i=t.version,o=JS(e,[i==null?void 0:i.cover,t.art,...r]),c=(i==null?void 0:i.startsAt)!==void 0&&i.endsAt!==void 0?i.endsAt-i.startsAt:void 0,u=c===void 0||c<=0?void 0:Math.min(1,Math.max(0,(n-i.startsAt)/c)),h=d=>new Date(d).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,i===void 0?"":s.jsxs(s.Fragment,{children:[" · ",s.jsx("b",{children:i.name})," 版本"]})]}),s.jsx("h2",{children:(i==null?void 0:i.title)??t.name})]}),s.jsxs("div",{className:"version-strip",children:[i===void 0&&s.jsx("span",{className:"small version-none",children:t.sources.some(d=>d.auto)?"还没有版本信息:点「活动日程」右上角刷新":"这个游戏的数据站不提供版本信息"}),i!==void 0&&u!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-end",children:h(i.startsAt)}),s.jsxs("div",{className:"version-track",role:"meter","aria-label":"版本进度","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(u*100),children:[s.jsx("span",{className:"version-fill",style:{width:`${u*100}%`}}),s.jsx("span",{className:"version-now",style:{left:`${u*100}%`}})]}),s.jsx("span",{className:"version-end",children:h(i.endsAt)})]}),(i==null?void 0:i.endsAt)!==void 0&&s.jsx("span",{className:"version-remaining",children:i.endsAt>n?s.jsxs(s.Fragment,{children:["还剩 ",s.jsx("strong",{children:Ag(i.endsAt,n)})]}):"本版本已结束"})]})]})}function LU({client:e,game:t,onAdded:n}){const[r,i]=b.useState(!1),[o,c]=b.useState(""),[u,h]=b.useState(!1),[d,p]=b.useState(null);if(!r)return s.jsxs("button",{className:"source-add",onClick:()=>i(!0),title:"添加一个关于这个游戏的网页,agent 会去读它",children:[s.jsx(Q,{name:"plus"}),"添加网址"]});const m=async()=>{const g=o.trim();if(g!==""){h(!0),p(null);try{await e.connection.call("games/source/add",{game:t.id,url:/^https?:\/\//.test(g)?g:`https://${g}`}),c(""),i(!1),n()}catch(x){p(Re(x))}finally{h(!1)}}};return s.jsxs("form",{className:"source-form",onSubmit:g=>{g.preventDefault(),m()},children:[s.jsx("input",{className:"text-input plain",autoFocus:!0,type:"text",inputMode:"url",placeholder:"https://… 官网公告、Wiki 页面、帖子",value:o,disabled:u,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Escape"&&i(!1)}}),s.jsx("button",{className:"small-button primary",type:"submit",disabled:u||o.trim()==="",children:u?"添加中…":"添加并读取"}),s.jsx("button",{className:"small-button",type:"button",onClick:()=>{i(!1),p(null)},children:"取消"}),d!==null&&s.jsx("span",{className:"tone-error small",children:d})]})}function DU({game:e,running:t,soon:n,now:r,busy:i,onRead:o,onReadWeb:c,onUnfollow:u,openSession:h}){var y,E;const d=t.map(rs),p=d.filter(N=>N.state==="finished").length,m=d.filter(N=>N.state==="partial").length,g=d.filter(N=>N.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":`已做完 ${p} 个,做了一部分 ${m} 个,没记录 ${g} 个`,children:[p>0&&s.jsx("span",{className:"done",style:{flexGrow:p}}),m>0&&s.jsx("span",{className:"partial",style:{flexGrow:m}}),g>0&&s.jsx("span",{className:"unknown",style:{flexGrow:g}})]}),s.jsxs("ul",{className:"status-legend",children:[s.jsxs("li",{children:[s.jsx("i",{className:"done"}),"已做完",s.jsx("b",{children:p})]}),s.jsxs("li",{children:[s.jsx("i",{className:"partial"}),"做了一部分",s.jsx("b",{children:m})]}),s.jsxs("li",{children:[s.jsx("i",{className:"unknown"}),"没记录",s.jsx("b",{children:g})]})]}),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:i!==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:i!==null||((y=e.webReading)==null?void 0:y.state)==="running",title:"agent 读官网公告、Wiki 等插件不能自己读的来源,把活动记进日历",onClick:()=>c(),children:[s.jsx(Q,{name:"search"}),((E=e.webReading)==null?void 0:E.state)==="running"?"agent 正在查…":"让 agent 上网查活动"]}),e.followed===!0&&s.jsx("button",{className:"small-button",disabled:i!==null,title:"不再显示这个游戏",onClick:u,children:"取消关注"})]}),x!==void 0&&s.jsx(sk,{what:"进游戏",reading:x,now:r,openSession:h}),e.webReading!==void 0&&s.jsx(sk,{what:"上网查",reading:e.webReading,now:r,openSession:h})]})}function sk({what:e,reading:t,now:n,openSession:r}){var o;const i=(o=t.summary)==null?void 0:o.replace(/[*_`#>]+/g,"").replace(/\s+/g," ").trim();return s.jsxs("div",{className:`reading ${t.state}`,children:[s.jsxs("div",{className:"reading-head",children:[s.jsx("span",{className:`badge ${t.state==="done"?"ok":t.state==="failed"?"warn":""}`,children:t.state==="running"?`正在${e}`:t.state==="done"?`上次${e}`:`${e}没完成`}),s.jsx("span",{className:"muted small",children:At(t.at,n)}),s.jsx("span",{className:"spacer"}),t.sessionId!==void 0&&s.jsxs("button",{className:"link-button small reading-open",onClick:()=>r(t.sessionId),children:["查看对话",s.jsx(Q,{name:"chevron"})]})]}),i!==void 0&&i!==""&&s.jsx("p",{className:"reading-summary",title:i,children:i})]})}function FU({client:e,game:t}){const n=je(e.capabilities),[r,i]=b.useState(null);return b.useEffect(()=>{if(!n.has("scripts"))return;let o=!0;return e.connection.call("games/mirrorchyan",{game:t.id}).then(c=>{o&&i(c.items)},()=>{o&&i([])}),()=>{o=!1}},[e,t.id,n.has("scripts")]),r===null||r.length===0?null:s.jsxs("div",{className:"mirror-tools",children:[s.jsx("div",{className:"muted small",children:"Mirror酱 上有这些玩它的工具:"}),s.jsx("ul",{children:r.slice(0,5).map(o=>s.jsxs("li",{children:[s.jsx("a",{href:`#/p/scripts/${encodeURIComponent(`mirror:${o.rid}`)}`,children:o.name}),s.jsx("span",{className:"chip subtle",children:o.rid}),o.description!==""&&s.jsx("span",{className:"muted small",children:o.description})]},o.rid))})]})}function BU({client:e,game:t,now:n,openScripts:r}){const i=je(e.capabilities),o=je(e.connection.status),[c,u]=b.useState(null),[h,d]=b.useState([]),[p,m]=b.useState(0),[g,x]=b.useState(null),[y,E]=b.useState(null),N=i.has("pipelines");b.useEffect(()=>e.connection.on("pipelines/changed",()=>m(k=>k+1)),[e]),b.useEffect(()=>e.connection.on("pipelines/run",k=>{k.state!=="running"&&m(I=>I+1)}),[e]),b.useEffect(()=>{if(o.state!=="open"||!N||t.scripts.length===0){u([]);return}let k=!0;return(async()=>{const{items:I}=await e.connection.call("pipelines/list",{}),z=(await Promise.all(I.filter(V=>!V.draft).map(async V=>({summary:V,pipeline:await e.connection.call("pipelines/get",{id:V.id})})))).filter(({pipeline:V})=>V.nodes.some($=>$.kind==="script-task"&&t.scripts.includes($.scriptId))),U=i.has("schedule")?await e.connection.call("schedule/status",{}).catch(()=>{}):void 0;k&&(u(z),d((U==null?void 0:U.upcoming)??[]))})().catch(I=>{k&&E(Re(I))}),()=>{k=!1}},[e,o.state,N,t.id,t.scripts.join(","),p]);const w=async k=>{x(k),E(null);try{await e.connection.call("pipelines/run",{id:k}),m(I=>I+1)}catch(I){E(Re(I))}finally{x(null)}},T={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:r,children:"脚本页"}),"安装或导入后,名字或仓库里提到这个游戏的脚本会自动对上。"]}),t.scripts.length===0&&s.jsx(FU,{client:e,game:t}),t.scripts.length>0&&s.jsxs("p",{className:"muted small",children:["玩它的脚本:",t.scripts.map((k,I)=>s.jsxs("span",{children:[I>0?"、":"",s.jsx("button",{className:"link-button",onClick:r,children:k})]},k))]}),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:k})=>{var z,U;const I=h.filter(V=>V.pipelineId===k.id).map(V=>V.at).sort((V,$)=>V-$)[0],L=k.lastRun;return s.jsxs("li",{children:[s.jsx("a",{className:"run-name",href:`#/p/pipelines/${encodeURIComponent(k.id)}`,children:k.name}),s.jsx("span",{className:"muted small",children:I!==void 0?`下次 ${new Date(I).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",weekday:"short",hour:"2-digit",minute:"2-digit"})}`:k.schedule.enabled?"定时已开":"没有定时"}),L!==void 0&&s.jsxs("span",{className:`badge ${((z=T[L.state])==null?void 0:z[0])??""}`,title:new Date(L.startedAt).toLocaleString("zh-CN",{hour12:!1}),children:[((U=T[L.state])==null?void 0:U[1])??L.state," · ",At(L.endedAt??L.startedAt,n)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:g!==null||(L==null?void 0:L.state)==="running",onClick:()=>void w(k.id),children:(L==null?void 0:L.state)==="running"?"运行中…":g===k.id?"启动中…":"运行"})]},k.id)})}),y!==null&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:y})]})]})}function t_(e,t,n){const r=(e.startsAt??0)<=t,i=r&&e.endsAt!==void 0&&e.endsAt<=t,o=i?e.shopEndsAt:e.endsAt,c=r&&o!==void 0&&o-t<n*Yi&&rs(e).state!=="finished";return{started:r,shopOnly:i,end:o,soon:c,target:r?o:e.startsAt}}function n_({activity:e,art:t,now:n,soonDays:r}){var y;const{started:i,shopOnly:o,end:c,soon:u,target:h}=t_(e,n,r),d=e.startsAt!==void 0&&c!==void 0?c-e.startsAt:void 0,p=d===void 0||d<=0||!i?void 0:Math.min(1,Math.max(0,(n-e.startsAt)/d)),m=rs(e).state==="finished"?["done","已做完"]:i?o?["shop","商店开放"]:["live","进行中"]:["upcoming","即将开始"],g=h===void 0?{value:"",unit:"",rest:""}:OU(h-n),x=((y=e.cover)==null?void 0:y.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 ${m[0]}`,children:m[1]}),s.jsxs("span",{className:"sched-count","aria-label":h===void 0?"时间未知":`${i?"剩余":"距开始"}${Ag(h,n)}`,children:[h===void 0?s.jsx("b",{children:"?"}):s.jsxs(s.Fragment,{children:[s.jsx("b",{children:g.value}),s.jsx("small",{children:g.unit}),g.rest!==""&&s.jsx("em",{children:g.rest})]}),s.jsx("i",{children:i?o?"商店":"剩余":"后开始"})]}),p!==void 0&&s.jsx("span",{className:"sched-elapsed",style:{width:`${p*100}%`}})]})}function UU({client:e,activity:t,game:n,now:r,soonDays:i,onClick:o,expanded:c}){var E,N,w,T;const u=Vo(e,t.cover),h=rs(t),{started:d,shopOnly:p,end:m,soon:g}=t_(t,r,i),x=Ig(n.timezone,r),y=t.chosen===void 0?void 0:t.chosen===bo?"我设的":t.chosen===Hl?"游戏画面":(N=(E=t.sources)==null?void 0:E.find(k=>k.id===t.chosen))==null?void 0:N.name;return s.jsxs("button",{className:`sched-card ${u===void 0?"no-art":""} ${g?"soon":""}`,onClick:o,"aria-expanded":c,children:[s.jsx(n_,{activity:t,art:u,now:r,soonDays:i}),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:!d&&t.startsAt!==void 0?`${Nm(t.startsAt,n.timezone)} 开始 · ${x}`:m!==void 0?`${Nm(m,n.timezone)} ${p?"商店关闭":"结束"} · ${x}`:`结束时间未知${((w=t.screen)==null?void 0:w.remaining)===void 0?"":`,游戏里显示「${t.screen.remaining}」`}`}),t.todo.length>0&&h.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}),y!==void 0&&s.jsxs("span",{className:"sched-kind",title:`你选了用「${y}」的图片和时间`,children:["用 ",y]}),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?"我添加的":"我改过"}),((T=t.sources)==null?void 0:T.some(k=>k.web))===!0&&s.jsx("span",{className:"sched-kind",title:`来源:${t.sources.map(k=>k.name).join("、")}`,children:t.sources.every(k=>k.web)?"网页读到":"数据站 + 网页"})]}),s.jsx(Cg,{progress:h})]})]})]})}function HU({client:e,pool:t,game:n,now:r}){const i=Vo(e,t.cover),o=(t.startsAt??0)<=r;return s.jsxs("article",{className:"pool-card",children:[s.jsx("div",{className:"pool-art",children:i===void 0?s.jsx(Q,{name:"sparkles"}):s.jsx("img",{src:i,alt:""})}),s.jsxs("div",{className:"pool-main",children:[t.type!==void 0&&s.jsx("span",{className:"muted small",children:t.type}),s.jsx("strong",{children:t.name}),t.up.length>0&&s.jsxs("span",{className:"small",children:["UP:",t.up.join("、")]}),s.jsxs("span",{className:"small",children:[o?"剩余":"距开始"," ",s.jsx("strong",{className:"pool-left",children:Ag(o?t.endsAt:t.startsAt,r)})]}),s.jsxs("span",{className:"muted small",children:[Nm(t.endsAt,n.timezone)," 结束 (",Ig(n.timezone,r),")"]})]})]})}function ZU(e,t){return b.useMemo(()=>new Map(e.map((n,r)=>[n.id,t[r%t.length]])),[e,t])}function rk({color:e,label:t,onClose:n,children:r}){const i=b.useRef(null),o=()=>{var c;return((c=i.current)==null?void 0:c.querySelector("form.activity-editor"))!==null};return b.useEffect(()=>{var u;const c=document.activeElement;return(u=i.current)==null||u.focus({preventScroll:!0}),()=>{c instanceof HTMLElement&&c.isConnected&&c.focus({preventScroll:!0})}},[]),b.useEffect(()=>{const c=u=>{if(document.querySelector(".image-viewer")!==null||(u.key==="Escape"&&!o()&&n(),u.key!=="Tab"||i.current===null))return;const h=[...i.current.querySelectorAll("a[href], button:not(:disabled), input:not(:disabled):not([hidden]), textarea:not(:disabled)")],d=h[0],p=h[h.length-1],m=document.activeElement;d===void 0||p===void 0||(u.shiftKey&&(m===d||m===i.current)?(u.preventDefault(),p.focus()):!u.shiftKey&&m===p&&(u.preventDefault(),d.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:i,className:"activity-dialog",role:"dialog","aria-modal":"true","aria-label":t,tabIndex:-1,style:{"--game":e},children:r})})}function WU(e,t){const n=u=>At(u,t),r=e.sources??[],i=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:bo,name:"我设的",note:i===void 0?"":n(i.at),title:"你自己填的:刷新不会改掉",startsAt:i==null?void 0:i.startsAt,endsAt:i==null?void 0:i.endsAt,cover:i==null?void 0:i.cover,blank:i===void 0||!o(i)},...r.filter(u=>!u.web).map(c),...r.filter(u=>u.web).map(c),...e.screen===void 0?[]:[{id:Hl,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 VU(e,t){var i,o,c;const n=((i=e.shown)==null?void 0:i.startsAt)===t,r=((o=e.shown)==null?void 0:o.endsAt)===t;return[...((c=e.shown)==null?void 0:c.cover)===t?["图片"]:[],...n&&r?["时间"]:n?["开始时间"]:r?["结束时间"]:[]]}function qU({client:e,url:t}){const n=Vo(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 GU({client:e,activity:t,game:n,now:r,soonDays:i,onClose:o,onChanged:c,openSession:u}){var me,xe,oe;const[h,d]=b.useState(null),[p,m]=b.useState(!1),[g,x]=b.useState(""),[y,E]=b.useState(!1),[N,w]=b.useState(null),[T,k]=b.useState(void 0);b.useEffect(()=>k(void 0),[t]);const I=T??t,[L,z]=b.useState(void 0);b.useEffect(()=>z(void 0),[I.chosen]);const U=L!==void 0?L??void 0:I.chosen,V=Vo(e,I.cover),$=b.useRef(void 0);V!==void 0&&($.current=V);const P=I.cover===void 0?void 0:V??$.current,D=(n==null?void 0:n.timezone)??"Asia/Shanghai",B=re=>new Date(re).toLocaleString("zh-CN",{timeZone:D,hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}),_=WU(I,r),C=I.shopEndsAt!==void 0||_.some(re=>re.shopEndsAt!==void 0),R=I.sources!==void 0||I.screen!==void 0,M=(re,ie)=>{E(!0),w(null),re.then(()=>{c(),ie==null||ie()},ye=>w(Re(ye))).finally(()=>E(!1))},F=re=>M(e.connection.call("games/activity/progress",{activityId:I.id,...re})),H=re=>F({todo:I.todo.filter(ie=>ie!==re),done:[...I.done,re]}),W=re=>F({todo:[...I.todo,re],done:I.done.filter(ie=>ie!==re)}),K=()=>{const re=g.trim();re===""||I.todo.includes(re)||I.done.includes(re)||(x(""),F({todo:[...I.todo,re]}))},q=re=>{z(re),w(null),e.connection.call("games/activity/source",{activityId:I.id,source:re}).then(ie=>{k(ie),c()},ie=>{z(void 0),w(Re(ie))})},Y=(re,ie)=>{const ye=new Image;ye.onload=()=>d({src:re,width:ye.naturalWidth,height:ye.naturalHeight,name:ie}),ye.src=re},fe=()=>{E(!0),w(null),e.connection.call("games/activity/reset",{activityId:I.id}).then(re=>{c(),re.activity===void 0&&o()},re=>w(Re(re))).finally(()=>E(!1))};return p&&n!==void 0?s.jsx("div",{className:"dialog-form",children:s.jsx(Eg,{client:e,game:n,activity:I,onDone:()=>{m(!1),c()},onCancel:()=>m(!1)})}):s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"dialog-head",children:[s.jsxs("div",{className:"dialog-title",children:[s.jsx("h3",{title:I.name,children:I.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)??I.game]}),I.kind!==void 0&&s.jsx("span",{className:"sched-kind",children:I.kind})]})]}),s.jsx(Cg,{progress:rs(I)}),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:P===void 0,title:P===void 0?void 0:"看大图","aria-label":"看大图",onClick:()=>{P!==void 0&&Y(P,`${I.name}.png`)},children:s.jsx(n_,{activity:I,art:P,now:r,soonDays:i})}),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:I.startsAt===void 0?"未知":B(I.startsAt)})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"结束"}),s.jsx("dd",{children:I.endsAt===void 0?"未知":B(I.endsAt)})]}),C&&s.jsxs("div",{className:"wide",children:[s.jsx("dt",{children:"商店开到"}),s.jsx("dd",{children:I.shopEndsAt===void 0?"—":B(I.shopEndsAt)})]})]}),s.jsxs("span",{className:"muted small",children:[Ig(D,r),",游戏服务器时间",((me=I.screen)==null?void 0:me.remaining)===void 0?"":`;游戏里显示「${I.screen.remaining}」`]}),I.description!==void 0&&s.jsx("p",{className:"ov-description",children:I.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"}),U!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>q(null),children:"恢复默认"})]}),s.jsx("div",{className:"source-rows",children:_.map(re=>{const ie=re.id===bo,ye=U===re.id;return s.jsxs("button",{className:`source-row ${ye?"on":""}`,"aria-pressed":ye,disabled:re.blank&&!ie,title:re.title,onClick:()=>{re.blank&&ie?m(!0):q(ye?null:re.id)},children:[s.jsx(qU,{client:e,url:re.cover}),s.jsxs("span",{className:"source-row-main",children:[s.jsxs("span",{className:"source-row-name",children:[s.jsx("b",{children:re.name}),ye&&s.jsx(Q,{name:"check"}),re.note!==""&&s.jsx("small",{children:re.note})]}),re.blank?s.jsx("span",{className:"source-row-dates muted",children:ie?"还没填,点这里设置图片和时间":"没有时间和图片"}):s.jsxs("span",{className:"source-row-dates",children:[s.jsx("span",{children:re.startsAt===void 0&&re.endsAt===void 0?"没有时间":`${re.startsAt===void 0?"?":B(re.startsAt)} – ${re.endsAt===void 0?"?":B(re.endsAt)}`}),re.shopEndsAt!==void 0&&s.jsxs("em",{children:["商店到 ",B(re.shopEndsAt)]})]})]}),s.jsx("span",{className:"source-row-uses",children:VU(I,re.id).map(De=>s.jsx("i",{children:De},De))})]},re.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:"要做的事"}),I.todo.length+I.done.length>0&&s.jsxs("span",{className:"count",children:[I.done.length,"/",I.todo.length+I.done.length]})]}),s.jsxs("div",{className:"ov-checklist",role:"list",children:[I.todo.map(re=>s.jsxs("label",{className:"ov-check",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!1,disabled:y,onChange:()=>H(re)}),re]},`t${re}`)),I.done.map(re=>s.jsxs("label",{className:"ov-check done",role:"listitem",children:[s.jsx("input",{type:"checkbox",checked:!0,disabled:y,onChange:()=>W(re)}),re]},`d${re}`)),I.todo.length+I.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:g,maxLength:80,placeholder:"加一项,回车添加",disabled:y,onChange:re=>x(re.target.value),onKeyDown:re=>{re.key==="Enter"&&K()}}),s.jsxs("button",{className:"small-button",disabled:y||g.trim()==="",onClick:K,children:[s.jsx(Q,{name:"plus"}),"添加"]})]})]}),s.jsxs("div",{className:"dialog-section dialog-links",children:[I.url!==void 0&&s.jsx("a",{className:"link-button small",href:I.url,target:"_blank",rel:"noreferrer",children:"活动页面"}),((xe=I.screen)==null?void 0:xe.evidence)===!0&&s.jsx("button",{className:"link-button small",onClick:()=>void e.connection.call("games/evidence",{activityId:I.id}).then(re=>Y(`data:${re.mediaType};base64,${re.data}`,`${I.name}-截图.png`),re=>w(Re(re))),children:"看游戏截图"}),((oe=I.screen)==null?void 0:oe.sessionId)!==void 0&&u!==void 0&&s.jsx("button",{className:"link-button small",onClick:()=>u(I.screen.sessionId),children:"agent 的对话"}),s.jsx("span",{className:"spacer"}),I.own!==void 0&&R&&s.jsx("button",{className:"link-button small muted",title:"去掉你改过的名字、时间、图片等,恢复成来源的",disabled:y,onClick:fe,children:"清除我设的"}),s.jsx("button",{className:"link-button small muted",title:"读错了或不关心",disabled:y,onClick:()=>M(e.connection.call("games/activity/remove",{activityId:I.id}),o),children:"从日历去掉"})]}),N!==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:N})]})})]})]}),s.jsxs("footer",{className:"dialog-foot",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:I.finished!==void 0,disabled:y,onChange:re=>F({finished:re.target.checked})}),"这个活动我做完了"]}),s.jsx("span",{className:"spacer"}),n!==void 0&&s.jsxs("button",{className:"small-button",disabled:y,onClick:()=>m(!0),children:[s.jsx(Q,{name:"pencil"}),"编辑"]})]}),h!==null&&s.jsx(ng,{src:h.src,width:h.width,height:h.height,name:h.name,onClose:()=>d(null)})]})}const KU=864e5;function YU({client:e,openSession:t,openSettings:n,openPage:r,arg:i}){const o=je(e.connection.status),c=Cn(3e4),[u,h]=b.useState(null),[d,p]=b.useState(0),[m,g]=b.useState(i??""),[x,y]=b.useState(null),[E,N]=b.useState(null),[w,T]=b.useState(null),[k,I]=b.useState(!1),[L,z]=b.useState(null),U=b.useCallback(()=>z(null),[]);b.useEffect(()=>{i!==void 0&&g(i)},[i]),b.useEffect(()=>e.connection.on("games/changed",()=>p(F=>F+1)),[e]),b.useEffect(()=>{if(o.state!=="open")return;let F=!0;return e.connection.call("games/list",{}).then(H=>{F&&h(H)}).catch(H=>{F&&N(Re(H))}),()=>{F=!1}},[e,o.state,d]);const V=(u==null?void 0:u.games)??[],$=ZU(V,Vi),P=m==="report",D=P?void 0:V.find(F=>F.id===m),B=!P&&D===void 0,_=F=>{g(F),z(null),T(null),N(null)},C=async(F,H)=>{y(F),N(null),T(null);try{const W=await H();typeof W=="string"&&T(W)}catch(W){N(Re(W))}finally{y(null),p(W=>W+1)}},R=F=>C(`refresh:${F??""}`,async()=>{const{results:H}=await e.connection.call("games/refresh",F===void 0?{}:{game:F}),W=Y=>{var fe;return((fe=V.find(me=>me.id===Y))==null?void 0:fe.name)??Y},K=Y=>{var fe;return((fe=V.find(me=>me.id===Y))==null?void 0:fe.sources.some(me=>me.auto))===!0},q=H.filter(Y=>K(Y.game)&&!Y.ok);if(q.length>0)throw new Error(q.map(Y=>`${W(Y.game)}没读到:${Y.detail??"未知原因"}`).join(";"));return F===void 0?`刷新完成:${H.filter(Y=>K(Y.game)).map(Y=>`${W(Y.game)} ${Y.count} 个活动`).join(";")}`:void 0}),M=F=>{const H=((u==null?void 0:u.activities)??[]).filter(K=>K.game===F.id&&(K.startsAt??0)<=c&&Math.max(K.endsAt??1/0,K.shopEndsAt??0)>c),W=H.filter(K=>rs(K).state!=="finished"&&K.endsAt!==void 0&&K.endsAt>c&&K.endsAt-c<((u==null?void 0:u.settings.report.soonDays)??3)*KU).length;return s.jsxs("button",{role:"tab","aria-selected":(D==null?void 0:D.id)===F.id,className:`game-tab ${(D==null?void 0:D.id)===F.id?"active":""}`,style:{"--game":$.get(F.id)},title:`${H.length} 个进行中${F.refreshed===void 0?"":` · ${At(F.refreshed.at,c)}刷新`}${F.followed===!0?" · 关注的游戏":""}`,onClick:()=>_(F.id),children:[s.jsx("span",{className:"game-dot"}),F.name,W>0&&s.jsx("span",{className:"game-tab-badge",title:`${W} 个快结束还没做完`,children:W})]},F.id)};return s.jsxs("section",{className:"main games-page",children:[s.jsxs("header",{className:"page-header games-header",children:[s.jsx("div",{className:"breadcrumb",children:s.jsx("h1",{children:"游戏"})}),s.jsxs("nav",{className:"game-tabs",role:"tablist","aria-label":"游戏",children:[s.jsxs("button",{role:"tab","aria-selected":B,className:`game-tab ${B?"active":""}`,onClick:()=>_(""),children:[s.jsx(Q,{name:"calendar"}),"全部活动"]}),s.jsx("span",{className:"game-tabs-divider"}),V.map(M),s.jsxs("button",{className:`game-tab add ${k?"active":""}`,"aria-expanded":k,title:"关注更多游戏(SRA 公共 API)",onClick:()=>I(F=>!F),children:[s.jsx(Q,{name:"plus"}),"更多游戏"]}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{role:"tab","aria-selected":P,className:`game-tab ${P?"active":""}`,onClick:()=>_("report"),children:[s.jsx(Q,{name:"send"}),"日报"]})]}),s.jsx("div",{className:"page-actions",children:s.jsxs("button",{className:"small-button",disabled:x!==null||V.length===0,onClick:()=>void R(),children:[s.jsx(Q,{name:"refresh"}),x==="refresh:"?"刷新中…":"刷新全部"]})})]}),s.jsxs("div",{className:"games-body",children:[k&&s.jsx("section",{className:"card",children:s.jsx(RU,{client:e,onChanged:()=>p(F=>F+1),onDiscover:F=>void C("discover",async()=>{const{sessionId:H}=await e.connection.call("games/discover",{name:F});t(H)})})}),E!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:E})]}),w!==null&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsx("span",{children:w})]}),u!==null&&V.length===0&&s.jsxs("div",{className:"empty",children:[s.jsx(Q,{name:"gamepad"}),s.jsx("p",{children:"没有游戏。点「更多游戏」关注几个。"})]}),u!==null&&B&&V.length>0&&s.jsx(AU,{client:e,games:V,activities:u.activities,now:c,soonDays:u.settings.report.soonDays,onOpenGame:_,onChanged:()=>p(F=>F+1)}),u!==null&&P&&s.jsx(XU,{client:e,data:u,games:V,now:c,openSettings:n,onChanged:()=>p(F=>F+1)}),u!==null&&D!==void 0&&s.jsx(zU,{client:e,game:D,activities:u.activities.filter(F=>F.game===D.id),color:$.get(D.id)??Vi[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:F=>z({kind:"activity",id:F}),onAdd:()=>z({kind:"add",game:D.id}),onRefresh:()=>void R(D.id),onRead:()=>void C(`read:${D.id}`,async()=>{const{sessionId:F}=await e.connection.call("games/read",{game:D.id});t(F)}),onReadWeb:F=>void C(`read-web:${D.id}`,async()=>{const{sessionId:H}=await e.connection.call("games/read",{game:D.id,how:"web",...F===void 0?{}:{source:F}});t(H)}),onUnfollow:()=>void C(`unfollow:${D.id}`,async()=>(await e.connection.call("games/follow",{sra:D.id.replace(/^sra-/,""),follow:!1}),g(""),`不再关注${D.name}`)),onChanged:()=>p(F=>F+1),openSession:t,openScripts:()=>r("scripts")},D.id)]}),u!==null&&L!==null&&(()=>{const F=()=>p(W=>W+1);if(L.kind==="add"){const W=V.find(K=>K.id===L.game);return W===void 0?null:s.jsx(rk,{color:$.get(W.id)??Vi[0],label:"添加活动",onClose:U,children:s.jsx("div",{className:"dialog-form",children:s.jsx(Eg,{client:e,game:W,onCancel:U,onDone:K=>{z({kind:"activity",id:K.id,saved:K}),F()}})})})}const H=u.activities.find(W=>W.id===L.id)??L.saved;return H===void 0?null:s.jsx(rk,{color:$.get(H.game)??Vi[0],label:`${H.name}的详情`,onClose:U,children:s.jsx(GU,{client:e,activity:H,game:V.find(W=>W.id===H.game),now:c,soonDays:u.settings.report.soonDays,onClose:U,onChanged:F,openSession:t},H.id)})})()]})}function XU({client:e,data:t,games:n,now:r,openSettings:i,onChanged:o}){const c=t.settings.report,[u,h]=b.useState(null),[d,p]=b.useState(!1),[m,g]=b.useState(null),[x,y]=b.useState(null);b.useEffect(()=>{let w=!0;return e.connection.call("games/report/preview",{}).then(T=>{w&&h(T)}).catch(()=>{}),()=>{w=!1}},[e,t]);const E=async w=>{p(!0),g(null);try{await e.connection.call("games/settings/set",{report:w}),o()}catch(T){g(Re(T))}finally{p(!1)}},N=async()=>{p(!0),g(null),y(null);try{const{channels:w}=await e.connection.call("games/report/send",{});y(w.length===0?"没有发出去:还没有设置好的聊天渠道。":`已发到${w.join("、")}。`),o()}catch(w){g(Re(w))}finally{p(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"每日日报"}),s.jsx("p",{className:"muted small",children:"每天先读一遍数据站,再把各游戏的活动、剩余天数和没做完的事发到飞书。进度来自 agent 最近一次进游戏读取(可以在编排里加一个 agent 节点,日常跑完后读一次)。"})]}),s.jsx("span",{className:`badge ${c.enabled?"ok":""}`,children:c.enabled?"已开启":"未开启"})]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.enabled,disabled:d,onChange:w=>void E({enabled:w.target.checked})}),"每天定时发送"]}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:c.ai,disabled:d,onChange:w=>void E({ai:w.target.checked})}),"用 AI 总结,只说近期的事(刚开始、快结束、即将开始),语气按「设置 → 回复风格」;agent 不可用时发下面的完整列表"]}),s.jsxs("div",{className:"field-row",children:[s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"发送时间"}),s.jsx("input",{className:"text-input plain",type:"time",defaultValue:c.at,disabled:d,onBlur:w=>{/^\d{2}:\d{2}$/.test(w.target.value)&&w.target.value!==c.at&&E({at:w.target.value})}},c.at)]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"剩余几天以内标成「快结束」"}),s.jsx("input",{className:"text-input plain",type:"number",min:1,max:30,defaultValue:c.soonDays,disabled:d,onBlur:w=>{const T=Math.max(1,Math.min(30,Math.round(Number(w.target.value)||3)));T!==c.soonDays&&E({soonDays:T})}},c.soonDays)]})]}),s.jsx("div",{className:"field-title",children:"包括的游戏(都不选就是全部)"}),s.jsx("div",{className:"chip-row",children:n.map(w=>{const T=c.games.includes(w.id);return s.jsx("button",{className:`chip chip-button ${T?"active":""}`,disabled:d,onClick:()=>void E({games:T?c.games.filter(k=>k!==w.id):[...c.games,w.id]}),children:w.name},w.id)})}),s.jsxs("p",{className:"muted small",children:[t.report.lastSentAt===void 0?"还没发过。":`上次:${At(t.report.lastSentAt,r)}。`,t.report.lastResult===void 0?"":` ${t.report.lastResult}。`,c.enabled&&t.report.next!==void 0&&` 下一次:${new Date(t.report.next).toLocaleString("zh-CN",{hour12:!1,month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}。`," ",s.jsx("button",{className:"link-button",onClick:()=>i("feishu"),children:"远程连接"})]}),m!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:m})]})]}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"今天的日报"}),s.jsx("p",{className:"muted small",children:c.ai?"完整列表。发送时 agent 从里面挑出近期的事写成总结,写不出来就发这份。":"发到飞书的就是这份。"})]}),s.jsxs("button",{className:"small-button primary",disabled:d,onClick:()=>void N(),children:[s.jsx(Q,{name:"send"}),d?"发送中…":"现在发送"]})]}),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}),`
228
+
229
+ `,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:At(t.report.lastSentAt,r)})]})}),s.jsx("div",{className:"report-preview",children:t.report.lastText})]})]})}const QU={id:"games",title:"游戏看板",milestone:"M6",requires:["games"],pages:[{id:"games",title:"游戏",icon:"gamepad",order:-10,component:YU}]},JU={game:"游戏",script:"脚本",general:"通用"};function e5({client:e,focus:t,openSession:n,openSkill:r}){const i=Cn(6e4),o=je(e.capabilities),[c,u]=b.useState(null),[h,d]=b.useState({games:new Set,scripts:new Set}),[p,m]=b.useState(null),[g,x]=b.useState(null),[y,E]=b.useState(null),[N,w]=b.useState(null),[T,k]=b.useState(!1),I=async($=!1)=>{m($?"refresh":p);try{u(await e.connection.call("skillhub/list",$?{refresh:!0}:{})),x(null)}catch(P){x(Re(P))}finally{$&&m(null)}};b.useEffect(()=>{I()},[e]),b.useEffect(()=>e.connection.on("skillhub/changed",()=>void I()),[e]),b.useEffect(()=>{let $=!0;return(async()=>{var B,_;const P=o.has("games")?((B=await e.connection.call("games/list",{}).catch(()=>{}))==null?void 0:B.games.map(C=>C.id))??[]:[],D=o.has("scripts")?((_=await e.connection.call("scripts/list",{}).catch(()=>{}))==null?void 0:_.scripts.flatMap(C=>[C.id,C.packId,C.known].filter(R=>R!==void 0)))??[]:[];$&&d({games:new Set(P),scripts:new Set(D)})})(),()=>{$=!1}},[e,o.has("games"),o.has("scripts")]);const L=async($,P)=>{m($),x(null),E(null);try{const D=await P();typeof D=="string"&&E(D),await I()}catch(D){x(Re(D))}finally{m(null)}},z=$=>$.games.some(P=>h.games.has(P))||$.scripts.some(P=>h.scripts.has(P)),U=b.useMemo(()=>{const $=[...(c==null?void 0:c.items)??[]].sort((P,D)=>+(D.name===t)-+(P.name===t)||P.name.localeCompare(D.name));return[{label:"已下载",items:$.filter(P=>P.installed!==void 0)},{label:"推荐给你",hint:"你关注的游戏、装了的脚本",items:$.filter(P=>P.installed===void 0&&z(P))},{label:"其他",items:$.filter(P=>P.installed===void 0&&!z(P))}].filter(P=>P.items.length>0)},[c,h,t]),V=($,P)=>L(`update:${$.name}`,async()=>{const D=await e.connection.call("skillhub/update",{name:$.name,...P===void 0?{}:{resolve:P}});return w(null),D.state==="merging"&&D.sessionId!==void 0?(n(D.sessionId),"agent 正在合并,合并完会写回你的这份技能"):D.state==="conflict"?"你改过这个技能:选「保留我的」「用新版」或「让 agent 合并」":D.state==="kept"?"已保留你的版本,这个新版本不再提示":D.state==="updated"?D.backup===void 0?`${$.name} 已更新`:`${$.name} 已更新,你原来的那份备份在 ${D.backup}`:"已是最新"});return s.jsxs("div",{className:"skill-hub",children:[s.jsxs("section",{className:"card skill-hub-head",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"技能库"}),s.jsxs("p",{className:"muted small",children:["游戏和脚本的技能放在 ",(c==null?void 0:c.repos.map($=>$.repo).join("、"))??"MultiGameAssistant/skills",",按需下载;下载的可以改,更新时不会覆盖你的改动。软件自带的核心技能受保护,随软件更新。"]})]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:(c==null?void 0:c.fetchedAt)===void 0?"":`${At(c.fetchedAt,i)}读取`}),s.jsxs("button",{className:"small-button",disabled:p!==null,onClick:()=>void I(!0),children:[s.jsx(Q,{name:"refresh"}),p==="refresh"?"读取中…":"检查更新"]}),s.jsx("button",{className:"ghost small-button",onClick:()=>k($=>!$),children:"仓库"})]})]}),T&&c!==null&&s.jsx(t5,{repos:c.repos,disabled:p!==null,onSave:$=>L("repos",async()=>(await e.connection.call("skillhub/repos/set",{repos:$}),k(!1),await e.connection.call("skillhub/list",{refresh:!0}),"已保存,按新的仓库读取"))}),c==null?void 0:c.errors.map($=>s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["读不到:",$,c.items.length>0?"(下面是之前读到的)":""]})]},$))]}),y!==null&&s.jsx("div",{className:"notice info",children:y}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]}),c===null&&g===null&&s.jsx("p",{className:"muted",children:"正在读取技能库…"}),c!==null&&c.items.length===0&&c.errors.length===0&&s.jsx("p",{className:"muted",children:"技能库里还没有技能。"}),U.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(P=>{var D,B,_,C;return s.jsxs("li",{className:P.name===t?"focused":"",children:[s.jsxs("div",{className:"hub-main",children:[s.jsxs("div",{className:"hub-title",children:[s.jsx("strong",{children:P.title??P.name}),P.title!==void 0&&s.jsx("code",{className:"muted small",children:P.name}),s.jsx("span",{className:"badge",children:JU[P.kind]}),((D=P.installed)==null?void 0:D.modified)===!0&&s.jsx("span",{className:"badge",title:"你改过这个技能;更新时不会覆盖",children:"你改过"}),((B=P.installed)==null?void 0:B.update)===!0&&s.jsx("span",{className:"badge ok",children:"有新版"})]}),s.jsx("span",{className:"muted small",children:P.description}),P.blocked!==void 0&&s.jsxs("span",{className:"muted small",children:[P.blocked,",没有下载(以你已有的为准)"]})]}),s.jsxs("div",{className:"hub-actions",children:[P.installed===void 0&&P.blocked===void 0&&s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void L(`install:${P.name}`,async()=>(await e.connection.call("skillhub/install",{name:P.name,repo:P.repo}),`已下载 ${P.name},agent 现在就能用`)),children:p===`install:${P.name}`?"下载中…":"下载"}),((_=P.installed)==null?void 0:_.update)===!0&&P.installed.modified!==!0&&s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void V(P),children:"更新"}),((C=P.installed)==null?void 0:C.update)===!0&&P.installed.modified===!0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void L(`diff:${P.name}`,async()=>w({name:P.name,...await e.connection.call("skillhub/diff",{name:P.name})})),children:"看看哪里不同"}),s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void V(P,"keep"),children:"保留我的"}),s.jsx("button",{className:"small-button",disabled:p!==null,onClick:()=>void V(P,"replace"),children:"用新版"}),s.jsx("button",{className:"primary small-button",disabled:p!==null,onClick:()=>void V(P,"merge"),children:"让 agent 合并"})]}),P.installed!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"ghost small-button",onClick:()=>r(P.name),children:"查看"}),s.jsx("button",{className:"ghost small-button",disabled:p!==null,onClick:()=>void L(`remove:${P.name}`,async()=>(await e.connection.call("skillhub/remove",{name:P.name}),`已删除下载的 ${P.name}`)),children:"删除"})]})]}),(N==null?void 0:N.name)===P.name&&s.jsx(n5,{mine:N.mine,theirs:N.theirs,onClose:()=>w(null)})]},`${P.repo}/${P.name}`)})})]},$.label))]})}function t5({repos:e,disabled:t,onSave:n}){const[r,i]=b.useState(e.map(u=>u.branch==="main"?u.repo:`${u.repo}@${u.branch}`).join(`
230
+ `)),o=r.split(/\r?\n/).map(u=>u.trim()).filter(Boolean).map(u=>{const[h,d]=u.replace(/^https:\/\/github\.com\//,"").replace(/\.git$/,"").split("@");return{repo:h??"",branch:d??"main"}}),c=o.length>0&&o.every(u=>/^[\w.-]+\/[\w.-]+$/.test(u.repo)&&/^[\w./-]+$/.test(u.branch));return s.jsxs("div",{className:"hub-repos",children:[s.jsx("label",{className:"field-label",htmlFor:"hub-repos",children:"技能仓库(一行一个 owner/repo,可以写 @分支;前面的同名技能优先)"}),s.jsx("textarea",{id:"hub-repos",className:"text-input plain",rows:3,value:r,onChange:u=>i(u.target.value),spellCheck:!1}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"别的仓库里的技能会让 agent 照着做,只加你信得过的。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:t,onClick:()=>i("MultiGameAssistant/skills"),children:"恢复默认"}),s.jsx("button",{className:"primary small-button",disabled:t||!c,onClick:()=>n(o),children:"保存"})]})]})}function n5({mine:e,theirs:t,onClose:n}){const r=b.useMemo(()=>s5(e.split(/\r?\n/),t.split(/\r?\n/)),[e,t]);return s.jsxs("div",{className:"hub-diff",children:[s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[s.jsx("span",{className:"diff-del",children:"− 只在你的版本里"})," ",s.jsx("span",{className:"diff-add",children:"+ 只在新版本里"})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"ghost small-button",onClick:n,children:"收起"})]}),s.jsx("pre",{children:r.map((i,o)=>s.jsxs("div",{className:i.kind==="-"?"diff-del":i.kind==="+"?"diff-add":"muted",children:[i.kind," ",i.text]},o))})]})}function s5(e,t){var p;const n=e.length,r=t.length,i=Array.from({length:n+1},()=>new Array(r+1).fill(0));for(let m=n-1;m>=0;m--)for(let g=r-1;g>=0;g--)i[m][g]=e[m]===t[g]?i[m+1][g+1]+1:Math.max(i[m+1][g],i[m][g+1]);const o=[];let c=0,u=0;for(;c<n||u<r;)c<n&&u<r&&e[c]===t[u]?(o.push({kind:" ",text:e[c]}),c++,u++):u<r&&(c===n||i[c][u+1]>=i[c+1][u])?(o.push({kind:"+",text:t[u]}),u++):(o.push({kind:"-",text:e[c]}),c++);const h=m=>o.slice(Math.max(0,m-2),m+3).some(g=>g.kind!==" "),d=[];for(let m=0;m<o.length;m++)o[m].kind!==" "||h(m)?d.push(o[m]):((p=d.at(-1))==null?void 0:p.text)!=="…"&&d.push({kind:" ",text:"…"});return d}const r5=[{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 i5(e){var t;return e.removable===!0?"在这里存的":((t=r5.find(n=>n.match(e.source)))==null?void 0:t.label)??"其他"}const a5="通用",s_="adg:skills:folded";function o5(){try{return new Set(JSON.parse(localStorage.getItem(s_)??"[]"))}catch{return new Set}}function l5(e){try{localStorage.setItem(s_,JSON.stringify([...e]))}catch{}}const c5=e=>e.startsWith("game:")?"gamepad":e.startsWith("script:")?"package":"layers";function u5({client:e,arg:t,openSession:n}){var re,ie,ye,De;const r=je(e.connection.status),i=je(e.capabilities),[o,c]=b.useState((t==null?void 0:t.startsWith("hub"))===!0?"hub":"mine"),u=(t==null?void 0:t.startsWith("hub:"))===!0?t.slice(4):void 0,[h,d]=b.useState(null),[p,m]=b.useState(""),[g,x]=b.useState(t??""),[y,E]=b.useState(null),[N,w]=b.useState(null),[T,k]=b.useState(0),[I,L]=b.useState(!1),[z,U]=b.useState(null),[V,$]=b.useState(o5),[P,D]=b.useState(!1),B=de=>$(Se=>{const ae=new Set(Se);return ae.delete(de)||ae.add(de),l5(ae),ae}),_=((re=Um(e).data)==null?void 0:re.scripts)??[],[C,R]=b.useState([]);b.useEffect(()=>{t!==void 0&&(t.startsWith("hub")?c("hub"):(c("mine"),x(t)))},[t]),b.useEffect(()=>e.connection.on("skills/changed",()=>k(de=>de+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!i.has("games"))return;let de=!0;return e.connection.call("games/list",{}).then(Se=>{de&&R(Se.games)},()=>{}),()=>{de=!1}},[e,r.state,i]),b.useEffect(()=>{if(r.state!=="open")return;let de=!0;return e.connection.call("skills/list",{}).then(Se=>{de&&(d(Se.skills),w(null))},Se=>{de&&w(Re(Se))}),()=>{de=!1}},[e,r.state,T,o]);const M=p.trim().toLowerCase(),F=b.useMemo(()=>(h??[]).filter(de=>M===""||`${de.name} ${de.description} ${de.whenToUse??""}`.toLowerCase().includes(M)),[h,M]),H=b.useMemo(()=>{const de=new Map,Se=(Ae,tt,et)=>{const jt=de.get(Ae)??{key:Ae,label:tt,items:[],subs:[],...et};return de.set(Ae,jt),jt},ae=Ae=>Se(`game:${Ae.id}`,Ae.name,{game:Ae.id}),pe=(Ae,tt)=>{const et=Ae.subs.find(jt=>jt.script===tt.id)??{key:`${Ae.key}/${tt.id}`,label:tt.name,script:tt.id,items:[]};return Ae.subs.includes(et)||Ae.subs.push(et),et},Le=(Ae,tt)=>{Ae.includes(tt)||Ae.push(tt)};if(M===""){for(const Ae of C)ae(Ae);for(const Ae of _){const tt=ON(Ae,C);tt===void 0?Se(`script:${Ae.id}`,Ae.name,{script:Ae.id}):pe(ae(tt),Ae)}}for(const Ae of F){const tt=Gp(Ae.owner,_,C);tt.length===0&&Le(Se("general",a5,{}).items,Ae);for(const et of tt)et.game!==void 0&&et.script!==void 0?Le(pe(ae(et.game),et.script).items,Ae):et.game!==void 0?Le(ae(et.game).items,Ae):et.script!==void 0&&Le(Se(`script:${et.script.id}`,et.script.name,{script:et.script.id}).items,Ae)}const Te=(Ae,tt)=>Ae.name.localeCompare(tt.name),Ge=Ae=>Ae.key.startsWith("game:")?0:Ae.key.startsWith("script:")?1:2;return[...de.values()].map(Ae=>({...Ae,items:Ae.items.sort(Te),subs:Ae.subs.map(tt=>({...tt,items:tt.items.sort(Te)})).sort((tt,et)=>tt.label.localeCompare(et.label))})).sort((Ae,tt)=>Ge(Ae)-Ge(tt)||Ae.label.localeCompare(tt.label))},[F,_,C,M]),W=H.flatMap(de=>[...de.items,...de.subs.flatMap(Se=>Se.items)])[0],K=F.find(de=>de.name===g)??W;b.useEffect(()=>{if(D(!1),K===void 0){E(null);return}let de=!0;return L(!1),e.connection.call("skills/get",{name:K.name}).then(Se=>{de&&E(Se)},Se=>{de&&w(Re(Se))}),()=>{de=!1}},[e,K==null?void 0:K.name,T]);const q=de=>{var Se;(Se=navigator.clipboard)==null||Se.writeText(`/${de} `).then(()=>L(!0),()=>{})},Y=async de=>{if(confirm(`删除技能「${de.name}」?它的文件夹会一起删掉,agent 以后就用不到它了。`))try{await e.connection.call("skills/remove",{name:de.name}),x(""),k(Se=>Se+1)}catch(Se){w(Re(Se))}},fe=de=>[...new Set(Gp(de.owner,_,C).map(zN))],me=de=>({name:"",description:"",content:"",scripts:de.script===void 0?[]:[de.script],games:de.script===void 0&&de.game!==void 0?[de.game]:[]}),xe=de=>s.jsxs("button",{className:`script-row skill-row ${z===null&&(K==null?void 0:K.name)===de.name?"active":""}`,onClick:()=>{U(null),x(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),oe=(de,Se,ae)=>s.jsx("button",{className:"icon-button skills-add",title:ae,"aria-label":`在${de}下新建技能`,disabled:r.state!=="open",onClick:()=>U(me(Se)),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:o==="hub"?"技能库":"agent 的技能"})]}),s.jsxs("div",{className:"page-actions",children:[i.has("skillhub")&&s.jsxs("div",{className:"tabs",role:"tablist",children:[s.jsx("button",{role:"tab","aria-selected":o==="mine",className:o==="mine"?"active":"",onClick:()=>c("mine"),children:"已有的技能"}),s.jsx("button",{role:"tab","aria-selected":o==="hub",className:o==="hub"?"active":"",onClick:()=>c("hub"),children:"技能库"})]}),o==="mine"&&s.jsxs("button",{className:"small-button",disabled:r.state!=="open",onClick:()=>U(me({})),children:[s.jsx(Q,{name:"plus"}),"新建技能"]}),o==="mine"&&s.jsxs("button",{className:"small-button",onClick:()=>k(de=>de+1),children:[s.jsx(Q,{name:"refresh"}),"刷新"]})]})]}),o==="hub"&&i.has("skillhub")?s.jsx("div",{className:"skill-hub-body",children:s.jsx(e5,{client:e,focus:u,openSession:n,openSkill:de=>{x(de),c("mine")}})}):s.jsxs("div",{className:"scripts-body",children:[s.jsxs("aside",{className:"scripts-list","aria-label":"技能列表",children:[s.jsxs("div",{className:"skills-search",children:[s.jsx(Q,{name:"search"}),s.jsx("input",{className:"text-input",value:p,onChange:de=>m(de.target.value),placeholder:"搜索技能","aria-label":"搜索技能"})]}),h!==null&&M!==""&&s.jsx("p",{className:"muted small skills-found",children:F.length===0?"没有匹配的技能。":`找到 ${F.length} 个技能`}),h!==null&&M===""&&F.length===0&&s.jsx("p",{className:"muted small pad",children:"还没有技能。"}),H.map(de=>{const Se=M!==""||!V.has(de.key);return s.jsxs("div",{className:`skills-group ${Se?"":"folded"}`,children:[s.jsxs("div",{className:"skills-section-head",children:[s.jsxs("button",{className:"skills-fold","aria-expanded":Se,onClick:()=>B(de.key),children:[s.jsx(Q,{name:"chevron-down",className:"skills-chevron"}),s.jsx(Q,{name:c5(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(ae=>ae.items)]).size})]}),oe(de.label,de,de.game!==void 0?`给游戏「${de.label}」新建一个技能(处理这个游戏的对话都能用)`:de.script!==void 0?`给「${de.label}」新建一个技能(只给它用)`:"新建一个通用技能")]}),Se&&s.jsxs(s.Fragment,{children:[de.items.map(xe),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(ae=>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:ae.label}),s.jsx("span",{className:"skills-count",children:ae.items.length}),s.jsx("span",{className:"spacer"}),oe(ae.label,{script:ae.script},`给「${ae.label}」新建一个技能(只给它用)`)]}),ae.items.length===0&&s.jsx("p",{className:"muted small skills-empty",children:"还没有只给它用的技能"}),ae.items.map(xe)]},ae.key))]})]},de.key)})]}),s.jsx("div",{className:"scripts-detail",children:s.jsxs("div",{className:"script-detail",children:[N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:N})]}),z!==null?s.jsx(d5,{client:e,draft:z,scripts:_,games:C,onCancel:()=>U(null),onSaved:de=>{U(null),x(de),w(null),k(Se=>Se+1)}}):s.jsxs(s.Fragment,{children:[h===null&&N===null&&s.jsx("p",{className:"muted",children:"正在读取…"}),h!==null&&K===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:r.state!=="open",onClick:()=>U(me({})),children:[s.jsx(Q,{name:"plus"}),"新建技能"]})]}),K!==void 0&&s.jsxs("article",{className:"card skill-card",children:[s.jsxs("header",{className:"skill-top",children:[s.jsxs("div",{className:"skill-title",children:[s.jsx("h2",{children:K.name}),s.jsxs("div",{className:"skill-meta",children:[fe(K).length===0?s.jsxs("span",{className:"badge",title:"所有对话都看得到、用得了",children:[s.jsx(Q,{name:"layers"}),"通用"]}):s.jsxs("span",{className:"badge warn",title:"技能隔离:只有在处理这些游戏或脚本的对话里,agent 才看得到、用得了这个技能",children:[s.jsx(Q,{name:(ye=(ie=K.owner)==null?void 0:ie.scripts)!=null&&ye.length?"package":"gamepad"}),"只给 ",fe(K).join("、")," 用"]}),K.modelInvocable&&s.jsx("span",{className:"badge ok",title:"agent 遇到相关的事会自己读这个技能",children:"agent 自动使用"}),s.jsxs("span",{className:"badge",title:K.removable===!0?"存在这个软件的技能文件夹里,可以编辑和删除":`在这里不能改和删${K.source==="hub"?",到「技能库」里卸载":""}`,children:[i5(K),K.removable===!0?"":" · 只读"]})]})]}),s.jsxs("div",{className:"skill-buttons",children:[K.userInvocable&&s.jsxs("button",{className:"small-button",onClick:()=>q(K.name),title:"复制后粘贴到对话框,后面写要它做的事",children:[s.jsx(Q,{name:I?"check":"copy"}),I?"已复制":`/${K.name}`]}),(K.removable===!0||K.source==="hub")&&s.jsxs("button",{className:"small-button","aria-expanded":P,onClick:()=>D(de=>!de),title:"放错了游戏或脚本时,换到对的那个",children:[s.jsx(Q,{name:"gamepad"}),"更换游戏和脚本"]}),K.removable===!0&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"small-button",disabled:(y==null?void 0:y.name)!==K.name,onClick:()=>{var de,Se;return U({original:K.name,name:K.name,description:K.description,content:(y==null?void 0:y.content)??"",scripts:[...((de=K.owner)==null?void 0:de.scripts)??[]],games:[...((Se=K.owner)==null?void 0:Se.games)??[]]})},children:[s.jsx(Q,{name:"pencil"}),"编辑"]}),s.jsx("button",{className:"small-button danger-outline",onClick:()=>void Y(K),children:"删除"})]}),K.path!==void 0&&((De=wr())==null?void 0:De.openPath)!==void 0&&s.jsx("button",{className:"icon-button skill-folder",title:`打开所在文件夹:${K.path}`,"aria-label":"打开所在文件夹",onClick:()=>{var de,Se;return void((Se=(de=wr())==null?void 0:de.openPath)==null?void 0:Se.call(de,K.path.replace(/[\\/][^\\/]+$/,"")))},children:s.jsx(Q,{name:"layers"})})]})]}),P&&s.jsx(h5,{client:e,skill:K,content:(y==null?void 0:y.name)===K.name?y.content:void 0,scripts:_,games:C,onCancel:()=>D(!1),onMoved:()=>{D(!1),w(null),k(de=>de+1)}},K.name),s.jsx("p",{className:"skill-desc",children:K.description}),K.whenToUse!==void 0&&s.jsxs("p",{className:"muted small",children:["什么时候用:",K.whenToUse]}),s.jsxs("section",{className:"skill-body","aria-label":"技能内容",children:[s.jsx("div",{className:"skill-body-label",children:"技能内容"}),(y==null?void 0:y.name)===K.name?s.jsx(Nr,{text:y.content}):s.jsx("p",{className:"muted",children:"正在读取…"})]}),K.path!==void 0&&s.jsx("code",{className:"muted small skill-path",title:K.path,children:K.path})]})]})]})})]})]})}function d5({client:e,draft:t,scripts:n,games:r,onCancel:i,onSaved:o}){const[c,u]=b.useState(t),[h,d]=b.useState(!1),[p,m]=b.useState(null);b.useEffect(()=>{u(t),m(null)},[t]);const g=t.original!==void 0,x=iN.test(c.name)&&c.name.length<=$p,y=x&&c.description.trim().length>=10&&c.content.trim().length>=20,E=async()=>{d(!0),m(null);try{await e.connection.call("skills/save",{name:c.name,description:c.description.trim(),content:c.content.trim(),...c.scripts.length===0?{}:{scripts:c.scripts},...c.games.length===0?{}:{games:c.games},...g?{replace:!0}:{}}),o(c.name)}catch(N){m(Re(N))}finally{d(!1)}};return s.jsxs("article",{className:"card skill-card skill-form",children:[s.jsx("div",{className:"skill-head",children:s.jsx("h2",{children:g?`编辑 ${t.original}`:"新建技能"})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:"名字(在对话里用 /名字 调用它)"}),s.jsx("input",{className:"text-input",value:c.name,disabled:g,maxLength:$p,autoFocus:!g,onChange:N=>u(w=>({...w,name:N.target.value.trim().toLowerCase()})),placeholder:"例:maa-daily-check"}),c.name!==""&&!x&&s.jsx("span",{className:"error small",children:"只能用小写英文字母、数字和短横线,例如 maa-daily-check"})]}),s.jsx(r_,{scripts:n,games:r,value:c,onChange:N=>u(w=>({...w,...N}))}),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:N=>u(w=>({...w,description:N.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:N=>u(w=>({...w,content:N.target.value}))})]}),p!==null&&s.jsx("p",{className:"error small",children:p}),s.jsxs("div",{className:"skill-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:h,onClick:i,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:h||!y,onClick:()=>void E(),children:h?"保存中…":"保存"})]})]})}function r_({scripts:e,games:t,value:n,onChange:r}){const[i]=b.useState(n),o=[...new Set([...i.scripts,...n.scripts])].filter(p=>!e.some(m=>m.id===p)),c=[...new Set([...i.games,...n.games])].filter(p=>qp(p,t)===void 0),u=(p,m)=>{var g;return p===m||((g=qp(p,t))==null?void 0:g.id)===m},h=p=>r({...n,scripts:n.scripts.includes(p)?n.scripts.filter(m=>m!==p):[...n.scripts,p]}),d=p=>r({...n,games:n.games.some(m=>u(m,p))?n.games.filter(m=>!u(m,p)):[...n.games,p]});return s.jsxs(s.Fragment,{children:[(t.length>0||c.length>0)&&s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个游戏用(和游戏本身有关、换个脚本也用得上的:游戏里的操作、界面、活动、机制)"}),s.jsxs("div",{className:"skill-owner-list",children:[t.map(p=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.games.some(m=>u(m,p.id)),onChange:()=>d(p.id)}),p.name]},p.id)),c.map(p=>s.jsxs("label",{className:"check-label",title:"游戏页上没有这个游戏",children:[s.jsx("input",{type:"checkbox",checked:n.games.includes(p),onChange:()=>d(p)}),p]},p))]})]}),s.jsxs("fieldset",{className:"field skill-owners",children:[s.jsx("legend",{className:"field-label",children:"给哪个脚本用(只在用这个脚本时才用得上的做法:它的配置、报错、日志)"}),e.length===0&&o.length===0&&s.jsx("span",{className:"muted small",children:"还没有装脚本。"}),s.jsxs("div",{className:"skill-owner-list",children:[e.map(p=>s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(p.id),onChange:()=>h(p.id)}),p.name]},p.id)),o.map(p=>s.jsxs("label",{className:"check-label",title:"这个脚本不在脚本库里(删掉了,或是脚本包 id)",children:[s.jsx("input",{type:"checkbox",checked:n.scripts.includes(p),onChange:()=>h(p)}),p]},p))]})]}),s.jsx("p",{className:"muted small",children:"游戏和脚本都不选就是通用技能,所有对话都能用。"})]})}function h5({client:e,skill:t,content:n,scripts:r,games:i,onCancel:o,onMoved:c}){var E,N;const[u,h]=b.useState({scripts:[...((E=t.owner)==null?void 0:E.scripts)??[]],games:[...((N=t.owner)==null?void 0:N.games)??[]]}),[d,p]=b.useState(!1),[m,g]=b.useState(null),x=t.source==="hub",y=async w=>{p(!0),g(null);try{if(x)await e.connection.call("skillhub/owner",{name:t.name,owner:w});else{if(n===void 0||w===null)return;await e.connection.call("skills/save",{name:t.name,description:t.description,content:n,replace:!0,...w.scripts.length===0?{}:{scripts:w.scripts},...w.games.length===0?{}:{games:w.games}})}c()}catch(T){g(Re(T))}finally{p(!1)}};return s.jsxs("div",{className:"skill-move",role:"group","aria-label":"更换游戏和脚本",children:[s.jsx(r_,{scripts:r,games:i,value:u,onChange:h}),x&&s.jsx("p",{className:"muted small",children:"这是从技能库下载的技能:你选的会一直保留,技能库更新它也不变。"}),m!==null&&s.jsx("p",{className:"error small",children:m}),s.jsxs("div",{className:"skill-actions",children:[x&&s.jsx("button",{className:"link-button small",disabled:d,onClick:()=>void y(null),children:"恢复成技能库里的"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:d,onClick:o,children:"取消"}),s.jsx("button",{className:"small-button primary",disabled:d||!x&&n===void 0,onClick:()=>void y(u),children:d?"保存中…":"保存"})]})]})}const f5={id:"skills",title:"技能",requires:["skills"],pages:[{id:"skills",title:"技能",icon:"sparkles",order:50,agent:"scripts",component:u5}]};function p5({client:e}){const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(0),[c,u]=b.useState(null),[h,d]=b.useState(null),[p,m]=b.useState(""),[g,x]=b.useState("");b.useEffect(()=>e.connection.on("emulators/changed",()=>o(N=>N+1)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let N=!0;return e.connection.call("emulators/status",{refresh:i===0}).then(w=>{N&&(r(w),m(w.settings.manualAddress??""),x(w.settings.adbPath??""))}).catch(w=>{N&&d(Re(w))}),()=>{N=!1}},[e,t.state,i]);const y=async(N,w)=>{u(N),d(null);try{await w(),o(T=>T+1)}catch(T){d(Re(T))}finally{u(null)}},E=N=>y("settings",()=>e.connection.call("emulators/settings/set",N));return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模拟器"}),s.jsx("p",{children:"需要安卓模拟器的任务(如 MAA)运行前,会自动启动这里选定的实例并取得 ADB 地址。分辨率请设为 16:9(如 1280×720)。"}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"当前使用"}),s.jsx("p",{className:"muted small",children:(n==null?void 0:n.selection.label)??"…"})]}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y("refresh",()=>e.connection.call("emulators/status",{refresh:!0})),children:"重新检测"})]}),(n==null?void 0:n.selection.problem)!==void 0&&s.jsxs("div",{className:"notice info left small",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:[n.selection.problem,"。可以对 agent 说「安装 MuMu 模拟器」,或在下面填写手动 ADB 地址。"]})]})]}),n==null?void 0:n.providers.map(N=>s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsxs("h3",{children:[N.name,N.version===void 0?"":` ${N.version}`]}),s.jsx("p",{className:"muted small",children:N.manager})]}),n.settings.mumuManager===N.manager&&s.jsx("span",{className:"badge ok",children:"已指定"})]}),N.error!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:N.error})]}),s.jsx("ul",{className:"version-list",children:N.instances.map(w=>s.jsxs("li",{className:w.index===n.settings.instance?"current":"",children:[s.jsx("span",{className:"version-name",children:w.index}),s.jsx("span",{children:w.name}),s.jsx("span",{className:`badge ${w.ready?"ok":""}`,children:w.ready?"已启动":w.running?"启动中":"未运行"}),w.adb!==void 0&&s.jsx("span",{className:"muted small",children:w.adb}),s.jsx("span",{className:"spacer"}),w.index!==n.settings.instance&&s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void E({instance:w.index}),children:"任务用这个"}),w.ready?s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`stop-${w.index}`,()=>e.connection.call("emulators/stop",{index:w.index})),children:"关闭"}):s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void y(`start-${w.index}`,()=>e.connection.call("emulators/start",{index:w.index})),children:c===`start-${w.index}`?"启动中…":"启动"})]},w.index))})]},N.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:N=>void E({autoStart:N.target.checked})}),"任务需要时自动启动模拟器"]}),s.jsx("label",{className:"field-label",htmlFor:"manual-adb",children:"手动 ADB 地址(其他模拟器或真机,可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"manual-adb",className:"text-input plain",value:p,onChange:N=>m(N.target.value),placeholder:"例如 127.0.0.1:5555;填写后不再管理 MuMu",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void E({manualAddress:p.trim()===""?null:p.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"adb-path",children:"adb.exe 位置(可选,出错时重连模拟器、截图用;默认用 MuMu 自带的)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"adb-path",className:"text-input plain",value:g,onChange:N=>x(N.target.value),placeholder:"例如 D:\\platform-tools\\adb.exe",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:c!==null,onClick:()=>void E({adbPath:g.trim()===""?null:g.trim()}),children:"保存"})]}),s.jsx("label",{className:"field-label",htmlFor:"boot-timeout",children:"等待安卓启动的最长时间(秒)"}),s.jsx("input",{id:"boot-timeout",className:"text-input plain",type:"number",min:30,max:900,defaultValue:n.settings.bootTimeoutSeconds,onBlur:N=>void E({bootTimeoutSeconds:Math.max(30,Math.min(900,Number(N.target.value)||180))})})]}),h!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]})]})}function m5({client:e}){const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(""),[h,d]=b.useState(""),[p,m]=b.useState(null),[g,x]=b.useState(!1),[y,E]=b.useState(null),[N,w]=b.useState(null),T=()=>e.connection.call("scripts/settings",{}).then(z=>{r(z),o(z)}).catch(z=>w(Re(z)));if(b.useEffect(()=>{t.state==="open"&&T()},[e,t.state]),i===null||n===null)return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),N===null?s.jsx("p",{children:"加载中…"}):s.jsx("div",{className:"notice error left",children:N})]});const k=(z,U)=>o({...i,[z]:U}),I=async()=>{x(!0),w(null),E(null);try{const{tokenConfigured:z,cdkConfigured:U,...V}=n,$=Object.fromEntries(Object.entries(i).filter(([P,D])=>V[P]!==D));Object.keys($).length>0&&await e.connection.call("scripts/settings/set",$),c.trim()!==""&&await e.connection.call("credentials/set",{ref:i.tokenRef,value:c.trim()}),u(""),h.trim()!==""&&(await e.connection.call("credentials/set",{ref:i.cdkRef,value:h.trim()}),d(""),L()),await T(),E("已保存,下一次安装起生效")}catch(z){w(Re(z))}finally{x(!1)}},L=async()=>{m("checking");try{m(await e.connection.call("scripts/mirrorchyan/check",{}))}catch(z){m({ok:!1,message:Re(z)})}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"脚本安装"}),s.jsx("p",{children:"从 GitHub 发布页下载脚本时使用的设置。国内网络下载慢或失败时,可以填写下载镜像前缀。"}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"下载镜像"}),s.jsx("input",{className:"text-input plain",value:i.downloadMirror,onChange:z=>k("downloadMirror",z.target.value),placeholder:"留空直接下载;例如 https://ghfast.top/",spellCheck:!1}),s.jsx("p",{className:"muted small",children:"镜像只用于 GitHub 上的文件:下载地址前面加上这个前缀。微软、Google 等官方组件始终直接下载。"}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:i.mirrorFallback,onChange:z=>k("mirrorFallback",z.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:h,onChange:z=>d(z.target.value),placeholder:n.cdkConfigured?"已配置;输入新值可替换":"在 Mirror酱 购买后得到的 CDK",autoComplete:"off"}),n.cdkConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"}),n.cdkConfigured&&s.jsx("button",{className:"small-button",disabled:p==="checking",onClick:()=>void L(),children:p==="checking"?"检查中…":"检查"})]}),p!==null&&p!=="checking"&&s.jsx("p",{className:"small",style:{color:p.ok?"var(--ok)":"var(--error)"},children:p.message}),s.jsxs("p",{className:"muted small",children:["保存在 dsh 的凭据文件里(",i.cdkRef,"),界面和日志里都不会显示它。"]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"GitHub 访问"}),s.jsx("label",{className:"field-label",htmlFor:"gh-token",children:"GitHub Token(可选)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:"gh-token",className:"text-input",type:"password",value:c,onChange:z=>u(z.target.value),placeholder:n.tokenConfigured?"已配置;输入新值可替换":"不填也能用;填写后请求上限从每小时 60 次提高到 5000 次",autoComplete:"off"}),n.tokenConfigured?s.jsx("span",{className:"badge ok",children:"已配置"}):s.jsx("span",{className:"badge",children:"未配置"})]}),s.jsxs("p",{className:"muted small",children:["只需要读取公开仓库的权限。保存在 dsh 的凭据文件里(",i.tokenRef,"),界面不会显示它的内容。"]}),s.jsx("label",{className:"field-label",htmlFor:"gh-api",children:"API 地址"}),s.jsx("input",{id:"gh-api",className:"text-input plain",value:i.apiBase,onChange:z=>k("apiBase",z.target.value),spellCheck:!1})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"版本"}),s.jsx("label",{className:"field-label",htmlFor:"keep-versions",children:"每个脚本保留的版本数(含当前版本)"}),s.jsx("input",{id:"keep-versions",className:"text-input plain",type:"number",min:1,max:10,value:i.keepVersions,onChange:z=>k("keepVersions",Math.max(1,Math.min(10,Number(z.target.value)||1)))}),s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:i.includePrereleases,onChange:z=>k("includePrereleases",z.target.checked)}),"没有正式版时使用预发布版本"]})]}),s.jsxs("div",{className:"key-actions",children:[y!==null&&s.jsx("span",{className:"muted small",children:y}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",disabled:g,onClick:()=>void I(),children:g?"保存中…":"保存"})]}),N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:N})]})]})}function g5({client:e,initialRepo:t,jobs:n,onDone:r,openSession:i,onClose:o}){const[c,u]=b.useState(t??""),[h,d]=b.useState(null),[p,m]=b.useState(""),[g,x]=b.useState(""),[y,E]=b.useState(!1),[N,w]=b.useState(null),[T,k]=b.useState(null),I=async($=c)=>{var D;const P=NM($);if(P===void 0){w("请输入 owner/repo,或粘贴 GitHub 上的仓库、发布或文件链接");return}E(!0),w(null);try{const B=await e.connection.call("scripts/releases",{repo:P.repo,limit:10});u(P.repo),d({...B,branch:P.branch});const _=B.releases.find(R=>R.tag===P.tag),C=_??B.releases.find(R=>!R.prerelease)??B.releases[0];m((C==null?void 0:C.tag)??""),x(((D=C==null?void 0:C.assets.find(R=>R.name===P.asset))==null?void 0:D.name)??(C==null?void 0:C.suggestedAsset)??""),P.tag!==void 0&&_===void 0&&B.releases.length>0&&w(`最近的发布里没有 ${P.tag},已改选最新版本`)}catch(B){d(null),w(Re(B))}finally{E(!1)}};b.useEffect(()=>{t!==void 0&&I(t)},[t]);const L=h==null?void 0:h.releases.find($=>$.tag===p),z=h!==null&&(h.branch!==void 0||h.releases.length===0),U=async()=>{if(h!==null){E(!0),w(null);try{const{jobId:$,scriptId:P}=await e.connection.call("scripts/install",{repo:h.repo,...h.branch===void 0?{}:{branch:h.branch}});k({jobId:$,scriptId:P,tag:h.branch===void 0?"默认分支":`${h.branch} 分支`,asset:"源码压缩包"})}catch($){w(Re($))}finally{E(!1)}}},V=async()=>{var $;if(!(h===null||L===void 0||g==="")){E(!0),w(null);try{const{jobId:P,scriptId:D}=await e.connection.call("scripts/install",{repo:h.repo,tag:L.tag,asset:g});k({jobId:P,scriptId:D,tag:L.tag,asset:g,size:($=L.assets.find(B=>B.name===g))==null?void 0:$.size})}catch(P){w(Re(P))}finally{E(!1)}}};if(T!==null&&h!==null){const $=n.get(T.scriptId);return s.jsx(i_,{client:e,repo:h.repo,...T,job:($==null?void 0:$.id)===T.jobId?$:void 0,onDone:()=>r(T.scriptId),openSession:i,onRetry:()=>k(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:$=>{$.preventDefault(),I()},children:[s.jsx("input",{className:"text-input plain","aria-label":"GitHub 仓库",value:c,onChange:$=>u($.target.value),placeholder:"owner/repo 或 GitHub 链接,例如 MaaAssistantArknights/MaaAssistantArknights",spellCheck:!1,disabled:y}),s.jsx("button",{type:"submit",disabled:y||c.trim()==="",children:y&&h===null?"读取中…":"读取发布"})]}),z&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:h.branch!==void 0?`链接指向 ${h.branch} 分支:会下载这个分支当前的源码,之后跟着它更新。`:"这个仓库还没有发布版本:可以下载默认分支当前的源码,之后跟着这个分支更新。"}),s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:h.releases.length===0?"primary":"",onClick:()=>void U(),disabled:y,children:["安装",h.branch===void 0?"源码":` ${h.branch} 分支`]})]}),h!==null&&h.releases.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"field-label",htmlFor:"release-select",children:["版本",h.packId!==void 0&&s.jsxs("span",{className:"chip subtle",children:["内置脚本包 ",h.packId]})]}),s.jsx(yn,{id:"release-select",value:p,disabled:y,onChange:$=>{var P;m($),x(((P=h.releases.find(D=>D.tag===$))==null?void 0:P.suggestedAsset)??"")},options:h.releases.map($=>({value:$.tag,label:`${$.tag}${$.prerelease?"(预发布)":""}`,...$.publishedAt===void 0?{}:{hint:`${$.publishedAt.slice(0,10)} 发布`}}))}),L!==void 0&&s.jsxs("fieldset",{className:"asset-list",disabled:y,children:[s.jsx("legend",{className:"field-label",children:"下载文件"}),L.assets.length===0&&s.jsx("div",{className:"muted small",children:"这个版本没有可下载的文件"}),[...L.assets].sort(($,P)=>+(P.name===L.suggestedAsset)-+($.name===L.suggestedAsset)).map($=>s.jsxs("label",{className:`asset-option ${$.name===g?"active":""}`,children:[s.jsx("input",{type:"radio",name:"asset",value:$.name,checked:$.name===g,onChange:()=>x($.name)}),s.jsx("span",{className:"asset-name",children:$.name}),$.name===L.suggestedAsset&&s.jsx("span",{className:"badge ok",children:"推荐"}),s.jsx("span",{className:"muted small",children:ka($.size)})]},$.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 V(),disabled:y||g==="",children:["安装 ",L==null?void 0:L.tag]})]})]}),N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:N})]})]})}function x5({client:e,initialRid:t,jobs:n,onDone:r,openSession:i,onGitHub:o,onClose:c}){const[u,h]=b.useState(""),d=v5(e,u),[p,m]=b.useState(null),[g,x]=b.useState(null),[y,E]=b.useState(!1),[N,w]=b.useState(null),[T,k]=b.useState(null);b.useEffect(()=>{e.connection.call("scripts/settings",{}).then(V=>x(V.cdkConfigured),()=>x(null))},[e]);const I=async V=>{E(!0),w(null);try{m(await e.connection.call("scripts/mirrorchyan/lookup",{rid:V}))}catch($){m(null),w(Re($))}finally{E(!1)}};b.useEffect(()=>{t!==void 0&&I(t)},[t]);const L=async()=>{if(p!==null){E(!0),w(null);try{k(await e.connection.call("scripts/install",{mirrorchyan:p.rid}))}catch(V){w(Re(V))}finally{E(!1)}}};if(T!==null&&p!==null){const V=n.get(T.scriptId);return s.jsx(i_,{client:e,repo:`Mirror酱 · ${p.rid}`,tag:p.version,asset:`${p.name??p.rid}(Mirror酱 完整包)`,job:(V==null?void 0:V.id)===T.jobId?V:void 0,onDone:()=>r(T.scriptId),openSession:i,onRetry:()=>k(null),onClose:c})}const z=u.trim(),U=/^[\w.-]{1,100}$/.test(z)&&!(d.items??[]).some(V=>V.rid.toLowerCase()===z.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:V=>h(V.target.value),placeholder:"例如 原神、鸣潮、BetterGI、MAA",spellCheck:!1,autoFocus:!0}),s.jsx(y5,{results:d,selected:p==null?void 0:p.rid,disabled:y,onPick:V=>void I(V)}),U&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsxs("button",{className:"small-button",disabled:y,onClick:()=>void I(z),children:["按资源 id 查询 ",z]})]}),p!==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:p.name??p.rid}),s.jsxs("span",{className:"badge",children:["Mirror酱 ",p.rid]}),s.jsxs("span",{className:"muted small",children:["最新 ",p.version]})]}),p.description!==void 0&&s.jsx("p",{className:"muted small mirror-desc",children:p.description}),g===!1&&s.jsx("div",{className:"notice info left small",children:s.jsxs("span",{children:["还没有填写 Mirror酱 CDK,没法从 Mirror酱 下载。",p.repo!==void 0?"也可以从 GitHub 安装,填了 CDK 后它的更新会走 Mirror酱。":""]})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:p.repo===void 0?"":`GitHub:${p.repo}`}),s.jsx("span",{className:"spacer"}),p.repo!==void 0&&s.jsx("button",{className:"small-button",disabled:y,onClick:()=>o(p.repo),children:"从 GitHub 安装"}),s.jsxs("button",{className:"primary",onClick:()=>void L(),disabled:y||g===!1,children:["安装 ",p.version]})]})]}),N!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:N})]})]})}function v5(e,t){const[n,r]=b.useState({loading:!0});return b.useEffect(()=>{let i=!0;r(c=>({...c,loading:!0}));const o=setTimeout(()=>{e.connection.call("scripts/mirrorchyan/search",{query:t.trim()}).then(c=>{i&&r({items:c.items,from:c.from,loading:!1})}).catch(c=>{i&&r({error:Re(c),loading:!1})})},t.trim()===""?0:250);return()=>{i=!1,clearTimeout(o)}},[e,t]),n}function y5({results:e,selected:t,disabled:n,limit:r=8,onPick:i,pickLabel:o="选择"}){const[c,u]=b.useState(!1);if(e.error!==void 0)return s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:e.error})]});const h=e.items??[];if(h.length===0)return s.jsx("div",{className:"muted small mirror-empty",children:e.loading?"查找中…":"没有找到。可以换个说法(游戏简称、英文名),或直接输入资源 id。"});const d=c?h:h.slice(0,r);return s.jsxs(s.Fragment,{children:[e.from==="builtin"&&s.jsx("div",{className:"muted small mirror-empty",children:"读不到 Mirror酱 的项目列表,下面是已知的几个;也可以直接输入资源 id 查询。"}),s.jsx("ul",{className:"mirror-results",children:d.map(p=>s.jsxs("li",{className:p.rid===t?"active":"",children:[s.jsxs("div",{className:"mirror-result-main",children:[s.jsxs("span",{className:"mirror-result-name",children:[p.name,s.jsx("span",{className:"chip subtle",children:p.rid}),p.installed&&s.jsx("span",{className:"badge ok",children:"已在脚本库"})]}),p.description!==""&&s.jsx("span",{className:"muted small",children:p.description})]}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>i(p.rid),children:o})]},p.rid))}),!c&&h.length>r&&s.jsxs("button",{className:"link-button small",onClick:()=>u(!0),children:["还有 ",h.length-r," 个"]})]})}const ik=["resolving","downloading","verifying","extracting","checking","done"];function i_({client:e,repo:t,tag:n,asset:r,size:i,job:o,onDone:c,openSession:u,onRetry:h,onClose:d}){const p=(o==null?void 0:o.phase)??"queued",m=p==="done"?o==null?void 0:o.setup:void 0,g=o===void 0||o.endedAt===void 0,x=b5(o==null?void 0:o.received),y=(o==null?void 0:o.total)??i,E=y!==void 0&&y>0&&(o==null?void 0:o.received)!==void 0?Math.min(1,o.received/y):void 0,N=b.useRef(-1),w=ik.indexOf(p);w>N.current&&(N.current=w);const T=m!==void 0?"交给 agent 安装":p==="done"?"安装完成":p==="failed"?"安装失败":p==="cancelled"?"已取消安装":"正在安装",k=I=>p==="done"||I<N.current?"done":I===N.current?g?"active":"stopped":"todo";return s.jsxs("section",{className:"card panel-card install-progress","aria-live":"polite",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:T}),s.jsxs("p",{className:"muted small",children:[t," · ",n]})]}),s.jsx("button",{className:"icon-button","aria-label":"关闭",title:g?"关掉面板,安装在后台继续(左边列表里能看到进度)":"关闭",onClick:d,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:r}),i!==void 0&&s.jsx("span",{className:"muted small",children:ka(i)})]}),s.jsx("ol",{className:"install-steps",children:ik.slice(0,-1).map((I,L)=>{const z=k(L);return s.jsxs("li",{className:`install-step ${z}`,children:[s.jsx("span",{className:"install-step-mark",children:z==="done"?s.jsx(Q,{name:"check"}):z==="stopped"?s.jsx(Q,{name:"close"}):L+1}),s.jsx("span",{children:sd[I]})]},I)})}),g&&s.jsxs("div",{className:"install-bar",children:[s.jsx("div",{className:`progress ${p==="downloading"&&E!==void 0?"":"indeterminate"}`,"aria-hidden":"true",children:s.jsx("span",{style:p==="downloading"&&E!==void 0?{width:`${(E*100).toFixed(1)}%`}:void 0})}),s.jsxs("div",{className:"install-numbers muted small",children:[s.jsx("span",{children:o===void 0?"等待开始…":o.message??sd[p]}),p==="downloading"&&(o==null?void 0:o.received)!==void 0&&s.jsxs("span",{className:"install-bytes",children:[ka(o.received),y!==void 0?` / ${ka(y)}`:"",E!==void 0?` · ${Math.floor(E*100)}%`:"",x!==void 0?` · ${ka(Math.round(x))}/s`:"",x!==void 0&&x>0&&y!==void 0?` · 还要 ${k5((y-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})]}),m!==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:g?"可以关掉这个面板,安装会在后台继续。":m!==void 0?`下载好了 ${(o==null?void 0:o.version)??n} 的安装程序。`:p==="done"?`已安装 ${(o==null?void 0:o.version)??n}。`:""}),s.jsx("span",{className:"spacer"}),g&&o!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:o.id}).catch(()=>{}),children:"取消安装"}),(p==="failed"||p==="cancelled")&&s.jsx("button",{className:"small-button",onClick:h,children:"重新选择"}),(m==null?void 0:m.sessionId)!==void 0&&s.jsx("button",{className:"primary small-button",onClick:()=>u(m.sessionId),children:"查看对话"}),p==="done"&&m===void 0&&s.jsx("button",{className:"primary small-button",onClick:c,children:"查看脚本"})]})]})}function b5(e){const t=b.useRef([]),[n,r]=b.useState(void 0);return b.useEffect(()=>{if(e===void 0)return;const i=Date.now(),o=[...t.current.filter(u=>i-u.at<=4e3&&u.bytes<=e),{at:i,bytes:e}];t.current=o;const c=o[0];i-c.at>=500&&r((e-c.bytes)/((i-c.at)/1e3))},[e]),n}function k5(e){return!Number.isFinite(e)||e<0?"—":e<60?`${Math.max(1,Math.round(e))} 秒`:`${Math.floor(e/60)} 分 ${Math.round(e%60)} 秒`}function N5({client:e,onImported:t,onClose:n}){const[r,i]=b.useState(""),[o,c]=b.useState(""),[u,h]=b.useState(!1),[d,p]=b.useState(null),m=async()=>{h(!0),p(null);try{const g=await e.connection.call("scripts/import",{path:r.trim().replace(/^"|"$/g,""),...o.trim()===""?{}:{name:o.trim()}});t(g.id)}catch(g){p(Re(g)),h(!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:g=>{g.preventDefault(),m()},children:[s.jsx("label",{className:"field-label",htmlFor:"import-path",children:"目录路径"}),s.jsx("input",{id:"import-path",className:"text-input plain",value:r,onChange:g=>i(g.target.value),placeholder:"例如 D:\\Games\\MAA",spellCheck:!1,disabled:u}),s.jsx("label",{className:"field-label",htmlFor:"import-name",children:"显示名称(可选)"}),s.jsx("input",{id:"import-name",className:"text-input plain",value:o,onChange:g=>c(g.target.value),placeholder:"留空则按脚本包或目录名",disabled:u}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:"会按内置脚本包自动识别是哪个脚本。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary",type:"submit",disabled:u||r.trim()==="",children:u?"导入中…":"导入"})]})]}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]})]})}function wm({client:e,job:t,compact:n=!1}){const r=t.endedAt===void 0,i=t.total!==void 0&&t.total>0&&t.received!==void 0?Math.min(1,t.received/t.total):void 0,o=t.kind==="env-fix"?"修复环境":t.kind==="update"?"更新":"安装";return s.jsxs("div",{className:`job ${t.phase}${n?" compact":""}`,role:"status",children:[s.jsxs("div",{className:"job-line",children:[s.jsxs("span",{className:"job-phase",children:[o," · ",t.setup!==void 0&&t.phase==="done"?"已交给 agent 安装":sd[t.phase],t.version!==void 0&&t.phase==="done"?` ${t.version}`:""]}),i!==void 0&&r&&s.jsxs("span",{className:"job-bytes",children:[ka(t.received??0)," / ",ka(t.total??0)]}),r&&s.jsx("button",{className:"link-button",onClick:()=>void e.connection.call("scripts/jobs/cancel",{jobId:t.id}).catch(()=>{}),children:"取消"})]}),r&&s.jsx("div",{className:`progress ${i===void 0?"indeterminate":""}`,"aria-hidden":"true",children:s.jsx("span",{style:i===void 0?void 0:{width:`${(i*100).toFixed(1)}%`}})}),!n&&t.message!==void 0&&(r||t.setup!==void 0)&&s.jsx("div",{className:"job-message muted small",children:t.message}),t.error!==void 0&&s.jsx("div",{className:"job-error small",children:t.error})]})}const w5={install:"安装来源",pack:"脚本包",known:"已知项目",user:"你设置的"};function a_({client:e,script:t,disabled:n,act:r}){const[i,o]=b.useState(null),[c,u]=b.useState(""),[h,d]=b.useState(null),p=t.channels.github,m=t.channels.mirrorchyan,g=(N,w)=>r("channel",async()=>{await e.connection.call("scripts/source/set",w==="reset"?{id:t.id,reset:[N]}:N==="repo"?{id:t.id,repo:w}:{id:t.id,mirrorchyan:w}),o(null);const T=N==="repo"?"GitHub":"Mirror酱";return w===null?`已不再从 ${T} 更新`:w==="reset"?`${T} 更新渠道已恢复自动`:`${T} 更新渠道已设为 ${w}`}),x=()=>r("mirror-match",async()=>{const N=await e.connection.call("scripts/mirrorchyan/match",{id:t.id});return d({items:N.items,checked:!0}),N.items.length===0?`Mirror酱 上没有找到它${N.from==="builtin"?"(读不到 Mirror酱 的项目列表,只查了已知的)":""};知道资源 id 的话可以直接「设置」`:void 0}),y=(N,w)=>N==="repo"?/^[\w.-]+\/[\w.-]+$/.test(w):/^[\w.-]{1,100}$/.test(w),E=(N,w,T,k,I)=>s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:w}),s.jsx("dd",{children:i!==N?s.jsxs(s.Fragment,{children:[T!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:T.text}),s.jsxs("span",{className:"muted small",children:["(",w5[T.from],")"]})]}):s.jsx("span",{className:"muted small",children:k}),(T==null?void 0:T.from)!=="install"&&s.jsx("button",{className:"ghost small-button",disabled:n,onClick:()=>{u((T==null?void 0:T.text)??""),o(N)},children:T===void 0?"设置":"修改"}),N==="mirrorchyan"&&T===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":`${w}更新渠道`,value:c,onChange:L=>u(L.target.value),placeholder:I,spellCheck:!1,autoFocus:!0}),s.jsx("button",{className:"primary small-button",disabled:n||!y(N,c.trim()),onClick:()=>void g(N,c.trim()),children:N==="mirrorchyan"?"查询并保存":"保存"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g(N,"reset"),children:"恢复自动"}),T!==void 0&&s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g(N,null),children:"不用"}),s.jsx("button",{className:"ghost small-button",onClick:()=>o(null),children:"取消"})]})})]});return s.jsxs(s.Fragment,{children:[E("repo","GitHub",p===void 0?void 0:{text:p.repo,from:p.from},"未设置:填写它的 GitHub 仓库","owner/repo,例如 babalae/better-genshin-impact"),E("mirrorchyan","Mirror酱",m===void 0?void 0:{text:m.rid,from:m.from},"未设置:在 Mirror酱 发布的脚本填它的资源 id","资源 id,例如 BGI、MAA"),m===void 0&&h!==null&&h.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酱 上可能是它:"}),h.items.slice(0,5).map(N=>s.jsxs("span",{className:"mirror-match",children:[s.jsx("span",{children:N.name}),s.jsx("span",{className:"chip subtle",children:N.rid}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void g("mirrorchyan",N.rid).then(()=>d(null)),children:"用这个"})]},N.rid))]})]})]})}function j5({client:e,script:t,disabled:n,busy:r,now:i,act:o}){const[c,u]=b.useState(!1),h=t.localVersion,d=t.update,p=t.channels.github!==void 0||t.channels.mirrorchyan!==void 0;return s.jsxs("div",{className:"local-update",children:[s.jsxs("dl",{className:"local-facts",children:[s.jsx("dt",{children:"当前版本"}),s.jsx("dd",{children:h!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"version-name",children:h.version}),s.jsx("span",{className:"muted small",children:h.from==="更新"?"(由 MultiGameAssistant 更新)":`(读自 ${h.from})`})]}):s.jsx("span",{className:"muted small",children:"认不出这个目录的版本:检查更新时会当作可以更新"})}),s.jsx(a_,{client:e,script:t,disabled:n,act:o})]}),c?s.jsxs("div",{className:"local-confirm",children:[s.jsxs("p",{className:"small",children:["将在 ",s.jsx("code",{children:t.dir})," 里更新到 ",d==null?void 0:d.latest,":被替换的程序文件先备份到工具目录(可以撤销),已有的配置文件不动。请先关闭这个脚本。"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>u(!1),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:n,onClick:()=>void o("update",async()=>(u(!1),(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0)),children:"确认更新"})]})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[d===void 0?"还没有检查过更新":d.available?`有新版本 ${d.latest}`:`已是最新(${d.latest})`,d!==void 0&&` · ${At(d.checkedAt,i)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n||!p,onClick:()=>void o("check",async()=>{const m=await e.connection.call("scripts/checkUpdate",{id:t.id});return m.available?`发现新版本 ${m.latest}${m.current===void 0?"(认不出当前版本)":`,当前 ${m.current}`}`:"已是最新版本"}),children:r==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:n||(d==null?void 0:d.available)!==!0,onClick:()=>u(!0),children:"更新"})]}),t.undo!==void 0&&s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["上次更新:",t.undo.from??"(未知版本)"," → ",t.undo.to," · ",At(t.undo.at,i)]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:n,onClick:()=>void o("restore",async()=>{const m=await e.connection.call("scripts/restore",{id:t.id});return`已撤销,换回了更新前的文件${m.localVersion===void 0?"":`(${m.localVersion.version})`}`}),children:r==="restore"?"撤销中…":"撤销上次更新"})]})]})}function S5({client:e,script:t,openSession:n}){var z,U,V;const r=je(e.connection.status),i=je(e.capabilities),o=Cn(6e4),[c,u]=b.useState([]),[h,d]=b.useState(0),[p,m]=b.useState(!1),[g,x]=b.useState(null),[y,E]=b.useState(null);b.useEffect(()=>e.connection.on("packs/changed",()=>d($=>$+1)),[e]),b.useEffect(()=>{if(r.state!=="open"||!i.has("packs"))return;let $=!0;return e.connection.call("packs/drafts",{scriptId:t.id}).then(P=>{$&&u(P.items)}).catch(()=>{}),()=>{$=!1}},[e,t.id,r.state,i,h]);const N=async $=>{m(!0),x(null);try{await $()}catch(P){x(Re(P))}finally{m(!1)}},w=()=>N(async()=>{const{sessionId:$}=await e.connection.call("sessions/create",{focus:{scripts:[t.id]}});await e.connection.call("session/prompt",{sessionId:$,requestId:`analyze-${Date.now()}`,mode:"queue",text:`请按 script-analysis 技能分析脚本库里的「${t.name}」(id: ${t.id}),${t.packId===void 0?"为它生成":"检查并改进它的"}脚本包:先找到并读完这个项目自己的文档(目录里的说明、仓库 README、Wiki、文档站),再结合代码核对补全,实在没有文档才直接看代码。用 pack_propose 提交草稿,docs 里写明依据的文档。`}),n($)}),T=$=>N(async()=>{const{sessionId:P}=await e.connection.call("scripts/packReview",{id:t.id,decision:$});P!==void 0&&n(P)}),k=$=>N(async()=>{const{sessionId:P}=await e.connection.call("scripts/optimize",{id:t.id,decision:$});P!==void 0&&n(P)}),I=c[0],L=(z=t.optimize)==null?void 0:z.due;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"脚本包"}),s.jsx("p",{className:"muted small",children:t.packId===void 0?"还没有脚本包:agent 还不知道怎么运行它。":`使用脚本包 ${t.packId}。`})]}),s.jsxs("span",{className:"key-actions",children:[t.packId!==void 0&&s.jsxs("button",{className:"small-button",disabled:p||r.state!=="open",onClick:()=>void k("run"),title:"用运行攒下的信息:重新总结脚本包、调「多久没动静算卡住」、把走通的步骤存成只给它用的技能",children:[s.jsx(Q,{name:"sparkles"}),"优化脚本"]}),s.jsxs("button",{className:"small-button",disabled:p||r.state!=="open",onClick:()=>void w(),children:[s.jsx(Q,{name:"sparkles"}),t.packId===void 0?"让 agent 分析":"让 agent 改进"]})]})]}),t.packReview!==void 0&&I===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:p,onClick:()=>void T("keep"),children:"不用改"}),s.jsx("button",{className:"primary small-button",disabled:p||r.state!=="open",onClick:()=>void T("check"),children:"让 agent 检查"})]})]}),L!==void 0&&t.packReview===void 0&&I===void 0&&s.jsxs("div",{className:"notice left pack-review",children:[s.jsx(Q,{name:"sparkles"}),s.jsxs("span",{children:[L==="updated"?`${t.name} 更新后已经跑通了。`:`${t.name} ${((U=t.optimize)==null?void 0:U.at)===void 0?"装好以来":"上次优化以来"}已经跑成功 ${((V=t.optimize)==null?void 0:V.runs)??0} 次。`,"要让 agent 用这些运行记录优化它吗:重新总结脚本包、调卡住时间、把走通的步骤存成技能。"]}),s.jsxs("span",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void k("keep"),children:"这次不用"}),s.jsx("button",{className:"primary small-button",disabled:p||r.state!=="open",onClick:()=>void k("run"),children:"优化脚本"})]})]}),I!==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:[At(I.proposedAt,o),"提交 · 任务:",I.tasks.map($=>$.title).join("、")||"无"]})]}),s.jsx("p",{className:"draft-summary",children:I.summary}),I.docs!==void 0&&I.docs.length>0&&s.jsxs("details",{className:"draft-docs",children:[s.jsxs("summary",{className:"muted small",children:["依据的文档(",I.docs.length,")"]}),s.jsx("ul",{children:I.docs.map($=>s.jsxs("li",{children:[s.jsx("code",{children:$.source}),":",$.used]},$.source))})]}),I.noDocs!==void 0&&s.jsxs("p",{className:"muted small",children:["没有找到项目文档,按代码分析:",I.noDocs]}),I.current!==void 0&&s.jsxs("p",{className:"muted small",children:["接受后会替换当前的",I.current.builtin?"内置":"","脚本包(之前的版本会保留在历史里)。"]}),s.jsxs("div",{className:"segmented draft-tabs",children:[s.jsxs("label",{className:y==="manifest"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="manifest",onChange:()=>E($=>$==="manifest"?null:"manifest")}),"adg.script.yaml"]}),s.jsxs("label",{className:y==="skill"?"active":"",children:[s.jsx("input",{type:"checkbox",checked:y==="skill",onChange:()=>E($=>$==="skill"?null:"skill")}),"SKILL.md"]})]}),y!==null&&s.jsx("pre",{className:"draft-text",children:y==="manifest"?I.manifest:I.skill}),s.jsxs("div",{className:"key-actions",children:[I.sessionId!==void 0&&s.jsx("button",{className:"link-button",onClick:()=>n(I.sessionId),children:"查看分析过程"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:p,onClick:()=>void N(()=>e.connection.call("packs/reject",{packId:I.packId})),children:"拒绝"}),s.jsx("button",{className:"primary small-button",disabled:p,onClick:()=>void N(()=>e.connection.call("packs/accept",{packId:I.packId})),children:"接受并使用"})]})]}),g!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:g})]})]})}function _5({client:e,script:t}){const n=je(e.connection.status),r=Cn(15e3),[i,o]=b.useState(void 0),[c,u]=b.useState(0),[h,d]=b.useState(30),[p,m]=b.useState(null);b.useEffect(()=>e.connection.on("guard/changed",()=>u(y=>y+1)),[e]),b.useEffect(()=>{if(n.state!=="open")return;let y=!0;return e.connection.call("guard/grants",{}).then(E=>{y&&o(E.items.find(N=>N.scriptId===t.id))}).catch(()=>{}),()=>{y=!1}},[e,t.id,n.state,c]);const g=i!==void 0&&i.expiresAt>r?i:void 0,x=y=>{m(null),y().catch(E=>m(Re(E)))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"修改脚本文件"}),s.jsx("p",{className:"muted small",children:"默认禁止:agent 只能改脚本包声明的配置文件、只能用官方更新。确实需要改代码时,在这里临时允许。"})]}),g===void 0?s.jsx("span",{className:"badge ok",children:"受保护"}):s.jsx("span",{className:"badge warn",children:"已允许"})]}),g===void 0?s.jsxs("div",{className:"key-actions",children:[s.jsxs("label",{className:"check-label",children:["允许 agent 修改",s.jsx(yn,{inline:!0,"aria-label":"允许多久",value:String(h),onChange:y=>d(Number(y)),options:[15,30,60,120].map(y=>({value:String(y),label:`${y} 分钟`}))})]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>x(()=>e.connection.call("guard/grant",{scriptId:t.id,minutes:h})),children:"临时允许"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:["还剩约 ",Math.max(1,Math.round((g.expiresAt-r)/6e4))," 分钟"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",onClick:()=>x(()=>e.connection.call("guard/revoke",{scriptId:t.id})),children:"立即收回"})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:p})]})]})}function E5({client:e,script:t}){const n=je(e.connection.status),r=Cn(6e4),i=rj(e,t.id),[o,c]=b.useState(void 0),[u,h]=b.useState(null),[d,p]=b.useState(0),[m,g]=b.useState(null),[x,y]=b.useState(null),[E,N]=b.useState(null),[w,T]=b.useState(!1),[k,I]=b.useState(null),[L,z]=b.useState(null),[U,V]=b.useState(null),$=(i==null?void 0:i.items.find(M=>M.id===o))??(i==null?void 0:i.items.find(M=>M.id===i.current));b.useEffect(()=>{g(null),N(null)},[$==null?void 0:$.id]),b.useEffect(()=>e.connection.on("runs/state",M=>{M.scriptId!==t.id||M.endedAt===void 0||(p(F=>F+1),V(F=>F===null||F.runId!==M.id?F:(I(M.state==="succeeded"?`修改已同步到「${F.profile}」`:M.state==="cancelled"?"已放弃这次修改,本地配置没变":`没能保存修改:${M.outcome??"脚本窗口异常退出"}`),null)))}),[e,t.id]);const P=async M=>{if(U!==null){V({...U,finishing:M});try{M==="done"?await e.connection.call("configs/done",{runId:U.runId}):await e.connection.call("runs/stop",{runId:U.runId})}catch(F){z(Re(F)),V(null)}}};b.useEffect(()=>{if(n.state!=="open"||$===void 0)return;let M=!0;return e.connection.call("configs/status",{scriptId:t.id,profile:$.id}).then(F=>{M&&(h(F),z(null))}).catch(F=>{M&&z(Re(F))}),()=>{M=!1}},[e,t.id,t.packId,n.state,d,$==null?void 0:$.id]);const D=async M=>{T(!0),z(null),I(null);try{const F=await M();typeof F=="string"&&I(F),p(H=>H+1)}catch(F){z(Re(F))}finally{T(!1)}},B=((i==null?void 0:i.items.length)??0)>1,_=$!==void 0&&$.id===(i==null?void 0:i.current),C=(u==null?void 0:u.files.filter(M=>M.local))??[],R=u!==null&&u.profile.id===($==null?void 0:$.id)?u:null;return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"配置"}),s.jsx("p",{className:"muted small",children:"通过本应用运行时,用的是本地保存的配置;原项目里的配置不会被改动,你自己打开脚本时仍是它原来的设置。可以存几份(比如两个账号),运行和编排时选用哪一份。"})]}),s.jsxs("button",{className:"small-button",disabled:w||U!==null||n.state!=="open"||$===void 0,onClick:()=>void D(async()=>{const M=await e.connection.call("configs/open",{scriptId:t.id,profile:$.id});if(M.endedAt===void 0)V({runId:M.id,profile:$.name,finishing:null});else if(M.state!=="succeeded")throw new Error(M.outcome??"没能打开脚本的设置界面")}),children:[s.jsx(Q,{name:"settings"}),"打开脚本修改设置"]})]}),i!==null&&(B||((u==null?void 0:u.files.length)??0)>0)&&s.jsxs("div",{className:"profile-bar",children:[s.jsxs("div",{className:"profile-chips",role:"tablist","aria-label":"配置",children:[i.items.map(M=>s.jsxs("button",{role:"tab","aria-selected":M.id===($==null?void 0:$.id),className:`profile-chip ${M.id===($==null?void 0:$.id)?"active":""}`,onClick:()=>c(M.id),children:[M.name,M.id===i.current&&B&&s.jsx("span",{className:"profile-current",title:"不指定配置的运行都用它",children:"当前使用"})]},M.id)),s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>y(M=>M===null?{name:"",source:"copy",dir:""}:null),children:"+ 另存一份"})]}),$!==void 0&&B&&E===null&&s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:_?"运行时没有指定配置就用这一份":"在编排或运行时选它才会用到"}),s.jsx("span",{className:"spacer"}),!_&&s.jsx("button",{className:"small-button",disabled:w,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:$.id,current:!0}),`现在默认使用「${$.name}」`)),children:"设为当前使用"}),s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>N($.name),children:"改名"}),$.id!=="default"&&(m==="remove"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"用了这份配置的编排步骤会运行失败"}),s.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),s.jsx("button",{className:"danger-outline small-button",disabled:w,onClick:()=>void D(async()=>(await e.connection.call("configs/profiles/remove",{scriptId:t.id,profile:$.id}),g(null),c(void 0),`已删除「${$.name}」`)),children:"确认删除"})]}):s.jsx("button",{className:"ghost small-button",disabled:w,onClick:()=>g("remove"),children:"删除"}))]}),$!==void 0&&E!==null&&s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain","aria-label":"新名字",value:E,maxLength:30,autoFocus:!0,onChange:M=>N(M.target.value)}),s.jsx("button",{className:"small-button",onClick:()=>N(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w||E.trim()==="",onClick:()=>void D(async()=>{await e.connection.call("configs/profiles/update",{scriptId:t.id,profile:$.id,name:E.trim()}),N(null)}),children:"保存"})]}),x!==null&&$!==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:M=>y({...x,name:M.target.value})}),s.jsxs("fieldset",{className:"asset-list",disabled:w,children:[s.jsx("legend",{className:"field-label",children:"内容从哪里来"}),[["copy",`复制「${$.name}」`,"复制后可以「打开脚本修改设置」单独改它"],["original","读取原项目现在的配置","在脚本自己的界面里设好了另一套设置时用"],["folder","从别的文件夹读取",`另一份同样的脚本,或存下来的配置;只读 ${(u==null?void 0:u.files.map(M=>M.file).join("、"))||"脚本包声明的配置文件"}`]].map(([M,F,H])=>s.jsxs("label",{className:`asset-option choice-option ${x.source===M?"active":""}`,children:[s.jsx("input",{type:"radio",name:"profile-source",value:M,checked:x.source===M,onChange:()=>y({...x,source:M})}),s.jsxs("span",{className:"choice-text",children:[s.jsx("span",{children:F}),s.jsx("span",{className:"muted small",children:H})]})]},M))]}),x.source==="folder"&&s.jsx("input",{className:"text-input plain","aria-label":"文件夹",placeholder:"文件夹的完整路径,例如 D:\\MAA2",value:x.dir,onChange:M=>y({...x,dir:M.target.value})}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w||x.name.trim()===""||x.source==="folder"&&x.dir.trim()==="",onClick:()=>void D(async()=>{const M=x.source==="copy"?{kind:"copy",profile:$.id}:x.source==="original"?{kind:"original"}:{kind:"folder",dir:x.dir.trim()},F=await e.connection.call("configs/profiles/create",{scriptId:t.id,name:x.name.trim(),from:M});return y(null),c(F.profile.id),`已保存「${F.profile.name}」:${F.files.length>0?F.files.join("、"):"还没有配置文件"}`}),children:"保存"})]})]})]}),R!==null&&s.jsxs(s.Fragment,{children:[R.drift.length>0&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(Q,{name:"info"}),s.jsxs("span",{children:["原项目的配置在导入后改过(",R.drift.join("、"),"),可能是在脚本自己的界面里改的。本应用仍按「",R.profile.name,"」运行;需要的话可以导入。"]})]}),s.jsx(_a,{id:`config.files.${t.id}`,title:"配置文件",count:R.files.length,children:s.jsxs("ul",{className:"version-list",children:[R.files.map(M=>s.jsx(C5,{client:e,scriptId:t.id,profile:R.profile.id,file:M},`${R.profile.id}:${M.file}`)),R.files.length===0&&s.jsx("li",{className:"muted small",children:"脚本包没有声明配置文件"})]})}),s.jsxs("div",{className:"key-actions",children:[s.jsxs("span",{className:"muted small",children:[R.importedAt===void 0?"还没有导入":`${At(R.importedAt,r)}${B?`存的「${R.profile.name}」`:"从原项目导入"}`,C.length>0&&" · ",C.length>0&&s.jsx("button",{className:"link-button",onClick:()=>{var M;return void((M=navigator.clipboard)==null?void 0:M.writeText(R.dir))},children:"复制本地配置目录"})]}),s.jsx("span",{className:"spacer"}),m!=="import"?s.jsx("button",{className:"small-button",disabled:w,onClick:()=>g("import"),children:"导入原项目设置"}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"muted small",children:["会用原项目当前的配置覆盖「",R.profile.name,"」"]}),s.jsx("button",{className:"small-button",onClick:()=>g(null),children:"取消"}),s.jsx("button",{className:"primary small-button",disabled:w,onClick:()=>void D(async()=>{const M=await e.connection.call("configs/import",{scriptId:t.id,profile:R.profile.id});return g(null),M.imported.length>0?`已导入到「${R.profile.name}」:${M.imported.join("、")}`:"原项目里还没有这些配置文件"}),children:"确认导入"})]})]})]}),k!==null&&s.jsx("div",{className:"notice info left small",children:k}),U!==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," 的设置窗口已经打开,用的是本地配置「",U.profile,"」。在那个窗口里改好、保存后,回到这里点「我已手动改好」:脚本窗口会关闭,修改同步到「",U.profile,"」,之后的运行和编排都用它。"]}),s.jsx("p",{className:"muted small",children:"直接关掉脚本窗口也会保存。原项目里的配置不会被改动。"}),U.finishing!==null&&s.jsxs("p",{className:"dialog-progress",children:[s.jsx("span",{className:"tool-spinner","aria-hidden":!0}),U.finishing==="done"?"正在关闭脚本窗口并保存修改…":"正在关闭脚本窗口,不保存…"]}),s.jsxs("div",{className:"key-actions",children:[s.jsx("button",{className:"small-button",disabled:U.finishing!==null,onClick:()=>void P("discard"),children:"放弃修改"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"primary small-button",disabled:U.finishing!==null,onClick:()=>void P("done"),children:U.finishing==="done"?"保存中…":"我已手动改好"})]})]})}),L!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:L})]})]})}function C5({client:e,scriptId:t,profile:n,file:r}){const[i,o]=b.useState(!1),[c,u]=b.useState(null),[h,d]=b.useState(null),p=()=>{o(m=>!m),!(c!==null||!r.local)&&e.connection.call("configs/read",{scriptId:t,file:r.file,profile:n}).then(u,m=>d(Re(m)))};return s.jsxs("li",{className:`config-file ${i?"open":""}`,children:[s.jsxs("button",{type:"button",className:"config-file-head","aria-expanded":i,onClick:p,disabled:!r.local,title:r.local?"展开看本地配置的内容":"本地还没有这个文件",children:[s.jsx(Q,{name:"chevron",className:`fold-chevron ${i?"open":""}`}),s.jsx("span",{className:"version-name",children:r.file}),r.local?s.jsx("span",{className:"badge ok",children:"本地已保存"}):s.jsx("span",{className:"badge",children:"本地没有"}),r.changed&&s.jsx("span",{className:"badge warn",children:"原项目已改动"}),!r.original&&s.jsx("span",{className:"muted small",children:"原项目里没有"})]}),i&&(h!==null?s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h})]}):c===null?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsxs("pre",{className:"config-preview",children:[c.content,c.truncated?`
231
+ …(太长,只显示前一部分)`:""]}))]})}function A5({client:e,scriptId:t,scriptName:n,openSession:r}){const i=je(e.connection.status),[o,c]=b.useState(null),[u,h]=b.useState(""),[d,p]=b.useState(""),[m,g]=b.useState(""),[x,y]=b.useState(!1),[E,N]=b.useState(null),[w,T]=b.useState(!1),[k,I]=b.useState(null),[L,z]=b.useState(!1);b.useEffect(()=>{if(i.state!=="open")return;let R=!0;return e.connection.call("configs/launch",{scriptId:t}).then(M=>{R&&(c(M),h(M.settings.pcExe??""),p(M.settings.pcProcess??""),g(M.settings.androidPackage??""))}).catch(M=>{R&&N(Re(M))}),()=>{R=!1}},[e,t,i.state]);const U=async R=>{y(!0),N(null),T(!1);try{c(await e.connection.call("configs/launch/set",{scriptId:t,...R})),T(!0)}catch(M){N(Re(M))}finally{y(!1)}},V=async R=>{h(R),await U({pcExe:R})},$=async()=>{z(!0),N(null),T(!1),I(null);try{const R=await e.connection.call("configs/launch/locate",{scriptId:t});I(R),R.candidates.length===1&&await V(R.candidates[0].path)}catch(R){N(Re(R))}finally{z(!1)}},P=async()=>{N(null);try{const{sessionId:R}=await e.connection.call("sessions/create",{focus:{scripts:[t]}});await e.connection.call("session/prompt",{sessionId:R,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;没找到就在各个磁盘上搜索名为 ${(k==null?void 0:k.exe)??(o==null?void 0:o.game.pcProcess)??"游戏进程名"} 的程序(可以问我装在哪个盘)。找到后告诉我路径和你怎么确认的,再用 game_path_set 保存。`}),r(R)}catch(R){N(Re(R))}},D=async()=>{const R=wr();if(R===void 0)return;const M=await R.pickFile({title:"选择游戏程序",defaultPath:u.trim()===""?void 0:u.trim(),filterName:"程序",extensions:["exe"]});M!==null&&await V(M)};if(o===null)return E===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:E})]})});const{settings:B,game:_,uses:C}=o;return!C.adb&&!C.desktop?null:s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:["启动游戏",_.name===void 0?"":`:${_.name}`]}),s.jsxs("p",{className:"muted small",children:["有的脚本不会自己打开游戏或模拟器。运行前,本应用会先启动模拟器(模拟器任务),再按这里的设置启动游戏;游戏已经开着、或脚本自己会启动时不会重复启动。",_.selfLaunch,"。"]})]})}),s.jsx("label",{className:"field-label",htmlFor:`launch-mode-${t}`,children:"运行前由谁启动游戏"}),s.jsx(yn,{id:`launch-mode-${t}`,value:B.mode,disabled:x,onChange:R=>void U({mode:R}),options:[{value:"auto",label:"自动(推荐)",hint:"脚本自己不会启动游戏时,由本应用启动"},{value:"platform",label:"总是由本应用启动",hint:"游戏没开时先打开它"},{value:"off",label:"不启动",hint:"交给脚本或我自己"}]}),B.mode!=="off"&&C.adb&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-pkg-${t}`,children:"模拟器里的游戏包名(模拟器任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-pkg-${t}`,className:"text-input plain",value:m,onChange:R=>g(R.target.value),placeholder:_.androidPackage??"例如 com.example.game(不填就不在模拟器里启动游戏)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void U({androidPackage:m.trim()===""?null:m.trim()}),children:"保存"})]}),_.androidPackage!==void 0&&s.jsxs("p",{className:"muted small",children:["默认 ",_.androidPackage,";B 服、国际服等版本的包名不同时在这里改。"]})]}),B.mode!=="off"&&C.desktop&&s.jsxs(s.Fragment,{children:[s.jsx("label",{className:"field-label",htmlFor:`launch-exe-${t}`,children:"PC 游戏程序位置(占用鼠标键盘的任务)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-exe-${t}`,className:"text-input",value:u,onChange:R=>h(R.target.value),placeholder:"例如 D:\\Games\\Endfield\\Endfield.exe(也可以是游戏启动器)",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void U({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 $(),children:L?"正在查找…":"自动查找"}),wr()!==void 0&&s.jsx("button",{className:"small-button",disabled:x||L,onClick:()=>void D(),children:"选择文件…"}),s.jsx("button",{className:"link-button small",disabled:L,onClick:()=>void P(),children:"让 agent 找"})]}),k!==null&&k.exe===void 0&&s.jsx("p",{className:"muted small",children:"脚本包没有写游戏的进程名:先在下面填进程名,或用「选择文件…」/ 让 agent 找。"}),k!==null&&k.exe!==void 0&&k.candidates.length===0&&s.jsxs("p",{className:"muted small",children:["没找到 ",k.exe,"(查了正在运行的程序、已安装程序、开始菜单和桌面快捷方式、各盘的常见游戏目录)。可以「选择文件…」,或「让 agent 找」在整个磁盘上搜。"]}),k!==null&&k.candidates.length===1&&s.jsxs("p",{className:"muted small",children:["找到并保存了:",k.candidates[0].path,"(",k.candidates[0].source,")"]}),k!==null&&k.candidates.length>1&&s.jsxs("div",{className:"candidate-list",children:[s.jsxs("span",{className:"muted small",children:["找到 ",k.candidates.length," 个,选一个:"]}),k.candidates.map(R=>s.jsxs("button",{className:`candidate ${B.pcExe===R.path?"chosen":""}`,disabled:x,onClick:()=>void V(R.path),children:[s.jsx("span",{className:"mono",children:R.path}),s.jsx("span",{className:"muted small",children:R.source})]},R.path))]}),s.jsx("label",{className:"field-label",htmlFor:`launch-proc-${t}`,children:"游戏进程名(判断游戏是否已经开着)"}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{id:`launch-proc-${t}`,className:"text-input",value:d,onChange:R=>p(R.target.value),placeholder:_.pcProcess??"默认是上面程序的文件名",spellCheck:!1}),s.jsx("button",{className:"small-button",disabled:x,onClick:()=>void U({pcProcess:d.trim()===""?null:d.trim()}),children:"保存"})]}),s.jsx("p",{className:"muted small",children:"填的是启动器时,进程名要填游戏本身的(在任务管理器「详细信息」里看)。"})]}),w&&s.jsx("div",{className:"muted small",children:"已保存,下次运行生效。"}),E!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:E})]})]})}const I5=15*6e4;function T5({client:e,script:t,openSession:n}){const r=Cn(3e4),[i,o]=b.useState(!1),[c,u]=b.useState(null),h=t.summary,d=(h==null?void 0:h.state)==="running"&&r-h.at<I5,p=(h==null?void 0:h.state)==="failed"||h==null?void 0:h.text,m=async()=>{o(!0),u(null);try{await e.connection.call("scripts/summarize",{id:t.id})}catch(g){u(Re(g))}finally{o(!1)}};return s.jsxs("section",{className:"card script-summary",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"简介"}),s.jsx("p",{className:"muted small",children:d?"agent 正在看它的说明和文件…":h===void 0?"让 AI 看看它的说明(README)、文件和脚本包,用几句话说清楚它是什么、能做什么。":h.state==="failed"||h.state==="running"?"上次总结没有完成":`AI 总结 · ${At(h.at,r)}`})]}),s.jsxs("div",{className:"key-actions",children:[(h==null?void 0:h.sessionId)!==void 0&&s.jsx("button",{className:"ghost small-button",onClick:()=>n(h.sessionId),children:d?"看看进度":"查看对话"}),s.jsxs("button",{className:`${h===void 0?"primary ":""}small-button`,disabled:i||d,onClick:()=>void m(),children:[s.jsx(Q,{name:"sparkles"}),d?"总结中…":h===void 0?"让 AI 总结":"重新总结"]})]})]}),p!==void 0&&s.jsx("p",{className:`summary-text ${d?"muted":""}`,children:p}),(h==null?void 0:h.state)==="failed"&&h.text!==void 0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:h.text})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:c})]})]})}const $5={nsis:"NSIS",inno:"Inno Setup",kachina:"Kachina"};function o_({client:e,setup:t,openSession:n,onImported:r}){const[i,o]=b.useState(t.dir),[c,u]=b.useState(!1),[h,d]=b.useState(null),[p,m]=b.useState(null),[g,x]=b.useState(!1),y=t.agent,E=async(N,w)=>{d(N),m(null);try{await w()}catch(T){m(Re(T))}finally{d(null)}};return s.jsxs("section",{className:"card setup-card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsxs("h3",{children:[t.update?"更新":"安装"," ",t.name," ",t.version]}),s.jsxs("p",{className:"muted small",children:["下载到的是 ",$5[t.kind]," 安装程序,不是压缩包:要运行它把文件装好,再导入装好的文件夹。"]})]})}),(y==null?void 0:y.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(y.sessionId),children:"查看对话"})]}),(y==null?void 0:y.state)==="failed"&&s.jsxs("div",{className:"notice warn-box left",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["agent 没能装好:",y.reason??"原因不明","。可以按下面的步骤自己装,也可以之后再交给 agent。"]}),s.jsx("button",{className:"link-button",onClick:()=>n(y.sessionId),children:"查看对话"})]}),s.jsxs("ol",{className:"setup-steps",children:[s.jsx("li",{children:s.jsxs("div",{className:"setup-step",children:[s.jsx("span",{children:"打开安装程序,按它的提示装完。安装位置已经填好,保持不变;最后不用勾选「立即运行」。"}),s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void E("open",async()=>{await e.connection.call("scripts/setup/open",{id:t.scriptId}),u(!0)}),children:h==="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:N=>{N.preventDefault(),E("import",async()=>{const w=await e.connection.call("scripts/import",{path:i.trim().replace(/^"|"$/g,""),id:t.scriptId});r(w.id)})},children:[s.jsx("input",{className:"text-input plain","aria-label":"装好的文件夹",value:i,onChange:N=>o(N.target.value),spellCheck:!1,disabled:h!==null}),s.jsx("button",{className:"primary small-button",type:"submit",disabled:h!==null||i.trim()==="",children:h==="import"?"导入中…":"装好了,导入"})]})]})})]}),p!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:p})]}),s.jsx("div",{className:"key-actions",children:g?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"muted small",children:"删除下载好的安装程序,什么都不装。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>x(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:h!==null,onClick:()=>void E("discard",async()=>{await e.connection.call("scripts/setup/discard",{id:t.scriptId})}),children:"确认删除"})]}):s.jsxs(s.Fragment,{children:[(y==null?void 0:y.state)!=="running"&&s.jsx("button",{className:"small-button",disabled:h!==null,onClick:()=>void E("agent",async()=>{const{sessionId:N}=await e.connection.call("scripts/setup/agent",{id:t.scriptId});n(N)}),children:h==="agent"?"正在交给 agent…":"让 agent 安装"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:h!==null,onClick:()=>x(!0),children:"不装了"})]})})]})}const M5={ok:["ok","满足"],missing:["warn","缺少"],outdated:["warn","版本过旧"],unknown:["warn","无法判断"],unsupported:["","暂不检测"]};function R5({client:e,script:t,job:n,setup:r,onRemoved:i,openSession:o}){var z;const c=Cn(6e4),[u,h]=b.useState(null),[d,p]=b.useState(null),[m,g]=b.useState(null),[x,y]=b.useState(!1),[E,N]=b.useState(!1),w=n!==void 0&&(n.endedAt===void 0||n.startedAt>=t.addedAt-1e3)?n:void 0,T=ho(w),k=je(e.capabilities),I=t.source.kind!=="local",L=async(U,V)=>{h(U),p(null),g(null);try{const $=await V();typeof $=="string"&&g($)}catch($){p(Re($))}finally{h(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:VN[t.family]??t.family}),t.packId!==void 0?s.jsxs("span",{className:"badge ok",children:["脚本包 ",t.packId]}):s.jsx("span",{className:"badge warn",children:"无脚本包"}),t.channels.mirrorchyan!==void 0&&s.jsxs("span",{className:"badge",title:"填了 Mirror酱 CDK 后从 Mirror酱 更新(增量)",children:["Mirror酱 ",t.channels.mirrorchyan.rid]}),s.jsx("span",{className:"muted small",children:t.source.kind==="github"?`GitHub · ${t.source.repo}`:t.source.kind==="mirrorchyan"?`Mirror酱 · ${t.source.rid}`:"本地导入"})]})]})}),w!==void 0&&s.jsx(wm,{client:e,job:w}),r!==void 0&&s.jsx(o_,{client:e,setup:r,openSession:o,onImported:()=>{}}),t.dir!==void 0&&s.jsx(T5,{client:e,script:t,openSession:o}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"位置与版本"}),s.jsx("p",{className:"muted small",children:t.dir??"(无)"})]}),t.dir!==void 0&&s.jsxs("button",{className:"ghost small-button",onClick:()=>{var U;return void((U=navigator.clipboard)==null?void 0:U.writeText(t.dir))},children:[s.jsx(Q,{name:"copy"}),"复制路径"]})]}),I?s.jsxs(s.Fragment,{children:[s.jsx("ul",{className:"version-list",children:t.versions.map(U=>{var V;return s.jsxs("li",{className:U.current?"current":"",children:[s.jsx("span",{className:"version-name",children:U.version}),U.current&&s.jsx("span",{className:"badge ok",children:"当前"}),s.jsxs("span",{className:"muted small",children:[((V=U.asset)==null?void 0:V.name)??""," · ",At(U.installedAt,c)]}),s.jsx("span",{className:"spacer"}),!U.current&&s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void L("rollback",async()=>(await e.connection.call("scripts/rollback",{id:t.id,version:U.version}),`已切换到 ${U.version}`)),children:"切换到此版本"})]},U.version)})}),s.jsx("dl",{className:"local-facts channel-facts",children:s.jsx(a_,{client:e,script:t,disabled:T||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&&` · ${At(t.update.checkedAt,c)}检查`]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void L("check",async()=>{const U=await e.connection.call("scripts/checkUpdate",{id:t.id});return U.available?`发现新版本 ${U.latest}`:"已是最新版本"}),children:u==="check"?"检查中…":"检查更新"}),s.jsx("button",{className:"primary small-button",disabled:T||u!==null||((z=t.update)==null?void 0:z.available)!==!0,onClick:()=>void L("update",async()=>(await e.connection.call("scripts/update",{id:t.id})).upToDate?"已是最新版本":void 0),children:"更新"})]})]}):s.jsx(j5,{client:e,script:t,disabled:T||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?"没有脚本包,暂时不知道它需要什么":"还没有检查":`${At(t.env.checkedAt,c)}检查`})]}),s.jsx("button",{className:"small-button",disabled:T||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(U=>{const[V,$]=M5[U.status];return s.jsxs("li",{children:[s.jsxs("div",{className:"env-main",children:[s.jsx("span",{className:"env-label",children:U.label}),s.jsx("span",{className:`badge ${V}`,children:$}),U.found!==void 0&&s.jsx("span",{className:"muted small",children:U.found})]}),U.detail!==void 0&&s.jsx("div",{className:"muted small",children:U.detail}),U.fix!==void 0&&s.jsxs("div",{className:"env-fix",children:[s.jsx("span",{className:"muted small",children:U.fix.description}),U.fix.kind!=="manual"&&s.jsx("button",{className:"small-button",disabled:T||u!==null,onClick:()=>void L(`fix-${U.kind}`,async()=>{await e.connection.call("scripts/envFix",{id:t.id,kind:U.kind})}),children:U.fix.kind==="installer"?"安装(需要管理员)":"自动修复"})]})]},U.kind)})})]}),k.has("runs")&&t.dir!==void 0&&s.jsx(FP,{client:e,scriptId:t.id,packId:t.packId}),k.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(E5,{client:e,script:t}),k.has("runs")&&t.packId!==void 0&&t.dir!==void 0&&s.jsx(A5,{client:e,scriptId:t.id,scriptName:t.name,openSession:o},t.id),k.has("packs")&&s.jsx(S5,{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(U=>s.jsx("span",{className:"chip",children:U},U))}),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(U=>s.jsx("span",{className:"chip",children:U},U))})]})]}),k.has("guard")&&s.jsx(_5,{client:e,script:t}),s.jsx("section",{className:"card danger-zone",children:x?s.jsxs("div",{className:"key-actions",children:[I&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:E,onChange:U=>N(U.target.checked)}),"同时删除所有已安装版本"]}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"small-button",onClick:()=>y(!1),children:"取消"}),s.jsx("button",{className:"danger small-button",disabled:u!==null,onClick:()=>void L("remove",async()=>{await e.connection.call("scripts/remove",{id:t.id,deleteFiles:I&&E}),i()}),children:"确认移除"})]}):s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:I?"从脚本库移除;可选择同时删除已安装的文件。":"从脚本库移除;你的目录不会被删除。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline small-button",disabled:T,onClick:()=>y(!0),children:"移除"})]})}),m!==null&&s.jsx("div",{className:"notice info",children:m}),d!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:d})]})]})}function O5({client:e,openSession:t,arg:n}){const{data:r,error:i}=Um(e),o=eO(e),[c,u]=b.useState(null),[h,d]=b.useState(null);b.useEffect(()=>{(n==null?void 0:n.startsWith("mirror:"))===!0&&d({kind:"mirror",rid:n.slice(7)})},[n]);const p=(r==null?void 0:r.scripts)??[],m=((r==null?void 0:r.packs)??[]).filter(k=>!k.installed&&k.repo!==void 0&&k.error===void 0),g=((r==null?void 0:r.packs)??[]).filter(k=>k.error!==void 0),x=((r==null?void 0:r.known)??[]).filter(k=>!k.installed),y=(r==null?void 0:r.setups)??[],E=y.filter(k=>!p.some(I=>I.id===k.scriptId)),N=h===null?E.find(k=>k.scriptId===c):void 0,w=c===null||p.some(k=>k.id===c)||N!==void 0?void 0:o.get(c),T=p.find(k=>k.id===c)??(h===null&&w===void 0&&N===void 0?p[0]:void 0);return s.jsxs("section",{className:"main scripts-page",children:[s.jsxs("header",{className:"page-header",children:[s.jsxs("div",{className:"breadcrumb",children:[s.jsx("span",{children:"脚本"}),s.jsx("span",{className:"breadcrumb-divider",children:"/"}),s.jsx("h1",{children:"脚本库"})]}),s.jsxs("div",{className:"page-actions",children:[s.jsxs("button",{className:"small-button",onClick:()=>d({kind:"import"}),children:[s.jsx(Q,{name:"paperclip"}),"导入本地项目"]}),s.jsxs("button",{className:"small-button",onClick:()=>d({kind:"mirror"}),children:[s.jsx(Q,{name:"plus"}),"从 Mirror酱 安装"]}),s.jsxs("button",{className:"primary small-button",onClick:()=>d({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:[i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:i})]}),r===null&&i===null&&s.jsx("div",{className:"muted small pad",children:"加载中…"}),r!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"sidebar-label",children:["我的脚本(",p.length,")"]}),p.length===0&&![...o.values()].some(ho)&&s.jsxs("div",{className:"sidebar-empty",children:[s.jsx(Q,{name:"package"}),s.jsx("span",{children:"还没有脚本"}),s.jsx("span",{children:"从下面的脚本包安装,或导入已有目录"})]}),p.map(k=>{var z,U;const I=o.get(k.id),L=((z=k.env)==null?void 0:z.items.filter(V=>V.status!=="ok"&&V.status!=="unsupported").length)??0;return s.jsxs("button",{className:`script-row ${k.id===(T==null?void 0:T.id)&&h===null?"active":""}`,onClick:()=>{u(k.id),d(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:k.name}),s.jsxs("span",{className:"muted small",children:[k.source.kind==="local"?"本地":k.current??"未安装",k.family===void 0?"":` · ${VN[k.family]??k.family}`]})]}),ho(I)?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):y.some(V=>V.scriptId===k.id)?s.jsx("span",{className:"badge warn",children:"待安装"}):((U=k.update)==null?void 0:U.available)===!0?s.jsx("span",{className:"badge ok",children:"可更新"}):L>0?s.jsxs("span",{className:"badge warn",children:["环境 ",L]}):null]},k.id)}),E.length>0&&s.jsxs("div",{className:"sidebar-label",children:["等待安装(",E.length,")"]}),E.map(k=>{var I,L,z;return s.jsxs("button",{className:`script-row ${k===N?"active":""}`,onClick:()=>{u(k.scriptId),d(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:k.name}),s.jsxs("span",{className:"muted small",children:[k.version," · ",((I=k.agent)==null?void 0:I.state)==="running"?"agent 正在安装":((L=k.agent)==null?void 0:L.state)==="failed"?"agent 没能装好":"安装程序已下载"]})]}),((z=k.agent)==null?void 0:z.state)==="running"?s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"}):s.jsx("span",{className:"badge warn",children:"待安装"})]},k.scriptId)}),[...o.values()].filter(k=>ho(k)&&!p.some(I=>I.id===k.scriptId)).map(k=>s.jsxs("button",{className:`script-row ${c===k.scriptId&&h===null?"active":""}`,onClick:()=>{u(k.scriptId),d(null)},children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:k.scriptId}),s.jsxs("span",{className:"muted small",children:["正在安装 · ",sd[k.phase],k.total!==void 0&&k.received!==void 0&&k.total>0?` ${Math.floor(k.received/k.total*100)}%`:""]})]}),s.jsx("span",{className:"run-dot",role:"img","aria-label":"进行中"})]},k.id)),(m.length>0||x.length>0)&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"sidebar-label pack-label",children:"可安装的脚本包"}),m.map(k=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:k.name}),s.jsx("span",{className:"muted small",children:k.description??k.repo})]}),s.jsx("button",{className:"small-button",onClick:()=>d({kind:"install",repo:k.repo}),children:"安装"})]},k.id)),x.map(k=>s.jsxs("div",{className:"pack-row",children:[s.jsxs("span",{className:"script-row-main",children:[s.jsx("span",{className:"script-row-name",children:k.name}),s.jsx("span",{className:"muted small",children:[k.mirrorchyan===void 0?void 0:`Mirror酱 ${k.mirrorchyan}`,k.repo].filter(Boolean).join(" · ")})]}),s.jsx("button",{className:"small-button",onClick:()=>d(k.mirrorchyan!==void 0?{kind:"mirror",rid:k.mirrorchyan}:{kind:"install",repo:k.repo}),children:"安装"})]},k.id))]}),g.length>0&&s.jsxs("div",{className:"notice error left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:[g.length," 个脚本包无法读取:",g.map(k=>k.id).join("、")]})]})]})]}),s.jsxs("div",{className:"scripts-detail",children:[(h==null?void 0:h.kind)==="install"&&s.jsx(g5,{client:e,jobs:o,...h.repo===void 0?{}:{initialRepo:h.repo},onClose:()=>d(null),onDone:k=>{u(k),d(null)},openSession:t},h.repo??"blank"),(h==null?void 0:h.kind)==="mirror"&&s.jsx(x5,{client:e,jobs:o,...h.rid===void 0?{}:{initialRid:h.rid},onClose:()=>d(null),onDone:k=>{u(k),d(null)},openSession:t,onGitHub:k=>d({kind:"install",repo:k})},h.rid??"blank"),(h==null?void 0:h.kind)==="import"&&s.jsx(N5,{client:e,onClose:()=>d(null),onImported:k=>{u(k),d(null)}}),h===null&&T!==void 0&&s.jsx(R5,{client:e,script:T,job:o.get(T.id),setup:y.find(k=>k.scriptId===T.id),onRemoved:()=>u(null),openSession:t},T.id),N!==void 0&&s.jsx(o_,{client:e,setup:N,openSession:t,onImported:k=>u(k)},N.scriptId),h===null&&T===void 0&&w!==void 0&&s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:w.scriptId}),s.jsx("p",{className:"muted small",children:ho(w)?"正在安装,装好后这里显示脚本的详情":"安装没有完成"})]})}),s.jsx(wm,{client:e,job:w})]}),h===null&&T===void 0&&w===void 0&&N===void 0&&r!==null&&s.jsxs("div",{className:"empty",children:[[...o.values()].filter(k=>ho(k)&&!p.some(I=>I.id===k.scriptId)).map(k=>s.jsxs("div",{className:"pending-install",children:[s.jsx("strong",{children:k.scriptId}),s.jsx(wm,{client:e,job:k})]},k.id)),s.jsx("p",{children:"选择左侧的脚本查看详情,或安装一个新脚本。"})]}),r!==null&&s.jsxs("p",{className:"tools-dir muted small",children:["工具目录:",r.toolsDir]})]})]})]})}const z5={id:"scripts",title:"脚本库",milestone:"M1",requires:["scripts"],pages:[{id:"scripts",title:"脚本",icon:"package",order:10,agent:"scripts",component:O5}],settingsPages:[{id:"script-install",title:"脚本安装",order:10,component:m5}]},P5={id:"emulators",title:"模拟器",milestone:"M2",requires:["emulators"],settingsPages:[{id:"emulators",title:"模拟器",order:11,component:p5}]},vp="https://github.com/haaahhhis/MultiGameAssistant";function L5(){const[e,t]=b.useState(void 0);b.useEffect(()=>{var o;const r=(o=wr())==null?void 0:o.appInfo;if(r===void 0){t(null);return}let i=!0;return r().then(c=>{i&&t(c)},()=>{i&&t(null)}),()=>{i=!1}},[]);const n=e===void 0?"…":e===null?"在浏览器里打开(版本见桌面版)":e.fromSource?`从源码运行(${e.arch})`:`${e.version??"未知版本"}(${e.arch}${e.commit===void 0?"":` · ${e.commit}`})`;return s.jsxs("div",{className:"settings-page about-page",children:[s.jsx("h2",{children:"关于"}),s.jsx("p",{children:"MultiGameAssistant(多游戏助手):让 agent 替你管好各个游戏的日常脚本。"}),s.jsx("section",{className:"card about-card",children:s.jsxs("dl",{className:"about-facts",children:[s.jsx("dt",{children:"版本"}),s.jsx("dd",{children:n}),s.jsx("dt",{children:"源代码"}),s.jsx("dd",{children:s.jsx("a",{href:vp,target:"_blank",rel:"noreferrer",children:vp.replace("https://","")})}),s.jsx("dt",{children:"许可证"}),s.jsx("dd",{children:s.jsx("a",{href:`${vp}/blob/main/LICENSE`,target:"_blank",rel:"noreferrer",children:"GNU AGPL-3.0-only"})})]})}),(e==null?void 0:e.fromSource)===!0?s.jsxs("section",{className:"card about-card",children:[s.jsx("h3",{children:"更新"}),s.jsx("p",{className:"muted",children:"从源码运行:在项目目录 git pull 后重新构建(pnpm install、pnpm build)。"})]}):e!=null&&s.jsx(D5,{}),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 D5(){const{bridge:e,state:t}=EN();if(e===void 0||t===null)return null;const n=t==null?void 0:t.latest,r=t===void 0?"…":t.checking?"正在检查…":t.error!==void 0?t.error:n!==void 0?`有新版本 ${n.version}${n.prerelease?"(预发布版)":""}${n.version===t.skipped?",已跳过":""}`:t.checkedAt!==void 0?`已经是最新版本(${new Date(t.checkedAt).toLocaleString()} 检查)`:"还没有检查过";return s.jsxs("section",{className:"card about-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"更新"}),s.jsxs("p",{className:(t==null?void 0:t.error)!==void 0&&!t.checking?"error small":"muted small",children:[r,n!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("a",{href:n.notesUrl,target:"_blank",rel:"noreferrer",children:"查看更新内容"})]})]})]}),s.jsxs("button",{className:"small-button",disabled:t===void 0||t.checking,onClick:()=>void e.check(),children:[s.jsx(Q,{name:"refresh"}),"检查更新"]})]}),t!==void 0&&s.jsx(CN,{bridge:e,state:t}),t!==void 0&&s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:t.auto,onChange:i=>void e.setAuto(i.target.checked)}),"自动检查更新(启动后和每隔几小时,从 GitHub Releases;",/-/.test(t.current)?"预发布版也会收到更新的预发布版":"只提示正式版",")"]})]})}const Bl=e=>e.replace(/\/+$/,""),ak=e=>{const t=Bl(e);return t.endsWith("/v1")?t.slice(0,-3):t},l_=[{id:"openai-completions",title:"OpenAI 兼容",subtitle:"Chat Completions",hint:"绝大多数第三方网关和本地服务都用这种:OneAPI / NewAPI、OpenRouter、硅基流动、vLLM、Ollama、LM Studio 等。",placeholder:"https://api.example.com/v1",requestPath:e=>`${Bl(e)}/chat/completions`,listPath:e=>`${Bl(e)}/models`},{id:"openai-responses",title:"OpenAI Responses",subtitle:"Responses API",hint:"OpenAI 的新一代接口,支持推理摘要等能力;仅在服务方明确支持 /responses 时使用。",placeholder:"https://api.openai.com/v1",requestPath:e=>`${Bl(e)}/responses`,listPath:e=>`${Bl(e)}/models`},{id:"anthropic-messages",title:"Anthropic 兼容",subtitle:"Messages API",hint:"Claude 官方接口以及兼容 Anthropic 格式的网关。地址写到域名即可,末尾的 /v1 可有可无。",placeholder:"https://api.anthropic.com",requestPath:e=>`${ak(e)}/v1/messages`,listPath:e=>`${ak(e)}/v1/models`}];function jm(e){return l_.find(t=>t.id===e)}function F5(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^[^a-z]+/,"").replace(/-+$/,"").slice(0,40)}function B5(e){return`${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}_API_KEY`}const U5=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;function H5(e){try{const{protocol:t}=new URL(e);return t==="http:"||t==="https:"}catch{return!1}}function vo(e){return e===void 0?null:e%1048576===0?`${e/1048576}M`:e>=1e6?`${+(e/1e6).toFixed(1)}M`:e%1024===0?`${e/1024}K`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}function Z5({client:e,profile:t,preset:n,taken:r,revision:i,readOnly:o,onDone:c}){var me;const u=t===void 0,h=n===void 0||n.id===""?"":r.includes(n.id)?`${n.id}-2`:n.id,[d,p]=b.useState(()=>{var xe;return((xe=jm((t==null?void 0:t.api)??(n==null?void 0:n.api)))==null?void 0:xe.id)??"openai-completions"}),[m,g]=b.useState((t==null?void 0:t.displayName)??((n==null?void 0:n.baseURL)===""?"":(n==null?void 0:n.name)??"")),[x,y]=b.useState((t==null?void 0:t.id)??h),[E,N]=b.useState(!u||h!==""),[w,T]=b.useState((t==null?void 0:t.baseURL)??(n==null?void 0:n.baseURL)??""),[k,I]=b.useState(""),[L,z]=b.useState((t==null?void 0:t.models)??[]),[U,V]=b.useState(!1),[$,P]=b.useState(null),D=jm(d),B=w.trim(),_=B!==""&&!H5(B),C=x!==""&&!U5.test(x),R=u&&r.includes(x),M=u_(k),F=(t==null?void 0:t.apiKeyRef)??(x===""?null:B5(x)),H=((me=t==null?void 0:t.credential)==null?void 0:me.configured)===!0,W=(t==null?void 0:t.credential)!==void 0&&!t.credential.writable,K=x===""?"请填写标识":C?"标识格式不正确":R?"这个标识已被占用":B===""?"请填写 Base URL":_?"Base URL 需要以 http:// 或 https:// 开头":M!==null?M:L.length===0?"至少需要一个模型:点击「拉取模型列表」或手动添加":null,q=xe=>{g(xe),E||y(F5(xe))},Y=async()=>{if(K===null){V(!0),P(null);try{await e.saveProvider({id:x,create:u,...m.trim()===""?{}:{displayName:m.trim()},api:d,baseURL:B,models:[...L],...k.trim()===""?{}:{apiKey:k.trim()},expectedRevision:i}),c()}catch(xe){const oe=xe instanceof Error?xe.message:String(xe);P(/SETTINGS_CONFLICT|conflict/i.test(oe)?"配置在别处被修改过了,请返回列表后重试。":oe)}finally{V(!1)}}},fe=U||o;return s.jsxs("form",{className:"provider-editor",onSubmit:xe=>{xe.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:U,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:l_.map(xe=>s.jsxs("button",{type:"button",role:"radio","aria-checked":d===xe.id,"aria-label":`${xe.title}(${xe.subtitle})`,className:`mode-option${d===xe.id?" selected":""}`,onClick:()=>p(xe.id),disabled:fe,children:[s.jsx("span",{className:"mode-title",children:xe.title}),s.jsx("span",{className:"mode-subtitle",children:xe.subtitle})]},xe.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:m,onChange:xe=>q(xe.target.value),placeholder:"例如:我的中转站",disabled:fe})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"标识"}),s.jsx("input",{className:"text-input",value:x,onChange:xe=>{y(xe.target.value.trim()),N(!0)},placeholder:"my-gateway",disabled:fe||!u,spellCheck:!1})]})]}),s.jsx("div",{className:C||R?"error small":"muted small",children:C?"标识只能用小写字母、数字和单个连字符,并以字母开头。":R?"这个标识已被占用(可能是已有的提供方或 dsh 内置提供方)。":u?"用于区分提供方,保存后不能修改。":"标识创建后不能修改。"}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"Base URL"}),s.jsx("input",{className:"text-input",value:w,onChange:xe=>T(xe.target.value),placeholder:D.placeholder,disabled:fe,spellCheck:!1})]}),_?s.jsx("div",{className:"error small",children:"Base URL 需要以 http:// 或 https:// 开头。"}):B!==""&&s.jsxs("div",{className:"muted small endpoint-preview",children:["对话请求 ",s.jsxs("code",{children:["POST ",D.requestPath(B)]}),s.jsx("br",{}),"模型列表 ",s.jsxs("code",{children:["GET ",D.listPath(B)]})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"API Key"}),s.jsx("input",{className:"text-input",type:"password",value:k,onChange:xe=>I(xe.target.value),placeholder:W?"由启动环境变量提供,无法在此修改":H?"已配置,留空则保持不变":"粘贴 Key;本地服务不需要时可留空",autoComplete:"new-password",disabled:fe||W,spellCheck:!1})]}),M!==null?s.jsx("div",{className:"error small",children:M}):F!==null&&s.jsxs("div",{className:"muted small",children:["保存在 dsh 凭据 ",s.jsx("code",{children:F})," 中,界面不会再显示 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(W5,{client:e,models:L,onChange:z,probe:{...t===void 0?{}:{provider:t.id},api:d,baseURL:B,apiKey:k.trim()},probeBlocked:B===""?"先填写 Base URL":_?"Base URL 无效":M,disabled:fe}),$!==null&&s.jsx("div",{className:"banner error",children:$}),s.jsxs("div",{className:"key-actions",children:[s.jsx("span",{className:"muted small",children:K}),s.jsx("span",{className:"spacer"}),s.jsx("button",{type:"button",onClick:c,disabled:U,children:"取消"}),s.jsx("button",{type:"submit",className:"primary",disabled:fe||K!==null,children:U?"保存中…":u?"创建":"保存"})]})]})}function W5({client:e,models:t,onChange:n,probe:r,probeBlocked:i,disabled:o}){const[c,u]=b.useState(null),[h,d]=b.useState(""),[p,m]=b.useState(""),[g,x]=b.useState(!1),[y,E]=b.useState(null),N=b.useRef(null),w=b.useMemo(()=>new Set(t.map($=>$.id)),[t]),T=async()=>{var P;(P=N.current)==null||P.abort();const $=new AbortController;N.current=$,x(!0),E(null);try{const D=await e.discoverModels({...r.provider===void 0?{}:{provider:r.provider},api:r.api,baseURL:r.baseURL,...r.apiKey===""?{}:{apiKey:r.apiKey}},$.signal);if($.signal.aborted)return;u([...D].sort((B,_)=>B.id.localeCompare(_.id))),D.length===0&&E("接口返回了空的模型列表,可以手动添加模型 ID。")}catch(D){$.signal.aborted||E(D instanceof Error?D.message:String(D))}finally{N.current===$&&(N.current=null,x(!1))}},k=$=>{n(w.has($.id)?t.filter(P=>P.id!==$.id):[...t,$])},I=$=>{n(t.map(P=>{if(P.id!==$)return P;if(P.efforts!==void 0&&P.efforts.length>0){const{efforts:D,...B}=P;return B}return{...P,efforts:["off","low","medium","high"]}}))},L=$=>{n(t.map(P=>{var D;return P.id!==$?P:{...P,input:((D=P.input)==null?void 0:D.includes("image"))===!0?["text"]:["text","image"]}}))},z=b.useMemo(()=>{const $=h.trim().toLowerCase();return(c??[]).filter(P=>$===""||P.id.toLowerCase().includes($)||(P.name??"").toLowerCase().includes($))},[c,h]),U=$=>{if($){const P=z.filter(D=>!w.has(D.id));n([...t,...P])}else{const P=new Set(z.map(D=>D.id));n(t.filter(D=>!P.has(D.id)))}},V=()=>{const $=p.split(/[\s,,]+/).map(P=>P.trim()).filter(P=>P!==""&&!w.has(P));$.length!==0&&(n([...t,...$.map(P=>(c==null?void 0:c.find(D=>D.id===P))??{id:P})]),m(""))};return s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"模型"}),s.jsxs("div",{className:"muted small",children:["已选 ",t.length," 个。只有选中的模型会出现在模型选择器里。能看图的模型点亮「图片」,否则 dsh 会拒绝发送图片;支持调思考强度的模型(如 GPT-5、o 系列、Claude、DeepSeek R 系列)点亮「思考」,对话里就能选强度。"]})]}),s.jsx("button",{type:"button",onClick:()=>void T(),disabled:o||g||i!==null,title:i??void 0,children:g?"拉取中…":c===null?"拉取模型列表":"重新拉取"})]}),y!==null&&s.jsx("div",{className:"error small",children:y}),t.length>0&&s.jsx("div",{className:"model-chips",children:t.map($=>{var P,D,B,_,C,R;return s.jsxs("span",{className:"chip removable",children:[$.id,vo($.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",vo($.contextWindow)]}),s.jsx("button",{type:"button",className:`chip-flag${((P=$.input)==null?void 0:P.includes("image"))===!0?" on":""}`,onClick:()=>L($.id),disabled:o,"aria-pressed":((D=$.input)==null?void 0:D.includes("image"))===!0,title:((B=$.input)==null?void 0:B.includes("image"))===!0?"支持图片输入(点击关闭)":"不支持图片输入(点击开启)",children:"图片"}),s.jsx("button",{type:"button",className:`chip-flag${(((_=$.efforts)==null?void 0:_.length)??0)>0?" on":""}`,onClick:()=>I($.id),disabled:o,"aria-pressed":(((C=$.efforts)==null?void 0:C.length)??0)>0,title:(((R=$.efforts)==null?void 0:R.length)??0)>0?`可选思考强度:${$.efforts.join(" / ")}(点击关闭)`:"没有声明思考强度(点击开启:不思考 / 低 / 中 / 高)",children:"思考"}),s.jsx("button",{type:"button",className:"chip-x",onClick:()=>n(t.filter(M=>M.id!==$.id)),disabled:o,"aria-label":`移除 ${$.id}`,children:"×"})]},$.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:h,onChange:$=>d($.target.value),placeholder:`搜索 ${c.length} 个模型`}),s.jsxs("button",{type:"button",className:"small-button",onClick:()=>U(!0),disabled:o,children:["全选",h!==""?"筛选结果":""]}),s.jsx("button",{type:"button",className:"small-button",onClick:()=>U(!1),disabled:o,children:"全不选"})]}),s.jsxs("ul",{className:"candidate-list",children:[z.map($=>{var P;return s.jsx("li",{children:s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:w.has($.id),onChange:()=>k($),disabled:o}),s.jsx("span",{className:"mono",children:$.id}),$.name!==void 0&&s.jsxs("span",{className:"muted",children:[" ",$.name]}),s.jsx("span",{className:"spacer"}),((P=$.input)==null?void 0:P.includes("image"))===!0&&s.jsx("span",{className:"badge",children:"图像"}),vo($.contextWindow)!==null&&s.jsxs("span",{className:"muted small",children:[vo($.contextWindow)," 上下文"]})]})},$.id)}),z.length===0&&s.jsx("li",{className:"muted small",children:"没有匹配的模型。"})]})]}),s.jsxs("div",{className:"key-input",children:[s.jsx("input",{className:"text-input plain-mono",value:p,onChange:$=>m($.target.value),onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),V())},placeholder:"手动添加模型 ID,多个用空格或逗号分隔",disabled:o,spellCheck:!1}),s.jsx("button",{type:"button",onClick:V,disabled:o||p.trim()==="",children:"添加"})]})]})}const V5=[{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:""}],yp=[{id:"deepseek-official",name:"DeepSeek",note:"内置,只需要填 Key",keyRef:Op,keyUrl:"https://platform.deepseek.com/api_keys"}];function q5({client:e}){const{catalog:t}=Zo(e),[n,r]=b.useState(!1),[i,o]=b.useState(void 0),c=je(e.providersRevision),u=je(e.credentialRevision),h=je(e.connection.status),[d,p]=b.useState(null),[m,g]=b.useState(null),[x,y]=b.useState(null),[E,N]=b.useState(null),w=b.useCallback(()=>{e.listProviders().then(k=>{p(k),g(null)}).catch(k=>g(k instanceof Error?k.message:String(k)))},[e]);if(b.useEffect(()=>{h.state==="open"&&w()},[w,c,u,h.state]),x!==null&&d!==null){const k=x==="new"?void 0:d.providers.find(I=>I.id===x);return s.jsx("section",{className:"providers-section",children:s.jsx(Z5,{client:e,profile:k,preset:x==="new"?i:void 0,taken:d.taken,revision:d.revision,readOnly:!d.writable,onDone:()=>{y(null),o(void 0),w()}},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:()=>r(!1),children:"返回"})]}),s.jsxs("div",{className:"preset-grid",children:[yp.map(k=>s.jsxs("button",{className:"preset-option",onClick:()=>{var I;r(!1),(I=document.getElementById(`builtin-${k.id}`))==null||I.scrollIntoView({behavior:"smooth"})},children:[s.jsx("span",{className:"mode-title",children:k.name}),s.jsx("span",{className:"mode-subtitle",children:k.note})]},k.id)),V5.map(k=>s.jsxs("button",{className:"preset-option",disabled:d===null||!d.writable,onClick:()=>{o(k),r(!1),y("new")},children:[s.jsx("span",{className:"mode-title",children:k.name}),s.jsx("span",{className:"mode-subtitle",children:k.note})]},k.key))]})]});const T=new Set((d==null?void 0:d.providers.map(k=>k.id))??[]);return s.jsxs("section",{className:"providers-section",children:[s.jsxs("div",{className:"page-head",children:[s.jsx("h3",{children:"模型服务"}),s.jsx("button",{className:"primary",onClick:()=>r(!0),disabled:d===null,children:"+ 添加模型服务"})]}),s.jsx("p",{className:"muted",children:"每个服务填一次 Key,它的模型就会出现在输入框旁的模型选择器里。Claude、ChatGPT、Gemini、国内各家和本机的 Ollama 都可以接;需要看截图的功能请选能看图的模型。Key 保存在本机 dsh 的凭据文件里,界面不会再显示。"}),yp.map(k=>s.jsx(Y5,{client:e,provider:k,catalog:t},k.id)),t==null?void 0:t.groups.filter(k=>!T.has(k.id)&&!yp.some(I=>I.id===k.id)).map(k=>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:k.name}),s.jsx("div",{className:"muted small",children:s.jsx("code",{children:k.id})})]}),s.jsx("span",{className:"badge",children:"内置"})]}),s.jsx("div",{className:"model-chips",children:k.models.map(I=>s.jsx("span",{className:"chip",children:I.name},I.id))})]},k.id)),m!==null&&s.jsx("div",{className:"banner error",children:m}),E!==null&&s.jsx("div",{className:"success small",children:E}),d!==null&&!d.writable&&s.jsx("div",{className:"notice info left",children:"当前 profile 是只读的,无法在界面中修改提供方。"}),d===null&&m===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),d==null?void 0:d.providers.map(k=>s.jsx(G5,{client:e,profile:k,revision:d.revision,readOnly:!d.writable,onEdit:()=>y(k.id),onRemoved:I=>{N(I?"已删除。它原本是新会话的默认模型,默认模型已恢复为 profile 自带的设置。":null),w()}},k.id))]})}function G5({client:e,profile:t,revision:n,readOnly:r,onEdit:i,onRemoved:o}){const[c,u]=b.useState(!1),[h,d]=b.useState(null),p=jm(t.api),m=async()=>{var x,y;const g=t.apiKeyRef!==void 0&&((x=t.credential)==null?void 0:x.source)==="file"?`
232
+
233
+ 同时删除已保存的 Key(${t.apiKeyRef})。`:"";if(window.confirm(`确定删除「${t.displayName}」吗?使用它的会话需要换一个模型。${g}`)){u(!0),d(null);try{const{defaultReset:E}=await e.removeProvider({id:t.id,removeKey:((y=t.credential)==null?void 0:y.source)==="file",expectedRevision:n});o(E)}catch(E){d(E instanceof Error?E.message:String(E))}finally{u(!1)}}};return s.jsxs("section",{className:"card provider-card",children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.displayName}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id}),t.baseURL!==void 0&&s.jsxs(s.Fragment,{children:[" · ",s.jsx("span",{className:"mono",children:t.baseURL})]})]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:p===void 0?t.api??"内置目录":`${p.title} · ${p.subtitle}`}),s.jsx(K5,{profile:t}),t.active?s.jsx("span",{className:"badge ok",children:"已生效"}):s.jsx("span",{className:"badge warn",title:t.error,children:"未生效"})]})]}),t.error!==void 0&&s.jsx("div",{className:"error small",children:t.error}),t.models.length>0?s.jsx("div",{className:"model-chips",children:t.models.map(g=>s.jsxs("span",{className:"chip",title:g.name??g.id,children:[g.id,vo(g.contextWindow)!==null&&s.jsxs("span",{className:"muted",children:[" · ",vo(g.contextWindow)]})]},g.id))}):s.jsx("div",{className:"muted small",children:"使用 dsh 内置的模型目录。"}),h!==null&&s.jsx("div",{className:"error small",children:h}),s.jsxs("div",{className:"key-actions",children:[!t.declared&&s.jsx("span",{className:"muted small",children:"这是 dsh 内置提供方的配置,请在 dsh 官方模型页面编辑。"}),s.jsx("span",{className:"spacer"}),s.jsx("button",{className:"danger-outline",onClick:()=>void m(),disabled:c||r,children:"删除"}),t.declared&&s.jsx("button",{onClick:i,disabled:c||r,children:"编辑"})]})]})}function K5({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 Y5({client:e,provider:t,catalog:n}){const{items:r}=_N(e,[t.keyRef]),i=(r==null?void 0:r[t.keyRef])??null,o=n==null?void 0:n.groups.find(u=>u.id===t.id),c=n==null?void 0:n.failures.find(u=>u.id===t.id);return s.jsxs("section",{className:"card provider-card",id:`builtin-${t.id}`,children:[s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{className:"provider-title",children:[s.jsx("h3",{children:t.name}),s.jsxs("div",{className:"muted small",children:[s.jsx("code",{children:t.id})," · ",t.note]})]}),s.jsxs("div",{className:"badges",children:[s.jsx("span",{className:"badge",children:"内置"}),i===null?null:i.configured?s.jsx("span",{className:"badge ok",children:"Key 已配置"}):s.jsx("span",{className:"badge warn",children:"Key 未配置"})]})]}),o!==void 0&&o.models.length>0&&s.jsx("div",{className:"model-chips",children:o.models.map(u=>s.jsx("span",{className:"chip",title:u.description,children:u.name},u.id))}),c!==void 0&&s.jsx("div",{className:"error small",children:c.message}),s.jsx(Q5,{client:e,refName:t.keyRef,title:`${t.name} API Key`,description:"",helpUrl:t.keyUrl,info:i,bare:!0})]})}const c_={file:"dsh 凭据文件",env:"启动环境变量","project-env":"项目 .env 文件","user-env":"dsh 主目录 .env 文件"};function u_(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 X5({client:e}){const t=je(e.capabilities);return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"模型"}),s.jsx("p",{className:"muted",children:"agent 用哪个模型、接哪些模型服务都在这里。保存后立即生效;新对话和飞书对话默认用下面选的模型,软件自己开的会话(干预、游戏等)可以另选一个;每个对话也可以在输入框旁边单独换。"}),s.jsx(e9,{client:e}),t.has("role-model")&&s.jsx(t9,{client:e}),t.has("providers")&&s.jsx(q5,{client:e})]})}function Q5({client:e,refName:t,title:n,description:r,helpUrl:i,info:o,placeholder:c,bare:u=!1}){const[h,d]=b.useState(""),[p,m]=b.useState(!1),[g,x]=b.useState(!1),[y,E]=b.useState(null),N=u_(h),w=o!==null&&!o.writable,T=async()=>{if(!(h.trim()===""||N!==null)){x(!0),E(null);try{await e.setCredential(t,h.trim()),d(""),m(!1),E({tone:"ok",text:"已保存,立即生效。"})}catch(L){E({tone:"error",text:L instanceof Error?L.message:String(L)})}finally{x(!1)}}},k=async()=>{if(window.confirm(`确定要删除已保存的 ${n} 吗?删除后需要重新填写才能使用对应模型。`)){x(!0),E(null);try{await e.unsetCredential(t),E({tone:"ok",text:"已删除。"})}catch(L){E({tone:"error",text:L instanceof Error?L.message:String(L)})}finally{x(!1)}}},I=u?"div":"section";return s.jsxs(I,{className:u?"credential-inline":"card",children:[!u&&s.jsxs("div",{className:"card-head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:n}),s.jsxs("div",{className:"muted small",children:[r," ",s.jsx("code",{children:t})]})]}),s.jsx(J5,{info:o})]}),w?s.jsxs("div",{className:"notice info left",children:["当前 Key 来自",c_[o.source??""]??o.source,",优先级高于界面保存的值,因此这里无法修改。 如需在界面中管理,请先从启动 dsh 的环境中移除 ",s.jsx("code",{children:t})," 再重新启动。"]}):s.jsxs("form",{className:"key-form",onSubmit:L=>{L.preventDefault(),T()},children:[s.jsxs("div",{className:"key-input",children:[s.jsx("input",{type:p?"text":"password",value:h,onChange:L=>{d(L.target.value),E(null)},placeholder:(o==null?void 0:o.configured)===!0?"已配置。输入新的 Key 可替换":c??"粘贴你的 API Key(sk-…)",autoComplete:"off",spellCheck:!1,"aria-label":n,disabled:g}),s.jsx("button",{type:"button",className:"ghost",onClick:()=>m(L=>!L),disabled:h==="",children:p?"隐藏":"显示"})]}),N!==null&&s.jsx("div",{className:"error small",children:N}),s.jsxs("div",{className:"key-actions",children:[i!==void 0&&s.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"small",children:"获取 API Key ↗"}),s.jsx("span",{className:"spacer"}),(o==null?void 0:o.configured)===!0&&o.source==="file"&&s.jsx("button",{type:"button",className:"danger-outline",onClick:()=>void k(),disabled:g,children:"删除"}),s.jsx("button",{type:"submit",className:"primary",disabled:g||h.trim()===""||N!==null,children:g?"保存中…":(o==null?void 0:o.configured)===!0?"替换":"保存"})]})]}),y!==null&&s.jsx("div",{className:y.tone==="ok"?"success small":"error small",children:y.text})]})}function J5({info:e}){return e===null?s.jsx("span",{className:"badge",children:"读取中…"}):e.configured?s.jsxs("span",{className:"badge ok",children:["已配置 · ",c_[e.source??""]??e.source??"未知来源"]}):s.jsx("span",{className:"badge warn",children:"未配置"})}function e9({client:e}){const{catalog:t,error:n}=Zo(e),r=je(e.capabilities),[i,o]=b.useState(!1),[c,u]=b.useState(null),h=t===null?"":`${t.default.provider}/${t.default.model}`,d=async m=>{const[g,...x]=m.split("/");o(!0),u(null);try{await e.connection.call("models/setDefault",{provider:g,model:x.join("/")}),u("已设为默认,新对话会用它。")}catch(y){u(y instanceof Error?y.message:String(y))}finally{o(!1)}},p=(t==null?void 0:t.groups.some(m=>m.models.some(g=>`${m.id}/${g.id}`===h)))??!1;return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"默认模型"}),s.jsx("p",{className:"muted small",children:"先在下面的模型服务里填好 Key,这里就能选它的模型。"})]})}),n!==null&&s.jsx("div",{className:"error small",children:n}),t===null&&n===null&&s.jsx("div",{className:"muted small",children:"读取中…"}),t!==null&&s.jsx(yn,{"aria-label":"默认模型",value:h,disabled:i||!r.has("model-default"),onChange:m=>void d(m),options:[...p?[]:[{value:h,label:`${t.default.provider} / ${t.default.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(m=>m.models.map(g=>({value:`${m.id}/${g.id}`,label:g.name,group:m.name})))]}),t==null?void 0:t.failures.map(m=>s.jsxs("div",{className:"error small",children:[m.name,":",m.message]},m.id)),c!==null&&s.jsx("div",{className:"muted small",children:c})]})}function t9({client:e}){const{catalog:t}=Zo(e),n=je(e.connection.status),[r,i]=b.useState(void 0),[o,c]=b.useState(!1),[u,h]=b.useState(null);b.useEffect(()=>{if(n.state!=="open")return;let g=!0;return e.connection.call("models/roleModel",{}).then(x=>{g&&i(x.model)}).catch(()=>{}),()=>{g=!1}},[e,n.state]);const d=r==null?"":`${r.provider}/${r.model}`,p=async g=>{const[x,...y]=g.split("/"),E=g===""?null:{provider:x,model:y.join("/")};c(!0),h(null);try{const{warning:N}=await e.connection.call("models/setRoleModel",{model:E});i(E),h(N!==void 0?{tone:"warn",text:N}:{tone:"ok",text:E===null?"角色 agent 和以前一样,用默认模型。":"之后新开的干预、游戏、脚本、编排会话用它;已经开着的会话不变。"})}catch(N){h({tone:"warn",text:N instanceof Error?N.message:String(N)})}finally{c(!1)}},m=d===""||((t==null?void 0:t.groups.some(g=>g.models.some(x=>`${g.id}/${x.id}`===d)))??!1);return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"角色 agent 的模型"}),s.jsx("p",{className:"muted small",children:"干预、游戏、脚本、编排这些软件自己开的会话用它。它们主要是截图、看日志、点击,选一个便宜、能看图的模型可以省用量;你自己的对话仍用上面的默认模型。"})]})}),t===null||r===void 0?s.jsx("div",{className:"muted small",children:"读取中…"}):s.jsx(yn,{"aria-label":"角色 agent 的模型",value:d,disabled:o,onChange:g=>void p(g),options:[{value:"",label:"和默认模型一样"},...m?[]:[{value:d,label:`${r.provider} / ${r.model}`,hint:"不可用:这个模型服务没有配好",disabled:!0}],...t.groups.flatMap(g=>g.models.map(x=>({value:`${g.id}/${x.id}`,label:x.name,group:g.name})))]}),u!==null&&s.jsx("div",{className:u.tone==="ok"?"muted small":"error small",children:u.text})]})}const n9=(e,t)=>e.auto===t.auto&&e.threshold===t.threshold;function s9({client:e}){var x;const t=je(e.connection.status),[n,r]=b.useState(null),[i,o]=b.useState(null),[c,u]=b.useState(!1),[h,d]=b.useState(null),p=(x=wr())==null?void 0:x.restartService;b.useEffect(()=>{if(h===null||n===null)return;if(h===n.settings.threshold){d(null);return}const y=setTimeout(()=>void m({...n.settings,threshold:h}).then(()=>d(null)),400);return()=>clearTimeout(y)},[h,n]),b.useEffect(()=>{if(t.state!=="open")return;let y=!0;return e.connection.call("compaction/get",{}).then(E=>{y&&r(E)}).catch(E=>{y&&o(Re(E))}),()=>{y=!1}},[e,t.state]);const m=async y=>{if(!(!y.auto&&(n==null?void 0:n.settings.auto)===!0&&!window.confirm(`关掉自动压缩后,对话超过模型的上下文长度时会直接出错,要手动压缩或开新对话才能继续。
234
+
235
+ 确定关掉吗?`))){u(!0),o(null);try{r(await e.connection.call("compaction/set",{settings:y}))}catch(E){o(Re(E))}finally{u(!1)}}},g=async()=>{p===void 0||!window.confirm(`重启 agent 服务:正在进行的对话和正在跑的脚本、流水线会被中断,大约需要半分钟。
236
+
237
+ 确定现在重启吗?`)||await p()};return s.jsxs("div",{className:"settings-page compaction-page",children:[s.jsx("h2",{children:"对话压缩"}),s.jsx("p",{children:"对话很长时,模型一次看不下全部内容。压缩会把较早的部分换成一份由模型写的摘要,之后 agent 只能看到这份摘要:"}),s.jsxs("ul",{className:"compaction-costs",children:[s.jsxs("li",{children:[s.jsx("strong",{children:"会丢失记忆"}),":早先的细节(具体的命令和输出、日志、截图、你说过的原话)agent 不再记得;"]}),s.jsx("li",{children:"摘要可能漏掉或写错内容,而且不能撤销;"}),s.jsx("li",{children:"界面上的聊天记录还在,只是 agent 看不到了。"})]}),n!==null&&s.jsxs("section",{className:"card",children:[s.jsxs("label",{className:"check-label",children:[s.jsx("input",{type:"checkbox",checked:n.settings.auto,disabled:c,onChange:y=>void m({...n.settings,auto:y.target.checked})}),"对话太长时自动压缩"]}),s.jsx("p",{className:"muted small",children:n.settings.auto?"关掉后不会自动压缩:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。":"已关闭:对话超过模型的上下文长度时会出错,需要手动压缩或开新对话。"}),s.jsxs("label",{className:"field compaction-threshold",children:[s.jsxs("span",{className:"field-title",children:["占满上下文的多少时压缩:",s.jsxs("strong",{children:[h??n.settings.threshold,"%"]}),(h??n.settings.threshold)===Q$?"(默认)":""]}),s.jsx("input",{type:"range",min:oN,max:lN,step:5,value:h??n.settings.threshold,disabled:!n.settings.auto,"aria-label":"压缩阈值(百分比)",onChange:y=>d(Number(y.target.value))}),s.jsx("span",{className:"muted small",children:"调低:压缩得早,回复快、花费少,但记得的细节少;调高:记得的多,但更可能临时压缩一大段。"})]}),!n9(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}%`:"不自动压缩",")。",p===void 0?"重启 MultiGameAssistant(或 dsh)后生效。":""]}),p!==void 0&&s.jsx("button",{className:"small-button",onClick:()=>void g(),children:"重启 agent 服务"})]}),i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:i})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"手动压缩"}),s.jsxs("p",{className:"muted small",children:["在对话框里输入 ",s.jsx("kbd",{children:"/压缩"}),",会先说明代价再确认。对话框旁边的小圆圈显示上下文用了多少,点开能看到各部分占多少。对话变慢、或报上下文超长时用;agent 正在工作时不能压缩。"]})]}),n===null&&i!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:i})]})]})}const ok=[{policy:"default",label:"默认",hint:"跟着上面的模式走"},{policy:"allow",label:"允许",hint:"不问你,直接做"},{policy:"ask",label:"先问我",hint:"每次都先问你,「完全访问」时也问"},{policy:"deny",label:"不允许",hint:"agent 不能做,会告诉你被关掉了"}],r9=[{value:"act",label:"诊断并处理"},{value:"diagnose",label:"只诊断"},{value:"off",label:"不干预"}];function i9({client:e,state:t,onState:n}){const r=je(e.capabilities),[i,o]=b.useState(null),[c,u]=b.useState(null),[h,d]=b.useState(null),p=r.has("monitor");b.useEffect(()=>{if(!p)return;let x=!0;return e.connection.call("monitor/settings",{}).then(y=>{x&&d(y)}).catch(()=>{}),()=>{x=!1}},[e,p]);const m=async(x,y)=>{o(x),u(null);try{n(await e.connection.call("permissions/area/set",{area:x,policy:y}))}catch(E){u(Re(E))}finally{o(null)}},g=async x=>{o("intervene"),u(null);try{d(await e.connection.call("monitor/settings/set",{intervene:x}))}catch(y){u(Re(y))}finally{o(null)}};return s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"card-head",children:s.jsxs("div",{children:[s.jsx("h3",{children:"按范围设置"}),s.jsxs("p",{className:"muted small",children:["agent 能自己做的事,一项一项决定:",ok.map(x=>`「${x.label}」${x.hint}`).join(";"),"。"]})]})}),s.jsxs("div",{className:"area-list",children:[p&&h!==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:r9.map(x=>s.jsx("button",{role:"radio","aria-checked":h.intervene===x.value,className:h.intervene===x.value?"active":"",disabled:i!==null,onClick:()=>void g(x.value),children:x.label},x.value))})]}),H$.map(x=>{const y=t.areas[x.id]??"default";return s.jsxs("div",{className:"area-row",children:[s.jsxs("div",{className:"area-text",children:[s.jsx("strong",{children:x.title}),s.jsx("span",{className:"muted small",children:x.description})]}),s.jsx("div",{className:"segmented-control area-choice",role:"radiogroup","aria-label":x.title,children:ok.map(E=>s.jsx("button",{role:"radio","aria-checked":y===E.policy,title:E.hint,className:`${y===E.policy?"active":""} ${E.policy}`,disabled:i!==null,onClick:()=>void m(x.id,E.policy),children:E.label},E.policy))})]},x.id)})]}),c!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:c})]})]})}const a9=[{mode:"ask",title:"每次确认(推荐)",text:"agent 的命令在沙箱里运行;安装陌生仓库、操作屏幕、沙箱外的命令、修改脚本文件等,都先问你。"},{mode:"full",title:"完全访问",text:"不用沙箱,所有需要确认的操作都自动允许,也可以修改脚本文件:agent 想改什么就改什么,不再问你。"}];function o9({client:e}){const t=je(e.connection.status),n=Cn(3e4),[r,i]=b.useState(null),[o,c]=b.useState(!1),[u,h]=b.useState(null);b.useEffect(()=>e.connection.on("permissions/changed",p=>i(p)),[e]),b.useEffect(()=>{if(t.state!=="open")return;let p=!0;return e.connection.call("permissions/get",{}).then(m=>{p&&i(m)}).catch(m=>{p&&h(Re(m))}),()=>{p=!1}},[e,t.state]);const d=async p=>{if((r==null?void 0:r.mode)!==p&&!(p==="full"&&!window.confirm(`打开「完全访问」后,agent 可以不经确认运行任何命令、修改或删除任何文件(包括脚本文件)、操作屏幕、安装软件。只在你信任当前模型、并且需要它自己完成整件事时打开。
238
+
239
+ 确定打开吗?`))){c(!0),h(null);try{i(await e.connection.call("permissions/set",{mode:p}))}catch(m){h(Re(m))}finally{c(!1)}}};return s.jsxs("div",{className:"settings-page",children:[s.jsx("h2",{children:"权限"}),s.jsx("p",{children:"决定 agent 做事之前要不要先问你。对所有会话都有效,包括飞书里的对话、异常处理和流水线里的 agent 步骤。"}),s.jsxs("section",{className:"card",children:[s.jsx("div",{className:"permission-options",role:"radiogroup","aria-label":"权限",children:a9.map(p=>s.jsxs("button",{role:"radio","aria-checked":(r==null?void 0:r.mode)===p.mode,disabled:o||r===null,className:`permission-option ${p.mode} ${(r==null?void 0:r.mode)===p.mode?"active":""}`,onClick:()=>void d(p.mode),children:[s.jsx("span",{className:"permission-dot","aria-hidden":"true"}),s.jsxs("span",{className:"permission-text",children:[s.jsx("strong",{children:p.title}),s.jsx("span",{children:p.text})]})]},p.mode))}),(r==null?void 0:r.mode)==="full"&&s.jsxs("div",{className:"notice warn-note left small",children:[s.jsx(Q,{name:"alert"}),s.jsxs("span",{children:["完全访问一直开着,没有时间限制,直到你改回「每次确认」",r.since===void 0?"":`(${l9(r.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})]})]}),r!==null&&s.jsx(i9,{client:e,state:r,onState:i}),r!==null&&r.recent.length>0&&s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"没问你就允许了的操作"}),s.jsxs("p",{className:"muted small",children:["因为「完全访问」或某个范围设成了「允许」。程序这次启动以来,最近 ",r.recent.length," 条。"]}),s.jsx("ul",{className:"version-list",children:r.recent.map((p,m)=>s.jsxs("li",{children:[s.jsx("span",{className:"badge",children:p.toolName}),s.jsx("span",{className:"permission-reason",children:p.reason??"(没有说明)"}),s.jsx("span",{className:"spacer"}),s.jsx("span",{className:"session-time",children:At(p.at,n)})]},m))})]})]})}function l9(e,t){const n=At(e,t);return n==="刚刚"?"刚刚打开":/^\d+ (分钟|小时|天)$/.test(n)?`${n}前打开`:`${n} 打开`}const d_=[{style:"default",title:"默认",sample:"不加设定,按模型自己的说话方式。"},{style:"concise",title:"简洁干练",sample:"「日常跑完了,3 个成功 1 个失败:MAA 刷理智没体力了。」"},{style:"patient",title:"耐心细致",sample:"「我先帮你看了 MAA 的日志,失败是因为理智不够——这不是脚本坏了,等理智恢复再跑就行。」"},{style:"lively",title:"活泼可爱",sample:"「搞定啦~日常都跑完了!就是理智又见底了 (。•́︿•̀。)」"},{style:"buddy",title:"游戏搭子",sample:"「日常清完了,理智又被榨干了哈哈,活动商店还差两样,明天接着肝。」"},{style:"butler",title:"稳重管家",sample:"「今日日常已完成。另有一项需要您决定:活动商店剩余两件,是否明日继续兑换?」"}],c9=[{style:"plain",title:"平实(推荐)",text:"直接说事,不带人设和称呼:它们要读的是内容。"},{style:"same",title:"和对你说话一样",text:"人设也带到 agent 之间的往来里。你在「协作」里看到的就是这个语气。"}],Is="";function lk(e){return e===void 0||e.style===void 0&&e.callUser===void 0&&e.custom===void 0&&e.peerStyle===void 0}function u9({client:e}){var D,B;const t=je(e.connection.status),n=Er(e),[r,i]=b.useState(null),[o,c]=b.useState({all:"",agents:{}}),[u,h]=b.useState(Is),[d,p]=b.useState(!1),[m,g]=b.useState(!1),[x,y]=b.useState(null),[E,N]=b.useState(!1),w=_=>{i({persona:_.persona,agents:_.agents}),c({all:_.prompt,agents:_.prompts})};b.useEffect(()=>{if(t.state!=="open")return;let _=!0;return e.connection.call("persona/get",{}).then(C=>{_&&w(C)}).catch(C=>{_&&y(Re(C))}),()=>{_=!1}},[e,t.state]);const T=_=>{i(_),p(!0),N(!1)},k=async(_=r)=>{if(_!==null){g(!0),y(null);try{w(await e.connection.call("persona/set",_)),p(!1),N(!0)}catch(C){y(Re(C))}finally{g(!1)}}},I=[{id:Rn.id,name:Rn.name},...n],L=_=>{r!==null&&T({...r,persona:{...r.persona,..._}})},z=r==null?void 0:r.agents[u],U=_=>{r!==null&&T({...r,agents:{...r.agents,[u]:{...z,..._}}})},V=_=>r===null?null:{...r,agents:{...r.agents,[u]:_===void 0?{}:{name:_}}},$=u!==Is&&!lk(z),P=u===Is?o.all:o.agents[u]??"";return s.jsxs("div",{className:"settings-page persona-page",children:[s.jsx("h2",{children:"回复风格"}),s.jsx("p",{children:"agent 说话的方式和人设:可以统一设置,也可以给某个 agent 单独设置。软件里的对话、飞书里的回复、流水线里的 agent 步骤都算。只改说话方式:它们能做什么、该做什么、什么要问你,都不变。子 agent 不用设置,它们只把结果交回给开它们的 agent。"}),r!==null&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"persona-scope segmented-control",role:"tablist","aria-label":"设置给谁",children:[s.jsx("button",{role:"tab","aria-selected":u===Is,className:u===Is?"active":"",onClick:()=>h(Is),children:"统一"}),I.map(_=>s.jsxs("button",{role:"tab","aria-selected":u===_.id,className:u===_.id?"active":"",onClick:()=>h(_.id),children:[_.name,!lk(r.agents[_.id])&&s.jsx("span",{className:"persona-own-dot",title:"有单独设置"})]},_.id))]}),u!==Is&&s.jsxs("section",{className:"card",children:[s.jsx("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",maxLength:20,placeholder:"例如:小助",value:(z==null?void 0:z.name)??"",onChange:_=>U({name:_.target.value})}),s.jsx("span",{className:"muted small",children:"它自称时用这个名字;别的 agent 也会知道你这么叫它。"})]})}),s.jsxs("div",{className:"segmented-control persona-follow",role:"radiogroup","aria-label":"说话方式",children:[s.jsx("button",{role:"radio","aria-checked":!$,className:$?"":"active",onClick:()=>{const _=V(z==null?void 0:z.name);_!==null&&$&&T(_)},children:"跟随统一"}),s.jsx("button",{role:"radio","aria-checked":$,className:$?"active":"",onClick:()=>{$||U({style:r.persona.style})},children:"单独设置"})]}),!$&&s.jsxs("p",{className:"muted small",children:["说话方式和「统一」一样:",(D=d_.find(_=>_.style===r.persona.style))==null?void 0:D.title,"。"]})]}),(u===Is||$)&&s.jsx(d9,{value:u===Is?r.persona:{style:(z==null?void 0:z.style)??r.persona.style,callUser:z==null?void 0:z.callUser,custom:z==null?void 0:z.custom,peerStyle:(z==null?void 0:z.peerStyle)??r.persona.peerStyle},shared:u===Is?void 0:r.persona,onChange:u===Is?L:U}),s.jsxs("section",{className:"card",children:[s.jsxs("div",{className:"persona-actions",children:[s.jsx("button",{className:"primary",disabled:m||!d,onClick:()=>void k(),children:m?"保存中…":"保存"}),u===Is?s.jsx("button",{disabled:m,onClick:()=>void k({...r,persona:{style:"default"}}),children:"统一设置恢复默认"}):$&&s.jsx("button",{disabled:m,onClick:()=>void k(V(z==null?void 0:z.name)),children:"恢复跟随统一"}),E&&!d&&s.jsx("span",{className:"muted small",children:"已保存,下一句回复开始生效。"})]}),x!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:x})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:u===Is?"加到 agent 提示词里的内容":`加到「${((B=I.find(_=>_.id===u))==null?void 0:B.name)??u}」提示词里的内容`}),P===""?s.jsx("p",{className:"muted small",children:"现在什么都不加。"}):s.jsx("pre",{className:"persona-prompt",children:P}),d&&s.jsx("p",{className:"muted small",children:"保存后更新。"})]})]}),r===null&&x!==null&&s.jsxs("div",{className:"notice error left",children:[s.jsx(Q,{name:"alert"}),s.jsx("span",{children:x})]})]})}function d9({value:e,shared:t,onChange:n}){const r=e.peerStyle??"plain",i=(o,c)=>t===void 0?c:o===void 0||o===""?"留空:和统一一样(现在没有设置)":`留空:和统一一样(${o})`;return s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"风格"}),s.jsx("div",{className:"persona-styles",role:"radiogroup","aria-label":"风格",children:d_.map(o=>s.jsxs("button",{role:"radio","aria-checked":e.style===o.style,className:`mode-option persona-style ${e.style===o.style?"selected":""}`,onClick:()=>n({style:o.style}),children:[s.jsx("strong",{children:o.title}),s.jsx("span",{className:"muted small",children:o.sample})]},o.style))})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"对你"}),s.jsx("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",maxLength:20,placeholder:i(t==null?void 0:t.callUser,"例如:博士、开拓者、指挥官"),value:e.callUser??"",onChange:o=>n({callUser:o.target.value})})]})}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-title",children:"其他要求(可选)"}),s.jsx("textarea",{className:"text-input plain",rows:5,placeholder:i(t==null?void 0:t.custom,"例如:说话带一点罗德岛干员的口吻;汇报时先说有没有失败;不要用表情。"),value:e.custom??"",onChange:o=>n({custom:o.target.value})})]})]}),s.jsxs("section",{className:"card",children:[s.jsx("h3",{children:"对其他 agent"}),s.jsx("div",{className:"persona-styles",role:"radiogroup","aria-label":"对其他 agent",children:c9.map(o=>s.jsxs("button",{role:"radio","aria-checked":r===o.style,className:`mode-option persona-style ${r===o.style?"selected":""}`,onClick:()=>n({peerStyle:o.style}),children:[s.jsx("strong",{children:o.title}),s.jsx("span",{className:"muted small",children:o.text})]},o.style))})]})]})}const h9={id:"settings-credentials",title:"模型",requires:["credentials","models"],settingsPages:[{id:"api-keys",title:"模型",order:0,component:X5}]},f9={id:"permissions",title:"权限",requires:["permissions"],settingsPages:[{id:"permissions",title:"权限",order:1,component:o9}]},p9={id:"persona",title:"回复风格",requires:["persona"],settingsPages:[{id:"persona",title:"回复风格",order:2,component:u9}]},m9={id:"compaction",title:"对话压缩",requires:["compaction"],settingsPages:[{id:"compaction",title:"对话压缩",order:3,component:s9}]},g9={id:"about",title:"关于",requires:[],settingsPages:[{id:"about",title:"关于",order:100,component:L5}]};function x9({client:e}){const t=je(e.capabilities),n=je(e.connection.server),[r,i]=b.useState(0);b.useEffect(()=>jN(()=>i(h=>h+1)),[]);const o=b.useMemo(()=>ZM(t),[t,r]),c=o.filter(h=>h.missing.length===0),u=o.filter(h=>h.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(h=>s.jsx("span",{className:"chip",children:h},h)),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:h})=>s.jsxs("li",{children:[s.jsx("span",{className:"plugin-name",children:h.title}),s.jsx("span",{className:"muted small",children:h.requires.length===0?"无需后端能力":h.requires.join(" · ")})]},h.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:h,missing:d})=>s.jsxs("li",{children:[s.jsxs("span",{className:"plugin-name",children:[h.title,h.milestone!==void 0&&s.jsx("span",{className:"chip subtle",children:h.milestone})]}),s.jsxs("span",{className:"muted small",children:["缺少:",d.join(" · ")]})]},h.id))})]})]})}const v9={id:"plugin-status",title:"插件状态",requires:[],settingsPages:[{id:"plugins",title:"插件状态",order:90,component:x9}]};function y9(e,t,n){const r=new Array(e);return new Proxy(r,{get(i,o,c){if(typeof o=="string"){const u=o.charCodeAt(0);if(u>=48&&u<=57){const h=+o;if(Number.isInteger(h)&&h>=0&&h<e){let d=i[h];if(!d){const p=t[h*2];d=i[h]={index:h,key:n(h),start:p,size:t[h*2+1],end:p+t[h*2+1],lane:0}}return d}}if(o==="length")return e}return Reflect.get(i,o,c)}})}function uo(e,t,n){let r=n.initialDeps??[],i,o=!0;function c(){const u=e();return(u.length!==r.length||u.some((d,p)=>r[p]!==d))&&(r=u,i=t(...u),n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(i),o=!1),i}return c.updateDeps=u=>{r=u},c}function ck(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const b9=(e,t)=>Math.abs(e-t)<1.01,k9=(e,t,n)=>{let r;return Object.assign(function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)},{cancel:()=>{e.clearTimeout(r)}})};let Rl;const bp=()=>{if(Rl!==void 0)return Rl;if(typeof navigator>"u")return Rl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Rl=!0;const e=navigator.maxTouchPoints;return Rl=navigator.platform==="MacIntel"&&e!==void 0&&e>0},uk=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},N9=e=>e,w9=e=>{const t=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,i=new Array(r);for(let o=0;o<r;o++)i[o]=t+o;return i},j9=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const i=c=>{const{width:u,height:h}=c;t({width:Math.round(u),height:Math.round(h)})};if(i(uk(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(c=>{const u=()=>{const h=c[0];if(h!=null&&h.borderBoxSize){const d=h.borderBoxSize[0];if(d){i({width:d.inlineSize,height:d.blockSize});return}}i(uk(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(u):u()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},Nd={passive:!0},S9=typeof window>"u"?!0:"onscrollend"in window,_9=(e,t,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const o=e.options.useScrollendEvent&&S9;let c=0;const u=o?null:k9(i,()=>t(c,!1),e.options.isScrollingResetDelay),h=m=>()=>{c=n(r),u==null||u(),t(c,m)},d=h(!0),p=h(!1);return r.addEventListener("scroll",d,Nd),o&&r.addEventListener("scrollend",p,Nd),()=>{r.removeEventListener("scroll",d),o&&r.removeEventListener("scrollend",p),u==null||u.cancel()}},E9=(e,t)=>_9(e,t,n=>{const{horizontal:r,isRtl:i}=e.options;return r?n.scrollLeft*(i&&-1||1):n.scrollTop}),C9=(e,t,n)=>{if(n.options.useCachedMeasurements){const r=n.indexFromElement(e),i=n.options.getItemKey(r);return n.itemSizeCache.get(i)??n.options.estimateSize(r)}if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const r=n.indexFromElement(e),i=n.options.getItemKey(r),o=n.itemSizeCache.get(i);if(o!==void 0)return o}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},A9=(e,{adjustments:t=0,behavior:n},r)=>{var i,o;(o=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||o.call(i,{[r.options.horizontal?"left":"top"]:e+t,behavior:n})},I9=A9;class T9{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var n,r,i;return((i=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:i.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(o=>{const c=()=>{const u=o.target,h=this.indexFromElement(u);if(!u.isConnected){this.observer.unobserve(u);for(const[d,p]of this.elementsCache)if(p===u){this.elementsCache.delete(d);break}return}this.isIndexInRange(h)&&this.shouldMeasureDuringScroll(h)&&this.resizeItem(h,this.options.measureElement(u,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var o;return(o=r())==null?void 0:o.observe(i,{box:"border-box"})},unobserve:i=>{var o;return(o=r())==null?void 0:o.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{var r,i;const o={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:N9,rangeExtractor:w9,onChange:()=>{},measureElement:C9,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const g in n){const x=n[g];x!==void 0&&(o[g]=x)}const c=this.options;let u=null,h=null,d=!1;if(c!==void 0&&c.enabled&&o.enabled&&o.anchorTo==="end"&&this.scrollElement!==null){const g=c.count,x=o.count,y=this.getMeasurements(),E=g>0?((r=y[0])==null?void 0:r.key)??c.getItemKey(0):null,N=g>0?((i=y[g-1])==null?void 0:i.key)??c.getItemKey(g-1):null;if(x!==g||g>0&&x>0&&(o.getItemKey(0)!==E||o.getItemKey(x-1)!==N)){d=!0;const k=g>0?this.getVirtualItemForOffset(this.getScrollOffset())??y[0]:null;k&&(u=[k.key,this.getScrollOffset()-k.start]);const I=o.followOnAppend===!0?"auto":o.followOnAppend||null;I&&x>g&&this.isAtEnd(c.scrollEndThreshold)&&(g===0||o.getItemKey(x-1)!==N)&&(h=I)}}this.options=o,d&&(this.pendingMin=0,this.itemSizeCacheVersion++);let p=!1,m=0;if(u&&this.scrollOffset!==null){const[g,x]=u,y=this.getMeasurements(),{count:E,getItemKey:N}=this.options;let w=0;for(;w<E&&N(w)!==g;)w++;if(w<E){const T=y[w];if(T){const k=Math.max(0,T.start+x);k!==this.scrollOffset&&(m=k-this.scrollOffset,this.scrollOffset=k,p=!0)}}}(p||h)&&(this.pendingScrollAnchor=[p?u[0]:null,p?u[1]:0,h,m])},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=uo(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,c)=>{if(c&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5&&(o=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;const u=this.getScrollOffset();this.scrollDirection=c?u===o?this.scrollDirection:u<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=c,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,c=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},u=()=>{this._iosTouching=!1,!(!bp()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",c,Nd),o.addEventListener("touchend",u,Nd),this.unsubs.push(()=>{o.removeEventListener("touchstart",c),o.removeEventListener("touchend",u),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const i=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,i&&this.scrollElement&&this.options.enabled){const[o,c,u,h]=i;o!==null&&!u&&(bp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?h!==0&&(this._iosDeferredAdjustment+=h):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),u&&this.scrollToEnd({behavior:u})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),r=this.getMaxScrollOffset();if(n<0||n>r)return;if(this._iosDeferredAdjustment<0&&n>=r-1){this._iosDeferredAdjustment=0;return}const i=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=i,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=uo(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,r,i,o,c,u,h,d)=>(this.prevLanes!==void 0&&this.prevLanes!==u&&(this.lanesChangedFlag=!0),this.prevLanes=u,this.pendingMin=null,{count:n,paddingStart:r,scrollMargin:i,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:h,gap:d}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=uo(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:r,scrollMargin:i,getItemKey:o,enabled:c,lanes:u,laneAssignmentMode:h,gap:d},p)=>{const m=this.itemSizeCache;if(!c)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const w of this.laneAssignments.keys())w>=n&&this.laneAssignments.delete(w);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(w=>{this.itemSizeCache.set(w.key,w.size)}));const g=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),u===1){const w=n*2;let T=this._flatMeasurements;if(!T||T.length<w){const L=new Float64Array(w);T&&g>0&&L.set(T.subarray(0,g*2)),T=L,this._flatMeasurements=T}let k;if(g===0)k=r+i;else{const L=g-1;k=T[L*2]+T[L*2+1]+d}for(let L=g;L<n;L++){const z=o(L),U=m.get(z),V=typeof U=="number"?U:this.options.estimateSize(L);T[L*2]=k,T[L*2+1]=V,k+=V+d}const I=y9(n,T,o);return this.measurementsCache=I,I}const x=this.measurementsCache.slice(0,g),y=new Array(u).fill(void 0),E=new Float64Array(u);let N=0;for(let w=0;w<g;w++){const T=x[w];T&&(y[T.lane]===void 0&&N++,y[T.lane]=w,E[T.lane]=T.end)}for(let w=g;w<n;w++){const T=o(w),k=this.laneAssignments.get(w);let I,L;const z=h==="estimate"||m.has(T);if(k!==void 0&&this.options.lanes>1){I=k;const P=y[I],D=P!==void 0?x[P]:void 0;L=D?D.end+d:r+i}else if(N===u){let P=0,D=E[0],B=y[0];for(let _=1;_<u;_++){const C=E[_];(C<D||C===D&&y[_]<B)&&(P=_,D=C,B=y[_])}I=P,L=D+d,z&&this.laneAssignments.set(w,I)}else I=w%this.options.lanes,L=r+i,z&&this.laneAssignments.set(w,I);const U=m.get(T),V=typeof U=="number"?U:this.options.estimateSize(w),$=L+V;x[w]={index:w,start:L,size:V,end:$,key:T,lane:I},y[I]===void 0&&N++,y[I]=w,E[I]=$}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=uo(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,i,o)=>n.length===0||r===0?(this.range=null,null):(this.range=M9(n,r,i,o,o===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=uo(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,o,c)=>o===null||c===null?[]:n({startIndex:o,endIndex:c,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const i=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(i!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),c=Math.max(0,i-o),u=Math.min(this.options.count-1,i+o);return n>=c&&n<=u}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((c,u)=>{c.isConnected||(this.observer.unobserve(c),this.elementsCache.delete(u))});return}const r=this.indexFromElement(n);if(!this.isIndexInRange(r))return;const i=this.options.getItemKey(r),o=this.elementsCache.get(i);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(i,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var i,o;if(!this.isIndexInRange(n))return;let c,u,h;const d=this._flatMeasurements;if(this.options.lanes===1&&d!==null)h=this.options.getItemKey(n),u=d[n*2],c=d[n*2+1];else{const g=this.measurementsCache[n];if(!g)return;h=g.key,u=g.start,c=g.size}const p=this.itemSizeCache.get(h)??c,m=r-p;if(m!==0){const g=this.options.anchorTo==="end"&&((i=this.scrollState)==null?void 0:i.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,x=g?this.getTotalSize():0,y=this.getScrollOffset()+this.scrollAdjustments,N=!this.itemSizeCache.has(h)?u<y:u+p<=y&&this.scrollDirection!=="backward",w=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:h,start:u,size:c,end:u+c,lane:0},m,this):N);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(h,r),this.itemSizeCacheVersion++;let T=!1;g?T=this.applyScrollAdjustment(this.getTotalSize()-x):w&&(T=this.applyScrollAdjustment(m)),this.notify(T)}},this.getVirtualItems=uo(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let o=0,c=n.length;o<c;o++){const u=n[o],h=r[u];i.push(h)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length===0)return;const i=this._flatMeasurements,o=this.options.lanes===1&&i!=null,c=h_(0,r.length-1,o?u=>i[u*2]:u=>ck(r[u]).start,n);return ck(r[c])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,r,i=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),c=this.getScrollOffset();r==="auto"&&(r=n>=c+o?"end":"start"),r==="center"?n+=(i-o)/2:r==="end"&&(n-=o);const u=this.getMaxScrollOffset();return Math.max(Math.min(u,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getSize(),o=this.getScrollOffset(),c=this.measurementsCache[n];if(!c)return;if(r==="auto")if(c.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(c.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const u=r==="end"?c.end+this.options.scrollPaddingEnd:c.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(u,r,c.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0;const o=this.getOffsetForAlignment(n,r),c=this.now();this.scrollState={index:null,align:r,behavior:i,startedAt:c,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:i="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,r);if(!o)return;const[c,u]=o,h=this.now();this.scrollState={index:n,align:u,behavior:i,startedAt:h,lastTargetOffset:c,stableFrames:0},this._scrollToOffset(c,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const i=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:n});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;if(r.length===0)i=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,c=this._flatMeasurements;c!=null?i=c[o*2]+c[o*2+1]:i=((n=r[o])==null?void 0:n.end)??0}else{const o=Array(this.options.lanes).fill(null);let c=r.length-1;for(;c>=0&&o.some(u=>u===null);){const u=r[c];o[u.lane]===null&&(o[u.lane]=u.end),c--}i=Math.max(...o.filter(u=>u!==null))}return Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const r=this.getMeasurements();for(const i of r)i&&this.itemSizeCache.has(i.key)&&n.push({index:i.index,key:i.key,start:i.start,size:i.size,end:i.end,lane:i.lane});return n},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this._intendedScrollOffset=n+(r??0),this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){return t===0?!1:bp()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=t,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,i=r?r[0]:this.scrollState.lastTargetOffset,o=1,c=i!==this.scrollState.lastTargetOffset;if(!c&&b9(i,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.getScrollOffset()!==i&&this._scrollToOffset(i,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,c){const u=this.getSize()||600,h=Math.abs(i-this.getScrollOffset()),d=this.scrollState.behavior==="smooth"&&h>u;this.scrollState.lastTargetOffset=i,d||(this.scrollState.behavior="auto"),this._scrollToOffset(i,{adjustments:void 0,behavior:d?"smooth":"auto"})}this.scheduleScrollReconcile()}}const h_=(e,t,n,r)=>{for(;e<=t;){const i=(e+t)/2|0,o=n(i);if(o<r)e=i+1;else if(o>r)t=i-1;else return i}return e>0?e-1:0};function $9(e,t,n){let r=0;for(;r<=t;){const i=(r+t)/2|0,o=e[i*2];if(o<n)r=i+1;else if(o>n)t=i-1;else return i}return r>0?r-1:0}function M9(e,t,n,r,i){const o=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:o};if(r===1&&i!==null){const d=$9(i,o,n);let p=d;const m=n+t;for(;p<o&&i[p*2]+i[p*2+1]<m;)p++;return{startIndex:d,endIndex:p}}let u=h_(0,o,d=>e[d].start,n),h=u;if(r===1)for(;h<o&&e[h].end<n+t;)h++;else if(r>1){const d=Array(r).fill(0);for(;h<o&&d.some(m=>m<n+t);){const m=e[h];d[m.lane]=m.end,h++}const p=Array(r).fill(n+t);for(;u>=0&&p.some(m=>m>=n);){const m=e[u];p[m.lane]=m.start,u--}u=Math.max(0,u-u%r),h=Math.min(o,h+(r-1-h%r))}return{startIndex:u,endIndex:h}}const kp=typeof document<"u"?b.useLayoutEffect:b.useEffect;function R9({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...r}){const i=b.useReducer(p=>p+1,0)[1],o=b.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});o.current.enabled=t,o.current.mode=n;const c=p=>{const m=o.current;if(!m.enabled||!m.container)return;const g=p.getTotalSize();if(g!==m.lastSize){m.lastSize=g;const x=p.options.horizontal?"width":"height";m.container.style[x]=`${g}px`}},u=p=>{const m=o.current;if(!m.enabled||!m.container)return;c(p);const g=!!p.options.horizontal,x=m.mode==="transform",y=g?"left":"top",E=p.options.scrollMargin,N=p.getVirtualItems();for(const w of N){const T=w.start-E,k=p.elementsCache.get(w.key);k&&m.lastPositions.get(k)!==T&&(m.lastPositions.set(k,T),x?k.style.transform=g?`translate3d(${T}px, 0, 0)`:`translate3d(0, ${T}px, 0)`:k.style[y]=`${T}px`)}},h={...r,onChange:(p,m)=>{var g;const x=o.current;let y=!0;if(x.enabled){u(p);const E=p.range,N=x.prevRange;y=!N||N.isScrolling!==p.isScrolling||N.startIndex!==(E==null?void 0:E.startIndex)||N.endIndex!==(E==null?void 0:E.endIndex),y&&(x.prevRange=E?{startIndex:E.startIndex,endIndex:E.endIndex,isScrolling:p.isScrolling}:null)}y&&(e&&m?tg.flushSync(i):i()),(g=r.onChange)==null||g.call(r,p,m)}},[d]=b.useState(()=>{const p=new T9(h);return Object.assign(p,{containerRef:m=>{const g=o.current;if(g.container=m,g.lastSize=null,m&&g.enabled){const x=p.getTotalSize();g.lastSize=x;const y=p.options.horizontal?"width":"height";m.style[y]=`${x}px`}}})});return d.setOptions(h),kp(()=>d._didMount(),[]),kp(()=>(c(d),d._willUpdate())),kp(()=>{u(d)}),d}function O9(e){return R9({observeElementRect:j9,observeElementOffset:E9,scrollToFn:I9,...e})}const Wd={user:"用户",context:"上下文",system:"系统",assistant:"助手",attempt:"失败尝试",tool:"工具",compaction:"压缩"},f_={ok:"已完成",error:"失败",running:"运行中",interrupted:"已中断"},z9={completed:"已完成",aborted:"已停止",error:"失败",blocked:"已阻止","max-tokens":"达到输出上限",interrupted:"已中断",forked:"已分叉"};function P9(e){return e.turn===null?"轮次之间":`第 ${e.turn} 轮`}function L9(e){return e.end===null?"进行中":e.reason===void 0?"":z9[e.reason.kind]??e.reason.kind}function p_(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 Kl(e){return e.end===null||e.end<e.start?void 0:e.end-e.start}function wd(e){return e.kind==="assistant"?e.content.filter(t=>t.type==="tool-call").length:0}function D9({record:e,totals:t,onClose:n}){const r=B9(e,t),[i,o]=b.useState(r[0].id),c=r.find(u=>u.id===i)??r[0];return s.jsxs("aside",{className:"inspector","aria-label":"事件详情",children:[s.jsxs("header",{className:"inspector-head",children:[s.jsx("span",{className:`kind-badge kind-${e.kind}`,children:Wd[e.kind]}),s.jsx("span",{className:"inspector-title",title:e.title,children:F9(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:r.map(u=>s.jsx("button",{role:"tab","aria-selected":u.id===c.id,className:u.id===c.id?"active":"",onClick:()=>o(u.id),children:u.label},u.id))}),s.jsx("div",{className:"inspector-body",children:c.render()})]})}function F9(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 Wd[e.kind]}}function B9(e,t){switch(e.kind){case"assistant":return[{id:"summary",label:"概述",render:()=>s.jsx(U9,{record:e})},{id:"raw",label:"原始输出",render:()=>s.jsx(Np,{content:e.content})},{id:"usage",label:"用量",render:()=>s.jsx(H9,{record:e,totals:t})},{id:"timing",label:"计时",render:()=>s.jsx(Z9,{record:e})}];case"tool":return[{id:"summary",label:"概述",render:()=>s.jsx(qi,{rows:[["状态",s.jsx(Xu,{record:e})],["工具",s.jsx("code",{children:e.name})],["调用 ID",s.jsx("code",{children:e.callId})],["开始时间",Zi(e.start)],["时长",e.end===null?"运行中":Os(Kl(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===""?"未捕获参数":eg(e.arguments)})},{id:"result",label:"结果",render:()=>e.result===void 0?s.jsx("p",{className:"muted",children:"未捕获结果"}):s.jsx(Np,{content:e.result})}];case"user":case"context":return[{id:"summary",label:"概述",render:()=>s.jsxs(s.Fragment,{children:[s.jsx(qi,{rows:[["来源",e.origin.human?"用户":e.origin.kind],["时间",Zi(e.start)],["附件",e.imageCount+e.fileCount===0?void 0:`图片 ×${e.imageCount} · 文件 ×${e.fileCount}`]]}),s.jsx("div",{className:"label",children:"预览"}),s.jsx(Np,{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(qi,{rows:[["状态",s.jsx(Xu,{record:e})],["开始时间",Zi(e.start)],["时长",Os(Kl(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(qi,{rows:[["状态",s.jsx(Xu,{record:e})],["开始时间",Zi(e.start)],["时长",e.end===null?"运行中":Os(Kl(e))],["已压缩",e.shadowedTokenCount===void 0?void 0:`${vn(e.shadowedTokenCount)} tok`],["输入 / 输出",e.usage===void 0?void 0:`${vn(e.usage.inputTokens)} / ${vn(e.usage.outputTokens)} tok`],["错误",e.error]]})}]}}function Xu({record:e}){return s.jsx("span",{className:`status-text status-${e.status}`,children:f_[e.status]})}function qi({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 U9({record:e}){const t=e.request,n=e.content.filter(i=>i.type==="text").map(i=>i.type==="text"?i.text:"").join(""),r=e.content.filter(i=>i.type==="tool-call");return s.jsxs(s.Fragment,{children:[s.jsx(qi,{rows:[["状态",s.jsx(Xu,{record:e})],["请求",`#${t.index}`],["提供方",t.provider],["模型",t.model],["推理强度",t.reasoningEffort],["可用工具",t.toolCount===void 0?void 0:String(t.toolCount)],["工具调用",r.length===0?void 0:String(r.length)],["重试",t.retries===0?void 0:String(t.retries)],["上次尝试错误",t.lastRetryError===void 0?void 0:`${t.lastRetryError.message}${t.lastRetryError.code===void 0?"":` (${t.lastRetryError.code})`}`]]}),n.trim()!==""&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"助手消息"}),s.jsx(Nr,{text:n,className:"inspector-markdown"})]}),n.trim()===""&&r.length>0&&s.jsx("p",{className:"muted small",children:"(仅工具调用)"}),r.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"label",children:"工具调用"}),s.jsx("ul",{className:"call-list",children:r.map(i=>s.jsxs("li",{children:[s.jsx("code",{children:i.name})," ",s.jsx("span",{className:"muted",children:i.arguments.slice(0,120)})]},i.callId))})]})]})}function Np({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(Nr,{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:eg(t.arguments)})]},n);case"image":return s.jsxs("div",{className:"raw-block muted small",children:["🖼 ",t.name??`图片 ${n+1}`," ",t.width!==void 0?`${t.width}×${t.height}`:""]},n);case"file":return s.jsxs("div",{className:"raw-block muted small",children:["📎 ",t.name??"文件"," ",t.size===void 0?"":`${vn(t.size)}B`]},n);default:return s.jsxs("div",{className:"raw-block muted small",children:["[",t.kind,"]"]},n)}})})}function H9({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(qi,{rows:[["输入(未缓存)",`${vn(n.inputTokens)} tok`],["缓存读取",n.cacheReadTokens===void 0?void 0:`${vn(n.cacheReadTokens)} tok`],["缓存写入",n.cacheWriteTokens===void 0?void 0:`${vn(n.cacheWriteTokens)} tok`],["输入合计",`${vn(p_(e))} tok`],["输出",`${vn(n.outputTokens)} tok`],["其中推理",n.reasoningTokens===void 0?void 0:`${vn(n.reasoningTokens)} tok`],["总计",n.totalTokens===void 0?void 0:`${vn(n.totalTokens)} tok`]]}),s.jsx("h4",{className:"usage-heading",children:"已加载窗口累计"}),s.jsx(qi,{rows:[["请求数",String(t.requests)],["输入(未缓存)",`${vn(t.inputTokens)} tok`],["缓存读取",`${vn(t.cacheReadTokens)} tok`],["输出",`${vn(t.outputTokens)} tok`],["其中推理",`${vn(t.reasoningTokens)} tok`]]})]})}function Z9({record:e}){const[t,n]=b.useState(!1),r=e.request;return s.jsx(qi,{rows:[["开始时间",s.jsx("button",{className:"link-button",onClick:()=>n(i=>!i),title:t?"显示本地时间":"显示 Unix 时间戳",children:t?String(e.start):Zi(e.start)})],["总时长",e.end===null?"运行中":Os(Kl(e))],["首 token 延迟",r.ttftMs===void 0?"不可用(步骤开始时间或首 token 不在已加载范围内)":Os(r.ttftMs)],["生成",r.decodeMs===void 0?e.live?"运行中":"不可用":Os(r.decodeMs)],["吞吐量",r.tokensPerSecond===void 0?r.usage===void 0?"用量不可用":"时长过短":`${r.tokensPerSecond.toFixed(1)} tok/s`],["工具调用",wd(e)===0?void 0:String(wd(e))],["计时来源",e.live?"会话时间戳(运行中)":"会话时间戳"]]})}const Du=14,W9=b.memo(function({model:t,mode:n,brush:r,selectedId:i,onBrush:o,onSelect:c}){const u=b.useMemo(()=>lz(t),[t]),h=b.useMemo(()=>Pw.map((P,D)=>({...P,index:D})).filter(P=>P.id!=="compaction"||u.some(D=>D.lane===P.index)),[u]),d=new Map(h.map((P,D)=>[P.index,D])),p=t.span,[m,g]=b.useState(null),x=n==="actual"&&p!==null?V9(m,p):null,y=b.useRef(null),[E,N]=b.useState(null),w=b.useRef(null),T=t.records.length,k=(P,D)=>n==="equal"?T===0?0:P/T:x===null||x.end===x.start?0:(D-x.start)/(x.end-x.start),I=P=>{var B;const D=(B=y.current)==null?void 0:B.getBoundingClientRect();return D===void 0||D.width===0?0:Math.min(1,Math.max(0,(P-D.left)/D.width))},L=P=>{if(P.button===2&&x!==null&&p!==null&&(x.start>p.start||x.end<p.end)){w.current={x:P.clientX,view:x};return}if(P.button!==0)return;const D=I(P.clientX);N({x0:D,x1:D})},z=P=>{if(w.current!==null&&p!==null&&y.current!==null){const D=(P.clientX-w.current.x)/y.current.clientWidth,B=w.current.view.end-w.current.view.start;g(dz(w.current.view,-D*B,p));return}E!==null&&N({...E,x1:I(P.clientX)})},U=()=>{if(w.current=null,E===null)return;const[P,D]=E.x0<E.x1?[E.x0,E.x1]:[E.x1,E.x0];if(N(null),!(D-P<.005)){if(n==="equal")o({mode:"equal",from:Math.floor(P*T),to:Math.max(Math.floor(P*T),Math.ceil(D*T)-1)});else if(x!==null){const B=x.end-x.start;o({mode:"actual",range:{start:x.start+P*B,end:x.start+D*B}})}}},V=P=>{if(n!=="actual"||x===null||p===null)return;const D=x.end-x.start;g(uz(x,x.start+I(P.clientX)*D,P.deltaY>0?1.25:.8,p))};if(T===0||p===null)return s.jsx("div",{className:"overview empty-overview muted small",children:"无计时数据"});const $=r===null?null:r.mode==="equal"?n==="equal"?{left:r.from/T,right:(r.to+1)/T}:null:n==="actual"?{left:k(0,r.range.start),right:k(0,r.range.end)}:null;return s.jsxs("div",{className:"overview",onContextMenu:P=>{P.preventDefault(),w.current===null&&o(null)},children:[s.jsx("div",{className:"overview-lanes",children:h.map(P=>s.jsx("div",{className:"lane-label",style:{height:Du},children:q9(P.id)},P.id))}),s.jsxs("div",{className:"overview-track",ref:y,style:{height:h.length*(Du+2)},onMouseDown:L,onMouseMove:z,onMouseUp:U,onMouseLeave:U,onWheel:V,children:[u.map((P,D)=>{const B=d.get(P.lane)??0,_=k(D,P.start),C=n==="equal"?(D+1)/T:k(D,P.end);if(C<0||_>1)return null;const R=P.record,M=Math.max(0,Math.min(1,C)-Math.max(0,_)),F=n==="actual"&&P.firstTokenAt!==void 0&&P.end>P.start?(P.firstTokenAt-P.start)/(P.end-P.start):null;return s.jsx("div",{className:`bar kind-${R.kind} status-${R.status} ${P.instant&&n==="actual"?"instant":""} ${R.id===i?"selected":""}`,style:{left:`${Math.max(0,_)*100}%`,width:n==="equal"?`calc(${M*100}% - 1px)`:`max(2px, ${M*100}%)`,top:B*(Du+2),height:Du,...F===null?{}:{"--ttft":`${Math.min(100,Math.max(0,F*100))}%`}},title:G9(R,P.firstTokenAt),onMouseUp:H=>{E!==null&&Math.abs(E.x1-E.x0)<.005&&H.button===0&&c(R)}},R.id)}),$!==null&&s.jsx("div",{className:"brush",style:{left:`${Math.max(0,$.left)*100}%`,width:`${(Math.min(1,$.right)-Math.max(0,$.left))*100}%`}}),E!==null&&s.jsx("div",{className:"brush dragging",style:{left:`${Math.min(E.x0,E.x1)*100}%`,width:`${Math.abs(E.x1-E.x0)*100}%`}})]}),s.jsx("div",{className:"overview-scale muted",children:n==="actual"&&x!==null?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Zi(x.start)}),s.jsxs("span",{children:["总计 ",Os(p.end-p.start),m!==null?" · 已缩放":""]}),s.jsx("span",{children:Zi(x.end)})]}):s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:[T," 条记录(等宽)"]}),s.jsxs("span",{children:["总计 ",Os(p.end-p.start)]}),s.jsx("span",{children:"拖动选择区间 · 右键清除"})]})})]})});function V9(e,t){if(e===null)return t;const n=Math.max(t.start,e.start),r=Math.min(t.end,e.end);return r>n?{start:n,end:r}:t}function q9(e){return e==="input"?"输入":e==="model"?"模型":e==="tool"?"工具":"压缩"}function G9(e,t){const n=[`${Wd[e.kind]} · ${e.title}`,`开始于 ${Zi(e.start)}`];return e.end===null?n.push("进行中(只显示开始标记)"):n.push(`总计 ${Os(e.end-e.start)}`),e.kind==="assistant"&&t!==void 0&&e.end!==null&&n.push(`首 token ${Os(t-e.start)} · 解码 ${Os(e.end-t)}`),n.join(`
240
+ `)}const K9=32,Y9=34,X9=60;function Q9({session:e,state:t}){const n=b.useMemo(()=>tz(t.events,t.live,{now:Date.now()}),[t.events,t.live,t.version]),[r,i]=b.useState("equal"),[o,c]=b.useState(null),[u,h]=b.useState(""),[d,p]=b.useState(new Set),[m,g]=b.useState(!0),[x,y]=b.useState(null),E=n.records.find(P=>P.id===x)??null,N=b.useMemo(()=>J9(n,{brush:o,query:u,collapsed:d,showCalls:m}),[n,o,u,d,m]),w=b.useMemo(()=>N.flatMap(P=>P.type==="record"?[P.record]:[]),[N]),T=b.useRef(null),k=zw(X9),I=k.following,L=O9({count:N.length,getScrollElement:()=>T.current,estimateSize:P=>{var D;return((D=N[P])==null?void 0:D.type)==="group"?Y9:K9},getItemKey:P=>{var D;return((D=N[P])==null?void 0:D.key)??P},overscan:12});b.useLayoutEffect(()=>{I.current&&N.length>0&&L.scrollToIndex(N.length-1,{align:"end"})},[N.length,t.version,L]),b.useEffect(()=>{if(x===null)return;const P=N.findIndex(D=>D.type==="record"&&D.record.id===x);P!==-1&&L.scrollToIndex(P,{align:"auto"})},[x]);const z=P=>p(D=>{const B=new Set(D);return B.has(P)?B.delete(P):B.add(P),B}),U=n.groups.length>0&&n.groups.every(P=>d.has(P.key)),V=P=>{if(P.key!=="ArrowDown"&&P.key!=="ArrowUp"&&P.key!=="Escape")return;if(P.preventDefault(),P.key==="Escape"){y(null);return}const D=w.findIndex(_=>_.id===x),B=w[P.key==="ArrowDown"?Math.min(w.length-1,D+1):Math.max(0,D-1)];B!==void 0&&y(B.id)},$=n.totals;return s.jsxs("div",{className:"trajectory",children:[s.jsxs("div",{className:"traj-toolbar",role:"toolbar","aria-label":"轨迹工具栏",children:[s.jsxs("button",{className:`toggle ${r==="actual"?"on":""}`,onClick:()=>{i(P=>P==="equal"?"actual":"equal"),c(null)},title:r==="equal"?"使用实际时长":"使用等宽操作",children:["⏱ ",r==="equal"?"等宽":"实际时间"]}),s.jsxs("button",{className:"toggle",onClick:()=>p(U?new Set:new Set(n.groups.map(P=>P.key))),children:["⊟ ",U?"展开所有轮次":"收起所有轮次"]}),s.jsxs("button",{className:`toggle ${m?"":"on"}`,onClick:()=>g(P=>!P),children:["⊟ ",m?"收起所有调用":"展开所有调用"]}),s.jsx("input",{className:"traj-search",value:u,onChange:P=>h(P.target.value),placeholder:"搜索轨迹","aria-label":"搜索轨迹"}),s.jsxs("span",{className:"traj-totals muted small",title:"已加载窗口内的累计",children:[$.requests," 次请求 · 输入 ",vn($.inputTokens+$.cacheReadTokens+$.cacheWriteTokens)," · 输出 ",vn($.outputTokens)," · ",$.toolCalls," 次工具调用",$.errors>0?` · ${$.errors} 个错误`:""]})]}),s.jsx(W9,{model:n,mode:r,brush:o,selectedId:x,onBrush:c,onSelect:P=>y(P.id)}),o!==null&&s.jsxs("div",{className:"brush-note small",children:["已按时间区间筛选,显示 ",w.length," 条记录 ",s.jsx("button",{className:"link-button",onClick:()=>c(null),children:"清除"})]}),s.jsxs("div",{className:"traj-main",children:[s.jsxs("div",{className:"ledger",ref:T,onScroll:k.onScroll,onWheel:k.onWheel,tabIndex:0,onKeyDown:V,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?"正在加载更早的历史…":"加载更早的历史"}),N.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(P=>{const D=N[P.index];return s.jsx("div",{className:"vrow",style:{transform:`translateY(${P.start}px)`,height:P.size},children:D.type==="group"?s.jsx(eH,{row:D,onToggle:()=>z(D.group.key)}):s.jsx(tH,{row:D,selected:D.record.id===x,onSelect:()=>y(B=>B===D.record.id?null:D.record.id)})},P.key)})})]}),E!==null&&s.jsx(D9,{record:E,totals:n.totals,onClose:()=>y(null)},E.id)]})]})}function J9(e,t){const n=new Set;let r=e.records;if(t.brush!==null){const c=t.brush;r=c.mode==="equal"?r.slice(c.from,c.to+1):r.filter(u=>cz(u,c.range))}for(const c of hz(r,t.query))n.add(c.id);const i=t.brush!==null||t.query.trim()!=="",o=[];for(const c of e.groups){const u=c.records.filter(p=>n.has(p.id)&&(t.showCalls||p.kind!=="tool"));if(i&&u.length===0)continue;const h=t.collapsed.has(c.key);if(o.push({type:"group",key:`g:${c.key}`,group:c,collapsed:h,matches:u.length}),h)continue;let d=null;for(const p of u){const m=p.step!==null&&p.step!==d?p.step:null;p.step!==null&&(d=p.step),o.push({type:"record",key:p.id,record:p,stepStart:m})}}return o}const eH=b.memo(function({row:t,onToggle:n}){var u,h;const r=t.group,i=r.records.filter(d=>d.kind==="tool").length,o=r.end===null?null:r.end-r.start,c=L9(r);return s.jsxs("button",{className:`group-row ${r.end===null?"open":""} reason-${((u=r.reason)==null?void 0:u.kind)??"none"}`,onClick:n,"aria-expanded":!t.collapsed,children:[s.jsx("span",{className:"chevron",children:t.collapsed?"▸":"▾"}),s.jsx("span",{className:"group-title",children:P9(r)}),s.jsxs("span",{className:"muted small",children:[r.steps.length>0&&`${r.steps.length} 个步骤`,i>0&&` · ${i} 个工具调用`,o!==null&&` · ${Os(o)}`,r.partialStart&&" · 开头在已加载范围之外"]}),c!==""&&s.jsx("span",{className:`group-reason reason-${r.end===null?"running":((h=r.reason)==null?void 0:h.kind)??"none"}`,children:c})]})}),tH=b.memo(function({row:t,selected:n,onSelect:r}){var u;const i=t.record,o=i.kind==="assistant",c=Kl(i);return s.jsxs("div",{className:`record-row kind-${i.kind} status-${i.status} ${n?"selected":""} ${t.stepStart!==null?"step-start":""}`,onClick:r,role:"row","aria-selected":n,children:[s.jsx("span",{className:"gutter muted",children:t.stepStart!==null?`第 ${t.stepStart} 步`:""}),s.jsx("span",{children:s.jsx("span",{className:`kind-badge kind-${i.kind}`,children:o?`#${i.request.index}`:Wd[i.kind]})}),s.jsxs("span",{className:"record-content",title:i.preview,children:[i.status==="running"&&s.jsx("span",{className:"running-dot"}),i.status==="error"&&s.jsxs("span",{className:"status-text status-error",children:[f_.error," · "]}),i.kind==="tool"?s.jsxs(s.Fragment,{children:[s.jsx("code",{className:"tool-name-inline",children:i.name})," ",s.jsx("span",{className:"muted",children:i.preview})]}):i.preview||s.jsx("span",{className:"muted",children:"(无内容)"})]}),s.jsx("span",{className:"num",children:o?vn(p_(i)):""}),s.jsx("span",{className:"num",children:o&&i.request.usage!==void 0?vn(i.request.usage.outputTokens):""}),s.jsx("span",{className:"num",children:o&&((u=i.request.usage)==null?void 0:u.reasoningTokens)!==void 0?vn(i.request.usage.reasoningTokens):""}),s.jsx("span",{className:"num",children:i.status==="running"?"…":c!==void 0&&(o||i.kind==="tool"||i.kind==="compaction"||i.kind==="attempt")?Os(c):""}),s.jsx("span",{className:"model-cell",children:o?i.request.model??"":""}),s.jsx("span",{className:"num",children:o&&wd(i)>0?wd(i):""})]})}),nH={id:"trajectory",title:"轨迹",requires:["sessions"],sessionViews:[{id:"trajectory",title:"轨迹",order:10,component:Q9}]};ZN();Bn(CP);Bn(nH);Bn(h9);Bn(f9);Bn(p9);Bn(m9);Bn(g9);Bn(v9);Bn(z5);Bn(P5);Bn(qP);Bn(GP);Bn(NU);Bn(wU);Bn(QU);Bn(f5);for(const e of AP)Bn(e);const m_=QE.createRoot(document.getElementById("root"));function wp(e){const t=new zM({url:vR(e),clientInfo:{name:"adg-web",version:"0.1.0"}});t.start(),m_.render(s.jsxs(EP,{children:[s.jsx(vP,{client:t}),s.jsx(_P,{client:t})]}))}const dk=Fm?null:MN();Fm?wp(null):dk===null?m_.render(s.jsx(NP,{onSubmit:e=>{xR(e),wp(e)}})):wp(dk);
241
+ //# sourceMappingURL=index-9SCfW_a1.js.map