openwriter 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,210 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var fb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function dl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xh={exports:{}},Oa={},wh={exports:{}},pt={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var hb;function J2(){if(hb)return pt;hb=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function g(A){return A===null||typeof A!="object"?null:(A=m&&A[m]||A["@@iterator"],typeof A=="function"?A:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,k={};function w(A,j,Q){this.props=A,this.context=j,this.refs=k,this.updater=Q||y}w.prototype.isReactComponent={},w.prototype.setState=function(A,j){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,j,"setState")},w.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function E(){}E.prototype=w.prototype;function N(A,j,Q){this.props=A,this.context=j,this.refs=k,this.updater=Q||y}var O=N.prototype=new E;O.constructor=N,b(O,w.prototype),O.isPureReactComponent=!0;var T=Array.isArray,C=Object.prototype.hasOwnProperty,R={current:null},L={key:!0,ref:!0,__self:!0,__source:!0};function D(A,j,Q){var oe,fe={},G=null,le=null;if(j!=null)for(oe in j.ref!==void 0&&(le=j.ref),j.key!==void 0&&(G=""+j.key),j)C.call(j,oe)&&!L.hasOwnProperty(oe)&&(fe[oe]=j[oe]);var Te=arguments.length-2;if(Te===1)fe.children=Q;else if(1<Te){for(var Ve=Array(Te),ce=0;ce<Te;ce++)Ve[ce]=arguments[ce+2];fe.children=Ve}if(A&&A.defaultProps)for(oe in Te=A.defaultProps,Te)fe[oe]===void 0&&(fe[oe]=Te[oe]);return{$$typeof:t,type:A,key:G,ref:le,props:fe,_owner:R.current}}function z(A,j){return{$$typeof:t,type:A.type,key:j,ref:A.ref,props:A.props,_owner:A._owner}}function F(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function J(A){var j={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(Q){return j[Q]})}var K=/\/+/g;function X(A,j){return typeof A=="object"&&A!==null&&A.key!=null?J(""+A.key):j.toString(36)}function W(A,j,Q,oe,fe){var G=typeof A;(G==="undefined"||G==="boolean")&&(A=null);var le=!1;if(A===null)le=!0;else switch(G){case"string":case"number":le=!0;break;case"object":switch(A.$$typeof){case t:case e:le=!0}}if(le)return le=A,fe=fe(le),A=oe===""?"."+X(le,0):oe,T(fe)?(Q="",A!=null&&(Q=A.replace(K,"$&/")+"/"),W(fe,j,Q,"",function(ce){return ce})):fe!=null&&(F(fe)&&(fe=z(fe,Q+(!fe.key||le&&le.key===fe.key?"":(""+fe.key).replace(K,"$&/")+"/")+A)),j.push(fe)),1;if(le=0,oe=oe===""?".":oe+":",T(A))for(var Te=0;Te<A.length;Te++){G=A[Te];var Ve=oe+X(G,Te);le+=W(G,j,Q,Ve,fe)}else if(Ve=g(A),typeof Ve=="function")for(A=Ve.call(A),Te=0;!(G=A.next()).done;)G=G.value,Ve=oe+X(G,Te++),le+=W(G,j,Q,Ve,fe);else if(G==="object")throw j=String(A),Error("Objects are not valid as a React child (found: "+(j==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":j)+"). If you meant to render a collection of children, use an array instead.");return le}function $(A,j,Q){if(A==null)return A;var oe=[],fe=0;return W(A,oe,"","",function(G){return j.call(Q,G,fe++)}),oe}function U(A){if(A._status===-1){var j=A._result;j=j(),j.then(function(Q){(A._status===0||A._status===-1)&&(A._status=1,A._result=Q)},function(Q){(A._status===0||A._status===-1)&&(A._status=2,A._result=Q)}),A._status===-1&&(A._status=0,A._result=j)}if(A._status===1)return A._result.default;throw A._result}var Z={current:null},V={transition:null},Y={ReactCurrentDispatcher:Z,ReactCurrentBatchConfig:V,ReactCurrentOwner:R};function I(){throw Error("act(...) is not supported in production builds of React.")}return pt.Children={map:$,forEach:function(A,j,Q){$(A,function(){j.apply(this,arguments)},Q)},count:function(A){var j=0;return $(A,function(){j++}),j},toArray:function(A){return $(A,function(j){return j})||[]},only:function(A){if(!F(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},pt.Component=w,pt.Fragment=n,pt.Profiler=s,pt.PureComponent=N,pt.StrictMode=r,pt.Suspense=u,pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Y,pt.act=I,pt.cloneElement=function(A,j,Q){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var oe=b({},A.props),fe=A.key,G=A.ref,le=A._owner;if(j!=null){if(j.ref!==void 0&&(G=j.ref,le=R.current),j.key!==void 0&&(fe=""+j.key),A.type&&A.type.defaultProps)var Te=A.type.defaultProps;for(Ve in j)C.call(j,Ve)&&!L.hasOwnProperty(Ve)&&(oe[Ve]=j[Ve]===void 0&&Te!==void 0?Te[Ve]:j[Ve])}var Ve=arguments.length-2;if(Ve===1)oe.children=Q;else if(1<Ve){Te=Array(Ve);for(var ce=0;ce<Ve;ce++)Te[ce]=arguments[ce+2];oe.children=Te}return{$$typeof:t,type:A.type,key:fe,ref:G,props:oe,_owner:le}},pt.createContext=function(A){return A={$$typeof:o,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:i,_context:A},A.Consumer=A},pt.createElement=D,pt.createFactory=function(A){var j=D.bind(null,A);return j.type=A,j},pt.createRef=function(){return{current:null}},pt.forwardRef=function(A){return{$$typeof:l,render:A}},pt.isValidElement=F,pt.lazy=function(A){return{$$typeof:p,_payload:{_status:-1,_result:A},_init:U}},pt.memo=function(A,j){return{$$typeof:f,type:A,compare:j===void 0?null:j}},pt.startTransition=function(A){var j=V.transition;V.transition={};try{A()}finally{V.transition=j}},pt.unstable_act=I,pt.useCallback=function(A,j){return Z.current.useCallback(A,j)},pt.useContext=function(A){return Z.current.useContext(A)},pt.useDebugValue=function(){},pt.useDeferredValue=function(A){return Z.current.useDeferredValue(A)},pt.useEffect=function(A,j){return Z.current.useEffect(A,j)},pt.useId=function(){return Z.current.useId()},pt.useImperativeHandle=function(A,j,Q){return Z.current.useImperativeHandle(A,j,Q)},pt.useInsertionEffect=function(A,j){return Z.current.useInsertionEffect(A,j)},pt.useLayoutEffect=function(A,j){return Z.current.useLayoutEffect(A,j)},pt.useMemo=function(A,j){return Z.current.useMemo(A,j)},pt.useReducer=function(A,j,Q){return Z.current.useReducer(A,j,Q)},pt.useRef=function(A){return Z.current.useRef(A)},pt.useState=function(A){return Z.current.useState(A)},pt.useSyncExternalStore=function(A,j,Q){return Z.current.useSyncExternalStore(A,j,Q)},pt.useTransition=function(){return Z.current.useTransition()},pt.version="18.3.1",pt}var pb;function fl(){return pb||(pb=1,wh.exports=J2()),wh.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var mb;function Y2(){if(mb)return Oa;mb=1;var t=fl(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,u,f){var p,m={},g=null,y=null;f!==void 0&&(g=""+f),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(y=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(m[p]=u[p]);if(l&&l.defaultProps)for(p in u=l.defaultProps,u)m[p]===void 0&&(m[p]=u[p]);return{$$typeof:e,type:l,key:g,ref:y,props:m,_owner:s.current}}return Oa.Fragment=n,Oa.jsx=o,Oa.jsxs=o,Oa}var gb;function Q2(){return gb||(gb=1,xh.exports=Y2()),xh.exports}var d=Q2(),S=fl();const ii=dl(S);var Ac={},kh={exports:{}},Xn={},Sh={exports:{}},Eh={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var vb;function X2(){return vb||(vb=1,(function(t){function e(V,Y){var I=V.length;V.push(Y);e:for(;0<I;){var A=I-1>>>1,j=V[A];if(0<s(j,Y))V[A]=Y,V[I]=j,I=A;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var Y=V[0],I=V.pop();if(I!==Y){V[0]=I;e:for(var A=0,j=V.length,Q=j>>>1;A<Q;){var oe=2*(A+1)-1,fe=V[oe],G=oe+1,le=V[G];if(0>s(fe,I))G<j&&0>s(le,fe)?(V[A]=le,V[G]=I,A=G):(V[A]=fe,V[oe]=I,A=oe);else if(G<j&&0>s(le,I))V[A]=le,V[G]=I,A=G;else break e}}return Y}function s(V,Y){var I=V.sortIndex-Y.sortIndex;return I!==0?I:V.id-Y.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],f=[],p=1,m=null,g=3,y=!1,b=!1,k=!1,w=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(V){for(var Y=n(f);Y!==null;){if(Y.callback===null)r(f);else if(Y.startTime<=V)r(f),Y.sortIndex=Y.expirationTime,e(u,Y);else break;Y=n(f)}}function T(V){if(k=!1,O(V),!b)if(n(u)!==null)b=!0,U(C);else{var Y=n(f);Y!==null&&Z(T,Y.startTime-V)}}function C(V,Y){b=!1,k&&(k=!1,E(D),D=-1),y=!0;var I=g;try{for(O(Y),m=n(u);m!==null&&(!(m.expirationTime>Y)||V&&!J());){var A=m.callback;if(typeof A=="function"){m.callback=null,g=m.priorityLevel;var j=A(m.expirationTime<=Y);Y=t.unstable_now(),typeof j=="function"?m.callback=j:m===n(u)&&r(u),O(Y)}else r(u);m=n(u)}if(m!==null)var Q=!0;else{var oe=n(f);oe!==null&&Z(T,oe.startTime-Y),Q=!1}return Q}finally{m=null,g=I,y=!1}}var R=!1,L=null,D=-1,z=5,F=-1;function J(){return!(t.unstable_now()-F<z)}function K(){if(L!==null){var V=t.unstable_now();F=V;var Y=!0;try{Y=L(!0,V)}finally{Y?X():(R=!1,L=null)}}else R=!1}var X;if(typeof N=="function")X=function(){N(K)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,$=W.port2;W.port1.onmessage=K,X=function(){$.postMessage(null)}}else X=function(){w(K,0)};function U(V){L=V,R||(R=!0,X())}function Z(V,Y){D=w(function(){V(t.unstable_now())},Y)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(V){V.callback=null},t.unstable_continueExecution=function(){b||y||(b=!0,U(C))},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(V){switch(g){case 1:case 2:case 3:var Y=3;break;default:Y=g}var I=g;g=Y;try{return V()}finally{g=I}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(V,Y){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var I=g;g=V;try{return Y()}finally{g=I}},t.unstable_scheduleCallback=function(V,Y,I){var A=t.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?A+I:A):I=A,V){case 1:var j=-1;break;case 2:j=250;break;case 5:j=1073741823;break;case 4:j=1e4;break;default:j=5e3}return j=I+j,V={id:p++,callback:Y,priorityLevel:V,startTime:I,expirationTime:j,sortIndex:-1},I>A?(V.sortIndex=I,e(f,V),n(u)===null&&V===n(f)&&(k?(E(D),D=-1):k=!0,Z(T,I-A))):(V.sortIndex=j,e(u,V),b||y||(b=!0,U(C))),V},t.unstable_shouldYield=J,t.unstable_wrapCallback=function(V){var Y=g;return function(){var I=g;g=Y;try{return V.apply(this,arguments)}finally{g=I}}}})(Eh)),Eh}var yb;function Z2(){return yb||(yb=1,Sh.exports=X2()),Sh.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var bb;function eM(){if(bb)return Xn;bb=1;var t=fl(),e=Z2();function n(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,h=1;h<arguments.length;h++)c+="&args[]="+encodeURIComponent(arguments[h]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(a,c){o(a,c),o(a+"Capture",c)}function o(a,c){for(s[a]=c,a=0;a<c.length;a++)r.add(c[a])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function g(a){return u.call(m,a)?!0:u.call(p,a)?!1:f.test(a)?m[a]=!0:(p[a]=!0,!1)}function y(a,c,h,v){if(h!==null&&h.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return v?!1:h!==null?!h.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function b(a,c,h,v){if(c===null||typeof c>"u"||y(a,c,h,v))return!0;if(v)return!1;if(h!==null)switch(h.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function k(a,c,h,v,x,_,M){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=v,this.attributeNamespace=x,this.mustUseProperty=h,this.propertyName=a,this.type=c,this.sanitizeURL=_,this.removeEmptyString=M}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){w[a]=new k(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var c=a[0];w[c]=new k(c,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){w[a]=new k(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){w[a]=new k(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){w[a]=new k(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){w[a]=new k(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){w[a]=new k(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){w[a]=new k(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){w[a]=new k(a,5,!1,a.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function N(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var c=a.replace(E,N);w[c]=new k(c,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var c=a.replace(E,N);w[c]=new k(c,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var c=a.replace(E,N);w[c]=new k(c,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!1,!1)}),w.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!0,!0)});function O(a,c,h,v){var x=w.hasOwnProperty(c)?w[c]:null;(x!==null?x.type!==0:v||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(b(c,h,x,v)&&(h=null),v||x===null?g(c)&&(h===null?a.removeAttribute(c):a.setAttribute(c,""+h)):x.mustUseProperty?a[x.propertyName]=h===null?x.type===3?!1:"":h:(c=x.attributeName,v=x.attributeNamespace,h===null?a.removeAttribute(c):(x=x.type,h=x===3||x===4&&h===!0?"":""+h,v?a.setAttributeNS(v,c,h):a.setAttribute(c,h))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,C=Symbol.for("react.element"),R=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),J=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),X=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Z=Symbol.for("react.offscreen"),V=Symbol.iterator;function Y(a){return a===null||typeof a!="object"?null:(a=V&&a[V]||a["@@iterator"],typeof a=="function"?a:null)}var I=Object.assign,A;function j(a){if(A===void 0)try{throw Error()}catch(h){var c=h.stack.trim().match(/\n( *(at )?)/);A=c&&c[1]||""}return`
34
+ `+A+a}var Q=!1;function oe(a,c){if(!a||Q)return"";Q=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(ie){var v=ie}Reflect.construct(a,[],c)}else{try{c.call()}catch(ie){v=ie}a.call(c.prototype)}else{try{throw Error()}catch(ie){v=ie}a()}}catch(ie){if(ie&&v&&typeof ie.stack=="string"){for(var x=ie.stack.split(`
35
+ `),_=v.stack.split(`
36
+ `),M=x.length-1,P=_.length-1;1<=M&&0<=P&&x[M]!==_[P];)P--;for(;1<=M&&0<=P;M--,P--)if(x[M]!==_[P]){if(M!==1||P!==1)do if(M--,P--,0>P||x[M]!==_[P]){var H=`
37
+ `+x[M].replace(" at new "," at ");return a.displayName&&H.includes("<anonymous>")&&(H=H.replace("<anonymous>",a.displayName)),H}while(1<=M&&0<=P);break}}}finally{Q=!1,Error.prepareStackTrace=h}return(a=a?a.displayName||a.name:"")?j(a):""}function fe(a){switch(a.tag){case 5:return j(a.type);case 16:return j("Lazy");case 13:return j("Suspense");case 19:return j("SuspenseList");case 0:case 2:case 15:return a=oe(a.type,!1),a;case 11:return a=oe(a.type.render,!1),a;case 1:return a=oe(a.type,!0),a;default:return""}}function G(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case L:return"Fragment";case R:return"Portal";case z:return"Profiler";case D:return"StrictMode";case X:return"Suspense";case W:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case J:return(a.displayName||"Context")+".Consumer";case F:return(a._context.displayName||"Context")+".Provider";case K:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case $:return c=a.displayName||null,c!==null?c:G(a.type)||"Memo";case U:c=a._payload,a=a._init;try{return G(a(c))}catch{}}return null}function le(a){var c=a.type;switch(a.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=c.render,a=a.displayName||a.name||"",c.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return G(c);case 8:return c===D?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function Te(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function Ve(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function ce(a){var c=Ve(a)?"checked":"value",h=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),v=""+a[c];if(!a.hasOwnProperty(c)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var x=h.get,_=h.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return x.call(this)},set:function(M){v=""+M,_.call(this,M)}}),Object.defineProperty(a,c,{enumerable:h.enumerable}),{getValue:function(){return v},setValue:function(M){v=""+M},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function ue(a){a._valueTracker||(a._valueTracker=ce(a))}function ae(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var h=c.getValue(),v="";return a&&(v=Ve(a)?a.checked?"true":"false":a.value),a=v,a!==h?(c.setValue(a),!0):!1}function je(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function Me(a,c){var h=c.checked;return I({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??a._wrapperState.initialChecked})}function He(a,c){var h=c.defaultValue==null?"":c.defaultValue,v=c.checked!=null?c.checked:c.defaultChecked;h=Te(c.value!=null?c.value:h),a._wrapperState={initialChecked:v,initialValue:h,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Ne(a,c){c=c.checked,c!=null&&O(a,"checked",c,!1)}function tt(a,c){Ne(a,c);var h=Te(c.value),v=c.type;if(h!=null)v==="number"?(h===0&&a.value===""||a.value!=h)&&(a.value=""+h):a.value!==""+h&&(a.value=""+h);else if(v==="submit"||v==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?$e(a,c.type,h):c.hasOwnProperty("defaultValue")&&$e(a,c.type,Te(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function Be(a,c,h){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var v=c.type;if(!(v!=="submit"&&v!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+a._wrapperState.initialValue,h||c===a.value||(a.value=c),a.defaultValue=c}h=a.name,h!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,h!==""&&(a.name=h)}function $e(a,c,h){(c!=="number"||je(a.ownerDocument)!==a)&&(h==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+h&&(a.defaultValue=""+h))}var ye=Array.isArray;function pe(a,c,h,v){if(a=a.options,c){c={};for(var x=0;x<h.length;x++)c["$"+h[x]]=!0;for(h=0;h<a.length;h++)x=c.hasOwnProperty("$"+a[h].value),a[h].selected!==x&&(a[h].selected=x),x&&v&&(a[h].defaultSelected=!0)}else{for(h=""+Te(h),c=null,x=0;x<a.length;x++){if(a[x].value===h){a[x].selected=!0,v&&(a[x].defaultSelected=!0);return}c!==null||a[x].disabled||(c=a[x])}c!==null&&(c.selected=!0)}}function Ze(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return I({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function Ae(a,c){var h=c.value;if(h==null){if(h=c.children,c=c.defaultValue,h!=null){if(c!=null)throw Error(n(92));if(ye(h)){if(1<h.length)throw Error(n(93));h=h[0]}c=h}c==null&&(c=""),h=c}a._wrapperState={initialValue:Te(h)}}function be(a,c){var h=Te(c.value),v=Te(c.defaultValue);h!=null&&(h=""+h,h!==a.value&&(a.value=h),c.defaultValue==null&&a.defaultValue!==h&&(a.defaultValue=h)),v!=null&&(a.defaultValue=""+v)}function ke(a){var c=a.textContent;c===a._wrapperState.initialValue&&c!==""&&c!==null&&(a.value=c)}function ze(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ht(a,c){return a==null||a==="http://www.w3.org/1999/xhtml"?ze(c):a==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var wt,kt=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,h,v,x){MSApp.execUnsafeLocalFunction(function(){return a(c,h,v,x)})}:a})(function(a,c){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=c;else{for(wt=wt||document.createElement("div"),wt.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=wt.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;c.firstChild;)a.appendChild(c.firstChild)}});function Bt(a,c){if(c){var h=a.firstChild;if(h&&h===a.lastChild&&h.nodeType===3){h.nodeValue=c;return}}a.textContent=c}var xn={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},An=["Webkit","ms","Moz","O"];Object.keys(xn).forEach(function(a){An.forEach(function(c){c=c+a.charAt(0).toUpperCase()+a.substring(1),xn[c]=xn[a]})});function On(a,c,h){return c==null||typeof c=="boolean"||c===""?"":h||typeof c!="number"||c===0||xn.hasOwnProperty(a)&&xn[a]?(""+c).trim():c+"px"}function wn(a,c){a=a.style;for(var h in c)if(c.hasOwnProperty(h)){var v=h.indexOf("--")===0,x=On(h,c[h],v);h==="float"&&(h="cssFloat"),v?a.setProperty(h,x):a[h]=x}}var re=I({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Je(a,c){if(c){if(re[a]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function et(a,c){if(a.indexOf("-")===-1)return typeof c.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Et=null;function rt(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var nt=null,ee=null,Ce=null;function lt(a){if(a=ga(a)){if(typeof nt!="function")throw Error(n(280));var c=a.stateNode;c&&(c=ql(c),nt(a.stateNode,a.type,c))}}function B(a){ee?Ce?Ce.push(a):Ce=[a]:ee=a}function se(){if(ee){var a=ee,c=Ce;if(Ce=ee=null,lt(a),c)for(a=0;a<c.length;a++)lt(c[a])}}function Se(a,c){return a(c)}function st(){}var Mt=!1;function Ot(a,c,h){if(Mt)return a(c,h);Mt=!0;try{return Se(a,c,h)}finally{Mt=!1,(ee!==null||Ce!==null)&&(st(),se())}}function Ie(a,c){var h=a.stateNode;if(h===null)return null;var v=ql(h);if(v===null)return null;h=v[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(v=!v.disabled)||(a=a.type,v=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!v;break e;default:a=!1}if(a)return null;if(h&&typeof h!="function")throw Error(n(231,c,typeof h));return h}var Re=!1;if(l)try{var Ye={};Object.defineProperty(Ye,"passive",{get:function(){Re=!0}}),window.addEventListener("test",Ye,Ye),window.removeEventListener("test",Ye,Ye)}catch{Re=!1}function rn(a,c,h,v,x,_,M,P,H){var ie=Array.prototype.slice.call(arguments,3);try{c.apply(h,ie)}catch(me){this.onError(me)}}var It=!1,Fr=null,Es=!1,pi=null,zd={onError:function(a){It=!0,Fr=a}};function Yo(a,c,h,v,x,_,M,P,H){It=!1,Fr=null,rn.apply(zd,arguments)}function Fd(a,c,h,v,x,_,M,P,H){if(Yo.apply(this,arguments),It){if(It){var ie=Fr;It=!1,Fr=null}else throw Error(n(198));Es||(Es=!0,pi=ie)}}function es(a){var c=a,h=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(h=c.return),a=c.return;while(a)}return c.tag===3?h:null}function Sl(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function Qo(a){if(es(a)!==a)throw Error(n(188))}function no(a){var c=a.alternate;if(!c){if(c=es(a),c===null)throw Error(n(188));return c!==a?null:a}for(var h=a,v=c;;){var x=h.return;if(x===null)break;var _=x.alternate;if(_===null){if(v=x.return,v!==null){h=v;continue}break}if(x.child===_.child){for(_=x.child;_;){if(_===h)return Qo(x),a;if(_===v)return Qo(x),c;_=_.sibling}throw Error(n(188))}if(h.return!==v.return)h=x,v=_;else{for(var M=!1,P=x.child;P;){if(P===h){M=!0,h=x,v=_;break}if(P===v){M=!0,v=x,h=_;break}P=P.sibling}if(!M){for(P=_.child;P;){if(P===h){M=!0,h=_,v=x;break}if(P===v){M=!0,v=_,h=x;break}P=P.sibling}if(!M)throw Error(n(189))}}if(h.alternate!==v)throw Error(n(190))}if(h.tag!==3)throw Error(n(188));return h.stateNode.current===h?a:c}function El(a){return a=no(a),a!==null?_l(a):null}function _l(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var c=_l(a);if(c!==null)return c;a=a.sibling}return null}var Nl=e.unstable_scheduleCallback,_r=e.unstable_cancelCallback,Cl=e.unstable_shouldYield,Tl=e.unstable_requestPaint,Ht=e.unstable_now,$d=e.unstable_getCurrentPriorityLevel,Xo=e.unstable_ImmediatePriority,mi=e.unstable_UserBlockingPriority,ro=e.unstable_NormalPriority,xe=e.unstable_LowPriority,We=e.unstable_IdlePriority,ut=null,mt=null;function Zt(a){if(mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(ut,a,void 0,(a.current.flags&128)===128)}catch{}}var Wt=Math.clz32?Math.clz32:Fn,$r=Math.log,so=Math.LN2;function Fn(a){return a>>>=0,a===0?32:31-($r(a)/so|0)|0}var $n=64,gi=4194304;function _s(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function vi(a,c){var h=a.pendingLanes;if(h===0)return 0;var v=0,x=a.suspendedLanes,_=a.pingedLanes,M=h&268435455;if(M!==0){var P=M&~x;P!==0?v=_s(P):(_&=M,_!==0&&(v=_s(_)))}else M=h&~x,M!==0?v=_s(M):_!==0&&(v=_s(_));if(v===0)return 0;if(c!==0&&c!==v&&(c&x)===0&&(x=v&-v,_=c&-c,x>=_||x===16&&(_&4194240)!==0))return c;if((v&4)!==0&&(v|=h&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=v;0<c;)h=31-Wt(c),x=1<<h,v|=a[h],c&=~x;return v}function Ud(a,c){switch(a){case 1:case 2:case 4:return c+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Hd(a,c){for(var h=a.suspendedLanes,v=a.pingedLanes,x=a.expirationTimes,_=a.pendingLanes;0<_;){var M=31-Wt(_),P=1<<M,H=x[M];H===-1?((P&h)===0||(P&v)!==0)&&(x[M]=Ud(P,c)):H<=c&&(a.expiredLanes|=P),_&=~P}}function Zo(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function Ml(){var a=$n;return $n<<=1,($n&4194240)===0&&($n=64),a}function Ns(a){for(var c=[],h=0;31>h;h++)c.push(a);return c}function Cs(a,c,h){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-Wt(c),a[c]=h}function ur(a,c){var h=a.pendingLanes&~c;a.pendingLanes=c,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=c,a.mutableReadLanes&=c,a.entangledLanes&=c,c=a.entanglements;var v=a.eventTimes;for(a=a.expirationTimes;0<h;){var x=31-Wt(h),_=1<<x;c[x]=0,v[x]=-1,a[x]=-1,h&=~_}}function ea(a,c){var h=a.entangledLanes|=c;for(a=a.entanglements;h;){var v=31-Wt(h),x=1<<v;x&c|a[v]&c&&(a[v]|=c),h&=~x}}var vt=0;function ct(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ta,en,Tt,yi,Ur,bi=!1,Ts=[],Ee=null,Le=null,ot=null,gt=new Map,Kt=new Map,dn=[],Wd="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Al(a,c){switch(a){case"focusin":case"focusout":Ee=null;break;case"dragenter":case"dragleave":Le=null;break;case"mouseover":case"mouseout":ot=null;break;case"pointerover":case"pointerout":gt.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":Kt.delete(c.pointerId)}}function na(a,c,h,v,x,_){return a===null||a.nativeEvent!==_?(a={blockedOn:c,domEventName:h,eventSystemFlags:v,nativeEvent:_,targetContainers:[x]},c!==null&&(c=ga(c),c!==null&&en(c)),a):(a.eventSystemFlags|=v,c=a.targetContainers,x!==null&&c.indexOf(x)===-1&&c.push(x),a)}function yT(a,c,h,v,x){switch(c){case"focusin":return Ee=na(Ee,a,c,h,v,x),!0;case"dragenter":return Le=na(Le,a,c,h,v,x),!0;case"mouseover":return ot=na(ot,a,c,h,v,x),!0;case"pointerover":var _=x.pointerId;return gt.set(_,na(gt.get(_)||null,a,c,h,v,x)),!0;case"gotpointercapture":return _=x.pointerId,Kt.set(_,na(Kt.get(_)||null,a,c,h,v,x)),!0}return!1}function Y0(a){var c=xi(a.target);if(c!==null){var h=es(c);if(h!==null){if(c=h.tag,c===13){if(c=Sl(h),c!==null){a.blockedOn=c,Ur(a.priority,function(){Tt(h)});return}}else if(c===3&&h.stateNode.current.memoizedState.isDehydrated){a.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Ol(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var h=Vd(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(h===null){h=a.nativeEvent;var v=new h.constructor(h.type,h);Et=v,h.target.dispatchEvent(v),Et=null}else return c=ga(h),c!==null&&en(c),a.blockedOn=h,!1;c.shift()}return!0}function Q0(a,c,h){Ol(a)&&h.delete(c)}function bT(){bi=!1,Ee!==null&&Ol(Ee)&&(Ee=null),Le!==null&&Ol(Le)&&(Le=null),ot!==null&&Ol(ot)&&(ot=null),gt.forEach(Q0),Kt.forEach(Q0)}function ra(a,c){a.blockedOn===c&&(a.blockedOn=null,bi||(bi=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,bT)))}function sa(a){function c(x){return ra(x,a)}if(0<Ts.length){ra(Ts[0],a);for(var h=1;h<Ts.length;h++){var v=Ts[h];v.blockedOn===a&&(v.blockedOn=null)}}for(Ee!==null&&ra(Ee,a),Le!==null&&ra(Le,a),ot!==null&&ra(ot,a),gt.forEach(c),Kt.forEach(c),h=0;h<dn.length;h++)v=dn[h],v.blockedOn===a&&(v.blockedOn=null);for(;0<dn.length&&(h=dn[0],h.blockedOn===null);)Y0(h),h.blockedOn===null&&dn.shift()}var io=T.ReactCurrentBatchConfig,Rl=!0;function xT(a,c,h,v){var x=vt,_=io.transition;io.transition=null;try{vt=1,qd(a,c,h,v)}finally{vt=x,io.transition=_}}function wT(a,c,h,v){var x=vt,_=io.transition;io.transition=null;try{vt=4,qd(a,c,h,v)}finally{vt=x,io.transition=_}}function qd(a,c,h,v){if(Rl){var x=Vd(a,c,h,v);if(x===null)uf(a,c,v,jl,h),Al(a,v);else if(yT(x,a,c,h,v))v.stopPropagation();else if(Al(a,v),c&4&&-1<Wd.indexOf(a)){for(;x!==null;){var _=ga(x);if(_!==null&&ta(_),_=Vd(a,c,h,v),_===null&&uf(a,c,v,jl,h),_===x)break;x=_}x!==null&&v.stopPropagation()}else uf(a,c,v,null,h)}}var jl=null;function Vd(a,c,h,v){if(jl=null,a=rt(v),a=xi(a),a!==null)if(c=es(a),c===null)a=null;else if(h=c.tag,h===13){if(a=Sl(c),a!==null)return a;a=null}else if(h===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return jl=a,null}function X0(a){switch(a){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch($d()){case Xo:return 1;case mi:return 4;case ro:case xe:return 16;case We:return 536870912;default:return 16}default:return 16}}var Ms=null,Kd=null,Il=null;function Z0(){if(Il)return Il;var a,c=Kd,h=c.length,v,x="value"in Ms?Ms.value:Ms.textContent,_=x.length;for(a=0;a<h&&c[a]===x[a];a++);var M=h-a;for(v=1;v<=M&&c[h-v]===x[_-v];v++);return Il=x.slice(a,1<v?1-v:void 0)}function Ll(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function Dl(){return!0}function ev(){return!1}function nr(a){function c(h,v,x,_,M){this._reactName=h,this._targetInst=x,this.type=v,this.nativeEvent=_,this.target=M,this.currentTarget=null;for(var P in a)a.hasOwnProperty(P)&&(h=a[P],this[P]=h?h(_):_[P]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?Dl:ev,this.isPropagationStopped=ev,this}return I(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=Dl)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=Dl)},persist:function(){},isPersistent:Dl}),c}var oo={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gd=nr(oo),ia=I({},oo,{view:0,detail:0}),kT=nr(ia),Jd,Yd,oa,Pl=I({},ia,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Xd,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==oa&&(oa&&a.type==="mousemove"?(Jd=a.screenX-oa.screenX,Yd=a.screenY-oa.screenY):Yd=Jd=0,oa=a),Jd)},movementY:function(a){return"movementY"in a?a.movementY:Yd}}),tv=nr(Pl),ST=I({},Pl,{dataTransfer:0}),ET=nr(ST),_T=I({},ia,{relatedTarget:0}),Qd=nr(_T),NT=I({},oo,{animationName:0,elapsedTime:0,pseudoElement:0}),CT=nr(NT),TT=I({},oo,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),MT=nr(TT),AT=I({},oo,{data:0}),nv=nr(AT),OT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},RT={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"},jT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function IT(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=jT[a])?!!c[a]:!1}function Xd(){return IT}var LT=I({},ia,{key:function(a){if(a.key){var c=OT[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=Ll(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?RT[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Xd,charCode:function(a){return a.type==="keypress"?Ll(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Ll(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),DT=nr(LT),PT=I({},Pl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),rv=nr(PT),BT=I({},ia,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Xd}),zT=nr(BT),FT=I({},oo,{propertyName:0,elapsedTime:0,pseudoElement:0}),$T=nr(FT),UT=I({},Pl,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),HT=nr(UT),WT=[9,13,27,32],Zd=l&&"CompositionEvent"in window,aa=null;l&&"documentMode"in document&&(aa=document.documentMode);var qT=l&&"TextEvent"in window&&!aa,sv=l&&(!Zd||aa&&8<aa&&11>=aa),iv=" ",ov=!1;function av(a,c){switch(a){case"keyup":return WT.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lv(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var ao=!1;function VT(a,c){switch(a){case"compositionend":return lv(c);case"keypress":return c.which!==32?null:(ov=!0,iv);case"textInput":return a=c.data,a===iv&&ov?null:a;default:return null}}function KT(a,c){if(ao)return a==="compositionend"||!Zd&&av(a,c)?(a=Z0(),Il=Kd=Ms=null,ao=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return sv&&c.locale!=="ko"?null:c.data;default:return null}}var GT={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 cv(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!GT[a.type]:c==="textarea"}function uv(a,c,h,v){B(v),c=Ul(c,"onChange"),0<c.length&&(h=new Gd("onChange","change",null,h,v),a.push({event:h,listeners:c}))}var la=null,ca=null;function JT(a){Tv(a,0)}function Bl(a){var c=ho(a);if(ae(c))return a}function YT(a,c){if(a==="change")return c}var dv=!1;if(l){var ef;if(l){var tf="oninput"in document;if(!tf){var fv=document.createElement("div");fv.setAttribute("oninput","return;"),tf=typeof fv.oninput=="function"}ef=tf}else ef=!1;dv=ef&&(!document.documentMode||9<document.documentMode)}function hv(){la&&(la.detachEvent("onpropertychange",pv),ca=la=null)}function pv(a){if(a.propertyName==="value"&&Bl(ca)){var c=[];uv(c,ca,a,rt(a)),Ot(JT,c)}}function QT(a,c,h){a==="focusin"?(hv(),la=c,ca=h,la.attachEvent("onpropertychange",pv)):a==="focusout"&&hv()}function XT(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Bl(ca)}function ZT(a,c){if(a==="click")return Bl(c)}function e2(a,c){if(a==="input"||a==="change")return Bl(c)}function t2(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var Nr=typeof Object.is=="function"?Object.is:t2;function ua(a,c){if(Nr(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var h=Object.keys(a),v=Object.keys(c);if(h.length!==v.length)return!1;for(v=0;v<h.length;v++){var x=h[v];if(!u.call(c,x)||!Nr(a[x],c[x]))return!1}return!0}function mv(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function gv(a,c){var h=mv(a);a=0;for(var v;h;){if(h.nodeType===3){if(v=a+h.textContent.length,a<=c&&v>=c)return{node:h,offset:c-a};a=v}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=mv(h)}}function vv(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?vv(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function yv(){for(var a=window,c=je();c instanceof a.HTMLIFrameElement;){try{var h=typeof c.contentWindow.location.href=="string"}catch{h=!1}if(h)a=c.contentWindow;else break;c=je(a.document)}return c}function nf(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}function n2(a){var c=yv(),h=a.focusedElem,v=a.selectionRange;if(c!==h&&h&&h.ownerDocument&&vv(h.ownerDocument.documentElement,h)){if(v!==null&&nf(h)){if(c=v.start,a=v.end,a===void 0&&(a=c),"selectionStart"in h)h.selectionStart=c,h.selectionEnd=Math.min(a,h.value.length);else if(a=(c=h.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var x=h.textContent.length,_=Math.min(v.start,x);v=v.end===void 0?_:Math.min(v.end,x),!a.extend&&_>v&&(x=v,v=_,_=x),x=gv(h,_);var M=gv(h,v);x&&M&&(a.rangeCount!==1||a.anchorNode!==x.node||a.anchorOffset!==x.offset||a.focusNode!==M.node||a.focusOffset!==M.offset)&&(c=c.createRange(),c.setStart(x.node,x.offset),a.removeAllRanges(),_>v?(a.addRange(c),a.extend(M.node,M.offset)):(c.setEnd(M.node,M.offset),a.addRange(c)))}}for(c=[],a=h;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<c.length;h++)a=c[h],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var r2=l&&"documentMode"in document&&11>=document.documentMode,lo=null,rf=null,da=null,sf=!1;function bv(a,c,h){var v=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;sf||lo==null||lo!==je(v)||(v=lo,"selectionStart"in v&&nf(v)?v={start:v.selectionStart,end:v.selectionEnd}:(v=(v.ownerDocument&&v.ownerDocument.defaultView||window).getSelection(),v={anchorNode:v.anchorNode,anchorOffset:v.anchorOffset,focusNode:v.focusNode,focusOffset:v.focusOffset}),da&&ua(da,v)||(da=v,v=Ul(rf,"onSelect"),0<v.length&&(c=new Gd("onSelect","select",null,c,h),a.push({event:c,listeners:v}),c.target=lo)))}function zl(a,c){var h={};return h[a.toLowerCase()]=c.toLowerCase(),h["Webkit"+a]="webkit"+c,h["Moz"+a]="moz"+c,h}var co={animationend:zl("Animation","AnimationEnd"),animationiteration:zl("Animation","AnimationIteration"),animationstart:zl("Animation","AnimationStart"),transitionend:zl("Transition","TransitionEnd")},of={},xv={};l&&(xv=document.createElement("div").style,"AnimationEvent"in window||(delete co.animationend.animation,delete co.animationiteration.animation,delete co.animationstart.animation),"TransitionEvent"in window||delete co.transitionend.transition);function Fl(a){if(of[a])return of[a];if(!co[a])return a;var c=co[a],h;for(h in c)if(c.hasOwnProperty(h)&&h in xv)return of[a]=c[h];return a}var wv=Fl("animationend"),kv=Fl("animationiteration"),Sv=Fl("animationstart"),Ev=Fl("transitionend"),_v=new Map,Nv="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function As(a,c){_v.set(a,c),i(c,[a])}for(var af=0;af<Nv.length;af++){var lf=Nv[af],s2=lf.toLowerCase(),i2=lf[0].toUpperCase()+lf.slice(1);As(s2,"on"+i2)}As(wv,"onAnimationEnd"),As(kv,"onAnimationIteration"),As(Sv,"onAnimationStart"),As("dblclick","onDoubleClick"),As("focusin","onFocus"),As("focusout","onBlur"),As(Ev,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var fa="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(" "),o2=new Set("cancel close invalid load scroll toggle".split(" ").concat(fa));function Cv(a,c,h){var v=a.type||"unknown-event";a.currentTarget=h,Fd(v,c,void 0,a),a.currentTarget=null}function Tv(a,c){c=(c&4)!==0;for(var h=0;h<a.length;h++){var v=a[h],x=v.event;v=v.listeners;e:{var _=void 0;if(c)for(var M=v.length-1;0<=M;M--){var P=v[M],H=P.instance,ie=P.currentTarget;if(P=P.listener,H!==_&&x.isPropagationStopped())break e;Cv(x,P,ie),_=H}else for(M=0;M<v.length;M++){if(P=v[M],H=P.instance,ie=P.currentTarget,P=P.listener,H!==_&&x.isPropagationStopped())break e;Cv(x,P,ie),_=H}}}if(Es)throw a=pi,Es=!1,pi=null,a}function zt(a,c){var h=c[gf];h===void 0&&(h=c[gf]=new Set);var v=a+"__bubble";h.has(v)||(Mv(c,a,2,!1),h.add(v))}function cf(a,c,h){var v=0;c&&(v|=4),Mv(h,a,v,c)}var $l="_reactListening"+Math.random().toString(36).slice(2);function ha(a){if(!a[$l]){a[$l]=!0,r.forEach(function(h){h!=="selectionchange"&&(o2.has(h)||cf(h,!1,a),cf(h,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[$l]||(c[$l]=!0,cf("selectionchange",!1,c))}}function Mv(a,c,h,v){switch(X0(c)){case 1:var x=xT;break;case 4:x=wT;break;default:x=qd}h=x.bind(null,c,h,a),x=void 0,!Re||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(x=!0),v?x!==void 0?a.addEventListener(c,h,{capture:!0,passive:x}):a.addEventListener(c,h,!0):x!==void 0?a.addEventListener(c,h,{passive:x}):a.addEventListener(c,h,!1)}function uf(a,c,h,v,x){var _=v;if((c&1)===0&&(c&2)===0&&v!==null)e:for(;;){if(v===null)return;var M=v.tag;if(M===3||M===4){var P=v.stateNode.containerInfo;if(P===x||P.nodeType===8&&P.parentNode===x)break;if(M===4)for(M=v.return;M!==null;){var H=M.tag;if((H===3||H===4)&&(H=M.stateNode.containerInfo,H===x||H.nodeType===8&&H.parentNode===x))return;M=M.return}for(;P!==null;){if(M=xi(P),M===null)return;if(H=M.tag,H===5||H===6){v=_=M;continue e}P=P.parentNode}}v=v.return}Ot(function(){var ie=_,me=rt(h),ge=[];e:{var he=_v.get(a);if(he!==void 0){var Oe=Gd,Pe=a;switch(a){case"keypress":if(Ll(h)===0)break e;case"keydown":case"keyup":Oe=DT;break;case"focusin":Pe="focus",Oe=Qd;break;case"focusout":Pe="blur",Oe=Qd;break;case"beforeblur":case"afterblur":Oe=Qd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Oe=tv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Oe=ET;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Oe=zT;break;case wv:case kv:case Sv:Oe=CT;break;case Ev:Oe=$T;break;case"scroll":Oe=kT;break;case"wheel":Oe=HT;break;case"copy":case"cut":case"paste":Oe=MT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Oe=rv}var Fe=(c&4)!==0,tn=!Fe&&a==="scroll",te=Fe?he!==null?he+"Capture":null:he;Fe=[];for(var q=ie,ne;q!==null;){ne=q;var we=ne.stateNode;if(ne.tag===5&&we!==null&&(ne=we,te!==null&&(we=Ie(q,te),we!=null&&Fe.push(pa(q,we,ne)))),tn)break;q=q.return}0<Fe.length&&(he=new Oe(he,Pe,null,h,me),ge.push({event:he,listeners:Fe}))}}if((c&7)===0){e:{if(he=a==="mouseover"||a==="pointerover",Oe=a==="mouseout"||a==="pointerout",he&&h!==Et&&(Pe=h.relatedTarget||h.fromElement)&&(xi(Pe)||Pe[ts]))break e;if((Oe||he)&&(he=me.window===me?me:(he=me.ownerDocument)?he.defaultView||he.parentWindow:window,Oe?(Pe=h.relatedTarget||h.toElement,Oe=ie,Pe=Pe?xi(Pe):null,Pe!==null&&(tn=es(Pe),Pe!==tn||Pe.tag!==5&&Pe.tag!==6)&&(Pe=null)):(Oe=null,Pe=ie),Oe!==Pe)){if(Fe=tv,we="onMouseLeave",te="onMouseEnter",q="mouse",(a==="pointerout"||a==="pointerover")&&(Fe=rv,we="onPointerLeave",te="onPointerEnter",q="pointer"),tn=Oe==null?he:ho(Oe),ne=Pe==null?he:ho(Pe),he=new Fe(we,q+"leave",Oe,h,me),he.target=tn,he.relatedTarget=ne,we=null,xi(me)===ie&&(Fe=new Fe(te,q+"enter",Pe,h,me),Fe.target=ne,Fe.relatedTarget=tn,we=Fe),tn=we,Oe&&Pe)t:{for(Fe=Oe,te=Pe,q=0,ne=Fe;ne;ne=uo(ne))q++;for(ne=0,we=te;we;we=uo(we))ne++;for(;0<q-ne;)Fe=uo(Fe),q--;for(;0<ne-q;)te=uo(te),ne--;for(;q--;){if(Fe===te||te!==null&&Fe===te.alternate)break t;Fe=uo(Fe),te=uo(te)}Fe=null}else Fe=null;Oe!==null&&Av(ge,he,Oe,Fe,!1),Pe!==null&&tn!==null&&Av(ge,tn,Pe,Fe,!0)}}e:{if(he=ie?ho(ie):window,Oe=he.nodeName&&he.nodeName.toLowerCase(),Oe==="select"||Oe==="input"&&he.type==="file")var Ue=YT;else if(cv(he))if(dv)Ue=e2;else{Ue=XT;var Qe=QT}else(Oe=he.nodeName)&&Oe.toLowerCase()==="input"&&(he.type==="checkbox"||he.type==="radio")&&(Ue=ZT);if(Ue&&(Ue=Ue(a,ie))){uv(ge,Ue,h,me);break e}Qe&&Qe(a,he,ie),a==="focusout"&&(Qe=he._wrapperState)&&Qe.controlled&&he.type==="number"&&$e(he,"number",he.value)}switch(Qe=ie?ho(ie):window,a){case"focusin":(cv(Qe)||Qe.contentEditable==="true")&&(lo=Qe,rf=ie,da=null);break;case"focusout":da=rf=lo=null;break;case"mousedown":sf=!0;break;case"contextmenu":case"mouseup":case"dragend":sf=!1,bv(ge,h,me);break;case"selectionchange":if(r2)break;case"keydown":case"keyup":bv(ge,h,me)}var Xe;if(Zd)e:{switch(a){case"compositionstart":var at="onCompositionStart";break e;case"compositionend":at="onCompositionEnd";break e;case"compositionupdate":at="onCompositionUpdate";break e}at=void 0}else ao?av(a,h)&&(at="onCompositionEnd"):a==="keydown"&&h.keyCode===229&&(at="onCompositionStart");at&&(sv&&h.locale!=="ko"&&(ao||at!=="onCompositionStart"?at==="onCompositionEnd"&&ao&&(Xe=Z0()):(Ms=me,Kd="value"in Ms?Ms.value:Ms.textContent,ao=!0)),Qe=Ul(ie,at),0<Qe.length&&(at=new nv(at,a,null,h,me),ge.push({event:at,listeners:Qe}),Xe?at.data=Xe:(Xe=lv(h),Xe!==null&&(at.data=Xe)))),(Xe=qT?VT(a,h):KT(a,h))&&(ie=Ul(ie,"onBeforeInput"),0<ie.length&&(me=new nv("onBeforeInput","beforeinput",null,h,me),ge.push({event:me,listeners:ie}),me.data=Xe))}Tv(ge,c)})}function pa(a,c,h){return{instance:a,listener:c,currentTarget:h}}function Ul(a,c){for(var h=c+"Capture",v=[];a!==null;){var x=a,_=x.stateNode;x.tag===5&&_!==null&&(x=_,_=Ie(a,h),_!=null&&v.unshift(pa(a,_,x)),_=Ie(a,c),_!=null&&v.push(pa(a,_,x))),a=a.return}return v}function uo(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Av(a,c,h,v,x){for(var _=c._reactName,M=[];h!==null&&h!==v;){var P=h,H=P.alternate,ie=P.stateNode;if(H!==null&&H===v)break;P.tag===5&&ie!==null&&(P=ie,x?(H=Ie(h,_),H!=null&&M.unshift(pa(h,H,P))):x||(H=Ie(h,_),H!=null&&M.push(pa(h,H,P)))),h=h.return}M.length!==0&&a.push({event:c,listeners:M})}var a2=/\r\n?/g,l2=/\u0000|\uFFFD/g;function Ov(a){return(typeof a=="string"?a:""+a).replace(a2,`
38
+ `).replace(l2,"")}function Hl(a,c,h){if(c=Ov(c),Ov(a)!==c&&h)throw Error(n(425))}function Wl(){}var df=null,ff=null;function hf(a,c){return a==="textarea"||a==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var pf=typeof setTimeout=="function"?setTimeout:void 0,c2=typeof clearTimeout=="function"?clearTimeout:void 0,Rv=typeof Promise=="function"?Promise:void 0,u2=typeof queueMicrotask=="function"?queueMicrotask:typeof Rv<"u"?function(a){return Rv.resolve(null).then(a).catch(d2)}:pf;function d2(a){setTimeout(function(){throw a})}function mf(a,c){var h=c,v=0;do{var x=h.nextSibling;if(a.removeChild(h),x&&x.nodeType===8)if(h=x.data,h==="/$"){if(v===0){a.removeChild(x),sa(c);return}v--}else h!=="$"&&h!=="$?"&&h!=="$!"||v++;h=x}while(h);sa(c)}function Os(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return a}function jv(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var h=a.data;if(h==="$"||h==="$!"||h==="$?"){if(c===0)return a;c--}else h==="/$"&&c++}a=a.previousSibling}return null}var fo=Math.random().toString(36).slice(2),Hr="__reactFiber$"+fo,ma="__reactProps$"+fo,ts="__reactContainer$"+fo,gf="__reactEvents$"+fo,f2="__reactListeners$"+fo,h2="__reactHandles$"+fo;function xi(a){var c=a[Hr];if(c)return c;for(var h=a.parentNode;h;){if(c=h[ts]||h[Hr]){if(h=c.alternate,c.child!==null||h!==null&&h.child!==null)for(a=jv(a);a!==null;){if(h=a[Hr])return h;a=jv(a)}return c}a=h,h=a.parentNode}return null}function ga(a){return a=a[Hr]||a[ts],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function ho(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function ql(a){return a[ma]||null}var vf=[],po=-1;function Rs(a){return{current:a}}function Ft(a){0>po||(a.current=vf[po],vf[po]=null,po--)}function Lt(a,c){po++,vf[po]=a.current,a.current=c}var js={},Rn=Rs(js),Kn=Rs(!1),wi=js;function mo(a,c){var h=a.type.contextTypes;if(!h)return js;var v=a.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===c)return v.__reactInternalMemoizedMaskedChildContext;var x={},_;for(_ in h)x[_]=c[_];return v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=x),x}function Gn(a){return a=a.childContextTypes,a!=null}function Vl(){Ft(Kn),Ft(Rn)}function Iv(a,c,h){if(Rn.current!==js)throw Error(n(168));Lt(Rn,c),Lt(Kn,h)}function Lv(a,c,h){var v=a.stateNode;if(c=c.childContextTypes,typeof v.getChildContext!="function")return h;v=v.getChildContext();for(var x in v)if(!(x in c))throw Error(n(108,le(a)||"Unknown",x));return I({},h,v)}function Kl(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||js,wi=Rn.current,Lt(Rn,a),Lt(Kn,Kn.current),!0}function Dv(a,c,h){var v=a.stateNode;if(!v)throw Error(n(169));h?(a=Lv(a,c,wi),v.__reactInternalMemoizedMergedChildContext=a,Ft(Kn),Ft(Rn),Lt(Rn,a)):Ft(Kn),Lt(Kn,h)}var ns=null,Gl=!1,yf=!1;function Pv(a){ns===null?ns=[a]:ns.push(a)}function p2(a){Gl=!0,Pv(a)}function Is(){if(!yf&&ns!==null){yf=!0;var a=0,c=vt;try{var h=ns;for(vt=1;a<h.length;a++){var v=h[a];do v=v(!0);while(v!==null)}ns=null,Gl=!1}catch(x){throw ns!==null&&(ns=ns.slice(a+1)),Nl(Xo,Is),x}finally{vt=c,yf=!1}}return null}var go=[],vo=0,Jl=null,Yl=0,dr=[],fr=0,ki=null,rs=1,ss="";function Si(a,c){go[vo++]=Yl,go[vo++]=Jl,Jl=a,Yl=c}function Bv(a,c,h){dr[fr++]=rs,dr[fr++]=ss,dr[fr++]=ki,ki=a;var v=rs;a=ss;var x=32-Wt(v)-1;v&=~(1<<x),h+=1;var _=32-Wt(c)+x;if(30<_){var M=x-x%5;_=(v&(1<<M)-1).toString(32),v>>=M,x-=M,rs=1<<32-Wt(c)+x|h<<x|v,ss=_+a}else rs=1<<_|h<<x|v,ss=a}function bf(a){a.return!==null&&(Si(a,1),Bv(a,1,0))}function xf(a){for(;a===Jl;)Jl=go[--vo],go[vo]=null,Yl=go[--vo],go[vo]=null;for(;a===ki;)ki=dr[--fr],dr[fr]=null,ss=dr[--fr],dr[fr]=null,rs=dr[--fr],dr[fr]=null}var rr=null,sr=null,Ut=!1,Cr=null;function zv(a,c){var h=gr(5,null,null,0);h.elementType="DELETED",h.stateNode=c,h.return=a,c=a.deletions,c===null?(a.deletions=[h],a.flags|=16):c.push(h)}function Fv(a,c){switch(a.tag){case 5:var h=a.type;return c=c.nodeType!==1||h.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,rr=a,sr=Os(c.firstChild),!0):!1;case 6:return c=a.pendingProps===""||c.nodeType!==3?null:c,c!==null?(a.stateNode=c,rr=a,sr=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(h=ki!==null?{id:rs,overflow:ss}:null,a.memoizedState={dehydrated:c,treeContext:h,retryLane:1073741824},h=gr(18,null,null,0),h.stateNode=c,h.return=a,a.child=h,rr=a,sr=null,!0):!1;default:return!1}}function wf(a){return(a.mode&1)!==0&&(a.flags&128)===0}function kf(a){if(Ut){var c=sr;if(c){var h=c;if(!Fv(a,c)){if(wf(a))throw Error(n(418));c=Os(h.nextSibling);var v=rr;c&&Fv(a,c)?zv(v,h):(a.flags=a.flags&-4097|2,Ut=!1,rr=a)}}else{if(wf(a))throw Error(n(418));a.flags=a.flags&-4097|2,Ut=!1,rr=a}}}function $v(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;rr=a}function Ql(a){if(a!==rr)return!1;if(!Ut)return $v(a),Ut=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!hf(a.type,a.memoizedProps)),c&&(c=sr)){if(wf(a))throw Uv(),Error(n(418));for(;c;)zv(a,c),c=Os(c.nextSibling)}if($v(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,c=0;a;){if(a.nodeType===8){var h=a.data;if(h==="/$"){if(c===0){sr=Os(a.nextSibling);break e}c--}else h!=="$"&&h!=="$!"&&h!=="$?"||c++}a=a.nextSibling}sr=null}}else sr=rr?Os(a.stateNode.nextSibling):null;return!0}function Uv(){for(var a=sr;a;)a=Os(a.nextSibling)}function yo(){sr=rr=null,Ut=!1}function Sf(a){Cr===null?Cr=[a]:Cr.push(a)}var m2=T.ReactCurrentBatchConfig;function va(a,c,h){if(a=h.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(n(309));var v=h.stateNode}if(!v)throw Error(n(147,a));var x=v,_=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===_?c.ref:(c=function(M){var P=x.refs;M===null?delete P[_]:P[_]=M},c._stringRef=_,c)}if(typeof a!="string")throw Error(n(284));if(!h._owner)throw Error(n(290,a))}return a}function Xl(a,c){throw a=Object.prototype.toString.call(c),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function Hv(a){var c=a._init;return c(a._payload)}function Wv(a){function c(te,q){if(a){var ne=te.deletions;ne===null?(te.deletions=[q],te.flags|=16):ne.push(q)}}function h(te,q){if(!a)return null;for(;q!==null;)c(te,q),q=q.sibling;return null}function v(te,q){for(te=new Map;q!==null;)q.key!==null?te.set(q.key,q):te.set(q.index,q),q=q.sibling;return te}function x(te,q){return te=Us(te,q),te.index=0,te.sibling=null,te}function _(te,q,ne){return te.index=ne,a?(ne=te.alternate,ne!==null?(ne=ne.index,ne<q?(te.flags|=2,q):ne):(te.flags|=2,q)):(te.flags|=1048576,q)}function M(te){return a&&te.alternate===null&&(te.flags|=2),te}function P(te,q,ne,we){return q===null||q.tag!==6?(q=ph(ne,te.mode,we),q.return=te,q):(q=x(q,ne),q.return=te,q)}function H(te,q,ne,we){var Ue=ne.type;return Ue===L?me(te,q,ne.props.children,we,ne.key):q!==null&&(q.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===U&&Hv(Ue)===q.type)?(we=x(q,ne.props),we.ref=va(te,q,ne),we.return=te,we):(we=kc(ne.type,ne.key,ne.props,null,te.mode,we),we.ref=va(te,q,ne),we.return=te,we)}function ie(te,q,ne,we){return q===null||q.tag!==4||q.stateNode.containerInfo!==ne.containerInfo||q.stateNode.implementation!==ne.implementation?(q=mh(ne,te.mode,we),q.return=te,q):(q=x(q,ne.children||[]),q.return=te,q)}function me(te,q,ne,we,Ue){return q===null||q.tag!==7?(q=Oi(ne,te.mode,we,Ue),q.return=te,q):(q=x(q,ne),q.return=te,q)}function ge(te,q,ne){if(typeof q=="string"&&q!==""||typeof q=="number")return q=ph(""+q,te.mode,ne),q.return=te,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case C:return ne=kc(q.type,q.key,q.props,null,te.mode,ne),ne.ref=va(te,null,q),ne.return=te,ne;case R:return q=mh(q,te.mode,ne),q.return=te,q;case U:var we=q._init;return ge(te,we(q._payload),ne)}if(ye(q)||Y(q))return q=Oi(q,te.mode,ne,null),q.return=te,q;Xl(te,q)}return null}function he(te,q,ne,we){var Ue=q!==null?q.key:null;if(typeof ne=="string"&&ne!==""||typeof ne=="number")return Ue!==null?null:P(te,q,""+ne,we);if(typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case C:return ne.key===Ue?H(te,q,ne,we):null;case R:return ne.key===Ue?ie(te,q,ne,we):null;case U:return Ue=ne._init,he(te,q,Ue(ne._payload),we)}if(ye(ne)||Y(ne))return Ue!==null?null:me(te,q,ne,we,null);Xl(te,ne)}return null}function Oe(te,q,ne,we,Ue){if(typeof we=="string"&&we!==""||typeof we=="number")return te=te.get(ne)||null,P(q,te,""+we,Ue);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case C:return te=te.get(we.key===null?ne:we.key)||null,H(q,te,we,Ue);case R:return te=te.get(we.key===null?ne:we.key)||null,ie(q,te,we,Ue);case U:var Qe=we._init;return Oe(te,q,ne,Qe(we._payload),Ue)}if(ye(we)||Y(we))return te=te.get(ne)||null,me(q,te,we,Ue,null);Xl(q,we)}return null}function Pe(te,q,ne,we){for(var Ue=null,Qe=null,Xe=q,at=q=0,pn=null;Xe!==null&&at<ne.length;at++){Xe.index>at?(pn=Xe,Xe=null):pn=Xe.sibling;var xt=he(te,Xe,ne[at],we);if(xt===null){Xe===null&&(Xe=pn);break}a&&Xe&&xt.alternate===null&&c(te,Xe),q=_(xt,q,at),Qe===null?Ue=xt:Qe.sibling=xt,Qe=xt,Xe=pn}if(at===ne.length)return h(te,Xe),Ut&&Si(te,at),Ue;if(Xe===null){for(;at<ne.length;at++)Xe=ge(te,ne[at],we),Xe!==null&&(q=_(Xe,q,at),Qe===null?Ue=Xe:Qe.sibling=Xe,Qe=Xe);return Ut&&Si(te,at),Ue}for(Xe=v(te,Xe);at<ne.length;at++)pn=Oe(Xe,te,at,ne[at],we),pn!==null&&(a&&pn.alternate!==null&&Xe.delete(pn.key===null?at:pn.key),q=_(pn,q,at),Qe===null?Ue=pn:Qe.sibling=pn,Qe=pn);return a&&Xe.forEach(function(Hs){return c(te,Hs)}),Ut&&Si(te,at),Ue}function Fe(te,q,ne,we){var Ue=Y(ne);if(typeof Ue!="function")throw Error(n(150));if(ne=Ue.call(ne),ne==null)throw Error(n(151));for(var Qe=Ue=null,Xe=q,at=q=0,pn=null,xt=ne.next();Xe!==null&&!xt.done;at++,xt=ne.next()){Xe.index>at?(pn=Xe,Xe=null):pn=Xe.sibling;var Hs=he(te,Xe,xt.value,we);if(Hs===null){Xe===null&&(Xe=pn);break}a&&Xe&&Hs.alternate===null&&c(te,Xe),q=_(Hs,q,at),Qe===null?Ue=Hs:Qe.sibling=Hs,Qe=Hs,Xe=pn}if(xt.done)return h(te,Xe),Ut&&Si(te,at),Ue;if(Xe===null){for(;!xt.done;at++,xt=ne.next())xt=ge(te,xt.value,we),xt!==null&&(q=_(xt,q,at),Qe===null?Ue=xt:Qe.sibling=xt,Qe=xt);return Ut&&Si(te,at),Ue}for(Xe=v(te,Xe);!xt.done;at++,xt=ne.next())xt=Oe(Xe,te,at,xt.value,we),xt!==null&&(a&&xt.alternate!==null&&Xe.delete(xt.key===null?at:xt.key),q=_(xt,q,at),Qe===null?Ue=xt:Qe.sibling=xt,Qe=xt);return a&&Xe.forEach(function(G2){return c(te,G2)}),Ut&&Si(te,at),Ue}function tn(te,q,ne,we){if(typeof ne=="object"&&ne!==null&&ne.type===L&&ne.key===null&&(ne=ne.props.children),typeof ne=="object"&&ne!==null){switch(ne.$$typeof){case C:e:{for(var Ue=ne.key,Qe=q;Qe!==null;){if(Qe.key===Ue){if(Ue=ne.type,Ue===L){if(Qe.tag===7){h(te,Qe.sibling),q=x(Qe,ne.props.children),q.return=te,te=q;break e}}else if(Qe.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===U&&Hv(Ue)===Qe.type){h(te,Qe.sibling),q=x(Qe,ne.props),q.ref=va(te,Qe,ne),q.return=te,te=q;break e}h(te,Qe);break}else c(te,Qe);Qe=Qe.sibling}ne.type===L?(q=Oi(ne.props.children,te.mode,we,ne.key),q.return=te,te=q):(we=kc(ne.type,ne.key,ne.props,null,te.mode,we),we.ref=va(te,q,ne),we.return=te,te=we)}return M(te);case R:e:{for(Qe=ne.key;q!==null;){if(q.key===Qe)if(q.tag===4&&q.stateNode.containerInfo===ne.containerInfo&&q.stateNode.implementation===ne.implementation){h(te,q.sibling),q=x(q,ne.children||[]),q.return=te,te=q;break e}else{h(te,q);break}else c(te,q);q=q.sibling}q=mh(ne,te.mode,we),q.return=te,te=q}return M(te);case U:return Qe=ne._init,tn(te,q,Qe(ne._payload),we)}if(ye(ne))return Pe(te,q,ne,we);if(Y(ne))return Fe(te,q,ne,we);Xl(te,ne)}return typeof ne=="string"&&ne!==""||typeof ne=="number"?(ne=""+ne,q!==null&&q.tag===6?(h(te,q.sibling),q=x(q,ne),q.return=te,te=q):(h(te,q),q=ph(ne,te.mode,we),q.return=te,te=q),M(te)):h(te,q)}return tn}var bo=Wv(!0),qv=Wv(!1),Zl=Rs(null),ec=null,xo=null,Ef=null;function _f(){Ef=xo=ec=null}function Nf(a){var c=Zl.current;Ft(Zl),a._currentValue=c}function Cf(a,c,h){for(;a!==null;){var v=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,v!==null&&(v.childLanes|=c)):v!==null&&(v.childLanes&c)!==c&&(v.childLanes|=c),a===h)break;a=a.return}}function wo(a,c){ec=a,Ef=xo=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&c)!==0&&(Jn=!0),a.firstContext=null)}function hr(a){var c=a._currentValue;if(Ef!==a)if(a={context:a,memoizedValue:c,next:null},xo===null){if(ec===null)throw Error(n(308));xo=a,ec.dependencies={lanes:0,firstContext:a}}else xo=xo.next=a;return c}var Ei=null;function Tf(a){Ei===null?Ei=[a]:Ei.push(a)}function Vv(a,c,h,v){var x=c.interleaved;return x===null?(h.next=h,Tf(c)):(h.next=x.next,x.next=h),c.interleaved=h,is(a,v)}function is(a,c){a.lanes|=c;var h=a.alternate;for(h!==null&&(h.lanes|=c),h=a,a=a.return;a!==null;)a.childLanes|=c,h=a.alternate,h!==null&&(h.childLanes|=c),h=a,a=a.return;return h.tag===3?h.stateNode:null}var Ls=!1;function Mf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kv(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function as(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function Ds(a,c,h){var v=a.updateQueue;if(v===null)return null;if(v=v.shared,(yt&2)!==0){var x=v.pending;return x===null?c.next=c:(c.next=x.next,x.next=c),v.pending=c,is(a,h)}return x=v.interleaved,x===null?(c.next=c,Tf(v)):(c.next=x.next,x.next=c),v.interleaved=c,is(a,h)}function tc(a,c,h){if(c=c.updateQueue,c!==null&&(c=c.shared,(h&4194240)!==0)){var v=c.lanes;v&=a.pendingLanes,h|=v,c.lanes=h,ea(a,h)}}function Gv(a,c){var h=a.updateQueue,v=a.alternate;if(v!==null&&(v=v.updateQueue,h===v)){var x=null,_=null;if(h=h.firstBaseUpdate,h!==null){do{var M={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};_===null?x=_=M:_=_.next=M,h=h.next}while(h!==null);_===null?x=_=c:_=_.next=c}else x=_=c;h={baseState:v.baseState,firstBaseUpdate:x,lastBaseUpdate:_,shared:v.shared,effects:v.effects},a.updateQueue=h;return}a=h.lastBaseUpdate,a===null?h.firstBaseUpdate=c:a.next=c,h.lastBaseUpdate=c}function nc(a,c,h,v){var x=a.updateQueue;Ls=!1;var _=x.firstBaseUpdate,M=x.lastBaseUpdate,P=x.shared.pending;if(P!==null){x.shared.pending=null;var H=P,ie=H.next;H.next=null,M===null?_=ie:M.next=ie,M=H;var me=a.alternate;me!==null&&(me=me.updateQueue,P=me.lastBaseUpdate,P!==M&&(P===null?me.firstBaseUpdate=ie:P.next=ie,me.lastBaseUpdate=H))}if(_!==null){var ge=x.baseState;M=0,me=ie=H=null,P=_;do{var he=P.lane,Oe=P.eventTime;if((v&he)===he){me!==null&&(me=me.next={eventTime:Oe,lane:0,tag:P.tag,payload:P.payload,callback:P.callback,next:null});e:{var Pe=a,Fe=P;switch(he=c,Oe=h,Fe.tag){case 1:if(Pe=Fe.payload,typeof Pe=="function"){ge=Pe.call(Oe,ge,he);break e}ge=Pe;break e;case 3:Pe.flags=Pe.flags&-65537|128;case 0:if(Pe=Fe.payload,he=typeof Pe=="function"?Pe.call(Oe,ge,he):Pe,he==null)break e;ge=I({},ge,he);break e;case 2:Ls=!0}}P.callback!==null&&P.lane!==0&&(a.flags|=64,he=x.effects,he===null?x.effects=[P]:he.push(P))}else Oe={eventTime:Oe,lane:he,tag:P.tag,payload:P.payload,callback:P.callback,next:null},me===null?(ie=me=Oe,H=ge):me=me.next=Oe,M|=he;if(P=P.next,P===null){if(P=x.shared.pending,P===null)break;he=P,P=he.next,he.next=null,x.lastBaseUpdate=he,x.shared.pending=null}}while(!0);if(me===null&&(H=ge),x.baseState=H,x.firstBaseUpdate=ie,x.lastBaseUpdate=me,c=x.shared.interleaved,c!==null){x=c;do M|=x.lane,x=x.next;while(x!==c)}else _===null&&(x.shared.lanes=0);Ci|=M,a.lanes=M,a.memoizedState=ge}}function Jv(a,c,h){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var v=a[c],x=v.callback;if(x!==null){if(v.callback=null,v=h,typeof x!="function")throw Error(n(191,x));x.call(v)}}}var ya={},Wr=Rs(ya),ba=Rs(ya),xa=Rs(ya);function _i(a){if(a===ya)throw Error(n(174));return a}function Af(a,c){switch(Lt(xa,c),Lt(ba,a),Lt(Wr,ya),a=c.nodeType,a){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:ht(null,"");break;default:a=a===8?c.parentNode:c,c=a.namespaceURI||null,a=a.tagName,c=ht(c,a)}Ft(Wr),Lt(Wr,c)}function ko(){Ft(Wr),Ft(ba),Ft(xa)}function Yv(a){_i(xa.current);var c=_i(Wr.current),h=ht(c,a.type);c!==h&&(Lt(ba,a),Lt(Wr,h))}function Of(a){ba.current===a&&(Ft(Wr),Ft(ba))}var qt=Rs(0);function rc(a){for(var c=a;c!==null;){if(c.tag===13){var h=c.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Rf=[];function jf(){for(var a=0;a<Rf.length;a++)Rf[a]._workInProgressVersionPrimary=null;Rf.length=0}var sc=T.ReactCurrentDispatcher,If=T.ReactCurrentBatchConfig,Ni=0,Vt=null,ln=null,fn=null,ic=!1,wa=!1,ka=0,g2=0;function jn(){throw Error(n(321))}function Lf(a,c){if(c===null)return!1;for(var h=0;h<c.length&&h<a.length;h++)if(!Nr(a[h],c[h]))return!1;return!0}function Df(a,c,h,v,x,_){if(Ni=_,Vt=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,sc.current=a===null||a.memoizedState===null?x2:w2,a=h(v,x),wa){_=0;do{if(wa=!1,ka=0,25<=_)throw Error(n(301));_+=1,fn=ln=null,c.updateQueue=null,sc.current=k2,a=h(v,x)}while(wa)}if(sc.current=lc,c=ln!==null&&ln.next!==null,Ni=0,fn=ln=Vt=null,ic=!1,c)throw Error(n(300));return a}function Pf(){var a=ka!==0;return ka=0,a}function qr(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fn===null?Vt.memoizedState=fn=a:fn=fn.next=a,fn}function pr(){if(ln===null){var a=Vt.alternate;a=a!==null?a.memoizedState:null}else a=ln.next;var c=fn===null?Vt.memoizedState:fn.next;if(c!==null)fn=c,ln=a;else{if(a===null)throw Error(n(310));ln=a,a={memoizedState:ln.memoizedState,baseState:ln.baseState,baseQueue:ln.baseQueue,queue:ln.queue,next:null},fn===null?Vt.memoizedState=fn=a:fn=fn.next=a}return fn}function Sa(a,c){return typeof c=="function"?c(a):c}function Bf(a){var c=pr(),h=c.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=a;var v=ln,x=v.baseQueue,_=h.pending;if(_!==null){if(x!==null){var M=x.next;x.next=_.next,_.next=M}v.baseQueue=x=_,h.pending=null}if(x!==null){_=x.next,v=v.baseState;var P=M=null,H=null,ie=_;do{var me=ie.lane;if((Ni&me)===me)H!==null&&(H=H.next={lane:0,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null}),v=ie.hasEagerState?ie.eagerState:a(v,ie.action);else{var ge={lane:me,action:ie.action,hasEagerState:ie.hasEagerState,eagerState:ie.eagerState,next:null};H===null?(P=H=ge,M=v):H=H.next=ge,Vt.lanes|=me,Ci|=me}ie=ie.next}while(ie!==null&&ie!==_);H===null?M=v:H.next=P,Nr(v,c.memoizedState)||(Jn=!0),c.memoizedState=v,c.baseState=M,c.baseQueue=H,h.lastRenderedState=v}if(a=h.interleaved,a!==null){x=a;do _=x.lane,Vt.lanes|=_,Ci|=_,x=x.next;while(x!==a)}else x===null&&(h.lanes=0);return[c.memoizedState,h.dispatch]}function zf(a){var c=pr(),h=c.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=a;var v=h.dispatch,x=h.pending,_=c.memoizedState;if(x!==null){h.pending=null;var M=x=x.next;do _=a(_,M.action),M=M.next;while(M!==x);Nr(_,c.memoizedState)||(Jn=!0),c.memoizedState=_,c.baseQueue===null&&(c.baseState=_),h.lastRenderedState=_}return[_,v]}function Qv(){}function Xv(a,c){var h=Vt,v=pr(),x=c(),_=!Nr(v.memoizedState,x);if(_&&(v.memoizedState=x,Jn=!0),v=v.queue,Ff(ty.bind(null,h,v,a),[a]),v.getSnapshot!==c||_||fn!==null&&fn.memoizedState.tag&1){if(h.flags|=2048,Ea(9,ey.bind(null,h,v,x,c),void 0,null),hn===null)throw Error(n(349));(Ni&30)!==0||Zv(h,c,x)}return x}function Zv(a,c,h){a.flags|=16384,a={getSnapshot:c,value:h},c=Vt.updateQueue,c===null?(c={lastEffect:null,stores:null},Vt.updateQueue=c,c.stores=[a]):(h=c.stores,h===null?c.stores=[a]:h.push(a))}function ey(a,c,h,v){c.value=h,c.getSnapshot=v,ny(c)&&ry(a)}function ty(a,c,h){return h(function(){ny(c)&&ry(a)})}function ny(a){var c=a.getSnapshot;a=a.value;try{var h=c();return!Nr(a,h)}catch{return!0}}function ry(a){var c=is(a,1);c!==null&&Or(c,a,1,-1)}function sy(a){var c=qr();return typeof a=="function"&&(a=a()),c.memoizedState=c.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Sa,lastRenderedState:a},c.queue=a,a=a.dispatch=b2.bind(null,Vt,a),[c.memoizedState,a]}function Ea(a,c,h,v){return a={tag:a,create:c,destroy:h,deps:v,next:null},c=Vt.updateQueue,c===null?(c={lastEffect:null,stores:null},Vt.updateQueue=c,c.lastEffect=a.next=a):(h=c.lastEffect,h===null?c.lastEffect=a.next=a:(v=h.next,h.next=a,a.next=v,c.lastEffect=a)),a}function iy(){return pr().memoizedState}function oc(a,c,h,v){var x=qr();Vt.flags|=a,x.memoizedState=Ea(1|c,h,void 0,v===void 0?null:v)}function ac(a,c,h,v){var x=pr();v=v===void 0?null:v;var _=void 0;if(ln!==null){var M=ln.memoizedState;if(_=M.destroy,v!==null&&Lf(v,M.deps)){x.memoizedState=Ea(c,h,_,v);return}}Vt.flags|=a,x.memoizedState=Ea(1|c,h,_,v)}function oy(a,c){return oc(8390656,8,a,c)}function Ff(a,c){return ac(2048,8,a,c)}function ay(a,c){return ac(4,2,a,c)}function ly(a,c){return ac(4,4,a,c)}function cy(a,c){if(typeof c=="function")return a=a(),c(a),function(){c(null)};if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function uy(a,c,h){return h=h!=null?h.concat([a]):null,ac(4,4,cy.bind(null,c,a),h)}function $f(){}function dy(a,c){var h=pr();c=c===void 0?null:c;var v=h.memoizedState;return v!==null&&c!==null&&Lf(c,v[1])?v[0]:(h.memoizedState=[a,c],a)}function fy(a,c){var h=pr();c=c===void 0?null:c;var v=h.memoizedState;return v!==null&&c!==null&&Lf(c,v[1])?v[0]:(a=a(),h.memoizedState=[a,c],a)}function hy(a,c,h){return(Ni&21)===0?(a.baseState&&(a.baseState=!1,Jn=!0),a.memoizedState=h):(Nr(h,c)||(h=Ml(),Vt.lanes|=h,Ci|=h,a.baseState=!0),c)}function v2(a,c){var h=vt;vt=h!==0&&4>h?h:4,a(!0);var v=If.transition;If.transition={};try{a(!1),c()}finally{vt=h,If.transition=v}}function py(){return pr().memoizedState}function y2(a,c,h){var v=Fs(a);if(h={lane:v,action:h,hasEagerState:!1,eagerState:null,next:null},my(a))gy(c,h);else if(h=Vv(a,c,h,v),h!==null){var x=Hn();Or(h,a,v,x),vy(h,c,v)}}function b2(a,c,h){var v=Fs(a),x={lane:v,action:h,hasEagerState:!1,eagerState:null,next:null};if(my(a))gy(c,x);else{var _=a.alternate;if(a.lanes===0&&(_===null||_.lanes===0)&&(_=c.lastRenderedReducer,_!==null))try{var M=c.lastRenderedState,P=_(M,h);if(x.hasEagerState=!0,x.eagerState=P,Nr(P,M)){var H=c.interleaved;H===null?(x.next=x,Tf(c)):(x.next=H.next,H.next=x),c.interleaved=x;return}}catch{}finally{}h=Vv(a,c,x,v),h!==null&&(x=Hn(),Or(h,a,v,x),vy(h,c,v))}}function my(a){var c=a.alternate;return a===Vt||c!==null&&c===Vt}function gy(a,c){wa=ic=!0;var h=a.pending;h===null?c.next=c:(c.next=h.next,h.next=c),a.pending=c}function vy(a,c,h){if((h&4194240)!==0){var v=c.lanes;v&=a.pendingLanes,h|=v,c.lanes=h,ea(a,h)}}var lc={readContext:hr,useCallback:jn,useContext:jn,useEffect:jn,useImperativeHandle:jn,useInsertionEffect:jn,useLayoutEffect:jn,useMemo:jn,useReducer:jn,useRef:jn,useState:jn,useDebugValue:jn,useDeferredValue:jn,useTransition:jn,useMutableSource:jn,useSyncExternalStore:jn,useId:jn,unstable_isNewReconciler:!1},x2={readContext:hr,useCallback:function(a,c){return qr().memoizedState=[a,c===void 0?null:c],a},useContext:hr,useEffect:oy,useImperativeHandle:function(a,c,h){return h=h!=null?h.concat([a]):null,oc(4194308,4,cy.bind(null,c,a),h)},useLayoutEffect:function(a,c){return oc(4194308,4,a,c)},useInsertionEffect:function(a,c){return oc(4,2,a,c)},useMemo:function(a,c){var h=qr();return c=c===void 0?null:c,a=a(),h.memoizedState=[a,c],a},useReducer:function(a,c,h){var v=qr();return c=h!==void 0?h(c):c,v.memoizedState=v.baseState=c,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:c},v.queue=a,a=a.dispatch=y2.bind(null,Vt,a),[v.memoizedState,a]},useRef:function(a){var c=qr();return a={current:a},c.memoizedState=a},useState:sy,useDebugValue:$f,useDeferredValue:function(a){return qr().memoizedState=a},useTransition:function(){var a=sy(!1),c=a[0];return a=v2.bind(null,a[1]),qr().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,h){var v=Vt,x=qr();if(Ut){if(h===void 0)throw Error(n(407));h=h()}else{if(h=c(),hn===null)throw Error(n(349));(Ni&30)!==0||Zv(v,c,h)}x.memoizedState=h;var _={value:h,getSnapshot:c};return x.queue=_,oy(ty.bind(null,v,_,a),[a]),v.flags|=2048,Ea(9,ey.bind(null,v,_,h,c),void 0,null),h},useId:function(){var a=qr(),c=hn.identifierPrefix;if(Ut){var h=ss,v=rs;h=(v&~(1<<32-Wt(v)-1)).toString(32)+h,c=":"+c+"R"+h,h=ka++,0<h&&(c+="H"+h.toString(32)),c+=":"}else h=g2++,c=":"+c+"r"+h.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},w2={readContext:hr,useCallback:dy,useContext:hr,useEffect:Ff,useImperativeHandle:uy,useInsertionEffect:ay,useLayoutEffect:ly,useMemo:fy,useReducer:Bf,useRef:iy,useState:function(){return Bf(Sa)},useDebugValue:$f,useDeferredValue:function(a){var c=pr();return hy(c,ln.memoizedState,a)},useTransition:function(){var a=Bf(Sa)[0],c=pr().memoizedState;return[a,c]},useMutableSource:Qv,useSyncExternalStore:Xv,useId:py,unstable_isNewReconciler:!1},k2={readContext:hr,useCallback:dy,useContext:hr,useEffect:Ff,useImperativeHandle:uy,useInsertionEffect:ay,useLayoutEffect:ly,useMemo:fy,useReducer:zf,useRef:iy,useState:function(){return zf(Sa)},useDebugValue:$f,useDeferredValue:function(a){var c=pr();return ln===null?c.memoizedState=a:hy(c,ln.memoizedState,a)},useTransition:function(){var a=zf(Sa)[0],c=pr().memoizedState;return[a,c]},useMutableSource:Qv,useSyncExternalStore:Xv,useId:py,unstable_isNewReconciler:!1};function Tr(a,c){if(a&&a.defaultProps){c=I({},c),a=a.defaultProps;for(var h in a)c[h]===void 0&&(c[h]=a[h]);return c}return c}function Uf(a,c,h,v){c=a.memoizedState,h=h(v,c),h=h==null?c:I({},c,h),a.memoizedState=h,a.lanes===0&&(a.updateQueue.baseState=h)}var cc={isMounted:function(a){return(a=a._reactInternals)?es(a)===a:!1},enqueueSetState:function(a,c,h){a=a._reactInternals;var v=Hn(),x=Fs(a),_=as(v,x);_.payload=c,h!=null&&(_.callback=h),c=Ds(a,_,x),c!==null&&(Or(c,a,x,v),tc(c,a,x))},enqueueReplaceState:function(a,c,h){a=a._reactInternals;var v=Hn(),x=Fs(a),_=as(v,x);_.tag=1,_.payload=c,h!=null&&(_.callback=h),c=Ds(a,_,x),c!==null&&(Or(c,a,x,v),tc(c,a,x))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var h=Hn(),v=Fs(a),x=as(h,v);x.tag=2,c!=null&&(x.callback=c),c=Ds(a,x,v),c!==null&&(Or(c,a,v,h),tc(c,a,v))}};function yy(a,c,h,v,x,_,M){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(v,_,M):c.prototype&&c.prototype.isPureReactComponent?!ua(h,v)||!ua(x,_):!0}function by(a,c,h){var v=!1,x=js,_=c.contextType;return typeof _=="object"&&_!==null?_=hr(_):(x=Gn(c)?wi:Rn.current,v=c.contextTypes,_=(v=v!=null)?mo(a,x):js),c=new c(h,_),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=cc,a.stateNode=c,c._reactInternals=a,v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=x,a.__reactInternalMemoizedMaskedChildContext=_),c}function xy(a,c,h,v){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(h,v),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(h,v),c.state!==a&&cc.enqueueReplaceState(c,c.state,null)}function Hf(a,c,h,v){var x=a.stateNode;x.props=h,x.state=a.memoizedState,x.refs={},Mf(a);var _=c.contextType;typeof _=="object"&&_!==null?x.context=hr(_):(_=Gn(c)?wi:Rn.current,x.context=mo(a,_)),x.state=a.memoizedState,_=c.getDerivedStateFromProps,typeof _=="function"&&(Uf(a,c,_,h),x.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(c=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),c!==x.state&&cc.enqueueReplaceState(x,x.state,null),nc(a,h,x,v),x.state=a.memoizedState),typeof x.componentDidMount=="function"&&(a.flags|=4194308)}function So(a,c){try{var h="",v=c;do h+=fe(v),v=v.return;while(v);var x=h}catch(_){x=`
39
+ Error generating stack: `+_.message+`
40
+ `+_.stack}return{value:a,source:c,stack:x,digest:null}}function Wf(a,c,h){return{value:a,source:null,stack:h??null,digest:c??null}}function qf(a,c){try{console.error(c.value)}catch(h){setTimeout(function(){throw h})}}var S2=typeof WeakMap=="function"?WeakMap:Map;function wy(a,c,h){h=as(-1,h),h.tag=3,h.payload={element:null};var v=c.value;return h.callback=function(){gc||(gc=!0,oh=v),qf(a,c)},h}function ky(a,c,h){h=as(-1,h),h.tag=3;var v=a.type.getDerivedStateFromError;if(typeof v=="function"){var x=c.value;h.payload=function(){return v(x)},h.callback=function(){qf(a,c)}}var _=a.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(h.callback=function(){qf(a,c),typeof v!="function"&&(Bs===null?Bs=new Set([this]):Bs.add(this));var M=c.stack;this.componentDidCatch(c.value,{componentStack:M!==null?M:""})}),h}function Sy(a,c,h){var v=a.pingCache;if(v===null){v=a.pingCache=new S2;var x=new Set;v.set(c,x)}else x=v.get(c),x===void 0&&(x=new Set,v.set(c,x));x.has(h)||(x.add(h),a=P2.bind(null,a,c,h),c.then(a,a))}function Ey(a){do{var c;if((c=a.tag===13)&&(c=a.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return a;a=a.return}while(a!==null);return null}function _y(a,c,h,v,x){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(c=as(-1,1),c.tag=2,Ds(h,c,1))),h.lanes|=1),a):(a.flags|=65536,a.lanes=x,a)}var E2=T.ReactCurrentOwner,Jn=!1;function Un(a,c,h,v){c.child=a===null?qv(c,null,h,v):bo(c,a.child,h,v)}function Ny(a,c,h,v,x){h=h.render;var _=c.ref;return wo(c,x),v=Df(a,c,h,v,_,x),h=Pf(),a!==null&&!Jn?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~x,ls(a,c,x)):(Ut&&h&&bf(c),c.flags|=1,Un(a,c,v,x),c.child)}function Cy(a,c,h,v,x){if(a===null){var _=h.type;return typeof _=="function"&&!hh(_)&&_.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(c.tag=15,c.type=_,Ty(a,c,_,v,x)):(a=kc(h.type,null,v,c,c.mode,x),a.ref=c.ref,a.return=c,c.child=a)}if(_=a.child,(a.lanes&x)===0){var M=_.memoizedProps;if(h=h.compare,h=h!==null?h:ua,h(M,v)&&a.ref===c.ref)return ls(a,c,x)}return c.flags|=1,a=Us(_,v),a.ref=c.ref,a.return=c,c.child=a}function Ty(a,c,h,v,x){if(a!==null){var _=a.memoizedProps;if(ua(_,v)&&a.ref===c.ref)if(Jn=!1,c.pendingProps=v=_,(a.lanes&x)!==0)(a.flags&131072)!==0&&(Jn=!0);else return c.lanes=a.lanes,ls(a,c,x)}return Vf(a,c,h,v,x)}function My(a,c,h){var v=c.pendingProps,x=v.children,_=a!==null?a.memoizedState:null;if(v.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Lt(_o,ir),ir|=h;else{if((h&1073741824)===0)return a=_!==null?_.baseLanes|h:h,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Lt(_o,ir),ir|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=_!==null?_.baseLanes:h,Lt(_o,ir),ir|=v}else _!==null?(v=_.baseLanes|h,c.memoizedState=null):v=h,Lt(_o,ir),ir|=v;return Un(a,c,x,h),c.child}function Ay(a,c){var h=c.ref;(a===null&&h!==null||a!==null&&a.ref!==h)&&(c.flags|=512,c.flags|=2097152)}function Vf(a,c,h,v,x){var _=Gn(h)?wi:Rn.current;return _=mo(c,_),wo(c,x),h=Df(a,c,h,v,_,x),v=Pf(),a!==null&&!Jn?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~x,ls(a,c,x)):(Ut&&v&&bf(c),c.flags|=1,Un(a,c,h,x),c.child)}function Oy(a,c,h,v,x){if(Gn(h)){var _=!0;Kl(c)}else _=!1;if(wo(c,x),c.stateNode===null)dc(a,c),by(c,h,v),Hf(c,h,v,x),v=!0;else if(a===null){var M=c.stateNode,P=c.memoizedProps;M.props=P;var H=M.context,ie=h.contextType;typeof ie=="object"&&ie!==null?ie=hr(ie):(ie=Gn(h)?wi:Rn.current,ie=mo(c,ie));var me=h.getDerivedStateFromProps,ge=typeof me=="function"||typeof M.getSnapshotBeforeUpdate=="function";ge||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(P!==v||H!==ie)&&xy(c,M,v,ie),Ls=!1;var he=c.memoizedState;M.state=he,nc(c,v,M,x),H=c.memoizedState,P!==v||he!==H||Kn.current||Ls?(typeof me=="function"&&(Uf(c,h,me,v),H=c.memoizedState),(P=Ls||yy(c,h,P,v,he,H,ie))?(ge||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(c.flags|=4194308)):(typeof M.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=v,c.memoizedState=H),M.props=v,M.state=H,M.context=ie,v=P):(typeof M.componentDidMount=="function"&&(c.flags|=4194308),v=!1)}else{M=c.stateNode,Kv(a,c),P=c.memoizedProps,ie=c.type===c.elementType?P:Tr(c.type,P),M.props=ie,ge=c.pendingProps,he=M.context,H=h.contextType,typeof H=="object"&&H!==null?H=hr(H):(H=Gn(h)?wi:Rn.current,H=mo(c,H));var Oe=h.getDerivedStateFromProps;(me=typeof Oe=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(P!==ge||he!==H)&&xy(c,M,v,H),Ls=!1,he=c.memoizedState,M.state=he,nc(c,v,M,x);var Pe=c.memoizedState;P!==ge||he!==Pe||Kn.current||Ls?(typeof Oe=="function"&&(Uf(c,h,Oe,v),Pe=c.memoizedState),(ie=Ls||yy(c,h,ie,v,he,Pe,H)||!1)?(me||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(v,Pe,H),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(v,Pe,H)),typeof M.componentDidUpdate=="function"&&(c.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof M.componentDidUpdate!="function"||P===a.memoizedProps&&he===a.memoizedState||(c.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||P===a.memoizedProps&&he===a.memoizedState||(c.flags|=1024),c.memoizedProps=v,c.memoizedState=Pe),M.props=v,M.state=Pe,M.context=H,v=ie):(typeof M.componentDidUpdate!="function"||P===a.memoizedProps&&he===a.memoizedState||(c.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||P===a.memoizedProps&&he===a.memoizedState||(c.flags|=1024),v=!1)}return Kf(a,c,h,v,_,x)}function Kf(a,c,h,v,x,_){Ay(a,c);var M=(c.flags&128)!==0;if(!v&&!M)return x&&Dv(c,h,!1),ls(a,c,_);v=c.stateNode,E2.current=c;var P=M&&typeof h.getDerivedStateFromError!="function"?null:v.render();return c.flags|=1,a!==null&&M?(c.child=bo(c,a.child,null,_),c.child=bo(c,null,P,_)):Un(a,c,P,_),c.memoizedState=v.state,x&&Dv(c,h,!0),c.child}function Ry(a){var c=a.stateNode;c.pendingContext?Iv(a,c.pendingContext,c.pendingContext!==c.context):c.context&&Iv(a,c.context,!1),Af(a,c.containerInfo)}function jy(a,c,h,v,x){return yo(),Sf(x),c.flags|=256,Un(a,c,h,v),c.child}var Gf={dehydrated:null,treeContext:null,retryLane:0};function Jf(a){return{baseLanes:a,cachePool:null,transitions:null}}function Iy(a,c,h){var v=c.pendingProps,x=qt.current,_=!1,M=(c.flags&128)!==0,P;if((P=M)||(P=a!==null&&a.memoizedState===null?!1:(x&2)!==0),P?(_=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(x|=1),Lt(qt,x&1),a===null)return kf(c),a=c.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((c.mode&1)===0?c.lanes=1:a.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(M=v.children,a=v.fallback,_?(v=c.mode,_=c.child,M={mode:"hidden",children:M},(v&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=M):_=Sc(M,v,0,null),a=Oi(a,v,h,null),_.return=c,a.return=c,_.sibling=a,c.child=_,c.child.memoizedState=Jf(h),c.memoizedState=Gf,a):Yf(c,M));if(x=a.memoizedState,x!==null&&(P=x.dehydrated,P!==null))return _2(a,c,M,v,P,x,h);if(_){_=v.fallback,M=c.mode,x=a.child,P=x.sibling;var H={mode:"hidden",children:v.children};return(M&1)===0&&c.child!==x?(v=c.child,v.childLanes=0,v.pendingProps=H,c.deletions=null):(v=Us(x,H),v.subtreeFlags=x.subtreeFlags&14680064),P!==null?_=Us(P,_):(_=Oi(_,M,h,null),_.flags|=2),_.return=c,v.return=c,v.sibling=_,c.child=v,v=_,_=c.child,M=a.child.memoizedState,M=M===null?Jf(h):{baseLanes:M.baseLanes|h,cachePool:null,transitions:M.transitions},_.memoizedState=M,_.childLanes=a.childLanes&~h,c.memoizedState=Gf,v}return _=a.child,a=_.sibling,v=Us(_,{mode:"visible",children:v.children}),(c.mode&1)===0&&(v.lanes=h),v.return=c,v.sibling=null,a!==null&&(h=c.deletions,h===null?(c.deletions=[a],c.flags|=16):h.push(a)),c.child=v,c.memoizedState=null,v}function Yf(a,c){return c=Sc({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function uc(a,c,h,v){return v!==null&&Sf(v),bo(c,a.child,null,h),a=Yf(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function _2(a,c,h,v,x,_,M){if(h)return c.flags&256?(c.flags&=-257,v=Wf(Error(n(422))),uc(a,c,M,v)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):(_=v.fallback,x=c.mode,v=Sc({mode:"visible",children:v.children},x,0,null),_=Oi(_,x,M,null),_.flags|=2,v.return=c,_.return=c,v.sibling=_,c.child=v,(c.mode&1)!==0&&bo(c,a.child,null,M),c.child.memoizedState=Jf(M),c.memoizedState=Gf,_);if((c.mode&1)===0)return uc(a,c,M,null);if(x.data==="$!"){if(v=x.nextSibling&&x.nextSibling.dataset,v)var P=v.dgst;return v=P,_=Error(n(419)),v=Wf(_,v,void 0),uc(a,c,M,v)}if(P=(M&a.childLanes)!==0,Jn||P){if(v=hn,v!==null){switch(M&-M){case 4:x=2;break;case 16:x=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:x=32;break;case 536870912:x=268435456;break;default:x=0}x=(x&(v.suspendedLanes|M))!==0?0:x,x!==0&&x!==_.retryLane&&(_.retryLane=x,is(a,x),Or(v,a,x,-1))}return fh(),v=Wf(Error(n(421))),uc(a,c,M,v)}return x.data==="$?"?(c.flags|=128,c.child=a.child,c=B2.bind(null,a),x._reactRetry=c,null):(a=_.treeContext,sr=Os(x.nextSibling),rr=c,Ut=!0,Cr=null,a!==null&&(dr[fr++]=rs,dr[fr++]=ss,dr[fr++]=ki,rs=a.id,ss=a.overflow,ki=c),c=Yf(c,v.children),c.flags|=4096,c)}function Ly(a,c,h){a.lanes|=c;var v=a.alternate;v!==null&&(v.lanes|=c),Cf(a.return,c,h)}function Qf(a,c,h,v,x){var _=a.memoizedState;_===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:v,tail:h,tailMode:x}:(_.isBackwards=c,_.rendering=null,_.renderingStartTime=0,_.last=v,_.tail=h,_.tailMode=x)}function Dy(a,c,h){var v=c.pendingProps,x=v.revealOrder,_=v.tail;if(Un(a,c,v.children,h),v=qt.current,(v&2)!==0)v=v&1|2,c.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&Ly(a,h,c);else if(a.tag===19)Ly(a,h,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}v&=1}if(Lt(qt,v),(c.mode&1)===0)c.memoizedState=null;else switch(x){case"forwards":for(h=c.child,x=null;h!==null;)a=h.alternate,a!==null&&rc(a)===null&&(x=h),h=h.sibling;h=x,h===null?(x=c.child,c.child=null):(x=h.sibling,h.sibling=null),Qf(c,!1,x,h,_);break;case"backwards":for(h=null,x=c.child,c.child=null;x!==null;){if(a=x.alternate,a!==null&&rc(a)===null){c.child=x;break}a=x.sibling,x.sibling=h,h=x,x=a}Qf(c,!0,h,null,_);break;case"together":Qf(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function dc(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function ls(a,c,h){if(a!==null&&(c.dependencies=a.dependencies),Ci|=c.lanes,(h&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(n(153));if(c.child!==null){for(a=c.child,h=Us(a,a.pendingProps),c.child=h,h.return=c;a.sibling!==null;)a=a.sibling,h=h.sibling=Us(a,a.pendingProps),h.return=c;h.sibling=null}return c.child}function N2(a,c,h){switch(c.tag){case 3:Ry(c),yo();break;case 5:Yv(c);break;case 1:Gn(c.type)&&Kl(c);break;case 4:Af(c,c.stateNode.containerInfo);break;case 10:var v=c.type._context,x=c.memoizedProps.value;Lt(Zl,v._currentValue),v._currentValue=x;break;case 13:if(v=c.memoizedState,v!==null)return v.dehydrated!==null?(Lt(qt,qt.current&1),c.flags|=128,null):(h&c.child.childLanes)!==0?Iy(a,c,h):(Lt(qt,qt.current&1),a=ls(a,c,h),a!==null?a.sibling:null);Lt(qt,qt.current&1);break;case 19:if(v=(h&c.childLanes)!==0,(a.flags&128)!==0){if(v)return Dy(a,c,h);c.flags|=128}if(x=c.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),Lt(qt,qt.current),v)break;return null;case 22:case 23:return c.lanes=0,My(a,c,h)}return ls(a,c,h)}var Py,Xf,By,zy;Py=function(a,c){for(var h=c.child;h!==null;){if(h.tag===5||h.tag===6)a.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===c)break;for(;h.sibling===null;){if(h.return===null||h.return===c)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},Xf=function(){},By=function(a,c,h,v){var x=a.memoizedProps;if(x!==v){a=c.stateNode,_i(Wr.current);var _=null;switch(h){case"input":x=Me(a,x),v=Me(a,v),_=[];break;case"select":x=I({},x,{value:void 0}),v=I({},v,{value:void 0}),_=[];break;case"textarea":x=Ze(a,x),v=Ze(a,v),_=[];break;default:typeof x.onClick!="function"&&typeof v.onClick=="function"&&(a.onclick=Wl)}Je(h,v);var M;h=null;for(ie in x)if(!v.hasOwnProperty(ie)&&x.hasOwnProperty(ie)&&x[ie]!=null)if(ie==="style"){var P=x[ie];for(M in P)P.hasOwnProperty(M)&&(h||(h={}),h[M]="")}else ie!=="dangerouslySetInnerHTML"&&ie!=="children"&&ie!=="suppressContentEditableWarning"&&ie!=="suppressHydrationWarning"&&ie!=="autoFocus"&&(s.hasOwnProperty(ie)?_||(_=[]):(_=_||[]).push(ie,null));for(ie in v){var H=v[ie];if(P=x!=null?x[ie]:void 0,v.hasOwnProperty(ie)&&H!==P&&(H!=null||P!=null))if(ie==="style")if(P){for(M in P)!P.hasOwnProperty(M)||H&&H.hasOwnProperty(M)||(h||(h={}),h[M]="");for(M in H)H.hasOwnProperty(M)&&P[M]!==H[M]&&(h||(h={}),h[M]=H[M])}else h||(_||(_=[]),_.push(ie,h)),h=H;else ie==="dangerouslySetInnerHTML"?(H=H?H.__html:void 0,P=P?P.__html:void 0,H!=null&&P!==H&&(_=_||[]).push(ie,H)):ie==="children"?typeof H!="string"&&typeof H!="number"||(_=_||[]).push(ie,""+H):ie!=="suppressContentEditableWarning"&&ie!=="suppressHydrationWarning"&&(s.hasOwnProperty(ie)?(H!=null&&ie==="onScroll"&&zt("scroll",a),_||P===H||(_=[])):(_=_||[]).push(ie,H))}h&&(_=_||[]).push("style",h);var ie=_;(c.updateQueue=ie)&&(c.flags|=4)}},zy=function(a,c,h,v){h!==v&&(c.flags|=4)};function _a(a,c){if(!Ut)switch(a.tailMode){case"hidden":c=a.tail;for(var h=null;c!==null;)c.alternate!==null&&(h=c),c=c.sibling;h===null?a.tail=null:h.sibling=null;break;case"collapsed":h=a.tail;for(var v=null;h!==null;)h.alternate!==null&&(v=h),h=h.sibling;v===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:v.sibling=null}}function In(a){var c=a.alternate!==null&&a.alternate.child===a.child,h=0,v=0;if(c)for(var x=a.child;x!==null;)h|=x.lanes|x.childLanes,v|=x.subtreeFlags&14680064,v|=x.flags&14680064,x.return=a,x=x.sibling;else for(x=a.child;x!==null;)h|=x.lanes|x.childLanes,v|=x.subtreeFlags,v|=x.flags,x.return=a,x=x.sibling;return a.subtreeFlags|=v,a.childLanes=h,c}function C2(a,c,h){var v=c.pendingProps;switch(xf(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return In(c),null;case 1:return Gn(c.type)&&Vl(),In(c),null;case 3:return v=c.stateNode,ko(),Ft(Kn),Ft(Rn),jf(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(a===null||a.child===null)&&(Ql(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,Cr!==null&&(ch(Cr),Cr=null))),Xf(a,c),In(c),null;case 5:Of(c);var x=_i(xa.current);if(h=c.type,a!==null&&c.stateNode!=null)By(a,c,h,v,x),a.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!v){if(c.stateNode===null)throw Error(n(166));return In(c),null}if(a=_i(Wr.current),Ql(c)){v=c.stateNode,h=c.type;var _=c.memoizedProps;switch(v[Hr]=c,v[ma]=_,a=(c.mode&1)!==0,h){case"dialog":zt("cancel",v),zt("close",v);break;case"iframe":case"object":case"embed":zt("load",v);break;case"video":case"audio":for(x=0;x<fa.length;x++)zt(fa[x],v);break;case"source":zt("error",v);break;case"img":case"image":case"link":zt("error",v),zt("load",v);break;case"details":zt("toggle",v);break;case"input":He(v,_),zt("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!_.multiple},zt("invalid",v);break;case"textarea":Ae(v,_),zt("invalid",v)}Je(h,_),x=null;for(var M in _)if(_.hasOwnProperty(M)){var P=_[M];M==="children"?typeof P=="string"?v.textContent!==P&&(_.suppressHydrationWarning!==!0&&Hl(v.textContent,P,a),x=["children",P]):typeof P=="number"&&v.textContent!==""+P&&(_.suppressHydrationWarning!==!0&&Hl(v.textContent,P,a),x=["children",""+P]):s.hasOwnProperty(M)&&P!=null&&M==="onScroll"&&zt("scroll",v)}switch(h){case"input":ue(v),Be(v,_,!0);break;case"textarea":ue(v),ke(v);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(v.onclick=Wl)}v=x,c.updateQueue=v,v!==null&&(c.flags|=4)}else{M=x.nodeType===9?x:x.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=ze(h)),a==="http://www.w3.org/1999/xhtml"?h==="script"?(a=M.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof v.is=="string"?a=M.createElement(h,{is:v.is}):(a=M.createElement(h),h==="select"&&(M=a,v.multiple?M.multiple=!0:v.size&&(M.size=v.size))):a=M.createElementNS(a,h),a[Hr]=c,a[ma]=v,Py(a,c,!1,!1),c.stateNode=a;e:{switch(M=et(h,v),h){case"dialog":zt("cancel",a),zt("close",a),x=v;break;case"iframe":case"object":case"embed":zt("load",a),x=v;break;case"video":case"audio":for(x=0;x<fa.length;x++)zt(fa[x],a);x=v;break;case"source":zt("error",a),x=v;break;case"img":case"image":case"link":zt("error",a),zt("load",a),x=v;break;case"details":zt("toggle",a),x=v;break;case"input":He(a,v),x=Me(a,v),zt("invalid",a);break;case"option":x=v;break;case"select":a._wrapperState={wasMultiple:!!v.multiple},x=I({},v,{value:void 0}),zt("invalid",a);break;case"textarea":Ae(a,v),x=Ze(a,v),zt("invalid",a);break;default:x=v}Je(h,x),P=x;for(_ in P)if(P.hasOwnProperty(_)){var H=P[_];_==="style"?wn(a,H):_==="dangerouslySetInnerHTML"?(H=H?H.__html:void 0,H!=null&&kt(a,H)):_==="children"?typeof H=="string"?(h!=="textarea"||H!=="")&&Bt(a,H):typeof H=="number"&&Bt(a,""+H):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(s.hasOwnProperty(_)?H!=null&&_==="onScroll"&&zt("scroll",a):H!=null&&O(a,_,H,M))}switch(h){case"input":ue(a),Be(a,v,!1);break;case"textarea":ue(a),ke(a);break;case"option":v.value!=null&&a.setAttribute("value",""+Te(v.value));break;case"select":a.multiple=!!v.multiple,_=v.value,_!=null?pe(a,!!v.multiple,_,!1):v.defaultValue!=null&&pe(a,!!v.multiple,v.defaultValue,!0);break;default:typeof x.onClick=="function"&&(a.onclick=Wl)}switch(h){case"button":case"input":case"select":case"textarea":v=!!v.autoFocus;break e;case"img":v=!0;break e;default:v=!1}}v&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return In(c),null;case 6:if(a&&c.stateNode!=null)zy(a,c,a.memoizedProps,v);else{if(typeof v!="string"&&c.stateNode===null)throw Error(n(166));if(h=_i(xa.current),_i(Wr.current),Ql(c)){if(v=c.stateNode,h=c.memoizedProps,v[Hr]=c,(_=v.nodeValue!==h)&&(a=rr,a!==null))switch(a.tag){case 3:Hl(v.nodeValue,h,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Hl(v.nodeValue,h,(a.mode&1)!==0)}_&&(c.flags|=4)}else v=(h.nodeType===9?h:h.ownerDocument).createTextNode(v),v[Hr]=c,c.stateNode=v}return In(c),null;case 13:if(Ft(qt),v=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(Ut&&sr!==null&&(c.mode&1)!==0&&(c.flags&128)===0)Uv(),yo(),c.flags|=98560,_=!1;else if(_=Ql(c),v!==null&&v.dehydrated!==null){if(a===null){if(!_)throw Error(n(318));if(_=c.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(n(317));_[Hr]=c}else yo(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;In(c),_=!1}else Cr!==null&&(ch(Cr),Cr=null),_=!0;if(!_)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=h,c):(v=v!==null,v!==(a!==null&&a.memoizedState!==null)&&v&&(c.child.flags|=8192,(c.mode&1)!==0&&(a===null||(qt.current&1)!==0?cn===0&&(cn=3):fh())),c.updateQueue!==null&&(c.flags|=4),In(c),null);case 4:return ko(),Xf(a,c),a===null&&ha(c.stateNode.containerInfo),In(c),null;case 10:return Nf(c.type._context),In(c),null;case 17:return Gn(c.type)&&Vl(),In(c),null;case 19:if(Ft(qt),_=c.memoizedState,_===null)return In(c),null;if(v=(c.flags&128)!==0,M=_.rendering,M===null)if(v)_a(_,!1);else{if(cn!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(M=rc(a),M!==null){for(c.flags|=128,_a(_,!1),v=M.updateQueue,v!==null&&(c.updateQueue=v,c.flags|=4),c.subtreeFlags=0,v=h,h=c.child;h!==null;)_=h,a=v,_.flags&=14680066,M=_.alternate,M===null?(_.childLanes=0,_.lanes=a,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=M.childLanes,_.lanes=M.lanes,_.child=M.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=M.memoizedProps,_.memoizedState=M.memoizedState,_.updateQueue=M.updateQueue,_.type=M.type,a=M.dependencies,_.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),h=h.sibling;return Lt(qt,qt.current&1|2),c.child}a=a.sibling}_.tail!==null&&Ht()>No&&(c.flags|=128,v=!0,_a(_,!1),c.lanes=4194304)}else{if(!v)if(a=rc(M),a!==null){if(c.flags|=128,v=!0,h=a.updateQueue,h!==null&&(c.updateQueue=h,c.flags|=4),_a(_,!0),_.tail===null&&_.tailMode==="hidden"&&!M.alternate&&!Ut)return In(c),null}else 2*Ht()-_.renderingStartTime>No&&h!==1073741824&&(c.flags|=128,v=!0,_a(_,!1),c.lanes=4194304);_.isBackwards?(M.sibling=c.child,c.child=M):(h=_.last,h!==null?h.sibling=M:c.child=M,_.last=M)}return _.tail!==null?(c=_.tail,_.rendering=c,_.tail=c.sibling,_.renderingStartTime=Ht(),c.sibling=null,h=qt.current,Lt(qt,v?h&1|2:h&1),c):(In(c),null);case 22:case 23:return dh(),v=c.memoizedState!==null,a!==null&&a.memoizedState!==null!==v&&(c.flags|=8192),v&&(c.mode&1)!==0?(ir&1073741824)!==0&&(In(c),c.subtreeFlags&6&&(c.flags|=8192)):In(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function T2(a,c){switch(xf(c),c.tag){case 1:return Gn(c.type)&&Vl(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return ko(),Ft(Kn),Ft(Rn),jf(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return Of(c),null;case 13:if(Ft(qt),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(n(340));yo()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Ft(qt),null;case 4:return ko(),null;case 10:return Nf(c.type._context),null;case 22:case 23:return dh(),null;case 24:return null;default:return null}}var fc=!1,Ln=!1,M2=typeof WeakSet=="function"?WeakSet:Set,De=null;function Eo(a,c){var h=a.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(v){Gt(a,c,v)}else h.current=null}function Zf(a,c,h){try{h()}catch(v){Gt(a,c,v)}}var Fy=!1;function A2(a,c){if(df=Rl,a=yv(),nf(a)){if("selectionStart"in a)var h={start:a.selectionStart,end:a.selectionEnd};else e:{h=(h=a.ownerDocument)&&h.defaultView||window;var v=h.getSelection&&h.getSelection();if(v&&v.rangeCount!==0){h=v.anchorNode;var x=v.anchorOffset,_=v.focusNode;v=v.focusOffset;try{h.nodeType,_.nodeType}catch{h=null;break e}var M=0,P=-1,H=-1,ie=0,me=0,ge=a,he=null;t:for(;;){for(var Oe;ge!==h||x!==0&&ge.nodeType!==3||(P=M+x),ge!==_||v!==0&&ge.nodeType!==3||(H=M+v),ge.nodeType===3&&(M+=ge.nodeValue.length),(Oe=ge.firstChild)!==null;)he=ge,ge=Oe;for(;;){if(ge===a)break t;if(he===h&&++ie===x&&(P=M),he===_&&++me===v&&(H=M),(Oe=ge.nextSibling)!==null)break;ge=he,he=ge.parentNode}ge=Oe}h=P===-1||H===-1?null:{start:P,end:H}}else h=null}h=h||{start:0,end:0}}else h=null;for(ff={focusedElem:a,selectionRange:h},Rl=!1,De=c;De!==null;)if(c=De,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,De=a;else for(;De!==null;){c=De;try{var Pe=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Pe!==null){var Fe=Pe.memoizedProps,tn=Pe.memoizedState,te=c.stateNode,q=te.getSnapshotBeforeUpdate(c.elementType===c.type?Fe:Tr(c.type,Fe),tn);te.__reactInternalSnapshotBeforeUpdate=q}break;case 3:var ne=c.stateNode.containerInfo;ne.nodeType===1?ne.textContent="":ne.nodeType===9&&ne.documentElement&&ne.removeChild(ne.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(we){Gt(c,c.return,we)}if(a=c.sibling,a!==null){a.return=c.return,De=a;break}De=c.return}return Pe=Fy,Fy=!1,Pe}function Na(a,c,h){var v=c.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var x=v=v.next;do{if((x.tag&a)===a){var _=x.destroy;x.destroy=void 0,_!==void 0&&Zf(c,h,_)}x=x.next}while(x!==v)}}function hc(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var h=c=c.next;do{if((h.tag&a)===a){var v=h.create;h.destroy=v()}h=h.next}while(h!==c)}}function eh(a){var c=a.ref;if(c!==null){var h=a.stateNode;switch(a.tag){case 5:a=h;break;default:a=h}typeof c=="function"?c(a):c.current=a}}function $y(a){var c=a.alternate;c!==null&&(a.alternate=null,$y(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[Hr],delete c[ma],delete c[gf],delete c[f2],delete c[h2])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function Uy(a){return a.tag===5||a.tag===3||a.tag===4}function Hy(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||Uy(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function th(a,c,h){var v=a.tag;if(v===5||v===6)a=a.stateNode,c?h.nodeType===8?h.parentNode.insertBefore(a,c):h.insertBefore(a,c):(h.nodeType===8?(c=h.parentNode,c.insertBefore(a,h)):(c=h,c.appendChild(a)),h=h._reactRootContainer,h!=null||c.onclick!==null||(c.onclick=Wl));else if(v!==4&&(a=a.child,a!==null))for(th(a,c,h),a=a.sibling;a!==null;)th(a,c,h),a=a.sibling}function nh(a,c,h){var v=a.tag;if(v===5||v===6)a=a.stateNode,c?h.insertBefore(a,c):h.appendChild(a);else if(v!==4&&(a=a.child,a!==null))for(nh(a,c,h),a=a.sibling;a!==null;)nh(a,c,h),a=a.sibling}var kn=null,Mr=!1;function Ps(a,c,h){for(h=h.child;h!==null;)Wy(a,c,h),h=h.sibling}function Wy(a,c,h){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(ut,h)}catch{}switch(h.tag){case 5:Ln||Eo(h,c);case 6:var v=kn,x=Mr;kn=null,Ps(a,c,h),kn=v,Mr=x,kn!==null&&(Mr?(a=kn,h=h.stateNode,a.nodeType===8?a.parentNode.removeChild(h):a.removeChild(h)):kn.removeChild(h.stateNode));break;case 18:kn!==null&&(Mr?(a=kn,h=h.stateNode,a.nodeType===8?mf(a.parentNode,h):a.nodeType===1&&mf(a,h),sa(a)):mf(kn,h.stateNode));break;case 4:v=kn,x=Mr,kn=h.stateNode.containerInfo,Mr=!0,Ps(a,c,h),kn=v,Mr=x;break;case 0:case 11:case 14:case 15:if(!Ln&&(v=h.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){x=v=v.next;do{var _=x,M=_.destroy;_=_.tag,M!==void 0&&((_&2)!==0||(_&4)!==0)&&Zf(h,c,M),x=x.next}while(x!==v)}Ps(a,c,h);break;case 1:if(!Ln&&(Eo(h,c),v=h.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=h.memoizedProps,v.state=h.memoizedState,v.componentWillUnmount()}catch(P){Gt(h,c,P)}Ps(a,c,h);break;case 21:Ps(a,c,h);break;case 22:h.mode&1?(Ln=(v=Ln)||h.memoizedState!==null,Ps(a,c,h),Ln=v):Ps(a,c,h);break;default:Ps(a,c,h)}}function qy(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var h=a.stateNode;h===null&&(h=a.stateNode=new M2),c.forEach(function(v){var x=z2.bind(null,a,v);h.has(v)||(h.add(v),v.then(x,x))})}}function Ar(a,c){var h=c.deletions;if(h!==null)for(var v=0;v<h.length;v++){var x=h[v];try{var _=a,M=c,P=M;e:for(;P!==null;){switch(P.tag){case 5:kn=P.stateNode,Mr=!1;break e;case 3:kn=P.stateNode.containerInfo,Mr=!0;break e;case 4:kn=P.stateNode.containerInfo,Mr=!0;break e}P=P.return}if(kn===null)throw Error(n(160));Wy(_,M,x),kn=null,Mr=!1;var H=x.alternate;H!==null&&(H.return=null),x.return=null}catch(ie){Gt(x,c,ie)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)Vy(c,a),c=c.sibling}function Vy(a,c){var h=a.alternate,v=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(Ar(c,a),Vr(a),v&4){try{Na(3,a,a.return),hc(3,a)}catch(Fe){Gt(a,a.return,Fe)}try{Na(5,a,a.return)}catch(Fe){Gt(a,a.return,Fe)}}break;case 1:Ar(c,a),Vr(a),v&512&&h!==null&&Eo(h,h.return);break;case 5:if(Ar(c,a),Vr(a),v&512&&h!==null&&Eo(h,h.return),a.flags&32){var x=a.stateNode;try{Bt(x,"")}catch(Fe){Gt(a,a.return,Fe)}}if(v&4&&(x=a.stateNode,x!=null)){var _=a.memoizedProps,M=h!==null?h.memoizedProps:_,P=a.type,H=a.updateQueue;if(a.updateQueue=null,H!==null)try{P==="input"&&_.type==="radio"&&_.name!=null&&Ne(x,_),et(P,M);var ie=et(P,_);for(M=0;M<H.length;M+=2){var me=H[M],ge=H[M+1];me==="style"?wn(x,ge):me==="dangerouslySetInnerHTML"?kt(x,ge):me==="children"?Bt(x,ge):O(x,me,ge,ie)}switch(P){case"input":tt(x,_);break;case"textarea":be(x,_);break;case"select":var he=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!_.multiple;var Oe=_.value;Oe!=null?pe(x,!!_.multiple,Oe,!1):he!==!!_.multiple&&(_.defaultValue!=null?pe(x,!!_.multiple,_.defaultValue,!0):pe(x,!!_.multiple,_.multiple?[]:"",!1))}x[ma]=_}catch(Fe){Gt(a,a.return,Fe)}}break;case 6:if(Ar(c,a),Vr(a),v&4){if(a.stateNode===null)throw Error(n(162));x=a.stateNode,_=a.memoizedProps;try{x.nodeValue=_}catch(Fe){Gt(a,a.return,Fe)}}break;case 3:if(Ar(c,a),Vr(a),v&4&&h!==null&&h.memoizedState.isDehydrated)try{sa(c.containerInfo)}catch(Fe){Gt(a,a.return,Fe)}break;case 4:Ar(c,a),Vr(a);break;case 13:Ar(c,a),Vr(a),x=a.child,x.flags&8192&&(_=x.memoizedState!==null,x.stateNode.isHidden=_,!_||x.alternate!==null&&x.alternate.memoizedState!==null||(ih=Ht())),v&4&&qy(a);break;case 22:if(me=h!==null&&h.memoizedState!==null,a.mode&1?(Ln=(ie=Ln)||me,Ar(c,a),Ln=ie):Ar(c,a),Vr(a),v&8192){if(ie=a.memoizedState!==null,(a.stateNode.isHidden=ie)&&!me&&(a.mode&1)!==0)for(De=a,me=a.child;me!==null;){for(ge=De=me;De!==null;){switch(he=De,Oe=he.child,he.tag){case 0:case 11:case 14:case 15:Na(4,he,he.return);break;case 1:Eo(he,he.return);var Pe=he.stateNode;if(typeof Pe.componentWillUnmount=="function"){v=he,h=he.return;try{c=v,Pe.props=c.memoizedProps,Pe.state=c.memoizedState,Pe.componentWillUnmount()}catch(Fe){Gt(v,h,Fe)}}break;case 5:Eo(he,he.return);break;case 22:if(he.memoizedState!==null){Jy(ge);continue}}Oe!==null?(Oe.return=he,De=Oe):Jy(ge)}me=me.sibling}e:for(me=null,ge=a;;){if(ge.tag===5){if(me===null){me=ge;try{x=ge.stateNode,ie?(_=x.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(P=ge.stateNode,H=ge.memoizedProps.style,M=H!=null&&H.hasOwnProperty("display")?H.display:null,P.style.display=On("display",M))}catch(Fe){Gt(a,a.return,Fe)}}}else if(ge.tag===6){if(me===null)try{ge.stateNode.nodeValue=ie?"":ge.memoizedProps}catch(Fe){Gt(a,a.return,Fe)}}else if((ge.tag!==22&&ge.tag!==23||ge.memoizedState===null||ge===a)&&ge.child!==null){ge.child.return=ge,ge=ge.child;continue}if(ge===a)break e;for(;ge.sibling===null;){if(ge.return===null||ge.return===a)break e;me===ge&&(me=null),ge=ge.return}me===ge&&(me=null),ge.sibling.return=ge.return,ge=ge.sibling}}break;case 19:Ar(c,a),Vr(a),v&4&&qy(a);break;case 21:break;default:Ar(c,a),Vr(a)}}function Vr(a){var c=a.flags;if(c&2){try{e:{for(var h=a.return;h!==null;){if(Uy(h)){var v=h;break e}h=h.return}throw Error(n(160))}switch(v.tag){case 5:var x=v.stateNode;v.flags&32&&(Bt(x,""),v.flags&=-33);var _=Hy(a);nh(a,_,x);break;case 3:case 4:var M=v.stateNode.containerInfo,P=Hy(a);th(a,P,M);break;default:throw Error(n(161))}}catch(H){Gt(a,a.return,H)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function O2(a,c,h){De=a,Ky(a)}function Ky(a,c,h){for(var v=(a.mode&1)!==0;De!==null;){var x=De,_=x.child;if(x.tag===22&&v){var M=x.memoizedState!==null||fc;if(!M){var P=x.alternate,H=P!==null&&P.memoizedState!==null||Ln;P=fc;var ie=Ln;if(fc=M,(Ln=H)&&!ie)for(De=x;De!==null;)M=De,H=M.child,M.tag===22&&M.memoizedState!==null?Yy(x):H!==null?(H.return=M,De=H):Yy(x);for(;_!==null;)De=_,Ky(_),_=_.sibling;De=x,fc=P,Ln=ie}Gy(a)}else(x.subtreeFlags&8772)!==0&&_!==null?(_.return=x,De=_):Gy(a)}}function Gy(a){for(;De!==null;){var c=De;if((c.flags&8772)!==0){var h=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Ln||hc(5,c);break;case 1:var v=c.stateNode;if(c.flags&4&&!Ln)if(h===null)v.componentDidMount();else{var x=c.elementType===c.type?h.memoizedProps:Tr(c.type,h.memoizedProps);v.componentDidUpdate(x,h.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var _=c.updateQueue;_!==null&&Jv(c,_,v);break;case 3:var M=c.updateQueue;if(M!==null){if(h=null,c.child!==null)switch(c.child.tag){case 5:h=c.child.stateNode;break;case 1:h=c.child.stateNode}Jv(c,M,h)}break;case 5:var P=c.stateNode;if(h===null&&c.flags&4){h=P;var H=c.memoizedProps;switch(c.type){case"button":case"input":case"select":case"textarea":H.autoFocus&&h.focus();break;case"img":H.src&&(h.src=H.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(c.memoizedState===null){var ie=c.alternate;if(ie!==null){var me=ie.memoizedState;if(me!==null){var ge=me.dehydrated;ge!==null&&sa(ge)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Ln||c.flags&512&&eh(c)}catch(he){Gt(c,c.return,he)}}if(c===a){De=null;break}if(h=c.sibling,h!==null){h.return=c.return,De=h;break}De=c.return}}function Jy(a){for(;De!==null;){var c=De;if(c===a){De=null;break}var h=c.sibling;if(h!==null){h.return=c.return,De=h;break}De=c.return}}function Yy(a){for(;De!==null;){var c=De;try{switch(c.tag){case 0:case 11:case 15:var h=c.return;try{hc(4,c)}catch(H){Gt(c,h,H)}break;case 1:var v=c.stateNode;if(typeof v.componentDidMount=="function"){var x=c.return;try{v.componentDidMount()}catch(H){Gt(c,x,H)}}var _=c.return;try{eh(c)}catch(H){Gt(c,_,H)}break;case 5:var M=c.return;try{eh(c)}catch(H){Gt(c,M,H)}}}catch(H){Gt(c,c.return,H)}if(c===a){De=null;break}var P=c.sibling;if(P!==null){P.return=c.return,De=P;break}De=c.return}}var R2=Math.ceil,pc=T.ReactCurrentDispatcher,rh=T.ReactCurrentOwner,mr=T.ReactCurrentBatchConfig,yt=0,hn=null,sn=null,Sn=0,ir=0,_o=Rs(0),cn=0,Ca=null,Ci=0,mc=0,sh=0,Ta=null,Yn=null,ih=0,No=1/0,cs=null,gc=!1,oh=null,Bs=null,vc=!1,zs=null,yc=0,Ma=0,ah=null,bc=-1,xc=0;function Hn(){return(yt&6)!==0?Ht():bc!==-1?bc:bc=Ht()}function Fs(a){return(a.mode&1)===0?1:(yt&2)!==0&&Sn!==0?Sn&-Sn:m2.transition!==null?(xc===0&&(xc=Ml()),xc):(a=vt,a!==0||(a=window.event,a=a===void 0?16:X0(a.type)),a)}function Or(a,c,h,v){if(50<Ma)throw Ma=0,ah=null,Error(n(185));Cs(a,h,v),((yt&2)===0||a!==hn)&&(a===hn&&((yt&2)===0&&(mc|=h),cn===4&&$s(a,Sn)),Qn(a,v),h===1&&yt===0&&(c.mode&1)===0&&(No=Ht()+500,Gl&&Is()))}function Qn(a,c){var h=a.callbackNode;Hd(a,c);var v=vi(a,a===hn?Sn:0);if(v===0)h!==null&&_r(h),a.callbackNode=null,a.callbackPriority=0;else if(c=v&-v,a.callbackPriority!==c){if(h!=null&&_r(h),c===1)a.tag===0?p2(Xy.bind(null,a)):Pv(Xy.bind(null,a)),u2(function(){(yt&6)===0&&Is()}),h=null;else{switch(ct(v)){case 1:h=Xo;break;case 4:h=mi;break;case 16:h=ro;break;case 536870912:h=We;break;default:h=ro}h=ob(h,Qy.bind(null,a))}a.callbackPriority=c,a.callbackNode=h}}function Qy(a,c){if(bc=-1,xc=0,(yt&6)!==0)throw Error(n(327));var h=a.callbackNode;if(Co()&&a.callbackNode!==h)return null;var v=vi(a,a===hn?Sn:0);if(v===0)return null;if((v&30)!==0||(v&a.expiredLanes)!==0||c)c=wc(a,v);else{c=v;var x=yt;yt|=2;var _=eb();(hn!==a||Sn!==c)&&(cs=null,No=Ht()+500,Mi(a,c));do try{L2();break}catch(P){Zy(a,P)}while(!0);_f(),pc.current=_,yt=x,sn!==null?c=0:(hn=null,Sn=0,c=cn)}if(c!==0){if(c===2&&(x=Zo(a),x!==0&&(v=x,c=lh(a,x))),c===1)throw h=Ca,Mi(a,0),$s(a,v),Qn(a,Ht()),h;if(c===6)$s(a,v);else{if(x=a.current.alternate,(v&30)===0&&!j2(x)&&(c=wc(a,v),c===2&&(_=Zo(a),_!==0&&(v=_,c=lh(a,_))),c===1))throw h=Ca,Mi(a,0),$s(a,v),Qn(a,Ht()),h;switch(a.finishedWork=x,a.finishedLanes=v,c){case 0:case 1:throw Error(n(345));case 2:Ai(a,Yn,cs);break;case 3:if($s(a,v),(v&130023424)===v&&(c=ih+500-Ht(),10<c)){if(vi(a,0)!==0)break;if(x=a.suspendedLanes,(x&v)!==v){Hn(),a.pingedLanes|=a.suspendedLanes&x;break}a.timeoutHandle=pf(Ai.bind(null,a,Yn,cs),c);break}Ai(a,Yn,cs);break;case 4:if($s(a,v),(v&4194240)===v)break;for(c=a.eventTimes,x=-1;0<v;){var M=31-Wt(v);_=1<<M,M=c[M],M>x&&(x=M),v&=~_}if(v=x,v=Ht()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*R2(v/1960))-v,10<v){a.timeoutHandle=pf(Ai.bind(null,a,Yn,cs),v);break}Ai(a,Yn,cs);break;case 5:Ai(a,Yn,cs);break;default:throw Error(n(329))}}}return Qn(a,Ht()),a.callbackNode===h?Qy.bind(null,a):null}function lh(a,c){var h=Ta;return a.current.memoizedState.isDehydrated&&(Mi(a,c).flags|=256),a=wc(a,c),a!==2&&(c=Yn,Yn=h,c!==null&&ch(c)),a}function ch(a){Yn===null?Yn=a:Yn.push.apply(Yn,a)}function j2(a){for(var c=a;;){if(c.flags&16384){var h=c.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var v=0;v<h.length;v++){var x=h[v],_=x.getSnapshot;x=x.value;try{if(!Nr(_(),x))return!1}catch{return!1}}}if(h=c.child,c.subtreeFlags&16384&&h!==null)h.return=c,c=h;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function $s(a,c){for(c&=~sh,c&=~mc,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var h=31-Wt(c),v=1<<h;a[h]=-1,c&=~v}}function Xy(a){if((yt&6)!==0)throw Error(n(327));Co();var c=vi(a,0);if((c&1)===0)return Qn(a,Ht()),null;var h=wc(a,c);if(a.tag!==0&&h===2){var v=Zo(a);v!==0&&(c=v,h=lh(a,v))}if(h===1)throw h=Ca,Mi(a,0),$s(a,c),Qn(a,Ht()),h;if(h===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,Ai(a,Yn,cs),Qn(a,Ht()),null}function uh(a,c){var h=yt;yt|=1;try{return a(c)}finally{yt=h,yt===0&&(No=Ht()+500,Gl&&Is())}}function Ti(a){zs!==null&&zs.tag===0&&(yt&6)===0&&Co();var c=yt;yt|=1;var h=mr.transition,v=vt;try{if(mr.transition=null,vt=1,a)return a()}finally{vt=v,mr.transition=h,yt=c,(yt&6)===0&&Is()}}function dh(){ir=_o.current,Ft(_o)}function Mi(a,c){a.finishedWork=null,a.finishedLanes=0;var h=a.timeoutHandle;if(h!==-1&&(a.timeoutHandle=-1,c2(h)),sn!==null)for(h=sn.return;h!==null;){var v=h;switch(xf(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&Vl();break;case 3:ko(),Ft(Kn),Ft(Rn),jf();break;case 5:Of(v);break;case 4:ko();break;case 13:Ft(qt);break;case 19:Ft(qt);break;case 10:Nf(v.type._context);break;case 22:case 23:dh()}h=h.return}if(hn=a,sn=a=Us(a.current,null),Sn=ir=c,cn=0,Ca=null,sh=mc=Ci=0,Yn=Ta=null,Ei!==null){for(c=0;c<Ei.length;c++)if(h=Ei[c],v=h.interleaved,v!==null){h.interleaved=null;var x=v.next,_=h.pending;if(_!==null){var M=_.next;_.next=x,v.next=M}h.pending=v}Ei=null}return a}function Zy(a,c){do{var h=sn;try{if(_f(),sc.current=lc,ic){for(var v=Vt.memoizedState;v!==null;){var x=v.queue;x!==null&&(x.pending=null),v=v.next}ic=!1}if(Ni=0,fn=ln=Vt=null,wa=!1,ka=0,rh.current=null,h===null||h.return===null){cn=1,Ca=c,sn=null;break}e:{var _=a,M=h.return,P=h,H=c;if(c=Sn,P.flags|=32768,H!==null&&typeof H=="object"&&typeof H.then=="function"){var ie=H,me=P,ge=me.tag;if((me.mode&1)===0&&(ge===0||ge===11||ge===15)){var he=me.alternate;he?(me.updateQueue=he.updateQueue,me.memoizedState=he.memoizedState,me.lanes=he.lanes):(me.updateQueue=null,me.memoizedState=null)}var Oe=Ey(M);if(Oe!==null){Oe.flags&=-257,_y(Oe,M,P,_,c),Oe.mode&1&&Sy(_,ie,c),c=Oe,H=ie;var Pe=c.updateQueue;if(Pe===null){var Fe=new Set;Fe.add(H),c.updateQueue=Fe}else Pe.add(H);break e}else{if((c&1)===0){Sy(_,ie,c),fh();break e}H=Error(n(426))}}else if(Ut&&P.mode&1){var tn=Ey(M);if(tn!==null){(tn.flags&65536)===0&&(tn.flags|=256),_y(tn,M,P,_,c),Sf(So(H,P));break e}}_=H=So(H,P),cn!==4&&(cn=2),Ta===null?Ta=[_]:Ta.push(_),_=M;do{switch(_.tag){case 3:_.flags|=65536,c&=-c,_.lanes|=c;var te=wy(_,H,c);Gv(_,te);break e;case 1:P=H;var q=_.type,ne=_.stateNode;if((_.flags&128)===0&&(typeof q.getDerivedStateFromError=="function"||ne!==null&&typeof ne.componentDidCatch=="function"&&(Bs===null||!Bs.has(ne)))){_.flags|=65536,c&=-c,_.lanes|=c;var we=ky(_,P,c);Gv(_,we);break e}}_=_.return}while(_!==null)}nb(h)}catch(Ue){c=Ue,sn===h&&h!==null&&(sn=h=h.return);continue}break}while(!0)}function eb(){var a=pc.current;return pc.current=lc,a===null?lc:a}function fh(){(cn===0||cn===3||cn===2)&&(cn=4),hn===null||(Ci&268435455)===0&&(mc&268435455)===0||$s(hn,Sn)}function wc(a,c){var h=yt;yt|=2;var v=eb();(hn!==a||Sn!==c)&&(cs=null,Mi(a,c));do try{I2();break}catch(x){Zy(a,x)}while(!0);if(_f(),yt=h,pc.current=v,sn!==null)throw Error(n(261));return hn=null,Sn=0,cn}function I2(){for(;sn!==null;)tb(sn)}function L2(){for(;sn!==null&&!Cl();)tb(sn)}function tb(a){var c=ib(a.alternate,a,ir);a.memoizedProps=a.pendingProps,c===null?nb(a):sn=c,rh.current=null}function nb(a){var c=a;do{var h=c.alternate;if(a=c.return,(c.flags&32768)===0){if(h=C2(h,c,ir),h!==null){sn=h;return}}else{if(h=T2(h,c),h!==null){h.flags&=32767,sn=h;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{cn=6,sn=null;return}}if(c=c.sibling,c!==null){sn=c;return}sn=c=a}while(c!==null);cn===0&&(cn=5)}function Ai(a,c,h){var v=vt,x=mr.transition;try{mr.transition=null,vt=1,D2(a,c,h,v)}finally{mr.transition=x,vt=v}return null}function D2(a,c,h,v){do Co();while(zs!==null);if((yt&6)!==0)throw Error(n(327));h=a.finishedWork;var x=a.finishedLanes;if(h===null)return null;if(a.finishedWork=null,a.finishedLanes=0,h===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var _=h.lanes|h.childLanes;if(ur(a,_),a===hn&&(sn=hn=null,Sn=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||vc||(vc=!0,ob(ro,function(){return Co(),null})),_=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||_){_=mr.transition,mr.transition=null;var M=vt;vt=1;var P=yt;yt|=4,rh.current=null,A2(a,h),Vy(h,a),n2(ff),Rl=!!df,ff=df=null,a.current=h,O2(h),Tl(),yt=P,vt=M,mr.transition=_}else a.current=h;if(vc&&(vc=!1,zs=a,yc=x),_=a.pendingLanes,_===0&&(Bs=null),Zt(h.stateNode),Qn(a,Ht()),c!==null)for(v=a.onRecoverableError,h=0;h<c.length;h++)x=c[h],v(x.value,{componentStack:x.stack,digest:x.digest});if(gc)throw gc=!1,a=oh,oh=null,a;return(yc&1)!==0&&a.tag!==0&&Co(),_=a.pendingLanes,(_&1)!==0?a===ah?Ma++:(Ma=0,ah=a):Ma=0,Is(),null}function Co(){if(zs!==null){var a=ct(yc),c=mr.transition,h=vt;try{if(mr.transition=null,vt=16>a?16:a,zs===null)var v=!1;else{if(a=zs,zs=null,yc=0,(yt&6)!==0)throw Error(n(331));var x=yt;for(yt|=4,De=a.current;De!==null;){var _=De,M=_.child;if((De.flags&16)!==0){var P=_.deletions;if(P!==null){for(var H=0;H<P.length;H++){var ie=P[H];for(De=ie;De!==null;){var me=De;switch(me.tag){case 0:case 11:case 15:Na(8,me,_)}var ge=me.child;if(ge!==null)ge.return=me,De=ge;else for(;De!==null;){me=De;var he=me.sibling,Oe=me.return;if($y(me),me===ie){De=null;break}if(he!==null){he.return=Oe,De=he;break}De=Oe}}}var Pe=_.alternate;if(Pe!==null){var Fe=Pe.child;if(Fe!==null){Pe.child=null;do{var tn=Fe.sibling;Fe.sibling=null,Fe=tn}while(Fe!==null)}}De=_}}if((_.subtreeFlags&2064)!==0&&M!==null)M.return=_,De=M;else e:for(;De!==null;){if(_=De,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Na(9,_,_.return)}var te=_.sibling;if(te!==null){te.return=_.return,De=te;break e}De=_.return}}var q=a.current;for(De=q;De!==null;){M=De;var ne=M.child;if((M.subtreeFlags&2064)!==0&&ne!==null)ne.return=M,De=ne;else e:for(M=q;De!==null;){if(P=De,(P.flags&2048)!==0)try{switch(P.tag){case 0:case 11:case 15:hc(9,P)}}catch(Ue){Gt(P,P.return,Ue)}if(P===M){De=null;break e}var we=P.sibling;if(we!==null){we.return=P.return,De=we;break e}De=P.return}}if(yt=x,Is(),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(ut,a)}catch{}v=!0}return v}finally{vt=h,mr.transition=c}}return!1}function rb(a,c,h){c=So(h,c),c=wy(a,c,1),a=Ds(a,c,1),c=Hn(),a!==null&&(Cs(a,1,c),Qn(a,c))}function Gt(a,c,h){if(a.tag===3)rb(a,a,h);else for(;c!==null;){if(c.tag===3){rb(c,a,h);break}else if(c.tag===1){var v=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Bs===null||!Bs.has(v))){a=So(h,a),a=ky(c,a,1),c=Ds(c,a,1),a=Hn(),c!==null&&(Cs(c,1,a),Qn(c,a));break}}c=c.return}}function P2(a,c,h){var v=a.pingCache;v!==null&&v.delete(c),c=Hn(),a.pingedLanes|=a.suspendedLanes&h,hn===a&&(Sn&h)===h&&(cn===4||cn===3&&(Sn&130023424)===Sn&&500>Ht()-ih?Mi(a,0):sh|=h),Qn(a,c)}function sb(a,c){c===0&&((a.mode&1)===0?c=1:(c=gi,gi<<=1,(gi&130023424)===0&&(gi=4194304)));var h=Hn();a=is(a,c),a!==null&&(Cs(a,c,h),Qn(a,h))}function B2(a){var c=a.memoizedState,h=0;c!==null&&(h=c.retryLane),sb(a,h)}function z2(a,c){var h=0;switch(a.tag){case 13:var v=a.stateNode,x=a.memoizedState;x!==null&&(h=x.retryLane);break;case 19:v=a.stateNode;break;default:throw Error(n(314))}v!==null&&v.delete(c),sb(a,h)}var ib;ib=function(a,c,h){if(a!==null)if(a.memoizedProps!==c.pendingProps||Kn.current)Jn=!0;else{if((a.lanes&h)===0&&(c.flags&128)===0)return Jn=!1,N2(a,c,h);Jn=(a.flags&131072)!==0}else Jn=!1,Ut&&(c.flags&1048576)!==0&&Bv(c,Yl,c.index);switch(c.lanes=0,c.tag){case 2:var v=c.type;dc(a,c),a=c.pendingProps;var x=mo(c,Rn.current);wo(c,h),x=Df(null,c,v,a,x,h);var _=Pf();return c.flags|=1,typeof x=="object"&&x!==null&&typeof x.render=="function"&&x.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,Gn(v)?(_=!0,Kl(c)):_=!1,c.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,Mf(c),x.updater=cc,c.stateNode=x,x._reactInternals=c,Hf(c,v,a,h),c=Kf(null,c,v,!0,_,h)):(c.tag=0,Ut&&_&&bf(c),Un(null,c,x,h),c=c.child),c;case 16:v=c.elementType;e:{switch(dc(a,c),a=c.pendingProps,x=v._init,v=x(v._payload),c.type=v,x=c.tag=$2(v),a=Tr(v,a),x){case 0:c=Vf(null,c,v,a,h);break e;case 1:c=Oy(null,c,v,a,h);break e;case 11:c=Ny(null,c,v,a,h);break e;case 14:c=Cy(null,c,v,Tr(v.type,a),h);break e}throw Error(n(306,v,""))}return c;case 0:return v=c.type,x=c.pendingProps,x=c.elementType===v?x:Tr(v,x),Vf(a,c,v,x,h);case 1:return v=c.type,x=c.pendingProps,x=c.elementType===v?x:Tr(v,x),Oy(a,c,v,x,h);case 3:e:{if(Ry(c),a===null)throw Error(n(387));v=c.pendingProps,_=c.memoizedState,x=_.element,Kv(a,c),nc(c,v,null,h);var M=c.memoizedState;if(v=M.element,_.isDehydrated)if(_={element:v,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},c.updateQueue.baseState=_,c.memoizedState=_,c.flags&256){x=So(Error(n(423)),c),c=jy(a,c,v,h,x);break e}else if(v!==x){x=So(Error(n(424)),c),c=jy(a,c,v,h,x);break e}else for(sr=Os(c.stateNode.containerInfo.firstChild),rr=c,Ut=!0,Cr=null,h=qv(c,null,v,h),c.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(yo(),v===x){c=ls(a,c,h);break e}Un(a,c,v,h)}c=c.child}return c;case 5:return Yv(c),a===null&&kf(c),v=c.type,x=c.pendingProps,_=a!==null?a.memoizedProps:null,M=x.children,hf(v,x)?M=null:_!==null&&hf(v,_)&&(c.flags|=32),Ay(a,c),Un(a,c,M,h),c.child;case 6:return a===null&&kf(c),null;case 13:return Iy(a,c,h);case 4:return Af(c,c.stateNode.containerInfo),v=c.pendingProps,a===null?c.child=bo(c,null,v,h):Un(a,c,v,h),c.child;case 11:return v=c.type,x=c.pendingProps,x=c.elementType===v?x:Tr(v,x),Ny(a,c,v,x,h);case 7:return Un(a,c,c.pendingProps,h),c.child;case 8:return Un(a,c,c.pendingProps.children,h),c.child;case 12:return Un(a,c,c.pendingProps.children,h),c.child;case 10:e:{if(v=c.type._context,x=c.pendingProps,_=c.memoizedProps,M=x.value,Lt(Zl,v._currentValue),v._currentValue=M,_!==null)if(Nr(_.value,M)){if(_.children===x.children&&!Kn.current){c=ls(a,c,h);break e}}else for(_=c.child,_!==null&&(_.return=c);_!==null;){var P=_.dependencies;if(P!==null){M=_.child;for(var H=P.firstContext;H!==null;){if(H.context===v){if(_.tag===1){H=as(-1,h&-h),H.tag=2;var ie=_.updateQueue;if(ie!==null){ie=ie.shared;var me=ie.pending;me===null?H.next=H:(H.next=me.next,me.next=H),ie.pending=H}}_.lanes|=h,H=_.alternate,H!==null&&(H.lanes|=h),Cf(_.return,h,c),P.lanes|=h;break}H=H.next}}else if(_.tag===10)M=_.type===c.type?null:_.child;else if(_.tag===18){if(M=_.return,M===null)throw Error(n(341));M.lanes|=h,P=M.alternate,P!==null&&(P.lanes|=h),Cf(M,h,c),M=_.sibling}else M=_.child;if(M!==null)M.return=_;else for(M=_;M!==null;){if(M===c){M=null;break}if(_=M.sibling,_!==null){_.return=M.return,M=_;break}M=M.return}_=M}Un(a,c,x.children,h),c=c.child}return c;case 9:return x=c.type,v=c.pendingProps.children,wo(c,h),x=hr(x),v=v(x),c.flags|=1,Un(a,c,v,h),c.child;case 14:return v=c.type,x=Tr(v,c.pendingProps),x=Tr(v.type,x),Cy(a,c,v,x,h);case 15:return Ty(a,c,c.type,c.pendingProps,h);case 17:return v=c.type,x=c.pendingProps,x=c.elementType===v?x:Tr(v,x),dc(a,c),c.tag=1,Gn(v)?(a=!0,Kl(c)):a=!1,wo(c,h),by(c,v,x),Hf(c,v,x,h),Kf(null,c,v,!0,a,h);case 19:return Dy(a,c,h);case 22:return My(a,c,h)}throw Error(n(156,c.tag))};function ob(a,c){return Nl(a,c)}function F2(a,c,h,v){this.tag=a,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function gr(a,c,h,v){return new F2(a,c,h,v)}function hh(a){return a=a.prototype,!(!a||!a.isReactComponent)}function $2(a){if(typeof a=="function")return hh(a)?1:0;if(a!=null){if(a=a.$$typeof,a===K)return 11;if(a===$)return 14}return 2}function Us(a,c){var h=a.alternate;return h===null?(h=gr(a.tag,c,a.key,a.mode),h.elementType=a.elementType,h.type=a.type,h.stateNode=a.stateNode,h.alternate=a,a.alternate=h):(h.pendingProps=c,h.type=a.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=a.flags&14680064,h.childLanes=a.childLanes,h.lanes=a.lanes,h.child=a.child,h.memoizedProps=a.memoizedProps,h.memoizedState=a.memoizedState,h.updateQueue=a.updateQueue,c=a.dependencies,h.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},h.sibling=a.sibling,h.index=a.index,h.ref=a.ref,h}function kc(a,c,h,v,x,_){var M=2;if(v=a,typeof a=="function")hh(a)&&(M=1);else if(typeof a=="string")M=5;else e:switch(a){case L:return Oi(h.children,x,_,c);case D:M=8,x|=8;break;case z:return a=gr(12,h,c,x|2),a.elementType=z,a.lanes=_,a;case X:return a=gr(13,h,c,x),a.elementType=X,a.lanes=_,a;case W:return a=gr(19,h,c,x),a.elementType=W,a.lanes=_,a;case Z:return Sc(h,x,_,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case F:M=10;break e;case J:M=9;break e;case K:M=11;break e;case $:M=14;break e;case U:M=16,v=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return c=gr(M,h,c,x),c.elementType=a,c.type=v,c.lanes=_,c}function Oi(a,c,h,v){return a=gr(7,a,v,c),a.lanes=h,a}function Sc(a,c,h,v){return a=gr(22,a,v,c),a.elementType=Z,a.lanes=h,a.stateNode={isHidden:!1},a}function ph(a,c,h){return a=gr(6,a,null,c),a.lanes=h,a}function mh(a,c,h){return c=gr(4,a.children!==null?a.children:[],a.key,c),c.lanes=h,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function U2(a,c,h,v,x){this.tag=c,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ns(0),this.expirationTimes=Ns(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ns(0),this.identifierPrefix=v,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function gh(a,c,h,v,x,_,M,P,H){return a=new U2(a,c,h,P,H),c===1?(c=1,_===!0&&(c|=8)):c=0,_=gr(3,null,null,c),a.current=_,_.stateNode=a,_.memoizedState={element:v,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mf(_),a}function H2(a,c,h){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:v==null?null:""+v,children:a,containerInfo:c,implementation:h}}function ab(a){if(!a)return js;a=a._reactInternals;e:{if(es(a)!==a||a.tag!==1)throw Error(n(170));var c=a;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(Gn(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(a.tag===1){var h=a.type;if(Gn(h))return Lv(a,h,c)}return c}function lb(a,c,h,v,x,_,M,P,H){return a=gh(h,v,!0,a,x,_,M,P,H),a.context=ab(null),h=a.current,v=Hn(),x=Fs(h),_=as(v,x),_.callback=c??null,Ds(h,_,x),a.current.lanes=x,Cs(a,x,v),Qn(a,v),a}function Ec(a,c,h,v){var x=c.current,_=Hn(),M=Fs(x);return h=ab(h),c.context===null?c.context=h:c.pendingContext=h,c=as(_,M),c.payload={element:a},v=v===void 0?null:v,v!==null&&(c.callback=v),a=Ds(x,c,M),a!==null&&(Or(a,x,M,_),tc(a,x,M)),M}function _c(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function cb(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var h=a.retryLane;a.retryLane=h!==0&&h<c?h:c}}function vh(a,c){cb(a,c),(a=a.alternate)&&cb(a,c)}function W2(){return null}var ub=typeof reportError=="function"?reportError:function(a){console.error(a)};function yh(a){this._internalRoot=a}Nc.prototype.render=yh.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(n(409));Ec(a,c,null,null)},Nc.prototype.unmount=yh.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;Ti(function(){Ec(null,a,null,null)}),c[ts]=null}};function Nc(a){this._internalRoot=a}Nc.prototype.unstable_scheduleHydration=function(a){if(a){var c=yi();a={blockedOn:null,target:a,priority:c};for(var h=0;h<dn.length&&c!==0&&c<dn[h].priority;h++);dn.splice(h,0,a),h===0&&Y0(a)}};function bh(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Cc(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function db(){}function q2(a,c,h,v,x){if(x){if(typeof v=="function"){var _=v;v=function(){var ie=_c(M);_.call(ie)}}var M=lb(c,v,a,0,null,!1,!1,"",db);return a._reactRootContainer=M,a[ts]=M.current,ha(a.nodeType===8?a.parentNode:a),Ti(),M}for(;x=a.lastChild;)a.removeChild(x);if(typeof v=="function"){var P=v;v=function(){var ie=_c(H);P.call(ie)}}var H=gh(a,0,!1,null,null,!1,!1,"",db);return a._reactRootContainer=H,a[ts]=H.current,ha(a.nodeType===8?a.parentNode:a),Ti(function(){Ec(c,H,h,v)}),H}function Tc(a,c,h,v,x){var _=h._reactRootContainer;if(_){var M=_;if(typeof x=="function"){var P=x;x=function(){var H=_c(M);P.call(H)}}Ec(c,M,a,x)}else M=q2(h,c,a,x,v);return _c(M)}ta=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var h=_s(c.pendingLanes);h!==0&&(ea(c,h|1),Qn(c,Ht()),(yt&6)===0&&(No=Ht()+500,Is()))}break;case 13:Ti(function(){var v=is(a,1);if(v!==null){var x=Hn();Or(v,a,1,x)}}),vh(a,1)}},en=function(a){if(a.tag===13){var c=is(a,134217728);if(c!==null){var h=Hn();Or(c,a,134217728,h)}vh(a,134217728)}},Tt=function(a){if(a.tag===13){var c=Fs(a),h=is(a,c);if(h!==null){var v=Hn();Or(h,a,c,v)}vh(a,c)}},yi=function(){return vt},Ur=function(a,c){var h=vt;try{return vt=a,c()}finally{vt=h}},nt=function(a,c,h){switch(c){case"input":if(tt(a,h),c=h.name,h.type==="radio"&&c!=null){for(h=a;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<h.length;c++){var v=h[c];if(v!==a&&v.form===a.form){var x=ql(v);if(!x)throw Error(n(90));ae(v),tt(v,x)}}}break;case"textarea":be(a,h);break;case"select":c=h.value,c!=null&&pe(a,!!h.multiple,c,!1)}},Se=uh,st=Ti;var V2={usingClientEntryPoint:!1,Events:[ga,ho,ql,B,se,uh]},Aa={findFiberByHostInstance:xi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},K2={bundleType:Aa.bundleType,version:Aa.version,rendererPackageName:Aa.rendererPackageName,rendererConfig:Aa.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=El(a),a===null?null:a.stateNode},findFiberByHostInstance:Aa.findFiberByHostInstance||W2,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Mc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Mc.isDisabled&&Mc.supportsFiber)try{ut=Mc.inject(K2),mt=Mc}catch{}}return Xn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V2,Xn.createPortal=function(a,c){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bh(c))throw Error(n(200));return H2(a,c,null,h)},Xn.createRoot=function(a,c){if(!bh(a))throw Error(n(299));var h=!1,v="",x=ub;return c!=null&&(c.unstable_strictMode===!0&&(h=!0),c.identifierPrefix!==void 0&&(v=c.identifierPrefix),c.onRecoverableError!==void 0&&(x=c.onRecoverableError)),c=gh(a,1,!1,null,null,h,!1,v,x),a[ts]=c.current,ha(a.nodeType===8?a.parentNode:a),new yh(c)},Xn.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=El(c),a=a===null?null:a.stateNode,a},Xn.flushSync=function(a){return Ti(a)},Xn.hydrate=function(a,c,h){if(!Cc(c))throw Error(n(200));return Tc(null,a,c,!0,h)},Xn.hydrateRoot=function(a,c,h){if(!bh(a))throw Error(n(405));var v=h!=null&&h.hydratedSources||null,x=!1,_="",M=ub;if(h!=null&&(h.unstable_strictMode===!0&&(x=!0),h.identifierPrefix!==void 0&&(_=h.identifierPrefix),h.onRecoverableError!==void 0&&(M=h.onRecoverableError)),c=lb(c,null,a,1,h??null,x,!1,_,M),a[ts]=c.current,ha(a),v)for(a=0;a<v.length;a++)h=v[a],x=h._getVersion,x=x(h._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[h,x]:c.mutableSourceEagerHydrationData.push(h,x);return new Nc(c)},Xn.render=function(a,c,h){if(!Cc(c))throw Error(n(200));return Tc(null,a,c,!1,h)},Xn.unmountComponentAtNode=function(a){if(!Cc(a))throw Error(n(40));return a._reactRootContainer?(Ti(function(){Tc(null,null,a,!1,function(){a._reactRootContainer=null,a[ts]=null})}),!0):!1},Xn.unstable_batchedUpdates=uh,Xn.unstable_renderSubtreeIntoContainer=function(a,c,h,v){if(!Cc(h))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Tc(a,c,h,!1,v)},Xn.version="18.3.1-next-f1338f8080-20240426",Xn}var xb;function AS(){if(xb)return kh.exports;xb=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),kh.exports=eM(),kh.exports}var wb;function tM(){if(wb)return Ac;wb=1;var t=AS();return Ac.createRoot=t.createRoot,Ac.hydrateRoot=t.hydrateRoot,Ac}var nM=tM();const rM=dl(nM),OS=[{id:"charter",label:"Charter",description:"Charter serif"},{id:"source-serif",label:"Source Serif",description:"Source Serif 4"},{id:"plex-mono",label:"Plex Mono",description:"IBM Plex Mono"},{id:"crimson",label:"Crimson",description:"Crimson Pro"},{id:"inter",label:"Inter",description:"Inter sans-serif"},{id:"baskerville",label:"Baskerville",description:"Libre Baskerville"},{id:"grotesk",label:"Grotesk",description:"Space Grotesk"},{id:"literata",label:"Literata",description:"Literata serif"},{id:"dm-sans",label:"DM Sans",description:"DM Sans + Serif"}],RS=[{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"},{id:"shelf",label:"Shelf",icon:"shelf"}],jS=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],IS=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],sM=["full","compact","minimal"],Nn={typeface:"ow-typeface",mode:"ow-theme-mode",sidebarMode:"ow-sidebar-mode",sidebarStyle:"ow-sidebar-style",sidebarDensity:"ow-sidebar-density",spacing:"ow-spacing",canvas:"ow-canvas"},iM={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function oM(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(Nn.typeface)){const n=iM[t];n&&localStorage.setItem(Nn.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(Nn.spacing)&&(localStorage.setItem(Nn.spacing,e),localStorage.removeItem("ow-typography"))}function LS(){const t=localStorage.getItem(Nn.typeface);return t&&OS.some(e=>e.id===t)?t:"charter"}function DS(){const t=localStorage.getItem(Nn.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ud(){const t=localStorage.getItem(Nn.sidebarMode);return t&&RS.some(e=>e.id===t)?t:"default"}function PS(){return"cards"}function BS(){const t=localStorage.getItem(Nn.sidebarDensity);return t&&sM.includes(t)?t:"full"}function aM(t){localStorage.setItem(Nn.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function zS(){const t=localStorage.getItem(Nn.spacing);return t&&IS.some(e=>e.id===t)?t:"default"}function FS(){const t=localStorage.getItem(Nn.canvas);return t&&jS.some(e=>e.id===t)?t:"seamless"}function $S(t,e,n,r,s="default",i="seamless"){const o=document.documentElement;o.setAttribute("data-typeface",t),o.setAttribute("data-mode",e),o.setAttribute("data-sidebar-mode",n),o.setAttribute("data-sidebar-style",r),s==="default"?o.removeAttribute("data-spacing"):o.setAttribute("data-spacing",s),i==="seamless"?o.removeAttribute("data-canvas"):o.setAttribute("data-canvas",i),o.removeAttribute("data-color"),localStorage.setItem(Nn.typeface,t),localStorage.setItem(Nn.mode,e),localStorage.setItem(Nn.sidebarMode,n),localStorage.setItem(Nn.sidebarStyle,r),localStorage.setItem(Nn.spacing,s),localStorage.setItem(Nn.canvas,i)}function lM(){oM(),$S(LS(),DS(),ud(),PS(),zS(),FS()),document.documentElement.setAttribute("data-sidebar-density",BS())}var cM=AS();const uM=dl(cM);var _h={exports:{}},Nh={};/**
41
+ * @license React
42
+ * use-sync-external-store-shim.production.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */var kb;function dM(){if(kb)return Nh;kb=1;var t=fl();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(m,g){var y=g(),b=r({inst:{value:y,getSnapshot:g}}),k=b[0].inst,w=b[1];return i(function(){k.value=y,k.getSnapshot=g,u(k)&&w({inst:k})},[m,y,g]),s(function(){return u(k)&&w({inst:k}),m(function(){u(k)&&w({inst:k})})},[m]),o(y),y}function u(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function f(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return Nh.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Nh}var Sb;function US(){return Sb||(Sb=1,_h.exports=dM()),_h.exports}var HS=US();function _n(t){this.content=t}_n.prototype={constructor:_n,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new _n(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new _n(n)},addToStart:function(t,e){return new _n([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new _n(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new _n(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=_n.from(t),t.size?new _n(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=_n.from(t),t.size?new _n(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=_n.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};_n.from=function(t){if(t instanceof _n)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new _n(e)};function WS(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=WS(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function qS(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),u=o.nodeSize;if(o==l){n-=u,r-=u;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let f=0,p=Math.min(o.text.length,l.text.length);for(;f<p&&o.text[o.text.length-f-1]==l.text[l.text.length-f-1];)f++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let f=qS(o.content,l.content,n-1,r-1);if(f)return f}n-=u,r-=u}}class de{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let u=this.content[o],f=l+u.nodeSize;if(f>e&&r(u,s+l,i||null,o)!==!1&&u.content.size){let p=l+1;u.nodesBetween(Math.max(0,e-p),Math.min(u.content.size,n-p),r,s+p)}l=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,u)=>{let f=l.isText?l.text.slice(Math.max(e,u)-u,n-u):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&f||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=f},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new de(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],u=o+l.nodeSize;u>e&&((o<e||u>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=u}return new de(r,s)}cutByIndex(e,n){return e==n?de.empty:e==0&&n==this.content.length?this:new de(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new de(s,i)}addToStart(e){return new de([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new de(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return WS(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return qS(this,e,n,r)}findIndex(e){if(e==0)return Oc(0,e);if(e==this.size)return Oc(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Oc(n+1,i):Oc(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return de.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new de(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return de.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new de(n||e,r)}static from(e){if(!e)return de.empty;if(e instanceof de)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new de([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}de.empty=new de([],0);const Ch={index:0,offset:0};function Oc(t,e){return Ch.index=t,Ch.offset=e,Ch}function pu(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!pu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!pu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Rt=class Um{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&pu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Um.none;if(e instanceof Um)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Rt.none=[];class mu extends Error{}class _e{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=KS(this.content,e+this.openStart,n);return r&&new _e(r,this.openStart,this.openEnd)}removeBetween(e,n){return new _e(VS(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return _e.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new _e(de.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new _e(e,r,s)}}_e.empty=new _e(de.empty,0,0);function VS(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(VS(i.content,e-s-1,n-s-1)))}function KS(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=KS(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function fM(t,e,n){if(n.openStart>t.depth)throw new mu("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new mu("Inconsistent open depths");return GS(t,e,n,0)}function GS(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=GS(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Fi(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=hM(n,t);return Fi(i,YS(t,o,l,e,r))}else return Fi(i,gu(t,e,r))}function JS(t,e){if(!e.type.compatibleContent(t.type))throw new mu("Cannot join "+e.type.name+" onto "+t.type.name)}function Hm(t,e,n){let r=t.node(n);return JS(r,e.node(n)),r}function zi(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ha(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(zi(t.nodeAfter,r),i++));for(let l=i;l<o;l++)zi(s.child(l),r);e&&e.depth==n&&e.textOffset&&zi(e.nodeBefore,r)}function Fi(t,e){return t.type.checkContent(e),t.copy(e)}function YS(t,e,n,r,s){let i=t.depth>s&&Hm(t,e,s+1),o=r.depth>s&&Hm(n,r,s+1),l=[];return Ha(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(JS(i,o),zi(Fi(i,YS(t,e,n,r,s+1)),l)):(i&&zi(Fi(i,gu(t,e,s+1)),l),Ha(e,n,s,l),o&&zi(Fi(o,gu(n,r,s+1)),l)),Ha(r,null,s,l),new de(l)}function gu(t,e,n){let r=[];if(Ha(null,t,n,r),t.depth>n){let s=Hm(t,e,n+1);zi(Fi(s,gu(t,e,n+1)),r)}return Ha(e,null,n,r),new de(r)}function hM(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(de.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Za{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Rt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new vu(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:u}=o.content.findIndex(i),f=i-u;if(r.push(o,l,s+u),!f||(o=o.child(l),o.isText))break;i=f-1,s+=u+1}return new Za(n,r,i)}static resolveCached(e,n){let r=Eb.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Eb.set(e,r=new pM);let s=r.elts[r.i]=Za.resolve(e,n);return r.i=(r.i+1)%mM,s}}class pM{constructor(){this.elts=[],this.i=0}}const mM=12,Eb=new WeakMap;class vu{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const gM=Object.create(null);class Lr{constructor(e,n,r,s=Rt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||de.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&pu(this.attrs,n||e.defaultAttrs||gM)&&Rt.sameSet(this.marks,r||Rt.none)}copy(e=null){return e==this.content?this:new Lr(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Lr(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return _e.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),f=s.node(o).content.cut(s.pos-l,i.pos-l);return new _e(f,s.depth-o,i.depth-o)}replace(e,n,r){return fM(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return Za.resolveCached(this,e)}resolveNoCache(e){return Za.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),QS(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=de.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let u=s;u<i;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Rt.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Rt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=de.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Lr.prototype.text=void 0;class yu extends Lr{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):QS(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new yu(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yu(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function QS(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Wi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new vM(e,n);if(r.next==null)return Wi.empty;let s=XS(r);r.next&&r.err("Unexpected trailing text");let i=EM(SM(s));return _M(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let u=o.matchFragment(e,r);if(u&&(!n||u.validEnd))return de.from(l.map(f=>f.createAndFill()));for(let f=0;f<o.next.length;f++){let{type:p,next:m}=o.next[f];if(!(p.isText||p.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let g=i(m,l.concat(p));if(g)return g}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:u}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||u.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
49
+ `)}}Wi.empty=new Wi(!0);class vM{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function XS(t){let e=[];do e.push(yM(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function yM(t){let e=[];do e.push(bM(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function bM(t){let e=kM(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=xM(t,e);else break;return e}function _b(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function xM(t,e){let n=_b(t),r=n;return t.eat(",")&&(t.next!="}"?r=_b(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function wM(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function kM(t){if(t.eat("(")){let e=XS(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=wM(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function SM(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,u){let f={term:u,to:l};return e[o].push(f),f}function s(o,l){o.forEach(u=>u.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((u,f)=>u.concat(i(f,l)),[]);if(o.type=="seq")for(let u=0;;u++){let f=i(o.exprs[u],l);if(u==o.exprs.length-1)return f;s(f,l=n())}else if(o.type=="star"){let u=n();return r(l,u),s(i(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return s(i(o.expr,l),u),s(i(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let u=l;for(let f=0;f<o.min;f++){let p=n();s(i(o.expr,u),p),u=p}if(o.max==-1)s(i(o.expr,u),u);else for(let f=o.min;f<o.max;f++){let p=n();r(u,p),s(i(o.expr,u),p),u=p}return[r(u)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function ZS(t,e){return e-t}function Nb(t,e){let n=[];return r(e),n.sort(ZS);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:u}=i[o];!l&&n.indexOf(u)==-1&&r(u)}}}function EM(t){let e=Object.create(null);return n(Nb(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:u})=>{if(!l)return;let f;for(let p=0;p<s.length;p++)s[p][0]==l&&(f=s[p][1]);Nb(t,u).forEach(p=>{f||s.push([l,f=[]]),f.indexOf(p)==-1&&f.push(p)})})});let i=e[r.join(",")]=new Wi(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(ZS);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function _M(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:u,next:f}=s.next[l];o.push(u.name),i&&!(u.isText||u.hasRequiredAttrs())&&(i=!1),r.indexOf(f)==-1&&r.push(f)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function eE(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function tE(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function nE(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function rE(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new CM(t,r,e[r]);return n}let Cb=class sE{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=rE(e,r.attrs),this.defaultAttrs=eE(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Wi.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:tE(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Lr(this,this.computeAttrs(e),de.from(n),Rt.setFrom(r))}createChecked(e=null,n,r){return n=de.from(n),this.checkContent(n),new Lr(this,this.computeAttrs(e),n,Rt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=de.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(de.empty,!0);return i?new Lr(this,e,n.append(i),Rt.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){nE(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Rt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new sE(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function NM(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class CM{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?NM(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class dd{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=rE(e,s.attrs),this.excluded=null;let i=eE(this.attrs);this.instance=i?new Rt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Rt(this,tE(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new dd(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){nE(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class iE{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=_n.from(e.nodes),n.marks=_n.from(e.marks||{}),this.nodes=Cb.compile(this.spec.nodes,this),this.marks=dd.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Wi.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Tb(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Tb(this,o.split(" "))}this.nodeFromJSON=s=>Lr.fromJSON(this,s),this.markFromJSON=s=>Rt.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Cb){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new yu(r,r.defaultAttrs,e,Rt.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Tb(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let u=t.marks[l];(s=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function TM(t){return t.tag!=null}function MM(t){return t.style!=null}class ti{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(TM(s))this.tags.push(s);else if(MM(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Ab(this,n,!1);return r.addAll(e,Rt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Ab(this,n,!0);return r.addAll(e,Rt.none,n.from,n.to),_e.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(RM(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ob(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=Ob(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ti(e,ti.schemaRules(e)))}}const oE={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},AM={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},aE={ol:!0,ul:!0},el=1,Wm=2,Wa=4;function Mb(t,e,n){return e!=null?(e?el:0)|(e==="full"?Wm:0):t&&t.whitespace=="pre"?el|Wm:n&~Wa}class Rc{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Rt.none,this.match=i||(o&Wa?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(de.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&el)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=de.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(de.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!oE.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ab{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=Mb(null,n.preserveWhitespace,0)|(r?Wa:0);s?i=new Rc(s.type,s.attrs,Rt.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Rc(null,null,Rt.none,!0,null,o):i=new Rc(e.schema.topNodeType,null,Rt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Wm?"full":this.localPreserveWS||(s.options&el)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
50
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let u=0;u<l.length;u++)u&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[u]&&this.insertNode(o.text(l[u]),n,!/\S/.test(l[u]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],u=e.previousSibling;(!l||u&&u.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;aE.hasOwnProperty(o)&&this.parser.normalizeLists&&OM(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(u?u.ignore:AM.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let f,p=this.needsBlock;if(oE.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),f=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let m=u&&u.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),f&&this.sync(i),this.needsBlock=p}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,u,f,u.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
51
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let u=this.parser.matchStyle(i,o,this,l);if(!u)break;if(u.ignore)return null;if(u.clearMark?n=n.filter(f=>!u.clearMark(f)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)l=u;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(i=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let u=this.nodes[o],f=u.findWrapping(e);if(f&&(!s||s.length>f.length+l)&&(s=f,i=u,!f.length))break;if(u.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Rt.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Rb(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=Mb(e,i,o.options);o.options&Wa&&o.content.length==0&&(l|=Wa);let u=Rt.none;return r=r.filter(f=>(o.type?o.type.allowsMarkType(f.type):Rb(f.type,e))?(u=f.addToSet(u),!1):!0),this.nodes.push(new Rc(e,n,u,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=el)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,u)=>{for(;l>=0;l--){let f=n[l];if(f==""){if(l==n.length-1||l==0)continue;for(;u>=i;u--)if(o(l-1,u))return!0;return!1}else{let p=u>0||u==0&&s?this.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!p||p.name!=f&&!p.isInGroup(f))return!1;u--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function OM(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&aE.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function RM(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Ob(t){let e={};for(let n in t)e[n]=t[n];return e}function Rb(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let u=0;u<l.edgeCount;u++){let{type:f,next:p}=l.edge(u);if(f==e||i.indexOf(p)<0&&o(p))return!0}};if(o(s.contentMatch))return!0}}class Qi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Th(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,u=0;for(;l<i.length&&u<o.marks.length;){let f=o.marks[u];if(!this.marks[f.type.name]){u++;continue}if(!f.eq(i[l][0])||f.type.spec.spanning===!1)break;l++,u++}for(;l<i.length;)s=i.pop()[1];for(;u<o.marks.length;){let f=o.marks[u++],p=this.serializeMark(f,o.isInline,n);p&&(i.push([f,s]),s.appendChild(p.dom),s=p.contentDOM||p.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=ou(Th(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&ou(Th(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return ou(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Qi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=jb(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return jb(e.marks)}}function jb(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Th(t){return t.document||window.document}const Ib=new WeakMap;function jM(t){let e=Ib.get(t);return e===void 0&&Ib.set(t,e=IM(t)),e}function IM(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function ou(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=jM(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,u=n?t.createElementNS(n,s):t.createElement(s),f=e[1],p=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){p=2;for(let m in f)if(f[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),f[m]):m=="style"&&u.style?u.style.cssText=f[m]:u.setAttribute(m,f[m])}}for(let m=p;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>p)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:b}=ou(t,g,n,r);if(u.appendChild(y),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:u,contentDOM:l}}const lE=65535,cE=Math.pow(2,16);function LM(t,e){return t+e*cE}function Lb(t){return t&lE}function DM(t){return(t-(t&lE))/cE}const uE=1,dE=2,au=4,fE=8;class qm{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&fE)>0}get deletedBefore(){return(this.delInfo&(uE|au))>0}get deletedAfter(){return(this.delInfo&(dE|au))>0}get deletedAcross(){return(this.delInfo&au)>0}}class or{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&or.empty)return or.empty}recover(e){let n=0,r=Lb(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+DM(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let u=this.ranges[l]-(this.inverted?s:0);if(u>e)break;let f=this.ranges[l+i],p=this.ranges[l+o],m=u+f;if(e<=m){let g=f?e==u?-1:e==m?1:n:n,y=u+s+(g<0?0:p);if(r)return y;let b=e==(n<0?u:m)?null:LM(l/3,e-u),k=e==u?dE:e==m?uE:au;return(n<0?e!=u:e!=m)&&(k|=fE),new qm(y,k,b)}s+=p-f}return r?e+s:new qm(e+s,0,null)}touches(e,n){let r=0,s=Lb(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let u=this.ranges[l]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[l+i],p=u+f;if(e<=p&&l==s*3)return!0;r+=this.ranges[l+o]-f}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),u=o+(this.inverted?0:i),f=this.ranges[s+n],p=this.ranges[s+r];e(l,l+f,u,u+p),i+=p-f}}invert(){return new or(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?or.empty:new or(e<0?[0,-e,0]:[0,0,e])}}or.empty=new or([]);class tl{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new tl(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new tl;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let u=this.getMirror(i);if(u!=null&&u>i&&u<this.to){i=u,e=this._maps[u].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new qm(e,s,null)}}const Mh=Object.create(null);class zn{getMap(){return or.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Mh[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Mh)throw new RangeError("Duplicate use of step JSON ID "+e);return Mh[e]=n,n.prototype.jsonID=e,n}}class on{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new on(e,null)}static fail(e){return new on(null,e)}static fromReplace(e,n,r,s){try{return on.ok(e.replace(n,r,s))}catch(i){if(i instanceof mu)return on.fail(i.message);throw i}}}function Ng(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Ng(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return de.fromArray(r)}class Xs extends zn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new _e(Ng(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,i)}invert(){return new Ir(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Xs(n.pos,r.pos,this.mark)}merge(e){return e instanceof Xs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xs(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Xs(n.from,n.to,e.markFromJSON(n.mark))}}zn.jsonID("addMark",Xs);class Ir extends zn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new _e(Ng(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,r)}invert(){return new Xs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ir(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ir&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ir(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ir(n.from,n.to,e.markFromJSON(n.mark))}}zn.jsonID("removeMark",Ir);class Zs extends zn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new _e(de.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Zs(this.pos,n.marks[s]);return new Zs(this.pos,this.mark)}}return new qi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zs(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Zs(n.pos,e.markFromJSON(n.mark))}}zn.jsonID("addNodeMark",Zs);class qi extends zn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new _e(de.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Zs(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new qi(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new qi(n.pos,e.markFromJSON(n.mark))}}zn.jsonID("removeNodeMark",qi);class mn extends zn{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Vm(e,this.from,this.to)?on.fail("Structure replace would overwrite content"):on.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new or([this.from,this.to-this.from,this.slice.size])}invert(e){return new mn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new mn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof mn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?_e.empty:new _e(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new mn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?_e.empty:new _e(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new mn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new mn(n.from,n.to,_e.fromJSON(e,n.slice),!!n.structure)}}zn.jsonID("replace",mn);class gn extends zn{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Vm(e,this.from,this.gapFrom)||Vm(e,this.gapTo,this.to)))return on.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return on.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?on.fromReplace(e,this.from,this.to,r):on.fail("Content does not fit in gap")}getMap(){return new or([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new gn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new gn(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new gn(n.from,n.to,n.gapFrom,n.gapTo,_e.fromJSON(e,n.slice),n.insert,!!n.structure)}}zn.jsonID("replaceAround",gn);function Vm(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function PM(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(u,f,p)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&p.type.allowsMarkType(r.type)){let g=Math.max(f,e),y=Math.min(f+u.nodeSize,n),b=r.addToSet(m);for(let k=0;k<m.length;k++)m[k].isInSet(b)||(o&&o.to==g&&o.mark.eq(m[k])?o.to=y:s.push(o=new Ir(g,y,m[k])));l&&l.to==g?l.to=y:i.push(l=new Xs(g,y,r))}}),s.forEach(u=>t.step(u)),i.forEach(u=>t.step(u))}function BM(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let u=null;if(r instanceof dd){let f=o.marks,p;for(;p=r.isInSet(f);)(u||(u=[])).push(p),f=p.removeFromSet(f)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let f=Math.min(l+o.nodeSize,n);for(let p=0;p<u.length;p++){let m=u[p],g;for(let y=0;y<s.length;y++){let b=s[y];b.step==i-1&&m.eq(s[y].style)&&(g=b)}g?(g.to=f,g.step=i):s.push({style:m,from:Math.max(l,e),to:f,step:i})}}}),s.forEach(o=>t.step(new Ir(o.from,o.to,o.style)))}function Cg(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let u=0;u<i.childCount;u++){let f=i.child(u),p=l+f.nodeSize,m=r.matchType(f.type);if(!m)o.push(new mn(l,p,_e.empty));else{r=m;for(let g=0;g<f.marks.length;g++)n.allowsMarkType(f.marks[g].type)||t.step(new Ir(l,p,f.marks[g]));if(s&&f.isText&&n.whitespace!="pre"){let g,y=/\r?\n|\r/g,b;for(;g=y.exec(f.text);)b||(b=new _e(de.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),o.push(new mn(l+g.index,l+g.index+g[0].length,b))}}l=p}if(!r.validEnd){let u=r.fillBefore(de.empty,!0);t.replace(l,l,new _e(u,0,0))}for(let u=o.length-1;u>=0;u--)t.step(o[u])}function zM(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ko(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,u=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,u,n))return r;if(r==0||o.type.spec.isolating||!zM(o,l,u))break;l&&(s=1),u<o.childCount&&(i=1)}return null}function FM(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),u=o,f=l,p=de.empty,m=0;for(let b=i,k=!1;b>n;b--)k||r.index(b)>0?(k=!0,p=de.from(r.node(b).copy(p)),m++):u--;let g=de.empty,y=0;for(let b=i,k=!1;b>n;b--)k||s.after(b+1)<s.end(b)?(k=!0,g=de.from(s.node(b).copy(g)),y++):f++;t.step(new gn(u,f,o,l,new _e(p.append(g),m,y),p.size-m,!0))}function Tg(t,e,n=null,r=t){let s=$M(t,e),i=s&&UM(r,e);return i?s.map(Db).concat({type:e,attrs:n}).concat(i.map(Db)):null}function Db(t){return{type:t,attrs:null}}function $M(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function UM(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let u=(o.length?o[o.length-1]:e).contentMatch;for(let f=r;u&&f<s;f++)u=u.matchType(n.child(f).type);return!u||!u.validEnd?null:o}function HM(t,e,n){let r=de.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=de.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new gn(s,i,s,i,new _e(r,0,0),n.length,!0))}function WM(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let u=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,u)&&qM(t.doc,t.mapping.slice(i).map(l),r)){let f=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!b?f=!1:!y&&b&&(f=!0)}f===!1&&pE(t,o,l,i),Cg(t,t.mapping.slice(i).map(l,1),r,void 0,f===null);let p=t.mapping.slice(i),m=p.map(l,1),g=p.map(l+o.nodeSize,1);return t.step(new gn(m,g,m+1,g-1,new _e(de.from(r.create(u,null,o.marks)),0,0),1,!0)),f===!0&&hE(t,o,l,i),!1}})}function hE(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let u=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function pE(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
52
+ `))}})}function qM(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function VM(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new gn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new _e(de.from(o),0,0),1,!0))}function bs(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let f=s.depth-1,p=n-2;f>i;f--,p--){let m=s.node(f),g=s.index(f);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),b=r&&r[p+1];b&&(y=y.replaceChild(0,b.type.create(b.attrs)));let k=r&&r[p]||m;if(!m.canReplace(g+1,m.childCount)||!k.type.validContent(y))return!1}let l=s.indexAfter(i),u=r&&r[0];return s.node(i).canReplaceWith(l,l,u?u.type:s.node(i+1).type)}function KM(t,e,n=1,r){let s=t.doc.resolve(e),i=de.empty,o=de.empty;for(let l=s.depth,u=s.depth-n,f=n-1;l>u;l--,f--){i=de.from(s.node(l).copy(i));let p=r&&r[f];o=de.from(p?p.type.create(p.attrs,o):s.node(l).copy(o))}t.step(new mn(e,e,new _e(i.append(o),n,n),!0))}function ci(t,e){let n=t.resolve(e),r=n.index();return mE(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function GM(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function mE(t,e){return!!(t&&e&&!t.isLeaf&&GM(t,e))}function fd(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&mE(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function JM(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let p=o.whitespace=="pre",m=!!o.contentMatch.matchType(s);p&&!m?r=!1:!p&&m&&(r=!0)}let l=t.steps.length;if(r===!1){let p=t.doc.resolve(e+n);pE(t,p.node(),p.before(),l)}o.inlineContent&&Cg(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(l),f=u.map(e-n);if(t.step(new mn(f,u.map(e+n,-1),_e.empty,!0)),r===!0){let p=t.doc.resolve(f);hE(t,p.node(),p.before(),t.steps.length)}return t}function YM(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function gE(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(l>0?1:0),f=r.node(o),p=!1;if(i==1)p=f.canReplace(u,u,s);else{let m=f.contentMatchAt(u).findWrapping(s.firstChild.type);p=m&&f.canReplaceWith(u,u,m[0])}if(p)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function hd(t,e,n=e,r=_e.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return vE(s,i,r)?new mn(e,n,r):new QM(s,i,r).fit()}function vE(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class QM{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=de.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=de.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let u=new _e(i,o,l);return e>-1?new gn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new mn(r.pos,s.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Ah(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:u,match:f}=this.frontier[l],p,m=null;if(n==1&&(o?f.matchType(o.type)||(m=f.fillBefore(de.from(o),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:m};if(n==2&&o&&(p=f.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:p};if(i&&f.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ah(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new _e(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ah(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new _e(Pa(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new _e(Pa(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let k=0;k<i.length;k++)this.openFrontierNode(i[k]);let o=this.unplaced,l=r?r.content:o.content,u=o.openStart-e,f=0,p=[],{match:m,type:g}=this.frontier[n];if(s){for(let k=0;k<s.childCount;k++)p.push(s.child(k));m=m.matchFragment(s)}let y=l.size+e-(o.content.size-o.openEnd);for(;f<l.childCount;){let k=l.child(f),w=m.matchType(k.type);if(!w)break;f++,(f>1||u==0||k.content.size)&&(m=w,p.push(yE(k.mark(g.allowedMarks(k.marks)),f==1?u:0,f==l.childCount?y:-1)))}let b=f==l.childCount;b||(y=-1),this.placed=Ba(this.placed,n,de.from(p)),this.frontier[n].match=m,b&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let k=0,w=l;k<y;k++){let E=w.lastChild;this.frontier.push({type:E.type,match:E.contentMatchAt(E.childCount)}),w=E.content}this.unplaced=b?e==0?_e.empty:new _e(Pa(o.content,e-1,1),e-1,y<0?o.openEnd:e-1):new _e(Pa(o.content,e,f),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Oh(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Oh(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:u,type:f}=this.frontier[l],p=Oh(e,l,f,u,!0);if(!p||p.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ba(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Ba(this.placed,this.depth,de.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(de.empty,!0);n.childCount&&(this.placed=Ba(this.placed,this.frontier.length,n))}}function Pa(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Pa(t.firstChild.content,e-1,n)))}function Ba(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ba(t.lastChild.content,e-1,n)))}function Ah(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function yE(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,yE(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(de.empty,!0)))),t.copy(r)}function Oh(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!XM(n,i.content,o)?l:null}function XM(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ZM(t){return t.spec.defining||t.spec.definingForContent}function eA(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(vE(s,i,r))return t.step(new mn(e,n,r));let o=xE(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let g=s.depth,y=s.pos-1;g>0;g--,y--){let b=s.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(g)>-1?l=g:s.before(g)==y&&o.splice(1,0,-g)}let u=o.indexOf(l),f=[],p=r.openStart;for(let g=r.content,y=0;;y++){let b=g.firstChild;if(f.push(b),y==r.openStart)break;g=b.content}for(let g=p-1;g>=0;g--){let y=f[g],b=ZM(y.type);if(b&&!y.sameMarkup(s.node(Math.abs(l)-1)))p=g;else if(b||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+p+1)%(r.openStart+1),b=f[y];if(b)for(let k=0;k<o.length;k++){let w=o[(k+u)%o.length],E=!0;w<0&&(E=!1,w=-w);let N=s.node(w-1),O=s.index(w-1);if(N.canReplaceWith(O,O,b.type,b.marks))return t.replace(s.before(w),E?i.after(w):n,new _e(bE(r.content,0,r.openStart,y),y,r.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=s.before(y),n=i.after(y))}}function bE(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(bE(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(de.empty,!0))}return t}function tA(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=YM(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new _e(de.from(r),0,0))}function nA(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=xE(r,s);for(let o=0;o<i.length;o++){let l=i[o],u=o==i.length-1;if(u&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(u||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function xE(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class Po extends zn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return on.fromReplace(e,this.pos,this.pos+1,new _e(de.from(s),0,n.isLeaf?0:1))}getMap(){return or.empty}invert(e){return new Po(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Po(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Po(n.pos,n.attr,n.value)}}zn.jsonID("attr",Po);class nl extends zn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return on.ok(r)}getMap(){return or.empty}invert(e){return new nl(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new nl(n.attr,n.value)}}zn.jsonID("docAttr",nl);let Fo=class extends Error{};Fo=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Fo.prototype=Object.create(Error.prototype);Fo.prototype.constructor=Fo;Fo.prototype.name="TransformError";class Mg{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new tl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Fo(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,u)=>{e=Math.min(e,l),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=_e.empty){let s=hd(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new _e(de.from(r),0,0))}delete(e,n){return this.replace(e,n,_e.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return eA(this,e,n,r),this}replaceRangeWith(e,n,r){return tA(this,e,n,r),this}deleteRange(e,n){return nA(this,e,n),this}lift(e,n){return FM(this,e,n),this}join(e,n=1){return JM(this,e,n),this}wrap(e,n){return HM(this,e,n),this}setBlockType(e,n=e,r,s=null){return WM(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return VM(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Po(e,n,r)),this}setDocAttribute(e,n){return this.step(new nl(e,n)),this}addNodeMark(e,n){return this.step(new Zs(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Rt)n.isInSet(r.marks)&&this.step(new qi(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new qi(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return KM(this,e,n,r),this}addMark(e,n,r){return PM(this,e,n,r),this}removeMark(e,n,r){return BM(this,e,n,r),this}clearIncompatible(e,n,r){return Cg(this,e,n,r),this}}const Rh=Object.create(null);class it{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new wE(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=_e.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:u,$to:f}=o[l],p=e.mapping.slice(i);e.replaceRange(p.map(u.pos),p.map(f.pos),l?_e.empty:n),l==0&&zb(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],u=e.mapping.slice(r),f=u.map(o.pos),p=u.map(l.pos);i?e.deleteRange(f,p):(e.replaceRangeWith(f,p,n),zb(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Ge(e):Oo(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?Oo(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Oo(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new lr(e.node(0))}static atStart(e){return Oo(e,e,0,0,1)||new lr(e)}static atEnd(e){return Oo(e,e,e.content.size,e.childCount,-1)||new lr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Rh[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Rh)throw new RangeError("Duplicate use of selection JSON ID "+e);return Rh[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ge.between(this.$anchor,this.$head).getBookmark()}}it.prototype.visible=!0;class wE{constructor(e,n){this.$from=e,this.$to=n}}let Pb=!1;function Bb(t){!Pb&&!t.parent.inlineContent&&(Pb=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ge extends it{constructor(e,n=e){Bb(e),Bb(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return it.near(r);let s=e.resolve(n.map(this.anchor));return new Ge(s.parent.inlineContent?s:r,r)}replace(e,n=_e.empty){if(super.replace(e,n),n==_e.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ge&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new pd(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ge(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=it.findFrom(n,r,!0)||it.findFrom(n,-r,!0);if(i)n=i.$head;else return it.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(it.findFrom(e,-r,!0)||it.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Ge(e,n)}}it.jsonID("text",Ge);class pd{constructor(e,n){this.anchor=e,this.head=n}map(e){return new pd(e.map(this.anchor),e.map(this.head))}resolve(e){return Ge.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ke extends it{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?it.near(i):new Ke(i)}content(){return new _e(de.from(this.node),0,0)}eq(e){return e instanceof Ke&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ag(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ke(e.resolve(n.anchor))}static create(e,n){return new Ke(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ke.prototype.visible=!1;it.jsonID("node",Ke);class Ag{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new pd(r,r):new Ag(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ke.isSelectable(r)?new Ke(n):it.near(n)}}class lr extends it{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=_e.empty){if(n==_e.empty){e.delete(0,e.doc.content.size);let r=it.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new lr(e)}map(e){return new lr(e)}eq(e){return e instanceof lr}getBookmark(){return rA}}it.jsonID("all",lr);const rA={map(){return this},resolve(t){return new lr(t)}};function Oo(t,e,n,r,s,i=!1){if(e.inlineContent)return Ge.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Ke.isSelectable(l))return Ke.create(t,n-(s<0?l.nodeSize:0))}else{let u=Oo(t,l,n+s,s<0?l.childCount:0,s,i);if(u)return u}n+=l.nodeSize*s}return null}function zb(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof mn||s instanceof gn))return;let i=t.mapping.maps[r],o;i.forEach((l,u,f,p)=>{o==null&&(o=p)}),t.setSelection(it.near(t.doc.resolve(o),n))}const Fb=1,jc=2,$b=4;class sA extends Mg{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Fb)&~jc,this.storedMarks=null,this}get selectionSet(){return(this.updated&Fb)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=jc,this}ensureMarks(e){return Rt.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&jc)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~jc,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Rt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(it.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=$b,this}get scrolledIntoView(){return(this.updated&$b)>0}}function Ub(t,e){return!e||!t?t:t.bind(e)}class za{constructor(e,n,r){this.name=e,this.init=Ub(n.init,r),this.apply=Ub(n.apply,r)}}const iA=[new za("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new za("selection",{init(t,e){return t.selection||it.atStart(e.doc)},apply(t){return t.selection}}),new za("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new za("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class jh{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=iA.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new za(r.key,r.spec.state,r))})}}class Do{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let u=s?s[o].n:0,f=s?s[o].state:this,p=u<n.length&&l.spec.appendTransaction.call(l,u?n.slice(u):n,f,r);if(p&&r.filterTransaction(p,o)){if(p.setMeta("appendedTransaction",e),!s){s=[];for(let m=0;m<this.config.plugins.length;m++)s.push(m<o?{state:r,n:n.length}:{state:this,n:0})}n.push(p),r=r.applyInner(p),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Do(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new sA(this)}static create(e){let n=new jh(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Do(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new jh(this.schema,e.plugins),r=n.fields,s=new Do(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new jh(e.schema,e.plugins),i=new Do(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Lr.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=it.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let u=r[l],f=u.spec.state;if(u.key==o.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=f.fromJSON.call(u,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function kE(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=kE(s,e,{})),n[r]=s}return n}class Ct{constructor(e){this.spec=e,this.props={},e.props&&kE(e.props,this,this.props),this.key=e.key?e.key.key:SE("plugin")}getState(e){return e[this.key]}}const Ih=Object.create(null);function SE(t){return t in Ih?t+"$"+ ++Ih[t]:(Ih[t]=0,t+"$")}class jt{constructor(e="key"){this.key=SE(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Og=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function EE(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const _E=(t,e,n)=>{let r=EE(t,n);if(!r)return!1;let s=Rg(r);if(!s){let o=r.blockRange(),l=o&&Ko(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(IE(t,s,e,-1))return!0;if(r.parent.content.size==0&&($o(i,"end")||Ke.isSelectable(i)))for(let o=r.depth;;o--){let l=hd(t.doc,r.before(o),r.after(o),_e.empty);if(l&&l.slice.size<l.to-l.from){if(e){let u=t.tr.step(l);u.setSelection($o(i,"end")?it.findFrom(u.doc.resolve(u.mapping.map(s.pos,-1)),-1):Ke.create(u.doc,s.pos-i.nodeSize)),e(u.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},oA=(t,e,n)=>{let r=EE(t,n);if(!r)return!1;let s=Rg(r);return s?NE(t,s,e):!1},aA=(t,e,n)=>{let r=TE(t,n);if(!r)return!1;let s=jg(r);return s?NE(t,s,e):!1};function NE(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let p=s.lastChild;if(!p)return!1;s=p}let o=e.nodeAfter,l=o,u=e.pos+1;for(;!l.isTextblock;u++){if(l.type.spec.isolating)return!1;let p=l.firstChild;if(!p)return!1;l=p}let f=hd(t.doc,i,u,_e.empty);if(!f||f.from!=i||f instanceof mn&&f.slice.size>=u-i)return!1;if(n){let p=t.tr.step(f);p.setSelection(Ge.create(p.doc,i)),n(p.scrollIntoView())}return!0}function $o(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const CE=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Rg(r)}let o=i&&i.nodeBefore;return!o||!Ke.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ke.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Rg(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function TE(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const ME=(t,e,n)=>{let r=TE(t,n);if(!r)return!1;let s=jg(r);if(!s)return!1;let i=s.nodeAfter;if(IE(t,s,e,1))return!0;if(r.parent.content.size==0&&($o(i,"start")||Ke.isSelectable(i))){let o=hd(t.doc,r.before(),r.after(),_e.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection($o(i,"start")?it.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):Ke.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},AE=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=jg(r)}let o=i&&i.nodeAfter;return!o||!Ke.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ke.create(t.doc,i.pos)).scrollIntoView()),!0)};function jg(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const lA=(t,e)=>{let n=t.selection,r=n instanceof Ke,s;if(r){if(n.node.isTextblock||!ci(t.doc,n.from))return!1;s=n.from}else if(s=fd(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(Ke.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},cA=(t,e)=>{let n=t.selection,r;if(n instanceof Ke){if(n.node.isTextblock||!ci(t.doc,n.to))return!1;r=n.to}else if(r=fd(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},uA=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Ko(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},OE=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
53
+ `).scrollIntoView()),!0)};function Ig(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const dA=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=Ig(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),u=t.tr.replaceWith(l,l,o.createAndFill());u.setSelection(it.near(u.doc.resolve(l),1)),e(u.scrollIntoView())}return!0},RE=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof lr||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Ig(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(Ge.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},jE=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(bs(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Ko(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function fA(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof Ke&&e.selection.node.isBlock)return!r.parentOffset||!bs(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,u=!1,f=!1;for(let y=r.depth;;y--)if(r.node(y).isBlock){u=r.end(y)==r.pos+(r.depth-y),f=r.start(y)==r.pos-(r.depth-y),l=Ig(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),i.unshift(u&&l?{type:l}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let p=e.tr;(e.selection instanceof Ge||e.selection instanceof lr)&&p.deleteSelection();let m=p.mapping.map(r.pos),g=bs(p.doc,m,i.length,i);if(g||(i[0]=l?{type:l}:null,g=bs(p.doc,m,i.length,i)),!g)return!1;if(p.split(m,i.length,i),!u&&f&&r.node(o).type!=l){let y=p.mapping.map(r.before(o)),b=p.doc.resolve(y);l&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,l)&&p.setNodeMarkup(p.mapping.map(r.before(o)),l)}return n&&n(p.scrollIntoView()),!0}}const hA=fA(),pA=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(Ke.create(t.doc,s))),!0)};function mA(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||ci(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function IE(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,u=s.type.spec.isolating||i.type.spec.isolating;if(!u&&mA(t,e,n))return!0;let f=!u&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let y=e.pos+i.nodeSize,b=de.empty;for(let E=o.length-1;E>=0;E--)b=de.from(o[E].create(null,b));b=de.from(s.copy(b));let k=t.tr.step(new gn(e.pos-1,y,e.pos,y,new _e(b,1,0),o.length,!0)),w=k.doc.resolve(y+2*o.length);w.nodeAfter&&w.nodeAfter.type==s.type&&ci(k.doc,w.pos)&&k.join(w.pos),n(k.scrollIntoView())}return!0}let p=i.type.spec.isolating||r>0&&u?null:it.findFrom(e,1),m=p&&p.$from.blockRange(p.$to),g=m&&Ko(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(f&&$o(i,"start",!0)&&$o(s,"end")){let y=s,b=[];for(;b.push(y),!y.isTextblock;)y=y.lastChild;let k=i,w=1;for(;!k.isTextblock;k=k.firstChild)w++;if(y.canReplace(y.childCount,y.childCount,k.content)){if(n){let E=de.empty;for(let O=b.length-1;O>=0;O--)E=de.from(b[O].copy(E));let N=t.tr.step(new gn(e.pos-b.length,e.pos+i.nodeSize,e.pos+w,e.pos+i.nodeSize-w,new _e(E,b.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}function LE(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(Ge.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const gA=LE(-1),vA=LE(1);function yA(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&Tg(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Hb(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(u,f)=>{if(s)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)s=!0;else{let p=n.doc.resolve(f),m=p.index();s=p.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:u}}=n.selection.ranges[o];i.setBlockType(l,u,t,e)}r(i.scrollIntoView())}return!0}}function Lg(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Lg(Og,_E,CE);Lg(Og,ME,AE);Lg(OE,RE,jE,hA);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function bA(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return xA(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function xA(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=o.resolve(e.start-2);i=new vu(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new vu(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Tg(i,n,r,e);return l?(t&&wA(t,e,l,s,n),!0):!1}function wA(t,e,n,r,s){let i=de.empty;for(let p=n.length-1;p>=0;p--)i=de.from(n[p].type.create(n[p].attrs,i));t.step(new gn(e.start-(r?2:0),e.end,e.start,e.end,new _e(i,0,0),n.length,!0));let o=0;for(let p=0;p<n.length;p++)n[p].type==s&&(o=p+1);let l=n.length-o,u=e.start+n.length-(r?2:0),f=e.parent;for(let p=e.startIndex,m=e.endIndex,g=!0;p<m;p++,g=!1)!g&&bs(t.doc,u,l)&&(t.split(u,l),u+=2*l),u+=f.child(p).nodeSize;return t}function kA(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?SA(e,n,t,i):EA(e,n,i):!0:!1}}function SA(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new gn(i-1,o,i,o,new _e(de.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new vu(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Ko(r);if(l==null)return!1;s.lift(r,l);let u=s.doc.resolve(s.mapping.map(i,-1)-1);return ci(s.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&s.join(u.pos),e(s.scrollIntoView()),!0}function EA(t,e,n){let r=t.tr,s=n.parent;for(let y=n.end,b=n.endIndex-1,k=n.startIndex;b>k;b--)y-=s.child(b).nodeSize,r.delete(y-1,y+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,u=n.endIndex==s.childCount,f=i.node(-1),p=i.index(-1);if(!f.canReplace(p+(l?0:1),p+1,o.content.append(u?de.empty:de.from(s))))return!1;let m=i.pos,g=m+o.nodeSize;return r.step(new gn(m-(l?1:0),g+(u?1:0),m+1,g-1,new _e((l?de.empty:de.from(s.copy(de.empty))).append(u?de.empty:de.from(s.copy(de.empty))),l?0:1,u?0:1),l?0:1)),e(r.scrollIntoView()),!0}function _A(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,f=>f.childCount>0&&f.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,u=l.child(o-1);if(u.type!=t)return!1;if(n){let f=u.lastChild&&u.lastChild.type==l.type,p=de.from(f?t.create():null),m=new _e(de.from(t.create(null,de.from(l.type.create(null,p)))),f?3:1,0),g=i.start,y=i.end;n(e.tr.step(new gn(g-(f?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Cn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Uo=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Km=null;const ms=function(t,e,n){let r=Km||(Km=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},NA=function(){Km=null},Vi=function(t,e,n,r){return n&&(Wb(t,e,n,r,-1)||Wb(t,e,n,r,1))},CA=/^(img|br|input|textarea|hr)$/i;function Wb(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:xr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||hl(t)||CA.test(t.nodeName)||t.contentEditable=="false")return!1;e=Cn(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?xr(t):0}else return!1}}function xr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function TA(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=xr(t)}else if(t.parentNode&&!hl(t))e=Cn(t),t=t.parentNode;else return null}}function MA(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!hl(t))e=Cn(t)+1,t=t.parentNode;else return null}}function AA(t,e,n){for(let r=e==0,s=e==xr(t);r||s;){if(t==n)return!0;let i=Cn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==xr(t)}}function hl(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const md=function(t){return t.focusNode&&Vi(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ii(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function OA(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function RA(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(xr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(xr(r.startContainer),r.startOffset)}}}const Qr=typeof navigator<"u"?navigator:null,qb=typeof document<"u"?document:null,ui=Qr&&Qr.userAgent||"",Gm=/Edge\/(\d+)/.exec(ui),DE=/MSIE \d/.exec(ui),Jm=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ui),er=!!(DE||Jm||Gm),ni=DE?document.documentMode:Jm?+Jm[1]:Gm?+Gm[1]:0,wr=!er&&/gecko\/(\d+)/i.test(ui);wr&&+(/Firefox\/(\d+)/.exec(ui)||[0,0])[1];const Ym=!er&&/Chrome\/(\d+)/.exec(ui),Mn=!!Ym,PE=Ym?+Ym[1]:0,Pn=!er&&!!Qr&&/Apple Computer/.test(Qr.vendor),Ho=Pn&&(/Mobile\/\w+/.test(ui)||!!Qr&&Qr.maxTouchPoints>2),br=Ho||(Qr?/Mac/.test(Qr.platform):!1),BE=Qr?/Win/.test(Qr.platform):!1,vs=/Android \d/.test(ui),pl=!!qb&&"webkitFontSmoothing"in qb.documentElement.style,jA=pl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function IA(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function us(t,e){return typeof t=="number"?t:t[e]}function LA(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Vb(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Uo(o);continue}let l=o,u=l==i.body,f=u?IA(i):LA(l),p=0,m=0;if(e.top<f.top+us(r,"top")?m=-(f.top-e.top+us(s,"top")):e.bottom>f.bottom-us(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+us(s,"top")-f.top:e.bottom-f.bottom+us(s,"bottom")),e.left<f.left+us(r,"left")?p=-(f.left-e.left+us(s,"left")):e.right>f.right-us(r,"right")&&(p=e.right-f.right+us(s,"right")),p||m)if(u)i.defaultView.scrollBy(p,m);else{let y=l.scrollLeft,b=l.scrollTop;m&&(l.scrollTop+=m),p&&(l.scrollLeft+=p);let k=l.scrollLeft-y,w=l.scrollTop-b;e={left:e.left-k,top:e.top-w,right:e.right-k,bottom:e.bottom-w}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:Uo(o)}}function DA(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let u=l.getBoundingClientRect();if(u.top>=n-20){r=l,s=u.top;break}}return{refDOM:r,refTop:s,stack:zE(t.dom)}}function zE(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Uo(r));return e}function PA({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;FE(n,r==0?0:r-e)}function FE(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let To=null;function BA(t){if(t.setActive)return t.setActive();if(To)return t.focus(To);let e=zE(t);t.focus(To==null?{get preventScroll(){return To={preventScroll:!0},!0}}:void 0),To||(To=!1,FE(e,0))}function $E(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,u,f;for(let p=t.firstChild,m=0;p;p=p.nextSibling,m++){let g;if(p.nodeType==1)g=p.getClientRects();else if(p.nodeType==3)g=ms(p).getClientRects();else continue;for(let y=0;y<g.length;y++){let b=g[y];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let k=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(k<r){n=p,r=k,s=k&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,p.nodeType==1&&k&&(i=m+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!u&&b.left<=e.left&&b.right>=e.left&&(u=p,f={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(i=m+1)}}return!n&&u&&(n=u,s=f,r=0),n&&n.nodeType==3?zA(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:$E(n,s)}function zA(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=qs(r,1);if(o.top!=o.bottom&&Dg(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Dg(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function FA(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function $A(t,e,n){let{node:r,offset:s}=$E(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function UA(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),u;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((u=l.dom.getBoundingClientRect()).width||u.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&u.left>r.left||u.top>r.top?s=l.posBefore:(!o&&u.right<r.left||u.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function UE(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let u=0;u<l.length;u++){let f=l[u];if(Dg(e,f))return UE(o,e,f)}}if((i=(i+1)%r)==s)break}return t}function HA(t,e){let n=t.dom.ownerDocument,r,s=0,i=RA(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let f=t.dom.getBoundingClientRect();if(!Dg(e,f)||(o=UE(t.dom,e,f),!o))return null}if(Pn)for(let f=o;r&&f;f=Uo(f))f.draggable&&(r=void 0);if(o=FA(o,e),r){if(wr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let p=r.childNodes[s],m;p.nodeName=="IMG"&&(m=p.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let f;pl&&s&&r.nodeType==1&&(f=r.childNodes[s-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=UA(t,r,s,e))}l==null&&(l=$A(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function Kb(t){return t.top<t.bottom||t.left<t.right}function qs(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Kb(r))return r}return Array.prototype.find.call(n,Kb)||t.getBoundingClientRect()}const WA=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function HE(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=pl||wr;if(r.nodeType==3)if(o&&(WA.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let u=qs(ms(r,s,s),n);if(wr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=qs(ms(r,s-1,s-1),-1);if(f.top==u.top){let p=qs(ms(r,s,s+1),-1);if(p.top!=u.top)return Ra(p,p.left<f.left)}}return u}else{let u=s,f=s,p=n<0?1:-1;return n<0&&!s?(f++,p=-1):n>=0&&s==r.nodeValue.length?(u--,p=1):n<0?u--:f++,Ra(qs(ms(r,u,f),p),p<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==xr(r))){let u=r.childNodes[s-1];if(u.nodeType==1)return Lh(u.getBoundingClientRect(),!1)}if(i==null&&s<xr(r)){let u=r.childNodes[s];if(u.nodeType==1)return Lh(u.getBoundingClientRect(),!0)}return Lh(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==xr(r))){let u=r.childNodes[s-1],f=u.nodeType==3?ms(u,xr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(f)return Ra(qs(f,1),!1)}if(i==null&&s<xr(r)){let u=r.childNodes[s];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let f=u?u.nodeType==3?ms(u,0,o?0:1):u.nodeType==1?u:null:null;if(f)return Ra(qs(f,-1),!0)}return Ra(qs(r.nodeType==3?ms(r):r,-n),n>=0)}function Ra(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Lh(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function WE(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function qA(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return WE(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=HE(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let u;if(l.nodeType==1)u=l.getClientRects();else if(l.nodeType==3)u=ms(l,0,l.nodeValue.length).getClientRects();else continue;for(let f=0;f<u.length;f++){let p=u[f];if(p.bottom>p.top+1&&(n=="up"?o.top-p.top>(p.bottom-o.top)*2:p.bottom-o.bottom>(o.bottom-p.top)*2))return!1}}return!0})}const VA=/[\u0590-\u08ac]/;function KA(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!VA.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:WE(t,e,()=>{let{focusNode:u,focusOffset:f,anchorNode:p,anchorOffset:m}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:k}=t.domSelectionRange(),w=b&&!y.contains(b.nodeType==1?b:b.parentNode)||u==b&&f==k;try{l.collapse(p,m),u&&(u!=p||f!=m)&&l.extend&&l.extend(u,f)}catch{}return g!=null&&(l.caretBidiLevel=g),w}):r.pos==r.start()||r.pos==r.end()}let Gb=null,Jb=null,Yb=!1;function GA(t,e,n){return Gb==e&&Jb==n?Yb:(Gb=e,Jb=n,Yb=n=="up"||n=="down"?qA(t,e,n):KA(t,e,n))}const kr=0,Qb=1,Li=2,Xr=3;class ml{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=kr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Cn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof VE){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof qE&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Cn(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Cn(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let u=this.children[l],f=o+u.size;if(s==-1&&e<=f){let p=o+u.border;if(e>=p&&n<=f-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,p);e=o;for(let m=l;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){s=Cn(g.dom)+1;break}e-=g.size}s==-1&&(s=0)}if(s>-1&&(f>n||l==this.children.length-1)){n=f;for(let p=l+1;p<this.children.length;p++){let m=this.children[p];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=Cn(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=f}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let y=0,b=0;y<this.children.length;y++){let k=this.children[y],w=b+k.size;if(i>b&&o<w)return k.setSelection(e-b-k.border,n-b-k.border,r,s);b=w}let l=this.domFromPos(e,e?-1:1),u=n==e?l:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),p=r.domSelectionRange(),m=!1;if((wr||Pn)&&e==n){let{node:y,offset:b}=l;if(y.nodeType==3){if(m=!!(b&&y.nodeValue[b-1]==`
54
+ `),m&&b==y.nodeValue.length)for(let k=y,w;k;k=k.parentNode){if(w=k.nextSibling){w.nodeName=="BR"&&(l=u={node:w.parentNode,offset:Cn(w)+1});break}let E=k.pmViewDesc;if(E&&E.node&&E.node.isBlock)break}}else{let k=y.childNodes[b-1];m=k&&(k.nodeName=="BR"||k.contentEditable=="false")}}if(wr&&p.focusNode&&p.focusNode!=u.node&&p.focusNode.nodeType==1){let y=p.focusNode.childNodes[p.focusOffset];y&&y.contentEditable=="false"&&(s=!0)}if(!(s||m&&Pn)&&Vi(l.node,l.offset,p.anchorNode,p.anchorOffset)&&Vi(u.node,u.offset,p.focusNode,p.focusOffset))return;let g=!1;if((f.extend||e==n)&&!(m&&wr)){f.collapse(l.node,l.offset);try{e!=n&&f.extend(u.node,u.offset),g=!0}catch{}}if(!g){if(e>n){let b=l;l=u,u=b}let y=document.createRange();y.setEnd(u.node,u.offset),y.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,u=o-i.border;if(e>=l&&n<=u){this.dirty=e==r||n==o?Li:Qb,e==l&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Xr:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Li:Xr}r=o}this.dirty=Li}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Li:Qb;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class qE extends ml{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==kr&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class JA extends ml{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ki extends ml{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Qi.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ki(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Xr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Xr&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=kr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=kr}}slice(e,n,r){let s=Ki.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Xm(i,n,o,r)),e>0&&(i=Xm(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ri extends ml{constructor(e,n,r,s,i,o,l,u,f){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],u,f=l&&l(n,i,()=>{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,s),p=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!p)p=document.createTextNode(n.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:m}=Qi.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),n.type.spec.draggable&&(p.draggable=!0));let g=p;return p=JE(p,r,n),f?u=new YA(e,n,r,s,p,m||null,g,f,i,o+1):n.isText?new gd(e,n,r,s,p,g,i):new ri(e,n,r,s,p,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>de.empty)}return e}matchesNode(e,n,r){return this.dirty==kr&&e.eq(this.node)&&bu(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,u=new XA(this,o&&o.node,e);tO(this.node,this.innerDeco,(f,p,m)=>{f.spec.marks?u.syncToMarks(f.spec.marks,r,e,p):f.type.side>=0&&!m&&u.syncToMarks(p==this.node.childCount?Rt.none:this.node.child(p).marks,r,e,p),u.placeWidget(f,e,s)},(f,p,m,g)=>{u.syncToMarks(f.marks,r,e,g);let y;u.findNodeMatch(f,p,m,g)||l&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(y=u.findIndexWithChild(i.node))>-1&&u.updateNodeAt(f,p,m,y,e)||u.updateNextNode(f,p,m,e,g,s)||u.addNode(f,p,m,e,s),s+=f.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Li)&&(o&&this.protectLocalComposition(e,o),KE(this.contentDOM,this.children,e),Ho&&nO(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof Ge)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=rO(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new JA(this,i,n,s);e.input.compositionNodes.push(o),this.children=Xm(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Xr||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=kr}updateOuterDeco(e){if(bu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=GE(this.dom,this.nodeDOM,Qm(this.outerDeco,this.node,n),Qm(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Xb(t,e,n,r,s){JE(r,e,t);let i=new ri(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class gd extends ri{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Xr||this.dirty!=kr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=kr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=kr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new gd(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Xr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class VE extends ml{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==kr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class YA extends ri{constructor(e,n,r,s,i,o,l,u,f,p){super(e,n,r,s,i,o,l,f,p),this.spec=u}update(e,n,r,s){if(this.dirty==Xr)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function KE(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Zb(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof Ki){let u=r?r.previousSibling:t.lastChild;KE(o.contentDOM,o.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=Zb(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const qa=function(t){t&&(this.nodeName=t)};qa.prototype=Object.create(null);const Di=[new qa];function Qm(t,e,n){if(t.length==0)return Di;let r=n?Di[0]:new qa,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new qa(o.nodeName));for(let l in o){let u=o[l];u!=null&&(n&&s.length==1&&s.push(r=new qa(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+u:l=="style"?r.style=(r.style?r.style+";":"")+u:l!="nodeName"&&(r[l]=u))}}}return s}function GE(t,e,n,r){if(n==Di&&r==Di)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let u;l&&l.nodeName==o.nodeName&&s!=t&&(u=s.parentNode)&&u.nodeName.toLowerCase()==o.nodeName||(u=document.createElement(o.nodeName),u.pmIsDeco=!0,u.appendChild(s),l=Di[0]),s=u}QA(s,l||Di[0],o)}return s}function QA(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function JE(t,e,n){return GE(t,t,Di,Qm(e,n,t.nodeType!=1))}function bu(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Zb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class XA{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ZA(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=kr,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let u=-1,f=this.top.children.length;s<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let p=this.index;p<f;p++){let m=this.top.children[p];if(m.matchesMark(e[o])&&!this.isLocked(m.dom)){u=p;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let p=Ki.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,p),this.top=p,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,u=Math.min(this.top.children.length,l+5);l<u;l++){let f=this.top.children[l];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Xr&&o.dom==o.contentDOM&&(o.dirty=Li),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let u=this.top.children[l];if(u instanceof ri){let f=this.preMatch.matched.get(u);if(f!=null&&f!=i)return!1;let p=u.dom,m,g=this.isLocked(p)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Xr&&bu(n,u.outerDeco));if(!g&&u.update(e,n,r,s))return this.destroyBetween(this.index,l),u.dom!=p&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(u,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=Li,m.updateChildren(s,o+1),m.dirty=kr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!bu(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=ri.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let u of l.children)u.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=ri.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new qE(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Ki;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof gd)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Pn||Mn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new VE(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function ZA(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let f=n.children[r-1];if(f instanceof Ki)n=f,r=f.children.length;else{l=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=l.node;if(u){if(u!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function eO(t,e){return t.type.side-e.type.side}function tO(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let f=0;f<t.childCount;f++){let p=t.child(f);r(p,s,e.forChild(i,p),f),i+=p.nodeSize}return}let o=0,l=[],u=null;for(let f=0;;){let p,m;for(;o<s.length&&s[o].to==i;){let w=s[o++];w.widget&&(p?(m||(m=[p])).push(w):p=w)}if(p)if(m){m.sort(eO);for(let w=0;w<m.length;w++)n(m[w],f,!!u)}else n(p,f,!!u);let g,y;if(u)y=-1,g=u,u=null;else if(f<t.childCount)y=f,g=t.child(f++);else break;for(let w=0;w<l.length;w++)l[w].to<=i&&l.splice(w--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let b=i+g.nodeSize;if(g.isText){let w=b;o<s.length&&s[o].from<w&&(w=s[o].from);for(let E=0;E<l.length;E++)l[E].to<w&&(w=l[E].to);w<b&&(u=g.cut(w-i),g=g.cut(0,w-i),b=w,y=-1)}else for(;o<s.length&&s[o].to<b;)o++;let k=g.isInline&&!g.isLeaf?l.filter(w=>!w.inline):l.slice();r(g,k,e.forChild(i,g),y),i=b}}function nO(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function rO(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let u=o.text;for(;s<t.childCount;){let f=t.child(s++);if(i+=f.nodeSize,!f.isText)break;u+=f.text}if(i>=n){if(i>=r&&u.slice(r-e.length-l,r-l)==e)return r-e.length;let f=l<r?u.lastIndexOf(e,r-l-1):-1;if(f>=0&&f+e.length+l>=n)return l+f;if(n==r&&u.length>=r+e.length-l&&u.slice(r-l,r-l+e.length)==e)return r}}return-1}function Xm(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],f=l,p=l+=u.size;f>=n||p<=e?i.push(u):(f<e&&i.push(u.slice(0,e-f,r)),s&&(i.push(s),s=void 0),p>n&&i.push(u.slice(n-f,u.size,r)))}return i}function Pg(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),u,f;if(md(n)){for(u=o;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&Ke.isSelectable(m)&&s.parent&&!(m.isInline&&AA(n.focusNode,n.focusOffset,s.dom))){let g=s.posBefore;f=new Ke(o==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y<n.rangeCount;y++){let b=n.getRangeAt(y);m=Math.min(m,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(m<0)return null;[u,o]=g==t.state.selection.anchor?[g,m]:[m,g],l=r.resolve(o)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let p=r.resolve(u);if(!f){let m=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;f=Bg(t,p,l,m)}return f}function YE(t){return t.editable?t.hasFocus():XE(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function xs(t,e=!1){let n=t.state.selection;if(QE(t,n),!!YE(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Mn){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Vi(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)iO(t);else{let{anchor:r,head:s}=n,i,o;ex&&!(n instanceof Ge)&&(n.$from.parent.inlineContent||(i=tx(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=tx(t,n.to))),t.docView.setSelection(r,s,t,e),ex&&(i&&nx(i),o&&nx(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&sO(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const ex=Pn||Mn&&PE<63;function tx(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Pn&&s&&s.contentEditable=="false")return Dh(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Dh(s);if(i)return Dh(i)}}function Dh(t){return t.contentEditable="true",Pn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function nx(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function sO(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!YE(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function iO(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Cn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&er&&ni<=11&&(n.disabled=!0,n.disabled=!1)}function QE(t,e){if(e instanceof Ke){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(rx(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else rx(t)}function rx(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Bg(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Ge.between(e,n,r)}function sx(t){return t.editable&&!t.hasFocus()?!1:XE(t)}function XE(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function oO(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Vi(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Zm(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&it.findFrom(i,e)}function Vs(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ix(t,e,n){let r=t.state.selection;if(r instanceof Ge)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Vs(t,new Ge(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Zm(t.state,e);return s&&s instanceof Ke?Vs(t,s):!1}else if(!(br&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Ke.isSelectable(i)?Vs(t,new Ke(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):pl?Vs(t,new Ge(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ke&&r.node.isInline)return Vs(t,new Ge(e>0?r.$to:r.$from));{let s=Zm(t.state,e);return s?Vs(t,s):!1}}}function xu(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Va(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Mo(t,e){return e<0?aO(t):lO(t)}function aO(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(wr&&n.nodeType==1&&r<xu(n)&&Va(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Va(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ZE(n))break;{let l=n.previousSibling;for(;l&&Va(l,-1);)s=n.parentNode,i=Cn(l),l=l.previousSibling;if(l)n=l,r=xu(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?eg(t,n,r):s&&eg(t,s,i)}function lO(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=xu(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Va(l,1))i=n,o=++r;else break}else{if(ZE(n))break;{let l=n.nextSibling;for(;l&&Va(l,1);)i=l.parentNode,o=Cn(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=xu(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&eg(t,i,o)}function ZE(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function cO(t,e){for(;t&&e==t.childNodes.length&&!hl(t);)e=Cn(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function uO(t,e){for(;t&&!e&&!hl(t);)e=Cn(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function eg(t,e,n){if(e.nodeType!=3){let i,o;(o=cO(e,n))?(e=o,n=0):(i=uO(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(md(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&xs(t)},50)}function ox(t,e){let n=t.state.doc.resolve(e);if(!(Mn||BE)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function ax(t,e,n){let r=t.state.selection;if(r instanceof Ge&&!r.empty||n.indexOf("s")>-1||br&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Zm(t.state,e);if(o&&o instanceof Ke)return Vs(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof lr?it.near(o,e):it.findFrom(o,e);return l?Vs(t,l):!1}return!1}function lx(t,e){if(!(t.state.selection instanceof Ge))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function cx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function dO(t){if(!Pn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;cx(t,r,"true"),setTimeout(()=>cx(t,r,"false"),20)}return!1}function fO(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function hO(t,e){let n=e.keyCode,r=fO(e);if(n==8||br&&n==72&&r=="c")return lx(t,-1)||Mo(t,-1);if(n==46&&!e.shiftKey||br&&n==68&&r=="c")return lx(t,1)||Mo(t,1);if(n==13||n==27)return!0;if(n==37||br&&n==66&&r=="c"){let s=n==37?ox(t,t.state.selection.from)=="ltr"?-1:1:-1;return ix(t,s,r)||Mo(t,s)}else if(n==39||br&&n==70&&r=="c"){let s=n==39?ox(t,t.state.selection.from)=="ltr"?1:-1:1;return ix(t,s,r)||Mo(t,s)}else{if(n==38||br&&n==80&&r=="c")return ax(t,-1,r)||Mo(t,-1);if(n==40||br&&n==78&&r=="c")return dO(t)||ax(t,1,r)||Mo(t,1);if(r==(br?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function zg(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||Qi.fromSchema(t.state.schema),l=i_(),u=l.createElement("div");u.appendChild(o.serializeFragment(r,{document:l}));let f=u.firstChild,p,m=0;for(;f&&f.nodeType==1&&(p=s_[f.nodeName.toLowerCase()]);){for(let y=p.length-1;y>=0;y--){let b=l.createElement(p[y]);for(;u.firstChild;)b.appendChild(u.firstChild);u.appendChild(b),m++}f=u.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${s} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",y=>y(e,t))||e.content.textBetween(0,e.content.size,`
55
+
56
+ `);return{dom:u,text:g,slice:e}}function e_(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,i||r,t)}),i)return l=new _e(de.from(t.state.schema.text(e.replace(/\r\n?/g,`
57
+ `))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let m=t.someProp("clipboardTextParser",g=>g(e,s,r,t));if(m)l=m;else{let g=s.marks(),{schema:y}=t.state,b=Qi.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(k=>{let w=o.appendChild(document.createElement("p"));k&&w.appendChild(b.serializeNode(y.text(k,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=vO(n),pl&&yO(o);let f=o&&o.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let m=+p[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||ti.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||p),context:s,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!pO.test(g.parentNode.nodeName)?{ignore:!0}:null}})),p)l=bO(ux(l,+p[1],+p[2]),p[4]);else if(l=_e.maxOpen(mO(l.content,s),!0),l.openStart||l.openEnd){let m=0,g=0;for(let y=l.content.firstChild;m<l.openStart&&!y.type.spec.isolating;m++,y=y.firstChild);for(let y=l.content.lastChild;g<l.openEnd&&!y.type.spec.isolating;g++,y=y.lastChild);l=ux(l,m,g)}return t.someProp("transformPasted",m=>{l=m(l,t,u)}),l}const pO=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function mO(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let u=s.findWrapping(l.type),f;if(!u)return o=null;if(f=o.length&&i.length&&n_(u,i,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=r_(o[o.length-1],i.length));let p=t_(l,u);o.push(p),s=s.matchType(p.type),i=u}}),o)return de.from(o)}return t}function t_(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,de.from(t));return t}function n_(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=n_(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(de.from(t_(n,t,s+1))))}}function r_(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,r_(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(de.empty,!0);return t.copy(n.append(r))}function tg(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=tg(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(de.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function ux(t,e,n){return e<t.openStart&&(t=new _e(tg(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new _e(tg(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const s_={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let dx=null;function i_(){return dx||(dx=document.implementation.createHTMLDocument("title"))}let Ph=null;function gO(t){let e=window.trustedTypes;return e?(Ph||(Ph=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ph.createHTML(t)):t}function vO(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=i_().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&s_[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=gO(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function yO(t){let e=t.querySelectorAll(Mn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function bO(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let u=n.nodes[r[l]];if(!u||u.hasRequiredAttrs())break;s=de.from(u.create(r[l+1],s)),i++,o++}return new _e(s,i,o)}const qn={},Vn={},xO={touchstart:!0,touchmove:!0};class wO{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function kO(t){for(let e in qn){let n=qn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{EO(t,r)&&!Fg(t,r)&&(t.editable||!(r.type in Vn))&&n(t,r)},xO[e]?{passive:!0}:void 0)}Pn&&t.dom.addEventListener("input",()=>null),ng(t)}function ei(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function SO(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function ng(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Fg(t,r))})}function Fg(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function EO(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function _O(t,e){!Fg(t,e)&&qn[e.type]&&(t.editable||!(e.type in Vn))&&qn[e.type](t,e)}Vn.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!a_(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(vs&&Mn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ho&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Ii(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||hO(t,n)?n.preventDefault():ei(t,"key")};Vn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Vn.keypress=(t,e)=>{let n=e;if(a_(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||br&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Ge)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function vd(t){return{left:t.clientX,top:t.clientY}}function NO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function $g(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Bo(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function CO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ke.isSelectable(r)?(Bo(t,new Ke(n)),!0):!1}function TO(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Ke&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(Ke.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(Bo(t,Ke.create(t.state.doc,s)),!0):!1}function MO(t,e,n,r,s){return $g(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?TO(t,n):CO(t,n))}function AO(t,e,n,r){return $g(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function OO(t,e,n,r){return $g(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||RO(t,n,r)}function RO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Bo(t,Ge.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Bo(t,Ge.create(r,l+1,l+1+o.content.size));else if(Ke.isSelectable(o))Bo(t,Ke.create(r,l));else continue;return!0}}function Ug(t){return wu(t)}const o_=br?"metaKey":"ctrlKey";qn.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Ug(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&NO(n,t.input.lastClick)&&!n[o_]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(vd(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new jO(t,o,n,!!r)):(i=="doubleClick"?AO:OO)(t,o.pos,o.inside,n)?n.preventDefault():ei(t,"pointer"))};class jO{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[o_],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let p=e.state.doc.resolve(n.pos);i=p.parent,o=p.depth?p.before():0}const l=s?null:r.target,u=l?e.docView.nearestDesc(l,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||f instanceof Ke&&f.from<=o&&f.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&wr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),ei(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>xs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(vd(e))),this.updateAllowDefault(e),this.allowDefault||!n?ei(this.view,"pointer"):MO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Pn&&this.mightDrag&&!this.mightDrag.node.isAtom||Mn&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Bo(this.view,it.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ei(this.view,"pointer")}move(e){this.updateAllowDefault(e),ei(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}qn.touchstart=t=>{t.input.lastTouch=Date.now(),Ug(t),ei(t,"pointer")};qn.touchmove=t=>{t.input.lastTouch=Date.now(),ei(t,"pointer")};qn.contextmenu=t=>Ug(t);function a_(t,e){return t.composing?!0:Pn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const IO=vs?5e3:-1;Vn.compositionstart=Vn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Ge&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Mn&&BE&&LO(t)))t.markCursor=t.state.storedMarks||n.marks(),wu(t,!0),t.markCursor=null;else if(wu(t,!e.selection.empty),wr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}l_(t,IO)};function LO(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Vn.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,l_(t,20))};function l_(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>wu(t),e))}function c_(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=PO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function DO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=TA(e.focusNode,e.focusOffset),r=MA(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function PO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function wu(t,e=!1){if(!(vs&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),c_(t),e||t.docView&&t.docView.dirty){let n=Pg(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function BO(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const rl=er&&ni<15||Ho&&jA<604;qn.copy=Vn.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=rl?null:n.clipboardData,o=r.content(),{dom:l,text:u}=zg(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",u)):BO(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function zO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function FO(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?sl(t,r.value,null,s,e):sl(t,r.textContent,r.innerHTML,s,e)},50)}function sl(t,e,n,r,s){let i=e_(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,s,i||_e.empty)))return!0;if(!i)return!1;let o=zO(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function u_(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Vn.paste=(t,e)=>{let n=e;if(t.composing&&!vs)return;let r=rl?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&sl(t,u_(r),r.getData("text/html"),s,n)?n.preventDefault():FO(t,n)};class d_{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const $O=br?"altKey":"ctrlKey";function f_(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[$O]}qn.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(vd(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Ke?s.to-1:s.to))){if(r&&r.mightDrag)o=Ke.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=Ke.create(t.state.doc,m.posBefore))}}let l=(o||t.state.selection).content(),{dom:u,text:f,slice:p}=zg(t,l);(!n.dataTransfer.files.length||!Mn||PE>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(rl?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",rl||n.dataTransfer.setData("text/plain",f),t.dragging=new d_(p,f_(t,n),o)};qn.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Vn.dragover=Vn.dragenter=(t,e)=>e.preventDefault();Vn.drop=(t,e)=>{try{UO(t,e,t.dragging)}finally{t.dragging=null}};function UO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(vd(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=e_(t,u_(e.dataTransfer),rl?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&f_(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||_e.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?gE(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let u=t.state.tr;if(o){let{node:y}=n;y?y.replace(u):u.deleteSelection()}let f=u.mapping.map(l),p=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(p?u.replaceRangeWith(f,f,i.content.firstChild):u.replaceRange(f,f,i),u.doc.eq(m))return;let g=u.doc.resolve(f);if(p&&Ke.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new Ke(g));else{let y=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((b,k,w,E)=>y=E),u.setSelection(Bg(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}qn.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&xs(t)},20))};qn.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};qn.beforeinput=(t,e)=>{if(Mn&&vs&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Ii(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Vn)qn[t]=Vn[t];function il(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class ku{constructor(e,n){this.toDOM=e,this.spec=n||$i,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Dt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ku&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&il(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class si{constructor(e,n){this.attrs=e,this.spec=n||$i}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Dt(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof si&&il(this.attrs,e.attrs)&&il(this.spec,e.spec)}static is(e){return e.type instanceof si}destroy(){}}class Hg{constructor(e,n){this.attrs=e,this.spec=n||$i}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Dt(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof Hg&&il(this.attrs,e.attrs)&&il(this.spec,e.spec)}destroy(){}}class Dt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Dt(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Dt(e,e,new ku(n,r))}static inline(e,n,r,s){return new Dt(e,n,new si(r,s))}static node(e,n,r,s){return new Dt(e,n,new Hg(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof si}get widget(){return this.type instanceof ku}}const Ro=[],$i={};class St{constructor(e,n){this.local=e.length?e:Ro,this.children=n.length?n:Ro}static create(e,n){return n.length?Su(n,e,0,$i):Dn}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==Dn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||$i)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let u=this.local[l].map(e,r,s);u&&u.type.valid(n,u)?(o||(o=[])).push(u):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?HO(this.children,o||[],e,n,r,s,i):o?new St(o.sort(Ui),Ro):Dn}add(e,n){return n.length?this==Dn?St.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,u)=>{let f=u+r,p;if(p=p_(n,l,f)){for(s||(s=this.children.slice());i<s.length&&s[i]<u;)i+=3;s[i]==u?s[i+2]=s[i+2].addInner(l,p,f+1):s.splice(i,0,u,u+l.nodeSize,Su(p,l,f+1,$i)),i+=3}});let o=h_(i?m_(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new St(o.length?this.local.concat(o).sort(Ui):this.local,s||this.children)}remove(e){return e.length==0||this==Dn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,u=r[i+1]+n;for(let p=0,m;p<e.length;p++)(m=e[p])&&m.from>l&&m.to<u&&(e[p]=null,(o||(o=[])).push(m));if(!o)continue;r==this.children&&(r=this.children.slice());let f=r[i+2].removeInner(o,l+1);f!=Dn?r[i+2]=f:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new St(s,r):Dn}forChild(e,n){if(this==Dn)return this;if(n.isLeaf)return St.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let u=this.local[l];if(u.from<o&&u.to>i&&u.type instanceof si){let f=Math.max(i,u.from)-i,p=Math.min(o,u.to)-i;f<p&&(s||(s=[])).push(u.copy(f,p))}}if(s){let l=new St(s.sort(Ui),Ro);return r?new Js([l,r]):l}return r||Dn}eq(e){if(this==e)return!0;if(!(e instanceof St)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Wg(this.localsInner(e))}localsInner(e){if(this==Dn)return Ro;if(e.inlineContent||!this.local.some(si.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof si||n.push(this.local[r]);return n}forEachSet(e){e(this)}}St.empty=new St([],[]);St.removeOverlap=Wg;const Dn=St.empty;class Js{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,$i));return Js.from(r)}forChild(e,n){if(n.isLeaf)return St.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Dn&&(i instanceof Js?r=r.concat(i.members):r.push(i))}return Js.from(r)}eq(e){if(!(e instanceof Js)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Wg(r?n:n.sort(Ui)):Ro}static from(e){switch(e.length){case 0:return Dn;case 1:return e[0];default:return new Js(e.every(n=>n instanceof St)?e:e.reduce((n,r)=>n.concat(r instanceof St?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function HO(t,e,n,r,s,i,o){let l=t.slice();for(let f=0,p=i;f<n.maps.length;f++){let m=0;n.maps[f].forEach((g,y,b,k)=>{let w=k-b-(y-g);for(let E=0;E<l.length;E+=3){let N=l[E+1];if(N<0||g>N+p-m)continue;let O=l[E]+p-m;y>=O?l[E+1]=g<=O?-2:-1:g>=p&&w&&(l[E]+=w,l[E+1]+=w)}m+=w}),p=n.maps[f].map(p,-1)}let u=!1;for(let f=0;f<l.length;f+=3)if(l[f+1]<0){if(l[f+1]==-2){u=!0,l[f+1]=-1;continue}let p=n.map(t[f]+i),m=p-s;if(m<0||m>=r.content.size){u=!0;continue}let g=n.map(t[f+1]+i,-1),y=g-s,{index:b,offset:k}=r.content.findIndex(m),w=r.maybeChild(b);if(w&&k==m&&k+w.nodeSize==y){let E=l[f+2].mapInner(n,w,p+1,t[f]+i+1,o);E!=Dn?(l[f]=m,l[f+1]=y,l[f+2]=E):(l[f+1]=-2,u=!0)}else u=!0}if(u){let f=WO(l,t,e,n,s,i,o),p=Su(f,r,0,o);e=p.local;for(let m=0;m<l.length;m+=3)l[m+1]<0&&(l.splice(m,3),m-=3);for(let m=0,g=0;m<p.children.length;m+=3){let y=p.children[m];for(;g<l.length&&l[g]<y;)g+=3;l.splice(g,0,p.children[m],p.children[m+1],p.children[m+2])}}return new St(e.sort(Ui),l)}function h_(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Dt(s.from+e,s.to+e,s.type))}return n}function WO(t,e,n,r,s,i,o){function l(u,f){for(let p=0;p<u.local.length;p++){let m=u.local[p].map(r,s,f);m?n.push(m):o.onRemove&&o.onRemove(u.local[p].spec)}for(let p=0;p<u.children.length;p+=3)l(u.children[p+2],u.children[p]+f+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&l(t[u+2],e[u]+i+1);return n}function p_(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function m_(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Su(t,e,n,r){let s=[],i=!1;e.forEach((l,u)=>{let f=p_(t,l,u+n);if(f){i=!0;let p=Su(f,l,n+u+1,r);p!=Dn&&s.push(u,u+l.nodeSize,p)}});let o=h_(i?m_(t):t,-n).sort(Ui);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new St(o,s):Dn}function Ui(t,e){return t.from-e.from||t.to-e.to}function Wg(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),fx(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),fx(e,s,r.copy(i.from,r.to)));break}}}return e}function fx(t,e,n){for(;e<t.length&&Ui(n,t[e])>0;)e++;t.splice(e,0,n)}function Bh(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Dn&&e.push(r)}),t.cursorWrapper&&e.push(St.create(t.state.doc,[t.cursorWrapper.deco])),Js.from(e)}const qO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},VO=er&&ni<=11;class KO{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class GO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new KO,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);er&&ni<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Pn&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),VO&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,qO)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(sx(this.view)){if(this.suppressingSelectionUpdates)return xs(this.view);if(er&&ni<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Uo(i))n.add(i);for(let i=e.anchorNode;i;i=Uo(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sx(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,u=[];if(e.editable)for(let p=0;p<n.length;p++){let m=this.registerMutation(n[p],u);m&&(i=i<0?m.from:Math.min(m.from,i),o=o<0?m.to:Math.max(m.to,o),m.typeOver&&(l=!0))}if(u.some(p=>p.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let p of u)if(p.nodeName=="BR"&&p.parentNode){let m=p.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&p.parentNode.removeChild(p)}}else if(wr&&u.length){let p=u.filter(m=>m.nodeName=="BR");if(p.length==2){let[m,g]=p;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of p){let y=g.parentNode;y&&y.nodeName=="LI"&&(!m||QO(e,m)!=y)&&g.remove()}}}let f=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&md(r)&&(f=Pg(e))&&f.eq(it.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,xs(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),JO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,XO(e,u)),this.handleDOMChange(i,o,l,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||xs(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let p=0;p<e.addedNodes.length;p++){let m=e.addedNodes[p];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(er&&ni<=11&&e.addedNodes.length)for(let p=0;p<e.addedNodes.length;p++){let{previousSibling:m,nextSibling:g}=e.addedNodes[p];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(i=g)}let o=s&&s.parentNode==e.target?Cn(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),u=i&&i.parentNode==e.target?Cn(i):e.target.childNodes.length,f=r.localPosFromDOM(e.target,u,1);return{from:l,to:f}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let hx=new WeakMap,px=!1;function JO(t){if(!hx.has(t)&&(hx.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=wr,px)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),px=!0}}function mx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Vi(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function YO(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return mx(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?mx(t,n):null}function QO(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function XO(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let u=l.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;l=u}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function ZO(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),u=t.domSelectionRange(),f,p=u.anchorNode;if(p&&t.dom.contains(p.nodeType==1?p:p.parentNode)&&(f=[{node:p,offset:u.anchorOffset}],md(u)||f.push({node:u.focusNode,offset:u.focusOffset})),Mn&&t.input.lastKeyCode===8)for(let w=i;w>s;w--){let E=r.childNodes[w-1],N=E.pmViewDesc;if(E.nodeName=="BR"&&!N){i=w;break}if(!N||N.size)break}let m=t.state.doc,g=t.someProp("domParser")||ti.fromSchema(t.state.schema),y=m.resolve(o),b=null,k=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:s,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:eR,context:y});if(f&&f[0].pos!=null){let w=f[0].pos,E=f[1]&&f[1].pos;E==null&&(E=w),b={anchor:w+o,head:E+o}}return{doc:k,sel:b,from:o,to:l}}function eR(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Pn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Pn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const tR=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function nR(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let L=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,D=Pg(t,L);if(D&&!t.state.selection.eq(D)){if(Mn&&vs&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",F=>F(t,Ii(13,"Enter"))))return;let z=t.state.tr.setSelection(D);L=="pointer"?z.setMeta("pointer",!0):L=="key"&&z.scrollIntoView(),i&&z.setMeta("composition",i),t.dispatch(z)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let u=t.state.selection,f=ZO(t,e,n),p=t.state.doc,m=p.slice(f.from,f.to),g,y;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,y="end"):(g=t.state.selection.from,y="start"),t.input.lastKeyCode=null;let b=iR(m.content,f.doc.content,f.from,g,y);if(b&&t.input.domChangeCount++,(Ho&&t.input.lastIOSEnter>Date.now()-225||vs)&&s.some(L=>L.nodeType==1&&!tR.test(L.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",L=>L(t,Ii(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&u instanceof Ge&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))b={start:u.from,endA:u.to,endB:u.to};else{if(f.sel){let L=gx(t,t.state.doc,f.sel);if(L&&!L.eq(t.state.selection)){let D=t.state.tr.setSelection(L);i&&D.setMeta("composition",i),t.dispatch(D)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof Ge&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),er&&ni<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>f.from&&f.doc.textBetween(b.start-f.from-1,b.start-f.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let k=f.doc.resolveNoCache(b.start-f.from),w=f.doc.resolveNoCache(b.endB-f.from),E=p.resolve(b.start),N=k.sameParent(w)&&k.parent.inlineContent&&E.end()>=b.endA;if((Ho&&t.input.lastIOSEnter>Date.now()-225&&(!N||s.some(L=>L.nodeName=="DIV"||L.nodeName=="P"))||!N&&k.pos<f.doc.content.size&&(!k.sameParent(w)||!k.parent.inlineContent)&&k.pos<w.pos&&!/\S/.test(f.doc.textBetween(k.pos,w.pos,"","")))&&t.someProp("handleKeyDown",L=>L(t,Ii(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&sR(p,b.start,b.endA,k,w)&&t.someProp("handleKeyDown",L=>L(t,Ii(8,"Backspace")))){vs&&Mn&&t.domObserver.suppressSelectionUpdates();return}Mn&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),vs&&!N&&k.start()!=w.start()&&w.parentOffset==0&&k.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==b.endA&&(b.endB-=2,w=f.doc.resolveNoCache(b.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(L){return L(t,Ii(13,"Enter"))})},20));let O=b.start,T=b.endA,C=L=>{let D=L||t.state.tr.replace(O,T,f.doc.slice(b.start-f.from,b.endB-f.from));if(f.sel){let z=gx(t,D.doc,f.sel);z&&!(Mn&&t.composing&&z.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(z.head==O||z.head==D.mapping.map(T)-1)||er&&z.empty&&z.head==O)&&D.setSelection(z)}return i&&D.setMeta("composition",i),D.scrollIntoView()},R;if(N)if(k.pos==w.pos){er&&ni<=11&&k.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>xs(t),20));let L=C(t.state.tr.delete(O,T)),D=p.resolve(b.start).marksAcross(p.resolve(b.endA));D&&L.ensureMarks(D),t.dispatch(L)}else if(b.endA==b.endB&&(R=rR(k.parent.content.cut(k.parentOffset,w.parentOffset),E.parent.content.cut(E.parentOffset,b.endA-E.start())))){let L=C(t.state.tr);R.type=="add"?L.addMark(O,T,R.mark):L.removeMark(O,T,R.mark),t.dispatch(L)}else if(k.parent.child(k.index()).isText&&k.index()==w.index()-(w.textOffset?0:1)){let L=k.parent.textBetween(k.parentOffset,w.parentOffset),D=()=>C(t.state.tr.insertText(L,O,T));t.someProp("handleTextInput",z=>z(t,O,T,L,D))||t.dispatch(D())}else t.dispatch(C());else t.dispatch(C())}function gx(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Bg(t,e.resolve(n.anchor),e.resolve(n.head))}function rR(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,u;for(let p=0;p<r.length;p++)s=r[p].removeFromSet(s);for(let p=0;p<n.length;p++)i=n[p].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",u=p=>p.mark(l.addToSet(p.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",u=p=>p.mark(l.removeFromSet(p.marks));else return null;let f=[];for(let p=0;p<e.childCount;p++)f.push(u(e.child(p)));if(de.from(f).eq(t))return{mark:l,type:o}}function sR(t,e,n,r,s){if(n-e<=s.pos-r.pos||zh(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(zh(i,!0,!0));return!o.parent.isTextblock||o.pos>n||zh(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function zh(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function iR(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let u=Math.max(0,i-Math.min(o,l));r-=o+u-i}if(o<i&&t.size<e.size){let u=r<=i&&r>=o?i-r:0;i-=u,i&&i<e.size&&vx(e.textBetween(i-1,i+1))&&(i+=u?1:-1),l=i+(l-o),o=i}else if(l<i){let u=r<=i&&r>=l?i-r:0;i-=u,i&&i<t.size&&vx(t.textBetween(i-1,i+1))&&(i+=u?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function vx(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class g_{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new wO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(kx),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=xx(this),bx(this),this.nodeViews=wx(this),this.docView=Xb(this.state.doc,yx(this),Bh(this),this.dom,this),this.domObserver=new GO(this,(r,s,i,o)=>nR(this,r,s,i,o)),this.domObserver.start(),kO(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ng(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(kx),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(c_(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=wx(this);aR(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ng(this),this.editable=xx(this),bx(this);let u=Bh(this),f=yx(this),p=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,f,u);(m||!e.selection.eq(s.selection))&&(o=!0);let g=p=="preserve"&&o&&this.dom.style.overflowAnchor==null&&DA(this);if(o){this.domObserver.stop();let y=m&&(er||Mn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&oR(s.selection,e.selection);if(m){let b=Mn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=DO(this)),(i||!this.docView.update(e.doc,f,u,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Xb(e.doc,f,u,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&oO(this))?xs(this,y):(QE(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():g&&PA(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Ke){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Vb(this,n.getBoundingClientRect(),e)}else Vb(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new d_(e.slice,e.move,s<0?void 0:Ke.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(er){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&BA(this.dom),xs(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return HA(this,e)}coordsAtPos(e,n=1){return HE(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return GA(this,n||this.state,e)}pasteHTML(e,n){return sl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return sl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return zg(this,e)}destroy(){this.docView&&(SO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bh(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,NA())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return _O(this,e)}domSelectionRange(){let e=this.domSelection();return e?Pn&&this.root.nodeType===11&&OA(this.dom.ownerDocument)==this.dom&&YO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}g_.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function yx(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Dt.node(0,t.state.doc.content.size,e)]}function bx(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Dt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function xx(t){return!t.someProp("editable",e=>e(t.state)===!1)}function oR(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function wx(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function aR(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function kx(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var oi={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Eu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},lR=typeof navigator<"u"&&/Mac/.test(navigator.platform),cR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Tn=0;Tn<10;Tn++)oi[48+Tn]=oi[96+Tn]=String(Tn);for(var Tn=1;Tn<=24;Tn++)oi[Tn+111]="F"+Tn;for(var Tn=65;Tn<=90;Tn++)oi[Tn]=String.fromCharCode(Tn+32),Eu[Tn]=String.fromCharCode(Tn);for(var Fh in oi)Eu.hasOwnProperty(Fh)||(Eu[Fh]=oi[Fh]);function uR(t){var e=lR&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||cR&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Eu:oi)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const dR=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fR=typeof navigator<"u"&&/Win/.test(navigator.platform);function hR(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let u=e[l];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))dR?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function pR(t){let e=Object.create(null);for(let n in t)e[hR(n)]=t[n];return e}function $h(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function mR(t){return new Ct({props:{handleKeyDown:qg(t)}})}function qg(t){let e=pR(t);return function(n,r){let s=uR(r),i,o=e[$h(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[$h(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fR&&r.ctrlKey&&r.altKey)&&(i=oi[r.keyCode])&&i!=s){let l=e[$h(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var gR=Object.defineProperty,Vg=(t,e)=>{for(var n in e)gR(t,n,{get:e[n],enumerable:!0})};function yd(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var bd=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...f)=>{const p=l(...f)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,u=t||s.tr,f=()=>(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),o.every(m=>m===!0)),p={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...b)=>{const k=this.buildProps(u,e),w=g(...b)(k);return o.push(w),p}])),run:f};return p}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,u])=>[l,(...f)=>u(...f)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:yd({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,u])=>[l,(...f)=>u(...f)(o)]))}};return o}},v_={};Vg(v_,{blur:()=>vR,clearContent:()=>yR,clearNodes:()=>bR,command:()=>xR,createParagraphNear:()=>wR,cut:()=>kR,deleteCurrentNode:()=>SR,deleteNode:()=>ER,deleteRange:()=>_R,deleteSelection:()=>NR,enter:()=>CR,exitCode:()=>TR,extendMarkRange:()=>MR,first:()=>AR,focus:()=>RR,forEach:()=>jR,insertContent:()=>IR,insertContentAt:()=>PR,joinBackward:()=>FR,joinDown:()=>zR,joinForward:()=>$R,joinItemBackward:()=>UR,joinItemForward:()=>HR,joinTextblockBackward:()=>WR,joinTextblockForward:()=>qR,joinUp:()=>BR,keyboardShortcut:()=>KR,lift:()=>GR,liftEmptyBlock:()=>JR,liftListItem:()=>YR,newlineInCode:()=>QR,resetAttributes:()=>XR,scrollIntoView:()=>ZR,selectAll:()=>ej,selectNodeBackward:()=>tj,selectNodeForward:()=>nj,selectParentNode:()=>rj,selectTextblockEnd:()=>sj,selectTextblockStart:()=>ij,setContent:()=>oj,setMark:()=>Ej,setMeta:()=>_j,setNode:()=>Nj,setNodeSelection:()=>Cj,setTextDirection:()=>Tj,setTextSelection:()=>Mj,sinkListItem:()=>Aj,splitBlock:()=>Oj,splitListItem:()=>Rj,toggleList:()=>jj,toggleMark:()=>Ij,toggleNode:()=>Lj,toggleWrap:()=>Dj,undoInputRule:()=>Pj,unsetAllMarks:()=>Bj,unsetMark:()=>zj,unsetTextDirection:()=>Fj,updateAttributes:()=>$j,wrapIn:()=>Uj,wrapInList:()=>Hj});var vR=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),yR=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),bR=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,u)=>{if(l.type.isText)return;const{doc:f,mapping:p}=e,m=f.resolve(p.map(u)),g=f.resolve(p.map(u+l.nodeSize)),y=m.blockRange(g);if(!y)return;const b=Ko(y);if(l.type.isTextblock){const{defaultType:k}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,k)}(b||b===0)&&e.lift(y,b)})}),!0},xR=t=>e=>t(e),wR=()=>({state:t,dispatch:e})=>RE(t,e),kR=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new Ge(r.doc.resolve(Math.max(o-1,0)))),!0},SR=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),u=s.after(i);t.delete(l,u).scrollIntoView()}return!0}return!1};function an(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ER=t=>({tr:e,state:n,dispatch:r})=>{const s=an(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const u=i.before(o),f=i.after(o);e.delete(u,f).scrollIntoView()}return!0}return!1},_R=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},NR=()=>({state:t,dispatch:e})=>Og(t,e),CR=()=>({commands:t})=>t.keyboardShortcut("Enter"),TR=()=>({state:t,dispatch:e})=>dA(t,e);function Kg(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function _u(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Kg(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function y_(t,e,n={}){return t.find(r=>r.type===e&&_u(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Sx(t,e,n={}){return!!y_(t,e,n)}function Gg(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(p=>p.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(p=>p.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!y_([...s.node.marks],e,n)))return;let o=s.index,l=t.start()+s.offset,u=o+1,f=l+s.node.nodeSize;for(;o>0&&Sx([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;u<t.parent.childCount&&Sx([...t.parent.child(u).marks],e,n);)f+=t.parent.child(u).nodeSize,u+=1;return{from:l,to:f}}function ws(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var MR=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=ws(t,r.schema),{doc:o,selection:l}=n,{$from:u,from:f,to:p}=l;if(s){const m=Gg(u,i,e);if(m&&m.from<=f&&m.to>=p){const g=Ge.create(o,m.from,m.to);n.setSelection(g)}}return!0},AR=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function b_(t){return t instanceof Ge}function Pi(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function x_(t,e=null){if(!e)return null;const n=it.atStart(t),r=it.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?Ge.create(t,Pi(0,s,i),Pi(t.content.size,s,i)):Ge.create(t,Pi(e,s,i),Pi(e,s,i))}function Ex(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Nu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function OR(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var RR=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Nu()||Ex())&&r.dom.focus(),OR()&&!Nu()&&!Ex()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!b_(n.state.selection))return o(),!0;const l=x_(s.doc,t)||n.state.selection,u=n.state.selection.eq(l);return i&&(u||s.setSelection(l),u&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},jR=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),IR=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),w_=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&w_(r)}return t};function Ic(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return w_(n)}function ol(t,e,n){if(t instanceof Lr||t instanceof de)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return de.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),ol("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const u=new iE({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:f=>(o=!0,l=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?ti.fromSchema(u).parseSlice(Ic(t),n.parseOptions):ti.fromSchema(u).parse(Ic(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=ti.fromSchema(e);return n.slice?i.parseSlice(Ic(t),n.parseOptions).content:i.parse(Ic(t),n.parseOptions)}return ol("",e,n)}function LR(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof mn||s instanceof gn))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,u,f,p)=>{o===0&&(o=p)}),t.setSelection(it.near(t.doc.resolve(o),n))}var DR=t=>!("type"in t),PR=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const u=w=>{i.emit("contentError",{editor:i,error:w,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{ol(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(w){u(w)}try{l=ol(e,i.schema,{parseOptions:f,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(w){return u(w),!1}let{from:p,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((DR(l)?l:[l]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,y=y?w.isBlock:!1}),p===m&&y){const{parent:w}=r.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,m+=1)}let k;if(g){if(Array.isArray(e))k=e.map(w=>w.text||"").join("");else if(e instanceof de){let w="";e.forEach(E=>{E.text&&(w+=E.text)}),k=w}else typeof e=="object"&&e&&e.text?k=e.text:k=e;r.insertText(k,p,m)}else{k=l;const w=r.doc.resolve(p),E=w.node(),N=w.parentOffset===0,O=E.isText||E.isTextblock,T=E.content.size>0;N&&O&&T&&(p=Math.max(0,p-1)),r.replaceWith(p,m,k)}n.updateSelection&&LR(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:p,text:k}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:p,text:k})}return!0},BR=()=>({state:t,dispatch:e})=>lA(t,e),zR=()=>({state:t,dispatch:e})=>cA(t,e),FR=()=>({state:t,dispatch:e})=>_E(t,e),$R=()=>({state:t,dispatch:e})=>ME(t,e),UR=()=>({state:t,dispatch:e,tr:n})=>{try{const r=fd(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},HR=()=>({state:t,dispatch:e,tr:n})=>{try{const r=fd(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},WR=()=>({state:t,dispatch:e})=>oA(t,e),qR=()=>({state:t,dispatch:e})=>aA(t,e);function k_(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function VR(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const u=e[l];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))Nu()||k_()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var KR=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=VR(t).split(/-(?!$)/),o=i.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,l))});return u==null||u.steps.forEach(f=>{const p=f.map(r.mapping);p&&s&&r.maybeStep(p)}),!0};function ai(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?an(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),b=Math.min(s,g+m.nodeSize);l.push({node:m,from:y,to:b})});const u=s-r,f=l.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>_u(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=u}var GR=(t,e={})=>({state:n,dispatch:r})=>{const s=an(t,n.schema);return ai(n,s,e)?uA(n,r):!1},JR=()=>({state:t,dispatch:e})=>jE(t,e),YR=t=>({state:e,dispatch:n})=>{const r=an(t,e.schema);return kA(r)(e,n)},QR=()=>({state:t,dispatch:e})=>OE(t,e);function xd(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function _x(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var XR=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=xd(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=an(t,r.schema)),l==="mark"&&(o=ws(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(p,m)=>{i&&i===p.type&&(u=!0,s&&n.setNodeMarkup(m,void 0,_x(p.attrs,e))),o&&p.marks.length&&p.marks.forEach(g=>{o===g.type&&(u=!0,s&&n.addMark(m,m+p.nodeSize,o.create(_x(g.attrs,e))))})})}),u},ZR=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),ej=()=>({tr:t,dispatch:e})=>{if(e){const n=new lr(t.doc);t.setSelection(n)}return!0},tj=()=>({state:t,dispatch:e})=>CE(t,e),nj=()=>({state:t,dispatch:e})=>AE(t,e),rj=()=>({state:t,dispatch:e})=>pA(t,e),sj=()=>({state:t,dispatch:e})=>vA(t,e),ij=()=>({state:t,dispatch:e})=>gA(t,e);function rg(t,e,n={},r={}){return ol(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var oj=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const f=rg(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function S_(t,e){const n=ws(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,u=>{o.push(...u.marks)});const l=o.find(u=>u.type.name===n.name);return l?{...l.attrs}:{}}function Jg(t,e){const n=new Mg(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function aj(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Cu(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function E_(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function __(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function wd(t){return e=>__(e.$from,t)}function qe(t,e,n){return t.config[e]===void 0&&t.parent?qe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?qe(t.parent,e,n):null}):t.config[e]}function Yg(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=qe(e,"addExtensions",n);return r?[e,...Yg(r())]:e}).flat(10)}function Qg(t,e){const n=Qi.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function N_(t){return typeof t=="function"}function _t(t,e=void 0,...n){return N_(t)?e?t.bind(e)(...n):t(...n):t}function lj(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Wo(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function C_(t){const e=[],{nodeExtensions:n,markExtensions:r}=Wo(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},u=qe(o,"addGlobalAttributes",l);if(!u)return;u().forEach(p=>{p.types.forEach(m=>{Object.entries(p.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...i,...y}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},u=qe(o,"addAttributes",l);if(!u)return;const f=u();Object.entries(f).forEach(([p,m])=>{const g={...i,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:o.name,name:p,attribute:g})})}),e}function Nt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],u=r[s]?r[s].split(" "):[],f=l.filter(p=>!u.includes(p));r[s]=[...u,...f].join(" ")}else if(s==="style"){const l=i?i.split(";").map(p=>p.trim()).filter(Boolean):[],u=r[s]?r[s].split(";").map(p=>p.trim()).filter(Boolean):[],f=new Map;u.forEach(p=>{const[m,g]=p.split(":").map(y=>y.trim());f.set(m,g)}),l.forEach(p=>{const[m,g]=p.split(":").map(y=>y.trim());f.set(m,g)}),r[s]=Array.from(f.entries()).map(([p,m])=>`${p}: ${m}`).join("; ")}else r[s]=i}),r},{})}function al(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Nt(n,r),{})}function cj(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Nx(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):cj(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Cx(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&lj(n)?!1:n!=null))}function Tx(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function uj(t,e){var n;const r=C_(t),{nodeExtensions:s,markExtensions:i}=Wo(t),o=(n=s.find(f=>qe(f,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(f=>{const p=r.filter(E=>E.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((E,N)=>{const O=qe(N,"extendNodeSchema",m);return{...E,...O?O(f):{}}},{}),y=Cx({...g,content:_t(qe(f,"content",m)),marks:_t(qe(f,"marks",m)),group:_t(qe(f,"group",m)),inline:_t(qe(f,"inline",m)),atom:_t(qe(f,"atom",m)),selectable:_t(qe(f,"selectable",m)),draggable:_t(qe(f,"draggable",m)),code:_t(qe(f,"code",m)),whitespace:_t(qe(f,"whitespace",m)),linebreakReplacement:_t(qe(f,"linebreakReplacement",m)),defining:_t(qe(f,"defining",m)),isolating:_t(qe(f,"isolating",m)),attrs:Object.fromEntries(p.map(Tx))}),b=_t(qe(f,"parseHTML",m));b&&(y.parseDOM=b.map(E=>Nx(E,p)));const k=qe(f,"renderHTML",m);k&&(y.toDOM=E=>k({node:E,HTMLAttributes:al(E,p)}));const w=qe(f,"renderText",m);return w&&(y.toText=w),[f.name,y]})),u=Object.fromEntries(i.map(f=>{const p=r.filter(w=>w.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((w,E)=>{const N=qe(E,"extendMarkSchema",m);return{...w,...N?N(f):{}}},{}),y=Cx({...g,inclusive:_t(qe(f,"inclusive",m)),excludes:_t(qe(f,"excludes",m)),group:_t(qe(f,"group",m)),spanning:_t(qe(f,"spanning",m)),code:_t(qe(f,"code",m)),attrs:Object.fromEntries(p.map(Tx))}),b=_t(qe(f,"parseHTML",m));b&&(y.parseDOM=b.map(w=>Nx(w,p)));const k=qe(f,"renderHTML",m);return k&&(y.toDOM=w=>k({mark:w,HTMLAttributes:al(w,p)})),[f.name,y]}));return new iE({topNode:o,nodes:l,marks:u})}function dj(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Tu(t){return t.sort((n,r)=>{const s=qe(n,"priority")||100,i=qe(r,"priority")||100;return s>i?-1:s<i?1:0})}function T_(t){const e=Tu(Yg(t)),n=dj(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function M_(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
58
+
59
+ `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(u,f,p,m)=>{var g;u.isBlock&&f>r&&(l+=i);const y=o==null?void 0:o[u.type.name];if(y)return p&&(l+=y({node:u,pos:f,parent:p,index:m,range:e})),!1;u.isText&&(l+=(g=u==null?void 0:u.text)==null?void 0:g.slice(Math.max(r,f)-f,s-f))}),l}function fj(t,e){const n={from:0,to:t.content.size};return M_(t,n,e)}function A_(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function hj(t,e){const n=an(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function O_(t,e){const n=xd(typeof e=="string"?e:e.name,t.schema);return n==="node"?hj(t,e):n==="mark"?S_(t,e):{}}function pj(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function mj(t){const e=pj(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Xg(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,u)=>{o.push({from:l,to:u})});else{const{from:l,to:u}=n[i];if(l===void 0||u===void 0)return;o.push({from:l,to:u})}o.forEach(({from:l,to:u})=>{const f=e.slice(i).map(l,-1),p=e.slice(i).map(u),m=e.invert().map(f,-1),g=e.invert().map(p);r.push({oldRange:{from:m,to:g},newRange:{from:f,to:p}})})}),mj(r)}function Zg(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=Gg(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var gj=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);(l==null?void 0:l.type.name)===e?o=l:i-=1}return[o,i]};function Lc(t,e){return e.nodes[t]||e.marks[t]||null}function lu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var vj=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var u,f;const p=((f=(u=s.type.spec).toText)==null?void 0:f.call(u,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?p:p.slice(0,Math.max(0,r-i))}),n};function sg(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?ws(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>_u(m.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:m,$to:g})=>{const y=m.pos,b=g.pos;t.doc.nodesBetween(y,b,(k,w)=>{if(!k.isText&&!k.marks.length)return;const E=Math.max(y,w),N=Math.min(b,w+k.nodeSize),O=N-E;o+=O,l.push(...k.marks.map(T=>({mark:T,from:E,to:N})))})}),o===0)return!1;const u=l.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>_u(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),f=l.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+f:u)>=o}function yj(t,e,n={}){if(!e)return ai(t,null,n)||sg(t,null,n);const r=xd(e,t.schema);return r==="node"?ai(t,e,n):r==="mark"?sg(t,e,n):!1}var bj=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=wd(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},xj=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Mx(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Ax(t,e){const{nodeExtensions:n}=Wo(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=_t(qe(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function kd(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(kd(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function R_(t){return t instanceof Ke}var j_=class I_{constructor(e){this.position=e}static fromJSON(e){return new I_(e.position)}toJSON(){return{position:this.position}}};function wj(t,e){const n=e.mapping.mapResult(t.position);return{position:new j_(n.pos),mapResult:n}}function kj(t){return new j_(t)}function Sj(t,e,n){var r;const{selection:s}=e;let i=null;if(b_(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(f=>f.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:u})=>{let f=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,u.pos,(p,m,g)=>{if(f)return!1;if(p.isInline){const y=!g||g.type.allowsMarkType(n),b=!!n.isInSet(p.marks)||!p.marks.some(k=>k.type.excludes(n));f=y&&b}return!f}),f})}var Ej=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,u=ws(t,r.schema);if(s)if(o){const f=S_(r,u);n.addStoredMark(u.create({...f,...e}))}else l.forEach(f=>{const p=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(p,m,(g,y)=>{const b=Math.max(y,p),k=Math.min(y+g.nodeSize,m);g.marks.find(E=>E.type===u)?g.marks.forEach(E=>{u===E.type&&n.addMark(b,k,u.create({...E.attrs,...e}))}):n.addMark(b,k,u.create(e))})});return Sj(r,n,u)},_j=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Nj=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=an(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>Hb(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Hb(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Cj=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Pi(t,0,r.content.size),i=Ke.create(r,s);e.setSelection(i)}return!0},Tj=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(u,f)=>{u.isText||n.setNodeMarkup(f,void 0,{...u.attrs,dir:t})}),!0},Mj=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=Ge.atStart(r).from,l=Ge.atEnd(r).to,u=Pi(s,o,l),f=Pi(i,o,l),p=Ge.create(r,u,f);e.setSelection(p)}return!0},Aj=t=>({state:e,dispatch:n})=>{const r=an(t,e.schema);return _A(r)(e,n)};function Ox(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var Oj=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:u}=i,f=s.extensionManager.attributes,p=lu(f,l.node().type.name,l.node().attrs);if(i instanceof Ke&&i.node.isBlock)return!l.parentOffset||!bs(o,l.pos)?!1:(r&&(t&&Ox(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,g=l.depth===0?void 0:aj(l.node(-1).contentMatchAt(l.indexAfter(-1)));let y=m&&g?[{type:g,attrs:p}]:void 0,b=bs(e.doc,e.mapping.map(l.pos),1,y);if(!y&&!b&&bs(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(b=!0,y=g?[{type:g,attrs:p}]:void 0),r){if(b&&(i instanceof Ge&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,y),g&&!m&&!l.parentOffset&&l.parent.type!==g)){const k=e.mapping.map(l.before()),w=e.doc.resolve(k);l.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&Ox(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return b},Rj=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=an(t,r.schema),{$from:u,$to:f}=r.selection,p=r.selection.node;if(p&&p.isBlock||u.depth<2||!u.sameParent(f))return!1;const m=u.node(-1);if(m.type!==l)return!1;const g=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1)return!1;if(s){let E=de.empty;const N=u.index(-1)?1:u.index(-2)?2:3;for(let D=u.depth-N;D>=u.depth-3;D-=1)E=de.from(u.node(D).copy(E));const O=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,T={...lu(g,u.node().type.name,u.node().attrs),...e},C=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;E=E.append(de.from(l.createAndFill(null,C)||void 0));const R=u.before(u.depth-(N-1));n.replace(R,u.after(-O),new _e(E,4-N,0));let L=-1;n.doc.nodesBetween(R,n.doc.content.size,(D,z)=>{if(L>-1)return!1;D.isTextblock&&D.content.size===0&&(L=z+1)}),L>-1&&n.setSelection(Ge.near(n.doc.resolve(L))),n.scrollIntoView()}return!0}const y=f.pos===u.end()?m.contentMatchAt(0).defaultType:null,b={...lu(g,m.type.name,m.attrs),...e},k={...lu(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,f.pos);const w=y?[{type:l,attrs:b},{type:y,attrs:k}]:[{type:l,attrs:b}];if(!bs(n.doc,u.pos,2))return!1;if(s){const{selection:E,storedMarks:N}=r,{splittableMarks:O}=i.extensionManager,T=N||E.$to.parentOffset&&E.$from.marks();if(n.split(u.pos,2,w).scrollIntoView(),!T||!s)return!0;const C=T.filter(R=>O.includes(R.type.name));n.ensureMarks(C)}return!0},Uh=(t,e)=>{const n=wd(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&ci(t.doc,n.pos)&&t.join(n.pos),!0},Hh=(t,e)=>{const n=wd(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&ci(t.doc,r)&&t.join(r),!0},jj=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:u,commands:f,can:p})=>{const{extensions:m,splittableMarks:g}=s.extensionManager,y=an(t,o.schema),b=an(e,o.schema),{selection:k,storedMarks:w}=o,{$from:E,$to:N}=k,O=E.blockRange(N),T=w||k.$to.parentOffset&&k.$from.marks();if(!O)return!1;const C=wd(R=>Ax(R.type.name,m))(k);if(O.depth>=1&&C&&O.depth-C.depth<=1){if(C.node.type===y)return f.liftListItem(b);if(Ax(C.node.type.name,m)&&y.validContent(C.node.content)&&l)return u().command(()=>(i.setNodeMarkup(C.pos,y),!0)).command(()=>Uh(i,y)).command(()=>Hh(i,y)).run()}return!n||!T||!l?u().command(()=>p().wrapInList(y,r)?!0:f.clearNodes()).wrapInList(y,r).command(()=>Uh(i,y)).command(()=>Hh(i,y)).run():u().command(()=>{const R=p().wrapInList(y,r),L=T.filter(D=>g.includes(D.type.name));return i.ensureMarks(L),R?!0:f.clearNodes()}).wrapInList(y,r).command(()=>Uh(i,y)).command(()=>Hh(i,y)).run()},Ij=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=ws(t,r.schema);return sg(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},Lj=(t,e,n={})=>({state:r,commands:s})=>{const i=an(t,r.schema),o=an(e,r.schema),l=ai(r,i,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),l?s.setNode(o,u):s.setNode(i,{...u,...n})},Dj=(t,e={})=>({state:n,commands:r})=>{const s=an(t,n.schema);return ai(n,s,e)?r.lift(s):r.wrapIn(s,e)},Pj=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let u=l.steps.length-1;u>=0;u-=1)o.step(l.steps[u].invert(l.docs[u]));if(i.text){const u=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else o.delete(i.from,i.to)}return!0}}return!1},Bj=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},zj=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,u=ws(t,r.schema),{$from:f,empty:p,ranges:m}=l;if(!s)return!0;if(p&&o){let{from:g,to:y}=l;const b=(i=f.marks().find(w=>w.type===u))==null?void 0:i.attrs,k=Gg(f,u,b);k&&(g=k.from,y=k.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},Fj=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,u)=>{if(l.isText)return;const f={...l.attrs};delete f.dir,e.setNodeMarkup(u,void 0,f)}),!0},$j=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=xd(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=an(t,r.schema)),l==="mark"&&(o=ws(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{const p=f.$from.pos,m=f.$to.pos;let g,y,b,k;n.selection.empty?r.doc.nodesBetween(p,m,(w,E)=>{i&&i===w.type&&(u=!0,b=Math.max(E,p),k=Math.min(E+w.nodeSize,m),g=E,y=w)}):r.doc.nodesBetween(p,m,(w,E)=>{E<p&&i&&i===w.type&&(u=!0,b=Math.max(E,p),k=Math.min(E+w.nodeSize,m),g=E,y=w),E>=p&&E<=m&&(i&&i===w.type&&(u=!0,s&&n.setNodeMarkup(E,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(N=>{if(o===N.type&&(u=!0,s)){const O=Math.max(E,p),T=Math.min(E+w.nodeSize,m);n.addMark(O,T,o.create({...N.attrs,...e}))}}))}),y&&(g!==void 0&&s&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(w=>{o===w.type&&s&&n.addMark(b,k,o.create({...w.attrs,...e}))}))}),u},Uj=(t,e={})=>({state:n,dispatch:r})=>{const s=an(t,n.schema);return yA(s,e)(n,r)},Hj=(t,e={})=>({state:n,dispatch:r})=>{const s=an(t,n.schema);return bA(s,e)(n,r)},Wj=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},gl=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},qj=(t,e)=>{if(Kg(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Dc(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:u}=n;if(u.composing)return!1;const f=u.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let p=!1;const m=vj(f)+i;return o.forEach(g=>{if(p)return;const y=qj(m,g.find);if(!y)return;const b=u.state.tr,k=yd({state:u.state,transaction:b}),w={from:r-(y[0].length-i.length),to:s},{commands:E,chain:N,can:O}=new bd({editor:n,state:k});g.handler({state:k,range:w,match:y,commands:E,chain:N,can:O})===null||!b.steps.length||(g.undoable&&b.setMeta(l,{transform:b,from:r,to:s,text:i}),u.dispatch(b),p=!0)}),p}function Vj(t){const{editor:e,rules:n}=t,r=new Ct({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const u=s.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:p}=u;typeof p=="string"?p=p:p=Qg(de.from(p),o.schema);const{from:m}=u,g=m+p.length;Dc({editor:e,from:m,to:g,text:p,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return Dc({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Dc({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Dc({editor:e,from:o.pos,to:o.pos,text:`
60
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Kj(t){return Object.prototype.toString.call(t).slice(8,-1)}function Pc(t){return Kj(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function L_(t,e){const n={...t};return Pc(t)&&Pc(e)&&Object.keys(e).forEach(r=>{Pc(e[r])&&Pc(t[r])?n[r]=L_(t[r],e[r]):n[r]=e[r]}),n}var e0=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{..._t(qe(this,"addOptions",{name:this.name}))||{}}}get storage(){return{..._t(qe(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>L_(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Dr=class D_ extends e0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new D_(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(f=>(f==null?void 0:f.type.name)===n.name))return!1;const u=o.find(f=>(f==null?void 0:f.type.name)===n.name);return u&&r.removeStoredMark(u),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Gj(t){return typeof t=="number"}var Jj=class{constructor(t){this.find=t.find,this.handler=t.handler}},Yj=(t,e,n)=>{if(Kg(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Qj(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:u,chain:f,can:p}=new bd({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(y,b)=>{var k,w,E,N,O;if((w=(k=y.type)==null?void 0:k.spec)!=null&&w.code||!(y.isText||y.isTextblock||y.isInline))return;const T=(O=(N=(E=y.content)==null?void 0:E.size)!=null?N:y.nodeSize)!=null?O:0,C=Math.max(r,b),R=Math.min(s,b+T);if(C>=R)return;const L=y.isText?y.text||"":y.textBetween(C-b,R-b,void 0,"");Yj(L,i.find,o).forEach(z=>{if(z.index===void 0)return;const F=C+z.index+1,J=F+z[0].length,K={from:n.tr.mapping.map(F),to:n.tr.mapping.map(J)},X=i.handler({state:n,range:K,match:z,commands:u,chain:f,can:p,pasteEvent:o,dropEvent:l});m.push(X)})}),m.every(y=>y!==null)}var Bc=null,Xj=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function Zj(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const u=({state:p,from:m,to:g,rule:y,pasteEvt:b})=>{const k=p.tr,w=yd({state:p,transaction:k});if(!(!Qj({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:b,dropEvent:l})||!k.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,k}};return n.map(p=>new Ct({view(m){const g=b=>{var k;r=(k=m.dom.parentElement)!=null&&k.contains(b.target)?m.dom.parentElement:null,r&&(Bc=e)},y=()=>{Bc&&(Bc=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=r===m.dom.parentElement,l=g,!i){const y=Bc;y!=null&&y.isEditable&&setTimeout(()=>{const b=y.state.selection;b&&y.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(m,g)=>{var y;const b=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,s=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const b=m[0],k=b.getMeta("uiEvent")==="paste"&&!s,w=b.getMeta("uiEvent")==="drop"&&!i,E=b.getMeta("applyPasteRules"),N=!!E;if(!k&&!w&&!N)return;if(N){let{text:C}=E;typeof C=="string"?C=C:C=Qg(de.from(C),y.schema);const{from:R}=E,L=R+C.length,D=Xj(C);return u({rule:p,state:y,from:R,to:{b:L},pasteEvt:D})}const O=g.doc.content.findDiffStart(y.doc.content),T=g.doc.content.findDiffEnd(y.doc.content);if(!(!Gj(O)||!T||O===T.b))return u({rule:p,state:y,from:O,to:T,pasteEvt:o})}}))}var Sd=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=T_(t),this.schema=uj(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Lc(e.name,this.schema)},r=qe(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Tu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Lc(r.name,this.schema)},i=[],o=qe(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&qe(r,"exitable",s)&&(l.ArrowRight=()=>Dr.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,b])=>[y,()=>b({editor:t})]));l={...l,...g}}const u=mR(l);i.push(u);const f=qe(r,"addInputRules",s);if(Mx(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const y=Vj({editor:t,rules:g}),b=Array.isArray(y)?y:[y];i.push(...b)}}const p=qe(r,"addPasteRules",s);if(Mx(r,t.options.enablePasteRules)&&p){const g=p();if(g&&g.length){const y=Zj({editor:t,rules:g});i.push(...y)}}const m=qe(r,"addProseMirrorPlugins",s);if(m){const g=m();i.push(...g)}return i})}get attributes(){return C_(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Wo(this.extensions);return Object.fromEntries(e.filter(n=>!!qe(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:an(n.name,this.schema)},i=qe(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(u,f,p,m,g)=>{const y=al(u,r);return o({node:u,view:f,getPos:p,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Tu([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Lc(s.name,this.schema)},o=qe(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Wo(this.extensions);return Object.fromEntries(e.filter(n=>!!qe(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ws(n.name,this.schema)},i=qe(n,"addMarkView",s);if(!i)return[];const o=(l,u,f)=>{const p=al(l,r);return i()({mark:l,view:u,inline:f,editor:t,extension:n,HTMLAttributes:p,updateAttributes:m=>{pI(l,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Lc(e.name,this.schema)};e.type==="mark"&&((n=_t(qe(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=qe(e,"onBeforeCreate",r),i=qe(e,"onCreate",r),o=qe(e,"onUpdate",r),l=qe(e,"onSelectionUpdate",r),u=qe(e,"onTransaction",r),f=qe(e,"onFocus",r),p=qe(e,"onBlur",r),m=qe(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),u&&this.editor.on("transaction",u),f&&this.editor.on("focus",f),p&&this.editor.on("blur",p),m&&this.editor.on("destroy",m)})}};Sd.resolve=T_;Sd.sort=Tu;Sd.flatten=Yg;var eI={};Vg(eI,{ClipboardTextSerializer:()=>B_,Commands:()=>z_,Delete:()=>F_,Drop:()=>$_,Editable:()=>U_,FocusEvents:()=>W_,Keymap:()=>q_,Paste:()=>V_,Tabindex:()=>K_,TextDirection:()=>G_,focusEventsPluginKey:()=>H_});var bt=class P_ extends e0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new P_(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},B_=bt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ct({key:new jt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(p=>p.$from.pos)),l=Math.max(...i.map(p=>p.$to.pos)),u=A_(n);return M_(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),z_=bt.create({name:"commands",addCommands(){return{...v_}}}),F_=bt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,u,f;if((f=(u=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:u.call(l,t))!=null?f:t.getMeta("y-sync$"))return;const p=Jg(t.before,[t,...e]);Xg(p).forEach(y=>{p.mapping.mapResult(y.oldRange.from).deletedAfter&&p.mapping.mapResult(y.oldRange.to).deletedBefore&&p.before.nodesBetween(y.oldRange.from,y.oldRange.to,(b,k)=>{const w=k+b.nodeSize-2,E=y.oldRange.from<=k&&w<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:k,to:w,newFrom:p.mapping.map(k),newTo:p.mapping.map(w),deletedRange:y.oldRange,newRange:y.newRange,partial:!E,editor:this.editor,transaction:t,combinedTransform:p})})});const g=p.mapping;p.steps.forEach((y,b)=>{var k,w;if(y instanceof Ir){const E=g.slice(b).map(y.from,-1),N=g.slice(b).map(y.to),O=g.invert().map(E,-1),T=g.invert().map(N),C=(k=p.doc.nodeAt(E-1))==null?void 0:k.marks.some(L=>L.eq(y.mark)),R=(w=p.doc.nodeAt(N))==null?void 0:w.marks.some(L=>L.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:O,to:T},newRange:{from:E,to:N},partial:!!(R||C),editor:this.editor,transaction:t,combinedTransform:p})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),$_=bt.create({name:"drop",addProseMirrorPlugins(){return[new Ct({key:new jt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),U_=bt.create({name:"editable",addProseMirrorPlugins(){return[new Ct({key:new jt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),H_=new jt("focusEvents"),W_=bt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ct({key:H_,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),q_=bt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:u,doc:f}=l,{empty:p,$anchor:m}=u,{pos:g,parent:y}=m,b=m.parent.isTextblock&&g>0?l.doc.resolve(g-1):m,k=b.parent.type.spec.isolating,w=m.pos-m.parentOffset,E=k&&b.parent.childCount===1?w===m.pos:it.atStart(f).from===g;return!p||!y.type.isTextblock||y.textContent.length||!E||E&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Nu()||k_()?i:s},addProseMirrorPlugins(){return[new Ct({key:new jt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(k=>k.getMeta("composition")))return;const r=t.some(k=>k.docChanged)&&!e.doc.eq(n.doc),s=t.some(k=>k.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,u=it.atStart(e.doc).from,f=it.atEnd(e.doc).to;if(i||!(o===u&&l===f)||!kd(n.doc))return;const g=n.tr,y=yd({state:n,transaction:g}),{commands:b}=new bd({editor:this.editor,state:y});if(b.clearNodes(),!!g.steps.length)return g}})]}}),V_=bt.create({name:"paste",addProseMirrorPlugins(){return[new Ct({key:new jt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),K_=bt.create({name:"tabindex",addProseMirrorPlugins(){return[new Ct({key:new jt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),G_=bt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Wo(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Ct({key:new jt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),tI=class Fa{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Fa(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Fa(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Fa(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(l);if(!s&&!o&&u.depth<=this.depth)return;const f=new Fa(u,this.editor,s,s||o?n:null);s&&(f.actualDepth=this.depth+1),e.push(f)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const u=o[l];if(i[u]!==n[u])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(u=>n[u]===o.node.attrs[u])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},nI=`.ProseMirror {
61
+ position: relative;
62
+ }
63
+
64
+ .ProseMirror {
65
+ word-wrap: break-word;
66
+ white-space: pre-wrap;
67
+ white-space: break-spaces;
68
+ -webkit-font-variant-ligatures: none;
69
+ font-variant-ligatures: none;
70
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
71
+ }
72
+
73
+ .ProseMirror [contenteditable="false"] {
74
+ white-space: normal;
75
+ }
76
+
77
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
78
+ white-space: pre-wrap;
79
+ }
80
+
81
+ .ProseMirror pre {
82
+ white-space: pre-wrap;
83
+ }
84
+
85
+ img.ProseMirror-separator {
86
+ display: inline !important;
87
+ border: none !important;
88
+ margin: 0 !important;
89
+ width: 0 !important;
90
+ height: 0 !important;
91
+ }
92
+
93
+ .ProseMirror-gapcursor {
94
+ display: none;
95
+ pointer-events: none;
96
+ position: absolute;
97
+ margin: 0;
98
+ }
99
+
100
+ .ProseMirror-gapcursor:after {
101
+ content: "";
102
+ display: block;
103
+ position: absolute;
104
+ top: -2px;
105
+ width: 20px;
106
+ border-top: 1px solid black;
107
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
108
+ }
109
+
110
+ @keyframes ProseMirror-cursor-blink {
111
+ to {
112
+ visibility: hidden;
113
+ }
114
+ }
115
+
116
+ .ProseMirror-hideselection *::selection {
117
+ background: transparent;
118
+ }
119
+
120
+ .ProseMirror-hideselection *::-moz-selection {
121
+ background: transparent;
122
+ }
123
+
124
+ .ProseMirror-hideselection * {
125
+ caret-color: transparent;
126
+ }
127
+
128
+ .ProseMirror-focused .ProseMirror-gapcursor {
129
+ display: block;
130
+ }`;function rI(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var sI=class extends Wj{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:wj,createMappablePosition:kj},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=x_(e,this.options.autofocus);this.editorState=Do.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=rI(nI,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=N_(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[U_,B_.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),z_,W_,q_,K_,$_,V_,F_,G_.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Sd(r,this)}createCommandManager(){this.commandManager=new bd({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=rg(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=rg(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new g_(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.prependClass(),this.injectCSS();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(f=>{var p;return(p=this.capturedTransaction)==null?void 0:p.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),l=o==null?void 0:o.getMeta("focus"),u=o==null?void 0:o.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return O_(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return yj(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Qg(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
131
+
132
+ `,textSerializers:n={}}=t||{};return fj(this.state.doc,{blockSeparator:e,textSerializers:{...A_(this.schema),...n}})}get isEmpty(){return kd(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new tI(e,this)}get $doc(){return this.$pos(0)}};function Gi(t){return new gl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=_t(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const u=l.search(/\S/),f=n.from+l.indexOf(o),p=f+o.length;if(Zg(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(k=>k===t.type&&k!==y.mark.type)).filter(y=>y.to>f).length)return null;p<n.to&&i.delete(p,n.to),f>n.from&&i.delete(n.from+u,f);const g=n.from+u+o.length;i.addMark(n.from+u,g,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function J_(t){return new gl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=_t(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const u=t.type.create(s);if(r[1]){const f=r[0].lastIndexOf(r[1]);let p=o+f;p>l?p=l:l=p+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(p,l,u)}else if(r[0]){const f=t.type.isInline?o:o-1;i.insert(f,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function ig(t){return new gl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=_t(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Xt(t){return new gl({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const o=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const u=i-o;u>0&&(s=r[0].slice(l-u,l)+s,i=o)}e.tr.insertText(s,i,o)},undoable:t.undoable})}function qo(t){return new gl({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=_t(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),f=u&&Tg(u,t.type,i);if(!f)return null;if(o.wrap(u,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,b=g||m.$to.parentOffset&&m.$from.marks();if(b){const k=b.filter(w=>y.includes(w.type.name));o.ensureMarks(k)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(m,i).run()}const p=o.doc.resolve(n.from-1).nodeBefore;p&&p.type===t.type&&ci(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,p))&&o.join(n.from-1)},undoable:t.undoable})}var iI=t=>"touches"in t,oI=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const u=l.clientX-this.startX,f=l.clientY-this.startY;this.handleResize(u,f)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const u=l.touches[0];if(!u)return;const f=u.clientX-this.startX,p=u.clientY-this.startY;this.handleResize(f,p)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(l,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,iI(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),u=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),l?s=this.startHeight+n:u&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let f=Math.max(this.minSize.width,t),p=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(f=Math.min(this.maxSize.width,f)),(s=this.maxSize)!=null&&s.height&&(p=Math.min(this.maxSize.height,p)),{width:f,height:p}}let l=t,u=e;return l<this.minSize.width&&(l=this.minSize.width,u=l/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,l=u*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&l>this.maxSize.width&&(l=this.maxSize.width,u=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,l=u*this.aspectRatio),{width:l,height:u}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function aI(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ke){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}var lI={};Vg(lI,{createAtomBlockMarkdownSpec:()=>cI,createBlockMarkdownSpec:()=>uI,createInlineMarkdownSpec:()=>hI,parseAttributes:()=>t0,parseIndentedBlocks:()=>og,renderNestedMarkdownContent:()=>r0,serializeAttributes:()=>n0});function t0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const f=s.map(p=>p.trim().slice(1));e.class=f.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,f,p])=>{var m;const g=parseInt(((m=p.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),y=n[g];y&&(e[f]=y.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(p=>{p.match(/^[a-zA-Z][\w-]*$/)&&(e[p]=!0)}),e}function n0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function cI(t){const{nodeName:e,name:n,parseAttributes:r=t0,serializeAttributes:s=n0,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,u=n||e,f=p=>{if(!l)return p;const m={};return l.forEach(g=>{g in p&&(m[g]=p[g])}),m};return{parseMarkdown:(p,m)=>{const g={...i,...p.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(p){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),y=(m=p.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(p,m,g){const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=p.match(y);if(!b)return;const k=b[1]||"",w=r(k);if(!o.find(N=>!(N in w)))return{type:e,raw:b[0],attributes:w}}},renderMarkdown:p=>{const m=f(p.attrs||{}),g=s(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function uI(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=t0,serializeAttributes:i=n0,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t,f=n||e,p=m=>{if(!u)return m;const g={};return u.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(r){const k=r(m);y=typeof k=="string"?[{type:"text",text:k}]:k}else l==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const b={...o,...m.attributes};return g.createNode(e,b,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${f}`,"m"),b=(g=m.match(y))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(m,g,y){var b;const k=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(k);if(!w)return;const[E,N=""]=w,O=s(N);let T=1;const C=E.length;let R="";const L=/^:::([\w-]*)(\s.*)?/gm,D=m.slice(C);for(L.lastIndex=0;;){const z=L.exec(D);if(z===null)break;const F=z.index,J=z[1];if(!((b=z[2])!=null&&b.endsWith(":::"))){if(J)T+=1;else if(T-=1,T===0){const K=D.slice(0,F);R=K.trim();const X=m.slice(0,C+F+z[0].length);let W=[];if(R)if(l==="block")for(W=y.blockTokens(K),W.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=y.inlineTokens($.text))});W.length>0;){const $=W[W.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))W.pop();else break}else W=y.inlineTokens(R);return{type:e,raw:X,attributes:O,content:R,tokens:W}}}}}},renderMarkdown:(m,g)=>{const y=p(m.attrs||{}),b=i(y),k=b?` {${b}}`:"",w=g.renderChildren(m.content||[],`
133
+
134
+ `);return`:::${f}${k}
135
+
136
+ ${w}
137
+
138
+ :::`}}}function dI(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function fI(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function hI(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=dI,serializeAttributes:i=fI,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:u}=t,f=n||e,p=g=>{if(!u)return g;const y={};return u.forEach(b=>{const k=typeof b=="string"?b:b.name,w=typeof b=="string"?void 0:b.skipIfDefault;if(k in g){const E=g[k];if(w!==void 0&&E===w)return;y[k]=E}}),y},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const b={...o,...g.attributes};if(l)return y.createNode(e,b);const k=r?r(g):g.content||"";return k?y.createNode(e,b,[y.createTextNode(k)]):y.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=l?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),b=g.match(y),k=b==null?void 0:b.index;return k!==void 0?k:-1},tokenize(g,y,b){const k=l?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(k);if(!w)return;let E="",N="";if(l){const[,T]=w;N=T}else{const[,T,C]=w;N=T,E=C||""}const O=s(N.trim());return{type:e,raw:w[0],content:E.trim(),attributes:O}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(E=>E.type==="text").map(E=>E.text).join(""));const b=p(g.attrs||{}),k=i(b),w=k?` ${k}`:"";return l?`[${f}${w}]`:`[${f}${w}]${y}[/${f}]`}}}function og(t,e,n){var r,s,i,o;const l=t.split(`
139
+ `),u=[];let f="",p=0;const m=e.baseIndentSize||2;for(;p<l.length;){const g=l[p],y=g.match(e.itemPattern);if(!y){if(u.length>0)break;if(g.trim()===""){p+=1,f=`${f}${g}
140
+ `;continue}else return}const b=e.extractItemData(y),{indentLevel:k,mainContent:w}=b;f=`${f}${g}
141
+ `;const E=[w];for(p+=1;p<l.length;){const C=l[p];if(C.trim()===""){const L=l.slice(p+1).findIndex(F=>F.trim()!=="");if(L===-1)break;if((((s=(r=l[p+1+L].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>k){E.push(C),f=`${f}${C}
142
+ `,p+=1;continue}else break}if((((o=(i=C.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>k)E.push(C),f=`${f}${C}
143
+ `,p+=1;else break}let N;const O=E.slice(1);if(O.length>0){const C=O.map(R=>R.slice(k+m)).join(`
144
+ `);C.trim()&&(e.customNestedParser?N=e.customNestedParser(C):N=n.blockTokens(C))}const T=e.createToken(b,N);u.push(T)}if(u.length!==0)return{items:u,raw:f}}function r0(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]),u=[`${s}${l}`];return o&&o.length>0&&o.forEach(f=>{const p=e.renderChildren([f]);if(p){const m=p.split(`
145
+ `).map(g=>g?e.indent(g):"").join(`
146
+ `);u.push(m)}}),u.join(`
147
+ `)}function pI(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,u)=>{const f=i.mapping.map(u),p=i.mapping.map(u)+l.nodeSize;let m=null;if(l.marks.forEach(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});i.removeMark(f,p,t.type),i.addMark(f,p,y)}}),i.docChanged&&e.view.dispatch(i)}var un=class Y_ extends e0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Y_(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function li(t){return new Jj({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=_t(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],u=r[0];let f=n.to;if(l){const p=u.search(/\S/),m=n.from+u.indexOf(l),g=m+l.length;if(Zg(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.from&&o.delete(n.from+p,m),f=n.from+p+l.length,o.addMark(n.from+p,f,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:mI,getOwnPropertySymbols:gI}=Object,{hasOwnProperty:vI}=Object.prototype;function Wh(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function zc(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const u=t(n,r,s);return i.delete(n),i.delete(r),u}}function yI(t){return t!=null?t[Symbol.toStringTag]:void 0}function Rx(t){return mI(t).concat(gI(t))}const bI=Object.hasOwn||((t,e)=>vI.call(t,e));function Xi(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const xI="__v",wI="__o",kI="_owner",{getOwnPropertyDescriptor:jx,keys:Ix}=Object;function SI(t,e){return t.byteLength===e.byteLength&&Mu(new Uint8Array(t),new Uint8Array(e))}function EI(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function _I(t,e){return t.byteLength===e.byteLength&&Mu(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function NI(t,e){return Xi(t.getTime(),e.getTime())}function CI(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function TI(t,e){return t===e}function Lx(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,u=0;for(;(o=i.next())&&!o.done;){const f=e.entries();let p=!1,m=0;for(;(l=f.next())&&!l.done;){if(s[m]){m++;continue}const g=o.value,y=l.value;if(n.equals(g[0],y[0],u,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){p=s[m]=!0;break}m++}if(!p)return!1;u++}return!0}const MI=Xi;function AI(t,e,n){const r=Ix(t);let s=r.length;if(Ix(e).length!==s)return!1;for(;s-- >0;)if(!Q_(t,e,n,r[s]))return!1;return!0}function ja(t,e,n){const r=Rx(t);let s=r.length;if(Rx(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!Q_(t,e,n,i)||(o=jx(t,i),l=jx(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function OI(t,e){return Xi(t.valueOf(),e.valueOf())}function RI(t,e){return t.source===e.source&&t.flags===e.flags}function Dx(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const u=e.values();let f=!1,p=0;for(;(l=u.next())&&!l.done;){if(!s[p]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){f=s[p]=!0;break}p++}if(!f)return!1}return!0}function Mu(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function jI(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Q_(t,e,n,r){return(r===kI||r===wI||r===xI)&&(t.$$typeof||e.$$typeof)?!0:bI(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const II="[object ArrayBuffer]",LI="[object Arguments]",DI="[object Boolean]",PI="[object DataView]",BI="[object Date]",zI="[object Error]",FI="[object Map]",$I="[object Number]",UI="[object Object]",HI="[object RegExp]",WI="[object Set]",qI="[object String]",VI={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},KI="[object URL]",GI=Object.prototype.toString;function JI({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:u,arePrimitiveWrappersEqual:f,areRegExpsEqual:p,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:b}){return function(w,E,N){if(w===E)return!0;if(w==null||E==null)return!1;const O=typeof w;if(O!==typeof E)return!1;if(O!=="object")return O==="number"?l(w,E,N):O==="function"?i(w,E,N):!1;const T=w.constructor;if(T!==E.constructor)return!1;if(T===Object)return u(w,E,N);if(Array.isArray(w))return e(w,E,N);if(T===Date)return r(w,E,N);if(T===RegExp)return p(w,E,N);if(T===Map)return o(w,E,N);if(T===Set)return m(w,E,N);const C=GI.call(w);if(C===BI)return r(w,E,N);if(C===HI)return p(w,E,N);if(C===FI)return o(w,E,N);if(C===WI)return m(w,E,N);if(C===UI)return typeof w.then!="function"&&typeof E.then!="function"&&u(w,E,N);if(C===KI)return y(w,E,N);if(C===zI)return s(w,E,N);if(C===LI)return u(w,E,N);if(VI[C])return g(w,E,N);if(C===II)return t(w,E,N);if(C===PI)return n(w,E,N);if(C===DI||C===$I||C===qI)return f(w,E,N);if(b){let R=b[C];if(!R){const L=yI(w);L&&(R=b[L])}if(R)return R(w,E,N)}return!1}}function YI({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:SI,areArraysEqual:n?ja:EI,areDataViewsEqual:_I,areDatesEqual:NI,areErrorsEqual:CI,areFunctionsEqual:TI,areMapsEqual:n?Wh(Lx,ja):Lx,areNumbersEqual:MI,areObjectsEqual:n?ja:AI,arePrimitiveWrappersEqual:OI,areRegExpsEqual:RI,areSetsEqual:n?Wh(Dx,ja):Dx,areTypedArraysEqual:n?Wh(Mu,ja):Mu,areUrlsEqual:jI,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=zc(r.areArraysEqual),i=zc(r.areMapsEqual),o=zc(r.areObjectsEqual),l=zc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function QI(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function XI({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,u){const{cache:f=t?new WeakMap:void 0,meta:p}=n();return e(l,u,{cache:f,equals:r,meta:p,strict:s})};if(t)return function(l,u){return e(l,u,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,u){return e(l,u,i)}}const ZI=di();di({strict:!0});di({circular:!0});di({circular:!0,strict:!0});di({createInternalComparator:()=>Xi});di({strict:!0,createInternalComparator:()=>Xi});di({circular:!0,createInternalComparator:()=>Xi});di({circular:!0,createInternalComparator:()=>Xi,strict:!0});function di(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=YI(t),o=JI(i),l=n?n(o):QI(o);return XI({circular:e,comparator:o,createState:r,equals:l,strict:s})}var qh={exports:{}},Vh={};/**
148
+ * @license React
149
+ * use-sync-external-store-shim/with-selector.production.js
150
+ *
151
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
152
+ *
153
+ * This source code is licensed under the MIT license found in the
154
+ * LICENSE file in the root directory of this source tree.
155
+ */var Px;function eL(){if(Px)return Vh;Px=1;var t=fl(),e=US();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,u=t.useDebugValue;return Vh.useSyncExternalStoreWithSelector=function(f,p,m,g,y){var b=i(null);if(b.current===null){var k={hasValue:!1,value:null};b.current=k}else k=b.current;b=l(function(){function E(R){if(!N){if(N=!0,O=R,R=g(R),y!==void 0&&k.hasValue){var L=k.value;if(y(L,R))return T=L}return T=R}if(L=T,r(O,R))return L;var D=g(R);return y!==void 0&&y(L,D)?(O=R,L):(O=R,T=D)}var N=!1,O,T,C=m===void 0?null:m;return[function(){return E(p())},C===null?void 0:function(){return E(C())}]},[p,m,g,y]);var w=s(f,b[0],b[1]);return o(function(){k.hasValue=!0,k.value=w},[w]),u(w),w},Vh}var Bx;function tL(){return Bx||(Bx=1,qh.exports=eL()),qh.exports}var nL=tL(),rL=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},sL=({contentComponent:t})=>{const e=HS.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return d.jsx(d.Fragment,{children:Object.values(e)})};function iL(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:uM.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var oL=class extends ii.Component{constructor(t){var e;super(t),this.editorContentRef=ii.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=iL(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:rL(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&d.jsx(sL,{contentComponent:t.contentComponent})]})}},aL=S.forwardRef((t,e)=>{const n=ii.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ii.createElement(oL,{key:n,innerRef:e,...t})}),s0=ii.memo(aL),lL=typeof window<"u"?S.useLayoutEffect:S.useEffect,cL=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function uL(t){var e;const[n]=S.useState(()=>new cL(t.editor)),r=nL.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:ZI);return lL(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var dL=!1,ag=typeof window>"u",fL=ag||!!(typeof window<"u"&&window.next),hL=class X_{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){return this.options.current.immediatelyRender===void 0?ag||fL?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new sI(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?X_.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Z_(t={},e=[]){const n=S.useRef(t);n.current=t;const[r]=S.useState(()=>new hL(n)),s=HS.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(s),S.useEffect(r.onRender(e)),uL({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var eN=S.createContext({editor:null});eN.Consumer;var pL=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),mL=()=>S.useContext(pL);ii.forwardRef((t,e)=>{const{onDragStart:n}=mL(),r=t.as||"div";return d.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ii.createContext({markViewContentRef:()=>{}});var i0=S.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});i0.displayName="TiptapContext";var gL=()=>S.useContext(i0);function tN({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=S.useMemo(()=>({editor:r}),[r]),i=S.useMemo(()=>({editor:r}),[r]);return d.jsx(eN.Provider,{value:i,children:d.jsx(i0.Provider,{value:s,children:n})})}tN.displayName="Tiptap";function nN({...t}){const{editor:e}=gL();return d.jsx(s0,{editor:e,...t})}nN.displayName="Tiptap.Content";Object.assign(tN,{Content:nN});var vL=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,yL=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,bL=Dr.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",Nt(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Gi({find:vL,type:this.type})]},addPasteRules(){return[li({find:yL,type:this.type})]}}),xL=bL,wL=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,kL=un.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",Nt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",f=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return f?`![${u}](${l} "${f}")`:`![${u}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o,editor:l})=>{const u=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,g);break}}),u.src=o.src;const f=new oI({element:u,editor:l,node:s,getPos:i,onResize:(m,g)=>{u.style.width=`${m}px`,u.style.height=`${g}px`},onCommit:(m,g)=>{const y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),p=f.dom;return p.style.visibility="hidden",p.style.pointerEvents="none",u.onload=()=>{p.style.visibility="",p.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[J_({find:wL,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),o0=kL;const SL="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",EL="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",lg="numeric",cg="ascii",ug="alpha",Ka="asciinumeric",$a="alphanumeric",dg="domain",rN="emoji",_L="scheme",NL="slashscheme",Kh="whitespace";function CL(t,e){return t in e||(e[t]=[]),e[t]}function Bi(t,e,n){e[lg]&&(e[Ka]=!0,e[$a]=!0),e[cg]&&(e[Ka]=!0,e[ug]=!0),e[Ka]&&(e[$a]=!0),e[ug]&&(e[$a]=!0),e[$a]&&(e[dg]=!0),e[rN]&&(e[dg]=!0);for(const r in e){const s=CL(r,n);s.indexOf(t)<0&&s.push(t)}}function TL(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Zn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Zn.groups={};Zn.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Zn.groups;let s;return e&&e.j?s=e:(s=new Zn(e),n&&r&&Bi(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Zn.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new Zn,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Zn,i){if(r)if(o.t&&typeof o.t=="string"){const u=Object.assign(TL(o.t,r),n);Bi(i,u,r)}else n&&Bi(i,n,r);o.t=i}return s.j[t]=o,o}};const dt=(t,e,n,r,s)=>t.ta(e,n,r,s),Jt=(t,e,n,r,s)=>t.tr(e,n,r,s),zx=(t,e,n,r,s)=>t.ts(e,n,r,s),ve=(t,e,n,r,s)=>t.tt(e,n,r,s),hs="WORD",fg="UWORD",sN="ASCIINUMERICAL",iN="ALPHANUMERICAL",ll="LOCALHOST",hg="TLD",pg="UTLD",cu="SCHEME",jo="SLASH_SCHEME",a0="NUM",mg="WS",l0="NL",Ga="OPENBRACE",Ja="CLOSEBRACE",Au="OPENBRACKET",Ou="CLOSEBRACKET",Ru="OPENPAREN",ju="CLOSEPAREN",Iu="OPENANGLEBRACKET",Lu="CLOSEANGLEBRACKET",Du="FULLWIDTHLEFTPAREN",Pu="FULLWIDTHRIGHTPAREN",Bu="LEFTCORNERBRACKET",zu="RIGHTCORNERBRACKET",Fu="LEFTWHITECORNERBRACKET",$u="RIGHTWHITECORNERBRACKET",Uu="FULLWIDTHLESSTHAN",Hu="FULLWIDTHGREATERTHAN",Wu="AMPERSAND",qu="APOSTROPHE",Vu="ASTERISK",Ks="AT",Ku="BACKSLASH",Gu="BACKTICK",Ju="CARET",Ys="COLON",c0="COMMA",Yu="DOLLAR",Gr="DOT",Qu="EQUALS",u0="EXCLAMATION",yr="HYPHEN",Ya="PERCENT",Xu="PIPE",Zu="PLUS",ed="POUND",Qa="QUERY",d0="QUOTE",oN="FULLWIDTHMIDDLEDOT",f0="SEMI",Jr="SLASH",Xa="TILDE",td="UNDERSCORE",aN="EMOJI",nd="SYM";var lN=Object.freeze({__proto__:null,ALPHANUMERICAL:iN,AMPERSAND:Wu,APOSTROPHE:qu,ASCIINUMERICAL:sN,ASTERISK:Vu,AT:Ks,BACKSLASH:Ku,BACKTICK:Gu,CARET:Ju,CLOSEANGLEBRACKET:Lu,CLOSEBRACE:Ja,CLOSEBRACKET:Ou,CLOSEPAREN:ju,COLON:Ys,COMMA:c0,DOLLAR:Yu,DOT:Gr,EMOJI:aN,EQUALS:Qu,EXCLAMATION:u0,FULLWIDTHGREATERTHAN:Hu,FULLWIDTHLEFTPAREN:Du,FULLWIDTHLESSTHAN:Uu,FULLWIDTHMIDDLEDOT:oN,FULLWIDTHRIGHTPAREN:Pu,HYPHEN:yr,LEFTCORNERBRACKET:Bu,LEFTWHITECORNERBRACKET:Fu,LOCALHOST:ll,NL:l0,NUM:a0,OPENANGLEBRACKET:Iu,OPENBRACE:Ga,OPENBRACKET:Au,OPENPAREN:Ru,PERCENT:Ya,PIPE:Xu,PLUS:Zu,POUND:ed,QUERY:Qa,QUOTE:d0,RIGHTCORNERBRACKET:zu,RIGHTWHITECORNERBRACKET:$u,SCHEME:cu,SEMI:f0,SLASH:Jr,SLASH_SCHEME:jo,SYM:nd,TILDE:Xa,TLD:hg,UNDERSCORE:td,UTLD:pg,UWORD:fg,WORD:hs,WS:mg});const ds=/[a-z]/,Ia=new RegExp("\\p{L}","u"),Gh=new RegExp("\\p{Emoji}","u"),fs=/\d/,Jh=/\s/,Fx="\r",Yh=`
156
+ `,ML="️",AL="‍",Qh="";let Fc=null,$c=null;function OL(t=[]){const e={};Zn.groups=e;const n=new Zn;Fc==null&&(Fc=$x(SL)),$c==null&&($c=$x(EL)),ve(n,"'",qu),ve(n,"{",Ga),ve(n,"}",Ja),ve(n,"[",Au),ve(n,"]",Ou),ve(n,"(",Ru),ve(n,")",ju),ve(n,"<",Iu),ve(n,">",Lu),ve(n,"(",Du),ve(n,")",Pu),ve(n,"「",Bu),ve(n,"」",zu),ve(n,"『",Fu),ve(n,"』",$u),ve(n,"<",Uu),ve(n,">",Hu),ve(n,"&",Wu),ve(n,"*",Vu),ve(n,"@",Ks),ve(n,"`",Gu),ve(n,"^",Ju),ve(n,":",Ys),ve(n,",",c0),ve(n,"$",Yu),ve(n,".",Gr),ve(n,"=",Qu),ve(n,"!",u0),ve(n,"-",yr),ve(n,"%",Ya),ve(n,"|",Xu),ve(n,"+",Zu),ve(n,"#",ed),ve(n,"?",Qa),ve(n,'"',d0),ve(n,"/",Jr),ve(n,";",f0),ve(n,"~",Xa),ve(n,"_",td),ve(n,"\\",Ku),ve(n,"・",oN);const r=Jt(n,fs,a0,{[lg]:!0});Jt(r,fs,r);const s=Jt(r,ds,sN,{[Ka]:!0}),i=Jt(r,Ia,iN,{[$a]:!0}),o=Jt(n,ds,hs,{[cg]:!0});Jt(o,fs,s),Jt(o,ds,o),Jt(s,fs,s),Jt(s,ds,s);const l=Jt(n,Ia,fg,{[ug]:!0});Jt(l,ds),Jt(l,fs,i),Jt(l,Ia,l),Jt(i,fs,i),Jt(i,ds),Jt(i,Ia,i);const u=ve(n,Yh,l0,{[Kh]:!0}),f=ve(n,Fx,mg,{[Kh]:!0}),p=Jt(n,Jh,mg,{[Kh]:!0});ve(n,Qh,p),ve(f,Yh,u),ve(f,Qh,p),Jt(f,Jh,p),ve(p,Fx),ve(p,Yh),Jt(p,Jh,p),ve(p,Qh,p);const m=Jt(n,Gh,aN,{[rN]:!0});ve(m,"#"),Jt(m,Gh,m),ve(m,ML,m);const g=ve(m,AL);ve(g,"#"),Jt(g,Gh,m);const y=[[ds,o],[fs,s]],b=[[ds,null],[Ia,l],[fs,i]];for(let k=0;k<Fc.length;k++)Ws(n,Fc[k],hg,hs,y);for(let k=0;k<$c.length;k++)Ws(n,$c[k],pg,fg,b);Bi(hg,{tld:!0,ascii:!0},e),Bi(pg,{utld:!0,alpha:!0},e),Ws(n,"file",cu,hs,y),Ws(n,"mailto",cu,hs,y),Ws(n,"http",jo,hs,y),Ws(n,"https",jo,hs,y),Ws(n,"ftp",jo,hs,y),Ws(n,"ftps",jo,hs,y),Bi(cu,{scheme:!0,ascii:!0},e),Bi(jo,{slashscheme:!0,ascii:!0},e),t=t.sort((k,w)=>k[0]>w[0]?1:-1);for(let k=0;k<t.length;k++){const w=t[k][0],N=t[k][1]?{[_L]:!0}:{[NL]:!0};w.indexOf("-")>=0?N[dg]=!0:ds.test(w)?fs.test(w)?N[Ka]=!0:N[cg]=!0:N[lg]=!0,zx(n,w,w,N)}return zx(n,"localhost",ll,{ascii:!0}),n.jd=new Zn(nd),{start:n,tokens:Object.assign({groups:e},lN)}}function cN(t,e){const n=RL(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,u=null,f=0,p=null,m=-1,g=-1;for(;o<r&&(u=l.go(n[o]));)l=u,l.accepts()?(m=0,g=0,p=l):m>=0&&(m+=n[o].length,g++),f+=n[o].length,i+=n[o].length,o++;i-=m,o-=g,f-=m,s.push({t:p.t,v:e.slice(i-f,i),s:i-f,e:i})}return s}function RL(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Ws(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const u=e[l];t.j[u]?i=t.j[u]:(i=new Zn(r),i.jr=s.slice(),t.j[u]=i),t=i}return i=new Zn(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function $x(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const cl={defaultProtocol:"http",events:null,format:Ux,formatHref:Ux,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function h0(t,e=null){let n=Object.assign({},cl);t&&(n=Object.assign(n,t instanceof h0?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}h0.prototype={o:cl,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:cl[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Ux(t){return t}function uN(t,e){this.t="token",this.v=t,this.tk=e}uN.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=cl.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),u=t.get("target",n,e),f=t.get("rel",n,e),p=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),u&&(o.target=u),f&&(o.rel=f),p&&Object.assign(o,p),{tagName:s,attributes:o,content:i,eventListeners:m}}};function Ed(t,e){class n extends uN{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Hx=Ed("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Wx=Ed("text"),jL=Ed("nl"),Uc=Ed("url",{isLink:!0,toHref(t=cl.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ll&&t[1].t===Ys}}),vr=t=>new Zn(t);function IL({groups:t}){const e=t.domain.concat([Wu,Vu,Ks,Ku,Gu,Ju,Yu,Qu,yr,a0,Ya,Xu,Zu,ed,Jr,nd,Xa,td]),n=[qu,Ys,c0,Gr,u0,Ya,Qa,d0,f0,Iu,Lu,Ga,Ja,Ou,Au,Ru,ju,Du,Pu,Bu,zu,Fu,$u,Uu,Hu],r=[Wu,qu,Vu,Ku,Gu,Ju,Yu,Qu,yr,Ga,Ja,Ya,Xu,Zu,ed,Qa,Jr,nd,Xa,td],s=vr(),i=ve(s,Xa);dt(i,r,i),dt(i,t.domain,i);const o=vr(),l=vr(),u=vr();dt(s,t.domain,o),dt(s,t.scheme,l),dt(s,t.slashscheme,u),dt(o,r,i),dt(o,t.domain,o);const f=ve(o,Ks);ve(i,Ks,f),ve(l,Ks,f),ve(u,Ks,f);const p=ve(i,Gr);dt(p,r,i),dt(p,t.domain,i);const m=vr();dt(f,t.domain,m),dt(m,t.domain,m);const g=ve(m,Gr);dt(g,t.domain,m);const y=vr(Hx);dt(g,t.tld,y),dt(g,t.utld,y),ve(f,ll,y);const b=ve(m,yr);ve(b,yr,b),dt(b,t.domain,m),dt(y,t.domain,m),ve(y,Gr,g),ve(y,yr,b);const k=ve(y,Ys);dt(k,t.numeric,Hx);const w=ve(o,yr),E=ve(o,Gr);ve(w,yr,w),dt(w,t.domain,o),dt(E,r,i),dt(E,t.domain,o);const N=vr(Uc);dt(E,t.tld,N),dt(E,t.utld,N),dt(N,t.domain,o),dt(N,r,i),ve(N,Gr,E),ve(N,yr,w),ve(N,Ks,f);const O=ve(N,Ys),T=vr(Uc);dt(O,t.numeric,T);const C=vr(Uc),R=vr();dt(C,e,C),dt(C,n,R),dt(R,e,C),dt(R,n,R),ve(N,Jr,C),ve(T,Jr,C);const L=ve(l,Ys),D=ve(u,Ys),z=ve(D,Jr),F=ve(z,Jr);dt(l,t.domain,o),ve(l,Gr,E),ve(l,yr,w),dt(u,t.domain,o),ve(u,Gr,E),ve(u,yr,w),dt(L,t.domain,C),ve(L,Jr,C),ve(L,Qa,C),dt(F,t.domain,C),dt(F,e,C),ve(F,Jr,C);const J=[[Ga,Ja],[Au,Ou],[Ru,ju],[Iu,Lu],[Du,Pu],[Bu,zu],[Fu,$u],[Uu,Hu]];for(let K=0;K<J.length;K++){const[X,W]=J[K],$=ve(C,X);ve(R,X,$),ve($,W,C);const U=vr(Uc);dt($,e,U);const Z=vr();dt($,n),dt(U,e,U),dt(U,n,Z),dt(Z,e,U),dt(Z,n,Z),ve(U,W,C),ve(Z,W,C)}return ve(s,ll,N),ve(s,l0,jL),{start:s,tokens:lN}}function LL(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,u=null,f=null,p=0,m=null,g=-1;for(;s<r&&!(u=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(f=u||l.go(n[s].t));)u=null,l=f,l.accepts()?(g=0,m=l):g>=0&&g++,s++,p++;if(g<0)s-=p,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(Xh(Wx,e,o)),o=[]),s-=g,p-=g;const y=m.t,b=n.slice(s-p,s);i.push(Xh(y,e,b))}}return o.length>0&&i.push(Xh(Wx,e,o)),i}function Xh(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const DL=typeof console<"u"&&console&&console.warn||(()=>{}),PL="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",$t={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function BL(){return Zn.groups={},$t.scanner=null,$t.parser=null,$t.tokenQueue=[],$t.pluginQueue=[],$t.customSchemes=[],$t.initialized=!1,$t}function qx(t,e=!1){if($t.initialized&&DL(`linkifyjs: already initialized - will not register custom scheme "${t}" ${PL}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
157
+ 1. Must only contain digits, lowercase ASCII letters or "-"
158
+ 2. Cannot start or end with "-"
159
+ 3. "-" cannot repeat`);$t.customSchemes.push([t,e])}function zL(){$t.scanner=OL($t.customSchemes);for(let t=0;t<$t.tokenQueue.length;t++)$t.tokenQueue[t][1]({scanner:$t.scanner});$t.parser=IL($t.scanner.tokens);for(let t=0;t<$t.pluginQueue.length;t++)$t.pluginQueue[t][1]({scanner:$t.scanner,parser:$t.parser});return $t.initialized=!0,$t}function p0(t){return $t.initialized||zL(),LL($t.parser.start,t,cN($t.scanner.start,t))}p0.scan=cN;function dN(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new h0(n),s=p0(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var m0="[\0-   ᠎ -\u2029  ]",FL=new RegExp(m0),$L=new RegExp(`${m0}$`),UL=new RegExp(m0,"g");function HL(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function WL(t){return new Ct({key:new jt("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),i=e.some(f=>f.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=Jg(n.doc,[...e]);if(Xg(l).forEach(({newRange:f})=>{const p=E_(r.doc,f,y=>y.isTextblock);let m,g;if(p.length>1)m=p[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(p.length){const y=r.doc.textBetween(f.from,f.to," "," ");if(!$L.test(y))return;m=p[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const y=g.split(FL).filter(Boolean);if(y.length<=0)return!1;const b=y[y.length-1],k=m.pos+g.lastIndexOf(b);if(!b)return!1;const w=p0(b).map(E=>E.toObject(t.defaultProtocol));if(!HL(w))return!1;w.filter(E=>E.isLink).map(E=>({...E,from:k+E.start+1,to:k+E.end+1})).filter(E=>r.schema.marks.code?!r.doc.rangeHasMark(E.from,E.to,r.schema.marks.code):!0).filter(E=>t.validate(E.value)).filter(E=>t.shouldAutoLink(E.value)).forEach(E=>{Zg(E.from,E.to,r.doc).some(N=>N.mark.type===t.type)||o.addMark(E.from,E.to,t.type.create({href:E.href}))})}}),!!o.steps.length)return o}})}function qL(t){return new Ct({key:new jt("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const u=r.target;if(!u)return!1;const f=t.editor.view.dom;o=u.closest("a"),o&&!f.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=O_(e.state,t.type.name),f=(s=o.href)!=null?s:u.href,p=(i=o.target)!=null?i:u.target;f&&(window.open(f,p),l=!0)}return l}}})}function VL(t){return new Ct({key:new jt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let u="";r.content.forEach(p=>{u+=p.textContent});const f=dN(u,{defaultProtocol:t.defaultProtocol}).find(p=>p.isLink&&p.value===u);return!u||!f||s!==void 0&&!s(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function Ri(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(UL,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var fN=Dr.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){qx(t);return}qx(t.scheme,t.optionalSlashes)})},onDestroy(){BL()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Ri(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Ri(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Ri(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Nt(this.options.HTMLAttributes,t),0]:["a",Nt(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",u=e.renderChildren(t);return l?`[${u}](${o} "${l}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Ri(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Ri(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[li({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=dN(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Ri(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(WL({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Ri(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(qL({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(VL({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),KL=fN;function GL(t={}){return new Ct({view(e){return new JL(e,t)}})}class JL{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let b=y.getBoundingClientRect(),k=m?b.bottom:b.top;m&&g&&(k=(k+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*l;r={left:b.left,right:b.right,top:k-w,bottom:k+w}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,p;if(!u||u==document.body&&getComputedStyle(u).position=="static")f=-pageXOffset,p=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,y=m.height/u.offsetHeight;f=m.left-u.scrollLeft*g,p=m.top-u.scrollTop*y}this.element.style.left=(r.left-f)/o+"px",this.element.style.top=(r.top-p)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=gE(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Yt extends it{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Yt.valid(r)?new Yt(r):it.near(r)}content(){return _e.empty}eq(e){return e instanceof Yt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Yt(e.resolve(n.pos))}getBookmark(){return new g0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!YL(e)||!QL(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Yt.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let u=e.doc.resolve(s);if(Yt.valid(u))return u}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Ke.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(Yt.valid(l))return l}return null}}}Yt.prototype.visible=!1;Yt.findFrom=Yt.findGapCursorFrom;it.jsonID("gapcursor",Yt);class g0{constructor(e){this.pos=e}map(e){return new g0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Yt.valid(n)?new Yt(n):it.near(n)}}function hN(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function YL(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||hN(s.type))return!0;if(s.inlineContent)return!1}}return!0}function QL(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||hN(s.type))return!0;if(s.inlineContent)return!1}}return!0}function XL(){return new Ct({props:{decorations:nD,createSelectionBetween(t,e,n){return e.pos==n.pos&&Yt.valid(n)?new Yt(n):null},handleClick:eD,handleKeyDown:ZL,handleDOMEvents:{beforeinput:tD}}})}const ZL=qg({ArrowLeft:Hc("horiz",-1),ArrowRight:Hc("horiz",1),ArrowUp:Hc("vert",-1),ArrowDown:Hc("vert",1)});function Hc(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,u=o.empty;if(o instanceof Ge){if(!i.endOfTextblock(n)||l.depth==0)return!1;u=!1,l=r.doc.resolve(e>0?l.after():l.before())}let f=Yt.findGapCursorFrom(l,e,u);return f?(s&&s(r.tr.setSelection(new Yt(f))),!0):!1}}function eD(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Yt.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Ke.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Yt(r))),!0)}function tD(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Yt))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=de.empty;for(let o=r.length-1;o>=0;o--)s=de.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new _e(s,0,0));return i.setSelection(Ge.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function nD(t){if(!(t.selection instanceof Yt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",St.create(t.doc,[Dt.widget(t.selection.head,e,{key:"gapcursor"})])}var rd=200,vn=function(){};vn.prototype.append=function(e){return e.length?(e=vn.from(e),!this.length&&e||e.length<rd&&this.leafAppend(e)||this.length<rd&&e.leafPrepend(this)||this.appendInner(e)):this};vn.prototype.prepend=function(e){return e.length?vn.from(e).append(this):this};vn.prototype.appendInner=function(e){return new rD(this,e)};vn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?vn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};vn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};vn.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};vn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};vn.from=function(e){return e instanceof vn?e:e&&e.length?new pN(e):vn.empty};var pN=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var u=i;u<o;u++)if(s(this.values[u],l+u)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var u=i-1;u>=o;u--)if(s(this.values[u],l+u)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=rd)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=rd)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(vn);vn.empty=new pN([]);var rD=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(vn);const sD=500;class jr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,u,f=[],p=[];return this.items.forEach((m,g)=>{if(!m.step){s||(s=this.remapping(r,g+1),i=s.maps.length),i--,p.push(m);return}if(s){p.push(new Yr(m.map));let y=m.step.map(s.slice(i)),b;y&&o.maybeStep(y).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],f.push(new Yr(b,void 0,void 0,f.length+p.length))),i--,b&&s.appendMap(b,i)}else o.maybeStep(m.step);if(m.selection)return l=s?m.selection.map(s.slice(i)):m.selection,u=new jr(this.items.slice(0,r).append(p.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,u=!s&&l.length?l.get(l.length-1):null;for(let p=0;p<e.steps.length;p++){let m=e.steps[p].invert(e.docs[p]),g=new Yr(e.mapping.maps[p],m,n),y;(y=u&&u.merge(g))&&(g=y,p?i.pop():l=l.slice(0,l.length-1)),i.push(g),n&&(o++,n=void 0),s||(u=g)}let f=o-r.depth;return f>oD&&(l=iD(l,f),o-=f),new jr(l.append(i),o)}remapping(e,n){let r=new tl;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new jr(this.items.append(e.map(n=>new Yr(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},s);let u=n;this.items.forEach(g=>{let y=i.getMirror(--u);if(y==null)return;o=Math.min(o,y);let b=i.maps[y];if(g.step){let k=e.steps[y].invert(e.docs[y]),w=g.selection&&g.selection.map(i.slice(u+1,y));w&&l++,r.push(new Yr(b,k,w))}else r.push(new Yr(b))},s);let f=[];for(let g=n;g<o;g++)f.push(new Yr(i.maps[g]));let p=this.items.slice(0,s).append(f).append(r),m=new jr(p,l);return m.emptyItemCount()>sD&&(m=m.compress(this.items.length-r.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let u=o.step.map(n.slice(r)),f=u&&u.getMap();if(r--,f&&n.appendMap(f,r),u){let p=o.selection&&o.selection.map(n.slice(r));p&&i++;let m=new Yr(f.invert(),u,p),g,y=s.length-1;(g=s.length&&s[y].merge(m))?s[y]=g:s.push(m)}}else o.map&&r--},this.items.length,0),new jr(vn.from(s.reverse()),i)}}jr.empty=new jr(vn.empty,0);function iD(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Yr{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Yr(n.getMap().invert(),n,this.selection)}}}class Gs{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const oD=20;function aD(t,e,n,r){let s=n.getMeta(Hi),i;if(s)return s.historyState;n.getMeta(uD)&&(t=new Gs(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Hi))return o.getMeta(Hi).redo?new Gs(t.done.addTransform(n,void 0,r,uu(e)),t.undone,Vx(n.mapping.maps),t.prevTime,t.prevComposition):new Gs(t.done,t.undone.addTransform(n,void 0,r,uu(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),u=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!lD(n,t.prevRanges)),f=o?Zh(t.prevRanges,n.mapping):Vx(n.mapping.maps);return new Gs(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,uu(e)),jr.empty,f,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Gs(t.done.rebased(n,i),t.undone.rebased(n,i),Zh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Gs(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Zh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function lD(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function Vx(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Zh(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function cD(t,e,n){let r=uu(e),s=Hi.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),u=new Gs(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Hi,{redo:n,historyState:u})}let ep=!1,Kx=null;function uu(t){let e=t.plugins;if(Kx!=e){ep=!1,Kx=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){ep=!0;break}}return ep}const Hi=new jt("history"),uD=new jt("closeHistory");function dD(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ct({key:Hi,state:{init(){return new Gs(jr.empty,jr.empty,null,0,-1)},apply(e,n,r){return aD(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?gN:r=="historyRedo"?vN:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function mN(t,e){return(n,r)=>{let s=Hi.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=cD(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const gN=mN(!1,!0),vN=mN(!0,!0);bt.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ct({key:new jt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(l,u);return t=!0,f}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,u=i-r,f=l-u,p=l;return e.deleteRange(f,p),!(this.storage.characters({node:e.doc})>r)}})]}});var fD=bt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[GL(this.options)]}});bt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ct({key:new jt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return St.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,f)=>{if(u.isText)return;if(!(s>=f&&s<=f+u.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((u,f)=>{if(u.isText||!(s>=f&&s<=f+u.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(Dt.node(f,f+u.nodeSize,{class:this.options.className}))}),St.create(t,i)}}})]}});var hD=bt.create({name:"gapCursor",addProseMirrorPlugins(){return[XL()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=_t(qe(t,"allowGapCursor",n)))!=null?e:null}}}),Gx="placeholder";function pD(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var mD=bt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Gx,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${pD(this.options.dataAttribute)}`:`data-${Gx}`;return[new Ct({key:new jt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,u)=>{const f=s>=u&&s<=u+l.nodeSize,p=!l.isLeaf&&kd(l);if((f||!this.options.showOnlyCurrent)&&p){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=Dt.node(u,u+l.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:u,hasAnchor:f}):this.options.placeholder});i.push(g)}return this.options.includeChildren}),St.create(e,i)}}})]}});bt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ct({key:new jt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||R_(n.selection)||t.view.dragging?null:St.create(n.doc,[Dt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Jx({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var gD=bt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new jt(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new Ct({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:u,schema:f}=o,p=e.getState(o),m=l.content.size,g=f.nodes[n];if(p)return u.insert(m,g.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Jx({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Jx({node:o,types:r})}}})]}}),vD=bt.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>gN(t,e),redo:()=>({state:t,dispatch:e})=>vN(t,e)}},addProseMirrorPlugins(){return[dD(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),_d=mD,yD=Dr.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Nt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),bD=yD,xD=Dr.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Nt(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),wD=xD;let gg,vg;if(typeof WeakMap<"u"){let t=new WeakMap;gg=e=>t.get(e),vg=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;gg=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},vg=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Qt=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:u,bottom:f}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,u),right:Math.max(r,l),bottom:Math.max(i,f)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return gg(t)||vg(t,kD(t))}};function kD(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=SD(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let f=0,p=e*n;f<p;f++)r[f]=0;for(let f=0,p=0;f<n;f++){const m=t.child(f);p++;for(let b=0;;b++){for(;s<r.length&&r[s]!=0;)s++;if(b==m.childCount)break;const k=m.child(b),{colspan:w,rowspan:E,colwidth:N}=k.attrs;for(let O=0;O<E;O++){if(O+f>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:p,n:E-O});break}const T=s+O*e;for(let C=0;C<w;C++){r[T+C]==0?r[T+C]=p:(i||(i=[])).push({type:"collision",row:f,pos:p,n:w-C});const R=N&&N[C];if(R){const L=(T+C)%e*2,D=o[L];D==null||D!=R&&o[L+1]==1?(o[L]=R,o[L+1]=1):D==R&&o[L+1]++}}}s+=w,p+=k.nodeSize}const g=(f+1)*e;let y=0;for(;s<g;)r[s++]==0&&y++;y&&(i||(i=[])).push({type:"missing",row:f,n:y}),p++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Qt(e,n,r,i);let u=!1;for(let f=0;!u&&f<o.length;f+=2)o[f]!=null&&o[f+1]<n&&(u=!0);return u&&ED(l,o,t),l}function SD(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let u=0;u<l.childCount;u++){const f=l.child(u);o+f.attrs.rowspan>r&&(i+=f.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function ED(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const u=o.attrs;for(let f=0;f<u.colspan;f++){const p=e[(s+f)%t.width*2];p!=null&&(!u.colwidth||u.colwidth[f]!=p)&&((l||(l=_D(u)))[f]=p)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function _D(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Bn(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const Qs=new jt("selectingCells");function Ji(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function ND(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Pr(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Nd(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Ji(e.$head)||CD(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function CD(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function yg(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function TD(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function v0(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function yN(t,e,n){const r=t.node(-1),s=Qt.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Yi(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function bN(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function MD(t,e,n){const r=Bn(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var Pt=class ps extends it{constructor(e,n=e){const r=e.node(-1),s=Qt.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),u=s.cellsInRect(o).filter(p=>p!=n.pos-i);u.unshift(n.pos-i);const f=u.map(p=>{const m=r.nodeAt(p);if(!m)throw new RangeError(`No cell with offset ${p} found`);const g=i+p+1;return new wE(l.resolve(g),l.resolve(g+m.content.size))});super(f[0].$from,f[0].$to,f),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(yg(r)&&yg(s)&&v0(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ps.rowSelection(r,s):i&&this.isColSelection()?ps.colSelection(r,s):new ps(r,s)}return Ge.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Qt.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let u=s.top;u<s.bottom;u++){const f=[];for(let p=u*n.width+s.left,m=s.left;m<s.right;m++,p++){const g=n.map[p];if(i[g])continue;i[g]=!0;const y=n.findCell(g);let b=e.nodeAt(g);if(!b)throw new RangeError(`No cell with offset ${g} found`);const k=s.left-y.left,w=y.right-s.right;if(k>0||w>0){let E=b.attrs;if(k>0&&(E=Yi(E,0,k)),w>0&&(E=Yi(E,E.colspan-w,w)),y.left<s.left){if(b=b.type.createAndFill(E),!b)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(E)}`)}else b=b.type.create(E,b.content)}if(y.top<s.top||y.bottom>s.bottom){const E={...b.attrs,rowspan:Math.min(y.bottom,s.bottom)-Math.max(y.top,s.top)};y.top<s.top?b=b.type.createAndFill(E):b=b.type.create(E,b.content)}f.push(b)}o.push(e.child(u).copy(de.from(f)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new _e(de.from(l),1,1)}replace(e,n=_e.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:u}=s[o],f=e.mapping.slice(r);e.replace(f.map(l.pos),f.map(u.pos),o?_e.empty:n)}const i=it.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new _e(de.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Qt.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Qt.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=u.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=u.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=u.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new ps(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Qt.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof ps&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Qt.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=u.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=u.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=u.resolve(i+s.map[s.width*(o.top+1)-1]))),new ps(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new ps(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new ps(e.resolve(n),e.resolve(r))}getBookmark(){return new AD(this.$anchorCell.pos,this.$headCell.pos)}};Pt.prototype.visible=!1;it.jsonID("cell",Pt);var AD=class xN{constructor(e,n){this.anchor=e,this.head=n}map(e){return new xN(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&v0(n,r)?new Pt(n,r):it.near(r,1)}};function OD(t){if(!(t.selection instanceof Pt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Dt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),St.create(t.doc,e)}function RD({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function jD({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function ID(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof Ke&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Pt.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Pt.rowSelection(l,l)}else if(!n){const l=Qt.get(r.node),u=r.from+1,f=u+l.map[l.width*l.height-1];i=Pt.create(s,u+1,f)}}else r instanceof Ge&&RD(r)?i=Ge.create(s,r.from):r instanceof Ge&&jD(r)&&(i=Ge.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const LD=new jt("fix-tables");function wN(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const u=e.child(o);for(let f=l,p=Math.min(s,o+3);f<p;f++)if(t.child(f)==u){l=f+1,n+=u.nodeSize;continue e}r(u,n),l<s&&t.child(l).sameMarkup(u)?wN(t.child(l),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function kN(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=DD(t,s,i,n))};return e?e.doc!=t.doc&&wN(e.doc,t.doc,0,r):t.doc.descendants(r),n}function DD(t,e,n,r){const s=Qt.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u<s.height;u++)i.push(0);for(let u=0;u<s.problems.length;u++){const f=s.problems[u];if(f.type=="collision"){const p=e.nodeAt(f.pos);if(!p)continue;const m=p.attrs;for(let g=0;g<m.rowspan;g++)i[f.row+g]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,Yi(m,m.colspan-f.n,f.n))}else if(f.type=="missing")i[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const p=e.nodeAt(f.pos);if(!p)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...p.attrs,rowspan:p.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const p=e.nodeAt(f.pos);if(!p)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...p.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const p=r.mapping.map(n);r.delete(p,p+e.nodeSize)}}let o,l;for(let u=0;u<i.length;u++)i[u]&&(o==null&&(o=u),l=u);for(let u=0,f=n+1;u<s.height;u++){const p=e.child(u),m=f+p.nodeSize,g=i[u];if(g>0){let y="cell";p.firstChild&&(y=p.firstChild.type.spec.tableRole);const b=[];for(let w=0;w<g;w++){const E=Bn(t.schema)[y].createAndFill();E&&b.push(E)}const k=(u==0||o==u-1)&&l==u?f+1:m-1;r.insert(r.mapping.map(k),b)}f=m}return r.setMeta(LD,{fixTables:!0})}function Zr(t){const e=t.selection,n=Nd(t),r=n.node(-1),s=n.start(-1),i=Qt.get(r);return{...e instanceof Pt?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function SN(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;MD(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const u=e.map[l],f=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,bN(f.attrs,s-e.colCount(u))),o+=f.attrs.rowspan-1}else{const u=i==null?Bn(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,f=e.positionAt(o,s,r);t.insert(t.mapping.map(n+f),u.createAndFill())}}return t}function PD(t,e){if(!Pr(t))return!1;if(e){const n=Zr(t);e(SN(t.tr,n,n.left))}return!0}function BD(t,e){if(!Pr(t))return!1;if(e){const n=Zr(t);e(SN(t.tr,n,n.right))}return!0}function zD(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,u=e.map[l],f=n.nodeAt(u),p=f.attrs;if(s>0&&e.map[l-1]==u||s<e.width-1&&e.map[l+1]==u)t.setNodeMarkup(t.mapping.slice(i).map(r+u),null,Yi(p,s-e.colCount(u)));else{const m=t.mapping.slice(i).map(r+u);t.delete(m,m+f.nodeSize)}o+=p.rowspan}}function FD(t,e){if(!Pr(t))return!1;if(e){const n=Zr(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;zD(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Qt.get(i)}e(r)}return!0}function $D(t,e,n){var r;const s=Bn(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function EN(t,{map:e,tableStart:n,table:r},s){let i=n;for(let f=0;f<s;f++)i+=r.child(f).nodeSize;const o=[];let l=s>0?-1:0;$D(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let f=0,p=e.width*s;f<e.width;f++,p++)if(s>0&&s<e.height&&e.map[p]==e.map[p-e.width]){const m=e.map[p],g=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var u;const m=l==null?Bn(r.type.schema).cell:(u=r.nodeAt(e.map[p+l*e.width]))===null||u===void 0?void 0:u.type,g=m==null?void 0:m.createAndFill();g&&o.push(g)}return t.insert(i,Bn(r.type.schema).row.create(null,o)),t}function UD(t,e){if(!Pr(t))return!1;if(e){const n=Zr(t);e(EN(t.tr,n,n.top))}return!0}function HD(t,e){if(!Pr(t))return!1;if(e){const n=Zr(t);e(EN(t.tr,n,n.bottom))}return!0}function WD(t,{map:e,table:n,tableStart:r},s){let i=0;for(let f=0;f<s;f++)i+=n.child(f).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const u=new Set;for(let f=0,p=s*e.width;f<e.width;f++,p++){const m=e.map[p];if(!u.has(m)){if(u.add(m),s>0&&m==e.map[p-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g,rowspan:g.rowspan-1}),f+=g.colspan-1}else if(s<e.height&&m==e.map[p+e.width]){const g=n.nodeAt(m),y=g.attrs,b=g.type.create({...y,rowspan:g.attrs.rowspan-1},g.content),k=e.positionAt(s+1,f,n);t.insert(t.mapping.slice(l).map(r+k),b),f+=y.colspan-1}}}}function qD(t,e){if(!Pr(t))return!1;if(e){const n=Zr(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;WD(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Qt.get(n.table)}e(r)}return!0}function Yx(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function VD({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Qx(t,e){const n=t.selection;if(!(n instanceof Pt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Zr(t),{map:s}=r;if(VD(s,r))return!1;if(e){const i=t.tr,o={};let l=de.empty,u,f;for(let p=r.top;p<r.bottom;p++)for(let m=r.left;m<r.right;m++){const g=s.map[p*s.width+m],y=r.table.nodeAt(g);if(!(o[g]||!y))if(o[g]=!0,u==null)u=g,f=y;else{Yx(y)||(l=l.append(y.content));const b=i.mapping.map(g+r.tableStart);i.delete(b,b+y.nodeSize)}}if(u==null||f==null)return!0;if(i.setNodeMarkup(u+r.tableStart,null,{...bN(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const p=u+1+f.content.size,m=Yx(f)?u+1:p;i.replaceWith(m+r.tableStart,p+r.tableStart,l)}i.setSelection(new Pt(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Xx(t,e){const n=Bn(t.schema);return KD(({node:r})=>n[r.type.spec.tableRole])(t,e)}function KD(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof Pt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=ND(r.$from),!s)return!1;i=(o=Ji(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const u=[],f=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const p=Zr(e),m=e.tr;for(let y=0;y<p.right-p.left;y++)u.push(f?{...l,colwidth:f&&f[y]?[f[y]]:null}:l);let g;for(let y=p.top;y<p.bottom;y++){let b=p.map.positionAt(y,p.left,p.table);y==p.top&&(b+=s.nodeSize);for(let k=p.left,w=0;k<p.right;k++,w++)k==p.left&&y==p.top||m.insert(g=m.mapping.map(b+p.tableStart,1),t({node:s,row:y,col:k}).createAndFill(u[w]))}m.setNodeMarkup(i,t({node:s,row:p.top,col:p.left}),u[0]),r instanceof Pt&&m.setSelection(new Pt(m.doc.resolve(r.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function GD(t,e){return function(n,r){if(!Pr(n))return!1;const s=Nd(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Pt?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function JD(t){return function(e,n){if(!Pr(e))return!1;if(n){const r=Bn(e.schema),s=Zr(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(u=>s.table.nodeAt(u));for(let u=0;u<o.length;u++)l[u].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[u],r.cell,l[u].attrs);if(i.steps.length===0)for(let u=0;u<o.length;u++)i.setNodeMarkup(s.tableStart+o[u],r.header_cell,l[u].attrs);n(i)}return!0}}function Zx(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function ul(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?JD(t):function(n,r){if(!Pr(n))return!1;if(r){const s=Bn(n.schema),i=Zr(n),o=n.tr,l=Zx("row",i,s),u=Zx("column",i,s),f=(t==="column"?l:t==="row"&&u)?1:0,p=t=="column"?{left:0,top:f,right:1,bottom:i.map.height}:t=="row"?{left:f,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?u?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(g=>{const y=g+i.tableStart,b=o.doc.nodeAt(y);b&&o.setNodeMarkup(y,m,b.attrs)}),r(o)}return!0}}ul("row",{useDeprecatedLogic:!0});ul("column",{useDeprecatedLogic:!0});const YD=ul("cell",{useDeprecatedLogic:!0});function QD(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function e1(t){return function(e,n){if(!Pr(e))return!1;const r=QD(Nd(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(Ge.between(s,TD(s))).scrollIntoView())}return!0}}function XD(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Wc(t,e){const n=t.selection;if(!(n instanceof Pt))return!1;if(e){const r=t.tr,s=Bn(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new _e(s,0,0))}),r.docChanged&&e(r)}return!0}function ZD(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let u=0;u<e.childCount;u++){let f=e.child(u).content;const p=u?0:Math.max(0,n-1),m=u<e.childCount-1?0:Math.max(0,r-1);(p||m)&&(f=bg(Bn(o).row,new _e(f,p,m)).content),l.push(f)}else if(i=="cell"||i=="header_cell")l.push(n||r?bg(Bn(o).row,new _e(e,n,r)).content:e);else return null;return eP(o,l)}function eP(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:u}=i.child(o).attrs;for(let f=s;f<s+l;f++)n[f]=(n[f]||0)+u}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(de.empty),n[s]<r){const i=Bn(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(de.from(o))}return{height:e.length,width:r,rows:e}}function bg(t,e){const n=t.createAndFill();return new Mg(n).replace(0,n.content.size,e).doc}function tP({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const u=n[l],f=[];for(let p=i[l]||0,m=0;p<r;m++){let g=u.child(m%u.childCount);p+g.attrs.colspan>r&&(g=g.type.createChecked(Yi(g.attrs,g.attrs.colspan,p+g.attrs.colspan-r),g.content)),f.push(g),p+=g.attrs.colspan;for(let y=1;y<g.attrs.rowspan;y++)i[l+y]=(i[l+y]||0)+g.attrs.colspan}o.push(de.from(f))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const u=[],f=n[l%e];for(let p=0;p<f.childCount;p++){let m=f.child(p);o+m.attrs.rowspan>s&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,s-m.attrs.rowspan)},m.content)),u.push(m)}i.push(de.from(u))}n=i,e=s}return{width:t,height:e,rows:n}}function nP(t,e,n,r,s,i,o){const l=t.doc.type.schema,u=Bn(l);let f,p;if(s>e.width)for(let m=0,g=0;m<e.height;m++){const y=n.child(m);g+=y.nodeSize;const b=[];let k;y.lastChild==null||y.lastChild.type==u.cell?k=f||(f=u.cell.createAndFill()):k=p||(p=u.header_cell.createAndFill());for(let w=e.width;w<s;w++)b.push(k);t.insert(t.mapping.slice(o).map(g-1+r),b)}if(i>e.height){const m=[];for(let b=0,k=(e.height-1)*e.width;b<Math.max(e.width,s);b++){const w=b>=e.width?!1:n.nodeAt(e.map[k+b]).type==u.header_cell;m.push(w?p||(p=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const g=u.row.create(null,de.from(m)),y=[];for(let b=e.height;b<i;b++)y.push(g);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),y)}return!!(f||p)}function t1(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let u=!1;for(let f=s;f<i;f++){const p=o*e.width+f,m=e.map[p];if(e.map[p-e.width]==m){u=!0;const g=n.nodeAt(m),{top:y,left:b}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g.attrs,rowspan:o-y}),t.insert(t.mapping.slice(l).map(e.positionAt(o,b,n)),g.type.createAndFill({...g.attrs,rowspan:y+g.attrs.rowspan-o})),f+=g.attrs.colspan-1}}return u}function n1(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let u=!1;for(let f=s;f<i;f++){const p=f*e.width+o,m=e.map[p];if(e.map[p-1]==m){u=!0;const g=n.nodeAt(m),y=e.colCount(m),b=t.mapping.slice(l).map(m+r);t.setNodeMarkup(b,null,Yi(g.attrs,o-y,g.attrs.colspan-(o-y))),t.insert(b+g.nodeSize,g.type.createAndFill(Yi(g.attrs,0,o-y))),f+=g.attrs.rowspan-1}}return u}function r1(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Qt.get(i);const{top:l,left:u}=r,f=u+s.width,p=l+s.height,m=t.tr;let g=0;function y(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");o=Qt.get(i),g=m.mapping.maps.length}nP(m,o,i,n,f,p,g)&&y(),t1(m,o,i,n,u,f,l,g)&&y(),t1(m,o,i,n,u,f,p,g)&&y(),n1(m,o,i,n,l,p,u,g)&&y(),n1(m,o,i,n,l,p,f,g)&&y();for(let b=l;b<p;b++){const k=o.positionAt(b,u,i),w=o.positionAt(b,f,i);m.replace(m.mapping.slice(g).map(k+n),m.mapping.slice(g).map(w+n),new _e(s.rows[b-l],0,0))}y(),m.setSelection(new Pt(m.doc.resolve(n+o.positionAt(l,u,i)),m.doc.resolve(n+o.positionAt(p-1,f-1,i)))),e(m)}const rP=qg({ArrowLeft:qc("horiz",-1),ArrowRight:qc("horiz",1),ArrowUp:qc("vert",-1),ArrowDown:qc("vert",1),"Shift-ArrowLeft":Vc("horiz",-1),"Shift-ArrowRight":Vc("horiz",1),"Shift-ArrowUp":Vc("vert",-1),"Shift-ArrowDown":Vc("vert",1),Backspace:Wc,"Mod-Backspace":Wc,Delete:Wc,"Mod-Delete":Wc});function du(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function qc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Pt)return du(n,r,it.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=_N(s,t,e);if(o==null)return!1;if(t=="horiz")return du(n,r,it.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),u=yN(l,t,e);let f;return u?f=it.near(u,1):e<0?f=it.near(n.doc.resolve(l.before(-1)),-1):f=it.near(n.doc.resolve(l.after(-1)),1),du(n,r,f)}}}function Vc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof Pt)o=i;else{const u=_N(s,t,e);if(u==null)return!1;o=new Pt(n.doc.resolve(u))}const l=yN(o.$headCell,t,e);return l?du(n,r,new Pt(o.$anchorCell,l)):!1}}function sP(t,e){const n=t.state.doc,r=Ji(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Pt(r))),!0):!1}function iP(t,e,n){if(!Pr(t.state))return!1;let r=ZD(n);const s=t.state.selection;if(s instanceof Pt){r||(r={width:1,height:1,rows:[de.from(bg(Bn(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Qt.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=tP(r,l.right-l.left,l.bottom-l.top),r1(t.state,t.dispatch,o,l,r),!0}else if(r){const i=Nd(t.state),o=i.start(-1);return r1(t.state,t.dispatch,o,Qt.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function oP(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=s1(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Pt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Ji(t.state.selection.$anchor))!=null&&((n=tp(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(u,f){let p=tp(t,f);const m=Qs.getState(t.state)==null;if(!p||!v0(u,p))if(m)p=u;else return;const g=new Pt(u,p);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(Qs,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),Qs.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Qs,-1))}function l(u){const f=u,p=Qs.getState(t.state);let m;if(p!=null)m=t.state.doc.resolve(p);else if(s1(t,f.target)!=r&&(m=tp(t,e),!m))return o();m&&i(m,f)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function _N(t,e,n){if(!(t.state.selection instanceof Ge))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function s1(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function tp(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Ji(t.state.doc.resolve(r))||Ji(t.state.doc.resolve(s))}var aP=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),xg(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,xg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function xg(t,e,n,r,s,i){let o=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f){for(let m=0,g=0;m<f.childCount;m++){const{colspan:y,colwidth:b}=f.child(m).attrs;for(let k=0;k<y;k++,g++){const w=s==g?i:b&&b[k],E=w?w+"px":"";if(o+=w||r,w||(l=!1),u)u.style.width!=E&&(u.style.width=E),u=u.nextSibling;else{const N=document.createElement("col");N.style.width=E,e.appendChild(N)}}}for(;u;){var p;const m=u.nextSibling;(p=u.parentNode)===null||p===void 0||p.removeChild(u),u=m}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const ar=new jt("tableColumnResizing");function lP({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=aP,lastColumnResizable:s=!0}={}){const i=new Ct({key:ar,state:{init(o,l){var u;const f=(u=i.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,p=Bn(l.schema).table.name;return r&&f&&(f[p]=(m,g)=>new r(m,n,g)),new cP(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=ar.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{uP(o,l,t,s)},mouseleave:o=>{dP(o)},mousedown:(o,l)=>{fP(o,l,e,n)}},decorations:o=>{const l=ar.getState(o);if(l&&l.activeHandle>-1)return vP(o,l.activeHandle)},nodeViews:{}}});return i}var cP=class fu{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(ar);if(r&&r.setHandle!=null)return new fu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new fu(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return yg(e.doc.resolve(s))||(s=-1),new fu(s,n.dragging)}return n}};function uP(t,e,n,r){if(!t.editable)return;const s=ar.getState(t.state);if(s&&!s.dragging){const i=pP(e.target);let o=-1;if(i){const{left:l,right:u}=i.getBoundingClientRect();e.clientX-l<=n?o=i1(t,e,"left",n):u-e.clientX<=n&&(o=i1(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),u=l.node(-1),f=Qt.get(u),p=l.start(-1);if(f.colCount(l.pos-p)+l.nodeAfter.attrs.colspan-1==f.width-1)return}NN(t,o)}}}function dP(t){if(!t.editable)return;const e=ar.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&NN(t,-1)}function fP(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=ar.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),u=hP(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(ar,{setDragging:{startX:e.clientX,startWidth:u}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",p);const g=ar.getState(t.state);g!=null&&g.dragging&&(mP(t,g.activeHandle,o1(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(ar,{setDragging:null})))}function p(m){if(!m.which)return f(m);const g=ar.getState(t.state);if(g&&g.dragging){const y=o1(g.dragging,m,n);a1(t,g.activeHandle,y,r)}}return a1(t,o.activeHandle,u,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",p),e.preventDefault(),!0}function hP(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let u=0;u<n;u++)r[u]&&(o-=r[u],l--);return o/l}function pP(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function i1(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Ji(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const u=Qt.get(l.node(-1)),f=l.start(-1),p=u.map.indexOf(l.pos-f);return p%u.width==0?-1:f+u.map[p-1]}function o1(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function NN(t,e){t.dispatch(t.state.tr.setMeta(ar,{setHandle:e}))}function mP(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Qt.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let f=0;f<i.height;f++){const p=f*i.width+l;if(f&&i.map[p]==i.map[p-i.width])continue;const m=i.map[p],g=s.nodeAt(m).attrs,y=g.colspan==1?0:l-i.colCount(m);if(g.colwidth&&g.colwidth[y]==n)continue;const b=g.colwidth?g.colwidth.slice():gP(g.colspan);b[y]=n,u.setNodeMarkup(o+m,null,{...g,colwidth:b})}u.docChanged&&t.dispatch(u)}function a1(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Qt.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let u=t.domAtPos(s.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&xg(i,u.firstChild,u,r,l,n)}function gP(t){return Array(t).fill(0)}function vP(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return St.empty;const i=Qt.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<i.height;f++){const p=l+f*i.width;if((l==i.width-1||i.map[p]!=i.map[p+1])&&(f==0||i.map[p]!=i.map[p-i.width])){var u;const m=i.map[p],g=o+m+s.nodeAt(m).nodeSize-1,y=document.createElement("div");y.className="column-resize-handle",!((u=ar.getState(t))===null||u===void 0)&&u.dragging&&n.push(Dt.node(o+m,o+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(Dt.widget(g,y))}}return St.create(t.doc,n)}function yP({allowTableNodeSelection:t=!1}={}){return new Ct({key:Qs,state:{init(){return null},apply(e,n){const r=e.getMeta(Qs);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:OD,handleDOMEvents:{mousedown:oP},createSelectionBetween(e){return Qs.getState(e.state)!=null?e.state.selection:null},handleTripleClick:sP,handleKeyDown:rP,handlePaste:iP},appendTransaction(e,n,r){return ID(r,kN(r,n),t)}})}var CN=un.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Nt(this.options.HTMLAttributes,t),0]}}),TN=un.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Nt(this.options.HTMLAttributes,t),0]}}),MN=un.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Nt(this.options.HTMLAttributes,t),0]}});function wg(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function l1(t,e,n,r,s,i){var o;let l=0,u=!0,f=e.firstChild;const p=t.firstChild;if(p!==null)for(let g=0,y=0;g<p.childCount;g+=1){const{colspan:b,colwidth:k}=p.child(g).attrs;for(let w=0;w<b;w+=1,y+=1){const E=s===y?i:k&&k[w],N=E?`${E}px`:"";if(l+=E||r,E||(u=!1),f){if(f.style.width!==N){const[O,T]=wg(r,E);f.style.setProperty(O,T)}f=f.nextSibling}else{const O=document.createElement("col"),[T,C]=wg(r,E);O.style.setProperty(T,C),e.appendChild(O)}}}for(;f;){const g=f.nextSibling;(o=f.parentNode)==null||o.removeChild(f),f=g}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!m?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var bP=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),l1(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,l1(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function xP(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let m=0,g=0;m<l.childCount;m+=1){const{colspan:y,colwidth:b}=l.child(m).attrs;for(let k=0;k<y;k+=1,g+=1){const w=n===g?r:b&&b[k];s+=w||e,w||(i=!1);const[E,N]=wg(e,w);o.push(["col",{style:`${E}: ${N}`}])}}const u=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:u,tableMinWidth:f}}function c1(t,e){return t.createAndFill()}function wP(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function kP(t,e,n,r,s){const i=wP(t),o=[],l=[];for(let f=0;f<n;f+=1){const p=c1(i.cell);if(p&&l.push(p),r){const m=c1(i.header_cell);m&&o.push(m)}}const u=[];for(let f=0;f<e;f+=1)u.push(i.row.createChecked(null,r&&f===0?o:l));return i.table.createChecked(null,u)}function SP(t){return t instanceof Pt}var Kc=({editor:t})=>{const{selection:e}=t.state;if(!SP(e))return!1;let n=0;const r=__(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},EP="";function _P(t){return(t||"").replace(/\s+/g," ").trim()}function NP(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:EP;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(b=>{const k=[];b.content&&b.content.forEach(w=>{let E="";w.content&&Array.isArray(w.content)&&w.content.length>1?E=w.content.map(C=>e.renderChildren(C)).join(s):E=w.content?e.renderChildren(w.content):"";const N=_P(E),O=w.type==="tableHeader";k.push({text:N,isHeader:O})}),i.push(k)});const o=i.reduce((b,k)=>Math.max(b,k.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(b=>{var k;for(let w=0;w<o;w+=1){const N=(((k=b[w])==null?void 0:k.text)||"").length;N>l[w]&&(l[w]=N),l[w]<3&&(l[w]=3)}});const u=(b,k)=>b+" ".repeat(Math.max(0,k-b.length)),f=i[0],p=f.some(b=>b.isHeader);let m=`
160
+ `;const g=new Array(o).fill(0).map((b,k)=>p&&f[k]&&f[k].text||"");return m+=`| ${g.map((b,k)=>u(b,l[k])).join(" | ")} |
161
+ `,m+=`| ${l.map(b=>"-".repeat(Math.max(3,b))).join(" | ")} |
162
+ `,(p?i.slice(1):i).forEach(b=>{m+=`| ${new Array(o).fill(0).map((k,w)=>u(b[w]&&b[w].text||"",l[w])).join(" | ")} |
163
+ `}),m}var CP=NP,AN=un.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:bP,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=xP(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",Nt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>CP(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=kP(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Ge.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>PD(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>BD(t,e),deleteColumn:()=>({state:t,dispatch:e})=>FD(t,e),addRowBefore:()=>({state:t,dispatch:e})=>UD(t,e),addRowAfter:()=>({state:t,dispatch:e})=>HD(t,e),deleteRow:()=>({state:t,dispatch:e})=>qD(t,e),deleteTable:()=>({state:t,dispatch:e})=>XD(t,e),mergeCells:()=>({state:t,dispatch:e})=>Qx(t,e),splitCell:()=>({state:t,dispatch:e})=>Xx(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>ul("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>ul("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>YD(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Qx(t,e)?!0:Xx(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>GD(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>e1(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>e1(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&kN(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Pt.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Kc,"Mod-Backspace":Kc,Delete:Kc,"Mod-Delete":Kc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[lP({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],yP({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:_t(qe(t,"tableRole",e))}}});bt.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(AN.configure(this.options.table)),this.options.tableCell!==!1&&t.push(CN.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(TN.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(MN.configure(this.options.tableRow)),t}});var TP=Object.defineProperty,MP=(t,e)=>{for(var n in e)TP(t,n,{get:e[n],enumerable:!0})},AP="listItem",u1="textStyle",d1=/^\s*([-+*])\s$/,ON=un.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",Nt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
164
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AP,this.editor.getAttributes(u1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=qo({find:d1,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=qo({find:d1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(u1),editor:this.editor})),[t]}}),RN=un.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Nt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>r0(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),OP={};MP(OP,{findListItemPos:()=>vl,getNextListDepth:()=>y0,handleBackspace:()=>kg,handleDelete:()=>Sg,hasListBefore:()=>jN,hasListItemAfter:()=>RP,hasListItemBefore:()=>IN,listItemHasSubList:()=>LN,nextListIsDeeper:()=>DN,nextListIsHigher:()=>PN});var vl=(t,e)=>{const{$from:n}=e.selection,r=an(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},y0=(t,e)=>{const n=vl(t,e);if(!n)return!1;const[,r]=gj(e,t,n.$pos.pos+4);return r},jN=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},IN=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},LN=(t,e,n)=>{if(!n)return!1;const r=an(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},kg=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ai(t.state,e)&&jN(t.state,e,n)){const{$anchor:l}=t.state.selection,u=t.state.doc.resolve(l.before()-1),f=[];u.node().descendants((g,y)=>{g.type.name===e&&f.push({node:g,pos:y})});const p=f.at(-1);if(!p)return!1;const m=t.state.doc.resolve(u.start()+p.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},m.end()).joinForward().run()}if(!ai(t.state,e)||!xj(t.state))return!1;const r=vl(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=LN(e,t.state,i);return IN(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},DN=(t,e)=>{const n=y0(t,e),r=vl(t,e);return!r||!n?!1:n>r.depth},PN=(t,e)=>{const n=y0(t,e),r=vl(t,e);return!r||!n?!1:n<r.depth},Sg=(t,e)=>{if(!ai(t.state,e)||!bj(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:DN(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():PN(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},RP=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},BN=bt.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Sg(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Sg(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&kg(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&kg(t,n,r)&&(e=!0)}),e}}}}),f1=/^(\s*)(\d+)\.\s+(.*)$/,jP=/^\s/;function IP(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(f1);if(!i)break;const[,o,l,u]=i,f=o.length;let p=u,m=n+1;const g=[s];for(;m<t.length;){const y=t[m];if(y.match(f1))break;if(y.trim()==="")g.push(y),p+=`
165
+ `,m+=1;else if(y.match(jP))g.push(y),p+=`
166
+ ${y.slice(f+2)}`,m+=1;else break}e.push({indent:f,number:parseInt(l,10),content:p.trim(),raw:g.join(`
167
+ `)}),r=m,n=m}return[e,r]}function zN(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const l=o.content.split(`
168
+ `),u=((r=l[0])==null?void 0:r.trim())||"",f=[];u&&f.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const p=l.slice(1).join(`
169
+ `).trim();if(p){const y=n.blockTokens(p);f.push(...y)}let m=i+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(k=>k.indent)),b=zN(g,y,n);f.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(k=>k.raw).join(`
170
+ `)})}s.push({type:"list_item",raw:o.raw,tokens:f}),i=m}else i+=1}return s}function LP(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var DP="listItem",h1="textStyle",p1=/^(\d+)\.\s$/,FN=un.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Nt(this.options.HTMLAttributes,n),0]:["ol",Nt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?LP(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
171
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
172
+ `),[i,o]=IP(s);if(i.length===0)return;const l=zN(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
173
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(DP,this.editor.getAttributes(h1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=qo({find:p1,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=qo({find:p1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(h1)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),PP=/^\s*(\[([( |x])?\])\s$/,$N=un.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Nt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return r0(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),u=document.createElement("div"),f=m=>{var g,y;l.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,l.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",m=>m.preventDefault()),l.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const b=n();if(typeof b!="number")return!1;const k=y.doc.nodeAt(b);return y.setNodeMarkup(b,void 0,{...k==null?void 0:k.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{s.setAttribute(m,g)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,u),Object.entries(e).forEach(([m,g])=>{s.setAttribute(m,g)});let p=new Set(Object.keys(e));return{dom:s,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;s.dataset.checked=m.attrs.checked,l.checked=m.attrs.checked,f(m);const g=r.extensionManager.attributes,y=al(m,g),b=new Set(Object.keys(y)),k=this.options.HTMLAttributes;return p.forEach(w=>{b.has(w)||(w in k?s.setAttribute(w,k[w]):s.removeAttribute(w))}),Object.entries(y).forEach(([w,E])=>{E==null?w in k?s.setAttribute(w,k[w]):s.removeAttribute(w):s.setAttribute(w,E)}),p=b,!0}}}},addInputRules(){return[qo({find:PP,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),UN=un.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Nt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
174
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=og(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,u)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:u}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=og(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});bt.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(ON.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(RN.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(BN.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(FN.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push($N.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(UN.configure(this.options.taskList)),t}});var BP=$N,zP=UN,FP=20,HN=(t,e=0)=>{const n=[];return!t.children.length||e>FP||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...HN(r,e+1))}),n},$P=t=>{if(!t.children.length)return;const e=HN(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},WN=Dr.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&$P(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Nt(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),UP=bt.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),HP=bt.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),WP=bt.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),qP=bt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),VP=bt.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});bt.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(UP.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(HP.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(WP.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(qP.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(VP.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(WN.configure(this.options.textStyle)),t}});var KP=t=>Xt({find:/--$/,replace:t??"—"}),GP=t=>Xt({find:/\.\.\.$/,replace:t??"…"}),JP=t=>Xt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),YP=t=>Xt({find:/"$/,replace:t??"”"}),QP=t=>Xt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),XP=t=>Xt({find:/'$/,replace:t??"’"}),ZP=t=>Xt({find:/<-$/,replace:t??"←"}),e3=t=>Xt({find:/->$/,replace:t??"→"}),t3=t=>Xt({find:/\(c\)$/,replace:t??"©"}),n3=t=>Xt({find:/\(tm\)$/,replace:t??"™"}),r3=t=>Xt({find:/\(sm\)$/,replace:t??"℠"}),s3=t=>Xt({find:/\(r\)$/,replace:t??"®"}),i3=t=>Xt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),o3=t=>Xt({find:/\+\/-$/,replace:t??"±"}),a3=t=>Xt({find:/!=$/,replace:t??"≠"}),l3=t=>Xt({find:/<<$/,replace:t??"«"}),c3=t=>Xt({find:/>>$/,replace:t??"»"}),u3=t=>Xt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),d3=t=>Xt({find:/\^2$/,replace:t??"²"}),f3=t=>Xt({find:/\^3$/,replace:t??"³"}),h3=t=>Xt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),p3=t=>Xt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),m3=bt.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(KP(this.options.emDash)),this.options.ellipsis!==!1&&t.push(GP(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(JP(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(YP(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(QP(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(XP(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(ZP(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(e3(this.options.rightArrow)),this.options.copyright!==!1&&t.push(t3(this.options.copyright)),this.options.trademark!==!1&&t.push(n3(this.options.trademark)),this.options.servicemark!==!1&&t.push(r3(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(s3(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(i3(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(o3(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(a3(this.options.notEqual)),this.options.laquo!==!1&&t.push(l3(this.options.laquo)),this.options.raquo!==!1&&t.push(c3(this.options.raquo)),this.options.multiplication!==!1&&t.push(u3(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(d3(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(f3(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(h3(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(p3(this.options.threeQuarters)),t}}),g3=m3,qN=Dr.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Nt(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),v3=qN,En=[];for(var np=0;np<256;++np)En.push((np+256).toString(16).slice(1));function y3(t,e=0){return(En[t[e+0]]+En[t[e+1]]+En[t[e+2]]+En[t[e+3]]+"-"+En[t[e+4]]+En[t[e+5]]+"-"+En[t[e+6]]+En[t[e+7]]+"-"+En[t[e+8]]+En[t[e+9]]+"-"+En[t[e+10]]+En[t[e+11]]+En[t[e+12]]+En[t[e+13]]+En[t[e+14]]+En[t[e+15]]).toLowerCase()}var Gc,b3=new Uint8Array(16);function x3(){if(!Gc&&(Gc=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Gc))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Gc(b3)}var w3=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const m1={randomUUID:w3};function k3(t,e,n){if(m1.randomUUID&&!t)return m1.randomUUID();t=t||{};var r=t.random||(t.rng||x3)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,y3(r)}function S3(t){const e=new Set,n=new Set;return t.forEach(r=>{e.has(r)?n.add(r):e.add(r)}),Array.from(n)}var E3=bt.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>k3(),filterTransaction:null,updateDocument:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>t[this.options.attributeName]?{[`data-${this.options.attributeName}`]:t[this.options.attributeName]}:{}}}}]},onCreate(){var t;if(!this.options.updateDocument)return;const e=this.editor.extensionManager.extensions.find(l=>l.name==="collaboration"),n=this.editor.extensionManager.extensions.find(l=>l.name==="collaborationCaret"),s=[e,n].filter(Boolean).find(l=>{var u;return(u=l==null?void 0:l.options)==null?void 0:u.provider}),i=(t=s==null?void 0:s.options)==null?void 0:t.provider,o=()=>{const{view:l,state:u}=this.editor,{tr:f,doc:p}=u,{types:m,attributeName:g,generateID:y}=this.options;Cu(p,k=>m.includes(k.type.name)&&k.attrs[g]===null).forEach(({node:k,pos:w})=>{f.setNodeMarkup(w,void 0,{...k.attrs,[g]:y({node:k,pos:w})})}),f.setMeta("addToHistory",!1),l.dispatch(f),i&&i.off("synced",o)};if(s){if(!i)return o();i.on("synced",o)}else return o()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new Ct({key:new jt("uniqueID"),appendTransaction:(n,r,s)=>{const i=n.some(k=>k.docChanged)&&!r.doc.eq(s.doc),o=this.options.filterTransaction&&n.some(k=>{var w,E;return!((E=(w=this.options).filterTransaction)!=null&&E.call(w,k))});if(n.find(k=>k.getMeta("y-sync$"))||!i||o)return;const{tr:u}=s,{types:f,attributeName:p,generateID:m}=this.options,g=Jg(r.doc,n),{mapping:y}=g;if(Xg(g).forEach(({newRange:k})=>{const w=E_(s.doc,k,N=>f.includes(N.type.name)),E=w.map(({node:N})=>N.attrs[p]).filter(N=>N!==null);w.forEach(({node:N,pos:O},T)=>{var C;const R=(C=u.doc.nodeAt(O))==null?void 0:C.attrs[p];if(R===null){u.setNodeMarkup(O,void 0,{...N.attrs,[p]:m({node:N,pos:O})});return}const L=w[T+1];if(L&&N.content.size===0){const J=u.doc.nodeAt(L.pos);if(J!=null&&J.attrs[p]&&J.attrs[p]!==R)return;u.setNodeMarkup(L.pos,void 0,{...L.node.attrs,[p]:R}),E[T+1]=R;const K=m({node:N,pos:O});return u.setNodeMarkup(O,void 0,{...N.attrs,[p]:K}),E[T]=K,u}const D=S3(E),{deleted:z}=y.invert().mapResult(O);z&&D.includes(R)&&u.setNodeMarkup(O,void 0,{...N.attrs,[p]:m({node:N,pos:O})})})}),!!u.steps.length)return u.setStoredMarks(s.tr.storedMarks),u.setMeta("__uniqueIDTransaction",!0),u},view(n){const r=s=>{var i;t=(i=n.dom.parentElement)!=null&&i.contains(s.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var s,i;return(t!==n.dom.parentElement||((s=r.dataTransfer)==null?void 0:s.effectAllowed)==="copyMove"||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:s}=this.options,i=o=>{const l=[];return o.forEach(u=>{if(u.isText){l.push(u);return}if(!r.includes(u.type.name)){l.push(u.copy(i(u.content)));return}const f=u.type.create({...u.attrs,[s]:null},i(u.content),u.marks);l.push(f)}),de.from(l)};return e=!1,new _e(i(n.content),n.openStart,n.openEnd)}}})]}}),b0=E3,sd=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},_3=/^\s*>\s$/,N3=un.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return sd("blockquote",{...Nt(this.options.HTMLAttributes,t),children:sd("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const l=e.renderChildren([s]).split(`
175
+ `).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(l.join(`
176
+ `))}),r.join(`
177
+ ${n}
178
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[qo({find:_3,type:this.type})]}}),C3=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,T3=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,M3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,A3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,O3=Dr.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return sd("strong",{...Nt(this.options.HTMLAttributes,t),children:sd("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Gi({find:C3,type:this.type}),Gi({find:M3,type:this.type})]},addPasteRules(){return[li({find:T3,type:this.type}),li({find:A3,type:this.type})]}}),R3=/(^|[^`])`([^`]+)`(?!`)$/,j3=/(^|[^`])`([^`]+)`(?!`)/g,I3=Dr.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Nt(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Gi({find:R3,type:this.type})]},addPasteRules(){return[li({find:j3,type:this.type})]}}),rp=4,L3=/^```([a-z]+)?[\s\n]$/,D3=/^~~~([a-z]+)?[\s\n]$/,VN=un.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:rp,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Nt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
179
+ `):r=`\`\`\`${s}
180
+
181
+ \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:rp,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:u})=>{const{from:f,to:p}=s,y=r.doc.textBetween(f,p,`
182
+ `,`
183
+ `).split(`
184
+ `).map(b=>l+b).join(`
185
+ `);return u.replaceWith(f,p,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:rp,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var u;const{pos:f}=i,p=i.start(),m=i.end(),y=r.doc.textBetween(p,m,`
186
+ `,`
187
+ `).split(`
188
+ `);let b=0,k=0;const w=f-p;for(let R=0;R<y.length;R+=1){if(k+y[R].length>=w){b=R;break}k+=y[R].length+1}const N=((u=y[b].match(/^ */))==null?void 0:u[0])||"",O=Math.min(N.length,n);if(O===0)return!0;let T=p;for(let R=0;R<b;R+=1)T+=y[R].length+1;return l.delete(T,T+O),f-T<=O&&l.setSelection(Ge.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:u,to:f}=s,g=r.doc.textBetween(u,f,`
189
+ `,`
190
+ `).split(`
191
+ `).map(y=>{var b;const k=((b=y.match(/^ */))==null?void 0:b[0])||"",w=Math.min(k.length,n);return y.slice(w)}).join(`
192
+ `);return l.replaceWith(u,f,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
193
+
194
+ `);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:f})=>(f.setSelection(it.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[ig({find:L3,type:this.type,getAttributes:t=>({language:t[1]})}),ig({find:D3,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ct({key:new jt("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,u=l.text(n.replace(/\r\n?/g,`
195
+ `));return o.replaceSelectionWith(this.type.create({language:i},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(Ge.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),P3=VN,B3=un.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
196
+
197
+ `):""}),z3=un.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Nt(this.options.HTMLAttributes,t)]},renderText(){return`
198
+ `},renderMarkdown:()=>`
199
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,u=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:p})=>{if(p&&u&&o){const m=u.filter(g=>l.includes(g.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),F3=un.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Nt(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>ig({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),$3=un.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Nt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!aI(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return R_(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:u}=o.selection,f=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(Ge.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Ke.create(o.doc,u.pos)):o.setSelection(Ge.create(o.doc,u.pos));else{const p=i.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=p==null?void 0:p.create();m&&(o.insert(f,m),o.setSelection(Ge.create(o.doc,f+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[J_({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),U3=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,H3=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,W3=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,q3=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,V3=Dr.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Nt(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Gi({find:U3,type:this.type}),Gi({find:W3,type:this.type})]},addPasteRules(){return[li({find:H3,type:this.type}),li({find:q3,type:this.type})]}}),g1="&nbsp;",K3=" ",G3=un.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Nt(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===g1||r[0].text===K3)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?g1:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),J3=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Y3=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Q3=Dr.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Nt(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Gi({find:J3,type:this.type})]},addPasteRules(){return[li({find:Y3,type:this.type})]}}),X3=un.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Z3=bt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(O3.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(N3.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(ON.configure(this.options.bulletList)),this.options.code!==!1&&s.push(I3.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(VN.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(B3.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(fD.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(hD.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(z3.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(F3.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(vD.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push($3.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(V3.configure(this.options.italic)),this.options.listItem!==!1&&s.push(RN.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(BN.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(fN.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(FN.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(G3.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(Q3.configure(this.options.strike)),this.options.text!==!1&&s.push(X3.configure(this.options.text)),this.options.underline!==!1&&s.push(qN.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(gD.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),x0=Z3,sp,v1;function e4(){if(v1)return sp;v1=1;function t(B){return B instanceof Map?B.clear=B.delete=B.set=function(){throw new Error("map is read-only")}:B instanceof Set&&(B.add=B.clear=B.delete=function(){throw new Error("set is read-only")}),Object.freeze(B),Object.getOwnPropertyNames(B).forEach(se=>{const Se=B[se],st=typeof Se;(st==="object"||st==="function")&&!Object.isFrozen(Se)&&t(Se)}),B}class e{constructor(se){se.data===void 0&&(se.data={}),this.data=se.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(B){return B.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(B,...se){const Se=Object.create(null);for(const st in B)Se[st]=B[st];return se.forEach(function(st){for(const Mt in st)Se[Mt]=st[Mt]}),Se}const s="</span>",i=B=>!!B.scope,o=(B,{prefix:se})=>{if(B.startsWith("language:"))return B.replace("language:","language-");if(B.includes(".")){const Se=B.split(".");return[`${se}${Se.shift()}`,...Se.map((st,Mt)=>`${st}${"_".repeat(Mt+1)}`)].join(" ")}return`${se}${B}`};class l{constructor(se,Se){this.buffer="",this.classPrefix=Se.classPrefix,se.walk(this)}addText(se){this.buffer+=n(se)}openNode(se){if(!i(se))return;const Se=o(se.scope,{prefix:this.classPrefix});this.span(Se)}closeNode(se){i(se)&&(this.buffer+=s)}value(){return this.buffer}span(se){this.buffer+=`<span class="${se}">`}}const u=(B={})=>{const se={children:[]};return Object.assign(se,B),se};class f{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(se){this.top.children.push(se)}openNode(se){const Se=u({scope:se});this.add(Se),this.stack.push(Se)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(se){return this.constructor._walk(se,this.rootNode)}static _walk(se,Se){return typeof Se=="string"?se.addText(Se):Se.children&&(se.openNode(Se),Se.children.forEach(st=>this._walk(se,st)),se.closeNode(Se)),se}static _collapse(se){typeof se!="string"&&se.children&&(se.children.every(Se=>typeof Se=="string")?se.children=[se.children.join("")]:se.children.forEach(Se=>{f._collapse(Se)}))}}class p extends f{constructor(se){super(),this.options=se}addText(se){se!==""&&this.add(se)}startScope(se){this.openNode(se)}endScope(){this.closeNode()}__addSublanguage(se,Se){const st=se.root;Se&&(st.scope=`language:${Se}`),this.add(st)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(B){return B?typeof B=="string"?B:B.source:null}function g(B){return k("(?=",B,")")}function y(B){return k("(?:",B,")*")}function b(B){return k("(?:",B,")?")}function k(...B){return B.map(Se=>m(Se)).join("")}function w(B){const se=B[B.length-1];return typeof se=="object"&&se.constructor===Object?(B.splice(B.length-1,1),se):{}}function E(...B){return"("+(w(B).capture?"":"?:")+B.map(st=>m(st)).join("|")+")"}function N(B){return new RegExp(B.toString()+"|").exec("").length-1}function O(B,se){const Se=B&&B.exec(se);return Se&&Se.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function C(B,{joinWith:se}){let Se=0;return B.map(st=>{Se+=1;const Mt=Se;let Ot=m(st),Ie="";for(;Ot.length>0;){const Re=T.exec(Ot);if(!Re){Ie+=Ot;break}Ie+=Ot.substring(0,Re.index),Ot=Ot.substring(Re.index+Re[0].length),Re[0][0]==="\\"&&Re[1]?Ie+="\\"+String(Number(Re[1])+Mt):(Ie+=Re[0],Re[0]==="("&&Se++)}return Ie}).map(st=>`(${st})`).join(se)}const R=/\b\B/,L="[a-zA-Z]\\w*",D="[a-zA-Z_]\\w*",z="\\b\\d+(\\.\\d+)?",F="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",J="\\b(0b[01]+)",K="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",X=(B={})=>{const se=/^#![ ]*\//;return B.binary&&(B.begin=k(se,/.*\b/,B.binary,/\b.*/)),r({scope:"meta",begin:se,end:/$/,relevance:0,"on:begin":(Se,st)=>{Se.index!==0&&st.ignoreMatch()}},B)},W={begin:"\\\\[\\s\\S]",relevance:0},$={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[W]},U={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[W]},Z={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},V=function(B,se,Se={}){const st=r({scope:"comment",begin:B,end:se,contains:[]},Se);st.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Mt=E("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return st.contains.push({begin:k(/[ ]+/,"(",Mt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),st},Y=V("//","$"),I=V("/\\*","\\*/"),A=V("#","$"),j={scope:"number",begin:z,relevance:0},Q={scope:"number",begin:F,relevance:0},oe={scope:"number",begin:J,relevance:0},fe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[W,{begin:/\[/,end:/\]/,relevance:0,contains:[W]}]},G={scope:"title",begin:L,relevance:0},le={scope:"title",begin:D,relevance:0},Te={begin:"\\.\\s*"+D,relevance:0};var ce=Object.freeze({__proto__:null,APOS_STRING_MODE:$,BACKSLASH_ESCAPE:W,BINARY_NUMBER_MODE:oe,BINARY_NUMBER_RE:J,COMMENT:V,C_BLOCK_COMMENT_MODE:I,C_LINE_COMMENT_MODE:Y,C_NUMBER_MODE:Q,C_NUMBER_RE:F,END_SAME_AS_BEGIN:function(B){return Object.assign(B,{"on:begin":(se,Se)=>{Se.data._beginMatch=se[1]},"on:end":(se,Se)=>{Se.data._beginMatch!==se[1]&&Se.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:L,MATCH_NOTHING_RE:R,METHOD_GUARD:Te,NUMBER_MODE:j,NUMBER_RE:z,PHRASAL_WORDS_MODE:Z,QUOTE_STRING_MODE:U,REGEXP_MODE:fe,RE_STARTERS_RE:K,SHEBANG:X,TITLE_MODE:G,UNDERSCORE_IDENT_RE:D,UNDERSCORE_TITLE_MODE:le});function ue(B,se){B.input[B.index-1]==="."&&se.ignoreMatch()}function ae(B,se){B.className!==void 0&&(B.scope=B.className,delete B.className)}function je(B,se){se&&B.beginKeywords&&(B.begin="\\b("+B.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",B.__beforeBegin=ue,B.keywords=B.keywords||B.beginKeywords,delete B.beginKeywords,B.relevance===void 0&&(B.relevance=0))}function Me(B,se){Array.isArray(B.illegal)&&(B.illegal=E(...B.illegal))}function He(B,se){if(B.match){if(B.begin||B.end)throw new Error("begin & end are not supported with match");B.begin=B.match,delete B.match}}function Ne(B,se){B.relevance===void 0&&(B.relevance=1)}const tt=(B,se)=>{if(!B.beforeMatch)return;if(B.starts)throw new Error("beforeMatch cannot be used with starts");const Se=Object.assign({},B);Object.keys(B).forEach(st=>{delete B[st]}),B.keywords=Se.keywords,B.begin=k(Se.beforeMatch,g(Se.begin)),B.starts={relevance:0,contains:[Object.assign(Se,{endsParent:!0})]},B.relevance=0,delete Se.beforeMatch},Be=["of","and","for","in","not","or","if","then","parent","list","value"],$e="keyword";function ye(B,se,Se=$e){const st=Object.create(null);return typeof B=="string"?Mt(Se,B.split(" ")):Array.isArray(B)?Mt(Se,B):Object.keys(B).forEach(function(Ot){Object.assign(st,ye(B[Ot],se,Ot))}),st;function Mt(Ot,Ie){se&&(Ie=Ie.map(Re=>Re.toLowerCase())),Ie.forEach(function(Re){const Ye=Re.split("|");st[Ye[0]]=[Ot,pe(Ye[0],Ye[1])]})}}function pe(B,se){return se?Number(se):Ze(B)?0:1}function Ze(B){return Be.includes(B.toLowerCase())}const Ae={},be=B=>{console.error(B)},ke=(B,...se)=>{console.log(`WARN: ${B}`,...se)},ze=(B,se)=>{Ae[`${B}/${se}`]||(console.log(`Deprecated as of ${B}. ${se}`),Ae[`${B}/${se}`]=!0)},ht=new Error;function wt(B,se,{key:Se}){let st=0;const Mt=B[Se],Ot={},Ie={};for(let Re=1;Re<=se.length;Re++)Ie[Re+st]=Mt[Re],Ot[Re+st]=!0,st+=N(se[Re-1]);B[Se]=Ie,B[Se]._emit=Ot,B[Se]._multi=!0}function kt(B){if(Array.isArray(B.begin)){if(B.skip||B.excludeBegin||B.returnBegin)throw be("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ht;if(typeof B.beginScope!="object"||B.beginScope===null)throw be("beginScope must be object"),ht;wt(B,B.begin,{key:"beginScope"}),B.begin=C(B.begin,{joinWith:""})}}function Bt(B){if(Array.isArray(B.end)){if(B.skip||B.excludeEnd||B.returnEnd)throw be("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ht;if(typeof B.endScope!="object"||B.endScope===null)throw be("endScope must be object"),ht;wt(B,B.end,{key:"endScope"}),B.end=C(B.end,{joinWith:""})}}function xn(B){B.scope&&typeof B.scope=="object"&&B.scope!==null&&(B.beginScope=B.scope,delete B.scope)}function An(B){xn(B),typeof B.beginScope=="string"&&(B.beginScope={_wrap:B.beginScope}),typeof B.endScope=="string"&&(B.endScope={_wrap:B.endScope}),kt(B),Bt(B)}function On(B){function se(Ie,Re){return new RegExp(m(Ie),"m"+(B.case_insensitive?"i":"")+(B.unicodeRegex?"u":"")+(Re?"g":""))}class Se{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Re,Ye){Ye.position=this.position++,this.matchIndexes[this.matchAt]=Ye,this.regexes.push([Ye,Re]),this.matchAt+=N(Re)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Re=this.regexes.map(Ye=>Ye[1]);this.matcherRe=se(C(Re,{joinWith:"|"}),!0),this.lastIndex=0}exec(Re){this.matcherRe.lastIndex=this.lastIndex;const Ye=this.matcherRe.exec(Re);if(!Ye)return null;const rn=Ye.findIndex((Fr,Es)=>Es>0&&Fr!==void 0),It=this.matchIndexes[rn];return Ye.splice(0,rn),Object.assign(Ye,It)}}class st{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Re){if(this.multiRegexes[Re])return this.multiRegexes[Re];const Ye=new Se;return this.rules.slice(Re).forEach(([rn,It])=>Ye.addRule(rn,It)),Ye.compile(),this.multiRegexes[Re]=Ye,Ye}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Re,Ye){this.rules.push([Re,Ye]),Ye.type==="begin"&&this.count++}exec(Re){const Ye=this.getMatcher(this.regexIndex);Ye.lastIndex=this.lastIndex;let rn=Ye.exec(Re);if(this.resumingScanAtSamePosition()&&!(rn&&rn.index===this.lastIndex)){const It=this.getMatcher(0);It.lastIndex=this.lastIndex+1,rn=It.exec(Re)}return rn&&(this.regexIndex+=rn.position+1,this.regexIndex===this.count&&this.considerAll()),rn}}function Mt(Ie){const Re=new st;return Ie.contains.forEach(Ye=>Re.addRule(Ye.begin,{rule:Ye,type:"begin"})),Ie.terminatorEnd&&Re.addRule(Ie.terminatorEnd,{type:"end"}),Ie.illegal&&Re.addRule(Ie.illegal,{type:"illegal"}),Re}function Ot(Ie,Re){const Ye=Ie;if(Ie.isCompiled)return Ye;[ae,He,An,tt].forEach(It=>It(Ie,Re)),B.compilerExtensions.forEach(It=>It(Ie,Re)),Ie.__beforeBegin=null,[je,Me,Ne].forEach(It=>It(Ie,Re)),Ie.isCompiled=!0;let rn=null;return typeof Ie.keywords=="object"&&Ie.keywords.$pattern&&(Ie.keywords=Object.assign({},Ie.keywords),rn=Ie.keywords.$pattern,delete Ie.keywords.$pattern),rn=rn||/\w+/,Ie.keywords&&(Ie.keywords=ye(Ie.keywords,B.case_insensitive)),Ye.keywordPatternRe=se(rn,!0),Re&&(Ie.begin||(Ie.begin=/\B|\b/),Ye.beginRe=se(Ye.begin),!Ie.end&&!Ie.endsWithParent&&(Ie.end=/\B|\b/),Ie.end&&(Ye.endRe=se(Ye.end)),Ye.terminatorEnd=m(Ye.end)||"",Ie.endsWithParent&&Re.terminatorEnd&&(Ye.terminatorEnd+=(Ie.end?"|":"")+Re.terminatorEnd)),Ie.illegal&&(Ye.illegalRe=se(Ie.illegal)),Ie.contains||(Ie.contains=[]),Ie.contains=[].concat(...Ie.contains.map(function(It){return re(It==="self"?Ie:It)})),Ie.contains.forEach(function(It){Ot(It,Ye)}),Ie.starts&&Ot(Ie.starts,Re),Ye.matcher=Mt(Ye),Ye}if(B.compilerExtensions||(B.compilerExtensions=[]),B.contains&&B.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return B.classNameAliases=r(B.classNameAliases||{}),Ot(B)}function wn(B){return B?B.endsWithParent||wn(B.starts):!1}function re(B){return B.variants&&!B.cachedVariants&&(B.cachedVariants=B.variants.map(function(se){return r(B,{variants:null},se)})),B.cachedVariants?B.cachedVariants:wn(B)?r(B,{starts:B.starts?r(B.starts):null}):Object.isFrozen(B)?r(B):B}var Je="11.11.1";class et extends Error{constructor(se,Se){super(se),this.name="HTMLInjectionError",this.html=Se}}const Et=n,rt=r,nt=Symbol("nomatch"),ee=7,Ce=function(B){const se=Object.create(null),Se=Object.create(null),st=[];let Mt=!0;const Ot="Could not find the language '{}', did you forget to load/include a language module?",Ie={disableAutodetect:!0,name:"Plain text",contains:[]};let Re={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ye(xe){return Re.noHighlightRe.test(xe)}function rn(xe){let We=xe.className+" ";We+=xe.parentNode?xe.parentNode.className:"";const ut=Re.languageDetectRe.exec(We);if(ut){const mt=_r(ut[1]);return mt||(ke(Ot.replace("{}",ut[1])),ke("Falling back to no-highlight mode for this block.",xe)),mt?ut[1]:"no-highlight"}return We.split(/\s+/).find(mt=>Ye(mt)||_r(mt))}function It(xe,We,ut){let mt="",Zt="";typeof We=="object"?(mt=xe,ut=We.ignoreIllegals,Zt=We.language):(ze("10.7.0","highlight(lang, code, ...args) has been deprecated."),ze("10.7.0",`Please use highlight(code, options) instead.
200
+ https://github.com/highlightjs/highlight.js/issues/2277`),Zt=xe,mt=We),ut===void 0&&(ut=!0);const Wt={code:mt,language:Zt};mi("before:highlight",Wt);const $r=Wt.result?Wt.result:Fr(Wt.language,Wt.code,ut);return $r.code=Wt.code,mi("after:highlight",$r),$r}function Fr(xe,We,ut,mt){const Zt=Object.create(null);function Wt(Ee,Le){return Ee.keywords[Le]}function $r(){if(!ct.keywords){en.addText(Tt);return}let Ee=0;ct.keywordPatternRe.lastIndex=0;let Le=ct.keywordPatternRe.exec(Tt),ot="";for(;Le;){ot+=Tt.substring(Ee,Le.index);const gt=ur.case_insensitive?Le[0].toLowerCase():Le[0],Kt=Wt(ct,gt);if(Kt){const[dn,Wd]=Kt;if(en.addText(ot),ot="",Zt[gt]=(Zt[gt]||0)+1,Zt[gt]<=ee&&(yi+=Wd),dn.startsWith("_"))ot+=Le[0];else{const Al=ur.classNameAliases[dn]||dn;$n(Le[0],Al)}}else ot+=Le[0];Ee=ct.keywordPatternRe.lastIndex,Le=ct.keywordPatternRe.exec(Tt)}ot+=Tt.substring(Ee),en.addText(ot)}function so(){if(Tt==="")return;let Ee=null;if(typeof ct.subLanguage=="string"){if(!se[ct.subLanguage]){en.addText(Tt);return}Ee=Fr(ct.subLanguage,Tt,!0,ta[ct.subLanguage]),ta[ct.subLanguage]=Ee._top}else Ee=pi(Tt,ct.subLanguage.length?ct.subLanguage:null);ct.relevance>0&&(yi+=Ee.relevance),en.__addSublanguage(Ee._emitter,Ee.language)}function Fn(){ct.subLanguage!=null?so():$r(),Tt=""}function $n(Ee,Le){Ee!==""&&(en.startScope(Le),en.addText(Ee),en.endScope())}function gi(Ee,Le){let ot=1;const gt=Le.length-1;for(;ot<=gt;){if(!Ee._emit[ot]){ot++;continue}const Kt=ur.classNameAliases[Ee[ot]]||Ee[ot],dn=Le[ot];Kt?$n(dn,Kt):(Tt=dn,$r(),Tt=""),ot++}}function _s(Ee,Le){return Ee.scope&&typeof Ee.scope=="string"&&en.openNode(ur.classNameAliases[Ee.scope]||Ee.scope),Ee.beginScope&&(Ee.beginScope._wrap?($n(Tt,ur.classNameAliases[Ee.beginScope._wrap]||Ee.beginScope._wrap),Tt=""):Ee.beginScope._multi&&(gi(Ee.beginScope,Le),Tt="")),ct=Object.create(Ee,{parent:{value:ct}}),ct}function vi(Ee,Le,ot){let gt=O(Ee.endRe,ot);if(gt){if(Ee["on:end"]){const Kt=new e(Ee);Ee["on:end"](Le,Kt),Kt.isMatchIgnored&&(gt=!1)}if(gt){for(;Ee.endsParent&&Ee.parent;)Ee=Ee.parent;return Ee}}if(Ee.endsWithParent)return vi(Ee.parent,Le,ot)}function Ud(Ee){return ct.matcher.regexIndex===0?(Tt+=Ee[0],1):(Ts=!0,0)}function Hd(Ee){const Le=Ee[0],ot=Ee.rule,gt=new e(ot),Kt=[ot.__beforeBegin,ot["on:begin"]];for(const dn of Kt)if(dn&&(dn(Ee,gt),gt.isMatchIgnored))return Ud(Le);return ot.skip?Tt+=Le:(ot.excludeBegin&&(Tt+=Le),Fn(),!ot.returnBegin&&!ot.excludeBegin&&(Tt=Le)),_s(ot,Ee),ot.returnBegin?0:Le.length}function Zo(Ee){const Le=Ee[0],ot=We.substring(Ee.index),gt=vi(ct,Ee,ot);if(!gt)return nt;const Kt=ct;ct.endScope&&ct.endScope._wrap?(Fn(),$n(Le,ct.endScope._wrap)):ct.endScope&&ct.endScope._multi?(Fn(),gi(ct.endScope,Ee)):Kt.skip?Tt+=Le:(Kt.returnEnd||Kt.excludeEnd||(Tt+=Le),Fn(),Kt.excludeEnd&&(Tt=Le));do ct.scope&&en.closeNode(),!ct.skip&&!ct.subLanguage&&(yi+=ct.relevance),ct=ct.parent;while(ct!==gt.parent);return gt.starts&&_s(gt.starts,Ee),Kt.returnEnd?0:Le.length}function Ml(){const Ee=[];for(let Le=ct;Le!==ur;Le=Le.parent)Le.scope&&Ee.unshift(Le.scope);Ee.forEach(Le=>en.openNode(Le))}let Ns={};function Cs(Ee,Le){const ot=Le&&Le[0];if(Tt+=Ee,ot==null)return Fn(),0;if(Ns.type==="begin"&&Le.type==="end"&&Ns.index===Le.index&&ot===""){if(Tt+=We.slice(Le.index,Le.index+1),!Mt){const gt=new Error(`0 width match regex (${xe})`);throw gt.languageName=xe,gt.badRule=Ns.rule,gt}return 1}if(Ns=Le,Le.type==="begin")return Hd(Le);if(Le.type==="illegal"&&!ut){const gt=new Error('Illegal lexeme "'+ot+'" for mode "'+(ct.scope||"<unnamed>")+'"');throw gt.mode=ct,gt}else if(Le.type==="end"){const gt=Zo(Le);if(gt!==nt)return gt}if(Le.type==="illegal"&&ot==="")return Tt+=`
201
+ `,1;if(bi>1e5&&bi>Le.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Tt+=ot,ot.length}const ur=_r(xe);if(!ur)throw be(Ot.replace("{}",xe)),new Error('Unknown language: "'+xe+'"');const ea=On(ur);let vt="",ct=mt||ea;const ta={},en=new Re.__emitter(Re);Ml();let Tt="",yi=0,Ur=0,bi=0,Ts=!1;try{if(ur.__emitTokens)ur.__emitTokens(We,en);else{for(ct.matcher.considerAll();;){bi++,Ts?Ts=!1:ct.matcher.considerAll(),ct.matcher.lastIndex=Ur;const Ee=ct.matcher.exec(We);if(!Ee)break;const Le=We.substring(Ur,Ee.index),ot=Cs(Le,Ee);Ur=Ee.index+ot}Cs(We.substring(Ur))}return en.finalize(),vt=en.toHTML(),{language:xe,value:vt,relevance:yi,illegal:!1,_emitter:en,_top:ct}}catch(Ee){if(Ee.message&&Ee.message.includes("Illegal"))return{language:xe,value:Et(We),illegal:!0,relevance:0,_illegalBy:{message:Ee.message,index:Ur,context:We.slice(Ur-100,Ur+100),mode:Ee.mode,resultSoFar:vt},_emitter:en};if(Mt)return{language:xe,value:Et(We),illegal:!1,relevance:0,errorRaised:Ee,_emitter:en,_top:ct};throw Ee}}function Es(xe){const We={value:Et(xe),illegal:!1,relevance:0,_top:Ie,_emitter:new Re.__emitter(Re)};return We._emitter.addText(xe),We}function pi(xe,We){We=We||Re.languages||Object.keys(se);const ut=Es(xe),mt=We.filter(_r).filter(Tl).map(Fn=>Fr(Fn,xe,!1));mt.unshift(ut);const Zt=mt.sort((Fn,$n)=>{if(Fn.relevance!==$n.relevance)return $n.relevance-Fn.relevance;if(Fn.language&&$n.language){if(_r(Fn.language).supersetOf===$n.language)return 1;if(_r($n.language).supersetOf===Fn.language)return-1}return 0}),[Wt,$r]=Zt,so=Wt;return so.secondBest=$r,so}function zd(xe,We,ut){const mt=We&&Se[We]||ut;xe.classList.add("hljs"),xe.classList.add(`language-${mt}`)}function Yo(xe){let We=null;const ut=rn(xe);if(Ye(ut))return;if(mi("before:highlightElement",{el:xe,language:ut}),xe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",xe);return}if(xe.children.length>0&&(Re.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(xe)),Re.throwUnescapedHTML))throw new et("One of your code blocks includes unescaped HTML.",xe.innerHTML);We=xe;const mt=We.textContent,Zt=ut?It(mt,{language:ut,ignoreIllegals:!0}):pi(mt);xe.innerHTML=Zt.value,xe.dataset.highlighted="yes",zd(xe,ut,Zt.language),xe.result={language:Zt.language,re:Zt.relevance,relevance:Zt.relevance},Zt.secondBest&&(xe.secondBest={language:Zt.secondBest.language,relevance:Zt.secondBest.relevance}),mi("after:highlightElement",{el:xe,result:Zt,text:mt})}function Fd(xe){Re=rt(Re,xe)}const es=()=>{no(),ze("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Sl(){no(),ze("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Qo=!1;function no(){function xe(){no()}if(document.readyState==="loading"){Qo||window.addEventListener("DOMContentLoaded",xe,!1),Qo=!0;return}document.querySelectorAll(Re.cssSelector).forEach(Yo)}function El(xe,We){let ut=null;try{ut=We(B)}catch(mt){if(be("Language definition for '{}' could not be registered.".replace("{}",xe)),Mt)be(mt);else throw mt;ut=Ie}ut.name||(ut.name=xe),se[xe]=ut,ut.rawDefinition=We.bind(null,B),ut.aliases&&Cl(ut.aliases,{languageName:xe})}function _l(xe){delete se[xe];for(const We of Object.keys(Se))Se[We]===xe&&delete Se[We]}function Nl(){return Object.keys(se)}function _r(xe){return xe=(xe||"").toLowerCase(),se[xe]||se[Se[xe]]}function Cl(xe,{languageName:We}){typeof xe=="string"&&(xe=[xe]),xe.forEach(ut=>{Se[ut.toLowerCase()]=We})}function Tl(xe){const We=_r(xe);return We&&!We.disableAutodetect}function Ht(xe){xe["before:highlightBlock"]&&!xe["before:highlightElement"]&&(xe["before:highlightElement"]=We=>{xe["before:highlightBlock"](Object.assign({block:We.el},We))}),xe["after:highlightBlock"]&&!xe["after:highlightElement"]&&(xe["after:highlightElement"]=We=>{xe["after:highlightBlock"](Object.assign({block:We.el},We))})}function $d(xe){Ht(xe),st.push(xe)}function Xo(xe){const We=st.indexOf(xe);We!==-1&&st.splice(We,1)}function mi(xe,We){const ut=xe;st.forEach(function(mt){mt[ut]&&mt[ut](We)})}function ro(xe){return ze("10.7.0","highlightBlock will be removed entirely in v12.0"),ze("10.7.0","Please use highlightElement now."),Yo(xe)}Object.assign(B,{highlight:It,highlightAuto:pi,highlightAll:no,highlightElement:Yo,highlightBlock:ro,configure:Fd,initHighlighting:es,initHighlightingOnLoad:Sl,registerLanguage:El,unregisterLanguage:_l,listLanguages:Nl,getLanguage:_r,registerAliases:Cl,autoDetection:Tl,inherit:rt,addPlugin:$d,removePlugin:Xo}),B.debugMode=function(){Mt=!1},B.safeMode=function(){Mt=!0},B.versionString=Je,B.regex={concat:k,lookahead:g,either:E,optional:b,anyNumberOfTimes:y};for(const xe in ce)typeof ce[xe]=="object"&&t(ce[xe]);return Object.assign(B,ce),B},lt=Ce({});return lt.newInstance=()=>Ce({}),sp=lt,lt.HighlightJS=lt,lt.default=lt,sp}var t4=e4();const KN=dl(t4);function GN(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?GN(n.children,r):{text:n.value,classes:r}})}function y1(t){return t.value||t.children||[]}function n4(t){return!!KN.getLanguage(t)}function b1({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return Cu(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const u=i.node.attrs.language||r,f=n.listLanguages(),p=u&&(f.includes(u)||n4(u)||(o=n.registered)!=null&&o.call(n,u))?y1(n.highlight(u,i.node.textContent)):y1(n.highlightAuto(i.node.textContent));GN(p).forEach(m=>{const g=l+m.text.length;if(m.classes.length){const y=Dt.inline(l,g,{class:m.classes.join(" ")});s.push(y)}l=g})}),St.create(t,s)}function r4(t){return typeof t=="function"}function s4({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>r4(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new Ct({key:new jt("lowlight"),state:{init:(s,{doc:i})=>b1({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const u=o.selection.$head.parent.type.name,f=l.selection.$head.parent.type.name,p=Cu(o.doc,g=>g.type.name===t),m=Cu(l.doc,g=>g.type.name===t);return s.docChanged&&([u,f].includes(t)||m.length!==p.length||s.steps.some(g=>g.from!==void 0&&g.to!==void 0&&p.some(y=>y.pos>=g.from&&y.pos+y.node.nodeSize<=g.to)))?b1({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var i4=P3.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],s4({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),o4=i4;function a4(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},y=e.optional(s)+t.IDENT_RE+"\\s*\\(",b=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],E=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],T={type:k,keyword:b,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},C={className:"function.dispatch",relevance:0,keywords:{_hint:E},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[C,m,l,n,t.C_BLOCK_COMMENT_MODE,p,f],L={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:R.concat([{begin:/\(/,end:/\)/,keywords:T,contains:R.concat(["self"]),relevance:0}]),relevance:0},D={className:"function",begin:"("+o+"[\\*&\\s]+)+"+y,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:y,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,p]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,l,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(L,D,C,R,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:T,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function l4(t){const e={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=a4(t),r=n.keywords;return r.type=[...r.type,...e.type],r.literal=[...r.literal,...e.literal],r.built_in=[...r.built_in,...e.built_in],r._hints=e._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function c4(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const u={match:/\\"/},f={className:"string",begin:/'/,end:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],y=t.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),b={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],w=["true","false"],E={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],O=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],T=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],C=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:k,literal:w,built_in:[...N,...O,"set","shopt",...T,...C]},contains:[y,t.SHEBANG(),b,m,i,o,E,l,u,f,p,n]}}function u4(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},y=e.optional(s)+t.IDENT_RE+"\\s*\\(",w={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},E=[m,l,n,t.C_BLOCK_COMMENT_MODE,p,f],N={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:E.concat([{begin:/\(/,end:/\)/,keywords:w,contains:E.concat(["self"]),relevance:0}]),relevance:0},O={begin:"("+o+"[\\*&\\s]+)+"+y,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:w,relevance:0},{begin:y,returnBegin:!0,contains:[t.inherit(g,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,l,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C",aliases:["h"],keywords:w,disableAutodetect:!0,illegal:"</",contains:[].concat(N,O,E,[m,{begin:t.IDENT_RE+"::",keywords:w},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:m,strings:f,keywords:w}}}function d4(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},y=e.optional(s)+t.IDENT_RE+"\\s*\\(",b=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],E=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],T={type:k,keyword:b,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},C={className:"function.dispatch",relevance:0,keywords:{_hint:E},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[C,m,l,n,t.C_BLOCK_COMMENT_MODE,p,f],L={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:R.concat([{begin:/\(/,end:/\)/,keywords:T,contains:R.concat(["self"]),relevance:0}]),relevance:0},D={className:"function",begin:"("+o+"[\\*&\\s]+)+"+y,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:y,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,p]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,l,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(L,D,C,R,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:T,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function f4(t){const e=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],s=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],i=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],o={keyword:s.concat(i),built_in:e,literal:r},l=t.inherit(t.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),u={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},p={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},m=t.inherit(p,{illegal:/\n/}),g={className:"subst",begin:/\{/,end:/\}/,keywords:o},y=t.inherit(g,{illegal:/\n/}),b={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,y]},k={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},w=t.inherit(k,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]});g.contains=[k,b,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.C_BLOCK_COMMENT_MODE],y.contains=[w,b,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const E={variants:[f,k,b,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},N={begin:"<",end:">",contains:[{beginKeywords:"in out"},l]},O=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",T={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},E,u,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},l,N,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[l,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[l,N,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+O+"\\s+)+"+t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,N],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[E,u,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},T]}}const h4=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),p4=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],m4=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],g4=[...p4,...m4],v4=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),y4=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),b4=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),x4=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function w4(t){const e=t.regex,n=h4(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+y4.join("|")+")"},{begin:":(:)?("+b4.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+x4.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:v4.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+g4.join("|")+")\\b"}]}}function k4(t){const e=t.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:e.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:e.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function S4(t){const i={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:i,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,illegal:/["']/}]}]}}function E4(t){const e=t.regex,n=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[t.HASH_COMMENT_MODE,t.QUOTE_STRING_MODE,t.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:e.concat(n,e.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function _4(t){const e=t.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:t.NUMBER_RE}]},r=t.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},l={begin:/\[/,end:/\]/,contains:[r,i,s,o,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,p=/'[^']*'/,m=e.either(u,f,p),g=e.concat(m,"(\\s*\\.\\s*",m,")*",e.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,l,i,s,o,n]}}]}}var Io="[0-9](_*[0-9])*",Jc=`\\.(${Io})`,Yc="[0-9a-fA-F](_*[0-9a-fA-F])*",x1={className:"number",variants:[{begin:`(\\b(${Io})((${Jc})|\\.)?|(${Jc}))[eE][+-]?(${Io})[fFdD]?\\b`},{begin:`\\b(${Io})((${Jc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Jc})[fFdD]?\\b`},{begin:`\\b(${Io})[fFdD]\\b`},{begin:`\\b0[xX]((${Yc})\\.?|(${Yc})?\\.(${Yc}))[pP][+-]?(${Io})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Yc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function JN(t,e,n){return n===-1?"":t.replace(e,r=>JN(t,e,n-1))}function N4(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+JN("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),u={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},p={className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:u,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[p,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:u,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[f,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,x1,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},x1,f]}}const w1="[A-Za-z$_][0-9A-Za-z$_]*",C4=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],T4=["true","false","null","undefined","NaN","Infinity"],YN=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],QN=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],XN=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],M4=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],A4=[].concat(XN,YN,QN);function O4(t){const e=t.regex,n=(V,{after:Y})=>{const I="</"+V[0].slice(1);return V.input.indexOf(I,Y)!==-1},r=w1,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,Y)=>{const I=V[0].length+V.index,A=V.input[I];if(A==="<"||A===","){Y.ignoreMatch();return}A===">"&&(n(V,{after:I})||Y.ignoreMatch());let j;const Q=V.input.substring(I);if(j=Q.match(/^\s*=/)){Y.ignoreMatch();return}if((j=Q.match(/^\s+extends\s+/))&&j.index===0){Y.ignoreMatch();return}}},l={$pattern:w1,keyword:C4,literal:T4,built_in:A4,"variable.language":M4},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},O=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,k,w,{match:/\$\d+/},m];g.contains=O.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(O)});const T=[].concat(N,g.contains),C=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:C},L={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},D={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...YN,...QN]}},z={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},F={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},J={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(V){return e.concat("(?!",V.join("|"),")")}const X={match:e.concat(/\b/,K([...XN,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},W={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},$={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},U="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",Z={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(U)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:C,CLASS_REFERENCE:D},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),z,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,k,w,N,{match:/\$\d+/},m,D,{scope:"attr",match:r+e.lookahead(":"),relevance:0},Z,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,t.REGEXP_MODE,{className:"function",begin:U,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:C}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},F,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},W,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},X,J,L,$,{match:/\$[(.]/}]}}function R4(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Lo="[0-9](_*[0-9])*",Qc=`\\.(${Lo})`,Xc="[0-9a-fA-F](_*[0-9a-fA-F])*",j4={className:"number",variants:[{begin:`(\\b(${Lo})((${Qc})|\\.)?|(${Qc}))[eE][+-]?(${Lo})[fFdD]?\\b`},{begin:`\\b(${Lo})((${Qc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Qc})[fFdD]?\\b`},{begin:`\\b(${Lo})[fFdD]\\b`},{begin:`\\b0[xX]((${Xc})\\.?|(${Xc})?\\.(${Xc}))[pP][+-]?(${Lo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Xc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function I4(t){const e={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"@"},s={className:"subst",begin:/\$\{/,end:/\}/,contains:[t.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+t.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,s]},{begin:"'",end:"'",illegal:/\n/,contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[t.BACKSLASH_ESCAPE,i,s]}]};s.contains.push(o);const l={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+t.UNDERSCORE_IDENT_RE+")?"},u={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(o,{className:"string"}),"self"]}]},f=j4,p=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),m={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},g=m;return g.variants[1].contains=[m],m.variants[1].contains=[g],{name:"Kotlin",aliases:["kt","kts"],keywords:e,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),t.C_LINE_COMMENT_MODE,p,n,r,l,u,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[m,t.C_LINE_COMMENT_MODE,p],relevance:0},t.C_LINE_COMMENT_MODE,p,l,u,o,t.C_NUMBER_MODE]},p]},{begin:[/class|interface|trait/,/\s+/,t.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},t.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},l,u]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
202
+ `},f]}}const L4=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),D4=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],P4=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],B4=[...D4,...P4],z4=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),ZN=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),eC=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),F4=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),$4=ZN.concat(eC).sort().reverse();function U4(t){const e=L4(t),n=$4,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",o=[],l=[],u=function(O){return{className:"string",begin:"~?"+O+".*?"+O}},f=function(O,T,C){return{className:O,begin:T,relevance:C}},p={$pattern:/[a-z-]+/,keyword:r,attribute:z4.join(" ")},m={begin:"\\(",end:"\\)",contains:l,keywords:p,relevance:0};l.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,u("'"),u('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},e.HEXCOLOR,m,f("variable","@@?"+s,10),f("variable","@\\{"+s+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:s+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},e.IMPORTANT,{beginKeywords:"and not"},e.FUNCTION_DISPATCH);const g=l.concat({begin:/\{/,end:/\}/,contains:o}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(l)},b={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+F4.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:l}}]},k={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:p,returnEnd:!0,contains:l,relevance:0}},w={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:g}},E={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,y,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+B4.join("|")+")\\b",className:"selector-tag"},e.CSS_NUMBER_MODE,f("selector-tag",i,0),f("selector-id","#"+i),f("selector-class","\\."+i,0),f("selector-tag","&",0),e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+ZN.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+eC.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:g},{begin:"!important"},e.FUNCTION_DISPATCH]},N={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[E]};return o.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,k,w,N,b,E,y,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function H4(t){const e="\\[=*\\[",n="\\]=*\\]",r={begin:e,end:n,contains:["self"]},s=[t.COMMENT("--(?!"+e+")","$"),t.COMMENT("--"+e,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:t.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:s.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[t.inherit(t.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:s}].concat(s)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:e,end:n,contains:[r],relevance:5}])}}function W4(t){const e={className:"variable",variants:[{begin:"\\$\\("+t.UNDERSCORE_IDENT_RE+"\\)",contains:[t.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,e]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[e,n]},s={begin:"^"+t.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[e]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[t.HASH_COMMENT_MODE,e,n,r,s,i,o]}}function q4(t){const e=t.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},s={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},l=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,l,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=t.inherit(f,{contains:[]}),g=t.inherit(p,{contains:[]});f.contains.push(g),p.contains.push(m);let y=[n,u];return[f,p,m,g].forEach(E=>{E.contains=E.contains.concat(y)}),y=y.concat(f,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,i,f,p,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},s,r,u,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function V4(t){const e={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,l={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},u={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:l,illegal:"</",contains:[e,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.C_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+u.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:u,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function K4(t){const e=t.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,keyword:n.join(" ")},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},o={begin:/->\{/,end:/\}/},l={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},u={scope:"variable",variants:[{begin:/\$\d/},{begin:e.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[l]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},p=[t.BACKSLASH_ESCAPE,i,u],m=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],g=(k,w,E="\\1")=>{const N=E==="\\1"?E:e.concat(E,w);return e.concat(e.concat("(?:",k,")"),w,/(?:\\.|[^\\\/])*?/,N,/(?:\\.|[^\\\/])*?/,E,r)},y=(k,w,E)=>e.concat(e.concat("(?:",k,")"),w,/(?:\\.|[^\\\/])*?/,E,r),b=[u,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:p,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:g("s|tr|y",e.either(...m,{capture:!0}))},{begin:g("s|tr|y","\\(","\\)")},{begin:g("s|tr|y","\\[","\\]")},{begin:g("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",e.either(...m,{capture:!0}),/\1/)},{begin:y("m|qr",/\(/,/\)/)},{begin:y("m|qr",/\[/,/\]/)},{begin:y("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,l]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,l,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=b,o.contains=b,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:b}}function G4(t){const e=t.regex,n=/(?![A-Za-z0-9])(?![$])/,r=e.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=e.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),i=e.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+r},l={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},u={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=t.inherit(t.APOS_STRING_MODE,{illegal:null}),p=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(u)}),m={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(u),"on:begin":(W,$)=>{$.data._beginMatch=W[1]||W[2]},"on:end":(W,$)=>{$.data._beginMatch!==W[1]&&$.ignoreMatch()}},g=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
203
+ ]`,b={scope:"string",variants:[p,f,m,g]},k={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},w=["false","null","true"],E=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],N=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],T={keyword:E,literal:(W=>{const $=[];return W.forEach(U=>{$.push(U),U.toLowerCase()===U?$.push(U.toUpperCase()):$.push(U.toLowerCase())}),$})(w),built_in:N},C=W=>W.map($=>$.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,e.concat(y,"+"),e.concat("(?!",C(N).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},L=e.concat(r,"\\b(?!\\()"),D={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),L],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),L],scope:{1:"title.class",3:"variable.constant"}},{match:[s,e.concat("::",e.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},z={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},F={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[z,o,D,t.C_BLOCK_COMMENT_MODE,b,k,R]},J={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",C(E).join("\\b|"),"|",C(N).join("\\b|"),"\\b)"),r,e.concat(y,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[F]};F.contains.push(J);const K=[z,D,t.C_BLOCK_COMMENT_MODE,b,k,R],X={begin:e.concat(/#\[\s*\\?/,e.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:w,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:w,keyword:["new","array"]},contains:["self",...K]},...K,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:T,contains:[X,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},l,{scope:"variable.language",match:/\$this\b/},o,J,D,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},R,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:T,contains:["self",X,o,D,t.C_BLOCK_COMMENT_MODE,b,k]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},b,k]}}function J4(t){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},t.inherit(t.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),t.inherit(t.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function Y4(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function Q4(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,u,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u,p,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,p,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",y=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,b=`\\b|${r.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${y}))[eE][+-]?(${g})[jJ]?(?=${b})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${g})[jJ](?=${b})`}]},w={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},E={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",u,k,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,k,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[u,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,w,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[E]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[k,E,m]}]}}function X4(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function Z4(t){const e=t.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=e.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=e.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[t.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:e.lookahead(e.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),t.HASH_COMMENT_MODE,{scope:"string",contains:[t.BACKSLASH_ESCAPE],variants:[t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function e6(t){const e=t.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=e.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=e.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},l={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[l]}),t.COMMENT("^=begin","^=end",{contains:[l],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:o},m={className:"string",contains:[t.BACKSLASH_ESCAPE,p],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:e.concat(/<<[-~]?'?/,e.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,p]})]}]},g="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",b={className:"number",relevance:0,variants:[{begin:`\\b(${g})(\\.(${y}))?([eE][+-]?(${y})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},k={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},R=[m,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:o},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[k]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},b,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,p],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(u,f),relevance:0}].concat(u,f);p.contains=R,k.contains=R;const F=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:R}}];return f.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(F).concat(f).concat(R)}}function t6(t){const e=t.regex,n=/(r#)?/,r=e.concat(n,t.UNDERSCORE_IDENT_RE),s=e.concat(n,t.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,e.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",l=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:p,keyword:l,literal:u,built_in:f},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:p}},{className:"punctuation",begin:"->"},i]}}const n6=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),r6=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],s6=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],i6=[...r6,...s6],o6=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),a6=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),l6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),c6=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function u6(t){const e=n6(t),n=l6,r=a6,s="@[a-z-]+",i="and or not only",l={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,e.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+i6.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},l,{begin:/\(/,end:/\)/,contains:[e.CSS_NUMBER_MODE]},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+c6.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[e.BLOCK_COMMENT,l,e.HEXCOLOR,e.CSS_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.IMPORTANT,e.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:o6.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},l,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.HEXCOLOR,e.CSS_NUMBER_MODE]},e.FUNCTION_DISPATCH]}}function d6(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function f6(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],u=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],g=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],y=p,b=[...f,...u].filter(C=>!p.includes(C)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},E={match:e.concat(/\b/,e.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function N(C){return e.concat(/\b/,e.either(...C.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const O={scope:"keyword",match:N(g),relevance:0};function T(C,{exceptions:R,when:L}={}){const D=L;return R=R||[],C.map(z=>z.match(/\|\d+$/)||R.includes(z)?z:D(z)?`${z}|0`:z)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(b,{when:C=>C.length<3}),literal:i,type:l,built_in:m},contains:[{scope:"type",match:N(o)},O,E,k,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,w]}}function tC(t){return t?typeof t=="string"?t:t.source:null}function La(t){return At("(?=",t,")")}function At(...t){return t.map(n=>tC(n)).join("")}function h6(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Wn(...t){return"("+(h6(t).capture?"":"?:")+t.map(r=>tC(r)).join("|")+")"}const w0=t=>At(/\b/,t,/\w$/.test(t)?/\b/:/\B/),p6=["Protocol","Type"].map(w0),k1=["init","self"].map(w0),m6=["Any","Self"],ip=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],S1=["false","nil","true"],g6=["assignment","associativity","higherThan","left","lowerThan","none","right"],v6=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],E1=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],nC=Wn(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),rC=Wn(nC,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),op=At(nC,rC,"*"),sC=Wn(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),id=Wn(sC,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Kr=At(sC,id,"*"),Zc=At(/[A-Z]/,id,"*"),y6=["attached","autoclosure",At(/convention\(/,Wn("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",At(/objc\(/,Kr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],b6=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function x6(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,Wn(...p6,...k1)],className:{2:"keyword"}},i={match:At(/\./,Wn(...ip)),relevance:0},o=ip.filter(Ne=>typeof Ne=="string").concat(["_|0"]),l=ip.filter(Ne=>typeof Ne!="string").concat(m6).map(w0),u={variants:[{className:"keyword",match:Wn(...l,...k1)}]},f={$pattern:Wn(/\b\w+/,/#\w+/),keyword:o.concat(v6),literal:S1},p=[s,i,u],m={match:At(/\./,Wn(...E1)),relevance:0},g={className:"built_in",match:At(/\b/,Wn(...E1),/(?=\()/)},y=[m,g],b={match:/->/,relevance:0},k={className:"operator",relevance:0,variants:[{match:op},{match:`\\.(\\.|${rC})+`}]},w=[b,k],E="([0-9]_*)+",N="([0-9a-fA-F]_*)+",O={className:"number",relevance:0,variants:[{match:`\\b(${E})(\\.(${E}))?([eE][+-]?(${E}))?\\b`},{match:`\\b0x(${N})(\\.(${N}))?([pP][+-]?(${E}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(Ne="")=>({className:"subst",variants:[{match:At(/\\/,Ne,/[0\\tnr"']/)},{match:At(/\\/,Ne,/u\{[0-9a-fA-F]{1,8}\}/)}]}),C=(Ne="")=>({className:"subst",match:At(/\\/,Ne,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(Ne="")=>({className:"subst",label:"interpol",begin:At(/\\/,Ne,/\(/),end:/\)/}),L=(Ne="")=>({begin:At(Ne,/"""/),end:At(/"""/,Ne),contains:[T(Ne),C(Ne),R(Ne)]}),D=(Ne="")=>({begin:At(Ne,/"/),end:At(/"/,Ne),contains:[T(Ne),R(Ne)]}),z={className:"string",variants:[L(),L("#"),L("##"),L("###"),D(),D("#"),D("##"),D("###")]},F=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],J={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:F},K=Ne=>{const tt=At(Ne,/\//),Be=At(/\//,Ne);return{begin:tt,end:Be,contains:[...F,{scope:"comment",begin:`#(?!.*${Be})`,end:/$/}]}},X={scope:"regexp",variants:[K("###"),K("##"),K("#"),J]},W={match:At(/`/,Kr,/`/)},$={className:"variable",match:/\$\d+/},U={className:"variable",match:`\\$${id}+`},Z=[W,$,U],V={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:b6,contains:[...w,O,z]}]}},Y={scope:"keyword",match:At(/@/,Wn(...y6),La(Wn(/\(/,/\s+/)))},I={scope:"meta",match:At(/@/,Kr)},A=[V,Y,I],j={match:La(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:At(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,id,"+")},{className:"type",match:Zc,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:At(/\s+&\s+/,La(Zc)),relevance:0}]},Q={begin:/</,end:/>/,keywords:f,contains:[...r,...p,...A,b,j]};j.contains.push(Q);const oe={match:At(Kr,/\s*:/),keywords:"_|0",relevance:0},fe={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",oe,...r,X,...p,...y,...w,O,z,...Z,...A,j]},G={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,j]},le={begin:Wn(La(At(Kr,/\s*:/)),La(At(Kr,/\s+/,Kr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Kr}]},Te={begin:/\(/,end:/\)/,keywords:f,contains:[le,...r,...p,...w,O,z,...A,j,fe],endsParent:!0,illegal:/["']/},Ve={match:[/(func|macro)/,/\s+/,Wn(W.match,Kr,op)],className:{1:"keyword",3:"title.function"},contains:[G,Te,e],illegal:[/\[/,/%/]},ce={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[G,Te,e],illegal:/\[|%/},ue={match:[/operator/,/\s+/,op],className:{1:"keyword",3:"title"}},ae={begin:[/precedencegroup/,/\s+/,Zc],className:{1:"keyword",3:"title"},contains:[j],keywords:[...g6,...S1],end:/}/},je={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Me={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},He={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Kr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[G,...p,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Zc},...p],relevance:0}]};for(const Ne of z.variants){const tt=Ne.contains.find($e=>$e.label==="interpol");tt.keywords=f;const Be=[...p,...y,...w,O,z,...Z];tt.contains=[...Be,{begin:/\(/,end:/\)/,contains:["self",...Be]}]}return{name:"Swift",keywords:f,contains:[...r,Ve,ce,je,Me,He,ue,ae,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},X,...p,...y,...w,O,z,...Z,...A,j,fe]}}const od="[A-Za-z$_][0-9A-Za-z$_]*",iC=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],oC=["true","false","null","undefined","NaN","Infinity"],aC=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],lC=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],cC=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],uC=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],dC=[].concat(cC,aC,lC);function w6(t){const e=t.regex,n=(V,{after:Y})=>{const I="</"+V[0].slice(1);return V.input.indexOf(I,Y)!==-1},r=od,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,Y)=>{const I=V[0].length+V.index,A=V.input[I];if(A==="<"||A===","){Y.ignoreMatch();return}A===">"&&(n(V,{after:I})||Y.ignoreMatch());let j;const Q=V.input.substring(I);if(j=Q.match(/^\s*=/)){Y.ignoreMatch();return}if((j=Q.match(/^\s+extends\s+/))&&j.index===0){Y.ignoreMatch();return}}},l={$pattern:od,keyword:iC,literal:oC,built_in:dC,"variable.language":uC},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},O=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,k,w,{match:/\$\d+/},m];g.contains=O.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(O)});const T=[].concat(N,g.contains),C=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:C},L={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},D={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...aC,...lC]}},z={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},F={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},J={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(V){return e.concat("(?!",V.join("|"),")")}const X={match:e.concat(/\b/,K([...cC,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},W={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},$={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},U="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",Z={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(U)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:C,CLASS_REFERENCE:D},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),z,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,k,w,N,{match:/\$\d+/},m,D,{scope:"attr",match:r+e.lookahead(":"),relevance:0},Z,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,t.REGEXP_MODE,{className:"function",begin:U,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:C}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},F,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},W,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},X,J,L,$,{match:/\$[(.]/}]}}function k6(t){const e=t.regex,n=w6(t),r=od,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:od,keyword:iC.concat(u),literal:oC,built_in:dC.concat(s),"variable.language":uC},p={className:"meta",begin:"@"+r},m=(k,w,E)=>{const N=k.contains.findIndex(O=>O.label===w);if(N===-1)throw new Error("can not find mode to replace");k.contains.splice(N,1,E)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(p);const g=n.contains.find(k=>k.scope==="attr"),y=Object.assign({},g,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,y]),n.contains=n.contains.concat([p,i,o,y]),m(n,"shebang",t.SHEBANG()),m(n,"use_strict",l);const b=n.contains.find(k=>k.label==="func.def");return b.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function S6(t){const e=t.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,l=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:e.concat(/# */,e.either(i,s),/ *#/)},{begin:e.concat(/# */,l,/ *#/)},{begin:e.concat(/# */,o,/ *#/)},{begin:e.concat(/# */,e.either(i,s),/ +/,e.either(o,l),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},p={className:"label",begin:/^\w+:/},m=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),g=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,u,f,p,m,g,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[g]}]}}function E6(t){t.regex;const e=t.COMMENT(/\(;/,/;\)/);e.contains.push("self");const n=t.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},l={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},u={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,e,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,o,s,t.QUOTE_STRING_MODE,u,f,l]}}function _6(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),u=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,u,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,u,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function N6(t){const e="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,s]},l=t.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},b={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},k={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},w=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},g,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},b,k,i,o],E=[...w];return E.pop(),E.push(l),y.contains=E,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}const C6={arduino:l4,bash:c4,c:u4,cpp:d4,csharp:f4,css:w4,diff:k4,go:S4,graphql:E4,ini:_4,java:N4,javascript:O4,json:R4,kotlin:I4,less:U4,lua:H4,makefile:W4,markdown:q4,objectivec:V4,perl:K4,php:G4,"php-template":J4,plaintext:Y4,python:Q4,"python-repl":X4,r:Z4,ruby:e6,rust:t6,scss:u6,shell:d6,sql:f6,swift:x6,typescript:k6,vbnet:S6,wasm:E6,xml:_6,yaml:N6},_1={},T6="hljs-";function M6(t){const e=KN.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(u,f,p){const m=p||_1,g=typeof m.prefix=="string"?m.prefix:T6;if(!e.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");e.configure({__emitter:A6,classPrefix:g});const y=e.highlight(f,{ignoreIllegals:!0,language:u});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const b=y._emitter.root,k=b.data;return k.language=y.language,k.relevance=y.relevance,b}function r(u,f){const m=(f||_1).subset||s();let g=-1,y=0,b;for(;++g<m.length;){const k=m[g];if(!e.getLanguage(k))continue;const w=n(k,u,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>y&&(y=w.data.relevance,b=w)}return b||{type:"root",children:[],data:{language:void 0,relevance:y}}}function s(){return e.listLanguages()}function i(u,f){if(typeof u=="string")e.registerLanguage(u,f);else{let p;for(p in u)Object.hasOwn(u,p)&&e.registerLanguage(p,u[p])}}function o(u,f){if(typeof u=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const m=u[p];e.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function l(u){return!!e.getLanguage(u)}}class A6{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const O6=new jt("blurredLoadingNode"),k0=bt.create({name:"blurredLoadingNode",addStorage(){return{loadingNodes:{}}},addCommands(){return{applyLoadingEffect:(t,e,n,r="paragraph")=>({editor:s})=>{const i={...this.storage.loadingNodes};return i[t]={from:e,to:n,id:t,active:!0,type:r},this.storage.loadingNodes=i,s.view.dispatch(s.view.state.tr),setTimeout(()=>{s.isFocused&&s.commands.setTextSelection({from:e,to:e})},0),!0},removeLoadingEffect:t=>({editor:e})=>{const n={...this.storage.loadingNodes};return n[t]&&(delete n[t],this.storage.loadingNodes=n,e.view.dispatch(e.view.state.tr),e.isFocused||setTimeout(()=>{e.commands.focus()},0)),!0}}},addProseMirrorPlugins(){return[new Ct({key:O6,props:{decorations:t=>{const e=this.storage.loadingNodes,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;if(!s.active)return;const{from:i,to:o,type:l}=s;l==="selection"?n.push(Dt.inline(i,o,{class:"node-blur-selection"})):t.doc.nodesBetween(i,o,(u,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(u.type.name)?(n.push(Dt.node(f,f+u.nodeSize,{class:"node-blur-effect"})),!1):!0)}),St.create(t.doc,n)}}})]}}),S0=un.create({name:"imageLoading",group:"block",atom:!0,addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:'div[data-type="image-loading"]'}]},renderHTML(){return["div",{"data-type":"image-loading",class:"image-loading-placeholder",contenteditable:"false"}]}}),R6=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],E0=bt.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:R6,attributes:{pendingStatus:{default:null,parseHTML:t=>t.getAttribute("data-pending-status")||null,renderHTML:t=>t.pendingStatus?{"data-pending-status":t.pendingStatus}:{}},pendingOriginalContent:{default:null,rendered:!1},pendingSelectionFrom:{default:null,rendered:!1},pendingSelectionTo:{default:null,rendered:!1},pendingOriginalFrom:{default:null,rendered:!1},pendingOriginalTo:{default:null,rendered:!1},pendingGroupId:{default:null,rendered:!1}}}]}}),j6=M6(C6),_0=KL.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),target:{default:null}}},renderHTML({HTMLAttributes:t}){var r;const{target:e,...n}=t;if((r=n.href)!=null&&r.startsWith("doc:")){const{href:s,...i}=n;return["span",{...i,"data-doc":s.slice(4),class:"doc-link"},0]}return["a",Nt(this.options.HTMLAttributes,n),0]}}),I6=[x0.configure({codeBlock:!1,link:!1,underline:!1}),o4.configure({lowlight:j6}),_0.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),WN,v3,xL,bD,wD,zP,BP.configure({nested:!0}),o0,g3,AN.configure({resizable:!1}),MN,TN,CN,k0,S0,E0,_d.configure({placeholder:"Start writing..."}),b0.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],L6=[x0.configure({codeBlock:!1,horizontalRule:!0,heading:{levels:[1,2,3]},link:!1,underline:!1}),_0.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),o0,k0,S0,E0,_d.configure({placeholder:"Start writing..."}),b0.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image","imageLoading","horizontalRule"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],D6=bt.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>{const{state:t}=this.editor,{$from:e}=t.selection,n=e.pos,r=n>0?t.doc.resolve(n).nodeBefore:null;if((r==null?void 0:r.type.name)==="hardBreak"){const{tr:s}=t;return s.delete(n-r.nodeSize,n),s.split(s.mapping.map(n)),this.editor.view.dispatch(s),!0}return this.editor.commands.setHardBreak()}}}}),fC=[x0.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),_0.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),o0,k0,S0,E0,D6,b0.configure({types:["paragraph","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...fC,_d.configure({placeholder:"What is happening?!"})];function Rr({onClick:t,active:e,disabled:n,title:r,children:s}){return d.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function N1(){return d.jsx("div",{className:"floating-toolbar__divider"})}function P6({editor:t}){const[e,n]=S.useState(!1),[r,s]=S.useState({top:0,left:0}),[,i]=S.useState(0),o=S.useRef(-1),l=S.useRef(-1),u=S.useRef(!1);return S.useEffect(()=>{const f=t.view.dom,p=()=>{u.current=!0},m=()=>{if(!u.current)return;u.current=!1;const{from:g,to:y}=t.state.selection,b=g!==y&&t.state.selection.node;if(g!==y&&!b){const k=t.isActive("codeBlock"),w=!!document.querySelector(".context-menu");if(!k&&!w){o.current=g,l.current=y;const E=t.view.coordsAtPos(g),N=t.view.coordsAtPos(y,1),O=(E.left+N.right)/2;s({top:E.top,left:O}),n(!0)}}};return f.addEventListener("mousedown",p),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",p),document.removeEventListener("mouseup",m)}},[t]),S.useEffect(()=>{const f=()=>{u.current=!1,n(!1),o.current=-1,l.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),S.useEffect(()=>{const f=()=>{const{from:p,to:m}=t.state.selection,g=p===m,y=t.isActive("codeBlock"),b=!!document.querySelector(".context-menu"),k=t.view.hasFocus(),w=!g&&t.state.selection.node;if(g||w||y||b||!k)n(!1),o.current=-1,l.current=-1;else if(!u.current&&(n(!0),p!==o.current||m!==l.current)){o.current=p,l.current=m;const E=t.view.coordsAtPos(p),N=t.view.coordsAtPos(m,1),O=(E.left+N.right)/2;s({top:E.top,left:O})}i(E=>E+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?d.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[d.jsx(Rr,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),d.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),d.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),d.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),d.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),d.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),d.jsx(Rr,{onClick:()=>{const f=t.getAttributes("link").href||"",p=window.prompt("Link URL:",f);p!==null&&(p===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:p}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),d.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),d.jsx(N1,{}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"m17 12 3-2v8"})]})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),d.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),d.jsx(N1,{}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M3 12h.01"}),d.jsx("path",{d:"M3 18h.01"}),d.jsx("path",{d:"M3 6h.01"}),d.jsx("path",{d:"M8 12h13"}),d.jsx("path",{d:"M8 18h13"}),d.jsx("path",{d:"M8 6h13"})]})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M11 12h9"}),d.jsx("path",{d:"M11 18h9"}),d.jsx("path",{d:"M11 6h9"}),d.jsx("path",{d:"M4 10V4h1"}),d.jsx("path",{d:"M4 10h2"}),d.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),d.jsx(Rr,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17 6H3"}),d.jsx("path",{d:"M21 12H8"}),d.jsx("path",{d:"M21 18H8"}),d.jsx("path",{d:"M3 12v6"})]})})]}):null}const B6=new jt("pendingDecoration");let hC=null,pC=null;function C1(t,e){hC=t,pC=e??null}let ad=!1,mC=null,N0=null,gC=null;function C0(){return ad}function z6(){return N0}function F6(){return gC}function Eg(t,e,n,r){ad=t,mC=t?e??null:null,N0=t?r??null:null,gC=t?n??null:null}function $6(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function T1(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const o=t.child(i);if(o.isText){if(r+o.text.length>=n)return s+(n-r);r+=o.text.length,s+=o.nodeSize}else{const l=o.type.spec.leafText?o.type.spec.leafText(o).length:0;if(l>0&&r+l>=n)return s;r+=l,s+=o.nodeSize}}return n===r?s:null}function M1(t){const e=[];return t.descendants((n,r)=>{var b,k,w,E,N,O,T;const s=(b=n.attrs)==null?void 0:b.pendingStatus;if(!s)return!0;const i=(k=n.attrs)==null?void 0:k.id,o=(w=n.attrs)==null?void 0:w.pendingGroupId,l=o&&o===pC,f=ad&&i===mC||o&&ad&&o===N0,p=f?(E=n.attrs)==null?void 0:E.pendingOriginalFrom:(N=n.attrs)==null?void 0:N.pendingSelectionFrom,m=f?(O=n.attrs)==null?void 0:O.pendingOriginalTo:(T=n.attrs)==null?void 0:T.pendingSelectionTo,g=p!=null&&m!=null,y=f?"pending-original":$6(s);if(g&&n.isTextblock&&y){const C=T1(n,r,p),R=T1(n,r,m);C!==null&&R!==null&&C<R&&e.push(Dt.inline(C,R,{class:y}))}else y&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(Dt.inline(r+1,r+n.nodeSize-1,{class:y})):e.push(Dt.node(r,r+n.nodeSize,{class:y})));if(i&&(i===hC||l)){const C=f?"original":s;e.push(Dt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${C}`}))}return!0}),St.create(t,e)}function vC(){return new Ct({key:B6,state:{init(t,e){return M1(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?M1(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function T0(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const U6=new jt("markDecoration");let hu=[];function A1(t){hu=t}function O1(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=j1(e,n,s),o=j1(e,n,s+t.text.length);return i===null||o===null||i>=o?null:Dt.inline(i,o,{class:"agent-mark",title:t.note?`Agent Mark: ${t.note}`:"Agent Mark","data-mark-id":t.id})}function R1(t){if(hu.length===0)return St.empty;const e=[],n=new Set,r=new Map;t.descendants((i,o)=>{var l;return i.isTextblock&&((l=i.attrs)!=null&&l.id)&&r.set(i.attrs.id,{node:i,pos:o}),!0});for(const i of hu){const o=r.get(i.nodeId);if(!o)continue;const l=O1(i,o.node,o.pos);l&&(n.add(i.id),e.push(l))}const s=hu.filter(i=>!n.has(i.id));return s.length>0&&t.descendants((i,o)=>{if(!i.isTextblock)return!0;for(const l of s){if(n.has(l.id))continue;const u=O1(l,i,o);u&&(n.add(l.id),e.push(u))}return!0}),St.create(t,e)}function j1(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const o=t.child(i);if(o.isText){if(r+o.text.length>=n)return s+(n-r);r+=o.text.length,s+=o.nodeSize}else{const l=o.type.spec.leafText?o.type.spec.leafText(o).length:0;if(l>0&&r+l>=n)return s;r+=l,s+=o.nodeSize}}return n===r?s:null}function yC(){return new Ct({key:U6,state:{init(t,e){return R1(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceMarkUpdate")?R1(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function I1(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceMarkUpdate",!0);n(r)}async function bC(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json(),{state:i}=e,o=i.schema.nodes.image.create({src:s,alt:t.name}),l=i.tr.replaceSelectionWith(o);e.dispatch(l)}catch{}}function xC(t,e){var r;const n=(r=e.clipboardData)==null?void 0:r.items;if(!n)return!1;for(const s of n)if(s.type.startsWith("image/")){e.preventDefault();const i=s.getAsFile();return i&&bC(i,t),!0}return!1}function wC(t,e){var r;const n=(r=e.dataTransfer)==null?void 0:r.files;if(!(n!=null&&n.length))return!1;for(const s of n)if(s.type.startsWith("image/"))return e.preventDefault(),bC(s,t),!0;return!1}function eu({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=S.useRef(s);i.current=s;const o=Z_({extensions:e||I6,content:t||"<p></p>",onUpdate:({editor:l})=>{C0()||n==null||n(l.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:xC,handleDrop:wC}},[t]);return S.useEffect(()=>{if(!o)return;const l=o.view.dom,u=f=>{var y;const m=f.target.closest("span.doc-link[data-doc]");if(!m)return;const g=m.getAttribute("data-doc");(y=i.current)==null||y.call(i,g)};return l.addEventListener("click",u,!0),()=>l.removeEventListener("click",u,!0)},[o]),S.useEffect(()=>{if(!o)return;const{state:l}=o.view;if(l.plugins.some(p=>p.key==="pendingDecoration$"))return;const u=vC(),f=l.reconfigure({plugins:[...l.plugins,u]});o.view.updateState(f)},[o]),S.useEffect(()=>{if(!o)return;const{state:l}=o.view;if(l.plugins.some(p=>p.key==="markDecoration$"))return;const u=yC(),f=l.reconfigure({plugins:[...l.plugins,u]});o.view.updateState(f)},[o]),S.useEffect(()=>{o&&(r==null||r(o))},[o,r]),o?d.jsxs(d.Fragment,{children:[d.jsx(s0,{editor:o}),d.jsx(P6,{editor:o})]}):null}function nn({onClick:t,active:e,disabled:n,title:r,children:s}){return d.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function Ao(){return d.jsx("div",{className:"format-toolbar__divider"})}async function H6(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json();e.chain().focus().setImage({src:s,alt:t.name}).run()}catch{}}function W6({editor:t}){const[,e]=S.useState(0),n=S.useRef(null);S.useEffect(()=>{const s=()=>e(i=>i+1);return t.on("transaction",s),()=>{t.off("transaction",s)}},[t]);const r=s=>{var o;const i=(o=s.target.files)==null?void 0:o[0];i&&H6(i,t),s.target.value=""};return d.jsxs("div",{className:"format-toolbar",children:[d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),d.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),d.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),d.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),d.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),d.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m16 18 6-6-6-6"}),d.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),d.jsx(Ao,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),d.jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m4 5 8 8"}),d.jsx("path",{d:"m12 5-8 8"}),d.jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m4 19 8-8"}),d.jsx("path",{d:"m12 19-8-8"}),d.jsx("path",{d:"M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})})]}),d.jsx(Ao,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"m17 12 3-2v8"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),d.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M13 4v16"}),d.jsx("path",{d:"M17 4v16"}),d.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),d.jsx(Ao,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M3 12h.01"}),d.jsx("path",{d:"M3 18h.01"}),d.jsx("path",{d:"M3 6h.01"}),d.jsx("path",{d:"M8 12h13"}),d.jsx("path",{d:"M8 18h13"}),d.jsx("path",{d:"M8 6h13"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M11 12h9"}),d.jsx("path",{d:"M11 18h9"}),d.jsx("path",{d:"M11 6h9"}),d.jsx("path",{d:"M4 10V4h1"}),d.jsx("path",{d:"M4 10h2"}),d.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m3 17 2 2 4-4"}),d.jsx("path",{d:"m3 7 2 2 4-4"}),d.jsx("path",{d:"M13 6h8"}),d.jsx("path",{d:"M13 12h8"}),d.jsx("path",{d:"M13 18h8"})]})})]}),d.jsx(Ao,{}),d.jsx("div",{className:"format-toolbar__group",children:d.jsx(nn,{onClick:()=>{const s=t.getAttributes("link").href||"",i=window.prompt("Link URL:",s);i!==null&&(i===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:i}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),d.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}),d.jsx(Ao,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17 6H3"}),d.jsx("path",{d:"M21 12H8"}),d.jsx("path",{d:"M21 18H8"}),d.jsx("path",{d:"M3 12v6"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("path",{d:"m10 9-3 3 3 3"}),d.jsx("path",{d:"m14 15 3-3-3-3"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M5 12h14"})})})]}),d.jsx(Ao,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>{var s;return(s=n.current)==null?void 0:s.click()},title:"Insert Image",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.jsx("circle",{cx:"9",cy:"9",r:"2"}),d.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("path",{d:"M12 3v18"}),d.jsx("path",{d:"M3 9h18"}),d.jsx("path",{d:"M3 15h18"})]})})]}),d.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const q6={tree:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),timeline:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),d.jsx("circle",{cx:"12",cy:"6",r:"2"}),d.jsx("circle",{cx:"12",cy:"12",r:"2"}),d.jsx("circle",{cx:"12",cy:"18",r:"2"}),d.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),d.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),d.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),d.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),d.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 19V5"}),d.jsx("path",{d:"M8 19V7"}),d.jsx("path",{d:"M12 19V4"}),d.jsx("path",{d:"M16 19V8"}),d.jsx("path",{d:"M20 19V6"}),d.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function V6(){const[t,e]=S.useState(!1),[n,r]=S.useState(LS),[s,i]=S.useState(DS),[o,l]=S.useState(ud),u=PS(),[f,p]=S.useState(zS),[m,g]=S.useState(FS),y=S.useRef(null),b=(T=n,C=s,R=o,L=u,D=f,z=m)=>{$S(T,C,R,L,D,z)},k=T=>{r(T),b(T)},w=()=>{const T=s==="light"?"dark":"light";i(T),b(void 0,T)},E=T=>{l(T),b(void 0,void 0,T),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:T}))},N=T=>{p(T),b(void 0,void 0,void 0,void 0,T)},O=T=>{g(T),b(void 0,void 0,void 0,void 0,void 0,T)};return S.useEffect(()=>{if(!t)return;const T=C=>{y.current&&!y.current.contains(C.target)&&e(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),d.jsxs("div",{className:"appearance-wrapper",ref:y,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Appearance",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),d.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),d.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),d.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),d.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]})}),t&&d.jsxs("div",{className:"appearance-dropdown",children:[d.jsx("div",{className:"appearance-section",children:d.jsxs("div",{className:"appearance-section-header",children:[d.jsx("span",{className:"appearance-section-title",children:"Mode"}),d.jsxs("button",{className:"appearance-mode-btn",onClick:w,title:s==="light"?"Switch to dark":"Switch to light",children:[s==="light"?d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"5"}),d.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),d.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),d.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),d.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),d.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),d.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),d.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),d.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),d.jsx("span",{children:s==="light"?"Light":"Dark"})]})]})}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Typography"})}),d.jsx("div",{className:"appearance-typeface-grid",children:OS.map(T=>d.jsx("button",{className:`appearance-style-option ${n===T.id?"active":""}`,onClick:()=>k(T.id),title:T.description,children:T.label},T.id))})]}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),d.jsx("div",{className:"appearance-typography-grid",children:IS.map(T=>d.jsx("button",{className:`appearance-style-option ${f===T.id?"active":""}`,onClick:()=>N(T.id),children:T.label},T.id))})]}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),d.jsx("div",{className:"appearance-style-grid",children:jS.map(T=>d.jsx("button",{className:`appearance-style-option ${m===T.id?"active":""}`,onClick:()=>O(T.id),children:T.label},T.id))})]}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Layout"})}),d.jsx("div",{className:"appearance-mode-grid",children:RS.map(T=>d.jsxs("button",{className:`appearance-mode-option ${o===T.id?"active":""}`,onClick:()=>E(T.id),children:[q6[T.icon],d.jsx("span",{children:T.label})]},T.id))})]})]})]})}function L1(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function K6(){const[t,e]=S.useState(!1),[n,r]=S.useState([]),[s,i]=S.useState(null),[o,l]=S.useState(new Set),u=S.useRef(null),f=S.useCallback(()=>{fetch("/api/available-plugins").then(g=>g.json()).then(g=>r(g.plugins||[])).catch(()=>{})},[]);S.useEffect(()=>{t&&f()},[t,f]),S.useEffect(()=>{const g=()=>f();return window.addEventListener("ow-plugins-changed",g),()=>window.removeEventListener("ow-plugins-changed",g)},[f]),S.useEffect(()=>{if(!t)return;const g=y=>{u.current&&!u.current.contains(y.target)&&e(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[t]);const p=S.useCallback(async(g,y)=>{i(g);try{(await fetch(y?"/api/plugins/disable":"/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})})).ok&&f()}catch{}finally{i(null)}},[f]),m=S.useCallback((g,y,b)=>{fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,config:{[y]:b}})}).catch(()=>{})},[]);return d.jsxs("div",{className:"plugin-wrapper",ref:u,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Plugins",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 22v-5"}),d.jsx("path",{d:"M9 8V2"}),d.jsx("path",{d:"M15 8V2"}),d.jsx("path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"})]})}),t&&d.jsxs("div",{className:"plugin-dropdown",children:[d.jsx("div",{className:"plugin-dropdown-header",children:"Plugins"}),n.length===0?d.jsx("div",{className:"plugin-empty",children:"No plugins found"}):n.map(g=>d.jsxs("div",{className:"plugin-item",children:[d.jsxs("div",{className:"plugin-item-header",children:[d.jsxs("div",{className:"plugin-item-info",children:[d.jsxs("div",{className:"plugin-item-name",children:[L1(g.name),d.jsxs("span",{className:"plugin-item-version",children:["v",g.version]})]}),g.description&&d.jsx("div",{className:"plugin-item-desc",children:g.description})]}),d.jsxs("label",{className:`plugin-toggle${s===g.name?" loading":""}`,children:[d.jsx("input",{type:"checkbox",checked:g.enabled,disabled:s===g.name,onChange:()=>p(g.name,g.enabled)}),d.jsx("span",{className:"plugin-toggle-track"}),d.jsx("span",{className:"plugin-toggle-thumb"})]})]}),g.enabled&&Object.keys(g.configSchema).length>0&&(()=>{const y=Object.entries(g.configSchema).some(([b,k])=>k.required&&!g.config[b]);return d.jsxs("div",{className:"plugin-config-section",children:[y&&d.jsxs("div",{className:"plugin-setup-hint",children:["Ask your agent: “set up ",L1(g.name),"”"]}),d.jsxs("button",{className:"plugin-config-toggle",onClick:()=>l(b=>{const k=new Set(b);return k.has(g.name)?k.delete(g.name):k.add(g.name),k}),children:[d.jsx("svg",{className:`plugin-config-chevron${o.has(g.name)?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),o.has(g.name)&&d.jsx("div",{className:"plugin-config",children:Object.entries(g.configSchema).map(([b,k])=>d.jsxs("div",{className:"plugin-config-field",children:[d.jsx("label",{className:"plugin-config-label",children:k.description||b}),d.jsx("input",{className:"plugin-config-input",type:b.toLowerCase().includes("key")||b.toLowerCase().includes("secret")||b.toLowerCase().includes("token")?"password":"text",defaultValue:g.config[b]||"",placeholder:k.env?`$${k.env}`:"",onBlur:w=>m(g.name,b,w.target.value)})]},b))})]})})()]},g.name))]})]})}function G6(t){const e=Date.now()-t,n=Math.floor(e/1e3);if(n<60)return"Just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const i=Math.floor(s/24);return i<7?`${i}d ago`:new Date(t).toLocaleDateString()}function J6(t){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function Y6(){const[t,e]=S.useState(!1),[n,r]=S.useState([]),[s,i]=S.useState(null),[o,l]=S.useState(!1),u=S.useRef(null),f=S.useCallback(()=>{fetch("/api/versions").then(m=>m.json()).then(m=>{r(Array.isArray(m)?m:[]),i(null)}).catch(()=>r([]))},[]);S.useEffect(()=>{t&&f()},[t,f]),S.useEffect(()=>{if(!t)return;const m=g=>{u.current&&!u.current.contains(g.target)&&e(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[t]);const p=S.useCallback(async m=>{if(s!==null){l(!0);try{(await fetch(`/api/versions/${s}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:m})})).ok&&f()}catch{}l(!1)}},[s,f]);return d.jsxs("div",{className:"version-wrapper",ref:u,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Version history",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t&&d.jsxs("div",{className:"version-dropdown",children:[d.jsx("div",{className:"version-dropdown__header",children:"Version History"}),d.jsx("div",{className:"version-dropdown__list",children:n.length===0?d.jsx("div",{className:"version-dropdown__empty",children:"No versions yet. Versions are created automatically when you save."}):n.map(m=>d.jsxs("div",{className:`version-dropdown__item${s===m.timestamp?" version-dropdown__item--selected":""}`,onClick:()=>i(m.timestamp===s?null:m.timestamp),children:[d.jsx("span",{className:"version-dropdown__item-time",children:G6(m.timestamp)}),d.jsxs("span",{className:"version-dropdown__item-meta",children:[m.wordCount.toLocaleString()," words · ",J6(m.size)]})]},m.timestamp))}),n.length>0&&d.jsxs("div",{className:"version-dropdown__footer",children:[d.jsx("button",{className:"version-dropdown__review-btn",disabled:s===null||o,onClick:()=>p("review"),children:"Review"}),d.jsx("button",{className:"version-dropdown__restore-btn",disabled:s===null||o,onClick:()=>p("full"),children:"Restore"})]})]})]})}const Q6=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"16 18 22 12 16 6"}),d.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("path",{d:"M14 2v6h6"}),d.jsx("path",{d:"M16 13H8"}),d.jsx("path",{d:"M16 17H8"}),d.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17 6.1H3"}),d.jsx("path",{d:"M21 12.1H3"}),d.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),d.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),d.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function X6(){const[t,e]=S.useState(!1),n=S.useRef(null);S.useEffect(()=>{if(!t)return;const s=i=>{n.current&&!n.current.contains(i.target)&&e(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[t]);const r=s=>{if(e(!1),s==="pdf"){window.open("/api/export?format=pdf","_blank");return}const i=document.createElement("a");i.href=`/api/export?format=${s}`,i.download="",document.body.appendChild(i),i.click(),document.body.removeChild(i)};return d.jsxs("div",{className:"export-wrapper",ref:n,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Export document",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),d.jsx("polyline",{points:"7 10 12 15 17 10"}),d.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),t&&d.jsxs("div",{className:"export-dropdown",children:[d.jsx("div",{className:"export-dropdown__header",children:"Export"}),d.jsx("div",{className:"export-dropdown__list",children:Q6.map(s=>d.jsxs("div",{className:"export-dropdown__item",onClick:()=>r(s.key),children:[d.jsx("span",{className:"export-dropdown__item-icon",children:s.icon}),d.jsxs("span",{className:"export-dropdown__item-text",children:[d.jsx("span",{className:"export-dropdown__item-label",children:s.label}),d.jsx("span",{className:"export-dropdown__item-desc",children:s.desc})]})]},s.key))})]})]})}function Z6({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=S.useState("form"),[i,o]=S.useState(null),[l,u]=S.useState((t==null?void 0:t.domain)||""),[f,p]=S.useState(""),[m,g]=S.useState((t==null?void 0:t.from_name)||""),[y,b]=S.useState(""),[k,w]=S.useState((t==null?void 0:t.id)||""),[E,N]=S.useState({dns_verified:!1,sender_verified:!1}),O=S.useRef(null),T=S.useRef(null);S.useEffect(()=>{const J=K=>{r!=="submitting"&&r!=="verifying"&&T.current&&!T.current.contains(K.target)&&e()};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[e,r]),S.useEffect(()=>{const J=K=>{K.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[e,r]),S.useEffect(()=>()=>{O.current&&clearInterval(O.current)},[]);async function C(){var J,K;s("submitting"),o(null);try{const W=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:l,from_email:f,from_name:m||void 0,physical_address:y}})})).json(),$=(K=(J=W.content)==null?void 0:J[0])!=null&&K.text?JSON.parse(W.content[0].text):W;if($.error){o($.error),s("error");return}const U=$.connectionId||$.connection_id||k;U&&w(U),L(U)}catch(X){o(X.message),s("error")}}async function R(){var J,K;s("submitting"),o(null);try{const W=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:l,from_email:f||void 0,from_name:m||void 0,physical_address:y||void 0}})})).json(),$=(K=(J=W.content)==null?void 0:J[0])!=null&&K.text?JSON.parse(W.content[0].text):W;if($.error){o($.error),s("error");return}s("done")}catch(X){o(X.message),s("error")}}function L(J){s("verifying"),O.current=setInterval(async()=>{var K,X;try{const $=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:J}})})).json(),U=(X=(K=$.content)==null?void 0:K[0])!=null&&X.text?JSON.parse($.content[0].text):$,Z=!!U.dns_verified,V=!!U.sender_verified;N({dns_verified:Z,sender_verified:V}),Z&&V&&(O.current&&clearInterval(O.current),O.current=null,s("done"))}catch{}},5e3)}function D(){k&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:k}})}).catch(()=>{})}const z=!!t,F=l.trim()&&f.trim()&&y.trim();return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"newsletter-modal newsletter-modal--setup",ref:T,children:[d.jsxs("div",{className:"newsletter-modal__header",children:[d.jsx("h3",{children:z?"Newsletter Settings":"Set Up Newsletter"}),d.jsx("button",{className:"newsletter-modal__close",onClick:e,children:"×"})]}),d.jsxs("div",{className:"newsletter-modal__body",children:[r==="form"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsx("label",{className:"newsletter-modal__label",children:"Domain"}),d.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"yourdomain.com",value:l,onChange:J=>u(J.target.value),disabled:z,autoComplete:"off"})]}),d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsx("label",{className:"newsletter-modal__label",children:"From Email"}),d.jsx("input",{className:"newsletter-modal__input",type:"email",placeholder:"newsletter@yourdomain.com",value:f,onChange:J=>p(J.target.value),autoComplete:"off"})]}),d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsxs("label",{className:"newsletter-modal__label",children:["From Name ",d.jsx("span",{className:"newsletter-modal__optional",children:"(optional)"})]}),d.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"Your Name or Brand",value:m,onChange:J=>g(J.target.value),autoComplete:"off"})]}),d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsxs("label",{className:"newsletter-modal__label",children:["Physical Address ",d.jsx("span",{className:"newsletter-modal__required",children:"*"})]}),d.jsx("textarea",{className:"newsletter-modal__input newsletter-modal__textarea",rows:2,placeholder:"123 Main St, City, State 12345",value:y,onChange:J=>b(J.target.value)}),d.jsx("span",{className:"newsletter-modal__hint",children:"Required by CAN-SPAM. Included in email footer."})]}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:z?R:C,disabled:!F,children:z?"Save":"Set Up Domain"})]})]}),r==="submitting"&&d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:z?"Saving...":"Setting up domain..."})]}),r==="verifying"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"newsletter-modal__verify",children:[d.jsx("p",{className:"newsletter-modal__verify-title",children:"Verifying domain setup..."}),d.jsxs("div",{className:"newsletter-modal__verify-checks",children:[d.jsxs("div",{className:`newsletter-modal__verify-item${E.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[E.dns_verified?"✓":d.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),d.jsx("span",{children:"DNS records"})]}),d.jsxs("div",{className:`newsletter-modal__verify-item${E.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[E.sender_verified?"✓":d.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),d.jsx("span",{children:"Sender verification"})]})]}),d.jsx("p",{className:"newsletter-modal__hint",children:"This may take a few minutes. You can close and check back later."})]}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:D,children:"Resend Verification"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Close"})]})]}),r==="done"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:z?"Settings saved!":"Newsletter domain configured!"}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Done"})})]}),r==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__error",children:i}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s("form"),children:"Try Again"})]})]})]})]})})}const eB={github:[{key:"owner",label:"Owner",placeholder:"username or org",readonly:!0},{key:"repo",label:"Repository",placeholder:"my-blog",readonly:!0},{key:"branch",label:"Branch",placeholder:"main"},{key:"contentDir",label:"Content Directory",placeholder:"src/content/blog",required:!0},{key:"imageDir",label:"Image Directory",placeholder:"public/images/blog"}],x:[],linkedin:[]};function tB({connectionId:t,provider:e,displayName:n,onClose:r,onSaved:s}){const[i,o]=S.useState("loading"),[l,u]=S.useState({}),[f,p]=S.useState(null),m=S.useRef(null),g=eB[e]||[];S.useEffect(()=>{fetch(`/api/connections/${t}/config`).then(k=>k.json()).then(k=>{u(k.config||{}),o("form")}).catch(k=>{p(k.message),o("error")})},[t]),S.useEffect(()=>{const k=w=>{i!=="saving"&&m.current&&!m.current.contains(w.target)&&r()};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[r,i]),S.useEffect(()=>{const k=w=>{w.key==="Escape"&&i!=="saving"&&r()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[r,i]);async function y(){o("saving"),p(null);try{const k=await fetch(`/api/connections/${t}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),w=await k.json();if(!k.ok)throw new Error(w.error||"Failed to save");o("saved"),s(),setTimeout(r,800)}catch(k){p(k.message),o("error")}}function b(k){switch(k){case"x":return"X (Twitter)";case"linkedin":return"LinkedIn";case"github":return"GitHub";default:return k}}return d.jsx("div",{className:"conn-config-overlay",children:d.jsxs("div",{className:"conn-config-modal",ref:m,children:[d.jsxs("div",{className:"conn-config-modal__header",children:[d.jsxs("div",{className:"conn-config-modal__title",children:[b(e)," Settings"]}),d.jsx("div",{className:"conn-config-modal__subtitle",children:n})]}),i==="loading"&&d.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[d.jsx("div",{className:"conn-config-spinner"}),d.jsx("span",{children:"Loading configuration..."})]}),(i==="form"||i==="error")&&g.length>0&&d.jsxs("div",{className:"conn-config-modal__body",children:[g.map(k=>d.jsxs("div",{className:"conn-config-field",children:[d.jsxs("label",{className:"conn-config-field__label",children:[k.label,k.readonly&&d.jsx("span",{className:"conn-config-field__badge",children:"read-only"})]}),d.jsx("input",{className:"conn-config-field__input",value:l[k.key]||"",placeholder:k.placeholder,readOnly:k.readonly,onChange:w=>u(E=>({...E,[k.key]:w.target.value}))})]},k.key)),f&&d.jsx("div",{className:"conn-config-modal__error",children:f})]}),(i==="form"||i==="error")&&g.length===0&&d.jsx("div",{className:"conn-config-modal__body conn-config-modal__center",children:d.jsxs("span",{className:"conn-config-modal__empty",children:["No configuration needed for ",b(e),"."]})}),i==="saving"&&d.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[d.jsx("div",{className:"conn-config-spinner"}),d.jsx("span",{children:"Saving..."})]}),i==="saved"&&d.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[d.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),d.jsx("span",{children:"Saved"})]}),d.jsxs("div",{className:"conn-config-modal__footer",children:[d.jsx("button",{className:"conn-config-btn conn-config-btn--secondary",onClick:r,children:i==="saved"?"Close":"Cancel"}),g.length>0&&(i==="form"||i==="error")&&d.jsx("button",{className:"conn-config-btn conn-config-btn--primary",onClick:y,children:"Save"})]})]})})}const nB=[{id:"x",label:"X (Twitter)",oauth:!0},{id:"linkedin",label:"LinkedIn",oauth:!0},{id:"github",label:"GitHub",oauth:!0},{id:"newsletter",label:"Newsletter",oauth:!1}];function rB(){const[t,e]=S.useState(!1),[n,r]=S.useState([]),[s,i]=S.useState(null),[o,l]=S.useState(null),[u,f]=S.useState(null),[p,m]=S.useState(null),g=S.useRef(null),y=S.useRef(null);S.useEffect(()=>{if(!t)return;const T=C=>{g.current&&!g.current.contains(C.target)&&(e(!1),i(null))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),S.useEffect(()=>{t&&b()},[t]),S.useEffect(()=>()=>{y.current&&clearInterval(y.current)},[]);function b(){fetch("/api/connections").then(T=>T.json()).then(T=>{const C=(T.connections||[]).filter(R=>R&&R.id&&R.provider);r(C)}).catch(()=>{})}async function k(T){l(T);try{const C=await fetch(`/api/connections/oauth/${T}/start`,{method:"POST"}),R=await C.json();if(!C.ok||!R.url){l(null);return}window.open(R.url,"_blank","width=600,height=700"),y.current=setInterval(async()=>{try{const D=await(await fetch(`/api/connections/oauth/${T}/status/${R.state}`)).json();D.status==="completed"?(y.current&&clearInterval(y.current),y.current=null,l(null),b()):D.status==="failed"&&(y.current&&clearInterval(y.current),y.current=null,l(null))}catch{}},2e3)}catch{l(null)}}async function w(T){try{const C=await fetch(`/api/connections/${T}`,{method:"DELETE"});if(!C.ok){const R=await C.json().catch(()=>({error:"Delete failed"}));console.error("[Connections] Delete failed:",R.error)}}catch(C){console.error("[Connections] Delete error:",C)}i(null),await b()}function E(T){return T==="active"?"connections-status--active":T==="expired"?"connections-status--expired":T==="revoked"?"connections-status--revoked":"connections-status--pending"}function N(T){switch(T){case"x":return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})});case"linkedin":return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})});case"github":return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z"})});case"newsletter":return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),d.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});default:return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),d.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}}const O=new Map;for(const T of n)O.set(T.provider,T);return d.jsxs("div",{className:"connections-wrapper",ref:g,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Connections",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"5",r:"3"}),d.jsx("circle",{cx:"5",cy:"19",r:"3"}),d.jsx("circle",{cx:"19",cy:"19",r:"3"}),d.jsx("line",{x1:"12",y1:"8",x2:"5",y2:"16"}),d.jsx("line",{x1:"12",y1:"8",x2:"19",y2:"16"})]})}),p&&d.jsx(tB,{connectionId:p.id,provider:p.provider,displayName:p.display_name,onClose:()=>m(null),onSaved:()=>b()}),u&&d.jsx(Z6,{existingConnection:u==="edit"?O.get("newsletter"):null,onClose:()=>f(null),onSaved:()=>b()}),t&&d.jsxs("div",{className:"connections-dropdown",children:[d.jsx("div",{className:"connections-dropdown__header",children:"Connections"}),d.jsx("div",{className:"connections-dropdown__list",children:nB.map(T=>{const C=O.get(T.id);return C&&s===C.id?d.jsxs("div",{className:"connections-dropdown__confirm",children:[d.jsxs("span",{children:["Disconnect ",T.label,"?"]}),d.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[d.jsx("button",{onClick:()=>w(C.id),children:"Yes"}),d.jsx("button",{onClick:()=>i(null),children:"No"})]})]},T.id):C?d.jsxs("div",{className:"connections-dropdown__item",children:[d.jsx("div",{className:"connections-dropdown__icon",children:N(T.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:C.display_name||C.domain||T.label}),d.jsxs("div",{className:"connections-dropdown__type",children:[d.jsx("span",{className:`connections-status ${E(C.status)}`}),"Connected"]})]}),d.jsxs("div",{className:"connections-dropdown__actions",children:[d.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>{T.id==="newsletter"?f("edit"):m({id:C.id,provider:T.id,display_name:C.display_name||T.label})},title:"Settings",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),d.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>i(C.id),title:"Disconnect",children:"×"})]})]},T.id):T.oauth?d.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[d.jsx("div",{className:"connections-dropdown__icon",children:N(T.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:T.label}),d.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),d.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>k(T.id),disabled:o!==null,children:o===T.id?"Connecting…":"Connect"})]},T.id):d.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[d.jsx("div",{className:"connections-dropdown__icon",children:N(T.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:T.label}),d.jsx("div",{className:"connections-dropdown__type",children:"Built-in · Not configured"})]}),d.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>f("new"),children:"Configure"})]},T.id)})})]})]})}const sB=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),iB=()=>d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),oB=()=>d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),aB=()=>d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function lB({title:t,onTitleChange:e,syncStatus:n,onSync:r,onToggleSidebar:s,canGoBack:i,canGoForward:o,onGoBack:l,onGoForward:u,editor:f,onToggleToolbar:p,toolbarOpen:m}){const[g,y]=S.useState(!1),[,b]=S.useState(0),k=S.useRef(null),[w,E]=S.useState(!1),[N,O]=S.useState([]),[T,C]=S.useState(!1),R=S.useRef(null),[L,D]=S.useState(null);S.useEffect(()=>{fetch("/api/update-info").then(X=>X.json()).then(X=>{X.updateAvailable&&D({currentVersion:X.currentVersion,latestVersion:X.updateAvailable})}).catch(()=>{})},[]);const z=S.useCallback(()=>{y(!0),setTimeout(()=>{var X;return(X=k.current)==null?void 0:X.select()},0)},[]),F=S.useCallback(()=>{y(!1)},[]),J=S.useCallback(X=>{X.key==="Enter"&&y(!1),X.key==="Escape"&&y(!1)},[]),K=S.useCallback(()=>{if(w){E(!1);return}E(!0),C(!0),fetch("/api/sync/pending").then(X=>X.json()).then(X=>O(X)).catch(()=>O([])).finally(()=>C(!1))},[w]);return S.useEffect(()=>{n.state!=="pending"&&E(!1)},[n.state]),S.useEffect(()=>{if(!w)return;const X=W=>{R.current&&!R.current.contains(W.target)&&E(!1)};return document.addEventListener("mousedown",X),()=>document.removeEventListener("mousedown",X)},[w]),S.useEffect(()=>{if(!f)return;const X=()=>b(W=>W+1);return f.on("transaction",X),()=>{f.off("transaction",X)}},[f]),d.jsxs("div",{className:"titlebar",children:[d.jsxs("div",{className:"titlebar-left",children:[s&&d.jsx("button",{className:"titlebar-menu-btn",onClick:s,title:"Open sidebar",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),l&&d.jsx("button",{className:"titlebar-nav-btn",onClick:l,disabled:!i,title:"Go back (Alt+Left)",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),u&&d.jsx("button",{className:"titlebar-nav-btn",onClick:u,disabled:!o,title:"Go forward (Alt+Right)",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),f&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"titlebar-divider"}),d.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo (Ctrl+Z)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),d.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo (Ctrl+Y)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),d.jsxs("div",{className:"titlebar-center",children:[g?d.jsx("input",{ref:k,className:"titlebar-input",value:t,onChange:X=>e(X.target.value),onBlur:F,onKeyDown:J,autoFocus:!0}):d.jsx("span",{className:"titlebar-title",onDoubleClick:z,children:t}),L&&d.jsxs("span",{className:"titlebar-update-badge",title:`Update available: v${L.currentVersion} → v${L.latestVersion}
204
+ Run: npm update -g openwriter`,children:["v",L.latestVersion]})]}),d.jsxs("div",{className:"titlebar-right",children:[p&&d.jsx("button",{className:`titlebar-nav-btn${m?" titlebar-nav-btn--active":""}`,onClick:p,title:"Toggle format toolbar",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 20h16"}),d.jsx("path",{d:"m6 16 6-12 6 12"}),d.jsx("path",{d:"M8 12h8"})]})}),d.jsx(K6,{}),d.jsx(rB,{}),d.jsx(V6,{}),d.jsx(Y6,{}),d.jsx(X6,{}),d.jsxs("div",{className:"sync-btn-group",ref:R,children:[d.jsxs("button",{className:`titlebar-btn sync-btn-state sync-${n.state}`,onClick:r,disabled:n.state==="syncing",title:n.lastSyncTime?`Last synced: ${new Date(n.lastSyncTime).toLocaleString()}`:"Sync to GitHub",children:[n.state==="unconfigured"&&d.jsxs(d.Fragment,{children:[d.jsx(sB,{})," Sync"]}),n.state==="synced"&&d.jsxs(d.Fragment,{children:[d.jsx(iB,{})," Synced"]}),n.state==="pending"&&d.jsxs(d.Fragment,{children:[d.jsx(oB,{})," Sync",n.pendingFiles?` (${n.pendingFiles})`:""]}),n.state==="syncing"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),n.state==="error"&&d.jsxs(d.Fragment,{children:[d.jsx(aB,{})," Retry"]})]}),n.state==="pending"&&n.pendingFiles&&n.pendingFiles>0&&d.jsx("button",{className:"sync-details-btn",onClick:K,title:"View pending changes",children:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:d.jsx("path",{d:w?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),w&&d.jsxs("div",{className:"sync-pending-dropdown",children:[d.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),T?d.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):N.length===0?d.jsx("div",{className:"sync-pending-loading",children:"No changes"}):d.jsx("div",{className:"sync-pending-list",children:N.map((X,W)=>d.jsxs("div",{className:`sync-pending-item sync-file-${X.status}`,children:[d.jsx("span",{className:"sync-file-badge",children:X.status[0].toUpperCase()}),d.jsx("span",{className:"sync-file-name",children:X.file})]},W))})]})]})]})]})}function yn(t,e){let n=null;return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function Cd(t,e){const n=[];return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.pendingGroupId)===e&&n.push({nodeId:r.attrs.id,pos:s,node:r}),!0}),n}function zo(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function ld(t){return t?Array.isArray(t)?t.map(ld).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>ld(e)).join(""):"":""}const cB=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function cd(t,e){for(const n of t)n.type&&cB.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&cd(n.content,e)}function _g(t,e,n){const r=Array.isArray(n)?n:[n];if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const y=yn(t,e.nodeId);if(!y)return{success:!1,error:`Node ${e.nodeId} not found`};const b=r.map((k,w)=>{var E;return{...k,attrs:{...k.attrs,id:((E=k.attrs)==null?void 0:E.id)||(w===0?e.nodeId:zo())}}});cd(b,"insert");try{return t.chain().deleteRange({from:y.pos,to:y.pos+y.node.nodeSize}).insertContentAt(y.pos,b).run(),{success:!0,nodeId:e.nodeId}}catch(k){return{success:!1,error:`Failed to replace empty node: ${k}`}}}if(!e.afterNodeId&&!e.beforeNodeId)return{success:!1,error:"Insert requires afterNodeId, beforeNodeId, or nodeId"};const s=e.afterNodeId||e.beforeNodeId,i=!!e.afterNodeId,o=yn(t,s);if(!o)return{success:!1,error:`Anchor node ${s} not found`};const l=ld(n),u=i?o.pos+o.node.nodeSize:0,f=i?o.pos+o.node.nodeSize+5e3:o.pos;let p=null;if(t.state.doc.nodesBetween(u,Math.min(f,t.state.doc.content.size),y=>{var b,k;return((b=y.attrs)==null?void 0:b.pendingStatus)==="insert"&&((k=y.attrs)!=null&&k.id)&&(y.textContent||"")===l?(p=y.attrs.id,!1):!0}),p)return{success:!0,nodeId:p};const m=r.map(y=>{var b;return{...y,attrs:{...y.attrs,id:((b=y.attrs)==null?void 0:b.id)||zo()}}});cd(m,"insert");const g=i?o.pos+o.node.nodeSize:o.pos;try{return t.chain().insertContentAt(g,m).run(),{success:!0,nodeId:m[0].attrs.id}}catch(y){return{success:!1,error:`Failed to insert content: ${y}`}}}function M0(t,e,n,r){var y;const s=yn(t,e);if(!s)return{success:!1,error:`Node ${e} not found`};const{node:i,pos:o}=s,l=Array.isArray(n)?n:[n],f=!((y=i.attrs)!=null&&y.pendingOriginalContent)?i.toJSON():i.attrs.pendingOriginalContent,p={...l[0],attrs:{...l[0].attrs,id:e,pendingStatus:"rewrite",pendingOriginalContent:f,...r?{pendingSelectionFrom:r.selectionFrom,pendingSelectionTo:r.selectionTo,pendingOriginalFrom:r.originalFrom,pendingOriginalTo:r.originalTo}:{}}},m=l.slice(1).map(b=>{var k;return{...b,attrs:{...b.attrs,id:((k=b.attrs)==null?void 0:k.id)||zo()}}});cd(m,"insert");const g=[p,...m];try{return t.chain().command(({tr:b})=>{const k=g.map(w=>t.state.schema.nodeFromJSON(w));return b.replaceWith(o,o+i.nodeSize,k),!0}).run(),{success:!0,nodeId:e}}catch(b){return{success:!1,error:`Failed to rewrite: ${b}`}}}function uB(t,e,n){if(e.length===0)return{success:!1,error:"Range rewrite requires original IDs"};if(!n||n.length===0)return{success:!1,error:"Range rewrite requires new content (received empty)"};if(n.map(m=>ld(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=yn(t,e[0]),i=yn(t,e[e.length-1]);if(!s||!i)return{success:!1,error:"Could not find original nodes for range rewrite"};const o=[];for(const m of e){const g=yn(t,m);g&&o.push(g.node.toJSON())}const l=s.pos,u=i.pos+i.node.nodeSize,f=zo()+zo(),p=n.map((m,g)=>{var y;return{...m,attrs:{...m.attrs,id:((y=m.attrs)==null?void 0:y.id)||zo(),pendingStatus:"rewrite",pendingGroupId:f,...g===0?{pendingOriginalContent:o}:{}}}});try{return t.chain().deleteRange({from:l,to:u}).insertContentAt(l,p).run(),{success:!0,nodeId:p[0].attrs.id}}catch(m){return{success:!1,error:`Failed to apply range rewrite: ${m}`}}}function kC(t,e){var i;const n=yn(t,e);if(!n)return{success:!1,error:`Node ${e} not found`};const{node:r,pos:s}=n;if(((i=r.attrs)==null?void 0:i.pendingStatus)==="delete")return{success:!0,nodeId:e};try{return t.chain().command(({tr:o})=>(o.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:"delete"}),!0)).run(),{success:!0,nodeId:e}}catch(o){return{success:!1,error:`Failed to mark for deletion: ${o}`}}}function dB(t,e){if(e.operation==="rewrite"&&e.nodeId&&e.content){const n=M0(t,e.nodeId,e.content);return{success:n.success,error:n.error}}if(e.operation==="insert"&&e.content){let n=null;if(e.nodeId&&!e.afterNodeId?n={nodeId:e.nodeId}:e.afterNodeId&&(n={afterNodeId:e.afterNodeId}),!n)return{success:!1,error:"Insert requires afterNodeId or nodeId"};const r=_g(t,n,e.content);return{success:r.success,error:r.error}}if(e.operation==="delete"&&e.nodeId){const n=kC(t,e.nodeId);return{success:n.success,error:n.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function ap(t,e){if(e.length===0)return;if(e.length===1){dB(t,e[0]);return}const n=t.state.schema;t.chain().command(({tr:r})=>{var s;for(const i of e)try{if(i.operation==="rewrite"&&i.nodeId&&i.content){const o=tu(r.doc,i.nodeId);if(!o)continue;const u=(Array.isArray(i.content)?i.content:[i.content]).map(f=>n.nodeFromJSON(f));r.replaceWith(o.pos,o.pos+o.node.nodeSize,u)}else if(i.operation==="insert"&&i.content){const l=(Array.isArray(i.content)?i.content:[i.content]).map(u=>n.nodeFromJSON(u));if(i.nodeId&&!i.afterNodeId){const u=tu(r.doc,i.nodeId);if(!u)continue;r.replaceWith(u.pos,u.pos+u.node.nodeSize,l)}else if(i.afterNodeId){const u=tu(r.doc,i.afterNodeId);if(!u)continue;const f=u.pos+u.node.nodeSize;r.insert(f,de.fromArray(l))}}else if(i.operation==="delete"&&i.nodeId){const o=tu(r.doc,i.nodeId);if(!o||((s=o.node.attrs)==null?void 0:s.pendingStatus)==="delete")continue;r.setNodeMarkup(o.pos,void 0,{...o.node.attrs,pendingStatus:"delete"})}}catch{continue}return!0}).run()}function tu(t,e){let n=null;return t.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function fB(t,e,n,r){const s=[];if(r==="delete"){for(const o of n)s.push(kC(t,o));return s}if(r==="insert"){const o=n[n.length-1];return o&&e.length>0&&s.push(_g(t,{nodeId:o},e)),s}if(n.length>1){const o=uB(t,n,e);return s.push(o),s}const i=M0(t,n[0],e[0]);if(s.push(i),e.length>1){const o=e.slice(1);s.push(_g(t,{afterNodeId:n[0]},o))}return s}const D1="[[START_SELECTION]]",P1="[[END_SELECTION]]";function hB(t){if(!(t!=null&&t.content)||!Array.isArray(t.content))return 0;let e=0;for(const n of t.content)n.type==="text"&&typeof n.text=="string"?e+=n.text.length:n.type==="hardBreak"&&(e+=1);return e}function nu(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=hB(t);let s=Math.max(0,Math.min(e,r));for(let i=0;i<t.content.length;i++){const o=t.content[i];if(o.type==="text"&&typeof o.text=="string"){if(s<=o.text.length){const l=Math.max(0,Math.min(o.text.length,s));o.text=o.text.slice(0,l)+n+o.text.slice(l);return}s-=o.text.length;continue}if(o.type==="hardBreak"){if(s===0){t.content.splice(i+1,0,{type:"text",text:n});return}s-=1;continue}if(s===0){t.content.splice(i,0,{type:"text",text:n});return}}t.content.push({type:"text",text:n})}function pB(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(nu(r[0],n,P1),nu(r[0],e,D1),r):(nu(r[0],e,D1),nu(r[r.length-1],n,P1),r)}function mB(t){const e=r=>r.replace(/\[\[(START|END)_SELECTION]]/g,""),n=r=>{r.type==="text"&&typeof r.text=="string"&&(r.text=e(r.text)),r.content&&Array.isArray(r.content)&&r.content.forEach(n)};Array.isArray(t)?t.forEach(n):n(t)}const gB=[{action:"agent-mark",label:"Agent Mark",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function vB({editorRef:t,allEditors:e,documentId:n}){const[r,s]=S.useState(!1),[i,o]=S.useState({x:0,y:0}),[l,u]=S.useState(!1),[f,p]=S.useState(""),[m,g]=S.useState(!1),[y,b]=S.useState(""),[k,w]=S.useState(!1),[E,N]=S.useState([]),[O,T]=S.useState([]),[C,R]=S.useState(!1),[L,D]=S.useState(""),[z,F]=S.useState([]),[J,K]=S.useState(!1),[X,W]=S.useState(""),$=S.useRef(null),U=S.useRef(null),Z=S.useRef(null),V=S.useCallback(ce=>{if(e&&e.length>0){for(const ae of e)if(ae.view.dom.contains(ce))return ae}const ue=t.current;return ue&&ue.view.dom.contains(ce)?ue:null},[e,t]);S.useLayoutEffect(()=>{const ce=$.current;if(!ce||!r)return;const ue=ce.getBoundingClientRect(),ae=8;let{x:je,y:Me}=i;Me+ue.height+ae>window.innerHeight&&(Me=i.y-ue.height),je+ue.width+ae>window.innerWidth&&(je=i.x-ue.width),Me<ae&&(Me=ae),je<ae&&(je=ae),(je!==i.x||Me!==i.y)&&o({x:je,y:Me})},[r,i]);const Y=S.useCallback(()=>{fetch("/api/plugins").then(ce=>ce.json()).then(ce=>{const ue=[];for(const ae of ce.plugins||[]){const je=ae.displayName||void 0;for(const Me of ae.contextMenuItems||[])ue.push({...Me,pluginDisplayName:je})}F(ue)}).catch(()=>{})},[]);S.useEffect(()=>{Y()},[Y]),S.useEffect(()=>{const ce=()=>Y();return window.addEventListener("ow-plugins-changed",ce),()=>window.removeEventListener("ow-plugins-changed",ce)},[Y]),S.useEffect(()=>{const ce=ue=>{$.current&&!$.current.contains(ue.target)&&(s(!1),g(!1),w(!1),K(!1),W(""))};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[]);const I=S.useCallback(()=>{const ce=Z.current||t.current;return ce?ce.isActive("link"):!1},[t]),A=S.useCallback(()=>{const ce=Z.current||t.current,ue=U.current;if(!ce||!ue)return!1;const{from:ae,to:je}=ue;let Me=!1;return ce.state.doc.nodesBetween(ae,je,He=>{var Ne;return(Ne=He.attrs)!=null&&Ne.pendingStatus&&(Me=!0),!Me}),Me},[t]),j=S.useCallback(()=>{const ce=Z.current||t.current,ue=U.current,ae=(ue==null?void 0:ue.from)??0,je=(ue==null?void 0:ue.to)??0,Me=ae!==je,He=(()=>{if(!ce)return!1;try{return ce.state.doc.resolve(ae).parent.content.size===0}catch{return!1}})(),Ne=A(),tt=[];for(const Be of z)Be.condition==="has-selection"&&!Me||Be.condition==="empty-node"&&!He||tt.push({action:Be.action,label:Be.label,shortcut:Be.shortcut,isPlugin:!0,promptForInput:Be.promptForInput,pluginDisplayName:Be.pluginDisplayName});for(const Be of gB)Be.condition==="has-selection"&&(!Me||Ne)||tt.push(Be);return Me&&tt.push({action:"link",label:"Link to doc",shortcut:"L"}),I()&&tt.push({action:"unlink",label:"Unlink"}),tt},[t,I,z,A]);S.useEffect(()=>{const ce=ae=>{var Be;if(ae.button!==2)return;const je=V(ae.target);if(!je)return;Z.current=je;const{from:Me,to:He}=je.state.selection,Ne=[],tt=[];if(Me!==He&&je.state.doc.nodesBetween(Me,He,$e=>{$e.isBlock&&$e.type.name!=="doc"&&(Ne.push($e.toJSON()),$e.attrs.id&&tt.push($e.attrs.id))}),Ne.length===0){const{$from:$e}=je.state.selection,ye=$e.parent;ye&&ye.type.name!=="doc"&&(Ne.push(ye.toJSON()),(Be=ye.attrs)!=null&&Be.id&&tt.push(ye.attrs.id))}U.current={from:Me,to:He,nodes:Ne,nodeIds:tt}},ue=ae=>{V(ae.target)&&(ae.shiftKey||(ae.preventDefault(),o({x:ae.clientX,y:ae.clientY}),s(!0),g(!1),w(!1),K(!1),W("")))};return document.addEventListener("mousedown",ce,!0),document.addEventListener("contextmenu",ue),()=>{document.removeEventListener("mousedown",ce,!0),document.removeEventListener("contextmenu",ue)}},[V]);const Q=S.useCallback(async(ce,ue)=>{var Ze,Ae,be,ke,ze;const ae=Z.current||t.current;if(!ae)return;const je=U.current;if(!je||je.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",ce);return}let{nodes:Me,nodeIds:He}=je;const{from:Ne,to:tt}=je;u(!0),s(!1),g(!1);const Be=`ctx-${Date.now()}`,$e=ae.state.doc.resolve(Ne),ye=ae.state.doc.resolve(tt),pe=$e.sameParent(ye)&&Ne!==tt;ae.commands.applyLoadingEffect(Be,Ne,tt,pe?"selection":"paragraph");try{const ht=[],wt=[],kt=new Set(He);let Bt=!1;const xn=ae.state.doc;for(let ee=0;ee<xn.childCount;ee++){const Ce=xn.child(ee),lt=(Ze=Ce.attrs)==null?void 0:Ze.id;if(lt&&kt.has(lt))Bt=!0;else if(Bt){const B=Ce.textContent.trim();B&&wt.push(B)}else{const B=Ce.textContent.trim();B&&ht.push(B)}}const An=ce.includes(":")?ce.split(":").slice(1).join(":"):ce;let On=Me,wn=!1,re=0,Je=0;if(pe&&Me.length===1){const ee=$e.start($e.depth);re=Ne-ee,Je=tt-ee;const Ce=((be=(Ae=Me[0])==null?void 0:Ae.content)==null?void 0:be.reduce((lt,B)=>{var se;return lt+(((se=B.text)==null?void 0:se.length)||(B.type==="hardBreak"?1:0))},0))??0;(re>0||Je<Ce)&&(On=pB(Me,re,Je),wn=!0)}const et=ae.state.doc.textContent,Et={nodes:On,action:An,nodeIds:He,contextBefore:ht.slice(-3),contextAfter:wt.slice(0,3),fullDocument:et,documentId:n,debug:!0};wn&&(Et.hasSelectionMarkers=!0),ue&&(Et.instruction=ue);const rt=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Et)});if(!rt.ok){const ee=await rt.json().catch(()=>({}));console.error("[ContextMenu] API error:",rt.status,ee);return}const nt=await rt.json();if(nt.success&&nt.nodes){let ee=nt.nodes;if(ee.length===1&&Array.isArray(ee[0])&&(ee=ee[0]),mB(ee),wn&&ee.length===1&&He.length===1){const Ce=Se=>(Se==null?void 0:Se.reduce((st,Mt)=>{var Ot;return st+(((Ot=Mt.text)==null?void 0:Ot.length)||(Mt.type==="hardBreak"?1:0))},0))??0,lt=Ce((ke=Me[0])==null?void 0:ke.content),B=Ce((ze=ee[0])==null?void 0:ze.content),se={selectionFrom:re,selectionTo:B-(lt-Je),originalFrom:re,originalTo:Je};M0(ae,He[0],ee[0],se)}else fB(ae,ee,He,An)}else console.warn("[ContextMenu] Unexpected response:",nt)}catch(ht){console.error("[ContextMenu] Plugin action failed:",ht)}finally{ae.commands.removeLoadingEffect(Be),u(!1)}},[t]),oe=S.useCallback(async ce=>{const ue=Z.current||t.current;if(!ue)return;const{$from:ae}=ue.state.selection,je=ae.before(ae.depth),Me=ae.after(ae.depth),He=ae.parent.content.size===0;u(!0),s(!1),g(!1),He?ue.chain().focus().deleteRange({from:je,to:Me}).insertContentAt(je,{type:"imageLoading"}).run():ue.chain().focus().insertContentAt(Me,{type:"imageLoading"}).run();let Ne=-1;ue.state.doc.descendants((tt,Be)=>{if(tt.type.name==="imageLoading"&&Ne===-1)return Ne=Be,tt.nodeSize,!1});try{const Be=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:ce})})).json();if(Be.success&&Be.src){let $e=-1,ye=0;if(ue.state.doc.descendants((pe,Ze)=>{if(pe.type.name==="imageLoading"&&$e===-1)return $e=Ze,ye=pe.nodeSize,!1}),$e>=0){const{tr:pe}=ue.state;pe.replaceWith($e,$e+ye,ue.schema.nodes.image.create({src:Be.src,alt:ce})),ue.view.dispatch(pe)}}else{console.error("[ContextMenu] Image generation failed:",Be.error);let $e=-1,ye=0;if(ue.state.doc.descendants((pe,Ze)=>{if(pe.type.name==="imageLoading"&&$e===-1)return $e=Ze,ye=pe.nodeSize,!1}),$e>=0){const{tr:pe}=ue.state;pe.delete($e,$e+ye),ue.view.dispatch(pe)}}}catch(tt){console.error("[ContextMenu] Image generation failed:",tt);let Be=-1,$e=0;if(ue.state.doc.descendants((ye,pe)=>{if(ye.type.name==="imageLoading"&&Be===-1)return Be=pe,$e=ye.nodeSize,!1}),Be>=0){const{tr:ye}=ue.state;ye.delete(Be,Be+$e),ue.view.dispatch(ye)}}finally{u(!1)}},[t]),fe=S.useCallback(ce=>{const{action:ue,isPlugin:ae,promptForInput:je}=ce;if(ae&&je){b(ue),g(!0);return}if(ae){if(ue.startsWith("img:"))return;Q(ue);return}if(ue==="agent-mark"){K(!0);return}if(ue==="delete"){const Me=Z.current||t.current,He=U.current;if(Me&&He&&He.nodeIds.length>0){const{tr:Ne}=Me.state,tt=new Set(He.nodeIds),Be=[];Me.state.doc.descendants(($e,ye)=>{var pe;if((pe=$e.attrs)!=null&&pe.id&&tt.has($e.attrs.id))return Be.push({from:ye,to:ye+$e.nodeSize}),!1});for(const $e of Be.reverse())Ne.delete($e.from,$e.to);Be.length>0&&Me.view.dispatch(Ne)}s(!1);return}if(ue==="link"){const Me=Z.current||t.current;if(Me){const He=[];Me.state.doc.descendants(Ne=>{var tt;(tt=Ne.marks)==null||tt.forEach(Be=>{var $e,ye;if(Be.type.name==="link"&&((ye=($e=Be.attrs)==null?void 0:$e.href)!=null&&ye.startsWith("doc:"))){const pe=Be.attrs.href.slice(4);He.includes(pe)||He.push(pe)}})}),T(He)}fetch("/api/documents").then(He=>He.json()).then(He=>{Array.isArray(He)&&N(He.map(Ne=>({filename:Ne.filename,title:Ne.title}))),R(!1),D(""),w(!0)}).catch(()=>{});return}if(ue==="unlink"){const Me=Z.current||t.current;Me&&Me.chain().focus().unsetLink().run(),s(!1);return}},[Q,t]),G=S.useCallback(()=>{f.trim()&&(y.startsWith("img:")?oe(f.trim()):Q(y,f.trim()),p(""),b(""))},[Q,oe,y,f]),le=S.useCallback(()=>{const ce=Z.current||t.current,ue=U.current;if(!ce||!ue||!n)return;const{from:ae,to:je,nodeIds:Me}=ue;if(ae===je||Me.length===0)return;const He=ce.state.doc.textBetween(ae,je,`
205
+ `);He.trim()&&fetch("/api/marks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:He,note:X.trim(),nodeId:Me[Me.length-1]})}).then(()=>{s(!1),K(!1),W("")}).catch(Ne=>{console.error("[ContextMenu] Agent mark failed:",Ne)})},[t,n,X]),Te=S.useCallback(ce=>{const ue=Z.current||t.current;ue&&ue.chain().focus().setLink({href:`doc:${ce}`}).run(),fetch("/api/auto-tag-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetFile:ce})}).catch(()=>{}),s(!1),w(!1)},[t]),Ve=S.useCallback(()=>{const ce=L.trim();if(!ce)return;const ue=Z.current||t.current;ue&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ce})}).then(ae=>ae.json()).then(ae=>{ae.filename&&ue.chain().focus().setLink({href:`doc:${ae.filename}`}).run()}).catch(()=>{}),s(!1),w(!1),R(!1),D(""))},[t,L]);return r?d.jsx("div",{ref:$,className:"context-menu",style:{left:i.x,top:i.y},children:l?d.jsx("div",{className:"context-menu-loading",children:"Applying..."}):J?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:X,onChange:ce=>W(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&le(),ce.key==="Escape"&&(K(!1),W(""))},placeholder:"Note for agent (optional)..."}),d.jsx("button",{onClick:le,children:"Mark"})]}):m?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:f,onChange:ce=>p(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&G(),ce.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),d.jsx("button",{onClick:G,children:"Apply"})]}):k?d.jsxs("div",{className:"context-menu-link-picker",children:[d.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),C?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:L,onChange:ce=>D(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&Ve(),ce.key==="Escape"&&R(!1)},placeholder:"New document title..."}),d.jsx("button",{onClick:Ve,children:"Create"})]}):d.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>R(!0),children:d.jsx("span",{children:"+ New link doc"})}),d.jsxs("div",{className:"context-menu-link-list",children:[O.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),E.filter(ce=>O.includes(ce.filename)).map(({filename:ce,title:ue})=>d.jsx("button",{className:"context-menu-item",onClick:()=>Te(ce),children:d.jsx("span",{children:ue})},`linked-${ce}`))]}),d.jsx("div",{className:"context-menu-section-header",children:"All documents"}),E.filter(ce=>!O.includes(ce.filename)).map(({filename:ce,title:ue})=>d.jsx("button",{className:"context-menu-item",onClick:()=>Te(ce),children:d.jsx("span",{children:ue})},ce)),E.length===0&&d.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const ce=j();let ue;return ce.map((ae,je)=>{const Me=ae.isPlugin&&ae.pluginDisplayName&&ae.pluginDisplayName!==ue,He=ue!==void 0;ae.isPlugin?ue=ae.pluginDisplayName:ue=void 0;const Ne=!ae.isPlugin&&He;return d.jsxs("span",{children:[Me&&d.jsx("div",{className:"context-menu-section-header",children:ae.pluginDisplayName}),Ne&&d.jsx("div",{className:"context-menu-divider"}),d.jsxs("button",{className:"context-menu-item",onClick:()=>fe(ae),children:[d.jsx("span",{children:ae.label}),ae.shortcut&&d.jsx("span",{className:"context-menu-shortcut",children:ae.shortcut})]})]},ae.action)})})()}):null}function A0(t,e,n){let r=t.resolve(e);for(;r.depth>0;){const s=r.node(r.depth),i=r.before(r.depth),o=i+s.nodeSize;if(s.childCount===1)e=i,n=o,r=t.resolve(e);else break}return{from:e,to:n}}function yB(t,e){const n=yn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function bB(t,e){const n=yn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null,pendingOriginalContent:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run(),!0}function xB(t,e){var o;const n=yn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="delete")return!0;const i=A0(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function wB(t,e){var o;const n=yn(t,e);if(!n)return!0;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="insert")return!0;const i=A0(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function kB(t,e){var o,l;const n=yn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="rewrite")return!0;const i=(l=r.attrs)==null?void 0:l.pendingOriginalContent;if(i)t.chain().deleteRange({from:s,to:s+r.nodeSize}).insertContentAt(s,i).run();else{const u=A0(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(u).run()}return!0}function SB(t,e){var i;const n=yn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return((i=r.attrs)==null?void 0:i.pendingStatus)!=="delete"||t.chain().command(({tr:o})=>(o.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function EB(t,e){const n=Cd(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=yn(t,r.nodeId);s&&t.chain().command(({tr:i})=>(i.setNodeMarkup(s.pos,void 0,{...s.node.attrs,pendingStatus:null,pendingOriginalContent:null,pendingGroupId:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run()}return!0}function _B(t,e){var l;const n=Cd(t,e);if(n.length===0)return!1;const r=(l=n[0].node.attrs)==null?void 0:l.pendingOriginalContent,s=n[0].pos,i=n[n.length-1],o=i.pos+i.node.nodeSize;try{return r&&Array.isArray(r)&&r.length>0?t.chain().deleteRange({from:s,to:o}).insertContentAt(s,r).run():t.chain().deleteRange({from:s,to:o}).run(),!0}catch{return!1}}function SC(t,e){var i,o;const n=yn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return EB(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return yB(t,e);case"rewrite":return bB(t,e);case"delete":return xB(t,e);default:return!1}}function EC(t,e){var i,o;const n=yn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return _B(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return wB(t,e);case"rewrite":return kB(t,e);case"delete":return SB(t,e);default:return!1}}function NB(t){const e=_C(t).reverse();for(const n of e)SC(t,n);t.view&&T0(t.view)}function CB(t){const e=_C(t).reverse();for(const n of e)EC(t,n);t.view&&T0(t.view)}function O0(t){const e=[],n=new Set;return t.state.doc.descendants((r,s)=>{var o,l,u;const i=(o=r.attrs)==null?void 0:o.pendingStatus;if(i&&((l=r.attrs)!=null&&l.id)){const f=(u=r.attrs)==null?void 0:u.pendingGroupId;if(f){if(n.has(f))return!0;n.add(f)}e.push({nodeId:r.attrs.id,pos:s,pendingStatus:i,groupId:f,editor:t})}return!0}),e}function lp(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...O0(n));return e}function _C(t){return O0(t).map(e=>e.nodeId)}function TB(t){let e=0,n=0,r=0;for(const s of t)s.pendingStatus==="insert"?e++:s.pendingStatus==="rewrite"?n++:s.pendingStatus==="delete"&&r++;return{insert:e,rewrite:n,delete:r,total:t.length}}function Da(t,e){if(t.isDestroyed)return;let n=-1;if(t.state.doc.descendants((i,o)=>{var l;return((l=i.attrs)==null?void 0:l.id)===e?(n=o,!1):!0}),n===-1)return;const r=t.view.nodeDOM(n),s=r instanceof HTMLElement?r:r==null?void 0:r.parentElement;if(s){s.scrollIntoView({behavior:"smooth",block:"center"});return}try{const i=t.view.coordsAtPos(n),o=t.view.dom.closest(".editor-container");if(o){const l=o.getBoundingClientRect(),u=i.top-l.top+o.scrollTop-o.clientHeight/2;o.scrollTo({top:u,behavior:"smooth"})}}catch{}}function MB(t){const[e,n]=S.useState([]),[r,s]=S.useState(0),i=S.useRef(),o=S.useRef(new Set),l=S.useCallback(()=>{const E=t.filter(R=>R&&!R.isDestroyed);if(E.length===0){n([]),o.current=new Set;return}const N=lp(E);n(N);const O=o.current,T=new Set(N.map(R=>R.nodeId));let C=-1;if(O.size>0){for(let R=0;R<N.length;R++)if(!O.has(N[R].nodeId)){C=R;break}}o.current=T,C>=0?(s(C),Da(N[C].editor,N[C].nodeId)):N.length===0?s(0):s(R=>Math.min(R,N.length-1))},[t]);S.useEffect(()=>{const E=t.filter(T=>T&&!T.isDestroyed);if(E.length===0)return;const N=()=>{clearTimeout(i.current),i.current=setTimeout(l,50)};for(const T of E)T.on("transaction",N);l();const O=setTimeout(()=>{const T=lp(E.filter(C=>!C.isDestroyed));T.length>0&&Da(T[0].editor,T[0].nodeId)},150);return()=>{for(const T of E)T.isDestroyed||T.off("transaction",N);clearTimeout(i.current),clearTimeout(O)}},[t,l]),S.useEffect(()=>{const E=e[r]??null;return C1((E==null?void 0:E.nodeId)??null,(E==null?void 0:E.groupId)??null),E!=null&&E.editor&&!E.editor.isDestroyed&&E.editor.view&&T0(E.editor.view),()=>{C1(null)}},[r,e]);const u=TB(e),f=e[r]??null,p=S.useCallback(()=>{if(e.length===0)return;const E=(r+1)%e.length;s(E),e[E]&&Da(e[E].editor,e[E].nodeId)},[e,r]),m=S.useCallback(()=>{if(e.length===0)return;const E=(r-1+e.length)%e.length;s(E),e[E]&&Da(e[E].editor,e[E].nodeId)},[e,r]),g=S.useCallback(()=>{const E=t.filter(T=>T&&!T.isDestroyed),N=lp(E);if(N.length===0)return;const O=Math.min(r,N.length-1);Da(N[O].editor,N[O].nodeId)},[t,r]),y=S.useCallback(()=>{f&&(SC(f.editor,f.nodeId),l(),g())},[f,l,g]),b=S.useCallback(()=>{f&&(EC(f.editor,f.nodeId),l(),g())},[f,l,g]),k=S.useCallback(()=>{const E=t.filter(N=>N&&!N.isDestroyed);for(const N of E)NB(N);l()},[t,l]),w=S.useCallback(()=>{const E=t.filter(N=>N&&!N.isDestroyed);for(const N of E)CB(N);l()},[t,l]);return{pendingNodes:e,counts:u,currentNode:f,currentIndex:r,hasPending:u.total>0,goToNext:p,goToPrevious:m,acceptCurrent:y,rejectCurrent:b,acceptAll:k,rejectAll:w,refresh:l}}const Go={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},AB=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...Go})}),OB=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...Go})}),RB=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...Go})}),jB=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...Go})}),B1=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...Go})}),z1=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...Go})});function NC(t,e,n){const r=yn(t,e);if(!r)return!1;const{pos:s,node:i}=r,o={type:n.type||i.type.name,attrs:{...n.attrs||{},id:i.attrs.id,pendingStatus:i.attrs.pendingStatus,pendingOriginalContent:i.attrs.pendingOriginalContent,pendingSelectionFrom:i.attrs.pendingSelectionFrom,pendingSelectionTo:i.attrs.pendingSelectionTo,pendingOriginalFrom:i.attrs.pendingOriginalFrom,pendingOriginalTo:i.attrs.pendingOriginalTo},content:n.content};try{return t.chain().command(({tr:l})=>(l.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:s+i.nodeSize}).insertContentAt(s,o).run(),!0}catch{return!1}}function CC(t,e,n){const r=Cd(t,e);if(r.length===0)return!1;const s=r[0].pos,i=r[r.length-1].pos+r[r.length-1].node.nodeSize;try{return t.chain().command(({tr:o})=>(o.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:i}).insertContentAt(s,n).run(),!0}catch{return!1}}function ru(t,e){if(!C0()||!e)return!1;const n=F6(),r=z6();return r&&n&&Array.isArray(n)?CC(t,r,n):n&&NC(t,e,n),Eg(!1),!0}function IB({editors:t,pendingDocs:e,currentFilename:n,onSwitchDocument:r,sendMessage:s,getDocument:i}){const{counts:o,currentNode:l,currentIndex:u,hasPending:f,goToNext:p,goToPrevious:m,acceptCurrent:g,rejectCurrent:y,acceptAll:b,rejectAll:k}=MB(t),[w,E]=S.useState(!1),N=S.useRef(null),O=S.useRef(null),T=e.filenames.length,C=LB(e.filenames,n),R=(l==null?void 0:l.pendingStatus)==="rewrite",L=!!(l!=null&&l.groupId),D=R,z=S.useCallback(()=>{var I,A;const Y=l==null?void 0:l.editor;if(!(!Y||!l||l.pendingStatus!=="rewrite"))if(w)O.current&&ru(O.current,N.current),N.current=null,O.current=null,E(!1);else if(L&&l.groupId){const j=Cd(Y,l.groupId);if(j.length===0)return;const Q=(I=j[0].node.attrs)==null?void 0:I.pendingOriginalContent;if(!Q||!Array.isArray(Q))return;const oe=j.map(le=>le.node.toJSON()),fe=Q.map((le,Te)=>({...le,attrs:{...le.attrs||{},pendingStatus:"rewrite",pendingGroupId:l.groupId,...Te===0?{pendingOriginalContent:Q}:{}}}));if(!CC(Y,l.groupId,fe))return;Eg(!0,l.nodeId,oe,l.groupId),N.current=l.nodeId,O.current=Y,E(!0)}else{const j=yn(Y,l.nodeId);if(!j)return;const{node:Q}=j,oe=(A=Q.attrs)==null?void 0:A.pendingOriginalContent;if(!oe)return;const fe=Q.toJSON();if(!NC(Y,l.nodeId,oe))return;Eg(!0,l.nodeId,fe),N.current=l.nodeId,O.current=Y,E(!0)}},[l,w,L]);S.useEffect(()=>{if(!w)return;const Y=N.current,I=O.current;Y&&I&&(l==null?void 0:l.nodeId)!==Y&&(ru(I,Y),N.current=null,O.current=null,E(!1))},[l==null?void 0:l.nodeId,w]),S.useEffect(()=>{if(t.length!==0)return()=>{C0()&&N.current&&O.current&&(ru(O.current,N.current),N.current=null,O.current=null)}},[t]);const F=S.useCallback(Y=>{if(!n)return;if(!t.some(A=>!A||A.isDestroyed?!1:O0(A).length>0)){const A=i==null?void 0:i();A&&s({type:"doc-update",document:A,filename:n}),s({type:"pending-resolved",filename:n,action:Y})}},[t,n,s,i]),J=S.useCallback(()=>{O.current&&w&&N.current&&(ru(O.current,N.current),N.current=null,O.current=null,E(!1))},[w]),K=S.useCallback(()=>{J(),g(),F("accept")},[J,g,F]),X=S.useCallback(()=>{J(),y(),F("reject")},[J,y,F]),W=S.useCallback(()=>{J(),b(),F("accept")},[J,b,F]);S.useEffect(()=>{const Y=()=>W();return window.addEventListener("ow-accept-all",Y),()=>window.removeEventListener("ow-accept-all",Y)},[W]);const $=S.useCallback(()=>{J(),k(),F("reject")},[J,k,F]),U=S.useCallback(()=>{if(T===0||T===1&&C===0)return;const Y=C<=0?T-1:C-1;r(e.filenames[Y])},[T,C,e.filenames,r]),Z=S.useCallback(()=>{if(T===0||T===1&&C===0)return;const Y=C>=T-1?0:C+1;r(e.filenames[Y])},[T,C,e.filenames,r]);if(S.useEffect(()=>{if(!f)return;const Y=I=>{if(!(I.target instanceof HTMLInputElement||I.target instanceof HTMLTextAreaElement)&&!(I.target instanceof HTMLElement&&I.target.closest("[contenteditable]")))switch(I.key){case"j":case"ArrowDown":!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),p());break;case"k":case"ArrowUp":!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),m());break;case"h":case"ArrowLeft":!I.metaKey&&!I.ctrlKey&&!I.altKey&&(I.preventDefault(),U());break;case"l":case"ArrowRight":!I.metaKey&&!I.ctrlKey&&!I.altKey&&(I.preventDefault(),Z());break;case"a":!I.metaKey&&!I.ctrlKey&&!I.shiftKey&&(I.preventDefault(),K());break;case"r":!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),X());break;case"A":I.shiftKey&&!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),W());break;case"R":I.shiftKey&&!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),$());break;case"o":!I.metaKey&&!I.ctrlKey&&!I.shiftKey&&(I.preventDefault(),z());break}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[f,p,m,U,Z,K,X,W,$,z]),!f)return null;const V=C>=0?C+1:"?";return d.jsxs("div",{className:"review-panel",children:[T>1&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"review-panel__nav",children:[d.jsx("button",{className:"review-panel__btn",onClick:U,title:"Previous doc (h)",children:d.jsx(AB,{})}),d.jsx("button",{className:"review-panel__btn",onClick:Z,title:"Next doc (l)",children:d.jsx(OB,{})}),d.jsxs("span",{className:"review-panel__counter",children:[V,"/",T]})]}),d.jsx("div",{className:"review-panel__divider"})]}),d.jsxs("div",{className:"review-panel__nav",children:[d.jsx("button",{className:"review-panel__btn",onClick:m,disabled:o.total===0,title:"Previous (k)",children:d.jsx(RB,{})}),d.jsx("button",{className:"review-panel__btn",onClick:p,disabled:o.total===0,title:"Next (j)",children:d.jsx(jB,{})}),d.jsxs("span",{className:"review-panel__counter",children:[u+1,"/",o.total]})]}),d.jsx("div",{className:"review-panel__divider"}),d.jsxs("div",{className:"review-panel__toggle",children:[d.jsx("button",{className:`review-panel__toggle-btn${D&&!w?" review-panel__toggle-btn--active":""}`,onClick:()=>D&&w&&z(),disabled:!D,title:"Show modified (o)",children:"Modified"}),d.jsx("button",{className:`review-panel__toggle-btn${D&&w?" review-panel__toggle-btn--active":""}`,onClick:()=>D&&!w&&z(),disabled:!D,title:"Show original (o)",children:"Original"})]}),d.jsx("div",{className:"review-panel__divider"}),d.jsxs("div",{className:"review-panel__actions",children:[d.jsx("button",{className:"review-panel__accept",onClick:K,title:"Accept (a)",children:d.jsx(B1,{})}),d.jsx("button",{className:"review-panel__reject",onClick:X,title:"Reject (r)",children:d.jsx(z1,{})}),d.jsxs("button",{className:"review-panel__accept-all",onClick:W,title:"Accept all (Shift+A)",children:[d.jsx(B1,{}),d.jsx("span",{children:"All"})]}),d.jsxs("button",{className:"review-panel__reject-all",onClick:$,title:"Reject all (Shift+R)",children:[d.jsx(z1,{}),d.jsx("span",{children:"All"})]})]})]})}function LB(t,e){return t.indexOf(e)}function su(t){return t.type==="doc"?t.file:t.id}function TC(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&TC(n.items,e)}function Vo(t){const e=new Date(t),n=Date.now()-e.getTime();return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<6048e5?`${Math.floor(n/864e5)}d ago`:e.toLocaleDateString()}function ys(t){return/^[A-Z]:[/\\]|^\//.test(t)}function MC(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function DB(t){const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=new Date(r.getTime()-864e5),i=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.getTime()===r.getTime()?"Today":i.getTime()===s.getTime()?"Yesterday":n.getTime()-i.getTime()<6048e5?e.toLocaleDateString(void 0,{weekday:"long"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function PB(t,e){const[n,r]=S.useState([]),[s,i]=S.useState([]),[o,l]=S.useState(new Set),u=S.useRef(null),f=S.useCallback(()=>{fetch("/api/documents").then(m=>m.json()).then(m=>{Array.isArray(m)&&r(m)}).catch(()=>{})},[]),p=S.useCallback(()=>{fetch("/api/workspaces").then(m=>m.json()).then(async m=>{if(!Array.isArray(m))return;const g=await Promise.all(m.map(async b=>{try{const w=await(await fetch(`/api/workspaces/${encodeURIComponent(b.filename)}`)).json();return{...b,workspace:w}}catch{return b}}));i(g);const y=new Set;for(const b of g)b.workspace&&TC(b.workspace.root,y);l(y)}).catch(()=>{})},[]);return S.useEffect(()=>{f()},[f,t]),S.useEffect(()=>{p()},[p,e,t]),S.useEffect(()=>{const m=requestAnimationFrame(()=>{var y;const g=(y=u.current)==null?void 0:y.querySelector(".sidebar-item.active");g==null||g.scrollIntoView({block:"nearest",behavior:"instant"})});return()=>cancelAnimationFrame(m)},[n]),{docs:n,workspaces:s,assignedFiles:o,fetchDocs:f,scrollRef:u}}function BB(t,e,n){const r=S.useCallback(C=>{fetch(`/api/documents/${encodeURIComponent(C)}`,{method:"DELETE"}).catch(()=>{})},[]),s=S.useCallback(C=>{fetch(`/api/documents/${encodeURIComponent(C)}/archive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),i=S.useCallback(C=>{fetch(`/api/documents/${encodeURIComponent(C)}/unarchive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),o=S.useCallback((C,R,L)=>{!L.trim()||L.trim()===R||fetch(`/api/documents/${encodeURIComponent(C)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:L.trim()})}).then(()=>e()).catch(()=>{})},[e]),l=S.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),u=S.useCallback(C=>{fetch(`/api/workspaces/${encodeURIComponent(C)}`,{method:"DELETE"}).catch(()=>{})},[]),f=S.useCallback((C,R,L)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L?{metadata:L}:{})}).then(D=>D.json()).then(D=>{if(D.filename)return fetch(`/api/workspaces/${encodeURIComponent(C)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:D.filename,title:D.title||"Untitled",containerId:R})})}).catch(()=>{})},[]),p=S.useCallback((C,R)=>{fetch(`/api/workspaces/${encodeURIComponent(C)}/docs/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]),m=S.useCallback((C,R)=>{fetch(`/api/workspaces/${encodeURIComponent(C)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:R})}).catch(()=>{})},[]),g=S.useCallback((C,R)=>{fetch(`/api/workspaces/${encodeURIComponent(C)}/containers/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]),y=S.useCallback((C,R,L)=>{L.trim()&&fetch(`/api/workspaces/${encodeURIComponent(C)}/containers/${encodeURIComponent(R)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:L.trim()})}).catch(()=>{})},[]),b=S.useCallback((C,R)=>{R.trim()&&fetch(`/api/workspaces/${encodeURIComponent(C)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:R.trim()})}).catch(()=>{})},[]),[k,w]=S.useState({}),E=S.useRef(-1);S.useEffect(()=>{n!==E.current&&(E.current=n??0,fetch("/api/documents").then(C=>C.json()).then(C=>{const R={};return Promise.all(C.map(L=>fetch(`/api/doc-tags/${encodeURIComponent(L.filename)}`).then(D=>D.json()).then(D=>{var z;(z=D.tags)!=null&&z.length&&(R[L.filename]=D.tags)}).catch(()=>{}))).then(()=>w(R))}).catch(()=>{}))},[n]);const N=S.useCallback(C=>k[C]||[],[k]),O=S.useCallback((C,R)=>{R.trim()&&(w(L=>{const D=L[C]||[];return D.includes(R.trim())?L:{...L,[C]:[...D,R.trim()]}}),fetch(`/api/doc-tags/${encodeURIComponent(C)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:R.trim()})}).catch(()=>{}))},[]),T=S.useCallback((C,R)=>{w(L=>{const z=(L[C]||[]).filter(F=>F!==R);if(z.length===0){const F={...L};return delete F[C],F}return{...L,[C]:z}}),fetch(`/api/doc-tags/${encodeURIComponent(C)}/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]);return{fetchDocs:e,handleDelete:r,handleArchive:s,handleUnarchive:i,handleRename:o,handleCreateWorkspace:l,handleDeleteWorkspace:u,handleCreateInWorkspace:f,handleRemoveFromWorkspace:p,handleCreateContainer:m,handleDeleteContainer:g,handleRenameContainer:y,handleRenameWorkspace:b,getDocTags:N,handleAddTag:O,handleRemoveTag:T}}function zB({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,o]=S.useState(null),[l,u]=S.useState(null),f=S.useRef(null),p=S.useRef(null),m=S.useRef(null),g=S.useRef(null),y=S.useRef(null),b=5,k=(F,J,K)=>K==="before"?J>0?su(F[J-1]):null:su(F[J]),w=S.useCallback((F,J)=>{if(J===null){const W=t.filter(U=>!n.has(U.filename)).map(U=>({type:"doc",file:U.filename,title:U.title})),$=W.findIndex(U=>su(U)===F);return $>=0?{siblings:W,index:$,containerId:null}:null}const K=e.find(W=>W.filename===J);if(!(K!=null&&K.workspace))return null;const X=(W,$)=>{for(let U=0;U<W.length;U++){if(su(W[U])===F)return{siblings:W,index:U,containerId:$};if(W[U].type==="container"){const Z=X(W[U].items,W[U].id);if(Z)return Z}}return null};return X(K.workspace.root,null)},[t,n,e]),E=S.useCallback(()=>{o(null),u(null),y.current=null,g.current=null,m.current&&(m.current.remove(),m.current=null),f.current&&(clearTimeout(f.current),f.current=null),p.current&&(cancelAnimationFrame(p.current),p.current=null),document.body.style.userSelect=""},[]),N=S.useCallback((F,J)=>{if(!F||!J)return;if(F.type==="workspace"){const V=J.itemId;if(V===F.filename)return;const Y=e.map(j=>j.filename),I=Y.indexOf(F.filename);if(I<0)return;Y.splice(I,1);let A=Y.indexOf(V);if(A<0)return;J.position==="after"&&(A+=1),Y.splice(A,0,F.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:Y})}).catch(()=>{});return}const{wsFilename:K,containerId:X,afterId:W}=J,$=F.type==="doc"?F.file:F.id,U=F.sourceWs;if(J.itemId===$)return;if(F.type==="container"){if(U!==K||!K)return;fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent($)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:X??null,afterFile:W})}).catch(()=>{});return}const Z=F.file;if(U===null&&K===null){const V=t.filter(Q=>!n.has(Q.filename)).map(Q=>Q.filename),Y=V.indexOf(Z);if(Y<0)return;V.splice(Y,1);let I=W?V.indexOf(W):-1;I>=0?I+=1:I=0,V.splice(I,0,Z);const A=[];let j=0;for(const Q of t)n.has(Q.filename)?A.push(Q.filename):A.push(V[j++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:A})}).catch(()=>{});return}if(U===null&&K!==null){fetch(`/api/workspaces/${encodeURIComponent(K)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:Z,title:Z.replace(/\.md$/,""),containerId:X??null,afterFile:W})}).catch(()=>{});return}if(U!==null&&K===null){fetch(`/api/workspaces/${encodeURIComponent(U)}/docs/${encodeURIComponent(Z)}`,{method:"DELETE"}).catch(()=>{});return}if(U===K&&K!==null){fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent(Z)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:X??null,afterFile:W})}).catch(()=>{});return}U!==null&&K!==null&&fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent(Z)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:U,containerId:X??null,afterFile:W,title:Z.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),O=S.useCallback((F,J)=>{const K=m.current;K&&(K.style.display="none");const X=document.elementFromPoint(F,J);if(K&&(K.style.display=""),!X)return null;if((i==null?void 0:i.type)==="workspace"){const Q=X.closest("[data-ws-drag]");if(Q){const oe=Q.dataset.wsDrag,fe=Q.getBoundingClientRect(),G=(J-fe.top)/fe.height;return{itemId:oe,position:G<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}return null}const W=X.closest("[data-drag-id]");if(!W){const Q=X.closest("[data-drop-ws]");return Q?{itemId:"__section__",position:"inside",wsFilename:Q.dataset.dropWs==="__docs__"?null:Q.dataset.dropWs,containerId:Q.dataset.dropContainer||null,afterId:null}:null}const $=W.dataset.dragId,U=W.dataset.dragType,Z=W.dataset.dragWs==="__docs__"?null:W.dataset.dragWs,V=W.getBoundingClientRect(),Y=(J-V.top)/V.height;if(U==="container-header"){const Q=$,oe=W.dataset.dragParent||null,fe=w(Q,Z);return fe?Y<.25?{itemId:Q,position:"before",wsFilename:Z,containerId:oe,afterId:k(fe.siblings,fe.index,"before")}:Y>.75?{itemId:Q,position:"after",wsFilename:Z,containerId:oe,afterId:k(fe.siblings,fe.index,"after")}:{itemId:Q,position:"inside",wsFilename:Z,containerId:Q,afterId:null}:null}const I=W.dataset.dragContainer||null,A=w($,Z);if(!A)return null;const j=Y<.5?"before":"after";return{itemId:$,position:j,wsFilename:Z,containerId:I,afterId:k(A.siblings,A.index,j)}},[w,i]),T=S.useCallback(F=>{const J=r.current;if(!J)return;const K=J.getBoundingClientRect(),X=80,W=18;let $=0;if(F<K.top+X?$=-W*Math.max(0,1-(F-K.top)/X):F>K.bottom-X&&($=W*Math.max(0,1-(K.bottom-F)/X)),p.current&&(cancelAnimationFrame(p.current),p.current=null),$!==0){const U=()=>{J.scrollTop+=$,p.current=requestAnimationFrame(U)};p.current=requestAnimationFrame(U)}},[r]),C=S.useCallback((F,J)=>{const K=m.current;K&&(K.style.display="none");const X=document.elementFromPoint(F,J);K&&(K.style.display="");const W=X==null?void 0:X.closest("[data-section-key]");if(!W){f.current&&(clearTimeout(f.current),f.current=null);return}const $=W.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(U=>{if(!U.has($))return U;const Z=new Set(U);return Z.delete($),Z})},500)},[s]);S.useEffect(()=>{if(!i)return;const F=K=>{m.current&&(m.current.style.left=`${K.clientX+12}px`,m.current.style.top=`${K.clientY-8}px`),u(O(K.clientX,K.clientY)),T(K.clientY),C(K.clientX,K.clientY)},J=K=>{N(i,O(K.clientX,K.clientY)),E()};return window.addEventListener("pointermove",F),window.addEventListener("pointerup",J),()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",J)}},[i,O,N,E,T,C]);const R=S.useCallback((F,J,K)=>{if(F.button!==0||F.target.closest("input, button, .sidebar-tag-remove, .sidebar-tag-add, .sidebar-container-actions, .sidebar-delete-btn, .sidebar-confirm-delete, .sidebar-inline-confirm"))return;g.current={x:F.clientX,y:F.clientY},y.current=J;const W=U=>{if(!g.current||!y.current)return;const Z=U.clientX-g.current.x,V=U.clientY-g.current.y;if(Math.abs(Z)+Math.abs(V)>=b){document.body.style.userSelect="none",window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",$),o(y.current),y.current=null;const Y=document.createElement("div");Y.style.cssText="position:fixed;pointer-events:none;z-index:9999;padding:4px 10px;background:var(--bg-surface, white);border:1px solid var(--border, #cbd5e1);border-radius:6px;font-size:12px;box-shadow:0 2px 8px rgba(0,0,0,0.12);max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-dark, #334155);",Y.textContent=K,document.body.appendChild(Y),m.current=Y,Y.style.left=`${U.clientX+12}px`,Y.style.top=`${U.clientY-8}px`}},$=()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",$),g.current=null,y.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",W),window.addEventListener("pointerup",$)},[]);return{draggedItem:i,dropIndicator:l,handlePointerDown:R,dropClass:F=>!l||l.itemId!==F?"":l.position==="before"?"drop-before":l.position==="after"?"drop-after":l.position==="inside"?"drop-inside":"",isDragging:F=>i?i.type==="doc"?i.file===F:i.type==="workspace"?i.filename===F:i.id===F:!1,isContainerDropTarget:F=>!l||!i?!1:l.containerId===F}}function FB({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onRename:o,onArchive:l,onDelete:u,onPluginAction:f,pluginItems:p,onSchedulePost:m,onViewAnalytics:g,viewAnalyticsLabel:y,onMarkSent:b,isAlreadySent:k,isApproved:w,onToggleApprove:E}){const N=S.useRef(null),[O,T]=S.useState(!1),[C,R]=S.useState(!1),[L,D]=S.useState({left:t,top:e});S.useLayoutEffect(()=>{const F=N.current;if(!F)return;const J=F.getBoundingClientRect(),K=8;let X=t,W=e;e+J.height+K>window.innerHeight&&(W=e-J.height),t+J.width+K>window.innerWidth&&(X=t-J.width),W<K&&(W=K),X<K&&(X=K),D({left:X,top:W})},[t,e]),S.useEffect(()=>{const F=J=>{N.current&&!N.current.contains(J.target)&&s()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[s]),S.useEffect(()=>{const F=J=>{J.key==="Escape"&&s()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[s]);const z=S.useCallback(F=>{f(F.action,F),s()},[f,s]);return d.jsxs("div",{ref:N,className:"context-menu",style:{left:L.left,top:L.top},children:[d.jsx("button",{className:"context-menu-item",onClick:()=>{i(),s()},children:d.jsx("span",{children:"Duplicate"})}),d.jsx("button",{className:"context-menu-item",onClick:()=>{o(),s()},children:d.jsx("span",{children:"Rename"})}),C?d.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:F=>F.stopPropagation(),children:[d.jsx("span",{children:"Archive?"}),d.jsx("button",{onClick:()=>{l(),s()},children:"Yes"}),d.jsx("button",{onClick:()=>R(!1),children:"No"})]}):d.jsx("button",{className:"context-menu-item",onClick:()=>R(!0),children:d.jsx("span",{children:"Archive"})}),O?d.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:F=>F.stopPropagation(),children:[d.jsx("span",{children:ys(n)?"Remove?":"Delete?"}),d.jsx("button",{onClick:()=>{u(),s()},children:"Yes"}),d.jsx("button",{onClick:()=>T(!1),children:"No"})]}):d.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>T(!0),children:d.jsx("span",{children:ys(n)?"Remove":"Delete"})}),E&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{E(),s()},children:d.jsx("span",{children:w?"Remove Approval":"Approve"})})]}),m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{m(),s()},children:d.jsx("span",{children:"Schedule Post"})})]}),b&&!k&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{b(),s()},children:d.jsx("span",{children:"Mark as Sent"})})]}),g&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{g(),s()},children:d.jsx("span",{children:y||"View Analytics"})})]}),p.length>0&&d.jsx(d.Fragment,{children:(()=>{let F;return p.map(J=>{const K=J.pluginDisplayName&&J.pluginDisplayName!==F;return F=J.pluginDisplayName,d.jsxs("span",{children:[K&&d.jsx("div",{className:"context-menu-divider"}),K&&d.jsx("div",{className:"context-menu-section-header",children:J.pluginDisplayName}),d.jsx("button",{className:"context-menu-item",onClick:()=>z(J),children:d.jsx("span",{children:J.label})})]},J.action)})})()})]})}function $B({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=S.useState(""),o=S.useRef(null);S.useEffect(()=>{var u;(u=o.current)==null||u.focus()},[]),S.useEffect(()=>{const u=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);const l=S.useCallback(()=>{n(s.trim())},[s,n]);return d.jsx("div",{className:"focus-modal-overlay",onClick:r,children:d.jsxs("div",{className:"focus-modal",onClick:u=>u.stopPropagation(),children:[d.jsxs("div",{className:"focus-modal-header",children:[d.jsx("h2",{children:t}),d.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),d.jsxs("div",{className:"focus-modal-body",children:[d.jsxs("label",{children:['Focus instructions for "',e,'"',d.jsx("textarea",{ref:o,value:s,onChange:u=>i(u.target.value.slice(0,500)),placeholder:"Optional: guide the transformation (e.g. 'focus on the intro section', 'keep it professional')...",onKeyDown:u=>{u.key==="Enter"&&(u.ctrlKey||u.metaKey)&&l()}})]}),d.jsxs("div",{className:"focus-modal-hint",children:[s.length,"/500"]}),d.jsxs("div",{className:"focus-modal-actions",children:[d.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),d.jsx("button",{className:"focus-modal-btn primary",onClick:l,children:"Go"})]})]})]})})}function cp(t,e){if(!e)return[t];const n=[],r=t.toLowerCase(),s=e.toLowerCase();let i=0;for(;i<t.length;){const o=r.indexOf(s,i);if(o===-1){n.push(t.slice(i));break}o>i&&n.push(t.slice(i,o)),n.push(d.jsx("mark",{children:t.slice(o,o+e.length)},o)),i=o+e.length}return n}function F1({r:t,query:e,onClick:n}){return d.jsxs("div",{className:`sidebar-item search-result-item ${t.isActive?"active":""} ${t.isArchived?"search-result-archived":""}`,onClick:n,children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-item-title-text",children:t.matchType==="title"?cp(t.title,e):t.title}),t.isArchived&&d.jsx("span",{className:"search-archived-badge",children:"archived"})]}),t.matchType==="tag"&&t.matchedTag&&d.jsxs("div",{className:"search-result-tag",children:["Tag: ",cp(t.matchedTag,e)]}),t.matchType==="content"&&t.snippet&&d.jsx("div",{className:"search-result-snippet",children:cp(t.snippet,e)}),d.jsxs("div",{className:"sidebar-item-meta",children:[t.wordCount.toLocaleString()," words · ",Vo(t.lastModified)]})]})}function R0({results:t,query:e,onSwitchDocument:n,actions:r}){if(t.length===0)return d.jsx("div",{className:"sidebar-scroll",children:d.jsxs("div",{className:"search-empty",children:['No results for "',e,'"']})});const s=t.filter(o=>!o.isArchived),i=t.filter(o=>o.isArchived);return d.jsx("div",{className:"sidebar-scroll",children:d.jsxs("div",{className:"search-results",children:[s.map(o=>d.jsx(F1,{r:o,query:e,onClick:()=>n(o.filename)},o.filename)),i.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"search-archived-divider",children:d.jsx("span",{children:"Archived"})}),i.map(o=>d.jsx(F1,{r:o,query:e,onClick:()=>r.handleUnarchive(o.filename)},o.filename))]})]})})}async function up(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();return(i=(s=r.content)==null?void 0:s[0])!=null&&i.text?JSON.parse(r.content[0].text):r}function dp(t,e){return e?(t/e*100).toFixed(1)+"%":"0%"}function $1(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function U1(t,e=50){try{const n=new URL(t),r=n.hostname+n.pathname+n.search;return r.length>e?r.slice(0,e)+"...":r}catch{return t.length>e?t.slice(0,e)+"...":t}}function UB({docId:t,title:e,onClose:n}){const[r,s]=S.useState("loading"),[i,o]=S.useState([]),[l,u]=S.useState(""),[f,p]=S.useState(null),[m,g]=S.useState(null),[y,b]=S.useState("links"),[k,w]=S.useState("all"),[E,N]=S.useState(!1),[O,T]=S.useState(!1),[C,R]=S.useState(""),[L,D]=S.useState(!1),[z,F]=S.useState(null),J=S.useRef(null);S.useEffect(()=>{let G=!1;return(async()=>{try{const le=await up("list_newsletter_issues",{limit:20});if(G)return;if(!le.issues||le.issues.length===0){s("no-data");return}o(le.issues);const Te=le.issues[0].id;u(Te)}catch(le){G||(g(le.message),s("error"))}})(),()=>{G=!0}},[]),S.useEffect(()=>{if(!l)return;let G=!1;return N(!0),T(!1),F(null),R(""),(async()=>{try{const le=await up("get_newsletter_analytics",{issue_id:l});if(G)return;if(le.error){g(le.error),s("error");return}p(le),s("loaded")}catch(le){G||(g(le.message),s("error"))}finally{G||N(!1)}})(),()=>{G=!0}},[l]),S.useEffect(()=>{const G=le=>{J.current&&!J.current.contains(le.target)&&n()};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[n]),S.useEffect(()=>{const G=le=>{le.key==="Escape"&&n()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[n]);const K=f?WB(f.subscriber_events):[],X=(f==null?void 0:f.issue.recipient_count)??0,W=f?f.stats.delivered||X-f.stats.bounces:0,$=f?new Set(f.subscriber_events.filter(G=>{var le;return G.event_type==="click"&&((le=G.url)==null?void 0:le.includes("/newsletter/unsubscribe/"))}).map(G=>G.email)).size:0,U=f?f.stats.unsubscribes||$:0,Z=f?f.subscriber_events.filter(G=>G.event_type==="dropped").length:0,V=f?Math.max(0,X-f.stats.unique_opens):0,Y=f!=null&&f.issue.sent_at?Date.now()-new Date(f.issue.sent_at).getTime():0,I=Math.floor(Y/36e5),A=!!(f!=null&&f.issue.resent_at||z),j=G=>{const le=Math.floor(G/36e5);return le<1?"just now":le<24?`${le}h ago`:`${Math.floor(le/24)}d ${le%24}h ago`},Q=async()=>{if(!(!C.trim()||L)){D(!0);try{const G=await up("resend_to_unopened",{issue_id:l,subject:C});G.error?(g(G.error),s("error")):(F({sent:G.sent,failed:G.failed}),T(!1))}catch(G){g(G.message),s("error")}finally{D(!1)}}},oe=G=>{var le;return G.event_type==="unsubscribe"||G.event_type==="click"&&!!((le=G.url)!=null&&le.includes("/newsletter/unsubscribe/"))},fe=f?HB(f.subscriber_events.filter(G=>k==="all"?!0:k==="unsubscribe"?oe(G):G.event_type===k)):[];return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"na-modal",ref:J,children:[d.jsxs("div",{className:"na-header",children:[d.jsx("h3",{children:"Newsletter Analytics"}),d.jsx("button",{className:"newsletter-modal__close",onClick:n,children:"×"})]}),r==="loading"&&!f&&d.jsx("div",{className:"na-body",children:d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:"Loading analytics..."})]})}),r==="no-data"&&d.jsxs("div",{className:"na-body",children:[d.jsx("div",{className:"newsletter-modal__status",children:d.jsx("span",{children:"No newsletter sends found yet."})}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="error"&&d.jsxs("div",{className:"na-body",children:[d.jsx("div",{className:"newsletter-modal__error",children:m}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="loaded"&&f&&d.jsxs("div",{className:"na-body",children:[i.length>1&&d.jsx("select",{className:"newsletter-modal__select na-issue-select",value:l,onChange:G=>u(G.target.value),children:i.map(G=>d.jsxs("option",{value:G.id,children:[G.subject," — ",$1(G.sent_at)]},G.id))}),E?d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:"Loading..."})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"na-kpi-row",children:[d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:W.toLocaleString()}),d.jsx("div",{className:"na-kpi__label",children:"Delivered"}),d.jsxs("div",{className:"na-kpi__sub",children:[X.toLocaleString()," sent"]})]}),d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:dp(f.stats.unique_opens,W)}),d.jsx("div",{className:"na-kpi__label",children:"Open rate"}),d.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_opens.toLocaleString()," opens"]})]}),d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:dp(f.stats.unique_clicks,W)}),d.jsx("div",{className:"na-kpi__label",children:"Click rate"}),d.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_clicks.toLocaleString()," clicks"]})]})]}),d.jsxs("div",{className:"na-kpi-row na-kpi-row--secondary",children:[d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:f.stats.bounces}),d.jsx("span",{className:"na-kpi__label--sm",children:"Bounces"})]}),d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:U}),d.jsx("span",{className:"na-kpi__label--sm",children:"Unsubs"})]}),d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:Z}),d.jsx("span",{className:"na-kpi__label--sm",children:"Dropped"})]}),f.stats.complaints>0&&d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:f.stats.complaints}),d.jsx("span",{className:"na-kpi__label--sm",children:"Spam"})]})]}),V>0&&!A&&d.jsx("div",{className:"na-resend",children:O?d.jsxs("div",{className:"na-resend-panel",children:[d.jsxs("div",{className:"na-resend-label-row",children:[d.jsx("span",{className:"na-resend-label",children:"New subject line"}),d.jsxs("span",{className:"na-resend-meta",children:["sent ",j(Y),I<48?" · consider waiting 48h":""]})]}),d.jsx("input",{className:"na-resend-input",type:"text",value:C,onChange:G=>R(G.target.value),placeholder:"Try a different angle"}),d.jsxs("div",{className:"na-resend-actions",children:[d.jsx("button",{className:"na-resend-cancel",onClick:()=>T(!1),children:"Cancel"}),d.jsx("button",{className:"na-resend-send",onClick:Q,disabled:L||!C.trim(),children:L?"Sending...":`Send to ${V.toLocaleString()}`})]})]}):d.jsxs("button",{className:"na-resend-toggle",onClick:()=>{T(!0),R(f.issue.subject)},children:["Resend to ",V.toLocaleString()," non-openers ",d.jsx("span",{style:{float:"right"},children:"›"})]})}),A&&d.jsxs("div",{className:"na-resend-done",children:["Resent ",f.issue.resent_at?j(Date.now()-new Date(f.issue.resent_at).getTime()):"just now",z?` — ${z.sent} sent`:"",f.issue.resend_subject?` — "${f.issue.resend_subject}"`:""]}),d.jsxs("div",{className:"na-tabs",children:[d.jsxs("button",{className:`na-tab${y==="links"?" active":""}`,onClick:()=>b("links"),children:["Links (",K.length,")"]}),d.jsxs("button",{className:`na-tab${y==="activity"?" active":""}`,onClick:()=>b("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),y==="links"&&d.jsx("div",{className:"na-table-wrap",children:K.length===0?d.jsx("div",{className:"na-empty",children:"No link clicks recorded yet."}):d.jsxs("table",{className:"na-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Link"}),d.jsx("th",{children:"Unique"}),d.jsx("th",{children:"Total"}),d.jsx("th",{children:"CTR"})]})}),d.jsx("tbody",{children:K.map(G=>d.jsxs("tr",{children:[d.jsx("td",{className:"na-table__url",title:G.url,children:d.jsx("a",{href:G.url,target:"_blank",rel:"noopener noreferrer",children:U1(G.url)})}),d.jsx("td",{children:G.uniqueClicks}),d.jsx("td",{children:G.totalClicks}),d.jsx("td",{children:dp(G.uniqueClicks,W)})]},G.url))})]})}),y==="activity"&&d.jsxs("div",{className:"na-activity",children:[d.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(G=>d.jsx("button",{className:`na-filter-btn${k===G?" active":""}`,onClick:()=>w(G),children:G==="all"?"All":G.charAt(0).toUpperCase()+G.slice(1)+"s"},G))}),d.jsxs("div",{className:"na-table-wrap",children:[fe.length===0?d.jsxs("div",{className:"na-empty",children:["No ",k==="all"?"":k+" ","events recorded."]}):d.jsxs("table",{className:"na-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Email"}),d.jsx("th",{children:"Event"}),d.jsx("th",{children:"Detail"}),d.jsx("th",{children:"Time"})]})}),d.jsx("tbody",{children:fe.slice(0,100).map(G=>d.jsxs("tr",{children:[d.jsx("td",{className:"na-table__email",children:G.email}),d.jsxs("td",{children:[d.jsx("span",{className:`na-badge na-badge--${G.event_type}`,children:G.event_type}),G.count>1&&d.jsxs("span",{className:"na-count",children:[G.count,"x"]})]}),d.jsx("td",{className:"na-table__url",children:G.url?d.jsx("a",{href:G.url,target:"_blank",rel:"noopener noreferrer",children:U1(G.url,35)}):"—"}),d.jsx("td",{className:"na-table__time",children:$1(G.latestTimestamp)})]},G.key))})]}),fe.length>100&&d.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",fe.length," events"]})]})]})]})]})]})})}function HB(t){const e=new Map;for(const n of t){const r=`${n.email}|${n.event_type}|${n.url||""}`,s=e.get(r);s?(s.count++,n.timestamp>s.latestTimestamp&&(s.latestTimestamp=n.timestamp)):e.set(r,{key:r,email:n.email,event_type:n.event_type,url:n.url,latestTimestamp:n.timestamp,count:1})}return Array.from(e.values()).sort((n,r)=>new Date(r.latestTimestamp).getTime()-new Date(n.latestTimestamp).getTime())}function WB(t){const e=t.filter(r=>r.event_type==="click"&&r.url),n=new Map;for(const r of e){const s=r.url;let i=n.get(s);i||(i={emails:new Set,total:0},n.set(s,i)),i.emails.add(r.email),i.total++}return Array.from(n.entries()).map(([r,{emails:s,total:i}])=>({url:r,uniqueClicks:s.size,totalClicks:i})).sort((r,s)=>s.uniqueClicks-r.uniqueClicks)}function qB(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function Td({filename:t,title:e,onClose:n}){const[r,s]=S.useState("queue"),[i,o]=S.useState(null),[l,u]=S.useState(null),[f,p]=S.useState(""),[m,g]=S.useState(!1),[y,b]=S.useState(null),[k,w]=S.useState(null);S.useEffect(()=>{fetch(`/api/documents/${encodeURIComponent(t)}/text`).then(O=>{if(!O.ok)throw new Error("Failed to load document");return O.json()}).then(O=>{u(O.text||""),o(qB(O.meta||{}))}).catch(O=>w(O.message))},[t]);const E=async()=>{var O;if(!(!l||!i)){g(!0);try{const T={content:l,content_type:i,mode:r};r==="custom"&&f&&(T.scheduled_at=new Date(f).toISOString());const C=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)}),R=await C.json();if(C.ok){const L=(O=R.item)!=null&&O.scheduled_at?new Date(R.item.scheduled_at).toLocaleString():"now";b({success:!0,message:`Scheduled for ${L}`})}else b({success:!1,message:R.error||"Failed to schedule"})}catch(T){b({success:!1,message:T.message})}finally{g(!1)}}},N=i===null&&!k;return d.jsx("div",{className:"schedule-post-overlay",onClick:n,children:d.jsxs("div",{className:"schedule-post-modal",onClick:O=>O.stopPropagation(),children:[d.jsxs("div",{className:"schedule-post-modal-header",children:[d.jsx("h3",{children:"Schedule Post"}),d.jsx("button",{className:"schedule-post-modal-close",onClick:n,children:"×"})]}),d.jsx("div",{className:"schedule-post-modal-doc",children:e}),k?d.jsxs("div",{className:"schedule-post-modal-result error",children:[k,d.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):y?d.jsxs("div",{className:`schedule-post-modal-result ${y.success?"success":"error"}`,children:[y.message,d.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"schedule-post-modal-field",children:[d.jsx("label",{children:"Content Type"}),d.jsx("div",{className:"schedule-post-modal-type",children:N?"...":i})]}),d.jsxs("div",{className:"schedule-post-modal-field",children:[d.jsx("label",{children:"Mode"}),d.jsxs("div",{className:"schedule-post-modal-modes",children:[d.jsx("button",{className:`schedule-post-mode ${r==="queue"?"active":""}`,onClick:()=>s("queue"),children:"Queue Next"}),d.jsx("button",{className:`schedule-post-mode ${r==="now"?"active":""}`,onClick:()=>s("now"),children:"Post Now"}),d.jsx("button",{className:`schedule-post-mode ${r==="custom"?"active":""}`,onClick:()=>s("custom"),children:"Custom Time"})]})]}),r==="custom"&&d.jsxs("div",{className:"schedule-post-modal-field",children:[d.jsx("label",{children:"Date & Time"}),d.jsx("input",{type:"datetime-local",value:f,onChange:O=>p(O.target.value)})]}),d.jsxs("div",{className:"schedule-post-modal-actions",children:[d.jsx("button",{className:"schedule-post-modal-cancel",onClick:n,children:"Cancel"}),d.jsx("button",{className:"schedule-post-modal-submit",onClick:E,disabled:m||N||r==="custom"&&!f,children:m?"Scheduling...":r==="now"?"Post Now":"Schedule"})]})]})]})})}const H1=[{key:"document",label:"Document"},{key:"tweet",label:"Tweet",metadata:{tweetContext:{mode:"tweet"}}},{key:"reply",label:"Reply",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{tweetContext:{mode:"reply"}}},{key:"quote",label:"Quote Tweet",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{tweetContext:{mode:"quote"}}},{key:"article",label:"Article",metadata:{articleContext:{active:!0}}},{key:"linkedin",label:"LinkedIn",metadata:{linkedinContext:{active:!0}}},{key:"newsletter",label:"Newsletter",metadata:{newsletterContext:{active:!0}}},{key:"blog",label:"Blog",metadata:{blogContext:{active:!0}}}];function VB({anchorRect:t,onSelect:e,onClose:n}){const r=S.useRef(null),[s,i]=S.useState(null),[o,l]=S.useState(""),u=S.useRef(null),[f,p]=S.useState({left:t.left,top:t.bottom+4});S.useLayoutEffect(()=>{const b=r.current;if(!b)return;const k=b.getBoundingClientRect(),w=8;let E=t.left,N=t.bottom+4;N+k.height+w>window.innerHeight&&(N=t.top-k.height-4),E+k.width+w>window.innerWidth&&(E=t.right-k.width),N<w&&(N=w),E<w&&(E=w),p({left:E,top:N})},[t]),S.useEffect(()=>{const b=k=>{r.current&&!r.current.contains(k.target)&&n()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]),S.useEffect(()=>{const b=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[n]),S.useEffect(()=>{s&&setTimeout(()=>{var b;return(b=u.current)==null?void 0:b.focus()},0)},[s]);const m=b=>{if(b.needsUrl){i(b.key),l("");return}e(b.metadata)},g=()=>{if(!s||!o.trim())return;const b=o.trim();if(!b.includes("x.com")&&!b.includes("twitter.com"))return;const k=H1.find(E=>E.key===s);if(!(k!=null&&k.metadata))return;const w=JSON.parse(JSON.stringify(k.metadata));w.tweetContext&&(w.tweetContext.url=b),e(w)},y=o.trim().includes("x.com")||o.trim().includes("twitter.com");return d.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:H1.map(b=>d.jsxs("div",{children:[d.jsx("button",{className:`create-doc-dropdown-item${s===b.key?" active":""}`,onClick:()=>m(b),children:b.label}),s===b.key&&d.jsxs("div",{className:"create-doc-dropdown-url",children:[d.jsx("input",{ref:u,type:"text",placeholder:b.urlPlaceholder,value:o,onChange:k=>l(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),g()),k.key==="Escape"&&(i(null),l(""))}}),d.jsx("button",{onClick:g,disabled:!y,children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},b.key))})}const KB=[{id:"full",label:"Full"},{id:"compact",label:"Compact"},{id:"minimal",label:"Minimal"}];function AC(t,e){if(!e)return!0;for(const n of t)if(n.type==="container"&&(n.id===e||AC(n.items,e)))return!0;return!1}function OC(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=OC(n.items,e);if(r)return[n.id,...r]}}return null}function GB({docs:t,archivedDocs:e,workspaces:n,assignedFiles:r,pendingDocs:s,onSwitchDocument:i,onCreateDocument:o,actions:l,scrollRef:u,writingTitle:f,writingTarget:p,searchQuery:m,searchResults:g,onSearchChange:y}){const[b,k]=S.useState(null),[w,E]=S.useState(""),[N,O]=S.useState(null),[T,C]=S.useState(()=>{try{const re=localStorage.getItem("ow-collapsed-sections");return re?new Set(JSON.parse(re)):new Set}catch{return new Set}}),[R,L]=S.useState(null),[D,z]=S.useState(null),[F,J]=S.useState(""),[K,X]=S.useState(null),[W,$]=S.useState(""),[U,Z]=S.useState(null),[V,Y]=S.useState(""),[I,A]=S.useState(null),[j,Q]=S.useState(null),[oe,fe]=S.useState([]),[G,le]=S.useState(null),[Te,Ve]=S.useState(null),[ce,ue]=S.useState(null),[ae,je]=S.useState(null),[Me,He]=S.useState(BS),Ne=S.useRef(null);S.useEffect(()=>{if(!ae)return;const re=Je=>{Ne.current&&!Ne.current.contains(Je.target)&&je(null)};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[ae]);const tt=re=>{He(re),aM(re),je(null)},Be=re=>{re.preventDefault(),je({x:re.clientX,y:re.clientY})},{draggedItem:$e,dropIndicator:ye,handlePointerDown:pe,dropClass:Ze,isDragging:Ae,isContainerDropTarget:be}=zB({docs:t,workspaces:n,assignedFiles:r,scrollRef:u,setCollapsedSections:C}),ke=S.useCallback(()=>{fetch("/api/plugins").then(re=>re.json()).then(re=>{const Je=[];for(const et of re.plugins||[]){const Et=et.displayName||void 0;for(const rt of et.sidebarMenuItems||[])Je.push({...rt,pluginDisplayName:Et})}fe(Je)}).catch(()=>{})},[]);S.useEffect(()=>{ke()},[ke]),S.useEffect(()=>{const re=()=>ke();return window.addEventListener("ow-plugins-changed",re),()=>window.removeEventListener("ow-plugins-changed",re)},[ke]);const ze=S.useCallback((re,Je)=>{re.preventDefault(),re.stopPropagation(),A({x:re.clientX,y:re.clientY,filename:Je.filename,title:Je.title,docId:Je.docId,lastSent:Je.lastSent,postedUrl:Je.postedUrl,isNewsletter:Je.isNewsletter})},[]),ht=S.useCallback(re=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:re})}).catch(()=>{})},[]),wt=S.useCallback((re,Je,et,Et,rt)=>{if(Je.promptForFocus&&rt===void 0){le({action:re,label:Je.label,filename:et,title:Et});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:re,filename:et,title:Et,instructions:rt||"",label:Je.label})}).catch(()=>{})},[]),kt=re=>{C(Je=>{const et=new Set(Je);return et.has(re)?et.delete(re):et.add(re),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...et])),et})},Bt=t.find(re=>re.isActive),xn=S.useRef(n);if(xn.current=n,S.useEffect(()=>{var re;if(Bt)for(const Je of xn.current){const et=OC(((re=Je.workspace)==null?void 0:re.root)||[],Bt.filename);if(et){C(Et=>{const rt=[Je.filename,...et.map(ee=>`container-${ee}`)];if(rt.every(ee=>!Et.has(ee)))return Et;const nt=new Set(Et);for(const ee of rt)nt.delete(ee);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...nt])),nt});break}}},[Bt==null?void 0:Bt.filename]),g!==null)return d.jsx(R0,{results:g,query:m,onSwitchDocument:i,actions:l});const An=t.filter(re=>!r.has(re.filename)),On=(re,Je,et,Et,rt)=>d.jsxs("div",{className:`sidebar-item ${re.isActive?"active":""} ${Ae(re.filename)?"dragging":""} ${Ze(re.filename)}`,"data-drag-id":re.filename,"data-drag-type":"doc","data-drag-ws":Je||"__docs__","data-drag-container":et||"",onPointerDown:nt=>pe(nt,{type:"doc",file:re.filename,sourceWs:Je||null},re.title),onClick:()=>!re.isActive&&!$e&&i(re.filename),onDoubleClick:()=>{k(re.filename),E(re.title)},onContextMenu:nt=>ze(nt,re),children:[b===re.filename?d.jsx("input",{className:"sidebar-rename-input",value:w,onChange:nt=>E(nt.target.value),onBlur:()=>{l.handleRename(re.filename,re.title,w),k(null)},onKeyDown:nt=>{nt.key==="Enter"&&(l.handleRename(re.filename,re.title,w),k(null)),nt.key==="Escape"&&k(null)},autoFocus:!0,onClick:nt=>nt.stopPropagation()}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-item-title-text",children:re.title}),l.getDocTags(re.filename).includes("✓")&&d.jsx("svg",{className:"sidebar-approved-icon",title:"Approved",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),re.lastSent&&d.jsx("svg",{className:"sidebar-sent-icon",title:"Sent",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),s.filenames.includes(re.filename)&&d.jsx("span",{className:"sidebar-pending-dot"})]}),ys(re.filename)&&d.jsx("div",{className:"sidebar-item-context",children:MC(re.filename)}),d.jsxs("div",{className:"sidebar-item-meta",children:[re.wordCount.toLocaleString()," words · ",Vo(re.lastModified)]}),d.jsxs("div",{className:"sidebar-tags",children:[l.getDocTags(re.filename).filter(nt=>nt!=="✓").map(nt=>d.jsxs("span",{className:"sidebar-tag",onClick:ee=>ee.stopPropagation(),children:[nt,d.jsx("span",{className:"sidebar-tag-remove",onClick:ee=>{ee.stopPropagation(),l.handleRemoveTag(re.filename,nt)},children:"×"})]},nt)),U===re.filename?d.jsx("input",{className:"sidebar-tag-input",value:V,onChange:nt=>Y(nt.target.value),onBlur:()=>{V.trim()&&l.handleAddTag(re.filename,V),Z(null)},onKeyDown:nt=>{nt.key==="Enter"&&(l.handleAddTag(re.filename,V),Z(null),Y("")),nt.key==="Escape"&&(Z(null),Y(""))},autoFocus:!0,onClick:nt=>nt.stopPropagation(),placeholder:"tag..."}):d.jsx("button",{className:"sidebar-tag-add",onClick:nt=>{nt.stopPropagation(),Z(re.filename),Y("")},children:"+"})]})]}),N===re.filename?d.jsxs("div",{className:"sidebar-confirm-delete",onClick:nt=>nt.stopPropagation(),children:[d.jsx("span",{children:ys(re.filename)?"Remove?":"Delete?"}),d.jsx("button",{onClick:()=>{l.handleDelete(re.filename),O(null)},children:"Yes"}),d.jsx("button",{onClick:()=>O(null),children:"No"})]}):d.jsx("button",{className:"sidebar-delete-btn",onClick:nt=>{nt.stopPropagation(),O(re.filename)},title:ys(re.filename)?"Remove document":"Delete document",children:"×"})]},re.filename),wn=(re,Je,et,Et,rt,nt)=>{if(re.type==="doc"){const se=t.find(Se=>Se.filename===re.file);return se?On(se,et,Et):ys(re.file)?d.jsx("div",{className:"sidebar-item sidebar-unavailable",children:d.jsxs("div",{className:"sidebar-item-title",children:[re.title||re.file," (unavailable)"]})},re.file):d.jsxs("div",{className:"sidebar-item sidebar-missing",children:[d.jsxs("div",{className:"sidebar-item-title",children:[re.title||re.file," (missing)"]}),d.jsx("button",{className:"sidebar-delete-btn",onClick:()=>l.handleRemoveFromWorkspace(et,re.file),title:"Remove",children:"×"})]},re.file)}const ee=re,Ce=`container-${ee.id}`,lt=T.has(Ce),B=Je<=2?`depth-${Je}`:"depth-2";return d.jsxs("div",{className:`sidebar-container ${B} ${lt?"collapsed":""} ${Ze(ee.id)} ${be(ee.id)?"drop-inside":""}`,children:[d.jsxs("div",{className:`sidebar-container-header ${(ye==null?void 0:ye.itemId)===ee.id&&ye.position==="inside"?"drop-inside":""}`,"data-drag-id":ee.id,"data-drag-type":"container-header","data-drag-ws":et,"data-drag-parent":Et||"","data-section-key":Ce,onPointerDown:se=>pe(se,{type:"container",id:ee.id,sourceWs:et},ee.name),onClick:()=>!$e&&kt(Ce),children:[d.jsx("span",{className:`sidebar-chevron ${lt?"collapsed":""}`,children:"▾"}),D===ee.id?d.jsx("input",{className:"sidebar-rename-input",value:F,onChange:se=>J(se.target.value),onBlur:()=>{l.handleRenameContainer(et,ee.id,F),z(null)},onKeyDown:se=>{se.key==="Enter"&&(l.handleRenameContainer(et,ee.id,F),z(null)),se.key==="Escape"&&z(null)},autoFocus:!0,onClick:se=>se.stopPropagation()}):d.jsx("span",{className:"sidebar-container-name",onDoubleClick:se=>{se.stopPropagation(),z(ee.id),J(ee.name)},children:ee.name}),d.jsxs("div",{className:"sidebar-container-actions",children:[d.jsx("button",{className:"sidebar-new-btn",onClick:se=>{se.stopPropagation(),ue({anchor:se.target.getBoundingClientRect(),wsFilename:et,containerId:ee.id})},title:"New doc",children:"+"}),Je<2&&d.jsx("button",{className:"sidebar-new-btn",onClick:se=>{se.stopPropagation(),l.handleCreateContainer(et,ee.id)},title:"New sub-container",children:"☐"}),d.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:se=>{se.stopPropagation(),l.handleDeleteContainer(et,ee.id)},title:"Delete container",children:"×"})]})]}),!lt&&d.jsxs("div",{className:"sidebar-container-list","data-drop-ws":et,"data-drop-container":ee.id,children:[f&&(p==null?void 0:p.wsFilename)===et&&p.containerId===ee.id&&d.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-writing-spinner"}),d.jsx("span",{className:"sidebar-item-title-text",children:f})]}),d.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f&&(p==null?void 0:p.wsFilename)===et&&p.containerId===ee.id?ee.items.filter(se=>se.type!=="doc"||se.title!==f):ee.items).map((se,Se)=>wn(se,Je+1,et,ee.id,ee.items)),ee.items.length===0&&!f&&d.jsx("div",{className:"sidebar-empty",children:$e?"Drop here":"Empty"})]})]},ee.id)};return d.jsxs("div",{className:"sidebar-scroll",ref:u,children:[d.jsxs("div",{className:`sidebar-section sidebar-docs-section ${T.has("docs")?"docs-collapsed":""}`,children:[d.jsxs("div",{className:"sidebar-section-header","data-section-key":"docs",onClick:()=>kt("docs"),onContextMenu:Be,children:[d.jsx("span",{className:`sidebar-chevron ${T.has("docs")?"collapsed":""}`,children:"▾"}),d.jsx("span",{className:"sidebar-label",children:"Documents"}),d.jsx("button",{className:"sidebar-new-btn",onClick:re=>{re.stopPropagation(),ue({anchor:re.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!T.has("docs")&&d.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&(!p||!n.some(re=>re.filename===(p==null?void 0:p.wsFilename)))&&d.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-writing-spinner"}),d.jsx("span",{className:"sidebar-item-title-text",children:f})]}),d.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f?An.filter(re=>re.title!==f):An).map((re,Je)=>(An.map(et=>({type:"doc",file:et.filename,title:et.title})),On(re,void 0,null))),An.length===0&&d.jsx("div",{className:"sidebar-empty",children:$e?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(re=>{var Et;const Je=((Et=re.workspace)==null?void 0:Et.root)||[],et=T.has(re.filename);return d.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${et?"ws-collapsed":""} ${Ae(re.filename)?"dragging":""} ${(ye==null?void 0:ye.itemId)===re.filename?ye.position==="before"?"drop-before":"drop-after":""}`,children:[d.jsxs("div",{className:"sidebar-section-header","data-section-key":re.filename,"data-ws-drag":re.filename,onPointerDown:rt=>pe(rt,{type:"workspace",filename:re.filename},re.title),onClick:()=>!$e&&kt(re.filename),onContextMenu:Be,children:[d.jsx("span",{className:`sidebar-chevron ${et?"collapsed":""}`,children:"▾"}),K===re.filename?d.jsx("input",{className:"sidebar-rename-input",value:W,onChange:rt=>$(rt.target.value),onBlur:()=>{l.handleRenameWorkspace(re.filename,W),X(null)},onKeyDown:rt=>{rt.key==="Enter"&&(l.handleRenameWorkspace(re.filename,W),X(null)),rt.key==="Escape"&&X(null)},autoFocus:!0,onClick:rt=>rt.stopPropagation()}):d.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:rt=>{rt.stopPropagation(),X(re.filename),$(re.title)},children:re.title}),d.jsxs("div",{className:"sidebar-workspace-actions",children:[d.jsx("button",{className:"sidebar-new-btn",onClick:rt=>{rt.stopPropagation(),ue({anchor:rt.target.getBoundingClientRect(),wsFilename:re.filename,containerId:null})},title:"New document",children:"+"}),d.jsx("button",{className:"sidebar-new-btn",onClick:rt=>{rt.stopPropagation(),l.handleCreateContainer(re.filename,null)},title:"New container",children:"☐"}),R===re.filename?d.jsxs("span",{className:"sidebar-inline-confirm",onClick:rt=>rt.stopPropagation(),children:[d.jsx("button",{onClick:()=>{l.handleDeleteWorkspace(re.filename),L(null)},children:"Yes"}),d.jsx("button",{onClick:()=>L(null),children:"No"})]}):d.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:rt=>{rt.stopPropagation(),L(re.filename)},title:"Delete workspace",children:"×"})]})]}),!et&&d.jsxs("div",{className:"sidebar-section-list","data-drop-ws":re.filename,children:[f&&(p==null?void 0:p.wsFilename)===re.filename&&(p.containerId===null||!AC(Je,p.containerId))&&d.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-writing-spinner"}),d.jsx("span",{className:"sidebar-item-title-text",children:f})]}),d.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f&&(p==null?void 0:p.wsFilename)===re.filename&&p.containerId===null?Je.filter(rt=>rt.type!=="doc"||rt.title!==f):Je).map((rt,nt)=>wn(rt,0,re.filename,null)),Je.length===0&&!f&&d.jsx("div",{className:"sidebar-empty",children:$e?"Drop here to add":"Empty workspace"})]})]},re.filename)}),d.jsx("div",{className:"sidebar-new-workspace",children:d.jsx("button",{onClick:l.handleCreateWorkspace,children:"+ New Workspace"})}),I&&d.jsx(FB,{x:I.x,y:I.y,filename:I.filename,title:I.title,onClose:()=>A(null),onDuplicate:()=>ht(I.filename),onRename:()=>{k(I.filename),E(I.title)},onArchive:()=>l.handleArchive(I.filename),onDelete:()=>l.handleDelete(I.filename),onPluginAction:(re,Je)=>wt(re,Je,I.filename,I.title),pluginItems:oe,onSchedulePost:()=>{Ve({filename:I.filename,title:I.title}),A(null)},onViewAnalytics:I.docId&&I.lastSent&&(I.postedUrl||I.isNewsletter)?()=>{I.isNewsletter?Q({docId:I.docId,title:I.title}):I.postedUrl&&window.open(I.postedUrl,"_blank"),A(null)}:void 0,viewAnalyticsLabel:I.isNewsletter?"View Analytics":I.postedUrl?"View on X":"View Analytics",isApproved:l.getDocTags(I.filename).includes("✓"),onToggleApprove:()=>{l.getDocTags(I.filename).includes("✓")?l.handleRemoveTag(I.filename,"✓"):(l.handleAddTag(I.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAlreadySent:!!I.lastSent,onMarkSent:()=>{const re=I.filename;l.getDocTags(re).includes("✓")&&l.handleRemoveTag(re,"✓"),i(re),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>l.fetchDocs()).catch(()=>{})},100),A(null)}}),G&&d.jsx($B,{actionLabel:G.label,docTitle:G.title,onClose:()=>le(null),onConfirm:re=>{const Je=oe.find(et=>et.action===G.action);Je&&wt(G.action,Je,G.filename,G.title,re),le(null)}}),j&&d.jsx(UB,{docId:j.docId,title:j.title,onClose:()=>Q(null)}),Te&&d.jsx(Td,{filename:Te.filename,title:Te.title,onClose:()=>Ve(null)}),ce&&d.jsx(VB,{anchorRect:ce.anchor,onClose:()=>ue(null),onSelect:re=>{ue(null),ce.wsFilename?l.handleCreateInWorkspace(ce.wsFilename,ce.containerId??null,re):re?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:re})}).catch(()=>{}):o()}}),ae&&d.jsx("div",{ref:Ne,className:"sidebar-density-dropdown",style:{position:"fixed",left:ae.x,top:ae.y,zIndex:200},children:KB.map(re=>d.jsx("button",{className:`sidebar-density-option ${Me===re.id?"active":""}`,onClick:()=>tt(re.id),children:re.label},re.id))})]})}function JB({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:o,scrollRef:l,searchQuery:u,searchResults:f}){const[p,m]=S.useState(null);if(f!==null)return d.jsx(R0,{results:f,query:u,onSwitchDocument:s});const g=[...t].sort((w,E)=>new Date(E.lastModified).getTime()-new Date(w.lastModified).getTime()),y=[];let b="";for(const w of g){const E=DB(w.lastModified);E!==b&&(y.push({label:E,docs:[]}),b=E),y[y.length-1].docs.push(w)}const k=w=>{for(const E of e){if(!E.workspace)continue;const N=O=>{for(const T of O)if(T.type==="doc"&&T.file===w||T.type==="container"&&N(T.items))return!0;return!1};if(N(E.workspace.root))return E.title}return null};return d.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:l,children:[d.jsxs("div",{className:"tl-header",children:[d.jsx("span",{className:"tl-title",children:"Timeline"}),d.jsx("button",{className:"sidebar-new-btn",onClick:i,title:"New document",children:"+"})]}),y.map(w=>d.jsxs("div",{className:"tl-group",children:[d.jsx("div",{className:"tl-date",children:w.label}),w.docs.map(E=>{const N=k(E.filename);return d.jsxs("div",{className:`tl-item ${E.isActive?"active":""}`,onClick:()=>!E.isActive&&s(E.filename),children:[d.jsx("div",{className:"tl-dot"}),d.jsxs("div",{className:"tl-content",children:[d.jsxs("div",{className:"tl-item-title",children:[d.jsx("span",{children:E.title}),r.filenames.includes(E.filename)&&d.jsx("span",{className:"sidebar-pending-dot"})]}),ys(E.filename)&&d.jsx("div",{className:"tl-item-context",children:MC(E.filename)}),d.jsxs("div",{className:"tl-item-meta",children:[E.wordCount.toLocaleString()," words · ",Vo(E.lastModified)]}),N&&d.jsx("div",{className:"tl-badge",children:N})]}),p===E.filename?d.jsxs("div",{className:"sidebar-confirm-delete",onClick:O=>O.stopPropagation(),children:[d.jsx("span",{children:ys(E.filename)?"Remove?":"Delete?"}),d.jsx("button",{onClick:()=>{o.handleDelete(E.filename),m(null)},children:"Yes"}),d.jsx("button",{onClick:()=>m(null),children:"No"})]}):d.jsx("button",{className:"sidebar-delete-btn",onClick:O=>{O.stopPropagation(),m(E.filename)},title:ys(E.filename)?"Remove":"Delete",children:"×"})]},E.filename)})]},w.label)),t.length===0&&d.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function YB({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:l,searchResults:u,onSearchChange:f}){const[p,m]=S.useState([]),[g,y]=S.useState(null),[b,k]=S.useState(null),w=S.useRef(null);S.useEffect(()=>{if(!g)return;const A=j=>{w.current&&!w.current.contains(j.target)&&y(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[g]);const E=(A,j)=>{for(const Q of A)if(Q.type==="container"){if(Q.id===j)return Q;const oe=E(Q.items,j);if(oe)return oe}return null},N=A=>{let j=0;for(const Q of A)Q.type==="doc"?j++:Q.type==="container"&&(j+=N(Q.items));return j},O=A=>{const j=[];for(const Q of A)Q.type==="doc"?j.push(Q.file):Q.type==="container"&&j.push(...O(Q.items));return j},T=S.useMemo(()=>{if(p.length===0)return[];const A=p[p.length-1],j=e.find(oe=>oe.filename===A.wsFilename);if(!(j!=null&&j.workspace))return[];if(A.type==="workspace")return j.workspace.root;const Q=E(j.workspace.root,A.key);return Q?Q.items:[]},[p,e]),C=T.filter(A=>A.type==="container"),R=S.useMemo(()=>{const A=T.filter(j=>j.type==="doc").map(j=>j.file);return t.filter(j=>A.includes(j.filename))},[T,t]),L=A=>{const j=O(A.items);return t.filter(Q=>j.includes(Q.filename))},D=A=>{const j=e.find(oe=>oe.filename===A);if(!(j!=null&&j.workspace))return[];const Q=O(j.workspace.root);return t.filter(oe=>Q.includes(oe.filename))},z=S.useMemo(()=>t.filter(A=>!n.has(A.filename)),[t,n]),F=A=>{m(j=>[...j,A]),y(null)},J=()=>{m(A=>A.slice(0,-1)),y(null)},K=(A,j)=>{if(g===A){y(null);return}const oe=j.currentTarget.getBoundingClientRect();k({top:oe.bottom+4,left:oe.left}),y(A)},X=A=>{s(A),y(null)},W=p.length>1?p[p.length-2].title:"All",$=S.useRef(null),U=S.useRef(null),[Z,V]=S.useState(null),Y=S.useCallback(A=>{const Q=A.currentTarget.getBoundingClientRect();V({top:Q.bottom+4,left:Q.left})},[]);S.useEffect(()=>{if(!u)return;const A=j=>{U.current&&!U.current.contains(j.target)&&$.current&&!$.current.contains(j.target)&&f("")};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[u,f]);const I=()=>{if(!g)return[];if(g==="__unassigned__")return z;if(g==="__level-docs__")return R;const A=e.find(j=>j.filename===g);if(A)return D(A.filename);for(const j of e){if(!j.workspace)continue;const Q=E(j.workspace.root,g);if(Q)return L(Q)}return[]};return d.jsxs("div",{className:"board-scroll",ref:o,children:[d.jsxs("div",{className:"board-search-pill",children:[d.jsxs("svg",{className:"board-search-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("path",{d:"m21 21-4.3-4.3"})]}),d.jsx("input",{ref:$,className:"board-search-input",type:"text",placeholder:"Search...",value:l,onChange:A=>f(A.target.value),onFocus:Y}),l&&d.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),p.length===0?d.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):d.jsxs("button",{className:"board-back",onClick:J,title:`Back to ${W}`,children:["← ",W]}),p.length===0&&d.jsxs(d.Fragment,{children:[z.length>0&&d.jsxs("button",{className:`board-chip ${g==="__unassigned__"?"open":""}`,onClick:A=>K("__unassigned__",A),children:["Documents ",d.jsx("span",{className:"board-chip-count",children:z.length})]}),e.map(A=>{var Q;const j=(Q=A.workspace)==null?void 0:Q.root.some(oe=>oe.type==="container");return d.jsxs("button",{className:`board-chip ${g===A.filename?"open":""}`,onClick:oe=>j?F({type:"workspace",key:A.filename,title:A.title,wsFilename:A.filename}):K(A.filename,oe),children:[A.title," ",d.jsx("span",{className:"board-chip-count",children:A.docCount}),j&&d.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.filename)}),d.jsx("button",{className:"board-chip board-chip-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),p.length>0&&d.jsxs(d.Fragment,{children:[R.length>0&&d.jsxs("button",{className:`board-chip board-chip-docs ${g==="__level-docs__"?"open":""}`,onClick:A=>K("__level-docs__",A),children:["Docs ",d.jsx("span",{className:"board-chip-count",children:R.length})]}),C.map(A=>{const j=A.items.some(Q=>Q.type==="container");return d.jsxs("button",{className:`board-chip ${g===A.id?"open":""}`,onClick:Q=>j?F({type:"container",key:A.id,title:A.name,wsFilename:p[p.length-1].wsFilename}):K(A.id,Q),children:[A.name," ",d.jsx("span",{className:"board-chip-count",children:N(A.items)}),j&&d.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.id)})]}),g&&b&&(()=>{const A=I();return d.jsxs("div",{className:"board-dropdown",ref:w,style:{position:"fixed",top:b.top,left:b.left},children:[A.map(j=>d.jsxs("div",{className:`board-dropdown-item ${j.isActive?"active":""}`,onClick:()=>X(j.filename),children:[d.jsxs("span",{className:"board-dropdown-title",children:[j.title,r.filenames.includes(j.filename)&&d.jsx("span",{className:"board-pending-dot"})]}),d.jsxs("span",{className:"board-dropdown-meta",children:[j.wordCount.toLocaleString()," words · ",Vo(j.lastModified)]})]},j.filename)),A.length===0&&d.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),u&&Z&&d.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:U,style:{position:"fixed",top:Z.top,left:Z.left},children:[u.map(A=>d.jsxs("div",{className:`board-dropdown-item ${A.isActive?"active":""}`,onClick:()=>{s(A.filename),f("")},children:[d.jsx("span",{className:"board-dropdown-title",children:A.title}),A.matchType==="tag"&&A.matchedTag&&d.jsxs("span",{className:"board-dropdown-meta",children:["Tag: ",A.matchedTag]}),A.matchType==="content"&&A.snippet&&d.jsx("span",{className:"board-dropdown-meta board-search-snippet",children:A.snippet}),d.jsxs("span",{className:"board-dropdown-meta",children:[A.wordCount.toLocaleString()," words · ",Vo(A.lastModified)]})]},A.filename)),u.length===0&&d.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function QB({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:l,searchResults:u}){const[f,p]=S.useState([]);if(u!==null)return d.jsx(R0,{results:u,query:l,onSwitchDocument:s});const m=(T,C)=>{for(const R of T)if(R.type==="container"){if(R.id===C)return R;const L=m(R.items,C);if(L)return L}return null},g=T=>{let C=0;for(const R of T)R.type==="doc"?C++:R.type==="container"&&(C+=g(R.items));return C},y=S.useMemo(()=>{if(f.length===0)return[];const T=f[f.length-1],C=e.find(L=>L.filename===T.wsFilename);if(!(C!=null&&C.workspace))return[];if(T.type==="workspace")return C.workspace.root;const R=m(C.workspace.root,T.key);return R?R.items:[]},[f,e]),b=y.filter(T=>T.type==="container"),k=S.useMemo(()=>{if(f.length===0)return t.filter(C=>!n.has(C.filename));const T=y.filter(C=>C.type==="doc").map(C=>C.file);return t.filter(C=>T.includes(C.filename))},[f,y,t,n]),w=T=>p(C=>[...C,T]),E=()=>p(T=>T.slice(0,-1)),N=f.length>1?f[f.length-2].title:"Shelf",O=f.length>0?f[f.length-1].title:"Documents";return d.jsxs("div",{className:"shelf-wrapper",children:[d.jsxs("div",{className:"shelf-spines",ref:o,children:[f.length>0&&d.jsxs("button",{className:"shelf-back",onClick:E,title:`Back to ${N}`,children:[d.jsx("span",{className:"shelf-back-arrow",children:"←"}),d.jsx("span",{className:"shelf-back-label",children:N})]}),f.length===0&&d.jsxs(d.Fragment,{children:[e.map(T=>d.jsxs("div",{className:"shelf-section-spine",onClick:()=>w({type:"workspace",key:T.filename,title:T.title,wsFilename:T.filename}),title:T.title,children:[d.jsx("span",{className:"shelf-section-title",children:T.title}),d.jsx("span",{className:"shelf-section-count",children:T.docCount})]},T.filename)),d.jsx("button",{className:"shelf-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),f.length>0&&b.map(T=>d.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>w({type:"container",key:T.id,title:T.name,wsFilename:f[f.length-1].wsFilename}),title:T.name,children:[d.jsx("span",{className:"shelf-section-title",children:T.name}),d.jsx("span",{className:"shelf-section-count",children:g(T.items)})]},T.id))]}),d.jsxs("div",{className:"shelf-docs",children:[d.jsx("div",{className:"shelf-docs-header",children:O}),d.jsxs("div",{className:"shelf-docs-list",children:[k.map(T=>d.jsxs("div",{className:`shelf-doc-item ${T.isActive?"active":""}`,onClick:()=>s(T.filename),children:[d.jsxs("div",{className:"shelf-doc-title",children:[d.jsx("span",{children:T.title}),r.filenames.includes(T.filename)&&d.jsx("span",{className:"shelf-pending-dot"})]}),d.jsxs("div",{className:"shelf-doc-meta",children:[T.wordCount.toLocaleString()," words · ",Vo(T.lastModified)]})]},T.filename)),k.length===0&&d.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}const XB=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],ZB=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}],RC=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","America/Phoenix","America/Toronto","America/Vancouver","America/Sao_Paulo","America/Mexico_City","Europe/London","Europe/Paris","Europe/Berlin","Europe/Amsterdam","Europe/Rome","Europe/Madrid","Europe/Moscow","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Asia/Singapore","Asia/Seoul","Australia/Sydney","Australia/Melbourne","Pacific/Auckland"];function W1(t){var e;try{const n=new Date,i=((e=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(n).find(l=>l.type==="timeZoneName"))==null?void 0:e.value)||"";return`${t.split("/").pop().replace(/_/g," ")} (${i})`}catch{return t}}function e5(t){if(t.length>0)return t[0].timezone;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(RC.includes(e))return e}catch{}return"America/New_York"}function t5({slots:t,onBack:e}){const[n,r]=S.useState(t),[s,i]=S.useState(()=>e5(t)),[o,l]=S.useState(!1),[u,f]=S.useState("09:00"),[p,m]=S.useState(["default"]),[g,y]=S.useState("any"),[b,k]=S.useState(!1),w=S.useRef(null);S.useEffect(()=>{if(!o)return;function C(R){w.current&&!w.current.contains(R.target)&&l(!1)}return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[o]);async function E(C){i(C);const R=[];for(const L of n){const D=await fetch(`/api/scheduler/slots/${L.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:C})});if(D.ok){const z=await D.json();R.push(z.slot)}else R.push(L)}R.length>0&&r(R)}async function N(){const C=await fetch("/api/scheduler/slots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:u,days:p.includes("default")?["default"]:p,filter_type:g,timezone:s})});if(C.ok){const R=await C.json();r(L=>[...L,R.slot]),k(!1),f("09:00"),m(["default"]),y("any")}}async function O(C){(await fetch(`/api/scheduler/slots/${C}`,{method:"DELETE"})).ok&&r(L=>L.filter(D=>D.id!==C))}function T(C){m(R=>{if(C==="default")return["default"];const L=R.filter(D=>D!=="default");if(L.includes(C)){const D=L.filter(z=>z!==C);return D.length===0?["default"]:D}return[...L,C]})}return d.jsxs("div",{className:"sidebar-schedule",children:[d.jsxs("div",{className:"sidebar-schedule-header",children:[d.jsx("button",{className:"sidebar-schedule-btn",onClick:e,title:"Back",children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}),d.jsx("h3",{children:"Slot Settings"}),d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>k(!b),children:b?"Cancel":"+ Add"})]}),d.jsxs("div",{className:"slot-tz",ref:w,children:[d.jsx("label",{className:"slot-tz-label",children:"Timezone"}),d.jsxs("button",{className:"slot-tz-trigger",onClick:()=>l(!o),children:[d.jsx("span",{children:W1(s)}),d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`slot-tz-chevron ${o?"slot-tz-chevron--open":""}`,children:d.jsx("path",{d:"m6 9 6 6 6-6"})})]}),o&&d.jsx("div",{className:"slot-tz-dropdown",children:RC.map(C=>d.jsx("div",{className:`slot-tz-option ${C===s?"active":""}`,onClick:()=>{E(C),l(!1)},children:W1(C)},C))})]}),b&&d.jsxs("div",{className:"slot-add-form",children:[d.jsxs("div",{className:"slot-add-row",children:[d.jsx("input",{type:"time",className:"slot-input",value:u,onChange:C=>f(C.target.value)}),d.jsx("select",{className:"slot-input",value:g,onChange:C=>y(C.target.value),children:ZB.map(C=>d.jsx("option",{value:C.value,children:C.label},C.value))})]}),d.jsxs("div",{className:"slot-add-days",children:[d.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${p.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>T("default"),children:"Every day"}),XB.map(C=>d.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${p.includes(C.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>T(C.toLowerCase()),children:C},C))]}),d.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active slot-create-btn",onClick:N,children:"Create Slot"})]}),d.jsx("div",{className:"slot-list",children:n.length===0?d.jsxs("div",{className:"schedule-empty",children:[d.jsx("div",{className:"schedule-empty-title",children:"No slots"}),d.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):n.map(C=>d.jsxs("div",{className:"schedule-item slot-item",children:[d.jsx("div",{className:"schedule-item-time slot-item-time",children:n5(C.time)}),d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:C.days.includes("default")?"Every day":C.days.join(", ")}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsxs("span",{children:["Filter: ",C.filter_type]}),C.filter_value&&d.jsxs("span",{children:["(",C.filter_value,")"]})]})]}),d.jsx("button",{className:"schedule-item-action schedule-item-action--danger slot-delete-btn",onClick:()=>O(C.id),title:"Delete slot",children:"×"})]},C.id))})]})}function n5(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function r5({onBack:t}){const[e,n]=S.useState([]),[r,s]=S.useState([]),[i,o]=S.useState(null),[l,u]=S.useState(!1),[f,p]=S.useState(!0),m=S.useCallback(async()=>{try{const[E,N]=await Promise.all([fetch("/api/scheduler/autoplugs/goals"),fetch("/api/scheduler/autoplugs/tracking")]);if(E.ok){const O=await E.json();n(O.goals||[])}if(N.ok){const O=await N.json();s(O.tracking||[])}}catch{}p(!1)},[]);S.useEffect(()=>{m()},[m]);const g=async E=>{(await fetch(`/api/scheduler/autoplugs/goals/${E.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!E.enabled})})).ok&&n(O=>O.map(T=>T.id===E.id?{...T,enabled:!T.enabled}:T))},y=async E=>{(await fetch(`/api/scheduler/autoplugs/goals/${E}`,{method:"DELETE"})).ok&&(n(O=>O.filter(T=>T.id!==E)),o(null))},b=async E=>{(await fetch(`/api/scheduler/autoplugs/tracking/${E}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipped:!0})})).ok&&s(O=>O.map(T=>T.id===E?{...T,skipped:!0}:T))},k=e.reduce((E,N)=>N.rule&&N.enabled?Math.min(E,N.rule.threshold):E,1/0),w=k===1/0?50:k;return d.jsxs("div",{className:"sidebar-schedule",children:[d.jsxs("div",{className:"sidebar-schedule-header",children:[d.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}),d.jsx("h3",{children:"Autoplugs"}),d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>u(!l),children:l?"Cancel":"+ Add"})]}),l&&d.jsx(i5,{onCreated:E=>{n(N=>[...N,E]),u(!1)}}),f?null:d.jsxs(d.Fragment,{children:[e.length===0?d.jsxs("div",{className:"schedule-empty",children:[d.jsx("div",{className:"schedule-empty-title",children:"No goals"}),d.jsx("div",{className:"schedule-empty-desc",children:"Create a goal to start autoplugging your tweets."})]}):e.map(E=>d.jsxs("div",{children:[d.jsxs("div",{className:"schedule-item",onClick:()=>o(i===E.id?null:E.id),children:[d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:E.name}),d.jsx("div",{className:"schedule-item-meta",children:s5(E).map((N,O)=>d.jsx("span",{children:N},O))})]}),d.jsx("button",{className:`autoplug-toggle ${E.enabled?"autoplug-toggle--on":"autoplug-toggle--off"}`,onClick:N=>{N.stopPropagation(),g(E)},title:E.enabled?"Disable":"Enable"})]}),i===E.id&&d.jsx(o5,{goal:E,onSaved:N=>{n(O=>O.map(T=>T.id===N.id?N:T))},onDeleted:()=>y(E.id),onRefresh:m})]},E.id)),d.jsx("div",{className:"schedule-day-header",children:"Tracking"}),r.length===0?d.jsxs("div",{className:"schedule-empty",children:[d.jsx("div",{className:"schedule-empty-title",children:"No tracked tweets"}),d.jsx("div",{className:"schedule-empty-desc",children:"Tweets will appear here after posting."})]}):r.map(E=>d.jsxs("div",{className:"schedule-item",children:[d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:E.original_text||`Tweet ${E.tweet_id}`}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsx("span",{children:a5(E.posted_at)}),d.jsxs("span",{children:[E.likes," likes"]}),d.jsxs("span",{children:[E.retweets," RTs"]}),E.views>0&&d.jsxs("span",{children:[l5(E.views)," views"]})]}),E.triggered?d.jsxs("div",{className:"autoplug-tracking-triggered",children:[d.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Autoplugged ",E.goal_name?`→ ${E.goal_name}`:""]}):E.skipped?d.jsx("div",{className:"autoplug-tracking-skipped",children:"Skipped"}):d.jsx("div",{className:"autoplug-tracking-bar",children:d.jsx("div",{className:"autoplug-tracking-bar-fill",style:{width:`${Math.min(100,E.likes/w*100)}%`}})})]}),!E.triggered&&!E.skipped&&d.jsx("button",{className:"autoplug-tracking-skip",onClick:()=>b(E.id),title:"Skip autoplug for this tweet",children:"×"})]},E.id))]})]})}function s5(t){const e=[];return t.rule&&(e.push(`${t.rule.threshold}+ ${t.rule.metric}`),e.push(t.rule.mode.charAt(0).toUpperCase()+t.rule.mode.slice(1)),t.rule.delay_minutes>0&&e.push(`${t.rule.delay_minutes}m delay`)),e.push(`${t.pool_count} msg${t.pool_count!==1?"s":""}`),e}function i5({onCreated:t}){const[e,n]=S.useState(""),[r,s]=S.useState(""),[i,o]=S.useState(""),[l,u]=S.useState("likes"),[f,p]=S.useState(50),[m,g]=S.useState(30),[y,b]=S.useState("static"),[k,w]=S.useState(!1),E=async()=>{if(e.trim()){w(!0);try{const N=await fetch("/api/scheduler/autoplugs/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.trim(),link:r.trim()||null,description:i.trim()||null})});if(!N.ok){w(!1);return}const{goal:O}=await N.json();await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:O.id,metric:l,threshold:f,delay_minutes:m,mode:y})});const T=await fetch("/api/scheduler/autoplugs/goals");if(T.ok){const R=((await T.json()).goals||[]).find(L=>L.id===O.id);if(R){t(R);return}}t({...O,rule_count:1,pool_count:0,rule:{metric:l,threshold:f,delay_minutes:m,mode:y,id:""}})}finally{w(!1)}}};return d.jsxs("div",{className:"autoplug-editor",children:[d.jsxs("label",{children:["Name",d.jsx("input",{value:e,onChange:N=>n(N.target.value),placeholder:"Newsletter, Course..."})]}),d.jsxs("label",{children:["Link",d.jsx("input",{value:r,onChange:N=>s(N.target.value),placeholder:"https://..."})]}),d.jsxs("label",{children:["Description (context for LLM)",d.jsx("textarea",{value:i,onChange:N=>o(N.target.value),placeholder:"Weekly engineering insights...",rows:2})]}),d.jsxs("div",{className:"autoplug-editor-row",children:[d.jsx("input",{type:"number",value:f,onChange:N=>p(Number(N.target.value)),min:1}),d.jsxs("select",{value:l,onChange:N=>u(N.target.value),children:[d.jsx("option",{value:"likes",children:"likes"}),d.jsx("option",{value:"retweets",children:"retweets"}),d.jsx("option",{value:"views",children:"views"})]}),d.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),d.jsx("input",{type:"number",value:m,onChange:N=>g(Number(N.target.value)),min:0,className:"autoplug-delay-input"}),d.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),d.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(N=>d.jsx("button",{className:y===N?"active":"",onClick:()=>b(N),children:N==="llm"?"LLM":N.charAt(0).toUpperCase()+N.slice(1)},N))}),d.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active autoplug-create-btn",onClick:E,disabled:k||!e.trim(),children:k?"Creating...":"Create Goal"})]})}function o5({goal:t,onSaved:e,onDeleted:n,onRefresh:r}){var J,K,X,W;const[s,i]=S.useState(t.name),[o,l]=S.useState(t.link||""),[u,f]=S.useState(t.description||""),[p,m]=S.useState(((J=t.rule)==null?void 0:J.metric)||"likes"),[g,y]=S.useState(((K=t.rule)==null?void 0:K.threshold)||50),[b,k]=S.useState(((X=t.rule)==null?void 0:X.delay_minutes)||30),[w,E]=S.useState(((W=t.rule)==null?void 0:W.mode)||"static"),[N,O]=S.useState([]),[T,C]=S.useState(""),[R,L]=S.useState(!1);S.useEffect(()=>{fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`).then($=>$.json()).then($=>O($.pool||[])).catch(()=>{})},[t.id]);const D=async()=>{var $;L(!0);try{await fetch(`/api/scheduler/autoplugs/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,link:o||null,description:u||null})}),($=t.rule)!=null&&$.id?await fetch(`/api/scheduler/autoplugs/rules/${t.rule.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metric:p,threshold:g,delay_minutes:b,mode:w})}):await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:t.id,metric:p,threshold:g,delay_minutes:b,mode:w})}),r()}finally{L(!1)}},z=async()=>{if(!T.trim())return;const $=await fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:T.trim()})});if($.ok){const U=await $.json();O(Z=>[...Z,U.message]),C("")}},F=async $=>{(await fetch(`/api/scheduler/autoplugs/pool/${$}`,{method:"DELETE"})).ok&&O(Z=>Z.filter(V=>V.id!==$))};return d.jsxs("div",{className:"autoplug-editor",children:[d.jsxs("label",{children:["Name",d.jsx("input",{value:s,onChange:$=>i($.target.value)})]}),d.jsxs("label",{children:["Link",d.jsx("input",{value:o,onChange:$=>l($.target.value),placeholder:"https://..."})]}),d.jsxs("label",{children:["Description",d.jsx("textarea",{value:u,onChange:$=>f($.target.value),rows:2})]}),d.jsx("div",{className:"autoplug-editor-section-label",children:"Trigger"}),d.jsxs("div",{className:"autoplug-editor-row",children:[d.jsx("input",{type:"number",value:g,onChange:$=>y(Number($.target.value)),min:1}),d.jsxs("select",{value:p,onChange:$=>m($.target.value),children:[d.jsx("option",{value:"likes",children:"likes"}),d.jsx("option",{value:"retweets",children:"retweets"}),d.jsx("option",{value:"views",children:"views"})]}),d.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),d.jsx("input",{type:"number",value:b,onChange:$=>k(Number($.target.value)),min:0,className:"autoplug-delay-input"}),d.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),d.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map($=>d.jsx("button",{className:w===$?"active":"",onClick:()=>E($),children:$==="llm"?"LLM":$.charAt(0).toUpperCase()+$.slice(1)},$))}),d.jsxs("div",{className:"autoplug-pool-section",children:[d.jsx("div",{className:"autoplug-editor-section-label",children:"Static Pool"}),N.map($=>d.jsxs("div",{className:"autoplug-pool-item",children:[d.jsx("span",{children:$.content}),d.jsx("button",{onClick:()=>F($.id),title:"Remove",children:"×"})]},$.id)),d.jsxs("div",{className:"autoplug-pool-add",children:[d.jsx("input",{value:T,onChange:$=>C($.target.value),placeholder:"Add message... (use {{link}} for link)",onKeyDown:$=>$.key==="Enter"&&z()}),d.jsx("button",{onClick:z,children:"+"})]})]}),(w==="llm"||w==="hybrid")&&d.jsx("div",{className:"autoplug-llm-hint",children:"LLM mode uses Author's Voice to generate contextual replies referencing the original tweet."}),d.jsxs("div",{className:"autoplug-editor-actions",children:[d.jsx("button",{className:"schedule-item-action",onClick:D,disabled:R,children:R?"Saving...":"Save"}),d.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:n,children:"Delete"})]})]})}function a5(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/6e4);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function l5(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function c5({onBack:t}){const[e,n]=S.useState([]),[r,s]=S.useState([]),[i,o]=S.useState(!1),[l,u]=S.useState(!1),[f,p]=S.useState(null),[m,g]=S.useState(!0),y=S.useCallback(async()=>{try{const[w,E]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots"),fetch("/api/scheduler/sync",{method:"POST"})]);if(w.ok){const N=await w.json();n(N.items||[])}if(E.ok){const N=await E.json();s(N.slots||[])}}catch{}g(!1)},[]);S.useEffect(()=>{y()},[y]);const b=async w=>{(await fetch(`/api/scheduler/queue/${w}`,{method:"DELETE"})).ok&&(n(N=>N.filter(O=>O.id!==w)),p(null))};if(l)return d.jsx(r5,{onBack:()=>{u(!1),y()}});if(i)return d.jsx(t5,{slots:r,onBack:()=>{o(!1),y()}});const k=u5(r,e);return d.jsxs("div",{className:"sidebar-schedule",children:[d.jsxs("div",{className:"sidebar-schedule-header",children:[d.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back to documents",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}),d.jsx("h3",{children:"Schedule"}),d.jsxs("div",{className:"sidebar-schedule-actions",children:[d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>u(!0),title:"Autoplugs",children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}),d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>o(!0),title:"Manage slots",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),m?null:r.length===0?d.jsxs("div",{className:"schedule-empty",children:[d.jsx("div",{className:"schedule-empty-title",children:"No time slots"}),d.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):k.map(({label:w,entries:E})=>d.jsxs("div",{className:"schedule-day",children:[d.jsx("div",{className:"schedule-day-header",children:w}),E.map((N,O)=>{var T,C,R,L,D;return N.type==="empty"?d.jsxs("div",{className:"schedule-slot-empty",children:[d.jsx("div",{className:"schedule-item-time",children:V1(N.time)}),d.jsx("div",{className:"schedule-slot-empty-label",children:((T=N.slot)==null?void 0:T.filter_type)==="any"?"Open slot":`${(C=N.slot)==null?void 0:C.filter_type}: ${((R=N.slot)==null?void 0:R.filter_value)||"any"}`})]},`empty-${O}`):d.jsxs("div",{children:[d.jsxs("div",{className:"schedule-item",onClick:()=>p(f===N.item.id?null:N.item.id),children:[d.jsx("div",{className:"schedule-item-time",children:V1(N.time)}),d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:((L=N.item.content)==null?void 0:L.text)||JSON.stringify(N.item.content)}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsx("span",{className:`schedule-item-status schedule-item-status--${N.item.status}`}),d.jsx("span",{children:N.item.status}),N.item.connection_name&&d.jsx("span",{children:N.item.connection_name}),N.item.provider&&d.jsx("span",{children:N.item.provider})]})]})]}),f===N.item.id&&d.jsxs("div",{className:"schedule-item-expanded",children:[d.jsx("div",{className:"schedule-item-full-text",children:((D=N.item.content)==null?void 0:D.text)||JSON.stringify(N.item.content,null,2)}),d.jsx("div",{className:"schedule-item-actions",children:d.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>b(N.item.id),children:"Cancel"})})]})]},N.item.id)})]},w))]})}function u5(t,e){const n=new Date,r=[];for(let l=0;l<7;l++){const u=new Date(n);u.setDate(u.getDate()+l),u.setHours(0,0,0,0);let f;l===0?f="Today":l===1?f="Tomorrow":f=u.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),r.push({label:f,date:u})}const s=new Map;for(const l of e){const u=new Date(l.scheduled_at),f=`${u.getFullYear()}-${u.getMonth()}-${u.getDate()}-${u.getHours()}-${u.getMinutes()}`;s.set(f,l)}const i=new Set,o=[];for(const{label:l,date:u}of r){const f=[],p=u.getDay(),g=["sun","mon","tue","wed","thu","fri","sat"][p];for(const y of t){if(!(y.days.includes("default")||y.days.includes(g)))continue;const[k,w]=y.time.split(":").map(Number),E=new Date(u);if(E.setHours(k,w,0,0),q1(u,n)&&E<n)continue;const N=`${E.getFullYear()}-${E.getMonth()}-${E.getDate()}-${k}-${w}`,O=s.get(N);O?(f.push({type:"filled",time:E,item:O,slot:y}),i.add(O.id)):f.push({type:"empty",time:E,slot:y})}for(const y of e){if(i.has(y.id))continue;const b=new Date(y.scheduled_at);q1(b,u)&&(f.push({type:"filled",time:b,item:y}),i.add(y.id))}f.sort((y,b)=>y.time.getTime()-b.time.getTime()),f.length>0&&o.push({label:l,entries:f})}return o}function q1(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function V1(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function d5({onBack:t}){const[e,n]=S.useState([]),[r,s]=S.useState(""),[i,o]=S.useState(null),[l,u]=S.useState(!1),f=S.useRef(null),p=S.useCallback(async()=>{try{const w=await fetch("/api/tasks");if(w.ok){const E=await w.json();n(E.tasks||[])}}catch{}},[]);S.useEffect(()=>{p()},[p]);const m=async()=>{const w=r.trim();if(w){s("");try{const E=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:w})});if(E.ok){const N=await E.json();n(O=>[...O,N.task])}}catch{}}},g=w=>{o(w),fetch(`/api/tasks/${w}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({completed:!0})}).catch(()=>{}),setTimeout(()=>{n(E=>E.filter(N=>N.id!==w)),o(null)},400)},y=async w=>{try{(await fetch(`/api/tasks/${w}`,{method:"DELETE"})).ok&&n(N=>N.filter(O=>O.id!==w))}catch{}},b=()=>{u(!0),setTimeout(()=>{var w;return(w=f.current)==null?void 0:w.focus()},0)},k=e.filter(w=>!w.completed);return d.jsxs("div",{className:"sidebar-tasks",children:[d.jsxs("div",{className:"sidebar-tasks-header",children:[d.jsx("button",{className:"sidebar-tasks-back",onClick:t,title:"Back to documents",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}),d.jsx("h3",{children:"Tasks"}),d.jsx("button",{className:"sidebar-tasks-add-btn",onClick:b,title:"Add task",children:"+"})]}),k.length===0&&!l?d.jsxs("div",{className:"sidebar-tasks-empty",children:[d.jsx("div",{className:"sidebar-tasks-empty-title",children:"No tasks"}),d.jsx("div",{className:"sidebar-tasks-empty-desc",children:"Add tasks to track your checklist."})]}):d.jsx("div",{className:"sidebar-tasks-list",children:k.map(w=>d.jsxs("div",{className:`sidebar-tasks-item${i===w.id?" completing":""}`,children:[d.jsx("input",{type:"checkbox",className:"sidebar-tasks-checkbox",checked:i===w.id,onChange:()=>g(w.id)}),d.jsx("span",{className:`sidebar-tasks-text${i===w.id?" completed":""}`,children:w.text}),d.jsx("button",{className:"sidebar-tasks-delete",onClick:()=>y(w.id),title:"Remove",children:"×"})]},w.id))}),l&&d.jsx("div",{className:"sidebar-tasks-add",children:d.jsx("input",{ref:f,type:"text",placeholder:"New task...",value:r,onChange:w=>s(w.target.value),onKeyDown:w=>{w.key==="Enter"&&m(),w.key==="Escape"&&(u(!1),s(""))},onBlur:()=>{r.trim()||u(!1)}})})]})}function f5({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:o}){const[l,u]=S.useState(!1),[f,p]=S.useState(!1),[m,g]=S.useState(""),[y,b]=S.useState(null),k=S.useRef(null),w=S.useRef(null);S.useEffect(()=>{if(!l)return;const N=O=>{k.current&&!k.current.contains(O.target)&&(u(!1),p(!1),g(""),b(null))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]),S.useEffect(()=>{f&&w.current&&w.current.focus()},[f]);const E=()=>{const N=m.trim();N&&(s(N),g(""),p(!1))};return d.jsxs("div",{className:"sidebar-profile-wrapper",ref:k,children:[d.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>u(!l),title:`Profile: ${e}`,children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"8",r:"4"}),d.jsx("path",{d:"M5.5 21a8.38 8.38 0 0 1 13 0"})]})}),l&&d.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(N=>d.jsxs("div",{className:"sidebar-profile-row",children:[y===N?d.jsxs("div",{className:"sidebar-profile-confirm",children:[d.jsx("span",{children:"Delete?"}),d.jsxs("div",{className:"sidebar-inline-confirm",children:[d.jsx("button",{onClick:()=>{i(N),b(null)},children:"Yes"}),d.jsx("button",{onClick:()=>b(null),children:"No"})]})]}):d.jsx(d.Fragment,{children:d.jsxs("button",{className:`sidebar-profile-option ${N===e?"active":""}`,onClick:()=>{N!==e&&r(N),u(!1)},children:[d.jsx("span",{className:"sidebar-profile-check",children:N===e?"✓":""}),d.jsx("span",{children:N})]})}),N!=="Default"&&N!==e&&y!==N&&d.jsx("button",{className:"sidebar-profile-delete-btn",onClick:O=>{O.stopPropagation(),b(N)},title:"Delete profile",children:"×"})]},N)),n.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sidebar-profile-divider"}),d.jsx("div",{className:"sidebar-profile-trash-label",children:"Trash"}),n.map(N=>d.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[d.jsx("span",{className:"sidebar-profile-trash-name",children:N}),d.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>o(N),children:"Restore"})]},N))]}),d.jsx("div",{className:"sidebar-profile-divider"}),f?d.jsx("div",{className:"sidebar-profile-add-input",children:d.jsx("input",{ref:w,type:"text",value:m,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&E(),N.key==="Escape"&&(p(!1),g(""))},placeholder:"Profile name..."})}):d.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>p(!0),children:[d.jsx("span",{className:"sidebar-profile-check",children:"+"}),d.jsx("span",{children:"New Profile"})]})]})]})}function K1({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,workspacesRefreshKey:s,pendingDocs:i,writingTitle:o,writingTarget:l,onClose:u}){const{docs:f,workspaces:p,assignedFiles:m,fetchDocs:g,scrollRef:y}=PB(r,s),b=BB(p,g,r),k=ud(),[w,E]=S.useState(!1),[N,O]=S.useState(!1),[T,C]=S.useState([]),[R,L]=S.useState("Default"),D=S.useCallback(async()=>{try{const G=await fetch("/api/profiles");if(G.ok){const le=await G.json();C(le.profiles),L(le.active)}}catch{}},[]);S.useEffect(()=>{D()},[D]);const z=S.useCallback(async G=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G})})).ok&&(L(G),D())}catch{}},[D]),F=S.useCallback(async G=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G})})).ok&&D()}catch{}},[D]),[J,K]=S.useState([]),X=S.useCallback(async()=>{try{const G=await fetch("/api/profiles/trash");if(G.ok){const le=await G.json();K(le.profiles)}}catch{}},[]);S.useEffect(()=>{X()},[X]);const W=S.useCallback(async G=>{try{(await fetch(`/api/profiles/${encodeURIComponent(G)}`,{method:"DELETE"})).ok&&(D(),X())}catch{}},[D,X]),$=S.useCallback(async G=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G})})).ok&&(D(),X())}catch{}},[D,X]),[U,Z]=S.useState(""),[V,Y]=S.useState(null),I=S.useRef(),A=S.useRef(null),j=S.useCallback(G=>{if(Z(G),I.current&&clearTimeout(I.current),!G.trim()){Y(null);return}I.current=setTimeout(async()=>{try{const le=await fetch(`/api/documents/search?q=${encodeURIComponent(G.trim())}&archived=true`);le.ok&&Y(await le.json())}catch{}},250)},[]);S.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]);const Q={docs:f,archivedDocs:[],workspaces:p,assignedFiles:m,pendingDocs:i,writingTitle:o,writingTarget:l,onSwitchDocument:e,onCreateDocument:n,actions:b,scrollRef:y,searchQuery:U,searchResults:V,onSearchChange:j},oe=()=>{switch(k){case"timeline":return d.jsx(JB,{...Q});case"board":return d.jsx(YB,{...Q});case"shelf":return d.jsx(QB,{...Q});default:return d.jsx(GB,{...Q})}},fe=d.jsxs("div",{className:"sidebar-search",children:[d.jsxs("svg",{className:"sidebar-search-icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"10.5",cy:"10.5",r:"7"}),d.jsx("path",{d:"m20 20-4.5-4.5"})]}),d.jsx("input",{ref:A,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:U,onChange:G=>j(G.target.value)}),U&&d.jsx("button",{className:"sidebar-search-clear",onClick:()=>j(""),title:"Clear search",children:"×"})]});return k==="board"?d.jsx("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,children:oe()}):d.jsxs("div",{className:`sidebar ${t?"open":""}`,children:[d.jsxs("div",{className:"sidebar-topbar",children:[d.jsxs("div",{className:"sidebar-logo",children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M17 3a2.83 2.83 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),d.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),d.jsxs("div",{className:"sidebar-topbar-actions",children:[d.jsx(f5,{profiles:T,activeProfile:R,trashedProfiles:J,onSwitch:z,onCreate:F,onDelete:W,onRestore:$}),d.jsx("button",{className:`sidebar-collapse-btn${w?" sidebar-collapse-btn--active":""}`,onClick:()=>{E(!w),O(!1)},title:"Schedule",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("line",{x1:"16",x2:"16",y1:"1",y2:"5"}),d.jsx("line",{x1:"8",x2:"8",y1:"1",y2:"5"}),d.jsx("line",{x1:"3",x2:"21",y1:"9",y2:"9"})]})}),d.jsx("button",{className:`sidebar-collapse-btn${N?" sidebar-collapse-btn--active":""}`,onClick:()=>{O(!N),E(!1)},title:"Tasks",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("path",{d:"m9 12 2 2 4-4"})]})}),u&&d.jsx("button",{className:"sidebar-collapse-btn",onClick:u,title:"Close sidebar",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),N?d.jsx(d5,{onBack:()=>O(!1)}):w?d.jsx(c5,{onBack:()=>E(!1)}):d.jsxs(d.Fragment,{children:[fe,oe()]})]})}function h5({onClose:t,onSetupComplete:e}){const[n,r]=S.useState("detecting"),[s,i]=S.useState(null),[o,l]=S.useState("gh"),[u,f]=S.useState("openwriter-docs"),[p,m]=S.useState(!0),[g,y]=S.useState(""),[b,k]=S.useState(""),[w,E]=S.useState(""),[N,O]=S.useState("");S.useEffect(()=>{fetch("/api/sync/capabilities").then(C=>C.json()).then(C=>{i(C),C.ghAuthenticated?l("gh"):(C.gitInstalled,l("pat")),r("setup")}).catch(()=>{E("Failed to detect git capabilities"),r("error")})},[]);const T=S.useCallback(async()=>{r("progress"),O(o==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const C={method:o,repoName:u,isPrivate:p};o==="pat"&&(C.pat=g),o==="connect"&&(C.remoteUrl=b,C.pat=g||void 0);const R=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)});if(!R.ok){const L=await R.json().catch(()=>({}));throw new Error(L.error||`Setup failed (${R.status})`)}r("done"),e()}catch(C){E(C.message),r("error")}},[o,u,p,g,b,e]);return d.jsx("div",{className:"sync-modal-overlay",onClick:t,children:d.jsxs("div",{className:"sync-modal",onClick:C=>C.stopPropagation(),children:[d.jsxs("div",{className:"sync-modal-header",children:[d.jsx("h2",{children:"Sync to GitHub"}),d.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-spinner"}),d.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&s&&d.jsxs("div",{className:"sync-modal-body",children:[!s.gitInstalled&&d.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",d.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),s.gitInstalled&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"sync-tabs",children:[s.ghAuthenticated&&d.jsx("button",{className:`sync-tab${o==="gh"?" active":""}`,onClick:()=>l("gh"),children:"GitHub CLI"}),d.jsx("button",{className:`sync-tab${o==="pat"?" active":""}`,onClick:()=>l("pat"),children:"Personal Access Token"}),d.jsx("button",{className:`sync-tab${o==="connect"?" active":""}`,onClick:()=>l("connect"),children:"Connect Existing"})]}),o==="gh"&&d.jsxs("div",{className:"sync-form",children:[d.jsxs("label",{children:["Repository name",d.jsx("input",{type:"text",value:u,onChange:C=>f(C.target.value),placeholder:"openwriter-docs"})]}),d.jsxs("label",{className:"sync-checkbox",children:[d.jsx("input",{type:"checkbox",checked:p,onChange:C=>m(C.target.checked)}),"Private repository"]})]}),o==="pat"&&d.jsxs("div",{className:"sync-form",children:[!s.ghAuthenticated&&!s.ghInstalled&&d.jsxs("p",{className:"sync-hint",children:["Create a ",d.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",d.jsx("code",{children:"repo"})," scope."]}),d.jsxs("label",{children:["Personal Access Token",d.jsx("input",{type:"password",value:g,onChange:C=>y(C.target.value),placeholder:"ghp_..."})]}),d.jsxs("label",{children:["Repository name",d.jsx("input",{type:"text",value:u,onChange:C=>f(C.target.value),placeholder:"openwriter-docs"})]}),d.jsxs("label",{className:"sync-checkbox",children:[d.jsx("input",{type:"checkbox",checked:p,onChange:C=>m(C.target.checked)}),"Private repository"]})]}),o==="connect"&&d.jsxs("div",{className:"sync-form",children:[d.jsxs("label",{children:["Remote URL",d.jsx("input",{type:"text",value:b,onChange:C=>k(C.target.value),placeholder:"https://github.com/user/repo.git"})]}),d.jsxs("label",{children:["PAT (optional, for private repos)",d.jsx("input",{type:"password",value:g,onChange:C=>y(C.target.value),placeholder:"ghp_..."})]})]}),d.jsxs("div",{className:"sync-modal-actions",children:[d.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),d.jsx("button",{className:"sync-btn primary",onClick:T,disabled:o==="pat"&&!g||o==="connect"&&!b||o!=="connect"&&!u,children:o==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-spinner"}),d.jsx("p",{children:N})]}),n==="done"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-success-icon",children:"✓"}),d.jsx("p",{children:"Successfully synced to GitHub!"}),d.jsx("div",{className:"sync-modal-actions",children:d.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-error-msg",children:w}),d.jsxs("div",{className:"sync-modal-actions",children:[d.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),d.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function p5({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentsChanged:r,onWorkspacesChanged:s,onTitleChanged:i,onPendingDocsChanged:o,onMetadataChanged:l,onSyncStatus:u,onWritingStarted:f,onWritingFinished:p,getEditorState:m}){const g=S.useRef(null),[y,b]=S.useState(!1),k=S.useRef(t),w=S.useRef(e),E=S.useRef(n),N=S.useRef(r),O=S.useRef(s),T=S.useRef(i),C=S.useRef(o),R=S.useRef(u),L=S.useRef(l),D=S.useRef(f),z=S.useRef(p),F=S.useRef(m);k.current=t,w.current=e,E.current=n,N.current=r,O.current=s,T.current=i,C.current=o,L.current=l,R.current=u,D.current=f,z.current=p,F.current=m,S.useEffect(()=>{const X=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let W,$=!1,U=1e3;function Z(){const Y=new WebSocket(X);g.current=Y,Y.onopen=()=>{b(!0),U=1e3,$&&Y.send(JSON.stringify({type:"request-document"})),$=!0},Y.onmessage=I=>{var A,j,Q,oe,fe,G,le,Te,Ve,ce,ue;try{const ae=JSON.parse(I.data);ae.type==="node-changes"&&ae.changes&&((A=k.current)==null||A.call(k,ae.changes)),ae.type==="agent-status"&&((j=w.current)==null||j.call(w,!!ae.agentConnected)),ae.type==="document-switched"&&((Q=E.current)==null||Q.call(E,{document:ae.document,title:ae.title,filename:ae.filename,docId:ae.docId,metadata:ae.metadata})),ae.type==="metadata-changed"&&ae.metadata&&((oe=L.current)==null||oe.call(L,ae.metadata)),ae.type==="documents-changed"&&((fe=N.current)==null||fe.call(N)),ae.type==="workspaces-changed"&&((G=O.current)==null||G.call(O)),ae.type==="title-changed"&&ae.title&&((le=T.current)==null||le.call(T,ae.title)),ae.type==="pending-docs-changed"&&ae.pendingDocs&&((Te=C.current)==null||Te.call(C,ae.pendingDocs)),ae.type==="sync-status"&&((Ve=R.current)==null||Ve.call(R,{state:ae.state,lastSyncTime:ae.lastSyncTime,pendingFiles:ae.pendingFiles,error:ae.error})),ae.type==="writing-started"&&ae.title&&((ce=D.current)==null||ce.call(D,ae.title,ae.target||null)),ae.type==="writing-finished"&&((ue=z.current)==null||ue.call(z)),ae.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),ae.type==="marks-changed"&&ae.filename&&window.dispatchEvent(new CustomEvent("ow-marks-changed",{detail:{filename:ae.filename}}))}catch{}},Y.onclose=()=>{b(!1),W=setTimeout(Z,U),U=Math.min(U*1.5,8e3)},Y.onerror=()=>{Y.close()}}Z();function V(){var Y;document.visibilityState==="visible"&&((Y=g.current)==null?void 0:Y.readyState)!==WebSocket.OPEN&&(clearTimeout(W),U=1e3,Z())}return document.addEventListener("visibilitychange",V),()=>{var Y;clearTimeout(W),document.removeEventListener("visibilitychange",V),(Y=g.current)==null||Y.close()}},[]);const J=S.useCallback(K=>{var X;((X=g.current)==null?void 0:X.readyState)===WebSocket.OPEN&&g.current.send(JSON.stringify(K))},[]);return{connected:y,sendMessage:J}}function m5(t){const[e,n]=S.useState(null),[r,s]=S.useState(!1),[i,o]=S.useState(null),l=S.useRef(void 0);return S.useEffect(()=>{if(!t){n(null),s(!1),o(null),l.current=void 0;return}t!==l.current&&(l.current=t,s(!0),o(null),fetch(`/api/tweet-embed?url=${encodeURIComponent(t)}`).then(u=>u.ok?u.json():u.json().then(f=>Promise.reject(new Error(f.error||`HTTP ${u.status}`)))).then(u=>{n(u),s(!1)}).catch(u=>{o(u.message),s(!1)}))},[t]),{tweet:e,loading:r,error:i}}function g5(t){var r;const e=t.view.dom,n=[];for(const s of e.children){const i=(r=s.innerText)==null?void 0:r.trim();i&&n.push(i)}return n.join(`
206
+
207
+ `)}function v5(t){const e=n=>{var r;if(n.type==="image"&&((r=n.attrs)!=null&&r.src))return n.attrs.src;if(n.content)for(const s of n.content){const i=e(s);if(i)return i}return null};return e(t.getJSON())}async function y5(t){try{const e=await fetch(t);if(!e.ok)return null;const n=await e.blob();return n.type==="image/png"?n:new Promise(r=>{const s=new Image,i=URL.createObjectURL(n);s.onload=()=>{const o=document.createElement("canvas");o.width=s.naturalWidth,o.height=s.naturalHeight,o.getContext("2d").drawImage(s,0,0),o.toBlob(l=>{URL.revokeObjectURL(i),r(l)},"image/png")},s.onerror=()=>{URL.revokeObjectURL(i),r(null)},s.src=i})}catch{return null}}function b5(t,e){const[n,r]=S.useState("idle"),s=S.useRef();return{copyText:S.useCallback(async()=>{const o=t.current[e];if(!o)return;const l=g5(o),u=v5(o);if(!(!l&&!u)){try{const f={};if(l&&(f["text/plain"]=new Blob([l],{type:"text/plain"})),u){const p=await y5(u);p&&(f["image/png"]=p)}Object.keys(f).length>0&&await navigator.clipboard.write([new ClipboardItem(f)])}catch{if(l){const f=document.createElement("textarea");f.value=l,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select(),document.execCommand("copy"),document.body.removeChild(f)}}r("copied"),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r("idle"),2e3)}},[t,e]),copyState:n}}function fp(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e4?`${(t/1e3).toFixed(0)}K`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function x5(t){try{const e=Date.now(),n=new Date(t).getTime(),r=Math.floor((e-n)/1e3);if(r<60)return`${r}s`;const s=Math.floor(r/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return""}}const w5=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z"})}),k5=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M4.5 3.88l4.432 4.14-1.364 1.46L5.5 7.55V16c0 1.1.896 2 2 2H13v2H7.5c-2.209 0-4-1.79-4-4V7.55L1.432 9.48.068 8.02 4.5 3.88zM16.5 6H11V4h5.5c2.209 0 4 1.79 4 4v8.45l2.068-1.93 1.364 1.46-4.432 4.14-4.432-4.14 1.364-1.46 2.068 1.93V8c0-1.1-.896-2-2-2z"})}),S5=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M16.697 5.5c-1.222-.06-2.679.51-3.89 2.16l-.805 1.09-.806-1.09C9.984 6.01 8.526 5.44 7.304 5.5c-1.243.07-2.349.78-2.91 1.91-.552 1.12-.633 2.78.479 4.82 1.074 1.97 3.257 4.27 7.129 6.61 3.87-2.34 6.052-4.64 7.126-6.61 1.111-2.04 1.03-3.7.477-4.82-.561-1.13-1.666-1.84-2.908-1.91zm4.187 7.69c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z"})}),E5=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M4 4.5C4 3.12 5.119 2 6.5 2h11C18.881 2 20 3.12 20 4.5v18.44l-8-5.71-8 5.71V4.5zM6.5 4c-.276 0-.5.22-.5.5v14.56l6-4.29 6 4.29V4.5c0-.28-.224-.5-.5-.5h-11z"})}),_5=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M12 2.59l5.7 5.7-1.41 1.42L13 6.41V16h-2V6.41l-3.3 3.3-1.41-1.42L12 2.59zM21 15l-.02 3.51c0 1.38-1.12 2.49-2.5 2.49H5.5C4.11 21 3 19.88 3 18.5V15h2v3.5c0 .28.22.5.5.5h12.98c.28 0 .5-.22.5-.5L19 15h2z"})});function jC({tweet:t,nested:e,url:n}){const r=x5(t.createdAt);return d.jsxs("div",{className:`tweet-embed-card${e?" tweet-embed-nested":""}${n?" tweet-embed-card--clickable":""}`,onClick:n?()=>window.open(n,"_blank","noopener,noreferrer"):void 0,role:n?"link":void 0,children:[d.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?d.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):d.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),d.jsxs("div",{className:"tweet-author-info",children:[d.jsx("span",{className:"tweet-author-name",children:t.author.name}),d.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),r&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"tweet-author-separator",children:"·"}),d.jsx("span",{className:"tweet-author-timestamp",children:r})]})]})]}),d.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&d.jsx("div",{className:"tweet-media",children:t.media.map((s,i)=>s.type==="photo"?d.jsx("img",{className:"tweet-media-img",src:s.url,alt:"",loading:"lazy"},i):s.type==="video"||s.type==="gif"?d.jsx("div",{className:"tweet-media-video-placeholder",children:d.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&d.jsx(jC,{tweet:t.quoteTweet,nested:!0}),!e&&d.jsxs("div",{className:"tweet-actions-row",children:[d.jsxs("span",{className:"tweet-action tweet-action-reply",children:[d.jsx(w5,{}),t.metrics.replies>0&&fp(t.metrics.replies)]}),d.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[d.jsx(k5,{}),t.metrics.retweets>0&&fp(t.metrics.retweets)]}),d.jsxs("span",{className:"tweet-action tweet-action-like",children:[d.jsx(S5,{}),t.metrics.likes>0&&fp(t.metrics.likes)]}),d.jsx("span",{className:"tweet-action tweet-action-bookmark",children:d.jsx(E5,{})}),d.jsx("span",{className:"tweet-action tweet-action-share",children:d.jsx(_5,{})})]})]})}function N5({tweet:t,url:e}){return d.jsx(jC,{tweet:t,url:e})}function C5({initialContent:t,placeholder:e="What is happening?!",onUpdate:n,onReady:r,onFocus:s}){const i=S.useRef(r);i.current=r;const o=Z_({extensions:[...fC,_d.configure({placeholder:e})],content:t||"<p></p>",onUpdate:({editor:l})=>{n==null||n(l)},onFocus:()=>{s==null||s()},editorProps:{handlePaste:xC,handleDrop:wC}},[t]);return S.useEffect(()=>{if(!o)return;const{state:l}=o.view;if(l.plugins.some(p=>p.key==="pendingDecoration$"))return;const u=vC(),f=l.reconfigure({plugins:[...l.plugins,u]});o.view.updateState(f)},[o]),S.useEffect(()=>{if(!o)return;const{state:l}=o.view;if(l.plugins.some(p=>p.key==="markDecoration$"))return;const u=yC(),f=l.reconfigure({plugins:[...l.plugins,u]});o.view.updateState(f)},[o]),S.useEffect(()=>{var l;o&&((l=i.current)==null||l.call(i,o))},[o]),o?d.jsx(s0,{editor:o}):null}function T5({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),s=n<=20,i=s?30:26,o=2,l=(i-o)/2,u=2*Math.PI*l,f=u*(1-r);let p="var(--x-blue, #1d9bf0)";return n<=0?p="var(--x-red, #f4212e)":n<=20&&(p="var(--x-yellow, #ffd400)"),t===0?null:d.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:i,height:i},children:[d.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[d.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:o}),d.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:p,strokeWidth:o,strokeDasharray:u,strokeDashoffset:f,strokeLinecap:"round",transform:`rotate(-90 ${i/2} ${i/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),s&&d.jsx("span",{className:"tweet-char-number",style:{color:p,fontSize:n<-9||n>9?10:11},children:n})]})}const G1="@openwriter/plugin-x-api",J1=[{key:"api-key",label:"API Key",env:"X_API_KEY"},{key:"api-secret",label:"API Secret",env:"X_API_SECRET"},{key:"access-token",label:"Access Token",env:"X_ACCESS_TOKEN"},{key:"access-token-secret",label:"Access Token Secret",env:"X_ACCESS_TOKEN_SECRET"}];function M5({onConnected:t,onCancel:e}){const[n,r]=S.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=S.useState(!1),[o,l]=S.useState(""),u=J1.every(p=>n[p.key].trim()),f=async()=>{i(!0),l("");try{if(!(await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G1,config:n})})).ok)throw new Error("Failed to save config");const g=await(await fetch("/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G1})})).json();if(!g.success)throw new Error(g.error||"Failed to enable plugin");const b=await(await fetch("/api/x/status")).json();b.connected?t():l(b.error||"Could not verify X credentials. Check your API keys.")}catch(p){l(p.message||"Connection failed")}finally{i(!1)}};return d.jsxs("div",{className:"x-connect-prompt",children:[d.jsxs("div",{className:"x-connect-header",children:[d.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),d.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:d.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:d.jsx("path",{fill:"currentColor",d:"M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"})})})]}),d.jsx("div",{className:"x-connect-fields",children:J1.map(p=>d.jsxs("div",{className:"x-connect-field",children:[d.jsx("label",{className:"x-connect-label",children:p.label}),d.jsx("input",{type:"password",className:"x-connect-input",value:n[p.key],onChange:m=>r(g=>({...g,[p.key]:m.target.value})),placeholder:p.env,spellCheck:!1,autoComplete:"off"})]},p.key))}),o&&d.jsx("div",{className:"x-connect-error",children:o}),d.jsxs("div",{className:"x-connect-actions",children:[d.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),d.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!u||s,children:s?"Connecting...":"Connect"})]})]})}var Y1={},hp,Q1;function ks(){return Q1||(Q1=1,hp=function(t){return typeof t=="object"?t!==null:typeof t=="function"}),hp}var pp,X1;function cr(){if(X1)return pp;X1=1;var t=ks();return pp=function(e){if(!t(e))throw TypeError(e+" is not an object!");return e},pp}var mp,Z1;function Md(){return Z1||(Z1=1,mp=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}),mp}var gp,ew;function fi(){if(ew)return gp;ew=1;var t=Md();return gp=function(e){return Object(t(e))},gp}var vp,tw;function Ad(){if(tw)return vp;tw=1;var t=Math.ceil,e=Math.floor;return vp=function(n){return isNaN(n=+n)?0:(n>0?e:t)(n)},vp}var yp,nw;function Zi(){if(nw)return yp;nw=1;var t=Ad(),e=Math.min;return yp=function(n){return n>0?e(t(n),9007199254740991):0},yp}var bp,rw;function IC(){if(rw)return bp;rw=1;var t=Ad(),e=Md();return bp=function(n){return function(r,s){var i=String(e(r)),o=t(s),l=i.length,u,f;return o<0||o>=l?n?"":void 0:(u=i.charCodeAt(o),u<55296||u>56319||o+1===l||(f=i.charCodeAt(o+1))<56320||f>57343?n?i.charAt(o):u:n?i.slice(o,o+2):(u-55296<<10)+(f-56320)+65536)}},bp}var xp,sw;function j0(){if(sw)return xp;sw=1;var t=IC()(!0);return xp=function(e,n,r){return n+(r?t(e,n).length:1)},xp}var wp,iw;function Od(){if(iw)return wp;iw=1;var t={}.toString;return wp=function(e){return t.call(e).slice(8,-1)},wp}var kp={exports:{}},Sp={exports:{}},Ep={exports:{}},ow;function Jo(){if(ow)return Ep.exports;ow=1;var t=Ep.exports={version:"2.6.12"};return typeof __e=="number"&&(__e=t),Ep.exports}var _p={exports:{}},aw;function Sr(){if(aw)return _p.exports;aw=1;var t=_p.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();return typeof __g=="number"&&(__g=t),_p.exports}var Np,lw;function Rd(){return lw||(lw=1,Np=!1),Np}var cw;function jd(){if(cw)return Sp.exports;cw=1;var t=Jo(),e=Sr(),n="__core-js_shared__",r=e[n]||(e[n]={});return(Sp.exports=function(s,i){return r[s]||(r[s]=i!==void 0?i:{})})("versions",[]).push({version:t.version,mode:Rd()?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"}),Sp.exports}var Cp,uw;function yl(){if(uw)return Cp;uw=1;var t=0,e=Math.random();return Cp=function(n){return"Symbol(".concat(n===void 0?"":n,")_",(++t+e).toString(36))},Cp}var dw;function bn(){if(dw)return kp.exports;dw=1;var t=jd()("wks"),e=yl(),n=Sr().Symbol,r=typeof n=="function",s=kp.exports=function(i){return t[i]||(t[i]=r&&n[i]||(r?n:e)("Symbol."+i))};return s.store=t,kp.exports}var Tp,fw;function I0(){if(fw)return Tp;fw=1;var t=Od(),e=bn()("toStringTag"),n=t((function(){return arguments})())=="Arguments",r=function(s,i){try{return s[i]}catch{}};return Tp=function(s){var i,o,l;return s===void 0?"Undefined":s===null?"Null":typeof(o=r(i=Object(s),e))=="string"?o:n?t(i):(l=t(i))=="Object"&&typeof i.callee=="function"?"Arguments":l},Tp}var Mp,hw;function L0(){if(hw)return Mp;hw=1;var t=I0(),e=RegExp.prototype.exec;return Mp=function(n,r){var s=n.exec;if(typeof s=="function"){var i=s.call(n,r);if(typeof i!="object")throw new TypeError("RegExp exec method returned something other than an Object or null");return i}if(t(n)!=="RegExp")throw new TypeError("RegExp#exec called on incompatible receiver");return e.call(n,r)},Mp}var pw={},Ap,mw;function Id(){if(mw)return Ap;mw=1;var t=cr();return Ap=function(){var e=t(this),n="";return e.global&&(n+="g"),e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),e.sticky&&(n+="y"),n},Ap}var Op,gw;function D0(){if(gw)return Op;gw=1;var t=Id(),e=RegExp.prototype.exec,n=String.prototype.replace,r=e,s="lastIndex",i=(function(){var u=/a/,f=/b*/g;return e.call(u,"a"),e.call(f,"a"),u[s]!==0||f[s]!==0})(),o=/()??/.exec("")[1]!==void 0,l=i||o;return l&&(r=function(f){var p=this,m,g,y,b;return o&&(g=new RegExp("^"+p.source+"$(?!\\s)",t.call(p))),i&&(m=p[s]),y=e.call(p,f),i&&y&&(p[s]=p.global?y.index+y[0].length:m),o&&y&&y.length>1&&n.call(y[0],g,function(){for(b=1;b<arguments.length-2;b++)arguments[b]===void 0&&(y[b]=void 0)}),y}),Op=r,Op}var Rp={},jp,vw;function Br(){return vw||(vw=1,jp=function(t){try{return!!t()}catch{return!0}}),jp}var Ip,yw;function Er(){return yw||(yw=1,Ip=!Br()(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})),Ip}var Lp,bw;function LC(){if(bw)return Lp;bw=1;var t=ks(),e=Sr().document,n=t(e)&&t(e.createElement);return Lp=function(r){return n?e.createElement(r):{}},Lp}var Dp,xw;function DC(){return xw||(xw=1,Dp=!Er()&&!Br()(function(){return Object.defineProperty(LC()("div"),"a",{get:function(){return 7}}).a!=7})),Dp}var Pp,ww;function P0(){if(ww)return Pp;ww=1;var t=ks();return Pp=function(e,n){if(!t(e))return e;var r,s;if(n&&typeof(r=e.toString)=="function"&&!t(s=r.call(e))||typeof(r=e.valueOf)=="function"&&!t(s=r.call(e))||!n&&typeof(r=e.toString)=="function"&&!t(s=r.call(e)))return s;throw TypeError("Can't convert object to primitive value")},Pp}var kw;function zr(){if(kw)return Rp;kw=1;var t=cr(),e=DC(),n=P0(),r=Object.defineProperty;return Rp.f=Er()?Object.defineProperty:function(i,o,l){if(t(i),o=n(o,!0),t(l),e)try{return r(i,o,l)}catch{}if("get"in l||"set"in l)throw TypeError("Accessors not supported!");return"value"in l&&(i[o]=l.value),i},Rp}var Bp,Sw;function bl(){return Sw||(Sw=1,Bp=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}),Bp}var zp,Ew;function hi(){if(Ew)return zp;Ew=1;var t=zr(),e=bl();return zp=Er()?function(n,r,s){return t.f(n,r,e(1,s))}:function(n,r,s){return n[r]=s,n},zp}var Fp={exports:{}},$p,_w;function eo(){if(_w)return $p;_w=1;var t={}.hasOwnProperty;return $p=function(e,n){return t.call(e,n)},$p}var Up,Nw;function A5(){return Nw||(Nw=1,Up=jd()("native-function-to-string",Function.toString)),Up}var Cw;function Ss(){if(Cw)return Fp.exports;Cw=1;var t=Sr(),e=hi(),n=eo(),r=yl()("src"),s=A5(),i="toString",o=(""+s).split(i);return Jo().inspectSource=function(l){return s.call(l)},(Fp.exports=function(l,u,f,p){var m=typeof f=="function";m&&(n(f,"name")||e(f,"name",u)),l[u]!==f&&(m&&(n(f,r)||e(f,r,l[u]?""+l[u]:o.join(String(u)))),l===t?l[u]=f:p?l[u]?l[u]=f:e(l,u,f):(delete l[u],e(l,u,f)))})(Function.prototype,i,function(){return typeof this=="function"&&this[r]||s.call(this)}),Fp.exports}var Hp,Tw;function Ld(){return Tw||(Tw=1,Hp=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}),Hp}var Wp,Mw;function Dd(){if(Mw)return Wp;Mw=1;var t=Ld();return Wp=function(e,n,r){if(t(e),n===void 0)return e;switch(r){case 1:return function(s){return e.call(n,s)};case 2:return function(s,i){return e.call(n,s,i)};case 3:return function(s,i,o){return e.call(n,s,i,o)}}return function(){return e.apply(n,arguments)}},Wp}var qp,Aw;function tr(){if(Aw)return qp;Aw=1;var t=Sr(),e=Jo(),n=hi(),r=Ss(),s=Dd(),i="prototype",o=function(l,u,f){var p=l&o.F,m=l&o.G,g=l&o.S,y=l&o.P,b=l&o.B,k=m?t:g?t[u]||(t[u]={}):(t[u]||{})[i],w=m?e:e[u]||(e[u]={}),E=w[i]||(w[i]={}),N,O,T,C;m&&(f=u);for(N in f)O=!p&&k&&k[N]!==void 0,T=(O?k:f)[N],C=b&&O?s(T,t):y&&typeof T=="function"?s(Function.call,T):T,k&&r(k,N,T,l&o.U),w[N]!=T&&n(w,N,C),y&&E[N]!=T&&(E[N]=T)};return t.core=e,o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,o.U=64,o.R=128,qp=o,qp}var Ow;function O5(){if(Ow)return pw;Ow=1;var t=D0();return tr()({target:"RegExp",proto:!0,forced:t!==/./.exec},{exec:t}),pw}var Vp,Rw;function B0(){if(Rw)return Vp;Rw=1,O5();var t=Ss(),e=hi(),n=Br(),r=Md(),s=bn(),i=D0(),o=s("species"),l=!n(function(){var f=/./;return f.exec=function(){var p=[];return p.groups={a:"7"},p},"".replace(f,"$<a>")!=="7"}),u=(function(){var f=/(?:)/,p=f.exec;f.exec=function(){return p.apply(this,arguments)};var m="ab".split(f);return m.length===2&&m[0]==="a"&&m[1]==="b"})();return Vp=function(f,p,m){var g=s(f),y=!n(function(){var O={};return O[g]=function(){return 7},""[f](O)!=7}),b=y?!n(function(){var O=!1,T=/a/;return T.exec=function(){return O=!0,null},f==="split"&&(T.constructor={},T.constructor[o]=function(){return T}),T[g](""),!O}):void 0;if(!y||!b||f==="replace"&&!l||f==="split"&&!u){var k=/./[g],w=m(r,g,""[f],function(T,C,R,L,D){return C.exec===i?y&&!D?{done:!0,value:k.call(C,R,L)}:{done:!0,value:T.call(R,C,L)}:{done:!1}}),E=w[0],N=w[1];t(String.prototype,f,E),e(RegExp.prototype,g,p==2?function(O,T){return N.call(O,this,T)}:function(O){return N.call(O,this)})}},Vp}var jw;function R5(){if(jw)return Y1;jw=1;var t=cr(),e=fi(),n=Zi(),r=Ad(),s=j0(),i=L0(),o=Math.max,l=Math.min,u=Math.floor,f=/\$([$&`']|\d\d?|<[^>]*>)/g,p=/\$([$&`']|\d\d?)/g,m=function(g){return g===void 0?g:String(g)};return B0()("replace",2,function(g,y,b,k){return[function(N,O){var T=g(this),C=N==null?void 0:N[y];return C!==void 0?C.call(N,T,O):b.call(String(T),N,O)},function(E,N){var O=k(b,E,this,N);if(O.done)return O.value;var T=t(E),C=String(this),R=typeof N=="function";R||(N=String(N));var L=T.global;if(L){var D=T.unicode;T.lastIndex=0}for(var z=[];;){var F=i(T,C);if(F===null||(z.push(F),!L))break;var J=String(F[0]);J===""&&(T.lastIndex=s(C,n(T.lastIndex),D))}for(var K="",X=0,W=0;W<z.length;W++){F=z[W];for(var $=String(F[0]),U=o(l(r(F.index),C.length),0),Z=[],V=1;V<F.length;V++)Z.push(m(F[V]));var Y=F.groups;if(R){var I=[$].concat(Z,U,C);Y!==void 0&&I.push(Y);var A=String(N.apply(void 0,I))}else A=w($,C,U,Z,Y,N);U>=X&&(K+=C.slice(X,U)+A,X=U+$.length)}return K+C.slice(X)}];function w(E,N,O,T,C,R){var L=O+E.length,D=T.length,z=p;return C!==void 0&&(C=e(C),z=f),b.call(R,z,function(F,J){var K;switch(J.charAt(0)){case"$":return"$";case"&":return E;case"`":return N.slice(0,O);case"'":return N.slice(L);case"<":K=C[J.slice(1,-1)];break;default:var X=+J;if(X===0)return F;if(X>D){var W=u(X/10);return W===0?F:W<=D?T[W-1]===void 0?J.charAt(1):T[W-1]+J.charAt(1):F}K=T[X-1]}return K===void 0?"":K})}}),Y1}R5();var Iw={},Kp,Lw;function z0(){if(Lw)return Kp;Lw=1;var t=Od();return Kp=Object("z").propertyIsEnumerable(0)?Object:function(e){return t(e)=="String"?e.split(""):Object(e)},Kp}var Gp,Dw;function to(){if(Dw)return Gp;Dw=1;var t=z0(),e=Md();return Gp=function(n){return t(e(n))},Gp}var Jp,Pw;function j5(){if(Pw)return Jp;Pw=1;var t=Ad(),e=Math.max,n=Math.min;return Jp=function(r,s){return r=t(r),r<0?e(r+s,0):n(r,s)},Jp}var Yp,Bw;function PC(){if(Bw)return Yp;Bw=1;var t=to(),e=Zi(),n=j5();return Yp=function(r){return function(s,i,o){var l=t(s),u=e(l.length),f=n(o,u),p;if(r&&i!=i){for(;u>f;)if(p=l[f++],p!=p)return!0}else for(;u>f;f++)if((r||f in l)&&l[f]===i)return r||f||0;return!r&&-1}},Yp}var Qp,zw;function xl(){if(zw)return Qp;zw=1;var t=Br();return Qp=function(e,n){return!!e&&t(function(){n?e.call(null,function(){},1):e.call(null)})},Qp}var Fw;function I5(){if(Fw)return Iw;Fw=1;var t=tr(),e=PC()(!1),n=[].indexOf,r=!!n&&1/[1].indexOf(1,-0)<0;return t(t.P+t.F*(r||!xl()(n)),"Array",{indexOf:function(i){return r?n.apply(this,arguments)||0:e(this,i,arguments[1])}}),Iw}I5();var L5=/[a-z]{1,6}(?:[._][a-z]{1,2})?/i,BC=/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/,$w={},Xp={},Zp={},Uw;function F0(){return Uw||(Uw=1,Zp.f={}.propertyIsEnumerable),Zp}var Hw;function $0(){if(Hw)return Xp;Hw=1;var t=F0(),e=bl(),n=to(),r=P0(),s=eo(),i=DC(),o=Object.getOwnPropertyDescriptor;return Xp.f=Er()?o:function(u,f){if(u=n(u),f=r(f,!0),i)try{return o(u,f)}catch{}if(s(u,f))return e(!t.f.call(u,f),u[f])},Xp}var em,Ww;function D5(){if(Ww)return em;Ww=1;var t=ks(),e=cr(),n=function(r,s){if(e(r),!t(s)&&s!==null)throw TypeError(s+": can't set as prototype!")};return em={set:Object.setPrototypeOf||("__proto__"in{}?(function(r,s,i){try{i=Dd()(Function.call,$0().f(Object.prototype,"__proto__").set,2),i(r,[]),s=!(r instanceof Array)}catch{s=!0}return function(l,u){return n(l,u),s?l.__proto__=u:i(l,u),l}})({},!1):void 0),check:n},em}var tm,qw;function P5(){if(qw)return tm;qw=1;var t=ks(),e=D5().set;return tm=function(n,r,s){var i=r.constructor,o;return i!==s&&typeof i=="function"&&(o=i.prototype)!==s.prototype&&t(o)&&e&&e(n,o),n},tm}var nm={},rm,Vw;function U0(){if(Vw)return rm;Vw=1;var t=jd()("keys"),e=yl();return rm=function(n){return t[n]||(t[n]=e(n))},rm}var sm,Kw;function zC(){if(Kw)return sm;Kw=1;var t=eo(),e=to(),n=PC()(!1),r=U0()("IE_PROTO");return sm=function(s,i){var o=e(s),l=0,u=[],f;for(f in o)f!=r&&t(o,f)&&u.push(f);for(;i.length>l;)t(o,f=i[l++])&&(~n(u,f)||u.push(f));return u},sm}var im,Gw;function H0(){return Gw||(Gw=1,im="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")),im}var Jw;function Pd(){if(Jw)return nm;Jw=1;var t=zC(),e=H0().concat("length","prototype");return nm.f=Object.getOwnPropertyNames||function(r){return t(r,e)},nm}var om,Yw;function FC(){if(Yw)return om;Yw=1;var t=ks(),e=Od(),n=bn()("match");return om=function(r){var s;return t(r)&&((s=r[n])!==void 0?!!s:e(r)=="RegExp")},om}var am,Qw;function B5(){if(Qw)return am;Qw=1;var t=Sr(),e=zr(),n=Er(),r=bn()("species");return am=function(s){var i=t[s];n&&i&&!i[r]&&e.f(i,r,{configurable:!0,get:function(){return this}})},am}var Xw;function z5(){if(Xw)return $w;Xw=1;var t=Sr(),e=P5(),n=zr().f,r=Pd().f,s=FC(),i=Id(),o=t.RegExp,l=o,u=o.prototype,f=/a/g,p=/a/g,m=new o(f)!==f;if(Er()&&(!m||Br()(function(){return p[bn()("match")]=!1,o(f)!=f||o(p)==p||o(f,"i")!="/a/i"}))){o=function(w,E){var N=this instanceof o,O=s(w),T=E===void 0;return!N&&O&&w.constructor===o&&T?w:e(m?new l(O&&!T?w.source:w,E):l((O=w instanceof o)?w.source:w,O&&T?i.call(w):E),N?this:u,o)};for(var g=function(k){k in o||n(o,k,{configurable:!0,get:function(){return l[k]},set:function(w){l[k]=w}})},y=r(l),b=0;y.length>b;)g(y[b++]);u.constructor=o,o.prototype=u,Ss()(t,"RegExp",o)}return B5()("RegExp"),$w}z5();function ft(t,e,n){return n=n||"",typeof t!="string"&&(t.global&&n.indexOf("g")<0&&(n+="g"),t.ignoreCase&&n.indexOf("i")<0&&(n+="i"),t.multiline&&n.indexOf("m")<0&&(n+="m"),t=t.source),new RegExp(t.replace(/#\{(\w+)\}/g,function(r,s){var i=e[s]||"";return typeof i!="string"&&(i=i.source),i}),n)}var $C=/\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/;const UC=ft(/[#{spacesGroup}]/,{spacesGroup:$C});ft("(^|#{spaces})(\\$)(#{cashtag})(?=$|\\s|[#{punct}])",{cashtag:L5,spaces:UC,punct:BC},"gi");var Zw={},ek;function F5(){if(ek)return Zw;ek=1;var t=cr(),e=Zi(),n=j0(),r=L0();return B0()("match",1,function(s,i,o,l){return[function(f){var p=s(this),m=f==null?void 0:f[i];return m!==void 0?m.call(f,p):new RegExp(f)[i](String(p))},function(u){var f=l(o,u,this);if(f.done)return f.value;var p=t(u),m=String(this);if(!p.global)return r(p,m);var g=p.unicode;p.lastIndex=0;for(var y=[],b=0,k;(k=r(p,m))!==null;){var w=String(k[0]);y[b]=w,w===""&&(p.lastIndex=n(m,e(p.lastIndex),g)),b++}return b===0?null:y}]}),Zw}F5();var HC=/[##]/;ft(/^(?:#{hashSigns}|:\/\/)/,{hashSigns:HC});var WC=ft(RegExp("(?:(?:한국|香港|澳門|新加坡|台灣|台湾|中國|中国|გე|ລາວ|ไทย|ලංකා|ഭാരതം|ಭಾರತ|భారత్|சிங்கப்பூர்|இலங்கை|இந்தியா|ଭାରତ|ભારત|ਭਾਰਤ|ভাৰত|ভারত|বাংলা|भारोत|भारतम्|भारत|ڀارت|پاکستان|موريتانيا|مليسيا|مصر|قطر|فلسطين|عمان|عراق|سورية|سودان|تونس|بھارت|بارت|ایران|امارات|المغرب|السعودية|الجزائر|البحرين|الاردن|հայ|қаз|укр|срб|рф|мон|мкд|ею|бел|бг|ευ|ελ|zw|zm|za|yt|ye|ws|wf|vu|vn|vi|vg|ve|vc|va|uz|uy|us|um|uk|ug|ua|tz|tw|tv|tt|tr|tp|to|tn|tm|tl|tk|tj|th|tg|tf|td|tc|sz|sy|sx|sv|su|st|ss|sr|so|sn|sm|sl|sk|sj|si|sh|sg|se|sd|sc|sb|sa|rw|ru|rs|ro|re|qa|py|pw|pt|ps|pr|pn|pm|pl|pk|ph|pg|pf|pe|pa|om|nz|nu|nr|np|no|nl|ni|ng|nf|ne|nc|na|mz|my|mx|mw|mv|mu|mt|ms|mr|mq|mp|mo|mn|mm|ml|mk|mh|mg|mf|me|md|mc|ma|ly|lv|lu|lt|ls|lr|lk|li|lc|lb|la|kz|ky|kw|kr|kp|kn|km|ki|kh|kg|ke|jp|jo|jm|je|it|is|ir|iq|io|in|im|il|ie|id|hu|ht|hr|hn|hm|hk|gy|gw|gu|gt|gs|gr|gq|gp|gn|gm|gl|gi|gh|gg|gf|ge|gd|gb|ga|fr|fo|fm|fk|fj|fi|eu|et|es|er|eh|eg|ee|ec|dz|do|dm|dk|dj|de|cz|cy|cx|cw|cv|cu|cr|co|cn|cm|cl|ck|ci|ch|cg|cf|cd|cc|ca|bz|by|bw|bv|bt|bs|br|bq|bo|bn|bm|bl|bj|bi|bh|bg|bf|be|bd|bb|ba|az|ax|aw|au|at|as|ar|aq|ao|an|am|al|ai|ag|af|ae|ad|ac)(?=[^0-9a-zA-Z@+-]|$))")),qC=/\u202A-\u202E\u061C\u200E\u200F\u2066\u2067\u2068\u2069/,W0=/\uFFFE\uFEFF\uFFFF/;function $5(t,e){return t.replace(/#\{(\w+)\}/g,function(n,r){return e[r]||""})}var U5=$5("#{punct}#{spacesGroup}#{invalidCharsGroup}#{directionalMarkersGroup}",{punct:BC,spacesGroup:$C,invalidCharsGroup:W0,directionalMarkersGroup:qC}),VC=ft(/[^#{invalidDomainChars}]/,{invalidDomainChars:U5}),H5=ft(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:VC}),KC=ft(RegExp("(?:(?:삼성|닷컴|닷넷|香格里拉|餐厅|食品|飞利浦|電訊盈科|集团|通販|购物|谷歌|诺基亚|联通|网络|网站|网店|网址|组织机构|移动|珠宝|点看|游戏|淡马锡|机构|書籍|时尚|新闻|政府|政务|招聘|手表|手机|我爱你|慈善|微博|广东|工行|家電|娱乐|天主教|大拿|大众汽车|在线|嘉里大酒店|嘉里|商标|商店|商城|公益|公司|八卦|健康|信息|佛山|企业|中文网|中信|世界|ポイント|ファッション|セール|ストア|コム|グーグル|クラウド|みんな|คอม|संगठन|नेट|कॉम|همراه|موقع|موبايلي|كوم|كاثوليك|عرب|شبكة|بيتك|بازار|العليان|ارامكو|اتصالات|ابوظبي|קום|сайт|рус|орг|онлайн|москва|ком|католик|дети|zuerich|zone|zippo|zip|zero|zara|zappos|yun|youtube|you|yokohama|yoga|yodobashi|yandex|yamaxun|yahoo|yachts|xyz|xxx|xperia|xin|xihuan|xfinity|xerox|xbox|wtf|wtc|wow|world|works|work|woodside|wolterskluwer|wme|winners|wine|windows|win|williamhill|wiki|wien|whoswho|weir|weibo|wedding|wed|website|weber|webcam|weatherchannel|weather|watches|watch|warman|wanggou|wang|walter|walmart|wales|vuelos|voyage|voto|voting|vote|volvo|volkswagen|vodka|vlaanderen|vivo|viva|vistaprint|vista|vision|visa|virgin|vip|vin|villas|viking|vig|video|viajes|vet|versicherung|vermögensberatung|vermögensberater|verisign|ventures|vegas|vanguard|vana|vacations|ups|uol|uno|university|unicom|uconnect|ubs|ubank|tvs|tushu|tunes|tui|tube|trv|trust|travelersinsurance|travelers|travelchannel|travel|training|trading|trade|toys|toyota|town|tours|total|toshiba|toray|top|tools|tokyo|today|tmall|tkmaxx|tjx|tjmaxx|tirol|tires|tips|tiffany|tienda|tickets|tiaa|theatre|theater|thd|teva|tennis|temasek|telefonica|telecity|tel|technology|tech|team|tdk|tci|taxi|tax|tattoo|tatar|tatamotors|target|taobao|talk|taipei|tab|systems|symantec|sydney|swiss|swiftcover|swatch|suzuki|surgery|surf|support|supply|supplies|sucks|style|study|studio|stream|store|storage|stockholm|stcgroup|stc|statoil|statefarm|statebank|starhub|star|staples|stada|srt|srl|spreadbetting|spot|sport|spiegel|space|soy|sony|song|solutions|solar|sohu|software|softbank|social|soccer|sncf|smile|smart|sling|skype|sky|skin|ski|site|singles|sina|silk|shriram|showtime|show|shouji|shopping|shop|shoes|shiksha|shia|shell|shaw|sharp|shangrila|sfr|sexy|sex|sew|seven|ses|services|sener|select|seek|security|secure|seat|search|scot|scor|scjohnson|science|schwarz|schule|school|scholarships|schmidt|schaeffler|scb|sca|sbs|sbi|saxo|save|sas|sarl|sapo|sap|sanofi|sandvikcoromant|sandvik|samsung|samsclub|salon|sale|sakura|safety|safe|saarland|ryukyu|rwe|run|ruhr|rugby|rsvp|room|rogers|rodeo|rocks|rocher|rmit|rip|rio|ril|rightathome|ricoh|richardli|rich|rexroth|reviews|review|restaurant|rest|republican|report|repair|rentals|rent|ren|reliance|reit|reisen|reise|rehab|redumbrella|redstone|red|recipes|realty|realtor|realestate|read|raid|radio|racing|qvc|quest|quebec|qpon|pwc|pub|prudential|pru|protection|property|properties|promo|progressive|prof|productions|prod|pro|prime|press|praxi|pramerica|post|porn|politie|poker|pohl|pnc|plus|plumbing|playstation|play|place|pizza|pioneer|pink|ping|pin|pid|pictures|pictet|pics|piaget|physio|photos|photography|photo|phone|philips|phd|pharmacy|pfizer|pet|pccw|pay|passagens|party|parts|partners|pars|paris|panerai|panasonic|pamperedchef|page|ovh|ott|otsuka|osaka|origins|orientexpress|organic|org|orange|oracle|open|ooo|onyourside|online|onl|ong|one|omega|ollo|oldnavy|olayangroup|olayan|okinawa|office|off|observer|obi|nyc|ntt|nrw|nra|nowtv|nowruz|now|norton|northwesternmutual|nokia|nissay|nissan|ninja|nikon|nike|nico|nhk|ngo|nfl|nexus|nextdirect|next|news|newholland|new|neustar|network|netflix|netbank|net|nec|nba|navy|natura|nationwide|name|nagoya|nadex|nab|mutuelle|mutual|museum|mtr|mtpc|mtn|msd|movistar|movie|mov|motorcycles|moto|moscow|mortgage|mormon|mopar|montblanc|monster|money|monash|mom|moi|moe|moda|mobily|mobile|mobi|mma|mls|mlb|mitsubishi|mit|mint|mini|mil|microsoft|miami|metlife|merckmsd|meo|menu|men|memorial|meme|melbourne|meet|media|med|mckinsey|mcdonalds|mcd|mba|mattel|maserati|marshalls|marriott|markets|marketing|market|map|mango|management|man|makeup|maison|maif|madrid|macys|luxury|luxe|lupin|lundbeck|ltda|ltd|lplfinancial|lpl|love|lotto|lotte|london|lol|loft|locus|locker|loans|loan|llp|llc|lixil|living|live|lipsy|link|linde|lincoln|limo|limited|lilly|like|lighting|lifestyle|lifeinsurance|life|lidl|liaison|lgbt|lexus|lego|legal|lefrak|leclerc|lease|lds|lawyer|law|latrobe|latino|lat|lasalle|lanxess|landrover|land|lancome|lancia|lancaster|lamer|lamborghini|ladbrokes|lacaixa|kyoto|kuokgroup|kred|krd|kpn|kpmg|kosher|komatsu|koeln|kiwi|kitchen|kindle|kinder|kim|kia|kfh|kerryproperties|kerrylogistics|kerryhotels|kddi|kaufen|juniper|juegos|jprs|jpmorgan|joy|jot|joburg|jobs|jnj|jmp|jll|jlc|jio|jewelry|jetzt|jeep|jcp|jcb|java|jaguar|iwc|iveco|itv|itau|istanbul|ist|ismaili|iselect|irish|ipiranga|investments|intuit|international|intel|int|insure|insurance|institute|ink|ing|info|infiniti|industries|inc|immobilien|immo|imdb|imamat|ikano|iinet|ifm|ieee|icu|ice|icbc|ibm|hyundai|hyatt|hughes|htc|hsbc|how|house|hotmail|hotels|hoteles|hot|hosting|host|hospital|horse|honeywell|honda|homesense|homes|homegoods|homedepot|holiday|holdings|hockey|hkt|hiv|hitachi|hisamitsu|hiphop|hgtv|hermes|here|helsinki|help|healthcare|health|hdfcbank|hdfc|hbo|haus|hangout|hamburg|hair|guru|guitars|guide|guge|gucci|guardian|group|grocery|gripe|green|gratis|graphics|grainger|gov|got|gop|google|goog|goodyear|goodhands|goo|golf|goldpoint|gold|godaddy|gmx|gmo|gmbh|gmail|globo|global|gle|glass|glade|giving|gives|gifts|gift|ggee|george|genting|gent|gea|gdn|gbiz|gay|garden|gap|games|game|gallup|gallo|gallery|gal|fyi|futbol|furniture|fund|fun|fujixerox|fujitsu|ftr|frontier|frontdoor|frogans|frl|fresenius|free|fox|foundation|forum|forsale|forex|ford|football|foodnetwork|food|foo|fly|flsmidth|flowers|florist|flir|flights|flickr|fitness|fit|fishing|fish|firmdale|firestone|fire|financial|finance|final|film|fido|fidelity|fiat|ferrero|ferrari|feedback|fedex|fast|fashion|farmers|farm|fans|fan|family|faith|fairwinds|fail|fage|extraspace|express|exposed|expert|exchange|everbank|events|eus|eurovision|etisalat|esurance|estate|esq|erni|ericsson|equipment|epson|epost|enterprises|engineering|engineer|energy|emerck|email|education|edu|edeka|eco|eat|earth|dvr|dvag|durban|dupont|duns|dunlop|duck|dubai|dtv|drive|download|dot|doosan|domains|doha|dog|dodge|doctor|docs|dnp|diy|dish|discover|discount|directory|direct|digital|diet|diamonds|dhl|dev|design|desi|dentist|dental|democrat|delta|deloitte|dell|delivery|degree|deals|dealer|deal|dds|dclk|day|datsun|dating|date|data|dance|dad|dabur|cyou|cymru|cuisinella|csc|cruises|cruise|crs|crown|cricket|creditunion|creditcard|credit|cpa|courses|coupons|coupon|country|corsica|coop|cool|cookingchannel|cooking|contractors|contact|consulting|construction|condos|comsec|computer|compare|company|community|commbank|comcast|com|cologne|college|coffee|codes|coach|clubmed|club|cloud|clothing|clinique|clinic|click|cleaning|claims|cityeats|city|citic|citi|citadel|cisco|circle|cipriani|church|chrysler|chrome|christmas|chloe|chintai|cheap|chat|chase|charity|channel|chanel|cfd|cfa|cern|ceo|center|ceb|cbs|cbre|cbn|cba|catholic|catering|cat|casino|cash|caseih|case|casa|cartier|cars|careers|career|care|cards|caravan|car|capitalone|capital|capetown|canon|cancerresearch|camp|camera|cam|calvinklein|call|cal|cafe|cab|bzh|buzz|buy|business|builders|build|bugatti|budapest|brussels|brother|broker|broadway|bridgestone|bradesco|box|boutique|bot|boston|bostik|bosch|boots|booking|book|boo|bond|bom|bofa|boehringer|boats|bnpparibas|bnl|bmw|bms|blue|bloomberg|blog|blockbuster|blanco|blackfriday|black|biz|bio|bingo|bing|bike|bid|bible|bharti|bet|bestbuy|best|berlin|bentley|beer|beauty|beats|bcn|bcg|bbva|bbt|bbc|bayern|bauhaus|basketball|baseball|bargains|barefoot|barclays|barclaycard|barcelona|bar|bank|band|bananarepublic|banamex|baidu|baby|azure|axa|aws|avianca|autos|auto|author|auspost|audio|audible|audi|auction|attorney|athleta|associates|asia|asda|arte|art|arpa|army|archi|aramco|arab|aquarelle|apple|app|apartments|aol|anz|anquan|android|analytics|amsterdam|amica|amfam|amex|americanfamily|americanexpress|alstom|alsace|ally|allstate|allfinanz|alipay|alibaba|alfaromeo|akdn|airtel|airforce|airbus|aigo|aig|agency|agakhan|africa|afl|afamilycompany|aetna|aero|aeg|adult|ads|adac|actor|active|aco|accountants|accountant|accenture|academy|abudhabi|abogado|able|abc|abbvie|abbott|abb|abarth|aarp|aaa|onion)(?=[^0-9a-zA-Z@+-]|$))")),GC=/(?:xn--[\-0-9a-z]+)/,W5=ft(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:VC}),q5=ft(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/,{validDomainName:H5,validSubdomain:W5,validGTLD:KC,validCCTLD:WC,validPunycode:GC}),V5=/[0-9]+/,JC=/\u0400-\u04FF/,Bd=/\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u024F\u0253\u0254\u0256\u0257\u0259\u025B\u0263\u0268\u026F\u0272\u0289\u028B\u02BB\u0300-\u036F\u1E00-\u1EFF/,YC=ft(/[a-z#{cyrillicLettersAndMarks}0-9!\*';:=\+,\.\$\/%#\[\]\-\u2013_~@\|&#{latinAccentChars}]/i,{cyrillicLettersAndMarks:JC,latinAccentChars:Bd}),QC=ft("\\((?:#{validGeneralUrlPathChars}+|(?:#{validGeneralUrlPathChars}*\\(#{validGeneralUrlPathChars}+\\)#{validGeneralUrlPathChars}*))\\)",{validGeneralUrlPathChars:YC},"i"),K5=ft(/[\+\-a-z#{cyrillicLettersAndMarks}0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i,{cyrillicLettersAndMarks:JC,latinAccentChars:Bd,validUrlBalancedParens:QC}),G5=ft("(?:(?:#{validGeneralUrlPathChars}*(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*#{validUrlPathEndingChars})|(?:@#{validGeneralUrlPathChars}+/))",{validGeneralUrlPathChars:YC,validUrlBalancedParens:QC,validUrlPathEndingChars:K5},"i"),J5=ft(/(?:[^A-Za-z0-9@@$###{invalidCharsGroup}]|[#{directionalMarkersGroup}]|^)/,{invalidCharsGroup:W0,directionalMarkersGroup:qC}),XC=/[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i,ZC=/[a-z0-9\-_&=#\/]/i,tk=ft("((#{validUrlPrecedingChars})((https?:\\/\\/)?(#{validDomain})(?::(#{validPortNumber}))?(\\/#{validUrlPath}*)?(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?))",{validUrlPrecedingChars:J5,validDomain:q5,validPortNumber:V5,validUrlPath:G5,validUrlQueryChars:XC,validUrlQueryEndingChars:ZC},"gi"),Y5=/[-_.\/]$/,nk={},lm,rk;function Q5(){if(rk)return lm;rk=1;var t=cr(),e=Ld(),n=bn()("species");return lm=function(r,s){var i=t(r).constructor,o;return i===void 0||(o=t(i)[n])==null?s:e(o)},lm}var sk;function X5(){if(sk)return nk;sk=1;var t=FC(),e=cr(),n=Q5(),r=j0(),s=Zi(),i=L0(),o=D0(),l=Br(),u=Math.min,f=[].push,p="split",m="length",g="lastIndex",y=4294967295,b=!l(function(){});return B0()("split",2,function(k,w,E,N){var O;return"abbc"[p](/(b)*/)[1]=="c"||"test"[p](/(?:)/,-1)[m]!=4||"ab"[p](/(?:ab)*/)[m]!=2||"."[p](/(.?)(.?)/)[m]!=4||"."[p](/()()/)[m]>1||""[p](/.?/)[m]?O=function(T,C){var R=String(this);if(T===void 0&&C===0)return[];if(!t(T))return E.call(R,T,C);for(var L=[],D=(T.ignoreCase?"i":"")+(T.multiline?"m":"")+(T.unicode?"u":"")+(T.sticky?"y":""),z=0,F=C===void 0?y:C>>>0,J=new RegExp(T.source,D+"g"),K,X,W;(K=o.call(J,R))&&(X=J[g],!(X>z&&(L.push(R.slice(z,K.index)),K[m]>1&&K.index<R[m]&&f.apply(L,K.slice(1)),W=K[0][m],z=X,L[m]>=F)));)J[g]===K.index&&J[g]++;return z===R[m]?(W||!J.test(""))&&L.push(""):L.push(R.slice(z)),L[m]>F?L.slice(0,F):L}:"0"[p](void 0,0)[m]?O=function(T,C){return T===void 0&&C===0?[]:E.call(this,T,C)}:O=E,[function(C,R){var L=k(this),D=C==null?void 0:C[w];return D!==void 0?D.call(C,L,R):O.call(String(L),C,R)},function(T,C){var R=N(O,T,this,C,O!==E);if(R.done)return R.value;var L=e(T),D=String(this),z=n(L,RegExp),F=L.unicode,J=(L.ignoreCase?"i":"")+(L.multiline?"m":"")+(L.unicode?"u":"")+(b?"y":"g"),K=new z(b?L:"^(?:"+L.source+")",J),X=C===void 0?y:C>>>0;if(X===0)return[];if(D.length===0)return i(K,D)===null?[D]:[];for(var W=0,$=0,U=[];$<D.length;){K.lastIndex=b?$:0;var Z=i(K,b?D:D.slice($)),V;if(Z===null||(V=u(s(K.lastIndex+(b?0:$)),D.length))===W)$=r(D,$,F);else{if(U.push(D.slice(W,$)),U.length===X)return U;for(var Y=1;Y<=Z.length-1;Y++)if(U.push(Z[Y]),U.length===X)return U;$=W=V}}return U.push(D.slice(W)),U}]}),nk}X5();var Ua={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var Z5=Ua.exports,ik;function ez(){return ik||(ik=1,(function(t,e){(function(n){var r=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,i=typeof fb=="object"&&fb;(i.global===i||i.window===i||i.self===i)&&(n=i);var o,l=2147483647,u=36,f=1,p=26,m=38,g=700,y=72,b=128,k="-",w=/^xn--/,E=/[^\x20-\x7E]/,N=/[\x2E\u3002\uFF0E\uFF61]/g,O={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=u-f,C=Math.floor,R=String.fromCharCode,L;function D(I){throw new RangeError(O[I])}function z(I,A){for(var j=I.length,Q=[];j--;)Q[j]=A(I[j]);return Q}function F(I,A){var j=I.split("@"),Q="";j.length>1&&(Q=j[0]+"@",I=j[1]),I=I.replace(N,".");var oe=I.split("."),fe=z(oe,A).join(".");return Q+fe}function J(I){for(var A=[],j=0,Q=I.length,oe,fe;j<Q;)oe=I.charCodeAt(j++),oe>=55296&&oe<=56319&&j<Q?(fe=I.charCodeAt(j++),(fe&64512)==56320?A.push(((oe&1023)<<10)+(fe&1023)+65536):(A.push(oe),j--)):A.push(oe);return A}function K(I){return z(I,function(A){var j="";return A>65535&&(A-=65536,j+=R(A>>>10&1023|55296),A=56320|A&1023),j+=R(A),j}).join("")}function X(I){return I-48<10?I-22:I-65<26?I-65:I-97<26?I-97:u}function W(I,A){return I+22+75*(I<26)-((A!=0)<<5)}function $(I,A,j){var Q=0;for(I=j?C(I/g):I>>1,I+=C(I/A);I>T*p>>1;Q+=u)I=C(I/T);return C(Q+(T+1)*I/(I+m))}function U(I){var A=[],j=I.length,Q,oe=0,fe=b,G=y,le,Te,Ve,ce,ue,ae,je,Me,He;for(le=I.lastIndexOf(k),le<0&&(le=0),Te=0;Te<le;++Te)I.charCodeAt(Te)>=128&&D("not-basic"),A.push(I.charCodeAt(Te));for(Ve=le>0?le+1:0;Ve<j;){for(ce=oe,ue=1,ae=u;Ve>=j&&D("invalid-input"),je=X(I.charCodeAt(Ve++)),(je>=u||je>C((l-oe)/ue))&&D("overflow"),oe+=je*ue,Me=ae<=G?f:ae>=G+p?p:ae-G,!(je<Me);ae+=u)He=u-Me,ue>C(l/He)&&D("overflow"),ue*=He;Q=A.length+1,G=$(oe-ce,Q,ce==0),C(oe/Q)>l-fe&&D("overflow"),fe+=C(oe/Q),oe%=Q,A.splice(oe++,0,fe)}return K(A)}function Z(I){var A,j,Q,oe,fe,G,le,Te,Ve,ce,ue,ae=[],je,Me,He,Ne;for(I=J(I),je=I.length,A=b,j=0,fe=y,G=0;G<je;++G)ue=I[G],ue<128&&ae.push(R(ue));for(Q=oe=ae.length,oe&&ae.push(k);Q<je;){for(le=l,G=0;G<je;++G)ue=I[G],ue>=A&&ue<le&&(le=ue);for(Me=Q+1,le-A>C((l-j)/Me)&&D("overflow"),j+=(le-A)*Me,A=le,G=0;G<je;++G)if(ue=I[G],ue<A&&++j>l&&D("overflow"),ue==A){for(Te=j,Ve=u;ce=Ve<=fe?f:Ve>=fe+p?p:Ve-fe,!(Te<ce);Ve+=u)Ne=Te-ce,He=u-ce,ae.push(R(W(ce+Ne%He,0))),Te=C(Ne/He);ae.push(R(W(Te,0))),fe=$(j,Me,Q==oe),j=0,++Q}++j,++A}return ae.join("")}function V(I){return F(I,function(A){return w.test(A)?U(A.slice(4).toLowerCase()):A})}function Y(I){return F(I,function(A){return E.test(A)?"xn--"+Z(A):A})}if(o={version:"1.4.1",ucs2:{decode:J,encode:K},decode:U,encode:Z,toASCII:Y,toUnicode:V},r&&s)if(t.exports==r)s.exports=o;else for(L in o)o.hasOwnProperty(L)&&(r[L]=o[L]);else n.punycode=o})(Z5)})(Ua,Ua.exports)),Ua.exports}var tz=ez();const nz=dl(tz);var eT=ft(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi,{latinAccentChars:Bd,validGTLD:KC,validCCTLD:WC,validPunycode:GC}),rz=63,sz="xn--",iz={toAscii:function(e){if(!(e.substring(0,4)===sz&&!e.match(eT))){for(var n=e.split("."),r=0;r<n.length;r++){var s=n[r],i=nz.toASCII(s);if(i.length<1||i.length>rz)return}return n.join(".")}}},oz=ft(/^https?:\/\/t\.co\/([a-z0-9]+)(?:\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?/,{validUrlQueryChars:XC,validUrlQueryEndingChars:ZC},"i"),az="https://",lz={extractUrlsWithoutProtocol:!0},cz=4096,uz=40,dz=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:lz;if(!e||(n.extractUrlsWithoutProtocol?!e.match(/\./):!e.match(/:/)))return[];for(var r=[],s=function(){var l=RegExp.$2,u=RegExp.$3,f=RegExp.$4,p=RegExp.$5,m=RegExp.$7,g=tk.lastIndex,y=g-u.length;if(!fz(u,f||az,p))return"continue";if(f){if(u.match(oz)){var w=RegExp.$1;if(w&&w.length>uz)return"continue";u=RegExp.lastMatch,g=y+u.length}r.push({url:u,indices:[y,g]})}else{if(!n.extractUrlsWithoutProtocol||l.match(Y5))return"continue";var b=null,k=0;if(p.replace(eT,function(E){var N=p.indexOf(E,k);k=N+E.length,b={url:E,indices:[y+N,y+k]},r.push(b)}),b==null)return"continue";m&&(b.url=u.replace(p,b.url),b.indices[1]=g)}};tk.exec(e);)var i=s();return r},fz=function(e,n,r){var s=e.length,i=iz.toAscii(r);return!i||!i.length?!1:(s=s+i.length-r.length,n.length+s<=cz)},ok={},ak;function hz(){if(ak)return ok;ak=1;var t=tr(),e=Ld(),n=fi(),r=Br(),s=[].sort,i=[1,2,3];return t(t.P+t.F*(r(function(){i.sort(void 0)})||!r(function(){i.sort(null)})||!xl()(s)),"Array",{sort:function(l){return l===void 0?s.call(n(this)):s.call(n(this),e(l))}}),ok}hz();var tT=/\ud800[\udc00-\udc0b\udc0d-\udc26\udc28-\udc3a\udc3c\udc3d\udc3f-\udc4d\udc50-\udc5d\udc80-\udcfa\uddfd\ude80-\ude9c\udea0-\uded0\udee0\udf00-\udf1f\udf30-\udf40\udf42-\udf49\udf50-\udf7a\udf80-\udf9d\udfa0-\udfc3\udfc8-\udfcf]|\ud801[\udc00-\udc9d\udd00-\udd27\udd30-\udd63\ude00-\udf36\udf40-\udf55\udf60-\udf67]|\ud802[\udc00-\udc05\udc08\udc0a-\udc35\udc37\udc38\udc3c\udc3f-\udc55\udc60-\udc76\udc80-\udc9e\udd00-\udd15\udd20-\udd39\udd80-\uddb7\uddbe\uddbf\ude00-\ude03\ude05\ude06\ude0c-\ude13\ude15-\ude17\ude19-\ude33\ude38-\ude3a\ude3f\ude60-\ude7c\ude80-\ude9c\udec0-\udec7\udec9-\udee6\udf00-\udf35\udf40-\udf55\udf60-\udf72\udf80-\udf91]|\ud803[\udc00-\udc48]|\ud804[\udc00-\udc46\udc7f-\udcba\udcd0-\udce8\udd00-\udd34\udd50-\udd73\udd76\udd80-\uddc4\uddda\ude00-\ude11\ude13-\ude37\udeb0-\udeea\udf01-\udf03\udf05-\udf0c\udf0f\udf10\udf13-\udf28\udf2a-\udf30\udf32\udf33\udf35-\udf39\udf3c-\udf44\udf47\udf48\udf4b-\udf4d\udf57\udf5d-\udf63\udf66-\udf6c\udf70-\udf74]|\ud805[\udc80-\udcc5\udcc7\udd80-\uddb5\uddb8-\uddc0\ude00-\ude40\ude44\ude80-\udeb7]|\ud806[\udca0-\udcdf\udcff\udec0-\udef8]|\ud808[\udc00-\udf98]|\ud80c[\udc00-\udfff]|\ud80d[\udc00-\udc2e]|\ud81a[\udc00-\ude38\ude40-\ude5e\uded0-\udeed\udef0-\udef4\udf00-\udf36\udf40-\udf43\udf63-\udf77\udf7d-\udf8f]|\ud81b[\udf00-\udf44\udf50-\udf7e\udf8f-\udf9f]|\ud82c[\udc00\udc01]|\ud82f[\udc00-\udc6a\udc70-\udc7c\udc80-\udc88\udc90-\udc99\udc9d\udc9e]|\ud834[\udd65-\udd69\udd6d-\udd72\udd7b-\udd82\udd85-\udd8b\uddaa-\uddad\ude42-\ude44]|\ud835[\udc00-\udc54\udc56-\udc9c\udc9e\udc9f\udca2\udca5\udca6\udca9-\udcac\udcae-\udcb9\udcbb\udcbd-\udcc3\udcc5-\udd05\udd07-\udd0a\udd0d-\udd14\udd16-\udd1c\udd1e-\udd39\udd3b-\udd3e\udd40-\udd44\udd46\udd4a-\udd50\udd52-\udea5\udea8-\udec0\udec2-\udeda\udedc-\udefa\udefc-\udf14\udf16-\udf34\udf36-\udf4e\udf50-\udf6e\udf70-\udf88\udf8a-\udfa8\udfaa-\udfc2\udfc4-\udfcb]|\ud83a[\udc00-\udcc4\udcd0-\udcd6]|\ud83b[\ude00-\ude03\ude05-\ude1f\ude21\ude22\ude24\ude27\ude29-\ude32\ude34-\ude37\ude39\ude3b\ude42\ude47\ude49\ude4b\ude4d-\ude4f\ude51\ude52\ude54\ude57\ude59\ude5b\ude5d\ude5f\ude61\ude62\ude64\ude67-\ude6a\ude6c-\ude72\ude74-\ude77\ude79-\ude7c\ude7e\ude80-\ude89\ude8b-\ude9b\udea1-\udea3\udea5-\udea9\udeab-\udebb]|\ud840[\udc00-\udfff]|\ud841[\udc00-\udfff]|\ud842[\udc00-\udfff]|\ud843[\udc00-\udfff]|\ud844[\udc00-\udfff]|\ud845[\udc00-\udfff]|\ud846[\udc00-\udfff]|\ud847[\udc00-\udfff]|\ud848[\udc00-\udfff]|\ud849[\udc00-\udfff]|\ud84a[\udc00-\udfff]|\ud84b[\udc00-\udfff]|\ud84c[\udc00-\udfff]|\ud84d[\udc00-\udfff]|\ud84e[\udc00-\udfff]|\ud84f[\udc00-\udfff]|\ud850[\udc00-\udfff]|\ud851[\udc00-\udfff]|\ud852[\udc00-\udfff]|\ud853[\udc00-\udfff]|\ud854[\udc00-\udfff]|\ud855[\udc00-\udfff]|\ud856[\udc00-\udfff]|\ud857[\udc00-\udfff]|\ud858[\udc00-\udfff]|\ud859[\udc00-\udfff]|\ud85a[\udc00-\udfff]|\ud85b[\udc00-\udfff]|\ud85c[\udc00-\udfff]|\ud85d[\udc00-\udfff]|\ud85e[\udc00-\udfff]|\ud85f[\udc00-\udfff]|\ud860[\udc00-\udfff]|\ud861[\udc00-\udfff]|\ud862[\udc00-\udfff]|\ud863[\udc00-\udfff]|\ud864[\udc00-\udfff]|\ud865[\udc00-\udfff]|\ud866[\udc00-\udfff]|\ud867[\udc00-\udfff]|\ud868[\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|\ud86a[\udc00-\udfff]|\ud86b[\udc00-\udfff]|\ud86c[\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]|\ud87e[\udc00-\ude1d]|\udb40[\udd00-\uddef]/,nT=/A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u052f\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07ca-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0-\u08b2\u08e4-\u0963\u0971-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09f0\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a70-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0c00-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c81-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0cf1\u0cf2\u0d01-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u103f\u1050-\u108f\u109a-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16f1-\u16f8\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u180b-\u180d\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191e\u1920-\u192b\u1930-\u193b\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f\u1aa7\u1ab0-\u1abe\u1b00-\u1b4b\u1b6b-\u1b73\u1b80-\u1baf\u1bba-\u1bf3\u1c00-\u1c37\u1c4d-\u1c4f\u1c5a-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1cf8\u1cf9\u1d00-\u1df5\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u20d0-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005\u3006\u302a-\u302f\u3031-\u3035\u303b\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua672\ua674-\ua67d\ua67f-\ua69d\ua69f-\ua6e5\ua6f0\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua7ad\ua7b0\ua7b1\ua7f7-\ua827\ua840-\ua873\ua880-\ua8c4\ua8e0-\ua8f7\ua8fb\ua90a-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf\ua9e0-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa36\uaa40-\uaa4d\uaa60-\uaa76\uaa7a-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab5f\uab64\uab65\uabc0-\uabea\uabec\uabed\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf870-\uf87f\uf882\uf884-\uf89f\uf8b8\uf8c1-\uf8d6\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe2d\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc/,rT=/[\uD800-\uDBFF][\uDC00-\uDFFF]/gm,pz=ft(/(?:[#{bmpLetterAndMarks}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}))/,{bmpLetterAndMarks:nT,nonBmpCodePairs:rT,astralLetterAndMarks:tT}),mz=/\ud801[\udca0-\udca9]|\ud804[\udc66-\udc6f\udcf0-\udcf9\udd36-\udd3f\uddd0-\uddd9\udef0-\udef9]|\ud805[\udcd0-\udcd9\ude50-\ude59\udec0-\udec9]|\ud806[\udce0-\udce9]|\ud81a[\ude60-\ude69\udf50-\udf59]|\ud835[\udfce-\udfff]/,gz=/0-9\u0660-\u0669\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0de6-\u0def\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\ua9f0-\ua9f9\uaa50-\uaa59\uabf0-\uabf9\uff10-\uff19/,vz=/_\u200c\u200d\ua67e\u05be\u05f3\u05f4\uff5e\u301c\u309b\u309c\u30a0\u30fb\u3003\u0f0b\u0f0c\xb7/,sT=ft(/(?:[#{bmpLetterAndMarks}#{bmpNumerals}#{hashtagSpecialChars}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}|#{astralNumerals}))/,{bmpLetterAndMarks:nT,bmpNumerals:gz,hashtagSpecialChars:vz,nonBmpCodePairs:rT,astralLetterAndMarks:tT,astralNumerals:mz}),yz=/(?:[^\uD800-\uDFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF])/,bz=ft(/(?:^|\uFE0E|\uFE0F|$|(?!#{hashtagAlphaNumeric}|&)#{codePoint})/,{codePoint:yz,hashtagAlphaNumeric:sT});ft(/(#{hashtagBoundary})(#{hashSigns})(?!\uFE0F|\u20E3)(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi,{hashtagBoundary:bz,hashSigns:HC,hashtagAlphaNumeric:sT,hashtagAlpha:pz});var q0=/[@@]/;ft(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/,{atSigns:q0,latinAccentChars:Bd});var xz=/(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:^|[^a-zA-Z0-9_+~.-])(?:rt|RT|rT|Rt):?)/,wz=ft("(#{validMentionPrecedingChars})(#{atSigns})([a-zA-Z0-9_]{1,20})(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?",{validMentionPrecedingChars:xz,atSigns:q0},"g"),lk={},ck={},uk;function kz(){return uk||(uk=1,Er()&&/./g.flags!="g"&&zr().f(RegExp.prototype,"flags",{configurable:!0,get:Id()})),ck}var dk;function Sz(){if(dk)return lk;dk=1,kz();var t=cr(),e=Id(),n=Er(),r="toString",s=/./[r],i=function(o){Ss()(RegExp.prototype,r,o,!0)};return Br()(function(){return s.call({source:"a",flags:"b"})!="/a/b"})?i(function(){var l=t(this);return"/".concat(l.source,"/","flags"in l?l.flags:!n&&l instanceof RegExp?e.call(l):void 0)}):s.name!=r&&i(function(){return s.call(this)}),lk}Sz();var fk={},hk;function Ez(){if(hk)return fk;hk=1;var t=Date.prototype,e="Invalid Date",n="toString",r=t[n],s=t.getTime;return new Date(NaN)+""!=e&&Ss()(t,n,function(){var o=s.call(this);return o===o?r.call(this):e}),fk}Ez();var pk={},mk;function _z(){if(mk)return pk;mk=1;var t=I0(),e={};return e[bn()("toStringTag")]="z",e+""!="[object z]"&&Ss()(Object.prototype,"toString",function(){return"[object "+t(this)+"]"},!0),pk}_z();const gk={defaults:{version:3,maxWeightedTweetLength:280,scale:100,defaultWeight:200,emojiParsingEnabled:!0,transformedURLLength:23,ranges:[{start:0,end:4351,weight:100},{start:8192,end:8205,weight:100},{start:8208,end:8223,weight:100},{start:8242,end:8247,weight:100}]}};ft(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/,{atSigns:q0,spaces:UC});var vk={},cm,yk;function V0(){if(yk)return cm;yk=1;var t=Od();return cm=Array.isArray||function(n){return t(n)=="Array"},cm}var bk;function Nz(){if(bk)return vk;bk=1;var t=tr();return t(t.S,"Array",{isArray:V0()}),vk}Nz();var Cz=function(e,n){var r=n.defaultWeight,s=n.ranges,i=r,o=e.charCodeAt(0);if(Array.isArray(s))for(var l=0,u=s.length;l<u;l++){var f=s[l];if(o>=f.start&&o<=f.end){i=f.weight;break}}return i},xk={},um,wk;function Tz(){if(wk)return um;wk=1;var t=Ld(),e=fi(),n=z0(),r=Zi();return um=function(s,i,o,l,u){t(i);var f=e(s),p=n(f),m=r(f.length),g=u?m-1:0,y=u?-1:1;if(o<2)for(;;){if(g in p){l=p[g],g+=y;break}if(g+=y,u?g<0:m<=g)throw TypeError("Reduce of empty array with no initial value")}for(;u?g>=0:m>g;g+=y)g in p&&(l=i(l,p[g],g,f));return l},um}var kk;function Mz(){if(kk)return xk;kk=1;var t=tr(),e=Tz();return t(t.P+t.F*!xl()([].reduce,!0),"Array",{reduce:function(r){return e(this,r,arguments.length,arguments[1],!1)}}),xk}Mz();var Sk={},dm,Ek;function Az(){if(Ek)return dm;Ek=1;var t=bn()("unscopables"),e=Array.prototype;return e[t]==null&&hi()(e,t,{}),dm=function(n){e[t][n]=!0},dm}var fm,_k;function Oz(){return _k||(_k=1,fm=function(t,e){return{value:e,done:!!t}}),fm}var hm,Nk;function wl(){return Nk||(Nk=1,hm={}),hm}var pm,Ck;function kl(){if(Ck)return pm;Ck=1;var t=zC(),e=H0();return pm=Object.keys||function(r){return t(r,e)},pm}var mm,Tk;function iT(){if(Tk)return mm;Tk=1;var t=zr(),e=cr(),n=kl();return mm=Er()?Object.defineProperties:function(s,i){e(s);for(var o=n(i),l=o.length,u=0,f;l>u;)t.f(s,f=o[u++],i[f]);return s},mm}var gm,Mk;function Rz(){if(Mk)return gm;Mk=1;var t=Sr().document;return gm=t&&t.documentElement,gm}var vm,Ak;function oT(){if(Ak)return vm;Ak=1;var t=cr(),e=iT(),n=H0(),r=U0()("IE_PROTO"),s=function(){},i="prototype",o=function(){var l=LC()("iframe"),u=n.length,f="<",p=">",m;for(l.style.display="none",Rz().appendChild(l),l.src="javascript:",m=l.contentWindow.document,m.open(),m.write(f+"script"+p+"document.F=Object"+f+"/script"+p),m.close(),o=m.F;u--;)delete o[i][n[u]];return o()};return vm=Object.create||function(u,f){var p;return u!==null?(s[i]=t(u),p=new s,s[i]=null,p[r]=u):p=o(),f===void 0?p:e(p,f)},vm}var ym,Ok;function K0(){if(Ok)return ym;Ok=1;var t=zr().f,e=eo(),n=bn()("toStringTag");return ym=function(r,s,i){r&&!e(r=i?r:r.prototype,n)&&t(r,n,{configurable:!0,value:s})},ym}var bm,Rk;function jz(){if(Rk)return bm;Rk=1;var t=oT(),e=bl(),n=K0(),r={};return hi()(r,bn()("iterator"),function(){return this}),bm=function(s,i,o){s.prototype=t(r,{next:e(1,o)}),n(s,i+" Iterator")},bm}var xm,jk;function Iz(){if(jk)return xm;jk=1;var t=eo(),e=fi(),n=U0()("IE_PROTO"),r=Object.prototype;return xm=Object.getPrototypeOf||function(s){return s=e(s),t(s,n)?s[n]:typeof s.constructor=="function"&&s instanceof s.constructor?s.constructor.prototype:s instanceof Object?r:null},xm}var wm,Ik;function aT(){if(Ik)return wm;Ik=1;var t=Rd(),e=tr(),n=Ss(),r=hi(),s=wl(),i=jz(),o=K0(),l=Iz(),u=bn()("iterator"),f=!([].keys&&"next"in[].keys()),p="@@iterator",m="keys",g="values",y=function(){return this};return wm=function(b,k,w,E,N,O,T){i(w,k,E);var C=function(Z){if(!f&&Z in z)return z[Z];switch(Z){case m:return function(){return new w(this,Z)};case g:return function(){return new w(this,Z)}}return function(){return new w(this,Z)}},R=k+" Iterator",L=N==g,D=!1,z=b.prototype,F=z[u]||z[p]||N&&z[N],J=F||C(N),K=N?L?C("entries"):J:void 0,X=k=="Array"&&z.entries||F,W,$,U;if(X&&(U=l(X.call(new b)),U!==Object.prototype&&U.next&&(o(U,R,!0),!t&&typeof U[u]!="function"&&r(U,u,y))),L&&F&&F.name!==g&&(D=!0,J=function(){return F.call(this)}),(!t||T)&&(f||D||!z[u])&&r(z,u,J),s[k]=J,s[R]=y,N)if(W={values:L?J:C(g),keys:O?J:C(m),entries:K},T)for($ in W)$ in z||n(z,$,W[$]);else e(e.P+e.F*(f||D),k,W);return W},wm}var km,Lk;function lT(){if(Lk)return km;Lk=1;var t=Az(),e=Oz(),n=wl(),r=to();return km=aT()(Array,"Array",function(s,i){this._t=r(s),this._i=0,this._k=i},function(){var s=this._t,i=this._k,o=this._i++;return!s||o>=s.length?(this._t=void 0,e(1)):i=="keys"?e(0,o):i=="values"?e(0,s[o]):e(0,[o,s[o]])},"values"),n.Arguments=n.Array,t("keys"),t("values"),t("entries"),km}var Dk;function Lz(){if(Dk)return Sk;Dk=1;for(var t=lT(),e=kl(),n=Ss(),r=Sr(),s=hi(),i=wl(),o=bn(),l=o("iterator"),u=o("toStringTag"),f=i.Array,p={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},m=e(p),g=0;g<m.length;g++){var y=m[g],b=p[y],k=r[y],w=k&&k.prototype,E;if(w&&(w[l]||s(w,l,f),w[u]||s(w,u,y),i[y]=f,b))for(E in t)w[E]||n(w,E,t[E],!0)}return Sk}Lz();lT();var Pk={},Sm,Bk;function Dz(){if(Bk)return Sm;Bk=1;var t=tr(),e=Jo(),n=Br();return Sm=function(r,s){var i=(e.Object||{})[r]||Object[r],o={};o[r]=s(i),t(t.S+t.F*n(function(){i(1)}),"Object",o)},Sm}var zk;function Pz(){if(zk)return Pk;zk=1;var t=fi(),e=kl();return Dz()("keys",function(){return function(r){return e(t(r))}}),Pk}Pz();var Bz=ft(/[#{invalidCharsGroup}]/,{invalidCharsGroup:W0});function zz(t){return Bz.test(t)}var ji={},iu={},Fk;function Fz(){return Fk||(Fk=1,Object.defineProperty(iu,"__esModule",{value:!0}),iu.default=/(?:\ud83d[\udc68\udc69])(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddb0-\uddb3])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a-\udc6d\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\udeeb\udeec\udef4-\udef9]|\ud83e[\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd40-\udd45\udd47-\udd70\udd73-\udd76\udd7a\udd7c-\udda2\uddb4\uddb7\uddc0-\uddc2\uddd0\uddde-\uddff]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g),iu}var $k;function $z(){if($k)return ji;$k=1,Object.defineProperty(ji,"__esModule",{value:!0}),ji.TypeName=void 0,ji.parse=s,ji.toCodePoints=u;var t=Fz(),e=n(t);function n(f){return f&&f.__esModule?f:{default:f}}var r=ji.TypeName="emoji";function s(f,p){var m=p&&p.assetType?p.assetType:"svg",g=p&&p.buildUrl?p.buildUrl:function(E,N){return N==="png"?"https://twemoji.maxcdn.com/2/72x72/"+E+".png":"https://twemoji.maxcdn.com/2/svg/"+E+".svg"},y=[];for(e.default.lastIndex=0;;){var b=e.default.exec(f);if(!b)break;var k=b[0],w=u(l(k)).join("-");y.push({url:w?g(w,m):"",indices:[b.index,e.default.lastIndex],text:k,type:r})}return y}var i=/\uFE0F/g,o="‍",l=function(p){return p.indexOf(o)<0?p.replace(i,""):p};function u(f){for(var p=[],m=0,g=0,y=0;y<f.length;)m=f.charCodeAt(y++),g?(p.push((65536+(g-55296<<10)+(m-56320)).toString(16)),g=0):m>55296&&m<=56319?g=m:p.push(m.toString(16));return p}return ji}var Uz=$z(),Hz=function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:gk.defaults,r=Object.keys(n).length?n:gk.defaults,s=r.defaultWeight,i=r.emojiParsingEnabled,o=r.scale,l=r.maxWeightedTweetLength,u=r.transformedURLLength,f=typeof String.prototype.normalize=="function"?e.normalize():e,p=Uk(dz(f)),m=i?Uk(Uz.parse(f)):[],g=f.length,y=0,b=0,k=!0,w=0;w<g;w++){if(p[w]){var E=p[w],N=E.url;E.indices,y+=u*o,w+=N.length-1}else if(i&&m[w]){var O=m[w],T=O.text;O.indices,y+=s,w+=T.length-1}else w+=Wz(f,w)?1:0,y+=Cz(f.charAt(w),r);k&&(k=!zz(f.substring(w,w+1))),k&&y<=l*o&&(b=w)}y=y/o,k=k&&y>0&&y<=l;var C=Math.floor(y/l*1e3),R=e.length-f.length;return b+=R,{weightedLength:y,valid:k,permillage:C,validRangeStart:0,validRangeEnd:b,displayRangeStart:0,displayRangeEnd:e.length>0?e.length-1:0}},Uk=function(e){return e.reduce(function(n,r){return n[r.indices[0]]=r,n},{})},Wz=function(e,n){if(n<e.length-1){var r=e.charCodeAt(n),s=e.charCodeAt(n+1);return 55296<=r&&r<=56319&&56320<=s&&s<=57343}return!1},Hk={},Wk;function qz(){if(Wk)return Hk;Wk=1;var t=tr();return t(t.S+t.F*!Er(),"Object",{defineProperty:zr().f}),Hk}qz();var qk={},Vk;function Vz(){if(Vk)return qk;Vk=1;var t=tr();return t(t.S+t.F*!Er(),"Object",{defineProperties:iT()}),qk}Vz();var Kk={},Em={},Gk;function G0(){return Gk||(Gk=1,Em.f=Object.getOwnPropertySymbols),Em}var _m,Jk;function Kz(){if(Jk)return _m;Jk=1;var t=Pd(),e=G0(),n=cr(),r=Sr().Reflect;return _m=r&&r.ownKeys||function(i){var o=t.f(n(i)),l=e.f;return l?o.concat(l(i)):o},_m}var Nm,Yk;function cT(){if(Yk)return Nm;Yk=1;var t=zr(),e=bl();return Nm=function(n,r,s){r in n?t.f(n,r,e(0,s)):n[r]=s},Nm}var Qk;function Gz(){if(Qk)return Kk;Qk=1;var t=tr(),e=Kz(),n=to(),r=$0(),s=cT();return t(t.S,"Object",{getOwnPropertyDescriptors:function(o){for(var l=n(o),u=r.f,f=e(l),p={},m=0,g,y;f.length>m;)y=u(l,g=f[m++]),y!==void 0&&s(p,g,y);return p}}),Kk}Gz();var Xk={},Cm,Zk;function Jz(){if(Zk)return Cm;Zk=1;var t=ks(),e=V0(),n=bn()("species");return Cm=function(r){var s;return e(r)&&(s=r.constructor,typeof s=="function"&&(s===Array||e(s.prototype))&&(s=void 0),t(s)&&(s=s[n],s===null&&(s=void 0))),s===void 0?Array:s},Cm}var Tm,eS;function Yz(){if(eS)return Tm;eS=1;var t=Jz();return Tm=function(e,n){return new(t(e))(n)},Tm}var Mm,tS;function uT(){if(tS)return Mm;tS=1;var t=Dd(),e=z0(),n=fi(),r=Zi(),s=Yz();return Mm=function(i,o){var l=i==1,u=i==2,f=i==3,p=i==4,m=i==6,g=i==5||m,y=o||s;return function(b,k,w){for(var E=n(b),N=e(E),O=t(k,w,3),T=r(N.length),C=0,R=l?y(b,T):u?y(b,0):void 0,L,D;T>C;C++)if((g||C in N)&&(L=N[C],D=O(L,C,E),i)){if(l)R[C]=D;else if(D)switch(i){case 3:return!0;case 5:return L;case 6:return C;case 2:R.push(L)}else if(p)return!1}return m?-1:f||p?p:R}},Mm}var nS;function Qz(){if(nS)return Xk;nS=1;var t=tr(),e=uT()(0),n=xl()([].forEach,!0);return t(t.P+t.F*!n,"Array",{forEach:function(s){return e(this,s,arguments[1])}}),Xk}Qz();var rS={},sS;function Xz(){if(sS)return rS;sS=1;var t=tr(),e=uT()(2);return t(t.P+t.F*!xl()([].filter,!0),"Array",{filter:function(r){return e(this,r,arguments[1])}}),rS}Xz();var iS={},Am={exports:{}},oS;function Zz(){if(oS)return Am.exports;oS=1;var t=yl()("meta"),e=ks(),n=eo(),r=zr().f,s=0,i=Object.isExtensible||function(){return!0},o=!Br()(function(){return i(Object.preventExtensions({}))}),l=function(g){r(g,t,{value:{i:"O"+ ++s,w:{}}})},u=function(g,y){if(!e(g))return typeof g=="symbol"?g:(typeof g=="string"?"S":"P")+g;if(!n(g,t)){if(!i(g))return"F";if(!y)return"E";l(g)}return g[t].i},f=function(g,y){if(!n(g,t)){if(!i(g))return!0;if(!y)return!1;l(g)}return g[t].w},p=function(g){return o&&m.NEED&&i(g)&&!n(g,t)&&l(g),g},m=Am.exports={KEY:t,NEED:!1,fastKey:u,getWeak:f,onFreeze:p};return Am.exports}var Om={},aS;function dT(){return aS||(aS=1,Om.f=bn()),Om}var Rm,lS;function e8(){if(lS)return Rm;lS=1;var t=Sr(),e=Jo(),n=Rd(),r=dT(),s=zr().f;return Rm=function(i){var o=e.Symbol||(e.Symbol=n?{}:t.Symbol||{});i.charAt(0)!="_"&&!(i in o)&&s(o,i,{value:r.f(i)})},Rm}var jm,cS;function t8(){if(cS)return jm;cS=1;var t=kl(),e=G0(),n=F0();return jm=function(r){var s=t(r),i=e.f;if(i)for(var o=i(r),l=n.f,u=0,f;o.length>u;)l.call(r,f=o[u++])&&s.push(f);return s},jm}var Im={},uS;function n8(){if(uS)return Im;uS=1;var t=to(),e=Pd().f,n={}.toString,r=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(i){try{return e(i)}catch{return r.slice()}};return Im.f=function(o){return r&&n.call(o)=="[object Window]"?s(o):e(t(o))},Im}var dS;function r8(){if(dS)return iS;dS=1;var t=Sr(),e=eo(),n=Er(),r=tr(),s=Ss(),i=Zz().KEY,o=Br(),l=jd(),u=K0(),f=yl(),p=bn(),m=dT(),g=e8(),y=t8(),b=V0(),k=cr(),w=ks(),E=fi(),N=to(),O=P0(),T=bl(),C=oT(),R=n8(),L=$0(),D=G0(),z=zr(),F=kl(),J=L.f,K=z.f,X=R.f,W=t.Symbol,$=t.JSON,U=$&&$.stringify,Z="prototype",V=p("_hidden"),Y=p("toPrimitive"),I={}.propertyIsEnumerable,A=l("symbol-registry"),j=l("symbols"),Q=l("op-symbols"),oe=Object[Z],fe=typeof W=="function"&&!!D.f,G=t.QObject,le=!G||!G[Z]||!G[Z].findChild,Te=n&&o(function(){return C(K({},"a",{get:function(){return K(this,"a",{value:7}).a}})).a!=7})?function(Ae,be,ke){var ze=J(oe,be);ze&&delete oe[be],K(Ae,be,ke),ze&&Ae!==oe&&K(oe,be,ze)}:K,Ve=function(Ae){var be=j[Ae]=C(W[Z]);return be._k=Ae,be},ce=fe&&typeof W.iterator=="symbol"?function(Ae){return typeof Ae=="symbol"}:function(Ae){return Ae instanceof W},ue=function(be,ke,ze){return be===oe&&ue(Q,ke,ze),k(be),ke=O(ke,!0),k(ze),e(j,ke)?(ze.enumerable?(e(be,V)&&be[V][ke]&&(be[V][ke]=!1),ze=C(ze,{enumerable:T(0,!1)})):(e(be,V)||K(be,V,T(1,{})),be[V][ke]=!0),Te(be,ke,ze)):K(be,ke,ze)},ae=function(be,ke){k(be);for(var ze=y(ke=N(ke)),ht=0,wt=ze.length,kt;wt>ht;)ue(be,kt=ze[ht++],ke[kt]);return be},je=function(be,ke){return ke===void 0?C(be):ae(C(be),ke)},Me=function(be){var ke=I.call(this,be=O(be,!0));return this===oe&&e(j,be)&&!e(Q,be)?!1:ke||!e(this,be)||!e(j,be)||e(this,V)&&this[V][be]?ke:!0},He=function(be,ke){if(be=N(be),ke=O(ke,!0),!(be===oe&&e(j,ke)&&!e(Q,ke))){var ze=J(be,ke);return ze&&e(j,ke)&&!(e(be,V)&&be[V][ke])&&(ze.enumerable=!0),ze}},Ne=function(be){for(var ke=X(N(be)),ze=[],ht=0,wt;ke.length>ht;)!e(j,wt=ke[ht++])&&wt!=V&&wt!=i&&ze.push(wt);return ze},tt=function(be){for(var ke=be===oe,ze=X(ke?Q:N(be)),ht=[],wt=0,kt;ze.length>wt;)e(j,kt=ze[wt++])&&(!ke||e(oe,kt))&&ht.push(j[kt]);return ht};fe||(W=function(){if(this instanceof W)throw TypeError("Symbol is not a constructor!");var be=f(arguments.length>0?arguments[0]:void 0),ke=function(ze){this===oe&&ke.call(Q,ze),e(this,V)&&e(this[V],be)&&(this[V][be]=!1),Te(this,be,T(1,ze))};return n&&le&&Te(oe,be,{configurable:!0,set:ke}),Ve(be)},s(W[Z],"toString",function(){return this._k}),L.f=He,z.f=ue,Pd().f=R.f=Ne,F0().f=Me,D.f=tt,n&&!Rd()&&s(oe,"propertyIsEnumerable",Me,!0),m.f=function(Ae){return Ve(p(Ae))}),r(r.G+r.W+r.F*!fe,{Symbol:W});for(var Be="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),$e=0;Be.length>$e;)p(Be[$e++]);for(var ye=F(p.store),pe=0;ye.length>pe;)g(ye[pe++]);r(r.S+r.F*!fe,"Symbol",{for:function(Ae){return e(A,Ae+="")?A[Ae]:A[Ae]=W(Ae)},keyFor:function(be){if(!ce(be))throw TypeError(be+" is not a symbol!");for(var ke in A)if(A[ke]===be)return ke},useSetter:function(){le=!0},useSimple:function(){le=!1}}),r(r.S+r.F*!fe,"Object",{create:je,defineProperty:ue,defineProperties:ae,getOwnPropertyDescriptor:He,getOwnPropertyNames:Ne,getOwnPropertySymbols:tt});var Ze=o(function(){D.f(1)});return r(r.S+r.F*Ze,"Object",{getOwnPropertySymbols:function(be){return D.f(E(be))}}),$&&r(r.S+r.F*(!fe||o(function(){var Ae=W();return U([Ae])!="[null]"||U({a:Ae})!="{}"||U(Object(Ae))!="{}"})),"JSON",{stringify:function(be){for(var ke=[be],ze=1,ht,wt;arguments.length>ze;)ke.push(arguments[ze++]);if(wt=ht=ke[1],!(!w(ht)&&be===void 0||ce(be)))return b(ht)||(ht=function(kt,Bt){if(typeof wt=="function"&&(Bt=wt.call(this,kt,Bt)),!ce(Bt))return Bt}),ke[1]=ht,U.apply($,ke)}}),W[Z][Y]||hi()(W[Z],Y,W[Z].valueOf),u(W,"Symbol"),u(Math,"Math",!0),u(t.JSON,"JSON",!0),iS}r8();ft(/^#{validMentionOrList}$/,{validMentionOrList:wz});var fT=/[a-z\u0400-\u04FF0-9\-._~]/i,hT=/(?:%[0-9a-f]{2})/i,pT=/[!$&'()*+,;=]/i,mT=ft("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:)*",{validateUrlUnreserved:fT,validateUrlPctEncoded:hT,validateUrlSubDelims:pT},"i"),s8=/(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i,i8=/(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i,o8=/(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i,a8=ft(/(?:(?:#{validateUrlSubDomainSegment}\.)*(?:#{validateUrlDomainSegment}\.)#{validateUrlDomainTld})/i,{validateUrlSubDomainSegment:o8,validateUrlDomainSegment:s8,validateUrlDomainTld:i8}),l8=/(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i,c8=ft(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i,{validateUrlDecOctet:l8}),u8=/(?:\[[a-f0-9:\.]+\])/i,gT=ft("(?:#{validateUrlIpv4}|#{validateUrlIpv6})",{validateUrlIpv4:c8,validateUrlIpv6:u8},"i"),d8=ft("(?:#{validateUrlIp}|#{validateUrlDomain})",{validateUrlIp:gT,validateUrlDomain:a8},"i"),vT=/[0-9]{1,5}/;ft("(?:(#{validateUrlUserinfo})@)?(#{validateUrlHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:mT,validateUrlHost:d8,validateUrlPort:vT},"i");var J0=ft("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|[:|@])",{validateUrlUnreserved:fT,validateUrlPctEncoded:hT,validateUrlSubDelims:pT},"i");ft(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:J0});ft(/(\/#{validateUrlPchar}*)*/i,{validateUrlPchar:J0});ft(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:J0});ft("^(?:([^:/?#]+):\\/\\/)?([^/?#]*)([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$","i");var f8=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,h8=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,p8=/(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,m8=ft(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i,{validateUrlUnicodeSubDomainSegment:f8,validateUrlUnicodeDomainSegment:h8,validateUrlUnicodeDomainTld:p8}),g8=ft("(?:#{validateUrlIp}|#{validateUrlUnicodeDomain})",{validateUrlIp:gT,validateUrlUnicodeDomain:m8},"i");ft("(?:(#{validateUrlUserinfo})@)?(#{validateUrlUnicodeHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:mT,validateUrlUnicodeHost:g8,validateUrlPort:vT},"i");var fS={},hS;function v8(){if(hS)return fS;hS=1;var t=IC()(!0);return aT()(String,"String",function(e){this._t=String(e),this._i=0},function(){var e=this._t,n=this._i,r;return n>=e.length?{value:void 0,done:!0}:(r=t(e,n),this._i+=r.length,{value:r,done:!1})}),fS}v8();var pS={},Lm,mS;function y8(){if(mS)return Lm;mS=1;var t=cr();return Lm=function(e,n,r,s){try{return s?n(t(r)[0],r[1]):n(r)}catch(o){var i=e.return;throw i!==void 0&&t(i.call(e)),o}},Lm}var Dm,gS;function b8(){if(gS)return Dm;gS=1;var t=wl(),e=bn()("iterator"),n=Array.prototype;return Dm=function(r){return r!==void 0&&(t.Array===r||n[e]===r)},Dm}var Pm,vS;function x8(){if(vS)return Pm;vS=1;var t=I0(),e=bn()("iterator"),n=wl();return Pm=Jo().getIteratorMethod=function(r){if(r!=null)return r[e]||r["@@iterator"]||n[t(r)]},Pm}var Bm,yS;function w8(){if(yS)return Bm;yS=1;var t=bn()("iterator"),e=!1;try{var n=[7][t]();n.return=function(){e=!0},Array.from(n,function(){throw 2})}catch{}return Bm=function(r,s){if(!s&&!e)return!1;var i=!1;try{var o=[7],l=o[t]();l.next=function(){return{done:i=!0}},o[t]=function(){return l},r(o)}catch{}return i},Bm}var bS;function k8(){if(bS)return pS;bS=1;var t=Dd(),e=tr(),n=fi(),r=y8(),s=b8(),i=Zi(),o=cT(),l=x8();return e(e.S+e.F*!w8()(function(u){Array.from(u)}),"Array",{from:function(f){var p=n(f),m=typeof this=="function"?this:Array,g=arguments.length,y=g>1?arguments[1]:void 0,b=y!==void 0,k=0,w=l(p),E,N,O,T;if(b&&(y=t(y,g>2?arguments[2]:void 0,2)),w!=null&&!(m==Array&&s(w)))for(T=w.call(p),N=new m;!(O=T.next()).done;k++)o(N,k,b?r(T,y,[O.value,k],!0):O.value);else for(E=i(p.length),N=new m(E);E>k;k++)o(N,k,b?y(p[k],k):p[k]);return N.length=k,N}}),pS}k8();const S8={parseTweet:Hz},{parseTweet:E8}=S8;function xS(t){return E8(t).weightedLength}const wS="ow-x-handle";function _8(){const[t,e]=S.useState(()=>localStorage.getItem(wS)||""),[n,r]=S.useState(!1),[s,i]=S.useState(""),o=S.useRef(null),l=S.useRef(null),u=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(wS,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=o.current)==null?void 0:m.focus()},0)};S.useEffect(()=>{if(!n)return;const m=g=>{l.current&&!l.current.contains(g.target)&&u()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n,s]);const p=t?`https://unavatar.io/twitter/${t}`:"";return d.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:l,children:[t?d.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:p,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):d.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&d.jsx("div",{className:"tweet-handle-popover",children:d.jsx("input",{ref:o,className:"tweet-handle-input",value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&u(),m.key==="Escape"&&r(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function kS(){return d.jsxs("div",{className:"tweet-skeleton",children:[d.jsxs("div",{className:"tweet-author-row",children:[d.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),d.jsxs("div",{className:"tweet-author-info",children:[d.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),d.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),d.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),d.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function N8(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function SS(t){if(!t)return[null];if(typeof t=="string"){const e=t.split(/<hr\s*\/?>/i).map(n=>n.trim()).filter(Boolean);return e.length?e:[null]}if((t==null?void 0:t.type)==="doc"&&Array.isArray(t.content)){const e=[[]];for(const r of t.content)r.type==="horizontalRule"?e.push([]):e[e.length-1].push(r);const n=e.map(r=>r.length?{type:"doc",content:r}:null).filter(Boolean);return n.length?n:[null]}return[t]}function zm(t){const e=[],n=t.filter(Boolean);return n.forEach((r,s)=>{const i=r.getJSON();i.content&&e.push(...i.content),s<n.length-1&&e.push({type:"horizontalRule"})}),{type:"doc",content:e}}function ES(t){const e=[],n=r=>{var s;r.type==="image"&&((s=r.attrs)!=null&&s.src)&&e.push(r.attrs.src),r.content&&r.content.forEach(n)};return n(t.getJSON()),e.slice(0,4)}function Fm(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tweetContext:t}),keepalive:!0}).catch(()=>{})}function C8({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s,filename:i,title:o}){const{tweet:l,loading:u,error:f}=m5(t==null?void 0:t.url),[p,m]=S.useState(()=>SS(e)),[g,y]=S.useState(0),b=S.useRef([]),k=S.useRef(null),w=S.useRef(!0),E=S.useRef(!1),N=S.useRef(p.length),[O,T]=S.useState(()=>p.map(()=>0)),[C,R]=S.useState(0),[L,D]=S.useState(0),[z,F]=S.useState(null),[J,K]=S.useState(),[X,W]=S.useState(!1),[$,U]=S.useState("idle"),[Z,V]=S.useState(""),Y=S.useRef(),{copyText:I,copyState:A}=b5(b,C),[j,Q]=S.useState(!1);S.useEffect(()=>{let ye=!1;return(async()=>{try{const pe=await fetch("/api/x/status");if(ye)return;if(pe.ok){const Ze=await pe.json();F(Ze.connected),K(Ze.username)}else F(!1)}catch{ye||F(!1)}})(),()=>{ye=!0}},[]),S.useEffect(()=>{if(w.current){w.current=!1;return}if(!e||JSON.stringify(e)===k.current)return;const pe=SS(e);E.current=!0,N.current=pe.length,b.current=[],m(pe),T(pe.map(()=>0)),y(Ze=>Ze+1)},[e]);const oe=S.useCallback((ye,pe)=>{if(b.current[ye]=pe,T(Ae=>{const be=[...Ae];return be[ye]=xS(pe.getText()),be}),E.current)return;const Ze=zm(b.current);k.current=JSON.stringify(Ze),n==null||n(Ze)},[n]),fe=S.useCallback((ye,pe)=>{if(b.current[ye]=pe,T(Ze=>{const Ae=[...Ze];return Ae[ye]=xS(pe.getText()),Ae}),D(Ze=>Ze+1),E.current&&b.current.filter(Boolean).length>=N.current){E.current=!1;const Ae=zm(b.current);k.current=JSON.stringify(Ae)}ye===0&&(r==null||r(pe)),s==null||s(b.current.filter(Boolean))},[r,s]),G=p.length>1;O.reduce((ye,pe)=>ye+pe,0);const le=S.useCallback(()=>{const ye=C+1;m(pe=>[...pe.slice(0,ye),"<p></p>",...pe.slice(ye)]),T(pe=>[...pe.slice(0,ye),0,...pe.slice(ye)]),R(ye)},[C]),Te=S.useCallback(ye=>{ye!==0&&(b.current.splice(ye,1),m(pe=>pe.filter((Ze,Ae)=>Ae!==ye)),T(pe=>pe.filter((Ze,Ae)=>Ae!==ye)),setTimeout(()=>{const pe=zm(b.current);n==null||n(pe),s==null||s(b.current.filter(Boolean))},0))},[n,s]),Ve=!!(t!=null&&t.url),ce=(t==null?void 0:t.mode)==="reply",ue=b.current.filter(Boolean).some(pe=>pe.getText().trim()||ES(pe).length>0),ae=z&&ue&&$==="idle",je=async()=>{if(!z){W(!0);return}if(ae){U("uploading"),V("");try{const ye=b.current.filter(Boolean),pe=[];for(const Ae of ye){const be=Ae.getText().trim(),ke=ES(Ae);if(!be&&ke.length===0)continue;const ze=[];for(const ht of ke){const kt=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:ht})})).json();if(!kt.success)throw new Error(kt.error||"Image upload failed");ze.push(kt.mediaId)}pe.push({text:be,mediaIds:ze})}if(pe.length===0)return;U("posting");const Ze=N8(t==null?void 0:t.url);if(pe.length===1){const Ae={};pe[0].text&&(Ae.text=pe[0].text),pe[0].mediaIds.length>0&&(Ae.mediaIds=pe[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&Ze?Ae.replyTo=Ze:(t==null?void 0:t.mode)==="quote"&&Ze&&(Ae.quoteTweetId=Ze);const ke=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ae)})).json();ke.success?(Fm({lastPost:{postedAt:new Date().toISOString(),tweetUrl:ke.tweetUrl}}),U("success"),Y.current=setTimeout(()=>U("idle"),2500)):(console.error("[TweetCompose] Post error:",ke.error),V(ke.error||"Post failed"),U("error"),setTimeout(()=>U("idle"),3e3))}else{const be={tweets:pe.map(ht=>({text:ht.text,...ht.mediaIds.length>0?{mediaIds:ht.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&Ze&&(be.replyTo=Ze);const ze=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)})).json();ze.success?(Fm({lastPost:{postedAt:new Date().toISOString(),tweetUrl:ze.threadUrl}}),U("success"),Y.current=setTimeout(()=>U("idle"),2500)):(V(ze.error||"Thread post failed"),U("error"),setTimeout(()=>U("idle"),3e3))}}catch(ye){V(ye.message||"Network error"),U("error"),setTimeout(()=>U("idle"),3e3)}}};S.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const Me=()=>{F(!0),W(!1),fetch("/api/x/status").then(ye=>ye.json()).then(ye=>{ye.username&&K(ye.username)}).catch(()=>{})},He=$==="uploading"?"Uploading...":$==="posting"?"Posting...":$==="success"?"Posted!":$==="error"?"Failed":G?C===0?"Post Thread":"Post All":"Post",Ne=p.map((ye,pe)=>pe===0?ce?"Post your reply":"What is happening?!":"Add another tweet"),tt=ye=>{var pe;return d.jsxs("div",{className:`tweet-compose-footer${ye?" tweet-compose-footer--inline":""}`,children:[C===0&&((pe=t==null?void 0:t.lastPost)==null?void 0:pe.postedAt)&&d.jsxs("a",{className:"tweet-posted-status",href:t.lastPost.tweetUrl,target:"_blank",rel:"noopener noreferrer",title:t.lastPost.tweetUrl||"Posted to X",children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Posted ",new Date(t.lastPost.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),$==="error"&&Z&&d.jsx("span",{className:"tweet-post-error",children:Z}),G&&d.jsxs("span",{className:"tweet-thread-counter",children:[C+1,"/",p.length]}),d.jsx(T5,{count:O[C]||0}),d.jsx("button",{className:"tweet-thread-add",onClick:le,title:"Add another tweet",children:d.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[d.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),d.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),d.jsx("button",{className:`tweet-copy-btn${A==="copied"?" tweet-copy-btn--copied":""}`,disabled:!ue,onClick:I,title:"Copy tweet text to clipboard",children:A==="copied"?d.jsxs(d.Fragment,{children:[d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 8.5L6.5 12L13 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied!"]}):d.jsxs(d.Fragment,{children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[d.jsx("rect",{x:"5.5",y:"2",width:"8.5",height:"10.5",rx:"1.5",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M3.5 5H2.5A1.5 1.5 0 001 6.5V13a1.5 1.5 0 001.5 1.5H9A1.5 1.5 0 0010.5 13v-1",stroke:"currentColor",strokeWidth:"1.5"})]}),"Copy"]})}),C===0&&(()=>{var Ae;const Ze=!!((Ae=t==null?void 0:t.lastPost)!=null&&Ae.postedAt);return d.jsx("button",{className:`tweet-mark-sent-btn${Ze?" tweet-mark-sent-btn--done":""}`,onClick:()=>{Ze||Fm({lastPost:{postedAt:new Date().toISOString()}})},title:Ze?"Posted":"Mark as manually posted",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:Ze?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"8 12 11 15 16 9",stroke:Ze?"#fff":"currentColor"})]})})})(),i&&d.jsx("button",{className:"tweet-schedule-btn",onClick:()=>Q(!0),title:"Schedule post",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"12 6 12 12 16 14"})]})}),d.jsx("button",{className:`tweet-post-btn${ae||!z&&z!==null?" tweet-post-btn--active":""}${$==="success"?" tweet-post-btn--success":""}${$==="error"?" tweet-post-btn--error":""}`,disabled:z?!ae:!1,onClick:je,title:z?J?`Post as @${J}`:"Post to X":"Connect X to post",children:He})]})},Be=Ve&&!ce,$e=()=>d.jsx("div",{className:"tweet-thread-editors",children:p.map((ye,pe)=>d.jsxs("div",{className:`tweet-thread-item${pe===C?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[d.jsxs("div",{className:"tweet-thread-item-left",children:[d.jsx(_8,{}),pe<p.length-1&&d.jsx("div",{className:"tweet-thread-line"})]}),d.jsxs("div",{className:"tweet-thread-item-right",children:[pe>0&&d.jsx("button",{className:"tweet-thread-remove",onClick:()=>Te(pe),title:"Remove this tweet",children:"×"}),d.jsx("div",{className:`tweet-compose-box${pe===0&&!G?" tweet-compose-box--standalone":""}`,children:d.jsx(C5,{initialContent:ye,placeholder:Ne[pe],onUpdate:Ze=>oe(pe,Ze),onReady:Ze=>fe(pe,Ze),onFocus:()=>R(pe)})}),pe===C&&!Be&&tt(pe<p.length-1)]})]},`${g}-${pe}`))});return d.jsxs("div",{className:"tweet-compose-wrapper",children:[Ve&&ce&&d.jsxs(d.Fragment,{children:[u&&d.jsx("div",{className:"tweet-context-section",children:d.jsx(kS,{})}),f&&d.jsx("div",{className:"tweet-context-section",children:d.jsxs("div",{className:"tweet-embed-error",children:[d.jsx("span",{children:"Could not load tweet"}),d.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]})}),l&&d.jsx("div",{className:"tweet-reply-parent-section",children:d.jsxs("div",{className:"tweet-reply-thread",children:[d.jsxs("div",{className:"tweet-reply-thread-left",children:[l.author.avatarUrl?d.jsx("img",{className:"tweet-avatar",src:l.author.avatarUrl,alt:""}):d.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),d.jsx("div",{className:"tweet-reply-thread-line"})]}),d.jsxs("div",{className:"tweet-reply-thread-right",children:[d.jsxs("div",{className:"tweet-reply-parent",children:[d.jsxs("div",{className:"tweet-author-info",children:[d.jsx("span",{className:"tweet-author-name",children:l.author.name}),d.jsxs("span",{className:"tweet-author-handle",children:["@",l.author.username]})]}),d.jsx("div",{className:"tweet-text",children:l.text}),l.media&&l.media.length>0&&d.jsx("div",{className:"tweet-media",children:l.media.map((ye,pe)=>ye.type==="photo"?d.jsx("img",{className:"tweet-media-img",src:ye.url,alt:"",loading:"lazy"},pe):d.jsx("div",{className:"tweet-media-video-placeholder",children:d.jsx("span",{children:"Video"})},pe))})]}),d.jsxs("div",{className:"tweet-replying-to-inline",children:["Replying to ",d.jsxs("span",{className:"tweet-reply-handle",children:["@",l.author.username]})]})]})]})}),$e()]}),Be&&d.jsxs(d.Fragment,{children:[$e(),d.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[u&&d.jsx(kS,{}),f&&d.jsxs("div",{className:"tweet-embed-error",children:[d.jsx("span",{children:"Could not load tweet"}),d.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]}),l&&d.jsx(N5,{tweet:l,url:t==null?void 0:t.url})]}),d.jsx("div",{className:"tweet-quote-footer",children:tt()})]}),!Ve&&$e(),X&&d.jsx(M5,{onConnected:Me,onCancel:()=>W(!1)}),j&&i&&d.jsx(Td,{filename:i,title:o||"Untitled",onClose:()=>Q(!1)})]})}function T8(){const[t,e]=S.useState("idle"),n=S.useRef();return{copyAsHtml:S.useCallback(async()=>{const s=document.querySelector(".ProseMirror");if(!s)return;const i=s.cloneNode(!0);i.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(p=>p.remove());let o="";const l=document.querySelector(".article-title-input");l!=null&&l.value&&l.value!=="Untitled"&&(o+=`<h1>${l.value}</h1>
208
+ `);const u=o+i.innerHTML,f=M8(i);try{const p=new ClipboardItem({"text/html":new Blob([u],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})});await navigator.clipboard.write([p])}catch{try{await navigator.clipboard.writeText(f)}catch{const p=document.createElement("textarea");p.value=f,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function M8(t){var n;const e=[];for(const r of t.children){const s=(n=r.innerText)==null?void 0:n.trim();s&&e.push(s)}return e.join(`
209
+
210
+ `)}const $m="ow-x-handle",_S="ow-x-name",A8=new Set(["Untitled","New Document","Article"]);function O8({src:t,coverImages:e}){const[n,r]=S.useState(t?"display":"empty"),[s,i]=S.useState(t||""),[o,l]=S.useState(e||(t?[t]:[])),[u,f]=S.useState(""),[p,m]=S.useState(""),g=S.useRef(null);S.useEffect(()=>{t?(i(t),r("display")):e&&e.length>0?(i(e[0]),r("display")):(i(""),r("empty"),f(""),m(""))},[t,e]),S.useEffect(()=>{e&&e.length>0?l(e):l(t?[t]:[])},[e]);const y=s?o.indexOf(s):-1,b=o.length,k=b>1,w=S.useCallback(z=>{const F=o[z];F&&(i(F),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:F,coverImages:o}})}).catch(()=>{}))},[o]),E=S.useCallback(()=>{y>0&&w(y-1)},[y,w]),N=S.useCallback(()=>{y<b-1&&w(y+1)},[y,b,w]),O=S.useCallback(async()=>{if(u.trim()){r("loading"),m("");try{const F=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(F.success&&F.src){const J=[...o,F.src];l(J),i(F.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:F.src,coverImages:J}})}).catch(()=>{})}else m(F.error||"Generation failed"),r("prompt")}catch(z){m(z.message||"Network error"),r("prompt")}}},[u,o]),T=z=>{z.key==="Enter"&&O(),z.key==="Escape"&&(r("empty"),f(""),m(""))},C=()=>{r("prompt"),setTimeout(()=>{var z;return(z=g.current)==null?void 0:z.focus()},0)},R=()=>{const z=o.filter(F=>F!==s);if(l(z),z.length>0){const F=Math.min(y,z.length-1),J=z[F];i(J),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:J,coverImages:z}})}).catch(()=>{})}else i(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},L=()=>{r("prompt"),setTimeout(()=>{var z;return(z=g.current)==null?void 0:z.focus()},0)},D=()=>{const z=document.createElement("a");z.href=s,z.download=`cover-${y+1}.png`,z.click()};return n==="display"&&s?d.jsxs("div",{className:"article-cover article-cover--display",children:[d.jsx("img",{className:"article-cover-img",src:s,alt:"Cover"}),d.jsxs("div",{className:"article-cover-overlay",children:[k&&d.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:E,disabled:y<=0,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"15 18 9 12 15 6"})})}),d.jsxs("div",{className:"article-cover-overlay-center",children:[d.jsxs("button",{className:"article-cover-overlay-btn",onClick:L,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"23 4 23 10 17 10"}),d.jsx("polyline",{points:"1 20 1 14 7 14"}),d.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),d.jsxs("button",{className:"article-cover-overlay-btn",onClick:D,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),d.jsx("polyline",{points:"7 10 12 15 17 10"}),d.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),d.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:R,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),k&&d.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:N,disabled:y>=b-1,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})})}),k&&d.jsxs("div",{className:"article-cover-counter",children:[y+1," / ",b]})]})]}):n==="loading"?d.jsxs("div",{className:"article-cover article-cover--loading",children:[d.jsx("div",{className:"article-cover-spinner"}),d.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?d.jsxs("div",{className:"article-cover article-cover--prompt",children:[d.jsxs("div",{className:"article-cover-prompt-row",children:[d.jsx("input",{ref:g,className:"article-cover-prompt-input",value:u,onChange:z=>f(z.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),d.jsx("button",{className:"article-cover-prompt-btn",onClick:O,disabled:!u.trim(),children:"Generate"}),d.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&d.jsx("div",{className:"article-cover-error",children:p})]}):d.jsxs("div",{className:"article-cover article-cover--empty",onClick:C,children:[d.jsxs("svg",{className:"article-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("polyline",{points:"21 15 16 10 5 21"})]}),d.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function R8(){const[t,e]=S.useState(()=>localStorage.getItem($m)||""),[n,r]=S.useState(()=>localStorage.getItem(_S)||""),[s,i]=S.useState(!1),[o,l]=S.useState(""),u=S.useRef(null),f=S.useRef(null),p=()=>{const b=o.replace(/^@/,"").trim();b&&(localStorage.setItem($m,b),e(b)),i(!1)},m=()=>{l(t),i(!0),setTimeout(()=>{var b;return(b=u.current)==null?void 0:b.focus()},0)};S.useEffect(()=>{if(!s)return;const b=k=>{f.current&&!f.current.contains(k.target)&&p()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s,o]),S.useEffect(()=>{const b=()=>{e(localStorage.getItem($m)||""),r(localStorage.getItem(_S)||"")};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[]);const g=t?`https://unavatar.io/twitter/${t}`:"",y=n||t||"Set your @handle";return d.jsxs("div",{className:"article-byline",ref:f,children:[d.jsxs("div",{className:"article-byline-row",onClick:m,title:t?`@${t} — click to change`:"Set your @handle",children:[t?d.jsx("img",{className:"article-byline-avatar",src:g,alt:`@${t}`}):d.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),d.jsx("span",{className:"article-byline-name",children:y}),t&&d.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),s&&d.jsx("div",{className:"article-byline-popover",children:d.jsx("input",{ref:u,className:"article-byline-input",value:o,onChange:b=>l(b.target.value),onKeyDown:b=>{b.key==="Enter"&&p(),b.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function j8({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s,lastPost:i}){const{copyAsHtml:o,copyState:l}=T8(),[u,f]=S.useState(i?"done":"idle");S.useEffect(()=>{f(i?"done":"idle")},[i]);const p=S.useCallback(()=>{u==="idle"&&(fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:{postedAt:new Date().toISOString()}}}),keepalive:!0}).catch(()=>{}),f("done"))},[u]);return d.jsxs("div",{className:"article-compose-wrapper",children:[d.jsx(O8,{src:r,coverImages:s}),d.jsxs("div",{className:"article-compose-content",children:[d.jsx("input",{className:"article-title-input",type:"text",value:A8.has(e||"")?"":e||"",onChange:m=>n==null?void 0:n(m.target.value||"Untitled"),placeholder:"Add a title",spellCheck:!1}),d.jsx(R8,{}),d.jsx("div",{className:"article-compose-body",children:t})]}),d.jsxs("div",{className:"article-compose-footer",children:[d.jsx("button",{className:`article-mark-sent-btn${u==="done"?" article-mark-sent-btn--done":""}`,onClick:u==="done"?void 0:p,title:u==="done"?"Posted":"Mark as manually posted",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:u==="done"?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"8 12 11 15 16 9",stroke:u==="done"?"#fff":"currentColor"})]})}),u==="done"&&i&&d.jsxs("span",{className:"article-sent-status",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),d.jsx("button",{className:`article-copy-btn${l==="copied"?" article-copy-btn--copied":""}`,onClick:o,children:l==="copied"?d.jsxs(d.Fragment,{children:[d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):d.jsxs(d.Fragment,{children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy as HTML"]})})]})]})}function I8({connectionId:t,repoName:e,title:n,slug:r,onClose:s}){const[i,o]=S.useState("confirm"),[l,u]=S.useState(null),[f,p]=S.useState(null),m=S.useRef(null),g=()=>i==="published"?{publishedAt:new Date().toISOString(),url:f||void 0,repo:e}:void 0;S.useEffect(()=>{const b=k=>{i!=="publishing"&&m.current&&!m.current.contains(k.target)&&s(g())};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s,i,f]),S.useEffect(()=>{const b=k=>{k.key==="Escape"&&i!=="publishing"&&s(g())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s,i,f]);async function y(){o("publishing"),u(null);try{const b=await fetch("/api/blog/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:t})}),k=await b.json();if(!b.ok||k.error){u(k.error||`Publish failed (${b.status})`),o("error");return}k.url&&p(k.url),o("published"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:{lastPublish:{publishedAt:new Date().toISOString(),url:k.url||void 0,repo:e}}})}).catch(()=>{})}catch(b){u(b.message),o("error")}}return d.jsx("div",{className:"blog-publish-overlay",children:d.jsxs("div",{className:"blog-publish-modal",ref:m,children:[d.jsxs("div",{className:"blog-publish__header",children:[d.jsx("h3",{children:"Publish to GitHub"}),d.jsx("button",{className:"blog-publish__close",onClick:()=>s(g()),children:"×"})]}),d.jsxs("div",{className:"blog-publish__body",children:[i==="confirm"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"blog-publish__summary",children:[d.jsxs("div",{className:"blog-publish__row",children:[d.jsx("span",{className:"blog-publish__label",children:"Repository"}),d.jsx("span",{className:"blog-publish__value",children:e})]}),d.jsxs("div",{className:"blog-publish__row",children:[d.jsx("span",{className:"blog-publish__label",children:"Title"}),d.jsx("span",{className:"blog-publish__value",children:n})]}),r&&d.jsxs("div",{className:"blog-publish__row",children:[d.jsx("span",{className:"blog-publish__label",children:"Slug"}),d.jsx("span",{className:"blog-publish__value blog-publish__value--mono",children:r})]})]}),d.jsxs("div",{className:"blog-publish__actions",children:[d.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),d.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:y,children:"Publish"})]})]}),i==="publishing"&&d.jsxs("div",{className:"blog-publish__status",children:[d.jsx("div",{className:"blog-publish__spinner"}),d.jsxs("span",{children:["Publishing to ",e,"..."]})]}),i==="published"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"blog-publish__status blog-publish__status--success",children:["Published to ",e,"!"]}),f&&d.jsx("a",{className:"blog-publish__link",href:f,target:"_blank",rel:"noopener noreferrer",children:"View on GitHub"}),d.jsx("div",{className:"blog-publish__actions",children:d.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:()=>s({publishedAt:new Date().toISOString(),url:f||void 0,repo:e}),children:"Done"})})]}),i==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"blog-publish__error",children:l}),d.jsxs("div",{className:"blog-publish__actions",children:[d.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),d.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:y,children:"Retry"})]})]})]})]})})}const NS={font:"sans",width:"standard",spacing:"comfortable"},CS=new Set(["Untitled","New Document","Blog"]);function L8(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function TS(){return new Date().toISOString().split("T")[0]}function gs(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function D8({src:t,coverImages:e}){const[n,r]=S.useState(t?"display":"empty"),[s,i]=S.useState(t||""),[o,l]=S.useState(e||(t?[t]:[])),[u,f]=S.useState(""),[p,m]=S.useState(""),g=S.useRef(null);S.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),S.useEffect(()=>{e&&e.length>0?l(e):l(t?[t]:[])},[e]);const y=s?o.indexOf(s):-1,b=o.length,k=b>1,w=S.useCallback(z=>{const F=o[z];F&&(i(F),gs({coverImage:F,coverImages:o}))},[o]),E=S.useCallback(()=>{y>0&&w(y-1)},[y,w]),N=S.useCallback(()=>{y<b-1&&w(y+1)},[y,b,w]),O=S.useCallback(async()=>{if(u.trim()){r("loading"),m("");try{const F=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(F.success&&F.src){const J=[...o,F.src];l(J),i(F.src),r("display"),f(""),gs({coverImage:F.src,coverImages:J})}else m(F.error||"Generation failed"),r("prompt")}catch(z){m(z.message||"Network error"),r("prompt")}}},[u,o]),T=z=>{z.key==="Enter"&&O(),z.key==="Escape"&&(r("empty"),f(""),m(""))},C=()=>{r("prompt"),setTimeout(()=>{var z;return(z=g.current)==null?void 0:z.focus()},0)},R=()=>{const z=o.filter(F=>F!==s);if(l(z),z.length>0){const F=Math.min(y,z.length-1),J=z[F];i(J),gs({coverImage:J,coverImages:z})}else i(""),r("empty"),gs({coverImage:void 0,coverImages:void 0})},L=()=>{r("prompt"),setTimeout(()=>{var z;return(z=g.current)==null?void 0:z.focus()},0)},D=()=>{const z=document.createElement("a");z.href=s,z.download=`cover-${y+1}.png`,z.click()};return n==="display"&&s?d.jsxs("div",{className:"blog-cover blog-cover--display",children:[d.jsx("img",{className:"blog-cover-img",src:s,alt:"Cover"}),d.jsxs("div",{className:"blog-cover-overlay",children:[k&&d.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:E,disabled:y<=0,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"15 18 9 12 15 6"})})}),d.jsxs("div",{className:"blog-cover-overlay-center",children:[d.jsxs("button",{className:"blog-cover-btn",onClick:L,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"23 4 23 10 17 10"}),d.jsx("polyline",{points:"1 20 1 14 7 14"}),d.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),d.jsxs("button",{className:"blog-cover-btn",onClick:D,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),d.jsx("polyline",{points:"7 10 12 15 17 10"}),d.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),d.jsxs("button",{className:"blog-cover-btn blog-cover-btn--danger",onClick:R,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),k&&d.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:N,disabled:y>=b-1,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})})}),k&&d.jsxs("div",{className:"blog-cover-counter",children:[y+1," / ",b]})]})]}):n==="loading"?d.jsxs("div",{className:"blog-cover blog-cover--loading",children:[d.jsx("div",{className:"blog-cover-spinner"}),d.jsx("span",{className:"blog-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?d.jsxs("div",{className:"blog-cover blog-cover--prompt",children:[d.jsxs("div",{className:"blog-cover-prompt-row",children:[d.jsx("input",{ref:g,className:"blog-cover-prompt-input",value:u,onChange:z=>f(z.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),d.jsx("button",{className:"blog-cover-prompt-btn",onClick:O,disabled:!u.trim(),children:"Generate"}),d.jsx("button",{className:"blog-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&d.jsx("div",{className:"blog-cover-error",children:p})]}):d.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:C,children:[d.jsxs("svg",{className:"blog-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("polyline",{points:"21 15 16 10 5 21"})]}),d.jsx("span",{className:"blog-cover-hint",children:"Add a featured image"})]})}function P8({tags:t,onChange:e}){const[n,r]=S.useState(""),s=S.useRef(null),i=u=>{const f=u.trim().toLowerCase();f&&!t.includes(f)&&e([...t,f]),r("")},o=u=>e(t.filter(f=>f!==u)),l=u=>{(u.key==="Enter"||u.key===",")&&(u.preventDefault(),i(n)),u.key==="Backspace"&&!n&&t.length>0&&o(t[t.length-1])};return d.jsxs("div",{className:"blog-tags",onClick:()=>{var u;return(u=s.current)==null?void 0:u.focus()},children:[t.map(u=>d.jsxs("span",{className:"blog-tag",children:[u,d.jsx("button",{className:"blog-tag-remove",onClick:f=>{f.stopPropagation(),o(u)},children:d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},u)),d.jsx("input",{ref:s,className:"blog-tag-input",value:n,onChange:u=>r(u.target.value),onKeyDown:l,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function B8({style:t,onChange:e}){const n=r=>`blog-style-btn${r?" active":""}`;return d.jsxs("div",{className:"blog-style-controls",children:[d.jsxs("div",{className:"blog-style-group",children:[d.jsx("span",{className:"blog-style-label",children:"Font"}),d.jsx("button",{className:n(t.font==="sans"),onClick:()=>e({...t,font:"sans"}),title:"Sans-serif",children:"Aa"}),d.jsx("button",{className:`${n(t.font==="serif")} serif-btn`,onClick:()=>e({...t,font:"serif"}),title:"Serif",children:"Aa"}),d.jsx("button",{className:`${n(t.font==="mono")} mono-btn`,onClick:()=>e({...t,font:"mono"}),title:"Monospace",children:"Aa"})]}),d.jsxs("div",{className:"blog-style-group",children:[d.jsx("span",{className:"blog-style-label",children:"Width"}),d.jsx("button",{className:n(t.width==="narrow"),onClick:()=>e({...t,width:"narrow"}),title:"Narrow (600px)",children:d.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:d.jsx("rect",{x:"4",y:"1",width:"8",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),d.jsx("button",{className:n(t.width==="standard"),onClick:()=>e({...t,width:"standard"}),title:"Standard (720px)",children:d.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:d.jsx("rect",{x:"2",y:"1",width:"12",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),d.jsx("button",{className:n(t.width==="wide"),onClick:()=>e({...t,width:"wide"}),title:"Wide (900px)",children:d.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:d.jsx("rect",{x:"0.5",y:"1",width:"15",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})})]}),d.jsxs("div",{className:"blog-style-group",children:[d.jsx("span",{className:"blog-style-label",children:"Spacing"}),d.jsx("button",{className:n(t.spacing==="compact"),onClick:()=>e({...t,spacing:"compact"}),title:"Compact",children:d.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("line",{x1:"1",y1:"3",x2:"15",y2:"3"}),d.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),d.jsx("line",{x1:"1",y1:"11",x2:"15",y2:"11"})]})}),d.jsx("button",{className:n(t.spacing==="comfortable"),onClick:()=>e({...t,spacing:"comfortable"}),title:"Comfortable",children:d.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("line",{x1:"1",y1:"2",x2:"15",y2:"2"}),d.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),d.jsx("line",{x1:"1",y1:"12",x2:"15",y2:"12"})]})})]})]})}function z8({children:t,title:e,onTitleChange:n,blogContext:r,filename:s}){var Y;const i=r||{},[o,l]=S.useState(i.description||""),[u,f]=S.useState(!1),[p,m]=S.useState(i.date||TS()),[g,y]=S.useState(i.tags||[]),[b,k]=S.useState(i.author||""),[w,E]=S.useState(i.slug||""),[N,O]=S.useState(i.draft??!1),[T,C]=S.useState({...NS,...i.style}),[R,L]=S.useState(!1),[D,z]=S.useState(!!i.slug),[F,J]=S.useState(null),[K,X]=S.useState(!1);S.useEffect(()=>{fetch("/api/blog/connection").then(I=>I.json()).then(I=>{I.connection&&J(I.connection)}).catch(()=>{})},[]),S.useEffect(()=>{!D&&e&&!CS.has(e)&&E(L8(e))},[e,D]),S.useEffect(()=>{l(i.description||""),m(i.date||TS()),y(i.tags||[]),k(i.author||""),E(i.slug||""),O(i.draft??!1),C({...NS,...i.style}),z(!!i.slug)},[r]);const W=!!(r!=null&&r.active),$=S.useCallback(()=>{W&&gs({description:o,date:p,tags:g,author:b,slug:w,draft:N,style:T})},[W,o,p,g,b,w,N,T]);S.useEffect(()=>{W&&gs({tags:g})},[W,g]),S.useEffect(()=>{W&&gs({style:T})},[W,T]),S.useEffect(()=>{W&&gs({draft:N})},[W,N]);const U=o.length,Z=U>160,V=["blog-compose-wrapper",`blog--font-${T.font}`,`blog--width-${T.width}`,`blog--spacing-${T.spacing}`].join(" ");return d.jsxs("div",{className:V,children:[d.jsx(D8,{src:i.coverImage,coverImages:i.coverImages}),d.jsxs("div",{className:"blog-compose-content",children:[((Y=i.lastPublish)==null?void 0:Y.publishedAt)&&d.jsxs("a",{className:"blog-published-status",href:i.lastPublish.url,target:"_blank",rel:"noopener noreferrer",title:i.lastPublish.url||`Published to ${i.lastPublish.repo||"GitHub"}`,children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Published ",new Date(i.lastPublish.publishedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),i.lastPublish.repo?` to ${i.lastPublish.repo.split("/").pop()}`:""]}),d.jsx("input",{className:"blog-title-input",type:"text",value:CS.has(e||"")?"":e||"",onChange:I=>n==null?void 0:n(I.target.value||"Untitled"),placeholder:"Post title",spellCheck:!1}),d.jsxs("div",{className:"blog-description-wrap",children:[d.jsx("textarea",{className:`blog-description-input${Z?" over-limit":""}`,value:o,onChange:I=>l(I.target.value),onBlur:$,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),d.jsxs("span",{className:`blog-description-count${Z?" over-limit":""}`,children:[U,"/160"]})]}),d.jsxs("div",{className:"blog-meta-toggle",onClick:()=>L(I=>!I),children:[d.jsx("svg",{className:`blog-meta-chevron${R?" open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})}),d.jsx("span",{children:"Metadata"}),N&&d.jsx("span",{className:"blog-draft-badge",children:"Draft"})]}),R&&d.jsxs("div",{className:"blog-meta-fields",children:[d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Date"}),d.jsx("input",{type:"date",className:"blog-meta-input",value:p,onChange:I=>m(I.target.value),onBlur:$})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Author"}),d.jsx("input",{type:"text",className:"blog-meta-input",value:b,onChange:I=>k(I.target.value),onBlur:$,placeholder:"Author name",spellCheck:!1})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Slug"}),d.jsx("input",{type:"text",className:"blog-meta-input",value:w,onChange:I=>{z(!0),E(I.target.value)},onBlur:$,placeholder:"auto-generated-from-title",spellCheck:!1})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Tags"}),d.jsx(P8,{tags:g,onChange:y})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Draft"}),d.jsx("button",{className:`blog-draft-toggle${N?" active":""}`,onClick:()=>O(I=>!I),children:d.jsx("div",{className:"blog-draft-toggle-knob"})})]})]}),d.jsx("div",{className:"blog-compose-body",children:t})]}),d.jsxs("div",{className:"blog-compose-footer",children:[d.jsx(B8,{style:T,onChange:C}),s&&d.jsxs("div",{className:"blog-footer-actions",children:[F&&d.jsxs("button",{className:"blog-footer-btn blog-footer-btn--primary",onClick:()=>X(!0),children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})}),"Publish"]}),d.jsxs("button",{className:"blog-footer-btn",onClick:()=>f(!0),children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]})]}),u&&s&&d.jsx(Td,{filename:s,title:e||"Untitled",onClose:()=>f(!1)}),K&&F&&d.jsx(I8,{connectionId:F.id,repoName:F.display_name,title:e||"Untitled",slug:w,onClose:I=>{X(!1),I&&gs({lastPublish:I})}})]})}function F8({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,o]=S.useState("confirm"),[l,u]=S.useState("html"),[f,p]=S.useState(""),[m,g]=S.useState(null),[y,b]=S.useState(null),[k,w]=S.useState(0),[E,N]=S.useState(null),[O,T]=S.useState(null),[C,R]=S.useState("all"),[L,D]=S.useState([]),[z,F]=S.useState(""),J=S.useRef(null),K=L.find(U=>U.id===z),X=C==="exclude_issue"&&K&&O!=null?Math.max(0,O-K.recipient_count):O;S.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(U=>U.json()).then(U=>{var V,Y;const Z=(Y=(V=U.content)==null?void 0:V[0])!=null&&Y.text?JSON.parse(U.content[0].text):U;Z.count!=null&&T(Z.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(U=>U.json()).then(U=>{var V,Y;const Z=(Y=(V=U.content)==null?void 0:V[0])!=null&&Y.text?JSON.parse(U.content[0].text):U;Z.issues&&D(Z.issues)}).catch(()=>{})},[]);const W=()=>i==="sent"?{sentCount:k,issueId:E,sentAt:new Date().toISOString()}:void 0;S.useEffect(()=>{const U=Z=>{i!=="sending"&&i!=="testing"&&J.current&&!J.current.contains(Z.target)&&s(W())};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[s,i,k,E]),S.useEffect(()=>{const U=Z=>{Z.key==="Escape"&&i!=="sending"&&i!=="testing"&&s(W())};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s,i,k,E]);async function $(U){var Z,V;o(U?"testing":"sending"),b(null);try{r&&await r();const Y={subject:e,connectionId:t,format:l};U&&(Y.test_email=U),!U&&C==="exclude_issue"&&z&&(Y.exclude_issue_id=z);const A=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"send_newsletter",arguments:Y})})).json(),j=(V=(Z=A.content)==null?void 0:Z[0])!=null&&V.text?JSON.parse(A.content[0].text):A;if(j.error){b(j.error),o("error");return}if(j.test){g(j.sent_to),o("confirm");return}const Q=j.sent||0,oe=j.issueId||null,fe=new Date().toISOString();w(Q),N(oe),o("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:Q,sentAt:fe,issueId:oe||void 0}}})}).catch(()=>{})}catch(Y){b(Y.message),o("error")}}return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"newsletter-modal",ref:J,children:[d.jsxs("div",{className:"newsletter-modal__header",children:[d.jsx("h3",{children:"Send Newsletter"}),d.jsx("button",{className:"newsletter-modal__close",onClick:()=>s(W()),children:"×"})]}),d.jsxs("div",{className:"newsletter-modal__body",children:[i==="confirm"&&d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"newsletter-modal__confirm-text",style:X==null?{visibility:"hidden"}:void 0,children:['Send "',d.jsx("strong",{children:e}),'" to ',X!=null?X.toLocaleString():0," subscriber",X!==1?"s":"","?"]}),d.jsxs("div",{className:"newsletter-modal__audience",children:[d.jsx("label",{className:"newsletter-modal__label",children:"Audience"}),d.jsxs("select",{className:"newsletter-modal__select",value:C,onChange:U=>{const Z=U.target.value;R(Z),Z==="all"&&F("")},children:[d.jsx("option",{value:"all",children:"All subscribers"}),L.length>0&&d.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),C==="exclude_issue"&&d.jsxs("select",{className:"newsletter-modal__select",value:z,onChange:U=>F(U.target.value),children:[d.jsx("option",{value:"",children:"Select a past issue"}),L.map(U=>d.jsxs("option",{value:U.id,children:[U.subject," (",U.recipient_count," sent)"]},U.id))]})]}),d.jsxs("div",{className:"newsletter-modal__format-toggle",children:[d.jsx("button",{className:`newsletter-modal__format-btn${l==="html"?" active":""}`,onClick:()=>u("html"),children:"HTML"}),d.jsx("button",{className:`newsletter-modal__format-btn${l==="plaintext"?" active":""}`,onClick:()=>u("plaintext"),children:"Plaintext"})]}),d.jsxs("div",{className:"newsletter-modal__test-section",children:[d.jsxs("div",{className:"newsletter-modal__test-row",children:[d.jsx("input",{type:"email",className:"newsletter-modal__test-input",placeholder:"Test email address",value:f,onChange:U=>p(U.target.value),onKeyDown:U=>{U.key==="Enter"&&f.trim()&&$(f.trim())}}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>$(f.trim()),children:"Send Test"})]}),m&&d.jsxs("p",{className:"newsletter-modal__test-success",children:["Test sent to ",m]})]}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",disabled:C==="exclude_issue"&&!z,onClick:()=>$(),children:"Send Now"})]})]}),(i==="sending"||i==="testing")&&d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:i==="testing"?"Sending test...":"Sending..."})]}),i==="sent"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:["Sent to ",k," subscriber",k!==1?"s":"","!"]}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:k,issueId:E,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__error",children:y}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>$(),children:"Retry"})]})]})]})]})})}function MS(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function $8({children:t,newsletterContext:e,filename:n,title:r,onTitleChange:s,onBeforeSend:i}){var W;const o=e||{},[l,u]=S.useState(o.subject||""),[f,p]=S.useState(o.previewText||""),[m,g]=S.useState([]),[y,b]=S.useState(null),[k,w]=S.useState(!1),[E,N]=S.useState((W=o.lastSend)!=null&&W.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null),O=S.useRef(null),T=S.useRef(n),C=S.useRef(o.subject||""),R=S.useRef(o.previewText||"");S.useEffect(()=>{var $;if(T.current!==n)u(o.subject||""),p(o.previewText||""),C.current=o.subject||"",R.current=o.previewText||"",T.current=n;else{const U=o.subject||"",Z=o.previewText||"";U!==C.current&&(u(U),C.current=U),Z!==R.current&&(p(Z),R.current=Z)}N(($=o.lastSend)!=null&&$.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null)},[e,n]),S.useEffect(()=>{fetch("/api/connections").then($=>$.json()).then($=>{const U=($.connections||[]).filter(Z=>Z.provider==="newsletter"&&Z.status==="active");g(U)}).catch(()=>{})},[]);const L=!!(e!=null&&e.active),D=S.useRef();S.useEffect(()=>{if(D.current&&clearTimeout(D.current),!(!s||!l.trim()))return D.current=setTimeout(async()=>{const $=r,U=!$||$==="Untitled",Z=O.current!==null&&$===O.current;if(U||Z){try{await fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{subject:l}})})}catch{}s(l.trim()),O.current=l.trim()}},500),()=>{D.current&&clearTimeout(D.current)}},[l,r,s]);const z=S.useCallback(()=>{L&&(C.current=l,R.current=f,MS({subject:l,previewText:f}))},[L,l,f]),F=f.length,J=F>=90,K=F>150,X=()=>{m.length===1&&b(m[0].id),m.length>1&&b(m[0].id)};return d.jsxs("div",{className:"nl-compose-wrapper",children:[E&&d.jsxs("div",{className:"nl-sent-status",children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent ",new Date(E.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",E.sentCount," subscriber",E.sentCount!==1?"s":""]}),d.jsxs("div",{className:"nl-compose-content",children:[d.jsx("input",{className:"nl-subject-input",type:"text",value:l,onChange:$=>u($.target.value),onBlur:z,placeholder:"Subject line (defaults to title if empty)",autoComplete:"off","data-lpignore":"true","data-1p-ignore":!0,spellCheck:!1}),d.jsxs("div",{className:"nl-preview-wrap",children:[d.jsx("textarea",{className:`nl-preview-input${K?" over-limit":""}`,value:f,onChange:$=>p($.target.value),onBlur:z,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),d.jsxs("span",{className:`nl-preview-count${K?" over-limit":J?" full":""}`,children:[F,"/90"]})]}),d.jsx("div",{className:"nl-compose-body",children:t})]}),n&&d.jsxs("div",{className:"nl-compose-footer",children:[m.length>0&&d.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:X,children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),d.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Send"]}),d.jsxs("button",{className:"nl-footer-btn",onClick:()=>w(!0),children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]}),y&&n&&d.jsx(F8,{connectionId:y,subject:l||r||"Untitled",filename:n,onBeforeSend:i,onClose:$=>{b(null),$&&(N($),MS({lastSend:{sentCount:$.sentCount,sentAt:$.sentAt,issueId:$.issueId||void 0}}))}}),k&&n&&d.jsx(Td,{filename:n,title:r||"Untitled",onClose:()=>w(!1)})]})}function U8(t){const e=t==null?void 0:t.articleContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function H8(t){const e=t==null?void 0:t.blogContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function W8(t){const e=t==null?void 0:t.newsletterContext;return e!=null&&typeof e=="object"&&(e.active===!0||Object.keys(e).length>0)}function q8(){var Et,rt,nt;const t=S.useRef(null),e=S.useRef([]),[n,r]=S.useState(null),[s,i]=S.useState([]),[o,l]=S.useState("Untitled"),[u,f]=S.useState(void 0),[p,m]=S.useState(0),[g,y]=S.useState(!0),[b,k]=S.useState(0),[w,E]=S.useState(0),[N,O]=S.useState({filenames:[],counts:{}}),[T,C]=S.useState({state:"unconfigured"}),[R,L]=S.useState(!1),[D,z]=S.useState({}),[F,J]=S.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[K,X]=S.useState(null),[W,$]=S.useState(null),U=S.useRef(0),Z=S.useRef(null),V=1500,Y=S.useCallback((ee,Ce)=>{Z.current&&(clearTimeout(Z.current),Z.current=null),U.current=Date.now(),X(ee),$(Ce)},[]),I=S.useCallback(()=>{if(Z.current)return;const ee=Date.now()-U.current,Ce=V-ee;Ce<=0?(X(null),$(null)):Z.current=setTimeout(()=>{Z.current=null,X(null),$(null)},Ce)},[]),[,A]=S.useState(0),j=S.useRef(null),Q=S.useRef(null),oe=S.useRef([]),fe=S.useRef(-1),G=S.useRef(!1),le=S.useRef(""),[Te,Ve]=S.useState(""),[ce,ue]=S.useState(!1),[ae,je]=S.useState(!1),Me=U8(D),He=H8(D),Ne=W8(D);S.useEffect(()=>(Me?document.documentElement.setAttribute("data-view","article"):He?document.documentElement.setAttribute("data-view","blog"):Ne?document.documentElement.setAttribute("data-view","newsletter"):D!=null&&D.tweetContext?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[D==null?void 0:D.tweetContext,Me,He,Ne]),S.useEffect(()=>{const ee=()=>A(Ce=>Ce+1);return window.addEventListener("ow-sidebar-mode-change",ee),()=>window.removeEventListener("ow-sidebar-mode-change",ee)},[]),S.useEffect(()=>{fetch("/api/document",{cache:"no-store"}).then(ee=>ee.json()).then(ee=>{ee.document&&(f(ee.document),Q.current=ee.document),ee.title&&l(ee.title),ee.metadata&&z(ee.metadata)}).catch(()=>{f(void 0)}),fetch("/api/pending-docs").then(ee=>ee.json()).then(ee=>O(ee)).catch(()=>{}),fetch("/api/sync/status").then(ee=>ee.json()).then(ee=>C(ee)).catch(()=>{})},[]);const tt=S.useCallback(ee=>{t.current=ee,r(ee),e.current=[ee],i([ee])},[]),Be=S.useRef([]),$e=S.useCallback(ee=>{if(e.current=ee,i(ee),Be.current.length>0&&ee.length>0){const Ce=Be.current;Be.current=[];for(const lt of ee)lt.isDestroyed||ap(lt,Ce)}},[]),ye=S.useCallback(ee=>{j.current&&(clearTimeout(j.current),j.current=null);const Ce=le.current==="",lt=ee.filename===le.current;if(le.current=ee.filename,Q.current=ee.document,Ve(ee.filename),f(ee.document),l(ee.title),z(ee.metadata||{}),!lt&&!Ce&&m(B=>B+1),k(B=>B+1),G.current){const B=oe.current[fe.current];B&&setTimeout(()=>{const se=document.querySelector(".editor-container");se&&(se.scrollTop=B.scrollTop)},50),G.current=!1}ue(fe.current>0),je(fe.current<oe.current.length-1)},[]),pe=S.useCallback(()=>{k(ee=>ee+1)},[]),Ze=S.useCallback(()=>{E(ee=>ee+1)},[]),Ae=S.useCallback(ee=>{O(ee)},[]),{connected:be,sendMessage:ke}=p5({onNodeChanges:ee=>{const Ce=e.current;if(Ce.length<=1){const lt=t.current;if(!lt)return;ap(lt,ee)}else{if(Ce.some(B=>B.isDestroyed)){Be.current.push(...ee);return}for(const B of Ce)ap(B,ee)}},onDocumentSwitched:ye,onDocumentsChanged:pe,onWorkspacesChanged:Ze,onPendingDocsChanged:Ae,onMetadataChanged:ee=>z(ee),onWritingStarted:(ee,Ce)=>Y(ee,Ce),onWritingFinished:()=>I(),onSyncStatus:ee=>C(ee),onTitleChanged:ee=>l(ee),getEditorState:()=>{var Ce;const ee=Q.current||((Ce=t.current)==null?void 0:Ce.getJSON());return ee?{document:ee}:null}}),ze=S.useCallback(()=>{var Ce;j.current&&(clearTimeout(j.current),j.current=null);const ee=Q.current||((Ce=t.current)==null?void 0:Ce.getJSON());ee&&ke({type:"doc-update",document:ee,filename:le.current})},[ke]),ht=S.useCallback(async()=>{var Ce;const ee=Q.current||((Ce=t.current)==null?void 0:Ce.getJSON());ee&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:ee,filename:le.current})})},[]);S.useEffect(()=>{const ee=()=>{var se;j.current&&(clearTimeout(j.current),j.current=null);const lt=Q.current||((se=t.current)==null?void 0:se.getJSON());if(!lt)return;const B=JSON.stringify({type:"flush",document:lt});navigator.sendBeacon("/api/flush",new Blob([B],{type:"application/json"}))},Ce=()=>{document.visibilityState==="hidden"&&ee()};return window.addEventListener("beforeunload",ee),document.addEventListener("visibilitychange",Ce),()=>{window.removeEventListener("beforeunload",ee),document.removeEventListener("visibilitychange",Ce)}},[]);const wt=S.useCallback(()=>{ze(),ke({type:"create-document"})},[ze,ke]),kt=S.useCallback(ee=>{const Ce=document.querySelector(".editor-container"),lt=(Ce==null?void 0:Ce.scrollTop)||0;!G.current&&le.current&&(oe.current=oe.current.slice(0,fe.current+1),oe.current.push({filename:le.current,scrollTop:lt}),fe.current=oe.current.length-1),ze(),ke({type:"switch-document",filename:ee})},[ze,ke]),Bt=S.useCallback(()=>{if(fe.current<=0)return;const ee=document.querySelector(".editor-container"),Ce=(ee==null?void 0:ee.scrollTop)||0;fe.current===oe.current.length-1&&le.current?(oe.current=oe.current.slice(0,fe.current+1),oe.current.push({filename:le.current,scrollTop:Ce})):le.current&&(oe.current[fe.current+1]={filename:le.current,scrollTop:Ce});const lt=oe.current[fe.current];fe.current--,G.current=!0,ue(fe.current>0),je(!0),ze(),ke({type:"switch-document",filename:lt.filename})},[ze,ke]),xn=S.useCallback(()=>{if(fe.current>=oe.current.length-2)return;const ee=document.querySelector(".editor-container"),Ce=(ee==null?void 0:ee.scrollTop)||0;le.current&&(oe.current[fe.current+1]={filename:le.current,scrollTop:Ce}),fe.current++;const lt=oe.current[fe.current+1];G.current=!0,ue(!0),je(fe.current<oe.current.length-2),ze(),ke({type:"switch-document",filename:lt.filename})},[ze,ke]),An=S.useCallback(()=>{const ee=le.current,Ce=t.current;!ee||!Ce||fetch(`/api/marks/${encodeURIComponent(ee)}`).then(lt=>lt.json()).then(lt=>{A1(lt.marks||[]),I1(Ce.view)}).catch(()=>{A1([]),Ce!=null&&Ce.view&&I1(Ce.view)})},[]);S.useEffect(()=>{An()},[Te,An]),S.useEffect(()=>{const ee=Ce=>{const lt=Ce.detail;(lt==null?void 0:lt.filename)===le.current&&An()};return window.addEventListener("ow-marks-changed",ee),()=>window.removeEventListener("ow-marks-changed",ee)},[An]),S.useEffect(()=>{const ee=Ce=>{Ce.altKey&&Ce.key==="ArrowLeft"&&(Ce.preventDefault(),Bt()),Ce.altKey&&Ce.key==="ArrowRight"&&(Ce.preventDefault(),xn())};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[Bt,xn]);const On=S.useCallback(ee=>{Q.current=ee,j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{ke({type:"doc-update",document:ee,filename:le.current})},1e3)},[ke]),wn=S.useCallback(ee=>{l(ee),ke({type:"title-update",title:ee})},[ke]),re=S.useCallback(()=>{J(ee=>(localStorage.setItem("ow-toolbar",ee?"hidden":"visible"),!ee))},[]),Je=S.useCallback(()=>{if(T.state==="unconfigured"){L(!0);return}ze(),ke({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[T.state,ze,ke]),et=ud()==="board";return d.jsxs("div",{className:"app",children:[!et&&d.jsx(K1,{open:g,onSwitchDocument:kt,onCreateDocument:wt,refreshKey:b,workspacesRefreshKey:w,pendingDocs:N,writingTitle:K,writingTarget:W,onClose:()=>y(!1)}),d.jsxs("div",{className:"app-main",children:[d.jsx(lB,{title:o,onTitleChange:wn,syncStatus:T,onSync:Je,onToggleSidebar:!et&&!g?()=>y(!0):void 0,canGoBack:ce,canGoForward:ae,onGoBack:Bt,onGoForward:xn,editor:n,onToggleToolbar:re,toolbarOpen:F}),F&&n&&d.jsx(W6,{editor:n}),et&&d.jsx(K1,{open:!0,onSwitchDocument:kt,onCreateDocument:wt,refreshKey:b,workspacesRefreshKey:w,pendingDocs:N,writingTitle:K,writingTarget:W}),!be&&d.jsxs("div",{className:"connection-banner",children:[d.jsx("div",{className:"connection-banner-spinner"}),d.jsx("span",{children:"Reconnecting to server..."})]}),d.jsx("div",{className:"editor-container",children:Me?d.jsx(j8,{title:o,onTitleChange:wn,coverImage:(Et=D==null?void 0:D.articleContext)==null?void 0:Et.coverImage,coverImages:(rt=D==null?void 0:D.articleContext)==null?void 0:rt.coverImages,lastPost:(nt=D==null?void 0:D.articleContext)==null?void 0:nt.lastPost,children:d.jsx(eu,{initialContent:u,extensions:L6,onUpdate:On,onReady:tt,onLinkClick:kt},p)}):He?d.jsx(z8,{title:o,onTitleChange:wn,blogContext:D==null?void 0:D.blogContext,filename:Te,children:d.jsx(eu,{initialContent:u,onUpdate:On,onReady:tt,onLinkClick:kt},p)}):Ne?d.jsx($8,{newsletterContext:D==null?void 0:D.newsletterContext,filename:Te,title:o,onTitleChange:wn,onBeforeSend:ht,children:d.jsx(eu,{initialContent:u,onUpdate:On,onReady:tt,onLinkClick:kt},p)}):D!=null&&D.tweetContext?d.jsx(C8,{tweetContext:D.tweetContext,initialContent:u,onUpdate:On,onEditorReady:tt,onEditorsChange:$e,filename:Te,title:o},p):d.jsx(eu,{initialContent:u,onUpdate:On,onReady:tt,onLinkClick:kt},p)}),d.jsx(IB,{editors:s,pendingDocs:N,currentFilename:Te,onSwitchDocument:kt,sendMessage:ke,getDocument:()=>Q.current})]}),d.jsx(vB,{editorRef:t,allEditors:s,documentId:Te}),R&&d.jsx(h5,{onClose:()=>L(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(ee=>ee.json()).then(C).catch(()=>{})}})]})}lM();rM.createRoot(document.getElementById("root")).render(d.jsx(ii.StrictMode,{children:d.jsx(q8,{})}));