plotlink-ows 1.2.94 → 1.2.95

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,143 @@
1
+ (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const c of o.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function i(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(a){if(a.ep)return;a.ep=!0;const o=i(a);fetch(a.href,o)}})();function Du(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},to={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and 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 X_;function iC(){if(X_)return to;X_=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function i(s,a,o){var c=null;if(o!==void 0&&(c=""+o),a.key!==void 0&&(c=""+a.key),"key"in a){o={};for(var h in a)h!=="key"&&(o[h]=a[h])}else o=a;return a=o.ref,{$$typeof:e,type:s,key:c,ref:a!==void 0?a:null,props:o}}return to.Fragment=t,to.jsx=i,to.jsxs=i,to}var Z_;function nC(){return Z_||(Z_=1,qd.exports=iC()),qd.exports}var d=nC(),Wd={exports:{}},et={};/**
10
+ * @license React
11
+ * react.production.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and 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 Q_;function rC(){if(Q_)return et;Q_=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function v(R){return R===null||typeof R!="object"?null:(R=b&&R[b]||R["@@iterator"],typeof R=="function"?R:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,j={};function E(R,V,C){this.props=R,this.context=V,this.refs=j,this.updater=C||y}E.prototype.isReactComponent={},E.prototype.setState=function(R,V){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,V,"setState")},E.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function z(){}z.prototype=E.prototype;function O(R,V,C){this.props=R,this.context=V,this.refs=j,this.updater=C||y}var W=O.prototype=new z;W.constructor=O,N(W,E.prototype),W.isPureReactComponent=!0;var q=Array.isArray;function D(){}var te={H:null,A:null,T:null,S:null},de=Object.prototype.hasOwnProperty;function _e(R,V,C){var K=C.ref;return{$$typeof:e,type:R,key:V,ref:K!==void 0?K:null,props:C}}function P(R,V){return _e(R.type,V,R.props)}function ae(R){return typeof R=="object"&&R!==null&&R.$$typeof===e}function G(R){var V={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(C){return V[C]})}var Y=/\/+/g;function Q(R,V){return typeof R=="object"&&R!==null&&R.key!=null?G(""+R.key):V.toString(36)}function I(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(D,D):(R.status="pending",R.then(function(V){R.status==="pending"&&(R.status="fulfilled",R.value=V)},function(V){R.status==="pending"&&(R.status="rejected",R.reason=V)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function A(R,V,C,K,re){var ue=typeof R;(ue==="undefined"||ue==="boolean")&&(R=null);var $=!1;if(R===null)$=!0;else switch(ue){case"bigint":case"string":case"number":$=!0;break;case"object":switch(R.$$typeof){case e:case t:$=!0;break;case _:return $=R._init,A($(R._payload),V,C,K,re)}}if($)return re=re(R),$=K===""?"."+Q(R,0):K,q(re)?(C="",$!=null&&(C=$.replace(Y,"$&/")+"/"),A(re,V,C,"",function(Te){return Te})):re!=null&&(ae(re)&&(re=P(re,C+(re.key==null||R&&R.key===re.key?"":(""+re.key).replace(Y,"$&/")+"/")+$)),V.push(re)),1;$=0;var le=K===""?".":K+":";if(q(R))for(var be=0;be<R.length;be++)K=R[be],ue=le+Q(K,be),$+=A(K,V,C,ue,re);else if(be=v(R),typeof be=="function")for(R=be.call(R),be=0;!(K=R.next()).done;)K=K.value,ue=le+Q(K,be++),$+=A(K,V,C,ue,re);else if(ue==="object"){if(typeof R.then=="function")return A(I(R),V,C,K,re);throw V=String(R),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.")}return $}function B(R,V,C){if(R==null)return R;var K=[],re=0;return A(R,K,"","",function(ue){return V.call(C,ue,re++)}),K}function U(R){if(R._status===-1){var V=R._result;V=V(),V.then(function(C){(R._status===0||R._status===-1)&&(R._status=1,R._result=C)},function(C){(R._status===0||R._status===-1)&&(R._status=2,R._result=C)}),R._status===-1&&(R._status=0,R._result=V)}if(R._status===1)return R._result.default;throw R._result}var ge=typeof reportError=="function"?reportError:function(R){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var V=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof R=="object"&&R!==null&&typeof R.message=="string"?String(R.message):String(R),error:R});if(!window.dispatchEvent(V))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",R);return}console.error(R)},T={map:B,forEach:function(R,V,C){B(R,function(){V.apply(this,arguments)},C)},count:function(R){var V=0;return B(R,function(){V++}),V},toArray:function(R){return B(R,function(V){return V})||[]},only:function(R){if(!ae(R))throw Error("React.Children.only expected to receive a single React element child.");return R}};return et.Activity=x,et.Children=T,et.Component=E,et.Fragment=i,et.Profiler=a,et.PureComponent=O,et.StrictMode=s,et.Suspense=p,et.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=te,et.__COMPILER_RUNTIME={__proto__:null,c:function(R){return te.H.useMemoCache(R)}},et.cache=function(R){return function(){return R.apply(null,arguments)}},et.cacheSignal=function(){return null},et.cloneElement=function(R,V,C){if(R==null)throw Error("The argument must be a React element, but you passed "+R+".");var K=N({},R.props),re=R.key;if(V!=null)for(ue in V.key!==void 0&&(re=""+V.key),V)!de.call(V,ue)||ue==="key"||ue==="__self"||ue==="__source"||ue==="ref"&&V.ref===void 0||(K[ue]=V[ue]);var ue=arguments.length-2;if(ue===1)K.children=C;else if(1<ue){for(var $=Array(ue),le=0;le<ue;le++)$[le]=arguments[le+2];K.children=$}return _e(R.type,re,K)},et.createContext=function(R){return R={$$typeof:c,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null},R.Provider=R,R.Consumer={$$typeof:o,_context:R},R},et.createElement=function(R,V,C){var K,re={},ue=null;if(V!=null)for(K in V.key!==void 0&&(ue=""+V.key),V)de.call(V,K)&&K!=="key"&&K!=="__self"&&K!=="__source"&&(re[K]=V[K]);var $=arguments.length-2;if($===1)re.children=C;else if(1<$){for(var le=Array($),be=0;be<$;be++)le[be]=arguments[be+2];re.children=le}if(R&&R.defaultProps)for(K in $=R.defaultProps,$)re[K]===void 0&&(re[K]=$[K]);return _e(R,ue,re)},et.createRef=function(){return{current:null}},et.forwardRef=function(R){return{$$typeof:h,render:R}},et.isValidElement=ae,et.lazy=function(R){return{$$typeof:_,_payload:{_status:-1,_result:R},_init:U}},et.memo=function(R,V){return{$$typeof:f,type:R,compare:V===void 0?null:V}},et.startTransition=function(R){var V=te.T,C={};te.T=C;try{var K=R(),re=te.S;re!==null&&re(C,K),typeof K=="object"&&K!==null&&typeof K.then=="function"&&K.then(D,ge)}catch(ue){ge(ue)}finally{V!==null&&C.types!==null&&(V.types=C.types),te.T=V}},et.unstable_useCacheRefresh=function(){return te.H.useCacheRefresh()},et.use=function(R){return te.H.use(R)},et.useActionState=function(R,V,C){return te.H.useActionState(R,V,C)},et.useCallback=function(R,V){return te.H.useCallback(R,V)},et.useContext=function(R){return te.H.useContext(R)},et.useDebugValue=function(){},et.useDeferredValue=function(R,V){return te.H.useDeferredValue(R,V)},et.useEffect=function(R,V){return te.H.useEffect(R,V)},et.useEffectEvent=function(R){return te.H.useEffectEvent(R)},et.useId=function(){return te.H.useId()},et.useImperativeHandle=function(R,V,C){return te.H.useImperativeHandle(R,V,C)},et.useInsertionEffect=function(R,V){return te.H.useInsertionEffect(R,V)},et.useLayoutEffect=function(R,V){return te.H.useLayoutEffect(R,V)},et.useMemo=function(R,V){return te.H.useMemo(R,V)},et.useOptimistic=function(R,V){return te.H.useOptimistic(R,V)},et.useReducer=function(R,V,C){return te.H.useReducer(R,V,C)},et.useRef=function(R){return te.H.useRef(R)},et.useState=function(R){return te.H.useState(R)},et.useSyncExternalStore=function(R,V,C){return te.H.useSyncExternalStore(R,V,C)},et.useTransition=function(){return te.H.useTransition()},et.version="19.2.3",et}var J_;function Op(){return J_||(J_=1,Wd.exports=rC()),Wd.exports}var w=Op();const sC=Du(w);var Gd={exports:{}},io={},Yd={exports:{}},Kd={};/**
18
+ * @license React
19
+ * scheduler.production.js
20
+ *
21
+ * Copyright (c) Meta Platforms, Inc. and 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 eb;function aC(){return eb||(eb=1,(function(e){function t(A,B){var U=A.length;A.push(B);e:for(;0<U;){var ge=U-1>>>1,T=A[ge];if(0<a(T,B))A[ge]=B,A[U]=T,U=ge;else break e}}function i(A){return A.length===0?null:A[0]}function s(A){if(A.length===0)return null;var B=A[0],U=A.pop();if(U!==B){A[0]=U;e:for(var ge=0,T=A.length,R=T>>>1;ge<R;){var V=2*(ge+1)-1,C=A[V],K=V+1,re=A[K];if(0>a(C,U))K<T&&0>a(re,C)?(A[ge]=re,A[K]=U,ge=K):(A[ge]=C,A[V]=U,ge=V);else if(K<T&&0>a(re,U))A[ge]=re,A[K]=U,ge=K;else break e}}return B}function a(A,B){var U=A.sortIndex-B.sortIndex;return U!==0?U:A.id-B.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,h=c.now();e.unstable_now=function(){return c.now()-h}}var p=[],f=[],_=1,x=null,b=3,v=!1,y=!1,N=!1,j=!1,E=typeof setTimeout=="function"?setTimeout:null,z=typeof clearTimeout=="function"?clearTimeout:null,O=typeof setImmediate<"u"?setImmediate:null;function W(A){for(var B=i(f);B!==null;){if(B.callback===null)s(f);else if(B.startTime<=A)s(f),B.sortIndex=B.expirationTime,t(p,B);else break;B=i(f)}}function q(A){if(N=!1,W(A),!y)if(i(p)!==null)y=!0,D||(D=!0,G());else{var B=i(f);B!==null&&I(q,B.startTime-A)}}var D=!1,te=-1,de=5,_e=-1;function P(){return j?!0:!(e.unstable_now()-_e<de)}function ae(){if(j=!1,D){var A=e.unstable_now();_e=A;var B=!0;try{e:{y=!1,N&&(N=!1,z(te),te=-1),v=!0;var U=b;try{t:{for(W(A),x=i(p);x!==null&&!(x.expirationTime>A&&P());){var ge=x.callback;if(typeof ge=="function"){x.callback=null,b=x.priorityLevel;var T=ge(x.expirationTime<=A);if(A=e.unstable_now(),typeof T=="function"){x.callback=T,W(A),B=!0;break t}x===i(p)&&s(p),W(A)}else s(p);x=i(p)}if(x!==null)B=!0;else{var R=i(f);R!==null&&I(q,R.startTime-A),B=!1}}break e}finally{x=null,b=U,v=!1}B=void 0}}finally{B?G():D=!1}}}var G;if(typeof O=="function")G=function(){O(ae)};else if(typeof MessageChannel<"u"){var Y=new MessageChannel,Q=Y.port2;Y.port1.onmessage=ae,G=function(){Q.postMessage(null)}}else G=function(){E(ae,0)};function I(A,B){te=E(function(){A(e.unstable_now())},B)}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(A){A.callback=null},e.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):de=0<A?Math.floor(1e3/A):5},e.unstable_getCurrentPriorityLevel=function(){return b},e.unstable_next=function(A){switch(b){case 1:case 2:case 3:var B=3;break;default:B=b}var U=b;b=B;try{return A()}finally{b=U}},e.unstable_requestPaint=function(){j=!0},e.unstable_runWithPriority=function(A,B){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var U=b;b=A;try{return B()}finally{b=U}},e.unstable_scheduleCallback=function(A,B,U){var ge=e.unstable_now();switch(typeof U=="object"&&U!==null?(U=U.delay,U=typeof U=="number"&&0<U?ge+U:ge):U=ge,A){case 1:var T=-1;break;case 2:T=250;break;case 5:T=1073741823;break;case 4:T=1e4;break;default:T=5e3}return T=U+T,A={id:_++,callback:B,priorityLevel:A,startTime:U,expirationTime:T,sortIndex:-1},U>ge?(A.sortIndex=U,t(f,A),i(p)===null&&A===i(f)&&(N?(z(te),te=-1):N=!0,I(q,U-ge))):(A.sortIndex=T,t(p,A),y||v||(y=!0,D||(D=!0,G()))),A},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(A){var B=b;return function(){var U=b;b=B;try{return A.apply(this,arguments)}finally{b=U}}}})(Kd)),Kd}var tb;function lC(){return tb||(tb=1,Yd.exports=aC()),Yd.exports}var Vd={exports:{}},tn={};/**
26
+ * @license React
27
+ * react-dom.production.js
28
+ *
29
+ * Copyright (c) Meta Platforms, Inc. and 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 ib;function oC(){if(ib)return tn;ib=1;var e=Op();function t(p){var f="https://react.dev/errors/"+p;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var _=2;_<arguments.length;_++)f+="&args[]="+encodeURIComponent(arguments[_])}return"Minified React error #"+p+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(){}var s={d:{f:i,r:function(){throw Error(t(522))},D:i,C:i,L:i,m:i,X:i,S:i,M:i},p:0,findDOMNode:null},a=Symbol.for("react.portal");function o(p,f,_){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:x==null?null:""+x,children:p,containerInfo:f,implementation:_}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(p,f){if(p==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return tn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,tn.createPortal=function(p,f){var _=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return o(p,f,null,_)},tn.flushSync=function(p){var f=c.T,_=s.p;try{if(c.T=null,s.p=2,p)return p()}finally{c.T=f,s.p=_,s.d.f()}},tn.preconnect=function(p,f){typeof p=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(p,f))},tn.prefetchDNS=function(p){typeof p=="string"&&s.d.D(p)},tn.preinit=function(p,f){if(typeof p=="string"&&f&&typeof f.as=="string"){var _=f.as,x=h(_,f.crossOrigin),b=typeof f.integrity=="string"?f.integrity:void 0,v=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;_==="style"?s.d.S(p,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:x,integrity:b,fetchPriority:v}):_==="script"&&s.d.X(p,{crossOrigin:x,integrity:b,fetchPriority:v,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},tn.preinitModule=function(p,f){if(typeof p=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var _=h(f.as,f.crossOrigin);s.d.M(p,{crossOrigin:_,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(p)},tn.preload=function(p,f){if(typeof p=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var _=f.as,x=h(_,f.crossOrigin);s.d.L(p,_,{crossOrigin:x,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},tn.preloadModule=function(p,f){if(typeof p=="string")if(f){var _=h(f.as,f.crossOrigin);s.d.m(p,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:_,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(p)},tn.requestFormReset=function(p){s.d.r(p)},tn.unstable_batchedUpdates=function(p,f){return p(f)},tn.useFormState=function(p,f,_){return c.H.useFormState(p,f,_)},tn.useFormStatus=function(){return c.H.useHostTransitionStatus()},tn.version="19.2.3",tn}var nb;function cC(){if(nb)return Vd.exports;nb=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(),Vd.exports=oC(),Vd.exports}/**
34
+ * @license React
35
+ * react-dom-client.production.js
36
+ *
37
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
38
+ *
39
+ * This source code is licensed under the MIT license found in the
40
+ * LICENSE file in the root directory of this source tree.
41
+ */var rb;function uC(){if(rb)return io;rb=1;var e=lC(),t=Op(),i=cC();function s(n){var r="https://react.dev/errors/"+n;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+n+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(n){return!(!n||n.nodeType!==1&&n.nodeType!==9&&n.nodeType!==11)}function o(n){var r=n,l=n;if(n.alternate)for(;r.return;)r=r.return;else{n=r;do r=n,(r.flags&4098)!==0&&(l=r.return),n=r.return;while(n)}return r.tag===3?l:null}function c(n){if(n.tag===13){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function h(n){if(n.tag===31){var r=n.memoizedState;if(r===null&&(n=n.alternate,n!==null&&(r=n.memoizedState)),r!==null)return r.dehydrated}return null}function p(n){if(o(n)!==n)throw Error(s(188))}function f(n){var r=n.alternate;if(!r){if(r=o(n),r===null)throw Error(s(188));return r!==n?null:n}for(var l=n,u=r;;){var m=l.return;if(m===null)break;var g=m.alternate;if(g===null){if(u=m.return,u!==null){l=u;continue}break}if(m.child===g.child){for(g=m.child;g;){if(g===l)return p(m),n;if(g===u)return p(m),r;g=g.sibling}throw Error(s(188))}if(l.return!==u.return)l=m,u=g;else{for(var S=!1,k=m.child;k;){if(k===l){S=!0,l=m,u=g;break}if(k===u){S=!0,u=m,l=g;break}k=k.sibling}if(!S){for(k=g.child;k;){if(k===l){S=!0,l=g,u=m;break}if(k===u){S=!0,u=g,l=m;break}k=k.sibling}if(!S)throw Error(s(189))}}if(l.alternate!==u)throw Error(s(190))}if(l.tag!==3)throw Error(s(188));return l.stateNode.current===l?n:r}function _(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n;for(n=n.child;n!==null;){if(r=_(n),r!==null)return r;n=n.sibling}return null}var x=Object.assign,b=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),O=Symbol.for("react.context"),W=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),de=Symbol.for("react.lazy"),_e=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),ae=Symbol.iterator;function G(n){return n===null||typeof n!="object"?null:(n=ae&&n[ae]||n["@@iterator"],typeof n=="function"?n:null)}var Y=Symbol.for("react.client.reference");function Q(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===Y?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case N:return"Fragment";case E:return"Profiler";case j:return"StrictMode";case q:return"Suspense";case D:return"SuspenseList";case _e:return"Activity"}if(typeof n=="object")switch(n.$$typeof){case y:return"Portal";case O:return n.displayName||"Context";case z:return(n._context.displayName||"Context")+".Consumer";case W:var r=n.render;return n=n.displayName,n||(n=r.displayName||r.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case te:return r=n.displayName||null,r!==null?r:Q(n.type)||"Memo";case de:r=n._payload,n=n._init;try{return Q(n(r))}catch{}}return null}var I=Array.isArray,A=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U={pending:!1,data:null,method:null,action:null},ge=[],T=-1;function R(n){return{current:n}}function V(n){0>T||(n.current=ge[T],ge[T]=null,T--)}function C(n,r){T++,ge[T]=n.current,n.current=r}var K=R(null),re=R(null),ue=R(null),$=R(null);function le(n,r){switch(C(ue,r),C(re,n),C(K,null),r.nodeType){case 9:case 11:n=(n=r.documentElement)&&(n=n.namespaceURI)?b_(n):0;break;default:if(n=r.tagName,r=r.namespaceURI)r=b_(r),n=v_(r,n);else switch(n){case"svg":n=1;break;case"math":n=2;break;default:n=0}}V(K),C(K,n)}function be(){V(K),V(re),V(ue)}function Te(n){n.memoizedState!==null&&C($,n);var r=K.current,l=v_(r,n.type);r!==l&&(C(re,n),C(K,l))}function Le(n){re.current===n&&(V(K),V(re)),$.current===n&&(V($),Zl._currentValue=U)}var ze,ye;function rt(n){if(ze===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);ze=r&&r[1]||"",ye=-1<l.stack.indexOf(`
42
+ at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
43
+ `+ze+n+ye}var bt=!1;function wt(n,r){if(!n||bt)return"";bt=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(r){var fe=function(){throw Error()};if(Object.defineProperty(fe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(fe,[])}catch(se){var J=se}Reflect.construct(n,[],fe)}else{try{fe.call()}catch(se){J=se}n.call(fe.prototype)}}else{try{throw Error()}catch(se){J=se}(fe=n())&&typeof fe.catch=="function"&&fe.catch(function(){})}}catch(se){if(se&&J&&typeof se.stack=="string")return[se.stack,J.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=u.DetermineComponentFrameRoot(),S=g[0],k=g[1];if(S&&k){var M=S.split(`
44
+ `),Z=k.split(`
45
+ `);for(m=u=0;u<M.length&&!M[u].includes("DetermineComponentFrameRoot");)u++;for(;m<Z.length&&!Z[m].includes("DetermineComponentFrameRoot");)m++;if(u===M.length||m===Z.length)for(u=M.length-1,m=Z.length-1;1<=u&&0<=m&&M[u]!==Z[m];)m--;for(;1<=u&&0<=m;u--,m--)if(M[u]!==Z[m]){if(u!==1||m!==1)do if(u--,m--,0>m||M[u]!==Z[m]){var ce=`
46
+ `+M[u].replace(" at new "," at ");return n.displayName&&ce.includes("<anonymous>")&&(ce=ce.replace("<anonymous>",n.displayName)),ce}while(1<=u&&0<=m);break}}}finally{bt=!1,Error.prepareStackTrace=l}return(l=n?n.displayName||n.name:"")?rt(l):""}function vt(n,r){switch(n.tag){case 26:case 27:case 5:return rt(n.type);case 16:return rt("Lazy");case 13:return n.child!==r&&r!==null?rt("Suspense Fallback"):rt("Suspense");case 19:return rt("SuspenseList");case 0:case 15:return wt(n.type,!1);case 11:return wt(n.type.render,!1);case 1:return wt(n.type,!0);case 31:return rt("Activity");default:return""}}function Ve(n){try{var r="",l=null;do r+=vt(n,l),l=n,n=n.return;while(n);return r}catch(u){return`
47
+ Error generating stack: `+u.message+`
48
+ `+u.stack}}var Me=Object.prototype.hasOwnProperty,Je=e.unstable_scheduleCallback,It=e.unstable_cancelCallback,Ae=e.unstable_shouldYield,ii=e.unstable_requestPaint,Ct=e.unstable_now,pi=e.unstable_getCurrentPriorityLevel,ne=e.unstable_ImmediatePriority,xe=e.unstable_UserBlockingPriority,Be=e.unstable_NormalPriority,$e=e.unstable_LowPriority,Ge=e.unstable_IdlePriority,Ot=e.log,Mt=e.unstable_setDisableYieldValue,ct=null,We=null;function Bt(n){if(typeof Ot=="function"&&Mt(n),We&&typeof We.setStrictMode=="function")try{We.setStrictMode(ct,n)}catch{}}var pt=Math.clz32?Math.clz32:ke,Mi=Math.log,H=Math.LN2;function ke(n){return n>>>=0,n===0?32:31-(Mi(n)/H|0)|0}var Pe=256,je=262144,Ie=4194304;function Xe(n){var r=n&42;if(r!==0)return r;switch(n&-n){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function mt(n,r,l){var u=n.pendingLanes;if(u===0)return 0;var m=0,g=n.suspendedLanes,S=n.pingedLanes;n=n.warmLanes;var k=u&134217727;return k!==0?(u=k&~g,u!==0?m=Xe(u):(S&=k,S!==0?m=Xe(S):l||(l=k&~n,l!==0&&(m=Xe(l))))):(k=u&~g,k!==0?m=Xe(k):S!==0?m=Xe(S):l||(l=u&~n,l!==0&&(m=Xe(l)))),m===0?0:r!==0&&r!==m&&(r&g)===0&&(g=m&-m,l=r&-r,g>=l||g===32&&(l&4194048)!==0)?r:m}function Qe(n,r){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&r)===0}function Tt(n,r){switch(n){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32: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 r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function qt(){var n=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),n}function li(n){for(var r=[],l=0;31>l;l++)r.push(n);return r}function oe(n,r){n.pendingLanes|=r,r!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Ee(n,r,l,u,m,g){var S=n.pendingLanes;n.pendingLanes=l,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=l,n.entangledLanes&=l,n.errorRecoveryDisabledLanes&=l,n.shellSuspendCounter=0;var k=n.entanglements,M=n.expirationTimes,Z=n.hiddenUpdates;for(l=S&~l;0<l;){var ce=31-pt(l),fe=1<<ce;k[ce]=0,M[ce]=-1;var J=Z[ce];if(J!==null)for(Z[ce]=null,ce=0;ce<J.length;ce++){var se=J[ce];se!==null&&(se.lane&=-536870913)}l&=~fe}u!==0&&Ue(n,u,0),g!==0&&m===0&&n.tag!==0&&(n.suspendedLanes|=g&~(S&~r))}function Ue(n,r,l){n.pendingLanes|=r,n.suspendedLanes&=~r;var u=31-pt(r);n.entangledLanes|=r,n.entanglements[u]=n.entanglements[u]|1073741824|l&261930}function Ye(n,r){var l=n.entangledLanes|=r;for(n=n.entanglements;l;){var u=31-pt(l),m=1<<u;m&r|n[u]&r&&(n[u]|=r),l&=~m}}function ee(n,r){var l=r&-r;return l=(l&42)!==0?1:me(l),(l&(n.suspendedLanes|r))!==0?0:l}function me(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;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:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Ce(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function ut(){var n=B.p;return n!==0?n:(n=window.event,n===void 0?32:F_(n.type))}function ot(n,r){var l=B.p;try{return B.p=n,r()}finally{B.p=l}}var tt=Math.random().toString(36).slice(2),st="__reactFiber$"+tt,it="__reactProps$"+tt,kt="__reactContainer$"+tt,ht="__reactEvents$"+tt,Kt="__reactListeners$"+tt,Lt="__reactHandles$"+tt,oi="__reactResources$"+tt,Fi="__reactMarker$"+tt;function Fn(n){delete n[st],delete n[it],delete n[ht],delete n[Kt],delete n[Lt]}function qi(n){var r=n[st];if(r)return r;for(var l=n.parentNode;l;){if(r=l[kt]||l[st]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(n=N_(n);n!==null;){if(l=n[st])return l;n=N_(n)}return r}n=l,l=n.parentNode}return null}function ni(n){if(n=n[st]||n[kt]){var r=n.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return n}return null}function jn(n){var r=n.tag;if(r===5||r===26||r===27||r===6)return n.stateNode;throw Error(s(33))}function qn(n){var r=n[oi];return r||(r=n[oi]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function ri(n){n[Fi]=!0}var Vt=new Set,Wn={};function ln(n,r){An(n,r),An(n+"Capture",r)}function An(n,r){for(Wn[n]=r,n=0;n<r.length;n++)Vt.add(r[n])}var ts=RegExp("^[: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]*$"),Jt={},xn={};function dl(n){return Me.call(xn,n)?!0:Me.call(Jt,n)?!1:ts.test(n)?xn[n]=!0:(Jt[n]=!0,!1)}function Ar(n,r,l){if(dl(r))if(l===null)n.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":n.removeAttribute(r);return;case"boolean":var u=r.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){n.removeAttribute(r);return}}n.setAttribute(r,""+l)}}function or(n,r,l){if(l===null)n.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(r);return}n.setAttribute(r,""+l)}}function _n(n,r,l,u){if(u===null)n.removeAttribute(l);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":n.removeAttribute(l);return}n.setAttributeNS(r,l,""+u)}}function Qi(n){switch(typeof n){case"bigint":case"boolean":case"number":case"string":case"undefined":return n;case"object":return n;default:return""}}function ha(n){var r=n.type;return(n=n.nodeName)&&n.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function Ji(n,r,l){var u=Object.getOwnPropertyDescriptor(n.constructor.prototype,r);if(!n.hasOwnProperty(r)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var m=u.get,g=u.set;return Object.defineProperty(n,r,{configurable:!0,get:function(){return m.call(this)},set:function(S){l=""+S,g.call(this,S)}}),Object.defineProperty(n,r,{enumerable:u.enumerable}),{getValue:function(){return l},setValue:function(S){l=""+S},stopTracking:function(){n._valueTracker=null,delete n[r]}}}}function cr(n){if(!n._valueTracker){var r=ha(n)?"checked":"value";n._valueTracker=Ji(n,r,""+n[r])}}function en(n){if(!n)return!1;var r=n._valueTracker;if(!r)return!0;var l=r.getValue(),u="";return n&&(u=ha(n)?n.checked?"true":"false":n.value),n=u,n!==l?(r.setValue(n),!0):!1}function on(n){if(n=n||(typeof document<"u"?document:void 0),typeof n>"u")return null;try{return n.activeElement||n.body}catch{return n.body}}var da=/[\n"\\]/g;function Ei(n){return n.replace(da,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function fa(n,r,l,u,m,g,S,k){n.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?n.type=S:n.removeAttribute("type"),r!=null?S==="number"?(r===0&&n.value===""||n.value!=r)&&(n.value=""+Qi(r)):n.value!==""+Qi(r)&&(n.value=""+Qi(r)):S!=="submit"&&S!=="reset"||n.removeAttribute("value"),r!=null?ma(n,S,Qi(r)):l!=null?ma(n,S,Qi(l)):u!=null&&n.removeAttribute("value"),m==null&&g!=null&&(n.defaultChecked=!!g),m!=null&&(n.checked=m&&typeof m!="function"&&typeof m!="symbol"),k!=null&&typeof k!="function"&&typeof k!="symbol"&&typeof k!="boolean"?n.name=""+Qi(k):n.removeAttribute("name")}function pa(n,r,l,u,m,g,S,k){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(n.type=g),r!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||r!=null)){cr(n);return}l=l!=null?""+Qi(l):"",r=r!=null?""+Qi(r):l,k||r===n.value||(n.value=r),n.defaultValue=r}u=u??m,u=typeof u!="function"&&typeof u!="symbol"&&!!u,n.checked=k?n.checked:!!u,n.defaultChecked=!!u,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(n.name=S),cr(n)}function ma(n,r,l){r==="number"&&on(n.ownerDocument)===n||n.defaultValue===""+l||(n.defaultValue=""+l)}function Gn(n,r,l,u){if(n=n.options,r){r={};for(var m=0;m<l.length;m++)r["$"+l[m]]=!0;for(l=0;l<n.length;l++)m=r.hasOwnProperty("$"+n[l].value),n[l].selected!==m&&(n[l].selected=m),m&&u&&(n[l].defaultSelected=!0)}else{for(l=""+Qi(l),r=null,m=0;m<n.length;m++){if(n[m].value===l){n[m].selected=!0,u&&(n[m].defaultSelected=!0);return}r!==null||n[m].disabled||(r=n[m])}r!==null&&(r.selected=!0)}}function ga(n,r,l){if(r!=null&&(r=""+Qi(r),r!==n.value&&(n.value=r),l==null)){n.defaultValue!==r&&(n.defaultValue=r);return}n.defaultValue=l!=null?""+Qi(l):""}function fl(n,r,l,u){if(r==null){if(u!=null){if(l!=null)throw Error(s(92));if(I(u)){if(1<u.length)throw Error(s(93));u=u[0]}l=u}l==null&&(l=""),r=l}l=Qi(r),n.defaultValue=l,u=n.textContent,u===l&&u!==""&&u!==null&&(n.value=u),cr(n)}function Yn(n,r){if(r){var l=n.firstChild;if(l&&l===n.lastChild&&l.nodeType===3){l.nodeValue=r;return}}n.textContent=r}var Io=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ho(n,r,l){var u=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?u?n.setProperty(r,""):r==="float"?n.cssFloat="":n[r]="":u?n.setProperty(r,l):typeof l!="number"||l===0||Io.has(r)?r==="float"?n.cssFloat=l:n[r]=(""+l).trim():n[r]=l+"px"}function Uo(n,r,l){if(r!=null&&typeof r!="object")throw Error(s(62));if(n=n.style,l!=null){for(var u in l)!l.hasOwnProperty(u)||r!=null&&r.hasOwnProperty(u)||(u.indexOf("--")===0?n.setProperty(u,""):u==="float"?n.cssFloat="":n[u]="");for(var m in r)u=r[m],r.hasOwnProperty(m)&&l[m]!==u&&Ho(n,m,u)}else for(var g in r)r.hasOwnProperty(g)&&Ho(n,g,r[g])}function xa(n){if(n.indexOf("-")===-1)return!1;switch(n){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 pl=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Wu=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function _a(n){return Wu.test(""+n)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":n}function cn(){}var is=null;function ml(n){return n=n.target||n.srcElement||window,n.correspondingUseElement&&(n=n.correspondingUseElement),n.nodeType===3?n.parentNode:n}var ur=null,Rr=null;function ie(n){var r=ni(n);if(r&&(n=r.stateNode)){var l=n[it]||null;e:switch(n=r.stateNode,r.type){case"input":if(fa(n,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=n;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+Ei(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var u=l[r];if(u!==n&&u.form===n.form){var m=u[it]||null;if(!m)throw Error(s(90));fa(u,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name)}}for(r=0;r<l.length;r++)u=l[r],u.form===n.form&&en(u)}break e;case"textarea":ga(n,l.value,l.defaultValue);break e;case"select":r=l.value,r!=null&&Gn(n,!!l.multiple,r,!1)}}}var Se=!1;function Ne(n,r,l){if(Se)return n(r,l);Se=!0;try{var u=n(r);return u}finally{if(Se=!1,(ur!==null||Rr!==null)&&(Nc(),ur&&(r=ur,n=Rr,Rr=ur=null,ie(r),n)))for(r=0;r<n.length;r++)ie(n[r])}}function Ze(n,r){var l=n.stateNode;if(l===null)return null;var u=l[it]||null;if(u===null)return null;l=u[r];e:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(n=n.type,u=!(n==="button"||n==="input"||n==="select"||n==="textarea")),n=!u;break e;default:n=!1}if(n)return null;if(l&&typeof l!="function")throw Error(s(231,r,typeof l));return l}var jt=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_i=!1;if(jt)try{var Rn={};Object.defineProperty(Rn,"passive",{get:function(){_i=!0}}),window.addEventListener("test",Rn,Rn),window.removeEventListener("test",Rn,Rn)}catch{_i=!1}var un=null,hr=null,Ls=null;function vm(){if(Ls)return Ls;var n,r=hr,l=r.length,u,m="value"in un?un.value:un.textContent,g=m.length;for(n=0;n<l&&r[n]===m[n];n++);var S=l-n;for(u=1;u<=S&&r[l-u]===m[g-u];u++);return Ls=m.slice(n,1<u?1-u:void 0)}function $o(n){var r=n.keyCode;return"charCode"in n?(n=n.charCode,n===0&&r===13&&(n=13)):n=r,n===10&&(n=13),32<=n||n===13?n:0}function Fo(){return!0}function ym(){return!1}function bn(n){function r(l,u,m,g,S){this._reactName=l,this._targetInst=m,this.type=u,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var k in n)n.hasOwnProperty(k)&&(l=n[k],this[k]=l?l(g):g[k]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?Fo:ym,this.isPropagationStopped=ym,this}return x(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Fo)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Fo)},persist:function(){},isPersistent:Fo}),r}var Os={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(n){return n.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qo=bn(Os),gl=x({},Os,{view:0,detail:0}),e1=bn(gl),Gu,Yu,xl,Wo=x({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vu,button:0,buttons:0,relatedTarget:function(n){return n.relatedTarget===void 0?n.fromElement===n.srcElement?n.toElement:n.fromElement:n.relatedTarget},movementX:function(n){return"movementX"in n?n.movementX:(n!==xl&&(xl&&n.type==="mousemove"?(Gu=n.screenX-xl.screenX,Yu=n.screenY-xl.screenY):Yu=Gu=0,xl=n),Gu)},movementY:function(n){return"movementY"in n?n.movementY:Yu}}),Sm=bn(Wo),t1=x({},Wo,{dataTransfer:0}),i1=bn(t1),n1=x({},gl,{relatedTarget:0}),Ku=bn(n1),r1=x({},Os,{animationName:0,elapsedTime:0,pseudoElement:0}),s1=bn(r1),a1=x({},Os,{clipboardData:function(n){return"clipboardData"in n?n.clipboardData:window.clipboardData}}),l1=bn(a1),o1=x({},Os,{data:0}),wm=bn(o1),c1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},u1={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},h1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function d1(n){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(n):(n=h1[n])?!!r[n]:!1}function Vu(){return d1}var f1=x({},gl,{key:function(n){if(n.key){var r=c1[n.key]||n.key;if(r!=="Unidentified")return r}return n.type==="keypress"?(n=$o(n),n===13?"Enter":String.fromCharCode(n)):n.type==="keydown"||n.type==="keyup"?u1[n.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vu,charCode:function(n){return n.type==="keypress"?$o(n):0},keyCode:function(n){return n.type==="keydown"||n.type==="keyup"?n.keyCode:0},which:function(n){return n.type==="keypress"?$o(n):n.type==="keydown"||n.type==="keyup"?n.keyCode:0}}),p1=bn(f1),m1=x({},Wo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Cm=bn(m1),g1=x({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vu}),x1=bn(g1),_1=x({},Os,{propertyName:0,elapsedTime:0,pseudoElement:0}),b1=bn(_1),v1=x({},Wo,{deltaX:function(n){return"deltaX"in n?n.deltaX:"wheelDeltaX"in n?-n.wheelDeltaX:0},deltaY:function(n){return"deltaY"in n?n.deltaY:"wheelDeltaY"in n?-n.wheelDeltaY:"wheelDelta"in n?-n.wheelDelta:0},deltaZ:0,deltaMode:0}),y1=bn(v1),S1=x({},Os,{newState:0,oldState:0}),w1=bn(S1),C1=[9,13,27,32],Xu=jt&&"CompositionEvent"in window,_l=null;jt&&"documentMode"in document&&(_l=document.documentMode);var k1=jt&&"TextEvent"in window&&!_l,km=jt&&(!Xu||_l&&8<_l&&11>=_l),Em=" ",Nm=!1;function Tm(n,r){switch(n){case"keyup":return C1.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jm(n){return n=n.detail,typeof n=="object"&&"data"in n?n.data:null}var ba=!1;function E1(n,r){switch(n){case"compositionend":return jm(r);case"keypress":return r.which!==32?null:(Nm=!0,Em);case"textInput":return n=r.data,n===Em&&Nm?null:n;default:return null}}function N1(n,r){if(ba)return n==="compositionend"||!Xu&&Tm(n,r)?(n=vm(),Ls=hr=un=null,ba=!1,n):null;switch(n){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return km&&r.locale!=="ko"?null:r.data;default:return null}}var T1={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 Am(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r==="input"?!!T1[n.type]:r==="textarea"}function Rm(n,r,l,u){ur?Rr?Rr.push(u):Rr=[u]:ur=u,r=Bc(r,"onChange"),0<r.length&&(l=new qo("onChange","change",null,l,u),n.push({event:l,listeners:r}))}var bl=null,vl=null;function j1(n){f_(n,0)}function Go(n){var r=jn(n);if(en(r))return n}function Mm(n,r){if(n==="change")return r}var Dm=!1;if(jt){var Zu;if(jt){var Qu="oninput"in document;if(!Qu){var Bm=document.createElement("div");Bm.setAttribute("oninput","return;"),Qu=typeof Bm.oninput=="function"}Zu=Qu}else Zu=!1;Dm=Zu&&(!document.documentMode||9<document.documentMode)}function Lm(){bl&&(bl.detachEvent("onpropertychange",Om),vl=bl=null)}function Om(n){if(n.propertyName==="value"&&Go(vl)){var r=[];Rm(r,vl,n,ml(n)),Ne(j1,r)}}function A1(n,r,l){n==="focusin"?(Lm(),bl=r,vl=l,bl.attachEvent("onpropertychange",Om)):n==="focusout"&&Lm()}function R1(n){if(n==="selectionchange"||n==="keyup"||n==="keydown")return Go(vl)}function M1(n,r){if(n==="click")return Go(r)}function D1(n,r){if(n==="input"||n==="change")return Go(r)}function B1(n,r){return n===r&&(n!==0||1/n===1/r)||n!==n&&r!==r}var Mn=typeof Object.is=="function"?Object.is:B1;function yl(n,r){if(Mn(n,r))return!0;if(typeof n!="object"||n===null||typeof r!="object"||r===null)return!1;var l=Object.keys(n),u=Object.keys(r);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var m=l[u];if(!Me.call(r,m)||!Mn(n[m],r[m]))return!1}return!0}function zm(n){for(;n&&n.firstChild;)n=n.firstChild;return n}function Pm(n,r){var l=zm(n);n=0;for(var u;l;){if(l.nodeType===3){if(u=n+l.textContent.length,n<=r&&u>=r)return{node:l,offset:r-n};n=u}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=zm(l)}}function Im(n,r){return n&&r?n===r?!0:n&&n.nodeType===3?!1:r&&r.nodeType===3?Im(n,r.parentNode):"contains"in n?n.contains(r):n.compareDocumentPosition?!!(n.compareDocumentPosition(r)&16):!1:!1}function Hm(n){n=n!=null&&n.ownerDocument!=null&&n.ownerDocument.defaultView!=null?n.ownerDocument.defaultView:window;for(var r=on(n.document);r instanceof n.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch{l=!1}if(l)n=r.contentWindow;else break;r=on(n.document)}return r}function Ju(n){var r=n&&n.nodeName&&n.nodeName.toLowerCase();return r&&(r==="input"&&(n.type==="text"||n.type==="search"||n.type==="tel"||n.type==="url"||n.type==="password")||r==="textarea"||n.contentEditable==="true")}var L1=jt&&"documentMode"in document&&11>=document.documentMode,va=null,eh=null,Sl=null,th=!1;function Um(n,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;th||va==null||va!==on(u)||(u=va,"selectionStart"in u&&Ju(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),Sl&&yl(Sl,u)||(Sl=u,u=Bc(eh,"onSelect"),0<u.length&&(r=new qo("onSelect","select",null,r,l),n.push({event:r,listeners:u}),r.target=va)))}function zs(n,r){var l={};return l[n.toLowerCase()]=r.toLowerCase(),l["Webkit"+n]="webkit"+r,l["Moz"+n]="moz"+r,l}var ya={animationend:zs("Animation","AnimationEnd"),animationiteration:zs("Animation","AnimationIteration"),animationstart:zs("Animation","AnimationStart"),transitionrun:zs("Transition","TransitionRun"),transitionstart:zs("Transition","TransitionStart"),transitioncancel:zs("Transition","TransitionCancel"),transitionend:zs("Transition","TransitionEnd")},ih={},$m={};jt&&($m=document.createElement("div").style,"AnimationEvent"in window||(delete ya.animationend.animation,delete ya.animationiteration.animation,delete ya.animationstart.animation),"TransitionEvent"in window||delete ya.transitionend.transition);function Ps(n){if(ih[n])return ih[n];if(!ya[n])return n;var r=ya[n],l;for(l in r)if(r.hasOwnProperty(l)&&l in $m)return ih[n]=r[l];return n}var Fm=Ps("animationend"),qm=Ps("animationiteration"),Wm=Ps("animationstart"),O1=Ps("transitionrun"),z1=Ps("transitionstart"),P1=Ps("transitioncancel"),Gm=Ps("transitionend"),Ym=new Map,nh="abort auxClick beforeToggle 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(" ");nh.push("scrollEnd");function dr(n,r){Ym.set(n,r),ln(r,[n])}var Yo=typeof reportError=="function"?reportError:function(n){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof n=="object"&&n!==null&&typeof n.message=="string"?String(n.message):String(n),error:n});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",n);return}console.error(n)},Kn=[],Sa=0,rh=0;function Ko(){for(var n=Sa,r=rh=Sa=0;r<n;){var l=Kn[r];Kn[r++]=null;var u=Kn[r];Kn[r++]=null;var m=Kn[r];Kn[r++]=null;var g=Kn[r];if(Kn[r++]=null,u!==null&&m!==null){var S=u.pending;S===null?m.next=m:(m.next=S.next,S.next=m),u.pending=m}g!==0&&Km(l,m,g)}}function Vo(n,r,l,u){Kn[Sa++]=n,Kn[Sa++]=r,Kn[Sa++]=l,Kn[Sa++]=u,rh|=u,n.lanes|=u,n=n.alternate,n!==null&&(n.lanes|=u)}function sh(n,r,l,u){return Vo(n,r,l,u),Xo(n)}function Is(n,r){return Vo(n,null,null,r),Xo(n)}function Km(n,r,l){n.lanes|=l;var u=n.alternate;u!==null&&(u.lanes|=l);for(var m=!1,g=n.return;g!==null;)g.childLanes|=l,u=g.alternate,u!==null&&(u.childLanes|=l),g.tag===22&&(n=g.stateNode,n===null||n._visibility&1||(m=!0)),n=g,g=g.return;return n.tag===3?(g=n.stateNode,m&&r!==null&&(m=31-pt(l),n=g.hiddenUpdates,u=n[m],u===null?n[m]=[r]:u.push(r),r.lane=l|536870912),g):null}function Xo(n){if(50<ql)throw ql=0,pd=null,Error(s(185));for(var r=n.return;r!==null;)n=r,r=n.return;return n.tag===3?n.stateNode:null}var wa={};function I1(n,r,l,u){this.tag=n,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Dn(n,r,l,u){return new I1(n,r,l,u)}function ah(n){return n=n.prototype,!(!n||!n.isReactComponent)}function Mr(n,r){var l=n.alternate;return l===null?(l=Dn(n.tag,r,n.key,n.mode),l.elementType=n.elementType,l.type=n.type,l.stateNode=n.stateNode,l.alternate=n,n.alternate=l):(l.pendingProps=r,l.type=n.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=n.flags&65011712,l.childLanes=n.childLanes,l.lanes=n.lanes,l.child=n.child,l.memoizedProps=n.memoizedProps,l.memoizedState=n.memoizedState,l.updateQueue=n.updateQueue,r=n.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=n.sibling,l.index=n.index,l.ref=n.ref,l.refCleanup=n.refCleanup,l}function Vm(n,r){n.flags&=65011714;var l=n.alternate;return l===null?(n.childLanes=0,n.lanes=r,n.child=null,n.subtreeFlags=0,n.memoizedProps=null,n.memoizedState=null,n.updateQueue=null,n.dependencies=null,n.stateNode=null):(n.childLanes=l.childLanes,n.lanes=l.lanes,n.child=l.child,n.subtreeFlags=0,n.deletions=null,n.memoizedProps=l.memoizedProps,n.memoizedState=l.memoizedState,n.updateQueue=l.updateQueue,n.type=l.type,r=l.dependencies,n.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),n}function Zo(n,r,l,u,m,g){var S=0;if(u=n,typeof n=="function")ah(n)&&(S=1);else if(typeof n=="string")S=qw(n,l,K.current)?26:n==="html"||n==="head"||n==="body"?27:5;else e:switch(n){case _e:return n=Dn(31,l,r,m),n.elementType=_e,n.lanes=g,n;case N:return Hs(l.children,m,g,r);case j:S=8,m|=24;break;case E:return n=Dn(12,l,r,m|2),n.elementType=E,n.lanes=g,n;case q:return n=Dn(13,l,r,m),n.elementType=q,n.lanes=g,n;case D:return n=Dn(19,l,r,m),n.elementType=D,n.lanes=g,n;default:if(typeof n=="object"&&n!==null)switch(n.$$typeof){case O:S=10;break e;case z:S=9;break e;case W:S=11;break e;case te:S=14;break e;case de:S=16,u=null;break e}S=29,l=Error(s(130,n===null?"null":typeof n,"")),u=null}return r=Dn(S,l,r,m),r.elementType=n,r.type=u,r.lanes=g,r}function Hs(n,r,l,u){return n=Dn(7,n,u,r),n.lanes=l,n}function lh(n,r,l){return n=Dn(6,n,null,r),n.lanes=l,n}function Xm(n){var r=Dn(18,null,null,0);return r.stateNode=n,r}function oh(n,r,l){return r=Dn(4,n.children!==null?n.children:[],n.key,r),r.lanes=l,r.stateNode={containerInfo:n.containerInfo,pendingChildren:null,implementation:n.implementation},r}var Zm=new WeakMap;function Vn(n,r){if(typeof n=="object"&&n!==null){var l=Zm.get(n);return l!==void 0?l:(r={value:n,source:r,stack:Ve(r)},Zm.set(n,r),r)}return{value:n,source:r,stack:Ve(r)}}var Ca=[],ka=0,Qo=null,wl=0,Xn=[],Zn=0,ns=null,xr=1,_r="";function Dr(n,r){Ca[ka++]=wl,Ca[ka++]=Qo,Qo=n,wl=r}function Qm(n,r,l){Xn[Zn++]=xr,Xn[Zn++]=_r,Xn[Zn++]=ns,ns=n;var u=xr;n=_r;var m=32-pt(u)-1;u&=~(1<<m),l+=1;var g=32-pt(r)+m;if(30<g){var S=m-m%5;g=(u&(1<<S)-1).toString(32),u>>=S,m-=S,xr=1<<32-pt(r)+m|l<<m|u,_r=g+n}else xr=1<<g|l<<m|u,_r=n}function ch(n){n.return!==null&&(Dr(n,1),Qm(n,1,0))}function uh(n){for(;n===Qo;)Qo=Ca[--ka],Ca[ka]=null,wl=Ca[--ka],Ca[ka]=null;for(;n===ns;)ns=Xn[--Zn],Xn[Zn]=null,_r=Xn[--Zn],Xn[Zn]=null,xr=Xn[--Zn],Xn[Zn]=null}function Jm(n,r){Xn[Zn++]=xr,Xn[Zn++]=_r,Xn[Zn++]=ns,xr=r.id,_r=r.overflow,ns=n}var Wi=null,Xt=null,Et=!1,rs=null,Qn=!1,hh=Error(s(519));function ss(n){var r=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Cl(Vn(r,n)),hh}function eg(n){var r=n.stateNode,l=n.type,u=n.memoizedProps;switch(r[st]=n,r[it]=u,l){case"dialog":xt("cancel",r),xt("close",r);break;case"iframe":case"object":case"embed":xt("load",r);break;case"video":case"audio":for(l=0;l<Gl.length;l++)xt(Gl[l],r);break;case"source":xt("error",r);break;case"img":case"image":case"link":xt("error",r),xt("load",r);break;case"details":xt("toggle",r);break;case"input":xt("invalid",r),pa(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":xt("invalid",r);break;case"textarea":xt("invalid",r),fl(r,u.value,u.defaultValue,u.children)}l=u.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||u.suppressHydrationWarning===!0||x_(r.textContent,l)?(u.popover!=null&&(xt("beforetoggle",r),xt("toggle",r)),u.onScroll!=null&&xt("scroll",r),u.onScrollEnd!=null&&xt("scrollend",r),u.onClick!=null&&(r.onclick=cn),r=!0):r=!1,r||ss(n,!0)}function tg(n){for(Wi=n.return;Wi;)switch(Wi.tag){case 5:case 31:case 13:Qn=!1;return;case 27:case 3:Qn=!0;return;default:Wi=Wi.return}}function Ea(n){if(n!==Wi)return!1;if(!Et)return tg(n),Et=!0,!1;var r=n.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=n.type,l=!(l!=="form"&&l!=="button")||jd(n.type,n.memoizedProps)),l=!l),l&&Xt&&ss(n),tg(n),r===13){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Xt=E_(n)}else if(r===31){if(n=n.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(317));Xt=E_(n)}else r===27?(r=Xt,bs(n.type)?(n=Bd,Bd=null,Xt=n):Xt=r):Xt=Wi?er(n.stateNode.nextSibling):null;return!0}function Us(){Xt=Wi=null,Et=!1}function dh(){var n=rs;return n!==null&&(wn===null?wn=n:wn.push.apply(wn,n),rs=null),n}function Cl(n){rs===null?rs=[n]:rs.push(n)}var fh=R(null),$s=null,Br=null;function as(n,r,l){C(fh,r._currentValue),r._currentValue=l}function Lr(n){n._currentValue=fh.current,V(fh)}function ph(n,r,l){for(;n!==null;){var u=n.alternate;if((n.childLanes&r)!==r?(n.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),n===l)break;n=n.return}}function mh(n,r,l,u){var m=n.child;for(m!==null&&(m.return=n);m!==null;){var g=m.dependencies;if(g!==null){var S=m.child;g=g.firstContext;e:for(;g!==null;){var k=g;g=m;for(var M=0;M<r.length;M++)if(k.context===r[M]){g.lanes|=l,k=g.alternate,k!==null&&(k.lanes|=l),ph(g.return,l,n),u||(S=null);break e}g=k.next}}else if(m.tag===18){if(S=m.return,S===null)throw Error(s(341));S.lanes|=l,g=S.alternate,g!==null&&(g.lanes|=l),ph(S,l,n),S=null}else S=m.child;if(S!==null)S.return=m;else for(S=m;S!==null;){if(S===n){S=null;break}if(m=S.sibling,m!==null){m.return=S.return,S=m;break}S=S.return}m=S}}function Na(n,r,l,u){n=null;for(var m=r,g=!1;m!==null;){if(!g){if((m.flags&524288)!==0)g=!0;else if((m.flags&262144)!==0)break}if(m.tag===10){var S=m.alternate;if(S===null)throw Error(s(387));if(S=S.memoizedProps,S!==null){var k=m.type;Mn(m.pendingProps.value,S.value)||(n!==null?n.push(k):n=[k])}}else if(m===$.current){if(S=m.alternate,S===null)throw Error(s(387));S.memoizedState.memoizedState!==m.memoizedState.memoizedState&&(n!==null?n.push(Zl):n=[Zl])}m=m.return}n!==null&&mh(r,n,l,u),r.flags|=262144}function Jo(n){for(n=n.firstContext;n!==null;){if(!Mn(n.context._currentValue,n.memoizedValue))return!0;n=n.next}return!1}function Fs(n){$s=n,Br=null,n=n.dependencies,n!==null&&(n.firstContext=null)}function Gi(n){return ig($s,n)}function ec(n,r){return $s===null&&Fs(n),ig(n,r)}function ig(n,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},Br===null){if(n===null)throw Error(s(308));Br=r,n.dependencies={lanes:0,firstContext:r},n.flags|=524288}else Br=Br.next=r;return l}var H1=typeof AbortController<"u"?AbortController:function(){var n=[],r=this.signal={aborted:!1,addEventListener:function(l,u){n.push(u)}};this.abort=function(){r.aborted=!0,n.forEach(function(l){return l()})}},U1=e.unstable_scheduleCallback,$1=e.unstable_NormalPriority,bi={$$typeof:O,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function gh(){return{controller:new H1,data:new Map,refCount:0}}function kl(n){n.refCount--,n.refCount===0&&U1($1,function(){n.controller.abort()})}var El=null,xh=0,Ta=0,ja=null;function F1(n,r){if(El===null){var l=El=[];xh=0,Ta=vd(),ja={status:"pending",value:void 0,then:function(u){l.push(u)}}}return xh++,r.then(ng,ng),r}function ng(){if(--xh===0&&El!==null){ja!==null&&(ja.status="fulfilled");var n=El;El=null,Ta=0,ja=null;for(var r=0;r<n.length;r++)(0,n[r])()}}function q1(n,r){var l=[],u={status:"pending",value:null,reason:null,then:function(m){l.push(m)}};return n.then(function(){u.status="fulfilled",u.value=r;for(var m=0;m<l.length;m++)(0,l[m])(r)},function(m){for(u.status="rejected",u.reason=m,m=0;m<l.length;m++)(0,l[m])(void 0)}),u}var rg=A.S;A.S=function(n,r){Ux=Ct(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&F1(n,r),rg!==null&&rg(n,r)};var qs=R(null);function _h(){var n=qs.current;return n!==null?n:Wt.pooledCache}function tc(n,r){r===null?C(qs,qs.current):C(qs,r.pool)}function sg(){var n=_h();return n===null?null:{parent:bi._currentValue,pool:n}}var Aa=Error(s(460)),bh=Error(s(474)),ic=Error(s(542)),nc={then:function(){}};function ag(n){return n=n.status,n==="fulfilled"||n==="rejected"}function lg(n,r,l){switch(l=n[l],l===void 0?n.push(r):l!==r&&(r.then(cn,cn),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,cg(n),n;default:if(typeof r.status=="string")r.then(cn,cn);else{if(n=Wt,n!==null&&100<n.shellSuspendCounter)throw Error(s(482));n=r,n.status="pending",n.then(function(u){if(r.status==="pending"){var m=r;m.status="fulfilled",m.value=u}},function(u){if(r.status==="pending"){var m=r;m.status="rejected",m.reason=u}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw n=r.reason,cg(n),n}throw Gs=r,Aa}}function Ws(n){try{var r=n._init;return r(n._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Gs=l,Aa):l}}var Gs=null;function og(){if(Gs===null)throw Error(s(459));var n=Gs;return Gs=null,n}function cg(n){if(n===Aa||n===ic)throw Error(s(483))}var Ra=null,Nl=0;function rc(n){var r=Nl;return Nl+=1,Ra===null&&(Ra=[]),lg(Ra,n,r)}function Tl(n,r){r=r.props.ref,n.ref=r!==void 0?r:null}function sc(n,r){throw r.$$typeof===b?Error(s(525)):(n=Object.prototype.toString.call(r),Error(s(31,n==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":n)))}function ug(n){function r(F,L){if(n){var X=F.deletions;X===null?(F.deletions=[L],F.flags|=16):X.push(L)}}function l(F,L){if(!n)return null;for(;L!==null;)r(F,L),L=L.sibling;return null}function u(F){for(var L=new Map;F!==null;)F.key!==null?L.set(F.key,F):L.set(F.index,F),F=F.sibling;return L}function m(F,L){return F=Mr(F,L),F.index=0,F.sibling=null,F}function g(F,L,X){return F.index=X,n?(X=F.alternate,X!==null?(X=X.index,X<L?(F.flags|=67108866,L):X):(F.flags|=67108866,L)):(F.flags|=1048576,L)}function S(F){return n&&F.alternate===null&&(F.flags|=67108866),F}function k(F,L,X,he){return L===null||L.tag!==6?(L=lh(X,F.mode,he),L.return=F,L):(L=m(L,X),L.return=F,L)}function M(F,L,X,he){var He=X.type;return He===N?ce(F,L,X.props.children,he,X.key):L!==null&&(L.elementType===He||typeof He=="object"&&He!==null&&He.$$typeof===de&&Ws(He)===L.type)?(L=m(L,X.props),Tl(L,X),L.return=F,L):(L=Zo(X.type,X.key,X.props,null,F.mode,he),Tl(L,X),L.return=F,L)}function Z(F,L,X,he){return L===null||L.tag!==4||L.stateNode.containerInfo!==X.containerInfo||L.stateNode.implementation!==X.implementation?(L=oh(X,F.mode,he),L.return=F,L):(L=m(L,X.children||[]),L.return=F,L)}function ce(F,L,X,he,He){return L===null||L.tag!==7?(L=Hs(X,F.mode,he,He),L.return=F,L):(L=m(L,X),L.return=F,L)}function fe(F,L,X){if(typeof L=="string"&&L!==""||typeof L=="number"||typeof L=="bigint")return L=lh(""+L,F.mode,X),L.return=F,L;if(typeof L=="object"&&L!==null){switch(L.$$typeof){case v:return X=Zo(L.type,L.key,L.props,null,F.mode,X),Tl(X,L),X.return=F,X;case y:return L=oh(L,F.mode,X),L.return=F,L;case de:return L=Ws(L),fe(F,L,X)}if(I(L)||G(L))return L=Hs(L,F.mode,X,null),L.return=F,L;if(typeof L.then=="function")return fe(F,rc(L),X);if(L.$$typeof===O)return fe(F,ec(F,L),X);sc(F,L)}return null}function J(F,L,X,he){var He=L!==null?L.key:null;if(typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint")return He!==null?null:k(F,L,""+X,he);if(typeof X=="object"&&X!==null){switch(X.$$typeof){case v:return X.key===He?M(F,L,X,he):null;case y:return X.key===He?Z(F,L,X,he):null;case de:return X=Ws(X),J(F,L,X,he)}if(I(X)||G(X))return He!==null?null:ce(F,L,X,he,null);if(typeof X.then=="function")return J(F,L,rc(X),he);if(X.$$typeof===O)return J(F,L,ec(F,X),he);sc(F,X)}return null}function se(F,L,X,he,He){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return F=F.get(X)||null,k(L,F,""+he,He);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case v:return F=F.get(he.key===null?X:he.key)||null,M(L,F,he,He);case y:return F=F.get(he.key===null?X:he.key)||null,Z(L,F,he,He);case de:return he=Ws(he),se(F,L,X,he,He)}if(I(he)||G(he))return F=F.get(X)||null,ce(L,F,he,He,null);if(typeof he.then=="function")return se(F,L,X,rc(he),He);if(he.$$typeof===O)return se(F,L,X,ec(L,he),He);sc(L,he)}return null}function De(F,L,X,he){for(var He=null,At=null,Oe=L,at=L=0,St=null;Oe!==null&&at<X.length;at++){Oe.index>at?(St=Oe,Oe=null):St=Oe.sibling;var Rt=J(F,Oe,X[at],he);if(Rt===null){Oe===null&&(Oe=St);break}n&&Oe&&Rt.alternate===null&&r(F,Oe),L=g(Rt,L,at),At===null?He=Rt:At.sibling=Rt,At=Rt,Oe=St}if(at===X.length)return l(F,Oe),Et&&Dr(F,at),He;if(Oe===null){for(;at<X.length;at++)Oe=fe(F,X[at],he),Oe!==null&&(L=g(Oe,L,at),At===null?He=Oe:At.sibling=Oe,At=Oe);return Et&&Dr(F,at),He}for(Oe=u(Oe);at<X.length;at++)St=se(Oe,F,at,X[at],he),St!==null&&(n&&St.alternate!==null&&Oe.delete(St.key===null?at:St.key),L=g(St,L,at),At===null?He=St:At.sibling=St,At=St);return n&&Oe.forEach(function(Cs){return r(F,Cs)}),Et&&Dr(F,at),He}function qe(F,L,X,he){if(X==null)throw Error(s(151));for(var He=null,At=null,Oe=L,at=L=0,St=null,Rt=X.next();Oe!==null&&!Rt.done;at++,Rt=X.next()){Oe.index>at?(St=Oe,Oe=null):St=Oe.sibling;var Cs=J(F,Oe,Rt.value,he);if(Cs===null){Oe===null&&(Oe=St);break}n&&Oe&&Cs.alternate===null&&r(F,Oe),L=g(Cs,L,at),At===null?He=Cs:At.sibling=Cs,At=Cs,Oe=St}if(Rt.done)return l(F,Oe),Et&&Dr(F,at),He;if(Oe===null){for(;!Rt.done;at++,Rt=X.next())Rt=fe(F,Rt.value,he),Rt!==null&&(L=g(Rt,L,at),At===null?He=Rt:At.sibling=Rt,At=Rt);return Et&&Dr(F,at),He}for(Oe=u(Oe);!Rt.done;at++,Rt=X.next())Rt=se(Oe,F,at,Rt.value,he),Rt!==null&&(n&&Rt.alternate!==null&&Oe.delete(Rt.key===null?at:Rt.key),L=g(Rt,L,at),At===null?He=Rt:At.sibling=Rt,At=Rt);return n&&Oe.forEach(function(tC){return r(F,tC)}),Et&&Dr(F,at),He}function $t(F,L,X,he){if(typeof X=="object"&&X!==null&&X.type===N&&X.key===null&&(X=X.props.children),typeof X=="object"&&X!==null){switch(X.$$typeof){case v:e:{for(var He=X.key;L!==null;){if(L.key===He){if(He=X.type,He===N){if(L.tag===7){l(F,L.sibling),he=m(L,X.props.children),he.return=F,F=he;break e}}else if(L.elementType===He||typeof He=="object"&&He!==null&&He.$$typeof===de&&Ws(He)===L.type){l(F,L.sibling),he=m(L,X.props),Tl(he,X),he.return=F,F=he;break e}l(F,L);break}else r(F,L);L=L.sibling}X.type===N?(he=Hs(X.props.children,F.mode,he,X.key),he.return=F,F=he):(he=Zo(X.type,X.key,X.props,null,F.mode,he),Tl(he,X),he.return=F,F=he)}return S(F);case y:e:{for(He=X.key;L!==null;){if(L.key===He)if(L.tag===4&&L.stateNode.containerInfo===X.containerInfo&&L.stateNode.implementation===X.implementation){l(F,L.sibling),he=m(L,X.children||[]),he.return=F,F=he;break e}else{l(F,L);break}else r(F,L);L=L.sibling}he=oh(X,F.mode,he),he.return=F,F=he}return S(F);case de:return X=Ws(X),$t(F,L,X,he)}if(I(X))return De(F,L,X,he);if(G(X)){if(He=G(X),typeof He!="function")throw Error(s(150));return X=He.call(X),qe(F,L,X,he)}if(typeof X.then=="function")return $t(F,L,rc(X),he);if(X.$$typeof===O)return $t(F,L,ec(F,X),he);sc(F,X)}return typeof X=="string"&&X!==""||typeof X=="number"||typeof X=="bigint"?(X=""+X,L!==null&&L.tag===6?(l(F,L.sibling),he=m(L,X),he.return=F,F=he):(l(F,L),he=lh(X,F.mode,he),he.return=F,F=he),S(F)):l(F,L)}return function(F,L,X,he){try{Nl=0;var He=$t(F,L,X,he);return Ra=null,He}catch(Oe){if(Oe===Aa||Oe===ic)throw Oe;var At=Dn(29,Oe,null,F.mode);return At.lanes=he,At.return=F,At}finally{}}}var Ys=ug(!0),hg=ug(!1),ls=!1;function vh(n){n.updateQueue={baseState:n.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yh(n,r){n=n.updateQueue,r.updateQueue===n&&(r.updateQueue={baseState:n.baseState,firstBaseUpdate:n.firstBaseUpdate,lastBaseUpdate:n.lastBaseUpdate,shared:n.shared,callbacks:null})}function os(n){return{lane:n,tag:0,payload:null,callback:null,next:null}}function cs(n,r,l){var u=n.updateQueue;if(u===null)return null;if(u=u.shared,(Dt&2)!==0){var m=u.pending;return m===null?r.next=r:(r.next=m.next,m.next=r),u.pending=r,r=Xo(n),Km(n,null,l),r}return Vo(n,u,r,l),Xo(n)}function jl(n,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,Ye(n,l)}}function Sh(n,r){var l=n.updateQueue,u=n.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var m=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var S={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?m=g=S:g=g.next=S,l=l.next}while(l!==null);g===null?m=g=r:g=g.next=r}else m=g=r;l={baseState:u.baseState,firstBaseUpdate:m,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},n.updateQueue=l;return}n=l.lastBaseUpdate,n===null?l.firstBaseUpdate=r:n.next=r,l.lastBaseUpdate=r}var wh=!1;function Al(){if(wh){var n=ja;if(n!==null)throw n}}function Rl(n,r,l,u){wh=!1;var m=n.updateQueue;ls=!1;var g=m.firstBaseUpdate,S=m.lastBaseUpdate,k=m.shared.pending;if(k!==null){m.shared.pending=null;var M=k,Z=M.next;M.next=null,S===null?g=Z:S.next=Z,S=M;var ce=n.alternate;ce!==null&&(ce=ce.updateQueue,k=ce.lastBaseUpdate,k!==S&&(k===null?ce.firstBaseUpdate=Z:k.next=Z,ce.lastBaseUpdate=M))}if(g!==null){var fe=m.baseState;S=0,ce=Z=M=null,k=g;do{var J=k.lane&-536870913,se=J!==k.lane;if(se?(yt&J)===J:(u&J)===J){J!==0&&J===Ta&&(wh=!0),ce!==null&&(ce=ce.next={lane:0,tag:k.tag,payload:k.payload,callback:null,next:null});e:{var De=n,qe=k;J=r;var $t=l;switch(qe.tag){case 1:if(De=qe.payload,typeof De=="function"){fe=De.call($t,fe,J);break e}fe=De;break e;case 3:De.flags=De.flags&-65537|128;case 0:if(De=qe.payload,J=typeof De=="function"?De.call($t,fe,J):De,J==null)break e;fe=x({},fe,J);break e;case 2:ls=!0}}J=k.callback,J!==null&&(n.flags|=64,se&&(n.flags|=8192),se=m.callbacks,se===null?m.callbacks=[J]:se.push(J))}else se={lane:J,tag:k.tag,payload:k.payload,callback:k.callback,next:null},ce===null?(Z=ce=se,M=fe):ce=ce.next=se,S|=J;if(k=k.next,k===null){if(k=m.shared.pending,k===null)break;se=k,k=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);ce===null&&(M=fe),m.baseState=M,m.firstBaseUpdate=Z,m.lastBaseUpdate=ce,g===null&&(m.shared.lanes=0),ps|=S,n.lanes=S,n.memoizedState=fe}}function dg(n,r){if(typeof n!="function")throw Error(s(191,n));n.call(r)}function fg(n,r){var l=n.callbacks;if(l!==null)for(n.callbacks=null,n=0;n<l.length;n++)dg(l[n],r)}var Ma=R(null),ac=R(0);function pg(n,r){n=qr,C(ac,n),C(Ma,r),qr=n|r.baseLanes}function Ch(){C(ac,qr),C(Ma,Ma.current)}function kh(){qr=ac.current,V(Ma),V(ac)}var Bn=R(null),Jn=null;function us(n){var r=n.alternate;C(mi,mi.current&1),C(Bn,n),Jn===null&&(r===null||Ma.current!==null||r.memoizedState!==null)&&(Jn=n)}function Eh(n){C(mi,mi.current),C(Bn,n),Jn===null&&(Jn=n)}function mg(n){n.tag===22?(C(mi,mi.current),C(Bn,n),Jn===null&&(Jn=n)):hs()}function hs(){C(mi,mi.current),C(Bn,Bn.current)}function Ln(n){V(Bn),Jn===n&&(Jn=null),V(mi)}var mi=R(0);function lc(n){for(var r=n;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Md(l)||Dd(l)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var Or=0,nt=null,Ht=null,vi=null,oc=!1,Da=!1,Ks=!1,cc=0,Ml=0,Ba=null,W1=0;function ci(){throw Error(s(321))}function Nh(n,r){if(r===null)return!1;for(var l=0;l<r.length&&l<n.length;l++)if(!Mn(n[l],r[l]))return!1;return!0}function Th(n,r,l,u,m,g){return Or=g,nt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,A.H=n===null||n.memoizedState===null?Qg:Fh,Ks=!1,g=l(u,m),Ks=!1,Da&&(g=xg(r,l,u,m)),gg(n),g}function gg(n){A.H=Ll;var r=Ht!==null&&Ht.next!==null;if(Or=0,vi=Ht=nt=null,oc=!1,Ml=0,Ba=null,r)throw Error(s(300));n===null||yi||(n=n.dependencies,n!==null&&Jo(n)&&(yi=!0))}function xg(n,r,l,u){nt=n;var m=0;do{if(Da&&(Ba=null),Ml=0,Da=!1,25<=m)throw Error(s(301));if(m+=1,vi=Ht=null,n.updateQueue!=null){var g=n.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}A.H=Jg,g=r(l,u)}while(Da);return g}function G1(){var n=A.H,r=n.useState()[0];return r=typeof r.then=="function"?Dl(r):r,n=n.useState()[0],(Ht!==null?Ht.memoizedState:null)!==n&&(nt.flags|=1024),r}function jh(){var n=cc!==0;return cc=0,n}function Ah(n,r,l){r.updateQueue=n.updateQueue,r.flags&=-2053,n.lanes&=~l}function Rh(n){if(oc){for(n=n.memoizedState;n!==null;){var r=n.queue;r!==null&&(r.pending=null),n=n.next}oc=!1}Or=0,vi=Ht=nt=null,Da=!1,Ml=cc=0,Ba=null}function hn(){var n={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vi===null?nt.memoizedState=vi=n:vi=vi.next=n,vi}function gi(){if(Ht===null){var n=nt.alternate;n=n!==null?n.memoizedState:null}else n=Ht.next;var r=vi===null?nt.memoizedState:vi.next;if(r!==null)vi=r,Ht=n;else{if(n===null)throw nt.alternate===null?Error(s(467)):Error(s(310));Ht=n,n={memoizedState:Ht.memoizedState,baseState:Ht.baseState,baseQueue:Ht.baseQueue,queue:Ht.queue,next:null},vi===null?nt.memoizedState=vi=n:vi=vi.next=n}return vi}function uc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Dl(n){var r=Ml;return Ml+=1,Ba===null&&(Ba=[]),n=lg(Ba,n,r),r=nt,(vi===null?r.memoizedState:vi.next)===null&&(r=r.alternate,A.H=r===null||r.memoizedState===null?Qg:Fh),n}function hc(n){if(n!==null&&typeof n=="object"){if(typeof n.then=="function")return Dl(n);if(n.$$typeof===O)return Gi(n)}throw Error(s(438,String(n)))}function Mh(n){var r=null,l=nt.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var u=nt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(r={data:u.data.map(function(m){return m.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=uc(),nt.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(n),u=0;u<n;u++)l[u]=P;return r.index++,l}function zr(n,r){return typeof r=="function"?r(n):r}function dc(n){var r=gi();return Dh(r,Ht,n)}function Dh(n,r,l){var u=n.queue;if(u===null)throw Error(s(311));u.lastRenderedReducer=l;var m=n.baseQueue,g=u.pending;if(g!==null){if(m!==null){var S=m.next;m.next=g.next,g.next=S}r.baseQueue=m=g,u.pending=null}if(g=n.baseState,m===null)n.memoizedState=g;else{r=m.next;var k=S=null,M=null,Z=r,ce=!1;do{var fe=Z.lane&-536870913;if(fe!==Z.lane?(yt&fe)===fe:(Or&fe)===fe){var J=Z.revertLane;if(J===0)M!==null&&(M=M.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),fe===Ta&&(ce=!0);else if((Or&J)===J){Z=Z.next,J===Ta&&(ce=!0);continue}else fe={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},M===null?(k=M=fe,S=g):M=M.next=fe,nt.lanes|=J,ps|=J;fe=Z.action,Ks&&l(g,fe),g=Z.hasEagerState?Z.eagerState:l(g,fe)}else J={lane:fe,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},M===null?(k=M=J,S=g):M=M.next=J,nt.lanes|=fe,ps|=fe;Z=Z.next}while(Z!==null&&Z!==r);if(M===null?S=g:M.next=k,!Mn(g,n.memoizedState)&&(yi=!0,ce&&(l=ja,l!==null)))throw l;n.memoizedState=g,n.baseState=S,n.baseQueue=M,u.lastRenderedState=g}return m===null&&(u.lanes=0),[n.memoizedState,u.dispatch]}function Bh(n){var r=gi(),l=r.queue;if(l===null)throw Error(s(311));l.lastRenderedReducer=n;var u=l.dispatch,m=l.pending,g=r.memoizedState;if(m!==null){l.pending=null;var S=m=m.next;do g=n(g,S.action),S=S.next;while(S!==m);Mn(g,r.memoizedState)||(yi=!0),r.memoizedState=g,r.baseQueue===null&&(r.baseState=g),l.lastRenderedState=g}return[g,u]}function _g(n,r,l){var u=nt,m=gi(),g=Et;if(g){if(l===void 0)throw Error(s(407));l=l()}else l=r();var S=!Mn((Ht||m).memoizedState,l);if(S&&(m.memoizedState=l,yi=!0),m=m.queue,zh(yg.bind(null,u,m,n),[n]),m.getSnapshot!==r||S||vi!==null&&vi.memoizedState.tag&1){if(u.flags|=2048,La(9,{destroy:void 0},vg.bind(null,u,m,l,r),null),Wt===null)throw Error(s(349));g||(Or&127)!==0||bg(u,r,l)}return l}function bg(n,r,l){n.flags|=16384,n={getSnapshot:r,value:l},r=nt.updateQueue,r===null?(r=uc(),nt.updateQueue=r,r.stores=[n]):(l=r.stores,l===null?r.stores=[n]:l.push(n))}function vg(n,r,l,u){r.value=l,r.getSnapshot=u,Sg(r)&&wg(n)}function yg(n,r,l){return l(function(){Sg(r)&&wg(n)})}function Sg(n){var r=n.getSnapshot;n=n.value;try{var l=r();return!Mn(n,l)}catch{return!0}}function wg(n){var r=Is(n,2);r!==null&&Cn(r,n,2)}function Lh(n){var r=hn();if(typeof n=="function"){var l=n;if(n=l(),Ks){Bt(!0);try{l()}finally{Bt(!1)}}}return r.memoizedState=r.baseState=n,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:n},r}function Cg(n,r,l,u){return n.baseState=l,Dh(n,Ht,typeof u=="function"?u:zr)}function Y1(n,r,l,u,m){if(mc(n))throw Error(s(485));if(n=r.action,n!==null){var g={payload:m,action:n,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};A.T!==null?l(!0):g.isTransition=!1,u(g),l=r.pending,l===null?(g.next=r.pending=g,kg(r,g)):(g.next=l.next,r.pending=l.next=g)}}function kg(n,r){var l=r.action,u=r.payload,m=n.state;if(r.isTransition){var g=A.T,S={};A.T=S;try{var k=l(m,u),M=A.S;M!==null&&M(S,k),Eg(n,r,k)}catch(Z){Oh(n,r,Z)}finally{g!==null&&S.types!==null&&(g.types=S.types),A.T=g}}else try{g=l(m,u),Eg(n,r,g)}catch(Z){Oh(n,r,Z)}}function Eg(n,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){Ng(n,r,u)},function(u){return Oh(n,r,u)}):Ng(n,r,l)}function Ng(n,r,l){r.status="fulfilled",r.value=l,Tg(r),n.state=l,r=n.pending,r!==null&&(l=r.next,l===r?n.pending=null:(l=l.next,r.next=l,kg(n,l)))}function Oh(n,r,l){var u=n.pending;if(n.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=l,Tg(r),r=r.next;while(r!==u)}n.action=null}function Tg(n){n=n.listeners;for(var r=0;r<n.length;r++)(0,n[r])()}function jg(n,r){return r}function Ag(n,r){if(Et){var l=Wt.formState;if(l!==null){e:{var u=nt;if(Et){if(Xt){t:{for(var m=Xt,g=Qn;m.nodeType!==8;){if(!g){m=null;break t}if(m=er(m.nextSibling),m===null){m=null;break t}}g=m.data,m=g==="F!"||g==="F"?m:null}if(m){Xt=er(m.nextSibling),u=m.data==="F!";break e}}ss(u)}u=!1}u&&(r=l[0])}}return l=hn(),l.memoizedState=l.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:jg,lastRenderedState:r},l.queue=u,l=Vg.bind(null,nt,u),u.dispatch=l,u=Lh(!1),g=$h.bind(null,nt,!1,u.queue),u=hn(),m={state:r,dispatch:null,action:n,pending:null},u.queue=m,l=Y1.bind(null,nt,m,g,l),m.dispatch=l,u.memoizedState=n,[r,l,!1]}function Rg(n){var r=gi();return Mg(r,Ht,n)}function Mg(n,r,l){if(r=Dh(n,r,jg)[0],n=dc(zr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=Dl(r)}catch(S){throw S===Aa?ic:S}else u=r;r=gi();var m=r.queue,g=m.dispatch;return l!==r.memoizedState&&(nt.flags|=2048,La(9,{destroy:void 0},K1.bind(null,m,l),null)),[u,g,n]}function K1(n,r){n.action=r}function Dg(n){var r=gi(),l=Ht;if(l!==null)return Mg(r,l,n);gi(),r=r.memoizedState,l=gi();var u=l.queue.dispatch;return l.memoizedState=n,[r,u,!1]}function La(n,r,l,u){return n={tag:n,create:l,deps:u,inst:r,next:null},r=nt.updateQueue,r===null&&(r=uc(),nt.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=n.next=n:(u=l.next,l.next=n,n.next=u,r.lastEffect=n),n}function Bg(){return gi().memoizedState}function fc(n,r,l,u){var m=hn();nt.flags|=n,m.memoizedState=La(1|r,{destroy:void 0},l,u===void 0?null:u)}function pc(n,r,l,u){var m=gi();u=u===void 0?null:u;var g=m.memoizedState.inst;Ht!==null&&u!==null&&Nh(u,Ht.memoizedState.deps)?m.memoizedState=La(r,g,l,u):(nt.flags|=n,m.memoizedState=La(1|r,g,l,u))}function Lg(n,r){fc(8390656,8,n,r)}function zh(n,r){pc(2048,8,n,r)}function V1(n){nt.flags|=4;var r=nt.updateQueue;if(r===null)r=uc(),nt.updateQueue=r,r.events=[n];else{var l=r.events;l===null?r.events=[n]:l.push(n)}}function Og(n){var r=gi().memoizedState;return V1({ref:r,nextImpl:n}),function(){if((Dt&2)!==0)throw Error(s(440));return r.impl.apply(void 0,arguments)}}function zg(n,r){return pc(4,2,n,r)}function Pg(n,r){return pc(4,4,n,r)}function Ig(n,r){if(typeof r=="function"){n=n();var l=r(n);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return n=n(),r.current=n,function(){r.current=null}}function Hg(n,r,l){l=l!=null?l.concat([n]):null,pc(4,4,Ig.bind(null,r,n),l)}function Ph(){}function Ug(n,r){var l=gi();r=r===void 0?null:r;var u=l.memoizedState;return r!==null&&Nh(r,u[1])?u[0]:(l.memoizedState=[n,r],n)}function $g(n,r){var l=gi();r=r===void 0?null:r;var u=l.memoizedState;if(r!==null&&Nh(r,u[1]))return u[0];if(u=n(),Ks){Bt(!0);try{n()}finally{Bt(!1)}}return l.memoizedState=[u,r],u}function Ih(n,r,l){return l===void 0||(Or&1073741824)!==0&&(yt&261930)===0?n.memoizedState=r:(n.memoizedState=l,n=Fx(),nt.lanes|=n,ps|=n,l)}function Fg(n,r,l,u){return Mn(l,r)?l:Ma.current!==null?(n=Ih(n,l,u),Mn(n,r)||(yi=!0),n):(Or&42)===0||(Or&1073741824)!==0&&(yt&261930)===0?(yi=!0,n.memoizedState=l):(n=Fx(),nt.lanes|=n,ps|=n,r)}function qg(n,r,l,u,m){var g=B.p;B.p=g!==0&&8>g?g:8;var S=A.T,k={};A.T=k,$h(n,!1,r,l);try{var M=m(),Z=A.S;if(Z!==null&&Z(k,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var ce=q1(M,u);Bl(n,r,ce,Pn(n))}else Bl(n,r,u,Pn(n))}catch(fe){Bl(n,r,{then:function(){},status:"rejected",reason:fe},Pn())}finally{B.p=g,S!==null&&k.types!==null&&(S.types=k.types),A.T=S}}function X1(){}function Hh(n,r,l,u){if(n.tag!==5)throw Error(s(476));var m=Wg(n).queue;qg(n,m,r,U,l===null?X1:function(){return Gg(n),l(u)})}function Wg(n){var r=n.memoizedState;if(r!==null)return r;r={memoizedState:U,baseState:U,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:U},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zr,lastRenderedState:l},next:null},n.memoizedState=r,n=n.alternate,n!==null&&(n.memoizedState=r),r}function Gg(n){var r=Wg(n);r.next===null&&(r=n.alternate.memoizedState),Bl(n,r.next.queue,{},Pn())}function Uh(){return Gi(Zl)}function Yg(){return gi().memoizedState}function Kg(){return gi().memoizedState}function Z1(n){for(var r=n.return;r!==null;){switch(r.tag){case 24:case 3:var l=Pn();n=os(l);var u=cs(r,n,l);u!==null&&(Cn(u,r,l),jl(u,r,l)),r={cache:gh()},n.payload=r;return}r=r.return}}function Q1(n,r,l){var u=Pn();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},mc(n)?Xg(r,l):(l=sh(n,r,l,u),l!==null&&(Cn(l,n,u),Zg(l,r,u)))}function Vg(n,r,l){var u=Pn();Bl(n,r,l,u)}function Bl(n,r,l,u){var m={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(mc(n))Xg(r,m);else{var g=n.alternate;if(n.lanes===0&&(g===null||g.lanes===0)&&(g=r.lastRenderedReducer,g!==null))try{var S=r.lastRenderedState,k=g(S,l);if(m.hasEagerState=!0,m.eagerState=k,Mn(k,S))return Vo(n,r,m,0),Wt===null&&Ko(),!1}catch{}finally{}if(l=sh(n,r,m,u),l!==null)return Cn(l,n,u),Zg(l,r,u),!0}return!1}function $h(n,r,l,u){if(u={lane:2,revertLane:vd(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},mc(n)){if(r)throw Error(s(479))}else r=sh(n,l,u,2),r!==null&&Cn(r,n,2)}function mc(n){var r=n.alternate;return n===nt||r!==null&&r===nt}function Xg(n,r){Da=oc=!0;var l=n.pending;l===null?r.next=r:(r.next=l.next,l.next=r),n.pending=r}function Zg(n,r,l){if((l&4194048)!==0){var u=r.lanes;u&=n.pendingLanes,l|=u,r.lanes=l,Ye(n,l)}}var Ll={readContext:Gi,use:hc,useCallback:ci,useContext:ci,useEffect:ci,useImperativeHandle:ci,useLayoutEffect:ci,useInsertionEffect:ci,useMemo:ci,useReducer:ci,useRef:ci,useState:ci,useDebugValue:ci,useDeferredValue:ci,useTransition:ci,useSyncExternalStore:ci,useId:ci,useHostTransitionStatus:ci,useFormState:ci,useActionState:ci,useOptimistic:ci,useMemoCache:ci,useCacheRefresh:ci};Ll.useEffectEvent=ci;var Qg={readContext:Gi,use:hc,useCallback:function(n,r){return hn().memoizedState=[n,r===void 0?null:r],n},useContext:Gi,useEffect:Lg,useImperativeHandle:function(n,r,l){l=l!=null?l.concat([n]):null,fc(4194308,4,Ig.bind(null,r,n),l)},useLayoutEffect:function(n,r){return fc(4194308,4,n,r)},useInsertionEffect:function(n,r){fc(4,2,n,r)},useMemo:function(n,r){var l=hn();r=r===void 0?null:r;var u=n();if(Ks){Bt(!0);try{n()}finally{Bt(!1)}}return l.memoizedState=[u,r],u},useReducer:function(n,r,l){var u=hn();if(l!==void 0){var m=l(r);if(Ks){Bt(!0);try{l(r)}finally{Bt(!1)}}}else m=r;return u.memoizedState=u.baseState=m,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:n,lastRenderedState:m},u.queue=n,n=n.dispatch=Q1.bind(null,nt,n),[u.memoizedState,n]},useRef:function(n){var r=hn();return n={current:n},r.memoizedState=n},useState:function(n){n=Lh(n);var r=n.queue,l=Vg.bind(null,nt,r);return r.dispatch=l,[n.memoizedState,l]},useDebugValue:Ph,useDeferredValue:function(n,r){var l=hn();return Ih(l,n,r)},useTransition:function(){var n=Lh(!1);return n=qg.bind(null,nt,n.queue,!0,!1),hn().memoizedState=n,[!1,n]},useSyncExternalStore:function(n,r,l){var u=nt,m=hn();if(Et){if(l===void 0)throw Error(s(407));l=l()}else{if(l=r(),Wt===null)throw Error(s(349));(yt&127)!==0||bg(u,r,l)}m.memoizedState=l;var g={value:l,getSnapshot:r};return m.queue=g,Lg(yg.bind(null,u,g,n),[n]),u.flags|=2048,La(9,{destroy:void 0},vg.bind(null,u,g,l,r),null),l},useId:function(){var n=hn(),r=Wt.identifierPrefix;if(Et){var l=_r,u=xr;l=(u&~(1<<32-pt(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=cc++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=W1++,r="_"+r+"r_"+l.toString(32)+"_";return n.memoizedState=r},useHostTransitionStatus:Uh,useFormState:Ag,useActionState:Ag,useOptimistic:function(n){var r=hn();r.memoizedState=r.baseState=n;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=$h.bind(null,nt,!0,l),l.dispatch=r,[n,r]},useMemoCache:Mh,useCacheRefresh:function(){return hn().memoizedState=Z1.bind(null,nt)},useEffectEvent:function(n){var r=hn(),l={impl:n};return r.memoizedState=l,function(){if((Dt&2)!==0)throw Error(s(440));return l.impl.apply(void 0,arguments)}}},Fh={readContext:Gi,use:hc,useCallback:Ug,useContext:Gi,useEffect:zh,useImperativeHandle:Hg,useInsertionEffect:zg,useLayoutEffect:Pg,useMemo:$g,useReducer:dc,useRef:Bg,useState:function(){return dc(zr)},useDebugValue:Ph,useDeferredValue:function(n,r){var l=gi();return Fg(l,Ht.memoizedState,n,r)},useTransition:function(){var n=dc(zr)[0],r=gi().memoizedState;return[typeof n=="boolean"?n:Dl(n),r]},useSyncExternalStore:_g,useId:Yg,useHostTransitionStatus:Uh,useFormState:Rg,useActionState:Rg,useOptimistic:function(n,r){var l=gi();return Cg(l,Ht,n,r)},useMemoCache:Mh,useCacheRefresh:Kg};Fh.useEffectEvent=Og;var Jg={readContext:Gi,use:hc,useCallback:Ug,useContext:Gi,useEffect:zh,useImperativeHandle:Hg,useInsertionEffect:zg,useLayoutEffect:Pg,useMemo:$g,useReducer:Bh,useRef:Bg,useState:function(){return Bh(zr)},useDebugValue:Ph,useDeferredValue:function(n,r){var l=gi();return Ht===null?Ih(l,n,r):Fg(l,Ht.memoizedState,n,r)},useTransition:function(){var n=Bh(zr)[0],r=gi().memoizedState;return[typeof n=="boolean"?n:Dl(n),r]},useSyncExternalStore:_g,useId:Yg,useHostTransitionStatus:Uh,useFormState:Dg,useActionState:Dg,useOptimistic:function(n,r){var l=gi();return Ht!==null?Cg(l,Ht,n,r):(l.baseState=n,[n,l.queue.dispatch])},useMemoCache:Mh,useCacheRefresh:Kg};Jg.useEffectEvent=Og;function qh(n,r,l,u){r=n.memoizedState,l=l(u,r),l=l==null?r:x({},r,l),n.memoizedState=l,n.lanes===0&&(n.updateQueue.baseState=l)}var Wh={enqueueSetState:function(n,r,l){n=n._reactInternals;var u=Pn(),m=os(u);m.payload=r,l!=null&&(m.callback=l),r=cs(n,m,u),r!==null&&(Cn(r,n,u),jl(r,n,u))},enqueueReplaceState:function(n,r,l){n=n._reactInternals;var u=Pn(),m=os(u);m.tag=1,m.payload=r,l!=null&&(m.callback=l),r=cs(n,m,u),r!==null&&(Cn(r,n,u),jl(r,n,u))},enqueueForceUpdate:function(n,r){n=n._reactInternals;var l=Pn(),u=os(l);u.tag=2,r!=null&&(u.callback=r),r=cs(n,u,l),r!==null&&(Cn(r,n,l),jl(r,n,l))}};function ex(n,r,l,u,m,g,S){return n=n.stateNode,typeof n.shouldComponentUpdate=="function"?n.shouldComponentUpdate(u,g,S):r.prototype&&r.prototype.isPureReactComponent?!yl(l,u)||!yl(m,g):!0}function tx(n,r,l,u){n=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,u),r.state!==n&&Wh.enqueueReplaceState(r,r.state,null)}function Vs(n,r){var l=r;if("ref"in r){l={};for(var u in r)u!=="ref"&&(l[u]=r[u])}if(n=n.defaultProps){l===r&&(l=x({},l));for(var m in n)l[m]===void 0&&(l[m]=n[m])}return l}function ix(n){Yo(n)}function nx(n){console.error(n)}function rx(n){Yo(n)}function gc(n,r){try{var l=n.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function sx(n,r,l){try{var u=n.onCaughtError;u(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(m){setTimeout(function(){throw m})}}function Gh(n,r,l){return l=os(l),l.tag=3,l.payload={element:null},l.callback=function(){gc(n,r)},l}function ax(n){return n=os(n),n.tag=3,n}function lx(n,r,l,u){var m=l.type.getDerivedStateFromError;if(typeof m=="function"){var g=u.value;n.payload=function(){return m(g)},n.callback=function(){sx(r,l,u)}}var S=l.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(n.callback=function(){sx(r,l,u),typeof m!="function"&&(ms===null?ms=new Set([this]):ms.add(this));var k=u.stack;this.componentDidCatch(u.value,{componentStack:k!==null?k:""})})}function J1(n,r,l,u,m){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=l.alternate,r!==null&&Na(r,l,m,!0),l=Bn.current,l!==null){switch(l.tag){case 31:case 13:return Jn===null?Tc():l.alternate===null&&ui===0&&(ui=3),l.flags&=-257,l.flags|=65536,l.lanes=m,u===nc?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([u]):r.add(u),xd(n,u,m)),!1;case 22:return l.flags|=65536,u===nc?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([u])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([u]):l.add(u)),xd(n,u,m)),!1}throw Error(s(435,l.tag))}return xd(n,u,m),Tc(),!1}if(Et)return r=Bn.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=m,u!==hh&&(n=Error(s(422),{cause:u}),Cl(Vn(n,l)))):(u!==hh&&(r=Error(s(423),{cause:u}),Cl(Vn(r,l))),n=n.current.alternate,n.flags|=65536,m&=-m,n.lanes|=m,u=Vn(u,l),m=Gh(n.stateNode,u,m),Sh(n,m),ui!==4&&(ui=2)),!1;var g=Error(s(520),{cause:u});if(g=Vn(g,l),Fl===null?Fl=[g]:Fl.push(g),ui!==4&&(ui=2),r===null)return!0;u=Vn(u,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,n=m&-m,l.lanes|=n,n=Gh(l.stateNode,u,n),Sh(l,n),!1;case 1:if(r=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(ms===null||!ms.has(g))))return l.flags|=65536,m&=-m,l.lanes|=m,m=ax(m),lx(m,n,l,u),Sh(l,m),!1}l=l.return}while(l!==null);return!1}var Yh=Error(s(461)),yi=!1;function Yi(n,r,l,u){r.child=n===null?hg(r,null,l,u):Ys(r,n.child,l,u)}function ox(n,r,l,u,m){l=l.render;var g=r.ref;if("ref"in u){var S={};for(var k in u)k!=="ref"&&(S[k]=u[k])}else S=u;return Fs(r),u=Th(n,r,l,S,g,m),k=jh(),n!==null&&!yi?(Ah(n,r,m),Pr(n,r,m)):(Et&&k&&ch(r),r.flags|=1,Yi(n,r,u,m),r.child)}function cx(n,r,l,u,m){if(n===null){var g=l.type;return typeof g=="function"&&!ah(g)&&g.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=g,ux(n,r,g,u,m)):(n=Zo(l.type,null,u,r,r.mode,m),n.ref=r.ref,n.return=r,r.child=n)}if(g=n.child,!td(n,m)){var S=g.memoizedProps;if(l=l.compare,l=l!==null?l:yl,l(S,u)&&n.ref===r.ref)return Pr(n,r,m)}return r.flags|=1,n=Mr(g,u),n.ref=r.ref,n.return=r,r.child=n}function ux(n,r,l,u,m){if(n!==null){var g=n.memoizedProps;if(yl(g,u)&&n.ref===r.ref)if(yi=!1,r.pendingProps=u=g,td(n,m))(n.flags&131072)!==0&&(yi=!0);else return r.lanes=n.lanes,Pr(n,r,m)}return Kh(n,r,l,u,m)}function hx(n,r,l,u){var m=u.children,g=n!==null?n.memoizedState:null;if(n===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((r.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,n!==null){for(u=r.child=n.child,m=0;u!==null;)m=m|u.lanes|u.childLanes,u=u.sibling;u=m&~g}else u=0,r.child=null;return dx(n,r,g,l,u)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},n!==null&&tc(r,g!==null?g.cachePool:null),g!==null?pg(r,g):Ch(),mg(r);else return u=r.lanes=536870912,dx(n,r,g!==null?g.baseLanes|l:l,l,u)}else g!==null?(tc(r,g.cachePool),pg(r,g),hs(),r.memoizedState=null):(n!==null&&tc(r,null),Ch(),hs());return Yi(n,r,m,l),r.child}function Ol(n,r){return n!==null&&n.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function dx(n,r,l,u,m){var g=_h();return g=g===null?null:{parent:bi._currentValue,pool:g},r.memoizedState={baseLanes:l,cachePool:g},n!==null&&tc(r,null),Ch(),mg(r),n!==null&&Na(n,r,u,!0),r.childLanes=m,null}function xc(n,r){return r=bc({mode:r.mode,children:r.children},n.mode),r.ref=n.ref,n.child=r,r.return=n,r}function fx(n,r,l){return Ys(r,n.child,null,l),n=xc(r,r.pendingProps),n.flags|=2,Ln(r),r.memoizedState=null,n}function ew(n,r,l){var u=r.pendingProps,m=(r.flags&128)!==0;if(r.flags&=-129,n===null){if(Et){if(u.mode==="hidden")return n=xc(r,u),r.lanes=536870912,Ol(null,n);if(Eh(r),(n=Xt)?(n=k_(n,Qn),n=n!==null&&n.data==="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:ns!==null?{id:xr,overflow:_r}:null,retryLane:536870912,hydrationErrors:null},l=Xm(n),l.return=r,r.child=l,Wi=r,Xt=null)):n=null,n===null)throw ss(r);return r.lanes=536870912,null}return xc(r,u)}var g=n.memoizedState;if(g!==null){var S=g.dehydrated;if(Eh(r),m)if(r.flags&256)r.flags&=-257,r=fx(n,r,l);else if(r.memoizedState!==null)r.child=n.child,r.flags|=128,r=null;else throw Error(s(558));else if(yi||Na(n,r,l,!1),m=(l&n.childLanes)!==0,yi||m){if(u=Wt,u!==null&&(S=ee(u,l),S!==0&&S!==g.retryLane))throw g.retryLane=S,Is(n,S),Cn(u,n,S),Yh;Tc(),r=fx(n,r,l)}else n=g.treeContext,Xt=er(S.nextSibling),Wi=r,Et=!0,rs=null,Qn=!1,n!==null&&Jm(r,n),r=xc(r,u),r.flags|=4096;return r}return n=Mr(n.child,{mode:u.mode,children:u.children}),n.ref=r.ref,r.child=n,n.return=r,n}function _c(n,r){var l=r.ref;if(l===null)n!==null&&n.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(s(284));(n===null||n.ref!==l)&&(r.flags|=4194816)}}function Kh(n,r,l,u,m){return Fs(r),l=Th(n,r,l,u,void 0,m),u=jh(),n!==null&&!yi?(Ah(n,r,m),Pr(n,r,m)):(Et&&u&&ch(r),r.flags|=1,Yi(n,r,l,m),r.child)}function px(n,r,l,u,m,g){return Fs(r),r.updateQueue=null,l=xg(r,u,l,m),gg(n),u=jh(),n!==null&&!yi?(Ah(n,r,g),Pr(n,r,g)):(Et&&u&&ch(r),r.flags|=1,Yi(n,r,l,g),r.child)}function mx(n,r,l,u,m){if(Fs(r),r.stateNode===null){var g=wa,S=l.contextType;typeof S=="object"&&S!==null&&(g=Gi(S)),g=new l(u,g),r.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Wh,r.stateNode=g,g._reactInternals=r,g=r.stateNode,g.props=u,g.state=r.memoizedState,g.refs={},vh(r),S=l.contextType,g.context=typeof S=="object"&&S!==null?Gi(S):wa,g.state=r.memoizedState,S=l.getDerivedStateFromProps,typeof S=="function"&&(qh(r,l,S,u),g.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(S=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),S!==g.state&&Wh.enqueueReplaceState(g,g.state,null),Rl(r,u,g,m),Al(),g.state=r.memoizedState),typeof g.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(n===null){g=r.stateNode;var k=r.memoizedProps,M=Vs(l,k);g.props=M;var Z=g.context,ce=l.contextType;S=wa,typeof ce=="object"&&ce!==null&&(S=Gi(ce));var fe=l.getDerivedStateFromProps;ce=typeof fe=="function"||typeof g.getSnapshotBeforeUpdate=="function",k=r.pendingProps!==k,ce||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(k||Z!==S)&&tx(r,g,u,S),ls=!1;var J=r.memoizedState;g.state=J,Rl(r,u,g,m),Al(),Z=r.memoizedState,k||J!==Z||ls?(typeof fe=="function"&&(qh(r,l,fe,u),Z=r.memoizedState),(M=ls||ex(r,l,M,u,J,Z,S))?(ce||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(r.flags|=4194308)):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=Z),g.props=u,g.state=Z,g.context=S,u=M):(typeof g.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{g=r.stateNode,yh(n,r),S=r.memoizedProps,ce=Vs(l,S),g.props=ce,fe=r.pendingProps,J=g.context,Z=l.contextType,M=wa,typeof Z=="object"&&Z!==null&&(M=Gi(Z)),k=l.getDerivedStateFromProps,(Z=typeof k=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==fe||J!==M)&&tx(r,g,u,M),ls=!1,J=r.memoizedState,g.state=J,Rl(r,u,g,m),Al();var se=r.memoizedState;S!==fe||J!==se||ls||n!==null&&n.dependencies!==null&&Jo(n.dependencies)?(typeof k=="function"&&(qh(r,l,k,u),se=r.memoizedState),(ce=ls||ex(r,l,ce,u,J,se,M)||n!==null&&n.dependencies!==null&&Jo(n.dependencies))?(Z||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(u,se,M),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(u,se,M)),typeof g.componentDidUpdate=="function"&&(r.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===n.memoizedProps&&J===n.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&J===n.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=se),g.props=u,g.state=se,g.context=M,u=ce):(typeof g.componentDidUpdate!="function"||S===n.memoizedProps&&J===n.memoizedState||(r.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===n.memoizedProps&&J===n.memoizedState||(r.flags|=1024),u=!1)}return g=u,_c(n,r),u=(r.flags&128)!==0,g||u?(g=r.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:g.render(),r.flags|=1,n!==null&&u?(r.child=Ys(r,n.child,null,m),r.child=Ys(r,null,l,m)):Yi(n,r,l,m),r.memoizedState=g.state,n=r.child):n=Pr(n,r,m),n}function gx(n,r,l,u){return Us(),r.flags|=256,Yi(n,r,l,u),r.child}var Vh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Xh(n){return{baseLanes:n,cachePool:sg()}}function Zh(n,r,l){return n=n!==null?n.childLanes&~l:0,r&&(n|=zn),n}function xx(n,r,l){var u=r.pendingProps,m=!1,g=(r.flags&128)!==0,S;if((S=g)||(S=n!==null&&n.memoizedState===null?!1:(mi.current&2)!==0),S&&(m=!0,r.flags&=-129),S=(r.flags&32)!==0,r.flags&=-33,n===null){if(Et){if(m?us(r):hs(),(n=Xt)?(n=k_(n,Qn),n=n!==null&&n.data!=="&"?n:null,n!==null&&(r.memoizedState={dehydrated:n,treeContext:ns!==null?{id:xr,overflow:_r}:null,retryLane:536870912,hydrationErrors:null},l=Xm(n),l.return=r,r.child=l,Wi=r,Xt=null)):n=null,n===null)throw ss(r);return Dd(n)?r.lanes=32:r.lanes=536870912,null}var k=u.children;return u=u.fallback,m?(hs(),m=r.mode,k=bc({mode:"hidden",children:k},m),u=Hs(u,m,l,null),k.return=r,u.return=r,k.sibling=u,r.child=k,u=r.child,u.memoizedState=Xh(l),u.childLanes=Zh(n,S,l),r.memoizedState=Vh,Ol(null,u)):(us(r),Qh(r,k))}var M=n.memoizedState;if(M!==null&&(k=M.dehydrated,k!==null)){if(g)r.flags&256?(us(r),r.flags&=-257,r=Jh(n,r,l)):r.memoizedState!==null?(hs(),r.child=n.child,r.flags|=128,r=null):(hs(),k=u.fallback,m=r.mode,u=bc({mode:"visible",children:u.children},m),k=Hs(k,m,l,null),k.flags|=2,u.return=r,k.return=r,u.sibling=k,r.child=u,Ys(r,n.child,null,l),u=r.child,u.memoizedState=Xh(l),u.childLanes=Zh(n,S,l),r.memoizedState=Vh,r=Ol(null,u));else if(us(r),Dd(k)){if(S=k.nextSibling&&k.nextSibling.dataset,S)var Z=S.dgst;S=Z,u=Error(s(419)),u.stack="",u.digest=S,Cl({value:u,source:null,stack:null}),r=Jh(n,r,l)}else if(yi||Na(n,r,l,!1),S=(l&n.childLanes)!==0,yi||S){if(S=Wt,S!==null&&(u=ee(S,l),u!==0&&u!==M.retryLane))throw M.retryLane=u,Is(n,u),Cn(S,n,u),Yh;Md(k)||Tc(),r=Jh(n,r,l)}else Md(k)?(r.flags|=192,r.child=n.child,r=null):(n=M.treeContext,Xt=er(k.nextSibling),Wi=r,Et=!0,rs=null,Qn=!1,n!==null&&Jm(r,n),r=Qh(r,u.children),r.flags|=4096);return r}return m?(hs(),k=u.fallback,m=r.mode,M=n.child,Z=M.sibling,u=Mr(M,{mode:"hidden",children:u.children}),u.subtreeFlags=M.subtreeFlags&65011712,Z!==null?k=Mr(Z,k):(k=Hs(k,m,l,null),k.flags|=2),k.return=r,u.return=r,u.sibling=k,r.child=u,Ol(null,u),u=r.child,k=n.child.memoizedState,k===null?k=Xh(l):(m=k.cachePool,m!==null?(M=bi._currentValue,m=m.parent!==M?{parent:M,pool:M}:m):m=sg(),k={baseLanes:k.baseLanes|l,cachePool:m}),u.memoizedState=k,u.childLanes=Zh(n,S,l),r.memoizedState=Vh,Ol(n.child,u)):(us(r),l=n.child,n=l.sibling,l=Mr(l,{mode:"visible",children:u.children}),l.return=r,l.sibling=null,n!==null&&(S=r.deletions,S===null?(r.deletions=[n],r.flags|=16):S.push(n)),r.child=l,r.memoizedState=null,l)}function Qh(n,r){return r=bc({mode:"visible",children:r},n.mode),r.return=n,n.child=r}function bc(n,r){return n=Dn(22,n,null,r),n.lanes=0,n}function Jh(n,r,l){return Ys(r,n.child,null,l),n=Qh(r,r.pendingProps.children),n.flags|=2,r.memoizedState=null,n}function _x(n,r,l){n.lanes|=r;var u=n.alternate;u!==null&&(u.lanes|=r),ph(n.return,r,l)}function ed(n,r,l,u,m,g){var S=n.memoizedState;S===null?n.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:m,treeForkCount:g}:(S.isBackwards=r,S.rendering=null,S.renderingStartTime=0,S.last=u,S.tail=l,S.tailMode=m,S.treeForkCount=g)}function bx(n,r,l){var u=r.pendingProps,m=u.revealOrder,g=u.tail;u=u.children;var S=mi.current,k=(S&2)!==0;if(k?(S=S&1|2,r.flags|=128):S&=1,C(mi,S),Yi(n,r,u,l),u=Et?wl:0,!k&&n!==null&&(n.flags&128)!==0)e:for(n=r.child;n!==null;){if(n.tag===13)n.memoizedState!==null&&_x(n,l,r);else if(n.tag===19)_x(n,l,r);else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===r)break e;for(;n.sibling===null;){if(n.return===null||n.return===r)break e;n=n.return}n.sibling.return=n.return,n=n.sibling}switch(m){case"forwards":for(l=r.child,m=null;l!==null;)n=l.alternate,n!==null&&lc(n)===null&&(m=l),l=l.sibling;l=m,l===null?(m=r.child,r.child=null):(m=l.sibling,l.sibling=null),ed(r,!1,m,l,g,u);break;case"backwards":case"unstable_legacy-backwards":for(l=null,m=r.child,r.child=null;m!==null;){if(n=m.alternate,n!==null&&lc(n)===null){r.child=m;break}n=m.sibling,m.sibling=l,l=m,m=n}ed(r,!0,l,null,g,u);break;case"together":ed(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function Pr(n,r,l){if(n!==null&&(r.dependencies=n.dependencies),ps|=r.lanes,(l&r.childLanes)===0)if(n!==null){if(Na(n,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(n!==null&&r.child!==n.child)throw Error(s(153));if(r.child!==null){for(n=r.child,l=Mr(n,n.pendingProps),r.child=l,l.return=r;n.sibling!==null;)n=n.sibling,l=l.sibling=Mr(n,n.pendingProps),l.return=r;l.sibling=null}return r.child}function td(n,r){return(n.lanes&r)!==0?!0:(n=n.dependencies,!!(n!==null&&Jo(n)))}function tw(n,r,l){switch(r.tag){case 3:le(r,r.stateNode.containerInfo),as(r,bi,n.memoizedState.cache),Us();break;case 27:case 5:Te(r);break;case 4:le(r,r.stateNode.containerInfo);break;case 10:as(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Eh(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(us(r),r.flags|=128,null):(l&r.child.childLanes)!==0?xx(n,r,l):(us(r),n=Pr(n,r,l),n!==null?n.sibling:null);us(r);break;case 19:var m=(n.flags&128)!==0;if(u=(l&r.childLanes)!==0,u||(Na(n,r,l,!1),u=(l&r.childLanes)!==0),m){if(u)return bx(n,r,l);r.flags|=128}if(m=r.memoizedState,m!==null&&(m.rendering=null,m.tail=null,m.lastEffect=null),C(mi,mi.current),u)break;return null;case 22:return r.lanes=0,hx(n,r,l,r.pendingProps);case 24:as(r,bi,n.memoizedState.cache)}return Pr(n,r,l)}function vx(n,r,l){if(n!==null)if(n.memoizedProps!==r.pendingProps)yi=!0;else{if(!td(n,l)&&(r.flags&128)===0)return yi=!1,tw(n,r,l);yi=(n.flags&131072)!==0}else yi=!1,Et&&(r.flags&1048576)!==0&&Qm(r,wl,r.index);switch(r.lanes=0,r.tag){case 16:e:{var u=r.pendingProps;if(n=Ws(r.elementType),r.type=n,typeof n=="function")ah(n)?(u=Vs(n,u),r.tag=1,r=mx(null,r,n,u,l)):(r.tag=0,r=Kh(null,r,n,u,l));else{if(n!=null){var m=n.$$typeof;if(m===W){r.tag=11,r=ox(null,r,n,u,l);break e}else if(m===te){r.tag=14,r=cx(null,r,n,u,l);break e}}throw r=Q(n)||n,Error(s(306,r,""))}}return r;case 0:return Kh(n,r,r.type,r.pendingProps,l);case 1:return u=r.type,m=Vs(u,r.pendingProps),mx(n,r,u,m,l);case 3:e:{if(le(r,r.stateNode.containerInfo),n===null)throw Error(s(387));u=r.pendingProps;var g=r.memoizedState;m=g.element,yh(n,r),Rl(r,u,null,l);var S=r.memoizedState;if(u=S.cache,as(r,bi,u),u!==g.cache&&mh(r,[bi],l,!0),Al(),u=S.element,g.isDehydrated)if(g={element:u,isDehydrated:!1,cache:S.cache},r.updateQueue.baseState=g,r.memoizedState=g,r.flags&256){r=gx(n,r,u,l);break e}else if(u!==m){m=Vn(Error(s(424)),r),Cl(m),r=gx(n,r,u,l);break e}else{switch(n=r.stateNode.containerInfo,n.nodeType){case 9:n=n.body;break;default:n=n.nodeName==="HTML"?n.ownerDocument.body:n}for(Xt=er(n.firstChild),Wi=r,Et=!0,rs=null,Qn=!0,l=hg(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Us(),u===m){r=Pr(n,r,l);break e}Yi(n,r,u,l)}r=r.child}return r;case 26:return _c(n,r),n===null?(l=R_(r.type,null,r.pendingProps,null))?r.memoizedState=l:Et||(l=r.type,n=r.pendingProps,u=Lc(ue.current).createElement(l),u[st]=r,u[it]=n,Ki(u,l,n),ri(u),r.stateNode=u):r.memoizedState=R_(r.type,n.memoizedProps,r.pendingProps,n.memoizedState),null;case 27:return Te(r),n===null&&Et&&(u=r.stateNode=T_(r.type,r.pendingProps,ue.current),Wi=r,Qn=!0,m=Xt,bs(r.type)?(Bd=m,Xt=er(u.firstChild)):Xt=m),Yi(n,r,r.pendingProps.children,l),_c(n,r),n===null&&(r.flags|=4194304),r.child;case 5:return n===null&&Et&&((m=u=Xt)&&(u=Rw(u,r.type,r.pendingProps,Qn),u!==null?(r.stateNode=u,Wi=r,Xt=er(u.firstChild),Qn=!1,m=!0):m=!1),m||ss(r)),Te(r),m=r.type,g=r.pendingProps,S=n!==null?n.memoizedProps:null,u=g.children,jd(m,g)?u=null:S!==null&&jd(m,S)&&(r.flags|=32),r.memoizedState!==null&&(m=Th(n,r,G1,null,null,l),Zl._currentValue=m),_c(n,r),Yi(n,r,u,l),r.child;case 6:return n===null&&Et&&((n=l=Xt)&&(l=Mw(l,r.pendingProps,Qn),l!==null?(r.stateNode=l,Wi=r,Xt=null,n=!0):n=!1),n||ss(r)),null;case 13:return xx(n,r,l);case 4:return le(r,r.stateNode.containerInfo),u=r.pendingProps,n===null?r.child=Ys(r,null,u,l):Yi(n,r,u,l),r.child;case 11:return ox(n,r,r.type,r.pendingProps,l);case 7:return Yi(n,r,r.pendingProps,l),r.child;case 8:return Yi(n,r,r.pendingProps.children,l),r.child;case 12:return Yi(n,r,r.pendingProps.children,l),r.child;case 10:return u=r.pendingProps,as(r,r.type,u.value),Yi(n,r,u.children,l),r.child;case 9:return m=r.type._context,u=r.pendingProps.children,Fs(r),m=Gi(m),u=u(m),r.flags|=1,Yi(n,r,u,l),r.child;case 14:return cx(n,r,r.type,r.pendingProps,l);case 15:return ux(n,r,r.type,r.pendingProps,l);case 19:return bx(n,r,l);case 31:return ew(n,r,l);case 22:return hx(n,r,l,r.pendingProps);case 24:return Fs(r),u=Gi(bi),n===null?(m=_h(),m===null&&(m=Wt,g=gh(),m.pooledCache=g,g.refCount++,g!==null&&(m.pooledCacheLanes|=l),m=g),r.memoizedState={parent:u,cache:m},vh(r),as(r,bi,m)):((n.lanes&l)!==0&&(yh(n,r),Rl(r,null,null,l),Al()),m=n.memoizedState,g=r.memoizedState,m.parent!==u?(m={parent:u,cache:u},r.memoizedState=m,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=m),as(r,bi,u)):(u=g.cache,as(r,bi,u),u!==m.cache&&mh(r,[bi],l,!0))),Yi(n,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(s(156,r.tag))}function Ir(n){n.flags|=4}function id(n,r,l,u,m){if((r=(n.mode&32)!==0)&&(r=!1),r){if(n.flags|=16777216,(m&335544128)===m)if(n.stateNode.complete)n.flags|=8192;else if(Yx())n.flags|=8192;else throw Gs=nc,bh}else n.flags&=-16777217}function yx(n,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)n.flags&=-16777217;else if(n.flags|=16777216,!O_(r))if(Yx())n.flags|=8192;else throw Gs=nc,bh}function vc(n,r){r!==null&&(n.flags|=4),n.flags&16384&&(r=n.tag!==22?qt():536870912,n.lanes|=r,Ia|=r)}function zl(n,r){if(!Et)switch(n.tailMode){case"hidden":r=n.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?n.tail=null:l.sibling=null;break;case"collapsed":l=n.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?r||n.tail===null?n.tail=null:n.tail.sibling=null:u.sibling=null}}function Zt(n){var r=n.alternate!==null&&n.alternate.child===n.child,l=0,u=0;if(r)for(var m=n.child;m!==null;)l|=m.lanes|m.childLanes,u|=m.subtreeFlags&65011712,u|=m.flags&65011712,m.return=n,m=m.sibling;else for(m=n.child;m!==null;)l|=m.lanes|m.childLanes,u|=m.subtreeFlags,u|=m.flags,m.return=n,m=m.sibling;return n.subtreeFlags|=u,n.childLanes=l,r}function iw(n,r,l){var u=r.pendingProps;switch(uh(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Zt(r),null;case 1:return Zt(r),null;case 3:return l=r.stateNode,u=null,n!==null&&(u=n.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),Lr(bi),be(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(n===null||n.child===null)&&(Ea(r)?Ir(r):n===null||n.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,dh())),Zt(r),null;case 26:var m=r.type,g=r.memoizedState;return n===null?(Ir(r),g!==null?(Zt(r),yx(r,g)):(Zt(r),id(r,m,null,u,l))):g?g!==n.memoizedState?(Ir(r),Zt(r),yx(r,g)):(Zt(r),r.flags&=-16777217):(n=n.memoizedProps,n!==u&&Ir(r),Zt(r),id(r,m,n,u,l)),null;case 27:if(Le(r),l=ue.current,m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Ir(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return Zt(r),null}n=K.current,Ea(r)?eg(r):(n=T_(m,u,l),r.stateNode=n,Ir(r))}return Zt(r),null;case 5:if(Le(r),m=r.type,n!==null&&r.stateNode!=null)n.memoizedProps!==u&&Ir(r);else{if(!u){if(r.stateNode===null)throw Error(s(166));return Zt(r),null}if(g=K.current,Ea(r))eg(r);else{var S=Lc(ue.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;default:switch(m){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",m);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",m);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?S.createElement("select",{is:u.is}):S.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?S.createElement(m,{is:u.is}):S.createElement(m)}}g[st]=r,g[it]=u;e:for(S=r.child;S!==null;){if(S.tag===5||S.tag===6)g.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===r)break e;for(;S.sibling===null;){if(S.return===null||S.return===r)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}r.stateNode=g;e:switch(Ki(g,m,u),m){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&Ir(r)}}return Zt(r),id(r,r.type,n===null?null:n.memoizedProps,r.pendingProps,l),null;case 6:if(n&&r.stateNode!=null)n.memoizedProps!==u&&Ir(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(s(166));if(n=ue.current,Ea(r)){if(n=r.stateNode,l=r.memoizedProps,u=null,m=Wi,m!==null)switch(m.tag){case 27:case 5:u=m.memoizedProps}n[st]=r,n=!!(n.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||x_(n.nodeValue,l)),n||ss(r,!0)}else n=Lc(n).createTextNode(u),n[st]=r,r.stateNode=n}return Zt(r),null;case 31:if(l=r.memoizedState,n===null||n.memoizedState!==null){if(u=Ea(r),l!==null){if(n===null){if(!u)throw Error(s(318));if(n=r.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(s(557));n[st]=r}else Us(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Zt(r),n=!1}else l=dh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=l),n=!0;if(!n)return r.flags&256?(Ln(r),r):(Ln(r),null);if((r.flags&128)!==0)throw Error(s(558))}return Zt(r),null;case 13:if(u=r.memoizedState,n===null||n.memoizedState!==null&&n.memoizedState.dehydrated!==null){if(m=Ea(r),u!==null&&u.dehydrated!==null){if(n===null){if(!m)throw Error(s(318));if(m=r.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(s(317));m[st]=r}else Us(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;Zt(r),m=!1}else m=dh(),n!==null&&n.memoizedState!==null&&(n.memoizedState.hydrationErrors=m),m=!0;if(!m)return r.flags&256?(Ln(r),r):(Ln(r),null)}return Ln(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,n=n!==null&&n.memoizedState!==null,l&&(u=r.child,m=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(m=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==m&&(u.flags|=2048)),l!==n&&l&&(r.child.flags|=8192),vc(r,r.updateQueue),Zt(r),null);case 4:return be(),n===null&&Cd(r.stateNode.containerInfo),Zt(r),null;case 10:return Lr(r.type),Zt(r),null;case 19:if(V(mi),u=r.memoizedState,u===null)return Zt(r),null;if(m=(r.flags&128)!==0,g=u.rendering,g===null)if(m)zl(u,!1);else{if(ui!==0||n!==null&&(n.flags&128)!==0)for(n=r.child;n!==null;){if(g=lc(n),g!==null){for(r.flags|=128,zl(u,!1),n=g.updateQueue,r.updateQueue=n,vc(r,n),r.subtreeFlags=0,n=l,l=r.child;l!==null;)Vm(l,n),l=l.sibling;return C(mi,mi.current&1|2),Et&&Dr(r,u.treeForkCount),r.child}n=n.sibling}u.tail!==null&&Ct()>kc&&(r.flags|=128,m=!0,zl(u,!1),r.lanes=4194304)}else{if(!m)if(n=lc(g),n!==null){if(r.flags|=128,m=!0,n=n.updateQueue,r.updateQueue=n,vc(r,n),zl(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!Et)return Zt(r),null}else 2*Ct()-u.renderingStartTime>kc&&l!==536870912&&(r.flags|=128,m=!0,zl(u,!1),r.lanes=4194304);u.isBackwards?(g.sibling=r.child,r.child=g):(n=u.last,n!==null?n.sibling=g:r.child=g,u.last=g)}return u.tail!==null?(n=u.tail,u.rendering=n,u.tail=n.sibling,u.renderingStartTime=Ct(),n.sibling=null,l=mi.current,C(mi,m?l&1|2:l&1),Et&&Dr(r,u.treeForkCount),n):(Zt(r),null);case 22:case 23:return Ln(r),kh(),u=r.memoizedState!==null,n!==null?n.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(Zt(r),r.subtreeFlags&6&&(r.flags|=8192)):Zt(r),l=r.updateQueue,l!==null&&vc(r,l.retryQueue),l=null,n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),n!==null&&V(qs),null;case 24:return l=null,n!==null&&(l=n.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),Lr(bi),Zt(r),null;case 25:return null;case 30:return null}throw Error(s(156,r.tag))}function nw(n,r){switch(uh(r),r.tag){case 1:return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 3:return Lr(bi),be(),n=r.flags,(n&65536)!==0&&(n&128)===0?(r.flags=n&-65537|128,r):null;case 26:case 27:case 5:return Le(r),null;case 31:if(r.memoizedState!==null){if(Ln(r),r.alternate===null)throw Error(s(340));Us()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 13:if(Ln(r),n=r.memoizedState,n!==null&&n.dehydrated!==null){if(r.alternate===null)throw Error(s(340));Us()}return n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 19:return V(mi),null;case 4:return be(),null;case 10:return Lr(r.type),null;case 22:case 23:return Ln(r),kh(),n!==null&&V(qs),n=r.flags,n&65536?(r.flags=n&-65537|128,r):null;case 24:return Lr(bi),null;case 25:return null;default:return null}}function Sx(n,r){switch(uh(r),r.tag){case 3:Lr(bi),be();break;case 26:case 27:case 5:Le(r);break;case 4:be();break;case 31:r.memoizedState!==null&&Ln(r);break;case 13:Ln(r);break;case 19:V(mi);break;case 10:Lr(r.type);break;case 22:case 23:Ln(r),kh(),n!==null&&V(qs);break;case 24:Lr(bi)}}function Pl(n,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var m=u.next;l=m;do{if((l.tag&n)===n){u=void 0;var g=l.create,S=l.inst;u=g(),S.destroy=u}l=l.next}while(l!==m)}}catch(k){Pt(r,r.return,k)}}function ds(n,r,l){try{var u=r.updateQueue,m=u!==null?u.lastEffect:null;if(m!==null){var g=m.next;u=g;do{if((u.tag&n)===n){var S=u.inst,k=S.destroy;if(k!==void 0){S.destroy=void 0,m=r;var M=l,Z=k;try{Z()}catch(ce){Pt(m,M,ce)}}}u=u.next}while(u!==g)}}catch(ce){Pt(r,r.return,ce)}}function wx(n){var r=n.updateQueue;if(r!==null){var l=n.stateNode;try{fg(r,l)}catch(u){Pt(n,n.return,u)}}}function Cx(n,r,l){l.props=Vs(n.type,n.memoizedProps),l.state=n.memoizedState;try{l.componentWillUnmount()}catch(u){Pt(n,r,u)}}function Il(n,r){try{var l=n.ref;if(l!==null){switch(n.tag){case 26:case 27:case 5:var u=n.stateNode;break;case 30:u=n.stateNode;break;default:u=n.stateNode}typeof l=="function"?n.refCleanup=l(u):l.current=u}}catch(m){Pt(n,r,m)}}function br(n,r){var l=n.ref,u=n.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(m){Pt(n,r,m)}finally{n.refCleanup=null,n=n.alternate,n!=null&&(n.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(m){Pt(n,r,m)}else l.current=null}function kx(n){var r=n.type,l=n.memoizedProps,u=n.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break e;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(m){Pt(n,n.return,m)}}function nd(n,r,l){try{var u=n.stateNode;kw(u,n.type,l,r),u[it]=r}catch(m){Pt(n,n.return,m)}}function Ex(n){return n.tag===5||n.tag===3||n.tag===26||n.tag===27&&bs(n.type)||n.tag===4}function rd(n){e:for(;;){for(;n.sibling===null;){if(n.return===null||Ex(n.return))return null;n=n.return}for(n.sibling.return=n.return,n=n.sibling;n.tag!==5&&n.tag!==6&&n.tag!==18;){if(n.tag===27&&bs(n.type)||n.flags&2||n.child===null||n.tag===4)continue e;n.child.return=n,n=n.child}if(!(n.flags&2))return n.stateNode}}function sd(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(n,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(n),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=cn));else if(u!==4&&(u===27&&bs(n.type)&&(l=n.stateNode,r=null),n=n.child,n!==null))for(sd(n,r,l),n=n.sibling;n!==null;)sd(n,r,l),n=n.sibling}function yc(n,r,l){var u=n.tag;if(u===5||u===6)n=n.stateNode,r?l.insertBefore(n,r):l.appendChild(n);else if(u!==4&&(u===27&&bs(n.type)&&(l=n.stateNode),n=n.child,n!==null))for(yc(n,r,l),n=n.sibling;n!==null;)yc(n,r,l),n=n.sibling}function Nx(n){var r=n.stateNode,l=n.memoizedProps;try{for(var u=n.type,m=r.attributes;m.length;)r.removeAttributeNode(m[0]);Ki(r,u,l),r[st]=n,r[it]=l}catch(g){Pt(n,n.return,g)}}var Hr=!1,Si=!1,ad=!1,Tx=typeof WeakSet=="function"?WeakSet:Set,Di=null;function rw(n,r){if(n=n.containerInfo,Nd=$c,n=Hm(n),Ju(n)){if("selectionStart"in n)var l={start:n.selectionStart,end:n.selectionEnd};else e:{l=(l=n.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var m=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var S=0,k=-1,M=-1,Z=0,ce=0,fe=n,J=null;t:for(;;){for(var se;fe!==l||m!==0&&fe.nodeType!==3||(k=S+m),fe!==g||u!==0&&fe.nodeType!==3||(M=S+u),fe.nodeType===3&&(S+=fe.nodeValue.length),(se=fe.firstChild)!==null;)J=fe,fe=se;for(;;){if(fe===n)break t;if(J===l&&++Z===m&&(k=S),J===g&&++ce===u&&(M=S),(se=fe.nextSibling)!==null)break;fe=J,J=fe.parentNode}fe=se}l=k===-1||M===-1?null:{start:k,end:M}}else l=null}l=l||{start:0,end:0}}else l=null;for(Td={focusedElem:n,selectionRange:l},$c=!1,Di=r;Di!==null;)if(r=Di,n=r.child,(r.subtreeFlags&1028)!==0&&n!==null)n.return=r,Di=n;else for(;Di!==null;){switch(r=Di,g=r.alternate,n=r.flags,r.tag){case 0:if((n&4)!==0&&(n=r.updateQueue,n=n!==null?n.events:null,n!==null))for(l=0;l<n.length;l++)m=n[l],m.ref.impl=m.nextImpl;break;case 11:case 15:break;case 1:if((n&1024)!==0&&g!==null){n=void 0,l=r,m=g.memoizedProps,g=g.memoizedState,u=l.stateNode;try{var De=Vs(l.type,m);n=u.getSnapshotBeforeUpdate(De,g),u.__reactInternalSnapshotBeforeUpdate=n}catch(qe){Pt(l,l.return,qe)}}break;case 3:if((n&1024)!==0){if(n=r.stateNode.containerInfo,l=n.nodeType,l===9)Rd(n);else if(l===1)switch(n.nodeName){case"HEAD":case"HTML":case"BODY":Rd(n);break;default:n.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((n&1024)!==0)throw Error(s(163))}if(n=r.sibling,n!==null){n.return=r.return,Di=n;break}Di=r.return}}function jx(n,r,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:$r(n,l),u&4&&Pl(5,l);break;case 1:if($r(n,l),u&4)if(n=l.stateNode,r===null)try{n.componentDidMount()}catch(S){Pt(l,l.return,S)}else{var m=Vs(l.type,r.memoizedProps);r=r.memoizedState;try{n.componentDidUpdate(m,r,n.__reactInternalSnapshotBeforeUpdate)}catch(S){Pt(l,l.return,S)}}u&64&&wx(l),u&512&&Il(l,l.return);break;case 3:if($r(n,l),u&64&&(n=l.updateQueue,n!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{fg(n,r)}catch(S){Pt(l,l.return,S)}}break;case 27:r===null&&u&4&&Nx(l);case 26:case 5:$r(n,l),r===null&&u&4&&kx(l),u&512&&Il(l,l.return);break;case 12:$r(n,l);break;case 31:$r(n,l),u&4&&Mx(n,l);break;case 13:$r(n,l),u&4&&Dx(n,l),u&64&&(n=l.memoizedState,n!==null&&(n=n.dehydrated,n!==null&&(l=fw.bind(null,l),Dw(n,l))));break;case 22:if(u=l.memoizedState!==null||Hr,!u){r=r!==null&&r.memoizedState!==null||Si,m=Hr;var g=Si;Hr=u,(Si=r)&&!g?Fr(n,l,(l.subtreeFlags&8772)!==0):$r(n,l),Hr=m,Si=g}break;case 30:break;default:$r(n,l)}}function Ax(n){var r=n.alternate;r!==null&&(n.alternate=null,Ax(r)),n.child=null,n.deletions=null,n.sibling=null,n.tag===5&&(r=n.stateNode,r!==null&&Fn(r)),n.stateNode=null,n.return=null,n.dependencies=null,n.memoizedProps=null,n.memoizedState=null,n.pendingProps=null,n.stateNode=null,n.updateQueue=null}var ei=null,vn=!1;function Ur(n,r,l){for(l=l.child;l!==null;)Rx(n,r,l),l=l.sibling}function Rx(n,r,l){if(We&&typeof We.onCommitFiberUnmount=="function")try{We.onCommitFiberUnmount(ct,l)}catch{}switch(l.tag){case 26:Si||br(l,r),Ur(n,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Si||br(l,r);var u=ei,m=vn;bs(l.type)&&(ei=l.stateNode,vn=!1),Ur(n,r,l),Kl(l.stateNode),ei=u,vn=m;break;case 5:Si||br(l,r);case 6:if(u=ei,m=vn,ei=null,Ur(n,r,l),ei=u,vn=m,ei!==null)if(vn)try{(ei.nodeType===9?ei.body:ei.nodeName==="HTML"?ei.ownerDocument.body:ei).removeChild(l.stateNode)}catch(g){Pt(l,r,g)}else try{ei.removeChild(l.stateNode)}catch(g){Pt(l,r,g)}break;case 18:ei!==null&&(vn?(n=ei,w_(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,l.stateNode),Ya(n)):w_(ei,l.stateNode));break;case 4:u=ei,m=vn,ei=l.stateNode.containerInfo,vn=!0,Ur(n,r,l),ei=u,vn=m;break;case 0:case 11:case 14:case 15:ds(2,l,r),Si||ds(4,l,r),Ur(n,r,l);break;case 1:Si||(br(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"&&Cx(l,r,u)),Ur(n,r,l);break;case 21:Ur(n,r,l);break;case 22:Si=(u=Si)||l.memoizedState!==null,Ur(n,r,l),Si=u;break;default:Ur(n,r,l)}}function Mx(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null))){n=n.dehydrated;try{Ya(n)}catch(l){Pt(r,r.return,l)}}}function Dx(n,r){if(r.memoizedState===null&&(n=r.alternate,n!==null&&(n=n.memoizedState,n!==null&&(n=n.dehydrated,n!==null))))try{Ya(n)}catch(l){Pt(r,r.return,l)}}function sw(n){switch(n.tag){case 31:case 13:case 19:var r=n.stateNode;return r===null&&(r=n.stateNode=new Tx),r;case 22:return n=n.stateNode,r=n._retryCache,r===null&&(r=n._retryCache=new Tx),r;default:throw Error(s(435,n.tag))}}function Sc(n,r){var l=sw(n);r.forEach(function(u){if(!l.has(u)){l.add(u);var m=pw.bind(null,n,u);u.then(m,m)}})}function yn(n,r){var l=r.deletions;if(l!==null)for(var u=0;u<l.length;u++){var m=l[u],g=n,S=r,k=S;e:for(;k!==null;){switch(k.tag){case 27:if(bs(k.type)){ei=k.stateNode,vn=!1;break e}break;case 5:ei=k.stateNode,vn=!1;break e;case 3:case 4:ei=k.stateNode.containerInfo,vn=!0;break e}k=k.return}if(ei===null)throw Error(s(160));Rx(g,S,m),ei=null,vn=!1,g=m.alternate,g!==null&&(g.return=null),m.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)Bx(r,n),r=r.sibling}var fr=null;function Bx(n,r){var l=n.alternate,u=n.flags;switch(n.tag){case 0:case 11:case 14:case 15:yn(r,n),Sn(n),u&4&&(ds(3,n,n.return),Pl(3,n),ds(5,n,n.return));break;case 1:yn(r,n),Sn(n),u&512&&(Si||l===null||br(l,l.return)),u&64&&Hr&&(n=n.updateQueue,n!==null&&(u=n.callbacks,u!==null&&(l=n.shared.hiddenCallbacks,n.shared.hiddenCallbacks=l===null?u:l.concat(u))));break;case 26:var m=fr;if(yn(r,n),Sn(n),u&512&&(Si||l===null||br(l,l.return)),u&4){var g=l!==null?l.memoizedState:null;if(u=n.memoizedState,l===null)if(u===null)if(n.stateNode===null){e:{u=n.type,l=n.memoizedProps,m=m.ownerDocument||m;t:switch(u){case"title":g=m.getElementsByTagName("title")[0],(!g||g[Fi]||g[st]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=m.createElement(u),m.head.insertBefore(g,m.querySelector("head > title"))),Ki(g,u,l),g[st]=n,ri(g),u=g;break e;case"link":var S=B_("link","href",m).get(u+(l.href||""));if(S){for(var k=0;k<S.length;k++)if(g=S[k],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){S.splice(k,1);break t}}g=m.createElement(u),Ki(g,u,l),m.head.appendChild(g);break;case"meta":if(S=B_("meta","content",m).get(u+(l.content||""))){for(k=0;k<S.length;k++)if(g=S[k],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){S.splice(k,1);break t}}g=m.createElement(u),Ki(g,u,l),m.head.appendChild(g);break;default:throw Error(s(468,u))}g[st]=n,ri(g),u=g}n.stateNode=u}else L_(m,n.type,n.stateNode);else n.stateNode=D_(m,u,n.memoizedProps);else g!==u?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,u===null?L_(m,n.type,n.stateNode):D_(m,u,n.memoizedProps)):u===null&&n.stateNode!==null&&nd(n,n.memoizedProps,l.memoizedProps)}break;case 27:yn(r,n),Sn(n),u&512&&(Si||l===null||br(l,l.return)),l!==null&&u&4&&nd(n,n.memoizedProps,l.memoizedProps);break;case 5:if(yn(r,n),Sn(n),u&512&&(Si||l===null||br(l,l.return)),n.flags&32){m=n.stateNode;try{Yn(m,"")}catch(De){Pt(n,n.return,De)}}u&4&&n.stateNode!=null&&(m=n.memoizedProps,nd(n,m,l!==null?l.memoizedProps:m)),u&1024&&(ad=!0);break;case 6:if(yn(r,n),Sn(n),u&4){if(n.stateNode===null)throw Error(s(162));u=n.memoizedProps,l=n.stateNode;try{l.nodeValue=u}catch(De){Pt(n,n.return,De)}}break;case 3:if(Pc=null,m=fr,fr=Oc(r.containerInfo),yn(r,n),fr=m,Sn(n),u&4&&l!==null&&l.memoizedState.isDehydrated)try{Ya(r.containerInfo)}catch(De){Pt(n,n.return,De)}ad&&(ad=!1,Lx(n));break;case 4:u=fr,fr=Oc(n.stateNode.containerInfo),yn(r,n),Sn(n),fr=u;break;case 12:yn(r,n),Sn(n);break;case 31:yn(r,n),Sn(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Sc(n,u)));break;case 13:yn(r,n),Sn(n),n.child.flags&8192&&n.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Cc=Ct()),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Sc(n,u)));break;case 22:m=n.memoizedState!==null;var M=l!==null&&l.memoizedState!==null,Z=Hr,ce=Si;if(Hr=Z||m,Si=ce||M,yn(r,n),Si=ce,Hr=Z,Sn(n),u&8192)e:for(r=n.stateNode,r._visibility=m?r._visibility&-2:r._visibility|1,m&&(l===null||M||Hr||Si||Xs(n)),l=null,r=n;;){if(r.tag===5||r.tag===26){if(l===null){M=l=r;try{if(g=M.stateNode,m)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{k=M.stateNode;var fe=M.memoizedProps.style,J=fe!=null&&fe.hasOwnProperty("display")?fe.display:null;k.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(De){Pt(M,M.return,De)}}}else if(r.tag===6){if(l===null){M=r;try{M.stateNode.nodeValue=m?"":M.memoizedProps}catch(De){Pt(M,M.return,De)}}}else if(r.tag===18){if(l===null){M=r;try{var se=M.stateNode;m?C_(se,!0):C_(M.stateNode,!1)}catch(De){Pt(M,M.return,De)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===n)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===n)break e;for(;r.sibling===null;){if(r.return===null||r.return===n)break e;l===r&&(l=null),r=r.return}l===r&&(l=null),r.sibling.return=r.return,r=r.sibling}u&4&&(u=n.updateQueue,u!==null&&(l=u.retryQueue,l!==null&&(u.retryQueue=null,Sc(n,l))));break;case 19:yn(r,n),Sn(n),u&4&&(u=n.updateQueue,u!==null&&(n.updateQueue=null,Sc(n,u)));break;case 30:break;case 21:break;default:yn(r,n),Sn(n)}}function Sn(n){var r=n.flags;if(r&2){try{for(var l,u=n.return;u!==null;){if(Ex(u)){l=u;break}u=u.return}if(l==null)throw Error(s(160));switch(l.tag){case 27:var m=l.stateNode,g=rd(n);yc(n,g,m);break;case 5:var S=l.stateNode;l.flags&32&&(Yn(S,""),l.flags&=-33);var k=rd(n);yc(n,k,S);break;case 3:case 4:var M=l.stateNode.containerInfo,Z=rd(n);sd(n,Z,M);break;default:throw Error(s(161))}}catch(ce){Pt(n,n.return,ce)}n.flags&=-3}r&4096&&(n.flags&=-4097)}function Lx(n){if(n.subtreeFlags&1024)for(n=n.child;n!==null;){var r=n;Lx(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),n=n.sibling}}function $r(n,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)jx(n,r.alternate,r),r=r.sibling}function Xs(n){for(n=n.child;n!==null;){var r=n;switch(r.tag){case 0:case 11:case 14:case 15:ds(4,r,r.return),Xs(r);break;case 1:br(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&Cx(r,r.return,l),Xs(r);break;case 27:Kl(r.stateNode);case 26:case 5:br(r,r.return),Xs(r);break;case 22:r.memoizedState===null&&Xs(r);break;case 30:Xs(r);break;default:Xs(r)}n=n.sibling}}function Fr(n,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,m=n,g=r,S=g.flags;switch(g.tag){case 0:case 11:case 15:Fr(m,g,l),Pl(4,g);break;case 1:if(Fr(m,g,l),u=g,m=u.stateNode,typeof m.componentDidMount=="function")try{m.componentDidMount()}catch(Z){Pt(u,u.return,Z)}if(u=g,m=u.updateQueue,m!==null){var k=u.stateNode;try{var M=m.shared.hiddenCallbacks;if(M!==null)for(m.shared.hiddenCallbacks=null,m=0;m<M.length;m++)dg(M[m],k)}catch(Z){Pt(u,u.return,Z)}}l&&S&64&&wx(g),Il(g,g.return);break;case 27:Nx(g);case 26:case 5:Fr(m,g,l),l&&u===null&&S&4&&kx(g),Il(g,g.return);break;case 12:Fr(m,g,l);break;case 31:Fr(m,g,l),l&&S&4&&Mx(m,g);break;case 13:Fr(m,g,l),l&&S&4&&Dx(m,g);break;case 22:g.memoizedState===null&&Fr(m,g,l),Il(g,g.return);break;case 30:break;default:Fr(m,g,l)}r=r.sibling}}function ld(n,r){var l=null;n!==null&&n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(l=n.memoizedState.cachePool.pool),n=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(n=r.memoizedState.cachePool.pool),n!==l&&(n!=null&&n.refCount++,l!=null&&kl(l))}function od(n,r){n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&kl(n))}function pr(n,r,l,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Ox(n,r,l,u),r=r.sibling}function Ox(n,r,l,u){var m=r.flags;switch(r.tag){case 0:case 11:case 15:pr(n,r,l,u),m&2048&&Pl(9,r);break;case 1:pr(n,r,l,u);break;case 3:pr(n,r,l,u),m&2048&&(n=null,r.alternate!==null&&(n=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==n&&(r.refCount++,n!=null&&kl(n)));break;case 12:if(m&2048){pr(n,r,l,u),n=r.stateNode;try{var g=r.memoizedProps,S=g.id,k=g.onPostCommit;typeof k=="function"&&k(S,r.alternate===null?"mount":"update",n.passiveEffectDuration,-0)}catch(M){Pt(r,r.return,M)}}else pr(n,r,l,u);break;case 31:pr(n,r,l,u);break;case 13:pr(n,r,l,u);break;case 23:break;case 22:g=r.stateNode,S=r.alternate,r.memoizedState!==null?g._visibility&2?pr(n,r,l,u):Hl(n,r):g._visibility&2?pr(n,r,l,u):(g._visibility|=2,Oa(n,r,l,u,(r.subtreeFlags&10256)!==0||!1)),m&2048&&ld(S,r);break;case 24:pr(n,r,l,u),m&2048&&od(r.alternate,r);break;default:pr(n,r,l,u)}}function Oa(n,r,l,u,m){for(m=m&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var g=n,S=r,k=l,M=u,Z=S.flags;switch(S.tag){case 0:case 11:case 15:Oa(g,S,k,M,m),Pl(8,S);break;case 23:break;case 22:var ce=S.stateNode;S.memoizedState!==null?ce._visibility&2?Oa(g,S,k,M,m):Hl(g,S):(ce._visibility|=2,Oa(g,S,k,M,m)),m&&Z&2048&&ld(S.alternate,S);break;case 24:Oa(g,S,k,M,m),m&&Z&2048&&od(S.alternate,S);break;default:Oa(g,S,k,M,m)}r=r.sibling}}function Hl(n,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=n,u=r,m=u.flags;switch(u.tag){case 22:Hl(l,u),m&2048&&ld(u.alternate,u);break;case 24:Hl(l,u),m&2048&&od(u.alternate,u);break;default:Hl(l,u)}r=r.sibling}}var Ul=8192;function za(n,r,l){if(n.subtreeFlags&Ul)for(n=n.child;n!==null;)zx(n,r,l),n=n.sibling}function zx(n,r,l){switch(n.tag){case 26:za(n,r,l),n.flags&Ul&&n.memoizedState!==null&&Ww(l,fr,n.memoizedState,n.memoizedProps);break;case 5:za(n,r,l);break;case 3:case 4:var u=fr;fr=Oc(n.stateNode.containerInfo),za(n,r,l),fr=u;break;case 22:n.memoizedState===null&&(u=n.alternate,u!==null&&u.memoizedState!==null?(u=Ul,Ul=16777216,za(n,r,l),Ul=u):za(n,r,l));break;default:za(n,r,l)}}function Px(n){var r=n.alternate;if(r!==null&&(n=r.child,n!==null)){r.child=null;do r=n.sibling,n.sibling=null,n=r;while(n!==null)}}function $l(n){var r=n.deletions;if((n.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var u=r[l];Di=u,Hx(u,n)}Px(n)}if(n.subtreeFlags&10256)for(n=n.child;n!==null;)Ix(n),n=n.sibling}function Ix(n){switch(n.tag){case 0:case 11:case 15:$l(n),n.flags&2048&&ds(9,n,n.return);break;case 3:$l(n);break;case 12:$l(n);break;case 22:var r=n.stateNode;n.memoizedState!==null&&r._visibility&2&&(n.return===null||n.return.tag!==13)?(r._visibility&=-3,wc(n)):$l(n);break;default:$l(n)}}function wc(n){var r=n.deletions;if((n.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var u=r[l];Di=u,Hx(u,n)}Px(n)}for(n=n.child;n!==null;){switch(r=n,r.tag){case 0:case 11:case 15:ds(8,r,r.return),wc(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,wc(r));break;default:wc(r)}n=n.sibling}}function Hx(n,r){for(;Di!==null;){var l=Di;switch(l.tag){case 0:case 11:case 15:ds(8,l,r);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var u=l.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:kl(l.memoizedState.cache)}if(u=l.child,u!==null)u.return=l,Di=u;else e:for(l=n;Di!==null;){u=Di;var m=u.sibling,g=u.return;if(Ax(u),u===l){Di=null;break e}if(m!==null){m.return=g,Di=m;break e}Di=g}}}var aw={getCacheForType:function(n){var r=Gi(bi),l=r.data.get(n);return l===void 0&&(l=n(),r.data.set(n,l)),l},cacheSignal:function(){return Gi(bi).controller.signal}},lw=typeof WeakMap=="function"?WeakMap:Map,Dt=0,Wt=null,gt=null,yt=0,zt=0,On=null,fs=!1,Pa=!1,cd=!1,qr=0,ui=0,ps=0,Zs=0,ud=0,zn=0,Ia=0,Fl=null,wn=null,hd=!1,Cc=0,Ux=0,kc=1/0,Ec=null,ms=null,Ni=0,gs=null,Ha=null,Wr=0,dd=0,fd=null,$x=null,ql=0,pd=null;function Pn(){return(Dt&2)!==0&&yt!==0?yt&-yt:A.T!==null?vd():ut()}function Fx(){if(zn===0)if((yt&536870912)===0||Et){var n=je;je<<=1,(je&3932160)===0&&(je=262144),zn=n}else zn=536870912;return n=Bn.current,n!==null&&(n.flags|=32),zn}function Cn(n,r,l){(n===Wt&&(zt===2||zt===9)||n.cancelPendingCommit!==null)&&(Ua(n,0),xs(n,yt,zn,!1)),oe(n,l),((Dt&2)===0||n!==Wt)&&(n===Wt&&((Dt&2)===0&&(Zs|=l),ui===4&&xs(n,yt,zn,!1)),vr(n))}function qx(n,r,l){if((Dt&6)!==0)throw Error(s(327));var u=!l&&(r&127)===0&&(r&n.expiredLanes)===0||Qe(n,r),m=u?uw(n,r):gd(n,r,!0),g=u;do{if(m===0){Pa&&!u&&xs(n,r,0,!1);break}else{if(l=n.current.alternate,g&&!ow(l)){m=gd(n,r,!1),g=!1;continue}if(m===2){if(g=r,n.errorRecoveryDisabledLanes&g)var S=0;else S=n.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){r=S;e:{var k=n;m=Fl;var M=k.current.memoizedState.isDehydrated;if(M&&(Ua(k,S).flags|=256),S=gd(k,S,!1),S!==2){if(cd&&!M){k.errorRecoveryDisabledLanes|=g,Zs|=g,m=4;break e}g=wn,wn=m,g!==null&&(wn===null?wn=g:wn.push.apply(wn,g))}m=S}if(g=!1,m!==2)continue}}if(m===1){Ua(n,0),xs(n,r,0,!0);break}e:{switch(u=n,g=m,g){case 0:case 1:throw Error(s(345));case 4:if((r&4194048)!==r)break;case 6:xs(u,r,zn,!fs);break e;case 2:wn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((r&62914560)===r&&(m=Cc+300-Ct(),10<m)){if(xs(u,r,zn,!fs),mt(u,0,!0)!==0)break e;Wr=r,u.timeoutHandle=y_(Wx.bind(null,u,l,wn,Ec,hd,r,zn,Zs,Ia,fs,g,"Throttled",-0,0),m);break e}Wx(u,l,wn,Ec,hd,r,zn,Zs,Ia,fs,g,null,-0,0)}}break}while(!0);vr(n)}function Wx(n,r,l,u,m,g,S,k,M,Z,ce,fe,J,se){if(n.timeoutHandle=-1,fe=r.subtreeFlags,fe&8192||(fe&16785408)===16785408){fe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:cn},zx(r,g,fe);var De=(g&62914560)===g?Cc-Ct():(g&4194048)===g?Ux-Ct():0;if(De=Gw(fe,De),De!==null){Wr=g,n.cancelPendingCommit=De(Jx.bind(null,n,r,g,l,u,m,S,k,M,ce,fe,null,J,se)),xs(n,g,S,!Z);return}}Jx(n,r,g,l,u,m,S,k,M)}function ow(n){for(var r=n;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var u=0;u<l.length;u++){var m=l[u],g=m.getSnapshot;m=m.value;try{if(!Mn(g(),m))return!1}catch{return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===n)break;for(;r.sibling===null;){if(r.return===null||r.return===n)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function xs(n,r,l,u){r&=~ud,r&=~Zs,n.suspendedLanes|=r,n.pingedLanes&=~r,u&&(n.warmLanes|=r),u=n.expirationTimes;for(var m=r;0<m;){var g=31-pt(m),S=1<<g;u[g]=-1,m&=~S}l!==0&&Ue(n,l,r)}function Nc(){return(Dt&6)===0?(Wl(0),!1):!0}function md(){if(gt!==null){if(zt===0)var n=gt.return;else n=gt,Br=$s=null,Rh(n),Ra=null,Nl=0,n=gt;for(;n!==null;)Sx(n.alternate,n),n=n.return;gt=null}}function Ua(n,r){var l=n.timeoutHandle;l!==-1&&(n.timeoutHandle=-1,Tw(l)),l=n.cancelPendingCommit,l!==null&&(n.cancelPendingCommit=null,l()),Wr=0,md(),Wt=n,gt=l=Mr(n.current,null),yt=r,zt=0,On=null,fs=!1,Pa=Qe(n,r),cd=!1,Ia=zn=ud=Zs=ps=ui=0,wn=Fl=null,hd=!1,(r&8)!==0&&(r|=r&32);var u=n.entangledLanes;if(u!==0)for(n=n.entanglements,u&=r;0<u;){var m=31-pt(u),g=1<<m;r|=n[m],u&=~g}return qr=r,Ko(),l}function Gx(n,r){nt=null,A.H=Ll,r===Aa||r===ic?(r=og(),zt=3):r===bh?(r=og(),zt=4):zt=r===Yh?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,On=r,gt===null&&(ui=1,gc(n,Vn(r,n.current)))}function Yx(){var n=Bn.current;return n===null?!0:(yt&4194048)===yt?Jn===null:(yt&62914560)===yt||(yt&536870912)!==0?n===Jn:!1}function Kx(){var n=A.H;return A.H=Ll,n===null?Ll:n}function Vx(){var n=A.A;return A.A=aw,n}function Tc(){ui=4,fs||(yt&4194048)!==yt&&Bn.current!==null||(Pa=!0),(ps&134217727)===0&&(Zs&134217727)===0||Wt===null||xs(Wt,yt,zn,!1)}function gd(n,r,l){var u=Dt;Dt|=2;var m=Kx(),g=Vx();(Wt!==n||yt!==r)&&(Ec=null,Ua(n,r)),r=!1;var S=ui;e:do try{if(zt!==0&&gt!==null){var k=gt,M=On;switch(zt){case 8:md(),S=6;break e;case 3:case 2:case 9:case 6:Bn.current===null&&(r=!0);var Z=zt;if(zt=0,On=null,$a(n,k,M,Z),l&&Pa){S=0;break e}break;default:Z=zt,zt=0,On=null,$a(n,k,M,Z)}}cw(),S=ui;break}catch(ce){Gx(n,ce)}while(!0);return r&&n.shellSuspendCounter++,Br=$s=null,Dt=u,A.H=m,A.A=g,gt===null&&(Wt=null,yt=0,Ko()),S}function cw(){for(;gt!==null;)Xx(gt)}function uw(n,r){var l=Dt;Dt|=2;var u=Kx(),m=Vx();Wt!==n||yt!==r?(Ec=null,kc=Ct()+500,Ua(n,r)):Pa=Qe(n,r);e:do try{if(zt!==0&&gt!==null){r=gt;var g=On;t:switch(zt){case 1:zt=0,On=null,$a(n,r,g,1);break;case 2:case 9:if(ag(g)){zt=0,On=null,Zx(r);break}r=function(){zt!==2&&zt!==9||Wt!==n||(zt=7),vr(n)},g.then(r,r);break e;case 3:zt=7;break e;case 4:zt=5;break e;case 7:ag(g)?(zt=0,On=null,Zx(r)):(zt=0,On=null,$a(n,r,g,7));break;case 5:var S=null;switch(gt.tag){case 26:S=gt.memoizedState;case 5:case 27:var k=gt;if(S?O_(S):k.stateNode.complete){zt=0,On=null;var M=k.sibling;if(M!==null)gt=M;else{var Z=k.return;Z!==null?(gt=Z,jc(Z)):gt=null}break t}}zt=0,On=null,$a(n,r,g,5);break;case 6:zt=0,On=null,$a(n,r,g,6);break;case 8:md(),ui=6;break e;default:throw Error(s(462))}}hw();break}catch(ce){Gx(n,ce)}while(!0);return Br=$s=null,A.H=u,A.A=m,Dt=l,gt!==null?0:(Wt=null,yt=0,Ko(),ui)}function hw(){for(;gt!==null&&!Ae();)Xx(gt)}function Xx(n){var r=vx(n.alternate,n,qr);n.memoizedProps=n.pendingProps,r===null?jc(n):gt=r}function Zx(n){var r=n,l=r.alternate;switch(r.tag){case 15:case 0:r=px(l,r,r.pendingProps,r.type,void 0,yt);break;case 11:r=px(l,r,r.pendingProps,r.type.render,r.ref,yt);break;case 5:Rh(r);default:Sx(l,r),r=gt=Vm(r,qr),r=vx(l,r,qr)}n.memoizedProps=n.pendingProps,r===null?jc(n):gt=r}function $a(n,r,l,u){Br=$s=null,Rh(r),Ra=null,Nl=0;var m=r.return;try{if(J1(n,m,r,l,yt)){ui=1,gc(n,Vn(l,n.current)),gt=null;return}}catch(g){if(m!==null)throw gt=m,g;ui=1,gc(n,Vn(l,n.current)),gt=null;return}r.flags&32768?(Et||u===1?n=!0:Pa||(yt&536870912)!==0?n=!1:(fs=n=!0,(u===2||u===9||u===3||u===6)&&(u=Bn.current,u!==null&&u.tag===13&&(u.flags|=16384))),Qx(r,n)):jc(r)}function jc(n){var r=n;do{if((r.flags&32768)!==0){Qx(r,fs);return}n=r.return;var l=iw(r.alternate,r,qr);if(l!==null){gt=l;return}if(r=r.sibling,r!==null){gt=r;return}gt=r=n}while(r!==null);ui===0&&(ui=5)}function Qx(n,r){do{var l=nw(n.alternate,n);if(l!==null){l.flags&=32767,gt=l;return}if(l=n.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(n=n.sibling,n!==null)){gt=n;return}gt=n=l}while(n!==null);ui=6,gt=null}function Jx(n,r,l,u,m,g,S,k,M){n.cancelPendingCommit=null;do Ac();while(Ni!==0);if((Dt&6)!==0)throw Error(s(327));if(r!==null){if(r===n.current)throw Error(s(177));if(g=r.lanes|r.childLanes,g|=rh,Ee(n,l,g,S,k,M),n===Wt&&(gt=Wt=null,yt=0),Ha=r,gs=n,Wr=l,dd=g,fd=m,$x=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(n.callbackNode=null,n.callbackPriority=0,mw(Be,function(){return r_(),null})):(n.callbackNode=null,n.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=A.T,A.T=null,m=B.p,B.p=2,S=Dt,Dt|=4;try{rw(n,r,l)}finally{Dt=S,B.p=m,A.T=u}}Ni=1,e_(),t_(),i_()}}function e_(){if(Ni===1){Ni=0;var n=gs,r=Ha,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=A.T,A.T=null;var u=B.p;B.p=2;var m=Dt;Dt|=4;try{Bx(r,n);var g=Td,S=Hm(n.containerInfo),k=g.focusedElem,M=g.selectionRange;if(S!==k&&k&&k.ownerDocument&&Im(k.ownerDocument.documentElement,k)){if(M!==null&&Ju(k)){var Z=M.start,ce=M.end;if(ce===void 0&&(ce=Z),"selectionStart"in k)k.selectionStart=Z,k.selectionEnd=Math.min(ce,k.value.length);else{var fe=k.ownerDocument||document,J=fe&&fe.defaultView||window;if(J.getSelection){var se=J.getSelection(),De=k.textContent.length,qe=Math.min(M.start,De),$t=M.end===void 0?qe:Math.min(M.end,De);!se.extend&&qe>$t&&(S=$t,$t=qe,qe=S);var F=Pm(k,qe),L=Pm(k,$t);if(F&&L&&(se.rangeCount!==1||se.anchorNode!==F.node||se.anchorOffset!==F.offset||se.focusNode!==L.node||se.focusOffset!==L.offset)){var X=fe.createRange();X.setStart(F.node,F.offset),se.removeAllRanges(),qe>$t?(se.addRange(X),se.extend(L.node,L.offset)):(X.setEnd(L.node,L.offset),se.addRange(X))}}}}for(fe=[],se=k;se=se.parentNode;)se.nodeType===1&&fe.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;k<fe.length;k++){var he=fe[k];he.element.scrollLeft=he.left,he.element.scrollTop=he.top}}$c=!!Nd,Td=Nd=null}finally{Dt=m,B.p=u,A.T=l}}n.current=r,Ni=2}}function t_(){if(Ni===2){Ni=0;var n=gs,r=Ha,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=A.T,A.T=null;var u=B.p;B.p=2;var m=Dt;Dt|=4;try{jx(n,r.alternate,r)}finally{Dt=m,B.p=u,A.T=l}}Ni=3}}function i_(){if(Ni===4||Ni===3){Ni=0,ii();var n=gs,r=Ha,l=Wr,u=$x;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?Ni=5:(Ni=0,Ha=gs=null,n_(n,n.pendingLanes));var m=n.pendingLanes;if(m===0&&(ms=null),Ce(l),r=r.stateNode,We&&typeof We.onCommitFiberRoot=="function")try{We.onCommitFiberRoot(ct,r,void 0,(r.current.flags&128)===128)}catch{}if(u!==null){r=A.T,m=B.p,B.p=2,A.T=null;try{for(var g=n.onRecoverableError,S=0;S<u.length;S++){var k=u[S];g(k.value,{componentStack:k.stack})}}finally{A.T=r,B.p=m}}(Wr&3)!==0&&Ac(),vr(n),m=n.pendingLanes,(l&261930)!==0&&(m&42)!==0?n===pd?ql++:(ql=0,pd=n):ql=0,Wl(0)}}function n_(n,r){(n.pooledCacheLanes&=r)===0&&(r=n.pooledCache,r!=null&&(n.pooledCache=null,kl(r)))}function Ac(){return e_(),t_(),i_(),r_()}function r_(){if(Ni!==5)return!1;var n=gs,r=dd;dd=0;var l=Ce(Wr),u=A.T,m=B.p;try{B.p=32>l?32:l,A.T=null,l=fd,fd=null;var g=gs,S=Wr;if(Ni=0,Ha=gs=null,Wr=0,(Dt&6)!==0)throw Error(s(331));var k=Dt;if(Dt|=4,Ix(g.current),Ox(g,g.current,S,l),Dt=k,Wl(0,!1),We&&typeof We.onPostCommitFiberRoot=="function")try{We.onPostCommitFiberRoot(ct,g)}catch{}return!0}finally{B.p=m,A.T=u,n_(n,r)}}function s_(n,r,l){r=Vn(l,r),r=Gh(n.stateNode,r,2),n=cs(n,r,2),n!==null&&(oe(n,2),vr(n))}function Pt(n,r,l){if(n.tag===3)s_(n,n,l);else for(;r!==null;){if(r.tag===3){s_(r,n,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(ms===null||!ms.has(u))){n=Vn(l,n),l=ax(2),u=cs(r,l,2),u!==null&&(lx(l,u,r,n),oe(u,2),vr(u));break}}r=r.return}}function xd(n,r,l){var u=n.pingCache;if(u===null){u=n.pingCache=new lw;var m=new Set;u.set(r,m)}else m=u.get(r),m===void 0&&(m=new Set,u.set(r,m));m.has(l)||(cd=!0,m.add(l),n=dw.bind(null,n,r,l),r.then(n,n))}function dw(n,r,l){var u=n.pingCache;u!==null&&u.delete(r),n.pingedLanes|=n.suspendedLanes&l,n.warmLanes&=~l,Wt===n&&(yt&l)===l&&(ui===4||ui===3&&(yt&62914560)===yt&&300>Ct()-Cc?(Dt&2)===0&&Ua(n,0):ud|=l,Ia===yt&&(Ia=0)),vr(n)}function a_(n,r){r===0&&(r=qt()),n=Is(n,r),n!==null&&(oe(n,r),vr(n))}function fw(n){var r=n.memoizedState,l=0;r!==null&&(l=r.retryLane),a_(n,l)}function pw(n,r){var l=0;switch(n.tag){case 31:case 13:var u=n.stateNode,m=n.memoizedState;m!==null&&(l=m.retryLane);break;case 19:u=n.stateNode;break;case 22:u=n.stateNode._retryCache;break;default:throw Error(s(314))}u!==null&&u.delete(r),a_(n,l)}function mw(n,r){return Je(n,r)}var Rc=null,Fa=null,_d=!1,Mc=!1,bd=!1,_s=0;function vr(n){n!==Fa&&n.next===null&&(Fa===null?Rc=Fa=n:Fa=Fa.next=n),Mc=!0,_d||(_d=!0,xw())}function Wl(n,r){if(!bd&&Mc){bd=!0;do for(var l=!1,u=Rc;u!==null;){if(n!==0){var m=u.pendingLanes;if(m===0)var g=0;else{var S=u.suspendedLanes,k=u.pingedLanes;g=(1<<31-pt(42|n)+1)-1,g&=m&~(S&~k),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,u_(u,g))}else g=yt,g=mt(u,u===Wt?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||Qe(u,g)||(l=!0,u_(u,g));u=u.next}while(l);bd=!1}}function gw(){l_()}function l_(){Mc=_d=!1;var n=0;_s!==0&&Nw()&&(n=_s);for(var r=Ct(),l=null,u=Rc;u!==null;){var m=u.next,g=o_(u,r);g===0?(u.next=null,l===null?Rc=m:l.next=m,m===null&&(Fa=l)):(l=u,(n!==0||(g&3)!==0)&&(Mc=!0)),u=m}Ni!==0&&Ni!==5||Wl(n),_s!==0&&(_s=0)}function o_(n,r){for(var l=n.suspendedLanes,u=n.pingedLanes,m=n.expirationTimes,g=n.pendingLanes&-62914561;0<g;){var S=31-pt(g),k=1<<S,M=m[S];M===-1?((k&l)===0||(k&u)!==0)&&(m[S]=Tt(k,r)):M<=r&&(n.expiredLanes|=k),g&=~k}if(r=Wt,l=yt,l=mt(n,n===r?l:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u=n.callbackNode,l===0||n===r&&(zt===2||zt===9)||n.cancelPendingCommit!==null)return u!==null&&u!==null&&It(u),n.callbackNode=null,n.callbackPriority=0;if((l&3)===0||Qe(n,l)){if(r=l&-l,r===n.callbackPriority)return r;switch(u!==null&&It(u),Ce(l)){case 2:case 8:l=xe;break;case 32:l=Be;break;case 268435456:l=Ge;break;default:l=Be}return u=c_.bind(null,n),l=Je(l,u),n.callbackPriority=r,n.callbackNode=l,r}return u!==null&&u!==null&&It(u),n.callbackPriority=2,n.callbackNode=null,2}function c_(n,r){if(Ni!==0&&Ni!==5)return n.callbackNode=null,n.callbackPriority=0,null;var l=n.callbackNode;if(Ac()&&n.callbackNode!==l)return null;var u=yt;return u=mt(n,n===Wt?u:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),u===0?null:(qx(n,u,r),o_(n,Ct()),n.callbackNode!=null&&n.callbackNode===l?c_.bind(null,n):null)}function u_(n,r){if(Ac())return null;qx(n,r,!0)}function xw(){jw(function(){(Dt&6)!==0?Je(ne,gw):l_()})}function vd(){if(_s===0){var n=Ta;n===0&&(n=Pe,Pe<<=1,(Pe&261888)===0&&(Pe=256)),_s=n}return _s}function h_(n){return n==null||typeof n=="symbol"||typeof n=="boolean"?null:typeof n=="function"?n:_a(""+n)}function d_(n,r){var l=r.ownerDocument.createElement("input");return l.name=r.name,l.value=r.value,n.id&&l.setAttribute("form",n.id),r.parentNode.insertBefore(l,r),n=new FormData(n),l.parentNode.removeChild(l),n}function _w(n,r,l,u,m){if(r==="submit"&&l&&l.stateNode===m){var g=h_((m[it]||null).action),S=u.submitter;S&&(r=(r=S[it]||null)?h_(r.formAction):S.getAttribute("formAction"),r!==null&&(g=r,S=null));var k=new qo("action","action",null,u,m);n.push({event:k,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(_s!==0){var M=S?d_(m,S):new FormData(m);Hh(l,{pending:!0,data:M,method:m.method,action:g},null,M)}}else typeof g=="function"&&(k.preventDefault(),M=S?d_(m,S):new FormData(m),Hh(l,{pending:!0,data:M,method:m.method,action:g},g,M))},currentTarget:m}]})}}for(var yd=0;yd<nh.length;yd++){var Sd=nh[yd],bw=Sd.toLowerCase(),vw=Sd[0].toUpperCase()+Sd.slice(1);dr(bw,"on"+vw)}dr(Fm,"onAnimationEnd"),dr(qm,"onAnimationIteration"),dr(Wm,"onAnimationStart"),dr("dblclick","onDoubleClick"),dr("focusin","onFocus"),dr("focusout","onBlur"),dr(O1,"onTransitionRun"),dr(z1,"onTransitionStart"),dr(P1,"onTransitionCancel"),dr(Gm,"onTransitionEnd"),An("onMouseEnter",["mouseout","mouseover"]),An("onMouseLeave",["mouseout","mouseover"]),An("onPointerEnter",["pointerout","pointerover"]),An("onPointerLeave",["pointerout","pointerover"]),ln("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ln("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ln("onBeforeInput",["compositionend","keypress","textInput","paste"]),ln("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ln("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ln("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Gl="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(" "),yw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Gl));function f_(n,r){r=(r&4)!==0;for(var l=0;l<n.length;l++){var u=n[l],m=u.event;u=u.listeners;e:{var g=void 0;if(r)for(var S=u.length-1;0<=S;S--){var k=u[S],M=k.instance,Z=k.currentTarget;if(k=k.listener,M!==g&&m.isPropagationStopped())break e;g=k,m.currentTarget=Z;try{g(m)}catch(ce){Yo(ce)}m.currentTarget=null,g=M}else for(S=0;S<u.length;S++){if(k=u[S],M=k.instance,Z=k.currentTarget,k=k.listener,M!==g&&m.isPropagationStopped())break e;g=k,m.currentTarget=Z;try{g(m)}catch(ce){Yo(ce)}m.currentTarget=null,g=M}}}}function xt(n,r){var l=r[ht];l===void 0&&(l=r[ht]=new Set);var u=n+"__bubble";l.has(u)||(p_(r,n,2,!1),l.add(u))}function wd(n,r,l){var u=0;r&&(u|=4),p_(l,n,u,r)}var Dc="_reactListening"+Math.random().toString(36).slice(2);function Cd(n){if(!n[Dc]){n[Dc]=!0,Vt.forEach(function(l){l!=="selectionchange"&&(yw.has(l)||wd(l,!1,n),wd(l,!0,n))});var r=n.nodeType===9?n:n.ownerDocument;r===null||r[Dc]||(r[Dc]=!0,wd("selectionchange",!1,r))}}function p_(n,r,l,u){switch(F_(r)){case 2:var m=Vw;break;case 8:m=Xw;break;default:m=Id}l=m.bind(null,r,l,n),m=void 0,!_i||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(m=!0),u?m!==void 0?n.addEventListener(r,l,{capture:!0,passive:m}):n.addEventListener(r,l,!0):m!==void 0?n.addEventListener(r,l,{passive:m}):n.addEventListener(r,l,!1)}function kd(n,r,l,u,m){var g=u;if((r&1)===0&&(r&2)===0&&u!==null)e:for(;;){if(u===null)return;var S=u.tag;if(S===3||S===4){var k=u.stateNode.containerInfo;if(k===m)break;if(S===4)for(S=u.return;S!==null;){var M=S.tag;if((M===3||M===4)&&S.stateNode.containerInfo===m)return;S=S.return}for(;k!==null;){if(S=qi(k),S===null)return;if(M=S.tag,M===5||M===6||M===26||M===27){u=g=S;continue e}k=k.parentNode}}u=u.return}Ne(function(){var Z=g,ce=ml(l),fe=[];e:{var J=Ym.get(n);if(J!==void 0){var se=qo,De=n;switch(n){case"keypress":if($o(l)===0)break e;case"keydown":case"keyup":se=p1;break;case"focusin":De="focus",se=Ku;break;case"focusout":De="blur",se=Ku;break;case"beforeblur":case"afterblur":se=Ku;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":se=Sm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":se=i1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":se=x1;break;case Fm:case qm:case Wm:se=s1;break;case Gm:se=b1;break;case"scroll":case"scrollend":se=e1;break;case"wheel":se=y1;break;case"copy":case"cut":case"paste":se=l1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":se=Cm;break;case"toggle":case"beforetoggle":se=w1}var qe=(r&4)!==0,$t=!qe&&(n==="scroll"||n==="scrollend"),F=qe?J!==null?J+"Capture":null:J;qe=[];for(var L=Z,X;L!==null;){var he=L;if(X=he.stateNode,he=he.tag,he!==5&&he!==26&&he!==27||X===null||F===null||(he=Ze(L,F),he!=null&&qe.push(Yl(L,he,X))),$t)break;L=L.return}0<qe.length&&(J=new se(J,De,null,l,ce),fe.push({event:J,listeners:qe}))}}if((r&7)===0){e:{if(J=n==="mouseover"||n==="pointerover",se=n==="mouseout"||n==="pointerout",J&&l!==is&&(De=l.relatedTarget||l.fromElement)&&(qi(De)||De[kt]))break e;if((se||J)&&(J=ce.window===ce?ce:(J=ce.ownerDocument)?J.defaultView||J.parentWindow:window,se?(De=l.relatedTarget||l.toElement,se=Z,De=De?qi(De):null,De!==null&&($t=o(De),qe=De.tag,De!==$t||qe!==5&&qe!==27&&qe!==6)&&(De=null)):(se=null,De=Z),se!==De)){if(qe=Sm,he="onMouseLeave",F="onMouseEnter",L="mouse",(n==="pointerout"||n==="pointerover")&&(qe=Cm,he="onPointerLeave",F="onPointerEnter",L="pointer"),$t=se==null?J:jn(se),X=De==null?J:jn(De),J=new qe(he,L+"leave",se,l,ce),J.target=$t,J.relatedTarget=X,he=null,qi(ce)===Z&&(qe=new qe(F,L+"enter",De,l,ce),qe.target=X,qe.relatedTarget=$t,he=qe),$t=he,se&&De)t:{for(qe=Sw,F=se,L=De,X=0,he=F;he;he=qe(he))X++;he=0;for(var He=L;He;He=qe(He))he++;for(;0<X-he;)F=qe(F),X--;for(;0<he-X;)L=qe(L),he--;for(;X--;){if(F===L||L!==null&&F===L.alternate){qe=F;break t}F=qe(F),L=qe(L)}qe=null}else qe=null;se!==null&&m_(fe,J,se,qe,!1),De!==null&&$t!==null&&m_(fe,$t,De,qe,!0)}}e:{if(J=Z?jn(Z):window,se=J.nodeName&&J.nodeName.toLowerCase(),se==="select"||se==="input"&&J.type==="file")var At=Mm;else if(Am(J))if(Dm)At=D1;else{At=R1;var Oe=A1}else se=J.nodeName,!se||se.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?Z&&xa(Z.elementType)&&(At=Mm):At=M1;if(At&&(At=At(n,Z))){Rm(fe,At,l,ce);break e}Oe&&Oe(n,J,Z),n==="focusout"&&Z&&J.type==="number"&&Z.memoizedProps.value!=null&&ma(J,"number",J.value)}switch(Oe=Z?jn(Z):window,n){case"focusin":(Am(Oe)||Oe.contentEditable==="true")&&(va=Oe,eh=Z,Sl=null);break;case"focusout":Sl=eh=va=null;break;case"mousedown":th=!0;break;case"contextmenu":case"mouseup":case"dragend":th=!1,Um(fe,l,ce);break;case"selectionchange":if(L1)break;case"keydown":case"keyup":Um(fe,l,ce)}var at;if(Xu)e:{switch(n){case"compositionstart":var St="onCompositionStart";break e;case"compositionend":St="onCompositionEnd";break e;case"compositionupdate":St="onCompositionUpdate";break e}St=void 0}else ba?Tm(n,l)&&(St="onCompositionEnd"):n==="keydown"&&l.keyCode===229&&(St="onCompositionStart");St&&(km&&l.locale!=="ko"&&(ba||St!=="onCompositionStart"?St==="onCompositionEnd"&&ba&&(at=vm()):(un=ce,hr="value"in un?un.value:un.textContent,ba=!0)),Oe=Bc(Z,St),0<Oe.length&&(St=new wm(St,n,null,l,ce),fe.push({event:St,listeners:Oe}),at?St.data=at:(at=jm(l),at!==null&&(St.data=at)))),(at=k1?E1(n,l):N1(n,l))&&(St=Bc(Z,"onBeforeInput"),0<St.length&&(Oe=new wm("onBeforeInput","beforeinput",null,l,ce),fe.push({event:Oe,listeners:St}),Oe.data=at)),_w(fe,n,Z,l,ce)}f_(fe,r)})}function Yl(n,r,l){return{instance:n,listener:r,currentTarget:l}}function Bc(n,r){for(var l=r+"Capture",u=[];n!==null;){var m=n,g=m.stateNode;if(m=m.tag,m!==5&&m!==26&&m!==27||g===null||(m=Ze(n,l),m!=null&&u.unshift(Yl(n,m,g)),m=Ze(n,r),m!=null&&u.push(Yl(n,m,g))),n.tag===3)return u;n=n.return}return[]}function Sw(n){if(n===null)return null;do n=n.return;while(n&&n.tag!==5&&n.tag!==27);return n||null}function m_(n,r,l,u,m){for(var g=r._reactName,S=[];l!==null&&l!==u;){var k=l,M=k.alternate,Z=k.stateNode;if(k=k.tag,M!==null&&M===u)break;k!==5&&k!==26&&k!==27||Z===null||(M=Z,m?(Z=Ze(l,g),Z!=null&&S.unshift(Yl(l,Z,M))):m||(Z=Ze(l,g),Z!=null&&S.push(Yl(l,Z,M)))),l=l.return}S.length!==0&&n.push({event:r,listeners:S})}var ww=/\r\n?/g,Cw=/\u0000|\uFFFD/g;function g_(n){return(typeof n=="string"?n:""+n).replace(ww,`
49
+ `).replace(Cw,"")}function x_(n,r){return r=g_(r),g_(n)===r}function Ut(n,r,l,u,m,g){switch(l){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||Yn(n,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&Yn(n,""+u);break;case"className":or(n,"class",u);break;case"tabIndex":or(n,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":or(n,l,u);break;case"style":Uo(n,u,g);break;case"data":if(r!=="object"){or(n,"data",u);break}case"src":case"href":if(u===""&&(r!=="a"||l!=="href")){n.removeAttribute(l);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(l);break}u=_a(""+u),n.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){n.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof g=="function"&&(l==="formAction"?(r!=="input"&&Ut(n,r,"name",m.name,m,null),Ut(n,r,"formEncType",m.formEncType,m,null),Ut(n,r,"formMethod",m.formMethod,m,null),Ut(n,r,"formTarget",m.formTarget,m,null)):(Ut(n,r,"encType",m.encType,m,null),Ut(n,r,"method",m.method,m,null),Ut(n,r,"target",m.target,m,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){n.removeAttribute(l);break}u=_a(""+u),n.setAttribute(l,u);break;case"onClick":u!=null&&(n.onclick=cn);break;case"onScroll":u!=null&&xt("scroll",n);break;case"onScrollEnd":u!=null&&xt("scrollend",n);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(m.children!=null)throw Error(s(60));n.innerHTML=l}}break;case"multiple":n.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":n.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){n.removeAttribute("xlink:href");break}l=_a(""+u),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(l,""+u):n.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(l,""):n.removeAttribute(l);break;case"capture":case"download":u===!0?n.setAttribute(l,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?n.setAttribute(l,u):n.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?n.setAttribute(l,u):n.removeAttribute(l);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?n.removeAttribute(l):n.setAttribute(l,u);break;case"popover":xt("beforetoggle",n),xt("toggle",n),Ar(n,"popover",u);break;case"xlinkActuate":_n(n,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":_n(n,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":_n(n,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":_n(n,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":_n(n,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":_n(n,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":_n(n,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":_n(n,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":_n(n,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Ar(n,"is",u);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=pl.get(l)||l,Ar(n,l,u))}}function Ed(n,r,l,u,m,g){switch(l){case"style":Uo(n,u,g);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(s(61));if(l=u.__html,l!=null){if(m.children!=null)throw Error(s(60));n.innerHTML=l}}break;case"children":typeof u=="string"?Yn(n,u):(typeof u=="number"||typeof u=="bigint")&&Yn(n,""+u);break;case"onScroll":u!=null&&xt("scroll",n);break;case"onScrollEnd":u!=null&&xt("scrollend",n);break;case"onClick":u!=null&&(n.onclick=cn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Wn.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(m=l.endsWith("Capture"),r=l.slice(2,m?l.length-7:void 0),g=n[it]||null,g=g!=null?g[l]:null,typeof g=="function"&&n.removeEventListener(r,g,m),typeof u=="function")){typeof g!="function"&&g!==null&&(l in n?n[l]=null:n.hasAttribute(l)&&n.removeAttribute(l)),n.addEventListener(r,u,m);break e}l in n?n[l]=u:u===!0?n.setAttribute(l,""):Ar(n,l,u)}}}function Ki(n,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":xt("error",n),xt("load",n);var u=!1,m=!1,g;for(g in l)if(l.hasOwnProperty(g)){var S=l[g];if(S!=null)switch(g){case"src":u=!0;break;case"srcSet":m=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Ut(n,r,g,S,l,null)}}m&&Ut(n,r,"srcSet",l.srcSet,l,null),u&&Ut(n,r,"src",l.src,l,null);return;case"input":xt("invalid",n);var k=g=S=m=null,M=null,Z=null;for(u in l)if(l.hasOwnProperty(u)){var ce=l[u];if(ce!=null)switch(u){case"name":m=ce;break;case"type":S=ce;break;case"checked":M=ce;break;case"defaultChecked":Z=ce;break;case"value":g=ce;break;case"defaultValue":k=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(s(137,r));break;default:Ut(n,r,u,ce,l,null)}}pa(n,g,k,M,Z,S,m,!1);return;case"select":xt("invalid",n),u=S=g=null;for(m in l)if(l.hasOwnProperty(m)&&(k=l[m],k!=null))switch(m){case"value":g=k;break;case"defaultValue":S=k;break;case"multiple":u=k;default:Ut(n,r,m,k,l,null)}r=g,l=S,n.multiple=!!u,r!=null?Gn(n,!!u,r,!1):l!=null&&Gn(n,!!u,l,!0);return;case"textarea":xt("invalid",n),g=m=u=null;for(S in l)if(l.hasOwnProperty(S)&&(k=l[S],k!=null))switch(S){case"value":u=k;break;case"defaultValue":m=k;break;case"children":g=k;break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(s(91));break;default:Ut(n,r,S,k,l,null)}fl(n,u,m,g);return;case"option":for(M in l)if(l.hasOwnProperty(M)&&(u=l[M],u!=null))switch(M){case"selected":n.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:Ut(n,r,M,u,l,null)}return;case"dialog":xt("beforetoggle",n),xt("toggle",n),xt("cancel",n),xt("close",n);break;case"iframe":case"object":xt("load",n);break;case"video":case"audio":for(u=0;u<Gl.length;u++)xt(Gl[u],n);break;case"image":xt("error",n),xt("load",n);break;case"details":xt("toggle",n);break;case"embed":case"source":case"link":xt("error",n),xt("load",n);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in l)if(l.hasOwnProperty(Z)&&(u=l[Z],u!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,r));default:Ut(n,r,Z,u,l,null)}return;default:if(xa(r)){for(ce in l)l.hasOwnProperty(ce)&&(u=l[ce],u!==void 0&&Ed(n,r,ce,u,l,void 0));return}}for(k in l)l.hasOwnProperty(k)&&(u=l[k],u!=null&&Ut(n,r,k,u,l,null))}function kw(n,r,l,u){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var m=null,g=null,S=null,k=null,M=null,Z=null,ce=null;for(se in l){var fe=l[se];if(l.hasOwnProperty(se)&&fe!=null)switch(se){case"checked":break;case"value":break;case"defaultValue":M=fe;default:u.hasOwnProperty(se)||Ut(n,r,se,null,u,fe)}}for(var J in u){var se=u[J];if(fe=l[J],u.hasOwnProperty(J)&&(se!=null||fe!=null))switch(J){case"type":g=se;break;case"name":m=se;break;case"checked":Z=se;break;case"defaultChecked":ce=se;break;case"value":S=se;break;case"defaultValue":k=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(s(137,r));break;default:se!==fe&&Ut(n,r,J,se,u,fe)}}fa(n,S,k,M,Z,ce,g,m);return;case"select":se=S=k=J=null;for(g in l)if(M=l[g],l.hasOwnProperty(g)&&M!=null)switch(g){case"value":break;case"multiple":se=M;default:u.hasOwnProperty(g)||Ut(n,r,g,null,u,M)}for(m in u)if(g=u[m],M=l[m],u.hasOwnProperty(m)&&(g!=null||M!=null))switch(m){case"value":J=g;break;case"defaultValue":k=g;break;case"multiple":S=g;default:g!==M&&Ut(n,r,m,g,u,M)}r=k,l=S,u=se,J!=null?Gn(n,!!l,J,!1):!!u!=!!l&&(r!=null?Gn(n,!!l,r,!0):Gn(n,!!l,l?[]:"",!1));return;case"textarea":se=J=null;for(k in l)if(m=l[k],l.hasOwnProperty(k)&&m!=null&&!u.hasOwnProperty(k))switch(k){case"value":break;case"children":break;default:Ut(n,r,k,null,u,m)}for(S in u)if(m=u[S],g=l[S],u.hasOwnProperty(S)&&(m!=null||g!=null))switch(S){case"value":J=m;break;case"defaultValue":se=m;break;case"children":break;case"dangerouslySetInnerHTML":if(m!=null)throw Error(s(91));break;default:m!==g&&Ut(n,r,S,m,u,g)}ga(n,J,se);return;case"option":for(var De in l)if(J=l[De],l.hasOwnProperty(De)&&J!=null&&!u.hasOwnProperty(De))switch(De){case"selected":n.selected=!1;break;default:Ut(n,r,De,null,u,J)}for(M in u)if(J=u[M],se=l[M],u.hasOwnProperty(M)&&J!==se&&(J!=null||se!=null))switch(M){case"selected":n.selected=J&&typeof J!="function"&&typeof J!="symbol";break;default:Ut(n,r,M,J,u,se)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var qe in l)J=l[qe],l.hasOwnProperty(qe)&&J!=null&&!u.hasOwnProperty(qe)&&Ut(n,r,qe,null,u,J);for(Z in u)if(J=u[Z],se=l[Z],u.hasOwnProperty(Z)&&J!==se&&(J!=null||se!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(s(137,r));break;default:Ut(n,r,Z,J,u,se)}return;default:if(xa(r)){for(var $t in l)J=l[$t],l.hasOwnProperty($t)&&J!==void 0&&!u.hasOwnProperty($t)&&Ed(n,r,$t,void 0,u,J);for(ce in u)J=u[ce],se=l[ce],!u.hasOwnProperty(ce)||J===se||J===void 0&&se===void 0||Ed(n,r,ce,J,u,se);return}}for(var F in l)J=l[F],l.hasOwnProperty(F)&&J!=null&&!u.hasOwnProperty(F)&&Ut(n,r,F,null,u,J);for(fe in u)J=u[fe],se=l[fe],!u.hasOwnProperty(fe)||J===se||J==null&&se==null||Ut(n,r,fe,J,u,se)}function __(n){switch(n){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Ew(){if(typeof performance.getEntriesByType=="function"){for(var n=0,r=0,l=performance.getEntriesByType("resource"),u=0;u<l.length;u++){var m=l[u],g=m.transferSize,S=m.initiatorType,k=m.duration;if(g&&k&&__(S)){for(S=0,k=m.responseEnd,u+=1;u<l.length;u++){var M=l[u],Z=M.startTime;if(Z>k)break;var ce=M.transferSize,fe=M.initiatorType;ce&&__(fe)&&(M=M.responseEnd,S+=ce*(M<k?1:(k-Z)/(M-Z)))}if(--u,r+=8*(g+S)/(m.duration/1e3),n++,10<n)break}}if(0<n)return r/n/1e6}return navigator.connection&&(n=navigator.connection.downlink,typeof n=="number")?n:5}var Nd=null,Td=null;function Lc(n){return n.nodeType===9?n:n.ownerDocument}function b_(n){switch(n){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function v_(n,r){if(n===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return n===1&&r==="foreignObject"?0:n}function jd(n,r){return n==="textarea"||n==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var Ad=null;function Nw(){var n=window.event;return n&&n.type==="popstate"?n===Ad?!1:(Ad=n,!0):(Ad=null,!1)}var y_=typeof setTimeout=="function"?setTimeout:void 0,Tw=typeof clearTimeout=="function"?clearTimeout:void 0,S_=typeof Promise=="function"?Promise:void 0,jw=typeof queueMicrotask=="function"?queueMicrotask:typeof S_<"u"?function(n){return S_.resolve(null).then(n).catch(Aw)}:y_;function Aw(n){setTimeout(function(){throw n})}function bs(n){return n==="head"}function w_(n,r){var l=r,u=0;do{var m=l.nextSibling;if(n.removeChild(l),m&&m.nodeType===8)if(l=m.data,l==="/$"||l==="/&"){if(u===0){n.removeChild(m),Ya(r);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")Kl(n.ownerDocument.documentElement);else if(l==="head"){l=n.ownerDocument.head,Kl(l);for(var g=l.firstChild;g;){var S=g.nextSibling,k=g.nodeName;g[Fi]||k==="SCRIPT"||k==="STYLE"||k==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=S}}else l==="body"&&Kl(n.ownerDocument.body);l=m}while(l);Ya(r)}function C_(n,r){var l=n;n=0;do{var u=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),u&&u.nodeType===8)if(l=u.data,l==="/$"){if(n===0)break;n--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||n++;l=u}while(l)}function Rd(n){var r=n.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Rd(l),Fn(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}n.removeChild(l)}}function Rw(n,r,l,u){for(;n.nodeType===1;){var m=l;if(n.nodeName.toLowerCase()!==r.toLowerCase()){if(!u&&(n.nodeName!=="INPUT"||n.type!=="hidden"))break}else if(u){if(!n[Fi])switch(r){case"meta":if(!n.hasAttribute("itemprop"))break;return n;case"link":if(g=n.getAttribute("rel"),g==="stylesheet"&&n.hasAttribute("data-precedence"))break;if(g!==m.rel||n.getAttribute("href")!==(m.href==null||m.href===""?null:m.href)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin)||n.getAttribute("title")!==(m.title==null?null:m.title))break;return n;case"style":if(n.hasAttribute("data-precedence"))break;return n;case"script":if(g=n.getAttribute("src"),(g!==(m.src==null?null:m.src)||n.getAttribute("type")!==(m.type==null?null:m.type)||n.getAttribute("crossorigin")!==(m.crossOrigin==null?null:m.crossOrigin))&&g&&n.hasAttribute("async")&&!n.hasAttribute("itemprop"))break;return n;default:return n}}else if(r==="input"&&n.type==="hidden"){var g=m.name==null?null:""+m.name;if(m.type==="hidden"&&n.getAttribute("name")===g)return n}else return n;if(n=er(n.nextSibling),n===null)break}return null}function Mw(n,r,l){if(r==="")return null;for(;n.nodeType!==3;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!l||(n=er(n.nextSibling),n===null))return null;return n}function k_(n,r){for(;n.nodeType!==8;)if((n.nodeType!==1||n.nodeName!=="INPUT"||n.type!=="hidden")&&!r||(n=er(n.nextSibling),n===null))return null;return n}function Md(n){return n.data==="$?"||n.data==="$~"}function Dd(n){return n.data==="$!"||n.data==="$?"&&n.ownerDocument.readyState!=="loading"}function Dw(n,r){var l=n.ownerDocument;if(n.data==="$~")n._reactRetry=r;else if(n.data!=="$?"||l.readyState!=="loading")r();else{var u=function(){r(),l.removeEventListener("DOMContentLoaded",u)};l.addEventListener("DOMContentLoaded",u),n._reactRetry=u}}function er(n){for(;n!=null;n=n.nextSibling){var r=n.nodeType;if(r===1||r===3)break;if(r===8){if(r=n.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return n}var Bd=null;function E_(n){n=n.nextSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="/$"||l==="/&"){if(r===0)return er(n.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}n=n.nextSibling}return null}function N_(n){n=n.previousSibling;for(var r=0;n;){if(n.nodeType===8){var l=n.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return n;r--}else l!=="/$"&&l!=="/&"||r++}n=n.previousSibling}return null}function T_(n,r,l){switch(r=Lc(l),n){case"html":if(n=r.documentElement,!n)throw Error(s(452));return n;case"head":if(n=r.head,!n)throw Error(s(453));return n;case"body":if(n=r.body,!n)throw Error(s(454));return n;default:throw Error(s(451))}}function Kl(n){for(var r=n.attributes;r.length;)n.removeAttributeNode(r[0]);Fn(n)}var tr=new Map,j_=new Set;function Oc(n){return typeof n.getRootNode=="function"?n.getRootNode():n.nodeType===9?n:n.ownerDocument}var Gr=B.d;B.d={f:Bw,r:Lw,D:Ow,C:zw,L:Pw,m:Iw,X:Uw,S:Hw,M:$w};function Bw(){var n=Gr.f(),r=Nc();return n||r}function Lw(n){var r=ni(n);r!==null&&r.tag===5&&r.type==="form"?Gg(r):Gr.r(n)}var qa=typeof document>"u"?null:document;function A_(n,r,l){var u=qa;if(u&&typeof r=="string"&&r){var m=Ei(r);m='link[rel="'+n+'"][href="'+m+'"]',typeof l=="string"&&(m+='[crossorigin="'+l+'"]'),j_.has(m)||(j_.add(m),n={rel:n,crossOrigin:l,href:r},u.querySelector(m)===null&&(r=u.createElement("link"),Ki(r,"link",n),ri(r),u.head.appendChild(r)))}}function Ow(n){Gr.D(n),A_("dns-prefetch",n,null)}function zw(n,r){Gr.C(n,r),A_("preconnect",n,r)}function Pw(n,r,l){Gr.L(n,r,l);var u=qa;if(u&&n&&r){var m='link[rel="preload"][as="'+Ei(r)+'"]';r==="image"&&l&&l.imageSrcSet?(m+='[imagesrcset="'+Ei(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(m+='[imagesizes="'+Ei(l.imageSizes)+'"]')):m+='[href="'+Ei(n)+'"]';var g=m;switch(r){case"style":g=Wa(n);break;case"script":g=Ga(n)}tr.has(g)||(n=x({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:n,as:r},l),tr.set(g,n),u.querySelector(m)!==null||r==="style"&&u.querySelector(Vl(g))||r==="script"&&u.querySelector(Xl(g))||(r=u.createElement("link"),Ki(r,"link",n),ri(r),u.head.appendChild(r)))}}function Iw(n,r){Gr.m(n,r);var l=qa;if(l&&n){var u=r&&typeof r.as=="string"?r.as:"script",m='link[rel="modulepreload"][as="'+Ei(u)+'"][href="'+Ei(n)+'"]',g=m;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Ga(n)}if(!tr.has(g)&&(n=x({rel:"modulepreload",href:n},r),tr.set(g,n),l.querySelector(m)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Xl(g)))return}u=l.createElement("link"),Ki(u,"link",n),ri(u),l.head.appendChild(u)}}}function Hw(n,r,l){Gr.S(n,r,l);var u=qa;if(u&&n){var m=qn(u).hoistableStyles,g=Wa(n);r=r||"default";var S=m.get(g);if(!S){var k={loading:0,preload:null};if(S=u.querySelector(Vl(g)))k.loading=5;else{n=x({rel:"stylesheet",href:n,"data-precedence":r},l),(l=tr.get(g))&&Ld(n,l);var M=S=u.createElement("link");ri(M),Ki(M,"link",n),M._p=new Promise(function(Z,ce){M.onload=Z,M.onerror=ce}),M.addEventListener("load",function(){k.loading|=1}),M.addEventListener("error",function(){k.loading|=2}),k.loading|=4,zc(S,r,u)}S={type:"stylesheet",instance:S,count:1,state:k},m.set(g,S)}}}function Uw(n,r){Gr.X(n,r);var l=qa;if(l&&n){var u=qn(l).hoistableScripts,m=Ga(n),g=u.get(m);g||(g=l.querySelector(Xl(m)),g||(n=x({src:n,async:!0},r),(r=tr.get(m))&&Od(n,r),g=l.createElement("script"),ri(g),Ki(g,"link",n),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function $w(n,r){Gr.M(n,r);var l=qa;if(l&&n){var u=qn(l).hoistableScripts,m=Ga(n),g=u.get(m);g||(g=l.querySelector(Xl(m)),g||(n=x({src:n,async:!0,type:"module"},r),(r=tr.get(m))&&Od(n,r),g=l.createElement("script"),ri(g),Ki(g,"link",n),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(m,g))}}function R_(n,r,l,u){var m=(m=ue.current)?Oc(m):null;if(!m)throw Error(s(446));switch(n){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Wa(l.href),l=qn(m).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){n=Wa(l.href);var g=qn(m).hoistableStyles,S=g.get(n);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(n,S),(g=m.querySelector(Vl(n)))&&!g._p&&(S.instance=g,S.state.loading=5),tr.has(n)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},tr.set(n,l),g||Fw(m,n,l,S.state))),r&&u===null)throw Error(s(528,""));return S}if(r&&u!==null)throw Error(s(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Ga(l),l=qn(m).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,n))}}function Wa(n){return'href="'+Ei(n)+'"'}function Vl(n){return'link[rel="stylesheet"]['+n+"]"}function M_(n){return x({},n,{"data-precedence":n.precedence,precedence:null})}function Fw(n,r,l,u){n.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=n.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Ki(r,"link",l),ri(r),n.head.appendChild(r))}function Ga(n){return'[src="'+Ei(n)+'"]'}function Xl(n){return"script[async]"+n}function D_(n,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=n.querySelector('style[data-href~="'+Ei(l.href)+'"]');if(u)return r.instance=u,ri(u),u;var m=x({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(n.ownerDocument||n).createElement("style"),ri(u),Ki(u,"style",m),zc(u,l.precedence,n),r.instance=u;case"stylesheet":m=Wa(l.href);var g=n.querySelector(Vl(m));if(g)return r.state.loading|=4,r.instance=g,ri(g),g;u=M_(l),(m=tr.get(m))&&Ld(u,m),g=(n.ownerDocument||n).createElement("link"),ri(g);var S=g;return S._p=new Promise(function(k,M){S.onload=k,S.onerror=M}),Ki(g,"link",u),r.state.loading|=4,zc(g,l.precedence,n),r.instance=g;case"script":return g=Ga(l.src),(m=n.querySelector(Xl(g)))?(r.instance=m,ri(m),m):(u=l,(m=tr.get(g))&&(u=x({},l),Od(u,m)),n=n.ownerDocument||n,m=n.createElement("script"),ri(m),Ki(m,"link",u),n.head.appendChild(m),r.instance=m);case"void":return null;default:throw Error(s(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,zc(u,l.precedence,n));return r.instance}function zc(n,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=u.length?u[u.length-1]:null,g=m,S=0;S<u.length;S++){var k=u[S];if(k.dataset.precedence===r)g=k;else if(g!==m)break}g?g.parentNode.insertBefore(n,g.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(n,r.firstChild))}function Ld(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.title==null&&(n.title=r.title)}function Od(n,r){n.crossOrigin==null&&(n.crossOrigin=r.crossOrigin),n.referrerPolicy==null&&(n.referrerPolicy=r.referrerPolicy),n.integrity==null&&(n.integrity=r.integrity)}var Pc=null;function B_(n,r,l){if(Pc===null){var u=new Map,m=Pc=new Map;m.set(l,u)}else m=Pc,u=m.get(l),u||(u=new Map,m.set(l,u));if(u.has(n))return u;for(u.set(n,null),l=l.getElementsByTagName(n),m=0;m<l.length;m++){var g=l[m];if(!(g[Fi]||g[st]||n==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(r)||"";S=n+S;var k=u.get(S);k?k.push(g):u.set(S,[g])}}return u}function L_(n,r,l){n=n.ownerDocument||n,n.head.insertBefore(l,r==="title"?n.querySelector("head > title"):null)}function qw(n,r,l){if(l===1||r.itemProp!=null)return!1;switch(n){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return n=r.disabled,typeof r.precedence=="string"&&n==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function O_(n){return!(n.type==="stylesheet"&&(n.state.loading&3)===0)}function Ww(n,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var m=Wa(u.href),g=r.querySelector(Vl(m));if(g){r=g._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(n.count++,n=Ic.bind(n),r.then(n,n)),l.state.loading|=4,l.instance=g,ri(g);return}g=r.ownerDocument||r,u=M_(u),(m=tr.get(m))&&Ld(u,m),g=g.createElement("link"),ri(g);var S=g;S._p=new Promise(function(k,M){S.onload=k,S.onerror=M}),Ki(g,"link",u),l.instance=g}n.stylesheets===null&&(n.stylesheets=new Map),n.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(n.count++,l=Ic.bind(n),r.addEventListener("load",l),r.addEventListener("error",l))}}var zd=0;function Gw(n,r){return n.stylesheets&&n.count===0&&Uc(n,n.stylesheets),0<n.count||0<n.imgCount?function(l){var u=setTimeout(function(){if(n.stylesheets&&Uc(n,n.stylesheets),n.unsuspend){var g=n.unsuspend;n.unsuspend=null,g()}},6e4+r);0<n.imgBytes&&zd===0&&(zd=62500*Ew());var m=setTimeout(function(){if(n.waitingForImages=!1,n.count===0&&(n.stylesheets&&Uc(n,n.stylesheets),n.unsuspend)){var g=n.unsuspend;n.unsuspend=null,g()}},(n.imgBytes>zd?50:800)+r);return n.unsuspend=l,function(){n.unsuspend=null,clearTimeout(u),clearTimeout(m)}}:null}function Ic(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Uc(this,this.stylesheets);else if(this.unsuspend){var n=this.unsuspend;this.unsuspend=null,n()}}}var Hc=null;function Uc(n,r){n.stylesheets=null,n.unsuspend!==null&&(n.count++,Hc=new Map,r.forEach(Yw,n),Hc=null,Ic.call(n))}function Yw(n,r){if(!(r.state.loading&4)){var l=Hc.get(n);if(l)var u=l.get(null);else{l=new Map,Hc.set(n,l);for(var m=n.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<m.length;g++){var S=m[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(l.set(S.dataset.precedence,S),u=S)}u&&l.set(null,u)}m=r.instance,S=m.getAttribute("data-precedence"),g=l.get(S)||u,g===u&&l.set(null,m),l.set(S,m),this.count++,u=Ic.bind(this),m.addEventListener("load",u),m.addEventListener("error",u),g?g.parentNode.insertBefore(m,g.nextSibling):(n=n.nodeType===9?n.head:n,n.insertBefore(m,n.firstChild)),r.state.loading|=4}}var Zl={$$typeof:O,Provider:null,Consumer:null,_currentValue:U,_currentValue2:U,_threadCount:0};function Kw(n,r,l,u,m,g,S,k,M){this.tag=1,this.containerInfo=n,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=li(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=li(0),this.hiddenUpdates=li(null),this.identifierPrefix=u,this.onUncaughtError=m,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=M,this.incompleteTransitions=new Map}function z_(n,r,l,u,m,g,S,k,M,Z,ce,fe){return n=new Kw(n,r,l,S,M,Z,ce,fe,k),r=1,g===!0&&(r|=24),g=Dn(3,null,null,r),n.current=g,g.stateNode=n,r=gh(),r.refCount++,n.pooledCache=r,r.refCount++,g.memoizedState={element:u,isDehydrated:l,cache:r},vh(g),n}function P_(n){return n?(n=wa,n):wa}function I_(n,r,l,u,m,g){m=P_(m),u.context===null?u.context=m:u.pendingContext=m,u=os(r),u.payload={element:l},g=g===void 0?null:g,g!==null&&(u.callback=g),l=cs(n,u,r),l!==null&&(Cn(l,n,r),jl(l,n,r))}function H_(n,r){if(n=n.memoizedState,n!==null&&n.dehydrated!==null){var l=n.retryLane;n.retryLane=l!==0&&l<r?l:r}}function Pd(n,r){H_(n,r),(n=n.alternate)&&H_(n,r)}function U_(n){if(n.tag===13||n.tag===31){var r=Is(n,67108864);r!==null&&Cn(r,n,67108864),Pd(n,67108864)}}function $_(n){if(n.tag===13||n.tag===31){var r=Pn();r=me(r);var l=Is(n,r);l!==null&&Cn(l,n,r),Pd(n,r)}}var $c=!0;function Vw(n,r,l,u){var m=A.T;A.T=null;var g=B.p;try{B.p=2,Id(n,r,l,u)}finally{B.p=g,A.T=m}}function Xw(n,r,l,u){var m=A.T;A.T=null;var g=B.p;try{B.p=8,Id(n,r,l,u)}finally{B.p=g,A.T=m}}function Id(n,r,l,u){if($c){var m=Hd(u);if(m===null)kd(n,r,u,Fc,l),q_(n,u);else if(Qw(m,n,r,l,u))u.stopPropagation();else if(q_(n,u),r&4&&-1<Zw.indexOf(n)){for(;m!==null;){var g=ni(m);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=Xe(g.pendingLanes);if(S!==0){var k=g;for(k.pendingLanes|=2,k.entangledLanes|=2;S;){var M=1<<31-pt(S);k.entanglements[1]|=M,S&=~M}vr(g),(Dt&6)===0&&(kc=Ct()+500,Wl(0))}}break;case 31:case 13:k=Is(g,2),k!==null&&Cn(k,g,2),Nc(),Pd(g,2)}if(g=Hd(u),g===null&&kd(n,r,u,Fc,l),g===m)break;m=g}m!==null&&u.stopPropagation()}else kd(n,r,u,null,l)}}function Hd(n){return n=ml(n),Ud(n)}var Fc=null;function Ud(n){if(Fc=null,n=qi(n),n!==null){var r=o(n);if(r===null)n=null;else{var l=r.tag;if(l===13){if(n=c(r),n!==null)return n;n=null}else if(l===31){if(n=h(r),n!==null)return n;n=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;n=null}else r!==n&&(n=null)}}return Fc=n,null}function F_(n){switch(n){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(pi()){case ne:return 2;case xe:return 8;case Be:case $e:return 32;case Ge:return 268435456;default:return 32}default:return 32}}var $d=!1,vs=null,ys=null,Ss=null,Ql=new Map,Jl=new Map,ws=[],Zw="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".split(" ");function q_(n,r){switch(n){case"focusin":case"focusout":vs=null;break;case"dragenter":case"dragleave":ys=null;break;case"mouseover":case"mouseout":Ss=null;break;case"pointerover":case"pointerout":Ql.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Jl.delete(r.pointerId)}}function eo(n,r,l,u,m,g){return n===null||n.nativeEvent!==g?(n={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:g,targetContainers:[m]},r!==null&&(r=ni(r),r!==null&&U_(r)),n):(n.eventSystemFlags|=u,r=n.targetContainers,m!==null&&r.indexOf(m)===-1&&r.push(m),n)}function Qw(n,r,l,u,m){switch(r){case"focusin":return vs=eo(vs,n,r,l,u,m),!0;case"dragenter":return ys=eo(ys,n,r,l,u,m),!0;case"mouseover":return Ss=eo(Ss,n,r,l,u,m),!0;case"pointerover":var g=m.pointerId;return Ql.set(g,eo(Ql.get(g)||null,n,r,l,u,m)),!0;case"gotpointercapture":return g=m.pointerId,Jl.set(g,eo(Jl.get(g)||null,n,r,l,u,m)),!0}return!1}function W_(n){var r=qi(n.target);if(r!==null){var l=o(r);if(l!==null){if(r=l.tag,r===13){if(r=c(l),r!==null){n.blockedOn=r,ot(n.priority,function(){$_(l)});return}}else if(r===31){if(r=h(l),r!==null){n.blockedOn=r,ot(n.priority,function(){$_(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){n.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}n.blockedOn=null}function qc(n){if(n.blockedOn!==null)return!1;for(var r=n.targetContainers;0<r.length;){var l=Hd(n.nativeEvent);if(l===null){l=n.nativeEvent;var u=new l.constructor(l.type,l);is=u,l.target.dispatchEvent(u),is=null}else return r=ni(l),r!==null&&U_(r),n.blockedOn=l,!1;r.shift()}return!0}function G_(n,r,l){qc(n)&&l.delete(r)}function Jw(){$d=!1,vs!==null&&qc(vs)&&(vs=null),ys!==null&&qc(ys)&&(ys=null),Ss!==null&&qc(Ss)&&(Ss=null),Ql.forEach(G_),Jl.forEach(G_)}function Wc(n,r){n.blockedOn===r&&(n.blockedOn=null,$d||($d=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,Jw)))}var Gc=null;function Y_(n){Gc!==n&&(Gc=n,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Gc===n&&(Gc=null);for(var r=0;r<n.length;r+=3){var l=n[r],u=n[r+1],m=n[r+2];if(typeof u!="function"){if(Ud(u||l)===null)continue;break}var g=ni(l);g!==null&&(n.splice(r,3),r-=3,Hh(g,{pending:!0,data:m,method:l.method,action:u},u,m))}}))}function Ya(n){function r(M){return Wc(M,n)}vs!==null&&Wc(vs,n),ys!==null&&Wc(ys,n),Ss!==null&&Wc(Ss,n),Ql.forEach(r),Jl.forEach(r);for(var l=0;l<ws.length;l++){var u=ws[l];u.blockedOn===n&&(u.blockedOn=null)}for(;0<ws.length&&(l=ws[0],l.blockedOn===null);)W_(l),l.blockedOn===null&&ws.shift();if(l=(n.ownerDocument||n).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var m=l[u],g=l[u+1],S=m[it]||null;if(typeof g=="function")S||Y_(l);else if(S){var k=null;if(g&&g.hasAttribute("formAction")){if(m=g,S=g[it]||null)k=S.formAction;else if(Ud(m)!==null)continue}else k=S.action;typeof k=="function"?l[u+1]=k:(l.splice(u,3),u-=3),Y_(l)}}}function K_(){function n(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return m=S})},focusReset:"manual",scroll:"manual"})}function r(){m!==null&&(m(),m=null),u||setTimeout(l,20)}function l(){if(!u&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,m=null;return navigation.addEventListener("navigate",n),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){u=!0,navigation.removeEventListener("navigate",n),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),m!==null&&(m(),m=null)}}}function Fd(n){this._internalRoot=n}Yc.prototype.render=Fd.prototype.render=function(n){var r=this._internalRoot;if(r===null)throw Error(s(409));var l=r.current,u=Pn();I_(l,u,n,r,null,null)},Yc.prototype.unmount=Fd.prototype.unmount=function(){var n=this._internalRoot;if(n!==null){this._internalRoot=null;var r=n.containerInfo;I_(n.current,2,null,n,null,null),Nc(),r[kt]=null}};function Yc(n){this._internalRoot=n}Yc.prototype.unstable_scheduleHydration=function(n){if(n){var r=ut();n={blockedOn:null,target:n,priority:r};for(var l=0;l<ws.length&&r!==0&&r<ws[l].priority;l++);ws.splice(l,0,n),l===0&&W_(n)}};var V_=t.version;if(V_!=="19.2.3")throw Error(s(527,V_,"19.2.3"));B.findDOMNode=function(n){var r=n._reactInternals;if(r===void 0)throw typeof n.render=="function"?Error(s(188)):(n=Object.keys(n).join(","),Error(s(268,n)));return n=f(r),n=n!==null?_(n):null,n=n===null?null:n.stateNode,n};var eC={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:A,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Kc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kc.isDisabled&&Kc.supportsFiber)try{ct=Kc.inject(eC),We=Kc}catch{}}return io.createRoot=function(n,r){if(!a(n))throw Error(s(299));var l=!1,u="",m=ix,g=nx,S=rx;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(m=r.onUncaughtError),r.onCaughtError!==void 0&&(g=r.onCaughtError),r.onRecoverableError!==void 0&&(S=r.onRecoverableError)),r=z_(n,1,!1,null,null,l,u,null,m,g,S,K_),n[kt]=r.current,Cd(n),new Fd(r)},io.hydrateRoot=function(n,r,l){if(!a(n))throw Error(s(299));var u=!1,m="",g=ix,S=nx,k=rx,M=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(m=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(S=l.onCaughtError),l.onRecoverableError!==void 0&&(k=l.onRecoverableError),l.formState!==void 0&&(M=l.formState)),r=z_(n,1,!0,r,l??null,u,m,M,g,S,k,K_),r.context=P_(null),l=r.current,u=Pn(),u=me(u),m=os(u),m.callback=null,cs(l,m,u),l=u,r.current.lanes=l,oe(r,l),vr(r),n[kt]=r.current,Cd(n),new Yc(r)},io.version="19.2.3",io}var sb;function hC(){if(sb)return Gd.exports;sb=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(),Gd.exports=uC(),Gd.exports}var dC=hC();const fC=Du(dC);function pC({onLogin:e}){const[t,i]=w.useState(""),[s,a]=w.useState(null),[o,c]=w.useState(!1),h=async p=>{if(p.preventDefault(),!t.trim())return;c(!0),a(null);const f=await e(t);f&&a(f),c(!1)};return d.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:d.jsxs("div",{className:"w-full max-w-sm",children:[d.jsxs("div",{className:"border-border rounded border p-6",children:[d.jsxs("div",{className:"mb-6 text-center",children:[d.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),d.jsx("p",{className:"text-muted mt-1 text-xs",children:"local writer agent"})]}),d.jsxs("form",{onSubmit:h,className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),d.jsx("input",{type:"password",value:t,onChange:p=>i(p.target.value),placeholder:"enter your passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),s&&d.jsx("p",{className:"text-error text-xs",children:s}),d.jsx("button",{type:"submit",disabled:o||!t.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:o?"authenticating...":"unlock"})]})]}),d.jsx("p",{className:"text-muted mt-4 text-center text-[10px]",children:"enter your passphrase to unlock"})]})})}function mC({onSetup:e}){const[t,i]=w.useState(""),[s,a]=w.useState(""),[o,c]=w.useState(null),[h,p]=w.useState(!1),f=async _=>{if(_.preventDefault(),!t.trim()||t.length<4){c("Passphrase must be at least 4 characters");return}if(t!==s){c("Passphrases do not match");return}p(!0),c(null);const x=await e(t);x&&c(x),p(!1)};return d.jsx("div",{className:"flex h-screen items-center justify-center p-4",children:d.jsx("div",{className:"w-full max-w-sm",children:d.jsxs("div",{className:"border-border rounded border p-6",children:[d.jsxs("div",{className:"mb-6 text-center",children:[d.jsx("h1",{className:"text-accent text-lg font-bold tracking-tight",children:"PlotLink OWS"}),d.jsx("p",{className:"text-muted mt-1 text-xs",children:"first-time setup"})]}),d.jsx("p",{className:"text-muted mb-4 text-xs leading-relaxed",children:"Choose a passphrase to protect your local writer agent. This will be used to unlock the app and secure your OWS wallet."}),d.jsxs("form",{onSubmit:f,className:"space-y-4",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Passphrase"}),d.jsx("input",{type:"password",value:t,onChange:_=>i(_.target.value),placeholder:"choose a passphrase",autoFocus:!0,className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted mb-1.5 block text-xs uppercase tracking-wider",children:"Confirm"}),d.jsx("input",{type:"password",value:s,onChange:_=>a(_.target.value),placeholder:"repeat passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),o&&d.jsx("p",{className:"text-error text-xs",children:o}),d.jsx("button",{type:"submit",disabled:h||!t.trim()||!s.trim(),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:h?"setting up...":"create passphrase"})]})]})})})}const Xd="http://localhost:7777";function Cy({token:e}){const[t,i]=w.useState(null),[s,a]=w.useState(!1),[o,c]=w.useState(null),[h,p]=w.useState(!1),[f,_]=w.useState(null),x=w.useCallback((E,z)=>fetch(E,{...z,headers:{...z==null?void 0:z.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]),b=w.useCallback(()=>{x(`${Xd}/api/wallet`).then(E=>E.json()).then(E=>i(E)).catch(()=>i({exists:!1,error:"Failed to load wallet"}))},[x]);w.useEffect(()=>{b()},[b]);const v=async()=>{a(!0),_(null);try{const E=await x(`${Xd}/api/wallet/create`,{method:"POST"}),z=await E.json();if(!E.ok)throw new Error(z.error||"Creation failed");b()}catch(E){_(E instanceof Error?E.message:"Failed to create wallet")}a(!1)},y=async E=>{c(E.walletId||E.name),_(null);try{const z=await x(`${Xd}/api/wallet/active`,{method:"POST",body:JSON.stringify({walletId:E.walletId,name:E.name,address:E.normalizedAddress||E.address})}),O=await z.json();if(!z.ok)throw new Error(O.error||"Wallet switch failed");b()}catch(z){_(z instanceof Error?z.message:"Failed to switch wallet")}c(null)},N=()=>{t!=null&&t.address&&(navigator.clipboard.writeText(t.address),p(!0),setTimeout(()=>p(!1),2e3))},j=E=>`${E.slice(0,6)}...${E.slice(-4)}`;return d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"OWS Wallet"}),!t&&d.jsx("p",{className:"text-muted text-xs",children:"loading..."}),t&&!t.exists&&d.jsxs("div",{className:"space-y-3",children:[d.jsx("p",{className:"text-muted text-xs",children:t.error||"No wallet created yet. Create one to enable autonomous transactions."}),f&&d.jsx("p",{className:"text-error text-xs",children:f}),d.jsx("button",{onClick:v,disabled:s,className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-4 py-2 text-xs font-medium transition-colors",children:s?"creating...":"create wallet"})]}),(t==null?void 0:t.selectionRequired)&&t.wallets&&t.wallets.length>0&&d.jsxs("div",{className:"mb-4 space-y-3 rounded border border-amber-600/30 bg-amber-950/10 p-3",children:[d.jsx("p",{className:"text-xs text-amber-700",children:"Multiple OWS wallets found. Select the wallet OWS should use for publishing and signing."}),t.wallets.map(E=>d.jsxs("div",{className:"border-border flex items-center justify-between gap-3 rounded border p-2",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("p",{className:"text-foreground truncate text-xs font-medium",children:E.name}),d.jsx("p",{className:"text-muted truncate text-[10px] font-mono",children:E.address||"No EVM address"})]}),d.jsx("button",{onClick:()=>y(E),disabled:!E.address||o===(E.walletId||E.name),className:"border-accent text-accent hover:bg-accent/10 disabled:opacity-40 rounded border px-2 py-1 text-[10px] font-medium transition-colors",children:o===(E.walletId||E.name)?"switching...":"use"})]},E.walletId||E.name)),f&&d.jsx("p",{className:"text-error text-xs",children:f})]}),t&&t.exists&&t.address&&d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:"Active Wallet (Base)"}),d.jsx("span",{className:`rounded border px-1.5 py-0.5 text-[9px] ${t.ethBalance&&parseFloat(t.ethBalance)>0?"border-accent/30 text-accent":"border-accent-dim/30 text-accent-dim"}`,children:t.ethBalance&&parseFloat(t.ethBalance)>0?"active":"no balance"})]}),t.name&&d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Name"}),d.jsx("span",{className:"text-foreground truncate pl-3 font-mono text-[10px]",children:t.name})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("code",{className:"text-foreground bg-surface rounded px-2 py-1 text-xs font-mono",children:j(t.address)}),d.jsx("button",{onClick:N,className:"text-muted hover:text-accent text-xs transition-colors",children:h?"copied":"copy"})]}),d.jsxs("div",{className:"border-border space-y-1 border-t pt-3",children:[d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"ETH"}),d.jsxs("span",{className:"text-foreground font-medium",children:[t.ethBalance||"0.000000"," ETH"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"USDC"}),d.jsxs("span",{className:"text-foreground font-medium",children:["$",t.usdcBalance||"0.00"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"PLOT"}),d.jsxs("span",{className:"text-foreground font-medium",children:[t.plotBalance||"0.0000"," PLOT"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Network"}),d.jsx("span",{className:"text-foreground",children:"Base"})]})]}),t.wallets&&t.wallets.length>1&&d.jsxs("div",{className:"border-border space-y-2 border-t pt-3",children:[d.jsx("p",{className:"text-muted text-[10px] font-medium uppercase tracking-wider",children:"Switch Wallet"}),t.wallets.map(E=>d.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("p",{className:E.active?"text-accent truncate font-medium":"text-foreground truncate",children:[E.name,E.active?" (active)":""]}),d.jsx("p",{className:"text-muted truncate text-[10px] font-mono",children:E.address||"No EVM address"})]}),!E.active&&d.jsx("button",{onClick:()=>y(E),disabled:!E.address||o===(E.walletId||E.name),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 rounded border px-2 py-1 text-[10px] transition-colors",children:o===(E.walletId||E.name)?"...":"use"})]},E.walletId||E.name)),f&&d.jsx("p",{className:"text-error text-xs",children:f})]}),d.jsxs("div",{className:"border-border border-t pt-3",children:[d.jsx("p",{className:"text-muted mb-2 text-[10px] font-medium uppercase tracking-wider",children:"Fund Wallet"}),d.jsx("p",{className:"text-muted text-[10px]",children:"Send ETH on Base for gas (~$0.01 per publish):"}),d.jsx("code",{className:"text-foreground bg-surface mt-1 block break-all rounded px-2 py-1.5 text-[10px] font-mono",children:t.address})]})]}),(t==null?void 0:t.exists)&&d.jsx("button",{onClick:v,disabled:s,className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 mt-4 rounded border px-3 py-1.5 text-[10px] font-medium transition-colors",children:s?"creating...":"create another wallet"})]})}function Su(e){return!!e&&e.codex.installed&&e.codex.auth==="unknown"}const zp="Codex is installed but its capabilities couldn't be read — you may need to log in to Codex (resolve outside OWS), then re-check.";function gC({token:e,onLogout:t}){const[i,s]=w.useState(""),[a,o]=w.useState(""),[c,h]=w.useState(null),[p,f]=w.useState(!1),[_,x]=w.useState(!1),[b,v]=w.useState(null),[y,N]=w.useState("AI Writer"),[j,E]=w.useState(""),[z,O]=w.useState(""),[W,q]=w.useState(!1),[D,te]=w.useState(null),[de,_e]=w.useState(""),[P,ae]=w.useState(null),[G,Y]=w.useState(!1),[Q,I]=w.useState(null),[A,B]=w.useState(null),[U,ge]=w.useState(null),T=w.useCallback((re,ue)=>fetch(re,{...ue,headers:{...ue==null?void 0:ue.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]);w.useEffect(()=>{T("/api/settings/link-status").then(re=>re.json()).then(re=>v(re)).catch(()=>v({linked:!1}))},[]),w.useEffect(()=>{T("/api/agent/readiness").then(re=>re.ok?re.json():null).then(re=>{re&&ge(re)}).catch(()=>{})},[]);const R=async()=>{if(!y.trim()){te("Agent name is required");return}if(!j.trim()){te("Description is required");return}q(!0),te(null);try{const re=await T("/api/settings/register-agent",{method:"POST",body:JSON.stringify({name:y,description:j,...z.trim()&&{genre:z}})}),ue=await re.json();if(!re.ok)throw new Error(ue.error||"Registration failed");v({linked:!0,agentId:ue.agentId,owsWallet:ue.owsWallet,txHash:ue.txHash})}catch(re){te(re instanceof Error?re.message:"Registration failed")}q(!1)},V=async()=>{if(!de.trim()||!/^0x[a-fA-F0-9]{40}$/.test(de)){I("Enter a valid wallet address (0x...)");return}Y(!0),I(null),ae(null);try{const re=await T("/api/settings/generate-binding",{method:"POST",body:JSON.stringify({humanWallet:de})}),ue=await re.json();if(!re.ok)throw new Error(ue.error||"Failed to generate binding code");ae(ue)}catch(re){I(re instanceof Error?re.message:"Failed to generate binding code")}Y(!1)},C=async(re,ue)=>{await navigator.clipboard.writeText(re),B(ue),setTimeout(()=>B(null),2e3)},K=async()=>{if(h(null),f(!1),!i||i.length<4){h("Passphrase must be at least 4 characters");return}if(i!==a){h("Passphrases do not match");return}x(!0);try{const re=await T("/api/auth/reset-passphrase",{method:"POST",body:JSON.stringify({passphrase:i})});if(!re.ok){const ue=await re.json();throw new Error(ue.error||"Reset failed")}f(!0),s(""),o(""),setTimeout(()=>f(!1),3e3)}catch(re){h(re instanceof Error?re.message:"Reset failed")}x(!1)};return d.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-6",children:[d.jsx("h2",{className:"text-accent text-lg font-bold",children:"Settings"}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Identity"}),b!=null&&b.linked?d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-sm font-medium text-accent",children:"Registered"}),d.jsxs("span",{className:"text-muted text-xs",children:["Agent #",b.agentId]})]}),b.owsWallet&&d.jsxs("p",{className:"text-muted text-xs font-mono",children:["Wallet: ",b.owsWallet.slice(0,6),"...",b.owsWallet.slice(-4)]}),b.owner&&d.jsxs("p",{className:"text-muted text-xs font-mono",children:["Owner: ",b.owner.slice(0,6),"...",b.owner.slice(-4)]}),b.txHash&&d.jsx("p",{className:"text-muted text-xs",children:d.jsx("a",{href:`https://basescan.org/tx/${b.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View transaction on BaseScan"})}),d.jsx("p",{className:"text-muted text-xs",children:d.jsx("a",{href:`https://plotlink.xyz/profile/${b.owsWallet}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View agent profile on plotlink.xyz"})})]}):d.jsxs("div",{className:"space-y-3",children:[d.jsx("p",{className:"text-muted text-xs",children:"Register this AI writer on-chain via ERC-8004. Uses your OWS wallet's existing ETH balance for gas."}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Name"}),d.jsx("input",{value:y,onChange:re=>N(re.target.value),placeholder:"AI Writer",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Description"}),d.jsx("input",{value:j,onChange:re=>E(re.target.value),placeholder:"An AI writing assistant for fiction stories",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Genre (optional)"}),d.jsx("input",{value:z,onChange:re=>O(re.target.value),placeholder:"e.g. Fiction, Sci-Fi, Fantasy",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"})]}),D&&d.jsx("p",{className:"text-error text-xs",children:D}),d.jsx("button",{onClick:R,disabled:W||!y.trim()||!j.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:W?"Registering...":"Register Agent Identity"})]})]}),d.jsxs("div",{className:"border-border rounded border p-4","data-testid":"provider-readiness",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Agent Providers"}),d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Claude"}),d.jsx("span",{className:"text-muted text-xs",children:U!=null&&U.claude.installed?"Installed":"Not detected"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Codex"}),d.jsx("span",{className:"text-muted text-xs",children:U!=null&&U.codex.installed?"Installed":"Not detected"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Codex version"}),d.jsx("span",{className:"text-muted text-xs font-mono",children:(U==null?void 0:U.codex.version)??"—"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Image generation"}),d.jsx("span",{className:"text-muted text-xs",children:(U==null?void 0:U.codex.imageGeneration)??"unknown"})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Codex auth"}),d.jsx("span",{className:"text-muted text-xs","data-testid":"codex-auth-status",children:U!=null&&U.codex.installed?U.codex.auth==="ok"?"ok":"unclear":"—"})]}),Su(U)&&d.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"codex-auth-unknown-settings",children:zp}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("span",{className:"text-foreground text-sm",children:"Last checked"}),d.jsx("span",{className:"text-muted text-xs",children:U!=null&&U.checkedAt?new Date(U.checkedAt).toLocaleString():"—"})]})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Link to PlotLink"}),b!=null&&b.owner?d.jsxs("p",{className:"text-muted text-xs",children:["Linked to owner ",d.jsxs("span",{className:"font-mono",children:[b.owner.slice(0,6),"...",b.owner.slice(-4)]})]}):d.jsxs("div",{className:"space-y-3",children:[d.jsx("p",{className:"text-muted text-xs",children:"Link this OWS wallet to your PlotLink account so your stories appear under your profile on plotlink.xyz."}),d.jsxs("div",{className:"text-muted text-xs space-y-1 pl-3",children:[d.jsx("p",{children:"1. Enter your PlotLink wallet address below"}),d.jsx("p",{children:'2. Click "Generate Binding Code"'}),d.jsx("p",{children:"3. Copy the code and paste it on plotlink.xyz → Agents → Link AI Writer"})]}),d.jsx("input",{value:de,onChange:re=>_e(re.target.value),placeholder:"Your PlotLink wallet address (0x...)",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent font-mono"}),Q&&d.jsx("p",{className:"text-error text-xs",children:Q}),d.jsx("button",{onClick:V,disabled:G||!de.trim(),className:"bg-accent text-white hover:bg-accent-dim disabled:opacity-50 w-full rounded px-4 py-2 text-sm font-medium transition-colors",children:G?"Generating...":"Generate Binding Code"}),P&&d.jsxs("div",{className:"space-y-3 mt-3",children:[d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Binding Code (signature)"}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:P.signature}),d.jsx("button",{onClick:()=>C(P.signature,"signature"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="signature"?"Copied!":"Copy"})]})]}),d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"OWS Wallet Address"}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono break-all text-foreground pr-16",children:P.owsWallet}),d.jsx("button",{onClick:()=>C(P.owsWallet,"wallet"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="wallet"?"Copied!":"Copy"})]})]}),P.agentId&&d.jsxs("div",{children:[d.jsx("label",{className:"text-muted text-xs block mb-1",children:"Agent ID"}),d.jsxs("div",{className:"relative",children:[d.jsx("div",{className:"bg-surface border-border rounded border p-2 text-xs font-mono text-foreground pr-16",children:P.agentId}),d.jsx("button",{onClick:()=>C(String(P.agentId),"agentId"),className:"absolute top-1 right-1 text-xs px-2 py-1 rounded border border-border text-muted hover:text-accent hover:border-accent transition-colors",children:A==="agentId"?"Copied!":"Copy"})]})]}),d.jsx("p",{className:"text-xs text-accent",children:'Now go to plotlink.xyz/agents and paste the values in the "Link AI Writer" section.'})]})]})]}),d.jsx(Cy,{token:e}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Reset Passphrase"}),d.jsxs("div",{className:"space-y-3",children:[d.jsx("input",{type:"password",value:i,onChange:re=>s(re.target.value),placeholder:"new passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),d.jsx("input",{type:"password",value:a,onChange:re=>o(re.target.value),placeholder:"confirm passphrase",className:"bg-surface border-border text-foreground placeholder:text-muted/50 w-full rounded border px-3 py-2 text-sm outline-none focus:border-accent"}),c&&d.jsx("p",{className:"text-error text-xs",children:c}),p&&d.jsx("p",{className:"text-xs text-accent",children:"passphrase updated"}),d.jsx("button",{onClick:K,disabled:_||!i.trim(),className:"border-border text-muted hover:border-accent hover:text-accent disabled:opacity-40 w-full rounded border px-4 py-2 text-xs font-medium transition-colors",children:_?"updating...":"update passphrase"})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Session"}),d.jsx("button",{onClick:t,className:"border-border text-muted hover:border-error hover:text-error rounded border px-4 py-2 text-xs font-medium transition-colors",children:"logout"})]})]})}const xC="http://localhost:7777";function _C({token:e}){const[t,i]=w.useState(null),s=w.useCallback((h,p)=>fetch(h,{...p,headers:{...p==null?void 0:p.headers,Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),[e]),a=w.useCallback(()=>{s(`${xC}/api/dashboard`).then(h=>h.json()).then(i)},[s]);w.useEffect(()=>{a()},[a]);const o=h=>`${h.slice(0,6)}...${h.slice(-4)}`,c=h=>{if(!h)return"Unknown date";const p=new Date(h);return isNaN(p.getTime())?"Unknown date":p.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})};return t?d.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-6",children:[d.jsx("h2",{className:"text-accent text-lg font-bold",children:"Writer Dashboard"}),d.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-accent text-lg font-bold",children:t.stories.totalPublished}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"published"})]}),d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.pendingFiles}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"pending"})]}),d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalStories}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"stories"})]}),d.jsxs("div",{className:"border-border rounded border p-3 text-center",children:[d.jsx("div",{className:"text-foreground text-lg font-bold",children:t.stories.totalFiles}),d.jsx("div",{className:"text-muted text-[10px] uppercase tracking-wider",children:"files"})]})]}),t.wallet&&d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Wallet"}),d.jsxs("div",{className:"space-y-1.5",children:[t.wallet.name&&d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Active wallet"}),d.jsx("span",{className:"text-foreground truncate pl-3 font-mono text-[10px]",children:t.wallet.name})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Address"}),d.jsx("code",{className:"text-foreground font-mono text-[10px]",children:o(t.wallet.address)})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"ETH Balance"}),d.jsxs("span",{className:"text-foreground",children:[t.wallet.ethFormatted," ETH"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"USDC Balance"}),d.jsxs("span",{className:"text-foreground",children:["$",t.wallet.usdcBalance]})]})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Profit & Loss"}),d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Total costs (gas)"}),d.jsxs("span",{className:"text-error",children:["-",t.pnl.totalCostsEth," ETH (~$",t.pnl.totalCostsUsd,")"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Royalties earned"}),d.jsxs("span",{className:"text-accent",children:["+",t.pnl.totalRoyaltiesPlot," PLOT"]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Unclaimed royalties"}),d.jsxs("span",{className:"text-foreground",children:[t.royalties.unclaimed," PLOT"]})]}),d.jsxs("div",{className:"border-border flex justify-between border-t pt-1.5 text-xs font-medium",children:[d.jsx("span",{className:"text-muted",children:"Net P&L (USD)"}),d.jsxs("span",{className:parseFloat(t.pnl.netPnlUsd)>=0?"text-accent":"text-error",children:[parseFloat(t.pnl.netPnlUsd)>=0?"+":"","$",t.pnl.netPnlUsd]})]}),d.jsxs("div",{className:"flex justify-between text-xs",children:[d.jsx("span",{className:"text-muted",children:"Stories published"}),d.jsx("span",{className:"text-foreground",children:t.costs.storiesPublished})]})]})]}),d.jsxs("div",{className:"border-border rounded border p-4",children:[d.jsx("h3",{className:"text-accent mb-3 text-xs font-bold uppercase tracking-wider",children:"Published Stories"}),t.stories.published.length===0?d.jsx("p",{className:"text-muted text-xs",children:"no published stories yet"}):d.jsx("div",{className:"space-y-3",children:t.stories.published.map(h=>d.jsxs("div",{className:"bg-surface rounded border border-border p-4",children:[d.jsxs("div",{className:"flex items-start justify-between",children:[d.jsxs("div",{children:[h.genre&&d.jsx("span",{className:"bg-accent/10 text-accent rounded px-2 py-0.5 text-[10px] font-medium",children:h.genre}),d.jsx("h4",{className:"text-foreground mt-1 text-sm font-serif font-medium",children:h.title}),d.jsx("p",{className:"text-muted mt-0.5 text-[10px] font-mono",children:h.storyName})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[h.hasNotIndexed&&d.jsx("span",{className:"rounded border border-amber-600/30 px-1.5 py-0.5 text-[9px] text-amber-700",children:"not indexed"}),d.jsxs("span",{className:"rounded border border-green-700/30 px-1.5 py-0.5 text-[9px] text-green-700",children:[h.publishedFiles," published"]})]})]}),d.jsxs("div",{className:"mt-2 grid grid-cols-3 gap-2 text-center",children:[d.jsxs("div",{className:"rounded bg-background p-1.5",children:[d.jsx("div",{className:"text-foreground text-sm font-medium",children:h.plotCount}),d.jsx("div",{className:"text-muted text-[9px]",children:"Plots"})]}),d.jsxs("div",{className:"rounded bg-background p-1.5",children:[d.jsx("div",{className:"text-foreground text-sm font-medium font-mono",children:h.storylineId?`#${h.storylineId}`:"—"}),d.jsx("div",{className:"text-muted text-[9px]",children:"Storyline"})]}),d.jsxs("div",{className:"rounded bg-background p-1.5",children:[d.jsx("div",{className:"text-foreground text-sm font-medium",children:h.totalGasCostEth??"—"}),d.jsx("div",{className:"text-muted text-[9px]",children:"Gas (ETH)"})]})]}),d.jsx("div",{className:"mt-2 space-y-1",children:h.files.map(p=>d.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:p.status==="published-not-indexed"?"text-amber-700":"text-green-700",children:p.status==="published-not-indexed"?"⚠":"✓"}),d.jsx("span",{className:"text-muted font-mono",children:p.file})]}),p.txHash&&d.jsxs("a",{href:`https://basescan.org/tx/${p.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-accent font-mono",children:["tx:",p.txHash.slice(0,8),"..."]})]},p.file))}),d.jsxs("div",{className:"mt-2 flex items-center justify-between text-[10px]",children:[d.jsx("span",{className:"text-muted",children:c(h.latestPublishedAt)}),h.storylineId&&d.jsx("a",{href:`https://plotlink.xyz/story/${h.storylineId}`,target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"})]})]},h.id))})]}),t.stories.pendingFiles>0&&d.jsx("div",{className:"border-border rounded border p-4",children:d.jsxs("p",{className:"text-muted text-xs",children:[t.stories.pendingFiles," file(s) pending publish — go to Stories to publish them."]})})]}):d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx("span",{className:"text-muted text-sm",children:"loading dashboard..."})})}const bC={published:"✓","published-not-indexed":"⚠",pending:"⏳",draft:"📝"},vC={published:"text-green-700","published-not-indexed":"text-amber-700",pending:"text-amber-700",draft:"text-muted"};function yC({authFetch:e,selectedStory:t,selectedFile:i,onSelectFile:s,onNewStory:a,untitledSessions:o=[]}){const[c,h]=w.useState([]),[p,f]=w.useState([]),[_,x]=w.useState(new Set),[b,v]=w.useState(!1),y=w.useCallback(async()=>{try{const q=await e("/api/stories");if(q.ok){const D=await q.json();h(D.stories)}}catch{}},[e]),N=w.useCallback(async()=>{try{const q=await e("/api/stories/archived");if(q.ok){const D=await q.json();f(D.stories)}}catch{}},[e]),j=w.useCallback(async q=>{try{(await e("/api/stories/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:q})})).ok&&(N(),y())}catch{}},[e,N,y]);w.useEffect(()=>{y();const q=setInterval(y,5e3);return()=>clearInterval(q)},[y]),w.useEffect(()=>{b&&N()},[b,N]),w.useEffect(()=>{t&&x(q=>new Set(q).add(t))},[t]);const E=q=>{x(D=>{const te=new Set(D);return te.has(q)?te.delete(q):te.add(q),te})},z=q=>{var te;const D=q.map(de=>{var _e;return{file:de.file,num:(_e=de.file.match(/^plot-(\d+)\.md$/))==null?void 0:_e[1]}}).filter(de=>de.num!=null).sort((de,_e)=>parseInt(_e.num)-parseInt(de.num));return D.length>0?D[0].file:q.some(de=>de.file==="genesis.md")?"genesis.md":q.some(de=>de.file==="structure.md")?"structure.md":((te=q[0])==null?void 0:te.file)??null},O=q=>{if(E(q.name),q.contentType==="cartoon")s(q.name,"");else{const D=z(q.files);D&&s(q.name,D)}},W=q=>{const D=te=>{if(te==="structure.md")return 0;if(te==="genesis.md")return 1;const de=te.match(/^plot-(\d+)\.md$/);return de?2+parseInt(de[1]):100};return[...q].sort((te,de)=>D(te.file)-D(de.file))};return b?d.jsxs("div",{className:"h-full flex flex-col",children:[d.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[d.jsx("span",{className:"text-xs font-mono text-muted",children:"Archives"}),d.jsx("span",{className:"text-xs text-muted",children:p.length})]}),d.jsx("div",{className:"px-3 py-2 border-b border-border",children:d.jsxs("button",{onClick:()=>v(!1),className:"w-full px-3 py-1.5 text-sm text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1.5",children:[d.jsx("span",{children:"←"}),d.jsx("span",{children:"Back"})]})}),d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:p.length===0?d.jsx("div",{className:"p-3 text-sm text-muted",children:d.jsx("p",{children:"No archived stories."})}):p.map(q=>d.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-surface",children:[d.jsx("span",{className:"text-sm font-medium truncate",title:q.name,children:q.title||q.name}),d.jsx("button",{onClick:()=>j(q.name),className:"text-xs text-accent hover:text-accent-dim flex-shrink-0 ml-2",children:"Restore"})]},q.name))})]}):d.jsxs("div",{className:"h-full flex flex-col",children:[d.jsxs("div",{className:"px-3 py-1.5 border-b border-border flex items-center justify-between",children:[d.jsx("span",{className:"text-xs font-mono text-muted",children:"Stories"}),d.jsx("span",{className:"text-xs text-muted",children:c.length})]}),a&&d.jsx("div",{className:"px-3 py-2 border-b border-border",children:d.jsxs("button",{onClick:a,className:"w-full px-3 py-1.5 text-sm bg-accent text-white rounded hover:bg-accent-dim flex items-center justify-center gap-1.5",children:[d.jsx("span",{children:"+"}),d.jsx("span",{children:"New Story"})]})}),d.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",children:[o.map(q=>d.jsx("div",{children:d.jsxs("button",{onClick:()=>s(q,""),className:`w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm ${t===q?"bg-surface":""}`,children:[d.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-green-600 flex-shrink-0"}),d.jsx("span",{className:"font-medium italic text-muted",children:"Untitled"})]})},q)),c.length===0&&o.length===0?d.jsxs("div",{className:"p-3 text-sm text-muted",children:[d.jsx("p",{children:"No stories yet."}),d.jsx("p",{className:"mt-1 text-xs",children:'Click "+ New Story" above to start writing.'})]}):c.filter(q=>q.name!=="_example").map(q=>d.jsxs("div",{children:[d.jsxs("button",{onClick:()=>O(q),className:"w-full px-3 py-2 text-left flex items-center gap-2 hover:bg-surface text-sm",children:[d.jsx("span",{className:"text-xs text-muted",children:_.has(q.name)?"▼":"▶"}),d.jsx("span",{className:"font-medium truncate",title:q.name,children:q.title||q.name}),q.contentType==="cartoon"&&d.jsx("span",{className:"bg-accent/10 text-accent rounded px-1.5 py-0.5 text-[10px] font-medium flex-shrink-0",children:"Cartoon"}),d.jsxs("span",{className:"ml-auto flex-shrink-0 text-xs text-muted",children:[q.publishedCount,"/",q.files.length]})]}),_.has(q.name)&&d.jsx("div",{className:"pl-4",children:W(q.files).map(D=>{const te=t===q.name&&i===D.file;return d.jsxs("button",{onClick:()=>s(q.name,D.file),className:`w-full px-3 py-1.5 text-left flex items-center gap-2 text-xs hover:bg-surface ${te?"bg-surface font-medium":""}`,children:[d.jsx("span",{className:vC[D.status],children:bC[D.status]}),d.jsx("span",{className:"truncate font-mono",children:D.file})]},D.file)})})]},q.name))]}),d.jsx("div",{className:"px-3 py-2 border-t border-border",children:d.jsx("button",{onClick:()=>v(!0),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center justify-center gap-1.5",children:d.jsx("span",{children:"Archives"})})})]})}/**
50
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
51
+ * @license MIT
52
+ *
53
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
54
+ * @license MIT
55
+ *
56
+ * Originally forked from (with the author's permission):
57
+ * Fabrice Bellard's javascript vt100 for jslinux:
58
+ * http://bellard.org/jslinux/
59
+ * Copyright (c) 2011 Fabrice Bellard
60
+ */var ky=Object.defineProperty,SC=Object.getOwnPropertyDescriptor,wC=(e,t)=>{for(var i in t)ky(e,i,{get:t[i],enumerable:!0})},fi=(e,t,i,s)=>{for(var a=s>1?void 0:s?SC(t,i):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(a=(s?c(t,i,a):c(a))||a);return s&&a&&ky(t,i,a),a},Re=(e,t)=>(i,s)=>t(i,s,e),ab="Terminal input",zf={get:()=>ab,set:e=>ab=e},lb="Too much output to announce, navigate to rows manually to read",Pf={get:()=>lb,set:e=>lb=e};function CC(e){return e.replace(/\r?\n/g,"\r")}function kC(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function EC(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function NC(e,t,i,s){if(e.stopPropagation(),e.clipboardData){let a=e.clipboardData.getData("text/plain");Ey(a,t,i,s)}}function Ey(e,t,i,s){e=CC(e),e=kC(e,i.decPrivateModes.bracketedPasteMode&&s.rawOptions.ignoreBracketedPasteMode!==!0),i.triggerDataEvent(e,!0),t.value=""}function Ny(e,t,i){let s=i.getBoundingClientRect(),a=e.clientX-s.left-10,o=e.clientY-s.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${a}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function ob(e,t,i,s,a){Ny(e,t,i),a&&s.rightClickSelect(e),t.value=s.selectionText,t.select()}function js(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Bu(e,t=0,i=e.length){let s="";for(let a=t;a<i;++a){let o=e[a];o>65535?(o-=65536,s+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):s+=String.fromCharCode(o)}return s}var TC=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let i=e.length;if(!i)return 0;let s=0,a=0;if(this._interim){let o=e.charCodeAt(a++);56320<=o&&o<=57343?t[s++]=(this._interim-55296)*1024+o-56320+65536:(t[s++]=this._interim,t[s++]=o),this._interim=0}for(let o=a;o<i;++o){let c=e.charCodeAt(o);if(55296<=c&&c<=56319){if(++o>=i)return this._interim=c,s;let h=e.charCodeAt(o);56320<=h&&h<=57343?t[s++]=(c-55296)*1024+h-56320+65536:(t[s++]=c,t[s++]=h);continue}c!==65279&&(t[s++]=c)}return s}},jC=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let i=e.length;if(!i)return 0;let s=0,a,o,c,h,p=0,f=0;if(this.interim[0]){let b=!1,v=this.interim[0];v&=(v&224)===192?31:(v&240)===224?15:7;let y=0,N;for(;(N=this.interim[++y]&63)&&y<4;)v<<=6,v|=N;let j=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,E=j-y;for(;f<E;){if(f>=i)return 0;if(N=e[f++],(N&192)!==128){f--,b=!0;break}else this.interim[y++]=N,v<<=6,v|=N&63}b||(j===2?v<128?f--:t[s++]=v:j===3?v<2048||v>=55296&&v<=57343||v===65279||(t[s++]=v):v<65536||v>1114111||(t[s++]=v)),this.interim.fill(0)}let _=i-4,x=f;for(;x<i;){for(;x<_&&!((a=e[x])&128)&&!((o=e[x+1])&128)&&!((c=e[x+2])&128)&&!((h=e[x+3])&128);)t[s++]=a,t[s++]=o,t[s++]=c,t[s++]=h,x+=4;if(a=e[x++],a<128)t[s++]=a;else if((a&224)===192){if(x>=i)return this.interim[0]=a,s;if(o=e[x++],(o&192)!==128){x--;continue}if(p=(a&31)<<6|o&63,p<128){x--;continue}t[s++]=p}else if((a&240)===224){if(x>=i)return this.interim[0]=a,s;if(o=e[x++],(o&192)!==128){x--;continue}if(x>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[x++],(c&192)!==128){x--;continue}if(p=(a&15)<<12|(o&63)<<6|c&63,p<2048||p>=55296&&p<=57343||p===65279)continue;t[s++]=p}else if((a&248)===240){if(x>=i)return this.interim[0]=a,s;if(o=e[x++],(o&192)!==128){x--;continue}if(x>=i)return this.interim[0]=a,this.interim[1]=o,s;if(c=e[x++],(c&192)!==128){x--;continue}if(x>=i)return this.interim[0]=a,this.interim[1]=o,this.interim[2]=c,s;if(h=e[x++],(h&192)!==128){x--;continue}if(p=(a&7)<<18|(o&63)<<12|(c&63)<<6|h&63,p<65536||p>1114111)continue;t[s++]=p}}return s}},Ty="",Rs=" ",Ro=class jy{constructor(){this.fg=0,this.bg=0,this.extended=new wu}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new jy;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},wu=class Ay{constructor(t=0,i=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=i}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new Ay(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},lr=class Ry extends Ro{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new wu,this.combinedData=""}static fromCharData(t){let i=new Ry;return i.setFromCharData(t),i}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?js(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let i=!1;if(t[1].length>2)i=!0;else if(t[1].length===2){let s=t[1].charCodeAt(0);if(55296<=s&&s<=56319){let a=t[1].charCodeAt(1);56320<=a&&a<=57343?this.content=(s-55296)*1024+a-56320+65536|t[2]<<22:i=!0}else i=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;i&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},cb="di$target",If="di$dependencies",Zd=new Map;function AC(e){return e[If]||[]}function $i(e){if(Zd.has(e))return Zd.get(e);let t=function(i,s,a){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");RC(t,i,a)};return t._id=e,Zd.set(e,t),t}function RC(e,t,i){t[cb]===t?t[If].push({id:e,index:i}):(t[If]=[{id:e,index:i}],t[cb]=t)}var mn=$i("BufferService"),My=$i("CoreMouseService"),ca=$i("CoreService"),MC=$i("CharsetService"),Pp=$i("InstantiationService"),Dy=$i("LogService"),gn=$i("OptionsService"),By=$i("OscLinkService"),DC=$i("UnicodeService"),Mo=$i("DecorationService"),Hf=class{constructor(e,t,i){this._bufferService=e,this._optionsService=t,this._oscLinkService=i}provideLinks(e,t){var _;let i=this._bufferService.buffer.lines.get(e-1);if(!i){t(void 0);return}let s=[],a=this._optionsService.rawOptions.linkHandler,o=new lr,c=i.getTrimmedLength(),h=-1,p=-1,f=!1;for(let x=0;x<c;x++)if(!(p===-1&&!i.hasContent(x))){if(i.loadCell(x,o),o.hasExtendedAttrs()&&o.extended.urlId)if(p===-1){p=x,h=o.extended.urlId;continue}else f=o.extended.urlId!==h;else p!==-1&&(f=!0);if(f||p!==-1&&x===c-1){let b=(_=this._oscLinkService.getLinkData(h))==null?void 0:_.uri;if(b){let v={start:{x:p+1,y:e},end:{x:x+(!f&&x===c-1?1:0),y:e}},y=!1;if(!(a!=null&&a.allowNonHttpProtocols))try{let N=new URL(b);["http:","https:"].includes(N.protocol)||(y=!0)}catch{y=!0}y||s.push({text:b,range:v,activate:(N,j)=>a?a.activate(N,j,v):BC(N,j),hover:(N,j)=>{var E;return(E=a==null?void 0:a.hover)==null?void 0:E.call(a,N,j,v)},leave:(N,j)=>{var E;return(E=a==null?void 0:a.leave)==null?void 0:E.call(a,N,j,v)}})}f=!1,o.hasExtendedAttrs()&&o.extended.urlId?(p=x,h=o.extended.urlId):(p=-1,h=-1)}}t(s)}};Hf=fi([Re(0,mn),Re(1,gn),Re(2,By)],Hf);function BC(e,t){if(confirm(`Do you want to navigate to ${t}?
61
+
62
+ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){try{i.opener=null}catch{}i.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Lu=$i("CharSizeService"),Qr=$i("CoreBrowserService"),Ip=$i("MouseService"),Jr=$i("RenderService"),LC=$i("SelectionService"),Ly=$i("CharacterJoinerService"),ol=$i("ThemeService"),Oy=$i("LinkProviderService"),OC=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ub.isErrorNoTelemetry(e)?new ub(e.message+`
63
+
64
+ `+e.stack):new Error(e.message+`
65
+
66
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},zC=new OC;function hu(e){PC(e)||zC.onUnexpectedError(e)}var Uf="Canceled";function PC(e){return e instanceof IC?!0:e instanceof Error&&e.name===Uf&&e.message===Uf}var IC=class extends Error{constructor(){super(Uf),this.name=this.message}};function HC(e){return new Error(`Illegal argument: ${e}`)}var ub=class $f extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof $f)return t;let i=new $f;return i.message=t.message,i.stack=t.stack,i}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Ff=class zy extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,zy.prototype)}};function In(e,t=0){return e[e.length-(1+t)]}var UC;(e=>{function t(o){return o<0}e.isLessThan=t;function i(o){return o<=0}e.isLessThanOrEqual=i;function s(o){return o>0}e.isGreaterThan=s;function a(o){return o===0}e.isNeitherLessOrGreaterThan=a,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(UC||(UC={}));function $C(e,t){let i=this,s=!1,a;return function(){return s||(s=!0,t||(a=e.apply(i,arguments))),a}}var Py;(e=>{function t(W){return W&&typeof W=="object"&&typeof W[Symbol.iterator]=="function"}e.is=t;let i=Object.freeze([]);function s(){return i}e.empty=s;function*a(W){yield W}e.single=a;function o(W){return t(W)?W:a(W)}e.wrap=o;function c(W){return W||i}e.from=c;function*h(W){for(let q=W.length-1;q>=0;q--)yield W[q]}e.reverse=h;function p(W){return!W||W[Symbol.iterator]().next().done===!0}e.isEmpty=p;function f(W){return W[Symbol.iterator]().next().value}e.first=f;function _(W,q){let D=0;for(let te of W)if(q(te,D++))return!0;return!1}e.some=_;function x(W,q){for(let D of W)if(q(D))return D}e.find=x;function*b(W,q){for(let D of W)q(D)&&(yield D)}e.filter=b;function*v(W,q){let D=0;for(let te of W)yield q(te,D++)}e.map=v;function*y(W,q){let D=0;for(let te of W)yield*q(te,D++)}e.flatMap=y;function*N(...W){for(let q of W)yield*q}e.concat=N;function j(W,q,D){let te=D;for(let de of W)te=q(te,de);return te}e.reduce=j;function*E(W,q,D=W.length){for(q<0&&(q+=W.length),D<0?D+=W.length:D>W.length&&(D=W.length);q<D;q++)yield W[q]}e.slice=E;function z(W,q=Number.POSITIVE_INFINITY){let D=[];if(q===0)return[D,W];let te=W[Symbol.iterator]();for(let de=0;de<q;de++){let _e=te.next();if(_e.done)return[D,e.empty()];D.push(_e.value)}return[D,{[Symbol.iterator](){return te}}]}e.consume=z;async function O(W){let q=[];for await(let D of W)q.push(D);return Promise.resolve(q)}e.asyncToArray=O})(Py||(Py={}));function aa(e){if(Py.is(e)){let t=[];for(let i of e)if(i)try{i.dispose()}catch(s){t.push(s)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function FC(...e){return ti(()=>aa(e))}function ti(e){return{dispose:$C(()=>{e()})}}var Iy=class Hy{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{aa(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Hy.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Iy.DISABLE_DISPOSED_WARNING=!1;var Ms=Iy,ft=class{constructor(){this._store=new Ms,this._store}dispose(){this._store.dispose()}_register(t){if(t===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(t)}};ft.None=Object.freeze({dispose(){}});var sl=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Zr=typeof window=="object"?window:globalThis,qf=class Wf{constructor(t){this.element=t,this.next=Wf.Undefined,this.prev=Wf.Undefined}};qf.Undefined=new qf(void 0);var si=qf,hb=class{constructor(){this._first=si.Undefined,this._last=si.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===si.Undefined}clear(){let e=this._first;for(;e!==si.Undefined;){let t=e.next;e.prev=si.Undefined,e.next=si.Undefined,e=t}this._first=si.Undefined,this._last=si.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let i=new si(e);if(this._first===si.Undefined)this._first=i,this._last=i;else if(t){let a=this._last;this._last=i,i.prev=a,a.next=i}else{let a=this._first;this._first=i,i.next=a,a.prev=i}this._size+=1;let s=!1;return()=>{s||(s=!0,this._remove(i))}}shift(){if(this._first!==si.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==si.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==si.Undefined&&e.next!==si.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===si.Undefined&&e.next===si.Undefined?(this._first=si.Undefined,this._last=si.Undefined):e.next===si.Undefined?(this._last=this._last.prev,this._last.next=si.Undefined):e.prev===si.Undefined&&(this._first=this._first.next,this._first.prev=si.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==si.Undefined;)yield e.element,e=e.next}},qC=globalThis.performance&&typeof globalThis.performance.now=="function",WC=class Uy{static create(t){return new Uy(t)}constructor(t){this._now=qC&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Zi;(e=>{e.None=()=>ft.None;function t(G,Y){return x(G,()=>{},0,void 0,!0,void 0,Y)}e.defer=t;function i(G){return(Y,Q=null,I)=>{let A=!1,B;return B=G(U=>{if(!A)return B?B.dispose():A=!0,Y.call(Q,U)},null,I),A&&B.dispose(),B}}e.once=i;function s(G,Y,Q){return f((I,A=null,B)=>G(U=>I.call(A,Y(U)),null,B),Q)}e.map=s;function a(G,Y,Q){return f((I,A=null,B)=>G(U=>{Y(U),I.call(A,U)},null,B),Q)}e.forEach=a;function o(G,Y,Q){return f((I,A=null,B)=>G(U=>Y(U)&&I.call(A,U),null,B),Q)}e.filter=o;function c(G){return G}e.signal=c;function h(...G){return(Y,Q=null,I)=>{let A=FC(...G.map(B=>B(U=>Y.call(Q,U))));return _(A,I)}}e.any=h;function p(G,Y,Q,I){let A=Q;return s(G,B=>(A=Y(A,B),A),I)}e.reduce=p;function f(G,Y){let Q,I={onWillAddFirstListener(){Q=G(A.fire,A)},onDidRemoveLastListener(){Q==null||Q.dispose()}},A=new we(I);return Y==null||Y.add(A),A.event}function _(G,Y){return Y instanceof Array?Y.push(G):Y&&Y.add(G),G}function x(G,Y,Q=100,I=!1,A=!1,B,U){let ge,T,R,V=0,C,K={leakWarningThreshold:B,onWillAddFirstListener(){ge=G(ue=>{V++,T=Y(T,ue),I&&!R&&(re.fire(T),T=void 0),C=()=>{let $=T;T=void 0,R=void 0,(!I||V>1)&&re.fire($),V=0},typeof Q=="number"?(clearTimeout(R),R=setTimeout(C,Q)):R===void 0&&(R=0,queueMicrotask(C))})},onWillRemoveListener(){A&&V>0&&(C==null||C())},onDidRemoveLastListener(){C=void 0,ge.dispose()}},re=new we(K);return U==null||U.add(re),re.event}e.debounce=x;function b(G,Y=0,Q){return e.debounce(G,(I,A)=>I?(I.push(A),I):[A],Y,void 0,!0,void 0,Q)}e.accumulate=b;function v(G,Y=(I,A)=>I===A,Q){let I=!0,A;return o(G,B=>{let U=I||!Y(B,A);return I=!1,A=B,U},Q)}e.latch=v;function y(G,Y,Q){return[e.filter(G,Y,Q),e.filter(G,I=>!Y(I),Q)]}e.split=y;function N(G,Y=!1,Q=[],I){let A=Q.slice(),B=G(T=>{A?A.push(T):ge.fire(T)});I&&I.add(B);let U=()=>{A==null||A.forEach(T=>ge.fire(T)),A=null},ge=new we({onWillAddFirstListener(){B||(B=G(T=>ge.fire(T)),I&&I.add(B))},onDidAddFirstListener(){A&&(Y?setTimeout(U):U())},onDidRemoveLastListener(){B&&B.dispose(),B=null}});return I&&I.add(ge),ge.event}e.buffer=N;function j(G,Y){return(Q,I,A)=>{let B=Y(new z);return G(function(U){let ge=B.evaluate(U);ge!==E&&Q.call(I,ge)},void 0,A)}}e.chain=j;let E=Symbol("HaltChainable");class z{constructor(){this.steps=[]}map(Y){return this.steps.push(Y),this}forEach(Y){return this.steps.push(Q=>(Y(Q),Q)),this}filter(Y){return this.steps.push(Q=>Y(Q)?Q:E),this}reduce(Y,Q){let I=Q;return this.steps.push(A=>(I=Y(I,A),I)),this}latch(Y=(Q,I)=>Q===I){let Q=!0,I;return this.steps.push(A=>{let B=Q||!Y(A,I);return Q=!1,I=A,B?A:E}),this}evaluate(Y){for(let Q of this.steps)if(Y=Q(Y),Y===E)break;return Y}}function O(G,Y,Q=I=>I){let I=(...ge)=>U.fire(Q(...ge)),A=()=>G.on(Y,I),B=()=>G.removeListener(Y,I),U=new we({onWillAddFirstListener:A,onDidRemoveLastListener:B});return U.event}e.fromNodeEventEmitter=O;function W(G,Y,Q=I=>I){let I=(...ge)=>U.fire(Q(...ge)),A=()=>G.addEventListener(Y,I),B=()=>G.removeEventListener(Y,I),U=new we({onWillAddFirstListener:A,onDidRemoveLastListener:B});return U.event}e.fromDOMEventEmitter=W;function q(G){return new Promise(Y=>i(G)(Y))}e.toPromise=q;function D(G){let Y=new we;return G.then(Q=>{Y.fire(Q)},()=>{Y.fire(void 0)}).finally(()=>{Y.dispose()}),Y.event}e.fromPromise=D;function te(G,Y){return G(Q=>Y.fire(Q))}e.forward=te;function de(G,Y,Q){return Y(Q),G(I=>Y(I))}e.runAndSubscribe=de;class _e{constructor(Y,Q){this._observable=Y,this._counter=0,this._hasChanged=!1;let I={onWillAddFirstListener:()=>{Y.addObserver(this)},onDidRemoveLastListener:()=>{Y.removeObserver(this)}};this.emitter=new we(I),Q&&Q.add(this.emitter)}beginUpdate(Y){this._counter++}handlePossibleChange(Y){}handleChange(Y,Q){this._hasChanged=!0}endUpdate(Y){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function P(G,Y){return new _e(G,Y).emitter.event}e.fromObservable=P;function ae(G){return(Y,Q,I)=>{let A=0,B=!1,U={beginUpdate(){A++},endUpdate(){A--,A===0&&(G.reportChanges(),B&&(B=!1,Y.call(Q)))},handlePossibleChange(){},handleChange(){B=!0}};G.addObserver(U),G.reportChanges();let ge={dispose(){G.removeObserver(U)}};return I instanceof Ms?I.add(ge):Array.isArray(I)&&I.push(ge),ge}}e.fromObservableLight=ae})(Zi||(Zi={}));var Gf=class Yf{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Yf._idPool++}`,Yf.all.add(this)}start(t){this._stopWatch=new WC,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Gf.all=new Set,Gf._idPool=0;var GC=Gf,YC=-1,$y=class Fy{constructor(t,i,s=(Fy._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=i,this.name=s,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,i){let s=this.threshold;if(s<=0||i<s)return;this._stacks||(this._stacks=new Map);let a=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,a+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=s*.5;let[o,c]=this.getMostFrequentStack(),h=`[${this.name}] potential listener LEAK detected, having ${i} listeners already. MOST frequent listener (${c}):`;console.warn(h),console.warn(o);let p=new XC(h,o);this._errorHandler(p)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,i=0;for(let[s,a]of this._stacks)(!t||i<a)&&(t=[s,a],i=a);return t}};$y._idPool=1;var KC=$y,VC=class qy{constructor(t){this.value=t}static create(){let t=new Error;return new qy(t.stack??"")}print(){console.warn(this.value.split(`
67
+ `).slice(2).join(`
68
+ `))}},XC=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},ZC=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},QC=0,Qd=class{constructor(e){this.value=e,this.id=QC++}},JC=2,ek,we=class{constructor(t){var i,s,a,o;this._size=0,this._options=t,this._leakageMon=(i=this._options)!=null&&i.leakWarningThreshold?new KC((t==null?void 0:t.onListenerError)??hu,((s=this._options)==null?void 0:s.leakWarningThreshold)??YC):void 0,this._perfMon=(a=this._options)!=null&&a._profName?new GC(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,i,s,a;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(s=(i=this._options)==null?void 0:i.onDidRemoveLastListener)==null||s.call(i),(a=this._leakageMon)==null||a.dispose())}get event(){return this._event??(this._event=(t,i,s)=>{var h,p,f,_,x;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let b=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(b);let v=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],y=new ZC(`${b}. HINT: Stack shows most frequent listener (${v[1]}-times)`,v[0]);return(((h=this._options)==null?void 0:h.onListenerError)||hu)(y),ft.None}if(this._disposed)return ft.None;i&&(t=t.bind(i));let a=new Qd(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(a.stack=VC.create(),o=this._leakageMon.check(a.stack,this._size+1)),this._listeners?this._listeners instanceof Qd?(this._deliveryQueue??(this._deliveryQueue=new tk),this._listeners=[this._listeners,a]):this._listeners.push(a):((f=(p=this._options)==null?void 0:p.onWillAddFirstListener)==null||f.call(p,this),this._listeners=a,(x=(_=this._options)==null?void 0:_.onDidAddFirstListener)==null||x.call(_,this)),this._size++;let c=ti(()=>{o==null||o(),this._removeListener(a)});return s instanceof Ms?s.add(c):Array.isArray(s)&&s.push(c),c}),this._event}_removeListener(t){var o,c,h,p;if((c=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||c.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(p=(h=this._options)==null?void 0:h.onDidRemoveLastListener)==null||p.call(h,this),this._size=0;return}let i=this._listeners,s=i.indexOf(t);if(s===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,i[s]=void 0;let a=this._deliveryQueue.current===this;if(this._size*JC<=i.length){let f=0;for(let _=0;_<i.length;_++)i[_]?i[f++]=i[_]:a&&(this._deliveryQueue.end--,f<this._deliveryQueue.i&&this._deliveryQueue.i--);i.length=f}}_deliver(t,i){var a;if(!t)return;let s=((a=this._options)==null?void 0:a.onListenerError)||hu;if(!s){t.value(i);return}try{t.value(i)}catch(o){s(o)}}_deliverQueue(t){let i=t.current._listeners;for(;t.i<t.end;)this._deliver(i[t.i++],t.value);t.reset()}fire(t){var i,s,a,o;if((i=this._deliveryQueue)!=null&&i.current&&(this._deliverQueue(this._deliveryQueue),(s=this._perfMon)==null||s.stop()),(a=this._perfMon)==null||a.start(this._size),this._listeners)if(this._listeners instanceof Qd)this._deliver(this._listeners,t);else{let c=this._deliveryQueue;c.enqueue(this,t,this._listeners.length),this._deliverQueue(c)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},tk=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,i){this.i=0,this.end=i,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Kf=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new we,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new we,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,i){if(this.getZoomLevel(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToZoomLevel.set(s,t),this._onDidChangeZoomLevel.fire(s)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,i){this.mapWindowIdToZoomFactor.set(this.getWindowId(i),t)}setFullscreen(t,i){if(this.isFullscreen(i)===t)return;let s=this.getWindowId(i);this.mapWindowIdToFullScreen.set(s,t),this._onDidChangeFullscreen.fire(s)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};Kf.INSTANCE=new Kf;var Hp=Kf;function ik(e,t,i){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",i)}Hp.INSTANCE.onDidChangeZoomLevel;function nk(e){return Hp.INSTANCE.getZoomFactor(e)}Hp.INSTANCE.onDidChangeFullscreen;var cl=typeof navigator=="object"?navigator.userAgent:"",Vf=cl.indexOf("Firefox")>=0,rk=cl.indexOf("AppleWebKit")>=0,Up=cl.indexOf("Chrome")>=0,sk=!Up&&cl.indexOf("Safari")>=0;cl.indexOf("Electron/")>=0;cl.indexOf("Android")>=0;var Jd=!1;if(typeof Zr.matchMedia=="function"){let e=Zr.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Zr.matchMedia("(display-mode: fullscreen)");Jd=e.matches,ik(Zr,e,({matches:i})=>{Jd&&t.matches||(Jd=i)})}var tl="en",Xf=!1,Zf=!1,du=!1,Wy=!1,Vc,fu=tl,db=tl,ak,mr,sa=globalThis,Xi,yy;typeof sa.vscode<"u"&&typeof sa.vscode.process<"u"?Xi=sa.vscode.process:typeof process<"u"&&typeof((yy=process==null?void 0:process.versions)==null?void 0:yy.node)=="string"&&(Xi=process);var Sy,lk=typeof((Sy=Xi==null?void 0:Xi.versions)==null?void 0:Sy.electron)=="string",ok=lk&&(Xi==null?void 0:Xi.type)==="renderer",wy;if(typeof Xi=="object"){Xf=Xi.platform==="win32",Zf=Xi.platform==="darwin",du=Xi.platform==="linux",du&&Xi.env.SNAP&&Xi.env.SNAP_REVISION,Xi.env.CI||Xi.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Vc=tl,fu=tl;let e=Xi.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Vc=t.userLocale,db=t.osLocale,fu=t.resolvedLanguage||tl,ak=(wy=t.languagePack)==null?void 0:wy.translationsConfigFile}catch{}Wy=!0}else typeof navigator=="object"&&!ok?(mr=navigator.userAgent,Xf=mr.indexOf("Windows")>=0,Zf=mr.indexOf("Macintosh")>=0,(mr.indexOf("Macintosh")>=0||mr.indexOf("iPad")>=0||mr.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,du=mr.indexOf("Linux")>=0,(mr==null?void 0:mr.indexOf("Mobi"))>=0,fu=globalThis._VSCODE_NLS_LANGUAGE||tl,Vc=navigator.language.toLowerCase(),db=Vc):console.error("Unable to resolve platform.");var Gy=Xf,Nr=Zf,ck=du,fb=Wy,Tr=mr,ks=fu,uk;(e=>{function t(){return ks}e.value=t;function i(){return ks.length===2?ks==="en":ks.length>=3?ks[0]==="e"&&ks[1]==="n"&&ks[2]==="-":!1}e.isDefaultVariant=i;function s(){return ks==="en"}e.isDefault=s})(uk||(uk={}));var hk=typeof sa.postMessage=="function"&&!sa.importScripts;(()=>{if(hk){let e=[];sa.addEventListener("message",i=>{if(i.data&&i.data.vscodeScheduleAsyncWork)for(let s=0,a=e.length;s<a;s++){let o=e[s];if(o.id===i.data.vscodeScheduleAsyncWork){e.splice(s,1),o.callback();return}}});let t=0;return i=>{let s=++t;e.push({id:s,callback:i}),sa.postMessage({vscodeScheduleAsyncWork:s},"*")}}return e=>setTimeout(e)})();var dk=!!(Tr&&Tr.indexOf("Chrome")>=0);Tr&&Tr.indexOf("Firefox")>=0;!dk&&Tr&&Tr.indexOf("Safari")>=0;Tr&&Tr.indexOf("Edg/")>=0;Tr&&Tr.indexOf("Android")>=0;var Ka=typeof navigator=="object"?navigator:{};fb||document.queryCommandSupported&&document.queryCommandSupported("copy")||Ka&&Ka.clipboard&&Ka.clipboard.writeText,fb||Ka&&Ka.clipboard&&Ka.clipboard.readText;var $p=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},ef=new $p,pb=new $p,mb=new $p,fk=new Array(230),Yy;(e=>{function t(h){return ef.keyCodeToStr(h)}e.toString=t;function i(h){return ef.strToKeyCode(h)}e.fromString=i;function s(h){return pb.keyCodeToStr(h)}e.toUserSettingsUS=s;function a(h){return mb.keyCodeToStr(h)}e.toUserSettingsGeneral=a;function o(h){return pb.strToKeyCode(h)||mb.strToKeyCode(h)}e.fromUserSettings=o;function c(h){if(h>=98&&h<=113)return null;switch(h){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return ef.keyCodeToStr(h)}e.toElectronAccelerator=c})(Yy||(Yy={}));var pk=class Ky{constructor(t,i,s,a,o){this.ctrlKey=t,this.shiftKey=i,this.altKey=s,this.metaKey=a,this.keyCode=o}equals(t){return t instanceof Ky&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",i=this.shiftKey?"1":"0",s=this.altKey?"1":"0",a=this.metaKey?"1":"0";return`K${t}${i}${s}${a}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new mk([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},mk=class{constructor(e){if(e.length===0)throw HC("chords");this.chords=e}getHashCode(){let e="";for(let t=0,i=this.chords.length;t<i;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function gk(e){if(e.charCode){let i=String.fromCharCode(e.charCode).toUpperCase();return Yy.fromString(i)}let t=e.keyCode;if(t===3)return 7;if(Vf)switch(t){case 59:return 85;case 60:if(ck)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Nr)return 57;break}else if(rk&&(Nr&&t===93||!Nr&&t===92))return 57;return fk[t]||0}var xk=Nr?256:2048,_k=512,bk=1024,vk=Nr?2048:256,gb=class{constructor(e){var i;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(i=t.getModifierState)==null?void 0:i.call(t,"AltGraph"),this.keyCode=gk(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=xk),this.altKey&&(t|=_k),this.shiftKey&&(t|=bk),this.metaKey&&(t|=vk),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new pk(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},xb=new WeakMap;function yk(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,i=e.parent.location;if(t.origin!=="null"&&i.origin!=="null"&&t.origin!==i.origin)return null}catch{return null}return e.parent}var Sk=class{static getSameOriginWindowChain(e){let t=xb.get(e);if(!t){t=[],xb.set(e,t);let i=e,s;do s=yk(i),s?t.push({window:new WeakRef(i),iframeElement:i.frameElement||null}):t.push({window:new WeakRef(i),iframeElement:null}),i=s;while(i)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let i=0,s=0,a=this.getSameOriginWindowChain(e);for(let o of a){let c=o.window.deref();if(i+=(c==null?void 0:c.scrollY)??0,s+=(c==null?void 0:c.scrollX)??0,c===t||!o.iframeElement)break;let h=o.iframeElement.getBoundingClientRect();i+=h.top,s+=h.left}return{top:i,left:s}}},Xc=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let i=Sk.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=i.left,this.posy-=i.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},_b=class{constructor(e,t=0,i=0){var a;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=i,this.deltaX=t;let s=!1;if(Up){let o=navigator.userAgent.match(/Chrome\/(\d+)/);s=(o?parseInt(o[1]):123)<=122}if(e){let o=e,c=e,h=((a=e.view)==null?void 0:a.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")s?this.deltaY=o.wheelDeltaY/(120*h):this.deltaY=o.wheelDeltaY/120;else if(typeof c.VERTICAL_AXIS<"u"&&c.axis===c.VERTICAL_AXIS)this.deltaY=-c.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Vf&&!Nr?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")sk&&Gy?this.deltaX=-(o.wheelDeltaX/120):s?this.deltaX=o.wheelDeltaX/(120*h):this.deltaX=o.wheelDeltaX/120;else if(typeof c.HORIZONTAL_AXIS<"u"&&c.axis===c.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let p=e;p.deltaMode===p.DOM_DELTA_LINE?Vf&&!Nr?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(s?this.deltaY=e.wheelDelta/(120*h):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Vy=Object.freeze(function(e,t){let i=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(i)}}}),wk;(e=>{function t(i){return i===e.None||i===e.Cancelled||i instanceof Ck?!0:!i||typeof i!="object"?!1:typeof i.isCancellationRequested=="boolean"&&typeof i.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Zi.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vy})})(wk||(wk={}));var Ck=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vy:(this._emitter||(this._emitter=new we),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},Fp=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Ff("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Ff("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},kk=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,i=globalThis){if(this.isDisposed)throw new Ff("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let s=i.setInterval(()=>{e()},t);this.disposable=ti(()=>{i.clearInterval(s),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Ek;(e=>{async function t(s){let a,o=await Promise.all(s.map(c=>c.then(h=>h,h=>{a||(a=h)})));if(typeof a<"u")throw a;return o}e.settled=t;function i(s){return new Promise(async(a,o)=>{try{await s(a,o)}catch(c){o(c)}})}e.withAsyncBody=i})(Ek||(Ek={}));var bb=class nr{static fromArray(t){return new nr(i=>{i.emitMany(t)})}static fromPromise(t){return new nr(async i=>{i.emitMany(await t)})}static fromPromises(t){return new nr(async i=>{await Promise.all(t.map(async s=>i.emitOne(await s)))})}static merge(t){return new nr(async i=>{await Promise.all(t.map(async s=>{for await(let a of s)i.emitOne(a)}))})}constructor(t,i){this._state=0,this._results=[],this._error=null,this._onReturn=i,this._onStateChanged=new we,queueMicrotask(async()=>{let s={emitOne:a=>this.emitOne(a),emitMany:a=>this.emitMany(a),reject:a=>this.reject(a)};try{await Promise.resolve(t(s)),this.resolve()}catch(a){this.reject(a)}finally{s.emitOne=void 0,s.emitMany=void 0,s.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Zi.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var i;return(i=this._onReturn)==null||i.call(this),{done:!0,value:void 0}}}}static map(t,i){return new nr(async s=>{for await(let a of t)s.emitOne(i(a))})}map(t){return nr.map(this,t)}static filter(t,i){return new nr(async s=>{for await(let a of t)i(a)&&s.emitOne(a)})}filter(t){return nr.filter(this,t)}static coalesce(t){return nr.filter(t,i=>!!i)}coalesce(){return nr.coalesce(this)}static async toPromise(t){let i=[];for await(let s of t)i.push(s);return i}toPromise(){return nr.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};bb.EMPTY=bb.fromArray([]);var{getWindow:kr,getWindowId:Nk,onDidRegisterWindow:Tk}=(function(){let e=new Map,t={window:Zr,disposables:new Ms};e.set(Zr.vscodeWindowId,t);let i=new we,s=new we,a=new we;function o(c,h){return(typeof c=="number"?e.get(c):void 0)??(h?t:void 0)}return{onDidRegisterWindow:i.event,onWillUnregisterWindow:a.event,onDidUnregisterWindow:s.event,registerWindow(c){if(e.has(c.vscodeWindowId))return ft.None;let h=new Ms,p={window:c,disposables:h.add(new Ms)};return e.set(c.vscodeWindowId,p),h.add(ti(()=>{e.delete(c.vscodeWindowId),s.fire(c)})),h.add(Ke(c,Bi.BEFORE_UNLOAD,()=>{a.fire(c)})),i.fire(p),h},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(c){return c.vscodeWindowId},hasWindow(c){return e.has(c)},getWindowById:o,getWindow(c){var f;let h=c;if((f=h==null?void 0:h.ownerDocument)!=null&&f.defaultView)return h.ownerDocument.defaultView.window;let p=c;return p!=null&&p.view?p.view.window:Zr},getDocument(c){return kr(c).document}}})(),jk=class{constructor(e,t,i,s){this._node=e,this._type=t,this._handler=i,this._options=s||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Ke(e,t,i,s){return new jk(e,t,i,s)}var vb=function(e,t,i,s){return Ke(e,t,i,s)},qp,Ak=class extends kk{constructor(e){super(),this.defaultTarget=e&&kr(e)}cancelAndSet(e,t,i){return super.cancelAndSet(e,t,i??this.defaultTarget)}},yb=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){hu(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,i=new Map,s=new Map,a=o=>{i.set(o,!1);let c=e.get(o)??[];for(t.set(o,c),e.set(o,[]),s.set(o,!0);c.length>0;)c.sort(yb.sort),c.shift().execute();s.set(o,!1)};qp=(o,c,h=0)=>{let p=Nk(o),f=new yb(c,h),_=e.get(p);return _||(_=[],e.set(p,_)),_.push(f),i.get(p)||(i.set(p,!0),o.requestAnimationFrame(()=>a(p))),f}})();function Rk(e){let t=e.getBoundingClientRect(),i=kr(e);return{left:t.left+i.scrollX,top:t.top+i.scrollY,width:t.width,height:t.height}}var Bi={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Mk=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=kn(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=kn(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=kn(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=kn(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=kn(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=kn(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=kn(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=kn(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=kn(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=kn(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=kn(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=kn(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=kn(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=kn(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function kn(e){return typeof e=="number"?`${e}px`:e}function vo(e){return new Mk(e)}var Xy=class{constructor(){this._hooks=new Ms,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let i=this._onStopCallback;this._onStopCallback=null,e&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,i,s,a){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=a;let o=e;try{e.setPointerCapture(t),this._hooks.add(ti(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=kr(e)}this._hooks.add(Ke(o,Bi.POINTER_MOVE,c=>{if(c.buttons!==i){this.stopMonitoring(!0);return}c.preventDefault(),this._pointerMoveCallback(c)})),this._hooks.add(Ke(o,Bi.POINTER_UP,c=>this.stopMonitoring(!0)))}};function Dk(e,t,i){let s=null,a=null;if(typeof i.value=="function"?(s="value",a=i.value,a.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof i.get=="function"&&(s="get",a=i.get),!a)throw new Error("not supported");let o=`$memoize$${t}`;i[s]=function(...c){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:a.apply(this,c)}),this[o]}}var wr;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(wr||(wr={}));var mo=class nn extends ft{constructor(){super(),this.dispatched=!1,this.targets=new hb,this.ignoreTargets=new hb,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Zi.runAndSubscribe(Tk,({window:t,disposables:i})=>{i.add(Ke(t.document,"touchstart",s=>this.onTouchStart(s),{passive:!1})),i.add(Ke(t.document,"touchend",s=>this.onTouchEnd(t,s))),i.add(Ke(t.document,"touchmove",s=>this.onTouchMove(s),{passive:!1}))},{window:Zr,disposables:this._store}))}static addTarget(t){if(!nn.isTouchDevice())return ft.None;nn.INSTANCE||(nn.INSTANCE=new nn);let i=nn.INSTANCE.targets.push(t);return ti(i)}static ignoreTarget(t){if(!nn.isTouchDevice())return ft.None;nn.INSTANCE||(nn.INSTANCE=new nn);let i=nn.INSTANCE.ignoreTargets.push(t);return ti(i)}static isTouchDevice(){return"ontouchstart"in Zr||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let i=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let s=0,a=t.targetTouches.length;s<a;s++){let o=t.targetTouches.item(s);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:i,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[i],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let c=this.newGestureEvent(wr.Start,o.target);c.pageX=o.pageX,c.pageY=o.pageY,this.dispatchEvent(c)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,i){let s=Date.now(),a=Object.keys(this.activeTouches).length;for(let o=0,c=i.changedTouches.length;o<c;o++){let h=i.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(h.identifier))){console.warn("move of an UNKNOWN touch",h);continue}let p=this.activeTouches[h.identifier],f=Date.now()-p.initialTimeStamp;if(f<nn.HOLD_DELAY&&Math.abs(p.initialPageX-In(p.rollingPageX))<30&&Math.abs(p.initialPageY-In(p.rollingPageY))<30){let _=this.newGestureEvent(wr.Tap,p.initialTarget);_.pageX=In(p.rollingPageX),_.pageY=In(p.rollingPageY),this.dispatchEvent(_)}else if(f>=nn.HOLD_DELAY&&Math.abs(p.initialPageX-In(p.rollingPageX))<30&&Math.abs(p.initialPageY-In(p.rollingPageY))<30){let _=this.newGestureEvent(wr.Contextmenu,p.initialTarget);_.pageX=In(p.rollingPageX),_.pageY=In(p.rollingPageY),this.dispatchEvent(_)}else if(a===1){let _=In(p.rollingPageX),x=In(p.rollingPageY),b=In(p.rollingTimestamps)-p.rollingTimestamps[0],v=_-p.rollingPageX[0],y=x-p.rollingPageY[0],N=[...this.targets].filter(j=>p.initialTarget instanceof Node&&j.contains(p.initialTarget));this.inertia(t,N,s,Math.abs(v)/b,v>0?1:-1,_,Math.abs(y)/b,y>0?1:-1,x)}this.dispatchEvent(this.newGestureEvent(wr.End,p.initialTarget)),delete this.activeTouches[h.identifier]}this.dispatched&&(i.preventDefault(),i.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,i){let s=document.createEvent("CustomEvent");return s.initEvent(t,!1,!0),s.initialTarget=i,s.tapCount=0,s}dispatchEvent(t){if(t.type===wr.Tap){let i=new Date().getTime(),s=0;i-this._lastSetTapCountTime>nn.CLEAR_TAP_COUNT_TIME?s=1:s=2,this._lastSetTapCountTime=i,t.tapCount=s}else(t.type===wr.Change||t.type===wr.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let s of this.ignoreTargets)if(s.contains(t.initialTarget))return;let i=[];for(let s of this.targets)if(s.contains(t.initialTarget)){let a=0,o=t.initialTarget;for(;o&&o!==s;)a++,o=o.parentElement;i.push([a,s])}i.sort((s,a)=>s[0]-a[0]);for(let[s,a]of i)a.dispatchEvent(t),this.dispatched=!0}}inertia(t,i,s,a,o,c,h,p,f){this.handle=qp(t,()=>{let _=Date.now(),x=_-s,b=0,v=0,y=!0;a+=nn.SCROLL_FRICTION*x,h+=nn.SCROLL_FRICTION*x,a>0&&(y=!1,b=o*a*x),h>0&&(y=!1,v=p*h*x);let N=this.newGestureEvent(wr.Change);N.translationX=b,N.translationY=v,i.forEach(j=>j.dispatchEvent(N)),y||this.inertia(t,i,_,a,o,c+b,h,p,f+v)})}onTouchMove(t){let i=Date.now();for(let s=0,a=t.changedTouches.length;s<a;s++){let o=t.changedTouches.item(s);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let c=this.activeTouches[o.identifier],h=this.newGestureEvent(wr.Change,c.initialTarget);h.translationX=o.pageX-In(c.rollingPageX),h.translationY=o.pageY-In(c.rollingPageY),h.pageX=o.pageX,h.pageY=o.pageY,this.dispatchEvent(h),c.rollingPageX.length>3&&(c.rollingPageX.shift(),c.rollingPageY.shift(),c.rollingTimestamps.shift()),c.rollingPageX.push(o.pageX),c.rollingPageY.push(o.pageY),c.rollingTimestamps.push(i)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};mo.SCROLL_FRICTION=-.005,mo.HOLD_DELAY=700,mo.CLEAR_TAP_COUNT_TIME=400,fi([Dk],mo,"isTouchDevice",1);var Bk=mo,Wp=class extends ft{onclick(e,t){this._register(Ke(e,Bi.CLICK,i=>t(new Xc(kr(e),i))))}onmousedown(e,t){this._register(Ke(e,Bi.MOUSE_DOWN,i=>t(new Xc(kr(e),i))))}onmouseover(e,t){this._register(Ke(e,Bi.MOUSE_OVER,i=>t(new Xc(kr(e),i))))}onmouseleave(e,t){this._register(Ke(e,Bi.MOUSE_LEAVE,i=>t(new Xc(kr(e),i))))}onkeydown(e,t){this._register(Ke(e,Bi.KEY_DOWN,i=>t(new gb(i))))}onkeyup(e,t){this._register(Ke(e,Bi.KEY_UP,i=>t(new gb(i))))}oninput(e,t){this._register(Ke(e,Bi.INPUT,t))}onblur(e,t){this._register(Ke(e,Bi.BLUR,t))}onfocus(e,t){this._register(Ke(e,Bi.FOCUS,t))}onchange(e,t){this._register(Ke(e,Bi.CHANGE,t))}ignoreGesture(e){return Bk.ignoreTarget(e)}},Sb=11,Lk=class extends Wp{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Sb+"px",this.domNode.style.height=Sb+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Xy),this._register(vb(this.bgDomNode,Bi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(vb(this.domNode,Bi.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Ak),this._pointerdownScheduleRepeatTimer=this._register(new Fp)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,kr(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,i=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Ok=class Qf{constructor(t,i,s,a,o,c,h){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(i=i|0,s=s|0,a=a|0,o=o|0,c=c|0,h=h|0),this.rawScrollLeft=a,this.rawScrollTop=h,i<0&&(i=0),a+i>s&&(a=s-i),a<0&&(a=0),o<0&&(o=0),h+o>c&&(h=c-o),h<0&&(h=0),this.width=i,this.scrollWidth=s,this.scrollLeft=a,this.height=o,this.scrollHeight=c,this.scrollTop=h}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,i){return new Qf(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,i?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,i?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Qf(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,i){let s=this.width!==t.width,a=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,c=this.height!==t.height,h=this.scrollHeight!==t.scrollHeight,p=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:i,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:s,scrollWidthChanged:a,scrollLeftChanged:o,heightChanged:c,scrollHeightChanged:h,scrollTopChanged:p}}},zk=class extends ft{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Ok(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var s;let i=this._state.withScrollDimensions(e,t);this._setState(i,!!this._smoothScrolling),(s=this._smoothScrolling)==null||s.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let i=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===i.scrollLeft&&this._smoothScrolling.to.scrollTop===i.scrollTop)return;let s;t?s=new Cb(this._smoothScrolling.from,i,this._smoothScrolling.startTime,this._smoothScrolling.duration):s=this._smoothScrolling.combine(this._state,i,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=s}else{let i=this._state.withScrollPosition(e);this._smoothScrolling=Cb.start(this._state,i,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let i=this._state;i.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(i,t)))}},wb=class{constructor(e,t,i){this.scrollLeft=e,this.scrollTop=t,this.isDone=i}};function tf(e,t){let i=t-e;return function(s){return e+i*Hk(s)}}function Pk(e,t,i){return function(s){return s<i?e(s/i):t((s-i)/(1-i))}}var Cb=class Jf{constructor(t,i,s,a){this.from=t,this.to=i,this.duration=a,this.startTime=s,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,i,s){if(Math.abs(t-i)>2.5*s){let a,o;return t<i?(a=t+.75*s,o=i-.75*s):(a=t-.75*s,o=i+.75*s),Pk(tf(t,a),tf(o,i),.33)}return tf(t,i)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let i=(t-this.startTime)/this.duration;if(i<1){let s=this.scrollLeft(i),a=this.scrollTop(i);return new wb(s,a,!1)}return new wb(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,i,s){return Jf.start(t,i,s)}static start(t,i,s){s=s+10;let a=Date.now()-10;return new Jf(t,i,a,s)}};function Ik(e){return Math.pow(e,3)}function Hk(e){return 1-Ik(1-e)}var Uk=class extends ft{constructor(e,t,i){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=i,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new Fp)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},$k=140,Zy=class extends Wp{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Uk(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Xy),this._shouldRender=!0,this.domNode=vo(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Ke(this.domNode.domNode,Bi.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Lk(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,i,s){this.slider=vo(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof i=="number"&&this.slider.setWidth(i),typeof s=="number"&&this.slider.setHeight(s),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Ke(this.slider.domNode,Bi.POINTER_DOWN,a=>{a.button===0&&(a.preventDefault(),this._sliderPointerDown(a))})),this.onclick(this.slider.domNode,a=>{a.leftButton&&a.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,i=t+this._scrollbarState.getSliderPosition(),s=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),a=this._sliderPointerPosition(e);i<=a&&a<=s?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,i;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,i=e.offsetY;else{let a=Rk(this.domNode.domNode);t=e.pageX-a.left,i=e.pageY-a.top}let s=this._pointerDownRelativePosition(t,i);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(s):this._scrollbarState.getDesiredScrollPositionFromOffset(s)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),i=this._sliderOrthogonalPointerPosition(e),s=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,a=>{let o=this._sliderOrthogonalPointerPosition(a),c=Math.abs(o-i);if(Gy&&c>$k){this._setDesiredScrollPositionNow(s.getScrollPosition());return}let h=this._sliderPointerPosition(a)-t;this._setDesiredScrollPositionNow(s.getDesiredScrollPositionFromDelta(h))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Qy=class ep{constructor(t,i,s,a,o,c){this._scrollbarSize=Math.round(i),this._oppositeScrollbarSize=Math.round(s),this._arrowSize=Math.round(t),this._visibleSize=a,this._scrollSize=o,this._scrollPosition=c,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new ep(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let i=Math.round(t);return this._visibleSize!==i?(this._visibleSize=i,this._refreshComputedValues(),!0):!1}setScrollSize(t){let i=Math.round(t);return this._scrollSize!==i?(this._scrollSize=i,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let i=Math.round(t);return this._scrollPosition!==i?(this._scrollPosition=i,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,i,s,a,o){let c=Math.max(0,s-t),h=Math.max(0,c-2*i),p=a>0&&a>s;if(!p)return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(h),computedSliderRatio:0,computedSliderPosition:0};let f=Math.round(Math.max(20,Math.floor(s*h/a))),_=(h-f)/(a-s),x=o*_;return{computedAvailableSize:Math.round(c),computedIsNeeded:p,computedSliderSize:Math.round(f),computedSliderRatio:_,computedSliderPosition:Math.round(x)}}_refreshComputedValues(){let t=ep._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize-this._computedSliderSize/2;return Math.round(i/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let i=t-this._arrowSize,s=this._scrollPosition;return i<this._computedSliderPosition?s-=this._visibleSize:s+=this._visibleSize,s}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let i=this._computedSliderPosition+t;return Math.round(i/this._computedSliderRatio)}},Fk=class extends Zy{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Qy(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,s.width,s.scrollWidth,a.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},qk=class extends Zy{constructor(e,t,i){let s=e.getScrollDimensions(),a=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:i,scrollbarState:new Qy(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,s.height,s.scrollHeight,a.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Wk=500,kb=50,Gk=class{constructor(e,t,i){this.timestamp=e,this.deltaX=t,this.deltaY=i,this.score=0}},tp=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,i=0,s=1,a=this._rear;do{let o=a===this._front?t:Math.pow(2,-s);if(t-=o,i+=this._memory[a].score*o,a===this._front)break;a=(this._capacity+a-1)%this._capacity,s++}while(!0);return i<=.5}acceptStandardWheelEvent(t){if(Up){let i=kr(t.browserEvent),s=nk(i);this.accept(Date.now(),t.deltaX*s,t.deltaY*s)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,i,s){let a=null,o=new Gk(t,i,s);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(a=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,a)}_computeScore(t,i){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let s=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(s+=.25),i){let a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),c=Math.abs(i.deltaX),h=Math.abs(i.deltaY),p=Math.max(Math.min(a,c),1),f=Math.max(Math.min(o,h),1),_=Math.max(a,c),x=Math.max(o,h);_%p===0&&x%f===0&&(s-=.5)}return Math.min(Math.max(s,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};tp.INSTANCE=new tp;var Yk=tp,Kk=class extends Wp{constructor(e,t,i){super(),this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new we),this.onWillScroll=this._onWillScroll.event,this._options=Xk(t),this._scrollable=i,this._register(this._scrollable.onScroll(a=>{this._onWillScroll.fire(a),this._onDidScroll(a),this._onScroll.fire(a)}));let s={onMouseWheel:a=>this._onMouseWheel(a),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new qk(this._scrollable,this._options,s)),this._horizontalScrollbar=this._register(new Fk(this._scrollable,this._options,s)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=vo(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=vo(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=vo(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,a=>this._onMouseOver(a)),this.onmouseleave(this._listenOnDomNode,a=>this._onMouseLeave(a)),this._hideTimeout=this._register(new Fp),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=aa(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Nr&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new _b(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=aa(this._mouseWheelToDispose),e)){let t=i=>{this._onMouseWheel(new _b(i))};this._mouseWheelToDispose.push(Ke(this._listenOnDomNode,Bi.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var a;if((a=e.browserEvent)!=null&&a.defaultPrevented)return;let t=Yk.INSTANCE;t.acceptStandardWheelEvent(e);let i=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,c=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&c+o===0?c=o=0:Math.abs(o)>=Math.abs(c)?c=0:o=0),this._options.flipAxes&&([o,c]=[c,o]);let h=!Nr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||h)&&!c&&(c=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(c=c*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let p=this._scrollable.getFutureScrollPosition(),f={};if(o){let _=kb*o,x=p.scrollTop-(_<0?Math.floor(_):Math.ceil(_));this._verticalScrollbar.writeScrollPosition(f,x)}if(c){let _=kb*c,x=p.scrollLeft-(_<0?Math.floor(_):Math.ceil(_));this._horizontalScrollbar.writeScrollPosition(f,x)}f=this._scrollable.validateScrollPosition(f),(p.scrollLeft!==f.scrollLeft||p.scrollTop!==f.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(f):this._scrollable.setScrollPositionNow(f),i=!0)}let s=i;!s&&this._options.alwaysConsumeMouseWheel&&(s=!0),!s&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(s=!0),s&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,i=e.scrollLeft>0,s=i?" left":"",a=t?" top":"",o=i||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${s}`),this._topShadowDomNode.setClassName(`shadow${a}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${a}${s}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Wk)}},Vk=class extends Kk{constructor(e,t,i){super(e,t,i)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Xk(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,Nr&&(t.className+=" mac"),t}var ip=class extends ft{constructor(e,t,i,s,a,o,c,h){super(),this._bufferService=i,this._optionsService=c,this._renderService=h,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let p=this._register(new zk({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:f=>qp(s.window,f)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{p.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Vk(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},p)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(a.onProtocolChange(f=>{this._scrollableElement.updateOptions({handleMouseWheel:!(f&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Zi.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ti(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=s.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ti(()=>this._styleElement.remove())),this._register(Zi.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
69
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(f=>this._handleScroll(f)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),i=t-this._bufferService.buffer.ydisp;i!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(i)),this._isHandlingScroll=!1}};ip=fi([Re(2,mn),Re(3,Qr),Re(4,My),Re(5,ol),Re(6,gn),Re(7,Jr)],ip);var np=class extends ft{constructor(e,t,i,s,a){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=i,this._decorationService=s,this._renderService=a,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(ti(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var s;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((s=e==null?void 0:e.options)==null?void 0:s.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let i=e.options.x??0;return i&&i>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let i=this._decorationElements.get(e);i||(i=this._createElement(e),e.element=i,this._decorationElements.set(e,i),this._container.appendChild(i),e.onDispose(()=>{this._decorationElements.delete(e),i.remove()})),i.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(i.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,i.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,i.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,i.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(i)}}_refreshXPosition(e,t=e.element){if(!t)return;let i=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=i?`${i*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=i?`${i*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};np=fi([Re(1,mn),Re(2,Qr),Re(3,Mo),Re(4,Jr)],np);var Zk=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,i){return t>=e.startBufferLine-this._linePadding[i||"full"]&&t<=e.endBufferLine+this._linePadding[i||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},yr={full:0,left:0,center:0,right:0},Es={full:0,left:0,center:0,right:0},no={full:0,left:0,center:0,right:0},Cu=class extends ft{constructor(e,t,i,s,a,o,c,h){var f;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=i,this._decorationService=s,this._renderService=a,this._optionsService=o,this._themeService=c,this._coreBrowserService=h,this._colorZoneStore=new Zk,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(f=this._viewportElement.parentElement)==null||f.insertBefore(this._canvas,this._viewportElement),this._register(ti(()=>{var _;return(_=this._canvas)==null?void 0:_.remove()}));let p=this._canvas.getContext("2d");if(p)this._ctx=p;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Es.full=this._canvas.width,Es.left=e,Es.center=t,Es.right=e,this._refreshDrawHeightConstants(),no.full=1,no.left=1,no.center=1+Es.left,no.right=1+Es.left+Es.center}_refreshDrawHeightConstants(){yr.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);yr.left=t,yr.center=t,yr.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*yr.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(no[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-yr[e.position||"full"]/2),Es[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+yr[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Cu=fi([Re(2,mn),Re(3,Mo),Re(4,Jr),Re(5,gn),Re(6,ol),Re(7,Qr)],Cu);var pe;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
70
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(pe||(pe={}));var pu;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(pu||(pu={}));var Jy;(e=>e.ST=`${pe.ESC}\\`)(Jy||(Jy={}));var rp=class{constructor(e,t,i,s,a,o){this._textarea=e,this._compositionView=t,this._bufferService=i,this._optionsService=s,this._coreService=a,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let i;t.start+=this._dataAlreadySent.length,this._isComposing?i=this._textarea.value.substring(t.start,this._compositionPosition.start):i=this._textarea.value.substring(t.start),i.length>0&&this._coreService.triggerDataEvent(i,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,i=t.replace(e,"");this._dataAlreadySent=i,t.length>e.length?this._coreService.triggerDataEvent(i,!0):t.length<e.length?this._coreService.triggerDataEvent(`${pe.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),i=this._renderService.dimensions.css.cell.height,s=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,a=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=a+"px",this._compositionView.style.top=s+"px",this._compositionView.style.height=i+"px",this._compositionView.style.lineHeight=i+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=a+"px",this._textarea.style.top=s+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};rp=fi([Re(2,mn),Re(3,gn),Re(4,ca),Re(5,Jr)],rp);var Li=0,Oi=0,zi=0,hi=0,Eb={css:"#00000000",rgba:0},ki;(e=>{function t(a,o,c,h){return h!==void 0?`#${Qs(a)}${Qs(o)}${Qs(c)}${Qs(h)}`:`#${Qs(a)}${Qs(o)}${Qs(c)}`}e.toCss=t;function i(a,o,c,h=255){return(a<<24|o<<16|c<<8|h)>>>0}e.toRgba=i;function s(a,o,c,h){return{css:e.toCss(a,o,c,h),rgba:e.toRgba(a,o,c,h)}}e.toColor=s})(ki||(ki={}));var Qt;(e=>{function t(p,f){if(hi=(f.rgba&255)/255,hi===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,x=f.rgba>>16&255,b=f.rgba>>8&255,v=p.rgba>>24&255,y=p.rgba>>16&255,N=p.rgba>>8&255;Li=v+Math.round((_-v)*hi),Oi=y+Math.round((x-y)*hi),zi=N+Math.round((b-N)*hi);let j=ki.toCss(Li,Oi,zi),E=ki.toRgba(Li,Oi,zi);return{css:j,rgba:E}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,f,_){let x=mu.ensureContrastRatio(p.rgba,f.rgba,_);if(x)return ki.toColor(x>>24&255,x>>16&255,x>>8&255)}e.ensureContrastRatio=s;function a(p){let f=(p.rgba|255)>>>0;return[Li,Oi,zi]=mu.toChannels(f),{css:ki.toCss(Li,Oi,zi),rgba:f}}e.opaque=a;function o(p,f){return hi=Math.round(f*255),[Li,Oi,zi]=mu.toChannels(p.rgba),{css:ki.toCss(Li,Oi,zi,hi),rgba:ki.toRgba(Li,Oi,zi,hi)}}e.opacity=o;function c(p,f){return hi=p.rgba&255,o(p,hi*f/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(Qt||(Qt={}));var ai;(e=>{let t,i;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Li=parseInt(a.slice(1,2).repeat(2),16),Oi=parseInt(a.slice(2,3).repeat(2),16),zi=parseInt(a.slice(3,4).repeat(2),16),ki.toColor(Li,Oi,zi);case 5:return Li=parseInt(a.slice(1,2).repeat(2),16),Oi=parseInt(a.slice(2,3).repeat(2),16),zi=parseInt(a.slice(3,4).repeat(2),16),hi=parseInt(a.slice(4,5).repeat(2),16),ki.toColor(Li,Oi,zi,hi);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Li=parseInt(o[1]),Oi=parseInt(o[2]),zi=parseInt(o[3]),hi=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),ki.toColor(Li,Oi,zi,hi);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Li,Oi,zi,hi]=t.getImageData(0,0,1,1).data,hi!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:ki.toRgba(Li,Oi,zi,hi),css:a}}e.toColor=s})(ai||(ai={}));var dn;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,a,o){let c=s/255,h=a/255,p=o/255,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),x=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+_*.7152+x*.0722}e.relativeLuminance2=i})(dn||(dn={}));var mu;(e=>{function t(c,h){if(hi=(h&255)/255,hi===1)return h;let p=h>>24&255,f=h>>16&255,_=h>>8&255,x=c>>24&255,b=c>>16&255,v=c>>8&255;return Li=x+Math.round((p-x)*hi),Oi=b+Math.round((f-b)*hi),zi=v+Math.round((_-v)*hi),ki.toRgba(Li,Oi,zi)}e.blend=t;function i(c,h,p){let f=dn.relativeLuminance(c>>8),_=dn.relativeLuminance(h>>8);if(Yr(f,_)<p){if(_<f){let v=s(c,h,p),y=Yr(f,dn.relativeLuminance(v>>8));if(y<p){let N=a(c,h,p),j=Yr(f,dn.relativeLuminance(N>>8));return y>j?v:N}return v}let x=a(c,h,p),b=Yr(f,dn.relativeLuminance(x>>8));if(b<p){let v=s(c,h,p),y=Yr(f,dn.relativeLuminance(v>>8));return b>y?x:v}return x}}e.ensureContrastRatio=i;function s(c,h,p){let f=c>>24&255,_=c>>16&255,x=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,N=Yr(dn.relativeLuminance2(b,v,y),dn.relativeLuminance2(f,_,x));for(;N<p&&(b>0||v>0||y>0);)b-=Math.max(0,Math.ceil(b*.1)),v-=Math.max(0,Math.ceil(v*.1)),y-=Math.max(0,Math.ceil(y*.1)),N=Yr(dn.relativeLuminance2(b,v,y),dn.relativeLuminance2(f,_,x));return(b<<24|v<<16|y<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let f=c>>24&255,_=c>>16&255,x=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,N=Yr(dn.relativeLuminance2(b,v,y),dn.relativeLuminance2(f,_,x));for(;N<p&&(b<255||v<255||y<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),N=Yr(dn.relativeLuminance2(b,v,y),dn.relativeLuminance2(f,_,x));return(b<<24|v<<16|y<<8|255)>>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(mu||(mu={}));function Qs(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Yr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Qk=class extends Ro{constructor(e,t,i){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=i}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ku=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new lr}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let i=[],s=t.translateToString(!0),a=0,o=0,c=0,h=t.getFg(0),p=t.getBg(0);for(let f=0;f<t.getTrimmedLength();f++)if(t.loadCell(f,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==h||this._workCell.bg!==p){if(f-a>1){let _=this._getJoinedRanges(s,c,o,t,a);for(let x=0;x<_.length;x++)i.push(_[x])}a=f,c=o,h=this._workCell.fg,p=this._workCell.bg}o+=this._workCell.getChars().length||Rs.length}if(this._bufferService.cols-a>1){let f=this._getJoinedRanges(s,c,o,t,a);for(let _=0;_<f.length;_++)i.push(f[_])}return i}_getJoinedRanges(e,t,i,s,a){let o=e.substring(t,i),c=[];try{c=this._characterJoiners[0].handler(o)}catch(h){console.error(h)}for(let h=1;h<this._characterJoiners.length;h++)try{let p=this._characterJoiners[h].handler(o);for(let f=0;f<p.length;f++)ku._mergeRanges(c,p[f])}catch(p){console.error(p)}return this._stringRangesToCellRanges(c,s,a),c}_stringRangesToCellRanges(e,t,i){let s=0,a=!1,o=0,c=e[s];if(c){for(let h=i;h<this._bufferService.cols;h++){let p=t.getWidth(h),f=t.getString(h).length||Rs.length;if(p!==0){if(!a&&c[0]<=o&&(c[0]=h,a=!0),c[1]<=o){if(c[1]=h,c=e[++s],!c)break;c[0]<=o?(c[0]=h,a=!0):a=!1}o+=f}}c&&(c[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let i=!1;for(let s=0;s<e.length;s++){let a=e[s];if(i){if(t[1]<=a[0])return e[s-1][1]=t[1],e;if(t[1]<=a[1])return e[s-1][1]=Math.max(t[1],a[1]),e.splice(s,1),e;e.splice(s,1),s--}else{if(t[1]<=a[0])return e.splice(s,0,t),e;if(t[1]<=a[1])return a[0]=Math.min(t[0],a[0]),e;t[0]<a[1]&&(a[0]=Math.min(t[0],a[0]),i=!0);continue}}return i?e[e.length-1][1]=t[1]:e.push(t),e}};ku=fi([Re(0,mn)],ku);function Jk(e){return 57508<=e&&e<=57558}function e2(e){return 9472<=e&&e<=9631}function t2(e){return Jk(e)||e2(e)}function i2(){return{css:{canvas:Zc(),cell:Zc()},device:{canvas:Zc(),cell:Zc(),char:{width:0,height:0,left:0,top:0}}}}function Zc(){return{width:0,height:0}}var sp=class{constructor(e,t,i,s,a,o,c){this._document=e,this._characterJoinerService=t,this._optionsService=i,this._coreBrowserService=s,this._coreService=a,this._decorationService=o,this._themeService=c,this._workCell=new lr,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,i){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=i}createRow(e,t,i,s,a,o,c,h,p,f,_){let x=[],b=this._characterJoinerService.getJoinedCharacters(t),v=this._themeService.colors,y=e.getNoBgTrimmedLength();i&&y<o+1&&(y=o+1);let N,j=0,E="",z=0,O=0,W=0,q=0,D=!1,te=0,de=!1,_e=0,P=0,ae=[],G=f!==-1&&_!==-1;for(let Y=0;Y<y;Y++){e.loadCell(Y,this._workCell);let Q=this._workCell.getWidth();if(Q===0)continue;let I=!1,A=Y>=P,B=Y,U=this._workCell;if(b.length>0&&Y===b[0][0]&&A){let ye=b.shift(),rt=this._isCellInSelection(ye[0],t);for(z=ye[0]+1;z<ye[1];z++)A&&(A=rt===this._isCellInSelection(z,t));A&&(A=!i||o<ye[0]||o>=ye[1]),A?(I=!0,U=new Qk(this._workCell,e.translateToString(!0,ye[0],ye[1]),ye[1]-ye[0]),B=ye[1]-1,Q=U.getWidth()):P=ye[1]}let ge=this._isCellInSelection(Y,t),T=i&&Y===o,R=G&&Y>=f&&Y<=_,V=!1;this._decorationService.forEachDecorationAtCell(Y,t,void 0,ye=>{V=!0});let C=U.getChars()||Rs;if(C===" "&&(U.isUnderline()||U.isOverline())&&(C=" "),_e=Q*h-p.get(C,U.isBold(),U.isItalic()),!N)N=this._document.createElement("span");else if(j&&(ge&&de||!ge&&!de&&U.bg===O)&&(ge&&de&&v.selectionForeground||U.fg===W)&&U.extended.ext===q&&R===D&&_e===te&&!T&&!I&&!V&&A){U.isInvisible()?E+=Rs:E+=C,j++;continue}else j&&(N.textContent=E),N=this._document.createElement("span"),j=0,E="";if(O=U.bg,W=U.fg,q=U.extended.ext,D=R,te=_e,de=ge,I&&o>=Y&&o<=B&&(o=Y),!this._coreService.isCursorHidden&&T&&this._coreService.isCursorInitialized){if(ae.push("xterm-cursor"),this._coreBrowserService.isFocused)c&&ae.push("xterm-cursor-blink"),ae.push(s==="bar"?"xterm-cursor-bar":s==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(a)switch(a){case"outline":ae.push("xterm-cursor-outline");break;case"block":ae.push("xterm-cursor-block");break;case"bar":ae.push("xterm-cursor-bar");break;case"underline":ae.push("xterm-cursor-underline");break}}if(U.isBold()&&ae.push("xterm-bold"),U.isItalic()&&ae.push("xterm-italic"),U.isDim()&&ae.push("xterm-dim"),U.isInvisible()?E=Rs:E=U.getChars()||Rs,U.isUnderline()&&(ae.push(`xterm-underline-${U.extended.underlineStyle}`),E===" "&&(E=" "),!U.isUnderlineColorDefault()))if(U.isUnderlineColorRGB())N.style.textDecorationColor=`rgb(${Ro.toColorRGB(U.getUnderlineColor()).join(",")})`;else{let ye=U.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&U.isBold()&&ye<8&&(ye+=8),N.style.textDecorationColor=v.ansi[ye].css}U.isOverline()&&(ae.push("xterm-overline"),E===" "&&(E=" ")),U.isStrikethrough()&&ae.push("xterm-strikethrough"),R&&(N.style.textDecoration="underline");let K=U.getFgColor(),re=U.getFgColorMode(),ue=U.getBgColor(),$=U.getBgColorMode(),le=!!U.isInverse();if(le){let ye=K;K=ue,ue=ye;let rt=re;re=$,$=rt}let be,Te,Le=!1;this._decorationService.forEachDecorationAtCell(Y,t,void 0,ye=>{ye.options.layer!=="top"&&Le||(ye.backgroundColorRGB&&($=50331648,ue=ye.backgroundColorRGB.rgba>>8&16777215,be=ye.backgroundColorRGB),ye.foregroundColorRGB&&(re=50331648,K=ye.foregroundColorRGB.rgba>>8&16777215,Te=ye.foregroundColorRGB),Le=ye.options.layer==="top")}),!Le&&ge&&(be=this._coreBrowserService.isFocused?v.selectionBackgroundOpaque:v.selectionInactiveBackgroundOpaque,ue=be.rgba>>8&16777215,$=50331648,Le=!0,v.selectionForeground&&(re=50331648,K=v.selectionForeground.rgba>>8&16777215,Te=v.selectionForeground)),Le&&ae.push("xterm-decoration-top");let ze;switch($){case 16777216:case 33554432:ze=v.ansi[ue],ae.push(`xterm-bg-${ue}`);break;case 50331648:ze=ki.toColor(ue>>16,ue>>8&255,ue&255),this._addStyle(N,`background-color:#${Nb((ue>>>0).toString(16),"0",6)}`);break;case 0:default:le?(ze=v.foreground,ae.push("xterm-bg-257")):ze=v.background}switch(be||U.isDim()&&(be=Qt.multiplyOpacity(ze,.5)),re){case 16777216:case 33554432:U.isBold()&&K<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(K+=8),this._applyMinimumContrast(N,ze,v.ansi[K],U,be,void 0)||ae.push(`xterm-fg-${K}`);break;case 50331648:let ye=ki.toColor(K>>16&255,K>>8&255,K&255);this._applyMinimumContrast(N,ze,ye,U,be,Te)||this._addStyle(N,`color:#${Nb(K.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(N,ze,v.foreground,U,be,Te)||le&&ae.push("xterm-fg-257")}ae.length&&(N.className=ae.join(" "),ae.length=0),!T&&!I&&!V&&A?j++:N.textContent=E,_e!==this.defaultSpacing&&(N.style.letterSpacing=`${_e}px`),x.push(N),Y=B}return N&&j&&(N.textContent=E),x}_applyMinimumContrast(e,t,i,s,a,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||t2(s.getCode()))return!1;let c=this._getContrastCache(s),h;if(!a&&!o&&(h=c.getColor(t.rgba,i.rgba)),h===void 0){let p=this._optionsService.rawOptions.minimumContrastRatio/(s.isDim()?2:1);h=Qt.ensureContrastRatio(a||t,o||i,p),c.setColor((a||t).rgba,(o||i).rgba,h??null)}return h?(this._addStyle(e,`color:${h.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let i=this._selectionStart,s=this._selectionEnd;return!i||!s?!1:this._columnSelectMode?i[0]<=s[0]?e>=i[0]&&t>=i[1]&&e<s[0]&&t<=s[1]:e<i[0]&&t>=i[1]&&e>=s[0]&&t<=s[1]:t>i[1]&&t<s[1]||i[1]===s[1]&&t===i[1]&&e>=i[0]&&e<s[0]||i[1]<s[1]&&t===s[1]&&e<s[0]||i[1]<s[1]&&t===i[1]&&e>=i[0]}};sp=fi([Re(1,Ly),Re(2,gn),Re(3,Qr),Re(4,ca),Re(5,Mo),Re(6,ol)],sp);function Nb(e,t,i){for(;e.length<i;)e=t+e;return e}var n2=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let i=e.createElement("span");i.classList.add("xterm-char-measure-element");let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontWeight="bold";let a=e.createElement("span");a.classList.add("xterm-char-measure-element"),a.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[i,s,a,o],this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(a),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,i,s){e===this._font&&t===this._fontSize&&i===this._weight&&s===this._weightBold||(this._font=e,this._fontSize=t,this._weight=i,this._weightBold=s,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${i}`,this._measureElements[1].style.fontWeight=`${s}`,this._measureElements[2].style.fontWeight=`${i}`,this._measureElements[3].style.fontWeight=`${s}`,this.clear())}get(e,t,i){let s=0;if(!t&&!i&&e.length===1&&(s=e.charCodeAt(0))<256){if(this._flat[s]!==-9999)return this._flat[s];let c=this._measure(e,0);return c>0&&(this._flat[s]=c),c}let a=e;t&&(a+="B"),i&&(a+="I");let o=this._holey.get(a);if(o===void 0){let c=0;t&&(c|=1),i&&(c|=2),o=this._measure(e,c),o>0&&this._holey.set(a,o)}return o}_measure(e,t){let i=this._measureElements[t];return i.textContent=e.repeat(32),i.offsetWidth/32}},r2=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,i,s=!1){if(this.selectionStart=t,this.selectionEnd=i,!t||!i||t[0]===i[0]&&t[1]===i[1]){this.clear();return}let a=e.buffers.active.ydisp,o=t[1]-a,c=i[1]-a,h=Math.max(o,0),p=Math.min(c,e.rows-1);if(h>=e.rows||p<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=s,this.viewportStartRow=o,this.viewportEndRow=c,this.viewportCappedStartRow=h,this.viewportCappedEndRow=p,this.startCol=t[0],this.endCol=i[0]}isCellSelected(e,t,i){return this.hasSelection?(i-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&i>=this.viewportCappedStartRow&&t<this.endCol&&i<=this.viewportCappedEndRow:t<this.startCol&&i>=this.viewportCappedStartRow&&t>=this.endCol&&i<=this.viewportCappedEndRow:i>this.viewportStartRow&&i<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&i===this.viewportStartRow&&t>=this.startCol):!1}};function s2(){return new r2}var nf="xterm-dom-renderer-owner-",ir="xterm-rows",Qc="xterm-fg-",Tb="xterm-bg-",ro="xterm-focus",Jc="xterm-selection",a2=1,ap=class extends ft{constructor(e,t,i,s,a,o,c,h,p,f,_,x,b,v){super(),this._terminal=e,this._document=t,this._element=i,this._screenElement=s,this._viewportElement=a,this._helperContainer=o,this._linkifier2=c,this._charSizeService=p,this._optionsService=f,this._bufferService=_,this._coreService=x,this._coreBrowserService=b,this._themeService=v,this._terminalClass=a2++,this._rowElements=[],this._selectionRenderModel=s2(),this.onRequestRedraw=this._register(new we).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(ir),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Jc),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=i2(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(y=>this._injectCss(y))),this._injectCss(this._themeService.colors),this._rowFactory=h.createInstance(sp,document),this._element.classList.add(nf+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(y=>this._handleLinkHover(y))),this._register(this._linkifier2.onHideLinkUnderline(y=>this._handleLinkLeave(y))),this._register(ti(()=>{this._element.classList.remove(nf+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new n2(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let i of this._rowElements)i.style.width=`${this.dimensions.css.canvas.width}px`,i.style.height=`${this.dimensions.css.cell.height}px`,i.style.lineHeight=`${this.dimensions.css.cell.height}px`,i.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${ir} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${ir} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${ir} .xterm-dim { color: ${Qt.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let i=`blink_underline_${this._terminalClass}`,s=`blink_bar_${this._terminalClass}`,a=`blink_block_${this._terminalClass}`;t+=`@keyframes ${i} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${s} { 50% { box-shadow: none; }}`,t+=`@keyframes ${a} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${ir}.${ro} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${ir}.${ro} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${ir}.${ro} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${a} 1s step-end infinite;}${this._terminalSelector} .${ir} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${ir} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${ir} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${ir} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${ir} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Jc} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Jc} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Jc} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,c]of e.ansi.entries())t+=`${this._terminalSelector} .${Qc}${o} { color: ${c.css}; }${this._terminalSelector} .${Qc}${o}.xterm-dim { color: ${Qt.multiplyOpacity(c,.5).css}; }${this._terminalSelector} .${Tb}${o} { background-color: ${c.css}; }`;t+=`${this._terminalSelector} .${Qc}257 { color: ${Qt.opaque(e.background).css}; }${this._terminalSelector} .${Qc}257.xterm-dim { color: ${Qt.multiplyOpacity(Qt.opaque(e.background),.5).css}; }${this._terminalSelector} .${Tb}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let i=this._rowElements.length;i<=t;i++){let s=this._document.createElement("div");this._rowContainer.appendChild(s),this._rowElements.push(s)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(ro),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(ro),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,i){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,i),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,i),!this._selectionRenderModel.hasSelection))return;let s=this._selectionRenderModel.viewportStartRow,a=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,c=this._selectionRenderModel.viewportCappedEndRow,h=this._document.createDocumentFragment();if(i){let p=e[0]>t[0];h.appendChild(this._createSelectionElement(o,p?t[0]:e[0],p?e[0]:t[0],c-o+1))}else{let p=s===o?e[0]:0,f=o===a?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(o,p,f));let _=c-o-1;if(h.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,_)),o!==c){let x=a===c?t[0]:this._bufferService.cols;h.appendChild(this._createSelectionElement(c,0,x))}}this._selectionContainer.appendChild(h)}_createSelectionElement(e,t,i,s=1){let a=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,c=this.dimensions.css.cell.width*(i-t);return o+c>this.dimensions.css.canvas.width&&(c=this.dimensions.css.canvas.width-o),a.style.height=`${s*this.dimensions.css.cell.height}px`,a.style.top=`${e*this.dimensions.css.cell.height}px`,a.style.left=`${o}px`,a.style.width=`${c}px`,a}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let i=this._bufferService.buffer,s=i.ybase+i.y,a=Math.min(i.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,c=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,h=this._optionsService.rawOptions.cursorInactiveStyle;for(let p=e;p<=t;p++){let f=p+i.ydisp,_=this._rowElements[p],x=i.lines.get(f);if(!_||!x)break;_.replaceChildren(...this._rowFactory.createRow(x,f,f===s,c,h,a,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${nf}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,i,s,a,o){i<0&&(e=0),s<0&&(t=0);let c=this._bufferService.rows-1;i=Math.max(Math.min(i,c),0),s=Math.max(Math.min(s,c),0),a=Math.min(a,this._bufferService.cols);let h=this._bufferService.buffer,p=h.ybase+h.y,f=Math.min(h.x,a-1),_=this._optionsService.rawOptions.cursorBlink,x=this._optionsService.rawOptions.cursorStyle,b=this._optionsService.rawOptions.cursorInactiveStyle;for(let v=i;v<=s;++v){let y=v+h.ydisp,N=this._rowElements[v],j=h.lines.get(y);if(!N||!j)break;N.replaceChildren(...this._rowFactory.createRow(j,y,y===p,x,b,f,_,this.dimensions.css.cell.width,this._widthCache,o?v===i?e:0:-1,o?(v===s?t:a)-1:-1))}}};ap=fi([Re(7,Pp),Re(8,Lu),Re(9,gn),Re(10,mn),Re(11,ca),Re(12,Qr),Re(13,ol)],ap);var lp=class extends ft{constructor(e,t,i){super(),this._optionsService=i,this.width=0,this.height=0,this._onCharSizeChange=this._register(new we),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new o2(this._optionsService))}catch{this._measureStrategy=this._register(new l2(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};lp=fi([Re(2,gn)],lp);var e0=class extends ft{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},l2=class extends e0{constructor(e,t,i){super(),this._document=e,this._parentElement=t,this._optionsService=i,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},o2=class extends e0{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},c2=class extends ft{constructor(e,t,i){super(),this._textarea=e,this._window=t,this.mainDocument=i,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new u2(this._window)),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new we),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(s=>this._screenDprMonitor.setWindow(s))),this._register(Zi.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Ke(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Ke(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},u2=class extends ft{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new sl),this._onDprChange=this._register(new we),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ti(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Ke(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},h2=class extends ft{constructor(){super(),this.linkProviders=[],this._register(ti(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Gp(e,t,i){let s=i.getBoundingClientRect(),a=e.getComputedStyle(i),o=parseInt(a.getPropertyValue("padding-left")),c=parseInt(a.getPropertyValue("padding-top"));return[t.clientX-s.left-o,t.clientY-s.top-c]}function d2(e,t,i,s,a,o,c,h,p){if(!o)return;let f=Gp(e,t,i);if(f)return f[0]=Math.ceil((f[0]+(p?c/2:0))/c),f[1]=Math.ceil(f[1]/h),f[0]=Math.min(Math.max(f[0],1),s+(p?1:0)),f[1]=Math.min(Math.max(f[1],1),a),f}var op=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,i,s,a){return d2(window,e,t,i,s,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,a)}getMouseReportCoords(e,t){let i=Gp(window,e,t);if(this._charSizeService.hasValidSize)return i[0]=Math.min(Math.max(i[0],0),this._renderService.dimensions.css.canvas.width-1),i[1]=Math.min(Math.max(i[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(i[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(i[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(i[0]),y:Math.floor(i[1])}}};op=fi([Re(0,Jr),Re(1,Lu)],op);var f2=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},t0={};wC(t0,{getSafariVersion:()=>m2,isChromeOS:()=>s0,isFirefox:()=>i0,isIpad:()=>g2,isIphone:()=>x2,isLegacyEdge:()=>p2,isLinux:()=>Yp,isMac:()=>Eu,isNode:()=>Ou,isSafari:()=>n0,isWindows:()=>r0});var Ou=typeof process<"u"&&"title"in process,Do=Ou?"node":navigator.userAgent,Bo=Ou?"node":navigator.platform,i0=Do.includes("Firefox"),p2=Do.includes("Edge"),n0=/^((?!chrome|android).)*safari/i.test(Do);function m2(){if(!n0)return 0;let e=Do.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Eu=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Bo),g2=Bo==="iPad",x2=Bo==="iPhone",r0=["Windows","Win16","Win32","WinCE"].includes(Bo),Yp=Bo.indexOf("Linux")>=0,s0=/\bCrOS\b/.test(Do),a0=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,i=0,s=e.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),i=Math.max(t,i),a=e.timeRemaining(),i*1.5>a){s-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(s-t))}ms`),this._start();return}s=a}this.clear()}},_2=class extends a0{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},b2=class extends a0{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},Nu=!Ou&&"requestIdleCallback"in window?b2:_2,v2=class{constructor(){this._queue=new Nu}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},cp=class extends ft{constructor(e,t,i,s,a,o,c,h,p){super(),this._rowCount=e,this._optionsService=i,this._charSizeService=s,this._coreService=a,this._coreBrowserService=h,this._renderer=this._register(new sl),this._pausedResizeTask=new v2,this._observerDisposable=this._register(new sl),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new we),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new we),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new we),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new f2((f,_)=>this._renderRows(f,_),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new y2(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ti(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(c.onResize(()=>this._fullRefresh())),this._register(c.buffers.onBufferActivate(()=>{var f;return(f=this._renderer.value)==null?void 0:f.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(c.cols,c.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(c.buffer.y,c.buffer.y,!0))),this._register(p.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(f=>this._registerIntersectionObserver(f,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let i=new e.IntersectionObserver(s=>this._handleIntersectionChange(s[s.length-1]),{threshold:0});i.observe(t),this._observerDisposable.value=ti(()=>i.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,i=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let s=this._syncOutputHandler.flush();s&&(e=Math.min(e,s.start),t=Math.max(t,s.end)),i||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var i;return(i=this._renderer.value)==null?void 0:i.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,i){var s;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=i,(s=this._renderer.value)==null||s.handleSelectionChanged(e,t,i)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};cp=fi([Re(2,gn),Re(3,Lu),Re(4,ca),Re(5,Mo),Re(6,mn),Re(7,Qr),Re(8,ol)],cp);var y2=class{constructor(e,t,i){this._coreBrowserService=e,this._coreService=t,this._onTimeout=i,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function S2(e,t,i,s){let a=i.buffer.x,o=i.buffer.y;if(!i.buffer.hasScrollback)return k2(a,o,e,t,i,s)+zu(o,t,i,s)+E2(a,o,e,t,i,s);let c;if(o===t)return c=a>e?"D":"C",ko(Math.abs(a-e),Co(c,s));c=o>t?"D":"C";let h=Math.abs(o-t),p=C2(o>t?e:a,i)+(h-1)*i.cols+1+w2(o>t?a:e);return ko(p,Co(c,s))}function w2(e,t){return e-1}function C2(e,t){return t.cols-e}function k2(e,t,i,s,a,o){return zu(t,s,a,o).length===0?"":ko(o0(e,t,e,t-la(t,a),!1,a).length,Co("D",o))}function zu(e,t,i,s){let a=e-la(e,i),o=t-la(t,i),c=Math.abs(a-o)-N2(e,t,i);return ko(c,Co(l0(e,t),s))}function E2(e,t,i,s,a,o){let c;zu(t,s,a,o).length>0?c=s-la(s,a):c=t;let h=s,p=T2(e,t,i,s,a,o);return ko(o0(e,c,i,h,p==="C",a).length,Co(p,o))}function N2(e,t,i){var c;let s=0,a=e-la(e,i),o=t-la(t,i);for(let h=0;h<Math.abs(a-o);h++){let p=l0(e,t)==="A"?-1:1;(c=i.buffer.lines.get(a+p*h))!=null&&c.isWrapped&&s++}return s}function la(e,t){let i=0,s=t.buffer.lines.get(e),a=s==null?void 0:s.isWrapped;for(;a&&e>=0&&e<t.rows;)i++,s=t.buffer.lines.get(--e),a=s==null?void 0:s.isWrapped;return i}function T2(e,t,i,s,a,o){let c;return zu(i,s,a,o).length>0?c=s-la(s,a):c=t,e<i&&c<=s||e>=i&&c<s?"C":"D"}function l0(e,t){return e>t?"A":"B"}function o0(e,t,i,s,a,o){let c=e,h=t,p="";for(;(c!==i||h!==s)&&h>=0&&h<o.buffer.lines.length;)c+=a?1:-1,a&&c>o.cols-1?(p+=o.buffer.translateBufferLineToString(h,!1,e,c),c=0,e=0,h++):!a&&c<0&&(p+=o.buffer.translateBufferLineToString(h,!1,0,e+1),c=o.cols-1,e=c,h--);return p+o.buffer.translateBufferLineToString(h,!1,e,c)}function Co(e,t){let i=t?"O":"[";return pe.ESC+i+e}function ko(e,t){e=Math.floor(e);let i="";for(let s=0;s<e;s++)i+=t;return i}var j2=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function jb(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var rf=50,A2=15,R2=50,M2=500,D2=" ",B2=new RegExp(D2,"g"),up=class extends ft{constructor(e,t,i,s,a,o,c,h,p){super(),this._element=e,this._screenElement=t,this._linkifier=i,this._bufferService=s,this._coreService=a,this._mouseService=o,this._optionsService=c,this._renderService=h,this._coreBrowserService=p,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new lr,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new we),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new we),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new we),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=f=>this._handleMouseMove(f),this._mouseUpListener=f=>this._handleMouseUp(f),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(f=>this._handleTrim(f)),this._register(this._bufferService.buffers.onBufferActivate(f=>this._handleBufferActivate(f))),this.enable(),this._model=new j2(this._bufferService),this._activeSelectionMode=0,this._register(ti(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(f=>{f.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let i=this._bufferService.buffer,s=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let a=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let c=e[1];c<=t[1];c++){let h=i.translateBufferLineToString(c,!0,a,o);s.push(h)}}else{let a=e[1]===t[1]?t[0]:void 0;s.push(i.translateBufferLineToString(e[1],!0,e[0],a));for(let o=e[1]+1;o<=t[1]-1;o++){let c=i.lines.get(o),h=i.translateBufferLineToString(o,!0);c!=null&&c.isWrapped?s[s.length-1]+=h:s.push(h)}if(e[1]!==t[1]){let o=i.lines.get(t[1]),c=i.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?s[s.length-1]+=c:s.push(c)}}return s.map(a=>a.replace(B2," ")).join(r0?`\r
71
+ `:`
72
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Yp&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s||!t?!1:this._areCoordsInSelection(t,i,s)}isCellInSelection(e,t){let i=this._model.finalSelectionStart,s=this._model.finalSelectionEnd;return!i||!s?!1:this._areCoordsInSelection([e,t],i,s)}_areCoordsInSelection(e,t,i){return e[1]>t[1]&&e[1]<i[1]||t[1]===i[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<i[0]||t[1]<i[1]&&e[1]===i[1]&&e[0]<i[0]||t[1]<i[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var a,o;let i=(o=(a=this._linkifier.currentLink)==null?void 0:a.link)==null?void 0:o.range;if(i)return this._model.selectionStart=[i.start.x-1,i.start.y-1],this._model.selectionStartLength=jb(i,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let s=this._getMouseBufferCoords(e);return s?(this._selectWordAt(s,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Gp(this._coreBrowserService.window,e,this._screenElement)[1],i=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=i?0:(t>i&&(t-=i),t=Math.min(Math.max(t,-rf),rf),t/=rf,t/Math.abs(t)+Math.round(t*(A2-1)))}shouldForceSelection(e){return Eu?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),R2)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Eu&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let i=this._bufferService.buffer;if(this._model.selectionEnd[1]<i.lines.length){let s=i.lines.get(this._model.selectionEnd[1]);s&&s.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<M2&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let i=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(i&&i[0]!==void 0&&i[1]!==void 0){let s=S2(i[0]-1,i[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(s,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,i=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!i){this._oldHasSelection&&this._fireOnSelectionChange(e,t,i);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,i)}_fireOnSelectionChange(e,t,i){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=i,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let i=t;for(let s=0;t>=s;s++){let a=e.loadCell(s,this._workCell).getChars().length;this._workCell.getWidth()===0?i--:a>1&&t!==s&&(i+=a-1)}return i}setSelection(e,t,i){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=i,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,i=!0,s=!0){if(e[0]>=this._bufferService.cols)return;let a=this._bufferService.buffer,o=a.lines.get(e[1]);if(!o)return;let c=a.translateBufferLineToString(e[1],!1),h=this._convertViewportColToCharacterIndex(o,e[0]),p=h,f=e[0]-h,_=0,x=0,b=0,v=0;if(c.charAt(h)===" "){for(;h>0&&c.charAt(h-1)===" ";)h--;for(;p<c.length&&c.charAt(p+1)===" ";)p++}else{let j=e[0],E=e[0];o.getWidth(j)===0&&(_++,j--),o.getWidth(E)===2&&(x++,E++);let z=o.getString(E).length;for(z>1&&(v+=z-1,p+=z-1);j>0&&h>0&&!this._isCharWordSeparator(o.loadCell(j-1,this._workCell));){o.loadCell(j-1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===0?(_++,j--):O>1&&(b+=O-1,h-=O-1),h--,j--}for(;E<o.length&&p+1<c.length&&!this._isCharWordSeparator(o.loadCell(E+1,this._workCell));){o.loadCell(E+1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===2?(x++,E++):O>1&&(v+=O-1,p+=O-1),p++,E++}}p++;let y=h+f-_+b,N=Math.min(this._bufferService.cols,p-h+_+x-b-v);if(!(!t&&c.slice(h,p).trim()==="")){if(i&&y===0&&o.getCodePoint(0)!==32){let j=a.lines.get(e[1]-1);if(j&&o.isWrapped&&j.getCodePoint(this._bufferService.cols-1)!==32){let E=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(E){let z=this._bufferService.cols-E.start;y-=z,N+=z}}}if(s&&y+N===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let j=a.lines.get(e[1]+1);if(j!=null&&j.isWrapped&&j.getCodePoint(0)!==32){let E=this._getWordAt([0,e[1]+1],!1,!1,!0);E&&(N+=E.length)}}return{start:y,length:N}}}_selectWordAt(e,t){let i=this._getWordAt(e,t);if(i){for(;i.start<0;)i.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[i.start,e[1]],this._model.selectionStartLength=i.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let i=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,i--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,i++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,i]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),i={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=jb(i,this._bufferService.cols)}};up=fi([Re(3,mn),Re(4,ca),Re(5,Ip),Re(6,gn),Re(7,Jr),Re(8,Qr)],up);var Ab=class{constructor(){this._data={}}set(e,t,i){this._data[e]||(this._data[e]={}),this._data[e][t]=i}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},Rb=class{constructor(){this._color=new Ab,this._css=new Ab}setCss(e,t,i){this._css.set(e,t,i)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,i){this._color.set(e,t,i)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ti=Object.freeze((()=>{let e=[ai.toColor("#2e3436"),ai.toColor("#cc0000"),ai.toColor("#4e9a06"),ai.toColor("#c4a000"),ai.toColor("#3465a4"),ai.toColor("#75507b"),ai.toColor("#06989a"),ai.toColor("#d3d7cf"),ai.toColor("#555753"),ai.toColor("#ef2929"),ai.toColor("#8ae234"),ai.toColor("#fce94f"),ai.toColor("#729fcf"),ai.toColor("#ad7fa8"),ai.toColor("#34e2e2"),ai.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],a=t[i/6%6|0],o=t[i%6];e.push({css:ki.toCss(s,a,o),rgba:ki.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:ki.toCss(s,s,s),rgba:ki.toRgba(s,s,s)})}return e})()),ia=ai.toColor("#ffffff"),go=ai.toColor("#000000"),Mb=ai.toColor("#ffffff"),Db=go,so={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},L2=ia,hp=class extends ft{constructor(e){super(),this._optionsService=e,this._contrastCache=new Rb,this._halfContrastCache=new Rb,this._onChangeColors=this._register(new we),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ia,background:go,cursor:Mb,cursorAccent:Db,selectionForeground:void 0,selectionBackgroundTransparent:so,selectionBackgroundOpaque:Qt.blend(go,so),selectionInactiveBackgroundTransparent:so,selectionInactiveBackgroundOpaque:Qt.blend(go,so),scrollbarSliderBackground:Qt.opacity(ia,.2),scrollbarSliderHoverBackground:Qt.opacity(ia,.4),scrollbarSliderActiveBackground:Qt.opacity(ia,.5),overviewRulerBorder:ia,ansi:Ti.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=Ft(e.foreground,ia),t.background=Ft(e.background,go),t.cursor=Qt.blend(t.background,Ft(e.cursor,Mb)),t.cursorAccent=Qt.blend(t.background,Ft(e.cursorAccent,Db)),t.selectionBackgroundTransparent=Ft(e.selectionBackground,so),t.selectionBackgroundOpaque=Qt.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=Ft(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=Qt.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?Ft(e.selectionForeground,Eb):void 0,t.selectionForeground===Eb&&(t.selectionForeground=void 0),Qt.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=Qt.opacity(t.selectionBackgroundTransparent,.3)),Qt.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=Qt.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=Ft(e.scrollbarSliderBackground,Qt.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=Ft(e.scrollbarSliderHoverBackground,Qt.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=Ft(e.scrollbarSliderActiveBackground,Qt.opacity(t.foreground,.5)),t.overviewRulerBorder=Ft(e.overviewRulerBorder,L2),t.ansi=Ti.slice(),t.ansi[0]=Ft(e.black,Ti[0]),t.ansi[1]=Ft(e.red,Ti[1]),t.ansi[2]=Ft(e.green,Ti[2]),t.ansi[3]=Ft(e.yellow,Ti[3]),t.ansi[4]=Ft(e.blue,Ti[4]),t.ansi[5]=Ft(e.magenta,Ti[5]),t.ansi[6]=Ft(e.cyan,Ti[6]),t.ansi[7]=Ft(e.white,Ti[7]),t.ansi[8]=Ft(e.brightBlack,Ti[8]),t.ansi[9]=Ft(e.brightRed,Ti[9]),t.ansi[10]=Ft(e.brightGreen,Ti[10]),t.ansi[11]=Ft(e.brightYellow,Ti[11]),t.ansi[12]=Ft(e.brightBlue,Ti[12]),t.ansi[13]=Ft(e.brightMagenta,Ti[13]),t.ansi[14]=Ft(e.brightCyan,Ti[14]),t.ansi[15]=Ft(e.brightWhite,Ti[15]),e.extendedAnsi){let i=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let s=0;s<i;s++)t.ansi[s+16]=Ft(e.extendedAnsi[s],Ti[s+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};hp=fi([Re(0,gn)],hp);function Ft(e,t){if(e!==void 0)try{return ai.toColor(e)}catch{}return t}var O2=class{constructor(...e){this._entries=new Map;for(let[t,i]of e)this.set(t,i)}set(e,t){let i=this._entries.get(e);return this._entries.set(e,t),i}forEach(e){for(let[t,i]of this._entries.entries())e(t,i)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},z2=class{constructor(){this._services=new O2,this._services.set(Pp,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let i=AC(e).sort((o,c)=>o.index-c.index),s=[];for(let o of i){let c=this._services.get(o.id);if(!c)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);s.push(c)}let a=i.length>0?i[0].index:t.length;if(t.length!==a)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${a+1} conflicts with ${t.length} static arguments`);return new e(...t,...s)}},P2={trace:0,debug:1,info:2,warn:3,error:4,off:5},I2="xterm.js: ",dp=class extends ft{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=P2[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,i){this._evalLazyOptionalParams(i),e.call(console,(this._optionsService.options.logger?"":I2)+t,...i)}trace(e,...t){var i;this._logLevel<=0&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var i;this._logLevel<=1&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var i;this._logLevel<=2&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var i;this._logLevel<=3&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var i;this._logLevel<=4&&this._log(((i=this._optionsService.options.logger)==null?void 0:i.error.bind(this._optionsService.options.logger))??console.error,e,t)}};dp=fi([Re(0,gn)],dp);var Bb=class extends ft{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new we),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new we),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new we),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let i=0;i<Math.min(e,this.length);i++)t[i]=this._array[this._getCyclicIndex(i)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...i){if(t){for(let s=e;s<this._length-t;s++)this._array[this._getCyclicIndex(s)]=this._array[this._getCyclicIndex(s+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let s=this._length-1;s>=e;s--)this._array[this._getCyclicIndex(s+i.length)]=this._array[this._getCyclicIndex(s)];for(let s=0;s<i.length;s++)this._array[this._getCyclicIndex(e+s)]=i[s];if(i.length&&this.onInsertEmitter.fire({index:e,amount:i.length}),this._length+i.length>this._maxLength){let s=this._length+i.length-this._maxLength;this._startIndex+=s,this._length=this._maxLength,this.onTrimEmitter.fire(s)}else this._length+=i.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,i){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+i<0)throw new Error("Cannot shift elements in list beyond index 0");if(i>0){for(let a=t-1;a>=0;a--)this.set(e+a+i,this.get(e+a));let s=e+t+i-this._length;if(s>0)for(this._length+=s;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let s=0;s<t;s++)this.set(e+s+i,this.get(e+s))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},dt=3,Ci=Object.freeze(new Ro),eu=0,sf=2,xo=class c0{constructor(t,i,s=!1){this.isWrapped=s,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*dt);let a=i||lr.fromCharData([0,Ty,1,0]);for(let o=0;o<t;++o)this.setCell(o,a);this.length=t}get(t){let i=this._data[t*dt+0],s=i&2097151;return[this._data[t*dt+1],i&2097152?this._combined[t]:s?js(s):"",i>>22,i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s]}set(t,i){this._data[t*dt+1]=i[0],i[1].length>1?(this._combined[t]=i[1],this._data[t*dt+0]=t|2097152|i[2]<<22):this._data[t*dt+0]=i[1].charCodeAt(0)|i[2]<<22}getWidth(t){return this._data[t*dt+0]>>22}hasWidth(t){return this._data[t*dt+0]&12582912}getFg(t){return this._data[t*dt+1]}getBg(t){return this._data[t*dt+2]}hasContent(t){return this._data[t*dt+0]&4194303}getCodePoint(t){let i=this._data[t*dt+0];return i&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i&2097151}isCombined(t){return this._data[t*dt+0]&2097152}getString(t){let i=this._data[t*dt+0];return i&2097152?this._combined[t]:i&2097151?js(i&2097151):""}isProtected(t){return this._data[t*dt+2]&536870912}loadCell(t,i){return eu=t*dt,i.content=this._data[eu+0],i.fg=this._data[eu+1],i.bg=this._data[eu+2],i.content&2097152&&(i.combinedData=this._combined[t]),i.bg&268435456&&(i.extended=this._extendedAttrs[t]),i}setCell(t,i){i.content&2097152&&(this._combined[t]=i.combinedData),i.bg&268435456&&(this._extendedAttrs[t]=i.extended),this._data[t*dt+0]=i.content,this._data[t*dt+1]=i.fg,this._data[t*dt+2]=i.bg}setCellFromCodepoint(t,i,s,a){a.bg&268435456&&(this._extendedAttrs[t]=a.extended),this._data[t*dt+0]=i|s<<22,this._data[t*dt+1]=a.fg,this._data[t*dt+2]=a.bg}addCodepointToCell(t,i,s){let a=this._data[t*dt+0];a&2097152?this._combined[t]+=js(i):a&2097151?(this._combined[t]=js(a&2097151)+js(i),a&=-2097152,a|=2097152):a=i|1<<22,s&&(a&=-12582913,a|=s<<22),this._data[t*dt+0]=a}insertCells(t,i,s){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length-t){let a=new lr;for(let o=this.length-t-i-1;o>=0;--o)this.setCell(t+i+o,this.loadCell(t+o,a));for(let o=0;o<i;++o)this.setCell(t+o,s)}else for(let a=t;a<this.length;++a)this.setCell(a,s);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,s)}deleteCells(t,i,s){if(t%=this.length,i<this.length-t){let a=new lr;for(let o=0;o<this.length-t-i;++o)this.setCell(t+o,this.loadCell(t+i+o,a));for(let o=this.length-i;o<this.length;++o)this.setCell(o,s)}else for(let a=t;a<this.length;++a)this.setCell(a,s);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,s)}replaceCells(t,i,s,a=!1){if(a){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&!this.isProtected(i)&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.isProtected(t)||this.setCell(t,s),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,s),i<this.length&&this.getWidth(i-1)===2&&this.setCellFromCodepoint(i,0,1,s);t<i&&t<this.length;)this.setCell(t++,s)}resize(t,i){if(t===this.length)return this._data.length*4*sf<this._data.buffer.byteLength;let s=t*dt;if(t>this.length){if(this._data.buffer.byteLength>=s*4)this._data=new Uint32Array(this._data.buffer,0,s);else{let a=new Uint32Array(s);a.set(this._data),this._data=a}for(let a=this.length;a<t;++a)this.setCell(a,i)}else{this._data=this._data.subarray(0,s);let a=Object.keys(this._combined);for(let c=0;c<a.length;c++){let h=parseInt(a[c],10);h>=t&&delete this._combined[h]}let o=Object.keys(this._extendedAttrs);for(let c=0;c<o.length;c++){let h=parseInt(o[c],10);h>=t&&delete this._extendedAttrs[h]}}return this.length=t,s*4*sf<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*sf<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,i=!1){if(i){for(let s=0;s<this.length;++s)this.isProtected(s)||this.setCell(s,t);return}this._combined={},this._extendedAttrs={};for(let s=0;s<this.length;++s)this.setCell(s,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let i in t._combined)this._combined[i]=t._combined[i];this._extendedAttrs={};for(let i in t._extendedAttrs)this._extendedAttrs[i]=t._extendedAttrs[i];this.isWrapped=t.isWrapped}clone(){let t=new c0(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let i in this._combined)t._combined[i]=this._combined[i];for(let i in this._extendedAttrs)t._extendedAttrs[i]=this._extendedAttrs[i];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*dt+0]&4194303)return t+(this._data[t*dt+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*dt+0]&4194303||this._data[t*dt+2]&50331648)return t+(this._data[t*dt+0]>>22);return 0}copyCellsFrom(t,i,s,a,o){let c=t._data;if(o)for(let p=a-1;p>=0;p--){for(let f=0;f<dt;f++)this._data[(s+p)*dt+f]=c[(i+p)*dt+f];c[(i+p)*dt+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}else for(let p=0;p<a;p++){for(let f=0;f<dt;f++)this._data[(s+p)*dt+f]=c[(i+p)*dt+f];c[(i+p)*dt+2]&268435456&&(this._extendedAttrs[s+p]=t._extendedAttrs[i+p])}let h=Object.keys(t._combined);for(let p=0;p<h.length;p++){let f=parseInt(h[p],10);f>=i&&(this._combined[f-i+s]=t._combined[f])}}translateToString(t,i,s,a){i=i??0,s=s??this.length,t&&(s=Math.min(s,this.getTrimmedLength())),a&&(a.length=0);let o="";for(;i<s;){let c=this._data[i*dt+0],h=c&2097151,p=c&2097152?this._combined[i]:h?js(h):Rs;if(o+=p,a)for(let f=0;f<p.length;++f)a.push(i);i+=c>>22||1}return a&&a.push(i),o}};function H2(e,t,i,s,a,o){let c=[];for(let h=0;h<e.length-1;h++){let p=h,f=e.get(++p);if(!f.isWrapped)continue;let _=[e.get(h)];for(;p<e.length&&f.isWrapped;)_.push(f),f=e.get(++p);if(!o&&s>=h&&s<p){h+=_.length-1;continue}let x=0,b=Eo(_,x,t),v=1,y=0;for(;v<_.length;){let j=Eo(_,v,t),E=j-y,z=i-b,O=Math.min(E,z);_[x].copyCellsFrom(_[v],y,b,O,!1),b+=O,b===i&&(x++,b=0),y+=O,y===j&&(v++,y=0),b===0&&x!==0&&_[x-1].getWidth(i-1)===2&&(_[x].copyCellsFrom(_[x-1],i-1,b++,1,!1),_[x-1].setCell(i-1,a))}_[x].replaceCells(b,i,a);let N=0;for(let j=_.length-1;j>0&&(j>x||_[j].getTrimmedLength()===0);j--)N++;N>0&&(c.push(h+_.length-N),c.push(N)),h+=_.length-1}return c}function U2(e,t){let i=[],s=0,a=t[s],o=0;for(let c=0;c<e.length;c++)if(a===c){let h=t[++s];e.onDeleteEmitter.fire({index:c-o,amount:h}),c+=h-1,o+=h,a=t[++s]}else i.push(c);return{layout:i,countRemoved:o}}function $2(e,t){let i=[];for(let s=0;s<t.length;s++)i.push(e.get(t[s]));for(let s=0;s<i.length;s++)e.set(s,i[s]);e.length=t.length}function F2(e,t,i){let s=[],a=e.map((p,f)=>Eo(e,f,t)).reduce((p,f)=>p+f),o=0,c=0,h=0;for(;h<a;){if(a-h<i){s.push(a-h);break}o+=i;let p=Eo(e,c,t);o>p&&(o-=p,c++);let f=e[c].getWidth(o-1)===2;f&&o--;let _=f?i-1:i;s.push(_),h+=_}return s}function Eo(e,t,i){if(t===e.length-1)return e[t].getTrimmedLength();let s=!e[t].hasContent(i-1)&&e[t].getWidth(i-1)===1,a=e[t+1].getWidth(0)===2;return s&&a?i-1:i}var u0=class h0{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=h0._nextId++,this._onDispose=this.register(new we),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),aa(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};u0._nextId=1;var q2=u0,Ri={},na=Ri.B;Ri[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Ri.A={"#":"£"};Ri.B=void 0;Ri[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ri.C=Ri[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ri.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ri.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ri.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ri.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ri.E=Ri[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ri.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ri.H=Ri[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ri["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var Lb=4294967295,Ob=class{constructor(e,t,i){this._hasScrollback=e,this._optionsService=t,this._bufferService=i,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ci.clone(),this.savedCharset=na,this.markers=[],this._nullCell=lr.fromCharData([0,Ty,1,0]),this._whitespaceCell=lr.fromCharData([0,Rs,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new Nu,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new Bb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new wu),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new wu),this._whitespaceCell}getBlankLine(e,t){return new xo(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>Lb?Lb:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ci);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new Bb(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let i=this.getNullCell(Ci),s=0,a=this._getCorrectBufferLength(t);if(a>this.lines.maxLength&&(this.lines.maxLength=a),this.lines.length>0){if(this._cols<e)for(let c=0;c<this.lines.length;c++)s+=+this.lines.get(c).resize(e,i);let o=0;if(this._rows<t)for(let c=this._rows;c<t;c++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new xo(e,i)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new xo(e,i)));else for(let c=this._rows;c>t;c--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(a<this.lines.maxLength){let c=this.lines.length-a;c>0&&(this.lines.trimStart(c),this.ybase=Math.max(this.ybase-c,0),this.ydisp=Math.max(this.ydisp-c,0),this.savedY=Math.max(this.savedY-c,0)),this.lines.maxLength=a}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)s+=+this.lines.get(o).resize(e,i);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),s>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=H2(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ci),i);if(s.length>0){let a=U2(this.lines,s);$2(this.lines,a.layout),this._reflowLargerAdjustViewport(e,t,a.countRemoved)}}_reflowLargerAdjustViewport(e,t,i){let s=this.getNullCell(Ci),a=i;for(;a-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new xo(e,s))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-i,0)}_reflowSmaller(e,t){let i=this._optionsService.rawOptions.reflowCursorLine,s=this.getNullCell(Ci),a=[],o=0;for(let c=this.lines.length-1;c>=0;c--){let h=this.lines.get(c);if(!h||!h.isWrapped&&h.getTrimmedLength()<=e)continue;let p=[h];for(;h.isWrapped&&c>0;)h=this.lines.get(--c),p.unshift(h);if(!i){let O=this.ybase+this.y;if(O>=c&&O<c+p.length)continue}let f=p[p.length-1].getTrimmedLength(),_=F2(p,this._cols,e),x=_.length-p.length,b;this.ybase===0&&this.y!==this.lines.length-1?b=Math.max(0,this.y-this.lines.maxLength+x):b=Math.max(0,this.lines.length-this.lines.maxLength+x);let v=[];for(let O=0;O<x;O++){let W=this.getBlankLine(Ci,!0);v.push(W)}v.length>0&&(a.push({start:c+p.length+o,newLines:v}),o+=v.length),p.push(...v);let y=_.length-1,N=_[y];N===0&&(y--,N=_[y]);let j=p.length-x-1,E=f;for(;j>=0;){let O=Math.min(E,N);if(p[y]===void 0)break;if(p[y].copyCellsFrom(p[j],E-O,N-O,O,!0),N-=O,N===0&&(y--,N=_[y]),E-=O,E===0){j--;let W=Math.max(j,0);E=Eo(p,W,this._cols)}}for(let O=0;O<p.length;O++)_[O]<e&&p[O].setCell(_[O],s);let z=x-b;for(;z-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+x,this.ybase+t-1)}if(a.length>0){let c=[],h=[];for(let N=0;N<this.lines.length;N++)h.push(this.lines.get(N));let p=this.lines.length,f=p-1,_=0,x=a[_];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let b=0;for(let N=Math.min(this.lines.maxLength-1,p+o-1);N>=0;N--)if(x&&x.start>f+b){for(let j=x.newLines.length-1;j>=0;j--)this.lines.set(N--,x.newLines[j]);N++,c.push({index:f+1,amount:x.newLines.length}),b+=x.newLines.length,x=a[++_]}else this.lines.set(N,h[f--]);let v=0;for(let N=c.length-1;N>=0;N--)c[N].index+=v,this.lines.onInsertEmitter.fire(c[N]),v+=c[N].amount;let y=Math.max(0,p+o-this.lines.maxLength);y>0&&this.lines.onTrimEmitter.fire(y)}}translateBufferLineToString(e,t,i=0,s){let a=this.lines.get(e);return a?a.translateToString(t,i,s):""}getWrappedRangeForLine(e){let t=e,i=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;i+1<this.lines.length&&this.lines.get(i+1).isWrapped;)i++;return{first:t,last:i}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new q2(e);return this.markers.push(t),t.register(this.lines.onTrim(i=>{t.line-=i,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(i=>{t.line>=i.index&&(t.line+=i.amount)})),t.register(this.lines.onDelete(i=>{t.line>=i.index&&t.line<i.index+i.amount&&t.dispose(),t.line>i.index&&(t.line-=i.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},W2=class extends ft{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new we),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new Ob(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ob(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},d0=2,f0=1,fp=class extends ft{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,d0),this.rows=Math.max(e.rawOptions.rows||0,f0),this.buffers=this._register(new W2(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let i=this.cols!==e,s=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:i,rowsChanged:s})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let i=this.buffer,s;s=this._cachedBlankLine,(!s||s.length!==this.cols||s.getFg(0)!==e.fg||s.getBg(0)!==e.bg)&&(s=i.getBlankLine(e,t),this._cachedBlankLine=s),s.isWrapped=t;let a=i.ybase+i.scrollTop,o=i.ybase+i.scrollBottom;if(i.scrollTop===0){let c=i.lines.isFull;o===i.lines.length-1?c?i.lines.recycle().copyFrom(s):i.lines.push(s.clone()):i.lines.splice(o+1,0,s.clone()),c?this.isUserScrolling&&(i.ydisp=Math.max(i.ydisp-1,0)):(i.ybase++,this.isUserScrolling||i.ydisp++)}else{let c=o-a+1;i.lines.shiftElements(a+1,c-1,-1),i.lines.set(o,s.clone())}this.isUserScrolling||(i.ydisp=i.ybase),this._onScroll.fire(i.ydisp)}scrollLines(e,t){let i=this.buffer;if(e<0){if(i.ydisp===0)return;this.isUserScrolling=!0}else e+i.ydisp>=i.ybase&&(this.isUserScrolling=!1);let s=i.ydisp;i.ydisp=Math.max(Math.min(i.ydisp+e,i.ybase),0),s!==i.ydisp&&(t||this._onScroll.fire(i.ydisp))}};fp=fi([Re(0,gn)],fp);var Va={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Eu,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},G2=["normal","bold","100","200","300","400","500","600","700","800","900"],Y2=class extends ft{constructor(e){super(),this._onOptionChange=this._register(new we),this.onOptionChange=this._onOptionChange.event;let t={...Va};for(let i in e)if(i in t)try{let s=e[i];t[i]=this._sanitizeAndValidateOption(i,s)}catch(s){console.error(s)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ti(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(i=>{i===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(i=>{e.indexOf(i)!==-1&&t()})}_setupOptions(){let e=i=>{if(!(i in Va))throw new Error(`No option with key "${i}"`);return this.rawOptions[i]},t=(i,s)=>{if(!(i in Va))throw new Error(`No option with key "${i}"`);s=this._sanitizeAndValidateOption(i,s),this.rawOptions[i]!==s&&(this.rawOptions[i]=s,this._onOptionChange.fire(i))};for(let i in this.rawOptions){let s={get:e.bind(this,i),set:t.bind(this,i)};Object.defineProperty(this.options,i,s)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Va[e]),!K2(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Va[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=G2.includes(t)?t:Va[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function K2(e){return e==="block"||e==="underline"||e==="bar"}function _o(e,t=5){if(typeof e!="object")return e;let i=Array.isArray(e)?[]:{};for(let s in e)i[s]=t<=1?e[s]:e[s]&&_o(e[s],t-1);return i}var zb=Object.freeze({insertMode:!1}),Pb=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),pp=class extends ft{constructor(e,t,i){super(),this._bufferService=e,this._logService=t,this._optionsService=i,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new we),this.onData=this._onData.event,this._onUserInput=this._register(new we),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new we),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=_o(zb),this.decPrivateModes=_o(Pb)}reset(){this.modes=_o(zb),this.decPrivateModes=_o(Pb)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let i=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&i.ybase!==i.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(s=>s.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};pp=fi([Re(0,mn),Re(1,Dy),Re(2,gn)],pp);var Ib={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function af(e,t){let i=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(i|=64,i|=e.action):(i|=e.button&3,e.button&4&&(i|=64),e.button&8&&(i|=128),e.action===32?i|=32:e.action===0&&!t&&(i|=3)),i}var lf=String.fromCharCode,Hb={DEFAULT:e=>{let t=[af(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${lf(t[0])}${lf(t[1])}${lf(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${af(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${af(e,!0)};${e.x};${e.y}${t}`}},mp=class extends ft{constructor(e,t,i){super(),this._bufferService=e,this._coreService=t,this._optionsService=i,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new we),this.onProtocolChange=this._onProtocolChange.event;for(let s of Object.keys(Ib))this.addProtocol(s,Ib[s]);for(let s of Object.keys(Hb))this.addEncoding(s,Hb[s]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,i){if(e.deltaY===0||e.shiftKey||t===void 0||i===void 0)return 0;let s=t/i,a=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(a/=s+0,Math.abs(e.deltaY)<50&&(a*=.3),this._wheelPartialScroll+=a,a=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(a*=this._bufferService.rows),a}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,i){if(i){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};mp=fi([Re(0,mn),Re(1,ca),Re(2,gn)],mp);var of=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],V2=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],ji;function X2(e,t){let i=0,s=t.length-1,a;if(e<t[0][0]||e>t[s][1])return!1;for(;s>=i;)if(a=i+s>>1,e>t[a][1])i=a+1;else if(e<t[a][0])s=a-1;else return!0;return!1}var Z2=class{constructor(){if(this.version="6",!ji){ji=new Uint8Array(65536),ji.fill(1),ji[0]=0,ji.fill(0,1,32),ji.fill(0,127,160),ji.fill(2,4352,4448),ji[9001]=2,ji[9002]=2,ji.fill(2,11904,42192),ji[12351]=1,ji.fill(2,44032,55204),ji.fill(2,63744,64256),ji.fill(2,65040,65050),ji.fill(2,65072,65136),ji.fill(2,65280,65377),ji.fill(2,65504,65511);for(let e=0;e<of.length;++e)ji.fill(0,of[e][0],of[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?ji[e]:X2(e,V2)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let i=this.wcwidth(e),s=i===0&&t!==0;if(s){let a=ra.extractWidth(t);a===0?s=!1:a>i&&(i=a)}return ra.createPropertyValue(0,i,s)}},ra=class gu{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new we,this.onChange=this._onChange.event;let t=new Z2;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,i,s=!1){return(t&16777215)<<3|(i&3)<<1|(s?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let i=0,s=0,a=t.length;for(let o=0;o<a;++o){let c=t.charCodeAt(o);if(55296<=c&&c<=56319){if(++o>=a)return i+this.wcwidth(c);let f=t.charCodeAt(o);56320<=f&&f<=57343?c=(c-55296)*1024+f-56320+65536:i+=this.wcwidth(f)}let h=this.charProperties(c,s),p=gu.extractWidth(h);gu.extractShouldJoin(h)&&(p-=gu.extractWidth(s)),i+=p,s=h}return i}charProperties(t,i){return this._activeProvider.charProperties(t,i)}},Q2=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function Ub(e){var s;let t=(s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:s.get(e.cols-1),i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);i&&t&&(i.isWrapped=t[3]!==0&&t[3]!==32)}var ao=2147483647,J2=256,p0=class gp{constructor(t=32,i=32){if(this.maxLength=t,this.maxSubParamsLength=i,i>J2)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(i),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let i=new gp;if(!t.length)return i;for(let s=Array.isArray(t[0])?1:0;s<t.length;++s){let a=t[s];if(Array.isArray(a))for(let o=0;o<a.length;++o)i.addSubParam(a[o]);else i.addParam(a)}return i}clone(){let t=new gp(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let i=0;i<this.length;++i){t.push(this.params[i]);let s=this._subParamsIdx[i]>>8,a=this._subParamsIdx[i]&255;a-s>0&&t.push(Array.prototype.slice.call(this._subParams,s,a))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>ao?ao:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>ao?ao:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let i=this._subParamsIdx[t]>>8,s=this._subParamsIdx[t]&255;return s-i>0?this._subParams.subarray(i,s):null}getSubParamsAll(){let t={};for(let i=0;i<this.length;++i){let s=this._subParamsIdx[i]>>8,a=this._subParamsIdx[i]&255;a-s>0&&(t[i]=this._subParams.slice(s,a))}return t}addDigit(t){let i;if(this._rejectDigits||!(i=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let s=this._digitIsSub?this._subParams:this.params,a=s[i-1];s[i-1]=~a?Math.min(a*10+t,ao):t}},lo=[],eE=class{constructor(){this._state=0,this._active=lo,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=lo}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=lo,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||lo,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,i){if(!this._active.length)this._handlerFb(this._id,"PUT",Bu(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}start(){this.reset(),this._state=1}put(e,t,i){if(this._state!==3){if(this._state===1)for(;t<i;){let s=e[t++];if(s===59){this._state=2,this._start();break}if(s<48||57<s){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+s-48}this._state===2&&i-t>0&&this._put(e,t,i)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].end(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].end(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=lo,this._id=-1,this._state=0}}},Hn=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Bu(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(i=>(this._data="",this._hitLimit=!1,i));return this._data="",this._hitLimit=!1,t}},oo=[],tE=class{constructor(){this._handlers=Object.create(null),this._active=oo,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=oo}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let i=this._handlers[e];return i.push(t),{dispose:()=>{let s=i.indexOf(t);s!==-1&&i.splice(s,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=oo,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||oo,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let i=this._active.length-1;i>=0;i--)this._active[i].hook(t)}put(e,t,i){if(!this._active.length)this._handlerFb(this._ident,"PUT",Bu(e,t,i));else for(let s=this._active.length-1;s>=0;s--)this._active[s].put(e,t,i)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let i=!1,s=this._active.length-1,a=!1;if(this._stack.paused&&(s=this._stack.loopPosition-1,i=t,a=this._stack.fallThrough,this._stack.paused=!1),!a&&i===!1){for(;s>=0&&(i=this._active[s].unhook(e),i!==!0);s--)if(i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!1,i;s--}for(;s>=0;s--)if(i=this._active[s].unhook(!1),i instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=s,this._stack.fallThrough=!0,i}this._active=oo,this._ident=0}},bo=new p0;bo.addParam(0);var $b=class{constructor(e){this._handler=e,this._data="",this._params=bo,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():bo,this._data="",this._hitLimit=!1}put(e,t,i){this._hitLimit||(this._data+=Bu(e,t,i),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(i=>(this._params=bo,this._data="",this._hitLimit=!1,i));return this._params=bo,this._data="",this._hitLimit=!1,t}},iE=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,i,s){this.table[t<<8|e]=i<<4|s}addMany(e,t,i,s){for(let a=0;a<e.length;a++)this.table[t<<8|e[a]]=i<<4|s}},rr=160,nE=(function(){let e=new iE(4095),t=Array.apply(null,Array(256)).map((h,p)=>p),i=(h,p)=>t.slice(h,p),s=i(32,127),a=i(0,24);a.push(25),a.push.apply(a,i(28,32));let o=i(0,14),c;e.setDefault(1,0),e.addMany(s,0,2,0);for(c in o)e.addMany([24,26,153,154],c,3,0),e.addMany(i(128,144),c,3,0),e.addMany(i(144,152),c,3,0),e.add(156,c,0,0),e.add(27,c,11,1),e.add(157,c,4,8),e.addMany([152,158,159],c,0,7),e.add(155,c,11,3),e.add(144,c,11,9);return e.addMany(a,0,3,0),e.addMany(a,1,3,1),e.add(127,1,0,1),e.addMany(a,8,0,8),e.addMany(a,3,3,3),e.add(127,3,0,3),e.addMany(a,4,3,4),e.add(127,4,0,4),e.addMany(a,6,3,6),e.addMany(a,5,3,5),e.add(127,5,0,5),e.addMany(a,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(s,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(i(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(s,7,0,7),e.addMany(a,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(i(64,127),3,7,0),e.addMany(i(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(i(48,60),4,8,4),e.addMany(i(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(i(32,64),6,0,6),e.add(127,6,0,6),e.addMany(i(64,127),6,0,0),e.addMany(i(32,48),3,9,5),e.addMany(i(32,48),5,9,5),e.addMany(i(48,64),5,0,6),e.addMany(i(64,127),5,7,0),e.addMany(i(32,48),4,9,5),e.addMany(i(32,48),1,9,2),e.addMany(i(32,48),2,9,2),e.addMany(i(48,127),2,10,0),e.addMany(i(48,80),1,10,0),e.addMany(i(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(i(96,127),1,10,0),e.add(80,1,11,9),e.addMany(a,9,0,9),e.add(127,9,0,9),e.addMany(i(28,32),9,0,9),e.addMany(i(32,48),9,9,12),e.addMany(i(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(a,11,0,11),e.addMany(i(32,128),11,0,11),e.addMany(i(28,32),11,0,11),e.addMany(a,10,0,10),e.add(127,10,0,10),e.addMany(i(28,32),10,0,10),e.addMany(i(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(i(32,48),10,9,12),e.addMany(a,12,0,12),e.add(127,12,0,12),e.addMany(i(28,32),12,0,12),e.addMany(i(32,48),12,9,12),e.addMany(i(48,64),12,0,11),e.addMany(i(64,127),12,12,13),e.addMany(i(64,127),10,12,13),e.addMany(i(64,127),9,12,13),e.addMany(a,13,13,13),e.addMany(s,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(rr,0,2,0),e.add(rr,8,5,8),e.add(rr,6,0,6),e.add(rr,11,0,11),e.add(rr,13,13,13),e})(),rE=class extends ft{constructor(e=nE){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new p0,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,i,s)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,i)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ti(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new eE),this._dcsParser=this._register(new tE),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let i=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(i=e.prefix.charCodeAt(0),i&&60>i||i>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let a=0;a<e.intermediates.length;++a){let o=e.intermediates.charCodeAt(a);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");i<<=8,i|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let s=e.final.charCodeAt(0);if(t[0]>s||s>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return i<<=8,i|=s,i}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let i=this._identifier(e,[48,126]);this._escHandlers[i]===void 0&&(this._escHandlers[i]=[]);let s=this._escHandlers[i];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let i=this._identifier(e);this._csiHandlers[i]===void 0&&(this._csiHandlers[i]=[]);let s=this._csiHandlers[i];return s.push(t),{dispose:()=>{let a=s.indexOf(t);a!==-1&&s.splice(a,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,i,s,a){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=i,this._parseStack.transition=s,this._parseStack.chunkPos=a}parse(e,t,i){let s=0,a=0,o=0,c;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(i===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let h=this._parseStack.handlers,p=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(i===!1&&p>-1){for(;p>=0&&(c=h[p](this._params),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 4:if(i===!1&&p>-1){for(;p>=0&&(c=h[p](),c!==!0);p--)if(c instanceof Promise)return this._parseStack.handlerPos=p,c}this._parseStack.handlers=[];break;case 6:if(s=e[this._parseStack.chunkPos],c=this._dcsParser.unhook(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(s=e[this._parseStack.chunkPos],c=this._oscParser.end(s!==24&&s!==26,i),c)return c;s===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let h=o;h<t;++h){switch(s=e[h],a=this._transitions.table[this.currentState<<8|(s<160?s:rr)],a>>4){case 2:for(let b=h+1;;++b){if(b>=t||(s=e[b])<32||s>126&&s<rr){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<rr){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<rr){this._printHandler(e,h,b),h=b-1;break}if(++b>=t||(s=e[b])<32||s>126&&s<rr){this._printHandler(e,h,b),h=b-1;break}}break;case 3:this._executeHandlers[s]?this._executeHandlers[s]():this._executeHandlerFb(s),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:h,code:s,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let p=this._csiHandlers[this._collect<<8|s],f=p?p.length-1:-1;for(;f>=0&&(c=p[f](this._params),c!==!0);f--)if(c instanceof Promise)return this._preserveStack(3,p,f,a,h),c;f<0&&this._csiHandlerFb(this._collect<<8|s,this._params),this.precedingJoinState=0;break;case 8:do switch(s){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(s-48)}while(++h<t&&(s=e[h])>47&&s<60);h--;break;case 9:this._collect<<=8,this._collect|=s;break;case 10:let _=this._escHandlers[this._collect<<8|s],x=_?_.length-1:-1;for(;x>=0&&(c=_[x](),c!==!0);x--)if(c instanceof Promise)return this._preserveStack(4,_,x,a,h),c;x<0&&this._escHandlerFb(this._collect<<8|s),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|s,this._params);break;case 13:for(let b=h+1;;++b)if(b>=t||(s=e[b])===24||s===26||s===27||s>127&&s<rr){this._dcsParser.put(e,h,b),h=b-1;break}break;case 14:if(c=this._dcsParser.unhook(s!==24&&s!==26),c)return this._preserveStack(6,[],0,a,h),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let b=h+1;;b++)if(b>=t||(s=e[b])<32||s>127&&s<rr){this._oscParser.put(e,h,b),h=b-1;break}break;case 6:if(c=this._oscParser.end(s!==24&&s!==26),c)return this._preserveStack(5,[],0,a,h),c;s===27&&(a|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=a&15}}},sE=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,aE=/^[\da-f]+$/;function Fb(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let i=sE.exec(t);if(i){let s=i[1]?15:i[4]?255:i[7]?4095:65535;return[Math.round(parseInt(i[1]||i[4]||i[7]||i[10],16)/s*255),Math.round(parseInt(i[2]||i[5]||i[8]||i[11],16)/s*255),Math.round(parseInt(i[3]||i[6]||i[9]||i[12],16)/s*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),aE.exec(t)&&[3,6,9,12].includes(t.length))){let i=t.length/3,s=[0,0,0];for(let a=0;a<3;++a){let o=parseInt(t.slice(i*a,i*a+i),16);s[a]=i===1?o<<4:i===2?o:i===3?o>>4:o>>8}return s}}function cf(e,t){let i=e.toString(16),s=i.length<2?"0"+i:i;switch(t){case 4:return i[0];case 8:return s;case 12:return(s+s).slice(0,3);default:return s+s}}function lE(e,t=16){let[i,s,a]=e;return`rgb:${cf(i,t)}/${cf(s,t)}/${cf(a,t)}`}var oE={"(":0,")":1,"*":2,"+":3,"-":1,".":2},Ns=131072,qb=10;function Wb(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Gb=5e3,Yb=0,cE=class extends ft{constructor(e,t,i,s,a,o,c,h,p=new rE){super(),this._bufferService=e,this._charsetService=t,this._coreService=i,this._logService=s,this._optionsService=a,this._oscLinkService=o,this._coreMouseService=c,this._unicodeService=h,this._parser=p,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new TC,this._utf8Decoder=new jC,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ci.clone(),this._eraseAttrDataInternal=Ci.clone(),this._onRequestBell=this._register(new we),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new we),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new we),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new we),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new we),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new we),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new we),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new we),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new we),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new we),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new xp(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(f=>this._activeBuffer=f.activeBuffer)),this._parser.setCsiHandlerFallback((f,_)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(f),params:_.toArray()})}),this._parser.setEscHandlerFallback(f=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(f)})}),this._parser.setExecuteHandlerFallback(f=>{this._logService.debug("Unknown EXECUTE code: ",{code:f})}),this._parser.setOscHandlerFallback((f,_,x)=>{this._logService.debug("Unknown OSC code: ",{identifier:f,action:_,data:x})}),this._parser.setDcsHandlerFallback((f,_,x)=>{_==="HOOK"&&(x=x.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(f),action:_,payload:x})}),this._parser.setPrintHandler((f,_,x)=>this.print(f,_,x)),this._parser.registerCsiHandler({final:"@"},f=>this.insertChars(f)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},f=>this.scrollLeft(f)),this._parser.registerCsiHandler({final:"A"},f=>this.cursorUp(f)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},f=>this.scrollRight(f)),this._parser.registerCsiHandler({final:"B"},f=>this.cursorDown(f)),this._parser.registerCsiHandler({final:"C"},f=>this.cursorForward(f)),this._parser.registerCsiHandler({final:"D"},f=>this.cursorBackward(f)),this._parser.registerCsiHandler({final:"E"},f=>this.cursorNextLine(f)),this._parser.registerCsiHandler({final:"F"},f=>this.cursorPrecedingLine(f)),this._parser.registerCsiHandler({final:"G"},f=>this.cursorCharAbsolute(f)),this._parser.registerCsiHandler({final:"H"},f=>this.cursorPosition(f)),this._parser.registerCsiHandler({final:"I"},f=>this.cursorForwardTab(f)),this._parser.registerCsiHandler({final:"J"},f=>this.eraseInDisplay(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},f=>this.eraseInDisplay(f,!0)),this._parser.registerCsiHandler({final:"K"},f=>this.eraseInLine(f,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},f=>this.eraseInLine(f,!0)),this._parser.registerCsiHandler({final:"L"},f=>this.insertLines(f)),this._parser.registerCsiHandler({final:"M"},f=>this.deleteLines(f)),this._parser.registerCsiHandler({final:"P"},f=>this.deleteChars(f)),this._parser.registerCsiHandler({final:"S"},f=>this.scrollUp(f)),this._parser.registerCsiHandler({final:"T"},f=>this.scrollDown(f)),this._parser.registerCsiHandler({final:"X"},f=>this.eraseChars(f)),this._parser.registerCsiHandler({final:"Z"},f=>this.cursorBackwardTab(f)),this._parser.registerCsiHandler({final:"`"},f=>this.charPosAbsolute(f)),this._parser.registerCsiHandler({final:"a"},f=>this.hPositionRelative(f)),this._parser.registerCsiHandler({final:"b"},f=>this.repeatPrecedingCharacter(f)),this._parser.registerCsiHandler({final:"c"},f=>this.sendDeviceAttributesPrimary(f)),this._parser.registerCsiHandler({prefix:">",final:"c"},f=>this.sendDeviceAttributesSecondary(f)),this._parser.registerCsiHandler({final:"d"},f=>this.linePosAbsolute(f)),this._parser.registerCsiHandler({final:"e"},f=>this.vPositionRelative(f)),this._parser.registerCsiHandler({final:"f"},f=>this.hVPosition(f)),this._parser.registerCsiHandler({final:"g"},f=>this.tabClear(f)),this._parser.registerCsiHandler({final:"h"},f=>this.setMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"h"},f=>this.setModePrivate(f)),this._parser.registerCsiHandler({final:"l"},f=>this.resetMode(f)),this._parser.registerCsiHandler({prefix:"?",final:"l"},f=>this.resetModePrivate(f)),this._parser.registerCsiHandler({final:"m"},f=>this.charAttributes(f)),this._parser.registerCsiHandler({final:"n"},f=>this.deviceStatus(f)),this._parser.registerCsiHandler({prefix:"?",final:"n"},f=>this.deviceStatusPrivate(f)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},f=>this.softReset(f)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},f=>this.setCursorStyle(f)),this._parser.registerCsiHandler({final:"r"},f=>this.setScrollRegion(f)),this._parser.registerCsiHandler({final:"s"},f=>this.saveCursor(f)),this._parser.registerCsiHandler({final:"t"},f=>this.windowOptions(f)),this._parser.registerCsiHandler({final:"u"},f=>this.restoreCursor(f)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},f=>this.insertColumns(f)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},f=>this.deleteColumns(f)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},f=>this.selectProtected(f)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},f=>this.requestMode(f,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},f=>this.requestMode(f,!1)),this._parser.setExecuteHandler(pe.BEL,()=>this.bell()),this._parser.setExecuteHandler(pe.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(pe.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(pe.BS,()=>this.backspace()),this._parser.setExecuteHandler(pe.HT,()=>this.tab()),this._parser.setExecuteHandler(pe.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(pe.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(pu.IND,()=>this.index()),this._parser.setExecuteHandler(pu.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(pu.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Hn(f=>(this.setTitle(f),this.setIconName(f),!0))),this._parser.registerOscHandler(1,new Hn(f=>this.setIconName(f))),this._parser.registerOscHandler(2,new Hn(f=>this.setTitle(f))),this._parser.registerOscHandler(4,new Hn(f=>this.setOrReportIndexedColor(f))),this._parser.registerOscHandler(8,new Hn(f=>this.setHyperlink(f))),this._parser.registerOscHandler(10,new Hn(f=>this.setOrReportFgColor(f))),this._parser.registerOscHandler(11,new Hn(f=>this.setOrReportBgColor(f))),this._parser.registerOscHandler(12,new Hn(f=>this.setOrReportCursorColor(f))),this._parser.registerOscHandler(104,new Hn(f=>this.restoreIndexedColor(f))),this._parser.registerOscHandler(110,new Hn(f=>this.restoreFgColor(f))),this._parser.registerOscHandler(111,new Hn(f=>this.restoreBgColor(f))),this._parser.registerOscHandler(112,new Hn(f=>this.restoreCursorColor(f))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let f in Ri)this._parser.registerEscHandler({intermediates:"(",final:f},()=>this.selectCharset("("+f)),this._parser.registerEscHandler({intermediates:")",final:f},()=>this.selectCharset(")"+f)),this._parser.registerEscHandler({intermediates:"*",final:f},()=>this.selectCharset("*"+f)),this._parser.registerEscHandler({intermediates:"+",final:f},()=>this.selectCharset("+"+f)),this._parser.registerEscHandler({intermediates:"-",final:f},()=>this.selectCharset("-"+f)),this._parser.registerEscHandler({intermediates:".",final:f},()=>this.selectCharset("."+f)),this._parser.registerEscHandler({intermediates:"/",final:f},()=>this.selectCharset("/"+f));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(f=>(this._logService.error("Parsing error: ",f),f)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new $b((f,_)=>this.requestStatusString(f,_)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,i,s){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=i,this._parseStack.position=s}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,i)=>setTimeout(()=>i("#SLOW_TIMEOUT"),Gb))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Gb} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let i,s=this._activeBuffer.x,a=this._activeBuffer.y,o=0,c=this._parseStack.paused;if(c){if(i=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(i),i;s=this._parseStack.cursorStartX,a=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>Ns&&(o=this._parseStack.position+Ns)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,f=>String.fromCharCode(f)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(f=>f.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<Ns&&(this._parseBuffer=new Uint32Array(Math.min(e.length,Ns))),c||this._dirtyRowTracker.clearRange(),e.length>Ns)for(let f=o;f<e.length;f+=Ns){let _=f+Ns<e.length?f+Ns:e.length,x=typeof e=="string"?this._stringDecoder.decode(e.substring(f,_),this._parseBuffer):this._utf8Decoder.decode(e.subarray(f,_),this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,x))return this._preserveStack(s,a,x,f),this._logSlowResolvingAsync(i),i}else if(!c){let f=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(i=this._parser.parse(this._parseBuffer,f))return this._preserveStack(s,a,f,0),this._logSlowResolvingAsync(i),i}(this._activeBuffer.x!==s||this._activeBuffer.y!==a)&&this._onCursorMove.fire();let h=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),p=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);p<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(p,this._bufferService.rows-1),end:Math.min(h,this._bufferService.rows-1)})}print(e,t,i){let s,a,o=this._charsetService.charset,c=this._optionsService.rawOptions.screenReaderMode,h=this._bufferService.cols,p=this._coreService.decPrivateModes.wraparound,f=this._coreService.modes.insertMode,_=this._curAttrData,x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&i-t>0&&x.getWidth(this._activeBuffer.x-1)===2&&x.setCellFromCodepoint(this._activeBuffer.x-1,0,1,_);let b=this._parser.precedingJoinState;for(let v=t;v<i;++v){if(s=e[v],s<127&&o){let E=o[String.fromCharCode(s)];E&&(s=E.charCodeAt(0))}let y=this._unicodeService.charProperties(s,b);a=ra.extractWidth(y);let N=ra.extractShouldJoin(y),j=N?ra.extractWidth(b):0;if(b=y,c&&this._onA11yChar.fire(js(s)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+a-j>h){if(p){let E=x,z=this._activeBuffer.x-j;for(this._activeBuffer.x=j,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),x=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),j>0&&x instanceof xo&&x.copyCellsFrom(E,z,0,j,!1);z<h;)E.setCellFromCodepoint(z++,0,1,_)}else if(this._activeBuffer.x=h-1,a===2)continue}if(N&&this._activeBuffer.x){let E=x.getWidth(this._activeBuffer.x-1)?1:2;x.addCodepointToCell(this._activeBuffer.x-E,s,a);for(let z=a-j;--z>=0;)x.setCellFromCodepoint(this._activeBuffer.x++,0,0,_);continue}if(f&&(x.insertCells(this._activeBuffer.x,a-j,this._activeBuffer.getNullCell(_)),x.getWidth(h-1)===2&&x.setCellFromCodepoint(h-1,0,1,_)),x.setCellFromCodepoint(this._activeBuffer.x++,s,a,_),a>0)for(;--a;)x.setCellFromCodepoint(this._activeBuffer.x++,0,0,_)}this._parser.precedingJoinState=b,this._activeBuffer.x<h&&i-t>0&&x.getWidth(this._activeBuffer.x)===0&&!x.hasContent(this._activeBuffer.x)&&x.setCellFromCodepoint(this._activeBuffer.x,0,1,_),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,i=>Wb(i.params[0],this._optionsService.rawOptions.windowOptions)?t(i):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new $b(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Hn(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,i,s=!1,a=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,i,this._activeBuffer.getNullCell(this._eraseAttrData()),a),s&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);i&&(i.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),i.isWrapped=!1)}eraseInDisplay(e,t=!1){var s;this._restrictCursor(this._bufferService.cols);let i;switch(e.params[0]){case 0:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);i<this._bufferService.rows;i++)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(i);break;case 1:for(i=this._activeBuffer.y,this._dirtyRowTracker.markDirty(i),this._eraseInBufferLine(i,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(i+1).isWrapped=!1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(i=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,i-1);i--&&!((s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i))!=null&&s.getTrimmedLength()););for(;i>=0;i--)this._bufferService.scroll(this._eraseAttrData())}else{for(i=this._bufferService.rows,this._dirtyRowTracker.markDirty(i-1);i--;)this._resetBufferLine(i,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let a=this._activeBuffer.lines.length-this._bufferService.rows;a>0&&(this._activeBuffer.lines.trimStart(a),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-a,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-a,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,a=this._bufferService.rows-1+this._activeBuffer.ybase-s+1;for(;t--;)this._activeBuffer.lines.splice(a-1,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let i=this._activeBuffer.ybase+this._activeBuffer.y,s;for(s=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-s;t--;)this._activeBuffer.lines.splice(i,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ci));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let i=this._activeBuffer.scrollTop;i<=this._activeBuffer.scrollBottom;++i){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+i);s.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),s.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let i=e.params[0]||1,s=ra.extractWidth(t),a=this._activeBuffer.x-s,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(a),c=new Uint32Array(o.length*i),h=0;for(let f=0;f<o.length;){let _=o.codePointAt(f)||0;c[h++]=_,f+=_>65535?2:1}let p=h;for(let f=1;f<i;++f)c.copyWithin(p,0,h),p+=h;return this.print(c,0,p),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(pe.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(pe.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(pe.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(pe.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(pe.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,na),this._charsetService.setgCharset(1,na),this._charsetService.setgCharset(2,na),this._charsetService.setgCharset(3,na);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(N=>(N[N.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",N[N.SET=1]="SET",N[N.RESET=2]="RESET",N[N.PERMANENTLY_SET=3]="PERMANENTLY_SET",N[N.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(i={}));let s=this._coreService.decPrivateModes,{activeProtocol:a,activeEncoding:o}=this._coreMouseService,c=this._coreService,{buffers:h,cols:p}=this._bufferService,{active:f,alt:_}=h,x=this._optionsService.rawOptions,b=(N,j)=>(c.triggerDataEvent(`${pe.ESC}[${t?"":"?"}${N};${j}$y`),!0),v=N=>N?1:2,y=e.params[0];return t?y===2?b(y,4):y===4?b(y,v(c.modes.insertMode)):y===12?b(y,3):y===20?b(y,v(x.convertEol)):b(y,0):y===1?b(y,v(s.applicationCursorKeys)):y===3?b(y,x.windowOptions.setWinLines?p===80?2:p===132?1:0:0):y===6?b(y,v(s.origin)):y===7?b(y,v(s.wraparound)):y===8?b(y,3):y===9?b(y,v(a==="X10")):y===12?b(y,v(x.cursorBlink)):y===25?b(y,v(!c.isCursorHidden)):y===45?b(y,v(s.reverseWraparound)):y===66?b(y,v(s.applicationKeypad)):y===67?b(y,4):y===1e3?b(y,v(a==="VT200")):y===1002?b(y,v(a==="DRAG")):y===1003?b(y,v(a==="ANY")):y===1004?b(y,v(s.sendFocus)):y===1005?b(y,4):y===1006?b(y,v(o==="SGR")):y===1015?b(y,4):y===1016?b(y,v(o==="SGR_PIXELS")):y===1048?b(y,1):y===47||y===1047||y===1049?b(y,v(f===_)):y===2004?b(y,v(s.bracketedPasteMode)):y===2026?b(y,v(s.synchronizedOutput)):b(y,0)}_updateAttrColor(e,t,i,s,a){return t===2?(e|=50331648,e&=-16777216,e|=Ro.fromColorRGB([i,s,a])):t===5&&(e&=-50331904,e|=33554432|i&255),e}_extractColor(e,t,i){let s=[0,0,-1,0,0,0],a=0,o=0;do{if(s[o+a]=e.params[t+o],e.hasSubParams(t+o)){let c=e.getSubParams(t+o),h=0;do s[1]===5&&(a=1),s[o+h+1+a]=c[h];while(++h<c.length&&h+o+1+a<s.length);break}if(s[1]===5&&o+a>=2||s[1]===2&&o+a>=5)break;s[1]&&(a=1)}while(++o+t<e.length&&o+a<s.length);for(let c=2;c<s.length;++c)s[c]===-1&&(s[c]=0);switch(s[0]){case 38:i.fg=this._updateAttrColor(i.fg,s[1],s[3],s[4],s[5]);break;case 48:i.bg=this._updateAttrColor(i.bg,s[1],s[3],s[4],s[5]);break;case 58:i.extended=i.extended.clone(),i.extended.underlineColor=this._updateAttrColor(i.extended.underlineColor,s[1],s[3],s[4],s[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ci.fg,e.bg=Ci.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,i,s=this._curAttrData;for(let a=0;a<t;a++)i=e.params[a],i>=30&&i<=37?(s.fg&=-50331904,s.fg|=16777216|i-30):i>=40&&i<=47?(s.bg&=-50331904,s.bg|=16777216|i-40):i>=90&&i<=97?(s.fg&=-50331904,s.fg|=16777216|i-90|8):i>=100&&i<=107?(s.bg&=-50331904,s.bg|=16777216|i-100|8):i===0?this._processSGR0(s):i===1?s.fg|=134217728:i===3?s.bg|=67108864:i===4?(s.fg|=268435456,this._processUnderline(e.hasSubParams(a)?e.getSubParams(a)[0]:1,s)):i===5?s.fg|=536870912:i===7?s.fg|=67108864:i===8?s.fg|=1073741824:i===9?s.fg|=2147483648:i===2?s.bg|=134217728:i===21?this._processUnderline(2,s):i===22?(s.fg&=-134217729,s.bg&=-134217729):i===23?s.bg&=-67108865:i===24?(s.fg&=-268435457,this._processUnderline(0,s)):i===25?s.fg&=-536870913:i===27?s.fg&=-67108865:i===28?s.fg&=-1073741825:i===29?s.fg&=2147483647:i===39?(s.fg&=-67108864,s.fg|=Ci.fg&16777215):i===49?(s.bg&=-67108864,s.bg|=Ci.bg&16777215):i===38||i===48||i===58?a+=this._extractColor(e,a,s):i===53?s.bg|=1073741824:i===55?s.bg&=-1073741825:i===59?(s.extended=s.extended.clone(),s.extended.underlineColor=-1,s.updateExtended()):i===100?(s.fg&=-67108864,s.fg|=Ci.fg&16777215,s.bg&=-67108864,s.bg|=Ci.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",i);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${pe.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[${t};${i}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,i=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${pe.ESC}[?${t};${i}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ci.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let i=t%2===1;this._coreService.decPrivateModes.cursorBlink=i}return!0}setScrollRegion(e){let t=e.params[0]||1,i;return(e.length<2||(i=e.params[1])>this._bufferService.rows||i===0)&&(i=this._bufferService.rows),i>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=i-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Wb(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${pe.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>qb&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>qb&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],i=e.split(";");for(;i.length>1;){let s=i.shift(),a=i.shift();if(/^\d+$/.exec(s)){let o=parseInt(s);if(Kb(o))if(a==="?")t.push({type:0,index:o});else{let c=Fb(a);c&&t.push({type:1,index:o,color:c})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let i=e.slice(0,t).trim(),s=e.slice(t+1);return s?this._createHyperlink(i,s):i.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let i=e.split(":"),s,a=i.findIndex(o=>o.startsWith("id="));return a!==-1&&(s=i[a].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:s,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let i=e.split(";");for(let s=0;s<i.length&&!(t>=this._specialColors.length);++s,++t)if(i[s]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let a=Fb(i[s]);a&&this._onColor.fire([{type:1,index:this._specialColors[t],color:a}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],i=e.split(";");for(let s=0;s<i.length;++s)if(/^\d+$/.exec(i[s])){let a=parseInt(i[s]);Kb(a)&&t.push({type:2,index:a})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,na),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(oE[e[0]],Ri[e[1]]||na),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ci.clone(),this._eraseAttrDataInternal=Ci.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new lr;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let i=this._activeBuffer.ybase+this._activeBuffer.y+t,s=this._activeBuffer.lines.get(i);s&&(s.fill(e),s.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let i=c=>(this._coreService.triggerDataEvent(`${pe.ESC}${c}${pe.ESC}\\`),!0),s=this._bufferService.buffer,a=this._optionsService.rawOptions;return i(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${s.scrollTop+1};${s.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[a.cursorStyle]-(a.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},xp=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Yb=e,e=t,t=Yb),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};xp=fi([Re(0,mn)],xp);function Kb(e){return 0<=e&&e<256}var uE=5e7,Vb=12,hE=50,dE=class extends ft{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let i;for(;i=this._writeBuffer.shift();){this._action(i);let s=this._callbacks.shift();s&&s()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>uE)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let i=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let s=this._writeBuffer[this._bufferOffset],a=this._action(s,t);if(a){let c=h=>performance.now()-i>=Vb?setTimeout(()=>this._innerWrite(0,h)):this._innerWrite(i,h);a.catch(h=>(queueMicrotask(()=>{throw h}),Promise.resolve(!1))).then(c);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=s.length,performance.now()-i>=Vb)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>hE&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},_p=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let h=t.addMarker(t.ybase+t.y),p={data:e,id:this._nextId++,lines:[h]};return h.onDispose(()=>this._removeMarkerFromLink(p,h)),this._dataByLinkId.set(p.id,p),p.id}let i=e,s=this._getEntryIdKey(i),a=this._entriesWithId.get(s);if(a)return this.addLineToLink(a.id,t.ybase+t.y),a.id;let o=t.addMarker(t.ybase+t.y),c={id:this._nextId++,key:this._getEntryIdKey(i),data:i,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(c,o)),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(e,t){let i=this._dataByLinkId.get(e);if(i&&i.lines.every(s=>s.line!==t)){let s=this._bufferService.buffer.addMarker(t);i.lines.push(s),s.onDispose(()=>this._removeMarkerFromLink(i,s))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let i=e.lines.indexOf(t);i!==-1&&(e.lines.splice(i,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};_p=fi([Re(0,mn)],_p);var Xb=!1,fE=class extends ft{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new sl),this._onBinary=this._register(new we),this.onBinary=this._onBinary.event,this._onData=this._register(new we),this.onData=this._onData.event,this._onLineFeed=this._register(new we),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new we),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new we),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new we),this._instantiationService=new z2,this.optionsService=this._register(new Y2(e)),this._instantiationService.setService(gn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(fp)),this._instantiationService.setService(mn,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(dp)),this._instantiationService.setService(Dy,this._logService),this.coreService=this._register(this._instantiationService.createInstance(pp)),this._instantiationService.setService(ca,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(mp)),this._instantiationService.setService(My,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(ra)),this._instantiationService.setService(DC,this.unicodeService),this._charsetService=this._instantiationService.createInstance(Q2),this._instantiationService.setService(MC,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(_p),this._instantiationService.setService(By,this._oscLinkService),this._inputHandler=this._register(new cE(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Zi.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Zi.forward(this._bufferService.onResize,this._onResize)),this._register(Zi.forward(this.coreService.onData,this._onData)),this._register(Zi.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new dE((t,i)=>this._inputHandler.parse(t,i))),this._register(Zi.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new we),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Xb&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Xb=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,d0),t=Math.max(t,f0),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(Ub.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(Ub(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ti(()=>{for(let t of e)t.dispose()})}}},pE={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function mE(e,t,i,s){var c;let a={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?a.key=pe.ESC+"OA":a.key=pe.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?a.key=pe.ESC+"OD":a.key=pe.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?a.key=pe.ESC+"OC":a.key=pe.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?a.key=pe.ESC+"OB":a.key=pe.ESC+"[B");break;case 8:a.key=e.ctrlKey?"\b":pe.DEL,e.altKey&&(a.key=pe.ESC+a.key);break;case 9:if(e.shiftKey){a.key=pe.ESC+"[Z";break}a.key=pe.HT,a.cancel=!0;break;case 13:a.key=e.altKey?pe.ESC+pe.CR:pe.CR,a.cancel=!0;break;case 27:a.key=pe.ESC,e.altKey&&(a.key=pe.ESC+pe.ESC),a.cancel=!0;break;case 37:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"D":t?a.key=pe.ESC+"OD":a.key=pe.ESC+"[D";break;case 39:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"C":t?a.key=pe.ESC+"OC":a.key=pe.ESC+"[C";break;case 38:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"A":t?a.key=pe.ESC+"OA":a.key=pe.ESC+"[A";break;case 40:if(e.metaKey)break;o?a.key=pe.ESC+"[1;"+(o+1)+"B":t?a.key=pe.ESC+"OB":a.key=pe.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(a.key=pe.ESC+"[2~");break;case 46:o?a.key=pe.ESC+"[3;"+(o+1)+"~":a.key=pe.ESC+"[3~";break;case 36:o?a.key=pe.ESC+"[1;"+(o+1)+"H":t?a.key=pe.ESC+"OH":a.key=pe.ESC+"[H";break;case 35:o?a.key=pe.ESC+"[1;"+(o+1)+"F":t?a.key=pe.ESC+"OF":a.key=pe.ESC+"[F";break;case 33:e.shiftKey?a.type=2:e.ctrlKey?a.key=pe.ESC+"[5;"+(o+1)+"~":a.key=pe.ESC+"[5~";break;case 34:e.shiftKey?a.type=3:e.ctrlKey?a.key=pe.ESC+"[6;"+(o+1)+"~":a.key=pe.ESC+"[6~";break;case 112:o?a.key=pe.ESC+"[1;"+(o+1)+"P":a.key=pe.ESC+"OP";break;case 113:o?a.key=pe.ESC+"[1;"+(o+1)+"Q":a.key=pe.ESC+"OQ";break;case 114:o?a.key=pe.ESC+"[1;"+(o+1)+"R":a.key=pe.ESC+"OR";break;case 115:o?a.key=pe.ESC+"[1;"+(o+1)+"S":a.key=pe.ESC+"OS";break;case 116:o?a.key=pe.ESC+"[15;"+(o+1)+"~":a.key=pe.ESC+"[15~";break;case 117:o?a.key=pe.ESC+"[17;"+(o+1)+"~":a.key=pe.ESC+"[17~";break;case 118:o?a.key=pe.ESC+"[18;"+(o+1)+"~":a.key=pe.ESC+"[18~";break;case 119:o?a.key=pe.ESC+"[19;"+(o+1)+"~":a.key=pe.ESC+"[19~";break;case 120:o?a.key=pe.ESC+"[20;"+(o+1)+"~":a.key=pe.ESC+"[20~";break;case 121:o?a.key=pe.ESC+"[21;"+(o+1)+"~":a.key=pe.ESC+"[21~";break;case 122:o?a.key=pe.ESC+"[23;"+(o+1)+"~":a.key=pe.ESC+"[23~";break;case 123:o?a.key=pe.ESC+"[24;"+(o+1)+"~":a.key=pe.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?a.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?a.key=pe.NUL:e.keyCode>=51&&e.keyCode<=55?a.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?a.key=pe.DEL:e.keyCode===219?a.key=pe.ESC:e.keyCode===220?a.key=pe.FS:e.keyCode===221&&(a.key=pe.GS);else if((!i||s)&&e.altKey&&!e.metaKey){let h=(c=pE[e.keyCode])==null?void 0:c[e.shiftKey?1:0];if(h)a.key=pe.ESC+h;else if(e.keyCode>=65&&e.keyCode<=90){let p=e.ctrlKey?e.keyCode-64:e.keyCode+32,f=String.fromCharCode(p);e.shiftKey&&(f=f.toUpperCase()),a.key=pe.ESC+f}else if(e.keyCode===32)a.key=pe.ESC+(e.ctrlKey?pe.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let p=e.code.slice(3,4);e.shiftKey||(p=p.toLowerCase()),a.key=pe.ESC+p,a.cancel=!0}}else i&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(a.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?a.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(a.key=pe.US),e.key==="@"&&(a.key=pe.NUL));break}return a}var xi=0,gE=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new Nu,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new Nu,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((a,o)=>this._getKey(a)-this._getKey(o)),t=0,i=0,s=new Array(this._array.length+this._insertedValues.length);for(let a=0;a<s.length;a++)i>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[i])?(s[a]=e[t],t++):s[a]=this._array[i++];this._array=s,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(xi=this._search(t),xi===-1)||this._getKey(this._array[xi])!==t)return!1;do if(this._array[xi]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(xi),!0;while(++xi<this._array.length&&this._getKey(this._array[xi])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((a,o)=>a-o),t=0,i=new Array(this._array.length-e.length),s=0;for(let a=0;a<this._array.length;a++)e[t]===a?t++:i[s++]=this._array[a];this._array=i,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xi=this._search(e),!(xi<0||xi>=this._array.length)&&this._getKey(this._array[xi])===e))do yield this._array[xi];while(++xi<this._array.length&&this._getKey(this._array[xi])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(xi=this._search(e),!(xi<0||xi>=this._array.length)&&this._getKey(this._array[xi])===e))do t(this._array[xi]);while(++xi<this._array.length&&this._getKey(this._array[xi])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,i=this._array.length-1;for(;i>=t;){let s=t+i>>1,a=this._getKey(this._array[s]);if(a>e)i=s-1;else if(a<e)t=s+1;else{for(;s>0&&this._getKey(this._array[s-1])===e;)s--;return s}}return t}},uf=0,Zb=0,xE=class extends ft{constructor(){super(),this._decorations=new gE(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new we),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new we),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ti(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new _E(e);if(t){let i=t.marker.onDispose(()=>t.dispose()),s=t.onDispose(()=>{s.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),i.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,i){let s=0,a=0;for(let o of this._decorations.getKeyIterator(t))s=o.options.x??0,a=s+(o.options.width??1),e>=s&&e<a&&(!i||(o.options.layer??"bottom")===i)&&(yield o)}forEachDecorationAtCell(e,t,i,s){this._decorations.forEachByKey(t,a=>{uf=a.options.x??0,Zb=uf+(a.options.width??1),e>=uf&&e<Zb&&(!i||(a.options.layer??"bottom")===i)&&s(a)})}},_E=class extends Ms{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new we),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new we),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ai.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ai.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},bE=1e3,vE=class{constructor(e,t=bE){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,i){this._rowCount=i,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let s=performance.now();if(s-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=s,this._innerRefresh();else if(!this._additionalRefreshRequested){let a=s-this._lastRefreshMs,o=this._debounceThresholdMS-a;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Qb=20,Tu=class extends ft{constructor(e,t,i,s){super(),this._terminal=e,this._coreBrowserService=i,this._renderService=s,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let a=this._coreBrowserService.mainDocument;this._accessibilityContainer=a.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=a.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=a.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new vE(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
73
+ `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Ke(a,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ti(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<Qb+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
74
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===Qb+1&&(this._liveRegion.textContent+=Pf.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let i=this._terminal.buffer,s=i.lines.length.toString();for(let a=e;a<=t;a++){let o=i.lines.get(i.ydisp+a),c=[],h=(o==null?void 0:o.translateToString(!0,void 0,void 0,c))||"",p=(i.ydisp+a+1).toString(),f=this._rowElements[a];f&&(h.length===0?(f.textContent=" ",this._rowColumns.set(f,[0,1])):(f.textContent=h,this._rowColumns.set(f,c)),f.setAttribute("aria-posinset",p),f.setAttribute("aria-setsize",s),this._alignRowWidth(f))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let i=e.target,s=this._rowElements[t===0?1:this._rowElements.length-2],a=i.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(a===o||e.relatedTarget!==s)return;let c,h;if(t===0?(c=i,h=this._rowElements.pop(),this._rowContainer.removeChild(h)):(c=this._rowElements.shift(),h=i,this._rowContainer.removeChild(c)),c.removeEventListener("focus",this._topBoundaryFocusListener),h.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let p=this._createAccessibilityTreeNode();this._rowElements.unshift(p),this._rowContainer.insertAdjacentElement("afterbegin",p)}else{let p=this._createAccessibilityTreeNode();this._rowElements.push(p),this._rowContainer.appendChild(p)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var h;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},i={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(i.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===i.node&&t.offset>i.offset)&&([t,i]=[i,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let s=this._rowElements.slice(-1)[0];if(i.node.compareDocumentPosition(s)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(i={node:s,offset:((h=s.textContent)==null?void 0:h.length)??0}),!this._rowContainer.contains(i.node))return;let a=({node:p,offset:f})=>{let _=p instanceof Text?p.parentNode:p,x=parseInt(_==null?void 0:_.getAttribute("aria-posinset"),10)-1;if(isNaN(x))return console.warn("row is invalid. Race condition?"),null;let b=this._rowColumns.get(_);if(!b)return console.warn("columns is null. Race condition?"),null;let v=f<b.length?b[f]:b.slice(-1)[0]+1;return v>=this._terminal.cols&&(++x,v=0),{row:x,column:v}},o=a(t),c=a(i);if(!(!o||!c)){if(o.row>c.row||o.row===c.row&&o.column>=c.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(c.row-o.row)*this._terminal.cols-o.column+c.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var a,o;e.style.transform="";let t=e.getBoundingClientRect().width,i=(o=(a=this._rowColumns.get(e))==null?void 0:a.slice(-1))==null?void 0:o[0];if(!i)return;let s=i*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${s/t})`}};Tu=fi([Re(1,Pp),Re(2,Qr),Re(3,Jr)],Tu);var bp=class extends ft{constructor(e,t,i,s,a){super(),this._element=e,this._mouseService=t,this._renderService=i,this._bufferService=s,this._linkProviderService=a,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new we),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new we),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ti(()=>{var o;aa(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Ke(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Ke(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Ke(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Ke(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let i=e.composedPath();for(let s=0;s<i.length;s++){let a=i[s];if(a.classList.contains("xterm"))break;if(a.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var s,a;(!this._activeProviderReplies||!t)&&((s=this._activeProviderReplies)==null||s.forEach(o=>{o==null||o.forEach(c=>{c.link.dispose&&c.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let i=!1;for(let[o,c]of this._linkProviderService.linkProviders.entries())t?(a=this._activeProviderReplies)!=null&&a.get(o)&&(i=this._checkLinkProviderResult(o,e,i)):c.provideLinks(e.y,h=>{var f,_;if(this._isMouseOut)return;let p=h==null?void 0:h.map(x=>({link:x}));(f=this._activeProviderReplies)==null||f.set(o,p),i=this._checkLinkProviderResult(o,e,i),((_=this._activeProviderReplies)==null?void 0:_.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let i=new Set;for(let s=0;s<t.size;s++){let a=t.get(s);if(a)for(let o=0;o<a.length;o++){let c=a[o],h=c.link.range.start.y<e?0:c.link.range.start.x,p=c.link.range.end.y>e?this._bufferService.cols:c.link.range.end.x;for(let f=h;f<=p;f++){if(i.has(f)){a.splice(o--,1);break}i.add(f)}}}}_checkLinkProviderResult(e,t,i){var o;if(!this._activeProviderReplies)return i;let s=this._activeProviderReplies.get(e),a=!1;for(let c=0;c<e;c++)(!this._activeProviderReplies.has(c)||this._activeProviderReplies.get(c))&&(a=!0);if(!a&&s){let c=s.find(h=>this._linkAtPosition(h.link,t));c&&(i=!0,this._handleNewLink(c))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!i)for(let c=0;c<this._activeProviderReplies.size;c++){let h=(o=this._activeProviderReplies.get(c))==null?void 0:o.find(p=>this._linkAtPosition(p.link,t));if(h){i=!0,this._handleNewLink(h);break}}return i}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&yE(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,aa(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.pointerCursor},set:i=>{var s;(s=this._currentLink)!=null&&s.state&&this._currentLink.state.decorations.pointerCursor!==i&&(this._currentLink.state.decorations.pointerCursor=i,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",i))}},underline:{get:()=>{var i,s;return(s=(i=this._currentLink)==null?void 0:i.state)==null?void 0:s.decorations.underline},set:i=>{var s,a,o;(s=this._currentLink)!=null&&s.state&&((o=(a=this._currentLink)==null?void 0:a.state)==null?void 0:o.decorations.underline)!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(i=>{if(!this._currentLink)return;let s=i.start===0?0:i.start+1+this._bufferService.buffer.ydisp,a=this._bufferService.buffer.ydisp+1+i.end;if(this._currentLink.link.range.start.y>=s&&this._currentLink.link.range.end.y<=a&&(this._clearCurrentLink(s,a),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(i,t.text)}_fireUnderlineEvent(e,t){let i=e.range,s=this._bufferService.buffer.ydisp,a=this._createLinkUnderlineEvent(i.start.x-1,i.start.y-s-1,i.end.x,i.end.y-s-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(a)}_linkLeave(e,t,i){var s;(s=this._currentLink)!=null&&s.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(i,t.text)}_linkAtPosition(e,t){let i=e.range.start.y*this._bufferService.cols+e.range.start.x,s=e.range.end.y*this._bufferService.cols+e.range.end.x,a=t.y*this._bufferService.cols+t.x;return i<=a&&a<=s}_positionFromMouseEvent(e,t,i){let s=i.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(s)return{x:s[0],y:s[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,i,s,a){return{x1:e,y1:t,x2:i,y2:s,cols:this._bufferService.cols,fg:a}}};bp=fi([Re(1,Ip),Re(2,Jr),Re(3,mn),Re(4,Oy)],bp);function yE(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var SE=class extends fE{constructor(e={}){super(e),this._linkifier=this._register(new sl),this.browser=t0,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new sl),this._onCursorMove=this._register(new we),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new we),this.onKey=this._onKey.event,this._onRender=this._register(new we),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new we),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new we),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new we),this.onBell=this._onBell.event,this._onFocus=this._register(new we),this._onBlur=this._register(new we),this._onA11yCharEmitter=this._register(new we),this._onA11yTabEmitter=this._register(new we),this._onWillOpen=this._register(new we),this._setup(),this._decorationService=this._instantiationService.createInstance(xE),this._instantiationService.setService(Mo,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(h2),this._instantiationService.setService(Oy,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Hf)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Zi.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Zi.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Zi.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Zi.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ti(()=>{var t,i;this._customKeyEventHandler=void 0,(i=(t=this.element)==null?void 0:t.parentNode)==null||i.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let i,s="";switch(t.index){case 256:i="foreground",s="10";break;case 257:i="background",s="11";break;case 258:i="cursor",s="12";break;default:i="ansi",s="4;"+t.index}switch(t.type){case 0:let a=Qt.toColorRGB(i==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[i]);this.coreService.triggerDataEvent(`${pe.ESC}]${s};${lE(a)}${Jy.ST}`);break;case 1:if(i==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=ki.toColor(...t.color));else{let o=i;this._themeService.modifyColors(c=>c[o]=ki.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Tu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(pe.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let i=Math.min(this.buffer.x,this.cols-1),s=this._renderService.dimensions.css.cell.height,a=t.getWidth(i),o=this._renderService.dimensions.css.cell.width*a,c=this.buffer.y*this._renderService.dimensions.css.cell.height,h=i*this._renderService.dimensions.css.cell.width;this.textarea.style.left=h+"px",this.textarea.style.top=c+"px",this.textarea.style.width=o+"px",this.textarea.style.height=s+"px",this.textarea.style.lineHeight=s+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Ke(this.element,"copy",t=>{this.hasSelection()&&EC(t,this._selectionService)}));let e=t=>NC(t,this.textarea,this.coreService,this.optionsService);this._register(Ke(this.textarea,"paste",e)),this._register(Ke(this.element,"paste",e)),i0?this._register(Ke(this.element,"mousedown",t=>{t.button===2&&ob(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Ke(this.element,"contextmenu",t=>{ob(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Yp&&this._register(Ke(this.element,"auxclick",t=>{t.button===1&&Ny(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Ke(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Ke(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Ke(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Ke(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Ke(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Ke(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Ke(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var a;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((a=this.element)==null?void 0:a.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Ke(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let i=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",zf.get()),s0||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>i.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(c2,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Qr,this._coreBrowserService),this._register(Ke(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Ke(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(lp,this._document,this._helperContainer),this._instantiationService.setService(Lu,this._charSizeService),this._themeService=this._instantiationService.createInstance(hp),this._instantiationService.setService(ol,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ku),this._instantiationService.setService(Ly,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(cp,this.rows,this.screenElement)),this._instantiationService.setService(Jr,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(rp,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(op),this._instantiationService.setService(Ip,this._mouseService);let s=this._linkifier.value=this._register(this._instantiationService.createInstance(bp,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ip,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(up,this.element,this.screenElement,s)),this._instantiationService.setService(LC,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Zi.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(np,this.screenElement)),this._register(Ke(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Tu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Cu,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Cu,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(ap,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function i(o){var f,_,x,b,v;let c=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!c)return!1;let h,p;switch(o.overrideType||o.type){case"mousemove":p=32,o.buttons===void 0?(h=3,o.button!==void 0&&(h=o.button<3?o.button:3)):h=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":p=0,h=o.button<3?o.button:3;break;case"mousedown":p=1,h=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let y=o.deltaY;if(y===0||e.coreMouseService.consumeWheelEvent(o,(b=(x=(_=(f=e._renderService)==null?void 0:f.dimensions)==null?void 0:_.device)==null?void 0:x.cell)==null?void 0:b.height,(v=e._coreBrowserService)==null?void 0:v.dpr)===0)return!1;p=y<0?0:1,h=4;break;default:return!1}return p===void 0||h===void 0||h>4?!1:e.coreMouseService.triggerMouseEvent({col:c.col,row:c.row,x:c.x,y:c.y,button:h,action:p,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let s={mouseup:null,wheel:null,mousedrag:null,mousemove:null},a={mouseup:o=>(i(o),o.buttons||(this._document.removeEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.removeEventListener("mousemove",s.mousedrag)),this.cancel(o)),wheel:o=>(i(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&i(o)},mousemove:o=>{o.buttons||i(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?s.mousemove||(t.addEventListener("mousemove",a.mousemove),s.mousemove=a.mousemove):(t.removeEventListener("mousemove",s.mousemove),s.mousemove=null),o&16?s.wheel||(t.addEventListener("wheel",a.wheel,{passive:!1}),s.wheel=a.wheel):(t.removeEventListener("wheel",s.wheel),s.wheel=null),o&2?s.mouseup||(s.mouseup=a.mouseup):(this._document.removeEventListener("mouseup",s.mouseup),s.mouseup=null),o&4?s.mousedrag||(s.mousedrag=a.mousedrag):(this._document.removeEventListener("mousemove",s.mousedrag),s.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Ke(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return i(o),s.mouseup&&this._document.addEventListener("mouseup",s.mouseup),s.mousedrag&&this._document.addEventListener("mousemove",s.mousedrag),this.cancel(o)})),this._register(Ke(t,"wheel",o=>{var c,h,p,f,_;if(!s.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(f=(p=(h=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:h.device)==null?void 0:p.cell)==null?void 0:f.height,(_=e._coreBrowserService)==null?void 0:_.dpr)===0)return this.cancel(o,!0);let x=pe.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(x,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var i;(i=this._renderService)==null||i.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Ey(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,i){this._selectionService.setSelection(e,t,i)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var i;(i=this._selectionService)==null||i.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let i=mE(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),i.type===3||i.type===2){let s=this.rows-1;return this.scrollLines(i.type===2?-s:s),this.cancel(e,!0)}if(i.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(i.cancel&&this.cancel(e,!0),!i.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((i.key===pe.ETX||i.key===pe.CR)&&(this.textarea.value=""),this._onKey.fire({key:i.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let i=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?i:i&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(wE(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var i;(i=this._charSizeService)==null||i.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ci));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(pe.ESC+"[I"):this.coreService.triggerDataEvent(pe.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),i=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[4;${i};${t}t`);break;case 1:let s=this._renderService.dimensions.css.cell.width.toFixed(0),a=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${pe.ESC}[6;${a};${s}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function wE(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var CE=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let i={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(i),t.dispose=()=>this._wrappedAddonDispose(i),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let i=0;i<this._addons.length;i++)if(this._addons[i]===e){t=i;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},kE=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new lr)}translateToString(e,t,i){return this._line.translateToString(e,t,i)}},Jb=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new kE(t)}getNullCell(){return new lr}},EE=class extends ft{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new we),this.onBufferChange=this._onBufferChange.event,this._normal=new Jb(this._core.buffers.normal,"normal"),this._alternate=new Jb(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},NE=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,i=>t(i.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(i,s)=>t(i,s.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},TE=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},jE=["cols","rows"],Sr=0,AE=class extends ft{constructor(e){super(),this._core=this._register(new SE(e)),this._addonManager=this._register(new CE),this._publicOptions={...this._core.options};let t=s=>this._core.options[s],i=(s,a)=>{this._checkReadonlyOptions(s),this._core.options[s]=a};for(let s in this._core.options){let a={get:t.bind(this,s),set:i.bind(this,s)};Object.defineProperty(this._publicOptions,s,a)}}_checkReadonlyOptions(e){if(jE.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new NE(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new TE(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new EE(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,i){this._verifyIntegers(e,t,i),this._core.select(e,t,i)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
75
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return zf.get()},set promptLabel(e){zf.set(e)},get tooMuchOutput(){return Pf.get()},set tooMuchOutput(e){Pf.set(e)}}}_verifyIntegers(...e){for(Sr of e)if(Sr===1/0||isNaN(Sr)||Sr%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(Sr of e)if(Sr&&(Sr===1/0||isNaN(Sr)||Sr%1!==0||Sr<0))throw new Error("This API only accepts positive integers")}};/**
76
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
77
+ * @license MIT
78
+ *
79
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
80
+ * @license MIT
81
+ *
82
+ * Originally forked from (with the author's permission):
83
+ * Fabrice Bellard's javascript vt100 for jslinux:
84
+ * http://bellard.org/jslinux/
85
+ * Copyright (c) 2011 Fabrice Bellard
86
+ */var RE=2,ME=1,DE=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var x;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((x=this._terminal.options.overviewRuler)==null?void 0:x.width)||14,i=window.getComputedStyle(this._terminal.element.parentElement),s=parseInt(i.getPropertyValue("height")),a=Math.max(0,parseInt(i.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),c={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},h=c.top+c.bottom,p=c.right+c.left,f=s-h,_=a-p-t;return{cols:Math.max(RE,Math.floor(_/e.css.cell.width)),rows:Math.max(ME,Math.floor(f/e.css.cell.height))}}};/**
87
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
88
+ * @license MIT
89
+ *
90
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
91
+ * @license MIT
92
+ *
93
+ * Originally forked from (with the author's permission):
94
+ * Fabrice Bellard's javascript vt100 for jslinux:
95
+ * http://bellard.org/jslinux/
96
+ * Copyright (c) 2011 Fabrice Bellard
97
+ */var Pi=0,Ii=0,Hi=0,di=0,rn;(e=>{function t(a,o,c,h){return h!==void 0?`#${Js(a)}${Js(o)}${Js(c)}${Js(h)}`:`#${Js(a)}${Js(o)}${Js(c)}`}e.toCss=t;function i(a,o,c,h=255){return(a<<24|o<<16|c<<8|h)>>>0}e.toRgba=i;function s(a,o,c,h){return{css:e.toCss(a,o,c,h),rgba:e.toRgba(a,o,c,h)}}e.toColor=s})(rn||(rn={}));var BE;(e=>{function t(p,f){if(di=(f.rgba&255)/255,di===1)return{css:f.css,rgba:f.rgba};let _=f.rgba>>24&255,x=f.rgba>>16&255,b=f.rgba>>8&255,v=p.rgba>>24&255,y=p.rgba>>16&255,N=p.rgba>>8&255;Pi=v+Math.round((_-v)*di),Ii=y+Math.round((x-y)*di),Hi=N+Math.round((b-N)*di);let j=rn.toCss(Pi,Ii,Hi),E=rn.toRgba(Pi,Ii,Hi);return{css:j,rgba:E}}e.blend=t;function i(p){return(p.rgba&255)===255}e.isOpaque=i;function s(p,f,_){let x=xu.ensureContrastRatio(p.rgba,f.rgba,_);if(x)return rn.toColor(x>>24&255,x>>16&255,x>>8&255)}e.ensureContrastRatio=s;function a(p){let f=(p.rgba|255)>>>0;return[Pi,Ii,Hi]=xu.toChannels(f),{css:rn.toCss(Pi,Ii,Hi),rgba:f}}e.opaque=a;function o(p,f){return di=Math.round(f*255),[Pi,Ii,Hi]=xu.toChannels(p.rgba),{css:rn.toCss(Pi,Ii,Hi,di),rgba:rn.toRgba(Pi,Ii,Hi,di)}}e.opacity=o;function c(p,f){return di=p.rgba&255,o(p,di*f/255)}e.multiplyOpacity=c;function h(p){return[p.rgba>>24&255,p.rgba>>16&255,p.rgba>>8&255]}e.toColorRGB=h})(BE||(BE={}));var Vi;(e=>{let t,i;try{let a=document.createElement("canvas");a.width=1,a.height=1;let o=a.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",i=t.createLinearGradient(0,0,1,1))}catch{}function s(a){if(a.match(/#[\da-f]{3,8}/i))switch(a.length){case 4:return Pi=parseInt(a.slice(1,2).repeat(2),16),Ii=parseInt(a.slice(2,3).repeat(2),16),Hi=parseInt(a.slice(3,4).repeat(2),16),rn.toColor(Pi,Ii,Hi);case 5:return Pi=parseInt(a.slice(1,2).repeat(2),16),Ii=parseInt(a.slice(2,3).repeat(2),16),Hi=parseInt(a.slice(3,4).repeat(2),16),di=parseInt(a.slice(4,5).repeat(2),16),rn.toColor(Pi,Ii,Hi,di);case 7:return{css:a,rgba:(parseInt(a.slice(1),16)<<8|255)>>>0};case 9:return{css:a,rgba:parseInt(a.slice(1),16)>>>0}}let o=a.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Pi=parseInt(o[1]),Ii=parseInt(o[2]),Hi=parseInt(o[3]),di=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),rn.toColor(Pi,Ii,Hi,di);if(!t||!i)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=i,t.fillStyle=a,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Pi,Ii,Hi,di]=t.getImageData(0,0,1,1).data,di!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:rn.toRgba(Pi,Ii,Hi,di),css:a}}e.toColor=s})(Vi||(Vi={}));var fn;(e=>{function t(s){return i(s>>16&255,s>>8&255,s&255)}e.relativeLuminance=t;function i(s,a,o){let c=s/255,h=a/255,p=o/255,f=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),_=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4),x=p<=.03928?p/12.92:Math.pow((p+.055)/1.055,2.4);return f*.2126+_*.7152+x*.0722}e.relativeLuminance2=i})(fn||(fn={}));var xu;(e=>{function t(c,h){if(di=(h&255)/255,di===1)return h;let p=h>>24&255,f=h>>16&255,_=h>>8&255,x=c>>24&255,b=c>>16&255,v=c>>8&255;return Pi=x+Math.round((p-x)*di),Ii=b+Math.round((f-b)*di),Hi=v+Math.round((_-v)*di),rn.toRgba(Pi,Ii,Hi)}e.blend=t;function i(c,h,p){let f=fn.relativeLuminance(c>>8),_=fn.relativeLuminance(h>>8);if(Kr(f,_)<p){if(_<f){let v=s(c,h,p),y=Kr(f,fn.relativeLuminance(v>>8));if(y<p){let N=a(c,h,p),j=Kr(f,fn.relativeLuminance(N>>8));return y>j?v:N}return v}let x=a(c,h,p),b=Kr(f,fn.relativeLuminance(x>>8));if(b<p){let v=s(c,h,p),y=Kr(f,fn.relativeLuminance(v>>8));return b>y?x:v}return x}}e.ensureContrastRatio=i;function s(c,h,p){let f=c>>24&255,_=c>>16&255,x=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,N=Kr(fn.relativeLuminance2(b,v,y),fn.relativeLuminance2(f,_,x));for(;N<p&&(b>0||v>0||y>0);)b-=Math.max(0,Math.ceil(b*.1)),v-=Math.max(0,Math.ceil(v*.1)),y-=Math.max(0,Math.ceil(y*.1)),N=Kr(fn.relativeLuminance2(b,v,y),fn.relativeLuminance2(f,_,x));return(b<<24|v<<16|y<<8|255)>>>0}e.reduceLuminance=s;function a(c,h,p){let f=c>>24&255,_=c>>16&255,x=c>>8&255,b=h>>24&255,v=h>>16&255,y=h>>8&255,N=Kr(fn.relativeLuminance2(b,v,y),fn.relativeLuminance2(f,_,x));for(;N<p&&(b<255||v<255||y<255);)b=Math.min(255,b+Math.ceil((255-b)*.1)),v=Math.min(255,v+Math.ceil((255-v)*.1)),y=Math.min(255,y+Math.ceil((255-y)*.1)),N=Kr(fn.relativeLuminance2(b,v,y),fn.relativeLuminance2(f,_,x));return(b<<24|v<<16|y<<8|255)>>>0}e.increaseLuminance=a;function o(c){return[c>>24&255,c>>16&255,c>>8&255,c&255]}e.toChannels=o})(xu||(xu={}));function Js(e){let t=e.toString(16);return t.length<2?"0"+t:t}function Kr(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var LE=Object.freeze((()=>{let e=[Vi.toColor("#2e3436"),Vi.toColor("#cc0000"),Vi.toColor("#4e9a06"),Vi.toColor("#c4a000"),Vi.toColor("#3465a4"),Vi.toColor("#75507b"),Vi.toColor("#06989a"),Vi.toColor("#d3d7cf"),Vi.toColor("#555753"),Vi.toColor("#ef2929"),Vi.toColor("#8ae234"),Vi.toColor("#fce94f"),Vi.toColor("#729fcf"),Vi.toColor("#ad7fa8"),Vi.toColor("#34e2e2"),Vi.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let i=0;i<216;i++){let s=t[i/36%6|0],a=t[i/6%6|0],o=t[i%6];e.push({css:rn.toCss(s,a,o),rgba:rn.toRgba(s,a,o)})}for(let i=0;i<24;i++){let s=8+i*10;e.push({css:rn.toCss(s,s,s),rgba:rn.toRgba(s,s,s)})}return e})());function ev(e,t,i){return Math.max(t,Math.min(e,i))}function OE(e){switch(e){case"&":return"&amp;";case"<":return"&lt;"}return e}var m0=class{constructor(e){this._buffer=e}serialize(e,t){let i=this._buffer.getNullCell(),s=this._buffer.getNullCell(),a=i,o=e.start.y,c=e.end.y,h=e.start.x,p=e.end.x;this._beforeSerialize(c-o,o,c);for(let f=o;f<=c;f++){let _=this._buffer.getLine(f);if(_){let x=f===e.start.y?h:0,b=f===e.end.y?p:_.length;for(let v=x;v<b;v++){let y=_.getCell(v,a===i?s:i);if(!y){console.warn(`Can't get cell at row=${f}, col=${v}`);continue}this._nextCell(y,a,f,v),a=y}}this._rowEnd(f,f===c)}return this._afterSerialize(),this._serializeString(t)}_nextCell(e,t,i,s){}_rowEnd(e,t){}_beforeSerialize(e,t,i){}_afterSerialize(){}_serializeString(e){return""}};function g0(e,t){return e.getFgColorMode()===t.getFgColorMode()&&e.getFgColor()===t.getFgColor()}function Vr(e,t){return e.getBgColorMode()===t.getBgColorMode()&&e.getBgColor()===t.getBgColor()}function x0(e,t){return e.isInverse()===t.isInverse()&&e.isBold()===t.isBold()&&e.isUnderline()===t.isUnderline()&&e.isOverline()===t.isOverline()&&e.isBlink()===t.isBlink()&&e.isInvisible()===t.isInvisible()&&e.isItalic()===t.isItalic()&&e.isDim()===t.isDim()&&e.isStrikethrough()===t.isStrikethrough()}var zE=class extends m0{constructor(e,t){super(e),this._terminal=t,this._rowIndex=0,this._allRows=new Array,this._allRowSeparators=new Array,this._currentRow="",this._nullCellCount=0,this._cursorStyle=this._buffer.getNullCell(),this._cursorStyleRow=0,this._cursorStyleCol=0,this._backgroundCell=this._buffer.getNullCell(),this._firstRow=0,this._lastCursorRow=0,this._lastCursorCol=0,this._lastContentCursorRow=0,this._lastContentCursorCol=0,this._thisRowLastChar=this._buffer.getNullCell(),this._thisRowLastSecondChar=this._buffer.getNullCell(),this._nextRowFirstChar=this._buffer.getNullCell()}_beforeSerialize(e,t,i){this._allRows=new Array(e),this._lastContentCursorRow=t,this._lastCursorRow=t,this._firstRow=t}_rowEnd(e,t){var s;this._nullCellCount>0&&!Vr(this._cursorStyle,this._backgroundCell)&&(this._currentRow+=`\x1B[${this._nullCellCount}X`);let i="";if(!t){e-this._firstRow>=this._terminal.rows&&((s=this._buffer.getLine(this._cursorStyleRow))==null||s.getCell(this._cursorStyleCol,this._backgroundCell));let a=this._buffer.getLine(e),o=this._buffer.getLine(e+1);if(!o.isWrapped)i=`\r
98
+ `,this._lastCursorRow=e+1,this._lastCursorCol=0;else{i="";let c=a.getCell(a.length-1,this._thisRowLastChar),h=a.getCell(a.length-2,this._thisRowLastSecondChar),p=o.getCell(0,this._nextRowFirstChar),f=p.getWidth()>1,_=!1;(p.getChars()&&f?this._nullCellCount<=1:this._nullCellCount<=0)&&((c.getChars()||c.getWidth()===0)&&Vr(c,p)&&(_=!0),f&&(h.getChars()||h.getWidth()===0)&&Vr(c,p)&&Vr(h,p)&&(_=!0)),_||(i="-".repeat(this._nullCellCount+1),i+="\x1B[1D\x1B[1X",this._nullCellCount>0&&(i+="\x1B[A",i+=`\x1B[${a.length-this._nullCellCount}C`,i+=`\x1B[${this._nullCellCount}X`,i+=`\x1B[${a.length-this._nullCellCount}D`,i+="\x1B[B"),this._lastContentCursorRow=e+1,this._lastContentCursorCol=0,this._lastCursorRow=e+1,this._lastCursorCol=0)}}this._allRows[this._rowIndex]=this._currentRow,this._allRowSeparators[this._rowIndex++]=i,this._currentRow="",this._nullCellCount=0}_diffStyle(e,t){let i=[],s=!g0(e,t),a=!Vr(e,t),o=!x0(e,t);if(s||a||o)if(e.isAttributeDefault())t.isAttributeDefault()||i.push(0);else{if(s){let c=e.getFgColor();e.isFgRGB()?i.push(38,2,c>>>16&255,c>>>8&255,c&255):e.isFgPalette()?c>=16?i.push(38,5,c):i.push(c&8?90+(c&7):30+(c&7)):i.push(39)}if(a){let c=e.getBgColor();e.isBgRGB()?i.push(48,2,c>>>16&255,c>>>8&255,c&255):e.isBgPalette()?c>=16?i.push(48,5,c):i.push(c&8?100+(c&7):40+(c&7)):i.push(49)}o&&(e.isInverse()!==t.isInverse()&&i.push(e.isInverse()?7:27),e.isBold()!==t.isBold()&&i.push(e.isBold()?1:22),e.isUnderline()!==t.isUnderline()&&i.push(e.isUnderline()?4:24),e.isOverline()!==t.isOverline()&&i.push(e.isOverline()?53:55),e.isBlink()!==t.isBlink()&&i.push(e.isBlink()?5:25),e.isInvisible()!==t.isInvisible()&&i.push(e.isInvisible()?8:28),e.isItalic()!==t.isItalic()&&i.push(e.isItalic()?3:23),e.isDim()!==t.isDim()&&i.push(e.isDim()?2:22),e.isStrikethrough()!==t.isStrikethrough()&&i.push(e.isStrikethrough()?9:29))}return i}_nextCell(e,t,i,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,this._cursorStyle);if(a?!Vr(this._cursorStyle,e):o.length>0){this._nullCellCount>0&&(Vr(this._cursorStyle,this._backgroundCell)||(this._currentRow+=`\x1B[${this._nullCellCount}X`),this._currentRow+=`\x1B[${this._nullCellCount}C`,this._nullCellCount=0),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s,this._currentRow+=`\x1B[${o.join(";")}m`;let c=this._buffer.getLine(i);c!==void 0&&(c.getCell(s,this._cursorStyle),this._cursorStyleRow=i,this._cursorStyleCol=s)}a?this._nullCellCount+=e.getWidth():(this._nullCellCount>0&&(Vr(this._cursorStyle,this._backgroundCell)?this._currentRow+=`\x1B[${this._nullCellCount}C`:(this._currentRow+=`\x1B[${this._nullCellCount}X`,this._currentRow+=`\x1B[${this._nullCellCount}C`),this._nullCellCount=0),this._currentRow+=e.getChars(),this._lastContentCursorRow=this._lastCursorRow=i,this._lastContentCursorCol=this._lastCursorCol=s+e.getWidth())}_serializeString(e){let t=this._allRows.length;this._buffer.length-this._firstRow<=this._terminal.rows&&(t=this._lastContentCursorRow+1-this._firstRow,this._lastCursorCol=this._lastContentCursorCol,this._lastCursorRow=this._lastContentCursorRow);let i="";for(let o=0;o<t;o++)i+=this._allRows[o],o+1<t&&(i+=this._allRowSeparators[o]);if(!e){let o=this._buffer.baseY+this._buffer.cursorY,c=this._buffer.cursorX,h=o!==this._lastCursorRow||c!==this._lastCursorCol,p=f=>{f>0?i+=`\x1B[${f}C`:f<0&&(i+=`\x1B[${-f}D`)};h&&((f=>{f>0?i+=`\x1B[${f}B`:f<0&&(i+=`\x1B[${-f}A`)})(o-this._lastCursorRow),p(c-this._lastCursorCol))}let s=this._terminal._core._inputHandler._curAttrData,a=this._diffStyle(s,this._cursorStyle);return a.length>0&&(i+=`\x1B[${a.join(";")}m`),i}},PE=class{activate(e){this._terminal=e}_serializeBufferByScrollback(e,t,i){let s=t.length,a=i===void 0?s:ev(i+e.rows,0,s);return this._serializeBufferByRange(e,t,{start:s-a,end:s-1},!1)}_serializeBufferByRange(e,t,i,s){return new zE(t,e).serialize({start:{x:0,y:typeof i.start=="number"?i.start:i.start.line},end:{x:e.cols,y:typeof i.end=="number"?i.end:i.end.line}},s)}_serializeBufferAsHTML(e,t){var h;let i=e.buffer.active,s=new IE(i,e,t),a=t.onlySelection??!1,o=t.range;if(o)return s.serialize({start:{x:o.startCol,y:(o.startLine,o.startLine)},end:{x:e.cols,y:(o.endLine,o.endLine)}});if(!a){let p=i.length,f=t.scrollback,_=f===void 0?p:ev(f+e.rows,0,p);return s.serialize({start:{x:0,y:p-_},end:{x:e.cols,y:p-1}})}let c=(h=this._terminal)==null?void 0:h.getSelectionPosition();return c!==void 0?s.serialize({start:{x:c.start.x,y:c.start.y},end:{x:c.end.x,y:c.end.y}}):""}_serializeModes(e){let t="",i=e.modes;if(i.applicationCursorKeysMode&&(t+="\x1B[?1h"),i.applicationKeypadMode&&(t+="\x1B[?66h"),i.bracketedPasteMode&&(t+="\x1B[?2004h"),i.insertMode&&(t+="\x1B[4h"),i.originMode&&(t+="\x1B[?6h"),i.reverseWraparoundMode&&(t+="\x1B[?45h"),i.sendFocusMode&&(t+="\x1B[?1004h"),i.wraparoundMode===!1&&(t+="\x1B[?7l"),i.mouseTrackingMode!=="none")switch(i.mouseTrackingMode){case"x10":t+="\x1B[?9h";break;case"vt200":t+="\x1B[?1000h";break;case"drag":t+="\x1B[?1002h";break;case"any":t+="\x1B[?1003h";break}return t}serialize(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");let t=e!=null&&e.range?this._serializeBufferByRange(this._terminal,this._terminal.buffer.normal,e.range,!0):this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.normal,e==null?void 0:e.scrollback);if(!(e!=null&&e.excludeAltBuffer)&&this._terminal.buffer.active.type==="alternate"){let i=this._serializeBufferByScrollback(this._terminal,this._terminal.buffer.alternate,void 0);t+=`\x1B[?1049h\x1B[H${i}`}return e!=null&&e.excludeModes||(t+=this._serializeModes(this._terminal)),t}serializeAsHTML(e){if(!this._terminal)throw new Error("Cannot use addon until it has been loaded");return this._serializeBufferAsHTML(this._terminal,e||{})}dispose(){}},IE=class extends m0{constructor(e,t,i){super(e),this._terminal=t,this._options=i,this._currentRow="",this._htmlContent="",t._core._themeService?this._ansiColors=t._core._themeService.colors.ansi:this._ansiColors=LE}_padStart(e,t,i){return t=t>>0,i=i??" ",e.length>t?e:(t-=e.length,t>i.length&&(i+=i.repeat(t/i.length)),i.slice(0,t)+e)}_beforeSerialize(e,t,i){var c,h;this._htmlContent+="<html><body><!--StartFragment--><pre>";let s="#000000",a="#ffffff";(this._options.includeGlobalBackground??!1)&&(s=((c=this._terminal.options.theme)==null?void 0:c.foreground)??"#ffffff",a=((h=this._terminal.options.theme)==null?void 0:h.background)??"#000000");let o=[];o.push("color: "+s+";"),o.push("background-color: "+a+";"),o.push("font-family: "+this._terminal.options.fontFamily+";"),o.push("font-size: "+this._terminal.options.fontSize+"px;"),this._htmlContent+="<div style='"+o.join(" ")+"'>"}_afterSerialize(){this._htmlContent+="</div>",this._htmlContent+="</pre><!--EndFragment--></body></html>"}_rowEnd(e,t){this._htmlContent+="<div><span>"+this._currentRow+"</span></div>",this._currentRow=""}_getHexColor(e,t){let i=t?e.getFgColor():e.getBgColor();if(t?e.isFgRGB():e.isBgRGB())return"#"+[i>>16&255,i>>8&255,i&255].map(s=>this._padStart(s.toString(16),2,"0")).join("");if(t?e.isFgPalette():e.isBgPalette())return this._ansiColors[i].css}_diffStyle(e,t){let i=[],s=!g0(e,t),a=!Vr(e,t),o=!x0(e,t);if(s||a||o){let c=this._getHexColor(e,!0);c&&i.push("color: "+c+";");let h=this._getHexColor(e,!1);return h&&i.push("background-color: "+h+";"),e.isInverse()&&i.push("color: #000000; background-color: #BFBFBF;"),e.isBold()&&i.push("font-weight: bold;"),e.isUnderline()&&e.isOverline()?i.push("text-decoration: overline underline;"):e.isUnderline()?i.push("text-decoration: underline;"):e.isOverline()&&i.push("text-decoration: overline;"),e.isBlink()&&i.push("text-decoration: blink;"),e.isInvisible()&&i.push("visibility: hidden;"),e.isItalic()&&i.push("font-style: italic;"),e.isDim()&&i.push("opacity: 0.5;"),e.isStrikethrough()&&i.push("text-decoration: line-through;"),i}}_nextCell(e,t,i,s){if(e.getWidth()===0)return;let a=e.getChars()==="",o=this._diffStyle(e,t);o&&(this._currentRow+=o.length===0?"</span><span>":"</span><span style='"+o.join(" ")+"'>"),a?this._currentRow+=" ":this._currentRow+=OE(e.getChars())}_serializeString(){return this._htmlContent}};const HE="__OWS_FRESH_SESSION__",Xa="[REDACTED]",UE=[[/(authorization\s*:\s*bearer\s+)[^\s'"\x1b]+/gi,`$1${Xa}`],[/(\bbearer\s+)[A-Za-z0-9._-]{12,}/gi,`$1${Xa}`],[/(\btoken=)[^\s'"&\x1b]+/gi,`$1${Xa}`],[/(OWS_PASSPHRASE\s*[=:]\s*)[^\s'"\x1b]+/gi,`$1${Xa}`],[/(--passphrase[=\s]+)[^\s'"\x1b]+/gi,`$1${Xa}`],[/(passphrase["']?\s*[:=]\s*["']?)[^\s'"\x1b]+/gi,`$1${Xa}`]];function tv(e){let t=e;for(const[i,s]of UE)t=t.replace(i,s);return t}const iv="codex features enable image_generation";function $E(e,t){return e!=="cartoon"||!t?!1:!(t.codex.installed&&t.codex.imageGeneration==="enabled")}const FE={background:"#F0EBE1",foreground:"#2C1810",cursor:"#8B4513",cursorAccent:"#F0EBE1",selectionBackground:"#D4C5B0",selectionForeground:"#2C1810",black:"#2C1810",red:"#A63D40",green:"#4A7A4A",yellow:"#8B6914",blue:"#4A6FA5",magenta:"#7B4B8A",cyan:"#3D7A7A",white:"#E6DDD0",brightBlack:"#8B7355",brightRed:"#B85C5C",brightGreen:"#5A8A5A",brightYellow:"#A07D1C",brightBlue:"#5A82BA",brightMagenta:"#8E5D9F",brightCyan:"#5A8F8F",brightWhite:"#4A3728"},qE="plotlink-terminal",WE=1,Ds="scrollback",nv=10*1024*1024;function Kp(){return new Promise((e,t)=>{const i=indexedDB.open(qE,WE);i.onupgradeneeded=()=>{const s=i.result;s.objectStoreNames.contains(Ds)||s.createObjectStore(Ds)},i.onsuccess=()=>e(i.result),i.onerror=()=>t(i.error)})}async function Za(e,t){const i=t.length>nv?t.slice(-nv):t,s=await Kp();return new Promise((a,o)=>{const c=s.transaction(Ds,"readwrite");c.objectStore(Ds).put(i,e),c.oncomplete=()=>{s.close(),a()},c.onerror=()=>{s.close(),o(c.error)}})}async function GE(e){const t=await Kp();return new Promise((i,s)=>{const o=t.transaction(Ds,"readonly").objectStore(Ds).get(e);o.onsuccess=()=>{t.close(),i(o.result??null)},o.onerror=()=>{t.close(),s(o.error)}})}async function hf(e){const t=await Kp();return new Promise((i,s)=>{const a=t.transaction(Ds,"readwrite");a.objectStore(Ds).delete(e),a.oncomplete=()=>{t.close(),i()},a.onerror=()=>{t.close(),s(a.error)}})}const Ai=new Map;function YE({token:e,storyName:t,authFetch:i,onSelectStory:s,onDestroySession:a,onArchiveStory:o,confirmedStories:c,renameRef:h,bypassStories:p,agentProviders:f,readiness:_,contentType:x,needsProviderRepair:b,onRepairProvider:v}){const y=w.useRef(null),N=w.useRef(i),[j,E]=w.useState([]),[z,O]=w.useState(new Set),[W,q]=w.useState(null),[D,te]=w.useState(null),[de,_e]=w.useState(!1),[P,ae]=w.useState(!1),G=$E(x,_),Y=!!b,Q=w.useRef(()=>{});w.useEffect(()=>{N.current=i},[i]);const I=w.useCallback($=>{var be;const{width:le}=$.container.getBoundingClientRect();if(!(le<50))try{$.fit.fit(),((be=$.ws)==null?void 0:be.readyState)===WebSocket.OPEN&&$.ws.send(JSON.stringify({type:"resize",cols:$.term.cols,rows:$.term.rows}))}catch{}},[]),A=w.useCallback($=>{for(const[le,be]of Ai)be.container.style.display=le===$?"block":"none";if($){const le=Ai.get($);le&&setTimeout(()=>I(le),50)}},[I]),B=w.useRef({});w.useEffect(()=>{B.current=p||{}},[p]);const U=w.useRef({});w.useEffect(()=>{U.current=f||{}},[f]);const ge=w.useCallback(($,le,be)=>{const Te=window.location.protocol==="https:"?"wss:":"ws:",Le=B.current[$]?"&bypass=true":"",ze=U.current[$],ye=ze?`&provider=${encodeURIComponent(ze)}`:"",rt=new WebSocket(`${Te}//${window.location.host}/ws/terminal?story=${encodeURIComponent($)}&token=${e}&resume=${be}${Le}${ye}`);rt.onopen=()=>{le.connected=!0,le._retried=!1,O(wt=>{const vt=new Set(wt);return vt.delete($),vt}),rt.send(JSON.stringify({type:"resize",cols:le.term.cols,rows:le.term.rows}))};let bt=!0;rt.onmessage=wt=>{if(bt&&(bt=!1,typeof wt.data=="string"&&wt.data===HE)){le.term.reset(),hf($).catch(()=>{});return}le.term.write(typeof wt.data=="string"?tv(wt.data):wt.data)},rt.onclose=wt=>{if(le.connected=!1,le.ws===rt){le.ws=null;try{const vt=le.serialize.serialize();Za($,vt).catch(()=>{})}catch{}if(wt.code===4e3&&!le._retried){le._retried=!0,le.term.write(`\r
99
+ \x1B[33m[Resume failed — starting fresh session...]\x1B[0m\r
100
+ `),Q.current($,le,!1);return}O(vt=>new Set(vt).add($))}},le.term.onData(wt=>{rt.readyState===WebSocket.OPEN&&rt.send(wt)}),le.ws=rt},[e]);w.useEffect(()=>{Q.current=ge},[ge]);const T=w.useCallback(async($,le)=>{if(!y.current||Ai.has($))return;const{resume:be=!1,autoConnect:Te=!0}=le??{},Le=document.createElement("div");Le.style.width="100%",Le.style.height="100%",Le.style.display="none",Le.style.paddingLeft="10px",Le.style.boxSizing="border-box",y.current.appendChild(Le);const ze=new AE({cols:80,scrollback:5e3,fontSize:13,fontFamily:'"Geist Mono", ui-monospace, monospace',lineHeight:1.05,letterSpacing:0,cursorBlink:!0,cursorStyle:"block",theme:FE,allowTransparency:!1,drawBoldTextInBrightColors:!1,minimumContrastRatio:7}),ye=new DE,rt=new PE;ze.loadAddon(ye),ze.loadAddon(rt),ze.open(Le);const bt={term:ze,fit:ye,serialize:rt,ws:null,container:Le,observer:null,connected:!1},wt=new ResizeObserver(()=>{var Ve;const{width:vt}=Le.getBoundingClientRect();if(!(vt<50))try{ye.fit(),((Ve=bt.ws)==null?void 0:Ve.readyState)===WebSocket.OPEN&&bt.ws.send(JSON.stringify({type:"resize",cols:ze.cols,rows:ze.rows}))}catch{}});wt.observe(Le),bt.observer=wt,Ai.set($,bt),E(vt=>[...vt,$]);try{const vt=await GE($);if(vt){const Ve=tv(vt);ze.write(Ve),Ve!==vt&&Za($,Ve).catch(()=>{})}}catch{}Te?ge($,bt,be):O(vt=>new Set(vt).add($)),setTimeout(()=>I(bt),50)},[ge,I]),R=w.useCallback(async($,le)=>{const be=Ai.get($);be&&(be.ws&&(be.ws.close(),be.ws=null),le||(await N.current(`/api/terminal/${encodeURIComponent($)}`,{method:"DELETE"}).catch(()=>{}),be.term.clear()),ge($,be,le))},[ge]),V=w.useCallback($=>{const le=Ai.get($);if(le){try{const be=le.serialize.serialize();Za($,be).catch(()=>{})}catch{}le.observer.disconnect(),le.ws&&le.ws.close(),le.term.dispose(),le.container.remove(),Ai.delete($),E(be=>be.filter(Te=>Te!==$)),O(be=>{const Te=new Set(be);return Te.delete($),Te}),i(`/api/terminal/${encodeURIComponent($)}`,{method:"DELETE"}).catch(()=>{}),a==null||a($)}},[i,a]),C=w.useCallback($=>{var be;const le=Ai.get($);le&&(((be=le.ws)==null?void 0:be.readyState)===WebSocket.OPEN&&le.ws.send(`exit
101
+ `),hf($).catch(()=>{}),le.observer.disconnect(),le.ws&&le.ws.close(),le.term.dispose(),le.container.remove(),Ai.delete($),E(Te=>Te.filter(Le=>Le!==$)),O(Te=>{const Le=new Set(Te);return Le.delete($),Le}),i(`/api/terminal/${encodeURIComponent($)}/discard`,{method:"DELETE"}).catch(()=>{}),a==null||a($))},[i,a]),K=w.useCallback(async($,le,be)=>{const Te=Ai.get($);if(!Te||Ai.has(le)||!(await N.current("/api/terminal/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldName:$,newName:le,...be??{}})})).ok)return!1;Ai.delete($),Ai.set(le,Te);try{const ze=Te.serialize.serialize();await hf($),await Za(le,ze)}catch{}return E(ze=>ze.map(ye=>ye===$?le:ye)),O(ze=>{if(!ze.has($))return ze;const ye=new Set(ze);return ye.delete($),ye.add(le),ye}),(Te.connected||Te.ws)&&(await N.current(`/api/terminal/${encodeURIComponent(le)}`,{method:"DELETE"}).catch(()=>{}),Te.ws&&(Te.ws.close(),Te.ws=null),Q.current(le,Te,!0)),!0},[]);w.useEffect(()=>(h&&(h.current=K),()=>{h&&(h.current=null)}),[h,K]),w.useEffect(()=>{if(t){if(G){A(null);return}if(Y){A(null);return}Ai.has(t)?A(t):N.current(`/api/terminal/session/${encodeURIComponent(t)}`).then($=>$.ok?$.json():null).then($=>{if(!Ai.has(t)){const le=($==null?void 0:$.sessionId)&&!($!=null&&$.running);T(t,{autoConnect:!le}),A(t)}}).catch(()=>{Ai.has(t)||(T(t),A(t))})}},[t,T,A,G,Y]),w.useEffect(()=>{const $=setInterval(()=>{for(const[le,be]of Ai)if(be.connected)try{const Te=be.serialize.serialize();Za(le,Te).catch(()=>{})}catch{}},3e4);return()=>clearInterval($)},[]),w.useEffect(()=>()=>{for(const[$,le]of Ai){try{const be=le.serialize.serialize();Za($,be).catch(()=>{})}catch{}le.observer.disconnect(),le.ws&&le.ws.close(),le.term.dispose(),le.container.remove(),N.current(`/api/terminal/${encodeURIComponent($)}`,{method:"DELETE"}).catch(()=>{})}Ai.clear()},[]);const re=t?z.has(t):!1,ue=j.length===0;return d.jsxs("div",{className:"h-full flex flex-col",children:[!ue&&d.jsxs("div",{className:"px-2 py-1 border-b border-border flex items-center gap-1 overflow-x-auto",children:[j.map($=>d.jsxs("div",{onClick:()=>s==null?void 0:s($),className:`flex items-center gap-1 px-2 py-0.5 rounded text-xs font-mono cursor-pointer ${$===t?"bg-accent/10 text-accent":"text-muted hover:text-foreground"}`,children:[d.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${z.has($)?"bg-amber-500":$===t?"bg-green-600":"bg-muted/50"}`}),d.jsx("span",{className:`truncate max-w-[120px] ${$.startsWith("_new_")?"italic":""}`,children:$.startsWith("_new_")?"Untitled":$}),d.jsx("button",{onClick:le=>{le.stopPropagation(),$.startsWith("_new_")?q($):V($)},className:"ml-0.5 text-muted hover:text-error text-[10px] leading-none",title:"Close terminal",children:"×"})]},$)),t!=null&&t.startsWith("_new_")?d.jsx("button",{onClick:()=>q(t),className:"ml-auto px-2 py-0.5 text-xs text-error hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Cancel ×"}):t&&o&&(c!=null&&c.has(t))?d.jsx("button",{onClick:()=>te(t),className:"ml-auto px-2 py-0.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded flex items-center gap-1 flex-shrink-0",children:"Archive"}):null]}),d.jsxs("div",{className:"relative flex-1 min-h-0",children:[d.jsx("div",{ref:y,className:"h-full"}),ue&&!G&&!Y&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted",children:d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"text-lg font-serif",children:"Select a story on the left menu"}),d.jsx("p",{className:"text-sm mt-1",children:"to start an AI Writer session"})]})}),G&&d.jsx("div",{"data-testid":"cartoon-launch-blocked",className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Cartoon agent can't launch yet"}),d.jsx("p",{className:"text-xs text-muted",children:"This is a cartoon story. The writing agent needs Codex with image generation enabled before it can start, because the clean-image step relies on image generation support."}),_&&!_.codex.installed?d.jsxs("p",{className:"text-xs text-amber-700",children:["Codex was not detected. Install the Codex CLI and sign in (e.g. ",d.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," then"," ",d.jsx("span",{className:"font-mono",children:"codex login"}),"), then reopen this story."]}):Su(_)?d.jsxs("p",{className:"text-xs text-amber-700","data-testid":"codex-auth-unknown-launch",children:[zp," Then reopen this story."]}):d.jsxs("div",{className:"space-y-1",children:[d.jsx("p",{className:"text-xs text-amber-700",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this story:"}),d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("code",{className:"flex-1 truncate rounded border border-border bg-surface px-1.5 py-1 text-left text-[10px] font-mono text-foreground",children:iv}),d.jsx("button",{type:"button","data-testid":"copy-codex-enable-launch",onClick:async()=>{try{await navigator.clipboard.writeText(iv),_e(!0),setTimeout(()=>_e(!1),2e3)}catch{}},className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors",children:de?"Copied!":"Copy"})]})]})]})}),Y&&!G&&d.jsx("div",{"data-testid":"legacy-cartoon-provider-repair",className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-md",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Set this cartoon story's provider"}),d.jsx("p",{className:"text-xs text-muted",children:"This cartoon story was created before provider tracking, so it has no provider recorded and would launch with Claude — which can't generate the clean images cartoons need. Set this story's provider to Codex to continue."}),d.jsx("p",{className:"text-[11px] text-muted",children:"Only this story is changed. Other stories and fiction are not affected."}),d.jsx("button",{type:"button","data-testid":"repair-provider-codex",disabled:P,onClick:async()=>{if(!P){ae(!0);try{await(v==null?void 0:v())}finally{ae(!1)}}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:P?"Setting…":"Set this story's provider to Codex"})]})}),W&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Discard this session?"}),d.jsx("p",{className:"text-xs text-muted",children:"This session will be lost — your AI hasn't created a story structure yet."}),d.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d.jsx("button",{onClick:()=>q(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),d.jsx("button",{onClick:()=>{const $=W;q(null),C($)},className:"px-4 py-1.5 bg-error text-white text-sm rounded hover:opacity-80",children:"Discard"})]})]})}),D&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center z-10",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"text-center space-y-3 p-6 bg-surface border border-border rounded-lg shadow-lg max-w-sm",children:[d.jsx("p",{className:"text-sm font-serif text-foreground font-medium",children:"Archive this story?"}),d.jsx("p",{className:"text-xs text-muted",children:"You can restore it later from the Archives view."}),d.jsxs("div",{className:"flex items-center justify-center gap-2",children:[d.jsx("button",{onClick:()=>te(null),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Cancel"}),d.jsx("button",{onClick:async()=>{const $=D;te(null);try{(await N.current("/api/stories/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:$})})).ok&&(V($),o==null||o($))}catch{}},className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Archive"})]})]})}),re&&t&&d.jsx("div",{className:"absolute inset-0 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"text-center space-y-3",children:[d.jsx("p",{className:"text-sm font-serif text-foreground",children:"Terminal disconnected"}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:()=>R(t,!0),className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim",children:"Resume Session"}),d.jsx("button",{onClick:()=>R(t,!1),className:"px-4 py-1.5 border border-border text-sm rounded hover:bg-surface",children:"Start Fresh"})]}),d.jsx("p",{className:"text-xs text-muted",children:"Resume continues your previous Claude conversation"})]})})]})]})}function KE(e,t){const i={};return(e[e.length-1]===""?[...e,""]:e).join((i.padRight?" ":"")+","+(i.padLeft===!1?"":" ")).trim()}const VE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,XE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZE={};function rv(e,t){return(ZE.jsx?XE:VE).test(e)}const QE=/[ \t\n\f\r]/g;function JE(e){return typeof e=="object"?e.type==="text"?sv(e.value):!1:sv(e)}function sv(e){return e.replace(QE,"")===""}class Lo{constructor(t,i,s){this.normal=i,this.property=t,s&&(this.space=s)}}Lo.prototype.normal={};Lo.prototype.property={};Lo.prototype.space=void 0;function _0(e,t){const i={},s={};for(const a of e)Object.assign(i,a.property),Object.assign(s,a.normal);return new Lo(i,s,t)}function vp(e){return e.toLowerCase()}class Tn{constructor(t,i){this.attribute=i,this.property=t}}Tn.prototype.attribute="";Tn.prototype.booleanish=!1;Tn.prototype.boolean=!1;Tn.prototype.commaOrSpaceSeparated=!1;Tn.prototype.commaSeparated=!1;Tn.prototype.defined=!1;Tn.prototype.mustUseProperty=!1;Tn.prototype.number=!1;Tn.prototype.overloadedBoolean=!1;Tn.prototype.property="";Tn.prototype.spaceSeparated=!1;Tn.prototype.space=void 0;let eN=0;const lt=ua(),wi=ua(),yp=ua(),ve=ua(),Yt=ua(),il=ua(),Un=ua();function ua(){return 2**++eN}const Sp=Object.freeze(Object.defineProperty({__proto__:null,boolean:lt,booleanish:wi,commaOrSpaceSeparated:Un,commaSeparated:il,number:ve,overloadedBoolean:yp,spaceSeparated:Yt},Symbol.toStringTag,{value:"Module"})),df=Object.keys(Sp);class Vp extends Tn{constructor(t,i,s,a){let o=-1;if(super(t,i),av(this,"space",a),typeof s=="number")for(;++o<df.length;){const c=df[o];av(this,df[o],(s&Sp[c])===Sp[c])}}}Vp.prototype.defined=!0;function av(e,t,i){i&&(e[t]=i)}function ul(e){const t={},i={};for(const[s,a]of Object.entries(e.properties)){const o=new Vp(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(o.mustUseProperty=!0),t[s]=o,i[vp(s)]=s,i[vp(o.attribute)]=s}return new Lo(t,i,e.space)}const b0=ul({properties:{ariaActiveDescendant:null,ariaAtomic:wi,ariaAutoComplete:null,ariaBusy:wi,ariaChecked:wi,ariaColCount:ve,ariaColIndex:ve,ariaColSpan:ve,ariaControls:Yt,ariaCurrent:null,ariaDescribedBy:Yt,ariaDetails:null,ariaDisabled:wi,ariaDropEffect:Yt,ariaErrorMessage:null,ariaExpanded:wi,ariaFlowTo:Yt,ariaGrabbed:wi,ariaHasPopup:null,ariaHidden:wi,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Yt,ariaLevel:ve,ariaLive:null,ariaModal:wi,ariaMultiLine:wi,ariaMultiSelectable:wi,ariaOrientation:null,ariaOwns:Yt,ariaPlaceholder:null,ariaPosInSet:ve,ariaPressed:wi,ariaReadOnly:wi,ariaRelevant:null,ariaRequired:wi,ariaRoleDescription:Yt,ariaRowCount:ve,ariaRowIndex:ve,ariaRowSpan:ve,ariaSelected:wi,ariaSetSize:ve,ariaSort:null,ariaValueMax:ve,ariaValueMin:ve,ariaValueNow:ve,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function v0(e,t){return t in e?e[t]:t}function y0(e,t){return v0(e,t.toLowerCase())}const tN=ul({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:il,acceptCharset:Yt,accessKey:Yt,action:null,allow:null,allowFullScreen:lt,allowPaymentRequest:lt,allowUserMedia:lt,alt:null,as:null,async:lt,autoCapitalize:null,autoComplete:Yt,autoFocus:lt,autoPlay:lt,blocking:Yt,capture:null,charSet:null,checked:lt,cite:null,className:Yt,cols:ve,colSpan:null,content:null,contentEditable:wi,controls:lt,controlsList:Yt,coords:ve|il,crossOrigin:null,data:null,dateTime:null,decoding:null,default:lt,defer:lt,dir:null,dirName:null,disabled:lt,download:yp,draggable:wi,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:lt,formTarget:null,headers:Yt,height:ve,hidden:yp,high:ve,href:null,hrefLang:null,htmlFor:Yt,httpEquiv:Yt,id:null,imageSizes:null,imageSrcSet:null,inert:lt,inputMode:null,integrity:null,is:null,isMap:lt,itemId:null,itemProp:Yt,itemRef:Yt,itemScope:lt,itemType:Yt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:lt,low:ve,manifest:null,max:null,maxLength:ve,media:null,method:null,min:null,minLength:ve,multiple:lt,muted:lt,name:null,nonce:null,noModule:lt,noValidate:lt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:lt,optimum:ve,pattern:null,ping:Yt,placeholder:null,playsInline:lt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:lt,referrerPolicy:null,rel:Yt,required:lt,reversed:lt,rows:ve,rowSpan:ve,sandbox:Yt,scope:null,scoped:lt,seamless:lt,selected:lt,shadowRootClonable:lt,shadowRootDelegatesFocus:lt,shadowRootMode:null,shape:null,size:ve,sizes:null,slot:null,span:ve,spellCheck:wi,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ve,step:null,style:null,tabIndex:ve,target:null,title:null,translate:null,type:null,typeMustMatch:lt,useMap:null,value:wi,width:ve,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Yt,axis:null,background:null,bgColor:null,border:ve,borderColor:null,bottomMargin:ve,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:lt,declare:lt,event:null,face:null,frame:null,frameBorder:null,hSpace:ve,leftMargin:ve,link:null,longDesc:null,lowSrc:null,marginHeight:ve,marginWidth:ve,noResize:lt,noHref:lt,noShade:lt,noWrap:lt,object:null,profile:null,prompt:null,rev:null,rightMargin:ve,rules:null,scheme:null,scrolling:wi,standby:null,summary:null,text:null,topMargin:ve,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ve,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:lt,disableRemotePlayback:lt,prefix:null,property:null,results:ve,security:null,unselectable:null},space:"html",transform:y0}),iN=ul({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Un,accentHeight:ve,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ve,amplitude:ve,arabicForm:null,ascent:ve,attributeName:null,attributeType:null,azimuth:ve,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ve,by:null,calcMode:null,capHeight:ve,className:Yt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ve,diffuseConstant:ve,direction:null,display:null,dur:null,divisor:ve,dominantBaseline:null,download:lt,dx:null,dy:null,edgeMode:null,editable:null,elevation:ve,enableBackground:null,end:null,event:null,exponent:ve,externalResourcesRequired:null,fill:null,fillOpacity:ve,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:il,g2:il,glyphName:il,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ve,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ve,horizOriginX:ve,horizOriginY:ve,id:null,ideographic:ve,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ve,k:ve,k1:ve,k2:ve,k3:ve,k4:ve,kernelMatrix:Un,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ve,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ve,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ve,overlineThickness:ve,paintOrder:null,panose1:null,path:null,pathLength:ve,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Yt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ve,pointsAtY:ve,pointsAtZ:ve,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Un,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Un,rev:Un,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Un,requiredFeatures:Un,requiredFonts:Un,requiredFormats:Un,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ve,specularExponent:ve,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ve,strikethroughThickness:ve,string:null,stroke:null,strokeDashArray:Un,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ve,strokeOpacity:ve,strokeWidth:null,style:null,surfaceScale:ve,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Un,tabIndex:ve,tableValues:null,target:null,targetX:ve,targetY:ve,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Un,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ve,underlineThickness:ve,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ve,values:null,vAlphabetic:ve,vMathematical:ve,vectorEffect:null,vHanging:ve,vIdeographic:ve,version:null,vertAdvY:ve,vertOriginX:ve,vertOriginY:ve,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ve,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:v0}),S0=ul({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),w0=ul({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:y0}),C0=ul({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),nN={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},rN=/[A-Z]/g,lv=/-[a-z]/g,sN=/^data[-\w.:]+$/i;function aN(e,t){const i=vp(t);let s=t,a=Tn;if(i in e.normal)return e.property[e.normal[i]];if(i.length>4&&i.slice(0,4)==="data"&&sN.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(lv,oN);s="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!lv.test(o)){let c=o.replace(rN,lN);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}a=Vp}return new a(s,t)}function lN(e){return"-"+e.toLowerCase()}function oN(e){return e.charAt(1).toUpperCase()}const cN=_0([b0,tN,S0,w0,C0],"html"),Xp=_0([b0,iN,S0,w0,C0],"svg");function uN(e){return e.join(" ").trim()}var Qa={},ff,ov;function hN(){if(ov)return ff;ov=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,i=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,h=/^\s+|\s+$/g,p=`
102
+ `,f="/",_="*",x="",b="comment",v="declaration";function y(j,E){if(typeof j!="string")throw new TypeError("First argument must be a string");if(!j)return[];E=E||{};var z=1,O=1;function W(Q){var I=Q.match(t);I&&(z+=I.length);var A=Q.lastIndexOf(p);O=~A?Q.length-A:O+Q.length}function q(){var Q={line:z,column:O};return function(I){return I.position=new D(Q),_e(),I}}function D(Q){this.start=Q,this.end={line:z,column:O},this.source=E.source}D.prototype.content=j;function te(Q){var I=new Error(E.source+":"+z+":"+O+": "+Q);if(I.reason=Q,I.filename=E.source,I.line=z,I.column=O,I.source=j,!E.silent)throw I}function de(Q){var I=Q.exec(j);if(I){var A=I[0];return W(A),j=j.slice(A.length),I}}function _e(){de(i)}function P(Q){var I;for(Q=Q||[];I=ae();)I!==!1&&Q.push(I);return Q}function ae(){var Q=q();if(!(f!=j.charAt(0)||_!=j.charAt(1))){for(var I=2;x!=j.charAt(I)&&(_!=j.charAt(I)||f!=j.charAt(I+1));)++I;if(I+=2,x===j.charAt(I-1))return te("End of comment missing");var A=j.slice(2,I-2);return O+=2,W(A),j=j.slice(I),O+=2,Q({type:b,comment:A})}}function G(){var Q=q(),I=de(s);if(I){if(ae(),!de(a))return te("property missing ':'");var A=de(o),B=Q({type:v,property:N(I[0].replace(e,x)),value:A?N(A[0].replace(e,x)):x});return de(c),B}}function Y(){var Q=[];P(Q);for(var I;I=G();)I!==!1&&(Q.push(I),P(Q));return Q}return _e(),Y()}function N(j){return j?j.replace(h,x):x}return ff=y,ff}var cv;function dN(){if(cv)return Qa;cv=1;var e=Qa&&Qa.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Qa,"__esModule",{value:!0}),Qa.default=i;const t=e(hN());function i(s,a){let o=null;if(!s||typeof s!="string")return o;const c=(0,t.default)(s),h=typeof a=="function";return c.forEach(p=>{if(p.type!=="declaration")return;const{property:f,value:_}=p;h?a(f,_,p):_&&(o=o||{},o[f]=_)}),o}return Qa}var co={},uv;function fN(){if(uv)return co;uv=1,Object.defineProperty(co,"__esModule",{value:!0}),co.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,i=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(f){return!f||i.test(f)||e.test(f)},c=function(f,_){return _.toUpperCase()},h=function(f,_){return"".concat(_,"-")},p=function(f,_){return _===void 0&&(_={}),o(f)?f:(f=f.toLowerCase(),_.reactCompat?f=f.replace(a,h):f=f.replace(s,h),f.replace(t,c))};return co.camelCase=p,co}var uo,hv;function pN(){if(hv)return uo;hv=1;var e=uo&&uo.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(dN()),i=fN();function s(a,o){var c={};return!a||typeof a!="string"||(0,t.default)(a,function(h,p){h&&p&&(c[(0,i.camelCase)(h,o)]=p)}),c}return s.default=s,uo=s,uo}var mN=pN();const gN=Du(mN),k0=E0("end"),Zp=E0("start");function E0(e){return t;function t(i){const s=i&&i.position&&i.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function N0(e){const t=Zp(e),i=k0(e);if(t&&i)return{start:t,end:i}}function yo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?dv(e.position):"start"in e||"end"in e?dv(e):"line"in e||"column"in e?wp(e):""}function wp(e){return fv(e&&e.line)+":"+fv(e&&e.column)}function dv(e){return wp(e&&e.start)+"-"+wp(e&&e.end)}function fv(e){return e&&typeof e=="number"?e:1}class an extends Error{constructor(t,i,s){super(),typeof i=="string"&&(s=i,i=void 0);let a="",o={},c=!1;if(i&&("line"in i&&"column"in i?o={place:i}:"start"in i&&"end"in i?o={place:i}:"type"in i?o={ancestors:[i],place:i.position}:o={...i}),typeof t=="string"?a=t:!o.cause&&t&&(c=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof s=="string"){const p=s.indexOf(":");p===-1?o.ruleId=s:(o.source=s.slice(0,p),o.ruleId=s.slice(p+1))}if(!o.place&&o.ancestors&&o.ancestors){const p=o.ancestors[o.ancestors.length-1];p&&(o.place=p.position)}const h=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=h?h.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=h?h.line:void 0,this.name=yo(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}an.prototype.file="";an.prototype.name="";an.prototype.reason="";an.prototype.message="";an.prototype.stack="";an.prototype.column=void 0;an.prototype.line=void 0;an.prototype.ancestors=void 0;an.prototype.cause=void 0;an.prototype.fatal=void 0;an.prototype.place=void 0;an.prototype.ruleId=void 0;an.prototype.source=void 0;const Qp={}.hasOwnProperty,xN=new Map,_N=/[A-Z]/g,bN=new Set(["table","tbody","thead","tfoot","tr"]),vN=new Set(["td","th"]),T0="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function yN(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const i=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=jN(i,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=TN(i,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:i,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Xp:cN,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=j0(a,e,void 0);return o&&typeof o!="string"?o:a.create(e,a.Fragment,{children:o||void 0},void 0)}function j0(e,t,i){if(t.type==="element")return SN(e,t,i);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return wN(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return kN(e,t,i);if(t.type==="mdxjsEsm")return CN(e,t);if(t.type==="root")return EN(e,t,i);if(t.type==="text")return NN(e,t)}function SN(e,t,i){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Xp,e.schema=a),e.ancestors.push(t);const o=R0(e,t.tagName,!1),c=AN(e,t);let h=em(e,t);return bN.has(t.tagName)&&(h=h.filter(function(p){return typeof p=="string"?!JE(p):!0})),A0(e,c,o,t),Jp(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function wN(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}No(e,t.position)}function CN(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);No(e,t.position)}function kN(e,t,i){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Xp,e.schema=a),e.ancestors.push(t);const o=t.name===null?e.Fragment:R0(e,t.name,!0),c=RN(e,t),h=em(e,t);return A0(e,c,o,t),Jp(c,h),e.ancestors.pop(),e.schema=s,e.create(t,o,c,i)}function EN(e,t,i){const s={};return Jp(s,em(e,t)),e.create(t,e.Fragment,s,i)}function NN(e,t){return t.value}function A0(e,t,i,s){typeof i!="string"&&i!==e.Fragment&&e.passNode&&(t.node=s)}function Jp(e,t){if(t.length>0){const i=t.length>1?t:t[0];i&&(e.children=i)}}function TN(e,t,i){return s;function s(a,o,c,h){const f=Array.isArray(c.children)?i:t;return h?f(o,c,h):f(o,c)}}function jN(e,t){return i;function i(s,a,o,c){const h=Array.isArray(o.children),p=Zp(s);return t(a,o,c,h,{columnNumber:p?p.column-1:void 0,fileName:e,lineNumber:p?p.line:void 0},void 0)}}function AN(e,t){const i={};let s,a;for(a in t.properties)if(a!=="children"&&Qp.call(t.properties,a)){const o=MN(e,a,t.properties[a]);if(o){const[c,h]=o;e.tableCellAlignToStyle&&c==="align"&&typeof h=="string"&&vN.has(t.tagName)?s=h:i[c]=h}}if(s){const o=i.style||(i.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return i}function RN(e,t){const i={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const o=s.data.estree.body[0];o.type;const c=o.expression;c.type;const h=c.properties[0];h.type,Object.assign(i,e.evaluater.evaluateExpression(h.argument))}else No(e,t.position);else{const a=s.name;let o;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const h=s.value.data.estree.body[0];h.type,o=e.evaluater.evaluateExpression(h.expression)}else No(e,t.position);else o=s.value===null?!0:s.value;i[a]=o}return i}function em(e,t){const i=[];let s=-1;const a=e.passKeys?new Map:xN;for(;++s<t.children.length;){const o=t.children[s];let c;if(e.passKeys){const p=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(p){const f=a.get(p)||0;c=p+"-"+f,a.set(p,f+1)}}const h=j0(e,o,c);h!==void 0&&i.push(h)}return i}function MN(e,t,i){const s=aN(e.schema,t);if(!(i==null||typeof i=="number"&&Number.isNaN(i))){if(Array.isArray(i)&&(i=s.commaSeparated?KE(i):uN(i)),s.property==="style"){let a=typeof i=="object"?i:DN(e,String(i));return e.stylePropertyNameCase==="css"&&(a=BN(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?nN[s.property]||s.property:s.attribute,i]}}function DN(e,t){try{return gN(t,{reactCompat:!0})}catch(i){if(e.ignoreInvalidStyle)return{};const s=i,a=new an("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=T0+"#cannot-parse-style-attribute",a}}function R0(e,t,i){let s;if(!i)s={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let o=-1,c;for(;++o<a.length;){const h=rv(a[o])?{type:"Identifier",name:a[o]}:{type:"Literal",value:a[o]};c=c?{type:"MemberExpression",object:c,property:h,computed:!!(o&&h.type==="Literal"),optional:!1}:h}s=c}else s=rv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return Qp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);No(e)}function No(e,t){const i=new an("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=T0+"#cannot-handle-mdx-estrees-without-createevaluater",i}function BN(e){const t={};let i;for(i in e)Qp.call(e,i)&&(t[LN(i)]=e[i]);return t}function LN(e){let t=e.replace(_N,ON);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function ON(e){return"-"+e.toLowerCase()}const pf={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},zN={};function tm(e,t){const i=zN,s=typeof i.includeImageAlt=="boolean"?i.includeImageAlt:!0,a=typeof i.includeHtml=="boolean"?i.includeHtml:!0;return M0(e,s,a)}function M0(e,t,i){if(PN(e)){if("value"in e)return e.type==="html"&&!i?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return pv(e.children,t,i)}return Array.isArray(e)?pv(e,t,i):""}function pv(e,t,i){const s=[];let a=-1;for(;++a<e.length;)s[a]=M0(e[a],t,i);return s.join("")}function PN(e){return!!(e&&typeof e=="object")}const mv=document.createElement("i");function im(e){const t="&"+e+";";mv.innerHTML=t;const i=mv.textContent;return i.charCodeAt(i.length-1)===59&&e!=="semi"||i===t?!1:i}function $n(e,t,i,s){const a=e.length;let o=0,c;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,i=i>0?i:0,s.length<1e4)c=Array.from(s),c.unshift(t,i),e.splice(...c);else for(i&&e.splice(t,i);o<s.length;)c=s.slice(o,o+1e4),c.unshift(t,0),e.splice(...c),o+=1e4,t+=1e4}function sr(e,t){return e.length>0?($n(e,e.length,0,t),e):t}const gv={}.hasOwnProperty;function D0(e){const t={};let i=-1;for(;++i<e.length;)IN(t,e[i]);return t}function IN(e,t){let i;for(i in t){const a=(gv.call(e,i)?e[i]:void 0)||(e[i]={}),o=t[i];let c;if(o)for(c in o){gv.call(a,c)||(a[c]=[]);const h=o[c];HN(a[c],Array.isArray(h)?h:h?[h]:[])}}}function HN(e,t){let i=-1;const s=[];for(;++i<t.length;)(t[i].add==="after"?e:s).push(t[i]);$n(e,0,0,s)}function B0(e,t){const i=Number.parseInt(e,t);return i<9||i===11||i>13&&i<32||i>126&&i<160||i>55295&&i<57344||i>64975&&i<65008||(i&65535)===65535||(i&65535)===65534||i>1114111?"�":String.fromCodePoint(i)}function gr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const pn=Bs(/[A-Za-z]/),sn=Bs(/[\dA-Za-z]/),UN=Bs(/[#-'*+\--9=?A-Z^-~]/);function ju(e){return e!==null&&(e<32||e===127)}const Cp=Bs(/\d/),$N=Bs(/[\dA-Fa-f]/),FN=Bs(/[!-/:-@[-`{-~]/);function Fe(e){return e!==null&&e<-2}function Gt(e){return e!==null&&(e<0||e===32)}function _t(e){return e===-2||e===-1||e===32}const Pu=Bs(new RegExp("\\p{P}|\\p{S}","u")),oa=Bs(/\s/);function Bs(e){return t;function t(i){return i!==null&&i>-1&&e.test(String.fromCharCode(i))}}function hl(e){const t=[];let i=-1,s=0,a=0;for(;++i<e.length;){const o=e.charCodeAt(i);let c="";if(o===37&&sn(e.charCodeAt(i+1))&&sn(e.charCodeAt(i+2)))a=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(c=String.fromCharCode(o));else if(o>55295&&o<57344){const h=e.charCodeAt(i+1);o<56320&&h>56319&&h<57344?(c=String.fromCharCode(o,h),a=1):c="�"}else c=String.fromCharCode(o);c&&(t.push(e.slice(s,i),encodeURIComponent(c)),s=i+a+1,c=""),a&&(i+=a,a=0)}return t.join("")+e.slice(s)}function Nt(e,t,i,s){const a=s?s-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(p){return _t(p)?(e.enter(i),h(p)):t(p)}function h(p){return _t(p)&&o++<a?(e.consume(p),h):(e.exit(i),t(p))}}const qN={tokenize:WN};function WN(e){const t=e.attempt(this.parser.constructs.contentInitial,s,a);let i;return t;function s(h){if(h===null){e.consume(h);return}return e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),Nt(e,t,"linePrefix")}function a(h){return e.enter("paragraph"),o(h)}function o(h){const p=e.enter("chunkText",{contentType:"text",previous:i});return i&&(i.next=p),i=p,c(h)}function c(h){if(h===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(h);return}return Fe(h)?(e.consume(h),e.exit("chunkText"),o):(e.consume(h),c)}}const GN={tokenize:YN},xv={tokenize:KN};function YN(e){const t=this,i=[];let s=0,a,o,c;return h;function h(O){if(s<i.length){const W=i[s];return t.containerState=W[1],e.attempt(W[0].continuation,p,f)(O)}return f(O)}function p(O){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&z();const W=t.events.length;let q=W,D;for(;q--;)if(t.events[q][0]==="exit"&&t.events[q][1].type==="chunkFlow"){D=t.events[q][1].end;break}E(s);let te=W;for(;te<t.events.length;)t.events[te][1].end={...D},te++;return $n(t.events,q+1,0,t.events.slice(W)),t.events.length=te,f(O)}return h(O)}function f(O){if(s===i.length){if(!a)return b(O);if(a.currentConstruct&&a.currentConstruct.concrete)return y(O);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(xv,_,x)(O)}function _(O){return a&&z(),E(s),b(O)}function x(O){return t.parser.lazy[t.now().line]=s!==i.length,c=t.now().offset,y(O)}function b(O){return t.containerState={},e.attempt(xv,v,y)(O)}function v(O){return s++,i.push([t.currentConstruct,t.containerState]),b(O)}function y(O){if(O===null){a&&z(),E(0),e.consume(O);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:o}),N(O)}function N(O){if(O===null){j(e.exit("chunkFlow"),!0),E(0),e.consume(O);return}return Fe(O)?(e.consume(O),j(e.exit("chunkFlow")),s=0,t.interrupt=void 0,h):(e.consume(O),N)}function j(O,W){const q=t.sliceStream(O);if(W&&q.push(null),O.previous=o,o&&(o.next=O),o=O,a.defineSkip(O.start),a.write(q),t.parser.lazy[O.start.line]){let D=a.events.length;for(;D--;)if(a.events[D][1].start.offset<c&&(!a.events[D][1].end||a.events[D][1].end.offset>c))return;const te=t.events.length;let de=te,_e,P;for(;de--;)if(t.events[de][0]==="exit"&&t.events[de][1].type==="chunkFlow"){if(_e){P=t.events[de][1].end;break}_e=!0}for(E(s),D=te;D<t.events.length;)t.events[D][1].end={...P},D++;$n(t.events,de+1,0,t.events.slice(te)),t.events.length=D}}function E(O){let W=i.length;for(;W-- >O;){const q=i[W];t.containerState=q[1],q[0].exit.call(t,e)}i.length=O}function z(){a.write([null]),o=void 0,a=void 0,t.containerState._closeFlow=void 0}}function KN(e,t,i){return Nt(e,e.attempt(this.parser.constructs.document,t,i),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function al(e){if(e===null||Gt(e)||oa(e))return 1;if(Pu(e))return 2}function Iu(e,t,i){const s=[];let a=-1;for(;++a<e.length;){const o=e[a].resolveAll;o&&!s.includes(o)&&(t=o(t,i),s.push(o))}return t}const kp={name:"attention",resolveAll:VN,tokenize:XN};function VN(e,t){let i=-1,s,a,o,c,h,p,f,_;for(;++i<e.length;)if(e[i][0]==="enter"&&e[i][1].type==="attentionSequence"&&e[i][1]._close){for(s=i;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[i][1]).charCodeAt(0)){if((e[s][1]._close||e[i][1]._open)&&(e[i][1].end.offset-e[i][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[i][1].end.offset-e[i][1].start.offset)%3))continue;p=e[s][1].end.offset-e[s][1].start.offset>1&&e[i][1].end.offset-e[i][1].start.offset>1?2:1;const x={...e[s][1].end},b={...e[i][1].start};_v(x,-p),_v(b,p),c={type:p>1?"strongSequence":"emphasisSequence",start:x,end:{...e[s][1].end}},h={type:p>1?"strongSequence":"emphasisSequence",start:{...e[i][1].start},end:b},o={type:p>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[i][1].start}},a={type:p>1?"strong":"emphasis",start:{...c.start},end:{...h.end}},e[s][1].end={...c.start},e[i][1].start={...h.end},f=[],e[s][1].end.offset-e[s][1].start.offset&&(f=sr(f,[["enter",e[s][1],t],["exit",e[s][1],t]])),f=sr(f,[["enter",a,t],["enter",c,t],["exit",c,t],["enter",o,t]]),f=sr(f,Iu(t.parser.constructs.insideSpan.null,e.slice(s+1,i),t)),f=sr(f,[["exit",o,t],["enter",h,t],["exit",h,t],["exit",a,t]]),e[i][1].end.offset-e[i][1].start.offset?(_=2,f=sr(f,[["enter",e[i][1],t],["exit",e[i][1],t]])):_=0,$n(e,s-1,i-s+3,f),i=s+f.length-_-2;break}}for(i=-1;++i<e.length;)e[i][1].type==="attentionSequence"&&(e[i][1].type="data");return e}function XN(e,t){const i=this.parser.constructs.attentionMarkers.null,s=this.previous,a=al(s);let o;return c;function c(p){return o=p,e.enter("attentionSequence"),h(p)}function h(p){if(p===o)return e.consume(p),h;const f=e.exit("attentionSequence"),_=al(p),x=!_||_===2&&a||i.includes(p),b=!a||a===2&&_||i.includes(s);return f._open=!!(o===42?x:x&&(a||!b)),f._close=!!(o===42?b:b&&(_||!x)),t(p)}}function _v(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ZN={name:"autolink",tokenize:QN};function QN(e,t,i){let s=0;return a;function a(v){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(v){return pn(v)?(e.consume(v),c):v===64?i(v):f(v)}function c(v){return v===43||v===45||v===46||sn(v)?(s=1,h(v)):f(v)}function h(v){return v===58?(e.consume(v),s=0,p):(v===43||v===45||v===46||sn(v))&&s++<32?(e.consume(v),h):(s=0,f(v))}function p(v){return v===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):v===null||v===32||v===60||ju(v)?i(v):(e.consume(v),p)}function f(v){return v===64?(e.consume(v),_):UN(v)?(e.consume(v),f):i(v)}function _(v){return sn(v)?x(v):i(v)}function x(v){return v===46?(e.consume(v),s=0,_):v===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(v),e.exit("autolinkMarker"),e.exit("autolink"),t):b(v)}function b(v){if((v===45||sn(v))&&s++<63){const y=v===45?b:x;return e.consume(v),y}return i(v)}}const Oo={partial:!0,tokenize:JN};function JN(e,t,i){return s;function s(o){return _t(o)?Nt(e,a,"linePrefix")(o):a(o)}function a(o){return o===null||Fe(o)?t(o):i(o)}}const L0={continuation:{tokenize:t5},exit:i5,name:"blockQuote",tokenize:e5};function e5(e,t,i){const s=this;return a;function a(c){if(c===62){const h=s.containerState;return h.open||(e.enter("blockQuote",{_container:!0}),h.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),o}return i(c)}function o(c){return _t(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function t5(e,t,i){const s=this;return a;function a(c){return _t(c)?Nt(e,o,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return e.attempt(L0,t,i)(c)}}function i5(e){e.exit("blockQuote")}const O0={name:"characterEscape",tokenize:n5};function n5(e,t,i){return s;function s(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),a}function a(o){return FN(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):i(o)}}const z0={name:"characterReference",tokenize:r5};function r5(e,t,i){const s=this;let a=0,o,c;return h;function h(x){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),p}function p(x){return x===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(x),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),o=31,c=sn,_(x))}function f(x){return x===88||x===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(x),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,c=$N,_):(e.enter("characterReferenceValue"),o=7,c=Cp,_(x))}function _(x){if(x===59&&a){const b=e.exit("characterReferenceValue");return c===sn&&!im(s.sliceSerialize(b))?i(x):(e.enter("characterReferenceMarker"),e.consume(x),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(x)&&a++<o?(e.consume(x),_):i(x)}}const bv={partial:!0,tokenize:a5},vv={concrete:!0,name:"codeFenced",tokenize:s5};function s5(e,t,i){const s=this,a={partial:!0,tokenize:q};let o=0,c=0,h;return p;function p(D){return f(D)}function f(D){const te=s.events[s.events.length-1];return o=te&&te[1].type==="linePrefix"?te[2].sliceSerialize(te[1],!0).length:0,h=D,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),_(D)}function _(D){return D===h?(c++,e.consume(D),_):c<3?i(D):(e.exit("codeFencedFenceSequence"),_t(D)?Nt(e,x,"whitespace")(D):x(D))}function x(D){return D===null||Fe(D)?(e.exit("codeFencedFence"),s.interrupt?t(D):e.check(bv,N,W)(D)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(D))}function b(D){return D===null||Fe(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),x(D)):_t(D)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Nt(e,v,"whitespace")(D)):D===96&&D===h?i(D):(e.consume(D),b)}function v(D){return D===null||Fe(D)?x(D):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(D))}function y(D){return D===null||Fe(D)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),x(D)):D===96&&D===h?i(D):(e.consume(D),y)}function N(D){return e.attempt(a,W,j)(D)}function j(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),E}function E(D){return o>0&&_t(D)?Nt(e,z,"linePrefix",o+1)(D):z(D)}function z(D){return D===null||Fe(D)?e.check(bv,N,W)(D):(e.enter("codeFlowValue"),O(D))}function O(D){return D===null||Fe(D)?(e.exit("codeFlowValue"),z(D)):(e.consume(D),O)}function W(D){return e.exit("codeFenced"),t(D)}function q(D,te,de){let _e=0;return P;function P(I){return D.enter("lineEnding"),D.consume(I),D.exit("lineEnding"),ae}function ae(I){return D.enter("codeFencedFence"),_t(I)?Nt(D,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):G(I)}function G(I){return I===h?(D.enter("codeFencedFenceSequence"),Y(I)):de(I)}function Y(I){return I===h?(_e++,D.consume(I),Y):_e>=c?(D.exit("codeFencedFenceSequence"),_t(I)?Nt(D,Q,"whitespace")(I):Q(I)):de(I)}function Q(I){return I===null||Fe(I)?(D.exit("codeFencedFence"),te(I)):de(I)}}}function a5(e,t,i){const s=this;return a;function a(c){return c===null?i(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o)}function o(c){return s.parser.lazy[s.now().line]?i(c):t(c)}}const mf={name:"codeIndented",tokenize:o5},l5={partial:!0,tokenize:c5};function o5(e,t,i){const s=this;return a;function a(f){return e.enter("codeIndented"),Nt(e,o,"linePrefix",5)(f)}function o(f){const _=s.events[s.events.length-1];return _&&_[1].type==="linePrefix"&&_[2].sliceSerialize(_[1],!0).length>=4?c(f):i(f)}function c(f){return f===null?p(f):Fe(f)?e.attempt(l5,c,p)(f):(e.enter("codeFlowValue"),h(f))}function h(f){return f===null||Fe(f)?(e.exit("codeFlowValue"),c(f)):(e.consume(f),h)}function p(f){return e.exit("codeIndented"),t(f)}}function c5(e,t,i){const s=this;return a;function a(c){return s.parser.lazy[s.now().line]?i(c):Fe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),a):Nt(e,o,"linePrefix",5)(c)}function o(c){const h=s.events[s.events.length-1];return h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?t(c):Fe(c)?a(c):i(c)}}const u5={name:"codeText",previous:d5,resolve:h5,tokenize:f5};function h5(e){let t=e.length-4,i=3,s,a;if((e[i][1].type==="lineEnding"||e[i][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=i;++s<t;)if(e[s][1].type==="codeTextData"){e[i][1].type="codeTextPadding",e[t][1].type="codeTextPadding",i+=2,t-=2;break}}for(s=i-1,t++;++s<=t;)a===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(a=s):(s===t||e[s][1].type==="lineEnding")&&(e[a][1].type="codeTextData",s!==a+2&&(e[a][1].end=e[s-1][1].end,e.splice(a+2,s-a-2),t-=s-a-2,s=a+2),a=void 0);return e}function d5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function f5(e,t,i){let s=0,a,o;return c;function c(x){return e.enter("codeText"),e.enter("codeTextSequence"),h(x)}function h(x){return x===96?(e.consume(x),s++,h):(e.exit("codeTextSequence"),p(x))}function p(x){return x===null?i(x):x===32?(e.enter("space"),e.consume(x),e.exit("space"),p):x===96?(o=e.enter("codeTextSequence"),a=0,_(x)):Fe(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),p):(e.enter("codeTextData"),f(x))}function f(x){return x===null||x===32||x===96||Fe(x)?(e.exit("codeTextData"),p(x)):(e.consume(x),f)}function _(x){return x===96?(e.consume(x),a++,_):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(x)):(o.type="codeTextData",f(x))}}class p5{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,i){const s=i??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,i,s){const a=i||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return s&&ho(this.left,s),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),ho(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),ho(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const i=this.left.splice(t,Number.POSITIVE_INFINITY);ho(this.right,i.reverse())}else{const i=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);ho(this.left,i.reverse())}}}function ho(e,t){let i=0;if(t.length<1e4)e.push(...t);else for(;i<t.length;)e.push(...t.slice(i,i+1e4)),i+=1e4}function P0(e){const t={};let i=-1,s,a,o,c,h,p,f;const _=new p5(e);for(;++i<_.length;){for(;i in t;)i=t[i];if(s=_.get(i),i&&s[1].type==="chunkFlow"&&_.get(i-1)[1].type==="listItemPrefix"&&(p=s[1]._tokenizer.events,o=0,o<p.length&&p[o][1].type==="lineEndingBlank"&&(o+=2),o<p.length&&p[o][1].type==="content"))for(;++o<p.length&&p[o][1].type!=="content";)p[o][1].type==="chunkText"&&(p[o][1]._isInFirstContentOfListItem=!0,o++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,m5(_,i)),i=t[i],f=!0);else if(s[1]._container){for(o=i,a=void 0;o--;)if(c=_.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(a&&(_.get(a)[1].type="lineEndingBlank"),c[1].type="lineEnding",a=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;a&&(s[1].end={..._.get(a)[1].start},h=_.slice(a,i),h.unshift(s),_.splice(a,i-a+1,h))}}return $n(e,0,Number.POSITIVE_INFINITY,_.slice(0)),!f}function m5(e,t){const i=e.get(t)[1],s=e.get(t)[2];let a=t-1;const o=[];let c=i._tokenizer;c||(c=s.parser[i.contentType](i.start),i._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const h=c.events,p=[],f={};let _,x,b=-1,v=i,y=0,N=0;const j=[N];for(;v;){for(;e.get(++a)[1]!==v;);o.push(a),v._tokenizer||(_=s.sliceStream(v),v.next||_.push(null),x&&c.defineSkip(v.start),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(_),v._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),x=v,v=v.next}for(v=i;++b<h.length;)h[b][0]==="exit"&&h[b-1][0]==="enter"&&h[b][1].type===h[b-1][1].type&&h[b][1].start.line!==h[b][1].end.line&&(N=b+1,j.push(N),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(c.events=[],v?(v._tokenizer=void 0,v.previous=void 0):j.pop(),b=j.length;b--;){const E=h.slice(j[b],j[b+1]),z=o.pop();p.push([z,z+E.length-1]),e.splice(z,2,E)}for(p.reverse(),b=-1;++b<p.length;)f[y+p[b][0]]=y+p[b][1],y+=p[b][1]-p[b][0]-1;return f}const g5={resolve:_5,tokenize:b5},x5={partial:!0,tokenize:v5};function _5(e){return P0(e),e}function b5(e,t){let i;return s;function s(h){return e.enter("content"),i=e.enter("chunkContent",{contentType:"content"}),a(h)}function a(h){return h===null?o(h):Fe(h)?e.check(x5,c,o)(h):(e.consume(h),a)}function o(h){return e.exit("chunkContent"),e.exit("content"),t(h)}function c(h){return e.consume(h),e.exit("chunkContent"),i.next=e.enter("chunkContent",{contentType:"content",previous:i}),i=i.next,a}}function v5(e,t,i){const s=this;return a;function a(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Nt(e,o,"linePrefix")}function o(c){if(c===null||Fe(c))return i(c);const h=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&h&&h[1].type==="linePrefix"&&h[2].sliceSerialize(h[1],!0).length>=4?t(c):e.interrupt(s.parser.constructs.flow,i,t)(c)}}function I0(e,t,i,s,a,o,c,h,p){const f=p||Number.POSITIVE_INFINITY;let _=0;return x;function x(E){return E===60?(e.enter(s),e.enter(a),e.enter(o),e.consume(E),e.exit(o),b):E===null||E===32||E===41||ju(E)?i(E):(e.enter(s),e.enter(c),e.enter(h),e.enter("chunkString",{contentType:"string"}),N(E))}function b(E){return E===62?(e.enter(o),e.consume(E),e.exit(o),e.exit(a),e.exit(s),t):(e.enter(h),e.enter("chunkString",{contentType:"string"}),v(E))}function v(E){return E===62?(e.exit("chunkString"),e.exit(h),b(E)):E===null||E===60||Fe(E)?i(E):(e.consume(E),E===92?y:v)}function y(E){return E===60||E===62||E===92?(e.consume(E),v):v(E)}function N(E){return!_&&(E===null||E===41||Gt(E))?(e.exit("chunkString"),e.exit(h),e.exit(c),e.exit(s),t(E)):_<f&&E===40?(e.consume(E),_++,N):E===41?(e.consume(E),_--,N):E===null||E===32||E===40||ju(E)?i(E):(e.consume(E),E===92?j:N)}function j(E){return E===40||E===41||E===92?(e.consume(E),N):N(E)}}function H0(e,t,i,s,a,o){const c=this;let h=0,p;return f;function f(v){return e.enter(s),e.enter(a),e.consume(v),e.exit(a),e.enter(o),_}function _(v){return h>999||v===null||v===91||v===93&&!p||v===94&&!h&&"_hiddenFootnoteSupport"in c.parser.constructs?i(v):v===93?(e.exit(o),e.enter(a),e.consume(v),e.exit(a),e.exit(s),t):Fe(v)?(e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),_):(e.enter("chunkString",{contentType:"string"}),x(v))}function x(v){return v===null||v===91||v===93||Fe(v)||h++>999?(e.exit("chunkString"),_(v)):(e.consume(v),p||(p=!_t(v)),v===92?b:x)}function b(v){return v===91||v===92||v===93?(e.consume(v),h++,x):x(v)}}function U0(e,t,i,s,a,o){let c;return h;function h(b){return b===34||b===39||b===40?(e.enter(s),e.enter(a),e.consume(b),e.exit(a),c=b===40?41:b,p):i(b)}function p(b){return b===c?(e.enter(a),e.consume(b),e.exit(a),e.exit(s),t):(e.enter(o),f(b))}function f(b){return b===c?(e.exit(o),p(c)):b===null?i(b):Fe(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),Nt(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),_(b))}function _(b){return b===c||b===null||Fe(b)?(e.exit("chunkString"),f(b)):(e.consume(b),b===92?x:_)}function x(b){return b===c||b===92?(e.consume(b),_):_(b)}}function So(e,t){let i;return s;function s(a){return Fe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i=!0,s):_t(a)?Nt(e,s,i?"linePrefix":"lineSuffix")(a):t(a)}}const y5={name:"definition",tokenize:w5},S5={partial:!0,tokenize:C5};function w5(e,t,i){const s=this;let a;return o;function o(v){return e.enter("definition"),c(v)}function c(v){return H0.call(s,e,h,i,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function h(v){return a=gr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),p):i(v)}function p(v){return Gt(v)?So(e,f)(v):f(v)}function f(v){return I0(e,_,i,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function _(v){return e.attempt(S5,x,x)(v)}function x(v){return _t(v)?Nt(e,b,"whitespace")(v):b(v)}function b(v){return v===null||Fe(v)?(e.exit("definition"),s.parser.defined.push(a),t(v)):i(v)}}function C5(e,t,i){return s;function s(h){return Gt(h)?So(e,a)(h):i(h)}function a(h){return U0(e,o,i,"definitionTitle","definitionTitleMarker","definitionTitleString")(h)}function o(h){return _t(h)?Nt(e,c,"whitespace")(h):c(h)}function c(h){return h===null||Fe(h)?t(h):i(h)}}const k5={name:"hardBreakEscape",tokenize:E5};function E5(e,t,i){return s;function s(o){return e.enter("hardBreakEscape"),e.consume(o),a}function a(o){return Fe(o)?(e.exit("hardBreakEscape"),t(o)):i(o)}}const N5={name:"headingAtx",resolve:T5,tokenize:j5};function T5(e,t){let i=e.length-2,s=3,a,o;return e[s][1].type==="whitespace"&&(s+=2),i-2>s&&e[i][1].type==="whitespace"&&(i-=2),e[i][1].type==="atxHeadingSequence"&&(s===i-1||i-4>s&&e[i-2][1].type==="whitespace")&&(i-=s+1===i?2:4),i>s&&(a={type:"atxHeadingText",start:e[s][1].start,end:e[i][1].end},o={type:"chunkText",start:e[s][1].start,end:e[i][1].end,contentType:"text"},$n(e,s,i-s+1,[["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t]])),e}function j5(e,t,i){let s=0;return a;function a(_){return e.enter("atxHeading"),o(_)}function o(_){return e.enter("atxHeadingSequence"),c(_)}function c(_){return _===35&&s++<6?(e.consume(_),c):_===null||Gt(_)?(e.exit("atxHeadingSequence"),h(_)):i(_)}function h(_){return _===35?(e.enter("atxHeadingSequence"),p(_)):_===null||Fe(_)?(e.exit("atxHeading"),t(_)):_t(_)?Nt(e,h,"whitespace")(_):(e.enter("atxHeadingText"),f(_))}function p(_){return _===35?(e.consume(_),p):(e.exit("atxHeadingSequence"),h(_))}function f(_){return _===null||_===35||Gt(_)?(e.exit("atxHeadingText"),h(_)):(e.consume(_),f)}}const A5=["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","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],yv=["pre","script","style","textarea"],R5={concrete:!0,name:"htmlFlow",resolveTo:B5,tokenize:L5},M5={partial:!0,tokenize:z5},D5={partial:!0,tokenize:O5};function B5(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function L5(e,t,i){const s=this;let a,o,c,h,p;return f;function f(C){return _(C)}function _(C){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(C),x}function x(C){return C===33?(e.consume(C),b):C===47?(e.consume(C),o=!0,N):C===63?(e.consume(C),a=3,s.interrupt?t:T):pn(C)?(e.consume(C),c=String.fromCharCode(C),j):i(C)}function b(C){return C===45?(e.consume(C),a=2,v):C===91?(e.consume(C),a=5,h=0,y):pn(C)?(e.consume(C),a=4,s.interrupt?t:T):i(C)}function v(C){return C===45?(e.consume(C),s.interrupt?t:T):i(C)}function y(C){const K="CDATA[";return C===K.charCodeAt(h++)?(e.consume(C),h===K.length?s.interrupt?t:G:y):i(C)}function N(C){return pn(C)?(e.consume(C),c=String.fromCharCode(C),j):i(C)}function j(C){if(C===null||C===47||C===62||Gt(C)){const K=C===47,re=c.toLowerCase();return!K&&!o&&yv.includes(re)?(a=1,s.interrupt?t(C):G(C)):A5.includes(c.toLowerCase())?(a=6,K?(e.consume(C),E):s.interrupt?t(C):G(C)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?i(C):o?z(C):O(C))}return C===45||sn(C)?(e.consume(C),c+=String.fromCharCode(C),j):i(C)}function E(C){return C===62?(e.consume(C),s.interrupt?t:G):i(C)}function z(C){return _t(C)?(e.consume(C),z):P(C)}function O(C){return C===47?(e.consume(C),P):C===58||C===95||pn(C)?(e.consume(C),W):_t(C)?(e.consume(C),O):P(C)}function W(C){return C===45||C===46||C===58||C===95||sn(C)?(e.consume(C),W):q(C)}function q(C){return C===61?(e.consume(C),D):_t(C)?(e.consume(C),q):O(C)}function D(C){return C===null||C===60||C===61||C===62||C===96?i(C):C===34||C===39?(e.consume(C),p=C,te):_t(C)?(e.consume(C),D):de(C)}function te(C){return C===p?(e.consume(C),p=null,_e):C===null||Fe(C)?i(C):(e.consume(C),te)}function de(C){return C===null||C===34||C===39||C===47||C===60||C===61||C===62||C===96||Gt(C)?q(C):(e.consume(C),de)}function _e(C){return C===47||C===62||_t(C)?O(C):i(C)}function P(C){return C===62?(e.consume(C),ae):i(C)}function ae(C){return C===null||Fe(C)?G(C):_t(C)?(e.consume(C),ae):i(C)}function G(C){return C===45&&a===2?(e.consume(C),A):C===60&&a===1?(e.consume(C),B):C===62&&a===4?(e.consume(C),R):C===63&&a===3?(e.consume(C),T):C===93&&a===5?(e.consume(C),ge):Fe(C)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(M5,V,Y)(C)):C===null||Fe(C)?(e.exit("htmlFlowData"),Y(C)):(e.consume(C),G)}function Y(C){return e.check(D5,Q,V)(C)}function Q(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),I}function I(C){return C===null||Fe(C)?Y(C):(e.enter("htmlFlowData"),G(C))}function A(C){return C===45?(e.consume(C),T):G(C)}function B(C){return C===47?(e.consume(C),c="",U):G(C)}function U(C){if(C===62){const K=c.toLowerCase();return yv.includes(K)?(e.consume(C),R):G(C)}return pn(C)&&c.length<8?(e.consume(C),c+=String.fromCharCode(C),U):G(C)}function ge(C){return C===93?(e.consume(C),T):G(C)}function T(C){return C===62?(e.consume(C),R):C===45&&a===2?(e.consume(C),T):G(C)}function R(C){return C===null||Fe(C)?(e.exit("htmlFlowData"),V(C)):(e.consume(C),R)}function V(C){return e.exit("htmlFlow"),t(C)}}function O5(e,t,i){const s=this;return a;function a(c){return Fe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):i(c)}function o(c){return s.parser.lazy[s.now().line]?i(c):t(c)}}function z5(e,t,i){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Oo,t,i)}}const P5={name:"htmlText",tokenize:I5};function I5(e,t,i){const s=this;let a,o,c;return h;function h(T){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(T),p}function p(T){return T===33?(e.consume(T),f):T===47?(e.consume(T),q):T===63?(e.consume(T),O):pn(T)?(e.consume(T),de):i(T)}function f(T){return T===45?(e.consume(T),_):T===91?(e.consume(T),o=0,y):pn(T)?(e.consume(T),z):i(T)}function _(T){return T===45?(e.consume(T),v):i(T)}function x(T){return T===null?i(T):T===45?(e.consume(T),b):Fe(T)?(c=x,B(T)):(e.consume(T),x)}function b(T){return T===45?(e.consume(T),v):x(T)}function v(T){return T===62?A(T):T===45?b(T):x(T)}function y(T){const R="CDATA[";return T===R.charCodeAt(o++)?(e.consume(T),o===R.length?N:y):i(T)}function N(T){return T===null?i(T):T===93?(e.consume(T),j):Fe(T)?(c=N,B(T)):(e.consume(T),N)}function j(T){return T===93?(e.consume(T),E):N(T)}function E(T){return T===62?A(T):T===93?(e.consume(T),E):N(T)}function z(T){return T===null||T===62?A(T):Fe(T)?(c=z,B(T)):(e.consume(T),z)}function O(T){return T===null?i(T):T===63?(e.consume(T),W):Fe(T)?(c=O,B(T)):(e.consume(T),O)}function W(T){return T===62?A(T):O(T)}function q(T){return pn(T)?(e.consume(T),D):i(T)}function D(T){return T===45||sn(T)?(e.consume(T),D):te(T)}function te(T){return Fe(T)?(c=te,B(T)):_t(T)?(e.consume(T),te):A(T)}function de(T){return T===45||sn(T)?(e.consume(T),de):T===47||T===62||Gt(T)?_e(T):i(T)}function _e(T){return T===47?(e.consume(T),A):T===58||T===95||pn(T)?(e.consume(T),P):Fe(T)?(c=_e,B(T)):_t(T)?(e.consume(T),_e):A(T)}function P(T){return T===45||T===46||T===58||T===95||sn(T)?(e.consume(T),P):ae(T)}function ae(T){return T===61?(e.consume(T),G):Fe(T)?(c=ae,B(T)):_t(T)?(e.consume(T),ae):_e(T)}function G(T){return T===null||T===60||T===61||T===62||T===96?i(T):T===34||T===39?(e.consume(T),a=T,Y):Fe(T)?(c=G,B(T)):_t(T)?(e.consume(T),G):(e.consume(T),Q)}function Y(T){return T===a?(e.consume(T),a=void 0,I):T===null?i(T):Fe(T)?(c=Y,B(T)):(e.consume(T),Y)}function Q(T){return T===null||T===34||T===39||T===60||T===61||T===96?i(T):T===47||T===62||Gt(T)?_e(T):(e.consume(T),Q)}function I(T){return T===47||T===62||Gt(T)?_e(T):i(T)}function A(T){return T===62?(e.consume(T),e.exit("htmlTextData"),e.exit("htmlText"),t):i(T)}function B(T){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),U}function U(T){return _t(T)?Nt(e,ge,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):ge(T)}function ge(T){return e.enter("htmlTextData"),c(T)}}const nm={name:"labelEnd",resolveAll:F5,resolveTo:q5,tokenize:W5},H5={tokenize:G5},U5={tokenize:Y5},$5={tokenize:K5};function F5(e){let t=-1;const i=[];for(;++t<e.length;){const s=e[t][1];if(i.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const a=s.type==="labelImage"?4:2;s.type="data",t+=a}}return e.length!==i.length&&$n(e,0,e.length,i),e}function q5(e,t){let i=e.length,s=0,a,o,c,h;for(;i--;)if(a=e[i][1],o){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[i][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(c){if(e[i][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(o=i,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(c=i);const p={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[o][1].start},end:{...e[c][1].end}},_={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[c-2][1].start}};return h=[["enter",p,t],["enter",f,t]],h=sr(h,e.slice(o+1,o+s+3)),h=sr(h,[["enter",_,t]]),h=sr(h,Iu(t.parser.constructs.insideSpan.null,e.slice(o+s+4,c-3),t)),h=sr(h,[["exit",_,t],e[c-2],e[c-1],["exit",f,t]]),h=sr(h,e.slice(c+1)),h=sr(h,[["exit",p,t]]),$n(e,o,e.length,h),e}function W5(e,t,i){const s=this;let a=s.events.length,o,c;for(;a--;)if((s.events[a][1].type==="labelImage"||s.events[a][1].type==="labelLink")&&!s.events[a][1]._balanced){o=s.events[a][1];break}return h;function h(b){return o?o._inactive?x(b):(c=s.parser.defined.includes(gr(s.sliceSerialize({start:o.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),p):i(b)}function p(b){return b===40?e.attempt(H5,_,c?_:x)(b):b===91?e.attempt(U5,_,c?f:x)(b):c?_(b):x(b)}function f(b){return e.attempt($5,_,x)(b)}function _(b){return t(b)}function x(b){return o._balanced=!0,i(b)}}function G5(e,t,i){return s;function s(x){return e.enter("resource"),e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),a}function a(x){return Gt(x)?So(e,o)(x):o(x)}function o(x){return x===41?_(x):I0(e,c,h,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(x)}function c(x){return Gt(x)?So(e,p)(x):_(x)}function h(x){return i(x)}function p(x){return x===34||x===39||x===40?U0(e,f,i,"resourceTitle","resourceTitleMarker","resourceTitleString")(x):_(x)}function f(x){return Gt(x)?So(e,_)(x):_(x)}function _(x){return x===41?(e.enter("resourceMarker"),e.consume(x),e.exit("resourceMarker"),e.exit("resource"),t):i(x)}}function Y5(e,t,i){const s=this;return a;function a(h){return H0.call(s,e,o,c,"reference","referenceMarker","referenceString")(h)}function o(h){return s.parser.defined.includes(gr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(h):i(h)}function c(h){return i(h)}}function K5(e,t,i){return s;function s(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),a}function a(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):i(o)}}const V5={name:"labelStartImage",resolveAll:nm.resolveAll,tokenize:X5};function X5(e,t,i){const s=this;return a;function a(h){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(h),e.exit("labelImageMarker"),o}function o(h){return h===91?(e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelImage"),c):i(h)}function c(h){return h===94&&"_hiddenFootnoteSupport"in s.parser.constructs?i(h):t(h)}}const Z5={name:"labelStartLink",resolveAll:nm.resolveAll,tokenize:Q5};function Q5(e,t,i){const s=this;return a;function a(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),o}function o(c){return c===94&&"_hiddenFootnoteSupport"in s.parser.constructs?i(c):t(c)}}const gf={name:"lineEnding",tokenize:J5};function J5(e,t){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Nt(e,t,"linePrefix")}}const _u={name:"thematicBreak",tokenize:eT};function eT(e,t,i){let s=0,a;return o;function o(f){return e.enter("thematicBreak"),c(f)}function c(f){return a=f,h(f)}function h(f){return f===a?(e.enter("thematicBreakSequence"),p(f)):s>=3&&(f===null||Fe(f))?(e.exit("thematicBreak"),t(f)):i(f)}function p(f){return f===a?(e.consume(f),s++,p):(e.exit("thematicBreakSequence"),_t(f)?Nt(e,h,"whitespace")(f):h(f))}}const Nn={continuation:{tokenize:rT},exit:aT,name:"list",tokenize:nT},tT={partial:!0,tokenize:lT},iT={partial:!0,tokenize:sT};function nT(e,t,i){const s=this,a=s.events[s.events.length-1];let o=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,c=0;return h;function h(v){const y=s.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!s.containerState.marker||v===s.containerState.marker:Cp(v)){if(s.containerState.type||(s.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),v===42||v===45?e.check(_u,i,f)(v):f(v);if(!s.interrupt||v===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),p(v)}return i(v)}function p(v){return Cp(v)&&++c<10?(e.consume(v),p):(!s.interrupt||c<2)&&(s.containerState.marker?v===s.containerState.marker:v===41||v===46)?(e.exit("listItemValue"),f(v)):i(v)}function f(v){return e.enter("listItemMarker"),e.consume(v),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||v,e.check(Oo,s.interrupt?i:_,e.attempt(tT,b,x))}function _(v){return s.containerState.initialBlankLine=!0,o++,b(v)}function x(v){return _t(v)?(e.enter("listItemPrefixWhitespace"),e.consume(v),e.exit("listItemPrefixWhitespace"),b):i(v)}function b(v){return s.containerState.size=o+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(v)}}function rT(e,t,i){const s=this;return s.containerState._closeFlow=void 0,e.check(Oo,a,o);function a(h){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,Nt(e,t,"listItemIndent",s.containerState.size+1)(h)}function o(h){return s.containerState.furtherBlankLines||!_t(h)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,c(h)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(iT,t,c)(h))}function c(h){return s.containerState._closeFlow=!0,s.interrupt=void 0,Nt(e,e.attempt(Nn,t,i),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(h)}}function sT(e,t,i){const s=this;return Nt(e,a,"listItemIndent",s.containerState.size+1);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===s.containerState.size?t(o):i(o)}}function aT(e){e.exit(this.containerState.type)}function lT(e,t,i){const s=this;return Nt(e,a,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(o){const c=s.events[s.events.length-1];return!_t(o)&&c&&c[1].type==="listItemPrefixWhitespace"?t(o):i(o)}}const Sv={name:"setextUnderline",resolveTo:oT,tokenize:cT};function oT(e,t){let i=e.length,s,a,o;for(;i--;)if(e[i][0]==="enter"){if(e[i][1].type==="content"){s=i;break}e[i][1].type==="paragraph"&&(a=i)}else e[i][1].type==="content"&&e.splice(i,1),!o&&e[i][1].type==="definition"&&(o=i);const c={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",o?(e.splice(a,0,["enter",c,t]),e.splice(o+1,0,["exit",e[s][1],t]),e[s][1].end={...e[o][1].end}):e[s][1]=c,e.push(["exit",c,t]),e}function cT(e,t,i){const s=this;let a;return o;function o(f){let _=s.events.length,x;for(;_--;)if(s.events[_][1].type!=="lineEnding"&&s.events[_][1].type!=="linePrefix"&&s.events[_][1].type!=="content"){x=s.events[_][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||x)?(e.enter("setextHeadingLine"),a=f,c(f)):i(f)}function c(f){return e.enter("setextHeadingLineSequence"),h(f)}function h(f){return f===a?(e.consume(f),h):(e.exit("setextHeadingLineSequence"),_t(f)?Nt(e,p,"lineSuffix")(f):p(f))}function p(f){return f===null||Fe(f)?(e.exit("setextHeadingLine"),t(f)):i(f)}}const uT={tokenize:hT};function hT(e){const t=this,i=e.attempt(Oo,s,e.attempt(this.parser.constructs.flowInitial,a,Nt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(g5,a)),"linePrefix")));return i;function s(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,i}function a(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,i}}const dT={resolveAll:F0()},fT=$0("string"),pT=$0("text");function $0(e){return{resolveAll:F0(e==="text"?mT:void 0),tokenize:t};function t(i){const s=this,a=this.parser.constructs[e],o=i.attempt(a,c,h);return c;function c(_){return f(_)?o(_):h(_)}function h(_){if(_===null){i.consume(_);return}return i.enter("data"),i.consume(_),p}function p(_){return f(_)?(i.exit("data"),o(_)):(i.consume(_),p)}function f(_){if(_===null)return!0;const x=a[_];let b=-1;if(x)for(;++b<x.length;){const v=x[b];if(!v.previous||v.previous.call(s,s.previous))return!0}return!1}}}function F0(e){return t;function t(i,s){let a=-1,o;for(;++a<=i.length;)o===void 0?i[a]&&i[a][1].type==="data"&&(o=a,a++):(!i[a]||i[a][1].type!=="data")&&(a!==o+2&&(i[o][1].end=i[a-1][1].end,i.splice(o+2,a-o-2),a=o+2),o=void 0);return e?e(i,s):i}}function mT(e,t){let i=0;for(;++i<=e.length;)if((i===e.length||e[i][1].type==="lineEnding")&&e[i-1][1].type==="data"){const s=e[i-1][1],a=t.sliceStream(s);let o=a.length,c=-1,h=0,p;for(;o--;){const f=a[o];if(typeof f=="string"){for(c=f.length;f.charCodeAt(c-1)===32;)h++,c--;if(c)break;c=-1}else if(f===-2)p=!0,h++;else if(f!==-1){o++;break}}if(t._contentTypeTextTrailing&&i===e.length&&(h=0),h){const f={type:i===e.length||p||h<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:s.start._bufferIndex+c,_index:s.start._index+o,line:s.end.line,column:s.end.column-h,offset:s.end.offset-h},end:{...s.end}};s.end={...f.start},s.start.offset===s.end.offset?Object.assign(s,f):(e.splice(i,0,["enter",f,t],["exit",f,t]),i+=2)}i++}return e}const gT={42:Nn,43:Nn,45:Nn,48:Nn,49:Nn,50:Nn,51:Nn,52:Nn,53:Nn,54:Nn,55:Nn,56:Nn,57:Nn,62:L0},xT={91:y5},_T={[-2]:mf,[-1]:mf,32:mf},bT={35:N5,42:_u,45:[Sv,_u],60:R5,61:Sv,95:_u,96:vv,126:vv},vT={38:z0,92:O0},yT={[-5]:gf,[-4]:gf,[-3]:gf,33:V5,38:z0,42:kp,60:[ZN,P5],91:Z5,92:[k5,O0],93:nm,95:kp,96:u5},ST={null:[kp,dT]},wT={null:[42,95]},CT={null:[]},kT=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:wT,contentInitial:xT,disable:CT,document:gT,flow:bT,flowInitial:_T,insideSpan:ST,string:vT,text:yT},Symbol.toStringTag,{value:"Module"}));function ET(e,t,i){let s={_bufferIndex:-1,_index:0,line:i&&i.line||1,column:i&&i.column||1,offset:i&&i.offset||0};const a={},o=[];let c=[],h=[];const p={attempt:te(q),check:te(D),consume:z,enter:O,exit:W,interrupt:te(D,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:y,parser:e,previous:null,sliceSerialize:b,sliceStream:v,write:x};let _=t.tokenize.call(f,p);return t.resolveAll&&o.push(t),f;function x(ae){return c=sr(c,ae),j(),c[c.length-1]!==null?[]:(de(t,0),f.events=Iu(o,f.events,f),f.events)}function b(ae,G){return TT(v(ae),G)}function v(ae){return NT(c,ae)}function y(){const{_bufferIndex:ae,_index:G,line:Y,column:Q,offset:I}=s;return{_bufferIndex:ae,_index:G,line:Y,column:Q,offset:I}}function N(ae){a[ae.line]=ae.column,P()}function j(){let ae;for(;s._index<c.length;){const G=c[s._index];if(typeof G=="string")for(ae=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===ae&&s._bufferIndex<G.length;)E(G.charCodeAt(s._bufferIndex));else E(G)}}function E(ae){_=_(ae)}function z(ae){Fe(ae)?(s.line++,s.column=1,s.offset+=ae===-3?2:1,P()):ae!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===c[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=ae}function O(ae,G){const Y=G||{};return Y.type=ae,Y.start=y(),f.events.push(["enter",Y,f]),h.push(Y),Y}function W(ae){const G=h.pop();return G.end=y(),f.events.push(["exit",G,f]),G}function q(ae,G){de(ae,G.from)}function D(ae,G){G.restore()}function te(ae,G){return Y;function Y(Q,I,A){let B,U,ge,T;return Array.isArray(Q)?V(Q):"tokenize"in Q?V([Q]):R(Q);function R(ue){return $;function $(le){const be=le!==null&&ue[le],Te=le!==null&&ue.null,Le=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(Te)?Te:Te?[Te]:[]];return V(Le)(le)}}function V(ue){return B=ue,U=0,ue.length===0?A:C(ue[U])}function C(ue){return $;function $(le){return T=_e(),ge=ue,ue.partial||(f.currentConstruct=ue),ue.name&&f.parser.constructs.disable.null.includes(ue.name)?re():ue.tokenize.call(G?Object.assign(Object.create(f),G):f,p,K,re)(le)}}function K(ue){return ae(ge,T),I}function re(ue){return T.restore(),++U<B.length?C(B[U]):A}}}function de(ae,G){ae.resolveAll&&!o.includes(ae)&&o.push(ae),ae.resolve&&$n(f.events,G,f.events.length-G,ae.resolve(f.events.slice(G),f)),ae.resolveTo&&(f.events=ae.resolveTo(f.events,f))}function _e(){const ae=y(),G=f.previous,Y=f.currentConstruct,Q=f.events.length,I=Array.from(h);return{from:Q,restore:A};function A(){s=ae,f.previous=G,f.currentConstruct=Y,f.events.length=Q,h=I,P()}}function P(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function NT(e,t){const i=t.start._index,s=t.start._bufferIndex,a=t.end._index,o=t.end._bufferIndex;let c;if(i===a)c=[e[i].slice(s,o)];else{if(c=e.slice(i,a),s>-1){const h=c[0];typeof h=="string"?c[0]=h.slice(s):c.shift()}o>0&&c.push(e[a].slice(0,o))}return c}function TT(e,t){let i=-1;const s=[];let a;for(;++i<e.length;){const o=e[i];let c;if(typeof o=="string")c=o;else switch(o){case-5:{c="\r";break}case-4:{c=`
103
+ `;break}case-3:{c=`\r
104
+ `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&a)continue;c=" ";break}default:c=String.fromCharCode(o)}a=o===-2,s.push(c)}return s.join("")}function jT(e){const s={constructs:D0([kT,...(e||{}).extensions||[]]),content:a(qN),defined:[],document:a(GN),flow:a(uT),lazy:{},string:a(fT),text:a(pT)};return s;function a(o){return c;function c(h){return ET(s,o,h)}}}function AT(e){for(;!P0(e););return e}const wv=/[\0\t\n\r]/g;function RT(){let e=1,t="",i=!0,s;return a;function a(o,c,h){const p=[];let f,_,x,b,v;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),x=0,t="",i&&(o.charCodeAt(0)===65279&&x++,i=void 0);x<o.length;){if(wv.lastIndex=x,f=wv.exec(o),b=f&&f.index!==void 0?f.index:o.length,v=o.charCodeAt(b),!f){t=o.slice(x);break}if(v===10&&x===b&&s)p.push(-3),s=void 0;else switch(s&&(p.push(-5),s=void 0),x<b&&(p.push(o.slice(x,b)),e+=b-x),v){case 0:{p.push(65533),e++;break}case 9:{for(_=Math.ceil(e/4)*4,p.push(-2);e++<_;)p.push(-1);break}case 10:{p.push(-4),e=1;break}default:s=!0,e=1}x=b+1}return h&&(s&&p.push(-5),t&&p.push(t),p.push(null)),p}}const MT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function DT(e){return e.replace(MT,BT)}function BT(e,t,i){if(t)return t;if(i.charCodeAt(0)===35){const a=i.charCodeAt(1),o=a===120||a===88;return B0(i.slice(o?2:1),o?16:10)}return im(i)||e}const q0={}.hasOwnProperty;function LT(e,t,i){return t&&typeof t=="object"&&(i=t,t=void 0),OT(i)(AT(jT(i).document().write(RT()(e,t,!0))))}function OT(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Me),autolinkProtocol:_e,autolinkEmail:_e,atxHeading:o(bt),blockQuote:o(Te),characterEscape:_e,characterReference:_e,codeFenced:o(Le),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(Le,c),codeText:o(ze,c),codeTextData:_e,data:_e,codeFlowValue:_e,definition:o(ye),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(rt),hardBreakEscape:o(wt),hardBreakTrailing:o(wt),htmlFlow:o(vt,c),htmlFlowData:_e,htmlText:o(vt,c),htmlTextData:_e,image:o(Ve),label:c,link:o(Me),listItem:o(It),listItemValue:b,listOrdered:o(Je,x),listUnordered:o(Je),paragraph:o(Ae),reference:C,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(bt),strong:o(ii),thematicBreak:o(pi)},exit:{atxHeading:p(),atxHeadingSequence:q,autolink:p(),autolinkEmail:be,autolinkProtocol:le,blockQuote:p(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:ue,characterReference:$,codeFenced:p(j),codeFencedFence:N,codeFencedFenceInfo:v,codeFencedFenceMeta:y,codeFlowValue:P,codeIndented:p(E),codeText:p(I),codeTextData:P,data:P,definition:p(),definitionDestinationString:W,definitionLabelString:z,definitionTitleString:O,emphasis:p(),hardBreakEscape:p(G),hardBreakTrailing:p(G),htmlFlow:p(Y),htmlFlowData:P,htmlText:p(Q),htmlTextData:P,image:p(B),label:ge,labelText:U,lineEnding:ae,link:p(A),listItem:p(),listOrdered:p(),listUnordered:p(),paragraph:p(),referenceString:K,resourceDestinationString:T,resourceTitleString:R,resource:V,setextHeading:p(de),setextHeadingLineSequence:te,setextHeadingText:D,strong:p(),thematicBreak:p()}};W0(t,(e||{}).mdastExtensions||[]);const i={};return s;function s(ne){let xe={type:"root",children:[]};const Be={stack:[xe],tokenStack:[],config:t,enter:h,exit:f,buffer:c,resume:_,data:i},$e=[];let Ge=-1;for(;++Ge<ne.length;)if(ne[Ge][1].type==="listOrdered"||ne[Ge][1].type==="listUnordered")if(ne[Ge][0]==="enter")$e.push(Ge);else{const Ot=$e.pop();Ge=a(ne,Ot,Ge)}for(Ge=-1;++Ge<ne.length;){const Ot=t[ne[Ge][0]];q0.call(Ot,ne[Ge][1].type)&&Ot[ne[Ge][1].type].call(Object.assign({sliceSerialize:ne[Ge][2].sliceSerialize},Be),ne[Ge][1])}if(Be.tokenStack.length>0){const Ot=Be.tokenStack[Be.tokenStack.length-1];(Ot[1]||Cv).call(Be,void 0,Ot[0])}for(xe.position={start:Ts(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:Ts(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},Ge=-1;++Ge<t.transforms.length;)xe=t.transforms[Ge](xe)||xe;return xe}function a(ne,xe,Be){let $e=xe-1,Ge=-1,Ot=!1,Mt,ct,We,Bt;for(;++$e<=Be;){const pt=ne[$e];switch(pt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{pt[0]==="enter"?Ge++:Ge--,Bt=void 0;break}case"lineEndingBlank":{pt[0]==="enter"&&(Mt&&!Bt&&!Ge&&!We&&(We=$e),Bt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Bt=void 0}if(!Ge&&pt[0]==="enter"&&pt[1].type==="listItemPrefix"||Ge===-1&&pt[0]==="exit"&&(pt[1].type==="listUnordered"||pt[1].type==="listOrdered")){if(Mt){let Mi=$e;for(ct=void 0;Mi--;){const H=ne[Mi];if(H[1].type==="lineEnding"||H[1].type==="lineEndingBlank"){if(H[0]==="exit")continue;ct&&(ne[ct][1].type="lineEndingBlank",Ot=!0),H[1].type="lineEnding",ct=Mi}else if(!(H[1].type==="linePrefix"||H[1].type==="blockQuotePrefix"||H[1].type==="blockQuotePrefixWhitespace"||H[1].type==="blockQuoteMarker"||H[1].type==="listItemIndent"))break}We&&(!ct||We<ct)&&(Mt._spread=!0),Mt.end=Object.assign({},ct?ne[ct][1].start:pt[1].end),ne.splice(ct||$e,0,["exit",Mt,pt[2]]),$e++,Be++}if(pt[1].type==="listItemPrefix"){const Mi={type:"listItem",_spread:!1,start:Object.assign({},pt[1].start),end:void 0};Mt=Mi,ne.splice($e,0,["enter",Mi,pt[2]]),$e++,Be++,We=void 0,Bt=!0}}}return ne[xe][1]._spread=Ot,Be}function o(ne,xe){return Be;function Be($e){h.call(this,ne($e),$e),xe&&xe.call(this,$e)}}function c(){this.stack.push({type:"fragment",children:[]})}function h(ne,xe,Be){this.stack[this.stack.length-1].children.push(ne),this.stack.push(ne),this.tokenStack.push([xe,Be||void 0]),ne.position={start:Ts(xe.start),end:void 0}}function p(ne){return xe;function xe(Be){ne&&ne.call(this,Be),f.call(this,Be)}}function f(ne,xe){const Be=this.stack.pop(),$e=this.tokenStack.pop();if($e)$e[0].type!==ne.type&&(xe?xe.call(this,ne,$e[0]):($e[1]||Cv).call(this,ne,$e[0]));else throw new Error("Cannot close `"+ne.type+"` ("+yo({start:ne.start,end:ne.end})+"): it’s not open");Be.position.end=Ts(ne.end)}function _(){return tm(this.stack.pop())}function x(){this.data.expectingFirstListItemValue=!0}function b(ne){if(this.data.expectingFirstListItemValue){const xe=this.stack[this.stack.length-2];xe.start=Number.parseInt(this.sliceSerialize(ne),10),this.data.expectingFirstListItemValue=void 0}}function v(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.lang=ne}function y(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.meta=ne}function N(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function j(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ne.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function E(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ne.replace(/(\r?\n|\r)$/g,"")}function z(ne){const xe=this.resume(),Be=this.stack[this.stack.length-1];Be.label=xe,Be.identifier=gr(this.sliceSerialize(ne)).toLowerCase()}function O(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ne}function W(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ne}function q(ne){const xe=this.stack[this.stack.length-1];if(!xe.depth){const Be=this.sliceSerialize(ne).length;xe.depth=Be}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function te(ne){const xe=this.stack[this.stack.length-1];xe.depth=this.sliceSerialize(ne).codePointAt(0)===61?1:2}function de(){this.data.setextHeadingSlurpLineEnding=void 0}function _e(ne){const Be=this.stack[this.stack.length-1].children;let $e=Be[Be.length-1];(!$e||$e.type!=="text")&&($e=Ct(),$e.position={start:Ts(ne.start),end:void 0},Be.push($e)),this.stack.push($e)}function P(ne){const xe=this.stack.pop();xe.value+=this.sliceSerialize(ne),xe.position.end=Ts(ne.end)}function ae(ne){const xe=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Be=xe.children[xe.children.length-1];Be.position.end=Ts(ne.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(xe.type)&&(_e.call(this,ne),P.call(this,ne))}function G(){this.data.atHardBreak=!0}function Y(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ne}function Q(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ne}function I(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.value=ne}function A(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=xe,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function B(){const ne=this.stack[this.stack.length-1];if(this.data.inReference){const xe=this.data.referenceType||"shortcut";ne.type+="Reference",ne.referenceType=xe,delete ne.url,delete ne.title}else delete ne.identifier,delete ne.label;this.data.referenceType=void 0}function U(ne){const xe=this.sliceSerialize(ne),Be=this.stack[this.stack.length-2];Be.label=DT(xe),Be.identifier=gr(xe).toLowerCase()}function ge(){const ne=this.stack[this.stack.length-1],xe=this.resume(),Be=this.stack[this.stack.length-1];if(this.data.inReference=!0,Be.type==="link"){const $e=ne.children;Be.children=$e}else Be.alt=xe}function T(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.url=ne}function R(){const ne=this.resume(),xe=this.stack[this.stack.length-1];xe.title=ne}function V(){this.data.inReference=void 0}function C(){this.data.referenceType="collapsed"}function K(ne){const xe=this.resume(),Be=this.stack[this.stack.length-1];Be.label=xe,Be.identifier=gr(this.sliceSerialize(ne)).toLowerCase(),this.data.referenceType="full"}function re(ne){this.data.characterReferenceType=ne.type}function ue(ne){const xe=this.sliceSerialize(ne),Be=this.data.characterReferenceType;let $e;Be?($e=B0(xe,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):$e=im(xe);const Ge=this.stack[this.stack.length-1];Ge.value+=$e}function $(ne){const xe=this.stack.pop();xe.position.end=Ts(ne.end)}function le(ne){P.call(this,ne);const xe=this.stack[this.stack.length-1];xe.url=this.sliceSerialize(ne)}function be(ne){P.call(this,ne);const xe=this.stack[this.stack.length-1];xe.url="mailto:"+this.sliceSerialize(ne)}function Te(){return{type:"blockquote",children:[]}}function Le(){return{type:"code",lang:null,meta:null,value:""}}function ze(){return{type:"inlineCode",value:""}}function ye(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function rt(){return{type:"emphasis",children:[]}}function bt(){return{type:"heading",depth:0,children:[]}}function wt(){return{type:"break"}}function vt(){return{type:"html",value:""}}function Ve(){return{type:"image",title:null,url:"",alt:null}}function Me(){return{type:"link",title:null,url:"",children:[]}}function Je(ne){return{type:"list",ordered:ne.type==="listOrdered",start:null,spread:ne._spread,children:[]}}function It(ne){return{type:"listItem",spread:ne._spread,checked:null,children:[]}}function Ae(){return{type:"paragraph",children:[]}}function ii(){return{type:"strong",children:[]}}function Ct(){return{type:"text",value:""}}function pi(){return{type:"thematicBreak"}}}function Ts(e){return{line:e.line,column:e.column,offset:e.offset}}function W0(e,t){let i=-1;for(;++i<t.length;){const s=t[i];Array.isArray(s)?W0(e,s):zT(e,s)}}function zT(e,t){let i;for(i in t)if(q0.call(t,i))switch(i){case"canContainEols":{const s=t[i];s&&e[i].push(...s);break}case"transforms":{const s=t[i];s&&e[i].push(...s);break}case"enter":case"exit":{const s=t[i];s&&Object.assign(e[i],s);break}}}function Cv(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+yo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+yo({start:t.start,end:t.end})+") is still open")}function PT(e){const t=this;t.parser=i;function i(s){return LT(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function IT(e,t){const i={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,i),e.applyData(t,i)}function HT(e,t){const i={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,i),[e.applyData(t,i),{type:"text",value:`
105
+ `}]}function UT(e,t){const i=t.value?t.value+`
106
+ `:"",s={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(s.className=["language-"+a[0]]);let o={type:"element",tagName:"code",properties:s,children:[{type:"text",value:i}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function $T(e,t){const i={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function FT(e,t){const i={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function qT(e,t){const i=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=hl(s.toLowerCase()),o=e.footnoteOrder.indexOf(s);let c,h=e.footnoteCounts.get(s);h===void 0?(h=0,e.footnoteOrder.push(s),c=e.footnoteOrder.length):c=o+1,h+=1,e.footnoteCounts.set(s,h);const p={type:"element",tagName:"a",properties:{href:"#"+i+"fn-"+a,id:i+"fnref-"+a+(h>1?"-"+h:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};e.patch(t,p);const f={type:"element",tagName:"sup",properties:{},children:[p]};return e.patch(t,f),e.applyData(t,f)}function WT(e,t){const i={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function GT(e,t){if(e.options.allowDangerousHtml){const i={type:"raw",value:t.value};return e.patch(t,i),e.applyData(t,i)}}function G0(e,t){const i=t.referenceType;let s="]";if(i==="collapsed"?s+="[]":i==="full"&&(s+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+s}];const a=e.all(t),o=a[0];o&&o.type==="text"?o.value="["+o.value:a.unshift({type:"text",value:"["});const c=a[a.length-1];return c&&c.type==="text"?c.value+=s:a.push({type:"text",value:s}),a}function YT(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return G0(e,t);const a={src:hl(s.url||""),alt:t.alt};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,o),e.applyData(t,o)}function KT(e,t){const i={src:hl(t.url)};t.alt!==null&&t.alt!==void 0&&(i.alt=t.alt),t.title!==null&&t.title!==void 0&&(i.title=t.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function VT(e,t){const i={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,i);const s={type:"element",tagName:"code",properties:{},children:[i]};return e.patch(t,s),e.applyData(t,s)}function XT(e,t){const i=String(t.identifier).toUpperCase(),s=e.definitionById.get(i);if(!s)return G0(e,t);const a={href:hl(s.url||"")};s.title!==null&&s.title!==void 0&&(a.title=s.title);const o={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function ZT(e,t){const i={href:hl(t.url)};t.title!==null&&t.title!==void 0&&(i.title=t.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function QT(e,t,i){const s=e.all(t),a=i?JT(i):Y0(t),o={},c=[];if(typeof t.checked=="boolean"){const _=s[0];let x;_&&_.type==="element"&&_.tagName==="p"?x=_:(x={type:"element",tagName:"p",properties:{},children:[]},s.unshift(x)),x.children.length>0&&x.children.unshift({type:"text",value:" "}),x.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let h=-1;for(;++h<s.length;){const _=s[h];(a||h!==0||_.type!=="element"||_.tagName!=="p")&&c.push({type:"text",value:`
107
+ `}),_.type==="element"&&_.tagName==="p"&&!a?c.push(..._.children):c.push(_)}const p=s[s.length-1];p&&(a||p.type!=="element"||p.tagName!=="p")&&c.push({type:"text",value:`
108
+ `});const f={type:"element",tagName:"li",properties:o,children:c};return e.patch(t,f),e.applyData(t,f)}function JT(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const i=e.children;let s=-1;for(;!t&&++s<i.length;)t=Y0(i[s])}return t}function Y0(e){const t=e.spread;return t??e.children.length>1}function ej(e,t){const i={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(i.start=t.start);++a<s.length;){const c=s[a];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){i.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:i,children:e.wrap(s,!0)};return e.patch(t,o),e.applyData(t,o)}function tj(e,t){const i={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function ij(e,t){const i={type:"root",children:e.wrap(e.all(t))};return e.patch(t,i),e.applyData(t,i)}function nj(e,t){const i={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function rj(e,t){const i=e.all(t),s=i.shift(),a=[];if(s){const c={type:"element",tagName:"thead",properties:{},children:e.wrap([s],!0)};e.patch(t.children[0],c),a.push(c)}if(i.length>0){const c={type:"element",tagName:"tbody",properties:{},children:e.wrap(i,!0)},h=Zp(t.children[1]),p=k0(t.children[t.children.length-1]);h&&p&&(c.position={start:h,end:p}),a.push(c)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,o),e.applyData(t,o)}function sj(e,t,i){const s=i?i.children:void 0,o=(s?s.indexOf(t):1)===0?"th":"td",c=i&&i.type==="table"?i.align:void 0,h=c?c.length:t.children.length;let p=-1;const f=[];for(;++p<h;){const x=t.children[p],b={},v=c?c[p]:void 0;v&&(b.align=v);let y={type:"element",tagName:o,properties:b,children:[]};x&&(y.children=e.all(x),e.patch(x,y),y=e.applyData(x,y)),f.push(y)}const _={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,_),e.applyData(t,_)}function aj(e,t){const i={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}const kv=9,Ev=32;function lj(e){const t=String(e),i=/\r?\n|\r/g;let s=i.exec(t),a=0;const o=[];for(;s;)o.push(Nv(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=i.exec(t);return o.push(Nv(t.slice(a),a>0,!1)),o.join("")}function Nv(e,t,i){let s=0,a=e.length;if(t){let o=e.codePointAt(s);for(;o===kv||o===Ev;)s++,o=e.codePointAt(s)}if(i){let o=e.codePointAt(a-1);for(;o===kv||o===Ev;)a--,o=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function oj(e,t){const i={type:"text",value:lj(String(t.value))};return e.patch(t,i),e.applyData(t,i)}function cj(e,t){const i={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,i),e.applyData(t,i)}const uj={blockquote:IT,break:HT,code:UT,delete:$T,emphasis:FT,footnoteReference:qT,heading:WT,html:GT,imageReference:YT,image:KT,inlineCode:VT,linkReference:XT,link:ZT,listItem:QT,list:ej,paragraph:tj,root:ij,strong:nj,table:rj,tableCell:aj,tableRow:sj,text:oj,thematicBreak:cj,toml:tu,yaml:tu,definition:tu,footnoteDefinition:tu};function tu(){}const K0=-1,Hu=0,wo=1,Au=2,rm=3,sm=4,am=5,lm=6,V0=7,X0=8,Tv=typeof self=="object"?self:globalThis,hj=(e,t)=>{const i=(a,o)=>(e.set(o,a),a),s=a=>{if(e.has(a))return e.get(a);const[o,c]=t[a];switch(o){case Hu:case K0:return i(c,a);case wo:{const h=i([],a);for(const p of c)h.push(s(p));return h}case Au:{const h=i({},a);for(const[p,f]of c)h[s(p)]=s(f);return h}case rm:return i(new Date(c),a);case sm:{const{source:h,flags:p}=c;return i(new RegExp(h,p),a)}case am:{const h=i(new Map,a);for(const[p,f]of c)h.set(s(p),s(f));return h}case lm:{const h=i(new Set,a);for(const p of c)h.add(s(p));return h}case V0:{const{name:h,message:p}=c;return i(new Tv[h](p),a)}case X0:return i(BigInt(c),a);case"BigInt":return i(Object(BigInt(c)),a);case"ArrayBuffer":return i(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:h}=new Uint8Array(c);return i(new DataView(h),c)}}return i(new Tv[o](c),a)};return s},jv=e=>hj(new Map,e)(0),Ja="",{toString:dj}={},{keys:fj}=Object,fo=e=>{const t=typeof e;if(t!=="object"||!e)return[Hu,t];const i=dj.call(e).slice(8,-1);switch(i){case"Array":return[wo,Ja];case"Object":return[Au,Ja];case"Date":return[rm,Ja];case"RegExp":return[sm,Ja];case"Map":return[am,Ja];case"Set":return[lm,Ja];case"DataView":return[wo,i]}return i.includes("Array")?[wo,i]:i.includes("Error")?[V0,i]:[Au,i]},iu=([e,t])=>e===Hu&&(t==="function"||t==="symbol"),pj=(e,t,i,s)=>{const a=(c,h)=>{const p=s.push(c)-1;return i.set(h,p),p},o=c=>{if(i.has(c))return i.get(c);let[h,p]=fo(c);switch(h){case Hu:{let _=c;switch(p){case"bigint":h=X0,_=c.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+p);_=null;break;case"undefined":return a([K0],c)}return a([h,_],c)}case wo:{if(p){let b=c;return p==="DataView"?b=new Uint8Array(c.buffer):p==="ArrayBuffer"&&(b=new Uint8Array(c)),a([p,[...b]],c)}const _=[],x=a([h,_],c);for(const b of c)_.push(o(b));return x}case Au:{if(p)switch(p){case"BigInt":return a([p,c.toString()],c);case"Boolean":case"Number":case"String":return a([p,c.valueOf()],c)}if(t&&"toJSON"in c)return o(c.toJSON());const _=[],x=a([h,_],c);for(const b of fj(c))(e||!iu(fo(c[b])))&&_.push([o(b),o(c[b])]);return x}case rm:return a([h,c.toISOString()],c);case sm:{const{source:_,flags:x}=c;return a([h,{source:_,flags:x}],c)}case am:{const _=[],x=a([h,_],c);for(const[b,v]of c)(e||!(iu(fo(b))||iu(fo(v))))&&_.push([o(b),o(v)]);return x}case lm:{const _=[],x=a([h,_],c);for(const b of c)(e||!iu(fo(b)))&&_.push(o(b));return x}}const{message:f}=c;return a([h,{name:p,message:f}],c)};return o},Av=(e,{json:t,lossy:i}={})=>{const s=[];return pj(!(t||i),!!t,new Map,s)(e),s},To=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?jv(Av(e,t)):structuredClone(e):(e,t)=>jv(Av(e,t));function mj(e,t){const i=[{type:"text",value:"↩"}];return t>1&&i.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),i}function gj(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function xj(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",i=e.options.footnoteBackContent||mj,s=e.options.footnoteBackLabel||gj,a=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",c=e.options.footnoteLabelProperties||{className:["sr-only"]},h=[];let p=-1;for(;++p<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[p]);if(!f)continue;const _=e.all(f),x=String(f.identifier).toUpperCase(),b=hl(x.toLowerCase());let v=0;const y=[],N=e.footnoteCounts.get(x);for(;N!==void 0&&++v<=N;){y.length>0&&y.push({type:"text",value:" "});let z=typeof i=="string"?i:i(p,v);typeof z=="string"&&(z={type:"text",value:z}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(p,v),className:["data-footnote-backref"]},children:Array.isArray(z)?z:[z]})}const j=_[_.length-1];if(j&&j.type==="element"&&j.tagName==="p"){const z=j.children[j.children.length-1];z&&z.type==="text"?z.value+=" ":j.children.push({type:"text",value:" "}),j.children.push(...y)}else _.push(...y);const E={type:"element",tagName:"li",properties:{id:t+"fn-"+b},children:e.wrap(_,!0)};e.patch(f,E),h.push(E)}if(h.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...To(c),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
109
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(h,!0)},{type:"text",value:`
110
+ `}]}}const Uu=(function(e){if(e==null)return yj;if(typeof e=="function")return $u(e);if(typeof e=="object")return Array.isArray(e)?_j(e):bj(e);if(typeof e=="string")return vj(e);throw new Error("Expected function, string, or object as test")});function _j(e){const t=[];let i=-1;for(;++i<e.length;)t[i]=Uu(e[i]);return $u(s);function s(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function bj(e){const t=e;return $u(i);function i(s){const a=s;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function vj(e){return $u(t);function t(i){return i&&i.type===e}}function $u(e){return t;function t(i,s,a){return!!(Sj(i)&&e.call(this,i,typeof s=="number"?s:void 0,a||void 0))}}function yj(){return!0}function Sj(e){return e!==null&&typeof e=="object"&&"type"in e}const Z0=[],wj=!0,Ep=!1,Cj="skip";function Q0(e,t,i,s){let a;typeof t=="function"&&typeof i!="function"?(s=i,i=t):a=t;const o=Uu(a),c=s?-1:1;h(e,void 0,[])();function h(p,f,_){const x=p&&typeof p=="object"?p:{};if(typeof x.type=="string"){const v=typeof x.tagName=="string"?x.tagName:typeof x.name=="string"?x.name:void 0;Object.defineProperty(b,"name",{value:"node ("+(p.type+(v?"<"+v+">":""))+")"})}return b;function b(){let v=Z0,y,N,j;if((!t||o(p,f,_[_.length-1]||void 0))&&(v=kj(i(p,_)),v[0]===Ep))return v;if("children"in p&&p.children){const E=p;if(E.children&&v[0]!==Cj)for(N=(s?E.children.length:-1)+c,j=_.concat(E);N>-1&&N<E.children.length;){const z=E.children[N];if(y=h(z,N,j)(),y[0]===Ep)return y;N=typeof y[1]=="number"?y[1]:N+c}}return v}}}function kj(e){return Array.isArray(e)?e:typeof e=="number"?[wj,e]:e==null?Z0:[e]}function om(e,t,i,s){let a,o,c;typeof t=="function"&&typeof i!="function"?(o=void 0,c=t,a=i):(o=t,c=i,a=s),Q0(e,o,h,a);function h(p,f){const _=f[f.length-1],x=_?_.children.indexOf(p):void 0;return c(p,x,_)}}const Np={}.hasOwnProperty,Ej={};function Nj(e,t){const i=t||Ej,s=new Map,a=new Map,o=new Map,c={...uj,...i.handlers},h={all:f,applyData:jj,definitionById:s,footnoteById:a,footnoteCounts:o,footnoteOrder:[],handlers:c,one:p,options:i,patch:Tj,wrap:Rj};return om(e,function(_){if(_.type==="definition"||_.type==="footnoteDefinition"){const x=_.type==="definition"?s:a,b=String(_.identifier).toUpperCase();x.has(b)||x.set(b,_)}}),h;function p(_,x){const b=_.type,v=h.handlers[b];if(Np.call(h.handlers,b)&&v)return v(h,_,x);if(h.options.passThrough&&h.options.passThrough.includes(b)){if("children"in _){const{children:N,...j}=_,E=To(j);return E.children=h.all(_),E}return To(_)}return(h.options.unknownHandler||Aj)(h,_,x)}function f(_){const x=[];if("children"in _){const b=_.children;let v=-1;for(;++v<b.length;){const y=h.one(b[v],_);if(y){if(v&&b[v-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=Rv(y.value)),!Array.isArray(y)&&y.type==="element")){const N=y.children[0];N&&N.type==="text"&&(N.value=Rv(N.value))}Array.isArray(y)?x.push(...y):x.push(y)}}}return x}}function Tj(e,t){e.position&&(t.position=N0(e))}function jj(e,t){let i=t;if(e&&e.data){const s=e.data.hName,a=e.data.hChildren,o=e.data.hProperties;if(typeof s=="string")if(i.type==="element")i.tagName=s;else{const c="children"in i?i.children:[i];i={type:"element",tagName:s,properties:{},children:c}}i.type==="element"&&o&&Object.assign(i.properties,To(o)),"children"in i&&i.children&&a!==null&&a!==void 0&&(i.children=a)}return i}function Aj(e,t){const i=t.data||{},s="value"in t&&!(Np.call(i,"hProperties")||Np.call(i,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Rj(e,t){const i=[];let s=-1;for(t&&i.push({type:"text",value:`
111
+ `});++s<e.length;)s&&i.push({type:"text",value:`
112
+ `}),i.push(e[s]);return t&&e.length>0&&i.push({type:"text",value:`
113
+ `}),i}function Rv(e){let t=0,i=e.charCodeAt(t);for(;i===9||i===32;)t++,i=e.charCodeAt(t);return e.slice(t)}function Mv(e,t){const i=Nj(e,t),s=i.one(e,void 0),a=xj(i),o=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&o.children.push({type:"text",value:`
114
+ `},a),o}function Mj(e,t){return e&&"run"in e?async function(i,s){const a=Mv(i,{file:s,...t});await e.run(a,s)}:function(i,s){return Mv(i,{file:s,...e||t})}}function Dv(e){if(e)throw e}var xf,Bv;function Dj(){if(Bv)return xf;Bv=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},o=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var _=e.call(f,"constructor"),x=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!_&&!x)return!1;var b;for(b in f);return typeof b>"u"||e.call(f,b)},c=function(f,_){i&&_.name==="__proto__"?i(f,_.name,{enumerable:!0,configurable:!0,value:_.newValue,writable:!0}):f[_.name]=_.newValue},h=function(f,_){if(_==="__proto__")if(e.call(f,_)){if(s)return s(f,_).value}else return;return f[_]};return xf=function p(){var f,_,x,b,v,y,N=arguments[0],j=1,E=arguments.length,z=!1;for(typeof N=="boolean"&&(z=N,N=arguments[1]||{},j=2),(N==null||typeof N!="object"&&typeof N!="function")&&(N={});j<E;++j)if(f=arguments[j],f!=null)for(_ in f)x=h(N,_),b=h(f,_),N!==b&&(z&&b&&(o(b)||(v=a(b)))?(v?(v=!1,y=x&&a(x)?x:[]):y=x&&o(x)?x:{},c(N,{name:_,newValue:p(z,y,b)})):typeof b<"u"&&c(N,{name:_,newValue:b}));return N},xf}var Bj=Dj();const _f=Du(Bj);function Tp(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Lj(){const e=[],t={run:i,use:s};return t;function i(...a){let o=-1;const c=a.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);h(null,...a);function h(p,...f){const _=e[++o];let x=-1;if(p){c(p);return}for(;++x<a.length;)(f[x]===null||f[x]===void 0)&&(f[x]=a[x]);a=f,_?Oj(_,h)(...f):c(null,...f)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function Oj(e,t){let i;return s;function s(...c){const h=e.length>c.length;let p;h&&c.push(a);try{p=e.apply(this,c)}catch(f){const _=f;if(h&&i)throw _;return a(_)}h||(p&&p.then&&typeof p.then=="function"?p.then(o,a):p instanceof Error?a(p):o(p))}function a(c,...h){i||(i=!0,t(c,...h))}function o(c){a(null,c)}}const Cr={basename:zj,dirname:Pj,extname:Ij,join:Hj,sep:"/"};function zj(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');zo(e);let i=0,s=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){i=a+1;break}}else s<0&&(o=!0,s=a+1);return s<0?"":e.slice(i,s)}if(t===e)return"";let c=-1,h=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){i=a+1;break}}else c<0&&(o=!0,c=a+1),h>-1&&(e.codePointAt(a)===t.codePointAt(h--)?h<0&&(s=a):(h=-1,s=c));return i===s?s=c:s<0&&(s=e.length),e.slice(i,s)}function Pj(e){if(zo(e),e.length===0)return".";let t=-1,i=e.length,s;for(;--i;)if(e.codePointAt(i)===47){if(s){t=i;break}}else s||(s=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function Ij(e){zo(e);let t=e.length,i=-1,s=0,a=-1,o=0,c;for(;t--;){const h=e.codePointAt(t);if(h===47){if(c){s=t+1;break}continue}i<0&&(c=!0,i=t+1),h===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||i<0||o===0||o===1&&a===i-1&&a===s+1?"":e.slice(a,i)}function Hj(...e){let t=-1,i;for(;++t<e.length;)zo(e[t]),e[t]&&(i=i===void 0?e[t]:i+"/"+e[t]);return i===void 0?".":Uj(i)}function Uj(e){zo(e);const t=e.codePointAt(0)===47;let i=$j(e,!t);return i.length===0&&!t&&(i="."),i.length>0&&e.codePointAt(e.length-1)===47&&(i+="/"),t?"/"+i:i}function $j(e,t){let i="",s=0,a=-1,o=0,c=-1,h,p;for(;++c<=e.length;){if(c<e.length)h=e.codePointAt(c);else{if(h===47)break;h=47}if(h===47){if(!(a===c-1||o===1))if(a!==c-1&&o===2){if(i.length<2||s!==2||i.codePointAt(i.length-1)!==46||i.codePointAt(i.length-2)!==46){if(i.length>2){if(p=i.lastIndexOf("/"),p!==i.length-1){p<0?(i="",s=0):(i=i.slice(0,p),s=i.length-1-i.lastIndexOf("/")),a=c,o=0;continue}}else if(i.length>0){i="",s=0,a=c,o=0;continue}}t&&(i=i.length>0?i+"/..":"..",s=2)}else i.length>0?i+="/"+e.slice(a+1,c):i=e.slice(a+1,c),s=c-a-1;a=c,o=0}else h===46&&o>-1?o++:o=-1}return i}function zo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Fj={cwd:qj};function qj(){return"/"}function jp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Wj(e){if(typeof e=="string")e=new URL(e);else if(!jp(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Gj(e)}function Gj(e){if(e.hostname!==""){const s=new TypeError('File URL host must be "localhost" or empty on darwin');throw s.code="ERR_INVALID_FILE_URL_HOST",s}const t=e.pathname;let i=-1;for(;++i<t.length;)if(t.codePointAt(i)===37&&t.codePointAt(i+1)===50){const s=t.codePointAt(i+2);if(s===70||s===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const bf=["history","path","basename","stem","extname","dirname"];class J0{constructor(t){let i;t?jp(t)?i={path:t}:typeof t=="string"||Yj(t)?i={value:t}:i=t:i={},this.cwd="cwd"in i?"":Fj.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<bf.length;){const o=bf[s];o in i&&i[o]!==void 0&&i[o]!==null&&(this[o]=o==="history"?[...i[o]]:i[o])}let a;for(a in i)bf.includes(a)||(this[a]=i[a])}get basename(){return typeof this.path=="string"?Cr.basename(this.path):void 0}set basename(t){yf(t,"basename"),vf(t,"basename"),this.path=Cr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Cr.dirname(this.path):void 0}set dirname(t){Lv(this.basename,"dirname"),this.path=Cr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Cr.extname(this.path):void 0}set extname(t){if(vf(t,"extname"),Lv(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Cr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){jp(t)&&(t=Wj(t)),yf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Cr.basename(this.path,this.extname):void 0}set stem(t){yf(t,"stem"),vf(t,"stem"),this.path=Cr.join(this.dirname||"",t+(this.extname||""))}fail(t,i,s){const a=this.message(t,i,s);throw a.fatal=!0,a}info(t,i,s){const a=this.message(t,i,s);return a.fatal=void 0,a}message(t,i,s){const a=new an(t,i,s);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function vf(e,t){if(e&&e.includes(Cr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Cr.sep+"`")}function yf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Lv(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Yj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Kj=(function(e){const s=this.constructor.prototype,a=s[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,s),o}),Vj={}.hasOwnProperty;class cm extends Kj{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Lj()}copy(){const t=new cm;let i=-1;for(;++i<this.attachers.length;){const s=this.attachers[i];t.use(...s)}return t.data(_f(!0,{},this.namespace)),t}data(t,i){return typeof t=="string"?arguments.length===2?(Cf("data",this.frozen),this.namespace[t]=i,this):Vj.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Cf("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[i,...s]=this.attachers[this.freezeIndex];if(s[0]===!1)continue;s[0]===!0&&(s[0]=void 0);const a=i.call(t,...s);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const i=nu(t),s=this.parser||this.Parser;return Sf("parse",s),s(String(i),i)}process(t,i){const s=this;return this.freeze(),Sf("process",this.parser||this.Parser),wf("process",this.compiler||this.Compiler),i?a(void 0,i):new Promise(a);function a(o,c){const h=nu(t),p=s.parse(h);s.run(p,h,function(_,x,b){if(_||!x||!b)return f(_);const v=x,y=s.stringify(v,b);Qj(y)?b.value=y:b.result=y,f(_,b)});function f(_,x){_||!x?c(_):o?o(x):i(void 0,x)}}}processSync(t){let i=!1,s;return this.freeze(),Sf("processSync",this.parser||this.Parser),wf("processSync",this.compiler||this.Compiler),this.process(t,a),zv("processSync","process",i),s;function a(o,c){i=!0,Dv(o),s=c}}run(t,i,s){Ov(t),this.freeze();const a=this.transformers;return!s&&typeof i=="function"&&(s=i,i=void 0),s?o(void 0,s):new Promise(o);function o(c,h){const p=nu(i);a.run(t,p,f);function f(_,x,b){const v=x||t;_?h(_):c?c(v):s(void 0,v,b)}}}runSync(t,i){let s=!1,a;return this.run(t,i,o),zv("runSync","run",s),a;function o(c,h){Dv(c),a=h,s=!0}}stringify(t,i){this.freeze();const s=nu(i),a=this.compiler||this.Compiler;return wf("stringify",a),Ov(t),a(t,s)}use(t,...i){const s=this.attachers,a=this.namespace;if(Cf("use",this.frozen),t!=null)if(typeof t=="function")p(t,i);else if(typeof t=="object")Array.isArray(t)?h(t):c(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(f){if(typeof f=="function")p(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[_,...x]=f;p(_,x)}else c(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function c(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");h(f.plugins),f.settings&&(a.settings=_f(!0,a.settings,f.settings))}function h(f){let _=-1;if(f!=null)if(Array.isArray(f))for(;++_<f.length;){const x=f[_];o(x)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function p(f,_){let x=-1,b=-1;for(;++x<s.length;)if(s[x][0]===f){b=x;break}if(b===-1)s.push([f,..._]);else if(_.length>0){let[v,...y]=_;const N=s[b][1];Tp(N)&&Tp(v)&&(v=_f(!0,N,v)),s[b]=[f,v,...y]}}}}const Xj=new cm().freeze();function Sf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function wf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Cf(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Ov(e){if(!Tp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function zv(e,t,i){if(!i)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function nu(e){return Zj(e)?e:new J0(e)}function Zj(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Qj(e){return typeof e=="string"||Jj(e)}function Jj(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const eA="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Pv=[],Iv={allowDangerousHtml:!0},tA=/^(https?|ircs?|mailto|xmpp)$/i,iA=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function eS(e){const t=nA(e),i=rA(e);return sA(t.runSync(t.parse(i),i),e)}function nA(e){const t=e.rehypePlugins||Pv,i=e.remarkPlugins||Pv,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Iv}:Iv;return Xj().use(PT).use(i).use(Mj,s).use(t)}function rA(e){const t=e.children||"",i=new J0;return typeof t=="string"&&(i.value=t),i}function sA(e,t){const i=t.allowedElements,s=t.allowElement,a=t.components,o=t.disallowedElements,c=t.skipHtml,h=t.unwrapDisallowed,p=t.urlTransform||aA;for(const _ of iA)Object.hasOwn(t,_.from)&&(""+_.from+(_.to?"use `"+_.to+"` instead":"remove it")+eA+_.id,void 0);return om(e,f),yN(e,{Fragment:d.Fragment,components:a,ignoreInvalidStyle:!0,jsx:d.jsx,jsxs:d.jsxs,passKeys:!0,passNode:!0});function f(_,x,b){if(_.type==="raw"&&b&&typeof x=="number")return c?b.children.splice(x,1):b.children[x]={type:"text",value:_.value},x;if(_.type==="element"){let v;for(v in pf)if(Object.hasOwn(pf,v)&&Object.hasOwn(_.properties,v)){const y=_.properties[v],N=pf[v];(N===null||N.includes(_.tagName))&&(_.properties[v]=p(String(y||""),v,_))}}if(_.type==="element"){let v=i?!i.includes(_.tagName):o?o.includes(_.tagName):!1;if(!v&&s&&typeof x=="number"&&(v=!s(_,x,b)),v&&b&&typeof x=="number")return h&&_.children?b.children.splice(x,1,..._.children):b.children.splice(x,1),x}}}function aA(e){const t=e.indexOf(":"),i=e.indexOf("?"),s=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||i!==-1&&t>i||s!==-1&&t>s||tA.test(e.slice(0,t))?e:""}function lA(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function tS(e,t,i){const a=Uu((i||{}).ignore||[]),o=oA(t);let c=-1;for(;++c<o.length;)Q0(e,"text",h);function h(f,_){let x=-1,b;for(;++x<_.length;){const v=_[x],y=b?b.children:void 0;if(a(v,y?y.indexOf(v):void 0,b))return;b=v}if(b)return p(f,_)}function p(f,_){const x=_[_.length-1],b=o[c][0],v=o[c][1];let y=0;const j=x.children.indexOf(f);let E=!1,z=[];b.lastIndex=0;let O=b.exec(f.value);for(;O;){const W=O.index,q={index:O.index,input:O.input,stack:[..._,f]};let D=v(...O,q);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?b.lastIndex=W+1:(y!==W&&z.push({type:"text",value:f.value.slice(y,W)}),Array.isArray(D)?z.push(...D):D&&z.push(D),y=W+O[0].length,E=!0),!b.global)break;O=b.exec(f.value)}return E?(y<f.value.length&&z.push({type:"text",value:f.value.slice(y)}),x.children.splice(j,1,...z)):z=[f],j+z.length}}function oA(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const i=!e[0]||Array.isArray(e[0])?e:[e];let s=-1;for(;++s<i.length;){const a=i[s];t.push([cA(a[0]),uA(a[1])])}return t}function cA(e){return typeof e=="string"?new RegExp(lA(e),"g"):e}function uA(e){return typeof e=="function"?e:function(){return e}}function hA(e){tS(e,[/\r?\n|\r/g,dA])}function dA(){return{type:"break"}}function iS(){return function(e){hA(e)}}function Hv(e,t){const i=String(e);if(typeof t!="string")throw new TypeError("Expected character");let s=0,a=i.indexOf(t);for(;a!==-1;)s++,a=i.indexOf(t,a+t.length);return s}const kf="phrasing",Ef=["autolink","link","image","label"];function fA(){return{transforms:[vA],enter:{literalAutolink:mA,literalAutolinkEmail:Nf,literalAutolinkHttp:Nf,literalAutolinkWww:Nf},exit:{literalAutolink:bA,literalAutolinkEmail:_A,literalAutolinkHttp:gA,literalAutolinkWww:xA}}}function pA(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:kf,notInConstruct:Ef},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:kf,notInConstruct:Ef},{character:":",before:"[ps]",after:"\\/",inConstruct:kf,notInConstruct:Ef}]}}function mA(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Nf(e){this.config.enter.autolinkProtocol.call(this,e)}function gA(e){this.config.exit.autolinkProtocol.call(this,e)}function xA(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function _A(e){this.config.exit.autolinkEmail.call(this,e)}function bA(e){this.exit(e)}function vA(e){tS(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,yA],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),SA]],{ignore:["link","linkReference"]})}function yA(e,t,i,s,a){let o="";if(!nS(a)||(/^w/i.test(t)&&(i=t+i,t="",o="http://"),!wA(i)))return!1;const c=CA(i+s);if(!c[0])return!1;const h={type:"link",title:null,url:o+t+c[0],children:[{type:"text",value:t+c[0]}]};return c[1]?[h,{type:"text",value:c[1]}]:h}function SA(e,t,i,s){return!nS(s,!0)||/[-\d_]$/.test(i)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+i,children:[{type:"text",value:t+"@"+i}]}}function wA(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function CA(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let i=t[0],s=i.indexOf(")");const a=Hv(e,"(");let o=Hv(e,")");for(;s!==-1&&a>o;)e+=i.slice(0,s+1),i=i.slice(s+1),s=i.indexOf(")"),o++;return[e,i]}function nS(e,t){const i=e.input.charCodeAt(e.index-1);return(e.index===0||oa(i)||Pu(i))&&(!t||i!==47)}rS.peek=DA;function kA(){this.buffer()}function EA(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function NA(){this.buffer()}function TA(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function jA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=gr(this.sliceSerialize(e)).toLowerCase(),i.label=t}function AA(e){this.exit(e)}function RA(e){const t=this.resume(),i=this.stack[this.stack.length-1];i.type,i.identifier=gr(this.sliceSerialize(e)).toLowerCase(),i.label=t}function MA(e){this.exit(e)}function DA(){return"["}function rS(e,t,i,s){const a=i.createTracker(s);let o=a.move("[^");const c=i.enter("footnoteReference"),h=i.enter("reference");return o+=a.move(i.safe(i.associationId(e),{after:"]",before:o})),h(),c(),o+=a.move("]"),o}function BA(){return{enter:{gfmFootnoteCallString:kA,gfmFootnoteCall:EA,gfmFootnoteDefinitionLabelString:NA,gfmFootnoteDefinition:TA},exit:{gfmFootnoteCallString:jA,gfmFootnoteCall:AA,gfmFootnoteDefinitionLabelString:RA,gfmFootnoteDefinition:MA}}}function LA(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:i,footnoteReference:rS},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function i(s,a,o,c){const h=o.createTracker(c);let p=h.move("[^");const f=o.enter("footnoteDefinition"),_=o.enter("label");return p+=h.move(o.safe(o.associationId(s),{before:p,after:"]"})),_(),p+=h.move("]:"),s.children&&s.children.length>0&&(h.shift(4),p+=h.move((t?`
115
+ `:" ")+o.indentLines(o.containerFlow(s,h.current()),t?sS:OA))),f(),p}}function OA(e,t,i){return t===0?e:sS(e,t,i)}function sS(e,t,i){return(i?"":" ")+e}const zA=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];aS.peek=$A;function PA(){return{canContainEols:["delete"],enter:{strikethrough:HA},exit:{strikethrough:UA}}}function IA(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:zA}],handlers:{delete:aS}}}function HA(e){this.enter({type:"delete",children:[]},e)}function UA(e){this.exit(e)}function aS(e,t,i,s){const a=i.createTracker(s),o=i.enter("strikethrough");let c=a.move("~~");return c+=i.containerPhrasing(e,{...a.current(),before:c,after:"~"}),c+=a.move("~~"),o(),c}function $A(){return"~"}function FA(e){return e.length}function qA(e,t){const i=t||{},s=(i.align||[]).concat(),a=i.stringLength||FA,o=[],c=[],h=[],p=[];let f=0,_=-1;for(;++_<e.length;){const N=[],j=[];let E=-1;for(e[_].length>f&&(f=e[_].length);++E<e[_].length;){const z=WA(e[_][E]);if(i.alignDelimiters!==!1){const O=a(z);j[E]=O,(p[E]===void 0||O>p[E])&&(p[E]=O)}N.push(z)}c[_]=N,h[_]=j}let x=-1;if(typeof s=="object"&&"length"in s)for(;++x<f;)o[x]=Uv(s[x]);else{const N=Uv(s);for(;++x<f;)o[x]=N}x=-1;const b=[],v=[];for(;++x<f;){const N=o[x];let j="",E="";N===99?(j=":",E=":"):N===108?j=":":N===114&&(E=":");let z=i.alignDelimiters===!1?1:Math.max(1,p[x]-j.length-E.length);const O=j+"-".repeat(z)+E;i.alignDelimiters!==!1&&(z=j.length+z+E.length,z>p[x]&&(p[x]=z),v[x]=z),b[x]=O}c.splice(1,0,b),h.splice(1,0,v),_=-1;const y=[];for(;++_<c.length;){const N=c[_],j=h[_];x=-1;const E=[];for(;++x<f;){const z=N[x]||"";let O="",W="";if(i.alignDelimiters!==!1){const q=p[x]-(j[x]||0),D=o[x];D===114?O=" ".repeat(q):D===99?q%2?(O=" ".repeat(q/2+.5),W=" ".repeat(q/2-.5)):(O=" ".repeat(q/2),W=O):W=" ".repeat(q)}i.delimiterStart!==!1&&!x&&E.push("|"),i.padding!==!1&&!(i.alignDelimiters===!1&&z==="")&&(i.delimiterStart!==!1||x)&&E.push(" "),i.alignDelimiters!==!1&&E.push(O),E.push(z),i.alignDelimiters!==!1&&E.push(W),i.padding!==!1&&E.push(" "),(i.delimiterEnd!==!1||x!==f-1)&&E.push("|")}y.push(i.delimiterEnd===!1?E.join("").replace(/ +$/,""):E.join(""))}return y.join(`
116
+ `)}function WA(e){return e==null?"":String(e)}function Uv(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function GA(e,t,i,s){const a=i.enter("blockquote"),o=i.createTracker(s);o.move("> "),o.shift(2);const c=i.indentLines(i.containerFlow(e,o.current()),YA);return a(),c}function YA(e,t,i){return">"+(i?"":" ")+e}function KA(e,t){return $v(e,t.inConstruct,!0)&&!$v(e,t.notInConstruct,!1)}function $v(e,t,i){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return i;let s=-1;for(;++s<t.length;)if(e.includes(t[s]))return!0;return!1}function Fv(e,t,i,s){let a=-1;for(;++a<i.unsafe.length;)if(i.unsafe[a].character===`
117
+ `&&KA(i.stack,i.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
118
+ `}function VA(e,t){const i=String(e);let s=i.indexOf(t),a=s,o=0,c=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;s!==-1;)s===a?++o>c&&(c=o):o=1,a=s+t.length,s=i.indexOf(t,a);return c}function XA(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function ZA(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function QA(e,t,i,s){const a=ZA(i),o=e.value||"",c=a==="`"?"GraveAccent":"Tilde";if(XA(e,i)){const x=i.enter("codeIndented"),b=i.indentLines(o,JA);return x(),b}const h=i.createTracker(s),p=a.repeat(Math.max(VA(o,a)+1,3)),f=i.enter("codeFenced");let _=h.move(p);if(e.lang){const x=i.enter(`codeFencedLang${c}`);_+=h.move(i.safe(e.lang,{before:_,after:" ",encode:["`"],...h.current()})),x()}if(e.lang&&e.meta){const x=i.enter(`codeFencedMeta${c}`);_+=h.move(" "),_+=h.move(i.safe(e.meta,{before:_,after:`
119
+ `,encode:["`"],...h.current()})),x()}return _+=h.move(`
120
+ `),o&&(_+=h.move(o+`
121
+ `)),_+=h.move(p),f(),_}function JA(e,t,i){return(i?"":" ")+e}function um(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function eR(e,t,i,s){const a=um(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("definition");let h=i.enter("label");const p=i.createTracker(s);let f=p.move("[");return f+=p.move(i.safe(i.associationId(e),{before:f,after:"]",...p.current()})),f+=p.move("]: "),h(),!e.url||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),f+=p.move("<"),f+=p.move(i.safe(e.url,{before:f,after:">",...p.current()})),f+=p.move(">")):(h=i.enter("destinationRaw"),f+=p.move(i.safe(e.url,{before:f,after:e.title?" ":`
122
+ `,...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),f+=p.move(" "+a),f+=p.move(i.safe(e.title,{before:f,after:a,...p.current()})),f+=p.move(a),h()),c(),f}function tR(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function jo(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ru(e,t,i){const s=al(e),a=al(t);return s===void 0?a===void 0?i==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:s===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}lS.peek=iR;function lS(e,t,i,s){const a=tR(i),o=i.enter("emphasis"),c=i.createTracker(s),h=c.move(a);let p=c.move(i.containerPhrasing(e,{after:a,before:h,...c.current()}));const f=p.charCodeAt(0),_=Ru(s.before.charCodeAt(s.before.length-1),f,a);_.inside&&(p=jo(f)+p.slice(1));const x=p.charCodeAt(p.length-1),b=Ru(s.after.charCodeAt(0),x,a);b.inside&&(p=p.slice(0,-1)+jo(x));const v=c.move(a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:_.outside},h+p+v}function iR(e,t,i){return i.options.emphasis||"*"}function nR(e,t){let i=!1;return om(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return i=!0,Ep}),!!((!e.depth||e.depth<3)&&tm(e)&&(t.options.setext||i))}function rR(e,t,i,s){const a=Math.max(Math.min(6,e.depth||1),1),o=i.createTracker(s);if(nR(e,i)){const _=i.enter("headingSetext"),x=i.enter("phrasing"),b=i.containerPhrasing(e,{...o.current(),before:`
123
+ `,after:`
124
+ `});return x(),_(),b+`
125
+ `+(a===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(`
126
+ `))+1))}const c="#".repeat(a),h=i.enter("headingAtx"),p=i.enter("phrasing");o.move(c+" ");let f=i.containerPhrasing(e,{before:"# ",after:`
127
+ `,...o.current()});return/^[\t ]/.test(f)&&(f=jo(f.charCodeAt(0))+f.slice(1)),f=f?c+" "+f:c,i.options.closeAtx&&(f+=" "+c),p(),h(),f}oS.peek=sR;function oS(e){return e.value||""}function sR(){return"<"}cS.peek=aR;function cS(e,t,i,s){const a=um(i),o=a==='"'?"Quote":"Apostrophe",c=i.enter("image");let h=i.enter("label");const p=i.createTracker(s);let f=p.move("![");return f+=p.move(i.safe(e.alt,{before:f,after:"]",...p.current()})),f+=p.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=i.enter("destinationLiteral"),f+=p.move("<"),f+=p.move(i.safe(e.url,{before:f,after:">",...p.current()})),f+=p.move(">")):(h=i.enter("destinationRaw"),f+=p.move(i.safe(e.url,{before:f,after:e.title?" ":")",...p.current()}))),h(),e.title&&(h=i.enter(`title${o}`),f+=p.move(" "+a),f+=p.move(i.safe(e.title,{before:f,after:a,...p.current()})),f+=p.move(a),h()),f+=p.move(")"),c(),f}function aR(){return"!"}uS.peek=lR;function uS(e,t,i,s){const a=e.referenceType,o=i.enter("imageReference");let c=i.enter("label");const h=i.createTracker(s);let p=h.move("![");const f=i.safe(e.alt,{before:p,after:"]",...h.current()});p+=h.move(f+"]["),c();const _=i.stack;i.stack=[],c=i.enter("reference");const x=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=_,o(),a==="full"||!f||f!==x?p+=h.move(x+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function lR(){return"!"}hS.peek=oR;function hS(e,t,i){let s=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(s);)a+="`";for(/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^`|`$/.test(s))&&(s=" "+s+" ");++o<i.unsafe.length;){const c=i.unsafe[o],h=i.compilePattern(c);let p;if(c.atBreak)for(;p=h.exec(s);){let f=p.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(p.index+1)}}return a+s+a}function oR(){return"`"}function dS(e,t){const i=tm(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(i===e.url||"mailto:"+i===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}fS.peek=cR;function fS(e,t,i,s){const a=um(i),o=a==='"'?"Quote":"Apostrophe",c=i.createTracker(s);let h,p;if(dS(e,i)){const _=i.stack;i.stack=[],h=i.enter("autolink");let x=c.move("<");return x+=c.move(i.containerPhrasing(e,{before:x,after:">",...c.current()})),x+=c.move(">"),h(),i.stack=_,x}h=i.enter("link"),p=i.enter("label");let f=c.move("[");return f+=c.move(i.containerPhrasing(e,{before:f,after:"](",...c.current()})),f+=c.move("]("),p(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(p=i.enter("destinationLiteral"),f+=c.move("<"),f+=c.move(i.safe(e.url,{before:f,after:">",...c.current()})),f+=c.move(">")):(p=i.enter("destinationRaw"),f+=c.move(i.safe(e.url,{before:f,after:e.title?" ":")",...c.current()}))),p(),e.title&&(p=i.enter(`title${o}`),f+=c.move(" "+a),f+=c.move(i.safe(e.title,{before:f,after:a,...c.current()})),f+=c.move(a),p()),f+=c.move(")"),h(),f}function cR(e,t,i){return dS(e,i)?"<":"["}pS.peek=uR;function pS(e,t,i,s){const a=e.referenceType,o=i.enter("linkReference");let c=i.enter("label");const h=i.createTracker(s);let p=h.move("[");const f=i.containerPhrasing(e,{before:p,after:"]",...h.current()});p+=h.move(f+"]["),c();const _=i.stack;i.stack=[],c=i.enter("reference");const x=i.safe(i.associationId(e),{before:p,after:"]",...h.current()});return c(),i.stack=_,o(),a==="full"||!f||f!==x?p+=h.move(x+"]"):a==="shortcut"?p=p.slice(0,-1):p+=h.move("]"),p}function uR(){return"["}function hm(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function hR(e){const t=hm(e),i=e.options.bulletOther;if(!i)return t==="*"?"-":"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(i===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+i+"`) to be different");return i}function dR(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function mS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function fR(e,t,i,s){const a=i.enter("list"),o=i.bulletCurrent;let c=e.ordered?dR(i):hm(i);const h=e.ordered?c==="."?")":".":hR(i);let p=t&&i.bulletLastUsed?c===i.bulletLastUsed:!1;if(!e.ordered){const _=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&_&&(!_.children||!_.children[0])&&i.stack[i.stack.length-1]==="list"&&i.stack[i.stack.length-2]==="listItem"&&i.stack[i.stack.length-3]==="list"&&i.stack[i.stack.length-4]==="listItem"&&i.indexStack[i.indexStack.length-1]===0&&i.indexStack[i.indexStack.length-2]===0&&i.indexStack[i.indexStack.length-3]===0&&(p=!0),mS(i)===c&&_){let x=-1;for(;++x<e.children.length;){const b=e.children[x];if(b&&b.type==="listItem"&&b.children&&b.children[0]&&b.children[0].type==="thematicBreak"){p=!0;break}}}}p&&(c=h),i.bulletCurrent=c;const f=i.containerFlow(e,s);return i.bulletLastUsed=c,i.bulletCurrent=o,a(),f}function pR(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function mR(e,t,i,s){const a=pR(i);let o=i.bulletCurrent||hm(i);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(i.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let c=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const h=i.createTracker(s);h.move(o+" ".repeat(c-o.length)),h.shift(c);const p=i.enter("listItem"),f=i.indentLines(i.containerFlow(e,h.current()),_);return p(),f;function _(x,b,v){return b?(v?"":" ".repeat(c))+x:(v?o:o+" ".repeat(c-o.length))+x}}function gR(e,t,i,s){const a=i.enter("paragraph"),o=i.enter("phrasing"),c=i.containerPhrasing(e,s);return o(),a(),c}const xR=Uu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function _R(e,t,i,s){return(e.children.some(function(c){return xR(c)})?i.containerPhrasing:i.containerFlow).call(i,e,s)}function bR(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}gS.peek=vR;function gS(e,t,i,s){const a=bR(i),o=i.enter("strong"),c=i.createTracker(s),h=c.move(a+a);let p=c.move(i.containerPhrasing(e,{after:a,before:h,...c.current()}));const f=p.charCodeAt(0),_=Ru(s.before.charCodeAt(s.before.length-1),f,a);_.inside&&(p=jo(f)+p.slice(1));const x=p.charCodeAt(p.length-1),b=Ru(s.after.charCodeAt(0),x,a);b.inside&&(p=p.slice(0,-1)+jo(x));const v=c.move(a+a);return o(),i.attentionEncodeSurroundingInfo={after:b.outside,before:_.outside},h+p+v}function vR(e,t,i){return i.options.strong||"*"}function yR(e,t,i,s){return i.safe(e.value,s)}function SR(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function wR(e,t,i){const s=(mS(i)+(i.options.ruleSpaces?" ":"")).repeat(SR(i));return i.options.ruleSpaces?s.slice(0,-1):s}const xS={blockquote:GA,break:Fv,code:QA,definition:eR,emphasis:lS,hardBreak:Fv,heading:rR,html:oS,image:cS,imageReference:uS,inlineCode:hS,link:fS,linkReference:pS,list:fR,listItem:mR,paragraph:gR,root:_R,strong:gS,text:yR,thematicBreak:wR};function CR(){return{enter:{table:kR,tableData:qv,tableHeader:qv,tableRow:NR},exit:{codeText:TR,table:ER,tableData:Tf,tableHeader:Tf,tableRow:Tf}}}function kR(e){const t=e._align;this.enter({type:"table",align:t.map(function(i){return i==="none"?null:i}),children:[]},e),this.data.inTable=!0}function ER(e){this.exit(e),this.data.inTable=void 0}function NR(e){this.enter({type:"tableRow",children:[]},e)}function Tf(e){this.exit(e)}function qv(e){this.enter({type:"tableCell",children:[]},e)}function TR(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,jR));const i=this.stack[this.stack.length-1];i.type,i.value=t,this.exit(e)}function jR(e,t){return t==="|"?t:e}function AR(e){const t=e||{},i=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,o=i?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
128
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:c,tableCell:p,tableRow:h}};function c(v,y,N,j){return f(_(v,N,j),v.align)}function h(v,y,N,j){const E=x(v,N,j),z=f([E]);return z.slice(0,z.indexOf(`
129
+ `))}function p(v,y,N,j){const E=N.enter("tableCell"),z=N.enter("phrasing"),O=N.containerPhrasing(v,{...j,before:o,after:o});return z(),E(),O}function f(v,y){return qA(v,{align:y,alignDelimiters:s,padding:i,stringLength:a})}function _(v,y,N){const j=v.children;let E=-1;const z=[],O=y.enter("table");for(;++E<j.length;)z[E]=x(j[E],y,N);return O(),z}function x(v,y,N){const j=v.children;let E=-1;const z=[],O=y.enter("tableRow");for(;++E<j.length;)z[E]=p(j[E],v,y,N);return O(),z}function b(v,y,N){let j=xS.inlineCode(v,y,N);return N.stack.includes("tableCell")&&(j=j.replace(/\|/g,"\\$&")),j}}function RR(){return{exit:{taskListCheckValueChecked:Wv,taskListCheckValueUnchecked:Wv,paragraph:DR}}}function MR(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:BR}}}function Wv(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function DR(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const i=this.stack[this.stack.length-1];i.type;const s=i.children[0];if(s&&s.type==="text"){const a=t.children;let o=-1,c;for(;++o<a.length;){const h=a[o];if(h.type==="paragraph"){c=h;break}}c===i&&(s.value=s.value.slice(1),s.value.length===0?i.children.shift():i.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,i.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function BR(e,t,i,s){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",h=i.createTracker(s);o&&h.move(c);let p=xS.listItem(e,t,i,{...s,...h.current()});return o&&(p=p.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),p;function f(_){return _+c}}function LR(){return[fA(),BA(),PA(),CR(),RR()]}function OR(e){return{extensions:[pA(),LA(e),IA(),AR(e),MR()]}}const zR={tokenize:FR,partial:!0},_S={tokenize:qR,partial:!0},bS={tokenize:WR,partial:!0},vS={tokenize:GR,partial:!0},PR={tokenize:YR,partial:!0},yS={name:"wwwAutolink",tokenize:UR,previous:wS},SS={name:"protocolAutolink",tokenize:$R,previous:CS},es={name:"emailAutolink",tokenize:HR,previous:kS},jr={};function IR(){return{text:jr}}let ea=48;for(;ea<123;)jr[ea]=es,ea++,ea===58?ea=65:ea===91&&(ea=97);jr[43]=es;jr[45]=es;jr[46]=es;jr[95]=es;jr[72]=[es,SS];jr[104]=[es,SS];jr[87]=[es,yS];jr[119]=[es,yS];function HR(e,t,i){const s=this;let a,o;return c;function c(x){return!Ap(x)||!kS.call(s,s.previous)||dm(s.events)?i(x):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),h(x))}function h(x){return Ap(x)?(e.consume(x),h):x===64?(e.consume(x),p):i(x)}function p(x){return x===46?e.check(PR,_,f)(x):x===45||x===95||sn(x)?(o=!0,e.consume(x),p):_(x)}function f(x){return e.consume(x),a=!0,p}function _(x){return o&&a&&pn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(x)):i(x)}}function UR(e,t,i){const s=this;return a;function a(c){return c!==87&&c!==119||!wS.call(s,s.previous)||dm(s.events)?i(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(zR,e.attempt(_S,e.attempt(bS,o),i),i)(c))}function o(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function $R(e,t,i){const s=this;let a="",o=!1;return c;function c(x){return(x===72||x===104)&&CS.call(s,s.previous)&&!dm(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(x),e.consume(x),h):i(x)}function h(x){if(pn(x)&&a.length<5)return a+=String.fromCodePoint(x),e.consume(x),h;if(x===58){const b=a.toLowerCase();if(b==="http"||b==="https")return e.consume(x),p}return i(x)}function p(x){return x===47?(e.consume(x),o?f:(o=!0,p)):i(x)}function f(x){return x===null||ju(x)||Gt(x)||oa(x)||Pu(x)?i(x):e.attempt(_S,e.attempt(bS,_),i)(x)}function _(x){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(x)}}function FR(e,t,i){let s=0;return a;function a(c){return(c===87||c===119)&&s<3?(s++,e.consume(c),a):c===46&&s===3?(e.consume(c),o):i(c)}function o(c){return c===null?i(c):t(c)}}function qR(e,t,i){let s,a,o;return c;function c(f){return f===46||f===95?e.check(vS,p,h)(f):f===null||Gt(f)||oa(f)||f!==45&&Pu(f)?p(f):(o=!0,e.consume(f),c)}function h(f){return f===95?s=!0:(a=s,s=void 0),e.consume(f),c}function p(f){return a||s||!o?i(f):t(f)}}function WR(e,t){let i=0,s=0;return a;function a(c){return c===40?(i++,e.consume(c),a):c===41&&s<i?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(vS,t,o)(c):c===null||Gt(c)||oa(c)?t(c):(e.consume(c),a)}function o(c){return c===41&&s++,e.consume(c),a}}function GR(e,t,i){return s;function s(h){return h===33||h===34||h===39||h===41||h===42||h===44||h===46||h===58||h===59||h===63||h===95||h===126?(e.consume(h),s):h===38?(e.consume(h),o):h===93?(e.consume(h),a):h===60||h===null||Gt(h)||oa(h)?t(h):i(h)}function a(h){return h===null||h===40||h===91||Gt(h)||oa(h)?t(h):s(h)}function o(h){return pn(h)?c(h):i(h)}function c(h){return h===59?(e.consume(h),s):pn(h)?(e.consume(h),c):i(h)}}function YR(e,t,i){return s;function s(o){return e.consume(o),a}function a(o){return sn(o)?i(o):t(o)}}function wS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Gt(e)}function CS(e){return!pn(e)}function kS(e){return!(e===47||Ap(e))}function Ap(e){return e===43||e===45||e===46||e===95||sn(e)}function dm(e){let t=e.length,i=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){i=!0;break}if(s._gfmAutolinkLiteralWalkedInto){i=!1;break}}return e.length>0&&!i&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),i}const KR={tokenize:i3,partial:!0};function VR(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:JR,continuation:{tokenize:e3},exit:t3}},text:{91:{name:"gfmFootnoteCall",tokenize:QR},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:XR,resolveTo:ZR}}}}function XR(e,t,i){const s=this;let a=s.events.length;const o=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let c;for(;a--;){const p=s.events[a][1];if(p.type==="labelImage"){c=p;break}if(p.type==="gfmFootnoteCall"||p.type==="labelLink"||p.type==="label"||p.type==="image"||p.type==="link")break}return h;function h(p){if(!c||!c._balanced)return i(p);const f=gr(s.sliceSerialize({start:c.end,end:s.now()}));return f.codePointAt(0)!==94||!o.includes(f.slice(1))?i(p):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),t(p))}}function ZR(e,t){let i=e.length;for(;i--;)if(e[i][1].type==="labelImage"&&e[i][0]==="enter"){e[i][1];break}e[i+1][1].type="data",e[i+3][1].type="gfmFootnoteCallLabelMarker";const s={type:"gfmFootnoteCall",start:Object.assign({},e[i+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[i+3][1].end),end:Object.assign({},e[i+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},h=[e[i+1],e[i+2],["enter",s,t],e[i+3],e[i+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",c,t],["exit",c,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(i,e.length-i+1,...h),e}function QR(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o=0,c;return h;function h(x){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),p}function p(x){return x!==94?i(x):(e.enter("gfmFootnoteCallMarker"),e.consume(x),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(x){if(o>999||x===93&&!c||x===null||x===91||Gt(x))return i(x);if(x===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(gr(s.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):i(x)}return Gt(x)||(c=!0),o++,e.consume(x),x===92?_:f}function _(x){return x===91||x===92||x===93?(e.consume(x),o++,f):f(x)}}function JR(e,t,i){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o,c=0,h;return p;function p(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",_):i(y)}function _(y){if(c>999||y===93&&!h||y===null||y===91||Gt(y))return i(y);if(y===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return o=gr(s.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Gt(y)||(h=!0),c++,e.consume(y),y===92?x:_}function x(y){return y===91||y===92||y===93?(e.consume(y),c++,_):_(y)}function b(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),a.includes(o)||a.push(o),Nt(e,v,"gfmFootnoteDefinitionWhitespace")):i(y)}function v(y){return t(y)}}function e3(e,t,i){return e.check(Oo,t,e.attempt(KR,t,i))}function t3(e){e.exit("gfmFootnoteDefinition")}function i3(e,t,i){const s=this;return Nt(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const c=s.events[s.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(o):i(o)}}function n3(e){let i=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:o,resolveAll:a};return i==null&&(i=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function a(c,h){let p=-1;for(;++p<c.length;)if(c[p][0]==="enter"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._close){let f=p;for(;f--;)if(c[f][0]==="exit"&&c[f][1].type==="strikethroughSequenceTemporary"&&c[f][1]._open&&c[p][1].end.offset-c[p][1].start.offset===c[f][1].end.offset-c[f][1].start.offset){c[p][1].type="strikethroughSequence",c[f][1].type="strikethroughSequence";const _={type:"strikethrough",start:Object.assign({},c[f][1].start),end:Object.assign({},c[p][1].end)},x={type:"strikethroughText",start:Object.assign({},c[f][1].end),end:Object.assign({},c[p][1].start)},b=[["enter",_,h],["enter",c[f][1],h],["exit",c[f][1],h],["enter",x,h]],v=h.parser.constructs.insideSpan.null;v&&$n(b,b.length,0,Iu(v,c.slice(f+1,p),h)),$n(b,b.length,0,[["exit",x,h],["enter",c[p][1],h],["exit",c[p][1],h],["exit",_,h]]),$n(c,f-1,p-f+3,b),p=f+b.length-2;break}}for(p=-1;++p<c.length;)c[p][1].type==="strikethroughSequenceTemporary"&&(c[p][1].type="data");return c}function o(c,h,p){const f=this.previous,_=this.events;let x=0;return b;function b(y){return f===126&&_[_.length-1][1].type!=="characterEscape"?p(y):(c.enter("strikethroughSequenceTemporary"),v(y))}function v(y){const N=al(f);if(y===126)return x>1?p(y):(c.consume(y),x++,v);if(x<2&&!i)return p(y);const j=c.exit("strikethroughSequenceTemporary"),E=al(y);return j._open=!E||E===2&&!!N,j._close=!N||N===2&&!!E,h(y)}}}class r3{constructor(){this.map=[]}add(t,i,s){s3(this,t,i,s)}consume(t){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let i=this.map.length;const s=[];for(;i>0;)i-=1,s.push(t.slice(this.map[i][0]+this.map[i][1]),this.map[i][2]),t.length=this.map[i][0];s.push(t.slice()),t.length=0;let a=s.pop();for(;a;){for(const o of a)t.push(o);a=s.pop()}this.map.length=0}}function s3(e,t,i,s){let a=0;if(!(i===0&&s.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=i,e.map[a][2].push(...s);return}a+=1}e.map.push([t,i,s])}}function a3(e,t){let i=!1;const s=[];for(;t<e.length;){const a=e[t];if(i){if(a[0]==="enter")a[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=s.length-1;s[o]=s[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(i=!0);t+=1}return s}function l3(){return{flow:{null:{name:"table",tokenize:o3,resolveAll:c3}}}}function o3(e,t,i){const s=this;let a=0,o=0,c;return h;function h(P){let ae=s.events.length-1;for(;ae>-1;){const Q=s.events[ae][1].type;if(Q==="lineEnding"||Q==="linePrefix")ae--;else break}const G=ae>-1?s.events[ae][1].type:null,Y=G==="tableHead"||G==="tableRow"?D:p;return Y===D&&s.parser.lazy[s.now().line]?i(P):Y(P)}function p(P){return e.enter("tableHead"),e.enter("tableRow"),f(P)}function f(P){return P===124||(c=!0,o+=1),_(P)}function _(P){return P===null?i(P):Fe(P)?o>1?(o=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),v):i(P):_t(P)?Nt(e,_,"whitespace")(P):(o+=1,c&&(c=!1,a+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),c=!0,_):(e.enter("data"),x(P)))}function x(P){return P===null||P===124||Gt(P)?(e.exit("data"),_(P)):(e.consume(P),P===92?b:x)}function b(P){return P===92||P===124?(e.consume(P),x):x(P)}function v(P){return s.interrupt=!1,s.parser.lazy[s.now().line]?i(P):(e.enter("tableDelimiterRow"),c=!1,_t(P)?Nt(e,y,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):y(P))}function y(P){return P===45||P===58?j(P):P===124?(c=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),N):q(P)}function N(P){return _t(P)?Nt(e,j,"whitespace")(P):j(P)}function j(P){return P===58?(o+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),E):P===45?(o+=1,E(P)):P===null||Fe(P)?W(P):q(P)}function E(P){return P===45?(e.enter("tableDelimiterFiller"),z(P)):q(P)}function z(P){return P===45?(e.consume(P),z):P===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),O):(e.exit("tableDelimiterFiller"),O(P))}function O(P){return _t(P)?Nt(e,W,"whitespace")(P):W(P)}function W(P){return P===124?y(P):P===null||Fe(P)?!c||a!==o?q(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):q(P)}function q(P){return i(P)}function D(P){return e.enter("tableRow"),te(P)}function te(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),te):P===null||Fe(P)?(e.exit("tableRow"),t(P)):_t(P)?Nt(e,te,"whitespace")(P):(e.enter("data"),de(P))}function de(P){return P===null||P===124||Gt(P)?(e.exit("data"),te(P)):(e.consume(P),P===92?_e:de)}function _e(P){return P===92||P===124?(e.consume(P),de):de(P)}}function c3(e,t){let i=-1,s=!0,a=0,o=[0,0,0,0],c=[0,0,0,0],h=!1,p=0,f,_,x;const b=new r3;for(;++i<e.length;){const v=e[i],y=v[1];v[0]==="enter"?y.type==="tableHead"?(h=!1,p!==0&&(Gv(b,t,p,f,_),_=void 0,p=0),f={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},b.add(i,0,[["enter",f,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(s=!0,x=void 0,o=[0,0,0,0],c=[0,i+1,0,0],h&&(h=!1,_={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},b.add(i,0,[["enter",_,t]])),a=y.type==="tableDelimiterRow"?2:_?3:1):a&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(s=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],x=ru(b,t,o,a,void 0,x),o=[0,0,0,0]),c[2]=i)):y.type==="tableCellDivider"&&(s?s=!1:(o[1]!==0&&(c[0]=c[1],x=ru(b,t,o,a,void 0,x)),o=c,c=[o[1],i,0,0])):y.type==="tableHead"?(h=!0,p=i):y.type==="tableRow"||y.type==="tableDelimiterRow"?(p=i,o[1]!==0?(c[0]=c[1],x=ru(b,t,o,a,i,x)):c[1]!==0&&(x=ru(b,t,c,a,i,x)),a=0):a&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(c[3]=i)}for(p!==0&&Gv(b,t,p,f,_),b.consume(t.events),i=-1;++i<t.events.length;){const v=t.events[i];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=a3(t.events,i))}return e}function ru(e,t,i,s,a,o){const c=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",h="tableContent";i[0]!==0&&(o.end=Object.assign({},el(t.events,i[0])),e.add(i[0],0,[["exit",o,t]]));const p=el(t.events,i[1]);if(o={type:c,start:Object.assign({},p),end:Object.assign({},p)},e.add(i[1],0,[["enter",o,t]]),i[2]!==0){const f=el(t.events,i[2]),_=el(t.events,i[3]),x={type:h,start:Object.assign({},f),end:Object.assign({},_)};if(e.add(i[2],0,[["enter",x,t]]),s!==2){const b=t.events[i[2]],v=t.events[i[3]];if(b[1].end=Object.assign({},v[1].end),b[1].type="chunkText",b[1].contentType="text",i[3]>i[2]+1){const y=i[2]+1,N=i[3]-i[2]-1;e.add(y,N,[])}}e.add(i[3]+1,0,[["exit",x,t]])}return a!==void 0&&(o.end=Object.assign({},el(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function Gv(e,t,i,s,a){const o=[],c=el(t.events,i);a&&(a.end=Object.assign({},c),o.push(["exit",a,t])),s.end=Object.assign({},c),o.push(["exit",s,t]),e.add(i+1,0,o)}function el(e,t){const i=e[t],s=i[0]==="enter"?"start":"end";return i[1][s]}const u3={name:"tasklistCheck",tokenize:d3};function h3(){return{text:{91:u3}}}function d3(e,t,i){const s=this;return a;function a(p){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?i(p):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),o)}function o(p){return Gt(p)?(e.enter("taskListCheckValueUnchecked"),e.consume(p),e.exit("taskListCheckValueUnchecked"),c):p===88||p===120?(e.enter("taskListCheckValueChecked"),e.consume(p),e.exit("taskListCheckValueChecked"),c):i(p)}function c(p){return p===93?(e.enter("taskListCheckMarker"),e.consume(p),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),h):i(p)}function h(p){return Fe(p)?t(p):_t(p)?e.check({tokenize:f3},t,i)(p):i(p)}}function f3(e,t,i){return Nt(e,s,"whitespace");function s(a){return a===null?i(a):t(a)}}function p3(e){return D0([IR(),VR(),n3(e),l3(),h3()])}const m3={};function ES(e){const t=this,i=e||m3,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),o=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),c=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(p3(i)),o.push(LR()),c.push(OR(i))}const ta=["ariaDescribedBy","ariaLabel","ariaLabelledBy"],ll={ancestors:{tbody:["table"],td:["table"],th:["table"],thead:["table"],tfoot:["table"],tr:["table"]},attributes:{a:[...ta,"dataFootnoteBackref","dataFootnoteRef",["className","data-footnote-backref"],"href"],blockquote:["cite"],code:[["className",/^language-./]],del:["cite"],div:["itemScope","itemType"],dl:[...ta],h2:[["className","sr-only"]],img:[...ta,"longDesc","src"],input:[["disabled",!0],["type","checkbox"]],ins:["cite"],li:[["className","task-list-item"]],ol:[...ta,["className","contains-task-list"]],q:["cite"],section:["dataFootnotes",["className","footnotes"]],source:["srcSet"],summary:[...ta],table:[...ta],ul:[...ta,["className","contains-task-list"]],"*":["abbr","accept","acceptCharset","accessKey","action","align","alt","axis","border","cellPadding","cellSpacing","char","charOff","charSet","checked","clear","colSpan","color","cols","compact","coords","dateTime","dir","encType","frame","hSpace","headers","height","hrefLang","htmlFor","id","isMap","itemProp","label","lang","maxLength","media","method","multiple","name","noHref","noShade","noWrap","open","prompt","readOnly","rev","rowSpan","rows","rules","scope","selected","shape","size","span","start","summary","tabIndex","title","useMap","vAlign","value","width"]},clobber:["ariaDescribedBy","ariaLabelledBy","id","name"],clobberPrefix:"user-content-",protocols:{cite:["http","https"],href:["http","https","irc","ircs","mailto","xmpp"],longDesc:["http","https"],src:["http","https"]},required:{input:{disabled:!0,type:"checkbox"}},strip:["script"],tagNames:["a","b","blockquote","br","code","dd","del","details","div","dl","dt","em","h1","h2","h3","h4","h5","h6","hr","i","img","input","ins","kbd","li","ol","p","picture","pre","q","rp","rt","ruby","s","samp","section","source","span","strike","strong","sub","summary","sup","table","tbody","td","tfoot","th","thead","tr","tt","ul","var"]},As={}.hasOwnProperty;function g3(e,t){let i={type:"root",children:[]};const s={schema:t?{...ll,...t}:ll,stack:[]},a=NS(s,e);return a&&(Array.isArray(a)?a.length===1?i=a[0]:i.children=a:i=a),i}function NS(e,t){if(t&&typeof t=="object"){const i=t;switch(typeof i.type=="string"?i.type:""){case"comment":return x3(e,i);case"doctype":return _3(e,i);case"element":return b3(e,i);case"root":return v3(e,i);case"text":return y3(e,i)}}}function x3(e,t){if(e.schema.allowComments){const i=typeof t.value=="string"?t.value:"",s=i.indexOf("-->"),o={type:"comment",value:s<0?i:i.slice(0,s)};return Po(o,t),o}}function _3(e,t){if(e.schema.allowDoctypes){const i={type:"doctype"};return Po(i,t),i}}function b3(e,t){const i=typeof t.tagName=="string"?t.tagName:"";e.stack.push(i);const s=TS(e,t.children),a=S3(e,t.properties);e.stack.pop();let o=!1;if(i&&i!=="*"&&(!e.schema.tagNames||e.schema.tagNames.includes(i))&&(o=!0,e.schema.ancestors&&As.call(e.schema.ancestors,i))){const h=e.schema.ancestors[i];let p=-1;for(o=!1;++p<h.length;)e.stack.includes(h[p])&&(o=!0)}if(!o)return e.schema.strip&&!e.schema.strip.includes(i)?s:void 0;const c={type:"element",tagName:i,properties:a,children:s};return Po(c,t),c}function v3(e,t){const s={type:"root",children:TS(e,t.children)};return Po(s,t),s}function y3(e,t){const s={type:"text",value:typeof t.value=="string"?t.value:""};return Po(s,t),s}function TS(e,t){const i=[];if(Array.isArray(t)){const s=t;let a=-1;for(;++a<s.length;){const o=NS(e,s[a]);o&&(Array.isArray(o)?i.push(...o):i.push(o))}}return i}function S3(e,t){const i=e.stack[e.stack.length-1],s=e.schema.attributes,a=e.schema.required,o=s&&As.call(s,i)?s[i]:void 0,c=s&&As.call(s,"*")?s["*"]:void 0,h=t&&typeof t=="object"?t:{},p={};let f;for(f in h)if(As.call(h,f)){const _=h[f];let x=Yv(e,Kv(o,f),f,_);x==null&&(x=Yv(e,Kv(c,f),f,_)),x!=null&&(p[f]=x)}if(a&&As.call(a,i)){const _=a[i];for(f in _)As.call(_,f)&&!As.call(p,f)&&(p[f]=_[f])}return p}function Yv(e,t,i,s){return t?Array.isArray(s)?w3(e,t,i,s):jS(e,t,i,s):void 0}function w3(e,t,i,s){let a=-1;const o=[];for(;++a<s.length;){const c=jS(e,t,i,s[a]);(typeof c=="number"||typeof c=="string")&&o.push(c)}return o}function jS(e,t,i,s){if(!(typeof s!="boolean"&&typeof s!="number"&&typeof s!="string")&&C3(e,i,s)){if(typeof t=="object"&&t.length>1){let a=!1,o=0;for(;++o<t.length;){const c=t[o];if(c&&typeof c=="object"&&"flags"in c){if(c.test(String(s))){a=!0;break}}else if(c===s){a=!0;break}}if(!a)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(i)?e.schema.clobberPrefix+s:s}}function C3(e,t,i){const s=e.schema.protocols&&As.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!s||s.length===0)return!0;const a=String(i),o=a.indexOf(":"),c=a.indexOf("?"),h=a.indexOf("#"),p=a.indexOf("/");if(o<0||p>-1&&o>p||c>-1&&o>c||h>-1&&o>h)return!0;let f=-1;for(;++f<s.length;){const _=s[f];if(o===_.length&&a.slice(0,_.length)===_)return!0}return!1}function Po(e,t){const i=N0(t);t.data&&(e.data=To(t.data)),i&&(e.position=i)}function Kv(e,t){let i,s=-1;if(e)for(;++s<e.length;){const a=e[s],o=typeof a=="string"?a:a[0];if(o===t)return a;o==="data*"&&(i=a)}if(t.length>4&&t.slice(0,4).toLowerCase()==="data")return i}function AS(e){return function(t){return g3(t,e)}}const nl=["Romance","Fantasy","Science Fiction","Mystery","Thriller","Horror","Adventure","Historical Fiction","Contemporary Lit","Humor","Poetry","Non-Fiction","Fanfiction","Short Story","Paranormal","Werewolf","LGBTQ+","New Adult","Teen Fiction","Diverse Lit","Others"],Xr=["English","Chinese","Korean","Japanese","Spanish","French","Hindi","Arabic","Portuguese","Russian","Others"];function RS(e){return e.toLowerCase().replace(/[^a-z0-9+]/g,"")}const k3=Object.fromEntries(nl.map(e=>[RS(e),e])),E3={scifi:"Science Fiction",sf:"Science Fiction",comedy:"Humor",humour:"Humor",ya:"Teen Fiction",youngadult:"Teen Fiction",lgbt:"LGBTQ+",lgbtq:"LGBTQ+","lgbtqia+":"LGBTQ+",historical:"Historical Fiction",scary:"Horror"};function bu(e){if(!e)return null;const t=RS(e.trim());return t?k3[t]??E3[t]??null:null}function MS(e,t){const i=t.startsWith("assets/")?t.slice(7):t;return`/api/stories/${e}/asset/${i}`}function DS(e,t,i){const[s,a]=w.useState({url:null,loading:!!t,error:!1});return w.useEffect(()=>{if(!t){a({url:null,loading:!1,error:!1});return}let o=null,c=!1;return a({url:null,loading:!0,error:!1}),(async()=>{try{const h=await i(MS(e,t));if(!h.ok)throw new Error(`asset request failed (${h.status})`);const p=await h.blob();if(c)return;o=URL.createObjectURL(p),a({url:o,loading:!1,error:!1})}catch{c||a({url:null,loading:!1,error:!0})}})(),()=>{c=!0,o&&URL.revokeObjectURL(o)}},[e,t,i]),s}function Rp({storyName:e,assetPath:t,authFetch:i,alt:s,className:a}){const{url:o,loading:c,error:h}=DS(e,t,i);return h||!c&&!o?d.jsx("div",{className:"w-full aspect-video bg-surface border border-border rounded flex items-center justify-center",children:d.jsx("span",{className:"text-xs text-muted",children:"Image not available"})}):o?d.jsx("img",{src:o,alt:s,className:a??"w-full rounded border border-border"}):d.jsx("div",{className:"w-full aspect-video bg-surface border border-border rounded flex items-center justify-center","data-testid":"asset-loading",children:d.jsx("span",{className:"text-xs text-muted",children:"Loading image…"})})}function Vv(e,t,i,s){const a=t.split(/\s+/).filter(Boolean);if(a.length===0)return[""];const o=[];let c="";for(const h of a){const p=c?`${c} ${h}`:h;!c||e(p,s)<=i?c=p:(o.push(c),c=h)}return c&&o.push(c),o}function su(e,t,i,s,a){const o=a.lineHeightFactor??1.2,c=a.speakerScale??.8,h=a.paddingX??Math.max(2,i*.06),p=a.paddingY??Math.max(2,s*.08),f=Math.max(1,i-2*h),_=Math.max(1,s-2*p),x=Math.max(a.minFontSize,a.maxFontSize),b=Math.max(1,Math.min(a.minFontSize,x)),v=N=>{const j=a.hasSpeaker?N*c:0,E=a.hasSpeaker?j*o:0,z=Math.max(1,_-E),O=a.fontWeight??400,W=Vv((te,de)=>e(te,de,O),t,f,N),q=W.length*N*o,D=W.every(te=>e(te,N,O)<=f+.5);return{lines:W,ok:q<=z&&D}};if(typeof a.fontSize=="number"&&Number.isFinite(a.fontSize)&&a.fontSize>0){const N=Math.max(1,a.fontSize),{lines:j,ok:E}=v(N);return{lines:j,fontSize:N,lineHeight:N*o,speakerFontSize:a.hasSpeaker?N*c:0,overflow:!E}}for(let N=x;N>=b;N-=.5){const{lines:j,ok:E}=v(N);if(E)return{lines:j,fontSize:N,lineHeight:N*o,speakerFontSize:a.hasSpeaker?N*c:0,overflow:!1}}return{lines:Vv(e,t,f,b),fontSize:b,lineHeight:b*o,speakerFontSize:a.hasSpeaker?b*c:0,overflow:!0}}function N3(e){return{minFontSize:Math.max(1,e*.022),maxFontSize:Math.max(1,e*.05)}}const BS=["speech","narration","sfx"],T3=2;function Er(e,t,i){return Math.min(i,Math.max(t,e))}function rl(e,t,i){return typeof e=="number"&&Number.isFinite(e)?Er(e,t,i):void 0}function fm(e){if(!e||typeof e!="object")return;const t=e,i=t.mode==="manual"?"manual":t.mode==="auto"?"auto":void 0,s=rl(t.fontScale,.015,.12),a=t.fontWeight===700?700:t.fontWeight===400?400:void 0,o=rl(t.lineHeightFactor,.9,2),c=rl(t.speakerScale,.5,1.5);if(!(!i&&s===void 0&&a===void 0&&o===void 0&&c===void 0))return{...i?{mode:i}:{},...s!==void 0?{fontScale:s}:{},...a!==void 0?{fontWeight:a}:{},...o!==void 0?{lineHeightFactor:o}:{},...c!==void 0?{speakerScale:c}:{}}}function Fu(e){if(!e||typeof e!="object")return;const t=e,i=rl(t.paddingX,0,.25),s=rl(t.paddingY,0,.25),a=rl(t.cornerRadius,0,.49);if(!(i===void 0&&s===void 0&&a===void 0))return{...i!==void 0?{paddingX:i}:{},...s!==void 0?{paddingY:s}:{},...a!==void 0?{cornerRadius:a}:{}}}function au(e,t,i,s){const{minFontSize:a,maxFontSize:o}=N3(t),c=fm(e.textStyle),h=Fu(e.bubbleStyle);return{minFontSize:a,maxFontSize:o,hasSpeaker:e.type!=="sfx"&&!!e.speaker,...(c==null?void 0:c.lineHeightFactor)!==void 0?{lineHeightFactor:c.lineHeightFactor}:{},...(c==null?void 0:c.speakerScale)!==void 0?{speakerScale:c.speakerScale}:{},...(c==null?void 0:c.fontWeight)!==void 0?{fontWeight:c.fontWeight}:{},...(c==null?void 0:c.mode)==="manual"&&c.fontScale!==void 0?{fontSize:Math.max(1,t*c.fontScale)}:{},...(h==null?void 0:h.paddingX)!==void 0?{paddingX:i*h.paddingX}:{},...(h==null?void 0:h.paddingY)!==void 0?{paddingY:s*h.paddingY}:{}}}function j3(e,t,i){const s=Fu(e.bubbleStyle);return(s==null?void 0:s.cornerRadius)!==void 0?Math.min(t,i)*s.cornerRadius:void 0}function LS(e,t){const i=Math.min(e,t);return Math.max(0,Math.min(i*.4,i/2))}function Xv(e,t,i,s,a){const o=Math.max(0,i-2*s),c=Math.max(1,Math.min(a,o)/2),h=t+s+c,p=t+i-s-c;return{center:p>=h?Er(e,h,p):t+i/2,half:c}}function OS(e,t,i,s,a,o){const c=e+i/2,h=t+s/2,p=e+a.x*i,f=t+a.y*s;if(p>=e&&p<=e+i&&f>=t&&f<=t+s)return null;const _=p-c,x=f-h,b=Math.max(6,Math.min(i,s)*.3),v=o??LS(i,s);if(Math.abs(x)>=Math.abs(_)){const E=x>=0?t+s:t,{center:z,half:O}=Xv(p,e,i,v,b);return{tip:{x:p,y:f},base1:{x:z-O,y:E},base2:{x:z+O,y:E}}}const y=_>=0?e+i:e,{center:N,half:j}=Xv(f,t,s,v,b);return{tip:{x:p,y:f},base1:{x:y,y:N-j},base2:{x:y,y:N+j}}}function A3(e){return e.type!=="speech"||!e.tailAnchor?!1:OS(0,0,1,1,e.tailAnchor)!==null}function R3(e,t,i,s,a,o){const c=o??LS(i,s),h=e+i,p=t+s,f=!!a&&a.base1.y===t&&a.base2.y===t,_=!!a&&a.base1.x===h&&a.base2.x===h,x=!!a&&a.base1.y===p&&a.base2.y===p,b=!!a&&a.base1.x===e&&a.base2.x===e,v=[{k:"M",x:e+c,y:t}];return f&&a&&v.push({k:"L",x:a.base1.x,y:t},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:a.base2.x,y:t}),v.push({k:"L",x:h-c,y:t},{k:"A",cornerX:h,cornerY:t,x:h,y:t+c,r:c}),_&&a&&v.push({k:"L",x:h,y:a.base1.y},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:h,y:a.base2.y}),v.push({k:"L",x:h,y:p-c},{k:"A",cornerX:h,cornerY:p,x:h-c,y:p,r:c}),x&&a&&v.push({k:"L",x:a.base2.x,y:p},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:a.base1.x,y:p}),v.push({k:"L",x:e+c,y:p},{k:"A",cornerX:e,cornerY:p,x:e,y:p-c,r:c}),b&&a&&v.push({k:"L",x:e,y:a.base2.y},{k:"L",x:a.tip.x,y:a.tip.y},{k:"L",x:e,y:a.base1.y}),v.push({k:"L",x:e,y:t+c},{k:"A",cornerX:e,cornerY:t,x:e+c,y:t,r:c}),v}function M3(e,t,i,s,a,o){const c=R3(e,t,i,s,a,o).map(h=>h.k==="A"?`A ${h.r} ${h.r} 0 0 1 ${h.x} ${h.y}`:`${h.k} ${h.x} ${h.y}`);return c.push("Z"),c.join(" ")}function D3(e){return e.x<-1e-6||e.y<-1e-6||e.x+e.width>1+1e-6||e.y+e.height>1+1e-6}let Zv=0;function Qv(e,t=.1,i=.1){return Zv++,{id:`overlay-${Date.now()}-${Zv}`,type:e,x:t,y:i,width:e==="sfx"?.15:.25,height:e==="sfx"?.08:.12,text:"",...e==="speech"?{speaker:"",tailAnchor:{x:.5,y:1.2}}:{}}}function B3(e,t,i){return{width:Math.min(e==="sfx"?.3:.5,Math.max(.15,1-t)),height:Math.min(e==="sfx"?.1:.2,Math.max(.06,1-i))}}const lu=.05;function Ui(e){return typeof e=="number"&&Number.isFinite(e)}function L3(e,t,i){const s=e.toLowerCase(),a=/\bleft\b/.test(s),o=/\bright\b/.test(s),c=/\b(?:top|upper)\b/.test(s),h=/\b(?:bottom|lower)\b/.test(s),p=/\b(?:center|centre|middle)\b/.test(s);if(!a&&!o&&!c&&!h&&!p)return null;const f=a?lu:Er(o?1-t-lu:(1-t)/2,0,1),_=c?lu:Er(h?1-i-lu:(1-i)/2,0,1);return{x:f,y:_}}let O3=0;function z3(e){if(!e||typeof e!="object")return null;const t=e,i=BS.includes(t.type)?t.type:"speech",s=typeof t.text=="string"?t.text:"";let a=Ui(t.width)&&t.width>0?t.width:i==="sfx"?.15:.4,o=Ui(t.height)&&t.height>0?t.height:i==="sfx"?.08:.16,c,h;if(Ui(t.x)&&Ui(t.y))c=t.x,h=t.y;else{const b=typeof t.position=="string"?L3(t.position,a,o):null;if(!b)return null;c=b.x,h=b.y}c=Er(c,0,1),h=Er(h,0,1),a=Er(a,.02,1),o=Er(o,.02,1);const f={id:typeof t.id=="string"&&t.id?t.id:`overlay-norm-${++O3}`,type:i,x:c,y:h,width:a,height:o,text:s};if(i==="speech"){f.speaker=typeof t.speaker=="string"?t.speaker:"";const b=t.tailAnchor;f.tailAnchor=b&&Ui(b.x)&&Ui(b.y)?{x:b.x,y:b.y}:{x:.5,y:1.2}}else typeof t.speaker=="string"&&t.speaker&&(f.speaker=t.speaker);const _=fm(t.textStyle),x=Fu(t.bubbleStyle);return _&&(f.textStyle=_),x&&(f.bubbleStyle=x),f}function P3(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&!!t.id&&BS.includes(t.type)&&Ui(t.x)&&Ui(t.y)&&Ui(t.width)&&Ui(t.height)&&typeof t.text=="string"}function I3(e){const t=Array.isArray(e)?e:[],i=[],s=[];let a=!Array.isArray(e);return t.forEach((o,c)=>{const h=z3(o);if(!h){s.push({index:c,reason:"overlay has no numeric x/y/width/height and no recognizable position"}),a=!0;return}i.push(h),P3(o)||(a=!0)}),{overlays:i,changed:a,invalid:s}}function ZD(e){for(let t=0;t<e.length;t++){const i=e[t];if(!(Ui(i==null?void 0:i.x)&&Ui(i==null?void 0:i.y)&&Ui(i==null?void 0:i.width)&&Ui(i==null?void 0:i.height)&&i.width>0&&i.height>0))return{valid:!1,error:`Overlay ${t+1}${i!=null&&i.type?` (${i.type})`:""} has invalid geometry — repair or re-place it in the lettering editor before export`};const a=fm(i==null?void 0:i.textStyle);if(i!=null&&i.textStyle&&!a)return{valid:!1,error:`Overlay ${t+1}${i!=null&&i.type?` (${i.type})`:""} has invalid typography controls — reset them in the lettering editor before export`};const o=Fu(i==null?void 0:i.bubbleStyle);if(i!=null&&i.bubbleStyle&&!o)return{valid:!1,error:`Overlay ${t+1}${i!=null&&i.type?` (${i.type})`:""} has invalid bubble controls — reset them in the lettering editor before export`}}return{valid:!0}}const Jv=new Set(["speech","narration"]),H3=.12;function ey(e){return Ui(e==null?void 0:e.x)&&Ui(e==null?void 0:e.y)&&Ui(e==null?void 0:e.width)&&Ui(e==null?void 0:e.height)&&e.width>0&&e.height>0}function U3(e,t=H3){const i=[];for(let s=0;s<e.length;s++){const a=e[s];if(!(!Jv.has(a==null?void 0:a.type)||!ey(a)))for(let o=s+1;o<e.length;o++){const c=e[o];if(!Jv.has(c==null?void 0:c.type)||!ey(c))continue;const h=Math.min(a.x+a.width,c.x+c.width)-Math.max(a.x,c.x),p=Math.min(a.y+a.height,c.y+c.height)-Math.max(a.y,c.y);if(h<=0||p<=0)continue;const f=h*p,_=Math.min(a.width*a.height,c.width*c.height),x=_>0?f/_:0;x>=t&&i.push({indexA:s,indexB:o,idA:a.id,idB:c.id,ratio:x})}}return i}function ar(e){return e.kind==="text"}function $3(e){return!!e.finalImagePath||!!e.exportedAt?{key:"review",label:"Review final panel",opensEditor:!0}:e.cleanImagePath||ar(e)?{key:"letter",label:"Letter this cut",opensEditor:!0}:{key:"add-art",label:"Add clean art for this cut",opensEditor:!1}}function zS(e,t=T3){return!e.finalImagePath||!(e.overlays??[]).some(A3)?!1:(e.finalRendererVersion??0)<t}const ty=800;function F3(e){if(!e)return null;const t=e.match(/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/);if(!t)return null;const i=parseFloat(t[1]),s=parseFloat(t[2]);return!(i>0)||!(s>0)?null:{width:ty,height:Math.round(ty*s/i)}}function ou({cut:e}){return e.dialogue.length>0||e.narration||e.sfx?d.jsxs("div",{className:"space-y-1.5","data-testid":`cut-${e.id}-overlay`,children:[e.dialogue.map((i,s)=>d.jsxs("div",{className:"flex gap-2 text-xs",children:[d.jsxs("span",{className:"font-medium text-foreground flex-shrink-0",children:[i.speaker,":"]}),d.jsx("span",{className:"text-foreground",children:i.text})]},s)),e.narration&&d.jsx("div",{className:"border-l-2 border-border pl-3",children:d.jsx("p",{className:"text-xs text-muted italic",children:e.narration})}),e.sfx&&d.jsxs("p",{className:"text-xs font-mono text-muted",children:["SFX: ",e.sfx]})]}):null}function q3({cut:e,storyName:t,authFetch:i,onEditCut:s}){const a=!!e.finalImagePath,o=!!e.cleanImagePath,c=a||o,h=e.dialogue.length>0||!!e.narration||!!e.sfx,p=e.kind==="text";return d.jsxs("div",{className:"space-y-2",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:"text-[10px] font-mono text-muted bg-surface border border-border rounded px-1.5 py-0.5",children:["#",e.id]}),d.jsx("span",{className:"text-[10px] font-mono text-muted",children:e.shotType}),e.characters.length>0&&d.jsx("span",{className:"text-[10px] text-muted truncate",children:e.characters.join(", ")})]}),a&&d.jsx(Rp,{storyName:t,assetPath:e.finalImagePath,authFetch:i,alt:e.description||`Cut ${e.id}`}),!a&&o&&d.jsxs("div",{className:"border border-border rounded overflow-hidden",children:[d.jsx(Rp,{storyName:t,assetPath:e.cleanImagePath,authFetch:i,alt:e.description||`Cut ${e.id}`}),d.jsx("div",{className:"px-3 py-2 bg-surface/80 border-t border-border",children:d.jsx(ou,{cut:e})})]}),!c&&p&&d.jsxs("div",{className:"w-full border border-border rounded p-4 space-y-2",style:{background:e.background||void 0},"data-testid":`cut-${e.id}-textpanel`,children:[d.jsx("span",{className:"text-[10px] font-mono text-muted",children:"Text panel"}),h?d.jsx(ou,{cut:e}):d.jsx("p",{className:"text-xs text-muted italic",children:"Empty text panel — open the editor to add text."})]}),!c&&!p&&d.jsxs("div",{className:"w-full bg-surface border border-dashed border-border rounded p-4 space-y-2","data-testid":`cut-${e.id}-pending`,children:[d.jsxs("div",{className:"aspect-video flex flex-col items-center justify-center gap-1 text-center",children:[d.jsx("span",{className:"text-xs text-muted font-medium",children:"Image pending"}),d.jsx("span",{className:"text-[10px] text-muted",children:"Planned image cut — generate & upload the art"})]}),h&&d.jsxs("div",{className:"border-t border-dashed border-border pt-2 space-y-1",children:[d.jsx("span",{className:"text-[10px] font-mono text-muted",children:"Planned text (will be lettered onto the image)"}),d.jsx(ou,{cut:e})]})]}),e.description&&d.jsx("p",{className:"text-xs text-muted italic",children:e.description}),a&&d.jsx(ou,{cut:e}),s&&(()=>{const f=$3(e);return d.jsx("button",{type:"button","data-testid":`cut-${e.id}-cta`,"data-cut-action":f.key,onClick:()=>s(e.id,f.opensEditor),className:"w-full px-3 py-1.5 text-xs font-medium rounded bg-accent text-white hover:bg-accent-dim",children:f.label})})()]})}function W3({storyName:e,fileName:t,authFetch:i,onEditCut:s}){const[a,o]=w.useState(null),[c,h]=w.useState(!0),[p,f]=w.useState(null),_=t.replace(/\.md$/,""),x=w.useCallback(async()=>{h(!0),f(null);try{const b=await i(`/api/stories/${e}/cuts/${_}`);if(b.status===404){o(null),h(!1);return}if(!b.ok){const y=await b.json();f(y.error||"Failed to load cuts"),h(!1);return}const v=await b.json();o(v)}catch{f("Failed to load cuts")}finally{h(!1)}},[i,e,_]);return w.useEffect(()=>{x();const b=setInterval(x,5e3);return()=>clearInterval(b)},[x]),c&&!a?d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Loading cuts..."}):p?d.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2 px-4 text-center","data-testid":"cuts-error",children:[d.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),d.jsx("p",{className:"text-xs text-error",children:p}),d.jsxs("p",{className:"text-xs text-muted max-w-sm",children:[_,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema shown in the cartoon writing instructions."]}),d.jsx("button",{onClick:x,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]}):!a||a.cuts.length===0?d.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-2 px-4 text-center",children:[d.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),d.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]}):d.jsx("div",{className:"h-full overflow-y-auto",children:d.jsx("div",{className:"max-w-lg mx-auto px-4 py-6 space-y-6",children:a.cuts.map(b=>d.jsx(q3,{cut:b,storyName:e,authFetch:i,onEditCut:s},b.id))})})}const iy=/!\[[^\]]*\]\([^)]*\)/g,G3=/<!--[\s\S]*?-->/g,PS=200;function Y3(e){const t=(e.match(iy)||[]).length,i=e.length,s=e.replace(G3," ").replace(iy," ").replace(/\s+/g," ").trim();return{imageCount:t,charCount:i,nonImageProse:s,nonImageProsePreview:s.slice(0,PS)}}function K3(e){return`${e}: re-export required before publish — this final image uses an older speech-bubble tail style that can show a visible seam`}const V3=[/placeholder only/i,/\bOWS (?:should )?generates? the publish markdown/i,/generate(?:s|d)? the publish markdown from/i,/after clean images are approved/i,/lettered final images are created/i,/do not hand-?write/i,/\b(?:TODO|FIXME)\b/];function X3(e){for(const t of V3){const i=e.match(t);if(i)return i[0]}return null}function pm(e,t){const i=`<!-- ows:cartoon-cut ${t} start -->`,s=`<!-- ows:cartoon-cut ${t} end -->`,a=e.indexOf(i),o=e.indexOf(s);return a===-1||o===-1||o<a?null:e.slice(a+i.length,o)}function Z3(e,t){if(t.length===0)return!1;for(let i=0;i<t.length;i++){const s=`cut-${String(i+1).padStart(3,"0")}`;if(pm(e,s)===null)return!0}return!1}function IS(e,t){const i=[];if(t.length===0)return{ready:!1,issues:["This episode has no cuts planned yet — plan and produce its cuts before publishing."]};for(let c=0;c<t.length;c++){const h=t[c],p=`Cut ${c+1}`,f=`cut-${String(c+1).padStart(3,"0")}`;h.uploadedUrl||i.push(`${p}: not uploaded (no recorded uploaded URL)`),zS(h)&&i.push(K3(p));const _=pm(e,f);if(_===null){i.push(`${p}: missing or incomplete markdown block`);continue}const x=[..._.matchAll(/!\[[^\]]*\]\(([^)]*)\)/g)].map(b=>b[1].trim());x.length===0?i.push(`${p}: block has no image reference`):x.length>1?i.push(`${p}: block must contain exactly one image reference`):h.uploadedUrl&&x[0]!==h.uploadedUrl&&i.push(`${p}: image URL does not match the recorded uploaded URL`)}/awaiting upload|image pending|final image pending|pending upload/i.test(e)&&i.push("Markdown contains awaiting-upload placeholders");const s=X3(e);s&&i.push(`This episode still has placeholder/instructional text ("${s.slice(0,60)}") — remove it or re-run “Prepare episode for publish” so the published episode is images only`);const a=new Set(t.map(c=>c.uploadedUrl).filter(c=>!!c&&/^https?:\/\//i.test(c))),o=[...e.matchAll(/!\[[^\]]*\]\(([^)]*)\)/g)];for(const c of o){const h=c[1].trim();/^https?:\/\//i.test(h)?a.has(h)||i.push(`Image reference is not a recorded uploaded cut URL: ${h.slice(0,60)}`):i.push(`Invalid image reference (not an http(s) URL): ${h.slice(0,60)}`)}return e.length>1e4&&i.push(`Markdown is ${e.length} chars (limit 10,000)`),{ready:i.length===0,issues:i}}function HS(e,t){const i=t.length;if(i===0)return{stage:"not-started",issues:[],awaitingCount:0,totalCuts:0};if(Z3(e,t))return{stage:"planning",issues:[],awaitingCount:0,totalCuts:i};const{ready:s,issues:a}=IS(e,t);if(s)return{stage:"ready",issues:[],awaitingCount:0,totalCuts:i};const o=new Set;for(let p=0;p<t.length;p++){const f=`Cut ${p+1}`,_=`cut-${String(p+1).padStart(3,"0")}`,x=pm(e,_);if(x===null)continue;!/!\[[^\]]*\]\([^)]*\)/.test(x)&&!t[p].uploadedUrl&&o.add(f)}const c=new Set(["Markdown contains awaiting-upload placeholders"]);for(const p of o)c.add(`${p}: not uploaded (no recorded uploaded URL)`),c.add(`${p}: block has no image reference`);const h=a.filter(p=>!c.has(p));return h.length>0?{stage:"error",issues:h,awaitingCount:o.size,totalCuts:i}:{stage:"awaiting-upload",issues:[],awaitingCount:o.size,totalCuts:i}}const jf=[{key:"assemble",title:"Prepare the episode for publish",test:/markdown block|missing or incomplete/i},{key:"export",title:"Export final images",test:/re-export|older speech-bubble|visible seam/i},{key:"upload",title:"Upload final images",test:/not uploaded|no recorded uploaded url/i},{key:"images",title:"Fix image references",test:/image reference|not an http|does not match|exactly one image/i},{key:"cleanup",title:"Remove leftover text",test:/placeholder|instructional|awaiting-upload|awaiting upload/i},{key:"size",title:"Shorten the episode",test:/\blimit\b|\bchars\b/i}];function Q3(e){const t=new Map,i=[],s=[];for(const o of e){const c=o.match(/^Cut (\d+): (.+)$/);if(c){const h=c[2];t.has(h)||(t.set(h,[]),i.push(h)),t.get(h).push(Number(c[1]))}else s.push(o)}return[...i.map(o=>{const c=t.get(o).slice().sort((p,f)=>p-f);return`${c.length===1?`Cut ${c[0]}`:`Cuts ${c.join(", ")}`}: ${o}`}),...s]}function US(e){const t=c=>{var h;return((h=jf.find(p=>p.test.test(c)))==null?void 0:h.key)??"other"},i=new Map;for(const c of e){const h=t(c);i.has(h)||i.set(h,[]),i.get(h).push(c)}const s=[...jf.map(c=>c.key),"other"],a=c=>{var h;return((h=jf.find(p=>p.key===c))==null?void 0:h.title)??"Other issues"},o=[];for(const c of s){const h=i.get(c);!h||h.length===0||o.push({key:c,title:a(c),lines:Q3(h)})}return o}const J3=220,Af=/^(genre|logline|synopsis|premise|setting|tone|theme|themes|summary|hook|characters?|cast|arc|status|word\s*count|length|title)\b\s*[:\-–]/i;function mm(e){const t=[],i=[],s=e??"",a=s.match(/^#[ \t]+(.+)$/m),o=!!(a&&a[1].trim());o||t.push("Add a “# Title” heading — the Story opening needs a real title readers see first.");const c=s.replace(/^#\s+.+$/m,"").trim();if(c.length<J3)t.push("This Story opening is too short. Open the story for readers — the premise, the lead, and the stakes across a few short paragraphs that bridge into Episode 01, not a one-line setup.");else{const h=c.split(`
130
+ `).map(x=>x.trim()).filter(Boolean),p=h.filter(x=>/^([-*+]|\d+[.)])\s/.test(x)||Af.test(x)).length,f=c.split(/\n\s*\n/).map(x=>x.trim()).filter(Boolean),_=f.some(x=>x.length>=120&&!/^([-*+]|\d+[.)])\s/.test(x)&&!Af.test(x));h.length>0&&p/h.length>=.5||!_?t.push("This reads like a synopsis or outline. Write the Genesis as a reader-facing opening scene that sets up the first beat and stakes, then bridges into Episode 01 — not a logline, genre pitch, or character list."):f.filter(b=>b.length>=40&&!/^([-*+]|\d+[.)])\s/.test(b)&&!Af.test(b)).length<2&&t.push("Give the opening room to build: open across a few short paragraphs — the premise, what the lead wants, and the hook — that lead into Episode 01, instead of a single dense block that drops readers into a cold scene.")}return{hasTitle:o,blockers:t,warnings:i}}function eM(e){return/\.(webp|jpe?g)$/i.test(e)}function Mp(e){var c,h;let t=0,i=0,s=0,a=0,o=0;for(const p of e)ar(p)?(((h=p.overlays)==null?void 0:h.length)??0)>0&&s++:(t++,p.cleanImagePath&&eM(p.cleanImagePath)&&(i++,(((c=p.overlays)==null?void 0:c.length)??0)>0&&s++)),p.finalImagePath&&p.exportedAt&&a++,p.uploadedUrl&&o++;return{total:e.length,needClean:t,withClean:i,withText:s,exported:a,uploaded:o}}const tM={plan:"Plan cuts",clean:"Create clean images",letter:"Add speech bubbles & captions",export:"Export final images",upload:"Upload final images",publish:"Publish to PlotLink"};function po(e,t){return`${e} / ${t} cut${t===1?"":"s"}`}function iM(e){const{cuts:t,published:i=!1}=e,s=Mp(t);if(s.total===0)return{steps:[],nextStep:null};const a=s.total>0,o=a&&s.withClean===s.needClean,c=o&&s.withText===s.total,h=c&&s.exported===s.total,p=h&&s.uploaded===s.total,_={plan:a,clean:o,letter:c,export:h,upload:p,publish:p&&i},x=["plan","clean","letter","export","upload","publish"],b=x.findIndex(z=>!_[z]),v=z=>s.needClean>0?po(z,s.needClean):"no image cuts",y={plan:po(s.total,s.total),clean:v(s.withClean),letter:po(s.withText,s.total),export:po(s.exported,s.total),upload:po(s.uploaded,s.total),publish:null},N=x.map((z,O)=>({key:z,label:tM[z],status:b===-1||O<b?"done":O===b?"current":"todo",detail:y[z]})),E=b===-1?"Published — this episode is live on PlotLink.":{plan:"Plan the episode's cuts to begin.",clean:"Create a clean image for each cut — artwork only, no text or bubbles.",letter:"Open each cut in the lettering editor and place its speech bubbles and captions.",export:"Export the lettered final image for each cut.",upload:"Upload the exported final images so they're ready to publish.",publish:"Preview the episode, then publish to PlotLink."}[x[b]];return{steps:N,nextStep:E}}const nM="This is your story outline — not publishable. Ask AI to write the genesis next.";function rM(e){const{fileName:t,contentType:i,hasGenesis:s,isPublished:a,cutCount:o,cutProgress:c}=e,h=t==="structure.md",p=t==="genesis.md",f=/^plot-\d+\.md$/.test(t);if(h)return i!=="cartoon"?nM:s?"Your story outline is set. Genesis (Episode 1) already exists — review its opening and cuts; you don't need to write the Genesis again.":"This is your story outline — not publishable. Write the Genesis opening (Episode 1) next.";if(i==="cartoon"&&!a&&(p||f)&&o!==null){if(o===0)return p?"Genesis is your Episode 1 opening. Plan its cuts, then generate clean images for them.":"This episode hasn't been started — expand its cut plan before preparing it for publish.";if(p&&c){const _=c;if(_.withClean<_.needClean)return"Genesis has a cut plan — generate the clean images for its cuts next.";if(_.withText<_.total)return"Genesis clean art is ready — review the cuts and add speech bubbles & captions next.";if(_.exported<_.total)return"Genesis lettering is underway — export the final images next.";if(_.uploaded<_.total)return"Genesis final images are exported — upload them next, then prepare to publish."}}return null}function sM(e){const{stage:t,imageCount:i,hasNonImageProse:s}=e;if(t==="ready")return{possible:!0,recommended:!0,tone:"ok",headline:"Ready to publish",detail:"Every cut has an uploaded final image.",action:null};if(i===0&&s)return{possible:!1,recommended:!1,tone:"warning",headline:"Not recommended yet — this looks like planning/placeholder text",detail:"There are no images and the page is prose, so it reads as planning notes, not a finished episode.",action:"Prepare episode for publish after final images are uploaded."};switch(t){case"not-started":return{possible:!1,recommended:!1,tone:"info",headline:"Not started",detail:"This episode has no cuts planned yet.",action:"Plan its cuts, then create and upload images."};case"planning":return{possible:!1,recommended:!1,tone:"info",headline:"Not ready yet — prepare for publish",detail:"The cut plan is set, but the publish layout isn't built yet.",action:"Prepare the episode for publish."};case"awaiting-upload":return{possible:!1,recommended:!1,tone:"info",headline:"Waiting on image uploads",detail:"Some cuts still need a final uploaded image.",action:"Upload the remaining final images, then publish."};case"error":return{possible:!1,recommended:!1,tone:"blocker",headline:"Not publishable — needs fixes",detail:"Some cuts have problems that must be fixed before publishing.",action:"Open the technical details below to see what to fix."};default:return{possible:!1,recommended:!1,tone:"info",headline:"Checking readiness…",detail:"",action:null}}}const aM={...ll,attributes:{...ll.attributes,img:["src","alt","title"]}},lM={ok:"border-green-300 bg-green-50 text-green-800",info:"border-accent/30 bg-accent/5 text-foreground",warning:"border-amber-300 bg-amber-50 text-amber-800",blocker:"border-error/30 bg-error/5 text-error"};function oM({content:e,stage:t}){const i=Y3(e),s=i.nonImageProse.length>PS,a=sM({stage:t,imageCount:i.imageCount,hasNonImageProse:i.nonImageProse.length>0});return d.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"cartoon-publish-preview",children:[d.jsxs("div",{className:"px-4 py-2 border-b border-border text-[10px] text-muted flex flex-wrap items-center gap-x-3 gap-y-1","data-testid":"cartoon-publish-summary",children:[d.jsxs("span",{children:[i.imageCount," image",i.imageCount===1?"":"s"]}),d.jsxs("span",{children:[i.charCount.toLocaleString()," / 10,000 chars"]}),d.jsx("span",{className:`rounded-full px-2 py-0.5 font-medium ${a.possible?"bg-green-100 text-green-800":"bg-background text-muted"}`,"data-testid":"publish-possible",children:a.possible?"Publish possible":"Publish not possible yet"}),d.jsx("span",{className:`rounded-full px-2 py-0.5 font-medium ${a.recommended?"bg-green-100 text-green-800":a.tone==="warning"?"bg-amber-100 text-amber-800":"bg-background text-muted"}`,"data-testid":"publish-recommended",children:a.recommended?"Recommended":"Not recommended yet"})]}),d.jsxs("div",{className:`px-4 py-2 border-b text-[11px] ${lM[a.tone]}`,"data-testid":"cartoon-publish-verdict",children:[d.jsx("p",{className:"font-medium",children:a.headline}),a.detail&&d.jsx("p",{className:"mt-0.5 opacity-90",children:a.detail}),a.action&&d.jsxs("p",{className:"mt-0.5 opacity-90",children:["→ ",a.action]})]}),i.nonImageProse&&d.jsxs("div",{className:"px-4 py-2 border-b border-amber-300 bg-amber-50 text-[11px] text-amber-800","data-testid":"cartoon-nonimage-prose",children:[d.jsx("p",{className:"font-medium",children:"⚠ Non-image text in the published markdown:"}),d.jsxs("p",{className:"font-mono mt-1 whitespace-pre-wrap break-words",children:[i.nonImageProsePreview,s?"…":""]}),d.jsx("p",{className:"mt-1",children:"This text publishes verbatim around the comic images. Remove it (or re-run “Prepare episode for publish”) if it is planning or placeholder prose."})]}),d.jsx("div",{className:"max-w-lg mx-auto px-4 py-6",children:e.trim()?d.jsx("div",{className:"prose max-w-none",children:d.jsx(eS,{remarkPlugins:[iS,ES],rehypePlugins:[[AS,aM]],children:e})}):d.jsx("p",{className:"text-muted italic text-sm","data-testid":"cartoon-publish-empty",children:"No publish markdown yet — build it from the cut plan (Edit → Upload & Prepare for Publish)."})})]})}const cM="modulepreload",uM=function(e){return"/"+e},ny={},ry=function(t,i,s){let a=Promise.resolve();if(i&&i.length>0){let c=function(f){return Promise.all(f.map(_=>Promise.resolve(_).then(x=>({status:"fulfilled",value:x}),x=>({status:"rejected",reason:x}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),p=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));a=c(i.map(f=>{if(f=uM(f),f in ny)return;ny[f]=!0;const _=f.endsWith(".css"),x=_?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${x}`))return;const b=document.createElement("link");if(b.rel=_?"stylesheet":cM,_||(b.as="script"),b.crossOrigin="",b.href=f,p&&b.setAttribute("nonce",p),document.head.appendChild(b),_)return new Promise((v,y)=>{b.addEventListener("load",v),b.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${f}`)))})}))}function o(c){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=c,window.dispatchEvent(h),!h.defaultPrevented)throw c}return a.then(c=>{for(const h of c||[])h.status==="rejected"&&o(h.reason);return t().catch(o)})},gm=[{family:"Noto Sans",googleFontsId:"Noto+Sans",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans/about",category:"body",weights:[400,500,700],languages:["English","Spanish","French","Portuguese","Russian","Others"]},{family:"Noto Sans KR",googleFontsId:"Noto+Sans+KR",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+KR/about",category:"body",weights:[400,500,700],languages:["Korean"]},{family:"Noto Sans JP",googleFontsId:"Noto+Sans+JP",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+JP/about",category:"body",weights:[400,500,700],languages:["Japanese"]},{family:"Noto Sans SC",googleFontsId:"Noto+Sans+SC",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+SC/about",category:"body",weights:[400,500,700],languages:["Chinese"]},{family:"Noto Sans Devanagari",googleFontsId:"Noto+Sans+Devanagari",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Sans+Devanagari/about",category:"body",weights:[400,500,700],languages:["Hindi"]},{family:"Noto Naskh Arabic",googleFontsId:"Noto+Naskh+Arabic",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/noto/specimen/Noto+Naskh+Arabic/about",category:"body",weights:[400,500,700],languages:["Arabic"]},{family:"Bangers",googleFontsId:"Bangers",license:"OFL-1.1",licenseUrl:"https://fonts.google.com/specimen/Bangers/about",category:"display",weights:[400],languages:[]}],hM="system-ui, sans-serif",dM=gm.find(e=>e.family==="Noto Sans"),fM=gm.find(e=>e.category==="display");function pM(e){return gm.find(i=>i.category==="body"&&i.languages.includes(e))||dM}function mM(){return fM}function gM(e){const t=e.weights.join(";");return`https://fonts.googleapis.com/css2?family=${e.googleFontsId}:wght@${t}&display=swap`}function sy(e){return`"${e.family}", ${hM}`}function xM(e,t={}){var a,o,c,h;const i=!t.staleExport&&(!!e.finalImagePath||!!e.exportedAt),s=!t.staleExport&&(!!e.uploadedUrl||!!e.uploadedCid);return{hasCleanImage:!!e.cleanImagePath,hasScriptText:(((a=e.dialogue)==null?void 0:a.length)??0)>0||!!((o=e.narration)!=null&&o.trim())||!!((c=e.sfx)!=null&&c.trim()),bubblesPlaced:((h=e.overlays)==null?void 0:h.length)??0,exported:i,uploaded:s}}function vu(e){return JSON.stringify((e??[]).map(t=>[t.type,t.x,t.y,t.width,t.height,t.text,t.speaker??"",t.tailAnchor??null,t.textStyle??null,t.bubbleStyle??null]))}function _M(e){return!e.exported&&!e.uploaded?!1:e.baselineSig!==vu(e.current)}function $S(e){var i,s;const t=[];return(e.dialogue??[]).forEach((a,o)=>{var c;(c=a==null?void 0:a.text)!=null&&c.trim()&&t.push({type:"speech",speaker:a.speaker,text:a.text.trim(),key:`speech-${o}`})}),(i=e.narration)!=null&&i.trim()&&t.push({type:"narration",text:e.narration.trim(),key:"narration"}),(s=e.sfx)!=null&&s.trim()&&t.push({type:"sfx",text:e.sfx.trim(),key:"sfx"}),t}const bM={wide:"Wide",medium:"Medium","close-up":"Close-up","extreme-close-up":"Extreme close-up"},vM="No speech bubbles, captions, sound effects, narration, or any text or lettering in the image.",yM="Style lock — illustrated comic/webtoon panel art: clean black contour/ink lines, flat or cel shading, simplified but realistic (semi-realistic) anatomy and faces, backgrounds drawn as illustrated comic panels. Hold this same style on every cut for character and panel consistency. Hard negatives — NOT photorealistic, NOT a photograph, NOT a glossy or painterly digital painting, NOT concept art, NOT a 3D/CGI render, NOT airbrushed, no photoreal textures.";function SM(e){var a;const t=bM[e.shotType]??e.shotType,i=((a=e.description)==null?void 0:a.trim())||`Cut ${e.id}`,s=[`${t} shot. ${i}`];return e.characters.length>0&&s.push(`Characters: ${e.characters.join(", ")}.`),s.push(yM),s.push(vM),s.join(`
131
+ `).trim()}function wM(e,t){return`assets/${e}/cut-${String(t).padStart(2,"0")}-clean.webp`}function ay(e,t){const i=wM(t,e.id);return[`Generate the clean image for cut ${e.id}.`,"","Image description:",SM(e),"","How to hand it off:","- Produce the actual image — do not just describe it or return a prompt.",`- If your image tool can write a WebP or JPEG under 1MB, save it at ${i} and run "Sync clean images".`,'- If it only produces a PNG (e.g. built-in image generation saves to ~/.codex/generated_images), that is fine — do NOT convert or rename it yourself. Leave it there and import it into this cut with the OWS "Import from Codex" button, which converts the PNG automatically.',"- Clean image only: no text, speech bubbles, captions, sound effects, signage, watermark, or signature.","- Hold the style lock above — an illustrated comic/webtoon panel, NOT a photoreal photo, painterly concept art, or 3D render. If a result reads photorealistic, regenerate it as illustrated panel art.","- Do not letter or upload anything — final lettering and upload happen later in OWS."].join(`
132
+ `)}function CM(e,t){const i=`${t}.cuts.json`,s=$S(e),a=s.length>0?s.map(o=>o.type==="speech"?`- speech — ${o.speaker||"Speaker"}: "${o.text}"`:o.type==="narration"?`- narration: ${o.text}`:`- sfx: ${o.text}`).join(`
133
+ `):"- (no dialogue/narration/SFX recorded for this cut — add a caption only if the scene needs one)";return[`Draft the speech bubbles and captions for cut ${e.id} of ${t}.`,"","Script to letter:",a,"","How to draft it:",`- Edit cut ${e.id}'s "overlays" array in ${i}: add one overlay per line above — "type":"speech" for dialogue (also set "speaker"), "narration" for captions, "sfx" for sound effects, with the line's text.`,"- Position each overlay with x, y, width, height as 0–1 fractions of the panel, roughly where it belongs over the art, and keep bubbles clear of faces.","- These are DRAFT positions only: do NOT export or upload. The writer reviews and adjusts them in the OWS lettering editor, then exports the final image there."].join(`
134
+ `)}function En(e,t){return e*t}function ly(e,t){return t===0?0:e/t}function oy(e){const t=`gfont-${e.googleFontsId}`;if(document.getElementById(t))return;const i=document.createElement("link");i.id=t,i.rel="stylesheet",i.href=gM(e),document.head.appendChild(i)}const yu={speech:"Speech",narration:"Narration",sfx:"SFX"},kM={speech:"border-foreground/40",narration:"border-muted/40",sfx:"border-accent/40"};function Rf(e){const t=(e.speaker||e.text||"").trim().replace(/\s+/g," ");return t?`“${t.length>18?`${t.slice(0,18)}…`:t}”`:yu[e.type]}const cy=.05,EM=[{key:"down",label:"Down",anchor:{x:.5,y:1.2}},{key:"up",label:"Up",anchor:{x:.5,y:-.2}},{key:"left",label:"Left",anchor:{x:-.2,y:.5}},{key:"right",label:"Right",anchor:{x:1.2,y:.5}}];function cu(e,t,i){return Math.min(i,Math.max(t,e))}function NM({storyName:e,cut:t,plotFile:i,onSave:s,onClose:a,onExported:o,language:c="English",authFetch:h,targetLabel:p,returnOnSave:f=!1}){var Mt,ct,We,Bt,pt,Mi;const _=pM(c),x=mM(),b=sy(_),v=sy(x);w.useEffect(()=>{oy(_),oy(x)},[_,x]),w.useEffect(()=>{let H=!1;return ae(!1),(async()=>{try{const{ensureFontsReady:ke}=await ry(async()=>{const{ensureFontsReady:Pe}=await import("./export-cut-che5mMWc.js");return{ensureFontsReady:Pe}},[]);await ke([_.family,x.family])}catch{}H||ae(!0)})(),()=>{H=!0}},[_.family,x.family]);const y=DS(e,t.cleanImagePath,h),N=w.useMemo(()=>I3(t.overlays),[t.overlays]),j=N.invalid.length,[E,z]=w.useState(!1),O=j===0&&N.changed&&N.overlays.length>0,[W,q]=w.useState(()=>N.overlays),[D,te]=w.useState(()=>vu(N.overlays)),de=w.useRef(null),_e=w.useCallback(H=>(ke,Pe,je=400)=>{var Xe;!de.current&&typeof document<"u"&&(de.current=document.createElement("canvas"));const Ie=(Xe=de.current)==null?void 0:Xe.getContext("2d");return Ie?(Ie.font=`${je} ${Pe}px ${H}`,Ie.measureText(ke).width):ke.length*Pe*.5},[]),[P,ae]=w.useState(!1),[G,Y]=w.useState(null),[Q,I]=w.useState(!1),[A,B]=w.useState(!1),[U,ge]=w.useState(null),[T,R]=w.useState(null),[V,C]=w.useState(!1),[K,re]=w.useState({x:0,y:0,width:0,height:0}),ue=w.useRef(null),$=w.useRef(null),le=w.useRef(null),be=w.useCallback(()=>{const H=ue.current;if(!H)return;const ke=H.clientWidth,Pe=H.clientHeight;let je,Ie;if(t.kind==="text"){const Tt=F3(t.aspectRatio)??{width:800,height:600};je=Tt.width,Ie=Tt.height}else{const Tt=$.current;if(!Tt||!Tt.naturalWidth)return;je=Tt.naturalWidth,Ie=Tt.naturalHeight}if(!ke||!Pe)return;const Xe=Math.min(ke/je,Pe/Ie),mt=je*Xe,Qe=Ie*Xe;re({x:(ke-mt)/2,y:(Pe-Qe)/2,width:mt,height:Qe})},[t.kind,t.aspectRatio]);w.useEffect(()=>{const H=ue.current;if(!H)return;const ke=new ResizeObserver(()=>be());return ke.observe(H),()=>ke.disconnect()},[be]);const Te=w.useCallback(H=>{const ke=B3(H.type,H.x,H.y),Pe=ke.width,je=Math.max(.08,1-H.y);if(!H.text||!P||K.width<=0)return ke;const Ie=H.type==="sfx"?v:b,Xe=En(Pe,K.width);let mt=H.type==="sfx"?.08:.12;for(let Qe=0;Qe<24;Qe++){const Tt=Math.min(mt,je),qt=En(Tt,K.height);if(!su(_e(Ie),H.text,Xe,qt,au({...H},K.height||300,Xe,qt)).overflow||Tt>=je)return{width:Pe,height:Tt};mt+=.03}return{width:Pe,height:Math.min(mt,je)}},[P,K,_e,b,v]),Le=w.useCallback(H=>{const ke=Qv(H,.1+Math.random()*.3,.1+Math.random()*.3),Pe={...ke,...Te(ke)};q(je=>[...je,Pe]),Y(Pe.id)},[Te]),ze=w.useCallback(H=>{const Pe={...Qv(H.type,.1+Math.random()*.3,.1+Math.random()*.3),text:H.text,...H.type==="speech"&&H.speaker?{speaker:H.speaker}:{}},je={...Pe,...Te(Pe)};q(Ie=>[...Ie,je]),Y(je.id)},[Te]),ye=w.useCallback((H,ke)=>{q(Pe=>Pe.map(je=>je.id===H?{...je,...ke}:je))},[]),rt=w.useCallback(H=>{var mt;const ke=K.height||300,Pe=K.width>0?En(H.width,K.width):200,je=K.height>0?En(H.height,K.height):100,Ie=H.type==="sfx"?v:b,Xe=su(_e(Ie),H.text,Pe,je,au({...H,textStyle:void 0},ke,Pe,je));ye(H.id,{textStyle:{mode:"manual",fontScale:Xe.fontSize/Math.max(1,ke),fontWeight:((mt=H.textStyle)==null?void 0:mt.fontWeight)??400,lineHeightFactor:Xe.fontSize>0?Xe.lineHeight/Xe.fontSize:1.2,speakerScale:Xe.fontSize>0&&Xe.speakerFontSize>0?Xe.speakerFontSize/Xe.fontSize:.8}})},[K,v,b,_e,ye]),bt=w.useCallback(H=>{q(ke=>ke.filter(Pe=>Pe.id!==H)),Y(null),I(!1)},[]),wt=w.useCallback(()=>{Y(null),I(!1)},[]),vt=w.useCallback((H,ke)=>{H.stopPropagation(),Y(ke),I(!1)},[]),Ve=w.useCallback((H,ke,Pe)=>{H.stopPropagation(),H.preventDefault();const je=W.find(Ie=>Ie.id===ke);je&&(Y(ke),le.current={id:ke,mode:Pe,startX:H.clientX,startY:H.clientY,origX:je.x,origY:je.y,origW:je.width,origH:je.height})},[W]);w.useEffect(()=>{const H=Pe=>{const je=le.current;if(!je||K.width===0)return;const Ie=ly(Pe.clientX-je.startX,K.width),Xe=ly(Pe.clientY-je.startY,K.height);if(je.mode==="move"){const mt=cu(je.origX+Ie,0,1-je.origW),Qe=cu(je.origY+Xe,0,1-je.origH);ye(je.id,{x:mt,y:Qe})}else{const mt=cu(je.origW+Ie,cy,1-je.origX),Qe=cu(je.origH+Xe,cy,1-je.origY);ye(je.id,{width:mt,height:Qe})}},ke=()=>{le.current=null};return window.addEventListener("mousemove",H),window.addEventListener("mouseup",ke),()=>{window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",ke)}},[K,ye]);const Me=w.useCallback(async()=>{R(null);try{await s(W),f&&a()}catch(H){R(H instanceof Error?H.message:"Failed to save overlays")}},[W,s,a,f]),Je=w.useCallback(()=>{var H;(H=navigator.clipboard)==null||H.writeText(CM(t,i)),C(!0),setTimeout(()=>C(!1),2e3)},[t,i]),It=w.useCallback(async()=>{if(j>0&&!E){const H=j;ge(`${H} overlay${H===1?"":"s"} from the cut plan ${H===1?"has":"have"} no usable position and cannot be exported — re-place ${H===1?"it":"them"} or discard ${H===1?"it":"them"} first.`);return}B(!0),ge(null);try{await s(W);const{exportCut:H,ensureFontsReady:ke}=await ry(async()=>{const{exportCut:oe,ensureFontsReady:Ee}=await import("./export-cut-che5mMWc.js");return{exportCut:oe,ensureFontsReady:Ee}},[]),Pe=W.some(oe=>oe.type==="sfx"),je=[_.family,...Pe?[x.family]:[]],{ready:Ie,missing:Xe}=await ke(je);if(!Ie){ge(`Fonts not loaded: ${Xe.join(", ")}. Check your connection and retry.`),B(!1);return}if(t.cleanImagePath&&!y.url){ge(y.error?"Clean image failed to load — cannot export. Retry once it renders.":"Clean image still loading — wait for it to render, then export."),B(!1);return}const mt=y.url,Qe=await H(mt,W,b,v,{narration:t.narration,dialogue:t.dialogue},t.kind==="text"?{background:t.background,aspectRatio:t.aspectRatio}:void 0),Tt=new FormData,qt=Qe.type==="image/webp"?"webp":"jpg";Tt.append("file",Qe,`cut-${t.id}.${qt}`);const li=await h(`/api/stories/${e}/cuts/${i}/export-final/${t.id}`,{method:"POST",body:Tt});if(li.ok)te(vu(W)),o==null||o();else{const oe=await li.json();ge(oe.error||"Export failed")}}catch(H){ge(H instanceof Error?H.message:"Export failed")}finally{B(!1)}},[t,y,W,e,i,_,x,b,v,h,s,o,j,E]),Ae=W.find(H=>H.id===G),ii=w.useMemo(()=>U3(W),[W]),Ct=w.useRef(t.id);w.useEffect(()=>{Ct.current!==t.id&&(Ct.current=t.id,te(vu(N.overlays)))},[t.id,N.overlays]);const pi=_M({exported:!!t.finalImagePath||!!t.exportedAt,uploaded:!!t.uploadedUrl||!!t.uploadedCid,baselineSig:D,current:W}),ne=w.useMemo(()=>xM({...t,overlays:W},{staleExport:pi}),[t,W,pi]),xe=w.useMemo(()=>$S(t),[t]),Be=w.useMemo(()=>{const H={};for(const ke of W){const Pe=D3(ke);let je=!1;if(P&&K.width>0&&ke.text){const Ie=ke.type==="sfx"?v:b,Xe=En(ke.width,K.width),mt=En(ke.height,K.height);je=su(_e(Ie),ke.text,Xe,mt,au(ke,K.height||300,Xe,mt)).overflow}(Pe||je)&&(H[ke.id]={outOfBounds:Pe,overflow:je})}return H},[W,P,K,_e,b,v]),$e=Object.keys(Be).length,Ge=t.kind==="text",Ot=!t.cleanImagePath;return!Ge&&Ot&&W.length===0&&!t.narration&&!((Mt=t.dialogue)!=null&&Mt.length)?d.jsx("div",{className:"h-full flex items-center justify-center text-sm text-muted",children:"No clean image — upload one first, or add overlays for a narration cut."}):d.jsxs("div",{className:"h-full flex flex-col","data-testid":"focused-lettering-editor",children:[d.jsxs("div",{className:"px-4 py-3 border-b border-border bg-surface/40 flex items-center justify-between gap-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-accent",children:"Focused lettering editor"}),d.jsx("span",{className:"text-xs font-mono text-muted",children:p??`Cut #${t.id}`})]}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Place bubbles, captions, SFX, or between-scene card text, then save back to the full cut review."}),d.jsxs("span",{className:"text-[10px] text-muted","data-testid":"overlay-count",children:[W.length," overlays"]})]}),d.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[d.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[d.jsx("button",{onClick:()=>Le("speech"),className:"px-2 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"add-speech",children:"Speech"}),d.jsx("button",{onClick:()=>Le("narration"),className:"px-2 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"add-narration",children:"Narration"}),d.jsx("button",{onClick:()=>Le("sfx"),className:"px-2 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"add-sfx",children:"SFX"})]}),U&&d.jsx("span",{className:"text-[10px] text-error",children:U}),T&&d.jsx("span",{className:"text-[10px] text-error",children:T}),d.jsx("button",{onClick:It,disabled:A,className:"px-3 py-1 text-xs border border-accent text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"export-btn",children:A?"Exporting...":"Export"}),d.jsx("button",{onClick:()=>{Me()},className:"px-3 py-1 text-xs bg-accent text-white rounded hover:bg-accent-dim","data-testid":"save-lettering-btn",children:"Save"}),d.jsx("button",{onClick:a,className:"px-3 py-1 text-xs text-muted hover:text-foreground border border-border rounded","data-testid":"cancel-lettering-btn",children:"Cancel"})]})]}),j>0&&!E?d.jsxs("div",{className:"px-3 py-1 border-b border-border bg-error/10 text-[10px] text-error flex items-center gap-2 flex-wrap","data-testid":"overlay-repair-note",children:[d.jsxs("span",{children:[j," overlay",j===1?"":"s"," from the cut plan ",j===1?"has":"have"," no usable position and cannot be exported. Re-place ",j===1?"it":"them",", or"]}),d.jsxs("button",{onClick:()=>z(!0),"data-testid":"discard-invalid-overlays",className:"px-1.5 py-0.5 border border-error/40 rounded hover:bg-error/10",children:["discard ",j," unplaceable overlay",j===1?"":"s"]})]}):j>0?d.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-repair-note",children:["Discarded ",j," unplaceable overlay",j===1?"":"s"," — the export will not include ",j===1?"it":"them","."]}):O?d.jsx("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-repair-note",children:"Auto-placed overlays from the cut plan — review their positions before exporting."}):null,ii.length>0&&d.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"overlay-overlap-warning",children:["Cut #",t.id,": ",ii.length," bubble ",ii.length===1?"pair overlaps":"pairs overlap"," and may be hard to read —"," ",ii.map(H=>`#${H.indexA+1} ${Rf(W[H.indexA])} ↔ #${H.indexB+1} ${Rf(W[H.indexB])}`).join("; "),". Move them apart, or export as-is if the overlap is intended."]}),d.jsx("div",{className:"px-3 py-1 border-b border-border flex items-center gap-3 flex-wrap text-[10px] text-muted","data-testid":"lettering-checklist",children:[["clean-image","Clean image",ne.hasCleanImage],["script-text","Script text",ne.hasScriptText],["bubbles",`Bubbles placed${ne.bubblesPlaced?` (${ne.bubblesPlaced})`:""}`,ne.bubblesPlaced>0],["exported","Final exported",ne.exported],["uploaded","Uploaded",ne.uploaded]].map(([H,ke,Pe])=>d.jsxs("span",{"data-testid":`lettering-check-${H}`,"data-done":Pe?"true":"false",className:`flex items-center gap-1 ${Pe?"text-green-700":"text-muted/70"}`,children:[d.jsx("span",{"aria-hidden":!0,children:Pe?"✓":"○"}),ke]},H))}),pi&&d.jsx("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"lettering-stale-export-warning",children:"Bubbles changed since the last export — re-export this cut and upload the new final image before publishing."}),$e>0&&d.jsxs("div",{className:"px-3 py-1 border-b border-border bg-amber-500/10 text-[10px] text-amber-700","data-testid":"lettering-export-warning",children:[$e," bubble",$e===1?"":"s"," may not export cleanly:"," ",Object.entries(Be).map(([H,ke])=>{const Pe=W.findIndex(Ie=>Ie.id===H),je=[ke.outOfBounds?"outside image":null,ke.overflow?"text overflow":null].filter(Boolean).join(", ");return`#${Pe+1} ${Rf(W[Pe])} (${je})`}).join("; "),". Resize or reposition before exporting."]}),d.jsxs("div",{className:"flex-1 min-h-0 flex",children:[d.jsxs("div",{ref:ue,className:"flex-1 min-w-0 relative overflow-hidden bg-[#f8f5ef]",onClick:wt,"data-testid":"editor-surface",children:[t.cleanImagePath&&y.error?d.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted text-xs","data-testid":"clean-image-error",children:"Clean image not available"}):t.cleanImagePath&&!y.url?d.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted text-xs","data-testid":"clean-image-loading",children:"Loading clean image…"}):t.cleanImagePath?d.jsx("img",{ref:$,src:y.url,alt:`Cut ${t.id} clean`,className:"w-full h-full object-contain",draggable:!1,onLoad:be}):Ge?K.width>0&&d.jsx("div",{className:"absolute flex items-center justify-center text-muted text-xs",style:{left:K.x,top:K.y,width:K.width,height:K.height,background:t.background||"#ffffff"},"data-testid":"text-panel-canvas",children:"Text panel"}):d.jsx("div",{className:"w-full h-full bg-white flex items-center justify-center text-muted text-xs",ref:H=>{if(H&&K.width===0){const ke=H.getBoundingClientRect();ke.width>0&&re({x:0,y:0,width:ke.width,height:ke.height})}},children:"Narration cut"}),K.width>0&&d.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none","data-testid":"balloon-layer",children:W.map(H=>{if(H.type!=="speech")return null;const ke=K.x+En(H.x,K.width),Pe=K.y+En(H.y,K.height),je=En(H.width,K.width),Ie=En(H.height,K.height),Xe=j3(H,je,Ie),mt=H.tailAnchor?OS(ke,Pe,je,Ie,H.tailAnchor,Xe):null,Qe=Math.max(1.5,K.height*.004),Tt=H.id===G;return d.jsx("path",{"data-testid":`balloon-${H.id}`,d:M3(ke,Pe,je,Ie,mt,Xe),className:`fill-white/95 ${Tt?"stroke-accent":"stroke-[#1a1a1a]"}`,strokeWidth:Tt?Qe+.5:Qe,strokeLinejoin:"round"},H.id)})}),K.width>0&&W.map(H=>{const ke=K.x+En(H.x,K.width),Pe=K.y+En(H.y,K.height),je=En(H.width,K.width),Ie=En(H.height,K.height),Xe=H.id===G,mt=H.type==="speech",Qe=H.type==="narration",Tt=!!Be[H.id];return d.jsxs("div",{"data-testid":`overlay-${H.id}`,"data-warning":Tt?"true":"false",onClick:qt=>vt(qt,H.id),onMouseDown:qt=>Ve(qt,H.id,"move"),className:`absolute rounded cursor-move select-none ${mt?"":`border-2 ${kM[H.type]}`} ${Qe?"bg-[#f4efe6]/85 rounded-md":""} ${Xe&&!mt?"ring-2 ring-accent":""} ${Tt?"ring-2 ring-amber-500":""}`,style:{left:ke,top:Pe,width:je,height:Ie},children:[(()=>{var Ee,Ue;const qt=H.type==="sfx"?v:b;if(!H.text)return d.jsx("span",{className:"text-[9px] px-1 text-muted truncate block pointer-events-none",style:{fontFamily:qt},children:yu[H.type]});const li=H.type!=="sfx"&&!!H.speaker;if(!P)return d.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-1 overflow-hidden pointer-events-none text-center break-words",style:{fontFamily:qt,fontSize:Math.max(9,Math.min(Ie*.05,16)),fontWeight:((Ee=H.textStyle)==null?void 0:Ee.fontWeight)??400},"data-testid":`overlay-text-${H.id}`,"data-fonts-ready":"false",children:li?`${H.speaker}: ${H.text}`:H.text});const oe=su(_e(qt),H.text,je,Ie,au(H,K.height,je,Ie));return d.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center px-1 overflow-hidden pointer-events-none text-center",style:{fontFamily:qt},"data-testid":`overlay-text-${H.id}`,"data-fonts-ready":"true",children:[li&&d.jsx("span",{className:"font-bold text-[#3a3a3a] block",style:{fontSize:oe.speakerFontSize,lineHeight:1.2},children:H.speaker}),d.jsx("span",{className:"text-[#1a1a1a]",style:{fontSize:oe.fontSize,lineHeight:`${oe.lineHeight}px`,fontWeight:((Ue=H.textStyle)==null?void 0:Ue.fontWeight)??400},children:oe.lines.map((Ye,ee)=>d.jsx("span",{className:"block",children:Ye},ee))})]})})(),Xe&&d.jsx("div",{onMouseDown:qt=>{qt.stopPropagation(),Ve(qt,H.id,"resize")},className:"absolute bottom-0 right-0 w-2 h-2 bg-accent cursor-se-resize","data-testid":`resize-${H.id}`})]},H.id)})]}),d.jsxs("div",{className:"w-64 border-l border-border p-3 overflow-y-auto flex-shrink-0",children:[d.jsxs("div",{className:"mb-3 rounded border border-accent/30 bg-accent/5 p-2 space-y-1.5","data-testid":"ai-draft-current-target",children:[d.jsx("p",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-accent",children:"AI draft assist"}),d.jsxs("p",{className:"text-[11px] text-muted",children:["Copy a prompt scoped to ",p??`cut ${t.id}`,". Review and edit any drafted bubbles here before saving."]}),d.jsx("button",{type:"button",onClick:Je,className:"rounded border border-accent/40 px-2 py-1 text-[11px] font-medium text-accent hover:bg-accent/10","data-testid":"copy-ai-lettering-current",children:V?"Copied!":"Copy AI draft prompt"})]}),xe.length>0&&d.jsxs("div",{className:"mb-3 space-y-1.5","data-testid":"script-insert-panel",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"From script"}),d.jsx("div",{className:"flex flex-col gap-1",children:xe.map(H=>d.jsxs("button",{onClick:()=>ze(H),"data-testid":`script-insert-${H.key}`,title:`Add ${H.type} overlay with this text`,className:"text-left px-2 py-1 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5",children:[d.jsxs("span",{className:"font-medium text-accent",children:["+ ",yu[H.type]]})," ",d.jsxs("span",{className:"text-muted",children:[H.speaker?`${H.speaker}: `:"",H.text.length>32?`${H.text.slice(0,32)}…`:H.text]})]},H.key))})]}),Ae?d.jsxs("div",{className:"space-y-3",children:[d.jsx("p",{className:"text-xs font-medium text-foreground",children:yu[Ae.type]}),Ae.speaker!==void 0&&d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Speaker"}),d.jsx("input",{value:Ae.speaker||"",onChange:H=>ye(Ae.id,{speaker:H.target.value}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",placeholder:"Character name","data-testid":"inspector-speaker"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Text"}),d.jsx("textarea",{value:Ae.text,onChange:H=>ye(Ae.id,{text:H.target.value}),rows:3,className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent resize-none focus:border-accent focus:outline-none",placeholder:"Overlay text","data-testid":"inspector-text"})]}),d.jsx("button",{onClick:()=>ye(Ae.id,Te(Ae)),"data-testid":"inspector-fit-text",className:"w-full px-2 py-1 text-[11px] border border-border rounded hover:border-accent hover:text-accent",title:"Resize this overlay so its text fits without overflowing",children:"Fit box to text"}),d.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-typography",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Typography"}),((ct=Ae.textStyle)==null?void 0:ct.mode)==="manual"?d.jsx("button",{type:"button",onClick:()=>ye(Ae.id,{textStyle:void 0}),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"inspector-text-auto",children:"Auto-fit"}):d.jsx("button",{type:"button",onClick:()=>rt(Ae),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":"inspector-text-manual",children:"Manual"})]}),((We=Ae.textStyle)==null?void 0:We.mode)==="manual"?d.jsxs("div",{className:"space-y-1.5",children:[d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Font size (% panel height)"}),d.jsx("input",{type:"number",step:"0.1",min:"1.5",max:"12",value:((Ae.textStyle.fontScale??.032)*100).toFixed(1),onChange:H=>ye(Ae.id,{textStyle:{...Ae.textStyle,mode:"manual",fontScale:Math.max(.015,Math.min(.12,(parseFloat(H.target.value)||3.2)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-font-scale"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Weight"}),d.jsxs("select",{value:String(Ae.textStyle.fontWeight??400),onChange:H=>ye(Ae.id,{textStyle:{...Ae.textStyle,mode:"manual",fontWeight:H.target.value==="700"?700:400}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-font-weight",children:[d.jsx("option",{value:"400",children:"Regular"}),d.jsx("option",{value:"700",children:"Bold"})]})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Line height"}),d.jsx("input",{type:"number",step:"0.05",min:"0.9",max:"2",value:(Ae.textStyle.lineHeightFactor??1.2).toFixed(2),onChange:H=>ye(Ae.id,{textStyle:{...Ae.textStyle,mode:"manual",lineHeightFactor:Math.max(.9,Math.min(2,parseFloat(H.target.value)||1.2))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-line-height"})]}),Ae.type!=="sfx"&&d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Speaker scale"}),d.jsx("input",{type:"number",step:"0.05",min:"0.5",max:"1.5",value:(Ae.textStyle.speakerScale??.8).toFixed(2),onChange:H=>ye(Ae.id,{textStyle:{...Ae.textStyle,mode:"manual",speakerScale:Math.max(.5,Math.min(1.5,parseFloat(H.target.value)||.8))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-speaker-scale"})]})]}):d.jsx("p",{className:"text-[10px] text-muted",children:"Auto-fit stays on by default and resizes text to the box."})]}),Ae.type==="speech"&&(()=>{const H=Ae.tailAnchor||{x:.5,y:1.2};return d.jsxs("div",{className:"space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Tail anchor"}),d.jsx("div",{className:"flex flex-wrap gap-1","data-testid":"inspector-tail-presets",children:EM.map(ke=>d.jsx("button",{type:"button",onClick:()=>ye(Ae.id,{tailAnchor:ke.anchor}),className:"px-1.5 py-0.5 text-[10px] border border-border rounded hover:border-accent hover:bg-accent/5","data-testid":`inspector-tail-${ke.key}`,children:ke.label},ke.key))}),d.jsxs("div",{className:"flex gap-2",children:[d.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["x",d.jsx("input",{type:"number",step:"0.1",value:H.x,onChange:ke=>ye(Ae.id,{tailAnchor:{...H,x:parseFloat(ke.target.value)||0}}),className:"w-14 px-1 py-0.5 text-[10px] border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-tail-x"})]}),d.jsxs("label",{className:"flex items-center gap-1 text-[10px] font-mono text-muted",children:["y",d.jsx("input",{type:"number",step:"0.1",value:H.y,onChange:ke=>ye(Ae.id,{tailAnchor:{...H,y:parseFloat(ke.target.value)||0}}),className:"w-14 px-1 py-0.5 text-[10px] border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-tail-y"})]})]})]})})(),Ae.type!=="sfx"&&d.jsxs("div",{className:"space-y-1.5 rounded border border-border/70 p-2","data-testid":"inspector-bubble-style",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Bubble controls"}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Padding X (% width)"}),d.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((Bt=Ae.bubbleStyle)==null?void 0:Bt.paddingX)??.06)*100).toFixed(0),onChange:H=>ye(Ae.id,{bubbleStyle:{...Ae.bubbleStyle,paddingX:Math.max(0,Math.min(.25,(parseFloat(H.target.value)||6)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-padding-x"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Padding Y (% height)"}),d.jsx("input",{type:"number",step:"1",min:"0",max:"25",value:((((pt=Ae.bubbleStyle)==null?void 0:pt.paddingY)??.08)*100).toFixed(0),onChange:H=>ye(Ae.id,{bubbleStyle:{...Ae.bubbleStyle,paddingY:Math.max(0,Math.min(.25,(parseFloat(H.target.value)||8)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-padding-y"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] text-muted",children:"Corner roundness (% short side)"}),d.jsx("input",{type:"number",step:"1",min:"0",max:"49",value:((((Mi=Ae.bubbleStyle)==null?void 0:Mi.cornerRadius)??.4)*100).toFixed(0),onChange:H=>ye(Ae.id,{bubbleStyle:{...Ae.bubbleStyle,cornerRadius:Math.max(0,Math.min(.49,(parseFloat(H.target.value)||40)/100))}}),className:"w-full px-2 py-1 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"inspector-corner-radius"})]})]}),d.jsxs("div",{className:"text-[10px] text-muted","data-testid":"inspector-font",children:["Font: ",Ae.type==="sfx"?x.family:_.family]}),d.jsxs("div",{className:"text-[10px] font-mono text-muted space-y-0.5",children:[d.jsxs("p",{children:["x: ",Ae.x.toFixed(3),", y: ",Ae.y.toFixed(3)]}),d.jsxs("p",{children:["w: ",Ae.width.toFixed(3),", h: ",Ae.height.toFixed(3)]})]}),d.jsx("button",{onClick:()=>{Q?bt(Ae.id):I(!0)},className:"w-full px-2 py-1 text-xs text-error border border-error/30 rounded hover:bg-error/5","data-testid":"delete-overlay",children:Q?"Click again to delete":"Delete"})]}):d.jsx("p",{className:"text-xs text-muted","data-testid":"inspector-empty",children:"Select an overlay to inspect."})]})]})]})}const FS=12e3,TM=5,jM=6e4,AM=6e4,RM=5;function MM(e,t){return e===429?!0:!!t&&/rate[\s-]?limit/i.test(t)}function DM(e,t=FS){return Math.min(t*2**e,jM)}const qS=e=>new Promise(t=>setTimeout(t,e));async function BM(e,t={}){var c;const i=t.sleep??qS,s=t.maxRetries??TM,a=t.baseDelayMs??FS;let o=0;for(;;){const h=await e();if(h.ok||!MM(h.status,h.errorMessage)||o>=s)return h;const p=DM(o,a);o+=1,(c=t.onWaiting)==null||c.call(t,{attempt:o,maxRetries:s,waitMs:p}),await i(p)}}function LM(e={}){const t=e.limit??RM,i=e.windowMs??AM,s=e.sleep??qS,a=e.now??(()=>Date.now()),o=[],c=()=>{const h=a()-i;for(;o.length&&o[0]<=h;)o.shift()};return async function(){var p;if(c(),o.length>=t){const f=o[0]+i-a();f>0&&((p=e.onWaiting)==null||p.call(e,{waitMs:f}),await s(f)),c()}o.push(a())}}const Dp=1024*1024;function uy(e,t,i){return new Promise((s,a)=>{e.toBlob(o=>o?s(o):a(new Error(`Failed to export as ${t}`)),t,i)})}async function OM(e){const t=[.9,.8,.7,.6];for(const s of t)try{const a=await uy(e,"image/webp",s);if(a.type!=="image/webp")break;if(a.size<=Dp)return a}catch{break}const i=[.85,.7,.5];for(const s of i){const a=await uy(e,"image/jpeg",s);if(a.size<=Dp)return a}throw new Error("Cannot compress image under 1MB — reduce overlay count or image size")}const zM=["image/webp","image/jpeg"];function WS(e){return zM.includes(e.type)&&e.size<=Dp}async function PM(e){var i;if(typeof createImageBitmap!="function")throw new Error("This browser cannot decode the image for import");let t;try{t=await createImageBitmap(e)}catch{throw new Error("Could not read the selected image — pick a PNG, WebP, or JPEG file")}try{const s=document.createElement("canvas");s.width=t.width,s.height=t.height;const a=s.getContext("2d");if(!a)throw new Error("Could not process the image for import");return a.drawImage(t,0,0),s}finally{(i=t.close)==null||i.call(t)}}async function qu(e){if(WS(e))return e;const t=await PM(e);return OM(t)}function IM(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.token=="string"&&t.token.length>0&&typeof t.name=="string"&&typeof t.size=="number"&&typeof t.mtimeMs=="number"}async function HM(e){let t;try{t=await e("/api/codex/images")}catch{return[]}if(!t.ok)return[];let i;try{i=await t.json()}catch{return[]}const s=i==null?void 0:i.images;return Array.isArray(s)?s.filter(IM):[]}async function UM(e,t){let i;try{i=await e(`/api/codex/images/${encodeURIComponent(t.token)}`)}catch{throw new Error("Could not read the generated image from the Codex cache")}if(!i.ok)throw new Error("Could not read the generated image from the Codex cache");const s=await i.blob(),a=s.type||i.headers.get("Content-Type")||"image/png";return new File([s],t.name||"codex-image.png",{type:a})}function $M(e,t){const[i,s]=w.useState(null);return w.useEffect(()=>{let a=null,o=!1;return(async()=>{try{const c=await t(e);if(!c.ok)return;const h=await c.blob();if(o)return;a=URL.createObjectURL(h),s(a)}catch{}})(),()=>{o=!0,a&&URL.revokeObjectURL(a)}},[e,t]),i}function FM(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function qM(e,t){const i=t-e;if(!Number.isFinite(i)||i<45e3)return"just now";const s=Math.round(i/6e4);if(s<60)return`${s}m ago`;const a=Math.round(i/36e5);if(a<24)return`${a}h ago`;const o=Math.round(i/864e5);return o<7?`${o}d ago`:`${Math.round(i/(7*864e5))}w ago`}function WM({image:e,authFetch:t}){const i=$M(`/api/codex/images/${encodeURIComponent(e.token)}`,t);return i?d.jsx("img",{src:i,alt:e.name,className:"w-16 h-16 flex-shrink-0 rounded border border-border object-cover bg-white"}):d.jsx("div",{className:"w-16 h-16 flex-shrink-0 rounded border border-border bg-surface"})}function GM({authFetch:e,cutId:t,onImport:i,onClose:s}){const[a,o]=w.useState(null),[c,h]=w.useState(null),[p,f]=w.useState(null),[_,x]=w.useState("");w.useEffect(()=>{let E=!1;return(async()=>{const z=await HM(e);E||o(z)})(),()=>{E=!0}},[e]);const b=_.trim().toLowerCase(),v=w.useMemo(()=>a?b?a.filter(E=>E.name.toLowerCase().includes(b)):a:[],[a,b]),y=Date.now(),N=async E=>{h(null),f(E.token);try{const z=await UM(e,E);await i(z)}catch(z){h(z instanceof Error?z.message:"Could not import the generated image")}finally{f(null)}},j=a!==null&&a.length>0;return d.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-2","data-testid":`codex-picker-${t}`,children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Import a Codex-generated image"}),d.jsx("button",{onClick:s,"data-testid":`codex-picker-close-${t}`,className:"text-[11px] text-muted hover:text-foreground",children:"Close"})]}),j&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"search",value:_,onChange:E=>x(E.target.value),placeholder:"Filter by file name…","data-testid":`codex-picker-search-${t}`,className:"min-w-0 flex-1 px-2 py-1 text-[11px] border border-border rounded bg-transparent focus:border-accent focus:outline-none"}),d.jsx("span",{className:"text-[10px] text-muted whitespace-nowrap","data-testid":`codex-picker-count-${t}`,children:b?`${v.length} of ${a.length}`:`${a.length} image${a.length===1?"":"s"}`})]}),a===null&&d.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-loading-${t}`,children:"Looking for generated images…"}),a!==null&&a.length===0&&d.jsx("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-empty-${t}`,children:"No generated images found in the Codex cache yet. Generate art in Codex, then reopen this list — or use “Upload clean image” to pick a file."}),j&&v.length===0&&d.jsxs("p",{className:"text-[11px] text-muted","data-testid":`codex-picker-no-match-${t}`,children:["No generated images match “",_.trim(),"”."]}),j&&v.length>0&&d.jsx("ul",{className:"space-y-1 max-h-72 overflow-y-auto",children:v.map(E=>d.jsxs("li",{"data-testid":`codex-image-${E.token}`,className:"flex items-center gap-2 rounded border border-border bg-background/40 p-1.5",children:[d.jsx(WM,{image:E,authFetch:e}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("p",{className:"text-[11px] text-foreground",children:[qM(E.mtimeMs,y)," · ",FM(E.size)]}),d.jsx("p",{className:"truncate text-[10px] font-mono text-muted",title:E.name,children:E.name})]}),d.jsx("button",{onClick:()=>N(E),disabled:p!==null,"data-testid":`codex-import-${E.token}`,className:"px-2 py-1 text-[11px] border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50",children:p===E.token?"Importing…":"Import to this cut"})]},E.token))}),c&&d.jsx("p",{className:"text-[11px] text-error",children:c})]})}const YM={done:"✓",current:"▸",todo:"○"};function KM({checklist:e,issues:t,onFinish:i,finishing:s,progressText:a,canFinish:o,markdownReady:c=!1,published:h=!1}){var N;if(!e||e.steps.length===0)return null;const p=US(t),f=((N=e.steps.find(j=>j.key==="upload"))==null?void 0:N.status)==="done",_=f&&c&&!h,x=h||c?"done":f?"current":"todo",b=h?"done":_?"current":"todo",v=[...e.steps.filter(j=>j.key!=="publish"),{key:"assemble",label:"Episode sequence prepared",status:x,detail:null},{key:"ready",label:h?"Published to PlotLink":"Ready to publish",status:b,detail:null}],y=s?a||"Finishing…":h?"Published ✓":_?"Episode ready to publish":"Finish episode";return d.jsxs("div",{className:"px-3 py-2 border-b border-border bg-surface/50 space-y-2 flex-shrink-0","data-testid":"finish-episode-panel",children:[d.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Finish episode"}),e.nextStep&&d.jsxs("span",{className:"text-[10px] text-muted truncate","data-testid":"finish-next-step",children:["Next: ",e.nextStep]})]}),d.jsx("ol",{className:"flex flex-wrap gap-1.5",children:v.map(j=>d.jsxs("li",{"data-testid":`finish-step-${j.key}`,"data-status":j.status,className:`flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${j.status==="current"?"border-accent/40 bg-accent/10 text-accent":j.status==="done"?"border-border bg-background/70 text-foreground":"border-border/70 bg-background/40 text-muted"}`,children:[d.jsx("span",{"aria-hidden":!0,children:YM[j.status]}),d.jsx("span",{children:j.label}),j.detail&&d.jsxs("span",{className:"text-muted",children:["· ",j.detail]})]},j.key))}),d.jsx("button",{onClick:i,disabled:s||!o,"data-testid":"finish-episode-btn",title:"Upload the exported final panels, then prepare the episode for publishing — picks up where it left off",className:"px-3 py-1 text-xs border border-accent/40 text-accent rounded hover:bg-accent/5 disabled:opacity-50",children:y}),p.length>0&&d.jsx("div",{className:"space-y-1.5","data-testid":"finish-issues",children:p.map(j=>d.jsxs("div",{"data-testid":`finish-issue-group-${j.key}`,className:"text-[10px]",children:[d.jsx("p",{className:"font-medium text-amber-700",children:j.title}),d.jsx("ul",{className:"ml-3 list-disc text-muted",children:j.lines.map((E,z)=>d.jsx("li",{children:E},z))})]},j.key))})]})}function VM(e){return{planned:e.filter(t=>t.state==="planned").length,needsConversion:e.filter(t=>t.state==="needs-conversion").length,missing:e.filter(t=>t.state==="missing").length,cleanReady:e.filter(t=>t.state==="clean-ready").length,finalReady:e.filter(t=>t.state==="final-ready").length,uploaded:e.filter(t=>t.state==="uploaded").length}}function GS(e){return e.uploadedCid?"uploaded":e.finalImagePath||e.exportedAt?"lettered":e.cleanImagePath?"clean":ar(e)?"text":"missing"}const hy={muted:"text-muted",amber:"text-amber-700",green:"text-green-700",accent:"text-accent"},XM={muted:"bg-muted/40",amber:"bg-amber-500",green:"bg-green-600",accent:"bg-accent"};function ZM(e,t,i){var s;return e.uploadedCid||e.uploadedUrl?{key:"uploaded",label:"Uploaded",tone:"green"}:t?{key:"convert",label:"Needs conversion",tone:"amber"}:i?e.finalImagePath?{key:"review",label:"Needs review",tone:"amber"}:{key:"needs-image",label:"Needs image",tone:"muted"}:e.finalImagePath?{key:"exported",label:"Exported",tone:"green"}:ar(e)?{key:"text",label:"Ready for captions",tone:"accent"}:e.cleanImagePath?(((s=e.overlays)==null?void 0:s.length)??0)>0?{key:"review",label:"Needs review",tone:"amber"}:{key:"letter",label:"Ready for lettering",tone:"green"}:{key:"needs-image",label:"Needs image",tone:"muted"}}function QM(e){var t;return e.uploadedCid||e.uploadedUrl?{label:"Complete",detail:"Final image uploaded",tone:"green"}:e.finalImagePath||e.exportedAt?{label:"Exported",detail:"Ready to upload",tone:"green"}:(((t=e.overlays)==null?void 0:t.length)??0)>0?{label:"Draft saved",detail:`${e.overlays.length} overlay${e.overlays.length===1?"":"s"} placed`,tone:"amber"}:ar(e)?{label:"Between-scene card",detail:"Open to add narration or title text",tone:"accent"}:e.cleanImagePath?{label:"Unlettered",detail:"Clean art ready for bubble placement",tone:"muted"}:{label:"Needs artwork",detail:"Add or sync clean art first",tone:"muted"}}function JM({cut:e,storyName:t,plotFile:i,expanded:s,onToggle:a,authFetch:o,onUpdated:c,onOpenEditor:h,detectedLocalClean:p,onSyncClean:f,syncing:_,staleMessages:x,onRepairStale:b,repairing:v,conversionPng:y,onConvert:N,converting:j,rowRef:E}){var ue;const z=w.useRef(null),[O,W]=w.useState(!1),[q,D]=w.useState(null),[te,de]=w.useState(!1),[_e,P]=w.useState(!1),[ae,G]=w.useState(!1),[Y,Q]=w.useState(!1),I=GS(e),A=x.length>0,B=!!y,U=w.useCallback(async()=>{y&&(Q(!0),await N(e.id,y),Q(!1),c())},[y,N,e.id,c]),ge=w.useCallback(async $=>{W(!0),D(null);try{let le=$;if(!WS($))try{le=await qu($)}catch(ze){return D(ze instanceof Error?ze.message:"Could not import image"),!1}const be=le.type==="image/jpeg"?"jpg":"webp",Te=new FormData;Te.append("file",new File([le],`clean.${be}`,{type:le.type}));const Le=await o(`/api/stories/${t}/cuts/${i}/upload-clean/${e.id}`,{method:"POST",body:Te});if(!Le.ok){const ze=await Le.json();return D(ze.error||"Upload failed"),!1}return c(),!0}catch{return D("Upload failed"),!1}finally{W(!1)}},[o,t,i,e.id,c]),T=ZM(e,B,A),R=e.cleanImagePath??y??null,V=((ue=e.overlays)==null?void 0:ue.length)??0,C=!ar(e)&&!!e.cleanImagePath&&!e.finalImagePath&&!e.uploadedCid&&!e.uploadedUrl&&!A&&!B,K=T.key==="convert"?{label:Y?"Converting…":"Convert image",onClick:U,testid:`card-convert-${e.id}`}:T.key==="review"?{label:"Review cut",onClick:h,testid:`card-review-${e.id}`}:T.key==="text"?{label:"Add captions",onClick:h,testid:`card-letter-${e.id}`}:T.key==="needs-image"?{label:"Add artwork",onClick:a,testid:`card-addart-${e.id}`}:null,re=QM(e);return d.jsxs("div",{ref:E,"data-cut-row":e.id,className:`border rounded ${s?"border-accent/30":"border-border"}`,children:[d.jsxs("div",{className:"px-3 py-2 space-y-2","data-testid":`cut-card-${e.id}`,children:[d.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[d.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${XM[T.tone]}`}),d.jsxs("span",{className:"font-medium text-xs text-foreground",children:["Cut ",String(e.id).padStart(2,"0")]}),d.jsxs("span",{className:"font-mono text-[10px] text-muted",children:["· ",e.shotType]}),d.jsx("span",{className:`ml-auto text-[10px] font-medium flex-shrink-0 ${hy[T.tone]}`,"data-testid":`cut-card-status-${e.id}`,children:T.label})]}),R?d.jsx(Rp,{storyName:t,assetPath:R,authFetch:o,alt:`Cut ${e.id} artwork`,className:"w-full max-h-[32rem] object-contain rounded border border-border bg-white"}):d.jsx("div",{className:"w-full min-h-28 rounded border border-dashed border-border bg-surface/40 flex items-center justify-center text-[10px] text-muted","data-testid":`cut-card-noart-${e.id}`,children:ar(e)?"Text panel — no artwork needed":"No artwork yet"}),d.jsxs("div",{className:`rounded border border-border/70 bg-surface/50 px-2 py-1.5 text-[11px] ${hy[re.tone]}`,"data-testid":`lettering-review-state-${e.id}`,children:[d.jsx("span",{className:"font-semibold",children:re.label}),d.jsxs("span",{className:"text-muted",children:[" · ",re.detail]})]}),d.jsx("button",{onClick:a,"data-testid":`cut-desc-${e.id}`,className:"block w-full text-left text-[11px] text-muted hover:text-foreground",children:e.description||"No description"}),d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[C?d.jsx("button",{onClick:h,"data-testid":`add-bubbles-${e.id}`,className:"px-2.5 py-1 text-[11px] font-medium rounded bg-accent text-white hover:bg-accent-dim",children:V>0?"Review lettering":"Open focused editor"}):K?d.jsx("button",{onClick:K.onClick,disabled:T.key==="convert"&&(Y||j),"data-testid":K.testid,className:"px-2.5 py-1 text-[11px] font-medium rounded bg-accent text-white hover:bg-accent-dim disabled:opacity-50",children:K.label}):null,d.jsx("button",{onClick:a,"data-testid":`cut-details-${e.id}`,className:"px-2.5 py-1 text-[11px] rounded border border-border text-muted hover:border-accent hover:text-accent",children:s?"Hide details":"Open details"})]})]}),s&&d.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-border",children:[B&&d.jsxs("div",{className:"mt-2 rounded border border-amber-500/40 bg-amber-500/10 p-2 space-y-1","data-testid":`needs-conversion-${e.id}`,children:[d.jsx("p",{className:"text-[11px] text-amber-800",children:"This cut’s artwork is a PNG. Convert it to WebP so it can be lettered and published."}),d.jsx("button",{onClick:U,disabled:Y||j,"data-testid":`convert-cut-${e.id}`,className:"px-2 py-1 text-[11px] border border-amber-500/50 text-amber-800 rounded hover:bg-amber-500/20 disabled:opacity-50",children:Y?"Converting…":"Convert image"})]}),A&&!B&&d.jsxs("div",{className:"mt-2 rounded border border-error/40 bg-error/5 p-2 space-y-1","data-testid":`stale-asset-${e.id}`,children:[x.map(($,le)=>d.jsx("p",{className:"text-[11px] text-error",children:$},le)),d.jsx("button",{onClick:b,disabled:v,"data-testid":`repair-stale-${e.id}`,className:"px-2 py-1 text-[11px] border border-error/40 text-error rounded hover:bg-error/10 disabled:opacity-50",children:v?"Repairing…":"Clear stale path"})]}),!ar(e)&&d.jsxs("div",{className:"mt-2 space-y-2",children:[d.jsx("button",{onClick:()=>{navigator.clipboard.writeText(ay(e,i)),de(!0),setTimeout(()=>de(!1),2e3)},"data-testid":`copy-prompt-${e.id}`,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5",children:te?"Copied!":"Copy Codex task"}),d.jsx("input",{ref:z,type:"file",accept:"image/webp,image/jpeg,image/png",className:"hidden",onChange:$=>{var be;const le=(be=$.target.files)==null?void 0:be[0];le&&ge(le),$.target.value=""}}),d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsx("button",{onClick:()=>{var $;return($=z.current)==null?void 0:$.click()},disabled:O,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50",children:O?"Uploading...":e.cleanImagePath?"Replace clean image":"Upload clean image"}),d.jsx("button",{onClick:()=>G($=>!$),disabled:O,"data-testid":`import-codex-${e.id}`,className:"px-3 py-1.5 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50",children:ae?"Hide Codex images":"Import from Codex"})]}),ae&&d.jsx(GM,{authFetch:o,cutId:e.id,onImport:async $=>{await ge($)&&G(!1)},onClose:()=>G(!1)}),!e.cleanImagePath&&d.jsx("p",{className:"text-xs text-muted","data-testid":`clean-image-handoff-${e.id}`,children:"Generate this cut in Codex, then import the cached PNG with “Import from Codex” — or upload an image manually. Letter it next."}),I==="missing"&&d.jsxs("div",{className:"rounded border border-border bg-surface/60 p-2 space-y-1","data-testid":`ask-codex-${e.id}`,children:[d.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Generate this cut in Codex"}),d.jsxs("p",{className:"text-[10px] text-muted",children:["Copy the task below and paste it into Codex. Codex usually saves a PNG to its image cache — bring it into this cut with “Import from Codex” above (the PNG becomes a WebP automatically). If Codex instead writes a WebP/JPEG at"," ",d.jsxs("span",{className:"font-mono",children:["assets/",i,"/cut-",String(e.id).padStart(2,"0"),"-clean.webp"]}),", it’s picked up by “Sync clean images”."]}),d.jsx("button",{onClick:()=>{navigator.clipboard.writeText(ay(e,i)),P(!0),setTimeout(()=>P(!1),2e3)},"data-testid":`ask-codex-copy-${e.id}`,className:"px-2 py-1 text-[11px] border border-border rounded hover:border-accent hover:bg-accent/5",children:_e?"Copied!":"Copy Codex task"})]}),I==="missing"&&p&&d.jsx("button",{onClick:f,disabled:_,"data-testid":`found-local-clean-${e.id}`,className:"px-3 py-1.5 text-xs border border-green-700/40 text-green-700 rounded hover:bg-green-700/5 disabled:opacity-50",children:_?"Syncing...":"Found local clean image — sync to cut plan"}),q&&d.jsx("p",{className:"text-xs text-error mt-1",children:q})]}),(e.cleanImagePath||e.narration||e.dialogue.length>0||ar(e))&&d.jsx("button",{onClick:h,"data-testid":`open-editor-${e.id}`,className:"px-3 py-1.5 text-xs border border-accent/30 text-accent rounded hover:bg-accent/5",children:"Open editor"}),e.characters.length>0&&d.jsxs("p",{className:"text-xs text-muted",children:["Characters: ",e.characters.join(", ")]}),e.dialogue.length>0&&d.jsx("div",{className:"text-xs text-muted",children:e.dialogue.map(($,le)=>d.jsxs("p",{children:[d.jsxs("span",{className:"font-medium",children:[$.speaker,":"]})," ",$.text]},le))}),e.narration&&d.jsx("p",{className:"text-xs text-muted italic",children:e.narration})]})]})}function dy({storyName:e,fileName:t,authFetch:i,language:s,uploadRetry:a,onCutsChanged:o,focusRequest:c,onFocusHandled:h}){var Tt,qt,li;const[p,f]=w.useState(null),_=w.useRef(o);_.current=o;const x=w.useRef(h);x.current=h;const[b,v]=w.useState(!0),[y,N]=w.useState(null),[j,E]=w.useState(null),[z,O]=w.useState(null),[W,q]=w.useState(!1),[D,te]=w.useState([]),[de,_e]=w.useState(!1),[P,ae]=w.useState(""),[G,Y]=w.useState({markdownReady:!1,published:!1}),[Q,I]=w.useState(!1),[A,B]=w.useState(!1),[U,ge]=w.useState(!1),[T,R]=w.useState(null),[V,C]=w.useState(null),[K,re]=w.useState(new Set),[ue,$]=w.useState(new Map),[le,be]=w.useState(!1),[Te,Le]=w.useState(null),[ze,ye]=w.useState(!1),[rt,bt]=w.useState(null),wt=w.useRef(new Map),vt=w.useRef(null),Ve=t.replace(/\.md$/,"");w.useEffect(()=>{var oe;c&&vt.current!==c.seq&&(vt.current=c.seq,c.openEditor?O(c.cutId):(E(c.cutId),bt(c.cutId)),(oe=x.current)==null||oe.call(x))},[c]),w.useEffect(()=>{var Ee;if(rt==null)return;const oe=wt.current.get(rt);oe&&((Ee=oe.scrollIntoView)==null||Ee.call(oe,{behavior:"smooth",block:"center"}),bt(null))},[rt,p]);const Me=w.useCallback(async()=>{var oe;try{const Ee=await i(`/api/stories/${e}/cuts/${Ve}`);if(Ee.status===404){f(null);return}if(!Ee.ok){const Ye=await Ee.json();N(Ye.error||"Failed to load cuts");return}const Ue=await Ee.json();f(Ue),N(null);try{const Ye=await i(`/api/stories/${e}/${t}`);if(Ye.ok){const ee=await Ye.json(),me=typeof(ee==null?void 0:ee.content)=="string"?ee.content:"",Ce=Array.isArray(Ue==null?void 0:Ue.cuts)?Ue.cuts:[],ut=me.length>0&&IS(me,Ce).ready,ot=(ee==null?void 0:ee.status)==="published"||(ee==null?void 0:ee.status)==="published-not-indexed";Y({markdownReady:ut,published:ot})}else Y({markdownReady:!1,published:!1})}catch{Y({markdownReady:!1,published:!1})}(oe=_.current)==null||oe.call(_)}catch{N("Failed to load cuts")}finally{v(!1)}},[i,e,Ve,t]),Je=w.useCallback(async()=>{be(!1);try{const oe=await i(`/api/stories/${e}/cuts/${Ve}/detect-clean-images`);if(!oe.ok)return;const Ee=await oe.json();re(new Set(Array.isArray(Ee.detected)?Ee.detected:[]));const Ue=new Map,Ye=Ee.stale;if(Array.isArray(Ye))for(const ee of Ye){if(typeof(ee==null?void 0:ee.cutId)!="number"||typeof(ee==null?void 0:ee.message)!="string")continue;const me=Ue.get(ee.cutId)??[];me.push(ee.message),Ue.set(ee.cutId,me)}$(Ue),be(!0)}catch{}},[i,e,Ve]),It=w.useCallback(async()=>{Le(null);try{const oe=await i(`/api/stories/${e}/cuts/${Ve}/asset-diagnostics`);if(!oe.ok)return;const Ee=await oe.json();Le(Array.isArray(Ee.diagnostics)?Ee.diagnostics:null)}catch{}},[i,e,Ve]),Ae=w.useCallback(async()=>{ye(!0);try{await Promise.all([Me(),Je(),It()])}finally{ye(!1)}},[Me,Je,It]),ii=w.useCallback(async()=>{I(!0),C(null),te([]);try{const oe=await i(`/api/stories/${e}/cuts/${Ve}/sync-clean-images`,{method:"POST"}),Ee=await oe.json().catch(()=>({}));if(!oe.ok)C(Ee.error||"Sync failed");else{const Ue=Array.isArray(Ee.synced)?Ee.synced.length:0,Ye=Array.isArray(Ee.cleared)?Ee.cleared.length:0,ee=Array.isArray(Ee.rejected)?Ee.rejected:[];ee.length>0&&te(ee.map(Ce=>`Cut ${Ce.cutId}: ${Ce.reason}`));const me=[];Ue>0&&me.push(`Synced ${Ue}`),Ye>0&&me.push(`Cleared ${Ye} stale path${Ye===1?"":"s"}`),C(me.length>0?me.join(", "):"No new clean images"),await Me(),await Je(),await It()}}catch{C("Sync failed")}I(!1)},[i,e,Ve,Me,Je,It]),Ct=w.useCallback(async(oe,Ee)=>{try{const Ue=await i(MS(e,Ee));if(!Ue.ok)return!1;const Ye=await Ue.blob(),ee=await qu(new File([Ye],"clean.png",{type:Ye.type||"image/png"})),me=ee.type==="image/jpeg"?"jpg":"webp",Ce=new FormData;return Ce.append("file",new File([ee],`clean.${me}`,{type:ee.type})),(await i(`/api/stories/${e}/cuts/${Ve}/upload-clean/${oe}`,{method:"POST",body:Ce})).ok}catch{return!1}},[i,e,Ve]),pi=w.useCallback(async oe=>{ge(!0),R(null);let Ee=0;const Ue=[];for(const Ye of oe)await Ct(Ye.cutId,Ye.pngPath)?Ee++:Ue.push(Ye.cutId);await Ae(),ge(!1),R(Ue.length===0?`Converted ${Ee} image${Ee===1?"":"s"} to WebP`:`Converted ${Ee}; ${Ue.length} failed (Cut ${Ue.join(", ")}) — try Convert image on each`)},[Ct,Ae]),ne=w.useCallback(async()=>{var ee;if(!p)return;_e(!0),ae(""),te([]);const oe=p.cuts.filter(me=>me.finalImagePath&&!me.uploadedCid),Ee=[],Ue=LM({sleep:a==null?void 0:a.sleep,onWaiting:({waitMs:me})=>ae(`Upload limit reached — waiting ${Math.round(me/1e3)}s before continuing…`)});for(let me=0;me<oe.length;me++){const Ce=oe[me];ae(`Uploading cut ${Ce.id} (${me+1}/${oe.length})...`);try{const ut=Ce.finalImagePath.startsWith("assets/")?Ce.finalImagePath.slice(7):Ce.finalImagePath,ot=await i(`/api/stories/${e}/asset/${ut}`);if(!ot.ok){Ee.push(`Cut ${Ce.id}: failed to fetch asset`);continue}const tt=await ot.blob(),st=new FormData;st.append("file",tt,`cut-${Ce.id}.${tt.type==="image/webp"?"webp":"jpg"}`),await Ue();const it=await BM(async()=>{const Lt=await i("/api/publish/upload-plot-image",{method:"POST",body:st});if(Lt.ok){const{cid:Fi,url:Fn}=await Lt.json();return{ok:!0,status:Lt.status,cid:Fi,url:Fn}}const oi=await Lt.json().catch(()=>({}));return{ok:!1,status:Lt.status,errorMessage:oi.error}},{...a,onWaiting:({attempt:Lt,maxRetries:oi,waitMs:Fi})=>ae(`Cut ${Ce.id} rate-limited — waiting ${Math.round(Fi/1e3)}s before retry ${Lt}/${oi}...`)});if(!it.ok){Ee.push(`Cut ${Ce.id}: upload failed — ${it.errorMessage||"unknown"}`);continue}const{cid:kt,url:ht}=it;(await i(`/api/stories/${e}/cuts/${Ve}/set-uploaded/${Ce.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cid:kt,url:ht})})).ok||Ee.push(`Cut ${Ce.id}: failed to record upload`)}catch(ut){Ee.push(`Cut ${Ce.id}: ${ut instanceof Error?ut.message:"failed"}`)}}if(Ee.length>0){te(Ee),_e(!1),ae(""),Me();return}ae("Preparing episode for publishing…");const Ye=await i(`/api/stories/${e}/cuts/${Ve}/generate-markdown`,{method:"POST"});if(Ye.ok){const me=await Ye.json();((ee=me.warnings)==null?void 0:ee.length)>0&&te(me.warnings)}_e(!1),ae(""),Me()},[p,i,e,Ve,a,Me]),xe=w.useCallback(async()=>{B(!0),C(null);try{const oe=await i(`/api/stories/${e}/cuts/${Ve}/repair-asset-paths`,{method:"POST"}),Ee=await oe.json().catch(()=>({}));if(!oe.ok)C(Ee.error||"Repair failed");else{const Ue=Array.isArray(Ee.cleared)?Ee.cleared.length:0;C(Ue>0?`Cleared ${Ue} stale path${Ue===1?"":"s"}`:"No stale paths to clear"),await Me(),await Je()}}catch{C("Repair failed")}B(!1)},[i,e,Ve,Me,Je]),[Be,$e]=w.useState(!1),Ge=w.useCallback(async(oe,Ee=!0)=>{if(p){$e(!0);try{const Ue=p.cuts.reduce((ut,ot)=>Math.max(ut,ot.id),0)+1,Ye={id:Ue,shotType:"wide",description:"Text panel",characters:[],dialogue:[],narration:"",sfx:"",cleanImagePath:null,finalImagePath:null,exportedAt:null,uploadedCid:null,uploadedUrl:null,overlays:[],kind:"text",background:"#101820",aspectRatio:"4:5"},ee=[...p.cuts];ee.splice(Math.max(0,Math.min(oe,ee.length)),0,Ye);const me={...p,cuts:ee},Ce=await i(`/api/stories/${e}/cuts/${Ve}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(me)});if(Ce.ok)Ee?O(Ue):E(Ue),await Me();else{const ut=await Ce.json().catch(()=>({}));C(ut.error||"Could not add text panel")}}catch{C("Could not add text panel")}$e(!1)}},[p,i,e,Ve,Me]),Ot=w.useCallback(()=>Ge((p==null?void 0:p.cuts.length)??0,!0),[Ge,p]);if(w.useEffect(()=>{Me(),Je(),It()},[Me,Je,It]),b)return d.jsx("div",{className:"p-4 text-sm text-muted",children:"Loading cuts..."});if(y)return d.jsxs("div",{className:"p-4 space-y-2","data-testid":"cuts-error",children:[d.jsx("p",{className:"text-sm text-error font-medium",children:"Invalid cuts file"}),d.jsx("p",{className:"text-xs text-error",children:y}),d.jsxs("p",{className:"text-xs text-muted",children:[Ve,".cuts.json must follow the OWS v1 schema. Ask Claude to regenerate it using the v1 cuts schema from the cartoon writing instructions."]}),d.jsx("button",{onClick:Me,className:"text-xs text-accent hover:text-accent-dim",children:"Retry"})]});if(!p||p.cuts.length===0)return d.jsxs("div",{className:"p-4 text-center space-y-1",children:[d.jsx("p",{className:"text-sm text-muted",children:"No cuts yet"}),d.jsx("p",{className:"text-xs text-muted",children:"Ask Claude to create a cut plan for this episode."})]});const Mt=z!==null?p.cuts.find(oe=>oe.id===z):null;if(Mt)return d.jsx(NM,{storyName:e,cut:Mt,plotFile:Ve,language:s,authFetch:i,targetLabel:ar(Mt)?`Between-scene card ${Mt.id}`:`Cut ${String(Mt.id).padStart(2,"0")}`,returnOnSave:!0,onSave:async oe=>{const Ee={...p,cuts:p.cuts.map(Ye=>Ye.id===z?{...Ye,overlays:oe}:Ye)},Ue=await i(`/api/stories/${e}/cuts/${Ve}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ee)});if(!Ue.ok){const Ye=await Ue.json().catch(()=>({}));throw new Error(Ye.error||"Failed to save overlays")}},onExported:()=>Me(),onClose:()=>{O(null),Me()}});const ct=p.cuts.reduce((oe,Ee)=>{const Ue=GS(Ee);return oe[Ue]++,oe},{missing:0,clean:0,lettered:0,uploaded:0,text:0}),We=p.cuts.filter(oe=>!ar(oe)).length,Bt=p.cuts.filter(oe=>zS(oe)).map(oe=>oe.id),pt=iM({cuts:p.cuts,published:G.published}),Mi=((Tt=pt.steps.find(oe=>oe.key==="upload"))==null?void 0:Tt.status)==="done",H=p.cuts.some(oe=>oe.finalImagePath&&!oe.uploadedCid)||Mi&&!G.markdownReady,ke=(Te??[]).filter(oe=>oe.state==="needs-conversion"&&oe.convertiblePng).map(oe=>({cutId:oe.cutId,pngPath:oe.convertiblePng})),Pe=new Map(ke.map(oe=>[oe.cutId,oe.pngPath])),je=(Te??[]).filter(oe=>oe.state==="needs-conversion"&&oe.issue).map(oe=>oe.issue),Ie=t==="genesis.md"?"Genesis / Episode 1":`Episode ${parseInt(((qt=Ve.match(/\d+/))==null?void 0:qt[0])??"0",10)+1}`,Xe=typeof p.title=="string"?p.title:null,mt=p.cuts.filter(oe=>!ar(oe)),Qe={cuts:p.cuts.length,artwork:mt.filter(oe=>oe.cleanImagePath||Pe.has(oe.id)).length,converted:mt.filter(oe=>oe.cleanImagePath&&/\.(webp|jpe?g)$/i.test(oe.cleanImagePath)).length,lettered:p.cuts.filter(oe=>{var Ee;return(((Ee=oe.overlays)==null?void 0:Ee.length)??0)>0||!!oe.finalImagePath}).length,uploaded:p.cuts.filter(oe=>oe.uploadedCid||oe.uploadedUrl).length};return d.jsxs("div",{className:"h-full min-h-[22rem] flex flex-col overflow-hidden","data-testid":"cut-list-panel",children:[d.jsxs("div",{className:"px-3 py-2 border-b border-border flex-shrink-0","data-testid":"cut-board-header",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:"font-serif text-foreground truncate",children:Ie}),Xe&&d.jsxs("span",{className:"text-muted truncate",children:["· ",Xe]})]}),d.jsxs("div",{className:"mt-0.5 text-[10px] text-muted","data-testid":"cut-board-summary",children:[Qe.cuts," cuts · ",Qe.artwork," artwork found · ",Qe.converted," converted · ",Qe.lettered," lettered · ",Qe.uploaded," uploaded"]})]}),d.jsxs("details",{className:"border-b border-border flex-shrink-0","data-testid":"cut-advanced",children:[d.jsx("summary",{className:"px-3 py-1.5 text-[10px] text-muted cursor-pointer hover:text-foreground",children:"Technical details"}),d.jsxs("div",{className:"px-3 py-2 flex flex-wrap items-center gap-2 text-[10px]",children:[d.jsxs("span",{className:"font-mono text-muted",children:[p.cuts.length," cuts"]}),ct.missing>0&&d.jsxs("span",{className:"text-muted",children:[ct.missing," missing"]}),ct.clean>0&&d.jsxs("span",{className:"text-green-700",children:[ct.clean," clean"]}),ct.lettered>0&&d.jsxs("span",{className:"text-amber-700",children:[ct.lettered," lettered"]}),ct.uploaded>0&&d.jsxs("span",{className:"text-green-700",children:[ct.uploaded," uploaded"]}),ct.text>0&&d.jsxs("span",{className:"text-accent",children:[ct.text," text ",ct.text===1?"panel":"panels"]}),d.jsx("button",{onClick:async()=>{q(!0),te([]);try{const oe=await i(`/api/stories/${e}/cuts/${Ve}/generate-markdown`,{method:"POST"});if(oe.ok){const Ee=await oe.json();te(Ee.warnings||[])}}catch{}q(!1)},disabled:W,className:"ml-auto px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"generate-markdown-btn",title:"Build the publish-ready episode from the uploaded cut images",children:W?"Preparing…":"Prepare episode for publish"}),d.jsx("button",{onClick:Ot,disabled:Be,className:"px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"add-text-panel-btn",title:"Insert a narration/title card between art panels — a solid card exported as a final image panel, no drawing needed",children:Be?"Adding…":"Add narration/text panel"}),d.jsx("button",{onClick:Ae,disabled:ze,className:"px-2 py-0.5 border border-border text-muted rounded hover:border-accent hover:text-accent disabled:opacity-50","data-testid":"refresh-assets-btn",title:"Re-check the story folder for agent-generated images and report each cut's asset state — read only, nothing is uploaded or published",children:ze?"Checking…":"Refresh assets"}),d.jsx("button",{onClick:ii,disabled:Q,className:"px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"sync-clean-btn",children:Q?"Syncing...":"Sync clean images"}),d.jsx("button",{onClick:ne,disabled:de||!(p!=null&&p.cuts.some(oe=>oe.finalImagePath&&!oe.uploadedCid)),className:"px-2 py-0.5 border border-accent/30 text-accent rounded hover:bg-accent/5 disabled:opacity-50","data-testid":"upload-generate-btn",title:"Upload each cut's final lettered image, then prepare the episode for publishing",children:P||"Upload & Prepare for Publish"})]})]}),d.jsxs("div",{className:"px-3 py-2 border-b border-border bg-surface/40 flex-shrink-0","data-testid":"cartoon-workflow-help",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] text-muted",children:[d.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"1. Letter"}),d.jsx("span",{"aria-hidden":!0,children:"→"}),d.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"2. Export"}),d.jsx("span",{"aria-hidden":!0,children:"→"}),d.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"3. Upload"}),d.jsx("span",{"aria-hidden":!0,children:"→"}),d.jsx("span",{className:"rounded-full border border-border bg-background px-2 py-0.5 text-foreground",children:"4. Prepare episode for publish"})]}),d.jsxs("div",{className:"mt-1 text-[10px] text-muted",children:["Use ",d.jsx("span",{className:"text-accent",children:"Add narration/text panel"})," for a narration or title card. It becomes a solid card exported as a final image."]})]}),Bt.length>0&&d.jsxs("div",{className:"px-3 py-1.5 border-b border-amber-500/40 bg-amber-500/10 text-[10px] text-amber-700 flex-shrink-0","data-testid":"stale-bubble-export-warning",children:[Bt.length===1?"Cut":"Cuts"," ",Bt.join(", ")," ",Bt.length===1?"was":"were"," lettered with an older speech-bubble style whose tail can show a visible seam. Re-export ",Bt.length===1?"it":"them"," (open lettering → Export) and re-upload before publishing so the bubble tails are seamless."]}),le&&We>0&&ct.missing===0&&ue.size===0&&d.jsxs("div",{className:"px-3 py-1 border-b border-border bg-green-600/10 text-[10px] text-green-700 flex items-center gap-1 flex-shrink-0","data-testid":"clean-assets-ready",children:[d.jsx("span",{"aria-hidden":!0,children:"✓"}),d.jsxs("span",{children:["All ",We," clean image",We===1?"":"s"," present — clean-asset generation is complete. Ready for lettering in OWS."]})]}),V&&d.jsx("div",{className:"px-3 py-1 border-b border-border text-[10px] text-muted flex-shrink-0","data-testid":"sync-result",children:V}),ke.length>0&&d.jsxs("div",{className:"px-3 py-2 border-b border-amber-500/40 bg-amber-500/10 text-[11px] flex-shrink-0","data-testid":"convert-artwork",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsxs("span",{className:"font-medium text-amber-700","data-testid":"convert-artwork-count",children:[ke.length," PNG image",ke.length===1?"":"s"," found"]}),d.jsx("button",{onClick:()=>pi(ke),disabled:U,"data-testid":"convert-all-btn",className:"ml-auto px-2 py-0.5 border border-amber-500/50 text-amber-800 rounded hover:bg-amber-500/20 disabled:opacity-50",children:U?"Converting…":"Convert all to WebP"})]}),d.jsx("p",{className:"mt-1 text-[10px] text-muted",children:"PNG artwork is fine while drafting. Convert it before lettering/export so PlotLink can publish it safely."}),T&&d.jsx("p",{className:"mt-1 text-[10px] text-muted","data-testid":"convert-result",children:T}),je.length>0&&d.jsxs("details",{className:"mt-1","data-testid":"convert-technical-details",children:[d.jsx("summary",{className:"text-[10px] text-muted cursor-pointer",children:"Technical details"}),d.jsx("ul",{className:"mt-1 ml-3 list-disc text-[10px] text-muted",children:je.map((oe,Ee)=>d.jsx("li",{children:oe},Ee))})]})]}),Te&&Te.length>0&&(()=>{const oe=VM(Te),Ee=Te.filter(Ue=>Ue.state==="missing");return d.jsxs("div",{className:"px-3 py-1.5 border-b border-border bg-surface/40 text-[10px] flex-shrink-0","data-testid":"asset-diagnostics",children:[d.jsxs("span",{className:"text-muted","data-testid":"asset-diag-summary",children:["Assets: ",oe.uploaded," uploaded · ",oe.finalReady," final · ",oe.cleanReady," clean · ",oe.planned," planned",oe.needsConversion>0?` · ${oe.needsConversion} needs conversion`:"",oe.missing>0?` · ${oe.missing} missing`:""]}),Ee.length>0&&d.jsx("ul",{className:"mt-1 ml-3 list-disc text-error","data-testid":"asset-diag-issues",children:Ee.map(Ue=>d.jsx("li",{children:Ue.issue},Ue.cutId))})]})})(),d.jsx(KM,{checklist:pt,issues:D,onFinish:ne,finishing:de,progressText:P,canFinish:H,markdownReady:G.markdownReady,published:G.published}),d.jsxs("div",{className:"flex-1 min-h-56 overflow-y-auto p-3 space-y-3","data-testid":"lettering-review-board",children:[p.cuts.map((oe,Ee)=>{var Ue;return d.jsxs(w.Fragment,{children:[d.jsx(fy,{index:Ee,beforeLabel:Ee===0?"Episode opening":`After cut ${(Ue=p.cuts[Ee-1])==null?void 0:Ue.id}`,afterLabel:`Before cut ${oe.id}`,disabled:Be,onAdd:()=>Ge(Ee)}),d.jsx(JM,{cut:oe,storyName:e,plotFile:Ve,expanded:j===oe.id,onToggle:()=>E(j===oe.id?null:oe.id),authFetch:i,onUpdated:()=>{Me(),Je(),It()},onOpenEditor:()=>O(oe.id),detectedLocalClean:K.has(oe.id),onSyncClean:ii,syncing:Q,staleMessages:ue.get(oe.id)??[],onRepairStale:xe,repairing:A,conversionPng:Pe.get(oe.id)??null,onConvert:Ct,converting:U,rowRef:Ye=>{Ye?wt.current.set(oe.id,Ye):wt.current.delete(oe.id)}})]},oe.id)}),d.jsx(fy,{index:p.cuts.length,beforeLabel:`After cut ${(li=p.cuts[p.cuts.length-1])==null?void 0:li.id}`,afterLabel:"Episode ending",disabled:Be,onAdd:()=>Ge(p.cuts.length)})]})]})}function fy({index:e,beforeLabel:t,afterLabel:i,disabled:s,onAdd:a}){return d.jsxs("div",{className:"rounded border border-dashed border-border bg-surface/35 px-3 py-2 text-[11px] text-muted flex items-center gap-3","data-testid":`between-scene-slot-${e}`,children:[d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"font-medium text-foreground",children:"Between-scene lettering"}),d.jsxs("span",{className:"block truncate",children:[t," · ",i]})]}),d.jsx("button",{type:"button",onClick:a,disabled:s,className:"flex-shrink-0 rounded border border-accent/40 px-2.5 py-1 text-[11px] font-medium text-accent hover:bg-accent/5 disabled:opacity-50","data-testid":`add-between-scene-${e}`,children:"Add card"})]})}function xm({coach:e,onAction:t,className:i="",showEmptyState:s=!1}){const[a,o]=w.useState(null),c=a!==null&&a===(e==null?void 0:e.prompt);return e===void 0?null:e?d.jsx("div",{className:`m-3 rounded-lg border border-accent/40 bg-accent/10 px-4 py-3 shadow-sm ${i}`,"data-testid":"workflow-coach","data-stage":e.stageLabel,"data-action-kind":e.actionKind,"data-ui-action":e.uiAction??"",children:d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"inline-flex rounded-full bg-background px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.14em] text-accent","data-testid":"workflow-coach-stage",children:e.stageLabel}),d.jsxs("p",{className:"mt-1 text-sm text-foreground","data-testid":"workflow-coach-action",children:[d.jsx("span",{className:"font-semibold",children:"Next: "}),d.jsx("span",{children:e.action})]}),c&&d.jsx("p",{className:"mt-1 text-[11px] font-medium text-accent",children:"Prompt copied."})]}),e.actionKind==="agent"&&e.prompt?d.jsx("button",{onClick:()=>{var p;if(!e.prompt)return;const h=e.prompt;(p=navigator.clipboard)==null||p.writeText(h).then(()=>o(h)).catch(()=>{})},"data-testid":"workflow-coach-copy",className:"flex-shrink-0 rounded bg-accent px-4 py-2.5 text-sm font-bold text-white shadow-sm transition-colors hover:bg-accent-dim",children:"Next Action"}):e.actionKind==="ui"&&e.uiAction?d.jsx("button",{onClick:()=>t(e.uiAction,e.episodeFile),"data-testid":"workflow-coach-do",className:"flex-shrink-0 rounded bg-accent px-4 py-2.5 text-sm font-bold text-white shadow-sm transition-colors hover:bg-accent-dim",children:"Next Action"}):null]})}):s?d.jsx("div",{className:`m-3 rounded-lg border border-green-700/25 bg-green-950/5 px-4 py-3 ${i}`,"data-testid":"workflow-coach","data-state":"complete",children:d.jsxs("div",{className:"flex items-start gap-3",children:[d.jsx("span",{className:"rounded-full bg-green-700/10 px-2 py-1 text-[10px] font-bold uppercase tracking-[0.16em] text-green-700",children:"Complete"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-sm font-semibold text-foreground",children:"No next action available"}),d.jsx("p",{className:"mt-0.5 text-xs text-muted",children:"This workflow has no queued next step right now."})]})]})}):null}function eD({storyName:e,fileName:t,authFetch:i,refreshKey:s=0,onAction:a,showEmptyState:o=!1}){const[c,h]=w.useState(void 0),p=JSON.stringify([e,t??"",s]),[f,_]=w.useState(null);return f!==p&&(h(void 0),_(p)),w.useEffect(()=>{let x=!1;const b=t?`?focus=${encodeURIComponent(t)}`:"";return i(`/api/stories/${e}/progress${b}`).then(v=>v.ok?v.json():null).then(v=>{x||h((v==null?void 0:v.coach)??null)}).catch(()=>{}),()=>{x=!0}},[e,t,i,s]),d.jsx(xm,{coach:c,onAction:a,showEmptyState:o})}const tD=1024*1024,iD=["image/webp","image/jpeg"],nD="Cover: WebP or JPEG, max 1MB, 600×900 portrait recommended. Use clean cover art — avoid unreadable AI text or broken lettering.";function rD(e){return e.attached?{state:"attached",label:"Cover attached to your story.",tone:"success"}:e.invalid?{state:"invalid",label:"Cover file can't be used — must be WebP or JPEG, max 1MB.",tone:"error"}:e.hasSelectedCover?{state:"selected",label:"Cover selected — it will be uploaded when you publish.",tone:"accent"}:{state:"none",label:"No cover yet — add one before publishing (recommended).",tone:"muted"}}function py(e){return e.size>tD?"Image exceeds 1MB limit":iD.includes(e.type)?null:"Only WebP and JPEG images are accepted"}async function sD(e,t,i){const s=new FormData;s.append("file",i);const a=await e("/api/publish/upload-cover",{method:"POST",body:s});if(!a.ok)return null;const{cid:o}=await a.json();return!o||!(await e("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:t,coverCid:o})})).ok?null:o}function Bp(e){const t=e.match(/^#\s+(.+)$/m),i=t?t[1].trim():"";return i||null}function aD(e){return e.replace(/[-_]+/g," ").replace(/\s+/g," ").trim().split(" ").map(t=>t&&t[0].toUpperCase()+t.slice(1)).join(" ")}function Ao(e,t){const i=(e??"").trim().toLowerCase();if(!i)return!0;if(t==="genesis.md")return i==="genesis";const s=t.match(/^(plot-\d+)\.md$/);return s?i===s[1].toLowerCase()||/^plot-\d+$/.test(i):!1}function lD(e){const t=e.match(/^plot-(\d+)\.md$/);if(!t)return null;const i=t[1];return`Episode ${i.length<2?i.padStart(2,"0"):i}`}function Lp(e){const t=(e??"").trim();return!!(!t||/^(?:episode|ep|chapter|ch|part|pt|plot)\.?\s*[-–—:#]?\s*\d+$/i.test(t)||/^\d+$/.test(t)||/^plot[-_\s]?\d+$/i.test(t))}function _m(e){var s;const t=Bp(e.fileContent);if(t)return!Lp(t);const i=((s=e.episodeTitle)==null?void 0:s.trim())||null;return!!i&&!Lp(i)}function bm(e){const{fileName:t,fileContent:i,storySlug:s,structureContent:a,contentType:o,episodeTitle:c}=e,h=Bp(i);if(t==="genesis.md"){const p=a?Bp(a):null;return(h??p??aD(s)).slice(0,60)}if(h)return h.slice(0,60);if(o==="cartoon"){const p=c==null?void 0:c.trim(),f=lD(t);return((p||f)??t.replace(/\.md$/,"")).slice(0,60)}return t.replace(/\.md$/,"").slice(0,60)}function oD(e){return!!(e!=null&&e.txHash)&&(e==null?void 0:e.plotIndex)!=null&&e.plotIndex>0}function cD(e){return oD(e)&&(e==null?void 0:e.status)!=="published-not-indexed"}function my(e,t,i){if(e[t]==="cartoon"&&!i)return"cartoon"}function uD(e,t,i){return!(e!=="cartoon"||t||!i||i.startsWith("_new_"))}function Mf(e,t,i){if(e)return t[e]||i.get(e)||"fiction"}function Df(e){if(!e)return null;const t=Number(e);return Number.isFinite(t)?(t/1e18).toFixed(6):null}function hD(e){return!!e&&e.ready===!1}function dD(e){const t=Df(e.requiredBalance)??Df(e.creationFee),i=Df(e.ethBalance);return e.hasEnoughEth===!1&&t&&i?`Insufficient ETH: need at least ${t} ETH to publish; current balance is ${i} ETH.`+(e.address?` Top up the OWS wallet (${e.address}) and try again.`:" Top up the OWS wallet and try again."):e.error||"Publish preflight failed — the OWS wallet isn't ready to publish."}const fD={...ll,attributes:{...ll.attributes,img:["src","alt","title"]}},pD="https://ipfs.filebase.io/ipfs/";function mD(e){const t=[],i=/!\[([^\]]*)\]\(([^)]+)\)/g;let s;for(;(s=i.exec(e))!==null;)t.push({full:s[0],alt:s[1],url:s[2]});return t}function gD(e){const t=mD(e),i=[];for(const a of t)a.url.startsWith(pD)||i.push(`Non-IPFS image URL: ${a.url.length>60?a.url.slice(0,60)+"...":a.url}`);return e.match(/!\[[^\]]*\]\([^)]*$|!\[[^\]]*$(?!\])/gm)&&i.push("Malformed image markdown detected — check brackets and parentheses"),{count:t.length,warnings:i}}function xD({storyName:e,fileName:t,authFetch:i,onPublish:s,publishingFile:a,walletAddress:o,contentType:c="fiction",language:h,genre:p,isNsfw:f,hasGenesis:_=!1,onViewProgress:x,onOpenFile:b,onViewPublish:v}){const[y,N]=w.useState(null),[j,E]=w.useState(!1),[z,O]=w.useState("preview"),[W,q]=w.useState("publish"),[D,te]=w.useState("text"),[de,_e]=w.useState(null),P=w.useCallback((ie,Se)=>{O("edit"),_e(Ne=>({cutId:ie,openEditor:Se,seq:((Ne==null?void 0:Ne.seq)??0)+1}))},[]),[ae,G]=w.useState(""),[Y,Q]=w.useState(!1),[I,A]=w.useState(!1),[B,U]=w.useState(!1),[ge,T]=w.useState(null),[R,V]=w.useState(""),[C,K]=w.useState(""),[re,ue]=w.useState(!1),[$,le]=w.useState(null),[be,Te]=w.useState(0),[Le,ze]=w.useState(0),[ye,rt]=w.useState(null),[bt,wt]=w.useState(null),[vt,Ve]=w.useState(null),[Me,Je]=w.useState(0),It=w.useRef(null),Ae=w.useRef(!1),[ii,Ct]=w.useState(!1),[pi,ne]=w.useState(nl[0]),[xe,Be]=w.useState(Xr[0]),[$e,Ge]=w.useState(!1),[Ot,Mt]=w.useState(null),[ct,We]=w.useState(null),[Bt,pt]=w.useState(!1),[Mi,H]=w.useState(!1),[ke,Pe]=w.useState(!1),[je,Ie]=w.useState(null),[Xe,mt]=w.useState(!1),Qe=w.useRef(null),Tt=w.useRef(null),[qt,li]=w.useState(!1),[oe,Ee]=w.useState(null),[Ue,Ye]=w.useState(null),[ee,me]=w.useState("unknown"),Ce=w.useRef(!1),[ut,ot]=w.useState(!1),[tt,st]=w.useState(!1),[it,kt]=w.useState(null),[ht,Kt]=w.useState([]),[Lt,oi]=w.useState(null),Fi=w.useRef(null),Fn=w.useRef(null),qi=w.useCallback(async()=>{if(!e||!t){N(null);return}const ie=`${e}/${t}`,Se=Fn.current!==ie;Se&&(Fn.current=ie);try{const Ne=await i(`/api/stories/${e}/${t}`);if(Ne.ok){const Ze=await Ne.json();N(Ze),(Se||!Ae.current)&&(G(Ze.content??""),Se&&(A(!1),Ae.current=!1))}}catch{}},[e,t,i]);w.useEffect(()=>{E(!0),qi().finally(()=>E(!1))},[qi]),w.useEffect(()=>{if(!e||!t||z==="edit"&&I)return;const ie=setInterval(qi,3e3);return()=>clearInterval(ie)},[e,t,qi,z,I]);const[ni,jn]=w.useState(null),qn=c==="cartoon"&&t==="genesis.md";w.useEffect(()=>{if(!qn||!e){jn(null);return}let ie=!1;return i(`/api/stories/${e}/cuts/genesis`).then(Se=>Se.ok?Se.json():null).then(Se=>{ie||jn(Se?Mp(Se.cuts||[]):null)}).catch(()=>{ie||jn(null)}),()=>{ie=!0}},[qn,e,i]);const ri=c==="cartoon"&&!!t&&/^plot-\d+\.md$/.test(t);w.useEffect(()=>{if(!ri||!e||!t){le(null),Te(0),ze(0),rt(null);return}let ie=!1;const Se=t.replace(/\.md$/,"");return rt(null),(async()=>{try{const[Ne,Ze]=await Promise.all([i(`/api/stories/${e}/${t}`),i(`/api/stories/${e}/cuts/${Se}`)]);if(ie)return;if(!Ze.ok){le("error"),Te(0),ze(0),rt(null);return}const jt=await Ze.json(),_i=jt.cuts||[],Rn=Ne.ok?(await Ne.json()).content??"":"",un=HS(Rn,_i);ie||(le(un.stage),Te(un.awaitingCount),ze(un.totalCuts),rt(Mp(_i)),Ve(typeof jt.title=="string"?jt.title:null))}catch{ie||(le("error"),Te(0),ze(0),rt(null))}})(),()=>{ie=!0}},[ri,e,t,i,y==null?void 0:y.content,y==null?void 0:y.status,Me]),w.useEffect(()=>{if(!e){wt(null);return}let ie=!1;return i(`/api/stories/${e}/structure.md`).then(Se=>Se.ok?Se.json():null).then(Se=>{ie||wt((Se==null?void 0:Se.content)??null)}).catch(()=>{}),()=>{ie=!0}},[e,i]),w.useEffect(()=>{if(!e)return;const ie=bu(p);let Se=ie??"";if(!ie&&bt){const Ze=bt.match(/\*{0,2}genre\*{0,2}[:\s]+(.+)/i);Ze&&(Se=bu(Ze[1].replace(/\*+/g,"").trim())??"")}V(Se);let Ne=h&&Xr.find(Ze=>Ze.toLowerCase()===h.toLowerCase())||"";if(!Ne&&bt){const Ze=bt.match(/\*{0,2}language\*{0,2}[:\s]+(.+)/i);Ze&&(Ne=Xr.find(jt=>jt.toLowerCase()===Ze[1].replace(/\*+/g,"").trim().toLowerCase())||"")}K(Ne),ue(f??!1)},[e,p,h,f,bt]);const Vt=w.useCallback(ie=>{e&&i(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ie)}).catch(()=>{})},[e,i]),Wn=w.useCallback(async()=>{if(!(!e||!t)){Q(!0);try{(await i(`/api/stories/${e}/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:ae})})).ok&&(A(!1),Ae.current=!1,N(Se=>Se&&{...Se,content:ae}))}catch{}Q(!1)}},[e,t,i,ae]),ln=w.useCallback(async()=>{if(!e||!t)return;const ie=t.replace(/\.md$/,"");try{(await i(`/api/stories/${e}/cuts/${ie}/generate-markdown`,{method:"POST"})).ok&&(await qi(),Je(Ne=>Ne+1))}catch{}},[e,t,i,qi]),An=w.useCallback((ie,Se)=>{if(ie==="view-progress"){x==null||x();return}if(Se&&Se!==t){b==null||b(Se);return}switch(ie){case"open-cuts":case"open-lettering":case"upload":case"refresh-assets":O("edit"),te("cuts");break;case"generate-markdown":ln();break;case"publish":O("preview");break}},[t,x,b,ln]),ts=w.useCallback(ie=>{var Ze;const Se=(Ze=ie.target.files)==null?void 0:Ze[0];if(!Se)return;Ce.current=!0,Ee(null),Ye(null);const Ne=py(Se);if(Ne){Mt(null),We(jt=>(jt&&URL.revokeObjectURL(jt),null)),Qe.current&&(Qe.current.value=""),Ie(Ne),me("invalid");return}Mt(Se),We(jt=>(jt&&URL.revokeObjectURL(jt),URL.createObjectURL(Se))),Ie(null),me("selected")},[]),Jt=w.useCallback(async ie=>{var Ne;const Se=(Ne=ie.target.files)==null?void 0:Ne[0];if(Tt.current&&(Tt.current.value=""),!(!Se||!e)){Ce.current=!0,Ee(null),li(!0),Ie(null);try{let Ze;try{Ze=await qu(Se)}catch(hr){Mt(null),We(Ls=>(Ls&&URL.revokeObjectURL(Ls),null)),Ie(hr instanceof Error?hr.message:"Could not import image");return}const jt=Ze.type==="image/jpeg"?"jpg":"webp",_i=new File([Ze],`cover.${jt}`,{type:Ze.type}),Rn=new FormData;Rn.append("file",_i);const un=await i(`/api/stories/${e}/import-cover`,{method:"POST",body:Rn});if(!un.ok){const hr=await un.json().catch(()=>({}));Ie(hr.error||"Cover import failed");return}Mt(_i),We(hr=>(hr&&URL.revokeObjectURL(hr),URL.createObjectURL(_i))),Ye(null),me("selected"),Ie(null)}catch{Ie("Cover import failed")}finally{li(!1)}}},[e,i]),xn=w.useCallback(async ie=>{if(ie.size>1024*1024){kt("Image exceeds 1MB limit");return}if(!["image/webp","image/jpeg"].includes(ie.type)){kt("Only WebP and JPEG images are accepted");return}st(!0),kt(null);try{const Ne=new FormData;Ne.append("file",ie);const Ze=await i("/api/publish/upload-plot-image",{method:"POST",body:Ne});if(!Ze.ok){const _i=await Ze.json();throw new Error(_i.error||"Upload failed")}const jt=await Ze.json();Kt(_i=>[..._i,{cid:jt.cid,url:jt.url}])}catch(Ne){kt(Ne instanceof Error?Ne.message:"Upload failed")}finally{st(!1),Fi.current&&(Fi.current.value="")}},[i]),dl=w.useCallback(ie=>{var Ne;const Se=(Ne=ie.target.files)==null?void 0:Ne[0];Se&&xn(Se)},[xn]),Ar=w.useCallback(async()=>{if(y!=null&&y.storylineId){pt(!0),Ie(null),mt(!1);try{let ie;if(Ot){const Ne=new FormData;Ne.append("file",Ot);const Ze=await i("/api/publish/upload-cover",{method:"POST",body:Ne});if(!Ze.ok){const _i=await Ze.json();throw new Error(_i.error||"Cover upload failed")}ie=(await Ze.json()).cid}const Se=await i("/api/publish/update-storyline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storylineId:y.storylineId,...ie!==void 0&&{coverCid:ie},genre:pi,language:xe,isNsfw:$e})});if(!Se.ok){const Ne=await Se.json();throw new Error(Ne.error||"Update failed")}mt(!0),Mt(null),ie!==void 0&&(Pe(!0),We(Ne=>(Ne&&URL.revokeObjectURL(Ne),null)),me("unknown"),Qe.current&&(Qe.current.value="")),setTimeout(()=>mt(!1),3e3)}catch(ie){Ie(ie instanceof Error?ie.message:"Update failed")}finally{pt(!1)}}},[y==null?void 0:y.storylineId,Ot,pi,xe,$e,i]);w.useEffect(()=>{Ct(!1),Mt(null),We(null),Ie(null),mt(!1),H(!1),ot(!1),Kt([]),kt(null),Ee(null),Ye(null),me("unknown"),Ce.current=!1,te("text")},[e,t]),w.useEffect(()=>{if(t!=="genesis.md"||!e||!y||y.storylineId||y.status==="published"||y.status==="published-not-indexed"||Ce.current)return;let ie=!1;return(async()=>{try{const Se=await i(`/api/stories/${e}/cover-asset`);if(ie||!Se.ok)return;const Ne=await Se.json();if(ie)return;if(!(Ne!=null&&Ne.found)){me("none");return}if(!Ne.valid){Ye(Ne.error||"Detected cover asset is invalid and was not used"),me("invalid");return}const Ze=await i(`/api/stories/${e}/asset/${Ne.path.replace(/^assets\//,"")}`);if(ie||!Ze.ok)return;const jt=await Ze.blob(),_i=new File([jt],Ne.path.split("/").pop()||"cover.webp",{type:Ne.type});if(py(_i)||ie||Ce.current)return;Mt(_i),We(Rn=>(Rn&&URL.revokeObjectURL(Rn),URL.createObjectURL(_i))),Ee(Ne.path),me("detected")}catch{}})(),()=>{ie=!0}},[e,t,y,y==null?void 0:y.status,y==null?void 0:y.storylineId,i]),w.useEffect(()=>{if(!ii||!(y!=null&&y.storylineId))return;H(!1);const ie="https://plotlink.xyz";let Se=!1;return fetch(`${ie}/api/storyline/${y.storylineId}`).then(Ne=>Ne.ok?Ne.json():null).then(Ne=>{if(!Se){if(!Ne){Ie("Could not load current story metadata");return}if(Ne.genre){const Ze=bu(Ne.genre);Ze&&ne(Ze)}if(Ne.language){const Ze=Xr.find(jt=>jt.toLowerCase()===Ne.language.toLowerCase());Ze&&Be(Ze)}Ne.isNsfw!==void 0&&Ge(!!Ne.isNsfw),Pe(!!(Ne.coverCid||Ne.coverUrl||Ne.cover)),H(!0)}}).catch(()=>{Se||Ie("Could not load current story metadata")}),()=>{Se=!0}},[ii,y==null?void 0:y.storylineId]),w.useEffect(()=>{if(z!=="edit")return;const ie=Se=>{(Se.metaKey||Se.ctrlKey)&&Se.key==="s"&&(Se.preventDefault(),Wn())};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[z,Wn]),w.useEffect(()=>{if((y==null?void 0:y.status)!=="published-not-indexed"||!y.publishedAt)return;const ie=new Date(y.publishedAt).getTime(),Se=300*1e3,Ne=()=>{const jt=Math.max(0,Se-(Date.now()-ie));T(jt)};Ne();const Ze=setInterval(Ne,1e3);return()=>clearInterval(Ze)},[y==null?void 0:y.status,y==null?void 0:y.publishedAt]);const or=ge!==null&&ge<=0,_n=ge!==null&&ge>0?`${Math.floor(ge/6e4)}:${String(Math.floor(ge%6e4/1e3)).padStart(2,"0")}`:null;if(!e||!t)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:d.jsxs("div",{className:"text-center",children:[d.jsx("p",{className:"text-lg font-serif",children:"Select a file to preview"}),d.jsx("p",{className:"text-sm mt-1",children:"Click a story file in the sidebar"})]})});if(j&&!y)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted",children:"Loading..."});const ha=(z==="edit"?ae:(y==null?void 0:y.content)??"").length,Ji=t==="genesis.md",cr=t?/^plot-\d+\.md$/.test(t):!1,en=c==="cartoon"&&cr,on=c==="cartoon"&&Ji,da=on||en,Ei=(y==null?void 0:y.status)==="published"||(y==null?void 0:y.status)==="published-not-indexed",fa=on?ni?ni.total:null:en?$===null?null:Le:null,pa=rM({fileName:t??"",contentType:c,hasGenesis:_,isPublished:Ei,cutCount:fa,cutProgress:on?ni:null}),ma=(on||en)&&!Ei,Gn=ma?bm({fileName:t,fileContent:(y==null?void 0:y.content)??"",storySlug:e??"",structureContent:bt,contentType:"cartoon",episodeTitle:vt}):null,ga=!!Gn&&Ao(Gn,t),fl=en&&!Ei&&!_m({fileContent:(y==null?void 0:y.content)??"",episodeTitle:vt}),Yn=on&&!Ei?mm((y==null?void 0:y.content)??""):null,Io=!!Yn&&Yn.blockers.length>0,Ho="w-full max-w-[32rem] rounded-xl border px-3 py-3",Uo={muted:"text-muted",accent:"text-accent",error:"text-error",success:"text-green-700"},xa=ie=>{if(!on)return null;const Se=rD({hasSelectedCover:!!Ot,invalid:ee==="invalid",attached:ie});return d.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"cartoon-cover-status","data-state":Se.state,children:[d.jsx("span",{className:`text-[11px] font-medium ${Uo[Se.tone]}`,children:Se.label}),d.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cover-details",children:[d.jsx("summary",{className:"cursor-pointer select-none",children:"Cover tips"}),d.jsx("span",{className:"block mt-0.5","data-testid":"cartoon-cover-guidance",children:nD})]})]})},pl=ga||fl,Wu=()=>{if(!ma||!Gn)return null;const ie=Ji?"Story title":"Episode title";return d.jsxs("div",{className:"flex flex-col gap-0.5","data-testid":"publish-title-preview","data-raw":ga?"true":"false","data-blocked":pl?"true":"false",children:[d.jsxs("span",{className:"text-[11px] text-foreground",children:[d.jsxs("span",{className:"font-medium",children:[ie,":"]})," ",d.jsx("span",{className:pl?"text-error font-medium":"text-foreground",children:Gn})]}),ga?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename. ",Ji?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," before publishing."]}):fl?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",Gn,"” is a generic placeholder, not a reader-facing title, so it can’t be published. Set a real episode title in the cut plan (or add a “# Title” to the episode) — e.g. “Episode 01 — The Couple Coupon” — before publishing."]}):null]})},_a=()=>Yn?d.jsxs("div",{className:"flex flex-col gap-1 rounded border border-border bg-surface/50 p-2","data-testid":"cartoon-genesis-readiness","data-blocked":Io?"true":"false",children:[d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),d.jsx("span",{className:"text-[10px] text-muted","data-testid":"genesis-readiness-hint",children:"Genesis is the first thing readers see. Write it as the story opening/prologue, not a synopsis — set up the premise and stakes, then bridge into Episode 01."}),Yn.blockers.map((ie,Se)=>d.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:ie},`b-${Se}`)),Yn.warnings.map((ie,Se)=>d.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:ie},`w-${Se}`))]}):null,cn=Ji||cr?1e4:null,is=!Ei&&cn!==null&&ha>cn,ml=(y==null?void 0:y.content)??"",ur=Ei?{count:0,warnings:[]}:gD(ml),Rr=d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[d.jsx("textarea",{ref:It,value:ae,onChange:ie=>{G(ie.target.value),A(!0),Ae.current=!0},className:"flex-1 min-h-0 w-full resize-none px-4 py-3 text-sm leading-relaxed focus:outline-none",style:{fontFamily:'"Geist Mono", ui-monospace, monospace',background:"var(--paper-bg)",color:"var(--text)"},spellCheck:!1}),d.jsxs("div",{className:"px-3 py-1.5 border-t border-border flex items-center justify-between",children:[d.jsx("span",{className:"text-xs text-muted",children:I?"Unsaved changes":"No changes"}),d.jsx("button",{onClick:Wn,disabled:!I||Y,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:Y?"Saving...":"Save"})]})]});return d.jsxs("div",{className:"h-full flex flex-col",children:[d.jsxs("div",{className:"border-b border-border",children:[d.jsxs("div",{className:"px-3 py-1.5 flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-muted",children:[x&&d.jsx("button",{onClick:x,"data-testid":"view-progress-btn",className:"text-accent hover:underline font-sans",title:"Story progress overview",children:"← Progress"}),d.jsxs("span",{children:[e,"/",t]}),(y==null?void 0:y.status)==="published"&&d.jsx("span",{className:"text-green-700 font-medium",children:"Published"}),(y==null?void 0:y.status)==="published-not-indexed"&&d.jsx("span",{className:"text-amber-700 font-medium",title:y.indexError,children:"Published (not indexed)"}),(y==null?void 0:y.status)==="pending"&&d.jsx("span",{className:"text-amber-700 font-medium",children:"Pending"})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("span",{className:`text-xs font-mono ${is?"text-error font-medium":"text-muted"}`,children:[ha.toLocaleString(),cn!==null?`/${cn.toLocaleString()}`:" chars"]}),is&&d.jsxs("span",{className:"text-error text-xs font-medium",children:[(ha-cn).toLocaleString()," over limit"]})]})]}),d.jsxs("div",{className:"flex px-3 gap-1",children:[d.jsx("button",{onClick:()=>O("preview"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${z==="preview"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:"Preview"}),d.jsxs("button",{onClick:()=>O("edit"),className:`px-3 py-1 text-xs font-medium border-b-2 transition-colors ${z==="edit"?"border-accent text-accent":"border-transparent text-muted hover:text-foreground"}`,children:["Edit",I&&d.jsx("span",{className:"ml-1 text-amber-600",children:"*"})]})]})]}),c==="cartoon"&&e&&t&&d.jsx(eD,{storyName:e,fileName:t,authFetch:i,refreshKey:Me,onAction:An,showEmptyState:!0}),z==="preview"?en?d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[d.jsxs("div",{className:"flex gap-1 px-3 py-1 border-b border-border",children:[d.jsx("button",{"data-testid":"cartoon-mode-publish",onClick:()=>q("publish"),className:`px-2 py-0.5 text-[11px] rounded ${W==="publish"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Publish Preview"}),d.jsx("button",{"data-testid":"cartoon-mode-inspect",onClick:()=>q("inspect"),className:`px-2 py-0.5 text-[11px] rounded ${W==="inspect"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Cut Inspector"})]}),d.jsx("div",{className:"flex-1 min-h-0",children:W==="publish"?d.jsx(oM,{content:(y==null?void 0:y.content)??"",stage:$}):d.jsx(W3,{storyName:e,fileName:t,authFetch:i,onEditCut:P})})]}):d.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-6 py-4",style:{background:"var(--paper-bg)"},children:y!=null&&y.content?d.jsx("div",{className:"prose max-w-none",children:d.jsx(eS,{remarkPlugins:[iS,ES],rehypePlugins:[[AS,fD]],children:y.content})}):d.jsx("p",{className:"text-muted italic",children:"No content"})}):en?d.jsx("div",{className:"flex-1 min-h-[22rem] overflow-hidden",style:{background:"var(--paper-bg)"},children:d.jsx(dy,{storyName:e,fileName:t,authFetch:i,language:h,onCutsChanged:()=>Je(ie=>ie+1),focusRequest:de,onFocusHandled:()=>_e(null)})}):on?d.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",style:{background:"var(--paper-bg)"},children:[d.jsxs("div",{className:"flex gap-1 px-3 py-1 border-b border-border",children:[d.jsx("button",{"data-testid":"genesis-edit-mode-text",onClick:()=>te("text"),className:`px-2 py-0.5 text-[11px] rounded ${D==="text"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Opening text"}),d.jsx("button",{"data-testid":"genesis-edit-mode-cuts",onClick:()=>te("cuts"),className:`px-2 py-0.5 text-[11px] rounded ${D==="cuts"?"bg-accent text-white":"text-muted hover:text-foreground"}`,children:"Cuts"})]}),d.jsx("div",{className:"flex-1 min-h-0",children:D==="cuts"?d.jsx(dy,{storyName:e,fileName:t,authFetch:i,language:h,onCutsChanged:()=>Je(ie=>ie+1),focusRequest:de,onFocusHandled:()=>_e(null)}):Rr})]}):Rr,d.jsx("div",{className:"px-3 py-2 border-t border-border flex items-center justify-between",children:t==="structure.md"?d.jsx("p",{className:"text-muted text-xs italic","data-testid":"footer-guidance",children:pa}):(y==null?void 0:y.status)==="published-not-indexed"?d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:"text-amber-700",children:"Published on-chain but not indexed on PlotLink"}),!or&&d.jsx("button",{onClick:async()=>{if(!(!e||!t||!y.txHash)){U(!0);try{(await(await i("/api/publish/retry-index",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:e,fileName:t,txHash:y.txHash,content:y.content,storylineId:y.storylineId})})).json()).ok&&(await i(`/api/stories/${e}/${t}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:y.txHash,storylineId:y.storylineId,contentCid:"",gasCost:""})}),qi())}catch{}U(!1)}},disabled:B,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:B?"Retrying...":`Retry Index${_n?` (${_n})`:""}`}),cr&&d.jsx("button",{onClick:()=>{!e||!t||!window.confirm(`This episode is already on-chain — try “Retry Index” first.
135
+
136
+ Retry Publish creates a NEW on-chain transaction and a SECOND, permanent chapter on PlotLink (PlotLink content is immutable). Only do this if the chapter never appeared after indexing.
137
+
138
+ Create a new on-chain chapter anyway?`)||s==null||s(e,t,R,C,re)},disabled:!!a,"data-testid":"retry-publish-btn",className:"px-3 py-1 border border-border text-xs rounded hover:bg-surface disabled:opacity-50",children:a===t?"Publishing...":"Retry Publish"}),y.txHash&&d.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"})]}),d.jsx("p",{className:"text-muted text-xs",children:or?cr?"Index window expired. Use Retry Publish to create a new on-chain tx.":"Index window expired. Contact support or re-publish manually.":cr?"Try Retry Index first (available for 5 min after publish). If that fails, Retry Publish creates a new on-chain tx.":"Retry Index is available for 5 min after publish."}),y.indexError&&d.jsx("p",{className:"text-error text-xs",children:y.indexError})]}):(y==null?void 0:y.status)==="published"?d.jsxs("div",{className:"flex flex-col gap-2",children:[d.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:"text-green-700",children:"Published"}),y.storylineId&&d.jsx("a",{href:(()=>{var Ne;const ie=`https://plotlink.xyz/story/${y.storylineId}`;if(!cr)return ie;const Se=y.plotIndex!=null&&y.plotIndex>0?y.plotIndex:parseInt(((Ne=t==null?void 0:t.match(/^plot-(\d+)\.md$/))==null?void 0:Ne[1])??"1");return`${ie}/${Se}`})(),target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"View on PlotLink"}),y.txHash&&d.jsx("a",{href:`https://basescan.org/tx/${y.txHash}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted underline",children:"BaseScan"}),Ji&&o&&y.storylineId&&(!y.authorAddress||y.authorAddress.toLowerCase()===o.toLowerCase())&&d.jsx("button",{onClick:()=>Ct(ie=>!ie),className:"px-2 py-0.5 border border-border text-xs rounded hover:bg-surface",children:ii?"Close Edit":"Edit Story"})]}),ii&&Ji&&y.storylineId&&d.jsxs("div",{className:"border border-border rounded p-3 flex flex-col gap-3 bg-surface",children:[d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-xs font-medium text-foreground",children:"Cover Image"}),xa(ke),d.jsxs("div",{className:"flex items-start gap-3",children:[ct&&d.jsxs("div",{className:"relative",children:[d.jsx("img",{src:ct,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),d.jsx("button",{onClick:()=>{Mt(null),We(null),Ye(null),me("unknown"),Qe.current&&(Qe.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("input",{ref:Qe,type:"file",accept:"image/webp,image/jpeg",onChange:ts,className:"text-xs","data-testid":"cover-input"}),d.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"})]})]})]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("select",{value:pi,onChange:ie=>ne(ie.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:nl.map(ie=>d.jsx("option",{value:ie,children:ie},ie))}),d.jsx("select",{value:xe,onChange:ie=>Be(ie.target.value),className:"px-2 py-1.5 text-xs border border-border rounded bg-surface text-foreground",children:Xr.map(ie=>d.jsx("option",{value:ie,children:ie},ie))})]}),d.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:$e,onChange:ie=>Ge(ie.target.checked),className:"rounded border-border"}),"This story contains adult content (18+)"]}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{onClick:Ar,disabled:Bt||!Mi,className:"px-3 py-1 bg-accent text-white text-xs rounded hover:bg-accent-dim disabled:opacity-50",children:Bt?"Saving...":Mi?"Save Changes":"Loading..."}),Xe&&d.jsx("span",{className:"text-green-700 text-xs",children:"Updated!"}),je&&d.jsx("span",{className:"text-error text-xs",children:je})]})]})]}):d.jsxs("div",{className:"flex flex-col gap-2",children:[en&&ye&&ye.total>0&&d.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted","data-testid":"cartoon-status-summary",children:[d.jsxs("span",{children:["Cuts: ",d.jsx("span",{className:"text-foreground font-medium",children:ye.total})]}),d.jsxs("span",{children:["Clean: ",d.jsxs("span",{className:"text-foreground font-medium",children:[ye.withClean,"/",ye.needClean]})]}),d.jsxs("span",{children:["Lettered: ",d.jsxs("span",{className:"text-foreground font-medium",children:[ye.withText,"/",ye.total]})]}),d.jsxs("span",{children:["Uploaded: ",d.jsxs("span",{className:"text-foreground font-medium",children:[ye.uploaded,"/",ye.total]})]}),x&&d.jsx("button",{onClick:x,className:"ml-auto text-accent hover:underline","data-testid":"status-view-progress",children:"View progress →"})]}),on&&ni&&d.jsxs("div",{className:"text-xs text-muted","data-testid":"genesis-cuts-summary",children:["Episode 1 (Genesis) cuts: ",ni.total," planned",ni.total>0&&d.jsxs(d.Fragment,{children:[" ","· ",ni.withClean," clean"," ","· ",ni.withText," lettered"," ","· ",ni.exported," exported"," ","· ",ni.uploaded," uploaded"]})]}),(on||en)&&pa&&d.jsxs("div",{className:`${Ho} flex flex-col gap-1 border-border bg-surface/50`,"data-testid":"cartoon-not-started",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"rounded-full bg-background px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-muted",children:fa===0?"Not started":"Next step"}),d.jsx("span",{className:"text-xs font-medium text-foreground",children:on?"Genesis (Episode 1)":"Future episode"})]}),d.jsx("span",{className:"text-xs text-muted",children:pa})]}),cr&&!en&&z==="preview"&&d.jsxs("div",{children:[d.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:ut,onChange:ie=>ot(ie.target.checked),className:"rounded border-border"}),"Add illustrations in the plot"]}),ut&&d.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[d.jsxs("div",{className:"border-2 border-dashed border-border rounded p-3 flex flex-col items-center gap-1.5 cursor-pointer hover:border-accent transition-colors",onClick:()=>{var ie;return(ie=Fi.current)==null?void 0:ie.click()},onDragOver:ie=>{ie.preventDefault(),ie.stopPropagation()},onDrop:ie=>{var Ne;ie.preventDefault(),ie.stopPropagation();const Se=(Ne=ie.dataTransfer.files)==null?void 0:Ne[0];Se&&xn(Se)},children:[d.jsx("input",{ref:Fi,type:"file",accept:"image/webp,image/jpeg",onChange:dl,className:"hidden"}),d.jsx("span",{className:"text-xs text-muted",children:tt?"Uploading...":"Drop image here or click to browse"}),d.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB"})]}),it&&d.jsx("span",{className:"text-error text-xs",children:it}),ht.map((ie,Se)=>d.jsxs("div",{className:"border border-border rounded p-2 flex flex-col gap-1 bg-surface",children:[d.jsx("span",{className:"text-xs text-green-700",children:"Image uploaded! Copy the markdown below and paste it where you want the illustration to appear in your plot:"}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("code",{className:"flex-1 text-xs bg-background px-2 py-1 rounded font-mono break-all",children:["![Scene description](",ie.url,")"]}),d.jsx("button",{onClick:()=>{navigator.clipboard.writeText(`![Scene description](${ie.url})`),oi(Se),setTimeout(()=>oi(null),2e3)},className:"px-2 py-1 text-xs border border-border rounded hover:bg-surface shrink-0",children:Lt===Se?"Copied!":"Copy"})]})]},ie.cid))]})]}),Ji&&c!=="cartoon"&&!(z==="edit"&&D==="cuts")&&d.jsxs("div",{className:"flex flex-col gap-1.5","data-testid":"prepublish-cover",children:[d.jsxs("span",{className:"text-xs font-medium text-foreground",children:["Cover Image ",d.jsx("span",{className:"text-muted font-normal",children:"(optional)"})]}),xa(!1),d.jsxs("div",{className:"flex items-start gap-3",children:[ct&&d.jsxs("div",{className:"relative",children:[d.jsx("img",{src:ct,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),d.jsx("button",{onClick:()=>{Ce.current=!0,Ee(null),Ye(null),me("unknown"),Mt(null),We(ie=>(ie&&URL.revokeObjectURL(ie),null)),Qe.current&&(Qe.current.value="")},className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-error text-white rounded-full text-xs flex items-center justify-center",children:"x"})]}),d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("input",{ref:Qe,type:"file",accept:"image/webp,image/jpeg",onChange:ts,className:"text-xs","data-testid":"prepublish-cover-input"}),d.jsx("span",{className:"text-xs text-muted",children:"WebP/JPEG, max 1MB, 600x900px recommended"}),d.jsx("input",{ref:Tt,type:"file",accept:"image/png,image/webp,image/jpeg",onChange:Jt,className:"hidden","data-testid":"prepublish-cover-import-input"}),d.jsx("button",{type:"button",onClick:()=>{var ie;return(ie=Tt.current)==null?void 0:ie.click()},disabled:qt,className:"self-start px-2 py-1 text-xs border border-border rounded hover:border-accent hover:bg-accent/5 disabled:opacity-50","data-testid":"prepublish-cover-import",children:qt?"Importing…":"Import generated image (PNG ok)"}),Ot&&d.jsx("span",{className:"text-green-700 text-xs","data-testid":"prepublish-cover-will-upload",children:"This cover will be uploaded as the PlotLink storyline cover when you publish."}),oe&&d.jsxs("span",{className:"text-accent text-xs","data-testid":"prepublish-cover-detected",children:["Auto-detected generated cover ",oe," — pick a file to override."]}),Ue&&d.jsxs("span",{className:"text-amber-700 text-xs","data-testid":"prepublish-cover-detected-warning",children:[Ue," Use “Import generated image” below to convert/compress it, or pick a file."]}),c==="cartoon"&&ee==="none"&&!Ot&&d.jsxs("span",{className:"text-muted text-xs","data-testid":"prepublish-cover-none",children:["No generated cover detected. Create ",d.jsx("span",{className:"font-mono",children:"assets/cover.webp"})," or use “Import generated image” — it will be uploaded as the PlotLink storyline cover when you publish."]}),je&&d.jsx("span",{className:"text-error text-xs","data-testid":"prepublish-cover-error",children:je})]})]})]}),!da&&Wu(),!da&&_a(),!da&&d.jsxs("div",{className:"flex items-center gap-2",children:[Ji&&c!=="cartoon"&&d.jsxs(d.Fragment,{children:[d.jsxs("select",{value:R,"data-testid":"publish-genre-select",onChange:ie=>{V(ie.target.value),ie.target.value&&Vt({genre:ie.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${R?"border-border":"border-amber-500"}`,children:[!R&&d.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select genre"}),nl.map(ie=>d.jsx("option",{value:ie,children:ie},ie))]}),d.jsxs("select",{value:C,"data-testid":"publish-language-select",onChange:ie=>{K(ie.target.value),ie.target.value&&Vt({language:ie.target.value})},className:`px-2 py-1.5 text-xs border rounded bg-surface text-foreground ${C?"border-border":"border-amber-500"}`,children:[!C&&d.jsx("option",{value:"",disabled:!0,children:"Needs metadata — select language"}),Xr.map(ie=>d.jsx("option",{value:ie,children:ie},ie))]})]}),d.jsx("button",{onClick:async()=>{if(!e||!t)return;if(ur.count>0){const Se=`This plot contains ${ur.count} illustration(s). Content is immutable after publishing — image references cannot be changed or removed.
139
+
140
+ Please verify illustrations appear correctly in Preview before continuing.
141
+
142
+ Publish now?`;if(!window.confirm(Se))return}const ie=Ji?Ot:null;ie?await(s==null?void 0:s(e,t,R,C,re,ie))&&(Ce.current=!0,Ee(null),Ye(null),me("unknown"),Mt(null),We(Ne=>(Ne&&URL.revokeObjectURL(Ne),null)),Qe.current&&(Qe.current.value="")):s==null||s(e,t,R,C,re)},disabled:!!a||is||pl||Io||Ji&&(!R||!C)||en&&$!=="ready",className:"px-4 py-1.5 bg-accent text-white text-sm rounded hover:bg-accent-dim disabled:opacity-50 disabled:cursor-not-allowed",children:a===t?"Publishing...":"Publish to PlotLink"}),Ji&&c==="cartoon"&&(!R||!C)&&d.jsx("span",{className:"text-amber-600 text-xs","data-testid":"cartoon-metadata-needs-story-info",children:"Set the genre and language in Story Info before publishing"}),Ji&&c!=="cartoon"&&!R&&d.jsx("span",{className:"text-amber-600 text-xs","data-testid":"genre-needs-metadata",children:"Needs metadata — choose a genre before publishing"}),Ji&&c!=="cartoon"&&R&&!C&&d.jsx("span",{className:"text-amber-600 text-xs","data-testid":"language-needs-metadata",children:"Needs metadata — choose a language before publishing"}),is&&d.jsx("span",{className:"text-error text-xs",children:"Reduce content to publish"}),en&&$==="error"&&d.jsx("span",{className:"text-error text-xs","data-testid":"publish-disabled-reason",children:"Fix the issues below before publishing"}),en&&$==="planning"&&d.jsx("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:"Prepare the episode for publish to continue"}),en&&$==="awaiting-upload"&&d.jsxs("span",{className:"text-muted text-xs","data-testid":"publish-disabled-reason",children:["Upload all final images, then “Prepare episode for publish” — ",be," of ",Le," still need an uploaded image"]})]}),da&&d.jsx("button",{onClick:()=>v==null?void 0:v(),"data-testid":"cartoon-review-publish",className:"self-start rounded border border-accent/40 px-3 py-1 text-xs text-accent hover:bg-accent/5 transition-colors",children:"Review publish checklist →"}),ur.warnings.length>0&&d.jsx("div",{className:"flex flex-col gap-0.5",children:ur.warnings.map((ie,Se)=>d.jsx("span",{className:"text-amber-600 text-xs",children:ie},Se))}),Ji&&c!=="cartoon"&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted cursor-pointer",children:[d.jsx("input",{type:"checkbox",checked:re,onChange:ie=>{ue(ie.target.checked),Vt({isNsfw:ie.target.checked})},className:"rounded border-border"}),"This story contains adult content (18+)"]}),re&&d.jsx("span",{className:"text-xs text-amber-600",children:"Adult content will be hidden from the default browse view."})]})]})})]})}function _D(e){if(e.cover!=="present")return e.cover==="invalid"?"Replace the cover image - it must be a valid WebP or JPEG.":"Add a cover image before publishing.";const t=[];return e.metadata.language||t.push("language"),e.metadata.genre||t.push("genre"),e.metadata.title||t.push("title"),`Add the story ${t.join(" and ")||"details"} before publishing.`}function YS(e){const t=e.coach??null,i=e.metadata,s=e.setup.hasStructure,a=e.setup.hasGenesis,o=e.cover==="present",c=!i.title||!i.language||!i.genre,h=e.episodes.find(f=>!f.published)??null,p=!!h&&h.state!=="ready";return s?a?c?"story-info":p&&(t!=null&&t.episodeFile)?t.episodeFile:o?(t==null?void 0:t.episodeFile)??null:"story-info":"genesis.md":"whitepaper"}function bD({progress:e,onOpenStoryInfo:t}){return d.jsx("div",{className:"m-3 rounded-lg border border-accent/40 bg-accent/10 px-4 py-3 shadow-sm","data-testid":"story-info-cta",children:d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("span",{className:"inline-flex rounded-full bg-background px-2 py-0.5 text-[10px] font-bold uppercase tracking-[0.14em] text-accent",children:"Story info"}),d.jsxs("p",{className:"mt-1 text-sm text-foreground","data-testid":"story-info-next-action",children:[d.jsx("span",{className:"font-semibold",children:"Next: "}),d.jsx("span",{children:_D(e)})]})]}),d.jsx("button",{type:"button",onClick:t,disabled:!t,className:"flex-shrink-0 rounded bg-accent px-4 py-2.5 text-sm font-bold text-white shadow-sm transition-colors hover:bg-accent-dim disabled:cursor-not-allowed disabled:opacity-50","data-testid":"story-info-next-action-btn",children:"Next Action"})]})})}function KS({progress:e,onCoachAction:t,onOpenStoryInfo:i}){return YS(e)==="story-info"?d.jsx(bD,{progress:e,onOpenStoryInfo:i}):d.jsx(xm,{coach:e.coach??null,showEmptyState:!0,onAction:t})}function vD({storyName:e,authFetch:t,refreshKey:i=0,onCoachAction:s,onOpenStoryInfo:a}){const[o,c]=w.useState(void 0),h=JSON.stringify([e,i]),[p,f]=w.useState(null);return p!==h&&(c(void 0),f(h)),w.useEffect(()=>{let _=!1;return t(`/api/stories/${e}/progress`).then(x=>x.ok?x.json():null).then(x=>{_||c(yD(x)?x:null)}).catch(()=>{_||c(null)}),()=>{_=!0}},[e,t,i]),o===void 0?null:o?d.jsx(KS,{progress:o,onCoachAction:s,onOpenStoryInfo:a}):d.jsx(xm,{coach:null,showEmptyState:!0,onAction:s})}function yD(e){return!!e&&!!e.metadata&&!!e.setup&&Array.isArray(e.episodes)}function SD({storyName:e,authFetch:t,onOpenFile:i,onOpenStoryInfo:s,refreshKey:a=0}){const[o,c]=w.useState(null),[h,p]=w.useState(!0);return w.useEffect(()=>{let f=!1;return(async()=>{p(!0);try{const x=await t(`/api/stories/${e}/progress`),b=x.ok?await x.json():null;f||(c(b),p(!1))}catch{f||(c(null),p(!1))}})(),()=>{f=!0}},[e,t,a]),h?d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"progress-loading",children:"Loading progress…"}):!o||!o.metadata||!Array.isArray(o.episodes)?d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story progress."}):o.contentType==="cartoon"?d.jsx(jD,{progress:o,storyName:e,onOpenFile:i,onOpenStoryInfo:s}):d.jsx(MD,{progress:o,storyName:e,onOpenFile:i})}function uu({label:e,value:t,tone:i="muted"}){const s=i==="ok"?"text-green-700":i==="warn"?"text-amber-700":"text-muted";return d.jsxs("span",{className:"text-[11px]",children:[d.jsxs("span",{className:"text-muted",children:[e,": "]}),d.jsx("span",{className:`font-medium ${s}`,children:t})]})}function VS({progress:e}){const t=e.contentType==="cartoon",i=e.cover==="present"?"ok":e.cover==="invalid"?"warn":"muted";return d.jsxs("div",{className:"px-4 py-3 border-b border-border",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("h2",{className:"text-base font-serif text-foreground truncate",children:e.metadata.title||e.name}),d.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${t?"bg-accent/10 text-accent":"bg-surface text-muted"}`,children:t?"Cartoon":"Fiction"})]}),d.jsxs("div",{className:"mt-1.5 flex flex-wrap gap-x-3 gap-y-1",children:[d.jsx(uu,{label:"Language",value:e.metadata.language||"Needs metadata",tone:e.metadata.language?"muted":"warn"}),d.jsx(uu,{label:"Genre",value:e.metadata.genre||"Needs metadata",tone:e.metadata.genre?"muted":"warn"}),e.metadata.isNsfw!=null&&d.jsx(uu,{label:"Adult",value:e.metadata.isNsfw?"Yes (18+)":"No"}),t&&d.jsx(uu,{label:"Cover",value:e.cover==="present"?"Ready":e.cover==="invalid"?"Invalid":"Missing",tone:i})]})]})}const XS={published:"✓",done:"●",current:"◉","needs-action":"●","not-started":"○"},Mu={published:"text-green-700",done:"text-green-700",current:"text-accent","needs-action":"text-amber-700","not-started":"text-muted"},ZS={published:"Published",done:"Complete",current:"Current","needs-action":"Needs action","not-started":"Not started"},wD={done:"✓",current:"◓",todo:"○"},CD={done:"text-green-700",current:"text-accent",todo:"text-muted"};function QS({item:e}){return d.jsxs("div",{className:"flex items-baseline gap-2 text-[11px]","data-testid":"checklist-item","data-status":e.status,children:[d.jsx("span",{className:`${CD[e.status]} flex-shrink-0`,"aria-hidden":!0,children:wD[e.status]}),d.jsx("span",{className:e.status==="todo"?"text-muted":"text-foreground",children:e.label}),e.detail&&d.jsxs("span",{className:"text-muted",children:["· ",e.detail]})]})}function gy({index:e,title:t,status:i,items:s,fileName:a,openFile:o}){const c=d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsx("span",{className:`flex-shrink-0 ${Mu[i]}`,"aria-hidden":!0,children:XS[i]}),d.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",t]}),a&&d.jsx("span",{className:"text-[10px] text-muted truncate",children:a}),d.jsx("span",{className:`ml-auto text-[10px] font-medium ${Mu[i]} flex-shrink-0`,children:ZS[i]})]});return d.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":i,children:[o?d.jsx("button",{onClick:o,className:"w-full text-left rounded hover:bg-surface -mx-1 px-1 py-0.5","data-testid":`section-open-${e}`,children:c}):c,d.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:s.map((h,p)=>d.jsx(QS,{item:h},p))})]})}function kD(e,t){return e.published?"published":t?"current":e.state==="placeholder"?"not-started":(e.state==="blocked","needs-action")}function ED(e,t=!0){const i=e.checklist??[],s=[];if(e.kind==="genesis"&&s.push({label:"Opening text",status:t?"done":"todo"}),i.length===0)return s.push({label:"Cut plan",status:"todo"}),s.push({label:"Clean artwork",status:"todo"}),s;for(const a of i)s.push(ND(a));return s}function ND(e){return{label:e.label,status:e.status,detail:e.detail}}const TD={file:"genesis.md",label:"Episode 1 / Genesis",kind:"genesis",title:null,state:"placeholder",summary:"",published:!1,checklist:[],cuts:null};function jD({progress:e,storyName:t,onOpenFile:i,onOpenStoryInfo:s}){const a=e.metadata,o=e.setup.hasStructure,c=e.cover==="present",p=!a.title||!a.language||!a.genre||!c,f=YS(e),_=d.jsx(KS,{progress:e,onOpenStoryInfo:s,onCoachAction:(E,z)=>{E!=="view-progress"&&z&&i(t,z)}}),x=[{label:"Public title",status:a.title?"done":"todo",detail:a.title??null},{label:"Language",status:a.language?"done":"todo",detail:a.language??null},{label:"Genre",status:a.genre?"done":"todo",detail:a.genre??null},{label:"Cover image",status:c?"done":"todo",detail:e.cover==="invalid"?"Invalid — re-import":c?null:"Missing"}],b=f==="story-info"?"current":p?"needs-action":"done",v=o?"done":f==="whitepaper"?"current":"not-started",y=e.episodes.find(E=>E.kind==="genesis")??null,N=e.episodes.filter(E=>E.kind==="plot");let j=0;return d.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[d.jsx(VS,{progress:e}),d.jsx("div",{className:"border-b border-border","data-testid":"persistent-next-action",children:_}),d.jsx("p",{className:"px-4 pt-3 pb-1 text-[11px] font-medium text-muted uppercase tracking-wider",children:"Production Progress"}),d.jsx(gy,{index:++j,title:"Define Story Info",status:b,items:x}),d.jsx(gy,{index:++j,title:"Story Whitepaper",status:v,fileName:"structure.md",openFile:o?()=>i(t,"structure.md"):void 0,items:[{label:"Planning document",status:o?"done":"todo",detail:o?null:"Not written yet"}]}),y?d.jsx(Bf,{index:++j,ep:y,isActive:f===y.file,storyName:t,onOpenFile:i}):d.jsx(Bf,{index:++j,ep:TD,isActive:f==="genesis.md",openingDone:!1,canOpen:!1,storyName:t,onOpenFile:i}),N.map(E=>d.jsx(Bf,{index:++j,ep:E,isActive:f===E.file,storyName:t,onOpenFile:i},E.file)),d.jsxs("div",{className:"px-4 py-2 text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[d.jsxs("span",{children:[e.summary.published," published"]}),d.jsxs("span",{children:[e.summary.readyToPublish," ready"]}),e.summary.placeholders>0&&d.jsxs("span",{children:[e.summary.placeholders," not started"]}),e.summary.blocked>0&&d.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function Bf({index:e,ep:t,isActive:i,storyName:s,onOpenFile:a,openingDone:o=!0,canOpen:c=!0}){const h=kD(t,i),p=ED(t,o),f=t.title?`${t.label} · ${t.title}`:t.label,_=d.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[d.jsx("span",{className:`flex-shrink-0 ${Mu[h]}`,"aria-hidden":!0,children:XS[h]}),d.jsxs("span",{className:"text-xs font-medium text-foreground truncate",children:[e,". ",f]}),d.jsx("span",{className:"text-[10px] text-muted truncate",children:t.file}),d.jsx("span",{className:`ml-auto text-[10px] font-medium ${Mu[h]} flex-shrink-0`,children:ZS[h]})]});return d.jsxs("div",{className:"px-4 py-2.5 border-b border-border","data-testid":`workflow-section-${e}`,"data-status":h,children:[c?d.jsx("button",{onClick:()=>a(s,t.file),"data-testid":`progress-episode-${t.file}`,"data-state":t.state,className:"w-full text-left rounded hover:bg-surface -mx-1 px-1 py-0.5",children:_}):d.jsx("div",{"data-state":t.state,children:_}),d.jsx("div",{className:"mt-1.5 ml-1 flex flex-col gap-1 border-l border-border pl-3",children:p.map((x,b)=>d.jsx(QS,{item:x},b))})]})}const AD={published:"✓",ready:"●","in-progress":"◐",planning:"○",placeholder:"○",blocked:"✕",draft:"○"},xy={published:"text-green-700",ready:"text-green-700","in-progress":"text-accent",planning:"text-accent",placeholder:"text-muted",blocked:"text-error",draft:"text-muted"},RD={published:"Published",ready:"Ready","in-progress":"In progress",planning:"Planning",placeholder:"Not started",blocked:"Needs fixes",draft:"Draft"};function MD({progress:e,storyName:t,onOpenFile:i}){const[s,a]=w.useState(!1);return d.jsxs("div",{className:"h-full overflow-y-auto","data-testid":"story-progress-panel",children:[d.jsx(VS,{progress:e}),e.nextAction&&d.jsxs("div",{className:"px-4 py-2 border-b border-accent/30 bg-accent/5 text-xs space-y-1.5","data-testid":"progress-next-action",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium text-foreground",children:"Next: "}),d.jsx("span",{className:"text-muted",children:e.nextAction})]}),e.nextPrompt&&d.jsxs("div",{className:"flex items-start gap-1.5","data-testid":"progress-next-prompt",children:[d.jsx("code",{className:"flex-1 rounded border border-border bg-surface px-1.5 py-1 text-[10px] text-foreground break-words",children:e.nextPrompt}),d.jsx("button",{onClick:()=>{var o;e.nextPrompt&&((o=navigator.clipboard)==null||o.writeText(e.nextPrompt).then(()=>{a(!0)}).catch(()=>{}))},"data-testid":"copy-next-prompt",className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors flex-shrink-0",children:s?"Copied!":"Copy"})]})]}),d.jsxs("div",{className:"px-4 py-2 border-b border-border flex flex-col gap-1",children:[d.jsx(_y,{done:e.setup.hasStructure,label:"Story bible (structure.md)",onClick:e.setup.hasStructure?()=>i(t,"structure.md"):void 0}),d.jsx(_y,{done:e.setup.hasGenesis,label:"Genesis written",onClick:e.setup.hasGenesis?()=>i(t,"genesis.md"):void 0})]}),d.jsxs("div",{className:"px-4 py-2",children:[d.jsx("p",{className:"text-[11px] font-medium text-muted uppercase tracking-wider mb-1.5",children:"Chapters"}),e.episodes.length===0?d.jsx("p",{className:"text-xs text-muted italic","data-testid":"progress-no-episodes",children:"No chapters yet — write the Genesis to start."}):d.jsx("ol",{className:"flex flex-col gap-1",children:e.episodes.map(o=>d.jsx("li",{children:d.jsxs("button",{onClick:()=>i(t,o.file),"data-testid":`progress-episode-${o.file}`,"data-state":o.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:[d.jsx("span",{className:`mt-0.5 ${xy[o.state]}`,"aria-hidden":!0,children:AD[o.state]}),d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs font-medium text-foreground",children:o.label}),o.title&&d.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",o.title]}),d.jsx("span",{className:`ml-auto text-[10px] font-medium ${xy[o.state]}`,children:RD[o.state]})]}),d.jsx("span",{className:"block text-[11px] text-muted",children:o.summary})]})]})},o.file))})]}),d.jsxs("div",{className:"px-4 py-2 border-t border-border text-[11px] text-muted flex flex-wrap gap-x-3","data-testid":"progress-summary",children:[d.jsxs("span",{children:[e.summary.published," published"]}),e.summary.blocked>0&&d.jsxs("span",{className:"text-error",children:[e.summary.blocked," need fixes"]})]})]})}function _y({done:e,label:t,onClick:i}){const s=d.jsxs("span",{className:"flex items-center gap-2 text-xs",children:[d.jsx("span",{className:e?"text-green-700":"text-muted","aria-hidden":!0,children:e?"✓":"○"}),d.jsx("span",{className:e?"text-foreground":"text-muted",children:t})]});return i?d.jsx("button",{onClick:i,className:"text-left hover:underline",children:s}):d.jsx("div",{children:s})}const DD=[{key:"progress",label:"Progress"},{key:"story-info",label:"Story Info"},{key:"whitepaper",label:"Whitepaper"},{key:"genesis",label:"Genesis / Ep 1"},{key:"episodes",label:"Episodes"},{key:"publish",label:"Publish"}];function BD({storyTitle:e,active:t,onSelect:i}){return d.jsxs("div",{className:"flex-shrink-0 border-b border-border bg-surface/40","data-testid":"cartoon-workflow-nav",children:[d.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2",children:[d.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-accent",children:"Cartoon"}),d.jsx("span",{className:"text-xs font-serif text-foreground truncate",children:e})]}),d.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 overflow-x-auto",role:"tablist",children:DD.map(s=>{const a=s.key===t;return d.jsx("button",{role:"tab","aria-selected":a,"data-testid":`nav-tab-${s.key}`,"data-active":a,onClick:()=>i(s.key),className:`flex-shrink-0 rounded-full px-2.5 py-1 text-[11px] font-medium transition-colors ${a?"bg-accent text-white":"text-muted hover:text-foreground hover:bg-surface"}`,children:s.label},s.key)})})]})}function LD({storyName:e,authFetch:t,onSaved:i}){const[s,a]=w.useState(!0),[o,c]=w.useState(!1),[h,p]=w.useState(""),[f,_]=w.useState(""),[x,b]=w.useState(""),[v,y]=w.useState(""),[N,j]=w.useState(!1),[E,z]=w.useState("cartoon"),[O,W]=w.useState("unknown"),[q,D]=w.useState(!1),[te,de]=w.useState(!1),[_e,P]=w.useState(null),[ae,G]=w.useState(!1),[Y,Q]=w.useState(null),[I,A]=w.useState(!1),B=w.useRef(null);w.useEffect(()=>{let C=!1;return a(!0),c(!1),de(!1),P(null),(async()=>{try{const[K,re]=await Promise.all([t(`/api/stories/${e}`),t(`/api/stories/${e}/progress`)]);if(!K.ok){C||(c(!0),a(!1));return}const ue=await K.json(),$=re.ok?await re.json().catch(()=>null):null;if(C)return;p(ue.title??""),_(ue.description??""),b(bu(ue.genre)??""),y(ue.language&&Xr.find(le=>le.toLowerCase()===ue.language.toLowerCase())||""),j(!!ue.isNsfw),z(ue.contentType==="fiction"?"fiction":"cartoon"),W(($==null?void 0:$.cover)??"unknown"),a(!1)}catch{C||(c(!0),a(!1))}})(),()=>{C=!0}},[e,t]);const U=w.useCallback(async()=>{D(!0),de(!1),P(null);const C={title:h.trim(),description:f.trim(),genre:x,language:v,isNsfw:N};try{const K=await t(`/api/stories/${e}/publish-metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)});if(K.ok)de(!0),i==null||i({genre:x,language:v,isNsfw:N});else{const re=await K.json().catch(()=>({}));P(re.error||"Could not save story info.")}}catch{P("Could not save story info.")}D(!1)},[e,t,h,f,x,v,N,i]),ge=w.useCallback(async C=>{var re;const K=(re=C.target.files)==null?void 0:re[0];if(B.current&&(B.current.value=""),!!K){G(!0),P(null);try{let ue;try{ue=await qu(K)}catch(Le){P(Le instanceof Error?Le.message:"Could not import image");return}const $=ue.type==="image/jpeg"?"jpg":"webp",le=new File([ue],`cover.${$}`,{type:ue.type}),be=new FormData;be.append("file",le);const Te=await t(`/api/stories/${e}/import-cover`,{method:"POST",body:be});if(!Te.ok){const Le=await Te.json().catch(()=>({}));P(Le.error||"Cover import failed.");return}W("present"),Q(Le=>(Le&&URL.revokeObjectURL(Le),URL.createObjectURL(le)))}catch{P("Cover import failed.")}finally{G(!1)}}},[e,t]),T=w.useCallback(()=>{var K;const C=`Generate a cover image for this story (${h||e}) and save it as assets/cover.webp — portrait 600x900, WebP, under 1MB. Don't publish.`;(K=navigator.clipboard)==null||K.writeText(C).then(()=>{A(!0)}).catch(()=>{})},[h,e]);if(s)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"story-info-loading",children:"Loading story info…"});if(o)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load story info."});const R=O==="present"?"Cover set":O==="invalid"?"Invalid cover — re-import a WebP/JPEG under 1MB":"Missing cover",V=O==="present"?"text-green-700":O==="invalid"?"text-amber-700":"text-muted";return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"story-info-page",children:[d.jsx("h2",{className:"text-base font-serif text-foreground",children:"Story Info"}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"These details appear on PlotLink when the story is published."}),d.jsxs("div",{className:"mt-4 flex flex-col gap-4 max-w-xl",children:[d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Public title"}),d.jsx("input",{type:"text",value:h,onChange:C=>{p(C.target.value),de(!1)},"data-testid":"story-info-title",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),d.jsxs("label",{className:"flex flex-col gap-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Short description"}),d.jsx("textarea",{value:f,onChange:C=>{_(C.target.value),de(!1)},rows:3,"data-testid":"story-info-description",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none resize-y"})]}),d.jsxs("div",{className:"flex flex-wrap gap-4",children:[d.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Genre"}),d.jsxs("select",{value:x,onChange:C=>{b(C.target.value),de(!1)},"data-testid":"story-info-genre",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[d.jsx("option",{value:"",children:"Needs metadata"}),nl.map(C=>d.jsx("option",{value:C,children:C},C))]})]}),d.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Language"}),d.jsxs("select",{value:v,onChange:C=>{y(C.target.value),de(!1)},"data-testid":"story-info-language",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[d.jsx("option",{value:"",children:"Needs metadata"}),Xr.map(C=>d.jsx("option",{value:C,children:C},C))]})]}),d.jsxs("label",{className:"flex flex-col gap-1 min-w-[140px] flex-1",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Content type"}),d.jsx("span",{className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-surface text-muted","data-testid":"story-info-content-type",title:"Content type is locked after creation.",children:E==="cartoon"?"Cartoon · locked":"Fiction · locked"})]})]}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Cover image"}),d.jsxs("div",{className:"flex items-start gap-3",children:[Y&&d.jsx("img",{src:Y,alt:"Cover preview",className:"w-16 h-24 object-cover rounded border border-border"}),d.jsxs("div",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:`text-[11px] font-medium ${V}`,"data-testid":"story-info-cover-status",children:R}),d.jsx("span",{className:"text-[10px] text-muted",children:"WebP or JPEG, max 1MB, 600×900 recommended."}),d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("button",{type:"button",onClick:()=>{var C;return(C=B.current)==null?void 0:C.click()},disabled:ae,"data-testid":"story-info-import-cover",className:"rounded border border-border px-2.5 py-1 text-[11px] text-foreground hover:border-accent hover:text-accent transition-colors disabled:opacity-50",children:ae?"Importing…":"Import cover"}),d.jsx("button",{type:"button",onClick:T,"data-testid":"story-info-cover-prompt",className:"rounded border border-border px-2.5 py-1 text-[11px] text-muted hover:border-accent hover:text-accent transition-colors",children:I?"Copied!":"Ask agent for cover prompt"})]}),d.jsx("input",{ref:B,type:"file",accept:"image/*",onChange:ge,className:"hidden"})]})]})]}),d.jsxs("label",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"checkbox",checked:N,onChange:C=>{j(C.target.checked),de(!1)},"data-testid":"story-info-nsfw"}),d.jsx("span",{className:"text-xs text-foreground",children:"This story contains adult content (18+)"})]}),d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("button",{type:"button",onClick:U,disabled:q,"data-testid":"story-info-save",className:"rounded bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-dim transition-colors disabled:opacity-50",children:q?"Saving…":"Save Story Info"}),te&&d.jsx("span",{className:"text-[11px] text-green-700","data-testid":"story-info-saved",children:"Saved"}),_e&&d.jsx("span",{className:"text-[11px] text-error","data-testid":"story-info-error",children:_e})]})]})]})}function OD({storyName:e,authFetch:t,onOpenFile:i}){const[s,a]=w.useState(null),[o,c]=w.useState(!0);return w.useEffect(()=>{let h=!1;return(async()=>{c(!0);try{const f=await t(`/api/stories/${e}/progress`),_=f.ok?await f.json():null;h||(a(Array.isArray(_==null?void 0:_.episodes)?_.episodes:null),c(!1))}catch{h||(a(null),c(!1))}})(),()=>{h=!0}},[e,t]),o?d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"episodes-loading",children:"Loading episodes…"}):s?d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"episodes-page",children:[d.jsx("h2",{className:"text-base font-serif text-foreground",children:"Episodes"}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Genesis is Episode 1; each plot file is the next episode."}),s.length===0?d.jsx("p",{className:"mt-4 text-xs text-muted italic","data-testid":"episodes-empty",children:"No episodes yet — write the Genesis to start Episode 1."}):d.jsx("ol",{className:"mt-3 flex flex-col gap-1",children:s.map(h=>d.jsx("li",{children:d.jsx("button",{onClick:()=>i(e,h.file),"data-testid":`episodes-row-${h.file}`,"data-state":h.state,className:"w-full text-left flex items-start gap-2 rounded px-2 py-1.5 hover:bg-surface",children:d.jsxs("span",{className:"min-w-0 flex-1",children:[d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx("span",{className:"text-xs font-medium text-foreground",children:h.label}),h.title&&d.jsxs("span",{className:"text-[11px] text-muted truncate",children:["· ",h.title]}),d.jsx("span",{className:"ml-auto text-[10px] text-muted",children:h.file})]}),d.jsx("span",{className:"block text-[11px] text-muted",children:h.summary})]})})},h.file))})]}):d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load episodes."})}function zD({storyName:e,authFetch:t,onOpenFile:i,onOpenStoryInfo:s,onPublish:a,publishingFile:o,genre:c,language:h,isNsfw:p,refreshKey:f=0}){var vt,Ve;const[_,x]=w.useState(null),[b,v]=w.useState(!0),[y,N]=w.useState(!1),[j,E]=w.useState(null),[z,O]=w.useState(null),[W,q]=w.useState(null),[D,te]=w.useState(null),[de,_e]=w.useState(null),P=async()=>{try{const Me=await t(`/api/stories/${e}/cover-asset`),Je=Me.ok?await Me.json():null;if(!(Je!=null&&Je.found)||!Je.valid||!Je.path)return null;const It=await t(`/api/stories/${e}/asset/${String(Je.path).replace(/^assets\//,"")}`);if(!It.ok)return null;const Ae=await It.blob();return new File([Ae],String(Je.path).split("/").pop()||"cover.webp",{type:Je.type||Ae.type})}catch{return null}};w.useEffect(()=>{let Me=!1;return(async()=>{v(!0),N(!1);try{const It=await t(`/api/stories/${e}/progress`),Ae=It.ok?await It.json():null;if(Me)return;!Ae||!Array.isArray(Ae.episodes)?(N(!0),x(null)):x(Ae),v(!1)}catch{Me||(N(!0),x(null),v(!1))}})(),()=>{Me=!0}},[e,t,f]);const ae=((Ve=(vt=_==null?void 0:_.episodes)==null?void 0:vt.find(Me=>!Me.published))==null?void 0:Ve.file)??null,G=ae==="genesis.md",Y=JSON.stringify([ae??"",f]),[Q,I]=w.useState(null);if(Q!==Y&&(I(Y),O(null),q(null),te(null),_e(null)),w.useEffect(()=>{if(!ae)return;let Me=!1;const Je=ae.replace(/\.md$/,"");return(async()=>{var It;try{const Ae=[t(`/api/stories/${e}/${ae}`),t(`/api/stories/${e}/cuts/${Je}`)];G&&Ae.push(t(`/api/stories/${e}/structure.md`));const[ii,Ct,pi]=await Promise.all(Ae);if(Me)return;if(O(ii.ok?(await ii.json()).content??"":""),Ct.ok){const ne=await Ct.json();if(Me)return;q(Array.isArray(ne.cuts)?ne.cuts:[]),te(typeof ne.title=="string"?ne.title:null)}else q(null),te(null);_e(G&&pi&&pi.ok?((It=await pi.json())==null?void 0:It.content)??null:null)}catch{Me||(O(""),q(null),te(null),_e(null))}})(),()=>{Me=!0}},[ae,G,e,t,f]),b)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm","data-testid":"publish-page-loading",children:"Loading publish readiness…"});if(y||!_)return d.jsx("div",{className:"h-full flex items-center justify-center text-muted text-sm",children:"Could not load publish readiness."});const A=_.episodes.find(Me=>!Me.published);if(!A)return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[d.jsx("h2",{className:"text-base font-serif text-foreground",children:"Publish"}),d.jsx("p",{className:"mt-2 text-xs text-green-700","data-testid":"publish-all-done",children:_.episodes.length>0?"All episodes are published to PlotLink. Plan the next episode to continue.":"No episodes yet — write the Genesis (Episode 1) to begin."})]});const B=A.cuts,U=_.cover==="present",ge=[{label:"Opening text ready",status:"done"},{label:"Cut plan",status:B&&B.total>0?"done":"todo",detail:B?`${B.total} cut${B.total===1?"":"s"} planned`:"not started"},{label:"Clean images converted",status:B&&B.needClean>0&&B.withClean===B.needClean?"done":"todo",detail:B?`${B.withClean} / ${B.needClean}`:null},{label:"Cuts lettered",status:B&&B.total>0&&B.withText===B.total?"done":"todo",detail:B?`${B.withText} / ${B.total}`:null},{label:"Final images exported",status:B&&B.total>0&&B.exported===B.total?"done":"todo",detail:B?`${B.exported} / ${B.total}`:null},{label:"Final images uploaded",status:B&&B.total>0&&B.uploaded===B.total?"done":"todo",detail:B?`${B.uploaded} / ${B.total}`:null},{label:"Cover image",status:U?"done":"todo",detail:U?null:"recommended before publishing"},{label:"Publish to PlotLink",status:A.published?"done":"todo"}],T=A.state==="ready",R=A.state==="blocked",V=A.file==="genesis.md",C=!V||!!c&&!!h,K=!!o&&o===A.file,re=z!==null,ue=re?bm({fileName:A.file,fileContent:z??"",storySlug:e,structureContent:de,contentType:"cartoon",episodeTitle:D}):null,$=!!ue&&Ao(ue,A.file),le=!V&&re&&!_m({fileContent:z??"",episodeTitle:D}),be=$||le,Te=V&&re?mm(z??""):null,Le=!!Te&&Te.blockers.length>0,ze=!V&&re&&W!==null?HS(z??"",W):null,ye=ze&&ze.stage==="error"?ze.issues:[],bt=T&&C&&(re&&(V||W!==null))&&!be&&!Le&&!K&&!!a,wt=async()=>{if(!(!bt||!a)){E(null);try{const Me=V?await P():null;await a(e,A.file,c??"",h??"",!!p,Me)}catch{E("Publish could not be started. Please try again.")}}};return d.jsxs("div",{className:"h-full overflow-y-auto px-4 py-4","data-testid":"cartoon-publish-page",children:[d.jsxs("h2",{className:"text-base font-serif text-foreground",children:["Publish ",A.label]}),d.jsx("p",{className:"mt-0.5 text-[11px] text-muted",children:"Finalize this episode: convert, letter, export, upload, then publish to PlotLink."}),d.jsx("ul",{className:"mt-3 flex flex-col gap-1.5 max-w-xl","data-testid":"publish-checklist",children:ge.map((Me,Je)=>d.jsxs("li",{className:"flex items-baseline gap-2 text-xs","data-testid":"publish-check","data-status":Me.status,children:[d.jsx("span",{className:`flex-shrink-0 ${Me.status==="done"?"text-green-700":"text-muted"}`,"aria-hidden":!0,children:Me.status==="done"?"✓":"○"}),d.jsx("span",{className:Me.status==="done"?"text-foreground":"text-muted",children:Me.label}),Me.detail&&d.jsxs("span",{className:"text-muted",children:["· ",Me.detail]})]},Je))}),ue&&d.jsxs("div",{className:"mt-4 flex flex-col gap-0.5 max-w-xl","data-testid":"publish-title-preview","data-raw":$?"true":"false","data-blocked":be?"true":"false",children:[d.jsxs("span",{className:"text-[11px] text-foreground",children:[d.jsxs("span",{className:"font-medium",children:[V?"Story title":"Episode title",":"]})," ",d.jsx("span",{className:be?"text-error font-medium":"text-foreground",children:ue})]}),$?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-raw-error",children:["This would publish as a raw filename. ",V?"Add a real “# Title” heading to genesis.md":"Set a title in the cut plan (or add a “# Title” to the episode)"," before publishing."]}):le?d.jsxs("span",{className:"text-[10px] text-error","data-testid":"publish-title-episode-required",children:["“",ue,"” is a generic placeholder, not a reader-facing title, so it can’t be published. Set a real episode title in the cut plan (or add a “# Title” to the episode) — e.g. “Episode 01 — The Couple Coupon” — before publishing."]}):null]}),Te&&d.jsxs("div",{className:"mt-4 flex flex-col gap-1 rounded border border-border bg-surface/50 p-2 max-w-xl","data-testid":"cartoon-genesis-readiness","data-blocked":Le?"true":"false",children:[d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:"Story opening (Prologue)"}),d.jsx("span",{className:"text-[10px] text-muted","data-testid":"genesis-readiness-hint",children:"Genesis is the first thing readers see. Write it as the story opening/prologue, not a synopsis — set up the premise and stakes, then bridge into Episode 01."}),Te.blockers.map((Me,Je)=>d.jsx("span",{className:"text-[10px] text-error","data-testid":"genesis-readiness-blocker",children:Me},`b-${Je}`)),Te.warnings.map((Me,Je)=>d.jsx("span",{className:"text-[10px] text-amber-600","data-testid":"genesis-readiness-warning",children:Me},`w-${Je}`))]}),ye.length>0&&d.jsxs("div",{className:"mt-4 flex flex-col gap-2 rounded-xl border border-error/30 bg-error/5 px-3 py-3 max-w-xl","data-testid":"cartoon-publish-issues",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("span",{className:"rounded-full bg-error px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-white",children:"Before publish"}),d.jsx("span",{className:"text-xs font-medium text-foreground",children:"Finish these workflow steps"})]}),US(ye).map(Me=>d.jsx("div",{className:"rounded-lg border border-error/15 bg-background/70 px-2.5 py-2","data-testid":`cartoon-issue-group-${Me.key}`,children:d.jsx("span",{className:"text-[11px] font-medium text-foreground",children:Me.title})},Me.key)),d.jsxs("details",{className:"text-[10px] text-muted","data-testid":"cartoon-technical-details",children:[d.jsx("summary",{className:"cursor-pointer select-none",children:"Technical details"}),d.jsx("ul",{className:"mt-1 ml-3 list-disc",children:ye.map((Me,Je)=>d.jsx("li",{className:"font-mono break-words",children:Me},Je))})]})]}),d.jsxs("div",{className:"mt-4 flex flex-col gap-2 max-w-xl",children:[!U&&d.jsx("button",{onClick:s,"data-testid":"publish-add-cover",className:"self-start rounded border border-border px-3 py-1.5 text-xs text-foreground hover:border-accent hover:text-accent transition-colors",children:"Add a cover image (Story Info)"}),V&&!C&&d.jsx("button",{onClick:s,"data-testid":"publish-set-metadata",className:"self-start rounded border border-border px-3 py-1.5 text-xs text-foreground hover:border-accent hover:text-accent transition-colors",children:"Set genre & language (Story Info)"}),!T&&d.jsxs("button",{onClick:()=>i(e,A.file),"data-testid":"publish-open-episode",className:"self-start rounded border border-accent/40 px-3 py-1.5 text-xs text-accent hover:bg-accent/5 transition-colors",children:["Open ",A.label," to finish ",R?"and fix issues":"(letter / export / upload)"]}),d.jsx("button",{onClick:wt,disabled:!bt,"data-testid":"publish-cta",className:"self-start rounded bg-accent px-3 py-1.5 text-xs font-medium text-white hover:bg-accent-dim disabled:opacity-50 transition-colors",title:bt?void 0:"Finish the remaining steps above first",children:K?"Publishing…":`Publish ${A.label} to PlotLink`}),T?C?be||Le?d.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-title-blocked-reason",children:Le?"Fix the Story opening issues above before publishing.":"Set a real reader-facing title above before publishing."}):null:d.jsx("p",{className:"text-[11px] text-amber-700","data-testid":"publish-needs-metadata",children:"Set the genre and language in Story Info before publishing."}):d.jsx("p",{className:"text-[11px] text-muted","data-testid":"publish-blocked-reason",children:R?`Not publishable yet — ${A.summary.toLowerCase()}. Open the episode to fix the flagged cuts.`:`Not ready yet — ${A.summary.toLowerCase()}.`}),j&&d.jsx("p",{className:"text-[11px] text-error","data-testid":"publish-error",children:j})]}),d.jsxs("details",{className:"mt-4 max-w-xl","data-testid":"publish-technical-details",children:[d.jsx("summary",{className:"text-[11px] text-muted cursor-pointer hover:text-foreground",children:"Technical validation details"}),d.jsxs("div",{className:"mt-1 text-[10px] text-muted space-y-0.5",children:[d.jsxs("p",{children:["Episode file: ",d.jsx("span",{className:"font-mono",children:A.file})]}),d.jsxs("p",{children:["State: ",A.state," — ",A.summary]}),d.jsx("p",{children:"Per-cut production (cut plan, clean images, lettering, export, upload) happens in the episode’s cut workspace; open it above to finish any remaining step."})]})]})]})}function PD(e,t){var s;const i=[e.plots,e.chapters].filter(Boolean);for(const a of i){let c=t!=null?a.find(p=>p.plotIndex===t||p.index===t):void 0;if(!c&&a.length===1){const p=a[0];(!(p.plotIndex!=null||p.index!=null)||t==null)&&(c=p)}const h=(s=(c==null?void 0:c.title)??(c==null?void 0:c.name))==null?void 0:s.trim();if(h)return h}}function ID(e){var o;const{fileName:t,detail:i,plotIndex:s}=e;if(!i)return{ok:!0,checked:!1};if(t==="genesis.md"){const c=(o=i.title??i.name)==null?void 0:o.trim();return c?Ao(c,"genesis.md")?{ok:!1,checked:!0,publicTitle:c,reason:`PlotLink indexed the storyline title as “${c}”, a raw filename rather than the reader-facing title.`}:{ok:!0,checked:!0,publicTitle:c}:{ok:!0,checked:!1}}const a=PD(i,s);return a?Ao(a,t)||Lp(a)?{ok:!1,checked:!0,publicTitle:a,reason:`PlotLink indexed the episode title as “${a}”, a generic placeholder rather than a reader-facing episode title.`}:{ok:!0,checked:!0,publicTitle:a}:{ok:!0,checked:!1}}function HD(e){return`${e.reason??"PlotLink indexed a raw/generic public title for this publish."} Published metadata is immutable on-chain and cannot be edited — the next publish must use corrected, reader-facing metadata. (The webtoon pilot stays blocked until a publish indexes a real public title.)`}const JS="plotlink-panel-ratio",UD=.6,by=300,Lf=224,Of=6;function $D(){try{const e=localStorage.getItem(JS);if(e){const t=parseFloat(e);if(t>0&&t<1)return t}}catch{}return UD}function vy(e,t){if(t<=0)return e;const i=by/t,s=1-by/t;return i>=s?.5:Math.min(s,Math.max(i,e))}function FD({token:e,authFetch:t}){const[i,s]=w.useState(null),[a,o]=w.useState(null),[c,h]=w.useState(null),[p,f]=w.useState(null),[_,x]=w.useState(0),[b,v]=w.useState(""),[y,N]=w.useState(null),[j,E]=w.useState(null),[z,O]=w.useState($D),[W,q]=w.useState([]),[D,te]=w.useState(!1),[de,_e]=w.useState(""),[P,ae]=w.useState(""),[G,Y]=w.useState(""),[Q,I]=w.useState("English"),[A,B]=w.useState("normal"),[U,ge]=w.useState("claude"),[T,R]=w.useState(null),[V,C]=w.useState(!1),[K,re]=w.useState({}),[ue,$]=w.useState({}),[le,be]=w.useState(new Set),[Te,Le]=w.useState(new Set),[ze,ye]=w.useState({}),[rt,bt]=w.useState({}),[wt,vt]=w.useState({}),[Ve,Me]=w.useState({}),[Je,It]=w.useState({}),[Ae,ii]=w.useState({}),Ct=w.useRef(new Map),pi=w.useRef(new Map),ne=w.useRef(new Map),xe=w.useRef(new Map),Be=w.useRef(new Set),$e=w.useRef(null),Ge=w.useRef(null),Ot=w.useRef(!1);w.useEffect(()=>{t("/api/wallet").then(ee=>ee.ok?ee.json():null).then(ee=>{ee!=null&&ee.address&&E(ee.address)}).catch(()=>{})},[t]),w.useEffect(()=>{t("/api/agent/readiness").then(ee=>ee.ok?ee.json():null).then(ee=>{ee&&R(ee)}).catch(()=>{})},[t]),w.useEffect(()=>{try{localStorage.setItem(JS,String(z))}catch{}},[z]),w.useEffect(()=>{const ee=()=>{if(!Ge.current)return;const me=Ge.current.getBoundingClientRect().width-Lf-Of;O(Ce=>vy(Ce,me))};return window.addEventListener("resize",ee),ee(),()=>window.removeEventListener("resize",ee)},[]);const Mt=w.useCallback(()=>{_e(""),ae(""),Y(""),B("normal"),ge("claude"),te(!0)},[]),ct=w.useCallback(async(ee,me,Ce,ut)=>{const ot=de.trim();if(!ot)return;const tt=ee==="cartoon"?"codex":ut;try{const st=await t("/api/stories/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ot,description:P.trim()||void 0,language:me,genre:G||void 0,contentType:ee,agentMode:Ce,agentProvider:tt})});if(!st.ok)return;const it=await st.json();te(!1),ye(kt=>({...kt,[it.name]:ee})),bt(kt=>({...kt,[it.name]:me})),G&&vt(kt=>({...kt,[it.name]:G})),$(kt=>({...kt,[it.name]:tt})),Ce==="bypass"&&re(kt=>({...kt,[it.name]:!0})),s(it.name),o(null)}catch{}},[t,de,P,G]);w.useEffect(()=>{if(W.length===0)return;const ee=setInterval(async()=>{try{const me=await t("/api/stories");if(!me.ok)return;const Ce=await me.json(),ut=new Set(Ce.stories.filter(ot=>ot.name!=="_example").map(ot=>ot.name));for(const ot of ut)if(!Be.current.has(ot)&&W.length>0){const tt=W[0],st=Ct.current.get(tt)||"fiction",it=pi.current.get(tt)||"English",kt=ne.current.get(tt)||"normal",ht=xe.current.get(tt)||"claude";let Kt=!1;$e.current&&(Kt=await $e.current(tt,ot,{contentType:st,language:it,agentMode:kt,agentProvider:ht}).catch(()=>!1)),Kt&&(q(Lt=>Lt.slice(1)),Ct.current.delete(tt),pi.current.delete(tt),ne.current.delete(tt),xe.current.delete(tt),kt==="bypass"&&re(Lt=>{const oi={...Lt,[ot]:!0};return delete oi[tt],oi}),$(Lt=>{const oi={...Lt,[ot]:ht};return delete oi[tt],oi}),t(`/api/stories/${ot}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:st,language:it,agentMode:kt,agentProvider:ht})}).catch(()=>{})),s(ot),o(null)}Be.current=ut}catch{}},3e3);return()=>clearInterval(ee)},[t,W]),w.useEffect(()=>{t("/api/stories").then(ee=>{if(ee.ok)return ee.json()}).then(ee=>{ee!=null&&ee.stories&&(Be.current=new Set(ee.stories.filter(me=>me.name!=="_example").map(me=>me.name)))}).catch(()=>{})},[t]);const We=w.useCallback((ee,me)=>{s(ee),o(me),h(null)},[]),Bt=w.useRef(null),pt=w.useCallback(async ee=>{var me,Ce,ut,ot;Bt.current=ee,s(ee),o(null),h(null);try{const tt=await t(`/api/stories/${ee}`);if(tt.ok&&Bt.current===ee){const st=await tt.json();if(st.contentType==="cartoon")return;const it=st.files||[],ht=((me=it.map(Kt=>{var Lt;return{file:Kt.file,num:(Lt=Kt.file.match(/^plot-(\d+)\.md$/))==null?void 0:Lt[1]}}).filter(Kt=>Kt.num!=null).sort((Kt,Lt)=>parseInt(Lt.num)-parseInt(Kt.num))[0])==null?void 0:me.file)??((Ce=it.find(Kt=>Kt.file==="genesis.md"))==null?void 0:Ce.file)??((ut=it.find(Kt=>Kt.file==="structure.md"))==null?void 0:ut.file)??((ot=it[0])==null?void 0:ot.file);ht&&Bt.current===ee&&o(ht)}}catch{}},[t]),Mi=w.useCallback(ee=>{ee.preventDefault(),Ot.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const me=ut=>{if(!Ot.current||!Ge.current)return;const ot=Ge.current.getBoundingClientRect(),tt=ot.width-Lf-Of,st=ut.clientX-ot.left-Lf;O(vy(st/tt,tt))},Ce=()=>{Ot.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("mousemove",me),window.removeEventListener("mouseup",Ce)};window.addEventListener("mousemove",me),window.addEventListener("mouseup",Ce)},[]),H=w.useCallback(async(ee,me,Ce,ut,ot,tt)=>{var ht;f(me),v("Reading file..."),N(null);let st=!1,it=null,kt=!1;try{const Kt=await t(`/api/stories/${ee}/${me}`);if(!Kt.ok)throw new Error("Failed to read file");const Lt=await Kt.json(),oi=ze[ee];let Fi=null,Fn=null;if(me==="genesis.md")try{const Vt=await t(`/api/stories/${ee}/structure.md`);Vt.ok&&(Fi=(await Vt.json()).content??null)}catch{}else if(oi==="cartoon"&&me.match(/^plot-\d+\.md$/))try{const Vt=await t(`/api/stories/${ee}/cuts/${me.replace(/\.md$/,"")}`);Vt.ok&&(Fn=(await Vt.json()).title??null)}catch{}const qi=bm({fileName:me,fileContent:Lt.content,storySlug:ee,structureContent:Fi,contentType:oi,episodeTitle:Fn});if(oi==="cartoon"&&Ao(qi,me))return v(me==="genesis.md"?"Add a real “# Title” heading to genesis.md before publishing — it would otherwise publish as a raw filename.":"Set an episode title in the cut plan before publishing — it would otherwise publish as a raw filename."),setTimeout(()=>{f(null),v("")},6e3),!1;if(oi==="cartoon"&&me.match(/^plot-\d+\.md$/)&&!_m({fileContent:Lt.content,episodeTitle:Fn}))return v("Set a real episode title in the cut plan (or add a “# Title” to the episode) before publishing — a generic “Episode NN” placeholder can’t be published."),setTimeout(()=>{f(null),v("")},6e3),!1;if(oi==="cartoon"&&me==="genesis.md"){const Vt=mm(Lt.content).blockers;if(Vt.length>0)return v(`Genesis is the reader-facing Story opening — fix it before publishing: ${Vt[0]}`),setTimeout(()=>{f(null),v("")},6e3),!1}let ni;if(me.match(/^plot-\d+\.md$/)){if(cD(Lt)){v("Already published on PlotLink — republishing would create a duplicate chapter. Open it on PlotLink instead (or use Retry Index if it isn't showing yet)."),setTimeout(()=>{f(null),v("")},6e3);return}try{const Vt=await t(`/api/stories/${ee}`);if(Vt.ok){const ln=(await Vt.json()).files.find(An=>An.file==="genesis.md"&&An.storylineId);ni=ln==null?void 0:ln.storylineId}}catch{}if(!ni)return v("Error: Publish genesis first to create the storyline"),setTimeout(()=>{f(null),v("")},3e3),!1}v("Checking wallet balance...");try{const Vt=await t("/api/publish/preflight");if(Vt.ok){const Wn=await Vt.json();if(hD(Wn))return N(dD(Wn)),f(null),v(""),!1}}catch{}v("Publishing...");const jn=await t("/api/publish/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storyName:ee,fileName:me,title:qi,content:Lt.content,genre:Ce,language:ut,isNsfw:ot,storylineId:ni,...my(ze,ee,ni)?{contentType:my(ze,ee,ni)}:{}})});if(!jn.ok){const Vt=await jn.json();throw new Error(Vt.error||"Publish failed")}const qn=(ht=jn.body)==null?void 0:ht.getReader(),ri=new TextDecoder;if(qn)for(;;){const{done:Vt,value:Wn}=await qn.read();if(Vt)break;const An=ri.decode(Wn).split(`
143
+ `).filter(ts=>ts.startsWith("data: "));for(const ts of An)try{const Jt=JSON.parse(ts.slice(6));if(Jt.step&&v(Jt.message||Jt.step),Jt.step==="done"&&Jt.txHash){if(kt=!0,await t(`/api/stories/${ee}/${me}/publish-status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({txHash:Jt.txHash,storylineId:Jt.storylineId,plotIndex:Jt.plotIndex,contentCid:Jt.contentCid,gasCost:Jt.gasCost,indexError:Jt.indexError,authorAddress:j})}),x(xn=>xn+1),tt&&me==="genesis.md"&&Jt.storylineId){v("Uploading cover...");let xn=null;try{xn=await sD(t,Jt.storylineId,tt)}catch{}xn||(st=!0)}if(oi==="cartoon"&&Jt.storylineId)try{const xn=me!=="genesis.md",dl=`storylineId=${Jt.storylineId}`+(xn&&Jt.plotIndex!=null?`&plotIndex=${Jt.plotIndex}`:""),Ar=await t(`/api/publish/public-title?${dl}`);if(Ar.ok){const or=await Ar.json(),_n=xn?{plots:or.plotTitle!=null?[{plotIndex:Jt.plotIndex,title:or.plotTitle}]:[]}:{title:or.storylineTitle},Qi=ID({fileName:me,detail:_n,plotIndex:Jt.plotIndex});Qi.ok||(it=HD(Qi))}}catch{}}}catch{}}it&&N(it),v(st?"Published, but cover upload failed — set it later from Edit Story.":"Published!")}catch(Kt){const Lt=Kt instanceof Error?Kt.message:"Publish failed";v(`Error: ${Lt}`)}finally{setTimeout(()=>{f(null),v("")},3e3)}return kt&&!st},[t,ze,j]),ke=w.useCallback(ee=>{ee.startsWith("_new_")&&(q(me=>me.filter(Ce=>Ce!==ee)),Ct.current.delete(ee),pi.current.delete(ee),ne.current.delete(ee),xe.current.delete(ee),re(me=>{if(!(ee in me))return me;const Ce={...me};return delete Ce[ee],Ce}),$(me=>{if(!(ee in me))return me;const Ce={...me};return delete Ce[ee],Ce}))},[]);w.useEffect(()=>{const ee=Ce=>{be(new Set(Ce.filter(ht=>ht.hasStructure).map(ht=>ht.name))),Le(new Set(Ce.filter(ht=>ht.hasGenesis).map(ht=>ht.name)));const ut={},ot={},tt={},st={},it={},kt={};for(const ht of Ce)ut[ht.name]=ht.contentType||"fiction",ot[ht.name]=ht.language,tt[ht.name]=ht.genre,st[ht.name]=ht.isNsfw,it[ht.name]=ht.agentProvider,ht.title&&(kt[ht.name]=ht.title);ye(ut),bt(ot),vt(tt),Me(st),ii(it),It(kt)};t("/api/stories").then(Ce=>Ce.ok?Ce.json():null).then(Ce=>{Ce!=null&&Ce.stories&&ee(Ce.stories)}).catch(()=>{});const me=setInterval(async()=>{try{const Ce=await t("/api/stories");if(Ce.ok){const ut=await Ce.json();ee(ut.stories)}}catch{}},5e3);return()=>clearInterval(me)},[t]);const Pe=!!T&&T.codex.installed&&T.codex.imageGeneration==="enabled",je=!!T&&!Pe,Ie=w.useCallback(async()=>{try{await navigator.clipboard.writeText("codex features enable image_generation"),C(!0),setTimeout(()=>C(!1),2e3)}catch{}},[]),Xe=w.useCallback(async()=>{if(!i||i.startsWith("_new_"))return;const ee=i;if((await t(`/api/stories/${ee}/metadata`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:"cartoon",agentProvider:"codex"})})).ok){ii(Ce=>({...Ce,[ee]:"codex"})),$(Ce=>({...Ce,[ee]:"codex"}));try{const Ce=await t("/api/stories");if(Ce.ok){const ut=await Ce.json();if(ut!=null&&ut.stories){const ot={};for(const tt of ut.stories)ot[tt.name]=tt.agentProvider;ii(ot)}}}catch{}}},[t,i]),mt=w.useCallback(ee=>{i===ee&&(s(null),o(null))},[i]),Qe=i?ue[i]??Ae[i]:void 0,Tt=Mf(i,ze,Ct.current),qt=uD(Tt,Qe,i),li=!!i&&Tt==="cartoon",oe=c==="story-info"?"story-info":c==="episodes"?"episodes":c==="publish"?"publish":a==="structure.md"?"whitepaper":a==="genesis.md"?"genesis":a&&/^plot-\d+\.md$/.test(a)?"episodes":"progress",Ee=w.useCallback(ee=>{const me=i;if(me)switch(ee){case"progress":h(null),o(null);break;case"story-info":h("story-info");break;case"episodes":h("episodes");break;case"whitepaper":We(me,"structure.md");break;case"genesis":We(me,"genesis.md");break;case"publish":h("publish");break}},[i,We]),Ue=w.useCallback((ee,me)=>{const Ce=i;if(Ce)switch(ee){case"view-progress":h(null),o(null);break;case"publish":h("publish");break;case"open-cuts":case"open-lettering":case"upload":case"refresh-assets":case"generate-markdown":me&&We(Ce,me);break}},[i,We]),Ye=w.useCallback(ee=>{i&&(ee.genre!==void 0&&vt(me=>({...me,[i]:ee.genre||void 0})),ee.language!==void 0&&bt(me=>({...me,[i]:ee.language||void 0})),ee.isNsfw!==void 0&&Me(me=>({...me,[i]:ee.isNsfw})))},[i]);return d.jsxs("div",{ref:Ge,className:"h-[calc(100vh-3.5rem)] flex",children:[d.jsx("div",{className:"w-56 border-r border-border flex-shrink-0",children:d.jsx(yC,{authFetch:t,selectedStory:i,selectedFile:a,onSelectFile:We,onNewStory:Mt,untitledSessions:W})}),d.jsx("div",{className:"min-w-0 border-r border-border",style:{flex:`${z} 0 0`},children:d.jsx(YE,{token:e,storyName:i,authFetch:t,onSelectStory:pt,onDestroySession:ke,onArchiveStory:mt,confirmedStories:le,renameRef:$e,bypassStories:K,agentProviders:ue,readiness:T,contentType:Mf(i,ze,Ct.current),needsProviderRepair:qt,onRepairProvider:Xe})}),d.jsx("div",{onMouseDown:Mi,className:"flex-shrink-0 flex items-center justify-center hover:bg-border/50 transition-colors",style:{width:Of,cursor:"col-resize",background:"var(--border)"},children:d.jsxs("div",{className:"flex flex-col gap-1",children:[d.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),d.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}}),d.jsx("div",{className:"w-0.5 h-0.5 rounded-full",style:{background:"var(--text-muted)"}})]})}),d.jsxs("div",{className:"min-w-0 flex flex-col",style:{flex:`${1-z} 0 0`},children:[li&&i&&d.jsx(BD,{storyTitle:Je[i]||i,active:oe,onSelect:Ee}),li&&i&&c!==null&&d.jsx("div",{className:"flex-shrink-0 border-b border-border","data-testid":"workflow-context-next-action",children:d.jsx(vD,{storyName:i,authFetch:t,refreshKey:_,onCoachAction:Ue,onOpenStoryInfo:()=>h("story-info")})}),li&&c==="story-info"&&i?d.jsx(LD,{storyName:i,authFetch:t,onSaved:Ye}):li&&c==="episodes"&&i?d.jsx(OD,{storyName:i,authFetch:t,onOpenFile:We}):li&&c==="publish"&&i?d.jsx(zD,{storyName:i,authFetch:t,onOpenFile:We,onOpenStoryInfo:()=>h("story-info"),onPublish:H,publishingFile:p,genre:wt[i],language:rt[i],isNsfw:Ve[i],refreshKey:_}):i&&!a?d.jsx(SD,{storyName:i,authFetch:t,onOpenFile:We,onOpenStoryInfo:()=>h("story-info")}):d.jsx(xD,{storyName:i,fileName:a,authFetch:t,onPublish:H,publishingFile:p,walletAddress:j,contentType:Mf(i,ze,Ct.current)||"fiction",language:i?rt[i]:void 0,genre:i?wt[i]:void 0,isNsfw:i?Ve[i]:void 0,hasGenesis:i?Te.has(i):!1,onViewProgress:()=>o(null),onOpenFile:ee=>i&&We(i,ee),onViewPublish:()=>h("publish")}),b&&d.jsx("div",{className:"px-3 py-1.5 bg-surface border-t border-border text-xs text-muted",children:b}),y&&d.jsxs("div",{className:"px-3 py-2 bg-error/10 border-t border-error/40 text-xs text-error flex items-start justify-between gap-3","data-testid":"publish-block-error",role:"alert",children:[d.jsx("span",{children:y}),d.jsx("button",{type:"button",onClick:()=>N(null),className:"shrink-0 text-error/70 hover:text-error underline","data-testid":"publish-block-error-dismiss",children:"Dismiss"})]})]}),D&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(240, 235, 225, 0.9)"},children:d.jsxs("div",{className:"bg-surface border border-border rounded-lg shadow-lg p-6 max-w-sm w-full space-y-4",children:[d.jsx("h3",{className:"text-sm font-serif font-medium text-foreground text-center",children:"New Story"}),d.jsxs("label",{className:"block space-y-1",children:[d.jsxs("span",{className:"text-[10px] font-medium text-muted",children:["Title ",d.jsx("span",{className:"text-accent",children:"*"})]}),d.jsx("input",{type:"text",value:de,onChange:ee=>_e(ee.target.value),placeholder:"e.g. 신의 세포","data-testid":"new-story-title",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Short description (optional)"}),d.jsx("input",{type:"text",value:P,onChange:ee=>ae(ee.target.value),placeholder:"One line about the story","data-testid":"new-story-description",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none"})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Genre (optional)"}),d.jsxs("select",{value:G,onChange:ee=>Y(ee.target.value),"data-testid":"new-story-genre",className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:[d.jsx("option",{value:"",children:"— Select later —"}),nl.map(ee=>d.jsx("option",{value:ee,children:ee},ee))]})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Language"}),d.jsx("select",{value:Q,onChange:ee=>I(ee.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none",children:Xr.map(ee=>d.jsx("option",{value:ee,children:ee},ee))})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Agent mode"}),d.jsxs("select",{value:A,onChange:ee=>B(ee.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"agent-mode-select",children:[d.jsx("option",{value:"normal",children:"Normal (approve each action)"}),d.jsx("option",{value:"bypass",children:"Permissions Bypass (advanced)"})]}),A==="bypass"&&d.jsx("p",{className:"text-[10px] text-amber-700","data-testid":"agent-mode-warning",children:"Less safe: Claude can run actions without per-command approval."})]}),d.jsxs("label",{className:"block space-y-1",children:[d.jsx("span",{className:"text-[10px] font-medium text-muted",children:"Provider"}),d.jsxs("select",{value:U,onChange:ee=>ge(ee.target.value),className:"w-full px-2 py-1.5 text-xs border border-border rounded bg-transparent focus:border-accent focus:outline-none","data-testid":"agent-provider-select",children:[d.jsx("option",{value:"claude",children:"🤖 Claude (default)"}),d.jsx("option",{value:"codex",children:"🎨 Codex"})]}),d.jsx("p",{className:"text-[10px] text-muted","data-testid":"agent-provider-helper",children:U==="codex"?"Codex can generate clean cartoon images directly in the terminal.":"Claude prepares image prompts; you generate and upload clean images externally."})]}),d.jsx("p",{className:"text-xs text-muted text-center",children:"Choose a content type to create"}),!de.trim()&&d.jsx("p",{className:"text-[10px] text-amber-700 text-center","data-testid":"new-story-title-required",children:"Enter a title to create your story."}),d.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[d.jsxs("button",{onClick:()=>ct("fiction",Q,A,U),disabled:!de.trim(),"data-testid":"create-fiction",className:"border border-border rounded-lg p-4 hover:border-accent hover:bg-accent/5 transition-colors text-center space-y-1 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-border disabled:hover:bg-transparent",children:[d.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Fiction"}),d.jsx("p",{className:"text-[11px] text-muted",children:"Novels, short stories, poetry"})]}),d.jsxs("div",{className:"space-y-1",children:[d.jsxs("button",{onClick:()=>ct("cartoon",Q,A,"codex"),disabled:je||!de.trim(),"data-testid":"create-cartoon",className:"w-full border border-border rounded-lg p-4 hover:border-accent hover:bg-accent/5 transition-colors text-center space-y-1 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-border disabled:hover:bg-transparent",children:[d.jsx("p",{className:"text-sm font-serif font-medium text-foreground",children:"Cartoon"}),d.jsx("p",{className:"text-[11px] text-muted",children:"Comics, manga, webtoons"}),d.jsx("p",{className:"text-[11px] text-muted","data-testid":"cartoon-codex-note",children:"Cartoon mode requires Codex because the clean-image step needs image generation support."})]}),T&&!T.codex.installed&&d.jsxs("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-warning",children:["Codex was not detected. Install the Codex CLI and sign in (e.g. ",d.jsx("span",{className:"font-mono",children:"npm i -g @openai/codex"})," then"," ",d.jsx("span",{className:"font-mono",children:"codex login"}),") to create cartoons."]}),Su(T)&&d.jsx("p",{className:"text-[11px] text-amber-700 text-left","data-testid":"cartoon-codex-auth-unknown",children:zp}),T&&T.codex.installed&&!Su(T)&&T.codex.imageGeneration!=="enabled"&&d.jsxs("div",{"data-testid":"cartoon-codex-warning",children:[d.jsx("p",{className:"text-[11px] text-amber-700 text-left",children:"Codex is installed but image generation isn't enabled. Enable it, then reopen this dialog:"}),d.jsxs("div",{className:"mt-1 flex items-center gap-1",children:[d.jsx("code",{className:"flex-1 truncate rounded border border-border bg-surface px-1.5 py-1 text-left text-[10px] font-mono text-foreground",children:"codex features enable image_generation"}),d.jsx("button",{type:"button","data-testid":"copy-codex-enable",onClick:Ie,className:"rounded border border-border px-2 py-1 text-[10px] text-muted hover:border-accent hover:text-accent transition-colors",children:V?"Copied!":"Copy"})]})]})]})]}),d.jsx("button",{onClick:()=>te(!1),className:"w-full px-3 py-1.5 text-xs text-muted hover:text-foreground hover:bg-surface rounded text-center",children:"Cancel"})]})})]})}function qD({token:e,onComplete:t}){const[i,s]=w.useState(!1),[a,o]=w.useState(null),[c,h]=w.useState(!1),p=async()=>{s(!0),o(null);try{const f=await fetch("/api/wallet/create",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}}),_=await f.json();if(!f.ok)throw new Error(_.error||"Wallet creation failed");h(!0)}catch(f){o(f instanceof Error?f.message:"Wallet creation failed")}s(!1)};return w.useEffect(()=>{p()},[]),d.jsxs("div",{className:"mx-auto max-w-sm p-6 text-center",children:[d.jsx("h2",{className:"text-accent mb-1 text-lg font-bold",children:"Wallet Setup"}),d.jsx("p",{className:"text-muted mb-6 text-xs",children:"creating your OWS wallet for on-chain publishing"}),i&&d.jsx("p",{className:"text-accent text-sm",children:"creating wallet..."}),a&&d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"rounded border border-red-700/30 p-3 text-xs text-red-700",children:a}),d.jsx("button",{onClick:p,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"retry"})]}),c&&d.jsxs("div",{className:"space-y-4",children:[d.jsx("div",{className:"text-accent text-2xl",children:"✓"}),d.jsx("p",{className:"text-foreground text-sm font-medium",children:"wallet created"}),d.jsx("button",{onClick:t,className:"border-accent text-accent hover:bg-accent/10 w-full rounded border px-4 py-2 text-sm font-medium transition-colors",children:"continue"})]})]})}function WD({token:e,onLogout:t}){const[i,s]=w.useState("home"),[a,o]=w.useState(0),[c,h]=w.useState(null),p=w.useCallback(async(f,_)=>fetch(f,{..._,headers:{...(_==null?void 0:_.headers)||{},Authorization:`Bearer ${e}`}}),[e]);return w.useEffect(()=>{fetch("/api/health").then(f=>f.json()).then(f=>{f.version&&h(f.version)}).catch(()=>{})},[]),w.useEffect(()=>{async function f(){try{if(!(await(await p("/api/wallet")).json()).exists){s("wallet-setup");return}const b=await p("/api/stories");if(b.ok){const v=await b.json();o(v.stories.filter(y=>y.name!=="_example").length)}}catch{}}f()},[e]),d.jsxs("div",{className:"flex h-screen flex-col",children:[d.jsxs("header",{className:"border-border flex h-14 items-center justify-between border-b px-4 flex-shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("button",{onClick:()=>{i!=="wallet-setup"&&s("home")},className:"flex items-center gap-2 hover:opacity-80",children:d.jsx("span",{className:"text-accent text-sm font-bold tracking-tight",children:"PlotLink OWS"})}),d.jsxs("span",{className:"text-muted text-[10px] uppercase tracking-wider",children:["writer",c?` v${c}`:""]})]}),i!=="wallet-setup"&&d.jsxs("nav",{className:"flex items-center gap-4",children:[d.jsx("button",{onClick:()=>s("stories"),className:`text-xs transition-colors ${i==="stories"?"text-accent":"text-muted hover:text-foreground"}`,children:"stories"}),d.jsx("button",{onClick:()=>s("dashboard"),className:`text-xs transition-colors ${i==="dashboard"?"text-accent":"text-muted hover:text-foreground"}`,children:"dashboard"}),d.jsx("button",{onClick:()=>s("settings"),className:`text-xs transition-colors ${i==="settings"?"text-accent":"text-muted hover:text-foreground"}`,children:"settings"}),d.jsx("button",{onClick:t,className:"text-muted hover:text-foreground text-xs transition-colors",children:"logout"})]})]}),d.jsxs("main",{className:"flex-1 min-h-0",children:[i==="home"&&d.jsxs("div",{className:"mx-auto max-w-lg space-y-6 p-8",children:[d.jsxs("div",{className:"text-center space-y-2",children:[d.jsx("h1",{className:"text-2xl font-serif text-foreground",children:"Write. Publish. Earn."}),d.jsx("p",{className:"text-muted text-sm",children:"Claude or Codex helps create your story. You publish it on-chain."})]}),d.jsxs("div",{className:"text-center space-y-3",children:[d.jsx("button",{onClick:()=>s("stories"),className:"bg-accent text-white hover:bg-accent-dim px-6 py-2.5 rounded text-sm font-medium transition-colors",children:"Start Writing"}),a>0&&d.jsxs("p",{className:"text-muted text-xs",children:[a," ",a===1?"story":"stories"," in progress"]})]}),d.jsxs("div",{className:"rounded border border-border p-4 space-y-2 text-xs text-muted",children:[d.jsx("p",{className:"font-medium text-foreground text-sm",children:"How it works"}),d.jsxs("ol",{className:"space-y-1.5 list-decimal list-inside",children:[d.jsxs("li",{children:["Open the ",d.jsx("strong",{children:"Stories"})," tab — your writing agent launches in the terminal"]}),d.jsx("li",{children:"Tell the agent your story idea — it brainstorms, outlines, and writes"}),d.jsx("li",{children:"Review the live preview as the agent creates files"}),d.jsxs("li",{children:["Click ",d.jsx("strong",{children:"Publish"})," to put your story on-chain"]}),d.jsxs("li",{children:["Earn 5% royalties on every trade at ",d.jsx("a",{href:"https://plotlink.xyz",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline",children:"plotlink.xyz"})]})]}),d.jsx("p",{className:"text-[11px] text-muted",children:"Fiction defaults to Claude; cartoon mode uses Codex for clean-image generation."})]}),d.jsx("div",{className:"text-center",children:d.jsx("a",{href:"https://github.com/realproject7/plotlink-ows#-wallet-setup",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-accent underline transition-colors",children:"Wallet Setup Guide"})}),d.jsx(Cy,{token:e})]}),i==="stories"&&d.jsx(FD,{token:e,authFetch:p}),i==="dashboard"&&d.jsx(_C,{token:e}),i==="wallet-setup"&&d.jsx(qD,{token:e,onComplete:()=>s("home")}),i==="settings"&&d.jsx(gC,{token:e,onLogout:t})]})]})}function GD(){const[e,t]=w.useState(()=>localStorage.getItem("ows-token")),[i,s]=w.useState(null),[a,o]=w.useState(!0);w.useEffect(()=>{fetch("/api/auth/status").then(f=>f.json()).then(f=>s(f.configured)).catch(()=>s(null))},[]),w.useEffect(()=>{if(!e){o(!1);return}fetch("/api/auth/verify",{headers:{Authorization:`Bearer ${e}`}}).then(f=>{f.ok||(localStorage.removeItem("ows-token"),t(null))}).catch(()=>{localStorage.removeItem("ows-token"),t(null)}).finally(()=>o(!1))},[e]);const c=async f=>{try{const _=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:f})}),x=await _.json();return _.ok?(localStorage.setItem("ows-token",x.token),t(x.token),null):x.error||"Login failed"}catch{return"Cannot connect to server"}},h=async f=>{try{const _=await fetch("/api/auth/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({passphrase:f})}),x=await _.json();return _.ok?(localStorage.setItem("ows-token",x.token),t(x.token),s(!0),null):x.error||"Setup failed"}catch{return"Cannot connect to server"}},p=()=>{localStorage.removeItem("ows-token"),t(null)};return a||i===null?d.jsx("div",{className:"flex h-screen items-center justify-center",children:d.jsx("span",{className:"text-muted text-sm",children:"connecting..."})}):i?e?d.jsx(WD,{token:e,onLogout:p}):d.jsx(pC,{onLogin:c}):d.jsx(mC,{onSetup:h})}fC.createRoot(document.getElementById("root")).render(d.jsx(sC.StrictMode,{children:d.jsx(GD,{})}));export{Dp as M,au as a,j3 as b,OM as c,R3 as d,su as l,OS as s,F3 as t,ZD as v};