openwriter 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/index-BEDioWIU.js +208 -0
- package/dist/client/assets/{index-Be3gaGeo.css → index-BsHE9tXC.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/documents.js +38 -2
- package/dist/server/index.js +41 -16
- package/dist/server/marks.js +166 -0
- package/dist/server/mcp.js +63 -2
- package/dist/server/state.js +3 -0
- package/dist/server/workspaces.js +16 -0
- package/dist/server/ws.js +18 -3
- package/package.json +1 -4
- package/skill/SKILL.md +25 -2
- package/dist/client/assets/index-BwT1KW6a.js +0 -207
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const l of s.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function Lu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Df={exports:{}},ul={},Pf={exports:{}},Xe={};/**
|
|
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 Ry;function VE(){if(Ry)return Xe;Ry=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),h=Symbol.iterator;function y(R){return R===null||typeof R!="object"?null:(R=h&&R[h]||R["@@iterator"],typeof R=="function"?R:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,E={};function w(R,j,le){this.props=R,this.context=j,this.refs=E,this.updater=le||b}w.prototype.isReactComponent={},w.prototype.setState=function(R,j){if(typeof R!="object"&&typeof R!="function"&&R!=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,R,j,"setState")},w.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function S(){}S.prototype=w.prototype;function _(R,j,le){this.props=R,this.context=j,this.refs=E,this.updater=le||b}var M=_.prototype=new S;M.constructor=_,x(M,w.prototype),M.isPureReactComponent=!0;var T=Array.isArray,O=Object.prototype.hasOwnProperty,P={current:null},B={key:!0,ref:!0,__self:!0,__source:!0};function Q(R,j,le){var ye,Ee={},oe=null,z=null;if(j!=null)for(ye in j.ref!==void 0&&(z=j.ref),j.key!==void 0&&(oe=""+j.key),j)O.call(j,ye)&&!B.hasOwnProperty(ye)&&(Ee[ye]=j[ye]);var q=arguments.length-2;if(q===1)Ee.children=le;else if(1<q){for(var Y=Array(q),ne=0;ne<q;ne++)Y[ne]=arguments[ne+2];Ee.children=Y}if(R&&R.defaultProps)for(ye in q=R.defaultProps,q)Ee[ye]===void 0&&(Ee[ye]=q[ye]);return{$$typeof:t,type:R,key:oe,ref:z,props:Ee,_owner:P.current}}function X(R,j){return{$$typeof:t,type:R.type,key:j,ref:R.ref,props:R.props,_owner:R._owner}}function J(R){return typeof R=="object"&&R!==null&&R.$$typeof===t}function fe(R){var j={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(le){return j[le]})}var K=/\/+/g;function W(R,j){return typeof R=="object"&&R!==null&&R.key!=null?fe(""+R.key):j.toString(36)}function $(R,j,le,ye,Ee){var oe=typeof R;(oe==="undefined"||oe==="boolean")&&(R=null);var z=!1;if(R===null)z=!0;else switch(oe){case"string":case"number":z=!0;break;case"object":switch(R.$$typeof){case t:case e:z=!0}}if(z)return z=R,Ee=Ee(z),R=ye===""?"."+W(z,0):ye,T(Ee)?(le="",R!=null&&(le=R.replace(K,"$&/")+"/"),$(Ee,j,le,"",function(ne){return ne})):Ee!=null&&(J(Ee)&&(Ee=X(Ee,le+(!Ee.key||z&&z.key===Ee.key?"":(""+Ee.key).replace(K,"$&/")+"/")+R)),j.push(Ee)),1;if(z=0,ye=ye===""?".":ye+":",T(R))for(var q=0;q<R.length;q++){oe=R[q];var Y=ye+W(oe,q);z+=$(oe,j,le,Y,Ee)}else if(Y=y(R),typeof Y=="function")for(R=Y.call(R),q=0;!(oe=R.next()).done;)oe=oe.value,Y=ye+W(oe,q++),z+=$(oe,j,le,Y,Ee);else if(oe==="object")throw j=String(R),Error("Objects are not valid as a React child (found: "+(j==="[object Object]"?"object with keys {"+Object.keys(R).join(", ")+"}":j)+"). If you meant to render a collection of children, use an array instead.");return z}function Z(R,j,le){if(R==null)return R;var ye=[],Ee=0;return $(R,ye,"","",function(oe){return j.call(le,oe,Ee++)}),ye}function ee(R){if(R._status===-1){var j=R._result;j=j(),j.then(function(le){(R._status===0||R._status===-1)&&(R._status=1,R._result=le)},function(le){(R._status===0||R._status===-1)&&(R._status=2,R._result=le)}),R._status===-1&&(R._status=0,R._result=j)}if(R._status===1)return R._result.default;throw R._result}var he={current:null},G={transition:null},se={ReactCurrentDispatcher:he,ReactCurrentBatchConfig:G,ReactCurrentOwner:P};function ie(){throw Error("act(...) is not supported in production builds of React.")}return Xe.Children={map:Z,forEach:function(R,j,le){Z(R,function(){j.apply(this,arguments)},le)},count:function(R){var j=0;return Z(R,function(){j++}),j},toArray:function(R){return Z(R,function(j){return j})||[]},only:function(R){if(!J(R))throw Error("React.Children.only expected to receive a single React element child.");return R}},Xe.Component=w,Xe.Fragment=n,Xe.Profiler=i,Xe.PureComponent=_,Xe.StrictMode=r,Xe.Suspense=u,Xe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=se,Xe.act=ie,Xe.cloneElement=function(R,j,le){if(R==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+R+".");var ye=x({},R.props),Ee=R.key,oe=R.ref,z=R._owner;if(j!=null){if(j.ref!==void 0&&(oe=j.ref,z=P.current),j.key!==void 0&&(Ee=""+j.key),R.type&&R.type.defaultProps)var q=R.type.defaultProps;for(Y in j)O.call(j,Y)&&!B.hasOwnProperty(Y)&&(ye[Y]=j[Y]===void 0&&q!==void 0?q[Y]:j[Y])}var Y=arguments.length-2;if(Y===1)ye.children=le;else if(1<Y){q=Array(Y);for(var ne=0;ne<Y;ne++)q[ne]=arguments[ne+2];ye.children=q}return{$$typeof:t,type:R.type,key:Ee,ref:oe,props:ye,_owner:z}},Xe.createContext=function(R){return R={$$typeof:l,_currentValue:R,_currentValue2:R,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},R.Provider={$$typeof:s,_context:R},R.Consumer=R},Xe.createElement=Q,Xe.createFactory=function(R){var j=Q.bind(null,R);return j.type=R,j},Xe.createRef=function(){return{current:null}},Xe.forwardRef=function(R){return{$$typeof:c,render:R}},Xe.isValidElement=J,Xe.lazy=function(R){return{$$typeof:p,_payload:{_status:-1,_result:R},_init:ee}},Xe.memo=function(R,j){return{$$typeof:f,type:R,compare:j===void 0?null:j}},Xe.startTransition=function(R){var j=G.transition;G.transition={};try{R()}finally{G.transition=j}},Xe.unstable_act=ie,Xe.useCallback=function(R,j){return he.current.useCallback(R,j)},Xe.useContext=function(R){return he.current.useContext(R)},Xe.useDebugValue=function(){},Xe.useDeferredValue=function(R){return he.current.useDeferredValue(R)},Xe.useEffect=function(R,j){return he.current.useEffect(R,j)},Xe.useId=function(){return he.current.useId()},Xe.useImperativeHandle=function(R,j,le){return he.current.useImperativeHandle(R,j,le)},Xe.useInsertionEffect=function(R,j){return he.current.useInsertionEffect(R,j)},Xe.useLayoutEffect=function(R,j){return he.current.useLayoutEffect(R,j)},Xe.useMemo=function(R,j){return he.current.useMemo(R,j)},Xe.useReducer=function(R,j,le){return he.current.useReducer(R,j,le)},Xe.useRef=function(R){return he.current.useRef(R)},Xe.useState=function(R){return he.current.useState(R)},Xe.useSyncExternalStore=function(R,j,le){return he.current.useSyncExternalStore(R,j,le)},Xe.useTransition=function(){return he.current.useTransition()},Xe.version="18.3.1",Xe}var Iy;function Wl(){return Iy||(Iy=1,Pf.exports=VE()),Pf.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 Ly;function KE(){if(Ly)return ul;Ly=1;var t=Wl(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,f){var p,h={},y=null,b=null;f!==void 0&&(y=""+f),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(b=u.ref);for(p in u)r.call(u,p)&&!s.hasOwnProperty(p)&&(h[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)h[p]===void 0&&(h[p]=u[p]);return{$$typeof:e,type:c,key:y,ref:b,props:h,_owner:i.current}}return ul.Fragment=n,ul.jsx=l,ul.jsxs=l,ul}var Dy;function GE(){return Dy||(Dy=1,Df.exports=KE()),Df.exports}var g=GE(),N=Wl();const Ki=Lu(N);var rc={},jf={exports:{}},Un={},Bf={exports:{}},zf={};/**
|
|
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 Py;function qE(){return Py||(Py=1,(function(t){function e(G,se){var ie=G.length;G.push(se);e:for(;0<ie;){var R=ie-1>>>1,j=G[R];if(0<i(j,se))G[R]=se,G[ie]=j,ie=R;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var se=G[0],ie=G.pop();if(ie!==se){G[0]=ie;e:for(var R=0,j=G.length,le=j>>>1;R<le;){var ye=2*(R+1)-1,Ee=G[ye],oe=ye+1,z=G[oe];if(0>i(Ee,ie))oe<j&&0>i(z,Ee)?(G[R]=z,G[oe]=ie,R=oe):(G[R]=Ee,G[ye]=ie,R=ye);else if(oe<j&&0>i(z,ie))G[R]=z,G[oe]=ie,R=oe;else break e}}return se}function i(G,se){var ie=G.sortIndex-se.sortIndex;return ie!==0?ie:G.id-se.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var l=Date,c=l.now();t.unstable_now=function(){return l.now()-c}}var u=[],f=[],p=1,h=null,y=3,b=!1,x=!1,E=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function M(G){for(var se=n(f);se!==null;){if(se.callback===null)r(f);else if(se.startTime<=G)r(f),se.sortIndex=se.expirationTime,e(u,se);else break;se=n(f)}}function T(G){if(E=!1,M(G),!x)if(n(u)!==null)x=!0,ee(O);else{var se=n(f);se!==null&&he(T,se.startTime-G)}}function O(G,se){x=!1,E&&(E=!1,S(Q),Q=-1),b=!0;var ie=y;try{for(M(se),h=n(u);h!==null&&(!(h.expirationTime>se)||G&&!fe());){var R=h.callback;if(typeof R=="function"){h.callback=null,y=h.priorityLevel;var j=R(h.expirationTime<=se);se=t.unstable_now(),typeof j=="function"?h.callback=j:h===n(u)&&r(u),M(se)}else r(u);h=n(u)}if(h!==null)var le=!0;else{var ye=n(f);ye!==null&&he(T,ye.startTime-se),le=!1}return le}finally{h=null,y=ie,b=!1}}var P=!1,B=null,Q=-1,X=5,J=-1;function fe(){return!(t.unstable_now()-J<X)}function K(){if(B!==null){var G=t.unstable_now();J=G;var se=!0;try{se=B(!0,G)}finally{se?W():(P=!1,B=null)}}else P=!1}var W;if(typeof _=="function")W=function(){_(K)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,Z=$.port2;$.port1.onmessage=K,W=function(){Z.postMessage(null)}}else W=function(){w(K,0)};function ee(G){B=G,P||(P=!0,W())}function he(G,se){Q=w(function(){G(t.unstable_now())},se)}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(G){G.callback=null},t.unstable_continueExecution=function(){x||b||(x=!0,ee(O))},t.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<G?Math.floor(1e3/G):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(G){switch(y){case 1:case 2:case 3:var se=3;break;default:se=y}var ie=y;y=se;try{return G()}finally{y=ie}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(G,se){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var ie=y;y=G;try{return se()}finally{y=ie}},t.unstable_scheduleCallback=function(G,se,ie){var R=t.unstable_now();switch(typeof ie=="object"&&ie!==null?(ie=ie.delay,ie=typeof ie=="number"&&0<ie?R+ie:R):ie=R,G){case 1:var j=-1;break;case 2:j=250;break;case 5:j=1073741823;break;case 4:j=1e4;break;default:j=5e3}return j=ie+j,G={id:p++,callback:se,priorityLevel:G,startTime:ie,expirationTime:j,sortIndex:-1},ie>R?(G.sortIndex=ie,e(f,G),n(u)===null&&G===n(f)&&(E?(S(Q),Q=-1):E=!0,he(T,ie-R))):(G.sortIndex=j,e(u,G),x||b||(x=!0,ee(O))),G},t.unstable_shouldYield=fe,t.unstable_wrapCallback=function(G){var se=y;return function(){var ie=y;y=se;try{return G.apply(this,arguments)}finally{y=ie}}}})(zf)),zf}var jy;function JE(){return jy||(jy=1,Bf.exports=qE()),Bf.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 By;function YE(){if(By)return Un;By=1;var t=Wl(),e=JE();function n(o){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+o,d=1;d<arguments.length;d++)a+="&args[]="+encodeURIComponent(arguments[d]);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,i={};function s(o,a){l(o,a),l(o+"Capture",a)}function l(o,a){for(i[o]=a,o=0;o<a.length;o++)r.add(a[o])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},h={};function y(o){return u.call(h,o)?!0:u.call(p,o)?!1:f.test(o)?h[o]=!0:(p[o]=!0,!1)}function b(o,a,d,m){if(d!==null&&d.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return m?!1:d!==null?!d.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function x(o,a,d,m){if(a===null||typeof a>"u"||b(o,a,d,m))return!0;if(m)return!1;if(d!==null)switch(d.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 E(o,a,d,m,v,k,C){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=m,this.attributeNamespace=v,this.mustUseProperty=d,this.propertyName=o,this.type=a,this.sanitizeURL=k,this.removeEmptyString=C}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){w[o]=new E(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var a=o[0];w[a]=new E(a,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){w[o]=new E(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){w[o]=new E(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){w[o]=new E(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){w[o]=new E(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){w[o]=new E(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){w[o]=new E(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){w[o]=new E(o,5,!1,o.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function _(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(S,_);w[a]=new E(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(S,_);w[a]=new E(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(S,_);w[a]=new E(a,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){w[o]=new E(o,1,!1,o.toLowerCase(),null,!1,!1)}),w.xlinkHref=new E("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){w[o]=new E(o,1,!1,o.toLowerCase(),null,!0,!0)});function M(o,a,d,m){var v=w.hasOwnProperty(a)?w[a]:null;(v!==null?v.type!==0:m||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(x(a,d,v,m)&&(d=null),m||v===null?y(a)&&(d===null?o.removeAttribute(a):o.setAttribute(a,""+d)):v.mustUseProperty?o[v.propertyName]=d===null?v.type===3?!1:"":d:(a=v.attributeName,m=v.attributeNamespace,d===null?o.removeAttribute(a):(v=v.type,d=v===3||v===4&&d===!0?"":""+d,m?o.setAttributeNS(m,a,d):o.setAttribute(a,d))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,O=Symbol.for("react.element"),P=Symbol.for("react.portal"),B=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),J=Symbol.for("react.provider"),fe=Symbol.for("react.context"),K=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),he=Symbol.for("react.offscreen"),G=Symbol.iterator;function se(o){return o===null||typeof o!="object"?null:(o=G&&o[G]||o["@@iterator"],typeof o=="function"?o:null)}var ie=Object.assign,R;function j(o){if(R===void 0)try{throw Error()}catch(d){var a=d.stack.trim().match(/\n( *(at )?)/);R=a&&a[1]||""}return`
|
|
34
|
+
`+R+o}var le=!1;function ye(o,a){if(!o||le)return"";le=!0;var d=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(V){var m=V}Reflect.construct(o,[],a)}else{try{a.call()}catch(V){m=V}o.call(a.prototype)}else{try{throw Error()}catch(V){m=V}o()}}catch(V){if(V&&m&&typeof V.stack=="string"){for(var v=V.stack.split(`
|
|
35
|
+
`),k=m.stack.split(`
|
|
36
|
+
`),C=v.length-1,A=k.length-1;1<=C&&0<=A&&v[C]!==k[A];)A--;for(;1<=C&&0<=A;C--,A--)if(v[C]!==k[A]){if(C!==1||A!==1)do if(C--,A--,0>A||v[C]!==k[A]){var L=`
|
|
37
|
+
`+v[C].replace(" at new "," at ");return o.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",o.displayName)),L}while(1<=C&&0<=A);break}}}finally{le=!1,Error.prepareStackTrace=d}return(o=o?o.displayName||o.name:"")?j(o):""}function Ee(o){switch(o.tag){case 5:return j(o.type);case 16:return j("Lazy");case 13:return j("Suspense");case 19:return j("SuspenseList");case 0:case 2:case 15:return o=ye(o.type,!1),o;case 11:return o=ye(o.type.render,!1),o;case 1:return o=ye(o.type,!0),o;default:return""}}function oe(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case B:return"Fragment";case P:return"Portal";case X:return"Profiler";case Q:return"StrictMode";case W:return"Suspense";case $:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case fe:return(o.displayName||"Context")+".Consumer";case J:return(o._context.displayName||"Context")+".Provider";case K:var a=o.render;return o=o.displayName,o||(o=a.displayName||a.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case Z:return a=o.displayName||null,a!==null?a:oe(o.type)||"Memo";case ee:a=o._payload,o=o._init;try{return oe(o(a))}catch{}}return null}function z(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 oe(a);case 8:return a===Q?"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 q(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Y(o){var a=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function ne(o){var a=Y(o)?"checked":"value",d=Object.getOwnPropertyDescriptor(o.constructor.prototype,a),m=""+o[a];if(!o.hasOwnProperty(a)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var v=d.get,k=d.set;return Object.defineProperty(o,a,{configurable:!0,get:function(){return v.call(this)},set:function(C){m=""+C,k.call(this,C)}}),Object.defineProperty(o,a,{enumerable:d.enumerable}),{getValue:function(){return m},setValue:function(C){m=""+C},stopTracking:function(){o._valueTracker=null,delete o[a]}}}}function Me(o){o._valueTracker||(o._valueTracker=ne(o))}function H(o){if(!o)return!1;var a=o._valueTracker;if(!a)return!0;var d=a.getValue(),m="";return o&&(m=Y(o)?o.checked?"true":"false":o.value),o=m,o!==d?(a.setValue(o),!0):!1}function ke(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 we(o,a){var d=a.checked;return ie({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??o._wrapperState.initialChecked})}function $e(o,a){var d=a.defaultValue==null?"":a.defaultValue,m=a.checked!=null?a.checked:a.defaultChecked;d=q(a.value!=null?a.value:d),o._wrapperState={initialChecked:m,initialValue:d,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ae(o,a){a=a.checked,a!=null&&M(o,"checked",a,!1)}function je(o,a){Ae(o,a);var d=q(a.value),m=a.type;if(d!=null)m==="number"?(d===0&&o.value===""||o.value!=d)&&(o.value=""+d):o.value!==""+d&&(o.value=""+d);else if(m==="submit"||m==="reset"){o.removeAttribute("value");return}a.hasOwnProperty("value")?yn(o,a.type,d):a.hasOwnProperty("defaultValue")&&yn(o,a.type,q(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(o.defaultChecked=!!a.defaultChecked)}function ze(o,a,d){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var m=a.type;if(!(m!=="submit"&&m!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+o._wrapperState.initialValue,d||a===o.value||(o.value=a),o.defaultValue=a}d=o.name,d!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,d!==""&&(o.name=d)}function yn(o,a,d){(a!=="number"||ke(o.ownerDocument)!==o)&&(d==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+d&&(o.defaultValue=""+d))}var tt=Array.isArray;function gt(o,a,d,m){if(o=o.options,a){a={};for(var v=0;v<d.length;v++)a["$"+d[v]]=!0;for(d=0;d<o.length;d++)v=a.hasOwnProperty("$"+o[d].value),o[d].selected!==v&&(o[d].selected=v),v&&m&&(o[d].defaultSelected=!0)}else{for(d=""+q(d),a=null,v=0;v<o.length;v++){if(o[v].value===d){o[v].selected=!0,m&&(o[v].defaultSelected=!0);return}a!==null||o[v].disabled||(a=o[v])}a!==null&&(a.selected=!0)}}function et(o,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return ie({},a,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function Vn(o,a){var d=a.value;if(d==null){if(d=a.children,a=a.defaultValue,d!=null){if(a!=null)throw Error(n(92));if(tt(d)){if(1<d.length)throw Error(n(93));d=d[0]}a=d}a==null&&(a=""),d=a}o._wrapperState={initialValue:q(d)}}function Jt(o,a){var d=q(a.value),m=q(a.defaultValue);d!=null&&(d=""+d,d!==o.value&&(o.value=d),a.defaultValue==null&&o.defaultValue!==d&&(o.defaultValue=d)),m!=null&&(o.defaultValue=""+m)}function tr(o){var a=o.textContent;a===o._wrapperState.initialValue&&a!==""&&a!==null&&(o.value=a)}function Xt(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 bn(o,a){return o==null||o==="http://www.w3.org/1999/xhtml"?Xt(a):o==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Kn,Mr=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,d,m,v){MSApp.execUnsafeLocalFunction(function(){return o(a,d,m,v)})}:o})(function(o,a){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=a;else{for(Kn=Kn||document.createElement("div"),Kn.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=Kn.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;a.firstChild;)o.appendChild(a.firstChild)}});function nr(o,a){if(a){var d=o.firstChild;if(d&&d===o.lastChild&&d.nodeType===3){d.nodeValue=a;return}}o.textContent=a}var Gn={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},Ar=["Webkit","ms","Moz","O"];Object.keys(Gn).forEach(function(o){Ar.forEach(function(a){a=a+o.charAt(0).toUpperCase()+o.substring(1),Gn[a]=Gn[o]})});function gr(o,a,d){return a==null||typeof a=="boolean"||a===""?"":d||typeof a!="number"||a===0||Gn.hasOwnProperty(o)&&Gn[o]?(""+a).trim():a+"px"}function Pn(o,a){o=o.style;for(var d in a)if(a.hasOwnProperty(d)){var m=d.indexOf("--")===0,v=gr(d,a[d],m);d==="float"&&(d="cssFloat"),m?o.setProperty(d,v):o[d]=v}}var ae=ie({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 Le(o,a){if(a){if(ae[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 ft(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 Bt=null;function Ut(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var kt=null,vn=null,xn=null;function Ht(o){if(o=Jo(o)){if(typeof kt!="function")throw Error(n(280));var a=o.stateNode;a&&(a=ba(a),kt(o.stateNode,o.type,a))}}function I(o){vn?xn?xn.push(o):xn=[o]:vn=o}function te(){if(vn){var o=vn,a=xn;if(xn=vn=null,Ht(o),a)for(o=0;o<a.length;o++)Ht(a[o])}}function ve(o,a){return o(a)}function Ge(){}var wt=!1;function Nt(o,a,d){if(wt)return o(a,d);wt=!0;try{return ve(o,a,d)}finally{wt=!1,(vn!==null||xn!==null)&&(Ge(),te())}}function Ne(o,a){var d=o.stateNode;if(d===null)return null;var m=ba(d);if(m===null)return null;d=m[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":(m=!m.disabled)||(o=o.type,m=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!m;break e;default:o=!1}if(o)return null;if(d&&typeof d!="function")throw Error(n(231,a,typeof d));return d}var Ce=!1;if(c)try{var Ue={};Object.defineProperty(Ue,"passive",{get:function(){Ce=!0}}),window.addEventListener("test",Ue,Ue),window.removeEventListener("test",Ue,Ue)}catch{Ce=!1}function Wt(o,a,d,m,v,k,C,A,L){var V=Array.prototype.slice.call(arguments,3);try{a.apply(d,V)}catch(ue){this.onError(ue)}}var yt=!1,Or=null,di=!1,Zi=null,ed={onError:function(o){yt=!0,Or=o}};function Mo(o,a,d,m,v,k,C,A,L){yt=!1,Or=null,Wt.apply(ed,arguments)}function td(o,a,d,m,v,k,C,A,L){if(Mo.apply(this,arguments),yt){if(yt){var V=Or;yt=!1,Or=null}else throw Error(n(198));di||(di=!0,Zi=V)}}function Kr(o){var a=o,d=o;if(o.alternate)for(;a.return;)a=a.return;else{o=a;do a=o,(a.flags&4098)!==0&&(d=a.return),o=a.return;while(o)}return a.tag===3?d:null}function Yl(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 Ao(o){if(Kr(o)!==o)throw Error(n(188))}function Bs(o){var a=o.alternate;if(!a){if(a=Kr(o),a===null)throw Error(n(188));return a!==o?null:o}for(var d=o,m=a;;){var v=d.return;if(v===null)break;var k=v.alternate;if(k===null){if(m=v.return,m!==null){d=m;continue}break}if(v.child===k.child){for(k=v.child;k;){if(k===d)return Ao(v),o;if(k===m)return Ao(v),a;k=k.sibling}throw Error(n(188))}if(d.return!==m.return)d=v,m=k;else{for(var C=!1,A=v.child;A;){if(A===d){C=!0,d=v,m=k;break}if(A===m){C=!0,m=v,d=k;break}A=A.sibling}if(!C){for(A=k.child;A;){if(A===d){C=!0,d=k,m=v;break}if(A===m){C=!0,m=k,d=v;break}A=A.sibling}if(!C)throw Error(n(189))}}if(d.alternate!==m)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?o:a}function Ql(o){return o=Bs(o),o!==null?Xl(o):null}function Xl(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var a=Xl(o);if(a!==null)return a;o=o.sibling}return null}var Zl=e.unstable_scheduleCallback,yr=e.unstable_cancelCallback,ea=e.unstable_shouldYield,ta=e.unstable_requestPaint,Tt=e.unstable_now,nd=e.unstable_getCurrentPriorityLevel,Oo=e.unstable_ImmediatePriority,es=e.unstable_UserBlockingPriority,zs=e.unstable_NormalPriority,me=e.unstable_LowPriority,De=e.unstable_IdlePriority,Ye=null,Ze=null;function zt(o){if(Ze&&typeof Ze.onCommitFiberRoot=="function")try{Ze.onCommitFiberRoot(Ye,o,void 0,(o.current.flags&128)===128)}catch{}}var Mt=Math.clz32?Math.clz32:Mn,Rr=Math.log,Fs=Math.LN2;function Mn(o){return o>>>=0,o===0?32:31-(Rr(o)/Fs|0)|0}var An=64,ts=4194304;function fi(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 ns(o,a){var d=o.pendingLanes;if(d===0)return 0;var m=0,v=o.suspendedLanes,k=o.pingedLanes,C=d&268435455;if(C!==0){var A=C&~v;A!==0?m=fi(A):(k&=C,k!==0&&(m=fi(k)))}else C=d&~v,C!==0?m=fi(C):k!==0&&(m=fi(k));if(m===0)return 0;if(a!==0&&a!==m&&(a&v)===0&&(v=m&-m,k=a&-a,v>=k||v===16&&(k&4194240)!==0))return a;if((m&4)!==0&&(m|=d&16),a=o.entangledLanes,a!==0)for(o=o.entanglements,a&=m;0<a;)d=31-Mt(a),v=1<<d,m|=o[d],a&=~v;return m}function rd(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 id(o,a){for(var d=o.suspendedLanes,m=o.pingedLanes,v=o.expirationTimes,k=o.pendingLanes;0<k;){var C=31-Mt(k),A=1<<C,L=v[C];L===-1?((A&d)===0||(A&m)!==0)&&(v[C]=rd(A,a)):L<=a&&(o.expiredLanes|=A),k&=~A}}function Ro(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function na(){var o=An;return An<<=1,(An&4194240)===0&&(An=64),o}function pi(o){for(var a=[],d=0;31>d;d++)a.push(o);return a}function hi(o,a,d){o.pendingLanes|=a,a!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,a=31-Mt(a),o[a]=d}function rr(o,a){var d=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 m=o.eventTimes;for(o=o.expirationTimes;0<d;){var v=31-Mt(d),k=1<<v;a[v]=0,m[v]=-1,o[v]=-1,d&=~k}}function Io(o,a){var d=o.entangledLanes|=a;for(o=o.entanglements;d;){var m=31-Mt(d),v=1<<m;v&a|o[m]&a&&(o[m]|=a),d&=~v}}var rt=0;function Je(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Lo,Ft,dt,rs,Ir,is=!1,mi=[],be=null,_e=null,Ke=null,nt=new Map,Rt=new Map,Zt=[],sd="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 ra(o,a){switch(o){case"focusin":case"focusout":be=null;break;case"dragenter":case"dragleave":_e=null;break;case"mouseover":case"mouseout":Ke=null;break;case"pointerover":case"pointerout":nt.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Rt.delete(a.pointerId)}}function Do(o,a,d,m,v,k){return o===null||o.nativeEvent!==k?(o={blockedOn:a,domEventName:d,eventSystemFlags:m,nativeEvent:k,targetContainers:[v]},a!==null&&(a=Jo(a),a!==null&&Ft(a)),o):(o.eventSystemFlags|=m,a=o.targetContainers,v!==null&&a.indexOf(v)===-1&&a.push(v),o)}function h1(o,a,d,m,v){switch(a){case"focusin":return be=Do(be,o,a,d,m,v),!0;case"dragenter":return _e=Do(_e,o,a,d,m,v),!0;case"mouseover":return Ke=Do(Ke,o,a,d,m,v),!0;case"pointerover":var k=v.pointerId;return nt.set(k,Do(nt.get(k)||null,o,a,d,m,v)),!0;case"gotpointercapture":return k=v.pointerId,Rt.set(k,Do(Rt.get(k)||null,o,a,d,m,v)),!0}return!1}function gm(o){var a=ss(o.target);if(a!==null){var d=Kr(a);if(d!==null){if(a=d.tag,a===13){if(a=Yl(d),a!==null){o.blockedOn=a,Ir(o.priority,function(){dt(d)});return}}else if(a===3&&d.stateNode.current.memoizedState.isDehydrated){o.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}o.blockedOn=null}function ia(o){if(o.blockedOn!==null)return!1;for(var a=o.targetContainers;0<a.length;){var d=ld(o.domEventName,o.eventSystemFlags,a[0],o.nativeEvent);if(d===null){d=o.nativeEvent;var m=new d.constructor(d.type,d);Bt=m,d.target.dispatchEvent(m),Bt=null}else return a=Jo(d),a!==null&&Ft(a),o.blockedOn=d,!1;a.shift()}return!0}function ym(o,a,d){ia(o)&&d.delete(a)}function m1(){is=!1,be!==null&&ia(be)&&(be=null),_e!==null&&ia(_e)&&(_e=null),Ke!==null&&ia(Ke)&&(Ke=null),nt.forEach(ym),Rt.forEach(ym)}function Po(o,a){o.blockedOn===a&&(o.blockedOn=null,is||(is=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,m1)))}function jo(o){function a(v){return Po(v,o)}if(0<mi.length){Po(mi[0],o);for(var d=1;d<mi.length;d++){var m=mi[d];m.blockedOn===o&&(m.blockedOn=null)}}for(be!==null&&Po(be,o),_e!==null&&Po(_e,o),Ke!==null&&Po(Ke,o),nt.forEach(a),Rt.forEach(a),d=0;d<Zt.length;d++)m=Zt[d],m.blockedOn===o&&(m.blockedOn=null);for(;0<Zt.length&&(d=Zt[0],d.blockedOn===null);)gm(d),d.blockedOn===null&&Zt.shift()}var $s=T.ReactCurrentBatchConfig,sa=!0;function g1(o,a,d,m){var v=rt,k=$s.transition;$s.transition=null;try{rt=1,od(o,a,d,m)}finally{rt=v,$s.transition=k}}function y1(o,a,d,m){var v=rt,k=$s.transition;$s.transition=null;try{rt=4,od(o,a,d,m)}finally{rt=v,$s.transition=k}}function od(o,a,d,m){if(sa){var v=ld(o,a,d,m);if(v===null)Sd(o,a,m,oa,d),ra(o,m);else if(h1(v,o,a,d,m))m.stopPropagation();else if(ra(o,m),a&4&&-1<sd.indexOf(o)){for(;v!==null;){var k=Jo(v);if(k!==null&&Lo(k),k=ld(o,a,d,m),k===null&&Sd(o,a,m,oa,d),k===v)break;v=k}v!==null&&m.stopPropagation()}else Sd(o,a,m,null,d)}}var oa=null;function ld(o,a,d,m){if(oa=null,o=Ut(m),o=ss(o),o!==null)if(a=Kr(o),a===null)o=null;else if(d=a.tag,d===13){if(o=Yl(a),o!==null)return o;o=null}else if(d===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;o=null}else a!==o&&(o=null);return oa=o,null}function bm(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(nd()){case Oo:return 1;case es:return 4;case zs:case me:return 16;case De:return 536870912;default:return 16}default:return 16}}var gi=null,ad=null,la=null;function vm(){if(la)return la;var o,a=ad,d=a.length,m,v="value"in gi?gi.value:gi.textContent,k=v.length;for(o=0;o<d&&a[o]===v[o];o++);var C=d-o;for(m=1;m<=C&&a[d-m]===v[k-m];m++);return la=v.slice(o,1<m?1-m:void 0)}function aa(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 ca(){return!0}function xm(){return!1}function qn(o){function a(d,m,v,k,C){this._reactName=d,this._targetInst=v,this.type=m,this.nativeEvent=k,this.target=C,this.currentTarget=null;for(var A in o)o.hasOwnProperty(A)&&(d=o[A],this[A]=d?d(k):k[A]);return this.isDefaultPrevented=(k.defaultPrevented!=null?k.defaultPrevented:k.returnValue===!1)?ca:xm,this.isPropagationStopped=xm,this}return ie(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=ca)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=ca)},persist:function(){},isPersistent:ca}),a}var Us={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cd=qn(Us),Bo=ie({},Us,{view:0,detail:0}),b1=qn(Bo),ud,dd,zo,ua=ie({},Bo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:pd,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!==zo&&(zo&&o.type==="mousemove"?(ud=o.screenX-zo.screenX,dd=o.screenY-zo.screenY):dd=ud=0,zo=o),ud)},movementY:function(o){return"movementY"in o?o.movementY:dd}}),km=qn(ua),v1=ie({},ua,{dataTransfer:0}),x1=qn(v1),k1=ie({},Bo,{relatedTarget:0}),fd=qn(k1),w1=ie({},Us,{animationName:0,elapsedTime:0,pseudoElement:0}),E1=qn(w1),S1=ie({},Us,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),C1=qn(S1),N1=ie({},Us,{data:0}),wm=qn(N1),_1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},T1={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"},M1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function A1(o){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(o):(o=M1[o])?!!a[o]:!1}function pd(){return A1}var O1=ie({},Bo,{key:function(o){if(o.key){var a=_1[o.key]||o.key;if(a!=="Unidentified")return a}return o.type==="keypress"?(o=aa(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?T1[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:pd,charCode:function(o){return o.type==="keypress"?aa(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?aa(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),R1=qn(O1),I1=ie({},ua,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Em=qn(I1),L1=ie({},Bo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:pd}),D1=qn(L1),P1=ie({},Us,{propertyName:0,elapsedTime:0,pseudoElement:0}),j1=qn(P1),B1=ie({},ua,{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}),z1=qn(B1),F1=[9,13,27,32],hd=c&&"CompositionEvent"in window,Fo=null;c&&"documentMode"in document&&(Fo=document.documentMode);var $1=c&&"TextEvent"in window&&!Fo,Sm=c&&(!hd||Fo&&8<Fo&&11>=Fo),Cm=" ",Nm=!1;function _m(o,a){switch(o){case"keyup":return F1.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tm(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Hs=!1;function U1(o,a){switch(o){case"compositionend":return Tm(a);case"keypress":return a.which!==32?null:(Nm=!0,Cm);case"textInput":return o=a.data,o===Cm&&Nm?null:o;default:return null}}function H1(o,a){if(Hs)return o==="compositionend"||!hd&&_m(o,a)?(o=vm(),la=ad=gi=null,Hs=!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 Sm&&a.locale!=="ko"?null:a.data;default:return null}}var W1={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 Mm(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a==="input"?!!W1[o.type]:a==="textarea"}function Am(o,a,d,m){I(m),a=ma(a,"onChange"),0<a.length&&(d=new cd("onChange","change",null,d,m),o.push({event:d,listeners:a}))}var $o=null,Uo=null;function V1(o){qm(o,0)}function da(o){var a=qs(o);if(H(a))return o}function K1(o,a){if(o==="change")return a}var Om=!1;if(c){var md;if(c){var gd="oninput"in document;if(!gd){var Rm=document.createElement("div");Rm.setAttribute("oninput","return;"),gd=typeof Rm.oninput=="function"}md=gd}else md=!1;Om=md&&(!document.documentMode||9<document.documentMode)}function Im(){$o&&($o.detachEvent("onpropertychange",Lm),Uo=$o=null)}function Lm(o){if(o.propertyName==="value"&&da(Uo)){var a=[];Am(a,Uo,o,Ut(o)),Nt(V1,a)}}function G1(o,a,d){o==="focusin"?(Im(),$o=a,Uo=d,$o.attachEvent("onpropertychange",Lm)):o==="focusout"&&Im()}function q1(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return da(Uo)}function J1(o,a){if(o==="click")return da(a)}function Y1(o,a){if(o==="input"||o==="change")return da(a)}function Q1(o,a){return o===a&&(o!==0||1/o===1/a)||o!==o&&a!==a}var br=typeof Object.is=="function"?Object.is:Q1;function Ho(o,a){if(br(o,a))return!0;if(typeof o!="object"||o===null||typeof a!="object"||a===null)return!1;var d=Object.keys(o),m=Object.keys(a);if(d.length!==m.length)return!1;for(m=0;m<d.length;m++){var v=d[m];if(!u.call(a,v)||!br(o[v],a[v]))return!1}return!0}function Dm(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Pm(o,a){var d=Dm(o);o=0;for(var m;d;){if(d.nodeType===3){if(m=o+d.textContent.length,o<=a&&m>=a)return{node:d,offset:a-o};o=m}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Dm(d)}}function jm(o,a){return o&&a?o===a?!0:o&&o.nodeType===3?!1:a&&a.nodeType===3?jm(o,a.parentNode):"contains"in o?o.contains(a):o.compareDocumentPosition?!!(o.compareDocumentPosition(a)&16):!1:!1}function Bm(){for(var o=window,a=ke();a instanceof o.HTMLIFrameElement;){try{var d=typeof a.contentWindow.location.href=="string"}catch{d=!1}if(d)o=a.contentWindow;else break;a=ke(o.document)}return a}function yd(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 X1(o){var a=Bm(),d=o.focusedElem,m=o.selectionRange;if(a!==d&&d&&d.ownerDocument&&jm(d.ownerDocument.documentElement,d)){if(m!==null&&yd(d)){if(a=m.start,o=m.end,o===void 0&&(o=a),"selectionStart"in d)d.selectionStart=a,d.selectionEnd=Math.min(o,d.value.length);else if(o=(a=d.ownerDocument||document)&&a.defaultView||window,o.getSelection){o=o.getSelection();var v=d.textContent.length,k=Math.min(m.start,v);m=m.end===void 0?k:Math.min(m.end,v),!o.extend&&k>m&&(v=m,m=k,k=v),v=Pm(d,k);var C=Pm(d,m);v&&C&&(o.rangeCount!==1||o.anchorNode!==v.node||o.anchorOffset!==v.offset||o.focusNode!==C.node||o.focusOffset!==C.offset)&&(a=a.createRange(),a.setStart(v.node,v.offset),o.removeAllRanges(),k>m?(o.addRange(a),o.extend(C.node,C.offset)):(a.setEnd(C.node,C.offset),o.addRange(a)))}}for(a=[],o=d;o=o.parentNode;)o.nodeType===1&&a.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<a.length;d++)o=a[d],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var Z1=c&&"documentMode"in document&&11>=document.documentMode,Ws=null,bd=null,Wo=null,vd=!1;function zm(o,a,d){var m=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;vd||Ws==null||Ws!==ke(m)||(m=Ws,"selectionStart"in m&&yd(m)?m={start:m.selectionStart,end:m.selectionEnd}:(m=(m.ownerDocument&&m.ownerDocument.defaultView||window).getSelection(),m={anchorNode:m.anchorNode,anchorOffset:m.anchorOffset,focusNode:m.focusNode,focusOffset:m.focusOffset}),Wo&&Ho(Wo,m)||(Wo=m,m=ma(bd,"onSelect"),0<m.length&&(a=new cd("onSelect","select",null,a,d),o.push({event:a,listeners:m}),a.target=Ws)))}function fa(o,a){var d={};return d[o.toLowerCase()]=a.toLowerCase(),d["Webkit"+o]="webkit"+a,d["Moz"+o]="moz"+a,d}var Vs={animationend:fa("Animation","AnimationEnd"),animationiteration:fa("Animation","AnimationIteration"),animationstart:fa("Animation","AnimationStart"),transitionend:fa("Transition","TransitionEnd")},xd={},Fm={};c&&(Fm=document.createElement("div").style,"AnimationEvent"in window||(delete Vs.animationend.animation,delete Vs.animationiteration.animation,delete Vs.animationstart.animation),"TransitionEvent"in window||delete Vs.transitionend.transition);function pa(o){if(xd[o])return xd[o];if(!Vs[o])return o;var a=Vs[o],d;for(d in a)if(a.hasOwnProperty(d)&&d in Fm)return xd[o]=a[d];return o}var $m=pa("animationend"),Um=pa("animationiteration"),Hm=pa("animationstart"),Wm=pa("transitionend"),Vm=new Map,Km="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 yi(o,a){Vm.set(o,a),s(a,[o])}for(var kd=0;kd<Km.length;kd++){var wd=Km[kd],eE=wd.toLowerCase(),tE=wd[0].toUpperCase()+wd.slice(1);yi(eE,"on"+tE)}yi($m,"onAnimationEnd"),yi(Um,"onAnimationIteration"),yi(Hm,"onAnimationStart"),yi("dblclick","onDoubleClick"),yi("focusin","onFocus"),yi("focusout","onBlur"),yi(Wm,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),s("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),s("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),s("onBeforeInput",["compositionend","keypress","textInput","paste"]),s("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),s("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Vo="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(" "),nE=new Set("cancel close invalid load scroll toggle".split(" ").concat(Vo));function Gm(o,a,d){var m=o.type||"unknown-event";o.currentTarget=d,td(m,a,void 0,o),o.currentTarget=null}function qm(o,a){a=(a&4)!==0;for(var d=0;d<o.length;d++){var m=o[d],v=m.event;m=m.listeners;e:{var k=void 0;if(a)for(var C=m.length-1;0<=C;C--){var A=m[C],L=A.instance,V=A.currentTarget;if(A=A.listener,L!==k&&v.isPropagationStopped())break e;Gm(v,A,V),k=L}else for(C=0;C<m.length;C++){if(A=m[C],L=A.instance,V=A.currentTarget,A=A.listener,L!==k&&v.isPropagationStopped())break e;Gm(v,A,V),k=L}}}if(di)throw o=Zi,di=!1,Zi=null,o}function Et(o,a){var d=a[Ad];d===void 0&&(d=a[Ad]=new Set);var m=o+"__bubble";d.has(m)||(Jm(a,o,2,!1),d.add(m))}function Ed(o,a,d){var m=0;a&&(m|=4),Jm(d,o,m,a)}var ha="_reactListening"+Math.random().toString(36).slice(2);function Ko(o){if(!o[ha]){o[ha]=!0,r.forEach(function(d){d!=="selectionchange"&&(nE.has(d)||Ed(d,!1,o),Ed(d,!0,o))});var a=o.nodeType===9?o:o.ownerDocument;a===null||a[ha]||(a[ha]=!0,Ed("selectionchange",!1,a))}}function Jm(o,a,d,m){switch(bm(a)){case 1:var v=g1;break;case 4:v=y1;break;default:v=od}d=v.bind(null,a,d,o),v=void 0,!Ce||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(v=!0),m?v!==void 0?o.addEventListener(a,d,{capture:!0,passive:v}):o.addEventListener(a,d,!0):v!==void 0?o.addEventListener(a,d,{passive:v}):o.addEventListener(a,d,!1)}function Sd(o,a,d,m,v){var k=m;if((a&1)===0&&(a&2)===0&&m!==null)e:for(;;){if(m===null)return;var C=m.tag;if(C===3||C===4){var A=m.stateNode.containerInfo;if(A===v||A.nodeType===8&&A.parentNode===v)break;if(C===4)for(C=m.return;C!==null;){var L=C.tag;if((L===3||L===4)&&(L=C.stateNode.containerInfo,L===v||L.nodeType===8&&L.parentNode===v))return;C=C.return}for(;A!==null;){if(C=ss(A),C===null)return;if(L=C.tag,L===5||L===6){m=k=C;continue e}A=A.parentNode}}m=m.return}Nt(function(){var V=k,ue=Ut(d),de=[];e:{var ce=Vm.get(o);if(ce!==void 0){var Se=cd,Oe=o;switch(o){case"keypress":if(aa(d)===0)break e;case"keydown":case"keyup":Se=R1;break;case"focusin":Oe="focus",Se=fd;break;case"focusout":Oe="blur",Se=fd;break;case"beforeblur":case"afterblur":Se=fd;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Se=km;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=x1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=D1;break;case $m:case Um:case Hm:Se=E1;break;case Wm:Se=j1;break;case"scroll":Se=b1;break;case"wheel":Se=z1;break;case"copy":case"cut":case"paste":Se=C1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=Em}var Re=(a&4)!==0,$t=!Re&&o==="scroll",F=Re?ce!==null?ce+"Capture":null:ce;Re=[];for(var D=V,U;D!==null;){U=D;var ge=U.stateNode;if(U.tag===5&&ge!==null&&(U=ge,F!==null&&(ge=Ne(D,F),ge!=null&&Re.push(Go(D,ge,U)))),$t)break;D=D.return}0<Re.length&&(ce=new Se(ce,Oe,null,d,ue),de.push({event:ce,listeners:Re}))}}if((a&7)===0){e:{if(ce=o==="mouseover"||o==="pointerover",Se=o==="mouseout"||o==="pointerout",ce&&d!==Bt&&(Oe=d.relatedTarget||d.fromElement)&&(ss(Oe)||Oe[Gr]))break e;if((Se||ce)&&(ce=ue.window===ue?ue:(ce=ue.ownerDocument)?ce.defaultView||ce.parentWindow:window,Se?(Oe=d.relatedTarget||d.toElement,Se=V,Oe=Oe?ss(Oe):null,Oe!==null&&($t=Kr(Oe),Oe!==$t||Oe.tag!==5&&Oe.tag!==6)&&(Oe=null)):(Se=null,Oe=V),Se!==Oe)){if(Re=km,ge="onMouseLeave",F="onMouseEnter",D="mouse",(o==="pointerout"||o==="pointerover")&&(Re=Em,ge="onPointerLeave",F="onPointerEnter",D="pointer"),$t=Se==null?ce:qs(Se),U=Oe==null?ce:qs(Oe),ce=new Re(ge,D+"leave",Se,d,ue),ce.target=$t,ce.relatedTarget=U,ge=null,ss(ue)===V&&(Re=new Re(F,D+"enter",Oe,d,ue),Re.target=U,Re.relatedTarget=$t,ge=Re),$t=ge,Se&&Oe)t:{for(Re=Se,F=Oe,D=0,U=Re;U;U=Ks(U))D++;for(U=0,ge=F;ge;ge=Ks(ge))U++;for(;0<D-U;)Re=Ks(Re),D--;for(;0<U-D;)F=Ks(F),U--;for(;D--;){if(Re===F||F!==null&&Re===F.alternate)break t;Re=Ks(Re),F=Ks(F)}Re=null}else Re=null;Se!==null&&Ym(de,ce,Se,Re,!1),Oe!==null&&$t!==null&&Ym(de,$t,Oe,Re,!0)}}e:{if(ce=V?qs(V):window,Se=ce.nodeName&&ce.nodeName.toLowerCase(),Se==="select"||Se==="input"&&ce.type==="file")var Ie=K1;else if(Mm(ce))if(Om)Ie=Y1;else{Ie=q1;var He=G1}else(Se=ce.nodeName)&&Se.toLowerCase()==="input"&&(ce.type==="checkbox"||ce.type==="radio")&&(Ie=J1);if(Ie&&(Ie=Ie(o,V))){Am(de,Ie,d,ue);break e}He&&He(o,ce,V),o==="focusout"&&(He=ce._wrapperState)&&He.controlled&&ce.type==="number"&&yn(ce,"number",ce.value)}switch(He=V?qs(V):window,o){case"focusin":(Mm(He)||He.contentEditable==="true")&&(Ws=He,bd=V,Wo=null);break;case"focusout":Wo=bd=Ws=null;break;case"mousedown":vd=!0;break;case"contextmenu":case"mouseup":case"dragend":vd=!1,zm(de,d,ue);break;case"selectionchange":if(Z1)break;case"keydown":case"keyup":zm(de,d,ue)}var We;if(hd)e:{switch(o){case"compositionstart":var qe="onCompositionStart";break e;case"compositionend":qe="onCompositionEnd";break e;case"compositionupdate":qe="onCompositionUpdate";break e}qe=void 0}else Hs?_m(o,d)&&(qe="onCompositionEnd"):o==="keydown"&&d.keyCode===229&&(qe="onCompositionStart");qe&&(Sm&&d.locale!=="ko"&&(Hs||qe!=="onCompositionStart"?qe==="onCompositionEnd"&&Hs&&(We=vm()):(gi=ue,ad="value"in gi?gi.value:gi.textContent,Hs=!0)),He=ma(V,qe),0<He.length&&(qe=new wm(qe,o,null,d,ue),de.push({event:qe,listeners:He}),We?qe.data=We:(We=Tm(d),We!==null&&(qe.data=We)))),(We=$1?U1(o,d):H1(o,d))&&(V=ma(V,"onBeforeInput"),0<V.length&&(ue=new wm("onBeforeInput","beforeinput",null,d,ue),de.push({event:ue,listeners:V}),ue.data=We))}qm(de,a)})}function Go(o,a,d){return{instance:o,listener:a,currentTarget:d}}function ma(o,a){for(var d=a+"Capture",m=[];o!==null;){var v=o,k=v.stateNode;v.tag===5&&k!==null&&(v=k,k=Ne(o,d),k!=null&&m.unshift(Go(o,k,v)),k=Ne(o,a),k!=null&&m.push(Go(o,k,v))),o=o.return}return m}function Ks(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function Ym(o,a,d,m,v){for(var k=a._reactName,C=[];d!==null&&d!==m;){var A=d,L=A.alternate,V=A.stateNode;if(L!==null&&L===m)break;A.tag===5&&V!==null&&(A=V,v?(L=Ne(d,k),L!=null&&C.unshift(Go(d,L,A))):v||(L=Ne(d,k),L!=null&&C.push(Go(d,L,A)))),d=d.return}C.length!==0&&o.push({event:a,listeners:C})}var rE=/\r\n?/g,iE=/\u0000|\uFFFD/g;function Qm(o){return(typeof o=="string"?o:""+o).replace(rE,`
|
|
38
|
+
`).replace(iE,"")}function ga(o,a,d){if(a=Qm(a),Qm(o)!==a&&d)throw Error(n(425))}function ya(){}var Cd=null,Nd=null;function _d(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 Td=typeof setTimeout=="function"?setTimeout:void 0,sE=typeof clearTimeout=="function"?clearTimeout:void 0,Xm=typeof Promise=="function"?Promise:void 0,oE=typeof queueMicrotask=="function"?queueMicrotask:typeof Xm<"u"?function(o){return Xm.resolve(null).then(o).catch(lE)}:Td;function lE(o){setTimeout(function(){throw o})}function Md(o,a){var d=a,m=0;do{var v=d.nextSibling;if(o.removeChild(d),v&&v.nodeType===8)if(d=v.data,d==="/$"){if(m===0){o.removeChild(v),jo(a);return}m--}else d!=="$"&&d!=="$?"&&d!=="$!"||m++;d=v}while(d);jo(a)}function bi(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 Zm(o){o=o.previousSibling;for(var a=0;o;){if(o.nodeType===8){var d=o.data;if(d==="$"||d==="$!"||d==="$?"){if(a===0)return o;a--}else d==="/$"&&a++}o=o.previousSibling}return null}var Gs=Math.random().toString(36).slice(2),Lr="__reactFiber$"+Gs,qo="__reactProps$"+Gs,Gr="__reactContainer$"+Gs,Ad="__reactEvents$"+Gs,aE="__reactListeners$"+Gs,cE="__reactHandles$"+Gs;function ss(o){var a=o[Lr];if(a)return a;for(var d=o.parentNode;d;){if(a=d[Gr]||d[Lr]){if(d=a.alternate,a.child!==null||d!==null&&d.child!==null)for(o=Zm(o);o!==null;){if(d=o[Lr])return d;o=Zm(o)}return a}o=d,d=o.parentNode}return null}function Jo(o){return o=o[Lr]||o[Gr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function qs(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(n(33))}function ba(o){return o[qo]||null}var Od=[],Js=-1;function vi(o){return{current:o}}function St(o){0>Js||(o.current=Od[Js],Od[Js]=null,Js--)}function bt(o,a){Js++,Od[Js]=o.current,o.current=a}var xi={},kn=vi(xi),jn=vi(!1),ls=xi;function Ys(o,a){var d=o.type.contextTypes;if(!d)return xi;var m=o.stateNode;if(m&&m.__reactInternalMemoizedUnmaskedChildContext===a)return m.__reactInternalMemoizedMaskedChildContext;var v={},k;for(k in d)v[k]=a[k];return m&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=a,o.__reactInternalMemoizedMaskedChildContext=v),v}function Bn(o){return o=o.childContextTypes,o!=null}function va(){St(jn),St(kn)}function eg(o,a,d){if(kn.current!==xi)throw Error(n(168));bt(kn,a),bt(jn,d)}function tg(o,a,d){var m=o.stateNode;if(a=a.childContextTypes,typeof m.getChildContext!="function")return d;m=m.getChildContext();for(var v in m)if(!(v in a))throw Error(n(108,z(o)||"Unknown",v));return ie({},d,m)}function xa(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||xi,ls=kn.current,bt(kn,o),bt(jn,jn.current),!0}function ng(o,a,d){var m=o.stateNode;if(!m)throw Error(n(169));d?(o=tg(o,a,ls),m.__reactInternalMemoizedMergedChildContext=o,St(jn),St(kn),bt(kn,o)):St(jn),bt(jn,d)}var qr=null,ka=!1,Rd=!1;function rg(o){qr===null?qr=[o]:qr.push(o)}function uE(o){ka=!0,rg(o)}function ki(){if(!Rd&&qr!==null){Rd=!0;var o=0,a=rt;try{var d=qr;for(rt=1;o<d.length;o++){var m=d[o];do m=m(!0);while(m!==null)}qr=null,ka=!1}catch(v){throw qr!==null&&(qr=qr.slice(o+1)),Zl(Oo,ki),v}finally{rt=a,Rd=!1}}return null}var Qs=[],Xs=0,wa=null,Ea=0,ir=[],sr=0,as=null,Jr=1,Yr="";function cs(o,a){Qs[Xs++]=Ea,Qs[Xs++]=wa,wa=o,Ea=a}function ig(o,a,d){ir[sr++]=Jr,ir[sr++]=Yr,ir[sr++]=as,as=o;var m=Jr;o=Yr;var v=32-Mt(m)-1;m&=~(1<<v),d+=1;var k=32-Mt(a)+v;if(30<k){var C=v-v%5;k=(m&(1<<C)-1).toString(32),m>>=C,v-=C,Jr=1<<32-Mt(a)+v|d<<v|m,Yr=k+o}else Jr=1<<k|d<<v|m,Yr=o}function Id(o){o.return!==null&&(cs(o,1),ig(o,1,0))}function Ld(o){for(;o===wa;)wa=Qs[--Xs],Qs[Xs]=null,Ea=Qs[--Xs],Qs[Xs]=null;for(;o===as;)as=ir[--sr],ir[sr]=null,Yr=ir[--sr],ir[sr]=null,Jr=ir[--sr],ir[sr]=null}var Jn=null,Yn=null,_t=!1,vr=null;function sg(o,a){var d=cr(5,null,null,0);d.elementType="DELETED",d.stateNode=a,d.return=o,a=o.deletions,a===null?(o.deletions=[d],o.flags|=16):a.push(d)}function og(o,a){switch(o.tag){case 5:var d=o.type;return a=a.nodeType!==1||d.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(o.stateNode=a,Jn=o,Yn=bi(a.firstChild),!0):!1;case 6:return a=o.pendingProps===""||a.nodeType!==3?null:a,a!==null?(o.stateNode=a,Jn=o,Yn=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(d=as!==null?{id:Jr,overflow:Yr}:null,o.memoizedState={dehydrated:a,treeContext:d,retryLane:1073741824},d=cr(18,null,null,0),d.stateNode=a,d.return=o,o.child=d,Jn=o,Yn=null,!0):!1;default:return!1}}function Dd(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Pd(o){if(_t){var a=Yn;if(a){var d=a;if(!og(o,a)){if(Dd(o))throw Error(n(418));a=bi(d.nextSibling);var m=Jn;a&&og(o,a)?sg(m,d):(o.flags=o.flags&-4097|2,_t=!1,Jn=o)}}else{if(Dd(o))throw Error(n(418));o.flags=o.flags&-4097|2,_t=!1,Jn=o}}}function lg(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;Jn=o}function Sa(o){if(o!==Jn)return!1;if(!_t)return lg(o),_t=!0,!1;var a;if((a=o.tag!==3)&&!(a=o.tag!==5)&&(a=o.type,a=a!=="head"&&a!=="body"&&!_d(o.type,o.memoizedProps)),a&&(a=Yn)){if(Dd(o))throw ag(),Error(n(418));for(;a;)sg(o,a),a=bi(a.nextSibling)}if(lg(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 d=o.data;if(d==="/$"){if(a===0){Yn=bi(o.nextSibling);break e}a--}else d!=="$"&&d!=="$!"&&d!=="$?"||a++}o=o.nextSibling}Yn=null}}else Yn=Jn?bi(o.stateNode.nextSibling):null;return!0}function ag(){for(var o=Yn;o;)o=bi(o.nextSibling)}function Zs(){Yn=Jn=null,_t=!1}function jd(o){vr===null?vr=[o]:vr.push(o)}var dE=T.ReactCurrentBatchConfig;function Yo(o,a,d){if(o=d.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var m=d.stateNode}if(!m)throw Error(n(147,o));var v=m,k=""+o;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===k?a.ref:(a=function(C){var A=v.refs;C===null?delete A[k]:A[k]=C},a._stringRef=k,a)}if(typeof o!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,o))}return o}function Ca(o,a){throw o=Object.prototype.toString.call(a),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":o))}function cg(o){var a=o._init;return a(o._payload)}function ug(o){function a(F,D){if(o){var U=F.deletions;U===null?(F.deletions=[D],F.flags|=16):U.push(D)}}function d(F,D){if(!o)return null;for(;D!==null;)a(F,D),D=D.sibling;return null}function m(F,D){for(F=new Map;D!==null;)D.key!==null?F.set(D.key,D):F.set(D.index,D),D=D.sibling;return F}function v(F,D){return F=Mi(F,D),F.index=0,F.sibling=null,F}function k(F,D,U){return F.index=U,o?(U=F.alternate,U!==null?(U=U.index,U<D?(F.flags|=2,D):U):(F.flags|=2,D)):(F.flags|=1048576,D)}function C(F){return o&&F.alternate===null&&(F.flags|=2),F}function A(F,D,U,ge){return D===null||D.tag!==6?(D=Mf(U,F.mode,ge),D.return=F,D):(D=v(D,U),D.return=F,D)}function L(F,D,U,ge){var Ie=U.type;return Ie===B?ue(F,D,U.props.children,ge,U.key):D!==null&&(D.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===ee&&cg(Ie)===D.type)?(ge=v(D,U.props),ge.ref=Yo(F,D,U),ge.return=F,ge):(ge=Ja(U.type,U.key,U.props,null,F.mode,ge),ge.ref=Yo(F,D,U),ge.return=F,ge)}function V(F,D,U,ge){return D===null||D.tag!==4||D.stateNode.containerInfo!==U.containerInfo||D.stateNode.implementation!==U.implementation?(D=Af(U,F.mode,ge),D.return=F,D):(D=v(D,U.children||[]),D.return=F,D)}function ue(F,D,U,ge,Ie){return D===null||D.tag!==7?(D=ys(U,F.mode,ge,Ie),D.return=F,D):(D=v(D,U),D.return=F,D)}function de(F,D,U){if(typeof D=="string"&&D!==""||typeof D=="number")return D=Mf(""+D,F.mode,U),D.return=F,D;if(typeof D=="object"&&D!==null){switch(D.$$typeof){case O:return U=Ja(D.type,D.key,D.props,null,F.mode,U),U.ref=Yo(F,null,D),U.return=F,U;case P:return D=Af(D,F.mode,U),D.return=F,D;case ee:var ge=D._init;return de(F,ge(D._payload),U)}if(tt(D)||se(D))return D=ys(D,F.mode,U,null),D.return=F,D;Ca(F,D)}return null}function ce(F,D,U,ge){var Ie=D!==null?D.key:null;if(typeof U=="string"&&U!==""||typeof U=="number")return Ie!==null?null:A(F,D,""+U,ge);if(typeof U=="object"&&U!==null){switch(U.$$typeof){case O:return U.key===Ie?L(F,D,U,ge):null;case P:return U.key===Ie?V(F,D,U,ge):null;case ee:return Ie=U._init,ce(F,D,Ie(U._payload),ge)}if(tt(U)||se(U))return Ie!==null?null:ue(F,D,U,ge,null);Ca(F,U)}return null}function Se(F,D,U,ge,Ie){if(typeof ge=="string"&&ge!==""||typeof ge=="number")return F=F.get(U)||null,A(D,F,""+ge,Ie);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case O:return F=F.get(ge.key===null?U:ge.key)||null,L(D,F,ge,Ie);case P:return F=F.get(ge.key===null?U:ge.key)||null,V(D,F,ge,Ie);case ee:var He=ge._init;return Se(F,D,U,He(ge._payload),Ie)}if(tt(ge)||se(ge))return F=F.get(U)||null,ue(D,F,ge,Ie,null);Ca(D,ge)}return null}function Oe(F,D,U,ge){for(var Ie=null,He=null,We=D,qe=D=0,nn=null;We!==null&&qe<U.length;qe++){We.index>qe?(nn=We,We=null):nn=We.sibling;var ot=ce(F,We,U[qe],ge);if(ot===null){We===null&&(We=nn);break}o&&We&&ot.alternate===null&&a(F,We),D=k(ot,D,qe),He===null?Ie=ot:He.sibling=ot,He=ot,We=nn}if(qe===U.length)return d(F,We),_t&&cs(F,qe),Ie;if(We===null){for(;qe<U.length;qe++)We=de(F,U[qe],ge),We!==null&&(D=k(We,D,qe),He===null?Ie=We:He.sibling=We,He=We);return _t&&cs(F,qe),Ie}for(We=m(F,We);qe<U.length;qe++)nn=Se(We,F,qe,U[qe],ge),nn!==null&&(o&&nn.alternate!==null&&We.delete(nn.key===null?qe:nn.key),D=k(nn,D,qe),He===null?Ie=nn:He.sibling=nn,He=nn);return o&&We.forEach(function(Ai){return a(F,Ai)}),_t&&cs(F,qe),Ie}function Re(F,D,U,ge){var Ie=se(U);if(typeof Ie!="function")throw Error(n(150));if(U=Ie.call(U),U==null)throw Error(n(151));for(var He=Ie=null,We=D,qe=D=0,nn=null,ot=U.next();We!==null&&!ot.done;qe++,ot=U.next()){We.index>qe?(nn=We,We=null):nn=We.sibling;var Ai=ce(F,We,ot.value,ge);if(Ai===null){We===null&&(We=nn);break}o&&We&&Ai.alternate===null&&a(F,We),D=k(Ai,D,qe),He===null?Ie=Ai:He.sibling=Ai,He=Ai,We=nn}if(ot.done)return d(F,We),_t&&cs(F,qe),Ie;if(We===null){for(;!ot.done;qe++,ot=U.next())ot=de(F,ot.value,ge),ot!==null&&(D=k(ot,D,qe),He===null?Ie=ot:He.sibling=ot,He=ot);return _t&&cs(F,qe),Ie}for(We=m(F,We);!ot.done;qe++,ot=U.next())ot=Se(We,F,qe,ot.value,ge),ot!==null&&(o&&ot.alternate!==null&&We.delete(ot.key===null?qe:ot.key),D=k(ot,D,qe),He===null?Ie=ot:He.sibling=ot,He=ot);return o&&We.forEach(function(WE){return a(F,WE)}),_t&&cs(F,qe),Ie}function $t(F,D,U,ge){if(typeof U=="object"&&U!==null&&U.type===B&&U.key===null&&(U=U.props.children),typeof U=="object"&&U!==null){switch(U.$$typeof){case O:e:{for(var Ie=U.key,He=D;He!==null;){if(He.key===Ie){if(Ie=U.type,Ie===B){if(He.tag===7){d(F,He.sibling),D=v(He,U.props.children),D.return=F,F=D;break e}}else if(He.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===ee&&cg(Ie)===He.type){d(F,He.sibling),D=v(He,U.props),D.ref=Yo(F,He,U),D.return=F,F=D;break e}d(F,He);break}else a(F,He);He=He.sibling}U.type===B?(D=ys(U.props.children,F.mode,ge,U.key),D.return=F,F=D):(ge=Ja(U.type,U.key,U.props,null,F.mode,ge),ge.ref=Yo(F,D,U),ge.return=F,F=ge)}return C(F);case P:e:{for(He=U.key;D!==null;){if(D.key===He)if(D.tag===4&&D.stateNode.containerInfo===U.containerInfo&&D.stateNode.implementation===U.implementation){d(F,D.sibling),D=v(D,U.children||[]),D.return=F,F=D;break e}else{d(F,D);break}else a(F,D);D=D.sibling}D=Af(U,F.mode,ge),D.return=F,F=D}return C(F);case ee:return He=U._init,$t(F,D,He(U._payload),ge)}if(tt(U))return Oe(F,D,U,ge);if(se(U))return Re(F,D,U,ge);Ca(F,U)}return typeof U=="string"&&U!==""||typeof U=="number"?(U=""+U,D!==null&&D.tag===6?(d(F,D.sibling),D=v(D,U),D.return=F,F=D):(d(F,D),D=Mf(U,F.mode,ge),D.return=F,F=D),C(F)):d(F,D)}return $t}var eo=ug(!0),dg=ug(!1),Na=vi(null),_a=null,to=null,Bd=null;function zd(){Bd=to=_a=null}function Fd(o){var a=Na.current;St(Na),o._currentValue=a}function $d(o,a,d){for(;o!==null;){var m=o.alternate;if((o.childLanes&a)!==a?(o.childLanes|=a,m!==null&&(m.childLanes|=a)):m!==null&&(m.childLanes&a)!==a&&(m.childLanes|=a),o===d)break;o=o.return}}function no(o,a){_a=o,Bd=to=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&a)!==0&&(zn=!0),o.firstContext=null)}function or(o){var a=o._currentValue;if(Bd!==o)if(o={context:o,memoizedValue:a,next:null},to===null){if(_a===null)throw Error(n(308));to=o,_a.dependencies={lanes:0,firstContext:o}}else to=to.next=o;return a}var us=null;function Ud(o){us===null?us=[o]:us.push(o)}function fg(o,a,d,m){var v=a.interleaved;return v===null?(d.next=d,Ud(a)):(d.next=v.next,v.next=d),a.interleaved=d,Qr(o,m)}function Qr(o,a){o.lanes|=a;var d=o.alternate;for(d!==null&&(d.lanes|=a),d=o,o=o.return;o!==null;)o.childLanes|=a,d=o.alternate,d!==null&&(d.childLanes|=a),d=o,o=o.return;return d.tag===3?d.stateNode:null}var wi=!1;function Hd(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function pg(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 Ei(o,a,d){var m=o.updateQueue;if(m===null)return null;if(m=m.shared,(it&2)!==0){var v=m.pending;return v===null?a.next=a:(a.next=v.next,v.next=a),m.pending=a,Qr(o,d)}return v=m.interleaved,v===null?(a.next=a,Ud(m)):(a.next=v.next,v.next=a),m.interleaved=a,Qr(o,d)}function Ta(o,a,d){if(a=a.updateQueue,a!==null&&(a=a.shared,(d&4194240)!==0)){var m=a.lanes;m&=o.pendingLanes,d|=m,a.lanes=d,Io(o,d)}}function hg(o,a){var d=o.updateQueue,m=o.alternate;if(m!==null&&(m=m.updateQueue,d===m)){var v=null,k=null;if(d=d.firstBaseUpdate,d!==null){do{var C={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};k===null?v=k=C:k=k.next=C,d=d.next}while(d!==null);k===null?v=k=a:k=k.next=a}else v=k=a;d={baseState:m.baseState,firstBaseUpdate:v,lastBaseUpdate:k,shared:m.shared,effects:m.effects},o.updateQueue=d;return}o=d.lastBaseUpdate,o===null?d.firstBaseUpdate=a:o.next=a,d.lastBaseUpdate=a}function Ma(o,a,d,m){var v=o.updateQueue;wi=!1;var k=v.firstBaseUpdate,C=v.lastBaseUpdate,A=v.shared.pending;if(A!==null){v.shared.pending=null;var L=A,V=L.next;L.next=null,C===null?k=V:C.next=V,C=L;var ue=o.alternate;ue!==null&&(ue=ue.updateQueue,A=ue.lastBaseUpdate,A!==C&&(A===null?ue.firstBaseUpdate=V:A.next=V,ue.lastBaseUpdate=L))}if(k!==null){var de=v.baseState;C=0,ue=V=L=null,A=k;do{var ce=A.lane,Se=A.eventTime;if((m&ce)===ce){ue!==null&&(ue=ue.next={eventTime:Se,lane:0,tag:A.tag,payload:A.payload,callback:A.callback,next:null});e:{var Oe=o,Re=A;switch(ce=a,Se=d,Re.tag){case 1:if(Oe=Re.payload,typeof Oe=="function"){de=Oe.call(Se,de,ce);break e}de=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Re.payload,ce=typeof Oe=="function"?Oe.call(Se,de,ce):Oe,ce==null)break e;de=ie({},de,ce);break e;case 2:wi=!0}}A.callback!==null&&A.lane!==0&&(o.flags|=64,ce=v.effects,ce===null?v.effects=[A]:ce.push(A))}else Se={eventTime:Se,lane:ce,tag:A.tag,payload:A.payload,callback:A.callback,next:null},ue===null?(V=ue=Se,L=de):ue=ue.next=Se,C|=ce;if(A=A.next,A===null){if(A=v.shared.pending,A===null)break;ce=A,A=ce.next,ce.next=null,v.lastBaseUpdate=ce,v.shared.pending=null}}while(!0);if(ue===null&&(L=de),v.baseState=L,v.firstBaseUpdate=V,v.lastBaseUpdate=ue,a=v.shared.interleaved,a!==null){v=a;do C|=v.lane,v=v.next;while(v!==a)}else k===null&&(v.shared.lanes=0);ps|=C,o.lanes=C,o.memoizedState=de}}function mg(o,a,d){if(o=a.effects,a.effects=null,o!==null)for(a=0;a<o.length;a++){var m=o[a],v=m.callback;if(v!==null){if(m.callback=null,m=d,typeof v!="function")throw Error(n(191,v));v.call(m)}}}var Qo={},Dr=vi(Qo),Xo=vi(Qo),Zo=vi(Qo);function ds(o){if(o===Qo)throw Error(n(174));return o}function Wd(o,a){switch(bt(Zo,a),bt(Xo,o),bt(Dr,Qo),o=a.nodeType,o){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:bn(null,"");break;default:o=o===8?a.parentNode:a,a=o.namespaceURI||null,o=o.tagName,a=bn(a,o)}St(Dr),bt(Dr,a)}function ro(){St(Dr),St(Xo),St(Zo)}function gg(o){ds(Zo.current);var a=ds(Dr.current),d=bn(a,o.type);a!==d&&(bt(Xo,o),bt(Dr,d))}function Vd(o){Xo.current===o&&(St(Dr),St(Xo))}var At=vi(0);function Aa(o){for(var a=o;a!==null;){if(a.tag===13){var d=a.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.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 Kd=[];function Gd(){for(var o=0;o<Kd.length;o++)Kd[o]._workInProgressVersionPrimary=null;Kd.length=0}var Oa=T.ReactCurrentDispatcher,qd=T.ReactCurrentBatchConfig,fs=0,Ot=null,Yt=null,en=null,Ra=!1,el=!1,tl=0,fE=0;function wn(){throw Error(n(321))}function Jd(o,a){if(a===null)return!1;for(var d=0;d<a.length&&d<o.length;d++)if(!br(o[d],a[d]))return!1;return!0}function Yd(o,a,d,m,v,k){if(fs=k,Ot=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Oa.current=o===null||o.memoizedState===null?gE:yE,o=d(m,v),el){k=0;do{if(el=!1,tl=0,25<=k)throw Error(n(301));k+=1,en=Yt=null,a.updateQueue=null,Oa.current=bE,o=d(m,v)}while(el)}if(Oa.current=Da,a=Yt!==null&&Yt.next!==null,fs=0,en=Yt=Ot=null,Ra=!1,a)throw Error(n(300));return o}function Qd(){var o=tl!==0;return tl=0,o}function Pr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return en===null?Ot.memoizedState=en=o:en=en.next=o,en}function lr(){if(Yt===null){var o=Ot.alternate;o=o!==null?o.memoizedState:null}else o=Yt.next;var a=en===null?Ot.memoizedState:en.next;if(a!==null)en=a,Yt=o;else{if(o===null)throw Error(n(310));Yt=o,o={memoizedState:Yt.memoizedState,baseState:Yt.baseState,baseQueue:Yt.baseQueue,queue:Yt.queue,next:null},en===null?Ot.memoizedState=en=o:en=en.next=o}return en}function nl(o,a){return typeof a=="function"?a(o):a}function Xd(o){var a=lr(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=o;var m=Yt,v=m.baseQueue,k=d.pending;if(k!==null){if(v!==null){var C=v.next;v.next=k.next,k.next=C}m.baseQueue=v=k,d.pending=null}if(v!==null){k=v.next,m=m.baseState;var A=C=null,L=null,V=k;do{var ue=V.lane;if((fs&ue)===ue)L!==null&&(L=L.next={lane:0,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null}),m=V.hasEagerState?V.eagerState:o(m,V.action);else{var de={lane:ue,action:V.action,hasEagerState:V.hasEagerState,eagerState:V.eagerState,next:null};L===null?(A=L=de,C=m):L=L.next=de,Ot.lanes|=ue,ps|=ue}V=V.next}while(V!==null&&V!==k);L===null?C=m:L.next=A,br(m,a.memoizedState)||(zn=!0),a.memoizedState=m,a.baseState=C,a.baseQueue=L,d.lastRenderedState=m}if(o=d.interleaved,o!==null){v=o;do k=v.lane,Ot.lanes|=k,ps|=k,v=v.next;while(v!==o)}else v===null&&(d.lanes=0);return[a.memoizedState,d.dispatch]}function Zd(o){var a=lr(),d=a.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=o;var m=d.dispatch,v=d.pending,k=a.memoizedState;if(v!==null){d.pending=null;var C=v=v.next;do k=o(k,C.action),C=C.next;while(C!==v);br(k,a.memoizedState)||(zn=!0),a.memoizedState=k,a.baseQueue===null&&(a.baseState=k),d.lastRenderedState=k}return[k,m]}function yg(){}function bg(o,a){var d=Ot,m=lr(),v=a(),k=!br(m.memoizedState,v);if(k&&(m.memoizedState=v,zn=!0),m=m.queue,ef(kg.bind(null,d,m,o),[o]),m.getSnapshot!==a||k||en!==null&&en.memoizedState.tag&1){if(d.flags|=2048,rl(9,xg.bind(null,d,m,v,a),void 0,null),tn===null)throw Error(n(349));(fs&30)!==0||vg(d,a,v)}return v}function vg(o,a,d){o.flags|=16384,o={getSnapshot:a,value:d},a=Ot.updateQueue,a===null?(a={lastEffect:null,stores:null},Ot.updateQueue=a,a.stores=[o]):(d=a.stores,d===null?a.stores=[o]:d.push(o))}function xg(o,a,d,m){a.value=d,a.getSnapshot=m,wg(a)&&Eg(o)}function kg(o,a,d){return d(function(){wg(a)&&Eg(o)})}function wg(o){var a=o.getSnapshot;o=o.value;try{var d=a();return!br(o,d)}catch{return!0}}function Eg(o){var a=Qr(o,1);a!==null&&Er(a,o,1,-1)}function Sg(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:nl,lastRenderedState:o},a.queue=o,o=o.dispatch=mE.bind(null,Ot,o),[a.memoizedState,o]}function rl(o,a,d,m){return o={tag:o,create:a,destroy:d,deps:m,next:null},a=Ot.updateQueue,a===null?(a={lastEffect:null,stores:null},Ot.updateQueue=a,a.lastEffect=o.next=o):(d=a.lastEffect,d===null?a.lastEffect=o.next=o:(m=d.next,d.next=o,o.next=m,a.lastEffect=o)),o}function Cg(){return lr().memoizedState}function Ia(o,a,d,m){var v=Pr();Ot.flags|=o,v.memoizedState=rl(1|a,d,void 0,m===void 0?null:m)}function La(o,a,d,m){var v=lr();m=m===void 0?null:m;var k=void 0;if(Yt!==null){var C=Yt.memoizedState;if(k=C.destroy,m!==null&&Jd(m,C.deps)){v.memoizedState=rl(a,d,k,m);return}}Ot.flags|=o,v.memoizedState=rl(1|a,d,k,m)}function Ng(o,a){return Ia(8390656,8,o,a)}function ef(o,a){return La(2048,8,o,a)}function _g(o,a){return La(4,2,o,a)}function Tg(o,a){return La(4,4,o,a)}function Mg(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 Ag(o,a,d){return d=d!=null?d.concat([o]):null,La(4,4,Mg.bind(null,a,o),d)}function tf(){}function Og(o,a){var d=lr();a=a===void 0?null:a;var m=d.memoizedState;return m!==null&&a!==null&&Jd(a,m[1])?m[0]:(d.memoizedState=[o,a],o)}function Rg(o,a){var d=lr();a=a===void 0?null:a;var m=d.memoizedState;return m!==null&&a!==null&&Jd(a,m[1])?m[0]:(o=o(),d.memoizedState=[o,a],o)}function Ig(o,a,d){return(fs&21)===0?(o.baseState&&(o.baseState=!1,zn=!0),o.memoizedState=d):(br(d,a)||(d=na(),Ot.lanes|=d,ps|=d,o.baseState=!0),a)}function pE(o,a){var d=rt;rt=d!==0&&4>d?d:4,o(!0);var m=qd.transition;qd.transition={};try{o(!1),a()}finally{rt=d,qd.transition=m}}function Lg(){return lr().memoizedState}function hE(o,a,d){var m=_i(o);if(d={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null},Dg(o))Pg(a,d);else if(d=fg(o,a,d,m),d!==null){var v=Rn();Er(d,o,m,v),jg(d,a,m)}}function mE(o,a,d){var m=_i(o),v={lane:m,action:d,hasEagerState:!1,eagerState:null,next:null};if(Dg(o))Pg(a,v);else{var k=o.alternate;if(o.lanes===0&&(k===null||k.lanes===0)&&(k=a.lastRenderedReducer,k!==null))try{var C=a.lastRenderedState,A=k(C,d);if(v.hasEagerState=!0,v.eagerState=A,br(A,C)){var L=a.interleaved;L===null?(v.next=v,Ud(a)):(v.next=L.next,L.next=v),a.interleaved=v;return}}catch{}finally{}d=fg(o,a,v,m),d!==null&&(v=Rn(),Er(d,o,m,v),jg(d,a,m))}}function Dg(o){var a=o.alternate;return o===Ot||a!==null&&a===Ot}function Pg(o,a){el=Ra=!0;var d=o.pending;d===null?a.next=a:(a.next=d.next,d.next=a),o.pending=a}function jg(o,a,d){if((d&4194240)!==0){var m=a.lanes;m&=o.pendingLanes,d|=m,a.lanes=d,Io(o,d)}}var Da={readContext:or,useCallback:wn,useContext:wn,useEffect:wn,useImperativeHandle:wn,useInsertionEffect:wn,useLayoutEffect:wn,useMemo:wn,useReducer:wn,useRef:wn,useState:wn,useDebugValue:wn,useDeferredValue:wn,useTransition:wn,useMutableSource:wn,useSyncExternalStore:wn,useId:wn,unstable_isNewReconciler:!1},gE={readContext:or,useCallback:function(o,a){return Pr().memoizedState=[o,a===void 0?null:a],o},useContext:or,useEffect:Ng,useImperativeHandle:function(o,a,d){return d=d!=null?d.concat([o]):null,Ia(4194308,4,Mg.bind(null,a,o),d)},useLayoutEffect:function(o,a){return Ia(4194308,4,o,a)},useInsertionEffect:function(o,a){return Ia(4,2,o,a)},useMemo:function(o,a){var d=Pr();return a=a===void 0?null:a,o=o(),d.memoizedState=[o,a],o},useReducer:function(o,a,d){var m=Pr();return a=d!==void 0?d(a):a,m.memoizedState=m.baseState=a,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:a},m.queue=o,o=o.dispatch=hE.bind(null,Ot,o),[m.memoizedState,o]},useRef:function(o){var a=Pr();return o={current:o},a.memoizedState=o},useState:Sg,useDebugValue:tf,useDeferredValue:function(o){return Pr().memoizedState=o},useTransition:function(){var o=Sg(!1),a=o[0];return o=pE.bind(null,o[1]),Pr().memoizedState=o,[a,o]},useMutableSource:function(){},useSyncExternalStore:function(o,a,d){var m=Ot,v=Pr();if(_t){if(d===void 0)throw Error(n(407));d=d()}else{if(d=a(),tn===null)throw Error(n(349));(fs&30)!==0||vg(m,a,d)}v.memoizedState=d;var k={value:d,getSnapshot:a};return v.queue=k,Ng(kg.bind(null,m,k,o),[o]),m.flags|=2048,rl(9,xg.bind(null,m,k,d,a),void 0,null),d},useId:function(){var o=Pr(),a=tn.identifierPrefix;if(_t){var d=Yr,m=Jr;d=(m&~(1<<32-Mt(m)-1)).toString(32)+d,a=":"+a+"R"+d,d=tl++,0<d&&(a+="H"+d.toString(32)),a+=":"}else d=fE++,a=":"+a+"r"+d.toString(32)+":";return o.memoizedState=a},unstable_isNewReconciler:!1},yE={readContext:or,useCallback:Og,useContext:or,useEffect:ef,useImperativeHandle:Ag,useInsertionEffect:_g,useLayoutEffect:Tg,useMemo:Rg,useReducer:Xd,useRef:Cg,useState:function(){return Xd(nl)},useDebugValue:tf,useDeferredValue:function(o){var a=lr();return Ig(a,Yt.memoizedState,o)},useTransition:function(){var o=Xd(nl)[0],a=lr().memoizedState;return[o,a]},useMutableSource:yg,useSyncExternalStore:bg,useId:Lg,unstable_isNewReconciler:!1},bE={readContext:or,useCallback:Og,useContext:or,useEffect:ef,useImperativeHandle:Ag,useInsertionEffect:_g,useLayoutEffect:Tg,useMemo:Rg,useReducer:Zd,useRef:Cg,useState:function(){return Zd(nl)},useDebugValue:tf,useDeferredValue:function(o){var a=lr();return Yt===null?a.memoizedState=o:Ig(a,Yt.memoizedState,o)},useTransition:function(){var o=Zd(nl)[0],a=lr().memoizedState;return[o,a]},useMutableSource:yg,useSyncExternalStore:bg,useId:Lg,unstable_isNewReconciler:!1};function xr(o,a){if(o&&o.defaultProps){a=ie({},a),o=o.defaultProps;for(var d in o)a[d]===void 0&&(a[d]=o[d]);return a}return a}function nf(o,a,d,m){a=o.memoizedState,d=d(m,a),d=d==null?a:ie({},a,d),o.memoizedState=d,o.lanes===0&&(o.updateQueue.baseState=d)}var Pa={isMounted:function(o){return(o=o._reactInternals)?Kr(o)===o:!1},enqueueSetState:function(o,a,d){o=o._reactInternals;var m=Rn(),v=_i(o),k=Xr(m,v);k.payload=a,d!=null&&(k.callback=d),a=Ei(o,k,v),a!==null&&(Er(a,o,v,m),Ta(a,o,v))},enqueueReplaceState:function(o,a,d){o=o._reactInternals;var m=Rn(),v=_i(o),k=Xr(m,v);k.tag=1,k.payload=a,d!=null&&(k.callback=d),a=Ei(o,k,v),a!==null&&(Er(a,o,v,m),Ta(a,o,v))},enqueueForceUpdate:function(o,a){o=o._reactInternals;var d=Rn(),m=_i(o),v=Xr(d,m);v.tag=2,a!=null&&(v.callback=a),a=Ei(o,v,m),a!==null&&(Er(a,o,m,d),Ta(a,o,m))}};function Bg(o,a,d,m,v,k,C){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(m,k,C):a.prototype&&a.prototype.isPureReactComponent?!Ho(d,m)||!Ho(v,k):!0}function zg(o,a,d){var m=!1,v=xi,k=a.contextType;return typeof k=="object"&&k!==null?k=or(k):(v=Bn(a)?ls:kn.current,m=a.contextTypes,k=(m=m!=null)?Ys(o,v):xi),a=new a(d,k),o.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Pa,o.stateNode=a,a._reactInternals=o,m&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=v,o.__reactInternalMemoizedMaskedChildContext=k),a}function Fg(o,a,d,m){o=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(d,m),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(d,m),a.state!==o&&Pa.enqueueReplaceState(a,a.state,null)}function rf(o,a,d,m){var v=o.stateNode;v.props=d,v.state=o.memoizedState,v.refs={},Hd(o);var k=a.contextType;typeof k=="object"&&k!==null?v.context=or(k):(k=Bn(a)?ls:kn.current,v.context=Ys(o,k)),v.state=o.memoizedState,k=a.getDerivedStateFromProps,typeof k=="function"&&(nf(o,a,k,d),v.state=o.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof v.getSnapshotBeforeUpdate=="function"||typeof v.UNSAFE_componentWillMount!="function"&&typeof v.componentWillMount!="function"||(a=v.state,typeof v.componentWillMount=="function"&&v.componentWillMount(),typeof v.UNSAFE_componentWillMount=="function"&&v.UNSAFE_componentWillMount(),a!==v.state&&Pa.enqueueReplaceState(v,v.state,null),Ma(o,d,v,m),v.state=o.memoizedState),typeof v.componentDidMount=="function"&&(o.flags|=4194308)}function io(o,a){try{var d="",m=a;do d+=Ee(m),m=m.return;while(m);var v=d}catch(k){v=`
|
|
39
|
+
Error generating stack: `+k.message+`
|
|
40
|
+
`+k.stack}return{value:o,source:a,stack:v,digest:null}}function sf(o,a,d){return{value:o,source:null,stack:d??null,digest:a??null}}function of(o,a){try{console.error(a.value)}catch(d){setTimeout(function(){throw d})}}var vE=typeof WeakMap=="function"?WeakMap:Map;function $g(o,a,d){d=Xr(-1,d),d.tag=3,d.payload={element:null};var m=a.value;return d.callback=function(){Ha||(Ha=!0,kf=m),of(o,a)},d}function Ug(o,a,d){d=Xr(-1,d),d.tag=3;var m=o.type.getDerivedStateFromError;if(typeof m=="function"){var v=a.value;d.payload=function(){return m(v)},d.callback=function(){of(o,a)}}var k=o.stateNode;return k!==null&&typeof k.componentDidCatch=="function"&&(d.callback=function(){of(o,a),typeof m!="function"&&(Ci===null?Ci=new Set([this]):Ci.add(this));var C=a.stack;this.componentDidCatch(a.value,{componentStack:C!==null?C:""})}),d}function Hg(o,a,d){var m=o.pingCache;if(m===null){m=o.pingCache=new vE;var v=new Set;m.set(a,v)}else v=m.get(a),v===void 0&&(v=new Set,m.set(a,v));v.has(d)||(v.add(d),o=IE.bind(null,o,a,d),a.then(o,o))}function Wg(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 Vg(o,a,d,m,v){return(o.mode&1)===0?(o===a?o.flags|=65536:(o.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(a=Xr(-1,1),a.tag=2,Ei(d,a,1))),d.lanes|=1),o):(o.flags|=65536,o.lanes=v,o)}var xE=T.ReactCurrentOwner,zn=!1;function On(o,a,d,m){a.child=o===null?dg(a,null,d,m):eo(a,o.child,d,m)}function Kg(o,a,d,m,v){d=d.render;var k=a.ref;return no(a,v),m=Yd(o,a,d,m,k,v),d=Qd(),o!==null&&!zn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~v,Zr(o,a,v)):(_t&&d&&Id(a),a.flags|=1,On(o,a,m,v),a.child)}function Gg(o,a,d,m,v){if(o===null){var k=d.type;return typeof k=="function"&&!Tf(k)&&k.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(a.tag=15,a.type=k,qg(o,a,k,m,v)):(o=Ja(d.type,null,m,a,a.mode,v),o.ref=a.ref,o.return=a,a.child=o)}if(k=o.child,(o.lanes&v)===0){var C=k.memoizedProps;if(d=d.compare,d=d!==null?d:Ho,d(C,m)&&o.ref===a.ref)return Zr(o,a,v)}return a.flags|=1,o=Mi(k,m),o.ref=a.ref,o.return=a,a.child=o}function qg(o,a,d,m,v){if(o!==null){var k=o.memoizedProps;if(Ho(k,m)&&o.ref===a.ref)if(zn=!1,a.pendingProps=m=k,(o.lanes&v)!==0)(o.flags&131072)!==0&&(zn=!0);else return a.lanes=o.lanes,Zr(o,a,v)}return lf(o,a,d,m,v)}function Jg(o,a,d){var m=a.pendingProps,v=m.children,k=o!==null?o.memoizedState:null;if(m.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},bt(oo,Qn),Qn|=d;else{if((d&1073741824)===0)return o=k!==null?k.baseLanes|d:d,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:o,cachePool:null,transitions:null},a.updateQueue=null,bt(oo,Qn),Qn|=o,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},m=k!==null?k.baseLanes:d,bt(oo,Qn),Qn|=m}else k!==null?(m=k.baseLanes|d,a.memoizedState=null):m=d,bt(oo,Qn),Qn|=m;return On(o,a,v,d),a.child}function Yg(o,a){var d=a.ref;(o===null&&d!==null||o!==null&&o.ref!==d)&&(a.flags|=512,a.flags|=2097152)}function lf(o,a,d,m,v){var k=Bn(d)?ls:kn.current;return k=Ys(a,k),no(a,v),d=Yd(o,a,d,m,k,v),m=Qd(),o!==null&&!zn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~v,Zr(o,a,v)):(_t&&m&&Id(a),a.flags|=1,On(o,a,d,v),a.child)}function Qg(o,a,d,m,v){if(Bn(d)){var k=!0;xa(a)}else k=!1;if(no(a,v),a.stateNode===null)Ba(o,a),zg(a,d,m),rf(a,d,m,v),m=!0;else if(o===null){var C=a.stateNode,A=a.memoizedProps;C.props=A;var L=C.context,V=d.contextType;typeof V=="object"&&V!==null?V=or(V):(V=Bn(d)?ls:kn.current,V=Ys(a,V));var ue=d.getDerivedStateFromProps,de=typeof ue=="function"||typeof C.getSnapshotBeforeUpdate=="function";de||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(A!==m||L!==V)&&Fg(a,C,m,V),wi=!1;var ce=a.memoizedState;C.state=ce,Ma(a,m,C,v),L=a.memoizedState,A!==m||ce!==L||jn.current||wi?(typeof ue=="function"&&(nf(a,d,ue,m),L=a.memoizedState),(A=wi||Bg(a,d,A,m,ce,L,V))?(de||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(a.flags|=4194308)):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=m,a.memoizedState=L),C.props=m,C.state=L,C.context=V,m=A):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),m=!1)}else{C=a.stateNode,pg(o,a),A=a.memoizedProps,V=a.type===a.elementType?A:xr(a.type,A),C.props=V,de=a.pendingProps,ce=C.context,L=d.contextType,typeof L=="object"&&L!==null?L=or(L):(L=Bn(d)?ls:kn.current,L=Ys(a,L));var Se=d.getDerivedStateFromProps;(ue=typeof Se=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(A!==de||ce!==L)&&Fg(a,C,m,L),wi=!1,ce=a.memoizedState,C.state=ce,Ma(a,m,C,v);var Oe=a.memoizedState;A!==de||ce!==Oe||jn.current||wi?(typeof Se=="function"&&(nf(a,d,Se,m),Oe=a.memoizedState),(V=wi||Bg(a,d,V,m,ce,Oe,L)||!1)?(ue||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(m,Oe,L),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(m,Oe,L)),typeof C.componentDidUpdate=="function"&&(a.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof C.componentDidUpdate!="function"||A===o.memoizedProps&&ce===o.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||A===o.memoizedProps&&ce===o.memoizedState||(a.flags|=1024),a.memoizedProps=m,a.memoizedState=Oe),C.props=m,C.state=Oe,C.context=L,m=V):(typeof C.componentDidUpdate!="function"||A===o.memoizedProps&&ce===o.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||A===o.memoizedProps&&ce===o.memoizedState||(a.flags|=1024),m=!1)}return af(o,a,d,m,k,v)}function af(o,a,d,m,v,k){Yg(o,a);var C=(a.flags&128)!==0;if(!m&&!C)return v&&ng(a,d,!1),Zr(o,a,k);m=a.stateNode,xE.current=a;var A=C&&typeof d.getDerivedStateFromError!="function"?null:m.render();return a.flags|=1,o!==null&&C?(a.child=eo(a,o.child,null,k),a.child=eo(a,null,A,k)):On(o,a,A,k),a.memoizedState=m.state,v&&ng(a,d,!0),a.child}function Xg(o){var a=o.stateNode;a.pendingContext?eg(o,a.pendingContext,a.pendingContext!==a.context):a.context&&eg(o,a.context,!1),Wd(o,a.containerInfo)}function Zg(o,a,d,m,v){return Zs(),jd(v),a.flags|=256,On(o,a,d,m),a.child}var cf={dehydrated:null,treeContext:null,retryLane:0};function uf(o){return{baseLanes:o,cachePool:null,transitions:null}}function ey(o,a,d){var m=a.pendingProps,v=At.current,k=!1,C=(a.flags&128)!==0,A;if((A=C)||(A=o!==null&&o.memoizedState===null?!1:(v&2)!==0),A?(k=!0,a.flags&=-129):(o===null||o.memoizedState!==null)&&(v|=1),bt(At,v&1),o===null)return Pd(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):(C=m.children,o=m.fallback,k?(m=a.mode,k=a.child,C={mode:"hidden",children:C},(m&1)===0&&k!==null?(k.childLanes=0,k.pendingProps=C):k=Ya(C,m,0,null),o=ys(o,m,d,null),k.return=a,o.return=a,k.sibling=o,a.child=k,a.child.memoizedState=uf(d),a.memoizedState=cf,o):df(a,C));if(v=o.memoizedState,v!==null&&(A=v.dehydrated,A!==null))return kE(o,a,C,m,A,v,d);if(k){k=m.fallback,C=a.mode,v=o.child,A=v.sibling;var L={mode:"hidden",children:m.children};return(C&1)===0&&a.child!==v?(m=a.child,m.childLanes=0,m.pendingProps=L,a.deletions=null):(m=Mi(v,L),m.subtreeFlags=v.subtreeFlags&14680064),A!==null?k=Mi(A,k):(k=ys(k,C,d,null),k.flags|=2),k.return=a,m.return=a,m.sibling=k,a.child=m,m=k,k=a.child,C=o.child.memoizedState,C=C===null?uf(d):{baseLanes:C.baseLanes|d,cachePool:null,transitions:C.transitions},k.memoizedState=C,k.childLanes=o.childLanes&~d,a.memoizedState=cf,m}return k=o.child,o=k.sibling,m=Mi(k,{mode:"visible",children:m.children}),(a.mode&1)===0&&(m.lanes=d),m.return=a,m.sibling=null,o!==null&&(d=a.deletions,d===null?(a.deletions=[o],a.flags|=16):d.push(o)),a.child=m,a.memoizedState=null,m}function df(o,a){return a=Ya({mode:"visible",children:a},o.mode,0,null),a.return=o,o.child=a}function ja(o,a,d,m){return m!==null&&jd(m),eo(a,o.child,null,d),o=df(a,a.pendingProps.children),o.flags|=2,a.memoizedState=null,o}function kE(o,a,d,m,v,k,C){if(d)return a.flags&256?(a.flags&=-257,m=sf(Error(n(422))),ja(o,a,C,m)):a.memoizedState!==null?(a.child=o.child,a.flags|=128,null):(k=m.fallback,v=a.mode,m=Ya({mode:"visible",children:m.children},v,0,null),k=ys(k,v,C,null),k.flags|=2,m.return=a,k.return=a,m.sibling=k,a.child=m,(a.mode&1)!==0&&eo(a,o.child,null,C),a.child.memoizedState=uf(C),a.memoizedState=cf,k);if((a.mode&1)===0)return ja(o,a,C,null);if(v.data==="$!"){if(m=v.nextSibling&&v.nextSibling.dataset,m)var A=m.dgst;return m=A,k=Error(n(419)),m=sf(k,m,void 0),ja(o,a,C,m)}if(A=(C&o.childLanes)!==0,zn||A){if(m=tn,m!==null){switch(C&-C){case 4:v=2;break;case 16:v=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:v=32;break;case 536870912:v=268435456;break;default:v=0}v=(v&(m.suspendedLanes|C))!==0?0:v,v!==0&&v!==k.retryLane&&(k.retryLane=v,Qr(o,v),Er(m,o,v,-1))}return _f(),m=sf(Error(n(421))),ja(o,a,C,m)}return v.data==="$?"?(a.flags|=128,a.child=o.child,a=LE.bind(null,o),v._reactRetry=a,null):(o=k.treeContext,Yn=bi(v.nextSibling),Jn=a,_t=!0,vr=null,o!==null&&(ir[sr++]=Jr,ir[sr++]=Yr,ir[sr++]=as,Jr=o.id,Yr=o.overflow,as=a),a=df(a,m.children),a.flags|=4096,a)}function ty(o,a,d){o.lanes|=a;var m=o.alternate;m!==null&&(m.lanes|=a),$d(o.return,a,d)}function ff(o,a,d,m,v){var k=o.memoizedState;k===null?o.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:m,tail:d,tailMode:v}:(k.isBackwards=a,k.rendering=null,k.renderingStartTime=0,k.last=m,k.tail=d,k.tailMode=v)}function ny(o,a,d){var m=a.pendingProps,v=m.revealOrder,k=m.tail;if(On(o,a,m.children,d),m=At.current,(m&2)!==0)m=m&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&&ty(o,d,a);else if(o.tag===19)ty(o,d,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}m&=1}if(bt(At,m),(a.mode&1)===0)a.memoizedState=null;else switch(v){case"forwards":for(d=a.child,v=null;d!==null;)o=d.alternate,o!==null&&Aa(o)===null&&(v=d),d=d.sibling;d=v,d===null?(v=a.child,a.child=null):(v=d.sibling,d.sibling=null),ff(a,!1,v,d,k);break;case"backwards":for(d=null,v=a.child,a.child=null;v!==null;){if(o=v.alternate,o!==null&&Aa(o)===null){a.child=v;break}o=v.sibling,v.sibling=d,d=v,v=o}ff(a,!0,d,null,k);break;case"together":ff(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function Ba(o,a){(a.mode&1)===0&&o!==null&&(o.alternate=null,a.alternate=null,a.flags|=2)}function Zr(o,a,d){if(o!==null&&(a.dependencies=o.dependencies),ps|=a.lanes,(d&a.childLanes)===0)return null;if(o!==null&&a.child!==o.child)throw Error(n(153));if(a.child!==null){for(o=a.child,d=Mi(o,o.pendingProps),a.child=d,d.return=a;o.sibling!==null;)o=o.sibling,d=d.sibling=Mi(o,o.pendingProps),d.return=a;d.sibling=null}return a.child}function wE(o,a,d){switch(a.tag){case 3:Xg(a),Zs();break;case 5:gg(a);break;case 1:Bn(a.type)&&xa(a);break;case 4:Wd(a,a.stateNode.containerInfo);break;case 10:var m=a.type._context,v=a.memoizedProps.value;bt(Na,m._currentValue),m._currentValue=v;break;case 13:if(m=a.memoizedState,m!==null)return m.dehydrated!==null?(bt(At,At.current&1),a.flags|=128,null):(d&a.child.childLanes)!==0?ey(o,a,d):(bt(At,At.current&1),o=Zr(o,a,d),o!==null?o.sibling:null);bt(At,At.current&1);break;case 19:if(m=(d&a.childLanes)!==0,(o.flags&128)!==0){if(m)return ny(o,a,d);a.flags|=128}if(v=a.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),bt(At,At.current),m)break;return null;case 22:case 23:return a.lanes=0,Jg(o,a,d)}return Zr(o,a,d)}var ry,pf,iy,sy;ry=function(o,a){for(var d=a.child;d!==null;){if(d.tag===5||d.tag===6)o.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===a)break;for(;d.sibling===null;){if(d.return===null||d.return===a)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},pf=function(){},iy=function(o,a,d,m){var v=o.memoizedProps;if(v!==m){o=a.stateNode,ds(Dr.current);var k=null;switch(d){case"input":v=we(o,v),m=we(o,m),k=[];break;case"select":v=ie({},v,{value:void 0}),m=ie({},m,{value:void 0}),k=[];break;case"textarea":v=et(o,v),m=et(o,m),k=[];break;default:typeof v.onClick!="function"&&typeof m.onClick=="function"&&(o.onclick=ya)}Le(d,m);var C;d=null;for(V in v)if(!m.hasOwnProperty(V)&&v.hasOwnProperty(V)&&v[V]!=null)if(V==="style"){var A=v[V];for(C in A)A.hasOwnProperty(C)&&(d||(d={}),d[C]="")}else V!=="dangerouslySetInnerHTML"&&V!=="children"&&V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&V!=="autoFocus"&&(i.hasOwnProperty(V)?k||(k=[]):(k=k||[]).push(V,null));for(V in m){var L=m[V];if(A=v!=null?v[V]:void 0,m.hasOwnProperty(V)&&L!==A&&(L!=null||A!=null))if(V==="style")if(A){for(C in A)!A.hasOwnProperty(C)||L&&L.hasOwnProperty(C)||(d||(d={}),d[C]="");for(C in L)L.hasOwnProperty(C)&&A[C]!==L[C]&&(d||(d={}),d[C]=L[C])}else d||(k||(k=[]),k.push(V,d)),d=L;else V==="dangerouslySetInnerHTML"?(L=L?L.__html:void 0,A=A?A.__html:void 0,L!=null&&A!==L&&(k=k||[]).push(V,L)):V==="children"?typeof L!="string"&&typeof L!="number"||(k=k||[]).push(V,""+L):V!=="suppressContentEditableWarning"&&V!=="suppressHydrationWarning"&&(i.hasOwnProperty(V)?(L!=null&&V==="onScroll"&&Et("scroll",o),k||A===L||(k=[])):(k=k||[]).push(V,L))}d&&(k=k||[]).push("style",d);var V=k;(a.updateQueue=V)&&(a.flags|=4)}},sy=function(o,a,d,m){d!==m&&(a.flags|=4)};function il(o,a){if(!_t)switch(o.tailMode){case"hidden":a=o.tail;for(var d=null;a!==null;)a.alternate!==null&&(d=a),a=a.sibling;d===null?o.tail=null:d.sibling=null;break;case"collapsed":d=o.tail;for(var m=null;d!==null;)d.alternate!==null&&(m=d),d=d.sibling;m===null?a||o.tail===null?o.tail=null:o.tail.sibling=null:m.sibling=null}}function En(o){var a=o.alternate!==null&&o.alternate.child===o.child,d=0,m=0;if(a)for(var v=o.child;v!==null;)d|=v.lanes|v.childLanes,m|=v.subtreeFlags&14680064,m|=v.flags&14680064,v.return=o,v=v.sibling;else for(v=o.child;v!==null;)d|=v.lanes|v.childLanes,m|=v.subtreeFlags,m|=v.flags,v.return=o,v=v.sibling;return o.subtreeFlags|=m,o.childLanes=d,a}function EE(o,a,d){var m=a.pendingProps;switch(Ld(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return En(a),null;case 1:return Bn(a.type)&&va(),En(a),null;case 3:return m=a.stateNode,ro(),St(jn),St(kn),Gd(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(o===null||o.child===null)&&(Sa(a)?a.flags|=4:o===null||o.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,vr!==null&&(Sf(vr),vr=null))),pf(o,a),En(a),null;case 5:Vd(a);var v=ds(Zo.current);if(d=a.type,o!==null&&a.stateNode!=null)iy(o,a,d,m,v),o.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!m){if(a.stateNode===null)throw Error(n(166));return En(a),null}if(o=ds(Dr.current),Sa(a)){m=a.stateNode,d=a.type;var k=a.memoizedProps;switch(m[Lr]=a,m[qo]=k,o=(a.mode&1)!==0,d){case"dialog":Et("cancel",m),Et("close",m);break;case"iframe":case"object":case"embed":Et("load",m);break;case"video":case"audio":for(v=0;v<Vo.length;v++)Et(Vo[v],m);break;case"source":Et("error",m);break;case"img":case"image":case"link":Et("error",m),Et("load",m);break;case"details":Et("toggle",m);break;case"input":$e(m,k),Et("invalid",m);break;case"select":m._wrapperState={wasMultiple:!!k.multiple},Et("invalid",m);break;case"textarea":Vn(m,k),Et("invalid",m)}Le(d,k),v=null;for(var C in k)if(k.hasOwnProperty(C)){var A=k[C];C==="children"?typeof A=="string"?m.textContent!==A&&(k.suppressHydrationWarning!==!0&&ga(m.textContent,A,o),v=["children",A]):typeof A=="number"&&m.textContent!==""+A&&(k.suppressHydrationWarning!==!0&&ga(m.textContent,A,o),v=["children",""+A]):i.hasOwnProperty(C)&&A!=null&&C==="onScroll"&&Et("scroll",m)}switch(d){case"input":Me(m),ze(m,k,!0);break;case"textarea":Me(m),tr(m);break;case"select":case"option":break;default:typeof k.onClick=="function"&&(m.onclick=ya)}m=v,a.updateQueue=m,m!==null&&(a.flags|=4)}else{C=v.nodeType===9?v:v.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Xt(d)),o==="http://www.w3.org/1999/xhtml"?d==="script"?(o=C.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof m.is=="string"?o=C.createElement(d,{is:m.is}):(o=C.createElement(d),d==="select"&&(C=o,m.multiple?C.multiple=!0:m.size&&(C.size=m.size))):o=C.createElementNS(o,d),o[Lr]=a,o[qo]=m,ry(o,a,!1,!1),a.stateNode=o;e:{switch(C=ft(d,m),d){case"dialog":Et("cancel",o),Et("close",o),v=m;break;case"iframe":case"object":case"embed":Et("load",o),v=m;break;case"video":case"audio":for(v=0;v<Vo.length;v++)Et(Vo[v],o);v=m;break;case"source":Et("error",o),v=m;break;case"img":case"image":case"link":Et("error",o),Et("load",o),v=m;break;case"details":Et("toggle",o),v=m;break;case"input":$e(o,m),v=we(o,m),Et("invalid",o);break;case"option":v=m;break;case"select":o._wrapperState={wasMultiple:!!m.multiple},v=ie({},m,{value:void 0}),Et("invalid",o);break;case"textarea":Vn(o,m),v=et(o,m),Et("invalid",o);break;default:v=m}Le(d,v),A=v;for(k in A)if(A.hasOwnProperty(k)){var L=A[k];k==="style"?Pn(o,L):k==="dangerouslySetInnerHTML"?(L=L?L.__html:void 0,L!=null&&Mr(o,L)):k==="children"?typeof L=="string"?(d!=="textarea"||L!=="")&&nr(o,L):typeof L=="number"&&nr(o,""+L):k!=="suppressContentEditableWarning"&&k!=="suppressHydrationWarning"&&k!=="autoFocus"&&(i.hasOwnProperty(k)?L!=null&&k==="onScroll"&&Et("scroll",o):L!=null&&M(o,k,L,C))}switch(d){case"input":Me(o),ze(o,m,!1);break;case"textarea":Me(o),tr(o);break;case"option":m.value!=null&&o.setAttribute("value",""+q(m.value));break;case"select":o.multiple=!!m.multiple,k=m.value,k!=null?gt(o,!!m.multiple,k,!1):m.defaultValue!=null&>(o,!!m.multiple,m.defaultValue,!0);break;default:typeof v.onClick=="function"&&(o.onclick=ya)}switch(d){case"button":case"input":case"select":case"textarea":m=!!m.autoFocus;break e;case"img":m=!0;break e;default:m=!1}}m&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return En(a),null;case 6:if(o&&a.stateNode!=null)sy(o,a,o.memoizedProps,m);else{if(typeof m!="string"&&a.stateNode===null)throw Error(n(166));if(d=ds(Zo.current),ds(Dr.current),Sa(a)){if(m=a.stateNode,d=a.memoizedProps,m[Lr]=a,(k=m.nodeValue!==d)&&(o=Jn,o!==null))switch(o.tag){case 3:ga(m.nodeValue,d,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&ga(m.nodeValue,d,(o.mode&1)!==0)}k&&(a.flags|=4)}else m=(d.nodeType===9?d:d.ownerDocument).createTextNode(m),m[Lr]=a,a.stateNode=m}return En(a),null;case 13:if(St(At),m=a.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(_t&&Yn!==null&&(a.mode&1)!==0&&(a.flags&128)===0)ag(),Zs(),a.flags|=98560,k=!1;else if(k=Sa(a),m!==null&&m.dehydrated!==null){if(o===null){if(!k)throw Error(n(318));if(k=a.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(n(317));k[Lr]=a}else Zs(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;En(a),k=!1}else vr!==null&&(Sf(vr),vr=null),k=!0;if(!k)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=d,a):(m=m!==null,m!==(o!==null&&o.memoizedState!==null)&&m&&(a.child.flags|=8192,(a.mode&1)!==0&&(o===null||(At.current&1)!==0?Qt===0&&(Qt=3):_f())),a.updateQueue!==null&&(a.flags|=4),En(a),null);case 4:return ro(),pf(o,a),o===null&&Ko(a.stateNode.containerInfo),En(a),null;case 10:return Fd(a.type._context),En(a),null;case 17:return Bn(a.type)&&va(),En(a),null;case 19:if(St(At),k=a.memoizedState,k===null)return En(a),null;if(m=(a.flags&128)!==0,C=k.rendering,C===null)if(m)il(k,!1);else{if(Qt!==0||o!==null&&(o.flags&128)!==0)for(o=a.child;o!==null;){if(C=Aa(o),C!==null){for(a.flags|=128,il(k,!1),m=C.updateQueue,m!==null&&(a.updateQueue=m,a.flags|=4),a.subtreeFlags=0,m=d,d=a.child;d!==null;)k=d,o=m,k.flags&=14680066,C=k.alternate,C===null?(k.childLanes=0,k.lanes=o,k.child=null,k.subtreeFlags=0,k.memoizedProps=null,k.memoizedState=null,k.updateQueue=null,k.dependencies=null,k.stateNode=null):(k.childLanes=C.childLanes,k.lanes=C.lanes,k.child=C.child,k.subtreeFlags=0,k.deletions=null,k.memoizedProps=C.memoizedProps,k.memoizedState=C.memoizedState,k.updateQueue=C.updateQueue,k.type=C.type,o=C.dependencies,k.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),d=d.sibling;return bt(At,At.current&1|2),a.child}o=o.sibling}k.tail!==null&&Tt()>lo&&(a.flags|=128,m=!0,il(k,!1),a.lanes=4194304)}else{if(!m)if(o=Aa(C),o!==null){if(a.flags|=128,m=!0,d=o.updateQueue,d!==null&&(a.updateQueue=d,a.flags|=4),il(k,!0),k.tail===null&&k.tailMode==="hidden"&&!C.alternate&&!_t)return En(a),null}else 2*Tt()-k.renderingStartTime>lo&&d!==1073741824&&(a.flags|=128,m=!0,il(k,!1),a.lanes=4194304);k.isBackwards?(C.sibling=a.child,a.child=C):(d=k.last,d!==null?d.sibling=C:a.child=C,k.last=C)}return k.tail!==null?(a=k.tail,k.rendering=a,k.tail=a.sibling,k.renderingStartTime=Tt(),a.sibling=null,d=At.current,bt(At,m?d&1|2:d&1),a):(En(a),null);case 22:case 23:return Nf(),m=a.memoizedState!==null,o!==null&&o.memoizedState!==null!==m&&(a.flags|=8192),m&&(a.mode&1)!==0?(Qn&1073741824)!==0&&(En(a),a.subtreeFlags&6&&(a.flags|=8192)):En(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function SE(o,a){switch(Ld(a),a.tag){case 1:return Bn(a.type)&&va(),o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 3:return ro(),St(jn),St(kn),Gd(),o=a.flags,(o&65536)!==0&&(o&128)===0?(a.flags=o&-65537|128,a):null;case 5:return Vd(a),null;case 13:if(St(At),o=a.memoizedState,o!==null&&o.dehydrated!==null){if(a.alternate===null)throw Error(n(340));Zs()}return o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 19:return St(At),null;case 4:return ro(),null;case 10:return Fd(a.type._context),null;case 22:case 23:return Nf(),null;case 24:return null;default:return null}}var za=!1,Sn=!1,CE=typeof WeakSet=="function"?WeakSet:Set,Te=null;function so(o,a){var d=o.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(m){It(o,a,m)}else d.current=null}function hf(o,a,d){try{d()}catch(m){It(o,a,m)}}var oy=!1;function NE(o,a){if(Cd=sa,o=Bm(),yd(o)){if("selectionStart"in o)var d={start:o.selectionStart,end:o.selectionEnd};else e:{d=(d=o.ownerDocument)&&d.defaultView||window;var m=d.getSelection&&d.getSelection();if(m&&m.rangeCount!==0){d=m.anchorNode;var v=m.anchorOffset,k=m.focusNode;m=m.focusOffset;try{d.nodeType,k.nodeType}catch{d=null;break e}var C=0,A=-1,L=-1,V=0,ue=0,de=o,ce=null;t:for(;;){for(var Se;de!==d||v!==0&&de.nodeType!==3||(A=C+v),de!==k||m!==0&&de.nodeType!==3||(L=C+m),de.nodeType===3&&(C+=de.nodeValue.length),(Se=de.firstChild)!==null;)ce=de,de=Se;for(;;){if(de===o)break t;if(ce===d&&++V===v&&(A=C),ce===k&&++ue===m&&(L=C),(Se=de.nextSibling)!==null)break;de=ce,ce=de.parentNode}de=Se}d=A===-1||L===-1?null:{start:A,end:L}}else d=null}d=d||{start:0,end:0}}else d=null;for(Nd={focusedElem:o,selectionRange:d},sa=!1,Te=a;Te!==null;)if(a=Te,o=a.child,(a.subtreeFlags&1028)!==0&&o!==null)o.return=a,Te=o;else for(;Te!==null;){a=Te;try{var Oe=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Oe!==null){var Re=Oe.memoizedProps,$t=Oe.memoizedState,F=a.stateNode,D=F.getSnapshotBeforeUpdate(a.elementType===a.type?Re:xr(a.type,Re),$t);F.__reactInternalSnapshotBeforeUpdate=D}break;case 3:var U=a.stateNode.containerInfo;U.nodeType===1?U.textContent="":U.nodeType===9&&U.documentElement&&U.removeChild(U.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ge){It(a,a.return,ge)}if(o=a.sibling,o!==null){o.return=a.return,Te=o;break}Te=a.return}return Oe=oy,oy=!1,Oe}function sl(o,a,d){var m=a.updateQueue;if(m=m!==null?m.lastEffect:null,m!==null){var v=m=m.next;do{if((v.tag&o)===o){var k=v.destroy;v.destroy=void 0,k!==void 0&&hf(a,d,k)}v=v.next}while(v!==m)}}function Fa(o,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var d=a=a.next;do{if((d.tag&o)===o){var m=d.create;d.destroy=m()}d=d.next}while(d!==a)}}function mf(o){var a=o.ref;if(a!==null){var d=o.stateNode;switch(o.tag){case 5:o=d;break;default:o=d}typeof a=="function"?a(o):a.current=o}}function ly(o){var a=o.alternate;a!==null&&(o.alternate=null,ly(a)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(a=o.stateNode,a!==null&&(delete a[Lr],delete a[qo],delete a[Ad],delete a[aE],delete a[cE])),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 ay(o){return o.tag===5||o.tag===3||o.tag===4}function cy(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||ay(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 gf(o,a,d){var m=o.tag;if(m===5||m===6)o=o.stateNode,a?d.nodeType===8?d.parentNode.insertBefore(o,a):d.insertBefore(o,a):(d.nodeType===8?(a=d.parentNode,a.insertBefore(o,d)):(a=d,a.appendChild(o)),d=d._reactRootContainer,d!=null||a.onclick!==null||(a.onclick=ya));else if(m!==4&&(o=o.child,o!==null))for(gf(o,a,d),o=o.sibling;o!==null;)gf(o,a,d),o=o.sibling}function yf(o,a,d){var m=o.tag;if(m===5||m===6)o=o.stateNode,a?d.insertBefore(o,a):d.appendChild(o);else if(m!==4&&(o=o.child,o!==null))for(yf(o,a,d),o=o.sibling;o!==null;)yf(o,a,d),o=o.sibling}var cn=null,kr=!1;function Si(o,a,d){for(d=d.child;d!==null;)uy(o,a,d),d=d.sibling}function uy(o,a,d){if(Ze&&typeof Ze.onCommitFiberUnmount=="function")try{Ze.onCommitFiberUnmount(Ye,d)}catch{}switch(d.tag){case 5:Sn||so(d,a);case 6:var m=cn,v=kr;cn=null,Si(o,a,d),cn=m,kr=v,cn!==null&&(kr?(o=cn,d=d.stateNode,o.nodeType===8?o.parentNode.removeChild(d):o.removeChild(d)):cn.removeChild(d.stateNode));break;case 18:cn!==null&&(kr?(o=cn,d=d.stateNode,o.nodeType===8?Md(o.parentNode,d):o.nodeType===1&&Md(o,d),jo(o)):Md(cn,d.stateNode));break;case 4:m=cn,v=kr,cn=d.stateNode.containerInfo,kr=!0,Si(o,a,d),cn=m,kr=v;break;case 0:case 11:case 14:case 15:if(!Sn&&(m=d.updateQueue,m!==null&&(m=m.lastEffect,m!==null))){v=m=m.next;do{var k=v,C=k.destroy;k=k.tag,C!==void 0&&((k&2)!==0||(k&4)!==0)&&hf(d,a,C),v=v.next}while(v!==m)}Si(o,a,d);break;case 1:if(!Sn&&(so(d,a),m=d.stateNode,typeof m.componentWillUnmount=="function"))try{m.props=d.memoizedProps,m.state=d.memoizedState,m.componentWillUnmount()}catch(A){It(d,a,A)}Si(o,a,d);break;case 21:Si(o,a,d);break;case 22:d.mode&1?(Sn=(m=Sn)||d.memoizedState!==null,Si(o,a,d),Sn=m):Si(o,a,d);break;default:Si(o,a,d)}}function dy(o){var a=o.updateQueue;if(a!==null){o.updateQueue=null;var d=o.stateNode;d===null&&(d=o.stateNode=new CE),a.forEach(function(m){var v=DE.bind(null,o,m);d.has(m)||(d.add(m),m.then(v,v))})}}function wr(o,a){var d=a.deletions;if(d!==null)for(var m=0;m<d.length;m++){var v=d[m];try{var k=o,C=a,A=C;e:for(;A!==null;){switch(A.tag){case 5:cn=A.stateNode,kr=!1;break e;case 3:cn=A.stateNode.containerInfo,kr=!0;break e;case 4:cn=A.stateNode.containerInfo,kr=!0;break e}A=A.return}if(cn===null)throw Error(n(160));uy(k,C,v),cn=null,kr=!1;var L=v.alternate;L!==null&&(L.return=null),v.return=null}catch(V){It(v,a,V)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)fy(a,o),a=a.sibling}function fy(o,a){var d=o.alternate,m=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(wr(a,o),jr(o),m&4){try{sl(3,o,o.return),Fa(3,o)}catch(Re){It(o,o.return,Re)}try{sl(5,o,o.return)}catch(Re){It(o,o.return,Re)}}break;case 1:wr(a,o),jr(o),m&512&&d!==null&&so(d,d.return);break;case 5:if(wr(a,o),jr(o),m&512&&d!==null&&so(d,d.return),o.flags&32){var v=o.stateNode;try{nr(v,"")}catch(Re){It(o,o.return,Re)}}if(m&4&&(v=o.stateNode,v!=null)){var k=o.memoizedProps,C=d!==null?d.memoizedProps:k,A=o.type,L=o.updateQueue;if(o.updateQueue=null,L!==null)try{A==="input"&&k.type==="radio"&&k.name!=null&&Ae(v,k),ft(A,C);var V=ft(A,k);for(C=0;C<L.length;C+=2){var ue=L[C],de=L[C+1];ue==="style"?Pn(v,de):ue==="dangerouslySetInnerHTML"?Mr(v,de):ue==="children"?nr(v,de):M(v,ue,de,V)}switch(A){case"input":je(v,k);break;case"textarea":Jt(v,k);break;case"select":var ce=v._wrapperState.wasMultiple;v._wrapperState.wasMultiple=!!k.multiple;var Se=k.value;Se!=null?gt(v,!!k.multiple,Se,!1):ce!==!!k.multiple&&(k.defaultValue!=null?gt(v,!!k.multiple,k.defaultValue,!0):gt(v,!!k.multiple,k.multiple?[]:"",!1))}v[qo]=k}catch(Re){It(o,o.return,Re)}}break;case 6:if(wr(a,o),jr(o),m&4){if(o.stateNode===null)throw Error(n(162));v=o.stateNode,k=o.memoizedProps;try{v.nodeValue=k}catch(Re){It(o,o.return,Re)}}break;case 3:if(wr(a,o),jr(o),m&4&&d!==null&&d.memoizedState.isDehydrated)try{jo(a.containerInfo)}catch(Re){It(o,o.return,Re)}break;case 4:wr(a,o),jr(o);break;case 13:wr(a,o),jr(o),v=o.child,v.flags&8192&&(k=v.memoizedState!==null,v.stateNode.isHidden=k,!k||v.alternate!==null&&v.alternate.memoizedState!==null||(xf=Tt())),m&4&&dy(o);break;case 22:if(ue=d!==null&&d.memoizedState!==null,o.mode&1?(Sn=(V=Sn)||ue,wr(a,o),Sn=V):wr(a,o),jr(o),m&8192){if(V=o.memoizedState!==null,(o.stateNode.isHidden=V)&&!ue&&(o.mode&1)!==0)for(Te=o,ue=o.child;ue!==null;){for(de=Te=ue;Te!==null;){switch(ce=Te,Se=ce.child,ce.tag){case 0:case 11:case 14:case 15:sl(4,ce,ce.return);break;case 1:so(ce,ce.return);var Oe=ce.stateNode;if(typeof Oe.componentWillUnmount=="function"){m=ce,d=ce.return;try{a=m,Oe.props=a.memoizedProps,Oe.state=a.memoizedState,Oe.componentWillUnmount()}catch(Re){It(m,d,Re)}}break;case 5:so(ce,ce.return);break;case 22:if(ce.memoizedState!==null){my(de);continue}}Se!==null?(Se.return=ce,Te=Se):my(de)}ue=ue.sibling}e:for(ue=null,de=o;;){if(de.tag===5){if(ue===null){ue=de;try{v=de.stateNode,V?(k=v.style,typeof k.setProperty=="function"?k.setProperty("display","none","important"):k.display="none"):(A=de.stateNode,L=de.memoizedProps.style,C=L!=null&&L.hasOwnProperty("display")?L.display:null,A.style.display=gr("display",C))}catch(Re){It(o,o.return,Re)}}}else if(de.tag===6){if(ue===null)try{de.stateNode.nodeValue=V?"":de.memoizedProps}catch(Re){It(o,o.return,Re)}}else if((de.tag!==22&&de.tag!==23||de.memoizedState===null||de===o)&&de.child!==null){de.child.return=de,de=de.child;continue}if(de===o)break e;for(;de.sibling===null;){if(de.return===null||de.return===o)break e;ue===de&&(ue=null),de=de.return}ue===de&&(ue=null),de.sibling.return=de.return,de=de.sibling}}break;case 19:wr(a,o),jr(o),m&4&&dy(o);break;case 21:break;default:wr(a,o),jr(o)}}function jr(o){var a=o.flags;if(a&2){try{e:{for(var d=o.return;d!==null;){if(ay(d)){var m=d;break e}d=d.return}throw Error(n(160))}switch(m.tag){case 5:var v=m.stateNode;m.flags&32&&(nr(v,""),m.flags&=-33);var k=cy(o);yf(o,k,v);break;case 3:case 4:var C=m.stateNode.containerInfo,A=cy(o);gf(o,A,C);break;default:throw Error(n(161))}}catch(L){It(o,o.return,L)}o.flags&=-3}a&4096&&(o.flags&=-4097)}function _E(o,a,d){Te=o,py(o)}function py(o,a,d){for(var m=(o.mode&1)!==0;Te!==null;){var v=Te,k=v.child;if(v.tag===22&&m){var C=v.memoizedState!==null||za;if(!C){var A=v.alternate,L=A!==null&&A.memoizedState!==null||Sn;A=za;var V=Sn;if(za=C,(Sn=L)&&!V)for(Te=v;Te!==null;)C=Te,L=C.child,C.tag===22&&C.memoizedState!==null?gy(v):L!==null?(L.return=C,Te=L):gy(v);for(;k!==null;)Te=k,py(k),k=k.sibling;Te=v,za=A,Sn=V}hy(o)}else(v.subtreeFlags&8772)!==0&&k!==null?(k.return=v,Te=k):hy(o)}}function hy(o){for(;Te!==null;){var a=Te;if((a.flags&8772)!==0){var d=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Sn||Fa(5,a);break;case 1:var m=a.stateNode;if(a.flags&4&&!Sn)if(d===null)m.componentDidMount();else{var v=a.elementType===a.type?d.memoizedProps:xr(a.type,d.memoizedProps);m.componentDidUpdate(v,d.memoizedState,m.__reactInternalSnapshotBeforeUpdate)}var k=a.updateQueue;k!==null&&mg(a,k,m);break;case 3:var C=a.updateQueue;if(C!==null){if(d=null,a.child!==null)switch(a.child.tag){case 5:d=a.child.stateNode;break;case 1:d=a.child.stateNode}mg(a,C,d)}break;case 5:var A=a.stateNode;if(d===null&&a.flags&4){d=A;var L=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":L.autoFocus&&d.focus();break;case"img":L.src&&(d.src=L.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var V=a.alternate;if(V!==null){var ue=V.memoizedState;if(ue!==null){var de=ue.dehydrated;de!==null&&jo(de)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Sn||a.flags&512&&mf(a)}catch(ce){It(a,a.return,ce)}}if(a===o){Te=null;break}if(d=a.sibling,d!==null){d.return=a.return,Te=d;break}Te=a.return}}function my(o){for(;Te!==null;){var a=Te;if(a===o){Te=null;break}var d=a.sibling;if(d!==null){d.return=a.return,Te=d;break}Te=a.return}}function gy(o){for(;Te!==null;){var a=Te;try{switch(a.tag){case 0:case 11:case 15:var d=a.return;try{Fa(4,a)}catch(L){It(a,d,L)}break;case 1:var m=a.stateNode;if(typeof m.componentDidMount=="function"){var v=a.return;try{m.componentDidMount()}catch(L){It(a,v,L)}}var k=a.return;try{mf(a)}catch(L){It(a,k,L)}break;case 5:var C=a.return;try{mf(a)}catch(L){It(a,C,L)}}}catch(L){It(a,a.return,L)}if(a===o){Te=null;break}var A=a.sibling;if(A!==null){A.return=a.return,Te=A;break}Te=a.return}}var TE=Math.ceil,$a=T.ReactCurrentDispatcher,bf=T.ReactCurrentOwner,ar=T.ReactCurrentBatchConfig,it=0,tn=null,Vt=null,un=0,Qn=0,oo=vi(0),Qt=0,ol=null,ps=0,Ua=0,vf=0,ll=null,Fn=null,xf=0,lo=1/0,ei=null,Ha=!1,kf=null,Ci=null,Wa=!1,Ni=null,Va=0,al=0,wf=null,Ka=-1,Ga=0;function Rn(){return(it&6)!==0?Tt():Ka!==-1?Ka:Ka=Tt()}function _i(o){return(o.mode&1)===0?1:(it&2)!==0&&un!==0?un&-un:dE.transition!==null?(Ga===0&&(Ga=na()),Ga):(o=rt,o!==0||(o=window.event,o=o===void 0?16:bm(o.type)),o)}function Er(o,a,d,m){if(50<al)throw al=0,wf=null,Error(n(185));hi(o,d,m),((it&2)===0||o!==tn)&&(o===tn&&((it&2)===0&&(Ua|=d),Qt===4&&Ti(o,un)),$n(o,m),d===1&&it===0&&(a.mode&1)===0&&(lo=Tt()+500,ka&&ki()))}function $n(o,a){var d=o.callbackNode;id(o,a);var m=ns(o,o===tn?un:0);if(m===0)d!==null&&yr(d),o.callbackNode=null,o.callbackPriority=0;else if(a=m&-m,o.callbackPriority!==a){if(d!=null&&yr(d),a===1)o.tag===0?uE(by.bind(null,o)):rg(by.bind(null,o)),oE(function(){(it&6)===0&&ki()}),d=null;else{switch(Je(m)){case 1:d=Oo;break;case 4:d=es;break;case 16:d=zs;break;case 536870912:d=De;break;default:d=zs}d=Ny(d,yy.bind(null,o))}o.callbackPriority=a,o.callbackNode=d}}function yy(o,a){if(Ka=-1,Ga=0,(it&6)!==0)throw Error(n(327));var d=o.callbackNode;if(ao()&&o.callbackNode!==d)return null;var m=ns(o,o===tn?un:0);if(m===0)return null;if((m&30)!==0||(m&o.expiredLanes)!==0||a)a=qa(o,m);else{a=m;var v=it;it|=2;var k=xy();(tn!==o||un!==a)&&(ei=null,lo=Tt()+500,ms(o,a));do try{OE();break}catch(A){vy(o,A)}while(!0);zd(),$a.current=k,it=v,Vt!==null?a=0:(tn=null,un=0,a=Qt)}if(a!==0){if(a===2&&(v=Ro(o),v!==0&&(m=v,a=Ef(o,v))),a===1)throw d=ol,ms(o,0),Ti(o,m),$n(o,Tt()),d;if(a===6)Ti(o,m);else{if(v=o.current.alternate,(m&30)===0&&!ME(v)&&(a=qa(o,m),a===2&&(k=Ro(o),k!==0&&(m=k,a=Ef(o,k))),a===1))throw d=ol,ms(o,0),Ti(o,m),$n(o,Tt()),d;switch(o.finishedWork=v,o.finishedLanes=m,a){case 0:case 1:throw Error(n(345));case 2:gs(o,Fn,ei);break;case 3:if(Ti(o,m),(m&130023424)===m&&(a=xf+500-Tt(),10<a)){if(ns(o,0)!==0)break;if(v=o.suspendedLanes,(v&m)!==m){Rn(),o.pingedLanes|=o.suspendedLanes&v;break}o.timeoutHandle=Td(gs.bind(null,o,Fn,ei),a);break}gs(o,Fn,ei);break;case 4:if(Ti(o,m),(m&4194240)===m)break;for(a=o.eventTimes,v=-1;0<m;){var C=31-Mt(m);k=1<<C,C=a[C],C>v&&(v=C),m&=~k}if(m=v,m=Tt()-m,m=(120>m?120:480>m?480:1080>m?1080:1920>m?1920:3e3>m?3e3:4320>m?4320:1960*TE(m/1960))-m,10<m){o.timeoutHandle=Td(gs.bind(null,o,Fn,ei),m);break}gs(o,Fn,ei);break;case 5:gs(o,Fn,ei);break;default:throw Error(n(329))}}}return $n(o,Tt()),o.callbackNode===d?yy.bind(null,o):null}function Ef(o,a){var d=ll;return o.current.memoizedState.isDehydrated&&(ms(o,a).flags|=256),o=qa(o,a),o!==2&&(a=Fn,Fn=d,a!==null&&Sf(a)),o}function Sf(o){Fn===null?Fn=o:Fn.push.apply(Fn,o)}function ME(o){for(var a=o;;){if(a.flags&16384){var d=a.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var m=0;m<d.length;m++){var v=d[m],k=v.getSnapshot;v=v.value;try{if(!br(k(),v))return!1}catch{return!1}}}if(d=a.child,a.subtreeFlags&16384&&d!==null)d.return=a,a=d;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 Ti(o,a){for(a&=~vf,a&=~Ua,o.suspendedLanes|=a,o.pingedLanes&=~a,o=o.expirationTimes;0<a;){var d=31-Mt(a),m=1<<d;o[d]=-1,a&=~m}}function by(o){if((it&6)!==0)throw Error(n(327));ao();var a=ns(o,0);if((a&1)===0)return $n(o,Tt()),null;var d=qa(o,a);if(o.tag!==0&&d===2){var m=Ro(o);m!==0&&(a=m,d=Ef(o,m))}if(d===1)throw d=ol,ms(o,0),Ti(o,a),$n(o,Tt()),d;if(d===6)throw Error(n(345));return o.finishedWork=o.current.alternate,o.finishedLanes=a,gs(o,Fn,ei),$n(o,Tt()),null}function Cf(o,a){var d=it;it|=1;try{return o(a)}finally{it=d,it===0&&(lo=Tt()+500,ka&&ki())}}function hs(o){Ni!==null&&Ni.tag===0&&(it&6)===0&&ao();var a=it;it|=1;var d=ar.transition,m=rt;try{if(ar.transition=null,rt=1,o)return o()}finally{rt=m,ar.transition=d,it=a,(it&6)===0&&ki()}}function Nf(){Qn=oo.current,St(oo)}function ms(o,a){o.finishedWork=null,o.finishedLanes=0;var d=o.timeoutHandle;if(d!==-1&&(o.timeoutHandle=-1,sE(d)),Vt!==null)for(d=Vt.return;d!==null;){var m=d;switch(Ld(m),m.tag){case 1:m=m.type.childContextTypes,m!=null&&va();break;case 3:ro(),St(jn),St(kn),Gd();break;case 5:Vd(m);break;case 4:ro();break;case 13:St(At);break;case 19:St(At);break;case 10:Fd(m.type._context);break;case 22:case 23:Nf()}d=d.return}if(tn=o,Vt=o=Mi(o.current,null),un=Qn=a,Qt=0,ol=null,vf=Ua=ps=0,Fn=ll=null,us!==null){for(a=0;a<us.length;a++)if(d=us[a],m=d.interleaved,m!==null){d.interleaved=null;var v=m.next,k=d.pending;if(k!==null){var C=k.next;k.next=v,m.next=C}d.pending=m}us=null}return o}function vy(o,a){do{var d=Vt;try{if(zd(),Oa.current=Da,Ra){for(var m=Ot.memoizedState;m!==null;){var v=m.queue;v!==null&&(v.pending=null),m=m.next}Ra=!1}if(fs=0,en=Yt=Ot=null,el=!1,tl=0,bf.current=null,d===null||d.return===null){Qt=1,ol=a,Vt=null;break}e:{var k=o,C=d.return,A=d,L=a;if(a=un,A.flags|=32768,L!==null&&typeof L=="object"&&typeof L.then=="function"){var V=L,ue=A,de=ue.tag;if((ue.mode&1)===0&&(de===0||de===11||de===15)){var ce=ue.alternate;ce?(ue.updateQueue=ce.updateQueue,ue.memoizedState=ce.memoizedState,ue.lanes=ce.lanes):(ue.updateQueue=null,ue.memoizedState=null)}var Se=Wg(C);if(Se!==null){Se.flags&=-257,Vg(Se,C,A,k,a),Se.mode&1&&Hg(k,V,a),a=Se,L=V;var Oe=a.updateQueue;if(Oe===null){var Re=new Set;Re.add(L),a.updateQueue=Re}else Oe.add(L);break e}else{if((a&1)===0){Hg(k,V,a),_f();break e}L=Error(n(426))}}else if(_t&&A.mode&1){var $t=Wg(C);if($t!==null){($t.flags&65536)===0&&($t.flags|=256),Vg($t,C,A,k,a),jd(io(L,A));break e}}k=L=io(L,A),Qt!==4&&(Qt=2),ll===null?ll=[k]:ll.push(k),k=C;do{switch(k.tag){case 3:k.flags|=65536,a&=-a,k.lanes|=a;var F=$g(k,L,a);hg(k,F);break e;case 1:A=L;var D=k.type,U=k.stateNode;if((k.flags&128)===0&&(typeof D.getDerivedStateFromError=="function"||U!==null&&typeof U.componentDidCatch=="function"&&(Ci===null||!Ci.has(U)))){k.flags|=65536,a&=-a,k.lanes|=a;var ge=Ug(k,A,a);hg(k,ge);break e}}k=k.return}while(k!==null)}wy(d)}catch(Ie){a=Ie,Vt===d&&d!==null&&(Vt=d=d.return);continue}break}while(!0)}function xy(){var o=$a.current;return $a.current=Da,o===null?Da:o}function _f(){(Qt===0||Qt===3||Qt===2)&&(Qt=4),tn===null||(ps&268435455)===0&&(Ua&268435455)===0||Ti(tn,un)}function qa(o,a){var d=it;it|=2;var m=xy();(tn!==o||un!==a)&&(ei=null,ms(o,a));do try{AE();break}catch(v){vy(o,v)}while(!0);if(zd(),it=d,$a.current=m,Vt!==null)throw Error(n(261));return tn=null,un=0,Qt}function AE(){for(;Vt!==null;)ky(Vt)}function OE(){for(;Vt!==null&&!ea();)ky(Vt)}function ky(o){var a=Cy(o.alternate,o,Qn);o.memoizedProps=o.pendingProps,a===null?wy(o):Vt=a,bf.current=null}function wy(o){var a=o;do{var d=a.alternate;if(o=a.return,(a.flags&32768)===0){if(d=EE(d,a,Qn),d!==null){Vt=d;return}}else{if(d=SE(d,a),d!==null){d.flags&=32767,Vt=d;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Qt=6,Vt=null;return}}if(a=a.sibling,a!==null){Vt=a;return}Vt=a=o}while(a!==null);Qt===0&&(Qt=5)}function gs(o,a,d){var m=rt,v=ar.transition;try{ar.transition=null,rt=1,RE(o,a,d,m)}finally{ar.transition=v,rt=m}return null}function RE(o,a,d,m){do ao();while(Ni!==null);if((it&6)!==0)throw Error(n(327));d=o.finishedWork;var v=o.finishedLanes;if(d===null)return null;if(o.finishedWork=null,o.finishedLanes=0,d===o.current)throw Error(n(177));o.callbackNode=null,o.callbackPriority=0;var k=d.lanes|d.childLanes;if(rr(o,k),o===tn&&(Vt=tn=null,un=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||Wa||(Wa=!0,Ny(zs,function(){return ao(),null})),k=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||k){k=ar.transition,ar.transition=null;var C=rt;rt=1;var A=it;it|=4,bf.current=null,NE(o,d),fy(d,o),X1(Nd),sa=!!Cd,Nd=Cd=null,o.current=d,_E(d),ta(),it=A,rt=C,ar.transition=k}else o.current=d;if(Wa&&(Wa=!1,Ni=o,Va=v),k=o.pendingLanes,k===0&&(Ci=null),zt(d.stateNode),$n(o,Tt()),a!==null)for(m=o.onRecoverableError,d=0;d<a.length;d++)v=a[d],m(v.value,{componentStack:v.stack,digest:v.digest});if(Ha)throw Ha=!1,o=kf,kf=null,o;return(Va&1)!==0&&o.tag!==0&&ao(),k=o.pendingLanes,(k&1)!==0?o===wf?al++:(al=0,wf=o):al=0,ki(),null}function ao(){if(Ni!==null){var o=Je(Va),a=ar.transition,d=rt;try{if(ar.transition=null,rt=16>o?16:o,Ni===null)var m=!1;else{if(o=Ni,Ni=null,Va=0,(it&6)!==0)throw Error(n(331));var v=it;for(it|=4,Te=o.current;Te!==null;){var k=Te,C=k.child;if((Te.flags&16)!==0){var A=k.deletions;if(A!==null){for(var L=0;L<A.length;L++){var V=A[L];for(Te=V;Te!==null;){var ue=Te;switch(ue.tag){case 0:case 11:case 15:sl(8,ue,k)}var de=ue.child;if(de!==null)de.return=ue,Te=de;else for(;Te!==null;){ue=Te;var ce=ue.sibling,Se=ue.return;if(ly(ue),ue===V){Te=null;break}if(ce!==null){ce.return=Se,Te=ce;break}Te=Se}}}var Oe=k.alternate;if(Oe!==null){var Re=Oe.child;if(Re!==null){Oe.child=null;do{var $t=Re.sibling;Re.sibling=null,Re=$t}while(Re!==null)}}Te=k}}if((k.subtreeFlags&2064)!==0&&C!==null)C.return=k,Te=C;else e:for(;Te!==null;){if(k=Te,(k.flags&2048)!==0)switch(k.tag){case 0:case 11:case 15:sl(9,k,k.return)}var F=k.sibling;if(F!==null){F.return=k.return,Te=F;break e}Te=k.return}}var D=o.current;for(Te=D;Te!==null;){C=Te;var U=C.child;if((C.subtreeFlags&2064)!==0&&U!==null)U.return=C,Te=U;else e:for(C=D;Te!==null;){if(A=Te,(A.flags&2048)!==0)try{switch(A.tag){case 0:case 11:case 15:Fa(9,A)}}catch(Ie){It(A,A.return,Ie)}if(A===C){Te=null;break e}var ge=A.sibling;if(ge!==null){ge.return=A.return,Te=ge;break e}Te=A.return}}if(it=v,ki(),Ze&&typeof Ze.onPostCommitFiberRoot=="function")try{Ze.onPostCommitFiberRoot(Ye,o)}catch{}m=!0}return m}finally{rt=d,ar.transition=a}}return!1}function Ey(o,a,d){a=io(d,a),a=$g(o,a,1),o=Ei(o,a,1),a=Rn(),o!==null&&(hi(o,1,a),$n(o,a))}function It(o,a,d){if(o.tag===3)Ey(o,o,d);else for(;a!==null;){if(a.tag===3){Ey(a,o,d);break}else if(a.tag===1){var m=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof m.componentDidCatch=="function"&&(Ci===null||!Ci.has(m))){o=io(d,o),o=Ug(a,o,1),a=Ei(a,o,1),o=Rn(),a!==null&&(hi(a,1,o),$n(a,o));break}}a=a.return}}function IE(o,a,d){var m=o.pingCache;m!==null&&m.delete(a),a=Rn(),o.pingedLanes|=o.suspendedLanes&d,tn===o&&(un&d)===d&&(Qt===4||Qt===3&&(un&130023424)===un&&500>Tt()-xf?ms(o,0):vf|=d),$n(o,a)}function Sy(o,a){a===0&&((o.mode&1)===0?a=1:(a=ts,ts<<=1,(ts&130023424)===0&&(ts=4194304)));var d=Rn();o=Qr(o,a),o!==null&&(hi(o,a,d),$n(o,d))}function LE(o){var a=o.memoizedState,d=0;a!==null&&(d=a.retryLane),Sy(o,d)}function DE(o,a){var d=0;switch(o.tag){case 13:var m=o.stateNode,v=o.memoizedState;v!==null&&(d=v.retryLane);break;case 19:m=o.stateNode;break;default:throw Error(n(314))}m!==null&&m.delete(a),Sy(o,d)}var Cy;Cy=function(o,a,d){if(o!==null)if(o.memoizedProps!==a.pendingProps||jn.current)zn=!0;else{if((o.lanes&d)===0&&(a.flags&128)===0)return zn=!1,wE(o,a,d);zn=(o.flags&131072)!==0}else zn=!1,_t&&(a.flags&1048576)!==0&&ig(a,Ea,a.index);switch(a.lanes=0,a.tag){case 2:var m=a.type;Ba(o,a),o=a.pendingProps;var v=Ys(a,kn.current);no(a,d),v=Yd(null,a,m,o,v,d);var k=Qd();return a.flags|=1,typeof v=="object"&&v!==null&&typeof v.render=="function"&&v.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Bn(m)?(k=!0,xa(a)):k=!1,a.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,Hd(a),v.updater=Pa,a.stateNode=v,v._reactInternals=a,rf(a,m,o,d),a=af(null,a,m,!0,k,d)):(a.tag=0,_t&&k&&Id(a),On(null,a,v,d),a=a.child),a;case 16:m=a.elementType;e:{switch(Ba(o,a),o=a.pendingProps,v=m._init,m=v(m._payload),a.type=m,v=a.tag=jE(m),o=xr(m,o),v){case 0:a=lf(null,a,m,o,d);break e;case 1:a=Qg(null,a,m,o,d);break e;case 11:a=Kg(null,a,m,o,d);break e;case 14:a=Gg(null,a,m,xr(m.type,o),d);break e}throw Error(n(306,m,""))}return a;case 0:return m=a.type,v=a.pendingProps,v=a.elementType===m?v:xr(m,v),lf(o,a,m,v,d);case 1:return m=a.type,v=a.pendingProps,v=a.elementType===m?v:xr(m,v),Qg(o,a,m,v,d);case 3:e:{if(Xg(a),o===null)throw Error(n(387));m=a.pendingProps,k=a.memoizedState,v=k.element,pg(o,a),Ma(a,m,null,d);var C=a.memoizedState;if(m=C.element,k.isDehydrated)if(k={element:m,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},a.updateQueue.baseState=k,a.memoizedState=k,a.flags&256){v=io(Error(n(423)),a),a=Zg(o,a,m,d,v);break e}else if(m!==v){v=io(Error(n(424)),a),a=Zg(o,a,m,d,v);break e}else for(Yn=bi(a.stateNode.containerInfo.firstChild),Jn=a,_t=!0,vr=null,d=dg(a,null,m,d),a.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(Zs(),m===v){a=Zr(o,a,d);break e}On(o,a,m,d)}a=a.child}return a;case 5:return gg(a),o===null&&Pd(a),m=a.type,v=a.pendingProps,k=o!==null?o.memoizedProps:null,C=v.children,_d(m,v)?C=null:k!==null&&_d(m,k)&&(a.flags|=32),Yg(o,a),On(o,a,C,d),a.child;case 6:return o===null&&Pd(a),null;case 13:return ey(o,a,d);case 4:return Wd(a,a.stateNode.containerInfo),m=a.pendingProps,o===null?a.child=eo(a,null,m,d):On(o,a,m,d),a.child;case 11:return m=a.type,v=a.pendingProps,v=a.elementType===m?v:xr(m,v),Kg(o,a,m,v,d);case 7:return On(o,a,a.pendingProps,d),a.child;case 8:return On(o,a,a.pendingProps.children,d),a.child;case 12:return On(o,a,a.pendingProps.children,d),a.child;case 10:e:{if(m=a.type._context,v=a.pendingProps,k=a.memoizedProps,C=v.value,bt(Na,m._currentValue),m._currentValue=C,k!==null)if(br(k.value,C)){if(k.children===v.children&&!jn.current){a=Zr(o,a,d);break e}}else for(k=a.child,k!==null&&(k.return=a);k!==null;){var A=k.dependencies;if(A!==null){C=k.child;for(var L=A.firstContext;L!==null;){if(L.context===m){if(k.tag===1){L=Xr(-1,d&-d),L.tag=2;var V=k.updateQueue;if(V!==null){V=V.shared;var ue=V.pending;ue===null?L.next=L:(L.next=ue.next,ue.next=L),V.pending=L}}k.lanes|=d,L=k.alternate,L!==null&&(L.lanes|=d),$d(k.return,d,a),A.lanes|=d;break}L=L.next}}else if(k.tag===10)C=k.type===a.type?null:k.child;else if(k.tag===18){if(C=k.return,C===null)throw Error(n(341));C.lanes|=d,A=C.alternate,A!==null&&(A.lanes|=d),$d(C,d,a),C=k.sibling}else C=k.child;if(C!==null)C.return=k;else for(C=k;C!==null;){if(C===a){C=null;break}if(k=C.sibling,k!==null){k.return=C.return,C=k;break}C=C.return}k=C}On(o,a,v.children,d),a=a.child}return a;case 9:return v=a.type,m=a.pendingProps.children,no(a,d),v=or(v),m=m(v),a.flags|=1,On(o,a,m,d),a.child;case 14:return m=a.type,v=xr(m,a.pendingProps),v=xr(m.type,v),Gg(o,a,m,v,d);case 15:return qg(o,a,a.type,a.pendingProps,d);case 17:return m=a.type,v=a.pendingProps,v=a.elementType===m?v:xr(m,v),Ba(o,a),a.tag=1,Bn(m)?(o=!0,xa(a)):o=!1,no(a,d),zg(a,m,v),rf(a,m,v,d),af(null,a,m,!0,o,d);case 19:return ny(o,a,d);case 22:return Jg(o,a,d)}throw Error(n(156,a.tag))};function Ny(o,a){return Zl(o,a)}function PE(o,a,d,m){this.tag=o,this.key=d,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=m,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function cr(o,a,d,m){return new PE(o,a,d,m)}function Tf(o){return o=o.prototype,!(!o||!o.isReactComponent)}function jE(o){if(typeof o=="function")return Tf(o)?1:0;if(o!=null){if(o=o.$$typeof,o===K)return 11;if(o===Z)return 14}return 2}function Mi(o,a){var d=o.alternate;return d===null?(d=cr(o.tag,a,o.key,o.mode),d.elementType=o.elementType,d.type=o.type,d.stateNode=o.stateNode,d.alternate=o,o.alternate=d):(d.pendingProps=a,d.type=o.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=o.flags&14680064,d.childLanes=o.childLanes,d.lanes=o.lanes,d.child=o.child,d.memoizedProps=o.memoizedProps,d.memoizedState=o.memoizedState,d.updateQueue=o.updateQueue,a=o.dependencies,d.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},d.sibling=o.sibling,d.index=o.index,d.ref=o.ref,d}function Ja(o,a,d,m,v,k){var C=2;if(m=o,typeof o=="function")Tf(o)&&(C=1);else if(typeof o=="string")C=5;else e:switch(o){case B:return ys(d.children,v,k,a);case Q:C=8,v|=8;break;case X:return o=cr(12,d,a,v|2),o.elementType=X,o.lanes=k,o;case W:return o=cr(13,d,a,v),o.elementType=W,o.lanes=k,o;case $:return o=cr(19,d,a,v),o.elementType=$,o.lanes=k,o;case he:return Ya(d,v,k,a);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case J:C=10;break e;case fe:C=9;break e;case K:C=11;break e;case Z:C=14;break e;case ee:C=16,m=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return a=cr(C,d,a,v),a.elementType=o,a.type=m,a.lanes=k,a}function ys(o,a,d,m){return o=cr(7,o,m,a),o.lanes=d,o}function Ya(o,a,d,m){return o=cr(22,o,m,a),o.elementType=he,o.lanes=d,o.stateNode={isHidden:!1},o}function Mf(o,a,d){return o=cr(6,o,null,a),o.lanes=d,o}function Af(o,a,d){return a=cr(4,o.children!==null?o.children:[],o.key,a),a.lanes=d,a.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},a}function BE(o,a,d,m,v){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=pi(0),this.expirationTimes=pi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pi(0),this.identifierPrefix=m,this.onRecoverableError=v,this.mutableSourceEagerHydrationData=null}function Of(o,a,d,m,v,k,C,A,L){return o=new BE(o,a,d,A,L),a===1?(a=1,k===!0&&(a|=8)):a=0,k=cr(3,null,null,a),o.current=k,k.stateNode=o,k.memoizedState={element:m,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hd(k),o}function zE(o,a,d){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:P,key:m==null?null:""+m,children:o,containerInfo:a,implementation:d}}function _y(o){if(!o)return xi;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(Bn(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(o.tag===1){var d=o.type;if(Bn(d))return tg(o,d,a)}return a}function Ty(o,a,d,m,v,k,C,A,L){return o=Of(d,m,!0,o,v,k,C,A,L),o.context=_y(null),d=o.current,m=Rn(),v=_i(d),k=Xr(m,v),k.callback=a??null,Ei(d,k,v),o.current.lanes=v,hi(o,v,m),$n(o,m),o}function Qa(o,a,d,m){var v=a.current,k=Rn(),C=_i(v);return d=_y(d),a.context===null?a.context=d:a.pendingContext=d,a=Xr(k,C),a.payload={element:o},m=m===void 0?null:m,m!==null&&(a.callback=m),o=Ei(v,a,C),o!==null&&(Er(o,v,C,k),Ta(o,v,C)),C}function Xa(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 My(o,a){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var d=o.retryLane;o.retryLane=d!==0&&d<a?d:a}}function Rf(o,a){My(o,a),(o=o.alternate)&&My(o,a)}function FE(){return null}var Ay=typeof reportError=="function"?reportError:function(o){console.error(o)};function If(o){this._internalRoot=o}Za.prototype.render=If.prototype.render=function(o){var a=this._internalRoot;if(a===null)throw Error(n(409));Qa(o,a,null,null)},Za.prototype.unmount=If.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var a=o.containerInfo;hs(function(){Qa(null,o,null,null)}),a[Gr]=null}};function Za(o){this._internalRoot=o}Za.prototype.unstable_scheduleHydration=function(o){if(o){var a=rs();o={blockedOn:null,target:o,priority:a};for(var d=0;d<Zt.length&&a!==0&&a<Zt[d].priority;d++);Zt.splice(d,0,o),d===0&&gm(o)}};function Lf(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function ec(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Oy(){}function $E(o,a,d,m,v){if(v){if(typeof m=="function"){var k=m;m=function(){var V=Xa(C);k.call(V)}}var C=Ty(a,m,o,0,null,!1,!1,"",Oy);return o._reactRootContainer=C,o[Gr]=C.current,Ko(o.nodeType===8?o.parentNode:o),hs(),C}for(;v=o.lastChild;)o.removeChild(v);if(typeof m=="function"){var A=m;m=function(){var V=Xa(L);A.call(V)}}var L=Of(o,0,!1,null,null,!1,!1,"",Oy);return o._reactRootContainer=L,o[Gr]=L.current,Ko(o.nodeType===8?o.parentNode:o),hs(function(){Qa(a,L,d,m)}),L}function tc(o,a,d,m,v){var k=d._reactRootContainer;if(k){var C=k;if(typeof v=="function"){var A=v;v=function(){var L=Xa(C);A.call(L)}}Qa(a,C,o,v)}else C=$E(d,a,o,v,m);return Xa(C)}Lo=function(o){switch(o.tag){case 3:var a=o.stateNode;if(a.current.memoizedState.isDehydrated){var d=fi(a.pendingLanes);d!==0&&(Io(a,d|1),$n(a,Tt()),(it&6)===0&&(lo=Tt()+500,ki()))}break;case 13:hs(function(){var m=Qr(o,1);if(m!==null){var v=Rn();Er(m,o,1,v)}}),Rf(o,1)}},Ft=function(o){if(o.tag===13){var a=Qr(o,134217728);if(a!==null){var d=Rn();Er(a,o,134217728,d)}Rf(o,134217728)}},dt=function(o){if(o.tag===13){var a=_i(o),d=Qr(o,a);if(d!==null){var m=Rn();Er(d,o,a,m)}Rf(o,a)}},rs=function(){return rt},Ir=function(o,a){var d=rt;try{return rt=o,a()}finally{rt=d}},kt=function(o,a,d){switch(a){case"input":if(je(o,d),a=d.name,d.type==="radio"&&a!=null){for(d=o;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<d.length;a++){var m=d[a];if(m!==o&&m.form===o.form){var v=ba(m);if(!v)throw Error(n(90));H(m),je(m,v)}}}break;case"textarea":Jt(o,d);break;case"select":a=d.value,a!=null&>(o,!!d.multiple,a,!1)}},ve=Cf,Ge=hs;var UE={usingClientEntryPoint:!1,Events:[Jo,qs,ba,I,te,Cf]},cl={findFiberByHostInstance:ss,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},HE={bundleType:cl.bundleType,version:cl.version,rendererPackageName:cl.rendererPackageName,rendererConfig:cl.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=Ql(o),o===null?null:o.stateNode},findFiberByHostInstance:cl.findFiberByHostInstance||FE,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 nc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nc.isDisabled&&nc.supportsFiber)try{Ye=nc.inject(HE),Ze=nc}catch{}}return Un.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=UE,Un.createPortal=function(o,a){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Lf(a))throw Error(n(200));return zE(o,a,null,d)},Un.createRoot=function(o,a){if(!Lf(o))throw Error(n(299));var d=!1,m="",v=Ay;return a!=null&&(a.unstable_strictMode===!0&&(d=!0),a.identifierPrefix!==void 0&&(m=a.identifierPrefix),a.onRecoverableError!==void 0&&(v=a.onRecoverableError)),a=Of(o,1,!1,null,null,d,!1,m,v),o[Gr]=a.current,Ko(o.nodeType===8?o.parentNode:o),new If(a)},Un.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=Ql(a),o=o===null?null:o.stateNode,o},Un.flushSync=function(o){return hs(o)},Un.hydrate=function(o,a,d){if(!ec(a))throw Error(n(200));return tc(null,o,a,!0,d)},Un.hydrateRoot=function(o,a,d){if(!Lf(o))throw Error(n(405));var m=d!=null&&d.hydratedSources||null,v=!1,k="",C=Ay;if(d!=null&&(d.unstable_strictMode===!0&&(v=!0),d.identifierPrefix!==void 0&&(k=d.identifierPrefix),d.onRecoverableError!==void 0&&(C=d.onRecoverableError)),a=Ty(a,null,o,1,d??null,v,!1,k,C),o[Gr]=a.current,Ko(o),m)for(o=0;o<m.length;o++)d=m[o],v=d._getVersion,v=v(d._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[d,v]:a.mutableSourceEagerHydrationData.push(d,v);return new Za(a)},Un.render=function(o,a,d){if(!ec(a))throw Error(n(200));return tc(null,o,a,!1,d)},Un.unmountComponentAtNode=function(o){if(!ec(o))throw Error(n(40));return o._reactRootContainer?(hs(function(){tc(null,null,o,!1,function(){o._reactRootContainer=null,o[Gr]=null})}),!0):!1},Un.unstable_batchedUpdates=Cf,Un.unstable_renderSubtreeIntoContainer=function(o,a,d,m){if(!ec(d))throw Error(n(200));if(o==null||o._reactInternals===void 0)throw Error(n(38));return tc(o,a,d,!1,m)},Un.version="18.3.1-next-f1338f8080-20240426",Un}var zy;function gv(){if(zy)return jf.exports;zy=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(),jf.exports=YE(),jf.exports}var Fy;function QE(){if(Fy)return rc;Fy=1;var t=gv();return rc.createRoot=t.createRoot,rc.hydrateRoot=t.hydrateRoot,rc}var XE=QE();const ZE=Lu(XE),yv=[{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"}],bv=[{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"},{id:"shelf",label:"Shelf",icon:"shelf"}],vv=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],xv=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],eS=["full","compact","minimal"],pn={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"},tS={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function nS(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(pn.typeface)){const n=tS[t];n&&localStorage.setItem(pn.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(pn.spacing)&&(localStorage.setItem(pn.spacing,e),localStorage.removeItem("ow-typography"))}function kv(){const t=localStorage.getItem(pn.typeface);return t&&yv.some(e=>e.id===t)?t:"charter"}function wv(){const t=localStorage.getItem(pn.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Du(){const t=localStorage.getItem(pn.sidebarMode);return t&&bv.some(e=>e.id===t)?t:"default"}function Ev(){return"cards"}function Sv(){const t=localStorage.getItem(pn.sidebarDensity);return t&&eS.includes(t)?t:"full"}function rS(t){localStorage.setItem(pn.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function Cv(){const t=localStorage.getItem(pn.spacing);return t&&xv.some(e=>e.id===t)?t:"default"}function Nv(){const t=localStorage.getItem(pn.canvas);return t&&vv.some(e=>e.id===t)?t:"seamless"}function _v(t,e,n,r,i="default",s="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),i==="default"?l.removeAttribute("data-spacing"):l.setAttribute("data-spacing",i),s==="seamless"?l.removeAttribute("data-canvas"):l.setAttribute("data-canvas",s),l.removeAttribute("data-color"),localStorage.setItem(pn.typeface,t),localStorage.setItem(pn.mode,e),localStorage.setItem(pn.sidebarMode,n),localStorage.setItem(pn.sidebarStyle,r),localStorage.setItem(pn.spacing,i),localStorage.setItem(pn.canvas,s)}function iS(){nS(),_v(kv(),wv(),Du(),Ev(),Cv(),Nv()),document.documentElement.setAttribute("data-sidebar-density",Sv())}var sS=gv();const oS=Lu(sS);var Ff={exports:{}},$f={};/**
|
|
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 $y;function lS(){if($y)return $f;$y=1;var t=Wl();function e(h,y){return h===y&&(h!==0||1/h===1/y)||h!==h&&y!==y}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,l=t.useDebugValue;function c(h,y){var b=y(),x=r({inst:{value:b,getSnapshot:y}}),E=x[0].inst,w=x[1];return s(function(){E.value=b,E.getSnapshot=y,u(E)&&w({inst:E})},[h,b,y]),i(function(){return u(E)&&w({inst:E}),h(function(){u(E)&&w({inst:E})})},[h]),l(b),b}function u(h){var y=h.getSnapshot;h=h.value;try{var b=y();return!n(h,b)}catch{return!0}}function f(h,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return $f.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,$f}var Uy;function Tv(){return Uy||(Uy=1,Ff.exports=lS()),Ff.exports}var Mv=Tv();function fn(t){this.content=t}fn.prototype={constructor:fn,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,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new fn(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new fn(n)},addToStart:function(t,e){return new fn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new fn(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new fn(i)},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=fn.from(t),t.size?new fn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=fn.from(t),t.size?new fn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=fn.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}};fn.from=function(t){if(t instanceof fn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new fn(e)};function Av(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let l=0;i.text[l]==s.text[l];l++)n++;return n}if(i.content.size||s.content.size){let l=Av(i.content,s.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Ov(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let l=t.child(--i),c=e.child(--s),u=l.nodeSize;if(l==c){n-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let f=0,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=Ov(l.content,c.content,n-1,r-1);if(f)return f}n-=u,r-=u}}class re{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,i=0,s){for(let l=0,c=0;c<n;l++){let u=this.content[l],f=c+u.nodeSize;if(f>e&&r(u,i+c,s||null,l)!==!1&&u.content.size){let p=c+1;u.nodesBetween(Math.max(0,e-p),Math.min(u.content.size,n-p),r,i+p)}c=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",l=!0;return this.nodesBetween(e,n,(c,u)=>{let f=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&r&&(l?l=!1:s+=r),s+=f},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new re(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,l=0;l<n;s++){let c=this.content[s],u=l+c.nodeSize;u>e&&((l<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),i+=c.nodeSize),l=u}return new re(r,i)}cutByIndex(e,n){return e==n?re.empty:e==0&&n==this.content.length?this:new re(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new re(i,s)}addToStart(e){return new re([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new re(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 i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Av(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ov(this,e,n,r)}findIndex(e){if(e==0)return ic(0,e);if(e==this.size)return ic(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 i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?ic(n+1,s):ic(n,r);r=s}}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 re.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new re(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return re.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new re(n||e,r)}static from(e){if(!e)return re.empty;if(e instanceof re)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new re([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}re.empty=new re([],0);const Uf={index:0,offset:0};function ic(t,e){return Uf.index=t,Uf.offset=e,Uf}function Bc(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(!Bc(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Bc(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ht=class Cp{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}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&&Bc(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 i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}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 Cp.none;if(e instanceof Cp)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};ht.none=[];class zc extends Error{}class xe{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=Iv(this.content,e+this.openStart,n);return r&&new xe(r,this.openStart,this.openEnd)}removeBetween(e,n){return new xe(Rv(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 xe.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new xe(re.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new xe(e,r,i)}}xe.empty=new xe(re.empty,0,0);function Rv(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(i==e||s.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,s.copy(Rv(s.content,e-i-1,n-i-1)))}function Iv(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),l=t.maybeChild(i);if(s==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Iv(l.content,e-s-1,n,l);return c&&t.replaceChild(i,l.copy(c))}function aS(t,e,n){if(n.openStart>t.depth)throw new zc("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new zc("Inconsistent open depths");return Lv(t,e,n,0)}function Lv(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let l=Lv(t,e,n,r+1);return s.copy(s.content.replaceChild(i,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 Cs(l,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:l,end:c}=cS(n,t);return Cs(s,Pv(t,l,c,e,r))}else return Cs(s,Fc(t,e,r))}function Dv(t,e){if(!e.type.compatibleContent(t.type))throw new zc("Cannot join "+e.type.name+" onto "+t.type.name)}function Np(t,e,n){let r=t.node(n);return Dv(r,e.node(n)),r}function Ss(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 wl(t,e,n,r){let i=(e||t).node(n),s=0,l=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Ss(t.nodeAfter,r),s++));for(let c=s;c<l;c++)Ss(i.child(c),r);e&&e.depth==n&&e.textOffset&&Ss(e.nodeBefore,r)}function Cs(t,e){return t.type.checkContent(e),t.copy(e)}function Pv(t,e,n,r,i){let s=t.depth>i&&Np(t,e,i+1),l=r.depth>i&&Np(n,r,i+1),c=[];return wl(null,t,i,c),s&&l&&e.index(i)==n.index(i)?(Dv(s,l),Ss(Cs(s,Pv(t,e,n,r,i+1)),c)):(s&&Ss(Cs(s,Fc(t,e,i+1)),c),wl(e,n,i,c),l&&Ss(Cs(l,Fc(n,r,i+1)),c)),wl(r,null,i,c),new re(c)}function Fc(t,e,n){let r=[];if(wl(null,t,n,r),t.depth>n){let i=Np(t,e,n+1);Ss(Cs(i,Fc(t,e,n+1)),r)}return wl(e,null,n,r),new re(r)}function cS(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(re.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Rl{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],i=e.child(n);return r?e.child(n).cut(r):i}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],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ht.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let c=r;r=i,i=c}let s=r.marks;for(var l=0;l<s.length;l++)s[l].type.spec.inclusive===!1&&(!i||!s[l].isInSet(i.marks))&&(s=s[l--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 $c(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=[],i=0,s=n;for(let l=e;;){let{index:c,offset:u}=l.content.findIndex(s),f=s-u;if(r.push(l,c,i+u),!f||(l=l.child(c),l.isText))break;s=f-1,i+=u+1}return new Rl(n,r,s)}static resolveCached(e,n){let r=Hy.get(e);if(r)for(let s=0;s<r.elts.length;s++){let l=r.elts[s];if(l.pos==n)return l}else Hy.set(e,r=new uS);let i=r.elts[r.i]=Rl.resolve(e,n);return r.i=(r.i+1)%dS,i}}class uS{constructor(){this.elts=[],this.i=0}}const dS=12,Hy=new WeakMap;class $c{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 fS=Object.create(null);class Nr{constructor(e,n,r,i=ht.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||re.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,i=0){this.content.nodesBetween(e,n,r,i,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,i){return this.content.textBetween(e,n,r,i)}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&&Bc(this.attrs,n||e.defaultAttrs||fS)&&ht.sameSet(this.marks,r||ht.none)}copy(e=null){return e==this.content?this:new Nr(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Nr(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 xe.empty;let i=this.resolve(e),s=this.resolve(n),l=r?0:i.sharedDepth(n),c=i.start(l),f=i.node(l).content.cut(i.pos-c,s.pos-c);return new xe(f,i.depth-l,s.depth-l)}replace(e,n,r){return aS(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+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 i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Rl.resolveCached(this,e)}resolveNoCache(e){return Rl.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}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()+")"),jv(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=re.empty,i=0,s=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,s),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=i;u<s;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),l=s&&s.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=ht.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(!ht.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 i=re.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}}Nr.prototype.text=void 0;class Uc extends Nr{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):jv(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 Uc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Uc(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 jv(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ms{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new pS(e,n);if(r.next==null)return Ms.empty;let i=Bv(r);r.next&&r.err("Unexpected trailing text");let s=xS(vS(i));return kS(s,r),s}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 i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}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 i=[this];function s(l,c){let u=l.matchFragment(e,r);if(u&&(!n||u.validEnd))return re.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:p,next:h}=l.next[f];if(!(p.isText||p.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let y=s(h,c.concat(p));if(y)return y}}return null}return s(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 i=r.shift(),s=i.match;if(s.matchType(e)){let l=[];for(let c=i;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<s.next.length;l++){let{type:c,next:u}=s.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!i.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:i}),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 i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let l=0;l<r.next.length;l++)s+=(l?", ":"")+r.next[l].type.name+"->"+e.indexOf(r.next[l].next);return s}).join(`
|
|
49
|
+
`)}}Ms.empty=new Ms(!0);class pS{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 Bv(t){let e=[];do e.push(hS(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function hS(t){let e=[];do e.push(mS(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function mS(t){let e=bS(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=gS(t,e);else break;return e}function Wy(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function gS(t,e){let n=Wy(t),r=n;return t.eat(",")&&(t.next!="}"?r=Wy(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function yS(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let l=n[s];l.isInGroup(e)&&i.push(l)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function bS(t){if(t.eat("(")){let e=Bv(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=yS(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 vS(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(l,c,u){let f={term:u,to:c};return e[l].push(f),f}function i(l,c){l.forEach(u=>u.to=c)}function s(l,c){if(l.type=="choice")return l.exprs.reduce((u,f)=>u.concat(s(f,c)),[]);if(l.type=="seq")for(let u=0;;u++){let f=s(l.exprs[u],c);if(u==l.exprs.length-1)return f;i(f,c=n())}else if(l.type=="star"){let u=n();return r(c,u),i(s(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=n();return i(s(l.expr,c),u),i(s(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(c)].concat(s(l.expr,c));if(l.type=="range"){let u=c;for(let f=0;f<l.min;f++){let p=n();i(s(l.expr,u),p),u=p}if(l.max==-1)i(s(l.expr,u),u);else for(let f=l.min;f<l.max;f++){let p=n();r(u,p),i(s(l.expr,u),p),u=p}return[r(u)]}else{if(l.type=="name")return[r(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function zv(t,e){return e-t}function Vy(t,e){let n=[];return r(e),n.sort(zv);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let l=0;l<s.length;l++){let{term:c,to:u}=s[l];!c&&n.indexOf(u)==-1&&r(u)}}}function xS(t){let e=Object.create(null);return n(Vy(t,0));function n(r){let i=[];r.forEach(l=>{t[l].forEach(({term:c,to:u})=>{if(!c)return;let f;for(let p=0;p<i.length;p++)i[p][0]==c&&(f=i[p][1]);Vy(t,u).forEach(p=>{f||i.push([c,f=[]]),f.indexOf(p)==-1&&f.push(p)})})});let s=e[r.join(",")]=new Ms(r.indexOf(t.length-1)>-1);for(let l=0;l<i.length;l++){let c=i[l][1].sort(zv);s.next.push({type:i[l][0],next:e[c.join(",")]||n(c)})}return s}}function kS(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,l=[];for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];l.push(u.name),s&&!(u.isText||u.hasRequiredAttrs())&&(s=!1),r.indexOf(f)==-1&&r.push(f)}s&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Fv(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 $v(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Uv(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function Hv(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new ES(t,r,e[r]);return n}let Ky=class Wv{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=Hv(e,r.attrs),this.defaultAttrs=Fv(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==Ms.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:$v(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Nr(this,this.computeAttrs(e),re.from(n),ht.setFrom(r))}createChecked(e=null,n,r){return n=re.from(n),this.checkContent(n),new Nr(this,this.computeAttrs(e),n,ht.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=re.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(re.empty,!0);return s?new Nr(this,e,n.append(s),ht.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){Uv(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:ht.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,l)=>r[s]=new Wv(s,n,l));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function wS(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class ES{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?wS(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Pu{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Hv(e,i.attrs),this.excluded=null;let s=Fv(this.attrs);this.instance=s?new ht(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ht(this,$v(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,l)=>r[s]=new Pu(s,i++,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){Uv(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Vv{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=fn.from(e.nodes),n.marks=fn.from(e.marks||{}),this.nodes=Ky.compile(this.spec.nodes,this),this.marks=Pu.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],l=s.spec.content||"",c=s.spec.marks;if(s.contentMatch=r[l]||(r[l]=Ms.parse(l,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=c=="_"?null:c?Gy(this,c.split(" ")):c==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],l=s.spec.excludes;s.excluded=l==null?[s]:l==""?[]:Gy(this,l.split(" "))}this.nodeFromJSON=i=>Nr.fromJSON(this,i),this.markFromJSON=i=>ht.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ky){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,i)}text(e,n){let r=this.nodes.text;return new Uc(r,r.defaultAttrs,e,ht.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 Gy(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],l=s;if(s)n.push(s);else for(let c in t.marks){let u=t.marks[c];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&n.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function SS(t){return t.tag!=null}function CS(t){return t.style!=null}class Ui{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(SS(i))this.tags.push(i);else if(CS(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new Jy(this,n,!1);return r.addAll(e,ht.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Jy(this,n,!0);return r.addAll(e,ht.none,n.from,n.to),xe.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(TS(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let l=s.getAttrs(e);if(l===!1)continue;s.attrs=l||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let l=this.styles[s],c=l.style;if(!(c.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<s)break}n.splice(l,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(l=>{r(l=Yy(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(l=>{r(l=Yy(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ui(e,Ui.schemaRules(e)))}}const Kv={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},NS={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Gv={ol:!0,ul:!0},Il=1,_p=2,El=4;function qy(t,e,n){return e!=null?(e?Il:0)|(e==="full"?_p:0):t&&t.whitespace=="pre"?Il|_p:n&~El}class sc{constructor(e,n,r,i,s,l){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=l,this.content=[],this.activeMarks=ht.none,this.match=s||(l&El?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(re.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Il)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=re.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(re.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&&!Kv.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Jy{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,l=qy(null,n.preserveWhitespace,0)|(r?El:0);i?s=new sc(i.type,i.attrs,ht.none,!0,n.topMatch||i.type.contentMatch,l):r?s=new sc(null,null,ht.none,!0,null,l):s=new sc(e.schema.topNodeType,null,ht.none,!0,null,l),this.nodes=[s],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,i=this.top,s=i.options&_p?"full":this.localPreserveWS||(i.options&Il)>0,{schema:l}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
50
|
+
`);else if(l.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let u=0;u<c.length;u++)u&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[u]&&this.insertNode(l.text(c[u]),n,!/\S/.test(c[u]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let c=i.content[i.content.length-1],u=e.previousSibling;(!c||u&&u.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(r=r.slice(1))}r&&this.insertNode(l.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let l=e.nodeName.toLowerCase(),c;Gv.hasOwnProperty(l)&&this.parser.normalizeLists&&_S(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(u?u.ignore:NS.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,n);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let f,p=this.needsBlock;if(Kv.hasOwnProperty(l))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),f=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let h=u&&u.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),f&&this.sync(s),this.needsBlock=p}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,u,f,u.consuming===!1?c:void 0)}this.localPreserveWS=i}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 i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],l=r.getPropertyValue(s);if(l)for(let c=void 0;;){let u=this.parser.matchStyle(s,l,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?n=n.filter(f=>!u.clearMark(f)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,r,i){let s,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(l,n.attrs||null,r,n.preserveWhitespace);u&&(s=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(l&&l.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}s&&this.sync(c)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let l=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];l!=c;l=l.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(l,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let l=this.open,c=0;l>=0;l--){let u=this.nodes[l],f=u.findWrapping(e);if(f&&(!i||i.length>f.length+c)&&(i=f,s=u,!f.length))break;if(u.solid){if(r)break;c+=2}}if(!i)return null;this.sync(s);for(let l=0;l<i.length;l++)n=this.enterInner(i[l],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let l=ht.none;for(let c of i.concat(e.marks))(s.type?s.type.allowsMarkType(c.type):Qy(c.type,e.type))&&(l=c.addToSet(l));return s.content.push(e.mark(l)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let c=qy(e,s,l.options);l.options&El&&l.content.length==0&&(c|=El);let u=ht.none;return r=r.filter(f=>(l.type?l.type.allowsMarkType(f.type):Qy(f.type,e))?(u=f.addToSet(u),!1):!0),this.nodes.push(new sc(e,n,u,i,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|=Il)}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 i=r.length-1;i>=0;i--)e+=r[i].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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),l=(c,u)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;u>=s;u--)if(l(c-1,u))return!0;return!1}else{let p=u>0||u==0&&i?this.nodes[u].type:r&&u>=s?r.node(u-s).type:null;if(!p||p.name!=f&&!p.isInGroup(f))return!1;u--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function _S(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Gv.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function TS(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Yy(t){let e={};for(let n in t)e[n]=t[n];return e}function Qy(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],l=c=>{s.push(c);for(let u=0;u<c.edgeCount;u++){let{type:f,next:p}=c.edge(u);if(f==e||s.indexOf(p)<0&&l(p))return!0}};if(l(i.contentMatch))return!0}}class Ps{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Hf(n).createDocumentFragment());let i=r,s=[];return e.forEach(l=>{if(s.length||l.marks.length){let c=0,u=0;for(;c<s.length&&u<l.marks.length;){let f=l.marks[u];if(!this.marks[f.type.name]){u++;continue}if(!f.eq(s[c][0])||f.type.spec.spanning===!1)break;c++,u++}for(;c<s.length;)i=s.pop()[1];for(;u<l.marks.length;){let f=l.marks[u++],p=this.serializeMark(f,l.isInline,n);p&&(s.push([f,i]),i.appendChild(p.dom),i=p.contentDOM||p.dom)}}i.appendChild(this.serializeNodeInner(l,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Oc(Hf(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Oc(Hf(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Oc(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ps(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Xy(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Xy(e.marks)}}function Xy(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Hf(t){return t.document||window.document}const Zy=new WeakMap;function MS(t){let e=Zy.get(t);return e===void 0&&Zy.set(t,e=AS(t)),e}function AS(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 i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Oc(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 i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=MS(r))&&s.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=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let c,u=n?t.createElementNS(n,i):t.createElement(i),f=e[1],p=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){p=2;for(let h in f)if(f[h]!=null){let y=h.indexOf(" ");y>0?u.setAttributeNS(h.slice(0,y),h.slice(y+1),f[h]):h=="style"&&u.style?u.style.cssText=f[h]:u.setAttribute(h,f[h])}}for(let h=p;h<e.length;h++){let y=e[h];if(y===0){if(h<e.length-1||h>p)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:b,contentDOM:x}=Oc(t,y,n,r);if(u.appendChild(b),x){if(c)throw new RangeError("Multiple content holes");c=x}}}return{dom:u,contentDOM:c}}const qv=65535,Jv=Math.pow(2,16);function OS(t,e){return t+e*Jv}function eb(t){return t&qv}function RS(t){return(t-(t&qv))/Jv}const Yv=1,Qv=2,Rc=4,Xv=8;class Tp{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Xv)>0}get deletedBefore(){return(this.delInfo&(Yv|Rc))>0}get deletedAfter(){return(this.delInfo&(Qv|Rc))>0}get deletedAcross(){return(this.delInfo&Rc)>0}}class Xn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Xn.empty)return Xn.empty}recover(e){let n=0,r=eb(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+RS(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 i=0,s=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>e)break;let f=this.ranges[c+s],p=this.ranges[c+l],h=u+f;if(e<=h){let y=f?e==u?-1:e==h?1:n:n,b=u+i+(y<0?0:p);if(r)return b;let x=e==(n<0?u:h)?null:OS(c/3,e-u),E=e==u?Qv:e==h?Yv:Rc;return(n<0?e!=u:e!=h)&&(E|=Xv),new Tp(b,E,x)}i+=p-f}return r?e+i:new Tp(e+i,0,null)}touches(e,n){let r=0,i=eb(n),s=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[c+s],p=u+f;if(e<=p&&c==i*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 i=0,s=0;i<this.ranges.length;i+=3){let l=this.ranges[i],c=l-(this.inverted?s:0),u=l+(this.inverted?0:s),f=this.ranges[i+n],p=this.ranges[i+r];e(c,c+f,u,u+p),s+=p-f}}invert(){return new Xn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Xn.empty:new Xn(e<0?[0,-e,0]:[0,0,e])}}Xn.empty=new Xn([]);class Ll{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Ll(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 i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i: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 i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Ll;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 i=0;for(let s=this.from;s<this.to;s++){let l=this._maps[s],c=l.mapResult(e,n);if(c.recover!=null){let u=this.getMirror(s);if(u!=null&&u>s&&u<this.to){s=u,e=this._maps[u].recover(c.recover);continue}}i|=c.delInfo,e=c.pos}return r?e:new Tp(e,i,null)}}const Wf=Object.create(null);class Tn{getMap(){return Xn.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Wf[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 Wf)throw new RangeError("Duplicate use of step JSON ID "+e);return Wf[e]=n,n.prototype.jsonID=e,n}}class Gt{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Gt(e,null)}static fail(e){return new Gt(null,e)}static fromReplace(e,n,r,i){try{return Gt.ok(e.replace(n,r,i))}catch(s){if(s instanceof zc)return Gt.fail(s.message);throw s}}}function dh(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(dh(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return re.fromArray(r)}class zi extends Tn{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),i=r.node(r.sharedDepth(this.to)),s=new xe(dh(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return Gt.fromReplace(e,this.from,this.to,s)}invert(){return new Cr(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 zi(n.pos,r.pos,this.mark)}merge(e){return e instanceof zi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new zi(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 zi(n.from,n.to,e.markFromJSON(n.mark))}}Tn.jsonID("addMark",zi);class Cr extends Tn{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 xe(dh(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Gt.fromReplace(e,this.from,this.to,r)}invert(){return new zi(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 Cr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Cr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Cr(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 Cr(n.from,n.to,e.markFromJSON(n.mark))}}Tn.jsonID("removeMark",Cr);class Fi extends Tn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Gt.fromReplace(e,this.pos,this.pos+1,new xe(re.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 i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Fi(this.pos,n.marks[i]);return new Fi(this.pos,this.mark)}}return new As(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Fi(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 Fi(n.pos,e.markFromJSON(n.mark))}}Tn.jsonID("addNodeMark",Fi);class As extends Tn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Gt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Gt.fromReplace(e,this.pos,this.pos+1,new xe(re.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Fi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new As(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 As(n.pos,e.markFromJSON(n.mark))}}Tn.jsonID("removeNodeMark",As);class rn extends Tn{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Mp(e,this.from,this.to)?Gt.fail("Structure replace would overwrite content"):Gt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Xn([this.from,this.to-this.from,this.slice.size])}invert(e){return new rn(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 rn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof rn)||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?xe.empty:new xe(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new rn(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?xe.empty:new xe(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new rn(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 rn(n.from,n.to,xe.fromJSON(e,n.slice),!!n.structure)}}Tn.jsonID("replace",rn);class sn extends Tn{constructor(e,n,r,i,s,l,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=l,this.structure=c}apply(e){if(this.structure&&(Mp(e,this.from,this.gapFrom)||Mp(e,this.gapTo,this.to)))return Gt.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Gt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Gt.fromReplace(e,this.from,this.to,r):Gt.fail("Content does not fit in gap")}getMap(){return new Xn([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 sn(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),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new sn(n.pos,r.pos,i,s,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 sn(n.from,n.to,n.gapFrom,n.gapTo,xe.fromJSON(e,n.slice),n.insert,!!n.structure)}}Tn.jsonID("replaceAround",sn);function Mp(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let l=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function IS(t,e,n,r){let i=[],s=[],l,c;t.doc.nodesBetween(e,n,(u,f,p)=>{if(!u.isInline)return;let h=u.marks;if(!r.isInSet(h)&&p.type.allowsMarkType(r.type)){let y=Math.max(f,e),b=Math.min(f+u.nodeSize,n),x=r.addToSet(h);for(let E=0;E<h.length;E++)h[E].isInSet(x)||(l&&l.to==y&&l.mark.eq(h[E])?l.to=b:i.push(l=new Cr(y,b,h[E])));c&&c.to==y?c.to=b:s.push(c=new zi(y,b,r))}}),i.forEach(u=>t.step(u)),s.forEach(u=>t.step(u))}function LS(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(l,c)=>{if(!l.isInline)return;s++;let u=null;if(r instanceof Pu){let f=l.marks,p;for(;p=r.isInSet(f);)(u||(u=[])).push(p),f=p.removeFromSet(f)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let f=Math.min(c+l.nodeSize,n);for(let p=0;p<u.length;p++){let h=u[p],y;for(let b=0;b<i.length;b++){let x=i[b];x.step==s-1&&h.eq(i[b].style)&&(y=x)}y?(y.to=f,y.step=s):i.push({style:h,from:Math.max(c,e),to:f,step:s})}}}),i.forEach(l=>t.step(new Cr(l.from,l.to,l.style)))}function fh(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),l=[],c=e+1;for(let u=0;u<s.childCount;u++){let f=s.child(u),p=c+f.nodeSize,h=r.matchType(f.type);if(!h)l.push(new rn(c,p,xe.empty));else{r=h;for(let y=0;y<f.marks.length;y++)n.allowsMarkType(f.marks[y].type)||t.step(new Cr(c,p,f.marks[y]));if(i&&f.isText&&n.whitespace!="pre"){let y,b=/\r?\n|\r/g,x;for(;y=b.exec(f.text);)x||(x=new xe(re.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new rn(c+y.index,c+y.index+y[0].length,x))}}c=p}if(!r.validEnd){let u=r.fillBefore(re.empty,!0);t.replace(c,c,new xe(u,0,0))}for(let u=l.length-1;u>=0;u--)t.step(l[u])}function DS(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function _o(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let l=t.$from.node(r),c=t.$from.index(r)+i,u=t.$to.indexAfter(r)-s;if(r<t.depth&&l.canReplace(c,u,n))return r;if(r==0||l.type.spec.isolating||!DS(l,c,u))break;c&&(i=1),u<l.childCount&&(s=1)}return null}function PS(t,e,n){let{$from:r,$to:i,depth:s}=e,l=r.before(s+1),c=i.after(s+1),u=l,f=c,p=re.empty,h=0;for(let x=s,E=!1;x>n;x--)E||r.index(x)>0?(E=!0,p=re.from(r.node(x).copy(p)),h++):u--;let y=re.empty,b=0;for(let x=s,E=!1;x>n;x--)E||i.after(x+1)<i.end(x)?(E=!0,y=re.from(i.node(x).copy(y)),b++):f++;t.step(new sn(u,f,l,c,new xe(p.append(y),h,b),p.size-h,!0))}function ph(t,e,n=null,r=t){let i=jS(t,e),s=i&&BS(r,e);return s?i.map(tb).concat({type:e,attrs:n}).concat(s.map(tb)):null}function tb(t){return{type:t,attrs:null}}function jS(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let l=s.length?s[0]:e;return n.canReplaceWith(r,i,l)?s:null}function BS(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),l=e.contentMatch.findWrapping(s.type);if(!l)return null;let u=(l.length?l[l.length-1]:e).contentMatch;for(let f=r;u&&f<i;f++)u=u.matchType(n.child(f).type);return!u||!u.validEnd?null:l}function zS(t,e,n){let r=re.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=re.from(n[l].type.create(n[l].attrs,r))}let i=e.start,s=e.end;t.step(new sn(i,s,i,s,new xe(r,0,0),n.length,!0))}function FS(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(l,c)=>{let u=typeof i=="function"?i(l):i;if(l.isTextblock&&!l.hasMarkup(r,u)&&$S(t.doc,t.mapping.slice(s).map(c),r)){let f=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!x?f=!1:!b&&x&&(f=!0)}f===!1&&ex(t,l,c,s),fh(t,t.mapping.slice(s).map(c,1),r,void 0,f===null);let p=t.mapping.slice(s),h=p.map(c,1),y=p.map(c+l.nodeSize,1);return t.step(new sn(h,y,h+1,y-1,new xe(re.from(r.create(u,null,l.marks)),0,0),1,!0)),f===!0&&Zv(t,l,c,s),!1}})}function Zv(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(i.text);){let u=t.mapping.slice(r).map(n+1+s+l.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function ex(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let l=t.mapping.slice(r).map(n+1+s);t.replaceWith(l,l+1,e.type.schema.text(`
|
|
52
|
+
`))}})}function $S(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function US(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let l=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,l);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new sn(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new xe(re.from(l),0,0),1,!0))}function ai(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,l=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let f=i.depth-1,p=n-2;f>s;f--,p--){let h=i.node(f),y=i.index(f);if(h.type.spec.isolating)return!1;let b=h.content.cutByIndex(y,h.childCount),x=r&&r[p+1];x&&(b=b.replaceChild(0,x.type.create(x.attrs)));let E=r&&r[p]||h;if(!h.canReplace(y+1,h.childCount)||!E.type.validContent(b))return!1}let c=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(c,c,u?u.type:i.node(s+1).type)}function HS(t,e,n=1,r){let i=t.doc.resolve(e),s=re.empty,l=re.empty;for(let c=i.depth,u=i.depth-n,f=n-1;c>u;c--,f--){s=re.from(i.node(c).copy(s));let p=r&&r[f];l=re.from(p?p.type.create(p.attrs,l):i.node(c).copy(l))}t.step(new rn(e,e,new xe(s.append(l),n,n),!0))}function Yi(t,e){let n=t.resolve(e),r=n.index();return tx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function WS(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),l=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(l),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function tx(t,e){return!!(t&&e&&!t.isLeaf&&WS(t,e))}function ju(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,l,c=r.index(i);if(i==r.depth?(s=r.nodeBefore,l=r.nodeAfter):n>0?(s=r.node(i+1),c++,l=r.node(i).maybeChild(c)):(s=r.node(i).maybeChild(c-1),l=r.node(i+1)),s&&!s.isTextblock&&tx(s,l)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function VS(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),l=s.node().type;if(i&&l.inlineContent){let p=l.whitespace=="pre",h=!!l.contentMatch.matchType(i);p&&!h?r=!1:!p&&h&&(r=!0)}let c=t.steps.length;if(r===!1){let p=t.doc.resolve(e+n);ex(t,p.node(),p.before(),c)}l.inlineContent&&fh(t,e+n-1,l,s.node().contentMatchAt(s.index()),r==null);let u=t.mapping.slice(c),f=u.map(e-n);if(t.step(new rn(f,u.map(e+n,-1),xe.empty,!0)),r===!0){let p=t.doc.resolve(f);Zv(t,p.node(),p.before(),t.steps.length)}return t}function KS(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 i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function nx(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let l=r.depth;l>=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(c>0?1:0),f=r.node(l),p=!1;if(s==1)p=f.canReplace(u,u,i);else{let h=f.contentMatchAt(u).findWrapping(i.firstChild.type);p=h&&f.canReplaceWith(u,u,h[0])}if(p)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Bu(t,e,n=e,r=xe.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return rx(i,s,r)?new rn(e,n,r):new GS(i,s,r).fit()}function rx(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class GS{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=re.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=re.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,l=r.depth,c=i.depth;for(;l&&c&&s.childCount==1;)s=s.firstChild.content,l--,c--;let u=new xe(s,l,c);return e>-1?new sn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new rn(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Vf(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let l=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:f}=this.frontier[c],p,h=null;if(n==1&&(l?f.matchType(l.type)||(h=f.fillBefore(re.from(l),!1)):s&&u.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:c,parent:s,inject:h};if(n==2&&l&&(p=f.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:s,wrap:p};if(s&&f.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Vf(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new xe(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Vf(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new xe(yl(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new xe(yl(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let E=0;E<s.length;E++)this.openFrontierNode(s[E]);let l=this.unplaced,c=r?r.content:l.content,u=l.openStart-e,f=0,p=[],{match:h,type:y}=this.frontier[n];if(i){for(let E=0;E<i.childCount;E++)p.push(i.child(E));h=h.matchFragment(i)}let b=c.size+e-(l.content.size-l.openEnd);for(;f<c.childCount;){let E=c.child(f),w=h.matchType(E.type);if(!w)break;f++,(f>1||u==0||E.content.size)&&(h=w,p.push(ix(E.mark(y.allowedMarks(E.marks)),f==1?u:0,f==c.childCount?b:-1)))}let x=f==c.childCount;x||(b=-1),this.placed=bl(this.placed,n,re.from(p)),this.frontier[n].match=h,x&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let E=0,w=c;E<b;E++){let S=w.lastChild;this.frontier.push({type:S.type,match:S.contentMatchAt(S.childCount)}),w=S.content}this.unplaced=x?e==0?xe.empty:new xe(yl(l.content,e-1,1),e-1,b<0?l.openEnd:e-1):new xe(yl(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||!Kf(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,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),l=Kf(e,n,i,r,s);if(l){for(let c=n-1;c>=0;c--){let{match:u,type:f}=this.frontier[c],p=Kf(e,c,f,u,!0);if(!p||p.childCount)continue e}return{depth:n,fit:l,move:s?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=bl(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=bl(this.placed,this.depth,re.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(re.empty,!0);n.childCount&&(this.placed=bl(this.placed,this.frontier.length,n))}}function yl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(yl(t.firstChild.content,e-1,n)))}function bl(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(bl(t.lastChild.content,e-1,n)))}function Vf(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ix(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ix(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(re.empty,!0)))),t.copy(r)}function Kf(t,e,n,r,i){let s=t.node(e),l=i?t.indexAfter(e):t.index(e);if(l==s.childCount&&!n.compatibleContent(s.type))return null;let c=r.fillBefore(s.content,!0,l);return c&&!qS(n,s.content,l)?c:null}function qS(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function JS(t){return t.spec.defining||t.spec.definingForContent}function YS(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(rx(i,s,r))return t.step(new rn(e,n,r));let l=ox(i,s);l[l.length-1]==0&&l.pop();let c=-(i.depth+1);l.unshift(c);for(let y=i.depth,b=i.pos-1;y>0;y--,b--){let x=i.node(y).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;l.indexOf(y)>-1?c=y:i.before(y)==b&&l.splice(1,0,-y)}let u=l.indexOf(c),f=[],p=r.openStart;for(let y=r.content,b=0;;b++){let x=y.firstChild;if(f.push(x),b==r.openStart)break;y=x.content}for(let y=p-1;y>=0;y--){let b=f[y],x=JS(b.type);if(x&&!b.sameMarkup(i.node(Math.abs(c)-1)))p=y;else if(x||!b.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let b=(y+p+1)%(r.openStart+1),x=f[b];if(x)for(let E=0;E<l.length;E++){let w=l[(E+u)%l.length],S=!0;w<0&&(S=!1,w=-w);let _=i.node(w-1),M=i.index(w-1);if(_.canReplaceWith(M,M,x.type,x.marks))return t.replace(i.before(w),S?s.after(w):n,new xe(sx(r.content,0,r.openStart,b),b,r.openEnd))}}let h=t.steps.length;for(let y=l.length-1;y>=0&&(t.replace(e,n,r),!(t.steps.length>h));y--){let b=l[y];b<0||(e=i.before(b),n=s.after(b))}}function sx(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(sx(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),l=s.fillBefore(t).append(t);t=l.append(s.matchFragment(l).fillBefore(re.empty,!0))}return t}function QS(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=KS(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new xe(re.from(r),0,0))}function XS(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=ox(r,i);for(let l=0;l<s.length;l++){let c=s[l],u=l==s.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return t.delete(r.start(c),i.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return t.delete(r.before(c),i.after(c))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&i.end(l)-n!=i.depth-l&&r.start(l-1)==i.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),i.index(l-1)))return t.delete(r.before(l),n);t.delete(e,n)}function ox(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class bo extends Tn{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 Gt.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Gt.fromReplace(e,this.pos,this.pos+1,new xe(re.from(i),0,n.isLeaf?0:1))}getMap(){return Xn.empty}invert(e){return new bo(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 bo(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 bo(n.pos,n.attr,n.value)}}Tn.jsonID("attr",bo);class Dl extends Tn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Gt.ok(r)}getMap(){return Xn.empty}invert(e){return new Dl(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 Dl(n.attr,n.value)}}Tn.jsonID("docAttr",Dl);let ko=class extends Error{};ko=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ko.prototype=Object.create(Error.prototype);ko.prototype.constructor=ko;ko.prototype.name="TransformError";class hh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ll}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ko(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 i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((s,l,c,u)=>{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=xe.empty){let i=Bu(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new xe(re.from(r),0,0))}delete(e,n){return this.replace(e,n,xe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return YS(this,e,n,r),this}replaceRangeWith(e,n,r){return QS(this,e,n,r),this}deleteRange(e,n){return XS(this,e,n),this}lift(e,n){return PS(this,e,n),this}join(e,n=1){return VS(this,e,n),this}wrap(e,n){return zS(this,e,n),this}setBlockType(e,n=e,r,i=null){return FS(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return US(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new bo(e,n,r)),this}setDocAttribute(e,n){return this.step(new Dl(e,n)),this}addNodeMark(e,n){return this.step(new Fi(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 ht)n.isInSet(r.marks)&&this.step(new As(e,n));else{let i=r.marks,s,l=[];for(;s=n.isInSet(i);)l.push(new As(e,s)),i=s.removeFromSet(i);for(let c=l.length-1;c>=0;c--)this.step(l[c])}return this}split(e,n=1,r){return HS(this,e,n,r),this}addMark(e,n,r){return IS(this,e,n,r),this}removeMark(e,n,r){return LS(this,e,n,r),this}clearIncompatible(e,n,r){return fh(this,e,n,r),this}}const Gf=Object.create(null);class Ve{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new lx(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=xe.empty){let r=n.content.lastChild,i=null;for(let c=0;c<n.openEnd;c++)i=r,r=r.lastChild;let s=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:f}=l[c],p=e.mapping.slice(s);e.replaceRange(p.map(u.pos),p.map(f.pos),c?xe.empty:n),c==0&&ib(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:c}=i[s],u=e.mapping.slice(r),f=u.map(l.pos),p=u.map(c.pos);s?e.deleteRange(f,p):(e.replaceRangeWith(f,p,n),ib(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new Fe(e):fo(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let l=n<0?fo(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):fo(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new er(e.node(0))}static atStart(e){return fo(e,e,0,0,1)||new er(e)}static atEnd(e){return fo(e,e,e.content.size,e.childCount,-1)||new er(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Gf[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 Gf)throw new RangeError("Duplicate use of selection JSON ID "+e);return Gf[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Fe.between(this.$anchor,this.$head).getBookmark()}}Ve.prototype.visible=!0;class lx{constructor(e,n){this.$from=e,this.$to=n}}let nb=!1;function rb(t){!nb&&!t.parent.inlineContent&&(nb=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Fe extends Ve{constructor(e,n=e){rb(e),rb(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 Ve.near(r);let i=e.resolve(n.map(this.anchor));return new Fe(i.parent.inlineContent?i:r,r)}replace(e,n=xe.empty){if(super.replace(e,n),n==xe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Fe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new zu(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 Fe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=Ve.findFrom(n,r,!0)||Ve.findFrom(n,-r,!0);if(s)n=s.$head;else return Ve.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Ve.findFrom(e,-r,!0)||Ve.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new Fe(e,n)}}Ve.jsonID("text",Fe);class zu{constructor(e,n){this.anchor=e,this.head=n}map(e){return new zu(e.map(this.anchor),e.map(this.head))}resolve(e){return Fe.between(e.resolve(this.anchor),e.resolve(this.head))}}class Be extends Ve{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:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?Ve.near(s):new Be(s)}content(){return new xe(re.from(this.node),0,0)}eq(e){return e instanceof Be&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new mh(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Be(e.resolve(n.anchor))}static create(e,n){return new Be(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Be.prototype.visible=!1;Ve.jsonID("node",Be);class mh{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new zu(r,r):new mh(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Be.isSelectable(r)?new Be(n):Ve.near(n)}}class er extends Ve{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=xe.empty){if(n==xe.empty){e.delete(0,e.doc.content.size);let r=Ve.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new er(e)}map(e){return new er(e)}eq(e){return e instanceof er}getBookmark(){return ZS}}Ve.jsonID("all",er);const ZS={map(){return this},resolve(t){return new er(t)}};function fo(t,e,n,r,i,s=!1){if(e.inlineContent)return Fe.create(t,n);for(let l=r-(i>0?0:1);i>0?l<e.childCount:l>=0;l+=i){let c=e.child(l);if(c.isAtom){if(!s&&Be.isSelectable(c))return Be.create(t,n-(i<0?c.nodeSize:0))}else{let u=fo(t,c,n+i,i<0?c.childCount:0,i,s);if(u)return u}n+=c.nodeSize*i}return null}function ib(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof rn||i instanceof sn))return;let s=t.mapping.maps[r],l;s.forEach((c,u,f,p)=>{l==null&&(l=p)}),t.setSelection(Ve.near(t.doc.resolve(l),n))}const sb=1,oc=2,ob=4;class eC extends hh{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|sb)&~oc,this.storedMarks=null,this}get selectionSet(){return(this.updated&sb)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=oc,this}ensureMarks(e){return ht.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&oc)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~oc,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)||ht.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let l=this.doc.resolve(n);s=r==n?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ve.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|=ob,this}get scrolledIntoView(){return(this.updated&ob)>0}}function lb(t,e){return!e||!t?t:t.bind(e)}class vl{constructor(e,n,r){this.name=e,this.init=lb(n.init,r),this.apply=lb(n.apply,r)}}const tC=[new vl("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new vl("selection",{init(t,e){return t.selection||Ve.atStart(e.doc)},apply(t){return t.selection}}),new vl("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new vl("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class qf{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=tC.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 vl(r.key,r.spec.state,r))})}}class yo{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 i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let l=0;l<this.config.plugins.length;l++){let c=this.config.plugins[l];if(c.spec.appendTransaction){let u=i?i[l].n:0,f=i?i[l].state:this,p=u<n.length&&c.spec.appendTransaction.call(c,u?n.slice(u):n,f,r);if(p&&r.filterTransaction(p,l)){if(p.setMeta("appendedTransaction",e),!i){i=[];for(let h=0;h<this.config.plugins.length;h++)i.push(h<l?{state:r,n:n.length}:{state:this,n:0})}n.push(p),r=r.applyInner(p),s=!0}i&&(i[l]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new yo(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new eC(this)}static create(e){let n=new qf(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new yo(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new qf(this.schema,e.plugins),r=n.fields,i=new yo(n);for(let s=0;s<r.length;s++){let l=r[s].name;i[l]=this.hasOwnProperty(l)?this[l]:r[s].init(e,i)}return i}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 i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.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 i=new qf(e.schema,e.plugins),s=new yo(i);return i.fields.forEach(l=>{if(l.name=="doc")s.doc=Nr.fromJSON(e.schema,n.doc);else if(l.name=="selection")s.selection=Ve.fromJSON(s.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],f=u.spec.state;if(u.key==l.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){s[l.name]=f.fromJSON.call(u,e,n[c],s);return}}s[l.name]=l.init(e,s)}}),s}}function ax(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ax(i,e,{})),n[r]=i}return n}class ut{constructor(e){this.spec=e,this.props={},e.props&&ax(e.props,this,this.props),this.key=e.key?e.key.key:cx("plugin")}getState(e){return e[this.key]}}const Jf=Object.create(null);function cx(t){return t in Jf?t+"$"+ ++Jf[t]:(Jf[t]=0,t+"$")}class mt{constructor(e="key"){this.key=cx(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const gh=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ux(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const dx=(t,e,n)=>{let r=ux(t,n);if(!r)return!1;let i=yh(r);if(!i){let l=r.blockRange(),c=l&&_o(l);return c==null?!1:(e&&e(t.tr.lift(l,c).scrollIntoView()),!0)}let s=i.nodeBefore;if(xx(t,i,e,-1))return!0;if(r.parent.content.size==0&&(wo(s,"end")||Be.isSelectable(s)))for(let l=r.depth;;l--){let c=Bu(t.doc,r.before(l),r.after(l),xe.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=t.tr.step(c);u.setSelection(wo(s,"end")?Ve.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):Be.create(u.doc,i.pos-s.nodeSize)),e(u.scrollIntoView())}return!0}if(l==1||r.node(l-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},nC=(t,e,n)=>{let r=ux(t,n);if(!r)return!1;let i=yh(r);return i?fx(t,i,e):!1},rC=(t,e,n)=>{let r=hx(t,n);if(!r)return!1;let i=bh(r);return i?fx(t,i,e):!1};function fx(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let p=i.lastChild;if(!p)return!1;i=p}let l=e.nodeAfter,c=l,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let p=c.firstChild;if(!p)return!1;c=p}let f=Bu(t.doc,s,u,xe.empty);if(!f||f.from!=s||f instanceof rn&&f.slice.size>=u-s)return!1;if(n){let p=t.tr.step(f);p.setSelection(Fe.create(p.doc,s)),n(p.scrollIntoView())}return!0}function wo(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 px=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=yh(r)}let l=s&&s.nodeBefore;return!l||!Be.isSelectable(l)?!1:(e&&e(t.tr.setSelection(Be.create(t.doc,s.pos-l.nodeSize)).scrollIntoView()),!0)};function yh(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 hx(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const mx=(t,e,n)=>{let r=hx(t,n);if(!r)return!1;let i=bh(r);if(!i)return!1;let s=i.nodeAfter;if(xx(t,i,e,1))return!0;if(r.parent.content.size==0&&(wo(s,"start")||Be.isSelectable(s))){let l=Bu(t.doc,r.before(),r.after(),xe.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(wo(s,"start")?Ve.findFrom(c.doc.resolve(c.mapping.map(i.pos)),1):Be.create(c.doc,c.mapping.map(i.pos))),e(c.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},gx=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=bh(r)}let l=s&&s.nodeAfter;return!l||!Be.isSelectable(l)?!1:(e&&e(t.tr.setSelection(Be.create(t.doc,s.pos)).scrollIntoView()),!0)};function bh(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 iC=(t,e)=>{let n=t.selection,r=n instanceof Be,i;if(r){if(n.node.isTextblock||!Yi(t.doc,n.from))return!1;i=n.from}else if(i=ju(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(Be.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},sC=(t,e)=>{let n=t.selection,r;if(n instanceof Be){if(n.node.isTextblock||!Yi(t.doc,n.to))return!1;r=n.to}else if(r=ju(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},oC=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&_o(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},yx=(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 vh(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 lC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),l=vh(i.contentMatchAt(s));if(!l||!i.canReplaceWith(s,s,l))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,l.createAndFill());u.setSelection(Ve.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},bx=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof er||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=vh(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let l=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,c=t.tr.insert(l,s.createAndFill());c.setSelection(Fe.create(c.doc,l+1)),e(c.scrollIntoView())}return!0},vx=(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 s=n.before();if(ai(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&_o(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function aC(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Be&&e.selection.node.isBlock)return!r.parentOffset||!ai(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],l,c,u=!1,f=!1;for(let b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),f=r.start(b)==r.pos-(r.depth-b),c=vh(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),s.unshift(u&&c?{type:c}:null),l=b;break}else{if(b==1)return!1;s.unshift(null)}let p=e.tr;(e.selection instanceof Fe||e.selection instanceof er)&&p.deleteSelection();let h=p.mapping.map(r.pos),y=ai(p.doc,h,s.length,s);if(y||(s[0]=c?{type:c}:null,y=ai(p.doc,h,s.length,s)),!y)return!1;if(p.split(h,s.length,s),!u&&f&&r.node(l).type!=c){let b=p.mapping.map(r.before(l)),x=p.doc.resolve(b);c&&r.node(l-1).canReplaceWith(x.index(),x.index()+1,c)&&p.setNodeMarkup(p.mapping.map(r.before(l)),c)}return n&&n(p.scrollIntoView()),!0}}const cC=aC(),uC=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(Be.create(t.doc,i))),!0)};function dC(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Yi(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function xx(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,l,c,u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&dC(t,e,n))return!0;let f=!u&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(l=(c=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&c.matchType(l[0]||s.type).validEnd){if(n){let b=e.pos+s.nodeSize,x=re.empty;for(let S=l.length-1;S>=0;S--)x=re.from(l[S].create(null,x));x=re.from(i.copy(x));let E=t.tr.step(new sn(e.pos-1,b,e.pos,b,new xe(x,1,0),l.length,!0)),w=E.doc.resolve(b+2*l.length);w.nodeAfter&&w.nodeAfter.type==i.type&&Yi(E.doc,w.pos)&&E.join(w.pos),n(E.scrollIntoView())}return!0}let p=s.type.spec.isolating||r>0&&u?null:Ve.findFrom(e,1),h=p&&p.$from.blockRange(p.$to),y=h&&_o(h);if(y!=null&&y>=e.depth)return n&&n(t.tr.lift(h,y).scrollIntoView()),!0;if(f&&wo(s,"start",!0)&&wo(i,"end")){let b=i,x=[];for(;x.push(b),!b.isTextblock;)b=b.lastChild;let E=s,w=1;for(;!E.isTextblock;E=E.firstChild)w++;if(b.canReplace(b.childCount,b.childCount,E.content)){if(n){let S=re.empty;for(let M=x.length-1;M>=0;M--)S=re.from(x[M].copy(S));let _=t.tr.step(new sn(e.pos-x.length,e.pos+s.nodeSize,e.pos+w,e.pos+s.nodeSize-w,new xe(S,x.length,0),0,!0));n(_.scrollIntoView())}return!0}}return!1}function kx(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(Fe.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const fC=kx(-1),pC=kx(1);function hC(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,l=i.blockRange(s),c=l&&ph(l,t,e);return c?(r&&r(n.tr.wrap(l,c).scrollIntoView()),!0):!1}}function ab(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[s];n.doc.nodesBetween(l,c,(u,f)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)i=!0;else{let p=n.doc.resolve(f),h=p.index();i=p.parent.canReplaceWith(h,h+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let l=0;l<n.selection.ranges.length;l++){let{$from:{pos:c},$to:{pos:u}}=n.selection.ranges[l];s.setBlockType(c,u,t,e)}r(s.scrollIntoView())}return!0}}function xh(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}xh(gh,dx,px);xh(gh,mx,gx);xh(yx,bx,vx,cC);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function mC(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,l=i.blockRange(s);if(!l)return!1;let c=r?n.tr:null;return gC(c,l,t,e)?(r&&r(c.scrollIntoView()),!0):!1}}function gC(t,e,n,r=null){let i=!1,s=e,l=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=l.resolve(e.start-2);s=new $c(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new $c(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let c=ph(s,n,r,e);return c?(t&&yC(t,e,c,i,n),!0):!1}function yC(t,e,n,r,i){let s=re.empty;for(let p=n.length-1;p>=0;p--)s=re.from(n[p].type.create(n[p].attrs,s));t.step(new sn(e.start-(r?2:0),e.end,e.start,e.end,new xe(s,0,0),n.length,!0));let l=0;for(let p=0;p<n.length;p++)n[p].type==i&&(l=p+1);let c=n.length-l,u=e.start+n.length-(r?2:0),f=e.parent;for(let p=e.startIndex,h=e.endIndex,y=!0;p<h;p++,y=!1)!y&&ai(t.doc,u,c)&&(t.split(u,c),u+=2*c),u+=f.child(p).nodeSize;return t}function bC(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,l=>l.childCount>0&&l.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?vC(e,n,t,s):xC(e,n,s):!0:!1}}function vC(t,e,n,r){let i=t.tr,s=r.end,l=r.$to.end(r.depth);s<l&&(i.step(new sn(s-1,l,s,l,new xe(re.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new $c(i.doc.resolve(r.$from.pos),i.doc.resolve(l),r.depth));const c=_o(r);if(c==null)return!1;i.lift(r,c);let u=i.doc.resolve(i.mapping.map(s,-1)-1);return Yi(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function xC(t,e,n){let r=t.tr,i=n.parent;for(let b=n.end,x=n.endIndex-1,E=n.startIndex;x>E;x--)b-=i.child(x).nodeSize,r.delete(b-1,b+1);let s=r.doc.resolve(n.start),l=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==i.childCount,f=s.node(-1),p=s.index(-1);if(!f.canReplace(p+(c?0:1),p+1,l.content.append(u?re.empty:re.from(i))))return!1;let h=s.pos,y=h+l.nodeSize;return r.step(new sn(h-(c?1:0),y+(u?1:0),h+1,y-1,new xe((c?re.empty:re.from(i.copy(re.empty))).append(u?re.empty:re.from(i.copy(re.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function kC(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,f=>f.childCount>0&&f.firstChild.type==t);if(!s)return!1;let l=s.startIndex;if(l==0)return!1;let c=s.parent,u=c.child(l-1);if(u.type!=t)return!1;if(n){let f=u.lastChild&&u.lastChild.type==c.type,p=re.from(f?t.create():null),h=new xe(re.from(t.create(null,re.from(c.type.create(null,p)))),f?3:1,0),y=s.start,b=s.end;n(e.tr.step(new sn(y-(f?3:1),b,y,b,h,1,!0)).scrollIntoView())}return!0}}const hn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Eo=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Ap=null;const oi=function(t,e,n){let r=Ap||(Ap=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},wC=function(){Ap=null},Os=function(t,e,n,r){return n&&(cb(t,e,n,r,-1)||cb(t,e,n,r,1))},EC=/^(img|br|input|textarea|hr)$/i;function cb(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:pr(t))){let l=t.parentNode;if(!l||l.nodeType!=1||Vl(t)||EC.test(t.nodeName)||t.contentEditable=="false")return!1;e=hn(t)+(i<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[e+(i<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((s=l.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=l,e=i<0?pr(t):0}else return!1}}function pr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function SC(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=pr(t)}else if(t.parentNode&&!Vl(t))e=hn(t),t=t.parentNode;else return null}}function CC(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&&!Vl(t))e=hn(t)+1,t=t.parentNode;else return null}}function NC(t,e,n){for(let r=e==0,i=e==pr(t);r||i;){if(t==n)return!0;let s=hn(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==pr(t)}}function Vl(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 Fu=function(t){return t.focusNode&&Os(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function vs(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function _C(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function TC(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(pr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(pr(r.startContainer),r.startOffset)}}}const Hr=typeof navigator<"u"?navigator:null,ub=typeof document<"u"?document:null,Qi=Hr&&Hr.userAgent||"",Op=/Edge\/(\d+)/.exec(Qi),wx=/MSIE \d/.exec(Qi),Rp=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qi),Wn=!!(wx||Rp||Op),Hi=wx?document.documentMode:Rp?+Rp[1]:Op?+Op[1]:0,hr=!Wn&&/gecko\/(\d+)/i.test(Qi);hr&&+(/Firefox\/(\d+)/.exec(Qi)||[0,0])[1];const Ip=!Wn&&/Chrome\/(\d+)/.exec(Qi),gn=!!Ip,Ex=Ip?+Ip[1]:0,Nn=!Wn&&!!Hr&&/Apple Computer/.test(Hr.vendor),So=Nn&&(/Mobile\/\w+/.test(Qi)||!!Hr&&Hr.maxTouchPoints>2),fr=So||(Hr?/Mac/.test(Hr.platform):!1),Sx=Hr?/Win/.test(Hr.platform):!1,li=/Android \d/.test(Qi),Kl=!!ub&&"webkitFontSmoothing"in ub.documentElement.style,MC=Kl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function AC(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 ti(t,e){return typeof t=="number"?t:t[e]}function OC(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 db(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let l=n||t.dom;l;){if(l.nodeType!=1){l=Eo(l);continue}let c=l,u=c==s.body,f=u?AC(s):OC(c),p=0,h=0;if(e.top<f.top+ti(r,"top")?h=-(f.top-e.top+ti(i,"top")):e.bottom>f.bottom-ti(r,"bottom")&&(h=e.bottom-e.top>f.bottom-f.top?e.top+ti(i,"top")-f.top:e.bottom-f.bottom+ti(i,"bottom")),e.left<f.left+ti(r,"left")?p=-(f.left-e.left+ti(i,"left")):e.right>f.right-ti(r,"right")&&(p=e.right-f.right+ti(i,"right")),p||h)if(u)s.defaultView.scrollBy(p,h);else{let b=c.scrollLeft,x=c.scrollTop;h&&(c.scrollTop+=h),p&&(c.scrollLeft+=p);let E=c.scrollLeft-b,w=c.scrollTop-x;e={left:e.left-E,top:e.top-w,right:e.right-E,bottom:e.bottom-w}}let y=u?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:Eo(l)}}function RC(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,l=n+1;l<Math.min(innerHeight,e.bottom);l+=5){let c=t.root.elementFromPoint(s,l);if(!c||c==t.dom||!t.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=n-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:Cx(t.dom)}}function Cx(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Eo(r));return e}function IC({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Nx(n,r==0?0:r-e)}function Nx(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let co=null;function LC(t){if(t.setActive)return t.setActive();if(co)return t.focus(co);let e=Cx(t);t.focus(co==null?{get preventScroll(){return co={preventScroll:!0},!0}}:void 0),co||(co=!1,Nx(e,0))}function _x(t,e){let n,r=2e8,i,s=0,l=e.top,c=e.top,u,f;for(let p=t.firstChild,h=0;p;p=p.nextSibling,h++){let y;if(p.nodeType==1)y=p.getClientRects();else if(p.nodeType==3)y=oi(p).getClientRects();else continue;for(let b=0;b<y.length;b++){let x=y[b];if(x.top<=l&&x.bottom>=c){l=Math.max(x.bottom,l),c=Math.min(x.top,c);let E=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(E<r){n=p,r=E,i=E&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,p.nodeType==1&&E&&(s=h+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!u&&x.left<=e.left&&x.right>=e.left&&(u=p,f={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=h+1)}}return!n&&u&&(n=u,i=f,r=0),n&&n.nodeType==3?DC(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:_x(n,i)}function DC(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let l=Ri(r,1);if(l.top!=l.bottom&&kh(e,l)){i={node:t,offset:s+(e.left>=(l.left+l.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function kh(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function PC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function jC(t,e,n){let{node:r,offset:i}=_x(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let l=r.getBoundingClientRect();s=l.left!=l.right&&n.left>(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function BC(t,e,n,r){let i=-1;for(let s=e,l=!1;s!=t.dom;){let c=t.docView.nearestDesc(s,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!l&&u.left>r.left||u.top>r.top?i=c.posBefore:(!l&&u.right<r.left||u.bottom<r.top)&&(i=c.posAfter),l=!0),!c.contentDOM&&i<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;s=c.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Tx(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let l=t.childNodes[s];if(l.nodeType==1){let c=l.getClientRects();for(let u=0;u<c.length;u++){let f=c[u];if(kh(e,f))return Tx(l,e,f)}}if((s=(s+1)%r)==i)break}return t}function zC(t,e){let n=t.dom.ownerDocument,r,i=0,s=TC(n,e.left,e.top);s&&({node:r,offset:i}=s);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(!kh(e,f)||(l=Tx(t.dom,e,f),!l))return null}if(Nn)for(let f=l;r&&f;f=Eo(f))f.draggable&&(r=void 0);if(l=PC(l,e),r){if(hr&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let p=r.childNodes[i],h;p.nodeName=="IMG"&&(h=p.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let f;Kl&&i&&r.nodeType==1&&(f=r.childNodes[i-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=BC(t,r,i,e))}c==null&&(c=jC(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function fb(t){return t.top<t.bottom||t.left<t.right}function Ri(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(fb(r))return r}return Array.prototype.find.call(n,fb)||t.getBoundingClientRect()}const FC=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Mx(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),l=Kl||hr;if(r.nodeType==3)if(l&&(FC.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let u=Ri(oi(r,i,i),n);if(hr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let f=Ri(oi(r,i-1,i-1),-1);if(f.top==u.top){let p=Ri(oi(r,i,i+1),-1);if(p.top!=u.top)return dl(p,p.left<f.left)}}return u}else{let u=i,f=i,p=n<0?1:-1;return n<0&&!i?(f++,p=-1):n>=0&&i==r.nodeValue.length?(u--,p=1):n<0?u--:f++,dl(Ri(oi(r,u,f),p),p<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==pr(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return Yf(u.getBoundingClientRect(),!1)}if(s==null&&i<pr(r)){let u=r.childNodes[i];if(u.nodeType==1)return Yf(u.getBoundingClientRect(),!0)}return Yf(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==pr(r))){let u=r.childNodes[i-1],f=u.nodeType==3?oi(u,pr(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(f)return dl(Ri(f,1),!1)}if(s==null&&i<pr(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let f=u?u.nodeType==3?oi(u,0,l?0:1):u.nodeType==1?u:null:null;if(f)return dl(Ri(f,-1),!0)}return dl(Ri(r.nodeType==3?oi(r):r,-n),n>=0)}function dl(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 Yf(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 Ax(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function $C(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Ax(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(s,!0);if(!c)break;if(c.node.isBlock){s=c.contentDOM||c.dom;break}s=c.dom.parentNode}let l=Mx(t,i.pos,1);for(let c=s.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=oi(c,0,c.nodeValue.length).getClientRects();else continue;for(let f=0;f<u.length;f++){let p=u[f];if(p.bottom>p.top+1&&(n=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const UC=/[\u0590-\u08ac]/;function HC(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,l=i==r.parent.content.size,c=t.domSelection();return c?!UC.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?s:l:Ax(t,e,()=>{let{focusNode:u,focusOffset:f,anchorNode:p,anchorOffset:h}=t.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:E}=t.domSelectionRange(),w=x&&!b.contains(x.nodeType==1?x:x.parentNode)||u==x&&f==E;try{c.collapse(p,h),u&&(u!=p||f!=h)&&c.extend&&c.extend(u,f)}catch{}return y!=null&&(c.caretBidiLevel=y),w}):r.pos==r.start()||r.pos==r.end()}let pb=null,hb=null,mb=!1;function WC(t,e,n){return pb==e&&hb==n?mb:(pb=e,hb=n,mb=n=="up"||n=="down"?$C(t,e,n):HC(t,e,n))}const mr=0,gb=1,xs=2,Wr=3;class Gl{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=mr,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 i=this.children[n];if(i==e)return r;r+=i.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 s,l;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((l=s.pmViewDesc)&&l.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(l)+l.size:this.posAtStart}else{let s,l;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((l=s.pmViewDesc)&&l.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(l):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>hn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),l;if(s&&(!n||s.node))if(r&&(l=s.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return s}}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 i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let l=0;l<i.children.length;l++){let c=i.children[l];if(c.size){i=c;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let l=this.children[r],c=s+l.size;if(c>e||l instanceof Rx){i=e-s;break}s=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ox&&s.side>=0;r--);if(n<=0){let s,l=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,l=!1);return s&&n&&l&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?hn(s.dom)+1:0}}else{let s,l=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,l=!1);return s&&l&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?hn(s.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 i=-1,s=-1;for(let l=r,c=0;;c++){let u=this.children[c],f=l+u.size;if(i==-1&&e<=f){let p=l+u.border;if(e>=p&&n<=f-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,p);e=l;for(let h=c;h>0;h--){let y=this.children[h-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=hn(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(f>n||c==this.children.length-1)){n=f;for(let p=c+1;p<this.children.length;p++){let h=this.children[p];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=hn(h.dom);break}n+=h.size}s==-1&&(s=this.contentDOM.childNodes.length);break}l=f}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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,i=!1){let s=Math.min(e,n),l=Math.max(e,n);for(let b=0,x=0;b<this.children.length;b++){let E=this.children[b],w=x+E.size;if(s>x&&l<w)return E.setSelection(e-x-E.border,n-x-E.border,r,i);x=w}let c=this.domFromPos(e,e?-1:1),u=n==e?c:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),p=r.domSelectionRange(),h=!1;if((hr||Nn)&&e==n){let{node:b,offset:x}=c;if(b.nodeType==3){if(h=!!(x&&b.nodeValue[x-1]==`
|
|
54
|
+
`),h&&x==b.nodeValue.length)for(let E=b,w;E;E=E.parentNode){if(w=E.nextSibling){w.nodeName=="BR"&&(c=u={node:w.parentNode,offset:hn(w)+1});break}let S=E.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{let E=b.childNodes[x-1];h=E&&(E.nodeName=="BR"||E.contentEditable=="false")}}if(hr&&p.focusNode&&p.focusNode!=u.node&&p.focusNode.nodeType==1){let b=p.focusNode.childNodes[p.focusOffset];b&&b.contentEditable=="false"&&(i=!0)}if(!(i||h&&Nn)&&Os(c.node,c.offset,p.anchorNode,p.anchorOffset)&&Os(u.node,u.offset,p.focusNode,p.focusOffset))return;let y=!1;if((f.extend||e==n)&&!(h&&hr)){f.collapse(c.node,c.offset);try{e!=n&&f.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>n){let x=c;c=u,u=x}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(b)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],l=r+s.size;if(r==l?e<=l&&n>=r:e<l&&n>r){let c=r+s.border,u=l-s.border;if(e>=c&&n<=u){this.dirty=e==r||n==l?xs:gb,e==c&&n==u&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Wr:s.markDirty(e-c,n-c);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?xs:Wr}r=l}this.dirty=xs}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xs:gb;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ox extends Gl{constructor(e,n,r,i){let s,l=n.type.toDOM;if(typeof l=="function"&&(l=l(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!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,s=this}matchesWidget(e){return this.dirty==mr&&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 VC extends Gl{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 Rs extends Gl{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],l=s&&s(n,i,r);return(!l||!l.dom)&&(l=Ps.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Rs(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!=mr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=mr}}slice(e,n,r){let i=Rs.create(this.parent,this.mark,!0,r),s=this.children,l=this.size;n<l&&(s=Dp(s,n,l,r)),e>0&&(s=Dp(s,0,e,r));for(let c=0;c<s.length;c++)s[c].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Wi extends Gl{constructor(e,n,r,i,s,l,c,u,f){super(e,[],s,l),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=c}static create(e,n,r,i,s,l){let c=s.nodeViews[n.type.name],u,f=c&&c(n,s,()=>{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,i),p=f&&f.dom,h=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:h}=Ps.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),n.type.spec.draggable&&(p.draggable=!0));let y=p;return p=Dx(p,r,n),f?u=new KC(e,n,r,i,p,h||null,y,f,s,l+1):n.isText?new $u(e,n,r,i,p,y,s):new Wi(e,n,r,i,p,h||null,y,s,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=()=>re.empty)}return e}matchesNode(e,n,r){return this.dirty==mr&&e.eq(this.node)&&Hc(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,i=n,s=e.composing?this.localCompositionInfo(e,n):null,l=s&&s.pos>-1?s:null,c=s&&s.pos<0,u=new qC(this,l&&l.node,e);QC(this.node,this.innerDeco,(f,p,h)=>{f.spec.marks?u.syncToMarks(f.spec.marks,r,e,p):f.type.side>=0&&!h&&u.syncToMarks(p==this.node.childCount?ht.none:this.node.child(p).marks,r,e,p),u.placeWidget(f,e,i)},(f,p,h,y)=>{u.syncToMarks(f.marks,r,e,y);let b;u.findNodeMatch(f,p,h,y)||c&&e.state.selection.from>i&&e.state.selection.to<i+f.nodeSize&&(b=u.findIndexWithChild(s.node))>-1&&u.updateNodeAt(f,p,h,b,e)||u.updateNextNode(f,p,h,e,y,i)||u.addNode(f,p,h,e,i),i+=f.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==xs)&&(l&&this.protectLocalComposition(e,l),Ix(this.contentDOM,this.children,e),So&&XC(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Fe)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,c=ZC(this.node.content,l,r-n,i-n);return c<0?null:{node:s,pos:c,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let l=new VC(this,s,n,i);e.input.compositionNodes.push(l),this.children=Dp(this.children,r,r+i.length,e,l)}update(e,n,r,i){return this.dirty==Wr||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=mr}updateOuterDeco(e){if(Hc(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Lx(this.dom,this.nodeDOM,Lp(this.outerDeco,this.node,n),Lp(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 yb(t,e,n,r,i){Dx(r,e,t);let s=new Wi(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class $u extends Wi{constructor(e,n,r,i,s,l,c){super(e,n,r,i,s,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,i){return this.dirty==Wr||this.dirty!=mr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=mr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=mr,!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 i=this.node.cut(e,n),s=document.createTextNode(i.text);return new $u(this.parent,i,this.outerDeco,this.innerDeco,s,s,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 Rx extends Gl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==mr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class KC extends Wi{constructor(e,n,r,i,s,l,c,u,f,p){super(e,n,r,i,s,l,c,f,p),this.spec=u}update(e,n,r,i){if(this.dirty==Wr)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}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 Ix(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let l=e[s],c=l.dom;if(c.parentNode==t){for(;c!=r;)r=bb(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(c,r);if(l instanceof Rs){let u=r?r.previousSibling:t.lastChild;Ix(l.contentDOM,l.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=bb(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const Sl=function(t){t&&(this.nodeName=t)};Sl.prototype=Object.create(null);const ks=[new Sl];function Lp(t,e,n){if(t.length==0)return ks;let r=n?ks[0]:new Sl,i=[r];for(let s=0;s<t.length;s++){let l=t[s].type.attrs;if(l){l.nodeName&&i.push(r=new Sl(l.nodeName));for(let c in l){let u=l[c];u!=null&&(n&&i.length==1&&i.push(r=new Sl(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return i}function Lx(t,e,n,r){if(n==ks&&r==ks)return e;let i=e;for(let s=0;s<r.length;s++){let l=r[s],c=n[s];if(s){let u;c&&c.nodeName==l.nodeName&&i!=t&&(u=i.parentNode)&&u.nodeName.toLowerCase()==l.nodeName||(u=document.createElement(l.nodeName),u.pmIsDeco=!0,u.appendChild(i),c=ks[0]),i=u}GC(i,c||ks[0],l)}return i}function GC(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):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Dx(t,e,n){return Lx(t,t,ks,Lp(e,n,t.nodeType!=1))}function Hc(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 bb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class qC{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=JC(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,i){let s=0,l=this.stack.length>>1,c=Math.min(l,e.length);for(;s<c&&(s==l-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<l;)this.destroyRest(),this.top.dirty=mr,this.index=this.stack.pop(),this.top=this.stack.pop(),l--;for(;l<e.length;){this.stack.push(this.top,this.index+1);let u=-1,f=this.top.children.length;i<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let p=this.index;p<f;p++){let h=this.top.children[p];if(h.matchesMark(e[l])&&!this.isLocked(h.dom)){u=p;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let p=Rs.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,i){let s=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,r))s=this.top.children.indexOf(l,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let f=this.top.children[c];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){s=c;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let l=this.top.children[i];return l.dirty==Wr&&l.dom==l.contentDOM&&(l.dirty=xs),l.update(e,n,r,s)?(this.destroyBetween(this.index,i),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 i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,l){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof Wi){let f=this.preMatch.matched.get(u);if(f!=null&&f!=s)return!1;let p=u.dom,h,y=this.isLocked(p)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Wr&&Hc(n,u.outerDeco));if(!y&&u.update(e,n,r,i))return this.destroyBetween(this.index,c),u.dom!=p&&(this.changed=!0),this.index++,!0;if(!y&&(h=this.recreateWrapper(u,e,n,r,i,l)))return this.destroyBetween(this.index,c),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=xs,h.updateChildren(i,l+1),h.dirty=mr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,l){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Hc(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let c=Wi.create(this.top,n,r,i,s,l);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,n,r,i,s){let l=Wi.create(this.top,e,n,r,i,s);l.contentDOM&&l.updateChildren(i,s+1),this.top.children.splice(this.index++,0,l),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Ox(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Rs;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof $u)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Nn||gn)&&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 i=new Rx(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function JC(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,l=[];e:for(;i>0;){let c;for(;;)if(r){let f=n.children[r-1];if(f instanceof Rs)n=f,r=f.children.length;else{c=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(i-1))break;--i,s.set(c,i),l.push(c)}}return{index:i,matched:s,matches:l.reverse()}}function YC(t,e){return t.type.side-e.type.side}function QC(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let f=0;f<t.childCount;f++){let p=t.child(f);r(p,i,e.forChild(s,p),f),s+=p.nodeSize}return}let l=0,c=[],u=null;for(let f=0;;){let p,h;for(;l<i.length&&i[l].to==s;){let w=i[l++];w.widget&&(p?(h||(h=[p])).push(w):p=w)}if(p)if(h){h.sort(YC);for(let w=0;w<h.length;w++)n(h[w],f,!!u)}else n(p,f,!!u);let y,b;if(u)b=-1,y=u,u=null;else if(f<t.childCount)b=f,y=t.child(f++);else break;for(let w=0;w<c.length;w++)c[w].to<=s&&c.splice(w--,1);for(;l<i.length&&i[l].from<=s&&i[l].to>s;)c.push(i[l++]);let x=s+y.nodeSize;if(y.isText){let w=x;l<i.length&&i[l].from<w&&(w=i[l].from);for(let S=0;S<c.length;S++)c[S].to<w&&(w=c[S].to);w<x&&(u=y.cut(w-s),y=y.cut(0,w-s),x=w,b=-1)}else for(;l<i.length&&i[l].to<x;)l++;let E=y.isInline&&!y.isLeaf?c.filter(w=>!w.inline):c.slice();r(y,E,e.forChild(s,y),b),s=x}}function XC(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 ZC(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let l=t.child(i++),c=s;if(s+=l.nodeSize,!l.isText)continue;let u=l.text;for(;i<t.childCount;){let f=t.child(i++);if(s+=f.nodeSize,!f.isText)break;u+=f.text}if(s>=n){if(s>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let f=c<r?u.lastIndexOf(e,r-c-1):-1;if(f>=0&&f+e.length+c>=n)return c+f;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Dp(t,e,n,r,i){let s=[];for(let l=0,c=0;l<t.length;l++){let u=t[l],f=c,p=c+=u.size;f>=n||p<=e?s.push(u):(f<e&&s.push(u.slice(0,e-f,r)),i&&(s.push(i),i=void 0),p>n&&s.push(u.slice(n-f,u.size,r)))}return s}function wh(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let c=r.resolve(l),u,f;if(Fu(n)){for(u=l;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&Be.isSelectable(h)&&i.parent&&!(h.isInline&&NC(n.focusNode,n.focusOffset,i.dom))){let y=i.posBefore;f=new Be(l==y?c:r.resolve(y))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=l,y=l;for(let b=0;b<n.rangeCount;b++){let x=n.getRangeAt(b);h=Math.min(h,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),y=Math.max(y,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(h<0)return null;[u,l]=y==t.state.selection.anchor?[y,h]:[h,y],c=r.resolve(l)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let p=r.resolve(u);if(!f){let h=e=="pointer"||t.state.selection.head<c.pos&&!s?1:-1;f=Eh(t,p,c,h)}return f}function Px(t){return t.editable?t.hasFocus():Bx(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ci(t,e=!1){let n=t.state.selection;if(jx(t,n),!!Px(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&gn){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Os(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)tN(t);else{let{anchor:r,head:i}=n,s,l;vb&&!(n instanceof Fe)&&(n.$from.parent.inlineContent||(s=xb(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=xb(t,n.to))),t.docView.setSelection(r,i,t,e),vb&&(s&&kb(s),l&&kb(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&eN(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const vb=Nn||gn&&Ex<63;function xb(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Nn&&i&&i.contentEditable=="false")return Qf(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Qf(i);if(s)return Qf(s)}}function Qf(t){return t.contentEditable="true",Nn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function kb(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function eN(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Px(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function tN(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,hn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Wn&&Hi<=11&&(n.disabled=!0,n.disabled=!1)}function jx(t,e){if(e instanceof Be){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(wb(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else wb(t)}function wb(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Eh(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Fe.between(e,n,r)}function Eb(t){return t.editable&&!t.hasFocus()?!1:Bx(t)}function Bx(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 nN(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Os(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Pp(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Ve.findFrom(s,e)}function Ii(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Sb(t,e,n){let r=t.state.selection;if(r instanceof Fe)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let l=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ii(t,new Fe(r.$anchor,l))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Pp(t.state,e);return i&&i instanceof Be?Ii(t,i):!1}else if(!(fr&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!s||s.isText)return!1;let c=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(l=t.docView.descAt(c))&&!l.contentDOM?Be.isSelectable(s)?Ii(t,new Be(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Kl?Ii(t,new Fe(t.state.doc.resolve(e<0?c:c+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Be&&r.node.isInline)return Ii(t,new Fe(e>0?r.$to:r.$from));{let i=Pp(t.state,e);return i?Ii(t,i):!1}}}function Wc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Cl(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function uo(t,e){return e<0?rN(t):iN(t)}function rN(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,l=!1;for(hr&&n.nodeType==1&&r<Wc(n)&&Cl(n.childNodes[r],-1)&&(l=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(Cl(c,-1))i=n,s=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(zx(n))break;{let c=n.previousSibling;for(;c&&Cl(c,-1);)i=n.parentNode,s=hn(c),c=c.previousSibling;if(c)n=c,r=Wc(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?jp(t,n,r):i&&jp(t,i,s)}function iN(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Wc(n),s,l;for(;;)if(r<i){if(n.nodeType!=1)break;let c=n.childNodes[r];if(Cl(c,1))s=n,l=++r;else break}else{if(zx(n))break;{let c=n.nextSibling;for(;c&&Cl(c,1);)s=c.parentNode,l=hn(c)+1,c=c.nextSibling;if(c)n=c,r=0,i=Wc(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&jp(t,s,l)}function zx(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function sN(t,e){for(;t&&e==t.childNodes.length&&!Vl(t);)e=hn(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 oN(t,e){for(;t&&!e&&!Vl(t);)e=hn(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 jp(t,e,n){if(e.nodeType!=3){let s,l;(l=sN(e,n))?(e=l,n=0):(s=oN(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Fu(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&ci(t)},50)}function Cb(t,e){let n=t.state.doc.resolve(e);if(!(gn||Sx)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Nb(t,e,n){let r=t.state.selection;if(r instanceof Fe&&!r.empty||n.indexOf("s")>-1||fr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=Pp(t.state,e);if(l&&l instanceof Be)return Ii(t,l)}if(!i.parent.inlineContent){let l=e<0?i:s,c=r instanceof er?Ve.near(l,e):Ve.findFrom(l,e);return c?Ii(t,c):!1}return!1}function _b(t,e){if(!(t.state.selection instanceof Fe))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let l=t.state.tr;return e<0?l.delete(n.pos-s.nodeSize,n.pos):l.delete(n.pos,n.pos+s.nodeSize),t.dispatch(l),!0}return!1}function Tb(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function lN(t){if(!Nn||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;Tb(t,r,"true"),setTimeout(()=>Tb(t,r,"false"),20)}return!1}function aN(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function cN(t,e){let n=e.keyCode,r=aN(e);if(n==8||fr&&n==72&&r=="c")return _b(t,-1)||uo(t,-1);if(n==46&&!e.shiftKey||fr&&n==68&&r=="c")return _b(t,1)||uo(t,1);if(n==13||n==27)return!0;if(n==37||fr&&n==66&&r=="c"){let i=n==37?Cb(t,t.state.selection.from)=="ltr"?-1:1:-1;return Sb(t,i,r)||uo(t,i)}else if(n==39||fr&&n==70&&r=="c"){let i=n==39?Cb(t,t.state.selection.from)=="ltr"?1:-1:1;return Sb(t,i,r)||uo(t,i)}else{if(n==38||fr&&n==80&&r=="c")return Nb(t,-1,r)||uo(t,-1);if(n==40||fr&&n==78&&r=="c")return lN(t)||Nb(t,1,r)||uo(t,1);if(r==(fr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Sh(t,e){t.someProp("transformCopied",b=>{e=b(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;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")||Ps.fromSchema(t.state.schema),c=Vx(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));let f=u.firstChild,p,h=0;for(;f&&f.nodeType==1&&(p=Wx[f.nodeName.toLowerCase()]);){for(let b=p.length-1;b>=0;b--){let x=c.createElement(p[b]);for(;u.firstChild;)x.appendChild(u.firstChild);u.appendChild(x),h++}f=u.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let y=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
|
|
55
|
+
|
|
56
|
+
`);return{dom:u,text:y,slice:e}}function Fx(t,e,n,r,i){let s=i.parent.type.spec.code,l,c;if(!n&&!e)return null;let u=!!e&&(r||s||!n);if(u){if(t.someProp("transformPastedText",y=>{e=y(e,s||r,t)}),s)return c=new xe(re.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
57
|
+
`))),0,0),t.someProp("transformPasted",y=>{c=y(c,t,!0)}),c;let h=t.someProp("clipboardTextParser",y=>y(e,i,r,t));if(h)c=h;else{let y=i.marks(),{schema:b}=t.state,x=Ps.fromSchema(b);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(E=>{let w=l.appendChild(document.createElement("p"));E&&w.appendChild(x.serializeNode(b.text(E,y)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),l=pN(n),Kl&&hN(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 h=+p[3];h>0;h--){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")||Ui.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||p),context:i,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!uN.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)c=mN(Mb(c,+p[1],+p[2]),p[4]);else if(c=xe.maxOpen(dN(c.content,i),!0),c.openStart||c.openEnd){let h=0,y=0;for(let b=c.content.firstChild;h<c.openStart&&!b.type.spec.isolating;h++,b=b.firstChild);for(let b=c.content.lastChild;y<c.openEnd&&!b.type.spec.isolating;y++,b=b.lastChild);c=Mb(c,h,y)}return t.someProp("transformPasted",h=>{c=h(c,t,u)}),c}const uN=/^(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 dN(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,l=[];if(t.forEach(c=>{if(!l)return;let u=i.findWrapping(c.type),f;if(!u)return l=null;if(f=l.length&&s.length&&Ux(u,s,c,l[l.length-1],0))l[l.length-1]=f;else{l.length&&(l[l.length-1]=Hx(l[l.length-1],s.length));let p=$x(c,u);l.push(p),i=i.matchType(p.type),s=u}}),l)return re.from(l)}return t}function $x(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,re.from(t));return t}function Ux(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Ux(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(re.from($x(n,t,i+1))))}}function Hx(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Hx(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(re.empty,!0);return t.copy(n.append(r))}function Bp(t,e,n,r,i,s){let l=e<0?t.firstChild:t.lastChild,c=l.content;return t.childCount>1&&(s=0),i<r-1&&(c=Bp(c,e,n,r,i+1,s)),i>=n&&(c=e<0?l.contentMatchAt(0).fillBefore(c,s<=i).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(re.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(c))}function Mb(t,e,n){return e<t.openStart&&(t=new xe(Bp(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new xe(Bp(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Wx={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 Ab=null;function Vx(){return Ab||(Ab=document.implementation.createHTMLDocument("title"))}let Xf=null;function fN(t){let e=window.trustedTypes;return e?(Xf||(Xf=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Xf.createHTML(t)):t}function pN(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Vx().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Wx[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=fN(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function hN(t){let e=t.querySelectorAll(gn?"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 mN(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:i,openStart:s,openEnd:l}=t;for(let c=r.length-2;c>=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=re.from(u.create(r[c+1],i)),s++,l++}return new xe(i,s,l)}const Ln={},Dn={},gN={touchstart:!0,touchmove:!0};class yN{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 bN(t){for(let e in Ln){let n=Ln[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{xN(t,r)&&!Ch(t,r)&&(t.editable||!(r.type in Dn))&&n(t,r)},gN[e]?{passive:!0}:void 0)}Nn&&t.dom.addEventListener("input",()=>null),zp(t)}function $i(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function vN(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 zp(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Ch(t,r))})}function Ch(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function xN(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 kN(t,e){!Ch(t,e)&&Ln[e.type]&&(t.editable||!(e.type in Dn))&&Ln[e.type](t,e)}Dn.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Gx(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(li&&gn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),So&&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",i=>i(t,vs(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||cN(t,n)?n.preventDefault():$i(t,"key")};Dn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Dn.keypress=(t,e)=>{let n=e;if(Gx(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||fr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Fe)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",l=>l(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function Uu(t){return{left:t.clientX,top:t.clientY}}function wN(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Nh(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let l=s.depth+1;l>0;l--)if(t.someProp(e,c=>l>s.depth?c(t,n,s.nodeAfter,s.before(l),i,!0):c(t,n,s.node(l),s.before(l),i,!1)))return!0;return!1}function vo(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 EN(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Be.isSelectable(r)?(vo(t,new Be(n)),!0):!1}function SN(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Be&&(r=n.node);let s=t.state.doc.resolve(e);for(let l=s.depth+1;l>0;l--){let c=l>s.depth?s.nodeAfter:s.node(l);if(Be.isSelectable(c)){r&&n.$from.depth>0&&l>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(l);break}}return i!=null?(vo(t,Be.create(t.state.doc,i)),!0):!1}function CN(t,e,n,r,i){return Nh(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?SN(t,n):EN(t,n))}function NN(t,e,n,r){return Nh(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function _N(t,e,n,r){return Nh(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||TN(t,n,r)}function TN(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(vo(t,Fe.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(l.inlineContent)vo(t,Fe.create(r,c+1,c+1+l.content.size));else if(Be.isSelectable(l))vo(t,Be.create(r,c));else continue;return!0}}function _h(t){return Vc(t)}const Kx=fr?"metaKey":"ctrlKey";Ln.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=_h(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&wN(n,t.input.lastClick)&&!n[Kx]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button};let l=t.posAtCoords(Uu(n));l&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new MN(t,l,n,!!r)):(s=="doubleClick"?NN:_N)(t,l.pos,l.inside,n)?n.preventDefault():$i(t,"pointer"))};class MN{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Kx],this.allowDefault=r.shiftKey;let s,l;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),l=n.inside;else{let p=e.state.doc.resolve(n.pos);s=p.parent,l=p.depth?p.before():0}const c=i?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||f instanceof Be&&f.from<=l&&f.to>l)&&(this.mightDrag={node:s,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&hr&&!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)),$i(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(()=>ci(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(Uu(e))),this.updateAllowDefault(e),this.allowDefault||!n?$i(this.view,"pointer"):CN(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Nn&&this.mightDrag&&!this.mightDrag.node.isAtom||gn&&!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)?(vo(this.view,Ve.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):$i(this.view,"pointer")}move(e){this.updateAllowDefault(e),$i(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)}}Ln.touchstart=t=>{t.input.lastTouch=Date.now(),_h(t),$i(t,"pointer")};Ln.touchmove=t=>{t.input.lastTouch=Date.now(),$i(t,"pointer")};Ln.contextmenu=t=>_h(t);function Gx(t,e){return t.composing?!0:Nn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const AN=li?5e3:-1;Dn.compositionstart=Dn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Fe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||gn&&Sx&&ON(t)))t.markCursor=t.state.storedMarks||n.marks(),Vc(t,!0),t.markCursor=null;else if(Vc(t,!e.selection.empty),hr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let l=s<0?i.lastChild:i.childNodes[s-1];if(!l)break;if(l.nodeType==3){let c=t.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else i=l,s=-1}}t.input.composing=!0}qx(t,AN)};function ON(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"}Dn.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++,qx(t,20))};function qx(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Vc(t),e))}function Jx(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=IN());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function RN(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=SC(e.focusNode,e.focusOffset),r=CC(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.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 IN(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Vc(t,e=!1){if(!(li&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Jx(t),e||t.docView&&t.docView.dirty){let n=wh(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 LN(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(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Pl=Wn&&Hi<15||So&&MC<604;Ln.copy=Dn.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=Pl?null:n.clipboardData,l=r.content(),{dom:c,text:u}=Sh(t,l);s?(n.preventDefault(),s.clearData(),s.setData("text/html",c.innerHTML),s.setData("text/plain",u)):LN(t,c),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function DN(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function PN(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 i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?jl(t,r.value,null,i,e):jl(t,r.textContent,r.innerHTML,i,e)},50)}function jl(t,e,n,r,i){let s=Fx(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,s||xe.empty)))return!0;if(!s)return!1;let l=DN(s),c=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(s);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Yx(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," "):""}Dn.paste=(t,e)=>{let n=e;if(t.composing&&!li)return;let r=Pl?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&jl(t,Yx(r),r.getData("text/html"),i,n)?n.preventDefault():PN(t,n)};class Qx{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const jN=fr?"altKey":"ctrlKey";function Xx(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[jN]}Ln.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(Uu(n)),l;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Be?i.to-1:i.to))){if(r&&r.mightDrag)l=Be.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(l=Be.create(t.state.doc,h.posBefore))}}let c=(l||t.state.selection).content(),{dom:u,text:f,slice:p}=Sh(t,c);(!n.dataTransfer.files.length||!gn||Ex>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Pl?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Pl||n.dataTransfer.setData("text/plain",f),t.dragging=new Qx(p,Xx(t,n),l)};Ln.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Dn.dragover=Dn.dragenter=(t,e)=>e.preventDefault();Dn.drop=(t,e)=>{try{BN(t,e,t.dragging)}finally{t.dragging=null}};function BN(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Uu(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",b=>{s=b(s,t,!1)}):s=Fx(t,Yx(e.dataTransfer),Pl?null:e.dataTransfer.getData("text/html"),!1,i);let l=!!(n&&Xx(t,e));if(t.someProp("handleDrop",b=>b(t,e,s||xe.empty,l))){e.preventDefault();return}if(!s)return;e.preventDefault();let c=s?nx(t.state.doc,i.pos,s):i.pos;c==null&&(c=i.pos);let u=t.state.tr;if(l){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let f=u.mapping.map(c),p=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,h=u.doc;if(p?u.replaceRangeWith(f,f,s.content.firstChild):u.replaceRange(f,f,s),u.doc.eq(h))return;let y=u.doc.resolve(f);if(p&&Be.isSelectable(s.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new Be(y));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((x,E,w,S)=>b=S),u.setSelection(Eh(t,y,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Ln.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())&&ci(t)},20))};Ln.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)};Ln.beforeinput=(t,e)=>{if(gn&&li&&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",s=>s(t,vs(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Dn)Ln[t]=Dn[t];function Bl(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 Kc{constructor(e,n){this.toDOM=e,this.spec=n||Ns,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new vt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Kc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Bl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Vi{constructor(e,n){this.attrs=e,this.spec=n||Ns}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=l?null:new vt(s,l,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Vi&&Bl(this.attrs,e.attrs)&&Bl(this.spec,e.spec)}static is(e){return e.type instanceof Vi}destroy(){}}class Th{constructor(e,n){this.attrs=e,this.spec=n||Ns}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let l=e.mapResult(n.to+i,-1);return l.deleted||l.pos<=s.pos?null:new vt(s.pos-r,l.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Th&&Bl(this.attrs,e.attrs)&&Bl(this.spec,e.spec)}destroy(){}}class vt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new vt(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 vt(e,e,new Kc(n,r))}static inline(e,n,r,i){return new vt(e,n,new Vi(r,i))}static node(e,n,r,i){return new vt(e,n,new Th(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Vi}get widget(){return this.type instanceof Kc}}const po=[],Ns={};class lt{constructor(e,n){this.local=e.length?e:po,this.children=n.length?n:po}static create(e,n){return n.length?Gc(n,e,0,Ns):Cn}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let l=0;l<this.local.length;l++){let c=this.local[l];c.from<=n&&c.to>=e&&(!s||s(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}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,i+c,s)}}map(e,n,r){return this==Cn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ns)}mapInner(e,n,r,i,s){let l;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,i);u&&u.type.valid(n,u)?(l||(l=[])).push(u):s.onRemove&&s.onRemove(this.local[c].spec)}return this.children.length?zN(this.children,l||[],e,n,r,i,s):l?new lt(l.sort(_s),po):Cn}add(e,n){return n.length?this==Cn?lt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((c,u)=>{let f=u+r,p;if(p=ek(n,c,f)){for(i||(i=this.children.slice());s<i.length&&i[s]<u;)s+=3;i[s]==u?i[s+2]=i[s+2].addInner(c,p,f+1):i.splice(s,0,u,u+c.nodeSize,Gc(p,c,f+1,Ns)),s+=3}});let l=Zx(s?tk(n):n,-r);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||l.splice(c--,1);return new lt(l.length?this.local.concat(l).sort(_s):this.local,i||this.children)}remove(e){return e.length==0||this==Cn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let l,c=r[s]+n,u=r[s+1]+n;for(let p=0,h;p<e.length;p++)(h=e[p])&&h.from>c&&h.to<u&&(e[p]=null,(l||(l=[])).push(h));if(!l)continue;r==this.children&&(r=this.children.slice());let f=r[s+2].removeInner(l,c+1);f!=Cn?r[s+2]=f:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,l;s<e.length;s++)if(l=e[s])for(let c=0;c<i.length;c++)i[c].eq(l,n)&&(i==this.local&&(i=this.local.slice()),i.splice(c--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new lt(i,r):Cn}forChild(e,n){if(this==Cn)return this;if(n.isLeaf)return lt.empty;let r,i;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 s=e+1,l=s+n.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<l&&u.to>s&&u.type instanceof Vi){let f=Math.max(s,u.from)-s,p=Math.min(l,u.to)-s;f<p&&(i||(i=[])).push(u.copy(f,p))}}if(i){let c=new lt(i.sort(_s),po);return r?new Pi([c,r]):c}return r||Cn}eq(e){if(this==e)return!0;if(!(e instanceof lt)||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 Mh(this.localsInner(e))}localsInner(e){if(this==Cn)return po;if(e.inlineContent||!this.local.some(Vi.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Vi||n.push(this.local[r]);return n}forEachSet(e){e(this)}}lt.empty=new lt([],[]);lt.removeOverlap=Mh;const Cn=lt.empty;class Pi{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Ns));return Pi.from(r)}forChild(e,n){if(n.isLeaf)return lt.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Cn&&(s instanceof Pi?r=r.concat(s.members):r.push(s))}return Pi.from(r)}eq(e){if(!(e instanceof Pi)||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 i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let l=0;l<s.length;l++)n.push(s[l])}}return n?Mh(r?n:n.sort(_s)):po}static from(e){switch(e.length){case 0:return Cn;case 1:return e[0];default:return new Pi(e.every(n=>n instanceof lt)?e:e.reduce((n,r)=>n.concat(r instanceof lt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function zN(t,e,n,r,i,s,l){let c=t.slice();for(let f=0,p=s;f<n.maps.length;f++){let h=0;n.maps[f].forEach((y,b,x,E)=>{let w=E-x-(b-y);for(let S=0;S<c.length;S+=3){let _=c[S+1];if(_<0||y>_+p-h)continue;let M=c[S]+p-h;b>=M?c[S+1]=y<=M?-2:-1:y>=p&&w&&(c[S]+=w,c[S+1]+=w)}h+=w}),p=n.maps[f].map(p,-1)}let u=!1;for(let f=0;f<c.length;f+=3)if(c[f+1]<0){if(c[f+1]==-2){u=!0,c[f+1]=-1;continue}let p=n.map(t[f]+s),h=p-i;if(h<0||h>=r.content.size){u=!0;continue}let y=n.map(t[f+1]+s,-1),b=y-i,{index:x,offset:E}=r.content.findIndex(h),w=r.maybeChild(x);if(w&&E==h&&E+w.nodeSize==b){let S=c[f+2].mapInner(n,w,p+1,t[f]+s+1,l);S!=Cn?(c[f]=h,c[f+1]=b,c[f+2]=S):(c[f+1]=-2,u=!0)}else u=!0}if(u){let f=FN(c,t,e,n,i,s,l),p=Gc(f,r,0,l);e=p.local;for(let h=0;h<c.length;h+=3)c[h+1]<0&&(c.splice(h,3),h-=3);for(let h=0,y=0;h<p.children.length;h+=3){let b=p.children[h];for(;y<c.length&&c[y]<b;)y+=3;c.splice(y,0,p.children[h],p.children[h+1],p.children[h+2])}}return new lt(e.sort(_s),c)}function Zx(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new vt(i.from+e,i.to+e,i.type))}return n}function FN(t,e,n,r,i,s,l){function c(u,f){for(let p=0;p<u.local.length;p++){let h=u.local[p].map(r,i,f);h?n.push(h):l.onRemove&&l.onRemove(u.local[p].spec)}for(let p=0;p<u.children.length;p+=3)c(u.children[p+2],u.children[p]+f+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&c(t[u+2],e[u]+s+1);return n}function ek(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,l;s<t.length;s++)(l=t[s])&&l.from>n&&l.to<r&&((i||(i=[])).push(l),t[s]=null);return i}function tk(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Gc(t,e,n,r){let i=[],s=!1;e.forEach((c,u)=>{let f=ek(t,c,u+n);if(f){s=!0;let p=Gc(f,c,n+u+1,r);p!=Cn&&i.push(u,u+c.nodeSize,p)}});let l=Zx(s?tk(t):t,-n).sort(_s);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||i.length?new lt(l,i):Cn}function _s(t,e){return t.from-e.from||t.to-e.to}function Mh(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Ob(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Ob(e,i,r.copy(s.from,r.to)));break}}}return e}function Ob(t,e,n){for(;e<t.length&&_s(n,t[e])>0;)e++;t.splice(e,0,n)}function Zf(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Cn&&e.push(r)}),t.cursorWrapper&&e.push(lt.create(t.state.doc,[t.cursorWrapper.deco])),Pi.from(e)}const $N={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},UN=Wn&&Hi<=11;class HN{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 WN{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new HN,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Wn&&Hi<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Nn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),UN&&(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,$N)),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(Eb(this.view)){if(this.suppressingSelectionUpdates)return ci(this.view);if(Wn&&Hi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Os(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 s=e.focusNode;s;s=Eo(s))n.add(s);for(let s=e.anchorNode;s;s=Eo(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.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(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Eb(e)&&!this.ignoreSelectionChange(r),s=-1,l=-1,c=!1,u=[];if(e.editable)for(let p=0;p<n.length;p++){let h=this.registerMutation(n[p],u);h&&(s=s<0?h.from:Math.min(h.from,s),l=l<0?h.to:Math.max(h.to,l),h.typeOver&&(c=!0))}if(u.some(p=>p.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let p of u)if(p.nodeName=="BR"&&p.parentNode){let h=p.nextSibling;h&&h.nodeType==1&&h.contentEditable=="false"&&p.parentNode.removeChild(p)}}else if(hr&&u.length){let p=u.filter(h=>h.nodeName=="BR");if(p.length==2){let[h,y]=p;h.parentNode&&h.parentNode.parentNode==y.parentNode?y.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let y of p){let b=y.parentNode;b&&b.nodeName=="LI"&&(!h||GN(e,h)!=b)&&y.remove()}}}let f=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Fu(r)&&(f=wh(e))&&f.eq(Ve.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ci(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,l),VN(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qN(e,u)),this.handleDOMChange(s,l,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ci(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 h=e.addedNodes[p];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Wn&&Hi<=11&&e.addedNodes.length)for(let p=0;p<e.addedNodes.length;p++){let{previousSibling:h,nextSibling:y}=e.addedNodes[p];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(s=y)}let l=i&&i.parentNode==e.target?hn(i)+1:0,c=r.localPosFromDOM(e.target,l,-1),u=s&&s.parentNode==e.target?hn(s):e.target.childNodes.length,f=r.localPosFromDOM(e.target,u,1);return{from:c,to:f}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Rb=new WeakMap,Ib=!1;function VN(t){if(!Rb.has(t)&&(Rb.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=hr,Ib)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."),Ib=!0}}function Lb(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,l=t.domAtPos(t.state.selection.anchor);return Os(l.node,l.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function KN(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Lb(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Lb(t,n):null}function GN(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 qN(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let l=s.nextSibling;for(;l&&l.nodeName!="TD"&&l.nodeName!="TH";)l=l.nextSibling;if(l){let c=l;for(;;){let u=c.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;c=u}c.insertBefore(s,c.firstChild),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function JN(t,e,n){let{node:r,fromOffset:i,toOffset:s,from:l,to:c}=t.docView.parseRange(e,n),u=t.domSelectionRange(),f,p=u.anchorNode;if(p&&t.dom.contains(p.nodeType==1?p:p.parentNode)&&(f=[{node:p,offset:u.anchorOffset}],Fu(u)||f.push({node:u.focusNode,offset:u.focusOffset})),gn&&t.input.lastKeyCode===8)for(let w=s;w>i;w--){let S=r.childNodes[w-1],_=S.pmViewDesc;if(S.nodeName=="BR"&&!_){s=w;break}if(!_||_.size)break}let h=t.state.doc,y=t.someProp("domParser")||Ui.fromSchema(t.state.schema),b=h.resolve(l),x=null,E=y.parse(r,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:i,to:s,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:YN,context:b});if(f&&f[0].pos!=null){let w=f[0].pos,S=f[1]&&f[1].pos;S==null&&(S=w),x={anchor:w+l,head:S+l}}return{doc:E,sel:x,from:l,to:c}}function YN(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Nn&&/^(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||Nn&&/^(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 QN=/^(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 XN(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let B=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,Q=wh(t,B);if(Q&&!t.state.selection.eq(Q)){if(gn&&li&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",J=>J(t,vs(13,"Enter"))))return;let X=t.state.tr.setSelection(Q);B=="pointer"?X.setMeta("pointer",!0):B=="key"&&X.scrollIntoView(),s&&X.setMeta("composition",s),t.dispatch(X)}return}let l=t.state.doc.resolve(e),c=l.sharedDepth(n);e=l.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,f=JN(t,e,n),p=t.state.doc,h=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 x=t_(h.content,f.doc.content,f.from,y,b);if(x&&t.input.domChangeCount++,(So&&t.input.lastIOSEnter>Date.now()-225||li)&&i.some(B=>B.nodeType==1&&!QN.test(B.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",B=>B(t,vs(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&u instanceof Fe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))x={start:u.from,endA:u.to,endB:u.to};else{if(f.sel){let B=Db(t,t.state.doc,f.sel);if(B&&!B.eq(t.state.selection)){let Q=t.state.tr.setSelection(B);s&&Q.setMeta("composition",s),t.dispatch(Q)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof Fe&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),Wn&&Hi<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>f.from&&f.doc.textBetween(x.start-f.from-1,x.start-f.from+1)==" "&&(x.start--,x.endA--,x.endB--);let E=f.doc.resolveNoCache(x.start-f.from),w=f.doc.resolveNoCache(x.endB-f.from),S=p.resolve(x.start),_=E.sameParent(w)&&E.parent.inlineContent&&S.end()>=x.endA;if((So&&t.input.lastIOSEnter>Date.now()-225&&(!_||i.some(B=>B.nodeName=="DIV"||B.nodeName=="P"))||!_&&E.pos<f.doc.content.size&&(!E.sameParent(w)||!E.parent.inlineContent)&&E.pos<w.pos&&!/\S/.test(f.doc.textBetween(E.pos,w.pos,"","")))&&t.someProp("handleKeyDown",B=>B(t,vs(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&e_(p,x.start,x.endA,E,w)&&t.someProp("handleKeyDown",B=>B(t,vs(8,"Backspace")))){li&&gn&&t.domObserver.suppressSelectionUpdates();return}gn&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),li&&!_&&E.start()!=w.start()&&w.parentOffset==0&&E.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==x.endA&&(x.endB-=2,w=f.doc.resolveNoCache(x.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(B){return B(t,vs(13,"Enter"))})},20));let M=x.start,T=x.endA,O=B=>{let Q=B||t.state.tr.replace(M,T,f.doc.slice(x.start-f.from,x.endB-f.from));if(f.sel){let X=Db(t,Q.doc,f.sel);X&&!(gn&&t.composing&&X.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(X.head==M||X.head==Q.mapping.map(T)-1)||Wn&&X.empty&&X.head==M)&&Q.setSelection(X)}return s&&Q.setMeta("composition",s),Q.scrollIntoView()},P;if(_)if(E.pos==w.pos){Wn&&Hi<=11&&E.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ci(t),20));let B=O(t.state.tr.delete(M,T)),Q=p.resolve(x.start).marksAcross(p.resolve(x.endA));Q&&B.ensureMarks(Q),t.dispatch(B)}else if(x.endA==x.endB&&(P=ZN(E.parent.content.cut(E.parentOffset,w.parentOffset),S.parent.content.cut(S.parentOffset,x.endA-S.start())))){let B=O(t.state.tr);P.type=="add"?B.addMark(M,T,P.mark):B.removeMark(M,T,P.mark),t.dispatch(B)}else if(E.parent.child(E.index()).isText&&E.index()==w.index()-(w.textOffset?0:1)){let B=E.parent.textBetween(E.parentOffset,w.parentOffset),Q=()=>O(t.state.tr.insertText(B,M,T));t.someProp("handleTextInput",X=>X(t,M,T,B,Q))||t.dispatch(Q())}else t.dispatch(O());else t.dispatch(O())}function Db(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Eh(t,e.resolve(n.anchor),e.resolve(n.head))}function ZN(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,l,c,u;for(let p=0;p<r.length;p++)i=r[p].removeFromSet(i);for(let p=0;p<n.length;p++)s=n[p].removeFromSet(s);if(i.length==1&&s.length==0)c=i[0],l="add",u=p=>p.mark(c.addToSet(p.marks));else if(i.length==0&&s.length==1)c=s[0],l="remove",u=p=>p.mark(c.removeFromSet(p.marks));else return null;let f=[];for(let p=0;p<e.childCount;p++)f.push(u(e.child(p)));if(re.from(f).eq(t))return{mark:c,type:l}}function e_(t,e,n,r,i){if(n-e<=i.pos-r.pos||ep(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let c=s.nodeAfter;return c!=null&&n==e+c.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let l=t.resolve(ep(s,!0,!0));return!l.parent.isTextblock||l.pos>n||ep(l,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function ep(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function t_(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:l,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let u=Math.max(0,s-Math.min(l,c));r-=l+u-s}if(l<s&&t.size<e.size){let u=r<=s&&r>=l?s-r:0;s-=u,s&&s<e.size&&Pb(e.textBetween(s-1,s+1))&&(s+=u?1:-1),c=s+(c-l),l=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,s&&s<t.size&&Pb(t.textBetween(s-1,s+1))&&(s+=u?1:-1),l=s+(l-c),c=s}return{start:s,endA:l,endB:c}}function Pb(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 nk{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 yN,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach($b),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=zb(this),Bb(this),this.nodeViews=Fb(this),this.docView=yb(this.state.doc,jb(this),Zf(this),this.dom,this),this.domObserver=new WN(this,(r,i,s,l)=>XN(this,r,i,s,l)),this.domObserver.start(),bN(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&&zp(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach($b),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 i=this.state,s=!1,l=!1;e.storedMarks&&this.composing&&(Jx(this),l=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let b=Fb(this);r_(b,this.nodeViews)&&(this.nodeViews=b,s=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&zp(this),this.editable=zb(this),Bb(this);let u=Zf(this),f=jb(this),p=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,f,u);(h||!e.selection.eq(i.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&RC(this);if(l){this.domObserver.stop();let b=h&&(Wn||gn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&n_(i.selection,e.selection);if(h){let x=gn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=RN(this)),(s||!this.docView.update(e.doc,f,u,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=yb(e.doc,f,u,this.dom,this)),x&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&nN(this))?ci(this,b):(jx(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():y&&IC(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 Be){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&db(this,n.getBoundingClientRect(),e)}else db(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,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Qx(e.slice,e.move,i<0?void 0:Be.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let l=0;l<this.directPlugins.length;l++){let c=this.directPlugins[l].props[e];if(c!=null&&(i=n?n(c):c))return i}let s=this.state.plugins;if(s)for(let l=0;l<s.length;l++){let c=s[l].props[e];if(c!=null&&(i=n?n(c):c))return i}}hasFocus(){if(Wn){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&&LC(this.dom),ci(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 zC(this,e)}coordsAtPos(e,n=1){return Mx(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 i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return WC(this,n||this.state,e)}pasteHTML(e,n){return jl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return jl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Sh(this,e)}destroy(){this.docView&&(vN(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Zf(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,wC())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return kN(this,e)}domSelectionRange(){let e=this.domSelection();return e?Nn&&this.root.nodeType===11&&_C(this.dom.ownerDocument)==this.dom&&KN(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}nk.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function jb(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"),[vt.node(0,t.state.doc.content.size,e)]}function Bb(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:vt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function zb(t){return!t.someProp("editable",e=>e(t.state)===!1)}function n_(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 Fb(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function r_(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function $b(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 Gi={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:"'"},qc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},i_=typeof navigator<"u"&&/Mac/.test(navigator.platform),s_=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var mn=0;mn<10;mn++)Gi[48+mn]=Gi[96+mn]=String(mn);for(var mn=1;mn<=24;mn++)Gi[mn+111]="F"+mn;for(var mn=65;mn<=90;mn++)Gi[mn]=String.fromCharCode(mn+32),qc[mn]=String.fromCharCode(mn);for(var tp in Gi)qc.hasOwnProperty(tp)||(qc[tp]=Gi[tp]);function o_(t){var e=i_&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||s_&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?qc:Gi)[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 l_=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),a_=typeof navigator<"u"&&/Win/.test(navigator.platform);function c_(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,l;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))l_?l=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),l&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function u_(t){let e=Object.create(null);for(let n in t)e[c_(n)]=t[n];return e}function np(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 ut({props:{handleKeyDown:Ah(t)}})}function Ah(t){let e=u_(t);return function(n,r){let i=o_(r),s,l=e[np(i,r)];if(l&&l(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let c=e[np(i,r,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(a_&&r.ctrlKey&&r.altKey)&&(s=Gi[r.keyCode])&&s!=i){let c=e[np(s,r)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var f_=Object.defineProperty,Oh=(t,e)=>{for(var n in e)f_(t,n,{get:e[n],enumerable:!0})};function Hu(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var Wu=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:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...f)=>{const p=c(...f)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,l=[],c=!!t,u=t||i.tr,f=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(u),l.every(h=>h===!0)),p={...Object.fromEntries(Object.entries(n).map(([h,y])=>[h,(...x)=>{const E=this.buildProps(u,e),w=y(...x)(E);return l.push(w),p}])),run:f};return p}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...f)=>u(...f)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,l={tr:t,editor:r,view:s,state:Hu({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([c,u])=>[c,(...f)=>u(...f)(l)]))}};return l}},rk={};Oh(rk,{blur:()=>p_,clearContent:()=>h_,clearNodes:()=>m_,command:()=>g_,createParagraphNear:()=>y_,cut:()=>b_,deleteCurrentNode:()=>v_,deleteNode:()=>x_,deleteRange:()=>k_,deleteSelection:()=>w_,enter:()=>E_,exitCode:()=>S_,extendMarkRange:()=>C_,first:()=>N_,focus:()=>T_,forEach:()=>M_,insertContent:()=>A_,insertContentAt:()=>I_,joinBackward:()=>P_,joinDown:()=>D_,joinForward:()=>j_,joinItemBackward:()=>B_,joinItemForward:()=>z_,joinTextblockBackward:()=>F_,joinTextblockForward:()=>$_,joinUp:()=>L_,keyboardShortcut:()=>H_,lift:()=>W_,liftEmptyBlock:()=>V_,liftListItem:()=>K_,newlineInCode:()=>G_,resetAttributes:()=>q_,scrollIntoView:()=>J_,selectAll:()=>Y_,selectNodeBackward:()=>Q_,selectNodeForward:()=>X_,selectParentNode:()=>Z_,selectTextblockEnd:()=>eT,selectTextblockStart:()=>tT,setContent:()=>nT,setMark:()=>xT,setMeta:()=>kT,setNode:()=>wT,setNodeSelection:()=>ET,setTextDirection:()=>ST,setTextSelection:()=>CT,sinkListItem:()=>NT,splitBlock:()=>_T,splitListItem:()=>TT,toggleList:()=>MT,toggleMark:()=>AT,toggleNode:()=>OT,toggleWrap:()=>RT,undoInputRule:()=>IT,unsetAllMarks:()=>LT,unsetMark:()=>DT,unsetTextDirection:()=>PT,updateAttributes:()=>jT,wrapIn:()=>BT,wrapInList:()=>zT});var p_=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),h_=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),m_=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:l})=>{t.doc.nodesBetween(s.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:f,mapping:p}=e,h=f.resolve(p.map(u)),y=f.resolve(p.map(u+c.nodeSize)),b=h.blockRange(y);if(!b)return;const x=_o(b);if(c.type.isTextblock){const{defaultType:E}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(b.start,E)}(x||x===0)&&e.lift(b,x)})}),!0},g_=t=>e=>t(e),y_=()=>({state:t,dispatch:e})=>bx(t,e),b_=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const l=r.mapping.map(e);return r.insert(l,s.content),r.setSelection(new Fe(r.doc.resolve(Math.max(l-1,0)))),!0},v_=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const c=i.before(s),u=i.after(s);t.delete(c,u).scrollIntoView()}return!0}return!1};function qt(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 x_=t=>({tr:e,state:n,dispatch:r})=>{const i=qt(t,n.schema),s=e.selection.$anchor;for(let l=s.depth;l>0;l-=1)if(s.node(l).type===i){if(r){const u=s.before(l),f=s.after(l);e.delete(u,f).scrollIntoView()}return!0}return!1},k_=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},w_=()=>({state:t,dispatch:e})=>gh(t,e),E_=()=>({commands:t})=>t.keyboardShortcut("Enter"),S_=()=>({state:t,dispatch:e})=>lC(t,e);function Rh(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Jc(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Rh(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function ik(t,e,n={}){return t.find(r=>r.type===e&&Jc(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function Ub(t,e,n={}){return!!ik(t,e,n)}function Ih(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(p=>p.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(p=>p.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!ik([...i.node.marks],e,n)))return;let l=i.index,c=t.start()+i.offset,u=l+1,f=c+i.node.nodeSize;for(;l>0&&Ub([...t.parent.child(l-1).marks],e,n);)l-=1,c-=t.parent.child(l).nodeSize;for(;u<t.parent.childCount&&Ub([...t.parent.child(u).marks],e,n);)f+=t.parent.child(u).nodeSize,u+=1;return{from:c,to:f}}function ui(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 C_=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=ui(t,r.schema),{doc:l,selection:c}=n,{$from:u,from:f,to:p}=c;if(i){const h=Ih(u,s,e);if(h&&h.from<=f&&h.to>=p){const y=Fe.create(l,h.from,h.to);n.setSelection(y)}}return!0},N_=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 sk(t){return t instanceof Fe}function ws(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ok(t,e=null){if(!e)return null;const n=Ve.atStart(t),r=Ve.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?Fe.create(t,ws(0,i,s),ws(t.content.size,i,s)):Fe.create(t,ws(e,i,s),ws(e,i,s))}function Hb(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Yc(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function __(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var T_=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const l=()=>{(Yc()||Hb())&&r.dom.focus(),__()&&!Yc()&&!Hb()&&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(s&&t===null&&!sk(n.state.selection))return l(),!0;const c=ok(i.doc,t)||n.state.selection,u=n.state.selection.eq(c);return s&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},M_=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),A_=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),lk=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&&lk(r)}return t};function lc(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 lk(n)}function zl(t,e,n){if(t instanceof Nr||t instanceof re)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return re.fromArray(t.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(t);return n.errorOnInvalidContent&&l.check(),l}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),zl("",e,n)}if(i){if(n.errorOnInvalidContent){let l=!1,c="";const u=new Vv({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?Ui.fromSchema(u).parseSlice(lc(t),n.parseOptions):Ui.fromSchema(u).parse(lc(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const s=Ui.fromSchema(e);return n.slice?s.parseSlice(lc(t),n.parseOptions).content:s.parse(lc(t),n.parseOptions)}return zl("",e,n)}function O_(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof rn||i instanceof sn))return;const s=t.mapping.maps[r];let l=0;s.forEach((c,u,f,p)=>{l===0&&(l=p)}),t.setSelection(Ve.near(t.doc.resolve(l),n))}var R_=t=>!("type"in t),I_=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var l;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=w=>{s.emit("contentError",{editor:s,error:w,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{zl(e,s.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(w){u(w)}try{c=zl(e,s.schema,{parseOptions:f,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:s.options.enableContentCheck})}catch(w){return u(w),!1}let{from:p,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,b=!0;if((R_(c)?c:[c]).forEach(w=>{w.check(),y=y?w.isText&&w.marks.length===0:!1,b=b?w.isBlock:!1}),p===h&&b){const{parent:w}=r.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,h+=1)}let E;if(y){if(Array.isArray(e))E=e.map(w=>w.text||"").join("");else if(e instanceof re){let w="";e.forEach(S=>{S.text&&(w+=S.text)}),E=w}else typeof e=="object"&&e&&e.text?E=e.text:E=e;r.insertText(E,p,h)}else{E=c;const w=r.doc.resolve(p),S=w.node(),_=w.parentOffset===0,M=S.isText||S.isTextblock,T=S.content.size>0;_&&M&&T&&(p=Math.max(0,p-1)),r.replaceWith(p,h,E)}n.updateSelection&&O_(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:p,text:E}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:p,text:E})}return!0},L_=()=>({state:t,dispatch:e})=>iC(t,e),D_=()=>({state:t,dispatch:e})=>sC(t,e),P_=()=>({state:t,dispatch:e})=>dx(t,e),j_=()=>({state:t,dispatch:e})=>mx(t,e),B_=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ju(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},z_=()=>({state:t,dispatch:e,tr:n})=>{try{const r=ju(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},F_=()=>({state:t,dispatch:e})=>nC(t,e),$_=()=>({state:t,dispatch:e})=>rC(t,e);function ak(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function U_(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,l;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))Yc()||ak()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var H_=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=U_(t).split(/-(?!$)/),l=s.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,c))});return u==null||u.steps.forEach(f=>{const p=f.map(r.mapping);p&&i&&r.maybeStep(p)}),!0};function qi(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,l=e?qt(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(h,y)=>{if(h.isText)return;const b=Math.max(r,y),x=Math.min(i,y+h.nodeSize);c.push({node:h,from:b,to:x})});const u=i-r,f=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>Jc(h.node.attrs,n,{strict:!1}));return s?!!f.length:f.reduce((h,y)=>h+y.to-y.from,0)>=u}var W_=(t,e={})=>({state:n,dispatch:r})=>{const i=qt(t,n.schema);return qi(n,i,e)?oC(n,r):!1},V_=()=>({state:t,dispatch:e})=>vx(t,e),K_=t=>({state:e,dispatch:n})=>{const r=qt(t,e.schema);return bC(r)(e,n)},G_=()=>({state:t,dispatch:e})=>yx(t,e);function Vu(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Wb(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var q_=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,l=null;const c=Vu(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(s=qt(t,r.schema)),c==="mark"&&(l=ui(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(p,h)=>{s&&s===p.type&&(u=!0,i&&n.setNodeMarkup(h,void 0,Wb(p.attrs,e))),l&&p.marks.length&&p.marks.forEach(y=>{l===y.type&&(u=!0,i&&n.addMark(h,h+p.nodeSize,l.create(Wb(y.attrs,e))))})})}),u},J_=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Y_=()=>({tr:t,dispatch:e})=>{if(e){const n=new er(t.doc);t.setSelection(n)}return!0},Q_=()=>({state:t,dispatch:e})=>px(t,e),X_=()=>({state:t,dispatch:e})=>gx(t,e),Z_=()=>({state:t,dispatch:e})=>uC(t,e),eT=()=>({state:t,dispatch:e})=>pC(t,e),tT=()=>({state:t,dispatch:e})=>fC(t,e);function Fp(t,e,n={},r={}){return zl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var nT=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:l,commands:c})=>{const{doc:u}=s;if(r.preserveWhitespace!=="full"){const f=Fp(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return l&&s.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!n),!0}return l&&s.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function ck(t,e){const n=ui(e,t.schema),{from:r,to:i,empty:s}=t.selection,l=[];s?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function Lh(t,e){const n=new hh(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function rT(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 Qc(t,e){const n=[];return t.descendants((r,i)=>{e(r)&&n.push({node:r,pos:i})}),n}function uk(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function dk(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 Ku(t){return e=>dk(e.$from,t)}function Pe(t,e,n){return t.config[e]===void 0&&t.parent?Pe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Pe(t.parent,e,n):null}):t.config[e]}function Dh(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Pe(e,"addExtensions",n);return r?[e,...Dh(r())]:e}).flat(10)}function Ph(t,e){const n=Ps.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function fk(t){return typeof t=="function"}function at(t,e=void 0,...n){return fk(t)?e?t.bind(e)(...n):t(...n):t}function iT(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Co(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function pk(t){const e=[],{nodeExtensions:n,markExtensions:r}=Co(t),i=[...n,...r],s={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:i},u=Pe(l,"addGlobalAttributes",c);if(!u)return;u().forEach(p=>{p.types.forEach(h=>{Object.entries(p.attributes).forEach(([y,b])=>{e.push({type:h,name:y,attribute:{...s,...b}})})})})}),i.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},u=Pe(l,"addAttributes",c);if(!u)return;const f=u();Object.entries(f).forEach(([p,h])=>{const y={...s,...h};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 ct(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const c=s?String(s).split(" "):[],u=r[i]?r[i].split(" "):[],f=c.filter(p=>!u.includes(p));r[i]=[...u,...f].join(" ")}else if(i==="style"){const c=s?s.split(";").map(p=>p.trim()).filter(Boolean):[],u=r[i]?r[i].split(";").map(p=>p.trim()).filter(Boolean):[],f=new Map;u.forEach(p=>{const[h,y]=p.split(":").map(b=>b.trim());f.set(h,y)}),c.forEach(p=>{const[h,y]=p.split(":").map(b=>b.trim());f.set(h,y)}),r[i]=Array.from(f.entries()).map(([p,h])=>`${p}: ${h}`).join("; ")}else r[i]=s}),r},{})}function Fl(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)=>ct(n,r),{})}function sT(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Vb(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 i=e.reduce((s,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(n):sT(n.getAttribute(l.name));return c==null?s:{...s,[l.name]:c}},{});return{...r,...i}}}}function Kb(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&iT(n)?!1:n!=null))}function Gb(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=pk(t),{nodeExtensions:i,markExtensions:s}=Co(t),l=(n=i.find(f=>Pe(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(i.map(f=>{const p=r.filter(S=>S.type===f.name),h={name:f.name,options:f.options,storage:f.storage,editor:e},y=t.reduce((S,_)=>{const M=Pe(_,"extendNodeSchema",h);return{...S,...M?M(f):{}}},{}),b=Kb({...y,content:at(Pe(f,"content",h)),marks:at(Pe(f,"marks",h)),group:at(Pe(f,"group",h)),inline:at(Pe(f,"inline",h)),atom:at(Pe(f,"atom",h)),selectable:at(Pe(f,"selectable",h)),draggable:at(Pe(f,"draggable",h)),code:at(Pe(f,"code",h)),whitespace:at(Pe(f,"whitespace",h)),linebreakReplacement:at(Pe(f,"linebreakReplacement",h)),defining:at(Pe(f,"defining",h)),isolating:at(Pe(f,"isolating",h)),attrs:Object.fromEntries(p.map(Gb))}),x=at(Pe(f,"parseHTML",h));x&&(b.parseDOM=x.map(S=>Vb(S,p)));const E=Pe(f,"renderHTML",h);E&&(b.toDOM=S=>E({node:S,HTMLAttributes:Fl(S,p)}));const w=Pe(f,"renderText",h);return w&&(b.toText=w),[f.name,b]})),u=Object.fromEntries(s.map(f=>{const p=r.filter(w=>w.type===f.name),h={name:f.name,options:f.options,storage:f.storage,editor:e},y=t.reduce((w,S)=>{const _=Pe(S,"extendMarkSchema",h);return{...w,..._?_(f):{}}},{}),b=Kb({...y,inclusive:at(Pe(f,"inclusive",h)),excludes:at(Pe(f,"excludes",h)),group:at(Pe(f,"group",h)),spanning:at(Pe(f,"spanning",h)),code:at(Pe(f,"code",h)),attrs:Object.fromEntries(p.map(Gb))}),x=at(Pe(f,"parseHTML",h));x&&(b.parseDOM=x.map(w=>Vb(w,p)));const E=Pe(f,"renderHTML",h);return E&&(b.toDOM=w=>E({mark:w,HTMLAttributes:Fl(w,p)})),[f.name,b]}));return new Vv({topNode:l,nodes:c,marks:u})}function lT(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Xc(t){return t.sort((n,r)=>{const i=Pe(n,"priority")||100,s=Pe(r,"priority")||100;return i>s?-1:i<s?1:0})}function hk(t){const e=Xc(Dh(t)),n=lT(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 mk(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
58
|
+
|
|
59
|
+
`,textSerializers:l={}}=n||{};let c="";return t.nodesBetween(r,i,(u,f,p,h)=>{var y;u.isBlock&&f>r&&(c+=s);const b=l==null?void 0:l[u.type.name];if(b)return p&&(c+=b({node:u,pos:f,parent:p,index:h,range:e})),!1;u.isText&&(c+=(y=u==null?void 0:u.text)==null?void 0:y.slice(Math.max(r,f)-f,i-f))}),c}function aT(t,e){const n={from:0,to:t.content.size};return mk(t,n,e)}function gk(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function cT(t,e){const n=qt(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,c=>{s.push(c)});const l=s.reverse().find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function yk(t,e){const n=Vu(typeof e=="string"?e:e.name,t.schema);return n==="node"?cT(t,e):n==="mark"?ck(t,e):{}}function uT(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function dT(t){const e=uT(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,l)=>l!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function jh(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const l=[];if(i.ranges.length)i.forEach((c,u)=>{l.push({from:c,to:u})});else{const{from:c,to:u}=n[s];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}l.forEach(({from:c,to:u})=>{const f=e.slice(s).map(c,-1),p=e.slice(s).map(u),h=e.invert().map(f,-1),y=e.invert().map(p);r.push({oldRange:{from:h,to:y},newRange:{from:f,to:p}})})}),dT(r)}function Bh(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),l=Ih(s,i.type);l&&r.push({mark:i,...l})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(l=>({from:s,to:s+i.nodeSize,mark:l})))}),r}var fT=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,l=null;for(;s>0&&l===null;){const c=i.node(s);(c==null?void 0:c.type.name)===e?l=c:s-=1}return[l,s]};function ac(t,e){return e.nodes[t]||e.marks[t]||null}function Ic(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var pT=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,l,c)=>{var u,f;const p=((f=(u=i.type.spec).toText)==null?void 0:f.call(u,{node:i,pos:s,parent:l,index:c}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?p:p.slice(0,Math.max(0,r-s))}),n};function $p(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?ui(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>Jc(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:y})=>{const b=h.pos,x=y.pos;t.doc.nodesBetween(b,x,(E,w)=>{if(!E.isText&&!E.marks.length)return;const S=Math.max(b,w),_=Math.min(x,w+E.nodeSize),M=_-S;l+=M,c.push(...E.marks.map(T=>({mark:T,from:S,to:_})))})}),l===0)return!1;const u=c.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>Jc(h.mark.attrs,n,{strict:!1})).reduce((h,y)=>h+y.to-y.from,0),f=c.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,y)=>h+y.to-y.from,0);return(u>0?u+f:u)>=l}function hT(t,e,n={}){if(!e)return qi(t,null,n)||$p(t,null,n);const r=Vu(e,t.schema);return r==="node"?qi(t,e,n):r==="mark"?$p(t,e,n):!1}var mT=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=Ku(c=>c.type.name===e)(t.selection);if(!s)return!1;const l=t.doc.resolve(s.pos+1);return i.pos+1===l.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},gT=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function qb(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Jb(t,e){const{nodeExtensions:n}=Co(e),r=n.find(l=>l.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=at(Pe(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Gu(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 i=!0;return t.content.forEach(s=>{i!==!1&&(Gu(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function bk(t){return t instanceof Be}var vk=class xk{constructor(e){this.position=e}static fromJSON(e){return new xk(e.position)}toJSON(){return{position:this.position}}};function yT(t,e){const n=e.mapping.mapResult(t.position);return{position:new vk(n.pos),mapResult:n}}function bT(t){return new vk(t)}function vT(t,e,n){var r;const{selection:i}=e;let s=null;if(sk(i)&&(s=i.$cursor),s){const c=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(f=>f.type.excludes(n)))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(p,h,y)=>{if(f)return!1;if(p.isInline){const b=!y||y.type.allowsMarkType(n),x=!!n.isInSet(p.marks)||!p.marks.some(E=>E.type.excludes(n));f=b&&x}return!f}),f})}var xT=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:l,ranges:c}=s,u=ui(t,r.schema);if(i)if(l){const f=ck(r,u);n.addStoredMark(u.create({...f,...e}))}else c.forEach(f=>{const p=f.$from.pos,h=f.$to.pos;r.doc.nodesBetween(p,h,(y,b)=>{const x=Math.max(b,p),E=Math.min(b+y.nodeSize,h);y.marks.find(S=>S.type===u)?y.marks.forEach(S=>{u===S.type&&n.addMark(x,E,u.create({...S.attrs,...e}))}):n.addMark(x,E,u.create(e))})});return vT(r,n,u)},kT=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),wT=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=qt(t,n.schema);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:c})=>ab(s,{...l,...e})(n)?!0:c.clearNodes()).command(({state:c})=>ab(s,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ET=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=ws(t,0,r.content.size),s=Be.create(r,i);e.setSelection(s)}return!0},ST=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=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=s.from,c=s.to),i&&n.doc.nodesBetween(l,c,(u,f)=>{u.isText||n.setNodeMarkup(f,void 0,{...u.attrs,dir:t})}),!0},CT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,l=Fe.atStart(r).from,c=Fe.atEnd(r).to,u=ws(i,l,c),f=ws(s,l,c),p=Fe.create(r,u,f);e.setSelection(p)}return!0},NT=t=>({state:e,dispatch:n})=>{const r=qt(t,e.schema);return kC(r)(e,n)};function Yb(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}var _T=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:l}=e,{$from:c,$to:u}=s,f=i.extensionManager.attributes,p=Ic(f,c.node().type.name,c.node().attrs);if(s instanceof Be&&s.node.isBlock)return!c.parentOffset||!ai(l,c.pos)?!1:(r&&(t&&Yb(n,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const h=u.parentOffset===u.parent.content.size,y=c.depth===0?void 0:rT(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=h&&y?[{type:y,attrs:p}]:void 0,x=ai(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!x&&ai(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(x=!0,b=y?[{type:y,attrs:p}]:void 0),r){if(x&&(s instanceof Fe&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,b),y&&!h&&!c.parentOffset&&c.parent.type!==y)){const E=e.mapping.map(c.before()),w=e.doc.resolve(E);c.node(-1).canReplaceWith(w.index(),w.index()+1,y)&&e.setNodeMarkup(e.mapping.map(c.before()),y)}t&&Yb(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},TT=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var l;const c=qt(t,r.schema),{$from:u,$to:f}=r.selection,p=r.selection.node;if(p&&p.isBlock||u.depth<2||!u.sameParent(f))return!1;const h=u.node(-1);if(h.type!==c)return!1;const y=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(i){let S=re.empty;const _=u.index(-1)?1:u.index(-2)?2:3;for(let Q=u.depth-_;Q>=u.depth-3;Q-=1)S=re.from(u.node(Q).copy(S));const M=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,T={...Ic(y,u.node().type.name,u.node().attrs),...e},O=((l=c.contentMatch.defaultType)==null?void 0:l.createAndFill(T))||void 0;S=S.append(re.from(c.createAndFill(null,O)||void 0));const P=u.before(u.depth-(_-1));n.replace(P,u.after(-M),new xe(S,4-_,0));let B=-1;n.doc.nodesBetween(P,n.doc.content.size,(Q,X)=>{if(B>-1)return!1;Q.isTextblock&&Q.content.size===0&&(B=X+1)}),B>-1&&n.setSelection(Fe.near(n.doc.resolve(B))),n.scrollIntoView()}return!0}const b=f.pos===u.end()?h.contentMatchAt(0).defaultType:null,x={...Ic(y,h.type.name,h.attrs),...e},E={...Ic(y,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,f.pos);const w=b?[{type:c,attrs:x},{type:b,attrs:E}]:[{type:c,attrs:x}];if(!ai(n.doc,u.pos,2))return!1;if(i){const{selection:S,storedMarks:_}=r,{splittableMarks:M}=s.extensionManager,T=_||S.$to.parentOffset&&S.$from.marks();if(n.split(u.pos,2,w).scrollIntoView(),!T||!i)return!0;const O=T.filter(P=>M.includes(P.type.name));n.ensureMarks(O)}return!0},rp=(t,e)=>{const n=Ku(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Yi(t.doc,n.pos)&&t.join(n.pos),!0},ip=(t,e)=>{const n=Ku(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Yi(t.doc,r)&&t.join(r),!0},MT=(t,e,n,r={})=>({editor:i,tr:s,state:l,dispatch:c,chain:u,commands:f,can:p})=>{const{extensions:h,splittableMarks:y}=i.extensionManager,b=qt(t,l.schema),x=qt(e,l.schema),{selection:E,storedMarks:w}=l,{$from:S,$to:_}=E,M=S.blockRange(_),T=w||E.$to.parentOffset&&E.$from.marks();if(!M)return!1;const O=Ku(P=>Jb(P.type.name,h))(E);if(M.depth>=1&&O&&M.depth-O.depth<=1){if(O.node.type===b)return f.liftListItem(x);if(Jb(O.node.type.name,h)&&b.validContent(O.node.content)&&c)return u().command(()=>(s.setNodeMarkup(O.pos,b),!0)).command(()=>rp(s,b)).command(()=>ip(s,b)).run()}return!n||!T||!c?u().command(()=>p().wrapInList(b,r)?!0:f.clearNodes()).wrapInList(b,r).command(()=>rp(s,b)).command(()=>ip(s,b)).run():u().command(()=>{const P=p().wrapInList(b,r),B=T.filter(Q=>y.includes(Q.type.name));return s.ensureMarks(B),P?!0:f.clearNodes()}).wrapInList(b,r).command(()=>rp(s,b)).command(()=>ip(s,b)).run()},AT=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,l=ui(t,r.schema);return $p(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:s}):i.setMark(l,e)},OT=(t,e,n={})=>({state:r,commands:i})=>{const s=qt(t,r.schema),l=qt(e,r.schema),c=qi(r,s,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(l,u):i.setNode(s,{...u,...n})},RT=(t,e={})=>({state:n,commands:r})=>{const i=qt(t,n.schema);return qi(n,i,e)?r.lift(i):r.wrapIn(i,e)},IT=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const l=t.tr,c=s.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(s.text){const u=l.doc.resolve(s.from).marks();l.replaceWith(s.from,s.to,t.schema.text(s.text,u))}else l.delete(s.from,s.to)}return!0}}return!1},LT=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},DT=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,u=ui(t,r.schema),{$from:f,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:y,to:b}=c;const x=(s=f.marks().find(w=>w.type===u))==null?void 0:s.attrs,E=Ih(f,u,x);E&&(y=E.from,b=E.to),n.removeMark(y,b,u)}else h.forEach(y=>{n.removeMark(y.$from.pos,y.$to.pos,u)});return n.removeStoredMark(u),!0},PT=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,l;return typeof t=="number"?(s=t,l=t):t&&"from"in t&&"to"in t?(s=t.from,l=t.to):(s=i.from,l=i.to),r&&e.doc.nodesBetween(s,l,(c,u)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(u,void 0,f)}),!0},jT=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,l=null;const c=Vu(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(s=qt(t,r.schema)),c==="mark"&&(l=ui(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{const p=f.$from.pos,h=f.$to.pos;let y,b,x,E;n.selection.empty?r.doc.nodesBetween(p,h,(w,S)=>{s&&s===w.type&&(u=!0,x=Math.max(S,p),E=Math.min(S+w.nodeSize,h),y=S,b=w)}):r.doc.nodesBetween(p,h,(w,S)=>{S<p&&s&&s===w.type&&(u=!0,x=Math.max(S,p),E=Math.min(S+w.nodeSize,h),y=S,b=w),S>=p&&S<=h&&(s&&s===w.type&&(u=!0,i&&n.setNodeMarkup(S,void 0,{...w.attrs,...e})),l&&w.marks.length&&w.marks.forEach(_=>{if(l===_.type&&(u=!0,i)){const M=Math.max(S,p),T=Math.min(S+w.nodeSize,h);n.addMark(M,T,l.create({..._.attrs,...e}))}}))}),b&&(y!==void 0&&i&&n.setNodeMarkup(y,void 0,{...b.attrs,...e}),l&&b.marks.length&&b.marks.forEach(w=>{l===w.type&&i&&n.addMark(x,E,l.create({...w.attrs,...e}))}))}),u},BT=(t,e={})=>({state:n,dispatch:r})=>{const i=qt(t,n.schema);return hC(i,e)(n,r)},zT=(t,e={})=>({state:n,dispatch:r})=>{const i=qt(t,n.schema);return mC(i,e)(n,r)},FT=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}},$T=(t,e)=>{if(Rh(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 cc(t){var e;const{editor:n,from:r,to:i,text:s,rules:l,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const f=u.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(y=>y.type.spec.code))return!1;let p=!1;const h=pT(f)+s;return l.forEach(y=>{if(p)return;const b=$T(h,y.find);if(!b)return;const x=u.state.tr,E=Hu({state:u.state,transaction:x}),w={from:r-(b[0].length-s.length),to:i},{commands:S,chain:_,can:M}=new Wu({editor:n,state:E});y.handler({state:E,range:w,match:b,commands:S,chain:_,can:M})===null||!x.steps.length||(y.undoable&&x.setMeta(c,{transform:x,from:r,to:i,text:s}),u.dispatch(x),p=!0)}),p}function UT(t){const{editor:e,rules:n}=t,r=new ut({state:{init(){return null},apply(i,s,l){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:p}=u;typeof p=="string"?p=p:p=Ph(re.from(p),l.schema);const{from:h}=u,y=h+p.length;cc({editor:e,from:h,to:y,text:p,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,l,c){return cc({editor:e,from:s,to:l,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&cc({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:l}=i.state.selection;return l?cc({editor:e,from:l.pos,to:l.pos,text:`
|
|
60
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function HT(t){return Object.prototype.toString.call(t).slice(8,-1)}function uc(t){return HT(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function kk(t,e){const n={...t};return uc(t)&&uc(e)&&Object.keys(e).forEach(r=>{uc(e[r])&&uc(t[r])?n[r]=kk(t[r],e[r]):n[r]=e[r]}),n}var zh=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{...at(Pe(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...at(Pe(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>kk(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}},_r=class wk extends zh{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new wk(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(f=>(f==null?void 0:f.type.name)===n.name))return!1;const u=l.find(f=>(f==null?void 0:f.type.name)===n.name);return u&&r.removeStoredMark(u),r.insertText(" ",i.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 WT(t){return typeof t=="number"}var VT=class{constructor(t){this.find=t.find,this.handler=t.handler}},KT=(t,e,n)=>{if(Rh(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function GT(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:l,dropEvent:c}=t,{commands:u,chain:f,can:p}=new Wu({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(b,x)=>{var E,w,S,_,M;if((w=(E=b.type)==null?void 0:E.spec)!=null&&w.code||!(b.isText||b.isTextblock||b.isInline))return;const T=(M=(_=(S=b.content)==null?void 0:S.size)!=null?_:b.nodeSize)!=null?M:0,O=Math.max(r,x),P=Math.min(i,x+T);if(O>=P)return;const B=b.isText?b.text||"":b.textBetween(O-x,P-x,void 0,"");KT(B,s.find,l).forEach(X=>{if(X.index===void 0)return;const J=O+X.index+1,fe=J+X[0].length,K={from:n.tr.mapping.map(J),to:n.tr.mapping.map(fe)},W=s.handler({state:n,range:K,match:X,commands:u,chain:f,can:p,pasteEvent:l,dropEvent:c});h.push(W)})}),h.every(b=>b!==null)}var dc=null,qT=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function JT(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:p,from:h,to:y,rule:b,pasteEvt:x})=>{const E=p.tr,w=Hu({state:p,transaction:E});if(!(!GT({editor:e,state:w,from:Math.max(h-1,0),to:y.b-1,rule:b,pasteEvent:x,dropEvent:c})||!E.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,E}};return n.map(p=>new ut({view(h){const y=x=>{var E;r=(E=h.dom.parentElement)!=null&&E.contains(x.target)?h.dom.parentElement:null,r&&(dc=e)},b=()=>{dc&&(dc=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(h,y)=>{if(s=r===h.dom.parentElement,c=y,!s){const b=dc;b!=null&&b.isEditable&&setTimeout(()=>{const x=b.state.selection;x&&b.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(h,y)=>{var b;const x=(b=y.clipboardData)==null?void 0:b.getData("text/html");return l=y,i=!!(x!=null&&x.includes("data-pm-slice")),!1}}},appendTransaction:(h,y,b)=>{const x=h[0],E=x.getMeta("uiEvent")==="paste"&&!i,w=x.getMeta("uiEvent")==="drop"&&!s,S=x.getMeta("applyPasteRules"),_=!!S;if(!E&&!w&&!_)return;if(_){let{text:O}=S;typeof O=="string"?O=O:O=Ph(re.from(O),b.schema);const{from:P}=S,B=P+O.length,Q=qT(O);return u({rule:p,state:b,from:P,to:{b:B},pasteEvt:Q})}const M=y.doc.content.findDiffStart(b.doc.content),T=y.doc.content.findDiffEnd(b.doc.content);if(!(!WT(M)||!T||M===T.b))return u({rule:p,state:b,from:M,to:T,pasteEvt:l})}}))}var qu=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=hk(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:ac(e.name,this.schema)},r=Pe(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Xc([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ac(r.name,this.schema)},s=[],l=Pe(r,"addKeyboardShortcuts",i);let c={};if(r.type==="mark"&&Pe(r,"exitable",i)&&(c.ArrowRight=()=>_r.handleExit({editor:t,mark:r})),l){const y=Object.fromEntries(Object.entries(l()).map(([b,x])=>[b,()=>x({editor:t})]));c={...c,...y}}const u=d_(c);s.push(u);const f=Pe(r,"addInputRules",i);if(qb(r,t.options.enableInputRules)&&f){const y=f();if(y&&y.length){const b=UT({editor:t,rules:y}),x=Array.isArray(b)?b:[b];s.push(...x)}}const p=Pe(r,"addPasteRules",i);if(qb(r,t.options.enablePasteRules)&&p){const y=p();if(y&&y.length){const b=JT({editor:t,rules:y});s.push(...b)}}const h=Pe(r,"addProseMirrorPlugins",i);if(h){const y=h();s.push(...y)}return s})}get attributes(){return pk(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Co(this.extensions);return Object.fromEntries(e.filter(n=>!!Pe(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:qt(n.name,this.schema)},s=Pe(n,"addNodeView",i);if(!s)return[];const l=s();if(!l)return[];const c=(u,f,p,h,y)=>{const b=Fl(u,r);return l({node:u,view:f,getPos:p,decorations:h,innerDecorations:y,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return Xc([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:ac(i.name,this.schema)},l=Pe(i,"dispatchTransaction",s);return l?c=>{l.call(s,{transaction:c,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=Co(this.extensions);return Object.fromEntries(e.filter(n=>!!Pe(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ui(n.name,this.schema)},s=Pe(n,"addMarkView",i);if(!s)return[];const l=(c,u,f)=>{const p=Fl(c,r);return s()({mark:c,view:u,inline:f,editor:t,extension:n,HTMLAttributes:p,updateAttributes:h=>{uM(c,t,h)}})};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:ac(e.name,this.schema)};e.type==="mark"&&((n=at(Pe(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Pe(e,"onBeforeCreate",r),s=Pe(e,"onCreate",r),l=Pe(e,"onUpdate",r),c=Pe(e,"onSelectionUpdate",r),u=Pe(e,"onTransaction",r),f=Pe(e,"onFocus",r),p=Pe(e,"onBlur",r),h=Pe(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),f&&this.editor.on("focus",f),p&&this.editor.on("blur",p),h&&this.editor.on("destroy",h)})}};qu.resolve=hk;qu.sort=Xc;qu.flatten=Dh;var YT={};Oh(YT,{ClipboardTextSerializer:()=>Sk,Commands:()=>Ck,Delete:()=>Nk,Drop:()=>_k,Editable:()=>Tk,FocusEvents:()=>Ak,Keymap:()=>Ok,Paste:()=>Rk,Tabindex:()=>Ik,TextDirection:()=>Lk,focusEventsPluginKey:()=>Mk});var st=class Ek extends zh{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Ek(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Sk=st.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ut({key:new mt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,l=Math.min(...s.map(p=>p.$from.pos)),c=Math.max(...s.map(p=>p.$to.pos)),u=gk(n);return mk(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),Ck=st.create({name:"commands",addCommands(){return{...rk}}}),Nk=st.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var l,c,u,f;if((f=(u=(c=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const p=Lh(t.before,[t,...e]);jh(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,(x,E)=>{const w=E+x.nodeSize-2,S=b.oldRange.from<=E&&w<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:E,to:w,newFrom:p.mapping.map(E),newTo:p.mapping.map(w),deletedRange:b.oldRange,newRange:b.newRange,partial:!S,editor:this.editor,transaction:t,combinedTransform:p})})});const y=p.mapping;p.steps.forEach((b,x)=>{var E,w;if(b instanceof Cr){const S=y.slice(x).map(b.from,-1),_=y.slice(x).map(b.to),M=y.invert().map(S,-1),T=y.invert().map(_),O=(E=p.doc.nodeAt(S-1))==null?void 0:E.marks.some(B=>B.eq(b.mark)),P=(w=p.doc.nodeAt(_))==null?void 0:w.marks.some(B=>B.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:M,to:T},newRange:{from:S,to:_},partial:!!(P||O),editor:this.editor,transaction:t,combinedTransform:p})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),_k=st.create({name:"drop",addProseMirrorPlugins(){return[new ut({key:new mt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Tk=st.create({name:"editable",addProseMirrorPlugins(){return[new ut({key:new mt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Mk=new mt("focusEvents"),Ak=st.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new ut({key:Mk,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}}}})]}}),Ok=st.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:f}=c,{empty:p,$anchor:h}=u,{pos:y,parent:b}=h,x=h.parent.isTextblock&&y>0?c.doc.resolve(y-1):h,E=x.parent.type.spec.isolating,w=h.pos-h.parentOffset,S=E&&x.parent.childCount===1?w===h.pos:Ve.atStart(f).from===y;return!p||!b.type.isTextblock||b.textContent.length||!S||S&&h.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()},i={...r},s={...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 Yc()||ak()?s:i},addProseMirrorPlugins(){return[new ut({key:new mt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(E=>E.getMeta("composition")))return;const r=t.some(E=>E.docChanged)&&!e.doc.eq(n.doc),i=t.some(E=>E.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:l,to:c}=e.selection,u=Ve.atStart(e.doc).from,f=Ve.atEnd(e.doc).to;if(s||!(l===u&&c===f)||!Gu(n.doc))return;const y=n.tr,b=Hu({state:n,transaction:y}),{commands:x}=new Wu({editor:this.editor,state:b});if(x.clearNodes(),!!y.steps.length)return y}})]}}),Rk=st.create({name:"paste",addProseMirrorPlugins(){return[new ut({key:new mt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Ik=st.create({name:"tabindex",addProseMirrorPlugins(){return[new ut({key:new mt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Lk=st.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Co(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 ut({key:new mt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),QT=class xl{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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 xl(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 xl(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 xl(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,l=n.isInline,c=this.pos+r+(s?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!i&&!l&&u.depth<=this.depth)return;const f=new xl(u,this.editor,i,i||l?n:null);i&&(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,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,l=Object.keys(n);for(let c=0;c<l.length;c+=1){const u=l[c];if(s[u]!==n[u])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(l=>{r&&i.length>0||(l.node.type.name===e&&s.every(u=>n[u]===l.node.attrs[u])&&i.push(l),!(r&&i.length>0)&&(i=i.concat(l.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},XT=`.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 ZT(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var eM=class extends FT{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:yT,createMappablePosition:bT},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:i,moved:s})=>this.options.onDrop(r,i,s)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=ok(e,this.options.autofocus);this.editorState=yo.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=ZT(XT,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=fk(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(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(l=>!l.key.startsWith(s))}),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?[Tk,Sk.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ck,Ak,Ok,Ik,_k,Rk,Nk,Lk.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new qu(r,this)}createCommandManager(){this.commandManager=new Wu({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Fp(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=Fp(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),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new nk(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),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),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const l=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),u=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),u&&this.emit("blur",{editor:this,event:u.event,transaction:l}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return yk(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return hT(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Ph(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
131
|
+
|
|
132
|
+
`,textSerializers:n={}}=t||{};return aT(this.state.doc,{blockSeparator:e,textSerializers:{...gk(this.schema),...n}})}get isEmpty(){return Gu(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 QT(e,this)}get $doc(){return this.$pos(0)}};function Is(t){return new ql({find:t.find,handler:({state:e,range:n,match:r})=>{const i=at(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,l=r[r.length-1],c=r[0];if(l){const u=c.search(/\S/),f=n.from+c.indexOf(l),p=f+l.length;if(Bh(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(E=>E===t.type&&E!==b.mark.type)).filter(b=>b.to>f).length)return null;p<n.to&&s.delete(p,n.to),f>n.from&&s.delete(n.from+u,f);const y=n.from+u+l.length;s.addMark(n.from+u,y,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Dk(t){return new ql({find:t.find,handler:({state:e,range:n,match:r})=>{const i=at(t.getAttributes,void 0,r)||{},{tr:s}=e,l=n.from;let c=n.to;const u=t.type.create(i);if(r[1]){const f=r[0].lastIndexOf(r[1]);let p=l+f;p>c?p=c:c=p+r[1].length;const h=r[0][r[0].length-1];s.insertText(h,l+r[0].length-1),s.replaceWith(p,c,u)}else if(r[0]){const f=t.type.isInline?l:l-1;s.insert(f,t.type.create(i)).delete(s.mapping.map(l),s.mapping.map(c))}s.scrollIntoView()},undoable:t.undoable})}function Up(t){return new ql({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=at(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function jt(t){return new ql({find:t.find,handler:({state:e,range:n,match:r})=>{let i=t.replace,s=n.from;const l=n.to;if(r[1]){const c=r[0].lastIndexOf(r[1]);i+=r[0].slice(c+r[1].length),s+=c;const u=s-l;u>0&&(i=r[0].slice(c-u,c)+i,s=l)}e.tr.insertText(i,s,l)},undoable:t.undoable})}function No(t){return new ql({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=at(t.getAttributes,void 0,r)||{},l=e.tr.delete(n.from,n.to),u=l.doc.resolve(n.from).blockRange(),f=u&&ph(u,t.type,s);if(!f)return null;if(l.wrap(u,f),t.keepMarks&&t.editor){const{selection:h,storedMarks:y}=e,{splittableMarks:b}=t.editor.extensionManager,x=y||h.$to.parentOffset&&h.$from.marks();if(x){const E=x.filter(w=>b.includes(w.type.name));l.ensureMarks(E)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}const p=l.doc.resolve(n.from-1).nodeBefore;p&&p.type===t.type&&Yi(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,p))&&l.join(n.from-1)},undoable:t.undoable})}var tM=t=>"touches"in t,nM=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,f=c.clientY-this.startY;this.handleResize(u,f)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const f=u.clientX-this.startX,p=u.clientY-this.startY;this.handleResize(f,p)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s,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),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.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"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(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,tM(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:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),l=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return s?r=this.startWidth+e:l&&(r=this.startWidth-e),c?i=this.startHeight+n:u&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,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)),(i=this.maxSize)!=null&&i.height&&(p=Math.min(this.maxSize.height,p)),{width:f,height:p}}let c=t,u=e;return c<this.minSize.width&&(c=this.minSize.width,u=c/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,c=u*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&c>this.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(l=this.maxSize)!=null&&l.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function rM(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Be){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}var iM={};Oh(iM,{createAtomBlockMarkdownSpec:()=>sM,createBlockMarkdownSpec:()=>oM,createInlineMarkdownSpec:()=>cM,parseAttributes:()=>Fh,parseIndentedBlocks:()=>Hp,renderNestedMarkdownContent:()=>Uh,serializeAttributes:()=>$h});function Fh(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const f=i.map(p=>p.trim().slice(1));e.class=f.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,f,p])=>{var h;const y=parseInt(((h=p.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),b=n[y];b&&(e[f]=b.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(p=>{p.match(/^[a-zA-Z][\w-]*$/)&&(e[p]=!0)}),e}function $h(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 sM(t){const{nodeName:e,name:n,parseAttributes:r=Fh,serializeAttributes:i=$h,defaultAttributes:s={},requiredAttributes:l=[],allowedAttributes:c}=t,u=n||e,f=p=>{if(!c)return p;const h={};return c.forEach(y=>{y in p&&(h[y]=p[y])}),h};return{parseMarkdown:(p,h)=>{const y={...s,...p.attributes};return h.createNode(e,y,[])},markdownTokenizer:{name:e,level:"block",start(p){var h;const y=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(h=p.match(y))==null?void 0:h.index;return b!==void 0?b:-1},tokenize(p,h,y){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=p.match(b);if(!x)return;const E=x[1]||"",w=r(E);if(!l.find(_=>!(_ in w)))return{type:e,raw:x[0],attributes:w}}},renderMarkdown:p=>{const h=f(p.attrs||{}),y=i(h),b=y?` {${y}}`:"";return`:::${u}${b} :::`}}}function oM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=Fh,serializeAttributes:s=$h,defaultAttributes:l={},content:c="block",allowedAttributes:u}=t,f=n||e,p=h=>{if(!u)return h;const y={};return u.forEach(b=>{b in h&&(y[b]=h[b])}),y};return{parseMarkdown:(h,y)=>{let b;if(r){const E=r(h);b=typeof E=="string"?[{type:"text",text:E}]:E}else c==="block"?b=y.parseChildren(h.tokens||[]):b=y.parseInline(h.tokens||[]);const x={...l,...h.attributes};return y.createNode(e,x,b)},markdownTokenizer:{name:e,level:"block",start(h){var y;const b=new RegExp(`^:::${f}`,"m"),x=(y=h.match(b))==null?void 0:y.index;return x!==void 0?x:-1},tokenize(h,y,b){var x;const E=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=h.match(E);if(!w)return;const[S,_=""]=w,M=i(_);let T=1;const O=S.length;let P="";const B=/^:::([\w-]*)(\s.*)?/gm,Q=h.slice(O);for(B.lastIndex=0;;){const X=B.exec(Q);if(X===null)break;const J=X.index,fe=X[1];if(!((x=X[2])!=null&&x.endsWith(":::"))){if(fe)T+=1;else if(T-=1,T===0){const K=Q.slice(0,J);P=K.trim();const W=h.slice(0,O+J+X[0].length);let $=[];if(P)if(c==="block")for($=b.blockTokens(K),$.forEach(Z=>{Z.text&&(!Z.tokens||Z.tokens.length===0)&&(Z.tokens=b.inlineTokens(Z.text))});$.length>0;){const Z=$[$.length-1];if(Z.type==="paragraph"&&(!Z.text||Z.text.trim()===""))$.pop();else break}else $=b.inlineTokens(P);return{type:e,raw:W,attributes:M,content:P,tokens:$}}}}}},renderMarkdown:(h,y)=>{const b=p(h.attrs||{}),x=s(b),E=x?` {${x}}`:"",w=y.renderChildren(h.content||[],`
|
|
133
|
+
|
|
134
|
+
`);return`:::${f}${E}
|
|
135
|
+
|
|
136
|
+
${w}
|
|
137
|
+
|
|
138
|
+
:::`}}}function lM(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,l]=r;e[i]=s||l,r=n.exec(t)}return e}function aM(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function cM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=lM,serializeAttributes:s=aM,defaultAttributes:l={},selfClosing:c=!1,allowedAttributes:u}=t,f=n||e,p=y=>{if(!u)return y;const b={};return u.forEach(x=>{const E=typeof x=="string"?x:x.name,w=typeof x=="string"?void 0:x.skipIfDefault;if(E in y){const S=y[E];if(w!==void 0&&S===w)return;b[E]=S}}),b},h=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(y,b)=>{const x={...l,...y.attributes};if(c)return b.createNode(e,x);const E=r?r(y):y.content||"";return E?b.createNode(e,x,[b.createTextNode(E)]):b.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(y){const b=c?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),x=y.match(b),E=x==null?void 0:x.index;return E!==void 0?E:-1},tokenize(y,b,x){const E=c?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),w=y.match(E);if(!w)return;let S="",_="";if(c){const[,T]=w;_=T}else{const[,T,O]=w;_=T,S=O||""}const M=i(_.trim());return{type:e,raw:w[0],content:S.trim(),attributes:M}}},renderMarkdown:y=>{let b="";r?b=r(y):y.content&&y.content.length>0&&(b=y.content.filter(S=>S.type==="text").map(S=>S.text).join(""));const x=p(y.attrs||{}),E=s(x),w=E?` ${E}`:"";return c?`[${f}${w}]`:`[${f}${w}]${b}[/${f}]`}}}function Hp(t,e,n){var r,i,s,l;const c=t.split(`
|
|
139
|
+
`),u=[];let f="",p=0;const h=e.baseIndentSize||2;for(;p<c.length;){const y=c[p],b=y.match(e.itemPattern);if(!b){if(u.length>0)break;if(y.trim()===""){p+=1,f=`${f}${y}
|
|
140
|
+
`;continue}else return}const x=e.extractItemData(b),{indentLevel:E,mainContent:w}=x;f=`${f}${y}
|
|
141
|
+
`;const S=[w];for(p+=1;p<c.length;){const O=c[p];if(O.trim()===""){const B=c.slice(p+1).findIndex(J=>J.trim()!=="");if(B===-1)break;if((((i=(r=c[p+1+B].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>E){S.push(O),f=`${f}${O}
|
|
142
|
+
`,p+=1;continue}else break}if((((l=(s=O.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:l.length)||0)>E)S.push(O),f=`${f}${O}
|
|
143
|
+
`,p+=1;else break}let _;const M=S.slice(1);if(M.length>0){const O=M.map(P=>P.slice(E+h)).join(`
|
|
144
|
+
`);O.trim()&&(e.customNestedParser?_=e.customNestedParser(O):_=n.blockTokens(O))}const T=e.createToken(x,_);u.push(T)}if(u.length!==0)return{items:u,raw:f}}function Uh(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...l]=t.content,c=e.renderChildren([s]),u=[`${i}${c}`];return l&&l.length>0&&l.forEach(f=>{const p=e.renderChildren([f]);if(p){const h=p.split(`
|
|
145
|
+
`).map(y=>y?e.indent(y):"").join(`
|
|
146
|
+
`);u.push(h)}}),u.join(`
|
|
147
|
+
`)}function uM(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,l=t;i.descendants((c,u)=>{const f=s.mapping.map(u),p=s.mapping.map(u)+c.nodeSize;let h=null;if(c.marks.forEach(b=>{if(b!==l)return!1;h=b}),!h)return;let y=!1;if(Object.keys(n).forEach(b=>{n[b]!==h.attrs[b]&&(y=!0)}),y){const b=t.type.create({...t.attrs,...n});s.removeMark(f,p,t.type),s.addMark(f,p,b)}}),s.docChanged&&e.view.dispatch(s)}var an=class Pk extends zh{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Pk(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Ji(t){return new VT({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=at(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:l}=e,c=r[r.length-1],u=r[0];let f=n.to;if(c){const p=u.search(/\S/),h=n.from+u.indexOf(c),y=h+c.length;if(Bh(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(w=>w===t.type&&w!==x.mark.type)).filter(x=>x.to>h).length)return null;y<n.to&&l.delete(y,n.to),h>n.from&&l.delete(n.from+p,h),f=n.from+p+c.length,l.addMark(n.from+p,f,t.type.create(s||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:dM,getOwnPropertySymbols:fM}=Object,{hasOwnProperty:pM}=Object.prototype;function sp(t,e){return function(r,i,s){return t(r,i,s)&&e(r,i,s)}}function fc(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:s}=i,l=s.get(n),c=s.get(r);if(l&&c)return l===r&&c===n;s.set(n,r),s.set(r,n);const u=t(n,r,i);return s.delete(n),s.delete(r),u}}function hM(t){return t!=null?t[Symbol.toStringTag]:void 0}function Qb(t){return dM(t).concat(fM(t))}const mM=Object.hasOwn||((t,e)=>pM.call(t,e));function js(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const gM="__v",yM="__o",bM="_owner",{getOwnPropertyDescriptor:Xb,keys:Zb}=Object;function vM(t,e){return t.byteLength===e.byteLength&&Zc(new Uint8Array(t),new Uint8Array(e))}function xM(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&&Zc(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function wM(t,e){return js(t.getTime(),e.getTime())}function EM(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function SM(t,e){return t===e}function e0(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.entries();let l,c,u=0;for(;(l=s.next())&&!l.done;){const f=e.entries();let p=!1,h=0;for(;(c=f.next())&&!c.done;){if(i[h]){h++;continue}const y=l.value,b=c.value;if(n.equals(y[0],b[0],u,h,t,e,n)&&n.equals(y[1],b[1],y[0],b[0],t,e,n)){p=i[h]=!0;break}h++}if(!p)return!1;u++}return!0}const CM=js;function NM(t,e,n){const r=Zb(t);let i=r.length;if(Zb(e).length!==i)return!1;for(;i-- >0;)if(!jk(t,e,n,r[i]))return!1;return!0}function fl(t,e,n){const r=Qb(t);let i=r.length;if(Qb(e).length!==i)return!1;let s,l,c;for(;i-- >0;)if(s=r[i],!jk(t,e,n,s)||(l=Xb(t,s),c=Xb(e,s),(l||c)&&(!l||!c||l.configurable!==c.configurable||l.enumerable!==c.enumerable||l.writable!==c.writable)))return!1;return!0}function _M(t,e){return js(t.valueOf(),e.valueOf())}function TM(t,e){return t.source===e.source&&t.flags===e.flags}function t0(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.values();let l,c;for(;(l=s.next())&&!l.done;){const u=e.values();let f=!1,p=0;for(;(c=u.next())&&!c.done;){if(!i[p]&&n.equals(l.value,c.value,l.value,c.value,t,e,n)){f=i[p]=!0;break}p++}if(!f)return!1}return!0}function Zc(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 MM(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 jk(t,e,n,r){return(r===bM||r===yM||r===gM)&&(t.$$typeof||e.$$typeof)?!0:mM(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const AM="[object ArrayBuffer]",OM="[object Arguments]",RM="[object Boolean]",IM="[object DataView]",LM="[object Date]",DM="[object Error]",PM="[object Map]",jM="[object Number]",BM="[object Object]",zM="[object RegExp]",FM="[object Set]",$M="[object String]",UM={"[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},HM="[object URL]",WM=Object.prototype.toString;function VM({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:l,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:f,areRegExpsEqual:p,areSetsEqual:h,areTypedArraysEqual:y,areUrlsEqual:b,unknownTagComparators:x}){return function(w,S,_){if(w===S)return!0;if(w==null||S==null)return!1;const M=typeof w;if(M!==typeof S)return!1;if(M!=="object")return M==="number"?c(w,S,_):M==="function"?s(w,S,_):!1;const T=w.constructor;if(T!==S.constructor)return!1;if(T===Object)return u(w,S,_);if(Array.isArray(w))return e(w,S,_);if(T===Date)return r(w,S,_);if(T===RegExp)return p(w,S,_);if(T===Map)return l(w,S,_);if(T===Set)return h(w,S,_);const O=WM.call(w);if(O===LM)return r(w,S,_);if(O===zM)return p(w,S,_);if(O===PM)return l(w,S,_);if(O===FM)return h(w,S,_);if(O===BM)return typeof w.then!="function"&&typeof S.then!="function"&&u(w,S,_);if(O===HM)return b(w,S,_);if(O===DM)return i(w,S,_);if(O===OM)return u(w,S,_);if(UM[O])return y(w,S,_);if(O===AM)return t(w,S,_);if(O===IM)return n(w,S,_);if(O===RM||O===jM||O===$M)return f(w,S,_);if(x){let P=x[O];if(!P){const B=hM(w);B&&(P=x[B])}if(P)return P(w,S,_)}return!1}}function KM({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:vM,areArraysEqual:n?fl:xM,areDataViewsEqual:kM,areDatesEqual:wM,areErrorsEqual:EM,areFunctionsEqual:SM,areMapsEqual:n?sp(e0,fl):e0,areNumbersEqual:CM,areObjectsEqual:n?fl:NM,arePrimitiveWrappersEqual:_M,areRegExpsEqual:TM,areSetsEqual:n?sp(t0,fl):t0,areTypedArraysEqual:n?sp(Zc,fl):Zc,areUrlsEqual:MM,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=fc(r.areArraysEqual),s=fc(r.areMapsEqual),l=fc(r.areObjectsEqual),c=fc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:l,areSetsEqual:c})}return r}function GM(t){return function(e,n,r,i,s,l,c){return t(e,n,c)}}function qM({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(c,u){const{cache:f=t?new WeakMap:void 0,meta:p}=n();return e(c,u,{cache:f,equals:r,meta:p,strict:i})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const s={cache:void 0,equals:r,meta:void 0,strict:i};return function(c,u){return e(c,u,s)}}const JM=Xi();Xi({strict:!0});Xi({circular:!0});Xi({circular:!0,strict:!0});Xi({createInternalComparator:()=>js});Xi({strict:!0,createInternalComparator:()=>js});Xi({circular:!0,createInternalComparator:()=>js});Xi({circular:!0,createInternalComparator:()=>js,strict:!0});function Xi(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,s=KM(t),l=VM(s),c=n?n(l):GM(l);return qM({circular:e,comparator:l,createState:r,equals:c,strict:i})}var op={exports:{}},lp={};/**
|
|
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 n0;function YM(){if(n0)return lp;n0=1;var t=Wl(),e=Tv();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,i=e.useSyncExternalStore,s=t.useRef,l=t.useEffect,c=t.useMemo,u=t.useDebugValue;return lp.useSyncExternalStoreWithSelector=function(f,p,h,y,b){var x=s(null);if(x.current===null){var E={hasValue:!1,value:null};x.current=E}else E=x.current;x=c(function(){function S(P){if(!_){if(_=!0,M=P,P=y(P),b!==void 0&&E.hasValue){var B=E.value;if(b(B,P))return T=B}return T=P}if(B=T,r(M,P))return B;var Q=y(P);return b!==void 0&&b(B,Q)?(M=P,B):(M=P,T=Q)}var _=!1,M,T,O=h===void 0?null:h;return[function(){return S(p())},O===null?void 0:function(){return S(O())}]},[p,h,y,b]);var w=i(f,x[0],x[1]);return l(function(){E.hasValue=!0,E.value=w},[w]),u(w),w},lp}var r0;function QM(){return r0||(r0=1,op.exports=YM()),op.exports}var XM=QM(),ZM=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},eA=({contentComponent:t})=>{const e=Mv.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return g.jsx(g.Fragment,{children:Object.values(e)})};function tA(){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]:oS.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var nA=class extends Ki.Component{constructor(t){var e;super(t),this.editorContentRef=Ki.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=tA(),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 g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:ZM(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&g.jsx(eA,{contentComponent:t.contentComponent})]})}},rA=N.forwardRef((t,e)=>{const n=Ki.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Ki.createElement(nA,{key:n,innerRef:e,...t})}),Hh=Ki.memo(rA),iA=typeof window<"u"?N.useLayoutEffect:N.useEffect,sA=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]=N.useState(()=>new sA(t.editor)),r=XM.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:JM);return iA(()=>n.watch(t.editor),[t.editor,n]),N.useDebugValue(r),r}var lA=!1,Wp=typeof window>"u",aA=Wp||!!(typeof window<"u"&&window.next),cA=class Bk{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?Wp||aA?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)}};return new eM(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((i,s)=>{var l;return i===((l=n.extensions)==null?void 0:l[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Bk.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,i)=>r===e[i]))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 zk(t={},e=[]){const n=N.useRef(t);n.current=t;const[r]=N.useState(()=>new cA(n)),i=Mv.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return N.useDebugValue(i),N.useEffect(r.onRender(e)),oA({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var Fk=N.createContext({editor:null});Fk.Consumer;var uA=N.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),dA=()=>N.useContext(uA);Ki.forwardRef((t,e)=>{const{onDragStart:n}=dA(),r=t.as||"div";return g.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});Ki.createContext({markViewContentRef:()=>{}});var Wh=N.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Wh.displayName="TiptapContext";var fA=()=>N.useContext(Wh);function $k({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 i=N.useMemo(()=>({editor:r}),[r]),s=N.useMemo(()=>({editor:r}),[r]);return g.jsx(Fk.Provider,{value:s,children:g.jsx(Wh.Provider,{value:i,children:n})})}$k.displayName="Tiptap";function Uk({...t}){const{editor:e}=fA();return g.jsx(Hh,{editor:e,...t})}Uk.displayName="Tiptap.Content";Object.assign($k,{Content:Uk});var pA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,hA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,mA=_r.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",ct(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 i=/^(==)([^=]+)(==)/.exec(t);if(i){const s=i[2].trim(),l=n.inlineTokens(s);return{type:"highlight",raw:i[0],text:s,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[Is({find:pA,type:this.type})]},addPasteRules(){return[Ji({find:hA,type:this.type})]}}),gA=mA,yA=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,bA=an.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",ct(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,i,s,l;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",f=(l=(s=t.attrs)==null?void 0:s.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:i,getPos:s,HTMLAttributes:l,editor:c})=>{const u=document.createElement("img");Object.entries(l).forEach(([h,y])=>{if(y!=null)switch(h){case"width":case"height":break;default:u.setAttribute(h,y);break}}),u.src=l.src;const f=new nM({element:u,editor:c,node:i,getPos:s,onResize:(h,y)=>{u.style.width=`${h}px`,u.style.height=`${y}px`},onCommit:(h,y)=>{const b=s();b!==void 0&&this.editor.chain().setNodeSelection(b).updateAttributes(this.name,{width:h,height:y}).run()},onUpdate:(h,y,b)=>h.type===i.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),p=f.dom;return p.style.visibility="hidden",p.style.pointerEvents="none",u.onload=()=>{p.style.visibility="",p.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Dk({find:yA,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Vh=bA;const vA="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",xA="ελ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",Vp="numeric",Kp="ascii",Gp="alpha",Nl="asciinumeric",kl="alphanumeric",qp="domain",Hk="emoji",kA="scheme",wA="slashscheme",ap="whitespace";function EA(t,e){return t in e||(e[t]=[]),e[t]}function Es(t,e,n){e[Vp]&&(e[Nl]=!0,e[kl]=!0),e[Kp]&&(e[Nl]=!0,e[Gp]=!0),e[Nl]&&(e[kl]=!0),e[Gp]&&(e[kl]=!0),e[kl]&&(e[qp]=!0),e[Hk]&&(e[qp]=!0);for(const r in e){const i=EA(r,n);i.indexOf(t)<0&&i.push(t)}}function SA(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Hn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Hn.groups={};Hn.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 i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Hn.groups;let i;return e&&e.j?i=e:(i=new Hn(e),n&&r&&Es(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let l=0;l<s-1;l++)i=i.tt(t[l]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Hn.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let l,c=i.go(t);if(c?(l=new Hn,Object.assign(l.j,c.j),l.jr.push.apply(l.jr,c.jr),l.jd=c.jd,l.t=c.t):l=new Hn,s){if(r)if(l.t&&typeof l.t=="string"){const u=Object.assign(SA(l.t,r),n);Es(s,u,r)}else n&&Es(s,n,r);l.t=s}return i.j[t]=l,l}};const Qe=(t,e,n,r,i)=>t.ta(e,n,r,i),Lt=(t,e,n,r,i)=>t.tr(e,n,r,i),i0=(t,e,n,r,i)=>t.ts(e,n,r,i),pe=(t,e,n,r,i)=>t.tt(e,n,r,i),ii="WORD",Jp="UWORD",Wk="ASCIINUMERICAL",Vk="ALPHANUMERICAL",$l="LOCALHOST",Yp="TLD",Qp="UTLD",Lc="SCHEME",ho="SLASH_SCHEME",Kh="NUM",Xp="WS",Gh="NL",_l="OPENBRACE",Tl="CLOSEBRACE",eu="OPENBRACKET",tu="CLOSEBRACKET",nu="OPENPAREN",ru="CLOSEPAREN",iu="OPENANGLEBRACKET",su="CLOSEANGLEBRACKET",ou="FULLWIDTHLEFTPAREN",lu="FULLWIDTHRIGHTPAREN",au="LEFTCORNERBRACKET",cu="RIGHTCORNERBRACKET",uu="LEFTWHITECORNERBRACKET",du="RIGHTWHITECORNERBRACKET",fu="FULLWIDTHLESSTHAN",pu="FULLWIDTHGREATERTHAN",hu="AMPERSAND",mu="APOSTROPHE",gu="ASTERISK",Li="AT",yu="BACKSLASH",bu="BACKTICK",vu="CARET",ji="COLON",qh="COMMA",xu="DOLLAR",Fr="DOT",ku="EQUALS",Jh="EXCLAMATION",dr="HYPHEN",Ml="PERCENT",wu="PIPE",Eu="PLUS",Su="POUND",Al="QUERY",Yh="QUOTE",Kk="FULLWIDTHMIDDLEDOT",Qh="SEMI",$r="SLASH",Ol="TILDE",Cu="UNDERSCORE",Gk="EMOJI",Nu="SYM";var qk=Object.freeze({__proto__:null,ALPHANUMERICAL:Vk,AMPERSAND:hu,APOSTROPHE:mu,ASCIINUMERICAL:Wk,ASTERISK:gu,AT:Li,BACKSLASH:yu,BACKTICK:bu,CARET:vu,CLOSEANGLEBRACKET:su,CLOSEBRACE:Tl,CLOSEBRACKET:tu,CLOSEPAREN:ru,COLON:ji,COMMA:qh,DOLLAR:xu,DOT:Fr,EMOJI:Gk,EQUALS:ku,EXCLAMATION:Jh,FULLWIDTHGREATERTHAN:pu,FULLWIDTHLEFTPAREN:ou,FULLWIDTHLESSTHAN:fu,FULLWIDTHMIDDLEDOT:Kk,FULLWIDTHRIGHTPAREN:lu,HYPHEN:dr,LEFTCORNERBRACKET:au,LEFTWHITECORNERBRACKET:uu,LOCALHOST:$l,NL:Gh,NUM:Kh,OPENANGLEBRACKET:iu,OPENBRACE:_l,OPENBRACKET:eu,OPENPAREN:nu,PERCENT:Ml,PIPE:wu,PLUS:Eu,POUND:Su,QUERY:Al,QUOTE:Yh,RIGHTCORNERBRACKET:cu,RIGHTWHITECORNERBRACKET:du,SCHEME:Lc,SEMI:Qh,SLASH:$r,SLASH_SCHEME:ho,SYM:Nu,TILDE:Ol,TLD:Yp,UNDERSCORE:Cu,UTLD:Qp,UWORD:Jp,WORD:ii,WS:Xp});const ni=/[a-z]/,pl=new RegExp("\\p{L}","u"),cp=new RegExp("\\p{Emoji}","u"),ri=/\d/,up=/\s/,s0="\r",dp=`
|
|
156
|
+
`,CA="️",NA="",fp="";let pc=null,hc=null;function _A(t=[]){const e={};Hn.groups=e;const n=new Hn;pc==null&&(pc=o0(vA)),hc==null&&(hc=o0(xA)),pe(n,"'",mu),pe(n,"{",_l),pe(n,"}",Tl),pe(n,"[",eu),pe(n,"]",tu),pe(n,"(",nu),pe(n,")",ru),pe(n,"<",iu),pe(n,">",su),pe(n,"(",ou),pe(n,")",lu),pe(n,"「",au),pe(n,"」",cu),pe(n,"『",uu),pe(n,"』",du),pe(n,"<",fu),pe(n,">",pu),pe(n,"&",hu),pe(n,"*",gu),pe(n,"@",Li),pe(n,"`",bu),pe(n,"^",vu),pe(n,":",ji),pe(n,",",qh),pe(n,"$",xu),pe(n,".",Fr),pe(n,"=",ku),pe(n,"!",Jh),pe(n,"-",dr),pe(n,"%",Ml),pe(n,"|",wu),pe(n,"+",Eu),pe(n,"#",Su),pe(n,"?",Al),pe(n,'"',Yh),pe(n,"/",$r),pe(n,";",Qh),pe(n,"~",Ol),pe(n,"_",Cu),pe(n,"\\",yu),pe(n,"・",Kk);const r=Lt(n,ri,Kh,{[Vp]:!0});Lt(r,ri,r);const i=Lt(r,ni,Wk,{[Nl]:!0}),s=Lt(r,pl,Vk,{[kl]:!0}),l=Lt(n,ni,ii,{[Kp]:!0});Lt(l,ri,i),Lt(l,ni,l),Lt(i,ri,i),Lt(i,ni,i);const c=Lt(n,pl,Jp,{[Gp]:!0});Lt(c,ni),Lt(c,ri,s),Lt(c,pl,c),Lt(s,ri,s),Lt(s,ni),Lt(s,pl,s);const u=pe(n,dp,Gh,{[ap]:!0}),f=pe(n,s0,Xp,{[ap]:!0}),p=Lt(n,up,Xp,{[ap]:!0});pe(n,fp,p),pe(f,dp,u),pe(f,fp,p),Lt(f,up,p),pe(p,s0),pe(p,dp),Lt(p,up,p),pe(p,fp,p);const h=Lt(n,cp,Gk,{[Hk]:!0});pe(h,"#"),Lt(h,cp,h),pe(h,CA,h);const y=pe(h,NA);pe(y,"#"),Lt(y,cp,h);const b=[[ni,l],[ri,i]],x=[[ni,null],[pl,c],[ri,s]];for(let E=0;E<pc.length;E++)Oi(n,pc[E],Yp,ii,b);for(let E=0;E<hc.length;E++)Oi(n,hc[E],Qp,Jp,x);Es(Yp,{tld:!0,ascii:!0},e),Es(Qp,{utld:!0,alpha:!0},e),Oi(n,"file",Lc,ii,b),Oi(n,"mailto",Lc,ii,b),Oi(n,"http",ho,ii,b),Oi(n,"https",ho,ii,b),Oi(n,"ftp",ho,ii,b),Oi(n,"ftps",ho,ii,b),Es(Lc,{scheme:!0,ascii:!0},e),Es(ho,{slashscheme:!0,ascii:!0},e),t=t.sort((E,w)=>E[0]>w[0]?1:-1);for(let E=0;E<t.length;E++){const w=t[E][0],_=t[E][1]?{[kA]:!0}:{[wA]:!0};w.indexOf("-")>=0?_[qp]=!0:ni.test(w)?ri.test(w)?_[Nl]=!0:_[Kp]=!0:_[Vp]=!0,i0(n,w,w,_)}return i0(n,"localhost",$l,{ascii:!0}),n.jd=new Hn(Nu),{start:n,tokens:Object.assign({groups:e},qk)}}function Jk(t,e){const n=TA(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,i=[];let s=0,l=0;for(;l<r;){let c=t,u=null,f=0,p=null,h=-1,y=-1;for(;l<r&&(u=c.go(n[l]));)c=u,c.accepts()?(h=0,y=0,p=c):h>=0&&(h+=n[l].length,y++),f+=n[l].length,s+=n[l].length,l++;s-=h,l-=y,f-=h,i.push({t:p.t,v:e.slice(s-f,s),s:s-f,e:s})}return i}function TA(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,l=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(l),r+=l.length}return e}function Oi(t,e,n,r,i){let s;const l=e.length;for(let c=0;c<l-1;c++){const u=e[c];t.j[u]?s=t.j[u]:(s=new Hn(r),s.jr=i.slice(),t.j[u]=s),t=s}return s=new Hn(n),s.jr=i.slice(),t.j[e[l-1]]=s,s}function o0(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let l=parseInt(t.substring(r,r+s),10);l>0;l--)n.pop();r+=s}else n.push(t[r]),r++}return e}const Ul={defaultProtocol:"http",events:null,format:l0,formatHref:l0,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Xh(t,e=null){let n=Object.assign({},Ul);t&&(n=Object.assign(n,t instanceof Xh?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}Xh.prototype={o:Ul,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Ul[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},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 l0(t){return t}function Yk(t,e){this.t="token",this.v=t,this.tk=e}Yk.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=Ul.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),i=t.get("tagName",n,e),s=this.toFormattedString(t),l={},c=t.get("className",n,e),u=t.get("target",n,e),f=t.get("rel",n,e),p=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return l.href=r,c&&(l.class=c),u&&(l.target=u),f&&(l.rel=f),p&&Object.assign(l,p),{tagName:i,attributes:l,content:s,eventListeners:h}}};function Ju(t,e){class n extends Yk{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const a0=Ju("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),c0=Ju("text"),MA=Ju("nl"),mc=Ju("url",{isLink:!0,toHref(t=Ul.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==$l&&t[1].t===ji}}),ur=t=>new Hn(t);function AA({groups:t}){const e=t.domain.concat([hu,gu,Li,yu,bu,vu,xu,ku,dr,Kh,Ml,wu,Eu,Su,$r,Nu,Ol,Cu]),n=[mu,ji,qh,Fr,Jh,Ml,Al,Yh,Qh,iu,su,_l,Tl,tu,eu,nu,ru,ou,lu,au,cu,uu,du,fu,pu],r=[hu,mu,gu,yu,bu,vu,xu,ku,dr,_l,Tl,Ml,wu,Eu,Su,Al,$r,Nu,Ol,Cu],i=ur(),s=pe(i,Ol);Qe(s,r,s),Qe(s,t.domain,s);const l=ur(),c=ur(),u=ur();Qe(i,t.domain,l),Qe(i,t.scheme,c),Qe(i,t.slashscheme,u),Qe(l,r,s),Qe(l,t.domain,l);const f=pe(l,Li);pe(s,Li,f),pe(c,Li,f),pe(u,Li,f);const p=pe(s,Fr);Qe(p,r,s),Qe(p,t.domain,s);const h=ur();Qe(f,t.domain,h),Qe(h,t.domain,h);const y=pe(h,Fr);Qe(y,t.domain,h);const b=ur(a0);Qe(y,t.tld,b),Qe(y,t.utld,b),pe(f,$l,b);const x=pe(h,dr);pe(x,dr,x),Qe(x,t.domain,h),Qe(b,t.domain,h),pe(b,Fr,y),pe(b,dr,x);const E=pe(b,ji);Qe(E,t.numeric,a0);const w=pe(l,dr),S=pe(l,Fr);pe(w,dr,w),Qe(w,t.domain,l),Qe(S,r,s),Qe(S,t.domain,l);const _=ur(mc);Qe(S,t.tld,_),Qe(S,t.utld,_),Qe(_,t.domain,l),Qe(_,r,s),pe(_,Fr,S),pe(_,dr,w),pe(_,Li,f);const M=pe(_,ji),T=ur(mc);Qe(M,t.numeric,T);const O=ur(mc),P=ur();Qe(O,e,O),Qe(O,n,P),Qe(P,e,O),Qe(P,n,P),pe(_,$r,O),pe(T,$r,O);const B=pe(c,ji),Q=pe(u,ji),X=pe(Q,$r),J=pe(X,$r);Qe(c,t.domain,l),pe(c,Fr,S),pe(c,dr,w),Qe(u,t.domain,l),pe(u,Fr,S),pe(u,dr,w),Qe(B,t.domain,O),pe(B,$r,O),pe(B,Al,O),Qe(J,t.domain,O),Qe(J,e,O),pe(J,$r,O);const fe=[[_l,Tl],[eu,tu],[nu,ru],[iu,su],[ou,lu],[au,cu],[uu,du],[fu,pu]];for(let K=0;K<fe.length;K++){const[W,$]=fe[K],Z=pe(O,W);pe(P,W,Z),pe(Z,$,O);const ee=ur(mc);Qe(Z,e,ee);const he=ur();Qe(Z,n),Qe(ee,e,ee),Qe(ee,n,he),Qe(he,e,ee),Qe(he,n,he),pe(ee,$,O),pe(he,$,O)}return pe(i,$l,_),pe(i,Gh,MA),{start:i,tokens:qk}}function OA(t,e,n){let r=n.length,i=0,s=[],l=[];for(;i<r;){let c=t,u=null,f=null,p=0,h=null,y=-1;for(;i<r&&!(u=c.go(n[i].t));)l.push(n[i++]);for(;i<r&&(f=u||c.go(n[i].t));)u=null,c=f,c.accepts()?(y=0,h=c):y>=0&&y++,i++,p++;if(y<0)i-=p,i<r&&(l.push(n[i]),i++);else{l.length>0&&(s.push(pp(c0,e,l)),l=[]),i-=y,p-=y;const b=h.t,x=n.slice(i-p,i);s.push(pp(b,e,x))}}return l.length>0&&s.push(pp(c0,e,l)),s}function pp(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const RA=typeof console<"u"&&console&&console.warn||(()=>{}),IA="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ct={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function LA(){return Hn.groups={},Ct.scanner=null,Ct.parser=null,Ct.tokenQueue=[],Ct.pluginQueue=[],Ct.customSchemes=[],Ct.initialized=!1,Ct}function u0(t,e=!1){if(Ct.initialized&&RA(`linkifyjs: already initialized - will not register custom scheme "${t}" ${IA}`),!/^[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`);Ct.customSchemes.push([t,e])}function DA(){Ct.scanner=_A(Ct.customSchemes);for(let t=0;t<Ct.tokenQueue.length;t++)Ct.tokenQueue[t][1]({scanner:Ct.scanner});Ct.parser=AA(Ct.scanner.tokens);for(let t=0;t<Ct.pluginQueue.length;t++)Ct.pluginQueue[t][1]({scanner:Ct.scanner,parser:Ct.parser});return Ct.initialized=!0,Ct}function Zh(t){return Ct.initialized||DA(),OA(Ct.parser.start,t,Jk(Ct.scanner.start,t))}Zh.scan=Jk;function Qk(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 Xh(n),i=Zh(t),s=[];for(let l=0;l<i.length;l++){const c=i[l];c.isLink&&(!e||c.t===e)&&r.check(c)&&s.push(c.toFormattedObject(r))}return s}var em="[\0- -\u2029 ]",PA=new RegExp(em),jA=new RegExp(`${em}$`),BA=new RegExp(em,"g");function zA(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function FA(t){return new ut({key:new mt("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),s=e.some(f=>f.getMeta("preventAutolink"));if(!i||s)return;const{tr:l}=r,c=Lh(n.doc,[...e]);if(jh(c).forEach(({newRange:f})=>{const p=uk(r.doc,f,b=>b.isTextblock);let h,y;if(p.length>1)h=p[0],y=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(p.length){const b=r.doc.textBetween(f.from,f.to," "," ");if(!jA.test(b))return;h=p[0],y=r.doc.textBetween(h.pos,f.to,void 0," ")}if(h&&y){const b=y.split(PA).filter(Boolean);if(b.length<=0)return!1;const x=b[b.length-1],E=h.pos+y.lastIndexOf(x);if(!x)return!1;const w=Zh(x).map(S=>S.toObject(t.defaultProtocol));if(!zA(w))return!1;w.filter(S=>S.isLink).map(S=>({...S,from:E+S.start+1,to:E+S.end+1})).filter(S=>r.schema.marks.code?!r.doc.rangeHasMark(S.from,S.to,r.schema.marks.code):!0).filter(S=>t.validate(S.value)).filter(S=>t.shouldAutoLink(S.value)).forEach(S=>{Bh(S.from,S.to,r.doc).some(_=>_.mark.type===t.type)||l.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!l.steps.length)return l}})}function $A(t){return new ut({key:new mt("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{const u=r.target;if(!u)return!1;const f=t.editor.view.dom;l=u.closest("a"),l&&!f.contains(l)&&(l=null)}if(!l)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=yk(e.state,t.type.name),f=(i=l.href)!=null?i:u.href,p=(s=l.target)!=null?s:u.target;f&&(window.open(f,p),c=!0)}return c}}})}function UA(t){return new ut({key:new mt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:l}=s,{empty:c}=l;if(c)return!1;let u="";r.content.forEach(p=>{u+=p.textContent});const f=Qk(u,{defaultProtocol:t.defaultProtocol}).find(p=>p.isLink&&p.value===u);return!u||!f||i!==void 0&&!i(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function bs(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(BA,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Xk=_r.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"){u0(t);return}u0(t.scheme,t.optionalSlashes)})},onDestroy(){LA()},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)=>!!bs(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 i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!bs(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=>!!bs(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",ct(this.options.HTMLAttributes,t),0]:["a",ct(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,i,s;const l=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"",u=e.renderChildren(t);return c?`[${u}](${l} "${c}")`:`[${u}](${l})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!bs(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=>!!bs(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[Ji({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Qk(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:l=>!!bs(l,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.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(FA({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!bs(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push($A({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(UA({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),HA=Xk;function WA(t={}){return new ut({view(e){return new VA(e,t)}})}class VA{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(i=>{let s=l=>{this[i](l)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}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,i=this.editorView.dom,s=i.getBoundingClientRect(),l=s.width/i.offsetWidth,c=s.height/i.offsetHeight;if(n){let h=e.nodeBefore,y=e.nodeAfter;if(h||y){let b=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(b){let x=b.getBoundingClientRect(),E=h?x.bottom:x.top;h&&y&&(E=(E+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*c;r={left:x.left,right:x.right,top:E-w,bottom:E+w}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;r={left:h.left-y,right:h.left+y,top:h.top,bottom:h.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,p;if(!u||u==document.body&&getComputedStyle(u).position=="static")f=-pageXOffset,p=-pageYOffset;else{let h=u.getBoundingClientRect(),y=h.width/u.offsetWidth,b=h.height/u.offsetHeight;f=h.left-u.scrollLeft*y,p=h.top-u.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),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let l=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=nx(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 Dt extends Ve{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Dt.valid(r)?new Dt(r):Ve.near(r)}content(){return xe.empty}eq(e){return e instanceof Dt&&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 Dt(e.resolve(n.pos))}getBookmark(){return new tm(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!KA(e)||!GA(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Dt.valid(e))return e;let i=e.pos,s=null;for(let l=e.depth;;l--){let c=e.node(l);if(n>0?e.indexAfter(l)<c.childCount:e.index(l)>0){s=c.child(n>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;i+=n;let u=e.doc.resolve(i);if(Dt.valid(u))return u}for(;;){let l=n>0?s.firstChild:s.lastChild;if(!l){if(s.isAtom&&!s.isText&&!Be.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=l,i+=n;let c=e.doc.resolve(i);if(Dt.valid(c))return c}return null}}}Dt.prototype.visible=!1;Dt.findFrom=Dt.findGapCursorFrom;Ve.jsonID("gapcursor",Dt);class tm{constructor(e){this.pos=e}map(e){return new tm(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Dt.valid(n)?new Dt(n):Ve.near(n)}}function Zk(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function KA(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 i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Zk(i.type))return!0;if(i.inlineContent)return!1}}return!0}function GA(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 i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Zk(i.type))return!0;if(i.inlineContent)return!1}}return!0}function qA(){return new ut({props:{decorations:XA,createSelectionBetween(t,e,n){return e.pos==n.pos&&Dt.valid(n)?new Dt(n):null},handleClick:YA,handleKeyDown:JA,handleDOMEvents:{beforeinput:QA}}})}const JA=Ah({ArrowLeft:gc("horiz",-1),ArrowRight:gc("horiz",1),ArrowUp:gc("vert",-1),ArrowDown:gc("vert",1)});function gc(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let l=r.selection,c=e>0?l.$to:l.$from,u=l.empty;if(l instanceof Fe){if(!s.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=Dt.findGapCursorFrom(c,e,u);return f?(i&&i(r.tr.setSelection(new Dt(f))),!0):!1}}function YA(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Dt.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Be.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Dt(r))),!0)}function QA(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Dt))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 i=re.empty;for(let l=r.length-1;l>=0;l--)i=re.from(r[l].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new xe(i,0,0));return s.setSelection(Fe.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function XA(t){if(!(t.selection instanceof Dt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",lt.create(t.doc,[vt.widget(t.selection.head,e,{key:"gapcursor"})])}var _u=200,on=function(){};on.prototype.append=function(e){return e.length?(e=on.from(e),!this.length&&e||e.length<_u&&this.leafAppend(e)||this.length<_u&&e.leafPrepend(this)||this.appendInner(e)):this};on.prototype.prepend=function(e){return e.length?on.from(e).append(this):this};on.prototype.appendInner=function(e){return new ZA(this,e)};on.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?on.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};on.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};on.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)};on.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,l){return i.push(e(s,l))},n,r),i};on.from=function(e){return e instanceof on?e:e&&e.length?new ew(e):on.empty};var ew=(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(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,l,c){for(var u=s;u<l;u++)if(i(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,l,c){for(var u=s-1;u>=l;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=_u)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=_u)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(on);on.empty=new ew([]);var ZA=(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,i,s,l){var c=this.left.length;if(i<c&&this.left.forEachInner(r,i,Math.min(s,c),l)===!1||s>c&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,s)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,l){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(s,c)-c,l+c)===!1||s<c&&this.left.forEachInvertedInner(r,Math.min(i,c),s,l)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,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})(on);const eO=500;class Sr{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 i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let l=e.tr,c,u,f=[],p=[];return this.items.forEach((h,y)=>{if(!h.step){i||(i=this.remapping(r,y+1),s=i.maps.length),s--,p.push(h);return}if(i){p.push(new Ur(h.map));let b=h.step.map(i.slice(s)),x;b&&l.maybeStep(b).doc&&(x=l.mapping.maps[l.mapping.maps.length-1],f.push(new Ur(x,void 0,void 0,f.length+p.length))),s--,x&&i.appendMap(x,s)}else l.maybeStep(h.step);if(h.selection)return c=i?h.selection.map(i.slice(s)):h.selection,u=new Sr(this.items.slice(0,r).append(p.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:l,selection:c}}addTransform(e,n,r,i){let s=[],l=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let p=0;p<e.steps.length;p++){let h=e.steps[p].invert(e.docs[p]),y=new Ur(e.mapping.maps[p],h,n),b;(b=u&&u.merge(y))&&(y=b,p?s.pop():c=c.slice(0,c.length-1)),s.push(y),n&&(l++,n=void 0),i||(u=y)}let f=l-r.depth;return f>nO&&(c=tO(c,f),l-=f),new Sr(c.append(s),l)}remapping(e,n){let r=new Ll;return this.items.forEach((i,s)=>{let l=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,l)},e,n),r}addMaps(e){return this.eventCount==0?this:new Sr(this.items.append(e.map(n=>new Ur(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},i);let u=n;this.items.forEach(y=>{let b=s.getMirror(--u);if(b==null)return;l=Math.min(l,b);let x=s.maps[b];if(y.step){let E=e.steps[b].invert(e.docs[b]),w=y.selection&&y.selection.map(s.slice(u+1,b));w&&c++,r.push(new Ur(x,E,w))}else r.push(new Ur(x))},i);let f=[];for(let y=n;y<l;y++)f.push(new Ur(s.maps[y]));let p=this.items.slice(0,i).append(f).append(r),h=new Sr(p,c);return h.emptyItemCount()>eO&&(h=h.compress(this.items.length-r.length)),h}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,i=[],s=0;return this.items.forEach((l,c)=>{if(c>=e)i.push(l),l.selection&&s++;else if(l.step){let u=l.step.map(n.slice(r)),f=u&&u.getMap();if(r--,f&&n.appendMap(f,r),u){let p=l.selection&&l.selection.map(n.slice(r));p&&s++;let h=new Ur(f.invert(),u,p),y,b=i.length-1;(y=i.length&&i[b].merge(h))?i[b]=y:i.push(h)}}else l.map&&r--},this.items.length,0),new Sr(on.from(i.reverse()),s)}}Sr.empty=new Sr(on.empty,0);function tO(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Ur{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}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 Di{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const nO=20;function rO(t,e,n,r){let i=n.getMeta(Ts),s;if(i)return i.historyState;n.getMeta(oO)&&(t=new Di(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Ts))return l.getMeta(Ts).redo?new Di(t.done.addTransform(n,void 0,r,Dc(e)),t.undone,d0(n.mapping.maps),t.prevTime,t.prevComposition):new Di(t.done,t.undone.addTransform(n,void 0,r,Dc(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!l&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!iO(n,t.prevRanges)),f=l?hp(t.prevRanges,n.mapping):d0(n.mapping.maps);return new Di(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Dc(e)),Sr.empty,f,n.time,c??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Di(t.done.rebased(n,s),t.undone.rebased(n,s),hp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Di(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),hp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function iO(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function d0(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,l)=>e.push(s,l));return e}function hp(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function sO(t,e,n){let r=Dc(e),i=Ts.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let l=s.selection.resolve(s.transform.doc),c=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new Di(n?c:s.remaining,n?s.remaining:c,null,0,-1);return s.transform.setSelection(l).setMeta(Ts,{redo:n,historyState:u})}let mp=!1,f0=null;function Dc(t){let e=t.plugins;if(f0!=e){mp=!1,f0=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){mp=!0;break}}return mp}const Ts=new mt("history"),oO=new mt("closeHistory");function lO(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new ut({key:Ts,state:{init(){return new Di(Sr.empty,Sr.empty,null,0,-1)},apply(e,n,r){return rO(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?nw:r=="historyRedo"?rw:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function tw(t,e){return(n,r)=>{let i=Ts.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=sO(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const nw=tw(!1,!0),rw=tw(!0,!0);st.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 ut({key:new mt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>i){const l=s-i,c=0,u=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,u);return t=!0,f}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=s-r,f=c-u,p=c;return e.deleteRange(f,p),!(this.storage.characters({node:e.doc})>r)}})]}});var aO=st.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[WA(this.options)]}});st.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new ut({key:new mt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return lt.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((u,f)=>{if(u.isText)return;if(!(i>=f&&i<=f+u.nodeSize-1))return!1;l+=1});let c=0;return t.descendants((u,f)=>{if(u.isText||!(i>=f&&i<=f+u.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&l-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";s.push(vt.node(f,f+u.nodeSize,{class:this.options.className}))}),lt.create(t,s)}}})]}});var cO=st.create({name:"gapCursor",addProseMirrorPlugins(){return[qA()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=at(Pe(t,"allowGapCursor",n)))!=null?e:null}}}),p0="placeholder";function uO(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var dO=st.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:p0,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${uO(this.options.dataAttribute)}`:`data-${p0}`;return[new ut({key:new mt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,s=[];if(!r)return null;const l=this.editor.isEmpty;return e.descendants((c,u)=>{const f=i>=u&&i<=u+c.nodeSize,p=!c.isLeaf&&Gu(c);if((f||!this.options.showOnlyCurrent)&&p){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const y=vt.node(u,u+c.nodeSize,{class:h.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:f}):this.options.placeholder});s.push(y)}return this.options.includeChildren}),lt.create(e,s)}}})]}});st.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new ut({key:new mt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||bk(n.selection)||t.view.dragging?null:lt.create(n.doc,[vt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function h0({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var fO=st.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new mt(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(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new ut({key:e,appendTransaction:(i,s,l)=>{const{doc:c,tr:u,schema:f}=l,p=e.getState(l),h=c.content.size,y=f.nodes[n];if(p)return u.insert(h,y.create())},state:{init:(i,s)=>{const l=s.tr.doc.lastChild;return!h0({node:l,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const l=i.doc.lastChild;return!h0({node:l,types:r})}}})]}}),pO=st.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>nw(t,e),redo:()=>({state:t,dispatch:e})=>rw(t,e)}},addProseMirrorPlugins(){return[lO(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()}}}),Yu=dO,hO=_r.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",ct(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()}}}),mO=hO,gO=_r.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",ct(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()}}}),yO=gO;let Zp,eh;if(typeof WeakMap<"u"){let t=new WeakMap;Zp=e=>t.get(e),eh=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Zp=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},eh=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Pt=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,i=e/this.width|0;let s=r+1,l=i+1;for(let c=1;s<this.width&&this.map[e+c]==n;c++)s++;for(let c=1;l<this.height&&this.map[e+this.width*c]==n;c++)l++;return{left:r,top:i,right:s,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:i,top:s,bottom:l}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[s*this.width+(n<0?r-1:i)]:(n<0?s==0:l==this.height)?null:this.map[r+this.width*(n<0?s-1:l)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:s}=this.findCell(t),{left:l,right:c,top:u,bottom:f}=this.findCell(e);return{left:Math.min(n,l),top:Math.min(i,u),right:Math.max(r,c),bottom:Math.max(s,f)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const s=r*this.width+i,l=this.map[s];n[l]||(n[l]=!0,!(i==t.left&&i&&this.map[s-1]==l||r==t.top&&r&&this.map[s-this.width]==l)&&e.push(l))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const s=i+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]<i;)l++;return l==c?s-1:this.map[l]}i=s}}static get(t){return Zp(t)||eh(t,bO(t))}};function bO(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=vO(t),n=t.childCount,r=[];let i=0,s=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 h=t.child(f);p++;for(let x=0;;x++){for(;i<r.length&&r[i]!=0;)i++;if(x==h.childCount)break;const E=h.child(x),{colspan:w,rowspan:S,colwidth:_}=E.attrs;for(let M=0;M<S;M++){if(M+f>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:p,n:S-M});break}const T=i+M*e;for(let O=0;O<w;O++){r[T+O]==0?r[T+O]=p:(s||(s=[])).push({type:"collision",row:f,pos:p,n:w-O});const P=_&&_[O];if(P){const B=(T+O)%e*2,Q=l[B];Q==null||Q!=P&&l[B+1]==1?(l[B]=P,l[B+1]=1):Q==P&&l[B+1]++}}}i+=w,p+=E.nodeSize}const y=(f+1)*e;let b=0;for(;i<y;)r[i++]==0&&b++;b&&(s||(s=[])).push({type:"missing",row:f,n:b}),p++}(e===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const c=new Pt(e,n,r,s);let u=!1;for(let f=0;!u&&f<l.length;f+=2)l[f]!=null&&l[f+1]<n&&(u=!0);return u&&xO(c,l,t),c}function vO(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let s=0;if(n)for(let l=0;l<r;l++){const c=t.child(l);for(let u=0;u<c.childCount;u++){const f=c.child(u);l+f.attrs.rowspan>r&&(s+=f.attrs.colspan)}}for(let l=0;l<i.childCount;l++){const c=i.child(l);s+=c.attrs.colspan,c.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function xO(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const s=t.map[i];if(r[s])continue;r[s]=!0;const l=n.nodeAt(s);if(!l)throw new RangeError(`No cell with offset ${s} found`);let c=null;const u=l.attrs;for(let f=0;f<u.colspan;f++){const p=e[(i+f)%t.width*2];p!=null&&(!u.colwidth||u.colwidth[f]!=p)&&((c||(c=kO(u)))[f]=p)}c&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:c})}}function kO(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function _n(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Bi=new mt("selectingCells");function Ls(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 wO(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 Tr(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 Qu(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=Ls(e.$head)||EO(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function EO(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 th(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function SO(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function nm(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function iw(t,e,n){const r=t.node(-1),i=Pt.get(r),s=t.start(-1),l=i.nextCell(t.pos-s,e,n);return l==null?null:t.node(0).resolve(s+l)}function Ds(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(i=>i>0)||(r.colwidth=null)),r}function sw(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function CO(t,e,n){const r=_n(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var xt=class si extends Ve{constructor(e,n=e){const r=e.node(-1),i=Pt.get(r),s=e.start(-1),l=i.rectBetween(e.pos-s,n.pos-s),c=e.node(0),u=i.cellsInRect(l).filter(p=>p!=n.pos-s);u.unshift(n.pos-s);const f=u.map(p=>{const h=r.nodeAt(p);if(!h)throw new RangeError(`No cell with offset ${p} found`);const y=s+p+1;return new lx(c.resolve(y),c.resolve(y+h.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)),i=e.resolve(n.map(this.$headCell.pos));if(th(r)&&th(i)&&nm(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?si.rowSelection(r,i):s&&this.isColSelection()?si.colSelection(r,i):new si(r,i)}return Fe.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Pt.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},l=[];for(let u=i.top;u<i.bottom;u++){const f=[];for(let p=u*n.width+i.left,h=i.left;h<i.right;h++,p++){const y=n.map[p];if(s[y])continue;s[y]=!0;const b=n.findCell(y);let x=e.nodeAt(y);if(!x)throw new RangeError(`No cell with offset ${y} found`);const E=i.left-b.left,w=b.right-i.right;if(E>0||w>0){let S=x.attrs;if(E>0&&(S=Ds(S,0,E)),w>0&&(S=Ds(S,S.colspan-w,w)),b.left<i.left){if(x=x.type.createAndFill(S),!x)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(S)}`)}else x=x.type.create(S,x.content)}if(b.top<i.top||b.bottom>i.bottom){const S={...x.attrs,rowspan:Math.min(b.bottom,i.bottom)-Math.max(b.top,i.top)};b.top<i.top?x=x.type.createAndFill(S):x=x.type.create(S,x.content)}f.push(x)}l.push(e.child(u).copy(re.from(f)))}const c=this.isColSelection()&&this.isRowSelection()?e:l;return new xe(re.from(c),1,1)}replace(e,n=xe.empty){const r=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){const{$from:c,$to:u}=i[l],f=e.mapping.slice(r);e.replace(f.map(c.pos),f.map(u.pos),l?xe.empty:n)}const s=Ve.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new xe(re.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Pt.get(n),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let l=0;l<s.length;l++)e(n.nodeAt(s[l]),i+s[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,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Pt.get(r),s=e.start(-1),l=i.findCell(e.pos-s),c=i.findCell(n.pos-s),u=e.node(0);return l.top<=c.top?(l.top>0&&(e=u.resolve(s+i.map[l.left])),c.bottom<i.height&&(n=u.resolve(s+i.map[i.width*(i.height-1)+c.right-1]))):(c.top>0&&(n=u.resolve(s+i.map[c.left])),l.bottom<i.height&&(e=u.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))),new si(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Pt.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const l=i+this.$anchorCell.nodeAfter.attrs.colspan,c=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,c)==n.width}eq(e){return e instanceof si&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Pt.get(r),s=e.start(-1),l=i.findCell(e.pos-s),c=i.findCell(n.pos-s),u=e.node(0);return l.left<=c.left?(l.left>0&&(e=u.resolve(s+i.map[l.top*i.width])),c.right<i.width&&(n=u.resolve(s+i.map[i.width*(c.top+1)-1]))):(c.left>0&&(n=u.resolve(s+i.map[c.top*i.width])),l.right<i.width&&(e=u.resolve(s+i.map[i.width*(l.top+1)-1]))),new si(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new si(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new si(e.resolve(n),e.resolve(r))}getBookmark(){return new NO(this.$anchorCell.pos,this.$headCell.pos)}};xt.prototype.visible=!1;Ve.jsonID("cell",xt);var NO=class ow{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ow(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&&nm(n,r)?new xt(n,r):Ve.near(r,1)}};function _O(t){if(!(t.selection instanceof xt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(vt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),lt.create(t.doc,e)}function TO({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function MO({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function AO(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,l;if(r instanceof Be&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")s=xt.create(i,r.from);else if(l=="row"){const c=i.resolve(r.from+1);s=xt.rowSelection(c,c)}else if(!n){const c=Pt.get(r.node),u=r.from+1,f=u+c.map[c.width*c.height-1];s=xt.create(i,u+1,f)}}else r instanceof Fe&&TO(r)?s=Fe.create(i,r.from):r instanceof Fe&&MO(r)&&(s=Fe.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const OO=new mt("fix-tables");function lw(t,e,n,r){const i=t.childCount,s=e.childCount;e:for(let l=0,c=0;l<s;l++){const u=e.child(l);for(let f=c,p=Math.min(i,l+3);f<p;f++)if(t.child(f)==u){c=f+1,n+=u.nodeSize;continue e}r(u,n),c<i&&t.child(c).sameMarkup(u)?lw(t.child(c),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function aw(t,e){let n;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(n=RO(t,i,s,n))};return e?e.doc!=t.doc&&lw(e.doc,t.doc,0,r):t.doc.descendants(r),n}function RO(t,e,n,r){const i=Pt.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let u=0;u<i.height;u++)s.push(0);for(let u=0;u<i.problems.length;u++){const f=i.problems[u];if(f.type=="collision"){const p=e.nodeAt(f.pos);if(!p)continue;const h=p.attrs;for(let y=0;y<h.rowspan;y++)s[f.row+y]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,Ds(h,h.colspan-f.n,f.n))}else if(f.type=="missing")s[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 u=0;u<s.length;u++)s[u]&&(l==null&&(l=u),c=u);for(let u=0,f=n+1;u<i.height;u++){const p=e.child(u),h=f+p.nodeSize,y=s[u];if(y>0){let b="cell";p.firstChild&&(b=p.firstChild.type.spec.tableRole);const x=[];for(let w=0;w<y;w++){const S=_n(t.schema)[b].createAndFill();S&&x.push(S)}const E=(u==0||l==u-1)&&c==u?f+1:h-1;r.insert(r.mapping.map(E),x)}f=h}return r.setMeta(OO,{fixTables:!0})}function Vr(t){const e=t.selection,n=Qu(t),r=n.node(-1),i=n.start(-1),s=Pt.get(r);return{...e instanceof xt?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:r}}function cw(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;CO(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let l=0;l<e.height;l++){const c=l*e.width+i;if(i>0&&i<e.width&&e.map[c-1]==e.map[c]){const u=e.map[c],f=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,sw(f.attrs,i-e.colCount(u))),l+=f.attrs.rowspan-1}else{const u=s==null?_n(r.type.schema).cell:r.nodeAt(e.map[c+s]).type,f=e.positionAt(l,i,r);t.insert(t.mapping.map(n+f),u.createAndFill())}}return t}function IO(t,e){if(!Tr(t))return!1;if(e){const n=Vr(t);e(cw(t.tr,n,n.left))}return!0}function LO(t,e){if(!Tr(t))return!1;if(e){const n=Vr(t);e(cw(t.tr,n,n.right))}return!0}function DO(t,{map:e,table:n,tableStart:r},i){const s=t.mapping.maps.length;for(let l=0;l<e.height;){const c=l*e.width+i,u=e.map[c],f=n.nodeAt(u),p=f.attrs;if(i>0&&e.map[c-1]==u||i<e.width-1&&e.map[c+1]==u)t.setNodeMarkup(t.mapping.slice(s).map(r+u),null,Ds(p,i-e.colCount(u)));else{const h=t.mapping.slice(s).map(r+u);t.delete(h,h+f.nodeSize)}l+=p.rowspan}}function PO(t,e){if(!Tr(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 i=n.right-1;DO(r,n,i),i!=n.left;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=Pt.get(s)}e(r)}return!0}function jO(t,e,n){var r;const i=_n(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((r=e.nodeAt(t.map[s+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function uw(t,{map:e,tableStart:n,table:r},i){let s=n;for(let f=0;f<i;f++)s+=r.child(f).nodeSize;const l=[];let c=i>0?-1:0;jO(e,r,i+c)&&(c=i==0||i==e.height?null:0);for(let f=0,p=e.width*i;f<e.width;f++,p++)if(i>0&&i<e.height&&e.map[p]==e.map[p-e.width]){const h=e.map[p],y=r.nodeAt(h).attrs;t.setNodeMarkup(n+h,null,{...y,rowspan:y.rowspan+1}),f+=y.colspan-1}else{var u;const h=c==null?_n(r.type.schema).cell:(u=r.nodeAt(e.map[p+c*e.width]))===null||u===void 0?void 0:u.type,y=h==null?void 0:h.createAndFill();y&&l.push(y)}return t.insert(s,_n(r.type.schema).row.create(null,l)),t}function BO(t,e){if(!Tr(t))return!1;if(e){const n=Vr(t);e(uw(t.tr,n,n.top))}return!0}function zO(t,e){if(!Tr(t))return!1;if(e){const n=Vr(t);e(uw(t.tr,n,n.bottom))}return!0}function FO(t,{map:e,table:n,tableStart:r},i){let s=0;for(let f=0;f<i;f++)s+=n.child(f).nodeSize;const l=s+n.child(i).nodeSize,c=t.mapping.maps.length;t.delete(s+r,l+r);const u=new Set;for(let f=0,p=i*e.width;f<e.width;f++,p++){const h=e.map[p];if(!u.has(h)){if(u.add(h),i>0&&h==e.map[p-e.width]){const y=n.nodeAt(h).attrs;t.setNodeMarkup(t.mapping.slice(c).map(h+r),null,{...y,rowspan:y.rowspan-1}),f+=y.colspan-1}else if(i<e.height&&h==e.map[p+e.width]){const y=n.nodeAt(h),b=y.attrs,x=y.type.create({...b,rowspan:y.attrs.rowspan-1},y.content),E=e.positionAt(i+1,f,n);t.insert(t.mapping.slice(c).map(r+E),x),f+=b.colspan-1}}}}function $O(t,e){if(!Tr(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 i=n.bottom-1;FO(r,n,i),i!=n.top;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=Pt.get(n.table)}e(r)}return!0}function m0(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function UO({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,l=(r.bottom-1)*t+r.left,c=i+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[c]==n[c+1])return!0;s+=t,c+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[l]==n[l+t])return!0;i++,l++}return!1}function g0(t,e){const n=t.selection;if(!(n instanceof xt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Vr(t),{map:i}=r;if(UO(i,r))return!1;if(e){const s=t.tr,l={};let c=re.empty,u,f;for(let p=r.top;p<r.bottom;p++)for(let h=r.left;h<r.right;h++){const y=i.map[p*i.width+h],b=r.table.nodeAt(y);if(!(l[y]||!b))if(l[y]=!0,u==null)u=y,f=b;else{m0(b)||(c=c.append(b.content));const x=s.mapping.map(y+r.tableStart);s.delete(x,x+b.nodeSize)}}if(u==null||f==null)return!0;if(s.setNodeMarkup(u+r.tableStart,null,{...sw(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),c.size>0){const p=u+1+f.content.size,h=m0(f)?u+1:p;s.replaceWith(h+r.tableStart,p+r.tableStart,c)}s.setSelection(new xt(s.doc.resolve(u+r.tableStart))),e(s)}return!0}function y0(t,e){const n=_n(t.schema);return HO(({node:r})=>n[r.type.spec.tableRole])(t,e)}function HO(t){return(e,n)=>{const r=e.selection;let i,s;if(r instanceof xt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var l;if(i=wO(r.$from),!i)return!1;s=(l=Ls(r.$from))===null||l===void 0?void 0:l.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let c=i.attrs;const u=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const p=Vr(e),h=e.tr;for(let b=0;b<p.right-p.left;b++)u.push(f?{...c,colwidth:f&&f[b]?[f[b]]:null}:c);let y;for(let b=p.top;b<p.bottom;b++){let x=p.map.positionAt(b,p.left,p.table);b==p.top&&(x+=i.nodeSize);for(let E=p.left,w=0;E<p.right;E++,w++)E==p.left&&b==p.top||h.insert(y=h.mapping.map(x+p.tableStart,1),t({node:i,row:b,col:E}).createAndFill(u[w]))}h.setNodeMarkup(s,t({node:i,row:p.top,col:p.left}),u[0]),r instanceof xt&&h.setSelection(new xt(h.doc.resolve(r.$anchorCell.pos),y?h.doc.resolve(y):void 0)),n(h)}return!0}}function WO(t,e){return function(n,r){if(!Tr(n))return!1;const i=Qu(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const s=n.tr;n.selection instanceof xt?n.selection.forEachCell((l,c)=>{l.attrs[t]!==e&&s.setNodeMarkup(c,null,{...l.attrs,[t]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function VO(t){return function(e,n){if(!Tr(e))return!1;if(n){const r=_n(e.schema),i=Vr(e),s=e.tr,l=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),c=l.map(u=>i.table.nodeAt(u));for(let u=0;u<l.length;u++)c[u].type==r.header_cell&&s.setNodeMarkup(i.tableStart+l[u],r.cell,c[u].attrs);if(s.steps.length===0)for(let u=0;u<l.length;u++)s.setNodeMarkup(i.tableStart+l[u],r.header_cell,c[u].attrs);n(s)}return!0}}function b0(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 i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function Hl(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?VO(t):function(n,r){if(!Tr(n))return!1;if(r){const i=_n(n.schema),s=Vr(n),l=n.tr,c=b0("row",s,i),u=b0("column",s,i),f=(t==="column"?c:t==="row"&&u)?1:0,p=t=="column"?{left:0,top:f,right:1,bottom:s.map.height}:t=="row"?{left:f,top:0,right:s.map.width,bottom:1}:s,h=t=="column"?u?i.cell:i.header_cell:t=="row"?c?i.cell:i.header_cell:i.cell;s.map.cellsInRect(p).forEach(y=>{const b=y+s.tableStart,x=l.doc.nodeAt(b);x&&l.setNodeMarkup(b,h,x.attrs)}),r(l)}return!0}}Hl("row",{useDeprecatedLogic:!0});Hl("column",{useDeprecatedLogic:!0});const KO=Hl("cell",{useDeprecatedLogic:!0});function GO(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const s=t.node(-1).child(r),l=s.lastChild;if(l)return i-1-l.nodeSize;i-=s.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),i=t.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function v0(t){return function(e,n){if(!Tr(e))return!1;const r=GO(Qu(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(Fe.between(i,SO(i))).scrollIntoView())}return!0}}function qO(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 yc(t,e){const n=t.selection;if(!(n instanceof xt))return!1;if(e){const r=t.tr,i=_n(t.schema).cell.createAndFill().content;n.forEachCell((s,l)=>{s.content.eq(i)||r.replace(r.mapping.map(l+1),r.mapping.map(l+s.nodeSize-1),new xe(i,0,0))}),r.docChanged&&e(r)}return!0}function JO(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 i=e.child(0),s=i.type.spec.tableRole,l=i.type.schema,c=[];if(s=="row")for(let u=0;u<e.childCount;u++){let f=e.child(u).content;const p=u?0:Math.max(0,n-1),h=u<e.childCount-1?0:Math.max(0,r-1);(p||h)&&(f=nh(_n(l).row,new xe(f,p,h)).content),c.push(f)}else if(s=="cell"||s=="header_cell")c.push(n||r?nh(_n(l).row,new xe(e,n,r)).content:e);else return null;return YO(l,c)}function YO(t,e){const n=[];for(let i=0;i<e.length;i++){const s=e[i];for(let l=s.childCount-1;l>=0;l--){const{rowspan:c,colspan:u}=s.child(l).attrs;for(let f=i;f<i+c;f++)n[f]=(n[f]||0)+u}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(re.empty),n[i]<r){const s=_n(t).cell.createAndFill(),l=[];for(let c=n[i];c<r;c++)l.push(s);e[i]=e[i].append(re.from(l))}return{height:e.length,width:r,rows:e}}function nh(t,e){const n=t.createAndFill();return new hh(n).replace(0,n.content.size,e).doc}function QO({width:t,height:e,rows:n},r,i){if(t!=r){const s=[],l=[];for(let c=0;c<n.length;c++){const u=n[c],f=[];for(let p=s[c]||0,h=0;p<r;h++){let y=u.child(h%u.childCount);p+y.attrs.colspan>r&&(y=y.type.createChecked(Ds(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++)s[c+b]=(s[c+b]||0)+y.attrs.colspan}l.push(re.from(f))}n=l,t=r}if(e!=i){const s=[];for(let l=0,c=0;l<i;l++,c++){const u=[],f=n[c%e];for(let p=0;p<f.childCount;p++){let h=f.child(p);l+h.attrs.rowspan>i&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,i-h.attrs.rowspan)},h.content)),u.push(h)}s.push(re.from(u))}n=s,e=i}return{width:t,height:e,rows:n}}function XO(t,e,n,r,i,s,l){const c=t.doc.type.schema,u=_n(c);let f,p;if(i>e.width)for(let h=0,y=0;h<e.height;h++){const b=n.child(h);y+=b.nodeSize;const x=[];let E;b.lastChild==null||b.lastChild.type==u.cell?E=f||(f=u.cell.createAndFill()):E=p||(p=u.header_cell.createAndFill());for(let w=e.width;w<i;w++)x.push(E);t.insert(t.mapping.slice(l).map(y-1+r),x)}if(s>e.height){const h=[];for(let x=0,E=(e.height-1)*e.width;x<Math.max(e.width,i);x++){const w=x>=e.width?!1:n.nodeAt(e.map[E+x]).type==u.header_cell;h.push(w?p||(p=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const y=u.row.create(null,re.from(h)),b=[];for(let x=e.height;x<s;x++)b.push(y);t.insert(t.mapping.slice(l).map(r+n.nodeSize-2),b)}return!!(f||p)}function x0(t,e,n,r,i,s,l,c){if(l==0||l==e.height)return!1;let u=!1;for(let f=i;f<s;f++){const p=l*e.width+f,h=e.map[p];if(e.map[p-e.width]==h){u=!0;const y=n.nodeAt(h),{top:b,left:x}=e.findCell(h);t.setNodeMarkup(t.mapping.slice(c).map(h+r),null,{...y.attrs,rowspan:l-b}),t.insert(t.mapping.slice(c).map(e.positionAt(l,x,n)),y.type.createAndFill({...y.attrs,rowspan:b+y.attrs.rowspan-l})),f+=y.attrs.colspan-1}}return u}function k0(t,e,n,r,i,s,l,c){if(l==0||l==e.width)return!1;let u=!1;for(let f=i;f<s;f++){const p=f*e.width+l,h=e.map[p];if(e.map[p-1]==h){u=!0;const y=n.nodeAt(h),b=e.colCount(h),x=t.mapping.slice(c).map(h+r);t.setNodeMarkup(x,null,Ds(y.attrs,l-b,y.attrs.colspan-(l-b))),t.insert(x+y.nodeSize,y.type.createAndFill(Ds(y.attrs,0,l-b))),f+=y.attrs.rowspan-1}}return u}function w0(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let l=Pt.get(s);const{top:c,left:u}=r,f=u+i.width,p=c+i.height,h=t.tr;let y=0;function b(){if(s=n?h.doc.nodeAt(n-1):h.doc,!s)throw new Error("No table found");l=Pt.get(s),y=h.mapping.maps.length}XO(h,l,s,n,f,p,y)&&b(),x0(h,l,s,n,u,f,c,y)&&b(),x0(h,l,s,n,u,f,p,y)&&b(),k0(h,l,s,n,c,p,u,y)&&b(),k0(h,l,s,n,c,p,f,y)&&b();for(let x=c;x<p;x++){const E=l.positionAt(x,u,s),w=l.positionAt(x,f,s);h.replace(h.mapping.slice(y).map(E+n),h.mapping.slice(y).map(w+n),new xe(i.rows[x-c],0,0))}b(),h.setSelection(new xt(h.doc.resolve(n+l.positionAt(c,u,s)),h.doc.resolve(n+l.positionAt(p-1,f-1,s)))),e(h)}const ZO=Ah({ArrowLeft:bc("horiz",-1),ArrowRight:bc("horiz",1),ArrowUp:bc("vert",-1),ArrowDown:bc("vert",1),"Shift-ArrowLeft":vc("horiz",-1),"Shift-ArrowRight":vc("horiz",1),"Shift-ArrowUp":vc("vert",-1),"Shift-ArrowDown":vc("vert",1),Backspace:yc,"Mod-Backspace":yc,Delete:yc,"Mod-Delete":yc});function Pc(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function bc(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof xt)return Pc(n,r,Ve.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const l=dw(i,t,e);if(l==null)return!1;if(t=="horiz")return Pc(n,r,Ve.near(n.doc.resolve(s.head+e),e));{const c=n.doc.resolve(l),u=iw(c,t,e);let f;return u?f=Ve.near(u,1):e<0?f=Ve.near(n.doc.resolve(c.before(-1)),-1):f=Ve.near(n.doc.resolve(c.after(-1)),1),Pc(n,r,f)}}}function vc(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let l;if(s instanceof xt)l=s;else{const u=dw(i,t,e);if(u==null)return!1;l=new xt(n.doc.resolve(u))}const c=iw(l.$headCell,t,e);return c?Pc(n,r,new xt(l.$anchorCell,c)):!1}}function eR(t,e){const n=t.state.doc,r=Ls(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new xt(r))),!0):!1}function tR(t,e,n){if(!Tr(t.state))return!1;let r=JO(n);const i=t.state.selection;if(i instanceof xt){r||(r={width:1,height:1,rows:[re.from(nh(_n(t.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),l=i.$anchorCell.start(-1),c=Pt.get(s).rectBetween(i.$anchorCell.pos-l,i.$headCell.pos-l);return r=QO(r,c.right-c.left,c.bottom-c.top),w0(t.state,t.dispatch,l,c,r),!0}else if(r){const s=Qu(t.state),l=s.start(-1);return w0(t.state,t.dispatch,l,Pt.get(s.node(-1)).findCell(s.pos-l),r),!0}else return!1}function nR(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=E0(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof xt)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ls(t.state.selection.$anchor))!=null&&((n=gp(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(u,f){let p=gp(t,f);const h=Bi.getState(t.state)==null;if(!p||!nm(u,p))if(h)p=u;else return;const y=new xt(u,p);if(h||!t.state.selection.eq(y)){const b=t.state.tr.setSelection(y);h&&b.setMeta(Bi,u.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",c),Bi.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Bi,-1))}function c(u){const f=u,p=Bi.getState(t.state);let h;if(p!=null)h=t.state.doc.resolve(p);else if(E0(t,f.target)!=r&&(h=gp(t,e),!h))return l();h&&s(h,f)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",c)}function dw(t,e,n){if(!(t.state.selection instanceof Fe))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(i),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}function E0(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function gp(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Ls(t.state.doc.resolve(r))||Ls(t.state.doc.resolve(i))}var rR=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")),rh(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,rh(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function rh(t,e,n,r,i,s){let l=0,c=!0,u=e.firstChild;const f=t.firstChild;if(f){for(let h=0,y=0;h<f.childCount;h++){const{colspan:b,colwidth:x}=f.child(h).attrs;for(let E=0;E<b;E++,y++){const w=i==y?s:x&&x[E],S=w?w+"px":"";if(l+=w||r,w||(c=!1),u)u.style.width!=S&&(u.style.width=S),u=u.nextSibling;else{const _=document.createElement("col");_.style.width=S,e.appendChild(_)}}}for(;u;){var p;const h=u.nextSibling;(p=u.parentNode)===null||p===void 0||p.removeChild(u),u=h}c?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}const Zn=new mt("tableColumnResizing");function iR({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=rR,lastColumnResizable:i=!0}={}){const s=new ut({key:Zn,state:{init(l,c){var u;const f=(u=s.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,p=_n(c.schema).table.name;return r&&f&&(f[p]=(h,y)=>new r(h,n,y)),new sR(-1,!1)},apply(l,c){return c.apply(l)}},props:{attributes:l=>{const c=Zn.getState(l);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,c)=>{oR(l,c,t,i)},mouseleave:l=>{lR(l)},mousedown:(l,c)=>{aR(l,c,e,n)}},decorations:l=>{const c=Zn.getState(l);if(c&&c.activeHandle>-1)return pR(l,c.activeHandle)},nodeViews:{}}});return s}var sR=class jc{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Zn);if(r&&r.setHandle!=null)return new jc(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new jc(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return th(e.doc.resolve(i))||(i=-1),new jc(i,n.dragging)}return n}};function oR(t,e,n,r){if(!t.editable)return;const i=Zn.getState(t.state);if(i&&!i.dragging){const s=uR(e.target);let l=-1;if(s){const{left:c,right:u}=s.getBoundingClientRect();e.clientX-c<=n?l=S0(t,e,"left",n):u-e.clientX<=n&&(l=S0(t,e,"right",n))}if(l!=i.activeHandle){if(!r&&l!==-1){const c=t.state.doc.resolve(l),u=c.node(-1),f=Pt.get(u),p=c.start(-1);if(f.colCount(c.pos-p)+c.nodeAfter.attrs.colspan-1==f.width-1)return}fw(t,l)}}}function lR(t){if(!t.editable)return;const e=Zn.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&fw(t,-1)}function aR(t,e,n,r){var i;if(!t.editable)return!1;const s=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,l=Zn.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const c=t.state.doc.nodeAt(l.activeHandle),u=cR(t,l.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Zn,{setDragging:{startX:e.clientX,startWidth:u}}));function f(h){s.removeEventListener("mouseup",f),s.removeEventListener("mousemove",p);const y=Zn.getState(t.state);y!=null&&y.dragging&&(dR(t,y.activeHandle,C0(y.dragging,h,n)),t.dispatch(t.state.tr.setMeta(Zn,{setDragging:null})))}function p(h){if(!h.which)return f(h);const y=Zn.getState(t.state);if(y&&y.dragging){const b=C0(y.dragging,h,n);N0(t,y.activeHandle,b,r)}}return N0(t,l.activeHandle,u,r),s.addEventListener("mouseup",f),s.addEventListener("mousemove",p),e.preventDefault(),!0}function cR(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,c=n;if(r)for(let u=0;u<n;u++)r[u]&&(l-=r[u],c--);return l/c}function uR(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function S0(t,e,n,r){const i=n=="right"?-r:r,s=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:l}=s,c=Ls(t.state.doc.resolve(l));if(!c)return-1;if(n=="right")return c.pos;const u=Pt.get(c.node(-1)),f=c.start(-1),p=u.map.indexOf(c.pos-f);return p%u.width==0?-1:f+u.map[p-1]}function C0(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function fw(t,e){t.dispatch(t.state.tr.setMeta(Zn,{setHandle:e}))}function dR(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),s=Pt.get(i),l=r.start(-1),c=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let f=0;f<s.height;f++){const p=f*s.width+c;if(f&&s.map[p]==s.map[p-s.width])continue;const h=s.map[p],y=i.nodeAt(h).attrs,b=y.colspan==1?0:c-s.colCount(h);if(y.colwidth&&y.colwidth[b]==n)continue;const x=y.colwidth?y.colwidth.slice():fR(y.colspan);x[b]=n,u.setNodeMarkup(l+h,null,{...y,colwidth:x})}u.docChanged&&t.dispatch(u)}function N0(t,e,n,r){const i=t.state.doc.resolve(e),s=i.node(-1),l=i.start(-1),c=Pt.get(s).colCount(i.pos-l)+i.nodeAfter.attrs.colspan-1;let u=t.domAtPos(i.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&rh(s,u.firstChild,u,r,c,n)}function fR(t){return Array(t).fill(0)}function pR(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return lt.empty;const s=Pt.get(i),l=r.start(-1),c=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<s.height;f++){const p=c+f*s.width;if((c==s.width-1||s.map[p]!=s.map[p+1])&&(f==0||s.map[p]!=s.map[p-s.width])){var u;const h=s.map[p],y=l+h+i.nodeAt(h).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((u=Zn.getState(t))===null||u===void 0)&&u.dragging&&n.push(vt.node(l+h,l+h+i.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),n.push(vt.widget(y,b))}}return lt.create(t.doc,n)}function hR({allowTableNodeSelection:t=!1}={}){return new ut({key:Bi,state:{init(){return null},apply(e,n){const r=e.getMeta(Bi);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:_O,handleDOMEvents:{mousedown:nR},createSelectionBetween(e){return Bi.getState(e.state)!=null?e.state.selection:null},handleTripleClick:eR,handleKeyDown:ZO,handlePaste:tR},appendTransaction(e,n,r){return AO(r,aw(r,n),t)}})}var pw=an.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"),i=r?r.split(",").map(s=>parseInt(s,10)):null;if(!i){const s=(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&&s&&s[l]){const c=s[l].getAttribute("width");return c?[parseInt(c,10)]:null}}return i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",ct(this.options.HTMLAttributes,t),0]}}),hw=an.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",ct(this.options.HTMLAttributes,t),0]}}),mw=an.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",ct(this.options.HTMLAttributes,t),0]}});function ih(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function _0(t,e,n,r,i,s){var l;let c=0,u=!0,f=e.firstChild;const p=t.firstChild;if(p!==null)for(let y=0,b=0;y<p.childCount;y+=1){const{colspan:x,colwidth:E}=p.child(y).attrs;for(let w=0;w<x;w+=1,b+=1){const S=i===b?s:E&&E[w],_=S?`${S}px`:"";if(c+=S||r,S||(u=!1),f){if(f.style.width!==_){const[M,T]=ih(r,S);f.style.setProperty(M,T)}f=f.nextSibling}else{const M=document.createElement("col"),[T,O]=ih(r,S);M.style.setProperty(T,O),e.appendChild(M)}}}for(;f;){const y=f.nextSibling;(l=f.parentNode)==null||l.removeChild(f),f=y}const h=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!h?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var mR=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")),_0(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,_0(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 gR(t,e,n,r){let i=0,s=!0;const l=[],c=t.firstChild;if(!c)return{};for(let h=0,y=0;h<c.childCount;h+=1){const{colspan:b,colwidth:x}=c.child(h).attrs;for(let E=0;E<b;E+=1,y+=1){const w=n===y?r:x&&x[E];i+=w||e,w||(s=!1);const[S,_]=ih(e,w);l.push(["col",{style:`${S}: ${_}`}])}}const u=s?`${i}px`:"",f=s?"":`${i}px`;return{colgroup:["colgroup",{},...l],tableWidth:u,tableMinWidth:f}}function T0(t,e){return t.createAndFill()}function yR(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 bR(t,e,n,r,i){const s=yR(t),l=[],c=[];for(let f=0;f<n;f+=1){const p=T0(s.cell);if(p&&c.push(p),r){const h=T0(s.header_cell);h&&l.push(h)}}const u=[];for(let f=0;f<e;f+=1)u.push(s.row.createChecked(null,r&&f===0?l:c));return s.table.createChecked(null,u)}function vR(t){return t instanceof xt}var xc=({editor:t})=>{const{selection:e}=t.state;if(!vR(e))return!1;let n=0;const r=dk(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},xR="";function kR(t){return(t||"").replace(/\s+/g," ").trim()}function wR(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:xR;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(x=>{const E=[];x.content&&x.content.forEach(w=>{let S="";w.content&&Array.isArray(w.content)&&w.content.length>1?S=w.content.map(O=>e.renderChildren(O)).join(i):S=w.content?e.renderChildren(w.content):"";const _=kR(S),M=w.type==="tableHeader";E.push({text:_,isHeader:M})}),s.push(E)});const l=s.reduce((x,E)=>Math.max(x,E.length),0);if(l===0)return"";const c=new Array(l).fill(0);s.forEach(x=>{var E;for(let w=0;w<l;w+=1){const _=(((E=x[w])==null?void 0:E.text)||"").length;_>c[w]&&(c[w]=_),c[w]<3&&(c[w]=3)}});const u=(x,E)=>x+" ".repeat(Math.max(0,E-x.length)),f=s[0],p=f.some(x=>x.isHeader);let h=`
|
|
160
|
+
`;const y=new Array(l).fill(0).map((x,E)=>p&&f[E]&&f[E].text||"");return h+=`| ${y.map((x,E)=>u(x,c[E])).join(" | ")} |
|
|
161
|
+
`,h+=`| ${c.map(x=>"-".repeat(Math.max(3,x))).join(" | ")} |
|
|
162
|
+
`,(p?s.slice(1):s).forEach(x=>{h+=`| ${new Array(l).fill(0).map((E,w)=>u(x[w]&&x[w].text||"",c[w])).join(" | ")} |
|
|
163
|
+
`}),h}var ER=wR,gw=an.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:mR,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:i}=gR(t,this.options.cellMinWidth),s=e.style;function l(){return s||(r?`width: ${r}`:`min-width: ${i}`)}const c=["table",ct(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(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(s=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>ER(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const l=bR(s.schema,t,e,n);if(i){const c=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection(Fe.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>IO(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>LO(t,e),deleteColumn:()=>({state:t,dispatch:e})=>PO(t,e),addRowBefore:()=>({state:t,dispatch:e})=>BO(t,e),addRowAfter:()=>({state:t,dispatch:e})=>zO(t,e),deleteRow:()=>({state:t,dispatch:e})=>$O(t,e),deleteTable:()=>({state:t,dispatch:e})=>qO(t,e),mergeCells:()=>({state:t,dispatch:e})=>g0(t,e),splitCell:()=>({state:t,dispatch:e})=>y0(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Hl("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Hl("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>KO(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>g0(t,e)?!0:y0(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>WO(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>v0(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>v0(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&aw(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=xt.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:xc,"Mod-Backspace":xc,Delete:xc,"Mod-Delete":xc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[iR({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],hR({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:at(Pe(t,"tableRole",e))}}});st.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(gw.configure(this.options.table)),this.options.tableCell!==!1&&t.push(pw.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(hw.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(mw.configure(this.options.tableRow)),t}});var SR=Object.defineProperty,CR=(t,e)=>{for(var n in e)SR(t,n,{get:e[n],enumerable:!0})},NR="listItem",M0="textStyle",A0=/^\s*([-+*])\s$/,yw=an.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",ct(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(NR,this.editor.getAttributes(M0)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=No({find:A0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=No({find:A0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(M0),editor:this.editor})),[t]}}),bw=an.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",ct(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(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.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)=>Uh(t,e,r=>{var i,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.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)}}}),_R={};CR(_R,{findListItemPos:()=>Jl,getNextListDepth:()=>rm,handleBackspace:()=>sh,handleDelete:()=>oh,hasListBefore:()=>vw,hasListItemAfter:()=>TR,hasListItemBefore:()=>xw,listItemHasSubList:()=>kw,nextListIsDeeper:()=>ww,nextListIsHigher:()=>Ew});var Jl=(t,e)=>{const{$from:n}=e.selection,r=qt(t,e.schema);let i=null,s=n.depth,l=n.pos,c=null;for(;s>0&&c===null;)i=n.node(s),i.type===r?c=s:(s-=1,l-=1);return c===null?null:{$pos:e.doc.resolve(l),depth:c}},rm=(t,e)=>{const n=Jl(t,e);if(!n)return!1;const[,r]=fT(e,t,n.$pos.pos+4);return r},vw=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},xw=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},kw=(t,e,n)=>{if(!n)return!1;const r=qt(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},sh=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!qi(t.state,e)&&vw(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),f=[];u.node().descendants((y,b)=>{y.type.name===e&&f.push({node:y,pos:b})});const p=f.at(-1);if(!p)return!1;const h=t.state.doc.resolve(u.start()+p.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},h.end()).joinForward().run()}if(!qi(t.state,e)||!gT(t.state))return!1;const r=Jl(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),l=kw(e,t.state,s);return xw(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},ww=(t,e)=>{const n=rm(t,e),r=Jl(t,e);return!r||!n?!1:n>r.depth},Ew=(t,e)=>{const n=rm(t,e),r=Jl(t,e);return!r||!n?!1:n<r.depth},oh=(t,e)=>{if(!qi(t.state,e)||!mT(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:ww(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Ew(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},TR=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},Sw=st.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&&oh(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&&oh(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&&sh(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&&sh(t,n,r)&&(e=!0)}),e}}}}),O0=/^(\s*)(\d+)\.\s+(.*)$/,MR=/^\s/;function AR(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(O0);if(!s)break;const[,l,c,u]=s,f=l.length;let p=u,h=n+1;const y=[i];for(;h<t.length;){const b=t[h];if(b.match(O0))break;if(b.trim()==="")y.push(b),p+=`
|
|
165
|
+
`,h+=1;else if(b.match(MR))y.push(b),p+=`
|
|
166
|
+
${b.slice(f+2)}`,h+=1;else break}e.push({indent:f,number:parseInt(c,10),content:p.trim(),raw:y.join(`
|
|
167
|
+
`)}),r=h,n=h}return[e,r]}function Cw(t,e,n){var r;const i=[];let s=0;for(;s<t.length;){const l=t[s];if(l.indent===e){const c=l.content.split(`
|
|
168
|
+
`),u=((r=c[0])==null?void 0:r.trim())||"",f=[];u&&f.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const p=c.slice(1).join(`
|
|
169
|
+
`).trim();if(p){const b=n.blockTokens(p);f.push(...b)}let h=s+1;const y=[];for(;h<t.length&&t[h].indent>e;)y.push(t[h]),h+=1;if(y.length>0){const b=Math.min(...y.map(E=>E.indent)),x=Cw(y,b,n);f.push({type:"list",ordered:!0,start:y[0].number,items:x,raw:y.map(E=>E.raw).join(`
|
|
170
|
+
`)})}i.push({type:"list_item",raw:l.raw,tokens:f}),s=h}else s+=1}return i}function OR(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(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var RR="listItem",R0="textStyle",I0=/^(\d+)\.\s$/,Nw=an.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",ct(this.options.HTMLAttributes,n),0]:["ol",ct(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?OR(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 i=t.split(`
|
|
172
|
+
`),[s,l]=AR(i);if(s.length===0)return;const c=Cw(s,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:c,raw:i.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(R0)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=No({find:I0,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=No({find:I0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(R0)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),IR=/^\s*(\[([( |x])?\])\s$/,_w=an.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",ct(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 i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Uh(t,e,i)},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 i=document.createElement("li"),s=document.createElement("label"),l=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),f=h=>{var y,b;c.ariaLabel=((b=(y=this.options.a11y)==null?void 0:y.checkboxLabel)==null?void 0:b.call(y,h,c.checked))||`Task item checkbox for ${h.textContent||"empty task item"}`};f(t),s.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",h=>h.preventDefault()),c.addEventListener("change",h=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:y}=h.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:b})=>{const x=n();if(typeof x!="number")return!1;const E=b.doc.nodeAt(x);return b.setNodeMarkup(x,void 0,{...E==null?void 0:E.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(([h,y])=>{i.setAttribute(h,y)}),i.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,s.append(c,l),i.append(s,u),Object.entries(e).forEach(([h,y])=>{i.setAttribute(h,y)});let p=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:h=>{if(h.type!==this.type)return!1;i.dataset.checked=h.attrs.checked,c.checked=h.attrs.checked,f(h);const y=r.extensionManager.attributes,b=Fl(h,y),x=new Set(Object.keys(b)),E=this.options.HTMLAttributes;return p.forEach(w=>{x.has(w)||(w in E?i.setAttribute(w,E[w]):i.removeAttribute(w))}),Object.entries(b).forEach(([w,S])=>{S==null?w in E?i.setAttribute(w,E[w]):i.removeAttribute(w):i.setAttribute(w,S)}),p=x,!0}}}},addInputRules(){return[No({find:IR,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Tw=an.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",ct(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=s=>{const l=Hp(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:r},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(s)},i=Hp(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,l)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:l}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.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()}}});st.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(yw.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(bw.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Sw.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Nw.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(_w.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Tw.configure(this.options.taskList)),t}});var LR=_w,DR=Tw,PR=20,Mw=(t,e=0)=>{const n=[];return!t.children.length||e>PR||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Mw(r,e+1))}),n},jR=t=>{if(!t.children.length)return;const e=Mw(t);e&&e.forEach(n=>{var r,i;const s=n.getAttribute("style"),l=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${l};${s}`)})},Aw=_r.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&jR(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",ct(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(i=>i.type===this.type).some(i=>Object.values(i.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),BR=st.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(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const l=s[0].trim().toLowerCase(),c=s.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()}}}),zR=st.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(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const s=r[i].split(":");if(s.length>=2){const l=s[0].trim().toLowerCase(),c=s.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()}}}),FR=st.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()}}}),$R=st.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()}}}),UR=st.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()}}});st.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(BR.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(zR.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(FR.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push($R.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(UR.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Aw.configure(this.options.textStyle)),t}});var HR=t=>jt({find:/--$/,replace:t??"—"}),WR=t=>jt({find:/\.\.\.$/,replace:t??"…"}),VR=t=>jt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),KR=t=>jt({find:/"$/,replace:t??"”"}),GR=t=>jt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),qR=t=>jt({find:/'$/,replace:t??"’"}),JR=t=>jt({find:/<-$/,replace:t??"←"}),YR=t=>jt({find:/->$/,replace:t??"→"}),QR=t=>jt({find:/\(c\)$/,replace:t??"©"}),XR=t=>jt({find:/\(tm\)$/,replace:t??"™"}),ZR=t=>jt({find:/\(sm\)$/,replace:t??"℠"}),eI=t=>jt({find:/\(r\)$/,replace:t??"®"}),tI=t=>jt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),nI=t=>jt({find:/\+\/-$/,replace:t??"±"}),rI=t=>jt({find:/!=$/,replace:t??"≠"}),iI=t=>jt({find:/<<$/,replace:t??"«"}),sI=t=>jt({find:/>>$/,replace:t??"»"}),oI=t=>jt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),lI=t=>jt({find:/\^2$/,replace:t??"²"}),aI=t=>jt({find:/\^3$/,replace:t??"³"}),cI=t=>jt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),uI=t=>jt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),dI=st.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(HR(this.options.emDash)),this.options.ellipsis!==!1&&t.push(WR(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(VR(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(KR(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(GR(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(qR(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(JR(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(YR(this.options.rightArrow)),this.options.copyright!==!1&&t.push(QR(this.options.copyright)),this.options.trademark!==!1&&t.push(XR(this.options.trademark)),this.options.servicemark!==!1&&t.push(ZR(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(eI(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(tI(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(nI(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(rI(this.options.notEqual)),this.options.laquo!==!1&&t.push(iI(this.options.laquo)),this.options.raquo!==!1&&t.push(sI(this.options.raquo)),this.options.multiplication!==!1&&t.push(oI(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(lI(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(aI(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(cI(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(uI(this.options.threeQuarters)),t}}),fI=dI,Ow=_r.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",ct(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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},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()}}}),pI=Ow,dn=[];for(var yp=0;yp<256;++yp)dn.push((yp+256).toString(16).slice(1));function hI(t,e=0){return(dn[t[e+0]]+dn[t[e+1]]+dn[t[e+2]]+dn[t[e+3]]+"-"+dn[t[e+4]]+dn[t[e+5]]+"-"+dn[t[e+6]]+dn[t[e+7]]+"-"+dn[t[e+8]]+dn[t[e+9]]+"-"+dn[t[e+10]]+dn[t[e+11]]+dn[t[e+12]]+dn[t[e+13]]+dn[t[e+14]]+dn[t[e+15]]).toLowerCase()}var kc,mI=new Uint8Array(16);function gI(){if(!kc&&(kc=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!kc))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return kc(mI)}var yI=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const L0={randomUUID:yI};function bI(t,e,n){if(L0.randomUUID&&!t)return L0.randomUUID();t=t||{};var r=t.random||(t.rng||gI)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,hI(r)}function vI(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 xI=st.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>bI(),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"),i=[e,n].filter(Boolean).find(c=>{var u;return(u=c==null?void 0:c.options)==null?void 0:u.provider}),s=(t=i==null?void 0:i.options)==null?void 0:t.provider,l=()=>{const{view:c,state:u}=this.editor,{tr:f,doc:p}=u,{types:h,attributeName:y,generateID:b}=this.options;Qc(p,E=>h.includes(E.type.name)&&E.attrs[y]===null).forEach(({node:E,pos:w})=>{f.setNodeMarkup(w,void 0,{...E.attrs,[y]:b({node:E,pos:w})})}),f.setMeta("addToHistory",!1),c.dispatch(f),s&&s.off("synced",l)};if(i){if(!s)return l();s.on("synced",l)}else return l()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new ut({key:new mt("uniqueID"),appendTransaction:(n,r,i)=>{const s=n.some(E=>E.docChanged)&&!r.doc.eq(i.doc),l=this.options.filterTransaction&&n.some(E=>{var w,S;return!((S=(w=this.options).filterTransaction)!=null&&S.call(w,E))});if(n.find(E=>E.getMeta("y-sync$"))||!s||l)return;const{tr:u}=i,{types:f,attributeName:p,generateID:h}=this.options,y=Lh(r.doc,n),{mapping:b}=y;if(jh(y).forEach(({newRange:E})=>{const w=uk(i.doc,E,_=>f.includes(_.type.name)),S=w.map(({node:_})=>_.attrs[p]).filter(_=>_!==null);w.forEach(({node:_,pos:M},T)=>{var O;const P=(O=u.doc.nodeAt(M))==null?void 0:O.attrs[p];if(P===null){u.setNodeMarkup(M,void 0,{..._.attrs,[p]:h({node:_,pos:M})});return}const B=w[T+1];if(B&&_.content.size===0){const fe=u.doc.nodeAt(B.pos);if(fe!=null&&fe.attrs[p]&&fe.attrs[p]!==P)return;u.setNodeMarkup(B.pos,void 0,{...B.node.attrs,[p]:P}),S[T+1]=P;const K=h({node:_,pos:M});return u.setNodeMarkup(M,void 0,{..._.attrs,[p]:K}),S[T]=K,u}const Q=vI(S),{deleted:X}=b.invert().mapResult(M);X&&Q.includes(P)&&u.setNodeMarkup(M,void 0,{..._.attrs,[p]:h({node:_,pos:M})})})}),!!u.steps.length)return u.setStoredMarks(i.tr.storedMarks),u.setMeta("__uniqueIDTransaction",!0),u},view(n){const r=i=>{var s;t=(s=n.dom.parentElement)!=null&&s.contains(i.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var i,s;return(t!==n.dom.parentElement||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copyMove"||((s=r.dataTransfer)==null?void 0:s.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:i}=this.options,s=l=>{const c=[];return l.forEach(u=>{if(u.isText){c.push(u);return}if(!r.includes(u.type.name)){c.push(u.copy(s(u.content)));return}const f=u.type.create({...u.attrs,[i]:null},s(u.content),u.marks);c.push(f)}),re.from(c)};return e=!1,new xe(s(n.content),n.openStart,n.openEnd)}}})]}}),im=xI,Tu=(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]},kI=/^\s*>\s$/,wI=an.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Tu("blockquote",{...ct(this.options.HTMLAttributes,t),children:Tu("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(i=>{const c=e.renderChildren([i]).split(`
|
|
175
|
+
`).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.join(`
|
|
176
|
+
`))}),r.join(`
|
|
177
|
+
${n}
|
|
178
|
+
`)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[No({find:kI,type:this.type})]}}),EI=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,SI=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,CI=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,NI=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_I=_r.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 Tu("strong",{...ct(this.options.HTMLAttributes,t),children:Tu("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[Is({find:EI,type:this.type}),Is({find:CI,type:this.type})]},addPasteRules(){return[Ji({find:SI,type:this.type}),Ji({find:NI,type:this.type})]}}),TI=/(^|[^`])`([^`]+)`(?!`)$/,MI=/(^|[^`])`([^`]+)`(?!`)/g,AI=_r.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",ct(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[Is({find:TI,type:this.type})]},addPasteRules(){return[Ji({find:MI,type:this.type})]}}),bp=4,OI=/^```([a-z]+)?[\s\n]$/,RI=/^~~~([a-z]+)?[\s\n]$/,Rw=an.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:bp,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 s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(l=>l.startsWith(n)).map(l=>l.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",ct(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 i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
|
|
179
|
+
`):r=`\`\`\`${i}
|
|
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:bp,{state:r}=t,{selection:i}=r,{$from:s,empty:l}=i;if(s.parent.type!==this.type)return!1;const c=" ".repeat(n);return l?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:f,to:p}=i,b=r.doc.textBetween(f,p,`
|
|
182
|
+
`,`
|
|
183
|
+
`).split(`
|
|
184
|
+
`).map(x=>c+x).join(`
|
|
185
|
+
`);return u.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:bp,{state:r}=t,{selection:i}=r,{$from:s,empty:l}=i;return s.parent.type!==this.type?!1:l?t.commands.command(({tr:c})=>{var u;const{pos:f}=s,p=s.start(),h=s.end(),b=r.doc.textBetween(p,h,`
|
|
186
|
+
`,`
|
|
187
|
+
`).split(`
|
|
188
|
+
`);let x=0,E=0;const w=f-p;for(let P=0;P<b.length;P+=1){if(E+b[P].length>=w){x=P;break}E+=b[P].length+1}const _=((u=b[x].match(/^ */))==null?void 0:u[0])||"",M=Math.min(_.length,n);if(M===0)return!0;let T=p;for(let P=0;P<x;P+=1)T+=b[P].length+1;return c.delete(T,T+M),f-T<=M&&c.setSelection(Fe.create(c.doc,T)),!0}):t.commands.command(({tr:c})=>{const{from:u,to:f}=i,y=r.doc.textBetween(u,f,`
|
|
189
|
+
`,`
|
|
190
|
+
`).split(`
|
|
191
|
+
`).map(b=>{var x;const E=((x=b.match(/^ */))==null?void 0:x[0])||"",w=Math.min(E.length,n);return b.slice(w)}).join(`
|
|
192
|
+
`);return c.replaceWith(u,f,r.schema.text(y)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,l=r.parent.textContent.endsWith(`
|
|
193
|
+
|
|
194
|
+
`);return!s||!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:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:f})=>(f.setSelection(Ve.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Up({find:OI,type:this.type,getAttributes:t=>({language:t[1]})}),Up({find:RI,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new ut({key:new mt("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"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!n||!s)return!1;const{tr:l,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,`
|
|
195
|
+
`));return l.replaceSelectionWith(this.type.create({language:s},u)),l.selection.$from.parent.type!==this.type&&l.setSelection(Fe.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),II=Rw,LI=an.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
196
|
+
|
|
197
|
+
`):""}),DI=an.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",ct(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:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:c}=r.extensionManager,u=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:p})=>{if(p&&u&&l){const h=u.filter(y=>c.includes(y.type.name));f.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),PI=an.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]}`,ct(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,i="#".repeat(r);return t.content?`${i} ${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=>Up({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),jI=an.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",ct(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!rM(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return bk(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:l,dispatch:c})=>{if(c){const{$to:u}=l.selection,f=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(Fe.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Be.create(l.doc,u.pos)):l.setSelection(Fe.create(l.doc,u.pos));else{const p=s.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,h=p==null?void 0:p.create();h&&(l.insert(f,h),l.setSelection(Fe.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Dk({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),BI=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zI=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,FI=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$I=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,UI=_r.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",ct(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[Is({find:BI,type:this.type}),Is({find:FI,type:this.type})]},addPasteRules(){return[Ji({find:zI,type:this.type}),Ji({find:$I,type:this.type})]}}),D0=" ",HI=" ",WI=an.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",ct(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===D0||r[0].text===HI)?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?D0:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),VI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,KI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,GI=_r.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",ct(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[Is({find:VI,type:this.type})]},addPasteRules(){return[Ji({find:KI,type:this.type})]}}),qI=an.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),JI=st.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(_I.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(wI.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(yw.configure(this.options.bulletList)),this.options.code!==!1&&i.push(AI.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(Rw.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(LI.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(aO.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(cO.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(DI.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(PI.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(pO.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(jI.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(UI.configure(this.options.italic)),this.options.listItem!==!1&&i.push(bw.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Sw.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Xk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Nw.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(WI.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(GI.configure(this.options.strike)),this.options.text!==!1&&i.push(qI.configure(this.options.text)),this.options.underline!==!1&&i.push(Ow.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(fO.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),sm=JI,vp,P0;function YI(){if(P0)return vp;P0=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(te=>{const ve=I[te],Ge=typeof ve;(Ge==="object"||Ge==="function")&&!Object.isFrozen(ve)&&t(ve)}),I}class e{constructor(te){te.data===void 0&&(te.data={}),this.data=te.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,...te){const ve=Object.create(null);for(const Ge in I)ve[Ge]=I[Ge];return te.forEach(function(Ge){for(const wt in Ge)ve[wt]=Ge[wt]}),ve}const i="</span>",s=I=>!!I.scope,l=(I,{prefix:te})=>{if(I.startsWith("language:"))return I.replace("language:","language-");if(I.includes(".")){const ve=I.split(".");return[`${te}${ve.shift()}`,...ve.map((Ge,wt)=>`${Ge}${"_".repeat(wt+1)}`)].join(" ")}return`${te}${I}`};class c{constructor(te,ve){this.buffer="",this.classPrefix=ve.classPrefix,te.walk(this)}addText(te){this.buffer+=n(te)}openNode(te){if(!s(te))return;const ve=l(te.scope,{prefix:this.classPrefix});this.span(ve)}closeNode(te){s(te)&&(this.buffer+=i)}value(){return this.buffer}span(te){this.buffer+=`<span class="${te}">`}}const u=(I={})=>{const te={children:[]};return Object.assign(te,I),te};class f{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(te){this.top.children.push(te)}openNode(te){const ve=u({scope:te});this.add(ve),this.stack.push(ve)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(te){return this.constructor._walk(te,this.rootNode)}static _walk(te,ve){return typeof ve=="string"?te.addText(ve):ve.children&&(te.openNode(ve),ve.children.forEach(Ge=>this._walk(te,Ge)),te.closeNode(ve)),te}static _collapse(te){typeof te!="string"&&te.children&&(te.children.every(ve=>typeof ve=="string")?te.children=[te.children.join("")]:te.children.forEach(ve=>{f._collapse(ve)}))}}class p extends f{constructor(te){super(),this.options=te}addText(te){te!==""&&this.add(te)}startScope(te){this.openNode(te)}endScope(){this.closeNode()}__addSublanguage(te,ve){const Ge=te.root;ve&&(Ge.scope=`language:${ve}`),this.add(Ge)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function h(I){return I?typeof I=="string"?I:I.source:null}function y(I){return E("(?=",I,")")}function b(I){return E("(?:",I,")*")}function x(I){return E("(?:",I,")?")}function E(...I){return I.map(ve=>h(ve)).join("")}function w(I){const te=I[I.length-1];return typeof te=="object"&&te.constructor===Object?(I.splice(I.length-1,1),te):{}}function S(...I){return"("+(w(I).capture?"":"?:")+I.map(Ge=>h(Ge)).join("|")+")"}function _(I){return new RegExp(I.toString()+"|").exec("").length-1}function M(I,te){const ve=I&&I.exec(te);return ve&&ve.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function O(I,{joinWith:te}){let ve=0;return I.map(Ge=>{ve+=1;const wt=ve;let Nt=h(Ge),Ne="";for(;Nt.length>0;){const Ce=T.exec(Nt);if(!Ce){Ne+=Nt;break}Ne+=Nt.substring(0,Ce.index),Nt=Nt.substring(Ce.index+Ce[0].length),Ce[0][0]==="\\"&&Ce[1]?Ne+="\\"+String(Number(Ce[1])+wt):(Ne+=Ce[0],Ce[0]==="("&&ve++)}return Ne}).map(Ge=>`(${Ge})`).join(te)}const P=/\b\B/,B="[a-zA-Z]\\w*",Q="[a-zA-Z_]\\w*",X="\\b\\d+(\\.\\d+)?",J="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",fe="\\b(0b[01]+)",K="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",W=(I={})=>{const te=/^#![ ]*\//;return I.binary&&(I.begin=E(te,/.*\b/,I.binary,/\b.*/)),r({scope:"meta",begin:te,end:/$/,relevance:0,"on:begin":(ve,Ge)=>{ve.index!==0&&Ge.ignoreMatch()}},I)},$={begin:"\\\\[\\s\\S]",relevance:0},Z={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[$]},ee={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[$]},he={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/},G=function(I,te,ve={}){const Ge=r({scope:"comment",begin:I,end:te,contains:[]},ve);Ge.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 wt=S("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 Ge.contains.push({begin:E(/[ ]+/,"(",wt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ge},se=G("//","$"),ie=G("/\\*","\\*/"),R=G("#","$"),j={scope:"number",begin:X,relevance:0},le={scope:"number",begin:J,relevance:0},ye={scope:"number",begin:fe,relevance:0},Ee={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[$,{begin:/\[/,end:/\]/,relevance:0,contains:[$]}]},oe={scope:"title",begin:B,relevance:0},z={scope:"title",begin:Q,relevance:0},q={begin:"\\.\\s*"+Q,relevance:0};var ne=Object.freeze({__proto__:null,APOS_STRING_MODE:Z,BACKSLASH_ESCAPE:$,BINARY_NUMBER_MODE:ye,BINARY_NUMBER_RE:fe,COMMENT:G,C_BLOCK_COMMENT_MODE:ie,C_LINE_COMMENT_MODE:se,C_NUMBER_MODE:le,C_NUMBER_RE:J,END_SAME_AS_BEGIN:function(I){return Object.assign(I,{"on:begin":(te,ve)=>{ve.data._beginMatch=te[1]},"on:end":(te,ve)=>{ve.data._beginMatch!==te[1]&&ve.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:B,MATCH_NOTHING_RE:P,METHOD_GUARD:q,NUMBER_MODE:j,NUMBER_RE:X,PHRASAL_WORDS_MODE:he,QUOTE_STRING_MODE:ee,REGEXP_MODE:Ee,RE_STARTERS_RE:K,SHEBANG:W,TITLE_MODE:oe,UNDERSCORE_IDENT_RE:Q,UNDERSCORE_TITLE_MODE:z});function Me(I,te){I.input[I.index-1]==="."&&te.ignoreMatch()}function H(I,te){I.className!==void 0&&(I.scope=I.className,delete I.className)}function ke(I,te){te&&I.beginKeywords&&(I.begin="\\b("+I.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",I.__beforeBegin=Me,I.keywords=I.keywords||I.beginKeywords,delete I.beginKeywords,I.relevance===void 0&&(I.relevance=0))}function we(I,te){Array.isArray(I.illegal)&&(I.illegal=S(...I.illegal))}function $e(I,te){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 Ae(I,te){I.relevance===void 0&&(I.relevance=1)}const je=(I,te)=>{if(!I.beforeMatch)return;if(I.starts)throw new Error("beforeMatch cannot be used with starts");const ve=Object.assign({},I);Object.keys(I).forEach(Ge=>{delete I[Ge]}),I.keywords=ve.keywords,I.begin=E(ve.beforeMatch,y(ve.begin)),I.starts={relevance:0,contains:[Object.assign(ve,{endsParent:!0})]},I.relevance=0,delete ve.beforeMatch},ze=["of","and","for","in","not","or","if","then","parent","list","value"],yn="keyword";function tt(I,te,ve=yn){const Ge=Object.create(null);return typeof I=="string"?wt(ve,I.split(" ")):Array.isArray(I)?wt(ve,I):Object.keys(I).forEach(function(Nt){Object.assign(Ge,tt(I[Nt],te,Nt))}),Ge;function wt(Nt,Ne){te&&(Ne=Ne.map(Ce=>Ce.toLowerCase())),Ne.forEach(function(Ce){const Ue=Ce.split("|");Ge[Ue[0]]=[Nt,gt(Ue[0],Ue[1])]})}}function gt(I,te){return te?Number(te):et(I)?0:1}function et(I){return ze.includes(I.toLowerCase())}const Vn={},Jt=I=>{console.error(I)},tr=(I,...te)=>{console.log(`WARN: ${I}`,...te)},Xt=(I,te)=>{Vn[`${I}/${te}`]||(console.log(`Deprecated as of ${I}. ${te}`),Vn[`${I}/${te}`]=!0)},bn=new Error;function Kn(I,te,{key:ve}){let Ge=0;const wt=I[ve],Nt={},Ne={};for(let Ce=1;Ce<=te.length;Ce++)Ne[Ce+Ge]=wt[Ce],Nt[Ce+Ge]=!0,Ge+=_(te[Ce-1]);I[ve]=Ne,I[ve]._emit=Nt,I[ve]._multi=!0}function Mr(I){if(Array.isArray(I.begin)){if(I.skip||I.excludeBegin||I.returnBegin)throw Jt("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),bn;if(typeof I.beginScope!="object"||I.beginScope===null)throw Jt("beginScope must be object"),bn;Kn(I,I.begin,{key:"beginScope"}),I.begin=O(I.begin,{joinWith:""})}}function nr(I){if(Array.isArray(I.end)){if(I.skip||I.excludeEnd||I.returnEnd)throw Jt("skip, excludeEnd, returnEnd not compatible with endScope: {}"),bn;if(typeof I.endScope!="object"||I.endScope===null)throw Jt("endScope must be object"),bn;Kn(I,I.end,{key:"endScope"}),I.end=O(I.end,{joinWith:""})}}function Gn(I){I.scope&&typeof I.scope=="object"&&I.scope!==null&&(I.beginScope=I.scope,delete I.scope)}function Ar(I){Gn(I),typeof I.beginScope=="string"&&(I.beginScope={_wrap:I.beginScope}),typeof I.endScope=="string"&&(I.endScope={_wrap:I.endScope}),Mr(I),nr(I)}function gr(I){function te(Ne,Ce){return new RegExp(h(Ne),"m"+(I.case_insensitive?"i":"")+(I.unicodeRegex?"u":"")+(Ce?"g":""))}class ve{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ce,Ue){Ue.position=this.position++,this.matchIndexes[this.matchAt]=Ue,this.regexes.push([Ue,Ce]),this.matchAt+=_(Ce)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ce=this.regexes.map(Ue=>Ue[1]);this.matcherRe=te(O(Ce,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ce){this.matcherRe.lastIndex=this.lastIndex;const Ue=this.matcherRe.exec(Ce);if(!Ue)return null;const Wt=Ue.findIndex((Or,di)=>di>0&&Or!==void 0),yt=this.matchIndexes[Wt];return Ue.splice(0,Wt),Object.assign(Ue,yt)}}class Ge{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ce){if(this.multiRegexes[Ce])return this.multiRegexes[Ce];const Ue=new ve;return this.rules.slice(Ce).forEach(([Wt,yt])=>Ue.addRule(Wt,yt)),Ue.compile(),this.multiRegexes[Ce]=Ue,Ue}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ce,Ue){this.rules.push([Ce,Ue]),Ue.type==="begin"&&this.count++}exec(Ce){const Ue=this.getMatcher(this.regexIndex);Ue.lastIndex=this.lastIndex;let Wt=Ue.exec(Ce);if(this.resumingScanAtSamePosition()&&!(Wt&&Wt.index===this.lastIndex)){const yt=this.getMatcher(0);yt.lastIndex=this.lastIndex+1,Wt=yt.exec(Ce)}return Wt&&(this.regexIndex+=Wt.position+1,this.regexIndex===this.count&&this.considerAll()),Wt}}function wt(Ne){const Ce=new Ge;return Ne.contains.forEach(Ue=>Ce.addRule(Ue.begin,{rule:Ue,type:"begin"})),Ne.terminatorEnd&&Ce.addRule(Ne.terminatorEnd,{type:"end"}),Ne.illegal&&Ce.addRule(Ne.illegal,{type:"illegal"}),Ce}function Nt(Ne,Ce){const Ue=Ne;if(Ne.isCompiled)return Ue;[H,$e,Ar,je].forEach(yt=>yt(Ne,Ce)),I.compilerExtensions.forEach(yt=>yt(Ne,Ce)),Ne.__beforeBegin=null,[ke,we,Ae].forEach(yt=>yt(Ne,Ce)),Ne.isCompiled=!0;let Wt=null;return typeof Ne.keywords=="object"&&Ne.keywords.$pattern&&(Ne.keywords=Object.assign({},Ne.keywords),Wt=Ne.keywords.$pattern,delete Ne.keywords.$pattern),Wt=Wt||/\w+/,Ne.keywords&&(Ne.keywords=tt(Ne.keywords,I.case_insensitive)),Ue.keywordPatternRe=te(Wt,!0),Ce&&(Ne.begin||(Ne.begin=/\B|\b/),Ue.beginRe=te(Ue.begin),!Ne.end&&!Ne.endsWithParent&&(Ne.end=/\B|\b/),Ne.end&&(Ue.endRe=te(Ue.end)),Ue.terminatorEnd=h(Ue.end)||"",Ne.endsWithParent&&Ce.terminatorEnd&&(Ue.terminatorEnd+=(Ne.end?"|":"")+Ce.terminatorEnd)),Ne.illegal&&(Ue.illegalRe=te(Ne.illegal)),Ne.contains||(Ne.contains=[]),Ne.contains=[].concat(...Ne.contains.map(function(yt){return ae(yt==="self"?Ne:yt)})),Ne.contains.forEach(function(yt){Nt(yt,Ue)}),Ne.starts&&Nt(Ne.starts,Ce),Ue.matcher=wt(Ue),Ue}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||{}),Nt(I)}function Pn(I){return I?I.endsWithParent||Pn(I.starts):!1}function ae(I){return I.variants&&!I.cachedVariants&&(I.cachedVariants=I.variants.map(function(te){return r(I,{variants:null},te)})),I.cachedVariants?I.cachedVariants:Pn(I)?r(I,{starts:I.starts?r(I.starts):null}):Object.isFrozen(I)?r(I):I}var Le="11.11.1";class ft extends Error{constructor(te,ve){super(te),this.name="HTMLInjectionError",this.html=ve}}const Bt=n,Ut=r,kt=Symbol("nomatch"),vn=7,xn=function(I){const te=Object.create(null),ve=Object.create(null),Ge=[];let wt=!0;const Nt="Could not find the language '{}', did you forget to load/include a language module?",Ne={disableAutodetect:!0,name:"Plain text",contains:[]};let Ce={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ue(me){return Ce.noHighlightRe.test(me)}function Wt(me){let De=me.className+" ";De+=me.parentNode?me.parentNode.className:"";const Ye=Ce.languageDetectRe.exec(De);if(Ye){const Ze=yr(Ye[1]);return Ze||(tr(Nt.replace("{}",Ye[1])),tr("Falling back to no-highlight mode for this block.",me)),Ze?Ye[1]:"no-highlight"}return De.split(/\s+/).find(Ze=>Ue(Ze)||yr(Ze))}function yt(me,De,Ye){let Ze="",zt="";typeof De=="object"?(Ze=me,Ye=De.ignoreIllegals,zt=De.language):(Xt("10.7.0","highlight(lang, code, ...args) has been deprecated."),Xt("10.7.0",`Please use highlight(code, options) instead.
|
|
200
|
+
https://github.com/highlightjs/highlight.js/issues/2277`),zt=me,Ze=De),Ye===void 0&&(Ye=!0);const Mt={code:Ze,language:zt};es("before:highlight",Mt);const Rr=Mt.result?Mt.result:Or(Mt.language,Mt.code,Ye);return Rr.code=Mt.code,es("after:highlight",Rr),Rr}function Or(me,De,Ye,Ze){const zt=Object.create(null);function Mt(be,_e){return be.keywords[_e]}function Rr(){if(!Je.keywords){Ft.addText(dt);return}let be=0;Je.keywordPatternRe.lastIndex=0;let _e=Je.keywordPatternRe.exec(dt),Ke="";for(;_e;){Ke+=dt.substring(be,_e.index);const nt=rr.case_insensitive?_e[0].toLowerCase():_e[0],Rt=Mt(Je,nt);if(Rt){const[Zt,sd]=Rt;if(Ft.addText(Ke),Ke="",zt[nt]=(zt[nt]||0)+1,zt[nt]<=vn&&(rs+=sd),Zt.startsWith("_"))Ke+=_e[0];else{const ra=rr.classNameAliases[Zt]||Zt;An(_e[0],ra)}}else Ke+=_e[0];be=Je.keywordPatternRe.lastIndex,_e=Je.keywordPatternRe.exec(dt)}Ke+=dt.substring(be),Ft.addText(Ke)}function Fs(){if(dt==="")return;let be=null;if(typeof Je.subLanguage=="string"){if(!te[Je.subLanguage]){Ft.addText(dt);return}be=Or(Je.subLanguage,dt,!0,Lo[Je.subLanguage]),Lo[Je.subLanguage]=be._top}else be=Zi(dt,Je.subLanguage.length?Je.subLanguage:null);Je.relevance>0&&(rs+=be.relevance),Ft.__addSublanguage(be._emitter,be.language)}function Mn(){Je.subLanguage!=null?Fs():Rr(),dt=""}function An(be,_e){be!==""&&(Ft.startScope(_e),Ft.addText(be),Ft.endScope())}function ts(be,_e){let Ke=1;const nt=_e.length-1;for(;Ke<=nt;){if(!be._emit[Ke]){Ke++;continue}const Rt=rr.classNameAliases[be[Ke]]||be[Ke],Zt=_e[Ke];Rt?An(Zt,Rt):(dt=Zt,Rr(),dt=""),Ke++}}function fi(be,_e){return be.scope&&typeof be.scope=="string"&&Ft.openNode(rr.classNameAliases[be.scope]||be.scope),be.beginScope&&(be.beginScope._wrap?(An(dt,rr.classNameAliases[be.beginScope._wrap]||be.beginScope._wrap),dt=""):be.beginScope._multi&&(ts(be.beginScope,_e),dt="")),Je=Object.create(be,{parent:{value:Je}}),Je}function ns(be,_e,Ke){let nt=M(be.endRe,Ke);if(nt){if(be["on:end"]){const Rt=new e(be);be["on:end"](_e,Rt),Rt.isMatchIgnored&&(nt=!1)}if(nt){for(;be.endsParent&&be.parent;)be=be.parent;return be}}if(be.endsWithParent)return ns(be.parent,_e,Ke)}function rd(be){return Je.matcher.regexIndex===0?(dt+=be[0],1):(mi=!0,0)}function id(be){const _e=be[0],Ke=be.rule,nt=new e(Ke),Rt=[Ke.__beforeBegin,Ke["on:begin"]];for(const Zt of Rt)if(Zt&&(Zt(be,nt),nt.isMatchIgnored))return rd(_e);return Ke.skip?dt+=_e:(Ke.excludeBegin&&(dt+=_e),Mn(),!Ke.returnBegin&&!Ke.excludeBegin&&(dt=_e)),fi(Ke,be),Ke.returnBegin?0:_e.length}function Ro(be){const _e=be[0],Ke=De.substring(be.index),nt=ns(Je,be,Ke);if(!nt)return kt;const Rt=Je;Je.endScope&&Je.endScope._wrap?(Mn(),An(_e,Je.endScope._wrap)):Je.endScope&&Je.endScope._multi?(Mn(),ts(Je.endScope,be)):Rt.skip?dt+=_e:(Rt.returnEnd||Rt.excludeEnd||(dt+=_e),Mn(),Rt.excludeEnd&&(dt=_e));do Je.scope&&Ft.closeNode(),!Je.skip&&!Je.subLanguage&&(rs+=Je.relevance),Je=Je.parent;while(Je!==nt.parent);return nt.starts&&fi(nt.starts,be),Rt.returnEnd?0:_e.length}function na(){const be=[];for(let _e=Je;_e!==rr;_e=_e.parent)_e.scope&&be.unshift(_e.scope);be.forEach(_e=>Ft.openNode(_e))}let pi={};function hi(be,_e){const Ke=_e&&_e[0];if(dt+=be,Ke==null)return Mn(),0;if(pi.type==="begin"&&_e.type==="end"&&pi.index===_e.index&&Ke===""){if(dt+=De.slice(_e.index,_e.index+1),!wt){const nt=new Error(`0 width match regex (${me})`);throw nt.languageName=me,nt.badRule=pi.rule,nt}return 1}if(pi=_e,_e.type==="begin")return id(_e);if(_e.type==="illegal"&&!Ye){const nt=new Error('Illegal lexeme "'+Ke+'" for mode "'+(Je.scope||"<unnamed>")+'"');throw nt.mode=Je,nt}else if(_e.type==="end"){const nt=Ro(_e);if(nt!==kt)return nt}if(_e.type==="illegal"&&Ke==="")return dt+=`
|
|
201
|
+
`,1;if(is>1e5&&is>_e.index*3)throw new Error("potential infinite loop, way more iterations than matches");return dt+=Ke,Ke.length}const rr=yr(me);if(!rr)throw Jt(Nt.replace("{}",me)),new Error('Unknown language: "'+me+'"');const Io=gr(rr);let rt="",Je=Ze||Io;const Lo={},Ft=new Ce.__emitter(Ce);na();let dt="",rs=0,Ir=0,is=0,mi=!1;try{if(rr.__emitTokens)rr.__emitTokens(De,Ft);else{for(Je.matcher.considerAll();;){is++,mi?mi=!1:Je.matcher.considerAll(),Je.matcher.lastIndex=Ir;const be=Je.matcher.exec(De);if(!be)break;const _e=De.substring(Ir,be.index),Ke=hi(_e,be);Ir=be.index+Ke}hi(De.substring(Ir))}return Ft.finalize(),rt=Ft.toHTML(),{language:me,value:rt,relevance:rs,illegal:!1,_emitter:Ft,_top:Je}}catch(be){if(be.message&&be.message.includes("Illegal"))return{language:me,value:Bt(De),illegal:!0,relevance:0,_illegalBy:{message:be.message,index:Ir,context:De.slice(Ir-100,Ir+100),mode:be.mode,resultSoFar:rt},_emitter:Ft};if(wt)return{language:me,value:Bt(De),illegal:!1,relevance:0,errorRaised:be,_emitter:Ft,_top:Je};throw be}}function di(me){const De={value:Bt(me),illegal:!1,relevance:0,_top:Ne,_emitter:new Ce.__emitter(Ce)};return De._emitter.addText(me),De}function Zi(me,De){De=De||Ce.languages||Object.keys(te);const Ye=di(me),Ze=De.filter(yr).filter(ta).map(Mn=>Or(Mn,me,!1));Ze.unshift(Ye);const zt=Ze.sort((Mn,An)=>{if(Mn.relevance!==An.relevance)return An.relevance-Mn.relevance;if(Mn.language&&An.language){if(yr(Mn.language).supersetOf===An.language)return 1;if(yr(An.language).supersetOf===Mn.language)return-1}return 0}),[Mt,Rr]=zt,Fs=Mt;return Fs.secondBest=Rr,Fs}function ed(me,De,Ye){const Ze=De&&ve[De]||Ye;me.classList.add("hljs"),me.classList.add(`language-${Ze}`)}function Mo(me){let De=null;const Ye=Wt(me);if(Ue(Ye))return;if(es("before:highlightElement",{el:me,language:Ye}),me.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",me);return}if(me.children.length>0&&(Ce.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(me)),Ce.throwUnescapedHTML))throw new ft("One of your code blocks includes unescaped HTML.",me.innerHTML);De=me;const Ze=De.textContent,zt=Ye?yt(Ze,{language:Ye,ignoreIllegals:!0}):Zi(Ze);me.innerHTML=zt.value,me.dataset.highlighted="yes",ed(me,Ye,zt.language),me.result={language:zt.language,re:zt.relevance,relevance:zt.relevance},zt.secondBest&&(me.secondBest={language:zt.secondBest.language,relevance:zt.secondBest.relevance}),es("after:highlightElement",{el:me,result:zt,text:Ze})}function td(me){Ce=Ut(Ce,me)}const Kr=()=>{Bs(),Xt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Yl(){Bs(),Xt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ao=!1;function Bs(){function me(){Bs()}if(document.readyState==="loading"){Ao||window.addEventListener("DOMContentLoaded",me,!1),Ao=!0;return}document.querySelectorAll(Ce.cssSelector).forEach(Mo)}function Ql(me,De){let Ye=null;try{Ye=De(I)}catch(Ze){if(Jt("Language definition for '{}' could not be registered.".replace("{}",me)),wt)Jt(Ze);else throw Ze;Ye=Ne}Ye.name||(Ye.name=me),te[me]=Ye,Ye.rawDefinition=De.bind(null,I),Ye.aliases&&ea(Ye.aliases,{languageName:me})}function Xl(me){delete te[me];for(const De of Object.keys(ve))ve[De]===me&&delete ve[De]}function Zl(){return Object.keys(te)}function yr(me){return me=(me||"").toLowerCase(),te[me]||te[ve[me]]}function ea(me,{languageName:De}){typeof me=="string"&&(me=[me]),me.forEach(Ye=>{ve[Ye.toLowerCase()]=De})}function ta(me){const De=yr(me);return De&&!De.disableAutodetect}function Tt(me){me["before:highlightBlock"]&&!me["before:highlightElement"]&&(me["before:highlightElement"]=De=>{me["before:highlightBlock"](Object.assign({block:De.el},De))}),me["after:highlightBlock"]&&!me["after:highlightElement"]&&(me["after:highlightElement"]=De=>{me["after:highlightBlock"](Object.assign({block:De.el},De))})}function nd(me){Tt(me),Ge.push(me)}function Oo(me){const De=Ge.indexOf(me);De!==-1&&Ge.splice(De,1)}function es(me,De){const Ye=me;Ge.forEach(function(Ze){Ze[Ye]&&Ze[Ye](De)})}function zs(me){return Xt("10.7.0","highlightBlock will be removed entirely in v12.0"),Xt("10.7.0","Please use highlightElement now."),Mo(me)}Object.assign(I,{highlight:yt,highlightAuto:Zi,highlightAll:Bs,highlightElement:Mo,highlightBlock:zs,configure:td,initHighlighting:Kr,initHighlightingOnLoad:Yl,registerLanguage:Ql,unregisterLanguage:Xl,listLanguages:Zl,getLanguage:yr,registerAliases:ea,autoDetection:ta,inherit:Ut,addPlugin:nd,removePlugin:Oo}),I.debugMode=function(){wt=!1},I.safeMode=function(){wt=!0},I.versionString=Le,I.regex={concat:E,lookahead:y,either:S,optional:x,anyNumberOfTimes:b};for(const me in ne)typeof ne[me]=="object"&&t(ne[me]);return Object.assign(I,ne),I},Ht=xn({});return Ht.newInstance=()=>xn({}),vp=Ht,Ht.HighlightJS=Ht,Ht.default=Ht,vp}var QI=YI();const Iw=Lu(QI);function Lw(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?Lw(n.children,r):{text:n.value,classes:r}})}function j0(t){return t.value||t.children||[]}function XI(t){return!!Iw.getLanguage(t)}function B0({doc:t,name:e,lowlight:n,defaultLanguage:r}){const i=[];return Qc(t,s=>s.type.name===e).forEach(s=>{var l;let c=s.pos+1;const u=s.node.attrs.language||r,f=n.listLanguages(),p=u&&(f.includes(u)||XI(u)||(l=n.registered)!=null&&l.call(n,u))?j0(n.highlight(u,s.node.textContent)):j0(n.highlightAuto(s.node.textContent));Lw(p).forEach(h=>{const y=c+h.text.length;if(h.classes.length){const b=vt.inline(c,y,{class:h.classes.join(" ")});i.push(b)}c=y})}),lt.create(t,i)}function ZI(t){return typeof t=="function"}function e2({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(i=>ZI(e[i])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new ut({key:new mt("lowlight"),state:{init:(i,{doc:s})=>B0({doc:s,name:t,lowlight:e,defaultLanguage:n}),apply:(i,s,l,c)=>{const u=l.selection.$head.parent.type.name,f=c.selection.$head.parent.type.name,p=Qc(l.doc,y=>y.type.name===t),h=Qc(c.doc,y=>y.type.name===t);return i.docChanged&&([u,f].includes(t)||h.length!==p.length||i.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)))?B0({doc:i.doc,name:t,lowlight:e,defaultLanguage:n}):s.map(i.mapping,i.doc)}},props:{decorations(i){return r.getState(i)}}});return r}var t2=II.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))||[],e2({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),n2=t2;function r2(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+e.optional(i)+"[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},h={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(i)+t.IDENT_RE,relevance:0},b=e.optional(i)+t.IDENT_RE+"\\s*\\(",x=["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"],E=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],S=["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:E,keyword:x,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},O={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},P=[O,h,c,n,t.C_BLOCK_COMMENT_MODE,p,f],B={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:P.concat([{begin:/\(/,end:/\)/,keywords:T,contains:P.concat(["self"]),relevance:0}]),relevance:0},Q={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,h]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(B,Q,O,P,[h,{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 i2(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=r2(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 s2(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 i={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},s=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,i]};i.contains.push(c);const u={match:/\\"/},f={className:"string",begin:/'/,end:/'/},p={match:/\\'/},h={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}),x={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},E=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],w=["true","false"],S={match:/(\/[a-z._-]+)+/},_=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],M=["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"],O=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:E,literal:w,built_in:[..._,...M,"set","shopt",...T,...O]},contains:[b,t.SHEBANG(),x,h,s,l,S,c,u,f,p,n]}}function o2(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",l="("+r+"|"+e.optional(i)+"[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},h={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(i)+t.IDENT_RE,relevance:0},b=e.optional(i)+t.IDENT_RE+"\\s*\\(",w={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},S=[h,c,n,t.C_BLOCK_COMMENT_MODE,p,f],_={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:S.concat([{begin:/\(/,end:/\)/,keywords:w,contains:S.concat(["self"]),relevance:0}]),relevance:0},M={begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:w,relevance:0},{begin:b,returnBegin:!0,contains:[t.inherit(y,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,c,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,h]};return{name:"C",aliases:["h"],keywords:w,disableAutodetect:!0,illegal:"</",contains:[].concat(_,M,S,[h,{begin:t.IDENT_RE+"::",keywords:w},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:h,strings:f,keywords:w}}}function l2(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",i="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+e.optional(i)+"[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},h={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(i)+t.IDENT_RE,relevance:0},b=e.optional(i)+t.IDENT_RE+"\\s*\\(",x=["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"],E=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],S=["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:E,keyword:x,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},O={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},P=[O,h,c,n,t.C_BLOCK_COMMENT_MODE,p,f],B={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:P.concat([{begin:/\(/,end:/\)/,keywords:T,contains:P.concat(["self"]),relevance:0}]),relevance:0},Q={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,h]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(B,Q,O,P,[h,{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 a2(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"],i=["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"],s=["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:i.concat(s),built_in:e,literal:r},c=t.inherit(t.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),u={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},p={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},h=t.inherit(p,{illegal:/\n/}),y={className:"subst",begin:/\{/,end:/\}/,keywords:l},b=t.inherit(y,{illegal:/\n/}),x={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,b]},E={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]},w=t.inherit(E,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},b]});y.contains=[E,x,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.C_BLOCK_COMMENT_MODE],b.contains=[w,x,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const S={variants:[f,E,x,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},_={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},M=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"}},S,u,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},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,_,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:"("+M+"\\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,_],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,relevance:0,contains:[S,u,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},T]}}const c2=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_-]*/}}),u2=["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"],d2=["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"],f2=[...u2,...d2],p2=["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(),h2=["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(),m2=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),g2=["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 y2(t){const e=t.regex,n=c2(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},i="and or not only",s=/@-?\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:":("+h2.join("|")+")"},{begin:":(:)?("+m2.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+g2.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:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:p2.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+f2.join("|")+")\\b"}]}}function b2(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 v2(t){const s={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:s,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:s,illegal:/["']/}]}]}}function x2(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 k2(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 i={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={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,s,i,l,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,p=/'[^']*'/,h=e.either(u,f,p),y=e.concat(h,"(\\s*\\.\\s*",h,")*",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,s,i,l,n]}}]}}var mo="[0-9](_*[0-9])*",wc=`\\.(${mo})`,Ec="[0-9a-fA-F](_*[0-9a-fA-F])*",z0={className:"number",variants:[{begin:`(\\b(${mo})((${wc})|\\.)?|(${wc}))[eE][+-]?(${mo})[fFdD]?\\b`},{begin:`\\b(${mo})((${wc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${wc})[fFdD]?\\b`},{begin:`\\b(${mo})[fFdD]\\b`},{begin:`\\b0[xX]((${Ec})\\.?|(${Ec})?\\.(${Ec}))[pP][+-]?(${mo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Ec})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Dw(t,e,n){return n===-1?"":t.replace(e,r=>Dw(t,e,n-1))}function w2(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+Dw("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),u={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},p={className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:u,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[p,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:u,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[f,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,z0,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},z0,f]}}const F0="[A-Za-z$_][0-9A-Za-z$_]*",E2=["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"],S2=["true","false","null","undefined","NaN","Infinity"],Pw=["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"],jw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Bw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],C2=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],N2=[].concat(Bw,Pw,jw);function _2(t){const e=t.regex,n=(G,{after:se})=>{const ie="</"+G[0].slice(1);return G.input.indexOf(ie,se)!==-1},r=F0,i={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(G,se)=>{const ie=G[0].length+G.index,R=G.input[ie];if(R==="<"||R===","){se.ignoreMatch();return}R===">"&&(n(G,{after:ie})||se.ignoreMatch());let j;const le=G.input.substring(ie);if(j=le.match(/^\s*=/)){se.ignoreMatch();return}if((j=le.match(/^\s+extends\s+/))&&j.index===0){se.ignoreMatch();return}}},c={$pattern:F0,keyword:E2,literal:S2,built_in:N2,"variable.language":C2},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"css"}},E={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,y]},_={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]},M=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,x,E,w,{match:/\$\d+/},h];y.contains=M.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(M)});const T=[].concat(_,y.contains),O=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O},B={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},Q={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:{_:[...Pw,...jw]}},X={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},J={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},fe={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(G){return e.concat("(?!",G.join("|"),")")}const W={match:e.concat(/\b/,K([...Bw,"super","import"].map(G=>`${G}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},$={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Z={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},ee="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",he={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:Q},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),X,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,x,E,w,_,{match:/\$\d+/},h,Q,{scope:"attr",match:r+e.lookahead(":"),relevance:0},he,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,t.REGEXP_MODE,{className:"function",begin:ee,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:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},J,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},$,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},W,fe,B,Z,{match:/\$[(.]/}]}}function T2(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],i={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,i,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var go="[0-9](_*[0-9])*",Sc=`\\.(${go})`,Cc="[0-9a-fA-F](_*[0-9a-fA-F])*",M2={className:"number",variants:[{begin:`(\\b(${go})((${Sc})|\\.)?|(${Sc}))[eE][+-]?(${go})[fFdD]?\\b`},{begin:`\\b(${go})((${Sc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Sc})[fFdD]?\\b`},{begin:`\\b(${go})[fFdD]\\b`},{begin:`\\b0[xX]((${Cc})\\.?|(${Cc})?\\.(${Cc}))[pP][+-]?(${go})[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 A2(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+"@"},i={className:"subst",begin:/\$\{/,end:/\}/,contains:[t.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+t.UNDERSCORE_IDENT_RE},l={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,i]},{begin:"'",end:"'",illegal:/\n/,contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[t.BACKSLASH_ESCAPE,s,i]}]};i.contains.push(l);const c={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+t.UNDERSCORE_IDENT_RE+")?"},u={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(l,{className:"string"}),"self"]}]},f=M2,p=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),h={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},y=h;return y.variants[1].contains=[h],h.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,u,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[h,t.C_LINE_COMMENT_MODE,p],relevance:0},t.C_LINE_COMMENT_MODE,p,c,u,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,u]},l,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
|
|
202
|
+
`},f]}}const O2=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_-]*/}}),R2=["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"],I2=["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"],L2=[...R2,...I2],D2=["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(),zw=["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(),Fw=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),P2=["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(),j2=zw.concat(Fw).sort().reverse();function B2(t){const e=O2(t),n=j2,r="and or not only",i="[\\w-]+",s="("+i+"|@\\{"+i+"\\})",l=[],c=[],u=function(M){return{className:"string",begin:"~?"+M+".*?"+M}},f=function(M,T,O){return{className:M,begin:T,relevance:O}},p={$pattern:/[a-z-]+/,keyword:r,attribute:D2.join(" ")},h={begin:"\\(",end:"\\)",contains:c,keywords:p,relevance:0};c.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,u("'"),u('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},e.HEXCOLOR,h,f("variable","@@?"+i,10),f("variable","@\\{"+i+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:i+"\\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)},x={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+P2.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},E={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}},w={className:"variable",variants:[{begin:"@"+i+"\\s*:",relevance:15},{begin:"@"+i}],starts:{end:"[;}]",returnEnd:!0,contains:y}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,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","@\\{"+i+"\\}"),{begin:"\\b("+L2.join("|")+")\\b",className:"selector-tag"},e.CSS_NUMBER_MODE,f("selector-tag",s,0),f("selector-id","#"+s),f("selector-class","\\."+s,0),f("selector-tag","&",0),e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+zw.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Fw.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},e.FUNCTION_DISPATCH]},_={begin:i+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return l.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,E,w,_,x,S,b,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:l}}function z2(t){const e="\\[=*\\[",n="\\]=*\\]",r={begin:e,end:n,contains:["self"]},i=[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:i.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:i}].concat(i)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:e,end:n,contains:[r],relevance:5}])}}function F2(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]},i={begin:"^"+t.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},s={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,i,s,l]}}function $2(t){const e=t.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},i={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},h=t.inherit(f,{contains:[]}),y=t.inherit(p,{contains:[]});f.contains.push(y),p.contains.push(h);let b=[n,u];return[f,p,h,y].forEach(S=>{S.contains=S.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,s,f,p,{className:"quote",begin:"^>\\s+",contains:b,end:"$"},i,r,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function U2(t){const e={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},u={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[e,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.C_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+u.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:u,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function H2(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}/,i={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:i},l={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},u={scope:"variable",variants:[{begin:/\$\d/},{begin:e.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},p=[t.BACKSLASH_ESCAPE,s,u],h=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(E,w,S="\\1")=>{const _=S==="\\1"?S:e.concat(S,w);return e.concat(e.concat("(?:",E,")"),w,/(?:\\.|[^\\\/])*?/,_,/(?:\\.|[^\\\/])*?/,S,r)},b=(E,w,S)=>e.concat(e.concat("(?:",E,")"),w,/(?:\\.|[^\\\/])*?/,S,r),x=[u,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(...h,{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(...h,{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 s.contains=x,l.contains=x,{name:"Perl",aliases:["pl","pm"],keywords:i,contains:x}}function W2(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),i=e.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s=e.concat(/[A-Z]+/,n),l={scope:"variable",match:"\\$+"+r},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},u={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=t.inherit(t.APOS_STRING_MODE,{illegal:null}),p=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(u)}),h={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(u),"on:begin":($,Z)=>{Z.data._beginMatch=$[1]||$[2]},"on:end":($,Z)=>{Z.data._beginMatch!==$[1]&&Z.ignoreMatch()}},y=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
|
|
203
|
+
]`,x={scope:"string",variants:[p,f,h,y]},E={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},w=["false","null","true"],S=["__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"],_=["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:S,literal:($=>{const Z=[];return $.forEach(ee=>{Z.push(ee),ee.toLowerCase()===ee?Z.push(ee.toUpperCase()):Z.push(ee.toLowerCase())}),Z})(w),built_in:_},O=$=>$.map(Z=>Z.replace(/\|\d+$/,"")),P={variants:[{match:[/new/,e.concat(b,"+"),e.concat("(?!",O(_).join("\\b|"),"\\b)"),i],scope:{1:"keyword",4:"title.class"}}]},B=e.concat(r,"\\b(?!\\()"),Q={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),B],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[i,e.concat(/::/,e.lookahead(/(?!class\b)/)),B],scope:{1:"title.class",3:"variable.constant"}},{match:[i,e.concat("::",e.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},X={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},J={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[X,l,Q,t.C_BLOCK_COMMENT_MODE,x,E,P]},fe={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",O(S).join("\\b|"),"|",O(_).join("\\b|"),"\\b)"),r,e.concat(b,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[J]};J.contains.push(fe);const K=[X,Q,t.C_BLOCK_COMMENT_MODE,x,E,P],W={begin:e.concat(/#\[\s*\\?/,e.either(i,s)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:w,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:w,keyword:["new","array"]},contains:["self",...K]},...K,{scope:"meta",variants:[{match:i},{match:s}]}]};return{case_insensitive:!1,keywords:T,contains:[W,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,fe,Q,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},P,{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",W,l,Q,t.C_BLOCK_COMMENT_MODE,x,E]}]},{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]},x,E]}}function V2(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 K2(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function G2(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},p={begin:/\{\{/,relevance:0},h={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,u,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u,p,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,p,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",b=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,x=`\\b|${r.join("|")}`,E={className:"number",relevance:0,variants:[{begin:`(\\b(${y})|(${b}))[eE][+-]?(${y})[jJ]?(?=${x})`},{begin:`(${b})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${x})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${x})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${x})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${x})`},{begin:`\\b(${y})[jJ](?=${x})`}]},w={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},S={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,E,h,t.HASH_COMMENT_MODE]}]};return f.contains=[h,E,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,E,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},h,w,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[S]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[E,S,h]}]}}function q2(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function J2(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]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,s=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:[i,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[s,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:s},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function Y2(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]+/),i=e.concat(r,/(::\w+)*/),l={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[c]}),t.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:l},h={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])*",x={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"}]},E={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:l}]},P=[h,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:l},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:l},{relevance:0,match:[i,/\.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:[E]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[h,{begin:n}],relevance:0},x,{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(u,f),relevance:0}].concat(u,f);p.contains=P,E.contains=P;const J=[{begin:/^\s*=>/,starts:{end:"$",contains:P}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:l,contains:P}}];return f.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(J).concat(f).concat(P)}}function Q2(t){const e=t.regex,n=/(r#)?/,r=e.concat(n,t.UNDERSCORE_IDENT_RE),i=e.concat(n,t.IDENT_RE),s={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,e.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],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:u,built_in:f},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:p}},{className:"punctuation",begin:"->"},s]}}const X2=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_-]*/}}),Z2=["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"],eL=["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"],tL=[...Z2,...eL],nL=["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(),rL=["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(),iL=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),sL=["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 oL(t){const e=X2(t),n=iL,r=rL,i="@[a-z-]+",s="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("+tL.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("+sL.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:i,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:nL.join(" ")},contains:[{begin:i,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 lL(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function aL(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={begin:/"/,end:/"/,contains:[{match:/""/}]},s=["true","false","unknown"],l=["double precision","large object","with timezone","without timezone"],c=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],u=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],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"],h=["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,x=[...f,...u].filter(O=>!p.includes(O)),E={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:e.concat(/\b/,e.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function _(O){return e.concat(/\b/,e.either(...O.map(P=>P.replace(/\s+/,"\\s+"))),/\b/)}const M={scope:"keyword",match:_(y),relevance:0};function T(O,{exceptions:P,when:B}={}){const Q=B;return P=P||[],O.map(X=>X.match(/\|\d+$/)||P.includes(X)?X:Q(X)?`${X}|0`:X)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(x,{when:O=>O.length<3}),literal:s,type:c,built_in:h},contains:[{scope:"type",match:_(l)},M,S,E,r,i,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,w]}}function $w(t){return t?typeof t=="string"?t:t.source:null}function hl(t){return pt("(?=",t,")")}function pt(...t){return t.map(n=>$w(n)).join("")}function cL(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function In(...t){return"("+(cL(t).capture?"":"?:")+t.map(r=>$w(r)).join("|")+")"}const om=t=>pt(/\b/,t,/\w$/.test(t)?/\b/:/\B/),uL=["Protocol","Type"].map(om),$0=["init","self"].map(om),dL=["Any","Self"],xp=["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"],U0=["false","nil","true"],fL=["assignment","associativity","higherThan","left","lowerThan","none","right"],pL=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],H0=["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"],Uw=In(/[/=\-+!*%<>&|^~?]/,/[\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]/),Hw=In(Uw,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),kp=pt(Uw,Hw,"*"),Ww=In(/[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]/),Mu=In(Ww,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),zr=pt(Ww,Mu,"*"),Nc=pt(/[A-Z]/,Mu,"*"),hL=["attached","autoclosure",pt(/convention\(/,In("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",pt(/objc\(/,zr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],mL=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function gL(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],i={match:[/\./,In(...uL,...$0)],className:{2:"keyword"}},s={match:pt(/\./,In(...xp)),relevance:0},l=xp.filter(Ae=>typeof Ae=="string").concat(["_|0"]),c=xp.filter(Ae=>typeof Ae!="string").concat(dL).map(om),u={variants:[{className:"keyword",match:In(...c,...$0)}]},f={$pattern:In(/\b\w+/,/#\w+/),keyword:l.concat(pL),literal:U0},p=[i,s,u],h={match:pt(/\./,In(...H0)),relevance:0},y={className:"built_in",match:pt(/\b/,In(...H0),/(?=\()/)},b=[h,y],x={match:/->/,relevance:0},E={className:"operator",relevance:0,variants:[{match:kp},{match:`\\.(\\.|${Hw})+`}]},w=[x,E],S="([0-9]_*)+",_="([0-9a-fA-F]_*)+",M={className:"number",relevance:0,variants:[{match:`\\b(${S})(\\.(${S}))?([eE][+-]?(${S}))?\\b`},{match:`\\b0x(${_})(\\.(${_}))?([pP][+-]?(${S}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(Ae="")=>({className:"subst",variants:[{match:pt(/\\/,Ae,/[0\\tnr"']/)},{match:pt(/\\/,Ae,/u\{[0-9a-fA-F]{1,8}\}/)}]}),O=(Ae="")=>({className:"subst",match:pt(/\\/,Ae,/[\t ]*(?:[\r\n]|\r\n)/)}),P=(Ae="")=>({className:"subst",label:"interpol",begin:pt(/\\/,Ae,/\(/),end:/\)/}),B=(Ae="")=>({begin:pt(Ae,/"""/),end:pt(/"""/,Ae),contains:[T(Ae),O(Ae),P(Ae)]}),Q=(Ae="")=>({begin:pt(Ae,/"/),end:pt(/"/,Ae),contains:[T(Ae),P(Ae)]}),X={className:"string",variants:[B(),B("#"),B("##"),B("###"),Q(),Q("#"),Q("##"),Q("###")]},J=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],fe={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:J},K=Ae=>{const je=pt(Ae,/\//),ze=pt(/\//,Ae);return{begin:je,end:ze,contains:[...J,{scope:"comment",begin:`#(?!.*${ze})`,end:/$/}]}},W={scope:"regexp",variants:[K("###"),K("##"),K("#"),fe]},$={match:pt(/`/,zr,/`/)},Z={className:"variable",match:/\$\d+/},ee={className:"variable",match:`\\$${Mu}+`},he=[$,Z,ee],G={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:mL,contains:[...w,M,X]}]}},se={scope:"keyword",match:pt(/@/,In(...hL),hl(In(/\(/,/\s+/)))},ie={scope:"meta",match:pt(/@/,zr)},R=[G,se,ie],j={match:hl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:pt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Mu,"+")},{className:"type",match:Nc,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:pt(/\s+&\s+/,hl(Nc)),relevance:0}]},le={begin:/</,end:/>/,keywords:f,contains:[...r,...p,...R,x,j]};j.contains.push(le);const ye={match:pt(zr,/\s*:/),keywords:"_|0",relevance:0},Ee={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",ye,...r,W,...p,...b,...w,M,X,...he,...R,j]},oe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,j]},z={begin:In(hl(pt(zr,/\s*:/)),hl(pt(zr,/\s+/,zr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:zr}]},q={begin:/\(/,end:/\)/,keywords:f,contains:[z,...r,...p,...w,M,X,...R,j,Ee],endsParent:!0,illegal:/["']/},Y={match:[/(func|macro)/,/\s+/,In($.match,zr,kp)],className:{1:"keyword",3:"title.function"},contains:[oe,q,e],illegal:[/\[/,/%/]},ne={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[oe,q,e],illegal:/\[|%/},Me={match:[/operator/,/\s+/,kp],className:{1:"keyword",3:"title"}},H={begin:[/precedencegroup/,/\s+/,Nc],className:{1:"keyword",3:"title"},contains:[j],keywords:[...fL,...U0],end:/}/},ke={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},we={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},$e={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,zr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[oe,...p,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Nc},...p],relevance:0}]};for(const Ae of X.variants){const je=Ae.contains.find(yn=>yn.label==="interpol");je.keywords=f;const ze=[...p,...b,...w,M,X,...he];je.contains=[...ze,{begin:/\(/,end:/\)/,contains:["self",...ze]}]}return{name:"Swift",keywords:f,contains:[...r,Y,ne,ke,we,$e,Me,H,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},W,...p,...b,...w,M,X,...he,...R,j,Ee]}}const Au="[A-Za-z$_][0-9A-Za-z$_]*",Vw=["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"],Kw=["true","false","null","undefined","NaN","Infinity"],Gw=["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"],qw=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Jw=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Yw=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Qw=[].concat(Jw,Gw,qw);function yL(t){const e=t.regex,n=(G,{after:se})=>{const ie="</"+G[0].slice(1);return G.input.indexOf(ie,se)!==-1},r=Au,i={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(G,se)=>{const ie=G[0].length+G.index,R=G.input[ie];if(R==="<"||R===","){se.ignoreMatch();return}R===">"&&(n(G,{after:ie})||se.ignoreMatch());let j;const le=G.input.substring(ie);if(j=le.match(/^\s*=/)){se.ignoreMatch();return}if((j=le.match(/^\s+extends\s+/))&&j.index===0){se.ignoreMatch();return}}},c={$pattern:Au,keyword:Vw,literal:Kw,built_in:Qw,"variable.language":Yw},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",h={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"css"}},E={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,y]},_={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]},M=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,x,E,w,{match:/\$\d+/},h];y.contains=M.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(M)});const T=[].concat(_,y.contains),O=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),P={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:O},B={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},Q={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:{_:[...Gw,...qw]}},X={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},J={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[P],illegal:/%/},fe={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function K(G){return e.concat("(?!",G.join("|"),")")}const W={match:e.concat(/\b/,K([...Jw,"super","import"].map(G=>`${G}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},$={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},Z={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},P]},ee="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",he={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[P]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:Q},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),X,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,x,E,w,_,{match:/\$\d+/},h,Q,{scope:"attr",match:r+e.lookahead(":"),relevance:0},he,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,t.REGEXP_MODE,{className:"function",begin:ee,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:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.end},{match:s},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},J,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[P,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},$,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[P]},W,fe,B,Z,{match:/\$[(.]/}]}}function bL(t){const e=t.regex,n=yL(t),r=Au,i=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],s={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:i},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Au,keyword:Vw.concat(u),literal:Kw,built_in:Qw.concat(i),"variable.language":Yw},p={className:"meta",begin:"@"+r},h=(E,w,S)=>{const _=E.contains.findIndex(M=>M.label===w);if(_===-1)throw new Error("can not find mode to replace");E.contains.splice(_,1,S)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(p);const y=n.contains.find(E=>E.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,s,l,b]),h(n,"shebang",t.SHEBANG()),h(n,"use_strict",c);const x=n.contains.find(E=>E.label==="func.def");return x.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function vL(t){const e=t.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\d{1,2}\/\d{1,2}\/\d{4}/,s=/\d{4}-\d{1,2}-\d{1,2}/,l=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:e.concat(/# */,e.either(s,i),/ *#/)},{begin:e.concat(/# */,c,/ *#/)},{begin:e.concat(/# */,l,/ *#/)},{begin:e.concat(/# */,e.either(s,i),/ +/,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+:/},h=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),y=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,u,f,p,h,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 xL(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"],i={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},s={className:"variable",begin:/\$[\w_]+/},l={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},u={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,e,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},s,l,i,t.QUOTE_STRING_MODE,u,f,c]}}function kL(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,i={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},s={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=t.inherit(s,{begin:/\(/,end:/\)/}),c=t.inherit(t.APOS_STRING_MODE,{className:"string"}),u=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[i]},{begin:/'/,end:/'/,contains:[i]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[s,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[s,l,u,c]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},i,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function wL(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]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},s={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,i]},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},x={begin:/\{/,end:/\}/,contains:[b],illegal:"\\n",relevance:0},E={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},w=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},y,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},x,E,s,l],S=[...w];return S.pop(),S.push(c),b.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}const EL={arduino:i2,bash:s2,c:o2,cpp:l2,csharp:a2,css:y2,diff:b2,go:v2,graphql:x2,ini:k2,java:w2,javascript:_2,json:T2,kotlin:A2,less:B2,lua:z2,makefile:F2,markdown:$2,objectivec:U2,perl:H2,php:W2,"php-template":V2,plaintext:K2,python:G2,"python-repl":q2,r:J2,ruby:Y2,rust:Q2,scss:oL,shell:lL,sql:aL,swift:gL,typescript:bL,vbnet:vL,wasm:xL,xml:kL,yaml:wL},W0={},SL="hljs-";function CL(t){const e=Iw.newInstance();return t&&s(t),{highlight:n,highlightAuto:r,listLanguages:i,register:s,registerAlias:l,registered:c};function n(u,f,p){const h=p||W0,y=typeof h.prefix=="string"?h.prefix:SL;if(!e.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");e.configure({__emitter:NL,classPrefix:y});const b=e.highlight(f,{ignoreIllegals:!0,language:u});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const x=b._emitter.root,E=x.data;return E.language=b.language,E.relevance=b.relevance,x}function r(u,f){const h=(f||W0).subset||i();let y=-1,b=0,x;for(;++y<h.length;){const E=h[y];if(!e.getLanguage(E))continue;const w=n(E,u,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>b&&(b=w.data.relevance,x=w)}return x||{type:"root",children:[],data:{language:void 0,relevance:b}}}function i(){return e.listLanguages()}function s(u,f){if(typeof u=="string")e.registerLanguage(u,f);else{let p;for(p in u)Object.hasOwn(u,p)&&e.registerLanguage(p,u[p])}}function l(u,f){if(typeof u=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const h=u[p];e.registerAliases(typeof h=="string"?h:[...h],{languageName:p})}}}function c(u){return!!e.getLanguage(u)}}class NL{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],i=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(e){const n=this,r=e.split(".").map(function(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),i=this.stack[this.stack.length-1],s={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(s),this.stack.push(s)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const _L=new mt("blurredLoadingNode"),lm=st.create({name:"blurredLoadingNode",addStorage(){return{loadingNodes:{}}},addCommands(){return{applyLoadingEffect:(t,e,n,r="paragraph")=>({editor:i})=>{const s={...this.storage.loadingNodes};return s[t]={from:e,to:n,id:t,active:!0,type:r},this.storage.loadingNodes=s,i.view.dispatch(i.view.state.tr),setTimeout(()=>{i.isFocused&&i.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 ut({key:_L,props:{decorations:t=>{const e=this.storage.loadingNodes,n=[];return Object.entries(e).forEach(([,r])=>{const i=r;if(!i.active)return;const{from:s,to:l,type:c}=i;c==="selection"?n.push(vt.inline(s,l,{class:"node-blur-selection"})):t.doc.nodesBetween(s,l,(u,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(u.type.name)?(n.push(vt.node(f,f+u.nodeSize,{class:"node-blur-effect"})),!1):!0)}),lt.create(t.doc,n)}}})]}}),TL=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],am=st.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:TL,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}}}]}}),ML=CL(EL),cm=HA.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:i,...s}=n;return["span",{...s,"data-doc":i.slice(4),class:"doc-link"},0]}return["a",ct(this.options.HTMLAttributes,n),0]}}),AL=[sm.configure({codeBlock:!1,link:!1,underline:!1}),n2.configure({lowlight:ML}),cm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Aw,pI,gA,mO,yO,DR,LR.configure({nested:!0}),Vh,fI,gw.configure({resizable:!1}),mw,hw,pw,lm,am,Yu.configure({placeholder:"Start writing..."}),im.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],OL=[sm.configure({codeBlock:!1,horizontalRule:!1,heading:{levels:[1,2,3]},link:!1,underline:!1}),cm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Vh,lm,am,Yu.configure({placeholder:"Start writing..."}),im.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],RL=st.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.setHardBreak()}}}),Xw=[sm.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),cm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Vh,lm,am,RL,im.configure({types:["paragraph","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...Xw,Yu.configure({placeholder:"What is happening?!"})];function Br({onClick:t,active:e,disabled:n,title:r,children:i}){return g.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:s=>{s.preventDefault(),t()},disabled:n,title:r,children:i})}function V0(){return g.jsx("div",{className:"floating-toolbar__divider"})}function IL({editor:t}){const[e,n]=N.useState(!1),[r,i]=N.useState({top:0,left:0}),[,s]=N.useState(0),l=N.useRef(-1),c=N.useRef(-1),u=N.useRef(!1);return N.useEffect(()=>{const f=t.view.dom,p=()=>{u.current=!0},h=()=>{if(!u.current)return;u.current=!1;const{from:y,to:b}=t.state.selection;if(y!==b){const x=t.isActive("codeBlock"),E=!!document.querySelector(".context-menu");if(!x&&!E){l.current=y,c.current=b;const w=t.view.coordsAtPos(y),S=t.view.coordsAtPos(b,1),_=(w.left+S.right)/2;i({top:w.top,left:_}),n(!0)}}};return f.addEventListener("mousedown",p),document.addEventListener("mouseup",h),()=>{f.removeEventListener("mousedown",p),document.removeEventListener("mouseup",h)}},[t]),N.useEffect(()=>{const f=()=>{u.current=!1,n(!1),l.current=-1,c.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),N.useEffect(()=>{const f=()=>{const{from:p,to:h}=t.state.selection,y=p===h,b=t.isActive("codeBlock"),x=!!document.querySelector(".context-menu"),E=t.view.hasFocus();if(y||b||x||!E)n(!1),l.current=-1,c.current=-1;else if(!u.current&&(n(!0),p!==l.current||h!==c.current)){l.current=p,c.current=h;const w=t.view.coordsAtPos(p),S=t.view.coordsAtPos(h,1),_=(w.left+S.right)/2;i({top:w.top,left:_})}s(w=>w+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?g.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[g.jsx(Br,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.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"})})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),g.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),g.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),g.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),g.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),g.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),g.jsx(V0,{}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 12h8"}),g.jsx("path",{d:"M4 18V6"}),g.jsx("path",{d:"M12 18V6"}),g.jsx("path",{d:"m17 12 3-2v8"})]})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 12h8"}),g.jsx("path",{d:"M4 18V6"}),g.jsx("path",{d:"M12 18V6"}),g.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 12h8"}),g.jsx("path",{d:"M4 18V6"}),g.jsx("path",{d:"M12 18V6"}),g.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),g.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),g.jsx(V0,{}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M3 12h.01"}),g.jsx("path",{d:"M3 18h.01"}),g.jsx("path",{d:"M3 6h.01"}),g.jsx("path",{d:"M8 12h13"}),g.jsx("path",{d:"M8 18h13"}),g.jsx("path",{d:"M8 6h13"})]})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M11 12h9"}),g.jsx("path",{d:"M11 18h9"}),g.jsx("path",{d:"M11 6h9"}),g.jsx("path",{d:"M4 10V4h1"}),g.jsx("path",{d:"M4 10h2"}),g.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),g.jsx(Br,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M17 6H3"}),g.jsx("path",{d:"M21 12H8"}),g.jsx("path",{d:"M21 18H8"}),g.jsx("path",{d:"M3 12v6"})]})})]}):null}const LL=new mt("pendingDecoration");let Zw=null,e1=null;function K0(t,e){Zw=t,e1=e??null}let Ou=!1,t1=null,um=null,n1=null;function dm(){return Ou}function DL(){return um}function PL(){return n1}function lh(t,e,n,r){Ou=t,t1=t?e??null:null,um=t?r??null:null,n1=t?n??null:null}function jL(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function G0(t,e,n){let r=0,i=e+1;for(let s=0;s<t.childCount;s++){const l=t.child(s);if(l.isText){if(r+l.text.length>=n)return i+(n-r);r+=l.text.length,i+=l.nodeSize}else i+=l.nodeSize}return n===r?i:null}function q0(t){const e=[];return t.descendants((n,r)=>{var x,E,w,S,_,M,T;const i=(x=n.attrs)==null?void 0:x.pendingStatus;if(!i)return!0;const s=(E=n.attrs)==null?void 0:E.id,l=(w=n.attrs)==null?void 0:w.pendingGroupId,c=l&&l===e1,f=Ou&&s===t1||l&&Ou&&l===um,p=f?(S=n.attrs)==null?void 0:S.pendingOriginalFrom:(_=n.attrs)==null?void 0:_.pendingSelectionFrom,h=f?(M=n.attrs)==null?void 0:M.pendingOriginalTo:(T=n.attrs)==null?void 0:T.pendingSelectionTo,y=p!=null&&h!=null,b=f?"pending-original":jL(i);if(y&&n.isTextblock&&b){const O=G0(n,r,p),P=G0(n,r,h);O!==null&&P!==null&&O<P&&e.push(vt.inline(O,P,{class:b}))}else b&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(vt.inline(r+1,r+n.nodeSize-1,{class:b})):e.push(vt.node(r,r+n.nodeSize,{class:b})));if(s&&(s===Zw||c)){const O=f?"original":i;e.push(vt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${O}`}))}return!0}),lt.create(t,e)}function r1(){return new ut({key:LL,state:{init(t,e){return q0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?q0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function fm(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const BL=new mt("markDecoration");let ah=[];function J0(t){ah=t}function Y0(t){if(ah.length===0)return lt.empty;const e=[],n=new Map;for(const r of ah){const i=n.get(r.nodeId)||[];i.push(r),n.set(r.nodeId,i)}return t.descendants((r,i)=>{var u;const s=(u=r.attrs)==null?void 0:u.id;if(!s||!n.has(s))return!0;const l=n.get(s),c=r.textContent;for(const f of l){const p=c.indexOf(f.text);if(p===-1)continue;const h=Q0(r,i,p),y=Q0(r,i,p+f.text.length);if(h===null||y===null||h>=y)continue;const b=f.note?`Agent Mark: ${f.note}`:"Agent Mark";e.push(vt.inline(h,y,{class:"agent-mark",title:b,"data-mark-id":f.id}))}return!0}),lt.create(t,e)}function Q0(t,e,n){let r=0,i=e+1;for(let s=0;s<t.childCount;s++){const l=t.child(s);if(l.isText){if(r+l.text.length>=n)return i+(n-r);r+=l.text.length,i+=l.nodeSize}else i+=l.nodeSize}return n===r?i:null}function zL(){return new ut({key:BL,state:{init(t,e){return Y0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceMarkUpdate")?Y0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function X0(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceMarkUpdate",!0);n(r)}async function Z0(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:i}=await r.json(),{state:s}=e,l=s.schema.nodes.image.create({src:i,alt:t.name}),c=s.tr.replaceSelectionWith(l);e.dispatch(c)}catch{}}function ev({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:i}){const s=N.useRef(i);s.current=i;const l=zk({extensions:e||AL,content:t||"<p></p>",onUpdate:({editor:c})=>{dm()||n==null||n(c.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:(c,u)=>{var p;const f=(p=u.clipboardData)==null?void 0:p.items;if(!f)return!1;for(const h of f)if(h.type.startsWith("image/")){u.preventDefault();const y=h.getAsFile();return y&&Z0(y,c),!0}return!1},handleDrop:(c,u)=>{var p;const f=(p=u.dataTransfer)==null?void 0:p.files;if(!(f!=null&&f.length))return!1;for(const h of f)if(h.type.startsWith("image/"))return u.preventDefault(),Z0(h,c),!0;return!1}}},[t]);return N.useEffect(()=>{if(!l)return;const c=l.view.dom,u=f=>{var b;const h=f.target.closest("span.doc-link[data-doc]");if(!h)return;const y=h.getAttribute("data-doc");(b=s.current)==null||b.call(s,y)};return c.addEventListener("click",u,!0),()=>c.removeEventListener("click",u,!0)},[l]),N.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(p=>p.key==="pendingDecoration$"))return;const u=r1(),f=c.reconfigure({plugins:[...c.plugins,u]});l.view.updateState(f)},[l]),N.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(p=>p.key==="markDecoration$"))return;const u=zL(),f=c.reconfigure({plugins:[...c.plugins,u]});l.view.updateState(f)},[l]),N.useEffect(()=>{l&&(r==null||r(l))},[l,r]),l?g.jsxs(g.Fragment,{children:[g.jsx(Hh,{editor:l}),g.jsx(IL,{editor:l})]}):null}function Kt({onClick:t,active:e,disabled:n,title:r,children:i}){return g.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:s=>{s.preventDefault(),t()},disabled:n,title:r,children:i})}function ml(){return g.jsx("div",{className:"format-toolbar__divider"})}async function FL(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:i}=await r.json();e.chain().focus().setImage({src:i,alt:t.name}).run()}catch{}}function $L({editor:t}){const[,e]=N.useState(0),n=N.useRef(null);N.useEffect(()=>{const i=()=>e(s=>s+1);return t.on("transaction",i),()=>{t.off("transaction",i)}},[t]);const r=i=>{var l;const s=(l=i.target.files)==null?void 0:l[0];s&&FL(s,t),i.target.value=""};return g.jsxs("div",{className:"format-toolbar",children:[g.jsxs("div",{className:"format-toolbar__group",children:[g.jsx(Kt,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:g.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.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"})})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),g.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),g.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),g.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),g.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),g.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"m16 18 6-6-6-6"}),g.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),g.jsx(ml,{}),g.jsxs("div",{className:"format-toolbar__group",children:[g.jsx(Kt,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),g.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"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"m4 5 8 8"}),g.jsx("path",{d:"m12 5-8 8"}),g.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"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"m4 19 8-8"}),g.jsx("path",{d:"m12 19-8-8"}),g.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"})]})})]}),g.jsx(ml,{}),g.jsxs("div",{className:"format-toolbar__group",children:[g.jsx(Kt,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 12h8"}),g.jsx("path",{d:"M4 18V6"}),g.jsx("path",{d:"M12 18V6"}),g.jsx("path",{d:"m17 12 3-2v8"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 12h8"}),g.jsx("path",{d:"M4 18V6"}),g.jsx("path",{d:"M12 18V6"}),g.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 12h8"}),g.jsx("path",{d:"M4 18V6"}),g.jsx("path",{d:"M12 18V6"}),g.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),g.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M13 4v16"}),g.jsx("path",{d:"M17 4v16"}),g.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),g.jsx(ml,{}),g.jsxs("div",{className:"format-toolbar__group",children:[g.jsx(Kt,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M3 12h.01"}),g.jsx("path",{d:"M3 18h.01"}),g.jsx("path",{d:"M3 6h.01"}),g.jsx("path",{d:"M8 12h13"}),g.jsx("path",{d:"M8 18h13"}),g.jsx("path",{d:"M8 6h13"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M11 12h9"}),g.jsx("path",{d:"M11 18h9"}),g.jsx("path",{d:"M11 6h9"}),g.jsx("path",{d:"M4 10V4h1"}),g.jsx("path",{d:"M4 10h2"}),g.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"m3 17 2 2 4-4"}),g.jsx("path",{d:"m3 7 2 2 4-4"}),g.jsx("path",{d:"M13 6h8"}),g.jsx("path",{d:"M13 12h8"}),g.jsx("path",{d:"M13 18h8"})]})})]}),g.jsx(ml,{}),g.jsxs("div",{className:"format-toolbar__group",children:[g.jsx(Kt,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M17 6H3"}),g.jsx("path",{d:"M21 12H8"}),g.jsx("path",{d:"M21 18H8"}),g.jsx("path",{d:"M3 12v6"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),g.jsx("path",{d:"m10 9-3 3 3 3"}),g.jsx("path",{d:"m14 15 3-3-3-3"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:g.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("path",{d:"M5 12h14"})})})]}),g.jsx(ml,{}),g.jsxs("div",{className:"format-toolbar__group",children:[g.jsx(Kt,{onClick:()=>{var i;return(i=n.current)==null?void 0:i.click()},title:"Insert Image",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),g.jsx("circle",{cx:"9",cy:"9",r:"2"}),g.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),g.jsx(Kt,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:g.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),g.jsx("path",{d:"M12 3v18"}),g.jsx("path",{d:"M3 9h18"}),g.jsx("path",{d:"M3 15h18"})]})})]}),g.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const UL={tree:g.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),timeline:g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),g.jsx("circle",{cx:"12",cy:"6",r:"2"}),g.jsx("circle",{cx:"12",cy:"12",r:"2"}),g.jsx("circle",{cx:"12",cy:"18",r:"2"}),g.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),g.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),g.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),g.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),g.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:g.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 19V5"}),g.jsx("path",{d:"M8 19V7"}),g.jsx("path",{d:"M12 19V4"}),g.jsx("path",{d:"M16 19V8"}),g.jsx("path",{d:"M20 19V6"}),g.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function HL(){const[t,e]=N.useState(!1),[n,r]=N.useState(kv),[i,s]=N.useState(wv),[l,c]=N.useState(Du),u=Ev(),[f,p]=N.useState(Cv),[h,y]=N.useState(Nv),b=N.useRef(null),x=(T=n,O=i,P=l,B=u,Q=f,X=h)=>{_v(T,O,P,B,Q,X)},E=T=>{r(T),x(T)},w=()=>{const T=i==="light"?"dark":"light";s(T),x(void 0,T)},S=T=>{c(T),x(void 0,void 0,T),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:T}))},_=T=>{p(T),x(void 0,void 0,void 0,void 0,T)},M=T=>{y(T),x(void 0,void 0,void 0,void 0,void 0,T)};return N.useEffect(()=>{if(!t)return;const T=O=>{b.current&&!b.current.contains(O.target)&&e(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),g.jsxs("div",{className:"appearance-wrapper",ref:b,children:[g.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Appearance",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.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"}),g.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),g.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),g.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),g.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]})}),t&&g.jsxs("div",{className:"appearance-dropdown",children:[g.jsx("div",{className:"appearance-section",children:g.jsxs("div",{className:"appearance-section-header",children:[g.jsx("span",{className:"appearance-section-title",children:"Mode"}),g.jsxs("button",{className:"appearance-mode-btn",onClick:w,title:i==="light"?"Switch to dark":"Switch to light",children:[i==="light"?g.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("circle",{cx:"12",cy:"12",r:"5"}),g.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),g.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),g.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),g.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),g.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),g.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),g.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),g.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):g.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),g.jsx("span",{children:i==="light"?"Light":"Dark"})]})]})}),g.jsxs("div",{className:"appearance-section",children:[g.jsx("div",{className:"appearance-section-header",children:g.jsx("span",{className:"appearance-section-title",children:"Typography"})}),g.jsx("div",{className:"appearance-typeface-grid",children:yv.map(T=>g.jsx("button",{className:`appearance-style-option ${n===T.id?"active":""}`,onClick:()=>E(T.id),title:T.description,children:T.label},T.id))})]}),g.jsxs("div",{className:"appearance-section",children:[g.jsx("div",{className:"appearance-section-header",children:g.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),g.jsx("div",{className:"appearance-typography-grid",children:xv.map(T=>g.jsx("button",{className:`appearance-style-option ${f===T.id?"active":""}`,onClick:()=>_(T.id),children:T.label},T.id))})]}),g.jsxs("div",{className:"appearance-section",children:[g.jsx("div",{className:"appearance-section-header",children:g.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),g.jsx("div",{className:"appearance-style-grid",children:vv.map(T=>g.jsx("button",{className:`appearance-style-option ${h===T.id?"active":""}`,onClick:()=>M(T.id),children:T.label},T.id))})]}),g.jsxs("div",{className:"appearance-section",children:[g.jsx("div",{className:"appearance-section-header",children:g.jsx("span",{className:"appearance-section-title",children:"Layout"})}),g.jsx("div",{className:"appearance-mode-grid",children:bv.map(T=>g.jsxs("button",{className:`appearance-mode-option ${l===T.id?"active":""}`,onClick:()=>S(T.id),children:[UL[T.icon],g.jsx("span",{children:T.label})]},T.id))})]})]})]})}function WL(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function VL(){const[t,e]=N.useState(!1),[n,r]=N.useState([]),[i,s]=N.useState(null),[l,c]=N.useState(new Set),u=N.useRef(null),f=N.useCallback(()=>{fetch("/api/available-plugins").then(y=>y.json()).then(y=>r(y.plugins||[])).catch(()=>{})},[]);N.useEffect(()=>{t&&f()},[t,f]),N.useEffect(()=>{const y=()=>f();return window.addEventListener("ow-plugins-changed",y),()=>window.removeEventListener("ow-plugins-changed",y)},[f]),N.useEffect(()=>{if(!t)return;const y=b=>{u.current&&!u.current.contains(b.target)&&e(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[t]);const p=N.useCallback(async(y,b)=>{s(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{s(null)}},[f]),h=N.useCallback((y,b,x)=>{fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,config:{[b]:x}})}).catch(()=>{})},[]);return g.jsxs("div",{className:"plugin-wrapper",ref:u,children:[g.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Plugins",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M12 22v-5"}),g.jsx("path",{d:"M9 8V2"}),g.jsx("path",{d:"M15 8V2"}),g.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&&g.jsxs("div",{className:"plugin-dropdown",children:[g.jsx("div",{className:"plugin-dropdown-header",children:"Plugins"}),n.length===0?g.jsx("div",{className:"plugin-empty",children:"No plugins found"}):n.map(y=>g.jsxs("div",{className:"plugin-item",children:[g.jsxs("div",{className:"plugin-item-header",children:[g.jsxs("div",{className:"plugin-item-info",children:[g.jsxs("div",{className:"plugin-item-name",children:[WL(y.name),g.jsxs("span",{className:"plugin-item-version",children:["v",y.version]})]}),y.description&&g.jsx("div",{className:"plugin-item-desc",children:y.description})]}),g.jsxs("label",{className:`plugin-toggle${i===y.name?" loading":""}`,children:[g.jsx("input",{type:"checkbox",checked:y.enabled,disabled:i===y.name,onChange:()=>p(y.name,y.enabled)}),g.jsx("span",{className:"plugin-toggle-track"}),g.jsx("span",{className:"plugin-toggle-thumb"})]})]}),y.enabled&&Object.keys(y.configSchema).length>0&&g.jsxs("div",{className:"plugin-config-section",children:[g.jsxs("button",{className:"plugin-config-toggle",onClick:()=>c(b=>{const x=new Set(b);return x.has(y.name)?x.delete(y.name):x.add(y.name),x}),children:[g.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:g.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),l.has(y.name)&&g.jsx("div",{className:"plugin-config",children:Object.entries(y.configSchema).map(([b,x])=>g.jsxs("div",{className:"plugin-config-field",children:[g.jsx("label",{className:"plugin-config-label",children:x.description||b}),g.jsx("input",{className:"plugin-config-input",type:b.toLowerCase().includes("key")||b.toLowerCase().includes("secret")||b.toLowerCase().includes("token")?"password":"text",defaultValue:y.config[b]||"",placeholder:x.env?`$${x.env}`:"",onBlur:E=>h(y.name,b,E.target.value)})]},b))})]})]},y.name))]})]})}function KL(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 i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);return s<7?`${s}d ago`:new Date(t).toLocaleDateString()}function GL(t){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function qL(){const[t,e]=N.useState(!1),[n,r]=N.useState([]),[i,s]=N.useState(null),[l,c]=N.useState(!1),u=N.useRef(null),f=N.useCallback(()=>{fetch("/api/versions").then(h=>h.json()).then(h=>{r(Array.isArray(h)?h:[]),s(null)}).catch(()=>r([]))},[]);N.useEffect(()=>{t&&f()},[t,f]),N.useEffect(()=>{if(!t)return;const h=y=>{u.current&&!u.current.contains(y.target)&&e(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[t]);const p=N.useCallback(async h=>{if(i!==null){c(!0);try{(await fetch(`/api/versions/${i}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:h})})).ok&&f()}catch{}c(!1)}},[i,f]);return g.jsxs("div",{className:"version-wrapper",ref:u,children:[g.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Version history",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),g.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t&&g.jsxs("div",{className:"version-dropdown",children:[g.jsx("div",{className:"version-dropdown__header",children:"Version History"}),g.jsx("div",{className:"version-dropdown__list",children:n.length===0?g.jsx("div",{className:"version-dropdown__empty",children:"No versions yet. Versions are created automatically when you save."}):n.map(h=>g.jsxs("div",{className:`version-dropdown__item${i===h.timestamp?" version-dropdown__item--selected":""}`,onClick:()=>s(h.timestamp===i?null:h.timestamp),children:[g.jsx("span",{className:"version-dropdown__item-time",children:KL(h.timestamp)}),g.jsxs("span",{className:"version-dropdown__item-meta",children:[h.wordCount.toLocaleString()," words · ",GL(h.size)]})]},h.timestamp))}),n.length>0&&g.jsxs("div",{className:"version-dropdown__footer",children:[g.jsx("button",{className:"version-dropdown__review-btn",disabled:i===null||l,onClick:()=>p("review"),children:"Review"}),g.jsx("button",{className:"version-dropdown__restore-btn",disabled:i===null||l,onClick:()=>p("full"),children:"Restore"})]})]})]})}const JL=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),g.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("polyline",{points:"16 18 22 12 16 6"}),g.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),g.jsx("path",{d:"M14 2v6h6"}),g.jsx("path",{d:"M16 13H8"}),g.jsx("path",{d:"M16 17H8"}),g.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M17 6.1H3"}),g.jsx("path",{d:"M21 12.1H3"}),g.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),g.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"}),g.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function YL(){const[t,e]=N.useState(!1),n=N.useRef(null);N.useEffect(()=>{if(!t)return;const i=s=>{n.current&&!n.current.contains(s.target)&&e(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[t]);const r=i=>{if(e(!1),i==="pdf"){window.open("/api/export?format=pdf","_blank");return}const s=document.createElement("a");s.href=`/api/export?format=${i}`,s.download="",document.body.appendChild(s),s.click(),document.body.removeChild(s)};return g.jsxs("div",{className:"export-wrapper",ref:n,children:[g.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Export document",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),g.jsx("polyline",{points:"7 10 12 15 17 10"}),g.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),t&&g.jsxs("div",{className:"export-dropdown",children:[g.jsx("div",{className:"export-dropdown__header",children:"Export"}),g.jsx("div",{className:"export-dropdown__list",children:JL.map(i=>g.jsxs("div",{className:"export-dropdown__item",onClick:()=>r(i.key),children:[g.jsx("span",{className:"export-dropdown__item-icon",children:i.icon}),g.jsxs("span",{className:"export-dropdown__item-text",children:[g.jsx("span",{className:"export-dropdown__item-label",children:i.label}),g.jsx("span",{className:"export-dropdown__item-desc",children:i.desc})]})]},i.key))})]})]})}const QL=[{key:"tweet",label:"Tweet",desc:"Compose a tweet",icon:g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})},{key:"reply",label:"Reply",desc:"Reply to a tweet",needsUrl:!0,icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("polyline",{points:"9 17 4 12 9 7"}),g.jsx("path",{d:"M20 18v-2a4 4 0 0 0-4-4H4"})]})},{key:"quote",label:"Quote Tweet",desc:"Quote a tweet",needsUrl:!0,icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V21z"}),g.jsx("path",{d:"M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z"})]})},{key:"article",label:"Article",desc:"Long-form article",icon:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),g.jsx("path",{d:"M14 2v6h6"}),g.jsx("path",{d:"M16 13H8"}),g.jsx("path",{d:"M16 17H8"}),g.jsx("path",{d:"M10 9H8"})]})}];function XL({onCreateTemplate:t}){const[e,n]=N.useState(!1),[r,i]=N.useState(null),[s,l]=N.useState(""),c=N.useRef(null),u=N.useRef(null);N.useEffect(()=>{if(!e)return;const b=x=>{c.current&&!c.current.contains(x.target)&&(n(!1),i(null),l(""))};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[e]),N.useEffect(()=>{r&&setTimeout(()=>{var b;return(b=u.current)==null?void 0:b.focus()},0)},[r]);const f=b=>{if(b.needsUrl){i(b.key),l("");return}n(!1),t(b.key)},p=()=>{if(!r||!s.trim())return;const b=s.trim();!b.includes("x.com")&&!b.includes("twitter.com")||(n(!1),i(null),l(""),t(r,b))},h=b=>{b.key==="Enter"&&(b.preventDefault(),p()),b.key==="Escape"&&(i(null),l(""))},y=s.trim().includes("x.com")||s.trim().includes("twitter.com");return g.jsxs("div",{className:"template-wrapper",ref:c,children:[g.jsx("button",{className:`titlebar-nav-btn${e?" titlebar-nav-btn--active":""}`,onClick:()=>{n(!e),i(null),l("")},title:"Create from template",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),g.jsx("path",{d:"M3 9h18"}),g.jsx("path",{d:"M9 3v18"})]})}),e&&g.jsxs("div",{className:"template-dropdown",children:[g.jsx("div",{className:"template-dropdown__header",children:"Templates"}),g.jsx("div",{className:"template-dropdown__list",children:QL.map(b=>g.jsxs("div",{children:[g.jsxs("div",{className:`template-dropdown__item${r===b.key?" template-dropdown__item--active":""}`,onClick:()=>f(b),children:[g.jsx("span",{className:"template-dropdown__item-icon",children:b.icon}),g.jsxs("span",{className:"template-dropdown__item-text",children:[g.jsx("span",{className:"template-dropdown__item-label",children:b.label}),g.jsx("span",{className:"template-dropdown__item-desc",children:b.desc})]})]}),r===b.key&&g.jsxs("div",{className:"template-url-row",children:[g.jsx("input",{ref:u,className:"template-url-input",type:"text",placeholder:"Paste tweet URL...",value:s,onChange:x=>l(x.target.value),onKeyDown:h}),g.jsx("button",{className:"template-url-submit",onClick:p,disabled:!y,title:"Create template",children:g.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},b.key))})]})]})}const ZL=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:g.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"})}),eD=()=>g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.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"}),g.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),tD=()=>g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.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"}),g.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),nD=()=>g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.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"}),g.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function rD({title:t,onTitleChange:e,syncStatus:n,onSync:r,onToggleSidebar:i,canGoBack:s,canGoForward:l,onGoBack:c,onGoForward:u,editor:f,onToggleToolbar:p,toolbarOpen:h,onCreateTemplate:y}){const[b,x]=N.useState(!1),[,E]=N.useState(0),w=N.useRef(null),[S,_]=N.useState(!1),[M,T]=N.useState([]),[O,P]=N.useState(!1),B=N.useRef(null),Q=N.useCallback(()=>{x(!0),setTimeout(()=>{var K;return(K=w.current)==null?void 0:K.select()},0)},[]),X=N.useCallback(()=>{x(!1)},[]),J=N.useCallback(K=>{K.key==="Enter"&&x(!1),K.key==="Escape"&&x(!1)},[]),fe=N.useCallback(()=>{if(S){_(!1);return}_(!0),P(!0),fetch("/api/sync/pending").then(K=>K.json()).then(K=>T(K)).catch(()=>T([])).finally(()=>P(!1))},[S]);return N.useEffect(()=>{n.state!=="pending"&&_(!1)},[n.state]),N.useEffect(()=>{if(!S)return;const K=W=>{B.current&&!B.current.contains(W.target)&&_(!1)};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[S]),N.useEffect(()=>{if(!f)return;const K=()=>E(W=>W+1);return f.on("transaction",K),()=>{f.off("transaction",K)}},[f]),g.jsxs("div",{className:"titlebar",children:[g.jsxs("div",{className:"titlebar-left",children:[i&&g.jsx("button",{className:"titlebar-menu-btn",onClick:i,title:"Open sidebar",children:g.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:[g.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),g.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"1.5"}),g.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),c&&g.jsx("button",{className:"titlebar-nav-btn",onClick:c,disabled:!s,title:"Go back (Alt+Left)",children:g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),u&&g.jsx("button",{className:"titlebar-nav-btn",onClick:u,disabled:!l,title:"Go forward (Alt+Right)",children:g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),f&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"titlebar-divider"}),g.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo (Ctrl+Z)",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),g.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),g.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo (Ctrl+Y)",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),g.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),g.jsx("div",{className:"titlebar-center",children:b?g.jsx("input",{ref:w,className:"titlebar-input",value:t,onChange:K=>e(K.target.value),onBlur:X,onKeyDown:J,autoFocus:!0}):g.jsx("span",{className:"titlebar-title",onDoubleClick:Q,children:t})}),g.jsxs("div",{className:"titlebar-right",children:[p&&g.jsx("button",{className:`titlebar-nav-btn${h?" titlebar-nav-btn--active":""}`,onClick:p,title:"Toggle format toolbar",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M4 20h16"}),g.jsx("path",{d:"m6 16 6-12 6 12"}),g.jsx("path",{d:"M8 12h8"})]})}),y&&g.jsx(XL,{onCreateTemplate:y}),g.jsx(VL,{}),g.jsx(HL,{}),g.jsx(qL,{}),g.jsx(YL,{}),g.jsxs("div",{className:"sync-btn-group",ref:B,children:[g.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"&&g.jsxs(g.Fragment,{children:[g.jsx(ZL,{})," Sync"]}),n.state==="synced"&&g.jsxs(g.Fragment,{children:[g.jsx(eD,{})," Synced"]}),n.state==="pending"&&g.jsxs(g.Fragment,{children:[g.jsx(tD,{})," Sync",n.pendingFiles?` (${n.pendingFiles})`:""]}),n.state==="syncing"&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),n.state==="error"&&g.jsxs(g.Fragment,{children:[g.jsx(nD,{})," Retry"]})]}),n.state==="pending"&&n.pendingFiles&&n.pendingFiles>0&&g.jsx("button",{className:"sync-details-btn",onClick:fe,title:"View pending changes",children:g.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:g.jsx("path",{d:S?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),S&&g.jsxs("div",{className:"sync-pending-dropdown",children:[g.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),O?g.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):M.length===0?g.jsx("div",{className:"sync-pending-loading",children:"No changes"}):g.jsx("div",{className:"sync-pending-list",children:M.map((K,W)=>g.jsxs("div",{className:`sync-pending-item sync-file-${K.status}`,children:[g.jsx("span",{className:"sync-file-badge",children:K.status[0].toUpperCase()}),g.jsx("span",{className:"sync-file-name",children:K.file})]},W))})]})]})]})]})}function ln(t,e){let n=null;return t.state.doc.descendants((r,i)=>{var s;return((s=r.attrs)==null?void 0:s.id)===e?(n={node:r,pos:i},!1):!0}),n}function Xu(t,e){const n=[];return t.state.doc.descendants((r,i)=>{var s;return((s=r.attrs)==null?void 0:s.pendingGroupId)===e&&n.push({nodeId:r.attrs.id,pos:i,node:r}),!0}),n}function xo(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function Ru(t){return t?Array.isArray(t)?t.map(Ru).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>Ru(e)).join(""):"":""}const iD=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Iu(t,e){for(const n of t)n.type&&iD.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Iu(n.content,e)}function ch(t,e,n){const r=Array.isArray(n)?n:[n];if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const b=ln(t,e.nodeId);if(!b)return{success:!1,error:`Node ${e.nodeId} not found`};const x=r.map((E,w)=>{var S;return{...E,attrs:{...E.attrs,id:((S=E.attrs)==null?void 0:S.id)||(w===0?e.nodeId:xo())}}});Iu(x,"insert");try{return t.chain().deleteRange({from:b.pos,to:b.pos+b.node.nodeSize}).insertContentAt(b.pos,x).run(),{success:!0,nodeId:e.nodeId}}catch(E){return{success:!1,error:`Failed to replace empty node: ${E}`}}}if(!e.afterNodeId&&!e.beforeNodeId)return{success:!1,error:"Insert requires afterNodeId, beforeNodeId, or nodeId"};const i=e.afterNodeId||e.beforeNodeId,s=!!e.afterNodeId,l=ln(t,i);if(!l)return{success:!1,error:`Anchor node ${i} not found`};const c=Ru(n),u=s?l.pos+l.node.nodeSize:0,f=s?l.pos+l.node.nodeSize+5e3:l.pos;let p=null;if(t.state.doc.nodesBetween(u,Math.min(f,t.state.doc.content.size),b=>{var x,E;return((x=b.attrs)==null?void 0:x.pendingStatus)==="insert"&&((E=b.attrs)!=null&&E.id)&&(b.textContent||"")===c?(p=b.attrs.id,!1):!0}),p)return{success:!0,nodeId:p};const h=r.map(b=>{var x;return{...b,attrs:{...b.attrs,id:((x=b.attrs)==null?void 0:x.id)||xo()}}});Iu(h,"insert");const y=s?l.pos+l.node.nodeSize:l.pos;try{return t.chain().insertContentAt(y,h).run(),{success:!0,nodeId:h[0].attrs.id}}catch(b){return{success:!1,error:`Failed to insert content: ${b}`}}}function pm(t,e,n,r){var b;const i=ln(t,e);if(!i)return{success:!1,error:`Node ${e} not found`};const{node:s,pos:l}=i,c=Array.isArray(n)?n:[n],f=!((b=s.attrs)!=null&&b.pendingOriginalContent)?s.toJSON():s.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}:{}}},h=c.slice(1).map(x=>{var E;return{...x,attrs:{...x.attrs,id:((E=x.attrs)==null?void 0:E.id)||xo()}}});Iu(h,"insert");const y=[p,...h];try{return t.chain().deleteRange({from:l,to:l+s.nodeSize}).insertContentAt(l,y.length===1?y[0]:y).run(),{success:!0,nodeId:e}}catch(x){return{success:!1,error:`Failed to rewrite: ${x}`}}}function sD(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(h=>Ru(h)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const i=ln(t,e[0]),s=ln(t,e[e.length-1]);if(!i||!s)return{success:!1,error:"Could not find original nodes for range rewrite"};const l=[];for(const h of e){const y=ln(t,h);y&&l.push(y.node.toJSON())}const c=i.pos,u=s.pos+s.node.nodeSize,f=xo()+xo(),p=n.map((h,y)=>{var b;return{...h,attrs:{...h.attrs,id:((b=h.attrs)==null?void 0:b.id)||xo(),pendingStatus:"rewrite",pendingGroupId:f,...y===0?{pendingOriginalContent:l}:{}}}});try{return t.chain().deleteRange({from:c,to:u}).insertContentAt(c,p).run(),{success:!0,nodeId:p[0].attrs.id}}catch(h){return{success:!1,error:`Failed to apply range rewrite: ${h}`}}}function i1(t,e){var s;const n=ln(t,e);if(!n)return{success:!1,error:`Node ${e} not found`};const{node:r,pos:i}=n;if(((s=r.attrs)==null?void 0:s.pendingStatus)==="delete")return{success:!0,nodeId:e};try{return t.chain().command(({tr:l})=>(l.setNodeMarkup(i,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 oD(t,e){if(e.operation==="rewrite"&&e.nodeId&&e.content){const n=pm(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=ch(t,n,e.content);return{success:r.success,error:r.error}}if(e.operation==="delete"&&e.nodeId){const n=i1(t,e.nodeId);return{success:n.success,error:n.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function lD(t,e){if(e.length===0)return;if(e.length===1){oD(t,e[0]);return}const n=t.state.schema;t.chain().command(({tr:r})=>{var i;for(const s of e)try{if(s.operation==="rewrite"&&s.nodeId&&s.content){const l=_c(r.doc,s.nodeId);if(!l)continue;const u=(Array.isArray(s.content)?s.content:[s.content]).map(f=>n.nodeFromJSON(f));r.replaceWith(l.pos,l.pos+l.node.nodeSize,u)}else if(s.operation==="insert"&&s.content){const c=(Array.isArray(s.content)?s.content:[s.content]).map(u=>n.nodeFromJSON(u));if(s.nodeId&&!s.afterNodeId){const u=_c(r.doc,s.nodeId);if(!u)continue;r.replaceWith(u.pos,u.pos+u.node.nodeSize,c)}else if(s.afterNodeId){const u=_c(r.doc,s.afterNodeId);if(!u)continue;const f=u.pos+u.node.nodeSize;r.insert(f,re.fromArray(c))}}else if(s.operation==="delete"&&s.nodeId){const l=_c(r.doc,s.nodeId);if(!l||((i=l.node.attrs)==null?void 0:i.pendingStatus)==="delete")continue;r.setNodeMarkup(l.pos,void 0,{...l.node.attrs,pendingStatus:"delete"})}}catch{continue}return!0}).run()}function _c(t,e){let n=null;return t.descendants((r,i)=>{var s;return((s=r.attrs)==null?void 0:s.id)===e?(n={node:r,pos:i},!1):!0}),n}function tv(t,e,n,r){const i=[];if(r==="delete"){for(const l of n)i.push(i1(t,l));return i}if(r==="insert"){const l=n[n.length-1];return l&&e.length>0&&i.push(ch(t,{nodeId:l},e)),i}if(n.length>1){const l=sD(t,n,e);return i.push(l),i}const s=pm(t,n[0],e[0]);if(i.push(s),e.length>1){const l=e.slice(1);i.push(ch(t,{afterNodeId:n[0]},l))}return i}const nv="[[START_SELECTION]]",rv="[[END_SELECTION]]";function aD(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 Tc(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=aD(t);let i=Math.max(0,Math.min(e,r));for(let s=0;s<t.content.length;s++){const l=t.content[s];if(l.type==="text"&&typeof l.text=="string"){if(i<=l.text.length){const c=Math.max(0,Math.min(l.text.length,i));l.text=l.text.slice(0,c)+n+l.text.slice(c);return}i-=l.text.length;continue}if(l.type==="hardBreak"){if(i===0){t.content.splice(s+1,0,{type:"text",text:n});return}i-=1;continue}if(i===0){t.content.splice(s,0,{type:"text",text:n});return}}t.content.push({type:"text",text:n})}function cD(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(Tc(r[0],n,rv),Tc(r[0],e,nv),r):(Tc(r[0],e,nv),Tc(r[r.length-1],n,rv),r)}function uD(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 dD=[{action:"agent-mark",label:"Agent Mark",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function fD({editorRef:t,documentId:e}){const[n,r]=N.useState(!1),[i,s]=N.useState({x:0,y:0}),[l,c]=N.useState(!1),[u,f]=N.useState(""),[p,h]=N.useState(!1),[y,b]=N.useState(""),[x,E]=N.useState(!1),[w,S]=N.useState([]),[_,M]=N.useState([]),[T,O]=N.useState(!1),[P,B]=N.useState(""),[Q,X]=N.useState([]),[J,fe]=N.useState(!1),[K,W]=N.useState(""),$=N.useRef(null),Z=N.useRef(null);N.useLayoutEffect(()=>{const z=$.current;if(!z||!n)return;const q=z.getBoundingClientRect(),Y=8;let{x:ne,y:Me}=i;Me+q.height+Y>window.innerHeight&&(Me=i.y-q.height),ne+q.width+Y>window.innerWidth&&(ne=i.x-q.width),Me<Y&&(Me=Y),ne<Y&&(ne=Y),(ne!==i.x||Me!==i.y)&&s({x:ne,y:Me})},[n,i]);const ee=N.useCallback(()=>{fetch("/api/plugins").then(z=>z.json()).then(z=>{const q=[];for(const Y of z.plugins||[]){const ne=Y.displayName||void 0;for(const Me of Y.contextMenuItems||[])q.push({...Me,pluginDisplayName:ne})}X(q)}).catch(()=>{})},[]);N.useEffect(()=>{ee()},[ee]),N.useEffect(()=>{const z=()=>ee();return window.addEventListener("ow-plugins-changed",z),()=>window.removeEventListener("ow-plugins-changed",z)},[ee]),N.useEffect(()=>{const z=q=>{$.current&&!$.current.contains(q.target)&&(r(!1),h(!1),E(!1),fe(!1),W(""))};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[]);const he=N.useCallback(()=>{const z=t.current;return z?z.isActive("link"):!1},[t]),G=N.useCallback(()=>{const z=t.current,q=Z.current;if(!z||!q)return!1;const{from:Y,to:ne}=q;let Me=!1;return z.state.doc.nodesBetween(Y,ne,H=>{var ke;return(ke=H.attrs)!=null&&ke.pendingStatus&&(Me=!0),!Me}),Me},[t]),se=N.useCallback(()=>{const z=t.current,q=Z.current,Y=(q==null?void 0:q.from)??0,ne=(q==null?void 0:q.to)??0,Me=Y!==ne,H=(()=>{if(!z)return!1;try{return z.state.doc.resolve(Y).parent.content.size===0}catch{return!1}})(),ke=G(),we=[];for(const $e of Q)$e.condition==="has-selection"&&!Me||$e.condition==="empty-node"&&!H||we.push({action:$e.action,label:$e.label,shortcut:$e.shortcut,isPlugin:!0,promptForInput:$e.promptForInput,pluginDisplayName:$e.pluginDisplayName});for(const $e of dD)$e.condition==="has-selection"&&(!Me||ke)||we.push($e);return Me&&we.push({action:"link",label:"Link to doc",shortcut:"L"}),he()&&we.push({action:"unlink",label:"Unlink"}),we},[t,he,Q,G]);N.useEffect(()=>{const z=Y=>{var Ae;if(Y.button!==2)return;const ne=t.current;if(!ne||!ne.view.dom.contains(Y.target))return;const{from:H,to:ke}=ne.state.selection,we=[],$e=[];if(H!==ke&&ne.state.doc.nodesBetween(H,ke,je=>{je.isBlock&&je.type.name!=="doc"&&(we.push(je.toJSON()),je.attrs.id&&$e.push(je.attrs.id))}),we.length===0){const{$from:je}=ne.state.selection,ze=je.parent;ze&&ze.type.name!=="doc"&&(we.push(ze.toJSON()),(Ae=ze.attrs)!=null&&Ae.id&&$e.push(ze.attrs.id))}Z.current={from:H,to:ke,nodes:we,nodeIds:$e}},q=Y=>{const ne=t.current;!ne||!ne.view.dom.contains(Y.target)||(Y.preventDefault(),s({x:Y.clientX,y:Y.clientY}),r(!0),h(!1),E(!1),fe(!1),W(""))};return document.addEventListener("mousedown",z,!0),document.addEventListener("contextmenu",q),()=>{document.removeEventListener("mousedown",z,!0),document.removeEventListener("contextmenu",q)}},[t]);const ie=N.useCallback(async(z,q)=>{var yn,tt,gt,et,Vn,Jt,tr;const Y=t.current;if(!Y)return;const ne=Z.current;if(!ne||ne.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",z);return}let{nodes:Me,nodeIds:H}=ne;const{from:ke,to:we}=ne;c(!0),r(!1),h(!1);const $e=`ctx-${Date.now()}`,Ae=Y.state.doc.resolve(ke),je=Y.state.doc.resolve(we),ze=Ae.sameParent(je)&&ke!==we;Y.commands.applyLoadingEffect($e,ke,we,ze?"selection":"paragraph");try{const Xt=[],bn=[],Kn=new Set(H);let Mr=!1;const nr=Y.state.doc;for(let kt=0;kt<nr.childCount;kt++){const vn=nr.child(kt),xn=(yn=vn.attrs)==null?void 0:yn.id;if(xn&&Kn.has(xn))Mr=!0;else if(Mr){const Ht=vn.textContent.trim();Ht&&bn.push(Ht)}else{const Ht=vn.textContent.trim();Ht&&Xt.push(Ht)}}const Gn=z.includes(":")?z.split(":").slice(1).join(":"):z;let Ar=Me,gr=!1,Pn=0,ae=0;if(ze&&Me.length===1){const kt=Ae.start(Ae.depth);Pn=ke-kt,ae=we-kt;const vn=((gt=(tt=Me[0])==null?void 0:tt.content)==null?void 0:gt.reduce((xn,Ht)=>{var I;return xn+(((I=Ht.text)==null?void 0:I.length)||(Ht.type==="hardBreak"?1:0))},0))??0;(Pn>0||ae<vn)&&(Ar=cD(Me,Pn,ae),gr=!0)}const Le=Y.state.doc.textContent,ft={nodes:Ar,action:Gn,nodeIds:H,contextBefore:Xt.slice(-3),contextAfter:bn.slice(0,3),fullDocument:Le,documentId:e,debug:!0};gr&&(ft.hasSelectionMarkers=!0),q&&(ft.instruction=q);const Bt=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ft)});if(!Bt.ok){const kt=await Bt.json().catch(()=>({}));console.error("[ContextMenu] API error:",Bt.status,kt);return}const Ut=await Bt.json();if(Ut.success&&Ut.nodes){let kt=Ut.nodes;if(kt.length===1&&Array.isArray(kt[0])&&(kt=kt[0]),uD(kt),gr&&kt.length===1&&H.length===1){const vn=((Vn=(et=Me[0])==null?void 0:et.content)==null?void 0:Vn.map(I=>I.text||"").join(""))??"",xn=((tr=(Jt=kt[0])==null?void 0:Jt.content)==null?void 0:tr.map(I=>I.text||"").join(""))??"",Ht={selectionFrom:Pn,selectionTo:xn.length-(vn.length-ae),originalFrom:Pn,originalTo:ae};pm(Y,H[0],kt[0],Ht)}else tv(Y,kt,H,Gn);Ut.debug&&fetch("/api/prompt-debug",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:Gn,debug:Ut.debug,metadata:Ut.metadata})}).catch(()=>{})}else console.warn("[ContextMenu] Unexpected response:",Ut)}catch(Xt){console.error("[ContextMenu] Plugin action failed:",Xt)}finally{Y.commands.removeLoadingEffect($e),c(!1)}},[t]),R=N.useCallback(async z=>{const q=t.current;if(!q)return;const{$from:Y}=q.state.selection,ne=Y.before(Y.depth),Me=Y.after(Y.depth),H=Y.parent.content.size===0;c(!0),r(!1),h(!1);const ke=`ctx-img-${Date.now()}`;q.commands.applyLoadingEffect(ke,ne,Me,"paragraph");try{const $e=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:z})})).json();$e.success&&$e.src?H?q.chain().focus().deleteRange({from:ne,to:Me}).insertContentAt(ne,{type:"image",attrs:{src:$e.src,alt:z}}).run():q.chain().focus().insertContentAt(Me,{type:"image",attrs:{src:$e.src,alt:z}}).run():console.error("[ContextMenu] Image generation failed:",$e.error)}catch(we){console.error("[ContextMenu] Image generation failed:",we)}finally{q.commands.removeLoadingEffect(ke),c(!1)}},[t]),j=N.useCallback(z=>{const{action:q,isPlugin:Y,promptForInput:ne}=z;if(Y&&ne){b(q),h(!0);return}if(Y){if(q.startsWith("img:"))return;ie(q);return}if(q==="agent-mark"){fe(!0);return}if(q==="delete"){const Me=t.current;if(Me){const{from:H,to:ke}=Me.state.selection;Me.state.doc.nodesBetween(H,ke,we=>{we.isBlock&&we.type.name!=="doc"&&we.attrs.id&&tv(Me,[],[we.attrs.id],"delete")})}r(!1);return}if(q==="link"){const Me=t.current;if(Me){const H=[];Me.state.doc.descendants(ke=>{var we;(we=ke.marks)==null||we.forEach($e=>{var Ae,je;if($e.type.name==="link"&&((je=(Ae=$e.attrs)==null?void 0:Ae.href)!=null&&je.startsWith("doc:"))){const ze=$e.attrs.href.slice(4);H.includes(ze)||H.push(ze)}})}),M(H)}fetch("/api/documents").then(H=>H.json()).then(H=>{Array.isArray(H)&&S(H.map(ke=>({filename:ke.filename,title:ke.title}))),O(!1),B(""),E(!0)}).catch(()=>{});return}if(q==="unlink"){const Me=t.current;Me&&Me.chain().focus().unsetLink().run(),r(!1);return}},[ie,t]),le=N.useCallback(()=>{u.trim()&&(y.startsWith("img:")?R(u.trim()):ie(y,u.trim()),f(""),b(""))},[ie,R,y,u]),ye=N.useCallback(()=>{const z=t.current,q=Z.current;if(!z||!q||!e)return;const{from:Y,to:ne,nodeIds:Me}=q;if(Y===ne||Me.length===0)return;const H=z.state.doc.textBetween(Y,ne,`
|
|
204
|
+
`);H.trim()&&fetch("/api/marks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:e,text:H,note:K.trim(),nodeId:Me[0]})}).then(()=>{r(!1),fe(!1),W("")}).catch(ke=>{console.error("[ContextMenu] Agent mark failed:",ke)})},[t,e,K]),Ee=N.useCallback(z=>{const q=t.current;q&&q.chain().focus().setLink({href:`doc:${z}`}).run(),fetch("/api/auto-tag-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetFile:z})}).catch(()=>{}),r(!1),E(!1)},[t]),oe=N.useCallback(()=>{const z=P.trim();if(!z)return;const q=t.current;q&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:z})}).then(Y=>Y.json()).then(Y=>{Y.filename&&q.chain().focus().setLink({href:`doc:${Y.filename}`}).run()}).catch(()=>{}),r(!1),E(!1),O(!1),B(""))},[t,P]);return n?g.jsx("div",{ref:$,className:"context-menu",style:{left:i.x,top:i.y},children:l?g.jsx("div",{className:"context-menu-loading",children:"Applying..."}):J?g.jsxs("div",{className:"context-menu-custom",children:[g.jsx("input",{autoFocus:!0,value:K,onChange:z=>W(z.target.value),onKeyDown:z=>{z.key==="Enter"&&ye(),z.key==="Escape"&&(fe(!1),W(""))},placeholder:"Note for agent (optional)..."}),g.jsx("button",{onClick:ye,children:"Mark"})]}):p?g.jsxs("div",{className:"context-menu-custom",children:[g.jsx("input",{autoFocus:!0,value:u,onChange:z=>f(z.target.value),onKeyDown:z=>{z.key==="Enter"&&le(),z.key==="Escape"&&r(!1)},placeholder:"Custom instruction..."}),g.jsx("button",{onClick:le,children:"Apply"})]}):x?g.jsxs("div",{className:"context-menu-link-picker",children:[g.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),T?g.jsxs("div",{className:"context-menu-custom",children:[g.jsx("input",{autoFocus:!0,value:P,onChange:z=>B(z.target.value),onKeyDown:z=>{z.key==="Enter"&&oe(),z.key==="Escape"&&O(!1)},placeholder:"New document title..."}),g.jsx("button",{onClick:oe,children:"Create"})]}):g.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>O(!0),children:g.jsx("span",{children:"+ New link doc"})}),g.jsxs("div",{className:"context-menu-link-list",children:[_.length>0&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),w.filter(z=>_.includes(z.filename)).map(({filename:z,title:q})=>g.jsx("button",{className:"context-menu-item",onClick:()=>Ee(z),children:g.jsx("span",{children:q})},`linked-${z}`))]}),g.jsx("div",{className:"context-menu-section-header",children:"All documents"}),w.filter(z=>!_.includes(z.filename)).map(({filename:z,title:q})=>g.jsx("button",{className:"context-menu-item",onClick:()=>Ee(z),children:g.jsx("span",{children:q})},z)),w.length===0&&g.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const z=se();let q;return z.map((Y,ne)=>{const Me=Y.isPlugin&&Y.pluginDisplayName&&Y.pluginDisplayName!==q,H=q!==void 0;Y.isPlugin?q=Y.pluginDisplayName:q=void 0;const ke=!Y.isPlugin&&H;return g.jsxs("span",{children:[Me&&g.jsx("div",{className:"context-menu-section-header",children:Y.pluginDisplayName}),ke&&g.jsx("div",{className:"context-menu-divider"}),g.jsxs("button",{className:"context-menu-item",onClick:()=>j(Y),children:[g.jsx("span",{children:Y.label}),Y.shortcut&&g.jsx("span",{className:"context-menu-shortcut",children:Y.shortcut})]})]},Y.action)})})()}):null}function hm(t,e,n){let r=t.resolve(e);for(;r.depth>0;){const i=r.node(r.depth),s=r.before(r.depth),l=s+i.nodeSize;if(i.childCount===1)e=s,n=l,r=t.resolve(e);else break}return{from:e,to:n}}function pD(t,e){const n=ln(t,e);if(!n)return!1;const{node:r,pos:i}=n;return t.chain().command(({tr:s})=>(s.setNodeMarkup(i,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function hD(t,e){const n=ln(t,e);if(!n)return!1;const{node:r,pos:i}=n;return t.chain().command(({tr:s})=>(s.setNodeMarkup(i,void 0,{...r.attrs,pendingStatus:null,pendingOriginalContent:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run(),!0}function mD(t,e){var l;const n=ln(t,e);if(!n)return!1;const{node:r,pos:i}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="delete")return!0;const s=hm(t.state.doc,i,i+r.nodeSize);return t.chain().deleteRange(s).run(),!0}function gD(t,e){var l;const n=ln(t,e);if(!n)return!0;const{node:r,pos:i}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="insert")return!0;const s=hm(t.state.doc,i,i+r.nodeSize);return t.chain().deleteRange(s).run(),!0}function yD(t,e){var l,c;const n=ln(t,e);if(!n)return!1;const{node:r,pos:i}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="rewrite")return!0;const s=(c=r.attrs)==null?void 0:c.pendingOriginalContent;if(s)t.chain().deleteRange({from:i,to:i+r.nodeSize}).insertContentAt(i,s).run();else{const u=hm(t.state.doc,i,i+r.nodeSize);t.chain().deleteRange(u).run()}return!0}function bD(t,e){var s;const n=ln(t,e);if(!n)return!1;const{node:r,pos:i}=n;return((s=r.attrs)==null?void 0:s.pendingStatus)!=="delete"||t.chain().command(({tr:l})=>(l.setNodeMarkup(i,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function vD(t,e){const n=Xu(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const i=ln(t,r.nodeId);i&&t.chain().command(({tr:s})=>(s.setNodeMarkup(i.pos,void 0,{...i.node.attrs,pendingStatus:null,pendingOriginalContent:null,pendingGroupId:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run()}return!0}function xD(t,e){var c;const n=Xu(t,e);if(n.length===0)return!1;const r=(c=n[0].node.attrs)==null?void 0:c.pendingOriginalContent,i=n[0].pos,s=n[n.length-1],l=s.pos+s.node.nodeSize;try{return r&&Array.isArray(r)&&r.length>0?t.chain().deleteRange({from:i,to:l}).insertContentAt(i,r).run():t.chain().deleteRange({from:i,to:l}).run(),!0}catch{return!1}}function s1(t,e){var s,l;const n=ln(t,e);if(!n)return!1;const r=(s=n.node.attrs)==null?void 0:s.pendingGroupId;if(r)return vD(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return pD(t,e);case"rewrite":return hD(t,e);case"delete":return mD(t,e);default:return!1}}function o1(t,e){var s,l;const n=ln(t,e);if(!n)return!1;const r=(s=n.node.attrs)==null?void 0:s.pendingGroupId;if(r)return xD(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return gD(t,e);case"rewrite":return yD(t,e);case"delete":return bD(t,e);default:return!1}}function kD(t){const e=l1(t).reverse();for(const n of e)s1(t,n);t.view&&fm(t.view)}function wD(t){const e=l1(t).reverse();for(const n of e)o1(t,n);t.view&&fm(t.view)}function mm(t){const e=[],n=new Set;return t.state.doc.descendants((r,i)=>{var l,c,u;const s=(l=r.attrs)==null?void 0:l.pendingStatus;if(s&&((c=r.attrs)!=null&&c.id)){const f=(u=r.attrs)==null?void 0:u.pendingGroupId;if(f){if(n.has(f))return!0;n.add(f)}e.push({nodeId:r.attrs.id,pos:i,pendingStatus:s,groupId:f,editor:t})}return!0}),e}function wp(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...mm(n));return e}function l1(t){return mm(t).map(e=>e.nodeId)}function ED(t){let e=0,n=0,r=0;for(const i of t)i.pendingStatus==="insert"?e++:i.pendingStatus==="rewrite"?n++:i.pendingStatus==="delete"&&r++;return{insert:e,rewrite:n,delete:r,total:t.length}}function gl(t,e){if(t.isDestroyed)return;let n=-1;if(t.state.doc.descendants((i,s)=>{var l;return((l=i.attrs)==null?void 0:l.id)===e?(n=s,!1):!0}),n===-1)return;const r=t.view.nodeDOM(n);r&&r instanceof HTMLElement&&r.scrollIntoView({behavior:"smooth",block:"center"})}function SD(t){const[e,n]=N.useState([]),[r,i]=N.useState(0),s=N.useRef(),l=N.useRef(new Set),c=N.useCallback(()=>{const S=t.filter(P=>P&&!P.isDestroyed);if(S.length===0){n([]),l.current=new Set;return}const _=wp(S);n(_);const M=l.current,T=new Set(_.map(P=>P.nodeId));let O=-1;if(M.size>0){for(let P=0;P<_.length;P++)if(!M.has(_[P].nodeId)){O=P;break}}l.current=T,O>=0?(i(O),gl(_[O].editor,_[O].nodeId)):_.length===0?i(0):i(P=>Math.min(P,_.length-1))},[t]);N.useEffect(()=>{const S=t.filter(T=>T&&!T.isDestroyed);if(S.length===0)return;const _=()=>{clearTimeout(s.current),s.current=setTimeout(c,50)};for(const T of S)T.on("transaction",_);c();const M=setTimeout(()=>{const T=wp(S.filter(O=>!O.isDestroyed));T.length>0&&gl(T[0].editor,T[0].nodeId)},150);return()=>{for(const T of S)T.isDestroyed||T.off("transaction",_);clearTimeout(s.current),clearTimeout(M)}},[t,c]),N.useEffect(()=>{const S=e[r]??null;return K0((S==null?void 0:S.nodeId)??null,(S==null?void 0:S.groupId)??null),S!=null&&S.editor&&!S.editor.isDestroyed&&S.editor.view&&fm(S.editor.view),()=>{K0(null)}},[r,e]);const u=ED(e),f=e[r]??null,p=N.useCallback(()=>{if(e.length===0)return;const S=(r+1)%e.length;i(S),e[S]&&gl(e[S].editor,e[S].nodeId)},[e,r]),h=N.useCallback(()=>{if(e.length===0)return;const S=(r-1+e.length)%e.length;i(S),e[S]&&gl(e[S].editor,e[S].nodeId)},[e,r]),y=N.useCallback(()=>{const S=t.filter(T=>T&&!T.isDestroyed),_=wp(S);if(_.length===0)return;const M=Math.min(r,_.length-1);gl(_[M].editor,_[M].nodeId)},[t,r]),b=N.useCallback(()=>{f&&(s1(f.editor,f.nodeId),c(),y())},[f,c,y]),x=N.useCallback(()=>{f&&(o1(f.editor,f.nodeId),c(),y())},[f,c,y]),E=N.useCallback(()=>{const S=t.filter(_=>_&&!_.isDestroyed);for(const _ of S)kD(_);c()},[t,c]),w=N.useCallback(()=>{const S=t.filter(_=>_&&!_.isDestroyed);for(const _ of S)wD(_);c()},[t,c]);return{pendingNodes:e,counts:u,currentNode:f,currentIndex:r,hasPending:u.total>0,goToNext:p,goToPrevious:h,acceptCurrent:b,rejectCurrent:x,acceptAll:E,rejectAll:w,refresh:c}}const To={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},CD=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...To})}),iv=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...To})}),ND=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...To})}),_D=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...To})}),sv=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...To})}),ov=()=>g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:g.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...To})});function a1(t,e,n){const r=ln(t,e);if(!r)return!1;const{pos:i,node:s}=r,l={type:n.type||s.type.name,attrs:{...n.attrs||{},id:s.attrs.id,pendingStatus:s.attrs.pendingStatus,pendingOriginalContent:s.attrs.pendingOriginalContent,pendingSelectionFrom:s.attrs.pendingSelectionFrom,pendingSelectionTo:s.attrs.pendingSelectionTo,pendingOriginalFrom:s.attrs.pendingOriginalFrom,pendingOriginalTo:s.attrs.pendingOriginalTo},content:n.content};try{return t.chain().command(({tr:c})=>(c.setMeta("addToHistory",!1),!0)).deleteRange({from:i,to:i+s.nodeSize}).insertContentAt(i,l).run(),!0}catch{return!1}}function c1(t,e,n){const r=Xu(t,e);if(r.length===0)return!1;const i=r[0].pos,s=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:i,to:s}).insertContentAt(i,n).run(),!0}catch{return!1}}function Mc(t,e){if(!dm()||!e)return!1;const n=PL(),r=DL();return r&&n&&Array.isArray(n)?c1(t,r,n):n&&a1(t,e,n),lh(!1),!0}function TD({editors:t,pendingDocs:e,currentFilename:n,onSwitchDocument:r,sendMessage:i,getDocument:s}){const{counts:l,currentNode:c,currentIndex:u,hasPending:f,goToNext:p,goToPrevious:h,acceptCurrent:y,rejectCurrent:b,acceptAll:x,rejectAll:E}=SD(t),[w,S]=N.useState(!1),_=N.useRef(null),M=N.useRef(null),T=e.filenames.length,O=lv(e.filenames,n)>=0?T-1:T,P=f||T>0,B=lv(e.filenames,n),Q=(c==null?void 0:c.pendingStatus)==="rewrite",X=!!(c!=null&&c.groupId),J=Q,fe=N.useCallback(()=>{var j,le;const R=c==null?void 0:c.editor;if(!(!R||!c||c.pendingStatus!=="rewrite"))if(w)M.current&&Mc(M.current,_.current),_.current=null,M.current=null,S(!1);else if(X&&c.groupId){const ye=Xu(R,c.groupId);if(ye.length===0)return;const Ee=(j=ye[0].node.attrs)==null?void 0:j.pendingOriginalContent;if(!Ee||!Array.isArray(Ee))return;const oe=ye.map(Y=>Y.node.toJSON()),z=Ee.map((Y,ne)=>({...Y,attrs:{...Y.attrs||{},pendingStatus:"rewrite",pendingGroupId:c.groupId,...ne===0?{pendingOriginalContent:Ee}:{}}}));if(!c1(R,c.groupId,z))return;lh(!0,c.nodeId,oe,c.groupId),_.current=c.nodeId,M.current=R,S(!0)}else{const ye=ln(R,c.nodeId);if(!ye)return;const{node:Ee}=ye,oe=(le=Ee.attrs)==null?void 0:le.pendingOriginalContent;if(!oe)return;const z=Ee.toJSON();if(!a1(R,c.nodeId,oe))return;lh(!0,c.nodeId,z),_.current=c.nodeId,M.current=R,S(!0)}},[c,w,X]);N.useEffect(()=>{if(!w)return;const R=_.current,j=M.current;R&&j&&(c==null?void 0:c.nodeId)!==R&&(Mc(j,R),_.current=null,M.current=null,S(!1))},[c==null?void 0:c.nodeId,w]),N.useEffect(()=>{if(t.length!==0)return()=>{dm()&&_.current&&M.current&&(Mc(M.current,_.current),_.current=null,M.current=null)}},[t]);const K=N.useCallback(R=>{if(!n)return;if(!t.some(le=>!le||le.isDestroyed?!1:mm(le).length>0)){const le=s==null?void 0:s();le&&i({type:"doc-update",document:le,filename:n}),i({type:"pending-resolved",filename:n,action:R})}},[t,n,i,s]),W=N.useCallback(()=>{M.current&&w&&_.current&&(Mc(M.current,_.current),_.current=null,M.current=null,S(!1))},[w]),$=N.useCallback(()=>{W(),y(),K("accept")},[W,y,K]),Z=N.useCallback(()=>{W(),b(),K("reject")},[W,b,K]),ee=N.useCallback(()=>{W(),x(),K("accept")},[W,x,K]),he=N.useCallback(()=>{W(),E(),K("reject")},[W,E,K]),G=N.useCallback(()=>{if(T===0||T===1&&B===0)return;const R=B<=0?T-1:B-1;r(e.filenames[R])},[T,B,e.filenames,r]),se=N.useCallback(()=>{if(T===0||T===1&&B===0)return;const R=B>=T-1?0:B+1;r(e.filenames[R])},[T,B,e.filenames,r]);if(N.useEffect(()=>{if(!P)return;const R=j=>{if(!(j.target instanceof HTMLInputElement||j.target instanceof HTMLTextAreaElement)&&!(j.target instanceof HTMLElement&&j.target.closest("[contenteditable]")))switch(j.key){case"j":case"ArrowDown":!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),p());break;case"k":case"ArrowUp":!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),h());break;case"h":case"ArrowLeft":!j.metaKey&&!j.ctrlKey&&!j.altKey&&(j.preventDefault(),G());break;case"l":case"ArrowRight":!j.metaKey&&!j.ctrlKey&&!j.altKey&&(j.preventDefault(),se());break;case"a":!j.metaKey&&!j.ctrlKey&&!j.shiftKey&&(j.preventDefault(),$());break;case"r":!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),Z());break;case"A":j.shiftKey&&!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),ee());break;case"R":j.shiftKey&&!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),he());break;case"o":!j.metaKey&&!j.ctrlKey&&!j.shiftKey&&(j.preventDefault(),fe());break}};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[P,p,h,G,se,$,Z,ee,he,fe]),!P)return null;if(c!=null&&c.pendingStatus,!f&&O>0)return g.jsxs("div",{className:"review-panel",children:[g.jsxs("div",{className:"review-panel__status",children:["No changes here — ",O," other doc",O>1?"s have":" has"," changes"]}),g.jsx("div",{className:"review-panel__divider"}),g.jsx("div",{className:"review-panel__nav",children:g.jsx("button",{className:"review-panel__btn",onClick:se,title:"Next doc (l)",children:g.jsx(iv,{})})})]});const ie=B>=0?B+1:"?";return g.jsxs("div",{className:"review-panel",children:[T>1&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"review-panel__nav",children:[g.jsx("button",{className:"review-panel__btn",onClick:G,title:"Previous doc (h)",children:g.jsx(CD,{})}),g.jsx("button",{className:"review-panel__btn",onClick:se,title:"Next doc (l)",children:g.jsx(iv,{})}),g.jsxs("span",{className:"review-panel__counter",children:[ie,"/",T]})]}),g.jsx("div",{className:"review-panel__divider"})]}),g.jsxs("div",{className:"review-panel__nav",children:[g.jsx("button",{className:"review-panel__btn",onClick:h,disabled:l.total<=1,title:"Previous (k)",children:g.jsx(ND,{})}),g.jsx("button",{className:"review-panel__btn",onClick:p,disabled:l.total<=1,title:"Next (j)",children:g.jsx(_D,{})}),g.jsxs("span",{className:"review-panel__counter",children:[u+1,"/",l.total]})]}),g.jsx("div",{className:"review-panel__divider"}),g.jsxs("div",{className:"review-panel__toggle",children:[g.jsx("button",{className:`review-panel__toggle-btn${J&&!w?" review-panel__toggle-btn--active":""}`,onClick:()=>J&&w&&fe(),disabled:!J,title:"Show modified (o)",children:"Modified"}),g.jsx("button",{className:`review-panel__toggle-btn${J&&w?" review-panel__toggle-btn--active":""}`,onClick:()=>J&&!w&&fe(),disabled:!J,title:"Show original (o)",children:"Original"})]}),g.jsx("div",{className:"review-panel__divider"}),g.jsxs("div",{className:"review-panel__actions",children:[g.jsx("button",{className:"review-panel__accept",onClick:$,title:"Accept (a)",children:g.jsx(sv,{})}),g.jsx("button",{className:"review-panel__reject",onClick:Z,title:"Reject (r)",children:g.jsx(ov,{})}),g.jsxs("button",{className:"review-panel__accept-all",onClick:ee,title:"Accept all (Shift+A)",children:[g.jsx(sv,{}),g.jsx("span",{children:"All"})]}),g.jsxs("button",{className:"review-panel__reject-all",onClick:he,title:"Reject all (Shift+R)",children:[g.jsx(ov,{}),g.jsx("span",{children:"All"})]})]})]})}function lv(t,e){return t.indexOf(e)}function Ac(t){return t.type==="doc"?t.file:t.id}function u1(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&u1(n.items,e)}function Zu(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 uh(t){return/^[A-Z]:[/\\]|^\//.test(t)}function d1(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function MD(t){const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(r.getTime()-864e5),s=new Date(e.getFullYear(),e.getMonth(),e.getDate());return s.getTime()===r.getTime()?"Today":s.getTime()===i.getTime()?"Yesterday":n.getTime()-s.getTime()<6048e5?e.toLocaleDateString(void 0,{weekday:"long"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function AD(t,e){const[n,r]=N.useState([]),[i,s]=N.useState([]),[l,c]=N.useState(new Set),u=N.useRef(null),f=N.useCallback(()=>{fetch("/api/documents").then(h=>h.json()).then(h=>{Array.isArray(h)&&r(h)}).catch(()=>{})},[]),p=N.useCallback(()=>{fetch("/api/workspaces").then(h=>h.json()).then(async h=>{if(!Array.isArray(h))return;const y=await Promise.all(h.map(async x=>{try{const w=await(await fetch(`/api/workspaces/${encodeURIComponent(x.filename)}`)).json();return{...x,workspace:w}}catch{return x}}));s(y);const b=new Set;for(const x of y)x.workspace&&u1(x.workspace.root,b);c(b)}).catch(()=>{})},[]);return N.useEffect(()=>{f()},[f,t]),N.useEffect(()=>{p()},[p,e,t]),N.useEffect(()=>{const h=requestAnimationFrame(()=>{var b;const y=(b=u.current)==null?void 0:b.querySelector(".sidebar-item.active");y==null||y.scrollIntoView({block:"nearest",behavior:"instant"})});return()=>cancelAnimationFrame(h)},[n]),{docs:n,workspaces:i,assignedFiles:l,fetchDocs:f,scrollRef:u}}function OD(t,e,n){const r=N.useCallback(_=>{fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>{})},[]),i=N.useCallback((_,M,T)=>{!T.trim()||T.trim()===M||fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:T.trim()})}).then(()=>e()).catch(()=>{})},[e]),s=N.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),l=N.useCallback(_=>{fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>{})},[]),c=N.useCallback((_,M)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}).then(T=>T.json()).then(T=>{if(T.filename)return fetch(`/api/workspaces/${encodeURIComponent(_)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:T.filename,title:T.title||"Untitled",containerId:M})})}).catch(()=>{})},[]),u=N.useCallback((_,M)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/docs/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]),f=N.useCallback((_,M)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:M})}).catch(()=>{})},[]),p=N.useCallback((_,M)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]),h=N.useCallback((_,M,T)=>{T.trim()&&fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(M)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:T.trim()})}).catch(()=>{})},[]),[y,b]=N.useState({}),x=N.useRef(-1);N.useEffect(()=>{n!==x.current&&(x.current=n??0,fetch("/api/documents").then(_=>_.json()).then(_=>{const M={};return Promise.all(_.map(T=>fetch(`/api/doc-tags/${encodeURIComponent(T.filename)}`).then(O=>O.json()).then(O=>{var P;(P=O.tags)!=null&&P.length&&(M[T.filename]=O.tags)}).catch(()=>{}))).then(()=>b(M))}).catch(()=>{}))},[n]);const E=N.useCallback(_=>y[_]||[],[y]),w=N.useCallback((_,M)=>{M.trim()&&(b(T=>{const O=T[_]||[];return O.includes(M.trim())?T:{...T,[_]:[...O,M.trim()]}}),fetch(`/api/doc-tags/${encodeURIComponent(_)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:M.trim()})}).catch(()=>{}))},[]),S=N.useCallback((_,M)=>{b(T=>{const P=(T[_]||[]).filter(B=>B!==M);if(P.length===0){const B={...T};return delete B[_],B}return{...T,[_]:P}}),fetch(`/api/doc-tags/${encodeURIComponent(_)}/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]);return{fetchDocs:e,handleDelete:r,handleRename:i,handleCreateWorkspace:s,handleDeleteWorkspace:l,handleCreateInWorkspace:c,handleRemoveFromWorkspace:u,handleCreateContainer:f,handleDeleteContainer:p,handleRenameContainer:h,getDocTags:E,handleAddTag:w,handleRemoveTag:S}}function RD({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:i}){const[s,l]=N.useState(null),[c,u]=N.useState(null),f=N.useRef(null),p=N.useRef(null),h=N.useRef(null),y=N.useRef(null),b=N.useRef(null),x=5,E=(J,fe,K)=>K==="before"?fe>0?Ac(J[fe-1]):null:Ac(J[fe]),w=N.useCallback((J,fe)=>{if(fe===null){const $=t.filter(ee=>!n.has(ee.filename)).map(ee=>({type:"doc",file:ee.filename,title:ee.title})),Z=$.findIndex(ee=>Ac(ee)===J);return Z>=0?{siblings:$,index:Z,containerId:null}:null}const K=e.find($=>$.filename===fe);if(!(K!=null&&K.workspace))return null;const W=($,Z)=>{for(let ee=0;ee<$.length;ee++){if(Ac($[ee])===J)return{siblings:$,index:ee,containerId:Z};if($[ee].type==="container"){const he=W($[ee].items,$[ee].id);if(he)return he}}return null};return W(K.workspace.root,null)},[t,n,e]),S=N.useCallback(()=>{l(null),u(null),b.current=null,y.current=null,h.current&&(h.current.remove(),h.current=null),f.current&&(clearTimeout(f.current),f.current=null),p.current&&(cancelAnimationFrame(p.current),p.current=null),document.body.style.userSelect=""},[]),_=N.useCallback((J,fe)=>{if(!J||!fe)return;if(J.type==="workspace"){const G=fe.itemId;if(G===J.filename)return;const se=e.map(j=>j.filename),ie=se.indexOf(J.filename);if(ie<0)return;se.splice(ie,1);let R=se.indexOf(G);if(R<0)return;fe.position==="after"&&(R+=1),se.splice(R,0,J.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:se})}).catch(()=>{});return}const{wsFilename:K,containerId:W,afterId:$}=fe,Z=J.type==="doc"?J.file:J.id,ee=J.sourceWs;if(fe.itemId===Z)return;if(J.type==="container"){if(ee!==K||!K)return;fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent(Z)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:W??null,afterFile:$})}).catch(()=>{});return}const he=J.file;if(ee===null&&K===null){const G=t.filter(le=>!n.has(le.filename)).map(le=>le.filename),se=G.indexOf(he);if(se<0)return;G.splice(se,1);let ie=$?G.indexOf($):-1;ie>=0?ie+=1:ie=0,G.splice(ie,0,he);const R=[];let j=0;for(const le of t)n.has(le.filename)?R.push(le.filename):R.push(G[j++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:R})}).catch(()=>{});return}if(ee===null&&K!==null){fetch(`/api/workspaces/${encodeURIComponent(K)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:he,title:he.replace(/\.md$/,""),containerId:W??null,afterFile:$})}).catch(()=>{});return}if(ee!==null&&K===null){fetch(`/api/workspaces/${encodeURIComponent(ee)}/docs/${encodeURIComponent(he)}`,{method:"DELETE"}).catch(()=>{});return}if(ee===K&&K!==null){fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent(he)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:W??null,afterFile:$})}).catch(()=>{});return}ee!==null&&K!==null&&fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent(he)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:ee,containerId:W??null,afterFile:$,title:he.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),M=N.useCallback((J,fe)=>{const K=h.current;K&&(K.style.display="none");const W=document.elementFromPoint(J,fe);if(K&&(K.style.display=""),!W)return null;if((s==null?void 0:s.type)==="workspace"){const le=W.closest("[data-ws-drag]");if(le){const ye=le.dataset.wsDrag,Ee=le.getBoundingClientRect(),oe=(fe-Ee.top)/Ee.height;return{itemId:ye,position:oe<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}return null}const $=W.closest("[data-drag-id]");if(!$){const le=W.closest("[data-drop-ws]");return le?{itemId:"__section__",position:"inside",wsFilename:le.dataset.dropWs==="__docs__"?null:le.dataset.dropWs,containerId:le.dataset.dropContainer||null,afterId:null}:null}const Z=$.dataset.dragId,ee=$.dataset.dragType,he=$.dataset.dragWs==="__docs__"?null:$.dataset.dragWs,G=$.getBoundingClientRect(),se=(fe-G.top)/G.height;if(ee==="container-header"){const le=Z,ye=$.dataset.dragParent||null,Ee=w(le,he);return Ee?se<.25?{itemId:le,position:"before",wsFilename:he,containerId:ye,afterId:E(Ee.siblings,Ee.index,"before")}:se>.75?{itemId:le,position:"after",wsFilename:he,containerId:ye,afterId:E(Ee.siblings,Ee.index,"after")}:{itemId:le,position:"inside",wsFilename:he,containerId:le,afterId:null}:null}const ie=$.dataset.dragContainer||null,R=w(Z,he);if(!R)return null;const j=se<.5?"before":"after";return{itemId:Z,position:j,wsFilename:he,containerId:ie,afterId:E(R.siblings,R.index,j)}},[w,s]),T=N.useCallback(J=>{const fe=r.current;if(!fe)return;const K=fe.getBoundingClientRect(),W=80,$=18;let Z=0;if(J<K.top+W?Z=-$*Math.max(0,1-(J-K.top)/W):J>K.bottom-W&&(Z=$*Math.max(0,1-(K.bottom-J)/W)),p.current&&(cancelAnimationFrame(p.current),p.current=null),Z!==0){const ee=()=>{fe.scrollTop+=Z,p.current=requestAnimationFrame(ee)};p.current=requestAnimationFrame(ee)}},[r]),O=N.useCallback((J,fe)=>{const K=h.current;K&&(K.style.display="none");const W=document.elementFromPoint(J,fe);K&&(K.style.display="");const $=W==null?void 0:W.closest("[data-section-key]");if(!$){f.current&&(clearTimeout(f.current),f.current=null);return}const Z=$.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{i(ee=>{if(!ee.has(Z))return ee;const he=new Set(ee);return he.delete(Z),he})},500)},[i]);N.useEffect(()=>{if(!s)return;const J=K=>{h.current&&(h.current.style.left=`${K.clientX+12}px`,h.current.style.top=`${K.clientY-8}px`),u(M(K.clientX,K.clientY)),T(K.clientY),O(K.clientX,K.clientY)},fe=K=>{_(s,M(K.clientX,K.clientY)),S()};return window.addEventListener("pointermove",J),window.addEventListener("pointerup",fe),()=>{window.removeEventListener("pointermove",J),window.removeEventListener("pointerup",fe)}},[s,M,_,S,T,O]);const P=N.useCallback((J,fe,K)=>{if(J.button!==0||J.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:J.clientX,y:J.clientY},b.current=fe;const $=ee=>{if(!y.current||!b.current)return;const he=ee.clientX-y.current.x,G=ee.clientY-y.current.y;if(Math.abs(he)+Math.abs(G)>=x){document.body.style.userSelect="none",window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",Z),l(b.current),b.current=null;const se=document.createElement("div");se.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);",se.textContent=K,document.body.appendChild(se),h.current=se,se.style.left=`${ee.clientX+12}px`,se.style.top=`${ee.clientY-8}px`}},Z=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",Z),y.current=null,b.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",$),window.addEventListener("pointerup",Z)},[]);return{draggedItem:s,dropIndicator:c,handlePointerDown:P,dropClass:J=>!c||c.itemId!==J?"":c.position==="before"?"drop-before":c.position==="after"?"drop-after":c.position==="inside"?"drop-inside":"",isDragging:J=>s?s.type==="doc"?s.file===J:s.type==="workspace"?s.filename===J:s.id===J:!1,isContainerDropTarget:J=>!c||!s?!1:c.containerId===J}}function ID({x:t,y:e,filename:n,title:r,onClose:i,onDuplicate:s,onRename:l,onDelete:c,onPluginAction:u,pluginItems:f}){const p=N.useRef(null),[h,y]=N.useState(!1),[b,x]=N.useState({left:t,top:e});N.useLayoutEffect(()=>{const w=p.current;if(!w)return;const S=w.getBoundingClientRect(),_=8;let M=t,T=e;e+S.height+_>window.innerHeight&&(T=e-S.height),t+S.width+_>window.innerWidth&&(M=t-S.width),T<_&&(T=_),M<_&&(M=_),x({left:M,top:T})},[t,e]),N.useEffect(()=>{const w=S=>{p.current&&!p.current.contains(S.target)&&i()};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[i]),N.useEffect(()=>{const w=S=>{S.key==="Escape"&&i()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[i]);const E=N.useCallback(w=>{u(w.action,w),i()},[u,i]);return g.jsxs("div",{ref:p,className:"context-menu",style:{left:b.left,top:b.top},children:[g.jsx("button",{className:"context-menu-item",onClick:()=>{s(),i()},children:g.jsx("span",{children:"Duplicate"})}),g.jsx("button",{className:"context-menu-item",onClick:()=>{l(),i()},children:g.jsx("span",{children:"Rename"})}),h?g.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:w=>w.stopPropagation(),children:[g.jsx("span",{children:"Delete?"}),g.jsx("button",{onClick:()=>{c(),i()},children:"Yes"}),g.jsx("button",{onClick:()=>y(!1),children:"No"})]}):g.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>y(!0),children:g.jsx("span",{children:"Delete"})}),f.length>0&&g.jsx(g.Fragment,{children:(()=>{let w;return f.map(S=>{const _=S.pluginDisplayName&&S.pluginDisplayName!==w;return w=S.pluginDisplayName,g.jsxs("span",{children:[_&&g.jsx("div",{className:"context-menu-divider"}),_&&g.jsx("div",{className:"context-menu-section-header",children:S.pluginDisplayName}),g.jsx("button",{className:"context-menu-item",onClick:()=>E(S),children:g.jsx("span",{children:S.label})})]},S.action)})})()})]})}function LD({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[i,s]=N.useState(""),l=N.useRef(null);N.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),N.useEffect(()=>{const u=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);const c=N.useCallback(()=>{n(i.trim())},[i,n]);return g.jsx("div",{className:"focus-modal-overlay",onClick:r,children:g.jsxs("div",{className:"focus-modal",onClick:u=>u.stopPropagation(),children:[g.jsxs("div",{className:"focus-modal-header",children:[g.jsx("h2",{children:t}),g.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),g.jsxs("div",{className:"focus-modal-body",children:[g.jsxs("label",{children:['Focus instructions for "',e,'"',g.jsx("textarea",{ref:l,value:i,onChange:u=>s(u.target.value.slice(0,500)),placeholder:"Optional: guide the transformation (e.g. 'focus on the intro section', 'keep it professional')...",onKeyDown:u=>{u.key==="Enter"&&(u.ctrlKey||u.metaKey)&&c()}})]}),g.jsxs("div",{className:"focus-modal-hint",children:[i.length,"/500"]}),g.jsxs("div",{className:"focus-modal-actions",children:[g.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),g.jsx("button",{className:"focus-modal-btn primary",onClick:c,children:"Go"})]})]})]})})}function f1(t,e){if(!e)return!0;for(const n of t)if(n.type==="container"&&(n.id===e||f1(n.items,e)))return!0;return!1}function DD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:i,onCreateDocument:s,actions:l,scrollRef:c,writingTitle:u,writingTarget:f}){const[p,h]=N.useState(null),[y,b]=N.useState(""),[x,E]=N.useState(null),[w,S]=N.useState(()=>{try{const H=localStorage.getItem("ow-collapsed-sections");return H?new Set(JSON.parse(H)):new Set}catch{return new Set}}),[_,M]=N.useState(null),[T,O]=N.useState(null),[P,B]=N.useState(""),[Q,X]=N.useState(null),[J,fe]=N.useState(""),[K,W]=N.useState(null),[$,Z]=N.useState([]),[ee,he]=N.useState(null),{draggedItem:G,dropIndicator:se,handlePointerDown:ie,dropClass:R,isDragging:j,isContainerDropTarget:le}=RD({docs:t,workspaces:e,assignedFiles:n,scrollRef:c,setCollapsedSections:S}),ye=N.useCallback(()=>{fetch("/api/plugins").then(H=>H.json()).then(H=>{const ke=[];for(const we of H.plugins||[]){const $e=we.displayName||void 0;for(const Ae of we.sidebarMenuItems||[])ke.push({...Ae,pluginDisplayName:$e})}Z(ke)}).catch(()=>{})},[]);N.useEffect(()=>{ye()},[ye]),N.useEffect(()=>{const H=()=>ye();return window.addEventListener("ow-plugins-changed",H),()=>window.removeEventListener("ow-plugins-changed",H)},[ye]);const Ee=N.useCallback((H,ke)=>{H.preventDefault(),H.stopPropagation(),W({x:H.clientX,y:H.clientY,filename:ke.filename,title:ke.title})},[]),oe=N.useCallback(H=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:H})}).catch(()=>{})},[]),z=N.useCallback((H,ke,we,$e,Ae)=>{if(ke.promptForFocus&&Ae===void 0){he({action:H,label:ke.label,filename:we,title:$e});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:H,filename:we,title:$e,instructions:Ae||"",label:ke.label})}).catch(()=>{})},[]),q=H=>{S(ke=>{const we=new Set(ke);return we.has(H)?we.delete(H):we.add(H),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...we])),we})},Y=t.filter(H=>!n.has(H.filename)),ne=(H,ke,we,$e,Ae)=>g.jsxs("div",{className:`sidebar-item ${H.isActive?"active":""} ${j(H.filename)?"dragging":""} ${R(H.filename)}`,"data-drag-id":H.filename,"data-drag-type":"doc","data-drag-ws":ke||"__docs__","data-drag-container":we||"",onPointerDown:je=>ie(je,{type:"doc",file:H.filename,sourceWs:ke||null},H.title),onClick:()=>!H.isActive&&!G&&i(H.filename),onDoubleClick:()=>{h(H.filename),b(H.title)},onContextMenu:je=>Ee(je,H),children:[p===H.filename?g.jsx("input",{className:"sidebar-rename-input",value:y,onChange:je=>b(je.target.value),onBlur:()=>{l.handleRename(H.filename,H.title,y),h(null)},onKeyDown:je=>{je.key==="Enter"&&(l.handleRename(H.filename,H.title,y),h(null)),je.key==="Escape"&&h(null)},autoFocus:!0,onClick:je=>je.stopPropagation()}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"sidebar-item-title",children:[g.jsx("span",{className:"sidebar-item-title-text",children:H.title}),r.filenames.includes(H.filename)&&g.jsx("span",{className:"sidebar-pending-dot"})]}),uh(H.filename)&&g.jsx("div",{className:"sidebar-item-context",children:d1(H.filename)}),g.jsxs("div",{className:"sidebar-item-meta",children:[H.wordCount.toLocaleString()," words · ",Zu(H.lastModified)]}),g.jsxs("div",{className:"sidebar-tags",children:[l.getDocTags(H.filename).map(je=>g.jsxs("span",{className:"sidebar-tag",onClick:ze=>ze.stopPropagation(),children:[je,g.jsx("span",{className:"sidebar-tag-remove",onClick:ze=>{ze.stopPropagation(),l.handleRemoveTag(H.filename,je)},children:"×"})]},je)),Q===H.filename?g.jsx("input",{className:"sidebar-tag-input",value:J,onChange:je=>fe(je.target.value),onBlur:()=>{J.trim()&&l.handleAddTag(H.filename,J),X(null)},onKeyDown:je=>{je.key==="Enter"&&(l.handleAddTag(H.filename,J),X(null),fe("")),je.key==="Escape"&&(X(null),fe(""))},autoFocus:!0,onClick:je=>je.stopPropagation(),placeholder:"tag..."}):g.jsx("button",{className:"sidebar-tag-add",onClick:je=>{je.stopPropagation(),X(H.filename),fe("")},children:"+"})]})]}),x===H.filename?g.jsxs("div",{className:"sidebar-confirm-delete",onClick:je=>je.stopPropagation(),children:[g.jsx("span",{children:"Delete?"}),g.jsx("button",{onClick:()=>{l.handleDelete(H.filename),E(null)},children:"Yes"}),g.jsx("button",{onClick:()=>E(null),children:"No"})]}):g.jsx("button",{className:"sidebar-delete-btn",onClick:je=>{je.stopPropagation(),E(H.filename)},title:"Delete document",children:"×"})]},H.filename),Me=(H,ke,we,$e,Ae,je)=>{if(H.type==="doc"){const et=t.find(Vn=>Vn.filename===H.file);return et?ne(et,we,$e):uh(H.file)?g.jsx("div",{className:"sidebar-item sidebar-unavailable",children:g.jsxs("div",{className:"sidebar-item-title",children:[H.title||H.file," (unavailable)"]})},H.file):g.jsxs("div",{className:"sidebar-item sidebar-missing",children:[g.jsxs("div",{className:"sidebar-item-title",children:[H.title||H.file," (missing)"]}),g.jsx("button",{className:"sidebar-delete-btn",onClick:()=>l.handleRemoveFromWorkspace(we,H.file),title:"Remove",children:"×"})]},H.file)}const ze=H,yn=`container-${ze.id}`,tt=w.has(yn),gt=ke<=2?`depth-${ke}`:"depth-2";return g.jsxs("div",{className:`sidebar-container ${gt} ${tt?"collapsed":""} ${R(ze.id)} ${le(ze.id)?"drop-inside":""}`,children:[g.jsxs("div",{className:`sidebar-container-header ${(se==null?void 0:se.itemId)===ze.id&&se.position==="inside"?"drop-inside":""}`,"data-drag-id":ze.id,"data-drag-type":"container-header","data-drag-ws":we,"data-drag-parent":$e||"","data-section-key":yn,onPointerDown:et=>ie(et,{type:"container",id:ze.id,sourceWs:we},ze.name),onClick:()=>!G&&q(yn),children:[g.jsx("span",{className:`sidebar-chevron ${tt?"collapsed":""}`,children:"▾"}),T===ze.id?g.jsx("input",{className:"sidebar-rename-input",value:P,onChange:et=>B(et.target.value),onBlur:()=>{l.handleRenameContainer(we,ze.id,P),O(null)},onKeyDown:et=>{et.key==="Enter"&&(l.handleRenameContainer(we,ze.id,P),O(null)),et.key==="Escape"&&O(null)},autoFocus:!0,onClick:et=>et.stopPropagation()}):g.jsx("span",{className:"sidebar-container-name",onDoubleClick:et=>{et.stopPropagation(),O(ze.id),B(ze.name)},children:ze.name}),g.jsxs("div",{className:"sidebar-container-actions",children:[g.jsx("button",{className:"sidebar-new-btn",onClick:et=>{et.stopPropagation(),l.handleCreateInWorkspace(we,ze.id)},title:"New doc",children:"+"}),ke<2&&g.jsx("button",{className:"sidebar-new-btn",onClick:et=>{et.stopPropagation(),l.handleCreateContainer(we,ze.id)},title:"New sub-container",children:"☐"}),g.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:et=>{et.stopPropagation(),l.handleDeleteContainer(we,ze.id)},title:"Delete container",children:"×"})]})]}),!tt&&g.jsxs("div",{className:"sidebar-container-list","data-drop-ws":we,"data-drop-container":ze.id,children:[u&&(f==null?void 0:f.wsFilename)===we&&f.containerId===ze.id&&g.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[g.jsxs("div",{className:"sidebar-item-title",children:[g.jsx("span",{className:"sidebar-writing-spinner"}),g.jsx("span",{className:"sidebar-item-title-text",children:u})]}),g.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(u&&(f==null?void 0:f.wsFilename)===we&&f.containerId===ze.id?ze.items.filter(et=>et.type!=="doc"||et.title!==u):ze.items).map((et,Vn)=>Me(et,ke+1,we,ze.id,ze.items)),ze.items.length===0&&!u&&g.jsx("div",{className:"sidebar-empty",children:G?"Drop here":"Empty"})]})]},ze.id)};return g.jsxs("div",{className:"sidebar-scroll",ref:c,children:[g.jsxs("div",{className:`sidebar-section sidebar-docs-section ${w.has("docs")?"docs-collapsed":""}`,children:[g.jsxs("div",{className:"sidebar-section-header","data-section-key":"docs",onClick:()=>q("docs"),children:[g.jsx("span",{className:`sidebar-chevron ${w.has("docs")?"collapsed":""}`,children:"▾"}),g.jsx("span",{className:"sidebar-label",children:"Documents"}),g.jsx("button",{className:"sidebar-new-btn",onClick:H=>{H.stopPropagation(),s()},title:"New document",children:"+"})]}),!w.has("docs")&&g.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[u&&(!f||!e.some(H=>H.filename===(f==null?void 0:f.wsFilename)))&&g.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[g.jsxs("div",{className:"sidebar-item-title",children:[g.jsx("span",{className:"sidebar-writing-spinner"}),g.jsx("span",{className:"sidebar-item-title-text",children:u})]}),g.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(u?Y.filter(H=>H.title!==u):Y).map((H,ke)=>(Y.map(we=>({type:"doc",file:we.filename,title:we.title})),ne(H,void 0,null))),Y.length===0&&g.jsx("div",{className:"sidebar-empty",children:G?"Drop here to unassign":"No unassigned documents"})]})]}),e.map(H=>{var $e;const ke=(($e=H.workspace)==null?void 0:$e.root)||[],we=w.has(H.filename);return g.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${we?"ws-collapsed":""} ${j(H.filename)?"dragging":""} ${(se==null?void 0:se.itemId)===H.filename?se.position==="before"?"drop-before":"drop-after":""}`,children:[g.jsxs("div",{className:"sidebar-section-header","data-section-key":H.filename,"data-ws-drag":H.filename,onPointerDown:Ae=>ie(Ae,{type:"workspace",filename:H.filename},H.title),onClick:()=>!G&&q(H.filename),children:[g.jsx("span",{className:`sidebar-chevron ${we?"collapsed":""}`,children:"▾"}),g.jsx("span",{className:"sidebar-label sidebar-workspace-label",children:H.title}),g.jsxs("div",{className:"sidebar-workspace-actions",children:[g.jsx("button",{className:"sidebar-new-btn",onClick:Ae=>{Ae.stopPropagation(),l.handleCreateInWorkspace(H.filename,null)},title:"New document",children:"+"}),g.jsx("button",{className:"sidebar-new-btn",onClick:Ae=>{Ae.stopPropagation(),l.handleCreateContainer(H.filename,null)},title:"New container",children:"☐"}),_===H.filename?g.jsxs("span",{className:"sidebar-inline-confirm",onClick:Ae=>Ae.stopPropagation(),children:[g.jsx("button",{onClick:()=>{l.handleDeleteWorkspace(H.filename),M(null)},children:"Yes"}),g.jsx("button",{onClick:()=>M(null),children:"No"})]}):g.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:Ae=>{Ae.stopPropagation(),M(H.filename)},title:"Delete workspace",children:"×"})]})]}),!we&&g.jsxs("div",{className:"sidebar-section-list","data-drop-ws":H.filename,children:[u&&(f==null?void 0:f.wsFilename)===H.filename&&(f.containerId===null||!f1(ke,f.containerId))&&g.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[g.jsxs("div",{className:"sidebar-item-title",children:[g.jsx("span",{className:"sidebar-writing-spinner"}),g.jsx("span",{className:"sidebar-item-title-text",children:u})]}),g.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(u&&(f==null?void 0:f.wsFilename)===H.filename&&f.containerId===null?ke.filter(Ae=>Ae.type!=="doc"||Ae.title!==u):ke).map((Ae,je)=>Me(Ae,0,H.filename,null)),ke.length===0&&!u&&g.jsx("div",{className:"sidebar-empty",children:G?"Drop here to add":"Empty workspace"})]})]},H.filename)}),g.jsx("div",{className:"sidebar-new-workspace",children:g.jsx("button",{onClick:l.handleCreateWorkspace,children:"+ New Workspace"})}),K&&g.jsx(ID,{x:K.x,y:K.y,filename:K.filename,title:K.title,onClose:()=>W(null),onDuplicate:()=>oe(K.filename),onRename:()=>{h(K.filename),b(K.title)},onDelete:()=>l.handleDelete(K.filename),onPluginAction:(H,ke)=>z(H,ke,K.filename,K.title),pluginItems:$}),ee&&g.jsx(LD,{actionLabel:ee.label,docTitle:ee.title,onClose:()=>he(null),onConfirm:H=>{const ke=$.find(we=>we.action===ee.action);ke&&z(ee.action,ke,ee.filename,ee.title,H),he(null)}})]})}function PD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:i,onCreateDocument:s,actions:l,scrollRef:c}){const[u,f]=N.useState(null),p=[...t].sort((x,E)=>new Date(E.lastModified).getTime()-new Date(x.lastModified).getTime()),h=[];let y="";for(const x of p){const E=MD(x.lastModified);E!==y&&(h.push({label:E,docs:[]}),y=E),h[h.length-1].docs.push(x)}const b=x=>{for(const E of e){if(!E.workspace)continue;const w=S=>{for(const _ of S)if(_.type==="doc"&&_.file===x||_.type==="container"&&w(_.items))return!0;return!1};if(w(E.workspace.root))return E.title}return null};return g.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:c,children:[g.jsxs("div",{className:"tl-header",children:[g.jsx("span",{className:"tl-title",children:"Timeline"}),g.jsx("button",{className:"sidebar-new-btn",onClick:s,title:"New document",children:"+"})]}),h.map(x=>g.jsxs("div",{className:"tl-group",children:[g.jsx("div",{className:"tl-date",children:x.label}),x.docs.map(E=>{const w=b(E.filename);return g.jsxs("div",{className:`tl-item ${E.isActive?"active":""}`,onClick:()=>!E.isActive&&i(E.filename),children:[g.jsx("div",{className:"tl-dot"}),g.jsxs("div",{className:"tl-content",children:[g.jsxs("div",{className:"tl-item-title",children:[g.jsx("span",{children:E.title}),r.filenames.includes(E.filename)&&g.jsx("span",{className:"sidebar-pending-dot"})]}),uh(E.filename)&&g.jsx("div",{className:"tl-item-context",children:d1(E.filename)}),g.jsxs("div",{className:"tl-item-meta",children:[E.wordCount.toLocaleString()," words · ",Zu(E.lastModified)]}),w&&g.jsx("div",{className:"tl-badge",children:w})]}),u===E.filename?g.jsxs("div",{className:"sidebar-confirm-delete",onClick:S=>S.stopPropagation(),children:[g.jsx("span",{children:"Delete?"}),g.jsx("button",{onClick:()=>{l.handleDelete(E.filename),f(null)},children:"Yes"}),g.jsx("button",{onClick:()=>f(null),children:"No"})]}):g.jsx("button",{className:"sidebar-delete-btn",onClick:S=>{S.stopPropagation(),f(E.filename)},title:"Delete",children:"×"})]},E.filename)})]},x.label)),t.length===0&&g.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function jD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:i,actions:s,scrollRef:l}){const[c,u]=N.useState([]),[f,p]=N.useState(null),[h,y]=N.useState(null),b=N.useRef(null);N.useEffect(()=>{if(!f)return;const W=$=>{b.current&&!b.current.contains($.target)&&p(null)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[f]);const x=(W,$)=>{for(const Z of W)if(Z.type==="container"){if(Z.id===$)return Z;const ee=x(Z.items,$);if(ee)return ee}return null},E=W=>{let $=0;for(const Z of W)Z.type==="doc"?$++:Z.type==="container"&&($+=E(Z.items));return $},w=W=>{const $=[];for(const Z of W)Z.type==="doc"?$.push(Z.file):Z.type==="container"&&$.push(...w(Z.items));return $},S=N.useMemo(()=>{if(c.length===0)return[];const W=c[c.length-1],$=e.find(ee=>ee.filename===W.wsFilename);if(!($!=null&&$.workspace))return[];if(W.type==="workspace")return $.workspace.root;const Z=x($.workspace.root,W.key);return Z?Z.items:[]},[c,e]),_=S.filter(W=>W.type==="container"),M=N.useMemo(()=>{const W=S.filter($=>$.type==="doc").map($=>$.file);return t.filter($=>W.includes($.filename))},[S,t]),T=W=>{const $=w(W.items);return t.filter(Z=>$.includes(Z.filename))},O=W=>{const $=e.find(ee=>ee.filename===W);if(!($!=null&&$.workspace))return[];const Z=w($.workspace.root);return t.filter(ee=>Z.includes(ee.filename))},P=N.useMemo(()=>t.filter(W=>!n.has(W.filename)),[t,n]),B=W=>{u($=>[...$,W]),p(null)},Q=()=>{u(W=>W.slice(0,-1)),p(null)},X=(W,$)=>{if(f===W){p(null);return}const ee=$.currentTarget.getBoundingClientRect();y({top:ee.bottom+4,left:ee.left}),p(W)},J=W=>{i(W),p(null)},fe=c.length>1?c[c.length-2].title:"All",K=()=>{if(!f)return[];if(f==="__unassigned__")return P;if(f==="__level-docs__")return M;const W=e.find($=>$.filename===f);if(W)return O(W.filename);for(const $ of e){if(!$.workspace)continue;const Z=x($.workspace.root,f);if(Z)return T(Z)}return[]};return g.jsxs("div",{className:"board-scroll",ref:l,children:[c.length===0?g.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):g.jsxs("button",{className:"board-back",onClick:Q,title:`Back to ${fe}`,children:["← ",fe]}),c.length===0&&g.jsxs(g.Fragment,{children:[P.length>0&&g.jsxs("button",{className:`board-chip ${f==="__unassigned__"?"open":""}`,onClick:W=>X("__unassigned__",W),children:["Documents ",g.jsx("span",{className:"board-chip-count",children:P.length})]}),e.map(W=>{var Z;const $=(Z=W.workspace)==null?void 0:Z.root.some(ee=>ee.type==="container");return g.jsxs("button",{className:`board-chip ${f===W.filename?"open":""}`,onClick:ee=>$?B({type:"workspace",key:W.filename,title:W.title,wsFilename:W.filename}):X(W.filename,ee),children:[W.title," ",g.jsx("span",{className:"board-chip-count",children:W.docCount}),$&&g.jsx("span",{className:"board-chip-arrow",children:"›"})]},W.filename)}),g.jsx("button",{className:"board-chip board-chip-add",onClick:s.handleCreateWorkspace,title:"New workspace",children:"+"})]}),c.length>0&&g.jsxs(g.Fragment,{children:[M.length>0&&g.jsxs("button",{className:`board-chip board-chip-docs ${f==="__level-docs__"?"open":""}`,onClick:W=>X("__level-docs__",W),children:["Docs ",g.jsx("span",{className:"board-chip-count",children:M.length})]}),_.map(W=>{const $=W.items.some(Z=>Z.type==="container");return g.jsxs("button",{className:`board-chip ${f===W.id?"open":""}`,onClick:Z=>$?B({type:"container",key:W.id,title:W.name,wsFilename:c[c.length-1].wsFilename}):X(W.id,Z),children:[W.name," ",g.jsx("span",{className:"board-chip-count",children:E(W.items)}),$&&g.jsx("span",{className:"board-chip-arrow",children:"›"})]},W.id)})]}),f&&h&&(()=>{const W=K();return g.jsxs("div",{className:"board-dropdown",ref:b,style:{position:"fixed",top:h.top,left:h.left},children:[W.map($=>g.jsxs("div",{className:`board-dropdown-item ${$.isActive?"active":""}`,onClick:()=>J($.filename),children:[g.jsxs("span",{className:"board-dropdown-title",children:[$.title,r.filenames.includes($.filename)&&g.jsx("span",{className:"board-pending-dot"})]}),g.jsxs("span",{className:"board-dropdown-meta",children:[$.wordCount.toLocaleString()," words · ",Zu($.lastModified)]})]},$.filename)),W.length===0&&g.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})()]})}function BD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:i,actions:s,scrollRef:l}){const[c,u]=N.useState([]),f=(_,M)=>{for(const T of _)if(T.type==="container"){if(T.id===M)return T;const O=f(T.items,M);if(O)return O}return null},p=_=>{let M=0;for(const T of _)T.type==="doc"?M++:T.type==="container"&&(M+=p(T.items));return M},h=N.useMemo(()=>{if(c.length===0)return[];const _=c[c.length-1],M=e.find(O=>O.filename===_.wsFilename);if(!(M!=null&&M.workspace))return[];if(_.type==="workspace")return M.workspace.root;const T=f(M.workspace.root,_.key);return T?T.items:[]},[c,e]),y=h.filter(_=>_.type==="container"),b=N.useMemo(()=>{if(c.length===0)return t.filter(M=>!n.has(M.filename));const _=h.filter(M=>M.type==="doc").map(M=>M.file);return t.filter(M=>_.includes(M.filename))},[c,h,t,n]),x=_=>u(M=>[...M,_]),E=()=>u(_=>_.slice(0,-1)),w=c.length>1?c[c.length-2].title:"Shelf",S=c.length>0?c[c.length-1].title:"Documents";return g.jsxs("div",{className:"shelf-wrapper",children:[g.jsxs("div",{className:"shelf-spines",ref:l,children:[c.length>0&&g.jsxs("button",{className:"shelf-back",onClick:E,title:`Back to ${w}`,children:[g.jsx("span",{className:"shelf-back-arrow",children:"←"}),g.jsx("span",{className:"shelf-back-label",children:w})]}),c.length===0&&g.jsxs(g.Fragment,{children:[e.map(_=>g.jsxs("div",{className:"shelf-section-spine",onClick:()=>x({type:"workspace",key:_.filename,title:_.title,wsFilename:_.filename}),title:_.title,children:[g.jsx("span",{className:"shelf-section-title",children:_.title}),g.jsx("span",{className:"shelf-section-count",children:_.docCount})]},_.filename)),g.jsx("button",{className:"shelf-add",onClick:s.handleCreateWorkspace,title:"New workspace",children:"+"})]}),c.length>0&&y.map(_=>g.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>x({type:"container",key:_.id,title:_.name,wsFilename:c[c.length-1].wsFilename}),title:_.name,children:[g.jsx("span",{className:"shelf-section-title",children:_.name}),g.jsx("span",{className:"shelf-section-count",children:p(_.items)})]},_.id))]}),g.jsxs("div",{className:"shelf-docs",children:[g.jsx("div",{className:"shelf-docs-header",children:S}),g.jsxs("div",{className:"shelf-docs-list",children:[b.map(_=>g.jsxs("div",{className:`shelf-doc-item ${_.isActive?"active":""}`,onClick:()=>i(_.filename),children:[g.jsxs("div",{className:"shelf-doc-title",children:[g.jsx("span",{children:_.title}),r.filenames.includes(_.filename)&&g.jsx("span",{className:"shelf-pending-dot"})]}),g.jsxs("div",{className:"shelf-doc-meta",children:[_.wordCount.toLocaleString()," words · ",Zu(_.lastModified)]})]},_.filename)),b.length===0&&g.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}const zD=[{id:"full",label:"Full",lines:3},{id:"compact",label:"Compact",lines:2},{id:"minimal",label:"Minimal",lines:1}];function FD(){const[t,e]=N.useState(!1),[n,r]=N.useState(Sv),i=N.useRef(null);N.useEffect(()=>{if(!t)return;const l=c=>{i.current&&!i.current.contains(c.target)&&e(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[t]);const s=l=>{r(l),rS(l),e(!1)};return g.jsxs("div",{className:"sidebar-density-wrapper",ref:i,children:[g.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>e(!t),title:"Card density",children:g.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),g.jsx("path",{d:"M21 9H3"}),g.jsx("path",{d:"M21 15H3"})]})}),t&&g.jsx("div",{className:"sidebar-density-dropdown",children:zD.map(l=>g.jsxs("button",{className:`sidebar-density-option ${n===l.id?"active":""}`,onClick:()=>s(l.id),children:[g.jsx("span",{className:"sidebar-density-icon",children:Array.from({length:l.lines},(c,u)=>g.jsx("span",{className:"sidebar-density-line"},u))}),g.jsx("span",{children:l.label})]},l.id))})]})}function av({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,workspacesRefreshKey:i,pendingDocs:s,writingTitle:l,writingTarget:c,onClose:u}){const{docs:f,workspaces:p,assignedFiles:h,fetchDocs:y,scrollRef:b}=AD(r,i),x=OD(p,y,r),E=Du(),w={docs:f,workspaces:p,assignedFiles:h,pendingDocs:s,writingTitle:l,writingTarget:c,onSwitchDocument:e,onCreateDocument:n,actions:x,scrollRef:b},S=()=>{switch(E){case"timeline":return g.jsx(PD,{...w});case"board":return g.jsx(jD,{...w});case"shelf":return g.jsx(BD,{...w});default:return g.jsx(DD,{...w})}};return E==="board"?g.jsx("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,children:S()}):g.jsxs("div",{className:`sidebar ${t?"open":""}`,children:[g.jsxs("div",{className:"sidebar-topbar",children:[g.jsxs("div",{className:"sidebar-logo",children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[g.jsx("path",{d:"M17 3a2.83 2.83 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),g.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),g.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),g.jsxs("div",{className:"sidebar-topbar-actions",children:[g.jsx(FD,{}),u&&g.jsx("button",{className:"sidebar-collapse-btn",onClick:u,title:"Close sidebar",children:g.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",children:[g.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),g.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"1.5"}),g.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),S()]})}function $D({onClose:t,onSetupComplete:e}){const[n,r]=N.useState("detecting"),[i,s]=N.useState(null),[l,c]=N.useState("gh"),[u,f]=N.useState("openwriter-docs"),[p,h]=N.useState(!0),[y,b]=N.useState(""),[x,E]=N.useState(""),[w,S]=N.useState(""),[_,M]=N.useState("");N.useEffect(()=>{fetch("/api/sync/capabilities").then(O=>O.json()).then(O=>{s(O),O.ghAuthenticated?c("gh"):(O.gitInstalled,c("pat")),r("setup")}).catch(()=>{S("Failed to detect git capabilities"),r("error")})},[]);const T=N.useCallback(async()=>{r("progress"),M(l==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const O={method:l,repoName:u,isPrivate:p};l==="pat"&&(O.pat=y),l==="connect"&&(O.remoteUrl=x,O.pat=y||void 0);const P=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!P.ok){const B=await P.json().catch(()=>({}));throw new Error(B.error||`Setup failed (${P.status})`)}r("done"),e()}catch(O){S(O.message),r("error")}},[l,u,p,y,x,e]);return g.jsx("div",{className:"sync-modal-overlay",onClick:t,children:g.jsxs("div",{className:"sync-modal",onClick:O=>O.stopPropagation(),children:[g.jsxs("div",{className:"sync-modal-header",children:[g.jsx("h2",{children:"Sync to GitHub"}),g.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&g.jsxs("div",{className:"sync-modal-body",children:[g.jsx("div",{className:"sync-spinner"}),g.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&i&&g.jsxs("div",{className:"sync-modal-body",children:[!i.gitInstalled&&g.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",g.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),i.gitInstalled&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"sync-tabs",children:[i.ghAuthenticated&&g.jsx("button",{className:`sync-tab${l==="gh"?" active":""}`,onClick:()=>c("gh"),children:"GitHub CLI"}),g.jsx("button",{className:`sync-tab${l==="pat"?" active":""}`,onClick:()=>c("pat"),children:"Personal Access Token"}),g.jsx("button",{className:`sync-tab${l==="connect"?" active":""}`,onClick:()=>c("connect"),children:"Connect Existing"})]}),l==="gh"&&g.jsxs("div",{className:"sync-form",children:[g.jsxs("label",{children:["Repository name",g.jsx("input",{type:"text",value:u,onChange:O=>f(O.target.value),placeholder:"openwriter-docs"})]}),g.jsxs("label",{className:"sync-checkbox",children:[g.jsx("input",{type:"checkbox",checked:p,onChange:O=>h(O.target.checked)}),"Private repository"]})]}),l==="pat"&&g.jsxs("div",{className:"sync-form",children:[!i.ghAuthenticated&&!i.ghInstalled&&g.jsxs("p",{className:"sync-hint",children:["Create a ",g.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",g.jsx("code",{children:"repo"})," scope."]}),g.jsxs("label",{children:["Personal Access Token",g.jsx("input",{type:"password",value:y,onChange:O=>b(O.target.value),placeholder:"ghp_..."})]}),g.jsxs("label",{children:["Repository name",g.jsx("input",{type:"text",value:u,onChange:O=>f(O.target.value),placeholder:"openwriter-docs"})]}),g.jsxs("label",{className:"sync-checkbox",children:[g.jsx("input",{type:"checkbox",checked:p,onChange:O=>h(O.target.checked)}),"Private repository"]})]}),l==="connect"&&g.jsxs("div",{className:"sync-form",children:[g.jsxs("label",{children:["Remote URL",g.jsx("input",{type:"text",value:x,onChange:O=>E(O.target.value),placeholder:"https://github.com/user/repo.git"})]}),g.jsxs("label",{children:["PAT (optional, for private repos)",g.jsx("input",{type:"password",value:y,onChange:O=>b(O.target.value),placeholder:"ghp_..."})]})]}),g.jsxs("div",{className:"sync-modal-actions",children:[g.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),g.jsx("button",{className:"sync-btn primary",onClick:T,disabled:l==="pat"&&!y||l==="connect"&&!x||l!=="connect"&&!u,children:l==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&g.jsxs("div",{className:"sync-modal-body",children:[g.jsx("div",{className:"sync-spinner"}),g.jsx("p",{children:_})]}),n==="done"&&g.jsxs("div",{className:"sync-modal-body",children:[g.jsx("div",{className:"sync-success-icon",children:"✓"}),g.jsx("p",{children:"Successfully synced to GitHub!"}),g.jsx("div",{className:"sync-modal-actions",children:g.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&g.jsxs("div",{className:"sync-modal-body",children:[g.jsx("div",{className:"sync-error-msg",children:w}),g.jsxs("div",{className:"sync-modal-actions",children:[g.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),g.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function UD({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentsChanged:r,onWorkspacesChanged:i,onTitleChanged:s,onPendingDocsChanged:l,onMetadataChanged:c,onSyncStatus:u,onWritingStarted:f,onWritingFinished:p,getEditorState:h}){const y=N.useRef(null),[b,x]=N.useState(!1),E=N.useRef(t),w=N.useRef(e),S=N.useRef(n),_=N.useRef(r),M=N.useRef(i),T=N.useRef(s),O=N.useRef(l),P=N.useRef(u),B=N.useRef(c),Q=N.useRef(f),X=N.useRef(p),J=N.useRef(h);E.current=t,w.current=e,S.current=n,_.current=r,M.current=i,T.current=s,O.current=l,B.current=c,P.current=u,Q.current=f,X.current=p,J.current=h,N.useEffect(()=>{const W=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let $,Z=!1;function ee(){const he=new WebSocket(W);y.current=he,he.onopen=()=>{x(!0),Z&&he.send(JSON.stringify({type:"request-document"})),Z=!0},he.onmessage=G=>{var se,ie,R,j,le,ye,Ee,oe,z,q,Y;try{const ne=JSON.parse(G.data);ne.type==="node-changes"&&ne.changes&&((se=E.current)==null||se.call(E,ne.changes)),ne.type==="agent-status"&&((ie=w.current)==null||ie.call(w,!!ne.agentConnected)),ne.type==="document-switched"&&((R=S.current)==null||R.call(S,{document:ne.document,title:ne.title,filename:ne.filename,docId:ne.docId,metadata:ne.metadata})),ne.type==="metadata-changed"&&ne.metadata&&((j=B.current)==null||j.call(B,ne.metadata)),ne.type==="documents-changed"&&((le=_.current)==null||le.call(_)),ne.type==="workspaces-changed"&&((ye=M.current)==null||ye.call(M)),ne.type==="title-changed"&&ne.title&&((Ee=T.current)==null||Ee.call(T,ne.title)),ne.type==="pending-docs-changed"&&ne.pendingDocs&&((oe=O.current)==null||oe.call(O,ne.pendingDocs)),ne.type==="sync-status"&&((z=P.current)==null||z.call(P,{state:ne.state,lastSyncTime:ne.lastSyncTime,pendingFiles:ne.pendingFiles,error:ne.error})),ne.type==="writing-started"&&ne.title&&((q=Q.current)==null||q.call(Q,ne.title,ne.target||null)),ne.type==="writing-finished"&&((Y=X.current)==null||Y.call(X)),ne.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),ne.type==="marks-changed"&&ne.filename&&window.dispatchEvent(new CustomEvent("ow-marks-changed",{detail:{filename:ne.filename}}))}catch{}},he.onclose=()=>{x(!1),$=setTimeout(ee,2e3)},he.onerror=()=>{he.close()}}return ee(),()=>{var he;clearTimeout($),(he=y.current)==null||he.close()}},[]);const fe=N.useCallback(K=>{var W;((W=y.current)==null?void 0:W.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify(K))},[]);return{connected:b,sendMessage:fe}}function HD(t){const[e,n]=N.useState(null),[r,i]=N.useState(!1),[s,l]=N.useState(null),c=N.useRef(void 0);return N.useEffect(()=>{if(!t){n(null),i(!1),l(null),c.current=void 0;return}t!==c.current&&(c.current=t,i(!0),l(null),fetch(`/api/tweet-embed?url=${encodeURIComponent(t)}`).then(u=>u.ok?u.json():u.json().then(f=>Promise.reject(new Error(f.error||`HTTP ${u.status}`)))).then(u=>{n(u),i(!1)}).catch(u=>{l(u.message),i(!1)}))},[t]),{tweet:e,loading:r,error:s}}function Ep(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 WD(t){try{const e=Date.now(),n=new Date(t).getTime(),r=Math.floor((e-n)/1e3);if(r<60)return`${r}s`;const i=Math.floor(r/60);if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return""}}const VD=()=>g.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:g.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"})}),KD=()=>g.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:g.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"})}),GD=()=>g.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:g.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"})}),qD=()=>g.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:g.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"})}),JD=()=>g.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:g.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 p1({tweet:t,nested:e}){const n=WD(t.createdAt);return g.jsxs("div",{className:`tweet-embed-card${e?" tweet-embed-nested":""}`,children:[g.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?g.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):g.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),g.jsxs("div",{className:"tweet-author-info",children:[g.jsx("span",{className:"tweet-author-name",children:t.author.name}),g.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),n&&g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"tweet-author-separator",children:"·"}),g.jsx("span",{className:"tweet-author-timestamp",children:n})]})]})]}),g.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&g.jsx("div",{className:"tweet-media",children:t.media.map((r,i)=>r.type==="photo"?g.jsx("img",{className:"tweet-media-img",src:r.url,alt:"",loading:"lazy"},i):r.type==="video"||r.type==="gif"?g.jsx("div",{className:"tweet-media-video-placeholder",children:g.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&g.jsx(p1,{tweet:t.quoteTweet,nested:!0}),!e&&g.jsxs("div",{className:"tweet-actions-row",children:[g.jsxs("span",{className:"tweet-action tweet-action-reply",children:[g.jsx(VD,{}),t.metrics.replies>0&&Ep(t.metrics.replies)]}),g.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[g.jsx(KD,{}),t.metrics.retweets>0&&Ep(t.metrics.retweets)]}),g.jsxs("span",{className:"tweet-action tweet-action-like",children:[g.jsx(GD,{}),t.metrics.likes>0&&Ep(t.metrics.likes)]}),g.jsx("span",{className:"tweet-action tweet-action-bookmark",children:g.jsx(qD,{})}),g.jsx("span",{className:"tweet-action tweet-action-share",children:g.jsx(JD,{})})]})]})}function YD({tweet:t}){return g.jsx(p1,{tweet:t})}function QD({initialContent:t,placeholder:e="What is happening?!",onUpdate:n,onReady:r,onFocus:i}){const s=zk({extensions:[...Xw,Yu.configure({placeholder:e})],content:t||"<p></p>",onUpdate:({editor:l})=>{n==null||n(l)},onFocus:()=>{i==null||i()}},[t]);return N.useEffect(()=>{if(!s)return;const{state:l}=s.view;if(l.plugins.some(f=>f.key==="pendingDecoration$"))return;const c=r1(),u=l.reconfigure({plugins:[...l.plugins,c]});s.view.updateState(u)},[s]),N.useEffect(()=>{s&&(r==null||r(s))},[s,r]),s?g.jsx(Hh,{editor:s}):null}function XD({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),i=26,s=2,l=(i-s)/2,c=2*Math.PI*l,u=c*(1-r);let f="var(--x-blue, #1d9bf0)";n<=0?f="var(--x-red, #f4212e)":n<=20&&(f="var(--x-yellow, #ffd400)");const p=n<=20;return t===0?null:g.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:i,height:i},children:[g.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[g.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:s}),g.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:f,strokeWidth:s,strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",transform:`rotate(-90 ${i/2} ${i/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),p&&g.jsx("span",{className:"tweet-char-number",style:{color:f},children:n})]})}const cv="@openwriter/plugin-x-api",uv=[{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 ZD({onConnected:t,onCancel:e}){const[n,r]=N.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[i,s]=N.useState(!1),[l,c]=N.useState(""),u=uv.every(p=>n[p.key].trim()),f=async()=>{s(!0),c("");try{if(!(await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:cv,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:cv})})).json();if(!y.success)throw new Error(y.error||"Failed to enable plugin");const x=await(await fetch("/api/x/status")).json();x.connected?t():c(x.error||"Could not verify X credentials. Check your API keys.")}catch(p){c(p.message||"Connection failed")}finally{s(!1)}};return g.jsxs("div",{className:"x-connect-prompt",children:[g.jsxs("div",{className:"x-connect-header",children:[g.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),g.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:g.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:g.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"})})})]}),g.jsx("div",{className:"x-connect-fields",children:uv.map(p=>g.jsxs("div",{className:"x-connect-field",children:[g.jsx("label",{className:"x-connect-label",children:p.label}),g.jsx("input",{type:"password",className:"x-connect-input",value:n[p.key],onChange:h=>r(y=>({...y,[p.key]:h.target.value})),placeholder:p.env,spellCheck:!1,autoComplete:"off"})]},p.key))}),l&&g.jsx("div",{className:"x-connect-error",children:l}),g.jsxs("div",{className:"x-connect-actions",children:[g.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),g.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!u||i,children:i?"Connecting...":"Connect"})]})]})}const dv="ow-x-handle";function eP(){const[t,e]=N.useState(()=>localStorage.getItem(dv)||""),[n,r]=N.useState(!1),[i,s]=N.useState(""),l=N.useRef(null),c=N.useRef(null),u=()=>{const h=i.replace(/^@/,"").trim();h&&(localStorage.setItem(dv,h),e(h)),r(!1)},f=()=>{s(t),r(!0),setTimeout(()=>{var h;return(h=l.current)==null?void 0:h.focus()},0)};N.useEffect(()=>{if(!n)return;const h=y=>{c.current&&!c.current.contains(y.target)&&u()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n,i]);const p=t?`https://unavatar.io/twitter/${t}`:"";return g.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:c,children:[t?g.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:p,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):g.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&g.jsx("div",{className:"tweet-handle-popover",children:g.jsx("input",{ref:l,className:"tweet-handle-input",value:i,onChange:h=>s(h.target.value),onKeyDown:h=>{h.key==="Enter"&&u(),h.key==="Escape"&&r(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function fv(){return g.jsxs("div",{className:"tweet-skeleton",children:[g.jsxs("div",{className:"tweet-author-row",children:[g.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),g.jsxs("div",{className:"tweet-author-info",children:[g.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),g.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),g.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),g.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function tP(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function nP(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 pv(t){const e=[],n=t.filter(Boolean);return n.forEach((r,i)=>{const s=r.getJSON();s.content&&e.push(...s.content),i<n.length-1&&e.push({type:"horizontalRule"})}),{type:"doc",content:e}}function hv(t){const e=[],n=r=>{var i;r.type==="image"&&((i=r.attrs)!=null&&i.src)&&e.push(r.attrs.src),r.content&&r.content.forEach(n)};return n(t.getJSON()),e.slice(0,4)}function rP({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:i}){const{tweet:s,loading:l,error:c}=HD(t==null?void 0:t.url),[u,f]=N.useState(()=>nP(e)),p=N.useRef([]),[h,y]=N.useState(()=>u.map(()=>0)),[b,x]=N.useState(0),[E,w]=N.useState(0),[S,_]=N.useState(null),[M,T]=N.useState(),[O,P]=N.useState(!1),[B,Q]=N.useState("idle"),[X,J]=N.useState(""),fe=N.useRef();N.useEffect(()=>{let oe=!1;return(async()=>{try{const z=await fetch("/api/x/status");if(oe)return;if(z.ok){const q=await z.json();_(q.connected),T(q.username)}else _(!1)}catch{oe||_(!1)}})(),()=>{oe=!0}},[]);const K=N.useCallback((oe,z)=>{p.current[oe]=z,y(Y=>{const ne=[...Y];return ne[oe]=z.getText().length,ne});const q=pv(p.current);n==null||n(q)},[n]),W=N.useCallback((oe,z)=>{p.current[oe]=z,y(q=>{const Y=[...q];return Y[oe]=z.getText().length,Y}),w(q=>q+1),oe===0&&(r==null||r(z)),i==null||i(p.current.filter(Boolean))},[r,i]),$=u.length>1;h.reduce((oe,z)=>oe+z,0);const Z=N.useCallback(()=>{const oe=b+1;f(z=>[...z.slice(0,oe),"<p></p>",...z.slice(oe)]),y(z=>[...z.slice(0,oe),0,...z.slice(oe)]),x(oe)},[b]),ee=N.useCallback(oe=>{oe!==0&&(p.current.splice(oe,1),f(z=>z.filter((q,Y)=>Y!==oe)),y(z=>z.filter((q,Y)=>Y!==oe)),setTimeout(()=>{const z=pv(p.current);n==null||n(z),i==null||i(p.current.filter(Boolean))},0))},[n,i]),he=!!(t!=null&&t.url),G=(t==null?void 0:t.mode)==="reply",se=p.current.filter(Boolean).some(z=>z.getText().trim()||hv(z).length>0),ie=S&&se&&B==="idle",R=async()=>{if(!S){P(!0);return}if(ie){Q("uploading"),J("");try{const oe=p.current.filter(Boolean),z=[];for(const Y of oe){const ne=Y.getText().trim(),Me=hv(Y);if(!ne&&Me.length===0)continue;const H=[];for(const ke of Me){const $e=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:ke})})).json();if(!$e.success)throw new Error($e.error||"Image upload failed");H.push($e.mediaId)}z.push({text:ne,mediaIds:H})}if(z.length===0)return;Q("posting");const q=tP(t==null?void 0:t.url);if(z.length===1){const Y={};z[0].text&&(Y.text=z[0].text),z[0].mediaIds.length>0&&(Y.mediaIds=z[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&q?Y.replyTo=q:(t==null?void 0:t.mode)==="quote"&&q&&(Y.quoteTweetId=q);const Me=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Y)})).json();Me.success?(Q("success"),fe.current=setTimeout(()=>Q("idle"),2500)):(J(Me.error||"Post failed"),Q("error"),setTimeout(()=>Q("idle"),3e3))}else{const ne={tweets:z.map(ke=>({text:ke.text,...ke.mediaIds.length>0?{mediaIds:ke.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&q&&(ne.replyTo=q);const H=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)})).json();H.success?(Q("success"),fe.current=setTimeout(()=>Q("idle"),2500)):(J(H.error||"Thread post failed"),Q("error"),setTimeout(()=>Q("idle"),3e3))}}catch(oe){J(oe.message||"Network error"),Q("error"),setTimeout(()=>Q("idle"),3e3)}}};N.useEffect(()=>()=>{fe.current&&clearTimeout(fe.current)},[]);const j=()=>{_(!0),P(!1),fetch("/api/x/status").then(oe=>oe.json()).then(oe=>{oe.username&&T(oe.username)}).catch(()=>{})},le=B==="uploading"?"Uploading...":B==="posting"?"Posting...":B==="success"?"Posted!":B==="error"?"Failed":$?b===0?"Post Thread":"Post All":"Post",ye=u.map((oe,z)=>z===0?G?"Post your reply":"What is happening?!":"Add another tweet"),Ee=()=>g.jsx("div",{className:"tweet-thread-editors",children:u.map((oe,z)=>g.jsxs("div",{className:`tweet-thread-item${z===b?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[g.jsxs("div",{className:"tweet-thread-item-left",children:[g.jsx(eP,{}),z<u.length-1&&g.jsx("div",{className:"tweet-thread-line"})]}),g.jsxs("div",{className:"tweet-thread-item-right",children:[z>0&&g.jsx("button",{className:"tweet-thread-remove",onClick:()=>ee(z),title:"Remove this tweet",children:"×"}),g.jsx("div",{className:`tweet-compose-box${z===0&&!$?" tweet-compose-box--standalone":""}`,children:g.jsx(QD,{initialContent:oe,placeholder:ye[z],onUpdate:q=>K(z,q),onReady:q=>W(z,q),onFocus:()=>x(z)})}),z===b&&g.jsxs("div",{className:`tweet-compose-footer${z<u.length-1?" tweet-compose-footer--inline":""}`,children:[B==="error"&&X&&g.jsx("span",{className:"tweet-post-error",children:X}),g.jsx(XD,{count:h[b]||0}),g.jsx("button",{className:"tweet-thread-add",onClick:Z,title:"Add another tweet",children:g.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[g.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),g.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),g.jsx("button",{className:`tweet-post-btn${ie||!S&&S!==null?" tweet-post-btn--active":""}${B==="success"?" tweet-post-btn--success":""}${B==="error"?" tweet-post-btn--error":""}`,disabled:S?!ie:!1,onClick:R,title:S?M?`Post as @${M}`:"Post to X":"Connect X to post",children:le})]})]})]},z))});return g.jsxs("div",{className:"tweet-compose-wrapper",children:[he&&G&&g.jsxs(g.Fragment,{children:[l&&g.jsx("div",{className:"tweet-context-section",children:g.jsx(fv,{})}),c&&g.jsx("div",{className:"tweet-context-section",children:g.jsxs("div",{className:"tweet-embed-error",children:[g.jsx("span",{children:"Could not load tweet"}),g.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]})}),s&&g.jsx("div",{className:"tweet-reply-parent-section",children:g.jsxs("div",{className:"tweet-reply-thread",children:[g.jsxs("div",{className:"tweet-reply-thread-left",children:[s.author.avatarUrl?g.jsx("img",{className:"tweet-avatar",src:s.author.avatarUrl,alt:""}):g.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),g.jsx("div",{className:"tweet-reply-thread-line"})]}),g.jsxs("div",{className:"tweet-reply-thread-right",children:[g.jsxs("div",{className:"tweet-reply-parent",children:[g.jsxs("div",{className:"tweet-author-info",children:[g.jsx("span",{className:"tweet-author-name",children:s.author.name}),g.jsxs("span",{className:"tweet-author-handle",children:["@",s.author.username]})]}),g.jsx("div",{className:"tweet-text",children:s.text}),s.media&&s.media.length>0&&g.jsx("div",{className:"tweet-media",children:s.media.map((oe,z)=>oe.type==="photo"?g.jsx("img",{className:"tweet-media-img",src:oe.url,alt:"",loading:"lazy"},z):g.jsx("div",{className:"tweet-media-video-placeholder",children:g.jsx("span",{children:"Video"})},z))})]}),g.jsxs("div",{className:"tweet-replying-to-inline",children:["Replying to ",g.jsxs("span",{className:"tweet-reply-handle",children:["@",s.author.username]})]})]})]})}),Ee()]}),he&&!G&&g.jsxs(g.Fragment,{children:[Ee(),g.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[l&&g.jsx(fv,{}),c&&g.jsxs("div",{className:"tweet-embed-error",children:[g.jsx("span",{children:"Could not load tweet"}),g.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]}),s&&g.jsx(YD,{tweet:s})]})]}),!he&&Ee(),O&&g.jsx(ZD,{onConnected:j,onCancel:()=>P(!1)})]})}function iP(){const[t,e]=N.useState("idle"),n=N.useRef();return{copyAsHtml:N.useCallback(async()=>{const i=document.querySelector(".ProseMirror");if(!i)return;const s=i.cloneNode(!0);s.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(h=>h.remove());let l="";const c=document.querySelector(".article-cover-img");c!=null&&c.src&&(l+=`<img src="${c.src}" alt="Cover" style="width:100%;border-radius:8px;margin-bottom:16px" />
|
|
205
|
+
`);const u=document.querySelector(".article-title-input");u!=null&&u.value&&u.value!=="Untitled"&&(l+=`<h1>${u.value}</h1>
|
|
206
|
+
`);const f=l+s.innerHTML,p=sP(s);try{const h=new ClipboardItem({"text/html":new Blob([f],{type:"text/html"}),"text/plain":new Blob([p],{type:"text/plain"})});await navigator.clipboard.write([h])}catch{try{await navigator.clipboard.writeText(p)}catch{const h=document.createElement("textarea");h.value=p,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function sP(t){var n;const e=[];for(const r of t.children){const i=(n=r.innerText)==null?void 0:n.trim();i&&e.push(i)}return e.join(`
|
|
207
|
+
|
|
208
|
+
`)}const Sp="ow-x-handle",mv="ow-x-name",oP=new Set(["Untitled","New Document","Article"]);function lP({src:t,coverImages:e}){const[n,r]=N.useState(t?"display":"empty"),[i,s]=N.useState(t||""),[l,c]=N.useState(e||(t?[t]:[])),[u,f]=N.useState(""),[p,h]=N.useState(""),y=N.useRef(null);N.useEffect(()=>{t&&(s(t),r("display"))},[t]),N.useEffect(()=>{e&&e.length>0&&c(e)},[e]);const b=i?l.indexOf(i):-1,x=l.length,E=x>1,w=N.useCallback(X=>{const J=l[X];J&&(s(J),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:J,coverImages:l}})}).catch(()=>{}))},[l]),S=N.useCallback(()=>{b>0&&w(b-1)},[b,w]),_=N.useCallback(()=>{b<x-1&&w(b+1)},[b,x,w]),M=N.useCallback(async()=>{if(u.trim()){r("loading"),h("");try{const J=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(J.success&&J.src){const fe=[...l,J.src];c(fe),s(J.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:J.src,coverImages:fe}})}).catch(()=>{})}else h(J.error||"Generation failed"),r("prompt")}catch(X){h(X.message||"Network error"),r("prompt")}}},[u,l]),T=X=>{X.key==="Enter"&&M(),X.key==="Escape"&&(r("empty"),f(""),h(""))},O=()=>{r("prompt"),setTimeout(()=>{var X;return(X=y.current)==null?void 0:X.focus()},0)},P=()=>{const X=l.filter(J=>J!==i);if(c(X),X.length>0){const J=Math.min(b,X.length-1),fe=X[J];s(fe),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:fe,coverImages:X}})}).catch(()=>{})}else s(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},B=()=>{r("prompt"),setTimeout(()=>{var X;return(X=y.current)==null?void 0:X.focus()},0)},Q=()=>{const X=document.createElement("a");X.href=i,X.download=`cover-${b+1}.png`,X.click()};return n==="display"&&i?g.jsxs("div",{className:"article-cover article-cover--display",children:[g.jsx("img",{className:"article-cover-img",src:i,alt:"Cover"}),g.jsxs("div",{className:"article-cover-overlay",children:[E&&g.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:S,disabled:b<=0,children:g.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("polyline",{points:"15 18 9 12 15 6"})})}),g.jsxs("div",{className:"article-cover-overlay-center",children:[g.jsxs("button",{className:"article-cover-overlay-btn",onClick:B,children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("polyline",{points:"23 4 23 10 17 10"}),g.jsx("polyline",{points:"1 20 1 14 7 14"}),g.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),g.jsxs("button",{className:"article-cover-overlay-btn",onClick:Q,children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),g.jsx("polyline",{points:"7 10 12 15 17 10"}),g.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),g.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:P,children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),E&&g.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:_,disabled:b>=x-1,children:g.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("polyline",{points:"9 18 15 12 9 6"})})}),E&&g.jsxs("div",{className:"article-cover-counter",children:[b+1," / ",x]})]})]}):n==="loading"?g.jsxs("div",{className:"article-cover article-cover--loading",children:[g.jsx("div",{className:"article-cover-spinner"}),g.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?g.jsxs("div",{className:"article-cover article-cover--prompt",children:[g.jsxs("div",{className:"article-cover-prompt-row",children:[g.jsx("input",{ref:y,className:"article-cover-prompt-input",value:u,onChange:X=>f(X.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),g.jsx("button",{className:"article-cover-prompt-btn",onClick:M,disabled:!u.trim(),children:"Generate"}),g.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(i?"display":"empty"),f(""),h("")},children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&g.jsx("div",{className:"article-cover-error",children:p})]}):g.jsxs("div",{className:"article-cover article-cover--empty",onClick:O,children:[g.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:[g.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),g.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),g.jsx("polyline",{points:"21 15 16 10 5 21"})]}),g.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function aP(){const[t,e]=N.useState(()=>localStorage.getItem(Sp)||""),[n,r]=N.useState(()=>localStorage.getItem(mv)||""),[i,s]=N.useState(!1),[l,c]=N.useState(""),u=N.useRef(null),f=N.useRef(null),p=()=>{const x=l.replace(/^@/,"").trim();x&&(localStorage.setItem(Sp,x),e(x)),s(!1)},h=()=>{c(t),s(!0),setTimeout(()=>{var x;return(x=u.current)==null?void 0:x.focus()},0)};N.useEffect(()=>{if(!i)return;const x=E=>{f.current&&!f.current.contains(E.target)&&p()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[i,l]),N.useEffect(()=>{const x=()=>{e(localStorage.getItem(Sp)||""),r(localStorage.getItem(mv)||"")};return window.addEventListener("storage",x),()=>window.removeEventListener("storage",x)},[]);const y=t?`https://unavatar.io/twitter/${t}`:"",b=n||t||"Set your @handle";return g.jsxs("div",{className:"article-byline",ref:f,children:[g.jsxs("div",{className:"article-byline-row",onClick:h,title:t?`@${t} — click to change`:"Set your @handle",children:[t?g.jsx("img",{className:"article-byline-avatar",src:y,alt:`@${t}`}):g.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),g.jsx("span",{className:"article-byline-name",children:b}),t&&g.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),i&&g.jsx("div",{className:"article-byline-popover",children:g.jsx("input",{ref:u,className:"article-byline-input",value:l,onChange:x=>c(x.target.value),onKeyDown:x=>{x.key==="Enter"&&p(),x.key==="Escape"&&s(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function cP({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:i}){const{copyAsHtml:s,copyState:l}=iP();return g.jsxs("div",{className:"article-compose-wrapper",children:[g.jsx(lP,{src:r,coverImages:i}),g.jsxs("div",{className:"article-compose-content",children:[g.jsx("input",{className:"article-title-input",type:"text",value:oP.has(e||"")?"":e||"",onChange:c=>n==null?void 0:n(c.target.value||"Untitled"),placeholder:"Add a title",spellCheck:!1}),g.jsx(aP,{}),g.jsx("div",{className:"article-compose-body",children:t})]}),g.jsx("div",{className:"article-compose-footer",children:g.jsx("button",{className:`article-copy-btn${l==="copied"?" article-copy-btn--copied":""}`,onClick:s,children:l==="copied"?g.jsxs(g.Fragment,{children:[g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:g.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):g.jsxs(g.Fragment,{children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[g.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),g.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 uP(t){const e=t==null?void 0:t.articleContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function dP(){var gr,Pn;const t=N.useRef(null),[e,n]=N.useState(null),[r,i]=N.useState([]),[s,l]=N.useState("Untitled"),[c,u]=N.useState(void 0),[f,p]=N.useState(0),[h,y]=N.useState(!0),[b,x]=N.useState(0),[E,w]=N.useState(0),[S,_]=N.useState({filenames:[],counts:{}}),[M,T]=N.useState({state:"unconfigured"}),[O,P]=N.useState(!1),[B,Q]=N.useState({}),[X,J]=N.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[fe,K]=N.useState(null),[W,$]=N.useState(null),Z=N.useRef(0),ee=N.useRef(null),he=1500,G=N.useCallback((ae,Le)=>{ee.current&&(clearTimeout(ee.current),ee.current=null),Z.current=Date.now(),K(ae),$(Le)},[]),se=N.useCallback(()=>{if(ee.current)return;const ae=Date.now()-Z.current,Le=he-ae;Le<=0?(K(null),$(null)):ee.current=setTimeout(()=>{ee.current=null,K(null),$(null)},Le)},[]),[,ie]=N.useState(0),R=N.useRef(null),j=N.useRef(null),le=N.useRef([]),ye=N.useRef(-1),Ee=N.useRef(!1),oe=N.useRef(""),[z,q]=N.useState(""),[Y,ne]=N.useState(!1),[Me,H]=N.useState(!1),ke=uP(B);N.useEffect(()=>(ke?document.documentElement.setAttribute("data-view","article"):B!=null&&B.tweetContext?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[B==null?void 0:B.tweetContext,ke]),N.useEffect(()=>{const ae=()=>ie(Le=>Le+1);return window.addEventListener("ow-sidebar-mode-change",ae),()=>window.removeEventListener("ow-sidebar-mode-change",ae)},[]),N.useEffect(()=>{fetch("/api/document").then(ae=>ae.json()).then(ae=>{ae.document&&(u(ae.document),j.current=ae.document),ae.title&&l(ae.title),ae.metadata&&Q(ae.metadata)}).catch(()=>{u(void 0)}),fetch("/api/pending-docs").then(ae=>ae.json()).then(ae=>_(ae)).catch(()=>{}),fetch("/api/sync/status").then(ae=>ae.json()).then(ae=>T(ae)).catch(()=>{})},[]);const we=N.useCallback(ae=>{t.current=ae,n(ae),i([ae])},[]),$e=N.useCallback(ae=>{i(ae)},[]),Ae=N.useCallback(ae=>{const Le=oe.current==="",ft=ae.filename===oe.current;if(oe.current=ae.filename,j.current=ae.document,q(ae.filename),u(ae.document),l(ae.title),Q(ae.metadata||{}),!ft&&!Le&&p(Bt=>Bt+1),x(Bt=>Bt+1),Ee.current){const Bt=le.current[ye.current];Bt&&setTimeout(()=>{const Ut=document.querySelector(".editor-container");Ut&&(Ut.scrollTop=Bt.scrollTop)},50),Ee.current=!1}ne(ye.current>0),H(ye.current<le.current.length-1)},[]),je=N.useCallback(()=>{x(ae=>ae+1)},[]),ze=N.useCallback(()=>{w(ae=>ae+1)},[]),yn=N.useCallback(ae=>{_(ae)},[]),{sendMessage:tt}=UD({onNodeChanges:ae=>{const Le=t.current;Le&&lD(Le,ae)},onDocumentSwitched:Ae,onDocumentsChanged:je,onWorkspacesChanged:ze,onPendingDocsChanged:yn,onMetadataChanged:ae=>Q(ae),onWritingStarted:(ae,Le)=>G(ae,Le),onWritingFinished:()=>se(),onSyncStatus:ae=>T(ae),onTitleChanged:ae=>l(ae),getEditorState:()=>{var Le;const ae=j.current||((Le=t.current)==null?void 0:Le.getJSON());return ae?{document:ae}:null}}),gt=N.useCallback(()=>{var Le;R.current&&(clearTimeout(R.current),R.current=null);const ae=j.current||((Le=t.current)==null?void 0:Le.getJSON());ae&&tt({type:"doc-update",document:ae,filename:oe.current})},[tt]);N.useEffect(()=>{const ae=()=>{var Ut;R.current&&(clearTimeout(R.current),R.current=null);const ft=j.current||((Ut=t.current)==null?void 0:Ut.getJSON());if(!ft)return;const Bt=JSON.stringify({type:"flush",document:ft});navigator.sendBeacon("/api/flush",new Blob([Bt],{type:"application/json"}))},Le=()=>{document.visibilityState==="hidden"&&ae()};return window.addEventListener("beforeunload",ae),document.addEventListener("visibilitychange",Le),()=>{window.removeEventListener("beforeunload",ae),document.removeEventListener("visibilitychange",Le)}},[]);const et=N.useCallback(()=>{gt(),tt({type:"create-document"})},[gt,tt]),Vn=N.useCallback((ae,Le)=>{gt(),tt({type:"create-template",template:ae,url:Le})},[gt,tt]),Jt=N.useCallback(ae=>{const Le=document.querySelector(".editor-container"),ft=(Le==null?void 0:Le.scrollTop)||0;!Ee.current&&oe.current&&(le.current=le.current.slice(0,ye.current+1),le.current.push({filename:oe.current,scrollTop:ft}),ye.current=le.current.length-1),gt(),tt({type:"switch-document",filename:ae})},[gt,tt]),tr=N.useCallback(()=>{if(ye.current<=0)return;const ae=document.querySelector(".editor-container"),Le=(ae==null?void 0:ae.scrollTop)||0;ye.current===le.current.length-1&&oe.current?(le.current=le.current.slice(0,ye.current+1),le.current.push({filename:oe.current,scrollTop:Le})):oe.current&&(le.current[ye.current+1]={filename:oe.current,scrollTop:Le});const ft=le.current[ye.current];ye.current--,Ee.current=!0,ne(ye.current>0),H(!0),gt(),tt({type:"switch-document",filename:ft.filename})},[gt,tt]),Xt=N.useCallback(()=>{if(ye.current>=le.current.length-2)return;const ae=document.querySelector(".editor-container"),Le=(ae==null?void 0:ae.scrollTop)||0;oe.current&&(le.current[ye.current+1]={filename:oe.current,scrollTop:Le}),ye.current++;const ft=le.current[ye.current+1];Ee.current=!0,ne(!0),H(ye.current<le.current.length-2),gt(),tt({type:"switch-document",filename:ft.filename})},[gt,tt]),bn=N.useCallback(()=>{const ae=oe.current,Le=t.current;!ae||!Le||fetch(`/api/marks/${encodeURIComponent(ae)}`).then(ft=>ft.json()).then(ft=>{J0(ft.marks||[]),X0(Le.view)}).catch(()=>{J0([]),Le!=null&&Le.view&&X0(Le.view)})},[]);N.useEffect(()=>{bn()},[z,bn]),N.useEffect(()=>{const ae=Le=>{const ft=Le.detail;(ft==null?void 0:ft.filename)===oe.current&&bn()};return window.addEventListener("ow-marks-changed",ae),()=>window.removeEventListener("ow-marks-changed",ae)},[bn]),N.useEffect(()=>{const ae=Le=>{Le.altKey&&Le.key==="ArrowLeft"&&(Le.preventDefault(),tr()),Le.altKey&&Le.key==="ArrowRight"&&(Le.preventDefault(),Xt())};return window.addEventListener("keydown",ae),()=>window.removeEventListener("keydown",ae)},[tr,Xt]);const Kn=N.useCallback(ae=>{j.current=ae,R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{tt({type:"doc-update",document:ae,filename:oe.current})},1e3)},[tt]),Mr=N.useCallback(ae=>{l(ae),tt({type:"title-update",title:ae})},[tt]),nr=N.useCallback(()=>{J(ae=>(localStorage.setItem("ow-toolbar",ae?"hidden":"visible"),!ae))},[]),Gn=N.useCallback(()=>{if(M.state==="unconfigured"){P(!0);return}gt(),tt({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[M.state,gt,tt]),Ar=Du()==="board";return g.jsxs("div",{className:"app",children:[!Ar&&g.jsx(av,{open:h,onSwitchDocument:Jt,onCreateDocument:et,refreshKey:b,workspacesRefreshKey:E,pendingDocs:S,writingTitle:fe,writingTarget:W,onClose:()=>y(!1)}),g.jsxs("div",{className:"app-main",children:[g.jsx(rD,{title:s,onTitleChange:Mr,syncStatus:M,onSync:Gn,onToggleSidebar:!Ar&&!h?()=>y(!0):void 0,canGoBack:Y,canGoForward:Me,onGoBack:tr,onGoForward:Xt,editor:e,onToggleToolbar:nr,toolbarOpen:X,onCreateTemplate:Vn}),X&&e&&g.jsx($L,{editor:e}),Ar&&g.jsx(av,{open:!0,onSwitchDocument:Jt,onCreateDocument:et,refreshKey:b,workspacesRefreshKey:E,pendingDocs:S,writingTitle:fe,writingTarget:W}),g.jsx("div",{className:"editor-container",children:ke?g.jsx(cP,{title:s,onTitleChange:Mr,coverImage:(gr=B==null?void 0:B.articleContext)==null?void 0:gr.coverImage,coverImages:(Pn=B==null?void 0:B.articleContext)==null?void 0:Pn.coverImages,children:g.jsx(ev,{initialContent:c,extensions:OL,onUpdate:Kn,onReady:we,onLinkClick:Jt},f)}):B!=null&&B.tweetContext?g.jsx(rP,{tweetContext:B.tweetContext,initialContent:c,onUpdate:Kn,onEditorReady:we,onEditorsChange:$e},f):g.jsx(ev,{initialContent:c,onUpdate:Kn,onReady:we,onLinkClick:Jt},f)}),g.jsx(TD,{editors:r,pendingDocs:S,currentFilename:z,onSwitchDocument:Jt,sendMessage:tt,getDocument:()=>j.current})]}),g.jsx(fD,{editorRef:t,documentId:z}),O&&g.jsx($D,{onClose:()=>P(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(ae=>ae.json()).then(T).catch(()=>{})}})]})}iS();ZE.createRoot(document.getElementById("root")).render(g.jsx(Ki.StrictMode,{children:g.jsx(dP,{})}));
|