openwriter 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/index-02FEqxwZ.js +210 -0
- package/dist/client/assets/index-D9laiJ2-.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/plugins/x-api/dist/index.js +4 -2
- package/dist/plugins/x-api/package.json +2 -1
- package/dist/server/compact.js +39 -1
- package/dist/server/mcp.js +279 -207
- package/dist/server/state.js +74 -18
- package/dist/server/ws.js +12 -2
- package/package.json +4 -2
- package/skill/SKILL.md +14 -4
- package/dist/client/assets/index-BhlEJsdX.css +0 -1
- package/dist/client/assets/index-XajWsVLO.js +0 -210
|
@@ -1,210 +0,0 @@
|
|
|
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 zu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $f={exports:{}},pl={},Ff={exports:{}},ft={};/**
|
|
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 Uy;function gE(){if(Uy)return ft;Uy=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"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=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,L,te){this.props=A,this.context=L,this.refs=w,this.updater=te||b}k.prototype.isReactComponent={},k.prototype.setState=function(A,L){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,L,"setState")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function N(){}N.prototype=k.prototype;function C(A,L,te){this.props=A,this.context=L,this.refs=w,this.updater=te||b}var O=C.prototype=new N;O.constructor=C,v(O,k.prototype),O.isPureReactComponent=!0;var T=Array.isArray,_=Object.prototype.hasOwnProperty,R={current:null},D={key:!0,ref:!0,__self:!0,__source:!0};function z(A,L,te){var oe,he={},ne=null,ge=null;if(L!=null)for(oe in L.ref!==void 0&&(ge=L.ref),L.key!==void 0&&(ne=""+L.key),L)_.call(L,oe)&&!D.hasOwnProperty(oe)&&(he[oe]=L[oe]);var De=arguments.length-2;if(De===1)he.children=te;else if(1<De){for(var ot=Array(De),ce=0;ce<De;ce++)ot[ce]=arguments[ce+2];he.children=ot}if(A&&A.defaultProps)for(oe in De=A.defaultProps,De)he[oe]===void 0&&(he[oe]=De[oe]);return{$$typeof:t,type:A,key:ne,ref:ge,props:he,_owner:R.current}}function $(A,L){return{$$typeof:t,type:A.type,key:L,ref:A.ref,props:A.props,_owner:A._owner}}function U(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function Y(A){var L={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(te){return L[te]})}var X=/\/+/g;function J(A,L){return typeof A=="object"&&A!==null&&A.key!=null?Y(""+A.key):L.toString(36)}function q(A,L,te,oe,he){var ne=typeof A;(ne==="undefined"||ne==="boolean")&&(A=null);var ge=!1;if(A===null)ge=!0;else switch(ne){case"string":case"number":ge=!0;break;case"object":switch(A.$$typeof){case t:case e:ge=!0}}if(ge)return ge=A,he=he(ge),A=oe===""?"."+J(ge,0):oe,T(he)?(te="",A!=null&&(te=A.replace(X,"$&/")+"/"),q(he,L,te,"",function(ce){return ce})):he!=null&&(U(he)&&(he=$(he,te+(!he.key||ge&&ge.key===he.key?"":(""+he.key).replace(X,"$&/")+"/")+A)),L.push(he)),1;if(ge=0,oe=oe===""?".":oe+":",T(A))for(var De=0;De<A.length;De++){ne=A[De];var ot=oe+J(ne,De);ge+=q(ne,L,te,ot,he)}else if(ot=y(A),typeof ot=="function")for(A=ot.call(A),De=0;!(ne=A.next()).done;)ne=ne.value,ot=oe+J(ne,De++),ge+=q(ne,L,te,ot,he);else if(ne==="object")throw L=String(A),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.");return ge}function H(A,L,te){if(A==null)return A;var oe=[],he=0;return q(A,oe,"","",function(ne){return L.call(te,ne,he++)}),oe}function W(A){if(A._status===-1){var L=A._result;L=L(),L.then(function(te){(A._status===0||A._status===-1)&&(A._status=1,A._result=te)},function(te){(A._status===0||A._status===-1)&&(A._status=2,A._result=te)}),A._status===-1&&(A._status=0,A._result=L)}if(A._status===1)return A._result.default;throw A._result}var re={current:null},V={transition:null},K={ReactCurrentDispatcher:re,ReactCurrentBatchConfig:V,ReactCurrentOwner:R};function B(){throw Error("act(...) is not supported in production builds of React.")}return ft.Children={map:H,forEach:function(A,L,te){H(A,function(){L.apply(this,arguments)},te)},count:function(A){var L=0;return H(A,function(){L++}),L},toArray:function(A){return H(A,function(L){return L})||[]},only:function(A){if(!U(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},ft.Component=k,ft.Fragment=n,ft.Profiler=s,ft.PureComponent=C,ft.StrictMode=r,ft.Suspense=d,ft.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=K,ft.act=B,ft.cloneElement=function(A,L,te){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var oe=v({},A.props),he=A.key,ne=A.ref,ge=A._owner;if(L!=null){if(L.ref!==void 0&&(ne=L.ref,ge=R.current),L.key!==void 0&&(he=""+L.key),A.type&&A.type.defaultProps)var De=A.type.defaultProps;for(ot in L)_.call(L,ot)&&!D.hasOwnProperty(ot)&&(oe[ot]=L[ot]===void 0&&De!==void 0?De[ot]:L[ot])}var ot=arguments.length-2;if(ot===1)oe.children=te;else if(1<ot){De=Array(ot);for(var ce=0;ce<ot;ce++)De[ce]=arguments[ce+2];oe.children=De}return{$$typeof:t,type:A.type,key:he,ref:ne,props:oe,_owner:ge}},ft.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},ft.createElement=z,ft.createFactory=function(A){var L=z.bind(null,A);return L.type=A,L},ft.createRef=function(){return{current:null}},ft.forwardRef=function(A){return{$$typeof:c,render:A}},ft.isValidElement=U,ft.lazy=function(A){return{$$typeof:p,_payload:{_status:-1,_result:A},_init:W}},ft.memo=function(A,L){return{$$typeof:f,type:A,compare:L===void 0?null:L}},ft.startTransition=function(A){var L=V.transition;V.transition={};try{A()}finally{V.transition=L}},ft.unstable_act=B,ft.useCallback=function(A,L){return re.current.useCallback(A,L)},ft.useContext=function(A){return re.current.useContext(A)},ft.useDebugValue=function(){},ft.useDeferredValue=function(A){return re.current.useDeferredValue(A)},ft.useEffect=function(A,L){return re.current.useEffect(A,L)},ft.useId=function(){return re.current.useId()},ft.useImperativeHandle=function(A,L,te){return re.current.useImperativeHandle(A,L,te)},ft.useInsertionEffect=function(A,L){return re.current.useInsertionEffect(A,L)},ft.useLayoutEffect=function(A,L){return re.current.useLayoutEffect(A,L)},ft.useMemo=function(A,L){return re.current.useMemo(A,L)},ft.useReducer=function(A,L,te){return re.current.useReducer(A,L,te)},ft.useRef=function(A){return re.current.useRef(A)},ft.useState=function(A){return re.current.useState(A)},ft.useSyncExternalStore=function(A,L,te){return re.current.useSyncExternalStore(A,L,te)},ft.useTransition=function(){return re.current.useTransition()},ft.version="18.3.1",ft}var Hy;function Gl(){return Hy||(Hy=1,Ff.exports=gE()),Ff.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 Wy;function yE(){if(Wy)return pl;Wy=1;var t=Gl(),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,d,f){var p,m={},y=null,b=null;f!==void 0&&(y=""+f),d.key!==void 0&&(y=""+d.key),d.ref!==void 0&&(b=d.ref);for(p in d)r.call(d,p)&&!i.hasOwnProperty(p)&&(m[p]=d[p]);if(c&&c.defaultProps)for(p in d=c.defaultProps,d)m[p]===void 0&&(m[p]=d[p]);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 Vy;function bE(){return Vy||(Vy=1,$f.exports=yE()),$f.exports}var u=bE(),S=Gl();const Js=zu(S);var oc={},Uf={exports:{}},Jn={},Hf={exports:{}},Wf={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/var Ky;function vE(){return Ky||(Ky=1,(function(t){function e(V,K){var B=V.length;V.push(K);e:for(;0<B;){var A=B-1>>>1,L=V[A];if(0<s(L,K))V[A]=K,V[B]=L,B=A;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var K=V[0],B=V.pop();if(B!==K){V[0]=B;e:for(var A=0,L=V.length,te=L>>>1;A<te;){var oe=2*(A+1)-1,he=V[oe],ne=oe+1,ge=V[ne];if(0>s(he,B))ne<L&&0>s(ge,he)?(V[A]=ge,V[ne]=B,A=ne):(V[A]=he,V[oe]=B,A=oe);else if(ne<L&&0>s(ge,B))V[A]=ge,V[ne]=B,A=ne;else break e}}return K}function s(V,K){var B=V.sortIndex-K.sortIndex;return B!==0?B:V.id-K.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 d=[],f=[],p=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 K=n(f);K!==null;){if(K.callback===null)r(f);else if(K.startTime<=V)r(f),K.sortIndex=K.expirationTime,e(d,K);else break;K=n(f)}}function T(V){if(w=!1,O(V),!v)if(n(d)!==null)v=!0,W(_);else{var K=n(f);K!==null&&re(T,K.startTime-V)}}function _(V,K){v=!1,w&&(w=!1,N(z),z=-1),b=!0;var B=y;try{for(O(K),m=n(d);m!==null&&(!(m.expirationTime>K)||V&&!Y());){var A=m.callback;if(typeof A=="function"){m.callback=null,y=m.priorityLevel;var L=A(m.expirationTime<=K);K=t.unstable_now(),typeof L=="function"?m.callback=L:m===n(d)&&r(d),O(K)}else r(d);m=n(d)}if(m!==null)var te=!0;else{var oe=n(f);oe!==null&&re(T,oe.startTime-K),te=!1}return te}finally{m=null,y=B,b=!1}}var R=!1,D=null,z=-1,$=5,U=-1;function Y(){return!(t.unstable_now()-U<$)}function X(){if(D!==null){var V=t.unstable_now();U=V;var K=!0;try{K=D(!0,V)}finally{K?J():(R=!1,D=null)}}else R=!1}var J;if(typeof C=="function")J=function(){C(X)};else if(typeof MessageChannel<"u"){var q=new MessageChannel,H=q.port2;q.port1.onmessage=X,J=function(){H.postMessage(null)}}else J=function(){k(X,0)};function W(V){D=V,R||(R=!0,J())}function re(V,K){z=k(function(){V(t.unstable_now())},K)}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,W(_))},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"):$=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_getFirstCallbackNode=function(){return n(d)},t.unstable_next=function(V){switch(y){case 1:case 2:case 3:var K=3;break;default:K=y}var B=y;y=K;try{return V()}finally{y=B}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(V,K){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var B=y;y=V;try{return K()}finally{y=B}},t.unstable_scheduleCallback=function(V,K,B){var A=t.unstable_now();switch(typeof B=="object"&&B!==null?(B=B.delay,B=typeof B=="number"&&0<B?A+B:A):B=A,V){case 1:var L=-1;break;case 2:L=250;break;case 5:L=1073741823;break;case 4:L=1e4;break;default:L=5e3}return L=B+L,V={id:p++,callback:K,priorityLevel:V,startTime:B,expirationTime:L,sortIndex:-1},B>A?(V.sortIndex=B,e(f,V),n(d)===null&&V===n(f)&&(w?(N(z),z=-1):w=!0,re(T,B-A))):(V.sortIndex=L,e(d,V),v||b||(v=!0,W(_))),V},t.unstable_shouldYield=Y,t.unstable_wrapCallback=function(V){var K=y;return function(){var B=y;y=K;try{return V.apply(this,arguments)}finally{y=B}}}})(Wf)),Wf}var Gy;function xE(){return Gy||(Gy=1,Hf.exports=vE()),Hf.exports}/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var qy;function wE(){if(qy)return Jn;qy=1;var t=Gl(),e=xE();function n(o){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+o,h=1;h<arguments.length;h++)a+="&args[]="+encodeURIComponent(arguments[h]);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"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function y(o){return d.call(m,o)?!0:d.call(p,o)?!1:f.test(o)?m[o]=!0:(p[o]=!0,!1)}function b(o,a,h,g){if(h!==null&&h.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return g?!1:h!==null?!h.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,a,h,g){if(a===null||typeof a>"u"||b(o,a,h,g))return!0;if(g)return!1;if(h!==null)switch(h.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,h,g,x,E,M){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=g,this.attributeNamespace=x,this.mustUseProperty=h,this.propertyName=o,this.type=a,this.sanitizeURL=E,this.removeEmptyString=M}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,h,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,h,x,g)&&(h=null),g||x===null?y(a)&&(h===null?o.removeAttribute(a):o.setAttribute(a,""+h)):x.mustUseProperty?o[x.propertyName]=h===null?x.type===3?!1:"":h:(a=x.attributeName,g=x.attributeNamespace,h===null?o.removeAttribute(a):(x=x.type,h=x===3||x===4&&h===!0?"":""+h,g?o.setAttributeNS(g,a,h):o.setAttribute(a,h))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),R=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),Y=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),re=Symbol.for("react.offscreen"),V=Symbol.iterator;function K(o){return o===null||typeof o!="object"?null:(o=V&&o[V]||o["@@iterator"],typeof o=="function"?o:null)}var B=Object.assign,A;function L(o){if(A===void 0)try{throw Error()}catch(h){var a=h.stack.trim().match(/\n( *(at )?)/);A=a&&a[1]||""}return`
|
|
34
|
-
`+A+o}var te=!1;function oe(o,a){if(!o||te)return"";te=!0;var h=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(ee){var g=ee}Reflect.construct(o,[],a)}else{try{a.call()}catch(ee){g=ee}o.call(a.prototype)}else{try{throw Error()}catch(ee){g=ee}o()}}catch(ee){if(ee&&g&&typeof ee.stack=="string"){for(var x=ee.stack.split(`
|
|
35
|
-
`),E=g.stack.split(`
|
|
36
|
-
`),M=x.length-1,j=E.length-1;1<=M&&0<=j&&x[M]!==E[j];)j--;for(;1<=M&&0<=j;M--,j--)if(x[M]!==E[j]){if(M!==1||j!==1)do if(M--,j--,0>j||x[M]!==E[j]){var P=`
|
|
37
|
-
`+x[M].replace(" at new "," at ");return o.displayName&&P.includes("<anonymous>")&&(P=P.replace("<anonymous>",o.displayName)),P}while(1<=M&&0<=j);break}}}finally{te=!1,Error.prepareStackTrace=h}return(o=o?o.displayName||o.name:"")?L(o):""}function he(o){switch(o.tag){case 5:return L(o.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return o=oe(o.type,!1),o;case 11:return o=oe(o.type.render,!1),o;case 1:return o=oe(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 D:return"Fragment";case R:return"Portal";case $:return"Profiler";case z:return"StrictMode";case J:return"Suspense";case q:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case Y:return(o.displayName||"Context")+".Consumer";case U:return(o._context.displayName||"Context")+".Provider";case X:var a=o.render;return o=o.displayName,o||(o=a.displayName||a.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case H:return a=o.displayName||null,a!==null?a:ne(o.type)||"Memo";case W:a=o._payload,o=o._init;try{return ne(o(a))}catch{}}return null}function ge(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===z?"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 De(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function ot(o){var a=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function ce(o){var a=ot(o)?"checked":"value",h=Object.getOwnPropertyDescriptor(o.constructor.prototype,a),g=""+o[a];if(!o.hasOwnProperty(a)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var x=h.get,E=h.set;return Object.defineProperty(o,a,{configurable:!0,get:function(){return x.call(this)},set:function(M){g=""+M,E.call(this,M)}}),Object.defineProperty(o,a,{enumerable:h.enumerable}),{getValue:function(){return g},setValue:function(M){g=""+M},stopTracking:function(){o._valueTracker=null,delete o[a]}}}}function pe(o){o._valueTracker||(o._valueTracker=ce(o))}function se(o){if(!o)return!1;var a=o._valueTracker;if(!a)return!0;var h=a.getValue(),g="";return o&&(g=ot(o)?o.checked?"true":"false":o.value),o=g,o!==h?(a.setValue(o),!0):!1}function Pe(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 Oe(o,a){var h=a.checked;return B({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??o._wrapperState.initialChecked})}function Je(o,a){var h=a.defaultValue==null?"":a.defaultValue,g=a.checked!=null?a.checked:a.defaultChecked;h=De(a.value!=null?a.value:h),o._wrapperState={initialChecked:g,initialValue:h,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ne(o,a){a=a.checked,a!=null&&O(o,"checked",a,!1)}function et(o,a){Ne(o,a);var h=De(a.value),g=a.type;if(h!=null)g==="number"?(h===0&&o.value===""||o.value!=h)&&(o.value=""+h):o.value!==""+h&&(o.value=""+h);else if(g==="submit"||g==="reset"){o.removeAttribute("value");return}a.hasOwnProperty("value")?He(o,a.type,h):a.hasOwnProperty("defaultValue")&&He(o,a.type,De(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(o.defaultChecked=!!a.defaultChecked)}function Le(o,a,h){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,h||a===o.value||(o.value=a),o.defaultValue=a}h=o.name,h!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,h!==""&&(o.name=h)}function He(o,a,h){(a!=="number"||Pe(o.ownerDocument)!==o)&&(h==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+h&&(o.defaultValue=""+h))}var ke=Array.isArray;function fe(o,a,h,g){if(o=o.options,a){a={};for(var x=0;x<h.length;x++)a["$"+h[x]]=!0;for(h=0;h<o.length;h++)x=a.hasOwnProperty("$"+o[h].value),o[h].selected!==x&&(o[h].selected=x),x&&g&&(o[h].defaultSelected=!0)}else{for(h=""+De(h),a=null,x=0;x<o.length;x++){if(o[x].value===h){o[x].selected=!0,g&&(o[x].defaultSelected=!0);return}a!==null||o[x].disabled||(a=o[x])}a!==null&&(a.selected=!0)}}function qe(o,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return B({},a,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function at(o,a){var h=a.value;if(h==null){if(h=a.children,a=a.defaultValue,h!=null){if(a!=null)throw Error(n(92));if(ke(h)){if(1<h.length)throw Error(n(93));h=h[0]}a=h}a==null&&(a=""),h=a}o._wrapperState={initialValue:De(h)}}function it(o,a){var h=De(a.value),g=De(a.defaultValue);h!=null&&(h=""+h,h!==o.value&&(o.value=h),a.defaultValue==null&&o.defaultValue!==h&&(o.defaultValue=h)),g!=null&&(o.defaultValue=""+g)}function mt(o){var a=o.textContent;a===o._wrapperState.initialValue&&a!==""&&a!==null&&(o.value=a)}function $t(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 Lt(o,a){return o==null||o==="http://www.w3.org/1999/xhtml"?$t(a):o==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Z,We=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,h,g,x){MSApp.execUnsafeLocalFunction(function(){return o(a,h,g,x)})}:o})(function(o,a){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=a;else{for(Z=Z||document.createElement("div"),Z.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=Z.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;a.firstChild;)o.appendChild(a.firstChild)}});function Fe(o,a){if(a){var h=o.firstChild;if(h&&h===o.lastChild&&h.nodeType===3){h.nodeValue=a;return}}o.textContent=a}var xt={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},tt=["Webkit","ms","Moz","O"];Object.keys(xt).forEach(function(o){tt.forEach(function(a){a=a+o.charAt(0).toUpperCase()+o.substring(1),xt[a]=xt[o]})});function Xe(o,a,h){return a==null||typeof a=="boolean"||a===""?"":h||typeof a!="number"||a===0||xt.hasOwnProperty(o)&&xt[o]?(""+a).trim():a+"px"}function nt(o,a){o=o.style;for(var h in a)if(a.hasOwnProperty(h)){var g=h.indexOf("--")===0,x=Xe(h,a[h],g);h==="float"&&(h="cssFloat"),g?o.setProperty(h,x):o[h]=x}}var Dn=B({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 ln(o,a){if(a){if(Dn[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 ir(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 ct=null;function vn(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var le=null,Ee=null,lt=null;function Dt(o){if(o=Zo(o)){if(typeof le!="function")throw Error(n(280));var a=o.stateNode;a&&(a=wa(a),le(o.stateNode,o.type,a))}}function I(o){Ee?lt?lt.push(o):lt=[o]:Ee=o}function ie(){if(Ee){var o=Ee,a=lt;if(lt=Ee=null,Dt(o),a)for(o=0;o<a.length;o++)Dt(a[o])}}function xe(o,a){return o(a)}function Ye(){}var Ct=!1;function Tt(o,a,h){if(Ct)return o(a,h);Ct=!0;try{return xe(o,a,h)}finally{Ct=!1,(Ee!==null||lt!==null)&&(Ye(),ie())}}function Te(o,a){var h=o.stateNode;if(h===null)return null;var g=wa(h);if(g===null)return null;h=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(h&&typeof h!="function")throw Error(n(231,a,typeof h));return h}var _e=!1;if(c)try{var Ve={};Object.defineProperty(Ve,"passive",{get:function(){_e=!0}}),window.addEventListener("test",Ve,Ve),window.removeEventListener("test",Ve,Ve)}catch{_e=!1}function nn(o,a,h,g,x,E,M,j,P){var ee=Array.prototype.slice.call(arguments,3);try{a.apply(h,ee)}catch(de){this.onError(de)}}var Ot=!1,Rr=null,ps=!1,ni=null,id={onError:function(o){Ot=!0,Rr=o}};function jo(o,a,h,g,x,E,M,j,P){Ot=!1,Rr=null,nn.apply(id,arguments)}function od(o,a,h,g,x,E,M,j,P){if(jo.apply(this,arguments),Ot){if(Ot){var ee=Rr;Ot=!1,Rr=null}else throw Error(n(198));ps||(ps=!0,ni=ee)}}function Kr(o){var a=o,h=o;if(o.alternate)for(;a.return;)a=a.return;else{o=a;do a=o,(a.flags&4098)!==0&&(h=a.return),o=a.return;while(o)}return a.tag===3?h:null}function Zl(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 $i(o){var a=o.alternate;if(!a){if(a=Kr(o),a===null)throw Error(n(188));return a!==o?null:o}for(var h=o,g=a;;){var x=h.return;if(x===null)break;var E=x.alternate;if(E===null){if(g=x.return,g!==null){h=g;continue}break}if(x.child===E.child){for(E=x.child;E;){if(E===h)return Io(x),o;if(E===g)return Io(x),a;E=E.sibling}throw Error(n(188))}if(h.return!==g.return)h=x,g=E;else{for(var M=!1,j=x.child;j;){if(j===h){M=!0,h=x,g=E;break}if(j===g){M=!0,g=x,h=E;break}j=j.sibling}if(!M){for(j=E.child;j;){if(j===h){M=!0,h=E,g=x;break}if(j===g){M=!0,g=E,h=x;break}j=j.sibling}if(!M)throw Error(n(189))}}if(h.alternate!==g)throw Error(n(190))}if(h.tag!==3)throw Error(n(188));return h.stateNode.current===h?o:a}function ea(o){return o=$i(o),o!==null?ta(o):null}function ta(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var a=ta(o);if(a!==null)return a;o=o.sibling}return null}var na=e.unstable_scheduleCallback,vr=e.unstable_cancelCallback,ra=e.unstable_shouldYield,sa=e.unstable_requestPaint,Ut=e.unstable_now,ld=e.unstable_getCurrentPriorityLevel,Lo=e.unstable_ImmediatePriority,ri=e.unstable_UserBlockingPriority,Fi=e.unstable_NormalPriority,be=e.unstable_LowPriority,Be=e.unstable_IdlePriority,ut=null,ht=null;function Xt(o){if(ht&&typeof ht.onCommitFiberRoot=="function")try{ht.onCommitFiberRoot(ut,o,void 0,(o.current.flags&128)===128)}catch{}}var Ht=Math.clz32?Math.clz32:Pn,jr=Math.log,Ui=Math.LN2;function Pn(o){return o>>>=0,o===0?32:31-(jr(o)/Ui|0)|0}var Bn=64,si=4194304;function ms(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 ii(o,a){var h=o.pendingLanes;if(h===0)return 0;var g=0,x=o.suspendedLanes,E=o.pingedLanes,M=h&268435455;if(M!==0){var j=M&~x;j!==0?g=ms(j):(E&=M,E!==0&&(g=ms(E)))}else M=h&~x,M!==0?g=ms(M):E!==0&&(g=ms(E));if(g===0)return 0;if(a!==0&&a!==g&&(a&x)===0&&(x=g&-g,E=a&-a,x>=E||x===16&&(E&4194240)!==0))return a;if((g&4)!==0&&(g|=h&16),a=o.entangledLanes,a!==0)for(o=o.entanglements,a&=g;0<a;)h=31-Ht(a),x=1<<h,g|=o[h],a&=~x;return g}function ad(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 cd(o,a){for(var h=o.suspendedLanes,g=o.pingedLanes,x=o.expirationTimes,E=o.pendingLanes;0<E;){var M=31-Ht(E),j=1<<M,P=x[M];P===-1?((j&h)===0||(j&g)!==0)&&(x[M]=ad(j,a)):P<=a&&(o.expiredLanes|=j),E&=~j}}function Do(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function ia(){var o=Bn;return Bn<<=1,(Bn&4194240)===0&&(Bn=64),o}function gs(o){for(var a=[],h=0;31>h;h++)a.push(o);return a}function ys(o,a,h){o.pendingLanes|=a,a!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,a=31-Ht(a),o[a]=h}function or(o,a){var h=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<h;){var x=31-Ht(h),E=1<<x;a[x]=0,g[x]=-1,o[x]=-1,h&=~E}}function Po(o,a){var h=o.entangledLanes|=a;for(o=o.entanglements;h;){var g=31-Ht(h),x=1<<g;x&a|o[g]&a&&(o[g]|=a),h&=~x}}var gt=0;function st(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Bo,Zt,Nt,oi,Ir,li=!1,bs=[],we=null,Me=null,Ze=null,pt=new Map,Kt=new Map,dn=[],ud="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 oa(o,a){switch(o){case"focusin":case"focusout":we=null;break;case"dragenter":case"dragleave":Me=null;break;case"mouseover":case"mouseout":Ze=null;break;case"pointerover":case"pointerout":pt.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Kt.delete(a.pointerId)}}function zo(o,a,h,g,x,E){return o===null||o.nativeEvent!==E?(o={blockedOn:a,domEventName:h,eventSystemFlags:g,nativeEvent:E,targetContainers:[x]},a!==null&&(a=Zo(a),a!==null&&Zt(a)),o):(o.eventSystemFlags|=g,a=o.targetContainers,x!==null&&a.indexOf(x)===-1&&a.push(x),o)}function z1(o,a,h,g,x){switch(a){case"focusin":return we=zo(we,o,a,h,g,x),!0;case"dragenter":return Me=zo(Me,o,a,h,g,x),!0;case"mouseover":return Ze=zo(Ze,o,a,h,g,x),!0;case"pointerover":var E=x.pointerId;return pt.set(E,zo(pt.get(E)||null,o,a,h,g,x)),!0;case"gotpointercapture":return E=x.pointerId,Kt.set(E,zo(Kt.get(E)||null,o,a,h,g,x)),!0}return!1}function Cm(o){var a=ai(o.target);if(a!==null){var h=Kr(a);if(h!==null){if(a=h.tag,a===13){if(a=Zl(h),a!==null){o.blockedOn=a,Ir(o.priority,function(){Nt(h)});return}}else if(a===3&&h.stateNode.current.memoizedState.isDehydrated){o.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}o.blockedOn=null}function la(o){if(o.blockedOn!==null)return!1;for(var a=o.targetContainers;0<a.length;){var h=fd(o.domEventName,o.eventSystemFlags,a[0],o.nativeEvent);if(h===null){h=o.nativeEvent;var g=new h.constructor(h.type,h);ct=g,h.target.dispatchEvent(g),ct=null}else return a=Zo(h),a!==null&&Zt(a),o.blockedOn=h,!1;a.shift()}return!0}function _m(o,a,h){la(o)&&h.delete(a)}function $1(){li=!1,we!==null&&la(we)&&(we=null),Me!==null&&la(Me)&&(Me=null),Ze!==null&&la(Ze)&&(Ze=null),pt.forEach(_m),Kt.forEach(_m)}function $o(o,a){o.blockedOn===a&&(o.blockedOn=null,li||(li=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,$1)))}function Fo(o){function a(x){return $o(x,o)}if(0<bs.length){$o(bs[0],o);for(var h=1;h<bs.length;h++){var g=bs[h];g.blockedOn===o&&(g.blockedOn=null)}}for(we!==null&&$o(we,o),Me!==null&&$o(Me,o),Ze!==null&&$o(Ze,o),pt.forEach(a),Kt.forEach(a),h=0;h<dn.length;h++)g=dn[h],g.blockedOn===o&&(g.blockedOn=null);for(;0<dn.length&&(h=dn[0],h.blockedOn===null);)Cm(h),h.blockedOn===null&&dn.shift()}var Hi=T.ReactCurrentBatchConfig,aa=!0;function F1(o,a,h,g){var x=gt,E=Hi.transition;Hi.transition=null;try{gt=1,dd(o,a,h,g)}finally{gt=x,Hi.transition=E}}function U1(o,a,h,g){var x=gt,E=Hi.transition;Hi.transition=null;try{gt=4,dd(o,a,h,g)}finally{gt=x,Hi.transition=E}}function dd(o,a,h,g){if(aa){var x=fd(o,a,h,g);if(x===null)Md(o,a,g,ca,h),oa(o,g);else if(z1(x,o,a,h,g))g.stopPropagation();else if(oa(o,g),a&4&&-1<ud.indexOf(o)){for(;x!==null;){var E=Zo(x);if(E!==null&&Bo(E),E=fd(o,a,h,g),E===null&&Md(o,a,g,ca,h),E===x)break;x=E}x!==null&&g.stopPropagation()}else Md(o,a,g,null,h)}}var ca=null;function fd(o,a,h,g){if(ca=null,o=vn(g),o=ai(o),o!==null)if(a=Kr(o),a===null)o=null;else if(h=a.tag,h===13){if(o=Zl(a),o!==null)return o;o=null}else if(h===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;o=null}else a!==o&&(o=null);return ca=o,null}function Tm(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(ld()){case Lo:return 1;case ri:return 4;case Fi:case be:return 16;case Be:return 536870912;default:return 16}default:return 16}}var vs=null,hd=null,ua=null;function Mm(){if(ua)return ua;var o,a=hd,h=a.length,g,x="value"in vs?vs.value:vs.textContent,E=x.length;for(o=0;o<h&&a[o]===x[o];o++);var M=h-o;for(g=1;g<=M&&a[h-g]===x[E-g];g++);return ua=x.slice(o,1<g?1-g:void 0)}function da(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 fa(){return!0}function Am(){return!1}function Xn(o){function a(h,g,x,E,M){this._reactName=h,this._targetInst=x,this.type=g,this.nativeEvent=E,this.target=M,this.currentTarget=null;for(var j in o)o.hasOwnProperty(j)&&(h=o[j],this[j]=h?h(E):E[j]);return this.isDefaultPrevented=(E.defaultPrevented!=null?E.defaultPrevented:E.returnValue===!1)?fa:Am,this.isPropagationStopped=Am,this}return B(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=fa)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=fa)},persist:function(){},isPersistent:fa}),a}var Wi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},pd=Xn(Wi),Uo=B({},Wi,{view:0,detail:0}),H1=Xn(Uo),md,gd,Ho,ha=B({},Uo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:bd,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!==Ho&&(Ho&&o.type==="mousemove"?(md=o.screenX-Ho.screenX,gd=o.screenY-Ho.screenY):gd=md=0,Ho=o),md)},movementY:function(o){return"movementY"in o?o.movementY:gd}}),Om=Xn(ha),W1=B({},ha,{dataTransfer:0}),V1=Xn(W1),K1=B({},Uo,{relatedTarget:0}),yd=Xn(K1),G1=B({},Wi,{animationName:0,elapsedTime:0,pseudoElement:0}),q1=Xn(G1),J1=B({},Wi,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),Y1=Xn(J1),Q1=B({},Wi,{data:0}),Rm=Xn(Q1),X1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Z1={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"},eS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function tS(o){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(o):(o=eS[o])?!!a[o]:!1}function bd(){return tS}var nS=B({},Uo,{key:function(o){if(o.key){var a=X1[o.key]||o.key;if(a!=="Unidentified")return a}return o.type==="keypress"?(o=da(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?Z1[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:bd,charCode:function(o){return o.type==="keypress"?da(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?da(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),rS=Xn(nS),sS=B({},ha,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),jm=Xn(sS),iS=B({},Uo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:bd}),oS=Xn(iS),lS=B({},Wi,{propertyName:0,elapsedTime:0,pseudoElement:0}),aS=Xn(lS),cS=B({},ha,{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}),uS=Xn(cS),dS=[9,13,27,32],vd=c&&"CompositionEvent"in window,Wo=null;c&&"documentMode"in document&&(Wo=document.documentMode);var fS=c&&"TextEvent"in window&&!Wo,Im=c&&(!vd||Wo&&8<Wo&&11>=Wo),Lm=" ",Dm=!1;function Pm(o,a){switch(o){case"keyup":return dS.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bm(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Vi=!1;function hS(o,a){switch(o){case"compositionend":return Bm(a);case"keypress":return a.which!==32?null:(Dm=!0,Lm);case"textInput":return o=a.data,o===Lm&&Dm?null:o;default:return null}}function pS(o,a){if(Vi)return o==="compositionend"||!vd&&Pm(o,a)?(o=Mm(),ua=hd=vs=null,Vi=!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 Im&&a.locale!=="ko"?null:a.data;default:return null}}var mS={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 zm(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a==="input"?!!mS[o.type]:a==="textarea"}function $m(o,a,h,g){I(g),a=ba(a,"onChange"),0<a.length&&(h=new pd("onChange","change",null,h,g),o.push({event:h,listeners:a}))}var Vo=null,Ko=null;function gS(o){sg(o,0)}function pa(o){var a=Yi(o);if(se(a))return o}function yS(o,a){if(o==="change")return a}var Fm=!1;if(c){var xd;if(c){var wd="oninput"in document;if(!wd){var Um=document.createElement("div");Um.setAttribute("oninput","return;"),wd=typeof Um.oninput=="function"}xd=wd}else xd=!1;Fm=xd&&(!document.documentMode||9<document.documentMode)}function Hm(){Vo&&(Vo.detachEvent("onpropertychange",Wm),Ko=Vo=null)}function Wm(o){if(o.propertyName==="value"&&pa(Ko)){var a=[];$m(a,Ko,o,vn(o)),Tt(gS,a)}}function bS(o,a,h){o==="focusin"?(Hm(),Vo=a,Ko=h,Vo.attachEvent("onpropertychange",Wm)):o==="focusout"&&Hm()}function vS(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return pa(Ko)}function xS(o,a){if(o==="click")return pa(a)}function wS(o,a){if(o==="input"||o==="change")return pa(a)}function kS(o,a){return o===a&&(o!==0||1/o===1/a)||o!==o&&a!==a}var xr=typeof Object.is=="function"?Object.is:kS;function Go(o,a){if(xr(o,a))return!0;if(typeof o!="object"||o===null||typeof a!="object"||a===null)return!1;var h=Object.keys(o),g=Object.keys(a);if(h.length!==g.length)return!1;for(g=0;g<h.length;g++){var x=h[g];if(!d.call(a,x)||!xr(o[x],a[x]))return!1}return!0}function Vm(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Km(o,a){var h=Vm(o);o=0;for(var g;h;){if(h.nodeType===3){if(g=o+h.textContent.length,o<=a&&g>=a)return{node:h,offset:a-o};o=g}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Vm(h)}}function Gm(o,a){return o&&a?o===a?!0:o&&o.nodeType===3?!1:a&&a.nodeType===3?Gm(o,a.parentNode):"contains"in o?o.contains(a):o.compareDocumentPosition?!!(o.compareDocumentPosition(a)&16):!1:!1}function qm(){for(var o=window,a=Pe();a instanceof o.HTMLIFrameElement;){try{var h=typeof a.contentWindow.location.href=="string"}catch{h=!1}if(h)o=a.contentWindow;else break;a=Pe(o.document)}return a}function kd(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 SS(o){var a=qm(),h=o.focusedElem,g=o.selectionRange;if(a!==h&&h&&h.ownerDocument&&Gm(h.ownerDocument.documentElement,h)){if(g!==null&&kd(h)){if(a=g.start,o=g.end,o===void 0&&(o=a),"selectionStart"in h)h.selectionStart=a,h.selectionEnd=Math.min(o,h.value.length);else if(o=(a=h.ownerDocument||document)&&a.defaultView||window,o.getSelection){o=o.getSelection();var x=h.textContent.length,E=Math.min(g.start,x);g=g.end===void 0?E:Math.min(g.end,x),!o.extend&&E>g&&(x=g,g=E,E=x),x=Km(h,E);var M=Km(h,g);x&&M&&(o.rangeCount!==1||o.anchorNode!==x.node||o.anchorOffset!==x.offset||o.focusNode!==M.node||o.focusOffset!==M.offset)&&(a=a.createRange(),a.setStart(x.node,x.offset),o.removeAllRanges(),E>g?(o.addRange(a),o.extend(M.node,M.offset)):(a.setEnd(M.node,M.offset),o.addRange(a)))}}for(a=[],o=h;o=o.parentNode;)o.nodeType===1&&a.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<a.length;h++)o=a[h],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var ES=c&&"documentMode"in document&&11>=document.documentMode,Ki=null,Sd=null,qo=null,Ed=!1;function Jm(o,a,h){var g=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Ed||Ki==null||Ki!==Pe(g)||(g=Ki,"selectionStart"in g&&kd(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}),qo&&Go(qo,g)||(qo=g,g=ba(Sd,"onSelect"),0<g.length&&(a=new pd("onSelect","select",null,a,h),o.push({event:a,listeners:g}),a.target=Ki)))}function ma(o,a){var h={};return h[o.toLowerCase()]=a.toLowerCase(),h["Webkit"+o]="webkit"+a,h["Moz"+o]="moz"+a,h}var Gi={animationend:ma("Animation","AnimationEnd"),animationiteration:ma("Animation","AnimationIteration"),animationstart:ma("Animation","AnimationStart"),transitionend:ma("Transition","TransitionEnd")},Nd={},Ym={};c&&(Ym=document.createElement("div").style,"AnimationEvent"in window||(delete Gi.animationend.animation,delete Gi.animationiteration.animation,delete Gi.animationstart.animation),"TransitionEvent"in window||delete Gi.transitionend.transition);function ga(o){if(Nd[o])return Nd[o];if(!Gi[o])return o;var a=Gi[o],h;for(h in a)if(a.hasOwnProperty(h)&&h in Ym)return Nd[o]=a[h];return o}var Qm=ga("animationend"),Xm=ga("animationiteration"),Zm=ga("animationstart"),eg=ga("transitionend"),tg=new Map,ng="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 xs(o,a){tg.set(o,a),i(a,[o])}for(var Cd=0;Cd<ng.length;Cd++){var _d=ng[Cd],NS=_d.toLowerCase(),CS=_d[0].toUpperCase()+_d.slice(1);xs(NS,"on"+CS)}xs(Qm,"onAnimationEnd"),xs(Xm,"onAnimationIteration"),xs(Zm,"onAnimationStart"),xs("dblclick","onDoubleClick"),xs("focusin","onFocus"),xs("focusout","onBlur"),xs(eg,"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 Jo="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(" "),_S=new Set("cancel close invalid load scroll toggle".split(" ").concat(Jo));function rg(o,a,h){var g=o.type||"unknown-event";o.currentTarget=h,od(g,a,void 0,o),o.currentTarget=null}function sg(o,a){a=(a&4)!==0;for(var h=0;h<o.length;h++){var g=o[h],x=g.event;g=g.listeners;e:{var E=void 0;if(a)for(var M=g.length-1;0<=M;M--){var j=g[M],P=j.instance,ee=j.currentTarget;if(j=j.listener,P!==E&&x.isPropagationStopped())break e;rg(x,j,ee),E=P}else for(M=0;M<g.length;M++){if(j=g[M],P=j.instance,ee=j.currentTarget,j=j.listener,P!==E&&x.isPropagationStopped())break e;rg(x,j,ee),E=P}}}if(ps)throw o=ni,ps=!1,ni=null,o}function Pt(o,a){var h=a[Ld];h===void 0&&(h=a[Ld]=new Set);var g=o+"__bubble";h.has(g)||(ig(a,o,2,!1),h.add(g))}function Td(o,a,h){var g=0;a&&(g|=4),ig(h,o,g,a)}var ya="_reactListening"+Math.random().toString(36).slice(2);function Yo(o){if(!o[ya]){o[ya]=!0,r.forEach(function(h){h!=="selectionchange"&&(_S.has(h)||Td(h,!1,o),Td(h,!0,o))});var a=o.nodeType===9?o:o.ownerDocument;a===null||a[ya]||(a[ya]=!0,Td("selectionchange",!1,a))}}function ig(o,a,h,g){switch(Tm(a)){case 1:var x=F1;break;case 4:x=U1;break;default:x=dd}h=x.bind(null,a,h,o),x=void 0,!_e||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(x=!0),g?x!==void 0?o.addEventListener(a,h,{capture:!0,passive:x}):o.addEventListener(a,h,!0):x!==void 0?o.addEventListener(a,h,{passive:x}):o.addEventListener(a,h,!1)}function Md(o,a,h,g,x){var E=g;if((a&1)===0&&(a&2)===0&&g!==null)e:for(;;){if(g===null)return;var M=g.tag;if(M===3||M===4){var j=g.stateNode.containerInfo;if(j===x||j.nodeType===8&&j.parentNode===x)break;if(M===4)for(M=g.return;M!==null;){var P=M.tag;if((P===3||P===4)&&(P=M.stateNode.containerInfo,P===x||P.nodeType===8&&P.parentNode===x))return;M=M.return}for(;j!==null;){if(M=ai(j),M===null)return;if(P=M.tag,P===5||P===6){g=E=M;continue e}j=j.parentNode}}g=g.return}Tt(function(){var ee=E,de=vn(h),me=[];e:{var ue=tg.get(o);if(ue!==void 0){var Ce=pd,Re=o;switch(o){case"keypress":if(da(h)===0)break e;case"keydown":case"keyup":Ce=rS;break;case"focusin":Re="focus",Ce=yd;break;case"focusout":Re="blur",Ce=yd;break;case"beforeblur":case"afterblur":Ce=yd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ce=Om;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ce=V1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ce=oS;break;case Qm:case Xm:case Zm:Ce=q1;break;case eg:Ce=aS;break;case"scroll":Ce=H1;break;case"wheel":Ce=uS;break;case"copy":case"cut":case"paste":Ce=Y1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ce=jm}var je=(a&4)!==0,en=!je&&o==="scroll",G=je?ue!==null?ue+"Capture":null:ue;je=[];for(var F=ee,Q;F!==null;){Q=F;var ve=Q.stateNode;if(Q.tag===5&&ve!==null&&(Q=ve,G!==null&&(ve=Te(F,G),ve!=null&&je.push(Qo(F,ve,Q)))),en)break;F=F.return}0<je.length&&(ue=new Ce(ue,Re,null,h,de),me.push({event:ue,listeners:je}))}}if((a&7)===0){e:{if(ue=o==="mouseover"||o==="pointerover",Ce=o==="mouseout"||o==="pointerout",ue&&h!==ct&&(Re=h.relatedTarget||h.fromElement)&&(ai(Re)||Re[Gr]))break e;if((Ce||ue)&&(ue=de.window===de?de:(ue=de.ownerDocument)?ue.defaultView||ue.parentWindow:window,Ce?(Re=h.relatedTarget||h.toElement,Ce=ee,Re=Re?ai(Re):null,Re!==null&&(en=Kr(Re),Re!==en||Re.tag!==5&&Re.tag!==6)&&(Re=null)):(Ce=null,Re=ee),Ce!==Re)){if(je=Om,ve="onMouseLeave",G="onMouseEnter",F="mouse",(o==="pointerout"||o==="pointerover")&&(je=jm,ve="onPointerLeave",G="onPointerEnter",F="pointer"),en=Ce==null?ue:Yi(Ce),Q=Re==null?ue:Yi(Re),ue=new je(ve,F+"leave",Ce,h,de),ue.target=en,ue.relatedTarget=Q,ve=null,ai(de)===ee&&(je=new je(G,F+"enter",Re,h,de),je.target=Q,je.relatedTarget=en,ve=je),en=ve,Ce&&Re)t:{for(je=Ce,G=Re,F=0,Q=je;Q;Q=qi(Q))F++;for(Q=0,ve=G;ve;ve=qi(ve))Q++;for(;0<F-Q;)je=qi(je),F--;for(;0<Q-F;)G=qi(G),Q--;for(;F--;){if(je===G||G!==null&&je===G.alternate)break t;je=qi(je),G=qi(G)}je=null}else je=null;Ce!==null&&og(me,ue,Ce,je,!1),Re!==null&&en!==null&&og(me,en,Re,je,!0)}}e:{if(ue=ee?Yi(ee):window,Ce=ue.nodeName&&ue.nodeName.toLowerCase(),Ce==="select"||Ce==="input"&&ue.type==="file")var Ie=yS;else if(zm(ue))if(Fm)Ie=wS;else{Ie=vS;var Ke=bS}else(Ce=ue.nodeName)&&Ce.toLowerCase()==="input"&&(ue.type==="checkbox"||ue.type==="radio")&&(Ie=xS);if(Ie&&(Ie=Ie(o,ee))){$m(me,Ie,h,de);break e}Ke&&Ke(o,ue,ee),o==="focusout"&&(Ke=ue._wrapperState)&&Ke.controlled&&ue.type==="number"&&He(ue,"number",ue.value)}switch(Ke=ee?Yi(ee):window,o){case"focusin":(zm(Ke)||Ke.contentEditable==="true")&&(Ki=Ke,Sd=ee,qo=null);break;case"focusout":qo=Sd=Ki=null;break;case"mousedown":Ed=!0;break;case"contextmenu":case"mouseup":case"dragend":Ed=!1,Jm(me,h,de);break;case"selectionchange":if(ES)break;case"keydown":case"keyup":Jm(me,h,de)}var Ge;if(vd)e:{switch(o){case"compositionstart":var rt="onCompositionStart";break e;case"compositionend":rt="onCompositionEnd";break e;case"compositionupdate":rt="onCompositionUpdate";break e}rt=void 0}else Vi?Pm(o,h)&&(rt="onCompositionEnd"):o==="keydown"&&h.keyCode===229&&(rt="onCompositionStart");rt&&(Im&&h.locale!=="ko"&&(Vi||rt!=="onCompositionStart"?rt==="onCompositionEnd"&&Vi&&(Ge=Mm()):(vs=de,hd="value"in vs?vs.value:vs.textContent,Vi=!0)),Ke=ba(ee,rt),0<Ke.length&&(rt=new Rm(rt,o,null,h,de),me.push({event:rt,listeners:Ke}),Ge?rt.data=Ge:(Ge=Bm(h),Ge!==null&&(rt.data=Ge)))),(Ge=fS?hS(o,h):pS(o,h))&&(ee=ba(ee,"onBeforeInput"),0<ee.length&&(de=new Rm("onBeforeInput","beforeinput",null,h,de),me.push({event:de,listeners:ee}),de.data=Ge))}sg(me,a)})}function Qo(o,a,h){return{instance:o,listener:a,currentTarget:h}}function ba(o,a){for(var h=a+"Capture",g=[];o!==null;){var x=o,E=x.stateNode;x.tag===5&&E!==null&&(x=E,E=Te(o,h),E!=null&&g.unshift(Qo(o,E,x)),E=Te(o,a),E!=null&&g.push(Qo(o,E,x))),o=o.return}return g}function qi(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function og(o,a,h,g,x){for(var E=a._reactName,M=[];h!==null&&h!==g;){var j=h,P=j.alternate,ee=j.stateNode;if(P!==null&&P===g)break;j.tag===5&&ee!==null&&(j=ee,x?(P=Te(h,E),P!=null&&M.unshift(Qo(h,P,j))):x||(P=Te(h,E),P!=null&&M.push(Qo(h,P,j)))),h=h.return}M.length!==0&&o.push({event:a,listeners:M})}var TS=/\r\n?/g,MS=/\u0000|\uFFFD/g;function lg(o){return(typeof o=="string"?o:""+o).replace(TS,`
|
|
38
|
-
`).replace(MS,"")}function va(o,a,h){if(a=lg(a),lg(o)!==a&&h)throw Error(n(425))}function xa(){}var Ad=null,Od=null;function Rd(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 jd=typeof setTimeout=="function"?setTimeout:void 0,AS=typeof clearTimeout=="function"?clearTimeout:void 0,ag=typeof Promise=="function"?Promise:void 0,OS=typeof queueMicrotask=="function"?queueMicrotask:typeof ag<"u"?function(o){return ag.resolve(null).then(o).catch(RS)}:jd;function RS(o){setTimeout(function(){throw o})}function Id(o,a){var h=a,g=0;do{var x=h.nextSibling;if(o.removeChild(h),x&&x.nodeType===8)if(h=x.data,h==="/$"){if(g===0){o.removeChild(x),Fo(a);return}g--}else h!=="$"&&h!=="$?"&&h!=="$!"||g++;h=x}while(h);Fo(a)}function ws(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 cg(o){o=o.previousSibling;for(var a=0;o;){if(o.nodeType===8){var h=o.data;if(h==="$"||h==="$!"||h==="$?"){if(a===0)return o;a--}else h==="/$"&&a++}o=o.previousSibling}return null}var Ji=Math.random().toString(36).slice(2),Lr="__reactFiber$"+Ji,Xo="__reactProps$"+Ji,Gr="__reactContainer$"+Ji,Ld="__reactEvents$"+Ji,jS="__reactListeners$"+Ji,IS="__reactHandles$"+Ji;function ai(o){var a=o[Lr];if(a)return a;for(var h=o.parentNode;h;){if(a=h[Gr]||h[Lr]){if(h=a.alternate,a.child!==null||h!==null&&h.child!==null)for(o=cg(o);o!==null;){if(h=o[Lr])return h;o=cg(o)}return a}o=h,h=o.parentNode}return null}function Zo(o){return o=o[Lr]||o[Gr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function Yi(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(n(33))}function wa(o){return o[Xo]||null}var Dd=[],Qi=-1;function ks(o){return{current:o}}function Bt(o){0>Qi||(o.current=Dd[Qi],Dd[Qi]=null,Qi--)}function Rt(o,a){Qi++,Dd[Qi]=o.current,o.current=a}var Ss={},Tn=ks(Ss),Wn=ks(!1),ci=Ss;function Xi(o,a){var h=o.type.contextTypes;if(!h)return Ss;var g=o.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===a)return g.__reactInternalMemoizedMaskedChildContext;var x={},E;for(E in h)x[E]=a[E];return g&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=a,o.__reactInternalMemoizedMaskedChildContext=x),x}function Vn(o){return o=o.childContextTypes,o!=null}function ka(){Bt(Wn),Bt(Tn)}function ug(o,a,h){if(Tn.current!==Ss)throw Error(n(168));Rt(Tn,a),Rt(Wn,h)}function dg(o,a,h){var g=o.stateNode;if(a=a.childContextTypes,typeof g.getChildContext!="function")return h;g=g.getChildContext();for(var x in g)if(!(x in a))throw Error(n(108,ge(o)||"Unknown",x));return B({},h,g)}function Sa(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||Ss,ci=Tn.current,Rt(Tn,o),Rt(Wn,Wn.current),!0}function fg(o,a,h){var g=o.stateNode;if(!g)throw Error(n(169));h?(o=dg(o,a,ci),g.__reactInternalMemoizedMergedChildContext=o,Bt(Wn),Bt(Tn),Rt(Tn,o)):Bt(Wn),Rt(Wn,h)}var qr=null,Ea=!1,Pd=!1;function hg(o){qr===null?qr=[o]:qr.push(o)}function LS(o){Ea=!0,hg(o)}function Es(){if(!Pd&&qr!==null){Pd=!0;var o=0,a=gt;try{var h=qr;for(gt=1;o<h.length;o++){var g=h[o];do g=g(!0);while(g!==null)}qr=null,Ea=!1}catch(x){throw qr!==null&&(qr=qr.slice(o+1)),na(Lo,Es),x}finally{gt=a,Pd=!1}}return null}var Zi=[],eo=0,Na=null,Ca=0,lr=[],ar=0,ui=null,Jr=1,Yr="";function di(o,a){Zi[eo++]=Ca,Zi[eo++]=Na,Na=o,Ca=a}function pg(o,a,h){lr[ar++]=Jr,lr[ar++]=Yr,lr[ar++]=ui,ui=o;var g=Jr;o=Yr;var x=32-Ht(g)-1;g&=~(1<<x),h+=1;var E=32-Ht(a)+x;if(30<E){var M=x-x%5;E=(g&(1<<M)-1).toString(32),g>>=M,x-=M,Jr=1<<32-Ht(a)+x|h<<x|g,Yr=E+o}else Jr=1<<E|h<<x|g,Yr=o}function Bd(o){o.return!==null&&(di(o,1),pg(o,1,0))}function zd(o){for(;o===Na;)Na=Zi[--eo],Zi[eo]=null,Ca=Zi[--eo],Zi[eo]=null;for(;o===ui;)ui=lr[--ar],lr[ar]=null,Yr=lr[--ar],lr[ar]=null,Jr=lr[--ar],lr[ar]=null}var Zn=null,er=null,Ft=!1,wr=null;function mg(o,a){var h=fr(5,null,null,0);h.elementType="DELETED",h.stateNode=a,h.return=o,a=o.deletions,a===null?(o.deletions=[h],o.flags|=16):a.push(h)}function gg(o,a){switch(o.tag){case 5:var h=o.type;return a=a.nodeType!==1||h.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(o.stateNode=a,Zn=o,er=ws(a.firstChild),!0):!1;case 6:return a=o.pendingProps===""||a.nodeType!==3?null:a,a!==null?(o.stateNode=a,Zn=o,er=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(h=ui!==null?{id:Jr,overflow:Yr}:null,o.memoizedState={dehydrated:a,treeContext:h,retryLane:1073741824},h=fr(18,null,null,0),h.stateNode=a,h.return=o,o.child=h,Zn=o,er=null,!0):!1;default:return!1}}function $d(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Fd(o){if(Ft){var a=er;if(a){var h=a;if(!gg(o,a)){if($d(o))throw Error(n(418));a=ws(h.nextSibling);var g=Zn;a&&gg(o,a)?mg(g,h):(o.flags=o.flags&-4097|2,Ft=!1,Zn=o)}}else{if($d(o))throw Error(n(418));o.flags=o.flags&-4097|2,Ft=!1,Zn=o}}}function yg(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;Zn=o}function _a(o){if(o!==Zn)return!1;if(!Ft)return yg(o),Ft=!0,!1;var a;if((a=o.tag!==3)&&!(a=o.tag!==5)&&(a=o.type,a=a!=="head"&&a!=="body"&&!Rd(o.type,o.memoizedProps)),a&&(a=er)){if($d(o))throw bg(),Error(n(418));for(;a;)mg(o,a),a=ws(a.nextSibling)}if(yg(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 h=o.data;if(h==="/$"){if(a===0){er=ws(o.nextSibling);break e}a--}else h!=="$"&&h!=="$!"&&h!=="$?"||a++}o=o.nextSibling}er=null}}else er=Zn?ws(o.stateNode.nextSibling):null;return!0}function bg(){for(var o=er;o;)o=ws(o.nextSibling)}function to(){er=Zn=null,Ft=!1}function Ud(o){wr===null?wr=[o]:wr.push(o)}var DS=T.ReactCurrentBatchConfig;function el(o,a,h){if(o=h.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(n(309));var g=h.stateNode}if(!g)throw Error(n(147,o));var x=g,E=""+o;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===E?a.ref:(a=function(M){var j=x.refs;M===null?delete j[E]:j[E]=M},a._stringRef=E,a)}if(typeof o!="string")throw Error(n(284));if(!h._owner)throw Error(n(290,o))}return o}function Ta(o,a){throw o=Object.prototype.toString.call(a),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":o))}function vg(o){var a=o._init;return a(o._payload)}function xg(o){function a(G,F){if(o){var Q=G.deletions;Q===null?(G.deletions=[F],G.flags|=16):Q.push(F)}}function h(G,F){if(!o)return null;for(;F!==null;)a(G,F),F=F.sibling;return null}function g(G,F){for(G=new Map;F!==null;)F.key!==null?G.set(F.key,F):G.set(F.index,F),F=F.sibling;return G}function x(G,F){return G=Rs(G,F),G.index=0,G.sibling=null,G}function E(G,F,Q){return G.index=Q,o?(Q=G.alternate,Q!==null?(Q=Q.index,Q<F?(G.flags|=2,F):Q):(G.flags|=2,F)):(G.flags|=1048576,F)}function M(G){return o&&G.alternate===null&&(G.flags|=2),G}function j(G,F,Q,ve){return F===null||F.tag!==6?(F=If(Q,G.mode,ve),F.return=G,F):(F=x(F,Q),F.return=G,F)}function P(G,F,Q,ve){var Ie=Q.type;return Ie===D?de(G,F,Q.props.children,ve,Q.key):F!==null&&(F.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===W&&vg(Ie)===F.type)?(ve=x(F,Q.props),ve.ref=el(G,F,Q),ve.return=G,ve):(ve=Xa(Q.type,Q.key,Q.props,null,G.mode,ve),ve.ref=el(G,F,Q),ve.return=G,ve)}function ee(G,F,Q,ve){return F===null||F.tag!==4||F.stateNode.containerInfo!==Q.containerInfo||F.stateNode.implementation!==Q.implementation?(F=Lf(Q,G.mode,ve),F.return=G,F):(F=x(F,Q.children||[]),F.return=G,F)}function de(G,F,Q,ve,Ie){return F===null||F.tag!==7?(F=vi(Q,G.mode,ve,Ie),F.return=G,F):(F=x(F,Q),F.return=G,F)}function me(G,F,Q){if(typeof F=="string"&&F!==""||typeof F=="number")return F=If(""+F,G.mode,Q),F.return=G,F;if(typeof F=="object"&&F!==null){switch(F.$$typeof){case _:return Q=Xa(F.type,F.key,F.props,null,G.mode,Q),Q.ref=el(G,null,F),Q.return=G,Q;case R:return F=Lf(F,G.mode,Q),F.return=G,F;case W:var ve=F._init;return me(G,ve(F._payload),Q)}if(ke(F)||K(F))return F=vi(F,G.mode,Q,null),F.return=G,F;Ta(G,F)}return null}function ue(G,F,Q,ve){var Ie=F!==null?F.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number")return Ie!==null?null:j(G,F,""+Q,ve);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case _:return Q.key===Ie?P(G,F,Q,ve):null;case R:return Q.key===Ie?ee(G,F,Q,ve):null;case W:return Ie=Q._init,ue(G,F,Ie(Q._payload),ve)}if(ke(Q)||K(Q))return Ie!==null?null:de(G,F,Q,ve,null);Ta(G,Q)}return null}function Ce(G,F,Q,ve,Ie){if(typeof ve=="string"&&ve!==""||typeof ve=="number")return G=G.get(Q)||null,j(F,G,""+ve,Ie);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case _:return G=G.get(ve.key===null?Q:ve.key)||null,P(F,G,ve,Ie);case R:return G=G.get(ve.key===null?Q:ve.key)||null,ee(F,G,ve,Ie);case W:var Ke=ve._init;return Ce(G,F,Q,Ke(ve._payload),Ie)}if(ke(ve)||K(ve))return G=G.get(Q)||null,de(F,G,ve,Ie,null);Ta(F,ve)}return null}function Re(G,F,Q,ve){for(var Ie=null,Ke=null,Ge=F,rt=F=0,pn=null;Ge!==null&&rt<Q.length;rt++){Ge.index>rt?(pn=Ge,Ge=null):pn=Ge.sibling;var vt=ue(G,Ge,Q[rt],ve);if(vt===null){Ge===null&&(Ge=pn);break}o&&Ge&&vt.alternate===null&&a(G,Ge),F=E(vt,F,rt),Ke===null?Ie=vt:Ke.sibling=vt,Ke=vt,Ge=pn}if(rt===Q.length)return h(G,Ge),Ft&&di(G,rt),Ie;if(Ge===null){for(;rt<Q.length;rt++)Ge=me(G,Q[rt],ve),Ge!==null&&(F=E(Ge,F,rt),Ke===null?Ie=Ge:Ke.sibling=Ge,Ke=Ge);return Ft&&di(G,rt),Ie}for(Ge=g(G,Ge);rt<Q.length;rt++)pn=Ce(Ge,G,rt,Q[rt],ve),pn!==null&&(o&&pn.alternate!==null&&Ge.delete(pn.key===null?rt:pn.key),F=E(pn,F,rt),Ke===null?Ie=pn:Ke.sibling=pn,Ke=pn);return o&&Ge.forEach(function(js){return a(G,js)}),Ft&&di(G,rt),Ie}function je(G,F,Q,ve){var Ie=K(Q);if(typeof Ie!="function")throw Error(n(150));if(Q=Ie.call(Q),Q==null)throw Error(n(151));for(var Ke=Ie=null,Ge=F,rt=F=0,pn=null,vt=Q.next();Ge!==null&&!vt.done;rt++,vt=Q.next()){Ge.index>rt?(pn=Ge,Ge=null):pn=Ge.sibling;var js=ue(G,Ge,vt.value,ve);if(js===null){Ge===null&&(Ge=pn);break}o&&Ge&&js.alternate===null&&a(G,Ge),F=E(js,F,rt),Ke===null?Ie=js:Ke.sibling=js,Ke=js,Ge=pn}if(vt.done)return h(G,Ge),Ft&&di(G,rt),Ie;if(Ge===null){for(;!vt.done;rt++,vt=Q.next())vt=me(G,vt.value,ve),vt!==null&&(F=E(vt,F,rt),Ke===null?Ie=vt:Ke.sibling=vt,Ke=vt);return Ft&&di(G,rt),Ie}for(Ge=g(G,Ge);!vt.done;rt++,vt=Q.next())vt=Ce(Ge,G,rt,vt.value,ve),vt!==null&&(o&&vt.alternate!==null&&Ge.delete(vt.key===null?rt:vt.key),F=E(vt,F,rt),Ke===null?Ie=vt:Ke.sibling=vt,Ke=vt);return o&&Ge.forEach(function(mE){return a(G,mE)}),Ft&&di(G,rt),Ie}function en(G,F,Q,ve){if(typeof Q=="object"&&Q!==null&&Q.type===D&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case _:e:{for(var Ie=Q.key,Ke=F;Ke!==null;){if(Ke.key===Ie){if(Ie=Q.type,Ie===D){if(Ke.tag===7){h(G,Ke.sibling),F=x(Ke,Q.props.children),F.return=G,G=F;break e}}else if(Ke.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===W&&vg(Ie)===Ke.type){h(G,Ke.sibling),F=x(Ke,Q.props),F.ref=el(G,Ke,Q),F.return=G,G=F;break e}h(G,Ke);break}else a(G,Ke);Ke=Ke.sibling}Q.type===D?(F=vi(Q.props.children,G.mode,ve,Q.key),F.return=G,G=F):(ve=Xa(Q.type,Q.key,Q.props,null,G.mode,ve),ve.ref=el(G,F,Q),ve.return=G,G=ve)}return M(G);case R:e:{for(Ke=Q.key;F!==null;){if(F.key===Ke)if(F.tag===4&&F.stateNode.containerInfo===Q.containerInfo&&F.stateNode.implementation===Q.implementation){h(G,F.sibling),F=x(F,Q.children||[]),F.return=G,G=F;break e}else{h(G,F);break}else a(G,F);F=F.sibling}F=Lf(Q,G.mode,ve),F.return=G,G=F}return M(G);case W:return Ke=Q._init,en(G,F,Ke(Q._payload),ve)}if(ke(Q))return Re(G,F,Q,ve);if(K(Q))return je(G,F,Q,ve);Ta(G,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"?(Q=""+Q,F!==null&&F.tag===6?(h(G,F.sibling),F=x(F,Q),F.return=G,G=F):(h(G,F),F=If(Q,G.mode,ve),F.return=G,G=F),M(G)):h(G,F)}return en}var no=xg(!0),wg=xg(!1),Ma=ks(null),Aa=null,ro=null,Hd=null;function Wd(){Hd=ro=Aa=null}function Vd(o){var a=Ma.current;Bt(Ma),o._currentValue=a}function Kd(o,a,h){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===h)break;o=o.return}}function so(o,a){Aa=o,Hd=ro=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&a)!==0&&(Kn=!0),o.firstContext=null)}function cr(o){var a=o._currentValue;if(Hd!==o)if(o={context:o,memoizedValue:a,next:null},ro===null){if(Aa===null)throw Error(n(308));ro=o,Aa.dependencies={lanes:0,firstContext:o}}else ro=ro.next=o;return a}var fi=null;function Gd(o){fi===null?fi=[o]:fi.push(o)}function kg(o,a,h,g){var x=a.interleaved;return x===null?(h.next=h,Gd(a)):(h.next=x.next,x.next=h),a.interleaved=h,Qr(o,g)}function Qr(o,a){o.lanes|=a;var h=o.alternate;for(h!==null&&(h.lanes|=a),h=o,o=o.return;o!==null;)o.childLanes|=a,h=o.alternate,h!==null&&(h.childLanes|=a),h=o,o=o.return;return h.tag===3?h.stateNode:null}var Ns=!1;function qd(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sg(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 Cs(o,a,h){var g=o.updateQueue;if(g===null)return null;if(g=g.shared,(yt&2)!==0){var x=g.pending;return x===null?a.next=a:(a.next=x.next,x.next=a),g.pending=a,Qr(o,h)}return x=g.interleaved,x===null?(a.next=a,Gd(g)):(a.next=x.next,x.next=a),g.interleaved=a,Qr(o,h)}function Oa(o,a,h){if(a=a.updateQueue,a!==null&&(a=a.shared,(h&4194240)!==0)){var g=a.lanes;g&=o.pendingLanes,h|=g,a.lanes=h,Po(o,h)}}function Eg(o,a){var h=o.updateQueue,g=o.alternate;if(g!==null&&(g=g.updateQueue,h===g)){var x=null,E=null;if(h=h.firstBaseUpdate,h!==null){do{var M={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};E===null?x=E=M:E=E.next=M,h=h.next}while(h!==null);E===null?x=E=a:E=E.next=a}else x=E=a;h={baseState:g.baseState,firstBaseUpdate:x,lastBaseUpdate:E,shared:g.shared,effects:g.effects},o.updateQueue=h;return}o=h.lastBaseUpdate,o===null?h.firstBaseUpdate=a:o.next=a,h.lastBaseUpdate=a}function Ra(o,a,h,g){var x=o.updateQueue;Ns=!1;var E=x.firstBaseUpdate,M=x.lastBaseUpdate,j=x.shared.pending;if(j!==null){x.shared.pending=null;var P=j,ee=P.next;P.next=null,M===null?E=ee:M.next=ee,M=P;var de=o.alternate;de!==null&&(de=de.updateQueue,j=de.lastBaseUpdate,j!==M&&(j===null?de.firstBaseUpdate=ee:j.next=ee,de.lastBaseUpdate=P))}if(E!==null){var me=x.baseState;M=0,de=ee=P=null,j=E;do{var ue=j.lane,Ce=j.eventTime;if((g&ue)===ue){de!==null&&(de=de.next={eventTime:Ce,lane:0,tag:j.tag,payload:j.payload,callback:j.callback,next:null});e:{var Re=o,je=j;switch(ue=a,Ce=h,je.tag){case 1:if(Re=je.payload,typeof Re=="function"){me=Re.call(Ce,me,ue);break e}me=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=je.payload,ue=typeof Re=="function"?Re.call(Ce,me,ue):Re,ue==null)break e;me=B({},me,ue);break e;case 2:Ns=!0}}j.callback!==null&&j.lane!==0&&(o.flags|=64,ue=x.effects,ue===null?x.effects=[j]:ue.push(j))}else Ce={eventTime:Ce,lane:ue,tag:j.tag,payload:j.payload,callback:j.callback,next:null},de===null?(ee=de=Ce,P=me):de=de.next=Ce,M|=ue;if(j=j.next,j===null){if(j=x.shared.pending,j===null)break;ue=j,j=ue.next,ue.next=null,x.lastBaseUpdate=ue,x.shared.pending=null}}while(!0);if(de===null&&(P=me),x.baseState=P,x.firstBaseUpdate=ee,x.lastBaseUpdate=de,a=x.shared.interleaved,a!==null){x=a;do M|=x.lane,x=x.next;while(x!==a)}else E===null&&(x.shared.lanes=0);mi|=M,o.lanes=M,o.memoizedState=me}}function Ng(o,a,h){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=h,typeof x!="function")throw Error(n(191,x));x.call(g)}}}var tl={},Dr=ks(tl),nl=ks(tl),rl=ks(tl);function hi(o){if(o===tl)throw Error(n(174));return o}function Jd(o,a){switch(Rt(rl,a),Rt(nl,o),Rt(Dr,tl),o=a.nodeType,o){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:Lt(null,"");break;default:o=o===8?a.parentNode:a,a=o.namespaceURI||null,o=o.tagName,a=Lt(a,o)}Bt(Dr),Rt(Dr,a)}function io(){Bt(Dr),Bt(nl),Bt(rl)}function Cg(o){hi(rl.current);var a=hi(Dr.current),h=Lt(a,o.type);a!==h&&(Rt(nl,o),Rt(Dr,h))}function Yd(o){nl.current===o&&(Bt(Dr),Bt(nl))}var Wt=ks(0);function ja(o){for(var a=o;a!==null;){if(a.tag===13){var h=a.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.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 Qd=[];function Xd(){for(var o=0;o<Qd.length;o++)Qd[o]._workInProgressVersionPrimary=null;Qd.length=0}var Ia=T.ReactCurrentDispatcher,Zd=T.ReactCurrentBatchConfig,pi=0,Vt=null,an=null,fn=null,La=!1,sl=!1,il=0,PS=0;function Mn(){throw Error(n(321))}function ef(o,a){if(a===null)return!1;for(var h=0;h<a.length&&h<o.length;h++)if(!xr(o[h],a[h]))return!1;return!0}function tf(o,a,h,g,x,E){if(pi=E,Vt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Ia.current=o===null||o.memoizedState===null?FS:US,o=h(g,x),sl){E=0;do{if(sl=!1,il=0,25<=E)throw Error(n(301));E+=1,fn=an=null,a.updateQueue=null,Ia.current=HS,o=h(g,x)}while(sl)}if(Ia.current=Ba,a=an!==null&&an.next!==null,pi=0,fn=an=Vt=null,La=!1,a)throw Error(n(300));return o}function nf(){var o=il!==0;return il=0,o}function Pr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fn===null?Vt.memoizedState=fn=o:fn=fn.next=o,fn}function ur(){if(an===null){var o=Vt.alternate;o=o!==null?o.memoizedState:null}else o=an.next;var a=fn===null?Vt.memoizedState:fn.next;if(a!==null)fn=a,an=o;else{if(o===null)throw Error(n(310));an=o,o={memoizedState:an.memoizedState,baseState:an.baseState,baseQueue:an.baseQueue,queue:an.queue,next:null},fn===null?Vt.memoizedState=fn=o:fn=fn.next=o}return fn}function ol(o,a){return typeof a=="function"?a(o):a}function rf(o){var a=ur(),h=a.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=o;var g=an,x=g.baseQueue,E=h.pending;if(E!==null){if(x!==null){var M=x.next;x.next=E.next,E.next=M}g.baseQueue=x=E,h.pending=null}if(x!==null){E=x.next,g=g.baseState;var j=M=null,P=null,ee=E;do{var de=ee.lane;if((pi&de)===de)P!==null&&(P=P.next={lane:0,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null}),g=ee.hasEagerState?ee.eagerState:o(g,ee.action);else{var me={lane:de,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null};P===null?(j=P=me,M=g):P=P.next=me,Vt.lanes|=de,mi|=de}ee=ee.next}while(ee!==null&&ee!==E);P===null?M=g:P.next=j,xr(g,a.memoizedState)||(Kn=!0),a.memoizedState=g,a.baseState=M,a.baseQueue=P,h.lastRenderedState=g}if(o=h.interleaved,o!==null){x=o;do E=x.lane,Vt.lanes|=E,mi|=E,x=x.next;while(x!==o)}else x===null&&(h.lanes=0);return[a.memoizedState,h.dispatch]}function sf(o){var a=ur(),h=a.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=o;var g=h.dispatch,x=h.pending,E=a.memoizedState;if(x!==null){h.pending=null;var M=x=x.next;do E=o(E,M.action),M=M.next;while(M!==x);xr(E,a.memoizedState)||(Kn=!0),a.memoizedState=E,a.baseQueue===null&&(a.baseState=E),h.lastRenderedState=E}return[E,g]}function _g(){}function Tg(o,a){var h=Vt,g=ur(),x=a(),E=!xr(g.memoizedState,x);if(E&&(g.memoizedState=x,Kn=!0),g=g.queue,of(Og.bind(null,h,g,o),[o]),g.getSnapshot!==a||E||fn!==null&&fn.memoizedState.tag&1){if(h.flags|=2048,ll(9,Ag.bind(null,h,g,x,a),void 0,null),hn===null)throw Error(n(349));(pi&30)!==0||Mg(h,a,x)}return x}function Mg(o,a,h){o.flags|=16384,o={getSnapshot:a,value:h},a=Vt.updateQueue,a===null?(a={lastEffect:null,stores:null},Vt.updateQueue=a,a.stores=[o]):(h=a.stores,h===null?a.stores=[o]:h.push(o))}function Ag(o,a,h,g){a.value=h,a.getSnapshot=g,Rg(a)&&jg(o)}function Og(o,a,h){return h(function(){Rg(a)&&jg(o)})}function Rg(o){var a=o.getSnapshot;o=o.value;try{var h=a();return!xr(o,h)}catch{return!0}}function jg(o){var a=Qr(o,1);a!==null&&Nr(a,o,1,-1)}function Ig(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:ol,lastRenderedState:o},a.queue=o,o=o.dispatch=$S.bind(null,Vt,o),[a.memoizedState,o]}function ll(o,a,h,g){return o={tag:o,create:a,destroy:h,deps:g,next:null},a=Vt.updateQueue,a===null?(a={lastEffect:null,stores:null},Vt.updateQueue=a,a.lastEffect=o.next=o):(h=a.lastEffect,h===null?a.lastEffect=o.next=o:(g=h.next,h.next=o,o.next=g,a.lastEffect=o)),o}function Lg(){return ur().memoizedState}function Da(o,a,h,g){var x=Pr();Vt.flags|=o,x.memoizedState=ll(1|a,h,void 0,g===void 0?null:g)}function Pa(o,a,h,g){var x=ur();g=g===void 0?null:g;var E=void 0;if(an!==null){var M=an.memoizedState;if(E=M.destroy,g!==null&&ef(g,M.deps)){x.memoizedState=ll(a,h,E,g);return}}Vt.flags|=o,x.memoizedState=ll(1|a,h,E,g)}function Dg(o,a){return Da(8390656,8,o,a)}function of(o,a){return Pa(2048,8,o,a)}function Pg(o,a){return Pa(4,2,o,a)}function Bg(o,a){return Pa(4,4,o,a)}function zg(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 $g(o,a,h){return h=h!=null?h.concat([o]):null,Pa(4,4,zg.bind(null,a,o),h)}function lf(){}function Fg(o,a){var h=ur();a=a===void 0?null:a;var g=h.memoizedState;return g!==null&&a!==null&&ef(a,g[1])?g[0]:(h.memoizedState=[o,a],o)}function Ug(o,a){var h=ur();a=a===void 0?null:a;var g=h.memoizedState;return g!==null&&a!==null&&ef(a,g[1])?g[0]:(o=o(),h.memoizedState=[o,a],o)}function Hg(o,a,h){return(pi&21)===0?(o.baseState&&(o.baseState=!1,Kn=!0),o.memoizedState=h):(xr(h,a)||(h=ia(),Vt.lanes|=h,mi|=h,o.baseState=!0),a)}function BS(o,a){var h=gt;gt=h!==0&&4>h?h:4,o(!0);var g=Zd.transition;Zd.transition={};try{o(!1),a()}finally{gt=h,Zd.transition=g}}function Wg(){return ur().memoizedState}function zS(o,a,h){var g=As(o);if(h={lane:g,action:h,hasEagerState:!1,eagerState:null,next:null},Vg(o))Kg(a,h);else if(h=kg(o,a,h,g),h!==null){var x=$n();Nr(h,o,g,x),Gg(h,a,g)}}function $S(o,a,h){var g=As(o),x={lane:g,action:h,hasEagerState:!1,eagerState:null,next:null};if(Vg(o))Kg(a,x);else{var E=o.alternate;if(o.lanes===0&&(E===null||E.lanes===0)&&(E=a.lastRenderedReducer,E!==null))try{var M=a.lastRenderedState,j=E(M,h);if(x.hasEagerState=!0,x.eagerState=j,xr(j,M)){var P=a.interleaved;P===null?(x.next=x,Gd(a)):(x.next=P.next,P.next=x),a.interleaved=x;return}}catch{}finally{}h=kg(o,a,x,g),h!==null&&(x=$n(),Nr(h,o,g,x),Gg(h,a,g))}}function Vg(o){var a=o.alternate;return o===Vt||a!==null&&a===Vt}function Kg(o,a){sl=La=!0;var h=o.pending;h===null?a.next=a:(a.next=h.next,h.next=a),o.pending=a}function Gg(o,a,h){if((h&4194240)!==0){var g=a.lanes;g&=o.pendingLanes,h|=g,a.lanes=h,Po(o,h)}}var Ba={readContext:cr,useCallback:Mn,useContext:Mn,useEffect:Mn,useImperativeHandle:Mn,useInsertionEffect:Mn,useLayoutEffect:Mn,useMemo:Mn,useReducer:Mn,useRef:Mn,useState:Mn,useDebugValue:Mn,useDeferredValue:Mn,useTransition:Mn,useMutableSource:Mn,useSyncExternalStore:Mn,useId:Mn,unstable_isNewReconciler:!1},FS={readContext:cr,useCallback:function(o,a){return Pr().memoizedState=[o,a===void 0?null:a],o},useContext:cr,useEffect:Dg,useImperativeHandle:function(o,a,h){return h=h!=null?h.concat([o]):null,Da(4194308,4,zg.bind(null,a,o),h)},useLayoutEffect:function(o,a){return Da(4194308,4,o,a)},useInsertionEffect:function(o,a){return Da(4,2,o,a)},useMemo:function(o,a){var h=Pr();return a=a===void 0?null:a,o=o(),h.memoizedState=[o,a],o},useReducer:function(o,a,h){var g=Pr();return a=h!==void 0?h(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=zS.bind(null,Vt,o),[g.memoizedState,o]},useRef:function(o){var a=Pr();return o={current:o},a.memoizedState=o},useState:Ig,useDebugValue:lf,useDeferredValue:function(o){return Pr().memoizedState=o},useTransition:function(){var o=Ig(!1),a=o[0];return o=BS.bind(null,o[1]),Pr().memoizedState=o,[a,o]},useMutableSource:function(){},useSyncExternalStore:function(o,a,h){var g=Vt,x=Pr();if(Ft){if(h===void 0)throw Error(n(407));h=h()}else{if(h=a(),hn===null)throw Error(n(349));(pi&30)!==0||Mg(g,a,h)}x.memoizedState=h;var E={value:h,getSnapshot:a};return x.queue=E,Dg(Og.bind(null,g,E,o),[o]),g.flags|=2048,ll(9,Ag.bind(null,g,E,h,a),void 0,null),h},useId:function(){var o=Pr(),a=hn.identifierPrefix;if(Ft){var h=Yr,g=Jr;h=(g&~(1<<32-Ht(g)-1)).toString(32)+h,a=":"+a+"R"+h,h=il++,0<h&&(a+="H"+h.toString(32)),a+=":"}else h=PS++,a=":"+a+"r"+h.toString(32)+":";return o.memoizedState=a},unstable_isNewReconciler:!1},US={readContext:cr,useCallback:Fg,useContext:cr,useEffect:of,useImperativeHandle:$g,useInsertionEffect:Pg,useLayoutEffect:Bg,useMemo:Ug,useReducer:rf,useRef:Lg,useState:function(){return rf(ol)},useDebugValue:lf,useDeferredValue:function(o){var a=ur();return Hg(a,an.memoizedState,o)},useTransition:function(){var o=rf(ol)[0],a=ur().memoizedState;return[o,a]},useMutableSource:_g,useSyncExternalStore:Tg,useId:Wg,unstable_isNewReconciler:!1},HS={readContext:cr,useCallback:Fg,useContext:cr,useEffect:of,useImperativeHandle:$g,useInsertionEffect:Pg,useLayoutEffect:Bg,useMemo:Ug,useReducer:sf,useRef:Lg,useState:function(){return sf(ol)},useDebugValue:lf,useDeferredValue:function(o){var a=ur();return an===null?a.memoizedState=o:Hg(a,an.memoizedState,o)},useTransition:function(){var o=sf(ol)[0],a=ur().memoizedState;return[o,a]},useMutableSource:_g,useSyncExternalStore:Tg,useId:Wg,unstable_isNewReconciler:!1};function kr(o,a){if(o&&o.defaultProps){a=B({},a),o=o.defaultProps;for(var h in o)a[h]===void 0&&(a[h]=o[h]);return a}return a}function af(o,a,h,g){a=o.memoizedState,h=h(g,a),h=h==null?a:B({},a,h),o.memoizedState=h,o.lanes===0&&(o.updateQueue.baseState=h)}var za={isMounted:function(o){return(o=o._reactInternals)?Kr(o)===o:!1},enqueueSetState:function(o,a,h){o=o._reactInternals;var g=$n(),x=As(o),E=Xr(g,x);E.payload=a,h!=null&&(E.callback=h),a=Cs(o,E,x),a!==null&&(Nr(a,o,x,g),Oa(a,o,x))},enqueueReplaceState:function(o,a,h){o=o._reactInternals;var g=$n(),x=As(o),E=Xr(g,x);E.tag=1,E.payload=a,h!=null&&(E.callback=h),a=Cs(o,E,x),a!==null&&(Nr(a,o,x,g),Oa(a,o,x))},enqueueForceUpdate:function(o,a){o=o._reactInternals;var h=$n(),g=As(o),x=Xr(h,g);x.tag=2,a!=null&&(x.callback=a),a=Cs(o,x,g),a!==null&&(Nr(a,o,g,h),Oa(a,o,g))}};function qg(o,a,h,g,x,E,M){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(g,E,M):a.prototype&&a.prototype.isPureReactComponent?!Go(h,g)||!Go(x,E):!0}function Jg(o,a,h){var g=!1,x=Ss,E=a.contextType;return typeof E=="object"&&E!==null?E=cr(E):(x=Vn(a)?ci:Tn.current,g=a.contextTypes,E=(g=g!=null)?Xi(o,x):Ss),a=new a(h,E),o.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=za,o.stateNode=a,a._reactInternals=o,g&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=x,o.__reactInternalMemoizedMaskedChildContext=E),a}function Yg(o,a,h,g){o=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(h,g),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(h,g),a.state!==o&&za.enqueueReplaceState(a,a.state,null)}function cf(o,a,h,g){var x=o.stateNode;x.props=h,x.state=o.memoizedState,x.refs={},qd(o);var E=a.contextType;typeof E=="object"&&E!==null?x.context=cr(E):(E=Vn(a)?ci:Tn.current,x.context=Xi(o,E)),x.state=o.memoizedState,E=a.getDerivedStateFromProps,typeof E=="function"&&(af(o,a,E,h),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&&za.enqueueReplaceState(x,x.state,null),Ra(o,h,x,g),x.state=o.memoizedState),typeof x.componentDidMount=="function"&&(o.flags|=4194308)}function oo(o,a){try{var h="",g=a;do h+=he(g),g=g.return;while(g);var x=h}catch(E){x=`
|
|
39
|
-
Error generating stack: `+E.message+`
|
|
40
|
-
`+E.stack}return{value:o,source:a,stack:x,digest:null}}function uf(o,a,h){return{value:o,source:null,stack:h??null,digest:a??null}}function df(o,a){try{console.error(a.value)}catch(h){setTimeout(function(){throw h})}}var WS=typeof WeakMap=="function"?WeakMap:Map;function Qg(o,a,h){h=Xr(-1,h),h.tag=3,h.payload={element:null};var g=a.value;return h.callback=function(){Ka||(Ka=!0,Cf=g),df(o,a)},h}function Xg(o,a,h){h=Xr(-1,h),h.tag=3;var g=o.type.getDerivedStateFromError;if(typeof g=="function"){var x=a.value;h.payload=function(){return g(x)},h.callback=function(){df(o,a)}}var E=o.stateNode;return E!==null&&typeof E.componentDidCatch=="function"&&(h.callback=function(){df(o,a),typeof g!="function"&&(Ts===null?Ts=new Set([this]):Ts.add(this));var M=a.stack;this.componentDidCatch(a.value,{componentStack:M!==null?M:""})}),h}function Zg(o,a,h){var g=o.pingCache;if(g===null){g=o.pingCache=new WS;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(h)||(x.add(h),o=sE.bind(null,o,a,h),a.then(o,o))}function ey(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 ty(o,a,h,g,x){return(o.mode&1)===0?(o===a?o.flags|=65536:(o.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(a=Xr(-1,1),a.tag=2,Cs(h,a,1))),h.lanes|=1),o):(o.flags|=65536,o.lanes=x,o)}var VS=T.ReactCurrentOwner,Kn=!1;function zn(o,a,h,g){a.child=o===null?wg(a,null,h,g):no(a,o.child,h,g)}function ny(o,a,h,g,x){h=h.render;var E=a.ref;return so(a,x),g=tf(o,a,h,g,E,x),h=nf(),o!==null&&!Kn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~x,Zr(o,a,x)):(Ft&&h&&Bd(a),a.flags|=1,zn(o,a,g,x),a.child)}function ry(o,a,h,g,x){if(o===null){var E=h.type;return typeof E=="function"&&!jf(E)&&E.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(a.tag=15,a.type=E,sy(o,a,E,g,x)):(o=Xa(h.type,null,g,a,a.mode,x),o.ref=a.ref,o.return=a,a.child=o)}if(E=o.child,(o.lanes&x)===0){var M=E.memoizedProps;if(h=h.compare,h=h!==null?h:Go,h(M,g)&&o.ref===a.ref)return Zr(o,a,x)}return a.flags|=1,o=Rs(E,g),o.ref=a.ref,o.return=a,a.child=o}function sy(o,a,h,g,x){if(o!==null){var E=o.memoizedProps;if(Go(E,g)&&o.ref===a.ref)if(Kn=!1,a.pendingProps=g=E,(o.lanes&x)!==0)(o.flags&131072)!==0&&(Kn=!0);else return a.lanes=o.lanes,Zr(o,a,x)}return ff(o,a,h,g,x)}function iy(o,a,h){var g=a.pendingProps,x=g.children,E=o!==null?o.memoizedState:null;if(g.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},Rt(ao,tr),tr|=h;else{if((h&1073741824)===0)return o=E!==null?E.baseLanes|h:h,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:o,cachePool:null,transitions:null},a.updateQueue=null,Rt(ao,tr),tr|=o,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=E!==null?E.baseLanes:h,Rt(ao,tr),tr|=g}else E!==null?(g=E.baseLanes|h,a.memoizedState=null):g=h,Rt(ao,tr),tr|=g;return zn(o,a,x,h),a.child}function oy(o,a){var h=a.ref;(o===null&&h!==null||o!==null&&o.ref!==h)&&(a.flags|=512,a.flags|=2097152)}function ff(o,a,h,g,x){var E=Vn(h)?ci:Tn.current;return E=Xi(a,E),so(a,x),h=tf(o,a,h,g,E,x),g=nf(),o!==null&&!Kn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~x,Zr(o,a,x)):(Ft&&g&&Bd(a),a.flags|=1,zn(o,a,h,x),a.child)}function ly(o,a,h,g,x){if(Vn(h)){var E=!0;Sa(a)}else E=!1;if(so(a,x),a.stateNode===null)Fa(o,a),Jg(a,h,g),cf(a,h,g,x),g=!0;else if(o===null){var M=a.stateNode,j=a.memoizedProps;M.props=j;var P=M.context,ee=h.contextType;typeof ee=="object"&&ee!==null?ee=cr(ee):(ee=Vn(h)?ci:Tn.current,ee=Xi(a,ee));var de=h.getDerivedStateFromProps,me=typeof de=="function"||typeof M.getSnapshotBeforeUpdate=="function";me||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(j!==g||P!==ee)&&Yg(a,M,g,ee),Ns=!1;var ue=a.memoizedState;M.state=ue,Ra(a,g,M,x),P=a.memoizedState,j!==g||ue!==P||Wn.current||Ns?(typeof de=="function"&&(af(a,h,de,g),P=a.memoizedState),(j=Ns||qg(a,h,j,g,ue,P,ee))?(me||typeof M.UNSAFE_componentWillMount!="function"&&typeof M.componentWillMount!="function"||(typeof M.componentWillMount=="function"&&M.componentWillMount(),typeof M.UNSAFE_componentWillMount=="function"&&M.UNSAFE_componentWillMount()),typeof M.componentDidMount=="function"&&(a.flags|=4194308)):(typeof M.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=g,a.memoizedState=P),M.props=g,M.state=P,M.context=ee,g=j):(typeof M.componentDidMount=="function"&&(a.flags|=4194308),g=!1)}else{M=a.stateNode,Sg(o,a),j=a.memoizedProps,ee=a.type===a.elementType?j:kr(a.type,j),M.props=ee,me=a.pendingProps,ue=M.context,P=h.contextType,typeof P=="object"&&P!==null?P=cr(P):(P=Vn(h)?ci:Tn.current,P=Xi(a,P));var Ce=h.getDerivedStateFromProps;(de=typeof Ce=="function"||typeof M.getSnapshotBeforeUpdate=="function")||typeof M.UNSAFE_componentWillReceiveProps!="function"&&typeof M.componentWillReceiveProps!="function"||(j!==me||ue!==P)&&Yg(a,M,g,P),Ns=!1,ue=a.memoizedState,M.state=ue,Ra(a,g,M,x);var Re=a.memoizedState;j!==me||ue!==Re||Wn.current||Ns?(typeof Ce=="function"&&(af(a,h,Ce,g),Re=a.memoizedState),(ee=Ns||qg(a,h,ee,g,ue,Re,P)||!1)?(de||typeof M.UNSAFE_componentWillUpdate!="function"&&typeof M.componentWillUpdate!="function"||(typeof M.componentWillUpdate=="function"&&M.componentWillUpdate(g,Re,P),typeof M.UNSAFE_componentWillUpdate=="function"&&M.UNSAFE_componentWillUpdate(g,Re,P)),typeof M.componentDidUpdate=="function"&&(a.flags|=4),typeof M.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof M.componentDidUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=1024),a.memoizedProps=g,a.memoizedState=Re),M.props=g,M.state=Re,M.context=P,g=ee):(typeof M.componentDidUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=4),typeof M.getSnapshotBeforeUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=1024),g=!1)}return hf(o,a,h,g,E,x)}function hf(o,a,h,g,x,E){oy(o,a);var M=(a.flags&128)!==0;if(!g&&!M)return x&&fg(a,h,!1),Zr(o,a,E);g=a.stateNode,VS.current=a;var j=M&&typeof h.getDerivedStateFromError!="function"?null:g.render();return a.flags|=1,o!==null&&M?(a.child=no(a,o.child,null,E),a.child=no(a,null,j,E)):zn(o,a,j,E),a.memoizedState=g.state,x&&fg(a,h,!0),a.child}function ay(o){var a=o.stateNode;a.pendingContext?ug(o,a.pendingContext,a.pendingContext!==a.context):a.context&&ug(o,a.context,!1),Jd(o,a.containerInfo)}function cy(o,a,h,g,x){return to(),Ud(x),a.flags|=256,zn(o,a,h,g),a.child}var pf={dehydrated:null,treeContext:null,retryLane:0};function mf(o){return{baseLanes:o,cachePool:null,transitions:null}}function uy(o,a,h){var g=a.pendingProps,x=Wt.current,E=!1,M=(a.flags&128)!==0,j;if((j=M)||(j=o!==null&&o.memoizedState===null?!1:(x&2)!==0),j?(E=!0,a.flags&=-129):(o===null||o.memoizedState!==null)&&(x|=1),Rt(Wt,x&1),o===null)return Fd(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):(M=g.children,o=g.fallback,E?(g=a.mode,E=a.child,M={mode:"hidden",children:M},(g&1)===0&&E!==null?(E.childLanes=0,E.pendingProps=M):E=Za(M,g,0,null),o=vi(o,g,h,null),E.return=a,o.return=a,E.sibling=o,a.child=E,a.child.memoizedState=mf(h),a.memoizedState=pf,o):gf(a,M));if(x=o.memoizedState,x!==null&&(j=x.dehydrated,j!==null))return KS(o,a,M,g,j,x,h);if(E){E=g.fallback,M=a.mode,x=o.child,j=x.sibling;var P={mode:"hidden",children:g.children};return(M&1)===0&&a.child!==x?(g=a.child,g.childLanes=0,g.pendingProps=P,a.deletions=null):(g=Rs(x,P),g.subtreeFlags=x.subtreeFlags&14680064),j!==null?E=Rs(j,E):(E=vi(E,M,h,null),E.flags|=2),E.return=a,g.return=a,g.sibling=E,a.child=g,g=E,E=a.child,M=o.child.memoizedState,M=M===null?mf(h):{baseLanes:M.baseLanes|h,cachePool:null,transitions:M.transitions},E.memoizedState=M,E.childLanes=o.childLanes&~h,a.memoizedState=pf,g}return E=o.child,o=E.sibling,g=Rs(E,{mode:"visible",children:g.children}),(a.mode&1)===0&&(g.lanes=h),g.return=a,g.sibling=null,o!==null&&(h=a.deletions,h===null?(a.deletions=[o],a.flags|=16):h.push(o)),a.child=g,a.memoizedState=null,g}function gf(o,a){return a=Za({mode:"visible",children:a},o.mode,0,null),a.return=o,o.child=a}function $a(o,a,h,g){return g!==null&&Ud(g),no(a,o.child,null,h),o=gf(a,a.pendingProps.children),o.flags|=2,a.memoizedState=null,o}function KS(o,a,h,g,x,E,M){if(h)return a.flags&256?(a.flags&=-257,g=uf(Error(n(422))),$a(o,a,M,g)):a.memoizedState!==null?(a.child=o.child,a.flags|=128,null):(E=g.fallback,x=a.mode,g=Za({mode:"visible",children:g.children},x,0,null),E=vi(E,x,M,null),E.flags|=2,g.return=a,E.return=a,g.sibling=E,a.child=g,(a.mode&1)!==0&&no(a,o.child,null,M),a.child.memoizedState=mf(M),a.memoizedState=pf,E);if((a.mode&1)===0)return $a(o,a,M,null);if(x.data==="$!"){if(g=x.nextSibling&&x.nextSibling.dataset,g)var j=g.dgst;return g=j,E=Error(n(419)),g=uf(E,g,void 0),$a(o,a,M,g)}if(j=(M&o.childLanes)!==0,Kn||j){if(g=hn,g!==null){switch(M&-M){case 4:x=2;break;case 16:x=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:x=32;break;case 536870912:x=268435456;break;default:x=0}x=(x&(g.suspendedLanes|M))!==0?0:x,x!==0&&x!==E.retryLane&&(E.retryLane=x,Qr(o,x),Nr(g,o,x,-1))}return Rf(),g=uf(Error(n(421))),$a(o,a,M,g)}return x.data==="$?"?(a.flags|=128,a.child=o.child,a=iE.bind(null,o),x._reactRetry=a,null):(o=E.treeContext,er=ws(x.nextSibling),Zn=a,Ft=!0,wr=null,o!==null&&(lr[ar++]=Jr,lr[ar++]=Yr,lr[ar++]=ui,Jr=o.id,Yr=o.overflow,ui=a),a=gf(a,g.children),a.flags|=4096,a)}function dy(o,a,h){o.lanes|=a;var g=o.alternate;g!==null&&(g.lanes|=a),Kd(o.return,a,h)}function yf(o,a,h,g,x){var E=o.memoizedState;E===null?o.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:g,tail:h,tailMode:x}:(E.isBackwards=a,E.rendering=null,E.renderingStartTime=0,E.last=g,E.tail=h,E.tailMode=x)}function fy(o,a,h){var g=a.pendingProps,x=g.revealOrder,E=g.tail;if(zn(o,a,g.children,h),g=Wt.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&&dy(o,h,a);else if(o.tag===19)dy(o,h,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(Rt(Wt,g),(a.mode&1)===0)a.memoizedState=null;else switch(x){case"forwards":for(h=a.child,x=null;h!==null;)o=h.alternate,o!==null&&ja(o)===null&&(x=h),h=h.sibling;h=x,h===null?(x=a.child,a.child=null):(x=h.sibling,h.sibling=null),yf(a,!1,x,h,E);break;case"backwards":for(h=null,x=a.child,a.child=null;x!==null;){if(o=x.alternate,o!==null&&ja(o)===null){a.child=x;break}o=x.sibling,x.sibling=h,h=x,x=o}yf(a,!0,h,null,E);break;case"together":yf(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,h){if(o!==null&&(a.dependencies=o.dependencies),mi|=a.lanes,(h&a.childLanes)===0)return null;if(o!==null&&a.child!==o.child)throw Error(n(153));if(a.child!==null){for(o=a.child,h=Rs(o,o.pendingProps),a.child=h,h.return=a;o.sibling!==null;)o=o.sibling,h=h.sibling=Rs(o,o.pendingProps),h.return=a;h.sibling=null}return a.child}function GS(o,a,h){switch(a.tag){case 3:ay(a),to();break;case 5:Cg(a);break;case 1:Vn(a.type)&&Sa(a);break;case 4:Jd(a,a.stateNode.containerInfo);break;case 10:var g=a.type._context,x=a.memoizedProps.value;Rt(Ma,g._currentValue),g._currentValue=x;break;case 13:if(g=a.memoizedState,g!==null)return g.dehydrated!==null?(Rt(Wt,Wt.current&1),a.flags|=128,null):(h&a.child.childLanes)!==0?uy(o,a,h):(Rt(Wt,Wt.current&1),o=Zr(o,a,h),o!==null?o.sibling:null);Rt(Wt,Wt.current&1);break;case 19:if(g=(h&a.childLanes)!==0,(o.flags&128)!==0){if(g)return fy(o,a,h);a.flags|=128}if(x=a.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),Rt(Wt,Wt.current),g)break;return null;case 22:case 23:return a.lanes=0,iy(o,a,h)}return Zr(o,a,h)}var hy,bf,py,my;hy=function(o,a){for(var h=a.child;h!==null;){if(h.tag===5||h.tag===6)o.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===a)break;for(;h.sibling===null;){if(h.return===null||h.return===a)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},bf=function(){},py=function(o,a,h,g){var x=o.memoizedProps;if(x!==g){o=a.stateNode,hi(Dr.current);var E=null;switch(h){case"input":x=Oe(o,x),g=Oe(o,g),E=[];break;case"select":x=B({},x,{value:void 0}),g=B({},g,{value:void 0}),E=[];break;case"textarea":x=qe(o,x),g=qe(o,g),E=[];break;default:typeof x.onClick!="function"&&typeof g.onClick=="function"&&(o.onclick=xa)}ln(h,g);var M;h=null;for(ee in x)if(!g.hasOwnProperty(ee)&&x.hasOwnProperty(ee)&&x[ee]!=null)if(ee==="style"){var j=x[ee];for(M in j)j.hasOwnProperty(M)&&(h||(h={}),h[M]="")}else ee!=="dangerouslySetInnerHTML"&&ee!=="children"&&ee!=="suppressContentEditableWarning"&&ee!=="suppressHydrationWarning"&&ee!=="autoFocus"&&(s.hasOwnProperty(ee)?E||(E=[]):(E=E||[]).push(ee,null));for(ee in g){var P=g[ee];if(j=x!=null?x[ee]:void 0,g.hasOwnProperty(ee)&&P!==j&&(P!=null||j!=null))if(ee==="style")if(j){for(M in j)!j.hasOwnProperty(M)||P&&P.hasOwnProperty(M)||(h||(h={}),h[M]="");for(M in P)P.hasOwnProperty(M)&&j[M]!==P[M]&&(h||(h={}),h[M]=P[M])}else h||(E||(E=[]),E.push(ee,h)),h=P;else ee==="dangerouslySetInnerHTML"?(P=P?P.__html:void 0,j=j?j.__html:void 0,P!=null&&j!==P&&(E=E||[]).push(ee,P)):ee==="children"?typeof P!="string"&&typeof P!="number"||(E=E||[]).push(ee,""+P):ee!=="suppressContentEditableWarning"&&ee!=="suppressHydrationWarning"&&(s.hasOwnProperty(ee)?(P!=null&&ee==="onScroll"&&Pt("scroll",o),E||j===P||(E=[])):(E=E||[]).push(ee,P))}h&&(E=E||[]).push("style",h);var ee=E;(a.updateQueue=ee)&&(a.flags|=4)}},my=function(o,a,h,g){h!==g&&(a.flags|=4)};function al(o,a){if(!Ft)switch(o.tailMode){case"hidden":a=o.tail;for(var h=null;a!==null;)a.alternate!==null&&(h=a),a=a.sibling;h===null?o.tail=null:h.sibling=null;break;case"collapsed":h=o.tail;for(var g=null;h!==null;)h.alternate!==null&&(g=h),h=h.sibling;g===null?a||o.tail===null?o.tail=null:o.tail.sibling=null:g.sibling=null}}function An(o){var a=o.alternate!==null&&o.alternate.child===o.child,h=0,g=0;if(a)for(var x=o.child;x!==null;)h|=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;)h|=x.lanes|x.childLanes,g|=x.subtreeFlags,g|=x.flags,x.return=o,x=x.sibling;return o.subtreeFlags|=g,o.childLanes=h,a}function qS(o,a,h){var g=a.pendingProps;switch(zd(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return An(a),null;case 1:return Vn(a.type)&&ka(),An(a),null;case 3:return g=a.stateNode,io(),Bt(Wn),Bt(Tn),Xd(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(o===null||o.child===null)&&(_a(a)?a.flags|=4:o===null||o.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,wr!==null&&(Mf(wr),wr=null))),bf(o,a),An(a),null;case 5:Yd(a);var x=hi(rl.current);if(h=a.type,o!==null&&a.stateNode!=null)py(o,a,h,g,x),o.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!g){if(a.stateNode===null)throw Error(n(166));return An(a),null}if(o=hi(Dr.current),_a(a)){g=a.stateNode,h=a.type;var E=a.memoizedProps;switch(g[Lr]=a,g[Xo]=E,o=(a.mode&1)!==0,h){case"dialog":Pt("cancel",g),Pt("close",g);break;case"iframe":case"object":case"embed":Pt("load",g);break;case"video":case"audio":for(x=0;x<Jo.length;x++)Pt(Jo[x],g);break;case"source":Pt("error",g);break;case"img":case"image":case"link":Pt("error",g),Pt("load",g);break;case"details":Pt("toggle",g);break;case"input":Je(g,E),Pt("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!E.multiple},Pt("invalid",g);break;case"textarea":at(g,E),Pt("invalid",g)}ln(h,E),x=null;for(var M in E)if(E.hasOwnProperty(M)){var j=E[M];M==="children"?typeof j=="string"?g.textContent!==j&&(E.suppressHydrationWarning!==!0&&va(g.textContent,j,o),x=["children",j]):typeof j=="number"&&g.textContent!==""+j&&(E.suppressHydrationWarning!==!0&&va(g.textContent,j,o),x=["children",""+j]):s.hasOwnProperty(M)&&j!=null&&M==="onScroll"&&Pt("scroll",g)}switch(h){case"input":pe(g),Le(g,E,!0);break;case"textarea":pe(g),mt(g);break;case"select":case"option":break;default:typeof E.onClick=="function"&&(g.onclick=xa)}g=x,a.updateQueue=g,g!==null&&(a.flags|=4)}else{M=x.nodeType===9?x:x.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=$t(h)),o==="http://www.w3.org/1999/xhtml"?h==="script"?(o=M.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof g.is=="string"?o=M.createElement(h,{is:g.is}):(o=M.createElement(h),h==="select"&&(M=o,g.multiple?M.multiple=!0:g.size&&(M.size=g.size))):o=M.createElementNS(o,h),o[Lr]=a,o[Xo]=g,hy(o,a,!1,!1),a.stateNode=o;e:{switch(M=ir(h,g),h){case"dialog":Pt("cancel",o),Pt("close",o),x=g;break;case"iframe":case"object":case"embed":Pt("load",o),x=g;break;case"video":case"audio":for(x=0;x<Jo.length;x++)Pt(Jo[x],o);x=g;break;case"source":Pt("error",o),x=g;break;case"img":case"image":case"link":Pt("error",o),Pt("load",o),x=g;break;case"details":Pt("toggle",o),x=g;break;case"input":Je(o,g),x=Oe(o,g),Pt("invalid",o);break;case"option":x=g;break;case"select":o._wrapperState={wasMultiple:!!g.multiple},x=B({},g,{value:void 0}),Pt("invalid",o);break;case"textarea":at(o,g),x=qe(o,g),Pt("invalid",o);break;default:x=g}ln(h,x),j=x;for(E in j)if(j.hasOwnProperty(E)){var P=j[E];E==="style"?nt(o,P):E==="dangerouslySetInnerHTML"?(P=P?P.__html:void 0,P!=null&&We(o,P)):E==="children"?typeof P=="string"?(h!=="textarea"||P!=="")&&Fe(o,P):typeof P=="number"&&Fe(o,""+P):E!=="suppressContentEditableWarning"&&E!=="suppressHydrationWarning"&&E!=="autoFocus"&&(s.hasOwnProperty(E)?P!=null&&E==="onScroll"&&Pt("scroll",o):P!=null&&O(o,E,P,M))}switch(h){case"input":pe(o),Le(o,g,!1);break;case"textarea":pe(o),mt(o);break;case"option":g.value!=null&&o.setAttribute("value",""+De(g.value));break;case"select":o.multiple=!!g.multiple,E=g.value,E!=null?fe(o,!!g.multiple,E,!1):g.defaultValue!=null&&fe(o,!!g.multiple,g.defaultValue,!0);break;default:typeof x.onClick=="function"&&(o.onclick=xa)}switch(h){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 An(a),null;case 6:if(o&&a.stateNode!=null)my(o,a,o.memoizedProps,g);else{if(typeof g!="string"&&a.stateNode===null)throw Error(n(166));if(h=hi(rl.current),hi(Dr.current),_a(a)){if(g=a.stateNode,h=a.memoizedProps,g[Lr]=a,(E=g.nodeValue!==h)&&(o=Zn,o!==null))switch(o.tag){case 3:va(g.nodeValue,h,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&va(g.nodeValue,h,(o.mode&1)!==0)}E&&(a.flags|=4)}else g=(h.nodeType===9?h:h.ownerDocument).createTextNode(g),g[Lr]=a,a.stateNode=g}return An(a),null;case 13:if(Bt(Wt),g=a.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(Ft&&er!==null&&(a.mode&1)!==0&&(a.flags&128)===0)bg(),to(),a.flags|=98560,E=!1;else if(E=_a(a),g!==null&&g.dehydrated!==null){if(o===null){if(!E)throw Error(n(318));if(E=a.memoizedState,E=E!==null?E.dehydrated:null,!E)throw Error(n(317));E[Lr]=a}else to(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;An(a),E=!1}else wr!==null&&(Mf(wr),wr=null),E=!0;if(!E)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=h,a):(g=g!==null,g!==(o!==null&&o.memoizedState!==null)&&g&&(a.child.flags|=8192,(a.mode&1)!==0&&(o===null||(Wt.current&1)!==0?cn===0&&(cn=3):Rf())),a.updateQueue!==null&&(a.flags|=4),An(a),null);case 4:return io(),bf(o,a),o===null&&Yo(a.stateNode.containerInfo),An(a),null;case 10:return Vd(a.type._context),An(a),null;case 17:return Vn(a.type)&&ka(),An(a),null;case 19:if(Bt(Wt),E=a.memoizedState,E===null)return An(a),null;if(g=(a.flags&128)!==0,M=E.rendering,M===null)if(g)al(E,!1);else{if(cn!==0||o!==null&&(o.flags&128)!==0)for(o=a.child;o!==null;){if(M=ja(o),M!==null){for(a.flags|=128,al(E,!1),g=M.updateQueue,g!==null&&(a.updateQueue=g,a.flags|=4),a.subtreeFlags=0,g=h,h=a.child;h!==null;)E=h,o=g,E.flags&=14680066,M=E.alternate,M===null?(E.childLanes=0,E.lanes=o,E.child=null,E.subtreeFlags=0,E.memoizedProps=null,E.memoizedState=null,E.updateQueue=null,E.dependencies=null,E.stateNode=null):(E.childLanes=M.childLanes,E.lanes=M.lanes,E.child=M.child,E.subtreeFlags=0,E.deletions=null,E.memoizedProps=M.memoizedProps,E.memoizedState=M.memoizedState,E.updateQueue=M.updateQueue,E.type=M.type,o=M.dependencies,E.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),h=h.sibling;return Rt(Wt,Wt.current&1|2),a.child}o=o.sibling}E.tail!==null&&Ut()>co&&(a.flags|=128,g=!0,al(E,!1),a.lanes=4194304)}else{if(!g)if(o=ja(M),o!==null){if(a.flags|=128,g=!0,h=o.updateQueue,h!==null&&(a.updateQueue=h,a.flags|=4),al(E,!0),E.tail===null&&E.tailMode==="hidden"&&!M.alternate&&!Ft)return An(a),null}else 2*Ut()-E.renderingStartTime>co&&h!==1073741824&&(a.flags|=128,g=!0,al(E,!1),a.lanes=4194304);E.isBackwards?(M.sibling=a.child,a.child=M):(h=E.last,h!==null?h.sibling=M:a.child=M,E.last=M)}return E.tail!==null?(a=E.tail,E.rendering=a,E.tail=a.sibling,E.renderingStartTime=Ut(),a.sibling=null,h=Wt.current,Rt(Wt,g?h&1|2:h&1),a):(An(a),null);case 22:case 23:return Of(),g=a.memoizedState!==null,o!==null&&o.memoizedState!==null!==g&&(a.flags|=8192),g&&(a.mode&1)!==0?(tr&1073741824)!==0&&(An(a),a.subtreeFlags&6&&(a.flags|=8192)):An(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function JS(o,a){switch(zd(a),a.tag){case 1:return Vn(a.type)&&ka(),o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 3:return io(),Bt(Wn),Bt(Tn),Xd(),o=a.flags,(o&65536)!==0&&(o&128)===0?(a.flags=o&-65537|128,a):null;case 5:return Yd(a),null;case 13:if(Bt(Wt),o=a.memoizedState,o!==null&&o.dehydrated!==null){if(a.alternate===null)throw Error(n(340));to()}return o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 19:return Bt(Wt),null;case 4:return io(),null;case 10:return Vd(a.type._context),null;case 22:case 23:return Of(),null;case 24:return null;default:return null}}var Ua=!1,On=!1,YS=typeof WeakSet=="function"?WeakSet:Set,Ae=null;function lo(o,a){var h=o.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(g){Gt(o,a,g)}else h.current=null}function vf(o,a,h){try{h()}catch(g){Gt(o,a,g)}}var gy=!1;function QS(o,a){if(Ad=aa,o=qm(),kd(o)){if("selectionStart"in o)var h={start:o.selectionStart,end:o.selectionEnd};else e:{h=(h=o.ownerDocument)&&h.defaultView||window;var g=h.getSelection&&h.getSelection();if(g&&g.rangeCount!==0){h=g.anchorNode;var x=g.anchorOffset,E=g.focusNode;g=g.focusOffset;try{h.nodeType,E.nodeType}catch{h=null;break e}var M=0,j=-1,P=-1,ee=0,de=0,me=o,ue=null;t:for(;;){for(var Ce;me!==h||x!==0&&me.nodeType!==3||(j=M+x),me!==E||g!==0&&me.nodeType!==3||(P=M+g),me.nodeType===3&&(M+=me.nodeValue.length),(Ce=me.firstChild)!==null;)ue=me,me=Ce;for(;;){if(me===o)break t;if(ue===h&&++ee===x&&(j=M),ue===E&&++de===g&&(P=M),(Ce=me.nextSibling)!==null)break;me=ue,ue=me.parentNode}me=Ce}h=j===-1||P===-1?null:{start:j,end:P}}else h=null}h=h||{start:0,end:0}}else h=null;for(Od={focusedElem:o,selectionRange:h},aa=!1,Ae=a;Ae!==null;)if(a=Ae,o=a.child,(a.subtreeFlags&1028)!==0&&o!==null)o.return=a,Ae=o;else for(;Ae!==null;){a=Ae;try{var Re=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Re!==null){var je=Re.memoizedProps,en=Re.memoizedState,G=a.stateNode,F=G.getSnapshotBeforeUpdate(a.elementType===a.type?je:kr(a.type,je),en);G.__reactInternalSnapshotBeforeUpdate=F}break;case 3:var Q=a.stateNode.containerInfo;Q.nodeType===1?Q.textContent="":Q.nodeType===9&&Q.documentElement&&Q.removeChild(Q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ve){Gt(a,a.return,ve)}if(o=a.sibling,o!==null){o.return=a.return,Ae=o;break}Ae=a.return}return Re=gy,gy=!1,Re}function cl(o,a,h){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 E=x.destroy;x.destroy=void 0,E!==void 0&&vf(a,h,E)}x=x.next}while(x!==g)}}function Ha(o,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var h=a=a.next;do{if((h.tag&o)===o){var g=h.create;h.destroy=g()}h=h.next}while(h!==a)}}function xf(o){var a=o.ref;if(a!==null){var h=o.stateNode;switch(o.tag){case 5:o=h;break;default:o=h}typeof a=="function"?a(o):a.current=o}}function yy(o){var a=o.alternate;a!==null&&(o.alternate=null,yy(a)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(a=o.stateNode,a!==null&&(delete a[Lr],delete a[Xo],delete a[Ld],delete a[jS],delete a[IS])),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 by(o){return o.tag===5||o.tag===3||o.tag===4}function vy(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||by(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 wf(o,a,h){var g=o.tag;if(g===5||g===6)o=o.stateNode,a?h.nodeType===8?h.parentNode.insertBefore(o,a):h.insertBefore(o,a):(h.nodeType===8?(a=h.parentNode,a.insertBefore(o,h)):(a=h,a.appendChild(o)),h=h._reactRootContainer,h!=null||a.onclick!==null||(a.onclick=xa));else if(g!==4&&(o=o.child,o!==null))for(wf(o,a,h),o=o.sibling;o!==null;)wf(o,a,h),o=o.sibling}function kf(o,a,h){var g=o.tag;if(g===5||g===6)o=o.stateNode,a?h.insertBefore(o,a):h.appendChild(o);else if(g!==4&&(o=o.child,o!==null))for(kf(o,a,h),o=o.sibling;o!==null;)kf(o,a,h),o=o.sibling}var xn=null,Sr=!1;function _s(o,a,h){for(h=h.child;h!==null;)xy(o,a,h),h=h.sibling}function xy(o,a,h){if(ht&&typeof ht.onCommitFiberUnmount=="function")try{ht.onCommitFiberUnmount(ut,h)}catch{}switch(h.tag){case 5:On||lo(h,a);case 6:var g=xn,x=Sr;xn=null,_s(o,a,h),xn=g,Sr=x,xn!==null&&(Sr?(o=xn,h=h.stateNode,o.nodeType===8?o.parentNode.removeChild(h):o.removeChild(h)):xn.removeChild(h.stateNode));break;case 18:xn!==null&&(Sr?(o=xn,h=h.stateNode,o.nodeType===8?Id(o.parentNode,h):o.nodeType===1&&Id(o,h),Fo(o)):Id(xn,h.stateNode));break;case 4:g=xn,x=Sr,xn=h.stateNode.containerInfo,Sr=!0,_s(o,a,h),xn=g,Sr=x;break;case 0:case 11:case 14:case 15:if(!On&&(g=h.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){x=g=g.next;do{var E=x,M=E.destroy;E=E.tag,M!==void 0&&((E&2)!==0||(E&4)!==0)&&vf(h,a,M),x=x.next}while(x!==g)}_s(o,a,h);break;case 1:if(!On&&(lo(h,a),g=h.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=h.memoizedProps,g.state=h.memoizedState,g.componentWillUnmount()}catch(j){Gt(h,a,j)}_s(o,a,h);break;case 21:_s(o,a,h);break;case 22:h.mode&1?(On=(g=On)||h.memoizedState!==null,_s(o,a,h),On=g):_s(o,a,h);break;default:_s(o,a,h)}}function wy(o){var a=o.updateQueue;if(a!==null){o.updateQueue=null;var h=o.stateNode;h===null&&(h=o.stateNode=new YS),a.forEach(function(g){var x=oE.bind(null,o,g);h.has(g)||(h.add(g),g.then(x,x))})}}function Er(o,a){var h=a.deletions;if(h!==null)for(var g=0;g<h.length;g++){var x=h[g];try{var E=o,M=a,j=M;e:for(;j!==null;){switch(j.tag){case 5:xn=j.stateNode,Sr=!1;break e;case 3:xn=j.stateNode.containerInfo,Sr=!0;break e;case 4:xn=j.stateNode.containerInfo,Sr=!0;break e}j=j.return}if(xn===null)throw Error(n(160));xy(E,M,x),xn=null,Sr=!1;var P=x.alternate;P!==null&&(P.return=null),x.return=null}catch(ee){Gt(x,a,ee)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)ky(a,o),a=a.sibling}function ky(o,a){var h=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{cl(3,o,o.return),Ha(3,o)}catch(je){Gt(o,o.return,je)}try{cl(5,o,o.return)}catch(je){Gt(o,o.return,je)}}break;case 1:Er(a,o),Br(o),g&512&&h!==null&&lo(h,h.return);break;case 5:if(Er(a,o),Br(o),g&512&&h!==null&&lo(h,h.return),o.flags&32){var x=o.stateNode;try{Fe(x,"")}catch(je){Gt(o,o.return,je)}}if(g&4&&(x=o.stateNode,x!=null)){var E=o.memoizedProps,M=h!==null?h.memoizedProps:E,j=o.type,P=o.updateQueue;if(o.updateQueue=null,P!==null)try{j==="input"&&E.type==="radio"&&E.name!=null&&Ne(x,E),ir(j,M);var ee=ir(j,E);for(M=0;M<P.length;M+=2){var de=P[M],me=P[M+1];de==="style"?nt(x,me):de==="dangerouslySetInnerHTML"?We(x,me):de==="children"?Fe(x,me):O(x,de,me,ee)}switch(j){case"input":et(x,E);break;case"textarea":it(x,E);break;case"select":var ue=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!E.multiple;var Ce=E.value;Ce!=null?fe(x,!!E.multiple,Ce,!1):ue!==!!E.multiple&&(E.defaultValue!=null?fe(x,!!E.multiple,E.defaultValue,!0):fe(x,!!E.multiple,E.multiple?[]:"",!1))}x[Xo]=E}catch(je){Gt(o,o.return,je)}}break;case 6:if(Er(a,o),Br(o),g&4){if(o.stateNode===null)throw Error(n(162));x=o.stateNode,E=o.memoizedProps;try{x.nodeValue=E}catch(je){Gt(o,o.return,je)}}break;case 3:if(Er(a,o),Br(o),g&4&&h!==null&&h.memoizedState.isDehydrated)try{Fo(a.containerInfo)}catch(je){Gt(o,o.return,je)}break;case 4:Er(a,o),Br(o);break;case 13:Er(a,o),Br(o),x=o.child,x.flags&8192&&(E=x.memoizedState!==null,x.stateNode.isHidden=E,!E||x.alternate!==null&&x.alternate.memoizedState!==null||(Nf=Ut())),g&4&&wy(o);break;case 22:if(de=h!==null&&h.memoizedState!==null,o.mode&1?(On=(ee=On)||de,Er(a,o),On=ee):Er(a,o),Br(o),g&8192){if(ee=o.memoizedState!==null,(o.stateNode.isHidden=ee)&&!de&&(o.mode&1)!==0)for(Ae=o,de=o.child;de!==null;){for(me=Ae=de;Ae!==null;){switch(ue=Ae,Ce=ue.child,ue.tag){case 0:case 11:case 14:case 15:cl(4,ue,ue.return);break;case 1:lo(ue,ue.return);var Re=ue.stateNode;if(typeof Re.componentWillUnmount=="function"){g=ue,h=ue.return;try{a=g,Re.props=a.memoizedProps,Re.state=a.memoizedState,Re.componentWillUnmount()}catch(je){Gt(g,h,je)}}break;case 5:lo(ue,ue.return);break;case 22:if(ue.memoizedState!==null){Ny(me);continue}}Ce!==null?(Ce.return=ue,Ae=Ce):Ny(me)}de=de.sibling}e:for(de=null,me=o;;){if(me.tag===5){if(de===null){de=me;try{x=me.stateNode,ee?(E=x.style,typeof E.setProperty=="function"?E.setProperty("display","none","important"):E.display="none"):(j=me.stateNode,P=me.memoizedProps.style,M=P!=null&&P.hasOwnProperty("display")?P.display:null,j.style.display=Xe("display",M))}catch(je){Gt(o,o.return,je)}}}else if(me.tag===6){if(de===null)try{me.stateNode.nodeValue=ee?"":me.memoizedProps}catch(je){Gt(o,o.return,je)}}else if((me.tag!==22&&me.tag!==23||me.memoizedState===null||me===o)&&me.child!==null){me.child.return=me,me=me.child;continue}if(me===o)break e;for(;me.sibling===null;){if(me.return===null||me.return===o)break e;de===me&&(de=null),me=me.return}de===me&&(de=null),me.sibling.return=me.return,me=me.sibling}}break;case 19:Er(a,o),Br(o),g&4&&wy(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 h=o.return;h!==null;){if(by(h)){var g=h;break e}h=h.return}throw Error(n(160))}switch(g.tag){case 5:var x=g.stateNode;g.flags&32&&(Fe(x,""),g.flags&=-33);var E=vy(o);kf(o,E,x);break;case 3:case 4:var M=g.stateNode.containerInfo,j=vy(o);wf(o,j,M);break;default:throw Error(n(161))}}catch(P){Gt(o,o.return,P)}o.flags&=-3}a&4096&&(o.flags&=-4097)}function XS(o,a,h){Ae=o,Sy(o)}function Sy(o,a,h){for(var g=(o.mode&1)!==0;Ae!==null;){var x=Ae,E=x.child;if(x.tag===22&&g){var M=x.memoizedState!==null||Ua;if(!M){var j=x.alternate,P=j!==null&&j.memoizedState!==null||On;j=Ua;var ee=On;if(Ua=M,(On=P)&&!ee)for(Ae=x;Ae!==null;)M=Ae,P=M.child,M.tag===22&&M.memoizedState!==null?Cy(x):P!==null?(P.return=M,Ae=P):Cy(x);for(;E!==null;)Ae=E,Sy(E),E=E.sibling;Ae=x,Ua=j,On=ee}Ey(o)}else(x.subtreeFlags&8772)!==0&&E!==null?(E.return=x,Ae=E):Ey(o)}}function Ey(o){for(;Ae!==null;){var a=Ae;if((a.flags&8772)!==0){var h=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:On||Ha(5,a);break;case 1:var g=a.stateNode;if(a.flags&4&&!On)if(h===null)g.componentDidMount();else{var x=a.elementType===a.type?h.memoizedProps:kr(a.type,h.memoizedProps);g.componentDidUpdate(x,h.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var E=a.updateQueue;E!==null&&Ng(a,E,g);break;case 3:var M=a.updateQueue;if(M!==null){if(h=null,a.child!==null)switch(a.child.tag){case 5:h=a.child.stateNode;break;case 1:h=a.child.stateNode}Ng(a,M,h)}break;case 5:var j=a.stateNode;if(h===null&&a.flags&4){h=j;var P=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":P.autoFocus&&h.focus();break;case"img":P.src&&(h.src=P.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var ee=a.alternate;if(ee!==null){var de=ee.memoizedState;if(de!==null){var me=de.dehydrated;me!==null&&Fo(me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}On||a.flags&512&&xf(a)}catch(ue){Gt(a,a.return,ue)}}if(a===o){Ae=null;break}if(h=a.sibling,h!==null){h.return=a.return,Ae=h;break}Ae=a.return}}function Ny(o){for(;Ae!==null;){var a=Ae;if(a===o){Ae=null;break}var h=a.sibling;if(h!==null){h.return=a.return,Ae=h;break}Ae=a.return}}function Cy(o){for(;Ae!==null;){var a=Ae;try{switch(a.tag){case 0:case 11:case 15:var h=a.return;try{Ha(4,a)}catch(P){Gt(a,h,P)}break;case 1:var g=a.stateNode;if(typeof g.componentDidMount=="function"){var x=a.return;try{g.componentDidMount()}catch(P){Gt(a,x,P)}}var E=a.return;try{xf(a)}catch(P){Gt(a,E,P)}break;case 5:var M=a.return;try{xf(a)}catch(P){Gt(a,M,P)}}}catch(P){Gt(a,a.return,P)}if(a===o){Ae=null;break}var j=a.sibling;if(j!==null){j.return=a.return,Ae=j;break}Ae=a.return}}var ZS=Math.ceil,Wa=T.ReactCurrentDispatcher,Sf=T.ReactCurrentOwner,dr=T.ReactCurrentBatchConfig,yt=0,hn=null,rn=null,wn=0,tr=0,ao=ks(0),cn=0,ul=null,mi=0,Va=0,Ef=0,dl=null,Gn=null,Nf=0,co=1/0,es=null,Ka=!1,Cf=null,Ts=null,Ga=!1,Ms=null,qa=0,fl=0,_f=null,Ja=-1,Ya=0;function $n(){return(yt&6)!==0?Ut():Ja!==-1?Ja:Ja=Ut()}function As(o){return(o.mode&1)===0?1:(yt&2)!==0&&wn!==0?wn&-wn:DS.transition!==null?(Ya===0&&(Ya=ia()),Ya):(o=gt,o!==0||(o=window.event,o=o===void 0?16:Tm(o.type)),o)}function Nr(o,a,h,g){if(50<fl)throw fl=0,_f=null,Error(n(185));ys(o,h,g),((yt&2)===0||o!==hn)&&(o===hn&&((yt&2)===0&&(Va|=h),cn===4&&Os(o,wn)),qn(o,g),h===1&&yt===0&&(a.mode&1)===0&&(co=Ut()+500,Ea&&Es()))}function qn(o,a){var h=o.callbackNode;cd(o,a);var g=ii(o,o===hn?wn:0);if(g===0)h!==null&&vr(h),o.callbackNode=null,o.callbackPriority=0;else if(a=g&-g,o.callbackPriority!==a){if(h!=null&&vr(h),a===1)o.tag===0?LS(Ty.bind(null,o)):hg(Ty.bind(null,o)),OS(function(){(yt&6)===0&&Es()}),h=null;else{switch(st(g)){case 1:h=Lo;break;case 4:h=ri;break;case 16:h=Fi;break;case 536870912:h=Be;break;default:h=Fi}h=Dy(h,_y.bind(null,o))}o.callbackPriority=a,o.callbackNode=h}}function _y(o,a){if(Ja=-1,Ya=0,(yt&6)!==0)throw Error(n(327));var h=o.callbackNode;if(uo()&&o.callbackNode!==h)return null;var g=ii(o,o===hn?wn:0);if(g===0)return null;if((g&30)!==0||(g&o.expiredLanes)!==0||a)a=Qa(o,g);else{a=g;var x=yt;yt|=2;var E=Ay();(hn!==o||wn!==a)&&(es=null,co=Ut()+500,yi(o,a));do try{nE();break}catch(j){My(o,j)}while(!0);Wd(),Wa.current=E,yt=x,rn!==null?a=0:(hn=null,wn=0,a=cn)}if(a!==0){if(a===2&&(x=Do(o),x!==0&&(g=x,a=Tf(o,x))),a===1)throw h=ul,yi(o,0),Os(o,g),qn(o,Ut()),h;if(a===6)Os(o,g);else{if(x=o.current.alternate,(g&30)===0&&!eE(x)&&(a=Qa(o,g),a===2&&(E=Do(o),E!==0&&(g=E,a=Tf(o,E))),a===1))throw h=ul,yi(o,0),Os(o,g),qn(o,Ut()),h;switch(o.finishedWork=x,o.finishedLanes=g,a){case 0:case 1:throw Error(n(345));case 2:bi(o,Gn,es);break;case 3:if(Os(o,g),(g&130023424)===g&&(a=Nf+500-Ut(),10<a)){if(ii(o,0)!==0)break;if(x=o.suspendedLanes,(x&g)!==g){$n(),o.pingedLanes|=o.suspendedLanes&x;break}o.timeoutHandle=jd(bi.bind(null,o,Gn,es),a);break}bi(o,Gn,es);break;case 4:if(Os(o,g),(g&4194240)===g)break;for(a=o.eventTimes,x=-1;0<g;){var M=31-Ht(g);E=1<<M,M=a[M],M>x&&(x=M),g&=~E}if(g=x,g=Ut()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*ZS(g/1960))-g,10<g){o.timeoutHandle=jd(bi.bind(null,o,Gn,es),g);break}bi(o,Gn,es);break;case 5:bi(o,Gn,es);break;default:throw Error(n(329))}}}return qn(o,Ut()),o.callbackNode===h?_y.bind(null,o):null}function Tf(o,a){var h=dl;return o.current.memoizedState.isDehydrated&&(yi(o,a).flags|=256),o=Qa(o,a),o!==2&&(a=Gn,Gn=h,a!==null&&Mf(a)),o}function Mf(o){Gn===null?Gn=o:Gn.push.apply(Gn,o)}function eE(o){for(var a=o;;){if(a.flags&16384){var h=a.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var g=0;g<h.length;g++){var x=h[g],E=x.getSnapshot;x=x.value;try{if(!xr(E(),x))return!1}catch{return!1}}}if(h=a.child,a.subtreeFlags&16384&&h!==null)h.return=a,a=h;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 Os(o,a){for(a&=~Ef,a&=~Va,o.suspendedLanes|=a,o.pingedLanes&=~a,o=o.expirationTimes;0<a;){var h=31-Ht(a),g=1<<h;o[h]=-1,a&=~g}}function Ty(o){if((yt&6)!==0)throw Error(n(327));uo();var a=ii(o,0);if((a&1)===0)return qn(o,Ut()),null;var h=Qa(o,a);if(o.tag!==0&&h===2){var g=Do(o);g!==0&&(a=g,h=Tf(o,g))}if(h===1)throw h=ul,yi(o,0),Os(o,a),qn(o,Ut()),h;if(h===6)throw Error(n(345));return o.finishedWork=o.current.alternate,o.finishedLanes=a,bi(o,Gn,es),qn(o,Ut()),null}function Af(o,a){var h=yt;yt|=1;try{return o(a)}finally{yt=h,yt===0&&(co=Ut()+500,Ea&&Es())}}function gi(o){Ms!==null&&Ms.tag===0&&(yt&6)===0&&uo();var a=yt;yt|=1;var h=dr.transition,g=gt;try{if(dr.transition=null,gt=1,o)return o()}finally{gt=g,dr.transition=h,yt=a,(yt&6)===0&&Es()}}function Of(){tr=ao.current,Bt(ao)}function yi(o,a){o.finishedWork=null,o.finishedLanes=0;var h=o.timeoutHandle;if(h!==-1&&(o.timeoutHandle=-1,AS(h)),rn!==null)for(h=rn.return;h!==null;){var g=h;switch(zd(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&ka();break;case 3:io(),Bt(Wn),Bt(Tn),Xd();break;case 5:Yd(g);break;case 4:io();break;case 13:Bt(Wt);break;case 19:Bt(Wt);break;case 10:Vd(g.type._context);break;case 22:case 23:Of()}h=h.return}if(hn=o,rn=o=Rs(o.current,null),wn=tr=a,cn=0,ul=null,Ef=Va=mi=0,Gn=dl=null,fi!==null){for(a=0;a<fi.length;a++)if(h=fi[a],g=h.interleaved,g!==null){h.interleaved=null;var x=g.next,E=h.pending;if(E!==null){var M=E.next;E.next=x,g.next=M}h.pending=g}fi=null}return o}function My(o,a){do{var h=rn;try{if(Wd(),Ia.current=Ba,La){for(var g=Vt.memoizedState;g!==null;){var x=g.queue;x!==null&&(x.pending=null),g=g.next}La=!1}if(pi=0,fn=an=Vt=null,sl=!1,il=0,Sf.current=null,h===null||h.return===null){cn=1,ul=a,rn=null;break}e:{var E=o,M=h.return,j=h,P=a;if(a=wn,j.flags|=32768,P!==null&&typeof P=="object"&&typeof P.then=="function"){var ee=P,de=j,me=de.tag;if((de.mode&1)===0&&(me===0||me===11||me===15)){var ue=de.alternate;ue?(de.updateQueue=ue.updateQueue,de.memoizedState=ue.memoizedState,de.lanes=ue.lanes):(de.updateQueue=null,de.memoizedState=null)}var Ce=ey(M);if(Ce!==null){Ce.flags&=-257,ty(Ce,M,j,E,a),Ce.mode&1&&Zg(E,ee,a),a=Ce,P=ee;var Re=a.updateQueue;if(Re===null){var je=new Set;je.add(P),a.updateQueue=je}else Re.add(P);break e}else{if((a&1)===0){Zg(E,ee,a),Rf();break e}P=Error(n(426))}}else if(Ft&&j.mode&1){var en=ey(M);if(en!==null){(en.flags&65536)===0&&(en.flags|=256),ty(en,M,j,E,a),Ud(oo(P,j));break e}}E=P=oo(P,j),cn!==4&&(cn=2),dl===null?dl=[E]:dl.push(E),E=M;do{switch(E.tag){case 3:E.flags|=65536,a&=-a,E.lanes|=a;var G=Qg(E,P,a);Eg(E,G);break e;case 1:j=P;var F=E.type,Q=E.stateNode;if((E.flags&128)===0&&(typeof F.getDerivedStateFromError=="function"||Q!==null&&typeof Q.componentDidCatch=="function"&&(Ts===null||!Ts.has(Q)))){E.flags|=65536,a&=-a,E.lanes|=a;var ve=Xg(E,j,a);Eg(E,ve);break e}}E=E.return}while(E!==null)}Ry(h)}catch(Ie){a=Ie,rn===h&&h!==null&&(rn=h=h.return);continue}break}while(!0)}function Ay(){var o=Wa.current;return Wa.current=Ba,o===null?Ba:o}function Rf(){(cn===0||cn===3||cn===2)&&(cn=4),hn===null||(mi&268435455)===0&&(Va&268435455)===0||Os(hn,wn)}function Qa(o,a){var h=yt;yt|=2;var g=Ay();(hn!==o||wn!==a)&&(es=null,yi(o,a));do try{tE();break}catch(x){My(o,x)}while(!0);if(Wd(),yt=h,Wa.current=g,rn!==null)throw Error(n(261));return hn=null,wn=0,cn}function tE(){for(;rn!==null;)Oy(rn)}function nE(){for(;rn!==null&&!ra();)Oy(rn)}function Oy(o){var a=Ly(o.alternate,o,tr);o.memoizedProps=o.pendingProps,a===null?Ry(o):rn=a,Sf.current=null}function Ry(o){var a=o;do{var h=a.alternate;if(o=a.return,(a.flags&32768)===0){if(h=qS(h,a,tr),h!==null){rn=h;return}}else{if(h=JS(h,a),h!==null){h.flags&=32767,rn=h;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{cn=6,rn=null;return}}if(a=a.sibling,a!==null){rn=a;return}rn=a=o}while(a!==null);cn===0&&(cn=5)}function bi(o,a,h){var g=gt,x=dr.transition;try{dr.transition=null,gt=1,rE(o,a,h,g)}finally{dr.transition=x,gt=g}return null}function rE(o,a,h,g){do uo();while(Ms!==null);if((yt&6)!==0)throw Error(n(327));h=o.finishedWork;var x=o.finishedLanes;if(h===null)return null;if(o.finishedWork=null,o.finishedLanes=0,h===o.current)throw Error(n(177));o.callbackNode=null,o.callbackPriority=0;var E=h.lanes|h.childLanes;if(or(o,E),o===hn&&(rn=hn=null,wn=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||Ga||(Ga=!0,Dy(Fi,function(){return uo(),null})),E=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||E){E=dr.transition,dr.transition=null;var M=gt;gt=1;var j=yt;yt|=4,Sf.current=null,QS(o,h),ky(h,o),SS(Od),aa=!!Ad,Od=Ad=null,o.current=h,XS(h),sa(),yt=j,gt=M,dr.transition=E}else o.current=h;if(Ga&&(Ga=!1,Ms=o,qa=x),E=o.pendingLanes,E===0&&(Ts=null),Xt(h.stateNode),qn(o,Ut()),a!==null)for(g=o.onRecoverableError,h=0;h<a.length;h++)x=a[h],g(x.value,{componentStack:x.stack,digest:x.digest});if(Ka)throw Ka=!1,o=Cf,Cf=null,o;return(qa&1)!==0&&o.tag!==0&&uo(),E=o.pendingLanes,(E&1)!==0?o===_f?fl++:(fl=0,_f=o):fl=0,Es(),null}function uo(){if(Ms!==null){var o=st(qa),a=dr.transition,h=gt;try{if(dr.transition=null,gt=16>o?16:o,Ms===null)var g=!1;else{if(o=Ms,Ms=null,qa=0,(yt&6)!==0)throw Error(n(331));var x=yt;for(yt|=4,Ae=o.current;Ae!==null;){var E=Ae,M=E.child;if((Ae.flags&16)!==0){var j=E.deletions;if(j!==null){for(var P=0;P<j.length;P++){var ee=j[P];for(Ae=ee;Ae!==null;){var de=Ae;switch(de.tag){case 0:case 11:case 15:cl(8,de,E)}var me=de.child;if(me!==null)me.return=de,Ae=me;else for(;Ae!==null;){de=Ae;var ue=de.sibling,Ce=de.return;if(yy(de),de===ee){Ae=null;break}if(ue!==null){ue.return=Ce,Ae=ue;break}Ae=Ce}}}var Re=E.alternate;if(Re!==null){var je=Re.child;if(je!==null){Re.child=null;do{var en=je.sibling;je.sibling=null,je=en}while(je!==null)}}Ae=E}}if((E.subtreeFlags&2064)!==0&&M!==null)M.return=E,Ae=M;else e:for(;Ae!==null;){if(E=Ae,(E.flags&2048)!==0)switch(E.tag){case 0:case 11:case 15:cl(9,E,E.return)}var G=E.sibling;if(G!==null){G.return=E.return,Ae=G;break e}Ae=E.return}}var F=o.current;for(Ae=F;Ae!==null;){M=Ae;var Q=M.child;if((M.subtreeFlags&2064)!==0&&Q!==null)Q.return=M,Ae=Q;else e:for(M=F;Ae!==null;){if(j=Ae,(j.flags&2048)!==0)try{switch(j.tag){case 0:case 11:case 15:Ha(9,j)}}catch(Ie){Gt(j,j.return,Ie)}if(j===M){Ae=null;break e}var ve=j.sibling;if(ve!==null){ve.return=j.return,Ae=ve;break e}Ae=j.return}}if(yt=x,Es(),ht&&typeof ht.onPostCommitFiberRoot=="function")try{ht.onPostCommitFiberRoot(ut,o)}catch{}g=!0}return g}finally{gt=h,dr.transition=a}}return!1}function jy(o,a,h){a=oo(h,a),a=Qg(o,a,1),o=Cs(o,a,1),a=$n(),o!==null&&(ys(o,1,a),qn(o,a))}function Gt(o,a,h){if(o.tag===3)jy(o,o,h);else for(;a!==null;){if(a.tag===3){jy(a,o,h);break}else if(a.tag===1){var g=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Ts===null||!Ts.has(g))){o=oo(h,o),o=Xg(a,o,1),a=Cs(a,o,1),o=$n(),a!==null&&(ys(a,1,o),qn(a,o));break}}a=a.return}}function sE(o,a,h){var g=o.pingCache;g!==null&&g.delete(a),a=$n(),o.pingedLanes|=o.suspendedLanes&h,hn===o&&(wn&h)===h&&(cn===4||cn===3&&(wn&130023424)===wn&&500>Ut()-Nf?yi(o,0):Ef|=h),qn(o,a)}function Iy(o,a){a===0&&((o.mode&1)===0?a=1:(a=si,si<<=1,(si&130023424)===0&&(si=4194304)));var h=$n();o=Qr(o,a),o!==null&&(ys(o,a,h),qn(o,h))}function iE(o){var a=o.memoizedState,h=0;a!==null&&(h=a.retryLane),Iy(o,h)}function oE(o,a){var h=0;switch(o.tag){case 13:var g=o.stateNode,x=o.memoizedState;x!==null&&(h=x.retryLane);break;case 19:g=o.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(a),Iy(o,h)}var Ly;Ly=function(o,a,h){if(o!==null)if(o.memoizedProps!==a.pendingProps||Wn.current)Kn=!0;else{if((o.lanes&h)===0&&(a.flags&128)===0)return Kn=!1,GS(o,a,h);Kn=(o.flags&131072)!==0}else Kn=!1,Ft&&(a.flags&1048576)!==0&&pg(a,Ca,a.index);switch(a.lanes=0,a.tag){case 2:var g=a.type;Fa(o,a),o=a.pendingProps;var x=Xi(a,Tn.current);so(a,h),x=tf(null,a,g,o,x,h);var E=nf();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,Vn(g)?(E=!0,Sa(a)):E=!1,a.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,qd(a),x.updater=za,a.stateNode=x,x._reactInternals=a,cf(a,g,o,h),a=hf(null,a,g,!0,E,h)):(a.tag=0,Ft&&E&&Bd(a),zn(null,a,x,h),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=aE(g),o=kr(g,o),x){case 0:a=ff(null,a,g,o,h);break e;case 1:a=ly(null,a,g,o,h);break e;case 11:a=ny(null,a,g,o,h);break e;case 14:a=ry(null,a,g,kr(g.type,o),h);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),ff(o,a,g,x,h);case 1:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),ly(o,a,g,x,h);case 3:e:{if(ay(a),o===null)throw Error(n(387));g=a.pendingProps,E=a.memoizedState,x=E.element,Sg(o,a),Ra(a,g,null,h);var M=a.memoizedState;if(g=M.element,E.isDehydrated)if(E={element:g,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},a.updateQueue.baseState=E,a.memoizedState=E,a.flags&256){x=oo(Error(n(423)),a),a=cy(o,a,g,h,x);break e}else if(g!==x){x=oo(Error(n(424)),a),a=cy(o,a,g,h,x);break e}else for(er=ws(a.stateNode.containerInfo.firstChild),Zn=a,Ft=!0,wr=null,h=wg(a,null,g,h),a.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(to(),g===x){a=Zr(o,a,h);break e}zn(o,a,g,h)}a=a.child}return a;case 5:return Cg(a),o===null&&Fd(a),g=a.type,x=a.pendingProps,E=o!==null?o.memoizedProps:null,M=x.children,Rd(g,x)?M=null:E!==null&&Rd(g,E)&&(a.flags|=32),oy(o,a),zn(o,a,M,h),a.child;case 6:return o===null&&Fd(a),null;case 13:return uy(o,a,h);case 4:return Jd(a,a.stateNode.containerInfo),g=a.pendingProps,o===null?a.child=no(a,null,g,h):zn(o,a,g,h),a.child;case 11:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),ny(o,a,g,x,h);case 7:return zn(o,a,a.pendingProps,h),a.child;case 8:return zn(o,a,a.pendingProps.children,h),a.child;case 12:return zn(o,a,a.pendingProps.children,h),a.child;case 10:e:{if(g=a.type._context,x=a.pendingProps,E=a.memoizedProps,M=x.value,Rt(Ma,g._currentValue),g._currentValue=M,E!==null)if(xr(E.value,M)){if(E.children===x.children&&!Wn.current){a=Zr(o,a,h);break e}}else for(E=a.child,E!==null&&(E.return=a);E!==null;){var j=E.dependencies;if(j!==null){M=E.child;for(var P=j.firstContext;P!==null;){if(P.context===g){if(E.tag===1){P=Xr(-1,h&-h),P.tag=2;var ee=E.updateQueue;if(ee!==null){ee=ee.shared;var de=ee.pending;de===null?P.next=P:(P.next=de.next,de.next=P),ee.pending=P}}E.lanes|=h,P=E.alternate,P!==null&&(P.lanes|=h),Kd(E.return,h,a),j.lanes|=h;break}P=P.next}}else if(E.tag===10)M=E.type===a.type?null:E.child;else if(E.tag===18){if(M=E.return,M===null)throw Error(n(341));M.lanes|=h,j=M.alternate,j!==null&&(j.lanes|=h),Kd(M,h,a),M=E.sibling}else M=E.child;if(M!==null)M.return=E;else for(M=E;M!==null;){if(M===a){M=null;break}if(E=M.sibling,E!==null){E.return=M.return,M=E;break}M=M.return}E=M}zn(o,a,x.children,h),a=a.child}return a;case 9:return x=a.type,g=a.pendingProps.children,so(a,h),x=cr(x),g=g(x),a.flags|=1,zn(o,a,g,h),a.child;case 14:return g=a.type,x=kr(g,a.pendingProps),x=kr(g.type,x),ry(o,a,g,x,h);case 15:return sy(o,a,a.type,a.pendingProps,h);case 17:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),Fa(o,a),a.tag=1,Vn(g)?(o=!0,Sa(a)):o=!1,so(a,h),Jg(a,g,x),cf(a,g,x,h),hf(null,a,g,!0,o,h);case 19:return fy(o,a,h);case 22:return iy(o,a,h)}throw Error(n(156,a.tag))};function Dy(o,a){return na(o,a)}function lE(o,a,h,g){this.tag=o,this.key=h,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,h,g){return new lE(o,a,h,g)}function jf(o){return o=o.prototype,!(!o||!o.isReactComponent)}function aE(o){if(typeof o=="function")return jf(o)?1:0;if(o!=null){if(o=o.$$typeof,o===X)return 11;if(o===H)return 14}return 2}function Rs(o,a){var h=o.alternate;return h===null?(h=fr(o.tag,a,o.key,o.mode),h.elementType=o.elementType,h.type=o.type,h.stateNode=o.stateNode,h.alternate=o,o.alternate=h):(h.pendingProps=a,h.type=o.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=o.flags&14680064,h.childLanes=o.childLanes,h.lanes=o.lanes,h.child=o.child,h.memoizedProps=o.memoizedProps,h.memoizedState=o.memoizedState,h.updateQueue=o.updateQueue,a=o.dependencies,h.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},h.sibling=o.sibling,h.index=o.index,h.ref=o.ref,h}function Xa(o,a,h,g,x,E){var M=2;if(g=o,typeof o=="function")jf(o)&&(M=1);else if(typeof o=="string")M=5;else e:switch(o){case D:return vi(h.children,x,E,a);case z:M=8,x|=8;break;case $:return o=fr(12,h,a,x|2),o.elementType=$,o.lanes=E,o;case J:return o=fr(13,h,a,x),o.elementType=J,o.lanes=E,o;case q:return o=fr(19,h,a,x),o.elementType=q,o.lanes=E,o;case re:return Za(h,x,E,a);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case U:M=10;break e;case Y:M=9;break e;case X:M=11;break e;case H:M=14;break e;case W:M=16,g=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return a=fr(M,h,a,x),a.elementType=o,a.type=g,a.lanes=E,a}function vi(o,a,h,g){return o=fr(7,o,g,a),o.lanes=h,o}function Za(o,a,h,g){return o=fr(22,o,g,a),o.elementType=re,o.lanes=h,o.stateNode={isHidden:!1},o}function If(o,a,h){return o=fr(6,o,null,a),o.lanes=h,o}function Lf(o,a,h){return a=fr(4,o.children!==null?o.children:[],o.key,a),a.lanes=h,a.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},a}function cE(o,a,h,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=gs(0),this.expirationTimes=gs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gs(0),this.identifierPrefix=g,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function Df(o,a,h,g,x,E,M,j,P){return o=new cE(o,a,h,j,P),a===1?(a=1,E===!0&&(a|=8)):a=0,E=fr(3,null,null,a),o.current=E,E.stateNode=o,E.memoizedState={element:g,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},qd(E),o}function uE(o,a,h){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:h}}function Py(o){if(!o)return Ss;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(Vn(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(o.tag===1){var h=o.type;if(Vn(h))return dg(o,h,a)}return a}function By(o,a,h,g,x,E,M,j,P){return o=Df(h,g,!0,o,x,E,M,j,P),o.context=Py(null),h=o.current,g=$n(),x=As(h),E=Xr(g,x),E.callback=a??null,Cs(h,E,x),o.current.lanes=x,ys(o,x,g),qn(o,g),o}function ec(o,a,h,g){var x=a.current,E=$n(),M=As(x);return h=Py(h),a.context===null?a.context=h:a.pendingContext=h,a=Xr(E,M),a.payload={element:o},g=g===void 0?null:g,g!==null&&(a.callback=g),o=Cs(x,a,M),o!==null&&(Nr(o,x,M,E),Oa(o,x,M)),M}function tc(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 zy(o,a){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var h=o.retryLane;o.retryLane=h!==0&&h<a?h:a}}function Pf(o,a){zy(o,a),(o=o.alternate)&&zy(o,a)}function dE(){return null}var $y=typeof reportError=="function"?reportError:function(o){console.error(o)};function Bf(o){this._internalRoot=o}nc.prototype.render=Bf.prototype.render=function(o){var a=this._internalRoot;if(a===null)throw Error(n(409));ec(o,a,null,null)},nc.prototype.unmount=Bf.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var a=o.containerInfo;gi(function(){ec(null,o,null,null)}),a[Gr]=null}};function nc(o){this._internalRoot=o}nc.prototype.unstable_scheduleHydration=function(o){if(o){var a=oi();o={blockedOn:null,target:o,priority:a};for(var h=0;h<dn.length&&a!==0&&a<dn[h].priority;h++);dn.splice(h,0,o),h===0&&Cm(o)}};function zf(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function rc(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Fy(){}function fE(o,a,h,g,x){if(x){if(typeof g=="function"){var E=g;g=function(){var ee=tc(M);E.call(ee)}}var M=By(a,g,o,0,null,!1,!1,"",Fy);return o._reactRootContainer=M,o[Gr]=M.current,Yo(o.nodeType===8?o.parentNode:o),gi(),M}for(;x=o.lastChild;)o.removeChild(x);if(typeof g=="function"){var j=g;g=function(){var ee=tc(P);j.call(ee)}}var P=Df(o,0,!1,null,null,!1,!1,"",Fy);return o._reactRootContainer=P,o[Gr]=P.current,Yo(o.nodeType===8?o.parentNode:o),gi(function(){ec(a,P,h,g)}),P}function sc(o,a,h,g,x){var E=h._reactRootContainer;if(E){var M=E;if(typeof x=="function"){var j=x;x=function(){var P=tc(M);j.call(P)}}ec(a,M,o,x)}else M=fE(h,a,o,x,g);return tc(M)}Bo=function(o){switch(o.tag){case 3:var a=o.stateNode;if(a.current.memoizedState.isDehydrated){var h=ms(a.pendingLanes);h!==0&&(Po(a,h|1),qn(a,Ut()),(yt&6)===0&&(co=Ut()+500,Es()))}break;case 13:gi(function(){var g=Qr(o,1);if(g!==null){var x=$n();Nr(g,o,1,x)}}),Pf(o,1)}},Zt=function(o){if(o.tag===13){var a=Qr(o,134217728);if(a!==null){var h=$n();Nr(a,o,134217728,h)}Pf(o,134217728)}},Nt=function(o){if(o.tag===13){var a=As(o),h=Qr(o,a);if(h!==null){var g=$n();Nr(h,o,a,g)}Pf(o,a)}},oi=function(){return gt},Ir=function(o,a){var h=gt;try{return gt=o,a()}finally{gt=h}},le=function(o,a,h){switch(a){case"input":if(et(o,h),a=h.name,h.type==="radio"&&a!=null){for(h=o;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<h.length;a++){var g=h[a];if(g!==o&&g.form===o.form){var x=wa(g);if(!x)throw Error(n(90));se(g),et(g,x)}}}break;case"textarea":it(o,h);break;case"select":a=h.value,a!=null&&fe(o,!!h.multiple,a,!1)}},xe=Af,Ye=gi;var hE={usingClientEntryPoint:!1,Events:[Zo,Yi,wa,I,ie,Af]},hl={findFiberByHostInstance:ai,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},pE={bundleType:hl.bundleType,version:hl.version,rendererPackageName:hl.rendererPackageName,rendererConfig:hl.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=ea(o),o===null?null:o.stateNode},findFiberByHostInstance:hl.findFiberByHostInstance||dE,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 ic=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ic.isDisabled&&ic.supportsFiber)try{ut=ic.inject(pE),ht=ic}catch{}}return Jn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=hE,Jn.createPortal=function(o,a){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!zf(a))throw Error(n(200));return uE(o,a,null,h)},Jn.createRoot=function(o,a){if(!zf(o))throw Error(n(299));var h=!1,g="",x=$y;return a!=null&&(a.unstable_strictMode===!0&&(h=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),a=Df(o,1,!1,null,null,h,!1,g,x),o[Gr]=a.current,Yo(o.nodeType===8?o.parentNode:o),new Bf(a)},Jn.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=ea(a),o=o===null?null:o.stateNode,o},Jn.flushSync=function(o){return gi(o)},Jn.hydrate=function(o,a,h){if(!rc(a))throw Error(n(200));return sc(null,o,a,!0,h)},Jn.hydrateRoot=function(o,a,h){if(!zf(o))throw Error(n(405));var g=h!=null&&h.hydratedSources||null,x=!1,E="",M=$y;if(h!=null&&(h.unstable_strictMode===!0&&(x=!0),h.identifierPrefix!==void 0&&(E=h.identifierPrefix),h.onRecoverableError!==void 0&&(M=h.onRecoverableError)),a=By(a,null,o,1,h??null,x,!1,E,M),o[Gr]=a.current,Yo(o),g)for(o=0;o<g.length;o++)h=g[o],x=h._getVersion,x=x(h._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[h,x]:a.mutableSourceEagerHydrationData.push(h,x);return new nc(a)},Jn.render=function(o,a,h){if(!rc(a))throw Error(n(200));return sc(null,o,a,!1,h)},Jn.unmountComponentAtNode=function(o){if(!rc(o))throw Error(n(40));return o._reactRootContainer?(gi(function(){sc(null,null,o,!1,function(){o._reactRootContainer=null,o[Gr]=null})}),!0):!1},Jn.unstable_batchedUpdates=Af,Jn.unstable_renderSubtreeIntoContainer=function(o,a,h,g){if(!rc(h))throw Error(n(200));if(o==null||o._reactInternals===void 0)throw Error(n(38));return sc(o,a,h,!1,g)},Jn.version="18.3.1-next-f1338f8080-20240426",Jn}var Jy;function L0(){if(Jy)return Uf.exports;Jy=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(),Uf.exports=wE(),Uf.exports}var Yy;function kE(){if(Yy)return oc;Yy=1;var t=L0();return oc.createRoot=t.createRoot,oc.hydrateRoot=t.hydrateRoot,oc}var SE=kE();const EE=zu(SE),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"}],NE=["full","compact","minimal"],En={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"},CE={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function _E(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(En.typeface)){const n=CE[t];n&&localStorage.setItem(En.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(En.spacing)&&(localStorage.setItem(En.spacing,e),localStorage.removeItem("ow-typography"))}function $0(){const t=localStorage.getItem(En.typeface);return t&&D0.some(e=>e.id===t)?t:"charter"}function F0(){const t=localStorage.getItem(En.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function $u(){const t=localStorage.getItem(En.sidebarMode);return t&&P0.some(e=>e.id===t)?t:"default"}function U0(){return"cards"}function H0(){const t=localStorage.getItem(En.sidebarDensity);return t&&NE.includes(t)?t:"full"}function TE(t){localStorage.setItem(En.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function W0(){const t=localStorage.getItem(En.spacing);return t&&z0.some(e=>e.id===t)?t:"default"}function V0(){const t=localStorage.getItem(En.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(En.typeface,t),localStorage.setItem(En.mode,e),localStorage.setItem(En.sidebarMode,n),localStorage.setItem(En.sidebarStyle,r),localStorage.setItem(En.spacing,s),localStorage.setItem(En.canvas,i)}function ME(){_E(),K0($0(),F0(),$u(),U0(),W0(),V0()),document.documentElement.setAttribute("data-sidebar-density",H0())}var AE=L0();const OE=zu(AE);var Vf={exports:{}},Kf={};/**
|
|
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 Qy;function RE(){if(Qy)return Kf;Qy=1;var t=Gl();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,d(w)&&k({inst:w})},[m,b,y]),s(function(){return d(w)&&k({inst:w}),m(function(){d(w)&&k({inst:w})})},[m]),l(b),b}function d(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 p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Kf.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Kf}var Xy;function G0(){return Xy||(Xy=1,Vf.exports=RE()),Vf.exports}var q0=G0();function Sn(t){this.content=t}Sn.prototype={constructor:Sn,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 Sn(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 Sn(n)},addToStart:function(t,e){return new Sn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Sn(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 Sn(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=Sn.from(t),t.size?new Sn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Sn.from(t),t.size?new Sn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Sn.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}};Sn.from=function(t){if(t instanceof Sn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Sn(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),d=l.nodeSize;if(l==c){n-=d,r-=d;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let f=0,p=Math.min(l.text.length,c.text.length);for(;f<p&&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-=d,r-=d}}class ae{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 d=this.content[l],f=c+d.nodeSize;if(f>e&&r(d,s+c,i||null,l)!==!1&&d.content.size){let p=c+1;d.nodesBetween(Math.max(0,e-p),Math.min(d.content.size,n-p),r,s+p)}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,d)=>{let f=c.isText?c.text.slice(Math.max(e,d)-d,n-d):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 ae(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],d=l+c.nodeSize;d>e&&((l<e||d>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=d}return new ae(r,s)}cutByIndex(e,n){return e==n?ae.empty:e==0&&n==this.content.length?this:new ae(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 ae(s,i)}addToStart(e){return new ae([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ae(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 lc(0,e);if(e==this.size)return lc(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?lc(n+1,i):lc(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 ae.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ae(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ae.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 ae(n||e,r)}static from(e){if(!e)return ae.empty;if(e instanceof ae)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ae([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ae.empty=new ae([],0);const Gf={index:0,offset:0};function lc(t,e){return Gf.index=t,Gf.offset=e,Gf}function Hc(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(!Hc(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Hc(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Mt=class Lh{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&&Hc(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 Lh.none;if(e instanceof Lh)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Mt.none=[];class Wc 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(ae.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(ae.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 jE(t,e,n){if(n.openStart>t.depth)throw new Wc("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Wc("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 _i(l,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:l,end:c}=IE(n,t);return _i(i,tx(t,l,c,e,r))}else return _i(i,Vc(t,e,r))}function ex(t,e){if(!e.type.compatibleContent(t.type))throw new Wc("Cannot join "+e.type.name+" onto "+t.type.name)}function Dh(t,e,n){let r=t.node(n);return ex(r,e.node(n)),r}function Ci(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 Nl(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&&(Ci(t.nodeAfter,r),i++));for(let c=i;c<l;c++)Ci(s.child(c),r);e&&e.depth==n&&e.textOffset&&Ci(e.nodeBefore,r)}function _i(t,e){return t.type.checkContent(e),t.copy(e)}function tx(t,e,n,r,s){let i=t.depth>s&&Dh(t,e,s+1),l=r.depth>s&&Dh(n,r,s+1),c=[];return Nl(null,t,s,c),i&&l&&e.index(s)==n.index(s)?(ex(i,l),Ci(_i(i,tx(t,e,n,r,s+1)),c)):(i&&Ci(_i(i,Vc(t,e,s+1)),c),Nl(e,n,s,c),l&&Ci(_i(l,Vc(n,r,s+1)),c)),Nl(r,null,s,c),new ae(c)}function Vc(t,e,n){let r=[];if(Nl(null,t,n,r),t.depth>n){let s=Dh(t,e,n+1);Ci(_i(s,Vc(t,e,n+1)),r)}return Nl(e,null,n,r),new ae(r)}function IE(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(ae.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class Ll{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 Mt.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 Kc(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:d}=l.content.findIndex(i),f=i-d;if(r.push(l,c,s+d),!f||(l=l.child(c),l.isText))break;i=f-1,s+=d+1}return new Ll(n,r,i)}static resolveCached(e,n){let r=Zy.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 Zy.set(e,r=new LE);let s=r.elts[r.i]=Ll.resolve(e,n);return r.i=(r.i+1)%DE,s}}class LE{constructor(){this.elts=[],this.i=0}}const DE=12,Zy=new WeakMap;class Kc{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 PE=Object.create(null);class Mr{constructor(e,n,r,s=Mt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||ae.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&&Hc(this.attrs,n||e.defaultAttrs||PE)&&Mt.sameSet(this.marks,r||Mt.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 jE(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 Ll.resolveCached(this,e)}resolveNoCache(e){return Ll.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=ae.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 d=s;d<i;d++)if(!this.type.allowsMarks(r.child(d).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=Mt.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(!Mt.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=ae.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 Gc 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 Gc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Gc(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 Oi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new BE(e,n);if(r.next==null)return Oi.empty;let s=rx(r);r.next&&r.err("Unexpected trailing text");let i=VE(WE(s));return KE(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 d=l.matchFragment(e,r);if(d&&(!n||d.validEnd))return ae.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:p,next:m}=l.next[f];if(!(p.isText||p.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let y=i(m,c.concat(p));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:d}=i.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!s.type||d.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
|
-
`)}}Oi.empty=new Oi(!0);class BE{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(zE(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function zE(t){let e=[];do e.push($E(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function $E(t){let e=HE(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=FE(t,e);else break;return e}function eb(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function FE(t,e){let n=eb(t),r=n;return t.eat(",")&&(t.next!="}"?r=eb(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function UE(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 HE(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=UE(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 WE(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(l,c,d){let f={term:d,to:c};return e[l].push(f),f}function s(l,c){l.forEach(d=>d.to=c)}function i(l,c){if(l.type=="choice")return l.exprs.reduce((d,f)=>d.concat(i(f,c)),[]);if(l.type=="seq")for(let d=0;;d++){let f=i(l.exprs[d],c);if(d==l.exprs.length-1)return f;s(f,c=n())}else if(l.type=="star"){let d=n();return r(c,d),s(i(l.expr,d),d),[r(d)]}else if(l.type=="plus"){let d=n();return s(i(l.expr,c),d),s(i(l.expr,d),d),[r(d)]}else{if(l.type=="opt")return[r(c)].concat(i(l.expr,c));if(l.type=="range"){let d=c;for(let f=0;f<l.min;f++){let p=n();s(i(l.expr,d),p),d=p}if(l.max==-1)s(i(l.expr,d),d);else for(let f=l.min;f<l.max;f++){let p=n();r(d,p),s(i(l.expr,d),p),d=p}return[r(d)]}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 tb(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:d}=i[l];!c&&n.indexOf(d)==-1&&r(d)}}}function VE(t){let e=Object.create(null);return n(tb(t,0));function n(r){let s=[];r.forEach(l=>{t[l].forEach(({term:c,to:d})=>{if(!c)return;let f;for(let p=0;p<s.length;p++)s[p][0]==c&&(f=s[p][1]);tb(t,d).forEach(p=>{f||s.push([c,f=[]]),f.indexOf(p)==-1&&f.push(p)})})});let i=e[r.join(",")]=new Oi(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 KE(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:d,next:f}=s.next[c];l.push(d.name),i&&!(d.isText||d.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 qE(t,r,e[r]);return n}let nb=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==Oi.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),ae.from(n),Mt.setFrom(r))}createChecked(e=null,n,r){return n=ae.from(n),this.checkContent(n),new Mr(this,this.computeAttrs(e),n,Mt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ae.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(ae.empty,!0);return i?new Mr(this,e,n.append(i),Mt.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:Mt.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 GE(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 qE{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?GE(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 Mt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Mt(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=Sn.from(e.nodes),n.marks=Sn.from(e.marks||{}),this.nodes=nb.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]=Oi.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?rb(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==""?[]:rb(this,l.split(" "))}this.nodeFromJSON=s=>Mr.fromJSON(this,s),this.markFromJSON=s=>Mt.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 nb){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 Gc(r,r.defaultAttrs,e,Mt.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 rb(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 d=t.marks[c];(s=="_"||d.spec.group&&d.spec.group.split(" ").indexOf(s)>-1)&&n.push(l=d)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function JE(t){return t.tag!=null}function YE(t){return t.style!=null}class Vs{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(JE(s))this.tags.push(s);else if(YE(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 ib(this,n,!1);return r.addAll(e,Mt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ib(this,n,!0);return r.addAll(e,Mt.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(ZE(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 d=l.getAttrs(n);if(d===!1)continue;l.attrs=d||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=ob(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=ob(l)),l.node||l.ignore||l.mark||(l.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Vs(e,Vs.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},QE={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},fx={ol:!0,ul:!0},Dl=1,Ph=2,Cl=4;function sb(t,e,n){return e!=null?(e?Dl:0)|(e==="full"?Ph:0):t&&t.whitespace=="pre"?Dl|Ph:n&~Cl}class ac{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=Mt.none,this.match=i||(l&Cl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ae.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&Dl)){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=ae.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ae.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 ib{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=sb(null,n.preserveWhitespace,0)|(r?Cl:0);s?i=new ac(s.type,s.attrs,Mt.none,!0,n.topMatch||s.type.contentMatch,l):r?i=new ac(null,null,Mt.none,!0,null,l):i=new ac(e.schema.topNodeType,null,Mt.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&Ph?"full":this.localPreserveWS||(s.options&Dl)>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 d=0;d<c.length;d++)d&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[d]&&this.insertNode(l.text(c[d]),n,!/\S/.test(c[d]));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],d=e.previousSibling;(!c||d&&d.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&&XE(e);let d=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(d?d.ignore:QE.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,n);else if(!d||d.skip||d.closeParent){d&&d.closeParent?this.open=Math.max(0,this.open-1):d&&d.skip.nodeType&&(e=d.skip);let f,p=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=d&&d.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),f&&this.sync(i),this.needsBlock=p}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,d,f,d.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 d=this.parser.matchStyle(i,l,this,c);if(!d)break;if(d.ignore)return null;if(d.clearMark?n=n.filter(f=>!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)c=d;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 d=this.enter(l,n.attrs||null,r,n.preserveWhitespace);d&&(i=!0,r=d)}else{let d=this.parser.schema.marks[n.mark];r=r.concat(d.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(d=>this.insertNode(d,r,!1));else{let d=e;typeof n.contentElement=="string"?d=e.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(e):n.contentElement&&(d=n.contentElement),this.findAround(e,d,!0),this.addAll(d,r),this.findAround(e,d,!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 d=this.nodes[l],f=d.findWrapping(e);if(f&&(!s||s.length>f.length+c)&&(s=f,i=d,!f.length))break;if(d.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=Mt.none;for(let c of s.concat(e.marks))(i.type?i.type.allowsMarkType(c.type):lb(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=sb(e,i,l.options);l.options&Cl&&l.content.length==0&&(c|=Cl);let d=Mt.none;return r=r.filter(f=>(l.type?l.type.allowsMarkType(f.type):lb(f.type,e))?(d=f.addToSet(d),!1):!0),this.nodes.push(new ac(e,n,d,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|=Dl)}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,d)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;d>=i;d--)if(l(c-1,d))return!0;return!1}else{let p=d>0||d==0&&s?this.nodes[d].type:r&&d>=i?r.node(d-i).type:null;if(!p||p.name!=f&&!p.isInGroup(f))return!1;d--}}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 XE(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 ZE(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ob(t){let e={};for(let n in t)e[n]=t[n];return e}function lb(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 d=0;d<c.edgeCount;d++){let{type:f,next:p}=c.edge(d);if(f==e||i.indexOf(p)<0&&l(p))return!0}};if(l(s.contentMatch))return!0}}class Bi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=qf(n).createDocumentFragment());let s=r,i=[];return e.forEach(l=>{if(i.length||l.marks.length){let c=0,d=0;for(;c<i.length&&d<l.marks.length;){let f=l.marks[d];if(!this.marks[f.type.name]){d++;continue}if(!f.eq(i[c][0])||f.type.spec.spanning===!1)break;c++,d++}for(;c<i.length;)s=i.pop()[1];for(;d<l.marks.length;){let f=l.marks[d++],p=this.serializeMark(f,l.isInline,n);p&&(i.push([f,s]),s.appendChild(p.dom),s=p.contentDOM||p.dom)}}s.appendChild(this.serializeNodeInner(l,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Lc(qf(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&&Lc(qf(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Lc(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Bi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ab(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ab(e.marks)}}function ab(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function qf(t){return t.document||window.document}const cb=new WeakMap;function eN(t){let e=cb.get(t);return e===void 0&&cb.set(t,e=tN(t)),e}function tN(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 Lc(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=eN(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,d=n?t.createElementNS(n,s):t.createElement(s),f=e[1],p=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){p=2;for(let m in f)if(f[m]!=null){let y=m.indexOf(" ");y>0?d.setAttributeNS(m.slice(0,y),m.slice(y+1),f[m]):m=="style"&&d.style?d.style.cssText=f[m]:d.setAttribute(m,f[m])}}for(let m=p;m<e.length;m++){let y=e[m];if(y===0){if(m<e.length-1||m>p)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:b,contentDOM:v}=Lc(t,y,n,r);if(d.appendChild(b),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:d,contentDOM:c}}const hx=65535,px=Math.pow(2,16);function nN(t,e){return t+e*px}function ub(t){return t&hx}function rN(t){return(t-(t&hx))/px}const mx=1,gx=2,Dc=4,yx=8;class Bh{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|Dc))>0}get deletedAfter(){return(this.delInfo&(gx|Dc))>0}get deletedAcross(){return(this.delInfo&Dc)>0}}class nr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&nr.empty)return nr.empty}recover(e){let n=0,r=ub(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+rN(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 d=this.ranges[c]-(this.inverted?s:0);if(d>e)break;let f=this.ranges[c+i],p=this.ranges[c+l],m=d+f;if(e<=m){let y=f?e==d?-1:e==m?1:n:n,b=d+s+(y<0?0:p);if(r)return b;let v=e==(n<0?d:m)?null:nN(c/3,e-d),w=e==d?gx:e==m?mx:Dc;return(n<0?e!=d:e!=m)&&(w|=yx),new Bh(b,w,v)}s+=p-f}return r?e+s:new Bh(e+s,0,null)}touches(e,n){let r=0,s=ub(n),i=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let d=this.ranges[c]-(this.inverted?r:0);if(d>e)break;let f=this.ranges[c+i],p=d+f;if(e<=p&&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),d=l+(this.inverted?0:i),f=this.ranges[s+n],p=this.ranges[s+r];e(c,c+f,d,d+p),i+=p-f}}invert(){return new nr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?nr.empty:new nr(e<0?[0,-e,0]:[0,0,e])}}nr.empty=new nr([]);class Pl{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 Pl(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 Pl;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 d=this.getMirror(i);if(d!=null&&d>i&&d<this.to){i=d,e=this._maps[d].recover(c.recover);continue}}s|=c.delInfo,e=c.pos}return r?e:new Bh(e,s,null)}}const Jf=Object.create(null);class Ln{getMap(){return nr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Jf[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 Jf)throw new RangeError("Duplicate use of step JSON ID "+e);return Jf[e]=n,n.prototype.jsonID=e,n}}class sn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new sn(e,null)}static fail(e){return new sn(null,e)}static fromReplace(e,n,r,s){try{return sn.ok(e.replace(n,r,s))}catch(i){if(i instanceof Wc)return sn.fail(i.message);throw i}}}function vp(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(vp(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return ae.fromArray(r)}class Us extends Ln{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(vp(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 sn.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 Us(n.pos,r.pos,this.mark)}merge(e){return e instanceof Us&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Us(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 Us(n.from,n.to,e.markFromJSON(n.mark))}}Ln.jsonID("addMark",Us);class Tr extends Ln{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(vp(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return sn.fromReplace(e,this.from,this.to,r)}invert(){return new Us(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))}}Ln.jsonID("removeMark",Tr);class Hs extends Ln{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return sn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return sn.fromReplace(e,this.pos,this.pos+1,new Se(ae.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 Hs(this.pos,n.marks[s]);return new Hs(this.pos,this.mark)}}return new Ri(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Hs(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 Hs(n.pos,e.markFromJSON(n.mark))}}Ln.jsonID("addNodeMark",Hs);class Ri extends Ln{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return sn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return sn.fromReplace(e,this.pos,this.pos+1,new Se(ae.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Hs(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ri(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 Ri(n.pos,e.markFromJSON(n.mark))}}Ln.jsonID("removeNodeMark",Ri);class mn extends Ln{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&zh(e,this.from,this.to)?sn.fail("Structure replace would overwrite content"):sn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new nr([this.from,this.to-this.from,this.slice.size])}invert(e){return new mn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new mn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof mn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?Se.empty:new Se(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new mn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?Se.empty:new Se(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new mn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new mn(n.from,n.to,Se.fromJSON(e,n.slice),!!n.structure)}}Ln.jsonID("replace",mn);class gn extends Ln{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&&(zh(e,this.from,this.gapFrom)||zh(e,this.gapTo,this.to)))return sn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return sn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?sn.fromReplace(e,this.from,this.to,r):sn.fail("Content does not fit in gap")}getMap(){return new nr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new gn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new gn(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new gn(n.from,n.to,n.gapFrom,n.gapTo,Se.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ln.jsonID("replaceAround",gn);function zh(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 sN(t,e,n,r){let s=[],i=[],l,c;t.doc.nodesBetween(e,n,(d,f,p)=>{if(!d.isInline)return;let m=d.marks;if(!r.isInSet(m)&&p.type.allowsMarkType(r.type)){let y=Math.max(f,e),b=Math.min(f+d.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 Us(y,b,r))}}),s.forEach(d=>t.step(d)),i.forEach(d=>t.step(d))}function iN(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(l,c)=>{if(!l.isInline)return;i++;let d=null;if(r instanceof Fu){let f=l.marks,p;for(;p=r.isInSet(f);)(d||(d=[])).push(p),f=p.removeFromSet(f)}else r?r.isInSet(l.marks)&&(d=[r]):d=l.marks;if(d&&d.length){let f=Math.min(c+l.nodeSize,n);for(let p=0;p<d.length;p++){let m=d[p],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 xp(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),l=[],c=e+1;for(let d=0;d<i.childCount;d++){let f=i.child(d),p=c+f.nodeSize,m=r.matchType(f.type);if(!m)l.push(new mn(c,p,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,p,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(ae.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new mn(c+y.index,c+y.index+y[0].length,v))}}c=p}if(!r.validEnd){let d=r.fillBefore(ae.empty,!0);t.replace(c,c,new Se(d,0,0))}for(let d=l.length-1;d>=0;d--)t.step(l[d])}function oN(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Oo(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,d=t.$to.indexAfter(r)-i;if(r<t.depth&&l.canReplace(c,d,n))return r;if(r==0||l.type.spec.isolating||!oN(l,c,d))break;c&&(s=1),d<l.childCount&&(i=1)}return null}function lN(t,e,n){let{$from:r,$to:s,depth:i}=e,l=r.before(i+1),c=s.after(i+1),d=l,f=c,p=ae.empty,m=0;for(let v=i,w=!1;v>n;v--)w||r.index(v)>0?(w=!0,p=ae.from(r.node(v).copy(p)),m++):d--;let y=ae.empty,b=0;for(let v=i,w=!1;v>n;v--)w||s.after(v+1)<s.end(v)?(w=!0,y=ae.from(s.node(v).copy(y)),b++):f++;t.step(new gn(d,f,l,c,new Se(p.append(y),m,b),p.size-m,!0))}function wp(t,e,n=null,r=t){let s=aN(t,e),i=s&&cN(r,e);return i?s.map(db).concat({type:e,attrs:n}).concat(i.map(db)):null}function db(t){return{type:t,attrs:null}}function aN(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 cN(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 d=(l.length?l[l.length-1]:e).contentMatch;for(let f=r;d&&f<s;f++)d=d.matchType(n.child(f).type);return!d||!d.validEnd?null:l}function uN(t,e,n){let r=ae.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=ae.from(n[l].type.create(n[l].attrs,r))}let s=e.start,i=e.end;t.step(new gn(s,i,s,i,new Se(r,0,0),n.length,!0))}function dN(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 d=typeof s=="function"?s(l):s;if(l.isTextblock&&!l.hasMarkup(r,d)&&fN(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),xp(t,t.mapping.slice(i).map(c,1),r,void 0,f===null);let p=t.mapping.slice(i),m=p.map(c,1),y=p.map(c+l.nodeSize,1);return t.step(new gn(m,y,m+1,y-1,new Se(ae.from(r.create(d,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 d=t.mapping.slice(r).map(n+1+i+l.index);t.replaceWith(d,d+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 fN(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function hN(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 gn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Se(ae.from(l),0,0),1,!0))}function ds(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,p=n-2;f>i;f--,p--){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[p+1];v&&(b=b.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[p]||m;if(!m.canReplace(y+1,m.childCount)||!w.type.validContent(b))return!1}let c=s.indexAfter(i),d=r&&r[0];return s.node(i).canReplaceWith(c,c,d?d.type:s.node(i+1).type)}function pN(t,e,n=1,r){let s=t.doc.resolve(e),i=ae.empty,l=ae.empty;for(let c=s.depth,d=s.depth-n,f=n-1;c>d;c--,f--){i=ae.from(s.node(c).copy(i));let p=r&&r[f];l=ae.from(p?p.type.create(p.attrs,l):s.node(c).copy(l))}t.step(new mn(e,e,new Se(i.append(l),n,n),!0))}function Zs(t,e){let n=t.resolve(e),r=n.index();return xx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function mN(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&&mN(t,e))}function Uu(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 gN(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 p=l.whitespace=="pre",m=!!l.contentMatch.matchType(s);p&&!m?r=!1:!p&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let p=t.doc.resolve(e+n);vx(t,p.node(),p.before(),c)}l.inlineContent&&xp(t,e+n-1,l,i.node().contentMatchAt(i.index()),r==null);let d=t.mapping.slice(c),f=d.map(e-n);if(t.step(new mn(f,d.map(e+n,-1),Se.empty,!0)),r===!0){let p=t.doc.resolve(f);bx(t,p.node(),p.before(),t.steps.length)}return t}function yN(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,d=r.index(l)+(c>0?1:0),f=r.node(l),p=!1;if(i==1)p=f.canReplace(d,d,s);else{let m=f.contentMatchAt(d).findWrapping(s.firstChild.type);p=m&&f.canReplaceWith(d,d,m[0])}if(p)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Hu(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 mn(e,n,r):new bN(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 bN{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ae.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=ae.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 d=new Se(i,l,c);return e>-1?new gn(r.pos,e,this.$to.pos,this.$to.end(),d,n):d.size||r.pos!=this.$to.pos?new mn(r.pos,s.pos,d):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=Yf(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:d,match:f}=this.frontier[c],p,m=null;if(n==1&&(l?f.matchType(l.type)||(m=f.fillBefore(ae.from(l),!1)):i&&d.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&l&&(p=f.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:p};if(i&&f.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Yf(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=Yf(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Se(xl(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Se(xl(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,d=l.openStart-e,f=0,p=[],{match:m,type:y}=this.frontier[n];if(s){for(let w=0;w<s.childCount;w++)p.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||d==0||w.content.size)&&(m=k,p.push(Sx(w.mark(y.allowedMarks(w.marks)),f==1?d:0,f==c.childCount?b:-1)))}let v=f==c.childCount;v||(b=-1),this.placed=wl(this.placed,n,ae.from(p)),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(xl(l.content,e-1,1),e-1,b<0?l.openEnd:e-1):new Se(xl(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||!Qf(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=Qf(e,n,s,r,i);if(l){for(let c=n-1;c>=0;c--){let{match:d,type:f}=this.frontier[c],p=Qf(e,c,f,d,!0);if(!p||p.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=wl(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=wl(this.placed,this.depth,ae.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ae.empty,!0);n.childCount&&(this.placed=wl(this.placed,this.frontier.length,n))}}function xl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(xl(t.firstChild.content,e-1,n)))}function wl(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(wl(t.lastChild.content,e-1,n)))}function Yf(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(ae.empty,!0)))),t.copy(r)}function Qf(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&&!vN(n,i.content,l)?c:null}function vN(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function xN(t){return t.spec.defining||t.spec.definingForContent}function wN(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 mn(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 d=l.indexOf(c),f=[],p=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=p-1;y>=0;y--){let b=f[y],v=xN(b.type);if(v&&!b.sameMarkup(s.node(Math.abs(c)-1)))p=y;else if(v||!b.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let b=(y+p+1)%(r.openStart+1),v=f[b];if(v)for(let w=0;w<l.length;w++){let k=l[(w+d)%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(ae.empty,!0))}return t}function kN(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=yN(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Se(ae.from(r),0,0))}function SN(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],d=l==i.length-1;if(d&&c==0||r.node(c).type.contentMatch.validEnd)return t.delete(r.start(c),s.end(c));if(c>0&&(d||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 wo extends Ln{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 sn.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 sn.fromReplace(e,this.pos,this.pos+1,new Se(ae.from(s),0,n.isLeaf?0:1))}getMap(){return nr.empty}invert(e){return new wo(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 wo(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 wo(n.pos,n.attr,n.value)}}Ln.jsonID("attr",wo);class Bl extends Ln{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 sn.ok(r)}getMap(){return nr.empty}invert(e){return new Bl(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 Bl(n.attr,n.value)}}Ln.jsonID("docAttr",Bl);let Eo=class extends Error{};Eo=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Eo.prototype=Object.create(Error.prototype);Eo.prototype.constructor=Eo;Eo.prototype.name="TransformError";class kp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Pl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Eo(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,d)=>{e=Math.min(e,c),n=Math.max(n,d)})}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=Hu(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Se(ae.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 wN(this,e,n,r),this}replaceRangeWith(e,n,r){return kN(this,e,n,r),this}deleteRange(e,n){return SN(this,e,n),this}lift(e,n){return lN(this,e,n),this}join(e,n=1){return gN(this,e,n),this}wrap(e,n){return uN(this,e,n),this}setBlockType(e,n=e,r,s=null){return dN(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return hN(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new wo(e,n,r)),this}setDocAttribute(e,n){return this.step(new Bl(e,n)),this}addNodeMark(e,n){return this.step(new Hs(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 Mt)n.isInSet(r.marks)&&this.step(new Ri(e,n));else{let s=r.marks,i,l=[];for(;i=n.isInSet(s);)l.push(new Ri(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 pN(this,e,n,r),this}addMark(e,n,r){return sN(this,e,n,r),this}removeMark(e,n,r){return iN(this,e,n,r),this}clearIncompatible(e,n,r){return xp(this,e,n,r),this}}const Xf=Object.create(null);class Qe{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:d,$to:f}=l[c],p=e.mapping.slice(i);e.replaceRange(p.map(d.pos),p.map(f.pos),c?Se.empty:n),c==0&&pb(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],d=e.mapping.slice(r),f=d.map(l.pos),p=d.map(c.pos);i?e.deleteRange(f,p):(e.replaceRangeWith(f,p,n),pb(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Ue(e):mo(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?mo(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):mo(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 sr(e.node(0))}static atStart(e){return mo(e,e,0,0,1)||new sr(e)}static atEnd(e){return mo(e,e,e.content.size,e.childCount,-1)||new sr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Xf[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 Xf)throw new RangeError("Duplicate use of selection JSON ID "+e);return Xf[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ue.between(this.$anchor,this.$head).getBookmark()}}Qe.prototype.visible=!0;class Cx{constructor(e,n){this.$from=e,this.$to=n}}let fb=!1;function hb(t){!fb&&!t.parent.inlineContent&&(fb=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ue extends Qe{constructor(e,n=e){hb(e),hb(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 Qe.near(r);let s=e.resolve(n.map(this.anchor));return new Ue(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 Ue&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Wu(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 Ue(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=Qe.findFrom(n,r,!0)||Qe.findFrom(n,-r,!0);if(i)n=i.$head;else return Qe.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Qe.findFrom(e,-r,!0)||Qe.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Ue(e,n)}}Qe.jsonID("text",Ue);class Wu{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Wu(e.map(this.anchor),e.map(this.head))}resolve(e){return Ue.between(e.resolve(this.anchor),e.resolve(this.head))}}class $e extends Qe{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?Qe.near(i):new $e(i)}content(){return new Se(ae.from(this.node),0,0)}eq(e){return e instanceof $e&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Sp(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new $e(e.resolve(n.anchor))}static create(e,n){return new $e(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}$e.prototype.visible=!1;Qe.jsonID("node",$e);class Sp{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Wu(r,r):new Sp(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&$e.isSelectable(r)?new $e(n):Qe.near(n)}}class sr extends Qe{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=Qe.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new sr(e)}map(e){return new sr(e)}eq(e){return e instanceof sr}getBookmark(){return EN}}Qe.jsonID("all",sr);const EN={map(){return this},resolve(t){return new sr(t)}};function mo(t,e,n,r,s,i=!1){if(e.inlineContent)return Ue.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&&$e.isSelectable(c))return $e.create(t,n-(s<0?c.nodeSize:0))}else{let d=mo(t,c,n+s,s<0?c.childCount:0,s,i);if(d)return d}n+=c.nodeSize*s}return null}function pb(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof mn||s instanceof gn))return;let i=t.mapping.maps[r],l;i.forEach((c,d,f,p)=>{l==null&&(l=p)}),t.setSelection(Qe.near(t.doc.resolve(l),n))}const mb=1,cc=2,gb=4;class NN extends kp{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|mb)&~cc,this.storedMarks=null,this}get selectionSet(){return(this.updated&mb)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=cc,this}ensureMarks(e){return Mt.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&cc)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~cc,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)||Mt.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(Qe.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|=gb,this}get scrolledIntoView(){return(this.updated&gb)>0}}function yb(t,e){return!e||!t?t:t.bind(e)}class kl{constructor(e,n,r){this.name=e,this.init=yb(n.init,r),this.apply=yb(n.apply,r)}}const CN=[new kl("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new kl("selection",{init(t,e){return t.selection||Qe.atStart(e.doc)},apply(t){return t.selection}}),new kl("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new kl("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Zf{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=CN.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 kl(r.key,r.spec.state,r))})}}class xo{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 d=s?s[l].n:0,f=s?s[l].state:this,p=d<n.length&&c.spec.appendTransaction.call(c,d?n.slice(d):n,f,r);if(p&&r.filterTransaction(p,l)){if(p.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(p),r=r.applyInner(p),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 xo(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 NN(this)}static create(e){let n=new Zf(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new xo(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 Zf(this.schema,e.plugins),r=n.fields,s=new xo(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 Zf(e.schema,e.plugins),i=new xo(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=Qe.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 d=r[c],f=d.spec.state;if(d.key==l.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[l.name]=f.fromJSON.call(d,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 Et{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 eh=Object.create(null);function Tx(t){return t in eh?t+"$"+ ++eh[t]:(eh[t]=0,t+"$")}class At{constructor(e="key"){this.key=Tx(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ep=(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=Np(r);if(!s){let l=r.blockRange(),c=l&&Oo(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&&(No(i,"end")||$e.isSelectable(i)))for(let l=r.depth;;l--){let c=Hu(t.doc,r.before(l),r.after(l),Se.empty);if(c&&c.slice.size<c.to-c.from){if(e){let d=t.tr.step(c);d.setSelection(No(i,"end")?Qe.findFrom(d.doc.resolve(d.mapping.map(s.pos,-1)),-1):$e.create(d.doc,s.pos-i.nodeSize)),e(d.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},_N=(t,e,n)=>{let r=Mx(t,n);if(!r)return!1;let s=Np(r);return s?Ox(t,s,e):!1},TN=(t,e,n)=>{let r=jx(t,n);if(!r)return!1;let s=Cp(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 p=s.lastChild;if(!p)return!1;s=p}let l=e.nodeAfter,c=l,d=e.pos+1;for(;!c.isTextblock;d++){if(c.type.spec.isolating)return!1;let p=c.firstChild;if(!p)return!1;c=p}let f=Hu(t.doc,i,d,Se.empty);if(!f||f.from!=i||f instanceof mn&&f.slice.size>=d-i)return!1;if(n){let p=t.tr.step(f);p.setSelection(Ue.create(p.doc,i)),n(p.scrollIntoView())}return!0}function No(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=Np(r)}let l=i&&i.nodeBefore;return!l||!$e.isSelectable(l)?!1:(e&&e(t.tr.setSelection($e.create(t.doc,i.pos-l.nodeSize)).scrollIntoView()),!0)};function Np(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 jx(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ix=(t,e,n)=>{let r=jx(t,n);if(!r)return!1;let s=Cp(r);if(!s)return!1;let i=s.nodeAfter;if(zx(t,s,e,1))return!0;if(r.parent.content.size==0&&(No(i,"start")||$e.isSelectable(i))){let l=Hu(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(No(i,"start")?Qe.findFrom(c.doc.resolve(c.mapping.map(s.pos)),1):$e.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=Cp(r)}let l=i&&i.nodeAfter;return!l||!$e.isSelectable(l)?!1:(e&&e(t.tr.setSelection($e.create(t.doc,i.pos)).scrollIntoView()),!0)};function Cp(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 MN=(t,e)=>{let n=t.selection,r=n instanceof $e,s;if(r){if(n.node.isTextblock||!Zs(t.doc,n.from))return!1;s=n.from}else if(s=Uu(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection($e.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},AN=(t,e)=>{let n=t.selection,r;if(n instanceof $e){if(n.node.isTextblock||!Zs(t.doc,n.to))return!1;r=n.to}else if(r=Uu(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},ON=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Oo(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 _p(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 RN=(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=_p(s.contentMatchAt(i));if(!l||!s.canReplaceWith(i,i,l))return!1;if(e){let c=n.after(),d=t.tr.replaceWith(c,c,l.createAndFill());d.setSelection(Qe.near(d.doc.resolve(c),1)),e(d.scrollIntoView())}return!0},Px=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof sr||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=_p(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(Ue.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(ds(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Oo(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function jN(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof $e&&e.selection.node.isBlock)return!r.parentOffset||!ds(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],l,c,d=!1,f=!1;for(let b=r.depth;;b--)if(r.node(b).isBlock){d=r.end(b)==r.pos+(r.depth-b),f=r.start(b)==r.pos-(r.depth-b),c=_p(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(d&&c?{type:c}:null),l=b;break}else{if(b==1)return!1;i.unshift(null)}let p=e.tr;(e.selection instanceof Ue||e.selection instanceof sr)&&p.deleteSelection();let m=p.mapping.map(r.pos),y=ds(p.doc,m,i.length,i);if(y||(i[0]=c?{type:c}:null,y=ds(p.doc,m,i.length,i)),!y)return!1;if(p.split(m,i.length,i),!d&&f&&r.node(l).type!=c){let b=p.mapping.map(r.before(l)),v=p.doc.resolve(b);c&&r.node(l-1).canReplaceWith(v.index(),v.index()+1,c)&&p.setNodeMarkup(p.mapping.map(r.before(l)),c)}return n&&n(p.scrollIntoView()),!0}}const IN=jN(),LN=(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($e.create(t.doc,s))),!0)};function DN(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||Zs(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,d=s.type.spec.isolating||i.type.spec.isolating;if(!d&&DN(t,e,n))return!0;let f=!d&&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=ae.empty;for(let N=l.length-1;N>=0;N--)v=ae.from(l[N].create(null,v));v=ae.from(s.copy(v));let w=t.tr.step(new gn(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&&Zs(w.doc,k.pos)&&w.join(k.pos),n(w.scrollIntoView())}return!0}let p=i.type.spec.isolating||r>0&&d?null:Qe.findFrom(e,1),m=p&&p.$from.blockRange(p.$to),y=m&&Oo(m);if(y!=null&&y>=e.depth)return n&&n(t.tr.lift(m,y).scrollIntoView()),!0;if(f&&No(i,"start",!0)&&No(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=ae.empty;for(let O=v.length-1;O>=0;O--)N=ae.from(v[O].copy(N));let C=t.tr.step(new gn(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 $x(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(Ue.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const PN=$x(-1),BN=$x(1);function zN(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,l=s.blockRange(i),c=l&&wp(l,t,e);return c?(r&&r(n.tr.wrap(l,c).scrollIntoView()),!0):!1}}function bb(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,(d,f)=>{if(s)return!1;if(!(!d.isTextblock||d.hasMarkup(t,e)))if(d.type==t)s=!0;else{let p=n.doc.resolve(f),m=p.index();s=p.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let l=0;l<n.selection.ranges.length;l++){let{$from:{pos:c},$to:{pos:d}}=n.selection.ranges[l];i.setBlockType(c,d,t,e)}r(i.scrollIntoView())}return!0}}function Tp(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Tp(Ep,Ax,Rx);Tp(Ep,Ix,Lx);Tp(Dx,Px,Bx,IN);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function $N(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 FN(c,l,t,e)?(r&&r(c.scrollIntoView()),!0):!1}}function FN(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 d=l.resolve(e.start-2);i=new Kc(d,d,e.depth),e.endIndex<e.parent.childCount&&(e=new Kc(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let c=wp(i,n,r,e);return c?(t&&UN(t,e,c,s,n),!0):!1}function UN(t,e,n,r,s){let i=ae.empty;for(let p=n.length-1;p>=0;p--)i=ae.from(n[p].type.create(n[p].attrs,i));t.step(new gn(e.start-(r?2:0),e.end,e.start,e.end,new Se(i,0,0),n.length,!0));let l=0;for(let p=0;p<n.length;p++)n[p].type==s&&(l=p+1);let c=n.length-l,d=e.start+n.length-(r?2:0),f=e.parent;for(let p=e.startIndex,m=e.endIndex,y=!0;p<m;p++,y=!1)!y&&ds(t.doc,d,c)&&(t.split(d,c),d+=2*c),d+=f.child(p).nodeSize;return t}function HN(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?WN(e,n,t,i):VN(e,n,i):!0:!1}}function WN(t,e,n,r){let s=t.tr,i=r.end,l=r.$to.end(r.depth);i<l&&(s.step(new gn(i-1,l,i,l,new Se(ae.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Kc(s.doc.resolve(r.$from.pos),s.doc.resolve(l),r.depth));const c=Oo(r);if(c==null)return!1;s.lift(r,c);let d=s.doc.resolve(s.mapping.map(i,-1)-1);return Zs(s.doc,d.pos)&&d.nodeBefore.type==d.nodeAfter.type&&s.join(d.pos),e(s.scrollIntoView()),!0}function VN(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,d=n.endIndex==s.childCount,f=i.node(-1),p=i.index(-1);if(!f.canReplace(p+(c?0:1),p+1,l.content.append(d?ae.empty:ae.from(s))))return!1;let m=i.pos,y=m+l.nodeSize;return r.step(new gn(m-(c?1:0),y+(d?1:0),m+1,y-1,new Se((c?ae.empty:ae.from(s.copy(ae.empty))).append(d?ae.empty:ae.from(s.copy(ae.empty))),c?0:1,d?0:1),c?0:1)),e(r.scrollIntoView()),!0}function KN(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,d=c.child(l-1);if(d.type!=t)return!1;if(n){let f=d.lastChild&&d.lastChild.type==c.type,p=ae.from(f?t.create():null),m=new Se(ae.from(t.create(null,ae.from(c.type.create(null,p)))),f?3:1,0),y=i.start,b=i.end;n(e.tr.step(new gn(y-(f?3:1),b,y,b,m,1,!0)).scrollIntoView())}return!0}}const Nn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Co=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let $h=null;const ls=function(t,e,n){let r=$h||($h=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},GN=function(){$h=null},ji=function(t,e,n,r){return n&&(vb(t,e,n,r,-1)||vb(t,e,n,r,1))},qN=/^(img|br|input|textarea|hr)$/i;function vb(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||ql(t)||qN.test(t.nodeName)||t.contentEditable=="false")return!1;e=Nn(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 JN(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&&!ql(t))e=Nn(t),t=t.parentNode;else return null}}function YN(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&&!ql(t))e=Nn(t)+1,t=t.parentNode;else return null}}function QN(t,e,n){for(let r=e==0,s=e==gr(t);r||s;){if(t==n)return!0;let i=Nn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==gr(t)}}function ql(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 Vu=function(t){return t.focusNode&&ji(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function wi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function XN(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ZN(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,xb=typeof document<"u"?document:null,ei=Hr&&Hr.userAgent||"",Fh=/Edge\/(\d+)/.exec(ei),Fx=/MSIE \d/.exec(ei),Uh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ei),Qn=!!(Fx||Uh||Fh),Ks=Fx?document.documentMode:Uh?+Uh[1]:Fh?+Fh[1]:0,yr=!Qn&&/gecko\/(\d+)/i.test(ei);yr&&+(/Firefox\/(\d+)/.exec(ei)||[0,0])[1];const Hh=!Qn&&/Chrome\/(\d+)/.exec(ei),_n=!!Hh,Ux=Hh?+Hh[1]:0,jn=!Qn&&!!Hr&&/Apple Computer/.test(Hr.vendor),_o=jn&&(/Mobile\/\w+/.test(ei)||!!Hr&&Hr.maxTouchPoints>2),mr=_o||(Hr?/Mac/.test(Hr.platform):!1),Hx=Hr?/Win/.test(Hr.platform):!1,cs=/Android \d/.test(ei),Jl=!!xb&&"webkitFontSmoothing"in xb.documentElement.style,eC=Jl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function tC(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 nC(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 wb(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=Co(l);continue}let c=l,d=c==i.body,f=d?tC(i):nC(c),p=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")?p=-(f.left-e.left+ts(s,"left")):e.right>f.right-ts(r,"right")&&(p=e.right-f.right+ts(s,"right")),p||m)if(d)i.defaultView.scrollBy(p,m);else{let b=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),p&&(c.scrollLeft+=p);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=d?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:Co(l)}}function rC(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 d=c.getBoundingClientRect();if(d.top>=n-20){r=c,s=d.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=Co(r));return e}function sC({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 fo=null;function iC(t){if(t.setActive)return t.setActive();if(fo)return t.focus(fo);let e=Wx(t);t.focus(fo==null?{get preventScroll(){return fo={preventScroll:!0},!0}}:void 0),fo||(fo=!1,Vx(e,0))}function Kx(t,e){let n,r=2e8,s,i=0,l=e.top,c=e.top,d,f;for(let p=t.firstChild,m=0;p;p=p.nextSibling,m++){let y;if(p.nodeType==1)y=p.getClientRects();else if(p.nodeType==3)y=ls(p).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=p,r=w,s=w&&n.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,p.nodeType==1&&w&&(i=m+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!d&&v.left<=e.left&&v.right>=e.left&&(d=p,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&&d&&(n=d,s=f,r=0),n&&n.nodeType==3?oC(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:Kx(n,s)}function oC(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=Ls(r,1);if(l.top!=l.bottom&&Mp(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 Mp(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function lC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function aC(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 cC(t,e,n,r){let s=-1;for(let i=e,l=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),d;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((d=c.dom.getBoundingClientRect()).width||d.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!l&&d.left>r.left||d.top>r.top?s=c.posBefore:(!l&&d.right<r.left||d.bottom<r.top)&&(s=c.posAfter),l=!0),!c.contentDOM&&s<0&&!c.node.isText))return(c.node.isBlock?r.top<(d.top+d.bottom)/2:r.left<(d.left+d.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 d=0;d<c.length;d++){let f=c[d];if(Mp(e,f))return Gx(l,e,f)}}if((i=(i+1)%r)==s)break}return t}function uC(t,e){let n=t.dom.ownerDocument,r,s=0,i=ZN(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(!Mp(e,f)||(l=Gx(t.dom,e,f),!l))return null}if(jn)for(let f=l;r&&f;f=Co(f))f.draggable&&(r=void 0);if(l=lC(l,e),r){if(yr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let p=r.childNodes[s],m;p.nodeName=="IMG"&&(m=p.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let f;Jl&&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=cC(t,r,s,e))}c==null&&(c=aC(t,l,e));let d=t.docView.nearestDesc(l,!0);return{pos:c,inside:d?d.posAtStart-d.border:-1}}function kb(t){return t.top<t.bottom||t.left<t.right}function Ls(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(kb(r))return r}return Array.prototype.find.call(n,kb)||t.getBoundingClientRect()}const dC=/[\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=Jl||yr;if(r.nodeType==3)if(l&&(dC.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let d=Ls(ls(r,s,s),n);if(yr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=Ls(ls(r,s-1,s-1),-1);if(f.top==d.top){let p=Ls(ls(r,s,s+1),-1);if(p.top!=d.top)return ml(p,p.left<f.left)}}return d}else{let d=s,f=s,p=n<0?1:-1;return n<0&&!s?(f++,p=-1):n>=0&&s==r.nodeValue.length?(d--,p=1):n<0?d--:f++,ml(Ls(ls(r,d,f),p),p<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==gr(r))){let d=r.childNodes[s-1];if(d.nodeType==1)return th(d.getBoundingClientRect(),!1)}if(i==null&&s<gr(r)){let d=r.childNodes[s];if(d.nodeType==1)return th(d.getBoundingClientRect(),!0)}return th(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==gr(r))){let d=r.childNodes[s-1],f=d.nodeType==3?ls(d,gr(d)-(l?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(f)return ml(Ls(f,1),!1)}if(i==null&&s<gr(r)){let d=r.childNodes[s];for(;d.pmViewDesc&&d.pmViewDesc.ignoreForCoords;)d=d.nextSibling;let f=d?d.nodeType==3?ls(d,0,l?0:1):d.nodeType==1?d:null:null;if(f)return ml(Ls(f,-1),!0)}return ml(Ls(r.nodeType==3?ls(r):r,-n),n>=0)}function ml(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 th(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 fC(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 d;if(c.nodeType==1)d=c.getClientRects();else if(c.nodeType==3)d=ls(c,0,c.nodeValue.length).getClientRects();else continue;for(let f=0;f<d.length;f++){let p=d[f];if(p.bottom>p.top+1&&(n=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const hC=/[\u0590-\u08ac]/;function pC(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?!hC.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:l:Jx(t,e,()=>{let{focusNode:d,focusOffset:f,anchorNode:p,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)||d==v&&f==w;try{c.collapse(p,m),d&&(d!=p||f!=m)&&c.extend&&c.extend(d,f)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let Sb=null,Eb=null,Nb=!1;function mC(t,e,n){return Sb==e&&Eb==n?Nb:(Sb=e,Eb=n,Nb=n=="up"||n=="down"?fC(t,e,n):pC(t,e,n))}const br=0,Cb=1,ki=2,Wr=3;class Yl{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>Nn(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?Nn(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?Nn(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 d=this.children[c],f=l+d.size;if(s==-1&&e<=f){let p=l+d.border;if(e>=p&&n<=f-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(e,n,p);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=Nn(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 p=c+1;p<this.children.length;p++){let m=this.children[p];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=Nn(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),d=n==e?c:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),p=r.domSelectionRange(),m=!1;if((yr||jn)&&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=d={node:k.parentNode,offset:Nn(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&&p.focusNode&&p.focusNode!=d.node&&p.focusNode.nodeType==1){let b=p.focusNode.childNodes[p.focusOffset];b&&b.contentEditable=="false"&&(s=!0)}if(!(s||m&&jn)&&ji(c.node,c.offset,p.anchorNode,p.anchorOffset)&&ji(d.node,d.offset,p.focusNode,p.focusOffset))return;let y=!1;if((f.extend||e==n)&&!(m&&yr)){f.collapse(c.node,c.offset);try{e!=n&&f.extend(d.node,d.offset),y=!0}catch{}}if(!y){if(e>n){let v=c;c=d,d=v}let b=document.createRange();b.setEnd(d.node,d.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,d=l-i.border;if(e>=c&&n<=d){this.dirty=e==r||n==l?ki:Cb,e==c&&n==d&&(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?ki:Wr}r=l}this.dirty=ki}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ki:Cb;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 Yl{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 gC extends Yl{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 Yl{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=Bi.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=Vh(i,n,l,r)),e>0&&(i=Vh(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 Gs extends Yl{constructor(e,n,r,s,i,l,c,d,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],d,f=c&&c(n,i,()=>{if(!d)return l;if(d.parent)return d.parent.posBeforeChild(d)},r,s),p=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!p)p=document.createTextNode(n.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:m}=Bi.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),n.type.spec.draggable&&(p.draggable=!0));let y=p;return p=ew(p,r,n),f?d=new yC(e,n,r,s,p,m||null,y,f,i,l+1):n.isText?new Ku(e,n,r,s,p,y,i):new Gs(e,n,r,s,p,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=()=>ae.empty)}return e}matchesNode(e,n,r){return this.dirty==br&&e.eq(this.node)&&qc(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,d=new vC(this,l&&l.node,e);kC(this.node,this.innerDeco,(f,p,m)=>{f.spec.marks?d.syncToMarks(f.spec.marks,r,e,p):f.type.side>=0&&!m&&d.syncToMarks(p==this.node.childCount?Mt.none:this.node.child(p).marks,r,e,p),d.placeWidget(f,e,s)},(f,p,m,y)=>{d.syncToMarks(f.marks,r,e,y);let b;d.findNodeMatch(f,p,m,y)||c&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(b=d.findIndexWithChild(i.node))>-1&&d.updateNodeAt(f,p,m,b,e)||d.updateNextNode(f,p,m,e,y,s)||d.addNode(f,p,m,e,s),s+=f.nodeSize}),d.syncToMarks([],r,e,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==ki)&&(l&&this.protectLocalComposition(e,l),Xx(this.contentDOM,this.children,e),_o&&SC(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof Ue)||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=EC(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 gC(this,i,n,s);e.input.compositionNodes.push(l),this.children=Vh(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(qc(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Zx(this.dom,this.nodeDOM,Wh(this.outerDeco,this.node,n),Wh(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 _b(t,e,n,r,s){ew(r,e,t);let i=new Gs(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Ku extends Gs{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 Ku(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 Yl{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 yC extends Gs{constructor(e,n,r,s,i,l,c,d,f,p){super(e,n,r,s,i,l,c,f,p),this.spec=d}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=Tb(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(c,r);if(l instanceof Ii){let d=r?r.previousSibling:t.lastChild;Xx(l.contentDOM,l.children,n),r=d?d.nextSibling:t.firstChild}}for(;r;)r=Tb(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const _l=function(t){t&&(this.nodeName=t)};_l.prototype=Object.create(null);const Si=[new _l];function Wh(t,e,n){if(t.length==0)return Si;let r=n?Si[0]:new _l,s=[r];for(let i=0;i<t.length;i++){let l=t[i].type.attrs;if(l){l.nodeName&&s.push(r=new _l(l.nodeName));for(let c in l){let d=l[c];d!=null&&(n&&s.length==1&&s.push(r=new _l(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+d:c=="style"?r.style=(r.style?r.style+";":"")+d:c!="nodeName"&&(r[c]=d))}}}return s}function Zx(t,e,n,r){if(n==Si&&r==Si)return e;let s=e;for(let i=0;i<r.length;i++){let l=r[i],c=n[i];if(i){let d;c&&c.nodeName==l.nodeName&&s!=t&&(d=s.parentNode)&&d.nodeName.toLowerCase()==l.nodeName||(d=document.createElement(l.nodeName),d.pmIsDeco=!0,d.appendChild(s),c=Si[0]),s=d}bC(s,c||Si[0],l)}return s}function bC(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,Si,Wh(e,n,t.nodeType!=1))}function qc(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 Tb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class vC{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=xC(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 d=-1,f=this.top.children.length;s<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let p=this.index;p<f;p++){let m=this.top.children[p];if(m.matchesMark(e[l])&&!this.isLocked(m.dom)){d=p;break}}if(d>-1)d>this.index&&(this.changed=!0,this.destroyBetween(this.index,d)),this.top=this.top.children[this.index];else{let p=Ii.create(this.top,e[l],n,r);this.top.children.splice(this.index,0,p),this.top=p,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,d=Math.min(this.top.children.length,c+5);c<d;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=ki),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 d=this.top.children[c];if(d instanceof Gs){let f=this.preMatch.matched.get(d);if(f!=null&&f!=i)return!1;let p=d.dom,m,y=this.isLocked(p)&&!(e.isText&&d.node&&d.node.isText&&d.nodeDOM.nodeValue==e.text&&d.dirty!=Wr&&qc(n,d.outerDeco));if(!y&&d.update(e,n,r,s))return this.destroyBetween(this.index,c),d.dom!=p&&(this.changed=!0),this.index++,!0;if(!y&&(m=this.recreateWrapper(d,e,n,r,s,l)))return this.destroyBetween(this.index,c),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=ki,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)||!qc(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let c=Gs.create(this.top,n,r,s,i,l);if(c.contentDOM){c.children=e.children,e.children=[];for(let d of c.children)d.parent=c}return e.destroy(),c}addNode(e,n,r,s,i){let l=Gs.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 Ku)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((jn||_n)&&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 xC(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 d=c.node;if(d){if(d!=t.child(s-1))break;--s,i.set(c,s),l.push(c)}}return{index:s,matched:i,matches:l.reverse()}}function wC(t,e){return t.type.side-e.type.side}function kC(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let f=0;f<t.childCount;f++){let p=t.child(f);r(p,s,e.forChild(i,p),f),i+=p.nodeSize}return}let l=0,c=[],d=null;for(let f=0;;){let p,m;for(;l<s.length&&s[l].to==i;){let k=s[l++];k.widget&&(p?(m||(m=[p])).push(k):p=k)}if(p)if(m){m.sort(wC);for(let k=0;k<m.length;k++)n(m[k],f,!!d)}else n(p,f,!!d);let y,b;if(d)b=-1,y=d,d=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&&(d=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 SC(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 EC(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 d=l.text;for(;s<t.childCount;){let f=t.child(s++);if(i+=f.nodeSize,!f.isText)break;d+=f.text}if(i>=n){if(i>=r&&d.slice(r-e.length-c,r-c)==e)return r-e.length;let f=c<r?d.lastIndexOf(e,r-c-1):-1;if(f>=0&&f+e.length+c>=n)return c+f;if(n==r&&d.length>=r+e.length-c&&d.slice(r-c,r-c+e.length)==e)return r}}return-1}function Vh(t,e,n,r,s){let i=[];for(let l=0,c=0;l<t.length;l++){let d=t[l],f=c,p=c+=d.size;f>=n||p<=e?i.push(d):(f<e&&i.push(d.slice(0,e-f,r)),s&&(i.push(s),s=void 0),p>n&&i.push(d.slice(n-f,d.size,r)))}return i}function Ap(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),d,f;if(Vu(n)){for(d=l;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&$e.isSelectable(m)&&s.parent&&!(m.isInline&&QN(n.focusNode,n.focusOffset,s.dom))){let y=s.posBefore;f=new $e(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;[d,l]=y==t.state.selection.anchor?[y,m]:[m,y],c=r.resolve(l)}else d=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(d<0)return null}let p=r.resolve(d);if(!f){let m=e=="pointer"||t.state.selection.head<c.pos&&!i?1:-1;f=Op(t,p,c,m)}return f}function tw(t){return t.editable?t.hasFocus():rw(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function fs(t,e=!1){let n=t.state.selection;if(nw(t,n),!!tw(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&_n){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&ji(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)CC(t);else{let{anchor:r,head:s}=n,i,l;Mb&&!(n instanceof Ue)&&(n.$from.parent.inlineContent||(i=Ab(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Ab(t,n.to))),t.docView.setSelection(r,s,t,e),Mb&&(i&&Ob(i),l&&Ob(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&NC(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Mb=jn||_n&&Ux<63;function Ab(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(jn&&s&&s.contentEditable=="false")return nh(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return nh(s);if(i)return nh(i)}}function nh(t){return t.contentEditable="true",jn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Ob(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function NC(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 CC(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Nn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Qn&&Ks<=11&&(n.disabled=!0,n.disabled=!1)}function nw(t,e){if(e instanceof $e){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Rb(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Rb(t)}function Rb(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Op(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Ue.between(e,n,r)}function jb(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 _C(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ji(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Kh(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&&Qe.findFrom(i,e)}function Ds(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ib(t,e,n){let r=t.state.selection;if(r instanceof Ue)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 Ds(t,new Ue(r.$anchor,l))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Kh(t.state,e);return s&&s instanceof $e?Ds(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?$e.isSelectable(i)?Ds(t,new $e(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Jl?Ds(t,new Ue(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof $e&&r.node.isInline)return Ds(t,new Ue(e>0?r.$to:r.$from));{let s=Kh(t.state,e);return s?Ds(t,s):!1}}}function Jc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Tl(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ho(t,e){return e<0?TC(t):MC(t)}function TC(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<Jc(n)&&Tl(n.childNodes[r],-1)&&(l=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Tl(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&&Tl(c,-1);)s=n.parentNode,i=Nn(c),c=c.previousSibling;if(c)n=c,r=Jc(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?Gh(t,n,r):s&&Gh(t,s,i)}function MC(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Jc(n),i,l;for(;;)if(r<s){if(n.nodeType!=1)break;let c=n.childNodes[r];if(Tl(c,1))i=n,l=++r;else break}else{if(sw(n))break;{let c=n.nextSibling;for(;c&&Tl(c,1);)i=c.parentNode,l=Nn(c)+1,c=c.nextSibling;if(c)n=c,r=0,s=Jc(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Gh(t,i,l)}function sw(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function AC(t,e){for(;t&&e==t.childNodes.length&&!ql(t);)e=Nn(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 OC(t,e){for(;t&&!e&&!ql(t);)e=Nn(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 Gh(t,e,n){if(e.nodeType!=3){let i,l;(l=AC(e,n))?(e=l,n=0):(i=OC(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Vu(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&&fs(t)},50)}function Lb(t,e){let n=t.state.doc.resolve(e);if(!(_n||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 Db(t,e,n){let r=t.state.selection;if(r instanceof Ue&&!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=Kh(t.state,e);if(l&&l instanceof $e)return Ds(t,l)}if(!s.parent.inlineContent){let l=e<0?s:i,c=r instanceof sr?Qe.near(l,e):Qe.findFrom(l,e);return c?Ds(t,c):!1}return!1}function Pb(t,e){if(!(t.state.selection instanceof Ue))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 Bb(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function RC(t){if(!jn||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;Bb(t,r,"true"),setTimeout(()=>Bb(t,r,"false"),20)}return!1}function jC(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function IC(t,e){let n=e.keyCode,r=jC(e);if(n==8||mr&&n==72&&r=="c")return Pb(t,-1)||ho(t,-1);if(n==46&&!e.shiftKey||mr&&n==68&&r=="c")return Pb(t,1)||ho(t,1);if(n==13||n==27)return!0;if(n==37||mr&&n==66&&r=="c"){let s=n==37?Lb(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ib(t,s,r)||ho(t,s)}else if(n==39||mr&&n==70&&r=="c"){let s=n==39?Lb(t,t.state.selection.from)=="ltr"?1:-1:1;return Ib(t,s,r)||ho(t,s)}else{if(n==38||mr&&n==80&&r=="c")return Db(t,-1,r)||ho(t,-1);if(n==40||mr&&n==78&&r=="c")return RC(t)||Db(t,1,r)||ho(t,1);if(r==(mr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Rp(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")||Bi.fromSchema(t.state.schema),c=uw(),d=c.createElement("div");d.appendChild(l.serializeFragment(r,{document:c}));let f=d.firstChild,p,m=0;for(;f&&f.nodeType==1&&(p=cw[f.nodeName.toLowerCase()]);){for(let b=p.length-1;b>=0;b--){let v=c.createElement(p[b]);for(;d.firstChild;)v.appendChild(d.firstChild);d.appendChild(v),m++}f=d.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:d,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 d=!!e&&(r||i||!n);if(d){if(t.someProp("transformPastedText",y=>{e=y(e,i||r,t)}),i)return c=new Se(ae.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=Bi.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=BC(n),Jl&&zC(l);let f=l&&l.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let m=+p[3];m>0;m--){let 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")||Vs.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(d||p),context:s,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!LC.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)c=$C(zb(c,+p[1],+p[2]),p[4]);else if(c=Se.maxOpen(DC(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=zb(c,m,y)}return t.someProp("transformPasted",m=>{c=m(c,t,d)}),c}const LC=/^(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 DC(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 d=s.findWrapping(c.type),f;if(!d)return l=null;if(f=l.length&&i.length&&lw(d,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 p=ow(c,d);l.push(p),s=s.matchType(p.type),i=d}}),l)return ae.from(l)}return t}function ow(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ae.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(ae.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(ae.empty,!0);return t.copy(n.append(r))}function qh(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=qh(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(ae.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(c))}function zb(t,e,n){return e<t.openStart&&(t=new Se(qh(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Se(qh(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 $b=null;function uw(){return $b||($b=document.implementation.createHTMLDocument("title"))}let rh=null;function PC(t){let e=window.trustedTypes;return e?(rh||(rh=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),rh.createHTML(t)):t}function BC(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=PC(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function zC(t){let e=t.querySelectorAll(_n?"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 $C(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 d=n.nodes[r[c]];if(!d||d.hasRequiredAttrs())break;s=ae.from(d.create(r[c+1],s)),i++,l++}return new Se(s,i,l)}const Un={},Hn={},FC={touchstart:!0,touchmove:!0};class UC{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 HC(t){for(let e in Un){let n=Un[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{VC(t,r)&&!jp(t,r)&&(t.editable||!(r.type in Hn))&&n(t,r)},FC[e]?{passive:!0}:void 0)}jn&&t.dom.addEventListener("input",()=>null),Jh(t)}function Ws(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function WC(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 Jh(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>jp(t,r))})}function jp(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function VC(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 KC(t,e){!jp(t,e)&&Un[e.type]&&(t.editable||!(e.type in Hn))&&Un[e.type](t,e)}Hn.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(),!(cs&&_n&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),_o&&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,wi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||IC(t,n)?n.preventDefault():Ws(t,"key")};Hn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Hn.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 Ue)||!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 Gu(t){return{left:t.clientX,top:t.clientY}}function GC(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ip(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 ko(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 qC(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&$e.isSelectable(r)?(ko(t,new $e(n)),!0):!1}function JC(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof $e&&(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($e.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?(ko(t,$e.create(t.state.doc,s)),!0):!1}function YC(t,e,n,r,s){return Ip(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?JC(t,n):qC(t,n))}function QC(t,e,n,r){return Ip(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function XC(t,e,n,r){return Ip(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||ZC(t,n,r)}function ZC(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ko(t,Ue.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)ko(t,Ue.create(r,c+1,c+1+l.content.size));else if($e.isSelectable(l))ko(t,$e.create(r,c));else continue;return!0}}function Lp(t){return Yc(t)}const dw=mr?"metaKey":"ctrlKey";Un.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Lp(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&GC(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(Gu(n));l&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new e_(t,l,n,!!r)):(i=="doubleClick"?QC:XC)(t,l.pos,l.inside,n)?n.preventDefault():Ws(t,"pointer"))};class e_{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 p=e.state.doc.resolve(n.pos);i=p.parent,l=p.depth?p.before():0}const c=s?null:r.target,d=c?e.docView.nearestDesc(c,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||f instanceof $e&&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)),Ws(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(()=>fs(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(Gu(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ws(this.view,"pointer"):YC(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||jn&&this.mightDrag&&!this.mightDrag.node.isAtom||_n&&!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)?(ko(this.view,Qe.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ws(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ws(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)}}Un.touchstart=t=>{t.input.lastTouch=Date.now(),Lp(t),Ws(t,"pointer")};Un.touchmove=t=>{t.input.lastTouch=Date.now(),Ws(t,"pointer")};Un.contextmenu=t=>Lp(t);function fw(t,e){return t.composing?!0:jn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const t_=cs?5e3:-1;Hn.compositionstart=Hn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Ue&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||_n&&Hx&&n_(t)))t.markCursor=t.state.storedMarks||n.marks(),Yc(t,!0),t.markCursor=null;else if(Yc(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}hw(t,t_)};function n_(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"}Hn.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++,hw(t,20))};function hw(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Yc(t),e))}function pw(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=s_());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function r_(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=JN(e.focusNode,e.focusOffset),r=YN(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 s_(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Yc(t,e=!1){if(!(cs&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),pw(t),e||t.docView&&t.docView.dirty){let n=Ap(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 i_(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 zl=Qn&&Ks<15||_o&&eC<604;Un.copy=Hn.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=zl?null:n.clipboardData,l=r.content(),{dom:c,text:d}=Rp(t,l);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",d)):i_(t,c),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function o_(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function l_(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?$l(t,r.value,null,s,e):$l(t,r.textContent,r.innerHTML,s,e)},50)}function $l(t,e,n,r,s){let i=iw(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,s,i||Se.empty)))return!0;if(!i)return!1;let l=o_(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," "):""}Hn.paste=(t,e)=>{let n=e;if(t.composing&&!cs)return;let r=zl?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&$l(t,mw(r),r.getData("text/html"),s,n)?n.preventDefault():l_(t,n)};class gw{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const a_=mr?"altKey":"ctrlKey";function yw(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[a_]}Un.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(Gu(n)),l;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof $e?s.to-1:s.to))){if(r&&r.mightDrag)l=$e.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=$e.create(t.state.doc,m.posBefore))}}let c=(l||t.state.selection).content(),{dom:d,text:f,slice:p}=Rp(t,c);(!n.dataTransfer.files.length||!_n||Ux>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zl?"Text":"text/html",d.innerHTML),n.dataTransfer.effectAllowed="copyMove",zl||n.dataTransfer.setData("text/plain",f),t.dragging=new gw(p,yw(t,n),l)};Un.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Hn.dragover=Hn.dragenter=(t,e)=>e.preventDefault();Hn.drop=(t,e)=>{try{c_(t,e,t.dragging)}finally{t.dragging=null}};function c_(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Gu(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),zl?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 d=t.state.tr;if(l){let{node:b}=n;b?b.replace(d):d.deleteSelection()}let f=d.mapping.map(c),p=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=d.doc;if(p?d.replaceRangeWith(f,f,i.content.firstChild):d.replaceRange(f,f,i),d.doc.eq(m))return;let y=d.doc.resolve(f);if(p&&$e.isSelectable(i.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(i.content.firstChild))d.setSelection(new $e(y));else{let b=d.mapping.map(c);d.mapping.maps[d.mapping.maps.length-1].forEach((v,w,k,N)=>b=N),d.setSelection(Op(t,y,d.doc.resolve(b)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}Un.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())&&fs(t)},20))};Un.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)};Un.beforeinput=(t,e)=>{if(_n&&cs&&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,wi(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 Hn)Un[t]=Hn[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 Qc{constructor(e,n){this.toDOM=e,this.spec=n||Ti,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 jt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Qc&&(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 qs{constructor(e,n){this.attrs=e,this.spec=n||Ti}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 jt(i,l,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof qs&&Fl(this.attrs,e.attrs)&&Fl(this.spec,e.spec)}static is(e){return e.type instanceof qs}destroy(){}}class Dp{constructor(e,n){this.attrs=e,this.spec=n||Ti}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 jt(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 Dp&&Fl(this.attrs,e.attrs)&&Fl(this.spec,e.spec)}destroy(){}}class jt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new jt(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 jt(e,e,new Qc(n,r))}static inline(e,n,r,s){return new jt(e,n,new qs(r,s))}static node(e,n,r,s){return new jt(e,n,new Dp(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof qs}get widget(){return this.type instanceof Qc}}const go=[],Ti={};class wt{constructor(e,n){this.local=e.length?e:go,this.children=n.length?n:go}static create(e,n){return n.length?Xc(n,e,0,Ti):Rn}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==Rn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ti)}mapInner(e,n,r,s,i){let l;for(let c=0;c<this.local.length;c++){let d=this.local[c].map(e,r,s);d&&d.type.valid(n,d)?(l||(l=[])).push(d):i.onRemove&&i.onRemove(this.local[c].spec)}return this.children.length?u_(this.children,l||[],e,n,r,s,i):l?new wt(l.sort(Mi),go):Rn}add(e,n){return n.length?this==Rn?wt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((c,d)=>{let f=d+r,p;if(p=vw(n,c,f)){for(s||(s=this.children.slice());i<s.length&&s[i]<d;)i+=3;s[i]==d?s[i+2]=s[i+2].addInner(c,p,f+1):s.splice(i,0,d,d+c.nodeSize,Xc(p,c,f+1,Ti)),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 wt(l.length?this.local.concat(l).sort(Mi):this.local,s||this.children)}remove(e){return e.length==0||this==Rn?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,d=r[i+1]+n;for(let p=0,m;p<e.length;p++)(m=e[p])&&m.from>c&&m.to<d&&(e[p]=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!=Rn?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 wt(s,r):Rn}forChild(e,n){if(this==Rn)return this;if(n.isLeaf)return wt.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 d=this.local[c];if(d.from<l&&d.to>i&&d.type instanceof qs){let f=Math.max(i,d.from)-i,p=Math.min(l,d.to)-i;f<p&&(s||(s=[])).push(d.copy(f,p))}}if(s){let c=new wt(s.sort(Mi),go);return r?new zs([c,r]):c}return r||Rn}eq(e){if(this==e)return!0;if(!(e instanceof wt)||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 Pp(this.localsInner(e))}localsInner(e){if(this==Rn)return go;if(e.inlineContent||!this.local.some(qs.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof qs||n.push(this.local[r]);return n}forEachSet(e){e(this)}}wt.empty=new wt([],[]);wt.removeOverlap=Pp;const Rn=wt.empty;class zs{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Ti));return zs.from(r)}forChild(e,n){if(n.isLeaf)return wt.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Rn&&(i instanceof zs?r=r.concat(i.members):r.push(i))}return zs.from(r)}eq(e){if(!(e instanceof zs)||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?Pp(r?n:n.sort(Mi)):go}static from(e){switch(e.length){case 0:return Rn;case 1:return e[0];default:return new zs(e.every(n=>n instanceof wt)?e:e.reduce((n,r)=>n.concat(r instanceof wt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function u_(t,e,n,r,s,i,l){let c=t.slice();for(let f=0,p=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+p-m)continue;let O=c[N]+p-m;b>=O?c[N+1]=y<=O?-2:-1:y>=p&&k&&(c[N]+=k,c[N+1]+=k)}m+=k}),p=n.maps[f].map(p,-1)}let d=!1;for(let f=0;f<c.length;f+=3)if(c[f+1]<0){if(c[f+1]==-2){d=!0,c[f+1]=-1;continue}let p=n.map(t[f]+i),m=p-s;if(m<0||m>=r.content.size){d=!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,p+1,t[f]+i+1,l);N!=Rn?(c[f]=m,c[f+1]=b,c[f+2]=N):(c[f+1]=-2,d=!0)}else d=!0}if(d){let f=d_(c,t,e,n,s,i,l),p=Xc(f,r,0,l);e=p.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<p.children.length;m+=3){let b=p.children[m];for(;y<c.length&&c[y]<b;)y+=3;c.splice(y,0,p.children[m],p.children[m+1],p.children[m+2])}}return new wt(e.sort(Mi),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 jt(s.from+e,s.to+e,s.type))}return n}function d_(t,e,n,r,s,i,l){function c(d,f){for(let p=0;p<d.local.length;p++){let m=d.local[p].map(r,s,f);m?n.push(m):l.onRemove&&l.onRemove(d.local[p].spec)}for(let p=0;p<d.children.length;p+=3)c(d.children[p+2],d.children[p]+f+1)}for(let d=0;d<t.length;d+=3)t[d+1]==-1&&c(t[d+2],e[d]+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 Xc(t,e,n,r){let s=[],i=!1;e.forEach((c,d)=>{let f=vw(t,c,d+n);if(f){i=!0;let p=Xc(f,c,n+d+1,r);p!=Rn&&s.push(d,d+c.nodeSize,p)}});let l=bw(i?xw(t):t,-n).sort(Mi);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 wt(l,s):Rn}function Mi(t,e){return t.from-e.from||t.to-e.to}function Pp(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),Fb(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),Fb(e,s,r.copy(i.from,r.to)));break}}}return e}function Fb(t,e,n){for(;e<t.length&&Mi(n,t[e])>0;)e++;t.splice(e,0,n)}function sh(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Rn&&e.push(r)}),t.cursorWrapper&&e.push(wt.create(t.state.doc,[t.cursorWrapper.deco])),zs.from(e)}const f_={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},h_=Qn&&Ks<=11;class p_{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 m_{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new p_,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]);Qn&&Ks<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():jn&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),h_&&(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,f_)),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(jb(this.view)){if(this.suppressingSelectionUpdates)return fs(this.view);if(Qn&&Ks<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ji(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=Co(i))n.add(i);for(let i=e.anchorNode;i;i=Co(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)&&jb(e)&&!this.ignoreSelectionChange(r),i=-1,l=-1,c=!1,d=[];if(e.editable)for(let p=0;p<n.length;p++){let m=this.registerMutation(n[p],d);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(d.some(p=>p.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let p of d)if(p.nodeName=="BR"&&p.parentNode){let m=p.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&p.parentNode.removeChild(p)}}else if(yr&&d.length){let p=d.filter(m=>m.nodeName=="BR");if(p.length==2){let[m,y]=p;m.parentNode&&m.parentNode.parentNode==y.parentNode?y.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let y of p){let b=y.parentNode;b&&b.nodeName=="LI"&&(!m||b_(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&&Vu(r)&&(f=Ap(e))&&f.eq(Qe.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,fs(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,l),g_(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,v_(e,d)),this.handleDOMChange(i,l,c,d),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||fs(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let p=0;p<e.addedNodes.length;p++){let m=e.addedNodes[p];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Qn&&Ks<=11&&e.addedNodes.length)for(let p=0;p<e.addedNodes.length;p++){let{previousSibling:m,nextSibling:y}=e.addedNodes[p];(!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?Nn(s)+1:0,c=r.localPosFromDOM(e.target,l,-1),d=i&&i.parentNode==e.target?Nn(i):e.target.childNodes.length,f=r.localPosFromDOM(e.target,d,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 Ub=new WeakMap,Hb=!1;function g_(t){if(!Ub.has(t)&&(Ub.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=yr,Hb)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."),Hb=!0}}function Wb(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,l=t.domAtPos(t.state.selection.anchor);return ji(l.node,l.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function y_(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Wb(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?Wb(t,n):null}function b_(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 v_(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 d=c.firstChild;if(!d||d.nodeType!=1||d.contentEditable=="false"||/^(BR|IMG)$/.test(d.nodeName))break;c=d}c.insertBefore(i,c.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function x_(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:l,to:c}=t.docView.parseRange(e,n),d=t.domSelectionRange(),f,p=d.anchorNode;if(p&&t.dom.contains(p.nodeType==1?p:p.parentNode)&&(f=[{node:p,offset:d.anchorOffset}],Vu(d)||f.push({node:d.focusNode,offset:d.focusOffset})),_n&&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")||Vs.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:w_,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 w_(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(jn&&/^(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||jn&&/^(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 k_=/^(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 S_(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,z=Ap(t,D);if(z&&!t.state.selection.eq(z)){if(_n&&cs&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",U=>U(t,wi(13,"Enter"))))return;let $=t.state.tr.setSelection(z);D=="pointer"?$.setMeta("pointer",!0):D=="key"&&$.scrollIntoView(),i&&$.setMeta("composition",i),t.dispatch($)}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 d=t.state.selection,f=x_(t,e,n),p=t.state.doc,m=p.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=C_(m.content,f.doc.content,f.from,y,b);if(v&&t.input.domChangeCount++,(_o&&t.input.lastIOSEnter>Date.now()-225||cs)&&s.some(D=>D.nodeType==1&&!k_.test(D.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",D=>D(t,wi(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&d instanceof Ue&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))v={start:d.from,endA:d.to,endB:d.to};else{if(f.sel){let D=Vb(t,t.state.doc,f.sel);if(D&&!D.eq(t.state.selection)){let z=t.state.tr.setSelection(D);i&&z.setMeta("composition",i),t.dispatch(z)}}return}t.state.selection.from<t.state.selection.to&&v.start==v.endB&&t.state.selection instanceof Ue&&(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)),Qn&&Ks<=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=p.resolve(v.start),C=w.sameParent(k)&&w.parent.inlineContent&&N.end()>=v.endA;if((_o&&t.input.lastIOSEnter>Date.now()-225&&(!C||s.some(D=>D.nodeName=="DIV"||D.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",D=>D(t,wi(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&N_(p,v.start,v.endA,w,k)&&t.someProp("handleKeyDown",D=>D(t,wi(8,"Backspace")))){cs&&_n&&t.domObserver.suppressSelectionUpdates();return}_n&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),cs&&!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(D){return D(t,wi(13,"Enter"))})},20));let O=v.start,T=v.endA,_=D=>{let z=D||t.state.tr.replace(O,T,f.doc.slice(v.start-f.from,v.endB-f.from));if(f.sel){let $=Vb(t,z.doc,f.sel);$&&!(_n&&t.composing&&$.empty&&(v.start!=v.endB||t.input.lastChromeDelete<Date.now()-100)&&($.head==O||$.head==z.mapping.map(T)-1)||Qn&&$.empty&&$.head==O)&&z.setSelection($)}return i&&z.setMeta("composition",i),z.scrollIntoView()},R;if(C)if(w.pos==k.pos){Qn&&Ks<=11&&w.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>fs(t),20));let D=_(t.state.tr.delete(O,T)),z=p.resolve(v.start).marksAcross(p.resolve(v.endA));z&&D.ensureMarks(z),t.dispatch(D)}else if(v.endA==v.endB&&(R=E_(w.parent.content.cut(w.parentOffset,k.parentOffset),N.parent.content.cut(N.parentOffset,v.endA-N.start())))){let D=_(t.state.tr);R.type=="add"?D.addMark(O,T,R.mark):D.removeMark(O,T,R.mark),t.dispatch(D)}else if(w.parent.child(w.index()).isText&&w.index()==k.index()-(k.textOffset?0:1)){let D=w.parent.textBetween(w.parentOffset,k.parentOffset),z=()=>_(t.state.tr.insertText(D,O,T));t.someProp("handleTextInput",$=>$(t,O,T,D,z))||t.dispatch(z())}else t.dispatch(_());else t.dispatch(_())}function Vb(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Op(t,e.resolve(n.anchor),e.resolve(n.head))}function E_(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,l,c,d;for(let p=0;p<r.length;p++)s=r[p].removeFromSet(s);for(let p=0;p<n.length;p++)i=n[p].removeFromSet(i);if(s.length==1&&i.length==0)c=s[0],l="add",d=p=>p.mark(c.addToSet(p.marks));else if(s.length==0&&i.length==1)c=i[0],l="remove",d=p=>p.mark(c.removeFromSet(p.marks));else return null;let f=[];for(let p=0;p<e.childCount;p++)f.push(d(e.child(p)));if(ae.from(f).eq(t))return{mark:c,type:l}}function N_(t,e,n,r,s){if(n-e<=s.pos-r.pos||ih(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(ih(i,!0,!0));return!l.parent.isTextblock||l.pos>n||ih(l,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function ih(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 C_(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 d=Math.max(0,i-Math.min(l,c));r-=l+d-i}if(l<i&&t.size<e.size){let d=r<=i&&r>=l?i-r:0;i-=d,i&&i<e.size&&Kb(e.textBetween(i-1,i+1))&&(i+=d?1:-1),c=i+(c-l),l=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,i&&i<t.size&&Kb(t.textBetween(i-1,i+1))&&(i+=d?1:-1),l=i+(l-c),c=i}return{start:i,endA:l,endB:c}}function Kb(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 UC,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Qb),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=Jb(this),qb(this),this.nodeViews=Yb(this),this.docView=_b(this.state.doc,Gb(this),sh(this),this.dom,this),this.domObserver=new m_(this,(r,s,i,l)=>S_(this,r,s,i,l)),this.domObserver.start(),HC(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&&Jh(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qb),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&&(pw(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=Yb(this);T_(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Jh(this),this.editable=Jb(this),qb(this);let d=sh(this),f=Gb(this),p=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,f,d);(m||!e.selection.eq(s.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&rC(this);if(l){this.domObserver.stop();let b=m&&(Qn||_n)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&__(s.selection,e.selection);if(m){let v=_n?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=r_(this)),(i||!this.docView.update(e.doc,f,d,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=_b(e.doc,f,d,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_C(this))?fs(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),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():y&&sC(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 $e){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&wb(this,n.getBoundingClientRect(),e)}else wb(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:$e.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(Qn){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&&iC(this.dom),fs(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 uC(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 mC(this,n||this.state,e)}pasteHTML(e,n){return $l(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return $l(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Rp(this,e)}destroy(){this.docView&&(WC(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sh(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,GN())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return KC(this,e)}domSelectionRange(){let e=this.domSelection();return e?jn&&this.root.nodeType===11&&XN(this.dom.ownerDocument)==this.dom&&y_(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 Gb(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"),[jt.node(0,t.state.doc.content.size,e)]}function qb(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:jt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Jb(t){return!t.someProp("editable",e=>e(t.state)===!1)}function __(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 Yb(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 T_(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 Qb(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 Ys={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:"'"},Zc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},M_=typeof navigator<"u"&&/Mac/.test(navigator.platform),A_=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Cn=0;Cn<10;Cn++)Ys[48+Cn]=Ys[96+Cn]=String(Cn);for(var Cn=1;Cn<=24;Cn++)Ys[Cn+111]="F"+Cn;for(var Cn=65;Cn<=90;Cn++)Ys[Cn]=String.fromCharCode(Cn+32),Zc[Cn]=String.fromCharCode(Cn);for(var oh in Ys)Zc.hasOwnProperty(oh)||(Zc[oh]=Ys[oh]);function O_(t){var e=M_&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||A_&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Zc:Ys)[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 R_=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),j_=typeof navigator<"u"&&/Win/.test(navigator.platform);function I_(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 d=e[c];if(/^(cmd|meta|m)$/i.test(d))l=!0;else if(/^a(lt)?$/i.test(d))r=!0;else if(/^(c|ctrl|control)$/i.test(d))s=!0;else if(/^s(hift)?$/i.test(d))i=!0;else if(/^mod$/i.test(d))R_?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+d)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function L_(t){let e=Object.create(null);for(let n in t)e[I_(n)]=t[n];return e}function lh(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 D_(t){return new Et({props:{handleKeyDown:Bp(t)}})}function Bp(t){let e=L_(t);return function(n,r){let s=O_(r),i,l=e[lh(s,r)];if(l&&l(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let c=e[lh(s,r,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(j_&&r.ctrlKey&&r.altKey)&&(i=Ys[r.keyCode])&&i!=s){let c=e[lh(i,r)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var P_=Object.defineProperty,zp=(t,e)=>{for(var n in e)P_(t,n,{get:e[n],enumerable:!0})};function qu(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 Ju=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 p=c(...f)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,l=[],c=!!t,d=t||s.tr,f=()=>(!c&&e&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(d),l.every(m=>m===!0)),p={...Object.fromEntries(Object.entries(n).map(([m,y])=>[m,(...v)=>{const w=this.buildProps(d,e),k=y(...v)(w);return l.push(k),p}])),run:f};return p}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([c,d])=>[c,(...f)=>d(...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:qu({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,d])=>[c,(...f)=>d(...f)(l)]))}};return l}},kw={};zp(kw,{blur:()=>B_,clearContent:()=>z_,clearNodes:()=>$_,command:()=>F_,createParagraphNear:()=>U_,cut:()=>H_,deleteCurrentNode:()=>W_,deleteNode:()=>V_,deleteRange:()=>K_,deleteSelection:()=>G_,enter:()=>q_,exitCode:()=>J_,extendMarkRange:()=>Y_,first:()=>Q_,focus:()=>Z_,forEach:()=>eT,insertContent:()=>tT,insertContentAt:()=>sT,joinBackward:()=>lT,joinDown:()=>oT,joinForward:()=>aT,joinItemBackward:()=>cT,joinItemForward:()=>uT,joinTextblockBackward:()=>dT,joinTextblockForward:()=>fT,joinUp:()=>iT,keyboardShortcut:()=>pT,lift:()=>mT,liftEmptyBlock:()=>gT,liftListItem:()=>yT,newlineInCode:()=>bT,resetAttributes:()=>vT,scrollIntoView:()=>xT,selectAll:()=>wT,selectNodeBackward:()=>kT,selectNodeForward:()=>ST,selectParentNode:()=>ET,selectTextblockEnd:()=>NT,selectTextblockStart:()=>CT,setContent:()=>_T,setMark:()=>VT,setMeta:()=>KT,setNode:()=>GT,setNodeSelection:()=>qT,setTextDirection:()=>JT,setTextSelection:()=>YT,sinkListItem:()=>QT,splitBlock:()=>XT,splitListItem:()=>ZT,toggleList:()=>eM,toggleMark:()=>tM,toggleNode:()=>nM,toggleWrap:()=>rM,undoInputRule:()=>sM,unsetAllMarks:()=>iM,unsetMark:()=>oM,unsetTextDirection:()=>lM,updateAttributes:()=>aM,wrapIn:()=>cM,wrapInList:()=>uM});var B_=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),z_=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),$_=()=>({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,d)=>{if(c.type.isText)return;const{doc:f,mapping:p}=e,m=f.resolve(p.map(d)),y=f.resolve(p.map(d+c.nodeSize)),b=m.blockRange(y);if(!b)return;const v=Oo(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},F_=t=>e=>t(e),U_=()=>({state:t,dispatch:e})=>Px(t,e),H_=(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 Ue(r.doc.resolve(Math.max(l-1,0)))),!0},W_=()=>({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),d=s.after(i);t.delete(c,d).scrollIntoView()}return!0}return!1};function on(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 V_=t=>({tr:e,state:n,dispatch:r})=>{const s=on(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 d=i.before(l),f=i.after(l);e.delete(d,f).scrollIntoView()}return!0}return!1},K_=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},G_=()=>({state:t,dispatch:e})=>Ep(t,e),q_=()=>({commands:t})=>t.keyboardShortcut("Enter"),J_=()=>({state:t,dispatch:e})=>RN(t,e);function $p(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function eu(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:$p(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Sw(t,e,n={}){return t.find(r=>r.type===e&&eu(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Xb(t,e,n={}){return!!Sw(t,e,n)}function Fp(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(p=>p.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(p=>p.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Sw([...s.node.marks],e,n)))return;let l=s.index,c=t.start()+s.offset,d=l+1,f=c+s.node.nodeSize;for(;l>0&&Xb([...t.parent.child(l-1).marks],e,n);)l-=1,c-=t.parent.child(l).nodeSize;for(;d<t.parent.childCount&&Xb([...t.parent.child(d).marks],e,n);)f+=t.parent.child(d).nodeSize,d+=1;return{from:c,to:f}}function hs(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 Y_=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=hs(t,r.schema),{doc:l,selection:c}=n,{$from:d,from:f,to:p}=c;if(s){const m=Fp(d,i,e);if(m&&m.from<=f&&m.to>=p){const y=Ue.create(l,m.from,m.to);n.setSelection(y)}}return!0},Q_=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 Ue}function Ei(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=Qe.atStart(t),r=Qe.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?Ue.create(t,Ei(0,s,i),Ei(t.content.size,s,i)):Ue.create(t,Ei(e,s,i),Ei(e,s,i))}function Zb(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function tu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function X_(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Z_=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const l=()=>{(tu()||Zb())&&r.dom.focus(),X_()&&!tu()&&!Zb()&&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,d=n.state.selection.eq(c);return i&&(d||s.setSelection(c),d&&s.storedMarks&&s.setStoredMarks(s.storedMarks),l()),!0},eT=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),tT=(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 uc(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 Ul(t,e,n){if(t instanceof Mr||t instanceof ae)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 ae.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),Ul("",e,n)}if(s){if(n.errorOnInvalidContent){let l=!1,c="";const d=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?Vs.fromSchema(d).parseSlice(uc(t),n.parseOptions):Vs.fromSchema(d).parse(uc(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Vs.fromSchema(e);return n.slice?i.parseSlice(uc(t),n.parseOptions).content:i.parse(uc(t),n.parseOptions)}return Ul("",e,n)}function nT(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof mn||s instanceof gn))return;const i=t.mapping.maps[r];let l=0;i.forEach((c,d,f,p)=>{l===0&&(l=p)}),t.setSelection(Qe.near(t.doc.resolve(l),n))}var rT=t=>!("type"in t),sT=(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 d=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{Ul(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(k){d(k)}try{c=Ul(e,i.schema,{parseOptions:f,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:i.options.enableContentCheck})}catch(k){return d(k),!1}let{from:p,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,b=!0;if((rT(c)?c:[c]).forEach(k=>{k.check(),y=y?k.isText&&k.marks.length===0:!1,b=b?k.isBlock:!1}),p===m&&b){const{parent:k}=r.doc.resolve(p);k.isTextblock&&!k.type.spec.code&&!k.childCount&&(p-=1,m+=1)}let w;if(y){if(Array.isArray(e))w=e.map(k=>k.text||"").join("");else if(e instanceof ae){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,p,m)}else{w=c;const k=r.doc.resolve(p),N=k.node(),C=k.parentOffset===0,O=N.isText||N.isTextblock,T=N.content.size>0;C&&O&&T&&(p=Math.max(0,p-1)),r.replaceWith(p,m,w)}n.updateSelection&&nT(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:p,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:p,text:w})}return!0},iT=()=>({state:t,dispatch:e})=>MN(t,e),oT=()=>({state:t,dispatch:e})=>AN(t,e),lT=()=>({state:t,dispatch:e})=>Ax(t,e),aT=()=>({state:t,dispatch:e})=>Ix(t,e),cT=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Uu(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},uT=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Uu(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},dT=()=>({state:t,dispatch:e})=>_N(t,e),fT=()=>({state:t,dispatch:e})=>TN(t,e);function _w(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function hT(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 d=e[c];if(/^(cmd|meta|m)$/i.test(d))l=!0;else if(/^a(lt)?$/i.test(d))r=!0;else if(/^(c|ctrl|control)$/i.test(d))s=!0;else if(/^s(hift)?$/i.test(d))i=!0;else if(/^mod$/i.test(d))tu()||_w()?l=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${d}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var pT=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=hT(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}),d=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,c))});return d==null||d.steps.forEach(f=>{const p=f.map(r.mapping);p&&s&&r.maybeStep(p)}),!0};function Qs(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,l=e?on(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 d=s-r,f=c.filter(m=>l?l.name===m.node.type.name:!0).filter(m=>eu(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,y)=>m+y.to-y.from,0)>=d}var mT=(t,e={})=>({state:n,dispatch:r})=>{const s=on(t,n.schema);return Qs(n,s,e)?ON(n,r):!1},gT=()=>({state:t,dispatch:e})=>Bx(t,e),yT=t=>({state:e,dispatch:n})=>{const r=on(t,e.schema);return HN(r)(e,n)},bT=()=>({state:t,dispatch:e})=>Dx(t,e);function Yu(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ev(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 vT=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,l=null;const c=Yu(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=on(t,r.schema)),c==="mark"&&(l=hs(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(p,m)=>{i&&i===p.type&&(d=!0,s&&n.setNodeMarkup(m,void 0,ev(p.attrs,e))),l&&p.marks.length&&p.marks.forEach(y=>{l===y.type&&(d=!0,s&&n.addMark(m,m+p.nodeSize,l.create(ev(y.attrs,e))))})})}),d},xT=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),wT=()=>({tr:t,dispatch:e})=>{if(e){const n=new sr(t.doc);t.setSelection(n)}return!0},kT=()=>({state:t,dispatch:e})=>Rx(t,e),ST=()=>({state:t,dispatch:e})=>Lx(t,e),ET=()=>({state:t,dispatch:e})=>LN(t,e),NT=()=>({state:t,dispatch:e})=>BN(t,e),CT=()=>({state:t,dispatch:e})=>PN(t,e);function Yh(t,e,n={},r={}){return Ul(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var _T=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:l,commands:c})=>{const{doc:d}=i;if(r.preserveWhitespace!=="full"){const f=Yh(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return l&&i.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!n),!0}return l&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:d.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Tw(t,e){const n=hs(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,d=>{l.push(...d.marks)});const c=l.find(d=>d.type.name===n.name);return c?{...c.attrs}:{}}function Up(t,e){const n=new kp(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function TT(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 nu(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 Qu(t){return e=>Aw(e.$from,t)}function ze(t,e,n){return t.config[e]===void 0&&t.parent?ze(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?ze(t.parent,e,n):null}):t.config[e]}function Hp(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=ze(e,"addExtensions",n);return r?[e,...Hp(r())]:e}).flat(10)}function Wp(t,e){const n=Bi.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Ow(t){return typeof t=="function"}function kt(t,e=void 0,...n){return Ow(t)?e?t.bind(e)(...n):t(...n):t}function MT(t={}){return Object.keys(t).length===0&&t.constructor===Object}function To(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}=To(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},d=ze(l,"addGlobalAttributes",c);if(!d)return;d().forEach(p=>{p.types.forEach(m=>{Object.entries(p.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},d=ze(l,"addAttributes",c);if(!d)return;const f=d();Object.entries(f).forEach(([p,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:p,attribute:y})})}),e}function St(...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(" "):[],d=r[s]?r[s].split(" "):[],f=c.filter(p=>!d.includes(p));r[s]=[...d,...f].join(" ")}else if(s==="style"){const c=i?i.split(";").map(p=>p.trim()).filter(Boolean):[],d=r[s]?r[s].split(";").map(p=>p.trim()).filter(Boolean):[],f=new Map;d.forEach(p=>{const[m,y]=p.split(":").map(b=>b.trim());f.set(m,y)}),c.forEach(p=>{const[m,y]=p.split(":").map(b=>b.trim());f.set(m,y)}),r[s]=Array.from(f.entries()).map(([p,m])=>`${p}: ${m}`).join("; ")}else r[s]=i}),r},{})}function Hl(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)=>St(n,r),{})}function AT(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function tv(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):AT(n.getAttribute(l.name));return c==null?i:{...i,[l.name]:c}},{});return{...r,...s}}}}function nv(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&MT(n)?!1:n!=null))}function rv(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 OT(t,e){var n;const r=Rw(t),{nodeExtensions:s,markExtensions:i}=To(t),l=(n=s.find(f=>ze(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(s.map(f=>{const p=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=ze(C,"extendNodeSchema",m);return{...N,...O?O(f):{}}},{}),b=nv({...y,content:kt(ze(f,"content",m)),marks:kt(ze(f,"marks",m)),group:kt(ze(f,"group",m)),inline:kt(ze(f,"inline",m)),atom:kt(ze(f,"atom",m)),selectable:kt(ze(f,"selectable",m)),draggable:kt(ze(f,"draggable",m)),code:kt(ze(f,"code",m)),whitespace:kt(ze(f,"whitespace",m)),linebreakReplacement:kt(ze(f,"linebreakReplacement",m)),defining:kt(ze(f,"defining",m)),isolating:kt(ze(f,"isolating",m)),attrs:Object.fromEntries(p.map(rv))}),v=kt(ze(f,"parseHTML",m));v&&(b.parseDOM=v.map(N=>tv(N,p)));const w=ze(f,"renderHTML",m);w&&(b.toDOM=N=>w({node:N,HTMLAttributes:Hl(N,p)}));const k=ze(f,"renderText",m);return k&&(b.toText=k),[f.name,b]})),d=Object.fromEntries(i.map(f=>{const p=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=ze(N,"extendMarkSchema",m);return{...k,...C?C(f):{}}},{}),b=nv({...y,inclusive:kt(ze(f,"inclusive",m)),excludes:kt(ze(f,"excludes",m)),group:kt(ze(f,"group",m)),spanning:kt(ze(f,"spanning",m)),code:kt(ze(f,"code",m)),attrs:Object.fromEntries(p.map(rv))}),v=kt(ze(f,"parseHTML",m));v&&(b.parseDOM=v.map(k=>tv(k,p)));const w=ze(f,"renderHTML",m);return w&&(b.toDOM=k=>w({mark:k,HTMLAttributes:Hl(k,p)})),[f.name,b]}));return new ux({topNode:l,nodes:c,marks:d})}function RT(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function ru(t){return t.sort((n,r)=>{const s=ze(n,"priority")||100,i=ze(r,"priority")||100;return s>i?-1:s<i?1:0})}function jw(t){const e=ru(Hp(t)),n=RT(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 Iw(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
58
|
-
|
|
59
|
-
`,textSerializers:l={}}=n||{};let c="";return t.nodesBetween(r,s,(d,f,p,m)=>{var y;d.isBlock&&f>r&&(c+=i);const b=l==null?void 0:l[d.type.name];if(b)return p&&(c+=b({node:d,pos:f,parent:p,index:m,range:e})),!1;d.isText&&(c+=(y=d==null?void 0:d.text)==null?void 0:y.slice(Math.max(r,f)-f,s-f))}),c}function jT(t,e){const n={from:0,to:t.content.size};return Iw(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 IT(t,e){const n=on(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=Yu(typeof e=="string"?e:e.name,t.schema);return n==="node"?IT(t,e):n==="mark"?Tw(t,e):{}}function LT(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 DT(t){const e=LT(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 Vp(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const l=[];if(s.ranges.length)s.forEach((c,d)=>{l.push({from:c,to:d})});else{const{from:c,to:d}=n[i];if(c===void 0||d===void 0)return;l.push({from:c,to:d})}l.forEach(({from:c,to:d})=>{const f=e.slice(i).map(c,-1),p=e.slice(i).map(d),m=e.invert().map(f,-1),y=e.invert().map(p);r.push({oldRange:{from:m,to:y},newRange:{from:f,to:p}})})}),DT(r)}function Kp(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),l=Fp(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 PT=(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 dc(t,e){return e.nodes[t]||e.marks[t]||null}function Pc(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 BT=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,l,c)=>{var d,f;const p=((f=(d=s.type.spec).toText)==null?void 0:f.call(d,{node:s,pos:i,parent:l,index:c}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?p:p.slice(0,Math.max(0,r-i))}),n};function Qh(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?hs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>eu(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 d=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>eu(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(d>0?d+f:d)>=l}function zT(t,e,n={}){if(!e)return Qs(t,null,n)||Qh(t,null,n);const r=Yu(e,t.schema);return r==="node"?Qs(t,e,n):r==="mark"?Qh(t,e,n):!1}var $T=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Qu(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)},FT=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function sv(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function iv(t,e){const{nodeExtensions:n}=To(e),r=n.find(l=>l.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=kt(ze(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Xu(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&&(Xu(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Pw(t){return t instanceof $e}var Bw=class zw{constructor(e){this.position=e}static fromJSON(e){return new zw(e.position)}toJSON(){return{position:this.position}}};function UT(t,e){const n=e.mapping.mapResult(t.position);return{position:new Bw(n.pos),mapResult:n}}function HT(t){return new Bw(t)}function WT(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:d})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,d.pos,(p,m,y)=>{if(f)return!1;if(p.isInline){const b=!y||y.type.allowsMarkType(n),v=!!n.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(n));f=b&&v}return!f}),f})}var VT=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:l,ranges:c}=i,d=hs(t,r.schema);if(s)if(l){const f=Tw(r,d);n.addStoredMark(d.create({...f,...e}))}else c.forEach(f=>{const p=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(p,m,(y,b)=>{const v=Math.max(b,p),w=Math.min(b+y.nodeSize,m);y.marks.find(N=>N.type===d)?y.marks.forEach(N=>{d===N.type&&n.addMark(v,w,d.create({...N.attrs,...e}))}):n.addMark(v,w,d.create(e))})});return WT(r,n,d)},KT=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),GT=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=on(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})=>bb(i,{...l,...e})(n)?!0:c.clearNodes()).command(({state:c})=>bb(i,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},qT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Ei(t,0,r.content.size),i=$e.create(r,s);e.setSelection(i)}return!0},JT=(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,(d,f)=>{d.isText||n.setNodeMarkup(f,void 0,{...d.attrs,dir:t})}),!0},YT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,l=Ue.atStart(r).from,c=Ue.atEnd(r).to,d=Ei(s,l,c),f=Ei(i,l,c),p=Ue.create(r,d,f);e.setSelection(p)}return!0},QT=t=>({state:e,dispatch:n})=>{const r=on(t,e.schema);return KN(r)(e,n)};function ov(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 XT=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:l}=e,{$from:c,$to:d}=i,f=s.extensionManager.attributes,p=Pc(f,c.node().type.name,c.node().attrs);if(i instanceof $e&&i.node.isBlock)return!c.parentOffset||!ds(l,c.pos)?!1:(r&&(t&&ov(n,s.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=d.parentOffset===d.parent.content.size,y=c.depth===0?void 0:TT(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&y?[{type:y,attrs:p}]:void 0,v=ds(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!v&&ds(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(v=!0,b=y?[{type:y,attrs:p}]:void 0),r){if(v&&(i instanceof Ue&&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&&ov(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return v},ZT=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var l;const c=on(t,r.schema),{$from:d,$to:f}=r.selection,p=r.selection.node;if(p&&p.isBlock||d.depth<2||!d.sameParent(f))return!1;const m=d.node(-1);if(m.type!==c)return!1;const y=i.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==c||d.index(-2)!==d.node(-2).childCount-1)return!1;if(s){let N=ae.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let z=d.depth-C;z>=d.depth-3;z-=1)N=ae.from(d.node(z).copy(N));const O=d.indexAfter(-1)<d.node(-2).childCount?1:d.indexAfter(-2)<d.node(-3).childCount?2:3,T={...Pc(y,d.node().type.name,d.node().attrs),...e},_=((l=c.contentMatch.defaultType)==null?void 0:l.createAndFill(T))||void 0;N=N.append(ae.from(c.createAndFill(null,_)||void 0));const R=d.before(d.depth-(C-1));n.replace(R,d.after(-O),new Se(N,4-C,0));let D=-1;n.doc.nodesBetween(R,n.doc.content.size,(z,$)=>{if(D>-1)return!1;z.isTextblock&&z.content.size===0&&(D=$+1)}),D>-1&&n.setSelection(Ue.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}const b=f.pos===d.end()?m.contentMatchAt(0).defaultType:null,v={...Pc(y,m.type.name,m.attrs),...e},w={...Pc(y,d.node().type.name,d.node().attrs),...e};n.delete(d.pos,f.pos);const k=b?[{type:c,attrs:v},{type:b,attrs:w}]:[{type:c,attrs:v}];if(!ds(n.doc,d.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(d.pos,2,k).scrollIntoView(),!T||!s)return!0;const _=T.filter(R=>O.includes(R.type.name));n.ensureMarks(_)}return!0},ah=(t,e)=>{const n=Qu(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)&&Zs(t.doc,n.pos)&&t.join(n.pos),!0},ch=(t,e)=>{const n=Qu(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)&&Zs(t.doc,r)&&t.join(r),!0},eM=(t,e,n,r={})=>({editor:s,tr:i,state:l,dispatch:c,chain:d,commands:f,can:p})=>{const{extensions:m,splittableMarks:y}=s.extensionManager,b=on(t,l.schema),v=on(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 _=Qu(R=>iv(R.type.name,m))(w);if(O.depth>=1&&_&&O.depth-_.depth<=1){if(_.node.type===b)return f.liftListItem(v);if(iv(_.node.type.name,m)&&b.validContent(_.node.content)&&c)return d().command(()=>(i.setNodeMarkup(_.pos,b),!0)).command(()=>ah(i,b)).command(()=>ch(i,b)).run()}return!n||!T||!c?d().command(()=>p().wrapInList(b,r)?!0:f.clearNodes()).wrapInList(b,r).command(()=>ah(i,b)).command(()=>ch(i,b)).run():d().command(()=>{const R=p().wrapInList(b,r),D=T.filter(z=>y.includes(z.type.name));return i.ensureMarks(D),R?!0:f.clearNodes()}).wrapInList(b,r).command(()=>ah(i,b)).command(()=>ch(i,b)).run()},tM=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,l=hs(t,r.schema);return Qh(r,l,e)?s.unsetMark(l,{extendEmptyMarkRange:i}):s.setMark(l,e)},nM=(t,e,n={})=>({state:r,commands:s})=>{const i=on(t,r.schema),l=on(e,r.schema),c=Qs(r,i,n);let d;return r.selection.$anchor.sameParent(r.selection.$head)&&(d=r.selection.$anchor.parent.attrs),c?s.setNode(l,d):s.setNode(i,{...d,...n})},rM=(t,e={})=>({state:n,commands:r})=>{const s=on(t,n.schema);return Qs(n,s,e)?r.lift(s):r.wrapIn(s,e)},sM=()=>({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 d=c.steps.length-1;d>=0;d-=1)l.step(c.steps[d].invert(c.docs[d]));if(i.text){const d=l.doc.resolve(i.from).marks();l.replaceWith(i.from,i.to,t.schema.text(i.text,d))}else l.delete(i.from,i.to)}return!0}}return!1},iM=()=>({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},oM=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,d=hs(t,r.schema),{$from:f,empty:p,ranges:m}=c;if(!s)return!0;if(p&&l){let{from:y,to:b}=c;const v=(i=f.marks().find(k=>k.type===d))==null?void 0:i.attrs,w=Fp(f,d,v);w&&(y=w.from,b=w.to),n.removeMark(y,b,d)}else m.forEach(y=>{n.removeMark(y.$from.pos,y.$to.pos,d)});return n.removeStoredMark(d),!0},lM=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,d)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(d,void 0,f)}),!0},aM=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,l=null;const c=Yu(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=on(t,r.schema)),c==="mark"&&(l=hs(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{const p=f.$from.pos,m=f.$to.pos;let y,b,v,w;n.selection.empty?r.doc.nodesBetween(p,m,(k,N)=>{i&&i===k.type&&(d=!0,v=Math.max(N,p),w=Math.min(N+k.nodeSize,m),y=N,b=k)}):r.doc.nodesBetween(p,m,(k,N)=>{N<p&&i&&i===k.type&&(d=!0,v=Math.max(N,p),w=Math.min(N+k.nodeSize,m),y=N,b=k),N>=p&&N<=m&&(i&&i===k.type&&(d=!0,s&&n.setNodeMarkup(N,void 0,{...k.attrs,...e})),l&&k.marks.length&&k.marks.forEach(C=>{if(l===C.type&&(d=!0,s)){const O=Math.max(N,p),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}))}))}),d},cM=(t,e={})=>({state:n,dispatch:r})=>{const s=on(t,n.schema);return zN(s,e)(n,r)},uM=(t,e={})=>({state:n,dispatch:r})=>{const s=on(t,n.schema);return $N(s,e)(n,r)},dM=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={}}},Ql=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},fM=(t,e)=>{if($p(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 fc(t){var e;const{editor:n,from:r,to:s,text:i,rules:l,plugin:c}=t,{view:d}=n;if(d.composing)return!1;const f=d.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 p=!1;const m=BT(f)+i;return l.forEach(y=>{if(p)return;const b=fM(m,y.find);if(!b)return;const v=d.state.tr,w=qu({state:d.state,transaction:v}),k={from:r-(b[0].length-i.length),to:s},{commands:N,chain:C,can:O}=new Ju({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}),d.dispatch(v),p=!0)}),p}function hM(t){const{editor:e,rules:n}=t,r=new Et({state:{init(){return null},apply(s,i,l){const c=s.getMeta(r);if(c)return c;const d=s.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:p}=d;typeof p=="string"?p=p:p=Wp(ae.from(p),l.schema);const{from:m}=d,y=m+p.length;fc({editor:e,from:m,to:y,text:p,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,l,c){return fc({editor:e,from:i,to:l,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&fc({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?fc({editor:e,from:l.pos,to:l.pos,text:`
|
|
60
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function pM(t){return Object.prototype.toString.call(t).slice(8,-1)}function hc(t){return pM(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function $w(t,e){const n={...t};return hc(t)&&hc(e)&&Object.keys(e).forEach(r=>{hc(e[r])&&hc(t[r])?n[r]=$w(t[r],e[r]):n[r]=e[r]}),n}var Gp=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{...kt(ze(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...kt(ze(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>$w(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 Fw extends Gp{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Fw(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 d=l.find(f=>(f==null?void 0:f.type.name)===n.name);return d&&r.removeStoredMark(d),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 mM(t){return typeof t=="number"}var gM=class{constructor(t){this.find=t.find,this.handler=t.handler}},yM=(t,e,n)=>{if($p(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 bM(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:l,dropEvent:c}=t,{commands:d,chain:f,can:p}=new Ju({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,_=Math.max(r,v),R=Math.min(s,v+T);if(_>=R)return;const D=b.isText?b.text||"":b.textBetween(_-v,R-v,void 0,"");yM(D,i.find,l).forEach($=>{if($.index===void 0)return;const U=_+$.index+1,Y=U+$[0].length,X={from:n.tr.mapping.map(U),to:n.tr.mapping.map(Y)},J=i.handler({state:n,range:X,match:$,commands:d,chain:f,can:p,pasteEvent:l,dropEvent:c});m.push(J)})}),m.every(b=>b!==null)}var pc=null,vM=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function xM(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 d=({state:p,from:m,to:y,rule:b,pasteEvt:v})=>{const w=p.tr,k=qu({state:p,transaction:w});if(!(!bM({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(p=>new Et({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:_}=N;typeof _=="string"?_=_:_=Wp(ae.from(_),b.schema);const{from:R}=N,D=R+_.length,z=vM(_);return d({rule:p,state:b,from:R,to:{b:D},pasteEvt:z})}const O=y.doc.content.findDiffStart(b.doc.content),T=y.doc.content.findDiffEnd(b.doc.content);if(!(!mM(O)||!T||O===T.b))return d({rule:p,state:b,from:O,to:T,pasteEvt:l})}}))}var Zu=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=jw(t),this.schema=OT(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:dc(e.name,this.schema)},r=ze(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return ru([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:dc(r.name,this.schema)},i=[],l=ze(r,"addKeyboardShortcuts",s);let c={};if(r.type==="mark"&&ze(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 d=D_(c);i.push(d);const f=ze(r,"addInputRules",s);if(sv(r,t.options.enableInputRules)&&f){const y=f();if(y&&y.length){const b=hM({editor:t,rules:y}),v=Array.isArray(b)?b:[b];i.push(...v)}}const p=ze(r,"addPasteRules",s);if(sv(r,t.options.enablePasteRules)&&p){const y=p();if(y&&y.length){const b=xM({editor:t,rules:y});i.push(...b)}}const m=ze(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}=To(this.extensions);return Object.fromEntries(e.filter(n=>!!ze(n,"addNodeView")).map(n=>{const r=this.attributes.filter(d=>d.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:on(n.name,this.schema)},i=ze(n,"addNodeView",s);if(!i)return[];const l=i();if(!l)return[];const c=(d,f,p,m,y)=>{const b=Hl(d,r);return l({node:d,view:f,getPos:p,decorations:m,innerDecorations:y,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return ru([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:dc(s.name,this.schema)},l=ze(s,"dispatchTransaction",i);return l?c=>{l.call(i,{transaction:c,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=To(this.extensions);return Object.fromEntries(e.filter(n=>!!ze(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:hs(n.name,this.schema)},i=ze(n,"addMarkView",s);if(!i)return[];const l=(c,d,f)=>{const p=Hl(c,r);return i()({mark:c,view:d,inline:f,editor:t,extension:n,HTMLAttributes:p,updateAttributes:m=>{LM(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:dc(e.name,this.schema)};e.type==="mark"&&((n=kt(ze(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=ze(e,"onBeforeCreate",r),i=ze(e,"onCreate",r),l=ze(e,"onUpdate",r),c=ze(e,"onSelectionUpdate",r),d=ze(e,"onTransaction",r),f=ze(e,"onFocus",r),p=ze(e,"onBlur",r),m=ze(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),d&&this.editor.on("transaction",d),f&&this.editor.on("focus",f),p&&this.editor.on("blur",p),m&&this.editor.on("destroy",m)})}};Zu.resolve=jw;Zu.sort=ru;Zu.flatten=Hp;var wM={};zp(wM,{ClipboardTextSerializer:()=>Hw,Commands:()=>Ww,Delete:()=>Vw,Drop:()=>Kw,Editable:()=>Gw,FocusEvents:()=>Jw,Keymap:()=>Yw,Paste:()=>Qw,Tabindex:()=>Xw,TextDirection:()=>Zw,focusEventsPluginKey:()=>qw});var bt=class Uw extends Gp{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=bt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Et({key:new At("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(p=>p.$from.pos)),c=Math.max(...i.map(p=>p.$to.pos)),d=Lw(n);return Iw(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),Ww=bt.create({name:"commands",addCommands(){return{...kw}}}),Vw=bt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var l,c,d,f;if((f=(d=(c=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:c.filterTransaction)==null?void 0:d.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const p=Up(t.before,[t,...e]);Vp(p).forEach(b=>{p.mapping.mapResult(b.oldRange.from).deletedAfter&&p.mapping.mapResult(b.oldRange.to).deletedBefore&&p.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:p.mapping.map(w),newTo:p.mapping.map(k),deletedRange:b.oldRange,newRange:b.newRange,partial:!N,editor:this.editor,transaction:t,combinedTransform:p})})});const y=p.mapping;p.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),_=(w=p.doc.nodeAt(N-1))==null?void 0:w.marks.some(D=>D.eq(b.mark)),R=(k=p.doc.nodeAt(C))==null?void 0:k.marks.some(D=>D.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||_),editor:this.editor,transaction:t,combinedTransform:p})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),Kw=bt.create({name:"drop",addProseMirrorPlugins(){return[new Et({key:new At("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Gw=bt.create({name:"editable",addProseMirrorPlugins(){return[new Et({key:new At("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qw=new At("focusEvents"),Jw=bt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Et({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=bt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:d,doc:f}=c,{empty:p,$anchor:m}=d,{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:Qe.atStart(f).from===y;return!p||!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 tu()||_w()?i:s},addProseMirrorPlugins(){return[new Et({key:new At("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,d=Qe.atStart(e.doc).from,f=Qe.atEnd(e.doc).to;if(i||!(l===d&&c===f)||!Xu(n.doc))return;const y=n.tr,b=qu({state:n,transaction:y}),{commands:v}=new Ju({editor:this.editor,state:b});if(v.clearNodes(),!!y.steps.length)return y}})]}}),Qw=bt.create({name:"paste",addProseMirrorPlugins(){return[new Et({key:new At("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Xw=bt.create({name:"tabindex",addProseMirrorPlugins(){return[new Et({key:new At("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Zw=bt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=To(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 Et({key:new At("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),kM=class Sl{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 Sl(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 Sl(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 Sl(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 d=this.resolvedPos.doc.resolve(c);if(!s&&!l&&d.depth<=this.depth)return;const f=new Sl(d,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 d=l[c];if(i[d]!==n[d])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(d=>n[d]===l.node.attrs[d])&&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)}},SM=`.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 EM(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 NM=class extends dM{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:UT,createMappablePosition:HT},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=xo.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=EM(SM,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 Zu(r,this)}createCommandManager(){this.commandManager=new Ju({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Yh(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=Yh(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 p;return(p=this.capturedTransaction)==null?void 0:p.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const l=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),d=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),d&&this.emit("blur",{editor:this,event:d.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 zT(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Wp(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
131
|
-
|
|
132
|
-
`,textSerializers:n={}}=t||{};return jT(this.state.doc,{blockSeparator:e,textSerializers:{...Lw(this.schema),...n}})}get isEmpty(){return Xu(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 kM(e,this)}get $doc(){return this.$pos(0)}};function Li(t){return new Ql({find:t.find,handler:({state:e,range:n,match:r})=>{const s=kt(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 d=c.search(/\S/),f=n.from+c.indexOf(l),p=f+l.length;if(Kp(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;p<n.to&&i.delete(p,n.to),f>n.from&&i.delete(n.from+d,f);const y=n.from+d+l.length;i.addMark(n.from+d,y,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function ek(t){return new Ql({find:t.find,handler:({state:e,range:n,match:r})=>{const s=kt(t.getAttributes,void 0,r)||{},{tr:i}=e,l=n.from;let c=n.to;const d=t.type.create(s);if(r[1]){const f=r[0].lastIndexOf(r[1]);let p=l+f;p>c?p=c:c=p+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,l+r[0].length-1),i.replaceWith(p,c,d)}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 Xh(t){return new Ql({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=kt(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 Qt(t){return new Ql({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 d=i-l;d>0&&(s=r[0].slice(c-d,c)+s,i=l)}e.tr.insertText(s,i,l)},undoable:t.undoable})}function Mo(t){return new Ql({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=kt(t.getAttributes,void 0,r)||{},l=e.tr.delete(n.from,n.to),d=l.doc.resolve(n.from).blockRange(),f=d&&wp(d,t.type,i);if(!f)return null;if(l.wrap(d,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 p=l.doc.resolve(n.from-1).nodeBefore;p&&p.type===t.type&&Zs(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,p))&&l.join(n.from-1)},undoable:t.undoable})}var CM=t=>"touches"in t,_M=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 d=c.clientX-this.startX,f=c.clientY-this.startY;this.handleResize(d,f)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const d=c.touches[0];if(!d)return;const f=d.clientX-this.startX,p=d.clientY-this.startY;this.handleResize(f,p)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,d=this.element.offsetHeight;this.onCommit(c,d),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,CM(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"),d=t.includes("top");return i?r=this.startWidth+e:l&&(r=this.startWidth-e),c?s=this.startHeight+n:d&&(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),p=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(f=Math.min(this.maxSize.width,f)),(s=this.maxSize)!=null&&s.height&&(p=Math.min(this.maxSize.height,p)),{width:f,height:p}}let c=t,d=e;return c<this.minSize.width&&(c=this.minSize.width,d=c/this.aspectRatio),d<this.minSize.height&&(d=this.minSize.height,c=d*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&c>this.maxSize.width&&(c=this.maxSize.width,d=c/this.aspectRatio),(l=this.maxSize)!=null&&l.height&&d>this.maxSize.height&&(d=this.maxSize.height,c=d*this.aspectRatio),{width:c,height:d}}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 TM(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof $e){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 MM={};zp(MM,{createAtomBlockMarkdownSpec:()=>AM,createBlockMarkdownSpec:()=>OM,createInlineMarkdownSpec:()=>IM,parseAttributes:()=>qp,parseIndentedBlocks:()=>Zh,renderNestedMarkdownContent:()=>Yp,serializeAttributes:()=>Jp});function qp(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const f=s.map(p=>p.trim().slice(1));e.class=f.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,f,p])=>{var m;const y=parseInt(((m=p.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[y];b&&(e[f]=b.slice(1,-1))});const d=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 d&&d.split(/\s+/).filter(Boolean).forEach(p=>{p.match(/^[a-zA-Z][\w-]*$/)&&(e[p]=!0)}),e}function Jp(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 AM(t){const{nodeName:e,name:n,parseAttributes:r=qp,serializeAttributes:s=Jp,defaultAttributes:i={},requiredAttributes:l=[],allowedAttributes:c}=t,d=n||e,f=p=>{if(!c)return p;const m={};return c.forEach(y=>{y in p&&(m[y]=p[y])}),m};return{parseMarkdown:(p,m)=>{const y={...i,...p.attributes};return m.createNode(e,y,[])},markdownTokenizer:{name:e,level:"block",start(p){var m;const y=new RegExp(`^:::${d}(?:\\s|$)`,"m"),b=(m=p.match(y))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(p,m,y){const b=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=p.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:p=>{const m=f(p.attrs||{}),y=s(m),b=y?` {${y}}`:"";return`:::${d}${b} :::`}}}function OM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=qp,serializeAttributes:i=Jp,defaultAttributes:l={},content:c="block",allowedAttributes:d}=t,f=n||e,p=m=>{if(!d)return m;const y={};return d.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 _=N.length;let R="";const D=/^:::([\w-]*)(\s.*)?/gm,z=m.slice(_);for(D.lastIndex=0;;){const $=D.exec(z);if($===null)break;const U=$.index,Y=$[1];if(!((v=$[2])!=null&&v.endsWith(":::"))){if(Y)T+=1;else if(T-=1,T===0){const X=z.slice(0,U);R=X.trim();const J=m.slice(0,_+U+$[0].length);let q=[];if(R)if(c==="block")for(q=b.blockTokens(X),q.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=b.inlineTokens(H.text))});q.length>0;){const H=q[q.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))q.pop();else break}else q=b.inlineTokens(R);return{type:e,raw:J,attributes:O,content:R,tokens:q}}}}}},renderMarkdown:(m,y)=>{const b=p(m.attrs||{}),v=i(b),w=v?` {${v}}`:"",k=y.renderChildren(m.content||[],`
|
|
133
|
-
|
|
134
|
-
`);return`:::${f}${w}
|
|
135
|
-
|
|
136
|
-
${k}
|
|
137
|
-
|
|
138
|
-
:::`}}}function RM(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 jM(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function IM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=RM,serializeAttributes:i=jM,defaultAttributes:l={},selfClosing:c=!1,allowedAttributes:d}=t,f=n||e,p=y=>{if(!d)return y;const b={};return d.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,_]=k;C=T,N=_||""}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=p(y.attrs||{}),w=i(v),k=w?` ${w}`:"";return c?`[${f}${k}]`:`[${f}${k}]${b}[/${f}]`}}}function Zh(t,e,n){var r,s,i,l;const c=t.split(`
|
|
139
|
-
`),d=[];let f="",p=0;const m=e.baseIndentSize||2;for(;p<c.length;){const y=c[p],b=y.match(e.itemPattern);if(!b){if(d.length>0)break;if(y.trim()===""){p+=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(p+=1;p<c.length;){const _=c[p];if(_.trim()===""){const D=c.slice(p+1).findIndex(U=>U.trim()!=="");if(D===-1)break;if((((s=(r=c[p+1+D].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>w){N.push(_),f=`${f}${_}
|
|
142
|
-
`,p+=1;continue}else break}if((((l=(i=_.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:l.length)||0)>w)N.push(_),f=`${f}${_}
|
|
143
|
-
`,p+=1;else break}let C;const O=N.slice(1);if(O.length>0){const _=O.map(R=>R.slice(w+m)).join(`
|
|
144
|
-
`);_.trim()&&(e.customNestedParser?C=e.customNestedParser(_):C=n.blockTokens(_))}const T=e.createToken(v,C);d.push(T)}if(d.length!==0)return{items:d,raw:f}}function Yp(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]),d=[`${s}${c}`];return l&&l.length>0&&l.forEach(f=>{const p=e.renderChildren([f]);if(p){const m=p.split(`
|
|
145
|
-
`).map(y=>y?e.indent(y):"").join(`
|
|
146
|
-
`);d.push(m)}}),d.join(`
|
|
147
|
-
`)}function LM(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,l=t;s.descendants((c,d)=>{const f=i.mapping.map(d),p=i.mapping.map(d)+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,p,t.type),i.addMark(f,p,b)}}),i.docChanged&&e.view.dispatch(i)}var un=class tk extends Gp{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 Xs(t){return new gM({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=kt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:l}=e,c=r[r.length-1],d=r[0];let f=n.to;if(c){const p=d.search(/\S/),m=n.from+d.indexOf(c),y=m+c.length;if(Kp(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+p,m),f=n.from+p+c.length,l.addMark(n.from+p,f,t.type.create(i||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:DM,getOwnPropertySymbols:PM}=Object,{hasOwnProperty:BM}=Object.prototype;function uh(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function mc(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 d=t(n,r,s);return i.delete(n),i.delete(r),d}}function zM(t){return t!=null?t[Symbol.toStringTag]:void 0}function lv(t){return DM(t).concat(PM(t))}const $M=Object.hasOwn||((t,e)=>BM.call(t,e));function zi(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const FM="__v",UM="__o",HM="_owner",{getOwnPropertyDescriptor:av,keys:cv}=Object;function WM(t,e){return t.byteLength===e.byteLength&&su(new Uint8Array(t),new Uint8Array(e))}function VM(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 KM(t,e){return t.byteLength===e.byteLength&&su(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function GM(t,e){return zi(t.getTime(),e.getTime())}function qM(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function JM(t,e){return t===e}function uv(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,d=0;for(;(l=i.next())&&!l.done;){const f=e.entries();let p=!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],d,m,t,e,n)&&n.equals(y[1],b[1],y[0],b[0],t,e,n)){p=s[m]=!0;break}m++}if(!p)return!1;d++}return!0}const YM=zi;function QM(t,e,n){const r=cv(t);let s=r.length;if(cv(e).length!==s)return!1;for(;s-- >0;)if(!nk(t,e,n,r[s]))return!1;return!0}function gl(t,e,n){const r=lv(t);let s=r.length;if(lv(e).length!==s)return!1;let i,l,c;for(;s-- >0;)if(i=r[s],!nk(t,e,n,i)||(l=av(t,i),c=av(e,i),(l||c)&&(!l||!c||l.configurable!==c.configurable||l.enumerable!==c.enumerable||l.writable!==c.writable)))return!1;return!0}function XM(t,e){return zi(t.valueOf(),e.valueOf())}function ZM(t,e){return t.source===e.source&&t.flags===e.flags}function dv(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 d=e.values();let f=!1,p=0;for(;(c=d.next())&&!c.done;){if(!s[p]&&n.equals(l.value,c.value,l.value,c.value,t,e,n)){f=s[p]=!0;break}p++}if(!f)return!1}return!0}function su(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 eA(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===HM||r===UM||r===FM)&&(t.$$typeof||e.$$typeof)?!0:$M(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const tA="[object ArrayBuffer]",nA="[object Arguments]",rA="[object Boolean]",sA="[object DataView]",iA="[object Date]",oA="[object Error]",lA="[object Map]",aA="[object Number]",cA="[object Object]",uA="[object RegExp]",dA="[object Set]",fA="[object String]",hA={"[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},pA="[object URL]",mA=Object.prototype.toString;function gA({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:l,areNumbersEqual:c,areObjectsEqual:d,arePrimitiveWrappersEqual:f,areRegExpsEqual:p,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 d(k,N,C);if(Array.isArray(k))return e(k,N,C);if(T===Date)return r(k,N,C);if(T===RegExp)return p(k,N,C);if(T===Map)return l(k,N,C);if(T===Set)return m(k,N,C);const _=mA.call(k);if(_===iA)return r(k,N,C);if(_===uA)return p(k,N,C);if(_===lA)return l(k,N,C);if(_===dA)return m(k,N,C);if(_===cA)return typeof k.then!="function"&&typeof N.then!="function"&&d(k,N,C);if(_===pA)return b(k,N,C);if(_===oA)return s(k,N,C);if(_===nA)return d(k,N,C);if(hA[_])return y(k,N,C);if(_===tA)return t(k,N,C);if(_===sA)return n(k,N,C);if(_===rA||_===aA||_===fA)return f(k,N,C);if(v){let R=v[_];if(!R){const D=zM(k);D&&(R=v[D])}if(R)return R(k,N,C)}return!1}}function yA({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:WM,areArraysEqual:n?gl:VM,areDataViewsEqual:KM,areDatesEqual:GM,areErrorsEqual:qM,areFunctionsEqual:JM,areMapsEqual:n?uh(uv,gl):uv,areNumbersEqual:YM,areObjectsEqual:n?gl:QM,arePrimitiveWrappersEqual:XM,areRegExpsEqual:ZM,areSetsEqual:n?uh(dv,gl):dv,areTypedArraysEqual:n?uh(su,gl):su,areUrlsEqual:eA,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=mc(r.areArraysEqual),i=mc(r.areMapsEqual),l=mc(r.areObjectsEqual),c=mc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:l,areSetsEqual:c})}return r}function bA(t){return function(e,n,r,s,i,l,c){return t(e,n,c)}}function vA({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(c,d){const{cache:f=t?new WeakMap:void 0,meta:p}=n();return e(c,d,{cache:f,equals:r,meta:p,strict:s})};if(t)return function(c,d){return e(c,d,{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,d){return e(c,d,i)}}const xA=ti();ti({strict:!0});ti({circular:!0});ti({circular:!0,strict:!0});ti({createInternalComparator:()=>zi});ti({strict:!0,createInternalComparator:()=>zi});ti({circular:!0,createInternalComparator:()=>zi});ti({circular:!0,createInternalComparator:()=>zi,strict:!0});function ti(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=yA(t),l=gA(i),c=n?n(l):bA(l);return vA({circular:e,comparator:l,createState:r,equals:c,strict:s})}var dh={exports:{}},fh={};/**
|
|
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 fv;function wA(){if(fv)return fh;fv=1;var t=Gl(),e=G0();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,l=t.useEffect,c=t.useMemo,d=t.useDebugValue;return fh.useSyncExternalStoreWithSelector=function(f,p,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 D=w.value;if(b(D,R))return T=D}return T=R}if(D=T,r(O,R))return D;var z=y(R);return b!==void 0&&b(D,z)?(O=R,D):(O=R,T=z)}var C=!1,O,T,_=m===void 0?null:m;return[function(){return N(p())},_===null?void 0:function(){return N(_())}]},[p,m,y,b]);var k=s(f,v[0],v[1]);return l(function(){w.hasValue=!0,w.value=k},[k]),d(k),k},fh}var hv;function kA(){return hv||(hv=1,dh.exports=wA()),dh.exports}var SA=kA(),EA=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},NA=({contentComponent:t})=>{const e=q0.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return u.jsx(u.Fragment,{children:Object.values(e)})};function CA(){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]:OE.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 _A=class extends Js.Component{constructor(t){var e;super(t),this.editorContentRef=Js.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=CA(),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 u.jsxs(u.Fragment,{children:[u.jsx("div",{ref:EA(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&u.jsx(NA,{contentComponent:t.contentComponent})]})}},TA=S.forwardRef((t,e)=>{const n=Js.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Js.createElement(_A,{key:n,innerRef:e,...t})}),Qp=Js.memo(TA),MA=typeof window<"u"?S.useLayoutEffect:S.useEffect,AA=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 OA(t){var e;const[n]=S.useState(()=>new AA(t.editor)),r=SA.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:xA);return MA(()=>n.watch(t.editor),[t.editor,n]),S.useDebugValue(r),r}var RA=!1,ep=typeof window>"u",jA=ep||!!(typeof window<"u"&&window.next),IA=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?ep||jA?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 NM(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=S.useRef(t);n.current=t;const[r]=S.useState(()=>new IA(n)),s=q0.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return S.useDebugValue(s),S.useEffect(r.onRender(e)),OA({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var ik=S.createContext({editor:null});ik.Consumer;var LA=S.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),DA=()=>S.useContext(LA);Js.forwardRef((t,e)=>{const{onDragStart:n}=DA(),r=t.as||"div";return u.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Js.createContext({markViewContentRef:()=>{}});var Xp=S.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Xp.displayName="TiptapContext";var PA=()=>S.useContext(Xp);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=S.useMemo(()=>({editor:r}),[r]),i=S.useMemo(()=>({editor:r}),[r]);return u.jsx(ik.Provider,{value:i,children:u.jsx(Xp.Provider,{value:s,children:n})})}ok.displayName="Tiptap";function lk({...t}){const{editor:e}=PA();return u.jsx(Qp,{editor:e,...t})}lk.displayName="Tiptap.Content";Object.assign(ok,{Content:lk});var BA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,zA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,$A=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",St(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[Li({find:BA,type:this.type})]},addPasteRules(){return[Xs({find:zA,type:this.type})]}}),FA=$A,UA=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,HA=un.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",St(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:"",d=(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 d=document.createElement("img");Object.entries(l).forEach(([m,y])=>{if(y!=null)switch(m){case"width":case"height":break;default:d.setAttribute(m,y);break}}),d.src=l.src;const f=new _M({element:d,editor:c,node:s,getPos:i,onResize:(m,y)=>{d.style.width=`${m}px`,d.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}}),p=f.dom;return p.style.visibility="hidden",p.style.pointerEvents="none",d.onload=()=>{p.style.visibility="",p.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ek({find:UA,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Zp=HA;const WA="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",VA="ελ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",tp="numeric",np="ascii",rp="alpha",Ml="asciinumeric",El="alphanumeric",sp="domain",ak="emoji",KA="scheme",GA="slashscheme",hh="whitespace";function qA(t,e){return t in e||(e[t]=[]),e[t]}function Ni(t,e,n){e[tp]&&(e[Ml]=!0,e[El]=!0),e[np]&&(e[Ml]=!0,e[rp]=!0),e[Ml]&&(e[El]=!0),e[rp]&&(e[El]=!0),e[El]&&(e[sp]=!0),e[ak]&&(e[sp]=!0);for(const r in e){const s=qA(r,n);s.indexOf(t)<0&&s.push(t)}}function JA(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Yn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Yn.groups={};Yn.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||Yn.groups;let s;return e&&e.j?s=e:(s=new Yn(e),n&&r&&Ni(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||Yn.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 Yn,Object.assign(l.j,c.j),l.jr.push.apply(l.jr,c.jr),l.jd=c.jd,l.t=c.t):l=new Yn,i){if(r)if(l.t&&typeof l.t=="string"){const d=Object.assign(JA(l.t,r),n);Ni(i,d,r)}else n&&Ni(i,n,r);l.t=i}return s.j[t]=l,l}};const dt=(t,e,n,r,s)=>t.ta(e,n,r,s),qt=(t,e,n,r,s)=>t.tr(e,n,r,s),pv=(t,e,n,r,s)=>t.ts(e,n,r,s),ye=(t,e,n,r,s)=>t.tt(e,n,r,s),ss="WORD",ip="UWORD",ck="ASCIINUMERICAL",uk="ALPHANUMERICAL",Wl="LOCALHOST",op="TLD",lp="UTLD",Bc="SCHEME",yo="SLASH_SCHEME",em="NUM",ap="WS",tm="NL",Al="OPENBRACE",Ol="CLOSEBRACE",iu="OPENBRACKET",ou="CLOSEBRACKET",lu="OPENPAREN",au="CLOSEPAREN",cu="OPENANGLEBRACKET",uu="CLOSEANGLEBRACKET",du="FULLWIDTHLEFTPAREN",fu="FULLWIDTHRIGHTPAREN",hu="LEFTCORNERBRACKET",pu="RIGHTCORNERBRACKET",mu="LEFTWHITECORNERBRACKET",gu="RIGHTWHITECORNERBRACKET",yu="FULLWIDTHLESSTHAN",bu="FULLWIDTHGREATERTHAN",vu="AMPERSAND",xu="APOSTROPHE",wu="ASTERISK",Ps="AT",ku="BACKSLASH",Su="BACKTICK",Eu="CARET",$s="COLON",nm="COMMA",Nu="DOLLAR",$r="DOT",Cu="EQUALS",rm="EXCLAMATION",pr="HYPHEN",Rl="PERCENT",_u="PIPE",Tu="PLUS",Mu="POUND",jl="QUERY",sm="QUOTE",dk="FULLWIDTHMIDDLEDOT",im="SEMI",Fr="SLASH",Il="TILDE",Au="UNDERSCORE",fk="EMOJI",Ou="SYM";var hk=Object.freeze({__proto__:null,ALPHANUMERICAL:uk,AMPERSAND:vu,APOSTROPHE:xu,ASCIINUMERICAL:ck,ASTERISK:wu,AT:Ps,BACKSLASH:ku,BACKTICK:Su,CARET:Eu,CLOSEANGLEBRACKET:uu,CLOSEBRACE:Ol,CLOSEBRACKET:ou,CLOSEPAREN:au,COLON:$s,COMMA:nm,DOLLAR:Nu,DOT:$r,EMOJI:fk,EQUALS:Cu,EXCLAMATION:rm,FULLWIDTHGREATERTHAN:bu,FULLWIDTHLEFTPAREN:du,FULLWIDTHLESSTHAN:yu,FULLWIDTHMIDDLEDOT:dk,FULLWIDTHRIGHTPAREN:fu,HYPHEN:pr,LEFTCORNERBRACKET:hu,LEFTWHITECORNERBRACKET:mu,LOCALHOST:Wl,NL:tm,NUM:em,OPENANGLEBRACKET:cu,OPENBRACE:Al,OPENBRACKET:iu,OPENPAREN:lu,PERCENT:Rl,PIPE:_u,PLUS:Tu,POUND:Mu,QUERY:jl,QUOTE:sm,RIGHTCORNERBRACKET:pu,RIGHTWHITECORNERBRACKET:gu,SCHEME:Bc,SEMI:im,SLASH:Fr,SLASH_SCHEME:yo,SYM:Ou,TILDE:Il,TLD:op,UNDERSCORE:Au,UTLD:lp,UWORD:ip,WORD:ss,WS:ap});const ns=/[a-z]/,yl=new RegExp("\\p{L}","u"),ph=new RegExp("\\p{Emoji}","u"),rs=/\d/,mh=/\s/,mv="\r",gh=`
|
|
156
|
-
`,YA="️",QA="",yh="";let gc=null,yc=null;function XA(t=[]){const e={};Yn.groups=e;const n=new Yn;gc==null&&(gc=gv(WA)),yc==null&&(yc=gv(VA)),ye(n,"'",xu),ye(n,"{",Al),ye(n,"}",Ol),ye(n,"[",iu),ye(n,"]",ou),ye(n,"(",lu),ye(n,")",au),ye(n,"<",cu),ye(n,">",uu),ye(n,"(",du),ye(n,")",fu),ye(n,"「",hu),ye(n,"」",pu),ye(n,"『",mu),ye(n,"』",gu),ye(n,"<",yu),ye(n,">",bu),ye(n,"&",vu),ye(n,"*",wu),ye(n,"@",Ps),ye(n,"`",Su),ye(n,"^",Eu),ye(n,":",$s),ye(n,",",nm),ye(n,"$",Nu),ye(n,".",$r),ye(n,"=",Cu),ye(n,"!",rm),ye(n,"-",pr),ye(n,"%",Rl),ye(n,"|",_u),ye(n,"+",Tu),ye(n,"#",Mu),ye(n,"?",jl),ye(n,'"',sm),ye(n,"/",Fr),ye(n,";",im),ye(n,"~",Il),ye(n,"_",Au),ye(n,"\\",ku),ye(n,"・",dk);const r=qt(n,rs,em,{[tp]:!0});qt(r,rs,r);const s=qt(r,ns,ck,{[Ml]:!0}),i=qt(r,yl,uk,{[El]:!0}),l=qt(n,ns,ss,{[np]:!0});qt(l,rs,s),qt(l,ns,l),qt(s,rs,s),qt(s,ns,s);const c=qt(n,yl,ip,{[rp]:!0});qt(c,ns),qt(c,rs,i),qt(c,yl,c),qt(i,rs,i),qt(i,ns),qt(i,yl,i);const d=ye(n,gh,tm,{[hh]:!0}),f=ye(n,mv,ap,{[hh]:!0}),p=qt(n,mh,ap,{[hh]:!0});ye(n,yh,p),ye(f,gh,d),ye(f,yh,p),qt(f,mh,p),ye(p,mv),ye(p,gh),qt(p,mh,p),ye(p,yh,p);const m=qt(n,ph,fk,{[ak]:!0});ye(m,"#"),qt(m,ph,m),ye(m,YA,m);const y=ye(m,QA);ye(y,"#"),qt(y,ph,m);const b=[[ns,l],[rs,s]],v=[[ns,null],[yl,c],[rs,i]];for(let w=0;w<gc.length;w++)Is(n,gc[w],op,ss,b);for(let w=0;w<yc.length;w++)Is(n,yc[w],lp,ip,v);Ni(op,{tld:!0,ascii:!0},e),Ni(lp,{utld:!0,alpha:!0},e),Is(n,"file",Bc,ss,b),Is(n,"mailto",Bc,ss,b),Is(n,"http",yo,ss,b),Is(n,"https",yo,ss,b),Is(n,"ftp",yo,ss,b),Is(n,"ftps",yo,ss,b),Ni(Bc,{scheme:!0,ascii:!0},e),Ni(yo,{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]?{[KA]:!0}:{[GA]:!0};k.indexOf("-")>=0?C[sp]=!0:ns.test(k)?rs.test(k)?C[Ml]=!0:C[np]=!0:C[tp]=!0,pv(n,k,k,C)}return pv(n,"localhost",Wl,{ascii:!0}),n.jd=new Yn(Ou),{start:n,tokens:Object.assign({groups:e},hk)}}function pk(t,e){const n=ZA(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,s=[];let i=0,l=0;for(;l<r;){let c=t,d=null,f=0,p=null,m=-1,y=-1;for(;l<r&&(d=c.go(n[l]));)c=d,c.accepts()?(m=0,y=0,p=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:p.t,v:e.slice(i-f,i),s:i-f,e:i})}return s}function ZA(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 Is(t,e,n,r,s){let i;const l=e.length;for(let c=0;c<l-1;c++){const d=e[c];t.j[d]?i=t.j[d]:(i=new Yn(r),i.jr=s.slice(),t.j[d]=i),t=i}return i=new Yn(n),i.jr=s.slice(),t.j[e[l-1]]=i,i}function gv(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 Vl={defaultProtocol:"http",events:null,format:yv,formatHref:yv,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function om(t,e=null){let n=Object.assign({},Vl);t&&(n=Object.assign(n,t instanceof om?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}om.prototype={o:Vl,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]:Vl[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 yv(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=Vl.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),d=t.get("target",n,e),f=t.get("rel",n,e),p=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return l.href=r,c&&(l.class=c),d&&(l.target=d),f&&(l.rel=f),p&&Object.assign(l,p),{tagName:s,attributes:l,content:i,eventListeners:m}}};function ed(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 bv=ed("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),vv=ed("text"),e2=ed("nl"),bc=ed("url",{isLink:!0,toHref(t=Vl.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Wl&&t[1].t===$s}}),hr=t=>new Yn(t);function t2({groups:t}){const e=t.domain.concat([vu,wu,Ps,ku,Su,Eu,Nu,Cu,pr,em,Rl,_u,Tu,Mu,Fr,Ou,Il,Au]),n=[xu,$s,nm,$r,rm,Rl,jl,sm,im,cu,uu,Al,Ol,ou,iu,lu,au,du,fu,hu,pu,mu,gu,yu,bu],r=[vu,xu,wu,ku,Su,Eu,Nu,Cu,pr,Al,Ol,Rl,_u,Tu,Mu,jl,Fr,Ou,Il,Au],s=hr(),i=ye(s,Il);dt(i,r,i),dt(i,t.domain,i);const l=hr(),c=hr(),d=hr();dt(s,t.domain,l),dt(s,t.scheme,c),dt(s,t.slashscheme,d),dt(l,r,i),dt(l,t.domain,l);const f=ye(l,Ps);ye(i,Ps,f),ye(c,Ps,f),ye(d,Ps,f);const p=ye(i,$r);dt(p,r,i),dt(p,t.domain,i);const m=hr();dt(f,t.domain,m),dt(m,t.domain,m);const y=ye(m,$r);dt(y,t.domain,m);const b=hr(bv);dt(y,t.tld,b),dt(y,t.utld,b),ye(f,Wl,b);const v=ye(m,pr);ye(v,pr,v),dt(v,t.domain,m),dt(b,t.domain,m),ye(b,$r,y),ye(b,pr,v);const w=ye(b,$s);dt(w,t.numeric,bv);const k=ye(l,pr),N=ye(l,$r);ye(k,pr,k),dt(k,t.domain,l),dt(N,r,i),dt(N,t.domain,l);const C=hr(bc);dt(N,t.tld,C),dt(N,t.utld,C),dt(C,t.domain,l),dt(C,r,i),ye(C,$r,N),ye(C,pr,k),ye(C,Ps,f);const O=ye(C,$s),T=hr(bc);dt(O,t.numeric,T);const _=hr(bc),R=hr();dt(_,e,_),dt(_,n,R),dt(R,e,_),dt(R,n,R),ye(C,Fr,_),ye(T,Fr,_);const D=ye(c,$s),z=ye(d,$s),$=ye(z,Fr),U=ye($,Fr);dt(c,t.domain,l),ye(c,$r,N),ye(c,pr,k),dt(d,t.domain,l),ye(d,$r,N),ye(d,pr,k),dt(D,t.domain,_),ye(D,Fr,_),ye(D,jl,_),dt(U,t.domain,_),dt(U,e,_),ye(U,Fr,_);const Y=[[Al,Ol],[iu,ou],[lu,au],[cu,uu],[du,fu],[hu,pu],[mu,gu],[yu,bu]];for(let X=0;X<Y.length;X++){const[J,q]=Y[X],H=ye(_,J);ye(R,J,H),ye(H,q,_);const W=hr(bc);dt(H,e,W);const re=hr();dt(H,n),dt(W,e,W),dt(W,n,re),dt(re,e,W),dt(re,n,re),ye(W,q,_),ye(re,q,_)}return ye(s,Wl,C),ye(s,tm,e2),{start:s,tokens:hk}}function n2(t,e,n){let r=n.length,s=0,i=[],l=[];for(;s<r;){let c=t,d=null,f=null,p=0,m=null,y=-1;for(;s<r&&!(d=c.go(n[s].t));)l.push(n[s++]);for(;s<r&&(f=d||c.go(n[s].t));)d=null,c=f,c.accepts()?(y=0,m=c):y>=0&&y++,s++,p++;if(y<0)s-=p,s<r&&(l.push(n[s]),s++);else{l.length>0&&(i.push(bh(vv,e,l)),l=[]),s-=y,p-=y;const b=m.t,v=n.slice(s-p,s);i.push(bh(b,e,v))}}return l.length>0&&i.push(bh(vv,e,l)),i}function bh(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 r2=typeof console<"u"&&console&&console.warn||(()=>{}),s2="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",zt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function i2(){return Yn.groups={},zt.scanner=null,zt.parser=null,zt.tokenQueue=[],zt.pluginQueue=[],zt.customSchemes=[],zt.initialized=!1,zt}function xv(t,e=!1){if(zt.initialized&&r2(`linkifyjs: already initialized - will not register custom scheme "${t}" ${s2}`),!/^[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`);zt.customSchemes.push([t,e])}function o2(){zt.scanner=XA(zt.customSchemes);for(let t=0;t<zt.tokenQueue.length;t++)zt.tokenQueue[t][1]({scanner:zt.scanner});zt.parser=t2(zt.scanner.tokens);for(let t=0;t<zt.pluginQueue.length;t++)zt.pluginQueue[t][1]({scanner:zt.scanner,parser:zt.parser});return zt.initialized=!0,zt}function lm(t){return zt.initialized||o2(),n2(zt.parser.start,t,pk(zt.scanner.start,t))}lm.scan=pk;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 om(n),s=lm(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 am="[\0- -\u2029 ]",l2=new RegExp(am),a2=new RegExp(`${am}$`),c2=new RegExp(am,"g");function u2(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function d2(t){return new Et({key:new At("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=Up(n.doc,[...e]);if(Vp(c).forEach(({newRange:f})=>{const p=Mw(r.doc,f,b=>b.isTextblock);let m,y;if(p.length>1)m=p[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(p.length){const b=r.doc.textBetween(f.from,f.to," "," ");if(!a2.test(b))return;m=p[0],y=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&y){const b=y.split(l2).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=lm(v).map(N=>N.toObject(t.defaultProtocol));if(!u2(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=>{Kp(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 f2(t){return new Et({key:new At("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 d=r.target;if(!d)return!1;const f=t.editor.view.dom;l=d.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 d=Dw(e.state,t.type.name),f=(s=l.href)!=null?s:d.href,p=(i=l.target)!=null?i:d.target;f&&(window.open(f,p),c=!0)}return c}}})}function h2(t){return new Et({key:new At("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:l}=i,{empty:c}=l;if(c)return!1;let d="";r.content.forEach(p=>{d+=p.textContent});const f=gk(d,{defaultProtocol:t.defaultProtocol}).find(p=>p.isLink&&p.value===d);return!d||!f||s!==void 0&&!s(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function xi(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(c2,"").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"){xv(t);return}xv(t.scheme,t.optionalSlashes)})},onDestroy(){i2()},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)=>!!xi(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=>!!xi(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=>!!xi(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",St(this.options.HTMLAttributes,t),0]:["a",St(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:"",d=e.renderChildren(t);return c?`[${d}](${l} "${c}")`:`[${d}](${l})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!xi(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=>!!xi(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[Xs({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=>!!xi(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(d2({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!xi(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(f2({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(h2({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),p2=yk;function m2(t={}){return new Et({view(e){return new g2(e,t)}})}class g2{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 d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,p;if(!d||d==document.body&&getComputedStyle(d).position=="static")f=-pageXOffset,p=-pageYOffset;else{let m=d.getBoundingClientRect(),y=m.width/d.offsetWidth,b=m.height/d.offsetHeight;f=m.left-d.scrollLeft*y,p=m.top-d.scrollTop*b}this.element.style.left=(r.left-f)/l+"px",this.element.style.top=(r.top-p)/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 Jt extends Qe{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Jt.valid(r)?new Jt(r):Qe.near(r)}content(){return Se.empty}eq(e){return e instanceof Jt&&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 Jt(e.resolve(n.pos))}getBookmark(){return new cm(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!y2(e)||!b2(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&&Jt.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 d=e.doc.resolve(s);if(Jt.valid(d))return d}for(;;){let l=n>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!$e.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(Jt.valid(c))return c}return null}}}Jt.prototype.visible=!1;Jt.findFrom=Jt.findGapCursorFrom;Qe.jsonID("gapcursor",Jt);class cm{constructor(e){this.pos=e}map(e){return new cm(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Jt.valid(n)?new Jt(n):Qe.near(n)}}function bk(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function y2(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 b2(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 v2(){return new Et({props:{decorations:S2,createSelectionBetween(t,e,n){return e.pos==n.pos&&Jt.valid(n)?new Jt(n):null},handleClick:w2,handleKeyDown:x2,handleDOMEvents:{beforeinput:k2}}})}const x2=Bp({ArrowLeft:vc("horiz",-1),ArrowRight:vc("horiz",1),ArrowUp:vc("vert",-1),ArrowDown:vc("vert",1)});function vc(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,d=l.empty;if(l instanceof Ue){if(!i.endOfTextblock(n)||c.depth==0)return!1;d=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=Jt.findGapCursorFrom(c,e,d);return f?(s&&s(r.tr.setSelection(new Jt(f))),!0):!1}}function w2(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Jt.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&$e.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Jt(r))),!0)}function k2(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Jt))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=ae.empty;for(let l=r.length-1;l>=0;l--)s=ae.from(r[l].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Se(s,0,0));return i.setSelection(Ue.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function S2(t){if(!(t.selection instanceof Jt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",wt.create(t.doc,[jt.widget(t.selection.head,e,{key:"gapcursor"})])}var Ru=200,yn=function(){};yn.prototype.append=function(e){return e.length?(e=yn.from(e),!this.length&&e||e.length<Ru&&this.leafAppend(e)||this.length<Ru&&e.leafPrepend(this)||this.appendInner(e)):this};yn.prototype.prepend=function(e){return e.length?yn.from(e).append(this):this};yn.prototype.appendInner=function(e){return new E2(this,e)};yn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?yn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};yn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};yn.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)};yn.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};yn.from=function(e){return e instanceof yn?e:e&&e.length?new vk(e):yn.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 d=i;d<l;d++)if(s(this.values[d],c+d)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,l,c){for(var d=i-1;d>=l;d--)if(s(this.values[d],c+d)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Ru)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Ru)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})(yn);yn.empty=new vk([]);var E2=(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})(yn);const N2=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,d,f=[],p=[];return this.items.forEach((m,y)=>{if(!m.step){s||(s=this.remapping(r,y+1),i=s.maps.length),i--,p.push(m);return}if(s){p.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+p.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,d=new _r(this.items.slice(0,r).append(p.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:l,selection:c}}addTransform(e,n,r,s){let i=[],l=this.eventCount,c=this.items,d=!s&&c.length?c.get(c.length-1):null;for(let p=0;p<e.steps.length;p++){let m=e.steps[p].invert(e.docs[p]),y=new Ur(e.mapping.maps[p],m,n),b;(b=d&&d.merge(y))&&(y=b,p?i.pop():c=c.slice(0,c.length-1)),i.push(y),n&&(l++,n=void 0),s||(d=y)}let f=l-r.depth;return f>_2&&(c=C2(c,f),l-=f),new _r(c.append(i),l)}remapping(e,n){let r=new Pl;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 d=n;this.items.forEach(y=>{let b=i.getMirror(--d);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(d+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 p=this.items.slice(0,s).append(f).append(r),m=new _r(p,c);return m.emptyItemCount()>N2&&(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 d=l.step.map(n.slice(r)),f=d&&d.getMap();if(r--,f&&n.appendMap(f,r),d){let p=l.selection&&l.selection.map(n.slice(r));p&&i++;let m=new Ur(f.invert(),d,p),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(yn.from(s.reverse()),i)}}_r.empty=new _r(yn.empty,0);function C2(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 Bs{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const _2=20;function T2(t,e,n,r){let s=n.getMeta(Ai),i;if(s)return s.historyState;n.getMeta(O2)&&(t=new Bs(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Ai))return l.getMeta(Ai).redo?new Bs(t.done.addTransform(n,void 0,r,zc(e)),t.undone,wv(n.mapping.maps),t.prevTime,t.prevComposition):new Bs(t.done,t.undone.addTransform(n,void 0,r,zc(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),d=t.prevTime==0||!l&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!M2(n,t.prevRanges)),f=l?vh(t.prevRanges,n.mapping):wv(n.mapping.maps);return new Bs(t.done.addTransform(n,d?e.selection.getBookmark():void 0,r,zc(e)),_r.empty,f,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Bs(t.done.rebased(n,i),t.undone.rebased(n,i),vh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Bs(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function M2(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 wv(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 vh(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 A2(t,e,n){let r=zc(e),s=Ai.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),d=new Bs(n?c:i.remaining,n?i.remaining:c,null,0,-1);return i.transform.setSelection(l).setMeta(Ai,{redo:n,historyState:d})}let xh=!1,kv=null;function zc(t){let e=t.plugins;if(kv!=e){xh=!1,kv=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){xh=!0;break}}return xh}const Ai=new At("history"),O2=new At("closeHistory");function R2(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Et({key:Ai,state:{init(){return new Bs(_r.empty,_r.empty,null,0,-1)},apply(e,n,r){return T2(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=Ai.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=A2(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const wk=xk(!1,!0),kk=xk(!0,!0);bt.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Et({key:new At("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,d=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,d);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,d=i-r,f=c-d,p=c;return e.deleteRange(f,p),!(this.storage.characters({node:e.doc})>r)}})]}});var j2=bt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[m2(this.options)]}});bt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Et({key:new At("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return wt.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((d,f)=>{if(d.isText)return;if(!(s>=f&&s<=f+d.nodeSize-1))return!1;l+=1});let c=0;return t.descendants((d,f)=>{if(d.isText||!(s>=f&&s<=f+d.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(jt.node(f,f+d.nodeSize,{class:this.options.className}))}),wt.create(t,i)}}})]}});var I2=bt.create({name:"gapCursor",addProseMirrorPlugins(){return[v2()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=kt(ze(t,"allowGapCursor",n)))!=null?e:null}}}),Sv="placeholder";function L2(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var D2=bt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Sv,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${L2(this.options.dataAttribute)}`:`data-${Sv}`;return[new Et({key:new At("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,d)=>{const f=s>=d&&s<=d+c.nodeSize,p=!c.isLeaf&&Xu(c);if((f||!this.options.showOnlyCurrent)&&p){const m=[this.options.emptyNodeClass];l&&m.push(this.options.emptyEditorClass);const y=jt.node(d,d+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:d,hasAnchor:f}):this.options.placeholder});i.push(y)}return this.options.includeChildren}),wt.create(e,i)}}})]}});bt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Et({key:new At("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Pw(n.selection)||t.view.dragging?null:wt.create(n.doc,[jt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Ev({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var P2=bt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new At(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 Et({key:e,appendTransaction:(s,i,l)=>{const{doc:c,tr:d,schema:f}=l,p=e.getState(l),m=c.content.size,y=f.nodes[n];if(p)return d.insert(m,y.create())},state:{init:(s,i)=>{const l=i.tr.doc.lastChild;return!Ev({node:l,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const l=s.doc.lastChild;return!Ev({node:l,types:r})}}})]}}),B2=bt.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[R2(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()}}}),td=D2,z2=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",St(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()}}}),$2=z2,F2=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",St(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()}}}),U2=F2;let cp,up;if(typeof WeakMap<"u"){let t=new WeakMap;cp=e=>t.get(e),up=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;cp=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},up=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Yt=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:d,bottom:f}=this.findCell(e);return{left:Math.min(n,l),top:Math.min(s,d),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 cp(t)||up(t,H2(t))}};function H2(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=W2(t),n=t.childCount,r=[];let s=0,i=null;const l=[];for(let f=0,p=e*n;f<p;f++)r[f]=0;for(let f=0,p=0;f<n;f++){const m=t.child(f);p++;for(let 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:p,n:N-O});break}const T=s+O*e;for(let _=0;_<k;_++){r[T+_]==0?r[T+_]=p:(i||(i=[])).push({type:"collision",row:f,pos:p,n:k-_});const R=C&&C[_];if(R){const D=(T+_)%e*2,z=l[D];z==null||z!=R&&l[D+1]==1?(l[D]=R,l[D+1]=1):z==R&&l[D+1]++}}}s+=k,p+=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}),p++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const c=new Yt(e,n,r,i);let d=!1;for(let f=0;!d&&f<l.length;f+=2)l[f]!=null&&l[f+1]<n&&(d=!0);return d&&V2(c,l,t),c}function W2(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 d=0;d<c.childCount;d++){const f=c.child(d);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 V2(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 d=l.attrs;for(let f=0;f<d.colspan;f++){const p=e[(s+f)%t.width*2];p!=null&&(!d.colwidth||d.colwidth[f]!=p)&&((c||(c=K2(d)))[f]=p)}c&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:c})}}function K2(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 Fs=new At("selectingCells");function Di(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 G2(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 nd(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Di(e.$head)||q2(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function q2(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 dp(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function J2(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function um(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=Yt.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 Pi(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 Y2(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 It=class is extends Qe{constructor(e,n=e){const r=e.node(-1),s=Yt.get(r),i=e.start(-1),l=s.rectBetween(e.pos-i,n.pos-i),c=e.node(0),d=s.cellsInRect(l).filter(p=>p!=n.pos-i);d.unshift(n.pos-i);const f=d.map(p=>{const m=r.nodeAt(p);if(!m)throw new RangeError(`No cell with offset ${p} found`);const y=i+p+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(dp(r)&&dp(s)&&um(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 Ue.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Yt.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},l=[];for(let d=s.top;d<s.bottom;d++){const f=[];for(let p=d*n.width+s.left,m=s.left;m<s.right;m++,p++){const y=n.map[p];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=Pi(N,0,w)),k>0&&(N=Pi(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(d).copy(ae.from(f)))}const c=this.isColSelection()&&this.isRowSelection()?e:l;return new Se(ae.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:d}=s[l],f=e.mapping.slice(r);e.replace(f.map(c.pos),f.map(d.pos),l?Se.empty:n)}const i=Qe.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Se(ae.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Yt.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=Yt.get(r),i=e.start(-1),l=s.findCell(e.pos-i),c=s.findCell(n.pos-i),d=e.node(0);return l.top<=c.top?(l.top>0&&(e=d.resolve(i+s.map[l.left])),c.bottom<s.height&&(n=d.resolve(i+s.map[s.width*(s.height-1)+c.right-1]))):(c.top>0&&(n=d.resolve(i+s.map[c.left])),l.bottom<s.height&&(e=d.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))),new is(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Yt.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=Yt.get(r),i=e.start(-1),l=s.findCell(e.pos-i),c=s.findCell(n.pos-i),d=e.node(0);return l.left<=c.left?(l.left>0&&(e=d.resolve(i+s.map[l.top*s.width])),c.right<s.width&&(n=d.resolve(i+s.map[s.width*(c.top+1)-1]))):(c.left>0&&(n=d.resolve(i+s.map[c.top*s.width])),l.right<s.width&&(e=d.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 Q2(this.$anchorCell.pos,this.$headCell.pos)}};It.prototype.visible=!1;Qe.jsonID("cell",It);var Q2=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&&um(n,r)?new It(n,r):Qe.near(r,1)}};function X2(t){if(!(t.selection instanceof It))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(jt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),wt.create(t.doc,e)}function Z2({$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 eO({$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 tO(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,l;if(r instanceof $e&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")i=It.create(s,r.from);else if(l=="row"){const c=s.resolve(r.from+1);i=It.rowSelection(c,c)}else if(!n){const c=Yt.get(r.node),d=r.from+1,f=d+c.map[c.width*c.height-1];i=It.create(s,d+1,f)}}else r instanceof Ue&&Z2(r)?i=Ue.create(s,r.from):r instanceof Ue&&eO(r)&&(i=Ue.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const nO=new At("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 d=e.child(l);for(let f=c,p=Math.min(s,l+3);f<p;f++)if(t.child(f)==d){c=f+1,n+=d.nodeSize;continue e}r(d,n),c<s&&t.child(c).sameMarkup(d)?Ck(t.child(c),d,n+1,r):d.nodesBetween(0,d.content.size,r,n+1),n+=d.nodeSize}}function _k(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=rO(t,s,i,n))};return e?e.doc!=t.doc&&Ck(e.doc,t.doc,0,r):t.doc.descendants(r),n}function rO(t,e,n,r){const s=Yt.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let d=0;d<s.height;d++)i.push(0);for(let d=0;d<s.problems.length;d++){const f=s.problems[d];if(f.type=="collision"){const p=e.nodeAt(f.pos);if(!p)continue;const m=p.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,Pi(m,m.colspan-f.n,f.n))}else if(f.type=="missing")i[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const p=e.nodeAt(f.pos);if(!p)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...p.attrs,rowspan:p.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const p=e.nodeAt(f.pos);if(!p)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...p.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const p=r.mapping.map(n);r.delete(p,p+e.nodeSize)}}let l,c;for(let d=0;d<i.length;d++)i[d]&&(l==null&&(l=d),c=d);for(let d=0,f=n+1;d<s.height;d++){const p=e.child(d),m=f+p.nodeSize,y=i[d];if(y>0){let b="cell";p.firstChild&&(b=p.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=(d==0||l==d-1)&&c==d?f+1:m-1;r.insert(r.mapping.map(w),v)}f=m}return r.setMeta(nO,{fixTables:!0})}function Vr(t){const e=t.selection,n=nd(t),r=n.node(-1),s=n.start(-1),i=Yt.get(r);return{...e instanceof It?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;Y2(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 d=e.map[c],f=r.nodeAt(d);t.setNodeMarkup(t.mapping.map(n+d),null,Ek(f.attrs,s-e.colCount(d))),l+=f.attrs.rowspan-1}else{const d=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),d.createAndFill())}}return t}function sO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Tk(t.tr,n,n.left))}return!0}function iO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Tk(t.tr,n,n.right))}return!0}function oO(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,d=e.map[c],f=n.nodeAt(d),p=f.attrs;if(s>0&&e.map[c-1]==d||s<e.width-1&&e.map[c+1]==d)t.setNodeMarkup(t.mapping.slice(i).map(r+d),null,Pi(p,s-e.colCount(d)));else{const m=t.mapping.slice(i).map(r+d);t.delete(m,m+f.nodeSize)}l+=p.rowspan}}function lO(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;oO(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=Yt.get(i)}e(r)}return!0}function aO(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;aO(e,r,s+c)&&(c=s==0||s==e.height?null:0);for(let f=0,p=e.width*s;f<e.width;f++,p++)if(s>0&&s<e.height&&e.map[p]==e.map[p-e.width]){const m=e.map[p],y=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...y,rowspan:y.rowspan+1}),f+=y.colspan-1}else{var d;const m=c==null?In(r.type.schema).cell:(d=r.nodeAt(e.map[p+c*e.width]))===null||d===void 0?void 0:d.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 cO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Mk(t.tr,n,n.top))}return!0}function uO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Mk(t.tr,n,n.bottom))}return!0}function dO(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 d=new Set;for(let f=0,p=s*e.width;f<e.width;f++,p++){const m=e.map[p];if(!d.has(m)){if(d.add(m),s>0&&m==e.map[p-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[p+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 fO(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;dO(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=Yt.get(n.table)}e(r)}return!0}function Nv(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function hO({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 d=r.top;d<r.bottom;d++){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 d=r.left;d<r.right;d++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[l]==n[l+t])return!0;s++,l++}return!1}function Cv(t,e){const n=t.selection;if(!(n instanceof It)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Vr(t),{map:s}=r;if(hO(s,r))return!1;if(e){const i=t.tr,l={};let c=ae.empty,d,f;for(let p=r.top;p<r.bottom;p++)for(let m=r.left;m<r.right;m++){const y=s.map[p*s.width+m],b=r.table.nodeAt(y);if(!(l[y]||!b))if(l[y]=!0,d==null)d=y,f=b;else{Nv(b)||(c=c.append(b.content));const v=i.mapping.map(y+r.tableStart);i.delete(v,v+b.nodeSize)}}if(d==null||f==null)return!0;if(i.setNodeMarkup(d+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 p=d+1+f.content.size,m=Nv(f)?d+1:p;i.replaceWith(m+r.tableStart,p+r.tableStart,c)}i.setSelection(new It(i.doc.resolve(d+r.tableStart))),e(i)}return!0}function _v(t,e){const n=In(t.schema);return pO(({node:r})=>n[r.type.spec.tableRole])(t,e)}function pO(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof It){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var l;if(s=G2(r.$from),!s)return!1;i=(l=Di(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 d=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const p=Vr(e),m=e.tr;for(let b=0;b<p.right-p.left;b++)d.push(f?{...c,colwidth:f&&f[b]?[f[b]]:null}:c);let y;for(let b=p.top;b<p.bottom;b++){let v=p.map.positionAt(b,p.left,p.table);b==p.top&&(v+=s.nodeSize);for(let w=p.left,k=0;w<p.right;w++,k++)w==p.left&&b==p.top||m.insert(y=m.mapping.map(v+p.tableStart,1),t({node:s,row:b,col:w}).createAndFill(d[k]))}m.setNodeMarkup(i,t({node:s,row:p.top,col:p.left}),d[0]),r instanceof It&&m.setSelection(new It(m.doc.resolve(r.$anchorCell.pos),y?m.doc.resolve(y):void 0)),n(m)}return!0}}function mO(t,e){return function(n,r){if(!Or(n))return!1;const s=nd(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof It?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 gO(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(d=>s.table.nodeAt(d));for(let d=0;d<l.length;d++)c[d].type==r.header_cell&&i.setNodeMarkup(s.tableStart+l[d],r.cell,c[d].attrs);if(i.steps.length===0)for(let d=0;d<l.length;d++)i.setNodeMarkup(s.tableStart+l[d],r.header_cell,c[d].attrs);n(i)}return!0}}function Tv(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 Kl(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?gO(t):function(n,r){if(!Or(n))return!1;if(r){const s=In(n.schema),i=Vr(n),l=n.tr,c=Tv("row",i,s),d=Tv("column",i,s),f=(t==="column"?c:t==="row"&&d)?1:0,p=t=="column"?{left:0,top:f,right:1,bottom:i.map.height}:t=="row"?{left:f,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?d?s.cell:s.header_cell:t=="row"?c?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(y=>{const b=y+i.tableStart,v=l.doc.nodeAt(b);v&&l.setNodeMarkup(b,m,v.attrs)}),r(l)}return!0}}Kl("row",{useDeprecatedLogic:!0});Kl("column",{useDeprecatedLogic:!0});const yO=Kl("cell",{useDeprecatedLogic:!0});function bO(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 Mv(t){return function(e,n){if(!Or(e))return!1;const r=bO(nd(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(Ue.between(s,J2(s))).scrollIntoView())}return!0}}function vO(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 xc(t,e){const n=t.selection;if(!(n instanceof It))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 xO(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 d=0;d<e.childCount;d++){let f=e.child(d).content;const p=d?0:Math.max(0,n-1),m=d<e.childCount-1?0:Math.max(0,r-1);(p||m)&&(f=fp(In(l).row,new Se(f,p,m)).content),c.push(f)}else if(i=="cell"||i=="header_cell")c.push(n||r?fp(In(l).row,new Se(e,n,r)).content:e);else return null;return wO(l,c)}function wO(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:d}=i.child(l).attrs;for(let f=s;f<s+c;f++)n[f]=(n[f]||0)+d}}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(ae.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(ae.from(l))}return{height:e.length,width:r,rows:e}}function fp(t,e){const n=t.createAndFill();return new kp(n).replace(0,n.content.size,e).doc}function kO({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],l=[];for(let c=0;c<n.length;c++){const d=n[c],f=[];for(let p=i[c]||0,m=0;p<r;m++){let y=d.child(m%d.childCount);p+y.attrs.colspan>r&&(y=y.type.createChecked(Pi(y.attrs,y.attrs.colspan,p+y.attrs.colspan-r),y.content)),f.push(y),p+=y.attrs.colspan;for(let b=1;b<y.attrs.rowspan;b++)i[c+b]=(i[c+b]||0)+y.attrs.colspan}l.push(ae.from(f))}n=l,t=r}if(e!=s){const i=[];for(let l=0,c=0;l<s;l++,c++){const d=[],f=n[c%e];for(let p=0;p<f.childCount;p++){let m=f.child(p);l+m.attrs.rowspan>s&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,s-m.attrs.rowspan)},m.content)),d.push(m)}i.push(ae.from(d))}n=i,e=s}return{width:t,height:e,rows:n}}function SO(t,e,n,r,s,i,l){const c=t.doc.type.schema,d=In(c);let f,p;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==d.cell?w=f||(f=d.cell.createAndFill()):w=p||(p=d.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==d.header_cell;m.push(k?p||(p=d.header_cell.createAndFill()):f||(f=d.cell.createAndFill()))}const y=d.row.create(null,ae.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||p)}function Av(t,e,n,r,s,i,l,c){if(l==0||l==e.height)return!1;let d=!1;for(let f=s;f<i;f++){const p=l*e.width+f,m=e.map[p];if(e.map[p-e.width]==m){d=!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 d}function Ov(t,e,n,r,s,i,l,c){if(l==0||l==e.width)return!1;let d=!1;for(let f=s;f<i;f++){const p=f*e.width+l,m=e.map[p];if(e.map[p-1]==m){d=!0;const y=n.nodeAt(m),b=e.colCount(m),v=t.mapping.slice(c).map(m+r);t.setNodeMarkup(v,null,Pi(y.attrs,l-b,y.attrs.colspan-(l-b))),t.insert(v+y.nodeSize,y.type.createAndFill(Pi(y.attrs,0,l-b))),f+=y.attrs.rowspan-1}}return d}function Rv(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=Yt.get(i);const{top:c,left:d}=r,f=d+s.width,p=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=Yt.get(i),y=m.mapping.maps.length}SO(m,l,i,n,f,p,y)&&b(),Av(m,l,i,n,d,f,c,y)&&b(),Av(m,l,i,n,d,f,p,y)&&b(),Ov(m,l,i,n,c,p,d,y)&&b(),Ov(m,l,i,n,c,p,f,y)&&b();for(let v=c;v<p;v++){const w=l.positionAt(v,d,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 It(m.doc.resolve(n+l.positionAt(c,d,i)),m.doc.resolve(n+l.positionAt(p-1,f-1,i)))),e(m)}const EO=Bp({ArrowLeft:wc("horiz",-1),ArrowRight:wc("horiz",1),ArrowUp:wc("vert",-1),ArrowDown:wc("vert",1),"Shift-ArrowLeft":kc("horiz",-1),"Shift-ArrowRight":kc("horiz",1),"Shift-ArrowUp":kc("vert",-1),"Shift-ArrowDown":kc("vert",1),Backspace:xc,"Mod-Backspace":xc,Delete:xc,"Mod-Delete":xc});function $c(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function wc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof It)return $c(n,r,Qe.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 $c(n,r,Qe.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(l),d=Sk(c,t,e);let f;return d?f=Qe.near(d,1):e<0?f=Qe.near(n.doc.resolve(c.before(-1)),-1):f=Qe.near(n.doc.resolve(c.after(-1)),1),$c(n,r,f)}}}function kc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let l;if(i instanceof It)l=i;else{const d=Ak(s,t,e);if(d==null)return!1;l=new It(n.doc.resolve(d))}const c=Sk(l.$headCell,t,e);return c?$c(n,r,new It(l.$anchorCell,c)):!1}}function NO(t,e){const n=t.state.doc,r=Di(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new It(r))),!0):!1}function CO(t,e,n){if(!Or(t.state))return!1;let r=xO(n);const s=t.state.selection;if(s instanceof It){r||(r={width:1,height:1,rows:[ae.from(fp(In(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),l=s.$anchorCell.start(-1),c=Yt.get(i).rectBetween(s.$anchorCell.pos-l,s.$headCell.pos-l);return r=kO(r,c.right-c.left,c.bottom-c.top),Rv(t.state,t.dispatch,l,c,r),!0}else if(r){const i=nd(t.state),l=i.start(-1);return Rv(t.state,t.dispatch,l,Yt.get(i.node(-1)).findCell(i.pos-l),r),!0}else return!1}function _O(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=jv(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof It)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Di(t.state.selection.$anchor))!=null&&((n=wh(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(d,f){let p=wh(t,f);const m=Fs.getState(t.state)==null;if(!p||!um(d,p))if(m)p=d;else return;const y=new It(d,p);if(m||!t.state.selection.eq(y)){const b=t.state.tr.setSelection(y);m&&b.setMeta(Fs,d.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",c),Fs.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Fs,-1))}function c(d){const f=d,p=Fs.getState(t.state);let m;if(p!=null)m=t.state.doc.resolve(p);else if(jv(t,f.target)!=r&&(m=wh(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 Ue))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 jv(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function wh(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&&Di(t.state.doc.resolve(r))||Di(t.state.doc.resolve(s))}var TO=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")),hp(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,hp(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function hp(t,e,n,r,s,i){let l=0,c=!0,d=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),d)d.style.width!=N&&(d.style.width=N),d=d.nextSibling;else{const C=document.createElement("col");C.style.width=N,e.appendChild(C)}}}for(;d;){var p;const m=d.nextSibling;(p=d.parentNode)===null||p===void 0||p.removeChild(d),d=m}c?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}const rr=new At("tableColumnResizing");function MO({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=TO,lastColumnResizable:s=!0}={}){const i=new Et({key:rr,state:{init(l,c){var d;const f=(d=i.spec)===null||d===void 0||(d=d.props)===null||d===void 0?void 0:d.nodeViews,p=In(c.schema).table.name;return r&&f&&(f[p]=(m,y)=>new r(m,n,y)),new AO(-1,!1)},apply(l,c){return c.apply(l)}},props:{attributes:l=>{const c=rr.getState(l);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,c)=>{OO(l,c,t,s)},mouseleave:l=>{RO(l)},mousedown:(l,c)=>{jO(l,c,e,n)}},decorations:l=>{const c=rr.getState(l);if(c&&c.activeHandle>-1)return BO(l,c.activeHandle)},nodeViews:{}}});return i}var AO=class Fc{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(rr);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 dp(e.doc.resolve(s))||(s=-1),new Fc(s,n.dragging)}return n}};function OO(t,e,n,r){if(!t.editable)return;const s=rr.getState(t.state);if(s&&!s.dragging){const i=LO(e.target);let l=-1;if(i){const{left:c,right:d}=i.getBoundingClientRect();e.clientX-c<=n?l=Iv(t,e,"left",n):d-e.clientX<=n&&(l=Iv(t,e,"right",n))}if(l!=s.activeHandle){if(!r&&l!==-1){const c=t.state.doc.resolve(l),d=c.node(-1),f=Yt.get(d),p=c.start(-1);if(f.colCount(c.pos-p)+c.nodeAfter.attrs.colspan-1==f.width-1)return}Ok(t,l)}}}function RO(t){if(!t.editable)return;const e=rr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Ok(t,-1)}function jO(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=rr.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const c=t.state.doc.nodeAt(l.activeHandle),d=IO(t,l.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(rr,{setDragging:{startX:e.clientX,startWidth:d}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",p);const y=rr.getState(t.state);y!=null&&y.dragging&&(DO(t,y.activeHandle,Lv(y.dragging,m,n)),t.dispatch(t.state.tr.setMeta(rr,{setDragging:null})))}function p(m){if(!m.which)return f(m);const y=rr.getState(t.state);if(y&&y.dragging){const b=Lv(y.dragging,m,n);Dv(t,y.activeHandle,b,r)}}return Dv(t,l.activeHandle,d,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",p),e.preventDefault(),!0}function IO(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 d=0;d<n;d++)r[d]&&(l-=r[d],c--);return l/c}function LO(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Iv(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=Di(t.state.doc.resolve(l));if(!c)return-1;if(n=="right")return c.pos;const d=Yt.get(c.node(-1)),f=c.start(-1),p=d.map.indexOf(c.pos-f);return p%d.width==0?-1:f+d.map[p-1]}function Lv(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(rr,{setHandle:e}))}function DO(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Yt.get(s),l=r.start(-1),c=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,d=t.state.tr;for(let f=0;f<i.height;f++){const p=f*i.width+c;if(f&&i.map[p]==i.map[p-i.width])continue;const m=i.map[p],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():PO(y.colspan);v[b]=n,d.setNodeMarkup(l+m,null,{...y,colwidth:v})}d.docChanged&&t.dispatch(d)}function Dv(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),l=s.start(-1),c=Yt.get(i).colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;let d=t.domAtPos(s.start(-1)).node;for(;d&&d.nodeName!="TABLE";)d=d.parentNode;d&&hp(i,d.firstChild,d,r,c,n)}function PO(t){return Array(t).fill(0)}function BO(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return wt.empty;const i=Yt.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 p=c+f*i.width;if((c==i.width-1||i.map[p]!=i.map[p+1])&&(f==0||i.map[p]!=i.map[p-i.width])){var d;const m=i.map[p],y=l+m+s.nodeAt(m).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((d=rr.getState(t))===null||d===void 0)&&d.dragging&&n.push(jt.node(l+m,l+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(jt.widget(y,b))}}return wt.create(t.doc,n)}function zO({allowTableNodeSelection:t=!1}={}){return new Et({key:Fs,state:{init(){return null},apply(e,n){const r=e.getMeta(Fs);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:X2,handleDOMEvents:{mousedown:_O},createSelectionBetween(e){return Fs.getState(e.state)!=null?e.state.selection:null},handleTripleClick:NO,handleKeyDown:EO,handlePaste:CO},appendTransaction(e,n,r){return tO(r,_k(r,n),t)}})}var Rk=un.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),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",St(this.options.HTMLAttributes,t),0]}}),jk=un.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",St(this.options.HTMLAttributes,t),0]}}),Ik=un.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",St(this.options.HTMLAttributes,t),0]}});function pp(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Pv(t,e,n,r,s,i){var l;let c=0,d=!0,f=e.firstChild;const p=t.firstChild;if(p!==null)for(let y=0,b=0;y<p.childCount;y+=1){const{colspan:v,colwidth:w}=p.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||(d=!1),f){if(f.style.width!==C){const[O,T]=pp(r,N);f.style.setProperty(O,T)}f=f.nextSibling}else{const O=document.createElement("col"),[T,_]=pp(r,N);O.style.setProperty(T,_),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);d&&!m?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var $O=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")),Pv(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,Pv(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 FO(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]=pp(e,k);l.push(["col",{style:`${N}: ${C}`}])}}const d=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...l],tableWidth:d,tableMinWidth:f}}function Bv(t,e){return t.createAndFill()}function UO(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 HO(t,e,n,r,s){const i=UO(t),l=[],c=[];for(let f=0;f<n;f+=1){const p=Bv(i.cell);if(p&&c.push(p),r){const m=Bv(i.header_cell);m&&l.push(m)}}const d=[];for(let f=0;f<e;f+=1)d.push(i.row.createChecked(null,r&&f===0?l:c));return i.table.createChecked(null,d)}function WO(t){return t instanceof It}var Sc=({editor:t})=>{const{selection:e}=t.state;if(!WO(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},VO="";function KO(t){return(t||"").replace(/\s+/g," ").trim()}function GO(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:VO;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(_=>e.renderChildren(_)).join(s):N=k.content?e.renderChildren(k.content):"";const C=KO(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 d=(v,w)=>v+" ".repeat(Math.max(0,w-v.length)),f=i[0],p=f.some(v=>v.isHeader);let m=`
|
|
160
|
-
`;const y=new Array(l).fill(0).map((v,w)=>p&&f[w]&&f[w].text||"");return m+=`| ${y.map((v,w)=>d(v,c[w])).join(" | ")} |
|
|
161
|
-
`,m+=`| ${c.map(v=>"-".repeat(Math.max(3,v))).join(" | ")} |
|
|
162
|
-
`,(p?i.slice(1):i).forEach(v=>{m+=`| ${new Array(l).fill(0).map((w,k)=>d(v[k]&&v[k].text||"",c[k])).join(" | ")} |
|
|
163
|
-
`}),m}var qO=GO,Lk=un.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:$O,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}=FO(t,this.options.cellMinWidth),i=e.style;function l(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const c=["table",St(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)=>qO(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const l=HO(i.schema,t,e,n);if(s){const c=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection(Ue.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>sO(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>iO(t,e),deleteColumn:()=>({state:t,dispatch:e})=>lO(t,e),addRowBefore:()=>({state:t,dispatch:e})=>cO(t,e),addRowAfter:()=>({state:t,dispatch:e})=>uO(t,e),deleteRow:()=>({state:t,dispatch:e})=>fO(t,e),deleteTable:()=>({state:t,dispatch:e})=>vO(t,e),mergeCells:()=>({state:t,dispatch:e})=>Cv(t,e),splitCell:()=>({state:t,dispatch:e})=>_v(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Kl("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Kl("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>yO(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Cv(t,e)?!0:_v(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>mO(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Mv(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Mv(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&_k(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=It.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:Sc,"Mod-Backspace":Sc,Delete:Sc,"Mod-Delete":Sc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[MO({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],zO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:kt(ze(t,"tableRole",e))}}});bt.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(jk.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Ik.configure(this.options.tableRow)),t}});var JO=Object.defineProperty,YO=(t,e)=>{for(var n in e)JO(t,n,{get:e[n],enumerable:!0})},QO="listItem",zv="textStyle",$v=/^\s*([-+*])\s$/,Dk=un.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",St(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(QO,this.editor.getAttributes(zv)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Mo({find:$v,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Mo({find:$v,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(zv),editor:this.editor})),[t]}}),Pk=un.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",St(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)=>Yp(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)}}}),XO={};YO(XO,{findListItemPos:()=>Xl,getNextListDepth:()=>dm,handleBackspace:()=>mp,handleDelete:()=>gp,hasListBefore:()=>Bk,hasListItemAfter:()=>ZO,hasListItemBefore:()=>zk,listItemHasSubList:()=>$k,nextListIsDeeper:()=>Fk,nextListIsHigher:()=>Uk});var Xl=(t,e)=>{const{$from:n}=e.selection,r=on(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}},dm=(t,e)=>{const n=Xl(t,e);if(!n)return!1;const[,r]=PT(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)},$k=(t,e,n)=>{if(!n)return!1;const r=on(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},mp=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Qs(t.state,e)&&Bk(t.state,e,n)){const{$anchor:c}=t.state.selection,d=t.state.doc.resolve(c.before()-1),f=[];d.node().descendants((y,b)=>{y.type.name===e&&f.push({node:y,pos:b})});const p=f.at(-1);if(!p)return!1;const m=t.state.doc.resolve(d.start()+p.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Qs(t.state,e)||!FT(t.state))return!1;const r=Xl(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),l=$k(e,t.state,i);return zk(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Fk=(t,e)=>{const n=dm(t,e),r=Xl(t,e);return!r||!n?!1:n>r.depth},Uk=(t,e)=>{const n=dm(t,e),r=Xl(t,e);return!r||!n?!1:n<r.depth},gp=(t,e)=>{if(!Qs(t.state,e)||!$T(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:Fk(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()},ZO=(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=bt.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&gp(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&&gp(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&&mp(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&&mp(t,n,r)&&(e=!0)}),e}}}}),Fv=/^(\s*)(\d+)\.\s+(.*)$/,eR=/^\s/;function tR(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Fv);if(!i)break;const[,l,c,d]=i,f=l.length;let p=d,m=n+1;const y=[s];for(;m<t.length;){const b=t[m];if(b.match(Fv))break;if(b.trim()==="")y.push(b),p+=`
|
|
165
|
-
`,m+=1;else if(b.match(eR))y.push(b),p+=`
|
|
166
|
-
${b.slice(f+2)}`,m+=1;else break}e.push({indent:f,number:parseInt(c,10),content:p.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
|
-
`),d=((r=c[0])==null?void 0:r.trim())||"",f=[];d&&f.push({type:"paragraph",raw:d,tokens:n.inlineTokens(d)});const p=c.slice(1).join(`
|
|
169
|
-
`).trim();if(p){const b=n.blockTokens(p);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 nR(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 rR="listItem",Uv="textStyle",Hv=/^(\d+)\.\s$/,Vk=un.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",St(this.options.HTMLAttributes,n),0]:["ol",St(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?nR(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]=tR(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(rR,this.editor.getAttributes(Uv)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Mo({find:Hv,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=Mo({find:Hv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Uv)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),sR=/^\s*(\[([( |x])?\])\s$/,Kk=un.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",St(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 Yp(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"),d=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,d),Object.entries(e).forEach(([m,y])=>{s.setAttribute(m,y)});let p=new Set(Object.keys(e));return{dom:s,contentDOM:d,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=Hl(m,y),v=new Set(Object.keys(b)),w=this.options.HTMLAttributes;return p.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)}),p=v,!0}}}},addInputRules(){return[Mo({find:sR,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Gk=un.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",St(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=Zh(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,d)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:d}),customNestedParser:r},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(i)},s=Zh(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()}}});bt.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 iR=Kk,oR=Gk,lR=20,qk=(t,e=0)=>{const n=[];return!t.children.length||e>lR||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...qk(r,e+1))}),n},aR=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&&aR(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",St(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}}}}),cR=bt.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const 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()}}}),uR=bt.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const 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()}}}),dR=bt.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),fR=bt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),hR=bt.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});bt.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(cR.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(uR.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(dR.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(fR.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(hR.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Jk.configure(this.options.textStyle)),t}});var pR=t=>Qt({find:/--$/,replace:t??"—"}),mR=t=>Qt({find:/\.\.\.$/,replace:t??"…"}),gR=t=>Qt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),yR=t=>Qt({find:/"$/,replace:t??"”"}),bR=t=>Qt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),vR=t=>Qt({find:/'$/,replace:t??"’"}),xR=t=>Qt({find:/<-$/,replace:t??"←"}),wR=t=>Qt({find:/->$/,replace:t??"→"}),kR=t=>Qt({find:/\(c\)$/,replace:t??"©"}),SR=t=>Qt({find:/\(tm\)$/,replace:t??"™"}),ER=t=>Qt({find:/\(sm\)$/,replace:t??"℠"}),NR=t=>Qt({find:/\(r\)$/,replace:t??"®"}),CR=t=>Qt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),_R=t=>Qt({find:/\+\/-$/,replace:t??"±"}),TR=t=>Qt({find:/!=$/,replace:t??"≠"}),MR=t=>Qt({find:/<<$/,replace:t??"«"}),AR=t=>Qt({find:/>>$/,replace:t??"»"}),OR=t=>Qt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),RR=t=>Qt({find:/\^2$/,replace:t??"²"}),jR=t=>Qt({find:/\^3$/,replace:t??"³"}),IR=t=>Qt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),LR=t=>Qt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),DR=bt.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(pR(this.options.emDash)),this.options.ellipsis!==!1&&t.push(mR(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(gR(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(yR(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(bR(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(vR(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(xR(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(wR(this.options.rightArrow)),this.options.copyright!==!1&&t.push(kR(this.options.copyright)),this.options.trademark!==!1&&t.push(SR(this.options.trademark)),this.options.servicemark!==!1&&t.push(ER(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(NR(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(CR(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(_R(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(TR(this.options.notEqual)),this.options.laquo!==!1&&t.push(MR(this.options.laquo)),this.options.raquo!==!1&&t.push(AR(this.options.raquo)),this.options.multiplication!==!1&&t.push(OR(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(RR(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(jR(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(IR(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(LR(this.options.threeQuarters)),t}}),PR=DR,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",St(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()}}}),BR=Yk,kn=[];for(var kh=0;kh<256;++kh)kn.push((kh+256).toString(16).slice(1));function zR(t,e=0){return(kn[t[e+0]]+kn[t[e+1]]+kn[t[e+2]]+kn[t[e+3]]+"-"+kn[t[e+4]]+kn[t[e+5]]+"-"+kn[t[e+6]]+kn[t[e+7]]+"-"+kn[t[e+8]]+kn[t[e+9]]+"-"+kn[t[e+10]]+kn[t[e+11]]+kn[t[e+12]]+kn[t[e+13]]+kn[t[e+14]]+kn[t[e+15]]).toLowerCase()}var Ec,$R=new Uint8Array(16);function FR(){if(!Ec&&(Ec=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ec))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ec($R)}var UR=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Wv={randomUUID:UR};function HR(t,e,n){if(Wv.randomUUID&&!t)return Wv.randomUUID();t=t||{};var r=t.random||(t.rng||FR)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,zR(r)}function WR(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 VR=bt.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>HR(),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 d;return(d=c==null?void 0:c.options)==null?void 0:d.provider}),i=(t=s==null?void 0:s.options)==null?void 0:t.provider,l=()=>{const{view:c,state:d}=this.editor,{tr:f,doc:p}=d,{types:m,attributeName:y,generateID:b}=this.options;nu(p,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 Et({key:new At("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:d}=s,{types:f,attributeName:p,generateID:m}=this.options,y=Up(r.doc,n),{mapping:b}=y;if(Vp(y).forEach(({newRange:w})=>{const k=Mw(s.doc,w,C=>f.includes(C.type.name)),N=k.map(({node:C})=>C.attrs[p]).filter(C=>C!==null);k.forEach(({node:C,pos:O},T)=>{var _;const R=(_=d.doc.nodeAt(O))==null?void 0:_.attrs[p];if(R===null){d.setNodeMarkup(O,void 0,{...C.attrs,[p]:m({node:C,pos:O})});return}const D=k[T+1];if(D&&C.content.size===0){const Y=d.doc.nodeAt(D.pos);if(Y!=null&&Y.attrs[p]&&Y.attrs[p]!==R)return;d.setNodeMarkup(D.pos,void 0,{...D.node.attrs,[p]:R}),N[T+1]=R;const X=m({node:C,pos:O});return d.setNodeMarkup(O,void 0,{...C.attrs,[p]:X}),N[T]=X,d}const z=WR(N),{deleted:$}=b.invert().mapResult(O);$&&z.includes(R)&&d.setNodeMarkup(O,void 0,{...C.attrs,[p]:m({node:C,pos:O})})})}),!!d.steps.length)return d.setStoredMarks(s.tr.storedMarks),d.setMeta("__uniqueIDTransaction",!0),d},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(d=>{if(d.isText){c.push(d);return}if(!r.includes(d.type.name)){c.push(d.copy(i(d.content)));return}const f=d.type.create({...d.attrs,[s]:null},i(d.content),d.marks);c.push(f)}),ae.from(c)};return e=!1,new Se(i(n.content),n.openStart,n.openEnd)}}})]}}),fm=VR,ju=(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]},KR=/^\s*>\s$/,GR=un.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ju("blockquote",{...St(this.options.HTMLAttributes,t),children:ju("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(d=>d.trim()===""?n:`${n} ${d}`);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[Mo({find:KR,type:this.type})]}}),qR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,JR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,YR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,QR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,XR=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 ju("strong",{...St(this.options.HTMLAttributes,t),children:ju("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[Li({find:qR,type:this.type}),Li({find:YR,type:this.type})]},addPasteRules(){return[Xs({find:JR,type:this.type}),Xs({find:QR,type:this.type})]}}),ZR=/(^|[^`])`([^`]+)`(?!`)$/,ej=/(^|[^`])`([^`]+)`(?!`)/g,tj=Ar.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",St(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[Li({find:ZR,type:this.type})]},addPasteRules(){return[Xs({find:ej,type:this.type})]}}),Sh=4,nj=/^```([a-z]+)?[\s\n]$/,rj=/^~~~([a-z]+)?[\s\n]$/,Qk=un.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Sh,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",St(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:Sh,{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:d})=>{const{from:f,to:p}=s,b=r.doc.textBetween(f,p,`
|
|
182
|
-
`,`
|
|
183
|
-
`).split(`
|
|
184
|
-
`).map(v=>c+v).join(`
|
|
185
|
-
`);return d.replaceWith(f,p,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:Sh,{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 d;const{pos:f}=i,p=i.start(),m=i.end(),b=r.doc.textBetween(p,m,`
|
|
186
|
-
`,`
|
|
187
|
-
`).split(`
|
|
188
|
-
`);let v=0,w=0;const k=f-p;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=((d=b[v].match(/^ */))==null?void 0:d[0])||"",O=Math.min(C.length,n);if(O===0)return!0;let T=p;for(let R=0;R<v;R+=1)T+=b[R].length+1;return c.delete(T,T+O),f-T<=O&&c.setSelection(Ue.create(c.doc,T)),!0}):t.commands.command(({tr:c})=>{const{from:d,to:f}=s,y=r.doc.textBetween(d,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(d,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(Qe.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Xh({find:nj,type:this.type,getAttributes:t=>({language:t[1]})}),Xh({find:rj,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Et({key:new At("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,d=c.text(n.replace(/\r\n?/g,`
|
|
195
|
-
`));return l.replaceSelectionWith(this.type.create({language:i},d)),l.selection.$from.parent.type!==this.type&&l.setSelection(Ue.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),sj=Qk,ij=un.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
196
|
-
|
|
197
|
-
`):""}),oj=un.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",St(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,d=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:p})=>{if(p&&d&&l){const m=d.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()}}}),lj=un.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,St(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=>Xh({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),aj=un.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",St(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!TM(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:d}=l.selection,f=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?l.setSelection(Ue.create(l.doc,d.pos+1)):d.nodeAfter.isBlock?l.setSelection($e.create(l.doc,d.pos)):l.setSelection(Ue.create(l.doc,d.pos));else{const p=i.schema.nodes[this.options.nextNodeType]||d.parent.type.contentMatch.defaultType,m=p==null?void 0:p.create();m&&(l.insert(f,m),l.setSelection(Ue.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ek({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),cj=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,uj=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,dj=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,fj=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,hj=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",St(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[Li({find:cj,type:this.type}),Li({find:dj,type:this.type})]},addPasteRules(){return[Xs({find:uj,type:this.type}),Xs({find:fj,type:this.type})]}}),Vv=" ",pj=" ",mj=un.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",St(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===Vv||r[0].text===pj)?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?Vv:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),gj=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,yj=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,bj=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",St(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[Li({find:gj,type:this.type})]},addPasteRules(){return[Xs({find:yj,type:this.type})]}}),vj=un.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),xj=bt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(XR.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(GR.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Dk.configure(this.options.bulletList)),this.options.code!==!1&&s.push(tj.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Qk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(ij.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(j2.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(I2.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(oj.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(lj.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(B2.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(aj.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(hj.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(mj.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(bj.configure(this.options.strike)),this.options.text!==!1&&s.push(vj.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(P2.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),hm=xj,Eh,Kv;function wj(){if(Kv)return Eh;Kv=1;function t(I){return I instanceof Map?I.clear=I.delete=I.set=function(){throw new Error("map is read-only")}:I instanceof Set&&(I.add=I.clear=I.delete=function(){throw new Error("set is read-only")}),Object.freeze(I),Object.getOwnPropertyNames(I).forEach(ie=>{const xe=I[ie],Ye=typeof xe;(Ye==="object"||Ye==="function")&&!Object.isFrozen(xe)&&t(xe)}),I}class e{constructor(ie){ie.data===void 0&&(ie.data={}),this.data=ie.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(I){return I.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(I,...ie){const xe=Object.create(null);for(const Ye in I)xe[Ye]=I[Ye];return ie.forEach(function(Ye){for(const Ct in Ye)xe[Ct]=Ye[Ct]}),xe}const s="</span>",i=I=>!!I.scope,l=(I,{prefix:ie})=>{if(I.startsWith("language:"))return I.replace("language:","language-");if(I.includes(".")){const xe=I.split(".");return[`${ie}${xe.shift()}`,...xe.map((Ye,Ct)=>`${Ye}${"_".repeat(Ct+1)}`)].join(" ")}return`${ie}${I}`};class c{constructor(ie,xe){this.buffer="",this.classPrefix=xe.classPrefix,ie.walk(this)}addText(ie){this.buffer+=n(ie)}openNode(ie){if(!i(ie))return;const xe=l(ie.scope,{prefix:this.classPrefix});this.span(xe)}closeNode(ie){i(ie)&&(this.buffer+=s)}value(){return this.buffer}span(ie){this.buffer+=`<span class="${ie}">`}}const d=(I={})=>{const ie={children:[]};return Object.assign(ie,I),ie};class f{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ie){this.top.children.push(ie)}openNode(ie){const xe=d({scope:ie});this.add(xe),this.stack.push(xe)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ie){return this.constructor._walk(ie,this.rootNode)}static _walk(ie,xe){return typeof xe=="string"?ie.addText(xe):xe.children&&(ie.openNode(xe),xe.children.forEach(Ye=>this._walk(ie,Ye)),ie.closeNode(xe)),ie}static _collapse(ie){typeof ie!="string"&&ie.children&&(ie.children.every(xe=>typeof xe=="string")?ie.children=[ie.children.join("")]:ie.children.forEach(xe=>{f._collapse(xe)}))}}class p extends f{constructor(ie){super(),this.options=ie}addText(ie){ie!==""&&this.add(ie)}startScope(ie){this.openNode(ie)}endScope(){this.closeNode()}__addSublanguage(ie,xe){const Ye=ie.root;xe&&(Ye.scope=`language:${xe}`),this.add(Ye)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(I){return I?typeof I=="string"?I:I.source:null}function y(I){return w("(?=",I,")")}function b(I){return w("(?:",I,")*")}function v(I){return w("(?:",I,")?")}function w(...I){return I.map(xe=>m(xe)).join("")}function k(I){const ie=I[I.length-1];return typeof ie=="object"&&ie.constructor===Object?(I.splice(I.length-1,1),ie):{}}function N(...I){return"("+(k(I).capture?"":"?:")+I.map(Ye=>m(Ye)).join("|")+")"}function C(I){return new RegExp(I.toString()+"|").exec("").length-1}function O(I,ie){const xe=I&&I.exec(ie);return xe&&xe.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _(I,{joinWith:ie}){let xe=0;return I.map(Ye=>{xe+=1;const Ct=xe;let Tt=m(Ye),Te="";for(;Tt.length>0;){const _e=T.exec(Tt);if(!_e){Te+=Tt;break}Te+=Tt.substring(0,_e.index),Tt=Tt.substring(_e.index+_e[0].length),_e[0][0]==="\\"&&_e[1]?Te+="\\"+String(Number(_e[1])+Ct):(Te+=_e[0],_e[0]==="("&&xe++)}return Te}).map(Ye=>`(${Ye})`).join(ie)}const R=/\b\B/,D="[a-zA-Z]\\w*",z="[a-zA-Z_]\\w*",$="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Y="\\b(0b[01]+)",X="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",J=(I={})=>{const ie=/^#![ ]*\//;return I.binary&&(I.begin=w(ie,/.*\b/,I.binary,/\b.*/)),r({scope:"meta",begin:ie,end:/$/,relevance:0,"on:begin":(xe,Ye)=>{xe.index!==0&&Ye.ignoreMatch()}},I)},q={begin:"\\\\[\\s\\S]",relevance:0},H={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[q]},W={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[q]},re={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(I,ie,xe={}){const Ye=r({scope:"comment",begin:I,end:ie,contains:[]},xe);Ye.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 Ct=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 Ye.contains.push({begin:w(/[ ]+/,"(",Ct,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ye},K=V("//","$"),B=V("/\\*","\\*/"),A=V("#","$"),L={scope:"number",begin:$,relevance:0},te={scope:"number",begin:U,relevance:0},oe={scope:"number",begin:Y,relevance:0},he={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[q,{begin:/\[/,end:/\]/,relevance:0,contains:[q]}]},ne={scope:"title",begin:D,relevance:0},ge={scope:"title",begin:z,relevance:0},De={begin:"\\.\\s*"+z,relevance:0};var ce=Object.freeze({__proto__:null,APOS_STRING_MODE:H,BACKSLASH_ESCAPE:q,BINARY_NUMBER_MODE:oe,BINARY_NUMBER_RE:Y,COMMENT:V,C_BLOCK_COMMENT_MODE:B,C_LINE_COMMENT_MODE:K,C_NUMBER_MODE:te,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(I){return Object.assign(I,{"on:begin":(ie,xe)=>{xe.data._beginMatch=ie[1]},"on:end":(ie,xe)=>{xe.data._beginMatch!==ie[1]&&xe.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:D,MATCH_NOTHING_RE:R,METHOD_GUARD:De,NUMBER_MODE:L,NUMBER_RE:$,PHRASAL_WORDS_MODE:re,QUOTE_STRING_MODE:W,REGEXP_MODE:he,RE_STARTERS_RE:X,SHEBANG:J,TITLE_MODE:ne,UNDERSCORE_IDENT_RE:z,UNDERSCORE_TITLE_MODE:ge});function pe(I,ie){I.input[I.index-1]==="."&&ie.ignoreMatch()}function se(I,ie){I.className!==void 0&&(I.scope=I.className,delete I.className)}function Pe(I,ie){ie&&I.beginKeywords&&(I.begin="\\b("+I.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",I.__beforeBegin=pe,I.keywords=I.keywords||I.beginKeywords,delete I.beginKeywords,I.relevance===void 0&&(I.relevance=0))}function Oe(I,ie){Array.isArray(I.illegal)&&(I.illegal=N(...I.illegal))}function Je(I,ie){if(I.match){if(I.begin||I.end)throw new Error("begin & end are not supported with match");I.begin=I.match,delete I.match}}function Ne(I,ie){I.relevance===void 0&&(I.relevance=1)}const et=(I,ie)=>{if(!I.beforeMatch)return;if(I.starts)throw new Error("beforeMatch cannot be used with starts");const xe=Object.assign({},I);Object.keys(I).forEach(Ye=>{delete I[Ye]}),I.keywords=xe.keywords,I.begin=w(xe.beforeMatch,y(xe.begin)),I.starts={relevance:0,contains:[Object.assign(xe,{endsParent:!0})]},I.relevance=0,delete xe.beforeMatch},Le=["of","and","for","in","not","or","if","then","parent","list","value"],He="keyword";function ke(I,ie,xe=He){const Ye=Object.create(null);return typeof I=="string"?Ct(xe,I.split(" ")):Array.isArray(I)?Ct(xe,I):Object.keys(I).forEach(function(Tt){Object.assign(Ye,ke(I[Tt],ie,Tt))}),Ye;function Ct(Tt,Te){ie&&(Te=Te.map(_e=>_e.toLowerCase())),Te.forEach(function(_e){const Ve=_e.split("|");Ye[Ve[0]]=[Tt,fe(Ve[0],Ve[1])]})}}function fe(I,ie){return ie?Number(ie):qe(I)?0:1}function qe(I){return Le.includes(I.toLowerCase())}const at={},it=I=>{console.error(I)},mt=(I,...ie)=>{console.log(`WARN: ${I}`,...ie)},$t=(I,ie)=>{at[`${I}/${ie}`]||(console.log(`Deprecated as of ${I}. ${ie}`),at[`${I}/${ie}`]=!0)},Lt=new Error;function Z(I,ie,{key:xe}){let Ye=0;const Ct=I[xe],Tt={},Te={};for(let _e=1;_e<=ie.length;_e++)Te[_e+Ye]=Ct[_e],Tt[_e+Ye]=!0,Ye+=C(ie[_e-1]);I[xe]=Te,I[xe]._emit=Tt,I[xe]._multi=!0}function We(I){if(Array.isArray(I.begin)){if(I.skip||I.excludeBegin||I.returnBegin)throw it("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Lt;if(typeof I.beginScope!="object"||I.beginScope===null)throw it("beginScope must be object"),Lt;Z(I,I.begin,{key:"beginScope"}),I.begin=_(I.begin,{joinWith:""})}}function Fe(I){if(Array.isArray(I.end)){if(I.skip||I.excludeEnd||I.returnEnd)throw it("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Lt;if(typeof I.endScope!="object"||I.endScope===null)throw it("endScope must be object"),Lt;Z(I,I.end,{key:"endScope"}),I.end=_(I.end,{joinWith:""})}}function xt(I){I.scope&&typeof I.scope=="object"&&I.scope!==null&&(I.beginScope=I.scope,delete I.scope)}function tt(I){xt(I),typeof I.beginScope=="string"&&(I.beginScope={_wrap:I.beginScope}),typeof I.endScope=="string"&&(I.endScope={_wrap:I.endScope}),We(I),Fe(I)}function Xe(I){function ie(Te,_e){return new RegExp(m(Te),"m"+(I.case_insensitive?"i":"")+(I.unicodeRegex?"u":"")+(_e?"g":""))}class xe{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(_e,Ve){Ve.position=this.position++,this.matchIndexes[this.matchAt]=Ve,this.regexes.push([Ve,_e]),this.matchAt+=C(_e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const _e=this.regexes.map(Ve=>Ve[1]);this.matcherRe=ie(_(_e,{joinWith:"|"}),!0),this.lastIndex=0}exec(_e){this.matcherRe.lastIndex=this.lastIndex;const Ve=this.matcherRe.exec(_e);if(!Ve)return null;const nn=Ve.findIndex((Rr,ps)=>ps>0&&Rr!==void 0),Ot=this.matchIndexes[nn];return Ve.splice(0,nn),Object.assign(Ve,Ot)}}class Ye{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(_e){if(this.multiRegexes[_e])return this.multiRegexes[_e];const Ve=new xe;return this.rules.slice(_e).forEach(([nn,Ot])=>Ve.addRule(nn,Ot)),Ve.compile(),this.multiRegexes[_e]=Ve,Ve}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(_e,Ve){this.rules.push([_e,Ve]),Ve.type==="begin"&&this.count++}exec(_e){const Ve=this.getMatcher(this.regexIndex);Ve.lastIndex=this.lastIndex;let nn=Ve.exec(_e);if(this.resumingScanAtSamePosition()&&!(nn&&nn.index===this.lastIndex)){const Ot=this.getMatcher(0);Ot.lastIndex=this.lastIndex+1,nn=Ot.exec(_e)}return nn&&(this.regexIndex+=nn.position+1,this.regexIndex===this.count&&this.considerAll()),nn}}function Ct(Te){const _e=new Ye;return Te.contains.forEach(Ve=>_e.addRule(Ve.begin,{rule:Ve,type:"begin"})),Te.terminatorEnd&&_e.addRule(Te.terminatorEnd,{type:"end"}),Te.illegal&&_e.addRule(Te.illegal,{type:"illegal"}),_e}function Tt(Te,_e){const Ve=Te;if(Te.isCompiled)return Ve;[se,Je,tt,et].forEach(Ot=>Ot(Te,_e)),I.compilerExtensions.forEach(Ot=>Ot(Te,_e)),Te.__beforeBegin=null,[Pe,Oe,Ne].forEach(Ot=>Ot(Te,_e)),Te.isCompiled=!0;let nn=null;return typeof Te.keywords=="object"&&Te.keywords.$pattern&&(Te.keywords=Object.assign({},Te.keywords),nn=Te.keywords.$pattern,delete Te.keywords.$pattern),nn=nn||/\w+/,Te.keywords&&(Te.keywords=ke(Te.keywords,I.case_insensitive)),Ve.keywordPatternRe=ie(nn,!0),_e&&(Te.begin||(Te.begin=/\B|\b/),Ve.beginRe=ie(Ve.begin),!Te.end&&!Te.endsWithParent&&(Te.end=/\B|\b/),Te.end&&(Ve.endRe=ie(Ve.end)),Ve.terminatorEnd=m(Ve.end)||"",Te.endsWithParent&&_e.terminatorEnd&&(Ve.terminatorEnd+=(Te.end?"|":"")+_e.terminatorEnd)),Te.illegal&&(Ve.illegalRe=ie(Te.illegal)),Te.contains||(Te.contains=[]),Te.contains=[].concat(...Te.contains.map(function(Ot){return Dn(Ot==="self"?Te:Ot)})),Te.contains.forEach(function(Ot){Tt(Ot,Ve)}),Te.starts&&Tt(Te.starts,_e),Ve.matcher=Ct(Ve),Ve}if(I.compilerExtensions||(I.compilerExtensions=[]),I.contains&&I.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return I.classNameAliases=r(I.classNameAliases||{}),Tt(I)}function nt(I){return I?I.endsWithParent||nt(I.starts):!1}function Dn(I){return I.variants&&!I.cachedVariants&&(I.cachedVariants=I.variants.map(function(ie){return r(I,{variants:null},ie)})),I.cachedVariants?I.cachedVariants:nt(I)?r(I,{starts:I.starts?r(I.starts):null}):Object.isFrozen(I)?r(I):I}var ln="11.11.1";class ir extends Error{constructor(ie,xe){super(ie),this.name="HTMLInjectionError",this.html=xe}}const ct=n,vn=r,le=Symbol("nomatch"),Ee=7,lt=function(I){const ie=Object.create(null),xe=Object.create(null),Ye=[];let Ct=!0;const Tt="Could not find the language '{}', did you forget to load/include a language module?",Te={disableAutodetect:!0,name:"Plain text",contains:[]};let _e={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ve(be){return _e.noHighlightRe.test(be)}function nn(be){let Be=be.className+" ";Be+=be.parentNode?be.parentNode.className:"";const ut=_e.languageDetectRe.exec(Be);if(ut){const ht=vr(ut[1]);return ht||(mt(Tt.replace("{}",ut[1])),mt("Falling back to no-highlight mode for this block.",be)),ht?ut[1]:"no-highlight"}return Be.split(/\s+/).find(ht=>Ve(ht)||vr(ht))}function Ot(be,Be,ut){let ht="",Xt="";typeof Be=="object"?(ht=be,ut=Be.ignoreIllegals,Xt=Be.language):($t("10.7.0","highlight(lang, code, ...args) has been deprecated."),$t("10.7.0",`Please use highlight(code, options) instead.
|
|
200
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),Xt=be,ht=Be),ut===void 0&&(ut=!0);const Ht={code:ht,language:Xt};ri("before:highlight",Ht);const jr=Ht.result?Ht.result:Rr(Ht.language,Ht.code,ut);return jr.code=Ht.code,ri("after:highlight",jr),jr}function Rr(be,Be,ut,ht){const Xt=Object.create(null);function Ht(we,Me){return we.keywords[Me]}function jr(){if(!st.keywords){Zt.addText(Nt);return}let we=0;st.keywordPatternRe.lastIndex=0;let Me=st.keywordPatternRe.exec(Nt),Ze="";for(;Me;){Ze+=Nt.substring(we,Me.index);const pt=or.case_insensitive?Me[0].toLowerCase():Me[0],Kt=Ht(st,pt);if(Kt){const[dn,ud]=Kt;if(Zt.addText(Ze),Ze="",Xt[pt]=(Xt[pt]||0)+1,Xt[pt]<=Ee&&(oi+=ud),dn.startsWith("_"))Ze+=Me[0];else{const oa=or.classNameAliases[dn]||dn;Bn(Me[0],oa)}}else Ze+=Me[0];we=st.keywordPatternRe.lastIndex,Me=st.keywordPatternRe.exec(Nt)}Ze+=Nt.substring(we),Zt.addText(Ze)}function Ui(){if(Nt==="")return;let we=null;if(typeof st.subLanguage=="string"){if(!ie[st.subLanguage]){Zt.addText(Nt);return}we=Rr(st.subLanguage,Nt,!0,Bo[st.subLanguage]),Bo[st.subLanguage]=we._top}else we=ni(Nt,st.subLanguage.length?st.subLanguage:null);st.relevance>0&&(oi+=we.relevance),Zt.__addSublanguage(we._emitter,we.language)}function Pn(){st.subLanguage!=null?Ui():jr(),Nt=""}function Bn(we,Me){we!==""&&(Zt.startScope(Me),Zt.addText(we),Zt.endScope())}function si(we,Me){let Ze=1;const pt=Me.length-1;for(;Ze<=pt;){if(!we._emit[Ze]){Ze++;continue}const Kt=or.classNameAliases[we[Ze]]||we[Ze],dn=Me[Ze];Kt?Bn(dn,Kt):(Nt=dn,jr(),Nt=""),Ze++}}function ms(we,Me){return we.scope&&typeof we.scope=="string"&&Zt.openNode(or.classNameAliases[we.scope]||we.scope),we.beginScope&&(we.beginScope._wrap?(Bn(Nt,or.classNameAliases[we.beginScope._wrap]||we.beginScope._wrap),Nt=""):we.beginScope._multi&&(si(we.beginScope,Me),Nt="")),st=Object.create(we,{parent:{value:st}}),st}function ii(we,Me,Ze){let pt=O(we.endRe,Ze);if(pt){if(we["on:end"]){const Kt=new e(we);we["on:end"](Me,Kt),Kt.isMatchIgnored&&(pt=!1)}if(pt){for(;we.endsParent&&we.parent;)we=we.parent;return we}}if(we.endsWithParent)return ii(we.parent,Me,Ze)}function ad(we){return st.matcher.regexIndex===0?(Nt+=we[0],1):(bs=!0,0)}function cd(we){const Me=we[0],Ze=we.rule,pt=new e(Ze),Kt=[Ze.__beforeBegin,Ze["on:begin"]];for(const dn of Kt)if(dn&&(dn(we,pt),pt.isMatchIgnored))return ad(Me);return Ze.skip?Nt+=Me:(Ze.excludeBegin&&(Nt+=Me),Pn(),!Ze.returnBegin&&!Ze.excludeBegin&&(Nt=Me)),ms(Ze,we),Ze.returnBegin?0:Me.length}function Do(we){const Me=we[0],Ze=Be.substring(we.index),pt=ii(st,we,Ze);if(!pt)return le;const Kt=st;st.endScope&&st.endScope._wrap?(Pn(),Bn(Me,st.endScope._wrap)):st.endScope&&st.endScope._multi?(Pn(),si(st.endScope,we)):Kt.skip?Nt+=Me:(Kt.returnEnd||Kt.excludeEnd||(Nt+=Me),Pn(),Kt.excludeEnd&&(Nt=Me));do st.scope&&Zt.closeNode(),!st.skip&&!st.subLanguage&&(oi+=st.relevance),st=st.parent;while(st!==pt.parent);return pt.starts&&ms(pt.starts,we),Kt.returnEnd?0:Me.length}function ia(){const we=[];for(let Me=st;Me!==or;Me=Me.parent)Me.scope&&we.unshift(Me.scope);we.forEach(Me=>Zt.openNode(Me))}let gs={};function ys(we,Me){const Ze=Me&&Me[0];if(Nt+=we,Ze==null)return Pn(),0;if(gs.type==="begin"&&Me.type==="end"&&gs.index===Me.index&&Ze===""){if(Nt+=Be.slice(Me.index,Me.index+1),!Ct){const pt=new Error(`0 width match regex (${be})`);throw pt.languageName=be,pt.badRule=gs.rule,pt}return 1}if(gs=Me,Me.type==="begin")return cd(Me);if(Me.type==="illegal"&&!ut){const pt=new Error('Illegal lexeme "'+Ze+'" for mode "'+(st.scope||"<unnamed>")+'"');throw pt.mode=st,pt}else if(Me.type==="end"){const pt=Do(Me);if(pt!==le)return pt}if(Me.type==="illegal"&&Ze==="")return Nt+=`
|
|
201
|
-
`,1;if(li>1e5&&li>Me.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Nt+=Ze,Ze.length}const or=vr(be);if(!or)throw it(Tt.replace("{}",be)),new Error('Unknown language: "'+be+'"');const Po=Xe(or);let gt="",st=ht||Po;const Bo={},Zt=new _e.__emitter(_e);ia();let Nt="",oi=0,Ir=0,li=0,bs=!1;try{if(or.__emitTokens)or.__emitTokens(Be,Zt);else{for(st.matcher.considerAll();;){li++,bs?bs=!1:st.matcher.considerAll(),st.matcher.lastIndex=Ir;const we=st.matcher.exec(Be);if(!we)break;const Me=Be.substring(Ir,we.index),Ze=ys(Me,we);Ir=we.index+Ze}ys(Be.substring(Ir))}return Zt.finalize(),gt=Zt.toHTML(),{language:be,value:gt,relevance:oi,illegal:!1,_emitter:Zt,_top:st}}catch(we){if(we.message&&we.message.includes("Illegal"))return{language:be,value:ct(Be),illegal:!0,relevance:0,_illegalBy:{message:we.message,index:Ir,context:Be.slice(Ir-100,Ir+100),mode:we.mode,resultSoFar:gt},_emitter:Zt};if(Ct)return{language:be,value:ct(Be),illegal:!1,relevance:0,errorRaised:we,_emitter:Zt,_top:st};throw we}}function ps(be){const Be={value:ct(be),illegal:!1,relevance:0,_top:Te,_emitter:new _e.__emitter(_e)};return Be._emitter.addText(be),Be}function ni(be,Be){Be=Be||_e.languages||Object.keys(ie);const ut=ps(be),ht=Be.filter(vr).filter(sa).map(Pn=>Rr(Pn,be,!1));ht.unshift(ut);const Xt=ht.sort((Pn,Bn)=>{if(Pn.relevance!==Bn.relevance)return Bn.relevance-Pn.relevance;if(Pn.language&&Bn.language){if(vr(Pn.language).supersetOf===Bn.language)return 1;if(vr(Bn.language).supersetOf===Pn.language)return-1}return 0}),[Ht,jr]=Xt,Ui=Ht;return Ui.secondBest=jr,Ui}function id(be,Be,ut){const ht=Be&&xe[Be]||ut;be.classList.add("hljs"),be.classList.add(`language-${ht}`)}function jo(be){let Be=null;const ut=nn(be);if(Ve(ut))return;if(ri("before:highlightElement",{el:be,language:ut}),be.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",be);return}if(be.children.length>0&&(_e.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(be)),_e.throwUnescapedHTML))throw new ir("One of your code blocks includes unescaped HTML.",be.innerHTML);Be=be;const ht=Be.textContent,Xt=ut?Ot(ht,{language:ut,ignoreIllegals:!0}):ni(ht);be.innerHTML=Xt.value,be.dataset.highlighted="yes",id(be,ut,Xt.language),be.result={language:Xt.language,re:Xt.relevance,relevance:Xt.relevance},Xt.secondBest&&(be.secondBest={language:Xt.secondBest.language,relevance:Xt.secondBest.relevance}),ri("after:highlightElement",{el:be,result:Xt,text:ht})}function od(be){_e=vn(_e,be)}const Kr=()=>{$i(),$t("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Zl(){$i(),$t("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Io=!1;function $i(){function be(){$i()}if(document.readyState==="loading"){Io||window.addEventListener("DOMContentLoaded",be,!1),Io=!0;return}document.querySelectorAll(_e.cssSelector).forEach(jo)}function ea(be,Be){let ut=null;try{ut=Be(I)}catch(ht){if(it("Language definition for '{}' could not be registered.".replace("{}",be)),Ct)it(ht);else throw ht;ut=Te}ut.name||(ut.name=be),ie[be]=ut,ut.rawDefinition=Be.bind(null,I),ut.aliases&&ra(ut.aliases,{languageName:be})}function ta(be){delete ie[be];for(const Be of Object.keys(xe))xe[Be]===be&&delete xe[Be]}function na(){return Object.keys(ie)}function vr(be){return be=(be||"").toLowerCase(),ie[be]||ie[xe[be]]}function ra(be,{languageName:Be}){typeof be=="string"&&(be=[be]),be.forEach(ut=>{xe[ut.toLowerCase()]=Be})}function sa(be){const Be=vr(be);return Be&&!Be.disableAutodetect}function Ut(be){be["before:highlightBlock"]&&!be["before:highlightElement"]&&(be["before:highlightElement"]=Be=>{be["before:highlightBlock"](Object.assign({block:Be.el},Be))}),be["after:highlightBlock"]&&!be["after:highlightElement"]&&(be["after:highlightElement"]=Be=>{be["after:highlightBlock"](Object.assign({block:Be.el},Be))})}function ld(be){Ut(be),Ye.push(be)}function Lo(be){const Be=Ye.indexOf(be);Be!==-1&&Ye.splice(Be,1)}function ri(be,Be){const ut=be;Ye.forEach(function(ht){ht[ut]&&ht[ut](Be)})}function Fi(be){return $t("10.7.0","highlightBlock will be removed entirely in v12.0"),$t("10.7.0","Please use highlightElement now."),jo(be)}Object.assign(I,{highlight:Ot,highlightAuto:ni,highlightAll:$i,highlightElement:jo,highlightBlock:Fi,configure:od,initHighlighting:Kr,initHighlightingOnLoad:Zl,registerLanguage:ea,unregisterLanguage:ta,listLanguages:na,getLanguage:vr,registerAliases:ra,autoDetection:sa,inherit:vn,addPlugin:ld,removePlugin:Lo}),I.debugMode=function(){Ct=!1},I.safeMode=function(){Ct=!0},I.versionString=ln,I.regex={concat:w,lookahead:y,either:N,optional:v,anyNumberOfTimes:b};for(const be in ce)typeof ce[be]=="object"&&t(ce[be]);return Object.assign(I,ce),I},Dt=lt({});return Dt.newInstance=()=>lt({}),Eh=Dt,Dt.HighlightJS=Dt,Dt.default=Dt,Eh}var kj=wj();const Xk=zu(kj);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 Gv(t){return t.value||t.children||[]}function Sj(t){return!!Xk.getLanguage(t)}function qv({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return nu(t,i=>i.type.name===e).forEach(i=>{var l;let c=i.pos+1;const d=i.node.attrs.language||r,f=n.listLanguages(),p=d&&(f.includes(d)||Sj(d)||(l=n.registered)!=null&&l.call(n,d))?Gv(n.highlight(d,i.node.textContent)):Gv(n.highlightAuto(i.node.textContent));Zk(p).forEach(m=>{const y=c+m.text.length;if(m.classes.length){const b=jt.inline(c,y,{class:m.classes.join(" ")});s.push(b)}c=y})}),wt.create(t,s)}function Ej(t){return typeof t=="function"}function Nj({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>Ej(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new Et({key:new At("lowlight"),state:{init:(s,{doc:i})=>qv({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,l,c)=>{const d=l.selection.$head.parent.type.name,f=c.selection.$head.parent.type.name,p=nu(l.doc,y=>y.type.name===t),m=nu(c.doc,y=>y.type.name===t);return s.docChanged&&([d,f].includes(t)||m.length!==p.length||s.steps.some(y=>y.from!==void 0&&y.to!==void 0&&p.some(b=>b.pos>=y.from&&b.pos+b.node.nodeSize<=y.to)))?qv({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 Cj=sj.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))||[],Nj({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),_j=Cj;function Tj(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})"/})]},p={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},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},_={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,c,n,t.C_BLOCK_COMMENT_MODE,p,f],D={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},z={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,p]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,c,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,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(D,z,_,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 Mj(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=Tj(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 Aj(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 d={match:/\\"/},f={className:"string",begin:/'/,end:/'/},p={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"],_=["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,..._]},contains:[b,t.SHEBANG(),v,m,i,l,N,c,d,f,p,n]}}function Oj(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})"/})]},p={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},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,p,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,p,c,{begin:/\(/,end:/\)/,keywords:k,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,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 Rj(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})"/})]},p={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},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},_={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,c,n,t.C_BLOCK_COMMENT_MODE,p,f],D={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},z={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,p]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,c,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,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(D,z,_,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 jj(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)*"}),d={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},p={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},m=t.inherit(p,{illegal:/\n/}),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,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.C_BLOCK_COMMENT_MODE],b.contains=[k,v,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const N={variants:[f,w,v,p,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,d,{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,d,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},T]}}const Ij=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_-]*/}}),Lj=["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"],Dj=["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"],Pj=[...Lj,...Dj],Bj=["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(),zj=["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(),$j=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Fj=["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 Uj(t){const e=t.regex,n=Ij(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:":("+zj.join("|")+")"},{begin:":(:)?("+$j.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Fj.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:Bj.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+Pj.join("|")+")\\b"}]}}function Hj(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 Wj(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 Vj(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 Kj(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},d=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,p=/'[^']*'/,m=e.either(d,f,p),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 bo="[0-9](_*[0-9])*",Nc=`\\.(${bo})`,Cc="[0-9a-fA-F](_*[0-9a-fA-F])*",Jv={className:"number",variants:[{begin:`(\\b(${bo})((${Nc})|\\.)?|(${Nc}))[eE][+-]?(${bo})[fFdD]?\\b`},{begin:`\\b(${bo})((${Nc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Nc})[fFdD]?\\b`},{begin:`\\b(${bo})[fFdD]\\b`},{begin:`\\b0[xX]((${Cc})\\.?|(${Cc})?\\.(${Cc}))[pP][+-]?(${bo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Cc})[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 Gj(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+e1("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),d={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},p={className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:d,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[p,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:d,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[f,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,Jv,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},Jv,f]}}const Yv="[A-Za-z$_][0-9A-Za-z$_]*",qj=["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"],Jj=["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"],Yj=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Qj=[].concat(r1,t1,n1);function Xj(t){const e=t.regex,n=(V,{after:K})=>{const B="</"+V[0].slice(1);return V.input.indexOf(B,K)!==-1},r=Yv,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,K)=>{const B=V[0].length+V.index,A=V.input[B];if(A==="<"||A===","){K.ignoreMatch();return}A===">"&&(n(V,{after:B})||K.ignoreMatch());let L;const te=V.input.substring(B);if(L=te.match(/^\s*=/)){K.ignoreMatch();return}if((L=te.match(/^\s+extends\s+/))&&L.index===0){K.ignoreMatch();return}}},c={$pattern:Yv,keyword:qj,literal:Jj,built_in:Qj,"variable.language":Yj},d="[0-9](_?[0-9])*",f=`\\.(${d})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},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),_=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:_},D={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"}}]},z={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]}},$={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},Y={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(V){return e.concat("(?!",V.join("|"),")")}const J={match:e.concat(/\b/,X([...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},H={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},W="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",re={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(W)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:z},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),$,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,C,{match:/\$\d+/},m,z,{scope:"attr",match:r+e.lookahead(":"),relevance:0},re,{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:W,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:_}]}]},{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"]}]}]},U,{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]},J,Y,D,H,{match:/\$[(.]/}]}}function Zj(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 vo="[0-9](_*[0-9])*",_c=`\\.(${vo})`,Tc="[0-9a-fA-F](_*[0-9a-fA-F])*",eI={className:"number",variants:[{begin:`(\\b(${vo})((${_c})|\\.)?|(${_c}))[eE][+-]?(${vo})[fFdD]?\\b`},{begin:`\\b(${vo})((${_c})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${_c})[fFdD]?\\b`},{begin:`\\b(${vo})[fFdD]\\b`},{begin:`\\b0[xX]((${Tc})\\.?|(${Tc})?\\.(${Tc}))[pP][+-]?(${vo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Tc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function tI(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+")?"},d={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(l,{className:"string"}),"self"]}]},f=eI,p=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,p,n,r,c,d,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[m,t.C_LINE_COMMENT_MODE,p],relevance:0},t.C_LINE_COMMENT_MODE,p,c,d,l,t.C_NUMBER_MODE]},p]},{begin:[/class|interface|trait/,/\s+/,t.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},t.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},c,d]},l,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
|
|
202
|
-
`},f]}}const nI=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_-]*/}}),rI=["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"],sI=["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=[...rI,...sI],oI=["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(),lI=["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(),aI=s1.concat(i1).sort().reverse();function cI(t){const e=nI(t),n=aI,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",l=[],c=[],d=function(O){return{className:"string",begin:"~?"+O+".*?"+O}},f=function(O,T,_){return{className:O,begin:T,relevance:_}},p={$pattern:/[a-z-]+/,keyword:r,attribute:oI.join(" ")},m={begin:"\\(",end:"\\)",contains:c,keywords:p,relevance:0};c.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,d("'"),d('"'),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("+lI.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:p,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("+iI.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 uI(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 dI(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 fI(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+.-]*/,d={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}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=t.inherit(f,{contains:[]}),y=t.inherit(p,{contains:[]});f.contains.push(y),p.contains.push(m);let b=[n,d];return[f,p,m,y].forEach(N=>{N.contains=N.contains.concat(b)}),b=b.concat(f,p),{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,p,{className:"quote",begin:"^>\\s+",contains:b,end:"$"},s,r,d,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function hI(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"]},d={$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:"("+d.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:d,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function pI(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*\(.*?\))?/},d={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},p=[t.BACKSLASH_ESCAPE,i,d],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=[d,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),l,{className:"string",contains:p,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin: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 mI(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:/\?>/}]},d={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=t.inherit(t.APOS_STRING_MODE,{illegal:null}),p=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(d)}),m={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(d),"on:begin":(q,H)=>{H.data._beginMatch=q[1]||q[2]},"on:end":(q,H)=>{H.data._beginMatch!==q[1]&&H.ignoreMatch()}},y=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
|
|
203
|
-
]`,v={scope:"string",variants:[p,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 H=[];return q.forEach(W=>{H.push(W),W.toLowerCase()===W?H.push(W.toUpperCase()):H.push(W.toLowerCase())}),H})(k),built_in:C},_=q=>q.map(H=>H.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,e.concat(b,"+"),e.concat("(?!",_(C).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},D=e.concat(r,"\\b(?!\\()"),z={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),D],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),D],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"}}]},$={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},U={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[$,l,z,t.C_BLOCK_COMMENT_MODE,v,w,R]},Y={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",_(N).join("\\b|"),"|",_(C).join("\\b|"),"\\b)"),r,e.concat(b,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[U]};U.contains.push(Y);const X=[$,z,t.C_BLOCK_COMMENT_MODE,v,w,R],J={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",...X]},...X,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:T,contains:[J,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,Y,z,{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",J,l,z,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 gI(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 yI(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function bI(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"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d,p,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,p,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},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",d,w,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,w,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[d,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 vI(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function xI(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 wI(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]+"},d={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[c]}),t.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:l},m={className:"string",contains:[t.BACKSLASH_ESCAPE,p],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:e.concat(/<<[-~]?'?/,e.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,p]})]}]},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,p],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(d,f),relevance:0}].concat(d,f);p.contains=R,w.contains=R;const U=[{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(d),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(U).concat(f).concat(R)}}function kI(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"],d=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:p,keyword:c,literal:d,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:p}},{className:"punctuation",begin:"->"},i]}}const SI=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_-]*/}}),EI=["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"],NI=["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"],CI=[...EI,...NI],_I=["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(),TI=["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(),MI=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),AI=["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 OI(t){const e=SI(t),n=MI,r=TI,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("+CI.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("+AI.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:_I.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 RI(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function jI(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"],d=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],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=p,v=[...f,...d].filter(_=>!p.includes(_)),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(_){return e.concat(/\b/,e.either(..._.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const O={scope:"keyword",match:C(y),relevance:0};function T(_,{exceptions:R,when:D}={}){const z=D;return R=R||[],_.map($=>$.match(/\|\d+$/)||R.includes($)?$:z($)?`${$}|0`:$)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(v,{when:_=>_.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 bl(t){return _t("(?=",t,")")}function _t(...t){return t.map(n=>o1(n)).join("")}function II(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Fn(...t){return"("+(II(t).capture?"":"?:")+t.map(r=>o1(r)).join("|")+")"}const pm=t=>_t(/\b/,t,/\w$/.test(t)?/\b/:/\B/),LI=["Protocol","Type"].map(pm),Qv=["init","self"].map(pm),DI=["Any","Self"],Nh=["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"],Xv=["false","nil","true"],PI=["assignment","associativity","higherThan","left","lowerThan","none","right"],BI=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Zv=["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=Fn(/[/=\-+!*%<>&|^~?]/,/[\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=Fn(l1,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Ch=_t(l1,a1,"*"),c1=Fn(/[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=Fn(c1,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),zr=_t(c1,Iu,"*"),Mc=_t(/[A-Z]/,Iu,"*"),zI=["attached","autoclosure",_t(/convention\(/,Fn("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",_t(/objc\(/,zr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],$I=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function FI(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,Fn(...LI,...Qv)],className:{2:"keyword"}},i={match:_t(/\./,Fn(...Nh)),relevance:0},l=Nh.filter(Ne=>typeof Ne=="string").concat(["_|0"]),c=Nh.filter(Ne=>typeof Ne!="string").concat(DI).map(pm),d={variants:[{className:"keyword",match:Fn(...c,...Qv)}]},f={$pattern:Fn(/\b\w+/,/#\w+/),keyword:l.concat(BI),literal:Xv},p=[s,i,d],m={match:_t(/\./,Fn(...Zv)),relevance:0},y={className:"built_in",match:_t(/\b/,Fn(...Zv),/(?=\()/)},b=[m,y],v={match:/->/,relevance:0},w={className:"operator",relevance:0,variants:[{match:Ch},{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=(Ne="")=>({className:"subst",variants:[{match:_t(/\\/,Ne,/[0\\tnr"']/)},{match:_t(/\\/,Ne,/u\{[0-9a-fA-F]{1,8}\}/)}]}),_=(Ne="")=>({className:"subst",match:_t(/\\/,Ne,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(Ne="")=>({className:"subst",label:"interpol",begin:_t(/\\/,Ne,/\(/),end:/\)/}),D=(Ne="")=>({begin:_t(Ne,/"""/),end:_t(/"""/,Ne),contains:[T(Ne),_(Ne),R(Ne)]}),z=(Ne="")=>({begin:_t(Ne,/"/),end:_t(/"/,Ne),contains:[T(Ne),R(Ne)]}),$={className:"string",variants:[D(),D("#"),D("##"),D("###"),z(),z("#"),z("##"),z("###")]},U=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],Y={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:U},X=Ne=>{const et=_t(Ne,/\//),Le=_t(/\//,Ne);return{begin:et,end:Le,contains:[...U,{scope:"comment",begin:`#(?!.*${Le})`,end:/$/}]}},J={scope:"regexp",variants:[X("###"),X("##"),X("#"),Y]},q={match:_t(/`/,zr,/`/)},H={className:"variable",match:/\$\d+/},W={className:"variable",match:`\\$${Iu}+`},re=[q,H,W],V={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:$I,contains:[...k,O,$]}]}},K={scope:"keyword",match:_t(/@/,Fn(...zI),bl(Fn(/\(/,/\s+/)))},B={scope:"meta",match:_t(/@/,zr)},A=[V,K,B],L={match:bl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:_t(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Iu,"+")},{className:"type",match:Mc,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:_t(/\s+&\s+/,bl(Mc)),relevance:0}]},te={begin:/</,end:/>/,keywords:f,contains:[...r,...p,...A,v,L]};L.contains.push(te);const oe={match:_t(zr,/\s*:/),keywords:"_|0",relevance:0},he={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",oe,...r,J,...p,...b,...k,O,$,...re,...A,L]},ne={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,L]},ge={begin:Fn(bl(_t(zr,/\s*:/)),bl(_t(zr,/\s+/,zr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:zr}]},De={begin:/\(/,end:/\)/,keywords:f,contains:[ge,...r,...p,...k,O,$,...A,L,he],endsParent:!0,illegal:/["']/},ot={match:[/(func|macro)/,/\s+/,Fn(q.match,zr,Ch)],className:{1:"keyword",3:"title.function"},contains:[ne,De,e],illegal:[/\[/,/%/]},ce={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[ne,De,e],illegal:/\[|%/},pe={match:[/operator/,/\s+/,Ch],className:{1:"keyword",3:"title"}},se={begin:[/precedencegroup/,/\s+/,Mc],className:{1:"keyword",3:"title"},contains:[L],keywords:[...PI,...Xv],end:/}/},Pe={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Oe={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Je={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,zr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[ne,...p,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Mc},...p],relevance:0}]};for(const Ne of $.variants){const et=Ne.contains.find(He=>He.label==="interpol");et.keywords=f;const Le=[...p,...b,...k,O,$,...re];et.contains=[...Le,{begin:/\(/,end:/\)/,contains:["self",...Le]}]}return{name:"Swift",keywords:f,contains:[...r,ot,ce,Pe,Oe,Je,pe,se,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},J,...p,...b,...k,O,$,...re,...A,L,he]}}const Lu="[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"],h1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],p1=["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(p1,f1,h1);function UI(t){const e=t.regex,n=(V,{after:K})=>{const B="</"+V[0].slice(1);return V.input.indexOf(B,K)!==-1},r=Lu,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,K)=>{const B=V[0].length+V.index,A=V.input[B];if(A==="<"||A===","){K.ignoreMatch();return}A===">"&&(n(V,{after:B})||K.ignoreMatch());let L;const te=V.input.substring(B);if(L=te.match(/^\s*=/)){K.ignoreMatch();return}if((L=te.match(/^\s+extends\s+/))&&L.index===0){K.ignoreMatch();return}}},c={$pattern:Lu,keyword:u1,literal:d1,built_in:g1,"variable.language":m1},d="[0-9](_?[0-9])*",f=`\\.(${d})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},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),_=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:_},D={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"}}]},z={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,...h1]}},$={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},Y={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function X(V){return e.concat("(?!",V.join("|"),")")}const J={match:e.concat(/\b/,X([...p1,"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},H={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},W="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",re={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(W)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:z},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),$,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,C,{match:/\$\d+/},m,z,{scope:"attr",match:r+e.lookahead(":"),relevance:0},re,{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:W,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:_}]}]},{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"]}]}]},U,{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]},J,Y,D,H,{match:/\$[(.]/}]}}function HI(t){const e=t.regex,n=UI(t),r=Lu,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['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Lu,keyword:u1.concat(d),literal:d1,built_in:g1.concat(s),"variable.language":m1},p={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(p);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([p,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 WI(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}/,d={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])|[%&])?/}]},p={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,d,f,p,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 VI(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/},d={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,d,f,c]}}function KI(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"}),d=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,d,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,d,c]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[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 GI(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 qI={arduino:Mj,bash:Aj,c:Oj,cpp:Rj,csharp:jj,css:Uj,diff:Hj,go:Wj,graphql:Vj,ini:Kj,java:Gj,javascript:Xj,json:Zj,kotlin:tI,less:cI,lua:uI,makefile:dI,markdown:fI,objectivec:hI,perl:pI,php:mI,"php-template":gI,plaintext:yI,python:bI,"python-repl":vI,r:xI,ruby:wI,rust:kI,scss:OI,shell:RI,sql:jI,swift:FI,typescript:HI,vbnet:WI,wasm:VI,xml:KI,yaml:GI},e0={},JI="hljs-";function YI(t){const e=Xk.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:l,registered:c};function n(d,f,p){const m=p||e0,y=typeof m.prefix=="string"?m.prefix:JI;if(!e.getLanguage(d))throw new Error("Unknown language: `"+d+"` is not registered");e.configure({__emitter:QI,classPrefix:y});const b=e.highlight(f,{ignoreIllegals:!0,language:d});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(d,f){const m=(f||e0).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,d,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(d,f){if(typeof d=="string")e.registerLanguage(d,f);else{let p;for(p in d)Object.hasOwn(d,p)&&e.registerLanguage(p,d[p])}}function l(d,f){if(typeof d=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:d});else{let p;for(p in d)if(Object.hasOwn(d,p)){const m=d[p];e.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function c(d){return!!e.getLanguage(d)}}class QI{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 XI=new At("blurredLoadingNode"),mm=bt.create({name:"blurredLoadingNode",addStorage(){return{loadingNodes:{}}},addCommands(){return{applyLoadingEffect:(t,e,n,r="paragraph")=>({editor:s})=>{const i={...this.storage.loadingNodes};return i[t]={from:e,to:n,id:t,active:!0,type:r},this.storage.loadingNodes=i,s.view.dispatch(s.view.state.tr),setTimeout(()=>{s.isFocused&&s.commands.setTextSelection({from:e,to:e})},0),!0},removeLoadingEffect:t=>({editor:e})=>{const n={...this.storage.loadingNodes};return n[t]&&(delete n[t],this.storage.loadingNodes=n,e.view.dispatch(e.view.state.tr),e.isFocused||setTimeout(()=>{e.commands.focus()},0)),!0}}},addProseMirrorPlugins(){return[new Et({key:XI,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(jt.inline(i,l,{class:"node-blur-selection"})):t.doc.nodesBetween(i,l,(d,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(d.type.name)?(n.push(jt.node(f,f+d.nodeSize,{class:"node-blur-effect"})),!1):!0)}),wt.create(t.doc,n)}}})]}}),gm=un.create({name:"imageLoading",group:"block",atom:!0,addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:'div[data-type="image-loading"]'}]},renderHTML(){return["div",{"data-type":"image-loading",class:"image-loading-placeholder",contenteditable:"false"}]}}),ZI=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],ym=bt.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:ZI,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}}}]}}),eL=YI(qI),bm=p2.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",St(this.options.HTMLAttributes,n),0]}}),tL=[hm.configure({codeBlock:!1,link:!1,underline:!1}),_j.configure({lowlight:eL}),bm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Jk,BR,FA,$2,U2,oR,iR.configure({nested:!0}),Zp,PR,Lk.configure({resizable:!1}),Ik,jk,Rk,mm,gm,ym,td.configure({placeholder:"Start writing..."}),fm.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],nL=[hm.configure({codeBlock:!1,horizontalRule:!0,heading:{levels:[1,2,3]},link:!1,underline:!1}),bm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Zp,mm,gm,ym,td.configure({placeholder:"Start writing..."}),fm.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image","imageLoading","horizontalRule"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],rL=bt.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>{const{state:t}=this.editor,{$from:e}=t.selection,n=e.pos,r=n>0?t.doc.resolve(n).nodeBefore:null;if((r==null?void 0:r.type.name)==="hardBreak"){const{tr:s}=t;return s.delete(n-r.nodeSize,n),s.split(s.mapping.map(n)),this.editor.view.dispatch(s),!0}return this.editor.commands.setHardBreak()}}}}),y1=[hm.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),bm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Zp,mm,gm,ym,rL,fm.configure({types:["paragraph","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...y1,td.configure({placeholder:"What is happening?!"})];function Cr({onClick:t,active:e,disabled:n,title:r,children:s}){return u.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function t0(){return u.jsx("div",{className:"floating-toolbar__divider"})}function sL({editor:t}){const[e,n]=S.useState(!1),[r,s]=S.useState({top:0,left:0}),[,i]=S.useState(0),l=S.useRef(-1),c=S.useRef(-1),d=S.useRef(!1);return S.useEffect(()=>{const f=t.view.dom,p=()=>{d.current=!0},m=()=>{if(!d.current)return;d.current=!1;const{from:y,to:b}=t.state.selection,v=y!==b&&t.state.selection.node;if(y!==b&&!v){const w=t.isActive("codeBlock"),k=!!document.querySelector(".context-menu");if(!w&&!k){l.current=y,c.current=b;const N=t.view.coordsAtPos(y),C=t.view.coordsAtPos(b,1),O=(N.left+C.right)/2;s({top:N.top,left:O}),n(!0)}}};return f.addEventListener("mousedown",p),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",p),document.removeEventListener("mouseup",m)}},[t]),S.useEffect(()=>{const f=()=>{d.current=!1,n(!1),l.current=-1,c.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),S.useEffect(()=>{const f=()=>{const{from:p,to:m}=t.state.selection,y=p===m,b=t.isActive("codeBlock"),v=!!document.querySelector(".context-menu"),w=t.view.hasFocus(),k=!y&&t.state.selection.node;if(y||k||b||v||!w)n(!1),l.current=-1,c.current=-1;else if(!d.current&&(n(!0),p!==l.current||m!==c.current)){l.current=p,c.current=m;const N=t.view.coordsAtPos(p),C=t.view.coordsAtPos(m,1),O=(N.left+C.right)/2;s({top:N.top,left:O})}i(N=>N+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?u.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[u.jsx(Cr,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.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"})})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),u.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),u.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),u.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),u.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),u.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),u.jsx(Cr,{onClick:()=>{const f=t.getAttributes("link").href||"",p=window.prompt("Link URL:",f);p!==null&&(p===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:p}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.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"})]})}),u.jsx(t0,{}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"m17 12 3-2v8"})]})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),u.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),u.jsx(t0,{}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M3 12h.01"}),u.jsx("path",{d:"M3 18h.01"}),u.jsx("path",{d:"M3 6h.01"}),u.jsx("path",{d:"M8 12h13"}),u.jsx("path",{d:"M8 18h13"}),u.jsx("path",{d:"M8 6h13"})]})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M11 12h9"}),u.jsx("path",{d:"M11 18h9"}),u.jsx("path",{d:"M11 6h9"}),u.jsx("path",{d:"M4 10V4h1"}),u.jsx("path",{d:"M4 10h2"}),u.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),u.jsx(Cr,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M17 6H3"}),u.jsx("path",{d:"M21 12H8"}),u.jsx("path",{d:"M21 18H8"}),u.jsx("path",{d:"M3 12v6"})]})})]}):null}const iL=new At("pendingDecoration");let b1=null,v1=null;function n0(t,e){b1=t,v1=e??null}let Du=!1,x1=null,vm=null,w1=null;function xm(){return Du}function oL(){return vm}function lL(){return w1}function yp(t,e,n,r){Du=t,x1=t?e??null:null,vm=t?r??null:null,w1=t?n??null:null}function aL(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function r0(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 s0(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=Du&&i===x1||l&&Du&&l===vm,p=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=p!=null&&m!=null,b=f?"pending-original":aL(s);if(y&&n.isTextblock&&b){const _=r0(n,r,p),R=r0(n,r,m);_!==null&&R!==null&&_<R&&e.push(jt.inline(_,R,{class:b}))}else b&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(jt.inline(r+1,r+n.nodeSize-1,{class:b})):e.push(jt.node(r,r+n.nodeSize,{class:b})));if(i&&(i===b1||c)){const _=f?"original":s;e.push(jt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${_}`}))}return!0}),wt.create(t,e)}function k1(){return new Et({key:iL,state:{init(t,e){return s0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?s0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function wm(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const cL=new At("markDecoration");let Uc=[];function i0(t){Uc=t}function o0(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=a0(e,n,s),l=a0(e,n,s+t.text.length);return i===null||l===null||i>=l?null:jt.inline(i,l,{class:"agent-mark",title:t.note?`Agent Mark: ${t.note}`:"Agent Mark","data-mark-id":t.id})}function l0(t){if(Uc.length===0)return wt.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 Uc){const l=r.get(i.nodeId);if(!l)continue;const c=o0(i,l.node,l.pos);c&&(n.add(i.id),e.push(c))}const s=Uc.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 d=o0(c,i,l);d&&(n.add(c.id),e.push(d))}return!0}),wt.create(t,e)}function a0(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 S1(){return new Et({key:cL,state:{init(t,e){return l0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceMarkUpdate")?l0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function c0(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceMarkUpdate",!0);n(r)}async function E1(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 N1(t,e){var r;const n=(r=e.clipboardData)==null?void 0:r.items;if(!n)return!1;for(const s of n)if(s.type.startsWith("image/")){e.preventDefault();const i=s.getAsFile();return i&&E1(i,t),!0}return!1}function C1(t,e){var r;const n=(r=e.dataTransfer)==null?void 0:r.files;if(!(n!=null&&n.length))return!1;for(const s of n)if(s.type.startsWith("image/"))return e.preventDefault(),E1(s,t),!0;return!1}function Ac({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=S.useRef(s);i.current=s;const l=sk({extensions:e||tL,content:t||"<p></p>",onUpdate:({editor:c})=>{xm()||n==null||n(c.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:N1,handleDrop:C1}},[t]);return S.useEffect(()=>{if(!l)return;const c=l.view.dom,d=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",d,!0),()=>c.removeEventListener("click",d,!0)},[l]),S.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(p=>p.key==="pendingDecoration$"))return;const d=k1(),f=c.reconfigure({plugins:[...c.plugins,d]});l.view.updateState(f)},[l]),S.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(p=>p.key==="markDecoration$"))return;const d=S1(),f=c.reconfigure({plugins:[...c.plugins,d]});l.view.updateState(f)},[l]),S.useEffect(()=>{l&&(r==null||r(l))},[l,r]),l?u.jsxs(u.Fragment,{children:[u.jsx(Qp,{editor:l}),u.jsx(sL,{editor:l})]}):null}function tn({onClick:t,active:e,disabled:n,title:r,children:s}){return u.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function po(){return u.jsx("div",{className:"format-toolbar__divider"})}async function uL(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 dL({editor:t}){const[,e]=S.useState(0),n=S.useRef(null);S.useEffect(()=>{const s=()=>e(i=>i+1);return t.on("transaction",s),()=>{t.off("transaction",s)}},[t]);const r=s=>{var l;const i=(l=s.target.files)==null?void 0:l[0];i&&uL(i,t),s.target.value=""};return u.jsxs("div",{className:"format-toolbar",children:[u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(tn,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:u.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.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"})})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),u.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),u.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),u.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),u.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),u.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m16 18 6-6-6-6"}),u.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),u.jsx(po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(tn,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),u.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"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m4 5 8 8"}),u.jsx("path",{d:"m12 5-8 8"}),u.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"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m4 19 8-8"}),u.jsx("path",{d:"m12 19-8-8"}),u.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"})]})})]}),u.jsx(po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(tn,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"m17 12 3-2v8"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),u.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M13 4v16"}),u.jsx("path",{d:"M17 4v16"}),u.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),u.jsx(po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(tn,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M3 12h.01"}),u.jsx("path",{d:"M3 18h.01"}),u.jsx("path",{d:"M3 6h.01"}),u.jsx("path",{d:"M8 12h13"}),u.jsx("path",{d:"M8 18h13"}),u.jsx("path",{d:"M8 6h13"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M11 12h9"}),u.jsx("path",{d:"M11 18h9"}),u.jsx("path",{d:"M11 6h9"}),u.jsx("path",{d:"M4 10V4h1"}),u.jsx("path",{d:"M4 10h2"}),u.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m3 17 2 2 4-4"}),u.jsx("path",{d:"m3 7 2 2 4-4"}),u.jsx("path",{d:"M13 6h8"}),u.jsx("path",{d:"M13 12h8"}),u.jsx("path",{d:"M13 18h8"})]})})]}),u.jsx(po,{}),u.jsx("div",{className:"format-toolbar__group",children:u.jsx(tn,{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:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.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"})]})})}),u.jsx(po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(tn,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M17 6H3"}),u.jsx("path",{d:"M21 12H8"}),u.jsx("path",{d:"M21 18H8"}),u.jsx("path",{d:"M3 12v6"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("path",{d:"m10 9-3 3 3 3"}),u.jsx("path",{d:"m14 15 3-3-3-3"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:u.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M5 12h14"})})})]}),u.jsx(po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(tn,{onClick:()=>{var s;return(s=n.current)==null?void 0:s.click()},title:"Insert Image",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),u.jsx("circle",{cx:"9",cy:"9",r:"2"}),u.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),u.jsx(tn,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("path",{d:"M12 3v18"}),u.jsx("path",{d:"M3 9h18"}),u.jsx("path",{d:"M3 15h18"})]})})]}),u.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const fL={tree:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),timeline:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),u.jsx("circle",{cx:"12",cy:"6",r:"2"}),u.jsx("circle",{cx:"12",cy:"12",r:"2"}),u.jsx("circle",{cx:"12",cy:"18",r:"2"}),u.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),u.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),u.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),u.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),u.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 19V5"}),u.jsx("path",{d:"M8 19V7"}),u.jsx("path",{d:"M12 19V4"}),u.jsx("path",{d:"M16 19V8"}),u.jsx("path",{d:"M20 19V6"}),u.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function hL(){const[t,e]=S.useState(!1),[n,r]=S.useState($0),[s,i]=S.useState(F0),[l,c]=S.useState($u),d=U0(),[f,p]=S.useState(W0),[m,y]=S.useState(V0),b=S.useRef(null),v=(T=n,_=s,R=l,D=d,z=f,$=m)=>{K0(T,_,R,D,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=>{p(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 S.useEffect(()=>{if(!t)return;const T=_=>{b.current&&!b.current.contains(_.target)&&e(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),u.jsxs("div",{className:"appearance-wrapper",ref:b,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Appearance",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]})}),t&&u.jsxs("div",{className:"appearance-dropdown",children:[u.jsx("div",{className:"appearance-section",children:u.jsxs("div",{className:"appearance-section-header",children:[u.jsx("span",{className:"appearance-section-title",children:"Mode"}),u.jsxs("button",{className:"appearance-mode-btn",onClick:k,title:s==="light"?"Switch to dark":"Switch to light",children:[s==="light"?u.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"5"}),u.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),u.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),u.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),u.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),u.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),u.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),u.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),u.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):u.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),u.jsx("span",{children:s==="light"?"Light":"Dark"})]})]})}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Typography"})}),u.jsx("div",{className:"appearance-typeface-grid",children:D0.map(T=>u.jsx("button",{className:`appearance-style-option ${n===T.id?"active":""}`,onClick:()=>w(T.id),title:T.description,children:T.label},T.id))})]}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),u.jsx("div",{className:"appearance-typography-grid",children:z0.map(T=>u.jsx("button",{className:`appearance-style-option ${f===T.id?"active":""}`,onClick:()=>C(T.id),children:T.label},T.id))})]}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),u.jsx("div",{className:"appearance-style-grid",children:B0.map(T=>u.jsx("button",{className:`appearance-style-option ${m===T.id?"active":""}`,onClick:()=>O(T.id),children:T.label},T.id))})]}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Layout"})}),u.jsx("div",{className:"appearance-mode-grid",children:P0.map(T=>u.jsxs("button",{className:`appearance-mode-option ${l===T.id?"active":""}`,onClick:()=>N(T.id),children:[fL[T.icon],u.jsx("span",{children:T.label})]},T.id))})]})]})]})}function u0(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function pL(){const[t,e]=S.useState(!1),[n,r]=S.useState([]),[s,i]=S.useState(null),[l,c]=S.useState(new Set),d=S.useRef(null),f=S.useCallback(()=>{fetch("/api/available-plugins").then(y=>y.json()).then(y=>r(y.plugins||[])).catch(()=>{})},[]);S.useEffect(()=>{t&&f()},[t,f]),S.useEffect(()=>{const y=()=>f();return window.addEventListener("ow-plugins-changed",y),()=>window.removeEventListener("ow-plugins-changed",y)},[f]),S.useEffect(()=>{if(!t)return;const y=b=>{d.current&&!d.current.contains(b.target)&&e(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[t]);const p=S.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=S.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 u.jsxs("div",{className:"plugin-wrapper",ref:d,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Plugins",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12 22v-5"}),u.jsx("path",{d:"M9 8V2"}),u.jsx("path",{d:"M15 8V2"}),u.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&&u.jsxs("div",{className:"plugin-dropdown",children:[u.jsx("div",{className:"plugin-dropdown-header",children:"Plugins"}),n.length===0?u.jsx("div",{className:"plugin-empty",children:"No plugins found"}):n.map(y=>u.jsxs("div",{className:"plugin-item",children:[u.jsxs("div",{className:"plugin-item-header",children:[u.jsxs("div",{className:"plugin-item-info",children:[u.jsxs("div",{className:"plugin-item-name",children:[u0(y.name),u.jsxs("span",{className:"plugin-item-version",children:["v",y.version]})]}),y.description&&u.jsx("div",{className:"plugin-item-desc",children:y.description})]}),u.jsxs("label",{className:`plugin-toggle${s===y.name?" loading":""}`,children:[u.jsx("input",{type:"checkbox",checked:y.enabled,disabled:s===y.name,onChange:()=>p(y.name,y.enabled)}),u.jsx("span",{className:"plugin-toggle-track"}),u.jsx("span",{className:"plugin-toggle-thumb"})]})]}),y.enabled&&Object.keys(y.configSchema).length>0&&(()=>{const b=Object.entries(y.configSchema).some(([v,w])=>w.required&&!y.config[v]);return u.jsxs("div",{className:"plugin-config-section",children:[b&&u.jsxs("div",{className:"plugin-setup-hint",children:["Ask your agent: “set up ",u0(y.name),"”"]}),u.jsxs("button",{className:"plugin-config-toggle",onClick:()=>c(v=>{const w=new Set(v);return w.has(y.name)?w.delete(y.name):w.add(y.name),w}),children:[u.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:u.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),l.has(y.name)&&u.jsx("div",{className:"plugin-config",children:Object.entries(y.configSchema).map(([v,w])=>u.jsxs("div",{className:"plugin-config-field",children:[u.jsx("label",{className:"plugin-config-label",children:w.description||v}),u.jsx("input",{className:"plugin-config-input",type:v.toLowerCase().includes("key")||v.toLowerCase().includes("secret")||v.toLowerCase().includes("token")?"password":"text",defaultValue:y.config[v]||"",placeholder:w.env?`$${w.env}`:"",onBlur:k=>m(y.name,v,k.target.value)})]},v))})]})})()]},y.name))]})]})}function mL(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 gL(t){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function yL(){const[t,e]=S.useState(!1),[n,r]=S.useState([]),[s,i]=S.useState(null),[l,c]=S.useState(!1),d=S.useRef(null),f=S.useCallback(()=>{fetch("/api/versions").then(m=>m.json()).then(m=>{r(Array.isArray(m)?m:[]),i(null)}).catch(()=>r([]))},[]);S.useEffect(()=>{t&&f()},[t,f]),S.useEffect(()=>{if(!t)return;const m=y=>{d.current&&!d.current.contains(y.target)&&e(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[t]);const p=S.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 u.jsxs("div",{className:"version-wrapper",ref:d,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Version history",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t&&u.jsxs("div",{className:"version-dropdown",children:[u.jsx("div",{className:"version-dropdown__header",children:"Version History"}),u.jsx("div",{className:"version-dropdown__list",children:n.length===0?u.jsx("div",{className:"version-dropdown__empty",children:"No versions yet. Versions are created automatically when you save."}):n.map(m=>u.jsxs("div",{className:`version-dropdown__item${s===m.timestamp?" version-dropdown__item--selected":""}`,onClick:()=>i(m.timestamp===s?null:m.timestamp),children:[u.jsx("span",{className:"version-dropdown__item-time",children:mL(m.timestamp)}),u.jsxs("span",{className:"version-dropdown__item-meta",children:[m.wordCount.toLocaleString()," words · ",gL(m.size)]})]},m.timestamp))}),n.length>0&&u.jsxs("div",{className:"version-dropdown__footer",children:[u.jsx("button",{className:"version-dropdown__review-btn",disabled:s===null||l,onClick:()=>p("review"),children:"Review"}),u.jsx("button",{className:"version-dropdown__restore-btn",disabled:s===null||l,onClick:()=>p("full"),children:"Restore"})]})]})]})}const bL=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"16 18 22 12 16 6"}),u.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("path",{d:"M14 2v6h6"}),u.jsx("path",{d:"M16 13H8"}),u.jsx("path",{d:"M16 17H8"}),u.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M17 6.1H3"}),u.jsx("path",{d:"M21 12.1H3"}),u.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),u.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"}),u.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function vL(){const[t,e]=S.useState(!1),n=S.useRef(null);S.useEffect(()=>{if(!t)return;const s=i=>{n.current&&!n.current.contains(i.target)&&e(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[t]);const r=s=>{if(e(!1),s==="pdf"){window.open("/api/export?format=pdf","_blank");return}const i=document.createElement("a");i.href=`/api/export?format=${s}`,i.download="",document.body.appendChild(i),i.click(),document.body.removeChild(i)};return u.jsxs("div",{className:"export-wrapper",ref:n,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Export document",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u.jsx("polyline",{points:"7 10 12 15 17 10"}),u.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),t&&u.jsxs("div",{className:"export-dropdown",children:[u.jsx("div",{className:"export-dropdown__header",children:"Export"}),u.jsx("div",{className:"export-dropdown__list",children:bL.map(s=>u.jsxs("div",{className:"export-dropdown__item",onClick:()=>r(s.key),children:[u.jsx("span",{className:"export-dropdown__item-icon",children:s.icon}),u.jsxs("span",{className:"export-dropdown__item-text",children:[u.jsx("span",{className:"export-dropdown__item-label",children:s.label}),u.jsx("span",{className:"export-dropdown__item-desc",children:s.desc})]})]},s.key))})]})]})}function xL({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=S.useState("form"),[i,l]=S.useState(null),[c,d]=S.useState((t==null?void 0:t.domain)||""),[f,p]=S.useState(""),[m,y]=S.useState((t==null?void 0:t.from_name)||""),[b,v]=S.useState(""),[w,k]=S.useState((t==null?void 0:t.id)||""),[N,C]=S.useState({dns_verified:!1,sender_verified:!1}),O=S.useRef(null),T=S.useRef(null);S.useEffect(()=>{const Y=X=>{r!=="submitting"&&r!=="verifying"&&T.current&&!T.current.contains(X.target)&&e()};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[e,r]),S.useEffect(()=>{const Y=X=>{X.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[e,r]),S.useEffect(()=>()=>{O.current&&clearInterval(O.current)},[]);async function _(){var Y,X;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(),H=(X=(Y=q.content)==null?void 0:Y[0])!=null&&X.text?JSON.parse(q.content[0].text):q;if(H.error){l(H.error),s("error");return}const W=H.connectionId||H.connection_id||w;W&&k(W),D(W)}catch(J){l(J.message),s("error")}}async function R(){var Y,X;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(),H=(X=(Y=q.content)==null?void 0:Y[0])!=null&&X.text?JSON.parse(q.content[0].text):q;if(H.error){l(H.error),s("error");return}s("done")}catch(J){l(J.message),s("error")}}function D(Y){s("verifying"),O.current=setInterval(async()=>{var X,J;try{const H=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:Y}})})).json(),W=(J=(X=H.content)==null?void 0:X[0])!=null&&J.text?JSON.parse(H.content[0].text):H,re=!!W.dns_verified,V=!!W.sender_verified;C({dns_verified:re,sender_verified:V}),re&&V&&(O.current&&clearInterval(O.current),O.current=null,s("done"))}catch{}},5e3)}function z(){w&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:w}})}).catch(()=>{})}const $=!!t,U=c.trim()&&f.trim()&&b.trim();return u.jsx("div",{className:"newsletter-modal-overlay",children:u.jsxs("div",{className:"newsletter-modal newsletter-modal--setup",ref:T,children:[u.jsxs("div",{className:"newsletter-modal__header",children:[u.jsx("h3",{children:$?"Newsletter Settings":"Set Up Newsletter"}),u.jsx("button",{className:"newsletter-modal__close",onClick:e,children:"×"})]}),u.jsxs("div",{className:"newsletter-modal__body",children:[r==="form"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsx("label",{className:"newsletter-modal__label",children:"Domain"}),u.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"yourdomain.com",value:c,onChange:Y=>d(Y.target.value),disabled:$,autoComplete:"off"})]}),u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsx("label",{className:"newsletter-modal__label",children:"From Email"}),u.jsx("input",{className:"newsletter-modal__input",type:"email",placeholder:"newsletter@yourdomain.com",value:f,onChange:Y=>p(Y.target.value),autoComplete:"off"})]}),u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsxs("label",{className:"newsletter-modal__label",children:["From Name ",u.jsx("span",{className:"newsletter-modal__optional",children:"(optional)"})]}),u.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"Your Name or Brand",value:m,onChange:Y=>y(Y.target.value),autoComplete:"off"})]}),u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsxs("label",{className:"newsletter-modal__label",children:["Physical Address ",u.jsx("span",{className:"newsletter-modal__required",children:"*"})]}),u.jsx("textarea",{className:"newsletter-modal__input newsletter-modal__textarea",rows:2,placeholder:"123 Main St, City, State 12345",value:b,onChange:Y=>v(Y.target.value)}),u.jsx("span",{className:"newsletter-modal__hint",children:"Required by CAN-SPAM. Included in email footer."})]}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:$?R:_,disabled:!U,children:$?"Save":"Set Up Domain"})]})]}),r==="submitting"&&u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:$?"Saving...":"Setting up domain..."})]}),r==="verifying"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"newsletter-modal__verify",children:[u.jsx("p",{className:"newsletter-modal__verify-title",children:"Verifying domain setup..."}),u.jsxs("div",{className:"newsletter-modal__verify-checks",children:[u.jsxs("div",{className:`newsletter-modal__verify-item${N.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[N.dns_verified?"✓":u.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),u.jsx("span",{children:"DNS records"})]}),u.jsxs("div",{className:`newsletter-modal__verify-item${N.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[N.sender_verified?"✓":u.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),u.jsx("span",{children:"Sender verification"})]})]}),u.jsx("p",{className:"newsletter-modal__hint",children:"This may take a few minutes. You can close and check back later."})]}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:z,children:"Resend Verification"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Close"})]})]}),r==="done"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:$?"Settings saved!":"Newsletter domain configured!"}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Done"})})]}),r==="error"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"newsletter-modal__error",children:i}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s("form"),children:"Try Again"})]})]})]})]})})}const wL={github:[{key:"owner",label:"Owner",placeholder:"username or org",readonly:!0},{key:"repo",label:"Repository",placeholder:"my-blog",readonly:!0},{key:"branch",label:"Branch",placeholder:"main"},{key:"contentDir",label:"Content Directory",placeholder:"src/content/blog",required:!0},{key:"imageDir",label:"Image Directory",placeholder:"public/images/blog"}],x:[],linkedin:[]};function kL({connectionId:t,provider:e,displayName:n,onClose:r,onSaved:s}){const[i,l]=S.useState("loading"),[c,d]=S.useState({}),[f,p]=S.useState(null),m=S.useRef(null),y=wL[e]||[];S.useEffect(()=>{fetch(`/api/connections/${t}/config`).then(w=>w.json()).then(w=>{d(w.config||{}),l("form")}).catch(w=>{p(w.message),l("error")})},[t]),S.useEffect(()=>{const w=k=>{i!=="saving"&&m.current&&!m.current.contains(k.target)&&r()};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[r,i]),S.useEffect(()=>{const w=k=>{k.key==="Escape"&&i!=="saving"&&r()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[r,i]);async function b(){l("saving"),p(null);try{const w=await fetch(`/api/connections/${t}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),k=await w.json();if(!w.ok)throw new Error(k.error||"Failed to save");l("saved"),s(),setTimeout(r,800)}catch(w){p(w.message),l("error")}}function v(w){switch(w){case"x":return"X (Twitter)";case"linkedin":return"LinkedIn";case"github":return"GitHub";default:return w}}return u.jsx("div",{className:"conn-config-overlay",children:u.jsxs("div",{className:"conn-config-modal",ref:m,children:[u.jsxs("div",{className:"conn-config-modal__header",children:[u.jsxs("div",{className:"conn-config-modal__title",children:[v(e)," Settings"]}),u.jsx("div",{className:"conn-config-modal__subtitle",children:n})]}),i==="loading"&&u.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[u.jsx("div",{className:"conn-config-spinner"}),u.jsx("span",{children:"Loading configuration..."})]}),(i==="form"||i==="error")&&y.length>0&&u.jsxs("div",{className:"conn-config-modal__body",children:[y.map(w=>u.jsxs("div",{className:"conn-config-field",children:[u.jsxs("label",{className:"conn-config-field__label",children:[w.label,w.readonly&&u.jsx("span",{className:"conn-config-field__badge",children:"read-only"})]}),u.jsx("input",{className:"conn-config-field__input",value:c[w.key]||"",placeholder:w.placeholder,readOnly:w.readonly,onChange:k=>d(N=>({...N,[w.key]:k.target.value}))})]},w.key)),f&&u.jsx("div",{className:"conn-config-modal__error",children:f})]}),(i==="form"||i==="error")&&y.length===0&&u.jsx("div",{className:"conn-config-modal__body conn-config-modal__center",children:u.jsxs("span",{className:"conn-config-modal__empty",children:["No configuration needed for ",v(e),"."]})}),i==="saving"&&u.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[u.jsx("div",{className:"conn-config-spinner"}),u.jsx("span",{children:"Saving..."})]}),i==="saved"&&u.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[u.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),u.jsx("span",{children:"Saved"})]}),u.jsxs("div",{className:"conn-config-modal__footer",children:[u.jsx("button",{className:"conn-config-btn conn-config-btn--secondary",onClick:r,children:i==="saved"?"Close":"Cancel"}),y.length>0&&(i==="form"||i==="error")&&u.jsx("button",{className:"conn-config-btn conn-config-btn--primary",onClick:b,children:"Save"})]})]})})}const SL=[{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 EL(){const[t,e]=S.useState(!1),[n,r]=S.useState([]),[s,i]=S.useState(null),[l,c]=S.useState(null),[d,f]=S.useState(null),[p,m]=S.useState(null),y=S.useRef(null),b=S.useRef(null);S.useEffect(()=>{if(!t)return;const T=_=>{y.current&&!y.current.contains(_.target)&&(e(!1),i(null))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),S.useEffect(()=>{t&&v()},[t]),S.useEffect(()=>()=>{b.current&&clearInterval(b.current)},[]);function v(){fetch("/api/connections").then(T=>T.json()).then(T=>{const _=(T.connections||[]).filter(R=>R&&R.id&&R.provider);r(_)}).catch(()=>{})}async function w(T){c(T);try{const _=await fetch(`/api/connections/oauth/${T}/start`,{method:"POST"}),R=await _.json();if(!_.ok||!R.url){c(null);return}window.open(R.url,"_blank","width=600,height=700"),b.current=setInterval(async()=>{try{const z=await(await fetch(`/api/connections/oauth/${T}/status/${R.state}`)).json();z.status==="completed"?(b.current&&clearInterval(b.current),b.current=null,c(null),v()):z.status==="failed"&&(b.current&&clearInterval(b.current),b.current=null,c(null))}catch{}},2e3)}catch{c(null)}}async function k(T){try{const _=await fetch(`/api/connections/${T}`,{method:"DELETE"});if(!_.ok){const R=await _.json().catch(()=>({error:"Delete failed"}));console.error("[Connections] Delete failed:",R.error)}}catch(_){console.error("[Connections] Delete error:",_)}i(null),await v()}function N(T){return T==="active"?"connections-status--active":T==="expired"?"connections-status--expired":T==="revoked"?"connections-status--revoked":"connections-status--pending"}function C(T){switch(T){case"x":return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:u.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 u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:u.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 u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:u.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 u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),u.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});default:return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),u.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}}const O=new Map;for(const T of n)O.set(T.provider,T);return u.jsxs("div",{className:"connections-wrapper",ref:y,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Connections",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"5",r:"3"}),u.jsx("circle",{cx:"5",cy:"19",r:"3"}),u.jsx("circle",{cx:"19",cy:"19",r:"3"}),u.jsx("line",{x1:"12",y1:"8",x2:"5",y2:"16"}),u.jsx("line",{x1:"12",y1:"8",x2:"19",y2:"16"})]})}),p&&u.jsx(kL,{connectionId:p.id,provider:p.provider,displayName:p.display_name,onClose:()=>m(null),onSaved:()=>v()}),d&&u.jsx(xL,{existingConnection:d==="edit"?O.get("newsletter"):null,onClose:()=>f(null),onSaved:()=>v()}),t&&u.jsxs("div",{className:"connections-dropdown",children:[u.jsx("div",{className:"connections-dropdown__header",children:"Connections"}),u.jsx("div",{className:"connections-dropdown__list",children:SL.map(T=>{const _=O.get(T.id);return _&&s===_.id?u.jsxs("div",{className:"connections-dropdown__confirm",children:[u.jsxs("span",{children:["Disconnect ",T.label,"?"]}),u.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[u.jsx("button",{onClick:()=>k(_.id),children:"Yes"}),u.jsx("button",{onClick:()=>i(null),children:"No"})]})]},T.id):_?u.jsxs("div",{className:"connections-dropdown__item",children:[u.jsx("div",{className:"connections-dropdown__icon",children:C(T.id)}),u.jsxs("div",{className:"connections-dropdown__info",children:[u.jsx("div",{className:"connections-dropdown__name",children:_.display_name||_.domain||T.label}),u.jsxs("div",{className:"connections-dropdown__type",children:[u.jsx("span",{className:`connections-status ${N(_.status)}`}),"Connected"]})]}),u.jsxs("div",{className:"connections-dropdown__actions",children:[u.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>{T.id==="newsletter"?f("edit"):m({id:_.id,provider:T.id,display_name:_.display_name||T.label})},title:"Settings",children:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),u.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>i(_.id),title:"Disconnect",children:"×"})]})]},T.id):T.oauth?u.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[u.jsx("div",{className:"connections-dropdown__icon",children:C(T.id)}),u.jsxs("div",{className:"connections-dropdown__info",children:[u.jsx("div",{className:"connections-dropdown__name",children:T.label}),u.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),u.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>w(T.id),disabled:l!==null,children:l===T.id?"Connecting…":"Connect"})]},T.id):u.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[u.jsx("div",{className:"connections-dropdown__icon",children:C(T.id)}),u.jsxs("div",{className:"connections-dropdown__info",children:[u.jsx("div",{className:"connections-dropdown__name",children:T.label}),u.jsx("div",{className:"connections-dropdown__type",children:"Built-in · Not configured"})]}),u.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>f("new"),children:"Configure"})]},T.id)})})]})]})}const NL=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:u.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"})}),CL=()=>u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.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"}),u.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),_L=()=>u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.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"}),u.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),TL=()=>u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.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"}),u.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function ML({title:t,onTitleChange:e,syncStatus:n,onSync:r,onToggleSidebar:s,canGoBack:i,canGoForward:l,onGoBack:c,onGoForward:d,editor:f,onToggleToolbar:p,toolbarOpen:m}){const[y,b]=S.useState(!1),[,v]=S.useState(0),w=S.useRef(null),[k,N]=S.useState(!1),[C,O]=S.useState([]),[T,_]=S.useState(!1),R=S.useRef(null),[D,z]=S.useState(null);S.useEffect(()=>{fetch("/api/update-info").then(J=>J.json()).then(J=>{J.updateAvailable&&z({currentVersion:J.currentVersion,latestVersion:J.updateAvailable})}).catch(()=>{})},[]);const $=S.useCallback(()=>{b(!0),setTimeout(()=>{var J;return(J=w.current)==null?void 0:J.select()},0)},[]),U=S.useCallback(()=>{b(!1)},[]),Y=S.useCallback(J=>{J.key==="Enter"&&b(!1),J.key==="Escape"&&b(!1)},[]),X=S.useCallback(()=>{if(k){N(!1);return}N(!0),_(!0),fetch("/api/sync/pending").then(J=>J.json()).then(J=>O(J)).catch(()=>O([])).finally(()=>_(!1))},[k]);return S.useEffect(()=>{n.state!=="pending"&&N(!1)},[n.state]),S.useEffect(()=>{if(!k)return;const J=q=>{R.current&&!R.current.contains(q.target)&&N(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[k]),S.useEffect(()=>{if(!f)return;const J=()=>v(q=>q+1);return f.on("transaction",J),()=>{f.off("transaction",J)}},[f]),u.jsxs("div",{className:"titlebar",children:[u.jsxs("div",{className:"titlebar-left",children:[s&&u.jsx("button",{className:"titlebar-menu-btn",onClick:s,title:"Open sidebar",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),c&&u.jsx("button",{className:"titlebar-nav-btn",onClick:c,disabled:!i,title:"Go back (Alt+Left)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),d&&u.jsx("button",{className:"titlebar-nav-btn",onClick:d,disabled:!l,title:"Go forward (Alt+Right)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),f&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"titlebar-divider"}),u.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo (Ctrl+Z)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),u.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo (Ctrl+Y)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),u.jsxs("div",{className:"titlebar-center",children:[y?u.jsx("input",{ref:w,className:"titlebar-input",value:t,onChange:J=>e(J.target.value),onBlur:U,onKeyDown:Y,autoFocus:!0}):u.jsx("span",{className:"titlebar-title",onDoubleClick:$,children:t}),D&&u.jsxs("span",{className:"titlebar-update-badge",title:`Update available: v${D.currentVersion} → v${D.latestVersion}
|
|
204
|
-
Run: npm update -g openwriter`,children:["v",D.latestVersion]})]}),u.jsxs("div",{className:"titlebar-right",children:[p&&u.jsx("button",{className:`titlebar-nav-btn${m?" titlebar-nav-btn--active":""}`,onClick:p,title:"Toggle format toolbar",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 20h16"}),u.jsx("path",{d:"m6 16 6-12 6 12"}),u.jsx("path",{d:"M8 12h8"})]})}),u.jsx(pL,{}),u.jsx(EL,{}),u.jsx(hL,{}),u.jsx(yL,{}),u.jsx(vL,{}),u.jsxs("div",{className:"sync-btn-group",ref:R,children:[u.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"&&u.jsxs(u.Fragment,{children:[u.jsx(NL,{})," Sync"]}),n.state==="synced"&&u.jsxs(u.Fragment,{children:[u.jsx(CL,{})," Synced"]}),n.state==="pending"&&u.jsxs(u.Fragment,{children:[u.jsx(_L,{})," Sync",n.pendingFiles?` (${n.pendingFiles})`:""]}),n.state==="syncing"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),n.state==="error"&&u.jsxs(u.Fragment,{children:[u.jsx(TL,{})," Retry"]})]}),n.state==="pending"&&n.pendingFiles&&n.pendingFiles>0&&u.jsx("button",{className:"sync-details-btn",onClick:X,title:"View pending changes",children:u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:u.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&&u.jsxs("div",{className:"sync-pending-dropdown",children:[u.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),T?u.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):C.length===0?u.jsx("div",{className:"sync-pending-loading",children:"No changes"}):u.jsx("div",{className:"sync-pending-list",children:C.map((J,q)=>u.jsxs("div",{className:`sync-pending-item sync-file-${J.status}`,children:[u.jsx("span",{className:"sync-file-badge",children:J.status[0].toUpperCase()}),u.jsx("span",{className:"sync-file-name",children:J.file})]},q))})]})]})]})]})}function bn(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 rd(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 So(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function Pu(t){return t?Array.isArray(t)?t.map(Pu).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>Pu(e)).join(""):"":""}const AL=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Bu(t,e){for(const n of t)n.type&&AL.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Bu(n.content,e)}function bp(t,e,n){const r=Array.isArray(n)?n:[n];if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const b=bn(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:So())}}});Bu(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=bn(t,s);if(!l)return{success:!1,error:`Anchor node ${s} not found`};const c=Pu(n),d=i?l.pos+l.node.nodeSize:0,f=i?l.pos+l.node.nodeSize+5e3:l.pos;let p=null;if(t.state.doc.nodesBetween(d,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?(p=b.attrs.id,!1):!0}),p)return{success:!0,nodeId:p};const m=r.map(b=>{var v;return{...b,attrs:{...b.attrs,id:((v=b.attrs)==null?void 0:v.id)||So()}}});Bu(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 km(t,e,n,r){var b;const s=bn(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,p={...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)||So()}}});Bu(m,"insert");const y=[p,...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 OL(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=>Pu(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=bn(t,e[0]),i=bn(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=bn(t,m);y&&l.push(y.node.toJSON())}const c=s.pos,d=i.pos+i.node.nodeSize,f=So()+So(),p=n.map((m,y)=>{var b;return{...m,attrs:{...m.attrs,id:((b=m.attrs)==null?void 0:b.id)||So(),pendingStatus:"rewrite",pendingGroupId:f,...y===0?{pendingOriginalContent:l}:{}}}});try{return t.chain().deleteRange({from:c,to:d}).insertContentAt(c,p).run(),{success:!0,nodeId:p[0].attrs.id}}catch(m){return{success:!1,error:`Failed to apply range rewrite: ${m}`}}}function _1(t,e){var i;const n=bn(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 RL(t,e){if(e.operation==="rewrite"&&e.nodeId&&e.content){const n=km(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=bp(t,n,e.content);return{success:r.success,error:r.error}}if(e.operation==="delete"&&e.nodeId){const n=_1(t,e.nodeId);return{success:n.success,error:n.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function d0(t,e){if(e.length===0)return;if(e.length===1){RL(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=Oc(r.doc,i.nodeId);if(!l)continue;const d=(Array.isArray(i.content)?i.content:[i.content]).map(f=>n.nodeFromJSON(f));r.replaceWith(l.pos,l.pos+l.node.nodeSize,d)}else if(i.operation==="insert"&&i.content){const c=(Array.isArray(i.content)?i.content:[i.content]).map(d=>n.nodeFromJSON(d));if(i.nodeId&&!i.afterNodeId){const d=Oc(r.doc,i.nodeId);if(!d)continue;r.replaceWith(d.pos,d.pos+d.node.nodeSize,c)}else if(i.afterNodeId){const d=Oc(r.doc,i.afterNodeId);if(!d)continue;const f=d.pos+d.node.nodeSize;r.insert(f,ae.fromArray(c))}}else if(i.operation==="delete"&&i.nodeId){const l=Oc(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 Oc(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 jL(t,e,n,r){const s=[];if(r==="delete"){for(const l of n)s.push(_1(t,l));return s}if(r==="insert"){const l=n[n.length-1];return l&&e.length>0&&s.push(bp(t,{nodeId:l},e)),s}if(n.length>1){const l=OL(t,n,e);return s.push(l),s}const i=km(t,n[0],e[0]);if(s.push(i),e.length>1){const l=e.slice(1);s.push(bp(t,{afterNodeId:n[0]},l))}return s}const f0="[[START_SELECTION]]",h0="[[END_SELECTION]]";function IL(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 Rc(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=IL(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 LL(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(Rc(r[0],n,h0),Rc(r[0],e,f0),r):(Rc(r[0],e,f0),Rc(r[r.length-1],n,h0),r)}function DL(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 PL=[{action:"agent-mark",label:"Agent Mark",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function BL({editorRef:t,allEditors:e,documentId:n}){const[r,s]=S.useState(!1),[i,l]=S.useState({x:0,y:0}),[c,d]=S.useState(!1),[f,p]=S.useState(""),[m,y]=S.useState(!1),[b,v]=S.useState(""),[w,k]=S.useState(!1),[N,C]=S.useState([]),[O,T]=S.useState([]),[_,R]=S.useState(!1),[D,z]=S.useState(""),[$,U]=S.useState([]),[Y,X]=S.useState(!1),[J,q]=S.useState(""),H=S.useRef(null),W=S.useRef(null),re=S.useRef(null),V=S.useCallback(ce=>{if(e&&e.length>0){for(const se of e)if(se.view.dom.contains(ce))return se}const pe=t.current;return pe&&pe.view.dom.contains(ce)?pe:null},[e,t]);S.useLayoutEffect(()=>{const ce=H.current;if(!ce||!r)return;const pe=ce.getBoundingClientRect(),se=8;let{x:Pe,y:Oe}=i;Oe+pe.height+se>window.innerHeight&&(Oe=i.y-pe.height),Pe+pe.width+se>window.innerWidth&&(Pe=i.x-pe.width),Oe<se&&(Oe=se),Pe<se&&(Pe=se),(Pe!==i.x||Oe!==i.y)&&l({x:Pe,y:Oe})},[r,i]);const K=S.useCallback(()=>{fetch("/api/plugins").then(ce=>ce.json()).then(ce=>{const pe=[];for(const se of ce.plugins||[]){const Pe=se.displayName||void 0;for(const Oe of se.contextMenuItems||[])pe.push({...Oe,pluginDisplayName:Pe})}U(pe)}).catch(()=>{})},[]);S.useEffect(()=>{K()},[K]),S.useEffect(()=>{const ce=()=>K();return window.addEventListener("ow-plugins-changed",ce),()=>window.removeEventListener("ow-plugins-changed",ce)},[K]),S.useEffect(()=>{const ce=pe=>{H.current&&!H.current.contains(pe.target)&&(s(!1),y(!1),k(!1),X(!1),q(""))};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[]);const B=S.useCallback(()=>{const ce=re.current||t.current;return ce?ce.isActive("link"):!1},[t]),A=S.useCallback(()=>{const ce=re.current||t.current,pe=W.current;if(!ce||!pe)return!1;const{from:se,to:Pe}=pe;let Oe=!1;return ce.state.doc.nodesBetween(se,Pe,Je=>{var Ne;return(Ne=Je.attrs)!=null&&Ne.pendingStatus&&(Oe=!0),!Oe}),Oe},[t]),L=S.useCallback(()=>{const ce=re.current||t.current,pe=W.current,se=(pe==null?void 0:pe.from)??0,Pe=(pe==null?void 0:pe.to)??0,Oe=se!==Pe,Je=(()=>{if(!ce)return!1;try{return ce.state.doc.resolve(se).parent.content.size===0}catch{return!1}})(),Ne=A(),et=[];for(const Le of $)Le.condition==="has-selection"&&!Oe||Le.condition==="empty-node"&&!Je||et.push({action:Le.action,label:Le.label,shortcut:Le.shortcut,isPlugin:!0,promptForInput:Le.promptForInput,pluginDisplayName:Le.pluginDisplayName});for(const Le of PL)Le.condition==="has-selection"&&(!Oe||Ne)||et.push(Le);return Oe&&et.push({action:"link",label:"Link to doc",shortcut:"L"}),B()&&et.push({action:"unlink",label:"Unlink"}),et},[t,B,$,A]);S.useEffect(()=>{const ce=se=>{var Le;if(se.button!==2)return;const Pe=V(se.target);if(!Pe)return;re.current=Pe;const{from:Oe,to:Je}=Pe.state.selection,Ne=[],et=[];if(Oe!==Je&&Pe.state.doc.nodesBetween(Oe,Je,He=>{He.isBlock&&He.type.name!=="doc"&&(Ne.push(He.toJSON()),He.attrs.id&&et.push(He.attrs.id))}),Ne.length===0){const{$from:He}=Pe.state.selection,ke=He.parent;ke&&ke.type.name!=="doc"&&(Ne.push(ke.toJSON()),(Le=ke.attrs)!=null&&Le.id&&et.push(ke.attrs.id))}W.current={from:Oe,to:Je,nodes:Ne,nodeIds:et}},pe=se=>{V(se.target)&&(se.shiftKey||(se.preventDefault(),l({x:se.clientX,y:se.clientY}),s(!0),y(!1),k(!1),X(!1),q("")))};return document.addEventListener("mousedown",ce,!0),document.addEventListener("contextmenu",pe),()=>{document.removeEventListener("mousedown",ce,!0),document.removeEventListener("contextmenu",pe)}},[V]);const te=S.useCallback(async(ce,pe)=>{var qe,at,it,mt,$t;const se=re.current||t.current;if(!se)return;const Pe=W.current;if(!Pe||Pe.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",ce);return}let{nodes:Oe,nodeIds:Je}=Pe;const{from:Ne,to:et}=Pe;d(!0),s(!1),y(!1);const Le=`ctx-${Date.now()}`,He=se.state.doc.resolve(Ne),ke=se.state.doc.resolve(et),fe=He.sameParent(ke)&&Ne!==et;se.commands.applyLoadingEffect(Le,Ne,et,fe?"selection":"paragraph");try{const Lt=[],Z=[],We=new Set(Je);let Fe=!1;const xt=se.state.doc;for(let Ee=0;Ee<xt.childCount;Ee++){const lt=xt.child(Ee),Dt=(qe=lt.attrs)==null?void 0:qe.id;if(Dt&&We.has(Dt))Fe=!0;else if(Fe){const I=lt.textContent.trim();I&&Z.push(I)}else{const I=lt.textContent.trim();I&&Lt.push(I)}}const tt=ce.includes(":")?ce.split(":").slice(1).join(":"):ce;let Xe=Oe,nt=!1,Dn=0,ln=0;if(fe&&Oe.length===1){const Ee=He.start(He.depth);Dn=Ne-Ee,ln=et-Ee;const lt=((it=(at=Oe[0])==null?void 0:at.content)==null?void 0:it.reduce((Dt,I)=>{var ie;return Dt+(((ie=I.text)==null?void 0:ie.length)||(I.type==="hardBreak"?1:0))},0))??0;(Dn>0||ln<lt)&&(Xe=LL(Oe,Dn,ln),nt=!0)}const ir=se.state.doc.textContent,ct={nodes:Xe,action:tt,nodeIds:Je,contextBefore:Lt.slice(-3),contextAfter:Z.slice(0,3),fullDocument:ir,documentId:n,debug:!0};nt&&(ct.hasSelectionMarkers=!0),pe&&(ct.instruction=pe);const vn=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ct)});if(!vn.ok){const Ee=await vn.json().catch(()=>({}));console.error("[ContextMenu] API error:",vn.status,Ee);return}const le=await vn.json();if(le.success&&le.nodes){let Ee=le.nodes;if(Ee.length===1&&Array.isArray(Ee[0])&&(Ee=Ee[0]),DL(Ee),nt&&Ee.length===1&&Je.length===1){const lt=xe=>(xe==null?void 0:xe.reduce((Ye,Ct)=>{var Tt;return Ye+(((Tt=Ct.text)==null?void 0:Tt.length)||(Ct.type==="hardBreak"?1:0))},0))??0,Dt=lt((mt=Oe[0])==null?void 0:mt.content),I=lt(($t=Ee[0])==null?void 0:$t.content),ie={selectionFrom:Dn,selectionTo:I-(Dt-ln),originalFrom:Dn,originalTo:ln};km(se,Je[0],Ee[0],ie)}else jL(se,Ee,Je,tt)}else console.warn("[ContextMenu] Unexpected response:",le)}catch(Lt){console.error("[ContextMenu] Plugin action failed:",Lt)}finally{se.commands.removeLoadingEffect(Le),d(!1)}},[t]),oe=S.useCallback(async ce=>{const pe=re.current||t.current;if(!pe)return;const{$from:se}=pe.state.selection,Pe=se.before(se.depth),Oe=se.after(se.depth),Je=se.parent.content.size===0;d(!0),s(!1),y(!1),Je?pe.chain().focus().deleteRange({from:Pe,to:Oe}).insertContentAt(Pe,{type:"imageLoading"}).run():pe.chain().focus().insertContentAt(Oe,{type:"imageLoading"}).run();let Ne=-1;pe.state.doc.descendants((et,Le)=>{if(et.type.name==="imageLoading"&&Ne===-1)return Ne=Le,et.nodeSize,!1});try{const Le=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:ce})})).json();if(Le.success&&Le.src){let He=-1,ke=0;if(pe.state.doc.descendants((fe,qe)=>{if(fe.type.name==="imageLoading"&&He===-1)return He=qe,ke=fe.nodeSize,!1}),He>=0){const{tr:fe}=pe.state;fe.replaceWith(He,He+ke,pe.schema.nodes.image.create({src:Le.src,alt:ce})),pe.view.dispatch(fe)}}else{console.error("[ContextMenu] Image generation failed:",Le.error);let He=-1,ke=0;if(pe.state.doc.descendants((fe,qe)=>{if(fe.type.name==="imageLoading"&&He===-1)return He=qe,ke=fe.nodeSize,!1}),He>=0){const{tr:fe}=pe.state;fe.delete(He,He+ke),pe.view.dispatch(fe)}}}catch(et){console.error("[ContextMenu] Image generation failed:",et);let Le=-1,He=0;if(pe.state.doc.descendants((ke,fe)=>{if(ke.type.name==="imageLoading"&&Le===-1)return Le=fe,He=ke.nodeSize,!1}),Le>=0){const{tr:ke}=pe.state;ke.delete(Le,Le+He),pe.view.dispatch(ke)}}finally{d(!1)}},[t]),he=S.useCallback(ce=>{const{action:pe,isPlugin:se,promptForInput:Pe}=ce;if(se&&Pe){v(pe),y(!0);return}if(se){if(pe.startsWith("img:"))return;te(pe);return}if(pe==="agent-mark"){X(!0);return}if(pe==="delete"){const Oe=re.current||t.current,Je=W.current;if(Oe&&Je&&Je.nodeIds.length>0){const{tr:Ne}=Oe.state,et=new Set(Je.nodeIds),Le=[];Oe.state.doc.descendants((He,ke)=>{var fe;if((fe=He.attrs)!=null&&fe.id&&et.has(He.attrs.id))return Le.push({from:ke,to:ke+He.nodeSize}),!1});for(const He of Le.reverse())Ne.delete(He.from,He.to);Le.length>0&&Oe.view.dispatch(Ne)}s(!1);return}if(pe==="link"){const Oe=re.current||t.current;if(Oe){const Je=[];Oe.state.doc.descendants(Ne=>{var et;(et=Ne.marks)==null||et.forEach(Le=>{var He,ke;if(Le.type.name==="link"&&((ke=(He=Le.attrs)==null?void 0:He.href)!=null&&ke.startsWith("doc:"))){const fe=Le.attrs.href.slice(4);Je.includes(fe)||Je.push(fe)}})}),T(Je)}fetch("/api/documents").then(Je=>Je.json()).then(Je=>{Array.isArray(Je)&&C(Je.map(Ne=>({filename:Ne.filename,title:Ne.title}))),R(!1),z(""),k(!0)}).catch(()=>{});return}if(pe==="unlink"){const Oe=re.current||t.current;Oe&&Oe.chain().focus().unsetLink().run(),s(!1);return}},[te,t]),ne=S.useCallback(()=>{f.trim()&&(b.startsWith("img:")?oe(f.trim()):te(b,f.trim()),p(""),v(""))},[te,oe,b,f]),ge=S.useCallback(()=>{const ce=re.current||t.current,pe=W.current;if(!ce||!pe||!n)return;const{from:se,to:Pe,nodeIds:Oe}=pe;if(se===Pe||Oe.length===0)return;const Je=ce.state.doc.textBetween(se,Pe,`
|
|
205
|
-
`);Je.trim()&&fetch("/api/marks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:Je,note:J.trim(),nodeId:Oe[Oe.length-1]})}).then(()=>{s(!1),X(!1),q("")}).catch(Ne=>{console.error("[ContextMenu] Agent mark failed:",Ne)})},[t,n,J]),De=S.useCallback(ce=>{const pe=re.current||t.current;pe&&pe.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]),ot=S.useCallback(()=>{const ce=D.trim();if(!ce)return;const pe=re.current||t.current;pe&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ce})}).then(se=>se.json()).then(se=>{se.filename&&pe.chain().focus().setLink({href:`doc:${se.filename}`}).run()}).catch(()=>{}),s(!1),k(!1),R(!1),z(""))},[t,D]);return r?u.jsx("div",{ref:H,className:"context-menu",style:{left:i.x,top:i.y},children:c?u.jsx("div",{className:"context-menu-loading",children:"Applying..."}):Y?u.jsxs("div",{className:"context-menu-custom",children:[u.jsx("input",{autoFocus:!0,value:J,onChange:ce=>q(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&ge(),ce.key==="Escape"&&(X(!1),q(""))},placeholder:"Note for agent (optional)..."}),u.jsx("button",{onClick:ge,children:"Mark"})]}):m?u.jsxs("div",{className:"context-menu-custom",children:[u.jsx("input",{autoFocus:!0,value:f,onChange:ce=>p(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&ne(),ce.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),u.jsx("button",{onClick:ne,children:"Apply"})]}):w?u.jsxs("div",{className:"context-menu-link-picker",children:[u.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),_?u.jsxs("div",{className:"context-menu-custom",children:[u.jsx("input",{autoFocus:!0,value:D,onChange:ce=>z(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&ot(),ce.key==="Escape"&&R(!1)},placeholder:"New document title..."}),u.jsx("button",{onClick:ot,children:"Create"})]}):u.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>R(!0),children:u.jsx("span",{children:"+ New link doc"})}),u.jsxs("div",{className:"context-menu-link-list",children:[O.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),N.filter(ce=>O.includes(ce.filename)).map(({filename:ce,title:pe})=>u.jsx("button",{className:"context-menu-item",onClick:()=>De(ce),children:u.jsx("span",{children:pe})},`linked-${ce}`))]}),u.jsx("div",{className:"context-menu-section-header",children:"All documents"}),N.filter(ce=>!O.includes(ce.filename)).map(({filename:ce,title:pe})=>u.jsx("button",{className:"context-menu-item",onClick:()=>De(ce),children:u.jsx("span",{children:pe})},ce)),N.length===0&&u.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const ce=L();let pe;return ce.map((se,Pe)=>{const Oe=se.isPlugin&&se.pluginDisplayName&&se.pluginDisplayName!==pe,Je=pe!==void 0;se.isPlugin?pe=se.pluginDisplayName:pe=void 0;const Ne=!se.isPlugin&&Je;return u.jsxs("span",{children:[Oe&&u.jsx("div",{className:"context-menu-section-header",children:se.pluginDisplayName}),Ne&&u.jsx("div",{className:"context-menu-divider"}),u.jsxs("button",{className:"context-menu-item",onClick:()=>he(se),children:[u.jsx("span",{children:se.label}),se.shortcut&&u.jsx("span",{className:"context-menu-shortcut",children:se.shortcut})]})]},se.action)})})()}):null}function Sm(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 zL(t,e){const n=bn(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 $L(t,e){const n=bn(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 FL(t,e){var l;const n=bn(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=Sm(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function UL(t,e){var l;const n=bn(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=Sm(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function HL(t,e){var l,c;const n=bn(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 d=Sm(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(d).run()}return!0}function WL(t,e){var i;const n=bn(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 VL(t,e){const n=rd(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=bn(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 KL(t,e){var c;const n=rd(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 T1(t,e){var i,l;const n=bn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return VL(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return zL(t,e);case"rewrite":return $L(t,e);case"delete":return FL(t,e);default:return!1}}function M1(t,e){var i,l;const n=bn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return KL(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return UL(t,e);case"rewrite":return HL(t,e);case"delete":return WL(t,e);default:return!1}}function GL(t){const e=A1(t).reverse();for(const n of e)T1(t,n);t.view&&wm(t.view)}function qL(t){const e=A1(t).reverse();for(const n of e)M1(t,n);t.view&&wm(t.view)}function Em(t){const e=[],n=new Set;return t.state.doc.descendants((r,s)=>{var l,c,d;const i=(l=r.attrs)==null?void 0:l.pendingStatus;if(i&&((c=r.attrs)!=null&&c.id)){const f=(d=r.attrs)==null?void 0:d.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 _h(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...Em(n));return e}function A1(t){return Em(t).map(e=>e.nodeId)}function JL(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 vl(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(),d=i.top-c.top+l.scrollTop-l.clientHeight/2;l.scrollTo({top:d,behavior:"smooth"})}}catch{}}function YL(t){const[e,n]=S.useState([]),[r,s]=S.useState(0),i=S.useRef(),l=S.useRef(new Set),c=S.useCallback(()=>{const N=t.filter(R=>R&&!R.isDestroyed);if(N.length===0){n([]),l.current=new Set;return}const C=_h(N);n(C);const O=l.current,T=new Set(C.map(R=>R.nodeId));let _=-1;if(O.size>0){for(let R=0;R<C.length;R++)if(!O.has(C[R].nodeId)){_=R;break}}l.current=T,_>=0?(s(_),vl(C[_].editor,C[_].nodeId)):C.length===0?s(0):s(R=>Math.min(R,C.length-1))},[t]);S.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=_h(N.filter(_=>!_.isDestroyed));T.length>0&&vl(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]),S.useEffect(()=>{const N=e[r]??null;return n0((N==null?void 0:N.nodeId)??null,(N==null?void 0:N.groupId)??null),N!=null&&N.editor&&!N.editor.isDestroyed&&N.editor.view&&wm(N.editor.view),()=>{n0(null)}},[r,e]);const d=JL(e),f=e[r]??null,p=S.useCallback(()=>{if(e.length===0)return;const N=(r+1)%e.length;s(N),e[N]&&vl(e[N].editor,e[N].nodeId)},[e,r]),m=S.useCallback(()=>{if(e.length===0)return;const N=(r-1+e.length)%e.length;s(N),e[N]&&vl(e[N].editor,e[N].nodeId)},[e,r]),y=S.useCallback(()=>{const N=t.filter(T=>T&&!T.isDestroyed),C=_h(N);if(C.length===0)return;const O=Math.min(r,C.length-1);vl(C[O].editor,C[O].nodeId)},[t,r]),b=S.useCallback(()=>{f&&(T1(f.editor,f.nodeId),c(),y())},[f,c,y]),v=S.useCallback(()=>{f&&(M1(f.editor,f.nodeId),c(),y())},[f,c,y]),w=S.useCallback(()=>{const N=t.filter(C=>C&&!C.isDestroyed);for(const C of N)GL(C);c()},[t,c]),k=S.useCallback(()=>{const N=t.filter(C=>C&&!C.isDestroyed);for(const C of N)qL(C);c()},[t,c]);return{pendingNodes:e,counts:d,currentNode:f,currentIndex:r,hasPending:d.total>0,goToNext:p,goToPrevious:m,acceptCurrent:b,rejectCurrent:v,acceptAll:w,rejectAll:k,refresh:c}}const Ro={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},QL=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...Ro})}),XL=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...Ro})}),ZL=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...Ro})}),eD=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...Ro})}),p0=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...Ro})}),m0=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...Ro})});function O1(t,e,n){const r=bn(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 R1(t,e,n){const r=rd(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 jc(t,e){if(!xm()||!e)return!1;const n=lL(),r=oL();return r&&n&&Array.isArray(n)?R1(t,r,n):n&&O1(t,e,n),yp(!1),!0}function tD({editors:t,pendingDocs:e,currentFilename:n,onSwitchDocument:r,sendMessage:s,getDocument:i}){const{counts:l,currentNode:c,currentIndex:d,hasPending:f,goToNext:p,goToPrevious:m,acceptCurrent:y,rejectCurrent:b,acceptAll:v,rejectAll:w}=YL(t),[k,N]=S.useState(!1),C=S.useRef(null),O=S.useRef(null),T=e.filenames.length,_=nD(e.filenames,n),R=(c==null?void 0:c.pendingStatus)==="rewrite",D=!!(c!=null&&c.groupId),z=R,$=S.useCallback(()=>{var B,A;const K=c==null?void 0:c.editor;if(!(!K||!c||c.pendingStatus!=="rewrite"))if(k)O.current&&jc(O.current,C.current),C.current=null,O.current=null,N(!1);else if(D&&c.groupId){const L=rd(K,c.groupId);if(L.length===0)return;const te=(B=L[0].node.attrs)==null?void 0:B.pendingOriginalContent;if(!te||!Array.isArray(te))return;const oe=L.map(ge=>ge.node.toJSON()),he=te.map((ge,De)=>({...ge,attrs:{...ge.attrs||{},pendingStatus:"rewrite",pendingGroupId:c.groupId,...De===0?{pendingOriginalContent:te}:{}}}));if(!R1(K,c.groupId,he))return;yp(!0,c.nodeId,oe,c.groupId),C.current=c.nodeId,O.current=K,N(!0)}else{const L=bn(K,c.nodeId);if(!L)return;const{node:te}=L,oe=(A=te.attrs)==null?void 0:A.pendingOriginalContent;if(!oe)return;const he=te.toJSON();if(!O1(K,c.nodeId,oe))return;yp(!0,c.nodeId,he),C.current=c.nodeId,O.current=K,N(!0)}},[c,k,D]);S.useEffect(()=>{if(!k)return;const K=C.current,B=O.current;K&&B&&(c==null?void 0:c.nodeId)!==K&&(jc(B,K),C.current=null,O.current=null,N(!1))},[c==null?void 0:c.nodeId,k]),S.useEffect(()=>{if(t.length!==0)return()=>{xm()&&C.current&&O.current&&(jc(O.current,C.current),C.current=null,O.current=null)}},[t]);const U=S.useCallback(K=>{if(!n)return;if(!t.some(A=>!A||A.isDestroyed?!1:Em(A).length>0)){const A=i==null?void 0:i();A&&s({type:"doc-update",document:A,filename:n}),s({type:"pending-resolved",filename:n,action:K})}},[t,n,s,i]),Y=S.useCallback(()=>{O.current&&k&&C.current&&(jc(O.current,C.current),C.current=null,O.current=null,N(!1))},[k]),X=S.useCallback(()=>{Y(),y(),U("accept")},[Y,y,U]),J=S.useCallback(()=>{Y(),b(),U("reject")},[Y,b,U]),q=S.useCallback(()=>{Y(),v(),U("accept")},[Y,v,U]);S.useEffect(()=>{const K=()=>q();return window.addEventListener("ow-accept-all",K),()=>window.removeEventListener("ow-accept-all",K)},[q]);const H=S.useCallback(()=>{Y(),w(),U("reject")},[Y,w,U]),W=S.useCallback(()=>{if(T===0||T===1&&_===0)return;const K=_<=0?T-1:_-1;r(e.filenames[K])},[T,_,e.filenames,r]),re=S.useCallback(()=>{if(T===0||T===1&&_===0)return;const K=_>=T-1?0:_+1;r(e.filenames[K])},[T,_,e.filenames,r]);if(S.useEffect(()=>{if(!f)return;const K=B=>{if(!(B.target instanceof HTMLInputElement||B.target instanceof HTMLTextAreaElement)&&!(B.target instanceof HTMLElement&&B.target.closest("[contenteditable]")))switch(B.key){case"j":case"ArrowDown":!B.metaKey&&!B.ctrlKey&&(B.preventDefault(),p());break;case"k":case"ArrowUp":!B.metaKey&&!B.ctrlKey&&(B.preventDefault(),m());break;case"h":case"ArrowLeft":!B.metaKey&&!B.ctrlKey&&!B.altKey&&(B.preventDefault(),W());break;case"l":case"ArrowRight":!B.metaKey&&!B.ctrlKey&&!B.altKey&&(B.preventDefault(),re());break;case"a":!B.metaKey&&!B.ctrlKey&&!B.shiftKey&&(B.preventDefault(),X());break;case"r":!B.metaKey&&!B.ctrlKey&&(B.preventDefault(),J());break;case"A":B.shiftKey&&!B.metaKey&&!B.ctrlKey&&(B.preventDefault(),q());break;case"R":B.shiftKey&&!B.metaKey&&!B.ctrlKey&&(B.preventDefault(),H());break;case"o":!B.metaKey&&!B.ctrlKey&&!B.shiftKey&&(B.preventDefault(),$());break}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[f,p,m,W,re,X,J,q,H,$]),!f)return null;const V=_>=0?_+1:"?";return u.jsxs("div",{className:"review-panel",children:[T>1&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"review-panel__nav",children:[u.jsx("button",{className:"review-panel__btn",onClick:W,title:"Previous doc (h)",children:u.jsx(QL,{})}),u.jsx("button",{className:"review-panel__btn",onClick:re,title:"Next doc (l)",children:u.jsx(XL,{})}),u.jsxs("span",{className:"review-panel__counter",children:[V,"/",T]})]}),u.jsx("div",{className:"review-panel__divider"})]}),u.jsxs("div",{className:"review-panel__nav",children:[u.jsx("button",{className:"review-panel__btn",onClick:m,disabled:l.total===0,title:"Previous (k)",children:u.jsx(ZL,{})}),u.jsx("button",{className:"review-panel__btn",onClick:p,disabled:l.total===0,title:"Next (j)",children:u.jsx(eD,{})}),u.jsxs("span",{className:"review-panel__counter",children:[d+1,"/",l.total]})]}),u.jsx("div",{className:"review-panel__divider"}),u.jsxs("div",{className:"review-panel__toggle",children:[u.jsx("button",{className:`review-panel__toggle-btn${z&&!k?" review-panel__toggle-btn--active":""}`,onClick:()=>z&&k&&$(),disabled:!z,title:"Show modified (o)",children:"Modified"}),u.jsx("button",{className:`review-panel__toggle-btn${z&&k?" review-panel__toggle-btn--active":""}`,onClick:()=>z&&!k&&$(),disabled:!z,title:"Show original (o)",children:"Original"})]}),u.jsx("div",{className:"review-panel__divider"}),u.jsxs("div",{className:"review-panel__actions",children:[u.jsx("button",{className:"review-panel__accept",onClick:X,title:"Accept (a)",children:u.jsx(p0,{})}),u.jsx("button",{className:"review-panel__reject",onClick:J,title:"Reject (r)",children:u.jsx(m0,{})}),u.jsxs("button",{className:"review-panel__accept-all",onClick:q,title:"Accept all (Shift+A)",children:[u.jsx(p0,{}),u.jsx("span",{children:"All"})]}),u.jsxs("button",{className:"review-panel__reject-all",onClick:H,title:"Reject all (Shift+R)",children:[u.jsx(m0,{}),u.jsx("span",{children:"All"})]})]})]})}function nD(t,e){return t.indexOf(e)}function Ic(t){return t.type==="doc"?t.file:t.id}function j1(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&j1(n.items,e)}function Ao(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 us(t){return/^[A-Z]:[/\\]|^\//.test(t)}function I1(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function rD(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 sD(t,e){const[n,r]=S.useState([]),[s,i]=S.useState([]),[l,c]=S.useState(new Set),d=S.useRef(null),f=S.useCallback(()=>{fetch("/api/documents").then(m=>m.json()).then(m=>{Array.isArray(m)&&r(m)}).catch(()=>{})},[]),p=S.useCallback(()=>{fetch("/api/workspaces").then(m=>m.json()).then(async m=>{if(!Array.isArray(m))return;const 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&&j1(v.workspace.root,b);c(b)}).catch(()=>{})},[]);return S.useEffect(()=>{f()},[f,t]),S.useEffect(()=>{p()},[p,e,t]),S.useEffect(()=>{const m=requestAnimationFrame(()=>{var b;const y=(b=d.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:d}}function iD(t,e,n){const r=S.useCallback(_=>{fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>{})},[]),s=S.useCallback(_=>{fetch(`/api/documents/${encodeURIComponent(_)}/archive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),i=S.useCallback(_=>{fetch(`/api/documents/${encodeURIComponent(_)}/unarchive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),l=S.useCallback((_,R,D)=>{!D.trim()||D.trim()===R||fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:D.trim()})}).then(()=>e()).catch(()=>{})},[e]),c=S.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),d=S.useCallback(_=>{fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>{})},[]),f=S.useCallback((_,R,D)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(D?{metadata:D}:{})}).then(z=>z.json()).then(z=>{if(z.filename)return fetch(`/api/workspaces/${encodeURIComponent(_)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:z.filename,title:z.title||"Untitled",containerId:R})})}).catch(()=>{})},[]),p=S.useCallback((_,R)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/docs/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]),m=S.useCallback((_,R)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:R})}).catch(()=>{})},[]),y=S.useCallback((_,R)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]),b=S.useCallback((_,R,D)=>{D.trim()&&fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(R)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:D.trim()})}).catch(()=>{})},[]),v=S.useCallback((_,R)=>{R.trim()&&fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:R.trim()})}).catch(()=>{})},[]),[w,k]=S.useState({}),N=S.useRef(-1);S.useEffect(()=>{n!==N.current&&(N.current=n??0,fetch("/api/documents").then(_=>_.json()).then(_=>{const R={};return Promise.all(_.map(D=>fetch(`/api/doc-tags/${encodeURIComponent(D.filename)}`).then(z=>z.json()).then(z=>{var $;($=z.tags)!=null&&$.length&&(R[D.filename]=z.tags)}).catch(()=>{}))).then(()=>k(R))}).catch(()=>{}))},[n]);const C=S.useCallback(_=>w[_]||[],[w]),O=S.useCallback((_,R)=>{R.trim()&&(k(D=>{const z=D[_]||[];return z.includes(R.trim())?D:{...D,[_]:[...z,R.trim()]}}),fetch(`/api/doc-tags/${encodeURIComponent(_)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:R.trim()})}).catch(()=>{}))},[]),T=S.useCallback((_,R)=>{k(D=>{const $=(D[_]||[]).filter(U=>U!==R);if($.length===0){const U={...D};return delete U[_],U}return{...D,[_]:$}}),fetch(`/api/doc-tags/${encodeURIComponent(_)}/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[]);return{fetchDocs:e,handleDelete:r,handleArchive:s,handleUnarchive:i,handleRename:l,handleCreateWorkspace:c,handleDeleteWorkspace:d,handleCreateInWorkspace:f,handleRemoveFromWorkspace:p,handleCreateContainer:m,handleDeleteContainer:y,handleRenameContainer:b,handleRenameWorkspace:v,getDocTags:C,handleAddTag:O,handleRemoveTag:T}}function oD({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,l]=S.useState(null),[c,d]=S.useState(null),f=S.useRef(null),p=S.useRef(null),m=S.useRef(null),y=S.useRef(null),b=S.useRef(null),v=5,w=(U,Y,X)=>X==="before"?Y>0?Ic(U[Y-1]):null:Ic(U[Y]),k=S.useCallback((U,Y)=>{if(Y===null){const q=t.filter(W=>!n.has(W.filename)).map(W=>({type:"doc",file:W.filename,title:W.title})),H=q.findIndex(W=>Ic(W)===U);return H>=0?{siblings:q,index:H,containerId:null}:null}const X=e.find(q=>q.filename===Y);if(!(X!=null&&X.workspace))return null;const J=(q,H)=>{for(let W=0;W<q.length;W++){if(Ic(q[W])===U)return{siblings:q,index:W,containerId:H};if(q[W].type==="container"){const re=J(q[W].items,q[W].id);if(re)return re}}return null};return J(X.workspace.root,null)},[t,n,e]),N=S.useCallback(()=>{l(null),d(null),b.current=null,y.current=null,m.current&&(m.current.remove(),m.current=null),f.current&&(clearTimeout(f.current),f.current=null),p.current&&(cancelAnimationFrame(p.current),p.current=null),document.body.style.userSelect=""},[]),C=S.useCallback((U,Y)=>{if(!U||!Y)return;if(U.type==="workspace"){const V=Y.itemId;if(V===U.filename)return;const K=e.map(L=>L.filename),B=K.indexOf(U.filename);if(B<0)return;K.splice(B,1);let A=K.indexOf(V);if(A<0)return;Y.position==="after"&&(A+=1),K.splice(A,0,U.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:K})}).catch(()=>{});return}const{wsFilename:X,containerId:J,afterId:q}=Y,H=U.type==="doc"?U.file:U.id,W=U.sourceWs;if(Y.itemId===H)return;if(U.type==="container"){if(W!==X||!X)return;fetch(`/api/workspaces/${encodeURIComponent(X)}/docs/${encodeURIComponent(H)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:J??null,afterFile:q})}).catch(()=>{});return}const re=U.file;if(W===null&&X===null){const V=t.filter(te=>!n.has(te.filename)).map(te=>te.filename),K=V.indexOf(re);if(K<0)return;V.splice(K,1);let B=q?V.indexOf(q):-1;B>=0?B+=1:B=0,V.splice(B,0,re);const A=[];let L=0;for(const te of t)n.has(te.filename)?A.push(te.filename):A.push(V[L++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:A})}).catch(()=>{});return}if(W===null&&X!==null){fetch(`/api/workspaces/${encodeURIComponent(X)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:re,title:re.replace(/\.md$/,""),containerId:J??null,afterFile:q})}).catch(()=>{});return}if(W!==null&&X===null){fetch(`/api/workspaces/${encodeURIComponent(W)}/docs/${encodeURIComponent(re)}`,{method:"DELETE"}).catch(()=>{});return}if(W===X&&X!==null){fetch(`/api/workspaces/${encodeURIComponent(X)}/docs/${encodeURIComponent(re)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:J??null,afterFile:q})}).catch(()=>{});return}W!==null&&X!==null&&fetch(`/api/workspaces/${encodeURIComponent(X)}/docs/${encodeURIComponent(re)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:W,containerId:J??null,afterFile:q,title:re.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),O=S.useCallback((U,Y)=>{const X=m.current;X&&(X.style.display="none");const J=document.elementFromPoint(U,Y);if(X&&(X.style.display=""),!J)return null;if((i==null?void 0:i.type)==="workspace"){const te=J.closest("[data-ws-drag]");if(te){const oe=te.dataset.wsDrag,he=te.getBoundingClientRect(),ne=(Y-he.top)/he.height;return{itemId:oe,position:ne<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}return null}const q=J.closest("[data-drag-id]");if(!q){const te=J.closest("[data-drop-ws]");return te?{itemId:"__section__",position:"inside",wsFilename:te.dataset.dropWs==="__docs__"?null:te.dataset.dropWs,containerId:te.dataset.dropContainer||null,afterId:null}:null}const H=q.dataset.dragId,W=q.dataset.dragType,re=q.dataset.dragWs==="__docs__"?null:q.dataset.dragWs,V=q.getBoundingClientRect(),K=(Y-V.top)/V.height;if(W==="container-header"){const te=H,oe=q.dataset.dragParent||null,he=k(te,re);return he?K<.25?{itemId:te,position:"before",wsFilename:re,containerId:oe,afterId:w(he.siblings,he.index,"before")}:K>.75?{itemId:te,position:"after",wsFilename:re,containerId:oe,afterId:w(he.siblings,he.index,"after")}:{itemId:te,position:"inside",wsFilename:re,containerId:te,afterId:null}:null}const B=q.dataset.dragContainer||null,A=k(H,re);if(!A)return null;const L=K<.5?"before":"after";return{itemId:H,position:L,wsFilename:re,containerId:B,afterId:w(A.siblings,A.index,L)}},[k,i]),T=S.useCallback(U=>{const Y=r.current;if(!Y)return;const X=Y.getBoundingClientRect(),J=80,q=18;let H=0;if(U<X.top+J?H=-q*Math.max(0,1-(U-X.top)/J):U>X.bottom-J&&(H=q*Math.max(0,1-(X.bottom-U)/J)),p.current&&(cancelAnimationFrame(p.current),p.current=null),H!==0){const W=()=>{Y.scrollTop+=H,p.current=requestAnimationFrame(W)};p.current=requestAnimationFrame(W)}},[r]),_=S.useCallback((U,Y)=>{const X=m.current;X&&(X.style.display="none");const J=document.elementFromPoint(U,Y);X&&(X.style.display="");const q=J==null?void 0:J.closest("[data-section-key]");if(!q){f.current&&(clearTimeout(f.current),f.current=null);return}const H=q.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(W=>{if(!W.has(H))return W;const re=new Set(W);return re.delete(H),re})},500)},[s]);S.useEffect(()=>{if(!i)return;const U=X=>{m.current&&(m.current.style.left=`${X.clientX+12}px`,m.current.style.top=`${X.clientY-8}px`),d(O(X.clientX,X.clientY)),T(X.clientY),_(X.clientX,X.clientY)},Y=X=>{C(i,O(X.clientX,X.clientY)),N()};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",Y),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",Y)}},[i,O,C,N,T,_]);const R=S.useCallback((U,Y,X)=>{if(U.button!==0||U.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:U.clientX,y:U.clientY},b.current=Y;const q=W=>{if(!y.current||!b.current)return;const re=W.clientX-y.current.x,V=W.clientY-y.current.y;if(Math.abs(re)+Math.abs(V)>=v){document.body.style.userSelect="none",window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",H),l(b.current),b.current=null;const K=document.createElement("div");K.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);",K.textContent=X,document.body.appendChild(K),m.current=K,K.style.left=`${W.clientX+12}px`,K.style.top=`${W.clientY-8}px`}},H=()=>{window.removeEventListener("pointermove",q),window.removeEventListener("pointerup",H),y.current=null,b.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",q),window.addEventListener("pointerup",H)},[]);return{draggedItem:i,dropIndicator:c,handlePointerDown:R,dropClass:U=>!c||c.itemId!==U?"":c.position==="before"?"drop-before":c.position==="after"?"drop-after":c.position==="inside"?"drop-inside":"",isDragging:U=>i?i.type==="doc"?i.file===U:i.type==="workspace"?i.filename===U:i.id===U:!1,isContainerDropTarget:U=>!c||!i?!1:c.containerId===U}}function lD({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onRename:l,onArchive:c,onDelete:d,onPluginAction:f,pluginItems:p,onSchedulePost:m,onViewAnalytics:y,viewAnalyticsLabel:b,onMarkSent:v,isAlreadySent:w,isApproved:k,onToggleApprove:N}){const C=S.useRef(null),[O,T]=S.useState(!1),[_,R]=S.useState(!1),[D,z]=S.useState({left:t,top:e});S.useLayoutEffect(()=>{const U=C.current;if(!U)return;const Y=U.getBoundingClientRect(),X=8;let J=t,q=e;e+Y.height+X>window.innerHeight&&(q=e-Y.height),t+Y.width+X>window.innerWidth&&(J=t-Y.width),q<X&&(q=X),J<X&&(J=X),z({left:J,top:q})},[t,e]),S.useEffect(()=>{const U=Y=>{C.current&&!C.current.contains(Y.target)&&s()};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[s]),S.useEffect(()=>{const U=Y=>{Y.key==="Escape"&&s()};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s]);const $=S.useCallback(U=>{f(U.action,U),s()},[f,s]);return u.jsxs("div",{ref:C,className:"context-menu",style:{left:D.left,top:D.top},children:[u.jsx("button",{className:"context-menu-item",onClick:()=>{i(),s()},children:u.jsx("span",{children:"Duplicate"})}),u.jsx("button",{className:"context-menu-item",onClick:()=>{l(),s()},children:u.jsx("span",{children:"Rename"})}),_?u.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:U=>U.stopPropagation(),children:[u.jsx("span",{children:"Archive?"}),u.jsx("button",{onClick:()=>{c(),s()},children:"Yes"}),u.jsx("button",{onClick:()=>R(!1),children:"No"})]}):u.jsx("button",{className:"context-menu-item",onClick:()=>R(!0),children:u.jsx("span",{children:"Archive"})}),O?u.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:U=>U.stopPropagation(),children:[u.jsx("span",{children:us(n)?"Remove?":"Delete?"}),u.jsx("button",{onClick:()=>{d(),s()},children:"Yes"}),u.jsx("button",{onClick:()=>T(!1),children:"No"})]}):u.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>T(!0),children:u.jsx("span",{children:us(n)?"Remove":"Delete"})}),N&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{N(),s()},children:u.jsx("span",{children:k?"Remove Approval":"Approve"})})]}),m&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{m(),s()},children:u.jsx("span",{children:"Schedule Post"})})]}),v&&!w&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{v(),s()},children:u.jsx("span",{children:"Mark as Sent"})})]}),y&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{y(),s()},children:u.jsx("span",{children:b||"View Analytics"})})]}),p.length>0&&u.jsx(u.Fragment,{children:(()=>{let U;return p.map(Y=>{const X=Y.pluginDisplayName&&Y.pluginDisplayName!==U;return U=Y.pluginDisplayName,u.jsxs("span",{children:[X&&u.jsx("div",{className:"context-menu-divider"}),X&&u.jsx("div",{className:"context-menu-section-header",children:Y.pluginDisplayName}),u.jsx("button",{className:"context-menu-item",onClick:()=>$(Y),children:u.jsx("span",{children:Y.label})})]},Y.action)})})()})]})}function aD({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=S.useState(""),l=S.useRef(null);S.useEffect(()=>{var d;(d=l.current)==null||d.focus()},[]),S.useEffect(()=>{const d=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const c=S.useCallback(()=>{n(s.trim())},[s,n]);return u.jsx("div",{className:"focus-modal-overlay",onClick:r,children:u.jsxs("div",{className:"focus-modal",onClick:d=>d.stopPropagation(),children:[u.jsxs("div",{className:"focus-modal-header",children:[u.jsx("h2",{children:t}),u.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),u.jsxs("div",{className:"focus-modal-body",children:[u.jsxs("label",{children:['Focus instructions for "',e,'"',u.jsx("textarea",{ref:l,value:s,onChange:d=>i(d.target.value.slice(0,500)),placeholder:"Optional: guide the transformation (e.g. 'focus on the intro section', 'keep it professional')...",onKeyDown:d=>{d.key==="Enter"&&(d.ctrlKey||d.metaKey)&&c()}})]}),u.jsxs("div",{className:"focus-modal-hint",children:[s.length,"/500"]}),u.jsxs("div",{className:"focus-modal-actions",children:[u.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),u.jsx("button",{className:"focus-modal-btn primary",onClick:c,children:"Go"})]})]})]})})}function Th(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(u.jsx("mark",{children:t.slice(l,l+e.length)},l)),i=l+e.length}return n}function g0({r:t,query:e,onClick:n}){return u.jsxs("div",{className:`sidebar-item search-result-item ${t.isActive?"active":""} ${t.isArchived?"search-result-archived":""}`,onClick:n,children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-item-title-text",children:t.matchType==="title"?Th(t.title,e):t.title}),t.isArchived&&u.jsx("span",{className:"search-archived-badge",children:"archived"})]}),t.matchType==="tag"&&t.matchedTag&&u.jsxs("div",{className:"search-result-tag",children:["Tag: ",Th(t.matchedTag,e)]}),t.matchType==="content"&&t.snippet&&u.jsx("div",{className:"search-result-snippet",children:Th(t.snippet,e)}),u.jsxs("div",{className:"sidebar-item-meta",children:[t.wordCount.toLocaleString()," words · ",Ao(t.lastModified)]})]})}function Nm({results:t,query:e,onSwitchDocument:n,actions:r}){if(t.length===0)return u.jsx("div",{className:"sidebar-scroll",children:u.jsxs("div",{className:"search-empty",children:['No results for "',e,'"']})});const s=t.filter(l=>!l.isArchived),i=t.filter(l=>l.isArchived);return u.jsx("div",{className:"sidebar-scroll",children:u.jsxs("div",{className:"search-results",children:[s.map(l=>u.jsx(g0,{r:l,query:e,onClick:()=>n(l.filename)},l.filename)),i.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"search-archived-divider",children:u.jsx("span",{children:"Archived"})}),i.map(l=>u.jsx(g0,{r:l,query:e,onClick:()=>r.handleUnarchive(l.filename)},l.filename))]})]})})}async function Mh(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 Ah(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 cD({docId:t,title:e,onClose:n}){const[r,s]=S.useState("loading"),[i,l]=S.useState([]),[c,d]=S.useState(""),[f,p]=S.useState(null),[m,y]=S.useState(null),[b,v]=S.useState("links"),[w,k]=S.useState("all"),[N,C]=S.useState(!1),[O,T]=S.useState(!1),[_,R]=S.useState(""),[D,z]=S.useState(!1),[$,U]=S.useState(null),Y=S.useRef(null);S.useEffect(()=>{let ne=!1;return(async()=>{try{const ge=await Mh("list_newsletter_issues",{limit:20});if(ne)return;if(!ge.issues||ge.issues.length===0){s("no-data");return}l(ge.issues);const De=ge.issues[0].id;d(De)}catch(ge){ne||(y(ge.message),s("error"))}})(),()=>{ne=!0}},[]),S.useEffect(()=>{if(!c)return;let ne=!1;return C(!0),T(!1),U(null),R(""),(async()=>{try{const ge=await Mh("get_newsletter_analytics",{issue_id:c});if(ne)return;if(ge.error){y(ge.error),s("error");return}p(ge),s("loaded")}catch(ge){ne||(y(ge.message),s("error"))}finally{ne||C(!1)}})(),()=>{ne=!0}},[c]),S.useEffect(()=>{const ne=ge=>{Y.current&&!Y.current.contains(ge.target)&&n()};return document.addEventListener("mousedown",ne),()=>document.removeEventListener("mousedown",ne)},[n]),S.useEffect(()=>{const ne=ge=>{ge.key==="Escape"&&n()};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[n]);const X=f?dD(f.subscriber_events):[],J=(f==null?void 0:f.issue.recipient_count)??0,q=f?f.stats.delivered||J-f.stats.bounces:0,H=f?new Set(f.subscriber_events.filter(ne=>{var ge;return ne.event_type==="click"&&((ge=ne.url)==null?void 0:ge.includes("/newsletter/unsubscribe/"))}).map(ne=>ne.email)).size:0,W=f?f.stats.unsubscribes||H:0,re=f?f.subscriber_events.filter(ne=>ne.event_type==="dropped").length:0,V=f?Math.max(0,J-f.stats.unique_opens):0,K=f!=null&&f.issue.sent_at?Date.now()-new Date(f.issue.sent_at).getTime():0,B=Math.floor(K/36e5),A=!!(f!=null&&f.issue.resent_at||$),L=ne=>{const ge=Math.floor(ne/36e5);return ge<1?"just now":ge<24?`${ge}h ago`:`${Math.floor(ge/24)}d ${ge%24}h ago`},te=async()=>{if(!(!_.trim()||D)){z(!0);try{const ne=await Mh("resend_to_unopened",{issue_id:c,subject:_});ne.error?(y(ne.error),s("error")):(U({sent:ne.sent,failed:ne.failed}),T(!1))}catch(ne){y(ne.message),s("error")}finally{z(!1)}}},oe=ne=>{var ge;return ne.event_type==="unsubscribe"||ne.event_type==="click"&&!!((ge=ne.url)!=null&&ge.includes("/newsletter/unsubscribe/"))},he=f?uD(f.subscriber_events.filter(ne=>w==="all"?!0:w==="unsubscribe"?oe(ne):ne.event_type===w)):[];return u.jsx("div",{className:"newsletter-modal-overlay",children:u.jsxs("div",{className:"na-modal",ref:Y,children:[u.jsxs("div",{className:"na-header",children:[u.jsx("h3",{children:"Newsletter Analytics"}),u.jsx("button",{className:"newsletter-modal__close",onClick:n,children:"×"})]}),r==="loading"&&!f&&u.jsx("div",{className:"na-body",children:u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:"Loading analytics..."})]})}),r==="no-data"&&u.jsxs("div",{className:"na-body",children:[u.jsx("div",{className:"newsletter-modal__status",children:u.jsx("span",{children:"No newsletter sends found yet."})}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="error"&&u.jsxs("div",{className:"na-body",children:[u.jsx("div",{className:"newsletter-modal__error",children:m}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="loaded"&&f&&u.jsxs("div",{className:"na-body",children:[i.length>1&&u.jsx("select",{className:"newsletter-modal__select na-issue-select",value:c,onChange:ne=>d(ne.target.value),children:i.map(ne=>u.jsxs("option",{value:ne.id,children:[ne.subject," — ",y0(ne.sent_at)]},ne.id))}),N?u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:"Loading..."})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"na-kpi-row",children:[u.jsxs("div",{className:"na-kpi",children:[u.jsx("div",{className:"na-kpi__value",children:q.toLocaleString()}),u.jsx("div",{className:"na-kpi__label",children:"Delivered"}),u.jsxs("div",{className:"na-kpi__sub",children:[J.toLocaleString()," sent"]})]}),u.jsxs("div",{className:"na-kpi",children:[u.jsx("div",{className:"na-kpi__value",children:Ah(f.stats.unique_opens,q)}),u.jsx("div",{className:"na-kpi__label",children:"Open rate"}),u.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_opens.toLocaleString()," opens"]})]}),u.jsxs("div",{className:"na-kpi",children:[u.jsx("div",{className:"na-kpi__value",children:Ah(f.stats.unique_clicks,q)}),u.jsx("div",{className:"na-kpi__label",children:"Click rate"}),u.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_clicks.toLocaleString()," clicks"]})]})]}),u.jsxs("div",{className:"na-kpi-row na-kpi-row--secondary",children:[u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:f.stats.bounces}),u.jsx("span",{className:"na-kpi__label--sm",children:"Bounces"})]}),u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:W}),u.jsx("span",{className:"na-kpi__label--sm",children:"Unsubs"})]}),u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:re}),u.jsx("span",{className:"na-kpi__label--sm",children:"Dropped"})]}),f.stats.complaints>0&&u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:f.stats.complaints}),u.jsx("span",{className:"na-kpi__label--sm",children:"Spam"})]})]}),V>0&&!A&&u.jsx("div",{className:"na-resend",children:O?u.jsxs("div",{className:"na-resend-panel",children:[u.jsxs("div",{className:"na-resend-label-row",children:[u.jsx("span",{className:"na-resend-label",children:"New subject line"}),u.jsxs("span",{className:"na-resend-meta",children:["sent ",L(K),B<48?" · consider waiting 48h":""]})]}),u.jsx("input",{className:"na-resend-input",type:"text",value:_,onChange:ne=>R(ne.target.value),placeholder:"Try a different angle"}),u.jsxs("div",{className:"na-resend-actions",children:[u.jsx("button",{className:"na-resend-cancel",onClick:()=>T(!1),children:"Cancel"}),u.jsx("button",{className:"na-resend-send",onClick:te,disabled:D||!_.trim(),children:D?"Sending...":`Send to ${V.toLocaleString()}`})]})]}):u.jsxs("button",{className:"na-resend-toggle",onClick:()=>{T(!0),R(f.issue.subject)},children:["Resend to ",V.toLocaleString()," non-openers ",u.jsx("span",{style:{float:"right"},children:"›"})]})}),A&&u.jsxs("div",{className:"na-resend-done",children:["Resent ",f.issue.resent_at?L(Date.now()-new Date(f.issue.resent_at).getTime()):"just now",$?` — ${$.sent} sent`:"",f.issue.resend_subject?` — "${f.issue.resend_subject}"`:""]}),u.jsxs("div",{className:"na-tabs",children:[u.jsxs("button",{className:`na-tab${b==="links"?" active":""}`,onClick:()=>v("links"),children:["Links (",X.length,")"]}),u.jsxs("button",{className:`na-tab${b==="activity"?" active":""}`,onClick:()=>v("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),b==="links"&&u.jsx("div",{className:"na-table-wrap",children:X.length===0?u.jsx("div",{className:"na-empty",children:"No link clicks recorded yet."}):u.jsxs("table",{className:"na-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"Link"}),u.jsx("th",{children:"Unique"}),u.jsx("th",{children:"Total"}),u.jsx("th",{children:"CTR"})]})}),u.jsx("tbody",{children:X.map(ne=>u.jsxs("tr",{children:[u.jsx("td",{className:"na-table__url",title:ne.url,children:u.jsx("a",{href:ne.url,target:"_blank",rel:"noopener noreferrer",children:b0(ne.url)})}),u.jsx("td",{children:ne.uniqueClicks}),u.jsx("td",{children:ne.totalClicks}),u.jsx("td",{children:Ah(ne.uniqueClicks,q)})]},ne.url))})]})}),b==="activity"&&u.jsxs("div",{className:"na-activity",children:[u.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(ne=>u.jsx("button",{className:`na-filter-btn${w===ne?" active":""}`,onClick:()=>k(ne),children:ne==="all"?"All":ne.charAt(0).toUpperCase()+ne.slice(1)+"s"},ne))}),u.jsxs("div",{className:"na-table-wrap",children:[he.length===0?u.jsxs("div",{className:"na-empty",children:["No ",w==="all"?"":w+" ","events recorded."]}):u.jsxs("table",{className:"na-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"Email"}),u.jsx("th",{children:"Event"}),u.jsx("th",{children:"Detail"}),u.jsx("th",{children:"Time"})]})}),u.jsx("tbody",{children:he.slice(0,100).map(ne=>u.jsxs("tr",{children:[u.jsx("td",{className:"na-table__email",children:ne.email}),u.jsxs("td",{children:[u.jsx("span",{className:`na-badge na-badge--${ne.event_type}`,children:ne.event_type}),ne.count>1&&u.jsxs("span",{className:"na-count",children:[ne.count,"x"]})]}),u.jsx("td",{className:"na-table__url",children:ne.url?u.jsx("a",{href:ne.url,target:"_blank",rel:"noopener noreferrer",children:b0(ne.url,35)}):"—"}),u.jsx("td",{className:"na-table__time",children:y0(ne.latestTimestamp)})]},ne.key))})]}),he.length>100&&u.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",he.length," events"]})]})]})]})]})]})})}function uD(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 dD(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 fD(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function sd({filename:t,title:e,onClose:n}){const[r,s]=S.useState("queue"),[i,l]=S.useState(null),[c,d]=S.useState(null),[f,p]=S.useState(""),[m,y]=S.useState(!1),[b,v]=S.useState(null),[w,k]=S.useState(null);S.useEffect(()=>{fetch(`/api/documents/${encodeURIComponent(t)}/text`).then(O=>{if(!O.ok)throw new Error("Failed to load document");return O.json()}).then(O=>{d(O.text||""),l(fD(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 _=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)}),R=await _.json();if(_.ok){const D=(O=R.item)!=null&&O.scheduled_at?new Date(R.item.scheduled_at).toLocaleString():"now";v({success:!0,message:`Scheduled for ${D}`})}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 u.jsx("div",{className:"schedule-post-overlay",onClick:n,children:u.jsxs("div",{className:"schedule-post-modal",onClick:O=>O.stopPropagation(),children:[u.jsxs("div",{className:"schedule-post-modal-header",children:[u.jsx("h3",{children:"Schedule Post"}),u.jsx("button",{className:"schedule-post-modal-close",onClick:n,children:"×"})]}),u.jsx("div",{className:"schedule-post-modal-doc",children:e}),w?u.jsxs("div",{className:"schedule-post-modal-result error",children:[w,u.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):b?u.jsxs("div",{className:`schedule-post-modal-result ${b.success?"success":"error"}`,children:[b.message,u.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"schedule-post-modal-field",children:[u.jsx("label",{children:"Content Type"}),u.jsx("div",{className:"schedule-post-modal-type",children:C?"...":i})]}),u.jsxs("div",{className:"schedule-post-modal-field",children:[u.jsx("label",{children:"Mode"}),u.jsxs("div",{className:"schedule-post-modal-modes",children:[u.jsx("button",{className:`schedule-post-mode ${r==="queue"?"active":""}`,onClick:()=>s("queue"),children:"Queue Next"}),u.jsx("button",{className:`schedule-post-mode ${r==="now"?"active":""}`,onClick:()=>s("now"),children:"Post Now"}),u.jsx("button",{className:`schedule-post-mode ${r==="custom"?"active":""}`,onClick:()=>s("custom"),children:"Custom Time"})]})]}),r==="custom"&&u.jsxs("div",{className:"schedule-post-modal-field",children:[u.jsx("label",{children:"Date & Time"}),u.jsx("input",{type:"datetime-local",value:f,onChange:O=>p(O.target.value)})]}),u.jsxs("div",{className:"schedule-post-modal-actions",children:[u.jsx("button",{className:"schedule-post-modal-cancel",onClick:n,children:"Cancel"}),u.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 hD({anchorRect:t,onSelect:e,onClose:n}){const r=S.useRef(null),[s,i]=S.useState(null),[l,c]=S.useState(""),d=S.useRef(null),[f,p]=S.useState({left:t.left,top:t.bottom+4});S.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),p({left:N,top:C})},[t]),S.useEffect(()=>{const v=w=>{r.current&&!r.current.contains(w.target)&&n()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),S.useEffect(()=>{const v=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),S.useEffect(()=>{s&&setTimeout(()=>{var v;return(v=d.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 u.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:v0.map(v=>u.jsxs("div",{children:[u.jsx("button",{className:`create-doc-dropdown-item${s===v.key?" active":""}`,onClick:()=>m(v),children:v.label}),s===v.key&&u.jsxs("div",{className:"create-doc-dropdown-url",children:[u.jsx("input",{ref:d,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(""))}}),u.jsx("button",{onClick:y,disabled:!b,children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},v.key))})}function L1(t,e){if(!e)return!0;for(const n of t)if(n.type==="container"&&(n.id===e||L1(n.items,e)))return!0;return!1}function D1(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=D1(n.items,e);if(r)return[n.id,...r]}}return null}function pD({docs:t,archivedDocs:e,workspaces:n,assignedFiles:r,pendingDocs:s,onSwitchDocument:i,onCreateDocument:l,actions:c,scrollRef:d,writingTitle:f,writingTarget:p,searchQuery:m,searchResults:y,onSearchChange:b}){const[v,w]=S.useState(null),[k,N]=S.useState(""),[C,O]=S.useState(null),[T,_]=S.useState(()=>{try{const Z=localStorage.getItem("ow-collapsed-sections");return Z?new Set(JSON.parse(Z)):new Set}catch{return new Set}}),[R,D]=S.useState(null),[z,$]=S.useState(null),[U,Y]=S.useState(""),[X,J]=S.useState(null),[q,H]=S.useState(""),[W,re]=S.useState(null),[V,K]=S.useState(""),[B,A]=S.useState(null),[L,te]=S.useState(null),[oe,he]=S.useState([]),[ne,ge]=S.useState(null),[De,ot]=S.useState(null),[ce,pe]=S.useState(null),{draggedItem:se,dropIndicator:Pe,handlePointerDown:Oe,dropClass:Je,isDragging:Ne,isContainerDropTarget:et}=oD({docs:t,workspaces:n,assignedFiles:r,scrollRef:d,setCollapsedSections:_}),Le=S.useCallback(()=>{fetch("/api/plugins").then(Z=>Z.json()).then(Z=>{const We=[];for(const Fe of Z.plugins||[]){const xt=Fe.displayName||void 0;for(const tt of Fe.sidebarMenuItems||[])We.push({...tt,pluginDisplayName:xt})}he(We)}).catch(()=>{})},[]);S.useEffect(()=>{Le()},[Le]),S.useEffect(()=>{const Z=()=>Le();return window.addEventListener("ow-plugins-changed",Z),()=>window.removeEventListener("ow-plugins-changed",Z)},[Le]);const He=S.useCallback((Z,We)=>{Z.preventDefault(),Z.stopPropagation(),A({x:Z.clientX,y:Z.clientY,filename:We.filename,title:We.title,docId:We.docId,lastSent:We.lastSent,postedUrl:We.postedUrl,isNewsletter:We.isNewsletter})},[]),ke=S.useCallback(Z=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:Z})}).catch(()=>{})},[]),fe=S.useCallback((Z,We,Fe,xt,tt)=>{if(We.promptForFocus&&tt===void 0){ge({action:Z,label:We.label,filename:Fe,title:xt});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:Z,filename:Fe,title:xt,instructions:tt||"",label:We.label})}).catch(()=>{})},[]),qe=Z=>{_(We=>{const Fe=new Set(We);return Fe.has(Z)?Fe.delete(Z):Fe.add(Z),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...Fe])),Fe})},at=t.find(Z=>Z.isActive),it=S.useRef(n);if(it.current=n,S.useEffect(()=>{var Z;if(at)for(const We of it.current){const Fe=D1(((Z=We.workspace)==null?void 0:Z.root)||[],at.filename);if(Fe){_(xt=>{const tt=[We.filename,...Fe.map(nt=>`container-${nt}`)];if(tt.every(nt=>!xt.has(nt)))return xt;const Xe=new Set(xt);for(const nt of tt)Xe.delete(nt);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...Xe])),Xe});break}}},[at==null?void 0:at.filename]),y!==null)return u.jsx(Nm,{results:y,query:m,onSwitchDocument:i,actions:c});const mt=t.filter(Z=>!r.has(Z.filename)),$t=(Z,We,Fe,xt,tt)=>u.jsxs("div",{className:`sidebar-item ${Z.isActive?"active":""} ${Ne(Z.filename)?"dragging":""} ${Je(Z.filename)}`,"data-drag-id":Z.filename,"data-drag-type":"doc","data-drag-ws":We||"__docs__","data-drag-container":Fe||"",onPointerDown:Xe=>Oe(Xe,{type:"doc",file:Z.filename,sourceWs:We||null},Z.title),onClick:()=>!Z.isActive&&!se&&i(Z.filename),onDoubleClick:()=>{w(Z.filename),N(Z.title)},onContextMenu:Xe=>He(Xe,Z),children:[v===Z.filename?u.jsx("input",{className:"sidebar-rename-input",value:k,onChange:Xe=>N(Xe.target.value),onBlur:()=>{c.handleRename(Z.filename,Z.title,k),w(null)},onKeyDown:Xe=>{Xe.key==="Enter"&&(c.handleRename(Z.filename,Z.title,k),w(null)),Xe.key==="Escape"&&w(null)},autoFocus:!0,onClick:Xe=>Xe.stopPropagation()}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-item-title-text",children:Z.title}),c.getDocTags(Z.filename).includes("✓")&&u.jsx("svg",{className:"sidebar-approved-icon",title:"Approved",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),Z.lastSent&&u.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:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),s.filenames.includes(Z.filename)&&u.jsx("span",{className:"sidebar-pending-dot"})]}),us(Z.filename)&&u.jsx("div",{className:"sidebar-item-context",children:I1(Z.filename)}),u.jsxs("div",{className:"sidebar-item-meta",children:[Z.wordCount.toLocaleString()," words · ",Ao(Z.lastModified)]}),u.jsxs("div",{className:"sidebar-tags",children:[c.getDocTags(Z.filename).filter(Xe=>Xe!=="✓").map(Xe=>u.jsxs("span",{className:"sidebar-tag",onClick:nt=>nt.stopPropagation(),children:[Xe,u.jsx("span",{className:"sidebar-tag-remove",onClick:nt=>{nt.stopPropagation(),c.handleRemoveTag(Z.filename,Xe)},children:"×"})]},Xe)),W===Z.filename?u.jsx("input",{className:"sidebar-tag-input",value:V,onChange:Xe=>K(Xe.target.value),onBlur:()=>{V.trim()&&c.handleAddTag(Z.filename,V),re(null)},onKeyDown:Xe=>{Xe.key==="Enter"&&(c.handleAddTag(Z.filename,V),re(null),K("")),Xe.key==="Escape"&&(re(null),K(""))},autoFocus:!0,onClick:Xe=>Xe.stopPropagation(),placeholder:"tag..."}):u.jsx("button",{className:"sidebar-tag-add",onClick:Xe=>{Xe.stopPropagation(),re(Z.filename),K("")},children:"+"})]})]}),C===Z.filename?u.jsxs("div",{className:"sidebar-confirm-delete",onClick:Xe=>Xe.stopPropagation(),children:[u.jsx("span",{children:us(Z.filename)?"Remove?":"Delete?"}),u.jsx("button",{onClick:()=>{c.handleDelete(Z.filename),O(null)},children:"Yes"}),u.jsx("button",{onClick:()=>O(null),children:"No"})]}):u.jsx("button",{className:"sidebar-delete-btn",onClick:Xe=>{Xe.stopPropagation(),O(Z.filename)},title:us(Z.filename)?"Remove document":"Delete document",children:"×"})]},Z.filename),Lt=(Z,We,Fe,xt,tt,Xe)=>{if(Z.type==="doc"){const ct=t.find(vn=>vn.filename===Z.file);return ct?$t(ct,Fe,xt):us(Z.file)?u.jsx("div",{className:"sidebar-item sidebar-unavailable",children:u.jsxs("div",{className:"sidebar-item-title",children:[Z.title||Z.file," (unavailable)"]})},Z.file):u.jsxs("div",{className:"sidebar-item sidebar-missing",children:[u.jsxs("div",{className:"sidebar-item-title",children:[Z.title||Z.file," (missing)"]}),u.jsx("button",{className:"sidebar-delete-btn",onClick:()=>c.handleRemoveFromWorkspace(Fe,Z.file),title:"Remove",children:"×"})]},Z.file)}const nt=Z,Dn=`container-${nt.id}`,ln=T.has(Dn),ir=We<=2?`depth-${We}`:"depth-2";return u.jsxs("div",{className:`sidebar-container ${ir} ${ln?"collapsed":""} ${Je(nt.id)} ${et(nt.id)?"drop-inside":""}`,children:[u.jsxs("div",{className:`sidebar-container-header ${(Pe==null?void 0:Pe.itemId)===nt.id&&Pe.position==="inside"?"drop-inside":""}`,"data-drag-id":nt.id,"data-drag-type":"container-header","data-drag-ws":Fe,"data-drag-parent":xt||"","data-section-key":Dn,onPointerDown:ct=>Oe(ct,{type:"container",id:nt.id,sourceWs:Fe},nt.name),onClick:()=>!se&&qe(Dn),children:[u.jsx("span",{className:`sidebar-chevron ${ln?"collapsed":""}`,children:"▾"}),z===nt.id?u.jsx("input",{className:"sidebar-rename-input",value:U,onChange:ct=>Y(ct.target.value),onBlur:()=>{c.handleRenameContainer(Fe,nt.id,U),$(null)},onKeyDown:ct=>{ct.key==="Enter"&&(c.handleRenameContainer(Fe,nt.id,U),$(null)),ct.key==="Escape"&&$(null)},autoFocus:!0,onClick:ct=>ct.stopPropagation()}):u.jsx("span",{className:"sidebar-container-name",onDoubleClick:ct=>{ct.stopPropagation(),$(nt.id),Y(nt.name)},children:nt.name}),u.jsxs("div",{className:"sidebar-container-actions",children:[u.jsx("button",{className:"sidebar-new-btn",onClick:ct=>{ct.stopPropagation(),pe({anchor:ct.target.getBoundingClientRect(),wsFilename:Fe,containerId:nt.id})},title:"New doc",children:"+"}),We<2&&u.jsx("button",{className:"sidebar-new-btn",onClick:ct=>{ct.stopPropagation(),c.handleCreateContainer(Fe,nt.id)},title:"New sub-container",children:"☐"}),u.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:ct=>{ct.stopPropagation(),c.handleDeleteContainer(Fe,nt.id)},title:"Delete container",children:"×"})]})]}),!ln&&u.jsxs("div",{className:"sidebar-container-list","data-drop-ws":Fe,"data-drop-container":nt.id,children:[f&&(p==null?void 0:p.wsFilename)===Fe&&p.containerId===nt.id&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f&&(p==null?void 0:p.wsFilename)===Fe&&p.containerId===nt.id?nt.items.filter(ct=>ct.type!=="doc"||ct.title!==f):nt.items).map((ct,vn)=>Lt(ct,We+1,Fe,nt.id,nt.items)),nt.items.length===0&&!f&&u.jsx("div",{className:"sidebar-empty",children:se?"Drop here":"Empty"})]})]},nt.id)};return u.jsxs("div",{className:"sidebar-scroll",ref:d,children:[u.jsxs("div",{className:`sidebar-section sidebar-docs-section ${T.has("docs")?"docs-collapsed":""}`,children:[u.jsxs("div",{className:"sidebar-section-header","data-section-key":"docs",onClick:()=>qe("docs"),children:[u.jsx("span",{className:`sidebar-chevron ${T.has("docs")?"collapsed":""}`,children:"▾"}),u.jsx("span",{className:"sidebar-label",children:"Documents"}),u.jsx("button",{className:"sidebar-new-btn",onClick:Z=>{Z.stopPropagation(),pe({anchor:Z.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!T.has("docs")&&u.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&(!p||!n.some(Z=>Z.filename===(p==null?void 0:p.wsFilename)))&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f?mt.filter(Z=>Z.title!==f):mt).map((Z,We)=>(mt.map(Fe=>({type:"doc",file:Fe.filename,title:Fe.title})),$t(Z,void 0,null))),mt.length===0&&u.jsx("div",{className:"sidebar-empty",children:se?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(Z=>{var xt;const We=((xt=Z.workspace)==null?void 0:xt.root)||[],Fe=T.has(Z.filename);return u.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${Fe?"ws-collapsed":""} ${Ne(Z.filename)?"dragging":""} ${(Pe==null?void 0:Pe.itemId)===Z.filename?Pe.position==="before"?"drop-before":"drop-after":""}`,children:[u.jsxs("div",{className:"sidebar-section-header","data-section-key":Z.filename,"data-ws-drag":Z.filename,onPointerDown:tt=>Oe(tt,{type:"workspace",filename:Z.filename},Z.title),onClick:()=>!se&&qe(Z.filename),children:[u.jsx("span",{className:`sidebar-chevron ${Fe?"collapsed":""}`,children:"▾"}),X===Z.filename?u.jsx("input",{className:"sidebar-rename-input",value:q,onChange:tt=>H(tt.target.value),onBlur:()=>{c.handleRenameWorkspace(Z.filename,q),J(null)},onKeyDown:tt=>{tt.key==="Enter"&&(c.handleRenameWorkspace(Z.filename,q),J(null)),tt.key==="Escape"&&J(null)},autoFocus:!0,onClick:tt=>tt.stopPropagation()}):u.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:tt=>{tt.stopPropagation(),J(Z.filename),H(Z.title)},children:Z.title}),u.jsxs("div",{className:"sidebar-workspace-actions",children:[u.jsx("button",{className:"sidebar-new-btn",onClick:tt=>{tt.stopPropagation(),pe({anchor:tt.target.getBoundingClientRect(),wsFilename:Z.filename,containerId:null})},title:"New document",children:"+"}),u.jsx("button",{className:"sidebar-new-btn",onClick:tt=>{tt.stopPropagation(),c.handleCreateContainer(Z.filename,null)},title:"New container",children:"☐"}),R===Z.filename?u.jsxs("span",{className:"sidebar-inline-confirm",onClick:tt=>tt.stopPropagation(),children:[u.jsx("button",{onClick:()=>{c.handleDeleteWorkspace(Z.filename),D(null)},children:"Yes"}),u.jsx("button",{onClick:()=>D(null),children:"No"})]}):u.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:tt=>{tt.stopPropagation(),D(Z.filename)},title:"Delete workspace",children:"×"})]})]}),!Fe&&u.jsxs("div",{className:"sidebar-section-list","data-drop-ws":Z.filename,children:[f&&(p==null?void 0:p.wsFilename)===Z.filename&&(p.containerId===null||!L1(We,p.containerId))&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f&&(p==null?void 0:p.wsFilename)===Z.filename&&p.containerId===null?We.filter(tt=>tt.type!=="doc"||tt.title!==f):We).map((tt,Xe)=>Lt(tt,0,Z.filename,null)),We.length===0&&!f&&u.jsx("div",{className:"sidebar-empty",children:se?"Drop here to add":"Empty workspace"})]})]},Z.filename)}),u.jsx("div",{className:"sidebar-new-workspace",children:u.jsx("button",{onClick:c.handleCreateWorkspace,children:"+ New Workspace"})}),B&&u.jsx(lD,{x:B.x,y:B.y,filename:B.filename,title:B.title,onClose:()=>A(null),onDuplicate:()=>ke(B.filename),onRename:()=>{w(B.filename),N(B.title)},onArchive:()=>c.handleArchive(B.filename),onDelete:()=>c.handleDelete(B.filename),onPluginAction:(Z,We)=>fe(Z,We,B.filename,B.title),pluginItems:oe,onSchedulePost:()=>{ot({filename:B.filename,title:B.title}),A(null)},onViewAnalytics:B.docId&&B.lastSent&&(B.postedUrl||B.isNewsletter)?()=>{B.postedUrl?window.open(B.postedUrl,"_blank"):te({docId:B.docId,title:B.title}),A(null)}:void 0,viewAnalyticsLabel:B.postedUrl?"View on X":"View Analytics",isApproved:c.getDocTags(B.filename).includes("✓"),onToggleApprove:()=>{c.getDocTags(B.filename).includes("✓")?c.handleRemoveTag(B.filename,"✓"):(c.handleAddTag(B.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAlreadySent:!!B.lastSent,onMarkSent:()=>{const Z=B.filename;c.getDocTags(Z).includes("✓")&&c.handleRemoveTag(Z,"✓"),i(Z),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>c.fetchDocs()).catch(()=>{})},100),A(null)}}),ne&&u.jsx(aD,{actionLabel:ne.label,docTitle:ne.title,onClose:()=>ge(null),onConfirm:Z=>{const We=oe.find(Fe=>Fe.action===ne.action);We&&fe(ne.action,We,ne.filename,ne.title,Z),ge(null)}}),L&&u.jsx(cD,{docId:L.docId,title:L.title,onClose:()=>te(null)}),De&&u.jsx(sd,{filename:De.filename,title:De.title,onClose:()=>ot(null)}),ce&&u.jsx(hD,{anchorRect:ce.anchor,onClose:()=>pe(null),onSelect:Z=>{pe(null),ce.wsFilename?c.handleCreateInWorkspace(ce.wsFilename,ce.containerId??null,Z):Z?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:Z})}).catch(()=>{}):l()}})]})}function mD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:l,scrollRef:c,searchQuery:d,searchResults:f}){const[p,m]=S.useState(null);if(f!==null)return u.jsx(Nm,{results:f,query:d,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=rD(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 u.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:c,children:[u.jsxs("div",{className:"tl-header",children:[u.jsx("span",{className:"tl-title",children:"Timeline"}),u.jsx("button",{className:"sidebar-new-btn",onClick:i,title:"New document",children:"+"})]}),b.map(k=>u.jsxs("div",{className:"tl-group",children:[u.jsx("div",{className:"tl-date",children:k.label}),k.docs.map(N=>{const C=w(N.filename);return u.jsxs("div",{className:`tl-item ${N.isActive?"active":""}`,onClick:()=>!N.isActive&&s(N.filename),children:[u.jsx("div",{className:"tl-dot"}),u.jsxs("div",{className:"tl-content",children:[u.jsxs("div",{className:"tl-item-title",children:[u.jsx("span",{children:N.title}),r.filenames.includes(N.filename)&&u.jsx("span",{className:"sidebar-pending-dot"})]}),us(N.filename)&&u.jsx("div",{className:"tl-item-context",children:I1(N.filename)}),u.jsxs("div",{className:"tl-item-meta",children:[N.wordCount.toLocaleString()," words · ",Ao(N.lastModified)]}),C&&u.jsx("div",{className:"tl-badge",children:C})]}),p===N.filename?u.jsxs("div",{className:"sidebar-confirm-delete",onClick:O=>O.stopPropagation(),children:[u.jsx("span",{children:us(N.filename)?"Remove?":"Delete?"}),u.jsx("button",{onClick:()=>{l.handleDelete(N.filename),m(null)},children:"Yes"}),u.jsx("button",{onClick:()=>m(null),children:"No"})]}):u.jsx("button",{className:"sidebar-delete-btn",onClick:O=>{O.stopPropagation(),m(N.filename)},title:us(N.filename)?"Remove":"Delete",children:"×"})]},N.filename)})]},k.label)),t.length===0&&u.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function gD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:l,searchQuery:c,searchResults:d,onSearchChange:f}){const[p,m]=S.useState([]),[y,b]=S.useState(null),[v,w]=S.useState(null),k=S.useRef(null);S.useEffect(()=>{if(!y)return;const A=L=>{k.current&&!k.current.contains(L.target)&&b(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[y]);const N=(A,L)=>{for(const te of A)if(te.type==="container"){if(te.id===L)return te;const oe=N(te.items,L);if(oe)return oe}return null},C=A=>{let L=0;for(const te of A)te.type==="doc"?L++:te.type==="container"&&(L+=C(te.items));return L},O=A=>{const L=[];for(const te of A)te.type==="doc"?L.push(te.file):te.type==="container"&&L.push(...O(te.items));return L},T=S.useMemo(()=>{if(p.length===0)return[];const A=p[p.length-1],L=e.find(oe=>oe.filename===A.wsFilename);if(!(L!=null&&L.workspace))return[];if(A.type==="workspace")return L.workspace.root;const te=N(L.workspace.root,A.key);return te?te.items:[]},[p,e]),_=T.filter(A=>A.type==="container"),R=S.useMemo(()=>{const A=T.filter(L=>L.type==="doc").map(L=>L.file);return t.filter(L=>A.includes(L.filename))},[T,t]),D=A=>{const L=O(A.items);return t.filter(te=>L.includes(te.filename))},z=A=>{const L=e.find(oe=>oe.filename===A);if(!(L!=null&&L.workspace))return[];const te=O(L.workspace.root);return t.filter(oe=>te.includes(oe.filename))},$=S.useMemo(()=>t.filter(A=>!n.has(A.filename)),[t,n]),U=A=>{m(L=>[...L,A]),b(null)},Y=()=>{m(A=>A.slice(0,-1)),b(null)},X=(A,L)=>{if(y===A){b(null);return}const oe=L.currentTarget.getBoundingClientRect();w({top:oe.bottom+4,left:oe.left}),b(A)},J=A=>{s(A),b(null)},q=p.length>1?p[p.length-2].title:"All",H=S.useRef(null),W=S.useRef(null),[re,V]=S.useState(null),K=S.useCallback(A=>{const te=A.currentTarget.getBoundingClientRect();V({top:te.bottom+4,left:te.left})},[]);S.useEffect(()=>{if(!d)return;const A=L=>{W.current&&!W.current.contains(L.target)&&H.current&&!H.current.contains(L.target)&&f("")};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[d,f]);const B=()=>{if(!y)return[];if(y==="__unassigned__")return $;if(y==="__level-docs__")return R;const A=e.find(L=>L.filename===y);if(A)return z(A.filename);for(const L of e){if(!L.workspace)continue;const te=N(L.workspace.root,y);if(te)return D(te)}return[]};return u.jsxs("div",{className:"board-scroll",ref:l,children:[u.jsxs("div",{className:"board-search-pill",children:[u.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:[u.jsx("circle",{cx:"11",cy:"11",r:"8"}),u.jsx("path",{d:"m21 21-4.3-4.3"})]}),u.jsx("input",{ref:H,className:"board-search-input",type:"text",placeholder:"Search...",value:c,onChange:A=>f(A.target.value),onFocus:K}),c&&u.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),p.length===0?u.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):u.jsxs("button",{className:"board-back",onClick:Y,title:`Back to ${q}`,children:["← ",q]}),p.length===0&&u.jsxs(u.Fragment,{children:[$.length>0&&u.jsxs("button",{className:`board-chip ${y==="__unassigned__"?"open":""}`,onClick:A=>X("__unassigned__",A),children:["Documents ",u.jsx("span",{className:"board-chip-count",children:$.length})]}),e.map(A=>{var te;const L=(te=A.workspace)==null?void 0:te.root.some(oe=>oe.type==="container");return u.jsxs("button",{className:`board-chip ${y===A.filename?"open":""}`,onClick:oe=>L?U({type:"workspace",key:A.filename,title:A.title,wsFilename:A.filename}):X(A.filename,oe),children:[A.title," ",u.jsx("span",{className:"board-chip-count",children:A.docCount}),L&&u.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.filename)}),u.jsx("button",{className:"board-chip board-chip-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),p.length>0&&u.jsxs(u.Fragment,{children:[R.length>0&&u.jsxs("button",{className:`board-chip board-chip-docs ${y==="__level-docs__"?"open":""}`,onClick:A=>X("__level-docs__",A),children:["Docs ",u.jsx("span",{className:"board-chip-count",children:R.length})]}),_.map(A=>{const L=A.items.some(te=>te.type==="container");return u.jsxs("button",{className:`board-chip ${y===A.id?"open":""}`,onClick:te=>L?U({type:"container",key:A.id,title:A.name,wsFilename:p[p.length-1].wsFilename}):X(A.id,te),children:[A.name," ",u.jsx("span",{className:"board-chip-count",children:C(A.items)}),L&&u.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.id)})]}),y&&v&&(()=>{const A=B();return u.jsxs("div",{className:"board-dropdown",ref:k,style:{position:"fixed",top:v.top,left:v.left},children:[A.map(L=>u.jsxs("div",{className:`board-dropdown-item ${L.isActive?"active":""}`,onClick:()=>J(L.filename),children:[u.jsxs("span",{className:"board-dropdown-title",children:[L.title,r.filenames.includes(L.filename)&&u.jsx("span",{className:"board-pending-dot"})]}),u.jsxs("span",{className:"board-dropdown-meta",children:[L.wordCount.toLocaleString()," words · ",Ao(L.lastModified)]})]},L.filename)),A.length===0&&u.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),d&&re&&u.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:W,style:{position:"fixed",top:re.top,left:re.left},children:[d.map(A=>u.jsxs("div",{className:`board-dropdown-item ${A.isActive?"active":""}`,onClick:()=>{s(A.filename),f("")},children:[u.jsx("span",{className:"board-dropdown-title",children:A.title}),A.matchType==="tag"&&A.matchedTag&&u.jsxs("span",{className:"board-dropdown-meta",children:["Tag: ",A.matchedTag]}),A.matchType==="content"&&A.snippet&&u.jsx("span",{className:"board-dropdown-meta board-search-snippet",children:A.snippet}),u.jsxs("span",{className:"board-dropdown-meta",children:[A.wordCount.toLocaleString()," words · ",Ao(A.lastModified)]})]},A.filename)),d.length===0&&u.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function yD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:l,searchQuery:c,searchResults:d}){const[f,p]=S.useState([]);if(d!==null)return u.jsx(Nm,{results:d,query:c,onSwitchDocument:s});const m=(T,_)=>{for(const R of T)if(R.type==="container"){if(R.id===_)return R;const D=m(R.items,_);if(D)return D}return null},y=T=>{let _=0;for(const R of T)R.type==="doc"?_++:R.type==="container"&&(_+=y(R.items));return _},b=S.useMemo(()=>{if(f.length===0)return[];const T=f[f.length-1],_=e.find(D=>D.filename===T.wsFilename);if(!(_!=null&&_.workspace))return[];if(T.type==="workspace")return _.workspace.root;const R=m(_.workspace.root,T.key);return R?R.items:[]},[f,e]),v=b.filter(T=>T.type==="container"),w=S.useMemo(()=>{if(f.length===0)return t.filter(_=>!n.has(_.filename));const T=b.filter(_=>_.type==="doc").map(_=>_.file);return t.filter(_=>T.includes(_.filename))},[f,b,t,n]),k=T=>p(_=>[..._,T]),N=()=>p(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 u.jsxs("div",{className:"shelf-wrapper",children:[u.jsxs("div",{className:"shelf-spines",ref:l,children:[f.length>0&&u.jsxs("button",{className:"shelf-back",onClick:N,title:`Back to ${C}`,children:[u.jsx("span",{className:"shelf-back-arrow",children:"←"}),u.jsx("span",{className:"shelf-back-label",children:C})]}),f.length===0&&u.jsxs(u.Fragment,{children:[e.map(T=>u.jsxs("div",{className:"shelf-section-spine",onClick:()=>k({type:"workspace",key:T.filename,title:T.title,wsFilename:T.filename}),title:T.title,children:[u.jsx("span",{className:"shelf-section-title",children:T.title}),u.jsx("span",{className:"shelf-section-count",children:T.docCount})]},T.filename)),u.jsx("button",{className:"shelf-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),f.length>0&&v.map(T=>u.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:[u.jsx("span",{className:"shelf-section-title",children:T.name}),u.jsx("span",{className:"shelf-section-count",children:y(T.items)})]},T.id))]}),u.jsxs("div",{className:"shelf-docs",children:[u.jsx("div",{className:"shelf-docs-header",children:O}),u.jsxs("div",{className:"shelf-docs-list",children:[w.map(T=>u.jsxs("div",{className:`shelf-doc-item ${T.isActive?"active":""}`,onClick:()=>s(T.filename),children:[u.jsxs("div",{className:"shelf-doc-title",children:[u.jsx("span",{children:T.title}),r.filenames.includes(T.filename)&&u.jsx("span",{className:"shelf-pending-dot"})]}),u.jsxs("div",{className:"shelf-doc-meta",children:[T.wordCount.toLocaleString()," words · ",Ao(T.lastModified)]})]},T.filename)),w.length===0&&u.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}const bD=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],vD=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}],P1=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","America/Phoenix","America/Toronto","America/Vancouver","America/Sao_Paulo","America/Mexico_City","Europe/London","Europe/Paris","Europe/Berlin","Europe/Amsterdam","Europe/Rome","Europe/Madrid","Europe/Moscow","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Asia/Singapore","Asia/Seoul","Australia/Sydney","Australia/Melbourne","Pacific/Auckland"];function x0(t){var e;try{const n=new Date,i=((e=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(n).find(c=>c.type==="timeZoneName"))==null?void 0:e.value)||"";return`${t.split("/").pop().replace(/_/g," ")} (${i})`}catch{return t}}function xD(t){if(t.length>0)return t[0].timezone;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(P1.includes(e))return e}catch{}return"America/New_York"}function wD({slots:t,onBack:e}){const[n,r]=S.useState(t),[s,i]=S.useState(()=>xD(t)),[l,c]=S.useState(!1),[d,f]=S.useState("09:00"),[p,m]=S.useState(["default"]),[y,b]=S.useState("any"),[v,w]=S.useState(!1),k=S.useRef(null);S.useEffect(()=>{if(!l)return;function _(R){k.current&&!k.current.contains(R.target)&&c(!1)}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[l]);async function N(_){i(_);const R=[];for(const D of n){const z=await fetch(`/api/scheduler/slots/${D.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:_})});if(z.ok){const $=await z.json();R.push($.slot)}else R.push(D)}R.length>0&&r(R)}async function C(){const _=await fetch("/api/scheduler/slots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:d,days:p.includes("default")?["default"]:p,filter_type:y,timezone:s})});if(_.ok){const R=await _.json();r(D=>[...D,R.slot]),w(!1),f("09:00"),m(["default"]),b("any")}}async function O(_){(await fetch(`/api/scheduler/slots/${_}`,{method:"DELETE"})).ok&&r(D=>D.filter(z=>z.id!==_))}function T(_){m(R=>{if(_==="default")return["default"];const D=R.filter(z=>z!=="default");if(D.includes(_)){const z=D.filter($=>$!==_);return z.length===0?["default"]:z}return[...D,_]})}return u.jsxs("div",{className:"sidebar-schedule",children:[u.jsxs("div",{className:"sidebar-schedule-header",children:[u.jsx("button",{className:"sidebar-schedule-btn",onClick:e,title:"Back",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Slot Settings"}),u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>w(!v),children:v?"Cancel":"+ Add"})]}),u.jsxs("div",{className:"slot-tz",ref:k,children:[u.jsx("label",{className:"slot-tz-label",children:"Timezone"}),u.jsxs("button",{className:"slot-tz-trigger",onClick:()=>c(!l),children:[u.jsx("span",{children:x0(s)}),u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`slot-tz-chevron ${l?"slot-tz-chevron--open":""}`,children:u.jsx("path",{d:"m6 9 6 6 6-6"})})]}),l&&u.jsx("div",{className:"slot-tz-dropdown",children:P1.map(_=>u.jsx("div",{className:`slot-tz-option ${_===s?"active":""}`,onClick:()=>{N(_),c(!1)},children:x0(_)},_))})]}),v&&u.jsxs("div",{className:"slot-add-form",children:[u.jsxs("div",{className:"slot-add-row",children:[u.jsx("input",{type:"time",className:"slot-input",value:d,onChange:_=>f(_.target.value)}),u.jsx("select",{className:"slot-input",value:y,onChange:_=>b(_.target.value),children:vD.map(_=>u.jsx("option",{value:_.value,children:_.label},_.value))})]}),u.jsxs("div",{className:"slot-add-days",children:[u.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${p.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>T("default"),children:"Every day"}),bD.map(_=>u.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${p.includes(_.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>T(_.toLowerCase()),children:_},_))]}),u.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active slot-create-btn",onClick:C,children:"Create Slot"})]}),u.jsx("div",{className:"slot-list",children:n.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No slots"}),u.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):n.map(_=>u.jsxs("div",{className:"schedule-item slot-item",children:[u.jsx("div",{className:"schedule-item-time slot-item-time",children:kD(_.time)}),u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:_.days.includes("default")?"Every day":_.days.join(", ")}),u.jsxs("div",{className:"schedule-item-meta",children:[u.jsxs("span",{children:["Filter: ",_.filter_type]}),_.filter_value&&u.jsxs("span",{children:["(",_.filter_value,")"]})]})]}),u.jsx("button",{className:"schedule-item-action schedule-item-action--danger slot-delete-btn",onClick:()=>O(_.id),title:"Delete slot",children:"×"})]},_.id))})]})}function kD(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function SD({onBack:t}){const[e,n]=S.useState([]),[r,s]=S.useState([]),[i,l]=S.useState(null),[c,d]=S.useState(!1),[f,p]=S.useState(!0),m=S.useCallback(async()=>{try{const[N,C]=await Promise.all([fetch("/api/scheduler/autoplugs/goals"),fetch("/api/scheduler/autoplugs/tracking")]);if(N.ok){const O=await N.json();n(O.goals||[])}if(C.ok){const O=await C.json();s(O.tracking||[])}}catch{}p(!1)},[]);S.useEffect(()=>{m()},[m]);const y=async N=>{(await fetch(`/api/scheduler/autoplugs/goals/${N.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!N.enabled})})).ok&&n(O=>O.map(T=>T.id===N.id?{...T,enabled:!T.enabled}:T))},b=async N=>{(await fetch(`/api/scheduler/autoplugs/goals/${N}`,{method:"DELETE"})).ok&&(n(O=>O.filter(T=>T.id!==N)),l(null))},v=async N=>{(await fetch(`/api/scheduler/autoplugs/tracking/${N}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipped:!0})})).ok&&s(O=>O.map(T=>T.id===N?{...T,skipped:!0}:T))},w=e.reduce((N,C)=>C.rule&&C.enabled?Math.min(N,C.rule.threshold):N,1/0),k=w===1/0?50:w;return u.jsxs("div",{className:"sidebar-schedule",children:[u.jsxs("div",{className:"sidebar-schedule-header",children:[u.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Autoplugs"}),u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!c),children:c?"Cancel":"+ Add"})]}),c&&u.jsx(ED,{onCreated:N=>{n(C=>[...C,N]),d(!1)}}),f?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"autoplug-section-header",children:"Goals"}),e.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No goals"}),u.jsx("div",{className:"schedule-empty-desc",children:"Create a goal to start autoplugging your tweets."})]}):e.map(N=>u.jsxs("div",{children:[u.jsxs("div",{className:"schedule-item",onClick:()=>l(i===N.id?null:N.id),children:[u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:N.name}),N.link&&u.jsx("div",{className:"autoplug-goal-summary",children:N.link}),u.jsxs("div",{className:"schedule-item-meta",children:[N.rule&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{children:[N.rule.threshold,"+ ",N.rule.metric]}),u.jsx("span",{children:N.rule.mode.toUpperCase()}),u.jsxs("span",{children:[N.rule.delay_minutes,"m delay"]})]}),u.jsxs("span",{children:[N.pool_count," pool msg",N.pool_count!==1?"s":""]})]})]}),u.jsx("button",{className:`autoplug-toggle ${N.enabled?"autoplug-toggle--on":"autoplug-toggle--off"}`,onClick:C=>{C.stopPropagation(),y(N)},title:N.enabled?"Disable":"Enable"})]}),i===N.id&&u.jsx(ND,{goal:N,onSaved:C=>{n(O=>O.map(T=>T.id===C.id?C:T))},onDeleted:()=>b(N.id),onRefresh:m})]},N.id)),u.jsx("div",{className:"autoplug-section-header",children:"Tracking"}),r.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No tracked tweets"}),u.jsx("div",{className:"schedule-empty-desc",children:"Tweets will appear here after posting."})]}):r.map(N=>u.jsxs("div",{className:"autoplug-tracking-item",children:[u.jsxs("div",{className:"autoplug-tracking-header",children:[u.jsx("div",{className:"autoplug-tracking-text",children:N.original_text||`Tweet ${N.tweet_id}`}),!N.triggered&&!N.skipped&&u.jsx("button",{className:"autoplug-tracking-skip",onClick:()=>v(N.id),title:"Skip autoplug for this tweet",children:"×"})]}),u.jsxs("div",{className:"autoplug-tracking-meta",children:[u.jsx("span",{children:CD(N.posted_at)}),u.jsxs("span",{children:[N.likes," likes"]}),u.jsxs("span",{children:[N.retweets," RTs"]}),N.views>0&&u.jsxs("span",{children:[_D(N.views)," views"]}),u.jsx("span",{children:N.source})]}),N.triggered?u.jsxs("div",{className:"autoplug-tracking-triggered",children:[u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Autoplugged ",N.goal_name?`→ ${N.goal_name}`:""]}):N.skipped?u.jsx("div",{style:{fontSize:"10px",color:"var(--sidebar-text-secondary)",opacity:.6},children:"Skipped"}):u.jsx("div",{className:"autoplug-tracking-bar",children:u.jsx("div",{className:"autoplug-tracking-bar-fill",style:{width:`${Math.min(100,N.likes/k*100)}%`}})})]},N.id))]})]})}function ED({onCreated:t}){const[e,n]=S.useState(""),[r,s]=S.useState(""),[i,l]=S.useState(""),[c,d]=S.useState("likes"),[f,p]=S.useState(50),[m,y]=S.useState(30),[b,v]=S.useState("static"),[w,k]=S.useState(!1),N=async()=>{if(e.trim()){k(!0);try{const C=await fetch("/api/scheduler/autoplugs/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.trim(),link:r.trim()||null,description:i.trim()||null})});if(!C.ok){k(!1);return}const{goal:O}=await C.json();await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:O.id,metric:c,threshold:f,delay_minutes:m,mode:b})});const T=await fetch("/api/scheduler/autoplugs/goals");if(T.ok){const R=((await T.json()).goals||[]).find(D=>D.id===O.id);if(R){t(R);return}}t({...O,rule_count:1,pool_count:0,rule:{metric:c,threshold:f,delay_minutes:m,mode:b,id:""}})}finally{k(!1)}}};return u.jsxs("div",{className:"autoplug-editor",children:[u.jsxs("label",{children:["Name",u.jsx("input",{value:e,onChange:C=>n(C.target.value),placeholder:"Newsletter, Course..."})]}),u.jsxs("label",{children:["Link",u.jsx("input",{value:r,onChange:C=>s(C.target.value),placeholder:"https://..."})]}),u.jsxs("label",{children:["Description (context for LLM)",u.jsx("textarea",{value:i,onChange:C=>l(C.target.value),placeholder:"Weekly engineering insights...",rows:2})]}),u.jsxs("div",{className:"autoplug-editor-row",children:[u.jsx("input",{type:"number",value:f,onChange:C=>p(Number(C.target.value)),min:1}),u.jsxs("select",{value:c,onChange:C=>d(C.target.value),children:[u.jsx("option",{value:"likes",children:"likes"}),u.jsx("option",{value:"retweets",children:"retweets"}),u.jsx("option",{value:"views",children:"views"})]}),u.jsx("span",{style:{fontSize:"11px",color:"var(--sidebar-text-secondary)"},children:"wait"}),u.jsx("input",{type:"number",value:m,onChange:C=>y(Number(C.target.value)),min:0,style:{width:"50px"}}),u.jsx("span",{style:{fontSize:"11px",color:"var(--sidebar-text-secondary)"},children:"min"})]}),u.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(C=>u.jsx("button",{className:b===C?"active":"",onClick:()=>v(C),children:C==="llm"?"LLM":C.charAt(0).toUpperCase()+C.slice(1)},C))}),u.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active",onClick:N,disabled:w||!e.trim(),style:{width:"100%"},children:w?"Creating...":"Create Goal"})]})}function ND({goal:t,onSaved:e,onDeleted:n,onRefresh:r}){var Y,X,J,q;const[s,i]=S.useState(t.name),[l,c]=S.useState(t.link||""),[d,f]=S.useState(t.description||""),[p,m]=S.useState(((Y=t.rule)==null?void 0:Y.metric)||"likes"),[y,b]=S.useState(((X=t.rule)==null?void 0:X.threshold)||50),[v,w]=S.useState(((J=t.rule)==null?void 0:J.delay_minutes)||30),[k,N]=S.useState(((q=t.rule)==null?void 0:q.mode)||"static"),[C,O]=S.useState([]),[T,_]=S.useState(""),[R,D]=S.useState(!1);S.useEffect(()=>{fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`).then(H=>H.json()).then(H=>O(H.pool||[])).catch(()=>{})},[t.id]);const z=async()=>{var H;D(!0);try{await fetch(`/api/scheduler/autoplugs/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,link:l||null,description:d||null})}),(H=t.rule)!=null&&H.id?await fetch(`/api/scheduler/autoplugs/rules/${t.rule.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metric:p,threshold:y,delay_minutes:v,mode:k})}):await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:t.id,metric:p,threshold:y,delay_minutes:v,mode:k})}),r()}finally{D(!1)}},$=async()=>{if(!T.trim())return;const H=await fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:T.trim()})});if(H.ok){const W=await H.json();O(re=>[...re,W.message]),_("")}},U=async H=>{(await fetch(`/api/scheduler/autoplugs/pool/${H}`,{method:"DELETE"})).ok&&O(re=>re.filter(V=>V.id!==H))};return u.jsxs("div",{className:"autoplug-editor",children:[u.jsxs("label",{children:["Name",u.jsx("input",{value:s,onChange:H=>i(H.target.value)})]}),u.jsxs("label",{children:["Link",u.jsx("input",{value:l,onChange:H=>c(H.target.value),placeholder:"https://..."})]}),u.jsxs("label",{children:["Description",u.jsx("textarea",{value:d,onChange:H=>f(H.target.value),rows:2})]}),u.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--sidebar-text-secondary)",textTransform:"uppercase",letterSpacing:"0.3px"},children:"Trigger"}),u.jsxs("div",{className:"autoplug-editor-row",children:[u.jsx("input",{type:"number",value:y,onChange:H=>b(Number(H.target.value)),min:1}),u.jsxs("select",{value:p,onChange:H=>m(H.target.value),children:[u.jsx("option",{value:"likes",children:"likes"}),u.jsx("option",{value:"retweets",children:"retweets"}),u.jsx("option",{value:"views",children:"views"})]}),u.jsx("span",{style:{fontSize:"11px",color:"var(--sidebar-text-secondary)"},children:"wait"}),u.jsx("input",{type:"number",value:v,onChange:H=>w(Number(H.target.value)),min:0,style:{width:"50px"}}),u.jsx("span",{style:{fontSize:"11px",color:"var(--sidebar-text-secondary)"},children:"min"})]}),u.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(H=>u.jsx("button",{className:k===H?"active":"",onClick:()=>N(H),children:H==="llm"?"LLM":H.charAt(0).toUpperCase()+H.slice(1)},H))}),u.jsxs("div",{className:"autoplug-pool-section",children:[u.jsx("div",{className:"autoplug-pool-label",children:"Static Pool"}),C.map(H=>u.jsxs("div",{className:"autoplug-pool-item",children:[u.jsx("span",{children:H.content}),u.jsx("button",{onClick:()=>U(H.id),title:"Remove",children:"×"})]},H.id)),u.jsxs("div",{className:"autoplug-pool-add",children:[u.jsx("input",{value:T,onChange:H=>_(H.target.value),placeholder:"Add message... (use {{link}} for link)",onKeyDown:H=>H.key==="Enter"&&$()}),u.jsx("button",{onClick:$,children:"+"})]})]}),(k==="llm"||k==="hybrid")&&u.jsx("div",{style:{fontSize:"11px",color:"var(--sidebar-text-secondary)",padding:"4px 0"},children:"LLM mode uses Author's Voice to generate contextual replies referencing the original tweet."}),u.jsxs("div",{className:"autoplug-editor-actions",children:[u.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active",onClick:z,disabled:R,children:R?"Saving...":"Save"}),u.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:n,children:"Delete"})]})]})}function CD(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/6e4);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function _D(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function TD({onBack:t}){const[e,n]=S.useState([]),[r,s]=S.useState([]),[i,l]=S.useState(!1),[c,d]=S.useState(!1),[f,p]=S.useState(null),[m,y]=S.useState(!0),b=S.useCallback(async()=>{try{const[k,N]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots"),fetch("/api/scheduler/sync",{method:"POST"})]);if(k.ok){const C=await k.json();n(C.items||[])}if(N.ok){const C=await N.json();s(C.slots||[])}}catch{}y(!1)},[]);S.useEffect(()=>{b()},[b]);const v=async k=>{(await fetch(`/api/scheduler/queue/${k}`,{method:"DELETE"})).ok&&(n(C=>C.filter(O=>O.id!==k)),p(null))};if(c)return u.jsx(SD,{onBack:()=>{d(!1),b()}});if(i)return u.jsx(wD,{slots:r,onBack:()=>{l(!1),b()}});const w=MD(r,e);return u.jsxs("div",{className:"sidebar-schedule",children:[u.jsxs("div",{className:"sidebar-schedule-header",children:[u.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back to documents",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Schedule"}),u.jsxs("div",{className:"sidebar-schedule-actions",children:[u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!0),title:"Autoplugs",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}),u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>l(!0),title:"Manage slots",children:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),m?null:r.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No time slots"}),u.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):w.map(({label:k,entries:N})=>u.jsxs("div",{className:"schedule-day",children:[u.jsx("div",{className:"schedule-day-header",children:k}),N.map((C,O)=>{var T,_,R,D,z;return C.type==="empty"?u.jsxs("div",{className:"schedule-slot-empty",children:[u.jsx("div",{className:"schedule-item-time",children:k0(C.time)}),u.jsx("div",{className:"schedule-slot-empty-label",children:((T=C.slot)==null?void 0:T.filter_type)==="any"?"Open slot":`${(_=C.slot)==null?void 0:_.filter_type}: ${((R=C.slot)==null?void 0:R.filter_value)||"any"}`})]},`empty-${O}`):u.jsxs("div",{children:[u.jsxs("div",{className:"schedule-item",onClick:()=>p(f===C.item.id?null:C.item.id),children:[u.jsx("div",{className:"schedule-item-time",children:k0(C.time)}),u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:((D=C.item.content)==null?void 0:D.text)||JSON.stringify(C.item.content)}),u.jsxs("div",{className:"schedule-item-meta",children:[u.jsx("span",{className:`schedule-item-status schedule-item-status--${C.item.status}`}),u.jsx("span",{children:C.item.status}),C.item.connection_name&&u.jsx("span",{children:C.item.connection_name}),C.item.provider&&u.jsx("span",{children:C.item.provider})]})]})]}),f===C.item.id&&u.jsxs("div",{className:"schedule-item-expanded",children:[u.jsx("div",{className:"schedule-item-full-text",children:((z=C.item.content)==null?void 0:z.text)||JSON.stringify(C.item.content,null,2)}),u.jsx("div",{className:"schedule-item-actions",children:u.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>v(C.item.id),children:"Cancel"})})]})]},C.item.id)})]},k))]})}function MD(t,e){const n=new Date,r=[];for(let c=0;c<7;c++){const d=new Date(n);d.setDate(d.getDate()+c),d.setHours(0,0,0,0);let f;c===0?f="Today":c===1?f="Tomorrow":f=d.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),r.push({label:f,date:d})}const s=new Map;for(const c of e){const d=new Date(c.scheduled_at),f=`${d.getFullYear()}-${d.getMonth()}-${d.getDate()}-${d.getHours()}-${d.getMinutes()}`;s.set(f,c)}const i=new Set,l=[];for(const{label:c,date:d}of r){const f=[],p=d.getDay(),y=["sun","mon","tue","wed","thu","fri","sat"][p];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(d);if(N.setHours(w,k,0,0),w0(d,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);w0(v,d)&&(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 w0(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function k0(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function AD({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:l}){const[c,d]=S.useState(!1),[f,p]=S.useState(!1),[m,y]=S.useState(""),[b,v]=S.useState(null),w=S.useRef(null),k=S.useRef(null);S.useEffect(()=>{if(!c)return;const C=O=>{w.current&&!w.current.contains(O.target)&&(d(!1),p(!1),y(""),v(null))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[c]),S.useEffect(()=>{f&&k.current&&k.current.focus()},[f]);const N=()=>{const C=m.trim();C&&(s(C),y(""),p(!1))};return u.jsxs("div",{className:"sidebar-profile-wrapper",ref:w,children:[u.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>d(!c),title:`Profile: ${e}`,children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"8",r:"4"}),u.jsx("path",{d:"M5.5 21a8.38 8.38 0 0 1 13 0"})]})}),c&&u.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(C=>u.jsxs("div",{className:"sidebar-profile-row",children:[b===C?u.jsxs("div",{className:"sidebar-profile-confirm",children:[u.jsx("span",{children:"Delete?"}),u.jsxs("div",{className:"sidebar-inline-confirm",children:[u.jsx("button",{onClick:()=>{i(C),v(null)},children:"Yes"}),u.jsx("button",{onClick:()=>v(null),children:"No"})]})]}):u.jsx(u.Fragment,{children:u.jsxs("button",{className:`sidebar-profile-option ${C===e?"active":""}`,onClick:()=>{C!==e&&r(C),d(!1)},children:[u.jsx("span",{className:"sidebar-profile-check",children:C===e?"✓":""}),u.jsx("span",{children:C})]})}),C!=="Default"&&C!==e&&b!==C&&u.jsx("button",{className:"sidebar-profile-delete-btn",onClick:O=>{O.stopPropagation(),v(C)},title:"Delete profile",children:"×"})]},C)),n.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"sidebar-profile-divider"}),u.jsx("div",{className:"sidebar-profile-trash-label",children:"Trash"}),n.map(C=>u.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[u.jsx("span",{className:"sidebar-profile-trash-name",children:C}),u.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>l(C),children:"Restore"})]},C))]}),u.jsx("div",{className:"sidebar-profile-divider"}),f?u.jsx("div",{className:"sidebar-profile-add-input",children:u.jsx("input",{ref:k,type:"text",value:m,onChange:C=>y(C.target.value),onKeyDown:C=>{C.key==="Enter"&&N(),C.key==="Escape"&&(p(!1),y(""))},placeholder:"Profile name..."})}):u.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>p(!0),children:[u.jsx("span",{className:"sidebar-profile-check",children:"+"}),u.jsx("span",{children:"New Profile"})]})]})]})}const OD=[{id:"full",label:"Full",lines:3},{id:"compact",label:"Compact",lines:2},{id:"minimal",label:"Minimal",lines:1}];function RD(){const[t,e]=S.useState(!1),[n,r]=S.useState(H0),s=S.useRef(null);S.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),TE(l),e(!1)};return u.jsxs("div",{className:"sidebar-density-wrapper",ref:s,children:[u.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>e(!t),title:"Card density",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("path",{d:"M21 9H3"}),u.jsx("path",{d:"M21 15H3"})]})}),t&&u.jsx("div",{className:"sidebar-density-dropdown",children:OD.map(l=>u.jsxs("button",{className:`sidebar-density-option ${n===l.id?"active":""}`,onClick:()=>i(l.id),children:[u.jsx("span",{className:"sidebar-density-icon",children:Array.from({length:l.lines},(c,d)=>u.jsx("span",{className:"sidebar-density-line"},d))}),u.jsx("span",{children:l.label})]},l.id))})]})}function S0({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,workspacesRefreshKey:s,pendingDocs:i,writingTitle:l,writingTarget:c,onClose:d}){const{docs:f,workspaces:p,assignedFiles:m,fetchDocs:y,scrollRef:b}=sD(r,s),v=iD(p,y,r),w=$u(),[k,N]=S.useState(!1),[C,O]=S.useState([]),[T,_]=S.useState("Default"),R=S.useCallback(async()=>{try{const oe=await fetch("/api/profiles");if(oe.ok){const he=await oe.json();O(he.profiles),_(he.active)}}catch{}},[]);S.useEffect(()=>{R()},[R]);const D=S.useCallback(async oe=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:oe})})).ok&&(_(oe),R())}catch{}},[R]),z=S.useCallback(async oe=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:oe})})).ok&&R()}catch{}},[R]),[$,U]=S.useState([]),Y=S.useCallback(async()=>{try{const oe=await fetch("/api/profiles/trash");if(oe.ok){const he=await oe.json();U(he.profiles)}}catch{}},[]);S.useEffect(()=>{Y()},[Y]);const X=S.useCallback(async oe=>{try{(await fetch(`/api/profiles/${encodeURIComponent(oe)}`,{method:"DELETE"})).ok&&(R(),Y())}catch{}},[R,Y]),J=S.useCallback(async oe=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:oe})})).ok&&(R(),Y())}catch{}},[R,Y]),[q,H]=S.useState(""),[W,re]=S.useState(null),V=S.useRef(),K=S.useRef(null),B=S.useCallback(oe=>{if(H(oe),V.current&&clearTimeout(V.current),!oe.trim()){re(null);return}V.current=setTimeout(async()=>{try{const he=await fetch(`/api/documents/search?q=${encodeURIComponent(oe.trim())}&archived=true`);he.ok&&re(await he.json())}catch{}},250)},[]);S.useEffect(()=>()=>{V.current&&clearTimeout(V.current)},[]);const A={docs:f,archivedDocs:[],workspaces:p,assignedFiles:m,pendingDocs:i,writingTitle:l,writingTarget:c,onSwitchDocument:e,onCreateDocument:n,actions:v,scrollRef:b,searchQuery:q,searchResults:W,onSearchChange:B},L=()=>{switch(w){case"timeline":return u.jsx(mD,{...A});case"board":return u.jsx(gD,{...A});case"shelf":return u.jsx(yD,{...A});default:return u.jsx(pD,{...A})}},te=u.jsxs("div",{className:"sidebar-search",children:[u.jsxs("svg",{className:"sidebar-search-icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"10.5",cy:"10.5",r:"7"}),u.jsx("path",{d:"m20 20-4.5-4.5"})]}),u.jsx("input",{ref:K,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:q,onChange:oe=>B(oe.target.value)}),q&&u.jsx("button",{className:"sidebar-search-clear",onClick:()=>B(""),title:"Clear search",children:"×"})]});return w==="board"?u.jsx("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,children:L()}):u.jsxs("div",{className:`sidebar ${t?"open":""}`,children:[u.jsxs("div",{className:"sidebar-topbar",children:[u.jsxs("div",{className:"sidebar-logo",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.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"}),u.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),u.jsxs("div",{className:"sidebar-topbar-actions",children:[u.jsx(AD,{profiles:C,activeProfile:T,trashedProfiles:$,onSwitch:D,onCreate:z,onDelete:X,onRestore:J}),u.jsx("button",{className:`sidebar-collapse-btn${k?" sidebar-collapse-btn--active":""}`,onClick:()=>N(!k),title:"Schedule",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("line",{x1:"16",x2:"16",y1:"1",y2:"5"}),u.jsx("line",{x1:"8",x2:"8",y1:"1",y2:"5"}),u.jsx("line",{x1:"3",x2:"21",y1:"9",y2:"9"})]})}),u.jsx(RD,{}),d&&u.jsx("button",{className:"sidebar-collapse-btn",onClick:d,title:"Close sidebar",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),k?u.jsx(TD,{onBack:()=>N(!1)}):u.jsxs(u.Fragment,{children:[te,L()]})]})}function jD({onClose:t,onSetupComplete:e}){const[n,r]=S.useState("detecting"),[s,i]=S.useState(null),[l,c]=S.useState("gh"),[d,f]=S.useState("openwriter-docs"),[p,m]=S.useState(!0),[y,b]=S.useState(""),[v,w]=S.useState(""),[k,N]=S.useState(""),[C,O]=S.useState("");S.useEffect(()=>{fetch("/api/sync/capabilities").then(_=>_.json()).then(_=>{i(_),_.ghAuthenticated?c("gh"):(_.gitInstalled,c("pat")),r("setup")}).catch(()=>{N("Failed to detect git capabilities"),r("error")})},[]);const T=S.useCallback(async()=>{r("progress"),O(l==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const _={method:l,repoName:d,isPrivate:p};l==="pat"&&(_.pat=y),l==="connect"&&(_.remoteUrl=v,_.pat=y||void 0);const R=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!R.ok){const D=await R.json().catch(()=>({}));throw new Error(D.error||`Setup failed (${R.status})`)}r("done"),e()}catch(_){N(_.message),r("error")}},[l,d,p,y,v,e]);return u.jsx("div",{className:"sync-modal-overlay",onClick:t,children:u.jsxs("div",{className:"sync-modal",onClick:_=>_.stopPropagation(),children:[u.jsxs("div",{className:"sync-modal-header",children:[u.jsx("h2",{children:"Sync to GitHub"}),u.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-spinner"}),u.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&s&&u.jsxs("div",{className:"sync-modal-body",children:[!s.gitInstalled&&u.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",u.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),s.gitInstalled&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"sync-tabs",children:[s.ghAuthenticated&&u.jsx("button",{className:`sync-tab${l==="gh"?" active":""}`,onClick:()=>c("gh"),children:"GitHub CLI"}),u.jsx("button",{className:`sync-tab${l==="pat"?" active":""}`,onClick:()=>c("pat"),children:"Personal Access Token"}),u.jsx("button",{className:`sync-tab${l==="connect"?" active":""}`,onClick:()=>c("connect"),children:"Connect Existing"})]}),l==="gh"&&u.jsxs("div",{className:"sync-form",children:[u.jsxs("label",{children:["Repository name",u.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),u.jsxs("label",{className:"sync-checkbox",children:[u.jsx("input",{type:"checkbox",checked:p,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),l==="pat"&&u.jsxs("div",{className:"sync-form",children:[!s.ghAuthenticated&&!s.ghInstalled&&u.jsxs("p",{className:"sync-hint",children:["Create a ",u.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",u.jsx("code",{children:"repo"})," scope."]}),u.jsxs("label",{children:["Personal Access Token",u.jsx("input",{type:"password",value:y,onChange:_=>b(_.target.value),placeholder:"ghp_..."})]}),u.jsxs("label",{children:["Repository name",u.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),u.jsxs("label",{className:"sync-checkbox",children:[u.jsx("input",{type:"checkbox",checked:p,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),l==="connect"&&u.jsxs("div",{className:"sync-form",children:[u.jsxs("label",{children:["Remote URL",u.jsx("input",{type:"text",value:v,onChange:_=>w(_.target.value),placeholder:"https://github.com/user/repo.git"})]}),u.jsxs("label",{children:["PAT (optional, for private repos)",u.jsx("input",{type:"password",value:y,onChange:_=>b(_.target.value),placeholder:"ghp_..."})]})]}),u.jsxs("div",{className:"sync-modal-actions",children:[u.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),u.jsx("button",{className:"sync-btn primary",onClick:T,disabled:l==="pat"&&!y||l==="connect"&&!v||l!=="connect"&&!d,children:l==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-spinner"}),u.jsx("p",{children:C})]}),n==="done"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-success-icon",children:"✓"}),u.jsx("p",{children:"Successfully synced to GitHub!"}),u.jsx("div",{className:"sync-modal-actions",children:u.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-error-msg",children:k}),u.jsxs("div",{className:"sync-modal-actions",children:[u.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),u.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function ID({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentsChanged:r,onWorkspacesChanged:s,onTitleChanged:i,onPendingDocsChanged:l,onMetadataChanged:c,onSyncStatus:d,onWritingStarted:f,onWritingFinished:p,getEditorState:m}){const y=S.useRef(null),[b,v]=S.useState(!1),w=S.useRef(t),k=S.useRef(e),N=S.useRef(n),C=S.useRef(r),O=S.useRef(s),T=S.useRef(i),_=S.useRef(l),R=S.useRef(d),D=S.useRef(c),z=S.useRef(f),$=S.useRef(p),U=S.useRef(m);w.current=t,k.current=e,N.current=n,C.current=r,O.current=s,T.current=i,_.current=l,D.current=c,R.current=d,z.current=f,$.current=p,U.current=m,S.useEffect(()=>{const J=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let q,H=!1,W=1e3;function re(){const K=new WebSocket(J);y.current=K,K.onopen=()=>{v(!0),W=1e3,H&&K.send(JSON.stringify({type:"request-document"})),H=!0},K.onmessage=B=>{var A,L,te,oe,he,ne,ge,De,ot,ce,pe;try{const se=JSON.parse(B.data);se.type==="node-changes"&&se.changes&&((A=w.current)==null||A.call(w,se.changes)),se.type==="agent-status"&&((L=k.current)==null||L.call(k,!!se.agentConnected)),se.type==="document-switched"&&((te=N.current)==null||te.call(N,{document:se.document,title:se.title,filename:se.filename,docId:se.docId,metadata:se.metadata})),se.type==="metadata-changed"&&se.metadata&&((oe=D.current)==null||oe.call(D,se.metadata)),se.type==="documents-changed"&&((he=C.current)==null||he.call(C)),se.type==="workspaces-changed"&&((ne=O.current)==null||ne.call(O)),se.type==="title-changed"&&se.title&&((ge=T.current)==null||ge.call(T,se.title)),se.type==="pending-docs-changed"&&se.pendingDocs&&((De=_.current)==null||De.call(_,se.pendingDocs)),se.type==="sync-status"&&((ot=R.current)==null||ot.call(R,{state:se.state,lastSyncTime:se.lastSyncTime,pendingFiles:se.pendingFiles,error:se.error})),se.type==="writing-started"&&se.title&&((ce=z.current)==null||ce.call(z,se.title,se.target||null)),se.type==="writing-finished"&&((pe=$.current)==null||pe.call($)),se.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),se.type==="marks-changed"&&se.filename&&window.dispatchEvent(new CustomEvent("ow-marks-changed",{detail:{filename:se.filename}}))}catch{}},K.onclose=()=>{v(!1),q=setTimeout(re,W),W=Math.min(W*1.5,8e3)},K.onerror=()=>{K.close()}}re();function V(){var K;document.visibilityState==="visible"&&((K=y.current)==null?void 0:K.readyState)!==WebSocket.OPEN&&(clearTimeout(q),W=1e3,re())}return document.addEventListener("visibilitychange",V),()=>{var K;clearTimeout(q),document.removeEventListener("visibilitychange",V),(K=y.current)==null||K.close()}},[]);const Y=S.useCallback(X=>{var J;((J=y.current)==null?void 0:J.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify(X))},[]);return{connected:b,sendMessage:Y}}function LD(t){const[e,n]=S.useState(null),[r,s]=S.useState(!1),[i,l]=S.useState(null),c=S.useRef(void 0);return S.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(d=>d.ok?d.json():d.json().then(f=>Promise.reject(new Error(f.error||`HTTP ${d.status}`)))).then(d=>{n(d),s(!1)}).catch(d=>{l(d.message),s(!1)}))},[t]),{tweet:e,loading:r,error:i}}function DD(t){var r;const e=t.view.dom,n=[];for(const s of e.children){const i=(r=s.innerText)==null?void 0:r.trim();i&&n.push(i)}return n.join(`
|
|
206
|
-
|
|
207
|
-
`)}function PD(t){const e=n=>{var r;if(n.type==="image"&&((r=n.attrs)!=null&&r.src))return n.attrs.src;if(n.content)for(const s of n.content){const i=e(s);if(i)return i}return null};return e(t.getJSON())}async function BD(t){try{const e=await fetch(t);if(!e.ok)return null;const n=await e.blob();return n.type==="image/png"?n:new Promise(r=>{const s=new Image,i=URL.createObjectURL(n);s.onload=()=>{const l=document.createElement("canvas");l.width=s.naturalWidth,l.height=s.naturalHeight,l.getContext("2d").drawImage(s,0,0),l.toBlob(c=>{URL.revokeObjectURL(i),r(c)},"image/png")},s.onerror=()=>{URL.revokeObjectURL(i),r(null)},s.src=i})}catch{return null}}function zD(t,e){const[n,r]=S.useState("idle"),s=S.useRef();return{copyText:S.useCallback(async()=>{const l=t.current[e];if(!l)return;const c=DD(l),d=PD(l);if(!(!c&&!d)){try{const f={};if(c&&(f["text/plain"]=new Blob([c],{type:"text/plain"})),d){const p=await BD(d);p&&(f["image/png"]=p)}Object.keys(f).length>0&&await navigator.clipboard.write([new ClipboardItem(f)])}catch{if(c){const f=document.createElement("textarea");f.value=c,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select(),document.execCommand("copy"),document.body.removeChild(f)}}r("copied"),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r("idle"),2e3)}},[t,e]),copyState:n}}function Oh(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 $D(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 FD=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.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"})}),UD=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.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"})}),HD=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.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"})}),WD=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.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"})}),VD=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.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 B1({tweet:t,nested:e,url:n}){const r=$D(t.createdAt);return u.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:[u.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?u.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):u.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),u.jsxs("div",{className:"tweet-author-info",children:[u.jsx("span",{className:"tweet-author-name",children:t.author.name}),u.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),r&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"tweet-author-separator",children:"·"}),u.jsx("span",{className:"tweet-author-timestamp",children:r})]})]})]}),u.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&u.jsx("div",{className:"tweet-media",children:t.media.map((s,i)=>s.type==="photo"?u.jsx("img",{className:"tweet-media-img",src:s.url,alt:"",loading:"lazy"},i):s.type==="video"||s.type==="gif"?u.jsx("div",{className:"tweet-media-video-placeholder",children:u.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&u.jsx(B1,{tweet:t.quoteTweet,nested:!0}),!e&&u.jsxs("div",{className:"tweet-actions-row",children:[u.jsxs("span",{className:"tweet-action tweet-action-reply",children:[u.jsx(FD,{}),t.metrics.replies>0&&Oh(t.metrics.replies)]}),u.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[u.jsx(UD,{}),t.metrics.retweets>0&&Oh(t.metrics.retweets)]}),u.jsxs("span",{className:"tweet-action tweet-action-like",children:[u.jsx(HD,{}),t.metrics.likes>0&&Oh(t.metrics.likes)]}),u.jsx("span",{className:"tweet-action tweet-action-bookmark",children:u.jsx(WD,{})}),u.jsx("span",{className:"tweet-action tweet-action-share",children:u.jsx(VD,{})})]})]})}function KD({tweet:t,url:e}){return u.jsx(B1,{tweet:t,url:e})}function GD({initialContent:t,placeholder:e="What is happening?!",onUpdate:n,onReady:r,onFocus:s}){const i=sk({extensions:[...y1,td.configure({placeholder:e})],content:t||"<p></p>",onUpdate:({editor:l})=>{n==null||n(l)},onFocus:()=>{s==null||s()},editorProps:{handlePaste:N1,handleDrop:C1}},[t]);return S.useEffect(()=>{if(!i)return;const{state:l}=i.view;if(l.plugins.some(f=>f.key==="pendingDecoration$"))return;const c=k1(),d=l.reconfigure({plugins:[...l.plugins,c]});i.view.updateState(d)},[i]),S.useEffect(()=>{if(!i)return;const{state:l}=i.view;if(l.plugins.some(f=>f.key==="markDecoration$"))return;const c=S1(),d=l.reconfigure({plugins:[...l.plugins,c]});i.view.updateState(d)},[i]),S.useEffect(()=>{i&&(r==null||r(i))},[i,r]),i?u.jsx(Qp,{editor:i}):null}function qD({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),s=n<=20,i=s?30:26,l=2,c=(i-l)/2,d=2*Math.PI*c,f=d*(1-r);let p="var(--x-blue, #1d9bf0)";return n<=0?p="var(--x-red, #f4212e)":n<=20&&(p="var(--x-yellow, #ffd400)"),t===0?null:u.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:i,height:i},children:[u.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[u.jsx("circle",{cx:i/2,cy:i/2,r:c,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:l}),u.jsx("circle",{cx:i/2,cy:i/2,r:c,fill:"none",stroke:p,strokeWidth:l,strokeDasharray:d,strokeDashoffset:f,strokeLinecap:"round",transform:`rotate(-90 ${i/2} ${i/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),s&&u.jsx("span",{className:"tweet-char-number",style:{color:p,fontSize:n<-9||n>9?10:11},children:n})]})}const E0="@openwriter/plugin-x-api",N0=[{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]=S.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=S.useState(!1),[l,c]=S.useState(""),d=N0.every(p=>n[p.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:E0,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:E0})})).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(p){c(p.message||"Connection failed")}finally{i(!1)}};return u.jsxs("div",{className:"x-connect-prompt",children:[u.jsxs("div",{className:"x-connect-header",children:[u.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),u.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:u.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:u.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"})})})]}),u.jsx("div",{className:"x-connect-fields",children:N0.map(p=>u.jsxs("div",{className:"x-connect-field",children:[u.jsx("label",{className:"x-connect-label",children:p.label}),u.jsx("input",{type:"password",className:"x-connect-input",value:n[p.key],onChange:m=>r(y=>({...y,[p.key]:m.target.value})),placeholder:p.env,spellCheck:!1,autoComplete:"off"})]},p.key))}),l&&u.jsx("div",{className:"x-connect-error",children:l}),u.jsxs("div",{className:"x-connect-actions",children:[u.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),u.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!d||s,children:s?"Connecting...":"Connect"})]})]})}const C0="ow-x-handle";function YD(){const[t,e]=S.useState(()=>localStorage.getItem(C0)||""),[n,r]=S.useState(!1),[s,i]=S.useState(""),l=S.useRef(null),c=S.useRef(null),d=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(C0,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=l.current)==null?void 0:m.focus()},0)};S.useEffect(()=>{if(!n)return;const m=y=>{c.current&&!c.current.contains(y.target)&&d()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n,s]);const p=t?`https://unavatar.io/twitter/${t}`:"";return u.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:c,children:[t?u.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:p,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):u.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&u.jsx("div",{className:"tweet-handle-popover",children:u.jsx("input",{ref:l,className:"tweet-handle-input",value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&d(),m.key==="Escape"&&r(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function _0(){return u.jsxs("div",{className:"tweet-skeleton",children:[u.jsxs("div",{className:"tweet-author-row",children:[u.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),u.jsxs("div",{className:"tweet-author-info",children:[u.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),u.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),u.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),u.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function QD(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function T0(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 Rh(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 jh(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tweetContext:t}),keepalive:!0}).catch(()=>{})}function XD({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s,filename:i,title:l}){const{tweet:c,loading:d,error:f}=LD(t==null?void 0:t.url),[p,m]=S.useState(()=>T0(e)),[y,b]=S.useState(0),v=S.useRef([]),w=S.useRef(null),k=S.useRef(!0),N=S.useRef(!1),C=S.useRef(p.length),[O,T]=S.useState(()=>p.map(()=>0)),[_,R]=S.useState(0),[D,z]=S.useState(0),[$,U]=S.useState(null),[Y,X]=S.useState(),[J,q]=S.useState(!1),[H,W]=S.useState("idle"),[re,V]=S.useState(""),K=S.useRef(),{copyText:B,copyState:A}=zD(v,_),[L,te]=S.useState(!1);S.useEffect(()=>{let ke=!1;return(async()=>{try{const fe=await fetch("/api/x/status");if(ke)return;if(fe.ok){const qe=await fe.json();U(qe.connected),X(qe.username)}else U(!1)}catch{ke||U(!1)}})(),()=>{ke=!0}},[]),S.useEffect(()=>{if(k.current){k.current=!1;return}if(!e||JSON.stringify(e)===w.current)return;const fe=T0(e);N.current=!0,C.current=fe.length,v.current=[],m(fe),T(fe.map(()=>0)),b(qe=>qe+1)},[e]);const oe=S.useCallback((ke,fe)=>{if(v.current[ke]=fe,T(at=>{const it=[...at];return it[ke]=fe.getText().length,it}),N.current)return;const qe=Rh(v.current);w.current=JSON.stringify(qe),n==null||n(qe)},[n]),he=S.useCallback((ke,fe)=>{if(v.current[ke]=fe,T(qe=>{const at=[...qe];return at[ke]=fe.getText().length,at}),z(qe=>qe+1),N.current&&v.current.filter(Boolean).length>=C.current){N.current=!1;const at=Rh(v.current);w.current=JSON.stringify(at)}ke===0&&(r==null||r(fe)),s==null||s(v.current.filter(Boolean))},[r,s]),ne=p.length>1;O.reduce((ke,fe)=>ke+fe,0);const ge=S.useCallback(()=>{const ke=_+1;m(fe=>[...fe.slice(0,ke),"<p></p>",...fe.slice(ke)]),T(fe=>[...fe.slice(0,ke),0,...fe.slice(ke)]),R(ke)},[_]),De=S.useCallback(ke=>{ke!==0&&(v.current.splice(ke,1),m(fe=>fe.filter((qe,at)=>at!==ke)),T(fe=>fe.filter((qe,at)=>at!==ke)),setTimeout(()=>{const fe=Rh(v.current);n==null||n(fe),s==null||s(v.current.filter(Boolean))},0))},[n,s]),ot=!!(t!=null&&t.url),ce=(t==null?void 0:t.mode)==="reply",pe=v.current.filter(Boolean).some(fe=>fe.getText().trim()||M0(fe).length>0),se=$&&pe&&H==="idle",Pe=async()=>{if(!$){q(!0);return}if(se){W("uploading"),V("");try{const ke=v.current.filter(Boolean),fe=[];for(const at of ke){const it=at.getText().trim(),mt=M0(at);if(!it&&mt.length===0)continue;const $t=[];for(const Lt of mt){const We=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:Lt})})).json();if(!We.success)throw new Error(We.error||"Image upload failed");$t.push(We.mediaId)}fe.push({text:it,mediaIds:$t})}if(fe.length===0)return;W("posting");const qe=QD(t==null?void 0:t.url);if(fe.length===1){const at={};fe[0].text&&(at.text=fe[0].text),fe[0].mediaIds.length>0&&(at.mediaIds=fe[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&qe?at.replyTo=qe:(t==null?void 0:t.mode)==="quote"&&qe&&(at.quoteTweetId=qe);const mt=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(at)})).json();mt.success?(jh({lastPost:{postedAt:new Date().toISOString(),tweetUrl:mt.tweetUrl}}),W("success"),K.current=setTimeout(()=>W("idle"),2500)):(console.error("[TweetCompose] Post error:",mt.error),V(mt.error||"Post failed"),W("error"),setTimeout(()=>W("idle"),3e3))}else{const it={tweets:fe.map(Lt=>({text:Lt.text,...Lt.mediaIds.length>0?{mediaIds:Lt.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&qe&&(it.replyTo=qe);const $t=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(it)})).json();$t.success?(jh({lastPost:{postedAt:new Date().toISOString(),tweetUrl:$t.threadUrl}}),W("success"),K.current=setTimeout(()=>W("idle"),2500)):(V($t.error||"Thread post failed"),W("error"),setTimeout(()=>W("idle"),3e3))}}catch(ke){V(ke.message||"Network error"),W("error"),setTimeout(()=>W("idle"),3e3)}}};S.useEffect(()=>()=>{K.current&&clearTimeout(K.current)},[]);const Oe=()=>{U(!0),q(!1),fetch("/api/x/status").then(ke=>ke.json()).then(ke=>{ke.username&&X(ke.username)}).catch(()=>{})},Je=H==="uploading"?"Uploading...":H==="posting"?"Posting...":H==="success"?"Posted!":H==="error"?"Failed":ne?_===0?"Post Thread":"Post All":"Post",Ne=p.map((ke,fe)=>fe===0?ce?"Post your reply":"What is happening?!":"Add another tweet"),et=ke=>{var fe;return u.jsxs("div",{className:`tweet-compose-footer${ke?" tweet-compose-footer--inline":""}`,children:[_===0&&((fe=t==null?void 0:t.lastPost)==null?void 0:fe.postedAt)&&u.jsxs("a",{className:"tweet-posted-status",href:t.lastPost.tweetUrl,target:"_blank",rel:"noopener noreferrer",title:t.lastPost.tweetUrl||"Posted to X",children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Posted ",new Date(t.lastPost.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," on X"]}),H==="error"&&re&&u.jsx("span",{className:"tweet-post-error",children:re}),u.jsx(qD,{count:O[_]||0}),u.jsx("button",{className:"tweet-thread-add",onClick:ge,title:"Add another tweet",children:u.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[u.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),u.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),u.jsx("button",{className:`tweet-copy-btn${A==="copied"?" tweet-copy-btn--copied":""}`,disabled:!pe,onClick:B,title:"Copy tweet text to clipboard",children:A==="copied"?u.jsxs(u.Fragment,{children:[u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 8.5L6.5 12L13 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied!"]}):u.jsxs(u.Fragment,{children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("rect",{x:"5.5",y:"2",width:"8.5",height:"10.5",rx:"1.5",stroke:"currentColor",strokeWidth:"1.5"}),u.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"]})}),_===0&&(()=>{var at;const qe=!!((at=t==null?void 0:t.lastPost)!=null&&at.postedAt);return u.jsx("button",{className:`tweet-mark-sent-btn${qe?" tweet-mark-sent-btn--done":""}`,onClick:()=>{qe||jh({lastPost:{postedAt:new Date().toISOString()}})},title:qe?"Posted":"Mark as manually posted",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:qe?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"8 12 11 15 16 9",stroke:qe?"#fff":"currentColor"})]})})})(),i&&u.jsx("button",{className:"tweet-schedule-btn",onClick:()=>te(!0),title:"Schedule post",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]})}),u.jsx("button",{className:`tweet-post-btn${se||!$&&$!==null?" tweet-post-btn--active":""}${H==="success"?" tweet-post-btn--success":""}${H==="error"?" tweet-post-btn--error":""}`,disabled:$?!se:!1,onClick:Pe,title:$?Y?`Post as @${Y}`:"Post to X":"Connect X to post",children:Je})]})},Le=ot&&!ce,He=()=>u.jsx("div",{className:"tweet-thread-editors",children:p.map((ke,fe)=>u.jsxs("div",{className:`tweet-thread-item${fe===_?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[u.jsxs("div",{className:"tweet-thread-item-left",children:[u.jsx(YD,{}),fe<p.length-1&&u.jsx("div",{className:"tweet-thread-line"})]}),u.jsxs("div",{className:"tweet-thread-item-right",children:[fe>0&&u.jsx("button",{className:"tweet-thread-remove",onClick:()=>De(fe),title:"Remove this tweet",children:"×"}),u.jsx("div",{className:`tweet-compose-box${fe===0&&!ne?" tweet-compose-box--standalone":""}`,children:u.jsx(GD,{initialContent:ke,placeholder:Ne[fe],onUpdate:qe=>oe(fe,qe),onReady:qe=>he(fe,qe),onFocus:()=>R(fe)})}),fe===_&&!Le&&et(fe<p.length-1)]})]},`${y}-${fe}`))});return u.jsxs("div",{className:"tweet-compose-wrapper",children:[ot&&ce&&u.jsxs(u.Fragment,{children:[d&&u.jsx("div",{className:"tweet-context-section",children:u.jsx(_0,{})}),f&&u.jsx("div",{className:"tweet-context-section",children:u.jsxs("div",{className:"tweet-embed-error",children:[u.jsx("span",{children:"Could not load tweet"}),u.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]})}),c&&u.jsx("div",{className:"tweet-reply-parent-section",children:u.jsxs("div",{className:"tweet-reply-thread",children:[u.jsxs("div",{className:"tweet-reply-thread-left",children:[c.author.avatarUrl?u.jsx("img",{className:"tweet-avatar",src:c.author.avatarUrl,alt:""}):u.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),u.jsx("div",{className:"tweet-reply-thread-line"})]}),u.jsxs("div",{className:"tweet-reply-thread-right",children:[u.jsxs("div",{className:"tweet-reply-parent",children:[u.jsxs("div",{className:"tweet-author-info",children:[u.jsx("span",{className:"tweet-author-name",children:c.author.name}),u.jsxs("span",{className:"tweet-author-handle",children:["@",c.author.username]})]}),u.jsx("div",{className:"tweet-text",children:c.text}),c.media&&c.media.length>0&&u.jsx("div",{className:"tweet-media",children:c.media.map((ke,fe)=>ke.type==="photo"?u.jsx("img",{className:"tweet-media-img",src:ke.url,alt:"",loading:"lazy"},fe):u.jsx("div",{className:"tweet-media-video-placeholder",children:u.jsx("span",{children:"Video"})},fe))})]}),u.jsxs("div",{className:"tweet-replying-to-inline",children:["Replying to ",u.jsxs("span",{className:"tweet-reply-handle",children:["@",c.author.username]})]})]})]})}),He()]}),Le&&u.jsxs(u.Fragment,{children:[He(),u.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[d&&u.jsx(_0,{}),f&&u.jsxs("div",{className:"tweet-embed-error",children:[u.jsx("span",{children:"Could not load tweet"}),u.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]}),c&&u.jsx(KD,{tweet:c,url:t==null?void 0:t.url})]}),u.jsx("div",{className:"tweet-quote-footer",children:et()})]}),!ot&&He(),J&&u.jsx(JD,{onConnected:Oe,onCancel:()=>q(!1)}),L&&i&&u.jsx(sd,{filename:i,title:l||"Untitled",onClose:()=>te(!1)})]})}function ZD(){const[t,e]=S.useState("idle"),n=S.useRef();return{copyAsHtml:S.useCallback(async()=>{const s=document.querySelector(".ProseMirror");if(!s)return;const i=s.cloneNode(!0);i.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(p=>p.remove());let l="";const c=document.querySelector(".article-title-input");c!=null&&c.value&&c.value!=="Untitled"&&(l+=`<h1>${c.value}</h1>
|
|
208
|
-
`);const d=l+i.innerHTML,f=eP(i);try{const p=new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})});await navigator.clipboard.write([p])}catch{try{await navigator.clipboard.writeText(f)}catch{const p=document.createElement("textarea");p.value=f,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function eP(t){var n;const e=[];for(const r of t.children){const s=(n=r.innerText)==null?void 0:n.trim();s&&e.push(s)}return e.join(`
|
|
209
|
-
|
|
210
|
-
`)}const Ih="ow-x-handle",A0="ow-x-name",tP=new Set(["Untitled","New Document","Article"]);function nP({src:t,coverImages:e}){const[n,r]=S.useState(t?"display":"empty"),[s,i]=S.useState(t||""),[l,c]=S.useState(e||(t?[t]:[])),[d,f]=S.useState(""),[p,m]=S.useState(""),y=S.useRef(null);S.useEffect(()=>{t?(i(t),r("display")):e&&e.length>0?(i(e[0]),r("display")):(i(""),r("empty"),f(""),m(""))},[t,e]),S.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const b=s?l.indexOf(s):-1,v=l.length,w=v>1,k=S.useCallback($=>{const U=l[$];U&&(i(U),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:U,coverImages:l}})}).catch(()=>{}))},[l]),N=S.useCallback(()=>{b>0&&k(b-1)},[b,k]),C=S.useCallback(()=>{b<v-1&&k(b+1)},[b,v,k]),O=S.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const U=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})})).json();if(U.success&&U.src){const Y=[...l,U.src];c(Y),i(U.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:U.src,coverImages:Y}})}).catch(()=>{})}else m(U.error||"Generation failed"),r("prompt")}catch($){m($.message||"Network error"),r("prompt")}}},[d,l]),T=$=>{$.key==="Enter"&&O(),$.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var $;return($=y.current)==null?void 0:$.focus()},0)},R=()=>{const $=l.filter(U=>U!==s);if(c($),$.length>0){const U=Math.min(b,$.length-1),Y=$[U];i(Y),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:Y,coverImages:$}})}).catch(()=>{})}else i(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},D=()=>{r("prompt"),setTimeout(()=>{var $;return($=y.current)==null?void 0:$.focus()},0)},z=()=>{const $=document.createElement("a");$.href=s,$.download=`cover-${b+1}.png`,$.click()};return n==="display"&&s?u.jsxs("div",{className:"article-cover article-cover--display",children:[u.jsx("img",{className:"article-cover-img",src:s,alt:"Cover"}),u.jsxs("div",{className:"article-cover-overlay",children:[w&&u.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:N,disabled:b<=0,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"15 18 9 12 15 6"})})}),u.jsxs("div",{className:"article-cover-overlay-center",children:[u.jsxs("button",{className:"article-cover-overlay-btn",onClick:D,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"23 4 23 10 17 10"}),u.jsx("polyline",{points:"1 20 1 14 7 14"}),u.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),u.jsxs("button",{className:"article-cover-overlay-btn",onClick:z,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u.jsx("polyline",{points:"7 10 12 15 17 10"}),u.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),u.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:R,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),w&&u.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:C,disabled:b>=v-1,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})})}),w&&u.jsxs("div",{className:"article-cover-counter",children:[b+1," / ",v]})]})]}):n==="loading"?u.jsxs("div",{className:"article-cover article-cover--loading",children:[u.jsx("div",{className:"article-cover-spinner"}),u.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?u.jsxs("div",{className:"article-cover article-cover--prompt",children:[u.jsxs("div",{className:"article-cover-prompt-row",children:[u.jsx("input",{ref:y,className:"article-cover-prompt-input",value:d,onChange:$=>f($.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),u.jsx("button",{className:"article-cover-prompt-btn",onClick:O,disabled:!d.trim(),children:"Generate"}),u.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&u.jsx("div",{className:"article-cover-error",children:p})]}):u.jsxs("div",{className:"article-cover article-cover--empty",onClick:_,children:[u.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:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),u.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),u.jsx("polyline",{points:"21 15 16 10 5 21"})]}),u.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function rP(){const[t,e]=S.useState(()=>localStorage.getItem(Ih)||""),[n,r]=S.useState(()=>localStorage.getItem(A0)||""),[s,i]=S.useState(!1),[l,c]=S.useState(""),d=S.useRef(null),f=S.useRef(null),p=()=>{const v=l.replace(/^@/,"").trim();v&&(localStorage.setItem(Ih,v),e(v)),i(!1)},m=()=>{c(t),i(!0),setTimeout(()=>{var v;return(v=d.current)==null?void 0:v.focus()},0)};S.useEffect(()=>{if(!s)return;const v=w=>{f.current&&!f.current.contains(w.target)&&p()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s,l]),S.useEffect(()=>{const v=()=>{e(localStorage.getItem(Ih)||""),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 u.jsxs("div",{className:"article-byline",ref:f,children:[u.jsxs("div",{className:"article-byline-row",onClick:m,title:t?`@${t} — click to change`:"Set your @handle",children:[t?u.jsx("img",{className:"article-byline-avatar",src:y,alt:`@${t}`}):u.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),u.jsx("span",{className:"article-byline-name",children:b}),t&&u.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),s&&u.jsx("div",{className:"article-byline-popover",children:u.jsx("input",{ref:d,className:"article-byline-input",value:l,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&p(),v.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function sP({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s,lastPost:i}){const{copyAsHtml:l,copyState:c}=ZD(),[d,f]=S.useState(i?"done":"idle");S.useEffect(()=>{f(i?"done":"idle")},[i]);const p=S.useCallback(()=>{d==="idle"&&(fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:{postedAt:new Date().toISOString()}}}),keepalive:!0}).catch(()=>{}),f("done"))},[d]);return u.jsxs("div",{className:"article-compose-wrapper",children:[u.jsx(nP,{src:r,coverImages:s}),u.jsxs("div",{className:"article-compose-content",children:[u.jsx("input",{className:"article-title-input",type:"text",value:tP.has(e||"")?"":e||"",onChange:m=>n==null?void 0:n(m.target.value||"Untitled"),placeholder:"Add a title",spellCheck:!1}),u.jsx(rP,{}),u.jsx("div",{className:"article-compose-body",children:t})]}),u.jsxs("div",{className:"article-compose-footer",children:[u.jsx("button",{className:`article-mark-sent-btn${d==="done"?" article-mark-sent-btn--done":""}`,onClick:d==="done"?void 0:p,title:d==="done"?"Posted":"Mark as manually posted",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:d==="done"?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"8 12 11 15 16 9",stroke:d==="done"?"#fff":"currentColor"})]})}),d==="done"&&i&&u.jsxs("span",{className:"article-sent-status",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),u.jsx("button",{className:`article-copy-btn${c==="copied"?" article-copy-btn--copied":""}`,onClick:l,children:c==="copied"?u.jsxs(u.Fragment,{children:[u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):u.jsxs(u.Fragment,{children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),u.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy as HTML"]})})]})]})}function iP({connectionId:t,repoName:e,title:n,slug:r,onClose:s}){const[i,l]=S.useState("confirm"),[c,d]=S.useState(null),[f,p]=S.useState(null),m=S.useRef(null),y=()=>i==="published"?{publishedAt:new Date().toISOString(),url:f||void 0,repo:e}:void 0;S.useEffect(()=>{const v=w=>{i!=="publishing"&&m.current&&!m.current.contains(w.target)&&s(y())};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s,i,f]),S.useEffect(()=>{const v=w=>{w.key==="Escape"&&i!=="publishing"&&s(y())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s,i,f]);async function b(){l("publishing"),d(null);try{const v=await fetch("/api/blog/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:t})}),w=await v.json();if(!v.ok||w.error){d(w.error||`Publish failed (${v.status})`),l("error");return}w.url&&p(w.url),l("published"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:{lastPublish:{publishedAt:new Date().toISOString(),url:w.url||void 0,repo:e}}})}).catch(()=>{})}catch(v){d(v.message),l("error")}}return u.jsx("div",{className:"blog-publish-overlay",children:u.jsxs("div",{className:"blog-publish-modal",ref:m,children:[u.jsxs("div",{className:"blog-publish__header",children:[u.jsx("h3",{children:"Publish to GitHub"}),u.jsx("button",{className:"blog-publish__close",onClick:()=>s(y()),children:"×"})]}),u.jsxs("div",{className:"blog-publish__body",children:[i==="confirm"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"blog-publish__summary",children:[u.jsxs("div",{className:"blog-publish__row",children:[u.jsx("span",{className:"blog-publish__label",children:"Repository"}),u.jsx("span",{className:"blog-publish__value",children:e})]}),u.jsxs("div",{className:"blog-publish__row",children:[u.jsx("span",{className:"blog-publish__label",children:"Title"}),u.jsx("span",{className:"blog-publish__value",children:n})]}),r&&u.jsxs("div",{className:"blog-publish__row",children:[u.jsx("span",{className:"blog-publish__label",children:"Slug"}),u.jsx("span",{className:"blog-publish__value blog-publish__value--mono",children:r})]})]}),u.jsxs("div",{className:"blog-publish__actions",children:[u.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),u.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:b,children:"Publish"})]})]}),i==="publishing"&&u.jsxs("div",{className:"blog-publish__status",children:[u.jsx("div",{className:"blog-publish__spinner"}),u.jsxs("span",{children:["Publishing to ",e,"..."]})]}),i==="published"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"blog-publish__status blog-publish__status--success",children:["Published to ",e,"!"]}),f&&u.jsx("a",{className:"blog-publish__link",href:f,target:"_blank",rel:"noopener noreferrer",children:"View on GitHub"}),u.jsx("div",{className:"blog-publish__actions",children:u.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:()=>s({publishedAt:new Date().toISOString(),url:f||void 0,repo:e}),children:"Done"})})]}),i==="error"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"blog-publish__error",children:c}),u.jsxs("div",{className:"blog-publish__actions",children:[u.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),u.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:b,children:"Retry"})]})]})]})]})})}const O0={font:"sans",width:"standard",spacing:"comfortable"},R0=new Set(["Untitled","New Document","Blog"]);function oP(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function j0(){return new Date().toISOString().split("T")[0]}function as(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function lP({src:t,coverImages:e}){const[n,r]=S.useState(t?"display":"empty"),[s,i]=S.useState(t||""),[l,c]=S.useState(e||(t?[t]:[])),[d,f]=S.useState(""),[p,m]=S.useState(""),y=S.useRef(null);S.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),S.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=S.useCallback($=>{const U=l[$];U&&(i(U),as({coverImage:U,coverImages:l}))},[l]),N=S.useCallback(()=>{b>0&&k(b-1)},[b,k]),C=S.useCallback(()=>{b<v-1&&k(b+1)},[b,v,k]),O=S.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const U=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})})).json();if(U.success&&U.src){const Y=[...l,U.src];c(Y),i(U.src),r("display"),f(""),as({coverImage:U.src,coverImages:Y})}else m(U.error||"Generation failed"),r("prompt")}catch($){m($.message||"Network error"),r("prompt")}}},[d,l]),T=$=>{$.key==="Enter"&&O(),$.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var $;return($=y.current)==null?void 0:$.focus()},0)},R=()=>{const $=l.filter(U=>U!==s);if(c($),$.length>0){const U=Math.min(b,$.length-1),Y=$[U];i(Y),as({coverImage:Y,coverImages:$})}else i(""),r("empty"),as({coverImage:void 0,coverImages:void 0})},D=()=>{r("prompt"),setTimeout(()=>{var $;return($=y.current)==null?void 0:$.focus()},0)},z=()=>{const $=document.createElement("a");$.href=s,$.download=`cover-${b+1}.png`,$.click()};return n==="display"&&s?u.jsxs("div",{className:"blog-cover blog-cover--display",children:[u.jsx("img",{className:"blog-cover-img",src:s,alt:"Cover"}),u.jsxs("div",{className:"blog-cover-overlay",children:[w&&u.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:N,disabled:b<=0,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"15 18 9 12 15 6"})})}),u.jsxs("div",{className:"blog-cover-overlay-center",children:[u.jsxs("button",{className:"blog-cover-btn",onClick:D,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"23 4 23 10 17 10"}),u.jsx("polyline",{points:"1 20 1 14 7 14"}),u.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),u.jsxs("button",{className:"blog-cover-btn",onClick:z,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u.jsx("polyline",{points:"7 10 12 15 17 10"}),u.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),u.jsxs("button",{className:"blog-cover-btn blog-cover-btn--danger",onClick:R,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),w&&u.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:C,disabled:b>=v-1,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})})}),w&&u.jsxs("div",{className:"blog-cover-counter",children:[b+1," / ",v]})]})]}):n==="loading"?u.jsxs("div",{className:"blog-cover blog-cover--loading",children:[u.jsx("div",{className:"blog-cover-spinner"}),u.jsx("span",{className:"blog-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?u.jsxs("div",{className:"blog-cover blog-cover--prompt",children:[u.jsxs("div",{className:"blog-cover-prompt-row",children:[u.jsx("input",{ref:y,className:"blog-cover-prompt-input",value:d,onChange:$=>f($.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),u.jsx("button",{className:"blog-cover-prompt-btn",onClick:O,disabled:!d.trim(),children:"Generate"}),u.jsx("button",{className:"blog-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&u.jsx("div",{className:"blog-cover-error",children:p})]}):u.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:_,children:[u.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:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),u.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),u.jsx("polyline",{points:"21 15 16 10 5 21"})]}),u.jsx("span",{className:"blog-cover-hint",children:"Add a featured image"})]})}function aP({tags:t,onChange:e}){const[n,r]=S.useState(""),s=S.useRef(null),i=d=>{const f=d.trim().toLowerCase();f&&!t.includes(f)&&e([...t,f]),r("")},l=d=>e(t.filter(f=>f!==d)),c=d=>{(d.key==="Enter"||d.key===",")&&(d.preventDefault(),i(n)),d.key==="Backspace"&&!n&&t.length>0&&l(t[t.length-1])};return u.jsxs("div",{className:"blog-tags",onClick:()=>{var d;return(d=s.current)==null?void 0:d.focus()},children:[t.map(d=>u.jsxs("span",{className:"blog-tag",children:[d,u.jsx("button",{className:"blog-tag-remove",onClick:f=>{f.stopPropagation(),l(d)},children:u.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},d)),u.jsx("input",{ref:s,className:"blog-tag-input",value:n,onChange:d=>r(d.target.value),onKeyDown:c,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function cP({style:t,onChange:e}){const n=r=>`blog-style-btn${r?" active":""}`;return u.jsxs("div",{className:"blog-style-controls",children:[u.jsxs("div",{className:"blog-style-group",children:[u.jsx("span",{className:"blog-style-label",children:"Font"}),u.jsx("button",{className:n(t.font==="sans"),onClick:()=>e({...t,font:"sans"}),title:"Sans-serif",children:"Aa"}),u.jsx("button",{className:`${n(t.font==="serif")} serif-btn`,onClick:()=>e({...t,font:"serif"}),title:"Serif",children:"Aa"}),u.jsx("button",{className:`${n(t.font==="mono")} mono-btn`,onClick:()=>e({...t,font:"mono"}),title:"Monospace",children:"Aa"})]}),u.jsxs("div",{className:"blog-style-group",children:[u.jsx("span",{className:"blog-style-label",children:"Width"}),u.jsx("button",{className:n(t.width==="narrow"),onClick:()=>e({...t,width:"narrow"}),title:"Narrow (600px)",children:u.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:u.jsx("rect",{x:"4",y:"1",width:"8",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),u.jsx("button",{className:n(t.width==="standard"),onClick:()=>e({...t,width:"standard"}),title:"Standard (720px)",children:u.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:u.jsx("rect",{x:"2",y:"1",width:"12",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),u.jsx("button",{className:n(t.width==="wide"),onClick:()=>e({...t,width:"wide"}),title:"Wide (900px)",children:u.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:u.jsx("rect",{x:"0.5",y:"1",width:"15",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})})]}),u.jsxs("div",{className:"blog-style-group",children:[u.jsx("span",{className:"blog-style-label",children:"Spacing"}),u.jsx("button",{className:n(t.spacing==="compact"),onClick:()=>e({...t,spacing:"compact"}),title:"Compact",children:u.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[u.jsx("line",{x1:"1",y1:"3",x2:"15",y2:"3"}),u.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),u.jsx("line",{x1:"1",y1:"11",x2:"15",y2:"11"})]})}),u.jsx("button",{className:n(t.spacing==="comfortable"),onClick:()=>e({...t,spacing:"comfortable"}),title:"Comfortable",children:u.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[u.jsx("line",{x1:"1",y1:"2",x2:"15",y2:"2"}),u.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),u.jsx("line",{x1:"1",y1:"12",x2:"15",y2:"12"})]})})]})]})}function uP({children:t,title:e,onTitleChange:n,blogContext:r,filename:s}){var K;const i=r||{},[l,c]=S.useState(i.description||""),[d,f]=S.useState(!1),[p,m]=S.useState(i.date||j0()),[y,b]=S.useState(i.tags||[]),[v,w]=S.useState(i.author||""),[k,N]=S.useState(i.slug||""),[C,O]=S.useState(i.draft??!1),[T,_]=S.useState({...O0,...i.style}),[R,D]=S.useState(!1),[z,$]=S.useState(!!i.slug),[U,Y]=S.useState(null),[X,J]=S.useState(!1);S.useEffect(()=>{fetch("/api/blog/connection").then(B=>B.json()).then(B=>{B.connection&&Y(B.connection)}).catch(()=>{})},[]),S.useEffect(()=>{!z&&e&&!R0.has(e)&&N(oP(e))},[e,z]),S.useEffect(()=>{c(i.description||""),m(i.date||j0()),b(i.tags||[]),w(i.author||""),N(i.slug||""),O(i.draft??!1),_({...O0,...i.style}),$(!!i.slug)},[r]);const q=!!(r!=null&&r.active),H=S.useCallback(()=>{q&&as({description:l,date:p,tags:y,author:v,slug:k,draft:C,style:T})},[q,l,p,y,v,k,C,T]);S.useEffect(()=>{q&&as({tags:y})},[q,y]),S.useEffect(()=>{q&&as({style:T})},[q,T]),S.useEffect(()=>{q&&as({draft:C})},[q,C]);const W=l.length,re=W>160,V=["blog-compose-wrapper",`blog--font-${T.font}`,`blog--width-${T.width}`,`blog--spacing-${T.spacing}`].join(" ");return u.jsxs("div",{className:V,children:[u.jsx(lP,{src:i.coverImage,coverImages:i.coverImages}),u.jsxs("div",{className:"blog-compose-content",children:[((K=i.lastPublish)==null?void 0:K.publishedAt)&&u.jsxs("a",{className:"blog-published-status",href:i.lastPublish.url,target:"_blank",rel:"noopener noreferrer",title:i.lastPublish.url||`Published to ${i.lastPublish.repo||"GitHub"}`,children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Published ",new Date(i.lastPublish.publishedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),i.lastPublish.repo?` to ${i.lastPublish.repo.split("/").pop()}`:""]}),u.jsx("input",{className:"blog-title-input",type:"text",value:R0.has(e||"")?"":e||"",onChange:B=>n==null?void 0:n(B.target.value||"Untitled"),placeholder:"Post title",spellCheck:!1}),u.jsxs("div",{className:"blog-description-wrap",children:[u.jsx("textarea",{className:`blog-description-input${re?" over-limit":""}`,value:l,onChange:B=>c(B.target.value),onBlur:H,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),u.jsxs("span",{className:`blog-description-count${re?" over-limit":""}`,children:[W,"/160"]})]}),u.jsxs("div",{className:"blog-meta-toggle",onClick:()=>D(B=>!B),children:[u.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:u.jsx("polyline",{points:"9 18 15 12 9 6"})}),u.jsx("span",{children:"Metadata"}),C&&u.jsx("span",{className:"blog-draft-badge",children:"Draft"})]}),R&&u.jsxs("div",{className:"blog-meta-fields",children:[u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Date"}),u.jsx("input",{type:"date",className:"blog-meta-input",value:p,onChange:B=>m(B.target.value),onBlur:H})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Author"}),u.jsx("input",{type:"text",className:"blog-meta-input",value:v,onChange:B=>w(B.target.value),onBlur:H,placeholder:"Author name",spellCheck:!1})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Slug"}),u.jsx("input",{type:"text",className:"blog-meta-input",value:k,onChange:B=>{$(!0),N(B.target.value)},onBlur:H,placeholder:"auto-generated-from-title",spellCheck:!1})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Tags"}),u.jsx(aP,{tags:y,onChange:b})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Draft"}),u.jsx("button",{className:`blog-draft-toggle${C?" active":""}`,onClick:()=>O(B=>!B),children:u.jsx("div",{className:"blog-draft-toggle-knob"})})]})]}),u.jsx("div",{className:"blog-compose-body",children:t})]}),u.jsxs("div",{className:"blog-compose-footer",children:[u.jsx(cP,{style:T,onChange:_}),s&&u.jsxs("div",{className:"blog-footer-actions",children:[U&&u.jsxs("button",{className:"blog-footer-btn blog-footer-btn--primary",onClick:()=>J(!0),children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})}),"Publish"]}),u.jsxs("button",{className:"blog-footer-btn",onClick:()=>f(!0),children:[u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]})]}),d&&s&&u.jsx(sd,{filename:s,title:e||"Untitled",onClose:()=>f(!1)}),X&&U&&u.jsx(iP,{connectionId:U.id,repoName:U.display_name,title:e||"Untitled",slug:k,onClose:B=>{J(!1),B&&as({lastPublish:B})}})]})}function dP({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,l]=S.useState("confirm"),[c,d]=S.useState("html"),[f,p]=S.useState(""),[m,y]=S.useState(null),[b,v]=S.useState(null),[w,k]=S.useState(0),[N,C]=S.useState(null),[O,T]=S.useState(null),[_,R]=S.useState("all"),[D,z]=S.useState([]),[$,U]=S.useState(""),Y=S.useRef(null),X=D.find(W=>W.id===$),J=_==="exclude_issue"&&X&&O!=null?Math.max(0,O-X.recipient_count):O;S.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(W=>W.json()).then(W=>{var V,K;const re=(K=(V=W.content)==null?void 0:V[0])!=null&&K.text?JSON.parse(W.content[0].text):W;re.count!=null&&T(re.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(W=>W.json()).then(W=>{var V,K;const re=(K=(V=W.content)==null?void 0:V[0])!=null&&K.text?JSON.parse(W.content[0].text):W;re.issues&&z(re.issues)}).catch(()=>{})},[]);const q=()=>i==="sent"?{sentCount:w,issueId:N,sentAt:new Date().toISOString()}:void 0;S.useEffect(()=>{const W=re=>{i!=="sending"&&i!=="testing"&&Y.current&&!Y.current.contains(re.target)&&s(q())};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[s,i,w,N]),S.useEffect(()=>{const W=re=>{re.key==="Escape"&&i!=="sending"&&i!=="testing"&&s(q())};return document.addEventListener("keydown",W),()=>document.removeEventListener("keydown",W)},[s,i,w,N]);async function H(W){var re,V;l(W?"testing":"sending"),v(null);try{r&&await r();const K={subject:e,connectionId:t,format:c};W&&(K.test_email=W),!W&&_==="exclude_issue"&&$&&(K.exclude_issue_id=$);const A=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"send_newsletter",arguments:K})})).json(),L=(V=(re=A.content)==null?void 0:re[0])!=null&&V.text?JSON.parse(A.content[0].text):A;if(L.error){v(L.error),l("error");return}if(L.test){y(L.sent_to),l("confirm");return}const te=L.sent||0,oe=L.issueId||null,he=new Date().toISOString();k(te),C(oe),l("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:te,sentAt:he,issueId:oe||void 0}}})}).catch(()=>{})}catch(K){v(K.message),l("error")}}return u.jsx("div",{className:"newsletter-modal-overlay",children:u.jsxs("div",{className:"newsletter-modal",ref:Y,children:[u.jsxs("div",{className:"newsletter-modal__header",children:[u.jsx("h3",{children:"Send Newsletter"}),u.jsx("button",{className:"newsletter-modal__close",onClick:()=>s(q()),children:"×"})]}),u.jsxs("div",{className:"newsletter-modal__body",children:[i==="confirm"&&u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"newsletter-modal__confirm-text",style:J==null?{visibility:"hidden"}:void 0,children:['Send "',u.jsx("strong",{children:e}),'" to ',J!=null?J.toLocaleString():0," subscriber",J!==1?"s":"","?"]}),u.jsxs("div",{className:"newsletter-modal__audience",children:[u.jsx("label",{className:"newsletter-modal__label",children:"Audience"}),u.jsxs("select",{className:"newsletter-modal__select",value:_,onChange:W=>{const re=W.target.value;R(re),re==="all"&&U("")},children:[u.jsx("option",{value:"all",children:"All subscribers"}),D.length>0&&u.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),_==="exclude_issue"&&u.jsxs("select",{className:"newsletter-modal__select",value:$,onChange:W=>U(W.target.value),children:[u.jsx("option",{value:"",children:"Select a past issue"}),D.map(W=>u.jsxs("option",{value:W.id,children:[W.subject," (",W.recipient_count," sent)"]},W.id))]})]}),u.jsxs("div",{className:"newsletter-modal__format-toggle",children:[u.jsx("button",{className:`newsletter-modal__format-btn${c==="html"?" active":""}`,onClick:()=>d("html"),children:"HTML"}),u.jsx("button",{className:`newsletter-modal__format-btn${c==="plaintext"?" active":""}`,onClick:()=>d("plaintext"),children:"Plaintext"})]}),u.jsxs("div",{className:"newsletter-modal__test-section",children:[u.jsxs("div",{className:"newsletter-modal__test-row",children:[u.jsx("input",{type:"email",className:"newsletter-modal__test-input",placeholder:"Test email address",value:f,onChange:W=>p(W.target.value),onKeyDown:W=>{W.key==="Enter"&&f.trim()&&H(f.trim())}}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>H(f.trim()),children:"Send Test"})]}),m&&u.jsxs("p",{className:"newsletter-modal__test-success",children:["Test sent to ",m]})]}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",disabled:_==="exclude_issue"&&!$,onClick:()=>H(),children:"Send Now"})]})]}),(i==="sending"||i==="testing")&&u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:i==="testing"?"Sending test...":"Sending..."})]}),i==="sent"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:["Sent to ",w," subscriber",w!==1?"s":"","!"]}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:w,issueId:N,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"newsletter-modal__error",children:b}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>H(),children:"Retry"})]})]})]})]})})}function I0(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function fP({children:t,newsletterContext:e,filename:n,title:r,onTitleChange:s,onBeforeSend:i}){var X;const l=e||{},[c,d]=S.useState(l.subject||""),[f,p]=S.useState(l.previewText||""),[m,y]=S.useState([]),[b,v]=S.useState(null),[w,k]=S.useState(!1),[N,C]=S.useState((X=l.lastSend)!=null&&X.sentAt?{sentCount:l.lastSend.sentCount,issueId:l.lastSend.issueId||null,sentAt:l.lastSend.sentAt}:null),O=S.useRef(null),T=S.useRef(n);S.useEffect(()=>{var J;T.current!==n&&(d(l.subject||""),p(l.previewText||""),T.current=n),C((J=l.lastSend)!=null&&J.sentAt?{sentCount:l.lastSend.sentCount,issueId:l.lastSend.issueId||null,sentAt:l.lastSend.sentAt}:null)},[e,n]),S.useEffect(()=>{fetch("/api/connections").then(J=>J.json()).then(J=>{const q=(J.connections||[]).filter(H=>H.provider==="newsletter"&&H.status==="active");y(q)}).catch(()=>{})},[]);const _=!!(e!=null&&e.active),R=S.useRef();S.useEffect(()=>{if(R.current&&clearTimeout(R.current),!(!s||!c.trim()))return R.current=setTimeout(async()=>{const J=r,q=!J||J==="Untitled",H=O.current!==null&&J===O.current;if(q||H){try{await fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{subject:c}})})}catch{}s(c.trim()),O.current=c.trim()}},500),()=>{R.current&&clearTimeout(R.current)}},[c,r,s]);const D=S.useCallback(()=>{_&&I0({subject:c,previewText:f})},[_,c,f]),z=f.length,$=z>=90,U=z>150,Y=()=>{m.length===1&&v(m[0].id),m.length>1&&v(m[0].id)};return u.jsxs("div",{className:"nl-compose-wrapper",children:[N&&u.jsxs("div",{className:"nl-sent-status",children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent ",new Date(N.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",N.sentCount," subscriber",N.sentCount!==1?"s":""]}),u.jsxs("div",{className:"nl-compose-content",children:[u.jsx("input",{className:"nl-subject-input",type:"text",value:c,onChange:J=>d(J.target.value),onBlur:D,placeholder:"Subject line (defaults to title if empty)",autoComplete:"off","data-lpignore":"true","data-1p-ignore":!0,spellCheck:!1}),u.jsxs("div",{className:"nl-preview-wrap",children:[u.jsx("textarea",{className:`nl-preview-input${U?" over-limit":""}`,value:f,onChange:J=>p(J.target.value),onBlur:D,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),u.jsxs("span",{className:`nl-preview-count${U?" over-limit":$?" full":""}`,children:[z,"/90"]})]}),u.jsx("div",{className:"nl-compose-body",children:t})]}),n&&u.jsxs("div",{className:"nl-compose-footer",children:[m.length>0&&u.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:Y,children:[u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),u.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Send"]}),u.jsxs("button",{className:"nl-footer-btn",onClick:()=>k(!0),children:[u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]}),b&&n&&u.jsx(dP,{connectionId:b,subject:c||r||"Untitled",filename:n,onBeforeSend:i,onClose:J=>{v(null),J&&(C(J),I0({lastSend:{sentCount:J.sentCount,sentAt:J.sentAt,issueId:J.issueId||void 0}}))}}),w&&n&&u.jsx(sd,{filename:n,title:r||"Untitled",onClose:()=>k(!1)})]})}function hP(t){const e=t==null?void 0:t.articleContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function pP(t){const e=t==null?void 0:t.blogContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function mP(t){const e=t==null?void 0:t.newsletterContext;return e!=null&&typeof e=="object"&&(e.active===!0||Object.keys(e).length>0)}function gP(){var ir,ct,vn;const t=S.useRef(null),e=S.useRef([]),[n,r]=S.useState(null),[s,i]=S.useState([]),[l,c]=S.useState("Untitled"),[d,f]=S.useState(void 0),[p,m]=S.useState(0),[y,b]=S.useState(!0),[v,w]=S.useState(0),[k,N]=S.useState(0),[C,O]=S.useState({filenames:[],counts:{}}),[T,_]=S.useState({state:"unconfigured"}),[R,D]=S.useState(!1),[z,$]=S.useState({}),[U,Y]=S.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[X,J]=S.useState(null),[q,H]=S.useState(null),W=S.useRef(0),re=S.useRef(null),V=1500,K=S.useCallback((le,Ee)=>{re.current&&(clearTimeout(re.current),re.current=null),W.current=Date.now(),J(le),H(Ee)},[]),B=S.useCallback(()=>{if(re.current)return;const le=Date.now()-W.current,Ee=V-le;Ee<=0?(J(null),H(null)):re.current=setTimeout(()=>{re.current=null,J(null),H(null)},Ee)},[]),[,A]=S.useState(0),L=S.useRef(null),te=S.useRef(null),oe=S.useRef([]),he=S.useRef(-1),ne=S.useRef(!1),ge=S.useRef(""),[De,ot]=S.useState(""),[ce,pe]=S.useState(!1),[se,Pe]=S.useState(!1),Oe=hP(z),Je=pP(z),Ne=mP(z);S.useEffect(()=>(Oe?document.documentElement.setAttribute("data-view","article"):Je?document.documentElement.setAttribute("data-view","blog"):Ne?document.documentElement.setAttribute("data-view","newsletter"):z!=null&&z.tweetContext?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[z==null?void 0:z.tweetContext,Oe,Je,Ne]),S.useEffect(()=>{const le=()=>A(Ee=>Ee+1);return window.addEventListener("ow-sidebar-mode-change",le),()=>window.removeEventListener("ow-sidebar-mode-change",le)},[]),S.useEffect(()=>{fetch("/api/document",{cache:"no-store"}).then(le=>le.json()).then(le=>{le.document&&(f(le.document),te.current=le.document),le.title&&c(le.title),le.metadata&&$(le.metadata)}).catch(()=>{f(void 0)}),fetch("/api/pending-docs").then(le=>le.json()).then(le=>O(le)).catch(()=>{}),fetch("/api/sync/status").then(le=>le.json()).then(le=>_(le)).catch(()=>{})},[]);const et=S.useCallback(le=>{t.current=le,r(le),e.current=[le],i([le])},[]),Le=S.useCallback(le=>{e.current=le,i(le)},[]),He=S.useCallback(le=>{L.current&&(clearTimeout(L.current),L.current=null);const Ee=ge.current==="",lt=le.filename===ge.current;if(ge.current=le.filename,te.current=le.document,ot(le.filename),f(le.document),c(le.title),$(le.metadata||{}),!lt&&!Ee&&m(Dt=>Dt+1),w(Dt=>Dt+1),ne.current){const Dt=oe.current[he.current];Dt&&setTimeout(()=>{const I=document.querySelector(".editor-container");I&&(I.scrollTop=Dt.scrollTop)},50),ne.current=!1}pe(he.current>0),Pe(he.current<oe.current.length-1)},[]),ke=S.useCallback(()=>{w(le=>le+1)},[]),fe=S.useCallback(()=>{N(le=>le+1)},[]),qe=S.useCallback(le=>{O(le)},[]),{connected:at,sendMessage:it}=ID({onNodeChanges:le=>{const Ee=e.current;if(Ee.length<=1){const lt=t.current;if(!lt)return;d0(lt,le)}else for(const lt of Ee)d0(lt,le)},onDocumentSwitched:He,onDocumentsChanged:ke,onWorkspacesChanged:fe,onPendingDocsChanged:qe,onMetadataChanged:le=>$(le),onWritingStarted:(le,Ee)=>K(le,Ee),onWritingFinished:()=>B(),onSyncStatus:le=>_(le),onTitleChanged:le=>c(le),getEditorState:()=>{var Ee;const le=te.current||((Ee=t.current)==null?void 0:Ee.getJSON());return le?{document:le}:null}}),mt=S.useCallback(()=>{var Ee;L.current&&(clearTimeout(L.current),L.current=null);const le=te.current||((Ee=t.current)==null?void 0:Ee.getJSON());le&&it({type:"doc-update",document:le,filename:ge.current})},[it]),$t=S.useCallback(async()=>{var Ee;const le=te.current||((Ee=t.current)==null?void 0:Ee.getJSON());le&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:le,filename:ge.current})})},[]);S.useEffect(()=>{const le=()=>{var I;L.current&&(clearTimeout(L.current),L.current=null);const lt=te.current||((I=t.current)==null?void 0:I.getJSON());if(!lt)return;const Dt=JSON.stringify({type:"flush",document:lt});navigator.sendBeacon("/api/flush",new Blob([Dt],{type:"application/json"}))},Ee=()=>{document.visibilityState==="hidden"&&le()};return window.addEventListener("beforeunload",le),document.addEventListener("visibilitychange",Ee),()=>{window.removeEventListener("beforeunload",le),document.removeEventListener("visibilitychange",Ee)}},[]);const Lt=S.useCallback(()=>{mt(),it({type:"create-document"})},[mt,it]),Z=S.useCallback(le=>{const Ee=document.querySelector(".editor-container"),lt=(Ee==null?void 0:Ee.scrollTop)||0;!ne.current&&ge.current&&(oe.current=oe.current.slice(0,he.current+1),oe.current.push({filename:ge.current,scrollTop:lt}),he.current=oe.current.length-1),mt(),it({type:"switch-document",filename:le})},[mt,it]),We=S.useCallback(()=>{if(he.current<=0)return;const le=document.querySelector(".editor-container"),Ee=(le==null?void 0:le.scrollTop)||0;he.current===oe.current.length-1&&ge.current?(oe.current=oe.current.slice(0,he.current+1),oe.current.push({filename:ge.current,scrollTop:Ee})):ge.current&&(oe.current[he.current+1]={filename:ge.current,scrollTop:Ee});const lt=oe.current[he.current];he.current--,ne.current=!0,pe(he.current>0),Pe(!0),mt(),it({type:"switch-document",filename:lt.filename})},[mt,it]),Fe=S.useCallback(()=>{if(he.current>=oe.current.length-2)return;const le=document.querySelector(".editor-container"),Ee=(le==null?void 0:le.scrollTop)||0;ge.current&&(oe.current[he.current+1]={filename:ge.current,scrollTop:Ee}),he.current++;const lt=oe.current[he.current+1];ne.current=!0,pe(!0),Pe(he.current<oe.current.length-2),mt(),it({type:"switch-document",filename:lt.filename})},[mt,it]),xt=S.useCallback(()=>{const le=ge.current,Ee=t.current;!le||!Ee||fetch(`/api/marks/${encodeURIComponent(le)}`).then(lt=>lt.json()).then(lt=>{i0(lt.marks||[]),c0(Ee.view)}).catch(()=>{i0([]),Ee!=null&&Ee.view&&c0(Ee.view)})},[]);S.useEffect(()=>{xt()},[De,xt]),S.useEffect(()=>{const le=Ee=>{const lt=Ee.detail;(lt==null?void 0:lt.filename)===ge.current&&xt()};return window.addEventListener("ow-marks-changed",le),()=>window.removeEventListener("ow-marks-changed",le)},[xt]),S.useEffect(()=>{const le=Ee=>{Ee.altKey&&Ee.key==="ArrowLeft"&&(Ee.preventDefault(),We()),Ee.altKey&&Ee.key==="ArrowRight"&&(Ee.preventDefault(),Fe())};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[We,Fe]);const tt=S.useCallback(le=>{te.current=le,L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{it({type:"doc-update",document:le,filename:ge.current})},1e3)},[it]),Xe=S.useCallback(le=>{c(le),it({type:"title-update",title:le})},[it]),nt=S.useCallback(()=>{Y(le=>(localStorage.setItem("ow-toolbar",le?"hidden":"visible"),!le))},[]),Dn=S.useCallback(()=>{if(T.state==="unconfigured"){D(!0);return}mt(),it({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[T.state,mt,it]),ln=$u()==="board";return u.jsxs("div",{className:"app",children:[!ln&&u.jsx(S0,{open:y,onSwitchDocument:Z,onCreateDocument:Lt,refreshKey:v,workspacesRefreshKey:k,pendingDocs:C,writingTitle:X,writingTarget:q,onClose:()=>b(!1)}),u.jsxs("div",{className:"app-main",children:[u.jsx(ML,{title:l,onTitleChange:Xe,syncStatus:T,onSync:Dn,onToggleSidebar:!ln&&!y?()=>b(!0):void 0,canGoBack:ce,canGoForward:se,onGoBack:We,onGoForward:Fe,editor:n,onToggleToolbar:nt,toolbarOpen:U}),U&&n&&u.jsx(dL,{editor:n}),ln&&u.jsx(S0,{open:!0,onSwitchDocument:Z,onCreateDocument:Lt,refreshKey:v,workspacesRefreshKey:k,pendingDocs:C,writingTitle:X,writingTarget:q}),!at&&u.jsxs("div",{className:"connection-banner",children:[u.jsx("div",{className:"connection-banner-spinner"}),u.jsx("span",{children:"Reconnecting to server..."})]}),u.jsx("div",{className:"editor-container",children:Oe?u.jsx(sP,{title:l,onTitleChange:Xe,coverImage:(ir=z==null?void 0:z.articleContext)==null?void 0:ir.coverImage,coverImages:(ct=z==null?void 0:z.articleContext)==null?void 0:ct.coverImages,lastPost:(vn=z==null?void 0:z.articleContext)==null?void 0:vn.lastPost,children:u.jsx(Ac,{initialContent:d,extensions:nL,onUpdate:tt,onReady:et,onLinkClick:Z},p)}):Je?u.jsx(uP,{title:l,onTitleChange:Xe,blogContext:z==null?void 0:z.blogContext,filename:De,children:u.jsx(Ac,{initialContent:d,onUpdate:tt,onReady:et,onLinkClick:Z},p)}):Ne?u.jsx(fP,{newsletterContext:z==null?void 0:z.newsletterContext,filename:De,title:l,onTitleChange:Xe,onBeforeSend:$t,children:u.jsx(Ac,{initialContent:d,onUpdate:tt,onReady:et,onLinkClick:Z},p)}):z!=null&&z.tweetContext?u.jsx(XD,{tweetContext:z.tweetContext,initialContent:d,onUpdate:tt,onEditorReady:et,onEditorsChange:Le,filename:De,title:l},p):u.jsx(Ac,{initialContent:d,onUpdate:tt,onReady:et,onLinkClick:Z},p)}),u.jsx(tD,{editors:s,pendingDocs:C,currentFilename:De,onSwitchDocument:Z,sendMessage:it,getDocument:()=>te.current})]}),u.jsx(BL,{editorRef:t,allEditors:s,documentId:De}),R&&u.jsx(jD,{onClose:()=>D(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(le=>le.json()).then(_).catch(()=>{})}})]})}ME();EE.createRoot(document.getElementById("root")).render(u.jsx(Js.StrictMode,{children:u.jsx(gP,{})}));
|