openwriter 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/index-BjnZD0j5.js +209 -0
- package/dist/client/assets/index-DIJCM4cA.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/install-skill.js +119 -2
- package/dist/server/markdown-serialize.js +3 -1
- package/package.json +1 -1
- package/skill/SKILL.md +52 -16
- package/dist/client/assets/index-CCMCrgTu.js +0 -209
- package/dist/client/assets/index-DN1_4Au6.css +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
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 l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).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)}})();function Bu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Bf={exports:{}},pl={},zf={exports:{}},it={};/**
|
|
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 By;function fE(){if(By)return it;By=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"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function y(A){return A===null||typeof A!="object"?null:(A=m&&A[m]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function k(A,I,J){this.props=A,this.context=I,this.refs=w,this.updater=J||b}k.prototype.isReactComponent={},k.prototype.setState=function(A,I){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,I,"setState")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function N(){}N.prototype=k.prototype;function C(A,I,J){this.props=A,this.context=I,this.refs=w,this.updater=J||b}var O=C.prototype=new N;O.constructor=C,v(O,k.prototype),O.isPureReactComponent=!0;var T=Array.isArray,M=Object.prototype.hasOwnProperty,R={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function U(A,I,J){var re,pe={},Ne=null,Re=null;if(I!=null)for(re in I.ref!==void 0&&(Re=I.ref),I.key!==void 0&&(Ne=""+I.key),I)M.call(I,re)&&!B.hasOwnProperty(re)&&(pe[re]=I[re]);var Be=arguments.length-2;if(Be===1)pe.children=J;else if(1<Be){for(var tt=Array(Be),ce=0;ce<Be;ce++)tt[ce]=arguments[ce+2];pe.children=tt}if(A&&A.defaultProps)for(re in Be=A.defaultProps,Be)pe[re]===void 0&&(pe[re]=Be[re]);return{$$typeof:t,type:A,key:Ne,ref:Re,props:pe,_owner:R.current}}function z(A,I){return{$$typeof:t,type:A.type,key:I,ref:A.ref,props:A.props,_owner:A._owner}}function H(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function $(A){var I={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(J){return I[J]})}var L=/\/+/g;function Y(A,I){return typeof A=="object"&&A!==null&&A.key!=null?$(""+A.key):I.toString(36)}function Q(A,I,J,re,pe){var Ne=typeof A;(Ne==="undefined"||Ne==="boolean")&&(A=null);var Re=!1;if(A===null)Re=!0;else switch(Ne){case"string":case"number":Re=!0;break;case"object":switch(A.$$typeof){case t:case e:Re=!0}}if(Re)return Re=A,pe=pe(Re),A=re===""?"."+Y(Re,0):re,T(pe)?(J="",A!=null&&(J=A.replace(L,"$&/")+"/"),Q(pe,I,J,"",function(ce){return ce})):pe!=null&&(H(pe)&&(pe=z(pe,J+(!pe.key||Re&&Re.key===pe.key?"":(""+pe.key).replace(L,"$&/")+"/")+A)),I.push(pe)),1;if(Re=0,re=re===""?".":re+":",T(A))for(var Be=0;Be<A.length;Be++){Ne=A[Be];var tt=re+Y(Ne,Be);Re+=Q(Ne,I,J,tt,pe)}else if(tt=y(A),typeof tt=="function")for(A=tt.call(A),Be=0;!(Ne=A.next()).done;)Ne=Ne.value,tt=re+Y(Ne,Be++),Re+=Q(Ne,I,J,tt,pe);else if(Ne==="object")throw I=String(A),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return Re}function ee(A,I,J){if(A==null)return A;var re=[],pe=0;return Q(A,re,"","",function(Ne){return I.call(J,Ne,pe++)}),re}function G(A){if(A._status===-1){var I=A._result;I=I(),I.then(function(J){(A._status===0||A._status===-1)&&(A._status=1,A._result=J)},function(J){(A._status===0||A._status===-1)&&(A._status=2,A._result=J)}),A._status===-1&&(A._status=0,A._result=I)}if(A._status===1)return A._result.default;throw A._result}var ne={current:null},V={transition:null},X={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:V,ReactCurrentOwner:R};function te(){throw Error("act(...) is not supported in production builds of React.")}return it.Children={map:ee,forEach:function(A,I,J){ee(A,function(){I.apply(this,arguments)},J)},count:function(A){var I=0;return ee(A,function(){I++}),I},toArray:function(A){return ee(A,function(I){return I})||[]},only:function(A){if(!H(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},it.Component=k,it.Fragment=n,it.Profiler=s,it.PureComponent=C,it.StrictMode=r,it.Suspense=u,it.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,it.act=te,it.cloneElement=function(A,I,J){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var re=v({},A.props),pe=A.key,Ne=A.ref,Re=A._owner;if(I!=null){if(I.ref!==void 0&&(Ne=I.ref,Re=R.current),I.key!==void 0&&(pe=""+I.key),A.type&&A.type.defaultProps)var Be=A.type.defaultProps;for(tt in I)M.call(I,tt)&&!B.hasOwnProperty(tt)&&(re[tt]=I[tt]===void 0&&Be!==void 0?Be[tt]:I[tt])}var tt=arguments.length-2;if(tt===1)re.children=J;else if(1<tt){Be=Array(tt);for(var ce=0;ce<tt;ce++)Be[ce]=arguments[ce+2];re.children=Be}return{$$typeof:t,type:A.type,key:pe,ref:Ne,props:re,_owner:Re}},it.createContext=function(A){return A={$$typeof:l,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:i,_context:A},A.Consumer=A},it.createElement=U,it.createFactory=function(A){var I=U.bind(null,A);return I.type=A,I},it.createRef=function(){return{current:null}},it.forwardRef=function(A){return{$$typeof:c,render:A}},it.isValidElement=H,it.lazy=function(A){return{$$typeof:h,_payload:{_status:-1,_result:A},_init:G}},it.memo=function(A,I){return{$$typeof:f,type:A,compare:I===void 0?null:I}},it.startTransition=function(A){var I=V.transition;V.transition={};try{A()}finally{V.transition=I}},it.unstable_act=te,it.useCallback=function(A,I){return ne.current.useCallback(A,I)},it.useContext=function(A){return ne.current.useContext(A)},it.useDebugValue=function(){},it.useDeferredValue=function(A){return ne.current.useDeferredValue(A)},it.useEffect=function(A,I){return ne.current.useEffect(A,I)},it.useId=function(){return ne.current.useId()},it.useImperativeHandle=function(A,I,J){return ne.current.useImperativeHandle(A,I,J)},it.useInsertionEffect=function(A,I){return ne.current.useInsertionEffect(A,I)},it.useLayoutEffect=function(A,I){return ne.current.useLayoutEffect(A,I)},it.useMemo=function(A,I){return ne.current.useMemo(A,I)},it.useReducer=function(A,I,J){return ne.current.useReducer(A,I,J)},it.useRef=function(A){return ne.current.useRef(A)},it.useState=function(A){return ne.current.useState(A)},it.useSyncExternalStore=function(A,I,J){return ne.current.useSyncExternalStore(A,I,J)},it.useTransition=function(){return ne.current.useTransition()},it.version="18.3.1",it}var zy;function Kl(){return zy||(zy=1,zf.exports=fE()),zf.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 Fy;function pE(){if(Fy)return pl;Fy=1;var t=Kl(),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 l(c,u,f){var h,m={},y=null,b=null;f!==void 0&&(y=""+f),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(b=u.ref);for(h in u)r.call(u,h)&&!i.hasOwnProperty(h)&&(m[h]=u[h]);if(c&&c.defaultProps)for(h in u=c.defaultProps,u)m[h]===void 0&&(m[h]=u[h]);return{$$typeof:e,type:c,key:y,ref:b,props:m,_owner:s.current}}return pl.Fragment=n,pl.jsx=l,pl.jsxs=l,pl}var $y;function hE(){return $y||($y=1,Bf.exports=pE()),Bf.exports}var d=hE(),E=Kl();const qs=Bu(E);var ic={},Ff={exports:{}},qn={},$f={exports:{}},Uf={};/**
|
|
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 Uy;function mE(){return Uy||(Uy=1,(function(t){function e(V,X){var te=V.length;V.push(X);e:for(;0<te;){var A=te-1>>>1,I=V[A];if(0<s(I,X))V[A]=X,V[te]=I,te=A;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var X=V[0],te=V.pop();if(te!==X){V[0]=te;e:for(var A=0,I=V.length,J=I>>>1;A<J;){var re=2*(A+1)-1,pe=V[re],Ne=re+1,Re=V[Ne];if(0>s(pe,te))Ne<I&&0>s(Re,pe)?(V[A]=Re,V[Ne]=te,A=Ne):(V[A]=pe,V[re]=te,A=re);else if(Ne<I&&0>s(Re,te))V[A]=Re,V[Ne]=te,A=Ne;else break e}}return X}function s(V,X){var te=V.sortIndex-X.sortIndex;return te!==0?te:V.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();t.unstable_now=function(){return l.now()-c}}var u=[],f=[],h=1,m=null,y=3,b=!1,v=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=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 X=n(f);X!==null;){if(X.callback===null)r(f);else if(X.startTime<=V)r(f),X.sortIndex=X.expirationTime,e(u,X);else break;X=n(f)}}function T(V){if(w=!1,O(V),!v)if(n(u)!==null)v=!0,G(M);else{var X=n(f);X!==null&&ne(T,X.startTime-V)}}function M(V,X){v=!1,w&&(w=!1,N(U),U=-1),b=!0;var te=y;try{for(O(X),m=n(u);m!==null&&(!(m.expirationTime>X)||V&&!$());){var A=m.callback;if(typeof A=="function"){m.callback=null,y=m.priorityLevel;var I=A(m.expirationTime<=X);X=t.unstable_now(),typeof I=="function"?m.callback=I:m===n(u)&&r(u),O(X)}else r(u);m=n(u)}if(m!==null)var J=!0;else{var re=n(f);re!==null&&ne(T,re.startTime-X),J=!1}return J}finally{m=null,y=te,b=!1}}var R=!1,B=null,U=-1,z=5,H=-1;function $(){return!(t.unstable_now()-H<z)}function L(){if(B!==null){var V=t.unstable_now();H=V;var X=!0;try{X=B(!0,V)}finally{X?Y():(R=!1,B=null)}}else R=!1}var Y;if(typeof C=="function")Y=function(){C(L)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,ee=Q.port2;Q.port1.onmessage=L,Y=function(){ee.postMessage(null)}}else Y=function(){k(L,0)};function G(V){B=V,R||(R=!0,Y())}function ne(V,X){U=k(function(){V(t.unstable_now())},X)}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(){v||b||(v=!0,G(M))},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 y},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(V){switch(y){case 1:case 2:case 3:var X=3;break;default:X=y}var te=y;y=X;try{return V()}finally{y=te}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(V,X){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var te=y;y=V;try{return X()}finally{y=te}},t.unstable_scheduleCallback=function(V,X,te){var A=t.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?A+te:A):te=A,V){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=te+I,V={id:h++,callback:X,priorityLevel:V,startTime:te,expirationTime:I,sortIndex:-1},te>A?(V.sortIndex=te,e(f,V),n(u)===null&&V===n(f)&&(w?(N(U),U=-1):w=!0,ne(T,te-A))):(V.sortIndex=I,e(u,V),v||b||(v=!0,G(M))),V},t.unstable_shouldYield=$,t.unstable_wrapCallback=function(V){var X=y;return function(){var te=y;y=X;try{return V.apply(this,arguments)}finally{y=te}}}})(Uf)),Uf}var Hy;function gE(){return Hy||(Hy=1,$f.exports=mE()),$f.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 Wy;function yE(){if(Wy)return qn;Wy=1;var t=Kl(),e=gE();function n(o){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+o,p=1;p<arguments.length;p++)a+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+o+"; visit "+a+" 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(o,a){l(o,a),l(o+"Capture",a)}function l(o,a){for(s[o]=a,o=0;o<a.length;o++)r.add(a[o])}var c=!(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]*$/,h={},m={};function y(o){return u.call(m,o)?!0:u.call(h,o)?!1:f.test(o)?m[o]=!0:(h[o]=!0,!1)}function b(o,a,p,g){if(p!==null&&p.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return g?!1:p!==null?!p.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,a,p,g){if(a===null||typeof a>"u"||b(o,a,p,g))return!0;if(g)return!1;if(p!==null)switch(p.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function w(o,a,p,g,x,S,_){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=g,this.attributeNamespace=x,this.mustUseProperty=p,this.propertyName=o,this.type=a,this.sanitizeURL=S,this.removeEmptyString=_}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){k[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var a=o[0];k[a]=new w(a,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){k[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){k[o]=new w(o,2,!1,o,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(o){k[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){k[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){k[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){k[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){k[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function C(o){return o[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(o){var a=o.replace(N,C);k[a]=new w(a,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var a=o.replace(N,C);k[a]=new w(a,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var a=o.replace(N,C);k[a]=new w(a,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function O(o,a,p,g){var x=k.hasOwnProperty(a)?k[a]:null;(x!==null?x.type!==0:g||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(v(a,p,x,g)&&(p=null),g||x===null?y(a)&&(p===null?o.removeAttribute(a):o.setAttribute(a,""+p)):x.mustUseProperty?o[x.propertyName]=p===null?x.type===3?!1:"":p:(a=x.attributeName,g=x.attributeNamespace,p===null?o.removeAttribute(a):(x=x.type,p=x===3||x===4&&p===!0?"":""+p,g?o.setAttributeNS(g,a,p):o.setAttribute(a,p))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,M=Symbol.for("react.element"),R=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),H=Symbol.for("react.provider"),$=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),Y=Symbol.for("react.suspense"),Q=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),ne=Symbol.for("react.offscreen"),V=Symbol.iterator;function X(o){return o===null||typeof o!="object"?null:(o=V&&o[V]||o["@@iterator"],typeof o=="function"?o:null)}var te=Object.assign,A;function I(o){if(A===void 0)try{throw Error()}catch(p){var a=p.stack.trim().match(/\n( *(at )?)/);A=a&&a[1]||""}return`
|
|
34
|
+
`+A+o}var J=!1;function re(o,a){if(!o||J)return"";J=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(q){var g=q}Reflect.construct(o,[],a)}else{try{a.call()}catch(q){g=q}o.call(a.prototype)}else{try{throw Error()}catch(q){g=q}o()}}catch(q){if(q&&g&&typeof q.stack=="string"){for(var x=q.stack.split(`
|
|
35
|
+
`),S=g.stack.split(`
|
|
36
|
+
`),_=x.length-1,j=S.length-1;1<=_&&0<=j&&x[_]!==S[j];)j--;for(;1<=_&&0<=j;_--,j--)if(x[_]!==S[j]){if(_!==1||j!==1)do if(_--,j--,0>j||x[_]!==S[j]){var P=`
|
|
37
|
+
`+x[_].replace(" at new "," at ");return o.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",o.displayName)),P}while(1<=_&&0<=j);break}}}finally{J=!1,Error.prepareStackTrace=p}return(o=o?o.displayName||o.name:"")?I(o):""}function pe(o){switch(o.tag){case 5:return I(o.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return o=re(o.type,!1),o;case 11:return o=re(o.type.render,!1),o;case 1:return o=re(o.type,!0),o;default:return""}}function Ne(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case B:return"Fragment";case R:return"Portal";case z:return"Profiler";case U:return"StrictMode";case Y:return"Suspense";case Q:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case $:return(o.displayName||"Context")+".Consumer";case H:return(o._context.displayName||"Context")+".Provider";case L:var a=o.render;return o=o.displayName,o||(o=a.displayName||a.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case ee:return a=o.displayName||null,a!==null?a:Ne(o.type)||"Memo";case G:a=o._payload,o=o._init;try{return Ne(o(a))}catch{}}return null}function Re(o){var a=o.type;switch(o.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=a.render,o=o.displayName||o.name||"",a.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ne(a);case 8:return a===U?"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 a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function Be(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function tt(o){var a=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function ce(o){var a=tt(o)?"checked":"value",p=Object.getOwnPropertyDescriptor(o.constructor.prototype,a),g=""+o[a];if(!o.hasOwnProperty(a)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var x=p.get,S=p.set;return Object.defineProperty(o,a,{configurable:!0,get:function(){return x.call(this)},set:function(_){g=""+_,S.call(this,_)}}),Object.defineProperty(o,a,{enumerable:p.enumerable}),{getValue:function(){return g},setValue:function(_){g=""+_},stopTracking:function(){o._valueTracker=null,delete o[a]}}}}function xe(o){o._valueTracker||(o._valueTracker=ce(o))}function ie(o){if(!o)return!1;var a=o._valueTracker;if(!a)return!0;var p=a.getValue(),g="";return o&&(g=tt(o)?o.checked?"true":"false":o.value),o=g,o!==p?(a.setValue(o),!0):!1}function Le(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function ae(o,a){var p=a.checked;return te({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??o._wrapperState.initialChecked})}function ue(o,a){var p=a.defaultValue==null?"":a.defaultValue,g=a.checked!=null?a.checked:a.defaultChecked;p=Be(a.value!=null?a.value:p),o._wrapperState={initialChecked:g,initialValue:p,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function me(o,a){a=a.checked,a!=null&&O(o,"checked",a,!1)}function Ae(o,a){me(o,a);var p=Be(a.value),g=a.type;if(p!=null)g==="number"?(p===0&&o.value===""||o.value!=p)&&(o.value=""+p):o.value!==""+p&&(o.value=""+p);else if(g==="submit"||g==="reset"){o.removeAttribute("value");return}a.hasOwnProperty("value")?ct(o,a.type,p):a.hasOwnProperty("defaultValue")&&ct(o,a.type,Be(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(o.defaultChecked=!!a.defaultChecked)}function Ue(o,a,p){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var g=a.type;if(!(g!=="submit"&&g!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+o._wrapperState.initialValue,p||a===o.value||(o.value=a),o.defaultValue=a}p=o.name,p!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,p!==""&&(o.name=p)}function ct(o,a,p){(a!=="number"||Le(o.ownerDocument)!==o)&&(p==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+p&&(o.defaultValue=""+p))}var pt=Array.isArray;function Lt(o,a,p,g){if(o=o.options,a){a={};for(var x=0;x<p.length;x++)a["$"+p[x]]=!0;for(p=0;p<o.length;p++)x=a.hasOwnProperty("$"+o[p].value),o[p].selected!==x&&(o[p].selected=x),x&&g&&(o[p].defaultSelected=!0)}else{for(p=""+Be(p),a=null,x=0;x<o.length;x++){if(o[x].value===p){o[x].selected=!0,g&&(o[x].defaultSelected=!0);return}a!==null||o[x].disabled||(a=o[x])}a!==null&&(a.selected=!0)}}function Qn(o,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return te({},a,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function yn(o,a){var p=a.value;if(p==null){if(p=a.children,a=a.defaultValue,p!=null){if(a!=null)throw Error(n(92));if(pt(p)){if(1<p.length)throw Error(n(93));p=p[0]}a=p}a==null&&(a=""),p=a}o._wrapperState={initialValue:Be(p)}}function lt(o,a){var p=Be(a.value),g=Be(a.defaultValue);p!=null&&(p=""+p,p!==o.value&&(o.value=p),a.defaultValue==null&&o.defaultValue!==p&&(o.defaultValue=p)),g!=null&&(o.defaultValue=""+g)}function Ot(o){var a=o.textContent;a===o._wrapperState.initialValue&&a!==""&&a!==null&&(o.value=a)}function bn(o){switch(o){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 qt(o,a){return o==null||o==="http://www.w3.org/1999/xhtml"?bn(a):o==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Jt,Xn=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,p,g,x){MSApp.execUnsafeLocalFunction(function(){return o(a,p,g,x)})}:o})(function(o,a){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=a;else{for(Jt=Jt||document.createElement("div"),Jt.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=Jt.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;a.firstChild;)o.appendChild(a.firstChild)}});function Z(o,a){if(a){var p=o.firstChild;if(p&&p===o.lastChild&&p.nodeType===3){p.nodeValue=a;return}}o.textContent=a}var Ge={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},He=["Webkit","ms","Moz","O"];Object.keys(Ge).forEach(function(o){He.forEach(function(a){a=a+o.charAt(0).toUpperCase()+o.substring(1),Ge[a]=Ge[o]})});function kt(o,a,p){return a==null||typeof a=="boolean"||a===""?"":p||typeof a!="number"||a===0||Ge.hasOwnProperty(o)&&Ge[o]?(""+a).trim():a+"px"}function Ze(o,a){o=o.style;for(var p in a)if(a.hasOwnProperty(p)){var g=p.indexOf("--")===0,x=kt(p,a[p],g);p==="float"&&(p="cssFloat"),g?o.setProperty(p,x):o[p]=x}}var nt=te({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 qe(o,a){if(a){if(nt[o]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,o));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function Un(o,a){if(o.indexOf("-")===-1)return typeof a.is=="string";switch(o){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 ln=null;function oe(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var ve=null,Fe=null,St=null;function $t(o){if(o=Xo(o)){if(typeof ve!="function")throw Error(n(280));var a=o.stateNode;a&&(a=xa(a),ve(o.stateNode,o.type,a))}}function D(o){Fe?St?St.push(o):St=[o]:Fe=o}function se(){if(Fe){var o=Fe,a=St;if(St=Fe=null,$t(o),a)for(o=0;o<a.length;o++)$t(a[o])}}function we(o,a){return o(a)}function Je(){}var xt=!1;function Et(o,a,p){if(xt)return o(a,p);xt=!0;try{return we(o,a,p)}finally{xt=!1,(Fe!==null||St!==null)&&(Je(),se())}}function _e(o,a){var p=o.stateNode;if(p===null)return null;var g=xa(p);if(g===null)return null;p=g[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(o=o.type,g=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!g;break e;default:o=!1}if(o)return null;if(p&&typeof p!="function")throw Error(n(231,a,typeof p));return p}var Ce=!1;if(c)try{var We={};Object.defineProperty(We,"passive",{get:function(){Ce=!0}}),window.addEventListener("test",We,We),window.removeEventListener("test",We,We)}catch{Ce=!1}function en(o,a,p,g,x,S,_,j,P){var q=Array.prototype.slice.call(arguments,3);try{a.apply(p,q)}catch(fe){this.onError(fe)}}var _t=!1,Rr=null,fs=!1,ti=null,rd={onError:function(o){_t=!0,Rr=o}};function Ro(o,a,p,g,x,S,_,j,P){_t=!1,Rr=null,en.apply(rd,arguments)}function sd(o,a,p,g,x,S,_,j,P){if(Ro.apply(this,arguments),_t){if(_t){var q=Rr;_t=!1,Rr=null}else throw Error(n(198));fs||(fs=!0,ti=q)}}function Kr(o){var a=o,p=o;if(o.alternate)for(;a.return;)a=a.return;else{o=a;do a=o,(a.flags&4098)!==0&&(p=a.return),o=a.return;while(o)}return a.tag===3?p:null}function Xl(o){if(o.tag===13){var a=o.memoizedState;if(a===null&&(o=o.alternate,o!==null&&(a=o.memoizedState)),a!==null)return a.dehydrated}return null}function Io(o){if(Kr(o)!==o)throw Error(n(188))}function zi(o){var a=o.alternate;if(!a){if(a=Kr(o),a===null)throw Error(n(188));return a!==o?null:o}for(var p=o,g=a;;){var x=p.return;if(x===null)break;var S=x.alternate;if(S===null){if(g=x.return,g!==null){p=g;continue}break}if(x.child===S.child){for(S=x.child;S;){if(S===p)return Io(x),o;if(S===g)return Io(x),a;S=S.sibling}throw Error(n(188))}if(p.return!==g.return)p=x,g=S;else{for(var _=!1,j=x.child;j;){if(j===p){_=!0,p=x,g=S;break}if(j===g){_=!0,g=x,p=S;break}j=j.sibling}if(!_){for(j=S.child;j;){if(j===p){_=!0,p=S,g=x;break}if(j===g){_=!0,g=S,p=x;break}j=j.sibling}if(!_)throw Error(n(189))}}if(p.alternate!==g)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?o:a}function Zl(o){return o=zi(o),o!==null?ea(o):null}function ea(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var a=ea(o);if(a!==null)return a;o=o.sibling}return null}var ta=e.unstable_scheduleCallback,vr=e.unstable_cancelCallback,na=e.unstable_shouldYield,ra=e.unstable_requestPaint,Pt=e.unstable_now,id=e.unstable_getCurrentPriorityLevel,jo=e.unstable_ImmediatePriority,ni=e.unstable_UserBlockingPriority,Fi=e.unstable_NormalPriority,ye=e.unstable_LowPriority,De=e.unstable_IdlePriority,rt=null,ot=null;function Yt(o){if(ot&&typeof ot.onCommitFiberRoot=="function")try{ot.onCommitFiberRoot(rt,o,void 0,(o.current.flags&128)===128)}catch{}}var Bt=Math.clz32?Math.clz32:Ln,Ir=Math.log,$i=Math.LN2;function Ln(o){return o>>>=0,o===0?32:31-(Ir(o)/$i|0)|0}var Dn=64,ri=4194304;function ps(o){switch(o&-o){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 o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function si(o,a){var p=o.pendingLanes;if(p===0)return 0;var g=0,x=o.suspendedLanes,S=o.pingedLanes,_=p&268435455;if(_!==0){var j=_&~x;j!==0?g=ps(j):(S&=_,S!==0&&(g=ps(S)))}else _=p&~x,_!==0?g=ps(_):S!==0&&(g=ps(S));if(g===0)return 0;if(a!==0&&a!==g&&(a&x)===0&&(x=g&-g,S=a&-a,x>=S||x===16&&(S&4194240)!==0))return a;if((g&4)!==0&&(g|=p&16),a=o.entangledLanes,a!==0)for(o=o.entanglements,a&=g;0<a;)p=31-Bt(a),x=1<<p,g|=o[p],a&=~x;return g}function od(o,a){switch(o){case 1:case 2:case 4:return a+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 a+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 ld(o,a){for(var p=o.suspendedLanes,g=o.pingedLanes,x=o.expirationTimes,S=o.pendingLanes;0<S;){var _=31-Bt(S),j=1<<_,P=x[_];P===-1?((j&p)===0||(j&g)!==0)&&(x[_]=od(j,a)):P<=a&&(o.expiredLanes|=j),S&=~j}}function Lo(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function sa(){var o=Dn;return Dn<<=1,(Dn&4194240)===0&&(Dn=64),o}function hs(o){for(var a=[],p=0;31>p;p++)a.push(o);return a}function ms(o,a,p){o.pendingLanes|=a,a!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,a=31-Bt(a),o[a]=p}function or(o,a){var p=o.pendingLanes&~a;o.pendingLanes=a,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=a,o.mutableReadLanes&=a,o.entangledLanes&=a,a=o.entanglements;var g=o.eventTimes;for(o=o.expirationTimes;0<p;){var x=31-Bt(p),S=1<<x;a[x]=0,g[x]=-1,o[x]=-1,p&=~S}}function Do(o,a){var p=o.entangledLanes|=a;for(o=o.entanglements;p;){var g=31-Bt(p),x=1<<g;x&a|o[g]&a&&(o[g]|=a),p&=~x}}var ut=0;function et(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Po,Qt,vt,ii,jr,oi=!1,gs=[],ke=null,Te=null,Qe=null,at=new Map,Ut=new Map,an=[],ad="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 ia(o,a){switch(o){case"focusin":case"focusout":ke=null;break;case"dragenter":case"dragleave":Te=null;break;case"mouseover":case"mouseout":Qe=null;break;case"pointerover":case"pointerout":at.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ut.delete(a.pointerId)}}function Bo(o,a,p,g,x,S){return o===null||o.nativeEvent!==S?(o={blockedOn:a,domEventName:p,eventSystemFlags:g,nativeEvent:S,targetContainers:[x]},a!==null&&(a=Xo(a),a!==null&&Qt(a)),o):(o.eventSystemFlags|=g,a=o.targetContainers,x!==null&&a.indexOf(x)===-1&&a.push(x),o)}function L1(o,a,p,g,x){switch(a){case"focusin":return ke=Bo(ke,o,a,p,g,x),!0;case"dragenter":return Te=Bo(Te,o,a,p,g,x),!0;case"mouseover":return Qe=Bo(Qe,o,a,p,g,x),!0;case"pointerover":var S=x.pointerId;return at.set(S,Bo(at.get(S)||null,o,a,p,g,x)),!0;case"gotpointercapture":return S=x.pointerId,Ut.set(S,Bo(Ut.get(S)||null,o,a,p,g,x)),!0}return!1}function km(o){var a=li(o.target);if(a!==null){var p=Kr(a);if(p!==null){if(a=p.tag,a===13){if(a=Xl(p),a!==null){o.blockedOn=a,jr(o.priority,function(){vt(p)});return}}else if(a===3&&p.stateNode.current.memoizedState.isDehydrated){o.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}o.blockedOn=null}function oa(o){if(o.blockedOn!==null)return!1;for(var a=o.targetContainers;0<a.length;){var p=ud(o.domEventName,o.eventSystemFlags,a[0],o.nativeEvent);if(p===null){p=o.nativeEvent;var g=new p.constructor(p.type,p);ln=g,p.target.dispatchEvent(g),ln=null}else return a=Xo(p),a!==null&&Qt(a),o.blockedOn=p,!1;a.shift()}return!0}function Sm(o,a,p){oa(o)&&p.delete(a)}function D1(){oi=!1,ke!==null&&oa(ke)&&(ke=null),Te!==null&&oa(Te)&&(Te=null),Qe!==null&&oa(Qe)&&(Qe=null),at.forEach(Sm),Ut.forEach(Sm)}function zo(o,a){o.blockedOn===a&&(o.blockedOn=null,oi||(oi=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,D1)))}function Fo(o){function a(x){return zo(x,o)}if(0<gs.length){zo(gs[0],o);for(var p=1;p<gs.length;p++){var g=gs[p];g.blockedOn===o&&(g.blockedOn=null)}}for(ke!==null&&zo(ke,o),Te!==null&&zo(Te,o),Qe!==null&&zo(Qe,o),at.forEach(a),Ut.forEach(a),p=0;p<an.length;p++)g=an[p],g.blockedOn===o&&(g.blockedOn=null);for(;0<an.length&&(p=an[0],p.blockedOn===null);)km(p),p.blockedOn===null&&an.shift()}var Ui=T.ReactCurrentBatchConfig,la=!0;function P1(o,a,p,g){var x=ut,S=Ui.transition;Ui.transition=null;try{ut=1,cd(o,a,p,g)}finally{ut=x,Ui.transition=S}}function B1(o,a,p,g){var x=ut,S=Ui.transition;Ui.transition=null;try{ut=4,cd(o,a,p,g)}finally{ut=x,Ui.transition=S}}function cd(o,a,p,g){if(la){var x=ud(o,a,p,g);if(x===null)_d(o,a,g,aa,p),ia(o,g);else if(L1(x,o,a,p,g))g.stopPropagation();else if(ia(o,g),a&4&&-1<ad.indexOf(o)){for(;x!==null;){var S=Xo(x);if(S!==null&&Po(S),S=ud(o,a,p,g),S===null&&_d(o,a,g,aa,p),S===x)break;x=S}x!==null&&g.stopPropagation()}else _d(o,a,g,null,p)}}var aa=null;function ud(o,a,p,g){if(aa=null,o=oe(g),o=li(o),o!==null)if(a=Kr(o),a===null)o=null;else if(p=a.tag,p===13){if(o=Xl(a),o!==null)return o;o=null}else if(p===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;o=null}else a!==o&&(o=null);return aa=o,null}function Em(o){switch(o){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(id()){case jo:return 1;case ni:return 4;case Fi:case ye:return 16;case De:return 536870912;default:return 16}default:return 16}}var ys=null,dd=null,ca=null;function Nm(){if(ca)return ca;var o,a=dd,p=a.length,g,x="value"in ys?ys.value:ys.textContent,S=x.length;for(o=0;o<p&&a[o]===x[o];o++);var _=p-o;for(g=1;g<=_&&a[p-g]===x[S-g];g++);return ca=x.slice(o,1<g?1-g:void 0)}function ua(o){var a=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&a===13&&(o=13)):o=a,o===10&&(o=13),32<=o||o===13?o:0}function da(){return!0}function Cm(){return!1}function Zn(o){function a(p,g,x,S,_){this._reactName=p,this._targetInst=x,this.type=g,this.nativeEvent=S,this.target=_,this.currentTarget=null;for(var j in o)o.hasOwnProperty(j)&&(p=o[j],this[j]=p?p(S):S[j]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?da:Cm,this.isPropagationStopped=Cm,this}return te(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=da)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=da)},persist:function(){},isPersistent:da}),a}var Hi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fd=Zn(Hi),$o=te({},Hi,{view:0,detail:0}),z1=Zn($o),pd,hd,Uo,fa=te({},$o,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:gd,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Uo&&(Uo&&o.type==="mousemove"?(pd=o.screenX-Uo.screenX,hd=o.screenY-Uo.screenY):hd=pd=0,Uo=o),pd)},movementY:function(o){return"movementY"in o?o.movementY:hd}}),_m=Zn(fa),F1=te({},fa,{dataTransfer:0}),$1=Zn(F1),U1=te({},$o,{relatedTarget:0}),md=Zn(U1),H1=te({},Hi,{animationName:0,elapsedTime:0,pseudoElement:0}),W1=Zn(H1),V1=te({},Hi,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),K1=Zn(V1),G1=te({},Hi,{data:0}),Tm=Zn(G1),q1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},J1={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"},Y1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Q1(o){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(o):(o=Y1[o])?!!a[o]:!1}function gd(){return Q1}var X1=te({},$o,{key:function(o){if(o.key){var a=q1[o.key]||o.key;if(a!=="Unidentified")return a}return o.type==="keypress"?(o=ua(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?J1[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:gd,charCode:function(o){return o.type==="keypress"?ua(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?ua(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),Z1=Zn(X1),eS=te({},fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Mm=Zn(eS),tS=te({},$o,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:gd}),nS=Zn(tS),rS=te({},Hi,{propertyName:0,elapsedTime:0,pseudoElement:0}),sS=Zn(rS),iS=te({},fa,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),oS=Zn(iS),lS=[9,13,27,32],yd=c&&"CompositionEvent"in window,Ho=null;c&&"documentMode"in document&&(Ho=document.documentMode);var aS=c&&"TextEvent"in window&&!Ho,Am=c&&(!yd||Ho&&8<Ho&&11>=Ho),Om=" ",Rm=!1;function Im(o,a){switch(o){case"keyup":return lS.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jm(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Wi=!1;function cS(o,a){switch(o){case"compositionend":return jm(a);case"keypress":return a.which!==32?null:(Rm=!0,Om);case"textInput":return o=a.data,o===Om&&Rm?null:o;default:return null}}function uS(o,a){if(Wi)return o==="compositionend"||!yd&&Im(o,a)?(o=Nm(),ca=dd=ys=null,Wi=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Am&&a.locale!=="ko"?null:a.data;default:return null}}var dS={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 Lm(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a==="input"?!!dS[o.type]:a==="textarea"}function Dm(o,a,p,g){D(g),a=ya(a,"onChange"),0<a.length&&(p=new fd("onChange","change",null,p,g),o.push({event:p,listeners:a}))}var Wo=null,Vo=null;function fS(o){eg(o,0)}function pa(o){var a=Ji(o);if(ie(a))return o}function pS(o,a){if(o==="change")return a}var Pm=!1;if(c){var bd;if(c){var vd="oninput"in document;if(!vd){var Bm=document.createElement("div");Bm.setAttribute("oninput","return;"),vd=typeof Bm.oninput=="function"}bd=vd}else bd=!1;Pm=bd&&(!document.documentMode||9<document.documentMode)}function zm(){Wo&&(Wo.detachEvent("onpropertychange",Fm),Vo=Wo=null)}function Fm(o){if(o.propertyName==="value"&&pa(Vo)){var a=[];Dm(a,Vo,o,oe(o)),Et(fS,a)}}function hS(o,a,p){o==="focusin"?(zm(),Wo=a,Vo=p,Wo.attachEvent("onpropertychange",Fm)):o==="focusout"&&zm()}function mS(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return pa(Vo)}function gS(o,a){if(o==="click")return pa(a)}function yS(o,a){if(o==="input"||o==="change")return pa(a)}function bS(o,a){return o===a&&(o!==0||1/o===1/a)||o!==o&&a!==a}var xr=typeof Object.is=="function"?Object.is:bS;function Ko(o,a){if(xr(o,a))return!0;if(typeof o!="object"||o===null||typeof a!="object"||a===null)return!1;var p=Object.keys(o),g=Object.keys(a);if(p.length!==g.length)return!1;for(g=0;g<p.length;g++){var x=p[g];if(!u.call(a,x)||!xr(o[x],a[x]))return!1}return!0}function $m(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Um(o,a){var p=$m(o);o=0;for(var g;p;){if(p.nodeType===3){if(g=o+p.textContent.length,o<=a&&g>=a)return{node:p,offset:a-o};o=g}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=$m(p)}}function Hm(o,a){return o&&a?o===a?!0:o&&o.nodeType===3?!1:a&&a.nodeType===3?Hm(o,a.parentNode):"contains"in o?o.contains(a):o.compareDocumentPosition?!!(o.compareDocumentPosition(a)&16):!1:!1}function Wm(){for(var o=window,a=Le();a instanceof o.HTMLIFrameElement;){try{var p=typeof a.contentWindow.location.href=="string"}catch{p=!1}if(p)o=a.contentWindow;else break;a=Le(o.document)}return a}function xd(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a&&(a==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||a==="textarea"||o.contentEditable==="true")}function vS(o){var a=Wm(),p=o.focusedElem,g=o.selectionRange;if(a!==p&&p&&p.ownerDocument&&Hm(p.ownerDocument.documentElement,p)){if(g!==null&&xd(p)){if(a=g.start,o=g.end,o===void 0&&(o=a),"selectionStart"in p)p.selectionStart=a,p.selectionEnd=Math.min(o,p.value.length);else if(o=(a=p.ownerDocument||document)&&a.defaultView||window,o.getSelection){o=o.getSelection();var x=p.textContent.length,S=Math.min(g.start,x);g=g.end===void 0?S:Math.min(g.end,x),!o.extend&&S>g&&(x=g,g=S,S=x),x=Um(p,S);var _=Um(p,g);x&&_&&(o.rangeCount!==1||o.anchorNode!==x.node||o.anchorOffset!==x.offset||o.focusNode!==_.node||o.focusOffset!==_.offset)&&(a=a.createRange(),a.setStart(x.node,x.offset),o.removeAllRanges(),S>g?(o.addRange(a),o.extend(_.node,_.offset)):(a.setEnd(_.node,_.offset),o.addRange(a)))}}for(a=[],o=p;o=o.parentNode;)o.nodeType===1&&a.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<a.length;p++)o=a[p],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var xS=c&&"documentMode"in document&&11>=document.documentMode,Vi=null,wd=null,Go=null,kd=!1;function Vm(o,a,p){var g=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;kd||Vi==null||Vi!==Le(g)||(g=Vi,"selectionStart"in g&&xd(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Go&&Ko(Go,g)||(Go=g,g=ya(wd,"onSelect"),0<g.length&&(a=new fd("onSelect","select",null,a,p),o.push({event:a,listeners:g}),a.target=Vi)))}function ha(o,a){var p={};return p[o.toLowerCase()]=a.toLowerCase(),p["Webkit"+o]="webkit"+a,p["Moz"+o]="moz"+a,p}var Ki={animationend:ha("Animation","AnimationEnd"),animationiteration:ha("Animation","AnimationIteration"),animationstart:ha("Animation","AnimationStart"),transitionend:ha("Transition","TransitionEnd")},Sd={},Km={};c&&(Km=document.createElement("div").style,"AnimationEvent"in window||(delete Ki.animationend.animation,delete Ki.animationiteration.animation,delete Ki.animationstart.animation),"TransitionEvent"in window||delete Ki.transitionend.transition);function ma(o){if(Sd[o])return Sd[o];if(!Ki[o])return o;var a=Ki[o],p;for(p in a)if(a.hasOwnProperty(p)&&p in Km)return Sd[o]=a[p];return o}var Gm=ma("animationend"),qm=ma("animationiteration"),Jm=ma("animationstart"),Ym=ma("transitionend"),Qm=new Map,Xm="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 bs(o,a){Qm.set(o,a),i(a,[o])}for(var Ed=0;Ed<Xm.length;Ed++){var Nd=Xm[Ed],wS=Nd.toLowerCase(),kS=Nd[0].toUpperCase()+Nd.slice(1);bs(wS,"on"+kS)}bs(Gm,"onAnimationEnd"),bs(qm,"onAnimationIteration"),bs(Jm,"onAnimationStart"),bs("dblclick","onDoubleClick"),bs("focusin","onFocus"),bs("focusout","onBlur"),bs(Ym,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("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 qo="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(" "),SS=new Set("cancel close invalid load scroll toggle".split(" ").concat(qo));function Zm(o,a,p){var g=o.type||"unknown-event";o.currentTarget=p,sd(g,a,void 0,o),o.currentTarget=null}function eg(o,a){a=(a&4)!==0;for(var p=0;p<o.length;p++){var g=o[p],x=g.event;g=g.listeners;e:{var S=void 0;if(a)for(var _=g.length-1;0<=_;_--){var j=g[_],P=j.instance,q=j.currentTarget;if(j=j.listener,P!==S&&x.isPropagationStopped())break e;Zm(x,j,q),S=P}else for(_=0;_<g.length;_++){if(j=g[_],P=j.instance,q=j.currentTarget,j=j.listener,P!==S&&x.isPropagationStopped())break e;Zm(x,j,q),S=P}}}if(fs)throw o=ti,fs=!1,ti=null,o}function Rt(o,a){var p=a[Id];p===void 0&&(p=a[Id]=new Set);var g=o+"__bubble";p.has(g)||(tg(a,o,2,!1),p.add(g))}function Cd(o,a,p){var g=0;a&&(g|=4),tg(p,o,g,a)}var ga="_reactListening"+Math.random().toString(36).slice(2);function Jo(o){if(!o[ga]){o[ga]=!0,r.forEach(function(p){p!=="selectionchange"&&(SS.has(p)||Cd(p,!1,o),Cd(p,!0,o))});var a=o.nodeType===9?o:o.ownerDocument;a===null||a[ga]||(a[ga]=!0,Cd("selectionchange",!1,a))}}function tg(o,a,p,g){switch(Em(a)){case 1:var x=P1;break;case 4:x=B1;break;default:x=cd}p=x.bind(null,a,p,o),x=void 0,!Ce||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(x=!0),g?x!==void 0?o.addEventListener(a,p,{capture:!0,passive:x}):o.addEventListener(a,p,!0):x!==void 0?o.addEventListener(a,p,{passive:x}):o.addEventListener(a,p,!1)}function _d(o,a,p,g,x){var S=g;if((a&1)===0&&(a&2)===0&&g!==null)e:for(;;){if(g===null)return;var _=g.tag;if(_===3||_===4){var j=g.stateNode.containerInfo;if(j===x||j.nodeType===8&&j.parentNode===x)break;if(_===4)for(_=g.return;_!==null;){var P=_.tag;if((P===3||P===4)&&(P=_.stateNode.containerInfo,P===x||P.nodeType===8&&P.parentNode===x))return;_=_.return}for(;j!==null;){if(_=li(j),_===null)return;if(P=_.tag,P===5||P===6){g=S=_;continue e}j=j.parentNode}}g=g.return}Et(function(){var q=S,fe=oe(p),he=[];e:{var de=Qm.get(o);if(de!==void 0){var Ee=fd,Oe=o;switch(o){case"keypress":if(ua(p)===0)break e;case"keydown":case"keyup":Ee=Z1;break;case"focusin":Oe="focus",Ee=md;break;case"focusout":Oe="blur",Ee=md;break;case"beforeblur":case"afterblur":Ee=md;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ee=_m;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=$1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=nS;break;case Gm:case qm:case Jm:Ee=W1;break;case Ym:Ee=sS;break;case"scroll":Ee=z1;break;case"wheel":Ee=oS;break;case"copy":case"cut":case"paste":Ee=K1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=Mm}var Ie=(a&4)!==0,Xt=!Ie&&o==="scroll",W=Ie?de!==null?de+"Capture":null:de;Ie=[];for(var F=q,K;F!==null;){K=F;var be=K.stateNode;if(K.tag===5&&be!==null&&(K=be,W!==null&&(be=_e(F,W),be!=null&&Ie.push(Yo(F,be,K)))),Xt)break;F=F.return}0<Ie.length&&(de=new Ee(de,Oe,null,p,fe),he.push({event:de,listeners:Ie}))}}if((a&7)===0){e:{if(de=o==="mouseover"||o==="pointerover",Ee=o==="mouseout"||o==="pointerout",de&&p!==ln&&(Oe=p.relatedTarget||p.fromElement)&&(li(Oe)||Oe[Gr]))break e;if((Ee||de)&&(de=fe.window===fe?fe:(de=fe.ownerDocument)?de.defaultView||de.parentWindow:window,Ee?(Oe=p.relatedTarget||p.toElement,Ee=q,Oe=Oe?li(Oe):null,Oe!==null&&(Xt=Kr(Oe),Oe!==Xt||Oe.tag!==5&&Oe.tag!==6)&&(Oe=null)):(Ee=null,Oe=q),Ee!==Oe)){if(Ie=_m,be="onMouseLeave",W="onMouseEnter",F="mouse",(o==="pointerout"||o==="pointerover")&&(Ie=Mm,be="onPointerLeave",W="onPointerEnter",F="pointer"),Xt=Ee==null?de:Ji(Ee),K=Oe==null?de:Ji(Oe),de=new Ie(be,F+"leave",Ee,p,fe),de.target=Xt,de.relatedTarget=K,be=null,li(fe)===q&&(Ie=new Ie(W,F+"enter",Oe,p,fe),Ie.target=K,Ie.relatedTarget=Xt,be=Ie),Xt=be,Ee&&Oe)t:{for(Ie=Ee,W=Oe,F=0,K=Ie;K;K=Gi(K))F++;for(K=0,be=W;be;be=Gi(be))K++;for(;0<F-K;)Ie=Gi(Ie),F--;for(;0<K-F;)W=Gi(W),K--;for(;F--;){if(Ie===W||W!==null&&Ie===W.alternate)break t;Ie=Gi(Ie),W=Gi(W)}Ie=null}else Ie=null;Ee!==null&&ng(he,de,Ee,Ie,!1),Oe!==null&&Xt!==null&&ng(he,Xt,Oe,Ie,!0)}}e:{if(de=q?Ji(q):window,Ee=de.nodeName&&de.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&de.type==="file")var je=pS;else if(Lm(de))if(Pm)je=yS;else{je=mS;var Ve=hS}else(Ee=de.nodeName)&&Ee.toLowerCase()==="input"&&(de.type==="checkbox"||de.type==="radio")&&(je=gS);if(je&&(je=je(o,q))){Dm(he,je,p,fe);break e}Ve&&Ve(o,de,q),o==="focusout"&&(Ve=de._wrapperState)&&Ve.controlled&&de.type==="number"&&ct(de,"number",de.value)}switch(Ve=q?Ji(q):window,o){case"focusin":(Lm(Ve)||Ve.contentEditable==="true")&&(Vi=Ve,wd=q,Go=null);break;case"focusout":Go=wd=Vi=null;break;case"mousedown":kd=!0;break;case"contextmenu":case"mouseup":case"dragend":kd=!1,Vm(he,p,fe);break;case"selectionchange":if(xS)break;case"keydown":case"keyup":Vm(he,p,fe)}var Ke;if(yd)e:{switch(o){case"compositionstart":var Xe="onCompositionStart";break e;case"compositionend":Xe="onCompositionEnd";break e;case"compositionupdate":Xe="onCompositionUpdate";break e}Xe=void 0}else Wi?Im(o,p)&&(Xe="onCompositionEnd"):o==="keydown"&&p.keyCode===229&&(Xe="onCompositionStart");Xe&&(Am&&p.locale!=="ko"&&(Wi||Xe!=="onCompositionStart"?Xe==="onCompositionEnd"&&Wi&&(Ke=Nm()):(ys=fe,dd="value"in ys?ys.value:ys.textContent,Wi=!0)),Ve=ya(q,Xe),0<Ve.length&&(Xe=new Tm(Xe,o,null,p,fe),he.push({event:Xe,listeners:Ve}),Ke?Xe.data=Ke:(Ke=jm(p),Ke!==null&&(Xe.data=Ke)))),(Ke=aS?cS(o,p):uS(o,p))&&(q=ya(q,"onBeforeInput"),0<q.length&&(fe=new Tm("onBeforeInput","beforeinput",null,p,fe),he.push({event:fe,listeners:q}),fe.data=Ke))}eg(he,a)})}function Yo(o,a,p){return{instance:o,listener:a,currentTarget:p}}function ya(o,a){for(var p=a+"Capture",g=[];o!==null;){var x=o,S=x.stateNode;x.tag===5&&S!==null&&(x=S,S=_e(o,p),S!=null&&g.unshift(Yo(o,S,x)),S=_e(o,a),S!=null&&g.push(Yo(o,S,x))),o=o.return}return g}function Gi(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function ng(o,a,p,g,x){for(var S=a._reactName,_=[];p!==null&&p!==g;){var j=p,P=j.alternate,q=j.stateNode;if(P!==null&&P===g)break;j.tag===5&&q!==null&&(j=q,x?(P=_e(p,S),P!=null&&_.unshift(Yo(p,P,j))):x||(P=_e(p,S),P!=null&&_.push(Yo(p,P,j)))),p=p.return}_.length!==0&&o.push({event:a,listeners:_})}var ES=/\r\n?/g,NS=/\u0000|\uFFFD/g;function rg(o){return(typeof o=="string"?o:""+o).replace(ES,`
|
|
38
|
+
`).replace(NS,"")}function ba(o,a,p){if(a=rg(a),rg(o)!==a&&p)throw Error(n(425))}function va(){}var Td=null,Md=null;function Ad(o,a){return o==="textarea"||o==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Od=typeof setTimeout=="function"?setTimeout:void 0,CS=typeof clearTimeout=="function"?clearTimeout:void 0,sg=typeof Promise=="function"?Promise:void 0,_S=typeof queueMicrotask=="function"?queueMicrotask:typeof sg<"u"?function(o){return sg.resolve(null).then(o).catch(TS)}:Od;function TS(o){setTimeout(function(){throw o})}function Rd(o,a){var p=a,g=0;do{var x=p.nextSibling;if(o.removeChild(p),x&&x.nodeType===8)if(p=x.data,p==="/$"){if(g===0){o.removeChild(x),Fo(a);return}g--}else p!=="$"&&p!=="$?"&&p!=="$!"||g++;p=x}while(p);Fo(a)}function vs(o){for(;o!=null;o=o.nextSibling){var a=o.nodeType;if(a===1||a===3)break;if(a===8){if(a=o.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return o}function ig(o){o=o.previousSibling;for(var a=0;o;){if(o.nodeType===8){var p=o.data;if(p==="$"||p==="$!"||p==="$?"){if(a===0)return o;a--}else p==="/$"&&a++}o=o.previousSibling}return null}var qi=Math.random().toString(36).slice(2),Lr="__reactFiber$"+qi,Qo="__reactProps$"+qi,Gr="__reactContainer$"+qi,Id="__reactEvents$"+qi,MS="__reactListeners$"+qi,AS="__reactHandles$"+qi;function li(o){var a=o[Lr];if(a)return a;for(var p=o.parentNode;p;){if(a=p[Gr]||p[Lr]){if(p=a.alternate,a.child!==null||p!==null&&p.child!==null)for(o=ig(o);o!==null;){if(p=o[Lr])return p;o=ig(o)}return a}o=p,p=o.parentNode}return null}function Xo(o){return o=o[Lr]||o[Gr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function Ji(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(n(33))}function xa(o){return o[Qo]||null}var jd=[],Yi=-1;function xs(o){return{current:o}}function It(o){0>Yi||(o.current=jd[Yi],jd[Yi]=null,Yi--)}function Tt(o,a){Yi++,jd[Yi]=o.current,o.current=a}var ws={},_n=xs(ws),Hn=xs(!1),ai=ws;function Qi(o,a){var p=o.type.contextTypes;if(!p)return ws;var g=o.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===a)return g.__reactInternalMemoizedMaskedChildContext;var x={},S;for(S in p)x[S]=a[S];return g&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=a,o.__reactInternalMemoizedMaskedChildContext=x),x}function Wn(o){return o=o.childContextTypes,o!=null}function wa(){It(Hn),It(_n)}function og(o,a,p){if(_n.current!==ws)throw Error(n(168));Tt(_n,a),Tt(Hn,p)}function lg(o,a,p){var g=o.stateNode;if(a=a.childContextTypes,typeof g.getChildContext!="function")return p;g=g.getChildContext();for(var x in g)if(!(x in a))throw Error(n(108,Re(o)||"Unknown",x));return te({},p,g)}function ka(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||ws,ai=_n.current,Tt(_n,o),Tt(Hn,Hn.current),!0}function ag(o,a,p){var g=o.stateNode;if(!g)throw Error(n(169));p?(o=lg(o,a,ai),g.__reactInternalMemoizedMergedChildContext=o,It(Hn),It(_n),Tt(_n,o)):It(Hn),Tt(Hn,p)}var qr=null,Sa=!1,Ld=!1;function cg(o){qr===null?qr=[o]:qr.push(o)}function OS(o){Sa=!0,cg(o)}function ks(){if(!Ld&&qr!==null){Ld=!0;var o=0,a=ut;try{var p=qr;for(ut=1;o<p.length;o++){var g=p[o];do g=g(!0);while(g!==null)}qr=null,Sa=!1}catch(x){throw qr!==null&&(qr=qr.slice(o+1)),ta(jo,ks),x}finally{ut=a,Ld=!1}}return null}var Xi=[],Zi=0,Ea=null,Na=0,lr=[],ar=0,ci=null,Jr=1,Yr="";function ui(o,a){Xi[Zi++]=Na,Xi[Zi++]=Ea,Ea=o,Na=a}function ug(o,a,p){lr[ar++]=Jr,lr[ar++]=Yr,lr[ar++]=ci,ci=o;var g=Jr;o=Yr;var x=32-Bt(g)-1;g&=~(1<<x),p+=1;var S=32-Bt(a)+x;if(30<S){var _=x-x%5;S=(g&(1<<_)-1).toString(32),g>>=_,x-=_,Jr=1<<32-Bt(a)+x|p<<x|g,Yr=S+o}else Jr=1<<S|p<<x|g,Yr=o}function Dd(o){o.return!==null&&(ui(o,1),ug(o,1,0))}function Pd(o){for(;o===Ea;)Ea=Xi[--Zi],Xi[Zi]=null,Na=Xi[--Zi],Xi[Zi]=null;for(;o===ci;)ci=lr[--ar],lr[ar]=null,Yr=lr[--ar],lr[ar]=null,Jr=lr[--ar],lr[ar]=null}var er=null,tr=null,Dt=!1,wr=null;function dg(o,a){var p=fr(5,null,null,0);p.elementType="DELETED",p.stateNode=a,p.return=o,a=o.deletions,a===null?(o.deletions=[p],o.flags|=16):a.push(p)}function fg(o,a){switch(o.tag){case 5:var p=o.type;return a=a.nodeType!==1||p.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(o.stateNode=a,er=o,tr=vs(a.firstChild),!0):!1;case 6:return a=o.pendingProps===""||a.nodeType!==3?null:a,a!==null?(o.stateNode=a,er=o,tr=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(p=ci!==null?{id:Jr,overflow:Yr}:null,o.memoizedState={dehydrated:a,treeContext:p,retryLane:1073741824},p=fr(18,null,null,0),p.stateNode=a,p.return=o,o.child=p,er=o,tr=null,!0):!1;default:return!1}}function Bd(o){return(o.mode&1)!==0&&(o.flags&128)===0}function zd(o){if(Dt){var a=tr;if(a){var p=a;if(!fg(o,a)){if(Bd(o))throw Error(n(418));a=vs(p.nextSibling);var g=er;a&&fg(o,a)?dg(g,p):(o.flags=o.flags&-4097|2,Dt=!1,er=o)}}else{if(Bd(o))throw Error(n(418));o.flags=o.flags&-4097|2,Dt=!1,er=o}}}function pg(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;er=o}function Ca(o){if(o!==er)return!1;if(!Dt)return pg(o),Dt=!0,!1;var a;if((a=o.tag!==3)&&!(a=o.tag!==5)&&(a=o.type,a=a!=="head"&&a!=="body"&&!Ad(o.type,o.memoizedProps)),a&&(a=tr)){if(Bd(o))throw hg(),Error(n(418));for(;a;)dg(o,a),a=vs(a.nextSibling)}if(pg(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(317));e:{for(o=o.nextSibling,a=0;o;){if(o.nodeType===8){var p=o.data;if(p==="/$"){if(a===0){tr=vs(o.nextSibling);break e}a--}else p!=="$"&&p!=="$!"&&p!=="$?"||a++}o=o.nextSibling}tr=null}}else tr=er?vs(o.stateNode.nextSibling):null;return!0}function hg(){for(var o=tr;o;)o=vs(o.nextSibling)}function eo(){tr=er=null,Dt=!1}function Fd(o){wr===null?wr=[o]:wr.push(o)}var RS=T.ReactCurrentBatchConfig;function Zo(o,a,p){if(o=p.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var g=p.stateNode}if(!g)throw Error(n(147,o));var x=g,S=""+o;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===S?a.ref:(a=function(_){var j=x.refs;_===null?delete j[S]:j[S]=_},a._stringRef=S,a)}if(typeof o!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,o))}return o}function _a(o,a){throw o=Object.prototype.toString.call(a),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":o))}function mg(o){var a=o._init;return a(o._payload)}function gg(o){function a(W,F){if(o){var K=W.deletions;K===null?(W.deletions=[F],W.flags|=16):K.push(F)}}function p(W,F){if(!o)return null;for(;F!==null;)a(W,F),F=F.sibling;return null}function g(W,F){for(W=new Map;F!==null;)F.key!==null?W.set(F.key,F):W.set(F.index,F),F=F.sibling;return W}function x(W,F){return W=As(W,F),W.index=0,W.sibling=null,W}function S(W,F,K){return W.index=K,o?(K=W.alternate,K!==null?(K=K.index,K<F?(W.flags|=2,F):K):(W.flags|=2,F)):(W.flags|=1048576,F)}function _(W){return o&&W.alternate===null&&(W.flags|=2),W}function j(W,F,K,be){return F===null||F.tag!==6?(F=Rf(K,W.mode,be),F.return=W,F):(F=x(F,K),F.return=W,F)}function P(W,F,K,be){var je=K.type;return je===B?fe(W,F,K.props.children,be,K.key):F!==null&&(F.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===G&&mg(je)===F.type)?(be=x(F,K.props),be.ref=Zo(W,F,K),be.return=W,be):(be=Qa(K.type,K.key,K.props,null,W.mode,be),be.ref=Zo(W,F,K),be.return=W,be)}function q(W,F,K,be){return F===null||F.tag!==4||F.stateNode.containerInfo!==K.containerInfo||F.stateNode.implementation!==K.implementation?(F=If(K,W.mode,be),F.return=W,F):(F=x(F,K.children||[]),F.return=W,F)}function fe(W,F,K,be,je){return F===null||F.tag!==7?(F=bi(K,W.mode,be,je),F.return=W,F):(F=x(F,K),F.return=W,F)}function he(W,F,K){if(typeof F=="string"&&F!==""||typeof F=="number")return F=Rf(""+F,W.mode,K),F.return=W,F;if(typeof F=="object"&&F!==null){switch(F.$$typeof){case M:return K=Qa(F.type,F.key,F.props,null,W.mode,K),K.ref=Zo(W,null,F),K.return=W,K;case R:return F=If(F,W.mode,K),F.return=W,F;case G:var be=F._init;return he(W,be(F._payload),K)}if(pt(F)||X(F))return F=bi(F,W.mode,K,null),F.return=W,F;_a(W,F)}return null}function de(W,F,K,be){var je=F!==null?F.key:null;if(typeof K=="string"&&K!==""||typeof K=="number")return je!==null?null:j(W,F,""+K,be);if(typeof K=="object"&&K!==null){switch(K.$$typeof){case M:return K.key===je?P(W,F,K,be):null;case R:return K.key===je?q(W,F,K,be):null;case G:return je=K._init,de(W,F,je(K._payload),be)}if(pt(K)||X(K))return je!==null?null:fe(W,F,K,be,null);_a(W,K)}return null}function Ee(W,F,K,be,je){if(typeof be=="string"&&be!==""||typeof be=="number")return W=W.get(K)||null,j(F,W,""+be,je);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case M:return W=W.get(be.key===null?K:be.key)||null,P(F,W,be,je);case R:return W=W.get(be.key===null?K:be.key)||null,q(F,W,be,je);case G:var Ve=be._init;return Ee(W,F,K,Ve(be._payload),je)}if(pt(be)||X(be))return W=W.get(K)||null,fe(F,W,be,je,null);_a(F,be)}return null}function Oe(W,F,K,be){for(var je=null,Ve=null,Ke=F,Xe=F=0,dn=null;Ke!==null&&Xe<K.length;Xe++){Ke.index>Xe?(dn=Ke,Ke=null):dn=Ke.sibling;var ht=de(W,Ke,K[Xe],be);if(ht===null){Ke===null&&(Ke=dn);break}o&&Ke&&ht.alternate===null&&a(W,Ke),F=S(ht,F,Xe),Ve===null?je=ht:Ve.sibling=ht,Ve=ht,Ke=dn}if(Xe===K.length)return p(W,Ke),Dt&&ui(W,Xe),je;if(Ke===null){for(;Xe<K.length;Xe++)Ke=he(W,K[Xe],be),Ke!==null&&(F=S(Ke,F,Xe),Ve===null?je=Ke:Ve.sibling=Ke,Ve=Ke);return Dt&&ui(W,Xe),je}for(Ke=g(W,Ke);Xe<K.length;Xe++)dn=Ee(Ke,W,Xe,K[Xe],be),dn!==null&&(o&&dn.alternate!==null&&Ke.delete(dn.key===null?Xe:dn.key),F=S(dn,F,Xe),Ve===null?je=dn:Ve.sibling=dn,Ve=dn);return o&&Ke.forEach(function(Os){return a(W,Os)}),Dt&&ui(W,Xe),je}function Ie(W,F,K,be){var je=X(K);if(typeof je!="function")throw Error(n(150));if(K=je.call(K),K==null)throw Error(n(151));for(var Ve=je=null,Ke=F,Xe=F=0,dn=null,ht=K.next();Ke!==null&&!ht.done;Xe++,ht=K.next()){Ke.index>Xe?(dn=Ke,Ke=null):dn=Ke.sibling;var Os=de(W,Ke,ht.value,be);if(Os===null){Ke===null&&(Ke=dn);break}o&&Ke&&Os.alternate===null&&a(W,Ke),F=S(Os,F,Xe),Ve===null?je=Os:Ve.sibling=Os,Ve=Os,Ke=dn}if(ht.done)return p(W,Ke),Dt&&ui(W,Xe),je;if(Ke===null){for(;!ht.done;Xe++,ht=K.next())ht=he(W,ht.value,be),ht!==null&&(F=S(ht,F,Xe),Ve===null?je=ht:Ve.sibling=ht,Ve=ht);return Dt&&ui(W,Xe),je}for(Ke=g(W,Ke);!ht.done;Xe++,ht=K.next())ht=Ee(Ke,W,Xe,ht.value,be),ht!==null&&(o&&ht.alternate!==null&&Ke.delete(ht.key===null?Xe:ht.key),F=S(ht,F,Xe),Ve===null?je=ht:Ve.sibling=ht,Ve=ht);return o&&Ke.forEach(function(dE){return a(W,dE)}),Dt&&ui(W,Xe),je}function Xt(W,F,K,be){if(typeof K=="object"&&K!==null&&K.type===B&&K.key===null&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case M:e:{for(var je=K.key,Ve=F;Ve!==null;){if(Ve.key===je){if(je=K.type,je===B){if(Ve.tag===7){p(W,Ve.sibling),F=x(Ve,K.props.children),F.return=W,W=F;break e}}else if(Ve.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===G&&mg(je)===Ve.type){p(W,Ve.sibling),F=x(Ve,K.props),F.ref=Zo(W,Ve,K),F.return=W,W=F;break e}p(W,Ve);break}else a(W,Ve);Ve=Ve.sibling}K.type===B?(F=bi(K.props.children,W.mode,be,K.key),F.return=W,W=F):(be=Qa(K.type,K.key,K.props,null,W.mode,be),be.ref=Zo(W,F,K),be.return=W,W=be)}return _(W);case R:e:{for(Ve=K.key;F!==null;){if(F.key===Ve)if(F.tag===4&&F.stateNode.containerInfo===K.containerInfo&&F.stateNode.implementation===K.implementation){p(W,F.sibling),F=x(F,K.children||[]),F.return=W,W=F;break e}else{p(W,F);break}else a(W,F);F=F.sibling}F=If(K,W.mode,be),F.return=W,W=F}return _(W);case G:return Ve=K._init,Xt(W,F,Ve(K._payload),be)}if(pt(K))return Oe(W,F,K,be);if(X(K))return Ie(W,F,K,be);_a(W,K)}return typeof K=="string"&&K!==""||typeof K=="number"?(K=""+K,F!==null&&F.tag===6?(p(W,F.sibling),F=x(F,K),F.return=W,W=F):(p(W,F),F=Rf(K,W.mode,be),F.return=W,W=F),_(W)):p(W,F)}return Xt}var to=gg(!0),yg=gg(!1),Ta=xs(null),Ma=null,no=null,$d=null;function Ud(){$d=no=Ma=null}function Hd(o){var a=Ta.current;It(Ta),o._currentValue=a}function Wd(o,a,p){for(;o!==null;){var g=o.alternate;if((o.childLanes&a)!==a?(o.childLanes|=a,g!==null&&(g.childLanes|=a)):g!==null&&(g.childLanes&a)!==a&&(g.childLanes|=a),o===p)break;o=o.return}}function ro(o,a){Ma=o,$d=no=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&a)!==0&&(Vn=!0),o.firstContext=null)}function cr(o){var a=o._currentValue;if($d!==o)if(o={context:o,memoizedValue:a,next:null},no===null){if(Ma===null)throw Error(n(308));no=o,Ma.dependencies={lanes:0,firstContext:o}}else no=no.next=o;return a}var di=null;function Vd(o){di===null?di=[o]:di.push(o)}function bg(o,a,p,g){var x=a.interleaved;return x===null?(p.next=p,Vd(a)):(p.next=x.next,x.next=p),a.interleaved=p,Qr(o,g)}function Qr(o,a){o.lanes|=a;var p=o.alternate;for(p!==null&&(p.lanes|=a),p=o,o=o.return;o!==null;)o.childLanes|=a,p=o.alternate,p!==null&&(p.childLanes|=a),p=o,o=o.return;return p.tag===3?p.stateNode:null}var Ss=!1;function Kd(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vg(o,a){o=o.updateQueue,a.updateQueue===o&&(a.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function Xr(o,a){return{eventTime:o,lane:a,tag:0,payload:null,callback:null,next:null}}function Es(o,a,p){var g=o.updateQueue;if(g===null)return null;if(g=g.shared,(dt&2)!==0){var x=g.pending;return x===null?a.next=a:(a.next=x.next,x.next=a),g.pending=a,Qr(o,p)}return x=g.interleaved,x===null?(a.next=a,Vd(g)):(a.next=x.next,x.next=a),g.interleaved=a,Qr(o,p)}function Aa(o,a,p){if(a=a.updateQueue,a!==null&&(a=a.shared,(p&4194240)!==0)){var g=a.lanes;g&=o.pendingLanes,p|=g,a.lanes=p,Do(o,p)}}function xg(o,a){var p=o.updateQueue,g=o.alternate;if(g!==null&&(g=g.updateQueue,p===g)){var x=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var _={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?x=S=_:S=S.next=_,p=p.next}while(p!==null);S===null?x=S=a:S=S.next=a}else x=S=a;p={baseState:g.baseState,firstBaseUpdate:x,lastBaseUpdate:S,shared:g.shared,effects:g.effects},o.updateQueue=p;return}o=p.lastBaseUpdate,o===null?p.firstBaseUpdate=a:o.next=a,p.lastBaseUpdate=a}function Oa(o,a,p,g){var x=o.updateQueue;Ss=!1;var S=x.firstBaseUpdate,_=x.lastBaseUpdate,j=x.shared.pending;if(j!==null){x.shared.pending=null;var P=j,q=P.next;P.next=null,_===null?S=q:_.next=q,_=P;var fe=o.alternate;fe!==null&&(fe=fe.updateQueue,j=fe.lastBaseUpdate,j!==_&&(j===null?fe.firstBaseUpdate=q:j.next=q,fe.lastBaseUpdate=P))}if(S!==null){var he=x.baseState;_=0,fe=q=P=null,j=S;do{var de=j.lane,Ee=j.eventTime;if((g&de)===de){fe!==null&&(fe=fe.next={eventTime:Ee,lane:0,tag:j.tag,payload:j.payload,callback:j.callback,next:null});e:{var Oe=o,Ie=j;switch(de=a,Ee=p,Ie.tag){case 1:if(Oe=Ie.payload,typeof Oe=="function"){he=Oe.call(Ee,he,de);break e}he=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Ie.payload,de=typeof Oe=="function"?Oe.call(Ee,he,de):Oe,de==null)break e;he=te({},he,de);break e;case 2:Ss=!0}}j.callback!==null&&j.lane!==0&&(o.flags|=64,de=x.effects,de===null?x.effects=[j]:de.push(j))}else Ee={eventTime:Ee,lane:de,tag:j.tag,payload:j.payload,callback:j.callback,next:null},fe===null?(q=fe=Ee,P=he):fe=fe.next=Ee,_|=de;if(j=j.next,j===null){if(j=x.shared.pending,j===null)break;de=j,j=de.next,de.next=null,x.lastBaseUpdate=de,x.shared.pending=null}}while(!0);if(fe===null&&(P=he),x.baseState=P,x.firstBaseUpdate=q,x.lastBaseUpdate=fe,a=x.shared.interleaved,a!==null){x=a;do _|=x.lane,x=x.next;while(x!==a)}else S===null&&(x.shared.lanes=0);hi|=_,o.lanes=_,o.memoizedState=he}}function wg(o,a,p){if(o=a.effects,a.effects=null,o!==null)for(a=0;a<o.length;a++){var g=o[a],x=g.callback;if(x!==null){if(g.callback=null,g=p,typeof x!="function")throw Error(n(191,x));x.call(g)}}}var el={},Dr=xs(el),tl=xs(el),nl=xs(el);function fi(o){if(o===el)throw Error(n(174));return o}function Gd(o,a){switch(Tt(nl,a),Tt(tl,o),Tt(Dr,el),o=a.nodeType,o){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:qt(null,"");break;default:o=o===8?a.parentNode:a,a=o.namespaceURI||null,o=o.tagName,a=qt(a,o)}It(Dr),Tt(Dr,a)}function so(){It(Dr),It(tl),It(nl)}function kg(o){fi(nl.current);var a=fi(Dr.current),p=qt(a,o.type);a!==p&&(Tt(tl,o),Tt(Dr,p))}function qd(o){tl.current===o&&(It(Dr),It(tl))}var zt=xs(0);function Ra(o){for(var a=o;a!==null;){if(a.tag===13){var p=a.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===o)break;for(;a.sibling===null;){if(a.return===null||a.return===o)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Jd=[];function Yd(){for(var o=0;o<Jd.length;o++)Jd[o]._workInProgressVersionPrimary=null;Jd.length=0}var Ia=T.ReactCurrentDispatcher,Qd=T.ReactCurrentBatchConfig,pi=0,Ft=null,sn=null,cn=null,ja=!1,rl=!1,sl=0,IS=0;function Tn(){throw Error(n(321))}function Xd(o,a){if(a===null)return!1;for(var p=0;p<a.length&&p<o.length;p++)if(!xr(o[p],a[p]))return!1;return!0}function Zd(o,a,p,g,x,S){if(pi=S,Ft=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Ia.current=o===null||o.memoizedState===null?PS:BS,o=p(g,x),rl){S=0;do{if(rl=!1,sl=0,25<=S)throw Error(n(301));S+=1,cn=sn=null,a.updateQueue=null,Ia.current=zS,o=p(g,x)}while(rl)}if(Ia.current=Pa,a=sn!==null&&sn.next!==null,pi=0,cn=sn=Ft=null,ja=!1,a)throw Error(n(300));return o}function ef(){var o=sl!==0;return sl=0,o}function Pr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return cn===null?Ft.memoizedState=cn=o:cn=cn.next=o,cn}function ur(){if(sn===null){var o=Ft.alternate;o=o!==null?o.memoizedState:null}else o=sn.next;var a=cn===null?Ft.memoizedState:cn.next;if(a!==null)cn=a,sn=o;else{if(o===null)throw Error(n(310));sn=o,o={memoizedState:sn.memoizedState,baseState:sn.baseState,baseQueue:sn.baseQueue,queue:sn.queue,next:null},cn===null?Ft.memoizedState=cn=o:cn=cn.next=o}return cn}function il(o,a){return typeof a=="function"?a(o):a}function tf(o){var a=ur(),p=a.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=o;var g=sn,x=g.baseQueue,S=p.pending;if(S!==null){if(x!==null){var _=x.next;x.next=S.next,S.next=_}g.baseQueue=x=S,p.pending=null}if(x!==null){S=x.next,g=g.baseState;var j=_=null,P=null,q=S;do{var fe=q.lane;if((pi&fe)===fe)P!==null&&(P=P.next={lane:0,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null}),g=q.hasEagerState?q.eagerState:o(g,q.action);else{var he={lane:fe,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null};P===null?(j=P=he,_=g):P=P.next=he,Ft.lanes|=fe,hi|=fe}q=q.next}while(q!==null&&q!==S);P===null?_=g:P.next=j,xr(g,a.memoizedState)||(Vn=!0),a.memoizedState=g,a.baseState=_,a.baseQueue=P,p.lastRenderedState=g}if(o=p.interleaved,o!==null){x=o;do S=x.lane,Ft.lanes|=S,hi|=S,x=x.next;while(x!==o)}else x===null&&(p.lanes=0);return[a.memoizedState,p.dispatch]}function nf(o){var a=ur(),p=a.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=o;var g=p.dispatch,x=p.pending,S=a.memoizedState;if(x!==null){p.pending=null;var _=x=x.next;do S=o(S,_.action),_=_.next;while(_!==x);xr(S,a.memoizedState)||(Vn=!0),a.memoizedState=S,a.baseQueue===null&&(a.baseState=S),p.lastRenderedState=S}return[S,g]}function Sg(){}function Eg(o,a){var p=Ft,g=ur(),x=a(),S=!xr(g.memoizedState,x);if(S&&(g.memoizedState=x,Vn=!0),g=g.queue,rf(_g.bind(null,p,g,o),[o]),g.getSnapshot!==a||S||cn!==null&&cn.memoizedState.tag&1){if(p.flags|=2048,ol(9,Cg.bind(null,p,g,x,a),void 0,null),un===null)throw Error(n(349));(pi&30)!==0||Ng(p,a,x)}return x}function Ng(o,a,p){o.flags|=16384,o={getSnapshot:a,value:p},a=Ft.updateQueue,a===null?(a={lastEffect:null,stores:null},Ft.updateQueue=a,a.stores=[o]):(p=a.stores,p===null?a.stores=[o]:p.push(o))}function Cg(o,a,p,g){a.value=p,a.getSnapshot=g,Tg(a)&&Mg(o)}function _g(o,a,p){return p(function(){Tg(a)&&Mg(o)})}function Tg(o){var a=o.getSnapshot;o=o.value;try{var p=a();return!xr(o,p)}catch{return!0}}function Mg(o){var a=Qr(o,1);a!==null&&Nr(a,o,1,-1)}function Ag(o){var a=Pr();return typeof o=="function"&&(o=o()),a.memoizedState=a.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:il,lastRenderedState:o},a.queue=o,o=o.dispatch=DS.bind(null,Ft,o),[a.memoizedState,o]}function ol(o,a,p,g){return o={tag:o,create:a,destroy:p,deps:g,next:null},a=Ft.updateQueue,a===null?(a={lastEffect:null,stores:null},Ft.updateQueue=a,a.lastEffect=o.next=o):(p=a.lastEffect,p===null?a.lastEffect=o.next=o:(g=p.next,p.next=o,o.next=g,a.lastEffect=o)),o}function Og(){return ur().memoizedState}function La(o,a,p,g){var x=Pr();Ft.flags|=o,x.memoizedState=ol(1|a,p,void 0,g===void 0?null:g)}function Da(o,a,p,g){var x=ur();g=g===void 0?null:g;var S=void 0;if(sn!==null){var _=sn.memoizedState;if(S=_.destroy,g!==null&&Xd(g,_.deps)){x.memoizedState=ol(a,p,S,g);return}}Ft.flags|=o,x.memoizedState=ol(1|a,p,S,g)}function Rg(o,a){return La(8390656,8,o,a)}function rf(o,a){return Da(2048,8,o,a)}function Ig(o,a){return Da(4,2,o,a)}function jg(o,a){return Da(4,4,o,a)}function Lg(o,a){if(typeof a=="function")return o=o(),a(o),function(){a(null)};if(a!=null)return o=o(),a.current=o,function(){a.current=null}}function Dg(o,a,p){return p=p!=null?p.concat([o]):null,Da(4,4,Lg.bind(null,a,o),p)}function sf(){}function Pg(o,a){var p=ur();a=a===void 0?null:a;var g=p.memoizedState;return g!==null&&a!==null&&Xd(a,g[1])?g[0]:(p.memoizedState=[o,a],o)}function Bg(o,a){var p=ur();a=a===void 0?null:a;var g=p.memoizedState;return g!==null&&a!==null&&Xd(a,g[1])?g[0]:(o=o(),p.memoizedState=[o,a],o)}function zg(o,a,p){return(pi&21)===0?(o.baseState&&(o.baseState=!1,Vn=!0),o.memoizedState=p):(xr(p,a)||(p=sa(),Ft.lanes|=p,hi|=p,o.baseState=!0),a)}function jS(o,a){var p=ut;ut=p!==0&&4>p?p:4,o(!0);var g=Qd.transition;Qd.transition={};try{o(!1),a()}finally{ut=p,Qd.transition=g}}function Fg(){return ur().memoizedState}function LS(o,a,p){var g=Ts(o);if(p={lane:g,action:p,hasEagerState:!1,eagerState:null,next:null},$g(o))Ug(a,p);else if(p=bg(o,a,p,g),p!==null){var x=Bn();Nr(p,o,g,x),Hg(p,a,g)}}function DS(o,a,p){var g=Ts(o),x={lane:g,action:p,hasEagerState:!1,eagerState:null,next:null};if($g(o))Ug(a,x);else{var S=o.alternate;if(o.lanes===0&&(S===null||S.lanes===0)&&(S=a.lastRenderedReducer,S!==null))try{var _=a.lastRenderedState,j=S(_,p);if(x.hasEagerState=!0,x.eagerState=j,xr(j,_)){var P=a.interleaved;P===null?(x.next=x,Vd(a)):(x.next=P.next,P.next=x),a.interleaved=x;return}}catch{}finally{}p=bg(o,a,x,g),p!==null&&(x=Bn(),Nr(p,o,g,x),Hg(p,a,g))}}function $g(o){var a=o.alternate;return o===Ft||a!==null&&a===Ft}function Ug(o,a){rl=ja=!0;var p=o.pending;p===null?a.next=a:(a.next=p.next,p.next=a),o.pending=a}function Hg(o,a,p){if((p&4194240)!==0){var g=a.lanes;g&=o.pendingLanes,p|=g,a.lanes=p,Do(o,p)}}var Pa={readContext:cr,useCallback:Tn,useContext:Tn,useEffect:Tn,useImperativeHandle:Tn,useInsertionEffect:Tn,useLayoutEffect:Tn,useMemo:Tn,useReducer:Tn,useRef:Tn,useState:Tn,useDebugValue:Tn,useDeferredValue:Tn,useTransition:Tn,useMutableSource:Tn,useSyncExternalStore:Tn,useId:Tn,unstable_isNewReconciler:!1},PS={readContext:cr,useCallback:function(o,a){return Pr().memoizedState=[o,a===void 0?null:a],o},useContext:cr,useEffect:Rg,useImperativeHandle:function(o,a,p){return p=p!=null?p.concat([o]):null,La(4194308,4,Lg.bind(null,a,o),p)},useLayoutEffect:function(o,a){return La(4194308,4,o,a)},useInsertionEffect:function(o,a){return La(4,2,o,a)},useMemo:function(o,a){var p=Pr();return a=a===void 0?null:a,o=o(),p.memoizedState=[o,a],o},useReducer:function(o,a,p){var g=Pr();return a=p!==void 0?p(a):a,g.memoizedState=g.baseState=a,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:a},g.queue=o,o=o.dispatch=LS.bind(null,Ft,o),[g.memoizedState,o]},useRef:function(o){var a=Pr();return o={current:o},a.memoizedState=o},useState:Ag,useDebugValue:sf,useDeferredValue:function(o){return Pr().memoizedState=o},useTransition:function(){var o=Ag(!1),a=o[0];return o=jS.bind(null,o[1]),Pr().memoizedState=o,[a,o]},useMutableSource:function(){},useSyncExternalStore:function(o,a,p){var g=Ft,x=Pr();if(Dt){if(p===void 0)throw Error(n(407));p=p()}else{if(p=a(),un===null)throw Error(n(349));(pi&30)!==0||Ng(g,a,p)}x.memoizedState=p;var S={value:p,getSnapshot:a};return x.queue=S,Rg(_g.bind(null,g,S,o),[o]),g.flags|=2048,ol(9,Cg.bind(null,g,S,p,a),void 0,null),p},useId:function(){var o=Pr(),a=un.identifierPrefix;if(Dt){var p=Yr,g=Jr;p=(g&~(1<<32-Bt(g)-1)).toString(32)+p,a=":"+a+"R"+p,p=sl++,0<p&&(a+="H"+p.toString(32)),a+=":"}else p=IS++,a=":"+a+"r"+p.toString(32)+":";return o.memoizedState=a},unstable_isNewReconciler:!1},BS={readContext:cr,useCallback:Pg,useContext:cr,useEffect:rf,useImperativeHandle:Dg,useInsertionEffect:Ig,useLayoutEffect:jg,useMemo:Bg,useReducer:tf,useRef:Og,useState:function(){return tf(il)},useDebugValue:sf,useDeferredValue:function(o){var a=ur();return zg(a,sn.memoizedState,o)},useTransition:function(){var o=tf(il)[0],a=ur().memoizedState;return[o,a]},useMutableSource:Sg,useSyncExternalStore:Eg,useId:Fg,unstable_isNewReconciler:!1},zS={readContext:cr,useCallback:Pg,useContext:cr,useEffect:rf,useImperativeHandle:Dg,useInsertionEffect:Ig,useLayoutEffect:jg,useMemo:Bg,useReducer:nf,useRef:Og,useState:function(){return nf(il)},useDebugValue:sf,useDeferredValue:function(o){var a=ur();return sn===null?a.memoizedState=o:zg(a,sn.memoizedState,o)},useTransition:function(){var o=nf(il)[0],a=ur().memoizedState;return[o,a]},useMutableSource:Sg,useSyncExternalStore:Eg,useId:Fg,unstable_isNewReconciler:!1};function kr(o,a){if(o&&o.defaultProps){a=te({},a),o=o.defaultProps;for(var p in o)a[p]===void 0&&(a[p]=o[p]);return a}return a}function of(o,a,p,g){a=o.memoizedState,p=p(g,a),p=p==null?a:te({},a,p),o.memoizedState=p,o.lanes===0&&(o.updateQueue.baseState=p)}var Ba={isMounted:function(o){return(o=o._reactInternals)?Kr(o)===o:!1},enqueueSetState:function(o,a,p){o=o._reactInternals;var g=Bn(),x=Ts(o),S=Xr(g,x);S.payload=a,p!=null&&(S.callback=p),a=Es(o,S,x),a!==null&&(Nr(a,o,x,g),Aa(a,o,x))},enqueueReplaceState:function(o,a,p){o=o._reactInternals;var g=Bn(),x=Ts(o),S=Xr(g,x);S.tag=1,S.payload=a,p!=null&&(S.callback=p),a=Es(o,S,x),a!==null&&(Nr(a,o,x,g),Aa(a,o,x))},enqueueForceUpdate:function(o,a){o=o._reactInternals;var p=Bn(),g=Ts(o),x=Xr(p,g);x.tag=2,a!=null&&(x.callback=a),a=Es(o,x,g),a!==null&&(Nr(a,o,g,p),Aa(a,o,g))}};function Wg(o,a,p,g,x,S,_){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(g,S,_):a.prototype&&a.prototype.isPureReactComponent?!Ko(p,g)||!Ko(x,S):!0}function Vg(o,a,p){var g=!1,x=ws,S=a.contextType;return typeof S=="object"&&S!==null?S=cr(S):(x=Wn(a)?ai:_n.current,g=a.contextTypes,S=(g=g!=null)?Qi(o,x):ws),a=new a(p,S),o.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ba,o.stateNode=a,a._reactInternals=o,g&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=x,o.__reactInternalMemoizedMaskedChildContext=S),a}function Kg(o,a,p,g){o=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(p,g),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(p,g),a.state!==o&&Ba.enqueueReplaceState(a,a.state,null)}function lf(o,a,p,g){var x=o.stateNode;x.props=p,x.state=o.memoizedState,x.refs={},Kd(o);var S=a.contextType;typeof S=="object"&&S!==null?x.context=cr(S):(S=Wn(a)?ai:_n.current,x.context=Qi(o,S)),x.state=o.memoizedState,S=a.getDerivedStateFromProps,typeof S=="function"&&(of(o,a,S,p),x.state=o.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(a=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),a!==x.state&&Ba.enqueueReplaceState(x,x.state,null),Oa(o,p,x,g),x.state=o.memoizedState),typeof x.componentDidMount=="function"&&(o.flags|=4194308)}function io(o,a){try{var p="",g=a;do p+=pe(g),g=g.return;while(g);var x=p}catch(S){x=`
|
|
39
|
+
Error generating stack: `+S.message+`
|
|
40
|
+
`+S.stack}return{value:o,source:a,stack:x,digest:null}}function af(o,a,p){return{value:o,source:null,stack:p??null,digest:a??null}}function cf(o,a){try{console.error(a.value)}catch(p){setTimeout(function(){throw p})}}var FS=typeof WeakMap=="function"?WeakMap:Map;function Gg(o,a,p){p=Xr(-1,p),p.tag=3,p.payload={element:null};var g=a.value;return p.callback=function(){Va||(Va=!0,Ef=g),cf(o,a)},p}function qg(o,a,p){p=Xr(-1,p),p.tag=3;var g=o.type.getDerivedStateFromError;if(typeof g=="function"){var x=a.value;p.payload=function(){return g(x)},p.callback=function(){cf(o,a)}}var S=o.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(p.callback=function(){cf(o,a),typeof g!="function"&&(Cs===null?Cs=new Set([this]):Cs.add(this));var _=a.stack;this.componentDidCatch(a.value,{componentStack:_!==null?_:""})}),p}function Jg(o,a,p){var g=o.pingCache;if(g===null){g=o.pingCache=new FS;var x=new Set;g.set(a,x)}else x=g.get(a),x===void 0&&(x=new Set,g.set(a,x));x.has(p)||(x.add(p),o=eE.bind(null,o,a,p),a.then(o,o))}function Yg(o){do{var a;if((a=o.tag===13)&&(a=o.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return o;o=o.return}while(o!==null);return null}function Qg(o,a,p,g,x){return(o.mode&1)===0?(o===a?o.flags|=65536:(o.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(a=Xr(-1,1),a.tag=2,Es(p,a,1))),p.lanes|=1),o):(o.flags|=65536,o.lanes=x,o)}var $S=T.ReactCurrentOwner,Vn=!1;function Pn(o,a,p,g){a.child=o===null?yg(a,null,p,g):to(a,o.child,p,g)}function Xg(o,a,p,g,x){p=p.render;var S=a.ref;return ro(a,x),g=Zd(o,a,p,g,S,x),p=ef(),o!==null&&!Vn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~x,Zr(o,a,x)):(Dt&&p&&Dd(a),a.flags|=1,Pn(o,a,g,x),a.child)}function Zg(o,a,p,g,x){if(o===null){var S=p.type;return typeof S=="function"&&!Of(S)&&S.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(a.tag=15,a.type=S,ey(o,a,S,g,x)):(o=Qa(p.type,null,g,a,a.mode,x),o.ref=a.ref,o.return=a,a.child=o)}if(S=o.child,(o.lanes&x)===0){var _=S.memoizedProps;if(p=p.compare,p=p!==null?p:Ko,p(_,g)&&o.ref===a.ref)return Zr(o,a,x)}return a.flags|=1,o=As(S,g),o.ref=a.ref,o.return=a,a.child=o}function ey(o,a,p,g,x){if(o!==null){var S=o.memoizedProps;if(Ko(S,g)&&o.ref===a.ref)if(Vn=!1,a.pendingProps=g=S,(o.lanes&x)!==0)(o.flags&131072)!==0&&(Vn=!0);else return a.lanes=o.lanes,Zr(o,a,x)}return uf(o,a,p,g,x)}function ty(o,a,p){var g=a.pendingProps,x=g.children,S=o!==null?o.memoizedState:null;if(g.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Tt(lo,nr),nr|=p;else{if((p&1073741824)===0)return o=S!==null?S.baseLanes|p:p,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:o,cachePool:null,transitions:null},a.updateQueue=null,Tt(lo,nr),nr|=o,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=S!==null?S.baseLanes:p,Tt(lo,nr),nr|=g}else S!==null?(g=S.baseLanes|p,a.memoizedState=null):g=p,Tt(lo,nr),nr|=g;return Pn(o,a,x,p),a.child}function ny(o,a){var p=a.ref;(o===null&&p!==null||o!==null&&o.ref!==p)&&(a.flags|=512,a.flags|=2097152)}function uf(o,a,p,g,x){var S=Wn(p)?ai:_n.current;return S=Qi(a,S),ro(a,x),p=Zd(o,a,p,g,S,x),g=ef(),o!==null&&!Vn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~x,Zr(o,a,x)):(Dt&&g&&Dd(a),a.flags|=1,Pn(o,a,p,x),a.child)}function ry(o,a,p,g,x){if(Wn(p)){var S=!0;ka(a)}else S=!1;if(ro(a,x),a.stateNode===null)Fa(o,a),Vg(a,p,g),lf(a,p,g,x),g=!0;else if(o===null){var _=a.stateNode,j=a.memoizedProps;_.props=j;var P=_.context,q=p.contextType;typeof q=="object"&&q!==null?q=cr(q):(q=Wn(p)?ai:_n.current,q=Qi(a,q));var fe=p.getDerivedStateFromProps,he=typeof fe=="function"||typeof _.getSnapshotBeforeUpdate=="function";he||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(j!==g||P!==q)&&Kg(a,_,g,q),Ss=!1;var de=a.memoizedState;_.state=de,Oa(a,g,_,x),P=a.memoizedState,j!==g||de!==P||Hn.current||Ss?(typeof fe=="function"&&(of(a,p,fe,g),P=a.memoizedState),(j=Ss||Wg(a,p,j,g,de,P,q))?(he||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount()),typeof _.componentDidMount=="function"&&(a.flags|=4194308)):(typeof _.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=g,a.memoizedState=P),_.props=g,_.state=P,_.context=q,g=j):(typeof _.componentDidMount=="function"&&(a.flags|=4194308),g=!1)}else{_=a.stateNode,vg(o,a),j=a.memoizedProps,q=a.type===a.elementType?j:kr(a.type,j),_.props=q,he=a.pendingProps,de=_.context,P=p.contextType,typeof P=="object"&&P!==null?P=cr(P):(P=Wn(p)?ai:_n.current,P=Qi(a,P));var Ee=p.getDerivedStateFromProps;(fe=typeof Ee=="function"||typeof _.getSnapshotBeforeUpdate=="function")||typeof _.UNSAFE_componentWillReceiveProps!="function"&&typeof _.componentWillReceiveProps!="function"||(j!==he||de!==P)&&Kg(a,_,g,P),Ss=!1,de=a.memoizedState,_.state=de,Oa(a,g,_,x);var Oe=a.memoizedState;j!==he||de!==Oe||Hn.current||Ss?(typeof Ee=="function"&&(of(a,p,Ee,g),Oe=a.memoizedState),(q=Ss||Wg(a,p,q,g,de,Oe,P)||!1)?(fe||typeof _.UNSAFE_componentWillUpdate!="function"&&typeof _.componentWillUpdate!="function"||(typeof _.componentWillUpdate=="function"&&_.componentWillUpdate(g,Oe,P),typeof _.UNSAFE_componentWillUpdate=="function"&&_.UNSAFE_componentWillUpdate(g,Oe,P)),typeof _.componentDidUpdate=="function"&&(a.flags|=4),typeof _.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof _.componentDidUpdate!="function"||j===o.memoizedProps&&de===o.memoizedState||(a.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||j===o.memoizedProps&&de===o.memoizedState||(a.flags|=1024),a.memoizedProps=g,a.memoizedState=Oe),_.props=g,_.state=Oe,_.context=P,g=q):(typeof _.componentDidUpdate!="function"||j===o.memoizedProps&&de===o.memoizedState||(a.flags|=4),typeof _.getSnapshotBeforeUpdate!="function"||j===o.memoizedProps&&de===o.memoizedState||(a.flags|=1024),g=!1)}return df(o,a,p,g,S,x)}function df(o,a,p,g,x,S){ny(o,a);var _=(a.flags&128)!==0;if(!g&&!_)return x&&ag(a,p,!1),Zr(o,a,S);g=a.stateNode,$S.current=a;var j=_&&typeof p.getDerivedStateFromError!="function"?null:g.render();return a.flags|=1,o!==null&&_?(a.child=to(a,o.child,null,S),a.child=to(a,null,j,S)):Pn(o,a,j,S),a.memoizedState=g.state,x&&ag(a,p,!0),a.child}function sy(o){var a=o.stateNode;a.pendingContext?og(o,a.pendingContext,a.pendingContext!==a.context):a.context&&og(o,a.context,!1),Gd(o,a.containerInfo)}function iy(o,a,p,g,x){return eo(),Fd(x),a.flags|=256,Pn(o,a,p,g),a.child}var ff={dehydrated:null,treeContext:null,retryLane:0};function pf(o){return{baseLanes:o,cachePool:null,transitions:null}}function oy(o,a,p){var g=a.pendingProps,x=zt.current,S=!1,_=(a.flags&128)!==0,j;if((j=_)||(j=o!==null&&o.memoizedState===null?!1:(x&2)!==0),j?(S=!0,a.flags&=-129):(o===null||o.memoizedState!==null)&&(x|=1),Tt(zt,x&1),o===null)return zd(a),o=a.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((a.mode&1)===0?a.lanes=1:o.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(_=g.children,o=g.fallback,S?(g=a.mode,S=a.child,_={mode:"hidden",children:_},(g&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=_):S=Xa(_,g,0,null),o=bi(o,g,p,null),S.return=a,o.return=a,S.sibling=o,a.child=S,a.child.memoizedState=pf(p),a.memoizedState=ff,o):hf(a,_));if(x=o.memoizedState,x!==null&&(j=x.dehydrated,j!==null))return US(o,a,_,g,j,x,p);if(S){S=g.fallback,_=a.mode,x=o.child,j=x.sibling;var P={mode:"hidden",children:g.children};return(_&1)===0&&a.child!==x?(g=a.child,g.childLanes=0,g.pendingProps=P,a.deletions=null):(g=As(x,P),g.subtreeFlags=x.subtreeFlags&14680064),j!==null?S=As(j,S):(S=bi(S,_,p,null),S.flags|=2),S.return=a,g.return=a,g.sibling=S,a.child=g,g=S,S=a.child,_=o.child.memoizedState,_=_===null?pf(p):{baseLanes:_.baseLanes|p,cachePool:null,transitions:_.transitions},S.memoizedState=_,S.childLanes=o.childLanes&~p,a.memoizedState=ff,g}return S=o.child,o=S.sibling,g=As(S,{mode:"visible",children:g.children}),(a.mode&1)===0&&(g.lanes=p),g.return=a,g.sibling=null,o!==null&&(p=a.deletions,p===null?(a.deletions=[o],a.flags|=16):p.push(o)),a.child=g,a.memoizedState=null,g}function hf(o,a){return a=Xa({mode:"visible",children:a},o.mode,0,null),a.return=o,o.child=a}function za(o,a,p,g){return g!==null&&Fd(g),to(a,o.child,null,p),o=hf(a,a.pendingProps.children),o.flags|=2,a.memoizedState=null,o}function US(o,a,p,g,x,S,_){if(p)return a.flags&256?(a.flags&=-257,g=af(Error(n(422))),za(o,a,_,g)):a.memoizedState!==null?(a.child=o.child,a.flags|=128,null):(S=g.fallback,x=a.mode,g=Xa({mode:"visible",children:g.children},x,0,null),S=bi(S,x,_,null),S.flags|=2,g.return=a,S.return=a,g.sibling=S,a.child=g,(a.mode&1)!==0&&to(a,o.child,null,_),a.child.memoizedState=pf(_),a.memoizedState=ff,S);if((a.mode&1)===0)return za(o,a,_,null);if(x.data==="$!"){if(g=x.nextSibling&&x.nextSibling.dataset,g)var j=g.dgst;return g=j,S=Error(n(419)),g=af(S,g,void 0),za(o,a,_,g)}if(j=(_&o.childLanes)!==0,Vn||j){if(g=un,g!==null){switch(_&-_){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&(g.suspendedLanes|_))!==0?0:x,x!==0&&x!==S.retryLane&&(S.retryLane=x,Qr(o,x),Nr(g,o,x,-1))}return Af(),g=af(Error(n(421))),za(o,a,_,g)}return x.data==="$?"?(a.flags|=128,a.child=o.child,a=tE.bind(null,o),x._reactRetry=a,null):(o=S.treeContext,tr=vs(x.nextSibling),er=a,Dt=!0,wr=null,o!==null&&(lr[ar++]=Jr,lr[ar++]=Yr,lr[ar++]=ci,Jr=o.id,Yr=o.overflow,ci=a),a=hf(a,g.children),a.flags|=4096,a)}function ly(o,a,p){o.lanes|=a;var g=o.alternate;g!==null&&(g.lanes|=a),Wd(o.return,a,p)}function mf(o,a,p,g,x){var S=o.memoizedState;S===null?o.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:g,tail:p,tailMode:x}:(S.isBackwards=a,S.rendering=null,S.renderingStartTime=0,S.last=g,S.tail=p,S.tailMode=x)}function ay(o,a,p){var g=a.pendingProps,x=g.revealOrder,S=g.tail;if(Pn(o,a,g.children,p),g=zt.current,(g&2)!==0)g=g&1|2,a.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=a.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&ly(o,p,a);else if(o.tag===19)ly(o,p,a);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===a)break e;for(;o.sibling===null;){if(o.return===null||o.return===a)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}g&=1}if(Tt(zt,g),(a.mode&1)===0)a.memoizedState=null;else switch(x){case"forwards":for(p=a.child,x=null;p!==null;)o=p.alternate,o!==null&&Ra(o)===null&&(x=p),p=p.sibling;p=x,p===null?(x=a.child,a.child=null):(x=p.sibling,p.sibling=null),mf(a,!1,x,p,S);break;case"backwards":for(p=null,x=a.child,a.child=null;x!==null;){if(o=x.alternate,o!==null&&Ra(o)===null){a.child=x;break}o=x.sibling,x.sibling=p,p=x,x=o}mf(a,!0,p,null,S);break;case"together":mf(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Fa(o,a){(a.mode&1)===0&&o!==null&&(o.alternate=null,a.alternate=null,a.flags|=2)}function Zr(o,a,p){if(o!==null&&(a.dependencies=o.dependencies),hi|=a.lanes,(p&a.childLanes)===0)return null;if(o!==null&&a.child!==o.child)throw Error(n(153));if(a.child!==null){for(o=a.child,p=As(o,o.pendingProps),a.child=p,p.return=a;o.sibling!==null;)o=o.sibling,p=p.sibling=As(o,o.pendingProps),p.return=a;p.sibling=null}return a.child}function HS(o,a,p){switch(a.tag){case 3:sy(a),eo();break;case 5:kg(a);break;case 1:Wn(a.type)&&ka(a);break;case 4:Gd(a,a.stateNode.containerInfo);break;case 10:var g=a.type._context,x=a.memoizedProps.value;Tt(Ta,g._currentValue),g._currentValue=x;break;case 13:if(g=a.memoizedState,g!==null)return g.dehydrated!==null?(Tt(zt,zt.current&1),a.flags|=128,null):(p&a.child.childLanes)!==0?oy(o,a,p):(Tt(zt,zt.current&1),o=Zr(o,a,p),o!==null?o.sibling:null);Tt(zt,zt.current&1);break;case 19:if(g=(p&a.childLanes)!==0,(o.flags&128)!==0){if(g)return ay(o,a,p);a.flags|=128}if(x=a.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),Tt(zt,zt.current),g)break;return null;case 22:case 23:return a.lanes=0,ty(o,a,p)}return Zr(o,a,p)}var cy,gf,uy,dy;cy=function(o,a){for(var p=a.child;p!==null;){if(p.tag===5||p.tag===6)o.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===a)break;for(;p.sibling===null;){if(p.return===null||p.return===a)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},gf=function(){},uy=function(o,a,p,g){var x=o.memoizedProps;if(x!==g){o=a.stateNode,fi(Dr.current);var S=null;switch(p){case"input":x=ae(o,x),g=ae(o,g),S=[];break;case"select":x=te({},x,{value:void 0}),g=te({},g,{value:void 0}),S=[];break;case"textarea":x=Qn(o,x),g=Qn(o,g),S=[];break;default:typeof x.onClick!="function"&&typeof g.onClick=="function"&&(o.onclick=va)}qe(p,g);var _;p=null;for(q in x)if(!g.hasOwnProperty(q)&&x.hasOwnProperty(q)&&x[q]!=null)if(q==="style"){var j=x[q];for(_ in j)j.hasOwnProperty(_)&&(p||(p={}),p[_]="")}else q!=="dangerouslySetInnerHTML"&&q!=="children"&&q!=="suppressContentEditableWarning"&&q!=="suppressHydrationWarning"&&q!=="autoFocus"&&(s.hasOwnProperty(q)?S||(S=[]):(S=S||[]).push(q,null));for(q in g){var P=g[q];if(j=x!=null?x[q]:void 0,g.hasOwnProperty(q)&&P!==j&&(P!=null||j!=null))if(q==="style")if(j){for(_ in j)!j.hasOwnProperty(_)||P&&P.hasOwnProperty(_)||(p||(p={}),p[_]="");for(_ in P)P.hasOwnProperty(_)&&j[_]!==P[_]&&(p||(p={}),p[_]=P[_])}else p||(S||(S=[]),S.push(q,p)),p=P;else q==="dangerouslySetInnerHTML"?(P=P?P.__html:void 0,j=j?j.__html:void 0,P!=null&&j!==P&&(S=S||[]).push(q,P)):q==="children"?typeof P!="string"&&typeof P!="number"||(S=S||[]).push(q,""+P):q!=="suppressContentEditableWarning"&&q!=="suppressHydrationWarning"&&(s.hasOwnProperty(q)?(P!=null&&q==="onScroll"&&Rt("scroll",o),S||j===P||(S=[])):(S=S||[]).push(q,P))}p&&(S=S||[]).push("style",p);var q=S;(a.updateQueue=q)&&(a.flags|=4)}},dy=function(o,a,p,g){p!==g&&(a.flags|=4)};function ll(o,a){if(!Dt)switch(o.tailMode){case"hidden":a=o.tail;for(var p=null;a!==null;)a.alternate!==null&&(p=a),a=a.sibling;p===null?o.tail=null:p.sibling=null;break;case"collapsed":p=o.tail;for(var g=null;p!==null;)p.alternate!==null&&(g=p),p=p.sibling;g===null?a||o.tail===null?o.tail=null:o.tail.sibling=null:g.sibling=null}}function Mn(o){var a=o.alternate!==null&&o.alternate.child===o.child,p=0,g=0;if(a)for(var x=o.child;x!==null;)p|=x.lanes|x.childLanes,g|=x.subtreeFlags&14680064,g|=x.flags&14680064,x.return=o,x=x.sibling;else for(x=o.child;x!==null;)p|=x.lanes|x.childLanes,g|=x.subtreeFlags,g|=x.flags,x.return=o,x=x.sibling;return o.subtreeFlags|=g,o.childLanes=p,a}function WS(o,a,p){var g=a.pendingProps;switch(Pd(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mn(a),null;case 1:return Wn(a.type)&&wa(),Mn(a),null;case 3:return g=a.stateNode,so(),It(Hn),It(_n),Yd(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(o===null||o.child===null)&&(Ca(a)?a.flags|=4:o===null||o.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,wr!==null&&(_f(wr),wr=null))),gf(o,a),Mn(a),null;case 5:qd(a);var x=fi(nl.current);if(p=a.type,o!==null&&a.stateNode!=null)uy(o,a,p,g,x),o.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!g){if(a.stateNode===null)throw Error(n(166));return Mn(a),null}if(o=fi(Dr.current),Ca(a)){g=a.stateNode,p=a.type;var S=a.memoizedProps;switch(g[Lr]=a,g[Qo]=S,o=(a.mode&1)!==0,p){case"dialog":Rt("cancel",g),Rt("close",g);break;case"iframe":case"object":case"embed":Rt("load",g);break;case"video":case"audio":for(x=0;x<qo.length;x++)Rt(qo[x],g);break;case"source":Rt("error",g);break;case"img":case"image":case"link":Rt("error",g),Rt("load",g);break;case"details":Rt("toggle",g);break;case"input":ue(g,S),Rt("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!S.multiple},Rt("invalid",g);break;case"textarea":yn(g,S),Rt("invalid",g)}qe(p,S),x=null;for(var _ in S)if(S.hasOwnProperty(_)){var j=S[_];_==="children"?typeof j=="string"?g.textContent!==j&&(S.suppressHydrationWarning!==!0&&ba(g.textContent,j,o),x=["children",j]):typeof j=="number"&&g.textContent!==""+j&&(S.suppressHydrationWarning!==!0&&ba(g.textContent,j,o),x=["children",""+j]):s.hasOwnProperty(_)&&j!=null&&_==="onScroll"&&Rt("scroll",g)}switch(p){case"input":xe(g),Ue(g,S,!0);break;case"textarea":xe(g),Ot(g);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(g.onclick=va)}g=x,a.updateQueue=g,g!==null&&(a.flags|=4)}else{_=x.nodeType===9?x:x.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=bn(p)),o==="http://www.w3.org/1999/xhtml"?p==="script"?(o=_.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof g.is=="string"?o=_.createElement(p,{is:g.is}):(o=_.createElement(p),p==="select"&&(_=o,g.multiple?_.multiple=!0:g.size&&(_.size=g.size))):o=_.createElementNS(o,p),o[Lr]=a,o[Qo]=g,cy(o,a,!1,!1),a.stateNode=o;e:{switch(_=Un(p,g),p){case"dialog":Rt("cancel",o),Rt("close",o),x=g;break;case"iframe":case"object":case"embed":Rt("load",o),x=g;break;case"video":case"audio":for(x=0;x<qo.length;x++)Rt(qo[x],o);x=g;break;case"source":Rt("error",o),x=g;break;case"img":case"image":case"link":Rt("error",o),Rt("load",o),x=g;break;case"details":Rt("toggle",o),x=g;break;case"input":ue(o,g),x=ae(o,g),Rt("invalid",o);break;case"option":x=g;break;case"select":o._wrapperState={wasMultiple:!!g.multiple},x=te({},g,{value:void 0}),Rt("invalid",o);break;case"textarea":yn(o,g),x=Qn(o,g),Rt("invalid",o);break;default:x=g}qe(p,x),j=x;for(S in j)if(j.hasOwnProperty(S)){var P=j[S];S==="style"?Ze(o,P):S==="dangerouslySetInnerHTML"?(P=P?P.__html:void 0,P!=null&&Xn(o,P)):S==="children"?typeof P=="string"?(p!=="textarea"||P!=="")&&Z(o,P):typeof P=="number"&&Z(o,""+P):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(s.hasOwnProperty(S)?P!=null&&S==="onScroll"&&Rt("scroll",o):P!=null&&O(o,S,P,_))}switch(p){case"input":xe(o),Ue(o,g,!1);break;case"textarea":xe(o),Ot(o);break;case"option":g.value!=null&&o.setAttribute("value",""+Be(g.value));break;case"select":o.multiple=!!g.multiple,S=g.value,S!=null?Lt(o,!!g.multiple,S,!1):g.defaultValue!=null&&Lt(o,!!g.multiple,g.defaultValue,!0);break;default:typeof x.onClick=="function"&&(o.onclick=va)}switch(p){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}}g&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return Mn(a),null;case 6:if(o&&a.stateNode!=null)dy(o,a,o.memoizedProps,g);else{if(typeof g!="string"&&a.stateNode===null)throw Error(n(166));if(p=fi(nl.current),fi(Dr.current),Ca(a)){if(g=a.stateNode,p=a.memoizedProps,g[Lr]=a,(S=g.nodeValue!==p)&&(o=er,o!==null))switch(o.tag){case 3:ba(g.nodeValue,p,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&ba(g.nodeValue,p,(o.mode&1)!==0)}S&&(a.flags|=4)}else g=(p.nodeType===9?p:p.ownerDocument).createTextNode(g),g[Lr]=a,a.stateNode=g}return Mn(a),null;case 13:if(It(zt),g=a.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(Dt&&tr!==null&&(a.mode&1)!==0&&(a.flags&128)===0)hg(),eo(),a.flags|=98560,S=!1;else if(S=Ca(a),g!==null&&g.dehydrated!==null){if(o===null){if(!S)throw Error(n(318));if(S=a.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[Lr]=a}else eo(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;Mn(a),S=!1}else wr!==null&&(_f(wr),wr=null),S=!0;if(!S)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=p,a):(g=g!==null,g!==(o!==null&&o.memoizedState!==null)&&g&&(a.child.flags|=8192,(a.mode&1)!==0&&(o===null||(zt.current&1)!==0?on===0&&(on=3):Af())),a.updateQueue!==null&&(a.flags|=4),Mn(a),null);case 4:return so(),gf(o,a),o===null&&Jo(a.stateNode.containerInfo),Mn(a),null;case 10:return Hd(a.type._context),Mn(a),null;case 17:return Wn(a.type)&&wa(),Mn(a),null;case 19:if(It(zt),S=a.memoizedState,S===null)return Mn(a),null;if(g=(a.flags&128)!==0,_=S.rendering,_===null)if(g)ll(S,!1);else{if(on!==0||o!==null&&(o.flags&128)!==0)for(o=a.child;o!==null;){if(_=Ra(o),_!==null){for(a.flags|=128,ll(S,!1),g=_.updateQueue,g!==null&&(a.updateQueue=g,a.flags|=4),a.subtreeFlags=0,g=p,p=a.child;p!==null;)S=p,o=g,S.flags&=14680066,_=S.alternate,_===null?(S.childLanes=0,S.lanes=o,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=_.childLanes,S.lanes=_.lanes,S.child=_.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=_.memoizedProps,S.memoizedState=_.memoizedState,S.updateQueue=_.updateQueue,S.type=_.type,o=_.dependencies,S.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),p=p.sibling;return Tt(zt,zt.current&1|2),a.child}o=o.sibling}S.tail!==null&&Pt()>ao&&(a.flags|=128,g=!0,ll(S,!1),a.lanes=4194304)}else{if(!g)if(o=Ra(_),o!==null){if(a.flags|=128,g=!0,p=o.updateQueue,p!==null&&(a.updateQueue=p,a.flags|=4),ll(S,!0),S.tail===null&&S.tailMode==="hidden"&&!_.alternate&&!Dt)return Mn(a),null}else 2*Pt()-S.renderingStartTime>ao&&p!==1073741824&&(a.flags|=128,g=!0,ll(S,!1),a.lanes=4194304);S.isBackwards?(_.sibling=a.child,a.child=_):(p=S.last,p!==null?p.sibling=_:a.child=_,S.last=_)}return S.tail!==null?(a=S.tail,S.rendering=a,S.tail=a.sibling,S.renderingStartTime=Pt(),a.sibling=null,p=zt.current,Tt(zt,g?p&1|2:p&1),a):(Mn(a),null);case 22:case 23:return Mf(),g=a.memoizedState!==null,o!==null&&o.memoizedState!==null!==g&&(a.flags|=8192),g&&(a.mode&1)!==0?(nr&1073741824)!==0&&(Mn(a),a.subtreeFlags&6&&(a.flags|=8192)):Mn(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function VS(o,a){switch(Pd(a),a.tag){case 1:return Wn(a.type)&&wa(),o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 3:return so(),It(Hn),It(_n),Yd(),o=a.flags,(o&65536)!==0&&(o&128)===0?(a.flags=o&-65537|128,a):null;case 5:return qd(a),null;case 13:if(It(zt),o=a.memoizedState,o!==null&&o.dehydrated!==null){if(a.alternate===null)throw Error(n(340));eo()}return o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 19:return It(zt),null;case 4:return so(),null;case 10:return Hd(a.type._context),null;case 22:case 23:return Mf(),null;case 24:return null;default:return null}}var $a=!1,An=!1,KS=typeof WeakSet=="function"?WeakSet:Set,Me=null;function oo(o,a){var p=o.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(g){Ht(o,a,g)}else p.current=null}function yf(o,a,p){try{p()}catch(g){Ht(o,a,g)}}var fy=!1;function GS(o,a){if(Td=la,o=Wm(),xd(o)){if("selectionStart"in o)var p={start:o.selectionStart,end:o.selectionEnd};else e:{p=(p=o.ownerDocument)&&p.defaultView||window;var g=p.getSelection&&p.getSelection();if(g&&g.rangeCount!==0){p=g.anchorNode;var x=g.anchorOffset,S=g.focusNode;g=g.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var _=0,j=-1,P=-1,q=0,fe=0,he=o,de=null;t:for(;;){for(var Ee;he!==p||x!==0&&he.nodeType!==3||(j=_+x),he!==S||g!==0&&he.nodeType!==3||(P=_+g),he.nodeType===3&&(_+=he.nodeValue.length),(Ee=he.firstChild)!==null;)de=he,he=Ee;for(;;){if(he===o)break t;if(de===p&&++q===x&&(j=_),de===S&&++fe===g&&(P=_),(Ee=he.nextSibling)!==null)break;he=de,de=he.parentNode}he=Ee}p=j===-1||P===-1?null:{start:j,end:P}}else p=null}p=p||{start:0,end:0}}else p=null;for(Md={focusedElem:o,selectionRange:p},la=!1,Me=a;Me!==null;)if(a=Me,o=a.child,(a.subtreeFlags&1028)!==0&&o!==null)o.return=a,Me=o;else for(;Me!==null;){a=Me;try{var Oe=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Oe!==null){var Ie=Oe.memoizedProps,Xt=Oe.memoizedState,W=a.stateNode,F=W.getSnapshotBeforeUpdate(a.elementType===a.type?Ie:kr(a.type,Ie),Xt);W.__reactInternalSnapshotBeforeUpdate=F}break;case 3:var K=a.stateNode.containerInfo;K.nodeType===1?K.textContent="":K.nodeType===9&&K.documentElement&&K.removeChild(K.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(be){Ht(a,a.return,be)}if(o=a.sibling,o!==null){o.return=a.return,Me=o;break}Me=a.return}return Oe=fy,fy=!1,Oe}function al(o,a,p){var g=a.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var x=g=g.next;do{if((x.tag&o)===o){var S=x.destroy;x.destroy=void 0,S!==void 0&&yf(a,p,S)}x=x.next}while(x!==g)}}function Ua(o,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var p=a=a.next;do{if((p.tag&o)===o){var g=p.create;p.destroy=g()}p=p.next}while(p!==a)}}function bf(o){var a=o.ref;if(a!==null){var p=o.stateNode;switch(o.tag){case 5:o=p;break;default:o=p}typeof a=="function"?a(o):a.current=o}}function py(o){var a=o.alternate;a!==null&&(o.alternate=null,py(a)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(a=o.stateNode,a!==null&&(delete a[Lr],delete a[Qo],delete a[Id],delete a[MS],delete a[AS])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function hy(o){return o.tag===5||o.tag===3||o.tag===4}function my(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||hy(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function vf(o,a,p){var g=o.tag;if(g===5||g===6)o=o.stateNode,a?p.nodeType===8?p.parentNode.insertBefore(o,a):p.insertBefore(o,a):(p.nodeType===8?(a=p.parentNode,a.insertBefore(o,p)):(a=p,a.appendChild(o)),p=p._reactRootContainer,p!=null||a.onclick!==null||(a.onclick=va));else if(g!==4&&(o=o.child,o!==null))for(vf(o,a,p),o=o.sibling;o!==null;)vf(o,a,p),o=o.sibling}function xf(o,a,p){var g=o.tag;if(g===5||g===6)o=o.stateNode,a?p.insertBefore(o,a):p.appendChild(o);else if(g!==4&&(o=o.child,o!==null))for(xf(o,a,p),o=o.sibling;o!==null;)xf(o,a,p),o=o.sibling}var vn=null,Sr=!1;function Ns(o,a,p){for(p=p.child;p!==null;)gy(o,a,p),p=p.sibling}function gy(o,a,p){if(ot&&typeof ot.onCommitFiberUnmount=="function")try{ot.onCommitFiberUnmount(rt,p)}catch{}switch(p.tag){case 5:An||oo(p,a);case 6:var g=vn,x=Sr;vn=null,Ns(o,a,p),vn=g,Sr=x,vn!==null&&(Sr?(o=vn,p=p.stateNode,o.nodeType===8?o.parentNode.removeChild(p):o.removeChild(p)):vn.removeChild(p.stateNode));break;case 18:vn!==null&&(Sr?(o=vn,p=p.stateNode,o.nodeType===8?Rd(o.parentNode,p):o.nodeType===1&&Rd(o,p),Fo(o)):Rd(vn,p.stateNode));break;case 4:g=vn,x=Sr,vn=p.stateNode.containerInfo,Sr=!0,Ns(o,a,p),vn=g,Sr=x;break;case 0:case 11:case 14:case 15:if(!An&&(g=p.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){x=g=g.next;do{var S=x,_=S.destroy;S=S.tag,_!==void 0&&((S&2)!==0||(S&4)!==0)&&yf(p,a,_),x=x.next}while(x!==g)}Ns(o,a,p);break;case 1:if(!An&&(oo(p,a),g=p.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=p.memoizedProps,g.state=p.memoizedState,g.componentWillUnmount()}catch(j){Ht(p,a,j)}Ns(o,a,p);break;case 21:Ns(o,a,p);break;case 22:p.mode&1?(An=(g=An)||p.memoizedState!==null,Ns(o,a,p),An=g):Ns(o,a,p);break;default:Ns(o,a,p)}}function yy(o){var a=o.updateQueue;if(a!==null){o.updateQueue=null;var p=o.stateNode;p===null&&(p=o.stateNode=new KS),a.forEach(function(g){var x=nE.bind(null,o,g);p.has(g)||(p.add(g),g.then(x,x))})}}function Er(o,a){var p=a.deletions;if(p!==null)for(var g=0;g<p.length;g++){var x=p[g];try{var S=o,_=a,j=_;e:for(;j!==null;){switch(j.tag){case 5:vn=j.stateNode,Sr=!1;break e;case 3:vn=j.stateNode.containerInfo,Sr=!0;break e;case 4:vn=j.stateNode.containerInfo,Sr=!0;break e}j=j.return}if(vn===null)throw Error(n(160));gy(S,_,x),vn=null,Sr=!1;var P=x.alternate;P!==null&&(P.return=null),x.return=null}catch(q){Ht(x,a,q)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)by(a,o),a=a.sibling}function by(o,a){var p=o.alternate,g=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Er(a,o),Br(o),g&4){try{al(3,o,o.return),Ua(3,o)}catch(Ie){Ht(o,o.return,Ie)}try{al(5,o,o.return)}catch(Ie){Ht(o,o.return,Ie)}}break;case 1:Er(a,o),Br(o),g&512&&p!==null&&oo(p,p.return);break;case 5:if(Er(a,o),Br(o),g&512&&p!==null&&oo(p,p.return),o.flags&32){var x=o.stateNode;try{Z(x,"")}catch(Ie){Ht(o,o.return,Ie)}}if(g&4&&(x=o.stateNode,x!=null)){var S=o.memoizedProps,_=p!==null?p.memoizedProps:S,j=o.type,P=o.updateQueue;if(o.updateQueue=null,P!==null)try{j==="input"&&S.type==="radio"&&S.name!=null&&me(x,S),Un(j,_);var q=Un(j,S);for(_=0;_<P.length;_+=2){var fe=P[_],he=P[_+1];fe==="style"?Ze(x,he):fe==="dangerouslySetInnerHTML"?Xn(x,he):fe==="children"?Z(x,he):O(x,fe,he,q)}switch(j){case"input":Ae(x,S);break;case"textarea":lt(x,S);break;case"select":var de=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!S.multiple;var Ee=S.value;Ee!=null?Lt(x,!!S.multiple,Ee,!1):de!==!!S.multiple&&(S.defaultValue!=null?Lt(x,!!S.multiple,S.defaultValue,!0):Lt(x,!!S.multiple,S.multiple?[]:"",!1))}x[Qo]=S}catch(Ie){Ht(o,o.return,Ie)}}break;case 6:if(Er(a,o),Br(o),g&4){if(o.stateNode===null)throw Error(n(162));x=o.stateNode,S=o.memoizedProps;try{x.nodeValue=S}catch(Ie){Ht(o,o.return,Ie)}}break;case 3:if(Er(a,o),Br(o),g&4&&p!==null&&p.memoizedState.isDehydrated)try{Fo(a.containerInfo)}catch(Ie){Ht(o,o.return,Ie)}break;case 4:Er(a,o),Br(o);break;case 13:Er(a,o),Br(o),x=o.child,x.flags&8192&&(S=x.memoizedState!==null,x.stateNode.isHidden=S,!S||x.alternate!==null&&x.alternate.memoizedState!==null||(Sf=Pt())),g&4&&yy(o);break;case 22:if(fe=p!==null&&p.memoizedState!==null,o.mode&1?(An=(q=An)||fe,Er(a,o),An=q):Er(a,o),Br(o),g&8192){if(q=o.memoizedState!==null,(o.stateNode.isHidden=q)&&!fe&&(o.mode&1)!==0)for(Me=o,fe=o.child;fe!==null;){for(he=Me=fe;Me!==null;){switch(de=Me,Ee=de.child,de.tag){case 0:case 11:case 14:case 15:al(4,de,de.return);break;case 1:oo(de,de.return);var Oe=de.stateNode;if(typeof Oe.componentWillUnmount=="function"){g=de,p=de.return;try{a=g,Oe.props=a.memoizedProps,Oe.state=a.memoizedState,Oe.componentWillUnmount()}catch(Ie){Ht(g,p,Ie)}}break;case 5:oo(de,de.return);break;case 22:if(de.memoizedState!==null){wy(he);continue}}Ee!==null?(Ee.return=de,Me=Ee):wy(he)}fe=fe.sibling}e:for(fe=null,he=o;;){if(he.tag===5){if(fe===null){fe=he;try{x=he.stateNode,q?(S=x.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(j=he.stateNode,P=he.memoizedProps.style,_=P!=null&&P.hasOwnProperty("display")?P.display:null,j.style.display=kt("display",_))}catch(Ie){Ht(o,o.return,Ie)}}}else if(he.tag===6){if(fe===null)try{he.stateNode.nodeValue=q?"":he.memoizedProps}catch(Ie){Ht(o,o.return,Ie)}}else if((he.tag!==22&&he.tag!==23||he.memoizedState===null||he===o)&&he.child!==null){he.child.return=he,he=he.child;continue}if(he===o)break e;for(;he.sibling===null;){if(he.return===null||he.return===o)break e;fe===he&&(fe=null),he=he.return}fe===he&&(fe=null),he.sibling.return=he.return,he=he.sibling}}break;case 19:Er(a,o),Br(o),g&4&&yy(o);break;case 21:break;default:Er(a,o),Br(o)}}function Br(o){var a=o.flags;if(a&2){try{e:{for(var p=o.return;p!==null;){if(hy(p)){var g=p;break e}p=p.return}throw Error(n(160))}switch(g.tag){case 5:var x=g.stateNode;g.flags&32&&(Z(x,""),g.flags&=-33);var S=my(o);xf(o,S,x);break;case 3:case 4:var _=g.stateNode.containerInfo,j=my(o);vf(o,j,_);break;default:throw Error(n(161))}}catch(P){Ht(o,o.return,P)}o.flags&=-3}a&4096&&(o.flags&=-4097)}function qS(o,a,p){Me=o,vy(o)}function vy(o,a,p){for(var g=(o.mode&1)!==0;Me!==null;){var x=Me,S=x.child;if(x.tag===22&&g){var _=x.memoizedState!==null||$a;if(!_){var j=x.alternate,P=j!==null&&j.memoizedState!==null||An;j=$a;var q=An;if($a=_,(An=P)&&!q)for(Me=x;Me!==null;)_=Me,P=_.child,_.tag===22&&_.memoizedState!==null?ky(x):P!==null?(P.return=_,Me=P):ky(x);for(;S!==null;)Me=S,vy(S),S=S.sibling;Me=x,$a=j,An=q}xy(o)}else(x.subtreeFlags&8772)!==0&&S!==null?(S.return=x,Me=S):xy(o)}}function xy(o){for(;Me!==null;){var a=Me;if((a.flags&8772)!==0){var p=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:An||Ua(5,a);break;case 1:var g=a.stateNode;if(a.flags&4&&!An)if(p===null)g.componentDidMount();else{var x=a.elementType===a.type?p.memoizedProps:kr(a.type,p.memoizedProps);g.componentDidUpdate(x,p.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var S=a.updateQueue;S!==null&&wg(a,S,g);break;case 3:var _=a.updateQueue;if(_!==null){if(p=null,a.child!==null)switch(a.child.tag){case 5:p=a.child.stateNode;break;case 1:p=a.child.stateNode}wg(a,_,p)}break;case 5:var j=a.stateNode;if(p===null&&a.flags&4){p=j;var P=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":P.autoFocus&&p.focus();break;case"img":P.src&&(p.src=P.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var q=a.alternate;if(q!==null){var fe=q.memoizedState;if(fe!==null){var he=fe.dehydrated;he!==null&&Fo(he)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}An||a.flags&512&&bf(a)}catch(de){Ht(a,a.return,de)}}if(a===o){Me=null;break}if(p=a.sibling,p!==null){p.return=a.return,Me=p;break}Me=a.return}}function wy(o){for(;Me!==null;){var a=Me;if(a===o){Me=null;break}var p=a.sibling;if(p!==null){p.return=a.return,Me=p;break}Me=a.return}}function ky(o){for(;Me!==null;){var a=Me;try{switch(a.tag){case 0:case 11:case 15:var p=a.return;try{Ua(4,a)}catch(P){Ht(a,p,P)}break;case 1:var g=a.stateNode;if(typeof g.componentDidMount=="function"){var x=a.return;try{g.componentDidMount()}catch(P){Ht(a,x,P)}}var S=a.return;try{bf(a)}catch(P){Ht(a,S,P)}break;case 5:var _=a.return;try{bf(a)}catch(P){Ht(a,_,P)}}}catch(P){Ht(a,a.return,P)}if(a===o){Me=null;break}var j=a.sibling;if(j!==null){j.return=a.return,Me=j;break}Me=a.return}}var JS=Math.ceil,Ha=T.ReactCurrentDispatcher,wf=T.ReactCurrentOwner,dr=T.ReactCurrentBatchConfig,dt=0,un=null,tn=null,xn=0,nr=0,lo=xs(0),on=0,cl=null,hi=0,Wa=0,kf=0,ul=null,Kn=null,Sf=0,ao=1/0,es=null,Va=!1,Ef=null,Cs=null,Ka=!1,_s=null,Ga=0,dl=0,Nf=null,qa=-1,Ja=0;function Bn(){return(dt&6)!==0?Pt():qa!==-1?qa:qa=Pt()}function Ts(o){return(o.mode&1)===0?1:(dt&2)!==0&&xn!==0?xn&-xn:RS.transition!==null?(Ja===0&&(Ja=sa()),Ja):(o=ut,o!==0||(o=window.event,o=o===void 0?16:Em(o.type)),o)}function Nr(o,a,p,g){if(50<dl)throw dl=0,Nf=null,Error(n(185));ms(o,p,g),((dt&2)===0||o!==un)&&(o===un&&((dt&2)===0&&(Wa|=p),on===4&&Ms(o,xn)),Gn(o,g),p===1&&dt===0&&(a.mode&1)===0&&(ao=Pt()+500,Sa&&ks()))}function Gn(o,a){var p=o.callbackNode;ld(o,a);var g=si(o,o===un?xn:0);if(g===0)p!==null&&vr(p),o.callbackNode=null,o.callbackPriority=0;else if(a=g&-g,o.callbackPriority!==a){if(p!=null&&vr(p),a===1)o.tag===0?OS(Ey.bind(null,o)):cg(Ey.bind(null,o)),_S(function(){(dt&6)===0&&ks()}),p=null;else{switch(et(g)){case 1:p=jo;break;case 4:p=ni;break;case 16:p=Fi;break;case 536870912:p=De;break;default:p=Fi}p=Ry(p,Sy.bind(null,o))}o.callbackPriority=a,o.callbackNode=p}}function Sy(o,a){if(qa=-1,Ja=0,(dt&6)!==0)throw Error(n(327));var p=o.callbackNode;if(co()&&o.callbackNode!==p)return null;var g=si(o,o===un?xn:0);if(g===0)return null;if((g&30)!==0||(g&o.expiredLanes)!==0||a)a=Ya(o,g);else{a=g;var x=dt;dt|=2;var S=Cy();(un!==o||xn!==a)&&(es=null,ao=Pt()+500,gi(o,a));do try{XS();break}catch(j){Ny(o,j)}while(!0);Ud(),Ha.current=S,dt=x,tn!==null?a=0:(un=null,xn=0,a=on)}if(a!==0){if(a===2&&(x=Lo(o),x!==0&&(g=x,a=Cf(o,x))),a===1)throw p=cl,gi(o,0),Ms(o,g),Gn(o,Pt()),p;if(a===6)Ms(o,g);else{if(x=o.current.alternate,(g&30)===0&&!YS(x)&&(a=Ya(o,g),a===2&&(S=Lo(o),S!==0&&(g=S,a=Cf(o,S))),a===1))throw p=cl,gi(o,0),Ms(o,g),Gn(o,Pt()),p;switch(o.finishedWork=x,o.finishedLanes=g,a){case 0:case 1:throw Error(n(345));case 2:yi(o,Kn,es);break;case 3:if(Ms(o,g),(g&130023424)===g&&(a=Sf+500-Pt(),10<a)){if(si(o,0)!==0)break;if(x=o.suspendedLanes,(x&g)!==g){Bn(),o.pingedLanes|=o.suspendedLanes&x;break}o.timeoutHandle=Od(yi.bind(null,o,Kn,es),a);break}yi(o,Kn,es);break;case 4:if(Ms(o,g),(g&4194240)===g)break;for(a=o.eventTimes,x=-1;0<g;){var _=31-Bt(g);S=1<<_,_=a[_],_>x&&(x=_),g&=~S}if(g=x,g=Pt()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*JS(g/1960))-g,10<g){o.timeoutHandle=Od(yi.bind(null,o,Kn,es),g);break}yi(o,Kn,es);break;case 5:yi(o,Kn,es);break;default:throw Error(n(329))}}}return Gn(o,Pt()),o.callbackNode===p?Sy.bind(null,o):null}function Cf(o,a){var p=ul;return o.current.memoizedState.isDehydrated&&(gi(o,a).flags|=256),o=Ya(o,a),o!==2&&(a=Kn,Kn=p,a!==null&&_f(a)),o}function _f(o){Kn===null?Kn=o:Kn.push.apply(Kn,o)}function YS(o){for(var a=o;;){if(a.flags&16384){var p=a.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var g=0;g<p.length;g++){var x=p[g],S=x.getSnapshot;x=x.value;try{if(!xr(S(),x))return!1}catch{return!1}}}if(p=a.child,a.subtreeFlags&16384&&p!==null)p.return=a,a=p;else{if(a===o)break;for(;a.sibling===null;){if(a.return===null||a.return===o)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function Ms(o,a){for(a&=~kf,a&=~Wa,o.suspendedLanes|=a,o.pingedLanes&=~a,o=o.expirationTimes;0<a;){var p=31-Bt(a),g=1<<p;o[p]=-1,a&=~g}}function Ey(o){if((dt&6)!==0)throw Error(n(327));co();var a=si(o,0);if((a&1)===0)return Gn(o,Pt()),null;var p=Ya(o,a);if(o.tag!==0&&p===2){var g=Lo(o);g!==0&&(a=g,p=Cf(o,g))}if(p===1)throw p=cl,gi(o,0),Ms(o,a),Gn(o,Pt()),p;if(p===6)throw Error(n(345));return o.finishedWork=o.current.alternate,o.finishedLanes=a,yi(o,Kn,es),Gn(o,Pt()),null}function Tf(o,a){var p=dt;dt|=1;try{return o(a)}finally{dt=p,dt===0&&(ao=Pt()+500,Sa&&ks())}}function mi(o){_s!==null&&_s.tag===0&&(dt&6)===0&&co();var a=dt;dt|=1;var p=dr.transition,g=ut;try{if(dr.transition=null,ut=1,o)return o()}finally{ut=g,dr.transition=p,dt=a,(dt&6)===0&&ks()}}function Mf(){nr=lo.current,It(lo)}function gi(o,a){o.finishedWork=null,o.finishedLanes=0;var p=o.timeoutHandle;if(p!==-1&&(o.timeoutHandle=-1,CS(p)),tn!==null)for(p=tn.return;p!==null;){var g=p;switch(Pd(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&wa();break;case 3:so(),It(Hn),It(_n),Yd();break;case 5:qd(g);break;case 4:so();break;case 13:It(zt);break;case 19:It(zt);break;case 10:Hd(g.type._context);break;case 22:case 23:Mf()}p=p.return}if(un=o,tn=o=As(o.current,null),xn=nr=a,on=0,cl=null,kf=Wa=hi=0,Kn=ul=null,di!==null){for(a=0;a<di.length;a++)if(p=di[a],g=p.interleaved,g!==null){p.interleaved=null;var x=g.next,S=p.pending;if(S!==null){var _=S.next;S.next=x,g.next=_}p.pending=g}di=null}return o}function Ny(o,a){do{var p=tn;try{if(Ud(),Ia.current=Pa,ja){for(var g=Ft.memoizedState;g!==null;){var x=g.queue;x!==null&&(x.pending=null),g=g.next}ja=!1}if(pi=0,cn=sn=Ft=null,rl=!1,sl=0,wf.current=null,p===null||p.return===null){on=1,cl=a,tn=null;break}e:{var S=o,_=p.return,j=p,P=a;if(a=xn,j.flags|=32768,P!==null&&typeof P=="object"&&typeof P.then=="function"){var q=P,fe=j,he=fe.tag;if((fe.mode&1)===0&&(he===0||he===11||he===15)){var de=fe.alternate;de?(fe.updateQueue=de.updateQueue,fe.memoizedState=de.memoizedState,fe.lanes=de.lanes):(fe.updateQueue=null,fe.memoizedState=null)}var Ee=Yg(_);if(Ee!==null){Ee.flags&=-257,Qg(Ee,_,j,S,a),Ee.mode&1&&Jg(S,q,a),a=Ee,P=q;var Oe=a.updateQueue;if(Oe===null){var Ie=new Set;Ie.add(P),a.updateQueue=Ie}else Oe.add(P);break e}else{if((a&1)===0){Jg(S,q,a),Af();break e}P=Error(n(426))}}else if(Dt&&j.mode&1){var Xt=Yg(_);if(Xt!==null){(Xt.flags&65536)===0&&(Xt.flags|=256),Qg(Xt,_,j,S,a),Fd(io(P,j));break e}}S=P=io(P,j),on!==4&&(on=2),ul===null?ul=[S]:ul.push(S),S=_;do{switch(S.tag){case 3:S.flags|=65536,a&=-a,S.lanes|=a;var W=Gg(S,P,a);xg(S,W);break e;case 1:j=P;var F=S.type,K=S.stateNode;if((S.flags&128)===0&&(typeof F.getDerivedStateFromError=="function"||K!==null&&typeof K.componentDidCatch=="function"&&(Cs===null||!Cs.has(K)))){S.flags|=65536,a&=-a,S.lanes|=a;var be=qg(S,j,a);xg(S,be);break e}}S=S.return}while(S!==null)}Ty(p)}catch(je){a=je,tn===p&&p!==null&&(tn=p=p.return);continue}break}while(!0)}function Cy(){var o=Ha.current;return Ha.current=Pa,o===null?Pa:o}function Af(){(on===0||on===3||on===2)&&(on=4),un===null||(hi&268435455)===0&&(Wa&268435455)===0||Ms(un,xn)}function Ya(o,a){var p=dt;dt|=2;var g=Cy();(un!==o||xn!==a)&&(es=null,gi(o,a));do try{QS();break}catch(x){Ny(o,x)}while(!0);if(Ud(),dt=p,Ha.current=g,tn!==null)throw Error(n(261));return un=null,xn=0,on}function QS(){for(;tn!==null;)_y(tn)}function XS(){for(;tn!==null&&!na();)_y(tn)}function _y(o){var a=Oy(o.alternate,o,nr);o.memoizedProps=o.pendingProps,a===null?Ty(o):tn=a,wf.current=null}function Ty(o){var a=o;do{var p=a.alternate;if(o=a.return,(a.flags&32768)===0){if(p=WS(p,a,nr),p!==null){tn=p;return}}else{if(p=VS(p,a),p!==null){p.flags&=32767,tn=p;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{on=6,tn=null;return}}if(a=a.sibling,a!==null){tn=a;return}tn=a=o}while(a!==null);on===0&&(on=5)}function yi(o,a,p){var g=ut,x=dr.transition;try{dr.transition=null,ut=1,ZS(o,a,p,g)}finally{dr.transition=x,ut=g}return null}function ZS(o,a,p,g){do co();while(_s!==null);if((dt&6)!==0)throw Error(n(327));p=o.finishedWork;var x=o.finishedLanes;if(p===null)return null;if(o.finishedWork=null,o.finishedLanes=0,p===o.current)throw Error(n(177));o.callbackNode=null,o.callbackPriority=0;var S=p.lanes|p.childLanes;if(or(o,S),o===un&&(tn=un=null,xn=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Ka||(Ka=!0,Ry(Fi,function(){return co(),null})),S=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||S){S=dr.transition,dr.transition=null;var _=ut;ut=1;var j=dt;dt|=4,wf.current=null,GS(o,p),by(p,o),vS(Md),la=!!Td,Md=Td=null,o.current=p,qS(p),ra(),dt=j,ut=_,dr.transition=S}else o.current=p;if(Ka&&(Ka=!1,_s=o,Ga=x),S=o.pendingLanes,S===0&&(Cs=null),Yt(p.stateNode),Gn(o,Pt()),a!==null)for(g=o.onRecoverableError,p=0;p<a.length;p++)x=a[p],g(x.value,{componentStack:x.stack,digest:x.digest});if(Va)throw Va=!1,o=Ef,Ef=null,o;return(Ga&1)!==0&&o.tag!==0&&co(),S=o.pendingLanes,(S&1)!==0?o===Nf?dl++:(dl=0,Nf=o):dl=0,ks(),null}function co(){if(_s!==null){var o=et(Ga),a=dr.transition,p=ut;try{if(dr.transition=null,ut=16>o?16:o,_s===null)var g=!1;else{if(o=_s,_s=null,Ga=0,(dt&6)!==0)throw Error(n(331));var x=dt;for(dt|=4,Me=o.current;Me!==null;){var S=Me,_=S.child;if((Me.flags&16)!==0){var j=S.deletions;if(j!==null){for(var P=0;P<j.length;P++){var q=j[P];for(Me=q;Me!==null;){var fe=Me;switch(fe.tag){case 0:case 11:case 15:al(8,fe,S)}var he=fe.child;if(he!==null)he.return=fe,Me=he;else for(;Me!==null;){fe=Me;var de=fe.sibling,Ee=fe.return;if(py(fe),fe===q){Me=null;break}if(de!==null){de.return=Ee,Me=de;break}Me=Ee}}}var Oe=S.alternate;if(Oe!==null){var Ie=Oe.child;if(Ie!==null){Oe.child=null;do{var Xt=Ie.sibling;Ie.sibling=null,Ie=Xt}while(Ie!==null)}}Me=S}}if((S.subtreeFlags&2064)!==0&&_!==null)_.return=S,Me=_;else e:for(;Me!==null;){if(S=Me,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:al(9,S,S.return)}var W=S.sibling;if(W!==null){W.return=S.return,Me=W;break e}Me=S.return}}var F=o.current;for(Me=F;Me!==null;){_=Me;var K=_.child;if((_.subtreeFlags&2064)!==0&&K!==null)K.return=_,Me=K;else e:for(_=F;Me!==null;){if(j=Me,(j.flags&2048)!==0)try{switch(j.tag){case 0:case 11:case 15:Ua(9,j)}}catch(je){Ht(j,j.return,je)}if(j===_){Me=null;break e}var be=j.sibling;if(be!==null){be.return=j.return,Me=be;break e}Me=j.return}}if(dt=x,ks(),ot&&typeof ot.onPostCommitFiberRoot=="function")try{ot.onPostCommitFiberRoot(rt,o)}catch{}g=!0}return g}finally{ut=p,dr.transition=a}}return!1}function My(o,a,p){a=io(p,a),a=Gg(o,a,1),o=Es(o,a,1),a=Bn(),o!==null&&(ms(o,1,a),Gn(o,a))}function Ht(o,a,p){if(o.tag===3)My(o,o,p);else for(;a!==null;){if(a.tag===3){My(a,o,p);break}else if(a.tag===1){var g=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Cs===null||!Cs.has(g))){o=io(p,o),o=qg(a,o,1),a=Es(a,o,1),o=Bn(),a!==null&&(ms(a,1,o),Gn(a,o));break}}a=a.return}}function eE(o,a,p){var g=o.pingCache;g!==null&&g.delete(a),a=Bn(),o.pingedLanes|=o.suspendedLanes&p,un===o&&(xn&p)===p&&(on===4||on===3&&(xn&130023424)===xn&&500>Pt()-Sf?gi(o,0):kf|=p),Gn(o,a)}function Ay(o,a){a===0&&((o.mode&1)===0?a=1:(a=ri,ri<<=1,(ri&130023424)===0&&(ri=4194304)));var p=Bn();o=Qr(o,a),o!==null&&(ms(o,a,p),Gn(o,p))}function tE(o){var a=o.memoizedState,p=0;a!==null&&(p=a.retryLane),Ay(o,p)}function nE(o,a){var p=0;switch(o.tag){case 13:var g=o.stateNode,x=o.memoizedState;x!==null&&(p=x.retryLane);break;case 19:g=o.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(a),Ay(o,p)}var Oy;Oy=function(o,a,p){if(o!==null)if(o.memoizedProps!==a.pendingProps||Hn.current)Vn=!0;else{if((o.lanes&p)===0&&(a.flags&128)===0)return Vn=!1,HS(o,a,p);Vn=(o.flags&131072)!==0}else Vn=!1,Dt&&(a.flags&1048576)!==0&&ug(a,Na,a.index);switch(a.lanes=0,a.tag){case 2:var g=a.type;Fa(o,a),o=a.pendingProps;var x=Qi(a,_n.current);ro(a,p),x=Zd(null,a,g,o,x,p);var S=ef();return a.flags|=1,typeof x=="object"&&x!==null&&typeof x.render=="function"&&x.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Wn(g)?(S=!0,ka(a)):S=!1,a.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,Kd(a),x.updater=Ba,a.stateNode=x,x._reactInternals=a,lf(a,g,o,p),a=df(null,a,g,!0,S,p)):(a.tag=0,Dt&&S&&Dd(a),Pn(null,a,x,p),a=a.child),a;case 16:g=a.elementType;e:{switch(Fa(o,a),o=a.pendingProps,x=g._init,g=x(g._payload),a.type=g,x=a.tag=sE(g),o=kr(g,o),x){case 0:a=uf(null,a,g,o,p);break e;case 1:a=ry(null,a,g,o,p);break e;case 11:a=Xg(null,a,g,o,p);break e;case 14:a=Zg(null,a,g,kr(g.type,o),p);break e}throw Error(n(306,g,""))}return a;case 0:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),uf(o,a,g,x,p);case 1:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),ry(o,a,g,x,p);case 3:e:{if(sy(a),o===null)throw Error(n(387));g=a.pendingProps,S=a.memoizedState,x=S.element,vg(o,a),Oa(a,g,null,p);var _=a.memoizedState;if(g=_.element,S.isDehydrated)if(S={element:g,isDehydrated:!1,cache:_.cache,pendingSuspenseBoundaries:_.pendingSuspenseBoundaries,transitions:_.transitions},a.updateQueue.baseState=S,a.memoizedState=S,a.flags&256){x=io(Error(n(423)),a),a=iy(o,a,g,p,x);break e}else if(g!==x){x=io(Error(n(424)),a),a=iy(o,a,g,p,x);break e}else for(tr=vs(a.stateNode.containerInfo.firstChild),er=a,Dt=!0,wr=null,p=yg(a,null,g,p),a.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(eo(),g===x){a=Zr(o,a,p);break e}Pn(o,a,g,p)}a=a.child}return a;case 5:return kg(a),o===null&&zd(a),g=a.type,x=a.pendingProps,S=o!==null?o.memoizedProps:null,_=x.children,Ad(g,x)?_=null:S!==null&&Ad(g,S)&&(a.flags|=32),ny(o,a),Pn(o,a,_,p),a.child;case 6:return o===null&&zd(a),null;case 13:return oy(o,a,p);case 4:return Gd(a,a.stateNode.containerInfo),g=a.pendingProps,o===null?a.child=to(a,null,g,p):Pn(o,a,g,p),a.child;case 11:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),Xg(o,a,g,x,p);case 7:return Pn(o,a,a.pendingProps,p),a.child;case 8:return Pn(o,a,a.pendingProps.children,p),a.child;case 12:return Pn(o,a,a.pendingProps.children,p),a.child;case 10:e:{if(g=a.type._context,x=a.pendingProps,S=a.memoizedProps,_=x.value,Tt(Ta,g._currentValue),g._currentValue=_,S!==null)if(xr(S.value,_)){if(S.children===x.children&&!Hn.current){a=Zr(o,a,p);break e}}else for(S=a.child,S!==null&&(S.return=a);S!==null;){var j=S.dependencies;if(j!==null){_=S.child;for(var P=j.firstContext;P!==null;){if(P.context===g){if(S.tag===1){P=Xr(-1,p&-p),P.tag=2;var q=S.updateQueue;if(q!==null){q=q.shared;var fe=q.pending;fe===null?P.next=P:(P.next=fe.next,fe.next=P),q.pending=P}}S.lanes|=p,P=S.alternate,P!==null&&(P.lanes|=p),Wd(S.return,p,a),j.lanes|=p;break}P=P.next}}else if(S.tag===10)_=S.type===a.type?null:S.child;else if(S.tag===18){if(_=S.return,_===null)throw Error(n(341));_.lanes|=p,j=_.alternate,j!==null&&(j.lanes|=p),Wd(_,p,a),_=S.sibling}else _=S.child;if(_!==null)_.return=S;else for(_=S;_!==null;){if(_===a){_=null;break}if(S=_.sibling,S!==null){S.return=_.return,_=S;break}_=_.return}S=_}Pn(o,a,x.children,p),a=a.child}return a;case 9:return x=a.type,g=a.pendingProps.children,ro(a,p),x=cr(x),g=g(x),a.flags|=1,Pn(o,a,g,p),a.child;case 14:return g=a.type,x=kr(g,a.pendingProps),x=kr(g.type,x),Zg(o,a,g,x,p);case 15:return ey(o,a,a.type,a.pendingProps,p);case 17:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),Fa(o,a),a.tag=1,Wn(g)?(o=!0,ka(a)):o=!1,ro(a,p),Vg(a,g,x),lf(a,g,x,p),df(null,a,g,!0,o,p);case 19:return ay(o,a,p);case 22:return ty(o,a,p)}throw Error(n(156,a.tag))};function Ry(o,a){return ta(o,a)}function rE(o,a,p,g){this.tag=o,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(o,a,p,g){return new rE(o,a,p,g)}function Of(o){return o=o.prototype,!(!o||!o.isReactComponent)}function sE(o){if(typeof o=="function")return Of(o)?1:0;if(o!=null){if(o=o.$$typeof,o===L)return 11;if(o===ee)return 14}return 2}function As(o,a){var p=o.alternate;return p===null?(p=fr(o.tag,a,o.key,o.mode),p.elementType=o.elementType,p.type=o.type,p.stateNode=o.stateNode,p.alternate=o,o.alternate=p):(p.pendingProps=a,p.type=o.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=o.flags&14680064,p.childLanes=o.childLanes,p.lanes=o.lanes,p.child=o.child,p.memoizedProps=o.memoizedProps,p.memoizedState=o.memoizedState,p.updateQueue=o.updateQueue,a=o.dependencies,p.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},p.sibling=o.sibling,p.index=o.index,p.ref=o.ref,p}function Qa(o,a,p,g,x,S){var _=2;if(g=o,typeof o=="function")Of(o)&&(_=1);else if(typeof o=="string")_=5;else e:switch(o){case B:return bi(p.children,x,S,a);case U:_=8,x|=8;break;case z:return o=fr(12,p,a,x|2),o.elementType=z,o.lanes=S,o;case Y:return o=fr(13,p,a,x),o.elementType=Y,o.lanes=S,o;case Q:return o=fr(19,p,a,x),o.elementType=Q,o.lanes=S,o;case ne:return Xa(p,x,S,a);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case H:_=10;break e;case $:_=9;break e;case L:_=11;break e;case ee:_=14;break e;case G:_=16,g=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return a=fr(_,p,a,x),a.elementType=o,a.type=g,a.lanes=S,a}function bi(o,a,p,g){return o=fr(7,o,g,a),o.lanes=p,o}function Xa(o,a,p,g){return o=fr(22,o,g,a),o.elementType=ne,o.lanes=p,o.stateNode={isHidden:!1},o}function Rf(o,a,p){return o=fr(6,o,null,a),o.lanes=p,o}function If(o,a,p){return a=fr(4,o.children!==null?o.children:[],o.key,a),a.lanes=p,a.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},a}function iE(o,a,p,g,x){this.tag=a,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=hs(0),this.expirationTimes=hs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hs(0),this.identifierPrefix=g,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function jf(o,a,p,g,x,S,_,j,P){return o=new iE(o,a,p,j,P),a===1?(a=1,S===!0&&(a|=8)):a=0,S=fr(3,null,null,a),o.current=S,S.stateNode=o,S.memoizedState={element:g,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Kd(S),o}function oE(o,a,p){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:g==null?null:""+g,children:o,containerInfo:a,implementation:p}}function Iy(o){if(!o)return ws;o=o._reactInternals;e:{if(Kr(o)!==o||o.tag!==1)throw Error(n(170));var a=o;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(Wn(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(o.tag===1){var p=o.type;if(Wn(p))return lg(o,p,a)}return a}function jy(o,a,p,g,x,S,_,j,P){return o=jf(p,g,!0,o,x,S,_,j,P),o.context=Iy(null),p=o.current,g=Bn(),x=Ts(p),S=Xr(g,x),S.callback=a??null,Es(p,S,x),o.current.lanes=x,ms(o,x,g),Gn(o,g),o}function Za(o,a,p,g){var x=a.current,S=Bn(),_=Ts(x);return p=Iy(p),a.context===null?a.context=p:a.pendingContext=p,a=Xr(S,_),a.payload={element:o},g=g===void 0?null:g,g!==null&&(a.callback=g),o=Es(x,a,_),o!==null&&(Nr(o,x,_,S),Aa(o,x,_)),_}function ec(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function Ly(o,a){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var p=o.retryLane;o.retryLane=p!==0&&p<a?p:a}}function Lf(o,a){Ly(o,a),(o=o.alternate)&&Ly(o,a)}function lE(){return null}var Dy=typeof reportError=="function"?reportError:function(o){console.error(o)};function Df(o){this._internalRoot=o}tc.prototype.render=Df.prototype.render=function(o){var a=this._internalRoot;if(a===null)throw Error(n(409));Za(o,a,null,null)},tc.prototype.unmount=Df.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var a=o.containerInfo;mi(function(){Za(null,o,null,null)}),a[Gr]=null}};function tc(o){this._internalRoot=o}tc.prototype.unstable_scheduleHydration=function(o){if(o){var a=ii();o={blockedOn:null,target:o,priority:a};for(var p=0;p<an.length&&a!==0&&a<an[p].priority;p++);an.splice(p,0,o),p===0&&km(o)}};function Pf(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function nc(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Py(){}function aE(o,a,p,g,x){if(x){if(typeof g=="function"){var S=g;g=function(){var q=ec(_);S.call(q)}}var _=jy(a,g,o,0,null,!1,!1,"",Py);return o._reactRootContainer=_,o[Gr]=_.current,Jo(o.nodeType===8?o.parentNode:o),mi(),_}for(;x=o.lastChild;)o.removeChild(x);if(typeof g=="function"){var j=g;g=function(){var q=ec(P);j.call(q)}}var P=jf(o,0,!1,null,null,!1,!1,"",Py);return o._reactRootContainer=P,o[Gr]=P.current,Jo(o.nodeType===8?o.parentNode:o),mi(function(){Za(a,P,p,g)}),P}function rc(o,a,p,g,x){var S=p._reactRootContainer;if(S){var _=S;if(typeof x=="function"){var j=x;x=function(){var P=ec(_);j.call(P)}}Za(a,_,o,x)}else _=aE(p,a,o,x,g);return ec(_)}Po=function(o){switch(o.tag){case 3:var a=o.stateNode;if(a.current.memoizedState.isDehydrated){var p=ps(a.pendingLanes);p!==0&&(Do(a,p|1),Gn(a,Pt()),(dt&6)===0&&(ao=Pt()+500,ks()))}break;case 13:mi(function(){var g=Qr(o,1);if(g!==null){var x=Bn();Nr(g,o,1,x)}}),Lf(o,1)}},Qt=function(o){if(o.tag===13){var a=Qr(o,134217728);if(a!==null){var p=Bn();Nr(a,o,134217728,p)}Lf(o,134217728)}},vt=function(o){if(o.tag===13){var a=Ts(o),p=Qr(o,a);if(p!==null){var g=Bn();Nr(p,o,a,g)}Lf(o,a)}},ii=function(){return ut},jr=function(o,a){var p=ut;try{return ut=o,a()}finally{ut=p}},ve=function(o,a,p){switch(a){case"input":if(Ae(o,p),a=p.name,p.type==="radio"&&a!=null){for(p=o;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<p.length;a++){var g=p[a];if(g!==o&&g.form===o.form){var x=xa(g);if(!x)throw Error(n(90));ie(g),Ae(g,x)}}}break;case"textarea":lt(o,p);break;case"select":a=p.value,a!=null&&Lt(o,!!p.multiple,a,!1)}},we=Tf,Je=mi;var cE={usingClientEntryPoint:!1,Events:[Xo,Ji,xa,D,se,Tf]},fl={findFiberByHostInstance:li,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},uE={bundleType:fl.bundleType,version:fl.version,rendererPackageName:fl.rendererPackageName,rendererConfig:fl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=Zl(o),o===null?null:o.stateNode},findFiberByHostInstance:fl.findFiberByHostInstance||lE,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var sc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sc.isDisabled&&sc.supportsFiber)try{rt=sc.inject(uE),ot=sc}catch{}}return qn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=cE,qn.createPortal=function(o,a){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Pf(a))throw Error(n(200));return oE(o,a,null,p)},qn.createRoot=function(o,a){if(!Pf(o))throw Error(n(299));var p=!1,g="",x=Dy;return a!=null&&(a.unstable_strictMode===!0&&(p=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),a=jf(o,1,!1,null,null,p,!1,g,x),o[Gr]=a.current,Jo(o.nodeType===8?o.parentNode:o),new Df(a)},qn.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var a=o._reactInternals;if(a===void 0)throw typeof o.render=="function"?Error(n(188)):(o=Object.keys(o).join(","),Error(n(268,o)));return o=Zl(a),o=o===null?null:o.stateNode,o},qn.flushSync=function(o){return mi(o)},qn.hydrate=function(o,a,p){if(!nc(a))throw Error(n(200));return rc(null,o,a,!0,p)},qn.hydrateRoot=function(o,a,p){if(!Pf(o))throw Error(n(405));var g=p!=null&&p.hydratedSources||null,x=!1,S="",_=Dy;if(p!=null&&(p.unstable_strictMode===!0&&(x=!0),p.identifierPrefix!==void 0&&(S=p.identifierPrefix),p.onRecoverableError!==void 0&&(_=p.onRecoverableError)),a=jy(a,null,o,1,p??null,x,!1,S,_),o[Gr]=a.current,Jo(o),g)for(o=0;o<g.length;o++)p=g[o],x=p._getVersion,x=x(p._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[p,x]:a.mutableSourceEagerHydrationData.push(p,x);return new tc(a)},qn.render=function(o,a,p){if(!nc(a))throw Error(n(200));return rc(null,o,a,!1,p)},qn.unmountComponentAtNode=function(o){if(!nc(o))throw Error(n(40));return o._reactRootContainer?(mi(function(){rc(null,null,o,!1,function(){o._reactRootContainer=null,o[Gr]=null})}),!0):!1},qn.unstable_batchedUpdates=Tf,qn.unstable_renderSubtreeIntoContainer=function(o,a,p,g){if(!nc(p))throw Error(n(200));if(o==null||o._reactInternals===void 0)throw Error(n(38));return rc(o,a,p,!1,g)},qn.version="18.3.1-next-f1338f8080-20240426",qn}var Vy;function L0(){if(Vy)return Ff.exports;Vy=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(),Ff.exports=yE(),Ff.exports}var Ky;function bE(){if(Ky)return ic;Ky=1;var t=L0();return ic.createRoot=t.createRoot,ic.hydrateRoot=t.hydrateRoot,ic}var vE=bE();const xE=Bu(vE),D0=[{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"}],P0=[{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"},{id:"shelf",label:"Shelf",icon:"shelf"}],B0=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],z0=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],wE=["full","compact","minimal"],Sn={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"},kE={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function SE(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(Sn.typeface)){const n=kE[t];n&&localStorage.setItem(Sn.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(Sn.spacing)&&(localStorage.setItem(Sn.spacing,e),localStorage.removeItem("ow-typography"))}function F0(){const t=localStorage.getItem(Sn.typeface);return t&&D0.some(e=>e.id===t)?t:"charter"}function $0(){const t=localStorage.getItem(Sn.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function zu(){const t=localStorage.getItem(Sn.sidebarMode);return t&&P0.some(e=>e.id===t)?t:"default"}function U0(){return"cards"}function H0(){const t=localStorage.getItem(Sn.sidebarDensity);return t&&wE.includes(t)?t:"full"}function EE(t){localStorage.setItem(Sn.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function W0(){const t=localStorage.getItem(Sn.spacing);return t&&z0.some(e=>e.id===t)?t:"default"}function V0(){const t=localStorage.getItem(Sn.canvas);return t&&B0.some(e=>e.id===t)?t:"seamless"}function K0(t,e,n,r,s="default",i="seamless"){const l=document.documentElement;l.setAttribute("data-typeface",t),l.setAttribute("data-mode",e),l.setAttribute("data-sidebar-mode",n),l.setAttribute("data-sidebar-style",r),s==="default"?l.removeAttribute("data-spacing"):l.setAttribute("data-spacing",s),i==="seamless"?l.removeAttribute("data-canvas"):l.setAttribute("data-canvas",i),l.removeAttribute("data-color"),localStorage.setItem(Sn.typeface,t),localStorage.setItem(Sn.mode,e),localStorage.setItem(Sn.sidebarMode,n),localStorage.setItem(Sn.sidebarStyle,r),localStorage.setItem(Sn.spacing,s),localStorage.setItem(Sn.canvas,i)}function NE(){SE(),K0(F0(),$0(),zu(),U0(),W0(),V0()),document.documentElement.setAttribute("data-sidebar-density",H0())}var CE=L0();const _E=Bu(CE);var Hf={exports:{}},Wf={};/**
|
|
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 Gy;function TE(){if(Gy)return Wf;Gy=1;var t=Kl();function e(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,l=t.useDebugValue;function c(m,y){var b=y(),v=r({inst:{value:b,getSnapshot:y}}),w=v[0].inst,k=v[1];return i(function(){w.value=b,w.getSnapshot=y,u(w)&&k({inst:w})},[m,b,y]),s(function(){return u(w)&&k({inst:w}),m(function(){u(w)&&k({inst:w})})},[m]),l(b),b}function u(m){var y=m.getSnapshot;m=m.value;try{var b=y();return!n(m,b)}catch{return!0}}function f(m,y){return y()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Wf.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Wf}var qy;function G0(){return qy||(qy=1,Hf.exports=TE()),Hf.exports}var q0=G0();function kn(t){this.content=t}kn.prototype={constructor:kn,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 kn(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 kn(n)},addToStart:function(t,e){return new kn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new kn(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 kn(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=kn.from(t),t.size?new kn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=kn.from(t),t.size?new kn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=kn.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}};kn.from=function(t){if(t instanceof kn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new kn(e)};function J0(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 l=0;s.text[l]==i.text[l];l++)n++;return n}if(s.content.size||i.content.size){let l=J0(s.content,i.content,n+1);if(l!=null)return l}n+=s.nodeSize}}function Y0(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 l=t.child(--s),c=e.child(--i),u=l.nodeSize;if(l==c){n-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let f=0,h=Math.min(l.text.length,c.text.length);for(;f<h&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,r--;return{a:n,b:r}}if(l.content.size||c.content.size){let f=Y0(l.content,c.content,n-1,r-1);if(f)return f}n-=u,r-=u}}class le{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 l=0,c=0;c<n;l++){let u=this.content[l],f=c+u.nodeSize;if(f>e&&r(u,s+c,i||null,l)!==!1&&u.content.size){let h=c+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,n-h),r,s+h)}c=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",l=!0;return this.nodesBetween(e,n,(c,u)=>{let f=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?s?typeof s=="function"?s(c):s:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&r&&(l?l=!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 le(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,l=0;l<n;i++){let c=this.content[i],u=l+c.nodeSize;u>e&&((l<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),s+=c.nodeSize),l=u}return new le(r,s)}cutByIndex(e,n){return e==n?le.empty:e==0&&n==this.content.length?this:new le(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 le(s,i)}addToStart(e){return new le([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new le(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 J0(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Y0(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 le.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new le(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return le.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 le(n||e,r)}static from(e){if(!e)return le.empty;if(e instanceof le)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new le([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}le.empty=new le([],0);const Vf={index:0,offset:0};function oc(t,e){return Vf.index=t,Vf.offset=e,Vf}function Uc(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(!Uc(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Uc(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Nt=class Ap{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&&Uc(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 Ap.none;if(e instanceof Ap)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Nt.none=[];class Hc extends Error{}class Se{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=X0(this.content,e+this.openStart,n);return r&&new Se(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Se(Q0(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 Se.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 Se(le.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 Se(e,r,s)}}Se.empty=new Se(le.empty,0,0);function Q0(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(s==e||i.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(Q0(i.content,e-s-1,n-s-1)))}function X0(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),l=t.maybeChild(s);if(i==e||l.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=X0(l.content,e-i-1,n,l);return c&&t.replaceChild(s,l.copy(c))}function ME(t,e,n){if(n.openStart>t.depth)throw new Hc("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Hc("Inconsistent open depths");return Z0(t,e,n,0)}function Z0(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let l=Z0(t,e,n,r+1);return i.copy(i.content.replaceChild(s,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let l=t.parent,c=l.content;return Ci(l,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:l,end:c}=AE(n,t);return Ci(i,tx(t,l,c,e,r))}else return Ci(i,Wc(t,e,r))}function ex(t,e){if(!e.type.compatibleContent(t.type))throw new Hc("Cannot join "+e.type.name+" onto "+t.type.name)}function Op(t,e,n){let r=t.node(n);return ex(r,e.node(n)),r}function Ni(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 El(t,e,n,r){let s=(e||t).node(n),i=0,l=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ni(t.nodeAfter,r),i++));for(let c=i;c<l;c++)Ni(s.child(c),r);e&&e.depth==n&&e.textOffset&&Ni(e.nodeBefore,r)}function Ci(t,e){return t.type.checkContent(e),t.copy(e)}function tx(t,e,n,r,s){let i=t.depth>s&&Op(t,e,s+1),l=r.depth>s&&Op(n,r,s+1),c=[];return El(null,t,s,c),i&&l&&e.index(s)==n.index(s)?(ex(i,l),Ni(Ci(i,tx(t,e,n,r,s+1)),c)):(i&&Ni(Ci(i,Wc(t,e,s+1)),c),El(e,n,s,c),l&&Ni(Ci(l,Wc(n,r,s+1)),c)),El(r,null,s,c),new le(c)}function Wc(t,e,n){let r=[];if(El(null,t,n,r),t.depth>n){let s=Op(t,e,n+1);Ni(Ci(s,Wc(t,e,n+1)),r)}return El(e,null,n,r),new le(r)}function AE(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(le.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class jl{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 Nt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let c=r;r=s,s=c}let i=r.marks;for(var l=0;l<i.length;l++)i[l].type.spec.inclusive===!1&&(!s||!i[l].isInSet(s.marks))&&(i=i[l--].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 Vc(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 l=e;;){let{index:c,offset:u}=l.content.findIndex(i),f=i-u;if(r.push(l,c,s+u),!f||(l=l.child(c),l.isText))break;i=f-1,s+=u+1}return new jl(n,r,i)}static resolveCached(e,n){let r=Jy.get(e);if(r)for(let i=0;i<r.elts.length;i++){let l=r.elts[i];if(l.pos==n)return l}else Jy.set(e,r=new OE);let s=r.elts[r.i]=jl.resolve(e,n);return r.i=(r.i+1)%RE,s}}class OE{constructor(){this.elts=[],this.i=0}}const RE=12,Jy=new WeakMap;class Vc{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 IE=Object.create(null);class Mr{constructor(e,n,r,s=Nt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||le.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&&Uc(this.attrs,n||e.defaultAttrs||IE)&&Nt.sameSet(this.marks,r||Nt.none)}copy(e=null){return e==this.content?this:new Mr(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Mr(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 Se.empty;let s=this.resolve(e),i=this.resolve(n),l=r?0:s.sharedDepth(n),c=s.start(l),f=s.node(l).content.cut(s.pos-c,i.pos-c);return new Se(f,s.depth-l,i.depth-l)}replace(e,n,r){return ME(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 jl.resolveCached(this,e)}resolveNoCache(e){return jl.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()+")"),nx(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=le.empty,s=0,i=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,s,i),c=l&&l.matchFragment(this.content,n);if(!c||!c.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),l=i&&i.matchFragment(this.content,n);return l?l.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=Nt.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(!Nt.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=le.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Mr.prototype.text=void 0;class Kc extends Mr{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):nx(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 Kc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Kc(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 nx(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ai{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new jE(e,n);if(r.next==null)return Ai.empty;let s=rx(r);r.next&&r.err("Unexpected trailing text");let i=$E(FE(s));return UE(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(l,c){let u=l.matchFragment(e,r);if(u&&(!n||u.validEnd))return le.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:h,next:m}=l.next[f];if(!(h.isText||h.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let y=i(m,c.concat(h));if(y)return y}}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 l=[];for(let c=s;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!s.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:s}),n[c.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 l=0;l<r.next.length;l++)i+=(l?", ":"")+r.next[l].type.name+"->"+e.indexOf(r.next[l].next);return i}).join(`
|
|
49
|
+
`)}}Ai.empty=new Ai(!0);class jE{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 rx(t){let e=[];do e.push(LE(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function LE(t){let e=[];do e.push(DE(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function DE(t){let e=zE(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=PE(t,e);else break;return e}function Yy(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function PE(t,e){let n=Yy(t),r=n;return t.eat(",")&&(t.next!="}"?r=Yy(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function BE(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let l=n[i];l.isInGroup(e)&&s.push(l)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function zE(t){if(t.eat("(")){let e=rx(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=BE(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 FE(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(l,c,u){let f={term:u,to:c};return e[l].push(f),f}function s(l,c){l.forEach(u=>u.to=c)}function i(l,c){if(l.type=="choice")return l.exprs.reduce((u,f)=>u.concat(i(f,c)),[]);if(l.type=="seq")for(let u=0;;u++){let f=i(l.exprs[u],c);if(u==l.exprs.length-1)return f;s(f,c=n())}else if(l.type=="star"){let u=n();return r(c,u),s(i(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=n();return s(i(l.expr,c),u),s(i(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(c)].concat(i(l.expr,c));if(l.type=="range"){let u=c;for(let f=0;f<l.min;f++){let h=n();s(i(l.expr,u),h),u=h}if(l.max==-1)s(i(l.expr,u),u);else for(let f=l.min;f<l.max;f++){let h=n();r(u,h),s(i(l.expr,u),h),u=h}return[r(u)]}else{if(l.type=="name")return[r(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function sx(t,e){return e-t}function Qy(t,e){let n=[];return r(e),n.sort(sx);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let l=0;l<i.length;l++){let{term:c,to:u}=i[l];!c&&n.indexOf(u)==-1&&r(u)}}}function $E(t){let e=Object.create(null);return n(Qy(t,0));function n(r){let s=[];r.forEach(l=>{t[l].forEach(({term:c,to:u})=>{if(!c)return;let f;for(let h=0;h<s.length;h++)s[h][0]==c&&(f=s[h][1]);Qy(t,u).forEach(h=>{f||s.push([c,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let i=e[r.join(",")]=new Ai(r.indexOf(t.length-1)>-1);for(let l=0;l<s.length;l++){let c=s[l][1].sort(sx);i.next.push({type:s[l][0],next:e[c.join(",")]||n(c)})}return i}}function UE(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,l=[];for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];l.push(u.name),i&&!(u.isText||u.hasRequiredAttrs())&&(i=!1),r.indexOf(f)==-1&&r.push(f)}i&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ix(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 ox(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 lx(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 ax(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new WE(t,r,e[r]);return n}let Xy=class cx{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=ax(e,r.attrs),this.defaultAttrs=ix(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==Ai.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:ox(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Mr(this,this.computeAttrs(e),le.from(n),Nt.setFrom(r))}createChecked(e=null,n,r){return n=le.from(n),this.checkContent(n),new Mr(this,this.computeAttrs(e),n,Nt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=le.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(le.empty,!0);return i?new Mr(this,e,n.append(i),Nt.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){lx(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:Nt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,l)=>r[i]=new cx(i,n,l));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 HE(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 WE{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?HE(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Fu{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=ax(e,s.attrs),this.excluded=null;let i=ix(this.attrs);this.instance=i?new Nt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Nt(this,ox(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,l)=>r[i]=new Fu(i,s++,n,l)),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){lx(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ux{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=kn.from(e.nodes),n.marks=kn.from(e.marks||{}),this.nodes=Xy.compile(this.spec.nodes,this),this.marks=Fu.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],l=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=r[l]||(r[l]=Ai.parse(l,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=c=="_"?null:c?Zy(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],l=i.spec.excludes;i.excluded=l==null?[i]:l==""?[]:Zy(this,l.split(" "))}this.nodeFromJSON=s=>Mr.fromJSON(this,s),this.markFromJSON=s=>Nt.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 Xy){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 Kc(r,r.defaultAttrs,e,Nt.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 Zy(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],l=i;if(i)n.push(i);else for(let c in t.marks){let u=t.marks[c];(s=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(s)>-1)&&n.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function VE(t){return t.tag!=null}function KE(t){return t.style!=null}class Ws{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(VE(s))this.tags.push(s);else if(KE(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 tb(this,n,!1);return r.addAll(e,Nt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new tb(this,n,!0);return r.addAll(e,Nt.none,n.from,n.to),Se.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(JE(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let l=i.getAttrs(e);if(l===!1)continue;i.attrs=l||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 l=this.styles[i],c=l.style;if(!(c.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<i)break}n.splice(l,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(l=>{r(l=nb(l)),l.mark||l.ignore||l.clearMark||(l.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(l=>{r(l=nb(l)),l.node||l.ignore||l.mark||(l.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ws(e,Ws.schemaRules(e)))}}const dx={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},GE={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},fx={ol:!0,ul:!0},Ll=1,Rp=2,Nl=4;function eb(t,e,n){return e!=null?(e?Ll:0)|(e==="full"?Rp:0):t&&t.whitespace=="pre"?Ll|Rp:n&~Nl}class lc{constructor(e,n,r,s,i,l){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=l,this.content=[],this.activeMarks=Nt.none,this.match=i||(l&Nl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(le.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&Ll)){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=le.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(le.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&&!dx.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class tb{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,l=eb(null,n.preserveWhitespace,0)|(r?Nl:0);s?i=new lc(s.type,s.attrs,Nt.none,!0,n.topMatch||s.type.contentMatch,l):r?i=new lc(null,null,Nt.none,!0,null,l):i=new lc(e.schema.topNodeType,null,Nt.none,!0,null,l),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&Rp?"full":this.localPreserveWS||(s.options&Ll)>0,{schema:l}=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(l.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let u=0;u<c.length;u++)u&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[u]&&this.insertNode(l.text(c[u]),n,!/\S/.test(c[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 c=s.content[s.content.length-1],u=e.previousSibling;(!c||u&&u.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(r=r.slice(1))}r&&this.insertNode(l.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 l=e.nodeName.toLowerCase(),c;fx.hasOwnProperty(l)&&this.parser.normalizeLists&&qE(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(u?u.ignore:GE.hasOwnProperty(l))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,h=this.needsBlock;if(dx.hasOwnProperty(l))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=h}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,u,f,u.consuming===!1?c: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],l=r.getPropertyValue(i);if(l)for(let c=void 0;;){let u=this.parser.matchStyle(i,l,this,c);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)c=u;else break}}return n}addElementByRule(e,n,r,s){let i,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(l,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 c=this.top;if(l&&l.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(c)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let l=r?e.childNodes[r]:e.firstChild,c=s==null?null:e.childNodes[s];l!=c;l=l.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(l,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let l=this.open,c=0;l>=0;l--){let u=this.nodes[l],f=u.findWrapping(e);if(f&&(!s||s.length>f.length+c)&&(s=f,i=u,!f.length))break;if(u.solid){if(r)break;c+=2}}if(!s)return null;this.sync(i);for(let l=0;l<s.length;l++)n=this.enterInner(s[l],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 l=Nt.none;for(let c of s.concat(e.marks))(i.type?i.type.allowsMarkType(c.type):rb(c.type,e.type))&&(l=c.addToSet(l));return i.content.push(e.mark(l)),!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 l=this.top;l.match=l.match&&l.match.matchType(e);let c=eb(e,i,l.options);l.options&Nl&&l.content.length==0&&(c|=Nl);let u=Nt.none;return r=r.filter(f=>(l.type?l.type.allowsMarkType(f.type):rb(f.type,e))?(u=f.addToSet(u),!1):!0),this.nodes.push(new lc(e,n,u,s,null,c)),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|=Ll)}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),l=(c,u)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(l(c-1,u))return!0;return!1}else{let h=u>0||u==0&&s?this.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!h||h.name!=f&&!h.isInGroup(f))return!1;u--}}return!0};return l(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 qE(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&fx.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function JE(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function nb(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=[],l=c=>{i.push(c);for(let u=0;u<c.edgeCount;u++){let{type:f,next:h}=c.edge(u);if(f==e||i.indexOf(h)<0&&l(h))return!0}};if(l(s.contentMatch))return!0}}class Pi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Kf(n).createDocumentFragment());let s=r,i=[];return e.forEach(l=>{if(i.length||l.marks.length){let c=0,u=0;for(;c<i.length&&u<l.marks.length;){let f=l.marks[u];if(!this.marks[f.type.name]){u++;continue}if(!f.eq(i[c][0])||f.type.spec.spanning===!1)break;c++,u++}for(;c<i.length;)s=i.pop()[1];for(;u<l.marks.length;){let f=l.marks[u++],h=this.serializeMark(f,l.isInline,n);h&&(i.push([f,s]),s.appendChild(h.dom),s=h.contentDOM||h.dom)}}s.appendChild(this.serializeNodeInner(l,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=jc(Kf(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&&jc(Kf(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return jc(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Pi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=sb(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return sb(e.marks)}}function sb(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Kf(t){return t.document||window.document}const ib=new WeakMap;function YE(t){let e=ib.get(t);return e===void 0&&ib.set(t,e=QE(t)),e}function QE(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 jc(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=YE(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 l=s.indexOf(" ");l>0&&(n=s.slice(0,l),s=s.slice(l+1));let c,u=n?t.createElementNS(n,s):t.createElement(s),f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let m in f)if(f[m]!=null){let y=m.indexOf(" ");y>0?u.setAttributeNS(m.slice(0,y),m.slice(y+1),f[m]):m=="style"&&u.style?u.style.cssText=f[m]:u.setAttribute(m,f[m])}}for(let m=h;m<e.length;m++){let y=e[m];if(y===0){if(m<e.length-1||m>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:b,contentDOM:v}=jc(t,y,n,r);if(u.appendChild(b),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:u,contentDOM:c}}const px=65535,hx=Math.pow(2,16);function XE(t,e){return t+e*hx}function ob(t){return t&px}function ZE(t){return(t-(t&px))/hx}const mx=1,gx=2,Lc=4,yx=8;class Ip{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&yx)>0}get deletedBefore(){return(this.delInfo&(mx|Lc))>0}get deletedAfter(){return(this.delInfo&(gx|Lc))>0}get deletedAcross(){return(this.delInfo&Lc)>0}}class rr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&rr.empty)return rr.empty}recover(e){let n=0,r=ob(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+ZE(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,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?s:0);if(u>e)break;let f=this.ranges[c+i],h=this.ranges[c+l],m=u+f;if(e<=m){let y=f?e==u?-1:e==m?1:n:n,b=u+s+(y<0?0:h);if(r)return b;let v=e==(n<0?u:m)?null:XE(c/3,e-u),w=e==u?gx:e==m?mx:Lc;return(n<0?e!=u:e!=m)&&(w|=yx),new Ip(b,w,v)}s+=h-f}return r?e+s:new Ip(e+s,0,null)}touches(e,n){let r=0,s=ob(n),i=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[c+i],h=u+f;if(e<=h&&c==s*3)return!0;r+=this.ranges[c+l]-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 l=this.ranges[s],c=l-(this.inverted?i:0),u=l+(this.inverted?0:i),f=this.ranges[s+n],h=this.ranges[s+r];e(c,c+f,u,u+h),i+=h-f}}invert(){return new rr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?rr.empty:new rr(e<0?[0,-e,0]:[0,0,e])}}rr.empty=new rr([]);class Dl{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 Dl(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 Dl;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 l=this._maps[i],c=l.mapResult(e,n);if(c.recover!=null){let u=this.getMirror(i);if(u!=null&&u>i&&u<this.to){i=u,e=this._maps[u].recover(c.recover);continue}}s|=c.delInfo,e=c.pos}return r?e:new Ip(e,s,null)}}const Gf=Object.create(null);class jn{getMap(){return rr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gf[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 Gf)throw new RangeError("Duplicate use of step JSON ID "+e);return Gf[e]=n,n.prototype.jsonID=e,n}}class nn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new nn(e,null)}static fail(e){return new nn(null,e)}static fromReplace(e,n,r,s){try{return nn.ok(e.replace(n,r,s))}catch(i){if(i instanceof Hc)return nn.fail(i.message);throw i}}}function mh(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(mh(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return le.fromArray(r)}class Fs extends jn{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 Se(mh(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),s),n.openStart,n.openEnd);return nn.fromReplace(e,this.from,this.to,i)}invert(){return new Tr(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 Fs(n.pos,r.pos,this.mark)}merge(e){return e instanceof Fs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fs(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 Fs(n.from,n.to,e.markFromJSON(n.mark))}}jn.jsonID("addMark",Fs);class Tr extends jn{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 Se(mh(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return nn.fromReplace(e,this.from,this.to,r)}invert(){return new Fs(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 Tr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Tr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tr(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 Tr(n.from,n.to,e.markFromJSON(n.mark))}}jn.jsonID("removeMark",Tr);class $s extends jn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return nn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return nn.fromReplace(e,this.pos,this.pos+1,new Se(le.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 $s(this.pos,n.marks[s]);return new $s(this.pos,this.mark)}}return new Oi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new $s(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 $s(n.pos,e.markFromJSON(n.mark))}}jn.jsonID("addNodeMark",$s);class Oi extends jn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return nn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return nn.fromReplace(e,this.pos,this.pos+1,new Se(le.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new $s(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Oi(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 Oi(n.pos,e.markFromJSON(n.mark))}}jn.jsonID("removeNodeMark",Oi);class fn extends jn{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&jp(e,this.from,this.to)?nn.fail("Structure replace would overwrite content"):nn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new rr([this.from,this.to-this.from,this.slice.size])}invert(e){return new fn(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 fn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof fn)||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?Se.empty:new Se(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new fn(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?Se.empty:new Se(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new fn(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 fn(n.from,n.to,Se.fromJSON(e,n.slice),!!n.structure)}}jn.jsonID("replace",fn);class pn extends jn{constructor(e,n,r,s,i,l,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=l,this.structure=c}apply(e){if(this.structure&&(jp(e,this.from,this.gapFrom)||jp(e,this.gapTo,this.to)))return nn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return nn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?nn.fromReplace(e,this.from,this.to,r):nn.fail("Content does not fit in gap")}getMap(){return new rr([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 pn(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 pn(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 pn(n.from,n.to,n.gapFrom,n.gapTo,Se.fromJSON(e,n.slice),n.insert,!!n.structure)}}jn.jsonID("replaceAround",pn);function jp(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 l=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,s--}}return!1}function eN(t,e,n,r){let s=[],i=[],l,c;t.doc.nodesBetween(e,n,(u,f,h)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let y=Math.max(f,e),b=Math.min(f+u.nodeSize,n),v=r.addToSet(m);for(let w=0;w<m.length;w++)m[w].isInSet(v)||(l&&l.to==y&&l.mark.eq(m[w])?l.to=b:s.push(l=new Tr(y,b,m[w])));c&&c.to==y?c.to=b:i.push(c=new Fs(y,b,r))}}),s.forEach(u=>t.step(u)),i.forEach(u=>t.step(u))}function tN(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(l,c)=>{if(!l.isInline)return;i++;let u=null;if(r instanceof Fu){let f=l.marks,h;for(;h=r.isInSet(f);)(u||(u=[])).push(h),f=h.removeFromSet(f)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let f=Math.min(c+l.nodeSize,n);for(let h=0;h<u.length;h++){let m=u[h],y;for(let b=0;b<s.length;b++){let v=s[b];v.step==i-1&&m.eq(s[b].style)&&(y=v)}y?(y.to=f,y.step=i):s.push({style:m,from:Math.max(c,e),to:f,step:i})}}}),s.forEach(l=>t.step(new Tr(l.from,l.to,l.style)))}function gh(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),l=[],c=e+1;for(let u=0;u<i.childCount;u++){let f=i.child(u),h=c+f.nodeSize,m=r.matchType(f.type);if(!m)l.push(new fn(c,h,Se.empty));else{r=m;for(let y=0;y<f.marks.length;y++)n.allowsMarkType(f.marks[y].type)||t.step(new Tr(c,h,f.marks[y]));if(s&&f.isText&&n.whitespace!="pre"){let y,b=/\r?\n|\r/g,v;for(;y=b.exec(f.text);)v||(v=new Se(le.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new fn(c+y.index,c+y.index+y[0].length,v))}}c=h}if(!r.validEnd){let u=r.fillBefore(le.empty,!0);t.replace(c,c,new Se(u,0,0))}for(let u=l.length-1;u>=0;u--)t.step(l[u])}function nN(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ao(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let l=t.$from.node(r),c=t.$from.index(r)+s,u=t.$to.indexAfter(r)-i;if(r<t.depth&&l.canReplace(c,u,n))return r;if(r==0||l.type.spec.isolating||!nN(l,c,u))break;c&&(s=1),u<l.childCount&&(i=1)}return null}function rN(t,e,n){let{$from:r,$to:s,depth:i}=e,l=r.before(i+1),c=s.after(i+1),u=l,f=c,h=le.empty,m=0;for(let v=i,w=!1;v>n;v--)w||r.index(v)>0?(w=!0,h=le.from(r.node(v).copy(h)),m++):u--;let y=le.empty,b=0;for(let v=i,w=!1;v>n;v--)w||s.after(v+1)<s.end(v)?(w=!0,y=le.from(s.node(v).copy(y)),b++):f++;t.step(new pn(u,f,l,c,new Se(h.append(y),m,b),h.size-m,!0))}function yh(t,e,n=null,r=t){let s=sN(t,e),i=s&&iN(r,e);return i?s.map(lb).concat({type:e,attrs:n}).concat(i.map(lb)):null}function lb(t){return{type:t,attrs:null}}function sN(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let l=i.length?i[0]:e;return n.canReplaceWith(r,s,l)?i:null}function iN(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),l=e.contentMatch.findWrapping(i.type);if(!l)return null;let u=(l.length?l[l.length-1]:e).contentMatch;for(let f=r;u&&f<s;f++)u=u.matchType(n.child(f).type);return!u||!u.validEnd?null:l}function oN(t,e,n){let r=le.empty;for(let l=n.length-1;l>=0;l--){if(r.size){let c=n[l].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=le.from(n[l].type.create(n[l].attrs,r))}let s=e.start,i=e.end;t.step(new pn(s,i,s,i,new Se(r,0,0),n.length,!0))}function lN(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,(l,c)=>{let u=typeof s=="function"?s(l):s;if(l.isTextblock&&!l.hasMarkup(r,u)&&aN(t.doc,t.mapping.slice(i).map(c),r)){let f=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!v?f=!1:!b&&v&&(f=!0)}f===!1&&vx(t,l,c,i),gh(t,t.mapping.slice(i).map(c,1),r,void 0,f===null);let h=t.mapping.slice(i),m=h.map(c,1),y=h.map(c+l.nodeSize,1);return t.step(new pn(m,y,m+1,y-1,new Se(le.from(r.create(u,null,l.marks)),0,0),1,!0)),f===!0&&bx(t,l,c,i),!1}})}function bx(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(s.text);){let u=t.mapping.slice(r).map(n+1+i+l.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function vx(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let l=t.mapping.slice(r).map(n+1+i);t.replaceWith(l,l+1,e.type.schema.text(`
|
|
52
|
+
`))}})}function aN(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function cN(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 l=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,l);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new pn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Se(le.from(l),0,0),1,!0))}function cs(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,l=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!l.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let f=s.depth-1,h=n-2;f>i;f--,h--){let m=s.node(f),y=s.index(f);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(y,m.childCount),v=r&&r[h+1];v&&(b=b.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[h]||m;if(!m.canReplace(y+1,m.childCount)||!w.type.validContent(b))return!1}let c=s.indexAfter(i),u=r&&r[0];return s.node(i).canReplaceWith(c,c,u?u.type:s.node(i+1).type)}function uN(t,e,n=1,r){let s=t.doc.resolve(e),i=le.empty,l=le.empty;for(let c=s.depth,u=s.depth-n,f=n-1;c>u;c--,f--){i=le.from(s.node(c).copy(i));let h=r&&r[f];l=le.from(h?h.type.create(h.attrs,l):s.node(c).copy(l))}t.step(new fn(e,e,new Se(i.append(l),n,n),!0))}function Xs(t,e){let n=t.resolve(e),r=n.index();return xx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function dN(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),l=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(l),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function xx(t,e){return!!(t&&e&&!t.isLeaf&&dN(t,e))}function $u(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,l,c=r.index(s);if(s==r.depth?(i=r.nodeBefore,l=r.nodeAfter):n>0?(i=r.node(s+1),c++,l=r.node(s).maybeChild(c)):(i=r.node(s).maybeChild(c-1),l=r.node(s+1)),i&&!i.isTextblock&&xx(i,l)&&r.node(s).canReplace(c,c+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function fN(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),l=i.node().type;if(s&&l.inlineContent){let h=l.whitespace=="pre",m=!!l.contentMatch.matchType(s);h&&!m?r=!1:!h&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);vx(t,h.node(),h.before(),c)}l.inlineContent&&gh(t,e+n-1,l,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(c),f=u.map(e-n);if(t.step(new fn(f,u.map(e+n,-1),Se.empty,!0)),r===!0){let h=t.doc.resolve(f);bx(t,h.node(),h.before(),t.steps.length)}return t}function pN(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 wx(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 l=r.depth;l>=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(c>0?1:0),f=r.node(l),h=!1;if(i==1)h=f.canReplace(u,u,s);else{let m=f.contentMatchAt(u).findWrapping(s.firstChild.type);h=m&&f.canReplaceWith(u,u,m[0])}if(h)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Uu(t,e,n=e,r=Se.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return kx(s,i,r)?new fn(e,n,r):new hN(s,i,r).fit()}function kx(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class hN{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=le.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=le.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,l=r.depth,c=s.depth;for(;l&&c&&i.childCount==1;)i=i.firstChild.content,l--,c--;let u=new Se(i,l,c);return e>-1?new pn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new fn(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=qf(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let l=s.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:f}=this.frontier[c],h,m=null;if(n==1&&(l?f.matchType(l.type)||(m=f.fillBefore(le.from(l),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&l&&(h=f.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:h};if(i&&f.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=qf(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Se(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=qf(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Se(vl(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Se(vl(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 w=0;w<i.length;w++)this.openFrontierNode(i[w]);let l=this.unplaced,c=r?r.content:l.content,u=l.openStart-e,f=0,h=[],{match:m,type:y}=this.frontier[n];if(s){for(let w=0;w<s.childCount;w++)h.push(s.child(w));m=m.matchFragment(s)}let b=c.size+e-(l.content.size-l.openEnd);for(;f<c.childCount;){let w=c.child(f),k=m.matchType(w.type);if(!k)break;f++,(f>1||u==0||w.content.size)&&(m=k,h.push(Sx(w.mark(y.allowedMarks(w.marks)),f==1?u:0,f==c.childCount?b:-1)))}let v=f==c.childCount;v||(b=-1),this.placed=xl(this.placed,n,le.from(h)),this.frontier[n].match=m,v&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,k=c;w<b;w++){let N=k.lastChild;this.frontier.push({type:N.type,match:N.contentMatchAt(N.childCount)}),k=N.content}this.unplaced=v?e==0?Se.empty:new Se(vl(l.content,e-1,1),e-1,b<0?l.openEnd:e-1):new Se(vl(l.content,e,f),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Jf(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)),l=Jf(e,n,s,r,i);if(l){for(let c=n-1;c>=0;c--){let{match:u,type:f}=this.frontier[c],h=Jf(e,c,f,u,!0);if(!h||h.childCount)continue e}return{depth:n,fit:l,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=xl(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=xl(this.placed,this.depth,le.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(le.empty,!0);n.childCount&&(this.placed=xl(this.placed,this.frontier.length,n))}}function vl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(vl(t.firstChild.content,e-1,n)))}function xl(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(xl(t.lastChild.content,e-1,n)))}function qf(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Sx(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Sx(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(le.empty,!0)))),t.copy(r)}function Jf(t,e,n,r,s){let i=t.node(e),l=s?t.indexAfter(e):t.index(e);if(l==i.childCount&&!n.compatibleContent(i.type))return null;let c=r.fillBefore(i.content,!0,l);return c&&!mN(n,i.content,l)?c:null}function mN(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function gN(t){return t.spec.defining||t.spec.definingForContent}function yN(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(kx(s,i,r))return t.step(new fn(e,n,r));let l=Nx(s,i);l[l.length-1]==0&&l.pop();let c=-(s.depth+1);l.unshift(c);for(let y=s.depth,b=s.pos-1;y>0;y--,b--){let v=s.node(y).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;l.indexOf(y)>-1?c=y:s.before(y)==b&&l.splice(1,0,-y)}let u=l.indexOf(c),f=[],h=r.openStart;for(let y=r.content,b=0;;b++){let v=y.firstChild;if(f.push(v),b==r.openStart)break;y=v.content}for(let y=h-1;y>=0;y--){let b=f[y],v=gN(b.type);if(v&&!b.sameMarkup(s.node(Math.abs(c)-1)))h=y;else if(v||!b.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let b=(y+h+1)%(r.openStart+1),v=f[b];if(v)for(let w=0;w<l.length;w++){let k=l[(w+u)%l.length],N=!0;k<0&&(N=!1,k=-k);let C=s.node(k-1),O=s.index(k-1);if(C.canReplaceWith(O,O,v.type,v.marks))return t.replace(s.before(k),N?i.after(k):n,new Se(Ex(r.content,0,r.openStart,b),b,r.openEnd))}}let m=t.steps.length;for(let y=l.length-1;y>=0&&(t.replace(e,n,r),!(t.steps.length>m));y--){let b=l[y];b<0||(e=s.before(b),n=i.after(b))}}function Ex(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ex(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),l=i.fillBefore(t).append(t);t=l.append(i.matchFragment(l).fillBefore(le.empty,!0))}return t}function bN(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=pN(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Se(le.from(r),0,0))}function vN(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=Nx(r,s);for(let l=0;l<i.length;l++){let c=i[l],u=l==i.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return t.delete(r.start(c),s.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),s.indexAfter(c-1))))return t.delete(r.before(c),s.after(c))}for(let l=1;l<=r.depth&&l<=s.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&s.end(l)-n!=s.depth-l&&r.start(l-1)==s.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),s.index(l-1)))return t.delete(r.before(l),n);t.delete(e,n)}function Nx(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 xo extends jn{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 nn.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 nn.fromReplace(e,this.pos,this.pos+1,new Se(le.from(s),0,n.isLeaf?0:1))}getMap(){return rr.empty}invert(e){return new xo(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 xo(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 xo(n.pos,n.attr,n.value)}}jn.jsonID("attr",xo);class Pl extends jn{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 nn.ok(r)}getMap(){return rr.empty}invert(e){return new Pl(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 Pl(n.attr,n.value)}}jn.jsonID("docAttr",Pl);let So=class extends Error{};So=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};So.prototype=Object.create(Error.prototype);So.prototype.constructor=So;So.prototype.name="TransformError";class bh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new So(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,l,c,u)=>{e=Math.min(e,c),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=Se.empty){let s=Uu(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Se(le.from(r),0,0))}delete(e,n){return this.replace(e,n,Se.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return yN(this,e,n,r),this}replaceRangeWith(e,n,r){return bN(this,e,n,r),this}deleteRange(e,n){return vN(this,e,n),this}lift(e,n){return rN(this,e,n),this}join(e,n=1){return fN(this,e,n),this}wrap(e,n){return oN(this,e,n),this}setBlockType(e,n=e,r,s=null){return lN(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return cN(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new xo(e,n,r)),this}setDocAttribute(e,n){return this.step(new Pl(e,n)),this}addNodeMark(e,n){return this.step(new $s(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 Nt)n.isInSet(r.marks)&&this.step(new Oi(e,n));else{let s=r.marks,i,l=[];for(;i=n.isInSet(s);)l.push(new Oi(e,i)),s=i.removeFromSet(s);for(let c=l.length-1;c>=0;c--)this.step(l[c])}return this}split(e,n=1,r){return uN(this,e,n,r),this}addMark(e,n,r){return eN(this,e,n,r),this}removeMark(e,n,r){return tN(this,e,n,r),this}clearIncompatible(e,n,r){return gh(this,e,n,r),this}}const Yf=Object.create(null);class Ye{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Cx(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=Se.empty){let r=n.content.lastChild,s=null;for(let c=0;c<n.openEnd;c++)s=r,r=r.lastChild;let i=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:f}=l[c],h=e.mapping.slice(i);e.replaceRange(h.map(u.pos),h.map(f.pos),c?Se.empty:n),c==0&&ub(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:l,$to:c}=s[i],u=e.mapping.slice(r),f=u.map(l.pos),h=u.map(c.pos);i?e.deleteRange(f,h):(e.replaceRangeWith(f,h,n),ub(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new $e(e):ho(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 l=n<0?ho(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):ho(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ir(e.node(0))}static atStart(e){return ho(e,e,0,0,1)||new ir(e)}static atEnd(e){return ho(e,e,e.content.size,e.childCount,-1)||new ir(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Yf[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 Yf)throw new RangeError("Duplicate use of selection JSON ID "+e);return Yf[e]=n,n.prototype.jsonID=e,n}getBookmark(){return $e.between(this.$anchor,this.$head).getBookmark()}}Ye.prototype.visible=!0;class Cx{constructor(e,n){this.$from=e,this.$to=n}}let ab=!1;function cb(t){!ab&&!t.parent.inlineContent&&(ab=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class $e extends Ye{constructor(e,n=e){cb(e),cb(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 Ye.near(r);let s=e.resolve(n.map(this.anchor));return new $e(s.parent.inlineContent?s:r,r)}replace(e,n=Se.empty){if(super.replace(e,n),n==Se.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof $e&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hu(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 $e(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=Ye.findFrom(n,r,!0)||Ye.findFrom(n,-r,!0);if(i)n=i.$head;else return Ye.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Ye.findFrom(e,-r,!0)||Ye.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new $e(e,n)}}Ye.jsonID("text",$e);class Hu{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Hu(e.map(this.anchor),e.map(this.head))}resolve(e){return $e.between(e.resolve(this.anchor),e.resolve(this.head))}}class ze extends Ye{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?Ye.near(i):new ze(i)}content(){return new Se(le.from(this.node),0,0)}eq(e){return e instanceof ze&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new vh(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ze(e.resolve(n.anchor))}static create(e,n){return new ze(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ze.prototype.visible=!1;Ye.jsonID("node",ze);class vh{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Hu(r,r):new vh(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ze.isSelectable(r)?new ze(n):Ye.near(n)}}class ir extends Ye{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Se.empty){if(n==Se.empty){e.delete(0,e.doc.content.size);let r=Ye.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ir(e)}map(e){return new ir(e)}eq(e){return e instanceof ir}getBookmark(){return xN}}Ye.jsonID("all",ir);const xN={map(){return this},resolve(t){return new ir(t)}};function ho(t,e,n,r,s,i=!1){if(e.inlineContent)return $e.create(t,n);for(let l=r-(s>0?0:1);s>0?l<e.childCount:l>=0;l+=s){let c=e.child(l);if(c.isAtom){if(!i&&ze.isSelectable(c))return ze.create(t,n-(s<0?c.nodeSize:0))}else{let u=ho(t,c,n+s,s<0?c.childCount:0,s,i);if(u)return u}n+=c.nodeSize*s}return null}function ub(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof fn||s instanceof pn))return;let i=t.mapping.maps[r],l;i.forEach((c,u,f,h)=>{l==null&&(l=h)}),t.setSelection(Ye.near(t.doc.resolve(l),n))}const db=1,ac=2,fb=4;class wN extends bh{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|db)&~ac,this.storedMarks=null,this}get selectionSet(){return(this.updated&db)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ac,this}ensureMarks(e){return Nt.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&ac)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ac,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)||Nt.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 l=this.doc.resolve(n);i=r==n?l.marks():l.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(Ye.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|=fb,this}get scrolledIntoView(){return(this.updated&fb)>0}}function pb(t,e){return!e||!t?t:t.bind(e)}class wl{constructor(e,n,r){this.name=e,this.init=pb(n.init,r),this.apply=pb(n.apply,r)}}const kN=[new wl("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new wl("selection",{init(t,e){return t.selection||Ye.atStart(e.doc)},apply(t){return t.selection}}),new wl("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new wl("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qf{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=kN.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 wl(r.key,r.spec.state,r))})}}class vo{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 l=0;l<this.config.plugins.length;l++){let c=this.config.plugins[l];if(c.spec.appendTransaction){let u=s?s[l].n:0,f=s?s[l].state:this,h=u<n.length&&c.spec.appendTransaction.call(c,u?n.slice(u):n,f,r);if(h&&r.filterTransaction(h,l)){if(h.setMeta("appendedTransaction",e),!s){s=[];for(let m=0;m<this.config.plugins.length;m++)s.push(m<l?{state:r,n:n.length}:{state:this,n:0})}n.push(h),r=r.applyInner(h),i=!0}s&&(s[l]={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 vo(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 wN(this)}static create(e){let n=new Qf(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vo(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 Qf(this.schema,e.plugins),r=n.fields,s=new vo(n);for(let i=0;i<r.length;i++){let l=r[i].name;s[l]=this.hasOwnProperty(l)?this[l]: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 Qf(e.schema,e.plugins),i=new vo(s);return s.fields.forEach(l=>{if(l.name=="doc")i.doc=Mr.fromJSON(e.schema,n.doc);else if(l.name=="selection")i.selection=Ye.fromJSON(i.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],f=u.spec.state;if(u.key==l.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[l.name]=f.fromJSON.call(u,e,n[c],i);return}}i[l.name]=l.init(e,i)}}),i}}function _x(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=_x(s,e,{})),n[r]=s}return n}class bt{constructor(e){this.spec=e,this.props={},e.props&&_x(e.props,this,this.props),this.key=e.key?e.key.key:Tx("plugin")}getState(e){return e[this.key]}}const Xf=Object.create(null);function Tx(t){return t in Xf?t+"$"+ ++Xf[t]:(Xf[t]=0,t+"$")}class Ct{constructor(e="key"){this.key=Tx(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const xh=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Mx(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ax=(t,e,n)=>{let r=Mx(t,n);if(!r)return!1;let s=wh(r);if(!s){let l=r.blockRange(),c=l&&Ao(l);return c==null?!1:(e&&e(t.tr.lift(l,c).scrollIntoView()),!0)}let i=s.nodeBefore;if(zx(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Eo(i,"end")||ze.isSelectable(i)))for(let l=r.depth;;l--){let c=Uu(t.doc,r.before(l),r.after(l),Se.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=t.tr.step(c);u.setSelection(Eo(i,"end")?Ye.findFrom(u.doc.resolve(u.mapping.map(s.pos,-1)),-1):ze.create(u.doc,s.pos-i.nodeSize)),e(u.scrollIntoView())}return!0}if(l==1||r.node(l-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},SN=(t,e,n)=>{let r=Mx(t,n);if(!r)return!1;let s=wh(r);return s?Ox(t,s,e):!1},EN=(t,e,n)=>{let r=Ix(t,n);if(!r)return!1;let s=kh(r);return s?Ox(t,s,e):!1};function Ox(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 h=s.lastChild;if(!h)return!1;s=h}let l=e.nodeAfter,c=l,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let f=Uu(t.doc,i,u,Se.empty);if(!f||f.from!=i||f instanceof fn&&f.slice.size>=u-i)return!1;if(n){let h=t.tr.step(f);h.setSelection($e.create(h.doc,i)),n(h.scrollIntoView())}return!0}function Eo(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 Rx=(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=wh(r)}let l=i&&i.nodeBefore;return!l||!ze.isSelectable(l)?!1:(e&&e(t.tr.setSelection(ze.create(t.doc,i.pos-l.nodeSize)).scrollIntoView()),!0)};function wh(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 Ix(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const jx=(t,e,n)=>{let r=Ix(t,n);if(!r)return!1;let s=kh(r);if(!s)return!1;let i=s.nodeAfter;if(zx(t,s,e,1))return!0;if(r.parent.content.size==0&&(Eo(i,"start")||ze.isSelectable(i))){let l=Uu(t.doc,r.before(),r.after(),Se.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Eo(i,"start")?Ye.findFrom(c.doc.resolve(c.mapping.map(s.pos)),1):ze.create(c.doc,c.mapping.map(s.pos))),e(c.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},Lx=(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=kh(r)}let l=i&&i.nodeAfter;return!l||!ze.isSelectable(l)?!1:(e&&e(t.tr.setSelection(ze.create(t.doc,i.pos)).scrollIntoView()),!0)};function kh(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 NN=(t,e)=>{let n=t.selection,r=n instanceof ze,s;if(r){if(n.node.isTextblock||!Xs(t.doc,n.from))return!1;s=n.from}else if(s=$u(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(ze.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},CN=(t,e)=>{let n=t.selection,r;if(n instanceof ze){if(n.node.isTextblock||!Xs(t.doc,n.to))return!1;r=n.to}else if(r=$u(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},_N=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Ao(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Dx=(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 Sh(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 TN=(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),l=Sh(s.contentMatchAt(i));if(!l||!s.canReplaceWith(i,i,l))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,l.createAndFill());u.setSelection(Ye.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},Px=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof ir||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Sh(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let l=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,c=t.tr.insert(l,i.createAndFill());c.setSelection($e.create(c.doc,l+1)),e(c.scrollIntoView())}return!0},Bx=(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(cs(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Ao(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function MN(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof ze&&e.selection.node.isBlock)return!r.parentOffset||!cs(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],l,c,u=!1,f=!1;for(let b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),f=r.start(b)==r.pos-(r.depth-b),c=Sh(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(u&&c?{type:c}:null),l=b;break}else{if(b==1)return!1;i.unshift(null)}let h=e.tr;(e.selection instanceof $e||e.selection instanceof ir)&&h.deleteSelection();let m=h.mapping.map(r.pos),y=cs(h.doc,m,i.length,i);if(y||(i[0]=c?{type:c}:null,y=cs(h.doc,m,i.length,i)),!y)return!1;if(h.split(m,i.length,i),!u&&f&&r.node(l).type!=c){let b=h.mapping.map(r.before(l)),v=h.doc.resolve(b);c&&r.node(l-1).canReplaceWith(v.index(),v.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(l)),c)}return n&&n(h.scrollIntoView()),!0}}const AN=MN(),ON=(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(ze.create(t.doc,s))),!0)};function RN(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||Xs(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function zx(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,l,c,u=s.type.spec.isolating||i.type.spec.isolating;if(!u&&RN(t,e,n))return!0;let f=!u&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(l=(c=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&c.matchType(l[0]||i.type).validEnd){if(n){let b=e.pos+i.nodeSize,v=le.empty;for(let N=l.length-1;N>=0;N--)v=le.from(l[N].create(null,v));v=le.from(s.copy(v));let w=t.tr.step(new pn(e.pos-1,b,e.pos,b,new Se(v,1,0),l.length,!0)),k=w.doc.resolve(b+2*l.length);k.nodeAfter&&k.nodeAfter.type==s.type&&Xs(w.doc,k.pos)&&w.join(k.pos),n(w.scrollIntoView())}return!0}let h=i.type.spec.isolating||r>0&&u?null:Ye.findFrom(e,1),m=h&&h.$from.blockRange(h.$to),y=m&&Ao(m);if(y!=null&&y>=e.depth)return n&&n(t.tr.lift(m,y).scrollIntoView()),!0;if(f&&Eo(i,"start",!0)&&Eo(s,"end")){let b=s,v=[];for(;v.push(b),!b.isTextblock;)b=b.lastChild;let w=i,k=1;for(;!w.isTextblock;w=w.firstChild)k++;if(b.canReplace(b.childCount,b.childCount,w.content)){if(n){let N=le.empty;for(let O=v.length-1;O>=0;O--)N=le.from(v[O].copy(N));let C=t.tr.step(new pn(e.pos-v.length,e.pos+i.nodeSize,e.pos+k,e.pos+i.nodeSize-k,new Se(N,v.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function Fx(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($e.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const IN=Fx(-1),jN=Fx(1);function LN(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,l=s.blockRange(i),c=l&&yh(l,t,e);return c?(r&&r(n.tr.wrap(l,c).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:l},$to:{pos:c}}=n.selection.ranges[i];n.doc.nodesBetween(l,c,(u,f)=>{if(s)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)s=!0;else{let h=n.doc.resolve(f),m=h.index();s=h.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let l=0;l<n.selection.ranges.length;l++){let{$from:{pos:c},$to:{pos:u}}=n.selection.ranges[l];i.setBlockType(c,u,t,e)}r(i.scrollIntoView())}return!0}}function Eh(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Eh(xh,Ax,Rx);Eh(xh,jx,Lx);Eh(Dx,Px,Bx,AN);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function DN(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,l=s.blockRange(i);if(!l)return!1;let c=r?n.tr:null;return PN(c,l,t,e)?(r&&r(c.scrollIntoView()),!0):!1}}function PN(t,e,n,r=null){let s=!1,i=e,l=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=l.resolve(e.start-2);i=new Vc(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new Vc(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let c=yh(i,n,r,e);return c?(t&&BN(t,e,c,s,n),!0):!1}function BN(t,e,n,r,s){let i=le.empty;for(let h=n.length-1;h>=0;h--)i=le.from(n[h].type.create(n[h].attrs,i));t.step(new pn(e.start-(r?2:0),e.end,e.start,e.end,new Se(i,0,0),n.length,!0));let l=0;for(let h=0;h<n.length;h++)n[h].type==s&&(l=h+1);let c=n.length-l,u=e.start+n.length-(r?2:0),f=e.parent;for(let h=e.startIndex,m=e.endIndex,y=!0;h<m;h++,y=!1)!y&&cs(t.doc,u,c)&&(t.split(u,c),u+=2*c),u+=f.child(h).nodeSize;return t}function zN(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,l=>l.childCount>0&&l.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?FN(e,n,t,i):$N(e,n,i):!0:!1}}function FN(t,e,n,r){let s=t.tr,i=r.end,l=r.$to.end(r.depth);i<l&&(s.step(new pn(i-1,l,i,l,new Se(le.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Vc(s.doc.resolve(r.$from.pos),s.doc.resolve(l),r.depth));const c=Ao(r);if(c==null)return!1;s.lift(r,c);let u=s.doc.resolve(s.mapping.map(i,-1)-1);return Xs(s.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&s.join(u.pos),e(s.scrollIntoView()),!0}function $N(t,e,n){let r=t.tr,s=n.parent;for(let b=n.end,v=n.endIndex-1,w=n.startIndex;v>w;v--)b-=s.child(v).nodeSize,r.delete(b-1,b+1);let i=r.doc.resolve(n.start),l=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==s.childCount,f=i.node(-1),h=i.index(-1);if(!f.canReplace(h+(c?0:1),h+1,l.content.append(u?le.empty:le.from(s))))return!1;let m=i.pos,y=m+l.nodeSize;return r.step(new pn(m-(c?1:0),y+(u?1:0),m+1,y-1,new Se((c?le.empty:le.from(s.copy(le.empty))).append(u?le.empty:le.from(s.copy(le.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function UN(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 l=i.startIndex;if(l==0)return!1;let c=i.parent,u=c.child(l-1);if(u.type!=t)return!1;if(n){let f=u.lastChild&&u.lastChild.type==c.type,h=le.from(f?t.create():null),m=new Se(le.from(t.create(null,le.from(c.type.create(null,h)))),f?3:1,0),y=i.start,b=i.end;n(e.tr.step(new pn(y-(f?3:1),b,y,b,m,1,!0)).scrollIntoView())}return!0}}const En=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},No=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Lp=null;const ls=function(t,e,n){let r=Lp||(Lp=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},HN=function(){Lp=null},Ri=function(t,e,n,r){return n&&(mb(t,e,n,r,-1)||mb(t,e,n,r,1))},WN=/^(img|br|input|textarea|hr)$/i;function mb(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:gr(t))){let l=t.parentNode;if(!l||l.nodeType!=1||Gl(t)||WN.test(t.nodeName)||t.contentEditable=="false")return!1;e=En(t)+(s<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[e+(s<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((i=l.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=l,e=s<0?gr(t):0}else return!1}}function gr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function VN(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=gr(t)}else if(t.parentNode&&!Gl(t))e=En(t),t=t.parentNode;else return null}}function KN(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&&!Gl(t))e=En(t)+1,t=t.parentNode;else return null}}function GN(t,e,n){for(let r=e==0,s=e==gr(t);r||s;){if(t==n)return!0;let i=En(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==gr(t)}}function Gl(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 Wu=function(t){return t.focusNode&&Ri(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function xi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function qN(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function JN(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(gr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(gr(r.startContainer),r.startOffset)}}}const Hr=typeof navigator<"u"?navigator:null,gb=typeof document<"u"?document:null,Zs=Hr&&Hr.userAgent||"",Dp=/Edge\/(\d+)/.exec(Zs),$x=/MSIE \d/.exec(Zs),Pp=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zs),Yn=!!($x||Pp||Dp),Vs=$x?document.documentMode:Pp?+Pp[1]:Dp?+Dp[1]:0,yr=!Yn&&/gecko\/(\d+)/i.test(Zs);yr&&+(/Firefox\/(\d+)/.exec(Zs)||[0,0])[1];const Bp=!Yn&&/Chrome\/(\d+)/.exec(Zs),Cn=!!Bp,Ux=Bp?+Bp[1]:0,Rn=!Yn&&!!Hr&&/Apple Computer/.test(Hr.vendor),Co=Rn&&(/Mobile\/\w+/.test(Zs)||!!Hr&&Hr.maxTouchPoints>2),mr=Co||(Hr?/Mac/.test(Hr.platform):!1),Hx=Hr?/Win/.test(Hr.platform):!1,as=/Android \d/.test(Zs),ql=!!gb&&"webkitFontSmoothing"in gb.documentElement.style,YN=ql?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function QN(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 ts(t,e){return typeof t=="number"?t:t[e]}function XN(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 yb(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let l=n||t.dom;l;){if(l.nodeType!=1){l=No(l);continue}let c=l,u=c==i.body,f=u?QN(i):XN(c),h=0,m=0;if(e.top<f.top+ts(r,"top")?m=-(f.top-e.top+ts(s,"top")):e.bottom>f.bottom-ts(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+ts(s,"top")-f.top:e.bottom-f.bottom+ts(s,"bottom")),e.left<f.left+ts(r,"left")?h=-(f.left-e.left+ts(s,"left")):e.right>f.right-ts(r,"right")&&(h=e.right-f.right+ts(s,"right")),h||m)if(u)i.defaultView.scrollBy(h,m);else{let b=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),h&&(c.scrollLeft+=h);let w=c.scrollLeft-b,k=c.scrollTop-v;e={left:e.left-w,top:e.top-k,right:e.right-w,bottom:e.bottom-k}}let y=u?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:No(l)}}function ZN(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,l=n+1;l<Math.min(innerHeight,e.bottom);l+=5){let c=t.root.elementFromPoint(i,l);if(!c||c==t.dom||!t.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=n-20){r=c,s=u.top;break}}return{refDOM:r,refTop:s,stack:Wx(t.dom)}}function Wx(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=No(r));return e}function eC({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Vx(n,r==0?0:r-e)}function Vx(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 uo=null;function tC(t){if(t.setActive)return t.setActive();if(uo)return t.focus(uo);let e=Wx(t);t.focus(uo==null?{get preventScroll(){return uo={preventScroll:!0},!0}}:void 0),uo||(uo=!1,Vx(e,0))}function Kx(t,e){let n,r=2e8,s,i=0,l=e.top,c=e.top,u,f;for(let h=t.firstChild,m=0;h;h=h.nextSibling,m++){let y;if(h.nodeType==1)y=h.getClientRects();else if(h.nodeType==3)y=ls(h).getClientRects();else continue;for(let b=0;b<y.length;b++){let v=y[b];if(v.top<=l&&v.bottom>=c){l=Math.max(v.bottom,l),c=Math.min(v.top,c);let w=v.left>e.left?v.left-e.left:v.right<e.left?e.left-v.right:0;if(w<r){n=h,r=w,s=w&&n.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,h.nodeType==1&&w&&(i=m+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!u&&v.left<=e.left&&v.right>=e.left&&(u=h,f={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(i=m+1)}}return!n&&u&&(n=u,s=f,r=0),n&&n.nodeType==3?nC(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:Kx(n,s)}function nC(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 l=Is(r,1);if(l.top!=l.bottom&&Nh(e,l)){s={node:t,offset:i+(e.left>=(l.left+l.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Nh(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function rC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function sC(t,e,n){let{node:r,offset:s}=Kx(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let l=r.getBoundingClientRect();i=l.left!=l.right&&n.left>(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function iC(t,e,n,r){let s=-1;for(let i=e,l=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!l&&u.left>r.left||u.top>r.top?s=c.posBefore:(!l&&u.right<r.left||u.bottom<r.top)&&(s=c.posAfter),l=!0),!c.contentDOM&&s<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;i=c.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function Gx(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 l=t.childNodes[i];if(l.nodeType==1){let c=l.getClientRects();for(let u=0;u<c.length;u++){let f=c[u];if(Nh(e,f))return Gx(l,e,f)}}if((i=(i+1)%r)==s)break}return t}function oC(t,e){let n=t.dom.ownerDocument,r,s=0,i=JN(n,e.left,e.top);i&&({node:r,offset:s}=i);let l=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),c;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let f=t.dom.getBoundingClientRect();if(!Nh(e,f)||(l=Gx(t.dom,e,f),!l))return null}if(Rn)for(let f=l;r&&f;f=No(f))f.draggable&&(r=void 0);if(l=rC(l,e),r){if(yr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let h=r.childNodes[s],m;h.nodeName=="IMG"&&(m=h.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let f;ql&&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?c=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(c=iC(t,r,s,e))}c==null&&(c=sC(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function bb(t){return t.top<t.bottom||t.left<t.right}function Is(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(bb(r))return r}return Array.prototype.find.call(n,bb)||t.getBoundingClientRect()}const lC=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function qx(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),l=ql||yr;if(r.nodeType==3)if(l&&(lC.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let u=Is(ls(r,s,s),n);if(yr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=Is(ls(r,s-1,s-1),-1);if(f.top==u.top){let h=Is(ls(r,s,s+1),-1);if(h.top!=u.top)return hl(h,h.left<f.left)}}return u}else{let u=s,f=s,h=n<0?1:-1;return n<0&&!s?(f++,h=-1):n>=0&&s==r.nodeValue.length?(u--,h=1):n<0?u--:f++,hl(Is(ls(r,u,f),h),h<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==gr(r))){let u=r.childNodes[s-1];if(u.nodeType==1)return Zf(u.getBoundingClientRect(),!1)}if(i==null&&s<gr(r)){let u=r.childNodes[s];if(u.nodeType==1)return Zf(u.getBoundingClientRect(),!0)}return Zf(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==gr(r))){let u=r.childNodes[s-1],f=u.nodeType==3?ls(u,gr(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(f)return hl(Is(f,1),!1)}if(i==null&&s<gr(r)){let u=r.childNodes[s];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let f=u?u.nodeType==3?ls(u,0,l?0:1):u.nodeType==1?u:null:null;if(f)return hl(Is(f,-1),!0)}return hl(Is(r.nodeType==3?ls(r):r,-n),n>=0)}function hl(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 Zf(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 Jx(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 aC(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Jx(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let l=qx(t,s.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=ls(c,0,c.nodeValue.length).getClientRects();else continue;for(let f=0;f<u.length;f++){let h=u[f];if(h.bottom>h.top+1&&(n=="up"?l.top-h.top>(h.bottom-l.top)*2:h.bottom-l.bottom>(l.bottom-h.top)*2))return!1}}return!0})}const cC=/[\u0590-\u08ac]/;function uC(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,l=s==r.parent.content.size,c=t.domSelection();return c?!cC.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:l:Jx(t,e,()=>{let{focusNode:u,focusOffset:f,anchorNode:h,anchorOffset:m}=t.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:v,focusOffset:w}=t.domSelectionRange(),k=v&&!b.contains(v.nodeType==1?v:v.parentNode)||u==v&&f==w;try{c.collapse(h,m),u&&(u!=h||f!=m)&&c.extend&&c.extend(u,f)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let vb=null,xb=null,wb=!1;function dC(t,e,n){return vb==e&&xb==n?wb:(vb=e,xb=n,wb=n=="up"||n=="down"?aC(t,e,n):uC(t,e,n))}const br=0,kb=1,wi=2,Wr=3;class Jl{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=br,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,l;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((l=i.pmViewDesc)&&l.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(l)+l.size:this.posAtStart}else{let i,l;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((l=i.pmViewDesc)&&l.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(l):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>En(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),l;if(i&&(!n||i.node))if(r&&(l=i.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==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 l=0;l<s.children.length;l++){let c=s.children[l];if(c.size){s=c;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 l=this.children[r],c=i+l.size;if(c>e||l instanceof Qx){s=e-i;break}i=c}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 Yx&&i.side>=0;r--);if(n<=0){let i,l=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,l=!1);return i&&n&&l&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?En(i.dom)+1:0}}else{let i,l=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,l=!1);return i&&l&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?En(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 l=r,c=0;;c++){let u=this.children[c],f=l+u.size;if(s==-1&&e<=f){let h=l+u.border;if(e>=h&&n<=f-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,h);e=l;for(let m=c;m>0;m--){let y=this.children[m-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){s=En(y.dom)+1;break}e-=y.size}s==-1&&(s=0)}if(s>-1&&(f>n||c==this.children.length-1)){n=f;for(let h=c+1;h<this.children.length;h++){let m=this.children[h];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=En(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}l=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),l=Math.max(e,n);for(let b=0,v=0;b<this.children.length;b++){let w=this.children[b],k=v+w.size;if(i>v&&l<k)return w.setSelection(e-v-w.border,n-v-w.border,r,s);v=k}let c=this.domFromPos(e,e?-1:1),u=n==e?c:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),h=r.domSelectionRange(),m=!1;if((yr||Rn)&&e==n){let{node:b,offset:v}=c;if(b.nodeType==3){if(m=!!(v&&b.nodeValue[v-1]==`
|
|
54
|
+
`),m&&v==b.nodeValue.length)for(let w=b,k;w;w=w.parentNode){if(k=w.nextSibling){k.nodeName=="BR"&&(c=u={node:k.parentNode,offset:En(k)+1});break}let N=w.pmViewDesc;if(N&&N.node&&N.node.isBlock)break}}else{let w=b.childNodes[v-1];m=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(yr&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let b=h.focusNode.childNodes[h.focusOffset];b&&b.contentEditable=="false"&&(s=!0)}if(!(s||m&&Rn)&&Ri(c.node,c.offset,h.anchorNode,h.anchorOffset)&&Ri(u.node,u.offset,h.focusNode,h.focusOffset))return;let y=!1;if((f.extend||e==n)&&!(m&&yr)){f.collapse(c.node,c.offset);try{e!=n&&f.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>n){let v=c;c=u,u=v}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(b)}}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],l=r+i.size;if(r==l?e<=l&&n>=r:e<l&&n>r){let c=r+i.border,u=l-i.border;if(e>=c&&n<=u){this.dirty=e==r||n==l?wi:kb,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Wr:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?wi:Wr}r=l}this.dirty=wi}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?wi:kb;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Yx extends Jl{constructor(e,n,r,s){let i,l=n.type.toDOM;if(typeof l=="function"&&(l=l(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(l.nodeType!=1){let c=document.createElement("span");c.appendChild(l),l=c}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==br&&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 fC extends Jl{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 Ii extends Jl{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],l=i&&i(n,s,r);return(!l||!l.dom)&&(l=Pi.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ii(e,n,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&Wr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Wr&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=br){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=br}}slice(e,n,r){let s=Ii.create(this.parent,this.mark,!0,r),i=this.children,l=this.size;n<l&&(i=Fp(i,n,l,r)),e>0&&(i=Fp(i,0,e,r));for(let c=0;c<i.length;c++)i[c].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 Ks extends Jl{constructor(e,n,r,s,i,l,c,u,f){super(e,[],i,l),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=c}static create(e,n,r,s,i,l){let c=i.nodeViews[n.type.name],u,f=c&&c(n,i,()=>{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,s),h=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=Pi.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let y=h;return h=ew(h,r,n),f?u=new pC(e,n,r,s,h,m||null,y,f,i,l+1):n.isText?new Vu(e,n,r,s,h,y,i):new Ks(e,n,r,s,h,m||null,y,i,l+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=()=>le.empty)}return e}matchesNode(e,n,r){return this.dirty==br&&e.eq(this.node)&&Gc(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,l=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new mC(this,l&&l.node,e);bC(this.node,this.innerDeco,(f,h,m)=>{f.spec.marks?u.syncToMarks(f.spec.marks,r,e,h):f.type.side>=0&&!m&&u.syncToMarks(h==this.node.childCount?Nt.none:this.node.child(h).marks,r,e,h),u.placeWidget(f,e,s)},(f,h,m,y)=>{u.syncToMarks(f.marks,r,e,y);let b;u.findNodeMatch(f,h,m,y)||c&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(b=u.findIndexWithChild(i.node))>-1&&u.updateNodeAt(f,h,m,b,e)||u.updateNextNode(f,h,m,e,y,s)||u.addNode(f,h,m,e,s),s+=f.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==wi)&&(l&&this.protectLocalComposition(e,l),Xx(this.contentDOM,this.children,e),Co&&vC(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof $e)||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 l=i.nodeValue,c=xC(this.node.content,l,r-n,s-n);return c<0?null:{node:i,pos:c,text:l}}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 l=new fC(this,i,n,s);e.input.compositionNodes.push(l),this.children=Fp(this.children,r,r+s.length,e,l)}update(e,n,r,s){return this.dirty==Wr||!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=br}updateOuterDeco(e){if(Gc(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Zx(this.dom,this.nodeDOM,zp(this.outerDeco,this.node,n),zp(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 Sb(t,e,n,r,s){ew(r,e,t);let i=new Ks(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Vu extends Ks{constructor(e,n,r,s,i,l,c){super(e,n,r,s,i,null,l,c,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==Wr||this.dirty!=br&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=br||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=br,!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 Vu(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=Wr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Qx extends Jl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==br&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class pC extends Ks{constructor(e,n,r,s,i,l,c,u,f,h){super(e,n,r,s,i,l,c,f,h),this.spec=u}update(e,n,r,s){if(this.dirty==Wr)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 Xx(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let l=e[i],c=l.dom;if(c.parentNode==t){for(;c!=r;)r=Eb(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(c,r);if(l instanceof Ii){let u=r?r.previousSibling:t.lastChild;Xx(l.contentDOM,l.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=Eb(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Cl=function(t){t&&(this.nodeName=t)};Cl.prototype=Object.create(null);const ki=[new Cl];function zp(t,e,n){if(t.length==0)return ki;let r=n?ki[0]:new Cl,s=[r];for(let i=0;i<t.length;i++){let l=t[i].type.attrs;if(l){l.nodeName&&s.push(r=new Cl(l.nodeName));for(let c in l){let u=l[c];u!=null&&(n&&s.length==1&&s.push(r=new Cl(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return s}function Zx(t,e,n,r){if(n==ki&&r==ki)return e;let s=e;for(let i=0;i<r.length;i++){let l=r[i],c=n[i];if(i){let u;c&&c.nodeName==l.nodeName&&s!=t&&(u=s.parentNode)&&u.nodeName.toLowerCase()==l.nodeName||(u=document.createElement(l.nodeName),u.pmIsDeco=!0,u.appendChild(s),c=ki[0]),s=u}hC(s,c||ki[0],l)}return s}function hC(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 ew(t,e,n){return Zx(t,t,ki,zp(e,n,t.nodeType!=1))}function Gc(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 Eb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class mC{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gC(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,l=this.stack.length>>1,c=Math.min(l,e.length);for(;i<c&&(i==l-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<l;)this.destroyRest(),this.top.dirty=br,this.index=this.stack.pop(),this.top=this.stack.pop(),l--;for(;l<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 h=this.index;h<f;h++){let m=this.top.children[h];if(m.matchesMark(e[l])&&!this.isLocked(m.dom)){u=h;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let h=Ii.create(this.top,e[l],n,r);this.top.children.splice(this.index,0,h),this.top=h,this.changed=!0}this.index=0,l++}}findNodeMatch(e,n,r,s){let i=-1,l;if(s>=this.preMatch.index&&(l=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,r))i=this.top.children.indexOf(l,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let f=this.top.children[c];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){i=c;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let l=this.top.children[s];return l.dirty==Wr&&l.dom==l.contentDOM&&(l.dirty=wi),l.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,l){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof Ks){let f=this.preMatch.matched.get(u);if(f!=null&&f!=i)return!1;let h=u.dom,m,y=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Wr&&Gc(n,u.outerDeco));if(!y&&u.update(e,n,r,s))return this.destroyBetween(this.index,c),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!y&&(m=this.recreateWrapper(u,e,n,r,s,l)))return this.destroyBetween(this.index,c),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=wi,m.updateChildren(s,l+1),m.dirty=br),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,l){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Gc(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let c=Ks.create(this.top,n,r,s,i,l);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,n,r,s,i){let l=Ks.create(this.top,e,n,r,s,i);l.contentDOM&&l.updateChildren(s,i+1),this.top.children.splice(this.index++,0,l),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 Yx(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 Ii;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Vu)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Rn||Cn)&&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 Qx(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 gC(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,l=[];e:for(;s>0;){let c;for(;;)if(r){let f=n.children[r-1];if(f instanceof Ii)n=f,r=f.children.length;else{c=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(s-1))break;--s,i.set(c,s),l.push(c)}}return{index:s,matched:i,matches:l.reverse()}}function yC(t,e){return t.type.side-e.type.side}function bC(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let f=0;f<t.childCount;f++){let h=t.child(f);r(h,s,e.forChild(i,h),f),i+=h.nodeSize}return}let l=0,c=[],u=null;for(let f=0;;){let h,m;for(;l<s.length&&s[l].to==i;){let k=s[l++];k.widget&&(h?(m||(m=[h])).push(k):h=k)}if(h)if(m){m.sort(yC);for(let k=0;k<m.length;k++)n(m[k],f,!!u)}else n(h,f,!!u);let y,b;if(u)b=-1,y=u,u=null;else if(f<t.childCount)b=f,y=t.child(f++);else break;for(let k=0;k<c.length;k++)c[k].to<=i&&c.splice(k--,1);for(;l<s.length&&s[l].from<=i&&s[l].to>i;)c.push(s[l++]);let v=i+y.nodeSize;if(y.isText){let k=v;l<s.length&&s[l].from<k&&(k=s[l].from);for(let N=0;N<c.length;N++)c[N].to<k&&(k=c[N].to);k<v&&(u=y.cut(k-i),y=y.cut(0,k-i),v=k,b=-1)}else for(;l<s.length&&s[l].to<v;)l++;let w=y.isInline&&!y.isLeaf?c.filter(k=>!k.inline):c.slice();r(y,w,e.forChild(i,y),b),i=v}}function vC(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 xC(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let l=t.child(s++),c=i;if(i+=l.nodeSize,!l.isText)continue;let u=l.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-c,r-c)==e)return r-e.length;let f=c<r?u.lastIndexOf(e,r-c-1):-1;if(f>=0&&f+e.length+c>=n)return c+f;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Fp(t,e,n,r,s){let i=[];for(let l=0,c=0;l<t.length;l++){let u=t[l],f=c,h=c+=u.size;f>=n||h<=e?i.push(u):(f<e&&i.push(u.slice(0,e-f,r)),s&&(i.push(s),s=void 0),h>n&&i.push(u.slice(n-f,u.size,r)))}return i}function Ch(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,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let c=r.resolve(l),u,f;if(Wu(n)){for(u=l;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&ze.isSelectable(m)&&s.parent&&!(m.isInline&&GN(n.focusNode,n.focusOffset,s.dom))){let y=s.posBefore;f=new ze(l==y?c:r.resolve(y))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=l,y=l;for(let b=0;b<n.rangeCount;b++){let v=n.getRangeAt(b);m=Math.min(m,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),y=Math.max(y,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(m<0)return null;[u,l]=y==t.state.selection.anchor?[y,m]:[m,y],c=r.resolve(l)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!f){let m=e=="pointer"||t.state.selection.head<c.pos&&!i?1:-1;f=_h(t,h,c,m)}return f}function tw(t){return t.editable?t.hasFocus():rw(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function us(t,e=!1){let n=t.state.selection;if(nw(t,n),!!tw(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Cn){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ri(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)kC(t);else{let{anchor:r,head:s}=n,i,l;Nb&&!(n instanceof $e)&&(n.$from.parent.inlineContent||(i=Cb(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Cb(t,n.to))),t.docView.setSelection(r,s,t,e),Nb&&(i&&_b(i),l&&_b(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wC(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Nb=Rn||Cn&&Ux<63;function Cb(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(Rn&&s&&s.contentEditable=="false")return ep(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return ep(s);if(i)return ep(i)}}function ep(t){return t.contentEditable="true",Rn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function _b(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function wC(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(()=>{(!tw(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function kC(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,En(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Yn&&Vs<=11&&(n.disabled=!0,n.disabled=!1)}function nw(t,e){if(e instanceof ze){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Tb(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Tb(t)}function Tb(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function _h(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||$e.between(e,n,r)}function Mb(t){return t.editable&&!t.hasFocus()?!1:rw(t)}function rw(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 SC(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ri(e.node,e.offset,n.anchorNode,n.anchorOffset)}function $p(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&&Ye.findFrom(i,e)}function js(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ab(t,e,n){let r=t.state.selection;if(r instanceof $e)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 l=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return js(t,new $e(r.$anchor,l))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=$p(t.state,e);return s&&s instanceof ze?js(t,s):!1}else if(!(mr&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,l;if(!i||i.isText)return!1;let c=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(l=t.docView.descAt(c))&&!l.contentDOM?ze.isSelectable(i)?js(t,new ze(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):ql?js(t,new $e(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ze&&r.node.isInline)return js(t,new $e(e>0?r.$to:r.$from));{let s=$p(t.state,e);return s?js(t,s):!1}}}function qc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _l(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function fo(t,e){return e<0?EC(t):NC(t)}function EC(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,l=!1;for(yr&&n.nodeType==1&&r<qc(n)&&_l(n.childNodes[r],-1)&&(l=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(_l(c,-1))s=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(sw(n))break;{let c=n.previousSibling;for(;c&&_l(c,-1);)s=n.parentNode,i=En(c),c=c.previousSibling;if(c)n=c,r=qc(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?Up(t,n,r):s&&Up(t,s,i)}function NC(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=qc(n),i,l;for(;;)if(r<s){if(n.nodeType!=1)break;let c=n.childNodes[r];if(_l(c,1))i=n,l=++r;else break}else{if(sw(n))break;{let c=n.nextSibling;for(;c&&_l(c,1);)i=c.parentNode,l=En(c)+1,c=c.nextSibling;if(c)n=c,r=0,s=qc(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Up(t,i,l)}function sw(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function CC(t,e){for(;t&&e==t.childNodes.length&&!Gl(t);)e=En(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 _C(t,e){for(;t&&!e&&!Gl(t);)e=En(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 Up(t,e,n){if(e.nodeType!=3){let i,l;(l=CC(e,n))?(e=l,n=0):(i=_C(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Wu(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&&us(t)},50)}function Ob(t,e){let n=t.state.doc.resolve(e);if(!(Cn||Hx)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),l=(i.top+i.bottom)/2;if(l>s.top&&l<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),l=(i.top+i.bottom)/2;if(l>s.top&&l<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 Rb(t,e,n){let r=t.state.selection;if(r instanceof $e&&!r.empty||n.indexOf("s")>-1||mr&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=$p(t.state,e);if(l&&l instanceof ze)return js(t,l)}if(!s.parent.inlineContent){let l=e<0?s:i,c=r instanceof ir?Ye.near(l,e):Ye.findFrom(l,e);return c?js(t,c):!1}return!1}function Ib(t,e){if(!(t.state.selection instanceof $e))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 l=t.state.tr;return e<0?l.delete(n.pos-i.nodeSize,n.pos):l.delete(n.pos,n.pos+i.nodeSize),t.dispatch(l),!0}return!1}function jb(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function TC(t){if(!Rn||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;jb(t,r,"true"),setTimeout(()=>jb(t,r,"false"),20)}return!1}function MC(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function AC(t,e){let n=e.keyCode,r=MC(e);if(n==8||mr&&n==72&&r=="c")return Ib(t,-1)||fo(t,-1);if(n==46&&!e.shiftKey||mr&&n==68&&r=="c")return Ib(t,1)||fo(t,1);if(n==13||n==27)return!0;if(n==37||mr&&n==66&&r=="c"){let s=n==37?Ob(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ab(t,s,r)||fo(t,s)}else if(n==39||mr&&n==70&&r=="c"){let s=n==39?Ob(t,t.state.selection.from)=="ltr"?1:-1:1;return Ab(t,s,r)||fo(t,s)}else{if(n==38||mr&&n==80&&r=="c")return Rb(t,-1,r)||fo(t,-1);if(n==40||mr&&n==78&&r=="c")return TC(t)||Rb(t,1,r)||fo(t,1);if(r==(mr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Th(t,e){t.someProp("transformCopied",b=>{e=b(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 b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let l=t.someProp("clipboardSerializer")||Pi.fromSchema(t.state.schema),c=uw(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));let f=u.firstChild,h,m=0;for(;f&&f.nodeType==1&&(h=cw[f.nodeName.toLowerCase()]);){for(let b=h.length-1;b>=0;b--){let v=c.createElement(h[b]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),m++}f=u.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${s} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let y=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
|
|
55
|
+
|
|
56
|
+
`);return{dom:u,text:y,slice:e}}function iw(t,e,n,r,s){let i=s.parent.type.spec.code,l,c;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",y=>{e=y(e,i||r,t)}),i)return c=new Se(le.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
57
|
+
`))),0,0),t.someProp("transformPasted",y=>{c=y(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",y=>y(e,s,r,t));if(m)c=m;else{let y=s.marks(),{schema:b}=t.state,v=Pi.fromSchema(b);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let k=l.appendChild(document.createElement("p"));w&&k.appendChild(v.serializeNode(b.text(w,y)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),l=jC(n),ql&&LC(l);let f=l&&l.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||Ws.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||h),context:s,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!OC.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)c=DC(Lb(c,+h[1],+h[2]),h[4]);else if(c=Se.maxOpen(RC(c.content,s),!0),c.openStart||c.openEnd){let m=0,y=0;for(let b=c.content.firstChild;m<c.openStart&&!b.type.spec.isolating;m++,b=b.firstChild);for(let b=c.content.lastChild;y<c.openEnd&&!b.type.spec.isolating;y++,b=b.lastChild);c=Lb(c,m,y)}return t.someProp("transformPasted",m=>{c=m(c,t,u)}),c}const OC=/^(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 RC(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,l=[];if(t.forEach(c=>{if(!l)return;let u=s.findWrapping(c.type),f;if(!u)return l=null;if(f=l.length&&i.length&&lw(u,i,c,l[l.length-1],0))l[l.length-1]=f;else{l.length&&(l[l.length-1]=aw(l[l.length-1],i.length));let h=ow(c,u);l.push(h),s=s.matchType(h.type),i=u}}),l)return le.from(l)}return t}function ow(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,le.from(t));return t}function lw(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=lw(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(le.from(ow(n,t,s+1))))}}function aw(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,aw(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(le.empty,!0);return t.copy(n.append(r))}function Hp(t,e,n,r,s,i){let l=e<0?t.firstChild:t.lastChild,c=l.content;return t.childCount>1&&(i=0),s<r-1&&(c=Hp(c,e,n,r,s+1,i)),s>=n&&(c=e<0?l.contentMatchAt(0).fillBefore(c,i<=s).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(le.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(c))}function Lb(t,e,n){return e<t.openStart&&(t=new Se(Hp(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Se(Hp(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const cw={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 Db=null;function uw(){return Db||(Db=document.implementation.createHTMLDocument("title"))}let tp=null;function IC(t){let e=window.trustedTypes;return e?(tp||(tp=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),tp.createHTML(t)):t}function jC(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=uw().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&cw[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=IC(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function LC(t){let e=t.querySelectorAll(Cn?"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 DC(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:l}=t;for(let c=r.length-2;c>=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;s=le.from(u.create(r[c+1],s)),i++,l++}return new Se(s,i,l)}const Fn={},$n={},PC={touchstart:!0,touchmove:!0};class BC{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 zC(t){for(let e in Fn){let n=Fn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{$C(t,r)&&!Mh(t,r)&&(t.editable||!(r.type in $n))&&n(t,r)},PC[e]?{passive:!0}:void 0)}Rn&&t.dom.addEventListener("input",()=>null),Wp(t)}function Us(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function FC(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 Wp(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Mh(t,r))})}function Mh(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function $C(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 UC(t,e){!Mh(t,e)&&Fn[e.type]&&(t.editable||!(e.type in $n))&&Fn[e.type](t,e)}$n.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!fw(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(as&&Cn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Co&&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,xi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||AC(t,n)?n.preventDefault():Us(t,"key")};$n.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};$n.keypress=(t,e)=>{let n=e;if(fw(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||mr&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof $e)||!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",l=>l(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function Ku(t){return{left:t.clientX,top:t.clientY}}function HC(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ah(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let l=i.depth+1;l>0;l--)if(t.someProp(e,c=>l>i.depth?c(t,n,i.nodeAfter,i.before(l),s,!0):c(t,n,i.node(l),i.before(l),s,!1)))return!0;return!1}function wo(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 WC(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ze.isSelectable(r)?(wo(t,new ze(n)),!0):!1}function VC(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof ze&&(r=n.node);let i=t.state.doc.resolve(e);for(let l=i.depth+1;l>0;l--){let c=l>i.depth?i.nodeAfter:i.node(l);if(ze.isSelectable(c)){r&&n.$from.depth>0&&l>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(l);break}}return s!=null?(wo(t,ze.create(t.state.doc,s)),!0):!1}function KC(t,e,n,r,s){return Ah(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?VC(t,n):WC(t,n))}function GC(t,e,n,r){return Ah(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function qC(t,e,n,r){return Ah(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||JC(t,n,r)}function JC(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(wo(t,$e.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i),c=s.before(i);if(l.inlineContent)wo(t,$e.create(r,c+1,c+1+l.content.size));else if(ze.isSelectable(l))wo(t,ze.create(r,c));else continue;return!0}}function Oh(t){return Jc(t)}const dw=mr?"metaKey":"ctrlKey";Fn.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Oh(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&HC(n,t.input.lastClick)&&!n[dw]&&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 l=t.posAtCoords(Ku(n));l&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new YC(t,l,n,!!r)):(i=="doubleClick"?GC:qC)(t,l.pos,l.inside,n)?n.preventDefault():Us(t,"pointer"))};class YC{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[dw],this.allowDefault=r.shiftKey;let i,l;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),l=n.inside;else{let h=e.state.doc.resolve(n.pos);i=h.parent,l=h.depth?h.before():0}const c=s?null:r.target,u=c?e.docView.nearestDesc(c,!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 ze&&f.from<=l&&f.to>l)&&(this.mightDrag={node:i,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&yr&&!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)),Us(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(()=>us(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(Ku(e))),this.updateAllowDefault(e),this.allowDefault||!n?Us(this.view,"pointer"):KC(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Rn&&this.mightDrag&&!this.mightDrag.node.isAtom||Cn&&!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)?(wo(this.view,Ye.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Us(this.view,"pointer")}move(e){this.updateAllowDefault(e),Us(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)}}Fn.touchstart=t=>{t.input.lastTouch=Date.now(),Oh(t),Us(t,"pointer")};Fn.touchmove=t=>{t.input.lastTouch=Date.now(),Us(t,"pointer")};Fn.contextmenu=t=>Oh(t);function fw(t,e){return t.composing?!0:Rn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const QC=as?5e3:-1;$n.compositionstart=$n.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof $e&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Cn&&Hx&&XC(t)))t.markCursor=t.state.storedMarks||n.marks(),Jc(t,!0),t.markCursor=null;else if(Jc(t,!e.selection.empty),yr&&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 l=i<0?s.lastChild:s.childNodes[i-1];if(!l)break;if(l.nodeType==3){let c=t.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else s=l,i=-1}}t.input.composing=!0}pw(t,QC)};function XC(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"}$n.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++,pw(t,20))};function pw(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Jc(t),e))}function hw(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e_());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function ZC(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=VN(e.focusNode,e.focusOffset),r=KN(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 l=n.pmViewDesc;if(!(!l||!l.isText(n.nodeValue)))return r}}return n||r}function e_(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Jc(t,e=!1){if(!(as&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),hw(t),e||t.docView&&t.docView.dirty){let n=Ch(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 t_(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 Bl=Yn&&Vs<15||Co&&YN<604;Fn.copy=$n.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Bl?null:n.clipboardData,l=r.content(),{dom:c,text:u}=Th(t,l);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):t_(t,c),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function n_(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function r_(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?zl(t,r.value,null,s,e):zl(t,r.textContent,r.innerHTML,s,e)},50)}function zl(t,e,n,r,s){let i=iw(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,s,i||Se.empty)))return!0;if(!i)return!1;let l=n_(i),c=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function mw(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," "):""}$n.paste=(t,e)=>{let n=e;if(t.composing&&!as)return;let r=Bl?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&zl(t,mw(r),r.getData("text/html"),s,n)?n.preventDefault():r_(t,n)};class gw{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const s_=mr?"altKey":"ctrlKey";function yw(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[s_]}Fn.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(Ku(n)),l;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ze?s.to-1:s.to))){if(r&&r.mightDrag)l=ze.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&&(l=ze.create(t.state.doc,m.posBefore))}}let c=(l||t.state.selection).content(),{dom:u,text:f,slice:h}=Th(t,c);(!n.dataTransfer.files.length||!Cn||Ux>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Bl?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Bl||n.dataTransfer.setData("text/plain",f),t.dragging=new gw(h,yw(t,n),l)};Fn.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};$n.dragover=$n.dragenter=(t,e)=>e.preventDefault();$n.drop=(t,e)=>{try{i_(t,e,t.dragging)}finally{t.dragging=null}};function i_(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ku(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=iw(t,mw(e.dataTransfer),Bl?null:e.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&yw(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||Se.empty,l))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?wx(t.state.doc,s.pos,i):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(l){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let f=u.mapping.map(c),h=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(h?u.replaceRangeWith(f,f,i.content.firstChild):u.replaceRange(f,f,i),u.doc.eq(m))return;let y=u.doc.resolve(f);if(h&&ze.isSelectable(i.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new ze(y));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,w,k,N)=>b=N),u.setSelection(_h(t,y,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Fn.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())&&us(t)},20))};Fn.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)};Fn.beforeinput=(t,e)=>{if(Cn&&as&&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,xi(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 $n)Fn[t]=$n[t];function Fl(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 Yc{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:l}=e.mapResult(n.from+s,this.side<0?-1:1);return l?null:new Mt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Yc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Fl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Gs{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,l=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=l?null:new Mt(i,l,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Gs&&Fl(this.attrs,e.attrs)&&Fl(this.spec,e.spec)}static is(e){return e.type instanceof Gs}destroy(){}}class Rh{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 l=e.mapResult(n.to+s,-1);return l.deleted||l.pos<=i.pos?null:new Mt(i.pos-r,l.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 Rh&&Fl(this.attrs,e.attrs)&&Fl(this.spec,e.spec)}destroy(){}}class Mt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Mt(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 Mt(e,e,new Yc(n,r))}static inline(e,n,r,s){return new Mt(e,n,new Gs(r,s))}static node(e,n,r,s){return new Mt(e,n,new Rh(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Gs}get widget(){return this.type instanceof Yc}}const mo=[],_i={};class mt{constructor(e,n){this.local=e.length?e:mo,this.children=n.length?n:mo}static create(e,n){return n.length?Qc(n,e,0,_i):On}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 l=0;l<this.local.length;l++){let c=this.local[l];c.from<=n&&c.to>=e&&(!i||i(c.spec))&&r.push(c.copy(c.from+s,c.to+s))}for(let l=0;l<this.children.length;l+=3)if(this.children[l]<n&&this.children[l+1]>e){let c=this.children[l]+1;this.children[l+2].findInner(e-c,n-c,r,s+c,i)}}map(e,n,r){return this==On||e.maps.length==0?this:this.mapInner(e,n,0,0,r||_i)}mapInner(e,n,r,s,i){let l;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,s);u&&u.type.valid(n,u)?(l||(l=[])).push(u):i.onRemove&&i.onRemove(this.local[c].spec)}return this.children.length?o_(this.children,l||[],e,n,r,s,i):l?new mt(l.sort(Ti),mo):On}add(e,n){return n.length?this==On?mt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((c,u)=>{let f=u+r,h;if(h=vw(n,c,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(c,h,f+1):s.splice(i,0,u,u+c.nodeSize,Qc(h,c,f+1,_i)),i+=3}});let l=bw(i?xw(n):n,-r);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||l.splice(c--,1);return new mt(l.length?this.local.concat(l).sort(Ti):this.local,s||this.children)}remove(e){return e.length==0||this==On?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 l,c=r[i]+n,u=r[i+1]+n;for(let h=0,m;h<e.length;h++)(m=e[h])&&m.from>c&&m.to<u&&(e[h]=null,(l||(l=[])).push(m));if(!l)continue;r==this.children&&(r=this.children.slice());let f=r[i+2].removeInner(l,c+1);f!=On?r[i+2]=f:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,l;i<e.length;i++)if(l=e[i])for(let c=0;c<s.length;c++)s[c].eq(l,n)&&(s==this.local&&(s=this.local.slice()),s.splice(c--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new mt(s,r):On}forChild(e,n){if(this==On)return this;if(n.isLeaf)return mt.empty;let r,s;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let i=e+1,l=i+n.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<l&&u.to>i&&u.type instanceof Gs){let f=Math.max(i,u.from)-i,h=Math.min(l,u.to)-i;f<h&&(s||(s=[])).push(u.copy(f,h))}}if(s){let c=new mt(s.sort(Ti),mo);return r?new Ps([c,r]):c}return r||On}eq(e){if(this==e)return!0;if(!(e instanceof mt)||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 Ih(this.localsInner(e))}localsInner(e){if(this==On)return mo;if(e.inlineContent||!this.local.some(Gs.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Gs||n.push(this.local[r]);return n}forEachSet(e){e(this)}}mt.empty=new mt([],[]);mt.removeOverlap=Ih;const On=mt.empty;class Ps{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,_i));return Ps.from(r)}forChild(e,n){if(n.isLeaf)return mt.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=On&&(i instanceof Ps?r=r.concat(i.members):r.push(i))}return Ps.from(r)}eq(e){if(!(e instanceof Ps)||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 l=0;l<i.length;l++)n.push(i[l])}}return n?Ih(r?n:n.sort(Ti)):mo}static from(e){switch(e.length){case 0:return On;case 1:return e[0];default:return new Ps(e.every(n=>n instanceof mt)?e:e.reduce((n,r)=>n.concat(r instanceof mt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function o_(t,e,n,r,s,i,l){let c=t.slice();for(let f=0,h=i;f<n.maps.length;f++){let m=0;n.maps[f].forEach((y,b,v,w)=>{let k=w-v-(b-y);for(let N=0;N<c.length;N+=3){let C=c[N+1];if(C<0||y>C+h-m)continue;let O=c[N]+h-m;b>=O?c[N+1]=y<=O?-2:-1:y>=h&&k&&(c[N]+=k,c[N+1]+=k)}m+=k}),h=n.maps[f].map(h,-1)}let u=!1;for(let f=0;f<c.length;f+=3)if(c[f+1]<0){if(c[f+1]==-2){u=!0,c[f+1]=-1;continue}let h=n.map(t[f]+i),m=h-s;if(m<0||m>=r.content.size){u=!0;continue}let y=n.map(t[f+1]+i,-1),b=y-s,{index:v,offset:w}=r.content.findIndex(m),k=r.maybeChild(v);if(k&&w==m&&w+k.nodeSize==b){let N=c[f+2].mapInner(n,k,h+1,t[f]+i+1,l);N!=On?(c[f]=m,c[f+1]=b,c[f+2]=N):(c[f+1]=-2,u=!0)}else u=!0}if(u){let f=l_(c,t,e,n,s,i,l),h=Qc(f,r,0,l);e=h.local;for(let m=0;m<c.length;m+=3)c[m+1]<0&&(c.splice(m,3),m-=3);for(let m=0,y=0;m<h.children.length;m+=3){let b=h.children[m];for(;y<c.length&&c[y]<b;)y+=3;c.splice(y,0,h.children[m],h.children[m+1],h.children[m+2])}}return new mt(e.sort(Ti),c)}function bw(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 Mt(s.from+e,s.to+e,s.type))}return n}function l_(t,e,n,r,s,i,l){function c(u,f){for(let h=0;h<u.local.length;h++){let m=u.local[h].map(r,s,f);m?n.push(m):l.onRemove&&l.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)c(u.children[h+2],u.children[h]+f+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&c(t[u+2],e[u]+i+1);return n}function vw(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,l;i<t.length;i++)(l=t[i])&&l.from>n&&l.to<r&&((s||(s=[])).push(l),t[i]=null);return s}function xw(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Qc(t,e,n,r){let s=[],i=!1;e.forEach((c,u)=>{let f=vw(t,c,u+n);if(f){i=!0;let h=Qc(f,c,n+u+1,r);h!=On&&s.push(u,u+c.nodeSize,h)}});let l=bw(i?xw(t):t,-n).sort(Ti);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||(r.onRemove&&r.onRemove(l[c].spec),l.splice(c--,1));return l.length||s.length?new mt(l,s):On}function Ti(t,e){return t.from-e.from||t.to-e.to}function Ih(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),Pb(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),Pb(e,s,r.copy(i.from,r.to)));break}}}return e}function Pb(t,e,n){for(;e<t.length&&Ti(n,t[e])>0;)e++;t.splice(e,0,n)}function np(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=On&&e.push(r)}),t.cursorWrapper&&e.push(mt.create(t.state.doc,[t.cursorWrapper.deco])),Ps.from(e)}const a_={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},c_=Yn&&Vs<=11;class u_{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 d_{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new u_,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]);Yn&&Vs<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Rn&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),c_&&(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,a_)),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(Mb(this.view)){if(this.suppressingSelectionUpdates)return us(this.view);if(Yn&&Vs<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ri(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=No(i))n.add(i);for(let i=e.anchorNode;i;i=No(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)&&Mb(e)&&!this.ignoreSelectionChange(r),i=-1,l=-1,c=!1,u=[];if(e.editable)for(let h=0;h<n.length;h++){let m=this.registerMutation(n[h],u);m&&(i=i<0?m.from:Math.min(m.from,i),l=l<0?m.to:Math.max(m.to,l),m.typeOver&&(c=!0))}if(u.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let h of u)if(h.nodeName=="BR"&&h.parentNode){let m=h.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&h.parentNode.removeChild(h)}}else if(yr&&u.length){let h=u.filter(m=>m.nodeName=="BR");if(h.length==2){let[m,y]=h;m.parentNode&&m.parentNode.parentNode==y.parentNode?y.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let y of h){let b=y.parentNode;b&&b.nodeName=="LI"&&(!m||h_(e,m)!=b)&&y.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&&Wu(r)&&(f=Ch(e))&&f.eq(Ye.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,us(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,l),f_(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,m_(e,u)),this.handleDOMChange(i,l,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||us(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 h=0;h<e.addedNodes.length;h++){let m=e.addedNodes[h];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(Yn&&Vs<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:m,nextSibling:y}=e.addedNodes[h];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(i=y)}let l=s&&s.parentNode==e.target?En(s)+1:0,c=r.localPosFromDOM(e.target,l,-1),u=i&&i.parentNode==e.target?En(i):e.target.childNodes.length,f=r.localPosFromDOM(e.target,u,1);return{from:c,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 Bb=new WeakMap,zb=!1;function f_(t){if(!Bb.has(t)&&(Bb.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=yr,zb)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."),zb=!0}}function Fb(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,l=t.domAtPos(t.state.selection.anchor);return Ri(l.node,l.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function p_(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Fb(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?Fb(t,n):null}function h_(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 m_(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 l=i.nextSibling;for(;l&&l.nodeName!="TD"&&l.nodeName!="TH";)l=l.nextSibling;if(l){let c=l;for(;;){let u=c.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;c=u}c.insertBefore(i,c.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function g_(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:l,to:c}=t.docView.parseRange(e,n),u=t.domSelectionRange(),f,h=u.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)&&(f=[{node:h,offset:u.anchorOffset}],Wu(u)||f.push({node:u.focusNode,offset:u.focusOffset})),Cn&&t.input.lastKeyCode===8)for(let k=i;k>s;k--){let N=r.childNodes[k-1],C=N.pmViewDesc;if(N.nodeName=="BR"&&!C){i=k;break}if(!C||C.size)break}let m=t.state.doc,y=t.someProp("domParser")||Ws.fromSchema(t.state.schema),b=m.resolve(l),v=null,w=y.parse(r,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:s,to:i,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:y_,context:b});if(f&&f[0].pos!=null){let k=f[0].pos,N=f[1]&&f[1].pos;N==null&&(N=k),v={anchor:k+l,head:N+l}}return{doc:w,sel:v,from:l,to:c}}function y_(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Rn&&/^(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||Rn&&/^(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 b_=/^(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 v_(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let B=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,U=Ch(t,B);if(U&&!t.state.selection.eq(U)){if(Cn&&as&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",H=>H(t,xi(13,"Enter"))))return;let z=t.state.tr.setSelection(U);B=="pointer"?z.setMeta("pointer",!0):B=="key"&&z.scrollIntoView(),i&&z.setMeta("composition",i),t.dispatch(z)}return}let l=t.state.doc.resolve(e),c=l.sharedDepth(n);e=l.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,f=g_(t,e,n),h=t.state.doc,m=h.slice(f.from,f.to),y,b;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(y=t.state.selection.to,b="end"):(y=t.state.selection.from,b="start"),t.input.lastKeyCode=null;let v=k_(m.content,f.doc.content,f.from,y,b);if(v&&t.input.domChangeCount++,(Co&&t.input.lastIOSEnter>Date.now()-225||as)&&s.some(B=>B.nodeType==1&&!b_.test(B.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",B=>B(t,xi(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&u instanceof $e&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))v={start:u.from,endA:u.to,endB:u.to};else{if(f.sel){let B=$b(t,t.state.doc,f.sel);if(B&&!B.eq(t.state.selection)){let U=t.state.tr.setSelection(B);i&&U.setMeta("composition",i),t.dispatch(U)}}return}t.state.selection.from<t.state.selection.to&&v.start==v.endB&&t.state.selection instanceof $e&&(v.start>t.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?v.start=t.state.selection.from:v.endA<t.state.selection.to&&v.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),Yn&&Vs<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>f.from&&f.doc.textBetween(v.start-f.from-1,v.start-f.from+1)==" "&&(v.start--,v.endA--,v.endB--);let w=f.doc.resolveNoCache(v.start-f.from),k=f.doc.resolveNoCache(v.endB-f.from),N=h.resolve(v.start),C=w.sameParent(k)&&w.parent.inlineContent&&N.end()>=v.endA;if((Co&&t.input.lastIOSEnter>Date.now()-225&&(!C||s.some(B=>B.nodeName=="DIV"||B.nodeName=="P"))||!C&&w.pos<f.doc.content.size&&(!w.sameParent(k)||!w.parent.inlineContent)&&w.pos<k.pos&&!/\S/.test(f.doc.textBetween(w.pos,k.pos,"","")))&&t.someProp("handleKeyDown",B=>B(t,xi(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&w_(h,v.start,v.endA,w,k)&&t.someProp("handleKeyDown",B=>B(t,xi(8,"Backspace")))){as&&Cn&&t.domObserver.suppressSelectionUpdates();return}Cn&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),as&&!C&&w.start()!=k.start()&&k.parentOffset==0&&w.depth==k.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==v.endA&&(v.endB-=2,k=f.doc.resolveNoCache(v.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(B){return B(t,xi(13,"Enter"))})},20));let O=v.start,T=v.endA,M=B=>{let U=B||t.state.tr.replace(O,T,f.doc.slice(v.start-f.from,v.endB-f.from));if(f.sel){let z=$b(t,U.doc,f.sel);z&&!(Cn&&t.composing&&z.empty&&(v.start!=v.endB||t.input.lastChromeDelete<Date.now()-100)&&(z.head==O||z.head==U.mapping.map(T)-1)||Yn&&z.empty&&z.head==O)&&U.setSelection(z)}return i&&U.setMeta("composition",i),U.scrollIntoView()},R;if(C)if(w.pos==k.pos){Yn&&Vs<=11&&w.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>us(t),20));let B=M(t.state.tr.delete(O,T)),U=h.resolve(v.start).marksAcross(h.resolve(v.endA));U&&B.ensureMarks(U),t.dispatch(B)}else if(v.endA==v.endB&&(R=x_(w.parent.content.cut(w.parentOffset,k.parentOffset),N.parent.content.cut(N.parentOffset,v.endA-N.start())))){let B=M(t.state.tr);R.type=="add"?B.addMark(O,T,R.mark):B.removeMark(O,T,R.mark),t.dispatch(B)}else if(w.parent.child(w.index()).isText&&w.index()==k.index()-(k.textOffset?0:1)){let B=w.parent.textBetween(w.parentOffset,k.parentOffset),U=()=>M(t.state.tr.insertText(B,O,T));t.someProp("handleTextInput",z=>z(t,O,T,B,U))||t.dispatch(U())}else t.dispatch(M());else t.dispatch(M())}function $b(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:_h(t,e.resolve(n.anchor),e.resolve(n.head))}function x_(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,l,c,u;for(let h=0;h<r.length;h++)s=r[h].removeFromSet(s);for(let h=0;h<n.length;h++)i=n[h].removeFromSet(i);if(s.length==1&&i.length==0)c=s[0],l="add",u=h=>h.mark(c.addToSet(h.marks));else if(s.length==0&&i.length==1)c=i[0],l="remove",u=h=>h.mark(c.removeFromSet(h.marks));else return null;let f=[];for(let h=0;h<e.childCount;h++)f.push(u(e.child(h)));if(le.from(f).eq(t))return{mark:c,type:l}}function w_(t,e,n,r,s){if(n-e<=s.pos-r.pos||rp(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let c=i.nodeAfter;return c!=null&&n==e+c.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let l=t.resolve(rp(i,!0,!0));return!l.parent.isTextblock||l.pos>n||rp(l,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function rp(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 k_(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:l,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let u=Math.max(0,i-Math.min(l,c));r-=l+u-i}if(l<i&&t.size<e.size){let u=r<=i&&r>=l?i-r:0;i-=u,i&&i<e.size&&Ub(e.textBetween(i-1,i+1))&&(i+=u?1:-1),c=i+(c-l),l=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,i&&i<t.size&&Ub(t.textBetween(i-1,i+1))&&(i+=u?1:-1),l=i+(l-c),c=i}return{start:i,endA:l,endB:c}}function Ub(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 ww{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 BC,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Gb),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=Vb(this),Wb(this),this.nodeViews=Kb(this),this.docView=Sb(this.state.doc,Hb(this),np(this),this.dom,this),this.domObserver=new d_(this,(r,s,i,l)=>v_(this,r,s,i,l)),this.domObserver.start(),zC(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&&Wp(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gb),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,l=!1;e.storedMarks&&this.composing&&(hw(this),l=!0),this.state=e;let c=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let b=Kb(this);E_(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Wp(this),this.editable=Vb(this),Wb(this);let u=np(this),f=Hb(this),h=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))&&(l=!0);let y=h=="preserve"&&l&&this.dom.style.overflowAnchor==null&&ZN(this);if(l){this.domObserver.stop();let b=m&&(Yn||Cn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&S_(s.selection,e.selection);if(m){let v=Cn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ZC(this)),(i||!this.docView.update(e.doc,f,u,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Sb(e.doc,f,u,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&SC(this))?us(this,b):(nw(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),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():y&&eC(y)}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 ze){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&yb(this,n.getBoundingClientRect(),e)}else yb(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 gw(e.slice,e.move,s<0?void 0:ze.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 l=0;l<this.directPlugins.length;l++){let c=this.directPlugins[l].props[e];if(c!=null&&(s=n?n(c):c))return s}let i=this.state.plugins;if(i)for(let l=0;l<i.length;l++){let c=i[l].props[e];if(c!=null&&(s=n?n(c):c))return s}}hasFocus(){if(Yn){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&&tC(this.dom),us(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 oC(this,e)}coordsAtPos(e,n=1){return qx(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 dC(this,n||this.state,e)}pasteHTML(e,n){return zl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return zl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Th(this,e)}destroy(){this.docView&&(FC(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],np(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,HN())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return UC(this,e)}domSelectionRange(){let e=this.domSelection();return e?Rn&&this.root.nodeType===11&&qN(this.dom.ownerDocument)==this.dom&&p_(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ww.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Hb(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"),[Mt.node(0,t.state.doc.content.size,e)]}function Wb(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:Mt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Vb(t){return!t.someProp("editable",e=>e(t.state)===!1)}function S_(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 Kb(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 E_(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 Gb(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 Js={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:"'"},Xc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},N_=typeof navigator<"u"&&/Mac/.test(navigator.platform),C_=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Nn=0;Nn<10;Nn++)Js[48+Nn]=Js[96+Nn]=String(Nn);for(var Nn=1;Nn<=24;Nn++)Js[Nn+111]="F"+Nn;for(var Nn=65;Nn<=90;Nn++)Js[Nn]=String.fromCharCode(Nn+32),Xc[Nn]=String.fromCharCode(Nn);for(var sp in Js)Xc.hasOwnProperty(sp)||(Xc[sp]=Js[sp]);function __(t){var e=N_&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||C_&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Xc:Js)[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 T_=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),M_=typeof navigator<"u"&&/Win/.test(navigator.platform);function A_(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,l;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!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))T_?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function O_(t){let e=Object.create(null);for(let n in t)e[A_(n)]=t[n];return e}function ip(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 R_(t){return new bt({props:{handleKeyDown:jh(t)}})}function jh(t){let e=O_(t);return function(n,r){let s=__(r),i,l=e[ip(s,r)];if(l&&l(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let c=e[ip(s,r,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(M_&&r.ctrlKey&&r.altKey)&&(i=Js[r.keyCode])&&i!=s){let c=e[ip(i,r)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var I_=Object.defineProperty,Lh=(t,e)=>{for(var n in e)I_(t,n,{get:e[n],enumerable:!0})};function Gu(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 qu=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(([l,c])=>[l,(...f)=>{const h=c(...f)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),h}]))}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,l=[],c=!!t,u=t||s.tr,f=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),l.every(m=>m===!0)),h={...Object.fromEntries(Object.entries(n).map(([m,y])=>[m,(...v)=>{const w=this.buildProps(u,e),k=y(...v)(w);return l.push(k),h}])),run:f};return h}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(([c,u])=>[c,(...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,l={tr:t,editor:r,view:i,state:Gu({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(([c,u])=>[c,(...f)=>u(...f)(l)]))}};return l}},kw={};Lh(kw,{blur:()=>j_,clearContent:()=>L_,clearNodes:()=>D_,command:()=>P_,createParagraphNear:()=>B_,cut:()=>z_,deleteCurrentNode:()=>F_,deleteNode:()=>$_,deleteRange:()=>U_,deleteSelection:()=>H_,enter:()=>W_,exitCode:()=>V_,extendMarkRange:()=>K_,first:()=>G_,focus:()=>J_,forEach:()=>Y_,insertContent:()=>Q_,insertContentAt:()=>eT,joinBackward:()=>rT,joinDown:()=>nT,joinForward:()=>sT,joinItemBackward:()=>iT,joinItemForward:()=>oT,joinTextblockBackward:()=>lT,joinTextblockForward:()=>aT,joinUp:()=>tT,keyboardShortcut:()=>uT,lift:()=>dT,liftEmptyBlock:()=>fT,liftListItem:()=>pT,newlineInCode:()=>hT,resetAttributes:()=>mT,scrollIntoView:()=>gT,selectAll:()=>yT,selectNodeBackward:()=>bT,selectNodeForward:()=>vT,selectParentNode:()=>xT,selectTextblockEnd:()=>wT,selectTextblockStart:()=>kT,setContent:()=>ST,setMark:()=>$T,setMeta:()=>UT,setNode:()=>HT,setNodeSelection:()=>WT,setTextDirection:()=>VT,setTextSelection:()=>KT,sinkListItem:()=>GT,splitBlock:()=>qT,splitListItem:()=>JT,toggleList:()=>YT,toggleMark:()=>QT,toggleNode:()=>XT,toggleWrap:()=>ZT,undoInputRule:()=>eM,unsetAllMarks:()=>tM,unsetMark:()=>nM,unsetTextDirection:()=>rM,updateAttributes:()=>sM,wrapIn:()=>iM,wrapInList:()=>oM});var j_=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),L_=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),D_=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:l})=>{t.doc.nodesBetween(i.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:f,mapping:h}=e,m=f.resolve(h.map(u)),y=f.resolve(h.map(u+c.nodeSize)),b=m.blockRange(y);if(!b)return;const v=Ao(b);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(b.start,w)}(v||v===0)&&e.lift(b,v)})}),!0},P_=t=>e=>t(e),B_=()=>({state:t,dispatch:e})=>Px(t,e),z_=(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 l=r.mapping.map(e);return r.insert(l,i.content),r.setSelection(new $e(r.doc.resolve(Math.max(l-1,0)))),!0},F_=()=>({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 c=s.before(i),u=s.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function rn(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 $_=t=>({tr:e,state:n,dispatch:r})=>{const s=rn(t,n.schema),i=e.selection.$anchor;for(let l=i.depth;l>0;l-=1)if(i.node(l).type===s){if(r){const u=i.before(l),f=i.after(l);e.delete(u,f).scrollIntoView()}return!0}return!1},U_=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},H_=()=>({state:t,dispatch:e})=>xh(t,e),W_=()=>({commands:t})=>t.keyboardShortcut("Enter"),V_=()=>({state:t,dispatch:e})=>TN(t,e);function Dh(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Zc(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Dh(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Sw(t,e,n={}){return t.find(r=>r.type===e&&Zc(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function qb(t,e,n={}){return!!Sw(t,e,n)}function Ph(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(h=>h.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(h=>h.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Sw([...s.node.marks],e,n)))return;let l=s.index,c=t.start()+s.offset,u=l+1,f=c+s.node.nodeSize;for(;l>0&&qb([...t.parent.child(l-1).marks],e,n);)l-=1,c-=t.parent.child(l).nodeSize;for(;u<t.parent.childCount&&qb([...t.parent.child(u).marks],e,n);)f+=t.parent.child(u).nodeSize,u+=1;return{from:c,to:f}}function ds(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 K_=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=ds(t,r.schema),{doc:l,selection:c}=n,{$from:u,from:f,to:h}=c;if(s){const m=Ph(u,i,e);if(m&&m.from<=f&&m.to>=h){const y=$e.create(l,m.from,m.to);n.setSelection(y)}}return!0},G_=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 Ew(t){return t instanceof $e}function Si(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Nw(t,e=null){if(!e)return null;const n=Ye.atStart(t),r=Ye.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?$e.create(t,Si(0,s,i),Si(t.content.size,s,i)):$e.create(t,Si(e,s,i),Si(e,s,i))}function Jb(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function eu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function q_(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var J_=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const l=()=>{(eu()||Jb())&&r.dom.focus(),q_()&&!eu()&&!Jb()&&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&&!Ew(n.state.selection))return l(),!0;const c=Nw(s.doc,t)||n.state.selection,u=n.state.selection.eq(c);return i&&(u||s.setSelection(c),u&&s.storedMarks&&s.setStoredMarks(s.storedMarks),l()),!0},Y_=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Q_=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Cw=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&&Cw(r)}return t};function cc(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 Cw(n)}function $l(t,e,n){if(t instanceof Mr||t instanceof le)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 le.fromArray(t.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(t);return n.errorOnInvalidContent&&l.check(),l}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),$l("",e,n)}if(s){if(n.errorOnInvalidContent){let l=!1,c="";const u=new ux({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=>(l=!0,c=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?Ws.fromSchema(u).parseSlice(cc(t),n.parseOptions):Ws.fromSchema(u).parse(cc(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Ws.fromSchema(e);return n.slice?i.parseSlice(cc(t),n.parseOptions).content:i.parse(cc(t),n.parseOptions)}return $l("",e,n)}function X_(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof fn||s instanceof pn))return;const i=t.mapping.maps[r];let l=0;i.forEach((c,u,f,h)=>{l===0&&(l=h)}),t.setSelection(Ye.near(t.doc.resolve(l),n))}var Z_=t=>!("type"in t),eT=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var l;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=k=>{i.emit("contentError",{editor:i,error:k,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{$l(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(k){u(k)}try{c=$l(e,i.schema,{parseOptions:f,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:i.options.enableContentCheck})}catch(k){return u(k),!1}let{from:h,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,b=!0;if((Z_(c)?c:[c]).forEach(k=>{k.check(),y=y?k.isText&&k.marks.length===0:!1,b=b?k.isBlock:!1}),h===m&&b){const{parent:k}=r.doc.resolve(h);k.isTextblock&&!k.type.spec.code&&!k.childCount&&(h-=1,m+=1)}let w;if(y){if(Array.isArray(e))w=e.map(k=>k.text||"").join("");else if(e instanceof le){let k="";e.forEach(N=>{N.text&&(k+=N.text)}),w=k}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,h,m)}else{w=c;const k=r.doc.resolve(h),N=k.node(),C=k.parentOffset===0,O=N.isText||N.isTextblock,T=N.content.size>0;C&&O&&T&&(h=Math.max(0,h-1)),r.replaceWith(h,m,w)}n.updateSelection&&X_(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:w})}return!0},tT=()=>({state:t,dispatch:e})=>NN(t,e),nT=()=>({state:t,dispatch:e})=>CN(t,e),rT=()=>({state:t,dispatch:e})=>Ax(t,e),sT=()=>({state:t,dispatch:e})=>jx(t,e),iT=()=>({state:t,dispatch:e,tr:n})=>{try{const r=$u(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},oT=()=>({state:t,dispatch:e,tr:n})=>{try{const r=$u(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},lT=()=>({state:t,dispatch:e})=>SN(t,e),aT=()=>({state:t,dispatch:e})=>EN(t,e);function _w(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function cT(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,l;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!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))eu()||_w()?l=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var uT=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=cT(t).split(/-(?!$)/),l=i.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,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,c))});return u==null||u.steps.forEach(f=>{const h=f.map(r.mapping);h&&s&&r.maybeStep(h)}),!0};function Ys(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,l=e?rn(e,t.schema):null,c=[];t.doc.nodesBetween(r,s,(m,y)=>{if(m.isText)return;const b=Math.max(r,y),v=Math.min(s,y+m.nodeSize);c.push({node:m,from:b,to:v})});const u=s-r,f=c.filter(m=>l?l.name===m.node.type.name:!0).filter(m=>Zc(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,y)=>m+y.to-y.from,0)>=u}var dT=(t,e={})=>({state:n,dispatch:r})=>{const s=rn(t,n.schema);return Ys(n,s,e)?_N(n,r):!1},fT=()=>({state:t,dispatch:e})=>Bx(t,e),pT=t=>({state:e,dispatch:n})=>{const r=rn(t,e.schema);return zN(r)(e,n)},hT=()=>({state:t,dispatch:e})=>Dx(t,e);function Ju(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Yb(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 mT=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,l=null;const c=Ju(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=rn(t,r.schema)),c==="mark"&&(l=ds(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(h,m)=>{i&&i===h.type&&(u=!0,s&&n.setNodeMarkup(m,void 0,Yb(h.attrs,e))),l&&h.marks.length&&h.marks.forEach(y=>{l===y.type&&(u=!0,s&&n.addMark(m,m+h.nodeSize,l.create(Yb(y.attrs,e))))})})}),u},gT=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),yT=()=>({tr:t,dispatch:e})=>{if(e){const n=new ir(t.doc);t.setSelection(n)}return!0},bT=()=>({state:t,dispatch:e})=>Rx(t,e),vT=()=>({state:t,dispatch:e})=>Lx(t,e),xT=()=>({state:t,dispatch:e})=>ON(t,e),wT=()=>({state:t,dispatch:e})=>jN(t,e),kT=()=>({state:t,dispatch:e})=>IN(t,e);function Vp(t,e,n={},r={}){return $l(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var ST=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:l,commands:c})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const f=Vp(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return l&&i.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!n),!0}return l&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Tw(t,e){const n=ds(e,t.schema),{from:r,to:s,empty:i}=t.selection,l=[];i?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function Bh(t,e){const n=new bh(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function ET(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 tu(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function Mw(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Aw(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 Yu(t){return e=>Aw(e.$from,t)}function Pe(t,e,n){return t.config[e]===void 0&&t.parent?Pe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Pe(t.parent,e,n):null}):t.config[e]}function zh(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Pe(e,"addExtensions",n);return r?[e,...zh(r())]:e}).flat(10)}function Fh(t,e){const n=Pi.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Ow(t){return typeof t=="function"}function gt(t,e=void 0,...n){return Ow(t)?e?t.bind(e)(...n):t(...n):t}function NT(t={}){return Object.keys(t).length===0&&t.constructor===Object}function _o(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 Rw(t){const e=[],{nodeExtensions:n,markExtensions:r}=_o(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage,extensions:s},u=Pe(l,"addGlobalAttributes",c);if(!u)return;u().forEach(h=>{h.types.forEach(m=>{Object.entries(h.attributes).forEach(([y,b])=>{e.push({type:m,name:y,attribute:{...i,...b}})})})})}),s.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},u=Pe(l,"addAttributes",c);if(!u)return;const f=u();Object.entries(f).forEach(([h,m])=>{const y={...i,...m};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,e.push({type:l.name,name:h,attribute:y})})}),e}function yt(...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 c=i?String(i).split(" "):[],u=r[s]?r[s].split(" "):[],f=c.filter(h=>!u.includes(h));r[s]=[...u,...f].join(" ")}else if(s==="style"){const c=i?i.split(";").map(h=>h.trim()).filter(Boolean):[],u=r[s]?r[s].split(";").map(h=>h.trim()).filter(Boolean):[],f=new Map;u.forEach(h=>{const[m,y]=h.split(":").map(b=>b.trim());f.set(m,y)}),c.forEach(h=>{const[m,y]=h.split(":").map(b=>b.trim());f.set(m,y)}),r[s]=Array.from(f.entries()).map(([h,m])=>`${h}: ${m}`).join("; ")}else r[s]=i}),r},{})}function Ul(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)=>yt(n,r),{})}function CT(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Qb(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,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(n):CT(n.getAttribute(l.name));return c==null?i:{...i,[l.name]:c}},{});return{...r,...s}}}}function Xb(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&NT(n)?!1:n!=null))}function Zb(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 _T(t,e){var n;const r=Rw(t),{nodeExtensions:s,markExtensions:i}=_o(t),l=(n=s.find(f=>Pe(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(s.map(f=>{const h=r.filter(N=>N.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},y=t.reduce((N,C)=>{const O=Pe(C,"extendNodeSchema",m);return{...N,...O?O(f):{}}},{}),b=Xb({...y,content:gt(Pe(f,"content",m)),marks:gt(Pe(f,"marks",m)),group:gt(Pe(f,"group",m)),inline:gt(Pe(f,"inline",m)),atom:gt(Pe(f,"atom",m)),selectable:gt(Pe(f,"selectable",m)),draggable:gt(Pe(f,"draggable",m)),code:gt(Pe(f,"code",m)),whitespace:gt(Pe(f,"whitespace",m)),linebreakReplacement:gt(Pe(f,"linebreakReplacement",m)),defining:gt(Pe(f,"defining",m)),isolating:gt(Pe(f,"isolating",m)),attrs:Object.fromEntries(h.map(Zb))}),v=gt(Pe(f,"parseHTML",m));v&&(b.parseDOM=v.map(N=>Qb(N,h)));const w=Pe(f,"renderHTML",m);w&&(b.toDOM=N=>w({node:N,HTMLAttributes:Ul(N,h)}));const k=Pe(f,"renderText",m);return k&&(b.toText=k),[f.name,b]})),u=Object.fromEntries(i.map(f=>{const h=r.filter(k=>k.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},y=t.reduce((k,N)=>{const C=Pe(N,"extendMarkSchema",m);return{...k,...C?C(f):{}}},{}),b=Xb({...y,inclusive:gt(Pe(f,"inclusive",m)),excludes:gt(Pe(f,"excludes",m)),group:gt(Pe(f,"group",m)),spanning:gt(Pe(f,"spanning",m)),code:gt(Pe(f,"code",m)),attrs:Object.fromEntries(h.map(Zb))}),v=gt(Pe(f,"parseHTML",m));v&&(b.parseDOM=v.map(k=>Qb(k,h)));const w=Pe(f,"renderHTML",m);return w&&(b.toDOM=k=>w({mark:k,HTMLAttributes:Ul(k,h)})),[f.name,b]}));return new ux({topNode:l,nodes:c,marks:u})}function TT(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function nu(t){return t.sort((n,r)=>{const s=Pe(n,"priority")||100,i=Pe(r,"priority")||100;return s>i?-1:s<i?1:0})}function Iw(t){const e=nu(zh(t)),n=TT(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 jw(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
58
|
+
|
|
59
|
+
`,textSerializers:l={}}=n||{};let c="";return t.nodesBetween(r,s,(u,f,h,m)=>{var y;u.isBlock&&f>r&&(c+=i);const b=l==null?void 0:l[u.type.name];if(b)return h&&(c+=b({node:u,pos:f,parent:h,index:m,range:e})),!1;u.isText&&(c+=(y=u==null?void 0:u.text)==null?void 0:y.slice(Math.max(r,f)-f,s-f))}),c}function MT(t,e){const n={from:0,to:t.content.size};return jw(t,n,e)}function Lw(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function AT(t,e){const n=rn(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,c=>{i.push(c)});const l=i.reverse().find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Dw(t,e){const n=Ju(typeof e=="string"?e:e.name,t.schema);return n==="node"?AT(t,e):n==="mark"?Tw(t,e):{}}function OT(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 RT(t){const e=OT(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,l)=>l!==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 $h(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const l=[];if(s.ranges.length)s.forEach((c,u)=>{l.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}l.forEach(({from:c,to:u})=>{const f=e.slice(i).map(c,-1),h=e.slice(i).map(u),m=e.invert().map(f,-1),y=e.invert().map(h);r.push({oldRange:{from:m,to:y},newRange:{from:f,to:h}})})}),RT(r)}function Uh(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),l=Ph(i,s.type);l&&r.push({mark:s,...l})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(l=>({from:i,to:i+s.nodeSize,mark:l})))}),r}var IT=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,l=null;for(;i>0&&l===null;){const c=s.node(i);(c==null?void 0:c.type.name)===e?l=c:i-=1}return[l,i]};function uc(t,e){return e.nodes[t]||e.marks[t]||null}function Dc(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 jT=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,l,c)=>{var u,f;const h=((f=(u=s.type.spec).toText)==null?void 0:f.call(u,{node:s,pos:i,parent:l,index:c}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?h:h.slice(0,Math.max(0,r-i))}),n};function Kp(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?ds(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Zc(m.attrs,n,{strict:!1}));let l=0;const c=[];if(s.forEach(({$from:m,$to:y})=>{const b=m.pos,v=y.pos;t.doc.nodesBetween(b,v,(w,k)=>{if(!w.isText&&!w.marks.length)return;const N=Math.max(b,k),C=Math.min(v,k+w.nodeSize),O=C-N;l+=O,c.push(...w.marks.map(T=>({mark:T,from:N,to:C})))})}),l===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Zc(m.mark.attrs,n,{strict:!1})).reduce((m,y)=>m+y.to-y.from,0),f=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,y)=>m+y.to-y.from,0);return(u>0?u+f:u)>=l}function LT(t,e,n={}){if(!e)return Ys(t,null,n)||Kp(t,null,n);const r=Ju(e,t.schema);return r==="node"?Ys(t,e,n):r==="mark"?Kp(t,e,n):!1}var DT=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Yu(c=>c.type.name===e)(t.selection);if(!i)return!1;const l=t.doc.resolve(i.pos+1);return s.pos+1===l.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},PT=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function ev(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function tv(t,e){const{nodeExtensions:n}=_o(e),r=n.find(l=>l.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=gt(Pe(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Qu(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&&(Qu(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Pw(t){return t instanceof ze}var Bw=class zw{constructor(e){this.position=e}static fromJSON(e){return new zw(e.position)}toJSON(){return{position:this.position}}};function BT(t,e){const n=e.mapping.mapResult(t.position);return{position:new Bw(n.pos),mapResult:n}}function zT(t){return new Bw(t)}function FT(t,e,n){var r;const{selection:s}=e;let i=null;if(Ew(s)&&(i=s.$cursor),i){const c=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(f=>f.type.excludes(n)))}const{ranges:l}=s;return l.some(({$from:c,$to:u})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(h,m,y)=>{if(f)return!1;if(h.isInline){const b=!y||y.type.allowsMarkType(n),v=!!n.isInSet(h.marks)||!h.marks.some(w=>w.type.excludes(n));f=b&&v}return!f}),f})}var $T=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:l,ranges:c}=i,u=ds(t,r.schema);if(s)if(l){const f=Tw(r,u);n.addStoredMark(u.create({...f,...e}))}else c.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(h,m,(y,b)=>{const v=Math.max(b,h),w=Math.min(b+y.nodeSize,m);y.marks.find(N=>N.type===u)?y.marks.forEach(N=>{u===N.type&&n.addMark(v,w,u.create({...N.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return FT(r,n,u)},UT=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),HT=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=rn(t,n.schema);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:c})=>hb(i,{...l,...e})(n)?!0:c.clearNodes()).command(({state:c})=>hb(i,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},WT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Si(t,0,r.content.size),i=ze.create(r,s);e.setSelection(i)}return!0},VT=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let l,c;return typeof e=="number"?(l=e,c=e):e&&"from"in e&&"to"in e?(l=e.from,c=e.to):(l=i.from,c=i.to),s&&n.doc.nodesBetween(l,c,(u,f)=>{u.isText||n.setNodeMarkup(f,void 0,{...u.attrs,dir:t})}),!0},KT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,l=$e.atStart(r).from,c=$e.atEnd(r).to,u=Si(s,l,c),f=Si(i,l,c),h=$e.create(r,u,f);e.setSelection(h)}return!0},GT=t=>({state:e,dispatch:n})=>{const r=rn(t,e.schema);return UN(r)(e,n)};function nv(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 qT=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:l}=e,{$from:c,$to:u}=i,f=s.extensionManager.attributes,h=Dc(f,c.node().type.name,c.node().attrs);if(i instanceof ze&&i.node.isBlock)return!c.parentOffset||!cs(l,c.pos)?!1:(r&&(t&&nv(n,s.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,y=c.depth===0?void 0:ET(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&y?[{type:y,attrs:h}]:void 0,v=cs(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!v&&cs(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(v=!0,b=y?[{type:y,attrs:h}]:void 0),r){if(v&&(i instanceof $e&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,b),y&&!m&&!c.parentOffset&&c.parent.type!==y)){const w=e.mapping.map(c.before()),k=e.doc.resolve(w);c.node(-1).canReplaceWith(k.index(),k.index()+1,y)&&e.setNodeMarkup(e.mapping.map(c.before()),y)}t&&nv(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return v},JT=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var l;const c=rn(t,r.schema),{$from:u,$to:f}=r.selection,h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(f))return!1;const m=u.node(-1);if(m.type!==c)return!1;const y=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(s){let N=le.empty;const C=u.index(-1)?1:u.index(-2)?2:3;for(let U=u.depth-C;U>=u.depth-3;U-=1)N=le.from(u.node(U).copy(N));const O=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,T={...Dc(y,u.node().type.name,u.node().attrs),...e},M=((l=c.contentMatch.defaultType)==null?void 0:l.createAndFill(T))||void 0;N=N.append(le.from(c.createAndFill(null,M)||void 0));const R=u.before(u.depth-(C-1));n.replace(R,u.after(-O),new Se(N,4-C,0));let B=-1;n.doc.nodesBetween(R,n.doc.content.size,(U,z)=>{if(B>-1)return!1;U.isTextblock&&U.content.size===0&&(B=z+1)}),B>-1&&n.setSelection($e.near(n.doc.resolve(B))),n.scrollIntoView()}return!0}const b=f.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={...Dc(y,m.type.name,m.attrs),...e},w={...Dc(y,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,f.pos);const k=b?[{type:c,attrs:v},{type:b,attrs:w}]:[{type:c,attrs:v}];if(!cs(n.doc,u.pos,2))return!1;if(s){const{selection:N,storedMarks:C}=r,{splittableMarks:O}=i.extensionManager,T=C||N.$to.parentOffset&&N.$from.marks();if(n.split(u.pos,2,k).scrollIntoView(),!T||!s)return!0;const M=T.filter(R=>O.includes(R.type.name));n.ensureMarks(M)}return!0},op=(t,e)=>{const n=Yu(l=>l.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)&&Xs(t.doc,n.pos)&&t.join(n.pos),!0},lp=(t,e)=>{const n=Yu(l=>l.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)&&Xs(t.doc,r)&&t.join(r),!0},YT=(t,e,n,r={})=>({editor:s,tr:i,state:l,dispatch:c,chain:u,commands:f,can:h})=>{const{extensions:m,splittableMarks:y}=s.extensionManager,b=rn(t,l.schema),v=rn(e,l.schema),{selection:w,storedMarks:k}=l,{$from:N,$to:C}=w,O=N.blockRange(C),T=k||w.$to.parentOffset&&w.$from.marks();if(!O)return!1;const M=Yu(R=>tv(R.type.name,m))(w);if(O.depth>=1&&M&&O.depth-M.depth<=1){if(M.node.type===b)return f.liftListItem(v);if(tv(M.node.type.name,m)&&b.validContent(M.node.content)&&c)return u().command(()=>(i.setNodeMarkup(M.pos,b),!0)).command(()=>op(i,b)).command(()=>lp(i,b)).run()}return!n||!T||!c?u().command(()=>h().wrapInList(b,r)?!0:f.clearNodes()).wrapInList(b,r).command(()=>op(i,b)).command(()=>lp(i,b)).run():u().command(()=>{const R=h().wrapInList(b,r),B=T.filter(U=>y.includes(U.type.name));return i.ensureMarks(B),R?!0:f.clearNodes()}).wrapInList(b,r).command(()=>op(i,b)).command(()=>lp(i,b)).run()},QT=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,l=ds(t,r.schema);return Kp(r,l,e)?s.unsetMark(l,{extendEmptyMarkRange:i}):s.setMark(l,e)},XT=(t,e,n={})=>({state:r,commands:s})=>{const i=rn(t,r.schema),l=rn(e,r.schema),c=Ys(r,i,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?s.setNode(l,u):s.setNode(i,{...u,...n})},ZT=(t,e={})=>({state:n,commands:r})=>{const s=rn(t,n.schema);return Ys(n,s,e)?r.lift(s):r.wrapIn(s,e)},eM=()=>({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 l=t.tr,c=i.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(i.text){const u=l.doc.resolve(i.from).marks();l.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else l.delete(i.from,i.to)}return!0}}return!1},tM=()=>({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},nM=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,u=ds(t,r.schema),{$from:f,empty:h,ranges:m}=c;if(!s)return!0;if(h&&l){let{from:y,to:b}=c;const v=(i=f.marks().find(k=>k.type===u))==null?void 0:i.attrs,w=Ph(f,u,v);w&&(y=w.from,b=w.to),n.removeMark(y,b,u)}else m.forEach(y=>{n.removeMark(y.$from.pos,y.$to.pos,u)});return n.removeStoredMark(u),!0},rM=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,l;return typeof t=="number"?(i=t,l=t):t&&"from"in t&&"to"in t?(i=t.from,l=t.to):(i=s.from,l=s.to),r&&e.doc.nodesBetween(i,l,(c,u)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(u,void 0,f)}),!0},sM=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,l=null;const c=Ju(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=rn(t,r.schema)),c==="mark"&&(l=ds(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let y,b,v,w;n.selection.empty?r.doc.nodesBetween(h,m,(k,N)=>{i&&i===k.type&&(u=!0,v=Math.max(N,h),w=Math.min(N+k.nodeSize,m),y=N,b=k)}):r.doc.nodesBetween(h,m,(k,N)=>{N<h&&i&&i===k.type&&(u=!0,v=Math.max(N,h),w=Math.min(N+k.nodeSize,m),y=N,b=k),N>=h&&N<=m&&(i&&i===k.type&&(u=!0,s&&n.setNodeMarkup(N,void 0,{...k.attrs,...e})),l&&k.marks.length&&k.marks.forEach(C=>{if(l===C.type&&(u=!0,s)){const O=Math.max(N,h),T=Math.min(N+k.nodeSize,m);n.addMark(O,T,l.create({...C.attrs,...e}))}}))}),b&&(y!==void 0&&s&&n.setNodeMarkup(y,void 0,{...b.attrs,...e}),l&&b.marks.length&&b.marks.forEach(k=>{l===k.type&&s&&n.addMark(v,w,l.create({...k.attrs,...e}))}))}),u},iM=(t,e={})=>({state:n,dispatch:r})=>{const s=rn(t,n.schema);return LN(s,e)(n,r)},oM=(t,e={})=>({state:n,dispatch:r})=>{const s=rn(t,n.schema);return DN(s,e)(n,r)},lM=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={}}},Yl=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},aM=(t,e)=>{if(Dh(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:l,plugin:c}=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(y=>y.type.spec.code))return!1;let h=!1;const m=jT(f)+i;return l.forEach(y=>{if(h)return;const b=aM(m,y.find);if(!b)return;const v=u.state.tr,w=Gu({state:u.state,transaction:v}),k={from:r-(b[0].length-i.length),to:s},{commands:N,chain:C,can:O}=new qu({editor:n,state:w});y.handler({state:w,range:k,match:b,commands:N,chain:C,can:O})===null||!v.steps.length||(y.undoable&&v.setMeta(c,{transform:v,from:r,to:s,text:i}),u.dispatch(v),h=!0)}),h}function cM(t){const{editor:e,rules:n}=t,r=new bt({state:{init(){return null},apply(s,i,l){const c=s.getMeta(r);if(c)return c;const u=s.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=Fh(le.from(h),l.schema);const{from:m}=u,y=m+h.length;dc({editor:e,from:m,to:y,text:h,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,l,c){return dc({editor:e,from:i,to:l,text:c,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:l}=s.state.selection;return l?dc({editor:e,from:l.pos,to:l.pos,text:`
|
|
60
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function uM(t){return Object.prototype.toString.call(t).slice(8,-1)}function fc(t){return uM(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Fw(t,e){const n={...t};return fc(t)&&fc(e)&&Object.keys(e).forEach(r=>{fc(e[r])&&fc(t[r])?n[r]=Fw(t[r],e[r]):n[r]=e[r]}),n}var Hh=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{...gt(Pe(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...gt(Pe(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fw(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}},Ar=class $w extends Hh{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new $w(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const l=s.marks();if(!!!l.find(f=>(f==null?void 0:f.type.name)===n.name))return!1;const u=l.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 dM(t){return typeof t=="number"}var fM=class{constructor(t){this.find=t.find,this.handler=t.handler}},pM=(t,e,n)=>{if(Dh(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 hM(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:l,dropEvent:c}=t,{commands:u,chain:f,can:h}=new qu({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(b,v)=>{var w,k,N,C,O;if((k=(w=b.type)==null?void 0:w.spec)!=null&&k.code||!(b.isText||b.isTextblock||b.isInline))return;const T=(O=(C=(N=b.content)==null?void 0:N.size)!=null?C:b.nodeSize)!=null?O:0,M=Math.max(r,v),R=Math.min(s,v+T);if(M>=R)return;const B=b.isText?b.text||"":b.textBetween(M-v,R-v,void 0,"");pM(B,i.find,l).forEach(z=>{if(z.index===void 0)return;const H=M+z.index+1,$=H+z[0].length,L={from:n.tr.mapping.map(H),to:n.tr.mapping.map($)},Y=i.handler({state:n,range:L,match:z,commands:u,chain:f,can:h,pasteEvent:l,dropEvent:c});m.push(Y)})}),m.every(b=>b!==null)}var pc=null,mM=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function gM(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:h,from:m,to:y,rule:b,pasteEvt:v})=>{const w=h.tr,k=Gu({state:h,transaction:w});if(!(!hM({editor:e,state:k,from:Math.max(m-1,0),to:y.b-1,rule:b,pasteEvent:v,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(h=>new bt({view(m){const y=v=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(v.target)?m.dom.parentElement:null,r&&(pc=e)},b=()=>{pc&&(pc=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(m,y)=>{if(i=r===m.dom.parentElement,c=y,!i){const b=pc;b!=null&&b.isEditable&&setTimeout(()=>{const v=b.state.selection;v&&b.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(m,y)=>{var b;const v=(b=y.clipboardData)==null?void 0:b.getData("text/html");return l=y,s=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,y,b)=>{const v=m[0],w=v.getMeta("uiEvent")==="paste"&&!s,k=v.getMeta("uiEvent")==="drop"&&!i,N=v.getMeta("applyPasteRules"),C=!!N;if(!w&&!k&&!C)return;if(C){let{text:M}=N;typeof M=="string"?M=M:M=Fh(le.from(M),b.schema);const{from:R}=N,B=R+M.length,U=mM(M);return u({rule:h,state:b,from:R,to:{b:B},pasteEvt:U})}const O=y.doc.content.findDiffStart(b.doc.content),T=y.doc.content.findDiffEnd(b.doc.content);if(!(!dM(O)||!T||O===T.b))return u({rule:h,state:b,from:O,to:T,pasteEvt:l})}}))}var Xu=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Iw(t),this.schema=_T(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:uc(e.name,this.schema)},r=Pe(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return nu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:uc(r.name,this.schema)},i=[],l=Pe(r,"addKeyboardShortcuts",s);let c={};if(r.type==="mark"&&Pe(r,"exitable",s)&&(c.ArrowRight=()=>Ar.handleExit({editor:t,mark:r})),l){const y=Object.fromEntries(Object.entries(l()).map(([b,v])=>[b,()=>v({editor:t})]));c={...c,...y}}const u=R_(c);i.push(u);const f=Pe(r,"addInputRules",s);if(ev(r,t.options.enableInputRules)&&f){const y=f();if(y&&y.length){const b=cM({editor:t,rules:y}),v=Array.isArray(b)?b:[b];i.push(...v)}}const h=Pe(r,"addPasteRules",s);if(ev(r,t.options.enablePasteRules)&&h){const y=h();if(y&&y.length){const b=gM({editor:t,rules:y});i.push(...b)}}const m=Pe(r,"addProseMirrorPlugins",s);if(m){const y=m();i.push(...y)}return i})}get attributes(){return Rw(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=_o(this.extensions);return Object.fromEntries(e.filter(n=>!!Pe(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:rn(n.name,this.schema)},i=Pe(n,"addNodeView",s);if(!i)return[];const l=i();if(!l)return[];const c=(u,f,h,m,y)=>{const b=Ul(u,r);return l({node:u,view:f,getPos:h,decorations:m,innerDecorations:y,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return nu([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:uc(s.name,this.schema)},l=Pe(s,"dispatchTransaction",i);return l?c=>{l.call(i,{transaction:c,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=_o(this.extensions);return Object.fromEntries(e.filter(n=>!!Pe(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ds(n.name,this.schema)},i=Pe(n,"addMarkView",s);if(!i)return[];const l=(c,u,f)=>{const h=Ul(c,r);return i()({mark:c,view:u,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{OM(c,t,m)}})};return[n.name,l]}))}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:uc(e.name,this.schema)};e.type==="mark"&&((n=gt(Pe(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=Pe(e,"onBeforeCreate",r),i=Pe(e,"onCreate",r),l=Pe(e,"onUpdate",r),c=Pe(e,"onSelectionUpdate",r),u=Pe(e,"onTransaction",r),f=Pe(e,"onFocus",r),h=Pe(e,"onBlur",r),m=Pe(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),f&&this.editor.on("focus",f),h&&this.editor.on("blur",h),m&&this.editor.on("destroy",m)})}};Xu.resolve=Iw;Xu.sort=nu;Xu.flatten=zh;var yM={};Lh(yM,{ClipboardTextSerializer:()=>Hw,Commands:()=>Ww,Delete:()=>Vw,Drop:()=>Kw,Editable:()=>Gw,FocusEvents:()=>Jw,Keymap:()=>Yw,Paste:()=>Qw,Tabindex:()=>Xw,TextDirection:()=>Zw,focusEventsPluginKey:()=>qw});var ft=class Uw extends Hh{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Uw(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Hw=ft.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new bt({key:new Ct("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,l=Math.min(...i.map(h=>h.$from.pos)),c=Math.max(...i.map(h=>h.$to.pos)),u=Lw(n);return jw(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),Ww=ft.create({name:"commands",addCommands(){return{...kw}}}),Vw=ft.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var l,c,u,f;if((f=(u=(c=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const h=Bh(t.before,[t,...e]);$h(h).forEach(b=>{h.mapping.mapResult(b.oldRange.from).deletedAfter&&h.mapping.mapResult(b.oldRange.to).deletedBefore&&h.before.nodesBetween(b.oldRange.from,b.oldRange.to,(v,w)=>{const k=w+v.nodeSize-2,N=b.oldRange.from<=w&&k<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:k,newFrom:h.mapping.map(w),newTo:h.mapping.map(k),deletedRange:b.oldRange,newRange:b.newRange,partial:!N,editor:this.editor,transaction:t,combinedTransform:h})})});const y=h.mapping;h.steps.forEach((b,v)=>{var w,k;if(b instanceof Tr){const N=y.slice(v).map(b.from,-1),C=y.slice(v).map(b.to),O=y.invert().map(N,-1),T=y.invert().map(C),M=(w=h.doc.nodeAt(N-1))==null?void 0:w.marks.some(B=>B.eq(b.mark)),R=(k=h.doc.nodeAt(C))==null?void 0:k.marks.some(B=>B.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:O,to:T},newRange:{from:N,to:C},partial:!!(R||M),editor:this.editor,transaction:t,combinedTransform:h})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),Kw=ft.create({name:"drop",addProseMirrorPlugins(){return[new bt({key:new Ct("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Gw=ft.create({name:"editable",addProseMirrorPlugins(){return[new bt({key:new Ct("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qw=new Ct("focusEvents"),Jw=ft.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new bt({key:qw,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}}}})]}}),Yw=ft.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:f}=c,{empty:h,$anchor:m}=u,{pos:y,parent:b}=m,v=m.parent.isTextblock&&y>0?c.doc.resolve(y-1):m,w=v.parent.type.spec.isolating,k=m.pos-m.parentOffset,N=w&&v.parent.childCount===1?k===m.pos:Ye.atStart(f).from===y;return!h||!b.type.isTextblock||b.textContent.length||!N||N&&m.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.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 eu()||_w()?i:s},addProseMirrorPlugins(){return[new bt({key:new Ct("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),s=t.some(w=>w.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:l,to:c}=e.selection,u=Ye.atStart(e.doc).from,f=Ye.atEnd(e.doc).to;if(i||!(l===u&&c===f)||!Qu(n.doc))return;const y=n.tr,b=Gu({state:n,transaction:y}),{commands:v}=new qu({editor:this.editor,state:b});if(v.clearNodes(),!!y.steps.length)return y}})]}}),Qw=ft.create({name:"paste",addProseMirrorPlugins(){return[new bt({key:new Ct("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Xw=ft.create({name:"tabindex",addProseMirrorPlugins(){return[new bt({key:new Ct("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Zw=ft.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=_o(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 bt({key:new Ct("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),bM=class kl{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 kl(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 kl(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 kl(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,l=n.isInline,c=this.pos+r+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!s&&!l&&u.depth<=this.depth)return;const f=new kl(u,this.editor,s,s||l?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,l=Object.keys(n);for(let c=0;c<l.length;c+=1){const u=l[c];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(l=>{r&&s.length>0||(l.node.type.name===e&&i.every(u=>n[u]===l.node.attrs[u])&&s.push(l),!(r&&s.length>0)&&(s=s.concat(l.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)}},vM=`.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 xM(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 wM=class extends lM{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:BT,createMappablePosition:zT},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=Nw(e,this.options.autofocus);this.editorState=vo.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=xM(vM,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=Ow(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(l=>!l.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?[Gw,Hw.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ww,Jw,Yw,Xw,Kw,Qw,Vw,Zw.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 Xu(r,this)}createCommandManager(){this.commandManager=new qu({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Vp(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=Vp(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 ww(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 l=this.view.dom;l.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 h;return(h=this.capturedTransaction)==null?void 0:h.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 l=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),u=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),u&&this.emit("blur",{editor:this,event:u.event,transaction:l}),!(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 Dw(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return LT(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Fh(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
131
|
+
|
|
132
|
+
`,textSerializers:n={}}=t||{};return MT(this.state.doc,{blockSeparator:e,textSerializers:{...Lw(this.schema),...n}})}get isEmpty(){return Qu(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 bM(e,this)}get $doc(){return this.$pos(0)}};function ji(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=gt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,l=r[r.length-1],c=r[0];if(l){const u=c.search(/\S/),f=n.from+c.indexOf(l),h=f+l.length;if(Uh(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>f).length)return null;h<n.to&&i.delete(h,n.to),f>n.from&&i.delete(n.from+u,f);const y=n.from+u+l.length;i.addMark(n.from+u,y,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function ek(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=gt(t.getAttributes,void 0,r)||{},{tr:i}=e,l=n.from;let c=n.to;const u=t.type.create(s);if(r[1]){const f=r[0].lastIndexOf(r[1]);let h=l+f;h>c?h=c:c=h+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,l+r[0].length-1),i.replaceWith(h,c,u)}else if(r[0]){const f=t.type.isInline?l:l-1;i.insert(f,t.type.create(s)).delete(i.mapping.map(l),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function Gp(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=gt(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 Gt(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const l=n.to;if(r[1]){const c=r[0].lastIndexOf(r[1]);s+=r[0].slice(c+r[1].length),i+=c;const u=i-l;u>0&&(s=r[0].slice(c-u,c)+s,i=l)}e.tr.insertText(s,i,l)},undoable:t.undoable})}function To(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=gt(t.getAttributes,void 0,r)||{},l=e.tr.delete(n.from,n.to),u=l.doc.resolve(n.from).blockRange(),f=u&&yh(u,t.type,i);if(!f)return null;if(l.wrap(u,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:y}=e,{splittableMarks:b}=t.editor.extensionManager,v=y||m.$to.parentOffset&&m.$from.marks();if(v){const w=v.filter(k=>b.includes(k.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(m,i).run()}const h=l.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&Xs(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&l.join(n.from-1)},undoable:t.undoable})}var kM=t=>"touches"in t,SM=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=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,f=c.clientY-this.startY;this.handleResize(u,f)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const f=u.clientX-this.startX,h=u.clientY-this.startY;this.handleResize(f,h)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,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=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,l;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||""}),(l=t.options)!=null&&l.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,kM(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"),l=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?r=this.startWidth+e:l&&(r=this.startWidth-e),c?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+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,l;if(!n){let f=Math.max(this.minSize.width,t),h=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&&(h=Math.min(this.maxSize.height,h)),{width:f,height:h}}let c=t,u=e;return c<this.minSize.width&&(c=this.minSize.width,u=c/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,c=u*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&c>this.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(l=this.maxSize)!=null&&l.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,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 EM(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ze){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 NM={};Lh(NM,{createAtomBlockMarkdownSpec:()=>CM,createBlockMarkdownSpec:()=>_M,createInlineMarkdownSpec:()=>AM,parseAttributes:()=>Wh,parseIndentedBlocks:()=>qp,renderNestedMarkdownContent:()=>Kh,serializeAttributes:()=>Vh});function Wh(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(h=>h.trim().slice(1));e.class=f.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,f,h])=>{var m;const y=parseInt(((m=h.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[y];b&&(e[f]=b.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(h=>{h.match(/^[a-zA-Z][\w-]*$/)&&(e[h]=!0)}),e}function Vh(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 CM(t){const{nodeName:e,name:n,parseAttributes:r=Wh,serializeAttributes:s=Vh,defaultAttributes:i={},requiredAttributes:l=[],allowedAttributes:c}=t,u=n||e,f=h=>{if(!c)return h;const m={};return c.forEach(y=>{y in h&&(m[y]=h[y])}),m};return{parseMarkdown:(h,m)=>{const y={...i,...h.attributes};return m.createNode(e,y,[])},markdownTokenizer:{name:e,level:"block",start(h){var m;const y=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(m=h.match(y))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(h,m,y){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=h.match(b);if(!v)return;const w=v[1]||"",k=r(w);if(!l.find(C=>!(C in k)))return{type:e,raw:v[0],attributes:k}}},renderMarkdown:h=>{const m=f(h.attrs||{}),y=s(m),b=y?` {${y}}`:"";return`:::${u}${b} :::`}}}function _M(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Wh,serializeAttributes:i=Vh,defaultAttributes:l={},content:c="block",allowedAttributes:u}=t,f=n||e,h=m=>{if(!u)return m;const y={};return u.forEach(b=>{b in m&&(y[b]=m[b])}),y};return{parseMarkdown:(m,y)=>{let b;if(r){const w=r(m);b=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?b=y.parseChildren(m.tokens||[]):b=y.parseInline(m.tokens||[]);const v={...l,...m.attributes};return y.createNode(e,v,b)},markdownTokenizer:{name:e,level:"block",start(m){var y;const b=new RegExp(`^:::${f}`,"m"),v=(y=m.match(b))==null?void 0:y.index;return v!==void 0?v:-1},tokenize(m,y,b){var v;const w=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),k=m.match(w);if(!k)return;const[N,C=""]=k,O=s(C);let T=1;const M=N.length;let R="";const B=/^:::([\w-]*)(\s.*)?/gm,U=m.slice(M);for(B.lastIndex=0;;){const z=B.exec(U);if(z===null)break;const H=z.index,$=z[1];if(!((v=z[2])!=null&&v.endsWith(":::"))){if($)T+=1;else if(T-=1,T===0){const L=U.slice(0,H);R=L.trim();const Y=m.slice(0,M+H+z[0].length);let Q=[];if(R)if(c==="block")for(Q=b.blockTokens(L),Q.forEach(ee=>{ee.text&&(!ee.tokens||ee.tokens.length===0)&&(ee.tokens=b.inlineTokens(ee.text))});Q.length>0;){const ee=Q[Q.length-1];if(ee.type==="paragraph"&&(!ee.text||ee.text.trim()===""))Q.pop();else break}else Q=b.inlineTokens(R);return{type:e,raw:Y,attributes:O,content:R,tokens:Q}}}}}},renderMarkdown:(m,y)=>{const b=h(m.attrs||{}),v=i(b),w=v?` {${v}}`:"",k=y.renderChildren(m.content||[],`
|
|
133
|
+
|
|
134
|
+
`);return`:::${f}${w}
|
|
135
|
+
|
|
136
|
+
${k}
|
|
137
|
+
|
|
138
|
+
:::`}}}function TM(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,l]=r;e[s]=i||l,r=n.exec(t)}return e}function MM(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function AM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=TM,serializeAttributes:i=MM,defaultAttributes:l={},selfClosing:c=!1,allowedAttributes:u}=t,f=n||e,h=y=>{if(!u)return y;const b={};return u.forEach(v=>{const w=typeof v=="string"?v:v.name,k=typeof v=="string"?void 0:v.skipIfDefault;if(w in y){const N=y[w];if(k!==void 0&&N===k)return;b[w]=N}}),b},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(y,b)=>{const v={...l,...y.attributes};if(c)return b.createNode(e,v);const w=r?r(y):y.content||"";return w?b.createNode(e,v,[b.createTextNode(w)]):b.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(y){const b=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),v=y.match(b),w=v==null?void 0:v.index;return w!==void 0?w:-1},tokenize(y,b,v){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),k=y.match(w);if(!k)return;let N="",C="";if(c){const[,T]=k;C=T}else{const[,T,M]=k;C=T,N=M||""}const O=s(C.trim());return{type:e,raw:k[0],content:N.trim(),attributes:O}}},renderMarkdown:y=>{let b="";r?b=r(y):y.content&&y.content.length>0&&(b=y.content.filter(N=>N.type==="text").map(N=>N.text).join(""));const v=h(y.attrs||{}),w=i(v),k=w?` ${w}`:"";return c?`[${f}${k}]`:`[${f}${k}]${b}[/${f}]`}}}function qp(t,e,n){var r,s,i,l;const c=t.split(`
|
|
139
|
+
`),u=[];let f="",h=0;const m=e.baseIndentSize||2;for(;h<c.length;){const y=c[h],b=y.match(e.itemPattern);if(!b){if(u.length>0)break;if(y.trim()===""){h+=1,f=`${f}${y}
|
|
140
|
+
`;continue}else return}const v=e.extractItemData(b),{indentLevel:w,mainContent:k}=v;f=`${f}${y}
|
|
141
|
+
`;const N=[k];for(h+=1;h<c.length;){const M=c[h];if(M.trim()===""){const B=c.slice(h+1).findIndex(H=>H.trim()!=="");if(B===-1)break;if((((s=(r=c[h+1+B].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>w){N.push(M),f=`${f}${M}
|
|
142
|
+
`,h+=1;continue}else break}if((((l=(i=M.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:l.length)||0)>w)N.push(M),f=`${f}${M}
|
|
143
|
+
`,h+=1;else break}let C;const O=N.slice(1);if(O.length>0){const M=O.map(R=>R.slice(w+m)).join(`
|
|
144
|
+
`);M.trim()&&(e.customNestedParser?C=e.customNestedParser(M):C=n.blockTokens(M))}const T=e.createToken(v,C);u.push(T)}if(u.length!==0)return{items:u,raw:f}}function Kh(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...l]=t.content,c=e.renderChildren([i]),u=[`${s}${c}`];return l&&l.length>0&&l.forEach(f=>{const h=e.renderChildren([f]);if(h){const m=h.split(`
|
|
145
|
+
`).map(y=>y?e.indent(y):"").join(`
|
|
146
|
+
`);u.push(m)}}),u.join(`
|
|
147
|
+
`)}function OM(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,l=t;s.descendants((c,u)=>{const f=i.mapping.map(u),h=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(b=>{if(b!==l)return!1;m=b}),!m)return;let y=!1;if(Object.keys(n).forEach(b=>{n[b]!==m.attrs[b]&&(y=!0)}),y){const b=t.type.create({...t.attrs,...n});i.removeMark(f,h,t.type),i.addMark(f,h,b)}}),i.docChanged&&e.view.dispatch(i)}var gn=class tk extends Hh{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new tk(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Qs(t){return new fM({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=gt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:l}=e,c=r[r.length-1],u=r[0];let f=n.to;if(c){const h=u.search(/\S/),m=n.from+u.indexOf(c),y=m+c.length;if(Uh(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(k=>k===t.type&&k!==v.mark.type)).filter(v=>v.to>m).length)return null;y<n.to&&l.delete(y,n.to),m>n.from&&l.delete(n.from+h,m),f=n.from+h+c.length,l.addMark(n.from+h,f,t.type.create(i||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:RM,getOwnPropertySymbols:IM}=Object,{hasOwnProperty:jM}=Object.prototype;function ap(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function hc(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,l=i.get(n),c=i.get(r);if(l&&c)return l===r&&c===n;i.set(n,r),i.set(r,n);const u=t(n,r,s);return i.delete(n),i.delete(r),u}}function LM(t){return t!=null?t[Symbol.toStringTag]:void 0}function rv(t){return RM(t).concat(IM(t))}const DM=Object.hasOwn||((t,e)=>jM.call(t,e));function Bi(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const PM="__v",BM="__o",zM="_owner",{getOwnPropertyDescriptor:sv,keys:iv}=Object;function FM(t,e){return t.byteLength===e.byteLength&&ru(new Uint8Array(t),new Uint8Array(e))}function $M(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 UM(t,e){return t.byteLength===e.byteLength&&ru(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function HM(t,e){return Bi(t.getTime(),e.getTime())}function WM(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function VM(t,e){return t===e}function ov(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 l,c,u=0;for(;(l=i.next())&&!l.done;){const f=e.entries();let h=!1,m=0;for(;(c=f.next())&&!c.done;){if(s[m]){m++;continue}const y=l.value,b=c.value;if(n.equals(y[0],b[0],u,m,t,e,n)&&n.equals(y[1],b[1],y[0],b[0],t,e,n)){h=s[m]=!0;break}m++}if(!h)return!1;u++}return!0}const KM=Bi;function GM(t,e,n){const r=iv(t);let s=r.length;if(iv(e).length!==s)return!1;for(;s-- >0;)if(!nk(t,e,n,r[s]))return!1;return!0}function ml(t,e,n){const r=rv(t);let s=r.length;if(rv(e).length!==s)return!1;let i,l,c;for(;s-- >0;)if(i=r[s],!nk(t,e,n,i)||(l=sv(t,i),c=sv(e,i),(l||c)&&(!l||!c||l.configurable!==c.configurable||l.enumerable!==c.enumerable||l.writable!==c.writable)))return!1;return!0}function qM(t,e){return Bi(t.valueOf(),e.valueOf())}function JM(t,e){return t.source===e.source&&t.flags===e.flags}function lv(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 l,c;for(;(l=i.next())&&!l.done;){const u=e.values();let f=!1,h=0;for(;(c=u.next())&&!c.done;){if(!s[h]&&n.equals(l.value,c.value,l.value,c.value,t,e,n)){f=s[h]=!0;break}h++}if(!f)return!1}return!0}function ru(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 YM(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 nk(t,e,n,r){return(r===zM||r===BM||r===PM)&&(t.$$typeof||e.$$typeof)?!0:DM(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const QM="[object ArrayBuffer]",XM="[object Arguments]",ZM="[object Boolean]",eA="[object DataView]",tA="[object Date]",nA="[object Error]",rA="[object Map]",sA="[object Number]",iA="[object Object]",oA="[object RegExp]",lA="[object Set]",aA="[object String]",cA={"[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},uA="[object URL]",dA=Object.prototype.toString;function fA({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:l,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:f,areRegExpsEqual:h,areSetsEqual:m,areTypedArraysEqual:y,areUrlsEqual:b,unknownTagComparators:v}){return function(k,N,C){if(k===N)return!0;if(k==null||N==null)return!1;const O=typeof k;if(O!==typeof N)return!1;if(O!=="object")return O==="number"?c(k,N,C):O==="function"?i(k,N,C):!1;const T=k.constructor;if(T!==N.constructor)return!1;if(T===Object)return u(k,N,C);if(Array.isArray(k))return e(k,N,C);if(T===Date)return r(k,N,C);if(T===RegExp)return h(k,N,C);if(T===Map)return l(k,N,C);if(T===Set)return m(k,N,C);const M=dA.call(k);if(M===tA)return r(k,N,C);if(M===oA)return h(k,N,C);if(M===rA)return l(k,N,C);if(M===lA)return m(k,N,C);if(M===iA)return typeof k.then!="function"&&typeof N.then!="function"&&u(k,N,C);if(M===uA)return b(k,N,C);if(M===nA)return s(k,N,C);if(M===XM)return u(k,N,C);if(cA[M])return y(k,N,C);if(M===QM)return t(k,N,C);if(M===eA)return n(k,N,C);if(M===ZM||M===sA||M===aA)return f(k,N,C);if(v){let R=v[M];if(!R){const B=LM(k);B&&(R=v[B])}if(R)return R(k,N,C)}return!1}}function pA({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:FM,areArraysEqual:n?ml:$M,areDataViewsEqual:UM,areDatesEqual:HM,areErrorsEqual:WM,areFunctionsEqual:VM,areMapsEqual:n?ap(ov,ml):ov,areNumbersEqual:KM,areObjectsEqual:n?ml:GM,arePrimitiveWrappersEqual:qM,areRegExpsEqual:JM,areSetsEqual:n?ap(lv,ml):lv,areTypedArraysEqual:n?ap(ru,ml):ru,areUrlsEqual:YM,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=hc(r.areArraysEqual),i=hc(r.areMapsEqual),l=hc(r.areObjectsEqual),c=hc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:l,areSetsEqual:c})}return r}function hA(t){return function(e,n,r,s,i,l,c){return t(e,n,c)}}function mA({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(c,u){const{cache:f=t?new WeakMap:void 0,meta:h}=n();return e(c,u,{cache:f,equals:r,meta:h,strict:s})};if(t)return function(c,u){return e(c,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(c,u){return e(c,u,i)}}const gA=ei();ei({strict:!0});ei({circular:!0});ei({circular:!0,strict:!0});ei({createInternalComparator:()=>Bi});ei({strict:!0,createInternalComparator:()=>Bi});ei({circular:!0,createInternalComparator:()=>Bi});ei({circular:!0,createInternalComparator:()=>Bi,strict:!0});function ei(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=pA(t),l=fA(i),c=n?n(l):hA(l);return mA({circular:e,comparator:l,createState:r,equals:c,strict:s})}var cp={exports:{}},up={};/**
|
|
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 av;function yA(){if(av)return up;av=1;var t=Kl(),e=G0();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,l=t.useEffect,c=t.useMemo,u=t.useDebugValue;return up.useSyncExternalStoreWithSelector=function(f,h,m,y,b){var v=i(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=c(function(){function N(R){if(!C){if(C=!0,O=R,R=y(R),b!==void 0&&w.hasValue){var B=w.value;if(b(B,R))return T=B}return T=R}if(B=T,r(O,R))return B;var U=y(R);return b!==void 0&&b(B,U)?(O=R,B):(O=R,T=U)}var C=!1,O,T,M=m===void 0?null:m;return[function(){return N(h())},M===null?void 0:function(){return N(M())}]},[h,m,y,b]);var k=s(f,v[0],v[1]);return l(function(){w.hasValue=!0,w.value=k},[k]),u(k),k},up}var cv;function bA(){return cv||(cv=1,cp.exports=yA()),cp.exports}var vA=bA(),xA=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},wA=({contentComponent:t})=>{const e=q0.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return d.jsx(d.Fragment,{children:Object.values(e)})};function kA(){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]:_E.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 SA=class extends qs.Component{constructor(t){var e;super(t),this.editorContentRef=qs.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=kA(),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:xA(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&d.jsx(wA,{contentComponent:t.contentComponent})]})}},EA=E.forwardRef((t,e)=>{const n=qs.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return qs.createElement(SA,{key:n,innerRef:e,...t})}),Gh=qs.memo(EA),NA=typeof window<"u"?E.useLayoutEffect:E.useEffect,CA=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 _A(t){var e;const[n]=E.useState(()=>new CA(t.editor)),r=vA.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:gA);return NA(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var TA=!1,Jp=typeof window>"u",MA=Jp||!!(typeof window<"u"&&window.next),AA=class rk{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?Jp||MA?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 wM(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 l;return s===((l=n.extensions)==null?void 0:l[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?rk.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 sk(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new AA(n)),s=q0.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),_A({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var ik=E.createContext({editor:null});ik.Consumer;var OA=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),RA=()=>E.useContext(OA);qs.forwardRef((t,e)=>{const{onDragStart:n}=RA(),r=t.as||"div";return d.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});qs.createContext({markViewContentRef:()=>{}});var qh=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});qh.displayName="TiptapContext";var IA=()=>E.useContext(qh);function ok({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=E.useMemo(()=>({editor:r}),[r]),i=E.useMemo(()=>({editor:r}),[r]);return d.jsx(ik.Provider,{value:i,children:d.jsx(qh.Provider,{value:s,children:n})})}ok.displayName="Tiptap";function lk({...t}){const{editor:e}=IA();return d.jsx(Gh,{editor:e,...t})}lk.displayName="Tiptap.Content";Object.assign(ok,{Content:lk});var jA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,LA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,DA=Ar.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",yt(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(),l=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:l}}}},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[ji({find:jA,type:this.type})]},addPasteRules(){return[Qs({find:LA,type:this.type})]}}),PA=DA,BA=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,zA=gn.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",yt(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,l;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",f=(l=(i=t.attrs)==null?void 0:i.title)!=null?l:"";return f?``:``},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:l,editor:c})=>{const u=document.createElement("img");Object.entries(l).forEach(([m,y])=>{if(y!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,y);break}}),u.src=l.src;const f=new SM({element:u,editor:c,node:s,getPos:i,onResize:(m,y)=>{u.style.width=`${m}px`,u.style.height=`${y}px`},onCommit:(m,y)=>{const b=i();b!==void 0&&this.editor.chain().setNodeSelection(b).updateAttributes(this.name,{width:m,height:y}).run()},onUpdate:(m,y,b)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),h=f.dom;return h.style.visibility="hidden",h.style.pointerEvents="none",u.onload=()=>{h.style.visibility="",h.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ek({find:BA,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Jh=zA;const FA="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",$A="ελ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",Yp="numeric",Qp="ascii",Xp="alpha",Tl="asciinumeric",Sl="alphanumeric",Zp="domain",ak="emoji",UA="scheme",HA="slashscheme",dp="whitespace";function WA(t,e){return t in e||(e[t]=[]),e[t]}function Ei(t,e,n){e[Yp]&&(e[Tl]=!0,e[Sl]=!0),e[Qp]&&(e[Tl]=!0,e[Xp]=!0),e[Tl]&&(e[Sl]=!0),e[Xp]&&(e[Sl]=!0),e[Sl]&&(e[Zp]=!0),e[ak]&&(e[Zp]=!0);for(const r in e){const s=WA(r,n);s.indexOf(t)<0&&s.push(t)}}function VA(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Jn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Jn.groups={};Jn.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||Jn.groups;let s;return e&&e.j?s=e:(s=new Jn(e),n&&r&&Ei(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 l=0;l<i-1;l++)s=s.tt(t[l]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Jn.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let l,c=s.go(t);if(c?(l=new Jn,Object.assign(l.j,c.j),l.jr.push.apply(l.jr,c.jr),l.jd=c.jd,l.t=c.t):l=new Jn,i){if(r)if(l.t&&typeof l.t=="string"){const u=Object.assign(VA(l.t,r),n);Ei(i,u,r)}else n&&Ei(i,n,r);l.t=i}return s.j[t]=l,l}};const st=(t,e,n,r,s)=>t.ta(e,n,r,s),Wt=(t,e,n,r,s)=>t.tr(e,n,r,s),uv=(t,e,n,r,s)=>t.ts(e,n,r,s),ge=(t,e,n,r,s)=>t.tt(e,n,r,s),ss="WORD",eh="UWORD",ck="ASCIINUMERICAL",uk="ALPHANUMERICAL",Hl="LOCALHOST",th="TLD",nh="UTLD",Pc="SCHEME",go="SLASH_SCHEME",Yh="NUM",rh="WS",Qh="NL",Ml="OPENBRACE",Al="CLOSEBRACE",su="OPENBRACKET",iu="CLOSEBRACKET",ou="OPENPAREN",lu="CLOSEPAREN",au="OPENANGLEBRACKET",cu="CLOSEANGLEBRACKET",uu="FULLWIDTHLEFTPAREN",du="FULLWIDTHRIGHTPAREN",fu="LEFTCORNERBRACKET",pu="RIGHTCORNERBRACKET",hu="LEFTWHITECORNERBRACKET",mu="RIGHTWHITECORNERBRACKET",gu="FULLWIDTHLESSTHAN",yu="FULLWIDTHGREATERTHAN",bu="AMPERSAND",vu="APOSTROPHE",xu="ASTERISK",Ls="AT",wu="BACKSLASH",ku="BACKTICK",Su="CARET",Bs="COLON",Xh="COMMA",Eu="DOLLAR",Fr="DOT",Nu="EQUALS",Zh="EXCLAMATION",hr="HYPHEN",Ol="PERCENT",Cu="PIPE",_u="PLUS",Tu="POUND",Rl="QUERY",em="QUOTE",dk="FULLWIDTHMIDDLEDOT",tm="SEMI",$r="SLASH",Il="TILDE",Mu="UNDERSCORE",fk="EMOJI",Au="SYM";var pk=Object.freeze({__proto__:null,ALPHANUMERICAL:uk,AMPERSAND:bu,APOSTROPHE:vu,ASCIINUMERICAL:ck,ASTERISK:xu,AT:Ls,BACKSLASH:wu,BACKTICK:ku,CARET:Su,CLOSEANGLEBRACKET:cu,CLOSEBRACE:Al,CLOSEBRACKET:iu,CLOSEPAREN:lu,COLON:Bs,COMMA:Xh,DOLLAR:Eu,DOT:Fr,EMOJI:fk,EQUALS:Nu,EXCLAMATION:Zh,FULLWIDTHGREATERTHAN:yu,FULLWIDTHLEFTPAREN:uu,FULLWIDTHLESSTHAN:gu,FULLWIDTHMIDDLEDOT:dk,FULLWIDTHRIGHTPAREN:du,HYPHEN:hr,LEFTCORNERBRACKET:fu,LEFTWHITECORNERBRACKET:hu,LOCALHOST:Hl,NL:Qh,NUM:Yh,OPENANGLEBRACKET:au,OPENBRACE:Ml,OPENBRACKET:su,OPENPAREN:ou,PERCENT:Ol,PIPE:Cu,PLUS:_u,POUND:Tu,QUERY:Rl,QUOTE:em,RIGHTCORNERBRACKET:pu,RIGHTWHITECORNERBRACKET:mu,SCHEME:Pc,SEMI:tm,SLASH:$r,SLASH_SCHEME:go,SYM:Au,TILDE:Il,TLD:th,UNDERSCORE:Mu,UTLD:nh,UWORD:eh,WORD:ss,WS:rh});const ns=/[a-z]/,gl=new RegExp("\\p{L}","u"),fp=new RegExp("\\p{Emoji}","u"),rs=/\d/,pp=/\s/,dv="\r",hp=`
|
|
156
|
+
`,KA="️",GA="",mp="";let mc=null,gc=null;function qA(t=[]){const e={};Jn.groups=e;const n=new Jn;mc==null&&(mc=fv(FA)),gc==null&&(gc=fv($A)),ge(n,"'",vu),ge(n,"{",Ml),ge(n,"}",Al),ge(n,"[",su),ge(n,"]",iu),ge(n,"(",ou),ge(n,")",lu),ge(n,"<",au),ge(n,">",cu),ge(n,"(",uu),ge(n,")",du),ge(n,"「",fu),ge(n,"」",pu),ge(n,"『",hu),ge(n,"』",mu),ge(n,"<",gu),ge(n,">",yu),ge(n,"&",bu),ge(n,"*",xu),ge(n,"@",Ls),ge(n,"`",ku),ge(n,"^",Su),ge(n,":",Bs),ge(n,",",Xh),ge(n,"$",Eu),ge(n,".",Fr),ge(n,"=",Nu),ge(n,"!",Zh),ge(n,"-",hr),ge(n,"%",Ol),ge(n,"|",Cu),ge(n,"+",_u),ge(n,"#",Tu),ge(n,"?",Rl),ge(n,'"',em),ge(n,"/",$r),ge(n,";",tm),ge(n,"~",Il),ge(n,"_",Mu),ge(n,"\\",wu),ge(n,"・",dk);const r=Wt(n,rs,Yh,{[Yp]:!0});Wt(r,rs,r);const s=Wt(r,ns,ck,{[Tl]:!0}),i=Wt(r,gl,uk,{[Sl]:!0}),l=Wt(n,ns,ss,{[Qp]:!0});Wt(l,rs,s),Wt(l,ns,l),Wt(s,rs,s),Wt(s,ns,s);const c=Wt(n,gl,eh,{[Xp]:!0});Wt(c,ns),Wt(c,rs,i),Wt(c,gl,c),Wt(i,rs,i),Wt(i,ns),Wt(i,gl,i);const u=ge(n,hp,Qh,{[dp]:!0}),f=ge(n,dv,rh,{[dp]:!0}),h=Wt(n,pp,rh,{[dp]:!0});ge(n,mp,h),ge(f,hp,u),ge(f,mp,h),Wt(f,pp,h),ge(h,dv),ge(h,hp),Wt(h,pp,h),ge(h,mp,h);const m=Wt(n,fp,fk,{[ak]:!0});ge(m,"#"),Wt(m,fp,m),ge(m,KA,m);const y=ge(m,GA);ge(y,"#"),Wt(y,fp,m);const b=[[ns,l],[rs,s]],v=[[ns,null],[gl,c],[rs,i]];for(let w=0;w<mc.length;w++)Rs(n,mc[w],th,ss,b);for(let w=0;w<gc.length;w++)Rs(n,gc[w],nh,eh,v);Ei(th,{tld:!0,ascii:!0},e),Ei(nh,{utld:!0,alpha:!0},e),Rs(n,"file",Pc,ss,b),Rs(n,"mailto",Pc,ss,b),Rs(n,"http",go,ss,b),Rs(n,"https",go,ss,b),Rs(n,"ftp",go,ss,b),Rs(n,"ftps",go,ss,b),Ei(Pc,{scheme:!0,ascii:!0},e),Ei(go,{slashscheme:!0,ascii:!0},e),t=t.sort((w,k)=>w[0]>k[0]?1:-1);for(let w=0;w<t.length;w++){const k=t[w][0],C=t[w][1]?{[UA]:!0}:{[HA]:!0};k.indexOf("-")>=0?C[Zp]=!0:ns.test(k)?rs.test(k)?C[Tl]=!0:C[Qp]=!0:C[Yp]=!0,uv(n,k,k,C)}return uv(n,"localhost",Hl,{ascii:!0}),n.jd=new Jn(Au),{start:n,tokens:Object.assign({groups:e},pk)}}function hk(t,e){const n=JA(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,s=[];let i=0,l=0;for(;l<r;){let c=t,u=null,f=0,h=null,m=-1,y=-1;for(;l<r&&(u=c.go(n[l]));)c=u,c.accepts()?(m=0,y=0,h=c):m>=0&&(m+=n[l].length,y++),f+=n[l].length,i+=n[l].length,l++;i-=m,l-=y,f-=m,s.push({t:h.t,v:e.slice(i-f,i),s:i-f,e:i})}return s}function JA(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,l=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(l),r+=l.length}return e}function Rs(t,e,n,r,s){let i;const l=e.length;for(let c=0;c<l-1;c++){const u=e[c];t.j[u]?i=t.j[u]:(i=new Jn(r),i.jr=s.slice(),t.j[u]=i),t=i}return i=new Jn(n),i.jr=s.slice(),t.j[e[l-1]]=i,i}function fv(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 l=parseInt(t.substring(r,r+i),10);l>0;l--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Wl={defaultProtocol:"http",events:null,format:pv,formatHref:pv,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function nm(t,e=null){let n=Object.assign({},Wl);t&&(n=Object.assign(n,t instanceof nm?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}nm.prototype={o:Wl,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]:Wl[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 pv(t){return t}function mk(t,e){this.t="token",this.v=t,this.tk=e}mk.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=Wl.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),l={},c=t.get("className",n,e),u=t.get("target",n,e),f=t.get("rel",n,e),h=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return l.href=r,c&&(l.class=c),u&&(l.target=u),f&&(l.rel=f),h&&Object.assign(l,h),{tagName:s,attributes:l,content:i,eventListeners:m}}};function Zu(t,e){class n extends mk{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 hv=Zu("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),mv=Zu("text"),YA=Zu("nl"),yc=Zu("url",{isLink:!0,toHref(t=Wl.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Hl&&t[1].t===Bs}}),pr=t=>new Jn(t);function QA({groups:t}){const e=t.domain.concat([bu,xu,Ls,wu,ku,Su,Eu,Nu,hr,Yh,Ol,Cu,_u,Tu,$r,Au,Il,Mu]),n=[vu,Bs,Xh,Fr,Zh,Ol,Rl,em,tm,au,cu,Ml,Al,iu,su,ou,lu,uu,du,fu,pu,hu,mu,gu,yu],r=[bu,vu,xu,wu,ku,Su,Eu,Nu,hr,Ml,Al,Ol,Cu,_u,Tu,Rl,$r,Au,Il,Mu],s=pr(),i=ge(s,Il);st(i,r,i),st(i,t.domain,i);const l=pr(),c=pr(),u=pr();st(s,t.domain,l),st(s,t.scheme,c),st(s,t.slashscheme,u),st(l,r,i),st(l,t.domain,l);const f=ge(l,Ls);ge(i,Ls,f),ge(c,Ls,f),ge(u,Ls,f);const h=ge(i,Fr);st(h,r,i),st(h,t.domain,i);const m=pr();st(f,t.domain,m),st(m,t.domain,m);const y=ge(m,Fr);st(y,t.domain,m);const b=pr(hv);st(y,t.tld,b),st(y,t.utld,b),ge(f,Hl,b);const v=ge(m,hr);ge(v,hr,v),st(v,t.domain,m),st(b,t.domain,m),ge(b,Fr,y),ge(b,hr,v);const w=ge(b,Bs);st(w,t.numeric,hv);const k=ge(l,hr),N=ge(l,Fr);ge(k,hr,k),st(k,t.domain,l),st(N,r,i),st(N,t.domain,l);const C=pr(yc);st(N,t.tld,C),st(N,t.utld,C),st(C,t.domain,l),st(C,r,i),ge(C,Fr,N),ge(C,hr,k),ge(C,Ls,f);const O=ge(C,Bs),T=pr(yc);st(O,t.numeric,T);const M=pr(yc),R=pr();st(M,e,M),st(M,n,R),st(R,e,M),st(R,n,R),ge(C,$r,M),ge(T,$r,M);const B=ge(c,Bs),U=ge(u,Bs),z=ge(U,$r),H=ge(z,$r);st(c,t.domain,l),ge(c,Fr,N),ge(c,hr,k),st(u,t.domain,l),ge(u,Fr,N),ge(u,hr,k),st(B,t.domain,M),ge(B,$r,M),ge(B,Rl,M),st(H,t.domain,M),st(H,e,M),ge(H,$r,M);const $=[[Ml,Al],[su,iu],[ou,lu],[au,cu],[uu,du],[fu,pu],[hu,mu],[gu,yu]];for(let L=0;L<$.length;L++){const[Y,Q]=$[L],ee=ge(M,Y);ge(R,Y,ee),ge(ee,Q,M);const G=pr(yc);st(ee,e,G);const ne=pr();st(ee,n),st(G,e,G),st(G,n,ne),st(ne,e,G),st(ne,n,ne),ge(G,Q,M),ge(ne,Q,M)}return ge(s,Hl,C),ge(s,Qh,YA),{start:s,tokens:pk}}function XA(t,e,n){let r=n.length,s=0,i=[],l=[];for(;s<r;){let c=t,u=null,f=null,h=0,m=null,y=-1;for(;s<r&&!(u=c.go(n[s].t));)l.push(n[s++]);for(;s<r&&(f=u||c.go(n[s].t));)u=null,c=f,c.accepts()?(y=0,m=c):y>=0&&y++,s++,h++;if(y<0)s-=h,s<r&&(l.push(n[s]),s++);else{l.length>0&&(i.push(gp(mv,e,l)),l=[]),s-=y,h-=y;const b=m.t,v=n.slice(s-h,s);i.push(gp(b,e,v))}}return l.length>0&&i.push(gp(mv,e,l)),i}function gp(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 ZA=typeof console<"u"&&console&&console.warn||(()=>{}),e2="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",jt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function t2(){return Jn.groups={},jt.scanner=null,jt.parser=null,jt.tokenQueue=[],jt.pluginQueue=[],jt.customSchemes=[],jt.initialized=!1,jt}function gv(t,e=!1){if(jt.initialized&&ZA(`linkifyjs: already initialized - will not register custom scheme "${t}" ${e2}`),!/^[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`);jt.customSchemes.push([t,e])}function n2(){jt.scanner=qA(jt.customSchemes);for(let t=0;t<jt.tokenQueue.length;t++)jt.tokenQueue[t][1]({scanner:jt.scanner});jt.parser=QA(jt.scanner.tokens);for(let t=0;t<jt.pluginQueue.length;t++)jt.pluginQueue[t][1]({scanner:jt.scanner,parser:jt.parser});return jt.initialized=!0,jt}function rm(t){return jt.initialized||n2(),XA(jt.parser.start,t,hk(jt.scanner.start,t))}rm.scan=hk;function gk(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 nm(n),s=rm(t),i=[];for(let l=0;l<s.length;l++){const c=s[l];c.isLink&&(!e||c.t===e)&&r.check(c)&&i.push(c.toFormattedObject(r))}return i}var sm="[\0- -\u2029 ]",r2=new RegExp(sm),s2=new RegExp(`${sm}$`),i2=new RegExp(sm,"g");function o2(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function l2(t){return new bt({key:new Ct("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:l}=r,c=Bh(n.doc,[...e]);if($h(c).forEach(({newRange:f})=>{const h=Mw(r.doc,f,b=>b.isTextblock);let m,y;if(h.length>1)m=h[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(h.length){const b=r.doc.textBetween(f.from,f.to," "," ");if(!s2.test(b))return;m=h[0],y=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&y){const b=y.split(r2).filter(Boolean);if(b.length<=0)return!1;const v=b[b.length-1],w=m.pos+y.lastIndexOf(v);if(!v)return!1;const k=rm(v).map(N=>N.toObject(t.defaultProtocol));if(!o2(k))return!1;k.filter(N=>N.isLink).map(N=>({...N,from:w+N.start+1,to:w+N.end+1})).filter(N=>r.schema.marks.code?!r.doc.rangeHasMark(N.from,N.to,r.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{Uh(N.from,N.to,r.doc).some(C=>C.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function a2(t){return new bt({key:new Ct("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{const u=r.target;if(!u)return!1;const f=t.editor.view.dom;l=u.closest("a"),l&&!f.contains(l)&&(l=null)}if(!l)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=Dw(e.state,t.type.name),f=(s=l.href)!=null?s:u.href,h=(i=l.target)!=null?i:u.target;f&&(window.open(f,h),c=!0)}return c}}})}function c2(t){return new bt({key:new Ct("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:l}=i,{empty:c}=l;if(c)return!1;let u="";r.content.forEach(h=>{u+=h.textContent});const f=gk(u,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===u);return!u||!f||s!==void 0&&!s(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function vi(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(i2,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var yk=Ar.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"){gv(t);return}gv(t.scheme,t.optionalSlashes)})},onDestroy(){t2()},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)=>!!vi(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=>!!vi(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=>!!vi(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",yt(this.options.HTMLAttributes,t),0]:["a",yt(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 l=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",u=e.renderChildren(t);return c?`[${u}](${l} "${c}")`:`[${u}](${l})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!vi(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=>!!vi(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[Qs({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=gk(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:l=>!!vi(l,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(l2({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!vi(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(a2({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(c2({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),u2=yk;function d2(t={}){return new bt({view(e){return new f2(e,t)}})}class f2{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=l=>{this[s](l)};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(),l=i.width/s.offsetWidth,c=i.height/s.offsetHeight;if(n){let m=e.nodeBefore,y=e.nodeAfter;if(m||y){let b=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(b){let v=b.getBoundingClientRect(),w=m?v.bottom:v.top;m&&y&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*c;r={left:v.left,right:v.right,top:w-k,bottom:w+k}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;r={left:m.left-y,right:m.left+y,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,h;if(!u||u==document.body&&getComputedStyle(u).position=="static")f=-pageXOffset,h=-pageYOffset;else{let m=u.getBoundingClientRect(),y=m.width/u.offsetWidth,b=m.height/u.offsetHeight;f=m.left-u.scrollLeft*y,h=m.top-u.scrollTop*b}this.element.style.left=(r.left-f)/l+"px",this.element.style.top=(r.top-h)/c+"px",this.element.style.width=(r.right-r.left)/l+"px",this.element.style.height=(r.bottom-r.top)/c+"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 l=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=wx(this.editorView.state.doc,l,this.editorView.dragging.slice);c!=null&&(l=c)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Vt extends Ye{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Vt.valid(r)?new Vt(r):Ye.near(r)}content(){return Se.empty}eq(e){return e instanceof Vt&&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 Vt(e.resolve(n.pos))}getBookmark(){return new im(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!p2(e)||!h2(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&&Vt.valid(e))return e;let s=e.pos,i=null;for(let l=e.depth;;l--){let c=e.node(l);if(n>0?e.indexAfter(l)<c.childCount:e.index(l)>0){i=c.child(n>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;s+=n;let u=e.doc.resolve(s);if(Vt.valid(u))return u}for(;;){let l=n>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!ze.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=l,s+=n;let c=e.doc.resolve(s);if(Vt.valid(c))return c}return null}}}Vt.prototype.visible=!1;Vt.findFrom=Vt.findGapCursorFrom;Ye.jsonID("gapcursor",Vt);class im{constructor(e){this.pos=e}map(e){return new im(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Vt.valid(n)?new Vt(n):Ye.near(n)}}function bk(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function p2(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||bk(s.type))return!0;if(s.inlineContent)return!1}}return!0}function h2(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||bk(s.type))return!0;if(s.inlineContent)return!1}}return!0}function m2(){return new bt({props:{decorations:v2,createSelectionBetween(t,e,n){return e.pos==n.pos&&Vt.valid(n)?new Vt(n):null},handleClick:y2,handleKeyDown:g2,handleDOMEvents:{beforeinput:b2}}})}const g2=jh({ArrowLeft:bc("horiz",-1),ArrowRight:bc("horiz",1),ArrowUp:bc("vert",-1),ArrowDown:bc("vert",1)});function bc(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let l=r.selection,c=e>0?l.$to:l.$from,u=l.empty;if(l instanceof $e){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=Vt.findGapCursorFrom(c,e,u);return f?(s&&s(r.tr.setSelection(new Vt(f))),!0):!1}}function y2(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Vt.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ze.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Vt(r))),!0)}function b2(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Vt))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=le.empty;for(let l=r.length-1;l>=0;l--)s=le.from(r[l].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Se(s,0,0));return i.setSelection($e.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function v2(t){if(!(t.selection instanceof Vt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",mt.create(t.doc,[Mt.widget(t.selection.head,e,{key:"gapcursor"})])}var Ou=200,hn=function(){};hn.prototype.append=function(e){return e.length?(e=hn.from(e),!this.length&&e||e.length<Ou&&this.leafAppend(e)||this.length<Ou&&e.leafPrepend(this)||this.appendInner(e)):this};hn.prototype.prepend=function(e){return e.length?hn.from(e).append(this):this};hn.prototype.appendInner=function(e){return new x2(this,e)};hn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?hn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};hn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};hn.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)};hn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,l){return s.push(e(i,l))},n,r),s};hn.from=function(e){return e instanceof hn?e:e&&e.length?new vk(e):hn.empty};var vk=(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,l,c){for(var u=i;u<l;u++)if(s(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,l,c){for(var u=i-1;u>=l;u--)if(s(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Ou)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Ou)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})(hn);hn.empty=new vk([]);var x2=(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,l){var c=this.left.length;if(s<c&&this.left.forEachInner(r,s,Math.min(i,c),l)===!1||i>c&&this.right.forEachInner(r,Math.max(s-c,0),Math.min(this.length,i)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,l){var c=this.left.length;if(s>c&&this.right.forEachInvertedInner(r,s-c,Math.max(i,c)-c,l+c)===!1||i<c&&this.left.forEachInvertedInner(r,Math.min(s,c),i,l)===!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})(hn);const w2=500;class _r{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 l=e.tr,c,u,f=[],h=[];return this.items.forEach((m,y)=>{if(!m.step){s||(s=this.remapping(r,y+1),i=s.maps.length),i--,h.push(m);return}if(s){h.push(new Ur(m.map));let b=m.step.map(s.slice(i)),v;b&&l.maybeStep(b).doc&&(v=l.mapping.maps[l.mapping.maps.length-1],f.push(new Ur(v,void 0,void 0,f.length+h.length))),i--,v&&s.appendMap(v,i)}else l.maybeStep(m.step);if(m.selection)return c=s?m.selection.map(s.slice(i)):m.selection,u=new _r(this.items.slice(0,r).append(h.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:l,selection:c}}addTransform(e,n,r,s){let i=[],l=this.eventCount,c=this.items,u=!s&&c.length?c.get(c.length-1):null;for(let h=0;h<e.steps.length;h++){let m=e.steps[h].invert(e.docs[h]),y=new Ur(e.mapping.maps[h],m,n),b;(b=u&&u.merge(y))&&(y=b,h?i.pop():c=c.slice(0,c.length-1)),i.push(y),n&&(l++,n=void 0),s||(u=y)}let f=l-r.depth;return f>S2&&(c=k2(c,f),l-=f),new _r(c.append(i),l)}remapping(e,n){let r=new Dl;return this.items.forEach((s,i)=>{let l=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,l)},e,n),r}addMaps(e){return this.eventCount==0?this:new _r(this.items.append(e.map(n=>new Ur(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},s);let u=n;this.items.forEach(y=>{let b=i.getMirror(--u);if(b==null)return;l=Math.min(l,b);let v=i.maps[b];if(y.step){let w=e.steps[b].invert(e.docs[b]),k=y.selection&&y.selection.map(i.slice(u+1,b));k&&c++,r.push(new Ur(v,w,k))}else r.push(new Ur(v))},s);let f=[];for(let y=n;y<l;y++)f.push(new Ur(i.maps[y]));let h=this.items.slice(0,s).append(f).append(r),m=new _r(h,c);return m.emptyItemCount()>w2&&(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((l,c)=>{if(c>=e)s.push(l),l.selection&&i++;else if(l.step){let u=l.step.map(n.slice(r)),f=u&&u.getMap();if(r--,f&&n.appendMap(f,r),u){let h=l.selection&&l.selection.map(n.slice(r));h&&i++;let m=new Ur(f.invert(),u,h),y,b=s.length-1;(y=s.length&&s[b].merge(m))?s[b]=y:s.push(m)}}else l.map&&r--},this.items.length,0),new _r(hn.from(s.reverse()),i)}}_r.empty=new _r(hn.empty,0);function k2(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Ur{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 Ur(n.getMap().invert(),n,this.selection)}}}class Ds{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const S2=20;function E2(t,e,n,r){let s=n.getMeta(Mi),i;if(s)return s.historyState;n.getMeta(_2)&&(t=new Ds(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Mi))return l.getMeta(Mi).redo?new Ds(t.done.addTransform(n,void 0,r,Bc(e)),t.undone,yv(n.mapping.maps),t.prevTime,t.prevComposition):new Ds(t.done,t.undone.addTransform(n,void 0,r,Bc(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!l&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!N2(n,t.prevRanges)),f=l?yp(t.prevRanges,n.mapping):yv(n.mapping.maps);return new Ds(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Bc(e)),_r.empty,f,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ds(t.done.rebased(n,i),t.undone.rebased(n,i),yp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ds(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),yp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function N2(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 yv(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,l)=>e.push(i,l));return e}function yp(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 C2(t,e,n){let r=Bc(e),s=Mi.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let l=i.selection.resolve(i.transform.doc),c=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),u=new Ds(n?c:i.remaining,n?i.remaining:c,null,0,-1);return i.transform.setSelection(l).setMeta(Mi,{redo:n,historyState:u})}let bp=!1,bv=null;function Bc(t){let e=t.plugins;if(bv!=e){bp=!1,bv=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){bp=!0;break}}return bp}const Mi=new Ct("history"),_2=new Ct("closeHistory");function T2(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new bt({key:Mi,state:{init(){return new Ds(_r.empty,_r.empty,null,0,-1)},apply(e,n,r){return E2(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?wk:r=="historyRedo"?kk:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function xk(t,e){return(n,r)=>{let s=Mi.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=C2(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const wk=xk(!1,!0),kk=xk(!0,!0);ft.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 bt({key:new Ct("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 l=i-s,c=0,u=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,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 c=e.selection.$head.pos,u=i-r,f=c-u,h=c;return e.deleteRange(f,h),!(this.storage.characters({node:e.doc})>r)}})]}});var M2=ft.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[d2(this.options)]}});ft.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new bt({key:new Ct("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return mt.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((u,f)=>{if(u.isText)return;if(!(s>=f&&s<=f+u.nodeSize-1))return!1;l+=1});let c=0;return t.descendants((u,f)=>{if(u.isText||!(s>=f&&s<=f+u.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&l-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";i.push(Mt.node(f,f+u.nodeSize,{class:this.options.className}))}),mt.create(t,i)}}})]}});var A2=ft.create({name:"gapCursor",addProseMirrorPlugins(){return[m2()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=gt(Pe(t,"allowGapCursor",n)))!=null?e:null}}}),vv="placeholder";function O2(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var R2=ft.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:vv,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${O2(this.options.dataAttribute)}`:`data-${vv}`;return[new bt({key:new Ct("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,i=[];if(!r)return null;const l=this.editor.isEmpty;return e.descendants((c,u)=>{const f=s>=u&&s<=u+c.nodeSize,h=!c.isLeaf&&Qu(c);if((f||!this.options.showOnlyCurrent)&&h){const m=[this.options.emptyNodeClass];l&&m.push(this.options.emptyEditorClass);const y=Mt.node(u,u+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:f}):this.options.placeholder});i.push(y)}return this.options.includeChildren}),mt.create(e,i)}}})]}});ft.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new bt({key:new Ct("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Pw(n.selection)||t.view.dragging?null:mt.create(n.doc,[Mt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function xv({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var I2=ft.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ct(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 bt({key:e,appendTransaction:(s,i,l)=>{const{doc:c,tr:u,schema:f}=l,h=e.getState(l),m=c.content.size,y=f.nodes[n];if(h)return u.insert(m,y.create())},state:{init:(s,i)=>{const l=i.tr.doc.lastChild;return!xv({node:l,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const l=s.doc.lastChild;return!xv({node:l,types:r})}}})]}}),j2=ft.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>wk(t,e),redo:()=>({state:t,dispatch:e})=>kk(t,e)}},addProseMirrorPlugins(){return[T2(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()}}}),ed=R2,L2=Ar.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",yt(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()}}}),D2=L2,P2=Ar.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",yt(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()}}}),B2=P2;let sh,ih;if(typeof WeakMap<"u"){let t=new WeakMap;sh=e=>t.get(e),ih=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;sh=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},ih=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Kt=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,l=s+1;for(let c=1;i<this.width&&this.map[e+c]==n;c++)i++;for(let c=1;l<this.height&&this.map[e+this.width*c]==n;c++)l++;return{left:r,top:s,right:i,bottom:l}}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:l}=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:l==this.height)?null:this.map[r+this.width*(n<0?i-1:l)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:l,right:c,top:u,bottom:f}=this.findCell(e);return{left:Math.min(n,l),top:Math.min(s,u),right:Math.max(r,c),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,l=this.map[i];n[l]||(n[l]=!0,!(s==t.left&&s&&this.map[i-1]==l||r==t.top&&r&&this.map[i-this.width]==l)&&e.push(l))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let l=e+t*this.width;const c=(t+1)*this.width;for(;l<c&&this.map[l]<s;)l++;return l==c?i-1:this.map[l]}s=i}}static get(t){return sh(t)||ih(t,z2(t))}};function z2(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=F2(t),n=t.childCount,r=[];let s=0,i=null;const l=[];for(let f=0,h=e*n;f<h;f++)r[f]=0;for(let f=0,h=0;f<n;f++){const m=t.child(f);h++;for(let v=0;;v++){for(;s<r.length&&r[s]!=0;)s++;if(v==m.childCount)break;const w=m.child(v),{colspan:k,rowspan:N,colwidth:C}=w.attrs;for(let O=0;O<N;O++){if(O+f>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:h,n:N-O});break}const T=s+O*e;for(let M=0;M<k;M++){r[T+M]==0?r[T+M]=h:(i||(i=[])).push({type:"collision",row:f,pos:h,n:k-M});const R=C&&C[M];if(R){const B=(T+M)%e*2,U=l[B];U==null||U!=R&&l[B+1]==1?(l[B]=R,l[B+1]=1):U==R&&l[B+1]++}}}s+=k,h+=w.nodeSize}const y=(f+1)*e;let b=0;for(;s<y;)r[s++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:f,n:b}),h++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const c=new Kt(e,n,r,i);let u=!1;for(let f=0;!u&&f<l.length;f+=2)l[f]!=null&&l[f+1]<n&&(u=!0);return u&&$2(c,l,t),c}function F2(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 l=0;l<r;l++){const c=t.child(l);for(let u=0;u<c.childCount;u++){const f=c.child(u);l+f.attrs.rowspan>r&&(i+=f.attrs.colspan)}}for(let l=0;l<s.childCount;l++){const c=s.child(l);i+=c.attrs.colspan,c.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function $2(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 l=n.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let c=null;const u=l.attrs;for(let f=0;f<u.colspan;f++){const h=e[(s+f)%t.width*2];h!=null&&(!u.colwidth||u.colwidth[f]!=h)&&((c||(c=U2(u)))[f]=h)}c&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:c})}}function U2(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function In(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 zs=new Ct("selectingCells");function Li(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 H2(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 Or(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 td(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=Li(e.$head)||W2(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function W2(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 oh(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function V2(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function om(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Sk(t,e,n){const r=t.node(-1),s=Kt.get(r),i=t.start(-1),l=s.nextCell(t.pos-i,e,n);return l==null?null:t.node(0).resolve(i+l)}function Di(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 Ek(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 K2(t,e,n){const r=In(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 At=class is extends Ye{constructor(e,n=e){const r=e.node(-1),s=Kt.get(r),i=e.start(-1),l=s.rectBetween(e.pos-i,n.pos-i),c=e.node(0),u=s.cellsInRect(l).filter(h=>h!=n.pos-i);u.unshift(n.pos-i);const f=u.map(h=>{const m=r.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const y=i+h+1;return new Cx(c.resolve(y),c.resolve(y+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(oh(r)&&oh(s)&&om(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?is.rowSelection(r,s):i&&this.isColSelection()?is.colSelection(r,s):new is(r,s)}return $e.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Kt.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},l=[];for(let u=s.top;u<s.bottom;u++){const f=[];for(let h=u*n.width+s.left,m=s.left;m<s.right;m++,h++){const y=n.map[h];if(i[y])continue;i[y]=!0;const b=n.findCell(y);let v=e.nodeAt(y);if(!v)throw new RangeError(`No cell with offset ${y} found`);const w=s.left-b.left,k=b.right-s.right;if(w>0||k>0){let N=v.attrs;if(w>0&&(N=Di(N,0,w)),k>0&&(N=Di(N,N.colspan-k,k)),b.left<s.left){if(v=v.type.createAndFill(N),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(N)}`)}else v=v.type.create(N,v.content)}if(b.top<s.top||b.bottom>s.bottom){const N={...v.attrs,rowspan:Math.min(b.bottom,s.bottom)-Math.max(b.top,s.top)};b.top<s.top?v=v.type.createAndFill(N):v=v.type.create(N,v.content)}f.push(v)}l.push(e.child(u).copy(le.from(f)))}const c=this.isColSelection()&&this.isRowSelection()?e:l;return new Se(le.from(c),1,1)}replace(e,n=Se.empty){const r=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){const{$from:c,$to:u}=s[l],f=e.mapping.slice(r);e.replace(f.map(c.pos),f.map(u.pos),l?Se.empty:n)}const i=Ye.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Se(le.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Kt.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let l=0;l<i.length;l++)e(n.nodeAt(i[l]),s+i[l])}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=Kt.get(r),i=e.start(-1),l=s.findCell(e.pos-i),c=s.findCell(n.pos-i),u=e.node(0);return l.top<=c.top?(l.top>0&&(e=u.resolve(i+s.map[l.left])),c.bottom<s.height&&(n=u.resolve(i+s.map[s.width*(s.height-1)+c.right-1]))):(c.top>0&&(n=u.resolve(i+s.map[c.left])),l.bottom<s.height&&(e=u.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))),new is(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Kt.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 l=s+this.$anchorCell.nodeAfter.attrs.colspan,c=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,c)==n.width}eq(e){return e instanceof is&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Kt.get(r),i=e.start(-1),l=s.findCell(e.pos-i),c=s.findCell(n.pos-i),u=e.node(0);return l.left<=c.left?(l.left>0&&(e=u.resolve(i+s.map[l.top*s.width])),c.right<s.width&&(n=u.resolve(i+s.map[s.width*(c.top+1)-1]))):(c.left>0&&(n=u.resolve(i+s.map[c.top*s.width])),l.right<s.width&&(e=u.resolve(i+s.map[s.width*(l.top+1)-1]))),new is(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new is(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new is(e.resolve(n),e.resolve(r))}getBookmark(){return new G2(this.$anchorCell.pos,this.$headCell.pos)}};At.prototype.visible=!1;Ye.jsonID("cell",At);var G2=class Nk{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Nk(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&&om(n,r)?new At(n,r):Ye.near(r,1)}};function q2(t){if(!(t.selection instanceof At))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Mt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),mt.create(t.doc,e)}function J2({$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 Y2({$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 Q2(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,l;if(r instanceof ze&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")i=At.create(s,r.from);else if(l=="row"){const c=s.resolve(r.from+1);i=At.rowSelection(c,c)}else if(!n){const c=Kt.get(r.node),u=r.from+1,f=u+c.map[c.width*c.height-1];i=At.create(s,u+1,f)}}else r instanceof $e&&J2(r)?i=$e.create(s,r.from):r instanceof $e&&Y2(r)&&(i=$e.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const X2=new Ct("fix-tables");function Ck(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let l=0,c=0;l<i;l++){const u=e.child(l);for(let f=c,h=Math.min(s,l+3);f<h;f++)if(t.child(f)==u){c=f+1,n+=u.nodeSize;continue e}r(u,n),c<s&&t.child(c).sameMarkup(u)?Ck(t.child(c),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function _k(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=Z2(t,s,i,n))};return e?e.doc!=t.doc&&Ck(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Z2(t,e,n,r){const s=Kt.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 h=e.nodeAt(f.pos);if(!h)continue;const m=h.attrs;for(let y=0;y<m.rowspan;y++)i[f.row+y]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,Di(m,m.colspan-f.n,f.n))}else if(f.type=="missing")i[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const h=r.mapping.map(n);r.delete(h,h+e.nodeSize)}}let l,c;for(let u=0;u<i.length;u++)i[u]&&(l==null&&(l=u),c=u);for(let u=0,f=n+1;u<s.height;u++){const h=e.child(u),m=f+h.nodeSize,y=i[u];if(y>0){let b="cell";h.firstChild&&(b=h.firstChild.type.spec.tableRole);const v=[];for(let k=0;k<y;k++){const N=In(t.schema)[b].createAndFill();N&&v.push(N)}const w=(u==0||l==u-1)&&c==u?f+1:m-1;r.insert(r.mapping.map(w),v)}f=m}return r.setMeta(X2,{fixTables:!0})}function Vr(t){const e=t.selection,n=td(t),r=n.node(-1),s=n.start(-1),i=Kt.get(r);return{...e instanceof At?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function Tk(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;K2(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let l=0;l<e.height;l++){const c=l*e.width+s;if(s>0&&s<e.width&&e.map[c-1]==e.map[c]){const u=e.map[c],f=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,Ek(f.attrs,s-e.colCount(u))),l+=f.attrs.rowspan-1}else{const u=i==null?In(r.type.schema).cell:r.nodeAt(e.map[c+i]).type,f=e.positionAt(l,s,r);t.insert(t.mapping.map(n+f),u.createAndFill())}}return t}function eO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Tk(t.tr,n,n.left))}return!0}function tO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Tk(t.tr,n,n.right))}return!0}function nO(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let l=0;l<e.height;){const c=l*e.width+s,u=e.map[c],f=n.nodeAt(u),h=f.attrs;if(s>0&&e.map[c-1]==u||s<e.width-1&&e.map[c+1]==u)t.setNodeMarkup(t.mapping.slice(i).map(r+u),null,Di(h,s-e.colCount(u)));else{const m=t.mapping.slice(i).map(r+u);t.delete(m,m+f.nodeSize)}l+=h.rowspan}}function rO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;nO(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=Kt.get(i)}e(r)}return!0}function sO(t,e,n){var r;const s=In(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 Mk(t,{map:e,tableStart:n,table:r},s){let i=n;for(let f=0;f<s;f++)i+=r.child(f).nodeSize;const l=[];let c=s>0?-1:0;sO(e,r,s+c)&&(c=s==0||s==e.height?null:0);for(let f=0,h=e.width*s;f<e.width;f++,h++)if(s>0&&s<e.height&&e.map[h]==e.map[h-e.width]){const m=e.map[h],y=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...y,rowspan:y.rowspan+1}),f+=y.colspan-1}else{var u;const m=c==null?In(r.type.schema).cell:(u=r.nodeAt(e.map[h+c*e.width]))===null||u===void 0?void 0:u.type,y=m==null?void 0:m.createAndFill();y&&l.push(y)}return t.insert(i,In(r.type.schema).row.create(null,l)),t}function iO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Mk(t.tr,n,n.top))}return!0}function oO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Mk(t.tr,n,n.bottom))}return!0}function lO(t,{map:e,table:n,tableStart:r},s){let i=0;for(let f=0;f<s;f++)i+=n.child(f).nodeSize;const l=i+n.child(s).nodeSize,c=t.mapping.maps.length;t.delete(i+r,l+r);const u=new Set;for(let f=0,h=s*e.width;f<e.width;f++,h++){const m=e.map[h];if(!u.has(m)){if(u.add(m),s>0&&m==e.map[h-e.width]){const y=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...y,rowspan:y.rowspan-1}),f+=y.colspan-1}else if(s<e.height&&m==e.map[h+e.width]){const y=n.nodeAt(m),b=y.attrs,v=y.type.create({...b,rowspan:y.attrs.rowspan-1},y.content),w=e.positionAt(s+1,f,n);t.insert(t.mapping.slice(c).map(r+w),v),f+=b.colspan-1}}}}function aO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;lO(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=Kt.get(n.table)}e(r)}return!0}function wv(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function cO({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,l=(r.bottom-1)*t+r.left,c=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[c]==n[c+1])return!0;i+=t,c+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[l]==n[l+t])return!0;s++,l++}return!1}function kv(t,e){const n=t.selection;if(!(n instanceof At)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Vr(t),{map:s}=r;if(cO(s,r))return!1;if(e){const i=t.tr,l={};let c=le.empty,u,f;for(let h=r.top;h<r.bottom;h++)for(let m=r.left;m<r.right;m++){const y=s.map[h*s.width+m],b=r.table.nodeAt(y);if(!(l[y]||!b))if(l[y]=!0,u==null)u=y,f=b;else{wv(b)||(c=c.append(b.content));const v=i.mapping.map(y+r.tableStart);i.delete(v,v+b.nodeSize)}}if(u==null||f==null)return!0;if(i.setNodeMarkup(u+r.tableStart,null,{...Ek(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),c.size>0){const h=u+1+f.content.size,m=wv(f)?u+1:h;i.replaceWith(m+r.tableStart,h+r.tableStart,c)}i.setSelection(new At(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Sv(t,e){const n=In(t.schema);return uO(({node:r})=>n[r.type.spec.tableRole])(t,e)}function uO(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof At){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var l;if(s=H2(r.$from),!s)return!1;i=(l=Li(r.$from))===null||l===void 0?void 0:l.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let c=s.attrs;const u=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const h=Vr(e),m=e.tr;for(let b=0;b<h.right-h.left;b++)u.push(f?{...c,colwidth:f&&f[b]?[f[b]]:null}:c);let y;for(let b=h.top;b<h.bottom;b++){let v=h.map.positionAt(b,h.left,h.table);b==h.top&&(v+=s.nodeSize);for(let w=h.left,k=0;w<h.right;w++,k++)w==h.left&&b==h.top||m.insert(y=m.mapping.map(v+h.tableStart,1),t({node:s,row:b,col:w}).createAndFill(u[k]))}m.setNodeMarkup(i,t({node:s,row:h.top,col:h.left}),u[0]),r instanceof At&&m.setSelection(new At(m.doc.resolve(r.$anchorCell.pos),y?m.doc.resolve(y):void 0)),n(m)}return!0}}function dO(t,e){return function(n,r){if(!Or(n))return!1;const s=td(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof At?n.selection.forEachCell((l,c)=>{l.attrs[t]!==e&&i.setNodeMarkup(c,null,{...l.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function fO(t){return function(e,n){if(!Or(e))return!1;if(n){const r=In(e.schema),s=Vr(e),i=e.tr,l=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),c=l.map(u=>s.table.nodeAt(u));for(let u=0;u<l.length;u++)c[u].type==r.header_cell&&i.setNodeMarkup(s.tableStart+l[u],r.cell,c[u].attrs);if(i.steps.length===0)for(let u=0;u<l.length;u++)i.setNodeMarkup(s.tableStart+l[u],r.header_cell,c[u].attrs);n(i)}return!0}}function Ev(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 Vl(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?fO(t):function(n,r){if(!Or(n))return!1;if(r){const s=In(n.schema),i=Vr(n),l=n.tr,c=Ev("row",i,s),u=Ev("column",i,s),f=(t==="column"?c:t==="row"&&u)?1:0,h=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"?c?s.cell:s.header_cell:s.cell;i.map.cellsInRect(h).forEach(y=>{const b=y+i.tableStart,v=l.doc.nodeAt(b);v&&l.setNodeMarkup(b,m,v.attrs)}),r(l)}return!0}}Vl("row",{useDeprecatedLogic:!0});Vl("column",{useDeprecatedLogic:!0});const pO=Vl("cell",{useDeprecatedLogic:!0});function hO(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),l=i.lastChild;if(l)return s-1-l.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 Nv(t){return function(e,n){if(!Or(e))return!1;const r=hO(td(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection($e.between(s,V2(s))).scrollIntoView())}return!0}}function mO(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 vc(t,e){const n=t.selection;if(!(n instanceof At))return!1;if(e){const r=t.tr,s=In(t.schema).cell.createAndFill().content;n.forEachCell((i,l)=>{i.content.eq(s)||r.replace(r.mapping.map(l+1),r.mapping.map(l+i.nodeSize-1),new Se(s,0,0))}),r.docChanged&&e(r)}return!0}function gO(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,l=s.type.schema,c=[];if(i=="row")for(let u=0;u<e.childCount;u++){let f=e.child(u).content;const h=u?0:Math.max(0,n-1),m=u<e.childCount-1?0:Math.max(0,r-1);(h||m)&&(f=lh(In(l).row,new Se(f,h,m)).content),c.push(f)}else if(i=="cell"||i=="header_cell")c.push(n||r?lh(In(l).row,new Se(e,n,r)).content:e);else return null;return yO(l,c)}function yO(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let l=i.childCount-1;l>=0;l--){const{rowspan:c,colspan:u}=i.child(l).attrs;for(let f=s;f<s+c;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(le.empty),n[s]<r){const i=In(t).cell.createAndFill(),l=[];for(let c=n[s];c<r;c++)l.push(i);e[s]=e[s].append(le.from(l))}return{height:e.length,width:r,rows:e}}function lh(t,e){const n=t.createAndFill();return new bh(n).replace(0,n.content.size,e).doc}function bO({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],l=[];for(let c=0;c<n.length;c++){const u=n[c],f=[];for(let h=i[c]||0,m=0;h<r;m++){let y=u.child(m%u.childCount);h+y.attrs.colspan>r&&(y=y.type.createChecked(Di(y.attrs,y.attrs.colspan,h+y.attrs.colspan-r),y.content)),f.push(y),h+=y.attrs.colspan;for(let b=1;b<y.attrs.rowspan;b++)i[c+b]=(i[c+b]||0)+y.attrs.colspan}l.push(le.from(f))}n=l,t=r}if(e!=s){const i=[];for(let l=0,c=0;l<s;l++,c++){const u=[],f=n[c%e];for(let h=0;h<f.childCount;h++){let m=f.child(h);l+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(le.from(u))}n=i,e=s}return{width:t,height:e,rows:n}}function vO(t,e,n,r,s,i,l){const c=t.doc.type.schema,u=In(c);let f,h;if(s>e.width)for(let m=0,y=0;m<e.height;m++){const b=n.child(m);y+=b.nodeSize;const v=[];let w;b.lastChild==null||b.lastChild.type==u.cell?w=f||(f=u.cell.createAndFill()):w=h||(h=u.header_cell.createAndFill());for(let k=e.width;k<s;k++)v.push(w);t.insert(t.mapping.slice(l).map(y-1+r),v)}if(i>e.height){const m=[];for(let v=0,w=(e.height-1)*e.width;v<Math.max(e.width,s);v++){const k=v>=e.width?!1:n.nodeAt(e.map[w+v]).type==u.header_cell;m.push(k?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const y=u.row.create(null,le.from(m)),b=[];for(let v=e.height;v<i;v++)b.push(y);t.insert(t.mapping.slice(l).map(r+n.nodeSize-2),b)}return!!(f||h)}function Cv(t,e,n,r,s,i,l,c){if(l==0||l==e.height)return!1;let u=!1;for(let f=s;f<i;f++){const h=l*e.width+f,m=e.map[h];if(e.map[h-e.width]==m){u=!0;const y=n.nodeAt(m),{top:b,left:v}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...y.attrs,rowspan:l-b}),t.insert(t.mapping.slice(c).map(e.positionAt(l,v,n)),y.type.createAndFill({...y.attrs,rowspan:b+y.attrs.rowspan-l})),f+=y.attrs.colspan-1}}return u}function _v(t,e,n,r,s,i,l,c){if(l==0||l==e.width)return!1;let u=!1;for(let f=s;f<i;f++){const h=f*e.width+l,m=e.map[h];if(e.map[h-1]==m){u=!0;const y=n.nodeAt(m),b=e.colCount(m),v=t.mapping.slice(c).map(m+r);t.setNodeMarkup(v,null,Di(y.attrs,l-b,y.attrs.colspan-(l-b))),t.insert(v+y.nodeSize,y.type.createAndFill(Di(y.attrs,0,l-b))),f+=y.attrs.rowspan-1}}return u}function Tv(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let l=Kt.get(i);const{top:c,left:u}=r,f=u+s.width,h=c+s.height,m=t.tr;let y=0;function b(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");l=Kt.get(i),y=m.mapping.maps.length}vO(m,l,i,n,f,h,y)&&b(),Cv(m,l,i,n,u,f,c,y)&&b(),Cv(m,l,i,n,u,f,h,y)&&b(),_v(m,l,i,n,c,h,u,y)&&b(),_v(m,l,i,n,c,h,f,y)&&b();for(let v=c;v<h;v++){const w=l.positionAt(v,u,i),k=l.positionAt(v,f,i);m.replace(m.mapping.slice(y).map(w+n),m.mapping.slice(y).map(k+n),new Se(s.rows[v-c],0,0))}b(),m.setSelection(new At(m.doc.resolve(n+l.positionAt(c,u,i)),m.doc.resolve(n+l.positionAt(h-1,f-1,i)))),e(m)}const xO=jh({ArrowLeft:xc("horiz",-1),ArrowRight:xc("horiz",1),ArrowUp:xc("vert",-1),ArrowDown:xc("vert",1),"Shift-ArrowLeft":wc("horiz",-1),"Shift-ArrowRight":wc("horiz",1),"Shift-ArrowUp":wc("vert",-1),"Shift-ArrowDown":wc("vert",1),Backspace:vc,"Mod-Backspace":vc,Delete:vc,"Mod-Delete":vc});function zc(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function xc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof At)return zc(n,r,Ye.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const l=Ak(s,t,e);if(l==null)return!1;if(t=="horiz")return zc(n,r,Ye.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(l),u=Sk(c,t,e);let f;return u?f=Ye.near(u,1):e<0?f=Ye.near(n.doc.resolve(c.before(-1)),-1):f=Ye.near(n.doc.resolve(c.after(-1)),1),zc(n,r,f)}}}function wc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let l;if(i instanceof At)l=i;else{const u=Ak(s,t,e);if(u==null)return!1;l=new At(n.doc.resolve(u))}const c=Sk(l.$headCell,t,e);return c?zc(n,r,new At(l.$anchorCell,c)):!1}}function wO(t,e){const n=t.state.doc,r=Li(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new At(r))),!0):!1}function kO(t,e,n){if(!Or(t.state))return!1;let r=gO(n);const s=t.state.selection;if(s instanceof At){r||(r={width:1,height:1,rows:[le.from(lh(In(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),l=s.$anchorCell.start(-1),c=Kt.get(i).rectBetween(s.$anchorCell.pos-l,s.$headCell.pos-l);return r=bO(r,c.right-c.left,c.bottom-c.top),Tv(t.state,t.dispatch,l,c,r),!0}else if(r){const i=td(t.state),l=i.start(-1);return Tv(t.state,t.dispatch,l,Kt.get(i.node(-1)).findCell(i.pos-l),r),!0}else return!1}function SO(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Mv(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof At)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Li(t.state.selection.$anchor))!=null&&((n=vp(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 h=vp(t,f);const m=zs.getState(t.state)==null;if(!h||!om(u,h))if(m)h=u;else return;const y=new At(u,h);if(m||!t.state.selection.eq(y)){const b=t.state.tr.setSelection(y);m&&b.setMeta(zs,u.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",c),zs.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(zs,-1))}function c(u){const f=u,h=zs.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if(Mv(t,f.target)!=r&&(m=vp(t,e),!m))return l();m&&i(m,f)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",c)}function Ak(t,e,n){if(!(t.state.selection instanceof $e))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 l=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}function Mv(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function vp(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&&Li(t.state.doc.resolve(r))||Li(t.state.doc.resolve(s))}var EO=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")),ah(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,ah(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ah(t,e,n,r,s,i){let l=0,c=!0,u=e.firstChild;const f=t.firstChild;if(f){for(let m=0,y=0;m<f.childCount;m++){const{colspan:b,colwidth:v}=f.child(m).attrs;for(let w=0;w<b;w++,y++){const k=s==y?i:v&&v[w],N=k?k+"px":"";if(l+=k||r,k||(c=!1),u)u.style.width!=N&&(u.style.width=N),u=u.nextSibling;else{const C=document.createElement("col");C.style.width=N,e.appendChild(C)}}}for(;u;){var h;const m=u.nextSibling;(h=u.parentNode)===null||h===void 0||h.removeChild(u),u=m}c?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}const sr=new Ct("tableColumnResizing");function NO({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=EO,lastColumnResizable:s=!0}={}){const i=new bt({key:sr,state:{init(l,c){var u;const f=(u=i.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,h=In(c.schema).table.name;return r&&f&&(f[h]=(m,y)=>new r(m,n,y)),new CO(-1,!1)},apply(l,c){return c.apply(l)}},props:{attributes:l=>{const c=sr.getState(l);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,c)=>{_O(l,c,t,s)},mouseleave:l=>{TO(l)},mousedown:(l,c)=>{MO(l,c,e,n)}},decorations:l=>{const c=sr.getState(l);if(c&&c.activeHandle>-1)return jO(l,c.activeHandle)},nodeViews:{}}});return i}var CO=class Fc{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(sr);if(r&&r.setHandle!=null)return new Fc(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Fc(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return oh(e.doc.resolve(s))||(s=-1),new Fc(s,n.dragging)}return n}};function _O(t,e,n,r){if(!t.editable)return;const s=sr.getState(t.state);if(s&&!s.dragging){const i=OO(e.target);let l=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?l=Av(t,e,"left",n):u-e.clientX<=n&&(l=Av(t,e,"right",n))}if(l!=s.activeHandle){if(!r&&l!==-1){const c=t.state.doc.resolve(l),u=c.node(-1),f=Kt.get(u),h=c.start(-1);if(f.colCount(c.pos-h)+c.nodeAfter.attrs.colspan-1==f.width-1)return}Ok(t,l)}}}function TO(t){if(!t.editable)return;const e=sr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Ok(t,-1)}function MO(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,l=sr.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const c=t.state.doc.nodeAt(l.activeHandle),u=AO(t,l.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(sr,{setDragging:{startX:e.clientX,startWidth:u}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",h);const y=sr.getState(t.state);y!=null&&y.dragging&&(RO(t,y.activeHandle,Ov(y.dragging,m,n)),t.dispatch(t.state.tr.setMeta(sr,{setDragging:null})))}function h(m){if(!m.which)return f(m);const y=sr.getState(t.state);if(y&&y.dragging){const b=Ov(y.dragging,m,n);Rv(t,y.activeHandle,b,r)}}return Rv(t,l.activeHandle,u,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",h),e.preventDefault(),!0}function AO(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,c=n;if(r)for(let u=0;u<n;u++)r[u]&&(l-=r[u],c--);return l/c}function OO(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Av(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:l}=i,c=Li(t.state.doc.resolve(l));if(!c)return-1;if(n=="right")return c.pos;const u=Kt.get(c.node(-1)),f=c.start(-1),h=u.map.indexOf(c.pos-f);return h%u.width==0?-1:f+u.map[h-1]}function Ov(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Ok(t,e){t.dispatch(t.state.tr.setMeta(sr,{setHandle:e}))}function RO(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Kt.get(s),l=r.start(-1),c=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let f=0;f<i.height;f++){const h=f*i.width+c;if(f&&i.map[h]==i.map[h-i.width])continue;const m=i.map[h],y=s.nodeAt(m).attrs,b=y.colspan==1?0:c-i.colCount(m);if(y.colwidth&&y.colwidth[b]==n)continue;const v=y.colwidth?y.colwidth.slice():IO(y.colspan);v[b]=n,u.setNodeMarkup(l+m,null,{...y,colwidth:v})}u.docChanged&&t.dispatch(u)}function Rv(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),l=s.start(-1),c=Kt.get(i).colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;let u=t.domAtPos(s.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&ah(i,u.firstChild,u,r,c,n)}function IO(t){return Array(t).fill(0)}function jO(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return mt.empty;const i=Kt.get(s),l=r.start(-1),c=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<i.height;f++){const h=c+f*i.width;if((c==i.width-1||i.map[h]!=i.map[h+1])&&(f==0||i.map[h]!=i.map[h-i.width])){var u;const m=i.map[h],y=l+m+s.nodeAt(m).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((u=sr.getState(t))===null||u===void 0)&&u.dragging&&n.push(Mt.node(l+m,l+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(Mt.widget(y,b))}}return mt.create(t.doc,n)}function LO({allowTableNodeSelection:t=!1}={}){return new bt({key:zs,state:{init(){return null},apply(e,n){const r=e.getMeta(zs);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:q2,handleDOMEvents:{mousedown:SO},createSelectionBetween(e){return zs.getState(e.state)!=null?e.state.selection:null},handleTripleClick:wO,handleKeyDown:xO,handlePaste:kO},appendTransaction(e,n,r){return Q2(r,_k(r,n),t)}})}var Rk=gn.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"),l=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(l&&l>-1&&i&&i[l]){const c=i[l].getAttribute("width");return c?[parseInt(c,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",yt(this.options.HTMLAttributes,t),0]}}),Ik=gn.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",yt(this.options.HTMLAttributes,t),0]}}),jk=gn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",yt(this.options.HTMLAttributes,t),0]}});function ch(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Iv(t,e,n,r,s,i){var l;let c=0,u=!0,f=e.firstChild;const h=t.firstChild;if(h!==null)for(let y=0,b=0;y<h.childCount;y+=1){const{colspan:v,colwidth:w}=h.child(y).attrs;for(let k=0;k<v;k+=1,b+=1){const N=s===b?i:w&&w[k],C=N?`${N}px`:"";if(c+=N||r,N||(u=!1),f){if(f.style.width!==C){const[O,T]=ch(r,N);f.style.setProperty(O,T)}f=f.nextSibling}else{const O=document.createElement("col"),[T,M]=ch(r,N);O.style.setProperty(T,M),e.appendChild(O)}}}for(;f;){const y=f.nextSibling;(l=f.parentNode)==null||l.removeChild(f),f=y}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!m?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var DO=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")),Iv(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,Iv(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 PO(t,e,n,r){let s=0,i=!0;const l=[],c=t.firstChild;if(!c)return{};for(let m=0,y=0;m<c.childCount;m+=1){const{colspan:b,colwidth:v}=c.child(m).attrs;for(let w=0;w<b;w+=1,y+=1){const k=n===y?r:v&&v[w];s+=k||e,k||(i=!1);const[N,C]=ch(e,k);l.push(["col",{style:`${N}: ${C}`}])}}const u=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...l],tableWidth:u,tableMinWidth:f}}function jv(t,e){return t.createAndFill()}function BO(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 zO(t,e,n,r,s){const i=BO(t),l=[],c=[];for(let f=0;f<n;f+=1){const h=jv(i.cell);if(h&&c.push(h),r){const m=jv(i.header_cell);m&&l.push(m)}}const u=[];for(let f=0;f<e;f+=1)u.push(i.row.createChecked(null,r&&f===0?l:c));return i.table.createChecked(null,u)}function FO(t){return t instanceof At}var kc=({editor:t})=>{const{selection:e}=t.state;if(!FO(e))return!1;let n=0;const r=Aw(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},$O="";function UO(t){return(t||"").replace(/\s+/g," ").trim()}function HO(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:$O;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(v=>{const w=[];v.content&&v.content.forEach(k=>{let N="";k.content&&Array.isArray(k.content)&&k.content.length>1?N=k.content.map(M=>e.renderChildren(M)).join(s):N=k.content?e.renderChildren(k.content):"";const C=UO(N),O=k.type==="tableHeader";w.push({text:C,isHeader:O})}),i.push(w)});const l=i.reduce((v,w)=>Math.max(v,w.length),0);if(l===0)return"";const c=new Array(l).fill(0);i.forEach(v=>{var w;for(let k=0;k<l;k+=1){const C=(((w=v[k])==null?void 0:w.text)||"").length;C>c[k]&&(c[k]=C),c[k]<3&&(c[k]=3)}});const u=(v,w)=>v+" ".repeat(Math.max(0,w-v.length)),f=i[0],h=f.some(v=>v.isHeader);let m=`
|
|
160
|
+
`;const y=new Array(l).fill(0).map((v,w)=>h&&f[w]&&f[w].text||"");return m+=`| ${y.map((v,w)=>u(v,c[w])).join(" | ")} |
|
|
161
|
+
`,m+=`| ${c.map(v=>"-".repeat(Math.max(3,v))).join(" | ")} |
|
|
162
|
+
`,(h?i.slice(1):i).forEach(v=>{m+=`| ${new Array(l).fill(0).map((w,k)=>u(v[k]&&v[k].text||"",c[k])).join(" | ")} |
|
|
163
|
+
`}),m}var WO=HO,Lk=gn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:DO,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}=PO(t,this.options.cellMinWidth),i=e.style;function l(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const c=["table",yt(this.options.HTMLAttributes,e,{style:l()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},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)=>WO(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const l=zO(i.schema,t,e,n);if(s){const c=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection($e.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>eO(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>tO(t,e),deleteColumn:()=>({state:t,dispatch:e})=>rO(t,e),addRowBefore:()=>({state:t,dispatch:e})=>iO(t,e),addRowAfter:()=>({state:t,dispatch:e})=>oO(t,e),deleteRow:()=>({state:t,dispatch:e})=>aO(t,e),deleteTable:()=>({state:t,dispatch:e})=>mO(t,e),mergeCells:()=>({state:t,dispatch:e})=>kv(t,e),splitCell:()=>({state:t,dispatch:e})=>Sv(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Vl("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Vl("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>pO(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>kv(t,e)?!0:Sv(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>dO(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Nv(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Nv(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&_k(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=At.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?[NO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],LO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:gt(Pe(t,"tableRole",e))}}});ft.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Lk.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Rk.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(Ik.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(jk.configure(this.options.tableRow)),t}});var VO=Object.defineProperty,KO=(t,e)=>{for(var n in e)VO(t,n,{get:e[n],enumerable:!0})},GO="listItem",Lv="textStyle",Dv=/^\s*([-+*])\s$/,Dk=gn.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",yt(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(GO,this.editor.getAttributes(Lv)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=To({find:Dv,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=To({find:Dv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Lv),editor:this.editor})),[t]}}),Pk=gn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",yt(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 l=t.tokens.slice(1),c=e.parseChildren(l);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Kh(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)}}}),qO={};KO(qO,{findListItemPos:()=>Ql,getNextListDepth:()=>lm,handleBackspace:()=>uh,handleDelete:()=>dh,hasListBefore:()=>Bk,hasListItemAfter:()=>JO,hasListItemBefore:()=>zk,listItemHasSubList:()=>Fk,nextListIsDeeper:()=>$k,nextListIsHigher:()=>Uk});var Ql=(t,e)=>{const{$from:n}=e.selection,r=rn(t,e.schema);let s=null,i=n.depth,l=n.pos,c=null;for(;i>0&&c===null;)s=n.node(i),s.type===r?c=i:(i-=1,l-=1);return c===null?null:{$pos:e.doc.resolve(l),depth:c}},lm=(t,e)=>{const n=Ql(t,e);if(!n)return!1;const[,r]=IT(e,t,n.$pos.pos+4);return r},Bk=(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))},zk=(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)},Fk=(t,e,n)=>{if(!n)return!1;const r=rn(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},uh=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ys(t.state,e)&&Bk(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),f=[];u.node().descendants((y,b)=>{y.type.name===e&&f.push({node:y,pos:b})});const h=f.at(-1);if(!h)return!1;const m=t.state.doc.resolve(u.start()+h.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Ys(t.state,e)||!PT(t.state))return!1;const r=Ql(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),l=Fk(e,t.state,i);return zk(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},$k=(t,e)=>{const n=lm(t,e),r=Ql(t,e);return!r||!n?!1:n>r.depth},Uk=(t,e)=>{const n=lm(t,e),r=Ql(t,e);return!r||!n?!1:n<r.depth},dh=(t,e)=>{if(!Ys(t.state,e)||!DT(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:$k(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Uk(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},JO=(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)},Hk=ft.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&&dh(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&&dh(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&&uh(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&&uh(t,n,r)&&(e=!0)}),e}}}}),Pv=/^(\s*)(\d+)\.\s+(.*)$/,YO=/^\s/;function QO(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Pv);if(!i)break;const[,l,c,u]=i,f=l.length;let h=u,m=n+1;const y=[s];for(;m<t.length;){const b=t[m];if(b.match(Pv))break;if(b.trim()==="")y.push(b),h+=`
|
|
165
|
+
`,m+=1;else if(b.match(YO))y.push(b),h+=`
|
|
166
|
+
${b.slice(f+2)}`,m+=1;else break}e.push({indent:f,number:parseInt(c,10),content:h.trim(),raw:y.join(`
|
|
167
|
+
`)}),r=m,n=m}return[e,r]}function Wk(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const l=t[i];if(l.indent===e){const c=l.content.split(`
|
|
168
|
+
`),u=((r=c[0])==null?void 0:r.trim())||"",f=[];u&&f.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const h=c.slice(1).join(`
|
|
169
|
+
`).trim();if(h){const b=n.blockTokens(h);f.push(...b)}let m=i+1;const y=[];for(;m<t.length&&t[m].indent>e;)y.push(t[m]),m+=1;if(y.length>0){const b=Math.min(...y.map(w=>w.indent)),v=Wk(y,b,n);f.push({type:"list",ordered:!0,start:y[0].number,items:v,raw:y.map(w=>w.raw).join(`
|
|
170
|
+
`)})}s.push({type:"list_item",raw:l.raw,tokens:f}),i=m}else i+=1}return s}function XO(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 ZO="listItem",Bv="textStyle",zv=/^(\d+)\.\s$/,Vk=gn.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",yt(this.options.HTMLAttributes,n),0]:["ol",yt(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?XO(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,l]=QO(s);if(i.length===0)return;const c=Wk(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:c,raw:s.slice(0,l).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(ZO,this.editor.getAttributes(Bv)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=To({find:zv,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=To({find:zv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Bv)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),eR=/^\s*(\[([( |x])?\])\s$/,Kk=gn.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",yt(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 Kh(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"),l=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),f=m=>{var y,b;c.ariaLabel=((b=(y=this.options.a11y)==null?void 0:y.checkboxLabel)==null?void 0:b.call(y,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:y}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:b})=>{const v=n();if(typeof v!="number")return!1;const w=b.doc.nodeAt(v);return b.setNodeMarkup(v,void 0,{...w==null?void 0:w.attrs,checked:y}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,y)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,y])=>{s.setAttribute(m,y)}),s.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,l),s.append(i,u),Object.entries(e).forEach(([m,y])=>{s.setAttribute(m,y)});let h=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,c.checked=m.attrs.checked,f(m);const y=r.extensionManager.attributes,b=Ul(m,y),v=new Set(Object.keys(b)),w=this.options.HTMLAttributes;return h.forEach(k=>{v.has(k)||(k in w?s.setAttribute(k,w[k]):s.removeAttribute(k))}),Object.entries(b).forEach(([k,N])=>{N==null?k in w?s.setAttribute(k,w[k]):s.removeAttribute(k):s.setAttribute(k,N)}),h=v,!0}}}},addInputRules(){return[To({find:eR,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Gk=gn.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",yt(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 l=qp(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:r},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(i)},s=qp(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,l)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:l}),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()}}});ft.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Dk.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Pk.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Hk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Vk.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Kk.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Gk.configure(this.options.taskList)),t}});var tR=Kk,nR=Gk,rR=20,qk=(t,e=0)=>{const n=[];return!t.children.length||e>rR||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...qk(r,e+1))}),n},sR=t=>{if(!t.children.length)return;const e=qk(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),l=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${l};${i}`)})},Jk=Ar.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&sR(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",yt(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}}}}),iR=ft.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 l=i[0].trim().toLowerCase(),c=i.slice(1).join(":").trim();if(l==="background-color")return c.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()}}}),oR=ft.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 l=i[0].trim().toLowerCase(),c=i.slice(1).join(":").trim();if(l==="color")return c.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()}}}),lR=ft.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()}}}),aR=ft.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()}}}),cR=ft.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()}}});ft.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(iR.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(oR.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(lR.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(aR.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(cR.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Jk.configure(this.options.textStyle)),t}});var uR=t=>Gt({find:/--$/,replace:t??"—"}),dR=t=>Gt({find:/\.\.\.$/,replace:t??"…"}),fR=t=>Gt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),pR=t=>Gt({find:/"$/,replace:t??"”"}),hR=t=>Gt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),mR=t=>Gt({find:/'$/,replace:t??"’"}),gR=t=>Gt({find:/<-$/,replace:t??"←"}),yR=t=>Gt({find:/->$/,replace:t??"→"}),bR=t=>Gt({find:/\(c\)$/,replace:t??"©"}),vR=t=>Gt({find:/\(tm\)$/,replace:t??"™"}),xR=t=>Gt({find:/\(sm\)$/,replace:t??"℠"}),wR=t=>Gt({find:/\(r\)$/,replace:t??"®"}),kR=t=>Gt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),SR=t=>Gt({find:/\+\/-$/,replace:t??"±"}),ER=t=>Gt({find:/!=$/,replace:t??"≠"}),NR=t=>Gt({find:/<<$/,replace:t??"«"}),CR=t=>Gt({find:/>>$/,replace:t??"»"}),_R=t=>Gt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),TR=t=>Gt({find:/\^2$/,replace:t??"²"}),MR=t=>Gt({find:/\^3$/,replace:t??"³"}),AR=t=>Gt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),OR=t=>Gt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),RR=ft.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(uR(this.options.emDash)),this.options.ellipsis!==!1&&t.push(dR(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(fR(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(pR(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(hR(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(mR(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(gR(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(yR(this.options.rightArrow)),this.options.copyright!==!1&&t.push(bR(this.options.copyright)),this.options.trademark!==!1&&t.push(vR(this.options.trademark)),this.options.servicemark!==!1&&t.push(xR(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(wR(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(kR(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(SR(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(ER(this.options.notEqual)),this.options.laquo!==!1&&t.push(NR(this.options.laquo)),this.options.raquo!==!1&&t.push(CR(this.options.raquo)),this.options.multiplication!==!1&&t.push(_R(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(TR(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(MR(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(AR(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(OR(this.options.threeQuarters)),t}}),IR=RR,Yk=Ar.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",yt(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()}}}),jR=Yk,wn=[];for(var xp=0;xp<256;++xp)wn.push((xp+256).toString(16).slice(1));function LR(t,e=0){return(wn[t[e+0]]+wn[t[e+1]]+wn[t[e+2]]+wn[t[e+3]]+"-"+wn[t[e+4]]+wn[t[e+5]]+"-"+wn[t[e+6]]+wn[t[e+7]]+"-"+wn[t[e+8]]+wn[t[e+9]]+"-"+wn[t[e+10]]+wn[t[e+11]]+wn[t[e+12]]+wn[t[e+13]]+wn[t[e+14]]+wn[t[e+15]]).toLowerCase()}var Sc,DR=new Uint8Array(16);function PR(){if(!Sc&&(Sc=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Sc))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Sc(DR)}var BR=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Fv={randomUUID:BR};function zR(t,e,n){if(Fv.randomUUID&&!t)return Fv.randomUUID();t=t||{};var r=t.random||(t.rng||PR)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,LR(r)}function FR(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 $R=ft.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>zR(),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(c=>c.name==="collaboration"),n=this.editor.extensionManager.extensions.find(c=>c.name==="collaborationCaret"),s=[e,n].filter(Boolean).find(c=>{var u;return(u=c==null?void 0:c.options)==null?void 0:u.provider}),i=(t=s==null?void 0:s.options)==null?void 0:t.provider,l=()=>{const{view:c,state:u}=this.editor,{tr:f,doc:h}=u,{types:m,attributeName:y,generateID:b}=this.options;tu(h,w=>m.includes(w.type.name)&&w.attrs[y]===null).forEach(({node:w,pos:k})=>{f.setNodeMarkup(k,void 0,{...w.attrs,[y]:b({node:w,pos:k})})}),f.setMeta("addToHistory",!1),c.dispatch(f),i&&i.off("synced",l)};if(s){if(!i)return l();i.on("synced",l)}else return l()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new bt({key:new Ct("uniqueID"),appendTransaction:(n,r,s)=>{const i=n.some(w=>w.docChanged)&&!r.doc.eq(s.doc),l=this.options.filterTransaction&&n.some(w=>{var k,N;return!((N=(k=this.options).filterTransaction)!=null&&N.call(k,w))});if(n.find(w=>w.getMeta("y-sync$"))||!i||l)return;const{tr:u}=s,{types:f,attributeName:h,generateID:m}=this.options,y=Bh(r.doc,n),{mapping:b}=y;if($h(y).forEach(({newRange:w})=>{const k=Mw(s.doc,w,C=>f.includes(C.type.name)),N=k.map(({node:C})=>C.attrs[h]).filter(C=>C!==null);k.forEach(({node:C,pos:O},T)=>{var M;const R=(M=u.doc.nodeAt(O))==null?void 0:M.attrs[h];if(R===null){u.setNodeMarkup(O,void 0,{...C.attrs,[h]:m({node:C,pos:O})});return}const B=k[T+1];if(B&&C.content.size===0){const $=u.doc.nodeAt(B.pos);if($!=null&&$.attrs[h]&&$.attrs[h]!==R)return;u.setNodeMarkup(B.pos,void 0,{...B.node.attrs,[h]:R}),N[T+1]=R;const L=m({node:C,pos:O});return u.setNodeMarkup(O,void 0,{...C.attrs,[h]:L}),N[T]=L,u}const U=FR(N),{deleted:z}=b.invert().mapResult(O);z&&U.includes(R)&&u.setNodeMarkup(O,void 0,{...C.attrs,[h]:m({node:C,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=l=>{const c=[];return l.forEach(u=>{if(u.isText){c.push(u);return}if(!r.includes(u.type.name)){c.push(u.copy(i(u.content)));return}const f=u.type.create({...u.attrs,[s]:null},i(u.content),u.marks);c.push(f)}),le.from(c)};return e=!1,new Se(i(n.content),n.openStart,n.openEnd)}}})]}}),am=$R,Ru=(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]},UR=/^\s*>\s$/,HR=gn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ru("blockquote",{...yt(this.options.HTMLAttributes,t),children:Ru("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 c=e.renderChildren([s]).split(`
|
|
175
|
+
`).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.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[To({find:UR,type:this.type})]}}),WR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,KR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,GR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qR=Ar.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 Ru("strong",{...yt(this.options.HTMLAttributes,t),children:Ru("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[ji({find:WR,type:this.type}),ji({find:KR,type:this.type})]},addPasteRules(){return[Qs({find:VR,type:this.type}),Qs({find:GR,type:this.type})]}}),JR=/(^|[^`])`([^`]+)`(?!`)$/,YR=/(^|[^`])`([^`]+)`(?!`)/g,QR=Ar.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",yt(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[ji({find:JR,type:this.type})]},addPasteRules(){return[Qs({find:YR,type:this.type})]}}),wp=4,XR=/^```([a-z]+)?[\s\n]$/,ZR=/^~~~([a-z]+)?[\s\n]$/,Qk=gn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:wp,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(l=>l.startsWith(n)).map(l=>l.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",yt(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:wp,{state:r}=t,{selection:s}=r,{$from:i,empty:l}=s;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return l?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:f,to:h}=s,b=r.doc.textBetween(f,h,`
|
|
182
|
+
`,`
|
|
183
|
+
`).split(`
|
|
184
|
+
`).map(v=>c+v).join(`
|
|
185
|
+
`);return u.replaceWith(f,h,r.schema.text(b)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:wp,{state:r}=t,{selection:s}=r,{$from:i,empty:l}=s;return i.parent.type!==this.type?!1:l?t.commands.command(({tr:c})=>{var u;const{pos:f}=i,h=i.start(),m=i.end(),b=r.doc.textBetween(h,m,`
|
|
186
|
+
`,`
|
|
187
|
+
`).split(`
|
|
188
|
+
`);let v=0,w=0;const k=f-h;for(let R=0;R<b.length;R+=1){if(w+b[R].length>=k){v=R;break}w+=b[R].length+1}const C=((u=b[v].match(/^ */))==null?void 0:u[0])||"",O=Math.min(C.length,n);if(O===0)return!0;let T=h;for(let R=0;R<v;R+=1)T+=b[R].length+1;return c.delete(T,T+O),f-T<=O&&c.setSelection($e.create(c.doc,T)),!0}):t.commands.command(({tr:c})=>{const{from:u,to:f}=s,y=r.doc.textBetween(u,f,`
|
|
189
|
+
`,`
|
|
190
|
+
`).split(`
|
|
191
|
+
`).map(b=>{var v;const w=((v=b.match(/^ */))==null?void 0:v[0])||"",k=Math.min(w.length,n);return b.slice(k)}).join(`
|
|
192
|
+
`);return c.replaceWith(u,f,r.schema.text(y)),!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,l=r.parent.textContent.endsWith(`
|
|
193
|
+
|
|
194
|
+
`);return!i||!l?!1:t.chain().command(({tr:c})=>(c.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 c=s.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:f})=>(f.setSelection(Ye.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Gp({find:XR,type:this.type,getAttributes:t=>({language:t[1]})}),Gp({find:ZR,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new bt({key:new Ct("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:l,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,`
|
|
195
|
+
`));return l.replaceSelectionWith(this.type.create({language:i},u)),l.selection.$from.parent.type!==this.type&&l.setSelection($e.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),eI=Qk,tI=gn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
196
|
+
|
|
197
|
+
`):""}),nI=gn.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",yt(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:l}=this.options,{splittableMarks:c}=r.extensionManager,u=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:h})=>{if(h&&u&&l){const m=u.filter(y=>c.includes(y.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),rI=gn.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]}`,yt(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=>Gp({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),sI=gn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",yt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!EM(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Pw(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:l,dispatch:c})=>{if(c){const{$to:u}=l.selection,f=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection($e.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(ze.create(l.doc,u.pos)):l.setSelection($e.create(l.doc,u.pos));else{const h=i.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=h==null?void 0:h.create();m&&(l.insert(f,m),l.setSelection($e.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ek({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),iI=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,oI=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,lI=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,aI=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,cI=Ar.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",yt(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[ji({find:iI,type:this.type}),ji({find:lI,type:this.type})]},addPasteRules(){return[Qs({find:oI,type:this.type}),Qs({find:aI,type:this.type})]}}),$v=" ",uI=" ",dI=gn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",yt(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===$v||r[0].text===uI)?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?$v:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),fI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,pI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,hI=Ar.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",yt(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[ji({find:fI,type:this.type})]},addPasteRules(){return[Qs({find:pI,type:this.type})]}}),mI=gn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),gI=ft.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(qR.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(HR.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Dk.configure(this.options.bulletList)),this.options.code!==!1&&s.push(QR.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Qk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(tI.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(M2.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(A2.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(nI.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(rI.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(j2.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(sI.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(cI.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Pk.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Hk.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(yk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Vk.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(dI.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(hI.configure(this.options.strike)),this.options.text!==!1&&s.push(mI.configure(this.options.text)),this.options.underline!==!1&&s.push(Yk.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(I2.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),cm=gI,kp,Uv;function yI(){if(Uv)return kp;Uv=1;function t(D){return D instanceof Map?D.clear=D.delete=D.set=function(){throw new Error("map is read-only")}:D instanceof Set&&(D.add=D.clear=D.delete=function(){throw new Error("set is read-only")}),Object.freeze(D),Object.getOwnPropertyNames(D).forEach(se=>{const we=D[se],Je=typeof we;(Je==="object"||Je==="function")&&!Object.isFrozen(we)&&t(we)}),D}class e{constructor(se){se.data===void 0&&(se.data={}),this.data=se.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(D){return D.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(D,...se){const we=Object.create(null);for(const Je in D)we[Je]=D[Je];return se.forEach(function(Je){for(const xt in Je)we[xt]=Je[xt]}),we}const s="</span>",i=D=>!!D.scope,l=(D,{prefix:se})=>{if(D.startsWith("language:"))return D.replace("language:","language-");if(D.includes(".")){const we=D.split(".");return[`${se}${we.shift()}`,...we.map((Je,xt)=>`${Je}${"_".repeat(xt+1)}`)].join(" ")}return`${se}${D}`};class c{constructor(se,we){this.buffer="",this.classPrefix=we.classPrefix,se.walk(this)}addText(se){this.buffer+=n(se)}openNode(se){if(!i(se))return;const we=l(se.scope,{prefix:this.classPrefix});this.span(we)}closeNode(se){i(se)&&(this.buffer+=s)}value(){return this.buffer}span(se){this.buffer+=`<span class="${se}">`}}const u=(D={})=>{const se={children:[]};return Object.assign(se,D),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 we=u({scope:se});this.add(we),this.stack.push(we)}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,we){return typeof we=="string"?se.addText(we):we.children&&(se.openNode(we),we.children.forEach(Je=>this._walk(se,Je)),se.closeNode(we)),se}static _collapse(se){typeof se!="string"&&se.children&&(se.children.every(we=>typeof we=="string")?se.children=[se.children.join("")]:se.children.forEach(we=>{f._collapse(we)}))}}class h extends f{constructor(se){super(),this.options=se}addText(se){se!==""&&this.add(se)}startScope(se){this.openNode(se)}endScope(){this.closeNode()}__addSublanguage(se,we){const Je=se.root;we&&(Je.scope=`language:${we}`),this.add(Je)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(D){return D?typeof D=="string"?D:D.source:null}function y(D){return w("(?=",D,")")}function b(D){return w("(?:",D,")*")}function v(D){return w("(?:",D,")?")}function w(...D){return D.map(we=>m(we)).join("")}function k(D){const se=D[D.length-1];return typeof se=="object"&&se.constructor===Object?(D.splice(D.length-1,1),se):{}}function N(...D){return"("+(k(D).capture?"":"?:")+D.map(Je=>m(Je)).join("|")+")"}function C(D){return new RegExp(D.toString()+"|").exec("").length-1}function O(D,se){const we=D&&D.exec(se);return we&&we.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(D,{joinWith:se}){let we=0;return D.map(Je=>{we+=1;const xt=we;let Et=m(Je),_e="";for(;Et.length>0;){const Ce=T.exec(Et);if(!Ce){_e+=Et;break}_e+=Et.substring(0,Ce.index),Et=Et.substring(Ce.index+Ce[0].length),Ce[0][0]==="\\"&&Ce[1]?_e+="\\"+String(Number(Ce[1])+xt):(_e+=Ce[0],Ce[0]==="("&&we++)}return _e}).map(Je=>`(${Je})`).join(se)}const R=/\b\B/,B="[a-zA-Z]\\w*",U="[a-zA-Z_]\\w*",z="\\b\\d+(\\.\\d+)?",H="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",$="\\b(0b[01]+)",L="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Y=(D={})=>{const se=/^#![ ]*\//;return D.binary&&(D.begin=w(se,/.*\b/,D.binary,/\b.*/)),r({scope:"meta",begin:se,end:/$/,relevance:0,"on:begin":(we,Je)=>{we.index!==0&&Je.ignoreMatch()}},D)},Q={begin:"\\\\[\\s\\S]",relevance:0},ee={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[Q]},G={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[Q]},ne={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(D,se,we={}){const Je=r({scope:"comment",begin:D,end:se,contains:[]},we);Je.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 xt=N("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 Je.contains.push({begin:w(/[ ]+/,"(",xt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Je},X=V("//","$"),te=V("/\\*","\\*/"),A=V("#","$"),I={scope:"number",begin:z,relevance:0},J={scope:"number",begin:H,relevance:0},re={scope:"number",begin:$,relevance:0},pe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[Q,{begin:/\[/,end:/\]/,relevance:0,contains:[Q]}]},Ne={scope:"title",begin:B,relevance:0},Re={scope:"title",begin:U,relevance:0},Be={begin:"\\.\\s*"+U,relevance:0};var ce=Object.freeze({__proto__:null,APOS_STRING_MODE:ee,BACKSLASH_ESCAPE:Q,BINARY_NUMBER_MODE:re,BINARY_NUMBER_RE:$,COMMENT:V,C_BLOCK_COMMENT_MODE:te,C_LINE_COMMENT_MODE:X,C_NUMBER_MODE:J,C_NUMBER_RE:H,END_SAME_AS_BEGIN:function(D){return Object.assign(D,{"on:begin":(se,we)=>{we.data._beginMatch=se[1]},"on:end":(se,we)=>{we.data._beginMatch!==se[1]&&we.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:B,MATCH_NOTHING_RE:R,METHOD_GUARD:Be,NUMBER_MODE:I,NUMBER_RE:z,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:G,REGEXP_MODE:pe,RE_STARTERS_RE:L,SHEBANG:Y,TITLE_MODE:Ne,UNDERSCORE_IDENT_RE:U,UNDERSCORE_TITLE_MODE:Re});function xe(D,se){D.input[D.index-1]==="."&&se.ignoreMatch()}function ie(D,se){D.className!==void 0&&(D.scope=D.className,delete D.className)}function Le(D,se){se&&D.beginKeywords&&(D.begin="\\b("+D.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",D.__beforeBegin=xe,D.keywords=D.keywords||D.beginKeywords,delete D.beginKeywords,D.relevance===void 0&&(D.relevance=0))}function ae(D,se){Array.isArray(D.illegal)&&(D.illegal=N(...D.illegal))}function ue(D,se){if(D.match){if(D.begin||D.end)throw new Error("begin & end are not supported with match");D.begin=D.match,delete D.match}}function me(D,se){D.relevance===void 0&&(D.relevance=1)}const Ae=(D,se)=>{if(!D.beforeMatch)return;if(D.starts)throw new Error("beforeMatch cannot be used with starts");const we=Object.assign({},D);Object.keys(D).forEach(Je=>{delete D[Je]}),D.keywords=we.keywords,D.begin=w(we.beforeMatch,y(we.begin)),D.starts={relevance:0,contains:[Object.assign(we,{endsParent:!0})]},D.relevance=0,delete we.beforeMatch},Ue=["of","and","for","in","not","or","if","then","parent","list","value"],ct="keyword";function pt(D,se,we=ct){const Je=Object.create(null);return typeof D=="string"?xt(we,D.split(" ")):Array.isArray(D)?xt(we,D):Object.keys(D).forEach(function(Et){Object.assign(Je,pt(D[Et],se,Et))}),Je;function xt(Et,_e){se&&(_e=_e.map(Ce=>Ce.toLowerCase())),_e.forEach(function(Ce){const We=Ce.split("|");Je[We[0]]=[Et,Lt(We[0],We[1])]})}}function Lt(D,se){return se?Number(se):Qn(D)?0:1}function Qn(D){return Ue.includes(D.toLowerCase())}const yn={},lt=D=>{console.error(D)},Ot=(D,...se)=>{console.log(`WARN: ${D}`,...se)},bn=(D,se)=>{yn[`${D}/${se}`]||(console.log(`Deprecated as of ${D}. ${se}`),yn[`${D}/${se}`]=!0)},qt=new Error;function Jt(D,se,{key:we}){let Je=0;const xt=D[we],Et={},_e={};for(let Ce=1;Ce<=se.length;Ce++)_e[Ce+Je]=xt[Ce],Et[Ce+Je]=!0,Je+=C(se[Ce-1]);D[we]=_e,D[we]._emit=Et,D[we]._multi=!0}function Xn(D){if(Array.isArray(D.begin)){if(D.skip||D.excludeBegin||D.returnBegin)throw lt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),qt;if(typeof D.beginScope!="object"||D.beginScope===null)throw lt("beginScope must be object"),qt;Jt(D,D.begin,{key:"beginScope"}),D.begin=M(D.begin,{joinWith:""})}}function Z(D){if(Array.isArray(D.end)){if(D.skip||D.excludeEnd||D.returnEnd)throw lt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),qt;if(typeof D.endScope!="object"||D.endScope===null)throw lt("endScope must be object"),qt;Jt(D,D.end,{key:"endScope"}),D.end=M(D.end,{joinWith:""})}}function Ge(D){D.scope&&typeof D.scope=="object"&&D.scope!==null&&(D.beginScope=D.scope,delete D.scope)}function He(D){Ge(D),typeof D.beginScope=="string"&&(D.beginScope={_wrap:D.beginScope}),typeof D.endScope=="string"&&(D.endScope={_wrap:D.endScope}),Xn(D),Z(D)}function kt(D){function se(_e,Ce){return new RegExp(m(_e),"m"+(D.case_insensitive?"i":"")+(D.unicodeRegex?"u":"")+(Ce?"g":""))}class we{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ce,We){We.position=this.position++,this.matchIndexes[this.matchAt]=We,this.regexes.push([We,Ce]),this.matchAt+=C(Ce)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ce=this.regexes.map(We=>We[1]);this.matcherRe=se(M(Ce,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ce){this.matcherRe.lastIndex=this.lastIndex;const We=this.matcherRe.exec(Ce);if(!We)return null;const en=We.findIndex((Rr,fs)=>fs>0&&Rr!==void 0),_t=this.matchIndexes[en];return We.splice(0,en),Object.assign(We,_t)}}class Je{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ce){if(this.multiRegexes[Ce])return this.multiRegexes[Ce];const We=new we;return this.rules.slice(Ce).forEach(([en,_t])=>We.addRule(en,_t)),We.compile(),this.multiRegexes[Ce]=We,We}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ce,We){this.rules.push([Ce,We]),We.type==="begin"&&this.count++}exec(Ce){const We=this.getMatcher(this.regexIndex);We.lastIndex=this.lastIndex;let en=We.exec(Ce);if(this.resumingScanAtSamePosition()&&!(en&&en.index===this.lastIndex)){const _t=this.getMatcher(0);_t.lastIndex=this.lastIndex+1,en=_t.exec(Ce)}return en&&(this.regexIndex+=en.position+1,this.regexIndex===this.count&&this.considerAll()),en}}function xt(_e){const Ce=new Je;return _e.contains.forEach(We=>Ce.addRule(We.begin,{rule:We,type:"begin"})),_e.terminatorEnd&&Ce.addRule(_e.terminatorEnd,{type:"end"}),_e.illegal&&Ce.addRule(_e.illegal,{type:"illegal"}),Ce}function Et(_e,Ce){const We=_e;if(_e.isCompiled)return We;[ie,ue,He,Ae].forEach(_t=>_t(_e,Ce)),D.compilerExtensions.forEach(_t=>_t(_e,Ce)),_e.__beforeBegin=null,[Le,ae,me].forEach(_t=>_t(_e,Ce)),_e.isCompiled=!0;let en=null;return typeof _e.keywords=="object"&&_e.keywords.$pattern&&(_e.keywords=Object.assign({},_e.keywords),en=_e.keywords.$pattern,delete _e.keywords.$pattern),en=en||/\w+/,_e.keywords&&(_e.keywords=pt(_e.keywords,D.case_insensitive)),We.keywordPatternRe=se(en,!0),Ce&&(_e.begin||(_e.begin=/\B|\b/),We.beginRe=se(We.begin),!_e.end&&!_e.endsWithParent&&(_e.end=/\B|\b/),_e.end&&(We.endRe=se(We.end)),We.terminatorEnd=m(We.end)||"",_e.endsWithParent&&Ce.terminatorEnd&&(We.terminatorEnd+=(_e.end?"|":"")+Ce.terminatorEnd)),_e.illegal&&(We.illegalRe=se(_e.illegal)),_e.contains||(_e.contains=[]),_e.contains=[].concat(..._e.contains.map(function(_t){return nt(_t==="self"?_e:_t)})),_e.contains.forEach(function(_t){Et(_t,We)}),_e.starts&&Et(_e.starts,Ce),We.matcher=xt(We),We}if(D.compilerExtensions||(D.compilerExtensions=[]),D.contains&&D.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return D.classNameAliases=r(D.classNameAliases||{}),Et(D)}function Ze(D){return D?D.endsWithParent||Ze(D.starts):!1}function nt(D){return D.variants&&!D.cachedVariants&&(D.cachedVariants=D.variants.map(function(se){return r(D,{variants:null},se)})),D.cachedVariants?D.cachedVariants:Ze(D)?r(D,{starts:D.starts?r(D.starts):null}):Object.isFrozen(D)?r(D):D}var qe="11.11.1";class Un extends Error{constructor(se,we){super(se),this.name="HTMLInjectionError",this.html=we}}const ln=n,oe=r,ve=Symbol("nomatch"),Fe=7,St=function(D){const se=Object.create(null),we=Object.create(null),Je=[];let xt=!0;const Et="Could not find the language '{}', did you forget to load/include a language module?",_e={disableAutodetect:!0,name:"Plain text",contains:[]};let Ce={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function We(ye){return Ce.noHighlightRe.test(ye)}function en(ye){let De=ye.className+" ";De+=ye.parentNode?ye.parentNode.className:"";const rt=Ce.languageDetectRe.exec(De);if(rt){const ot=vr(rt[1]);return ot||(Ot(Et.replace("{}",rt[1])),Ot("Falling back to no-highlight mode for this block.",ye)),ot?rt[1]:"no-highlight"}return De.split(/\s+/).find(ot=>We(ot)||vr(ot))}function _t(ye,De,rt){let ot="",Yt="";typeof De=="object"?(ot=ye,rt=De.ignoreIllegals,Yt=De.language):(bn("10.7.0","highlight(lang, code, ...args) has been deprecated."),bn("10.7.0",`Please use highlight(code, options) instead.
|
|
200
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),Yt=ye,ot=De),rt===void 0&&(rt=!0);const Bt={code:ot,language:Yt};ni("before:highlight",Bt);const Ir=Bt.result?Bt.result:Rr(Bt.language,Bt.code,rt);return Ir.code=Bt.code,ni("after:highlight",Ir),Ir}function Rr(ye,De,rt,ot){const Yt=Object.create(null);function Bt(ke,Te){return ke.keywords[Te]}function Ir(){if(!et.keywords){Qt.addText(vt);return}let ke=0;et.keywordPatternRe.lastIndex=0;let Te=et.keywordPatternRe.exec(vt),Qe="";for(;Te;){Qe+=vt.substring(ke,Te.index);const at=or.case_insensitive?Te[0].toLowerCase():Te[0],Ut=Bt(et,at);if(Ut){const[an,ad]=Ut;if(Qt.addText(Qe),Qe="",Yt[at]=(Yt[at]||0)+1,Yt[at]<=Fe&&(ii+=ad),an.startsWith("_"))Qe+=Te[0];else{const ia=or.classNameAliases[an]||an;Dn(Te[0],ia)}}else Qe+=Te[0];ke=et.keywordPatternRe.lastIndex,Te=et.keywordPatternRe.exec(vt)}Qe+=vt.substring(ke),Qt.addText(Qe)}function $i(){if(vt==="")return;let ke=null;if(typeof et.subLanguage=="string"){if(!se[et.subLanguage]){Qt.addText(vt);return}ke=Rr(et.subLanguage,vt,!0,Po[et.subLanguage]),Po[et.subLanguage]=ke._top}else ke=ti(vt,et.subLanguage.length?et.subLanguage:null);et.relevance>0&&(ii+=ke.relevance),Qt.__addSublanguage(ke._emitter,ke.language)}function Ln(){et.subLanguage!=null?$i():Ir(),vt=""}function Dn(ke,Te){ke!==""&&(Qt.startScope(Te),Qt.addText(ke),Qt.endScope())}function ri(ke,Te){let Qe=1;const at=Te.length-1;for(;Qe<=at;){if(!ke._emit[Qe]){Qe++;continue}const Ut=or.classNameAliases[ke[Qe]]||ke[Qe],an=Te[Qe];Ut?Dn(an,Ut):(vt=an,Ir(),vt=""),Qe++}}function ps(ke,Te){return ke.scope&&typeof ke.scope=="string"&&Qt.openNode(or.classNameAliases[ke.scope]||ke.scope),ke.beginScope&&(ke.beginScope._wrap?(Dn(vt,or.classNameAliases[ke.beginScope._wrap]||ke.beginScope._wrap),vt=""):ke.beginScope._multi&&(ri(ke.beginScope,Te),vt="")),et=Object.create(ke,{parent:{value:et}}),et}function si(ke,Te,Qe){let at=O(ke.endRe,Qe);if(at){if(ke["on:end"]){const Ut=new e(ke);ke["on:end"](Te,Ut),Ut.isMatchIgnored&&(at=!1)}if(at){for(;ke.endsParent&&ke.parent;)ke=ke.parent;return ke}}if(ke.endsWithParent)return si(ke.parent,Te,Qe)}function od(ke){return et.matcher.regexIndex===0?(vt+=ke[0],1):(gs=!0,0)}function ld(ke){const Te=ke[0],Qe=ke.rule,at=new e(Qe),Ut=[Qe.__beforeBegin,Qe["on:begin"]];for(const an of Ut)if(an&&(an(ke,at),at.isMatchIgnored))return od(Te);return Qe.skip?vt+=Te:(Qe.excludeBegin&&(vt+=Te),Ln(),!Qe.returnBegin&&!Qe.excludeBegin&&(vt=Te)),ps(Qe,ke),Qe.returnBegin?0:Te.length}function Lo(ke){const Te=ke[0],Qe=De.substring(ke.index),at=si(et,ke,Qe);if(!at)return ve;const Ut=et;et.endScope&&et.endScope._wrap?(Ln(),Dn(Te,et.endScope._wrap)):et.endScope&&et.endScope._multi?(Ln(),ri(et.endScope,ke)):Ut.skip?vt+=Te:(Ut.returnEnd||Ut.excludeEnd||(vt+=Te),Ln(),Ut.excludeEnd&&(vt=Te));do et.scope&&Qt.closeNode(),!et.skip&&!et.subLanguage&&(ii+=et.relevance),et=et.parent;while(et!==at.parent);return at.starts&&ps(at.starts,ke),Ut.returnEnd?0:Te.length}function sa(){const ke=[];for(let Te=et;Te!==or;Te=Te.parent)Te.scope&&ke.unshift(Te.scope);ke.forEach(Te=>Qt.openNode(Te))}let hs={};function ms(ke,Te){const Qe=Te&&Te[0];if(vt+=ke,Qe==null)return Ln(),0;if(hs.type==="begin"&&Te.type==="end"&&hs.index===Te.index&&Qe===""){if(vt+=De.slice(Te.index,Te.index+1),!xt){const at=new Error(`0 width match regex (${ye})`);throw at.languageName=ye,at.badRule=hs.rule,at}return 1}if(hs=Te,Te.type==="begin")return ld(Te);if(Te.type==="illegal"&&!rt){const at=new Error('Illegal lexeme "'+Qe+'" for mode "'+(et.scope||"<unnamed>")+'"');throw at.mode=et,at}else if(Te.type==="end"){const at=Lo(Te);if(at!==ve)return at}if(Te.type==="illegal"&&Qe==="")return vt+=`
|
|
201
|
+
`,1;if(oi>1e5&&oi>Te.index*3)throw new Error("potential infinite loop, way more iterations than matches");return vt+=Qe,Qe.length}const or=vr(ye);if(!or)throw lt(Et.replace("{}",ye)),new Error('Unknown language: "'+ye+'"');const Do=kt(or);let ut="",et=ot||Do;const Po={},Qt=new Ce.__emitter(Ce);sa();let vt="",ii=0,jr=0,oi=0,gs=!1;try{if(or.__emitTokens)or.__emitTokens(De,Qt);else{for(et.matcher.considerAll();;){oi++,gs?gs=!1:et.matcher.considerAll(),et.matcher.lastIndex=jr;const ke=et.matcher.exec(De);if(!ke)break;const Te=De.substring(jr,ke.index),Qe=ms(Te,ke);jr=ke.index+Qe}ms(De.substring(jr))}return Qt.finalize(),ut=Qt.toHTML(),{language:ye,value:ut,relevance:ii,illegal:!1,_emitter:Qt,_top:et}}catch(ke){if(ke.message&&ke.message.includes("Illegal"))return{language:ye,value:ln(De),illegal:!0,relevance:0,_illegalBy:{message:ke.message,index:jr,context:De.slice(jr-100,jr+100),mode:ke.mode,resultSoFar:ut},_emitter:Qt};if(xt)return{language:ye,value:ln(De),illegal:!1,relevance:0,errorRaised:ke,_emitter:Qt,_top:et};throw ke}}function fs(ye){const De={value:ln(ye),illegal:!1,relevance:0,_top:_e,_emitter:new Ce.__emitter(Ce)};return De._emitter.addText(ye),De}function ti(ye,De){De=De||Ce.languages||Object.keys(se);const rt=fs(ye),ot=De.filter(vr).filter(ra).map(Ln=>Rr(Ln,ye,!1));ot.unshift(rt);const Yt=ot.sort((Ln,Dn)=>{if(Ln.relevance!==Dn.relevance)return Dn.relevance-Ln.relevance;if(Ln.language&&Dn.language){if(vr(Ln.language).supersetOf===Dn.language)return 1;if(vr(Dn.language).supersetOf===Ln.language)return-1}return 0}),[Bt,Ir]=Yt,$i=Bt;return $i.secondBest=Ir,$i}function rd(ye,De,rt){const ot=De&&we[De]||rt;ye.classList.add("hljs"),ye.classList.add(`language-${ot}`)}function Ro(ye){let De=null;const rt=en(ye);if(We(rt))return;if(ni("before:highlightElement",{el:ye,language:rt}),ye.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ye);return}if(ye.children.length>0&&(Ce.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(ye)),Ce.throwUnescapedHTML))throw new Un("One of your code blocks includes unescaped HTML.",ye.innerHTML);De=ye;const ot=De.textContent,Yt=rt?_t(ot,{language:rt,ignoreIllegals:!0}):ti(ot);ye.innerHTML=Yt.value,ye.dataset.highlighted="yes",rd(ye,rt,Yt.language),ye.result={language:Yt.language,re:Yt.relevance,relevance:Yt.relevance},Yt.secondBest&&(ye.secondBest={language:Yt.secondBest.language,relevance:Yt.secondBest.relevance}),ni("after:highlightElement",{el:ye,result:Yt,text:ot})}function sd(ye){Ce=oe(Ce,ye)}const Kr=()=>{zi(),bn("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Xl(){zi(),bn("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Io=!1;function zi(){function ye(){zi()}if(document.readyState==="loading"){Io||window.addEventListener("DOMContentLoaded",ye,!1),Io=!0;return}document.querySelectorAll(Ce.cssSelector).forEach(Ro)}function Zl(ye,De){let rt=null;try{rt=De(D)}catch(ot){if(lt("Language definition for '{}' could not be registered.".replace("{}",ye)),xt)lt(ot);else throw ot;rt=_e}rt.name||(rt.name=ye),se[ye]=rt,rt.rawDefinition=De.bind(null,D),rt.aliases&&na(rt.aliases,{languageName:ye})}function ea(ye){delete se[ye];for(const De of Object.keys(we))we[De]===ye&&delete we[De]}function ta(){return Object.keys(se)}function vr(ye){return ye=(ye||"").toLowerCase(),se[ye]||se[we[ye]]}function na(ye,{languageName:De}){typeof ye=="string"&&(ye=[ye]),ye.forEach(rt=>{we[rt.toLowerCase()]=De})}function ra(ye){const De=vr(ye);return De&&!De.disableAutodetect}function Pt(ye){ye["before:highlightBlock"]&&!ye["before:highlightElement"]&&(ye["before:highlightElement"]=De=>{ye["before:highlightBlock"](Object.assign({block:De.el},De))}),ye["after:highlightBlock"]&&!ye["after:highlightElement"]&&(ye["after:highlightElement"]=De=>{ye["after:highlightBlock"](Object.assign({block:De.el},De))})}function id(ye){Pt(ye),Je.push(ye)}function jo(ye){const De=Je.indexOf(ye);De!==-1&&Je.splice(De,1)}function ni(ye,De){const rt=ye;Je.forEach(function(ot){ot[rt]&&ot[rt](De)})}function Fi(ye){return bn("10.7.0","highlightBlock will be removed entirely in v12.0"),bn("10.7.0","Please use highlightElement now."),Ro(ye)}Object.assign(D,{highlight:_t,highlightAuto:ti,highlightAll:zi,highlightElement:Ro,highlightBlock:Fi,configure:sd,initHighlighting:Kr,initHighlightingOnLoad:Xl,registerLanguage:Zl,unregisterLanguage:ea,listLanguages:ta,getLanguage:vr,registerAliases:na,autoDetection:ra,inherit:oe,addPlugin:id,removePlugin:jo}),D.debugMode=function(){xt=!1},D.safeMode=function(){xt=!0},D.versionString=qe,D.regex={concat:w,lookahead:y,either:N,optional:v,anyNumberOfTimes:b};for(const ye in ce)typeof ce[ye]=="object"&&t(ce[ye]);return Object.assign(D,ce),D},$t=St({});return $t.newInstance=()=>St({}),kp=$t,$t.HighlightJS=$t,$t.default=$t,kp}var bI=yI();const Xk=Bu(bI);function Zk(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?Zk(n.children,r):{text:n.value,classes:r}})}function Hv(t){return t.value||t.children||[]}function vI(t){return!!Xk.getLanguage(t)}function Wv({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return tu(t,i=>i.type.name===e).forEach(i=>{var l;let c=i.pos+1;const u=i.node.attrs.language||r,f=n.listLanguages(),h=u&&(f.includes(u)||vI(u)||(l=n.registered)!=null&&l.call(n,u))?Hv(n.highlight(u,i.node.textContent)):Hv(n.highlightAuto(i.node.textContent));Zk(h).forEach(m=>{const y=c+m.text.length;if(m.classes.length){const b=Mt.inline(c,y,{class:m.classes.join(" ")});s.push(b)}c=y})}),mt.create(t,s)}function xI(t){return typeof t=="function"}function wI({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>xI(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new bt({key:new Ct("lowlight"),state:{init:(s,{doc:i})=>Wv({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,l,c)=>{const u=l.selection.$head.parent.type.name,f=c.selection.$head.parent.type.name,h=tu(l.doc,y=>y.type.name===t),m=tu(c.doc,y=>y.type.name===t);return s.docChanged&&([u,f].includes(t)||m.length!==h.length||s.steps.some(y=>y.from!==void 0&&y.to!==void 0&&h.some(b=>b.pos>=y.from&&b.pos+b.node.nodeSize<=y.to)))?Wv({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 kI=eI.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))||[],wI({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),SI=kI;function EI(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={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})"/})]},h={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]},y={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},b=e.optional(s)+t.IDENT_RE+"\\s*\\(",v=["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"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],k=["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"],N=["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:w,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:k},M={className:"function.dispatch",relevance:0,keywords:{_hint:N},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[M,m,c,n,t.C_BLOCK_COMMENT_MODE,h,f],B={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},U={className:"function",begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:b,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,c,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,c]}]},c,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(B,U,M,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",c]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function NI(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=EI(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 CI(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"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(c);const u={match:/\\"/},f={className:"string",begin:/'/,end:/'/},h={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},y=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],b=t.SHEBANG({binary:`(${y.join("|")})`,relevance:10}),v={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},w=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],k=["true","false"],N={match:/(\/[a-z._-]+)+/},C=["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"],M=["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:w,literal:k,built_in:[...C,...O,"set","shopt",...T,...M]},contains:[b,t.SHEBANG(),v,m,i,l,N,c,u,f,h,n]}}function _I(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",l="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={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})"/})]},h={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]},y={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},b=e.optional(s)+t.IDENT_RE+"\\s*\\(",k={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"},N=[m,c,n,t.C_BLOCK_COMMENT_MODE,h,f],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:k,contains:N.concat([{begin:/\(/,end:/\)/,keywords:k,contains:N.concat(["self"]),relevance:0}]),relevance:0},O={begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:k,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:k,relevance:0},{begin:b,returnBegin:!0,contains:[t.inherit(y,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:k,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,c,{begin:/\(/,end:/\)/,keywords:k,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C",aliases:["h"],keywords:k,disableAutodetect:!0,illegal:"</",contains:[].concat(C,O,N,[m,{begin:t.IDENT_RE+"::",keywords:k},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:m,strings:f,keywords:k}}}function TI(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={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})"/})]},h={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]},y={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},b=e.optional(s)+t.IDENT_RE+"\\s*\\(",v=["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"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],k=["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"],N=["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:w,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:k},M={className:"function.dispatch",relevance:0,keywords:{_hint:N},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[M,m,c,n,t.C_BLOCK_COMMENT_MODE,h,f],B={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},U={className:"function",begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:b,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,c,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,c]}]},c,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(B,U,M,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",c]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function MI(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"],l={keyword:s.concat(i),built_in:e,literal:r},c=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},h={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},m=t.inherit(h,{illegal:/\n/}),y={className:"subst",begin:/\{/,end:/\}/,keywords:l},b=t.inherit(y,{illegal:/\n/}),v={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,b]},w={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]},k=t.inherit(w,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},b]});y.contains=[w,v,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.C_BLOCK_COMMENT_MODE],b.contains=[k,v,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const N={variants:[f,w,v,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},C={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},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:l,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"}},N,u,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,C,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,C,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:l,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,C],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,relevance:0,contains:[N,u,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},T]}}const AI=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_-]*/}}),OI=["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"],RI=["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"],II=[...OI,...RI],jI=["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(),LI=["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(),DI=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),PI=["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 BI(t){const e=t.regex,n=AI(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,l="[a-zA-Z-][a-zA-Z0-9_-]*",c=[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:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+LI.join("|")+")"},{begin:":(:)?("+DI.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+PI.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{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:jI.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+II.join("|")+")\\b"}]}}function zI(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 FI(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 $I(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 UI(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/},l={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,s,l,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,h=/'[^']*'/,m=e.either(u,f,h),y=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:y,className:"attr",starts:{end:/$/,contains:[r,c,i,s,l,n]}}]}}var yo="[0-9](_*[0-9])*",Ec=`\\.(${yo})`,Nc="[0-9a-fA-F](_*[0-9a-fA-F])*",Vv={className:"number",variants:[{begin:`(\\b(${yo})((${Ec})|\\.)?|(${Ec}))[eE][+-]?(${yo})[fFdD]?\\b`},{begin:`\\b(${yo})((${Ec})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Ec})[fFdD]?\\b`},{begin:`\\b(${yo})[fFdD]\\b`},{begin:`\\b0[xX]((${Nc})\\.?|(${Nc})?\\.(${Nc}))[pP][+-]?(${yo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Nc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function e1(t,e,n){return n===-1?"":t.replace(e,r=>e1(t,e,n-1))}function HI(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+e1("(?:<"+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"]}]},h={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:[h,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,Vv,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},Vv,f]}}const Kv="[A-Za-z$_][0-9A-Za-z$_]*",WI=["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"],VI=["true","false","null","undefined","NaN","Infinity"],t1=["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"],n1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],r1=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],KI=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],GI=[].concat(r1,t1,n1);function qI(t){const e=t.regex,n=(V,{after:X})=>{const te="</"+V[0].slice(1);return V.input.indexOf(te,X)!==-1},r=Kv,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,X)=>{const te=V[0].length+V.index,A=V.input[te];if(A==="<"||A===","){X.ignoreMatch();return}A===">"&&(n(V,{after:te})||X.ignoreMatch());let I;const J=V.input.substring(te);if(I=J.match(/^\s*=/)){X.ignoreMatch();return}if((I=J.match(/^\s+extends\s+/))&&I.index===0){X.ignoreMatch();return}}},c={$pattern:Kv,keyword:WI,literal:VI,built_in:GI,"variable.language":KI},u="[0-9](_?[0-9])*",f=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\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},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,y]},C={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,b,v,w,k,{match:/\$\d+/},m];y.contains=O.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(O)});const T=[].concat(C,y.contains),M=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:M},B={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"}}]},U={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:{_:[...t1,...n1]}},z={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},H={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function L(V){return e.concat("(?!",V.join("|"),")")}const Y={match:e.concat(/\b/,L([...r1,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},Q={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ee={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},G="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(G)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:U},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),z,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,C,{match:/\$\d+/},m,U,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:G,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:c,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},H,{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},Q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},Y,$,B,ee,{match:/\$[(.]/}]}}function JI(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 bo="[0-9](_*[0-9])*",Cc=`\\.(${bo})`,_c="[0-9a-fA-F](_*[0-9a-fA-F])*",YI={className:"number",variants:[{begin:`(\\b(${bo})((${Cc})|\\.)?|(${Cc}))[eE][+-]?(${bo})[fFdD]?\\b`},{begin:`\\b(${bo})((${Cc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Cc})[fFdD]?\\b`},{begin:`\\b(${bo})[fFdD]\\b`},{begin:`\\b0[xX]((${_c})\\.?|(${_c})?\\.(${_c}))[pP][+-]?(${bo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${_c})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function QI(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},l={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(l);const c={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(l,{className:"string"}),"self"]}]},f=YI,h=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),m={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},y=m;return y.variants[1].contains=[m],m.variants[1].contains=[y],{name:"Kotlin",aliases:["kt","kts"],keywords:e,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),t.C_LINE_COMMENT_MODE,h,n,r,c,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,h],relevance:0},t.C_LINE_COMMENT_MODE,h,c,u,l,t.C_NUMBER_MODE]},h]},{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},c,u]},l,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
|
|
202
|
+
`},f]}}const XI=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_-]*/}}),ZI=["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"],ej=["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"],tj=[...ZI,...ej],nj=["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(),s1=["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(),i1=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),rj=["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(),sj=s1.concat(i1).sort().reverse();function ij(t){const e=XI(t),n=sj,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",l=[],c=[],u=function(O){return{className:"string",begin:"~?"+O+".*?"+O}},f=function(O,T,M){return{className:O,begin:T,relevance:M}},h={$pattern:/[a-z-]+/,keyword:r,attribute:nj.join(" ")},m={begin:"\\(",end:"\\)",contains:c,keywords:h,relevance:0};c.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 y=c.concat({begin:/\{/,end:/\}/,contains:l}),b={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},v={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+rj.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},w={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:c,relevance:0}},k={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:y}},N={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,b,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+tj.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:":("+s1.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+i1.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},e.FUNCTION_DISPATCH]},C={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[N]};return l.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,w,k,C,v,N,b,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:l}}function oj(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 lj(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"}},l={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,l]}}function aj(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},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),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}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=t.inherit(f,{contains:[]}),y=t.inherit(h,{contains:[]});f.contains.push(y),h.contains.push(m);let b=[n,u];return[f,h,m,y].forEach(N=>{N.contains=N.contains.concat(b)}),b=b.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:b},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:b}]}]},n,i,f,h,{className:"quote",begin:"^>\\s+",contains:b,end:"$"},s,r,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function cj(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_]*/,c={"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:c,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 uj(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},l={begin:/->\{/,end:/\}/},c={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:[c]},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},h=[t.BACKSLASH_ESCAPE,i,u],m=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(w,k,N="\\1")=>{const C=N==="\\1"?N:e.concat(N,k);return e.concat(e.concat("(?:",w,")"),k,/(?:\\.|[^\\\/])*?/,C,/(?:\\.|[^\\\/])*?/,N,r)},b=(w,k,N)=>e.concat(e.concat("(?:",w,")"),k,/(?:\\.|[^\\\/])*?/,N,r),v=[u,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),l,{className:"string",contains:h,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:y("s|tr|y",e.either(...m,{capture:!0}))},{begin:y("s|tr|y","\\(","\\)")},{begin:y("s|tr|y","\\[","\\]")},{begin:y("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:b("(?:m|qr)?",/\//,/\//)},{begin:b("m|qr",e.either(...m,{capture:!0}),/\1/)},{begin:b("m|qr",/\(/,/\)/)},{begin:b("m|qr",/\[/,/\]/)},{begin:b("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=v,l.contains=v,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:v}}function dj(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),l={scope:"variable",match:"\\$+"+r},c={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}),h=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":(Q,ee)=>{ee.data._beginMatch=Q[1]||Q[2]},"on:end":(Q,ee)=>{ee.data._beginMatch!==Q[1]&&ee.ignoreMatch()}},y=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
|
|
203
|
+
]`,v={scope:"string",variants:[h,f,m,y]},w={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},k=["false","null","true"],N=["__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"],C=["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:N,literal:(Q=>{const ee=[];return Q.forEach(G=>{ee.push(G),G.toLowerCase()===G?ee.push(G.toUpperCase()):ee.push(G.toLowerCase())}),ee})(k),built_in:C},M=Q=>Q.map(ee=>ee.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,e.concat(b,"+"),e.concat("(?!",M(C).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},B=e.concat(r,"\\b(?!\\()"),U={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),B],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),B],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(/(?!::)/))},H={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[z,l,U,t.C_BLOCK_COMMENT_MODE,v,w,R]},$={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",M(N).join("\\b|"),"|",M(C).join("\\b|"),"\\b)"),r,e.concat(b,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[H]};H.contains.push($);const L=[z,U,t.C_BLOCK_COMMENT_MODE,v,w,R],Y={begin:e.concat(/#\[\s*\\?/,e.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:k,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:k,keyword:["new","array"]},contains:["self",...L]},...L,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:T,contains:[Y,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}]}},c,{scope:"variable.language",match:/\$this\b/},l,$,U,{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",Y,l,U,t.C_BLOCK_COMMENT_MODE,v,w]}]},{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]},v,w]}}function fj(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 pj(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function hj(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"],c={$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:c,illegal:/#/},h={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,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u,h,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,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,h,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",b=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,v=`\\b|${r.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${y})|(${b}))[eE][+-]?(${y})[jJ]?(?=${v})`},{begin:`(${b})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${v})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${v})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${v})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${v})`},{begin:`\\b(${y})[jJ](?=${v})`}]},k={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,w,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,w,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,k,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{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:[w,N,m]}]}}function mj(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function gj(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 yj(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+)*/),l={"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"]},c={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[c]}),t.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:l},m={className:"string",contains:[t.BACKSLASH_ESCAPE,h],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,h]})]}]},y="[1-9](_?[0-9])*|0",b="[0-9](_?[0-9])*",v={className:"number",relevance:0,variants:[{begin:`\\b(${y})(\\.(${b}))?([eE][+-]?(${b})|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"}]},w={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:l}]},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:l},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:l},{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:[w]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},v,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:l},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,h],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);h.contains=R,w.contains=R;const H=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:l,contains:R}}];return f.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(H).concat(f).concat(R)}}function bj(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*\(/))},l="([ui](8|16|32|64|128|size)|f(32|64))?",c=["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!"],h=["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:h,keyword:c,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_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],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:h}},{className:"punctuation",begin:"->"},i]}}const vj=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_-]*/}}),xj=["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"],wj=["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"],kj=[...xj,...wj],Sj=["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(),Ej=["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(),Nj=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Cj=["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 _j(t){const e=vj(t),n=Nj,r=Ej,s="@[a-z-]+",i="and or not only",c={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("+kj.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[e.CSS_NUMBER_MODE]},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Cj.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,c,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:Sj.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},c,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.HEXCOLOR,e.CSS_NUMBER_MODE]},e.FUNCTION_DISPATCH]}}function Tj(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Mj(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"],l=["double precision","large object","with timezone","without timezone"],c=["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"],h=["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"],y=["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"],b=h,v=[...f,...u].filter(M=>!h.includes(M)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},k={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},N={match:e.concat(/\b/,e.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function C(M){return e.concat(/\b/,e.either(...M.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const O={scope:"keyword",match:C(y),relevance:0};function T(M,{exceptions:R,when:B}={}){const U=B;return R=R||[],M.map(z=>z.match(/\|\d+$/)||R.includes(z)?z:U(z)?`${z}|0`:z)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(v,{when:M=>M.length<3}),literal:i,type:c,built_in:m},contains:[{scope:"type",match:C(l)},O,N,w,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,k]}}function o1(t){return t?typeof t=="string"?t:t.source:null}function yl(t){return wt("(?=",t,")")}function wt(...t){return t.map(n=>o1(n)).join("")}function Aj(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function zn(...t){return"("+(Aj(t).capture?"":"?:")+t.map(r=>o1(r)).join("|")+")"}const um=t=>wt(/\b/,t,/\w$/.test(t)?/\b/:/\B/),Oj=["Protocol","Type"].map(um),Gv=["init","self"].map(um),Rj=["Any","Self"],Sp=["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"],qv=["false","nil","true"],Ij=["assignment","associativity","higherThan","left","lowerThan","none","right"],jj=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Jv=["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"],l1=zn(/[/=\-+!*%<>&|^~?]/,/[\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]/),a1=zn(l1,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Ep=wt(l1,a1,"*"),c1=zn(/[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]/),Iu=zn(c1,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),zr=wt(c1,Iu,"*"),Tc=wt(/[A-Z]/,Iu,"*"),Lj=["attached","autoclosure",wt(/convention\(/,zn("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",wt(/objc\(/,zr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],Dj=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function Pj(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,zn(...Oj,...Gv)],className:{2:"keyword"}},i={match:wt(/\./,zn(...Sp)),relevance:0},l=Sp.filter(me=>typeof me=="string").concat(["_|0"]),c=Sp.filter(me=>typeof me!="string").concat(Rj).map(um),u={variants:[{className:"keyword",match:zn(...c,...Gv)}]},f={$pattern:zn(/\b\w+/,/#\w+/),keyword:l.concat(jj),literal:qv},h=[s,i,u],m={match:wt(/\./,zn(...Jv)),relevance:0},y={className:"built_in",match:wt(/\b/,zn(...Jv),/(?=\()/)},b=[m,y],v={match:/->/,relevance:0},w={className:"operator",relevance:0,variants:[{match:Ep},{match:`\\.(\\.|${a1})+`}]},k=[v,w],N="([0-9]_*)+",C="([0-9a-fA-F]_*)+",O={className:"number",relevance:0,variants:[{match:`\\b(${N})(\\.(${N}))?([eE][+-]?(${N}))?\\b`},{match:`\\b0x(${C})(\\.(${C}))?([pP][+-]?(${N}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(me="")=>({className:"subst",variants:[{match:wt(/\\/,me,/[0\\tnr"']/)},{match:wt(/\\/,me,/u\{[0-9a-fA-F]{1,8}\}/)}]}),M=(me="")=>({className:"subst",match:wt(/\\/,me,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(me="")=>({className:"subst",label:"interpol",begin:wt(/\\/,me,/\(/),end:/\)/}),B=(me="")=>({begin:wt(me,/"""/),end:wt(/"""/,me),contains:[T(me),M(me),R(me)]}),U=(me="")=>({begin:wt(me,/"/),end:wt(/"/,me),contains:[T(me),R(me)]}),z={className:"string",variants:[B(),B("#"),B("##"),B("###"),U(),U("#"),U("##"),U("###")]},H=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],$={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:H},L=me=>{const Ae=wt(me,/\//),Ue=wt(/\//,me);return{begin:Ae,end:Ue,contains:[...H,{scope:"comment",begin:`#(?!.*${Ue})`,end:/$/}]}},Y={scope:"regexp",variants:[L("###"),L("##"),L("#"),$]},Q={match:wt(/`/,zr,/`/)},ee={className:"variable",match:/\$\d+/},G={className:"variable",match:`\\$${Iu}+`},ne=[Q,ee,G],V={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:Dj,contains:[...k,O,z]}]}},X={scope:"keyword",match:wt(/@/,zn(...Lj),yl(zn(/\(/,/\s+/)))},te={scope:"meta",match:wt(/@/,zr)},A=[V,X,te],I={match:yl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:wt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Iu,"+")},{className:"type",match:Tc,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:wt(/\s+&\s+/,yl(Tc)),relevance:0}]},J={begin:/</,end:/>/,keywords:f,contains:[...r,...h,...A,v,I]};I.contains.push(J);const re={match:wt(zr,/\s*:/),keywords:"_|0",relevance:0},pe={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",re,...r,Y,...h,...b,...k,O,z,...ne,...A,I]},Ne={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,I]},Re={begin:zn(yl(wt(zr,/\s*:/)),yl(wt(zr,/\s+/,zr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:zr}]},Be={begin:/\(/,end:/\)/,keywords:f,contains:[Re,...r,...h,...k,O,z,...A,I,pe],endsParent:!0,illegal:/["']/},tt={match:[/(func|macro)/,/\s+/,zn(Q.match,zr,Ep)],className:{1:"keyword",3:"title.function"},contains:[Ne,Be,e],illegal:[/\[/,/%/]},ce={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Ne,Be,e],illegal:/\[|%/},xe={match:[/operator/,/\s+/,Ep],className:{1:"keyword",3:"title"}},ie={begin:[/precedencegroup/,/\s+/,Tc],className:{1:"keyword",3:"title"},contains:[I],keywords:[...Ij,...qv],end:/}/},Le={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},ae={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},ue={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,zr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[Ne,...h,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Tc},...h],relevance:0}]};for(const me of z.variants){const Ae=me.contains.find(ct=>ct.label==="interpol");Ae.keywords=f;const Ue=[...h,...b,...k,O,z,...ne];Ae.contains=[...Ue,{begin:/\(/,end:/\)/,contains:["self",...Ue]}]}return{name:"Swift",keywords:f,contains:[...r,tt,ce,Le,ae,ue,xe,ie,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},Y,...h,...b,...k,O,z,...ne,...A,I,pe]}}const ju="[A-Za-z$_][0-9A-Za-z$_]*",u1=["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"],d1=["true","false","null","undefined","NaN","Infinity"],f1=["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"],p1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],h1=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],m1=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],g1=[].concat(h1,f1,p1);function Bj(t){const e=t.regex,n=(V,{after:X})=>{const te="</"+V[0].slice(1);return V.input.indexOf(te,X)!==-1},r=ju,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,X)=>{const te=V[0].length+V.index,A=V.input[te];if(A==="<"||A===","){X.ignoreMatch();return}A===">"&&(n(V,{after:te})||X.ignoreMatch());let I;const J=V.input.substring(te);if(I=J.match(/^\s*=/)){X.ignoreMatch();return}if((I=J.match(/^\s+extends\s+/))&&I.index===0){X.ignoreMatch();return}}},c={$pattern:ju,keyword:u1,literal:d1,built_in:g1,"variable.language":m1},u="[0-9](_?[0-9])*",f=`\\.(${u})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${h})\\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},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,y]},C={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,b,v,w,k,{match:/\$\d+/},m];y.contains=O.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(O)});const T=[].concat(C,y.contains),M=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:M},B={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"}}]},U={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:{_:[...f1,...p1]}},z={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},H={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function L(V){return e.concat("(?!",V.join("|"),")")}const Y={match:e.concat(/\b/,L([...h1,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},Q={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ee={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},G="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(G)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:U},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),z,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,C,{match:/\$\d+/},m,U,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:G,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:c,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},H,{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},Q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},Y,$,B,ee,{match:/\$[(.]/}]}}function zj(t){const e=t.regex,n=Bj(t),r=ju,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:ju,keyword:u1.concat(u),literal:d1,built_in:g1.concat(s),"variable.language":m1},h={className:"meta",begin:"@"+r},m=(w,k,N)=>{const C=w.contains.findIndex(O=>O.label===k);if(C===-1)throw new Error("can not find mode to replace");w.contains.splice(C,1,N)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const y=n.contains.find(w=>w.scope==="attr"),b=Object.assign({},y,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,y,b]),n.contains=n.contains.concat([h,i,l,b]),m(n,"shebang",t.SHEBANG()),m(n,"use_strict",c);const v=n.contains.find(w=>w.label==="func.def");return v.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Fj(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}/,l=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:e.concat(/# */,e.either(i,s),/ *#/)},{begin:e.concat(/# */,c,/ *#/)},{begin:e.concat(/# */,l,/ *#/)},{begin:e.concat(/# */,e.either(i,s),/ +/,e.either(l,c),/ *#/)}]},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])|[%&])?/}]},h={className:"label",begin:/^\w+:/},m=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),y=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,h,m,y,{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:[y]}]}}function $j(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_]+/},l={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={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,l,s,t.QUOTE_STRING_MODE,u,f,c]}}function Uj(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/}]},l=t.inherit(i,{begin:/\(/,end:/\)/}),c=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,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,u,c]}]}]},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 Hj(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}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,s]},c=t.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),y={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"},b={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},v={begin:/\{/,end:/\}/,contains:[b],illegal:"\\n",relevance:0},w={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},k=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+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}},y,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},v,w,i,l],N=[...k];return N.pop(),N.push(c),b.contains=N,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:k}}const Wj={arduino:NI,bash:CI,c:_I,cpp:TI,csharp:MI,css:BI,diff:zI,go:FI,graphql:$I,ini:UI,java:HI,javascript:qI,json:JI,kotlin:QI,less:ij,lua:oj,makefile:lj,markdown:aj,objectivec:cj,perl:uj,php:dj,"php-template":fj,plaintext:pj,python:hj,"python-repl":mj,r:gj,ruby:yj,rust:bj,scss:_j,shell:Tj,sql:Mj,swift:Pj,typescript:zj,vbnet:Fj,wasm:$j,xml:Uj,yaml:Hj},Yv={},Vj="hljs-";function Kj(t){const e=Xk.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:l,registered:c};function n(u,f,h){const m=h||Yv,y=typeof m.prefix=="string"?m.prefix:Vj;if(!e.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");e.configure({__emitter:Gj,classPrefix:y});const b=e.highlight(f,{ignoreIllegals:!0,language:u});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const v=b._emitter.root,w=v.data;return w.language=b.language,w.relevance=b.relevance,v}function r(u,f){const m=(f||Yv).subset||s();let y=-1,b=0,v;for(;++y<m.length;){const w=m[y];if(!e.getLanguage(w))continue;const k=n(w,u,f);k.data&&k.data.relevance!==void 0&&k.data.relevance>b&&(b=k.data.relevance,v=k)}return v||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return e.listLanguages()}function i(u,f){if(typeof u=="string")e.registerLanguage(u,f);else{let h;for(h in u)Object.hasOwn(u,h)&&e.registerLanguage(h,u[h])}}function l(u,f){if(typeof u=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let h;for(h in u)if(Object.hasOwn(u,h)){const m=u[h];e.registerAliases(typeof m=="string"?m:[...m],{languageName:h})}}}function c(u){return!!e.getLanguage(u)}}class Gj{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(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),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 qj=new Ct("blurredLoadingNode"),dm=ft.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 bt({key:qj,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:l,type:c}=s;c==="selection"?n.push(Mt.inline(i,l,{class:"node-blur-selection"})):t.doc.nodesBetween(i,l,(u,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(u.type.name)?(n.push(Mt.node(f,f+u.nodeSize,{class:"node-blur-effect"})),!1):!0)}),mt.create(t.doc,n)}}})]}}),Jj=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],fm=ft.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:Jj,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}}}]}}),Yj=Kj(Wj),pm=u2.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",yt(this.options.HTMLAttributes,n),0]}}),Qj=[cm.configure({codeBlock:!1,link:!1,underline:!1}),SI.configure({lowlight:Yj}),pm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Jk,jR,PA,D2,B2,nR,tR.configure({nested:!0}),Jh,IR,Lk.configure({resizable:!1}),jk,Ik,Rk,dm,fm,ed.configure({placeholder:"Start writing..."}),am.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],Xj=[cm.configure({codeBlock:!1,horizontalRule:!1,heading:{levels:[1,2,3]},link:!1,underline:!1}),pm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Jh,dm,fm,ed.configure({placeholder:"Start writing..."}),am.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],Zj=ft.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.setHardBreak()}}}),y1=[cm.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),pm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Jh,dm,fm,Zj,am.configure({types:["paragraph","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...y1,ed.configure({placeholder:"What is happening?!"})];function Cr({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 Qv(){return d.jsx("div",{className:"floating-toolbar__divider"})}function eL({editor:t}){const[e,n]=E.useState(!1),[r,s]=E.useState({top:0,left:0}),[,i]=E.useState(0),l=E.useRef(-1),c=E.useRef(-1),u=E.useRef(!1);return E.useEffect(()=>{const f=t.view.dom,h=()=>{u.current=!0},m=()=>{if(!u.current)return;u.current=!1;const{from:y,to:b}=t.state.selection;if(y!==b){const v=t.isActive("codeBlock"),w=!!document.querySelector(".context-menu");if(!v&&!w){l.current=y,c.current=b;const k=t.view.coordsAtPos(y),N=t.view.coordsAtPos(b,1),C=(k.left+N.right)/2;s({top:k.top,left:C}),n(!0)}}};return f.addEventListener("mousedown",h),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",h),document.removeEventListener("mouseup",m)}},[t]),E.useEffect(()=>{const f=()=>{u.current=!1,n(!1),l.current=-1,c.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),E.useEffect(()=>{const f=()=>{const{from:h,to:m}=t.state.selection,y=h===m,b=t.isActive("codeBlock"),v=!!document.querySelector(".context-menu"),w=t.view.hasFocus();if(y||b||v||!w)n(!1),l.current=-1,c.current=-1;else if(!u.current&&(n(!0),h!==l.current||m!==c.current)){l.current=h,c.current=m;const k=t.view.coordsAtPos(h),N=t.view.coordsAtPos(m,1),C=(k.left+N.right)/2;s({top:k.top,left:C})}i(k=>k+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(Cr,{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(Cr,{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(Cr,{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(Cr,{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(Cr,{onClick:()=>{const f=t.getAttributes("link").href||"",h=window.prompt("Link URL:",f);h!==null&&(h===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:h}).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(Qv,{}),d.jsx(Cr,{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(Cr,{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(Cr,{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(Qv,{}),d.jsx(Cr,{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(Cr,{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(Cr,{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 tL=new Ct("pendingDecoration");let b1=null,v1=null;function Xv(t,e){b1=t,v1=e??null}let Lu=!1,x1=null,hm=null,w1=null;function mm(){return Lu}function nL(){return hm}function rL(){return w1}function fh(t,e,n,r){Lu=t,x1=t?e??null:null,hm=t?r??null:null,w1=t?n??null:null}function sL(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function Zv(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const l=t.child(i);if(l.isText){if(r+l.text.length>=n)return s+(n-r);r+=l.text.length,s+=l.nodeSize}else{const c=l.type.spec.leafText?l.type.spec.leafText(l).length:0;if(c>0&&r+c>=n)return s;r+=c,s+=l.nodeSize}}return n===r?s:null}function e0(t){const e=[];return t.descendants((n,r)=>{var v,w,k,N,C,O,T;const s=(v=n.attrs)==null?void 0:v.pendingStatus;if(!s)return!0;const i=(w=n.attrs)==null?void 0:w.id,l=(k=n.attrs)==null?void 0:k.pendingGroupId,c=l&&l===v1,f=Lu&&i===x1||l&&Lu&&l===hm,h=f?(N=n.attrs)==null?void 0:N.pendingOriginalFrom:(C=n.attrs)==null?void 0:C.pendingSelectionFrom,m=f?(O=n.attrs)==null?void 0:O.pendingOriginalTo:(T=n.attrs)==null?void 0:T.pendingSelectionTo,y=h!=null&&m!=null,b=f?"pending-original":sL(s);if(y&&n.isTextblock&&b){const M=Zv(n,r,h),R=Zv(n,r,m);M!==null&&R!==null&&M<R&&e.push(Mt.inline(M,R,{class:b}))}else b&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(Mt.inline(r+1,r+n.nodeSize-1,{class:b})):e.push(Mt.node(r,r+n.nodeSize,{class:b})));if(i&&(i===b1||c)){const M=f?"original":s;e.push(Mt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${M}`}))}return!0}),mt.create(t,e)}function k1(){return new bt({key:tL,state:{init(t,e){return e0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?e0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function gm(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const iL=new Ct("markDecoration");let $c=[];function t0(t){$c=t}function n0(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=s0(e,n,s),l=s0(e,n,s+t.text.length);return i===null||l===null||i>=l?null:Mt.inline(i,l,{class:"agent-mark",title:t.note?`Agent Mark: ${t.note}`:"Agent Mark","data-mark-id":t.id})}function r0(t){if($c.length===0)return mt.empty;const e=[],n=new Set,r=new Map;t.descendants((i,l)=>{var c;return i.isTextblock&&((c=i.attrs)!=null&&c.id)&&r.set(i.attrs.id,{node:i,pos:l}),!0});for(const i of $c){const l=r.get(i.nodeId);if(!l)continue;const c=n0(i,l.node,l.pos);c&&(n.add(i.id),e.push(c))}const s=$c.filter(i=>!n.has(i.id));return s.length>0&&t.descendants((i,l)=>{if(!i.isTextblock)return!0;for(const c of s){if(n.has(c.id))continue;const u=n0(c,i,l);u&&(n.add(c.id),e.push(u))}return!0}),mt.create(t,e)}function s0(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const l=t.child(i);if(l.isText){if(r+l.text.length>=n)return s+(n-r);r+=l.text.length,s+=l.nodeSize}else{const c=l.type.spec.leafText?l.type.spec.leafText(l).length:0;if(c>0&&r+c>=n)return s;r+=c,s+=l.nodeSize}}return n===r?s:null}function oL(){return new bt({key:iL,state:{init(t,e){return r0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceMarkUpdate")?r0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function i0(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceMarkUpdate",!0);n(r)}async function o0(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,l=i.schema.nodes.image.create({src:s,alt:t.name}),c=i.tr.replaceSelectionWith(l);e.dispatch(c)}catch{}}function Mc({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=E.useRef(s);i.current=s;const l=sk({extensions:e||Qj,content:t||"<p></p>",onUpdate:({editor:c})=>{mm()||n==null||n(c.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:(c,u)=>{var h;const f=(h=u.clipboardData)==null?void 0:h.items;if(!f)return!1;for(const m of f)if(m.type.startsWith("image/")){u.preventDefault();const y=m.getAsFile();return y&&o0(y,c),!0}return!1},handleDrop:(c,u)=>{var h;const f=(h=u.dataTransfer)==null?void 0:h.files;if(!(f!=null&&f.length))return!1;for(const m of f)if(m.type.startsWith("image/"))return u.preventDefault(),o0(m,c),!0;return!1}}},[t]);return E.useEffect(()=>{if(!l)return;const c=l.view.dom,u=f=>{var b;const m=f.target.closest("span.doc-link[data-doc]");if(!m)return;const y=m.getAttribute("data-doc");(b=i.current)==null||b.call(i,y)};return c.addEventListener("click",u,!0),()=>c.removeEventListener("click",u,!0)},[l]),E.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(h=>h.key==="pendingDecoration$"))return;const u=k1(),f=c.reconfigure({plugins:[...c.plugins,u]});l.view.updateState(f)},[l]),E.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(h=>h.key==="markDecoration$"))return;const u=oL(),f=c.reconfigure({plugins:[...c.plugins,u]});l.view.updateState(f)},[l]),E.useEffect(()=>{l&&(r==null||r(l))},[l,r]),l?d.jsxs(d.Fragment,{children:[d.jsx(Gh,{editor:l}),d.jsx(eL,{editor:l})]}):null}function Zt({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 po(){return d.jsx("div",{className:"format-toolbar__divider"})}async function lL(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 aL({editor:t}){const[,e]=E.useState(0),n=E.useRef(null);E.useEffect(()=>{const s=()=>e(i=>i+1);return t.on("transaction",s),()=>{t.off("transaction",s)}},[t]);const r=s=>{var l;const i=(l=s.target.files)==null?void 0:l[0];i&&lL(i,t),s.target.value=""};return d.jsxs("div",{className:"format-toolbar",children:[d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(Zt,{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(Zt,{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(Zt,{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(Zt,{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(Zt,{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(po,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(Zt,{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(Zt,{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(Zt,{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(po,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(Zt,{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(Zt,{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(Zt,{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(Zt,{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(po,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(Zt,{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(Zt,{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(Zt,{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(po,{}),d.jsx("div",{className:"format-toolbar__group",children:d.jsx(Zt,{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(po,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(Zt,{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(Zt,{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(Zt,{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(po,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(Zt,{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(Zt,{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 cL={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 uL(){const[t,e]=E.useState(!1),[n,r]=E.useState(F0),[s,i]=E.useState($0),[l,c]=E.useState(zu),u=U0(),[f,h]=E.useState(W0),[m,y]=E.useState(V0),b=E.useRef(null),v=(T=n,M=s,R=l,B=u,U=f,z=m)=>{K0(T,M,R,B,U,z)},w=T=>{r(T),v(T)},k=()=>{const T=s==="light"?"dark":"light";i(T),v(void 0,T)},N=T=>{c(T),v(void 0,void 0,T),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:T}))},C=T=>{h(T),v(void 0,void 0,void 0,void 0,T)},O=T=>{y(T),v(void 0,void 0,void 0,void 0,void 0,T)};return E.useEffect(()=>{if(!t)return;const T=M=>{b.current&&!b.current.contains(M.target)&&e(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),d.jsxs("div",{className:"appearance-wrapper",ref:b,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:k,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:D0.map(T=>d.jsx("button",{className:`appearance-style-option ${n===T.id?"active":""}`,onClick:()=>w(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:z0.map(T=>d.jsx("button",{className:`appearance-style-option ${f===T.id?"active":""}`,onClick:()=>C(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:B0.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:P0.map(T=>d.jsxs("button",{className:`appearance-mode-option ${l===T.id?"active":""}`,onClick:()=>N(T.id),children:[cL[T.icon],d.jsx("span",{children:T.label})]},T.id))})]})]})]})}function dL(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function fL(){const[t,e]=E.useState(!1),[n,r]=E.useState([]),[s,i]=E.useState(null),[l,c]=E.useState(new Set),u=E.useRef(null),f=E.useCallback(()=>{fetch("/api/available-plugins").then(y=>y.json()).then(y=>r(y.plugins||[])).catch(()=>{})},[]);E.useEffect(()=>{t&&f()},[t,f]),E.useEffect(()=>{const y=()=>f();return window.addEventListener("ow-plugins-changed",y),()=>window.removeEventListener("ow-plugins-changed",y)},[f]),E.useEffect(()=>{if(!t)return;const y=b=>{u.current&&!u.current.contains(b.target)&&e(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[t]);const h=E.useCallback(async(y,b)=>{i(y);try{(await fetch(b?"/api/plugins/disable":"/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y})})).ok&&f()}catch{}finally{i(null)}},[f]),m=E.useCallback((y,b,v)=>{fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,config:{[b]:v}})}).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(y=>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:[dL(y.name),d.jsxs("span",{className:"plugin-item-version",children:["v",y.version]})]}),y.description&&d.jsx("div",{className:"plugin-item-desc",children:y.description})]}),d.jsxs("label",{className:`plugin-toggle${s===y.name?" loading":""}`,children:[d.jsx("input",{type:"checkbox",checked:y.enabled,disabled:s===y.name,onChange:()=>h(y.name,y.enabled)}),d.jsx("span",{className:"plugin-toggle-track"}),d.jsx("span",{className:"plugin-toggle-thumb"})]})]}),y.enabled&&Object.keys(y.configSchema).length>0&&d.jsxs("div",{className:"plugin-config-section",children:[d.jsxs("button",{className:"plugin-config-toggle",onClick:()=>c(b=>{const v=new Set(b);return v.has(y.name)?v.delete(y.name):v.add(y.name),v}),children:[d.jsx("svg",{className:`plugin-config-chevron${l.has(y.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"]}),l.has(y.name)&&d.jsx("div",{className:"plugin-config",children:Object.entries(y.configSchema).map(([b,v])=>d.jsxs("div",{className:"plugin-config-field",children:[d.jsx("label",{className:"plugin-config-label",children:v.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:y.config[b]||"",placeholder:v.env?`$${v.env}`:"",onBlur:w=>m(y.name,b,w.target.value)})]},b))})]})]},y.name))]})]})}function pL(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 hL(t){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function mL(){const[t,e]=E.useState(!1),[n,r]=E.useState([]),[s,i]=E.useState(null),[l,c]=E.useState(!1),u=E.useRef(null),f=E.useCallback(()=>{fetch("/api/versions").then(m=>m.json()).then(m=>{r(Array.isArray(m)?m:[]),i(null)}).catch(()=>r([]))},[]);E.useEffect(()=>{t&&f()},[t,f]),E.useEffect(()=>{if(!t)return;const m=y=>{u.current&&!u.current.contains(y.target)&&e(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[t]);const h=E.useCallback(async m=>{if(s!==null){c(!0);try{(await fetch(`/api/versions/${s}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:m})})).ok&&f()}catch{}c(!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:pL(m.timestamp)}),d.jsxs("span",{className:"version-dropdown__item-meta",children:[m.wordCount.toLocaleString()," words · ",hL(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||l,onClick:()=>h("review"),children:"Review"}),d.jsx("button",{className:"version-dropdown__restore-btn",disabled:s===null||l,onClick:()=>h("full"),children:"Restore"})]})]})]})}const gL=[{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 yL(){const[t,e]=E.useState(!1),n=E.useRef(null);E.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:gL.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 bL({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=E.useState("form"),[i,l]=E.useState(null),[c,u]=E.useState((t==null?void 0:t.domain)||""),[f,h]=E.useState(""),[m,y]=E.useState((t==null?void 0:t.from_name)||""),[b,v]=E.useState(""),[w,k]=E.useState((t==null?void 0:t.id)||""),[N,C]=E.useState({dns_verified:!1,sender_verified:!1}),O=E.useRef(null),T=E.useRef(null);E.useEffect(()=>{const $=L=>{r!=="submitting"&&r!=="verifying"&&T.current&&!T.current.contains(L.target)&&e()};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[e,r]),E.useEffect(()=>{const $=L=>{L.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[e,r]),E.useEffect(()=>()=>{O.current&&clearInterval(O.current)},[]);async function M(){var $,L;s("submitting"),l(null);try{const Q=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:c,from_email:f,from_name:m||void 0,physical_address:b}})})).json(),ee=(L=($=Q.content)==null?void 0:$[0])!=null&&L.text?JSON.parse(Q.content[0].text):Q;if(ee.error){l(ee.error),s("error");return}const G=ee.connectionId||ee.connection_id||w;G&&k(G),B(G)}catch(Y){l(Y.message),s("error")}}async function R(){var $,L;s("submitting"),l(null);try{const Q=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:c,from_email:f||void 0,from_name:m||void 0,physical_address:b||void 0}})})).json(),ee=(L=($=Q.content)==null?void 0:$[0])!=null&&L.text?JSON.parse(Q.content[0].text):Q;if(ee.error){l(ee.error),s("error");return}s("done")}catch(Y){l(Y.message),s("error")}}function B($){s("verifying"),O.current=setInterval(async()=>{var L,Y;try{const ee=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:$}})})).json(),G=(Y=(L=ee.content)==null?void 0:L[0])!=null&&Y.text?JSON.parse(ee.content[0].text):ee,ne=!!G.dns_verified,V=!!G.sender_verified;C({dns_verified:ne,sender_verified:V}),ne&&V&&(O.current&&clearInterval(O.current),O.current=null,s("done"))}catch{}},5e3)}function U(){w&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:w}})}).catch(()=>{})}const z=!!t,H=c.trim()&&f.trim()&&b.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:c,onChange:$=>u($.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:$=>h($.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:$=>y($.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:b,onChange:$=>v($.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:M,disabled:!H,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${N.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[N.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${N.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[N.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:U,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 vL=[{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 xL(){const[t,e]=E.useState(!1),[n,r]=E.useState([]),[s,i]=E.useState(null),[l,c]=E.useState(null),[u,f]=E.useState(null),h=E.useRef(null),m=E.useRef(null);E.useEffect(()=>{if(!t)return;const C=O=>{h.current&&!h.current.contains(O.target)&&(e(!1),i(null))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[t]),E.useEffect(()=>{t&&y()},[t]),E.useEffect(()=>()=>{m.current&&clearInterval(m.current)},[]);function y(){fetch("/api/connections").then(C=>C.json()).then(C=>{const O=(C.connections||[]).filter(T=>T&&T.id&&T.provider);r(O)}).catch(()=>{})}async function b(C){c(C);try{const O=await fetch(`/api/connections/oauth/${C}/start`,{method:"POST"}),T=await O.json();if(!O.ok||!T.url){c(null);return}window.open(T.url,"_blank","width=600,height=700"),m.current=setInterval(async()=>{try{const R=await(await fetch(`/api/connections/oauth/${C}/status/${T.state}`)).json();R.status==="completed"?(m.current&&clearInterval(m.current),m.current=null,c(null),y()):R.status==="failed"&&(m.current&&clearInterval(m.current),m.current=null,c(null))}catch{}},2e3)}catch{c(null)}}async function v(C){await fetch(`/api/connections/${C}`,{method:"DELETE"}),i(null),y()}function w(C){return C==="active"?"connections-status--active":C==="expired"?"connections-status--expired":C==="revoked"?"connections-status--revoked":"connections-status--pending"}function k(C){switch(C){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 N=new Map;for(const C of n)N.set(C.provider,C);return d.jsxs("div",{className:"connections-wrapper",ref:h,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"})]})}),u&&d.jsx(bL,{existingConnection:u==="edit"?N.get("newsletter"):null,onClose:()=>f(null),onSaved:()=>y()}),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:vL.map(C=>{const O=N.get(C.id);return O&&s===O.id?d.jsxs("div",{className:"connections-dropdown__confirm",children:[d.jsxs("span",{children:["Disconnect ",C.label,"?"]}),d.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[d.jsx("button",{onClick:()=>v(O.id),children:"Yes"}),d.jsx("button",{onClick:()=>i(null),children:"No"})]})]},C.id):O?d.jsxs("div",{className:"connections-dropdown__item",children:[d.jsx("div",{className:"connections-dropdown__icon",children:k(C.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:O.display_name||O.domain||C.label}),d.jsxs("div",{className:"connections-dropdown__type",children:[d.jsx("span",{className:`connections-status ${w(O.status)}`}),"Connected"]})]}),d.jsxs("div",{className:"connections-dropdown__actions",children:[C.id==="newsletter"&&d.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>f("edit"),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"})]})}),C.oauth&&d.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>i(O.id),title:"Disconnect",children:"×"})]})]},C.id):C.oauth?d.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[d.jsx("div",{className:"connections-dropdown__icon",children:k(C.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:C.label}),d.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),d.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>b(C.id),disabled:l!==null,children:l===C.id?"Connecting…":"Connect"})]},C.id):d.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[d.jsx("div",{className:"connections-dropdown__icon",children:k(C.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:C.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"})]},C.id)})})]})]})}const wL=()=>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"})}),kL=()=>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"})]}),SL=()=>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"})]}),EL=()=>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 NL({title:t,onTitleChange:e,syncStatus:n,onSync:r,onToggleSidebar:s,canGoBack:i,canGoForward:l,onGoBack:c,onGoForward:u,editor:f,onToggleToolbar:h,toolbarOpen:m}){const[y,b]=E.useState(!1),[,v]=E.useState(0),w=E.useRef(null),[k,N]=E.useState(!1),[C,O]=E.useState([]),[T,M]=E.useState(!1),R=E.useRef(null),B=E.useCallback(()=>{b(!0),setTimeout(()=>{var $;return($=w.current)==null?void 0:$.select()},0)},[]),U=E.useCallback(()=>{b(!1)},[]),z=E.useCallback($=>{$.key==="Enter"&&b(!1),$.key==="Escape"&&b(!1)},[]),H=E.useCallback(()=>{if(k){N(!1);return}N(!0),M(!0),fetch("/api/sync/pending").then($=>$.json()).then($=>O($)).catch(()=>O([])).finally(()=>M(!1))},[k]);return E.useEffect(()=>{n.state!=="pending"&&N(!1)},[n.state]),E.useEffect(()=>{if(!k)return;const $=L=>{R.current&&!R.current.contains(L.target)&&N(!1)};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[k]),E.useEffect(()=>{if(!f)return;const $=()=>v(L=>L+1);return f.on("transaction",$),()=>{f.off("transaction",$)}},[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"})]})}),c&&d.jsx("button",{className:"titlebar-nav-btn",onClick:c,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:!l,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.jsx("div",{className:"titlebar-center",children:y?d.jsx("input",{ref:w,className:"titlebar-input",value:t,onChange:$=>e($.target.value),onBlur:U,onKeyDown:z,autoFocus:!0}):d.jsx("span",{className:"titlebar-title",onDoubleClick:B,children:t})}),d.jsxs("div",{className:"titlebar-right",children:[h&&d.jsx("button",{className:`titlebar-nav-btn${m?" titlebar-nav-btn--active":""}`,onClick:h,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(fL,{}),d.jsx(xL,{}),d.jsx(uL,{}),d.jsx(mL,{}),d.jsx(yL,{}),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(wL,{})," Sync"]}),n.state==="synced"&&d.jsxs(d.Fragment,{children:[d.jsx(kL,{})," Synced"]}),n.state==="pending"&&d.jsxs(d.Fragment,{children:[d.jsx(SL,{})," 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(EL,{})," Retry"]})]}),n.state==="pending"&&n.pendingFiles&&n.pendingFiles>0&&d.jsx("button",{className:"sync-details-btn",onClick:H,title:"View pending changes",children:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:d.jsx("path",{d:k?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),k&&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..."}):C.length===0?d.jsx("div",{className:"sync-pending-loading",children:"No changes"}):d.jsx("div",{className:"sync-pending-list",children:C.map(($,L)=>d.jsxs("div",{className:`sync-pending-item sync-file-${$.status}`,children:[d.jsx("span",{className:"sync-file-badge",children:$.status[0].toUpperCase()}),d.jsx("span",{className:"sync-file-name",children:$.file})]},L))})]})]})]})]})}function mn(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 nd(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 ko(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function Du(t){return t?Array.isArray(t)?t.map(Du).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>Du(e)).join(""):"":""}const CL=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Pu(t,e){for(const n of t)n.type&&CL.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Pu(n.content,e)}function ph(t,e,n){const r=Array.isArray(n)?n:[n];if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const b=mn(t,e.nodeId);if(!b)return{success:!1,error:`Node ${e.nodeId} not found`};const v=r.map((w,k)=>{var N;return{...w,attrs:{...w.attrs,id:((N=w.attrs)==null?void 0:N.id)||(k===0?e.nodeId:ko())}}});Pu(v,"insert");try{return t.chain().deleteRange({from:b.pos,to:b.pos+b.node.nodeSize}).insertContentAt(b.pos,v).run(),{success:!0,nodeId:e.nodeId}}catch(w){return{success:!1,error:`Failed to replace empty node: ${w}`}}}if(!e.afterNodeId&&!e.beforeNodeId)return{success:!1,error:"Insert requires afterNodeId, beforeNodeId, or nodeId"};const s=e.afterNodeId||e.beforeNodeId,i=!!e.afterNodeId,l=mn(t,s);if(!l)return{success:!1,error:`Anchor node ${s} not found`};const c=Du(n),u=i?l.pos+l.node.nodeSize:0,f=i?l.pos+l.node.nodeSize+5e3:l.pos;let h=null;if(t.state.doc.nodesBetween(u,Math.min(f,t.state.doc.content.size),b=>{var v,w;return((v=b.attrs)==null?void 0:v.pendingStatus)==="insert"&&((w=b.attrs)!=null&&w.id)&&(b.textContent||"")===c?(h=b.attrs.id,!1):!0}),h)return{success:!0,nodeId:h};const m=r.map(b=>{var v;return{...b,attrs:{...b.attrs,id:((v=b.attrs)==null?void 0:v.id)||ko()}}});Pu(m,"insert");const y=i?l.pos+l.node.nodeSize:l.pos;try{return t.chain().insertContentAt(y,m).run(),{success:!0,nodeId:m[0].attrs.id}}catch(b){return{success:!1,error:`Failed to insert content: ${b}`}}}function ym(t,e,n,r){var b;const s=mn(t,e);if(!s)return{success:!1,error:`Node ${e} not found`};const{node:i,pos:l}=s,c=Array.isArray(n)?n:[n],f=!((b=i.attrs)!=null&&b.pendingOriginalContent)?i.toJSON():i.attrs.pendingOriginalContent,h={...c[0],attrs:{...c[0].attrs,id:e,pendingStatus:"rewrite",pendingOriginalContent:f,...r?{pendingSelectionFrom:r.selectionFrom,pendingSelectionTo:r.selectionTo,pendingOriginalFrom:r.originalFrom,pendingOriginalTo:r.originalTo}:{}}},m=c.slice(1).map(v=>{var w;return{...v,attrs:{...v.attrs,id:((w=v.attrs)==null?void 0:w.id)||ko()}}});Pu(m,"insert");const y=[h,...m];try{return t.chain().deleteRange({from:l,to:l+i.nodeSize}).insertContentAt(l,y.length===1?y[0]:y).run(),{success:!0,nodeId:e}}catch(v){return{success:!1,error:`Failed to rewrite: ${v}`}}}function _L(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=>Du(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=mn(t,e[0]),i=mn(t,e[e.length-1]);if(!s||!i)return{success:!1,error:"Could not find original nodes for range rewrite"};const l=[];for(const m of e){const y=mn(t,m);y&&l.push(y.node.toJSON())}const c=s.pos,u=i.pos+i.node.nodeSize,f=ko()+ko(),h=n.map((m,y)=>{var b;return{...m,attrs:{...m.attrs,id:((b=m.attrs)==null?void 0:b.id)||ko(),pendingStatus:"rewrite",pendingGroupId:f,...y===0?{pendingOriginalContent:l}:{}}}});try{return t.chain().deleteRange({from:c,to:u}).insertContentAt(c,h).run(),{success:!0,nodeId:h[0].attrs.id}}catch(m){return{success:!1,error:`Failed to apply range rewrite: ${m}`}}}function S1(t,e){var i;const n=mn(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:l})=>(l.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:"delete"}),!0)).run(),{success:!0,nodeId:e}}catch(l){return{success:!1,error:`Failed to mark for deletion: ${l}`}}}function TL(t,e){if(e.operation==="rewrite"&&e.nodeId&&e.content){const n=ym(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=ph(t,n,e.content);return{success:r.success,error:r.error}}if(e.operation==="delete"&&e.nodeId){const n=S1(t,e.nodeId);return{success:n.success,error:n.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function l0(t,e){if(e.length===0)return;if(e.length===1){TL(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 l=Ac(r.doc,i.nodeId);if(!l)continue;const u=(Array.isArray(i.content)?i.content:[i.content]).map(f=>n.nodeFromJSON(f));r.replaceWith(l.pos,l.pos+l.node.nodeSize,u)}else if(i.operation==="insert"&&i.content){const c=(Array.isArray(i.content)?i.content:[i.content]).map(u=>n.nodeFromJSON(u));if(i.nodeId&&!i.afterNodeId){const u=Ac(r.doc,i.nodeId);if(!u)continue;r.replaceWith(u.pos,u.pos+u.node.nodeSize,c)}else if(i.afterNodeId){const u=Ac(r.doc,i.afterNodeId);if(!u)continue;const f=u.pos+u.node.nodeSize;r.insert(f,le.fromArray(c))}}else if(i.operation==="delete"&&i.nodeId){const l=Ac(r.doc,i.nodeId);if(!l||((s=l.node.attrs)==null?void 0:s.pendingStatus)==="delete")continue;r.setNodeMarkup(l.pos,void 0,{...l.node.attrs,pendingStatus:"delete"})}}catch{continue}return!0}).run()}function Ac(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 a0(t,e,n,r){const s=[];if(r==="delete"){for(const l of n)s.push(S1(t,l));return s}if(r==="insert"){const l=n[n.length-1];return l&&e.length>0&&s.push(ph(t,{nodeId:l},e)),s}if(n.length>1){const l=_L(t,n,e);return s.push(l),s}const i=ym(t,n[0],e[0]);if(s.push(i),e.length>1){const l=e.slice(1);s.push(ph(t,{afterNodeId:n[0]},l))}return s}const c0="[[START_SELECTION]]",u0="[[END_SELECTION]]";function ML(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 Oc(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=ML(t);let s=Math.max(0,Math.min(e,r));for(let i=0;i<t.content.length;i++){const l=t.content[i];if(l.type==="text"&&typeof l.text=="string"){if(s<=l.text.length){const c=Math.max(0,Math.min(l.text.length,s));l.text=l.text.slice(0,c)+n+l.text.slice(c);return}s-=l.text.length;continue}if(l.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 AL(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(Oc(r[0],n,u0),Oc(r[0],e,c0),r):(Oc(r[0],e,c0),Oc(r[r.length-1],n,u0),r)}function OL(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 RL=[{action:"agent-mark",label:"Agent Mark",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function IL({editorRef:t,allEditors:e,documentId:n}){const[r,s]=E.useState(!1),[i,l]=E.useState({x:0,y:0}),[c,u]=E.useState(!1),[f,h]=E.useState(""),[m,y]=E.useState(!1),[b,v]=E.useState(""),[w,k]=E.useState(!1),[N,C]=E.useState([]),[O,T]=E.useState([]),[M,R]=E.useState(!1),[B,U]=E.useState(""),[z,H]=E.useState([]),[$,L]=E.useState(!1),[Y,Q]=E.useState(""),ee=E.useRef(null),G=E.useRef(null),ne=E.useRef(null),V=E.useCallback(ce=>{if(e&&e.length>0){for(const ie of e)if(ie.view.dom.contains(ce))return ie}const xe=t.current;return xe&&xe.view.dom.contains(ce)?xe:null},[e,t]);E.useLayoutEffect(()=>{const ce=ee.current;if(!ce||!r)return;const xe=ce.getBoundingClientRect(),ie=8;let{x:Le,y:ae}=i;ae+xe.height+ie>window.innerHeight&&(ae=i.y-xe.height),Le+xe.width+ie>window.innerWidth&&(Le=i.x-xe.width),ae<ie&&(ae=ie),Le<ie&&(Le=ie),(Le!==i.x||ae!==i.y)&&l({x:Le,y:ae})},[r,i]);const X=E.useCallback(()=>{fetch("/api/plugins").then(ce=>ce.json()).then(ce=>{const xe=[];for(const ie of ce.plugins||[]){const Le=ie.displayName||void 0;for(const ae of ie.contextMenuItems||[])xe.push({...ae,pluginDisplayName:Le})}H(xe)}).catch(()=>{})},[]);E.useEffect(()=>{X()},[X]),E.useEffect(()=>{const ce=()=>X();return window.addEventListener("ow-plugins-changed",ce),()=>window.removeEventListener("ow-plugins-changed",ce)},[X]),E.useEffect(()=>{const ce=xe=>{ee.current&&!ee.current.contains(xe.target)&&(s(!1),y(!1),k(!1),L(!1),Q(""))};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[]);const te=E.useCallback(()=>{const ce=ne.current||t.current;return ce?ce.isActive("link"):!1},[t]),A=E.useCallback(()=>{const ce=ne.current||t.current,xe=G.current;if(!ce||!xe)return!1;const{from:ie,to:Le}=xe;let ae=!1;return ce.state.doc.nodesBetween(ie,Le,ue=>{var me;return(me=ue.attrs)!=null&&me.pendingStatus&&(ae=!0),!ae}),ae},[t]),I=E.useCallback(()=>{const ce=ne.current||t.current,xe=G.current,ie=(xe==null?void 0:xe.from)??0,Le=(xe==null?void 0:xe.to)??0,ae=ie!==Le,ue=(()=>{if(!ce)return!1;try{return ce.state.doc.resolve(ie).parent.content.size===0}catch{return!1}})(),me=A(),Ae=[];for(const Ue of z)Ue.condition==="has-selection"&&!ae||Ue.condition==="empty-node"&&!ue||Ae.push({action:Ue.action,label:Ue.label,shortcut:Ue.shortcut,isPlugin:!0,promptForInput:Ue.promptForInput,pluginDisplayName:Ue.pluginDisplayName});for(const Ue of RL)Ue.condition==="has-selection"&&(!ae||me)||Ae.push(Ue);return ae&&Ae.push({action:"link",label:"Link to doc",shortcut:"L"}),te()&&Ae.push({action:"unlink",label:"Unlink"}),Ae},[t,te,z,A]);E.useEffect(()=>{const ce=ie=>{var Ue;if(ie.button!==2)return;const Le=V(ie.target);if(!Le)return;ne.current=Le;const{from:ae,to:ue}=Le.state.selection,me=[],Ae=[];if(ae!==ue&&Le.state.doc.nodesBetween(ae,ue,ct=>{ct.isBlock&&ct.type.name!=="doc"&&(me.push(ct.toJSON()),ct.attrs.id&&Ae.push(ct.attrs.id))}),me.length===0){const{$from:ct}=Le.state.selection,pt=ct.parent;pt&&pt.type.name!=="doc"&&(me.push(pt.toJSON()),(Ue=pt.attrs)!=null&&Ue.id&&Ae.push(pt.attrs.id))}G.current={from:ae,to:ue,nodes:me,nodeIds:Ae}},xe=ie=>{V(ie.target)&&(ie.shiftKey||(ie.preventDefault(),l({x:ie.clientX,y:ie.clientY}),s(!0),y(!1),k(!1),L(!1),Q("")))};return document.addEventListener("mousedown",ce,!0),document.addEventListener("contextmenu",xe),()=>{document.removeEventListener("mousedown",ce,!0),document.removeEventListener("contextmenu",xe)}},[V]);const J=E.useCallback(async(ce,xe)=>{var Qn,yn,lt,Ot,bn;const ie=ne.current||t.current;if(!ie)return;const Le=G.current;if(!Le||Le.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",ce);return}let{nodes:ae,nodeIds:ue}=Le;const{from:me,to:Ae}=Le;u(!0),s(!1),y(!1);const Ue=`ctx-${Date.now()}`,ct=ie.state.doc.resolve(me),pt=ie.state.doc.resolve(Ae),Lt=ct.sameParent(pt)&&me!==Ae;ie.commands.applyLoadingEffect(Ue,me,Ae,Lt?"selection":"paragraph");try{const qt=[],Jt=[],Xn=new Set(ue);let Z=!1;const Ge=ie.state.doc;for(let Fe=0;Fe<Ge.childCount;Fe++){const St=Ge.child(Fe),$t=(Qn=St.attrs)==null?void 0:Qn.id;if($t&&Xn.has($t))Z=!0;else if(Z){const D=St.textContent.trim();D&&Jt.push(D)}else{const D=St.textContent.trim();D&&qt.push(D)}}const He=ce.includes(":")?ce.split(":").slice(1).join(":"):ce;let kt=ae,Ze=!1,nt=0,qe=0;if(Lt&&ae.length===1){const Fe=ct.start(ct.depth);nt=me-Fe,qe=Ae-Fe;const St=((lt=(yn=ae[0])==null?void 0:yn.content)==null?void 0:lt.reduce(($t,D)=>{var se;return $t+(((se=D.text)==null?void 0:se.length)||(D.type==="hardBreak"?1:0))},0))??0;(nt>0||qe<St)&&(kt=AL(ae,nt,qe),Ze=!0)}const Un=ie.state.doc.textContent,ln={nodes:kt,action:He,nodeIds:ue,contextBefore:qt.slice(-3),contextAfter:Jt.slice(0,3),fullDocument:Un,documentId:n,debug:!0};Ze&&(ln.hasSelectionMarkers=!0),xe&&(ln.instruction=xe);const oe=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ln)});if(!oe.ok){const Fe=await oe.json().catch(()=>({}));console.error("[ContextMenu] API error:",oe.status,Fe);return}const ve=await oe.json();if(ve.success&&ve.nodes){let Fe=ve.nodes;if(Fe.length===1&&Array.isArray(Fe[0])&&(Fe=Fe[0]),OL(Fe),Ze&&Fe.length===1&&ue.length===1){const St=we=>(we==null?void 0:we.reduce((Je,xt)=>{var Et;return Je+(((Et=xt.text)==null?void 0:Et.length)||(xt.type==="hardBreak"?1:0))},0))??0,$t=St((Ot=ae[0])==null?void 0:Ot.content),D=St((bn=Fe[0])==null?void 0:bn.content),se={selectionFrom:nt,selectionTo:D-($t-qe),originalFrom:nt,originalTo:qe};ym(ie,ue[0],Fe[0],se)}else a0(ie,Fe,ue,He)}else console.warn("[ContextMenu] Unexpected response:",ve)}catch(qt){console.error("[ContextMenu] Plugin action failed:",qt)}finally{ie.commands.removeLoadingEffect(Ue),u(!1)}},[t]),re=E.useCallback(async ce=>{const xe=ne.current||t.current;if(!xe)return;const{$from:ie}=xe.state.selection,Le=ie.before(ie.depth),ae=ie.after(ie.depth),ue=ie.parent.content.size===0;u(!0),s(!1),y(!1);const me=`ctx-img-${Date.now()}`;xe.commands.applyLoadingEffect(me,Le,ae,"paragraph");try{const Ue=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:ce})})).json();Ue.success&&Ue.src?ue?xe.chain().focus().deleteRange({from:Le,to:ae}).insertContentAt(Le,{type:"image",attrs:{src:Ue.src,alt:ce}}).run():xe.chain().focus().insertContentAt(ae,{type:"image",attrs:{src:Ue.src,alt:ce}}).run():console.error("[ContextMenu] Image generation failed:",Ue.error)}catch(Ae){console.error("[ContextMenu] Image generation failed:",Ae)}finally{xe.commands.removeLoadingEffect(me),u(!1)}},[t]),pe=E.useCallback(ce=>{const{action:xe,isPlugin:ie,promptForInput:Le}=ce;if(ie&&Le){v(xe),y(!0);return}if(ie){if(xe.startsWith("img:"))return;J(xe);return}if(xe==="agent-mark"){L(!0);return}if(xe==="delete"){const ae=ne.current||t.current;if(ae){const{from:ue,to:me}=ae.state.selection;ae.state.doc.nodesBetween(ue,me,Ae=>{Ae.isBlock&&Ae.type.name!=="doc"&&Ae.attrs.id&&a0(ae,[],[Ae.attrs.id],"delete")})}s(!1);return}if(xe==="link"){const ae=ne.current||t.current;if(ae){const ue=[];ae.state.doc.descendants(me=>{var Ae;(Ae=me.marks)==null||Ae.forEach(Ue=>{var ct,pt;if(Ue.type.name==="link"&&((pt=(ct=Ue.attrs)==null?void 0:ct.href)!=null&&pt.startsWith("doc:"))){const Lt=Ue.attrs.href.slice(4);ue.includes(Lt)||ue.push(Lt)}})}),T(ue)}fetch("/api/documents").then(ue=>ue.json()).then(ue=>{Array.isArray(ue)&&C(ue.map(me=>({filename:me.filename,title:me.title}))),R(!1),U(""),k(!0)}).catch(()=>{});return}if(xe==="unlink"){const ae=ne.current||t.current;ae&&ae.chain().focus().unsetLink().run(),s(!1);return}},[J,t]),Ne=E.useCallback(()=>{f.trim()&&(b.startsWith("img:")?re(f.trim()):J(b,f.trim()),h(""),v(""))},[J,re,b,f]),Re=E.useCallback(()=>{const ce=ne.current||t.current,xe=G.current;if(!ce||!xe||!n)return;const{from:ie,to:Le,nodeIds:ae}=xe;if(ie===Le||ae.length===0)return;const ue=ce.state.doc.textBetween(ie,Le,`
|
|
204
|
+
`);ue.trim()&&fetch("/api/marks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:ue,note:Y.trim(),nodeId:ae[ae.length-1]})}).then(()=>{s(!1),L(!1),Q("")}).catch(me=>{console.error("[ContextMenu] Agent mark failed:",me)})},[t,n,Y]),Be=E.useCallback(ce=>{const xe=ne.current||t.current;xe&&xe.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),k(!1)},[t]),tt=E.useCallback(()=>{const ce=B.trim();if(!ce)return;const xe=ne.current||t.current;xe&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ce})}).then(ie=>ie.json()).then(ie=>{ie.filename&&xe.chain().focus().setLink({href:`doc:${ie.filename}`}).run()}).catch(()=>{}),s(!1),k(!1),R(!1),U(""))},[t,B]);return r?d.jsx("div",{ref:ee,className:"context-menu",style:{left:i.x,top:i.y},children:c?d.jsx("div",{className:"context-menu-loading",children:"Applying..."}):$?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:Y,onChange:ce=>Q(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&Re(),ce.key==="Escape"&&(L(!1),Q(""))},placeholder:"Note for agent (optional)..."}),d.jsx("button",{onClick:Re,children:"Mark"})]}):m?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:f,onChange:ce=>h(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&Ne(),ce.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),d.jsx("button",{onClick:Ne,children:"Apply"})]}):w?d.jsxs("div",{className:"context-menu-link-picker",children:[d.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),M?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:B,onChange:ce=>U(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&tt(),ce.key==="Escape"&&R(!1)},placeholder:"New document title..."}),d.jsx("button",{onClick:tt,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"}),N.filter(ce=>O.includes(ce.filename)).map(({filename:ce,title:xe})=>d.jsx("button",{className:"context-menu-item",onClick:()=>Be(ce),children:d.jsx("span",{children:xe})},`linked-${ce}`))]}),d.jsx("div",{className:"context-menu-section-header",children:"All documents"}),N.filter(ce=>!O.includes(ce.filename)).map(({filename:ce,title:xe})=>d.jsx("button",{className:"context-menu-item",onClick:()=>Be(ce),children:d.jsx("span",{children:xe})},ce)),N.length===0&&d.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const ce=I();let xe;return ce.map((ie,Le)=>{const ae=ie.isPlugin&&ie.pluginDisplayName&&ie.pluginDisplayName!==xe,ue=xe!==void 0;ie.isPlugin?xe=ie.pluginDisplayName:xe=void 0;const me=!ie.isPlugin&&ue;return d.jsxs("span",{children:[ae&&d.jsx("div",{className:"context-menu-section-header",children:ie.pluginDisplayName}),me&&d.jsx("div",{className:"context-menu-divider"}),d.jsxs("button",{className:"context-menu-item",onClick:()=>pe(ie),children:[d.jsx("span",{children:ie.label}),ie.shortcut&&d.jsx("span",{className:"context-menu-shortcut",children:ie.shortcut})]})]},ie.action)})})()}):null}function bm(t,e,n){let r=t.resolve(e);for(;r.depth>0;){const s=r.node(r.depth),i=r.before(r.depth),l=i+s.nodeSize;if(s.childCount===1)e=i,n=l,r=t.resolve(e);else break}return{from:e,to:n}}function jL(t,e){const n=mn(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 LL(t,e){const n=mn(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 DL(t,e){var l;const n=mn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="delete")return!0;const i=bm(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function PL(t,e){var l;const n=mn(t,e);if(!n)return!0;const{node:r,pos:s}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="insert")return!0;const i=bm(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function BL(t,e){var l,c;const n=mn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="rewrite")return!0;const i=(c=r.attrs)==null?void 0:c.pendingOriginalContent;if(i)t.chain().deleteRange({from:s,to:s+r.nodeSize}).insertContentAt(s,i).run();else{const u=bm(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(u).run()}return!0}function zL(t,e){var i;const n=mn(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:l})=>(l.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function FL(t,e){const n=nd(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=mn(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 $L(t,e){var c;const n=nd(t,e);if(n.length===0)return!1;const r=(c=n[0].node.attrs)==null?void 0:c.pendingOriginalContent,s=n[0].pos,i=n[n.length-1],l=i.pos+i.node.nodeSize;try{return r&&Array.isArray(r)&&r.length>0?t.chain().deleteRange({from:s,to:l}).insertContentAt(s,r).run():t.chain().deleteRange({from:s,to:l}).run(),!0}catch{return!1}}function E1(t,e){var i,l;const n=mn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return FL(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return jL(t,e);case"rewrite":return LL(t,e);case"delete":return DL(t,e);default:return!1}}function N1(t,e){var i,l;const n=mn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return $L(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return PL(t,e);case"rewrite":return BL(t,e);case"delete":return zL(t,e);default:return!1}}function UL(t){const e=C1(t).reverse();for(const n of e)E1(t,n);t.view&&gm(t.view)}function HL(t){const e=C1(t).reverse();for(const n of e)N1(t,n);t.view&&gm(t.view)}function vm(t){const e=[],n=new Set;return t.state.doc.descendants((r,s)=>{var l,c,u;const i=(l=r.attrs)==null?void 0:l.pendingStatus;if(i&&((c=r.attrs)!=null&&c.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 Np(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...vm(n));return e}function C1(t){return vm(t).map(e=>e.nodeId)}function WL(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 bl(t,e){if(t.isDestroyed)return;let n=-1;if(t.state.doc.descendants((i,l)=>{var c;return((c=i.attrs)==null?void 0:c.id)===e?(n=l,!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),l=t.view.dom.closest(".editor-container");if(l){const c=l.getBoundingClientRect(),u=i.top-c.top+l.scrollTop-l.clientHeight/2;l.scrollTo({top:u,behavior:"smooth"})}}catch{}}function VL(t){const[e,n]=E.useState([]),[r,s]=E.useState(0),i=E.useRef(),l=E.useRef(new Set),c=E.useCallback(()=>{const N=t.filter(R=>R&&!R.isDestroyed);if(N.length===0){n([]),l.current=new Set;return}const C=Np(N);n(C);const O=l.current,T=new Set(C.map(R=>R.nodeId));let M=-1;if(O.size>0){for(let R=0;R<C.length;R++)if(!O.has(C[R].nodeId)){M=R;break}}l.current=T,M>=0?(s(M),bl(C[M].editor,C[M].nodeId)):C.length===0?s(0):s(R=>Math.min(R,C.length-1))},[t]);E.useEffect(()=>{const N=t.filter(T=>T&&!T.isDestroyed);if(N.length===0)return;const C=()=>{clearTimeout(i.current),i.current=setTimeout(c,50)};for(const T of N)T.on("transaction",C);c();const O=setTimeout(()=>{const T=Np(N.filter(M=>!M.isDestroyed));T.length>0&&bl(T[0].editor,T[0].nodeId)},150);return()=>{for(const T of N)T.isDestroyed||T.off("transaction",C);clearTimeout(i.current),clearTimeout(O)}},[t,c]),E.useEffect(()=>{const N=e[r]??null;return Xv((N==null?void 0:N.nodeId)??null,(N==null?void 0:N.groupId)??null),N!=null&&N.editor&&!N.editor.isDestroyed&&N.editor.view&&gm(N.editor.view),()=>{Xv(null)}},[r,e]);const u=WL(e),f=e[r]??null,h=E.useCallback(()=>{if(e.length===0)return;const N=(r+1)%e.length;s(N),e[N]&&bl(e[N].editor,e[N].nodeId)},[e,r]),m=E.useCallback(()=>{if(e.length===0)return;const N=(r-1+e.length)%e.length;s(N),e[N]&&bl(e[N].editor,e[N].nodeId)},[e,r]),y=E.useCallback(()=>{const N=t.filter(T=>T&&!T.isDestroyed),C=Np(N);if(C.length===0)return;const O=Math.min(r,C.length-1);bl(C[O].editor,C[O].nodeId)},[t,r]),b=E.useCallback(()=>{f&&(E1(f.editor,f.nodeId),c(),y())},[f,c,y]),v=E.useCallback(()=>{f&&(N1(f.editor,f.nodeId),c(),y())},[f,c,y]),w=E.useCallback(()=>{const N=t.filter(C=>C&&!C.isDestroyed);for(const C of N)UL(C);c()},[t,c]),k=E.useCallback(()=>{const N=t.filter(C=>C&&!C.isDestroyed);for(const C of N)HL(C);c()},[t,c]);return{pendingNodes:e,counts:u,currentNode:f,currentIndex:r,hasPending:u.total>0,goToNext:h,goToPrevious:m,acceptCurrent:b,rejectCurrent:v,acceptAll:w,rejectAll:k,refresh:c}}const Oo={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},KL=()=>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",...Oo})}),d0=()=>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",...Oo})}),GL=()=>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",...Oo})}),qL=()=>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",...Oo})}),f0=()=>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",...Oo})}),p0=()=>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",...Oo})});function _1(t,e,n){const r=mn(t,e);if(!r)return!1;const{pos:s,node:i}=r,l={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:c})=>(c.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:s+i.nodeSize}).insertContentAt(s,l).run(),!0}catch{return!1}}function T1(t,e,n){const r=nd(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:l})=>(l.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:i}).insertContentAt(s,n).run(),!0}catch{return!1}}function Rc(t,e){if(!mm()||!e)return!1;const n=rL(),r=nL();return r&&n&&Array.isArray(n)?T1(t,r,n):n&&_1(t,e,n),fh(!1),!0}function JL({editors:t,pendingDocs:e,currentFilename:n,onSwitchDocument:r,sendMessage:s,getDocument:i}){const{counts:l,currentNode:c,currentIndex:u,hasPending:f,goToNext:h,goToPrevious:m,acceptCurrent:y,rejectCurrent:b,acceptAll:v,rejectAll:w}=VL(t),[k,N]=E.useState(!1),C=E.useRef(null),O=E.useRef(null),T=e.filenames.length,M=h0(e.filenames,n)>=0?T-1:T,R=f||T>0,B=h0(e.filenames,n),U=(c==null?void 0:c.pendingStatus)==="rewrite",z=!!(c!=null&&c.groupId),H=U,$=E.useCallback(()=>{var I,J;const A=c==null?void 0:c.editor;if(!(!A||!c||c.pendingStatus!=="rewrite"))if(k)O.current&&Rc(O.current,C.current),C.current=null,O.current=null,N(!1);else if(z&&c.groupId){const re=nd(A,c.groupId);if(re.length===0)return;const pe=(I=re[0].node.attrs)==null?void 0:I.pendingOriginalContent;if(!pe||!Array.isArray(pe))return;const Ne=re.map(tt=>tt.node.toJSON()),Re=pe.map((tt,ce)=>({...tt,attrs:{...tt.attrs||{},pendingStatus:"rewrite",pendingGroupId:c.groupId,...ce===0?{pendingOriginalContent:pe}:{}}}));if(!T1(A,c.groupId,Re))return;fh(!0,c.nodeId,Ne,c.groupId),C.current=c.nodeId,O.current=A,N(!0)}else{const re=mn(A,c.nodeId);if(!re)return;const{node:pe}=re,Ne=(J=pe.attrs)==null?void 0:J.pendingOriginalContent;if(!Ne)return;const Re=pe.toJSON();if(!_1(A,c.nodeId,Ne))return;fh(!0,c.nodeId,Re),C.current=c.nodeId,O.current=A,N(!0)}},[c,k,z]);E.useEffect(()=>{if(!k)return;const A=C.current,I=O.current;A&&I&&(c==null?void 0:c.nodeId)!==A&&(Rc(I,A),C.current=null,O.current=null,N(!1))},[c==null?void 0:c.nodeId,k]),E.useEffect(()=>{if(t.length!==0)return()=>{mm()&&C.current&&O.current&&(Rc(O.current,C.current),C.current=null,O.current=null)}},[t]);const L=E.useCallback(A=>{if(!n)return;if(!t.some(J=>!J||J.isDestroyed?!1:vm(J).length>0)){const J=i==null?void 0:i();J&&s({type:"doc-update",document:J,filename:n}),s({type:"pending-resolved",filename:n,action:A})}},[t,n,s,i]),Y=E.useCallback(()=>{O.current&&k&&C.current&&(Rc(O.current,C.current),C.current=null,O.current=null,N(!1))},[k]),Q=E.useCallback(()=>{Y(),y(),L("accept")},[Y,y,L]),ee=E.useCallback(()=>{Y(),b(),L("reject")},[Y,b,L]),G=E.useCallback(()=>{Y(),v(),L("accept")},[Y,v,L]),ne=E.useCallback(()=>{Y(),w(),L("reject")},[Y,w,L]),V=E.useCallback(()=>{if(T===0||T===1&&B===0)return;const A=B<=0?T-1:B-1;r(e.filenames[A])},[T,B,e.filenames,r]),X=E.useCallback(()=>{if(T===0||T===1&&B===0)return;const A=B>=T-1?0:B+1;r(e.filenames[A])},[T,B,e.filenames,r]);if(E.useEffect(()=>{if(!R)return;const A=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(),h());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(),V());break;case"l":case"ArrowRight":!I.metaKey&&!I.ctrlKey&&!I.altKey&&(I.preventDefault(),X());break;case"a":!I.metaKey&&!I.ctrlKey&&!I.shiftKey&&(I.preventDefault(),Q());break;case"r":!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),ee());break;case"A":I.shiftKey&&!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),G());break;case"R":I.shiftKey&&!I.metaKey&&!I.ctrlKey&&(I.preventDefault(),ne());break;case"o":!I.metaKey&&!I.ctrlKey&&!I.shiftKey&&(I.preventDefault(),$());break}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[R,h,m,V,X,Q,ee,G,ne,$]),!R)return null;if(c!=null&&c.pendingStatus,!f&&M>0)return d.jsxs("div",{className:"review-panel",children:[d.jsxs("div",{className:"review-panel__status",children:["No changes here — ",M," other doc",M>1?"s have":" has"," changes"]}),d.jsx("div",{className:"review-panel__divider"}),d.jsx("div",{className:"review-panel__nav",children:d.jsx("button",{className:"review-panel__btn",onClick:X,title:"Next doc (l)",children:d.jsx(d0,{})})})]});const te=B>=0?B+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:V,title:"Previous doc (h)",children:d.jsx(KL,{})}),d.jsx("button",{className:"review-panel__btn",onClick:X,title:"Next doc (l)",children:d.jsx(d0,{})}),d.jsxs("span",{className:"review-panel__counter",children:[te,"/",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:l.total<=1,title:"Previous (k)",children:d.jsx(GL,{})}),d.jsx("button",{className:"review-panel__btn",onClick:h,disabled:l.total<=1,title:"Next (j)",children:d.jsx(qL,{})}),d.jsxs("span",{className:"review-panel__counter",children:[u+1,"/",l.total]})]}),d.jsx("div",{className:"review-panel__divider"}),d.jsxs("div",{className:"review-panel__toggle",children:[d.jsx("button",{className:`review-panel__toggle-btn${H&&!k?" review-panel__toggle-btn--active":""}`,onClick:()=>H&&k&&$(),disabled:!H,title:"Show modified (o)",children:"Modified"}),d.jsx("button",{className:`review-panel__toggle-btn${H&&k?" review-panel__toggle-btn--active":""}`,onClick:()=>H&&!k&&$(),disabled:!H,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:Q,title:"Accept (a)",children:d.jsx(f0,{})}),d.jsx("button",{className:"review-panel__reject",onClick:ee,title:"Reject (r)",children:d.jsx(p0,{})}),d.jsxs("button",{className:"review-panel__accept-all",onClick:G,title:"Accept all (Shift+A)",children:[d.jsx(f0,{}),d.jsx("span",{children:"All"})]}),d.jsxs("button",{className:"review-panel__reject-all",onClick:ne,title:"Reject all (Shift+R)",children:[d.jsx(p0,{}),d.jsx("span",{children:"All"})]})]})]})}function h0(t,e){return t.indexOf(e)}function Ic(t){return t.type==="doc"?t.file:t.id}function M1(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&M1(n.items,e)}function Mo(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 hh(t){return/^[A-Z]:[/\\]|^\//.test(t)}function A1(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function YL(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 QL(t,e){const[n,r]=E.useState([]),[s,i]=E.useState([]),[l,c]=E.useState(new Set),u=E.useRef(null),f=E.useCallback(()=>{fetch("/api/documents").then(m=>m.json()).then(m=>{Array.isArray(m)&&r(m)}).catch(()=>{})},[]),h=E.useCallback(()=>{fetch("/api/workspaces").then(m=>m.json()).then(async m=>{if(!Array.isArray(m))return;const y=await Promise.all(m.map(async v=>{try{const k=await(await fetch(`/api/workspaces/${encodeURIComponent(v.filename)}`)).json();return{...v,workspace:k}}catch{return v}}));i(y);const b=new Set;for(const v of y)v.workspace&&M1(v.workspace.root,b);c(b)}).catch(()=>{})},[]);return E.useEffect(()=>{f()},[f,t]),E.useEffect(()=>{h()},[h,e,t]),E.useEffect(()=>{const m=requestAnimationFrame(()=>{var b;const y=(b=u.current)==null?void 0:b.querySelector(".sidebar-item.active");y==null||y.scrollIntoView({block:"nearest",behavior:"instant"})});return()=>cancelAnimationFrame(m)},[n]),{docs:n,workspaces:s,assignedFiles:l,fetchDocs:f,scrollRef:u}}function XL(t,e,n){const r=E.useCallback(M=>{fetch(`/api/documents/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]),s=E.useCallback(M=>{fetch(`/api/documents/${encodeURIComponent(M)}/archive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),i=E.useCallback(M=>{fetch(`/api/documents/${encodeURIComponent(M)}/unarchive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),l=E.useCallback((M,R,B)=>{!B.trim()||B.trim()===R||fetch(`/api/documents/${encodeURIComponent(M)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:B.trim()})}).then(()=>e()).catch(()=>{})},[e]),c=E.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),u=E.useCallback(M=>{fetch(`/api/workspaces/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]),f=E.useCallback((M,R,B)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B?{metadata:B}:{})}).then(U=>U.json()).then(U=>{if(U.filename)return fetch(`/api/workspaces/${encodeURIComponent(M)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:U.filename,title:U.title||"Untitled",containerId:R})})}).catch(()=>{})},[]),h=E.useCallback((M,R)=>{fetch(`/api/workspaces/${encodeURIComponent(M)}/docs/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]),m=E.useCallback((M,R)=>{fetch(`/api/workspaces/${encodeURIComponent(M)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:R})}).catch(()=>{})},[]),y=E.useCallback((M,R)=>{fetch(`/api/workspaces/${encodeURIComponent(M)}/containers/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]),b=E.useCallback((M,R,B)=>{B.trim()&&fetch(`/api/workspaces/${encodeURIComponent(M)}/containers/${encodeURIComponent(R)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:B.trim()})}).catch(()=>{})},[]),v=E.useCallback((M,R)=>{R.trim()&&fetch(`/api/workspaces/${encodeURIComponent(M)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:R.trim()})}).catch(()=>{})},[]),[w,k]=E.useState({}),N=E.useRef(-1);E.useEffect(()=>{n!==N.current&&(N.current=n??0,fetch("/api/documents").then(M=>M.json()).then(M=>{const R={};return Promise.all(M.map(B=>fetch(`/api/doc-tags/${encodeURIComponent(B.filename)}`).then(U=>U.json()).then(U=>{var z;(z=U.tags)!=null&&z.length&&(R[B.filename]=U.tags)}).catch(()=>{}))).then(()=>k(R))}).catch(()=>{}))},[n]);const C=E.useCallback(M=>w[M]||[],[w]),O=E.useCallback((M,R)=>{R.trim()&&(k(B=>{const U=B[M]||[];return U.includes(R.trim())?B:{...B,[M]:[...U,R.trim()]}}),fetch(`/api/doc-tags/${encodeURIComponent(M)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:R.trim()})}).catch(()=>{}))},[]),T=E.useCallback((M,R)=>{k(B=>{const z=(B[M]||[]).filter(H=>H!==R);if(z.length===0){const H={...B};return delete H[M],H}return{...B,[M]:z}}),fetch(`/api/doc-tags/${encodeURIComponent(M)}/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]);return{fetchDocs:e,handleDelete:r,handleArchive:s,handleUnarchive:i,handleRename:l,handleCreateWorkspace:c,handleDeleteWorkspace:u,handleCreateInWorkspace:f,handleRemoveFromWorkspace:h,handleCreateContainer:m,handleDeleteContainer:y,handleRenameContainer:b,handleRenameWorkspace:v,getDocTags:C,handleAddTag:O,handleRemoveTag:T}}function ZL({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,l]=E.useState(null),[c,u]=E.useState(null),f=E.useRef(null),h=E.useRef(null),m=E.useRef(null),y=E.useRef(null),b=E.useRef(null),v=5,w=(H,$,L)=>L==="before"?$>0?Ic(H[$-1]):null:Ic(H[$]),k=E.useCallback((H,$)=>{if($===null){const Q=t.filter(G=>!n.has(G.filename)).map(G=>({type:"doc",file:G.filename,title:G.title})),ee=Q.findIndex(G=>Ic(G)===H);return ee>=0?{siblings:Q,index:ee,containerId:null}:null}const L=e.find(Q=>Q.filename===$);if(!(L!=null&&L.workspace))return null;const Y=(Q,ee)=>{for(let G=0;G<Q.length;G++){if(Ic(Q[G])===H)return{siblings:Q,index:G,containerId:ee};if(Q[G].type==="container"){const ne=Y(Q[G].items,Q[G].id);if(ne)return ne}}return null};return Y(L.workspace.root,null)},[t,n,e]),N=E.useCallback(()=>{l(null),u(null),b.current=null,y.current=null,m.current&&(m.current.remove(),m.current=null),f.current&&(clearTimeout(f.current),f.current=null),h.current&&(cancelAnimationFrame(h.current),h.current=null),document.body.style.userSelect=""},[]),C=E.useCallback((H,$)=>{if(!H||!$)return;if(H.type==="workspace"){const V=$.itemId;if(V===H.filename)return;const X=e.map(I=>I.filename),te=X.indexOf(H.filename);if(te<0)return;X.splice(te,1);let A=X.indexOf(V);if(A<0)return;$.position==="after"&&(A+=1),X.splice(A,0,H.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:X})}).catch(()=>{});return}const{wsFilename:L,containerId:Y,afterId:Q}=$,ee=H.type==="doc"?H.file:H.id,G=H.sourceWs;if($.itemId===ee)return;if(H.type==="container"){if(G!==L||!L)return;fetch(`/api/workspaces/${encodeURIComponent(L)}/docs/${encodeURIComponent(ee)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:Y??null,afterFile:Q})}).catch(()=>{});return}const ne=H.file;if(G===null&&L===null){const V=t.filter(J=>!n.has(J.filename)).map(J=>J.filename),X=V.indexOf(ne);if(X<0)return;V.splice(X,1);let te=Q?V.indexOf(Q):-1;te>=0?te+=1:te=0,V.splice(te,0,ne);const A=[];let I=0;for(const J of t)n.has(J.filename)?A.push(J.filename):A.push(V[I++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:A})}).catch(()=>{});return}if(G===null&&L!==null){fetch(`/api/workspaces/${encodeURIComponent(L)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:ne,title:ne.replace(/\.md$/,""),containerId:Y??null,afterFile:Q})}).catch(()=>{});return}if(G!==null&&L===null){fetch(`/api/workspaces/${encodeURIComponent(G)}/docs/${encodeURIComponent(ne)}`,{method:"DELETE"}).catch(()=>{});return}if(G===L&&L!==null){fetch(`/api/workspaces/${encodeURIComponent(L)}/docs/${encodeURIComponent(ne)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:Y??null,afterFile:Q})}).catch(()=>{});return}G!==null&&L!==null&&fetch(`/api/workspaces/${encodeURIComponent(L)}/docs/${encodeURIComponent(ne)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:G,containerId:Y??null,afterFile:Q,title:ne.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),O=E.useCallback((H,$)=>{const L=m.current;L&&(L.style.display="none");const Y=document.elementFromPoint(H,$);if(L&&(L.style.display=""),!Y)return null;if((i==null?void 0:i.type)==="workspace"){const J=Y.closest("[data-ws-drag]");if(J){const re=J.dataset.wsDrag,pe=J.getBoundingClientRect(),Ne=($-pe.top)/pe.height;return{itemId:re,position:Ne<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}return null}const Q=Y.closest("[data-drag-id]");if(!Q){const J=Y.closest("[data-drop-ws]");return J?{itemId:"__section__",position:"inside",wsFilename:J.dataset.dropWs==="__docs__"?null:J.dataset.dropWs,containerId:J.dataset.dropContainer||null,afterId:null}:null}const ee=Q.dataset.dragId,G=Q.dataset.dragType,ne=Q.dataset.dragWs==="__docs__"?null:Q.dataset.dragWs,V=Q.getBoundingClientRect(),X=($-V.top)/V.height;if(G==="container-header"){const J=ee,re=Q.dataset.dragParent||null,pe=k(J,ne);return pe?X<.25?{itemId:J,position:"before",wsFilename:ne,containerId:re,afterId:w(pe.siblings,pe.index,"before")}:X>.75?{itemId:J,position:"after",wsFilename:ne,containerId:re,afterId:w(pe.siblings,pe.index,"after")}:{itemId:J,position:"inside",wsFilename:ne,containerId:J,afterId:null}:null}const te=Q.dataset.dragContainer||null,A=k(ee,ne);if(!A)return null;const I=X<.5?"before":"after";return{itemId:ee,position:I,wsFilename:ne,containerId:te,afterId:w(A.siblings,A.index,I)}},[k,i]),T=E.useCallback(H=>{const $=r.current;if(!$)return;const L=$.getBoundingClientRect(),Y=80,Q=18;let ee=0;if(H<L.top+Y?ee=-Q*Math.max(0,1-(H-L.top)/Y):H>L.bottom-Y&&(ee=Q*Math.max(0,1-(L.bottom-H)/Y)),h.current&&(cancelAnimationFrame(h.current),h.current=null),ee!==0){const G=()=>{$.scrollTop+=ee,h.current=requestAnimationFrame(G)};h.current=requestAnimationFrame(G)}},[r]),M=E.useCallback((H,$)=>{const L=m.current;L&&(L.style.display="none");const Y=document.elementFromPoint(H,$);L&&(L.style.display="");const Q=Y==null?void 0:Y.closest("[data-section-key]");if(!Q){f.current&&(clearTimeout(f.current),f.current=null);return}const ee=Q.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(G=>{if(!G.has(ee))return G;const ne=new Set(G);return ne.delete(ee),ne})},500)},[s]);E.useEffect(()=>{if(!i)return;const H=L=>{m.current&&(m.current.style.left=`${L.clientX+12}px`,m.current.style.top=`${L.clientY-8}px`),u(O(L.clientX,L.clientY)),T(L.clientY),M(L.clientX,L.clientY)},$=L=>{C(i,O(L.clientX,L.clientY)),N()};return window.addEventListener("pointermove",H),window.addEventListener("pointerup",$),()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",$)}},[i,O,C,N,T,M]);const R=E.useCallback((H,$,L)=>{if(H.button!==0||H.target.closest("input, button, .sidebar-tag-remove, .sidebar-tag-add, .sidebar-container-actions, .sidebar-delete-btn, .sidebar-confirm-delete, .sidebar-inline-confirm"))return;y.current={x:H.clientX,y:H.clientY},b.current=$;const Q=G=>{if(!y.current||!b.current)return;const ne=G.clientX-y.current.x,V=G.clientY-y.current.y;if(Math.abs(ne)+Math.abs(V)>=v){document.body.style.userSelect="none",window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",ee),l(b.current),b.current=null;const X=document.createElement("div");X.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);",X.textContent=L,document.body.appendChild(X),m.current=X,X.style.left=`${G.clientX+12}px`,X.style.top=`${G.clientY-8}px`}},ee=()=>{window.removeEventListener("pointermove",Q),window.removeEventListener("pointerup",ee),y.current=null,b.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",Q),window.addEventListener("pointerup",ee)},[]);return{draggedItem:i,dropIndicator:c,handlePointerDown:R,dropClass:H=>!c||c.itemId!==H?"":c.position==="before"?"drop-before":c.position==="after"?"drop-after":c.position==="inside"?"drop-inside":"",isDragging:H=>i?i.type==="doc"?i.file===H:i.type==="workspace"?i.filename===H:i.id===H:!1,isContainerDropTarget:H=>!c||!i?!1:c.containerId===H}}function eD({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onRename:l,onArchive:c,onDelete:u,onPluginAction:f,pluginItems:h,onNewsletterSend:m,onSchedulePost:y,onViewAnalytics:b}){const v=E.useRef(null),[w,k]=E.useState(!1),[N,C]=E.useState(!1),[O,T]=E.useState({left:t,top:e}),[M,R]=E.useState([]),[B,U]=E.useState(!1);E.useEffect(()=>{fetch("/api/connections").then($=>$.json()).then($=>{const L=($.connections||[]).filter(Y=>Y.provider==="newsletter"&&Y.status==="active");R(L)}).catch(()=>{})},[]),E.useLayoutEffect(()=>{const $=v.current;if(!$)return;const L=$.getBoundingClientRect(),Y=8;let Q=t,ee=e;e+L.height+Y>window.innerHeight&&(ee=e-L.height),t+L.width+Y>window.innerWidth&&(Q=t-L.width),ee<Y&&(ee=Y),Q<Y&&(Q=Y),T({left:Q,top:ee})},[t,e]),E.useEffect(()=>{const $=L=>{v.current&&!v.current.contains(L.target)&&s()};return document.addEventListener("mousedown",$),()=>document.removeEventListener("mousedown",$)},[s]),E.useEffect(()=>{const $=L=>{L.key==="Escape"&&s()};return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[s]);const z=E.useCallback($=>{f($.action,$),s()},[f,s]),H=E.useCallback(()=>{m&&(M.length===1?(m(M[0].id),s()):U(!B))},[m,M,B,s]);return d.jsxs("div",{ref:v,className:"context-menu",style:{left:O.left,top:O.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:()=>{l(),s()},children:d.jsx("span",{children:"Rename"})}),N?d.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:$=>$.stopPropagation(),children:[d.jsx("span",{children:"Archive?"}),d.jsx("button",{onClick:()=>{c(),s()},children:"Yes"}),d.jsx("button",{onClick:()=>C(!1),children:"No"})]}):d.jsx("button",{className:"context-menu-item",onClick:()=>C(!0),children:d.jsx("span",{children:"Archive"})}),w?d.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:$=>$.stopPropagation(),children:[d.jsx("span",{children:"Delete?"}),d.jsx("button",{onClick:()=>{u(),s()},children:"Yes"}),d.jsx("button",{onClick:()=>k(!1),children:"No"})]}):d.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>k(!0),children:d.jsx("span",{children:"Delete"})}),y&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{y(),s()},children:d.jsx("span",{children:"Schedule Post"})})]}),M.length>0&&m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:H,children:d.jsx("span",{children:"Send as Newsletter"})}),B&&M.length>1&&d.jsx("div",{className:"context-menu-sub",children:M.map($=>d.jsx("button",{className:"context-menu-item context-menu-sub-item",onClick:()=>{m($.id),s()},children:d.jsx("span",{children:$.display_name})},$.id))})]}),b&&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:"View Analytics"})})]}),h.length>0&&d.jsx(d.Fragment,{children:(()=>{let $;return h.map(L=>{const Y=L.pluginDisplayName&&L.pluginDisplayName!==$;return $=L.pluginDisplayName,d.jsxs("span",{children:[Y&&d.jsx("div",{className:"context-menu-divider"}),Y&&d.jsx("div",{className:"context-menu-section-header",children:L.pluginDisplayName}),d.jsx("button",{className:"context-menu-item",onClick:()=>z(L),children:d.jsx("span",{children:L.label})})]},L.action)})})()})]})}function tD({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=E.useState(""),l=E.useRef(null);E.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),E.useEffect(()=>{const u=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);const c=E.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:l,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)&&c()}})]}),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:c,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 l=r.indexOf(s,i);if(l===-1){n.push(t.slice(i));break}l>i&&n.push(t.slice(i,l)),n.push(d.jsx("mark",{children:t.slice(l,l+e.length)},l)),i=l+e.length}return n}function m0({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 · ",Mo(t.lastModified)]})]})}function xm({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(l=>!l.isArchived),i=t.filter(l=>l.isArchived);return d.jsx("div",{className:"sidebar-scroll",children:d.jsxs("div",{className:"search-results",children:[s.map(l=>d.jsx(m0,{r:l,query:e,onClick:()=>n(l.filename)},l.filename)),i.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"search-archived-divider",children:d.jsx("span",{children:"Archived"})}),i.map(l=>d.jsx(m0,{r:l,query:e,onClick:()=>r.handleUnarchive(l.filename)},l.filename))]})]})})}function O1({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,l]=E.useState("confirm"),[c,u]=E.useState("html"),[f,h]=E.useState(""),[m,y]=E.useState(null),[b,v]=E.useState(null),[w,k]=E.useState(0),[N,C]=E.useState(null),[O,T]=E.useState(null),[M,R]=E.useState("all"),[B,U]=E.useState([]),[z,H]=E.useState(""),$=E.useRef(null),L=B.find(G=>G.id===z),Y=M==="exclude_issue"&&L&&O!=null?Math.max(0,O-L.recipient_count):O;E.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(G=>G.json()).then(G=>{var V,X;const ne=(X=(V=G.content)==null?void 0:V[0])!=null&&X.text?JSON.parse(G.content[0].text):G;ne.count!=null&&T(ne.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(G=>G.json()).then(G=>{var V,X;const ne=(X=(V=G.content)==null?void 0:V[0])!=null&&X.text?JSON.parse(G.content[0].text):G;ne.issues&&U(ne.issues)}).catch(()=>{})},[]);const Q=()=>i==="sent"?{sentCount:w,issueId:N,sentAt:new Date().toISOString()}:void 0;E.useEffect(()=>{const G=ne=>{i!=="sending"&&i!=="testing"&&$.current&&!$.current.contains(ne.target)&&s(Q())};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[s,i,w,N]),E.useEffect(()=>{const G=ne=>{ne.key==="Escape"&&i!=="sending"&&i!=="testing"&&s(Q())};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[s,i,w,N]);async function ee(G){var ne,V;l(G?"testing":"sending"),v(null);try{r&&await r();const X={subject:e,connectionId:t,format:c};G&&(X.test_email=G),!G&&M==="exclude_issue"&&z&&(X.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:X})})).json(),I=(V=(ne=A.content)==null?void 0:ne[0])!=null&&V.text?JSON.parse(A.content[0].text):A;if(I.error){v(I.error),l("error");return}if(I.test){y(I.sent_to),l("confirm");return}const J=I.sent||0,re=I.issueId||null,pe=new Date().toISOString();k(J),C(re),l("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:J,sentAt:pe,issueId:re||void 0}}})}).catch(()=>{})}catch(X){v(X.message),l("error")}}return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"newsletter-modal",ref:$,children:[d.jsxs("div",{className:"newsletter-modal__header",children:[d.jsx("h3",{children:"Send Newsletter"}),d.jsx("button",{className:"newsletter-modal__close",onClick:()=>s(Q()),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:Y==null?{visibility:"hidden"}:void 0,children:['Send "',d.jsx("strong",{children:e}),'" to ',Y!=null?Y.toLocaleString():0," subscriber",Y!==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:M,onChange:G=>{const ne=G.target.value;R(ne),ne==="all"&&H("")},children:[d.jsx("option",{value:"all",children:"All subscribers"}),B.length>0&&d.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),M==="exclude_issue"&&d.jsxs("select",{className:"newsletter-modal__select",value:z,onChange:G=>H(G.target.value),children:[d.jsx("option",{value:"",children:"Select a past issue"}),B.map(G=>d.jsxs("option",{value:G.id,children:[G.subject," (",G.recipient_count," sent)"]},G.id))]})]}),d.jsxs("div",{className:"newsletter-modal__format-toggle",children:[d.jsx("button",{className:`newsletter-modal__format-btn${c==="html"?" active":""}`,onClick:()=>u("html"),children:"HTML"}),d.jsx("button",{className:`newsletter-modal__format-btn${c==="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:G=>h(G.target.value),onKeyDown:G=>{G.key==="Enter"&&f.trim()&&ee(f.trim())}}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>ee(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:M==="exclude_issue"&&!z,onClick:()=>ee(),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 ",w," subscriber",w!==1?"s":"","!"]}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:w,issueId:N,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__error",children:b}),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:()=>ee(),children:"Retry"})]})]})]})]})})}async function g0(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 _p(t,e){return e?(t/e*100).toFixed(1)+"%":"0%"}function y0(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function b0(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 nD({docId:t,title:e,onClose:n}){const[r,s]=E.useState("loading"),[i,l]=E.useState([]),[c,u]=E.useState(""),[f,h]=E.useState(null),[m,y]=E.useState(null),[b,v]=E.useState("links"),[w,k]=E.useState("all"),[N,C]=E.useState(!1),O=E.useRef(null);E.useEffect(()=>{let L=!1;return(async()=>{try{const Y=await g0("list_newsletter_issues",{limit:20});if(L)return;if(!Y.issues||Y.issues.length===0){s("no-data");return}l(Y.issues);const Q=Y.issues[0].id;u(Q)}catch(Y){L||(y(Y.message),s("error"))}})(),()=>{L=!0}},[]),E.useEffect(()=>{if(!c)return;let L=!1;return C(!0),(async()=>{try{const Y=await g0("get_newsletter_analytics",{issue_id:c});if(L)return;if(Y.error){y(Y.error),s("error");return}h(Y),s("loaded")}catch(Y){L||(y(Y.message),s("error"))}finally{L||C(!1)}})(),()=>{L=!0}},[c]),E.useEffect(()=>{const L=Y=>{O.current&&!O.current.contains(Y.target)&&n()};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[n]),E.useEffect(()=>{const L=Y=>{Y.key==="Escape"&&n()};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[n]);const T=f?sD(f.subscriber_events):[],M=(f==null?void 0:f.issue.recipient_count)??0,R=f?f.stats.delivered||M-f.stats.bounces:0,B=f?new Set(f.subscriber_events.filter(L=>{var Y;return L.event_type==="click"&&((Y=L.url)==null?void 0:Y.includes("/newsletter/unsubscribe/"))}).map(L=>L.email)).size:0,U=f?f.stats.unsubscribes||B:0,z=f?f.subscriber_events.filter(L=>L.event_type==="dropped").length:0,H=L=>{var Y;return L.event_type==="unsubscribe"||L.event_type==="click"&&!!((Y=L.url)!=null&&Y.includes("/newsletter/unsubscribe/"))},$=f?rD(f.subscriber_events.filter(L=>w==="all"?!0:w==="unsubscribe"?H(L):L.event_type===w)):[];return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"na-modal",ref:O,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:c,onChange:L=>u(L.target.value),children:i.map(L=>d.jsxs("option",{value:L.id,children:[L.subject," — ",y0(L.sent_at)]},L.id))}),N?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:R.toLocaleString()}),d.jsx("div",{className:"na-kpi__label",children:"Delivered"}),d.jsxs("div",{className:"na-kpi__sub",children:[M.toLocaleString()," sent"]})]}),d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:_p(f.stats.unique_opens,R)}),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:_p(f.stats.unique_clicks,R)}),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"})]})]}),d.jsxs("div",{className:"na-tabs",children:[d.jsxs("button",{className:`na-tab${b==="links"?" active":""}`,onClick:()=>v("links"),children:["Links (",T.length,")"]}),d.jsxs("button",{className:`na-tab${b==="activity"?" active":""}`,onClick:()=>v("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),b==="links"&&d.jsx("div",{className:"na-table-wrap",children:T.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:T.map(L=>d.jsxs("tr",{children:[d.jsx("td",{className:"na-table__url",title:L.url,children:d.jsx("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",children:b0(L.url)})}),d.jsx("td",{children:L.uniqueClicks}),d.jsx("td",{children:L.totalClicks}),d.jsx("td",{children:_p(L.uniqueClicks,R)})]},L.url))})]})}),b==="activity"&&d.jsxs("div",{className:"na-activity",children:[d.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(L=>d.jsx("button",{className:`na-filter-btn${w===L?" active":""}`,onClick:()=>k(L),children:L==="all"?"All":L.charAt(0).toUpperCase()+L.slice(1)+"s"},L))}),d.jsxs("div",{className:"na-table-wrap",children:[$.length===0?d.jsxs("div",{className:"na-empty",children:["No ",w==="all"?"":w+" ","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:$.slice(0,100).map(L=>d.jsxs("tr",{children:[d.jsx("td",{className:"na-table__email",children:L.email}),d.jsxs("td",{children:[d.jsx("span",{className:`na-badge na-badge--${L.event_type}`,children:L.event_type}),L.count>1&&d.jsxs("span",{className:"na-count",children:[L.count,"x"]})]}),d.jsx("td",{className:"na-table__url",children:L.url?d.jsx("a",{href:L.url,target:"_blank",rel:"noopener noreferrer",children:b0(L.url,35)}):"—"}),d.jsx("td",{className:"na-table__time",children:y0(L.latestTimestamp)})]},L.key))})]}),$.length>100&&d.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",$.length," events"]})]})]})]})]})]})})}function rD(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 sD(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 iD(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function wm({filename:t,title:e,onClose:n}){const[r,s]=E.useState("queue"),[i,l]=E.useState(null),[c,u]=E.useState(null),[f,h]=E.useState(""),[m,y]=E.useState(!1),[b,v]=E.useState(null),[w,k]=E.useState(null);E.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||""),l(iD(O.meta||{}))}).catch(O=>k(O.message))},[t]);const N=async()=>{var O;if(!(!c||!i)){y(!0);try{const T={content:c,content_type:i,mode:r};r==="custom"&&f&&(T.scheduled_at=new Date(f).toISOString());const M=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)}),R=await M.json();if(M.ok){const B=(O=R.item)!=null&&O.scheduled_at?new Date(R.item.scheduled_at).toLocaleString():"now";v({success:!0,message:`Scheduled for ${B}`})}else v({success:!1,message:R.error||"Failed to schedule"})}catch(T){v({success:!1,message:T.message})}finally{y(!1)}}},C=i===null&&!w;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}),w?d.jsxs("div",{className:"schedule-post-modal-result error",children:[w,d.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):b?d.jsxs("div",{className:`schedule-post-modal-result ${b.success?"success":"error"}`,children:[b.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:C?"...":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=>h(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:N,disabled:m||C||r==="custom"&&!f,children:m?"Scheduling...":r==="now"?"Post Now":"Schedule"})]})]})]})})}const v0=[{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 oD({anchorRect:t,onSelect:e,onClose:n}){const r=E.useRef(null),[s,i]=E.useState(null),[l,c]=E.useState(""),u=E.useRef(null),[f,h]=E.useState({left:t.left,top:t.bottom+4});E.useLayoutEffect(()=>{const v=r.current;if(!v)return;const w=v.getBoundingClientRect(),k=8;let N=t.left,C=t.bottom+4;C+w.height+k>window.innerHeight&&(C=t.top-w.height-4),N+w.width+k>window.innerWidth&&(N=t.right-w.width),C<k&&(C=k),N<k&&(N=k),h({left:N,top:C})},[t]),E.useEffect(()=>{const v=w=>{r.current&&!r.current.contains(w.target)&&n()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),E.useEffect(()=>{const v=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),E.useEffect(()=>{s&&setTimeout(()=>{var v;return(v=u.current)==null?void 0:v.focus()},0)},[s]);const m=v=>{if(v.needsUrl){i(v.key),c("");return}e(v.metadata)},y=()=>{if(!s||!l.trim())return;const v=l.trim();if(!v.includes("x.com")&&!v.includes("twitter.com"))return;const w=v0.find(N=>N.key===s);if(!(w!=null&&w.metadata))return;const k=JSON.parse(JSON.stringify(w.metadata));k.tweetContext&&(k.tweetContext.url=v),e(k)},b=l.trim().includes("x.com")||l.trim().includes("twitter.com");return d.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:v0.map(v=>d.jsxs("div",{children:[d.jsx("button",{className:`create-doc-dropdown-item${s===v.key?" active":""}`,onClick:()=>m(v),children:v.label}),s===v.key&&d.jsxs("div",{className:"create-doc-dropdown-url",children:[d.jsx("input",{ref:u,type:"text",placeholder:v.urlPlaceholder,value:l,onChange:w=>c(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),y()),w.key==="Escape"&&(i(null),c(""))}}),d.jsx("button",{onClick:y,disabled:!b,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"})})})]})]},v.key))})}function R1(t,e){if(!e)return!0;for(const n of t)if(n.type==="container"&&(n.id===e||R1(n.items,e)))return!0;return!1}function I1(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=I1(n.items,e);if(r)return[n.id,...r]}}return null}function lD({docs:t,archivedDocs:e,workspaces:n,assignedFiles:r,pendingDocs:s,onSwitchDocument:i,onCreateDocument:l,actions:c,scrollRef:u,writingTitle:f,writingTarget:h,searchQuery:m,searchResults:y,onSearchChange:b}){const[v,w]=E.useState(null),[k,N]=E.useState(""),[C,O]=E.useState(null),[T,M]=E.useState(()=>{try{const Z=localStorage.getItem("ow-collapsed-sections");return Z?new Set(JSON.parse(Z)):new Set}catch{return new Set}}),[R,B]=E.useState(null),[U,z]=E.useState(null),[H,$]=E.useState(""),[L,Y]=E.useState(null),[Q,ee]=E.useState(""),[G,ne]=E.useState(null),[V,X]=E.useState(""),[te,A]=E.useState(null),[I,J]=E.useState(null),[re,pe]=E.useState([]),[Ne,Re]=E.useState(null),[Be,tt]=E.useState(null),[ce,xe]=E.useState(null),[ie,Le]=E.useState(null),{draggedItem:ae,dropIndicator:ue,handlePointerDown:me,dropClass:Ae,isDragging:Ue,isContainerDropTarget:ct}=ZL({docs:t,workspaces:n,assignedFiles:r,scrollRef:u,setCollapsedSections:M}),pt=E.useCallback(()=>{fetch("/api/plugins").then(Z=>Z.json()).then(Z=>{const Ge=[];for(const He of Z.plugins||[]){const kt=He.displayName||void 0;for(const Ze of He.sidebarMenuItems||[])Ge.push({...Ze,pluginDisplayName:kt})}pe(Ge)}).catch(()=>{})},[]);E.useEffect(()=>{pt()},[pt]),E.useEffect(()=>{const Z=()=>pt();return window.addEventListener("ow-plugins-changed",Z),()=>window.removeEventListener("ow-plugins-changed",Z)},[pt]);const Lt=E.useCallback((Z,Ge)=>{Z.preventDefault(),Z.stopPropagation(),A({x:Z.clientX,y:Z.clientY,filename:Ge.filename,title:Ge.title,docId:Ge.docId,lastSent:Ge.lastSent})},[]),Qn=E.useCallback(Z=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:Z})}).catch(()=>{})},[]),yn=E.useCallback((Z,Ge,He,kt,Ze)=>{if(Ge.promptForFocus&&Ze===void 0){Re({action:Z,label:Ge.label,filename:He,title:kt});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:Z,filename:He,title:kt,instructions:Ze||"",label:Ge.label})}).catch(()=>{})},[]),lt=Z=>{M(Ge=>{const He=new Set(Ge);return He.has(Z)?He.delete(Z):He.add(Z),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...He])),He})},Ot=t.find(Z=>Z.isActive),bn=E.useRef(n);if(bn.current=n,E.useEffect(()=>{var Z;if(Ot)for(const Ge of bn.current){const He=I1(((Z=Ge.workspace)==null?void 0:Z.root)||[],Ot.filename);if(He){M(kt=>{const Ze=[Ge.filename,...He.map(qe=>`container-${qe}`)];if(Ze.every(qe=>!kt.has(qe)))return kt;const nt=new Set(kt);for(const qe of Ze)nt.delete(qe);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...nt])),nt});break}}},[Ot==null?void 0:Ot.filename]),y!==null)return d.jsx(xm,{results:y,query:m,onSwitchDocument:i,actions:c});const qt=t.filter(Z=>!r.has(Z.filename)),Jt=(Z,Ge,He,kt,Ze)=>d.jsxs("div",{className:`sidebar-item ${Z.isActive?"active":""} ${Ue(Z.filename)?"dragging":""} ${Ae(Z.filename)}`,"data-drag-id":Z.filename,"data-drag-type":"doc","data-drag-ws":Ge||"__docs__","data-drag-container":He||"",onPointerDown:nt=>me(nt,{type:"doc",file:Z.filename,sourceWs:Ge||null},Z.title),onClick:()=>!Z.isActive&&!ae&&i(Z.filename),onDoubleClick:()=>{w(Z.filename),N(Z.title)},onContextMenu:nt=>Lt(nt,Z),children:[v===Z.filename?d.jsx("input",{className:"sidebar-rename-input",value:k,onChange:nt=>N(nt.target.value),onBlur:()=>{c.handleRename(Z.filename,Z.title,k),w(null)},onKeyDown:nt=>{nt.key==="Enter"&&(c.handleRename(Z.filename,Z.title,k),w(null)),nt.key==="Escape"&&w(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:Z.title}),Z.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(Z.filename)&&d.jsx("span",{className:"sidebar-pending-dot"})]}),hh(Z.filename)&&d.jsx("div",{className:"sidebar-item-context",children:A1(Z.filename)}),d.jsxs("div",{className:"sidebar-item-meta",children:[Z.wordCount.toLocaleString()," words · ",Mo(Z.lastModified)]}),d.jsxs("div",{className:"sidebar-tags",children:[c.getDocTags(Z.filename).map(nt=>d.jsxs("span",{className:"sidebar-tag",onClick:qe=>qe.stopPropagation(),children:[nt,d.jsx("span",{className:"sidebar-tag-remove",onClick:qe=>{qe.stopPropagation(),c.handleRemoveTag(Z.filename,nt)},children:"×"})]},nt)),G===Z.filename?d.jsx("input",{className:"sidebar-tag-input",value:V,onChange:nt=>X(nt.target.value),onBlur:()=>{V.trim()&&c.handleAddTag(Z.filename,V),ne(null)},onKeyDown:nt=>{nt.key==="Enter"&&(c.handleAddTag(Z.filename,V),ne(null),X("")),nt.key==="Escape"&&(ne(null),X(""))},autoFocus:!0,onClick:nt=>nt.stopPropagation(),placeholder:"tag..."}):d.jsx("button",{className:"sidebar-tag-add",onClick:nt=>{nt.stopPropagation(),ne(Z.filename),X("")},children:"+"})]})]}),C===Z.filename?d.jsxs("div",{className:"sidebar-confirm-delete",onClick:nt=>nt.stopPropagation(),children:[d.jsx("span",{children:"Delete?"}),d.jsx("button",{onClick:()=>{c.handleDelete(Z.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(Z.filename)},title:"Delete document",children:"×"})]},Z.filename),Xn=(Z,Ge,He,kt,Ze,nt)=>{if(Z.type==="doc"){const ve=t.find(Fe=>Fe.filename===Z.file);return ve?Jt(ve,He,kt):hh(Z.file)?d.jsx("div",{className:"sidebar-item sidebar-unavailable",children:d.jsxs("div",{className:"sidebar-item-title",children:[Z.title||Z.file," (unavailable)"]})},Z.file):d.jsxs("div",{className:"sidebar-item sidebar-missing",children:[d.jsxs("div",{className:"sidebar-item-title",children:[Z.title||Z.file," (missing)"]}),d.jsx("button",{className:"sidebar-delete-btn",onClick:()=>c.handleRemoveFromWorkspace(He,Z.file),title:"Remove",children:"×"})]},Z.file)}const qe=Z,Un=`container-${qe.id}`,ln=T.has(Un),oe=Ge<=2?`depth-${Ge}`:"depth-2";return d.jsxs("div",{className:`sidebar-container ${oe} ${ln?"collapsed":""} ${Ae(qe.id)} ${ct(qe.id)?"drop-inside":""}`,children:[d.jsxs("div",{className:`sidebar-container-header ${(ue==null?void 0:ue.itemId)===qe.id&&ue.position==="inside"?"drop-inside":""}`,"data-drag-id":qe.id,"data-drag-type":"container-header","data-drag-ws":He,"data-drag-parent":kt||"","data-section-key":Un,onPointerDown:ve=>me(ve,{type:"container",id:qe.id,sourceWs:He},qe.name),onClick:()=>!ae&<(Un),children:[d.jsx("span",{className:`sidebar-chevron ${ln?"collapsed":""}`,children:"▾"}),U===qe.id?d.jsx("input",{className:"sidebar-rename-input",value:H,onChange:ve=>$(ve.target.value),onBlur:()=>{c.handleRenameContainer(He,qe.id,H),z(null)},onKeyDown:ve=>{ve.key==="Enter"&&(c.handleRenameContainer(He,qe.id,H),z(null)),ve.key==="Escape"&&z(null)},autoFocus:!0,onClick:ve=>ve.stopPropagation()}):d.jsx("span",{className:"sidebar-container-name",onDoubleClick:ve=>{ve.stopPropagation(),z(qe.id),$(qe.name)},children:qe.name}),d.jsxs("div",{className:"sidebar-container-actions",children:[d.jsx("button",{className:"sidebar-new-btn",onClick:ve=>{ve.stopPropagation(),Le({anchor:ve.target.getBoundingClientRect(),wsFilename:He,containerId:qe.id})},title:"New doc",children:"+"}),Ge<2&&d.jsx("button",{className:"sidebar-new-btn",onClick:ve=>{ve.stopPropagation(),c.handleCreateContainer(He,qe.id)},title:"New sub-container",children:"☐"}),d.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:ve=>{ve.stopPropagation(),c.handleDeleteContainer(He,qe.id)},title:"Delete container",children:"×"})]})]}),!ln&&d.jsxs("div",{className:"sidebar-container-list","data-drop-ws":He,"data-drop-container":qe.id,children:[f&&(h==null?void 0:h.wsFilename)===He&&h.containerId===qe.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&&(h==null?void 0:h.wsFilename)===He&&h.containerId===qe.id?qe.items.filter(ve=>ve.type!=="doc"||ve.title!==f):qe.items).map((ve,Fe)=>Xn(ve,Ge+1,He,qe.id,qe.items)),qe.items.length===0&&!f&&d.jsx("div",{className:"sidebar-empty",children:ae?"Drop here":"Empty"})]})]},qe.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:()=>lt("docs"),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:Z=>{Z.stopPropagation(),Le({anchor:Z.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!T.has("docs")&&d.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&(!h||!n.some(Z=>Z.filename===(h==null?void 0:h.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?qt.filter(Z=>Z.title!==f):qt).map((Z,Ge)=>(qt.map(He=>({type:"doc",file:He.filename,title:He.title})),Jt(Z,void 0,null))),qt.length===0&&d.jsx("div",{className:"sidebar-empty",children:ae?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(Z=>{var kt;const Ge=((kt=Z.workspace)==null?void 0:kt.root)||[],He=T.has(Z.filename);return d.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${He?"ws-collapsed":""} ${Ue(Z.filename)?"dragging":""} ${(ue==null?void 0:ue.itemId)===Z.filename?ue.position==="before"?"drop-before":"drop-after":""}`,children:[d.jsxs("div",{className:"sidebar-section-header","data-section-key":Z.filename,"data-ws-drag":Z.filename,onPointerDown:Ze=>me(Ze,{type:"workspace",filename:Z.filename},Z.title),onClick:()=>!ae&<(Z.filename),children:[d.jsx("span",{className:`sidebar-chevron ${He?"collapsed":""}`,children:"▾"}),L===Z.filename?d.jsx("input",{className:"sidebar-rename-input",value:Q,onChange:Ze=>ee(Ze.target.value),onBlur:()=>{c.handleRenameWorkspace(Z.filename,Q),Y(null)},onKeyDown:Ze=>{Ze.key==="Enter"&&(c.handleRenameWorkspace(Z.filename,Q),Y(null)),Ze.key==="Escape"&&Y(null)},autoFocus:!0,onClick:Ze=>Ze.stopPropagation()}):d.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:Ze=>{Ze.stopPropagation(),Y(Z.filename),ee(Z.title)},children:Z.title}),d.jsxs("div",{className:"sidebar-workspace-actions",children:[d.jsx("button",{className:"sidebar-new-btn",onClick:Ze=>{Ze.stopPropagation(),Le({anchor:Ze.target.getBoundingClientRect(),wsFilename:Z.filename,containerId:null})},title:"New document",children:"+"}),d.jsx("button",{className:"sidebar-new-btn",onClick:Ze=>{Ze.stopPropagation(),c.handleCreateContainer(Z.filename,null)},title:"New container",children:"☐"}),R===Z.filename?d.jsxs("span",{className:"sidebar-inline-confirm",onClick:Ze=>Ze.stopPropagation(),children:[d.jsx("button",{onClick:()=>{c.handleDeleteWorkspace(Z.filename),B(null)},children:"Yes"}),d.jsx("button",{onClick:()=>B(null),children:"No"})]}):d.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:Ze=>{Ze.stopPropagation(),B(Z.filename)},title:"Delete workspace",children:"×"})]})]}),!He&&d.jsxs("div",{className:"sidebar-section-list","data-drop-ws":Z.filename,children:[f&&(h==null?void 0:h.wsFilename)===Z.filename&&(h.containerId===null||!R1(Ge,h.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&&(h==null?void 0:h.wsFilename)===Z.filename&&h.containerId===null?Ge.filter(Ze=>Ze.type!=="doc"||Ze.title!==f):Ge).map((Ze,nt)=>Xn(Ze,0,Z.filename,null)),Ge.length===0&&!f&&d.jsx("div",{className:"sidebar-empty",children:ae?"Drop here to add":"Empty workspace"})]})]},Z.filename)}),d.jsx("div",{className:"sidebar-new-workspace",children:d.jsx("button",{onClick:c.handleCreateWorkspace,children:"+ New Workspace"})}),te&&d.jsx(eD,{x:te.x,y:te.y,filename:te.filename,title:te.title,onClose:()=>A(null),onDuplicate:()=>Qn(te.filename),onRename:()=>{w(te.filename),N(te.title)},onArchive:()=>c.handleArchive(te.filename),onDelete:()=>c.handleDelete(te.filename),onPluginAction:(Z,Ge)=>yn(Z,Ge,te.filename,te.title),pluginItems:re,onNewsletterSend:Z=>{tt({connectionId:Z,filename:te.filename,title:te.title}),A(null)},onSchedulePost:()=>{xe({filename:te.filename,title:te.title}),A(null)},onViewAnalytics:te.docId&&te.lastSent?()=>{J({docId:te.docId,title:te.title}),A(null)}:void 0}),Ne&&d.jsx(tD,{actionLabel:Ne.label,docTitle:Ne.title,onClose:()=>Re(null),onConfirm:Z=>{const Ge=re.find(He=>He.action===Ne.action);Ge&&yn(Ne.action,Ge,Ne.filename,Ne.title,Z),Re(null)}}),Be&&d.jsx(O1,{connectionId:Be.connectionId,subject:Be.title,filename:Be.filename,onClose:()=>tt(null)}),I&&d.jsx(nD,{docId:I.docId,title:I.title,onClose:()=>J(null)}),ce&&d.jsx(wm,{filename:ce.filename,title:ce.title,onClose:()=>xe(null)}),ie&&d.jsx(oD,{anchorRect:ie.anchor,onClose:()=>Le(null),onSelect:Z=>{Le(null),ie.wsFilename?c.handleCreateInWorkspace(ie.wsFilename,ie.containerId??null,Z):Z?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:Z})}).catch(()=>{}):l()}})]})}function aD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:l,scrollRef:c,searchQuery:u,searchResults:f}){const[h,m]=E.useState(null);if(f!==null)return d.jsx(xm,{results:f,query:u,onSwitchDocument:s});const y=[...t].sort((k,N)=>new Date(N.lastModified).getTime()-new Date(k.lastModified).getTime()),b=[];let v="";for(const k of y){const N=YL(k.lastModified);N!==v&&(b.push({label:N,docs:[]}),v=N),b[b.length-1].docs.push(k)}const w=k=>{for(const N of e){if(!N.workspace)continue;const C=O=>{for(const T of O)if(T.type==="doc"&&T.file===k||T.type==="container"&&C(T.items))return!0;return!1};if(C(N.workspace.root))return N.title}return null};return d.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:c,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:"+"})]}),b.map(k=>d.jsxs("div",{className:"tl-group",children:[d.jsx("div",{className:"tl-date",children:k.label}),k.docs.map(N=>{const C=w(N.filename);return d.jsxs("div",{className:`tl-item ${N.isActive?"active":""}`,onClick:()=>!N.isActive&&s(N.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:N.title}),r.filenames.includes(N.filename)&&d.jsx("span",{className:"sidebar-pending-dot"})]}),hh(N.filename)&&d.jsx("div",{className:"tl-item-context",children:A1(N.filename)}),d.jsxs("div",{className:"tl-item-meta",children:[N.wordCount.toLocaleString()," words · ",Mo(N.lastModified)]}),C&&d.jsx("div",{className:"tl-badge",children:C})]}),h===N.filename?d.jsxs("div",{className:"sidebar-confirm-delete",onClick:O=>O.stopPropagation(),children:[d.jsx("span",{children:"Delete?"}),d.jsx("button",{onClick:()=>{l.handleDelete(N.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(N.filename)},title:"Delete",children:"×"})]},N.filename)})]},k.label)),t.length===0&&d.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function cD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:l,searchQuery:c,searchResults:u,onSearchChange:f}){const[h,m]=E.useState([]),[y,b]=E.useState(null),[v,w]=E.useState(null),k=E.useRef(null);E.useEffect(()=>{if(!y)return;const A=I=>{k.current&&!k.current.contains(I.target)&&b(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[y]);const N=(A,I)=>{for(const J of A)if(J.type==="container"){if(J.id===I)return J;const re=N(J.items,I);if(re)return re}return null},C=A=>{let I=0;for(const J of A)J.type==="doc"?I++:J.type==="container"&&(I+=C(J.items));return I},O=A=>{const I=[];for(const J of A)J.type==="doc"?I.push(J.file):J.type==="container"&&I.push(...O(J.items));return I},T=E.useMemo(()=>{if(h.length===0)return[];const A=h[h.length-1],I=e.find(re=>re.filename===A.wsFilename);if(!(I!=null&&I.workspace))return[];if(A.type==="workspace")return I.workspace.root;const J=N(I.workspace.root,A.key);return J?J.items:[]},[h,e]),M=T.filter(A=>A.type==="container"),R=E.useMemo(()=>{const A=T.filter(I=>I.type==="doc").map(I=>I.file);return t.filter(I=>A.includes(I.filename))},[T,t]),B=A=>{const I=O(A.items);return t.filter(J=>I.includes(J.filename))},U=A=>{const I=e.find(re=>re.filename===A);if(!(I!=null&&I.workspace))return[];const J=O(I.workspace.root);return t.filter(re=>J.includes(re.filename))},z=E.useMemo(()=>t.filter(A=>!n.has(A.filename)),[t,n]),H=A=>{m(I=>[...I,A]),b(null)},$=()=>{m(A=>A.slice(0,-1)),b(null)},L=(A,I)=>{if(y===A){b(null);return}const re=I.currentTarget.getBoundingClientRect();w({top:re.bottom+4,left:re.left}),b(A)},Y=A=>{s(A),b(null)},Q=h.length>1?h[h.length-2].title:"All",ee=E.useRef(null),G=E.useRef(null),[ne,V]=E.useState(null),X=E.useCallback(A=>{const J=A.currentTarget.getBoundingClientRect();V({top:J.bottom+4,left:J.left})},[]);E.useEffect(()=>{if(!u)return;const A=I=>{G.current&&!G.current.contains(I.target)&&ee.current&&!ee.current.contains(I.target)&&f("")};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[u,f]);const te=()=>{if(!y)return[];if(y==="__unassigned__")return z;if(y==="__level-docs__")return R;const A=e.find(I=>I.filename===y);if(A)return U(A.filename);for(const I of e){if(!I.workspace)continue;const J=N(I.workspace.root,y);if(J)return B(J)}return[]};return d.jsxs("div",{className:"board-scroll",ref:l,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:ee,className:"board-search-input",type:"text",placeholder:"Search...",value:c,onChange:A=>f(A.target.value),onFocus:X}),c&&d.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),h.length===0?d.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):d.jsxs("button",{className:"board-back",onClick:$,title:`Back to ${Q}`,children:["← ",Q]}),h.length===0&&d.jsxs(d.Fragment,{children:[z.length>0&&d.jsxs("button",{className:`board-chip ${y==="__unassigned__"?"open":""}`,onClick:A=>L("__unassigned__",A),children:["Documents ",d.jsx("span",{className:"board-chip-count",children:z.length})]}),e.map(A=>{var J;const I=(J=A.workspace)==null?void 0:J.root.some(re=>re.type==="container");return d.jsxs("button",{className:`board-chip ${y===A.filename?"open":""}`,onClick:re=>I?H({type:"workspace",key:A.filename,title:A.title,wsFilename:A.filename}):L(A.filename,re),children:[A.title," ",d.jsx("span",{className:"board-chip-count",children:A.docCount}),I&&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:"+"})]}),h.length>0&&d.jsxs(d.Fragment,{children:[R.length>0&&d.jsxs("button",{className:`board-chip board-chip-docs ${y==="__level-docs__"?"open":""}`,onClick:A=>L("__level-docs__",A),children:["Docs ",d.jsx("span",{className:"board-chip-count",children:R.length})]}),M.map(A=>{const I=A.items.some(J=>J.type==="container");return d.jsxs("button",{className:`board-chip ${y===A.id?"open":""}`,onClick:J=>I?H({type:"container",key:A.id,title:A.name,wsFilename:h[h.length-1].wsFilename}):L(A.id,J),children:[A.name," ",d.jsx("span",{className:"board-chip-count",children:C(A.items)}),I&&d.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.id)})]}),y&&v&&(()=>{const A=te();return d.jsxs("div",{className:"board-dropdown",ref:k,style:{position:"fixed",top:v.top,left:v.left},children:[A.map(I=>d.jsxs("div",{className:`board-dropdown-item ${I.isActive?"active":""}`,onClick:()=>Y(I.filename),children:[d.jsxs("span",{className:"board-dropdown-title",children:[I.title,r.filenames.includes(I.filename)&&d.jsx("span",{className:"board-pending-dot"})]}),d.jsxs("span",{className:"board-dropdown-meta",children:[I.wordCount.toLocaleString()," words · ",Mo(I.lastModified)]})]},I.filename)),A.length===0&&d.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),u&&ne&&d.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:G,style:{position:"fixed",top:ne.top,left:ne.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 · ",Mo(A.lastModified)]})]},A.filename)),u.length===0&&d.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function uD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:l,searchQuery:c,searchResults:u}){const[f,h]=E.useState([]);if(u!==null)return d.jsx(xm,{results:u,query:c,onSwitchDocument:s});const m=(T,M)=>{for(const R of T)if(R.type==="container"){if(R.id===M)return R;const B=m(R.items,M);if(B)return B}return null},y=T=>{let M=0;for(const R of T)R.type==="doc"?M++:R.type==="container"&&(M+=y(R.items));return M},b=E.useMemo(()=>{if(f.length===0)return[];const T=f[f.length-1],M=e.find(B=>B.filename===T.wsFilename);if(!(M!=null&&M.workspace))return[];if(T.type==="workspace")return M.workspace.root;const R=m(M.workspace.root,T.key);return R?R.items:[]},[f,e]),v=b.filter(T=>T.type==="container"),w=E.useMemo(()=>{if(f.length===0)return t.filter(M=>!n.has(M.filename));const T=b.filter(M=>M.type==="doc").map(M=>M.file);return t.filter(M=>T.includes(M.filename))},[f,b,t,n]),k=T=>h(M=>[...M,T]),N=()=>h(T=>T.slice(0,-1)),C=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:l,children:[f.length>0&&d.jsxs("button",{className:"shelf-back",onClick:N,title:`Back to ${C}`,children:[d.jsx("span",{className:"shelf-back-arrow",children:"←"}),d.jsx("span",{className:"shelf-back-label",children:C})]}),f.length===0&&d.jsxs(d.Fragment,{children:[e.map(T=>d.jsxs("div",{className:"shelf-section-spine",onClick:()=>k({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&&v.map(T=>d.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>k({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:y(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:[w.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 · ",Mo(T.lastModified)]})]},T.filename)),w.length===0&&d.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}const dD=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],fD=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}];function pD({slots:t,onBack:e}){const[n,r]=E.useState(t),[s,i]=E.useState("09:00"),[l,c]=E.useState(["default"]),[u,f]=E.useState("any"),[h,m]=E.useState(!1);async function y(){const w=await fetch("/api/scheduler/slots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:s,days:l.includes("default")?["default"]:l,filter_type:u})});if(w.ok){const k=await w.json();r(N=>[...N,k.slot]),m(!1),i("09:00"),c(["default"]),f("any")}}async function b(w){(await fetch(`/api/scheduler/slots/${w}`,{method:"DELETE"})).ok&&r(N=>N.filter(C=>C.id!==w))}function v(w){c(k=>{if(w==="default")return["default"];const N=k.filter(C=>C!=="default");if(N.includes(w)){const C=N.filter(O=>O!==w);return C.length===0?["default"]:C}return[...N,w]})}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:()=>m(!h),children:h?"Cancel":"+ Add"})]}),h&&d.jsxs("div",{style:{padding:"12px",borderBottom:"1px solid var(--sidebar-border)"},children:[d.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"8px",alignItems:"center"},children:[d.jsx("input",{type:"time",value:s,onChange:w=>i(w.target.value),style:{background:"var(--sidebar-bg)",border:"1px solid var(--sidebar-border)",borderRadius:"4px",padding:"4px 8px",color:"var(--sidebar-text)",fontSize:"12px"}}),d.jsx("select",{value:u,onChange:w=>f(w.target.value),style:{background:"var(--sidebar-bg)",border:"1px solid var(--sidebar-border)",borderRadius:"4px",padding:"4px 8px",color:"var(--sidebar-text)",fontSize:"12px"},children:fD.map(w=>d.jsx("option",{value:w.value,children:w.label},w.value))})]}),d.jsxs("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginBottom:"8px"},children:[d.jsx("button",{className:`sidebar-schedule-btn ${l.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>v("default"),style:{fontSize:"10px",padding:"2px 6px"},children:"Every day"}),dD.map(w=>d.jsx("button",{className:`sidebar-schedule-btn ${l.includes(w.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>v(w.toLowerCase()),style:{fontSize:"10px",padding:"2px 6px"},children:w},w))]}),d.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active",onClick:y,style:{width:"100%"},children:"Create Slot"})]}),d.jsx("div",{style:{flex:1,overflow:"auto"},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(w=>d.jsxs("div",{className:"schedule-item",style:{cursor:"default"},children:[d.jsx("div",{className:"schedule-item-time",style:{width:"60px",fontWeight:600},children:hD(w.time)}),d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:w.days.includes("default")?"Every day":w.days.join(", ")}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsxs("span",{children:["Filter: ",w.filter_type]}),w.filter_value&&d.jsxs("span",{children:["(",w.filter_value,")"]}),d.jsx("span",{children:w.timezone})]})]}),d.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>b(w.id),title:"Delete slot",style:{alignSelf:"center"},children:"×"})]},w.id))})]})}function hD(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function mD({onBack:t}){const[e,n]=E.useState([]),[r,s]=E.useState([]),[i,l]=E.useState(!1),[c,u]=E.useState(null),[f,h]=E.useState(!0),m=E.useCallback(async()=>{try{const[v,w]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots")]);if(v.ok){const k=await v.json();n(k.items||[])}if(w.ok){const k=await w.json();s(k.slots||[])}}catch{}h(!1)},[]);E.useEffect(()=>{m()},[m]);const y=async v=>{(await fetch(`/api/scheduler/queue/${v}`,{method:"DELETE"})).ok&&(n(k=>k.filter(N=>N.id!==v)),u(null))};if(i)return d.jsx(pD,{slots:r,onBack:()=>{l(!1),m()}});const b=gD(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.jsx("div",{className:"sidebar-schedule-actions",children:d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>l(!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"})]})})})]}),f?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."})]}):b.map(({label:v,entries:w})=>d.jsxs("div",{className:"schedule-day",children:[d.jsx("div",{className:"schedule-day-header",children:v}),w.map((k,N)=>{var C,O,T,M,R;return k.type==="empty"?d.jsxs("div",{className:"schedule-slot-empty",children:[d.jsx("div",{className:"schedule-item-time",children:w0(k.time)}),d.jsx("div",{className:"schedule-slot-empty-label",children:((C=k.slot)==null?void 0:C.filter_type)==="any"?"Open slot":`${(O=k.slot)==null?void 0:O.filter_type}: ${((T=k.slot)==null?void 0:T.filter_value)||"any"}`})]},`empty-${N}`):d.jsxs("div",{children:[d.jsxs("div",{className:"schedule-item",onClick:()=>u(c===k.item.id?null:k.item.id),children:[d.jsx("div",{className:"schedule-item-time",children:w0(k.time)}),d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:((M=k.item.content)==null?void 0:M.text)||JSON.stringify(k.item.content)}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsx("span",{className:`schedule-item-status schedule-item-status--${k.item.status}`}),d.jsx("span",{children:k.item.status}),k.item.connection_name&&d.jsx("span",{children:k.item.connection_name}),k.item.provider&&d.jsx("span",{children:k.item.provider})]})]})]}),c===k.item.id&&d.jsxs("div",{className:"schedule-item-expanded",children:[d.jsx("div",{className:"schedule-item-full-text",children:((R=k.item.content)==null?void 0:R.text)||JSON.stringify(k.item.content,null,2)}),d.jsx("div",{className:"schedule-item-actions",children:d.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>y(k.item.id),children:"Cancel"})})]})]},k.item.id)})]},v))]})}function gD(t,e){const n=new Date,r=[];for(let c=0;c<7;c++){const u=new Date(n);u.setDate(u.getDate()+c),u.setHours(0,0,0,0);let f;c===0?f="Today":c===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 c of e){const u=new Date(c.scheduled_at),f=`${u.getFullYear()}-${u.getMonth()}-${u.getDate()}-${u.getHours()}-${u.getMinutes()}`;s.set(f,c)}const i=new Set,l=[];for(const{label:c,date:u}of r){const f=[],h=u.getDay(),y=["sun","mon","tue","wed","thu","fri","sat"][h];for(const b of t){if(!(b.days.includes("default")||b.days.includes(y)))continue;const[w,k]=b.time.split(":").map(Number),N=new Date(u);if(N.setHours(w,k,0,0),x0(u,n)&&N<n)continue;const C=`${N.getFullYear()}-${N.getMonth()}-${N.getDate()}-${w}-${k}`,O=s.get(C);O?(f.push({type:"filled",time:N,item:O,slot:b}),i.add(O.id)):f.push({type:"empty",time:N,slot:b})}for(const b of e){if(i.has(b.id))continue;const v=new Date(b.scheduled_at);x0(v,u)&&(f.push({type:"filled",time:v,item:b}),i.add(b.id))}f.sort((b,v)=>b.time.getTime()-v.time.getTime()),f.length>0&&l.push({label:c,entries:f})}return l}function x0(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function w0(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function yD({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:l}){const[c,u]=E.useState(!1),[f,h]=E.useState(!1),[m,y]=E.useState(""),[b,v]=E.useState(null),w=E.useRef(null),k=E.useRef(null);E.useEffect(()=>{if(!c)return;const C=O=>{w.current&&!w.current.contains(O.target)&&(u(!1),h(!1),y(""),v(null))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[c]),E.useEffect(()=>{f&&k.current&&k.current.focus()},[f]);const N=()=>{const C=m.trim();C&&(s(C),y(""),h(!1))};return d.jsxs("div",{className:"sidebar-profile-wrapper",ref:w,children:[d.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>u(!c),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"})]})}),c&&d.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(C=>d.jsxs("div",{className:"sidebar-profile-row",children:[b===C?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(C),v(null)},children:"Yes"}),d.jsx("button",{onClick:()=>v(null),children:"No"})]})]}):d.jsx(d.Fragment,{children:d.jsxs("button",{className:`sidebar-profile-option ${C===e?"active":""}`,onClick:()=>{C!==e&&r(C),u(!1)},children:[d.jsx("span",{className:"sidebar-profile-check",children:C===e?"✓":""}),d.jsx("span",{children:C})]})}),C!=="Default"&&C!==e&&b!==C&&d.jsx("button",{className:"sidebar-profile-delete-btn",onClick:O=>{O.stopPropagation(),v(C)},title:"Delete profile",children:"×"})]},C)),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(C=>d.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[d.jsx("span",{className:"sidebar-profile-trash-name",children:C}),d.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>l(C),children:"Restore"})]},C))]}),d.jsx("div",{className:"sidebar-profile-divider"}),f?d.jsx("div",{className:"sidebar-profile-add-input",children:d.jsx("input",{ref:k,type:"text",value:m,onChange:C=>y(C.target.value),onKeyDown:C=>{C.key==="Enter"&&N(),C.key==="Escape"&&(h(!1),y(""))},placeholder:"Profile name..."})}):d.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>h(!0),children:[d.jsx("span",{className:"sidebar-profile-check",children:"+"}),d.jsx("span",{children:"New Profile"})]})]})]})}const bD=[{id:"full",label:"Full",lines:3},{id:"compact",label:"Compact",lines:2},{id:"minimal",label:"Minimal",lines:1}];function vD(){const[t,e]=E.useState(!1),[n,r]=E.useState(H0),s=E.useRef(null);E.useEffect(()=>{if(!t)return;const l=c=>{s.current&&!s.current.contains(c.target)&&e(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[t]);const i=l=>{r(l),EE(l),e(!1)};return d.jsxs("div",{className:"sidebar-density-wrapper",ref:s,children:[d.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>e(!t),title:"Card density",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:"M21 9H3"}),d.jsx("path",{d:"M21 15H3"})]})}),t&&d.jsx("div",{className:"sidebar-density-dropdown",children:bD.map(l=>d.jsxs("button",{className:`sidebar-density-option ${n===l.id?"active":""}`,onClick:()=>i(l.id),children:[d.jsx("span",{className:"sidebar-density-icon",children:Array.from({length:l.lines},(c,u)=>d.jsx("span",{className:"sidebar-density-line"},u))}),d.jsx("span",{children:l.label})]},l.id))})]})}function k0({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,workspacesRefreshKey:s,pendingDocs:i,writingTitle:l,writingTarget:c,onClose:u}){const{docs:f,workspaces:h,assignedFiles:m,fetchDocs:y,scrollRef:b}=QL(r,s),v=XL(h,y,r),w=zu(),[k,N]=E.useState(!1),[C,O]=E.useState([]),[T,M]=E.useState("Default"),R=E.useCallback(async()=>{try{const re=await fetch("/api/profiles");if(re.ok){const pe=await re.json();O(pe.profiles),M(pe.active)}}catch{}},[]);E.useEffect(()=>{R()},[R]);const B=E.useCallback(async re=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:re})})).ok&&(M(re),R())}catch{}},[R]),U=E.useCallback(async re=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:re})})).ok&&R()}catch{}},[R]),[z,H]=E.useState([]),$=E.useCallback(async()=>{try{const re=await fetch("/api/profiles/trash");if(re.ok){const pe=await re.json();H(pe.profiles)}}catch{}},[]);E.useEffect(()=>{$()},[$]);const L=E.useCallback(async re=>{try{(await fetch(`/api/profiles/${encodeURIComponent(re)}`,{method:"DELETE"})).ok&&(R(),$())}catch{}},[R,$]),Y=E.useCallback(async re=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:re})})).ok&&(R(),$())}catch{}},[R,$]),[Q,ee]=E.useState(""),[G,ne]=E.useState(null),V=E.useRef(),X=E.useRef(null),te=E.useCallback(re=>{if(ee(re),V.current&&clearTimeout(V.current),!re.trim()){ne(null);return}V.current=setTimeout(async()=>{try{const pe=await fetch(`/api/documents/search?q=${encodeURIComponent(re.trim())}&archived=true`);pe.ok&&ne(await pe.json())}catch{}},250)},[]);E.useEffect(()=>()=>{V.current&&clearTimeout(V.current)},[]);const A={docs:f,archivedDocs:[],workspaces:h,assignedFiles:m,pendingDocs:i,writingTitle:l,writingTarget:c,onSwitchDocument:e,onCreateDocument:n,actions:v,scrollRef:b,searchQuery:Q,searchResults:G,onSearchChange:te},I=()=>{switch(w){case"timeline":return d.jsx(aD,{...A});case"board":return d.jsx(cD,{...A});case"shelf":return d.jsx(uD,{...A});default:return d.jsx(lD,{...A})}},J=d.jsxs("div",{className:"sidebar-search",children:[d.jsxs("svg",{className:"sidebar-search-icon",width:"14",height:"14",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:X,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:Q,onChange:re=>te(re.target.value)}),Q&&d.jsx("button",{className:"sidebar-search-clear",onClick:()=>te(""),title:"Clear search",children:"×"})]});return w==="board"?d.jsx("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,children:I()}):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(yD,{profiles:C,activeProfile:T,trashedProfiles:z,onSwitch:B,onCreate:U,onDelete:L,onRestore:Y}),d.jsx("button",{className:`sidebar-collapse-btn${k?" sidebar-collapse-btn--active":""}`,onClick:()=>N(!k),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(vD,{}),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"})]})})]})]}),k?d.jsx(mD,{onBack:()=>N(!1)}):d.jsxs(d.Fragment,{children:[J,I()]})]})}function xD({onClose:t,onSetupComplete:e}){const[n,r]=E.useState("detecting"),[s,i]=E.useState(null),[l,c]=E.useState("gh"),[u,f]=E.useState("openwriter-docs"),[h,m]=E.useState(!0),[y,b]=E.useState(""),[v,w]=E.useState(""),[k,N]=E.useState(""),[C,O]=E.useState("");E.useEffect(()=>{fetch("/api/sync/capabilities").then(M=>M.json()).then(M=>{i(M),M.ghAuthenticated?c("gh"):(M.gitInstalled,c("pat")),r("setup")}).catch(()=>{N("Failed to detect git capabilities"),r("error")})},[]);const T=E.useCallback(async()=>{r("progress"),O(l==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const M={method:l,repoName:u,isPrivate:h};l==="pat"&&(M.pat=y),l==="connect"&&(M.remoteUrl=v,M.pat=y||void 0);const R=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)});if(!R.ok){const B=await R.json().catch(()=>({}));throw new Error(B.error||`Setup failed (${R.status})`)}r("done"),e()}catch(M){N(M.message),r("error")}},[l,u,h,y,v,e]);return d.jsx("div",{className:"sync-modal-overlay",onClick:t,children:d.jsxs("div",{className:"sync-modal",onClick:M=>M.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${l==="gh"?" active":""}`,onClick:()=>c("gh"),children:"GitHub CLI"}),d.jsx("button",{className:`sync-tab${l==="pat"?" active":""}`,onClick:()=>c("pat"),children:"Personal Access Token"}),d.jsx("button",{className:`sync-tab${l==="connect"?" active":""}`,onClick:()=>c("connect"),children:"Connect Existing"})]}),l==="gh"&&d.jsxs("div",{className:"sync-form",children:[d.jsxs("label",{children:["Repository name",d.jsx("input",{type:"text",value:u,onChange:M=>f(M.target.value),placeholder:"openwriter-docs"})]}),d.jsxs("label",{className:"sync-checkbox",children:[d.jsx("input",{type:"checkbox",checked:h,onChange:M=>m(M.target.checked)}),"Private repository"]})]}),l==="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:y,onChange:M=>b(M.target.value),placeholder:"ghp_..."})]}),d.jsxs("label",{children:["Repository name",d.jsx("input",{type:"text",value:u,onChange:M=>f(M.target.value),placeholder:"openwriter-docs"})]}),d.jsxs("label",{className:"sync-checkbox",children:[d.jsx("input",{type:"checkbox",checked:h,onChange:M=>m(M.target.checked)}),"Private repository"]})]}),l==="connect"&&d.jsxs("div",{className:"sync-form",children:[d.jsxs("label",{children:["Remote URL",d.jsx("input",{type:"text",value:v,onChange:M=>w(M.target.value),placeholder:"https://github.com/user/repo.git"})]}),d.jsxs("label",{children:["PAT (optional, for private repos)",d.jsx("input",{type:"password",value:y,onChange:M=>b(M.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:l==="pat"&&!y||l==="connect"&&!v||l!=="connect"&&!u,children:l==="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:C})]}),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:k}),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 wD({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentsChanged:r,onWorkspacesChanged:s,onTitleChanged:i,onPendingDocsChanged:l,onMetadataChanged:c,onSyncStatus:u,onWritingStarted:f,onWritingFinished:h,getEditorState:m}){const y=E.useRef(null),[b,v]=E.useState(!1),w=E.useRef(t),k=E.useRef(e),N=E.useRef(n),C=E.useRef(r),O=E.useRef(s),T=E.useRef(i),M=E.useRef(l),R=E.useRef(u),B=E.useRef(c),U=E.useRef(f),z=E.useRef(h),H=E.useRef(m);w.current=t,k.current=e,N.current=n,C.current=r,O.current=s,T.current=i,M.current=l,B.current=c,R.current=u,U.current=f,z.current=h,H.current=m,E.useEffect(()=>{const Y=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let Q,ee=!1,G=1e3;function ne(){const X=new WebSocket(Y);y.current=X,X.onopen=()=>{v(!0),G=1e3,ee&&X.send(JSON.stringify({type:"request-document"})),ee=!0},X.onmessage=te=>{var A,I,J,re,pe,Ne,Re,Be,tt,ce,xe;try{const ie=JSON.parse(te.data);ie.type==="node-changes"&&ie.changes&&((A=w.current)==null||A.call(w,ie.changes)),ie.type==="agent-status"&&((I=k.current)==null||I.call(k,!!ie.agentConnected)),ie.type==="document-switched"&&((J=N.current)==null||J.call(N,{document:ie.document,title:ie.title,filename:ie.filename,docId:ie.docId,metadata:ie.metadata})),ie.type==="metadata-changed"&&ie.metadata&&((re=B.current)==null||re.call(B,ie.metadata)),ie.type==="documents-changed"&&((pe=C.current)==null||pe.call(C)),ie.type==="workspaces-changed"&&((Ne=O.current)==null||Ne.call(O)),ie.type==="title-changed"&&ie.title&&((Re=T.current)==null||Re.call(T,ie.title)),ie.type==="pending-docs-changed"&&ie.pendingDocs&&((Be=M.current)==null||Be.call(M,ie.pendingDocs)),ie.type==="sync-status"&&((tt=R.current)==null||tt.call(R,{state:ie.state,lastSyncTime:ie.lastSyncTime,pendingFiles:ie.pendingFiles,error:ie.error})),ie.type==="writing-started"&&ie.title&&((ce=U.current)==null||ce.call(U,ie.title,ie.target||null)),ie.type==="writing-finished"&&((xe=z.current)==null||xe.call(z)),ie.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),ie.type==="marks-changed"&&ie.filename&&window.dispatchEvent(new CustomEvent("ow-marks-changed",{detail:{filename:ie.filename}}))}catch{}},X.onclose=()=>{v(!1),Q=setTimeout(ne,G),G=Math.min(G*1.5,8e3)},X.onerror=()=>{X.close()}}ne();function V(){var X;document.visibilityState==="visible"&&((X=y.current)==null?void 0:X.readyState)!==WebSocket.OPEN&&(clearTimeout(Q),G=1e3,ne())}return document.addEventListener("visibilitychange",V),()=>{var X;clearTimeout(Q),document.removeEventListener("visibilitychange",V),(X=y.current)==null||X.close()}},[]);const $=E.useCallback(L=>{var Y;((Y=y.current)==null?void 0:Y.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify(L))},[]);return{connected:b,sendMessage:$}}function kD(t){const[e,n]=E.useState(null),[r,s]=E.useState(!1),[i,l]=E.useState(null),c=E.useRef(void 0);return E.useEffect(()=>{if(!t){n(null),s(!1),l(null),c.current=void 0;return}t!==c.current&&(c.current=t,s(!0),l(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=>{l(u.message),s(!1)}))},[t]),{tweet:e,loading:r,error:i}}function SD(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(`
|
|
205
|
+
|
|
206
|
+
`)}function ED(t,e){const[n,r]=E.useState("idle"),s=E.useRef();return{copyText:E.useCallback(async()=>{const l=t.current[e];if(!l)return;const c=SD(l);if(c){try{await navigator.clipboard.writeText(c)}catch{const u=document.createElement("textarea");u.value=c,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}r("copied"),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r("idle"),2e3)}},[t,e]),copyState:n}}function Tp(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 ND(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 CD=()=>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"})}),_D=()=>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"})}),TD=()=>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"})}),MD=()=>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"})}),AD=()=>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 j1({tweet:t,nested:e,url:n}){const r=ND(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(j1,{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(CD,{}),t.metrics.replies>0&&Tp(t.metrics.replies)]}),d.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[d.jsx(_D,{}),t.metrics.retweets>0&&Tp(t.metrics.retweets)]}),d.jsxs("span",{className:"tweet-action tweet-action-like",children:[d.jsx(TD,{}),t.metrics.likes>0&&Tp(t.metrics.likes)]}),d.jsx("span",{className:"tweet-action tweet-action-bookmark",children:d.jsx(MD,{})}),d.jsx("span",{className:"tweet-action tweet-action-share",children:d.jsx(AD,{})})]})]})}function OD({tweet:t,url:e}){return d.jsx(j1,{tweet:t,url:e})}function RD({initialContent:t,placeholder:e="What is happening?!",onUpdate:n,onReady:r,onFocus:s}){const i=sk({extensions:[...y1,ed.configure({placeholder:e})],content:t||"<p></p>",onUpdate:({editor:l})=>{n==null||n(l)},onFocus:()=>{s==null||s()}},[t]);return E.useEffect(()=>{if(!i)return;const{state:l}=i.view;if(l.plugins.some(f=>f.key==="pendingDecoration$"))return;const c=k1(),u=l.reconfigure({plugins:[...l.plugins,c]});i.view.updateState(u)},[i]),E.useEffect(()=>{i&&(r==null||r(i))},[i,r]),i?d.jsx(Gh,{editor:i}):null}function ID({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),s=26,i=2,l=(s-i)/2,c=2*Math.PI*l,u=c*(1-r);let f="var(--x-blue, #1d9bf0)";n<=0?f="var(--x-red, #f4212e)":n<=20&&(f="var(--x-yellow, #ffd400)");const h=n<=20;return t===0?null:d.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:s,height:s},children:[d.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[d.jsx("circle",{cx:s/2,cy:s/2,r:l,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:i}),d.jsx("circle",{cx:s/2,cy:s/2,r:l,fill:"none",stroke:f,strokeWidth:i,strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",transform:`rotate(-90 ${s/2} ${s/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),h&&d.jsx("span",{className:"tweet-char-number",style:{color:f},children:n})]})}const S0="@openwriter/plugin-x-api",E0=[{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 jD({onConnected:t,onCancel:e}){const[n,r]=E.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=E.useState(!1),[l,c]=E.useState(""),u=E0.every(h=>n[h.key].trim()),f=async()=>{i(!0),c("");try{if(!(await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S0,config:n})})).ok)throw new Error("Failed to save config");const y=await(await fetch("/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S0})})).json();if(!y.success)throw new Error(y.error||"Failed to enable plugin");const v=await(await fetch("/api/x/status")).json();v.connected?t():c(v.error||"Could not verify X credentials. Check your API keys.")}catch(h){c(h.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:E0.map(h=>d.jsxs("div",{className:"x-connect-field",children:[d.jsx("label",{className:"x-connect-label",children:h.label}),d.jsx("input",{type:"password",className:"x-connect-input",value:n[h.key],onChange:m=>r(y=>({...y,[h.key]:m.target.value})),placeholder:h.env,spellCheck:!1,autoComplete:"off"})]},h.key))}),l&&d.jsx("div",{className:"x-connect-error",children:l}),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"})]})]})}const N0="ow-x-handle";function LD(){const[t,e]=E.useState(()=>localStorage.getItem(N0)||""),[n,r]=E.useState(!1),[s,i]=E.useState(""),l=E.useRef(null),c=E.useRef(null),u=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(N0,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=l.current)==null?void 0:m.focus()},0)};E.useEffect(()=>{if(!n)return;const m=y=>{c.current&&!c.current.contains(y.target)&&u()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n,s]);const h=t?`https://unavatar.io/twitter/${t}`:"";return d.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:c,children:[t?d.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:h,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:l,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 C0(){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 DD(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function _0(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 T0(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 M0(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 PD({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s}){const{tweet:i,loading:l,error:c}=kD(t==null?void 0:t.url),[u,f]=E.useState(()=>_0(e)),[h,m]=E.useState(0),y=E.useRef([]),b=E.useRef(null),v=E.useRef(!0),[w,k]=E.useState(()=>u.map(()=>0)),[N,C]=E.useState(0),[O,T]=E.useState(0),[M,R]=E.useState(null),[B,U]=E.useState(),[z,H]=E.useState(!1),[$,L]=E.useState("idle"),[Y,Q]=E.useState(""),ee=E.useRef(),{copyText:G,copyState:ne}=ED(y,N);E.useEffect(()=>{let ae=!1;return(async()=>{try{const ue=await fetch("/api/x/status");if(ae)return;if(ue.ok){const me=await ue.json();R(me.connected),U(me.username)}else R(!1)}catch{ae||R(!1)}})(),()=>{ae=!0}},[]),E.useEffect(()=>{if(v.current){v.current=!1;return}if(!e||JSON.stringify(e)===b.current)return;const ue=_0(e);y.current=[],f(ue),k(ue.map(()=>0)),m(me=>me+1)},[e]);const V=E.useCallback((ae,ue)=>{y.current[ae]=ue,k(Ae=>{const Ue=[...Ae];return Ue[ae]=ue.getText().length,Ue});const me=T0(y.current);b.current=JSON.stringify(me),n==null||n(me)},[n]),X=E.useCallback((ae,ue)=>{y.current[ae]=ue,k(me=>{const Ae=[...me];return Ae[ae]=ue.getText().length,Ae}),T(me=>me+1),ae===0&&(r==null||r(ue)),s==null||s(y.current.filter(Boolean))},[r,s]),te=u.length>1;w.reduce((ae,ue)=>ae+ue,0);const A=E.useCallback(()=>{const ae=N+1;f(ue=>[...ue.slice(0,ae),"<p></p>",...ue.slice(ae)]),k(ue=>[...ue.slice(0,ae),0,...ue.slice(ae)]),C(ae)},[N]),I=E.useCallback(ae=>{ae!==0&&(y.current.splice(ae,1),f(ue=>ue.filter((me,Ae)=>Ae!==ae)),k(ue=>ue.filter((me,Ae)=>Ae!==ae)),setTimeout(()=>{const ue=T0(y.current);n==null||n(ue),s==null||s(y.current.filter(Boolean))},0))},[n,s]),J=!!(t!=null&&t.url),re=(t==null?void 0:t.mode)==="reply",pe=y.current.filter(Boolean).some(ue=>ue.getText().trim()||M0(ue).length>0),Ne=M&&pe&&$==="idle",Re=async()=>{if(!M){H(!0);return}if(Ne){L("uploading"),Q("");try{const ae=y.current.filter(Boolean),ue=[];for(const Ae of ae){const Ue=Ae.getText().trim(),ct=M0(Ae);if(!Ue&&ct.length===0)continue;const pt=[];for(const Lt of ct){const yn=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:Lt})})).json();if(!yn.success)throw new Error(yn.error||"Image upload failed");pt.push(yn.mediaId)}ue.push({text:Ue,mediaIds:pt})}if(ue.length===0)return;L("posting");const me=DD(t==null?void 0:t.url);if(ue.length===1){const Ae={};ue[0].text&&(Ae.text=ue[0].text),ue[0].mediaIds.length>0&&(Ae.mediaIds=ue[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&me?Ae.replyTo=me:(t==null?void 0:t.mode)==="quote"&&me&&(Ae.quoteTweetId=me);const ct=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ae)})).json();ct.success?(L("success"),ee.current=setTimeout(()=>L("idle"),2500)):(console.error("[TweetCompose] Post error:",ct.error),Q(ct.error||"Post failed"),L("error"),setTimeout(()=>L("idle"),3e3))}else{const Ue={tweets:ue.map(Lt=>({text:Lt.text,...Lt.mediaIds.length>0?{mediaIds:Lt.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&me&&(Ue.replyTo=me);const pt=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ue)})).json();pt.success?(L("success"),ee.current=setTimeout(()=>L("idle"),2500)):(Q(pt.error||"Thread post failed"),L("error"),setTimeout(()=>L("idle"),3e3))}}catch(ae){Q(ae.message||"Network error"),L("error"),setTimeout(()=>L("idle"),3e3)}}};E.useEffect(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);const Be=()=>{R(!0),H(!1),fetch("/api/x/status").then(ae=>ae.json()).then(ae=>{ae.username&&U(ae.username)}).catch(()=>{})},tt=$==="uploading"?"Uploading...":$==="posting"?"Posting...":$==="success"?"Posted!":$==="error"?"Failed":te?N===0?"Post Thread":"Post All":"Post",ce=u.map((ae,ue)=>ue===0?re?"Post your reply":"What is happening?!":"Add another tweet"),xe=ae=>d.jsxs("div",{className:`tweet-compose-footer${ae?" tweet-compose-footer--inline":""}`,children:[$==="error"&&Y&&d.jsx("span",{className:"tweet-post-error",children:Y}),d.jsx(ID,{count:w[N]||0}),d.jsx("button",{className:"tweet-thread-add",onClick:A,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${ne==="copied"?" tweet-copy-btn--copied":""}`,disabled:!pe,onClick:G,title:"Copy tweet text to clipboard",children:ne==="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"]})}),d.jsx("button",{className:`tweet-post-btn${Ne||!M&&M!==null?" tweet-post-btn--active":""}${$==="success"?" tweet-post-btn--success":""}${$==="error"?" tweet-post-btn--error":""}`,disabled:M?!Ne:!1,onClick:Re,title:M?B?`Post as @${B}`:"Post to X":"Connect X to post",children:tt})]}),ie=J&&!re,Le=()=>d.jsx("div",{className:"tweet-thread-editors",children:u.map((ae,ue)=>d.jsxs("div",{className:`tweet-thread-item${ue===N?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[d.jsxs("div",{className:"tweet-thread-item-left",children:[d.jsx(LD,{}),ue<u.length-1&&d.jsx("div",{className:"tweet-thread-line"})]}),d.jsxs("div",{className:"tweet-thread-item-right",children:[ue>0&&d.jsx("button",{className:"tweet-thread-remove",onClick:()=>I(ue),title:"Remove this tweet",children:"×"}),d.jsx("div",{className:`tweet-compose-box${ue===0&&!te?" tweet-compose-box--standalone":""}`,children:d.jsx(RD,{initialContent:ae,placeholder:ce[ue],onUpdate:me=>V(ue,me),onReady:me=>X(ue,me),onFocus:()=>C(ue)})}),ue===N&&!ie&&xe(ue<u.length-1)]})]},`${h}-${ue}`))});return d.jsxs("div",{className:"tweet-compose-wrapper",children:[J&&re&&d.jsxs(d.Fragment,{children:[l&&d.jsx("div",{className:"tweet-context-section",children:d.jsx(C0,{})}),c&&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})]})}),i&&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:[i.author.avatarUrl?d.jsx("img",{className:"tweet-avatar",src:i.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:i.author.name}),d.jsxs("span",{className:"tweet-author-handle",children:["@",i.author.username]})]}),d.jsx("div",{className:"tweet-text",children:i.text}),i.media&&i.media.length>0&&d.jsx("div",{className:"tweet-media",children:i.media.map((ae,ue)=>ae.type==="photo"?d.jsx("img",{className:"tweet-media-img",src:ae.url,alt:"",loading:"lazy"},ue):d.jsx("div",{className:"tweet-media-video-placeholder",children:d.jsx("span",{children:"Video"})},ue))})]}),d.jsxs("div",{className:"tweet-replying-to-inline",children:["Replying to ",d.jsxs("span",{className:"tweet-reply-handle",children:["@",i.author.username]})]})]})]})}),Le()]}),ie&&d.jsxs(d.Fragment,{children:[Le(),d.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[l&&d.jsx(C0,{}),c&&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})]}),i&&d.jsx(OD,{tweet:i,url:t==null?void 0:t.url})]}),d.jsx("div",{className:"tweet-quote-footer",children:xe()})]}),!J&&Le(),z&&d.jsx(jD,{onConnected:Be,onCancel:()=>H(!1)})]})}function BD(){const[t,e]=E.useState("idle"),n=E.useRef();return{copyAsHtml:E.useCallback(async()=>{const s=document.querySelector(".ProseMirror");if(!s)return;const i=s.cloneNode(!0);i.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(h=>h.remove());let l="";const c=document.querySelector(".article-title-input");c!=null&&c.value&&c.value!=="Untitled"&&(l+=`<h1>${c.value}</h1>
|
|
207
|
+
`);const u=l+i.innerHTML,f=zD(i);try{const h=new ClipboardItem({"text/html":new Blob([u],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})});await navigator.clipboard.write([h])}catch{try{await navigator.clipboard.writeText(f)}catch{const h=document.createElement("textarea");h.value=f,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function zD(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(`
|
|
208
|
+
|
|
209
|
+
`)}const Mp="ow-x-handle",A0="ow-x-name",FD=new Set(["Untitled","New Document","Article"]);function $D({src:t,coverImages:e}){const[n,r]=E.useState(t?"display":"empty"),[s,i]=E.useState(t||""),[l,c]=E.useState(e||(t?[t]:[])),[u,f]=E.useState(""),[h,m]=E.useState(""),y=E.useRef(null);E.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),E.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const b=s?l.indexOf(s):-1,v=l.length,w=v>1,k=E.useCallback(z=>{const H=l[z];H&&(i(H),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:H,coverImages:l}})}).catch(()=>{}))},[l]),N=E.useCallback(()=>{b>0&&k(b-1)},[b,k]),C=E.useCallback(()=>{b<v-1&&k(b+1)},[b,v,k]),O=E.useCallback(async()=>{if(u.trim()){r("loading"),m("");try{const H=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(H.success&&H.src){const $=[...l,H.src];c($),i(H.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:H.src,coverImages:$}})}).catch(()=>{})}else m(H.error||"Generation failed"),r("prompt")}catch(z){m(z.message||"Network error"),r("prompt")}}},[u,l]),T=z=>{z.key==="Enter"&&O(),z.key==="Escape"&&(r("empty"),f(""),m(""))},M=()=>{r("prompt"),setTimeout(()=>{var z;return(z=y.current)==null?void 0:z.focus()},0)},R=()=>{const z=l.filter(H=>H!==s);if(c(z),z.length>0){const H=Math.min(b,z.length-1),$=z[H];i($),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:$,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(()=>{})},B=()=>{r("prompt"),setTimeout(()=>{var z;return(z=y.current)==null?void 0:z.focus()},0)},U=()=>{const z=document.createElement("a");z.href=s,z.download=`cover-${b+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:[w&&d.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:N,disabled:b<=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:B,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: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:"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"]})]}),w&&d.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:C,disabled:b>=v-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"})})}),w&&d.jsxs("div",{className:"article-cover-counter",children:[b+1," / ",v]})]})]}):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:y,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"})]})})]}),h&&d.jsx("div",{className:"article-cover-error",children:h})]}):d.jsxs("div",{className:"article-cover article-cover--empty",onClick:M,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 UD(){const[t,e]=E.useState(()=>localStorage.getItem(Mp)||""),[n,r]=E.useState(()=>localStorage.getItem(A0)||""),[s,i]=E.useState(!1),[l,c]=E.useState(""),u=E.useRef(null),f=E.useRef(null),h=()=>{const v=l.replace(/^@/,"").trim();v&&(localStorage.setItem(Mp,v),e(v)),i(!1)},m=()=>{c(t),i(!0),setTimeout(()=>{var v;return(v=u.current)==null?void 0:v.focus()},0)};E.useEffect(()=>{if(!s)return;const v=w=>{f.current&&!f.current.contains(w.target)&&h()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s,l]),E.useEffect(()=>{const v=()=>{e(localStorage.getItem(Mp)||""),r(localStorage.getItem(A0)||"")};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]);const y=t?`https://unavatar.io/twitter/${t}`:"",b=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:y,alt:`@${t}`}):d.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),d.jsx("span",{className:"article-byline-name",children:b}),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:l,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&h(),v.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function HD({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s}){const{copyAsHtml:i,copyState:l}=BD();return d.jsxs("div",{className:"article-compose-wrapper",children:[d.jsx($D,{src:r,coverImages:s}),d.jsxs("div",{className:"article-compose-content",children:[d.jsx("input",{className:"article-title-input",type:"text",value:FD.has(e||"")?"":e||"",onChange:c=>n==null?void 0:n(c.target.value||"Untitled"),placeholder:"Add a title",spellCheck:!1}),d.jsx(UD,{}),d.jsx("div",{className:"article-compose-body",children:t})]}),d.jsx("div",{className:"article-compose-footer",children:d.jsx("button",{className:`article-copy-btn${l==="copied"?" article-copy-btn--copied":""}`,onClick:i,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"]})})})]})}const O0={font:"sans",width:"standard",spacing:"comfortable"},R0=new Set(["Untitled","New Document","Blog"]);function WD(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function I0(){return new Date().toISOString().split("T")[0]}function Hs(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function VD({src:t,coverImages:e}){const[n,r]=E.useState(t?"display":"empty"),[s,i]=E.useState(t||""),[l,c]=E.useState(e||(t?[t]:[])),[u,f]=E.useState(""),[h,m]=E.useState(""),y=E.useRef(null);E.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),E.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const b=s?l.indexOf(s):-1,v=l.length,w=v>1,k=E.useCallback(z=>{const H=l[z];H&&(i(H),Hs({coverImage:H,coverImages:l}))},[l]),N=E.useCallback(()=>{b>0&&k(b-1)},[b,k]),C=E.useCallback(()=>{b<v-1&&k(b+1)},[b,v,k]),O=E.useCallback(async()=>{if(u.trim()){r("loading"),m("");try{const H=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(H.success&&H.src){const $=[...l,H.src];c($),i(H.src),r("display"),f(""),Hs({coverImage:H.src,coverImages:$})}else m(H.error||"Generation failed"),r("prompt")}catch(z){m(z.message||"Network error"),r("prompt")}}},[u,l]),T=z=>{z.key==="Enter"&&O(),z.key==="Escape"&&(r("empty"),f(""),m(""))},M=()=>{r("prompt"),setTimeout(()=>{var z;return(z=y.current)==null?void 0:z.focus()},0)},R=()=>{const z=l.filter(H=>H!==s);if(c(z),z.length>0){const H=Math.min(b,z.length-1),$=z[H];i($),Hs({coverImage:$,coverImages:z})}else i(""),r("empty"),Hs({coverImage:void 0,coverImages:void 0})},B=()=>{r("prompt"),setTimeout(()=>{var z;return(z=y.current)==null?void 0:z.focus()},0)},U=()=>{const z=document.createElement("a");z.href=s,z.download=`cover-${b+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:[w&&d.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:N,disabled:b<=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:B,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: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:"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"]})]}),w&&d.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:C,disabled:b>=v-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"})})}),w&&d.jsxs("div",{className:"blog-cover-counter",children:[b+1," / ",v]})]})]}):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:y,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"})]})})]}),h&&d.jsx("div",{className:"blog-cover-error",children:h})]}):d.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:M,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 KD({tags:t,onChange:e}){const[n,r]=E.useState(""),s=E.useRef(null),i=u=>{const f=u.trim().toLowerCase();f&&!t.includes(f)&&e([...t,f]),r("")},l=u=>e(t.filter(f=>f!==u)),c=u=>{(u.key==="Enter"||u.key===",")&&(u.preventDefault(),i(n)),u.key==="Backspace"&&!n&&t.length>0&&l(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(),l(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:c,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function GD({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 qD({children:t,title:e,onTitleChange:n,blogContext:r,filename:s}){const i=r||{},[l,c]=E.useState(i.description||""),[u,f]=E.useState(!1),[h,m]=E.useState(i.date||I0()),[y,b]=E.useState(i.tags||[]),[v,w]=E.useState(i.author||""),[k,N]=E.useState(i.slug||""),[C,O]=E.useState(i.draft??!1),[T,M]=E.useState({...O0,...i.style}),[R,B]=E.useState(!1),[U,z]=E.useState(!!i.slug);E.useEffect(()=>{!U&&e&&!R0.has(e)&&N(WD(e))},[e,U]),E.useEffect(()=>{c(i.description||""),m(i.date||I0()),b(i.tags||[]),w(i.author||""),N(i.slug||""),O(i.draft??!1),M({...O0,...i.style}),z(!!i.slug)},[r]);const H=!!(r!=null&&r.active),$=E.useCallback(()=>{H&&Hs({description:l,date:h,tags:y,author:v,slug:k,draft:C,style:T})},[H,l,h,y,v,k,C,T]);E.useEffect(()=>{H&&Hs({tags:y})},[H,y]),E.useEffect(()=>{H&&Hs({style:T})},[H,T]),E.useEffect(()=>{H&&Hs({draft:C})},[H,C]);const L=l.length,Y=L>160,Q=["blog-compose-wrapper",`blog--font-${T.font}`,`blog--width-${T.width}`,`blog--spacing-${T.spacing}`].join(" ");return d.jsxs("div",{className:Q,children:[d.jsx(VD,{src:i.coverImage,coverImages:i.coverImages}),d.jsxs("div",{className:"blog-compose-content",children:[d.jsx("input",{className:"blog-title-input",type:"text",value:R0.has(e||"")?"":e||"",onChange:ee=>n==null?void 0:n(ee.target.value||"Untitled"),placeholder:"Post title",spellCheck:!1}),d.jsxs("div",{className:"blog-description-wrap",children:[d.jsx("textarea",{className:`blog-description-input${Y?" over-limit":""}`,value:l,onChange:ee=>c(ee.target.value),onBlur:$,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),d.jsxs("span",{className:`blog-description-count${Y?" over-limit":""}`,children:[L,"/160"]})]}),d.jsxs("div",{className:"blog-meta-toggle",onClick:()=>B(ee=>!ee),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"}),C&&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:h,onChange:ee=>m(ee.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:v,onChange:ee=>w(ee.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:k,onChange:ee=>{z(!0),N(ee.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(KD,{tags:y,onChange:b})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Draft"}),d.jsx("button",{className:`blog-draft-toggle${C?" active":""}`,onClick:()=>O(ee=>!ee),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(GD,{style:T,onChange:M}),s&&d.jsx("div",{className:"blog-footer-actions",children: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(wm,{filename:s,title:e||"Untitled",onClose:()=>f(!1)})]})}function j0(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function JD({children:t,newsletterContext:e,filename:n,title:r,onBeforeSend:s}){var U;const i=e||{},[l,c]=E.useState(i.subject||""),[u,f]=E.useState(i.previewText||""),[h,m]=E.useState([]),[y,b]=E.useState(null),[v,w]=E.useState(!1),[k,N]=E.useState((U=i.lastSend)!=null&&U.sentAt?{sentCount:i.lastSend.sentCount,issueId:i.lastSend.issueId||null,sentAt:i.lastSend.sentAt}:null);E.useEffect(()=>{var z;c(i.subject||""),f(i.previewText||""),(z=i.lastSend)!=null&&z.sentAt&&N({sentCount:i.lastSend.sentCount,issueId:i.lastSend.issueId||null,sentAt:i.lastSend.sentAt})},[e]),E.useEffect(()=>{fetch("/api/connections").then(z=>z.json()).then(z=>{const H=(z.connections||[]).filter($=>$.provider==="newsletter"&&$.status==="active");m(H)}).catch(()=>{})},[]);const C=!!(e!=null&&e.active),O=E.useCallback(()=>{C&&j0({subject:l,previewText:u})},[C,l,u]),T=u.length,M=T>=90,R=T>150,B=()=>{h.length===1&&b(h[0].id),h.length>1&&b(h[0].id)};return d.jsxs("div",{className:"nl-compose-wrapper",children:[k&&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(k.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",k.sentCount," subscriber",k.sentCount!==1?"s":""]}),d.jsxs("div",{className:"nl-compose-content",children:[d.jsx("input",{className:"nl-subject-input",type:"text",value:l,onChange:z=>c(z.target.value),onBlur:O,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${R?" over-limit":""}`,value:u,onChange:z=>f(z.target.value),onBlur:O,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),d.jsxs("span",{className:`nl-preview-count${R?" over-limit":M?" full":""}`,children:[T,"/90"]})]}),d.jsx("div",{className:"nl-compose-body",children:t})]}),n&&d.jsxs("div",{className:"nl-compose-footer",children:[h.length>0&&d.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:B,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(O1,{connectionId:y,subject:l||r||"Untitled",filename:n,onBeforeSend:s,onClose:z=>{b(null),z&&(N(z),j0({lastSend:{sentCount:z.sentCount,sentAt:z.sentAt,issueId:z.issueId||void 0}}))}}),v&&n&&d.jsx(wm,{filename:n,title:r||"Untitled",onClose:()=>w(!1)})]})}function YD(t){const e=t==null?void 0:t.articleContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function QD(t){const e=t==null?void 0:t.blogContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function XD(t){const e=t==null?void 0:t.newsletterContext;return e!=null&&typeof e=="object"&&(e.active===!0||Object.keys(e).length>0)}function ZD(){var Un,ln;const t=E.useRef(null),e=E.useRef([]),[n,r]=E.useState(null),[s,i]=E.useState([]),[l,c]=E.useState("Untitled"),[u,f]=E.useState(void 0),[h,m]=E.useState(0),[y,b]=E.useState(!0),[v,w]=E.useState(0),[k,N]=E.useState(0),[C,O]=E.useState({filenames:[],counts:{}}),[T,M]=E.useState({state:"unconfigured"}),[R,B]=E.useState(!1),[U,z]=E.useState({}),[H,$]=E.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[L,Y]=E.useState(null),[Q,ee]=E.useState(null),G=E.useRef(0),ne=E.useRef(null),V=1500,X=E.useCallback((oe,ve)=>{ne.current&&(clearTimeout(ne.current),ne.current=null),G.current=Date.now(),Y(oe),ee(ve)},[]),te=E.useCallback(()=>{if(ne.current)return;const oe=Date.now()-G.current,ve=V-oe;ve<=0?(Y(null),ee(null)):ne.current=setTimeout(()=>{ne.current=null,Y(null),ee(null)},ve)},[]),[,A]=E.useState(0),I=E.useRef(null),J=E.useRef(null),re=E.useRef([]),pe=E.useRef(-1),Ne=E.useRef(!1),Re=E.useRef(""),[Be,tt]=E.useState(""),[ce,xe]=E.useState(!1),[ie,Le]=E.useState(!1),ae=YD(U),ue=QD(U),me=XD(U);E.useEffect(()=>(ae?document.documentElement.setAttribute("data-view","article"):ue?document.documentElement.setAttribute("data-view","blog"):me?document.documentElement.setAttribute("data-view","newsletter"):U!=null&&U.tweetContext?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[U==null?void 0:U.tweetContext,ae,ue,me]),E.useEffect(()=>{const oe=()=>A(ve=>ve+1);return window.addEventListener("ow-sidebar-mode-change",oe),()=>window.removeEventListener("ow-sidebar-mode-change",oe)},[]),E.useEffect(()=>{fetch("/api/document").then(oe=>oe.json()).then(oe=>{oe.document&&(f(oe.document),J.current=oe.document),oe.title&&c(oe.title),oe.metadata&&z(oe.metadata)}).catch(()=>{f(void 0)}),fetch("/api/pending-docs").then(oe=>oe.json()).then(oe=>O(oe)).catch(()=>{}),fetch("/api/sync/status").then(oe=>oe.json()).then(oe=>M(oe)).catch(()=>{})},[]);const Ae=E.useCallback(oe=>{t.current=oe,r(oe),e.current=[oe],i([oe])},[]),Ue=E.useCallback(oe=>{e.current=oe,i(oe)},[]),ct=E.useCallback(oe=>{const ve=Re.current==="",Fe=oe.filename===Re.current;if(Re.current=oe.filename,J.current=oe.document,tt(oe.filename),f(oe.document),c(oe.title),z(oe.metadata||{}),!Fe&&!ve&&m(St=>St+1),w(St=>St+1),Ne.current){const St=re.current[pe.current];St&&setTimeout(()=>{const $t=document.querySelector(".editor-container");$t&&($t.scrollTop=St.scrollTop)},50),Ne.current=!1}xe(pe.current>0),Le(pe.current<re.current.length-1)},[]),pt=E.useCallback(()=>{w(oe=>oe+1)},[]),Lt=E.useCallback(()=>{N(oe=>oe+1)},[]),Qn=E.useCallback(oe=>{O(oe)},[]),{connected:yn,sendMessage:lt}=wD({onNodeChanges:oe=>{const ve=e.current;if(ve.length<=1){const Fe=t.current;if(!Fe)return;l0(Fe,oe)}else for(const Fe of ve)l0(Fe,oe)},onDocumentSwitched:ct,onDocumentsChanged:pt,onWorkspacesChanged:Lt,onPendingDocsChanged:Qn,onMetadataChanged:oe=>z(oe),onWritingStarted:(oe,ve)=>X(oe,ve),onWritingFinished:()=>te(),onSyncStatus:oe=>M(oe),onTitleChanged:oe=>c(oe),getEditorState:()=>{var ve;const oe=J.current||((ve=t.current)==null?void 0:ve.getJSON());return oe?{document:oe}:null}}),Ot=E.useCallback(()=>{var ve;I.current&&(clearTimeout(I.current),I.current=null);const oe=J.current||((ve=t.current)==null?void 0:ve.getJSON());oe&<({type:"doc-update",document:oe,filename:Re.current})},[lt]),bn=E.useCallback(async()=>{var ve;const oe=J.current||((ve=t.current)==null?void 0:ve.getJSON());oe&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:oe,filename:Re.current})})},[]);E.useEffect(()=>{const oe=()=>{var $t;I.current&&(clearTimeout(I.current),I.current=null);const Fe=J.current||(($t=t.current)==null?void 0:$t.getJSON());if(!Fe)return;const St=JSON.stringify({type:"flush",document:Fe});navigator.sendBeacon("/api/flush",new Blob([St],{type:"application/json"}))},ve=()=>{document.visibilityState==="hidden"&&oe()};return window.addEventListener("beforeunload",oe),document.addEventListener("visibilitychange",ve),()=>{window.removeEventListener("beforeunload",oe),document.removeEventListener("visibilitychange",ve)}},[]);const qt=E.useCallback(()=>{Ot(),lt({type:"create-document"})},[Ot,lt]),Jt=E.useCallback(oe=>{const ve=document.querySelector(".editor-container"),Fe=(ve==null?void 0:ve.scrollTop)||0;!Ne.current&&Re.current&&(re.current=re.current.slice(0,pe.current+1),re.current.push({filename:Re.current,scrollTop:Fe}),pe.current=re.current.length-1),Ot(),lt({type:"switch-document",filename:oe})},[Ot,lt]),Xn=E.useCallback(()=>{if(pe.current<=0)return;const oe=document.querySelector(".editor-container"),ve=(oe==null?void 0:oe.scrollTop)||0;pe.current===re.current.length-1&&Re.current?(re.current=re.current.slice(0,pe.current+1),re.current.push({filename:Re.current,scrollTop:ve})):Re.current&&(re.current[pe.current+1]={filename:Re.current,scrollTop:ve});const Fe=re.current[pe.current];pe.current--,Ne.current=!0,xe(pe.current>0),Le(!0),Ot(),lt({type:"switch-document",filename:Fe.filename})},[Ot,lt]),Z=E.useCallback(()=>{if(pe.current>=re.current.length-2)return;const oe=document.querySelector(".editor-container"),ve=(oe==null?void 0:oe.scrollTop)||0;Re.current&&(re.current[pe.current+1]={filename:Re.current,scrollTop:ve}),pe.current++;const Fe=re.current[pe.current+1];Ne.current=!0,xe(!0),Le(pe.current<re.current.length-2),Ot(),lt({type:"switch-document",filename:Fe.filename})},[Ot,lt]),Ge=E.useCallback(()=>{const oe=Re.current,ve=t.current;!oe||!ve||fetch(`/api/marks/${encodeURIComponent(oe)}`).then(Fe=>Fe.json()).then(Fe=>{t0(Fe.marks||[]),i0(ve.view)}).catch(()=>{t0([]),ve!=null&&ve.view&&i0(ve.view)})},[]);E.useEffect(()=>{Ge()},[Be,Ge]),E.useEffect(()=>{const oe=ve=>{const Fe=ve.detail;(Fe==null?void 0:Fe.filename)===Re.current&&Ge()};return window.addEventListener("ow-marks-changed",oe),()=>window.removeEventListener("ow-marks-changed",oe)},[Ge]),E.useEffect(()=>{const oe=ve=>{ve.altKey&&ve.key==="ArrowLeft"&&(ve.preventDefault(),Xn()),ve.altKey&&ve.key==="ArrowRight"&&(ve.preventDefault(),Z())};return window.addEventListener("keydown",oe),()=>window.removeEventListener("keydown",oe)},[Xn,Z]);const He=E.useCallback(oe=>{J.current=oe,I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{lt({type:"doc-update",document:oe,filename:Re.current})},1e3)},[lt]),kt=E.useCallback(oe=>{c(oe),lt({type:"title-update",title:oe})},[lt]),Ze=E.useCallback(()=>{$(oe=>(localStorage.setItem("ow-toolbar",oe?"hidden":"visible"),!oe))},[]),nt=E.useCallback(()=>{if(T.state==="unconfigured"){B(!0);return}Ot(),lt({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[T.state,Ot,lt]),qe=zu()==="board";return d.jsxs("div",{className:"app",children:[!qe&&d.jsx(k0,{open:y,onSwitchDocument:Jt,onCreateDocument:qt,refreshKey:v,workspacesRefreshKey:k,pendingDocs:C,writingTitle:L,writingTarget:Q,onClose:()=>b(!1)}),d.jsxs("div",{className:"app-main",children:[d.jsx(NL,{title:l,onTitleChange:kt,syncStatus:T,onSync:nt,onToggleSidebar:!qe&&!y?()=>b(!0):void 0,canGoBack:ce,canGoForward:ie,onGoBack:Xn,onGoForward:Z,editor:n,onToggleToolbar:Ze,toolbarOpen:H}),H&&n&&d.jsx(aL,{editor:n}),qe&&d.jsx(k0,{open:!0,onSwitchDocument:Jt,onCreateDocument:qt,refreshKey:v,workspacesRefreshKey:k,pendingDocs:C,writingTitle:L,writingTarget:Q}),!yn&&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:ae?d.jsx(HD,{title:l,onTitleChange:kt,coverImage:(Un=U==null?void 0:U.articleContext)==null?void 0:Un.coverImage,coverImages:(ln=U==null?void 0:U.articleContext)==null?void 0:ln.coverImages,children:d.jsx(Mc,{initialContent:u,extensions:Xj,onUpdate:He,onReady:Ae,onLinkClick:Jt},h)}):ue?d.jsx(qD,{title:l,onTitleChange:kt,blogContext:U==null?void 0:U.blogContext,filename:Be,children:d.jsx(Mc,{initialContent:u,onUpdate:He,onReady:Ae,onLinkClick:Jt},h)}):me?d.jsx(JD,{newsletterContext:U==null?void 0:U.newsletterContext,filename:Be,title:l,onBeforeSend:bn,children:d.jsx(Mc,{initialContent:u,onUpdate:He,onReady:Ae,onLinkClick:Jt},h)}):U!=null&&U.tweetContext?d.jsx(PD,{tweetContext:U.tweetContext,initialContent:u,onUpdate:He,onEditorReady:Ae,onEditorsChange:Ue},h):d.jsx(Mc,{initialContent:u,onUpdate:He,onReady:Ae,onLinkClick:Jt},h)}),d.jsx(JL,{editors:s,pendingDocs:C,currentFilename:Be,onSwitchDocument:Jt,sendMessage:lt,getDocument:()=>J.current})]}),d.jsx(IL,{editorRef:t,allEditors:s,documentId:Be}),R&&d.jsx(xD,{onClose:()=>B(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(oe=>oe.json()).then(M).catch(()=>{})}})]})}NE();xE.createRoot(document.getElementById("root")).render(d.jsx(qs.StrictMode,{children:d.jsx(ZD,{})}));
|