openwriter 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,215 +0,0 @@
1
- (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var q0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Il(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Wh={exports:{}},Ya={},Vh={exports:{}},Ot={};/**
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 K0;function xM(){if(K0)return Ot;K0=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(A){return A===null||typeof A!="object"?null:(A=m&&A[m]||A["@@iterator"],typeof A=="function"?A:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,k={};function w(A,L,ee){this.props=A,this.context=L,this.refs=k,this.updater=ee||v}w.prototype.isReactComponent={},w.prototype.setState=function(A,L){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,L,"setState")},w.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function S(){}S.prototype=w.prototype;function N(A,L,ee){this.props=A,this.context=L,this.refs=k,this.updater=ee||v}var T=N.prototype=new S;T.constructor=N,x(T,w.prototype),T.isPureReactComponent=!0;var M=Array.isArray,_=Object.prototype.hasOwnProperty,R={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function $(A,L,ee){var pe,xe={},re=null,Ne=null;if(L!=null)for(pe in L.ref!==void 0&&(Ne=L.ref),L.key!==void 0&&(re=""+L.key),L)_.call(L,pe)&&!I.hasOwnProperty(pe)&&(xe[pe]=L[pe]);var ke=arguments.length-2;if(ke===1)xe.children=ee;else if(1<ke){for(var ze=Array(ke),Fe=0;Fe<ke;Fe++)ze[Fe]=arguments[Fe+2];xe.children=ze}if(A&&A.defaultProps)for(pe in ke=A.defaultProps,ke)xe[pe]===void 0&&(xe[pe]=ke[pe]);return{$$typeof:t,type:A,key:re,ref:Ne,props:xe,_owner:R.current}}function P(A,L){return{$$typeof:t,type:A.type,key:L,ref:A.ref,props:A.props,_owner:A._owner}}function z(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function q(A){var L={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(ee){return L[ee]})}var F=/\/+/g;function G(A,L){return typeof A=="object"&&A!==null&&A.key!=null?q(""+A.key):L.toString(36)}function B(A,L,ee,pe,xe){var re=typeof A;(re==="undefined"||re==="boolean")&&(A=null);var Ne=!1;if(A===null)Ne=!0;else switch(re){case"string":case"number":Ne=!0;break;case"object":switch(A.$$typeof){case t:case e:Ne=!0}}if(Ne)return Ne=A,xe=xe(Ne),A=pe===""?"."+G(Ne,0):pe,M(xe)?(ee="",A!=null&&(ee=A.replace(F,"$&/")+"/"),B(xe,L,ee,"",function(Fe){return Fe})):xe!=null&&(z(xe)&&(xe=P(xe,ee+(!xe.key||Ne&&Ne.key===xe.key?"":(""+xe.key).replace(F,"$&/")+"/")+A)),L.push(xe)),1;if(Ne=0,pe=pe===""?".":pe+":",M(A))for(var ke=0;ke<A.length;ke++){re=A[ke];var ze=pe+G(re,ke);Ne+=B(re,L,ee,ze,xe)}else if(ze=g(A),typeof ze=="function")for(A=ze.call(A),ke=0;!(re=A.next()).done;)re=re.value,ze=pe+G(re,ke++),Ne+=B(re,L,ee,ze,xe);else if(re==="object")throw L=String(A),Error("Objects are not valid as a React child (found: "+(L==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":L)+"). If you meant to render a collection of children, use an array instead.");return Ne}function W(A,L,ee){if(A==null)return A;var pe=[],xe=0;return B(A,pe,"","",function(re){return L.call(ee,re,xe++)}),pe}function K(A){if(A._status===-1){var L=A._result;L=L(),L.then(function(ee){(A._status===0||A._status===-1)&&(A._status=1,A._result=ee)},function(ee){(A._status===0||A._status===-1)&&(A._status=2,A._result=ee)}),A._status===-1&&(A._status=0,A._result=L)}if(A._status===1)return A._result.default;throw A._result}var ne={current:null},V={transition:null},oe={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:V,ReactCurrentOwner:R};function J(){throw Error("act(...) is not supported in production builds of React.")}return Ot.Children={map:W,forEach:function(A,L,ee){W(A,function(){L.apply(this,arguments)},ee)},count:function(A){var L=0;return W(A,function(){L++}),L},toArray:function(A){return W(A,function(L){return L})||[]},only:function(A){if(!z(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},Ot.Component=w,Ot.Fragment=n,Ot.Profiler=s,Ot.PureComponent=N,Ot.StrictMode=r,Ot.Suspense=d,Ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=oe,Ot.act=J,Ot.cloneElement=function(A,L,ee){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var pe=x({},A.props),xe=A.key,re=A.ref,Ne=A._owner;if(L!=null){if(L.ref!==void 0&&(re=L.ref,Ne=R.current),L.key!==void 0&&(xe=""+L.key),A.type&&A.type.defaultProps)var ke=A.type.defaultProps;for(ze in L)_.call(L,ze)&&!I.hasOwnProperty(ze)&&(pe[ze]=L[ze]===void 0&&ke!==void 0?ke[ze]:L[ze])}var ze=arguments.length-2;if(ze===1)pe.children=ee;else if(1<ze){ke=Array(ze);for(var Fe=0;Fe<ze;Fe++)ke[Fe]=arguments[Fe+2];pe.children=ke}return{$$typeof:t,type:A.type,key:xe,ref:re,props:pe,_owner:Ne}},Ot.createContext=function(A){return A={$$typeof:o,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:i,_context:A},A.Consumer=A},Ot.createElement=$,Ot.createFactory=function(A){var L=$.bind(null,A);return L.type=A,L},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(A){return{$$typeof:l,render:A}},Ot.isValidElement=z,Ot.lazy=function(A){return{$$typeof:h,_payload:{_status:-1,_result:A},_init:K}},Ot.memo=function(A,L){return{$$typeof:f,type:A,compare:L===void 0?null:L}},Ot.startTransition=function(A){var L=V.transition;V.transition={};try{A()}finally{V.transition=L}},Ot.unstable_act=J,Ot.useCallback=function(A,L){return ne.current.useCallback(A,L)},Ot.useContext=function(A){return ne.current.useContext(A)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(A){return ne.current.useDeferredValue(A)},Ot.useEffect=function(A,L){return ne.current.useEffect(A,L)},Ot.useId=function(){return ne.current.useId()},Ot.useImperativeHandle=function(A,L,ee){return ne.current.useImperativeHandle(A,L,ee)},Ot.useInsertionEffect=function(A,L){return ne.current.useInsertionEffect(A,L)},Ot.useLayoutEffect=function(A,L){return ne.current.useLayoutEffect(A,L)},Ot.useMemo=function(A,L){return ne.current.useMemo(A,L)},Ot.useReducer=function(A,L,ee){return ne.current.useReducer(A,L,ee)},Ot.useRef=function(A){return ne.current.useRef(A)},Ot.useState=function(A){return ne.current.useState(A)},Ot.useSyncExternalStore=function(A,L,ee){return ne.current.useSyncExternalStore(A,L,ee)},Ot.useTransition=function(){return ne.current.useTransition()},Ot.version="18.3.1",Ot}var G0;function Ll(){return G0||(G0=1,Vh.exports=xM()),Vh.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 J0;function wM(){if(J0)return Ya;J0=1;var t=Ll(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,d,f){var h,m={},g=null,v=null;f!==void 0&&(g=""+f),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(v=d.ref);for(h in d)r.call(d,h)&&!i.hasOwnProperty(h)&&(m[h]=d[h]);if(l&&l.defaultProps)for(h in d=l.defaultProps,d)m[h]===void 0&&(m[h]=d[h]);return{$$typeof:e,type:l,key:g,ref:v,props:m,_owner:s.current}}return Ya.Fragment=n,Ya.jsx=o,Ya.jsxs=o,Ya}var Y0;function kM(){return Y0||(Y0=1,Wh.exports=wM()),Wh.exports}var c=kM(),b=Ll();const Mi=Il(b);var Jc={},qh={exports:{}},wr={},Kh={exports:{}},Gh={};/**
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 X0;function SM(){return X0||(X0=1,(function(t){function e(V,oe){var J=V.length;V.push(oe);e:for(;0<J;){var A=J-1>>>1,L=V[A];if(0<s(L,oe))V[A]=oe,V[J]=L,J=A;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var oe=V[0],J=V.pop();if(J!==oe){V[0]=J;e:for(var A=0,L=V.length,ee=L>>>1;A<ee;){var pe=2*(A+1)-1,xe=V[pe],re=pe+1,Ne=V[re];if(0>s(xe,J))re<L&&0>s(Ne,xe)?(V[A]=Ne,V[re]=J,A=re):(V[A]=xe,V[pe]=J,A=pe);else if(re<L&&0>s(Ne,J))V[A]=Ne,V[re]=J,A=re;else break e}}return oe}function s(V,oe){var J=V.sortIndex-oe.sortIndex;return J!==0?J:V.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var d=[],f=[],h=1,m=null,g=3,v=!1,x=!1,k=!1,w=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function T(V){for(var oe=n(f);oe!==null;){if(oe.callback===null)r(f);else if(oe.startTime<=V)r(f),oe.sortIndex=oe.expirationTime,e(d,oe);else break;oe=n(f)}}function M(V){if(k=!1,T(V),!x)if(n(d)!==null)x=!0,K(_);else{var oe=n(f);oe!==null&&ne(M,oe.startTime-V)}}function _(V,oe){x=!1,k&&(k=!1,S($),$=-1),v=!0;var J=g;try{for(T(oe),m=n(d);m!==null&&(!(m.expirationTime>oe)||V&&!q());){var A=m.callback;if(typeof A=="function"){m.callback=null,g=m.priorityLevel;var L=A(m.expirationTime<=oe);oe=t.unstable_now(),typeof L=="function"?m.callback=L:m===n(d)&&r(d),T(oe)}else r(d);m=n(d)}if(m!==null)var ee=!0;else{var pe=n(f);pe!==null&&ne(M,pe.startTime-oe),ee=!1}return ee}finally{m=null,g=J,v=!1}}var R=!1,I=null,$=-1,P=5,z=-1;function q(){return!(t.unstable_now()-z<P)}function F(){if(I!==null){var V=t.unstable_now();z=V;var oe=!0;try{oe=I(!0,V)}finally{oe?G():(R=!1,I=null)}}else R=!1}var G;if(typeof N=="function")G=function(){N(F)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,W=B.port2;B.port1.onmessage=F,G=function(){W.postMessage(null)}}else G=function(){w(F,0)};function K(V){I=V,R||(R=!0,G())}function ne(V,oe){$=w(function(){V(t.unstable_now())},oe)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(V){V.callback=null},t.unstable_continueExecution=function(){x||v||(x=!0,K(_))},t.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<V?Math.floor(1e3/V):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(d)},t.unstable_next=function(V){switch(g){case 1:case 2:case 3:var oe=3;break;default:oe=g}var J=g;g=oe;try{return V()}finally{g=J}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(V,oe){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var J=g;g=V;try{return oe()}finally{g=J}},t.unstable_scheduleCallback=function(V,oe,J){var A=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?A+J:A):J=A,V){case 1:var L=-1;break;case 2:L=250;break;case 5:L=1073741823;break;case 4:L=1e4;break;default:L=5e3}return L=J+L,V={id:h++,callback:oe,priorityLevel:V,startTime:J,expirationTime:L,sortIndex:-1},J>A?(V.sortIndex=J,e(f,V),n(d)===null&&V===n(f)&&(k?(S($),$=-1):k=!0,ne(M,J-A))):(V.sortIndex=L,e(d,V),x||v||(x=!0,K(_))),V},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(V){var oe=g;return function(){var J=g;g=oe;try{return V.apply(this,arguments)}finally{g=J}}}})(Gh)),Gh}var Q0;function EM(){return Q0||(Q0=1,Kh.exports=SM()),Kh.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 Z0;function NM(){if(Z0)return wr;Z0=1;var t=Ll(),e=EM();function n(a){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+a,p=1;p<arguments.length;p++)u+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+a+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(a,u){o(a,u),o(a+"Capture",u)}function o(a,u){for(s[a]=u,a=0;a<u.length;a++)r.add(u[a])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},m={};function g(a){return d.call(m,a)?!0:d.call(h,a)?!1:f.test(a)?m[a]=!0:(h[a]=!0,!1)}function v(a,u,p,y){if(p!==null&&p.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return y?!1:p!==null?!p.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function x(a,u,p,y){if(u===null||typeof u>"u"||v(a,u,p,y))return!0;if(y)return!1;if(p!==null)switch(p.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function k(a,u,p,y,E,C,O){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=y,this.attributeNamespace=E,this.mustUseProperty=p,this.propertyName=a,this.type=u,this.sanitizeURL=C,this.removeEmptyString=O}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){w[a]=new k(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var u=a[0];w[u]=new k(u,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){w[a]=new k(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){w[a]=new k(a,2,!1,a,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(a){w[a]=new k(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){w[a]=new k(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){w[a]=new k(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){w[a]=new k(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){w[a]=new k(a,5,!1,a.toLowerCase(),null,!1,!1)});var S=/[\-:]([a-z])/g;function N(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var u=a.replace(S,N);w[u]=new k(u,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var u=a.replace(S,N);w[u]=new k(u,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var u=a.replace(S,N);w[u]=new k(u,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!1,!1)}),w.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){w[a]=new k(a,1,!1,a.toLowerCase(),null,!0,!0)});function T(a,u,p,y){var E=w.hasOwnProperty(u)?w[u]:null;(E!==null?E.type!==0:y||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(x(u,p,E,y)&&(p=null),y||E===null?g(u)&&(p===null?a.removeAttribute(u):a.setAttribute(u,""+p)):E.mustUseProperty?a[E.propertyName]=p===null?E.type===3?!1:"":p:(u=E.attributeName,y=E.attributeNamespace,p===null?a.removeAttribute(u):(E=E.type,p=E===3||E===4&&p===!0?"":""+p,y?a.setAttributeNS(y,u,p):a.setAttribute(u,p))))}var M=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),R=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),z=Symbol.for("react.provider"),q=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),G=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),ne=Symbol.for("react.offscreen"),V=Symbol.iterator;function oe(a){return a===null||typeof a!="object"?null:(a=V&&a[V]||a["@@iterator"],typeof a=="function"?a:null)}var J=Object.assign,A;function L(a){if(A===void 0)try{throw Error()}catch(p){var u=p.stack.trim().match(/\n( *(at )?)/);A=u&&u[1]||""}return`
34
- `+A+a}var ee=!1;function pe(a,u){if(!a||ee)return"";ee=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ue){var y=ue}Reflect.construct(a,[],u)}else{try{u.call()}catch(ue){y=ue}a.call(u.prototype)}else{try{throw Error()}catch(ue){y=ue}a()}}catch(ue){if(ue&&y&&typeof ue.stack=="string"){for(var E=ue.stack.split(`
35
- `),C=y.stack.split(`
36
- `),O=E.length-1,H=C.length-1;1<=O&&0<=H&&E[O]!==C[H];)H--;for(;1<=O&&0<=H;O--,H--)if(E[O]!==C[H]){if(O!==1||H!==1)do if(O--,H--,0>H||E[O]!==C[H]){var X=`
37
- `+E[O].replace(" at new "," at ");return a.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",a.displayName)),X}while(1<=O&&0<=H);break}}}finally{ee=!1,Error.prepareStackTrace=p}return(a=a?a.displayName||a.name:"")?L(a):""}function xe(a){switch(a.tag){case 5:return L(a.type);case 16:return L("Lazy");case 13:return L("Suspense");case 19:return L("SuspenseList");case 0:case 2:case 15:return a=pe(a.type,!1),a;case 11:return a=pe(a.type.render,!1),a;case 1:return a=pe(a.type,!0),a;default:return""}}function re(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case I:return"Fragment";case R:return"Portal";case P:return"Profiler";case $:return"StrictMode";case G:return"Suspense";case B:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case q:return(a.displayName||"Context")+".Consumer";case z:return(a._context.displayName||"Context")+".Provider";case F:var u=a.render;return a=a.displayName,a||(a=u.displayName||u.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case W:return u=a.displayName||null,u!==null?u:re(a.type)||"Memo";case K:u=a._payload,a=a._init;try{return re(a(u))}catch{}}return null}function Ne(a){var u=a.type;switch(a.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=u.render,a=a.displayName||a.name||"",u.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return re(u);case 8:return u===$?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function ke(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ze(a){var u=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function Fe(a){var u=ze(a)?"checked":"value",p=Object.getOwnPropertyDescriptor(a.constructor.prototype,u),y=""+a[u];if(!a.hasOwnProperty(u)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var E=p.get,C=p.set;return Object.defineProperty(a,u,{configurable:!0,get:function(){return E.call(this)},set:function(O){y=""+O,C.call(this,O)}}),Object.defineProperty(a,u,{enumerable:p.enumerable}),{getValue:function(){return y},setValue:function(O){y=""+O},stopTracking:function(){a._valueTracker=null,delete a[u]}}}}function Ge(a){a._valueTracker||(a._valueTracker=Fe(a))}function Re(a){if(!a)return!1;var u=a._valueTracker;if(!u)return!0;var p=u.getValue(),y="";return a&&(y=ze(a)?a.checked?"true":"false":a.value),a=y,a!==p?(u.setValue(a),!0):!1}function Ze(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function gt(a,u){var p=u.checked;return J({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??a._wrapperState.initialChecked})}function ht(a,u){var p=u.defaultValue==null?"":u.defaultValue,y=u.checked!=null?u.checked:u.defaultChecked;p=ke(u.value!=null?u.value:p),a._wrapperState={initialChecked:y,initialValue:p,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function ge(a,u){u=u.checked,u!=null&&T(a,"checked",u,!1)}function vt(a,u){ge(a,u);var p=ke(u.value),y=u.type;if(p!=null)y==="number"?(p===0&&a.value===""||a.value!=p)&&(a.value=""+p):a.value!==""+p&&(a.value=""+p);else if(y==="submit"||y==="reset"){a.removeAttribute("value");return}u.hasOwnProperty("value")?Et(a,u.type,p):u.hasOwnProperty("defaultValue")&&Et(a,u.type,ke(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(a.defaultChecked=!!u.defaultChecked)}function _t(a,u,p){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var y=u.type;if(!(y!=="submit"&&y!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+a._wrapperState.initialValue,p||u===a.value||(a.value=u),a.defaultValue=u}p=a.name,p!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,p!==""&&(a.name=p)}function Et(a,u,p){(u!=="number"||Ze(a.ownerDocument)!==a)&&(p==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+p&&(a.defaultValue=""+p))}var Dt=Array.isArray;function ot(a,u,p,y){if(a=a.options,u){u={};for(var E=0;E<p.length;E++)u["$"+p[E]]=!0;for(p=0;p<a.length;p++)E=u.hasOwnProperty("$"+a[p].value),a[p].selected!==E&&(a[p].selected=E),E&&y&&(a[p].defaultSelected=!0)}else{for(p=""+ke(p),u=null,E=0;E<a.length;E++){if(a[E].value===p){a[E].selected=!0,y&&(a[E].defaultSelected=!0);return}u!==null||a[E].disabled||(u=a[E])}u!==null&&(u.selected=!0)}}function Le(a,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return J({},u,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function ve(a,u){var p=u.value;if(p==null){if(p=u.children,u=u.defaultValue,p!=null){if(u!=null)throw Error(n(92));if(Dt(p)){if(1<p.length)throw Error(n(93));p=p[0]}u=p}u==null&&(u=""),p=u}a._wrapperState={initialValue:ke(p)}}function te(a,u){var p=ke(u.value),y=ke(u.defaultValue);p!=null&&(p=""+p,p!==a.value&&(a.value=p),u.defaultValue==null&&a.defaultValue!==p&&(a.defaultValue=p)),y!=null&&(a.defaultValue=""+y)}function je(a){var u=a.textContent;u===a._wrapperState.initialValue&&u!==""&&u!==null&&(a.value=u)}function Q(a){switch(a){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function de(a,u){return a==null||a==="http://www.w3.org/1999/xhtml"?Q(u):a==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var fe,Je=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,p,y,E){MSApp.execUnsafeLocalFunction(function(){return a(u,p,y,E)})}:a})(function(a,u){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=u;else{for(fe=fe||document.createElement("div"),fe.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=fe.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;u.firstChild;)a.appendChild(u.firstChild)}});function Ie(a,u){if(u){var p=a.firstChild;if(p&&p===a.lastChild&&p.nodeType===3){p.nodeValue=u;return}}a.textContent=u}var it={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},dt=["Webkit","ms","Moz","O"];Object.keys(it).forEach(function(a){dt.forEach(function(u){u=u+a.charAt(0).toUpperCase()+a.substring(1),it[u]=it[a]})});function at(a,u,p){return u==null||typeof u=="boolean"||u===""?"":p||typeof u!="number"||u===0||it.hasOwnProperty(a)&&it[a]?(""+u).trim():u+"px"}function Ye(a,u){a=a.style;for(var p in u)if(u.hasOwnProperty(p)){var y=p.indexOf("--")===0,E=at(p,u[p],y);p==="float"&&(p="cssFloat"),y?a.setProperty(p,E):a[p]=E}}var qe=J({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 lt(a,u){if(u){if(qe[a]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function bt(a,u){if(a.indexOf("-")===-1)return typeof u.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ce=null;function Se(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var We=null,tt=null,He=null;function xt(a){if(a=La(a)){if(typeof We!="function")throw Error(n(280));var u=a.stateNode;u&&(u=uc(u),We(a.stateNode,a.type,u))}}function j(a){tt?He?He.push(a):He=[a]:tt=a}function U(){if(tt){var a=tt,u=He;if(He=tt=null,xt(a),u)for(a=0;a<u.length;a++)xt(u[a])}}function ie(a,u){return a(u)}function D(){}var ce=!1;function me(a,u,p){if(ce)return a(u,p);ce=!0;try{return ie(a,u,p)}finally{ce=!1,(tt!==null||He!==null)&&(D(),U())}}function se(a,u){var p=a.stateNode;if(p===null)return null;var y=uc(p);if(y===null)return null;p=y[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(y=!y.disabled)||(a=a.type,y=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!y;break e;default:a=!1}if(a)return null;if(p&&typeof p!="function")throw Error(n(231,u,typeof p));return p}var he=!1;if(l)try{var be={};Object.defineProperty(be,"passive",{get:function(){he=!0}}),window.addEventListener("test",be,be),window.removeEventListener("test",be,be)}catch{he=!1}function Be(a,u,p,y,E,C,O,H,X){var ue=Array.prototype.slice.call(arguments,3);try{u.apply(p,ue)}catch(Te){this.onError(Te)}}var Ee=!1,Ht=null,Tt=!1,cn=null,xn={onError:function(a){Ee=!0,Ht=a}};function Nn(a,u,p,y,E,C,O,H,X){Ee=!1,Ht=null,Be.apply(xn,arguments)}function Ve(a,u,p,y,E,C,O,H,X){if(Nn.apply(this,arguments),Ee){if(Ee){var ue=Ht;Ee=!1,Ht=null}else throw Error(n(198));Tt||(Tt=!0,cn=ue)}}function Vt(a){var u=a,p=a;if(a.alternate)for(;u.return;)u=u.return;else{a=u;do u=a,(u.flags&4098)!==0&&(p=u.return),a=u.return;while(a)}return u.tag===3?p:null}function Un(a){if(a.tag===13){var u=a.memoizedState;if(u===null&&(a=a.alternate,a!==null&&(u=a.memoizedState)),u!==null)return u.dehydrated}return null}function fn(a){if(Vt(a)!==a)throw Error(n(188))}function mr(a){var u=a.alternate;if(!u){if(u=Vt(a),u===null)throw Error(n(188));return u!==a?null:a}for(var p=a,y=u;;){var E=p.return;if(E===null)break;var C=E.alternate;if(C===null){if(y=E.return,y!==null){p=y;continue}break}if(E.child===C.child){for(C=E.child;C;){if(C===p)return fn(E),a;if(C===y)return fn(E),u;C=C.sibling}throw Error(n(188))}if(p.return!==y.return)p=E,y=C;else{for(var O=!1,H=E.child;H;){if(H===p){O=!0,p=E,y=C;break}if(H===y){O=!0,y=E,p=C;break}H=H.sibling}if(!O){for(H=C.child;H;){if(H===p){O=!0,p=C,y=E;break}if(H===y){O=!0,y=C,p=E;break}H=H.sibling}if(!O)throw Error(n(189))}}if(p.alternate!==y)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?a:u}function Xt(a){return a=mr(a),a!==null?Hn(a):null}function Hn(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var u=Hn(a);if(u!==null)return u;a=a.sibling}return null}var lr=e.unstable_scheduleCallback,cr=e.unstable_cancelCallback,_s=e.unstable_shouldYield,Ir=e.unstable_requestPaint,Bt=e.unstable_now,Lr=e.unstable_getCurrentPriorityLevel,Ys=e.unstable_ImmediatePriority,Qr=e.unstable_UserBlockingPriority,hs=e.unstable_NormalPriority,Ae=e.unstable_LowPriority,nt=e.unstable_IdlePriority,Ct=null,Mt=null;function an(a){if(Mt&&typeof Mt.onCommitFiberRoot=="function")try{Mt.onCommitFiberRoot(Ct,a,void 0,(a.current.flags&128)===128)}catch{}}var nn=Math.clz32?Math.clz32:An,Nr=Math.log,Ts=Math.LN2;function An(a){return a>>>=0,a===0?32:31-(Nr(a)/Ts|0)|0}var Y=64,ye=4194304;function De(a){switch(a&-a){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function wt(a,u){var p=a.pendingLanes;if(p===0)return 0;var y=0,E=a.suspendedLanes,C=a.pingedLanes,O=p&268435455;if(O!==0){var H=O&~E;H!==0?y=De(H):(C&=O,C!==0&&(y=De(C)))}else O=p&~E,O!==0?y=De(O):C!==0&&(y=De(C));if(y===0)return 0;if(u!==0&&u!==y&&(u&E)===0&&(E=y&-y,C=u&-u,E>=C||E===16&&(C&4194240)!==0))return u;if((y&4)!==0&&(y|=p&16),u=a.entangledLanes,u!==0)for(a=a.entanglements,u&=y;0<u;)p=31-nn(u),E=1<<p,y|=a[p],u&=~E;return y}function jt(a,u){switch(a){case 1:case 2:case 4:return u+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 u+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 Zn(a,u){for(var p=a.suspendedLanes,y=a.pingedLanes,E=a.expirationTimes,C=a.pendingLanes;0<C;){var O=31-nn(C),H=1<<O,X=E[O];X===-1?((H&p)===0||(H&y)!==0)&&(E[O]=jt(H,u)):X<=u&&(a.expiredLanes|=H),C&=~H}}function Wn(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function ps(){var a=Y;return Y<<=1,(Y&4194240)===0&&(Y=64),a}function Kt(a){for(var u=[],p=0;31>p;p++)u.push(a);return u}function Rn(a,u,p){a.pendingLanes|=u,u!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,u=31-nn(u),a[u]=p}function Dr(a,u){var p=a.pendingLanes&~u;a.pendingLanes=u,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=u,a.mutableReadLanes&=u,a.entangledLanes&=u,u=a.entanglements;var y=a.eventTimes;for(a=a.expirationTimes;0<p;){var E=31-nn(p),C=1<<E;u[E]=0,y[E]=-1,a[E]=-1,p&=~C}}function ba(a,u){var p=a.entangledLanes|=u;for(a=a.entanglements;p;){var y=31-nn(p),E=1<<y;E&u|a[y]&u&&(a[y]|=u),p&=~E}}var $t=0;function Nt(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var xa,wn,Yt,Fi,ms,zi=!1,Xs=[],$e=null,Xe=null,kt=null,Lt=new Map,hn=new Map,On=[],mf="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 Jl(a,u){switch(a){case"focusin":case"focusout":$e=null;break;case"dragenter":case"dragleave":Xe=null;break;case"mouseover":case"mouseout":kt=null;break;case"pointerover":case"pointerout":Lt.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":hn.delete(u.pointerId)}}function wa(a,u,p,y,E,C){return a===null||a.nativeEvent!==C?(a={blockedOn:u,domEventName:p,eventSystemFlags:y,nativeEvent:C,targetContainers:[E]},u!==null&&(u=La(u),u!==null&&wn(u)),a):(a.eventSystemFlags|=y,u=a.targetContainers,E!==null&&u.indexOf(E)===-1&&u.push(E),a)}function H2(a,u,p,y,E){switch(u){case"focusin":return $e=wa($e,a,u,p,y,E),!0;case"dragenter":return Xe=wa(Xe,a,u,p,y,E),!0;case"mouseover":return kt=wa(kt,a,u,p,y,E),!0;case"pointerover":var C=E.pointerId;return Lt.set(C,wa(Lt.get(C)||null,a,u,p,y,E)),!0;case"gotpointercapture":return C=E.pointerId,hn.set(C,wa(hn.get(C)||null,a,u,p,y,E)),!0}return!1}function My(a){var u=Ui(a.target);if(u!==null){var p=Vt(u);if(p!==null){if(u=p.tag,u===13){if(u=Un(p),u!==null){a.blockedOn=u,ms(a.priority,function(){Yt(p)});return}}else if(u===3&&p.stateNode.current.memoizedState.isDehydrated){a.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Yl(a){if(a.blockedOn!==null)return!1;for(var u=a.targetContainers;0<u.length;){var p=vf(a.domEventName,a.eventSystemFlags,u[0],a.nativeEvent);if(p===null){p=a.nativeEvent;var y=new p.constructor(p.type,p);Ce=y,p.target.dispatchEvent(y),Ce=null}else return u=La(p),u!==null&&wn(u),a.blockedOn=p,!1;u.shift()}return!0}function Ay(a,u,p){Yl(a)&&p.delete(u)}function W2(){zi=!1,$e!==null&&Yl($e)&&($e=null),Xe!==null&&Yl(Xe)&&(Xe=null),kt!==null&&Yl(kt)&&(kt=null),Lt.forEach(Ay),hn.forEach(Ay)}function ka(a,u){a.blockedOn===u&&(a.blockedOn=null,zi||(zi=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,W2)))}function Sa(a){function u(E){return ka(E,a)}if(0<Xs.length){ka(Xs[0],a);for(var p=1;p<Xs.length;p++){var y=Xs[p];y.blockedOn===a&&(y.blockedOn=null)}}for($e!==null&&ka($e,a),Xe!==null&&ka(Xe,a),kt!==null&&ka(kt,a),Lt.forEach(u),hn.forEach(u),p=0;p<On.length;p++)y=On[p],y.blockedOn===a&&(y.blockedOn=null);for(;0<On.length&&(p=On[0],p.blockedOn===null);)My(p),p.blockedOn===null&&On.shift()}var Co=M.ReactCurrentBatchConfig,Xl=!0;function V2(a,u,p,y){var E=$t,C=Co.transition;Co.transition=null;try{$t=1,gf(a,u,p,y)}finally{$t=E,Co.transition=C}}function q2(a,u,p,y){var E=$t,C=Co.transition;Co.transition=null;try{$t=4,gf(a,u,p,y)}finally{$t=E,Co.transition=C}}function gf(a,u,p,y){if(Xl){var E=vf(a,u,p,y);if(E===null)If(a,u,y,Ql,p),Jl(a,y);else if(H2(E,a,u,p,y))y.stopPropagation();else if(Jl(a,y),u&4&&-1<mf.indexOf(a)){for(;E!==null;){var C=La(E);if(C!==null&&xa(C),C=vf(a,u,p,y),C===null&&If(a,u,y,Ql,p),C===E)break;E=C}E!==null&&y.stopPropagation()}else If(a,u,y,null,p)}}var Ql=null;function vf(a,u,p,y){if(Ql=null,a=Se(y),a=Ui(a),a!==null)if(u=Vt(a),u===null)a=null;else if(p=u.tag,p===13){if(a=Un(u),a!==null)return a;a=null}else if(p===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;a=null}else u!==a&&(a=null);return Ql=a,null}function Ry(a){switch(a){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Lr()){case Ys:return 1;case Qr:return 4;case hs:case Ae:return 16;case nt:return 536870912;default:return 16}default:return 16}}var Qs=null,yf=null,Zl=null;function Oy(){if(Zl)return Zl;var a,u=yf,p=u.length,y,E="value"in Qs?Qs.value:Qs.textContent,C=E.length;for(a=0;a<p&&u[a]===E[a];a++);var O=p-a;for(y=1;y<=O&&u[p-y]===E[C-y];y++);return Zl=E.slice(a,1<y?1-y:void 0)}function ec(a){var u=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&u===13&&(a=13)):a=u,a===10&&(a=13),32<=a||a===13?a:0}function tc(){return!0}function Iy(){return!1}function Cr(a){function u(p,y,E,C,O){this._reactName=p,this._targetInst=E,this.type=y,this.nativeEvent=C,this.target=O,this.currentTarget=null;for(var H in a)a.hasOwnProperty(H)&&(p=a[H],this[H]=p?p(C):C[H]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?tc:Iy,this.isPropagationStopped=Iy,this}return J(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=tc)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=tc)},persist:function(){},isPersistent:tc}),u}var _o={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},bf=Cr(_o),Ea=J({},_o,{view:0,detail:0}),K2=Cr(Ea),xf,wf,Na,nc=J({},Ea,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Sf,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==Na&&(Na&&a.type==="mousemove"?(xf=a.screenX-Na.screenX,wf=a.screenY-Na.screenY):wf=xf=0,Na=a),xf)},movementY:function(a){return"movementY"in a?a.movementY:wf}}),Ly=Cr(nc),G2=J({},nc,{dataTransfer:0}),J2=Cr(G2),Y2=J({},Ea,{relatedTarget:0}),kf=Cr(Y2),X2=J({},_o,{animationName:0,elapsedTime:0,pseudoElement:0}),Q2=Cr(X2),Z2=J({},_o,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),ej=Cr(Z2),tj=J({},_o,{data:0}),Dy=Cr(tj),nj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},rj={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"},sj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ij(a){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(a):(a=sj[a])?!!u[a]:!1}function Sf(){return ij}var oj=J({},Ea,{key:function(a){if(a.key){var u=nj[a.key]||a.key;if(u!=="Unidentified")return u}return a.type==="keypress"?(a=ec(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?rj[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Sf,charCode:function(a){return a.type==="keypress"?ec(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?ec(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),aj=Cr(oj),lj=J({},nc,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Py=Cr(lj),cj=J({},Ea,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Sf}),uj=Cr(cj),dj=J({},_o,{propertyName:0,elapsedTime:0,pseudoElement:0}),fj=Cr(dj),hj=J({},nc,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),pj=Cr(hj),mj=[9,13,27,32],Ef=l&&"CompositionEvent"in window,Ca=null;l&&"documentMode"in document&&(Ca=document.documentMode);var gj=l&&"TextEvent"in window&&!Ca,By=l&&(!Ef||Ca&&8<Ca&&11>=Ca),$y=" ",Fy=!1;function zy(a,u){switch(a){case"keyup":return mj.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uy(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var To=!1;function vj(a,u){switch(a){case"compositionend":return Uy(u);case"keypress":return u.which!==32?null:(Fy=!0,$y);case"textInput":return a=u.data,a===$y&&Fy?null:a;default:return null}}function yj(a,u){if(To)return a==="compositionend"||!Ef&&zy(a,u)?(a=Oy(),Zl=yf=Qs=null,To=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return By&&u.locale!=="ko"?null:u.data;default:return null}}var bj={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 Hy(a){var u=a&&a.nodeName&&a.nodeName.toLowerCase();return u==="input"?!!bj[a.type]:u==="textarea"}function Wy(a,u,p,y){j(y),u=ac(u,"onChange"),0<u.length&&(p=new bf("onChange","change",null,p,y),a.push({event:p,listeners:u}))}var _a=null,Ta=null;function xj(a){lb(a,0)}function rc(a){var u=Oo(a);if(Re(u))return a}function wj(a,u){if(a==="change")return u}var Vy=!1;if(l){var Nf;if(l){var Cf="oninput"in document;if(!Cf){var qy=document.createElement("div");qy.setAttribute("oninput","return;"),Cf=typeof qy.oninput=="function"}Nf=Cf}else Nf=!1;Vy=Nf&&(!document.documentMode||9<document.documentMode)}function Ky(){_a&&(_a.detachEvent("onpropertychange",Gy),Ta=_a=null)}function Gy(a){if(a.propertyName==="value"&&rc(Ta)){var u=[];Wy(u,Ta,a,Se(a)),me(xj,u)}}function kj(a,u,p){a==="focusin"?(Ky(),_a=u,Ta=p,_a.attachEvent("onpropertychange",Gy)):a==="focusout"&&Ky()}function Sj(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return rc(Ta)}function Ej(a,u){if(a==="click")return rc(u)}function Nj(a,u){if(a==="input"||a==="change")return rc(u)}function Cj(a,u){return a===u&&(a!==0||1/a===1/u)||a!==a&&u!==u}var Zr=typeof Object.is=="function"?Object.is:Cj;function ja(a,u){if(Zr(a,u))return!0;if(typeof a!="object"||a===null||typeof u!="object"||u===null)return!1;var p=Object.keys(a),y=Object.keys(u);if(p.length!==y.length)return!1;for(y=0;y<p.length;y++){var E=p[y];if(!d.call(u,E)||!Zr(a[E],u[E]))return!1}return!0}function Jy(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Yy(a,u){var p=Jy(a);a=0;for(var y;p;){if(p.nodeType===3){if(y=a+p.textContent.length,a<=u&&y>=u)return{node:p,offset:u-a};a=y}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=Jy(p)}}function Xy(a,u){return a&&u?a===u?!0:a&&a.nodeType===3?!1:u&&u.nodeType===3?Xy(a,u.parentNode):"contains"in a?a.contains(u):a.compareDocumentPosition?!!(a.compareDocumentPosition(u)&16):!1:!1}function Qy(){for(var a=window,u=Ze();u instanceof a.HTMLIFrameElement;){try{var p=typeof u.contentWindow.location.href=="string"}catch{p=!1}if(p)a=u.contentWindow;else break;u=Ze(a.document)}return u}function _f(a){var u=a&&a.nodeName&&a.nodeName.toLowerCase();return u&&(u==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||u==="textarea"||a.contentEditable==="true")}function _j(a){var u=Qy(),p=a.focusedElem,y=a.selectionRange;if(u!==p&&p&&p.ownerDocument&&Xy(p.ownerDocument.documentElement,p)){if(y!==null&&_f(p)){if(u=y.start,a=y.end,a===void 0&&(a=u),"selectionStart"in p)p.selectionStart=u,p.selectionEnd=Math.min(a,p.value.length);else if(a=(u=p.ownerDocument||document)&&u.defaultView||window,a.getSelection){a=a.getSelection();var E=p.textContent.length,C=Math.min(y.start,E);y=y.end===void 0?C:Math.min(y.end,E),!a.extend&&C>y&&(E=y,y=C,C=E),E=Yy(p,C);var O=Yy(p,y);E&&O&&(a.rangeCount!==1||a.anchorNode!==E.node||a.anchorOffset!==E.offset||a.focusNode!==O.node||a.focusOffset!==O.offset)&&(u=u.createRange(),u.setStart(E.node,E.offset),a.removeAllRanges(),C>y?(a.addRange(u),a.extend(O.node,O.offset)):(u.setEnd(O.node,O.offset),a.addRange(u)))}}for(u=[],a=p;a=a.parentNode;)a.nodeType===1&&u.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<u.length;p++)a=u[p],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var Tj=l&&"documentMode"in document&&11>=document.documentMode,jo=null,Tf=null,Ma=null,jf=!1;function Zy(a,u,p){var y=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;jf||jo==null||jo!==Ze(y)||(y=jo,"selectionStart"in y&&_f(y)?y={start:y.selectionStart,end:y.selectionEnd}:(y=(y.ownerDocument&&y.ownerDocument.defaultView||window).getSelection(),y={anchorNode:y.anchorNode,anchorOffset:y.anchorOffset,focusNode:y.focusNode,focusOffset:y.focusOffset}),Ma&&ja(Ma,y)||(Ma=y,y=ac(Tf,"onSelect"),0<y.length&&(u=new bf("onSelect","select",null,u,p),a.push({event:u,listeners:y}),u.target=jo)))}function sc(a,u){var p={};return p[a.toLowerCase()]=u.toLowerCase(),p["Webkit"+a]="webkit"+u,p["Moz"+a]="moz"+u,p}var Mo={animationend:sc("Animation","AnimationEnd"),animationiteration:sc("Animation","AnimationIteration"),animationstart:sc("Animation","AnimationStart"),transitionend:sc("Transition","TransitionEnd")},Mf={},eb={};l&&(eb=document.createElement("div").style,"AnimationEvent"in window||(delete Mo.animationend.animation,delete Mo.animationiteration.animation,delete Mo.animationstart.animation),"TransitionEvent"in window||delete Mo.transitionend.transition);function ic(a){if(Mf[a])return Mf[a];if(!Mo[a])return a;var u=Mo[a],p;for(p in u)if(u.hasOwnProperty(p)&&p in eb)return Mf[a]=u[p];return a}var tb=ic("animationend"),nb=ic("animationiteration"),rb=ic("animationstart"),sb=ic("transitionend"),ib=new Map,ob="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 Zs(a,u){ib.set(a,u),i(u,[a])}for(var Af=0;Af<ob.length;Af++){var Rf=ob[Af],jj=Rf.toLowerCase(),Mj=Rf[0].toUpperCase()+Rf.slice(1);Zs(jj,"on"+Mj)}Zs(tb,"onAnimationEnd"),Zs(nb,"onAnimationIteration"),Zs(rb,"onAnimationStart"),Zs("dblclick","onDoubleClick"),Zs("focusin","onFocus"),Zs("focusout","onBlur"),Zs(sb,"onTransitionEnd"),o("onMouseEnter",["mouseout","mouseover"]),o("onMouseLeave",["mouseout","mouseover"]),o("onPointerEnter",["pointerout","pointerover"]),o("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Aa="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(" "),Aj=new Set("cancel close invalid load scroll toggle".split(" ").concat(Aa));function ab(a,u,p){var y=a.type||"unknown-event";a.currentTarget=p,Ve(y,u,void 0,a),a.currentTarget=null}function lb(a,u){u=(u&4)!==0;for(var p=0;p<a.length;p++){var y=a[p],E=y.event;y=y.listeners;e:{var C=void 0;if(u)for(var O=y.length-1;0<=O;O--){var H=y[O],X=H.instance,ue=H.currentTarget;if(H=H.listener,X!==C&&E.isPropagationStopped())break e;ab(E,H,ue),C=X}else for(O=0;O<y.length;O++){if(H=y[O],X=H.instance,ue=H.currentTarget,H=H.listener,X!==C&&E.isPropagationStopped())break e;ab(E,H,ue),C=X}}}if(Tt)throw a=cn,Tt=!1,cn=null,a}function rn(a,u){var p=u[Ff];p===void 0&&(p=u[Ff]=new Set);var y=a+"__bubble";p.has(y)||(cb(u,a,2,!1),p.add(y))}function Of(a,u,p){var y=0;u&&(y|=4),cb(p,a,y,u)}var oc="_reactListening"+Math.random().toString(36).slice(2);function Ra(a){if(!a[oc]){a[oc]=!0,r.forEach(function(p){p!=="selectionchange"&&(Aj.has(p)||Of(p,!1,a),Of(p,!0,a))});var u=a.nodeType===9?a:a.ownerDocument;u===null||u[oc]||(u[oc]=!0,Of("selectionchange",!1,u))}}function cb(a,u,p,y){switch(Ry(u)){case 1:var E=V2;break;case 4:E=q2;break;default:E=gf}p=E.bind(null,u,p,a),E=void 0,!he||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(E=!0),y?E!==void 0?a.addEventListener(u,p,{capture:!0,passive:E}):a.addEventListener(u,p,!0):E!==void 0?a.addEventListener(u,p,{passive:E}):a.addEventListener(u,p,!1)}function If(a,u,p,y,E){var C=y;if((u&1)===0&&(u&2)===0&&y!==null)e:for(;;){if(y===null)return;var O=y.tag;if(O===3||O===4){var H=y.stateNode.containerInfo;if(H===E||H.nodeType===8&&H.parentNode===E)break;if(O===4)for(O=y.return;O!==null;){var X=O.tag;if((X===3||X===4)&&(X=O.stateNode.containerInfo,X===E||X.nodeType===8&&X.parentNode===E))return;O=O.return}for(;H!==null;){if(O=Ui(H),O===null)return;if(X=O.tag,X===5||X===6){y=C=O;continue e}H=H.parentNode}}y=y.return}me(function(){var ue=C,Te=Se(p),Me=[];e:{var _e=ib.get(a);if(_e!==void 0){var Ke=bf,et=a;switch(a){case"keypress":if(ec(p)===0)break e;case"keydown":case"keyup":Ke=aj;break;case"focusin":et="focus",Ke=kf;break;case"focusout":et="blur",Ke=kf;break;case"beforeblur":case"afterblur":Ke=kf;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ke=Ly;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ke=J2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ke=uj;break;case tb:case nb:case rb:Ke=Q2;break;case sb:Ke=fj;break;case"scroll":Ke=K2;break;case"wheel":Ke=pj;break;case"copy":case"cut":case"paste":Ke=ej;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ke=Py}var rt=(u&4)!==0,kn=!rt&&a==="scroll",ae=rt?_e!==null?_e+"Capture":null:_e;rt=[];for(var Z=ue,le;Z!==null;){le=Z;var Pe=le.stateNode;if(le.tag===5&&Pe!==null&&(le=Pe,ae!==null&&(Pe=se(Z,ae),Pe!=null&&rt.push(Oa(Z,Pe,le)))),kn)break;Z=Z.return}0<rt.length&&(_e=new Ke(_e,et,null,p,Te),Me.push({event:_e,listeners:rt}))}}if((u&7)===0){e:{if(_e=a==="mouseover"||a==="pointerover",Ke=a==="mouseout"||a==="pointerout",_e&&p!==Ce&&(et=p.relatedTarget||p.fromElement)&&(Ui(et)||et[js]))break e;if((Ke||_e)&&(_e=Te.window===Te?Te:(_e=Te.ownerDocument)?_e.defaultView||_e.parentWindow:window,Ke?(et=p.relatedTarget||p.toElement,Ke=ue,et=et?Ui(et):null,et!==null&&(kn=Vt(et),et!==kn||et.tag!==5&&et.tag!==6)&&(et=null)):(Ke=null,et=ue),Ke!==et)){if(rt=Ly,Pe="onMouseLeave",ae="onMouseEnter",Z="mouse",(a==="pointerout"||a==="pointerover")&&(rt=Py,Pe="onPointerLeave",ae="onPointerEnter",Z="pointer"),kn=Ke==null?_e:Oo(Ke),le=et==null?_e:Oo(et),_e=new rt(Pe,Z+"leave",Ke,p,Te),_e.target=kn,_e.relatedTarget=le,Pe=null,Ui(Te)===ue&&(rt=new rt(ae,Z+"enter",et,p,Te),rt.target=le,rt.relatedTarget=kn,Pe=rt),kn=Pe,Ke&&et)t:{for(rt=Ke,ae=et,Z=0,le=rt;le;le=Ao(le))Z++;for(le=0,Pe=ae;Pe;Pe=Ao(Pe))le++;for(;0<Z-le;)rt=Ao(rt),Z--;for(;0<le-Z;)ae=Ao(ae),le--;for(;Z--;){if(rt===ae||ae!==null&&rt===ae.alternate)break t;rt=Ao(rt),ae=Ao(ae)}rt=null}else rt=null;Ke!==null&&ub(Me,_e,Ke,rt,!1),et!==null&&kn!==null&&ub(Me,kn,et,rt,!0)}}e:{if(_e=ue?Oo(ue):window,Ke=_e.nodeName&&_e.nodeName.toLowerCase(),Ke==="select"||Ke==="input"&&_e.type==="file")var st=wj;else if(Hy(_e))if(Vy)st=Nj;else{st=Sj;var pt=kj}else(Ke=_e.nodeName)&&Ke.toLowerCase()==="input"&&(_e.type==="checkbox"||_e.type==="radio")&&(st=Ej);if(st&&(st=st(a,ue))){Wy(Me,st,p,Te);break e}pt&&pt(a,_e,ue),a==="focusout"&&(pt=_e._wrapperState)&&pt.controlled&&_e.type==="number"&&Et(_e,"number",_e.value)}switch(pt=ue?Oo(ue):window,a){case"focusin":(Hy(pt)||pt.contentEditable==="true")&&(jo=pt,Tf=ue,Ma=null);break;case"focusout":Ma=Tf=jo=null;break;case"mousedown":jf=!0;break;case"contextmenu":case"mouseup":case"dragend":jf=!1,Zy(Me,p,Te);break;case"selectionchange":if(Tj)break;case"keydown":case"keyup":Zy(Me,p,Te)}var mt;if(Ef)e:{switch(a){case"compositionstart":var St="onCompositionStart";break e;case"compositionend":St="onCompositionEnd";break e;case"compositionupdate":St="onCompositionUpdate";break e}St=void 0}else To?zy(a,p)&&(St="onCompositionEnd"):a==="keydown"&&p.keyCode===229&&(St="onCompositionStart");St&&(By&&p.locale!=="ko"&&(To||St!=="onCompositionStart"?St==="onCompositionEnd"&&To&&(mt=Oy()):(Qs=Te,yf="value"in Qs?Qs.value:Qs.textContent,To=!0)),pt=ac(ue,St),0<pt.length&&(St=new Dy(St,a,null,p,Te),Me.push({event:St,listeners:pt}),mt?St.data=mt:(mt=Uy(p),mt!==null&&(St.data=mt)))),(mt=gj?vj(a,p):yj(a,p))&&(ue=ac(ue,"onBeforeInput"),0<ue.length&&(Te=new Dy("onBeforeInput","beforeinput",null,p,Te),Me.push({event:Te,listeners:ue}),Te.data=mt))}lb(Me,u)})}function Oa(a,u,p){return{instance:a,listener:u,currentTarget:p}}function ac(a,u){for(var p=u+"Capture",y=[];a!==null;){var E=a,C=E.stateNode;E.tag===5&&C!==null&&(E=C,C=se(a,p),C!=null&&y.unshift(Oa(a,C,E)),C=se(a,u),C!=null&&y.push(Oa(a,C,E))),a=a.return}return y}function Ao(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function ub(a,u,p,y,E){for(var C=u._reactName,O=[];p!==null&&p!==y;){var H=p,X=H.alternate,ue=H.stateNode;if(X!==null&&X===y)break;H.tag===5&&ue!==null&&(H=ue,E?(X=se(p,C),X!=null&&O.unshift(Oa(p,X,H))):E||(X=se(p,C),X!=null&&O.push(Oa(p,X,H)))),p=p.return}O.length!==0&&a.push({event:u,listeners:O})}var Rj=/\r\n?/g,Oj=/\u0000|\uFFFD/g;function db(a){return(typeof a=="string"?a:""+a).replace(Rj,`
38
- `).replace(Oj,"")}function lc(a,u,p){if(u=db(u),db(a)!==u&&p)throw Error(n(425))}function cc(){}var Lf=null,Df=null;function Pf(a,u){return a==="textarea"||a==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var Bf=typeof setTimeout=="function"?setTimeout:void 0,Ij=typeof clearTimeout=="function"?clearTimeout:void 0,fb=typeof Promise=="function"?Promise:void 0,Lj=typeof queueMicrotask=="function"?queueMicrotask:typeof fb<"u"?function(a){return fb.resolve(null).then(a).catch(Dj)}:Bf;function Dj(a){setTimeout(function(){throw a})}function $f(a,u){var p=u,y=0;do{var E=p.nextSibling;if(a.removeChild(p),E&&E.nodeType===8)if(p=E.data,p==="/$"){if(y===0){a.removeChild(E),Sa(u);return}y--}else p!=="$"&&p!=="$?"&&p!=="$!"||y++;p=E}while(p);Sa(u)}function ei(a){for(;a!=null;a=a.nextSibling){var u=a.nodeType;if(u===1||u===3)break;if(u===8){if(u=a.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return a}function hb(a){a=a.previousSibling;for(var u=0;a;){if(a.nodeType===8){var p=a.data;if(p==="$"||p==="$!"||p==="$?"){if(u===0)return a;u--}else p==="/$"&&u++}a=a.previousSibling}return null}var Ro=Math.random().toString(36).slice(2),gs="__reactFiber$"+Ro,Ia="__reactProps$"+Ro,js="__reactContainer$"+Ro,Ff="__reactEvents$"+Ro,Pj="__reactListeners$"+Ro,Bj="__reactHandles$"+Ro;function Ui(a){var u=a[gs];if(u)return u;for(var p=a.parentNode;p;){if(u=p[js]||p[gs]){if(p=u.alternate,u.child!==null||p!==null&&p.child!==null)for(a=hb(a);a!==null;){if(p=a[gs])return p;a=hb(a)}return u}a=p,p=a.parentNode}return null}function La(a){return a=a[gs]||a[js],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function Oo(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function uc(a){return a[Ia]||null}var zf=[],Io=-1;function ti(a){return{current:a}}function sn(a){0>Io||(a.current=zf[Io],zf[Io]=null,Io--)}function en(a,u){Io++,zf[Io]=a.current,a.current=u}var ni={},er=ti(ni),gr=ti(!1),Hi=ni;function Lo(a,u){var p=a.type.contextTypes;if(!p)return ni;var y=a.stateNode;if(y&&y.__reactInternalMemoizedUnmaskedChildContext===u)return y.__reactInternalMemoizedMaskedChildContext;var E={},C;for(C in p)E[C]=u[C];return y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=u,a.__reactInternalMemoizedMaskedChildContext=E),E}function vr(a){return a=a.childContextTypes,a!=null}function dc(){sn(gr),sn(er)}function pb(a,u,p){if(er.current!==ni)throw Error(n(168));en(er,u),en(gr,p)}function mb(a,u,p){var y=a.stateNode;if(u=u.childContextTypes,typeof y.getChildContext!="function")return p;y=y.getChildContext();for(var E in y)if(!(E in u))throw Error(n(108,Ne(a)||"Unknown",E));return J({},p,y)}function fc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||ni,Hi=er.current,en(er,a),en(gr,gr.current),!0}function gb(a,u,p){var y=a.stateNode;if(!y)throw Error(n(169));p?(a=mb(a,u,Hi),y.__reactInternalMemoizedMergedChildContext=a,sn(gr),sn(er),en(er,a)):sn(gr),en(gr,p)}var Ms=null,hc=!1,Uf=!1;function vb(a){Ms===null?Ms=[a]:Ms.push(a)}function $j(a){hc=!0,vb(a)}function ri(){if(!Uf&&Ms!==null){Uf=!0;var a=0,u=$t;try{var p=Ms;for($t=1;a<p.length;a++){var y=p[a];do y=y(!0);while(y!==null)}Ms=null,hc=!1}catch(E){throw Ms!==null&&(Ms=Ms.slice(a+1)),lr(Ys,ri),E}finally{$t=u,Uf=!1}}return null}var Do=[],Po=0,pc=null,mc=0,Pr=[],Br=0,Wi=null,As=1,Rs="";function Vi(a,u){Do[Po++]=mc,Do[Po++]=pc,pc=a,mc=u}function yb(a,u,p){Pr[Br++]=As,Pr[Br++]=Rs,Pr[Br++]=Wi,Wi=a;var y=As;a=Rs;var E=32-nn(y)-1;y&=~(1<<E),p+=1;var C=32-nn(u)+E;if(30<C){var O=E-E%5;C=(y&(1<<O)-1).toString(32),y>>=O,E-=O,As=1<<32-nn(u)+E|p<<E|y,Rs=C+a}else As=1<<C|p<<E|y,Rs=a}function Hf(a){a.return!==null&&(Vi(a,1),yb(a,1,0))}function Wf(a){for(;a===pc;)pc=Do[--Po],Do[Po]=null,mc=Do[--Po],Do[Po]=null;for(;a===Wi;)Wi=Pr[--Br],Pr[Br]=null,Rs=Pr[--Br],Pr[Br]=null,As=Pr[--Br],Pr[Br]=null}var _r=null,Tr=null,ln=!1,es=null;function bb(a,u){var p=Ur(5,null,null,0);p.elementType="DELETED",p.stateNode=u,p.return=a,u=a.deletions,u===null?(a.deletions=[p],a.flags|=16):u.push(p)}function xb(a,u){switch(a.tag){case 5:var p=a.type;return u=u.nodeType!==1||p.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(a.stateNode=u,_r=a,Tr=ei(u.firstChild),!0):!1;case 6:return u=a.pendingProps===""||u.nodeType!==3?null:u,u!==null?(a.stateNode=u,_r=a,Tr=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(p=Wi!==null?{id:As,overflow:Rs}:null,a.memoizedState={dehydrated:u,treeContext:p,retryLane:1073741824},p=Ur(18,null,null,0),p.stateNode=u,p.return=a,a.child=p,_r=a,Tr=null,!0):!1;default:return!1}}function Vf(a){return(a.mode&1)!==0&&(a.flags&128)===0}function qf(a){if(ln){var u=Tr;if(u){var p=u;if(!xb(a,u)){if(Vf(a))throw Error(n(418));u=ei(p.nextSibling);var y=_r;u&&xb(a,u)?bb(y,p):(a.flags=a.flags&-4097|2,ln=!1,_r=a)}}else{if(Vf(a))throw Error(n(418));a.flags=a.flags&-4097|2,ln=!1,_r=a}}}function wb(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;_r=a}function gc(a){if(a!==_r)return!1;if(!ln)return wb(a),ln=!0,!1;var u;if((u=a.tag!==3)&&!(u=a.tag!==5)&&(u=a.type,u=u!=="head"&&u!=="body"&&!Pf(a.type,a.memoizedProps)),u&&(u=Tr)){if(Vf(a))throw kb(),Error(n(418));for(;u;)bb(a,u),u=ei(u.nextSibling)}if(wb(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,u=0;a;){if(a.nodeType===8){var p=a.data;if(p==="/$"){if(u===0){Tr=ei(a.nextSibling);break e}u--}else p!=="$"&&p!=="$!"&&p!=="$?"||u++}a=a.nextSibling}Tr=null}}else Tr=_r?ei(a.stateNode.nextSibling):null;return!0}function kb(){for(var a=Tr;a;)a=ei(a.nextSibling)}function Bo(){Tr=_r=null,ln=!1}function Kf(a){es===null?es=[a]:es.push(a)}var Fj=M.ReactCurrentBatchConfig;function Da(a,u,p){if(a=p.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(n(309));var y=p.stateNode}if(!y)throw Error(n(147,a));var E=y,C=""+a;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===C?u.ref:(u=function(O){var H=E.refs;O===null?delete H[C]:H[C]=O},u._stringRef=C,u)}if(typeof a!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,a))}return a}function vc(a,u){throw a=Object.prototype.toString.call(u),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":a))}function Sb(a){var u=a._init;return u(a._payload)}function Eb(a){function u(ae,Z){if(a){var le=ae.deletions;le===null?(ae.deletions=[Z],ae.flags|=16):le.push(Z)}}function p(ae,Z){if(!a)return null;for(;Z!==null;)u(ae,Z),Z=Z.sibling;return null}function y(ae,Z){for(ae=new Map;Z!==null;)Z.key!==null?ae.set(Z.key,Z):ae.set(Z.index,Z),Z=Z.sibling;return ae}function E(ae,Z){return ae=di(ae,Z),ae.index=0,ae.sibling=null,ae}function C(ae,Z,le){return ae.index=le,a?(le=ae.alternate,le!==null?(le=le.index,le<Z?(ae.flags|=2,Z):le):(ae.flags|=2,Z)):(ae.flags|=1048576,Z)}function O(ae){return a&&ae.alternate===null&&(ae.flags|=2),ae}function H(ae,Z,le,Pe){return Z===null||Z.tag!==6?(Z=Bh(le,ae.mode,Pe),Z.return=ae,Z):(Z=E(Z,le),Z.return=ae,Z)}function X(ae,Z,le,Pe){var st=le.type;return st===I?Te(ae,Z,le.props.children,Pe,le.key):Z!==null&&(Z.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===K&&Sb(st)===Z.type)?(Pe=E(Z,le.props),Pe.ref=Da(ae,Z,le),Pe.return=ae,Pe):(Pe=zc(le.type,le.key,le.props,null,ae.mode,Pe),Pe.ref=Da(ae,Z,le),Pe.return=ae,Pe)}function ue(ae,Z,le,Pe){return Z===null||Z.tag!==4||Z.stateNode.containerInfo!==le.containerInfo||Z.stateNode.implementation!==le.implementation?(Z=$h(le,ae.mode,Pe),Z.return=ae,Z):(Z=E(Z,le.children||[]),Z.return=ae,Z)}function Te(ae,Z,le,Pe,st){return Z===null||Z.tag!==7?(Z=Zi(le,ae.mode,Pe,st),Z.return=ae,Z):(Z=E(Z,le),Z.return=ae,Z)}function Me(ae,Z,le){if(typeof Z=="string"&&Z!==""||typeof Z=="number")return Z=Bh(""+Z,ae.mode,le),Z.return=ae,Z;if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case _:return le=zc(Z.type,Z.key,Z.props,null,ae.mode,le),le.ref=Da(ae,null,Z),le.return=ae,le;case R:return Z=$h(Z,ae.mode,le),Z.return=ae,Z;case K:var Pe=Z._init;return Me(ae,Pe(Z._payload),le)}if(Dt(Z)||oe(Z))return Z=Zi(Z,ae.mode,le,null),Z.return=ae,Z;vc(ae,Z)}return null}function _e(ae,Z,le,Pe){var st=Z!==null?Z.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return st!==null?null:H(ae,Z,""+le,Pe);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case _:return le.key===st?X(ae,Z,le,Pe):null;case R:return le.key===st?ue(ae,Z,le,Pe):null;case K:return st=le._init,_e(ae,Z,st(le._payload),Pe)}if(Dt(le)||oe(le))return st!==null?null:Te(ae,Z,le,Pe,null);vc(ae,le)}return null}function Ke(ae,Z,le,Pe,st){if(typeof Pe=="string"&&Pe!==""||typeof Pe=="number")return ae=ae.get(le)||null,H(Z,ae,""+Pe,st);if(typeof Pe=="object"&&Pe!==null){switch(Pe.$$typeof){case _:return ae=ae.get(Pe.key===null?le:Pe.key)||null,X(Z,ae,Pe,st);case R:return ae=ae.get(Pe.key===null?le:Pe.key)||null,ue(Z,ae,Pe,st);case K:var pt=Pe._init;return Ke(ae,Z,le,pt(Pe._payload),st)}if(Dt(Pe)||oe(Pe))return ae=ae.get(le)||null,Te(Z,ae,Pe,st,null);vc(Z,Pe)}return null}function et(ae,Z,le,Pe){for(var st=null,pt=null,mt=Z,St=Z=0,Dn=null;mt!==null&&St<le.length;St++){mt.index>St?(Dn=mt,mt=null):Dn=mt.sibling;var Wt=_e(ae,mt,le[St],Pe);if(Wt===null){mt===null&&(mt=Dn);break}a&&mt&&Wt.alternate===null&&u(ae,mt),Z=C(Wt,Z,St),pt===null?st=Wt:pt.sibling=Wt,pt=Wt,mt=Dn}if(St===le.length)return p(ae,mt),ln&&Vi(ae,St),st;if(mt===null){for(;St<le.length;St++)mt=Me(ae,le[St],Pe),mt!==null&&(Z=C(mt,Z,St),pt===null?st=mt:pt.sibling=mt,pt=mt);return ln&&Vi(ae,St),st}for(mt=y(ae,mt);St<le.length;St++)Dn=Ke(mt,ae,St,le[St],Pe),Dn!==null&&(a&&Dn.alternate!==null&&mt.delete(Dn.key===null?St:Dn.key),Z=C(Dn,Z,St),pt===null?st=Dn:pt.sibling=Dn,pt=Dn);return a&&mt.forEach(function(fi){return u(ae,fi)}),ln&&Vi(ae,St),st}function rt(ae,Z,le,Pe){var st=oe(le);if(typeof st!="function")throw Error(n(150));if(le=st.call(le),le==null)throw Error(n(151));for(var pt=st=null,mt=Z,St=Z=0,Dn=null,Wt=le.next();mt!==null&&!Wt.done;St++,Wt=le.next()){mt.index>St?(Dn=mt,mt=null):Dn=mt.sibling;var fi=_e(ae,mt,Wt.value,Pe);if(fi===null){mt===null&&(mt=Dn);break}a&&mt&&fi.alternate===null&&u(ae,mt),Z=C(fi,Z,St),pt===null?st=fi:pt.sibling=fi,pt=fi,mt=Dn}if(Wt.done)return p(ae,mt),ln&&Vi(ae,St),st;if(mt===null){for(;!Wt.done;St++,Wt=le.next())Wt=Me(ae,Wt.value,Pe),Wt!==null&&(Z=C(Wt,Z,St),pt===null?st=Wt:pt.sibling=Wt,pt=Wt);return ln&&Vi(ae,St),st}for(mt=y(ae,mt);!Wt.done;St++,Wt=le.next())Wt=Ke(mt,ae,St,Wt.value,Pe),Wt!==null&&(a&&Wt.alternate!==null&&mt.delete(Wt.key===null?St:Wt.key),Z=C(Wt,Z,St),pt===null?st=Wt:pt.sibling=Wt,pt=Wt);return a&&mt.forEach(function(bM){return u(ae,bM)}),ln&&Vi(ae,St),st}function kn(ae,Z,le,Pe){if(typeof le=="object"&&le!==null&&le.type===I&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case _:e:{for(var st=le.key,pt=Z;pt!==null;){if(pt.key===st){if(st=le.type,st===I){if(pt.tag===7){p(ae,pt.sibling),Z=E(pt,le.props.children),Z.return=ae,ae=Z;break e}}else if(pt.elementType===st||typeof st=="object"&&st!==null&&st.$$typeof===K&&Sb(st)===pt.type){p(ae,pt.sibling),Z=E(pt,le.props),Z.ref=Da(ae,pt,le),Z.return=ae,ae=Z;break e}p(ae,pt);break}else u(ae,pt);pt=pt.sibling}le.type===I?(Z=Zi(le.props.children,ae.mode,Pe,le.key),Z.return=ae,ae=Z):(Pe=zc(le.type,le.key,le.props,null,ae.mode,Pe),Pe.ref=Da(ae,Z,le),Pe.return=ae,ae=Pe)}return O(ae);case R:e:{for(pt=le.key;Z!==null;){if(Z.key===pt)if(Z.tag===4&&Z.stateNode.containerInfo===le.containerInfo&&Z.stateNode.implementation===le.implementation){p(ae,Z.sibling),Z=E(Z,le.children||[]),Z.return=ae,ae=Z;break e}else{p(ae,Z);break}else u(ae,Z);Z=Z.sibling}Z=$h(le,ae.mode,Pe),Z.return=ae,ae=Z}return O(ae);case K:return pt=le._init,kn(ae,Z,pt(le._payload),Pe)}if(Dt(le))return et(ae,Z,le,Pe);if(oe(le))return rt(ae,Z,le,Pe);vc(ae,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,Z!==null&&Z.tag===6?(p(ae,Z.sibling),Z=E(Z,le),Z.return=ae,ae=Z):(p(ae,Z),Z=Bh(le,ae.mode,Pe),Z.return=ae,ae=Z),O(ae)):p(ae,Z)}return kn}var $o=Eb(!0),Nb=Eb(!1),yc=ti(null),bc=null,Fo=null,Gf=null;function Jf(){Gf=Fo=bc=null}function Yf(a){var u=yc.current;sn(yc),a._currentValue=u}function Xf(a,u,p){for(;a!==null;){var y=a.alternate;if((a.childLanes&u)!==u?(a.childLanes|=u,y!==null&&(y.childLanes|=u)):y!==null&&(y.childLanes&u)!==u&&(y.childLanes|=u),a===p)break;a=a.return}}function zo(a,u){bc=a,Gf=Fo=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&u)!==0&&(yr=!0),a.firstContext=null)}function $r(a){var u=a._currentValue;if(Gf!==a)if(a={context:a,memoizedValue:u,next:null},Fo===null){if(bc===null)throw Error(n(308));Fo=a,bc.dependencies={lanes:0,firstContext:a}}else Fo=Fo.next=a;return u}var qi=null;function Qf(a){qi===null?qi=[a]:qi.push(a)}function Cb(a,u,p,y){var E=u.interleaved;return E===null?(p.next=p,Qf(u)):(p.next=E.next,E.next=p),u.interleaved=p,Os(a,y)}function Os(a,u){a.lanes|=u;var p=a.alternate;for(p!==null&&(p.lanes|=u),p=a,a=a.return;a!==null;)a.childLanes|=u,p=a.alternate,p!==null&&(p.childLanes|=u),p=a,a=a.return;return p.tag===3?p.stateNode:null}var si=!1;function Zf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function _b(a,u){a=a.updateQueue,u.updateQueue===a&&(u.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Is(a,u){return{eventTime:a,lane:u,tag:0,payload:null,callback:null,next:null}}function ii(a,u,p){var y=a.updateQueue;if(y===null)return null;if(y=y.shared,(Ft&2)!==0){var E=y.pending;return E===null?u.next=u:(u.next=E.next,E.next=u),y.pending=u,Os(a,p)}return E=y.interleaved,E===null?(u.next=u,Qf(y)):(u.next=E.next,E.next=u),y.interleaved=u,Os(a,p)}function xc(a,u,p){if(u=u.updateQueue,u!==null&&(u=u.shared,(p&4194240)!==0)){var y=u.lanes;y&=a.pendingLanes,p|=y,u.lanes=p,ba(a,p)}}function Tb(a,u){var p=a.updateQueue,y=a.alternate;if(y!==null&&(y=y.updateQueue,p===y)){var E=null,C=null;if(p=p.firstBaseUpdate,p!==null){do{var O={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};C===null?E=C=O:C=C.next=O,p=p.next}while(p!==null);C===null?E=C=u:C=C.next=u}else E=C=u;p={baseState:y.baseState,firstBaseUpdate:E,lastBaseUpdate:C,shared:y.shared,effects:y.effects},a.updateQueue=p;return}a=p.lastBaseUpdate,a===null?p.firstBaseUpdate=u:a.next=u,p.lastBaseUpdate=u}function wc(a,u,p,y){var E=a.updateQueue;si=!1;var C=E.firstBaseUpdate,O=E.lastBaseUpdate,H=E.shared.pending;if(H!==null){E.shared.pending=null;var X=H,ue=X.next;X.next=null,O===null?C=ue:O.next=ue,O=X;var Te=a.alternate;Te!==null&&(Te=Te.updateQueue,H=Te.lastBaseUpdate,H!==O&&(H===null?Te.firstBaseUpdate=ue:H.next=ue,Te.lastBaseUpdate=X))}if(C!==null){var Me=E.baseState;O=0,Te=ue=X=null,H=C;do{var _e=H.lane,Ke=H.eventTime;if((y&_e)===_e){Te!==null&&(Te=Te.next={eventTime:Ke,lane:0,tag:H.tag,payload:H.payload,callback:H.callback,next:null});e:{var et=a,rt=H;switch(_e=u,Ke=p,rt.tag){case 1:if(et=rt.payload,typeof et=="function"){Me=et.call(Ke,Me,_e);break e}Me=et;break e;case 3:et.flags=et.flags&-65537|128;case 0:if(et=rt.payload,_e=typeof et=="function"?et.call(Ke,Me,_e):et,_e==null)break e;Me=J({},Me,_e);break e;case 2:si=!0}}H.callback!==null&&H.lane!==0&&(a.flags|=64,_e=E.effects,_e===null?E.effects=[H]:_e.push(H))}else Ke={eventTime:Ke,lane:_e,tag:H.tag,payload:H.payload,callback:H.callback,next:null},Te===null?(ue=Te=Ke,X=Me):Te=Te.next=Ke,O|=_e;if(H=H.next,H===null){if(H=E.shared.pending,H===null)break;_e=H,H=_e.next,_e.next=null,E.lastBaseUpdate=_e,E.shared.pending=null}}while(!0);if(Te===null&&(X=Me),E.baseState=X,E.firstBaseUpdate=ue,E.lastBaseUpdate=Te,u=E.shared.interleaved,u!==null){E=u;do O|=E.lane,E=E.next;while(E!==u)}else C===null&&(E.shared.lanes=0);Ji|=O,a.lanes=O,a.memoizedState=Me}}function jb(a,u,p){if(a=u.effects,u.effects=null,a!==null)for(u=0;u<a.length;u++){var y=a[u],E=y.callback;if(E!==null){if(y.callback=null,y=p,typeof E!="function")throw Error(n(191,E));E.call(y)}}}var Pa={},vs=ti(Pa),Ba=ti(Pa),$a=ti(Pa);function Ki(a){if(a===Pa)throw Error(n(174));return a}function eh(a,u){switch(en($a,u),en(Ba,a),en(vs,Pa),a=u.nodeType,a){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:de(null,"");break;default:a=a===8?u.parentNode:u,u=a.namespaceURI||null,a=a.tagName,u=de(u,a)}sn(vs),en(vs,u)}function Uo(){sn(vs),sn(Ba),sn($a)}function Mb(a){Ki($a.current);var u=Ki(vs.current),p=de(u,a.type);u!==p&&(en(Ba,a),en(vs,p))}function th(a){Ba.current===a&&(sn(vs),sn(Ba))}var un=ti(0);function kc(a){for(var u=a;u!==null;){if(u.tag===13){var p=u.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===a)break;for(;u.sibling===null;){if(u.return===null||u.return===a)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var nh=[];function rh(){for(var a=0;a<nh.length;a++)nh[a]._workInProgressVersionPrimary=null;nh.length=0}var Sc=M.ReactCurrentDispatcher,sh=M.ReactCurrentBatchConfig,Gi=0,dn=null,jn=null,In=null,Ec=!1,Fa=!1,za=0,zj=0;function tr(){throw Error(n(321))}function ih(a,u){if(u===null)return!1;for(var p=0;p<u.length&&p<a.length;p++)if(!Zr(a[p],u[p]))return!1;return!0}function oh(a,u,p,y,E,C){if(Gi=C,dn=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Sc.current=a===null||a.memoizedState===null?Vj:qj,a=p(y,E),Fa){C=0;do{if(Fa=!1,za=0,25<=C)throw Error(n(301));C+=1,In=jn=null,u.updateQueue=null,Sc.current=Kj,a=p(y,E)}while(Fa)}if(Sc.current=_c,u=jn!==null&&jn.next!==null,Gi=0,In=jn=dn=null,Ec=!1,u)throw Error(n(300));return a}function ah(){var a=za!==0;return za=0,a}function ys(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return In===null?dn.memoizedState=In=a:In=In.next=a,In}function Fr(){if(jn===null){var a=dn.alternate;a=a!==null?a.memoizedState:null}else a=jn.next;var u=In===null?dn.memoizedState:In.next;if(u!==null)In=u,jn=a;else{if(a===null)throw Error(n(310));jn=a,a={memoizedState:jn.memoizedState,baseState:jn.baseState,baseQueue:jn.baseQueue,queue:jn.queue,next:null},In===null?dn.memoizedState=In=a:In=In.next=a}return In}function Ua(a,u){return typeof u=="function"?u(a):u}function lh(a){var u=Fr(),p=u.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var y=jn,E=y.baseQueue,C=p.pending;if(C!==null){if(E!==null){var O=E.next;E.next=C.next,C.next=O}y.baseQueue=E=C,p.pending=null}if(E!==null){C=E.next,y=y.baseState;var H=O=null,X=null,ue=C;do{var Te=ue.lane;if((Gi&Te)===Te)X!==null&&(X=X.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),y=ue.hasEagerState?ue.eagerState:a(y,ue.action);else{var Me={lane:Te,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};X===null?(H=X=Me,O=y):X=X.next=Me,dn.lanes|=Te,Ji|=Te}ue=ue.next}while(ue!==null&&ue!==C);X===null?O=y:X.next=H,Zr(y,u.memoizedState)||(yr=!0),u.memoizedState=y,u.baseState=O,u.baseQueue=X,p.lastRenderedState=y}if(a=p.interleaved,a!==null){E=a;do C=E.lane,dn.lanes|=C,Ji|=C,E=E.next;while(E!==a)}else E===null&&(p.lanes=0);return[u.memoizedState,p.dispatch]}function ch(a){var u=Fr(),p=u.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var y=p.dispatch,E=p.pending,C=u.memoizedState;if(E!==null){p.pending=null;var O=E=E.next;do C=a(C,O.action),O=O.next;while(O!==E);Zr(C,u.memoizedState)||(yr=!0),u.memoizedState=C,u.baseQueue===null&&(u.baseState=C),p.lastRenderedState=C}return[C,y]}function Ab(){}function Rb(a,u){var p=dn,y=Fr(),E=u(),C=!Zr(y.memoizedState,E);if(C&&(y.memoizedState=E,yr=!0),y=y.queue,uh(Lb.bind(null,p,y,a),[a]),y.getSnapshot!==u||C||In!==null&&In.memoizedState.tag&1){if(p.flags|=2048,Ha(9,Ib.bind(null,p,y,E,u),void 0,null),Ln===null)throw Error(n(349));(Gi&30)!==0||Ob(p,u,E)}return E}function Ob(a,u,p){a.flags|=16384,a={getSnapshot:u,value:p},u=dn.updateQueue,u===null?(u={lastEffect:null,stores:null},dn.updateQueue=u,u.stores=[a]):(p=u.stores,p===null?u.stores=[a]:p.push(a))}function Ib(a,u,p,y){u.value=p,u.getSnapshot=y,Db(u)&&Pb(a)}function Lb(a,u,p){return p(function(){Db(u)&&Pb(a)})}function Db(a){var u=a.getSnapshot;a=a.value;try{var p=u();return!Zr(a,p)}catch{return!0}}function Pb(a){var u=Os(a,1);u!==null&&ss(u,a,1,-1)}function Bb(a){var u=ys();return typeof a=="function"&&(a=a()),u.memoizedState=u.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ua,lastRenderedState:a},u.queue=a,a=a.dispatch=Wj.bind(null,dn,a),[u.memoizedState,a]}function Ha(a,u,p,y){return a={tag:a,create:u,destroy:p,deps:y,next:null},u=dn.updateQueue,u===null?(u={lastEffect:null,stores:null},dn.updateQueue=u,u.lastEffect=a.next=a):(p=u.lastEffect,p===null?u.lastEffect=a.next=a:(y=p.next,p.next=a,a.next=y,u.lastEffect=a)),a}function $b(){return Fr().memoizedState}function Nc(a,u,p,y){var E=ys();dn.flags|=a,E.memoizedState=Ha(1|u,p,void 0,y===void 0?null:y)}function Cc(a,u,p,y){var E=Fr();y=y===void 0?null:y;var C=void 0;if(jn!==null){var O=jn.memoizedState;if(C=O.destroy,y!==null&&ih(y,O.deps)){E.memoizedState=Ha(u,p,C,y);return}}dn.flags|=a,E.memoizedState=Ha(1|u,p,C,y)}function Fb(a,u){return Nc(8390656,8,a,u)}function uh(a,u){return Cc(2048,8,a,u)}function zb(a,u){return Cc(4,2,a,u)}function Ub(a,u){return Cc(4,4,a,u)}function Hb(a,u){if(typeof u=="function")return a=a(),u(a),function(){u(null)};if(u!=null)return a=a(),u.current=a,function(){u.current=null}}function Wb(a,u,p){return p=p!=null?p.concat([a]):null,Cc(4,4,Hb.bind(null,u,a),p)}function dh(){}function Vb(a,u){var p=Fr();u=u===void 0?null:u;var y=p.memoizedState;return y!==null&&u!==null&&ih(u,y[1])?y[0]:(p.memoizedState=[a,u],a)}function qb(a,u){var p=Fr();u=u===void 0?null:u;var y=p.memoizedState;return y!==null&&u!==null&&ih(u,y[1])?y[0]:(a=a(),p.memoizedState=[a,u],a)}function Kb(a,u,p){return(Gi&21)===0?(a.baseState&&(a.baseState=!1,yr=!0),a.memoizedState=p):(Zr(p,u)||(p=ps(),dn.lanes|=p,Ji|=p,a.baseState=!0),u)}function Uj(a,u){var p=$t;$t=p!==0&&4>p?p:4,a(!0);var y=sh.transition;sh.transition={};try{a(!1),u()}finally{$t=p,sh.transition=y}}function Gb(){return Fr().memoizedState}function Hj(a,u,p){var y=ci(a);if(p={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null},Jb(a))Yb(u,p);else if(p=Cb(a,u,p,y),p!==null){var E=dr();ss(p,a,y,E),Xb(p,u,y)}}function Wj(a,u,p){var y=ci(a),E={lane:y,action:p,hasEagerState:!1,eagerState:null,next:null};if(Jb(a))Yb(u,E);else{var C=a.alternate;if(a.lanes===0&&(C===null||C.lanes===0)&&(C=u.lastRenderedReducer,C!==null))try{var O=u.lastRenderedState,H=C(O,p);if(E.hasEagerState=!0,E.eagerState=H,Zr(H,O)){var X=u.interleaved;X===null?(E.next=E,Qf(u)):(E.next=X.next,X.next=E),u.interleaved=E;return}}catch{}finally{}p=Cb(a,u,E,y),p!==null&&(E=dr(),ss(p,a,y,E),Xb(p,u,y))}}function Jb(a){var u=a.alternate;return a===dn||u!==null&&u===dn}function Yb(a,u){Fa=Ec=!0;var p=a.pending;p===null?u.next=u:(u.next=p.next,p.next=u),a.pending=u}function Xb(a,u,p){if((p&4194240)!==0){var y=u.lanes;y&=a.pendingLanes,p|=y,u.lanes=p,ba(a,p)}}var _c={readContext:$r,useCallback:tr,useContext:tr,useEffect:tr,useImperativeHandle:tr,useInsertionEffect:tr,useLayoutEffect:tr,useMemo:tr,useReducer:tr,useRef:tr,useState:tr,useDebugValue:tr,useDeferredValue:tr,useTransition:tr,useMutableSource:tr,useSyncExternalStore:tr,useId:tr,unstable_isNewReconciler:!1},Vj={readContext:$r,useCallback:function(a,u){return ys().memoizedState=[a,u===void 0?null:u],a},useContext:$r,useEffect:Fb,useImperativeHandle:function(a,u,p){return p=p!=null?p.concat([a]):null,Nc(4194308,4,Hb.bind(null,u,a),p)},useLayoutEffect:function(a,u){return Nc(4194308,4,a,u)},useInsertionEffect:function(a,u){return Nc(4,2,a,u)},useMemo:function(a,u){var p=ys();return u=u===void 0?null:u,a=a(),p.memoizedState=[a,u],a},useReducer:function(a,u,p){var y=ys();return u=p!==void 0?p(u):u,y.memoizedState=y.baseState=u,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:u},y.queue=a,a=a.dispatch=Hj.bind(null,dn,a),[y.memoizedState,a]},useRef:function(a){var u=ys();return a={current:a},u.memoizedState=a},useState:Bb,useDebugValue:dh,useDeferredValue:function(a){return ys().memoizedState=a},useTransition:function(){var a=Bb(!1),u=a[0];return a=Uj.bind(null,a[1]),ys().memoizedState=a,[u,a]},useMutableSource:function(){},useSyncExternalStore:function(a,u,p){var y=dn,E=ys();if(ln){if(p===void 0)throw Error(n(407));p=p()}else{if(p=u(),Ln===null)throw Error(n(349));(Gi&30)!==0||Ob(y,u,p)}E.memoizedState=p;var C={value:p,getSnapshot:u};return E.queue=C,Fb(Lb.bind(null,y,C,a),[a]),y.flags|=2048,Ha(9,Ib.bind(null,y,C,p,u),void 0,null),p},useId:function(){var a=ys(),u=Ln.identifierPrefix;if(ln){var p=Rs,y=As;p=(y&~(1<<32-nn(y)-1)).toString(32)+p,u=":"+u+"R"+p,p=za++,0<p&&(u+="H"+p.toString(32)),u+=":"}else p=zj++,u=":"+u+"r"+p.toString(32)+":";return a.memoizedState=u},unstable_isNewReconciler:!1},qj={readContext:$r,useCallback:Vb,useContext:$r,useEffect:uh,useImperativeHandle:Wb,useInsertionEffect:zb,useLayoutEffect:Ub,useMemo:qb,useReducer:lh,useRef:$b,useState:function(){return lh(Ua)},useDebugValue:dh,useDeferredValue:function(a){var u=Fr();return Kb(u,jn.memoizedState,a)},useTransition:function(){var a=lh(Ua)[0],u=Fr().memoizedState;return[a,u]},useMutableSource:Ab,useSyncExternalStore:Rb,useId:Gb,unstable_isNewReconciler:!1},Kj={readContext:$r,useCallback:Vb,useContext:$r,useEffect:uh,useImperativeHandle:Wb,useInsertionEffect:zb,useLayoutEffect:Ub,useMemo:qb,useReducer:ch,useRef:$b,useState:function(){return ch(Ua)},useDebugValue:dh,useDeferredValue:function(a){var u=Fr();return jn===null?u.memoizedState=a:Kb(u,jn.memoizedState,a)},useTransition:function(){var a=ch(Ua)[0],u=Fr().memoizedState;return[a,u]},useMutableSource:Ab,useSyncExternalStore:Rb,useId:Gb,unstable_isNewReconciler:!1};function ts(a,u){if(a&&a.defaultProps){u=J({},u),a=a.defaultProps;for(var p in a)u[p]===void 0&&(u[p]=a[p]);return u}return u}function fh(a,u,p,y){u=a.memoizedState,p=p(y,u),p=p==null?u:J({},u,p),a.memoizedState=p,a.lanes===0&&(a.updateQueue.baseState=p)}var Tc={isMounted:function(a){return(a=a._reactInternals)?Vt(a)===a:!1},enqueueSetState:function(a,u,p){a=a._reactInternals;var y=dr(),E=ci(a),C=Is(y,E);C.payload=u,p!=null&&(C.callback=p),u=ii(a,C,E),u!==null&&(ss(u,a,E,y),xc(u,a,E))},enqueueReplaceState:function(a,u,p){a=a._reactInternals;var y=dr(),E=ci(a),C=Is(y,E);C.tag=1,C.payload=u,p!=null&&(C.callback=p),u=ii(a,C,E),u!==null&&(ss(u,a,E,y),xc(u,a,E))},enqueueForceUpdate:function(a,u){a=a._reactInternals;var p=dr(),y=ci(a),E=Is(p,y);E.tag=2,u!=null&&(E.callback=u),u=ii(a,E,y),u!==null&&(ss(u,a,y,p),xc(u,a,y))}};function Qb(a,u,p,y,E,C,O){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(y,C,O):u.prototype&&u.prototype.isPureReactComponent?!ja(p,y)||!ja(E,C):!0}function Zb(a,u,p){var y=!1,E=ni,C=u.contextType;return typeof C=="object"&&C!==null?C=$r(C):(E=vr(u)?Hi:er.current,y=u.contextTypes,C=(y=y!=null)?Lo(a,E):ni),u=new u(p,C),a.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Tc,a.stateNode=u,u._reactInternals=a,y&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=E,a.__reactInternalMemoizedMaskedChildContext=C),u}function e0(a,u,p,y){a=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(p,y),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(p,y),u.state!==a&&Tc.enqueueReplaceState(u,u.state,null)}function hh(a,u,p,y){var E=a.stateNode;E.props=p,E.state=a.memoizedState,E.refs={},Zf(a);var C=u.contextType;typeof C=="object"&&C!==null?E.context=$r(C):(C=vr(u)?Hi:er.current,E.context=Lo(a,C)),E.state=a.memoizedState,C=u.getDerivedStateFromProps,typeof C=="function"&&(fh(a,u,C,p),E.state=a.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(u=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),u!==E.state&&Tc.enqueueReplaceState(E,E.state,null),wc(a,p,E,y),E.state=a.memoizedState),typeof E.componentDidMount=="function"&&(a.flags|=4194308)}function Ho(a,u){try{var p="",y=u;do p+=xe(y),y=y.return;while(y);var E=p}catch(C){E=`
39
- Error generating stack: `+C.message+`
40
- `+C.stack}return{value:a,source:u,stack:E,digest:null}}function ph(a,u,p){return{value:a,source:null,stack:p??null,digest:u??null}}function mh(a,u){try{console.error(u.value)}catch(p){setTimeout(function(){throw p})}}var Gj=typeof WeakMap=="function"?WeakMap:Map;function t0(a,u,p){p=Is(-1,p),p.tag=3,p.payload={element:null};var y=u.value;return p.callback=function(){Lc||(Lc=!0,Mh=y),mh(a,u)},p}function n0(a,u,p){p=Is(-1,p),p.tag=3;var y=a.type.getDerivedStateFromError;if(typeof y=="function"){var E=u.value;p.payload=function(){return y(E)},p.callback=function(){mh(a,u)}}var C=a.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(p.callback=function(){mh(a,u),typeof y!="function"&&(ai===null?ai=new Set([this]):ai.add(this));var O=u.stack;this.componentDidCatch(u.value,{componentStack:O!==null?O:""})}),p}function r0(a,u,p){var y=a.pingCache;if(y===null){y=a.pingCache=new Gj;var E=new Set;y.set(u,E)}else E=y.get(u),E===void 0&&(E=new Set,y.set(u,E));E.has(p)||(E.add(p),a=lM.bind(null,a,u,p),u.then(a,a))}function s0(a){do{var u;if((u=a.tag===13)&&(u=a.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return a;a=a.return}while(a!==null);return null}function i0(a,u,p,y,E){return(a.mode&1)===0?(a===u?a.flags|=65536:(a.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(u=Is(-1,1),u.tag=2,ii(p,u,1))),p.lanes|=1),a):(a.flags|=65536,a.lanes=E,a)}var Jj=M.ReactCurrentOwner,yr=!1;function ur(a,u,p,y){u.child=a===null?Nb(u,null,p,y):$o(u,a.child,p,y)}function o0(a,u,p,y,E){p=p.render;var C=u.ref;return zo(u,E),y=oh(a,u,p,y,C,E),p=ah(),a!==null&&!yr?(u.updateQueue=a.updateQueue,u.flags&=-2053,a.lanes&=~E,Ls(a,u,E)):(ln&&p&&Hf(u),u.flags|=1,ur(a,u,y,E),u.child)}function a0(a,u,p,y,E){if(a===null){var C=p.type;return typeof C=="function"&&!Ph(C)&&C.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(u.tag=15,u.type=C,l0(a,u,C,y,E)):(a=zc(p.type,null,y,u,u.mode,E),a.ref=u.ref,a.return=u,u.child=a)}if(C=a.child,(a.lanes&E)===0){var O=C.memoizedProps;if(p=p.compare,p=p!==null?p:ja,p(O,y)&&a.ref===u.ref)return Ls(a,u,E)}return u.flags|=1,a=di(C,y),a.ref=u.ref,a.return=u,u.child=a}function l0(a,u,p,y,E){if(a!==null){var C=a.memoizedProps;if(ja(C,y)&&a.ref===u.ref)if(yr=!1,u.pendingProps=y=C,(a.lanes&E)!==0)(a.flags&131072)!==0&&(yr=!0);else return u.lanes=a.lanes,Ls(a,u,E)}return gh(a,u,p,y,E)}function c0(a,u,p){var y=u.pendingProps,E=y.children,C=a!==null?a.memoizedState:null;if(y.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},en(Vo,jr),jr|=p;else{if((p&1073741824)===0)return a=C!==null?C.baseLanes|p:p,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:a,cachePool:null,transitions:null},u.updateQueue=null,en(Vo,jr),jr|=a,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},y=C!==null?C.baseLanes:p,en(Vo,jr),jr|=y}else C!==null?(y=C.baseLanes|p,u.memoizedState=null):y=p,en(Vo,jr),jr|=y;return ur(a,u,E,p),u.child}function u0(a,u){var p=u.ref;(a===null&&p!==null||a!==null&&a.ref!==p)&&(u.flags|=512,u.flags|=2097152)}function gh(a,u,p,y,E){var C=vr(p)?Hi:er.current;return C=Lo(u,C),zo(u,E),p=oh(a,u,p,y,C,E),y=ah(),a!==null&&!yr?(u.updateQueue=a.updateQueue,u.flags&=-2053,a.lanes&=~E,Ls(a,u,E)):(ln&&y&&Hf(u),u.flags|=1,ur(a,u,p,E),u.child)}function d0(a,u,p,y,E){if(vr(p)){var C=!0;fc(u)}else C=!1;if(zo(u,E),u.stateNode===null)Mc(a,u),Zb(u,p,y),hh(u,p,y,E),y=!0;else if(a===null){var O=u.stateNode,H=u.memoizedProps;O.props=H;var X=O.context,ue=p.contextType;typeof ue=="object"&&ue!==null?ue=$r(ue):(ue=vr(p)?Hi:er.current,ue=Lo(u,ue));var Te=p.getDerivedStateFromProps,Me=typeof Te=="function"||typeof O.getSnapshotBeforeUpdate=="function";Me||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(H!==y||X!==ue)&&e0(u,O,y,ue),si=!1;var _e=u.memoizedState;O.state=_e,wc(u,y,O,E),X=u.memoizedState,H!==y||_e!==X||gr.current||si?(typeof Te=="function"&&(fh(u,p,Te,y),X=u.memoizedState),(H=si||Qb(u,p,H,y,_e,X,ue))?(Me||typeof O.UNSAFE_componentWillMount!="function"&&typeof O.componentWillMount!="function"||(typeof O.componentWillMount=="function"&&O.componentWillMount(),typeof O.UNSAFE_componentWillMount=="function"&&O.UNSAFE_componentWillMount()),typeof O.componentDidMount=="function"&&(u.flags|=4194308)):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=y,u.memoizedState=X),O.props=y,O.state=X,O.context=ue,y=H):(typeof O.componentDidMount=="function"&&(u.flags|=4194308),y=!1)}else{O=u.stateNode,_b(a,u),H=u.memoizedProps,ue=u.type===u.elementType?H:ts(u.type,H),O.props=ue,Me=u.pendingProps,_e=O.context,X=p.contextType,typeof X=="object"&&X!==null?X=$r(X):(X=vr(p)?Hi:er.current,X=Lo(u,X));var Ke=p.getDerivedStateFromProps;(Te=typeof Ke=="function"||typeof O.getSnapshotBeforeUpdate=="function")||typeof O.UNSAFE_componentWillReceiveProps!="function"&&typeof O.componentWillReceiveProps!="function"||(H!==Me||_e!==X)&&e0(u,O,y,X),si=!1,_e=u.memoizedState,O.state=_e,wc(u,y,O,E);var et=u.memoizedState;H!==Me||_e!==et||gr.current||si?(typeof Ke=="function"&&(fh(u,p,Ke,y),et=u.memoizedState),(ue=si||Qb(u,p,ue,y,_e,et,X)||!1)?(Te||typeof O.UNSAFE_componentWillUpdate!="function"&&typeof O.componentWillUpdate!="function"||(typeof O.componentWillUpdate=="function"&&O.componentWillUpdate(y,et,X),typeof O.UNSAFE_componentWillUpdate=="function"&&O.UNSAFE_componentWillUpdate(y,et,X)),typeof O.componentDidUpdate=="function"&&(u.flags|=4),typeof O.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof O.componentDidUpdate!="function"||H===a.memoizedProps&&_e===a.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||H===a.memoizedProps&&_e===a.memoizedState||(u.flags|=1024),u.memoizedProps=y,u.memoizedState=et),O.props=y,O.state=et,O.context=X,y=ue):(typeof O.componentDidUpdate!="function"||H===a.memoizedProps&&_e===a.memoizedState||(u.flags|=4),typeof O.getSnapshotBeforeUpdate!="function"||H===a.memoizedProps&&_e===a.memoizedState||(u.flags|=1024),y=!1)}return vh(a,u,p,y,C,E)}function vh(a,u,p,y,E,C){u0(a,u);var O=(u.flags&128)!==0;if(!y&&!O)return E&&gb(u,p,!1),Ls(a,u,C);y=u.stateNode,Jj.current=u;var H=O&&typeof p.getDerivedStateFromError!="function"?null:y.render();return u.flags|=1,a!==null&&O?(u.child=$o(u,a.child,null,C),u.child=$o(u,null,H,C)):ur(a,u,H,C),u.memoizedState=y.state,E&&gb(u,p,!0),u.child}function f0(a){var u=a.stateNode;u.pendingContext?pb(a,u.pendingContext,u.pendingContext!==u.context):u.context&&pb(a,u.context,!1),eh(a,u.containerInfo)}function h0(a,u,p,y,E){return Bo(),Kf(E),u.flags|=256,ur(a,u,p,y),u.child}var yh={dehydrated:null,treeContext:null,retryLane:0};function bh(a){return{baseLanes:a,cachePool:null,transitions:null}}function p0(a,u,p){var y=u.pendingProps,E=un.current,C=!1,O=(u.flags&128)!==0,H;if((H=O)||(H=a!==null&&a.memoizedState===null?!1:(E&2)!==0),H?(C=!0,u.flags&=-129):(a===null||a.memoizedState!==null)&&(E|=1),en(un,E&1),a===null)return qf(u),a=u.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((u.mode&1)===0?u.lanes=1:a.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(O=y.children,a=y.fallback,C?(y=u.mode,C=u.child,O={mode:"hidden",children:O},(y&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=O):C=Uc(O,y,0,null),a=Zi(a,y,p,null),C.return=u,a.return=u,C.sibling=a,u.child=C,u.child.memoizedState=bh(p),u.memoizedState=yh,a):xh(u,O));if(E=a.memoizedState,E!==null&&(H=E.dehydrated,H!==null))return Yj(a,u,O,y,H,E,p);if(C){C=y.fallback,O=u.mode,E=a.child,H=E.sibling;var X={mode:"hidden",children:y.children};return(O&1)===0&&u.child!==E?(y=u.child,y.childLanes=0,y.pendingProps=X,u.deletions=null):(y=di(E,X),y.subtreeFlags=E.subtreeFlags&14680064),H!==null?C=di(H,C):(C=Zi(C,O,p,null),C.flags|=2),C.return=u,y.return=u,y.sibling=C,u.child=y,y=C,C=u.child,O=a.child.memoizedState,O=O===null?bh(p):{baseLanes:O.baseLanes|p,cachePool:null,transitions:O.transitions},C.memoizedState=O,C.childLanes=a.childLanes&~p,u.memoizedState=yh,y}return C=a.child,a=C.sibling,y=di(C,{mode:"visible",children:y.children}),(u.mode&1)===0&&(y.lanes=p),y.return=u,y.sibling=null,a!==null&&(p=u.deletions,p===null?(u.deletions=[a],u.flags|=16):p.push(a)),u.child=y,u.memoizedState=null,y}function xh(a,u){return u=Uc({mode:"visible",children:u},a.mode,0,null),u.return=a,a.child=u}function jc(a,u,p,y){return y!==null&&Kf(y),$o(u,a.child,null,p),a=xh(u,u.pendingProps.children),a.flags|=2,u.memoizedState=null,a}function Yj(a,u,p,y,E,C,O){if(p)return u.flags&256?(u.flags&=-257,y=ph(Error(n(422))),jc(a,u,O,y)):u.memoizedState!==null?(u.child=a.child,u.flags|=128,null):(C=y.fallback,E=u.mode,y=Uc({mode:"visible",children:y.children},E,0,null),C=Zi(C,E,O,null),C.flags|=2,y.return=u,C.return=u,y.sibling=C,u.child=y,(u.mode&1)!==0&&$o(u,a.child,null,O),u.child.memoizedState=bh(O),u.memoizedState=yh,C);if((u.mode&1)===0)return jc(a,u,O,null);if(E.data==="$!"){if(y=E.nextSibling&&E.nextSibling.dataset,y)var H=y.dgst;return y=H,C=Error(n(419)),y=ph(C,y,void 0),jc(a,u,O,y)}if(H=(O&a.childLanes)!==0,yr||H){if(y=Ln,y!==null){switch(O&-O){case 4:E=2;break;case 16:E=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:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(y.suspendedLanes|O))!==0?0:E,E!==0&&E!==C.retryLane&&(C.retryLane=E,Os(a,E),ss(y,a,E,-1))}return Dh(),y=ph(Error(n(421))),jc(a,u,O,y)}return E.data==="$?"?(u.flags|=128,u.child=a.child,u=cM.bind(null,a),E._reactRetry=u,null):(a=C.treeContext,Tr=ei(E.nextSibling),_r=u,ln=!0,es=null,a!==null&&(Pr[Br++]=As,Pr[Br++]=Rs,Pr[Br++]=Wi,As=a.id,Rs=a.overflow,Wi=u),u=xh(u,y.children),u.flags|=4096,u)}function m0(a,u,p){a.lanes|=u;var y=a.alternate;y!==null&&(y.lanes|=u),Xf(a.return,u,p)}function wh(a,u,p,y,E){var C=a.memoizedState;C===null?a.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:y,tail:p,tailMode:E}:(C.isBackwards=u,C.rendering=null,C.renderingStartTime=0,C.last=y,C.tail=p,C.tailMode=E)}function g0(a,u,p){var y=u.pendingProps,E=y.revealOrder,C=y.tail;if(ur(a,u,y.children,p),y=un.current,(y&2)!==0)y=y&1|2,u.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=u.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&m0(a,p,u);else if(a.tag===19)m0(a,p,u);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===u)break e;for(;a.sibling===null;){if(a.return===null||a.return===u)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}y&=1}if(en(un,y),(u.mode&1)===0)u.memoizedState=null;else switch(E){case"forwards":for(p=u.child,E=null;p!==null;)a=p.alternate,a!==null&&kc(a)===null&&(E=p),p=p.sibling;p=E,p===null?(E=u.child,u.child=null):(E=p.sibling,p.sibling=null),wh(u,!1,E,p,C);break;case"backwards":for(p=null,E=u.child,u.child=null;E!==null;){if(a=E.alternate,a!==null&&kc(a)===null){u.child=E;break}a=E.sibling,E.sibling=p,p=E,E=a}wh(u,!0,p,null,C);break;case"together":wh(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function Mc(a,u){(u.mode&1)===0&&a!==null&&(a.alternate=null,u.alternate=null,u.flags|=2)}function Ls(a,u,p){if(a!==null&&(u.dependencies=a.dependencies),Ji|=u.lanes,(p&u.childLanes)===0)return null;if(a!==null&&u.child!==a.child)throw Error(n(153));if(u.child!==null){for(a=u.child,p=di(a,a.pendingProps),u.child=p,p.return=u;a.sibling!==null;)a=a.sibling,p=p.sibling=di(a,a.pendingProps),p.return=u;p.sibling=null}return u.child}function Xj(a,u,p){switch(u.tag){case 3:f0(u),Bo();break;case 5:Mb(u);break;case 1:vr(u.type)&&fc(u);break;case 4:eh(u,u.stateNode.containerInfo);break;case 10:var y=u.type._context,E=u.memoizedProps.value;en(yc,y._currentValue),y._currentValue=E;break;case 13:if(y=u.memoizedState,y!==null)return y.dehydrated!==null?(en(un,un.current&1),u.flags|=128,null):(p&u.child.childLanes)!==0?p0(a,u,p):(en(un,un.current&1),a=Ls(a,u,p),a!==null?a.sibling:null);en(un,un.current&1);break;case 19:if(y=(p&u.childLanes)!==0,(a.flags&128)!==0){if(y)return g0(a,u,p);u.flags|=128}if(E=u.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),en(un,un.current),y)break;return null;case 22:case 23:return u.lanes=0,c0(a,u,p)}return Ls(a,u,p)}var v0,kh,y0,b0;v0=function(a,u){for(var p=u.child;p!==null;){if(p.tag===5||p.tag===6)a.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===u)break;for(;p.sibling===null;){if(p.return===null||p.return===u)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},kh=function(){},y0=function(a,u,p,y){var E=a.memoizedProps;if(E!==y){a=u.stateNode,Ki(vs.current);var C=null;switch(p){case"input":E=gt(a,E),y=gt(a,y),C=[];break;case"select":E=J({},E,{value:void 0}),y=J({},y,{value:void 0}),C=[];break;case"textarea":E=Le(a,E),y=Le(a,y),C=[];break;default:typeof E.onClick!="function"&&typeof y.onClick=="function"&&(a.onclick=cc)}lt(p,y);var O;p=null;for(ue in E)if(!y.hasOwnProperty(ue)&&E.hasOwnProperty(ue)&&E[ue]!=null)if(ue==="style"){var H=E[ue];for(O in H)H.hasOwnProperty(O)&&(p||(p={}),p[O]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(s.hasOwnProperty(ue)?C||(C=[]):(C=C||[]).push(ue,null));for(ue in y){var X=y[ue];if(H=E!=null?E[ue]:void 0,y.hasOwnProperty(ue)&&X!==H&&(X!=null||H!=null))if(ue==="style")if(H){for(O in H)!H.hasOwnProperty(O)||X&&X.hasOwnProperty(O)||(p||(p={}),p[O]="");for(O in X)X.hasOwnProperty(O)&&H[O]!==X[O]&&(p||(p={}),p[O]=X[O])}else p||(C||(C=[]),C.push(ue,p)),p=X;else ue==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,H=H?H.__html:void 0,X!=null&&H!==X&&(C=C||[]).push(ue,X)):ue==="children"?typeof X!="string"&&typeof X!="number"||(C=C||[]).push(ue,""+X):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(s.hasOwnProperty(ue)?(X!=null&&ue==="onScroll"&&rn("scroll",a),C||H===X||(C=[])):(C=C||[]).push(ue,X))}p&&(C=C||[]).push("style",p);var ue=C;(u.updateQueue=ue)&&(u.flags|=4)}},b0=function(a,u,p,y){p!==y&&(u.flags|=4)};function Wa(a,u){if(!ln)switch(a.tailMode){case"hidden":u=a.tail;for(var p=null;u!==null;)u.alternate!==null&&(p=u),u=u.sibling;p===null?a.tail=null:p.sibling=null;break;case"collapsed":p=a.tail;for(var y=null;p!==null;)p.alternate!==null&&(y=p),p=p.sibling;y===null?u||a.tail===null?a.tail=null:a.tail.sibling=null:y.sibling=null}}function nr(a){var u=a.alternate!==null&&a.alternate.child===a.child,p=0,y=0;if(u)for(var E=a.child;E!==null;)p|=E.lanes|E.childLanes,y|=E.subtreeFlags&14680064,y|=E.flags&14680064,E.return=a,E=E.sibling;else for(E=a.child;E!==null;)p|=E.lanes|E.childLanes,y|=E.subtreeFlags,y|=E.flags,E.return=a,E=E.sibling;return a.subtreeFlags|=y,a.childLanes=p,u}function Qj(a,u,p){var y=u.pendingProps;switch(Wf(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return nr(u),null;case 1:return vr(u.type)&&dc(),nr(u),null;case 3:return y=u.stateNode,Uo(),sn(gr),sn(er),rh(),y.pendingContext&&(y.context=y.pendingContext,y.pendingContext=null),(a===null||a.child===null)&&(gc(u)?u.flags|=4:a===null||a.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,es!==null&&(Oh(es),es=null))),kh(a,u),nr(u),null;case 5:th(u);var E=Ki($a.current);if(p=u.type,a!==null&&u.stateNode!=null)y0(a,u,p,y,E),a.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!y){if(u.stateNode===null)throw Error(n(166));return nr(u),null}if(a=Ki(vs.current),gc(u)){y=u.stateNode,p=u.type;var C=u.memoizedProps;switch(y[gs]=u,y[Ia]=C,a=(u.mode&1)!==0,p){case"dialog":rn("cancel",y),rn("close",y);break;case"iframe":case"object":case"embed":rn("load",y);break;case"video":case"audio":for(E=0;E<Aa.length;E++)rn(Aa[E],y);break;case"source":rn("error",y);break;case"img":case"image":case"link":rn("error",y),rn("load",y);break;case"details":rn("toggle",y);break;case"input":ht(y,C),rn("invalid",y);break;case"select":y._wrapperState={wasMultiple:!!C.multiple},rn("invalid",y);break;case"textarea":ve(y,C),rn("invalid",y)}lt(p,C),E=null;for(var O in C)if(C.hasOwnProperty(O)){var H=C[O];O==="children"?typeof H=="string"?y.textContent!==H&&(C.suppressHydrationWarning!==!0&&lc(y.textContent,H,a),E=["children",H]):typeof H=="number"&&y.textContent!==""+H&&(C.suppressHydrationWarning!==!0&&lc(y.textContent,H,a),E=["children",""+H]):s.hasOwnProperty(O)&&H!=null&&O==="onScroll"&&rn("scroll",y)}switch(p){case"input":Ge(y),_t(y,C,!0);break;case"textarea":Ge(y),je(y);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(y.onclick=cc)}y=E,u.updateQueue=y,y!==null&&(u.flags|=4)}else{O=E.nodeType===9?E:E.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Q(p)),a==="http://www.w3.org/1999/xhtml"?p==="script"?(a=O.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof y.is=="string"?a=O.createElement(p,{is:y.is}):(a=O.createElement(p),p==="select"&&(O=a,y.multiple?O.multiple=!0:y.size&&(O.size=y.size))):a=O.createElementNS(a,p),a[gs]=u,a[Ia]=y,v0(a,u,!1,!1),u.stateNode=a;e:{switch(O=bt(p,y),p){case"dialog":rn("cancel",a),rn("close",a),E=y;break;case"iframe":case"object":case"embed":rn("load",a),E=y;break;case"video":case"audio":for(E=0;E<Aa.length;E++)rn(Aa[E],a);E=y;break;case"source":rn("error",a),E=y;break;case"img":case"image":case"link":rn("error",a),rn("load",a),E=y;break;case"details":rn("toggle",a),E=y;break;case"input":ht(a,y),E=gt(a,y),rn("invalid",a);break;case"option":E=y;break;case"select":a._wrapperState={wasMultiple:!!y.multiple},E=J({},y,{value:void 0}),rn("invalid",a);break;case"textarea":ve(a,y),E=Le(a,y),rn("invalid",a);break;default:E=y}lt(p,E),H=E;for(C in H)if(H.hasOwnProperty(C)){var X=H[C];C==="style"?Ye(a,X):C==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&Je(a,X)):C==="children"?typeof X=="string"?(p!=="textarea"||X!=="")&&Ie(a,X):typeof X=="number"&&Ie(a,""+X):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(s.hasOwnProperty(C)?X!=null&&C==="onScroll"&&rn("scroll",a):X!=null&&T(a,C,X,O))}switch(p){case"input":Ge(a),_t(a,y,!1);break;case"textarea":Ge(a),je(a);break;case"option":y.value!=null&&a.setAttribute("value",""+ke(y.value));break;case"select":a.multiple=!!y.multiple,C=y.value,C!=null?ot(a,!!y.multiple,C,!1):y.defaultValue!=null&&ot(a,!!y.multiple,y.defaultValue,!0);break;default:typeof E.onClick=="function"&&(a.onclick=cc)}switch(p){case"button":case"input":case"select":case"textarea":y=!!y.autoFocus;break e;case"img":y=!0;break e;default:y=!1}}y&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return nr(u),null;case 6:if(a&&u.stateNode!=null)b0(a,u,a.memoizedProps,y);else{if(typeof y!="string"&&u.stateNode===null)throw Error(n(166));if(p=Ki($a.current),Ki(vs.current),gc(u)){if(y=u.stateNode,p=u.memoizedProps,y[gs]=u,(C=y.nodeValue!==p)&&(a=_r,a!==null))switch(a.tag){case 3:lc(y.nodeValue,p,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&lc(y.nodeValue,p,(a.mode&1)!==0)}C&&(u.flags|=4)}else y=(p.nodeType===9?p:p.ownerDocument).createTextNode(y),y[gs]=u,u.stateNode=y}return nr(u),null;case 13:if(sn(un),y=u.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(ln&&Tr!==null&&(u.mode&1)!==0&&(u.flags&128)===0)kb(),Bo(),u.flags|=98560,C=!1;else if(C=gc(u),y!==null&&y.dehydrated!==null){if(a===null){if(!C)throw Error(n(318));if(C=u.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[gs]=u}else Bo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;nr(u),C=!1}else es!==null&&(Oh(es),es=null),C=!0;if(!C)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=p,u):(y=y!==null,y!==(a!==null&&a.memoizedState!==null)&&y&&(u.child.flags|=8192,(u.mode&1)!==0&&(a===null||(un.current&1)!==0?Mn===0&&(Mn=3):Dh())),u.updateQueue!==null&&(u.flags|=4),nr(u),null);case 4:return Uo(),kh(a,u),a===null&&Ra(u.stateNode.containerInfo),nr(u),null;case 10:return Yf(u.type._context),nr(u),null;case 17:return vr(u.type)&&dc(),nr(u),null;case 19:if(sn(un),C=u.memoizedState,C===null)return nr(u),null;if(y=(u.flags&128)!==0,O=C.rendering,O===null)if(y)Wa(C,!1);else{if(Mn!==0||a!==null&&(a.flags&128)!==0)for(a=u.child;a!==null;){if(O=kc(a),O!==null){for(u.flags|=128,Wa(C,!1),y=O.updateQueue,y!==null&&(u.updateQueue=y,u.flags|=4),u.subtreeFlags=0,y=p,p=u.child;p!==null;)C=p,a=y,C.flags&=14680066,O=C.alternate,O===null?(C.childLanes=0,C.lanes=a,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=O.childLanes,C.lanes=O.lanes,C.child=O.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=O.memoizedProps,C.memoizedState=O.memoizedState,C.updateQueue=O.updateQueue,C.type=O.type,a=O.dependencies,C.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),p=p.sibling;return en(un,un.current&1|2),u.child}a=a.sibling}C.tail!==null&&Bt()>qo&&(u.flags|=128,y=!0,Wa(C,!1),u.lanes=4194304)}else{if(!y)if(a=kc(O),a!==null){if(u.flags|=128,y=!0,p=a.updateQueue,p!==null&&(u.updateQueue=p,u.flags|=4),Wa(C,!0),C.tail===null&&C.tailMode==="hidden"&&!O.alternate&&!ln)return nr(u),null}else 2*Bt()-C.renderingStartTime>qo&&p!==1073741824&&(u.flags|=128,y=!0,Wa(C,!1),u.lanes=4194304);C.isBackwards?(O.sibling=u.child,u.child=O):(p=C.last,p!==null?p.sibling=O:u.child=O,C.last=O)}return C.tail!==null?(u=C.tail,C.rendering=u,C.tail=u.sibling,C.renderingStartTime=Bt(),u.sibling=null,p=un.current,en(un,y?p&1|2:p&1),u):(nr(u),null);case 22:case 23:return Lh(),y=u.memoizedState!==null,a!==null&&a.memoizedState!==null!==y&&(u.flags|=8192),y&&(u.mode&1)!==0?(jr&1073741824)!==0&&(nr(u),u.subtreeFlags&6&&(u.flags|=8192)):nr(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function Zj(a,u){switch(Wf(u),u.tag){case 1:return vr(u.type)&&dc(),a=u.flags,a&65536?(u.flags=a&-65537|128,u):null;case 3:return Uo(),sn(gr),sn(er),rh(),a=u.flags,(a&65536)!==0&&(a&128)===0?(u.flags=a&-65537|128,u):null;case 5:return th(u),null;case 13:if(sn(un),a=u.memoizedState,a!==null&&a.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Bo()}return a=u.flags,a&65536?(u.flags=a&-65537|128,u):null;case 19:return sn(un),null;case 4:return Uo(),null;case 10:return Yf(u.type._context),null;case 22:case 23:return Lh(),null;case 24:return null;default:return null}}var Ac=!1,rr=!1,eM=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Wo(a,u){var p=a.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(y){pn(a,u,y)}else p.current=null}function Sh(a,u,p){try{p()}catch(y){pn(a,u,y)}}var x0=!1;function tM(a,u){if(Lf=Xl,a=Qy(),_f(a)){if("selectionStart"in a)var p={start:a.selectionStart,end:a.selectionEnd};else e:{p=(p=a.ownerDocument)&&p.defaultView||window;var y=p.getSelection&&p.getSelection();if(y&&y.rangeCount!==0){p=y.anchorNode;var E=y.anchorOffset,C=y.focusNode;y=y.focusOffset;try{p.nodeType,C.nodeType}catch{p=null;break e}var O=0,H=-1,X=-1,ue=0,Te=0,Me=a,_e=null;t:for(;;){for(var Ke;Me!==p||E!==0&&Me.nodeType!==3||(H=O+E),Me!==C||y!==0&&Me.nodeType!==3||(X=O+y),Me.nodeType===3&&(O+=Me.nodeValue.length),(Ke=Me.firstChild)!==null;)_e=Me,Me=Ke;for(;;){if(Me===a)break t;if(_e===p&&++ue===E&&(H=O),_e===C&&++Te===y&&(X=O),(Ke=Me.nextSibling)!==null)break;Me=_e,_e=Me.parentNode}Me=Ke}p=H===-1||X===-1?null:{start:H,end:X}}else p=null}p=p||{start:0,end:0}}else p=null;for(Df={focusedElem:a,selectionRange:p},Xl=!1,Qe=u;Qe!==null;)if(u=Qe,a=u.child,(u.subtreeFlags&1028)!==0&&a!==null)a.return=u,Qe=a;else for(;Qe!==null;){u=Qe;try{var et=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(et!==null){var rt=et.memoizedProps,kn=et.memoizedState,ae=u.stateNode,Z=ae.getSnapshotBeforeUpdate(u.elementType===u.type?rt:ts(u.type,rt),kn);ae.__reactInternalSnapshotBeforeUpdate=Z}break;case 3:var le=u.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Pe){pn(u,u.return,Pe)}if(a=u.sibling,a!==null){a.return=u.return,Qe=a;break}Qe=u.return}return et=x0,x0=!1,et}function Va(a,u,p){var y=u.updateQueue;if(y=y!==null?y.lastEffect:null,y!==null){var E=y=y.next;do{if((E.tag&a)===a){var C=E.destroy;E.destroy=void 0,C!==void 0&&Sh(u,p,C)}E=E.next}while(E!==y)}}function Rc(a,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var p=u=u.next;do{if((p.tag&a)===a){var y=p.create;p.destroy=y()}p=p.next}while(p!==u)}}function Eh(a){var u=a.ref;if(u!==null){var p=a.stateNode;switch(a.tag){case 5:a=p;break;default:a=p}typeof u=="function"?u(a):u.current=a}}function w0(a){var u=a.alternate;u!==null&&(a.alternate=null,w0(u)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(u=a.stateNode,u!==null&&(delete u[gs],delete u[Ia],delete u[Ff],delete u[Pj],delete u[Bj])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function k0(a){return a.tag===5||a.tag===3||a.tag===4}function S0(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||k0(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function Nh(a,u,p){var y=a.tag;if(y===5||y===6)a=a.stateNode,u?p.nodeType===8?p.parentNode.insertBefore(a,u):p.insertBefore(a,u):(p.nodeType===8?(u=p.parentNode,u.insertBefore(a,p)):(u=p,u.appendChild(a)),p=p._reactRootContainer,p!=null||u.onclick!==null||(u.onclick=cc));else if(y!==4&&(a=a.child,a!==null))for(Nh(a,u,p),a=a.sibling;a!==null;)Nh(a,u,p),a=a.sibling}function Ch(a,u,p){var y=a.tag;if(y===5||y===6)a=a.stateNode,u?p.insertBefore(a,u):p.appendChild(a);else if(y!==4&&(a=a.child,a!==null))for(Ch(a,u,p),a=a.sibling;a!==null;)Ch(a,u,p),a=a.sibling}var Vn=null,ns=!1;function oi(a,u,p){for(p=p.child;p!==null;)E0(a,u,p),p=p.sibling}function E0(a,u,p){if(Mt&&typeof Mt.onCommitFiberUnmount=="function")try{Mt.onCommitFiberUnmount(Ct,p)}catch{}switch(p.tag){case 5:rr||Wo(p,u);case 6:var y=Vn,E=ns;Vn=null,oi(a,u,p),Vn=y,ns=E,Vn!==null&&(ns?(a=Vn,p=p.stateNode,a.nodeType===8?a.parentNode.removeChild(p):a.removeChild(p)):Vn.removeChild(p.stateNode));break;case 18:Vn!==null&&(ns?(a=Vn,p=p.stateNode,a.nodeType===8?$f(a.parentNode,p):a.nodeType===1&&$f(a,p),Sa(a)):$f(Vn,p.stateNode));break;case 4:y=Vn,E=ns,Vn=p.stateNode.containerInfo,ns=!0,oi(a,u,p),Vn=y,ns=E;break;case 0:case 11:case 14:case 15:if(!rr&&(y=p.updateQueue,y!==null&&(y=y.lastEffect,y!==null))){E=y=y.next;do{var C=E,O=C.destroy;C=C.tag,O!==void 0&&((C&2)!==0||(C&4)!==0)&&Sh(p,u,O),E=E.next}while(E!==y)}oi(a,u,p);break;case 1:if(!rr&&(Wo(p,u),y=p.stateNode,typeof y.componentWillUnmount=="function"))try{y.props=p.memoizedProps,y.state=p.memoizedState,y.componentWillUnmount()}catch(H){pn(p,u,H)}oi(a,u,p);break;case 21:oi(a,u,p);break;case 22:p.mode&1?(rr=(y=rr)||p.memoizedState!==null,oi(a,u,p),rr=y):oi(a,u,p);break;default:oi(a,u,p)}}function N0(a){var u=a.updateQueue;if(u!==null){a.updateQueue=null;var p=a.stateNode;p===null&&(p=a.stateNode=new eM),u.forEach(function(y){var E=uM.bind(null,a,y);p.has(y)||(p.add(y),y.then(E,E))})}}function rs(a,u){var p=u.deletions;if(p!==null)for(var y=0;y<p.length;y++){var E=p[y];try{var C=a,O=u,H=O;e:for(;H!==null;){switch(H.tag){case 5:Vn=H.stateNode,ns=!1;break e;case 3:Vn=H.stateNode.containerInfo,ns=!0;break e;case 4:Vn=H.stateNode.containerInfo,ns=!0;break e}H=H.return}if(Vn===null)throw Error(n(160));E0(C,O,E),Vn=null,ns=!1;var X=E.alternate;X!==null&&(X.return=null),E.return=null}catch(ue){pn(E,u,ue)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)C0(u,a),u=u.sibling}function C0(a,u){var p=a.alternate,y=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(rs(u,a),bs(a),y&4){try{Va(3,a,a.return),Rc(3,a)}catch(rt){pn(a,a.return,rt)}try{Va(5,a,a.return)}catch(rt){pn(a,a.return,rt)}}break;case 1:rs(u,a),bs(a),y&512&&p!==null&&Wo(p,p.return);break;case 5:if(rs(u,a),bs(a),y&512&&p!==null&&Wo(p,p.return),a.flags&32){var E=a.stateNode;try{Ie(E,"")}catch(rt){pn(a,a.return,rt)}}if(y&4&&(E=a.stateNode,E!=null)){var C=a.memoizedProps,O=p!==null?p.memoizedProps:C,H=a.type,X=a.updateQueue;if(a.updateQueue=null,X!==null)try{H==="input"&&C.type==="radio"&&C.name!=null&&ge(E,C),bt(H,O);var ue=bt(H,C);for(O=0;O<X.length;O+=2){var Te=X[O],Me=X[O+1];Te==="style"?Ye(E,Me):Te==="dangerouslySetInnerHTML"?Je(E,Me):Te==="children"?Ie(E,Me):T(E,Te,Me,ue)}switch(H){case"input":vt(E,C);break;case"textarea":te(E,C);break;case"select":var _e=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!C.multiple;var Ke=C.value;Ke!=null?ot(E,!!C.multiple,Ke,!1):_e!==!!C.multiple&&(C.defaultValue!=null?ot(E,!!C.multiple,C.defaultValue,!0):ot(E,!!C.multiple,C.multiple?[]:"",!1))}E[Ia]=C}catch(rt){pn(a,a.return,rt)}}break;case 6:if(rs(u,a),bs(a),y&4){if(a.stateNode===null)throw Error(n(162));E=a.stateNode,C=a.memoizedProps;try{E.nodeValue=C}catch(rt){pn(a,a.return,rt)}}break;case 3:if(rs(u,a),bs(a),y&4&&p!==null&&p.memoizedState.isDehydrated)try{Sa(u.containerInfo)}catch(rt){pn(a,a.return,rt)}break;case 4:rs(u,a),bs(a);break;case 13:rs(u,a),bs(a),E=a.child,E.flags&8192&&(C=E.memoizedState!==null,E.stateNode.isHidden=C,!C||E.alternate!==null&&E.alternate.memoizedState!==null||(jh=Bt())),y&4&&N0(a);break;case 22:if(Te=p!==null&&p.memoizedState!==null,a.mode&1?(rr=(ue=rr)||Te,rs(u,a),rr=ue):rs(u,a),bs(a),y&8192){if(ue=a.memoizedState!==null,(a.stateNode.isHidden=ue)&&!Te&&(a.mode&1)!==0)for(Qe=a,Te=a.child;Te!==null;){for(Me=Qe=Te;Qe!==null;){switch(_e=Qe,Ke=_e.child,_e.tag){case 0:case 11:case 14:case 15:Va(4,_e,_e.return);break;case 1:Wo(_e,_e.return);var et=_e.stateNode;if(typeof et.componentWillUnmount=="function"){y=_e,p=_e.return;try{u=y,et.props=u.memoizedProps,et.state=u.memoizedState,et.componentWillUnmount()}catch(rt){pn(y,p,rt)}}break;case 5:Wo(_e,_e.return);break;case 22:if(_e.memoizedState!==null){j0(Me);continue}}Ke!==null?(Ke.return=_e,Qe=Ke):j0(Me)}Te=Te.sibling}e:for(Te=null,Me=a;;){if(Me.tag===5){if(Te===null){Te=Me;try{E=Me.stateNode,ue?(C=E.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(H=Me.stateNode,X=Me.memoizedProps.style,O=X!=null&&X.hasOwnProperty("display")?X.display:null,H.style.display=at("display",O))}catch(rt){pn(a,a.return,rt)}}}else if(Me.tag===6){if(Te===null)try{Me.stateNode.nodeValue=ue?"":Me.memoizedProps}catch(rt){pn(a,a.return,rt)}}else if((Me.tag!==22&&Me.tag!==23||Me.memoizedState===null||Me===a)&&Me.child!==null){Me.child.return=Me,Me=Me.child;continue}if(Me===a)break e;for(;Me.sibling===null;){if(Me.return===null||Me.return===a)break e;Te===Me&&(Te=null),Me=Me.return}Te===Me&&(Te=null),Me.sibling.return=Me.return,Me=Me.sibling}}break;case 19:rs(u,a),bs(a),y&4&&N0(a);break;case 21:break;default:rs(u,a),bs(a)}}function bs(a){var u=a.flags;if(u&2){try{e:{for(var p=a.return;p!==null;){if(k0(p)){var y=p;break e}p=p.return}throw Error(n(160))}switch(y.tag){case 5:var E=y.stateNode;y.flags&32&&(Ie(E,""),y.flags&=-33);var C=S0(a);Ch(a,C,E);break;case 3:case 4:var O=y.stateNode.containerInfo,H=S0(a);Nh(a,H,O);break;default:throw Error(n(161))}}catch(X){pn(a,a.return,X)}a.flags&=-3}u&4096&&(a.flags&=-4097)}function nM(a,u,p){Qe=a,_0(a)}function _0(a,u,p){for(var y=(a.mode&1)!==0;Qe!==null;){var E=Qe,C=E.child;if(E.tag===22&&y){var O=E.memoizedState!==null||Ac;if(!O){var H=E.alternate,X=H!==null&&H.memoizedState!==null||rr;H=Ac;var ue=rr;if(Ac=O,(rr=X)&&!ue)for(Qe=E;Qe!==null;)O=Qe,X=O.child,O.tag===22&&O.memoizedState!==null?M0(E):X!==null?(X.return=O,Qe=X):M0(E);for(;C!==null;)Qe=C,_0(C),C=C.sibling;Qe=E,Ac=H,rr=ue}T0(a)}else(E.subtreeFlags&8772)!==0&&C!==null?(C.return=E,Qe=C):T0(a)}}function T0(a){for(;Qe!==null;){var u=Qe;if((u.flags&8772)!==0){var p=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:rr||Rc(5,u);break;case 1:var y=u.stateNode;if(u.flags&4&&!rr)if(p===null)y.componentDidMount();else{var E=u.elementType===u.type?p.memoizedProps:ts(u.type,p.memoizedProps);y.componentDidUpdate(E,p.memoizedState,y.__reactInternalSnapshotBeforeUpdate)}var C=u.updateQueue;C!==null&&jb(u,C,y);break;case 3:var O=u.updateQueue;if(O!==null){if(p=null,u.child!==null)switch(u.child.tag){case 5:p=u.child.stateNode;break;case 1:p=u.child.stateNode}jb(u,O,p)}break;case 5:var H=u.stateNode;if(p===null&&u.flags&4){p=H;var X=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":X.autoFocus&&p.focus();break;case"img":X.src&&(p.src=X.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ue=u.alternate;if(ue!==null){var Te=ue.memoizedState;if(Te!==null){var Me=Te.dehydrated;Me!==null&&Sa(Me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}rr||u.flags&512&&Eh(u)}catch(_e){pn(u,u.return,_e)}}if(u===a){Qe=null;break}if(p=u.sibling,p!==null){p.return=u.return,Qe=p;break}Qe=u.return}}function j0(a){for(;Qe!==null;){var u=Qe;if(u===a){Qe=null;break}var p=u.sibling;if(p!==null){p.return=u.return,Qe=p;break}Qe=u.return}}function M0(a){for(;Qe!==null;){var u=Qe;try{switch(u.tag){case 0:case 11:case 15:var p=u.return;try{Rc(4,u)}catch(X){pn(u,p,X)}break;case 1:var y=u.stateNode;if(typeof y.componentDidMount=="function"){var E=u.return;try{y.componentDidMount()}catch(X){pn(u,E,X)}}var C=u.return;try{Eh(u)}catch(X){pn(u,C,X)}break;case 5:var O=u.return;try{Eh(u)}catch(X){pn(u,O,X)}}}catch(X){pn(u,u.return,X)}if(u===a){Qe=null;break}var H=u.sibling;if(H!==null){H.return=u.return,Qe=H;break}Qe=u.return}}var rM=Math.ceil,Oc=M.ReactCurrentDispatcher,_h=M.ReactCurrentOwner,zr=M.ReactCurrentBatchConfig,Ft=0,Ln=null,Cn=null,qn=0,jr=0,Vo=ti(0),Mn=0,qa=null,Ji=0,Ic=0,Th=0,Ka=null,br=null,jh=0,qo=1/0,Ds=null,Lc=!1,Mh=null,ai=null,Dc=!1,li=null,Pc=0,Ga=0,Ah=null,Bc=-1,$c=0;function dr(){return(Ft&6)!==0?Bt():Bc!==-1?Bc:Bc=Bt()}function ci(a){return(a.mode&1)===0?1:(Ft&2)!==0&&qn!==0?qn&-qn:Fj.transition!==null?($c===0&&($c=ps()),$c):(a=$t,a!==0||(a=window.event,a=a===void 0?16:Ry(a.type)),a)}function ss(a,u,p,y){if(50<Ga)throw Ga=0,Ah=null,Error(n(185));Rn(a,p,y),((Ft&2)===0||a!==Ln)&&(a===Ln&&((Ft&2)===0&&(Ic|=p),Mn===4&&ui(a,qn)),xr(a,y),p===1&&Ft===0&&(u.mode&1)===0&&(qo=Bt()+500,hc&&ri()))}function xr(a,u){var p=a.callbackNode;Zn(a,u);var y=wt(a,a===Ln?qn:0);if(y===0)p!==null&&cr(p),a.callbackNode=null,a.callbackPriority=0;else if(u=y&-y,a.callbackPriority!==u){if(p!=null&&cr(p),u===1)a.tag===0?$j(R0.bind(null,a)):vb(R0.bind(null,a)),Lj(function(){(Ft&6)===0&&ri()}),p=null;else{switch(Nt(y)){case 1:p=Ys;break;case 4:p=Qr;break;case 16:p=hs;break;case 536870912:p=nt;break;default:p=hs}p=F0(p,A0.bind(null,a))}a.callbackPriority=u,a.callbackNode=p}}function A0(a,u){if(Bc=-1,$c=0,(Ft&6)!==0)throw Error(n(327));var p=a.callbackNode;if(Ko()&&a.callbackNode!==p)return null;var y=wt(a,a===Ln?qn:0);if(y===0)return null;if((y&30)!==0||(y&a.expiredLanes)!==0||u)u=Fc(a,y);else{u=y;var E=Ft;Ft|=2;var C=I0();(Ln!==a||qn!==u)&&(Ds=null,qo=Bt()+500,Xi(a,u));do try{oM();break}catch(H){O0(a,H)}while(!0);Jf(),Oc.current=C,Ft=E,Cn!==null?u=0:(Ln=null,qn=0,u=Mn)}if(u!==0){if(u===2&&(E=Wn(a),E!==0&&(y=E,u=Rh(a,E))),u===1)throw p=qa,Xi(a,0),ui(a,y),xr(a,Bt()),p;if(u===6)ui(a,y);else{if(E=a.current.alternate,(y&30)===0&&!sM(E)&&(u=Fc(a,y),u===2&&(C=Wn(a),C!==0&&(y=C,u=Rh(a,C))),u===1))throw p=qa,Xi(a,0),ui(a,y),xr(a,Bt()),p;switch(a.finishedWork=E,a.finishedLanes=y,u){case 0:case 1:throw Error(n(345));case 2:Qi(a,br,Ds);break;case 3:if(ui(a,y),(y&130023424)===y&&(u=jh+500-Bt(),10<u)){if(wt(a,0)!==0)break;if(E=a.suspendedLanes,(E&y)!==y){dr(),a.pingedLanes|=a.suspendedLanes&E;break}a.timeoutHandle=Bf(Qi.bind(null,a,br,Ds),u);break}Qi(a,br,Ds);break;case 4:if(ui(a,y),(y&4194240)===y)break;for(u=a.eventTimes,E=-1;0<y;){var O=31-nn(y);C=1<<O,O=u[O],O>E&&(E=O),y&=~C}if(y=E,y=Bt()-y,y=(120>y?120:480>y?480:1080>y?1080:1920>y?1920:3e3>y?3e3:4320>y?4320:1960*rM(y/1960))-y,10<y){a.timeoutHandle=Bf(Qi.bind(null,a,br,Ds),y);break}Qi(a,br,Ds);break;case 5:Qi(a,br,Ds);break;default:throw Error(n(329))}}}return xr(a,Bt()),a.callbackNode===p?A0.bind(null,a):null}function Rh(a,u){var p=Ka;return a.current.memoizedState.isDehydrated&&(Xi(a,u).flags|=256),a=Fc(a,u),a!==2&&(u=br,br=p,u!==null&&Oh(u)),a}function Oh(a){br===null?br=a:br.push.apply(br,a)}function sM(a){for(var u=a;;){if(u.flags&16384){var p=u.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var y=0;y<p.length;y++){var E=p[y],C=E.getSnapshot;E=E.value;try{if(!Zr(C(),E))return!1}catch{return!1}}}if(p=u.child,u.subtreeFlags&16384&&p!==null)p.return=u,u=p;else{if(u===a)break;for(;u.sibling===null;){if(u.return===null||u.return===a)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function ui(a,u){for(u&=~Th,u&=~Ic,a.suspendedLanes|=u,a.pingedLanes&=~u,a=a.expirationTimes;0<u;){var p=31-nn(u),y=1<<p;a[p]=-1,u&=~y}}function R0(a){if((Ft&6)!==0)throw Error(n(327));Ko();var u=wt(a,0);if((u&1)===0)return xr(a,Bt()),null;var p=Fc(a,u);if(a.tag!==0&&p===2){var y=Wn(a);y!==0&&(u=y,p=Rh(a,y))}if(p===1)throw p=qa,Xi(a,0),ui(a,u),xr(a,Bt()),p;if(p===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=u,Qi(a,br,Ds),xr(a,Bt()),null}function Ih(a,u){var p=Ft;Ft|=1;try{return a(u)}finally{Ft=p,Ft===0&&(qo=Bt()+500,hc&&ri())}}function Yi(a){li!==null&&li.tag===0&&(Ft&6)===0&&Ko();var u=Ft;Ft|=1;var p=zr.transition,y=$t;try{if(zr.transition=null,$t=1,a)return a()}finally{$t=y,zr.transition=p,Ft=u,(Ft&6)===0&&ri()}}function Lh(){jr=Vo.current,sn(Vo)}function Xi(a,u){a.finishedWork=null,a.finishedLanes=0;var p=a.timeoutHandle;if(p!==-1&&(a.timeoutHandle=-1,Ij(p)),Cn!==null)for(p=Cn.return;p!==null;){var y=p;switch(Wf(y),y.tag){case 1:y=y.type.childContextTypes,y!=null&&dc();break;case 3:Uo(),sn(gr),sn(er),rh();break;case 5:th(y);break;case 4:Uo();break;case 13:sn(un);break;case 19:sn(un);break;case 10:Yf(y.type._context);break;case 22:case 23:Lh()}p=p.return}if(Ln=a,Cn=a=di(a.current,null),qn=jr=u,Mn=0,qa=null,Th=Ic=Ji=0,br=Ka=null,qi!==null){for(u=0;u<qi.length;u++)if(p=qi[u],y=p.interleaved,y!==null){p.interleaved=null;var E=y.next,C=p.pending;if(C!==null){var O=C.next;C.next=E,y.next=O}p.pending=y}qi=null}return a}function O0(a,u){do{var p=Cn;try{if(Jf(),Sc.current=_c,Ec){for(var y=dn.memoizedState;y!==null;){var E=y.queue;E!==null&&(E.pending=null),y=y.next}Ec=!1}if(Gi=0,In=jn=dn=null,Fa=!1,za=0,_h.current=null,p===null||p.return===null){Mn=1,qa=u,Cn=null;break}e:{var C=a,O=p.return,H=p,X=u;if(u=qn,H.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var ue=X,Te=H,Me=Te.tag;if((Te.mode&1)===0&&(Me===0||Me===11||Me===15)){var _e=Te.alternate;_e?(Te.updateQueue=_e.updateQueue,Te.memoizedState=_e.memoizedState,Te.lanes=_e.lanes):(Te.updateQueue=null,Te.memoizedState=null)}var Ke=s0(O);if(Ke!==null){Ke.flags&=-257,i0(Ke,O,H,C,u),Ke.mode&1&&r0(C,ue,u),u=Ke,X=ue;var et=u.updateQueue;if(et===null){var rt=new Set;rt.add(X),u.updateQueue=rt}else et.add(X);break e}else{if((u&1)===0){r0(C,ue,u),Dh();break e}X=Error(n(426))}}else if(ln&&H.mode&1){var kn=s0(O);if(kn!==null){(kn.flags&65536)===0&&(kn.flags|=256),i0(kn,O,H,C,u),Kf(Ho(X,H));break e}}C=X=Ho(X,H),Mn!==4&&(Mn=2),Ka===null?Ka=[C]:Ka.push(C),C=O;do{switch(C.tag){case 3:C.flags|=65536,u&=-u,C.lanes|=u;var ae=t0(C,X,u);Tb(C,ae);break e;case 1:H=X;var Z=C.type,le=C.stateNode;if((C.flags&128)===0&&(typeof Z.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(ai===null||!ai.has(le)))){C.flags|=65536,u&=-u,C.lanes|=u;var Pe=n0(C,H,u);Tb(C,Pe);break e}}C=C.return}while(C!==null)}D0(p)}catch(st){u=st,Cn===p&&p!==null&&(Cn=p=p.return);continue}break}while(!0)}function I0(){var a=Oc.current;return Oc.current=_c,a===null?_c:a}function Dh(){(Mn===0||Mn===3||Mn===2)&&(Mn=4),Ln===null||(Ji&268435455)===0&&(Ic&268435455)===0||ui(Ln,qn)}function Fc(a,u){var p=Ft;Ft|=2;var y=I0();(Ln!==a||qn!==u)&&(Ds=null,Xi(a,u));do try{iM();break}catch(E){O0(a,E)}while(!0);if(Jf(),Ft=p,Oc.current=y,Cn!==null)throw Error(n(261));return Ln=null,qn=0,Mn}function iM(){for(;Cn!==null;)L0(Cn)}function oM(){for(;Cn!==null&&!_s();)L0(Cn)}function L0(a){var u=$0(a.alternate,a,jr);a.memoizedProps=a.pendingProps,u===null?D0(a):Cn=u,_h.current=null}function D0(a){var u=a;do{var p=u.alternate;if(a=u.return,(u.flags&32768)===0){if(p=Qj(p,u,jr),p!==null){Cn=p;return}}else{if(p=Zj(p,u),p!==null){p.flags&=32767,Cn=p;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Mn=6,Cn=null;return}}if(u=u.sibling,u!==null){Cn=u;return}Cn=u=a}while(u!==null);Mn===0&&(Mn=5)}function Qi(a,u,p){var y=$t,E=zr.transition;try{zr.transition=null,$t=1,aM(a,u,p,y)}finally{zr.transition=E,$t=y}return null}function aM(a,u,p,y){do Ko();while(li!==null);if((Ft&6)!==0)throw Error(n(327));p=a.finishedWork;var E=a.finishedLanes;if(p===null)return null;if(a.finishedWork=null,a.finishedLanes=0,p===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var C=p.lanes|p.childLanes;if(Dr(a,C),a===Ln&&(Cn=Ln=null,qn=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||Dc||(Dc=!0,F0(hs,function(){return Ko(),null})),C=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||C){C=zr.transition,zr.transition=null;var O=$t;$t=1;var H=Ft;Ft|=4,_h.current=null,tM(a,p),C0(p,a),_j(Df),Xl=!!Lf,Df=Lf=null,a.current=p,nM(p),Ir(),Ft=H,$t=O,zr.transition=C}else a.current=p;if(Dc&&(Dc=!1,li=a,Pc=E),C=a.pendingLanes,C===0&&(ai=null),an(p.stateNode),xr(a,Bt()),u!==null)for(y=a.onRecoverableError,p=0;p<u.length;p++)E=u[p],y(E.value,{componentStack:E.stack,digest:E.digest});if(Lc)throw Lc=!1,a=Mh,Mh=null,a;return(Pc&1)!==0&&a.tag!==0&&Ko(),C=a.pendingLanes,(C&1)!==0?a===Ah?Ga++:(Ga=0,Ah=a):Ga=0,ri(),null}function Ko(){if(li!==null){var a=Nt(Pc),u=zr.transition,p=$t;try{if(zr.transition=null,$t=16>a?16:a,li===null)var y=!1;else{if(a=li,li=null,Pc=0,(Ft&6)!==0)throw Error(n(331));var E=Ft;for(Ft|=4,Qe=a.current;Qe!==null;){var C=Qe,O=C.child;if((Qe.flags&16)!==0){var H=C.deletions;if(H!==null){for(var X=0;X<H.length;X++){var ue=H[X];for(Qe=ue;Qe!==null;){var Te=Qe;switch(Te.tag){case 0:case 11:case 15:Va(8,Te,C)}var Me=Te.child;if(Me!==null)Me.return=Te,Qe=Me;else for(;Qe!==null;){Te=Qe;var _e=Te.sibling,Ke=Te.return;if(w0(Te),Te===ue){Qe=null;break}if(_e!==null){_e.return=Ke,Qe=_e;break}Qe=Ke}}}var et=C.alternate;if(et!==null){var rt=et.child;if(rt!==null){et.child=null;do{var kn=rt.sibling;rt.sibling=null,rt=kn}while(rt!==null)}}Qe=C}}if((C.subtreeFlags&2064)!==0&&O!==null)O.return=C,Qe=O;else e:for(;Qe!==null;){if(C=Qe,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:Va(9,C,C.return)}var ae=C.sibling;if(ae!==null){ae.return=C.return,Qe=ae;break e}Qe=C.return}}var Z=a.current;for(Qe=Z;Qe!==null;){O=Qe;var le=O.child;if((O.subtreeFlags&2064)!==0&&le!==null)le.return=O,Qe=le;else e:for(O=Z;Qe!==null;){if(H=Qe,(H.flags&2048)!==0)try{switch(H.tag){case 0:case 11:case 15:Rc(9,H)}}catch(st){pn(H,H.return,st)}if(H===O){Qe=null;break e}var Pe=H.sibling;if(Pe!==null){Pe.return=H.return,Qe=Pe;break e}Qe=H.return}}if(Ft=E,ri(),Mt&&typeof Mt.onPostCommitFiberRoot=="function")try{Mt.onPostCommitFiberRoot(Ct,a)}catch{}y=!0}return y}finally{$t=p,zr.transition=u}}return!1}function P0(a,u,p){u=Ho(p,u),u=t0(a,u,1),a=ii(a,u,1),u=dr(),a!==null&&(Rn(a,1,u),xr(a,u))}function pn(a,u,p){if(a.tag===3)P0(a,a,p);else for(;u!==null;){if(u.tag===3){P0(u,a,p);break}else if(u.tag===1){var y=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof y.componentDidCatch=="function"&&(ai===null||!ai.has(y))){a=Ho(p,a),a=n0(u,a,1),u=ii(u,a,1),a=dr(),u!==null&&(Rn(u,1,a),xr(u,a));break}}u=u.return}}function lM(a,u,p){var y=a.pingCache;y!==null&&y.delete(u),u=dr(),a.pingedLanes|=a.suspendedLanes&p,Ln===a&&(qn&p)===p&&(Mn===4||Mn===3&&(qn&130023424)===qn&&500>Bt()-jh?Xi(a,0):Th|=p),xr(a,u)}function B0(a,u){u===0&&((a.mode&1)===0?u=1:(u=ye,ye<<=1,(ye&130023424)===0&&(ye=4194304)));var p=dr();a=Os(a,u),a!==null&&(Rn(a,u,p),xr(a,p))}function cM(a){var u=a.memoizedState,p=0;u!==null&&(p=u.retryLane),B0(a,p)}function uM(a,u){var p=0;switch(a.tag){case 13:var y=a.stateNode,E=a.memoizedState;E!==null&&(p=E.retryLane);break;case 19:y=a.stateNode;break;default:throw Error(n(314))}y!==null&&y.delete(u),B0(a,p)}var $0;$0=function(a,u,p){if(a!==null)if(a.memoizedProps!==u.pendingProps||gr.current)yr=!0;else{if((a.lanes&p)===0&&(u.flags&128)===0)return yr=!1,Xj(a,u,p);yr=(a.flags&131072)!==0}else yr=!1,ln&&(u.flags&1048576)!==0&&yb(u,mc,u.index);switch(u.lanes=0,u.tag){case 2:var y=u.type;Mc(a,u),a=u.pendingProps;var E=Lo(u,er.current);zo(u,p),E=oh(null,u,y,a,E,p);var C=ah();return u.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,vr(y)?(C=!0,fc(u)):C=!1,u.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Zf(u),E.updater=Tc,u.stateNode=E,E._reactInternals=u,hh(u,y,a,p),u=vh(null,u,y,!0,C,p)):(u.tag=0,ln&&C&&Hf(u),ur(null,u,E,p),u=u.child),u;case 16:y=u.elementType;e:{switch(Mc(a,u),a=u.pendingProps,E=y._init,y=E(y._payload),u.type=y,E=u.tag=fM(y),a=ts(y,a),E){case 0:u=gh(null,u,y,a,p);break e;case 1:u=d0(null,u,y,a,p);break e;case 11:u=o0(null,u,y,a,p);break e;case 14:u=a0(null,u,y,ts(y.type,a),p);break e}throw Error(n(306,y,""))}return u;case 0:return y=u.type,E=u.pendingProps,E=u.elementType===y?E:ts(y,E),gh(a,u,y,E,p);case 1:return y=u.type,E=u.pendingProps,E=u.elementType===y?E:ts(y,E),d0(a,u,y,E,p);case 3:e:{if(f0(u),a===null)throw Error(n(387));y=u.pendingProps,C=u.memoizedState,E=C.element,_b(a,u),wc(u,y,null,p);var O=u.memoizedState;if(y=O.element,C.isDehydrated)if(C={element:y,isDehydrated:!1,cache:O.cache,pendingSuspenseBoundaries:O.pendingSuspenseBoundaries,transitions:O.transitions},u.updateQueue.baseState=C,u.memoizedState=C,u.flags&256){E=Ho(Error(n(423)),u),u=h0(a,u,y,p,E);break e}else if(y!==E){E=Ho(Error(n(424)),u),u=h0(a,u,y,p,E);break e}else for(Tr=ei(u.stateNode.containerInfo.firstChild),_r=u,ln=!0,es=null,p=Nb(u,null,y,p),u.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Bo(),y===E){u=Ls(a,u,p);break e}ur(a,u,y,p)}u=u.child}return u;case 5:return Mb(u),a===null&&qf(u),y=u.type,E=u.pendingProps,C=a!==null?a.memoizedProps:null,O=E.children,Pf(y,E)?O=null:C!==null&&Pf(y,C)&&(u.flags|=32),u0(a,u),ur(a,u,O,p),u.child;case 6:return a===null&&qf(u),null;case 13:return p0(a,u,p);case 4:return eh(u,u.stateNode.containerInfo),y=u.pendingProps,a===null?u.child=$o(u,null,y,p):ur(a,u,y,p),u.child;case 11:return y=u.type,E=u.pendingProps,E=u.elementType===y?E:ts(y,E),o0(a,u,y,E,p);case 7:return ur(a,u,u.pendingProps,p),u.child;case 8:return ur(a,u,u.pendingProps.children,p),u.child;case 12:return ur(a,u,u.pendingProps.children,p),u.child;case 10:e:{if(y=u.type._context,E=u.pendingProps,C=u.memoizedProps,O=E.value,en(yc,y._currentValue),y._currentValue=O,C!==null)if(Zr(C.value,O)){if(C.children===E.children&&!gr.current){u=Ls(a,u,p);break e}}else for(C=u.child,C!==null&&(C.return=u);C!==null;){var H=C.dependencies;if(H!==null){O=C.child;for(var X=H.firstContext;X!==null;){if(X.context===y){if(C.tag===1){X=Is(-1,p&-p),X.tag=2;var ue=C.updateQueue;if(ue!==null){ue=ue.shared;var Te=ue.pending;Te===null?X.next=X:(X.next=Te.next,Te.next=X),ue.pending=X}}C.lanes|=p,X=C.alternate,X!==null&&(X.lanes|=p),Xf(C.return,p,u),H.lanes|=p;break}X=X.next}}else if(C.tag===10)O=C.type===u.type?null:C.child;else if(C.tag===18){if(O=C.return,O===null)throw Error(n(341));O.lanes|=p,H=O.alternate,H!==null&&(H.lanes|=p),Xf(O,p,u),O=C.sibling}else O=C.child;if(O!==null)O.return=C;else for(O=C;O!==null;){if(O===u){O=null;break}if(C=O.sibling,C!==null){C.return=O.return,O=C;break}O=O.return}C=O}ur(a,u,E.children,p),u=u.child}return u;case 9:return E=u.type,y=u.pendingProps.children,zo(u,p),E=$r(E),y=y(E),u.flags|=1,ur(a,u,y,p),u.child;case 14:return y=u.type,E=ts(y,u.pendingProps),E=ts(y.type,E),a0(a,u,y,E,p);case 15:return l0(a,u,u.type,u.pendingProps,p);case 17:return y=u.type,E=u.pendingProps,E=u.elementType===y?E:ts(y,E),Mc(a,u),u.tag=1,vr(y)?(a=!0,fc(u)):a=!1,zo(u,p),Zb(u,y,E),hh(u,y,E,p),vh(null,u,y,!0,a,p);case 19:return g0(a,u,p);case 22:return c0(a,u,p)}throw Error(n(156,u.tag))};function F0(a,u){return lr(a,u)}function dM(a,u,p,y){this.tag=a,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=y,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ur(a,u,p,y){return new dM(a,u,p,y)}function Ph(a){return a=a.prototype,!(!a||!a.isReactComponent)}function fM(a){if(typeof a=="function")return Ph(a)?1:0;if(a!=null){if(a=a.$$typeof,a===F)return 11;if(a===W)return 14}return 2}function di(a,u){var p=a.alternate;return p===null?(p=Ur(a.tag,u,a.key,a.mode),p.elementType=a.elementType,p.type=a.type,p.stateNode=a.stateNode,p.alternate=a,a.alternate=p):(p.pendingProps=u,p.type=a.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=a.flags&14680064,p.childLanes=a.childLanes,p.lanes=a.lanes,p.child=a.child,p.memoizedProps=a.memoizedProps,p.memoizedState=a.memoizedState,p.updateQueue=a.updateQueue,u=a.dependencies,p.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},p.sibling=a.sibling,p.index=a.index,p.ref=a.ref,p}function zc(a,u,p,y,E,C){var O=2;if(y=a,typeof a=="function")Ph(a)&&(O=1);else if(typeof a=="string")O=5;else e:switch(a){case I:return Zi(p.children,E,C,u);case $:O=8,E|=8;break;case P:return a=Ur(12,p,u,E|2),a.elementType=P,a.lanes=C,a;case G:return a=Ur(13,p,u,E),a.elementType=G,a.lanes=C,a;case B:return a=Ur(19,p,u,E),a.elementType=B,a.lanes=C,a;case ne:return Uc(p,E,C,u);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case z:O=10;break e;case q:O=9;break e;case F:O=11;break e;case W:O=14;break e;case K:O=16,y=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return u=Ur(O,p,u,E),u.elementType=a,u.type=y,u.lanes=C,u}function Zi(a,u,p,y){return a=Ur(7,a,y,u),a.lanes=p,a}function Uc(a,u,p,y){return a=Ur(22,a,y,u),a.elementType=ne,a.lanes=p,a.stateNode={isHidden:!1},a}function Bh(a,u,p){return a=Ur(6,a,null,u),a.lanes=p,a}function $h(a,u,p){return u=Ur(4,a.children!==null?a.children:[],a.key,u),u.lanes=p,u.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},u}function hM(a,u,p,y,E){this.tag=u,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Kt(0),this.expirationTimes=Kt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kt(0),this.identifierPrefix=y,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function Fh(a,u,p,y,E,C,O,H,X){return a=new hM(a,u,p,H,X),u===1?(u=1,C===!0&&(u|=8)):u=0,C=Ur(3,null,null,u),a.current=C,C.stateNode=a,C.memoizedState={element:y,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Zf(C),a}function pM(a,u,p){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:y==null?null:""+y,children:a,containerInfo:u,implementation:p}}function z0(a){if(!a)return ni;a=a._reactInternals;e:{if(Vt(a)!==a||a.tag!==1)throw Error(n(170));var u=a;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(vr(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(a.tag===1){var p=a.type;if(vr(p))return mb(a,p,u)}return u}function U0(a,u,p,y,E,C,O,H,X){return a=Fh(p,y,!0,a,E,C,O,H,X),a.context=z0(null),p=a.current,y=dr(),E=ci(p),C=Is(y,E),C.callback=u??null,ii(p,C,E),a.current.lanes=E,Rn(a,E,y),xr(a,y),a}function Hc(a,u,p,y){var E=u.current,C=dr(),O=ci(E);return p=z0(p),u.context===null?u.context=p:u.pendingContext=p,u=Is(C,O),u.payload={element:a},y=y===void 0?null:y,y!==null&&(u.callback=y),a=ii(E,u,O),a!==null&&(ss(a,E,O,C),xc(a,E,O)),O}function Wc(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function H0(a,u){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var p=a.retryLane;a.retryLane=p!==0&&p<u?p:u}}function zh(a,u){H0(a,u),(a=a.alternate)&&H0(a,u)}function mM(){return null}var W0=typeof reportError=="function"?reportError:function(a){console.error(a)};function Uh(a){this._internalRoot=a}Vc.prototype.render=Uh.prototype.render=function(a){var u=this._internalRoot;if(u===null)throw Error(n(409));Hc(a,u,null,null)},Vc.prototype.unmount=Uh.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var u=a.containerInfo;Yi(function(){Hc(null,a,null,null)}),u[js]=null}};function Vc(a){this._internalRoot=a}Vc.prototype.unstable_scheduleHydration=function(a){if(a){var u=Fi();a={blockedOn:null,target:a,priority:u};for(var p=0;p<On.length&&u!==0&&u<On[p].priority;p++);On.splice(p,0,a),p===0&&My(a)}};function Hh(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function qc(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function V0(){}function gM(a,u,p,y,E){if(E){if(typeof y=="function"){var C=y;y=function(){var ue=Wc(O);C.call(ue)}}var O=U0(u,y,a,0,null,!1,!1,"",V0);return a._reactRootContainer=O,a[js]=O.current,Ra(a.nodeType===8?a.parentNode:a),Yi(),O}for(;E=a.lastChild;)a.removeChild(E);if(typeof y=="function"){var H=y;y=function(){var ue=Wc(X);H.call(ue)}}var X=Fh(a,0,!1,null,null,!1,!1,"",V0);return a._reactRootContainer=X,a[js]=X.current,Ra(a.nodeType===8?a.parentNode:a),Yi(function(){Hc(u,X,p,y)}),X}function Kc(a,u,p,y,E){var C=p._reactRootContainer;if(C){var O=C;if(typeof E=="function"){var H=E;E=function(){var X=Wc(O);H.call(X)}}Hc(u,O,a,E)}else O=gM(p,u,a,E,y);return Wc(O)}xa=function(a){switch(a.tag){case 3:var u=a.stateNode;if(u.current.memoizedState.isDehydrated){var p=De(u.pendingLanes);p!==0&&(ba(u,p|1),xr(u,Bt()),(Ft&6)===0&&(qo=Bt()+500,ri()))}break;case 13:Yi(function(){var y=Os(a,1);if(y!==null){var E=dr();ss(y,a,1,E)}}),zh(a,1)}},wn=function(a){if(a.tag===13){var u=Os(a,134217728);if(u!==null){var p=dr();ss(u,a,134217728,p)}zh(a,134217728)}},Yt=function(a){if(a.tag===13){var u=ci(a),p=Os(a,u);if(p!==null){var y=dr();ss(p,a,u,y)}zh(a,u)}},Fi=function(){return $t},ms=function(a,u){var p=$t;try{return $t=a,u()}finally{$t=p}},We=function(a,u,p){switch(u){case"input":if(vt(a,p),u=p.name,p.type==="radio"&&u!=null){for(p=a;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<p.length;u++){var y=p[u];if(y!==a&&y.form===a.form){var E=uc(y);if(!E)throw Error(n(90));Re(y),vt(y,E)}}}break;case"textarea":te(a,p);break;case"select":u=p.value,u!=null&&ot(a,!!p.multiple,u,!1)}},ie=Ih,D=Yi;var vM={usingClientEntryPoint:!1,Events:[La,Oo,uc,j,U,Ih]},Ja={findFiberByHostInstance:Ui,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},yM={bundleType:Ja.bundleType,version:Ja.version,rendererPackageName:Ja.rendererPackageName,rendererConfig:Ja.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:M.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Xt(a),a===null?null:a.stateNode},findFiberByHostInstance:Ja.findFiberByHostInstance||mM,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 Gc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Gc.isDisabled&&Gc.supportsFiber)try{Ct=Gc.inject(yM),Mt=Gc}catch{}}return wr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vM,wr.createPortal=function(a,u){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Hh(u))throw Error(n(200));return pM(a,u,null,p)},wr.createRoot=function(a,u){if(!Hh(a))throw Error(n(299));var p=!1,y="",E=W0;return u!=null&&(u.unstable_strictMode===!0&&(p=!0),u.identifierPrefix!==void 0&&(y=u.identifierPrefix),u.onRecoverableError!==void 0&&(E=u.onRecoverableError)),u=Fh(a,1,!1,null,null,p,!1,y,E),a[js]=u.current,Ra(a.nodeType===8?a.parentNode:a),new Uh(u)},wr.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var u=a._reactInternals;if(u===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=Xt(u),a=a===null?null:a.stateNode,a},wr.flushSync=function(a){return Yi(a)},wr.hydrate=function(a,u,p){if(!qc(u))throw Error(n(200));return Kc(null,a,u,!0,p)},wr.hydrateRoot=function(a,u,p){if(!Hh(a))throw Error(n(405));var y=p!=null&&p.hydratedSources||null,E=!1,C="",O=W0;if(p!=null&&(p.unstable_strictMode===!0&&(E=!0),p.identifierPrefix!==void 0&&(C=p.identifierPrefix),p.onRecoverableError!==void 0&&(O=p.onRecoverableError)),u=U0(u,null,a,1,p??null,E,!1,C,O),a[js]=u.current,Ra(a),y)for(a=0;a<y.length;a++)p=y[a],E=p._getVersion,E=E(p._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[p,E]:u.mutableSourceEagerHydrationData.push(p,E);return new Vc(u)},wr.render=function(a,u,p){if(!qc(u))throw Error(n(200));return Kc(null,a,u,!1,p)},wr.unmountComponentAtNode=function(a){if(!qc(a))throw Error(n(40));return a._reactRootContainer?(Yi(function(){Kc(null,null,a,!1,function(){a._reactRootContainer=null,a[js]=null})}),!0):!1},wr.unstable_batchedUpdates=Ih,wr.unstable_renderSubtreeIntoContainer=function(a,u,p,y){if(!qc(p))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Kc(a,u,p,!1,y)},wr.version="18.3.1-next-f1338f8080-20240426",wr}var ex;function TE(){if(ex)return qh.exports;ex=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(),qh.exports=NM(),qh.exports}var tx;function CM(){if(tx)return Jc;tx=1;var t=TE();return Jc.createRoot=t.createRoot,Jc.hydrateRoot=t.hydrateRoot,Jc}var _M=CM();const TM=Il(_M),jE=[{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"}],ME=[{id:"files",label:"Files",icon:"files"},{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"}],AE=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],RE=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],jM=["full","compact","minimal"],Jn={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"},MM={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function AM(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(Jn.typeface)){const n=MM[t];n&&localStorage.setItem(Jn.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(Jn.spacing)&&(localStorage.setItem(Jn.spacing,e),localStorage.removeItem("ow-typography"))}function OE(){const t=localStorage.getItem(Jn.typeface);return t&&jE.some(e=>e.id===t)?t:"charter"}function IE(){const t=localStorage.getItem(Jn.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function $d(){const t=localStorage.getItem(Jn.sidebarMode);return t&&ME.some(e=>e.id===t)?t:"files"}function LE(){return"cards"}function DE(){const t=localStorage.getItem(Jn.sidebarDensity);return t&&jM.includes(t)?t:"full"}function RM(t){localStorage.setItem(Jn.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function PE(){const t=localStorage.getItem(Jn.spacing);return t&&RE.some(e=>e.id===t)?t:"default"}function BE(){const t=localStorage.getItem(Jn.canvas);return t&&AE.some(e=>e.id===t)?t:"seamless"}function $E(t,e,n,r,s="default",i="seamless"){const o=document.documentElement;o.setAttribute("data-typeface",t),o.setAttribute("data-mode",e),o.setAttribute("data-sidebar-mode",n),o.setAttribute("data-sidebar-style",r),s==="default"?o.removeAttribute("data-spacing"):o.setAttribute("data-spacing",s),i==="seamless"?o.removeAttribute("data-canvas"):o.setAttribute("data-canvas",i),o.removeAttribute("data-color"),localStorage.setItem(Jn.typeface,t),localStorage.setItem(Jn.mode,e),localStorage.setItem(Jn.sidebarMode,n),localStorage.setItem(Jn.sidebarStyle,r),localStorage.setItem(Jn.spacing,s),localStorage.setItem(Jn.canvas,i)}function OM(){AM(),$E(OE(),IE(),$d(),LE(),PE(),BE()),document.documentElement.setAttribute("data-sidebar-density",DE())}const FE="ow-right-rail",hg=280,IM=220,LM=520,zE=b.createContext(null);function DM(){const t={open:!0,activeTab:"activity",width:hg};try{const e=localStorage.getItem(FE);if(!e)return t;const n=JSON.parse(e);return{open:!!n.open,activeTab:n.activeTab??null,width:UE(typeof n.width=="number"?n.width:hg)}}catch{return t}}function UE(t){return Number.isFinite(t)?Math.max(IM,Math.min(LM,t)):hg}function PM({children:t}){const[e,n]=b.useState(()=>DM()),[r,s]=b.useState(!1),[i,o]=b.useState(!1),l=b.useRef(r);l.current=r,b.useEffect(()=>{try{localStorage.setItem(FE,JSON.stringify(e))}catch{}},[e]);const d=b.useCallback(k=>{l.current?(o(!0),n(w=>({...w,activeTab:k}))):n(w=>({...w,open:!0,activeTab:k}))},[]),f=b.useCallback(()=>{l.current?o(!1):n(k=>({...k,open:!1}))},[]),h=b.useCallback(()=>{l.current?o(k=>!k):n(k=>({...k,open:!k.open}))},[]),m=b.useCallback(k=>{n(w=>({...w,width:UE(k)}))},[]),g=b.useCallback(k=>{s(w=>w===k?w:(o(!1),k))},[]),v=r?i:e.open,x=b.useMemo(()=>({...e,overlay:r,drawerOpen:i,visible:v,openTab:d,closeRail:f,toggleRail:h,setWidth:m,setOverlay:g}),[e,r,i,v,d,f,h,m,g]);return c.jsx(zE.Provider,{value:x,children:t})}function Dl(){const t=b.useContext(zE);if(!t)throw new Error("useRightRail must be used inside <RightRailProvider>");return t}var HE=TE();const BM=Il(HE);var Jh={exports:{}},Yh={};/**
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 nx;function $M(){if(nx)return Yh;nx=1;var t=Ll();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(m,g){var v=g(),x=r({inst:{value:v,getSnapshot:g}}),k=x[0].inst,w=x[1];return i(function(){k.value=v,k.getSnapshot=g,d(k)&&w({inst:k})},[m,v,g]),s(function(){return d(k)&&w({inst:k}),m(function(){d(k)&&w({inst:k})})},[m]),o(v),v}function d(m){var g=m.getSnapshot;m=m.value;try{var v=g();return!n(m,v)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return Yh.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,Yh}var rx;function WE(){return rx||(rx=1,Jh.exports=$M()),Jh.exports}var VE=WE();function Gn(t){this.content=t}Gn.prototype={constructor:Gn,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Gn(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Gn(n)},addToStart:function(t,e){return new Gn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Gn(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Gn(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Gn.from(t),t.size?new Gn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Gn.from(t),t.size?new Gn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Gn.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}};Gn.from=function(t){if(t instanceof Gn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Gn(e)};function qE(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=qE(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function KE(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),d=o.nodeSize;if(o==l){n-=d,r-=d;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let f=0,h=Math.min(o.text.length,l.text.length);for(;f<h&&o.text[o.text.length-f-1]==l.text[l.text.length-f-1];)f++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let f=KE(o.content,l.content,n-1,r-1);if(f)return f}n-=d,r-=d}}class we{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let d=this.content[o],f=l+d.nodeSize;if(f>e&&r(d,s+l,i||null,o)!==!1&&d.content.size){let h=l+1;d.nodesBetween(Math.max(0,e-h),Math.min(d.content.size,n-h),r,s+h)}l=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,d)=>{let f=l.isText?l.text.slice(Math.max(e,d)-d,n-d):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&f||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=f},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new we(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],d=o+l.nodeSize;d>e&&((o<e||d>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=d}return new we(r,s)}cutByIndex(e,n){return e==n?we.empty:e==0&&n==this.content.length?this:new we(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new we(s,i)}addToStart(e){return new we([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new we(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return qE(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return KE(this,e,n,r)}findIndex(e){if(e==0)return Yc(0,e);if(e==this.size)return Yc(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Yc(n+1,i):Yc(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return we.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new we(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return we.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new we(n||e,r)}static from(e){if(!e)return we.empty;if(e instanceof we)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new we([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}we.empty=new we([],0);const Xh={index:0,offset:0};function Yc(t,e){return Xh.index=t,Xh.offset=e,Xh}function zu(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(!zu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!zu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Zt=class pg{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&zu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return pg.none;if(e instanceof pg)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Zt.none=[];class Uu extends Error{}class Ue{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=JE(this.content,e+this.openStart,n);return r&&new Ue(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ue(GE(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 Ue.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ue(we.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Ue(e,r,s)}}Ue.empty=new Ue(we.empty,0,0);function GE(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(GE(i.content,e-s-1,n-s-1)))}function JE(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=JE(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function FM(t,e,n){if(n.openStart>t.depth)throw new Uu("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Uu("Inconsistent open depths");return YE(t,e,n,0)}function YE(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=YE(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return co(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=zM(n,t);return co(i,QE(t,o,l,e,r))}else return co(i,Hu(t,e,r))}function XE(t,e){if(!e.type.compatibleContent(t.type))throw new Uu("Cannot join "+e.type.name+" onto "+t.type.name)}function mg(t,e,n){let r=t.node(n);return XE(r,e.node(n)),r}function lo(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 ul(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(lo(t.nodeAfter,r),i++));for(let l=i;l<o;l++)lo(s.child(l),r);e&&e.depth==n&&e.textOffset&&lo(e.nodeBefore,r)}function co(t,e){return t.type.checkContent(e),t.copy(e)}function QE(t,e,n,r,s){let i=t.depth>s&&mg(t,e,s+1),o=r.depth>s&&mg(n,r,s+1),l=[];return ul(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(XE(i,o),lo(co(i,QE(t,e,n,r,s+1)),l)):(i&&lo(co(i,Hu(t,e,s+1)),l),ul(e,n,s,l),o&&lo(co(o,Hu(n,r,s+1)),l)),ul(r,null,s,l),new we(l)}function Hu(t,e,n){let r=[];if(ul(null,t,n,r),t.depth>n){let s=mg(t,e,n+1);lo(co(s,Hu(t,e,n+1)),r)}return ul(e,null,n,r),new we(r)}function zM(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(we.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class wl{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Zt.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Wu(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:d}=o.content.findIndex(i),f=i-d;if(r.push(o,l,s+d),!f||(o=o.child(l),o.isText))break;i=f-1,s+=d+1}return new wl(n,r,i)}static resolveCached(e,n){let r=sx.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else sx.set(e,r=new UM);let s=r.elts[r.i]=wl.resolve(e,n);return r.i=(r.i+1)%HM,s}}class UM{constructor(){this.elts=[],this.i=0}}const HM=12,sx=new WeakMap;class Wu{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 WM=Object.create(null);class ls{constructor(e,n,r,s=Zt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||we.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&zu(this.attrs,n||e.defaultAttrs||WM)&&Zt.sameSet(this.marks,r||Zt.none)}copy(e=null){return e==this.content?this:new ls(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ls(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 Ue.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),f=s.node(o).content.cut(s.pos-l,i.pos-l);return new Ue(f,s.depth-o,i.depth-o)}replace(e,n,r){return FM(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return wl.resolveCached(this,e)}resolveNoCache(e){return wl.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ZE(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=we.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let d=s;d<i;d++)if(!this.type.allowsMarks(r.child(d).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Zt.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(!Zt.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=we.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}ls.prototype.text=void 0;class Vu extends ls{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ZE(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 Vu(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Vu(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 ZE(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class po{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new VM(e,n);if(r.next==null)return po.empty;let s=eN(r);r.next&&r.err("Unexpected trailing text");let i=QM(XM(s));return ZM(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let d=o.matchFragment(e,r);if(d&&(!n||d.validEnd))return we.from(l.map(f=>f.createAndFill()));for(let f=0;f<o.next.length;f++){let{type:h,next:m}=o.next[f];if(!(h.isText||h.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let g=i(m,l.concat(h));if(g)return g}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:d}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||d.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
49
- `)}}po.empty=new po(!0);class VM{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function eN(t){let e=[];do e.push(qM(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function qM(t){let e=[];do e.push(KM(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function KM(t){let e=YM(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=GM(t,e);else break;return e}function ix(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function GM(t,e){let n=ix(t),r=n;return t.eat(",")&&(t.next!="}"?r=ix(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function JM(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function YM(t){if(t.eat("(")){let e=eN(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=JM(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 XM(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,d){let f={term:d,to:l};return e[o].push(f),f}function s(o,l){o.forEach(d=>d.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((d,f)=>d.concat(i(f,l)),[]);if(o.type=="seq")for(let d=0;;d++){let f=i(o.exprs[d],l);if(d==o.exprs.length-1)return f;s(f,l=n())}else if(o.type=="star"){let d=n();return r(l,d),s(i(o.expr,d),d),[r(d)]}else if(o.type=="plus"){let d=n();return s(i(o.expr,l),d),s(i(o.expr,d),d),[r(d)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let d=l;for(let f=0;f<o.min;f++){let h=n();s(i(o.expr,d),h),d=h}if(o.max==-1)s(i(o.expr,d),d);else for(let f=o.min;f<o.max;f++){let h=n();r(d,h),s(i(o.expr,d),h),d=h}return[r(d)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function tN(t,e){return e-t}function ox(t,e){let n=[];return r(e),n.sort(tN);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:d}=i[o];!l&&n.indexOf(d)==-1&&r(d)}}}function QM(t){let e=Object.create(null);return n(ox(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:d})=>{if(!l)return;let f;for(let h=0;h<s.length;h++)s[h][0]==l&&(f=s[h][1]);ox(t,d).forEach(h=>{f||s.push([l,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let i=e[r.join(",")]=new po(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(tN);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function ZM(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:d,next:f}=s.next[l];o.push(d.name),i&&!(d.isText||d.hasRequiredAttrs())&&(i=!1),r.indexOf(f)==-1&&r.push(f)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function nN(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 rN(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function sN(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function iN(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new tA(t,r,e[r]);return n}let ax=class oN{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=iN(e,r.attrs),this.defaultAttrs=nN(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==po.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:rN(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ls(this,this.computeAttrs(e),we.from(n),Zt.setFrom(r))}createChecked(e=null,n,r){return n=we.from(n),this.checkContent(n),new ls(this,this.computeAttrs(e),n,Zt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=we.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(we.empty,!0);return i?new ls(this,e,n.append(i),Zt.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){sN(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:Zt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new oN(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function eA(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class tA{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?eA(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Fd{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=iN(e,s.attrs),this.excluded=null;let i=nN(this.attrs);this.instance=i?new Zt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Zt(this,rN(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Fd(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){sN(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class aN{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Gn.from(e.nodes),n.marks=Gn.from(e.marks||{}),this.nodes=ax.compile(this.spec.nodes,this),this.marks=Fd.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=po.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?lx(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:lx(this,o.split(" "))}this.nodeFromJSON=s=>ls.fromJSON(this,s),this.markFromJSON=s=>Zt.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ax){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Vu(r,r.defaultAttrs,e,Zt.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 lx(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let d=t.marks[l];(s=="_"||d.spec.group&&d.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=d)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function nA(t){return t.tag!=null}function rA(t){return t.style!=null}let dl=class gg{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(nA(s))this.tags.push(s);else if(rA(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new ux(this,n,!1);return r.addAll(e,Zt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ux(this,n,!0);return r.addAll(e,Zt.none,n.from,n.to),Ue.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(oA(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let d=o.getAttrs(n);if(d===!1)continue;o.attrs=d||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=dx(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=dx(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new gg(e,gg.schemaRules(e)))}};const lN={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},sA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cN={ol:!0,ul:!0},kl=1,vg=2,fl=4;function cx(t,e,n){return e!=null?(e?kl:0)|(e==="full"?vg:0):t&&t.whitespace=="pre"?kl|vg:n&~fl}class Xc{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Zt.none,this.match=i||(o&fl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(we.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&kl)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=we.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(we.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&&!lN.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ux{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=cx(null,n.preserveWhitespace,0)|(r?fl:0);s?i=new Xc(s.type,s.attrs,Zt.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Xc(null,null,Zt.none,!0,null,o):i=new Xc(e.schema.topNodeType,null,Zt.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&vg?"full":this.localPreserveWS||(s.options&kl)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
50
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let d=0;d<l.length;d++)d&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[d]&&this.insertNode(o.text(l[d]),n,!/\S/.test(l[d]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],d=e.previousSibling;(!l||d&&d.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;cN.hasOwnProperty(o)&&this.parser.normalizeLists&&iA(e);let d=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(d?d.ignore:sA.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!d||d.skip||d.closeParent){d&&d.closeParent?this.open=Math.max(0,this.open-1):d&&d.skip.nodeType&&(e=d.skip);let f,h=this.needsBlock;if(lN.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),f=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let m=d&&d.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),f&&this.sync(i),this.needsBlock=h}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,d,f,d.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
51
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let d=this.parser.matchStyle(i,o,this,l);if(!d)break;if(d.ignore)return null;if(d.clearMark?n=n.filter(f=>!d.clearMark(f)):n=n.concat(this.parser.schema.marks[d.mark].create(d.attrs)),d.consuming===!1)l=d;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let d=this.enter(o,n.attrs||null,r,n.preserveWhitespace);d&&(i=!0,r=d)}else{let d=this.parser.schema.marks[n.mark];r=r.concat(d.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(d=>this.insertNode(d,r,!1));else{let d=e;typeof n.contentElement=="string"?d=e.querySelector(n.contentElement):typeof n.contentElement=="function"?d=n.contentElement(e):n.contentElement&&(d=n.contentElement),this.findAround(e,d,!0),this.addAll(d,r),this.findAround(e,d,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let d=this.nodes[o],f=d.findWrapping(e);if(f&&(!s||s.length>f.length+l)&&(s=f,i=d,!f.length))break;if(d.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Zt.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):fx(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=cx(e,i,o.options);o.options&fl&&o.content.length==0&&(l|=fl);let d=Zt.none;return r=r.filter(f=>(o.type?o.type.allowsMarkType(f.type):fx(f.type,e))?(d=f.addToSet(d),!1):!0),this.nodes.push(new Xc(e,n,d,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=kl)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,d)=>{for(;l>=0;l--){let f=n[l];if(f==""){if(l==n.length-1||l==0)continue;for(;d>=i;d--)if(o(l-1,d))return!0;return!1}else{let h=d>0||d==0&&s?this.nodes[d].type:r&&d>=i?r.node(d-i).type:null;if(!h||h.name!=f&&!h.isInGroup(f))return!1;d--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function iA(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&cN.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function oA(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function dx(t){let e={};for(let n in t)e[n]=t[n];return e}function fx(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let d=0;d<l.edgeCount;d++){let{type:f,next:h}=l.edge(d);if(f==e||i.indexOf(h)<0&&o(h))return!0}};if(o(s.contentMatch))return!0}}class wo{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Qh(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,d=0;for(;l<i.length&&d<o.marks.length;){let f=o.marks[d];if(!this.marks[f.type.name]){d++;continue}if(!f.eq(i[l][0])||f.type.spec.spanning===!1)break;l++,d++}for(;l<i.length;)s=i.pop()[1];for(;d<o.marks.length;){let f=o.marks[d++],h=this.serializeMark(f,o.isInline,n);h&&(i.push([f,s]),s.appendChild(h.dom),s=h.contentDOM||h.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Ru(Qh(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Ru(Qh(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Ru(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new wo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hx(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hx(e.marks)}}function hx(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Qh(t){return t.document||window.document}const px=new WeakMap;function aA(t){let e=px.get(t);return e===void 0&&px.set(t,e=lA(t)),e}function lA(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Ru(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=aA(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,d=n?t.createElementNS(n,s):t.createElement(s),f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let m in f)if(f[m]!=null){let g=m.indexOf(" ");g>0?d.setAttributeNS(m.slice(0,g),m.slice(g+1),f[m]):m=="style"&&d.style?d.style.cssText=f[m]:d.setAttribute(m,f[m])}}for(let m=h;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:d,contentDOM:d}}else{let{dom:v,contentDOM:x}=Ru(t,g,n,r);if(d.appendChild(v),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:d,contentDOM:l}}const uN=65535,dN=Math.pow(2,16);function cA(t,e){return t+e*dN}function mx(t){return t&uN}function uA(t){return(t-(t&uN))/dN}const fN=1,hN=2,Ou=4,pN=8;class yg{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&pN)>0}get deletedBefore(){return(this.delInfo&(fN|Ou))>0}get deletedAfter(){return(this.delInfo&(hN|Ou))>0}get deletedAcross(){return(this.delInfo&Ou)>0}}class Mr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Mr.empty)return Mr.empty}recover(e){let n=0,r=mx(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+uA(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let d=this.ranges[l]-(this.inverted?s:0);if(d>e)break;let f=this.ranges[l+i],h=this.ranges[l+o],m=d+f;if(e<=m){let g=f?e==d?-1:e==m?1:n:n,v=d+s+(g<0?0:h);if(r)return v;let x=e==(n<0?d:m)?null:cA(l/3,e-d),k=e==d?hN:e==m?fN:Ou;return(n<0?e!=d:e!=m)&&(k|=pN),new yg(v,k,x)}s+=h-f}return r?e+s:new yg(e+s,0,null)}touches(e,n){let r=0,s=mx(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let d=this.ranges[l]-(this.inverted?r:0);if(d>e)break;let f=this.ranges[l+i],h=d+f;if(e<=h&&l==s*3)return!0;r+=this.ranges[l+o]-f}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),d=o+(this.inverted?0:i),f=this.ranges[s+n],h=this.ranges[s+r];e(l,l+f,d,d+h),i+=h-f}}invert(){return new Mr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Mr.empty:new Mr(e<0?[0,-e,0]:[0,0,e])}}Mr.empty=new Mr([]);class Sl{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Sl(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Sl;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let d=this.getMirror(i);if(d!=null&&d>i&&d<this.to){i=d,e=this._maps[d].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new yg(e,s,null)}}const Zh=Object.create(null);class ar{getMap(){return Mr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Zh[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 Zh)throw new RangeError("Duplicate use of step JSON ID "+e);return Zh[e]=n,n.prototype.jsonID=e,n}}class _n{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new _n(e,null)}static fail(e){return new _n(null,e)}static fromReplace(e,n,r,s){try{return _n.ok(e.replace(n,r,s))}catch(i){if(i instanceof Uu)return _n.fail(i.message);throw i}}}function iv(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(iv(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return we.fromArray(r)}class Si extends ar{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new Ue(iv(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return _n.fromReplace(e,this.from,this.to,i)}invert(){return new as(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 Si(n.pos,r.pos,this.mark)}merge(e){return e instanceof Si&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Si(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 Si(n.from,n.to,e.markFromJSON(n.mark))}}ar.jsonID("addMark",Si);class as extends ar{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 Ue(iv(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return _n.fromReplace(e,this.from,this.to,r)}invert(){return new Si(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 as(n.pos,r.pos,this.mark)}merge(e){return e instanceof as&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new as(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 as(n.from,n.to,e.markFromJSON(n.mark))}}ar.jsonID("removeMark",as);class Ei extends ar{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return _n.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return _n.fromReplace(e,this.pos,this.pos+1,new Ue(we.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Ei(this.pos,n.marks[s]);return new Ei(this.pos,this.mark)}}return new mo(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ei(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 Ei(n.pos,e.markFromJSON(n.mark))}}ar.jsonID("addNodeMark",Ei);class mo extends ar{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return _n.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return _n.fromReplace(e,this.pos,this.pos+1,new Ue(we.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Ei(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new mo(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 mo(n.pos,e.markFromJSON(n.mark))}}ar.jsonID("removeNodeMark",mo);class Pn extends ar{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&bg(e,this.from,this.to)?_n.fail("Structure replace would overwrite content"):_n.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Mr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Pn(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 Pn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Pn)||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?Ue.empty:new Ue(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Pn(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?Ue.empty:new Ue(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Pn(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 Pn(n.from,n.to,Ue.fromJSON(e,n.slice),!!n.structure)}}ar.jsonID("replace",Pn);class Bn extends ar{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(bg(e,this.from,this.gapFrom)||bg(e,this.gapTo,this.to)))return _n.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return _n.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?_n.fromReplace(e,this.from,this.to,r):_n.fail("Content does not fit in gap")}getMap(){return new Mr([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 Bn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Bn(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Bn(n.from,n.to,n.gapFrom,n.gapTo,Ue.fromJSON(e,n.slice),n.insert,!!n.structure)}}ar.jsonID("replaceAround",Bn);function bg(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function dA(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(d,f,h)=>{if(!d.isInline)return;let m=d.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let g=Math.max(f,e),v=Math.min(f+d.nodeSize,n),x=r.addToSet(m);for(let k=0;k<m.length;k++)m[k].isInSet(x)||(o&&o.to==g&&o.mark.eq(m[k])?o.to=v:s.push(o=new as(g,v,m[k])));l&&l.to==g?l.to=v:i.push(l=new Si(g,v,r))}}),s.forEach(d=>t.step(d)),i.forEach(d=>t.step(d))}function fA(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let d=null;if(r instanceof Fd){let f=o.marks,h;for(;h=r.isInSet(f);)(d||(d=[])).push(h),f=h.removeFromSet(f)}else r?r.isInSet(o.marks)&&(d=[r]):d=o.marks;if(d&&d.length){let f=Math.min(l+o.nodeSize,n);for(let h=0;h<d.length;h++){let m=d[h],g;for(let v=0;v<s.length;v++){let x=s[v];x.step==i-1&&m.eq(s[v].style)&&(g=x)}g?(g.to=f,g.step=i):s.push({style:m,from:Math.max(l,e),to:f,step:i})}}}),s.forEach(o=>t.step(new as(o.from,o.to,o.style)))}function ov(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let d=0;d<i.childCount;d++){let f=i.child(d),h=l+f.nodeSize,m=r.matchType(f.type);if(!m)o.push(new Pn(l,h,Ue.empty));else{r=m;for(let g=0;g<f.marks.length;g++)n.allowsMarkType(f.marks[g].type)||t.step(new as(l,h,f.marks[g]));if(s&&f.isText&&n.whitespace!="pre"){let g,v=/\r?\n|\r/g,x;for(;g=v.exec(f.text);)x||(x=new Ue(we.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),o.push(new Pn(l+g.index,l+g.index+g[0].length,x))}}l=h}if(!r.validEnd){let d=r.fillBefore(we.empty,!0);t.replace(l,l,new Ue(d,0,0))}for(let d=o.length-1;d>=0;d--)t.step(o[d])}function hA(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function va(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,d=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,d,n))return r;if(r==0||o.type.spec.isolating||!hA(o,l,d))break;l&&(s=1),d<o.childCount&&(i=1)}return null}function pA(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),d=o,f=l,h=we.empty,m=0;for(let x=i,k=!1;x>n;x--)k||r.index(x)>0?(k=!0,h=we.from(r.node(x).copy(h)),m++):d--;let g=we.empty,v=0;for(let x=i,k=!1;x>n;x--)k||s.after(x+1)<s.end(x)?(k=!0,g=we.from(s.node(x).copy(g)),v++):f++;t.step(new Bn(d,f,o,l,new Ue(h.append(g),m,v),h.size-m,!0))}function av(t,e,n=null,r=t){let s=mA(t,e),i=s&&gA(r,e);return i?s.map(gx).concat({type:e,attrs:n}).concat(i.map(gx)):null}function gx(t){return{type:t,attrs:null}}function mA(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function gA(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let d=(o.length?o[o.length-1]:e).contentMatch;for(let f=r;d&&f<s;f++)d=d.matchType(n.child(f).type);return!d||!d.validEnd?null:o}function vA(t,e,n){let r=we.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=we.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Bn(s,i,s,i,new Ue(r,0,0),n.length,!0))}function yA(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let d=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,d)&&bA(t.doc,t.mapping.slice(i).map(l),r)){let f=null;if(r.schema.linebreakReplacement){let v=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);v&&!x?f=!1:!v&&x&&(f=!0)}f===!1&&gN(t,o,l,i),ov(t,t.mapping.slice(i).map(l,1),r,void 0,f===null);let h=t.mapping.slice(i),m=h.map(l,1),g=h.map(l+o.nodeSize,1);return t.step(new Bn(m,g,m+1,g-1,new Ue(we.from(r.create(d,null,o.marks)),0,0),1,!0)),f===!0&&mN(t,o,l,i),!1}})}function mN(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let d=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(d,d+1,e.type.schema.linebreakReplacement.create())}}})}function gN(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
52
- `))}})}function bA(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function xA(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Bn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Ue(we.from(o),0,0),1,!0))}function Vs(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let f=s.depth-1,h=n-2;f>i;f--,h--){let m=s.node(f),g=s.index(f);if(m.type.spec.isolating)return!1;let v=m.content.cutByIndex(g,m.childCount),x=r&&r[h+1];x&&(v=v.replaceChild(0,x.type.create(x.attrs)));let k=r&&r[h]||m;if(!m.canReplace(g+1,m.childCount)||!k.type.validContent(v))return!1}let l=s.indexAfter(i),d=r&&r[0];return s.node(i).canReplaceWith(l,l,d?d.type:s.node(i+1).type)}function wA(t,e,n=1,r){let s=t.doc.resolve(e),i=we.empty,o=we.empty;for(let l=s.depth,d=s.depth-n,f=n-1;l>d;l--,f--){i=we.from(s.node(l).copy(i));let h=r&&r[f];o=we.from(h?h.type.create(h.attrs,o):s.node(l).copy(o))}t.step(new Pn(e,e,new Ue(i.append(o),n,n),!0))}function Li(t,e){let n=t.resolve(e),r=n.index();return vN(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function kA(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function vN(t,e){return!!(t&&e&&!t.isLeaf&&kA(t,e))}function zd(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&vN(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function SA(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let h=o.whitespace=="pre",m=!!o.contentMatch.matchType(s);h&&!m?r=!1:!h&&m&&(r=!0)}let l=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);gN(t,h.node(),h.before(),l)}o.inlineContent&&ov(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let d=t.mapping.slice(l),f=d.map(e-n);if(t.step(new Pn(f,d.map(e+n,-1),Ue.empty,!0)),r===!0){let h=t.doc.resolve(f);mN(t,h.node(),h.before(),t.steps.length)}return t}function EA(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function yN(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,d=r.index(o)+(l>0?1:0),f=r.node(o),h=!1;if(i==1)h=f.canReplace(d,d,s);else{let m=f.contentMatchAt(d).findWrapping(s.firstChild.type);h=m&&f.canReplaceWith(d,d,m[0])}if(h)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Ud(t,e,n=e,r=Ue.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return bN(s,i,r)?new Pn(e,n,r):new NA(s,i,r).fit()}function bN(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class NA{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=we.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=we.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let d=new Ue(i,o,l);return e>-1?new Bn(r.pos,e,this.$to.pos,this.$to.end(),d,n):d.size||r.pos!=this.$to.pos?new Pn(r.pos,s.pos,d):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=ep(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:d,match:f}=this.frontier[l],h,m=null;if(n==1&&(o?f.matchType(o.type)||(m=f.fillBefore(we.from(o),!1)):i&&d.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:m};if(n==2&&o&&(h=f.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:h};if(i&&f.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ep(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Ue(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=ep(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Ue(rl(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Ue(rl(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let k=0;k<i.length;k++)this.openFrontierNode(i[k]);let o=this.unplaced,l=r?r.content:o.content,d=o.openStart-e,f=0,h=[],{match:m,type:g}=this.frontier[n];if(s){for(let k=0;k<s.childCount;k++)h.push(s.child(k));m=m.matchFragment(s)}let v=l.size+e-(o.content.size-o.openEnd);for(;f<l.childCount;){let k=l.child(f),w=m.matchType(k.type);if(!w)break;f++,(f>1||d==0||k.content.size)&&(m=w,h.push(xN(k.mark(g.allowedMarks(k.marks)),f==1?d:0,f==l.childCount?v:-1)))}let x=f==l.childCount;x||(v=-1),this.placed=sl(this.placed,n,we.from(h)),this.frontier[n].match=m,x&&v<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let k=0,w=l;k<v;k++){let S=w.lastChild;this.frontier.push({type:S.type,match:S.contentMatchAt(S.childCount)}),w=S.content}this.unplaced=x?e==0?Ue.empty:new Ue(rl(o.content,e-1,1),e-1,v<0?o.openEnd:e-1):new Ue(rl(o.content,e,f),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!tp(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=tp(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:d,type:f}=this.frontier[l],h=tp(e,l,f,d,!0);if(!h||h.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=sl(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=sl(this.placed,this.depth,we.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(we.empty,!0);n.childCount&&(this.placed=sl(this.placed,this.frontier.length,n))}}function rl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(rl(t.firstChild.content,e-1,n)))}function sl(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(sl(t.lastChild.content,e-1,n)))}function ep(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function xN(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,xN(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(we.empty,!0)))),t.copy(r)}function tp(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!CA(n,i.content,o)?l:null}function CA(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function _A(t){return t.spec.defining||t.spec.definingForContent}function TA(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(bN(s,i,r))return t.step(new Pn(e,n,r));let o=kN(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let g=s.depth,v=s.pos-1;g>0;g--,v--){let x=s.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(g)>-1?l=g:s.before(g)==v&&o.splice(1,0,-g)}let d=o.indexOf(l),f=[],h=r.openStart;for(let g=r.content,v=0;;v++){let x=g.firstChild;if(f.push(x),v==r.openStart)break;g=x.content}for(let g=h-1;g>=0;g--){let v=f[g],x=_A(v.type);if(x&&!v.sameMarkup(s.node(Math.abs(l)-1)))h=g;else if(x||!v.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let v=(g+h+1)%(r.openStart+1),x=f[v];if(x)for(let k=0;k<o.length;k++){let w=o[(k+d)%o.length],S=!0;w<0&&(S=!1,w=-w);let N=s.node(w-1),T=s.index(w-1);if(N.canReplaceWith(T,T,x.type,x.marks))return t.replace(s.before(w),S?i.after(w):n,new Ue(wN(r.content,0,r.openStart,v),v,r.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let v=o[g];v<0||(e=s.before(v),n=i.after(v))}}function wN(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(wN(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(we.empty,!0))}return t}function jA(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=EA(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Ue(we.from(r),0,0))}function MA(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=kN(r,s);for(let o=0;o<i.length;o++){let l=i[o],d=o==i.length-1;if(d&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(d||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function kN(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class oa extends ar{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 _n.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return _n.fromReplace(e,this.pos,this.pos+1,new Ue(we.from(s),0,n.isLeaf?0:1))}getMap(){return Mr.empty}invert(e){return new oa(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 oa(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 oa(n.pos,n.attr,n.value)}}ar.jsonID("attr",oa);class El extends ar{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return _n.ok(r)}getMap(){return Mr.empty}invert(e){return new El(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 El(n.attr,n.value)}}ar.jsonID("docAttr",El);let ca=class extends Error{};ca=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ca.prototype=Object.create(Error.prototype);ca.prototype.constructor=ca;ca.prototype.name="TransformError";class lv{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Sl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ca(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,d)=>{e=Math.min(e,l),n=Math.max(n,d)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=Ue.empty){let s=Ud(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Ue(we.from(r),0,0))}delete(e,n){return this.replace(e,n,Ue.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return TA(this,e,n,r),this}replaceRangeWith(e,n,r){return jA(this,e,n,r),this}deleteRange(e,n){return MA(this,e,n),this}lift(e,n){return pA(this,e,n),this}join(e,n=1){return SA(this,e,n),this}wrap(e,n){return vA(this,e,n),this}setBlockType(e,n=e,r,s=null){return yA(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return xA(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new oa(e,n,r)),this}setDocAttribute(e,n){return this.step(new El(e,n)),this}addNodeMark(e,n){return this.step(new Ei(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 Zt)n.isInSet(r.marks)&&this.step(new mo(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new mo(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return wA(this,e,n,r),this}addMark(e,n,r){return dA(this,e,n,r),this}removeMark(e,n,r){return fA(this,e,n,r),this}clearIncompatible(e,n,r){return ov(this,e,n,r),this}}const np=Object.create(null);class yt{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new SN(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=Ue.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:d,$to:f}=o[l],h=e.mapping.slice(i);e.replaceRange(h.map(d.pos),h.map(f.pos),l?Ue.empty:n),l==0&&bx(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],d=e.mapping.slice(r),f=d.map(o.pos),h=d.map(l.pos);i?e.deleteRange(f,h):(e.replaceRangeWith(f,h,n),bx(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new ft(e):Qo(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?Qo(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Qo(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Rr(e.node(0))}static atStart(e){return Qo(e,e,0,0,1)||new Rr(e)}static atEnd(e){return Qo(e,e,e.content.size,e.childCount,-1)||new Rr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=np[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 np)throw new RangeError("Duplicate use of selection JSON ID "+e);return np[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ft.between(this.$anchor,this.$head).getBookmark()}}yt.prototype.visible=!0;class SN{constructor(e,n){this.$from=e,this.$to=n}}let vx=!1;function yx(t){!vx&&!t.parent.inlineContent&&(vx=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ft extends yt{constructor(e,n=e){yx(e),yx(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 yt.near(r);let s=e.resolve(n.map(this.anchor));return new ft(s.parent.inlineContent?s:r,r)}replace(e,n=Ue.empty){if(super.replace(e,n),n==Ue.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ft&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hd(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 ft(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=yt.findFrom(n,r,!0)||yt.findFrom(n,-r,!0);if(i)n=i.$head;else return yt.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(yt.findFrom(e,-r,!0)||yt.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new ft(e,n)}}yt.jsonID("text",ft);class Hd{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Hd(e.map(this.anchor),e.map(this.head))}resolve(e){return ft.between(e.resolve(this.anchor),e.resolve(this.head))}}class ut extends yt{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?yt.near(i):new ut(i)}content(){return new Ue(we.from(this.node),0,0)}eq(e){return e instanceof ut&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new cv(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ut(e.resolve(n.anchor))}static create(e,n){return new ut(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ut.prototype.visible=!1;yt.jsonID("node",ut);class cv{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Hd(r,r):new cv(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ut.isSelectable(r)?new ut(n):yt.near(n)}}class Rr extends yt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ue.empty){if(n==Ue.empty){e.delete(0,e.doc.content.size);let r=yt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Rr(e)}map(e){return new Rr(e)}eq(e){return e instanceof Rr}getBookmark(){return AA}}yt.jsonID("all",Rr);const AA={map(){return this},resolve(t){return new Rr(t)}};function Qo(t,e,n,r,s,i=!1){if(e.inlineContent)return ft.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&ut.isSelectable(l))return ut.create(t,n-(s<0?l.nodeSize:0))}else{let d=Qo(t,l,n+s,s<0?l.childCount:0,s,i);if(d)return d}n+=l.nodeSize*s}return null}function bx(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Pn||s instanceof Bn))return;let i=t.mapping.maps[r],o;i.forEach((l,d,f,h)=>{o==null&&(o=h)}),t.setSelection(yt.near(t.doc.resolve(o),n))}const xx=1,Qc=2,wx=4;class RA extends lv{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|xx)&~Qc,this.storedMarks=null,this}get selectionSet(){return(this.updated&xx)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Qc,this}ensureMarks(e){return Zt.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&Qc)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Qc,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)||Zt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(yt.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|=wx,this}get scrolledIntoView(){return(this.updated&wx)>0}}function kx(t,e){return!e||!t?t:t.bind(e)}class il{constructor(e,n,r){this.name=e,this.init=kx(n.init,r),this.apply=kx(n.apply,r)}}const OA=[new il("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new il("selection",{init(t,e){return t.selection||yt.atStart(e.doc)},apply(t){return t.selection}}),new il("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new il("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class rp{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=OA.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 il(r.key,r.spec.state,r))})}}class ra{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let d=s?s[o].n:0,f=s?s[o].state:this,h=d<n.length&&l.spec.appendTransaction.call(l,d?n.slice(d):n,f,r);if(h&&r.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!s){s=[];for(let m=0;m<this.config.plugins.length;m++)s.push(m<o?{state:r,n:n.length}:{state:this,n:0})}n.push(h),r=r.applyInner(h),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ra(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new RA(this)}static create(e){let n=new rp(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ra(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new rp(this.schema,e.plugins),r=n.fields,s=new ra(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new rp(e.schema,e.plugins),i=new ra(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=ls.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=yt.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let d=r[l],f=d.spec.state;if(d.key==o.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=f.fromJSON.call(d,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function EN(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=EN(s,e,{})),n[r]=s}return n}class Ut{constructor(e){this.spec=e,this.props={},e.props&&EN(e.props,this,this.props),this.key=e.key?e.key.key:NN("plugin")}getState(e){return e[this.key]}}const sp=Object.create(null);function NN(t){return t in sp?t+"$"+ ++sp[t]:(sp[t]=0,t+"$")}class Jt{constructor(e="key"){this.key=NN(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const uv=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function CN(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const _N=(t,e,n)=>{let r=CN(t,n);if(!r)return!1;let s=dv(r);if(!s){let o=r.blockRange(),l=o&&va(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(DN(t,s,e,-1))return!0;if(r.parent.content.size==0&&(ua(i,"end")||ut.isSelectable(i)))for(let o=r.depth;;o--){let l=Ud(t.doc,r.before(o),r.after(o),Ue.empty);if(l&&l.slice.size<l.to-l.from){if(e){let d=t.tr.step(l);d.setSelection(ua(i,"end")?yt.findFrom(d.doc.resolve(d.mapping.map(s.pos,-1)),-1):ut.create(d.doc,s.pos-i.nodeSize)),e(d.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},IA=(t,e,n)=>{let r=CN(t,n);if(!r)return!1;let s=dv(r);return s?TN(t,s,e):!1},LA=(t,e,n)=>{let r=MN(t,n);if(!r)return!1;let s=fv(r);return s?TN(t,s,e):!1};function TN(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let h=s.lastChild;if(!h)return!1;s=h}let o=e.nodeAfter,l=o,d=e.pos+1;for(;!l.isTextblock;d++){if(l.type.spec.isolating)return!1;let h=l.firstChild;if(!h)return!1;l=h}let f=Ud(t.doc,i,d,Ue.empty);if(!f||f.from!=i||f instanceof Pn&&f.slice.size>=d-i)return!1;if(n){let h=t.tr.step(f);h.setSelection(ft.create(h.doc,i)),n(h.scrollIntoView())}return!0}function ua(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 jN=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=dv(r)}let o=i&&i.nodeBefore;return!o||!ut.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ut.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function dv(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 MN(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const AN=(t,e,n)=>{let r=MN(t,n);if(!r)return!1;let s=fv(r);if(!s)return!1;let i=s.nodeAfter;if(DN(t,s,e,1))return!0;if(r.parent.content.size==0&&(ua(i,"start")||ut.isSelectable(i))){let o=Ud(t.doc,r.before(),r.after(),Ue.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(ua(i,"start")?yt.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):ut.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},RN=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=fv(r)}let o=i&&i.nodeAfter;return!o||!ut.isSelectable(o)?!1:(e&&e(t.tr.setSelection(ut.create(t.doc,i.pos)).scrollIntoView()),!0)};function fv(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 DA=(t,e)=>{let n=t.selection,r=n instanceof ut,s;if(r){if(n.node.isTextblock||!Li(t.doc,n.from))return!1;s=n.from}else if(s=zd(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(ut.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},PA=(t,e)=>{let n=t.selection,r;if(n instanceof ut){if(n.node.isTextblock||!Li(t.doc,n.to))return!1;r=n.to}else if(r=zd(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},BA=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&va(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},ON=(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 hv(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 $A=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=hv(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),d=t.tr.replaceWith(l,l,o.createAndFill());d.setSelection(yt.near(d.doc.resolve(l),1)),e(d.scrollIntoView())}return!0},IN=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Rr||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=hv(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(ft.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},LN=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Vs(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&va(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function FA(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof ut&&e.selection.node.isBlock)return!r.parentOffset||!Vs(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,d=!1,f=!1;for(let v=r.depth;;v--)if(r.node(v).isBlock){d=r.end(v)==r.pos+(r.depth-v),f=r.start(v)==r.pos-(r.depth-v),l=hv(r.node(v-1).contentMatchAt(r.indexAfter(v-1))),i.unshift(d&&l?{type:l}:null),o=v;break}else{if(v==1)return!1;i.unshift(null)}let h=e.tr;(e.selection instanceof ft||e.selection instanceof Rr)&&h.deleteSelection();let m=h.mapping.map(r.pos),g=Vs(h.doc,m,i.length,i);if(g||(i[0]=l?{type:l}:null,g=Vs(h.doc,m,i.length,i)),!g)return!1;if(h.split(m,i.length,i),!d&&f&&r.node(o).type!=l){let v=h.mapping.map(r.before(o)),x=h.doc.resolve(v);l&&r.node(o-1).canReplaceWith(x.index(),x.index()+1,l)&&h.setNodeMarkup(h.mapping.map(r.before(o)),l)}return n&&n(h.scrollIntoView()),!0}}const zA=FA(),UA=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(ut.create(t.doc,s))),!0)};function HA(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Li(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function DN(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,d=s.type.spec.isolating||i.type.spec.isolating;if(!d&&HA(t,e,n))return!0;let f=!d&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let v=e.pos+i.nodeSize,x=we.empty;for(let S=o.length-1;S>=0;S--)x=we.from(o[S].create(null,x));x=we.from(s.copy(x));let k=t.tr.step(new Bn(e.pos-1,v,e.pos,v,new Ue(x,1,0),o.length,!0)),w=k.doc.resolve(v+2*o.length);w.nodeAfter&&w.nodeAfter.type==s.type&&Li(k.doc,w.pos)&&k.join(w.pos),n(k.scrollIntoView())}return!0}let h=i.type.spec.isolating||r>0&&d?null:yt.findFrom(e,1),m=h&&h.$from.blockRange(h.$to),g=m&&va(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(f&&ua(i,"start",!0)&&ua(s,"end")){let v=s,x=[];for(;x.push(v),!v.isTextblock;)v=v.lastChild;let k=i,w=1;for(;!k.isTextblock;k=k.firstChild)w++;if(v.canReplace(v.childCount,v.childCount,k.content)){if(n){let S=we.empty;for(let T=x.length-1;T>=0;T--)S=we.from(x[T].copy(S));let N=t.tr.step(new Bn(e.pos-x.length,e.pos+i.nodeSize,e.pos+w,e.pos+i.nodeSize-w,new Ue(S,x.length,0),0,!0));n(N.scrollIntoView())}return!0}}return!1}function PN(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(ft.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const WA=PN(-1),VA=PN(1);function qA(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&av(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Sx(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(d,f)=>{if(s)return!1;if(!(!d.isTextblock||d.hasMarkup(t,e)))if(d.type==t)s=!0;else{let h=n.doc.resolve(f),m=h.index();s=h.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:d}}=n.selection.ranges[o];i.setBlockType(l,d,t,e)}r(i.scrollIntoView())}return!0}}function pv(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}pv(uv,_N,jN);pv(uv,AN,RN);pv(ON,IN,LN,zA);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function KA(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return GA(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function GA(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let d=o.resolve(e.start-2);i=new Wu(d,d,e.depth),e.endIndex<e.parent.childCount&&(e=new Wu(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=av(i,n,r,e);return l?(t&&JA(t,e,l,s,n),!0):!1}function JA(t,e,n,r,s){let i=we.empty;for(let h=n.length-1;h>=0;h--)i=we.from(n[h].type.create(n[h].attrs,i));t.step(new Bn(e.start-(r?2:0),e.end,e.start,e.end,new Ue(i,0,0),n.length,!0));let o=0;for(let h=0;h<n.length;h++)n[h].type==s&&(o=h+1);let l=n.length-o,d=e.start+n.length-(r?2:0),f=e.parent;for(let h=e.startIndex,m=e.endIndex,g=!0;h<m;h++,g=!1)!g&&Vs(t.doc,d,l)&&(t.split(d,l),d+=2*l),d+=f.child(h).nodeSize;return t}function YA(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?XA(e,n,t,i):QA(e,n,i):!0:!1}}function XA(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Bn(i-1,o,i,o,new Ue(we.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Wu(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=va(r);if(l==null)return!1;s.lift(r,l);let d=s.doc.resolve(s.mapping.map(i,-1)-1);return Li(s.doc,d.pos)&&d.nodeBefore.type==d.nodeAfter.type&&s.join(d.pos),e(s.scrollIntoView()),!0}function QA(t,e,n){let r=t.tr,s=n.parent;for(let v=n.end,x=n.endIndex-1,k=n.startIndex;x>k;x--)v-=s.child(x).nodeSize,r.delete(v-1,v+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,d=n.endIndex==s.childCount,f=i.node(-1),h=i.index(-1);if(!f.canReplace(h+(l?0:1),h+1,o.content.append(d?we.empty:we.from(s))))return!1;let m=i.pos,g=m+o.nodeSize;return r.step(new Bn(m-(l?1:0),g+(d?1:0),m+1,g-1,new Ue((l?we.empty:we.from(s.copy(we.empty))).append(d?we.empty:we.from(s.copy(we.empty))),l?0:1,d?0:1),l?0:1)),e(r.scrollIntoView()),!0}function ZA(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,f=>f.childCount>0&&f.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,d=l.child(o-1);if(d.type!=t)return!1;if(n){let f=d.lastChild&&d.lastChild.type==l.type,h=we.from(f?t.create():null),m=new Ue(we.from(t.create(null,we.from(l.type.create(null,h)))),f?3:1,0),g=i.start,v=i.end;n(e.tr.step(new Bn(g-(f?3:1),v,g,v,m,1,!0)).scrollIntoView())}return!0}}const Yn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},da=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let xg=null;const Us=function(t,e,n){let r=xg||(xg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},eR=function(){xg=null},go=function(t,e,n,r){return n&&(Ex(t,e,n,r,-1)||Ex(t,e,n,r,1))},tR=/^(img|br|input|textarea|hr)$/i;function Ex(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Kr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Pl(t)||tR.test(t.nodeName)||t.contentEditable=="false")return!1;e=Yn(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?Kr(t):0}else return!1}}function Kr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function nR(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=Kr(t)}else if(t.parentNode&&!Pl(t))e=Yn(t),t=t.parentNode;else return null}}function rR(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&&!Pl(t))e=Yn(t)+1,t=t.parentNode;else return null}}function sR(t,e,n){for(let r=e==0,s=e==Kr(t);r||s;){if(t==n)return!0;let i=Yn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Kr(t)}}function Pl(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 Wd=function(t){return t.focusNode&&go(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function no(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function iR(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function oR(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Kr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Kr(r.startContainer),r.startOffset)}}}const Es=typeof navigator<"u"?navigator:null,Nx=typeof document<"u"?document:null,Di=Es&&Es.userAgent||"",wg=/Edge\/(\d+)/.exec(Di),BN=/MSIE \d/.exec(Di),kg=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Di),Sr=!!(BN||kg||wg),Ci=BN?document.documentMode:kg?+kg[1]:wg?+wg[1]:0,Gr=!Sr&&/gecko\/(\d+)/i.test(Di);Gr&&+(/Firefox\/(\d+)/.exec(Di)||[0,0])[1];const Sg=!Sr&&/Chrome\/(\d+)/.exec(Di),Qn=!!Sg,$N=Sg?+Sg[1]:0,ir=!Sr&&!!Es&&/Apple Computer/.test(Es.vendor),fa=ir&&(/Mobile\/\w+/.test(Di)||!!Es&&Es.maxTouchPoints>2),qr=fa||(Es?/Mac/.test(Es.platform):!1),FN=Es?/Win/.test(Es.platform):!1,Hs=/Android \d/.test(Di),Bl=!!Nx&&"webkitFontSmoothing"in Nx.documentElement.style,aR=Bl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function lR(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 Ps(t,e){return typeof t=="number"?t:t[e]}function cR(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 Cx(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=da(o);continue}let l=o,d=l==i.body,f=d?lR(i):cR(l),h=0,m=0;if(e.top<f.top+Ps(r,"top")?m=-(f.top-e.top+Ps(s,"top")):e.bottom>f.bottom-Ps(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+Ps(s,"top")-f.top:e.bottom-f.bottom+Ps(s,"bottom")),e.left<f.left+Ps(r,"left")?h=-(f.left-e.left+Ps(s,"left")):e.right>f.right-Ps(r,"right")&&(h=e.right-f.right+Ps(s,"right")),h||m)if(d)i.defaultView.scrollBy(h,m);else{let v=l.scrollLeft,x=l.scrollTop;m&&(l.scrollTop+=m),h&&(l.scrollLeft+=h);let k=l.scrollLeft-v,w=l.scrollTop-x;e={left:e.left-k,top:e.top-w,right:e.right-k,bottom:e.bottom-w}}let g=d?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:da(o)}}function uR(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let d=l.getBoundingClientRect();if(d.top>=n-20){r=l,s=d.top;break}}return{refDOM:r,refTop:s,stack:zN(t.dom)}}function zN(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=da(r));return e}function dR({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;UN(n,r==0?0:r-e)}function UN(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Go=null;function fR(t){if(t.setActive)return t.setActive();if(Go)return t.focus(Go);let e=zN(t);t.focus(Go==null?{get preventScroll(){return Go={preventScroll:!0},!0}}:void 0),Go||(Go=!1,UN(e,0))}function HN(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,d,f;for(let h=t.firstChild,m=0;h;h=h.nextSibling,m++){let g;if(h.nodeType==1)g=h.getClientRects();else if(h.nodeType==3)g=Us(h).getClientRects();else continue;for(let v=0;v<g.length;v++){let x=g[v];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let k=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(k<r){n=h,r=k,s=k&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,h.nodeType==1&&k&&(i=m+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!d&&x.left<=e.left&&x.right>=e.left&&(d=h,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)&&(i=m+1)}}return!n&&d&&(n=d,s=f,r=0),n&&n.nodeType==3?hR(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:HN(n,s)}function hR(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=pi(r,1);if(o.top!=o.bottom&&mv(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function mv(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pR(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function mR(t,e,n){let{node:r,offset:s}=HN(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function gR(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),d;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((d=l.dom.getBoundingClientRect()).width||d.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&d.left>r.left||d.top>r.top?s=l.posBefore:(!o&&d.right<r.left||d.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(d.top+d.bottom)/2:r.left<(d.left+d.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function WN(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let d=0;d<l.length;d++){let f=l[d];if(mv(e,f))return WN(o,e,f)}}if((i=(i+1)%r)==s)break}return t}function vR(t,e){let n=t.dom.ownerDocument,r,s=0,i=oR(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let f=t.dom.getBoundingClientRect();if(!mv(e,f)||(o=WN(t.dom,e,f),!o))return null}if(ir)for(let f=o;r&&f;f=da(f))f.draggable&&(r=void 0);if(o=pR(o,e),r){if(Gr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let h=r.childNodes[s],m;h.nodeName=="IMG"&&(m=h.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let f;Bl&&s&&r.nodeType==1&&(f=r.childNodes[s-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=gR(t,r,s,e))}l==null&&(l=mR(t,o,e));let d=t.docView.nearestDesc(o,!0);return{pos:l,inside:d?d.posAtStart-d.border:-1}}function _x(t){return t.top<t.bottom||t.left<t.right}function pi(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(_x(r))return r}return Array.prototype.find.call(n,_x)||t.getBoundingClientRect()}const yR=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function VN(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Bl||Gr;if(r.nodeType==3)if(o&&(yR.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let d=pi(Us(r,s,s),n);if(Gr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=pi(Us(r,s-1,s-1),-1);if(f.top==d.top){let h=pi(Us(r,s,s+1),-1);if(h.top!=d.top)return Xa(h,h.left<f.left)}}return d}else{let d=s,f=s,h=n<0?1:-1;return n<0&&!s?(f++,h=-1):n>=0&&s==r.nodeValue.length?(d--,h=1):n<0?d--:f++,Xa(pi(Us(r,d,f),h),h<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Kr(r))){let d=r.childNodes[s-1];if(d.nodeType==1)return ip(d.getBoundingClientRect(),!1)}if(i==null&&s<Kr(r)){let d=r.childNodes[s];if(d.nodeType==1)return ip(d.getBoundingClientRect(),!0)}return ip(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Kr(r))){let d=r.childNodes[s-1],f=d.nodeType==3?Us(d,Kr(d)-(o?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(f)return Xa(pi(f,1),!1)}if(i==null&&s<Kr(r)){let d=r.childNodes[s];for(;d.pmViewDesc&&d.pmViewDesc.ignoreForCoords;)d=d.nextSibling;let f=d?d.nodeType==3?Us(d,0,o?0:1):d.nodeType==1?d:null:null;if(f)return Xa(pi(f,-1),!0)}return Xa(pi(r.nodeType==3?Us(r):r,-n),n>=0)}function Xa(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 ip(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 qN(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function bR(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return qN(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=VN(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let d;if(l.nodeType==1)d=l.getClientRects();else if(l.nodeType==3)d=Us(l,0,l.nodeValue.length).getClientRects();else continue;for(let f=0;f<d.length;f++){let h=d[f];if(h.bottom>h.top+1&&(n=="up"?o.top-h.top>(h.bottom-o.top)*2:h.bottom-o.bottom>(o.bottom-h.top)*2))return!1}}return!0})}const xR=/[\u0590-\u08ac]/;function wR(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!xR.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:qN(t,e,()=>{let{focusNode:d,focusOffset:f,anchorNode:h,anchorOffset:m}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let v=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:k}=t.domSelectionRange(),w=x&&!v.contains(x.nodeType==1?x:x.parentNode)||d==x&&f==k;try{l.collapse(h,m),d&&(d!=h||f!=m)&&l.extend&&l.extend(d,f)}catch{}return g!=null&&(l.caretBidiLevel=g),w}):r.pos==r.start()||r.pos==r.end()}let Tx=null,jx=null,Mx=!1;function kR(t,e,n){return Tx==e&&jx==n?Mx:(Tx=e,jx=n,Mx=n=="up"||n=="down"?bR(t,e,n):wR(t,e,n))}const Jr=0,Ax=1,ro=2,Ns=3;class $l{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Jr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Yn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof GN){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof KN&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Yn(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Yn(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let d=this.children[l],f=o+d.size;if(s==-1&&e<=f){let h=o+d.border;if(e>=h&&n<=f-d.border&&d.node&&d.contentDOM&&this.contentDOM.contains(d.contentDOM))return d.parseRange(e,n,h);e=o;for(let m=l;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){s=Yn(g.dom)+1;break}e-=g.size}s==-1&&(s=0)}if(s>-1&&(f>n||l==this.children.length-1)){n=f;for(let h=l+1;h<this.children.length;h++){let m=this.children[h];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=Yn(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=f}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let v=0,x=0;v<this.children.length;v++){let k=this.children[v],w=x+k.size;if(i>x&&o<w)return k.setSelection(e-x-k.border,n-x-k.border,r,s);x=w}let l=this.domFromPos(e,e?-1:1),d=n==e?l:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),h=r.domSelectionRange(),m=!1;if((Gr||ir)&&e==n){let{node:v,offset:x}=l;if(v.nodeType==3){if(m=!!(x&&v.nodeValue[x-1]==`
54
- `),m&&x==v.nodeValue.length)for(let k=v,w;k;k=k.parentNode){if(w=k.nextSibling){w.nodeName=="BR"&&(l=d={node:w.parentNode,offset:Yn(w)+1});break}let S=k.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{let k=v.childNodes[x-1];m=k&&(k.nodeName=="BR"||k.contentEditable=="false")}}if(Gr&&h.focusNode&&h.focusNode!=d.node&&h.focusNode.nodeType==1){let v=h.focusNode.childNodes[h.focusOffset];v&&v.contentEditable=="false"&&(s=!0)}if(!(s||m&&ir)&&go(l.node,l.offset,h.anchorNode,h.anchorOffset)&&go(d.node,d.offset,h.focusNode,h.focusOffset))return;let g=!1;if((f.extend||e==n)&&!(m&&Gr)){f.collapse(l.node,l.offset);try{e!=n&&f.extend(d.node,d.offset),g=!0}catch{}}if(!g){if(e>n){let x=l;l=d,d=x}let v=document.createRange();v.setEnd(d.node,d.offset),v.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(v)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,d=o-i.border;if(e>=l&&n<=d){this.dirty=e==r||n==o?ro:Ax,e==l&&n==d&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ns:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?ro:Ns}r=o}this.dirty=ro}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ro:Ax;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class KN extends $l{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Jr&&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 SR extends $l{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class vo extends $l{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=wo.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new vo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ns||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ns&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Jr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Jr}}slice(e,n,r){let s=vo.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Ng(i,n,o,r)),e>0&&(i=Ng(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class _i extends $l{constructor(e,n,r,s,i,o,l,d,f){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],d,f=l&&l(n,i,()=>{if(!d)return o;if(d.parent)return d.parent.posBeforeChild(d)},r,s),h=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=wo.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let g=h;return h=XN(h,r,n),f?d=new ER(e,n,r,s,h,m||null,g,f,i,o+1):n.isText?new Vd(e,n,r,s,h,g,i):new _i(e,n,r,s,h,m||null,g,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>we.empty)}return e}matchesNode(e,n,r){return this.dirty==Jr&&e.eq(this.node)&&qu(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,d=new CR(this,o&&o.node,e);jR(this.node,this.innerDeco,(f,h,m)=>{f.spec.marks?d.syncToMarks(f.spec.marks,r,e,h):f.type.side>=0&&!m&&d.syncToMarks(h==this.node.childCount?Zt.none:this.node.child(h).marks,r,e,h),d.placeWidget(f,e,s)},(f,h,m,g)=>{d.syncToMarks(f.marks,r,e,g);let v;d.findNodeMatch(f,h,m,g)||l&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(v=d.findIndexWithChild(i.node))>-1&&d.updateNodeAt(f,h,m,v,e)||d.updateNextNode(f,h,m,e,g,s)||d.addNode(f,h,m,e,s),s+=f.nodeSize}),d.syncToMarks([],r,e,0),this.node.isTextblock&&d.addTextblockHacks(),d.destroyRest(),(d.changed||this.dirty==ro)&&(o&&this.protectLocalComposition(e,o),JN(this.contentDOM,this.children,e),fa&&MR(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof ft)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=AR(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new SR(this,i,n,s);e.input.compositionNodes.push(o),this.children=Ng(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Ns||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Jr}updateOuterDeco(e){if(qu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=YN(this.dom,this.nodeDOM,Eg(this.outerDeco,this.node,n),Eg(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 Rx(t,e,n,r,s){XN(r,e,t);let i=new _i(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Vd extends _i{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Ns||this.dirty!=Jr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Jr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Jr,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new Vd(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ns)}get domAtom(){return!1}isText(e){return this.node.text==e}}class GN extends $l{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Jr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ER extends _i{constructor(e,n,r,s,i,o,l,d,f,h){super(e,n,r,s,i,o,l,f,h),this.spec=d}update(e,n,r,s){if(this.dirty==Ns)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function JN(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Ox(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof vo){let d=r?r.previousSibling:t.lastChild;JN(o.contentDOM,o.children,n),r=d?d.nextSibling:t.firstChild}}for(;r;)r=Ox(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const hl=function(t){t&&(this.nodeName=t)};hl.prototype=Object.create(null);const so=[new hl];function Eg(t,e,n){if(t.length==0)return so;let r=n?so[0]:new hl,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new hl(o.nodeName));for(let l in o){let d=o[l];d!=null&&(n&&s.length==1&&s.push(r=new hl(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+d:l=="style"?r.style=(r.style?r.style+";":"")+d:l!="nodeName"&&(r[l]=d))}}}return s}function YN(t,e,n,r){if(n==so&&r==so)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let d;l&&l.nodeName==o.nodeName&&s!=t&&(d=s.parentNode)&&d.nodeName.toLowerCase()==o.nodeName||(d=document.createElement(o.nodeName),d.pmIsDeco=!0,d.appendChild(s),l=so[0]),s=d}NR(s,l||so[0],o)}return s}function NR(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function XN(t,e,n){return YN(t,t,so,Eg(e,n,t.nodeType!=1))}function qu(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 Ox(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class CR{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=_R(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Jr,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let d=-1,f=this.top.children.length;s<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let h=this.index;h<f;h++){let m=this.top.children[h];if(m.matchesMark(e[o])&&!this.isLocked(m.dom)){d=h;break}}if(d>-1)d>this.index&&(this.changed=!0,this.destroyBetween(this.index,d)),this.top=this.top.children[this.index];else{let h=vo.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,h),this.top=h,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,d=Math.min(this.top.children.length,l+5);l<d;l++){let f=this.top.children[l];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Ns&&o.dom==o.contentDOM&&(o.dirty=ro),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let d=this.top.children[l];if(d instanceof _i){let f=this.preMatch.matched.get(d);if(f!=null&&f!=i)return!1;let h=d.dom,m,g=this.isLocked(h)&&!(e.isText&&d.node&&d.node.isText&&d.nodeDOM.nodeValue==e.text&&d.dirty!=Ns&&qu(n,d.outerDeco));if(!g&&d.update(e,n,r,s))return this.destroyBetween(this.index,l),d.dom!=h&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(d,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=ro,m.updateChildren(s,o+1),m.dirty=Jr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!qu(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=_i.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let d of l.children)d.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=_i.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new KN(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof vo;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Vd)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ir||Qn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new GN(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function _R(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let f=n.children[r-1];if(f instanceof vo)n=f,r=f.children.length;else{l=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let d=l.node;if(d){if(d!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function TR(t,e){return t.type.side-e.type.side}function jR(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let f=0;f<t.childCount;f++){let h=t.child(f);r(h,s,e.forChild(i,h),f),i+=h.nodeSize}return}let o=0,l=[],d=null;for(let f=0;;){let h,m;for(;o<s.length&&s[o].to==i;){let w=s[o++];w.widget&&(h?(m||(m=[h])).push(w):h=w)}if(h)if(m){m.sort(TR);for(let w=0;w<m.length;w++)n(m[w],f,!!d)}else n(h,f,!!d);let g,v;if(d)v=-1,g=d,d=null;else if(f<t.childCount)v=f,g=t.child(f++);else break;for(let w=0;w<l.length;w++)l[w].to<=i&&l.splice(w--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let x=i+g.nodeSize;if(g.isText){let w=x;o<s.length&&s[o].from<w&&(w=s[o].from);for(let S=0;S<l.length;S++)l[S].to<w&&(w=l[S].to);w<x&&(d=g.cut(w-i),g=g.cut(0,w-i),x=w,v=-1)}else for(;o<s.length&&s[o].to<x;)o++;let k=g.isInline&&!g.isLeaf?l.filter(w=>!w.inline):l.slice();r(g,k,e.forChild(i,g),v),i=x}}function MR(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 AR(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let d=o.text;for(;s<t.childCount;){let f=t.child(s++);if(i+=f.nodeSize,!f.isText)break;d+=f.text}if(i>=n){if(i>=r&&d.slice(r-e.length-l,r-l)==e)return r-e.length;let f=l<r?d.lastIndexOf(e,r-l-1):-1;if(f>=0&&f+e.length+l>=n)return l+f;if(n==r&&d.length>=r+e.length-l&&d.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ng(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let d=t[o],f=l,h=l+=d.size;f>=n||h<=e?i.push(d):(f<e&&i.push(d.slice(0,e-f,r)),s&&(i.push(s),s=void 0),h>n&&i.push(d.slice(n-f,d.size,r)))}return i}function gv(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),d,f;if(Wd(n)){for(d=o;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&ut.isSelectable(m)&&s.parent&&!(m.isInline&&sR(n.focusNode,n.focusOffset,s.dom))){let g=s.posBefore;f=new ut(o==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let v=0;v<n.rangeCount;v++){let x=n.getRangeAt(v);m=Math.min(m,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(m<0)return null;[d,o]=g==t.state.selection.anchor?[g,m]:[m,g],l=r.resolve(o)}else d=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(d<0)return null}let h=r.resolve(d);if(!f){let m=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;f=vv(t,h,l,m)}return f}function QN(t){return t.editable?t.hasFocus():eC(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function qs(t,e=!1){let n=t.state.selection;if(ZN(t,n),!!QN(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Qn){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&go(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)OR(t);else{let{anchor:r,head:s}=n,i,o;Ix&&!(n instanceof ft)&&(n.$from.parent.inlineContent||(i=Lx(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Lx(t,n.to))),t.docView.setSelection(r,s,t,e),Ix&&(i&&Dx(i),o&&Dx(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&RR(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Ix=ir||Qn&&$N<63;function Lx(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(ir&&s&&s.contentEditable=="false")return op(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return op(s);if(i)return op(i)}}function op(t){return t.contentEditable="true",ir&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Dx(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function RR(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!QN(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function OR(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Yn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Sr&&Ci<=11&&(n.disabled=!0,n.disabled=!1)}function ZN(t,e){if(e instanceof ut){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Px(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Px(t)}function Px(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function vv(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||ft.between(e,n,r)}function Bx(t){return t.editable&&!t.hasFocus()?!1:eC(t)}function eC(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 IR(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return go(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Cg(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&yt.findFrom(i,e)}function gi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function $x(t,e,n){let r=t.state.selection;if(r instanceof ft)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return gi(t,new ft(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Cg(t.state,e);return s&&s instanceof ut?gi(t,s):!1}else if(!(qr&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?ut.isSelectable(i)?gi(t,new ut(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Bl?gi(t,new ft(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ut&&r.node.isInline)return gi(t,new ft(e>0?r.$to:r.$from));{let s=Cg(t.state,e);return s?gi(t,s):!1}}}function Ku(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function pl(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Jo(t,e){return e<0?LR(t):DR(t)}function LR(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Gr&&n.nodeType==1&&r<Ku(n)&&pl(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(pl(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(tC(n))break;{let l=n.previousSibling;for(;l&&pl(l,-1);)s=n.parentNode,i=Yn(l),l=l.previousSibling;if(l)n=l,r=Ku(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?_g(t,n,r):s&&_g(t,s,i)}function DR(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Ku(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(pl(l,1))i=n,o=++r;else break}else{if(tC(n))break;{let l=n.nextSibling;for(;l&&pl(l,1);)i=l.parentNode,o=Yn(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Ku(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&_g(t,i,o)}function tC(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function PR(t,e){for(;t&&e==t.childNodes.length&&!Pl(t);)e=Yn(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 BR(t,e){for(;t&&!e&&!Pl(t);)e=Yn(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 _g(t,e,n){if(e.nodeType!=3){let i,o;(o=PR(e,n))?(e=o,n=0):(i=BR(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Wd(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&qs(t)},50)}function Fx(t,e){let n=t.state.doc.resolve(e);if(!(Qn||FN)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function zx(t,e,n){let r=t.state.selection;if(r instanceof ft&&!r.empty||n.indexOf("s")>-1||qr&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Cg(t.state,e);if(o&&o instanceof ut)return gi(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof Rr?yt.near(o,e):yt.findFrom(o,e);return l?gi(t,l):!1}return!1}function Ux(t,e){if(!(t.state.selection instanceof ft))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Hx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function $R(t){if(!ir||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;Hx(t,r,"true"),setTimeout(()=>Hx(t,r,"false"),20)}return!1}function FR(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function zR(t,e){let n=e.keyCode,r=FR(e);if(n==8||qr&&n==72&&r=="c")return Ux(t,-1)||Jo(t,-1);if(n==46&&!e.shiftKey||qr&&n==68&&r=="c")return Ux(t,1)||Jo(t,1);if(n==13||n==27)return!0;if(n==37||qr&&n==66&&r=="c"){let s=n==37?Fx(t,t.state.selection.from)=="ltr"?-1:1:-1;return $x(t,s,r)||Jo(t,s)}else if(n==39||qr&&n==70&&r=="c"){let s=n==39?Fx(t,t.state.selection.from)=="ltr"?1:-1:1;return $x(t,s,r)||Jo(t,s)}else{if(n==38||qr&&n==80&&r=="c")return zx(t,-1,r)||Jo(t,-1);if(n==40||qr&&n==78&&r=="c")return $R(t)||zx(t,1,r)||Jo(t,1);if(r==(qr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function yv(t,e){t.someProp("transformCopied",v=>{e=v(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let v=r.firstChild;n.push(v.type.name,v.attrs!=v.type.defaultAttrs?v.attrs:null),r=v.content}let o=t.someProp("clipboardSerializer")||wo.fromSchema(t.state.schema),l=aC(),d=l.createElement("div");d.appendChild(o.serializeFragment(r,{document:l}));let f=d.firstChild,h,m=0;for(;f&&f.nodeType==1&&(h=oC[f.nodeName.toLowerCase()]);){for(let v=h.length-1;v>=0;v--){let x=l.createElement(h[v]);for(;d.firstChild;)x.appendChild(d.firstChild);d.appendChild(x),m++}f=d.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${s} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",v=>v(e,t))||e.content.textBetween(0,e.content.size,`
55
-
56
- `);return{dom:d,text:g,slice:e}}function nC(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let d=!!e&&(r||i||!n);if(d){if(t.someProp("transformPastedText",g=>{e=g(e,i||r,t)}),i)return l=new Ue(we.from(t.state.schema.text(e.replace(/\r\n?/g,`
57
- `))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let m=t.someProp("clipboardTextParser",g=>g(e,s,r,t));if(m)l=m;else{let g=s.marks(),{schema:v}=t.state,x=wo.fromSchema(v);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(k=>{let w=o.appendChild(document.createElement("p"));k&&w.appendChild(x.serializeNode(v.text(k,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=VR(n),Bl&&qR(o);let f=o&&o.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||dl.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(d||h),context:s,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!UR.test(g.parentNode.nodeName)?{ignore:!0}:null}})),h)l=KR(Wx(l,+h[1],+h[2]),h[4]);else if(l=Ue.maxOpen(HR(l.content,s),!0),l.openStart||l.openEnd){let m=0,g=0;for(let v=l.content.firstChild;m<l.openStart&&!v.type.spec.isolating;m++,v=v.firstChild);for(let v=l.content.lastChild;g<l.openEnd&&!v.type.spec.isolating;g++,v=v.lastChild);l=Wx(l,m,g)}return t.someProp("transformPasted",m=>{l=m(l,t,d)}),l}const UR=/^(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 HR(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let d=s.findWrapping(l.type),f;if(!d)return o=null;if(f=o.length&&i.length&&sC(d,i,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=iC(o[o.length-1],i.length));let h=rC(l,d);o.push(h),s=s.matchType(h.type),i=d}}),o)return we.from(o)}return t}function rC(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,we.from(t));return t}function sC(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=sC(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(we.from(rC(n,t,s+1))))}}function iC(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,iC(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(we.empty,!0);return t.copy(n.append(r))}function Tg(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=Tg(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(we.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Wx(t,e,n){return e<t.openStart&&(t=new Ue(Tg(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ue(Tg(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const oC={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 Vx=null;function aC(){return Vx||(Vx=document.implementation.createHTMLDocument("title"))}let ap=null;function WR(t){let e=window.trustedTypes;return e?(ap||(ap=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),ap.createHTML(t)):t}function VR(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=aC().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&oC[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=WR(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function qR(t){let e=t.querySelectorAll(Qn?"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 KR(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let d=n.nodes[r[l]];if(!d||d.hasRequiredAttrs())break;s=we.from(d.create(r[l+1],s)),i++,o++}return new Ue(s,i,o)}const hr={},pr={},GR={touchstart:!0,touchmove:!0};class JR{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 YR(t){for(let e in hr){let n=hr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{QR(t,r)&&!bv(t,r)&&(t.editable||!(r.type in pr))&&n(t,r)},GR[e]?{passive:!0}:void 0)}ir&&t.dom.addEventListener("input",()=>null),jg(t)}function Ni(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function XR(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 jg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>bv(t,r))})}function bv(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function QR(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 ZR(t,e){!bv(t,e)&&hr[e.type]&&(t.editable||!(e.type in pr))&&hr[e.type](t,e)}pr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!cC(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Hs&&Qn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),fa&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,no(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||zR(t,n)?n.preventDefault():Ni(t,"key")};pr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};pr.keypress=(t,e)=>{let n=e;if(cC(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||qr&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ft)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function qd(t){return{left:t.clientX,top:t.clientY}}function eO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function xv(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function aa(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 tO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ut.isSelectable(r)?(aa(t,new ut(n)),!0):!1}function nO(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof ut&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(ut.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(aa(t,ut.create(t.state.doc,s)),!0):!1}function rO(t,e,n,r,s){return xv(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?nO(t,n):tO(t,n))}function sO(t,e,n,r){return xv(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function iO(t,e,n,r){return xv(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||oO(t,n,r)}function oO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(aa(t,ft.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)aa(t,ft.create(r,l+1,l+1+o.content.size));else if(ut.isSelectable(o))aa(t,ut.create(r,l));else continue;return!0}}function wv(t){return Gu(t)}const lC=qr?"metaKey":"ctrlKey";hr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=wv(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&eO(n,t.input.lastClick)&&!n[lC]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(qd(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new aO(t,o,n,!!r)):(i=="doubleClick"?sO:iO)(t,o.pos,o.inside,n)?n.preventDefault():Ni(t,"pointer"))};class aO{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[lC],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let h=e.state.doc.resolve(n.pos);i=h.parent,o=h.depth?h.before():0}const l=s?null:r.target,d=l?e.docView.nearestDesc(l,!0):null;this.target=d&&d.nodeDOM.nodeType==1?d.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||f instanceof ut&&f.from<=o&&f.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Gr&&!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)),Ni(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(()=>qs(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(qd(e))),this.updateAllowDefault(e),this.allowDefault||!n?Ni(this.view,"pointer"):rO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ir&&this.mightDrag&&!this.mightDrag.node.isAtom||Qn&&!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)?(aa(this.view,yt.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Ni(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ni(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)}}hr.touchstart=t=>{t.input.lastTouch=Date.now(),wv(t),Ni(t,"pointer")};hr.touchmove=t=>{t.input.lastTouch=Date.now(),Ni(t,"pointer")};hr.contextmenu=t=>wv(t);function cC(t,e){return t.composing?!0:ir&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const lO=Hs?5e3:-1;pr.compositionstart=pr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ft&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Qn&&FN&&cO(t)))t.markCursor=t.state.storedMarks||n.marks(),Gu(t,!0),t.markCursor=null;else if(Gu(t,!e.selection.empty),Gr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}uC(t,lO)};function cO(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"}pr.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++,uC(t,20))};function uC(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Gu(t),e))}function dC(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=dO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function uO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=nR(e.focusNode,e.focusOffset),r=rR(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function dO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Gu(t,e=!1){if(!(Hs&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),dC(t),e||t.docView&&t.docView.dirty){let n=gv(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 fO(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Nl=Sr&&Ci<15||fa&&aR<604;hr.copy=pr.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Nl?null:n.clipboardData,o=r.content(),{dom:l,text:d}=yv(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",d)):fO(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function hO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function pO(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Cl(t,r.value,null,s,e):Cl(t,r.textContent,r.innerHTML,s,e)},50)}function Cl(t,e,n,r,s){let i=nC(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,s,i||Ue.empty)))return!0;if(!i)return!1;let o=hO(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function fC(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," "):""}pr.paste=(t,e)=>{let n=e;if(t.composing&&!Hs)return;let r=Nl?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Cl(t,fC(r),r.getData("text/html"),s,n)?n.preventDefault():pO(t,n)};class hC{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const mO=qr?"altKey":"ctrlKey";function pC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[mO]}hr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(qd(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ut?s.to-1:s.to))){if(r&&r.mightDrag)o=ut.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(o=ut.create(t.state.doc,m.posBefore))}}let l=(o||t.state.selection).content(),{dom:d,text:f,slice:h}=yv(t,l);(!n.dataTransfer.files.length||!Qn||$N>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Nl?"Text":"text/html",d.innerHTML),n.dataTransfer.effectAllowed="copyMove",Nl||n.dataTransfer.setData("text/plain",f),t.dragging=new hC(h,pC(t,n),o)};hr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};pr.dragover=pr.dragenter=(t,e)=>e.preventDefault();pr.drop=(t,e)=>{try{gO(t,e,t.dragging)}finally{t.dragging=null}};function gO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(qd(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",v=>{i=v(i,t,!1)}):i=nC(t,fC(e.dataTransfer),Nl?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&pC(t,e));if(t.someProp("handleDrop",v=>v(t,e,i||Ue.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?yN(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let d=t.state.tr;if(o){let{node:v}=n;v?v.replace(d):d.deleteSelection()}let f=d.mapping.map(l),h=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=d.doc;if(h?d.replaceRangeWith(f,f,i.content.firstChild):d.replaceRange(f,f,i),d.doc.eq(m))return;let g=d.doc.resolve(f);if(h&&ut.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))d.setSelection(new ut(g));else{let v=d.mapping.map(l);d.mapping.maps[d.mapping.maps.length-1].forEach((x,k,w,S)=>v=S),d.setSelection(vv(t,g,d.doc.resolve(v)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}hr.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())&&qs(t)},20))};hr.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)};hr.beforeinput=(t,e)=>{if(Qn&&Hs&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,no(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in pr)hr[t]=pr[t];function _l(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 Ju{constructor(e,n){this.toDOM=e,this.spec=n||uo,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new qt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ju&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_l(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ti{constructor(e,n){this.attrs=e,this.spec=n||uo}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new qt(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ti&&_l(this.attrs,e.attrs)&&_l(this.spec,e.spec)}static is(e){return e.type instanceof Ti}destroy(){}}class kv{constructor(e,n){this.attrs=e,this.spec=n||uo}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new qt(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof kv&&_l(this.attrs,e.attrs)&&_l(this.spec,e.spec)}destroy(){}}class qt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new qt(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 qt(e,e,new Ju(n,r))}static inline(e,n,r,s){return new qt(e,n,new Ti(r,s))}static node(e,n,r,s){return new qt(e,n,new kv(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ti}get widget(){return this.type instanceof Ju}}const Zo=[],uo={};class It{constructor(e,n){this.local=e.length?e:Zo,this.children=n.length?n:Zo}static create(e,n){return n.length?Yu(n,e,0,uo):sr}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==sr||e.maps.length==0?this:this.mapInner(e,n,0,0,r||uo)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let d=this.local[l].map(e,r,s);d&&d.type.valid(n,d)?(o||(o=[])).push(d):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?vO(this.children,o||[],e,n,r,s,i):o?new It(o.sort(fo),Zo):sr}add(e,n){return n.length?this==sr?It.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,d)=>{let f=d+r,h;if(h=gC(n,l,f)){for(s||(s=this.children.slice());i<s.length&&s[i]<d;)i+=3;s[i]==d?s[i+2]=s[i+2].addInner(l,h,f+1):s.splice(i,0,d,d+l.nodeSize,Yu(h,l,f+1,uo)),i+=3}});let o=mC(i?vC(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new It(o.length?this.local.concat(o).sort(fo):this.local,s||this.children)}remove(e){return e.length==0||this==sr?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,d=r[i+1]+n;for(let h=0,m;h<e.length;h++)(m=e[h])&&m.from>l&&m.to<d&&(e[h]=null,(o||(o=[])).push(m));if(!o)continue;r==this.children&&(r=this.children.slice());let f=r[i+2].removeInner(o,l+1);f!=sr?r[i+2]=f:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new It(s,r):sr}forChild(e,n){if(this==sr)return this;if(n.isLeaf)return It.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let d=this.local[l];if(d.from<o&&d.to>i&&d.type instanceof Ti){let f=Math.max(i,d.from)-i,h=Math.min(o,d.to)-i;f<h&&(s||(s=[])).push(d.copy(f,h))}}if(s){let l=new It(s.sort(fo),Zo);return r?new bi([l,r]):l}return r||sr}eq(e){if(this==e)return!0;if(!(e instanceof It)||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 Sv(this.localsInner(e))}localsInner(e){if(this==sr)return Zo;if(e.inlineContent||!this.local.some(Ti.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ti||n.push(this.local[r]);return n}forEachSet(e){e(this)}}It.empty=new It([],[]);It.removeOverlap=Sv;const sr=It.empty;class bi{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,uo));return bi.from(r)}forChild(e,n){if(n.isLeaf)return It.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=sr&&(i instanceof bi?r=r.concat(i.members):r.push(i))}return bi.from(r)}eq(e){if(!(e instanceof bi)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?Sv(r?n:n.sort(fo)):Zo}static from(e){switch(e.length){case 0:return sr;case 1:return e[0];default:return new bi(e.every(n=>n instanceof It)?e:e.reduce((n,r)=>n.concat(r instanceof It?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function vO(t,e,n,r,s,i,o){let l=t.slice();for(let f=0,h=i;f<n.maps.length;f++){let m=0;n.maps[f].forEach((g,v,x,k)=>{let w=k-x-(v-g);for(let S=0;S<l.length;S+=3){let N=l[S+1];if(N<0||g>N+h-m)continue;let T=l[S]+h-m;v>=T?l[S+1]=g<=T?-2:-1:g>=h&&w&&(l[S]+=w,l[S+1]+=w)}m+=w}),h=n.maps[f].map(h,-1)}let d=!1;for(let f=0;f<l.length;f+=3)if(l[f+1]<0){if(l[f+1]==-2){d=!0,l[f+1]=-1;continue}let h=n.map(t[f]+i),m=h-s;if(m<0||m>=r.content.size){d=!0;continue}let g=n.map(t[f+1]+i,-1),v=g-s,{index:x,offset:k}=r.content.findIndex(m),w=r.maybeChild(x);if(w&&k==m&&k+w.nodeSize==v){let S=l[f+2].mapInner(n,w,h+1,t[f]+i+1,o);S!=sr?(l[f]=m,l[f+1]=v,l[f+2]=S):(l[f+1]=-2,d=!0)}else d=!0}if(d){let f=yO(l,t,e,n,s,i,o),h=Yu(f,r,0,o);e=h.local;for(let m=0;m<l.length;m+=3)l[m+1]<0&&(l.splice(m,3),m-=3);for(let m=0,g=0;m<h.children.length;m+=3){let v=h.children[m];for(;g<l.length&&l[g]<v;)g+=3;l.splice(g,0,h.children[m],h.children[m+1],h.children[m+2])}}return new It(e.sort(fo),l)}function mC(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new qt(s.from+e,s.to+e,s.type))}return n}function yO(t,e,n,r,s,i,o){function l(d,f){for(let h=0;h<d.local.length;h++){let m=d.local[h].map(r,s,f);m?n.push(m):o.onRemove&&o.onRemove(d.local[h].spec)}for(let h=0;h<d.children.length;h+=3)l(d.children[h+2],d.children[h]+f+1)}for(let d=0;d<t.length;d+=3)t[d+1]==-1&&l(t[d+2],e[d]+i+1);return n}function gC(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function vC(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Yu(t,e,n,r){let s=[],i=!1;e.forEach((l,d)=>{let f=gC(t,l,d+n);if(f){i=!0;let h=Yu(f,l,n+d+1,r);h!=sr&&s.push(d,d+l.nodeSize,h)}});let o=mC(i?vC(t):t,-n).sort(fo);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new It(o,s):sr}function fo(t,e){return t.from-e.from||t.to-e.to}function Sv(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),qx(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),qx(e,s,r.copy(i.from,r.to)));break}}}return e}function qx(t,e,n){for(;e<t.length&&fo(n,t[e])>0;)e++;t.splice(e,0,n)}function lp(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=sr&&e.push(r)}),t.cursorWrapper&&e.push(It.create(t.state.doc,[t.cursorWrapper.deco])),bi.from(e)}const bO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},xO=Sr&&Ci<=11;class wO{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 kO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new wO,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Sr&&Ci<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():ir&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),xO&&(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,bO)),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(Bx(this.view)){if(this.suppressingSelectionUpdates)return qs(this.view);if(Sr&&Ci<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&go(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=da(i))n.add(i);for(let i=e.anchorNode;i;i=da(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Bx(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,d=[];if(e.editable)for(let h=0;h<n.length;h++){let m=this.registerMutation(n[h],d);m&&(i=i<0?m.from:Math.min(m.from,i),o=o<0?m.to:Math.max(m.to,o),m.typeOver&&(l=!0))}if(d.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let h of d)if(h.nodeName=="BR"&&h.parentNode){let m=h.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&h.parentNode.removeChild(h)}}else if(Gr&&d.length){let h=d.filter(m=>m.nodeName=="BR");if(h.length==2){let[m,g]=h;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of h){let v=g.parentNode;v&&v.nodeName=="LI"&&(!m||NO(e,m)!=v)&&g.remove()}}}let f=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Wd(r)&&(f=gv(e))&&f.eq(yt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,qs(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),SO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,CO(e,d)),this.handleDOMChange(i,o,l,d),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||qs(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let m=e.addedNodes[h];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Sr&&Ci<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:m,nextSibling:g}=e.addedNodes[h];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(i=g)}let o=s&&s.parentNode==e.target?Yn(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),d=i&&i.parentNode==e.target?Yn(i):e.target.childNodes.length,f=r.localPosFromDOM(e.target,d,1);return{from:l,to:f}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Kx=new WeakMap,Gx=!1;function SO(t){if(!Kx.has(t)&&(Kx.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Gr,Gx)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."),Gx=!0}}function Jx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return go(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function EO(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Jx(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Jx(t,n):null}function NO(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 CO(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let d=l.firstChild;if(!d||d.nodeType!=1||d.contentEditable=="false"||/^(BR|IMG)$/.test(d.nodeName))break;l=d}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function _O(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),d=t.domSelectionRange(),f,h=d.anchorNode;if(h&&t.dom.contains(h.nodeType==1?h:h.parentNode)&&(f=[{node:h,offset:d.anchorOffset}],Wd(d)||f.push({node:d.focusNode,offset:d.focusOffset})),Qn&&t.input.lastKeyCode===8)for(let w=i;w>s;w--){let S=r.childNodes[w-1],N=S.pmViewDesc;if(S.nodeName=="BR"&&!N){i=w;break}if(!N||N.size)break}let m=t.state.doc,g=t.someProp("domParser")||dl.fromSchema(t.state.schema),v=m.resolve(o),x=null,k=g.parse(r,{topNode:v.parent,topMatch:v.parent.contentMatchAt(v.index()),topOpen:!0,from:s,to:i,preserveWhitespace:v.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:TO,context:v});if(f&&f[0].pos!=null){let w=f[0].pos,S=f[1]&&f[1].pos;S==null&&(S=w),x={anchor:w+o,head:S+o}}return{doc:k,sel:x,from:o,to:l}}function TO(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ir&&/^(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||ir&&/^(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 jO=/^(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 MO(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let I=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,$=gv(t,I);if($&&!t.state.selection.eq($)){if(Qn&&Hs&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",z=>z(t,no(13,"Enter"))))return;let P=t.state.tr.setSelection($);I=="pointer"?P.setMeta("pointer",!0):I=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),t.dispatch(P)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let d=t.state.selection,f=_O(t,e,n),h=t.state.doc,m=h.slice(f.from,f.to),g,v;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,v="end"):(g=t.state.selection.from,v="start"),t.input.lastKeyCode=null;let x=OO(m.content,f.doc.content,f.from,g,v);if(x&&t.input.domChangeCount++,(fa&&t.input.lastIOSEnter>Date.now()-225||Hs)&&s.some(I=>I.nodeType==1&&!jO.test(I.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",I=>I(t,no(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&d instanceof ft&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))x={start:d.from,endA:d.to,endB:d.to};else{if(f.sel){let I=Yx(t,t.state.doc,f.sel);if(I&&!I.eq(t.state.selection)){let $=t.state.tr.setSelection(I);i&&$.setMeta("composition",i),t.dispatch($)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof ft&&(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)),Sr&&Ci<=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 k=f.doc.resolveNoCache(x.start-f.from),w=f.doc.resolveNoCache(x.endB-f.from),S=h.resolve(x.start),N=k.sameParent(w)&&k.parent.inlineContent&&S.end()>=x.endA;if((fa&&t.input.lastIOSEnter>Date.now()-225&&(!N||s.some(I=>I.nodeName=="DIV"||I.nodeName=="P"))||!N&&k.pos<f.doc.content.size&&(!k.sameParent(w)||!k.parent.inlineContent)&&k.pos<w.pos&&!/\S/.test(f.doc.textBetween(k.pos,w.pos,"","")))&&t.someProp("handleKeyDown",I=>I(t,no(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&RO(h,x.start,x.endA,k,w)&&t.someProp("handleKeyDown",I=>I(t,no(8,"Backspace")))){Hs&&Qn&&t.domObserver.suppressSelectionUpdates();return}Qn&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Hs&&!N&&k.start()!=w.start()&&w.parentOffset==0&&k.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(I){return I(t,no(13,"Enter"))})},20));let T=x.start,M=x.endA,_=I=>{let $=I||t.state.tr.replace(T,M,f.doc.slice(x.start-f.from,x.endB-f.from));if(f.sel){let P=Yx(t,$.doc,f.sel);P&&!(Qn&&t.composing&&P.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(P.head==T||P.head==$.mapping.map(M)-1)||Sr&&P.empty&&P.head==T)&&$.setSelection(P)}return i&&$.setMeta("composition",i),$.scrollIntoView()},R;if(N)if(k.pos==w.pos){Sr&&Ci<=11&&k.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>qs(t),20));let I=_(t.state.tr.delete(T,M)),$=h.resolve(x.start).marksAcross(h.resolve(x.endA));$&&I.ensureMarks($),t.dispatch(I)}else if(x.endA==x.endB&&(R=AO(k.parent.content.cut(k.parentOffset,w.parentOffset),S.parent.content.cut(S.parentOffset,x.endA-S.start())))){let I=_(t.state.tr);R.type=="add"?I.addMark(T,M,R.mark):I.removeMark(T,M,R.mark),t.dispatch(I)}else if(k.parent.child(k.index()).isText&&k.index()==w.index()-(w.textOffset?0:1)){let I=k.parent.textBetween(k.parentOffset,w.parentOffset),$=()=>_(t.state.tr.insertText(I,T,M));t.someProp("handleTextInput",P=>P(t,T,M,I,$))||t.dispatch($())}else t.dispatch(_());else t.dispatch(_())}function Yx(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:vv(t,e.resolve(n.anchor),e.resolve(n.head))}function AO(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,d;for(let h=0;h<r.length;h++)s=r[h].removeFromSet(s);for(let h=0;h<n.length;h++)i=n[h].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",d=h=>h.mark(l.addToSet(h.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",d=h=>h.mark(l.removeFromSet(h.marks));else return null;let f=[];for(let h=0;h<e.childCount;h++)f.push(d(e.child(h)));if(we.from(f).eq(t))return{mark:l,type:o}}function RO(t,e,n,r,s){if(n-e<=s.pos-r.pos||cp(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(cp(i,!0,!0));return!o.parent.isTextblock||o.pos>n||cp(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function cp(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function OO(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let d=Math.max(0,i-Math.min(o,l));r-=o+d-i}if(o<i&&t.size<e.size){let d=r<=i&&r>=o?i-r:0;i-=d,i&&i<e.size&&Xx(e.textBetween(i-1,i+1))&&(i+=d?1:-1),l=i+(l-o),o=i}else if(l<i){let d=r<=i&&r>=l?i-r:0;i-=d,i&&i<t.size&&Xx(t.textBetween(i-1,i+1))&&(i+=d?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Xx(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 yC{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 JR,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(nw),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=ew(this),Zx(this),this.nodeViews=tw(this),this.docView=Rx(this.state.doc,Qx(this),lp(this),this.dom,this),this.domObserver=new kO(this,(r,s,i,o)=>MO(this,r,s,i,o)),this.domObserver.start(),YR(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&&jg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(nw),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(dC(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let v=tw(this);LO(v,this.nodeViews)&&(this.nodeViews=v,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&jg(this),this.editable=ew(this),Zx(this);let d=lp(this),f=Qx(this),h=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,f,d);(m||!e.selection.eq(s.selection))&&(o=!0);let g=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&uR(this);if(o){this.domObserver.stop();let v=m&&(Sr||Qn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&IO(s.selection,e.selection);if(m){let x=Qn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=uO(this)),(i||!this.docView.update(e.doc,f,d,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Rx(e.doc,f,d,this.dom,this)),x&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(v=!0)}v||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&IR(this))?qs(this,v):(ZN(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():g&&dR(g)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof ut){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Cx(this,n.getBoundingClientRect(),e)}else Cx(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new hC(e.slice,e.move,s<0?void 0:ut.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Sr){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&&fR(this.dom),qs(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 vR(this,e)}coordsAtPos(e,n=1){return VN(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return kR(this,n||this.state,e)}pasteHTML(e,n){return Cl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Cl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return yv(this,e)}destroy(){this.docView&&(XR(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],lp(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,eR())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ZR(this,e)}domSelectionRange(){let e=this.domSelection();return e?ir&&this.root.nodeType===11&&iR(this.dom.ownerDocument)==this.dom&&EO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}yC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Qx(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"),[qt.node(0,t.state.doc.content.size,e)]}function Zx(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:qt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ew(t){return!t.someProp("editable",e=>e(t.state)===!1)}function IO(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 tw(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function LO(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function nw(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 Ai={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:"'"},Xu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},DO=typeof navigator<"u"&&/Mac/.test(navigator.platform),PO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Xn=0;Xn<10;Xn++)Ai[48+Xn]=Ai[96+Xn]=String(Xn);for(var Xn=1;Xn<=24;Xn++)Ai[Xn+111]="F"+Xn;for(var Xn=65;Xn<=90;Xn++)Ai[Xn]=String.fromCharCode(Xn+32),Xu[Xn]=String.fromCharCode(Xn);for(var up in Ai)Xu.hasOwnProperty(up)||(Xu[up]=Ai[up]);function BO(t){var e=DO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||PO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Xu:Ai)[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 $O=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),FO=typeof navigator<"u"&&/Win/.test(navigator.platform);function zO(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let d=e[l];if(/^(cmd|meta|m)$/i.test(d))o=!0;else if(/^a(lt)?$/i.test(d))r=!0;else if(/^(c|ctrl|control)$/i.test(d))s=!0;else if(/^s(hift)?$/i.test(d))i=!0;else if(/^mod$/i.test(d))$O?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+d)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function UO(t){let e=Object.create(null);for(let n in t)e[zO(n)]=t[n];return e}function dp(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 HO(t){return new Ut({props:{handleKeyDown:Ev(t)}})}function Ev(t){let e=UO(t);return function(n,r){let s=BO(r),i,o=e[dp(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[dp(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(FO&&r.ctrlKey&&r.altKey)&&(i=Ai[r.keyCode])&&i!=s){let l=e[dp(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var WO=Object.defineProperty,Nv=(t,e)=>{for(var n in e)WO(t,n,{get:e[n],enumerable:!0})};function Kd(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var Gd=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...f)=>{const h=l(...f)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,d=t||s.tr,f=()=>(!l&&e&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(d),o.every(m=>m===!0)),h={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...x)=>{const k=this.buildProps(d,e),w=g(...x)(k);return o.push(w),h}])),run:f};return h}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,d])=>[l,(...f)=>d(...f)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:Kd({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,d])=>[l,(...f)=>d(...f)(o)]))}};return o}},bC={};Nv(bC,{blur:()=>VO,clearContent:()=>qO,clearNodes:()=>KO,command:()=>GO,createParagraphNear:()=>JO,cut:()=>YO,deleteCurrentNode:()=>XO,deleteNode:()=>QO,deleteRange:()=>ZO,deleteSelection:()=>eI,enter:()=>tI,exitCode:()=>nI,extendMarkRange:()=>rI,first:()=>sI,focus:()=>oI,forEach:()=>aI,insertContent:()=>lI,insertContentAt:()=>dI,joinBackward:()=>pI,joinDown:()=>hI,joinForward:()=>mI,joinItemBackward:()=>gI,joinItemForward:()=>vI,joinTextblockBackward:()=>yI,joinTextblockForward:()=>bI,joinUp:()=>fI,keyboardShortcut:()=>wI,lift:()=>kI,liftEmptyBlock:()=>SI,liftListItem:()=>EI,newlineInCode:()=>NI,resetAttributes:()=>CI,scrollIntoView:()=>_I,selectAll:()=>TI,selectNodeBackward:()=>jI,selectNodeForward:()=>MI,selectParentNode:()=>AI,selectTextblockEnd:()=>RI,selectTextblockStart:()=>OI,setContent:()=>II,setMark:()=>QI,setMeta:()=>ZI,setNode:()=>eL,setNodeSelection:()=>tL,setTextDirection:()=>nL,setTextSelection:()=>rL,sinkListItem:()=>sL,splitBlock:()=>iL,splitListItem:()=>oL,toggleList:()=>aL,toggleMark:()=>lL,toggleNode:()=>cL,toggleWrap:()=>uL,undoInputRule:()=>dL,unsetAllMarks:()=>fL,unsetMark:()=>hL,unsetTextDirection:()=>pL,updateAttributes:()=>mL,wrapIn:()=>gL,wrapInList:()=>vL});var VO=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),qO=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),KO=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,d)=>{if(l.type.isText)return;const{doc:f,mapping:h}=e,m=f.resolve(h.map(d)),g=f.resolve(h.map(d+l.nodeSize)),v=m.blockRange(g);if(!v)return;const x=va(v);if(l.type.isTextblock){const{defaultType:k}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(v.start,k)}(x||x===0)&&e.lift(v,x)})}),!0},GO=t=>e=>t(e),JO=()=>({state:t,dispatch:e})=>IN(t,e),YO=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new ft(r.doc.resolve(Math.max(o-1,0)))),!0},XO=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),d=s.after(i);t.delete(l,d).scrollIntoView()}return!0}return!1};function Tn(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 QO=t=>({tr:e,state:n,dispatch:r})=>{const s=Tn(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const d=i.before(o),f=i.after(o);e.delete(d,f).scrollIntoView()}return!0}return!1},ZO=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},eI=()=>({state:t,dispatch:e})=>uv(t,e),tI=()=>({commands:t})=>t.keyboardShortcut("Enter"),nI=()=>({state:t,dispatch:e})=>$A(t,e);function Cv(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Qu(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Cv(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function xC(t,e,n={}){return t.find(r=>r.type===e&&Qu(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function rw(t,e,n={}){return!!xC(t,e,n)}function _v(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(h=>h.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(h=>h.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!xC([...s.node.marks],e,n)))return;let o=s.index,l=t.start()+s.offset,d=o+1,f=l+s.node.nodeSize;for(;o>0&&rw([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;d<t.parent.childCount&&rw([...t.parent.child(d).marks],e,n);)f+=t.parent.child(d).nodeSize,d+=1;return{from:l,to:f}}function Ks(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 rI=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=Ks(t,r.schema),{doc:o,selection:l}=n,{$from:d,from:f,to:h}=l;if(s){const m=_v(d,i,e);if(m&&m.from<=f&&m.to>=h){const g=ft.create(o,m.from,m.to);n.setSelection(g)}}return!0},sI=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 wC(t){return t instanceof ft}function io(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function kC(t,e=null){if(!e)return null;const n=yt.atStart(t),r=yt.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?ft.create(t,io(0,s,i),io(t.content.size,s,i)):ft.create(t,io(e,s,i),io(e,s,i))}function Mg(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Tl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function iI(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var oI=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Tl()||Mg())&&r.dom.focus(),iI()&&!Tl()&&!Mg()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!wC(n.state.selection))return o(),!0;const l=kC(s.doc,t)||n.state.selection,d=n.state.selection.eq(l);return i&&(d||s.setSelection(l),d&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},aI=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),lI=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),SC=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&&SC(r)}return t};function Zc(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 SC(n)}function jl(t,e,n){if(t instanceof ls||t instanceof we)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return we.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),jl("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const d=new aN({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:f=>(o=!0,l=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?dl.fromSchema(d).parseSlice(Zc(t),n.parseOptions):dl.fromSchema(d).parse(Zc(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=dl.fromSchema(e);return n.slice?i.parseSlice(Zc(t),n.parseOptions).content:i.parse(Zc(t),n.parseOptions)}return jl("",e,n)}function cI(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Pn||s instanceof Bn))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,d,f,h)=>{o===0&&(o=h)}),t.setSelection(yt.near(t.doc.resolve(o),n))}var uI=t=>!("type"in t),dI=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const d=w=>{i.emit("contentError",{editor:i,error:w,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{jl(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(w){d(w)}try{l=jl(e,i.schema,{parseOptions:f,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(w){return d(w),!1}let{from:h,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,v=!0;if((uI(l)?l:[l]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,v=v?w.isBlock:!1}),h===m&&v){const{parent:w}=r.doc.resolve(h);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(h-=1,m+=1)}let k;if(g){if(Array.isArray(e))k=e.map(w=>w.text||"").join("");else if(e instanceof we){let w="";e.forEach(S=>{S.text&&(w+=S.text)}),k=w}else typeof e=="object"&&e&&e.text?k=e.text:k=e;r.insertText(k,h,m)}else{k=l;const w=r.doc.resolve(h),S=w.node(),N=w.parentOffset===0,T=S.isText||S.isTextblock,M=S.content.size>0;N&&T&&M&&(h=Math.max(0,h-1)),r.replaceWith(h,m,k)}n.updateSelection&&cI(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:k}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:k})}return!0},fI=()=>({state:t,dispatch:e})=>DA(t,e),hI=()=>({state:t,dispatch:e})=>PA(t,e),pI=()=>({state:t,dispatch:e})=>_N(t,e),mI=()=>({state:t,dispatch:e})=>AN(t,e),gI=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zd(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},vI=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zd(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},yI=()=>({state:t,dispatch:e})=>IA(t,e),bI=()=>({state:t,dispatch:e})=>LA(t,e);function EC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xI(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const d=e[l];if(/^(cmd|meta|m)$/i.test(d))o=!0;else if(/^a(lt)?$/i.test(d))r=!0;else if(/^(c|ctrl|control)$/i.test(d))s=!0;else if(/^s(hift)?$/i.test(d))i=!0;else if(/^mod$/i.test(d))Tl()||EC()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${d}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var wI=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=xI(t).split(/-(?!$)/),o=i.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),d=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,l))});return d==null||d.steps.forEach(f=>{const h=f.map(r.mapping);h&&s&&r.maybeStep(h)}),!0};function Ri(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Tn(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(m,g)=>{if(m.isText)return;const v=Math.max(r,g),x=Math.min(s,g+m.nodeSize);l.push({node:m,from:v,to:x})});const d=s-r,f=l.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Qu(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=d}var kI=(t,e={})=>({state:n,dispatch:r})=>{const s=Tn(t,n.schema);return Ri(n,s,e)?BA(n,r):!1},SI=()=>({state:t,dispatch:e})=>LN(t,e),EI=t=>({state:e,dispatch:n})=>{const r=Tn(t,e.schema);return YA(r)(e,n)},NI=()=>({state:t,dispatch:e})=>ON(t,e);function Jd(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function sw(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var CI=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Jd(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Tn(t,r.schema)),l==="mark"&&(o=Ks(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(h,m)=>{i&&i===h.type&&(d=!0,s&&n.setNodeMarkup(m,void 0,sw(h.attrs,e))),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&(d=!0,s&&n.addMark(m,m+h.nodeSize,o.create(sw(g.attrs,e))))})})}),d},_I=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),TI=()=>({tr:t,dispatch:e})=>{if(e){const n=new Rr(t.doc);t.setSelection(n)}return!0},jI=()=>({state:t,dispatch:e})=>jN(t,e),MI=()=>({state:t,dispatch:e})=>RN(t,e),AI=()=>({state:t,dispatch:e})=>UA(t,e),RI=()=>({state:t,dispatch:e})=>VA(t,e),OI=()=>({state:t,dispatch:e})=>WA(t,e);function Ag(t,e,n={},r={}){return jl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var II=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:d}=i;if(r.preserveWhitespace!=="full"){const f=Ag(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,d.content.size,f).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:d.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function NC(t,e){const n=Ks(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,d=>{o.push(...d.marks)});const l=o.find(d=>d.type.name===n.name);return l?{...l.attrs}:{}}function Tv(t,e){const n=new lv(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function LI(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 Zu(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function CC(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function _C(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 Yd(t){return e=>_C(e.$from,t)}function ct(t,e,n){return t.config[e]===void 0&&t.parent?ct(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?ct(t.parent,e,n):null}):t.config[e]}function jv(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=ct(e,"addExtensions",n);return r?[e,...jv(r())]:e}).flat(10)}function Mv(t,e){const n=wo.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function TC(t){return typeof t=="function"}function Gt(t,e=void 0,...n){return TC(t)?e?t.bind(e)(...n):t(...n):t}function DI(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ha(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function jC(t){const e=[],{nodeExtensions:n,markExtensions:r}=ha(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},d=ct(o,"addGlobalAttributes",l);if(!d)return;d().forEach(h=>{h.types.forEach(m=>{Object.entries(h.attributes).forEach(([g,v])=>{e.push({type:m,name:g,attribute:{...i,...v}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},d=ct(o,"addAttributes",l);if(!d)return;const f=d();Object.entries(f).forEach(([h,m])=>{const g={...i,...m};typeof(g==null?void 0:g.default)=="function"&&(g.default=g.default()),g!=null&&g.isRequired&&(g==null?void 0:g.default)===void 0&&delete g.default,e.push({type:o.name,name:h,attribute:g})})}),e}function zt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],d=r[s]?r[s].split(" "):[],f=l.filter(h=>!d.includes(h));r[s]=[...d,...f].join(" ")}else if(s==="style"){const l=i?i.split(";").map(h=>h.trim()).filter(Boolean):[],d=r[s]?r[s].split(";").map(h=>h.trim()).filter(Boolean):[],f=new Map;d.forEach(h=>{const[m,g]=h.split(":").map(v=>v.trim());f.set(m,g)}),l.forEach(h=>{const[m,g]=h.split(":").map(v=>v.trim());f.set(m,g)}),r[s]=Array.from(f.entries()).map(([h,m])=>`${h}: ${m}`).join("; ")}else r[s]=i}),r},{})}function pa(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)=>zt(n,r),{})}function PI(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function iw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):PI(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function ow(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&DI(n)?!1:n!=null))}function aw(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 BI(t,e){var n;const r=jC(t),{nodeExtensions:s,markExtensions:i}=ha(t),o=(n=s.find(f=>ct(f,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(f=>{const h=r.filter(S=>S.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((S,N)=>{const T=ct(N,"extendNodeSchema",m);return{...S,...T?T(f):{}}},{}),v=ow({...g,content:Gt(ct(f,"content",m)),marks:Gt(ct(f,"marks",m)),group:Gt(ct(f,"group",m)),inline:Gt(ct(f,"inline",m)),atom:Gt(ct(f,"atom",m)),selectable:Gt(ct(f,"selectable",m)),draggable:Gt(ct(f,"draggable",m)),code:Gt(ct(f,"code",m)),whitespace:Gt(ct(f,"whitespace",m)),linebreakReplacement:Gt(ct(f,"linebreakReplacement",m)),defining:Gt(ct(f,"defining",m)),isolating:Gt(ct(f,"isolating",m)),attrs:Object.fromEntries(h.map(aw))}),x=Gt(ct(f,"parseHTML",m));x&&(v.parseDOM=x.map(S=>iw(S,h)));const k=ct(f,"renderHTML",m);k&&(v.toDOM=S=>k({node:S,HTMLAttributes:pa(S,h)}));const w=ct(f,"renderText",m);return w&&(v.toText=w),[f.name,v]})),d=Object.fromEntries(i.map(f=>{const h=r.filter(w=>w.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((w,S)=>{const N=ct(S,"extendMarkSchema",m);return{...w,...N?N(f):{}}},{}),v=ow({...g,inclusive:Gt(ct(f,"inclusive",m)),excludes:Gt(ct(f,"excludes",m)),group:Gt(ct(f,"group",m)),spanning:Gt(ct(f,"spanning",m)),code:Gt(ct(f,"code",m)),attrs:Object.fromEntries(h.map(aw))}),x=Gt(ct(f,"parseHTML",m));x&&(v.parseDOM=x.map(w=>iw(w,h)));const k=ct(f,"renderHTML",m);return k&&(v.toDOM=w=>k({mark:w,HTMLAttributes:pa(w,h)})),[f.name,v]}));return new aN({topNode:o,nodes:l,marks:d})}function $I(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function ed(t){return t.sort((n,r)=>{const s=ct(n,"priority")||100,i=ct(r,"priority")||100;return s>i?-1:s<i?1:0})}function MC(t){const e=ed(jv(t)),n=$I(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 AC(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
58
-
59
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(d,f,h,m)=>{var g;d.isBlock&&f>r&&(l+=i);const v=o==null?void 0:o[d.type.name];if(v)return h&&(l+=v({node:d,pos:f,parent:h,index:m,range:e})),!1;d.isText&&(l+=(g=d==null?void 0:d.text)==null?void 0:g.slice(Math.max(r,f)-f,s-f))}),l}function FI(t,e){const n={from:0,to:t.content.size};return AC(t,n,e)}function RC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function zI(t,e){const n=Tn(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function OC(t,e){const n=Jd(typeof e=="string"?e:e.name,t.schema);return n==="node"?zI(t,e):n==="mark"?NC(t,e):{}}function UI(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function HI(t){const e=UI(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Av(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,d)=>{o.push({from:l,to:d})});else{const{from:l,to:d}=n[i];if(l===void 0||d===void 0)return;o.push({from:l,to:d})}o.forEach(({from:l,to:d})=>{const f=e.slice(i).map(l,-1),h=e.slice(i).map(d),m=e.invert().map(f,-1),g=e.invert().map(h);r.push({oldRange:{from:m,to:g},newRange:{from:f,to:h}})})}),HI(r)}function Rv(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=_v(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var WI=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);(l==null?void 0:l.type.name)===e?o=l:i-=1}return[o,i]};function eu(t,e){return e.nodes[t]||e.marks[t]||null}function Iu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var VI=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var d,f;const h=((f=(d=s.type.spec).toText)==null?void 0:f.call(d,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?h:h.slice(0,Math.max(0,r-i))}),n};function Rg(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Ks(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Qu(m.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:m,$to:g})=>{const v=m.pos,x=g.pos;t.doc.nodesBetween(v,x,(k,w)=>{if(!k.isText&&!k.marks.length)return;const S=Math.max(v,w),N=Math.min(x,w+k.nodeSize),T=N-S;o+=T,l.push(...k.marks.map(M=>({mark:M,from:S,to:N})))})}),o===0)return!1;const d=l.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Qu(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),f=l.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,g)=>m+g.to-g.from,0);return(d>0?d+f:d)>=o}function qI(t,e,n={}){if(!e)return Ri(t,null,n)||Rg(t,null,n);const r=Jd(e,t.schema);return r==="node"?Ri(t,e,n):r==="mark"?Rg(t,e,n):!1}var KI=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Yd(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},GI=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function lw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function cw(t,e){const{nodeExtensions:n}=ha(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=Gt(ct(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Xd(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Xd(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function IC(t){return t instanceof ut}var LC=class DC{constructor(e){this.position=e}static fromJSON(e){return new DC(e.position)}toJSON(){return{position:this.position}}};function JI(t,e){const n=e.mapping.mapResult(t.position);return{position:new LC(n.pos),mapResult:n}}function YI(t){return new LC(t)}function XI(t,e,n){var r;const{selection:s}=e;let i=null;if(wC(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(f=>f.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:d})=>{let f=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,d.pos,(h,m,g)=>{if(f)return!1;if(h.isInline){const v=!g||g.type.allowsMarkType(n),x=!!n.isInSet(h.marks)||!h.marks.some(k=>k.type.excludes(n));f=v&&x}return!f}),f})}var QI=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,d=Ks(t,r.schema);if(s)if(o){const f=NC(r,d);n.addStoredMark(d.create({...f,...e}))}else l.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(h,m,(g,v)=>{const x=Math.max(v,h),k=Math.min(v+g.nodeSize,m);g.marks.find(S=>S.type===d)?g.marks.forEach(S=>{d===S.type&&n.addMark(x,k,d.create({...S.attrs,...e}))}):n.addMark(x,k,d.create(e))})});return XI(r,n,d)},ZI=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),eL=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Tn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>Sx(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>Sx(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},tL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=io(t,0,r.content.size),i=ut.create(r,s);e.setSelection(i)}return!0},nL=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(d,f)=>{d.isText||n.setNodeMarkup(f,void 0,{...d.attrs,dir:t})}),!0},rL=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=ft.atStart(r).from,l=ft.atEnd(r).to,d=io(s,o,l),f=io(i,o,l),h=ft.create(r,d,f);e.setSelection(h)}return!0},sL=t=>({state:e,dispatch:n})=>{const r=Tn(t,e.schema);return ZA(r)(e,n)};function uw(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var iL=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:d}=i,f=s.extensionManager.attributes,h=Iu(f,l.node().type.name,l.node().attrs);if(i instanceof ut&&i.node.isBlock)return!l.parentOffset||!Vs(o,l.pos)?!1:(r&&(t&&uw(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const m=d.parentOffset===d.parent.content.size,g=l.depth===0?void 0:LI(l.node(-1).contentMatchAt(l.indexAfter(-1)));let v=m&&g?[{type:g,attrs:h}]:void 0,x=Vs(e.doc,e.mapping.map(l.pos),1,v);if(!v&&!x&&Vs(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(x=!0,v=g?[{type:g,attrs:h}]:void 0),r){if(x&&(i instanceof ft&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,v),g&&!m&&!l.parentOffset&&l.parent.type!==g)){const k=e.mapping.map(l.before()),w=e.doc.resolve(k);l.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&uw(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return x},oL=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Tn(t,r.schema),{$from:d,$to:f}=r.selection,h=r.selection.node;if(h&&h.isBlock||d.depth<2||!d.sameParent(f))return!1;const m=d.node(-1);if(m.type!==l)return!1;const g=i.extensionManager.attributes;if(d.parent.content.size===0&&d.node(-1).childCount===d.indexAfter(-1)){if(d.depth===2||d.node(-3).type!==l||d.index(-2)!==d.node(-2).childCount-1)return!1;if(s){let S=we.empty;const N=d.index(-1)?1:d.index(-2)?2:3;for(let $=d.depth-N;$>=d.depth-3;$-=1)S=we.from(d.node($).copy(S));const T=d.indexAfter(-1)<d.node(-2).childCount?1:d.indexAfter(-2)<d.node(-3).childCount?2:3,M={...Iu(g,d.node().type.name,d.node().attrs),...e},_=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(M))||void 0;S=S.append(we.from(l.createAndFill(null,_)||void 0));const R=d.before(d.depth-(N-1));n.replace(R,d.after(-T),new Ue(S,4-N,0));let I=-1;n.doc.nodesBetween(R,n.doc.content.size,($,P)=>{if(I>-1)return!1;$.isTextblock&&$.content.size===0&&(I=P+1)}),I>-1&&n.setSelection(ft.near(n.doc.resolve(I))),n.scrollIntoView()}return!0}const v=f.pos===d.end()?m.contentMatchAt(0).defaultType:null,x={...Iu(g,m.type.name,m.attrs),...e},k={...Iu(g,d.node().type.name,d.node().attrs),...e};n.delete(d.pos,f.pos);const w=v?[{type:l,attrs:x},{type:v,attrs:k}]:[{type:l,attrs:x}];if(!Vs(n.doc,d.pos,2))return!1;if(s){const{selection:S,storedMarks:N}=r,{splittableMarks:T}=i.extensionManager,M=N||S.$to.parentOffset&&S.$from.marks();if(n.split(d.pos,2,w).scrollIntoView(),!M||!s)return!0;const _=M.filter(R=>T.includes(R.type.name));n.ensureMarks(_)}return!0},fp=(t,e)=>{const n=Yd(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Li(t.doc,n.pos)&&t.join(n.pos),!0},hp=(t,e)=>{const n=Yd(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&Li(t.doc,r)&&t.join(r),!0},aL=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:d,commands:f,can:h})=>{const{extensions:m,splittableMarks:g}=s.extensionManager,v=Tn(t,o.schema),x=Tn(e,o.schema),{selection:k,storedMarks:w}=o,{$from:S,$to:N}=k,T=S.blockRange(N),M=w||k.$to.parentOffset&&k.$from.marks();if(!T)return!1;const _=Yd(R=>cw(R.type.name,m))(k);if(T.depth>=1&&_&&T.depth-_.depth<=1){if(_.node.type===v)return f.liftListItem(x);if(cw(_.node.type.name,m)&&v.validContent(_.node.content)&&l)return d().command(()=>(i.setNodeMarkup(_.pos,v),!0)).command(()=>fp(i,v)).command(()=>hp(i,v)).run()}return!n||!M||!l?d().command(()=>h().wrapInList(v,r)?!0:f.clearNodes()).wrapInList(v,r).command(()=>fp(i,v)).command(()=>hp(i,v)).run():d().command(()=>{const R=h().wrapInList(v,r),I=M.filter($=>g.includes($.type.name));return i.ensureMarks(I),R?!0:f.clearNodes()}).wrapInList(v,r).command(()=>fp(i,v)).command(()=>hp(i,v)).run()},lL=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Ks(t,r.schema);return Rg(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},cL=(t,e,n={})=>({state:r,commands:s})=>{const i=Tn(t,r.schema),o=Tn(e,r.schema),l=Ri(r,i,n);let d;return r.selection.$anchor.sameParent(r.selection.$head)&&(d=r.selection.$anchor.parent.attrs),l?s.setNode(o,d):s.setNode(i,{...d,...n})},uL=(t,e={})=>({state:n,commands:r})=>{const s=Tn(t,n.schema);return Ri(n,s,e)?r.lift(s):r.wrapIn(s,e)},dL=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let d=l.steps.length-1;d>=0;d-=1)o.step(l.steps[d].invert(l.docs[d]));if(i.text){const d=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,d))}else o.delete(i.from,i.to)}return!0}}return!1},fL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},hL=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,d=Ks(t,r.schema),{$from:f,empty:h,ranges:m}=l;if(!s)return!0;if(h&&o){let{from:g,to:v}=l;const x=(i=f.marks().find(w=>w.type===d))==null?void 0:i.attrs,k=_v(f,d,x);k&&(g=k.from,v=k.to),n.removeMark(g,v,d)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,d)});return n.removeStoredMark(d),!0},pL=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,d)=>{if(l.isText)return;const f={...l.attrs};delete f.dir,e.setNodeMarkup(d,void 0,f)}),!0},mL=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Jd(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Tn(t,r.schema)),l==="mark"&&(o=Ks(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let g,v,x,k;n.selection.empty?r.doc.nodesBetween(h,m,(w,S)=>{i&&i===w.type&&(d=!0,x=Math.max(S,h),k=Math.min(S+w.nodeSize,m),g=S,v=w)}):r.doc.nodesBetween(h,m,(w,S)=>{S<h&&i&&i===w.type&&(d=!0,x=Math.max(S,h),k=Math.min(S+w.nodeSize,m),g=S,v=w),S>=h&&S<=m&&(i&&i===w.type&&(d=!0,s&&n.setNodeMarkup(S,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(N=>{if(o===N.type&&(d=!0,s)){const T=Math.max(S,h),M=Math.min(S+w.nodeSize,m);n.addMark(T,M,o.create({...N.attrs,...e}))}}))}),v&&(g!==void 0&&s&&n.setNodeMarkup(g,void 0,{...v.attrs,...e}),o&&v.marks.length&&v.marks.forEach(w=>{o===w.type&&s&&n.addMark(x,k,o.create({...w.attrs,...e}))}))}),d},gL=(t,e={})=>({state:n,dispatch:r})=>{const s=Tn(t,n.schema);return qA(s,e)(n,r)},vL=(t,e={})=>({state:n,dispatch:r})=>{const s=Tn(t,n.schema);return KA(s,e)(n,r)},yL=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={}}},Fl=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},bL=(t,e)=>{if(Cv(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 tu(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:d}=n;if(d.composing)return!1;const f=d.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(g=>g.type.spec.code))return!1;let h=!1;const m=VI(f)+i;return o.forEach(g=>{if(h)return;const v=bL(m,g.find);if(!v)return;const x=d.state.tr,k=Kd({state:d.state,transaction:x}),w={from:r-(v[0].length-i.length),to:s},{commands:S,chain:N,can:T}=new Gd({editor:n,state:k});g.handler({state:k,range:w,match:v,commands:S,chain:N,can:T})===null||!x.steps.length||(g.undoable&&x.setMeta(l,{transform:x,from:r,to:s,text:i}),d.dispatch(x),h=!0)}),h}function xL(t){const{editor:e,rules:n}=t,r=new Ut({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const d=s.getMeta("applyInputRules");return!!d&&setTimeout(()=>{let{text:h}=d;typeof h=="string"?h=h:h=Mv(we.from(h),o.schema);const{from:m}=d,g=m+h.length;tu({editor:e,from:m,to:g,text:h,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return tu({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&tu({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?tu({editor:e,from:o.pos,to:o.pos,text:`
60
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function wL(t){return Object.prototype.toString.call(t).slice(8,-1)}function nu(t){return wL(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function PC(t,e){const n={...t};return nu(t)&&nu(e)&&Object.keys(e).forEach(r=>{nu(e[r])&&nu(t[r])?n[r]=PC(t[r],e[r]):n[r]=e[r]}),n}var Ov=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...Gt(ct(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Gt(ct(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>PC(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}},cs=class BC extends Ov{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new BC(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(f=>(f==null?void 0:f.type.name)===n.name))return!1;const d=o.find(f=>(f==null?void 0:f.type.name)===n.name);return d&&r.removeStoredMark(d),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function kL(t){return typeof t=="number"}var SL=class{constructor(t){this.find=t.find,this.handler=t.handler}},EL=(t,e,n)=>{if(Cv(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function NL(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:d,chain:f,can:h}=new Gd({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(v,x)=>{var k,w,S,N,T;if((w=(k=v.type)==null?void 0:k.spec)!=null&&w.code||!(v.isText||v.isTextblock||v.isInline))return;const M=(T=(N=(S=v.content)==null?void 0:S.size)!=null?N:v.nodeSize)!=null?T:0,_=Math.max(r,x),R=Math.min(s,x+M);if(_>=R)return;const I=v.isText?v.text||"":v.textBetween(_-x,R-x,void 0,"");EL(I,i.find,o).forEach(P=>{if(P.index===void 0)return;const z=_+P.index+1,q=z+P[0].length,F={from:n.tr.mapping.map(z),to:n.tr.mapping.map(q)},G=i.handler({state:n,range:F,match:P,commands:d,chain:f,can:h,pasteEvent:o,dropEvent:l});m.push(G)})}),m.every(v=>v!==null)}var ru=null,CL=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function _L(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const d=({state:h,from:m,to:g,rule:v,pasteEvt:x})=>{const k=h.tr,w=Kd({state:h,transaction:k});if(!(!NL({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:v,pasteEvent:x,dropEvent:l})||!k.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,k}};return n.map(h=>new Ut({view(m){const g=x=>{var k;r=(k=m.dom.parentElement)!=null&&k.contains(x.target)?m.dom.parentElement:null,r&&(ru=e)},v=()=>{ru&&(ru=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",v),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",v)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=r===m.dom.parentElement,l=g,!i){const v=ru;v!=null&&v.isEditable&&setTimeout(()=>{const x=v.state.selection;x&&v.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(m,g)=>{var v;const x=(v=g.clipboardData)==null?void 0:v.getData("text/html");return o=g,s=!!(x!=null&&x.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,v)=>{const x=m[0],k=x.getMeta("uiEvent")==="paste"&&!s,w=x.getMeta("uiEvent")==="drop"&&!i,S=x.getMeta("applyPasteRules"),N=!!S;if(!k&&!w&&!N)return;if(N){let{text:_}=S;typeof _=="string"?_=_:_=Mv(we.from(_),v.schema);const{from:R}=S,I=R+_.length,$=CL(_);return d({rule:h,state:v,from:R,to:{b:I},pasteEvt:$})}const T=g.doc.content.findDiffStart(v.doc.content),M=g.doc.content.findDiffEnd(v.doc.content);if(!(!kL(T)||!M||T===M.b))return d({rule:h,state:v,from:T,to:M,pasteEvt:o})}}))}var Qd=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=MC(t),this.schema=BI(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:eu(e.name,this.schema)},r=ct(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return ed([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:eu(r.name,this.schema)},i=[],o=ct(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&ct(r,"exitable",s)&&(l.ArrowRight=()=>cs.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([v,x])=>[v,()=>x({editor:t})]));l={...l,...g}}const d=HO(l);i.push(d);const f=ct(r,"addInputRules",s);if(lw(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const v=xL({editor:t,rules:g}),x=Array.isArray(v)?v:[v];i.push(...x)}}const h=ct(r,"addPasteRules",s);if(lw(r,t.options.enablePasteRules)&&h){const g=h();if(g&&g.length){const v=_L({editor:t,rules:g});i.push(...v)}}const m=ct(r,"addProseMirrorPlugins",s);if(m){const g=m();i.push(...g)}return i})}get attributes(){return jC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ha(this.extensions);return Object.fromEntries(e.filter(n=>!!ct(n,"addNodeView")).map(n=>{const r=this.attributes.filter(d=>d.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Tn(n.name,this.schema)},i=ct(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(d,f,h,m,g)=>{const v=pa(d,r);return o({node:d,view:f,getPos:h,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:v})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return ed([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:eu(s.name,this.schema)},o=ct(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=ha(this.extensions);return Object.fromEntries(e.filter(n=>!!ct(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ks(n.name,this.schema)},i=ct(n,"addMarkView",s);if(!i)return[];const o=(l,d,f)=>{const h=pa(l,r);return i()({mark:l,view:d,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{UL(l,t,m)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:eu(e.name,this.schema)};e.type==="mark"&&((n=Gt(ct(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=ct(e,"onBeforeCreate",r),i=ct(e,"onCreate",r),o=ct(e,"onUpdate",r),l=ct(e,"onSelectionUpdate",r),d=ct(e,"onTransaction",r),f=ct(e,"onFocus",r),h=ct(e,"onBlur",r),m=ct(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),d&&this.editor.on("transaction",d),f&&this.editor.on("focus",f),h&&this.editor.on("blur",h),m&&this.editor.on("destroy",m)})}};Qd.resolve=MC;Qd.sort=ed;Qd.flatten=jv;var TL={};Nv(TL,{ClipboardTextSerializer:()=>FC,Commands:()=>zC,Delete:()=>UC,Drop:()=>HC,Editable:()=>WC,FocusEvents:()=>qC,Keymap:()=>KC,Paste:()=>GC,Tabindex:()=>JC,TextDirection:()=>YC,focusEventsPluginKey:()=>VC});var Pt=class $C extends Ov{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new $C(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},FC=Pt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ut({key:new Jt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(h=>h.$from.pos)),l=Math.max(...i.map(h=>h.$to.pos)),d=RC(n);return AC(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),zC=Pt.create({name:"commands",addCommands(){return{...bC}}}),UC=Pt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,d,f;if((f=(d=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:d.call(l,t))!=null?f:t.getMeta("y-sync$"))return;const h=Tv(t.before,[t,...e]);Av(h).forEach(v=>{h.mapping.mapResult(v.oldRange.from).deletedAfter&&h.mapping.mapResult(v.oldRange.to).deletedBefore&&h.before.nodesBetween(v.oldRange.from,v.oldRange.to,(x,k)=>{const w=k+x.nodeSize-2,S=v.oldRange.from<=k&&w<=v.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:k,to:w,newFrom:h.mapping.map(k),newTo:h.mapping.map(w),deletedRange:v.oldRange,newRange:v.newRange,partial:!S,editor:this.editor,transaction:t,combinedTransform:h})})});const g=h.mapping;h.steps.forEach((v,x)=>{var k,w;if(v instanceof as){const S=g.slice(x).map(v.from,-1),N=g.slice(x).map(v.to),T=g.invert().map(S,-1),M=g.invert().map(N),_=(k=h.doc.nodeAt(S-1))==null?void 0:k.marks.some(I=>I.eq(v.mark)),R=(w=h.doc.nodeAt(N))==null?void 0:w.marks.some(I=>I.eq(v.mark));this.editor.emit("delete",{type:"mark",mark:v.mark,from:v.from,to:v.to,deletedRange:{from:T,to:M},newRange:{from:S,to:N},partial:!!(R||_),editor:this.editor,transaction:t,combinedTransform:h})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),HC=Pt.create({name:"drop",addProseMirrorPlugins(){return[new Ut({key:new Jt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),WC=Pt.create({name:"editable",addProseMirrorPlugins(){return[new Ut({key:new Jt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),VC=new Jt("focusEvents"),qC=Pt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ut({key:VC,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}}}})]}}),KC=Pt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:d,doc:f}=l,{empty:h,$anchor:m}=d,{pos:g,parent:v}=m,x=m.parent.isTextblock&&g>0?l.doc.resolve(g-1):m,k=x.parent.type.spec.isolating,w=m.pos-m.parentOffset,S=k&&x.parent.childCount===1?w===m.pos:yt.atStart(f).from===g;return!h||!v.type.isTextblock||v.textContent.length||!S||S&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Tl()||EC()?i:s},addProseMirrorPlugins(){return[new Ut({key:new Jt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(k=>k.getMeta("composition")))return;const r=t.some(k=>k.docChanged)&&!e.doc.eq(n.doc),s=t.some(k=>k.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,d=yt.atStart(e.doc).from,f=yt.atEnd(e.doc).to;if(i||!(o===d&&l===f)||!Xd(n.doc))return;const g=n.tr,v=Kd({state:n,transaction:g}),{commands:x}=new Gd({editor:this.editor,state:v});if(x.clearNodes(),!!g.steps.length)return g}})]}}),GC=Pt.create({name:"paste",addProseMirrorPlugins(){return[new Ut({key:new Jt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),JC=Pt.create({name:"tabindex",addProseMirrorPlugins(){return[new Ut({key:new Jt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),YC=Pt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ha(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 Jt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),jL=class ol{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ol(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 ol(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 ol(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const d=this.resolvedPos.doc.resolve(l);if(!s&&!o&&d.depth<=this.depth)return;const f=new ol(d,this.editor,s,s||o?n:null);s&&(f.actualDepth=this.depth+1),e.push(f)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const d=o[l];if(i[d]!==n[d])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(d=>n[d]===o.node.attrs[d])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},ML=`.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 AL(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var RL=class extends yL{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:JI,createMappablePosition:YI},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=kC(e,this.options.autofocus);this.editorState=ra.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=AL(ML,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=TC(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[WC,FC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),zC,qC,KC,JC,HC,GC,UC,YC.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Qd(r,this)}createCommandManager(){this.commandManager=new Gd({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Ag(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=Ag(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new yC(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.prependClass(),this.injectCSS();const o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(f=>{var h;return(h=this.capturedTransaction)==null?void 0:h.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),l=o==null?void 0:o.getMeta("focus"),d=o==null?void 0:o.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),d&&this.emit("blur",{editor:this,event:d.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return OC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return qI(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Mv(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
131
-
132
- `,textSerializers:n={}}=t||{};return FI(this.state.doc,{blockSeparator:e,textSerializers:{...RC(this.schema),...n}})}get isEmpty(){return Xd(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 jL(e,this)}get $doc(){return this.$pos(0)}};function yo(t){return new Fl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Gt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const d=l.search(/\S/),f=n.from+l.indexOf(o),h=f+o.length;if(Rv(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(k=>k===t.type&&k!==v.mark.type)).filter(v=>v.to>f).length)return null;h<n.to&&i.delete(h,n.to),f>n.from&&i.delete(n.from+d,f);const g=n.from+d+o.length;i.addMark(n.from+d,g,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function XC(t){return new Fl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Gt(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const d=t.type.create(s);if(r[1]){const f=r[0].lastIndexOf(r[1]);let h=o+f;h>l?h=l:l=h+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,o+r[0].length-1),i.replaceWith(h,l,d)}else if(r[0]){const f=t.type.isInline?o:o-1;i.insert(f,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Og(t){return new Fl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=Gt(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function yn(t){return new Fl({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const o=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const d=i-o;d>0&&(s=r[0].slice(l-d,l)+s,i=o)}e.tr.insertText(s,i,o)},undoable:t.undoable})}function ma(t){return new Fl({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=Gt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),d=o.doc.resolve(n.from).blockRange(),f=d&&av(d,t.type,i);if(!f)return null;if(o.wrap(d,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:v}=t.editor.extensionManager,x=g||m.$to.parentOffset&&m.$from.marks();if(x){const k=x.filter(w=>v.includes(w.type.name));o.ensureMarks(k)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(m,i).run()}const h=o.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&Li(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&o.join(n.from-1)},undoable:t.undoable})}var OL=t=>"touches"in t,IL=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const d=l.clientX-this.startX,f=l.clientY-this.startY;this.handleResize(d,f)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const d=l.touches[0];if(!d)return;const f=d.clientX-this.startX,h=d.clientY-this.startY;this.handleResize(f,h)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,d=this.element.offsetHeight;this.onCommit(l,d),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,OL(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),d=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),l?s=this.startHeight+n:d&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let f=Math.max(this.minSize.width,t),h=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(f=Math.min(this.maxSize.width,f)),(s=this.maxSize)!=null&&s.height&&(h=Math.min(this.maxSize.height,h)),{width:f,height:h}}let l=t,d=e;return l<this.minSize.width&&(l=this.minSize.width,d=l/this.aspectRatio),d<this.minSize.height&&(d=this.minSize.height,l=d*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&l>this.maxSize.width&&(l=this.maxSize.width,d=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&d>this.maxSize.height&&(d=this.maxSize.height,l=d*this.aspectRatio),{width:l,height:d}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function LL(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ut){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}var DL={};Nv(DL,{createAtomBlockMarkdownSpec:()=>PL,createBlockMarkdownSpec:()=>BL,createInlineMarkdownSpec:()=>zL,parseAttributes:()=>Iv,parseIndentedBlocks:()=>Ig,renderNestedMarkdownContent:()=>Dv,serializeAttributes:()=>Lv});function Iv(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const f=s.map(h=>h.trim().slice(1));e.class=f.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,f,h])=>{var m;const g=parseInt(((m=h.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),v=n[g];v&&(e[f]=v.slice(1,-1))});const d=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return d&&d.split(/\s+/).filter(Boolean).forEach(h=>{h.match(/^[a-zA-Z][\w-]*$/)&&(e[h]=!0)}),e}function Lv(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 PL(t){const{nodeName:e,name:n,parseAttributes:r=Iv,serializeAttributes:s=Lv,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,d=n||e,f=h=>{if(!l)return h;const m={};return l.forEach(g=>{g in h&&(m[g]=h[g])}),m};return{parseMarkdown:(h,m)=>{const g={...i,...h.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(h){var m;const g=new RegExp(`^:::${d}(?:\\s|$)`,"m"),v=(m=h.match(g))==null?void 0:m.index;return v!==void 0?v:-1},tokenize(h,m,g){const v=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=h.match(v);if(!x)return;const k=x[1]||"",w=r(k);if(!o.find(N=>!(N in w)))return{type:e,raw:x[0],attributes:w}}},renderMarkdown:h=>{const m=f(h.attrs||{}),g=s(m),v=g?` {${g}}`:"";return`:::${d}${v} :::`}}}function BL(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Iv,serializeAttributes:i=Lv,defaultAttributes:o={},content:l="block",allowedAttributes:d}=t,f=n||e,h=m=>{if(!d)return m;const g={};return d.forEach(v=>{v in m&&(g[v]=m[v])}),g};return{parseMarkdown:(m,g)=>{let v;if(r){const k=r(m);v=typeof k=="string"?[{type:"text",text:k}]:k}else l==="block"?v=g.parseChildren(m.tokens||[]):v=g.parseInline(m.tokens||[]);const x={...o,...m.attributes};return g.createNode(e,x,v)},markdownTokenizer:{name:e,level:"block",start(m){var g;const v=new RegExp(`^:::${f}`,"m"),x=(g=m.match(v))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(m,g,v){var x;const k=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(k);if(!w)return;const[S,N=""]=w,T=s(N);let M=1;const _=S.length;let R="";const I=/^:::([\w-]*)(\s.*)?/gm,$=m.slice(_);for(I.lastIndex=0;;){const P=I.exec($);if(P===null)break;const z=P.index,q=P[1];if(!((x=P[2])!=null&&x.endsWith(":::"))){if(q)M+=1;else if(M-=1,M===0){const F=$.slice(0,z);R=F.trim();const G=m.slice(0,_+z+P[0].length);let B=[];if(R)if(l==="block")for(B=v.blockTokens(F),B.forEach(W=>{W.text&&(!W.tokens||W.tokens.length===0)&&(W.tokens=v.inlineTokens(W.text))});B.length>0;){const W=B[B.length-1];if(W.type==="paragraph"&&(!W.text||W.text.trim()===""))B.pop();else break}else B=v.inlineTokens(R);return{type:e,raw:G,attributes:T,content:R,tokens:B}}}}}},renderMarkdown:(m,g)=>{const v=h(m.attrs||{}),x=i(v),k=x?` {${x}}`:"",w=g.renderChildren(m.content||[],`
133
-
134
- `);return`:::${f}${k}
135
-
136
- ${w}
137
-
138
- :::`}}}function $L(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function FL(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function zL(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=$L,serializeAttributes:i=FL,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:d}=t,f=n||e,h=g=>{if(!d)return g;const v={};return d.forEach(x=>{const k=typeof x=="string"?x:x.name,w=typeof x=="string"?void 0:x.skipIfDefault;if(k in g){const S=g[k];if(w!==void 0&&S===w)return;v[k]=S}}),v},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,v)=>{const x={...o,...g.attributes};if(l)return v.createNode(e,x);const k=r?r(g):g.content||"";return k?v.createNode(e,x,[v.createTextNode(k)]):v.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const v=l?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),x=g.match(v),k=x==null?void 0:x.index;return k!==void 0?k:-1},tokenize(g,v,x){const k=l?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(k);if(!w)return;let S="",N="";if(l){const[,M]=w;N=M}else{const[,M,_]=w;N=M,S=_||""}const T=s(N.trim());return{type:e,raw:w[0],content:S.trim(),attributes:T}}},renderMarkdown:g=>{let v="";r?v=r(g):g.content&&g.content.length>0&&(v=g.content.filter(S=>S.type==="text").map(S=>S.text).join(""));const x=h(g.attrs||{}),k=i(x),w=k?` ${k}`:"";return l?`[${f}${w}]`:`[${f}${w}]${v}[/${f}]`}}}function Ig(t,e,n){var r,s,i,o;const l=t.split(`
139
- `),d=[];let f="",h=0;const m=e.baseIndentSize||2;for(;h<l.length;){const g=l[h],v=g.match(e.itemPattern);if(!v){if(d.length>0)break;if(g.trim()===""){h+=1,f=`${f}${g}
140
- `;continue}else return}const x=e.extractItemData(v),{indentLevel:k,mainContent:w}=x;f=`${f}${g}
141
- `;const S=[w];for(h+=1;h<l.length;){const _=l[h];if(_.trim()===""){const I=l.slice(h+1).findIndex(z=>z.trim()!=="");if(I===-1)break;if((((s=(r=l[h+1+I].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>k){S.push(_),f=`${f}${_}
142
- `,h+=1;continue}else break}if((((o=(i=_.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>k)S.push(_),f=`${f}${_}
143
- `,h+=1;else break}let N;const T=S.slice(1);if(T.length>0){const _=T.map(R=>R.slice(k+m)).join(`
144
- `);_.trim()&&(e.customNestedParser?N=e.customNestedParser(_):N=n.blockTokens(_))}const M=e.createToken(x,N);d.push(M)}if(d.length!==0)return{items:d,raw:f}}function Dv(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]),d=[`${s}${l}`];return o&&o.length>0&&o.forEach(f=>{const h=e.renderChildren([f]);if(h){const m=h.split(`
145
- `).map(g=>g?e.indent(g):"").join(`
146
- `);d.push(m)}}),d.join(`
147
- `)}function UL(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,d)=>{const f=i.mapping.map(d),h=i.mapping.map(d)+l.nodeSize;let m=null;if(l.marks.forEach(v=>{if(v!==o)return!1;m=v}),!m)return;let g=!1;if(Object.keys(n).forEach(v=>{n[v]!==m.attrs[v]&&(g=!0)}),g){const v=t.type.create({...t.attrs,...n});i.removeMark(f,h,t.type),i.addMark(f,h,v)}}),i.docChanged&&e.view.dispatch(i)}var bn=class QC extends Ov{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new QC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},HL=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:d}=this.editor,f=t.target,h=f.nodeType===3?(e=f.parentElement)==null?void 0:e.closest("[data-drag-handle]"):f.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(f)||!h)return;let m=0,g=0;if(this.dom!==h){const N=this.dom.getBoundingClientRect(),T=h.getBoundingClientRect(),M=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,_=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;m=T.x-N.x+M,g=T.y-N.y+_}const v=this.dom.cloneNode(!0);try{const N=this.dom.getBoundingClientRect();v.style.width=`${Math.round(N.width)}px`,v.style.height=`${Math.round(N.height)}px`,v.style.boxSizing="border-box",v.style.pointerEvents="none"}catch{}let x=null;try{x=document.createElement("div"),x.style.position="absolute",x.style.top="-9999px",x.style.left="-9999px",x.style.pointerEvents="none",x.appendChild(v),document.body.appendChild(x),(l=t.dataTransfer)==null||l.setDragImage(v,m,g)}finally{x&&setTimeout(()=>{try{x==null||x.remove()}catch{}},0)}const k=this.getPos();if(typeof k!="number")return;const w=ut.create(d.state.doc,k),S=d.state.tr.setSelection(w);d.dispatch(S)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:d}=this,f=!!this.node.type.spec.draggable,h=ut.isSelectable(this.node),m=t.type==="copy",g=t.type==="paste",v=t.type==="cut",x=t.type==="mousedown";if(!f&&h&&s&&t.target===this.dom&&t.preventDefault(),f&&s&&!d&&t.target===this.dom)return t.preventDefault(),!1;if(f&&l&&!d&&x){const k=n.closest("[data-drag-handle]");k&&(this.dom===k||this.dom.contains(k))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(d||i||m||g||v||x&&h)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Tl()||Mg())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function Oi(t){return new SL({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=Gt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],d=r[0];let f=n.to;if(l){const h=d.search(/\S/),m=n.from+d.indexOf(l),g=m+l.length;if(Rv(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>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.from&&o.delete(n.from+h,m),f=n.from+h+l.length,o.addMark(n.from+h,f,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:WL,getOwnPropertySymbols:VL}=Object,{hasOwnProperty:qL}=Object.prototype;function pp(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function su(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const d=t(n,r,s);return i.delete(n),i.delete(r),d}}function KL(t){return t!=null?t[Symbol.toStringTag]:void 0}function dw(t){return WL(t).concat(VL(t))}const GL=Object.hasOwn||((t,e)=>qL.call(t,e));function ko(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const JL="__v",YL="__o",XL="_owner",{getOwnPropertyDescriptor:fw,keys:hw}=Object;function QL(t,e){return t.byteLength===e.byteLength&&td(new Uint8Array(t),new Uint8Array(e))}function ZL(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 eD(t,e){return t.byteLength===e.byteLength&&td(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function tD(t,e){return ko(t.getTime(),e.getTime())}function nD(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function rD(t,e){return t===e}function pw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,d=0;for(;(o=i.next())&&!o.done;){const f=e.entries();let h=!1,m=0;for(;(l=f.next())&&!l.done;){if(s[m]){m++;continue}const g=o.value,v=l.value;if(n.equals(g[0],v[0],d,m,t,e,n)&&n.equals(g[1],v[1],g[0],v[0],t,e,n)){h=s[m]=!0;break}m++}if(!h)return!1;d++}return!0}const sD=ko;function iD(t,e,n){const r=hw(t);let s=r.length;if(hw(e).length!==s)return!1;for(;s-- >0;)if(!ZC(t,e,n,r[s]))return!1;return!0}function Qa(t,e,n){const r=dw(t);let s=r.length;if(dw(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!ZC(t,e,n,i)||(o=fw(t,i),l=fw(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function oD(t,e){return ko(t.valueOf(),e.valueOf())}function aD(t,e){return t.source===e.source&&t.flags===e.flags}function mw(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const d=e.values();let f=!1,h=0;for(;(l=d.next())&&!l.done;){if(!s[h]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){f=s[h]=!0;break}h++}if(!f)return!1}return!0}function td(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 lD(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 ZC(t,e,n,r){return(r===XL||r===YL||r===JL)&&(t.$$typeof||e.$$typeof)?!0:GL(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const cD="[object ArrayBuffer]",uD="[object Arguments]",dD="[object Boolean]",fD="[object DataView]",hD="[object Date]",pD="[object Error]",mD="[object Map]",gD="[object Number]",vD="[object Object]",yD="[object RegExp]",bD="[object Set]",xD="[object String]",wD={"[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},kD="[object URL]",SD=Object.prototype.toString;function ED({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:d,arePrimitiveWrappersEqual:f,areRegExpsEqual:h,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:v,unknownTagComparators:x}){return function(w,S,N){if(w===S)return!0;if(w==null||S==null)return!1;const T=typeof w;if(T!==typeof S)return!1;if(T!=="object")return T==="number"?l(w,S,N):T==="function"?i(w,S,N):!1;const M=w.constructor;if(M!==S.constructor)return!1;if(M===Object)return d(w,S,N);if(Array.isArray(w))return e(w,S,N);if(M===Date)return r(w,S,N);if(M===RegExp)return h(w,S,N);if(M===Map)return o(w,S,N);if(M===Set)return m(w,S,N);const _=SD.call(w);if(_===hD)return r(w,S,N);if(_===yD)return h(w,S,N);if(_===mD)return o(w,S,N);if(_===bD)return m(w,S,N);if(_===vD)return typeof w.then!="function"&&typeof S.then!="function"&&d(w,S,N);if(_===kD)return v(w,S,N);if(_===pD)return s(w,S,N);if(_===uD)return d(w,S,N);if(wD[_])return g(w,S,N);if(_===cD)return t(w,S,N);if(_===fD)return n(w,S,N);if(_===dD||_===gD||_===xD)return f(w,S,N);if(x){let R=x[_];if(!R){const I=KL(w);I&&(R=x[I])}if(R)return R(w,S,N)}return!1}}function ND({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:QL,areArraysEqual:n?Qa:ZL,areDataViewsEqual:eD,areDatesEqual:tD,areErrorsEqual:nD,areFunctionsEqual:rD,areMapsEqual:n?pp(pw,Qa):pw,areNumbersEqual:sD,areObjectsEqual:n?Qa:iD,arePrimitiveWrappersEqual:oD,areRegExpsEqual:aD,areSetsEqual:n?pp(mw,Qa):mw,areTypedArraysEqual:n?pp(td,Qa):td,areUrlsEqual:lD,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=su(r.areArraysEqual),i=su(r.areMapsEqual),o=su(r.areObjectsEqual),l=su(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function CD(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function _D({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,d){const{cache:f=t?new WeakMap:void 0,meta:h}=n();return e(l,d,{cache:f,equals:r,meta:h,strict:s})};if(t)return function(l,d){return e(l,d,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,d){return e(l,d,i)}}const TD=Pi();Pi({strict:!0});Pi({circular:!0});Pi({circular:!0,strict:!0});Pi({createInternalComparator:()=>ko});Pi({strict:!0,createInternalComparator:()=>ko});Pi({circular:!0,createInternalComparator:()=>ko});Pi({circular:!0,createInternalComparator:()=>ko,strict:!0});function Pi(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=ND(t),o=ED(i),l=n?n(o):CD(o);return _D({circular:e,comparator:o,createState:r,equals:l,strict:s})}var mp={exports:{}},gp={};/**
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 gw;function jD(){if(gw)return gp;gw=1;var t=Ll(),e=WE();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,d=t.useDebugValue;return gp.useSyncExternalStoreWithSelector=function(f,h,m,g,v){var x=i(null);if(x.current===null){var k={hasValue:!1,value:null};x.current=k}else k=x.current;x=l(function(){function S(R){if(!N){if(N=!0,T=R,R=g(R),v!==void 0&&k.hasValue){var I=k.value;if(v(I,R))return M=I}return M=R}if(I=M,r(T,R))return I;var $=g(R);return v!==void 0&&v(I,$)?(T=R,I):(T=R,M=$)}var N=!1,T,M,_=m===void 0?null:m;return[function(){return S(h())},_===null?void 0:function(){return S(_())}]},[h,m,g,v]);var w=s(f,x[0],x[1]);return o(function(){k.hasValue=!0,k.value=w},[w]),d(w),w},gp}var vw;function MD(){return vw||(vw=1,mp.exports=jD()),mp.exports}var AD=MD(),RD=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},OD=({contentComponent:t})=>{const e=VE.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return c.jsx(c.Fragment,{children:Object.values(e)})};function ID(){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]:BM.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var LD=class extends Mi.Component{constructor(t){var e;super(t),this.editorContentRef=Mi.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=ID(),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 c.jsxs(c.Fragment,{children:[c.jsx("div",{ref:RD(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&c.jsx(OD,{contentComponent:t.contentComponent})]})}},DD=b.forwardRef((t,e)=>{const n=Mi.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return Mi.createElement(LD,{key:n,innerRef:e,...t})}),Pv=Mi.memo(DD),PD=typeof window<"u"?b.useLayoutEffect:b.useEffect,BD=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 $D(t){var e;const[n]=b.useState(()=>new BD(t.editor)),r=AD.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:TD);return PD(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var FD=!1,Lg=typeof window>"u",zD=Lg||!!(typeof window<"u"&&window.next),UD=class e_{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?Lg||zD?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new RL(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?e_.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function t_(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new UD(n)),s=VE.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(s),b.useEffect(r.onRender(e)),$D({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var n_=b.createContext({editor:null});n_.Consumer;var r_=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),HD=()=>b.useContext(r_),WD=Mi.forwardRef((t,e)=>{const{onDragStart:n}=HD(),r=t.as||"div";return c.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function yw(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function bw(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function VD(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function qD(t){if(yw(t)||bw(t))return!0;if(VD(t)){const e=t.type;if(e)return yw(e)||bw(e)}return!1}function KD(){try{if(b.version)return parseInt(b.version.split(".")[0],10)>=19}catch{}return!1}var GD=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?HE.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=KD(),i=qD(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=c.jsx(e,{...o}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};Mi.createContext({markViewContentRef:()=>{}});var JD=class extends HL{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,s){var i;return r==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(n,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(d={})=>this.updateAttributes(d),deleteNode:()=>this.deleteNode(),ref:b.createRef()};if(!this.component.displayName){const d=f=>f.charAt(0).toUpperCase()+f.substring(1);this.component.displayName=d(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:d=>{d&&this.contentDOMElement&&d.firstChild!==this.contentDOMElement&&(d.hasAttribute("data-node-view-wrapper")&&d.removeAttribute("data-node-view-wrapper"),d.appendChild(this.contentDOMElement))}},s=this.component,i=b.memo(d=>c.jsx(r_.Provider,{value:r,children:b.createElement(s,d)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new GD(i,{editor:this.editor,props:t,as:o,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,o=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=pa(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function YD(t,e){return n=>n.editor.contentComponent?new JD(t,n,e):{}}var Bv=b.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Bv.displayName="TiptapContext";var XD=()=>b.useContext(Bv);function s_({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=b.useMemo(()=>({editor:r}),[r]),i=b.useMemo(()=>({editor:r}),[r]);return c.jsx(n_.Provider,{value:i,children:c.jsx(Bv.Provider,{value:s,children:n})})}s_.displayName="Tiptap";function i_({...t}){const{editor:e}=XD();return c.jsx(Pv,{editor:e,...t})}i_.displayName="Tiptap.Content";Object.assign(s_,{Content:i_});var QD=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,ZD=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,eP=cs.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",zt(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[yo({find:QD,type:this.type})]},addPasteRules(){return[Oi({find:ZD,type:this.type})]}}),tP=eP,nP=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,rP=bn.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",zt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",d=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",f=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return f?`![${d}](${l} "${f}")`:`![${d}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o,editor:l})=>{const d=document.createElement("img");Object.entries(o).forEach(([m,g])=>{if(g!=null)switch(m){case"width":case"height":break;default:d.setAttribute(m,g);break}}),d.src=o.src;const f=new IL({element:d,editor:l,node:s,getPos:i,onResize:(m,g)=>{d.style.width=`${m}px`,d.style.height=`${g}px`},onCommit:(m,g)=>{const v=i();v!==void 0&&this.editor.chain().setNodeSelection(v).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,v)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),h=f.dom;return h.style.visibility="hidden",h.style.pointerEvents="none",d.onload=()=>{h.style.visibility="",h.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[XC({find:nP,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),$v=rP;const sP="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",iP="ελ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",Dg="numeric",Pg="ascii",Bg="alpha",ml="asciinumeric",al="alphanumeric",$g="domain",o_="emoji",oP="scheme",aP="slashscheme",vp="whitespace";function lP(t,e){return t in e||(e[t]=[]),e[t]}function oo(t,e,n){e[Dg]&&(e[ml]=!0,e[al]=!0),e[Pg]&&(e[ml]=!0,e[Bg]=!0),e[ml]&&(e[al]=!0),e[Bg]&&(e[al]=!0),e[al]&&(e[$g]=!0),e[o_]&&(e[$g]=!0);for(const r in e){const s=lP(r,n);s.indexOf(t)<0&&s.push(t)}}function cP(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function kr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}kr.groups={};kr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||kr.groups;let s;return e&&e.j?s=e:(s=new kr(e),n&&r&&oo(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||kr.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new kr,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new kr,i){if(r)if(o.t&&typeof o.t=="string"){const d=Object.assign(cP(o.t,r),n);oo(i,d,r)}else n&&oo(i,n,r);o.t=i}return s.j[t]=o,o}};const At=(t,e,n,r,s)=>t.ta(e,n,r,s),mn=(t,e,n,r,s)=>t.tr(e,n,r,s),xw=(t,e,n,r,s)=>t.ts(e,n,r,s),Oe=(t,e,n,r,s)=>t.tt(e,n,r,s),Fs="WORD",Fg="UWORD",a_="ASCIINUMERICAL",l_="ALPHANUMERICAL",Ml="LOCALHOST",zg="TLD",Ug="UTLD",Lu="SCHEME",ea="SLASH_SCHEME",Fv="NUM",Hg="WS",zv="NL",gl="OPENBRACE",vl="CLOSEBRACE",nd="OPENBRACKET",rd="CLOSEBRACKET",sd="OPENPAREN",id="CLOSEPAREN",od="OPENANGLEBRACKET",ad="CLOSEANGLEBRACKET",ld="FULLWIDTHLEFTPAREN",cd="FULLWIDTHRIGHTPAREN",ud="LEFTCORNERBRACKET",dd="RIGHTCORNERBRACKET",fd="LEFTWHITECORNERBRACKET",hd="RIGHTWHITECORNERBRACKET",pd="FULLWIDTHLESSTHAN",md="FULLWIDTHGREATERTHAN",gd="AMPERSAND",vd="APOSTROPHE",yd="ASTERISK",vi="AT",bd="BACKSLASH",xd="BACKTICK",wd="CARET",xi="COLON",Uv="COMMA",kd="DOLLAR",ws="DOT",Sd="EQUALS",Hv="EXCLAMATION",Vr="HYPHEN",yl="PERCENT",Ed="PIPE",Nd="PLUS",Cd="POUND",bl="QUERY",Wv="QUOTE",c_="FULLWIDTHMIDDLEDOT",Vv="SEMI",ks="SLASH",xl="TILDE",_d="UNDERSCORE",u_="EMOJI",Td="SYM";var d_=Object.freeze({__proto__:null,ALPHANUMERICAL:l_,AMPERSAND:gd,APOSTROPHE:vd,ASCIINUMERICAL:a_,ASTERISK:yd,AT:vi,BACKSLASH:bd,BACKTICK:xd,CARET:wd,CLOSEANGLEBRACKET:ad,CLOSEBRACE:vl,CLOSEBRACKET:rd,CLOSEPAREN:id,COLON:xi,COMMA:Uv,DOLLAR:kd,DOT:ws,EMOJI:u_,EQUALS:Sd,EXCLAMATION:Hv,FULLWIDTHGREATERTHAN:md,FULLWIDTHLEFTPAREN:ld,FULLWIDTHLESSTHAN:pd,FULLWIDTHMIDDLEDOT:c_,FULLWIDTHRIGHTPAREN:cd,HYPHEN:Vr,LEFTCORNERBRACKET:ud,LEFTWHITECORNERBRACKET:fd,LOCALHOST:Ml,NL:zv,NUM:Fv,OPENANGLEBRACKET:od,OPENBRACE:gl,OPENBRACKET:nd,OPENPAREN:sd,PERCENT:yl,PIPE:Ed,PLUS:Nd,POUND:Cd,QUERY:bl,QUOTE:Wv,RIGHTCORNERBRACKET:dd,RIGHTWHITECORNERBRACKET:hd,SCHEME:Lu,SEMI:Vv,SLASH:ks,SLASH_SCHEME:ea,SYM:Td,TILDE:xl,TLD:zg,UNDERSCORE:_d,UTLD:Ug,UWORD:Fg,WORD:Fs,WS:Hg});const Bs=/[a-z]/,Za=new RegExp("\\p{L}","u"),yp=new RegExp("\\p{Emoji}","u"),$s=/\d/,bp=/\s/,ww="\r",xp=`
156
- `,uP="️",dP="‍",wp="";let iu=null,ou=null;function fP(t=[]){const e={};kr.groups=e;const n=new kr;iu==null&&(iu=kw(sP)),ou==null&&(ou=kw(iP)),Oe(n,"'",vd),Oe(n,"{",gl),Oe(n,"}",vl),Oe(n,"[",nd),Oe(n,"]",rd),Oe(n,"(",sd),Oe(n,")",id),Oe(n,"<",od),Oe(n,">",ad),Oe(n,"(",ld),Oe(n,")",cd),Oe(n,"「",ud),Oe(n,"」",dd),Oe(n,"『",fd),Oe(n,"』",hd),Oe(n,"<",pd),Oe(n,">",md),Oe(n,"&",gd),Oe(n,"*",yd),Oe(n,"@",vi),Oe(n,"`",xd),Oe(n,"^",wd),Oe(n,":",xi),Oe(n,",",Uv),Oe(n,"$",kd),Oe(n,".",ws),Oe(n,"=",Sd),Oe(n,"!",Hv),Oe(n,"-",Vr),Oe(n,"%",yl),Oe(n,"|",Ed),Oe(n,"+",Nd),Oe(n,"#",Cd),Oe(n,"?",bl),Oe(n,'"',Wv),Oe(n,"/",ks),Oe(n,";",Vv),Oe(n,"~",xl),Oe(n,"_",_d),Oe(n,"\\",bd),Oe(n,"・",c_);const r=mn(n,$s,Fv,{[Dg]:!0});mn(r,$s,r);const s=mn(r,Bs,a_,{[ml]:!0}),i=mn(r,Za,l_,{[al]:!0}),o=mn(n,Bs,Fs,{[Pg]:!0});mn(o,$s,s),mn(o,Bs,o),mn(s,$s,s),mn(s,Bs,s);const l=mn(n,Za,Fg,{[Bg]:!0});mn(l,Bs),mn(l,$s,i),mn(l,Za,l),mn(i,$s,i),mn(i,Bs),mn(i,Za,i);const d=Oe(n,xp,zv,{[vp]:!0}),f=Oe(n,ww,Hg,{[vp]:!0}),h=mn(n,bp,Hg,{[vp]:!0});Oe(n,wp,h),Oe(f,xp,d),Oe(f,wp,h),mn(f,bp,h),Oe(h,ww),Oe(h,xp),mn(h,bp,h),Oe(h,wp,h);const m=mn(n,yp,u_,{[o_]:!0});Oe(m,"#"),mn(m,yp,m),Oe(m,uP,m);const g=Oe(m,dP);Oe(g,"#"),mn(g,yp,m);const v=[[Bs,o],[$s,s]],x=[[Bs,null],[Za,l],[$s,i]];for(let k=0;k<iu.length;k++)hi(n,iu[k],zg,Fs,v);for(let k=0;k<ou.length;k++)hi(n,ou[k],Ug,Fg,x);oo(zg,{tld:!0,ascii:!0},e),oo(Ug,{utld:!0,alpha:!0},e),hi(n,"file",Lu,Fs,v),hi(n,"mailto",Lu,Fs,v),hi(n,"http",ea,Fs,v),hi(n,"https",ea,Fs,v),hi(n,"ftp",ea,Fs,v),hi(n,"ftps",ea,Fs,v),oo(Lu,{scheme:!0,ascii:!0},e),oo(ea,{slashscheme:!0,ascii:!0},e),t=t.sort((k,w)=>k[0]>w[0]?1:-1);for(let k=0;k<t.length;k++){const w=t[k][0],N=t[k][1]?{[oP]:!0}:{[aP]:!0};w.indexOf("-")>=0?N[$g]=!0:Bs.test(w)?$s.test(w)?N[ml]=!0:N[Pg]=!0:N[Dg]=!0,xw(n,w,w,N)}return xw(n,"localhost",Ml,{ascii:!0}),n.jd=new kr(Td),{start:n,tokens:Object.assign({groups:e},d_)}}function f_(t,e){const n=hP(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,d=null,f=0,h=null,m=-1,g=-1;for(;o<r&&(d=l.go(n[o]));)l=d,l.accepts()?(m=0,g=0,h=l):m>=0&&(m+=n[o].length,g++),f+=n[o].length,i+=n[o].length,o++;i-=m,o-=g,f-=m,s.push({t:h.t,v:e.slice(i-f,i),s:i-f,e:i})}return s}function hP(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function hi(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const d=e[l];t.j[d]?i=t.j[d]:(i=new kr(r),i.jr=s.slice(),t.j[d]=i),t=i}return i=new kr(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function kw(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Al={defaultProtocol:"http",events:null,format:Sw,formatHref:Sw,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function qv(t,e=null){let n=Object.assign({},Al);t&&(n=Object.assign(n,t instanceof qv?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}qv.prototype={o:Al,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Al[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Sw(t){return t}function h_(t,e){this.t="token",this.v=t,this.tk=e}h_.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=Al.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),d=t.get("target",n,e),f=t.get("rel",n,e),h=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),d&&(o.target=d),f&&(o.rel=f),h&&Object.assign(o,h),{tagName:s,attributes:o,content:i,eventListeners:m}}};function Zd(t,e){class n extends h_{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Ew=Zd("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Nw=Zd("text"),pP=Zd("nl"),au=Zd("url",{isLink:!0,toHref(t=Al.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ml&&t[1].t===xi}}),Hr=t=>new kr(t);function mP({groups:t}){const e=t.domain.concat([gd,yd,vi,bd,xd,wd,kd,Sd,Vr,Fv,yl,Ed,Nd,Cd,ks,Td,xl,_d]),n=[vd,xi,Uv,ws,Hv,yl,bl,Wv,Vv,od,ad,gl,vl,rd,nd,sd,id,ld,cd,ud,dd,fd,hd,pd,md],r=[gd,vd,yd,bd,xd,wd,kd,Sd,Vr,gl,vl,yl,Ed,Nd,Cd,bl,ks,Td,xl,_d],s=Hr(),i=Oe(s,xl);At(i,r,i),At(i,t.domain,i);const o=Hr(),l=Hr(),d=Hr();At(s,t.domain,o),At(s,t.scheme,l),At(s,t.slashscheme,d),At(o,r,i),At(o,t.domain,o);const f=Oe(o,vi);Oe(i,vi,f),Oe(l,vi,f),Oe(d,vi,f);const h=Oe(i,ws);At(h,r,i),At(h,t.domain,i);const m=Hr();At(f,t.domain,m),At(m,t.domain,m);const g=Oe(m,ws);At(g,t.domain,m);const v=Hr(Ew);At(g,t.tld,v),At(g,t.utld,v),Oe(f,Ml,v);const x=Oe(m,Vr);Oe(x,Vr,x),At(x,t.domain,m),At(v,t.domain,m),Oe(v,ws,g),Oe(v,Vr,x);const k=Oe(v,xi);At(k,t.numeric,Ew);const w=Oe(o,Vr),S=Oe(o,ws);Oe(w,Vr,w),At(w,t.domain,o),At(S,r,i),At(S,t.domain,o);const N=Hr(au);At(S,t.tld,N),At(S,t.utld,N),At(N,t.domain,o),At(N,r,i),Oe(N,ws,S),Oe(N,Vr,w),Oe(N,vi,f);const T=Oe(N,xi),M=Hr(au);At(T,t.numeric,M);const _=Hr(au),R=Hr();At(_,e,_),At(_,n,R),At(R,e,_),At(R,n,R),Oe(N,ks,_),Oe(M,ks,_);const I=Oe(l,xi),$=Oe(d,xi),P=Oe($,ks),z=Oe(P,ks);At(l,t.domain,o),Oe(l,ws,S),Oe(l,Vr,w),At(d,t.domain,o),Oe(d,ws,S),Oe(d,Vr,w),At(I,t.domain,_),Oe(I,ks,_),Oe(I,bl,_),At(z,t.domain,_),At(z,e,_),Oe(z,ks,_);const q=[[gl,vl],[nd,rd],[sd,id],[od,ad],[ld,cd],[ud,dd],[fd,hd],[pd,md]];for(let F=0;F<q.length;F++){const[G,B]=q[F],W=Oe(_,G);Oe(R,G,W),Oe(W,B,_);const K=Hr(au);At(W,e,K);const ne=Hr();At(W,n),At(K,e,K),At(K,n,ne),At(ne,e,K),At(ne,n,ne),Oe(K,B,_),Oe(ne,B,_)}return Oe(s,Ml,N),Oe(s,zv,pP),{start:s,tokens:d_}}function gP(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,d=null,f=null,h=0,m=null,g=-1;for(;s<r&&!(d=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(f=d||l.go(n[s].t));)d=null,l=f,l.accepts()?(g=0,m=l):g>=0&&g++,s++,h++;if(g<0)s-=h,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(kp(Nw,e,o)),o=[]),s-=g,h-=g;const v=m.t,x=n.slice(s-h,s);i.push(kp(v,e,x))}}return o.length>0&&i.push(kp(Nw,e,o)),i}function kp(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const vP=typeof console<"u"&&console&&console.warn||(()=>{}),yP="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",on={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function bP(){return kr.groups={},on.scanner=null,on.parser=null,on.tokenQueue=[],on.pluginQueue=[],on.customSchemes=[],on.initialized=!1,on}function Cw(t,e=!1){if(on.initialized&&vP(`linkifyjs: already initialized - will not register custom scheme "${t}" ${yP}`),!/^[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`);on.customSchemes.push([t,e])}function xP(){on.scanner=fP(on.customSchemes);for(let t=0;t<on.tokenQueue.length;t++)on.tokenQueue[t][1]({scanner:on.scanner});on.parser=mP(on.scanner.tokens);for(let t=0;t<on.pluginQueue.length;t++)on.pluginQueue[t][1]({scanner:on.scanner,parser:on.parser});return on.initialized=!0,on}function Kv(t){return on.initialized||xP(),gP(on.parser.start,t,f_(on.scanner.start,t))}Kv.scan=f_;function p_(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 qv(n),s=Kv(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var Gv="[\0-   ᠎ -\u2029  ]",wP=new RegExp(Gv),kP=new RegExp(`${Gv}$`),SP=new RegExp(Gv,"g");function EP(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function NP(t){return new Ut({key:new Jt("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),i=e.some(f=>f.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=Tv(n.doc,[...e]);if(Av(l).forEach(({newRange:f})=>{const h=CC(r.doc,f,v=>v.isTextblock);let m,g;if(h.length>1)m=h[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(h.length){const v=r.doc.textBetween(f.from,f.to," "," ");if(!kP.test(v))return;m=h[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const v=g.split(wP).filter(Boolean);if(v.length<=0)return!1;const x=v[v.length-1],k=m.pos+g.lastIndexOf(x);if(!x)return!1;const w=Kv(x).map(S=>S.toObject(t.defaultProtocol));if(!EP(w))return!1;w.filter(S=>S.isLink).map(S=>({...S,from:k+S.start+1,to:k+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=>{Rv(S.from,S.to,r.doc).some(N=>N.mark.type===t.type)||o.addMark(S.from,S.to,t.type.create({href:S.href}))})}}),!!o.steps.length)return o}})}function CP(t){return new Ut({key:new Jt("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const d=r.target;if(!d)return!1;const f=t.editor.view.dom;o=d.closest("a"),o&&!f.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const d=OC(e.state,t.type.name),f=(s=o.href)!=null?s:d.href,h=(i=o.target)!=null?i:d.target;f&&(window.open(f,h),l=!0)}return l}}})}function _P(t){return new Ut({key:new Jt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let d="";r.content.forEach(h=>{d+=h.textContent});const f=p_(d,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===d);return!d||!f||s!==void 0&&!s(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function eo(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(SP,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var m_=cs.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"){Cw(t);return}Cw(t.scheme,t.optionalSlashes)})},onDestroy(){bP()},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)=>!!eo(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!eo(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=>!!eo(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",zt(this.options.HTMLAttributes,t),0]:["a",zt(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",d=e.renderChildren(t);return l?`[${d}](${o} "${l}")`:`[${d}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!eo(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=>!!eo(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[Oi({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=p_(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!eo(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(NP({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!eo(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(CP({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(_P({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),TP=m_;function jP(t={}){return new Ut({view(e){return new MP(e,t)}})}class MP{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let v=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(v){let x=v.getBoundingClientRect(),k=m?x.bottom:x.top;m&&g&&(k=(k+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*l;r={left:x.left,right:x.right,top:k-w,bottom:k+w}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:m.left-g,right:m.left+g,top:m.top,bottom:m.bottom}}let d=this.editorView.dom.offsetParent;this.element||(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let f,h;if(!d||d==document.body&&getComputedStyle(d).position=="static")f=-pageXOffset,h=-pageYOffset;else{let m=d.getBoundingClientRect(),g=m.width/d.offsetWidth,v=m.height/d.offsetHeight;f=m.left-d.scrollLeft*g,h=m.top-d.scrollTop*v}this.element.style.left=(r.left-f)/o+"px",this.element.style.top=(r.top-h)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=yN(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class gn extends yt{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return gn.valid(r)?new gn(r):yt.near(r)}content(){return Ue.empty}eq(e){return e instanceof gn&&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 gn(e.resolve(n.pos))}getBookmark(){return new Jv(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!AP(e)||!RP(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&gn.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let d=e.doc.resolve(s);if(gn.valid(d))return d}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!ut.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(gn.valid(l))return l}return null}}}gn.prototype.visible=!1;gn.findFrom=gn.findGapCursorFrom;yt.jsonID("gapcursor",gn);class Jv{constructor(e){this.pos=e}map(e){return new Jv(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return gn.valid(n)?new gn(n):yt.near(n)}}function g_(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function AP(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||g_(s.type))return!0;if(s.inlineContent)return!1}}return!0}function RP(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||g_(s.type))return!0;if(s.inlineContent)return!1}}return!0}function OP(){return new Ut({props:{decorations:PP,createSelectionBetween(t,e,n){return e.pos==n.pos&&gn.valid(n)?new gn(n):null},handleClick:LP,handleKeyDown:IP,handleDOMEvents:{beforeinput:DP}}})}const IP=Ev({ArrowLeft:lu("horiz",-1),ArrowRight:lu("horiz",1),ArrowUp:lu("vert",-1),ArrowDown:lu("vert",1)});function lu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,d=o.empty;if(o instanceof ft){if(!i.endOfTextblock(n)||l.depth==0)return!1;d=!1,l=r.doc.resolve(e>0?l.after():l.before())}let f=gn.findGapCursorFrom(l,e,d);return f?(s&&s(r.tr.setSelection(new gn(f))),!0):!1}}function LP(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!gn.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ut.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new gn(r))),!0)}function DP(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof gn))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=we.empty;for(let o=r.length-1;o>=0;o--)s=we.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Ue(s,0,0));return i.setSelection(ft.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function PP(t){if(!(t.selection instanceof gn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",It.create(t.doc,[qt.widget(t.selection.head,e,{key:"gapcursor"})])}var jd=200,$n=function(){};$n.prototype.append=function(e){return e.length?(e=$n.from(e),!this.length&&e||e.length<jd&&this.leafAppend(e)||this.length<jd&&e.leafPrepend(this)||this.appendInner(e)):this};$n.prototype.prepend=function(e){return e.length?$n.from(e).append(this):this};$n.prototype.appendInner=function(e){return new BP(this,e)};$n.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?$n.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};$n.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};$n.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)};$n.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};$n.from=function(e){return e instanceof $n?e:e&&e.length?new v_(e):$n.empty};var v_=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var d=i;d<o;d++)if(s(this.values[d],l+d)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var d=i-1;d>=o;d--)if(s(this.values[d],l+d)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=jd)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=jd)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})($n);$n.empty=new v_([]);var BP=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})($n);const $P=500;class is{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,d,f=[],h=[];return this.items.forEach((m,g)=>{if(!m.step){s||(s=this.remapping(r,g+1),i=s.maps.length),i--,h.push(m);return}if(s){h.push(new Ss(m.map));let v=m.step.map(s.slice(i)),x;v&&o.maybeStep(v).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],f.push(new Ss(x,void 0,void 0,f.length+h.length))),i--,x&&s.appendMap(x,i)}else o.maybeStep(m.step);if(m.selection)return l=s?m.selection.map(s.slice(i)):m.selection,d=new is(this.items.slice(0,r).append(h.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:d,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,d=!s&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let m=e.steps[h].invert(e.docs[h]),g=new Ss(e.mapping.maps[h],m,n),v;(v=d&&d.merge(g))&&(g=v,h?i.pop():l=l.slice(0,l.length-1)),i.push(g),n&&(o++,n=void 0),s||(d=g)}let f=o-r.depth;return f>zP&&(l=FP(l,f),o-=f),new is(l.append(i),o)}remapping(e,n){let r=new Sl;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new is(this.items.append(e.map(n=>new Ss(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},s);let d=n;this.items.forEach(g=>{let v=i.getMirror(--d);if(v==null)return;o=Math.min(o,v);let x=i.maps[v];if(g.step){let k=e.steps[v].invert(e.docs[v]),w=g.selection&&g.selection.map(i.slice(d+1,v));w&&l++,r.push(new Ss(x,k,w))}else r.push(new Ss(x))},s);let f=[];for(let g=n;g<o;g++)f.push(new Ss(i.maps[g]));let h=this.items.slice(0,s).append(f).append(r),m=new is(h,l);return m.emptyItemCount()>$P&&(m=m.compress(this.items.length-r.length)),m}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let d=o.step.map(n.slice(r)),f=d&&d.getMap();if(r--,f&&n.appendMap(f,r),d){let h=o.selection&&o.selection.map(n.slice(r));h&&i++;let m=new Ss(f.invert(),d,h),g,v=s.length-1;(g=s.length&&s[v].merge(m))?s[v]=g:s.push(m)}}else o.map&&r--},this.items.length,0),new is($n.from(s.reverse()),i)}}is.empty=new is($n.empty,0);function FP(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Ss{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Ss(n.getMap().invert(),n,this.selection)}}}class yi{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const zP=20;function UP(t,e,n,r){let s=n.getMeta(ho),i;if(s)return s.historyState;n.getMeta(VP)&&(t=new yi(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(ho))return o.getMeta(ho).redo?new yi(t.done.addTransform(n,void 0,r,Du(e)),t.undone,_w(n.mapping.maps),t.prevTime,t.prevComposition):new yi(t.done,t.undone.addTransform(n,void 0,r,Du(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),d=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!HP(n,t.prevRanges)),f=o?Sp(t.prevRanges,n.mapping):_w(n.mapping.maps);return new yi(t.done.addTransform(n,d?e.selection.getBookmark():void 0,r,Du(e)),is.empty,f,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new yi(t.done.rebased(n,i),t.undone.rebased(n,i),Sp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new yi(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Sp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function HP(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function _w(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Sp(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function WP(t,e,n){let r=Du(e),s=ho.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),d=new yi(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(ho,{redo:n,historyState:d})}let Ep=!1,Tw=null;function Du(t){let e=t.plugins;if(Tw!=e){Ep=!1,Tw=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ep=!0;break}}return Ep}const ho=new Jt("history"),VP=new Jt("closeHistory");function qP(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ut({key:ho,state:{init(){return new yi(is.empty,is.empty,null,0,-1)},apply(e,n,r){return UP(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?b_:r=="historyRedo"?x_:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function y_(t,e){return(n,r)=>{let s=ho.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=WP(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const b_=y_(!1,!0),x_=y_(!0,!0);Pt.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 Jt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,d=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(l,d);return t=!0,f}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,d=i-r,f=l-d,h=l;return e.deleteRange(f,h),!(this.storage.characters({node:e.doc})>r)}})]}});var KP=Pt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[jP(this.options)]}});Pt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ut({key:new Jt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return It.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((d,f)=>{if(d.isText)return;if(!(s>=f&&s<=f+d.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((d,f)=>{if(d.isText||!(s>=f&&s<=f+d.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(qt.node(f,f+d.nodeSize,{class:this.options.className}))}),It.create(t,i)}}})]}});var GP=Pt.create({name:"gapCursor",addProseMirrorPlugins(){return[OP()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Gt(ct(t,"allowGapCursor",n)))!=null?e:null}}}),jw="placeholder";function JP(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var YP=Pt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:jw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${JP(this.options.dataAttribute)}`:`data-${jw}`;return[new Ut({key:new Jt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,i=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((l,d)=>{const f=s>=d&&s<=d+l.nodeSize,h=!l.isLeaf&&Xd(l);if((f||!this.options.showOnlyCurrent)&&h){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=qt.node(d,d+l.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:l,pos:d,hasAnchor:f}):this.options.placeholder});i.push(g)}return this.options.includeChildren}),It.create(e,i)}}})]}});Pt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ut({key:new Jt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||IC(n.selection)||t.view.dragging?null:It.create(n.doc,[qt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Mw({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var XP=Pt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Jt(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new Ut({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:d,schema:f}=o,h=e.getState(o),m=l.content.size,g=f.nodes[n];if(h)return d.insert(m,g.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Mw({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Mw({node:o,types:r})}}})]}}),QP=Pt.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>b_(t,e),redo:()=>({state:t,dispatch:e})=>x_(t,e)}},addProseMirrorPlugins(){return[qP(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()}}}),ef=YP,ZP=cs.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",zt(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()}}}),e4=ZP,t4=cs.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",zt(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()}}}),n4=t4;let Wg,Vg;if(typeof WeakMap<"u"){let t=new WeakMap;Wg=e=>t.get(e),Vg=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Wg=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Vg=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var vn=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:d,bottom:f}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,d),right:Math.max(r,l),bottom:Math.max(i,f)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return Wg(t)||Vg(t,r4(t))}};function r4(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=s4(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let f=0,h=e*n;f<h;f++)r[f]=0;for(let f=0,h=0;f<n;f++){const m=t.child(f);h++;for(let x=0;;x++){for(;s<r.length&&r[s]!=0;)s++;if(x==m.childCount)break;const k=m.child(x),{colspan:w,rowspan:S,colwidth:N}=k.attrs;for(let T=0;T<S;T++){if(T+f>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:h,n:S-T});break}const M=s+T*e;for(let _=0;_<w;_++){r[M+_]==0?r[M+_]=h:(i||(i=[])).push({type:"collision",row:f,pos:h,n:w-_});const R=N&&N[_];if(R){const I=(M+_)%e*2,$=o[I];$==null||$!=R&&o[I+1]==1?(o[I]=R,o[I+1]=1):$==R&&o[I+1]++}}}s+=w,h+=k.nodeSize}const g=(f+1)*e;let v=0;for(;s<g;)r[s++]==0&&v++;v&&(i||(i=[])).push({type:"missing",row:f,n:v}),h++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new vn(e,n,r,i);let d=!1;for(let f=0;!d&&f<o.length;f+=2)o[f]!=null&&o[f+1]<n&&(d=!0);return d&&i4(l,o,t),l}function s4(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let d=0;d<l.childCount;d++){const f=l.child(d);o+f.attrs.rowspan>r&&(i+=f.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function i4(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const d=o.attrs;for(let f=0;f<d.colspan;f++){const h=e[(s+f)%t.width*2];h!=null&&(!d.colwidth||d.colwidth[f]!=h)&&((l||(l=o4(d)))[f]=h)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function o4(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function or(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const wi=new Jt("selectingCells");function bo(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 a4(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 us(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 tf(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=bo(e.$head)||l4(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function l4(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 qg(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function c4(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Yv(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function w_(t,e,n){const r=t.node(-1),s=vn.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function xo(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function k_(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function u4(t,e,n){const r=or(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var tn=class zs extends yt{constructor(e,n=e){const r=e.node(-1),s=vn.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),d=s.cellsInRect(o).filter(h=>h!=n.pos-i);d.unshift(n.pos-i);const f=d.map(h=>{const m=r.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const g=i+h+1;return new SN(l.resolve(g),l.resolve(g+m.content.size))});super(f[0].$from,f[0].$to,f),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(qg(r)&&qg(s)&&Yv(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?zs.rowSelection(r,s):i&&this.isColSelection()?zs.colSelection(r,s):new zs(r,s)}return ft.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=vn.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let d=s.top;d<s.bottom;d++){const f=[];for(let h=d*n.width+s.left,m=s.left;m<s.right;m++,h++){const g=n.map[h];if(i[g])continue;i[g]=!0;const v=n.findCell(g);let x=e.nodeAt(g);if(!x)throw new RangeError(`No cell with offset ${g} found`);const k=s.left-v.left,w=v.right-s.right;if(k>0||w>0){let S=x.attrs;if(k>0&&(S=xo(S,0,k)),w>0&&(S=xo(S,S.colspan-w,w)),v.left<s.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(v.top<s.top||v.bottom>s.bottom){const S={...x.attrs,rowspan:Math.min(v.bottom,s.bottom)-Math.max(v.top,s.top)};v.top<s.top?x=x.type.createAndFill(S):x=x.type.create(S,x.content)}f.push(x)}o.push(e.child(d).copy(we.from(f)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Ue(we.from(l),1,1)}replace(e,n=Ue.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:d}=s[o],f=e.mapping.slice(r);e.replace(f.map(l.pos),f.map(d.pos),o?Ue.empty:n)}const i=yt.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Ue(we.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=vn.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=vn.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),d=e.node(0);return o.top<=l.top?(o.top>0&&(e=d.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=d.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=d.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=d.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new zs(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=vn.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof zs&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=vn.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),d=e.node(0);return o.left<=l.left?(o.left>0&&(e=d.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=d.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=d.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=d.resolve(i+s.map[s.width*(o.top+1)-1]))),new zs(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new zs(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new zs(e.resolve(n),e.resolve(r))}getBookmark(){return new d4(this.$anchorCell.pos,this.$headCell.pos)}};tn.prototype.visible=!1;yt.jsonID("cell",tn);var d4=class S_{constructor(e,n){this.anchor=e,this.head=n}map(e){return new S_(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&&Yv(n,r)?new tn(n,r):yt.near(r,1)}};function f4(t){if(!(t.selection instanceof tn))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(qt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),It.create(t.doc,e)}function h4({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function p4({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function m4(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof ut&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=tn.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=tn.rowSelection(l,l)}else if(!n){const l=vn.get(r.node),d=r.from+1,f=d+l.map[l.width*l.height-1];i=tn.create(s,d+1,f)}}else r instanceof ft&&h4(r)?i=ft.create(s,r.from):r instanceof ft&&p4(r)&&(i=ft.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const g4=new Jt("fix-tables");function E_(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const d=e.child(o);for(let f=l,h=Math.min(s,o+3);f<h;f++)if(t.child(f)==d){l=f+1,n+=d.nodeSize;continue e}r(d,n),l<s&&t.child(l).sameMarkup(d)?E_(t.child(l),d,n+1,r):d.nodesBetween(0,d.content.size,r,n+1),n+=d.nodeSize}}function N_(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=v4(t,s,i,n))};return e?e.doc!=t.doc&&E_(e.doc,t.doc,0,r):t.doc.descendants(r),n}function v4(t,e,n,r){const s=vn.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let d=0;d<s.height;d++)i.push(0);for(let d=0;d<s.problems.length;d++){const f=s.problems[d];if(f.type=="collision"){const h=e.nodeAt(f.pos);if(!h)continue;const m=h.attrs;for(let g=0;g<m.rowspan;g++)i[f.row+g]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,xo(m,m.colspan-f.n,f.n))}else if(f.type=="missing")i[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const h=r.mapping.map(n);r.delete(h,h+e.nodeSize)}}let o,l;for(let d=0;d<i.length;d++)i[d]&&(o==null&&(o=d),l=d);for(let d=0,f=n+1;d<s.height;d++){const h=e.child(d),m=f+h.nodeSize,g=i[d];if(g>0){let v="cell";h.firstChild&&(v=h.firstChild.type.spec.tableRole);const x=[];for(let w=0;w<g;w++){const S=or(t.schema)[v].createAndFill();S&&x.push(S)}const k=(d==0||o==d-1)&&l==d?f+1:m-1;r.insert(r.mapping.map(k),x)}f=m}return r.setMeta(g4,{fixTables:!0})}function Cs(t){const e=t.selection,n=tf(t),r=n.node(-1),s=n.start(-1),i=vn.get(r);return{...e instanceof tn?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function C_(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;u4(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const d=e.map[l],f=r.nodeAt(d);t.setNodeMarkup(t.mapping.map(n+d),null,k_(f.attrs,s-e.colCount(d))),o+=f.attrs.rowspan-1}else{const d=i==null?or(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,f=e.positionAt(o,s,r);t.insert(t.mapping.map(n+f),d.createAndFill())}}return t}function y4(t,e){if(!us(t))return!1;if(e){const n=Cs(t);e(C_(t.tr,n,n.left))}return!0}function b4(t,e){if(!us(t))return!1;if(e){const n=Cs(t);e(C_(t.tr,n,n.right))}return!0}function x4(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,d=e.map[l],f=n.nodeAt(d),h=f.attrs;if(s>0&&e.map[l-1]==d||s<e.width-1&&e.map[l+1]==d)t.setNodeMarkup(t.mapping.slice(i).map(r+d),null,xo(h,s-e.colCount(d)));else{const m=t.mapping.slice(i).map(r+d);t.delete(m,m+f.nodeSize)}o+=h.rowspan}}function w4(t,e){if(!us(t))return!1;if(e){const n=Cs(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;x4(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=vn.get(i)}e(r)}return!0}function k4(t,e,n){var r;const s=or(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function __(t,{map:e,tableStart:n,table:r},s){let i=n;for(let f=0;f<s;f++)i+=r.child(f).nodeSize;const o=[];let l=s>0?-1:0;k4(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let f=0,h=e.width*s;f<e.width;f++,h++)if(s>0&&s<e.height&&e.map[h]==e.map[h-e.width]){const m=e.map[h],g=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var d;const m=l==null?or(r.type.schema).cell:(d=r.nodeAt(e.map[h+l*e.width]))===null||d===void 0?void 0:d.type,g=m==null?void 0:m.createAndFill();g&&o.push(g)}return t.insert(i,or(r.type.schema).row.create(null,o)),t}function S4(t,e){if(!us(t))return!1;if(e){const n=Cs(t);e(__(t.tr,n,n.top))}return!0}function E4(t,e){if(!us(t))return!1;if(e){const n=Cs(t);e(__(t.tr,n,n.bottom))}return!0}function N4(t,{map:e,table:n,tableStart:r},s){let i=0;for(let f=0;f<s;f++)i+=n.child(f).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const d=new Set;for(let f=0,h=s*e.width;f<e.width;f++,h++){const m=e.map[h];if(!d.has(m)){if(d.add(m),s>0&&m==e.map[h-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g,rowspan:g.rowspan-1}),f+=g.colspan-1}else if(s<e.height&&m==e.map[h+e.width]){const g=n.nodeAt(m),v=g.attrs,x=g.type.create({...v,rowspan:g.attrs.rowspan-1},g.content),k=e.positionAt(s+1,f,n);t.insert(t.mapping.slice(l).map(r+k),x),f+=v.colspan-1}}}}function C4(t,e){if(!us(t))return!1;if(e){const n=Cs(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;N4(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=vn.get(n.table)}e(r)}return!0}function Aw(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function _4({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let d=r.top;d<r.bottom;d++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let d=r.left;d<r.right;d++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Rw(t,e){const n=t.selection;if(!(n instanceof tn)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Cs(t),{map:s}=r;if(_4(s,r))return!1;if(e){const i=t.tr,o={};let l=we.empty,d,f;for(let h=r.top;h<r.bottom;h++)for(let m=r.left;m<r.right;m++){const g=s.map[h*s.width+m],v=r.table.nodeAt(g);if(!(o[g]||!v))if(o[g]=!0,d==null)d=g,f=v;else{Aw(v)||(l=l.append(v.content));const x=i.mapping.map(g+r.tableStart);i.delete(x,x+v.nodeSize)}}if(d==null||f==null)return!0;if(i.setNodeMarkup(d+r.tableStart,null,{...k_(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const h=d+1+f.content.size,m=Aw(f)?d+1:h;i.replaceWith(m+r.tableStart,h+r.tableStart,l)}i.setSelection(new tn(i.doc.resolve(d+r.tableStart))),e(i)}return!0}function Ow(t,e){const n=or(t.schema);return T4(({node:r})=>n[r.type.spec.tableRole])(t,e)}function T4(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof tn){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=a4(r.$from),!s)return!1;i=(o=bo(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const d=[],f=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const h=Cs(e),m=e.tr;for(let v=0;v<h.right-h.left;v++)d.push(f?{...l,colwidth:f&&f[v]?[f[v]]:null}:l);let g;for(let v=h.top;v<h.bottom;v++){let x=h.map.positionAt(v,h.left,h.table);v==h.top&&(x+=s.nodeSize);for(let k=h.left,w=0;k<h.right;k++,w++)k==h.left&&v==h.top||m.insert(g=m.mapping.map(x+h.tableStart,1),t({node:s,row:v,col:k}).createAndFill(d[w]))}m.setNodeMarkup(i,t({node:s,row:h.top,col:h.left}),d[0]),r instanceof tn&&m.setSelection(new tn(m.doc.resolve(r.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function j4(t,e){return function(n,r){if(!us(n))return!1;const s=tf(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof tn?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function M4(t){return function(e,n){if(!us(e))return!1;if(n){const r=or(e.schema),s=Cs(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(d=>s.table.nodeAt(d));for(let d=0;d<o.length;d++)l[d].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[d],r.cell,l[d].attrs);if(i.steps.length===0)for(let d=0;d<o.length;d++)i.setNodeMarkup(s.tableStart+o[d],r.header_cell,l[d].attrs);n(i)}return!0}}function Iw(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Rl(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?M4(t):function(n,r){if(!us(n))return!1;if(r){const s=or(n.schema),i=Cs(n),o=n.tr,l=Iw("row",i,s),d=Iw("column",i,s),f=(t==="column"?l:t==="row"&&d)?1:0,h=t=="column"?{left:0,top:f,right:1,bottom:i.map.height}:t=="row"?{left:f,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?d?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(h).forEach(g=>{const v=g+i.tableStart,x=o.doc.nodeAt(v);x&&o.setNodeMarkup(v,m,x.attrs)}),r(o)}return!0}}Rl("row",{useDeprecatedLogic:!0});Rl("column",{useDeprecatedLogic:!0});const A4=Rl("cell",{useDeprecatedLogic:!0});function R4(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Lw(t){return function(e,n){if(!us(e))return!1;const r=R4(tf(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(ft.between(s,c4(s))).scrollIntoView())}return!0}}function O4(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 cu(t,e){const n=t.selection;if(!(n instanceof tn))return!1;if(e){const r=t.tr,s=or(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new Ue(s,0,0))}),r.docChanged&&e(r)}return!0}function I4(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let d=0;d<e.childCount;d++){let f=e.child(d).content;const h=d?0:Math.max(0,n-1),m=d<e.childCount-1?0:Math.max(0,r-1);(h||m)&&(f=Kg(or(o).row,new Ue(f,h,m)).content),l.push(f)}else if(i=="cell"||i=="header_cell")l.push(n||r?Kg(or(o).row,new Ue(e,n,r)).content:e);else return null;return L4(o,l)}function L4(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:d}=i.child(o).attrs;for(let f=s;f<s+l;f++)n[f]=(n[f]||0)+d}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(we.empty),n[s]<r){const i=or(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(we.from(o))}return{height:e.length,width:r,rows:e}}function Kg(t,e){const n=t.createAndFill();return new lv(n).replace(0,n.content.size,e).doc}function D4({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const d=n[l],f=[];for(let h=i[l]||0,m=0;h<r;m++){let g=d.child(m%d.childCount);h+g.attrs.colspan>r&&(g=g.type.createChecked(xo(g.attrs,g.attrs.colspan,h+g.attrs.colspan-r),g.content)),f.push(g),h+=g.attrs.colspan;for(let v=1;v<g.attrs.rowspan;v++)i[l+v]=(i[l+v]||0)+g.attrs.colspan}o.push(we.from(f))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const d=[],f=n[l%e];for(let h=0;h<f.childCount;h++){let m=f.child(h);o+m.attrs.rowspan>s&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,s-m.attrs.rowspan)},m.content)),d.push(m)}i.push(we.from(d))}n=i,e=s}return{width:t,height:e,rows:n}}function P4(t,e,n,r,s,i,o){const l=t.doc.type.schema,d=or(l);let f,h;if(s>e.width)for(let m=0,g=0;m<e.height;m++){const v=n.child(m);g+=v.nodeSize;const x=[];let k;v.lastChild==null||v.lastChild.type==d.cell?k=f||(f=d.cell.createAndFill()):k=h||(h=d.header_cell.createAndFill());for(let w=e.width;w<s;w++)x.push(k);t.insert(t.mapping.slice(o).map(g-1+r),x)}if(i>e.height){const m=[];for(let x=0,k=(e.height-1)*e.width;x<Math.max(e.width,s);x++){const w=x>=e.width?!1:n.nodeAt(e.map[k+x]).type==d.header_cell;m.push(w?h||(h=d.header_cell.createAndFill()):f||(f=d.cell.createAndFill()))}const g=d.row.create(null,we.from(m)),v=[];for(let x=e.height;x<i;x++)v.push(g);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),v)}return!!(f||h)}function Dw(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let d=!1;for(let f=s;f<i;f++){const h=o*e.width+f,m=e.map[h];if(e.map[h-e.width]==m){d=!0;const g=n.nodeAt(m),{top:v,left:x}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g.attrs,rowspan:o-v}),t.insert(t.mapping.slice(l).map(e.positionAt(o,x,n)),g.type.createAndFill({...g.attrs,rowspan:v+g.attrs.rowspan-o})),f+=g.attrs.colspan-1}}return d}function Pw(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let d=!1;for(let f=s;f<i;f++){const h=f*e.width+o,m=e.map[h];if(e.map[h-1]==m){d=!0;const g=n.nodeAt(m),v=e.colCount(m),x=t.mapping.slice(l).map(m+r);t.setNodeMarkup(x,null,xo(g.attrs,o-v,g.attrs.colspan-(o-v))),t.insert(x+g.nodeSize,g.type.createAndFill(xo(g.attrs,0,o-v))),f+=g.attrs.rowspan-1}}return d}function Bw(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=vn.get(i);const{top:l,left:d}=r,f=d+s.width,h=l+s.height,m=t.tr;let g=0;function v(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");o=vn.get(i),g=m.mapping.maps.length}P4(m,o,i,n,f,h,g)&&v(),Dw(m,o,i,n,d,f,l,g)&&v(),Dw(m,o,i,n,d,f,h,g)&&v(),Pw(m,o,i,n,l,h,d,g)&&v(),Pw(m,o,i,n,l,h,f,g)&&v();for(let x=l;x<h;x++){const k=o.positionAt(x,d,i),w=o.positionAt(x,f,i);m.replace(m.mapping.slice(g).map(k+n),m.mapping.slice(g).map(w+n),new Ue(s.rows[x-l],0,0))}v(),m.setSelection(new tn(m.doc.resolve(n+o.positionAt(l,d,i)),m.doc.resolve(n+o.positionAt(h-1,f-1,i)))),e(m)}const B4=Ev({ArrowLeft:uu("horiz",-1),ArrowRight:uu("horiz",1),ArrowUp:uu("vert",-1),ArrowDown:uu("vert",1),"Shift-ArrowLeft":du("horiz",-1),"Shift-ArrowRight":du("horiz",1),"Shift-ArrowUp":du("vert",-1),"Shift-ArrowDown":du("vert",1),Backspace:cu,"Mod-Backspace":cu,Delete:cu,"Mod-Delete":cu});function Pu(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function uu(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof tn)return Pu(n,r,yt.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=T_(s,t,e);if(o==null)return!1;if(t=="horiz")return Pu(n,r,yt.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),d=w_(l,t,e);let f;return d?f=yt.near(d,1):e<0?f=yt.near(n.doc.resolve(l.before(-1)),-1):f=yt.near(n.doc.resolve(l.after(-1)),1),Pu(n,r,f)}}}function du(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof tn)o=i;else{const d=T_(s,t,e);if(d==null)return!1;o=new tn(n.doc.resolve(d))}const l=w_(o.$headCell,t,e);return l?Pu(n,r,new tn(o.$anchorCell,l)):!1}}function $4(t,e){const n=t.state.doc,r=bo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new tn(r))),!0):!1}function F4(t,e,n){if(!us(t.state))return!1;let r=I4(n);const s=t.state.selection;if(s instanceof tn){r||(r={width:1,height:1,rows:[we.from(Kg(or(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=vn.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=D4(r,l.right-l.left,l.bottom-l.top),Bw(t.state,t.dispatch,o,l,r),!0}else if(r){const i=tf(t.state),o=i.start(-1);return Bw(t.state,t.dispatch,o,vn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function z4(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=$w(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof tn)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=bo(t.state.selection.$anchor))!=null&&((n=Np(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(d,f){let h=Np(t,f);const m=wi.getState(t.state)==null;if(!h||!Yv(d,h))if(m)h=d;else return;const g=new tn(d,h);if(m||!t.state.selection.eq(g)){const v=t.state.tr.setSelection(g);m&&v.setMeta(wi,d.pos),t.dispatch(v)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),wi.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(wi,-1))}function l(d){const f=d,h=wi.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if($w(t,f.target)!=r&&(m=Np(t,e),!m))return o();m&&i(m,f)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function T_(t,e,n){if(!(t.state.selection instanceof ft))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function $w(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Np(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&bo(t.state.doc.resolve(r))||bo(t.state.doc.resolve(s))}var U4=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")),Gg(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,Gg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Gg(t,e,n,r,s,i){let o=0,l=!0,d=e.firstChild;const f=t.firstChild;if(f){for(let m=0,g=0;m<f.childCount;m++){const{colspan:v,colwidth:x}=f.child(m).attrs;for(let k=0;k<v;k++,g++){const w=s==g?i:x&&x[k],S=w?w+"px":"";if(o+=w||r,w||(l=!1),d)d.style.width!=S&&(d.style.width=S),d=d.nextSibling;else{const N=document.createElement("col");N.style.width=S,e.appendChild(N)}}}for(;d;){var h;const m=d.nextSibling;(h=d.parentNode)===null||h===void 0||h.removeChild(d),d=m}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Ar=new Jt("tableColumnResizing");function H4({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=U4,lastColumnResizable:s=!0}={}){const i=new Ut({key:Ar,state:{init(o,l){var d;const f=(d=i.spec)===null||d===void 0||(d=d.props)===null||d===void 0?void 0:d.nodeViews,h=or(l.schema).table.name;return r&&f&&(f[h]=(m,g)=>new r(m,n,g)),new W4(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Ar.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{V4(o,l,t,s)},mouseleave:o=>{q4(o)},mousedown:(o,l)=>{K4(o,l,e,n)}},decorations:o=>{const l=Ar.getState(o);if(l&&l.activeHandle>-1)return Q4(o,l.activeHandle)},nodeViews:{}}});return i}var W4=class Bu{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ar);if(r&&r.setHandle!=null)return new Bu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Bu(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return qg(e.doc.resolve(s))||(s=-1),new Bu(s,n.dragging)}return n}};function V4(t,e,n,r){if(!t.editable)return;const s=Ar.getState(t.state);if(s&&!s.dragging){const i=J4(e.target);let o=-1;if(i){const{left:l,right:d}=i.getBoundingClientRect();e.clientX-l<=n?o=Fw(t,e,"left",n):d-e.clientX<=n&&(o=Fw(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),d=l.node(-1),f=vn.get(d),h=l.start(-1);if(f.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==f.width-1)return}j_(t,o)}}}function q4(t){if(!t.editable)return;const e=Ar.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&j_(t,-1)}function K4(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Ar.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),d=G4(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Ar,{setDragging:{startX:e.clientX,startWidth:d}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",h);const g=Ar.getState(t.state);g!=null&&g.dragging&&(Y4(t,g.activeHandle,zw(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Ar,{setDragging:null})))}function h(m){if(!m.which)return f(m);const g=Ar.getState(t.state);if(g&&g.dragging){const v=zw(g.dragging,m,n);Uw(t,g.activeHandle,v,r)}}return Uw(t,o.activeHandle,d,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",h),e.preventDefault(),!0}function G4(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let d=0;d<n;d++)r[d]&&(o-=r[d],l--);return o/l}function J4(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Fw(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=bo(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const d=vn.get(l.node(-1)),f=l.start(-1),h=d.map.indexOf(l.pos-f);return h%d.width==0?-1:f+d.map[h-1]}function zw(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function j_(t,e){t.dispatch(t.state.tr.setMeta(Ar,{setHandle:e}))}function Y4(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=vn.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,d=t.state.tr;for(let f=0;f<i.height;f++){const h=f*i.width+l;if(f&&i.map[h]==i.map[h-i.width])continue;const m=i.map[h],g=s.nodeAt(m).attrs,v=g.colspan==1?0:l-i.colCount(m);if(g.colwidth&&g.colwidth[v]==n)continue;const x=g.colwidth?g.colwidth.slice():X4(g.colspan);x[v]=n,d.setNodeMarkup(o+m,null,{...g,colwidth:x})}d.docChanged&&t.dispatch(d)}function Uw(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=vn.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let d=t.domAtPos(s.start(-1)).node;for(;d&&d.nodeName!="TABLE";)d=d.parentNode;d&&Gg(i,d.firstChild,d,r,l,n)}function X4(t){return Array(t).fill(0)}function Q4(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return It.empty;const i=vn.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<i.height;f++){const h=l+f*i.width;if((l==i.width-1||i.map[h]!=i.map[h+1])&&(f==0||i.map[h]!=i.map[h-i.width])){var d;const m=i.map[h],g=o+m+s.nodeAt(m).nodeSize-1,v=document.createElement("div");v.className="column-resize-handle",!((d=Ar.getState(t))===null||d===void 0)&&d.dragging&&n.push(qt.node(o+m,o+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(qt.widget(g,v))}}return It.create(t.doc,n)}function Z4({allowTableNodeSelection:t=!1}={}){return new Ut({key:wi,state:{init(){return null},apply(e,n){const r=e.getMeta(wi);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:f4,handleDOMEvents:{mousedown:z4},createSelectionBetween(e){return wi.getState(e.state)!=null?e.state.selection:null},handleTripleClick:$4,handleKeyDown:B4,handlePaste:F4},appendTransaction(e,n,r){return m4(r,N_(r,n),t)}})}var M_=bn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",zt(this.options.HTMLAttributes,t),0]}}),A_=bn.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",zt(this.options.HTMLAttributes,t),0]}}),R_=bn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",zt(this.options.HTMLAttributes,t),0]}});function Jg(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Hw(t,e,n,r,s,i){var o;let l=0,d=!0,f=e.firstChild;const h=t.firstChild;if(h!==null)for(let g=0,v=0;g<h.childCount;g+=1){const{colspan:x,colwidth:k}=h.child(g).attrs;for(let w=0;w<x;w+=1,v+=1){const S=s===v?i:k&&k[w],N=S?`${S}px`:"";if(l+=S||r,S||(d=!1),f){if(f.style.width!==N){const[T,M]=Jg(r,S);f.style.setProperty(T,M)}f=f.nextSibling}else{const T=document.createElement("col"),[M,_]=Jg(r,S);T.style.setProperty(M,_),e.appendChild(T)}}}for(;f;){const g=f.nextSibling;(o=f.parentNode)==null||o.removeChild(f),f=g}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);d&&!m?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var e3=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")),Hw(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,Hw(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 t3(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let m=0,g=0;m<l.childCount;m+=1){const{colspan:v,colwidth:x}=l.child(m).attrs;for(let k=0;k<v;k+=1,g+=1){const w=n===g?r:x&&x[k];s+=w||e,w||(i=!1);const[S,N]=Jg(e,w);o.push(["col",{style:`${S}: ${N}`}])}}const d=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:d,tableMinWidth:f}}function Ww(t,e){return t.createAndFill()}function n3(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 r3(t,e,n,r,s){const i=n3(t),o=[],l=[];for(let f=0;f<n;f+=1){const h=Ww(i.cell);if(h&&l.push(h),r){const m=Ww(i.header_cell);m&&o.push(m)}}const d=[];for(let f=0;f<e;f+=1)d.push(i.row.createChecked(null,r&&f===0?o:l));return i.table.createChecked(null,d)}function s3(t){return t instanceof tn}var fu=({editor:t})=>{const{selection:e}=t.state;if(!s3(e))return!1;let n=0;const r=_C(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},i3="";function o3(t){return(t||"").replace(/\s+/g," ").trim()}function a3(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:i3;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(x=>{const k=[];x.content&&x.content.forEach(w=>{let S="";w.content&&Array.isArray(w.content)&&w.content.length>1?S=w.content.map(_=>e.renderChildren(_)).join(s):S=w.content?e.renderChildren(w.content):"";const N=o3(S),T=w.type==="tableHeader";k.push({text:N,isHeader:T})}),i.push(k)});const o=i.reduce((x,k)=>Math.max(x,k.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(x=>{var k;for(let w=0;w<o;w+=1){const N=(((k=x[w])==null?void 0:k.text)||"").length;N>l[w]&&(l[w]=N),l[w]<3&&(l[w]=3)}});const d=(x,k)=>x+" ".repeat(Math.max(0,k-x.length)),f=i[0],h=f.some(x=>x.isHeader);let m=`
160
- `;const g=new Array(o).fill(0).map((x,k)=>h&&f[k]&&f[k].text||"");return m+=`| ${g.map((x,k)=>d(x,l[k])).join(" | ")} |
161
- `,m+=`| ${l.map(x=>"-".repeat(Math.max(3,x))).join(" | ")} |
162
- `,(h?i.slice(1):i).forEach(x=>{m+=`| ${new Array(o).fill(0).map((k,w)=>d(x[w]&&x[w].text||"",l[w])).join(" | ")} |
163
- `}),m}var l3=a3,O_=bn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:e3,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=t3(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",zt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>l3(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=r3(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(ft.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>y4(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>b4(t,e),deleteColumn:()=>({state:t,dispatch:e})=>w4(t,e),addRowBefore:()=>({state:t,dispatch:e})=>S4(t,e),addRowAfter:()=>({state:t,dispatch:e})=>E4(t,e),deleteRow:()=>({state:t,dispatch:e})=>C4(t,e),deleteTable:()=>({state:t,dispatch:e})=>O4(t,e),mergeCells:()=>({state:t,dispatch:e})=>Rw(t,e),splitCell:()=>({state:t,dispatch:e})=>Ow(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Rl("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Rl("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>A4(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Rw(t,e)?!0:Ow(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>j4(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Lw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Lw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&N_(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=tn.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:fu,"Mod-Backspace":fu,Delete:fu,"Mod-Delete":fu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[H4({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Z4({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Gt(ct(t,"tableRole",e))}}});Pt.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(O_.configure(this.options.table)),this.options.tableCell!==!1&&t.push(M_.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(A_.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(R_.configure(this.options.tableRow)),t}});var c3=Object.defineProperty,u3=(t,e)=>{for(var n in e)c3(t,n,{get:e[n],enumerable:!0})},d3="listItem",Vw="textStyle",qw=/^\s*([-+*])\s$/,I_=bn.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",zt(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(d3,this.editor.getAttributes(Vw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ma({find:qw,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ma({find:qw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vw),editor:this.editor})),[t]}}),L_=bn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",zt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Dv(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),f3={};u3(f3,{findListItemPos:()=>zl,getNextListDepth:()=>Xv,handleBackspace:()=>Yg,handleDelete:()=>Xg,hasListBefore:()=>D_,hasListItemAfter:()=>h3,hasListItemBefore:()=>P_,listItemHasSubList:()=>B_,nextListIsDeeper:()=>$_,nextListIsHigher:()=>F_});var zl=(t,e)=>{const{$from:n}=e.selection,r=Tn(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Xv=(t,e)=>{const n=zl(t,e);if(!n)return!1;const[,r]=WI(e,t,n.$pos.pos+4);return r},D_=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},P_=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},B_=(t,e,n)=>{if(!n)return!1;const r=Tn(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},Yg=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ri(t.state,e)&&D_(t.state,e,n)){const{$anchor:l}=t.state.selection,d=t.state.doc.resolve(l.before()-1),f=[];d.node().descendants((g,v)=>{g.type.name===e&&f.push({node:g,pos:v})});const h=f.at(-1);if(!h)return!1;const m=t.state.doc.resolve(d.start()+h.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},m.end()).joinForward().run()}if(!Ri(t.state,e)||!GI(t.state))return!1;const r=zl(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=B_(e,t.state,i);return P_(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},$_=(t,e)=>{const n=Xv(t,e),r=zl(t,e);return!r||!n?!1:n>r.depth},F_=(t,e)=>{const n=Xv(t,e),r=zl(t,e);return!r||!n?!1:n<r.depth},Xg=(t,e)=>{if(!Ri(t.state,e)||!KI(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:$_(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():F_(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},h3=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},z_=Pt.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&&Xg(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&&Xg(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&&Yg(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&&Yg(t,n,r)&&(e=!0)}),e}}}}),Kw=/^(\s*)(\d+)\.\s+(.*)$/,p3=/^\s/;function m3(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Kw);if(!i)break;const[,o,l,d]=i,f=o.length;let h=d,m=n+1;const g=[s];for(;m<t.length;){const v=t[m];if(v.match(Kw))break;if(v.trim()==="")g.push(v),h+=`
165
- `,m+=1;else if(v.match(p3))g.push(v),h+=`
166
- ${v.slice(f+2)}`,m+=1;else break}e.push({indent:f,number:parseInt(l,10),content:h.trim(),raw:g.join(`
167
- `)}),r=m,n=m}return[e,r]}function U_(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const l=o.content.split(`
168
- `),d=((r=l[0])==null?void 0:r.trim())||"",f=[];d&&f.push({type:"paragraph",raw:d,tokens:n.inlineTokens(d)});const h=l.slice(1).join(`
169
- `).trim();if(h){const v=n.blockTokens(h);f.push(...v)}let m=i+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const v=Math.min(...g.map(k=>k.indent)),x=U_(g,v,n);f.push({type:"list",ordered:!0,start:g[0].number,items:x,raw:g.map(k=>k.raw).join(`
170
- `)})}s.push({type:"list_item",raw:o.raw,tokens:f}),i=m}else i+=1}return s}function g3(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var v3="listItem",Gw="textStyle",Jw=/^(\d+)\.\s$/,H_=bn.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",zt(this.options.HTMLAttributes,n),0]:["ol",zt(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?g3(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
171
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
172
- `),[i,o]=m3(s);if(i.length===0)return;const l=U_(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
173
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(v3,this.editor.getAttributes(Gw)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ma({find:Jw,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=ma({find:Jw,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Gw)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),y3=/^\s*(\[([( |x])?\])\s$/,W_=bn.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",zt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Dv(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),d=document.createElement("div"),f=m=>{var g,v;l.ariaLabel=((v=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:v.call(g,m,l.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",m=>m.preventDefault()),l.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:v})=>{const x=n();if(typeof x!="number")return!1;const k=v.doc.nodeAt(x);return v.setNodeMarkup(x,void 0,{...k==null?void 0:k.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{s.setAttribute(m,g)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,d),Object.entries(e).forEach(([m,g])=>{s.setAttribute(m,g)});let h=new Set(Object.keys(e));return{dom:s,contentDOM:d,update:m=>{if(m.type!==this.type)return!1;s.dataset.checked=m.attrs.checked,l.checked=m.attrs.checked,f(m);const g=r.extensionManager.attributes,v=pa(m,g),x=new Set(Object.keys(v)),k=this.options.HTMLAttributes;return h.forEach(w=>{x.has(w)||(w in k?s.setAttribute(w,k[w]):s.removeAttribute(w))}),Object.entries(v).forEach(([w,S])=>{S==null?w in k?s.setAttribute(w,k[w]):s.removeAttribute(w):s.setAttribute(w,S)}),h=x,!0}}}},addInputRules(){return[ma({find:y3,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),V_=bn.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",zt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
174
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=Ig(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,d)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:d}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=Ig(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Pt.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(I_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(L_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(z_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(H_.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(W_.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(V_.configure(this.options.taskList)),t}});var b3=W_,x3=V_,w3=20,q_=(t,e=0)=>{const n=[];return!t.children.length||e>w3||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...q_(r,e+1))}),n},k3=t=>{if(!t.children.length)return;const e=q_(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},K_=cs.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&k3(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",zt(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),S3=Pt.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),E3=Pt.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),N3=Pt.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()}}}),C3=Pt.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()}}}),_3=Pt.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()}}});Pt.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(S3.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(E3.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(N3.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(C3.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(_3.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(K_.configure(this.options.textStyle)),t}});var T3=t=>yn({find:/--$/,replace:t??"—"}),j3=t=>yn({find:/\.\.\.$/,replace:t??"…"}),M3=t=>yn({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),A3=t=>yn({find:/"$/,replace:t??"”"}),R3=t=>yn({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),O3=t=>yn({find:/'$/,replace:t??"’"}),I3=t=>yn({find:/<-$/,replace:t??"←"}),L3=t=>yn({find:/->$/,replace:t??"→"}),D3=t=>yn({find:/\(c\)$/,replace:t??"©"}),P3=t=>yn({find:/\(tm\)$/,replace:t??"™"}),B3=t=>yn({find:/\(sm\)$/,replace:t??"℠"}),$3=t=>yn({find:/\(r\)$/,replace:t??"®"}),F3=t=>yn({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),z3=t=>yn({find:/\+\/-$/,replace:t??"±"}),U3=t=>yn({find:/!=$/,replace:t??"≠"}),H3=t=>yn({find:/<<$/,replace:t??"«"}),W3=t=>yn({find:/>>$/,replace:t??"»"}),V3=t=>yn({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),q3=t=>yn({find:/\^2$/,replace:t??"²"}),K3=t=>yn({find:/\^3$/,replace:t??"³"}),G3=t=>yn({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),J3=t=>yn({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),Y3=Pt.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(T3(this.options.emDash)),this.options.ellipsis!==!1&&t.push(j3(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(M3(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(A3(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(R3(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(O3(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(I3(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(L3(this.options.rightArrow)),this.options.copyright!==!1&&t.push(D3(this.options.copyright)),this.options.trademark!==!1&&t.push(P3(this.options.trademark)),this.options.servicemark!==!1&&t.push(B3(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push($3(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(F3(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(z3(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(U3(this.options.notEqual)),this.options.laquo!==!1&&t.push(H3(this.options.laquo)),this.options.raquo!==!1&&t.push(W3(this.options.raquo)),this.options.multiplication!==!1&&t.push(V3(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(q3(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(K3(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(G3(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(J3(this.options.threeQuarters)),t}}),X3=Y3,G_=cs.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",zt(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Q3=G_,Kn=[];for(var Cp=0;Cp<256;++Cp)Kn.push((Cp+256).toString(16).slice(1));function Z3(t,e=0){return(Kn[t[e+0]]+Kn[t[e+1]]+Kn[t[e+2]]+Kn[t[e+3]]+"-"+Kn[t[e+4]]+Kn[t[e+5]]+"-"+Kn[t[e+6]]+Kn[t[e+7]]+"-"+Kn[t[e+8]]+Kn[t[e+9]]+"-"+Kn[t[e+10]]+Kn[t[e+11]]+Kn[t[e+12]]+Kn[t[e+13]]+Kn[t[e+14]]+Kn[t[e+15]]).toLowerCase()}var hu,e6=new Uint8Array(16);function t6(){if(!hu&&(hu=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!hu))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hu(e6)}var n6=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Yw={randomUUID:n6};function r6(t,e,n){if(Yw.randomUUID&&!t)return Yw.randomUUID();t=t||{};var r=t.random||(t.rng||t6)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,Z3(r)}function s6(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 i6=Pt.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>r6(),filterTransaction:null,updateDocument:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>t[this.options.attributeName]?{[`data-${this.options.attributeName}`]:t[this.options.attributeName]}:{}}}}]},onCreate(){var t;if(!this.options.updateDocument)return;const e=this.editor.extensionManager.extensions.find(l=>l.name==="collaboration"),n=this.editor.extensionManager.extensions.find(l=>l.name==="collaborationCaret"),s=[e,n].filter(Boolean).find(l=>{var d;return(d=l==null?void 0:l.options)==null?void 0:d.provider}),i=(t=s==null?void 0:s.options)==null?void 0:t.provider,o=()=>{const{view:l,state:d}=this.editor,{tr:f,doc:h}=d,{types:m,attributeName:g,generateID:v}=this.options;Zu(h,k=>m.includes(k.type.name)&&k.attrs[g]===null).forEach(({node:k,pos:w})=>{f.setNodeMarkup(w,void 0,{...k.attrs,[g]:v({node:k,pos:w})})}),f.setMeta("addToHistory",!1),l.dispatch(f),i&&i.off("synced",o)};if(s){if(!i)return o();i.on("synced",o)}else return o()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new Ut({key:new Jt("uniqueID"),appendTransaction:(n,r,s)=>{const i=n.some(k=>k.docChanged)&&!r.doc.eq(s.doc),o=this.options.filterTransaction&&n.some(k=>{var w,S;return!((S=(w=this.options).filterTransaction)!=null&&S.call(w,k))});if(n.find(k=>k.getMeta("y-sync$"))||!i||o)return;const{tr:d}=s,{types:f,attributeName:h,generateID:m}=this.options,g=Tv(r.doc,n),{mapping:v}=g;if(Av(g).forEach(({newRange:k})=>{const w=CC(s.doc,k,N=>f.includes(N.type.name)),S=w.map(({node:N})=>N.attrs[h]).filter(N=>N!==null);w.forEach(({node:N,pos:T},M)=>{var _;const R=(_=d.doc.nodeAt(T))==null?void 0:_.attrs[h];if(R===null){d.setNodeMarkup(T,void 0,{...N.attrs,[h]:m({node:N,pos:T})});return}const I=w[M+1];if(I&&N.content.size===0){const q=d.doc.nodeAt(I.pos);if(q!=null&&q.attrs[h]&&q.attrs[h]!==R)return;d.setNodeMarkup(I.pos,void 0,{...I.node.attrs,[h]:R}),S[M+1]=R;const F=m({node:N,pos:T});return d.setNodeMarkup(T,void 0,{...N.attrs,[h]:F}),S[M]=F,d}const $=s6(S),{deleted:P}=v.invert().mapResult(T);P&&$.includes(R)&&d.setNodeMarkup(T,void 0,{...N.attrs,[h]:m({node:N,pos:T})})})}),!!d.steps.length)return d.setStoredMarks(s.tr.storedMarks),d.setMeta("__uniqueIDTransaction",!0),d},view(n){const r=s=>{var i;t=(i=n.dom.parentElement)!=null&&i.contains(s.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var s,i;return(t!==n.dom.parentElement||((s=r.dataTransfer)==null?void 0:s.effectAllowed)==="copyMove"||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:s}=this.options,i=o=>{const l=[];return o.forEach(d=>{if(d.isText){l.push(d);return}if(!r.includes(d.type.name)){l.push(d.copy(i(d.content)));return}const f=d.type.create({...d.attrs,[s]:null},i(d.content),d.marks);l.push(f)}),we.from(l)};return e=!1,new Ue(i(n.content),n.openStart,n.openEnd)}}})]}}),Qv=i6,Md=(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]},o6=/^\s*>\s$/,a6=bn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Md("blockquote",{...zt(this.options.HTMLAttributes,t),children:Md("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const l=e.renderChildren([s]).split(`
175
- `).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(l.join(`
176
- `))}),r.join(`
177
- ${n}
178
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ma({find:o6,type:this.type})]}}),l6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,c6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,u6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,d6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,f6=cs.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 Md("strong",{...zt(this.options.HTMLAttributes,t),children:Md("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[yo({find:l6,type:this.type}),yo({find:u6,type:this.type})]},addPasteRules(){return[Oi({find:c6,type:this.type}),Oi({find:d6,type:this.type})]}}),h6=/(^|[^`])`([^`]+)`(?!`)$/,p6=/(^|[^`])`([^`]+)`(?!`)/g,m6=cs.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",zt(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[yo({find:h6,type:this.type})]},addPasteRules(){return[Oi({find:p6,type:this.type})]}}),_p=4,g6=/^```([a-z]+)?[\s\n]$/,v6=/^~~~([a-z]+)?[\s\n]$/,J_=bn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:_p,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",zt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
179
- `):r=`\`\`\`${s}
180
-
181
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_p,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:d})=>{const{from:f,to:h}=s,v=r.doc.textBetween(f,h,`
182
- `,`
183
- `).split(`
184
- `).map(x=>l+x).join(`
185
- `);return d.replaceWith(f,h,r.schema.text(v)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:_p,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var d;const{pos:f}=i,h=i.start(),m=i.end(),v=r.doc.textBetween(h,m,`
186
- `,`
187
- `).split(`
188
- `);let x=0,k=0;const w=f-h;for(let R=0;R<v.length;R+=1){if(k+v[R].length>=w){x=R;break}k+=v[R].length+1}const N=((d=v[x].match(/^ */))==null?void 0:d[0])||"",T=Math.min(N.length,n);if(T===0)return!0;let M=h;for(let R=0;R<x;R+=1)M+=v[R].length+1;return l.delete(M,M+T),f-M<=T&&l.setSelection(ft.create(l.doc,M)),!0}):t.commands.command(({tr:l})=>{const{from:d,to:f}=s,g=r.doc.textBetween(d,f,`
189
- `,`
190
- `).split(`
191
- `).map(v=>{var x;const k=((x=v.match(/^ */))==null?void 0:x[0])||"",w=Math.min(k.length,n);return v.slice(w)}).join(`
192
- `);return l.replaceWith(d,f,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
193
-
194
- `);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:f})=>(f.setSelection(yt.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Og({find:g6,type:this.type,getAttributes:t=>({language:t[1]})}),Og({find:v6,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ut({key:new Jt("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,d=l.text(n.replace(/\r\n?/g,`
195
- `));return o.replaceSelectionWith(this.type.create({language:i},d)),o.selection.$from.parent.type!==this.type&&o.setSelection(ft.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),y6=J_,b6=bn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
196
-
197
- `):""}),x6=bn.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",zt(this.options.HTMLAttributes,t)]},renderText(){return`
198
- `},renderMarkdown:()=>`
199
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,d=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:h})=>{if(h&&d&&o){const m=d.filter(g=>l.includes(g.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),w6=bn.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]}`,zt(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Og({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),k6=bn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",zt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!LL(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return IC(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:d}=o.selection,f=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?o.setSelection(ft.create(o.doc,d.pos+1)):d.nodeAfter.isBlock?o.setSelection(ut.create(o.doc,d.pos)):o.setSelection(ft.create(o.doc,d.pos));else{const h=i.schema.nodes[this.options.nextNodeType]||d.parent.type.contentMatch.defaultType,m=h==null?void 0:h.create();m&&(o.insert(f,m),o.setSelection(ft.create(o.doc,f+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[XC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),S6=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,E6=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,N6=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,C6=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,_6=cs.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",zt(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[yo({find:S6,type:this.type}),yo({find:N6,type:this.type})]},addPasteRules(){return[Oi({find:E6,type:this.type}),Oi({find:C6,type:this.type})]}}),Xw="&nbsp;",T6=" ",j6=bn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",zt(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===Xw||r[0].text===T6)?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?Xw:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),M6=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,A6=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,R6=cs.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",zt(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[yo({find:M6,type:this.type})]},addPasteRules(){return[Oi({find:A6,type:this.type})]}}),O6=bn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),I6=Pt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(f6.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(a6.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(I_.configure(this.options.bulletList)),this.options.code!==!1&&s.push(m6.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(J_.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(b6.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(KP.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(GP.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(x6.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(w6.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(QP.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(k6.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(_6.configure(this.options.italic)),this.options.listItem!==!1&&s.push(L_.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(z_.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(m_.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(H_.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(j6.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(R6.configure(this.options.strike)),this.options.text!==!1&&s.push(O6.configure(this.options.text)),this.options.underline!==!1&&s.push(G_.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(XP.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),Zv=I6,Tp,Qw;function L6(){if(Qw)return Tp;Qw=1;function t(j){return j instanceof Map?j.clear=j.delete=j.set=function(){throw new Error("map is read-only")}:j instanceof Set&&(j.add=j.clear=j.delete=function(){throw new Error("set is read-only")}),Object.freeze(j),Object.getOwnPropertyNames(j).forEach(U=>{const ie=j[U],D=typeof ie;(D==="object"||D==="function")&&!Object.isFrozen(ie)&&t(ie)}),j}class e{constructor(U){U.data===void 0&&(U.data={}),this.data=U.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(j,...U){const ie=Object.create(null);for(const D in j)ie[D]=j[D];return U.forEach(function(D){for(const ce in D)ie[ce]=D[ce]}),ie}const s="</span>",i=j=>!!j.scope,o=(j,{prefix:U})=>{if(j.startsWith("language:"))return j.replace("language:","language-");if(j.includes(".")){const ie=j.split(".");return[`${U}${ie.shift()}`,...ie.map((D,ce)=>`${D}${"_".repeat(ce+1)}`)].join(" ")}return`${U}${j}`};class l{constructor(U,ie){this.buffer="",this.classPrefix=ie.classPrefix,U.walk(this)}addText(U){this.buffer+=n(U)}openNode(U){if(!i(U))return;const ie=o(U.scope,{prefix:this.classPrefix});this.span(ie)}closeNode(U){i(U)&&(this.buffer+=s)}value(){return this.buffer}span(U){this.buffer+=`<span class="${U}">`}}const d=(j={})=>{const U={children:[]};return Object.assign(U,j),U};class f{constructor(){this.rootNode=d(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(U){this.top.children.push(U)}openNode(U){const ie=d({scope:U});this.add(ie),this.stack.push(ie)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(U){return this.constructor._walk(U,this.rootNode)}static _walk(U,ie){return typeof ie=="string"?U.addText(ie):ie.children&&(U.openNode(ie),ie.children.forEach(D=>this._walk(U,D)),U.closeNode(ie)),U}static _collapse(U){typeof U!="string"&&U.children&&(U.children.every(ie=>typeof ie=="string")?U.children=[U.children.join("")]:U.children.forEach(ie=>{f._collapse(ie)}))}}class h extends f{constructor(U){super(),this.options=U}addText(U){U!==""&&this.add(U)}startScope(U){this.openNode(U)}endScope(){this.closeNode()}__addSublanguage(U,ie){const D=U.root;ie&&(D.scope=`language:${ie}`),this.add(D)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(j){return j?typeof j=="string"?j:j.source:null}function g(j){return k("(?=",j,")")}function v(j){return k("(?:",j,")*")}function x(j){return k("(?:",j,")?")}function k(...j){return j.map(ie=>m(ie)).join("")}function w(j){const U=j[j.length-1];return typeof U=="object"&&U.constructor===Object?(j.splice(j.length-1,1),U):{}}function S(...j){return"("+(w(j).capture?"":"?:")+j.map(D=>m(D)).join("|")+")"}function N(j){return new RegExp(j.toString()+"|").exec("").length-1}function T(j,U){const ie=j&&j.exec(U);return ie&&ie.index===0}const M=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _(j,{joinWith:U}){let ie=0;return j.map(D=>{ie+=1;const ce=ie;let me=m(D),se="";for(;me.length>0;){const he=M.exec(me);if(!he){se+=me;break}se+=me.substring(0,he.index),me=me.substring(he.index+he[0].length),he[0][0]==="\\"&&he[1]?se+="\\"+String(Number(he[1])+ce):(se+=he[0],he[0]==="("&&ie++)}return se}).map(D=>`(${D})`).join(U)}const R=/\b\B/,I="[a-zA-Z]\\w*",$="[a-zA-Z_]\\w*",P="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",q="\\b(0b[01]+)",F="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",G=(j={})=>{const U=/^#![ ]*\//;return j.binary&&(j.begin=k(U,/.*\b/,j.binary,/\b.*/)),r({scope:"meta",begin:U,end:/$/,relevance:0,"on:begin":(ie,D)=>{ie.index!==0&&D.ignoreMatch()}},j)},B={begin:"\\\\[\\s\\S]",relevance:0},W={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[B]},K={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[B]},ne={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},V=function(j,U,ie={}){const D=r({scope:"comment",begin:j,end:U,contains:[]},ie);D.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 ce=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 D.contains.push({begin:k(/[ ]+/,"(",ce,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),D},oe=V("//","$"),J=V("/\\*","\\*/"),A=V("#","$"),L={scope:"number",begin:P,relevance:0},ee={scope:"number",begin:z,relevance:0},pe={scope:"number",begin:q,relevance:0},xe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[B,{begin:/\[/,end:/\]/,relevance:0,contains:[B]}]},re={scope:"title",begin:I,relevance:0},Ne={scope:"title",begin:$,relevance:0},ke={begin:"\\.\\s*"+$,relevance:0};var Fe=Object.freeze({__proto__:null,APOS_STRING_MODE:W,BACKSLASH_ESCAPE:B,BINARY_NUMBER_MODE:pe,BINARY_NUMBER_RE:q,COMMENT:V,C_BLOCK_COMMENT_MODE:J,C_LINE_COMMENT_MODE:oe,C_NUMBER_MODE:ee,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(j){return Object.assign(j,{"on:begin":(U,ie)=>{ie.data._beginMatch=U[1]},"on:end":(U,ie)=>{ie.data._beginMatch!==U[1]&&ie.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:I,MATCH_NOTHING_RE:R,METHOD_GUARD:ke,NUMBER_MODE:L,NUMBER_RE:P,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:K,REGEXP_MODE:xe,RE_STARTERS_RE:F,SHEBANG:G,TITLE_MODE:re,UNDERSCORE_IDENT_RE:$,UNDERSCORE_TITLE_MODE:Ne});function Ge(j,U){j.input[j.index-1]==="."&&U.ignoreMatch()}function Re(j,U){j.className!==void 0&&(j.scope=j.className,delete j.className)}function Ze(j,U){U&&j.beginKeywords&&(j.begin="\\b("+j.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",j.__beforeBegin=Ge,j.keywords=j.keywords||j.beginKeywords,delete j.beginKeywords,j.relevance===void 0&&(j.relevance=0))}function gt(j,U){Array.isArray(j.illegal)&&(j.illegal=S(...j.illegal))}function ht(j,U){if(j.match){if(j.begin||j.end)throw new Error("begin & end are not supported with match");j.begin=j.match,delete j.match}}function ge(j,U){j.relevance===void 0&&(j.relevance=1)}const vt=(j,U)=>{if(!j.beforeMatch)return;if(j.starts)throw new Error("beforeMatch cannot be used with starts");const ie=Object.assign({},j);Object.keys(j).forEach(D=>{delete j[D]}),j.keywords=ie.keywords,j.begin=k(ie.beforeMatch,g(ie.begin)),j.starts={relevance:0,contains:[Object.assign(ie,{endsParent:!0})]},j.relevance=0,delete ie.beforeMatch},_t=["of","and","for","in","not","or","if","then","parent","list","value"],Et="keyword";function Dt(j,U,ie=Et){const D=Object.create(null);return typeof j=="string"?ce(ie,j.split(" ")):Array.isArray(j)?ce(ie,j):Object.keys(j).forEach(function(me){Object.assign(D,Dt(j[me],U,me))}),D;function ce(me,se){U&&(se=se.map(he=>he.toLowerCase())),se.forEach(function(he){const be=he.split("|");D[be[0]]=[me,ot(be[0],be[1])]})}}function ot(j,U){return U?Number(U):Le(j)?0:1}function Le(j){return _t.includes(j.toLowerCase())}const ve={},te=j=>{console.error(j)},je=(j,...U)=>{console.log(`WARN: ${j}`,...U)},Q=(j,U)=>{ve[`${j}/${U}`]||(console.log(`Deprecated as of ${j}. ${U}`),ve[`${j}/${U}`]=!0)},de=new Error;function fe(j,U,{key:ie}){let D=0;const ce=j[ie],me={},se={};for(let he=1;he<=U.length;he++)se[he+D]=ce[he],me[he+D]=!0,D+=N(U[he-1]);j[ie]=se,j[ie]._emit=me,j[ie]._multi=!0}function Je(j){if(Array.isArray(j.begin)){if(j.skip||j.excludeBegin||j.returnBegin)throw te("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),de;if(typeof j.beginScope!="object"||j.beginScope===null)throw te("beginScope must be object"),de;fe(j,j.begin,{key:"beginScope"}),j.begin=_(j.begin,{joinWith:""})}}function Ie(j){if(Array.isArray(j.end)){if(j.skip||j.excludeEnd||j.returnEnd)throw te("skip, excludeEnd, returnEnd not compatible with endScope: {}"),de;if(typeof j.endScope!="object"||j.endScope===null)throw te("endScope must be object"),de;fe(j,j.end,{key:"endScope"}),j.end=_(j.end,{joinWith:""})}}function it(j){j.scope&&typeof j.scope=="object"&&j.scope!==null&&(j.beginScope=j.scope,delete j.scope)}function dt(j){it(j),typeof j.beginScope=="string"&&(j.beginScope={_wrap:j.beginScope}),typeof j.endScope=="string"&&(j.endScope={_wrap:j.endScope}),Je(j),Ie(j)}function at(j){function U(se,he){return new RegExp(m(se),"m"+(j.case_insensitive?"i":"")+(j.unicodeRegex?"u":"")+(he?"g":""))}class ie{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(he,be){be.position=this.position++,this.matchIndexes[this.matchAt]=be,this.regexes.push([be,he]),this.matchAt+=N(he)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const he=this.regexes.map(be=>be[1]);this.matcherRe=U(_(he,{joinWith:"|"}),!0),this.lastIndex=0}exec(he){this.matcherRe.lastIndex=this.lastIndex;const be=this.matcherRe.exec(he);if(!be)return null;const Be=be.findIndex((Ht,Tt)=>Tt>0&&Ht!==void 0),Ee=this.matchIndexes[Be];return be.splice(0,Be),Object.assign(be,Ee)}}class D{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(he){if(this.multiRegexes[he])return this.multiRegexes[he];const be=new ie;return this.rules.slice(he).forEach(([Be,Ee])=>be.addRule(Be,Ee)),be.compile(),this.multiRegexes[he]=be,be}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(he,be){this.rules.push([he,be]),be.type==="begin"&&this.count++}exec(he){const be=this.getMatcher(this.regexIndex);be.lastIndex=this.lastIndex;let Be=be.exec(he);if(this.resumingScanAtSamePosition()&&!(Be&&Be.index===this.lastIndex)){const Ee=this.getMatcher(0);Ee.lastIndex=this.lastIndex+1,Be=Ee.exec(he)}return Be&&(this.regexIndex+=Be.position+1,this.regexIndex===this.count&&this.considerAll()),Be}}function ce(se){const he=new D;return se.contains.forEach(be=>he.addRule(be.begin,{rule:be,type:"begin"})),se.terminatorEnd&&he.addRule(se.terminatorEnd,{type:"end"}),se.illegal&&he.addRule(se.illegal,{type:"illegal"}),he}function me(se,he){const be=se;if(se.isCompiled)return be;[Re,ht,dt,vt].forEach(Ee=>Ee(se,he)),j.compilerExtensions.forEach(Ee=>Ee(se,he)),se.__beforeBegin=null,[Ze,gt,ge].forEach(Ee=>Ee(se,he)),se.isCompiled=!0;let Be=null;return typeof se.keywords=="object"&&se.keywords.$pattern&&(se.keywords=Object.assign({},se.keywords),Be=se.keywords.$pattern,delete se.keywords.$pattern),Be=Be||/\w+/,se.keywords&&(se.keywords=Dt(se.keywords,j.case_insensitive)),be.keywordPatternRe=U(Be,!0),he&&(se.begin||(se.begin=/\B|\b/),be.beginRe=U(be.begin),!se.end&&!se.endsWithParent&&(se.end=/\B|\b/),se.end&&(be.endRe=U(be.end)),be.terminatorEnd=m(be.end)||"",se.endsWithParent&&he.terminatorEnd&&(be.terminatorEnd+=(se.end?"|":"")+he.terminatorEnd)),se.illegal&&(be.illegalRe=U(se.illegal)),se.contains||(se.contains=[]),se.contains=[].concat(...se.contains.map(function(Ee){return qe(Ee==="self"?se:Ee)})),se.contains.forEach(function(Ee){me(Ee,be)}),se.starts&&me(se.starts,he),be.matcher=ce(be),be}if(j.compilerExtensions||(j.compilerExtensions=[]),j.contains&&j.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return j.classNameAliases=r(j.classNameAliases||{}),me(j)}function Ye(j){return j?j.endsWithParent||Ye(j.starts):!1}function qe(j){return j.variants&&!j.cachedVariants&&(j.cachedVariants=j.variants.map(function(U){return r(j,{variants:null},U)})),j.cachedVariants?j.cachedVariants:Ye(j)?r(j,{starts:j.starts?r(j.starts):null}):Object.isFrozen(j)?r(j):j}var lt="11.11.1";class bt extends Error{constructor(U,ie){super(U),this.name="HTMLInjectionError",this.html=ie}}const Ce=n,Se=r,We=Symbol("nomatch"),tt=7,He=function(j){const U=Object.create(null),ie=Object.create(null),D=[];let ce=!0;const me="Could not find the language '{}', did you forget to load/include a language module?",se={disableAutodetect:!0,name:"Plain text",contains:[]};let he={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function be(Ae){return he.noHighlightRe.test(Ae)}function Be(Ae){let nt=Ae.className+" ";nt+=Ae.parentNode?Ae.parentNode.className:"";const Ct=he.languageDetectRe.exec(nt);if(Ct){const Mt=cr(Ct[1]);return Mt||(je(me.replace("{}",Ct[1])),je("Falling back to no-highlight mode for this block.",Ae)),Mt?Ct[1]:"no-highlight"}return nt.split(/\s+/).find(Mt=>be(Mt)||cr(Mt))}function Ee(Ae,nt,Ct){let Mt="",an="";typeof nt=="object"?(Mt=Ae,Ct=nt.ignoreIllegals,an=nt.language):(Q("10.7.0","highlight(lang, code, ...args) has been deprecated."),Q("10.7.0",`Please use highlight(code, options) instead.
200
- https://github.com/highlightjs/highlight.js/issues/2277`),an=Ae,Mt=nt),Ct===void 0&&(Ct=!0);const nn={code:Mt,language:an};Qr("before:highlight",nn);const Nr=nn.result?nn.result:Ht(nn.language,nn.code,Ct);return Nr.code=nn.code,Qr("after:highlight",Nr),Nr}function Ht(Ae,nt,Ct,Mt){const an=Object.create(null);function nn($e,Xe){return $e.keywords[Xe]}function Nr(){if(!Nt.keywords){wn.addText(Yt);return}let $e=0;Nt.keywordPatternRe.lastIndex=0;let Xe=Nt.keywordPatternRe.exec(Yt),kt="";for(;Xe;){kt+=Yt.substring($e,Xe.index);const Lt=Dr.case_insensitive?Xe[0].toLowerCase():Xe[0],hn=nn(Nt,Lt);if(hn){const[On,mf]=hn;if(wn.addText(kt),kt="",an[Lt]=(an[Lt]||0)+1,an[Lt]<=tt&&(Fi+=mf),On.startsWith("_"))kt+=Xe[0];else{const Jl=Dr.classNameAliases[On]||On;Y(Xe[0],Jl)}}else kt+=Xe[0];$e=Nt.keywordPatternRe.lastIndex,Xe=Nt.keywordPatternRe.exec(Yt)}kt+=Yt.substring($e),wn.addText(kt)}function Ts(){if(Yt==="")return;let $e=null;if(typeof Nt.subLanguage=="string"){if(!U[Nt.subLanguage]){wn.addText(Yt);return}$e=Ht(Nt.subLanguage,Yt,!0,xa[Nt.subLanguage]),xa[Nt.subLanguage]=$e._top}else $e=cn(Yt,Nt.subLanguage.length?Nt.subLanguage:null);Nt.relevance>0&&(Fi+=$e.relevance),wn.__addSublanguage($e._emitter,$e.language)}function An(){Nt.subLanguage!=null?Ts():Nr(),Yt=""}function Y($e,Xe){$e!==""&&(wn.startScope(Xe),wn.addText($e),wn.endScope())}function ye($e,Xe){let kt=1;const Lt=Xe.length-1;for(;kt<=Lt;){if(!$e._emit[kt]){kt++;continue}const hn=Dr.classNameAliases[$e[kt]]||$e[kt],On=Xe[kt];hn?Y(On,hn):(Yt=On,Nr(),Yt=""),kt++}}function De($e,Xe){return $e.scope&&typeof $e.scope=="string"&&wn.openNode(Dr.classNameAliases[$e.scope]||$e.scope),$e.beginScope&&($e.beginScope._wrap?(Y(Yt,Dr.classNameAliases[$e.beginScope._wrap]||$e.beginScope._wrap),Yt=""):$e.beginScope._multi&&(ye($e.beginScope,Xe),Yt="")),Nt=Object.create($e,{parent:{value:Nt}}),Nt}function wt($e,Xe,kt){let Lt=T($e.endRe,kt);if(Lt){if($e["on:end"]){const hn=new e($e);$e["on:end"](Xe,hn),hn.isMatchIgnored&&(Lt=!1)}if(Lt){for(;$e.endsParent&&$e.parent;)$e=$e.parent;return $e}}if($e.endsWithParent)return wt($e.parent,Xe,kt)}function jt($e){return Nt.matcher.regexIndex===0?(Yt+=$e[0],1):(Xs=!0,0)}function Zn($e){const Xe=$e[0],kt=$e.rule,Lt=new e(kt),hn=[kt.__beforeBegin,kt["on:begin"]];for(const On of hn)if(On&&(On($e,Lt),Lt.isMatchIgnored))return jt(Xe);return kt.skip?Yt+=Xe:(kt.excludeBegin&&(Yt+=Xe),An(),!kt.returnBegin&&!kt.excludeBegin&&(Yt=Xe)),De(kt,$e),kt.returnBegin?0:Xe.length}function Wn($e){const Xe=$e[0],kt=nt.substring($e.index),Lt=wt(Nt,$e,kt);if(!Lt)return We;const hn=Nt;Nt.endScope&&Nt.endScope._wrap?(An(),Y(Xe,Nt.endScope._wrap)):Nt.endScope&&Nt.endScope._multi?(An(),ye(Nt.endScope,$e)):hn.skip?Yt+=Xe:(hn.returnEnd||hn.excludeEnd||(Yt+=Xe),An(),hn.excludeEnd&&(Yt=Xe));do Nt.scope&&wn.closeNode(),!Nt.skip&&!Nt.subLanguage&&(Fi+=Nt.relevance),Nt=Nt.parent;while(Nt!==Lt.parent);return Lt.starts&&De(Lt.starts,$e),hn.returnEnd?0:Xe.length}function ps(){const $e=[];for(let Xe=Nt;Xe!==Dr;Xe=Xe.parent)Xe.scope&&$e.unshift(Xe.scope);$e.forEach(Xe=>wn.openNode(Xe))}let Kt={};function Rn($e,Xe){const kt=Xe&&Xe[0];if(Yt+=$e,kt==null)return An(),0;if(Kt.type==="begin"&&Xe.type==="end"&&Kt.index===Xe.index&&kt===""){if(Yt+=nt.slice(Xe.index,Xe.index+1),!ce){const Lt=new Error(`0 width match regex (${Ae})`);throw Lt.languageName=Ae,Lt.badRule=Kt.rule,Lt}return 1}if(Kt=Xe,Xe.type==="begin")return Zn(Xe);if(Xe.type==="illegal"&&!Ct){const Lt=new Error('Illegal lexeme "'+kt+'" for mode "'+(Nt.scope||"<unnamed>")+'"');throw Lt.mode=Nt,Lt}else if(Xe.type==="end"){const Lt=Wn(Xe);if(Lt!==We)return Lt}if(Xe.type==="illegal"&&kt==="")return Yt+=`
201
- `,1;if(zi>1e5&&zi>Xe.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Yt+=kt,kt.length}const Dr=cr(Ae);if(!Dr)throw te(me.replace("{}",Ae)),new Error('Unknown language: "'+Ae+'"');const ba=at(Dr);let $t="",Nt=Mt||ba;const xa={},wn=new he.__emitter(he);ps();let Yt="",Fi=0,ms=0,zi=0,Xs=!1;try{if(Dr.__emitTokens)Dr.__emitTokens(nt,wn);else{for(Nt.matcher.considerAll();;){zi++,Xs?Xs=!1:Nt.matcher.considerAll(),Nt.matcher.lastIndex=ms;const $e=Nt.matcher.exec(nt);if(!$e)break;const Xe=nt.substring(ms,$e.index),kt=Rn(Xe,$e);ms=$e.index+kt}Rn(nt.substring(ms))}return wn.finalize(),$t=wn.toHTML(),{language:Ae,value:$t,relevance:Fi,illegal:!1,_emitter:wn,_top:Nt}}catch($e){if($e.message&&$e.message.includes("Illegal"))return{language:Ae,value:Ce(nt),illegal:!0,relevance:0,_illegalBy:{message:$e.message,index:ms,context:nt.slice(ms-100,ms+100),mode:$e.mode,resultSoFar:$t},_emitter:wn};if(ce)return{language:Ae,value:Ce(nt),illegal:!1,relevance:0,errorRaised:$e,_emitter:wn,_top:Nt};throw $e}}function Tt(Ae){const nt={value:Ce(Ae),illegal:!1,relevance:0,_top:se,_emitter:new he.__emitter(he)};return nt._emitter.addText(Ae),nt}function cn(Ae,nt){nt=nt||he.languages||Object.keys(U);const Ct=Tt(Ae),Mt=nt.filter(cr).filter(Ir).map(An=>Ht(An,Ae,!1));Mt.unshift(Ct);const an=Mt.sort((An,Y)=>{if(An.relevance!==Y.relevance)return Y.relevance-An.relevance;if(An.language&&Y.language){if(cr(An.language).supersetOf===Y.language)return 1;if(cr(Y.language).supersetOf===An.language)return-1}return 0}),[nn,Nr]=an,Ts=nn;return Ts.secondBest=Nr,Ts}function xn(Ae,nt,Ct){const Mt=nt&&ie[nt]||Ct;Ae.classList.add("hljs"),Ae.classList.add(`language-${Mt}`)}function Nn(Ae){let nt=null;const Ct=Be(Ae);if(be(Ct))return;if(Qr("before:highlightElement",{el:Ae,language:Ct}),Ae.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ae);return}if(Ae.children.length>0&&(he.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(Ae)),he.throwUnescapedHTML))throw new bt("One of your code blocks includes unescaped HTML.",Ae.innerHTML);nt=Ae;const Mt=nt.textContent,an=Ct?Ee(Mt,{language:Ct,ignoreIllegals:!0}):cn(Mt);Ae.innerHTML=an.value,Ae.dataset.highlighted="yes",xn(Ae,Ct,an.language),Ae.result={language:an.language,re:an.relevance,relevance:an.relevance},an.secondBest&&(Ae.secondBest={language:an.secondBest.language,relevance:an.secondBest.relevance}),Qr("after:highlightElement",{el:Ae,result:an,text:Mt})}function Ve(Ae){he=Se(he,Ae)}const Vt=()=>{mr(),Q("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Un(){mr(),Q("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let fn=!1;function mr(){function Ae(){mr()}if(document.readyState==="loading"){fn||window.addEventListener("DOMContentLoaded",Ae,!1),fn=!0;return}document.querySelectorAll(he.cssSelector).forEach(Nn)}function Xt(Ae,nt){let Ct=null;try{Ct=nt(j)}catch(Mt){if(te("Language definition for '{}' could not be registered.".replace("{}",Ae)),ce)te(Mt);else throw Mt;Ct=se}Ct.name||(Ct.name=Ae),U[Ae]=Ct,Ct.rawDefinition=nt.bind(null,j),Ct.aliases&&_s(Ct.aliases,{languageName:Ae})}function Hn(Ae){delete U[Ae];for(const nt of Object.keys(ie))ie[nt]===Ae&&delete ie[nt]}function lr(){return Object.keys(U)}function cr(Ae){return Ae=(Ae||"").toLowerCase(),U[Ae]||U[ie[Ae]]}function _s(Ae,{languageName:nt}){typeof Ae=="string"&&(Ae=[Ae]),Ae.forEach(Ct=>{ie[Ct.toLowerCase()]=nt})}function Ir(Ae){const nt=cr(Ae);return nt&&!nt.disableAutodetect}function Bt(Ae){Ae["before:highlightBlock"]&&!Ae["before:highlightElement"]&&(Ae["before:highlightElement"]=nt=>{Ae["before:highlightBlock"](Object.assign({block:nt.el},nt))}),Ae["after:highlightBlock"]&&!Ae["after:highlightElement"]&&(Ae["after:highlightElement"]=nt=>{Ae["after:highlightBlock"](Object.assign({block:nt.el},nt))})}function Lr(Ae){Bt(Ae),D.push(Ae)}function Ys(Ae){const nt=D.indexOf(Ae);nt!==-1&&D.splice(nt,1)}function Qr(Ae,nt){const Ct=Ae;D.forEach(function(Mt){Mt[Ct]&&Mt[Ct](nt)})}function hs(Ae){return Q("10.7.0","highlightBlock will be removed entirely in v12.0"),Q("10.7.0","Please use highlightElement now."),Nn(Ae)}Object.assign(j,{highlight:Ee,highlightAuto:cn,highlightAll:mr,highlightElement:Nn,highlightBlock:hs,configure:Ve,initHighlighting:Vt,initHighlightingOnLoad:Un,registerLanguage:Xt,unregisterLanguage:Hn,listLanguages:lr,getLanguage:cr,registerAliases:_s,autoDetection:Ir,inherit:Se,addPlugin:Lr,removePlugin:Ys}),j.debugMode=function(){ce=!1},j.safeMode=function(){ce=!0},j.versionString=lt,j.regex={concat:k,lookahead:g,either:S,optional:x,anyNumberOfTimes:v};for(const Ae in Fe)typeof Fe[Ae]=="object"&&t(Fe[Ae]);return Object.assign(j,Fe),j},xt=He({});return xt.newInstance=()=>He({}),Tp=xt,xt.HighlightJS=xt,xt.default=xt,Tp}var D6=L6();const Y_=Il(D6);function X_(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?X_(n.children,r):{text:n.value,classes:r}})}function Zw(t){return t.value||t.children||[]}function P6(t){return!!Y_.getLanguage(t)}function ek({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return Zu(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const d=i.node.attrs.language||r,f=n.listLanguages(),h=d&&(f.includes(d)||P6(d)||(o=n.registered)!=null&&o.call(n,d))?Zw(n.highlight(d,i.node.textContent)):Zw(n.highlightAuto(i.node.textContent));X_(h).forEach(m=>{const g=l+m.text.length;if(m.classes.length){const v=qt.inline(l,g,{class:m.classes.join(" ")});s.push(v)}l=g})}),It.create(t,s)}function B6(t){return typeof t=="function"}function $6({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>B6(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new Ut({key:new Jt("lowlight"),state:{init:(s,{doc:i})=>ek({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const d=o.selection.$head.parent.type.name,f=l.selection.$head.parent.type.name,h=Zu(o.doc,g=>g.type.name===t),m=Zu(l.doc,g=>g.type.name===t);return s.docChanged&&([d,f].includes(t)||m.length!==h.length||s.steps.some(g=>g.from!==void 0&&g.to!==void 0&&h.some(v=>v.pos>=g.from&&v.pos+v.node.nodeSize<=g.to)))?ek({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var F6=y6.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))||[],$6({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),z6=F6;function U6(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},v=e.optional(s)+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"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],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"],M={type:k,keyword:x,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},_={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[_,m,l,n,t.C_BLOCK_COMMENT_MODE,h,f],I={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:M,contains:R.concat([{begin:/\(/,end:/\)/,keywords:M,contains:R.concat(["self"]),relevance:0}]),relevance:0},$={className:"function",begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:M,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:M,relevance:0},{begin:v,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,l,{begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:M,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(I,$,_,R,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:M,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:M},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function H6(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=U6(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 W6(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const d={match:/\\"/},f={className:"string",begin:/'/,end:/'/},h={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},g=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],v=t.SHEBANG({binary:`(${g.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},k=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],w=["true","false"],S={match:/(\/[a-z._-]+)+/},N=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],T=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],M=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],_=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:k,literal:w,built_in:[...N,...T,"set","shopt",...M,..._]},contains:[v,t.SHEBANG(),x,m,i,o,S,l,d,f,h,n]}}function V6(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},v=e.optional(s)+t.IDENT_RE+"\\s*\\(",w={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},S=[m,l,n,t.C_BLOCK_COMMENT_MODE,h,f],N={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},T={begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:w,relevance:0},{begin:v,returnBegin:!0,contains:[t.inherit(g,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,l,{begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C",aliases:["h"],keywords:w,disableAutodetect:!0,illegal:"</",contains:[].concat(N,T,S,[m,{begin:t.IDENT_RE+"::",keywords:w},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:m,strings:f,keywords:w}}}function q6(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",l={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},g={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},v=e.optional(s)+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"],k=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],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"],M={type:k,keyword:x,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},_={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},R=[_,m,l,n,t.C_BLOCK_COMMENT_MODE,h,f],I={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:M,contains:R.concat([{begin:/\(/,end:/\)/,keywords:M,contains:R.concat(["self"]),relevance:0}]),relevance:0},$={className:"function",begin:"("+o+"[\\*&\\s]+)+"+v,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:M,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:M,relevance:0},{begin:v,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,l,{begin:/\(/,end:/\)/,keywords:M,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,h,l]}]},l,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:M,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(I,$,_,R,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:M,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:M},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function K6(t){const e=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],s=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],i=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],o={keyword:s.concat(i),built_in:e,literal:r},l=t.inherit(t.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),d={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},h={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},m=t.inherit(h,{illegal:/\n/}),g={className:"subst",begin:/\{/,end:/\}/,keywords:o},v=t.inherit(g,{illegal:/\n/}),x={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,v]},k={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},w=t.inherit(k,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},v]});g.contains=[k,x,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.C_BLOCK_COMMENT_MODE],v.contains=[w,x,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const S={variants:[f,k,x,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},N={begin:"<",end:">",contains:[{beginKeywords:"in out"},l]},T=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",M={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},S,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},l,N,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[l,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[l,N,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+T+"\\s+)+"+t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,N],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[S,d,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},M]}}const G6=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_-]*/}}),J6=["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"],Y6=["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"],X6=[...J6,...Y6],Q6=["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(),Z6=["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(),eB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),tB=["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 nB(t){const e=t.regex,n=G6(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+Z6.join("|")+")"},{begin:":(:)?("+eB.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+tB.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:Q6.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+X6.join("|")+")\\b"}]}}function rB(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 sB(t){const i={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:i,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,illegal:/["']/}]}]}}function iB(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 oB(t){const e=t.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:t.NUMBER_RE}]},r=t.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},l={begin:/\[/,end:/\]/,contains:[r,i,s,o,n,"self"],relevance:0},d=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,h=/'[^']*'/,m=e.either(d,f,h),g=e.concat(m,"(\\s*\\.\\s*",m,")*",e.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:g,className:"attr",starts:{end:/$/,contains:[r,l,i,s,o,n]}}]}}var ta="[0-9](_*[0-9])*",pu=`\\.(${ta})`,mu="[0-9a-fA-F](_*[0-9a-fA-F])*",tk={className:"number",variants:[{begin:`(\\b(${ta})((${pu})|\\.)?|(${pu}))[eE][+-]?(${ta})[fFdD]?\\b`},{begin:`\\b(${ta})((${pu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${pu})[fFdD]?\\b`},{begin:`\\b(${ta})[fFdD]\\b`},{begin:`\\b0[xX]((${mu})\\.?|(${mu})?\\.(${mu}))[pP][+-]?(${ta})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${mu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Q_(t,e,n){return n===-1?"":t.replace(e,r=>Q_(t,e,n-1))}function aB(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+Q_("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),d={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},h={className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:d,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[h,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:d,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[f,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,tk,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},tk,f]}}const nk="[A-Za-z$_][0-9A-Za-z$_]*",lB=["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"],cB=["true","false","null","undefined","NaN","Infinity"],Z_=["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"],eT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],tT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],uB=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],dB=[].concat(tT,Z_,eT);function fB(t){const e=t.regex,n=(V,{after:oe})=>{const J="</"+V[0].slice(1);return V.input.indexOf(J,oe)!==-1},r=nk,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,oe)=>{const J=V[0].length+V.index,A=V.input[J];if(A==="<"||A===","){oe.ignoreMatch();return}A===">"&&(n(V,{after:J})||oe.ignoreMatch());let L;const ee=V.input.substring(J);if(L=ee.match(/^\s*=/)){oe.ignoreMatch();return}if((L=ee.match(/^\s+extends\s+/))&&L.index===0){oe.ignoreMatch();return}}},l={$pattern:nk,keyword:lB,literal:cB,built_in:dB,"variable.language":uB},d="[0-9](_?[0-9])*",f=`\\.(${d})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},T=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(T)});const M=[].concat(N,g.contains),_=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(M)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:_},I={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"}}]},$={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:{_:[...Z_,...eT]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(V){return e.concat("(?!",V.join("|"),")")}const G={match:e.concat(/\b/,F([...tT,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},B={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},W={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},K="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(K)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:$},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,N,{match:/\$\d+/},m,$,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,t.REGEXP_MODE,{className:"function",begin:K,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:_}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},B,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},G,q,I,W,{match:/\$[(.]/}]}}function hB(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var na="[0-9](_*[0-9])*",gu=`\\.(${na})`,vu="[0-9a-fA-F](_*[0-9a-fA-F])*",pB={className:"number",variants:[{begin:`(\\b(${na})((${gu})|\\.)?|(${gu}))[eE][+-]?(${na})[fFdD]?\\b`},{begin:`\\b(${na})((${gu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${gu})[fFdD]?\\b`},{begin:`\\b(${na})[fFdD]\\b`},{begin:`\\b0[xX]((${vu})\\.?|(${vu})?\\.(${vu}))[pP][+-]?(${na})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${vu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function mB(t){const e={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"@"},s={className:"subst",begin:/\$\{/,end:/\}/,contains:[t.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+t.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,s]},{begin:"'",end:"'",illegal:/\n/,contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[t.BACKSLASH_ESCAPE,i,s]}]};s.contains.push(o);const l={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+t.UNDERSCORE_IDENT_RE+")?"},d={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(o,{className:"string"}),"self"]}]},f=pB,h=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),m={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},g=m;return g.variants[1].contains=[m],m.variants[1].contains=[g],{name:"Kotlin",aliases:["kt","kts"],keywords:e,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),t.C_LINE_COMMENT_MODE,h,n,r,l,d,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[m,t.C_LINE_COMMENT_MODE,h],relevance:0},t.C_LINE_COMMENT_MODE,h,l,d,o,t.C_NUMBER_MODE]},h]},{begin:[/class|interface|trait/,/\s+/,t.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},t.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},l,d]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
202
- `},f]}}const gB=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_-]*/}}),vB=["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"],yB=["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"],bB=[...vB,...yB],xB=["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(),nT=["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(),rT=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),wB=["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(),kB=nT.concat(rT).sort().reverse();function SB(t){const e=gB(t),n=kB,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",o=[],l=[],d=function(T){return{className:"string",begin:"~?"+T+".*?"+T}},f=function(T,M,_){return{className:T,begin:M,relevance:_}},h={$pattern:/[a-z-]+/,keyword:r,attribute:xB.join(" ")},m={begin:"\\(",end:"\\)",contains:l,keywords:h,relevance:0};l.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,d("'"),d('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},e.HEXCOLOR,m,f("variable","@@?"+s,10),f("variable","@\\{"+s+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:s+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},e.IMPORTANT,{beginKeywords:"and not"},e.FUNCTION_DISPATCH);const g=l.concat({begin:/\{/,end:/\}/,contains:o}),v={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(l)},x={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+wB.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:l}}]},k={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:l,relevance:0}},w={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:g}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,v,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+bB.join("|")+")\\b",className:"selector-tag"},e.CSS_NUMBER_MODE,f("selector-tag",i,0),f("selector-id","#"+i),f("selector-class","\\."+i,0),f("selector-tag","&",0),e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+nT.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+rT.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:g},{begin:"!important"},e.FUNCTION_DISPATCH]},N={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return o.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,k,w,N,x,S,v,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function EB(t){const e="\\[=*\\[",n="\\]=*\\]",r={begin:e,end:n,contains:["self"]},s=[t.COMMENT("--(?!"+e+")","$"),t.COMMENT("--"+e,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:t.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:s.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[t.inherit(t.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:s}].concat(s)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:e,end:n,contains:[r],relevance:5}])}}function NB(t){const e={className:"variable",variants:[{begin:"\\$\\("+t.UNDERSCORE_IDENT_RE+"\\)",contains:[t.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,e]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[e,n]},s={begin:"^"+t.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[e]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[t.HASH_COMMENT_MODE,e,n,r,s,i,o]}}function CB(t){const e=t.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},s={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},l=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,l,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=t.inherit(f,{contains:[]}),g=t.inherit(h,{contains:[]});f.contains.push(g),h.contains.push(m);let v=[n,d];return[f,h,m,g].forEach(S=>{S.contains=S.contains.concat(v)}),v=v.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:v},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:v}]}]},n,i,f,h,{className:"quote",begin:"^>\\s+",contains:v,end:"$"},s,r,d,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function _B(t){const e={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,l={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},d={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:l,illegal:"</",contains:[e,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.C_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+d.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:d,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function TB(t){const e=t.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,keyword:n.join(" ")},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},o={begin:/->\{/,end:/\}/},l={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},d={scope:"variable",variants:[{begin:/\$\d/},{begin:e.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[l]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},h=[t.BACKSLASH_ESCAPE,i,d],m=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],g=(k,w,S="\\1")=>{const N=S==="\\1"?S:e.concat(S,w);return e.concat(e.concat("(?:",k,")"),w,/(?:\\.|[^\\\/])*?/,N,/(?:\\.|[^\\\/])*?/,S,r)},v=(k,w,S)=>e.concat(e.concat("(?:",k,")"),w,/(?:\\.|[^\\\/])*?/,S,r),x=[d,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:h,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:g("s|tr|y",e.either(...m,{capture:!0}))},{begin:g("s|tr|y","\\(","\\)")},{begin:g("s|tr|y","\\[","\\]")},{begin:g("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:v("(?:m|qr)?",/\//,/\//)},{begin:v("m|qr",e.either(...m,{capture:!0}),/\1/)},{begin:v("m|qr",/\(/,/\)/)},{begin:v("m|qr",/\[/,/\]/)},{begin:v("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,l]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,l,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=x,o.contains=x,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:x}}function jB(t){const e=t.regex,n=/(?![A-Za-z0-9])(?![$])/,r=e.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=e.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),i=e.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+r},l={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},d={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=t.inherit(t.APOS_STRING_MODE,{illegal:null}),h=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(d)}),m={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(d),"on:begin":(B,W)=>{W.data._beginMatch=B[1]||B[2]},"on:end":(B,W)=>{W.data._beginMatch!==B[1]&&W.ignoreMatch()}},g=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),v=`[
203
- ]`,x={scope:"string",variants:[h,f,m,g]},k={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},w=["false","null","true"],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"],N=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],M={keyword:S,literal:(B=>{const W=[];return B.forEach(K=>{W.push(K),K.toLowerCase()===K?W.push(K.toUpperCase()):W.push(K.toLowerCase())}),W})(w),built_in:N},_=B=>B.map(W=>W.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,e.concat(v,"+"),e.concat("(?!",_(N).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},I=e.concat(r,"\\b(?!\\()"),$={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),I],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),I],scope:{1:"title.class",3:"variable.constant"}},{match:[s,e.concat("::",e.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},P={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:M,contains:[P,o,$,t.C_BLOCK_COMMENT_MODE,x,k,R]},q={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",_(S).join("\\b|"),"|",_(N).join("\\b|"),"\\b)"),r,e.concat(v,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(q);const F=[P,$,t.C_BLOCK_COMMENT_MODE,x,k,R],G={begin:e.concat(/#\[\s*\\?/,e.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:w,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:w,keyword:["new","array"]},contains:["self",...F]},...F,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:M,contains:[G,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},l,{scope:"variable.language",match:/\$this\b/},o,q,$,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},R,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:M,contains:["self",G,o,$,t.C_BLOCK_COMMENT_MODE,x,k]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},x,k]}}function MB(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 AB(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function RB(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},h={begin:/\{\{/,relevance:0},m={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d,h,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,h,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},g="[0-9](_?[0-9])*",v=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,x=`\\b|${r.join("|")}`,k={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${v}))[eE][+-]?(${g})[jJ]?(?=${x})`},{begin:`(${v})[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(${g})[jJ](?=${x})`}]},w={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,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:l,contains:["self",d,k,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,k,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[d,k,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,w,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[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:[k,S,m]}]}}function OB(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function IB(t){const e=t.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=e.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=e.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[t.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:e.lookahead(e.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),t.HASH_COMMENT_MODE,{scope:"string",contains:[t.BACKSLASH_ESCAPE],variants:[t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function LB(t){const e=t.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=e.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=e.concat(r,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},l={className:"doctag",begin:"@[A-Za-z]+"},d={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[l]}),t.COMMENT("^=begin","^=end",{contains:[l],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:o},m={className:"string",contains:[t.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:e.concat(/<<[-~]?'?/,e.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,h]})]}]},g="[1-9](_?[0-9])*|0",v="[0-9](_?[0-9])*",x={className:"number",relevance:0,variants:[{begin:`\\b(${g})(\\.(${v}))?([eE][+-]?(${v})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},k={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},R=[m,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:o},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[k]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},x,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(d,f),relevance:0}].concat(d,f);h.contains=R,k.contains=R;const z=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:R}}];return f.unshift(d),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(z).concat(f).concat(R)}}function DB(t){const e=t.regex,n=/(r#)?/,r=e.concat(n,t.UNDERSCORE_IDENT_RE),s=e.concat(n,t.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,e.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",l=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],d=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:h,keyword:l,literal:d,built_in:f},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:h}},{className:"punctuation",begin:"->"},i]}}const PB=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_-]*/}}),BB=["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"],$B=["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"],FB=[...BB,...$B],zB=["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(),UB=["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(),HB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),WB=["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 VB(t){const e=PB(t),n=HB,r=UB,s="@[a-z-]+",i="and or not only",l={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,e.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+FB.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},l,{begin:/\(/,end:/\)/,contains:[e.CSS_NUMBER_MODE]},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+WB.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[e.BLOCK_COMMENT,l,e.HEXCOLOR,e.CSS_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.IMPORTANT,e.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:zB.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},l,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.HEXCOLOR,e.CSS_NUMBER_MODE]},e.FUNCTION_DISPATCH]}}function qB(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function KB(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],d=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],g=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],v=h,x=[...f,...d].filter(_=>!h.includes(_)),k={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:e.concat(/\b/,e.either(...v),/\s*\(/),relevance:0,keywords:{built_in:v}};function N(_){return e.concat(/\b/,e.either(..._.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const T={scope:"keyword",match:N(g),relevance:0};function M(_,{exceptions:R,when:I}={}){const $=I;return R=R||[],_.map(P=>P.match(/\|\d+$/)||R.includes(P)?P:$(P)?`${P}|0`:P)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:M(x,{when:_=>_.length<3}),literal:i,type:l,built_in:m},contains:[{scope:"type",match:N(o)},T,S,k,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,w]}}function sT(t){return t?typeof t=="string"?t:t.source:null}function el(t){return Qt("(?=",t,")")}function Qt(...t){return t.map(n=>sT(n)).join("")}function GB(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function fr(...t){return"("+(GB(t).capture?"":"?:")+t.map(r=>sT(r)).join("|")+")"}const ey=t=>Qt(/\b/,t,/\w$/.test(t)?/\b/:/\B/),JB=["Protocol","Type"].map(ey),rk=["init","self"].map(ey),YB=["Any","Self"],jp=["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"],sk=["false","nil","true"],XB=["assignment","associativity","higherThan","left","lowerThan","none","right"],QB=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],ik=["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"],iT=fr(/[/=\-+!*%<>&|^~?]/,/[\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]/),oT=fr(iT,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Mp=Qt(iT,oT,"*"),aT=fr(/[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]/),Ad=fr(aT,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),xs=Qt(aT,Ad,"*"),yu=Qt(/[A-Z]/,Ad,"*"),ZB=["attached","autoclosure",Qt(/convention\(/,fr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",Qt(/objc\(/,xs,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],e5=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function t5(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,fr(...JB,...rk)],className:{2:"keyword"}},i={match:Qt(/\./,fr(...jp)),relevance:0},o=jp.filter(ge=>typeof ge=="string").concat(["_|0"]),l=jp.filter(ge=>typeof ge!="string").concat(YB).map(ey),d={variants:[{className:"keyword",match:fr(...l,...rk)}]},f={$pattern:fr(/\b\w+/,/#\w+/),keyword:o.concat(QB),literal:sk},h=[s,i,d],m={match:Qt(/\./,fr(...ik)),relevance:0},g={className:"built_in",match:Qt(/\b/,fr(...ik),/(?=\()/)},v=[m,g],x={match:/->/,relevance:0},k={className:"operator",relevance:0,variants:[{match:Mp},{match:`\\.(\\.|${oT})+`}]},w=[x,k],S="([0-9]_*)+",N="([0-9a-fA-F]_*)+",T={className:"number",relevance:0,variants:[{match:`\\b(${S})(\\.(${S}))?([eE][+-]?(${S}))?\\b`},{match:`\\b0x(${N})(\\.(${N}))?([pP][+-]?(${S}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},M=(ge="")=>({className:"subst",variants:[{match:Qt(/\\/,ge,/[0\\tnr"']/)},{match:Qt(/\\/,ge,/u\{[0-9a-fA-F]{1,8}\}/)}]}),_=(ge="")=>({className:"subst",match:Qt(/\\/,ge,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(ge="")=>({className:"subst",label:"interpol",begin:Qt(/\\/,ge,/\(/),end:/\)/}),I=(ge="")=>({begin:Qt(ge,/"""/),end:Qt(/"""/,ge),contains:[M(ge),_(ge),R(ge)]}),$=(ge="")=>({begin:Qt(ge,/"/),end:Qt(/"/,ge),contains:[M(ge),R(ge)]}),P={className:"string",variants:[I(),I("#"),I("##"),I("###"),$(),$("#"),$("##"),$("###")]},z=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],q={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:z},F=ge=>{const vt=Qt(ge,/\//),_t=Qt(/\//,ge);return{begin:vt,end:_t,contains:[...z,{scope:"comment",begin:`#(?!.*${_t})`,end:/$/}]}},G={scope:"regexp",variants:[F("###"),F("##"),F("#"),q]},B={match:Qt(/`/,xs,/`/)},W={className:"variable",match:/\$\d+/},K={className:"variable",match:`\\$${Ad}+`},ne=[B,W,K],V={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:e5,contains:[...w,T,P]}]}},oe={scope:"keyword",match:Qt(/@/,fr(...ZB),el(fr(/\(/,/\s+/)))},J={scope:"meta",match:Qt(/@/,xs)},A=[V,oe,J],L={match:el(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:Qt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Ad,"+")},{className:"type",match:yu,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:Qt(/\s+&\s+/,el(yu)),relevance:0}]},ee={begin:/</,end:/>/,keywords:f,contains:[...r,...h,...A,x,L]};L.contains.push(ee);const pe={match:Qt(xs,/\s*:/),keywords:"_|0",relevance:0},xe={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",pe,...r,G,...h,...v,...w,T,P,...ne,...A,L]},re={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,L]},Ne={begin:fr(el(Qt(xs,/\s*:/)),el(Qt(xs,/\s+/,xs,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:xs}]},ke={begin:/\(/,end:/\)/,keywords:f,contains:[Ne,...r,...h,...w,T,P,...A,L,xe],endsParent:!0,illegal:/["']/},ze={match:[/(func|macro)/,/\s+/,fr(B.match,xs,Mp)],className:{1:"keyword",3:"title.function"},contains:[re,ke,e],illegal:[/\[/,/%/]},Fe={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[re,ke,e],illegal:/\[|%/},Ge={match:[/operator/,/\s+/,Mp],className:{1:"keyword",3:"title"}},Re={begin:[/precedencegroup/,/\s+/,yu],className:{1:"keyword",3:"title"},contains:[L],keywords:[...XB,...sk],end:/}/},Ze={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},gt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},ht={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,xs,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[re,...h,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:yu},...h],relevance:0}]};for(const ge of P.variants){const vt=ge.contains.find(Et=>Et.label==="interpol");vt.keywords=f;const _t=[...h,...v,...w,T,P,...ne];vt.contains=[..._t,{begin:/\(/,end:/\)/,contains:["self",..._t]}]}return{name:"Swift",keywords:f,contains:[...r,ze,Fe,Ze,gt,ht,Ge,Re,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},G,...h,...v,...w,T,P,...ne,...A,L,xe]}}const Rd="[A-Za-z$_][0-9A-Za-z$_]*",lT=["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"],cT=["true","false","null","undefined","NaN","Infinity"],uT=["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"],dT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],fT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],hT=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],pT=[].concat(fT,uT,dT);function n5(t){const e=t.regex,n=(V,{after:oe})=>{const J="</"+V[0].slice(1);return V.input.indexOf(J,oe)!==-1},r=Rd,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,oe)=>{const J=V[0].length+V.index,A=V.input[J];if(A==="<"||A===","){oe.ignoreMatch();return}A===">"&&(n(V,{after:J})||oe.ignoreMatch());let L;const ee=V.input.substring(J);if(L=ee.match(/^\s*=/)){oe.ignoreMatch();return}if((L=ee.match(/^\s+extends\s+/))&&L.index===0){oe.ignoreMatch();return}}},l={$pattern:Rd,keyword:lT,literal:cT,built_in:pT,"variable.language":hT},d="[0-9](_?[0-9])*",f=`\\.(${d})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},g={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},v={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},N={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},T=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,{match:/\$\d+/},m];g.contains=T.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(T)});const M=[].concat(N,g.contains),_=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(M)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:_},I={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"}}]},$={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:{_:[...uT,...dT]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(V){return e.concat("(?!",V.join("|"),")")}const G={match:e.concat(/\b/,F([...fT,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},B={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},W={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},K="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(K)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:$},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,v,x,k,w,N,{match:/\$\d+/},m,$,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[N,t.REGEXP_MODE,{className:"function",begin:K,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:_}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},B,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},G,q,I,W,{match:/\$[(.]/}]}}function r5(t){const e=t.regex,n=n5(t),r=Rd,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},d=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:Rd,keyword:lT.concat(d),literal:cT,built_in:pT.concat(s),"variable.language":hT},h={className:"meta",begin:"@"+r},m=(k,w,S)=>{const N=k.contains.findIndex(T=>T.label===w);if(N===-1)throw new Error("can not find mode to replace");k.contains.splice(N,1,S)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(k=>k.scope==="attr"),v=Object.assign({},g,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,v]),n.contains=n.contains.concat([h,i,o,v]),m(n,"shebang",t.SHEBANG()),m(n,"use_strict",l);const x=n.contains.find(k=>k.label==="func.def");return x.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function s5(t){const e=t.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,l=/\d{1,2}(:\d{1,2}){1,2}/,d={className:"literal",variants:[{begin:e.concat(/# */,e.either(i,s),/ *#/)},{begin:e.concat(/# */,l,/ *#/)},{begin:e.concat(/# */,o,/ *#/)},{begin:e.concat(/# */,e.either(i,s),/ +/,e.either(o,l),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},m=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),g=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,d,f,h,m,g,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[g]}]}}function i5(t){t.regex;const e=t.COMMENT(/\(;/,/;\)/);e.contains.push("self");const n=t.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},l={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},d={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,e,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,o,s,t.QUOTE_STRING_MODE,d,f,l]}}function o5(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),d=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,d,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,d,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function a5(t){const e="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,s]},l=t.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},v={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},x={begin:/\{/,end:/\}/,contains:[v],illegal:"\\n",relevance:0},k={begin:"\\[",end:"\\]",contains:[v],illegal:"\\n",relevance:0},w=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},g,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},x,k,i,o],S=[...w];return S.pop(),S.push(l),v.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}const l5={arduino:H6,bash:W6,c:V6,cpp:q6,csharp:K6,css:nB,diff:rB,go:sB,graphql:iB,ini:oB,java:aB,javascript:fB,json:hB,kotlin:mB,less:SB,lua:EB,makefile:NB,markdown:CB,objectivec:_B,perl:TB,php:jB,"php-template":MB,plaintext:AB,python:RB,"python-repl":OB,r:IB,ruby:LB,rust:DB,scss:VB,shell:qB,sql:KB,swift:t5,typescript:r5,vbnet:s5,wasm:i5,xml:o5,yaml:a5},ok={},c5="hljs-";function u5(t){const e=Y_.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(d,f,h){const m=h||ok,g=typeof m.prefix=="string"?m.prefix:c5;if(!e.getLanguage(d))throw new Error("Unknown language: `"+d+"` is not registered");e.configure({__emitter:d5,classPrefix:g});const v=e.highlight(f,{ignoreIllegals:!0,language:d});if(v.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:v.errorRaised});const x=v._emitter.root,k=x.data;return k.language=v.language,k.relevance=v.relevance,x}function r(d,f){const m=(f||ok).subset||s();let g=-1,v=0,x;for(;++g<m.length;){const k=m[g];if(!e.getLanguage(k))continue;const w=n(k,d,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>v&&(v=w.data.relevance,x=w)}return x||{type:"root",children:[],data:{language:void 0,relevance:v}}}function s(){return e.listLanguages()}function i(d,f){if(typeof d=="string")e.registerLanguage(d,f);else{let h;for(h in d)Object.hasOwn(d,h)&&e.registerLanguage(h,d[h])}}function o(d,f){if(typeof d=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:d});else{let h;for(h in d)if(Object.hasOwn(d,h)){const m=d[h];e.registerAliases(typeof m=="string"?m:[...m],{languageName:h})}}}function l(d){return!!e.getLanguage(d)}}class d5{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const f5=new Jt("blurredLoadingNode"),ty=Pt.create({name:"blurredLoadingNode",addStorage(){return{loadingNodes:{}}},addCommands(){return{applyLoadingEffect:(t,e,n,r="paragraph")=>({editor:s})=>{const i={...this.storage.loadingNodes};return i[t]={from:e,to:n,id:t,active:!0,type:r},this.storage.loadingNodes=i,s.view.dispatch(s.view.state.tr),setTimeout(()=>{s.isFocused&&s.commands.setTextSelection({from:e,to:e})},0),!0},removeLoadingEffect:t=>({editor:e})=>{const n={...this.storage.loadingNodes};return n[t]&&(delete n[t],this.storage.loadingNodes=n,e.view.dispatch(e.view.state.tr),e.isFocused||setTimeout(()=>{e.commands.focus()},0)),!0}}},addProseMirrorPlugins(){return[new Ut({key:f5,props:{decorations:t=>{const e=this.storage.loadingNodes,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;if(!s.active)return;const{from:i,to:o,type:l}=s;l==="selection"?n.push(qt.inline(i,o,{class:"node-blur-selection"})):t.doc.nodesBetween(i,o,(d,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(d.type.name)?(n.push(qt.node(f,f+d.nodeSize,{class:"node-blur-effect"})),!1):!0)}),It.create(t.doc,n)}}})]}}),ny=bn.create({name:"imageLoading",group:"block",atom:!0,addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:'div[data-type="image-loading"]'}]},renderHTML(){return["div",{"data-type":"image-loading",class:"image-loading-placeholder",contenteditable:"false"}]}}),h5=new Jt("insertionLoadingNode"),bu=new Map,ry=Pt.create({name:"insertionLoadingNode",addStorage(){return{insertionPoints:{}}},addCommands(){return{showInsertionLoading:(t,e)=>({editor:n})=>(this.storage.insertionPoints={},bu.clear(),this.storage.insertionPoints={[t]:{position:e,id:t,active:!0}},n.view.dom.classList.add("has-insertion-loading"),n.view.dispatch(n.view.state.tr),!0),removeInsertionLoading:t=>({editor:e})=>{const n={...this.storage.insertionPoints};return n[t]&&(delete n[t],this.storage.insertionPoints=n,bu.delete(t),Object.keys(n).length===0&&e.view.dom.classList.remove("has-insertion-loading"),e.view.dispatch(e.view.state.tr)),!0}}},addProseMirrorPlugins(){return[new Ut({key:h5,props:{decorations:t=>{const e=this.storage.insertionPoints,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;s.active&&n.push(qt.widget(s.position,()=>{const i=bu.get(s.id);if(i)return i;const o=document.createElement("span");o.className="inline-insertion-indicator";const l=document.createElement("span");l.className="inline-insertion-spinner";const d=document.createElement("div");d.className="bounce1";const f=document.createElement("div");f.className="bounce2";const h=document.createElement("div");return l.appendChild(d),l.appendChild(f),l.appendChild(h),o.appendChild(l),bu.set(s.id,o),o},{id:`insertion-${s.id}`}))}),It.create(t.doc,n)}}})]}}),p5=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],sy=Pt.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:p5,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},pendingOrphan:{default:null,rendered:!1},pendingStaleBaseline:{default:null,rendered:!1}}}]}}),m5=bn.create({name:"footnoteReference",group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{label:{default:"",parseHTML:t=>t.getAttribute("data-label")||"",renderHTML:t=>({"data-label":t.label})}}},parseHTML(){return[{tag:"sup.footnote-ref",getAttrs:t=>{const e=t.getAttribute("data-label");return e?{label:e}:!1}}]},renderHTML({HTMLAttributes:t}){return["sup",zt({class:"footnote-ref"},t)]},addKeyboardShortcuts(){return{"Mod-Shift-f":()=>(mT(this.editor),!0)}}}),g5=bn.create({name:"footnoteSection",group:"block",content:"footnoteDefinition+",defining:!0,isolating:!0,addAttributes(){return{id:{default:null}}},parseHTML(){return[{tag:"section.footnotes"}]},renderHTML({HTMLAttributes:t}){return["section",zt({class:"footnotes"},t),0]}}),v5=bn.create({name:"footnoteDefinition",group:"block",content:"paragraph+",defining:!0,isolating:!0,addAttributes(){return{id:{default:null},label:{default:"",parseHTML:t=>t.getAttribute("data-label")||"",renderHTML:t=>({"data-label":t.label})}}},parseHTML(){return[{tag:"div.footnote-def",getAttrs:t=>{const e=t.getAttribute("data-label");return e?{label:e}:!1}}]},renderHTML({HTMLAttributes:t}){return["div",zt({class:"footnote-def"},t),0]}});function mT(t){const{state:e}=t,{schema:n,doc:r}=e,s=n.nodes.footnoteReference,i=n.nodes.footnoteSection,o=n.nodes.footnoteDefinition,l=n.nodes.paragraph;if(!s||!i||!o||!l)return;const d=new Set;r.descendants(T=>{(T.type.name==="footnoteReference"||T.type.name==="footnoteDefinition")&&T.attrs.label&&d.add(String(T.attrs.label))});let f=1;for(;d.has(String(f));)f++;const h=String(f);let m=-1,g=null;r.forEach((T,M)=>{T.type.name==="footnoteSection"&&(m=M,g=T)});const v=o.create({label:h},l.create()),x=s.create({label:h}),k=e.selection.to,w=e.tr;w.insert(k,x);let S;if(m>=0&&g){const T=x.nodeSize,_=(k<=m?m+T+g.nodeSize:m+g.nodeSize)-1;w.insert(_,v),S=_+2}else{const T=i.create(null,v),M=w.doc.content.size;w.insert(M,T),S=M+3}const N=Math.min(S,w.doc.content.size);w.setSelection(ft.near(w.doc.resolve(N))),w.scrollIntoView(),t.view.dispatch(w),t.view.focus()}function y5({node:t,deleteNode:e}){return c.jsxs(WD,{as:"div",className:"tweet-image-card",draggable:!0,"data-drag-handle":!0,children:[c.jsx("img",{className:"tweet-image-card-img",src:t.attrs.src,alt:t.attrs.alt||"",draggable:!1}),c.jsx("button",{className:"tweet-image-card-remove",onClick:e,title:"Remove image",contentEditable:!1,children:"×"})]})}const b5=$v.extend({addNodeView(){return YD(y5)}}),x5=u5(l5),iy=TP.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),target:{default:null}}},renderHTML({HTMLAttributes:t}){var r;const{target:e,...n}=t;if((r=n.href)!=null&&r.startsWith("doc:")){const{href:s,...i}=n;return["span",{...i,"data-doc":s.slice(4),class:"doc-link"},0]}return["a",zt(this.options.HTMLAttributes,n),0]}}),w5=[Zv.configure({codeBlock:!1,link:!1,underline:!1}),z6.configure({lowlight:x5}),iy.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),K_,Q3,tP,e4,n4,x3,b3.configure({nested:!0}),$v,X3,O_.configure({resizable:!1}),R_,A_,M_,ty,ny,ry,sy,m5,g5,v5,ef.configure({placeholder:"Start writing..."}),Qv.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image","imageLoading","footnoteSection","footnoteDefinition"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],k5=[Zv.configure({codeBlock:!1,horizontalRule:!0,heading:{levels:[1,2,3]},link:!1,underline:!1}),iy.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),$v,ty,ny,ry,sy,ef.configure({placeholder:"Start writing..."}),Qv.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image","imageLoading","horizontalRule"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],S5=Pt.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>{const{state:t}=this.editor,{$from:e}=t.selection,n=e.pos,r=n>0?t.doc.resolve(n).nodeBefore:null;if((r==null?void 0:r.type.name)==="hardBreak"){const{tr:s}=t;return s.delete(n-r.nodeSize,n),s.split(s.mapping.map(n)),this.editor.view.dispatch(s),!0}return this.editor.commands.setHardBreak()}}}}),gT=[Zv.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),iy.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),b5,ty,ny,ry,sy,S5,Qv.configure({types:["paragraph","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...gT,ef.configure({placeholder:"What is happening?!"})];function Wr({onClick:t,active:e,disabled:n,title:r,children:s}){return c.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function ak(){return c.jsx("div",{className:"floating-toolbar__divider"})}function E5({editor:t}){const[e,n]=b.useState(!1),[r,s]=b.useState({top:0,left:0}),[,i]=b.useState(0),o=b.useRef(-1),l=b.useRef(-1),d=b.useRef(!1);return b.useEffect(()=>{const f=t.view.dom,h=()=>{d.current=!0},m=()=>{if(!d.current)return;d.current=!1;const{from:g,to:v}=t.state.selection,x=g!==v&&t.state.selection.node;if(g!==v&&!x){const k=t.isActive("codeBlock"),w=!!document.querySelector(".context-menu");if(!k&&!w){o.current=g,l.current=v;const S=t.view.coordsAtPos(g),N=t.view.coordsAtPos(v,1),T=(S.left+N.right)/2;s({top:S.top,left:T}),n(!0)}}};return f.addEventListener("mousedown",h),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",h),document.removeEventListener("mouseup",m)}},[t]),b.useEffect(()=>{const f=()=>{d.current=!1,n(!1),o.current=-1,l.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),b.useEffect(()=>{const f=()=>{const{from:h,to:m}=t.state.selection,g=h===m,v=t.isActive("codeBlock"),x=!!document.querySelector(".context-menu"),k=t.view.hasFocus(),w=!g&&t.state.selection.node;if(g||w||v||x||!k)n(!1),o.current=-1,l.current=-1;else if(!d.current&&(n(!0),h!==o.current||m!==l.current)){o.current=h,l.current=m;const S=t.view.coordsAtPos(h),N=t.view.coordsAtPos(m,1),T=(S.left+N.right)/2;s({top:S.top,left:T})}i(S=>S+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?c.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[c.jsx(Wr,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.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"})})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),c.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),c.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),c.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),c.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),c.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),c.jsx(Wr,{onClick:()=>{const f=t.getAttributes("link").href||"",h=window.prompt("Link URL:",f);h!==null&&(h===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:h}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),c.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),c.jsx(ak,{}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 12h8"}),c.jsx("path",{d:"M4 18V6"}),c.jsx("path",{d:"M12 18V6"}),c.jsx("path",{d:"m17 12 3-2v8"})]})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 12h8"}),c.jsx("path",{d:"M4 18V6"}),c.jsx("path",{d:"M12 18V6"}),c.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 12h8"}),c.jsx("path",{d:"M4 18V6"}),c.jsx("path",{d:"M12 18V6"}),c.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),c.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),c.jsx(ak,{}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M3 12h.01"}),c.jsx("path",{d:"M3 18h.01"}),c.jsx("path",{d:"M3 6h.01"}),c.jsx("path",{d:"M8 12h13"}),c.jsx("path",{d:"M8 18h13"}),c.jsx("path",{d:"M8 6h13"})]})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M11 12h9"}),c.jsx("path",{d:"M11 18h9"}),c.jsx("path",{d:"M11 6h9"}),c.jsx("path",{d:"M4 10V4h1"}),c.jsx("path",{d:"M4 10h2"}),c.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),c.jsx(Wr,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 6H3"}),c.jsx("path",{d:"M21 12H8"}),c.jsx("path",{d:"M21 18H8"}),c.jsx("path",{d:"M3 12v6"})]})}),c.jsx(Wr,{onClick:()=>mT(t),title:"Footnote (Ctrl+Shift+F)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 6h12"}),c.jsx("path",{d:"M4 12h12"}),c.jsx("path",{d:"M4 18h8"}),c.jsx("text",{x:"18",y:"9",fontSize:"9",fontWeight:"bold",stroke:"none",fill:"currentColor",children:"N"})]})})]}):null}const N5=new Jt("pendingDecoration");let vT=null,yT=null;function lk(t,e){vT=t,yT=e??null}let Od=!1,bT=null,oy=null,xT=null;function ay(){return Od}function C5(){return oy}function _5(){return xT}function ll(t,e,n,r){Od=t,bT=t?e??null:null,oy=t?r??null:null,xT=t?n??null:null}function T5(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function ck(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const o=t.child(i);if(o.isText){if(r+o.text.length>=n)return s+(n-r);r+=o.text.length,s+=o.nodeSize}else{const l=o.type.name==="hardBreak"?1:o.type.spec.leafText?o.type.spec.leafText(o).length:0;if(l>0&&r+l>=n)return s;r+=l,s+=o.nodeSize}}return n===r?s:null}function uk(t){const e=[];return t.descendants((n,r)=>{var w,S,N,T,M,_,R,I,$;const s=(w=n.attrs)==null?void 0:w.pendingStatus;if(!s)return!0;const i=(S=n.attrs)==null?void 0:S.id,o=(N=n.attrs)==null?void 0:N.pendingGroupId,l=o&&o===yT,f=Od&&i===bT||o&&Od&&o===oy,h=f?(T=n.attrs)==null?void 0:T.pendingOriginalFrom:(M=n.attrs)==null?void 0:M.pendingSelectionFrom,m=f?(_=n.attrs)==null?void 0:_.pendingOriginalTo:(R=n.attrs)==null?void 0:R.pendingSelectionTo,g=h!=null&&m!=null,v=f?"pending-original":T5(s),x=[];(I=n.attrs)!=null&&I.pendingOrphan&&x.push("pending-orphan"),($=n.attrs)!=null&&$.pendingStaleBaseline&&x.push("pending-stale");const k=v+(x.length?" "+x.join(" "):"");if(g&&n.isTextblock&&k){const P=ck(n,r,h),z=ck(n,r,m);P!==null&&z!==null&&P<z&&e.push(qt.inline(P,z,{class:k}))}else k&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(qt.inline(r+1,r+n.nodeSize-1,{class:k})):e.push(qt.node(r,r+n.nodeSize,{class:k})));if(i&&(i===vT||l)){const P=f?"original":s;e.push(qt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${P}`}))}return!0}),It.create(t,e)}function wT(){return new Ut({key:N5,state:{init(t,e){return uk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?uk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function ly(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const j5=new Jt("commentDecoration");let sa=[];function dk(t){sa=t}function $u(){return sa}function kT(t){return{class:"ow-comment","data-comment-id":t.id}}function fk(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=ia(e,n,s),o=ia(e,n,s+t.text.length);return i===null||o===null||i>=o?null:qt.inline(i,o,kT(t))}function M5(t,e){const n=t.nodeIds,r=t.text.split(`
204
- `),s=kT(t),i=[];if(r.length===n.length)for(let o=0;o<n.length;o++){const l=r[o];if(!l)continue;const d=e.get(n[o]);if(!d)continue;const h=d.node.textContent.indexOf(l);if(h===-1)continue;const m=ia(d.node,d.pos,h),g=ia(d.node,d.pos,h+l.length);m!==null&&g!==null&&m<g&&i.push(qt.inline(m,g,s))}else{let o=0;for(const l of n){if(o>=r.length)break;const d=e.get(l);if(!d)continue;const f=r[o];if(!f){o++;continue}const m=d.node.textContent.indexOf(f);if(m===-1)continue;const g=ia(d.node,d.pos,m),v=ia(d.node,d.pos,m+f.length);g!==null&&v!==null&&g<v&&(i.push(qt.inline(g,v,s)),o++)}}return i}function hk(t){if(sa.length===0)return It.empty;const e=[],n=new Set,r=new Map;t.descendants((i,o)=>{var l;return i.isTextblock&&((l=i.attrs)!=null&&l.id)&&r.set(i.attrs.id,{node:i,pos:o}),!0});for(const i of sa)if(i.nodeIds&&i.nodeIds.length>1){const o=M5(i,r);o.length>0&&(n.add(i.id),e.push(...o))}for(const i of sa){if(n.has(i.id))continue;const o=r.get(i.nodeId);if(!o)continue;const l=fk(i,o.node,o.pos);l&&(n.add(i.id),e.push(l))}const s=sa.filter(i=>!n.has(i.id));return s.length>0&&t.descendants((i,o)=>{if(!i.isTextblock)return!0;for(const l of s){if(n.has(l.id))continue;const d=fk(l,i,o);d&&(n.add(l.id),e.push(d))}return!0}),It.create(t,e)}function ia(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const o=t.child(i);if(o.isText){if(r+o.text.length>=n)return s+(n-r);r+=o.text.length,s+=o.nodeSize}else{const l=o.type.spec.leafText?o.type.spec.leafText(o).length:0;if(l>0&&r+l>=n)return s;r+=l,s+=o.nodeSize}}return n===r?s:null}function ST(){return new Ut({key:j5,state:{init(t,e){return hk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceCommentUpdate")?hk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function pk(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceCommentUpdate",!0);n(r)}const A5=new Jt("backlinkDecoration");let Id=[];function mk(t){Id=Array.isArray(t)?t:[]}function R5(t){const e=new Map;for(const n of t){if(!n.to_node)continue;const r=e.get(n.to_node)??[];r.push(n),e.set(n.to_node,r)}return e}function gk(t){if(Id.length===0)return It.empty;const e=R5(Id);if(e.size===0)return It.empty;const n=[];return t.descendants((r,s)=>{var l;if(!r.isTextblock)return!0;const i=(l=r.attrs)==null?void 0:l.id;if(!i)return!0;const o=e.get(i);return o&&n.push(qt.node(s,s+r.nodeSize,{class:"linked-paragraph","data-backlinks-count":String(o.length),"data-backlinks-node":i})),!0}),It.create(t,n)}function O5(){return new Ut({key:A5,state:{init(t,e){return gk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceBacklinkUpdate")?gk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function I5(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceBacklinkUpdate",!0);n(r)}function L5(t){return Id.filter(e=>e.to_node===t)}const D5=new Jt("attributionDecoration");let ET={},NT=!1;function vk(t){ET=t&&typeof t=="object"?t:{}}function P5(t){NT=t}function yk(t){if(!NT)return It.empty;const e=[];return t.descendants((n,r)=>{var o;if(!n.isTextblock)return!0;const s=(o=n.attrs)==null?void 0:o.id;if(!s)return!0;const i=ET[s]??"unknown";return e.push(qt.node(r,r+n.nodeSize,{class:`attr-block attr-${i}`,"data-attr-origin":i})),!0}),It.create(t,e)}function B5(){return new Ut({key:D5,state:{init(t,e){return yk(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceAttributionUpdate")?yk(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function bk(t){if(!t)return;const{state:e,dispatch:n}=t;n(e.tr.setMeta("forceAttributionUpdate",!0))}const cy=new WeakMap;function $5(t,e){cy.set(t,e)}async function CT(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json(),i=cy.get(e);if(!i||i.getPreviewImages().length>=4)return;i.addToPreview(s)}catch{}}async function F5(t,e){try{const n=await fetch("/api/download-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})});if(!n.ok)return;const{src:r}=await n.json(),s=cy.get(e);if(!s||s.getPreviewImages().length>=4)return;s.addToPreview(r)}catch{}}function z5(t){const e=[],n=/<img[^>]+src=["']([^"']+)["']/gi;let r;for(;(r=n.exec(t))!==null;){const s=r[1];(s.startsWith("http://")||s.startsWith("https://"))&&e.push(s)}return e}function _T(t,e){var s,i;const n=(s=e.clipboardData)==null?void 0:s.items;if(!n)return!1;for(const o of n)if(o.type.startsWith("image/")){e.preventDefault();const l=o.getAsFile();return l&&CT(l,t),!0}const r=(i=e.clipboardData)==null?void 0:i.getData("text/html");if(r){const o=z5(r);if(o.length>0){e.preventDefault();for(const l of o)F5(l,t);return!0}}return!1}function TT(t,e){var r;const n=(r=e.dataTransfer)==null?void 0:r.files;if(!(n!=null&&n.length))return!1;for(const s of n)if(s.type.startsWith("image/"))return e.preventDefault(),CT(s,t),!0;return!1}const U5=["<!--StartFragment-->","<span"," style="," class="];function H5(t){return U5.some(e=>t.includes(e))||/<p[^>]*>\s*(<br\s*\/?>)?\s*<\/p>/i.test(t)}function W5(t){var i;if(!H5(t))return t;const e=t.match(/<!--StartFragment-->([\s\S]*?)<!--EndFragment-->/),n=e?e[1]:t,r=new DOMParser().parseFromString(`<div>${n}</div>`,"text/html"),s=r.body.firstChild;if(!s)return n;for(const o of Array.from(s.querySelectorAll("span"))){const l=o.getAttribute("style")||"",d=/font-weight:\s*(bold|[6-9]00)/i.test(l),f=/font-style:\s*italic/i.test(l),h=/text-decoration:[^;]*underline/i.test(l);if(d||f||h){let m=o.innerHTML;d&&(m=`<strong>${m}</strong>`),f&&(m=`<em>${m}</em>`),h&&(m=`<u>${m}</u>`);const g=r.createElement("div");g.innerHTML=m,o.replaceWith(...Array.from(g.childNodes))}else o.replaceWith(...Array.from(o.childNodes))}for(const o of Array.from(s.querySelectorAll("*")))o.removeAttribute("style"),o.removeAttribute("class"),o.removeAttribute("id");for(const o of Array.from(s.querySelectorAll("p"))){const l=(o.textContent||"").replace(/ /g,"").trim(),d=o.children.length===1&&((i=o.firstElementChild)==null?void 0:i.tagName)==="BR";!l&&(o.children.length===0||d)&&o.remove()}return s.innerHTML}const xk=/^[a-f0-9]{8}$/;function jT(t){if(!t.startsWith("doc:"))return null;const e=t.slice(4);let n=e,r=null;const s=e.indexOf("?q=");if(s>=0){n=e.slice(0,s);try{r=decodeURIComponent(e.slice(s+3))}catch{r=e.slice(s+3)}}let i=null;const o=n.indexOf("#");if(o>=0){const d=n.slice(o+1);i=xk.test(d)?d:null,n=n.slice(0,o)}const l=xk.test(n);return{docId:l?n:null,filename:l?null:n,nodeId:i,quote:r}}function Ap(t){const e=t.docId||t.filename;if(!e)throw new Error("formatLinkHref: docId or filename required");let n=`doc:${e}`;return t.nodeId&&(n+=`#${t.nodeId}`),t.quote&&(n+=`?q=${encodeURIComponent(t.quote)}`),n}function V5(t){const e=jT(t);return e?e.docId||e.filename:null}function xu({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=b.useRef(s);i.current=s;const o=t_({extensions:e||w5,content:t||"<p></p>",onUpdate:({editor:d})=>{ay()||n==null||n(d.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:_T,handleDrop:TT,transformPastedHTML:W5}},[]),l=b.useRef(t);return b.useEffect(()=>{if(!o||!t||l.current===t)return;l.current=t;const d=performance.now();o.commands.setContent(t,{emitUpdate:!1});const f=performance.now(),h=window.__lastSwitch;h&&h.tClick?console.log(`[Editor] setContent t=${f.toFixed(0)} duration=${(f-d).toFixed(1)}ms fromClick=${(f-h.tClick).toFixed(1)}ms fromReceive=${h.tReceive?(f-h.tReceive).toFixed(1):"?"}ms`):console.log(`[Editor] setContent t=${f.toFixed(0)} duration=${(f-d).toFixed(1)}ms (no matching switch)`)},[o,t]),b.useEffect(()=>{o&&console.log(`[Editor] first mount t=${performance.now().toFixed(0)}`)},[o]),b.useEffect(()=>{if(!o)return;const d=o.view.dom,f=h=>{var k;const m=h.target,g=m.closest("span.doc-link[data-doc]");if(g){const w=g.getAttribute("data-doc"),S=jT(`doc:${w}`);if(!S)return;(k=i.current)==null||k.call(i,S);return}const v=m.closest("a[href]");if(!v)return;const x=v.getAttribute("href")||"";/^(https?:|mailto:|tel:)/i.test(x)&&(h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),window.open(x,"_blank","noopener,noreferrer")))};return d.addEventListener("click",f,!0),()=>d.removeEventListener("click",f,!0)},[o]),b.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="pendingDecoration$"))return;const f=wT(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),b.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="commentDecoration$"))return;const f=ST(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),b.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="backlinkDecoration$"))return;const f=O5(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),b.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="attributionDecoration$"))return;const f=B5(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),b.useEffect(()=>{o&&(r==null||r(o))},[o,r]),o?c.jsxs(c.Fragment,{children:[c.jsx(Pv,{editor:o}),c.jsx(E5,{editor:o})]}):null}function Sn({onClick:t,active:e,disabled:n,title:r,children:s}){return c.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function Yo(){return c.jsx("div",{className:"format-toolbar__divider"})}async function q5(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json();e.chain().focus().setImage({src:s,alt:t.name}).run()}catch{}}function K5({editor:t}){const[,e]=b.useState(0),n=b.useRef(null);b.useEffect(()=>{const s=()=>e(i=>i+1);return t.on("transaction",s),()=>{t.off("transaction",s)}},[t]);const r=s=>{var o;const i=(o=s.target.files)==null?void 0:o[0];i&&q5(i,t),s.target.value=""};return c.jsxs("div",{className:"format-toolbar",children:[c.jsxs("div",{className:"format-toolbar__group",children:[c.jsx(Sn,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:c.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.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"})})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),c.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),c.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),c.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),c.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),c.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"m16 18 6-6-6-6"}),c.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),c.jsx(Yo,{}),c.jsxs("div",{className:"format-toolbar__group",children:[c.jsx(Sn,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),c.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"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"m4 5 8 8"}),c.jsx("path",{d:"m12 5-8 8"}),c.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"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"m4 19 8-8"}),c.jsx("path",{d:"m12 19-8-8"}),c.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"})]})})]}),c.jsx(Yo,{}),c.jsxs("div",{className:"format-toolbar__group",children:[c.jsx(Sn,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 12h8"}),c.jsx("path",{d:"M4 18V6"}),c.jsx("path",{d:"M12 18V6"}),c.jsx("path",{d:"m17 12 3-2v8"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 12h8"}),c.jsx("path",{d:"M4 18V6"}),c.jsx("path",{d:"M12 18V6"}),c.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 12h8"}),c.jsx("path",{d:"M4 18V6"}),c.jsx("path",{d:"M12 18V6"}),c.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),c.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M13 4v16"}),c.jsx("path",{d:"M17 4v16"}),c.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),c.jsx(Yo,{}),c.jsxs("div",{className:"format-toolbar__group",children:[c.jsx(Sn,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M3 12h.01"}),c.jsx("path",{d:"M3 18h.01"}),c.jsx("path",{d:"M3 6h.01"}),c.jsx("path",{d:"M8 12h13"}),c.jsx("path",{d:"M8 18h13"}),c.jsx("path",{d:"M8 6h13"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M11 12h9"}),c.jsx("path",{d:"M11 18h9"}),c.jsx("path",{d:"M11 6h9"}),c.jsx("path",{d:"M4 10V4h1"}),c.jsx("path",{d:"M4 10h2"}),c.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"m3 17 2 2 4-4"}),c.jsx("path",{d:"m3 7 2 2 4-4"}),c.jsx("path",{d:"M13 6h8"}),c.jsx("path",{d:"M13 12h8"}),c.jsx("path",{d:"M13 18h8"})]})})]}),c.jsx(Yo,{}),c.jsx("div",{className:"format-toolbar__group",children:c.jsx(Sn,{onClick:()=>{const s=t.getAttributes("link").href||"",i=window.prompt("Link URL:",s);i!==null&&(i===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:i}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),c.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}),c.jsx(Yo,{}),c.jsxs("div",{className:"format-toolbar__group",children:[c.jsx(Sn,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 6H3"}),c.jsx("path",{d:"M21 12H8"}),c.jsx("path",{d:"M21 18H8"}),c.jsx("path",{d:"M3 12v6"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"m10 9-3 3 3 3"}),c.jsx("path",{d:"m14 15 3-3-3-3"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:c.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M5 12h14"})})})]}),c.jsx(Yo,{}),c.jsxs("div",{className:"format-toolbar__group",children:[c.jsx(Sn,{onClick:()=>{var s;return(s=n.current)==null?void 0:s.click()},title:"Insert Image",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),c.jsx("circle",{cx:"9",cy:"9",r:"2"}),c.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),c.jsx(Sn,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:c.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"M12 3v18"}),c.jsx("path",{d:"M3 9h18"}),c.jsx("path",{d:"M3 15h18"})]})})]}),c.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const En={strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round"},G5=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M9 12l2 2 4-4",stroke:"currentColor",...En}),c.jsx("path",{d:"M21 12c0 4.97-4.03 9-9 9s-9-4.03-9-9 4.03-9 9-9c2.3 0 4.4.86 6 2.27",stroke:"currentColor",...En})]}),J5=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",...En}),c.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",...En})]}),Y5=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:c.jsx("path",{d:"M4 10v4M8 6v12M12 9v6M16 4v16M20 10v4",stroke:"currentColor",...En})}),X5=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:"currentColor",...En}),c.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:"currentColor",...En})]}),Q5=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",stroke:"currentColor",...En}),c.jsx("polyline",{points:"7 10 12 15 17 10",stroke:"currentColor",...En}),c.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3",stroke:"currentColor",...En})]}),Z5=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:c.jsx("path",{d:"M3 12h3l3-8 4 16 3-8h5",stroke:"currentColor",...En})}),e$=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M12 22v-5",stroke:"currentColor",...En}),c.jsx("path",{d:"M9 8V2",stroke:"currentColor",...En}),c.jsx("path",{d:"M15 8V2",stroke:"currentColor",...En}),c.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",stroke:"currentColor",...En})]}),t$=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("circle",{cx:"12",cy:"5",r:"3",stroke:"currentColor",...En}),c.jsx("circle",{cx:"5",cy:"19",r:"3",stroke:"currentColor",...En}),c.jsx("circle",{cx:"19",cy:"19",r:"3",stroke:"currentColor",...En}),c.jsx("line",{x1:"12",y1:"8",x2:"5",y2:"16",stroke:"currentColor",...En}),c.jsx("line",{x1:"12",y1:"8",x2:"19",y2:"16",stroke:"currentColor",...En})]}),n$=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.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",stroke:"currentColor",...En}),c.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]}),MT=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:c.jsx("path",{d:"M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),r$=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M15 3v18",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M9 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),s$=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M15 3v18",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M10 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function i$({title:t,onTitleChange:e,onToggleSidebar:n,canGoBack:r,canGoForward:s,onGoBack:i,onGoForward:o,editor:l,onToggleToolbar:d,toolbarOpen:f,focusMode:h,onToggleFocusMode:m}){const{visible:g,openTab:v,activeTab:x}=Dl(),[k,w]=b.useState(!1),[,S]=b.useState(0),N=b.useRef(null),[T,M]=b.useState(null);b.useEffect(()=>{fetch("/api/update-info").then($=>$.json()).then($=>{$.updateAvailable&&M({currentVersion:$.currentVersion,latestVersion:$.updateAvailable,updateCommand:$.updateCommand||"npm update -g openwriter"})}).catch(()=>{})},[]);const _=b.useCallback(()=>{w(!0),setTimeout(()=>{var $;return($=N.current)==null?void 0:$.select()},0)},[]),R=b.useCallback(()=>{w(!1)},[]),I=b.useCallback($=>{$.key==="Enter"&&w(!1),$.key==="Escape"&&w(!1)},[]);return b.useEffect(()=>{if(!l)return;const $=()=>S(P=>P+1);return l.on("transaction",$),()=>{l.off("transaction",$)}},[l]),c.jsxs("div",{className:"titlebar",children:[c.jsxs("div",{className:"titlebar-left",children:[n&&c.jsx("button",{className:"titlebar-menu-btn",onClick:n,title:"Open sidebar",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),i&&c.jsx("button",{className:"titlebar-nav-btn",onClick:i,disabled:!r,title:"Go back (Alt+Left)",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),o&&c.jsx("button",{className:"titlebar-nav-btn",onClick:o,disabled:!s,title:"Go forward (Alt+Right)",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),l&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"titlebar-divider"}),c.jsx("button",{className:"titlebar-nav-btn",onClick:()=>l.chain().focus().undo().run(),disabled:!l.can().undo(),title:"Undo (Ctrl+Z)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),c.jsx("button",{className:"titlebar-nav-btn",onClick:()=>l.chain().focus().redo().run(),disabled:!l.can().redo(),title:"Redo (Ctrl+Y)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),c.jsxs("div",{className:"titlebar-center",children:[k?c.jsx("input",{ref:N,className:"titlebar-input",value:t,onChange:$=>e($.target.value),onBlur:R,onKeyDown:I,autoFocus:!0}):c.jsx("span",{className:"titlebar-title",onDoubleClick:_,children:t}),T&&c.jsxs("span",{className:"titlebar-update-badge",title:`Update available: v${T.currentVersion} → v${T.latestVersion}
205
- Run: ${T.updateCommand}`,children:["v",T.latestVersion]})]}),c.jsxs("div",{className:"titlebar-right",children:[!g&&m&&c.jsx("button",{className:`titlebar-nav-btn${h?" titlebar-nav-btn--active":""}`,onClick:m,title:"Focus mode","aria-label":"Focus mode","aria-pressed":h,children:c.jsx(MT,{})}),!g&&d&&c.jsx("button",{className:`titlebar-nav-btn${f?" titlebar-nav-btn--active":""}`,onClick:d,title:"Toggle format toolbar","aria-label":"Toggle format toolbar","aria-pressed":f,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 20h16"}),c.jsx("path",{d:"m6 16 6-12 6 12"}),c.jsx("path",{d:"M8 12h8"})]})}),!g&&c.jsx("button",{className:"titlebar-nav-btn",onClick:()=>v(x||"activity"),title:"Show right rail","aria-label":"Show right rail",children:c.jsx(s$,{})})]})]})}const wk="ow-update-dismissed";function o$(){const[t,e]=b.useState(null);if(b.useEffect(()=>{fetch("/api/update-info").then(r=>r.json()).then(r=>{if(!r.updateAvailable)return;let s="";try{s=localStorage.getItem(wk)||""}catch{}s!==r.updateAvailable&&e({currentVersion:r.currentVersion,latestVersion:r.updateAvailable,updateCommand:r.updateCommand||"npm update -g openwriter"})}).catch(()=>{})},[]),!t)return null;const n=()=>{try{localStorage.setItem(wk,t.latestVersion)}catch{}e(null)};return c.jsxs("div",{className:"editor-update-banner",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"editor-update-dot","aria-hidden":"true"}),c.jsxs("span",{children:["OpenWriter ",c.jsxs("strong",{children:["v",t.latestVersion]})," is available"," ","(you're on v",t.currentVersion,") — update with"," ",c.jsx("code",{className:"editor-update-cmd",children:t.updateCommand})]}),c.jsx("button",{type:"button",className:"editor-update-dismiss",onClick:n,"aria-label":"Dismiss update notification",children:"×"})]})}function Fn(t,e){let n=null;return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function nf(t,e){const n=[];return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.pendingGroupId)===e&&n.push({nodeId:r.attrs.id,pos:s,node:r}),!0}),n}function la(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function Ld(t){return t?Array.isArray(t)?t.map(Ld).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>Ld(e)).join(""):"":""}const a$=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Dd(t,e){for(const n of t)n.type&&a$.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Dd(n.content,e)}function Qg(t,e,n,r){const s=Array.isArray(n)?n:[n],i=(r==null?void 0:r.autoAccept)===!0;if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const m=Fn(t,e.nodeId);if(!m)return{success:!1,error:`Node ${e.nodeId} not found`};const g=s.map((v,x)=>{var k;return{...v,attrs:{...v.attrs,id:((k=v.attrs)==null?void 0:k.id)||(x===0?e.nodeId:la())}}});i||Dd(g,"insert");try{return t.chain().deleteRange({from:m.pos,to:m.pos+m.node.nodeSize}).insertContentAt(m.pos,g).run(),{success:!0,nodeId:e.nodeId}}catch(v){return{success:!1,error:`Failed to replace empty node: ${v}`}}}if(!e.afterNodeId&&!e.beforeNodeId)return{success:!1,error:"Insert requires afterNodeId, beforeNodeId, or nodeId"};const o=e.afterNodeId||e.beforeNodeId,l=!!e.afterNodeId,d=Fn(t,o);if(!d)return{success:!1,error:`Anchor node ${o} not found`};if(!i){const m=Ld(n),g=l?d.pos+d.node.nodeSize:0,v=l?d.pos+d.node.nodeSize+5e3:d.pos;let x=null;if(t.state.doc.nodesBetween(g,Math.min(v,t.state.doc.content.size),k=>{var w,S;return((w=k.attrs)==null?void 0:w.pendingStatus)==="insert"&&((S=k.attrs)!=null&&S.id)&&(k.textContent||"")===m?(x=k.attrs.id,!1):!0}),x)return{success:!0,nodeId:x}}const f=s.map(m=>{var g;return{...m,attrs:{...m.attrs,id:((g=m.attrs)==null?void 0:g.id)||la()}}});i||Dd(f,"insert");const h=l?d.pos+d.node.nodeSize:d.pos;try{return t.chain().insertContentAt(h,f).run(),{success:!0,nodeId:f[0].attrs.id}}catch(m){return{success:!1,error:`Failed to insert content: ${m}`}}}function uy(t,e,n,r,s){var w,S,N,T,M,_;const i=Fn(t,e);if(!i)return{success:!1,error:`Node ${e} not found`};const{node:o,pos:l}=i,d=Array.isArray(n)?n:[n],f=(s==null?void 0:s.autoAccept)===!0,m=!((w=o.attrs)!=null&&w.pendingOriginalContent)?o.toJSON():o.attrs.pendingOriginalContent,v=((S=d[0])==null?void 0:S.type)==="listItem"&&((_=(M=(T=(N=d[0])==null?void 0:N.content)==null?void 0:T[0])==null?void 0:M.attrs)==null?void 0:_.pendingStatus)!=null?{...d[0],attrs:{...d[0].attrs,id:e}}:{...d[0],attrs:f?{...d[0].attrs,id:e}:{...d[0].attrs,id:e,pendingStatus:"rewrite",pendingOriginalContent:m,...r?{pendingSelectionFrom:r.selectionFrom,pendingSelectionTo:r.selectionTo,pendingOriginalFrom:r.originalFrom,pendingOriginalTo:r.originalTo}:{}}},x=d.slice(1).map(R=>{var I;return{...R,attrs:{...R.attrs,id:((I=R.attrs)==null?void 0:I.id)||la()}}});f||Dd(x,"insert");const k=[v,...x];try{return t.chain().command(({tr:R})=>{const I=k.map($=>t.state.schema.nodeFromJSON($));return R.replaceWith(l,l+o.nodeSize,I),!0}).run(),{success:!0,nodeId:e}}catch(R){return{success:!1,error:`Failed to rewrite: ${R}`}}}function l$(t,e,n){if(e.length===0)return{success:!1,error:"Range rewrite requires original IDs"};if(!n||n.length===0)return{success:!1,error:"Range rewrite requires new content (received empty)"};if(n.map(m=>Ld(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=Fn(t,e[0]),i=Fn(t,e[e.length-1]);if(!s||!i)return{success:!1,error:"Could not find original nodes for range rewrite"};const o=[];for(const m of e){const g=Fn(t,m);g&&o.push(g.node.toJSON())}const l=s.pos,d=i.pos+i.node.nodeSize,f=la()+la(),h=n.map((m,g)=>{var v;return{...m,attrs:{...m.attrs,id:((v=m.attrs)==null?void 0:v.id)||la(),pendingStatus:"rewrite",pendingGroupId:f,...g===0?{pendingOriginalContent:o}:{}}}});try{return t.chain().deleteRange({from:l,to:d}).insertContentAt(l,h).run(),{success:!0,nodeId:h[0].attrs.id}}catch(m){return{success:!1,error:`Failed to apply range rewrite: ${m}`}}}function AT(t,e,n){var l;const r=Fn(t,e);if(!r)return{success:!1,error:`Node ${e} not found`};const{node:s,pos:i}=r,o=(n==null?void 0:n.autoAccept)===!0;if(!o&&((l=s.attrs)==null?void 0:l.pendingStatus)==="delete")return{success:!0,nodeId:e};try{return o?t.chain().deleteRange({from:i,to:i+s.nodeSize}).run():t.chain().command(({tr:d})=>(d.setNodeMarkup(i,void 0,{...s.attrs,pendingStatus:"delete"}),!0)).run(),{success:!0,nodeId:e}}catch(d){return{success:!1,error:`Failed to ${o?"delete":"mark for deletion"}: ${d}`}}}function c$(t,e){const n=e.autoAccept?{autoAccept:!0}:void 0;if(e.operation==="rewrite"&&e.nodeId&&e.content){const r=uy(t,e.nodeId,e.content,null,n);return{success:r.success,error:r.error}}if(e.operation==="insert"&&e.content){let r=null;if(e.nodeId&&!e.afterNodeId?r={nodeId:e.nodeId}:e.afterNodeId&&(r={afterNodeId:e.afterNodeId}),!r)return{success:!1,error:"Insert requires afterNodeId or nodeId"};const s=Qg(t,r,e.content,n);return{success:s.success,error:s.error}}if(e.operation==="delete"&&e.nodeId){const r=AT(t,e.nodeId,n);return{success:r.success,error:r.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function Rp(t,e){if(e.length===0)return;if(e.length===1){c$(t,e[0]);return}const n=t.state.schema;t.chain().command(({tr:r})=>{var s;for(const i of e)try{const o=i.autoAccept===!0;if(i.operation==="rewrite"&&i.nodeId&&i.content){const l=tl(r.doc,i.nodeId);if(!l){console.warn("[openwriter] rewrite skipped — node id not found in editor",{nodeId:i.nodeId});continue}const f=(Array.isArray(i.content)?i.content:[i.content]).map(h=>n.nodeFromJSON(h));r.replaceWith(l.pos,l.pos+l.node.nodeSize,f)}else if(i.operation==="insert"&&i.content){const d=(Array.isArray(i.content)?i.content:[i.content]).map(f=>n.nodeFromJSON(f));if(!o){const f=d.map(h=>h.textContent||"").join("");if(f&&i.afterNodeId){const h=tl(r.doc,i.afterNodeId);if(h){const m=h.pos+h.node.nodeSize,g=Math.min(m+5e3,r.doc.content.size);let v=!1;if(r.doc.nodesBetween(m,g,x=>{var k;return v?!1:((k=x.attrs)==null?void 0:k.pendingStatus)==="insert"&&(x.textContent||"")===f?(v=!0,!1):!0}),v)continue}}}if(i.nodeId&&!i.afterNodeId){const f=tl(r.doc,i.nodeId);if(!f){console.warn("[openwriter] insert (replace) skipped — node id not found in editor",{nodeId:i.nodeId});continue}r.replaceWith(f.pos,f.pos+f.node.nodeSize,d)}else if(i.afterNodeId){const f=tl(r.doc,i.afterNodeId);if(!f){console.warn("[openwriter] insert (after) skipped — anchor id not found in editor",{afterNodeId:i.afterNodeId});continue}const h=f.pos+f.node.nodeSize;r.insert(h,we.fromArray(d))}}else if(i.operation==="delete"&&i.nodeId){const l=tl(r.doc,i.nodeId);if(!l){console.warn("[openwriter] delete skipped — node id not found in editor",{nodeId:i.nodeId});continue}if(o)r.delete(l.pos,l.pos+l.node.nodeSize);else{if(((s=l.node.attrs)==null?void 0:s.pendingStatus)==="delete")continue;r.setNodeMarkup(l.pos,void 0,{...l.node.attrs,pendingStatus:"delete"})}}}catch{continue}return!0}).run()}function tl(t,e){let n=null;return t.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function u$(t,e){if(!e||e.length===0||t.isDestroyed)return;const n=new Map(e.map(r=>[r.oldId,r.newId]));t.chain().command(({tr:r})=>{const s=[];r.doc.descendants((i,o)=>{var d;const l=(d=i.attrs)==null?void 0:d.id;l&&n.has(l)&&s.push({pos:o,attrs:{...i.attrs,id:n.get(l)}})});for(const{pos:i,attrs:o}of s)r.setNodeMarkup(i,void 0,o);return!0}).run()}function d$(t,e,n,r){const s=[];if(r==="delete"){for(const o of n)s.push(AT(t,o));return s}if(r==="insert"){const o=n[n.length-1];return o&&e.length>0&&s.push(Qg(t,{nodeId:o},e)),s}if(n.length>1){const o=l$(t,n,e);return s.push(o),s}const i=uy(t,n[0],e[0]);if(s.push(i),e.length>1){const o=e.slice(1);s.push(Qg(t,{afterNodeId:n[0]},o))}return s}const kk="[[START_SELECTION]]",Sk="[[END_SELECTION]]";function f$(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 wu(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=f$(t);let s=Math.max(0,Math.min(e,r));for(let i=0;i<t.content.length;i++){const o=t.content[i];if(o.type==="text"&&typeof o.text=="string"){if(s<=o.text.length){const l=Math.max(0,Math.min(o.text.length,s));o.text=o.text.slice(0,l)+n+o.text.slice(l);return}s-=o.text.length;continue}if(o.type==="hardBreak"){if(s===0){t.content.splice(i+1,0,{type:"text",text:n});return}s-=1;continue}if(s===0){t.content.splice(i,0,{type:"text",text:n});return}}t.content.push({type:"text",text:n})}function h$(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(wu(r[0],n,Sk),wu(r[0],e,kk),r):(wu(r[0],e,kk),wu(r[r.length-1],n,Sk),r)}function p$(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)}let mi=null;function m$(){return mi&&document.body.contains(mi)||(mi=document.createElement("div"),mi.style.cssText=["position:fixed","left:50%","bottom:32px","transform:translateX(-50%)","z-index:99999","display:flex","flex-direction:column","gap:8px","align-items:center","pointer-events:none"].join(";"),document.body.appendChild(mi)),mi}function ji(t,e="info",n=3500,r){const s=m$(),i=document.createElement("div");i.style.cssText=["background:var(--bg-surface)","border:1px solid var(--border)",e==="error"?"border-left:3px solid var(--color-pending-delete)":"","color:var(--ink-dark)","font-family:var(--font-body)","padding:10px 14px","border-radius:8px","font-size:13px","line-height:1.4","max-width:420px","box-shadow:0 4px 20px rgba(0,0,0,0.15)","pointer-events:auto","opacity:0","transition:opacity 160ms ease, transform 160ms ease","transform:translateY(6px)",r?"display:flex;align-items:center;gap:12px":""].filter(Boolean).join(";");const o=document.createElement("span");if(o.textContent=t,i.appendChild(o),r){const d=document.createElement("button");d.textContent=r.label,d.style.cssText=["flex-shrink:0","padding:4px 12px","border-radius:6px","border:1px solid var(--accent)","background:var(--accent)","color:var(--bg-surface)","font-family:var(--font-body)","font-size:12px","font-weight:600","cursor:pointer"].join(";"),d.addEventListener("click",()=>{try{r.onClick()}finally{l()}}),i.appendChild(d)}function l(){i.style.opacity="0",i.style.transform="translateY(6px)",setTimeout(()=>{i.remove(),s.childElementCount===0&&(s.remove(),mi=null)},200)}s.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",i.style.transform="translateY(0)"}),setTimeout(l,n)}function g$(t){return`$${(t/100).toFixed(2)}`}async function v$(){try{const t=await fetch("/api/voice/billing");return t.ok?await t.json():null}catch{return null}}async function y$(){try{const t=await fetch("/api/voice/billing/topup-options");if(!t.ok)return[];const e=await t.json();return Array.isArray(e==null?void 0:e.options)?e.options:[]}catch{return[]}}async function RT(t){try{const e=await fetch("/api/voice/billing/topup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({amount:t})});if(!e.ok){ji("Could not start top-up. Please try again.","error");return}const n=await e.json();n!=null&&n.url?window.open(n.url,"_blank"):ji("Could not start top-up. Please try again.","error")}catch{ji("Could not start top-up. Please try again.","error")}}const Ek=5e3;function Nk(t,e){return t.docId&&e.includes(t.docId)?!0:e.includes(t.filename)}const b$=[{action:"comment",label:"Comment",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function x$({editorRef:t,allEditors:e,documentId:n}){const[r,s]=b.useState(!1),[i,o]=b.useState({x:0,y:0}),[l,d]=b.useState(!1),[f,h]=b.useState(""),[m,g]=b.useState(!1),[v,x]=b.useState(""),[k,w]=b.useState(!1),[S,N]=b.useState([]),[T,M]=b.useState([]),[_,R]=b.useState(!1),[I,$]=b.useState(""),[P,z]=b.useState([]),[q,F]=b.useState(!1),[G,B]=b.useState(""),[W,K]=b.useState(null),[ne,V]=b.useState(null),[oe,J]=b.useState(null),[A,L]=b.useState(!1),[ee,pe]=b.useState(null),[xe,re]=b.useState(null),Ne=b.useRef(null),ke=b.useRef(null),ze=b.useRef(null),Fe=b.useCallback(Q=>{if(e&&e.length>0){for(const fe of e)if(fe.view.dom.contains(Q))return fe}const de=t.current;return de&&de.view.dom.contains(Q)?de:null},[e,t]);b.useLayoutEffect(()=>{const Q=Ne.current;if(!Q||!r)return;const de=Q.getBoundingClientRect(),fe=8;let{x:Je,y:Ie}=i;Ie+de.height+fe>window.innerHeight&&(Ie=i.y-de.height),Je+de.width+fe>window.innerWidth&&(Je=i.x-de.width),Ie<fe&&(Ie=fe),Je<fe&&(Je=fe),(Je!==i.x||Ie!==i.y)&&o({x:Je,y:Ie})},[r,i]);const Ge=b.useCallback(()=>{fetch("/api/plugins").then(Q=>Q.json()).then(Q=>{const de=[];for(const fe of Q.plugins||[]){const Je=fe.displayName||void 0;for(const Ie of fe.contextMenuItems||[])de.push({...Ie,pluginDisplayName:Je})}z(de)}).catch(()=>{})},[]);b.useEffect(()=>{Ge()},[Ge]),b.useEffect(()=>{const Q=()=>Ge();return window.addEventListener("ow-plugins-changed",Q),()=>window.removeEventListener("ow-plugins-changed",Q)},[Ge]),b.useEffect(()=>{const Q=de=>{Ne.current&&!Ne.current.contains(de.target)&&(s(!1),g(!1),w(!1),F(!1),B(""),K(null),V(null),pe(null))};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[]);const Re=b.useCallback(()=>{const Q=ze.current||t.current;return Q?Q.isActive("link"):!1},[t]),Ze=b.useCallback(()=>{const Q=ze.current||t.current,de=ke.current;if(!Q||!de)return!1;const{from:fe,to:Je}=de;let Ie=!1;return Q.state.doc.nodesBetween(fe,Je,it=>{var dt;return(dt=it.attrs)!=null&&dt.pendingStatus&&(Ie=!0),!Ie}),Ie},[t]),gt=b.useCallback(()=>{const Q=ze.current||t.current,de=ke.current,fe=(de==null?void 0:de.from)??0,Je=(de==null?void 0:de.to)??0,Ie=fe!==Je,it=(()=>{if(!Q)return!1;try{return Q.state.doc.resolve(fe).parent.content.size===0}catch{return!1}})(),dt=Ze(),at=[];for(const Ye of P)Ye.condition==="has-selection"&&!Ie||Ye.condition==="empty-node"&&!it||at.push({action:Ye.action,label:Ye.label,shortcut:Ye.shortcut,isPlugin:!0,promptForInput:Ye.promptForInput,pluginDisplayName:Ye.pluginDisplayName});for(const Ye of b$)Ye.condition==="has-selection"&&(!Ie||dt)||at.push(Ye);if(Ie&&at.push({action:"link",label:"Link to doc",shortcut:"L"}),Re()&&at.push({action:"unlink",label:"Unlink"}),oe&&oe.entries.length>0&&at.unshift({action:"see-connections",label:`See connections (${oe.entries.length})`}),ee){const Ye=ee.title?`Go to "${ee.title}"`:"Go to target";at.unshift({action:"go-to-target",label:Ye})}return at},[t,Re,P,Ze,oe,ee]);b.useEffect(()=>{const Q=fe=>{var Ye;if(fe.button!==2)return;const Je=Fe(fe.target);if(!Je)return;ze.current=Je;const{from:Ie,to:it}=Je.state.selection,dt=[],at=[];if(Ie!==it&&Je.state.doc.nodesBetween(Ie,it,qe=>{qe.isBlock&&qe.type.name!=="doc"&&(dt.push(qe.toJSON()),qe.attrs.id&&at.push(qe.attrs.id))}),dt.length===0){const{$from:qe}=Je.state.selection,lt=qe.parent;lt&&lt.type.name!=="doc"&&(dt.push(lt.toJSON()),(Ye=lt.attrs)!=null&&Ye.id&&at.push(lt.attrs.id))}ke.current={from:Ie,to:it,nodes:dt,nodeIds:at}},de=fe=>{var lt,bt,Ce,Se,We,tt;if(!Fe(fe.target)||fe.shiftKey)return;const Ie=(bt=(lt=fe.target)==null?void 0:lt.closest)==null?void 0:bt.call(lt,"[data-comment-id]"),it=(Ie==null?void 0:Ie.getAttribute("data-comment-id"))||null,dt=(Se=(Ce=fe.target)==null?void 0:Ce.closest)==null?void 0:Se.call(Ce,".linked-paragraph[data-backlinks-node]"),at=(dt==null?void 0:dt.getAttribute("data-backlinks-node"))||null,Ye=(tt=(We=fe.target)==null?void 0:We.closest)==null?void 0:tt.call(We,"span.doc-link[data-doc]"),qe=(Ye==null?void 0:Ye.getAttribute("data-doc"))||null;if(fe.preventDefault(),o({x:fe.clientX,y:fe.clientY}),s(!0),g(!1),w(!1),L(!1),F(!1),B(""),K(null),it){const He=ke.current;if(!(!!He&&He.from!==He.to)){const j=$u().find(U=>U.id===it);if(j){V({id:j.id,text:j.text,note:j.note}),J(null);return}}}if(V(null),at){const He=L5(at);J(He.length>0?{nodeId:at,entries:He}:null)}else J(null);if(qe){const He=qe.indexOf("?"),xt=He>=0?qe.slice(0,He):qe,[j,U]=xt.split("#"),ie=j&&/^[a-f0-9]{8}$/.test(j)?j:null,D=U&&/^[a-f0-9]{8}$/.test(U)?U:null;if(ie){const ce=S.find(me=>me.docId===ie);pe({docId:ie,nodeId:D,title:(ce==null?void 0:ce.title)||null}),ce||fetch("/api/documents").then(me=>me.json()).then(me=>{if(Array.isArray(me)){const se=me.map(be=>({filename:be.filename,title:be.title,docId:be.docId}));N(se);const he=se.find(be=>be.docId===ie);he&&pe(be=>be&&be.docId===ie?{...be,title:he.title}:be)}}).catch(()=>{})}else pe(null)}else pe(null)};return document.addEventListener("mousedown",Q,!0),document.addEventListener("contextmenu",de),()=>{document.removeEventListener("mousedown",Q,!0),document.removeEventListener("contextmenu",de)}},[Fe]);const ht=b.useCallback(async(Q,de)=>{var bt,Ce,Se,We,tt;const fe=ze.current||t.current;if(!fe)return;const Je=ke.current;if(!Je||Je.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",Q);return}let{nodes:Ie,nodeIds:it}=Je;const{from:dt,to:at}=Je;d(!0),s(!1),g(!1);const Ye=`ctx-${Date.now()}`,qe=Q.includes(":")?Q.split(":").slice(1).join(":"):Q,lt=["insert","fill","fill-sentence"].includes(qe);if(lt)fe.commands.showInsertionLoading(Ye,dt);else{const He=fe.state.doc.resolve(dt),xt=fe.state.doc.resolve(at),j=He.sameParent(xt)&&dt!==at;fe.commands.applyLoadingEffect(Ye,dt,at,j?"selection":"paragraph")}try{const He=[],xt=[],j=new Set(it);let U=!1;const ie=fe.state.doc;for(let Ve=0;Ve<ie.childCount;Ve++){const Vt=ie.child(Ve),Un=(bt=Vt.attrs)==null?void 0:bt.id;if(Un&&j.has(Un))U=!0;else if(U){const fn=Vt.textContent.trim();fn&&xt.push(fn)}else{const fn=Vt.textContent.trim();fn&&He.push(fn)}}let D=Ie,ce=!1,me=0,se=0;const he=dt!==at?fe.state.doc.resolve(dt):null,be=dt!==at?fe.state.doc.resolve(at):null;if((he&&be?he.sameParent(be):!1)&&he&&Ie.length===1){const Ve=he.start(he.depth);me=dt-Ve,se=at-Ve;const Vt=((Se=(Ce=Ie[0])==null?void 0:Ce.content)==null?void 0:Se.reduce((Un,fn)=>{var mr;return Un+(((mr=fn.text)==null?void 0:mr.length)||(fn.type==="hardBreak"?1:0))},0))??0;(me>0||se<Vt)&&(D=h$(Ie,me,se),ce=!0)}const Ee=fe.state.doc.textContent,Ht={nodes:D,action:qe,nodeIds:it,contextBefore:He.slice(-3),contextAfter:xt.slice(0,3),fullDocument:Ee,documentId:n,debug:!0};ce&&(Ht.hasSelectionMarkers=!0),de&&(Ht.instruction=de);const cn=((Ie||[]).map(Ve=>Array.isArray(Ve==null?void 0:Ve.content)?Ve.content.map(Vt=>(Vt==null?void 0:Vt.text)||"").join(" "):"").join(" ").match(/\S+/g)||[]).length;if(cn>Ek){ji(`Selection too large: ${cn.toLocaleString()} words (max ${Ek.toLocaleString()}). Select a smaller section.`,"error"),lt?fe.commands.removeInsertionLoading(Ye):fe.commands.removeLoadingEffect(Ye);return}const xn=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ht)});if(!xn.ok){const Ve=await xn.json().catch(()=>({}));console.error("[ContextMenu] API error:",xn.status,Ve);const Vt=typeof(Ve==null?void 0:Ve.message)=="string"&&Ve.message||typeof(Ve==null?void 0:Ve.error)=="string"&&Ve.error||`Enhance failed (${xn.status}). Please try again.`;xn.status===402&&(Ve==null?void 0:Ve.error)==="insufficient_balance"?ji(Vt,"error",9e3,{label:"Top up",onClick:()=>RT(5)}):ji(Vt,"error");return}const Nn=await xn.json();if(Nn.success&&Nn.nodes){let Ve=Nn.nodes;if(Ve.length===1&&Array.isArray(Ve[0])&&(Ve=Ve[0]),p$(Ve),ce&&Ve.length===1&&it.length===1){const Vt=_s=>(_s??[]).reduce((Ir,Bt)=>Ir+(typeof Bt.text=="string"?Bt.text:Bt.type==="hardBreak"?`
206
- `:""),""),Un=Vt((We=Ie[0])==null?void 0:We.content),fn=Vt((tt=Ve[0])==null?void 0:tt.content),mr=Math.min(Un.length,fn.length);let Xt=0;for(;Xt<mr&&Un[Xt]===fn[Xt];)Xt++;let Hn=0;const lr=mr-Xt;for(;Hn<lr&&Un[Un.length-1-Hn]===fn[fn.length-1-Hn];)Hn++;const cr={selectionFrom:Xt,selectionTo:fn.length-Hn,originalFrom:Xt,originalTo:Un.length-Hn};uy(fe,it[0],Ve[0],cr)}else d$(fe,Ve,it,qe);window.dispatchEvent(new CustomEvent("ow-pending-write-applied")),Nn.debug&&fetch("/api/prompt-debug",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:qe,debug:Nn.debug,metadata:Nn.metadata})}).catch(()=>{})}else console.warn("[ContextMenu] Unexpected response:",Nn)}catch(He){console.error("[ContextMenu] Plugin action failed:",He)}finally{lt?fe.commands.removeInsertionLoading(Ye):fe.commands.removeLoadingEffect(Ye),d(!1)}},[t]),ge=b.useCallback(async Q=>{const de=ze.current||t.current;if(!de)return;const{$from:fe}=de.state.selection,Je=fe.before(fe.depth),Ie=fe.after(fe.depth),it=fe.parent.content.size===0;d(!0),s(!1),g(!1),it?de.chain().focus().deleteRange({from:Je,to:Ie}).insertContentAt(Je,{type:"imageLoading"}).run():de.chain().focus().insertContentAt(Ie,{type:"imageLoading"}).run();let dt=-1;de.state.doc.descendants((at,Ye)=>{if(at.type.name==="imageLoading"&&dt===-1)return dt=Ye,at.nodeSize,!1});try{const at=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:Q})}),Ye=await at.json().catch(()=>({success:!1,error:`Generation failed (${at.status})`}));if(Ye.success&&Ye.src){let qe=-1,lt=0;if(de.state.doc.descendants((bt,Ce)=>{if(bt.type.name==="imageLoading"&&qe===-1)return qe=Ce,lt=bt.nodeSize,!1}),qe>=0){const{tr:bt}=de.state;bt.replaceWith(qe,qe+lt,de.schema.nodes.image.create({src:Ye.src,alt:Q})),de.view.dispatch(bt)}}else{console.error("[ContextMenu] Image generation failed:",Ye.error);let qe=-1,lt=0;if(de.state.doc.descendants((bt,Ce)=>{if(bt.type.name==="imageLoading"&&qe===-1)return qe=Ce,lt=bt.nodeSize,!1}),qe>=0){const{tr:bt}=de.state;bt.delete(qe,qe+lt),de.view.dispatch(bt)}}}catch(at){console.error("[ContextMenu] Image generation failed:",at);let Ye=-1,qe=0;if(de.state.doc.descendants((lt,bt)=>{if(lt.type.name==="imageLoading"&&Ye===-1)return Ye=bt,qe=lt.nodeSize,!1}),Ye>=0){const{tr:lt}=de.state;lt.delete(Ye,Ye+qe),de.view.dispatch(lt)}}finally{d(!1)}},[t]),vt=b.useCallback(Q=>{const{action:de,isPlugin:fe,promptForInput:Je}=Q;if(fe&&Je){x(de),g(!0);return}if(fe){if(de.startsWith("img:"))return;ht(de);return}if(de==="comment"){F(!0);return}if(de==="delete"){const Ie=ze.current||t.current,it=ke.current;if(Ie&&it&&it.nodeIds.length>0){const{tr:dt}=Ie.state,at=new Set(it.nodeIds),Ye=[];Ie.state.doc.descendants((qe,lt)=>{var bt;if((bt=qe.attrs)!=null&&bt.id&&at.has(qe.attrs.id))return Ye.push({from:lt,to:lt+qe.nodeSize}),!1});for(const qe of Ye.reverse())dt.delete(qe.from,qe.to);Ye.length>0&&Ie.view.dispatch(dt)}s(!1);return}if(de==="link"){const Ie=ze.current||t.current;if(Ie){const it=[];Ie.state.doc.descendants(dt=>{var at;(at=dt.marks)==null||at.forEach(Ye=>{var qe,lt;if(Ye.type.name==="link"&&((lt=(qe=Ye.attrs)==null?void 0:qe.href)!=null&&lt.startsWith("doc:"))){const bt=V5(Ye.attrs.href);bt&&!it.includes(bt)&&it.push(bt)}})}),M(it)}fetch("/api/documents").then(it=>it.json()).then(it=>{Array.isArray(it)&&N(it.map(dt=>({filename:dt.filename,title:dt.title,docId:dt.docId}))),R(!1),$(""),w(!0)}).catch(()=>{});return}if(de==="unlink"){const Ie=ze.current||t.current;Ie&&Ie.chain().focus().unsetLink().run(),s(!1);return}if(de==="see-connections"){fetch("/api/documents").then(Ie=>Ie.json()).then(Ie=>{Array.isArray(Ie)&&N(Ie.map(it=>({filename:it.filename,title:it.title,docId:it.docId})))}).catch(()=>{}),L(!0);return}if(de==="go-to-target"){ee&&window.dispatchEvent(new CustomEvent("ow-navigate-to-link",{detail:{docId:ee.docId,nodeId:ee.nodeId,filename:null,quote:null}})),s(!1),pe(null);return}},[ht,t,ee]),_t=b.useCallback(()=>{f.trim()&&(v.startsWith("img:")?ge(f.trim()):ht(v,f.trim()),h(""),x(""))},[ht,ge,v,f]),Et=b.useCallback(()=>{if(!n)return;if(W){fetch("/api/comments",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,id:W.id,note:G.trim()})}).then(()=>{s(!1),F(!1),B(""),K(null)}).catch(dt=>{console.error("[ContextMenu] Comment edit failed:",dt)});return}const Q=ze.current||t.current,de=ke.current;if(!Q||!de)return;const{from:fe,to:Je,nodeIds:Ie}=de;if(fe===Je||Ie.length===0)return;const it=Q.state.doc.textBetween(fe,Je,`
207
- `);it.trim()&&fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:it,note:G.trim(),nodeId:Ie[Ie.length-1],nodeIds:Ie})}).then(()=>{s(!1),F(!1),B("")}).catch(dt=>{console.error("[ContextMenu] Comment create failed:",dt)})},[t,n,G,W]),Dt=b.useCallback(()=>{ne&&(K({id:ne.id,text:ne.text}),B(ne.note),F(!0),V(null))},[ne]),ot=b.useCallback(()=>{ne&&fetch("/api/comments/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[ne.id]})}).then(()=>{s(!1),V(null)}).catch(Q=>{console.error("[ContextMenu] Comment resolve failed:",Q)})},[ne]),Le=b.useCallback(()=>{ne&&fetch("/api/comments",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[ne.id]})}).then(()=>{s(!1),V(null)}).catch(Q=>{console.error("[ContextMenu] Comment delete failed:",Q)})},[ne]),ve=b.useCallback((Q,de)=>{const fe=ze.current||t.current;if(fe){const Je=Q.docId?Ap({docId:Q.docId,nodeId:de==null?void 0:de.nodeId,quote:de==null?void 0:de.quote}):Ap({filename:Q.filename});fe.chain().focus().setLink({href:Je}).run()}fetch("/api/auto-tag-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetFile:Q.filename})}).catch(()=>{}),s(!1),w(!1),re(null)},[t]),te=b.useCallback(Q=>{if(!Q.docId){ve(Q);return}re({docId:Q.docId,filename:Q.filename,title:Q.title,paragraphs:[],loading:!0}),fetch(`/api/documents/by-doc-id/${Q.docId}/paragraphs`).then(de=>de.json()).then(de=>{re(fe=>fe&&fe.docId===Q.docId?{...fe,paragraphs:Array.isArray(de.paragraphs)?de.paragraphs:[],loading:!1}:fe)}).catch(()=>{re(de=>de&&de.docId===Q.docId?{...de,paragraphs:[],loading:!1}:de)})},[ve]),je=b.useCallback(()=>{const Q=I.trim();if(!Q)return;const de=ze.current||t.current;de&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:Q})}).then(fe=>fe.json()).then(fe=>{if(fe.filename){const Je=Ap(fe.docId?{docId:fe.docId}:{filename:fe.filename});de.chain().focus().setLink({href:Je}).run()}}).catch(()=>{}),s(!1),w(!1),R(!1),$(""))},[t,I]);return r?c.jsx("div",{ref:Ne,className:"context-menu",style:{left:i.x,top:i.y},children:l?c.jsx("div",{className:"context-menu-loading",children:"Applying..."}):q?c.jsxs("div",{className:"context-menu-comment-editor",children:[(()=>{const Q=(W==null?void 0:W.text)??(()=>{const de=ze.current||t.current,fe=ke.current;return!de||!fe||fe.from===fe.to?"":de.state.doc.textBetween(fe.from,fe.to,`
208
- `)})();return Q?c.jsx("div",{className:"context-menu-comment-quote",children:Q}):null})(),c.jsx("textarea",{autoFocus:!0,className:"context-menu-comment-textarea",value:G,onChange:Q=>B(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&(Q.metaKey||Q.ctrlKey)&&(Q.preventDefault(),Et()),Q.key==="Escape"&&(s(!1),F(!1),B(""),K(null))},placeholder:"Note for agent (optional)...",rows:4}),c.jsxs("div",{className:"context-menu-comment-actions",children:[c.jsx("span",{className:"context-menu-comment-hint",children:"⌘↵ to save · Esc to cancel"}),c.jsx("button",{onClick:Et,children:W?"Save":"Comment"})]})]}):ne?c.jsxs(c.Fragment,{children:[c.jsx("button",{className:"context-menu-item",onClick:Dt,children:c.jsx("span",{children:"Edit comment"})}),c.jsx("button",{className:"context-menu-item",onClick:ot,children:c.jsx("span",{children:"Resolve comment"})}),c.jsx("button",{className:"context-menu-item",onClick:Le,children:c.jsx("span",{children:"Delete comment"})})]}):m?c.jsxs("div",{className:"context-menu-custom",children:[c.jsx("input",{autoFocus:!0,value:f,onChange:Q=>h(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&_t(),Q.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),c.jsx("button",{onClick:_t,children:"Apply"})]}):xe?c.jsxs("div",{className:"context-menu-link-picker",children:[c.jsxs("div",{className:"context-menu-link-header",children:[c.jsx("button",{className:"context-menu-link-back",onClick:()=>re(null),title:"Back to doc list",children:"←"}),c.jsxs("span",{children:['Pick paragraph in "',xe.title,'"']})]}),c.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>ve({filename:xe.filename,docId:xe.docId}),children:c.jsx("span",{children:"Link whole doc"})}),c.jsx("div",{className:"context-menu-link-list",children:xe.loading?c.jsx("div",{className:"context-menu-loading",children:"Loading…"}):xe.paragraphs.length===0?c.jsx("div",{className:"context-menu-loading",children:"No paragraphs"}):xe.paragraphs.map(Q=>{const de=Q.preview.replace(/…$/,"").slice(0,50),fe=Q.type==="heading"?Math.max(0,(Q.level||1)-1)*12:12;return c.jsx("button",{className:`context-menu-item context-menu-paragraph-row context-menu-paragraph-row--${Q.type}`,style:{paddingLeft:8+fe},onClick:()=>ve({filename:xe.filename,docId:xe.docId},{nodeId:Q.nodeId,quote:de}),children:c.jsx("span",{children:Q.preview})},Q.nodeId)})})]}):A&&oe?c.jsxs("div",{className:"context-menu-link-picker",children:[c.jsxs("div",{className:"context-menu-link-header",children:["Linked from ",oe.entries.length," ",oe.entries.length===1?"place":"places"]}),c.jsx("div",{className:"context-menu-link-list",children:oe.entries.map((Q,de)=>{const fe=S.find(Ie=>Ie.docId===Q.from_doc),Je=(fe==null?void 0:fe.title)||Q.from_doc;return c.jsxs("button",{className:"context-menu-item",onClick:()=>{window.dispatchEvent(new CustomEvent("ow-navigate-to-link",{detail:{docId:Q.from_doc,nodeId:Q.from_node,filename:null,quote:null}})),s(!1),L(!1)},children:[c.jsx("span",{children:Je}),c.jsxs("span",{className:"context-menu-shortcut",children:['"',Q.text,'"']})]},`${Q.from_doc}-${Q.from_node}-${de}`)})})]}):k?c.jsxs("div",{className:"context-menu-link-picker",children:[c.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),_?c.jsxs("div",{className:"context-menu-custom",children:[c.jsx("input",{autoFocus:!0,value:I,onChange:Q=>$(Q.target.value),onKeyDown:Q=>{Q.key==="Enter"&&je(),Q.key==="Escape"&&R(!1)},placeholder:"New document title..."}),c.jsx("button",{onClick:je,children:"Create"})]}):c.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>R(!0),children:c.jsx("span",{children:"+ New link doc"})}),c.jsxs("div",{className:"context-menu-link-list",children:[T.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),S.filter(Q=>Nk(Q,T)).map(Q=>c.jsxs("div",{className:"context-menu-link-row",children:[c.jsx("button",{className:"context-menu-item context-menu-link-row__main",onClick:()=>ve(Q),children:c.jsx("span",{children:Q.title})}),Q.docId&&c.jsx("button",{className:"context-menu-link-row__drill",title:"Pick a paragraph in this doc",onClick:()=>te(Q),children:"▸"})]},`linked-${Q.filename}`))]}),c.jsx("div",{className:"context-menu-section-header",children:"All documents"}),S.filter(Q=>!Nk(Q,T)).map(Q=>c.jsxs("div",{className:"context-menu-link-row",children:[c.jsx("button",{className:"context-menu-item context-menu-link-row__main",onClick:()=>ve(Q),children:c.jsx("span",{children:Q.title})}),Q.docId&&c.jsx("button",{className:"context-menu-link-row__drill",title:"Pick a paragraph in this doc",onClick:()=>te(Q),children:"▸"})]},Q.filename)),S.length===0&&c.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const Q=gt();let de;return Q.map((fe,Je)=>{const Ie=fe.isPlugin&&fe.pluginDisplayName&&fe.pluginDisplayName!==de,it=de!==void 0;fe.isPlugin?de=fe.pluginDisplayName:de=void 0;const dt=!fe.isPlugin&&it;return c.jsxs("span",{children:[Ie&&c.jsx("div",{className:"context-menu-section-header",children:fe.pluginDisplayName}),dt&&c.jsx("div",{className:"context-menu-divider"}),c.jsxs("button",{className:"context-menu-item",onClick:()=>vt(fe),children:[c.jsx("span",{children:fe.label}),fe.shortcut&&c.jsx("span",{className:"context-menu-shortcut",children:fe.shortcut})]})]},fe.action)})})()}):null}const w$=80,Op=8,Xo=8,k$=400;function Ck(t){return t.nodeIds&&t.nodeIds.length>0?t.nodeIds:[t.nodeId]}function _k(t,e){const n=new Set(e);return t.every(r=>n.has(r))}function S$(t,e){const n=e.find(s=>s.id===t);if(!n)return[];const r=Ck(n);return e.filter(s=>{if(s.id===n.id)return!0;const i=Ck(s);return _k(i,r)||_k(r,i)}).sort((s,i)=>(s.createdAt||"").localeCompare(i.createdAt||""))}function E$({documentId:t}){const[e,n]=b.useState(null),[r,s]=b.useState({kind:"view"}),[i,o]=b.useState(""),[l,d]=b.useState(0),[f,h]=b.useState({left:0,top:0,placement:"above"}),m=b.useRef(null),g=b.useRef(null),v=b.useRef(null),x=b.useRef(null),k=b.useRef({kind:"view"});b.useEffect(()=>{x.current=e},[e]),b.useEffect(()=>{k.current=r},[r]),b.useEffect(()=>{const G=()=>d(B=>B+1);return window.addEventListener("ow-comments-changed",G),()=>window.removeEventListener("ow-comments-changed",G)},[]);const w=b.useCallback(()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),S=b.useCallback(()=>{w(),v.current=window.setTimeout(()=>{k.current.kind==="view"&&n(null)},w$)},[w]),N=b.useCallback(()=>{w(),n(null),s({kind:"view"}),o("")},[w]),T=b.useMemo(()=>e?S$(e.commentId,$u()):[],[e,l]);b.useEffect(()=>{e&&T.length===0&&N()},[e,T.length,N]),b.useLayoutEffect(()=>{if(!e)return;const G=m.current;if(!G)return;const B=G.getBoundingClientRect(),{rect:W}=e,K=W.top,ne=window.innerHeight-W.bottom,V=K>=B.height+Op||K>=ne?"above":"below",oe=V==="above"?Math.max(Xo,W.top-B.height-Op):Math.min(window.innerHeight-B.height-Xo,W.bottom+Op);let J=W.left;J+B.width>window.innerWidth-Xo&&(J=window.innerWidth-B.width-Xo),J<Xo&&(J=Xo),h({left:J,top:oe,placement:V})},[e,r,T.length,l]),b.useEffect(()=>{const G=ne=>{var J,A,L;const V=ne.target,oe=(J=V==null?void 0:V.closest)==null?void 0:J.call(V,"[data-comment-id]");if(oe){const ee=oe.getAttribute("data-comment-id");if(!ee)return;if(((A=x.current)==null?void 0:A.commentId)===ee){w();return}w(),s({kind:"view"}),o(""),n({commentId:ee,rect:oe.getBoundingClientRect()});return}if((L=m.current)!=null&&L.contains(V)){w();return}x.current&&S()},B=ne=>{var oe,J;const V=ne.relatedTarget;if(V&&((oe=m.current)!=null&&oe.contains(V))){w();return}V&&((J=V.closest)!=null&&J.call(V,"[data-comment-id]"))||x.current&&S()},W=ne=>{if(ne.key==="Escape"&&x.current){if(ne.preventDefault(),k.current.kind!=="view"){s({kind:"view"}),o("");return}N()}},K=ne=>{var V;x.current&&k.current.kind==="view"&&((V=m.current)!=null&&V.contains(ne.target)||N())};return document.addEventListener("mouseover",G),document.addEventListener("mouseout",B),document.addEventListener("keydown",W),document.addEventListener("scroll",K,!0),()=>{document.removeEventListener("mouseover",G),document.removeEventListener("mouseout",B),document.removeEventListener("keydown",W),document.removeEventListener("scroll",K,!0),w()}},[w,S,N]),b.useEffect(()=>{var G;r.kind!=="view"&&((G=g.current)==null||G.focus())},[r]);const M=b.useCallback(G=>{const B=$u().find(W=>W.id===G);B&&(o(B.note||""),s({kind:"edit",commentId:G}))},[]),_=b.useCallback(G=>{o(""),s({kind:"compose",parentCommentId:G})},[]),R=b.useCallback(()=>{s({kind:"view"}),o("")},[]),I=b.useCallback(()=>{r.kind!=="edit"||!t||fetch("/api/comments",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t,id:r.commentId,note:i.trim()})}).then(()=>{s({kind:"view"}),o("")}).catch(G=>console.error("[CommentPopover] Save failed:",G))},[r,t,i]),$=b.useCallback(()=>{if(r.kind!=="compose"||!t)return;const G=$u().find(B=>B.id===r.parentCommentId);G&&fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t,text:G.text,note:i.trim(),nodeId:G.nodeId,nodeIds:G.nodeIds})}).then(()=>{s({kind:"view"}),o("")}).catch(B=>console.error("[CommentPopover] Create failed:",B))},[r,t,i]),P=b.useCallback(G=>{fetch("/api/comments/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[G]})}).catch(B=>console.error("[CommentPopover] Resolve failed:",B))},[]),z=b.useCallback(G=>{fetch("/api/comments",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[G]})}).catch(B=>console.error("[CommentPopover] Delete failed:",B))},[]);if(!e||T.length===0)return null;const q=r.kind!=="view",F=r.kind==="compose"?"Adding a new comment on the same range":null;return c.jsx("div",{ref:m,className:`ow-comment-popover ow-comment-popover-${f.placement}`,style:{left:f.left,top:f.top,maxHeight:k$},onMouseEnter:w,onMouseLeave:S,children:q?c.jsxs(c.Fragment,{children:[F&&c.jsx("div",{className:"ow-comment-popover-empty",children:F}),c.jsx("textarea",{ref:g,className:"ow-comment-popover-textarea",value:i,onChange:G=>o(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.metaKey||G.ctrlKey)&&(G.preventDefault(),r.kind==="edit"?I():r.kind==="compose"&&$()),G.key==="Escape"&&(G.preventDefault(),R())},rows:4,placeholder:"Note for agent (optional)..."}),c.jsxs("div",{className:"ow-comment-popover-actions",children:[c.jsx("span",{className:"ow-comment-popover-hint",children:"⌘↵ to save · Esc to cancel"}),c.jsx("button",{className:"ow-icon-btn",onClick:r.kind==="edit"?I:$,title:"Save",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M20 6 9 17l-5-5"})})})]})]}):c.jsx("div",{className:"ow-comment-popover-stack",children:T.map((G,B)=>c.jsxs("div",{className:`ow-comment-popover-card${B>0?" ow-comment-popover-card-divider":""}`,children:[G.note?c.jsx("div",{className:"ow-comment-popover-text",children:G.note}):c.jsx("div",{className:"ow-comment-popover-empty",children:"No note"}),c.jsxs("div",{className:"ow-comment-popover-actions",children:[c.jsx("button",{className:"ow-icon-btn",onClick:()=>M(G.id),title:"Edit comment",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12 20h9"}),c.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}),c.jsx("button",{className:"ow-icon-btn",onClick:()=>_(G.id),title:"Add another comment on this range",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12 5v14"}),c.jsx("path",{d:"M5 12h14"})]})}),c.jsx("button",{className:"ow-icon-btn",onClick:()=>P(G.id),title:"Resolve (mark addressed)",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M20 6 9 17l-5-5"})})}),c.jsx("button",{className:"ow-icon-btn ow-icon-btn-danger",onClick:()=>z(G.id),title:"Delete (remove permanently)",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M18 6 6 18"}),c.jsx("path",{d:"m6 6 12 12"})]})})]})]},G.id))})})}function ku(t){return t.type==="doc"?t.file:t.id}function Ol(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&Ol(n.items,e)}function OT(t,e,n,r){for(const s of t){if(s.type==="doc"&&s.file===e)return n||r;if(s.type==="container"){const i=s.autoAccept===!0,o=OT(s.items,e,n,r||i);if(o!==null)return o}}return null}function Pd(t,e){for(const n of t){const r=n.workspace;if(!r)continue;const s=r.autoAccept===!0;if(OT(r.root,e,s,!1)===!0)return!0}return!1}function ga(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 Ws(t){return/^[A-Z]:[/\\]|^\//.test(t)}function IT(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function N$(t){const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=new Date(r.getTime()-864e5),i=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.getTime()===r.getTime()?"Today":i.getTime()===s.getTime()?"Yesterday":n.getTime()-i.getTime()<6048e5?e.toLocaleDateString(void 0,{weekday:"long"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function C$(t,e){const[n,r]=b.useState([]),[s,i]=b.useState([]),o=b.useRef(null),l=b.useRef(new Set),d=b.useCallback(g=>{l.current.add(g)},[]),f=b.useMemo(()=>{const g=new Set;for(const v of s)v.workspace&&Ol(v.workspace.root,g);return g},[s]),h=b.useCallback(()=>{fetch("/api/documents").then(g=>g.json()).then(g=>{if(!Array.isArray(g))return;const v=l.current;if(v.size>0){const k=new Set(g.map(w=>w.filename));for(const w of[...v])k.has(w)||v.delete(w)}const x=v.size>0?g.filter(k=>!v.has(k.filename)):g;r(x)}).catch(()=>{})},[]),m=b.useCallback(()=>{fetch("/api/workspaces").then(g=>g.json()).then(async g=>{if(!Array.isArray(g))return;const v=await Promise.all(g.map(async x=>{try{const w=await(await fetch(`/api/workspaces/${encodeURIComponent(x.filename)}`)).json();return{...x,workspace:w}}catch{return x}}));i(v)}).catch(()=>{})},[]);return b.useEffect(()=>{h()},[h,t]),b.useEffect(()=>{m()},[m,e]),{docs:n,setDocs:r,workspaces:s,setWorkspaces:i,assignedFiles:f,fetchDocs:h,fetchWorkspaces:m,scrollRef:o,markPendingDelete:d}}function Zg(t,e){return t.filter(n=>!e(n)).map(n=>n.type==="container"?{...n,items:Zg(n.items,e)}:n)}function LT(t,e,n){return t.map(r=>r.type==="container"&&r.id===e?{...r,name:n}:r.type==="container"?{...r,items:LT(r.items,e,n)}:r)}function _$(t,e,n,r,s,i){const o=b.useCallback(_=>{n(R=>R.filter(I=>I.filename!==_)),i==null||i(_),fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>t())},[n,t]),l=b.useCallback(_=>{n(R=>R.filter(I=>I.filename!==_)),fetch(`/api/documents/${encodeURIComponent(_)}/archive`,{method:"POST"}).catch(()=>t())},[n,t]),d=b.useCallback(_=>{n(R=>R.filter(I=>I.filename!==_)),fetch(`/api/documents/${encodeURIComponent(_)}/unarchive`,{method:"POST"}).catch(()=>t())},[n,t]),f=b.useCallback((_,R,I)=>{!I.trim()||I.trim()===R||(n($=>$.map(P=>P.filename===_?{...P,title:I.trim()}:P)),fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:I.trim()})}).catch(()=>t()))},[n,t]),h=b.useCallback(_=>{r(R=>R.filter(I=>I.filename!==_)),fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>e())},[r,e]),m=b.useCallback((_,R)=>{R.trim()&&(r(I=>I.map($=>$.filename===_?{...$,title:R.trim()}:$)),fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:R.trim()})}).catch(()=>e()))},[r,e]),g=b.useCallback((_,R)=>{r(I=>I.map($=>$.filename!==_||!$.workspace?$:{...$,docCount:Math.max(0,$.docCount-1),workspace:{...$.workspace,root:Zg($.workspace.root,P=>P.type==="doc"&&P.file===R)}})),fetch(`/api/workspaces/${encodeURIComponent(_)}/docs/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>e())},[r,e]),v=b.useCallback((_,R,I=!1)=>{r(P=>P.map(z=>z.filename!==_||!z.workspace?z:{...z,workspace:{...z.workspace,root:Zg(z.workspace.root,q=>q.type==="container"&&q.id===R)}}));const $=`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(R)}${I?"?cascade=true":""}`;fetch($,{method:"DELETE"}).then(()=>{I&&t()}).catch(()=>e())},[r,e,t]),x=b.useCallback((_,R,I)=>{I.trim()&&(r($=>$.map(P=>P.filename!==_||!P.workspace?P:{...P,workspace:{...P.workspace,root:LT(P.workspace.root,R,I.trim())}})),fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(R)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:I.trim()})}).catch(()=>e()))},[r,e]),k=b.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),w=b.useCallback((_,R,I)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(I?{metadata:I}:{})}).then($=>$.json()).then($=>{if($.filename)return fetch(`/api/workspaces/${encodeURIComponent(_)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:$.filename,title:$.title||"Untitled",containerId:R})})}).catch(()=>{})},[]),S=b.useCallback((_,R)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:R})}).catch(()=>{})},[]),N=b.useCallback(_=>{const R=s.find(I=>I.filename===_);return(R==null?void 0:R.tags)??[]},[s]),T=b.useCallback((_,R)=>{const I=R.trim();I&&(n($=>$.map(P=>{if(P.filename!==_)return P;const z=P.tags??[];return z.includes(I)?P:{...P,tags:[...z,I]}})),fetch(`/api/doc-tags/${encodeURIComponent(_)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:I})}).catch(()=>{}))},[n]),M=b.useCallback((_,R)=>{n(I=>I.map($=>{if($.filename!==_)return $;const P=$.tags??[],z=P.filter(q=>q!==R);return z.length===P.length?$:z.length>0?{...$,tags:z}:{...$,tags:void 0}})),fetch(`/api/doc-tags/${encodeURIComponent(_)}/${encodeURIComponent(R)}`,{method:"DELETE"}).catch(()=>{})},[n]);return{fetchDocs:t,handleDelete:o,handleArchive:l,handleUnarchive:d,handleRename:f,handleCreateWorkspace:k,handleDeleteWorkspace:h,handleCreateInWorkspace:w,handleRemoveFromWorkspace:g,handleCreateContainer:S,handleDeleteContainer:v,handleRenameContainer:x,handleRenameWorkspace:m,getDocTags:N,handleAddTag:T,handleRemoveTag:M}}function DT({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,o]=b.useState(null),[l,d]=b.useState(null),f=b.useRef(null),h=b.useRef(null),m=b.useRef(null),g=b.useRef(null),v=b.useRef(null),x=5,k=(z,q,F)=>F==="before"?q>0?ku(z[q-1]):null:ku(z[q]),w=b.useCallback((z,q)=>{if(q===null){const B=t.filter(K=>!n.has(K.filename)).map(K=>({type:"doc",file:K.filename,title:K.title})),W=B.findIndex(K=>ku(K)===z);return W>=0?{siblings:B,index:W,containerId:null}:null}const F=e.find(B=>B.filename===q);if(!(F!=null&&F.workspace))return null;const G=(B,W)=>{for(let K=0;K<B.length;K++){if(ku(B[K])===z)return{siblings:B,index:K,containerId:W};if(B[K].type==="container"){const ne=G(B[K].items,B[K].id);if(ne)return ne}}return null};return G(F.workspace.root,null)},[t,n,e]),S=b.useCallback(()=>{o(null),d(null),v.current=null,g.current=null,m.current&&(m.current.remove(),m.current=null),f.current&&(clearTimeout(f.current),f.current=null),h.current&&(cancelAnimationFrame(h.current),h.current=null),document.body.style.userSelect=""},[]),N=b.useCallback((z,q)=>{if(!z||!q)return;if(z.type==="workspace"){const V=q.itemId;if(V===z.filename)return;const oe=e.map(L=>L.filename),J=oe.indexOf(z.filename);if(J<0)return;oe.splice(J,1);let A=oe.indexOf(V);if(A<0)return;q.position==="after"&&(A+=1),oe.splice(A,0,z.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:oe})}).catch(()=>{});return}const{wsFilename:F,containerId:G,afterId:B}=q,W=z.type==="doc"?z.file:z.id,K=z.sourceWs;if(q.itemId===W)return;if(z.type==="container"){if(F===null&&G===null&&q.itemId!=="__section__"){const V=q.itemId,oe=q.position==="after"?V:(()=>{const J=e.findIndex(A=>A.filename===V);return J>0?e[J-1].filename:null})();fetch("/api/workspaces/promote-container",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:K,containerId:W,afterWorkspaceFilename:oe})}).catch(()=>{});return}if(K!==F&&F){fetch(`/api/workspaces/${encodeURIComponent(F)}/containers/${encodeURIComponent(W)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:K,targetContainerId:G??null,afterIdentifier:B})}).catch(()=>{});return}if(!F)return;fetch(`/api/workspaces/${encodeURIComponent(F)}/docs/${encodeURIComponent(W)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:G??null,afterFile:B})}).catch(()=>{});return}const ne=z.file;if(K===null&&F===null){const V=t.filter(ee=>!n.has(ee.filename)).map(ee=>ee.filename),oe=V.indexOf(ne);if(oe<0)return;V.splice(oe,1);let J=B?V.indexOf(B):-1;J>=0?J+=1:J=0,V.splice(J,0,ne);const A=[];let L=0;for(const ee of t)n.has(ee.filename)?A.push(ee.filename):A.push(V[L++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:A})}).catch(()=>{});return}if(K===null&&F!==null){fetch(`/api/workspaces/${encodeURIComponent(F)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:ne,title:ne.replace(/\.md$/,""),containerId:G??null,afterFile:B})}).catch(()=>{});return}if(K!==null&&F===null){fetch(`/api/workspaces/${encodeURIComponent(K)}/docs/${encodeURIComponent(ne)}`,{method:"DELETE"}).catch(()=>{});return}if(K===F&&F!==null){fetch(`/api/workspaces/${encodeURIComponent(F)}/docs/${encodeURIComponent(ne)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:G??null,afterFile:B})}).catch(()=>{});return}K!==null&&F!==null&&fetch(`/api/workspaces/${encodeURIComponent(F)}/docs/${encodeURIComponent(ne)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:K,containerId:G??null,afterFile:B,title:ne.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),T=b.useCallback((z,q)=>{const F=m.current;F&&(F.style.display="none");const G=document.elementFromPoint(z,q);if(F&&(F.style.display=""),!G)return null;if((i==null?void 0:i.type)==="workspace"||(i==null?void 0:i.type)==="container"){const ee=G.closest("[data-ws-drag]");if(ee){const pe=ee.dataset.wsDrag,xe=ee.getBoundingClientRect(),re=(q-xe.top)/xe.height;return{itemId:pe,position:re<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}if((i==null?void 0:i.type)==="workspace")return null}if((i==null?void 0:i.type)==="doc"){const ee=G.closest("[data-ws-drag]");if(ee)return{itemId:"__section__",position:"inside",wsFilename:ee.dataset.wsDrag,containerId:null,afterId:null}}const B=G.closest("[data-drag-id]");if(!B){const ee=G.closest("[data-drop-ws]");return ee?{itemId:"__section__",position:"inside",wsFilename:ee.dataset.dropWs==="__docs__"?null:ee.dataset.dropWs,containerId:ee.dataset.dropContainer||null,afterId:null}:null}const W=B.dataset.dragId,K=B.dataset.dragType,ne=B.dataset.dragWs==="__docs__"?null:B.dataset.dragWs,V=B.getBoundingClientRect(),oe=(q-V.top)/V.height;if(K==="container-header"){const ee=W,pe=B.dataset.dragParent||null,xe=w(ee,ne);if(!xe)return null;const re=(i==null?void 0:i.type)==="container"?.33:.25;return oe<re?{itemId:ee,position:"before",wsFilename:ne,containerId:pe,afterId:k(xe.siblings,xe.index,"before")}:oe>1-re?{itemId:ee,position:"after",wsFilename:ne,containerId:pe,afterId:k(xe.siblings,xe.index,"after")}:{itemId:ee,position:"inside",wsFilename:ne,containerId:ee,afterId:null}}const J=B.dataset.dragContainer||null,A=w(W,ne);if(!A)return null;const L=oe<.5?"before":"after";return{itemId:W,position:L,wsFilename:ne,containerId:J,afterId:k(A.siblings,A.index,L)}},[w,i]),M=b.useCallback(z=>{const q=r.current;if(!q)return;const F=q.getBoundingClientRect(),G=80,B=18;let W=0;if(z<F.top+G?W=-B*Math.max(0,1-(z-F.top)/G):z>F.bottom-G&&(W=B*Math.max(0,1-(F.bottom-z)/G)),h.current&&(cancelAnimationFrame(h.current),h.current=null),W!==0){const K=()=>{q.scrollTop+=W,h.current=requestAnimationFrame(K)};h.current=requestAnimationFrame(K)}},[r]),_=b.useCallback((z,q)=>{const F=m.current;F&&(F.style.display="none");const G=document.elementFromPoint(z,q);F&&(F.style.display="");const B=G==null?void 0:G.closest("[data-section-key]");if(!B){f.current&&(clearTimeout(f.current),f.current=null);return}const W=B.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(K=>{if(!K.has(W))return K;const ne=new Set(K);return ne.delete(W),ne})},500)},[s]);b.useEffect(()=>{if(!i)return;const z=F=>{m.current&&(m.current.style.left=`${F.clientX+12}px`,m.current.style.top=`${F.clientY-8}px`),d(T(F.clientX,F.clientY)),M(F.clientY),_(F.clientX,F.clientY)},q=F=>{N(i,T(F.clientX,F.clientY)),S()};return window.addEventListener("pointermove",z),window.addEventListener("pointerup",q),()=>{window.removeEventListener("pointermove",z),window.removeEventListener("pointerup",q)}},[i,T,N,S,M,_]);const R=b.useCallback((z,q,F)=>{if(z.button!==0||z.target.closest("input, button, .sidebar-tag-remove, .sidebar-tag-add, .sidebar-container-actions, .sidebar-delete-btn, .sidebar-confirm-delete, .sidebar-inline-confirm"))return;g.current={x:z.clientX,y:z.clientY},v.current=q;const B=K=>{if(!g.current||!v.current)return;const ne=K.clientX-g.current.x,V=K.clientY-g.current.y;if(Math.abs(ne)+Math.abs(V)>=x){document.body.style.userSelect="none",window.removeEventListener("pointermove",B),window.removeEventListener("pointerup",W),o(v.current),v.current=null;const oe=document.createElement("div");oe.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);",oe.textContent=F,document.body.appendChild(oe),m.current=oe,oe.style.left=`${K.clientX+12}px`,oe.style.top=`${K.clientY-8}px`}},W=()=>{window.removeEventListener("pointermove",B),window.removeEventListener("pointerup",W),g.current=null,v.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",B),window.addEventListener("pointerup",W)},[]);return{draggedItem:i,dropIndicator:l,handlePointerDown:R,dropClass:z=>!l||l.itemId!==z?"":l.position==="before"?"drop-before":l.position==="after"?"drop-after":l.position==="inside"?"drop-inside":"",isDragging:z=>i?i.type==="doc"?i.file===z:i.type==="workspace"?i.filename===z:i.id===z:!1,isContainerDropTarget:z=>!l||!i?!1:l.containerId===z}}function Ul(t,e,n,r){var h;const s=b.useRef(e);s.current=e;const i=b.useRef(r);i.current=r;const o=b.useRef(null),l=b.useRef(null),d=b.useCallback(m=>{var v,x;const g=m||((v=s.current.find(k=>k.isActive))==null?void 0:v.filename);g&&((x=i.current)==null||x.call(i,g),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{const k=t.current;if(!k)return;const w=k.querySelector(`[data-drag-id="${CSS.escape(g)}"]`)||k.querySelector(".active");if(!w||w.offsetParent===null)return;const S=o.current===g,N=w.getBoundingClientRect(),T=k.getBoundingClientRect(),M=N.top<T.top||N.bottom>T.bottom;if(S||M){const _=N.top-T.top-(T.height/2-N.height/2);k.scrollTop+=_}S&&(o.current=null,w.classList.remove("reveal-pulse"),w.offsetWidth,w.classList.add("reveal-pulse"),setTimeout(()=>w.classList.remove("reveal-pulse"),1200))},60))},[t]),f=(h=e.find(m=>m.isActive))==null?void 0:h.filename;b.useEffect(()=>{d(f)},[f,n,d]),b.useEffect(()=>{const m=g=>{var x,k;const v=((x=g.detail)==null?void 0:x.filename)||((k=s.current.find(w=>w.isActive))==null?void 0:k.filename);v&&(o.current=v,d(v))};return window.addEventListener("ow-reveal-active-doc",m),()=>window.removeEventListener("ow-reveal-active-doc",m)},[d]),b.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[])}const T$=[{key:"document",label:"Document"},{key:"tweet",label:"Tweet"},{key:"article",label:"Article"},{key:"linkedin",label:"LinkedIn"},{key:"newsletter",label:"Newsletter"},{key:"blog",label:"Blog"}];function j$({onPick:t}){const[e,n]=b.useState(!1),r=b.useRef(null),s=b.useRef(null),[i,o]=b.useState({});return b.useLayoutEffect(()=>{if(!e||!r.current||!s.current)return;const l=s.current.getBoundingClientRect(),d=r.current.getBoundingClientRect(),f=8;let h=l.right-4,m=l.top-4;h+d.width+f>window.innerWidth&&(h=l.left-d.width+4),m+d.height+f>window.innerHeight&&(m=window.innerHeight-d.height-f),m<f&&(m=f),o({position:"fixed",left:h,top:m})},[e]),c.jsxs("span",{onMouseLeave:()=>n(!1),children:[c.jsx("div",{className:"context-menu-divider"}),c.jsxs("button",{ref:s,className:"context-menu-item context-menu-submenu-trigger",onMouseEnter:()=>n(!0),onClick:()=>n(l=>!l),children:[c.jsx("span",{children:"Create variant"}),c.jsx("span",{className:"context-menu-submenu-arrow",children:"▸"})]}),e&&c.jsx("div",{ref:r,className:"context-menu context-menu-submenu",style:i,children:T$.map(l=>c.jsx("button",{className:"context-menu-item",onClick:()=>t(l.key),children:c.jsx("span",{children:l.label})},l.key))})]})}function Tk({items:t,onAction:e}){const[n,r]=b.useState(null),s=b.useRef(null),i=b.useRef({}),o=b.useMemo(()=>{const h=new Map;for(const m of t){const g=m.pluginDisplayName||"_ungrouped",v=h.get(g)||[];v.push(m),h.set(g,v)}return h},[t]),[l,d]=b.useState({});b.useLayoutEffect(()=>{const h=n?i.current[n]:null;if(!n||!s.current||!h)return;const m=h.getBoundingClientRect(),g=s.current.getBoundingClientRect(),v=8;let x=m.right-4,k=m.top-4;x+g.width+v>window.innerWidth&&(x=m.left-g.width+4),k+g.height+v>window.innerHeight&&(k=window.innerHeight-g.height-v),k<v&&(k=v),d({position:"fixed",left:x,top:k})},[n]);const f=[];for(const[h,m]of o)if(h!=="_ungrouped"&&m.length>=3)f.push(c.jsxs("span",{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsxs("button",{ref:g=>{i.current[h]=g},className:"context-menu-item context-menu-submenu-trigger",onMouseEnter:()=>r(h),onClick:()=>r(n===h?null:h),children:[c.jsx("span",{children:"Transform"}),c.jsx("span",{className:"context-menu-submenu-arrow",children:"▸"})]}),n===h&&c.jsx("div",{ref:s,className:"context-menu context-menu-submenu",style:l,onMouseLeave:()=>r(null),children:m.map(g=>c.jsx("button",{className:"context-menu-item",onClick:()=>e(g),children:c.jsx("span",{children:g.label})},g.action))})]},`sub-${h}`));else{let g=!0;for(const v of m){const x=g&&h!=="_ungrouped";g=!1,f.push(c.jsxs("span",{children:[x&&c.jsx("div",{className:"context-menu-divider"}),x&&c.jsx("div",{className:"context-menu-section-header",children:h}),c.jsx("button",{className:"context-menu-item",onClick:()=>e(v),children:c.jsx("span",{children:v.label})})]},v.action))}}return c.jsx(c.Fragment,{children:f})}function Bd({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onCreateVariant:o,onRename:l,onArchive:d,onDelete:f,onPluginAction:h,pluginItems:m,onSchedulePost:g,onPostNow:v,isAlreadyPublished:x,onViewAnalytics:k,viewAnalyticsLabel:w,onMarkSent:S,isAlreadySent:N,isApproved:T,onToggleApprove:M,isAutoAccept:_,onToggleAutoAccept:R,sortState:I,sortProposalLabel:$,sortProposalReasoning:P,onRequestSort:z,onCancelSort:q,onAcceptSortProposal:F,onRejectSortProposal:G,folderMode:B,onNewDoc:W,onNewContainer:K,onAcceptAll:ne,onRejectAll:V,folderAutoAccept:oe,onToggleFolderAutoAccept:J,folderAutoAcceptLabel:A,onRequestSortAll:L,folderDocCount:ee,onDeleteWithDocs:pe,bulkCount:xe,onBulkDelete:re,onBulkRequestSort:Ne}){const ke=b.useRef(null),[ze,Fe]=b.useState(!1),[Ge,Re]=b.useState(!1),[Ze,gt]=b.useState({left:t,top:e});b.useLayoutEffect(()=>{const ge=ke.current;if(!ge)return;const vt=ge.getBoundingClientRect(),_t=8;let Et=t,Dt=e;e+vt.height+_t>window.innerHeight&&(Dt=e-vt.height),t+vt.width+_t>window.innerWidth&&(Et=t-vt.width),Dt<_t&&(Dt=_t),Et<_t&&(Et=_t),gt({left:Et,top:Dt})},[t,e]),b.useEffect(()=>{const ge=vt=>{ke.current&&!ke.current.contains(vt.target)&&s()};return document.addEventListener("mousedown",ge),()=>document.removeEventListener("mousedown",ge)},[s]),b.useEffect(()=>{const ge=vt=>{vt.key==="Escape"&&s()};return document.addEventListener("keydown",ge),()=>document.removeEventListener("keydown",ge)},[s]);const ht=b.useCallback(ge=>{h(ge.action,ge),s()},[h,s]);return xe&&xe>1&&re?c.jsxs("div",{ref:ke,className:"context-menu",style:{left:Ze.left,top:Ze.top},children:[c.jsxs("div",{className:"context-menu-section-header",children:[xe," selected"]}),Ne&&c.jsx("button",{className:"context-menu-item",onClick:()=>{Ne(),s()},children:c.jsxs("span",{children:["Request sort (",xe,")"]})}),ze?c.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:ge=>ge.stopPropagation(),children:[c.jsxs("span",{children:["Delete ",xe,"?"]}),c.jsx("button",{onClick:()=>{re(),s()},children:"Yes"}),c.jsx("button",{onClick:()=>Fe(!1),children:"No"})]}):c.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>Fe(!0),children:c.jsxs("span",{children:["Delete (",xe,")"]})})]}):B?c.jsxs("div",{ref:ke,className:"context-menu",style:{left:Ze.left,top:Ze.top},children:[c.jsx("button",{className:"context-menu-item",onClick:()=>{l(),s()},children:c.jsx("span",{children:"Rename"})}),W&&c.jsx("button",{className:"context-menu-item",onClick:ge=>{W(ge),s()},children:c.jsx("span",{children:"New Document"})}),K&&c.jsx("button",{className:"context-menu-item",onClick:()=>{K(),s()},children:c.jsx("span",{children:"New Container"})}),(ne||V)&&c.jsx("div",{className:"context-menu-divider"}),ne&&c.jsx("button",{className:"context-menu-item",onClick:()=>{ne(),s()},children:c.jsx("span",{children:"Accept All Changes"})}),V&&c.jsx("button",{className:"context-menu-item",onClick:()=>{V(),s()},children:c.jsx("span",{children:"Reject All Changes"})}),J&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{J(),s()},children:c.jsx("span",{children:oe?`Turn off auto-accept${A?" "+A:""}`:`Turn on auto-accept${A?" "+A:""}`})})]}),L&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{L(),s()},children:c.jsx("span",{children:"Request sort all"})})]}),m.length>0&&c.jsx(Tk,{items:m,onAction:ht}),c.jsx("div",{className:"context-menu-divider"}),ze?ee&&ee>0&&pe?c.jsxs("div",{className:"sidebar-ctx-folder-delete",onClick:ge=>ge.stopPropagation(),children:[c.jsx("div",{className:"sidebar-ctx-folder-delete-prompt",children:"Delete this folder?"}),c.jsxs("button",{className:"context-menu-item sidebar-ctx-delete-option",onClick:()=>{f(),s()},children:[c.jsx("span",{children:"Folder only"}),c.jsxs("span",{className:"sidebar-ctx-delete-hint",children:[ee," doc",ee===1?"":"s"," → Documents"]})]}),c.jsxs("button",{className:"context-menu-item sidebar-ctx-delete-option sidebar-ctx-delete",onClick:()=>{pe(),s()},children:[c.jsxs("span",{children:["Folder + ",ee," doc",ee===1?"":"s"]}),c.jsx("span",{className:"sidebar-ctx-delete-hint",children:"permanently deletes files"})]}),c.jsx("button",{className:"context-menu-item sidebar-ctx-delete-cancel",onClick:()=>Fe(!1),children:c.jsx("span",{children:"Cancel"})})]}):c.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:ge=>ge.stopPropagation(),children:[c.jsx("span",{children:"Delete?"}),c.jsx("button",{onClick:()=>{f(),s()},children:"Yes"}),c.jsx("button",{onClick:()=>Fe(!1),children:"No"})]}):c.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>Fe(!0),children:c.jsx("span",{children:"Delete"})})]}):c.jsxs("div",{ref:ke,className:"context-menu",style:{left:Ze.left,top:Ze.top},children:[c.jsx("button",{className:"context-menu-item",onClick:()=>{i(),s()},children:c.jsx("span",{children:"Duplicate"})}),o&&c.jsx(j$,{onPick:ge=>{o(ge),s()}}),c.jsx("button",{className:"context-menu-item",onClick:()=>{l(),s()},children:c.jsx("span",{children:"Rename"})}),Ge?c.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:ge=>ge.stopPropagation(),children:[c.jsx("span",{children:"Archive?"}),c.jsx("button",{onClick:()=>{d(),s()},children:"Yes"}),c.jsx("button",{onClick:()=>Re(!1),children:"No"})]}):c.jsx("button",{className:"context-menu-item",onClick:()=>Re(!0),children:c.jsx("span",{children:"Archive"})}),ze?c.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:ge=>ge.stopPropagation(),children:[c.jsx("span",{children:Ws(n)?"Remove?":"Delete?"}),c.jsx("button",{onClick:()=>{f(),s()},children:"Yes"}),c.jsx("button",{onClick:()=>Fe(!1),children:"No"})]}):c.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>Fe(!0),children:c.jsx("span",{children:Ws(n)?"Remove":"Delete"})}),M&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{M(),s()},children:c.jsx("span",{children:T?"Remove Approval":"Approve"})})]}),R&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{R(),s()},children:c.jsx("span",{children:_?"Turn off auto-accept":"Turn on auto-accept"})})]}),I==="proposal"&&F&&G&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsxs("div",{className:"sidebar-ctx-sort-proposal",onClick:ge=>ge.stopPropagation(),children:[c.jsxs("div",{className:"sidebar-ctx-sort-proposal-label",children:["Sort to ",$]}),P&&c.jsx("div",{className:"sidebar-ctx-sort-proposal-reason",children:P}),c.jsxs("div",{className:"sidebar-ctx-sort-proposal-actions",children:[c.jsx("button",{onClick:()=>{F(),s()},children:"Accept"}),c.jsx("button",{onClick:()=>{G(),s()},children:"Reject"})]})]})]}),I==="pending"&&q&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsxs("div",{className:"sidebar-ctx-sort-pending",onClick:ge=>ge.stopPropagation(),children:[c.jsx("span",{className:"sidebar-ctx-sort-pending-label",children:"Sort requested"}),c.jsx("button",{onClick:()=>{q(),s()},children:"Cancel"})]})]}),I==="none"&&z&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{z(),s()},children:c.jsx("span",{children:"Request sort"})})]}),g&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{g(),s()},children:c.jsx("span",{children:"Schedule Post"})})]}),v&&c.jsx("button",{className:"context-menu-item",onClick:()=>{v(),s()},children:c.jsx("span",{children:x?"Republish to Blog":"Post to Blog Now"})}),S&&!N&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{S(),s()},children:c.jsx("span",{children:"Mark as Sent"})})]}),k&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"context-menu-divider"}),c.jsx("button",{className:"context-menu-item",onClick:()=>{k(),s()},children:c.jsx("span",{children:w||"View Analytics"})})]}),m.length>0&&c.jsx(Tk,{items:m,onAction:ht})]})}const jk=5e3;function PT(t,e){return!t.promptForFocus||!e?!1:e.wordCount>jk?(ji(`Document too large to transform: ${e.wordCount.toLocaleString()} words (max ${jk.toLocaleString()}). Trim it down first.`,"error"),!0):!1}function BT({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=b.useState(""),o=b.useRef(null);b.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]),b.useEffect(()=>{const d=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const l=b.useCallback(()=>{n(s.trim())},[s,n]);return c.jsx("div",{className:"focus-modal-overlay",onClick:r,children:c.jsxs("div",{className:"focus-modal",onClick:d=>d.stopPropagation(),children:[c.jsxs("div",{className:"focus-modal-header",children:[c.jsx("h2",{children:t}),c.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),c.jsxs("div",{className:"focus-modal-body",children:[c.jsxs("label",{children:['Focus instructions for "',e,'"',c.jsx("textarea",{ref:o,value:s,onChange:d=>i(d.target.value.slice(0,500)),placeholder:"Optional: guide the transformation (e.g. 'focus on the intro section', 'keep it professional')...",onKeyDown:d=>{d.key==="Enter"&&(d.ctrlKey||d.metaKey)&&l()}})]}),c.jsxs("div",{className:"focus-modal-hint",children:[s.length,"/500"]}),c.jsxs("div",{className:"focus-modal-actions",children:[c.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),c.jsx("button",{className:"focus-modal-btn primary",onClick:l,children:"Go"})]})]})]})})}function Ip(t,e){if(!e)return[t];const n=[],r=t.toLowerCase(),s=e.toLowerCase();let i=0;for(;i<t.length;){const o=r.indexOf(s,i);if(o===-1){n.push(t.slice(i));break}o>i&&n.push(t.slice(i,o)),n.push(c.jsx("mark",{children:t.slice(o,o+e.length)},o)),i=o+e.length}return n}function Mk({r:t,query:e,onClick:n}){return c.jsxs("div",{className:`sidebar-item search-result-item ${t.isActive?"active":""} ${t.isArchived?"search-result-archived":""}`,onClick:n,children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-item-title-text",children:t.matchType==="title"?Ip(t.title,e):t.title}),t.isArchived&&c.jsx("span",{className:"search-archived-badge",children:"archived"})]}),t.matchType==="tag"&&t.matchedTag&&c.jsxs("div",{className:"search-result-tag",children:["Tag: ",Ip(t.matchedTag,e)]}),t.matchType==="content"&&t.snippet&&c.jsx("div",{className:"search-result-snippet",children:Ip(t.snippet,e)}),c.jsxs("div",{className:"sidebar-item-meta",children:[t.wordCount.toLocaleString()," words · ",ga(t.lastModified)]})]})}function rf({results:t,query:e,onSwitchDocument:n,actions:r}){if(t.length===0)return c.jsx("div",{className:"sidebar-scroll",children:c.jsxs("div",{className:"search-empty",children:['No results for "',e,'"']})});const s=t.filter(o=>!o.isArchived),i=t.filter(o=>o.isArchived);return c.jsx("div",{className:"sidebar-scroll",children:c.jsxs("div",{className:"search-results",children:[s.map(o=>c.jsx(Mk,{r:o,query:e,onClick:()=>n(o.filename)},o.filename)),i.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"search-archived-divider",children:c.jsx("span",{children:"Archived"})}),i.map(o=>c.jsx(Mk,{r:o,query:e,onClick:()=>r.handleUnarchive(o.filename)},o.filename))]})]})})}async function Lp(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();return(i=(s=r.content)==null?void 0:s[0])!=null&&i.text?JSON.parse(r.content[0].text):r}function Dp(t,e){return e?(t/e*100).toFixed(1)+"%":"0%"}function Ak(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Rk(t,e=50){try{const n=new URL(t),r=n.hostname+n.pathname+n.search;return r.length>e?r.slice(0,e)+"...":r}catch{return t.length>e?t.slice(0,e)+"...":t}}function $T({docId:t,title:e,onClose:n}){const[r,s]=b.useState("loading"),[i,o]=b.useState([]),[l,d]=b.useState(""),[f,h]=b.useState(null),[m,g]=b.useState(null),[v,x]=b.useState("links"),[k,w]=b.useState("all"),[S,N]=b.useState(!1),[T,M]=b.useState(!1),[_,R]=b.useState(""),[I,$]=b.useState(!1),[P,z]=b.useState(null),q=b.useRef(null);b.useEffect(()=>{let re=!1;return(async()=>{try{const Ne=await Lp("list_newsletter_issues",{limit:20});if(re)return;if(!Ne.issues||Ne.issues.length===0){s("no-data");return}o(Ne.issues);const ke=Ne.issues[0].id;d(ke)}catch(Ne){re||(g(Ne.message),s("error"))}})(),()=>{re=!0}},[]),b.useEffect(()=>{if(!l)return;let re=!1;return N(!0),M(!1),z(null),R(""),(async()=>{try{const Ne=await Lp("get_newsletter_analytics",{issue_id:l});if(re)return;if(Ne.error){g(Ne.error),s("error");return}h(Ne),s("loaded")}catch(Ne){re||(g(Ne.message),s("error"))}finally{re||N(!1)}})(),()=>{re=!0}},[l]),b.useEffect(()=>{const re=Ne=>{q.current&&!q.current.contains(Ne.target)&&n()};return document.addEventListener("mousedown",re),()=>document.removeEventListener("mousedown",re)},[n]),b.useEffect(()=>{const re=Ne=>{Ne.key==="Escape"&&n()};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[n]);const F=f?A$(f.subscriber_events):[],G=(f==null?void 0:f.issue.recipient_count)??0,B=f?f.stats.delivered||G-f.stats.bounces:0,W=f?new Set(f.subscriber_events.filter(re=>{var Ne;return re.event_type==="click"&&((Ne=re.url)==null?void 0:Ne.includes("/newsletter/unsubscribe/"))}).map(re=>re.email)).size:0,K=f?f.stats.unsubscribes||W:0,ne=f?f.subscriber_events.filter(re=>re.event_type==="dropped").length:0,V=f?Math.max(0,G-f.stats.unique_opens):0,oe=f!=null&&f.issue.sent_at?Date.now()-new Date(f.issue.sent_at).getTime():0,J=Math.floor(oe/36e5),A=!!(f!=null&&f.issue.resent_at||P),L=re=>{const Ne=Math.floor(re/36e5);return Ne<1?"just now":Ne<24?`${Ne}h ago`:`${Math.floor(Ne/24)}d ${Ne%24}h ago`},ee=async()=>{if(!(!_.trim()||I)){$(!0);try{const re=await Lp("resend_to_unopened",{issue_id:l,subject:_});re.error?(g(re.error),s("error")):(z({sent:re.sent,failed:re.failed}),M(!1))}catch(re){g(re.message),s("error")}finally{$(!1)}}},pe=re=>{var Ne;return re.event_type==="unsubscribe"||re.event_type==="click"&&!!((Ne=re.url)!=null&&Ne.includes("/newsletter/unsubscribe/"))},xe=f?M$(f.subscriber_events.filter(re=>k==="all"?!0:k==="unsubscribe"?pe(re):re.event_type===k)):[];return c.jsx("div",{className:"newsletter-modal-overlay",children:c.jsxs("div",{className:"na-modal",ref:q,children:[c.jsxs("div",{className:"na-header",children:[c.jsx("h3",{children:"Newsletter Analytics"}),c.jsx("button",{className:"newsletter-modal__close",onClick:n,children:"×"})]}),r==="loading"&&!f&&c.jsx("div",{className:"na-body",children:c.jsxs("div",{className:"newsletter-modal__status",children:[c.jsx("div",{className:"newsletter-modal__spinner"}),c.jsx("span",{children:"Loading analytics..."})]})}),r==="no-data"&&c.jsxs("div",{className:"na-body",children:[c.jsx("div",{className:"newsletter-modal__status",children:c.jsx("span",{children:"No newsletter sends found yet."})}),c.jsx("div",{className:"newsletter-modal__actions",children:c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="error"&&c.jsxs("div",{className:"na-body",children:[c.jsx("div",{className:"newsletter-modal__error",children:m}),c.jsx("div",{className:"newsletter-modal__actions",children:c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="loaded"&&f&&c.jsxs("div",{className:"na-body",children:[i.length>1&&c.jsx("select",{className:"newsletter-modal__select na-issue-select",value:l,onChange:re=>d(re.target.value),children:i.map(re=>c.jsxs("option",{value:re.id,children:[re.subject," — ",Ak(re.sent_at)]},re.id))}),S?c.jsxs("div",{className:"newsletter-modal__status",children:[c.jsx("div",{className:"newsletter-modal__spinner"}),c.jsx("span",{children:"Loading..."})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"na-kpi-row",children:[c.jsxs("div",{className:"na-kpi",children:[c.jsx("div",{className:"na-kpi__value",children:B.toLocaleString()}),c.jsx("div",{className:"na-kpi__label",children:"Delivered"}),c.jsxs("div",{className:"na-kpi__sub",children:[G.toLocaleString()," sent"]})]}),c.jsxs("div",{className:"na-kpi",children:[c.jsx("div",{className:"na-kpi__value",children:Dp(f.stats.unique_opens,B)}),c.jsx("div",{className:"na-kpi__label",children:"Open rate"}),c.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_opens.toLocaleString()," opens"]})]}),c.jsxs("div",{className:"na-kpi",children:[c.jsx("div",{className:"na-kpi__value",children:Dp(f.stats.unique_clicks,B)}),c.jsx("div",{className:"na-kpi__label",children:"Click rate"}),c.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_clicks.toLocaleString()," clicks"]})]})]}),c.jsxs("div",{className:"na-kpi-row na-kpi-row--secondary",children:[c.jsxs("div",{className:"na-kpi na-kpi--sm",children:[c.jsx("span",{className:"na-kpi__value--sm",children:f.stats.bounces}),c.jsx("span",{className:"na-kpi__label--sm",children:"Bounces"})]}),c.jsxs("div",{className:"na-kpi na-kpi--sm",children:[c.jsx("span",{className:"na-kpi__value--sm",children:K}),c.jsx("span",{className:"na-kpi__label--sm",children:"Unsubs"})]}),c.jsxs("div",{className:"na-kpi na-kpi--sm",children:[c.jsx("span",{className:"na-kpi__value--sm",children:ne}),c.jsx("span",{className:"na-kpi__label--sm",children:"Dropped"})]}),f.stats.complaints>0&&c.jsxs("div",{className:"na-kpi na-kpi--sm",children:[c.jsx("span",{className:"na-kpi__value--sm",children:f.stats.complaints}),c.jsx("span",{className:"na-kpi__label--sm",children:"Spam"})]})]}),V>0&&!A&&c.jsx("div",{className:"na-resend",children:T?c.jsxs("div",{className:"na-resend-panel",children:[c.jsxs("div",{className:"na-resend-label-row",children:[c.jsx("span",{className:"na-resend-label",children:"New subject line"}),c.jsxs("span",{className:"na-resend-meta",children:["sent ",L(oe),J<48?" · consider waiting 48h":""]})]}),c.jsx("input",{className:"na-resend-input",type:"text",value:_,onChange:re=>R(re.target.value),placeholder:"Try a different angle"}),c.jsxs("div",{className:"na-resend-actions",children:[c.jsx("button",{className:"na-resend-cancel",onClick:()=>M(!1),children:"Cancel"}),c.jsx("button",{className:"na-resend-send",onClick:ee,disabled:I||!_.trim(),children:I?"Sending...":`Send to ${V.toLocaleString()}`})]})]}):c.jsxs("button",{className:"na-resend-toggle",onClick:()=>{M(!0),R(f.issue.subject)},children:["Resend to ",V.toLocaleString()," non-openers ",c.jsx("span",{style:{float:"right"},children:"›"})]})}),A&&c.jsxs("div",{className:"na-resend-done",children:["Resent ",f.issue.resent_at?L(Date.now()-new Date(f.issue.resent_at).getTime()):"just now",P?` — ${P.sent} sent`:"",f.issue.resend_subject?` — "${f.issue.resend_subject}"`:""]}),c.jsxs("div",{className:"na-tabs",children:[c.jsxs("button",{className:`na-tab${v==="links"?" active":""}`,onClick:()=>x("links"),children:["Links (",F.length,")"]}),c.jsxs("button",{className:`na-tab${v==="activity"?" active":""}`,onClick:()=>x("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),v==="links"&&c.jsx("div",{className:"na-table-wrap",children:F.length===0?c.jsx("div",{className:"na-empty",children:"No link clicks recorded yet."}):c.jsxs("table",{className:"na-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{children:"Link"}),c.jsx("th",{children:"Unique"}),c.jsx("th",{children:"Total"}),c.jsx("th",{children:"CTR"})]})}),c.jsx("tbody",{children:F.map(re=>c.jsxs("tr",{children:[c.jsx("td",{className:"na-table__url",title:re.url,children:c.jsx("a",{href:re.url,target:"_blank",rel:"noopener noreferrer",children:Rk(re.url)})}),c.jsx("td",{children:re.uniqueClicks}),c.jsx("td",{children:re.totalClicks}),c.jsx("td",{children:Dp(re.uniqueClicks,B)})]},re.url))})]})}),v==="activity"&&c.jsxs("div",{className:"na-activity",children:[c.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(re=>c.jsx("button",{className:`na-filter-btn${k===re?" active":""}`,onClick:()=>w(re),children:re==="all"?"All":re.charAt(0).toUpperCase()+re.slice(1)+"s"},re))}),c.jsxs("div",{className:"na-table-wrap",children:[xe.length===0?c.jsxs("div",{className:"na-empty",children:["No ",k==="all"?"":k+" ","events recorded."]}):c.jsxs("table",{className:"na-table",children:[c.jsx("thead",{children:c.jsxs("tr",{children:[c.jsx("th",{children:"Email"}),c.jsx("th",{children:"Event"}),c.jsx("th",{children:"Detail"}),c.jsx("th",{children:"Time"})]})}),c.jsx("tbody",{children:xe.slice(0,100).map(re=>c.jsxs("tr",{children:[c.jsx("td",{className:"na-table__email",children:re.email}),c.jsxs("td",{children:[c.jsx("span",{className:`na-badge na-badge--${re.event_type}`,children:re.event_type}),re.count>1&&c.jsxs("span",{className:"na-count",children:[re.count,"x"]})]}),c.jsx("td",{className:"na-table__url",children:re.url?c.jsx("a",{href:re.url,target:"_blank",rel:"noopener noreferrer",children:Rk(re.url,35)}):"—"}),c.jsx("td",{className:"na-table__time",children:Ak(re.latestTimestamp)})]},re.key))})]}),xe.length>100&&c.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",xe.length," events"]})]})]})]})]})]})})}function M$(t){const e=new Map;for(const n of t){const r=`${n.email}|${n.event_type}|${n.url||""}`,s=e.get(r);s?(s.count++,n.timestamp>s.latestTimestamp&&(s.latestTimestamp=n.timestamp)):e.set(r,{key:r,email:n.email,event_type:n.event_type,url:n.url,latestTimestamp:n.timestamp,count:1})}return Array.from(e.values()).sort((n,r)=>new Date(r.latestTimestamp).getTime()-new Date(n.latestTimestamp).getTime())}function A$(t){const e=t.filter(r=>r.event_type==="click"&&r.url),n=new Map;for(const r of e){const s=r.url;let i=n.get(s);i||(i={emails:new Set,total:0},n.set(s,i)),i.emails.add(r.email),i.total++}return Array.from(n.entries()).map(([r,{emails:s,total:i}])=>({url:r,uniqueClicks:s.size,totalClicks:i})).sort((r,s)=>s.uniqueClicks-r.uniqueClicks)}function R$(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function Hl({filename:t,title:e,onClose:n}){const[r,s]=b.useState("queue"),[i,o]=b.useState(null),[l,d]=b.useState(null),[f,h]=b.useState(""),[m,g]=b.useState(!1),[v,x]=b.useState(null),[k,w]=b.useState(null);b.useEffect(()=>{fetch(`/api/documents/${encodeURIComponent(t)}/text`).then(T=>{if(!T.ok)throw new Error("Failed to load document");return T.json()}).then(T=>{d(T.text||""),o(R$(T.meta||{}))}).catch(T=>w(T.message))},[t]);const S=async()=>{var T;if(!(!l||!i)){g(!0);try{const M={content:l,content_type:i,mode:r};r==="custom"&&f&&(M.scheduled_at=new Date(f).toISOString());const _=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)}),R=await _.json();if(_.ok){const I=(T=R.item)!=null&&T.scheduled_at?new Date(R.item.scheduled_at).toLocaleString():"now";x({success:!0,message:`Scheduled for ${I}`})}else x({success:!1,message:R.error||"Failed to schedule"})}catch(M){x({success:!1,message:M.message})}finally{g(!1)}}},N=i===null&&!k;return c.jsx("div",{className:"schedule-post-overlay",onClick:n,children:c.jsxs("div",{className:"schedule-post-modal",onClick:T=>T.stopPropagation(),children:[c.jsxs("div",{className:"schedule-post-modal-header",children:[c.jsx("h3",{children:"Schedule Post"}),c.jsx("button",{className:"schedule-post-modal-close",onClick:n,children:"×"})]}),c.jsx("div",{className:"schedule-post-modal-doc",children:e}),k?c.jsxs("div",{className:"schedule-post-modal-result error",children:[k,c.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):v?c.jsxs("div",{className:`schedule-post-modal-result ${v.success?"success":"error"}`,children:[v.message,c.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"schedule-post-modal-field",children:[c.jsx("label",{children:"Content Type"}),c.jsx("div",{className:"schedule-post-modal-type",children:N?"...":i})]}),c.jsxs("div",{className:"schedule-post-modal-field",children:[c.jsx("label",{children:"Mode"}),c.jsxs("div",{className:"schedule-post-modal-modes",children:[c.jsx("button",{className:`schedule-post-mode ${r==="queue"?"active":""}`,onClick:()=>s("queue"),children:"Queue Next"}),c.jsx("button",{className:`schedule-post-mode ${r==="now"?"active":""}`,onClick:()=>s("now"),children:"Post Now"}),c.jsx("button",{className:`schedule-post-mode ${r==="custom"?"active":""}`,onClick:()=>s("custom"),children:"Custom Time"})]})]}),r==="custom"&&c.jsxs("div",{className:"schedule-post-modal-field",children:[c.jsx("label",{children:"Date & Time"}),c.jsx("input",{type:"datetime-local",value:f,onChange:T=>h(T.target.value)})]}),c.jsxs("div",{className:"schedule-post-modal-actions",children:[c.jsx("button",{className:"schedule-post-modal-cancel",onClick:n,children:"Cancel"}),c.jsx("button",{className:"schedule-post-modal-submit",onClick:S,disabled:m||N||r==="custom"&&!f,children:m?"Scheduling...":r==="now"?"Post Now":"Schedule"})]})]})]})})}const Ok=[{key:"document",label:"Document"},{key:"tweet",label:"Tweet",metadata:{content_type:"tweet",tweetContext:{mode:"tweet"}}},{key:"reply",label:"Reply",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{content_type:"reply",tweetContext:{mode:"reply"}}},{key:"quote",label:"Quote Tweet",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{content_type:"quote",tweetContext:{mode:"quote"}}},{key:"article",label:"Article",metadata:{content_type:"article",articleContext:{active:!0}}},{key:"linkedin",label:"LinkedIn",metadata:{content_type:"linkedin",linkedinContext:{active:!0}}},{key:"newsletter",label:"Newsletter",metadata:{content_type:"newsletter",newsletterContext:{active:!0}}},{key:"blog",label:"Blog",metadata:{content_type:"blog",blogContext:{active:!0}}}];function FT({anchorRect:t,onSelect:e,onClose:n}){const r=b.useRef(null),[s,i]=b.useState(null),[o,l]=b.useState(""),d=b.useRef(null),[f,h]=b.useState({left:t.left,top:t.bottom+4});b.useLayoutEffect(()=>{const x=r.current;if(!x)return;const k=x.getBoundingClientRect(),w=8;let S=t.left,N=t.bottom+4;N+k.height+w>window.innerHeight&&(N=t.top-k.height-4),S+k.width+w>window.innerWidth&&(S=t.right-k.width),N<w&&(N=w),S<w&&(S=w),h({left:S,top:N})},[t]),b.useEffect(()=>{const x=k=>{r.current&&!r.current.contains(k.target)&&n()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[n]),b.useEffect(()=>{const x=k=>{k.key==="Escape"&&n()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[n]),b.useEffect(()=>{s&&setTimeout(()=>{var x;return(x=d.current)==null?void 0:x.focus()},0)},[s]);const m=x=>{if(x.needsUrl){i(x.key),l("");return}e(x.metadata)},g=()=>{if(!s||!o.trim())return;const x=o.trim();if(!x.includes("x.com")&&!x.includes("twitter.com"))return;const k=Ok.find(S=>S.key===s);if(!(k!=null&&k.metadata))return;const w=JSON.parse(JSON.stringify(k.metadata));w.tweetContext&&(w.tweetContext.url=x),e(w)},v=o.trim().includes("x.com")||o.trim().includes("twitter.com");return c.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:Ok.map(x=>c.jsxs("div",{children:[c.jsx("button",{className:`create-doc-dropdown-item${s===x.key?" active":""}`,onClick:()=>m(x),children:x.label}),s===x.key&&c.jsxs("div",{className:"create-doc-dropdown-url",children:[c.jsx("input",{ref:d,type:"text",placeholder:x.urlPlaceholder,value:o,onChange:k=>l(k.target.value),onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),g()),k.key==="Escape"&&(i(null),l(""))}}),c.jsx("button",{onClick:g,disabled:!v,children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},x.key))})}const O$=[{id:"full",label:"Full"},{id:"compact",label:"Compact"},{id:"minimal",label:"Minimal"}];function ev(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=ev(n.items,e);if(r)return[n.id,...r]}}return null}function I$({docs:t,archivedDocs:e,workspaces:n,assignedFiles:r,pendingDocs:s,onSwitchDocument:i,onCreateDocument:o,actions:l,scrollRef:d,writingTitle:f,writingTarget:h,pendingWriteFilenames:m,searchQuery:g,searchResults:v,onSearchChange:x}){const k=D=>!!m&&m.has(D),[w,S]=b.useState(null),[N,T]=b.useState(""),[M,_]=b.useState(null),[R,I]=b.useState(()=>{try{const D=localStorage.getItem("ow-collapsed-sections");return D?new Set(JSON.parse(D)):new Set}catch{return new Set}}),[$,P]=b.useState(null),[z,q]=b.useState(null),[F,G]=b.useState(""),[B,W]=b.useState(null),[K,ne]=b.useState(""),[V,oe]=b.useState(null),[J,A]=b.useState(""),[L,ee]=b.useState(null),[pe,xe]=b.useState(null),[re,Ne]=b.useState([]),[ke,ze]=b.useState(!1),[Fe,Ge]=b.useState(null),[Re,Ze]=b.useState(null),[gt,ht]=b.useState(null),[ge,vt]=b.useState(null),[_t,Et]=b.useState(null),[Dt,ot]=b.useState(DE),Le=b.useRef(null);b.useEffect(()=>{if(!_t)return;const D=ce=>{Le.current&&!Le.current.contains(ce.target)&&Et(null)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[_t]);const ve=D=>{ot(D),RM(D),Et(null)},te=D=>{D.preventDefault(),Et({x:D.clientX,y:D.clientY})},je=b.useCallback((D,ce)=>{fetch("/api/documents/batch-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:D,action:ce})}).catch(()=>{})},[]),{draggedItem:Q,dropIndicator:de,handlePointerDown:fe,dropClass:Je,isDragging:Ie,isContainerDropTarget:it}=DT({docs:t,workspaces:n,assignedFiles:r,scrollRef:d,setCollapsedSections:I}),dt=b.useCallback(()=>{fetch("/api/plugins").then(D=>D.json()).then(D=>{const ce=[];let me=!1;for(const se of D.plugins||[]){const he=se.displayName||void 0;for(const be of se.sidebarMenuItems||[])ce.push({...be,pluginDisplayName:he});se.name==="@openwriter/plugin-publish"&&se.enabled&&(me=!0)}Ne(ce),ze(me)}).catch(()=>{})},[]);b.useEffect(()=>{dt()},[dt]),b.useEffect(()=>{const D=()=>dt();return window.addEventListener("ow-plugins-changed",D),()=>window.removeEventListener("ow-plugins-changed",D)},[dt]);const{variantsByMaster:at,variantFilenames:Ye}=b.useMemo(()=>{const D=new Map,ce=new Set;for(const me of t)if(me.masterDocId){const se=D.get(me.masterDocId)||[];se.push(me),D.set(me.masterDocId,se),ce.add(me.filename)}return{variantsByMaster:D,variantFilenames:ce}},[t]),qe=b.useCallback((D,ce)=>{D.preventDefault(),D.stopPropagation(),ee({x:D.clientX,y:D.clientY,filename:ce.filename,title:ce.title,docId:ce.docId,lastSent:ce.lastSent,postedUrl:ce.postedUrl,isNewsletter:ce.isNewsletter})},[]),lt=b.useCallback(D=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:D})}).catch(()=>{})},[]),bt=b.useCallback((D,ce,me)=>{fetch("/api/documents/variant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:D,masterDocId:ce,variantType:me})}).catch(()=>{})},[]),Ce=b.useCallback((D,ce,me,se,he)=>{if(!PT(ce,t.find(be=>be.filename===me))){if(ce.promptForFocus&&he===void 0){Ge({action:D,label:ce.label,filename:me,title:se});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:D,filename:me,title:se,instructions:he||"",label:ce.label})}).catch(()=>{})}},[t]),Se=D=>{I(ce=>{const me=new Set(ce);return me.has(D)?me.delete(D):me.add(D),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...me])),me})},We=b.useRef(n);We.current=n;const tt=b.useCallback(D=>{var ce;for(const me of We.current){const se=ev(((ce=me.workspace)==null?void 0:ce.root)||[],D);if(se){I(he=>{const be=[me.filename,...se.map(Ee=>`container-${Ee}`)];if(be.every(Ee=>!he.has(Ee)))return he;const Be=new Set(he);for(const Ee of be)Be.delete(Ee);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...Be])),Be});break}}},[]);Ul(d,t,n.length,tt);const He=b.useMemo(()=>{var se;const D=t.find(he=>he.isActive);if(!D)return null;const ce=D.masterDocId?t.find(he=>he.docId===D.masterDocId):void 0,me=(ce==null?void 0:ce.filename)??D.filename;for(const he of n){const be=ev(((se=he.workspace)==null?void 0:se.root)||[],me);if(be)return{wsFilename:he.filename,containerKeys:new Set(be.map(Be=>`container-${Be}`)),masterDocId:(ce==null?void 0:ce.docId)??null}}return{wsFilename:null,containerKeys:new Set,masterDocId:(ce==null?void 0:ce.docId)??null}},[t,n]);if(v!==null)return c.jsx(rf,{results:v,query:g,onSwitchDocument:i,actions:l});const xt=t.filter(D=>!r.has(D.filename)&&!Ye.has(D.filename)),j=(D,ce,me,se,he,be=!1)=>c.jsxs("div",{className:`sidebar-item ${D.isActive?"active":""} ${Ie(D.filename)?"dragging":""} ${Je(D.filename)}`,"data-drag-id":D.filename,"data-drag-type":"doc","data-drag-ws":ce||"__docs__","data-drag-container":me||"",onPointerDown:Be=>fe(Be,{type:"doc",file:D.filename,sourceWs:ce||null},D.title),onClick:()=>!D.isActive&&!Q&&i(D.filename),onDoubleClick:()=>{S(D.filename),T(D.title)},onContextMenu:Be=>qe(Be,D),children:[w===D.filename?c.jsx("input",{className:"sidebar-rename-input",value:N,onChange:Be=>T(Be.target.value),onBlur:()=>{l.handleRename(D.filename,D.title,N),S(null)},onKeyDown:Be=>{Be.key==="Enter"&&(l.handleRename(D.filename,D.title,N),S(null)),Be.key==="Escape"&&S(null)},autoFocus:!0,onClick:Be=>Be.stopPropagation()}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-item-title-text",children:D.title}),D.variantType&&c.jsx("span",{className:"files-badge-variant",children:D.variantType}),l.getDocTags(D.filename).includes("✓")&&c.jsx("svg",{className:"sidebar-approved-icon",title:"Approved",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),D.lastSent&&c.jsx("svg",{className:"sidebar-sent-icon",title:"Sent",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),(D.autoAccept===!0||D.autoAccept!==!1&&be)&&c.jsx("span",{className:"sidebar-auto-accept-dot",title:D.autoAccept===!0?"Auto-accept on":"Auto-accept inherited"}),s.filenames.includes(D.filename)&&c.jsx("span",{className:"sidebar-pending-dot"})]}),Ws(D.filename)&&c.jsx("div",{className:"sidebar-item-context",children:IT(D.filename)}),c.jsxs("div",{className:"sidebar-item-meta",children:[D.wordCount.toLocaleString()," words · ",ga(D.lastModified)]}),c.jsxs("div",{className:"sidebar-tags",children:[l.getDocTags(D.filename).filter(Be=>Be!=="✓").map(Be=>c.jsxs("span",{className:"sidebar-tag",onClick:Ee=>Ee.stopPropagation(),children:[Be,c.jsx("span",{className:"sidebar-tag-remove",onClick:Ee=>{Ee.stopPropagation(),l.handleRemoveTag(D.filename,Be)},children:"×"})]},Be)),V===D.filename?c.jsx("input",{className:"sidebar-tag-input",value:J,onChange:Be=>A(Be.target.value),onBlur:()=>{J.trim()&&l.handleAddTag(D.filename,J),oe(null)},onKeyDown:Be=>{Be.key==="Enter"&&(l.handleAddTag(D.filename,J),oe(null),A("")),Be.key==="Escape"&&(oe(null),A(""))},autoFocus:!0,onClick:Be=>Be.stopPropagation(),placeholder:"tag..."}):c.jsx("button",{className:"sidebar-tag-add",onClick:Be=>{Be.stopPropagation(),oe(D.filename),A("")},children:"+"})]})]}),M===D.filename?c.jsxs("div",{className:"sidebar-confirm-delete",onClick:Be=>Be.stopPropagation(),children:[c.jsx("span",{children:Ws(D.filename)?"Remove?":"Delete?"}),c.jsx("button",{onClick:()=>{l.handleDelete(D.filename),_(null)},children:"Yes"}),c.jsx("button",{onClick:()=>_(null),children:"No"})]}):c.jsx("button",{className:"sidebar-delete-btn",onClick:Be=>{Be.stopPropagation(),_(D.filename)},title:Ws(D.filename)?"Remove document":"Delete document",children:"×"})]},D.filename),U=(D,ce,me,se,he,be=!1)=>{const Be=D.docId?at.get(D.docId):void 0,Ee=f&&(h==null?void 0:h.parentDocId)&&h.parentDocId===D.docId;if(!(Be&&Be.length>0||Ee))return j(D,ce,me,se,he,be);const Tt=`variants-${D.docId}`,cn=!R.has(Tt);return c.jsxs("div",{className:"sidebar-variant-group",children:[c.jsxs("div",{className:`sidebar-variant-master${!cn&&(He==null?void 0:He.masterDocId)===D.docId?" active-within":""}`,onClick:xn=>{xn.target.closest(".sidebar-variant-chevron")&&(xn.stopPropagation(),Se(Tt))},children:[j(D,ce,me,se,he,be),c.jsx("span",{className:`sidebar-variant-chevron${cn?"":" collapsed"}`,children:c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),cn&&c.jsxs("div",{className:"sidebar-variant-children",children:[Be==null?void 0:Be.map((xn,Nn)=>j(xn,ce,me,se,Nn,be)),Ee&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:f})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]})]})]},`vg-${D.filename}`)},ie=(D,ce,me,se,he,be,Be=!1)=>{if(D.type==="doc"){const Ve=t.find(Vt=>Vt.filename===D.file);return Ve?Ye.has(Ve.filename)?c.jsx(c.Fragment,{}):U(Ve,me,se,he,be,Be):Ws(D.file)?c.jsx("div",{className:"sidebar-item sidebar-unavailable",children:c.jsxs("div",{className:"sidebar-item-title",children:[D.title||D.file," (unavailable)"]})},D.file):c.jsxs("div",{className:"sidebar-item sidebar-missing",children:[c.jsxs("div",{className:"sidebar-item-title",children:[D.title||D.file," (missing)"]}),c.jsx("button",{className:"sidebar-delete-btn",onClick:()=>l.handleRemoveFromWorkspace(me,D.file),title:"Remove",children:"×"})]},D.file)}const Ee=D,Ht=`container-${Ee.id}`,Tt=R.has(Ht),cn=ce<=2?`depth-${ce}`:"depth-2",xn=Ee.autoAccept===!0,Nn=xn||Be;return c.jsxs("div",{className:`sidebar-container ${cn} ${Tt?"collapsed":""} ${Je(Ee.id)} ${it(Ee.id)?"drop-inside":""}`,children:[c.jsxs("div",{className:`sidebar-container-header${Tt&&(He!=null&&He.containerKeys.has(Ht))?" active-within":""} ${(de==null?void 0:de.itemId)===Ee.id&&de.position==="inside"?"drop-inside":""}`,"data-drag-id":Ee.id,"data-drag-type":"container-header","data-drag-ws":me,"data-drag-parent":se||"","data-section-key":Ht,onPointerDown:Ve=>fe(Ve,{type:"container",id:Ee.id,sourceWs:me},Ee.name),onClick:()=>!Q&&Se(Ht),onContextMenu:Ve=>{Ve.preventDefault(),Ve.stopPropagation(),vt({x:Ve.clientX,y:Ve.clientY,type:"container",wsFilename:me,containerId:Ee.id,title:Ee.name,nodes:Ee.items,autoAccept:xn})},children:[c.jsx("span",{className:`sidebar-chevron ${Tt?"collapsed":""}`,children:"▾"}),z===Ee.id?c.jsx("input",{className:"sidebar-rename-input",value:F,onChange:Ve=>G(Ve.target.value),onBlur:()=>{l.handleRenameContainer(me,Ee.id,F),q(null)},onKeyDown:Ve=>{Ve.key==="Enter"&&(l.handleRenameContainer(me,Ee.id,F),q(null)),Ve.key==="Escape"&&q(null)},autoFocus:!0,onClick:Ve=>Ve.stopPropagation()}):c.jsx("span",{className:"sidebar-container-name",onDoubleClick:Ve=>{Ve.stopPropagation(),q(Ee.id),G(Ee.name)},children:Ee.name}),Nn&&c.jsx("span",{className:"sidebar-auto-accept-dot",title:xn?"Auto-accept on for this container":"Auto-accept inherited from workspace"}),c.jsxs("div",{className:"sidebar-container-actions",children:[c.jsx("button",{className:"sidebar-new-btn",onClick:Ve=>{Ve.stopPropagation(),ht({anchor:Ve.target.getBoundingClientRect(),wsFilename:me,containerId:Ee.id})},title:"New doc",children:"+"}),ce<2&&c.jsx("button",{className:"sidebar-new-btn",onClick:Ve=>{Ve.stopPropagation(),l.handleCreateContainer(me,Ee.id)},title:"New sub-container",children:"☐"}),c.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:Ve=>{Ve.stopPropagation(),l.handleDeleteContainer(me,Ee.id)},title:"Delete container",children:"×"})]})]}),!Tt&&c.jsxs("div",{className:"sidebar-container-list","data-drop-ws":me,"data-drop-container":Ee.id,children:[f&&!(h!=null&&h.parentDocId)&&(h==null?void 0:h.wsFilename)===me&&h.containerId===Ee.id&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:f})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),Ee.items.filter(Ve=>Ve.type!=="doc"?!0:!(k(Ve.file)||f&&(h==null?void 0:h.wsFilename)===me&&h.containerId===Ee.id&&Ve.title===f)).map((Ve,Vt)=>ie(Ve,ce+1,me,Ee.id,Ee.items,Vt,Nn)),Ee.items.length===0&&!f&&c.jsx("div",{className:"sidebar-empty",children:Q?"Drop here":"Empty"})]})]},Ee.id)};return c.jsxs("div",{className:"sidebar-scroll",ref:d,children:[c.jsxs("div",{className:`sidebar-section sidebar-docs-section ${R.has("docs")?"docs-collapsed":""}`,children:[c.jsxs("div",{className:`sidebar-section-header${R.has("docs")&&He!==null&&He.wsFilename===null?" active-within":""}`,"data-section-key":"docs",onClick:()=>Se("docs"),onContextMenu:te,children:[c.jsx("span",{className:`sidebar-chevron ${R.has("docs")?"collapsed":""}`,children:"▾"}),c.jsx("span",{className:"sidebar-label",children:"Documents"}),c.jsx("button",{className:"sidebar-new-btn",onClick:D=>{D.stopPropagation(),ht({anchor:D.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!R.has("docs")&&c.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&!(h!=null&&h.parentDocId)&&(!h||!n.some(D=>D.filename===(h==null?void 0:h.wsFilename)))&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:f})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),xt.filter(D=>!k(D.filename)&&(!f||D.title!==f)).map((D,ce)=>{const me=xt.map(se=>({type:"doc",file:se.filename,title:se.title}));return U(D,void 0,null,me,ce)}),xt.length===0&&c.jsx("div",{className:"sidebar-empty",children:Q?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(D=>{var he,be,Be;const ce=((he=D.workspace)==null?void 0:he.root)||[],me=R.has(D.filename),se=((be=D.workspace)==null?void 0:be.autoAccept)===!0||D.autoAccept===!0;return c.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${me?"ws-collapsed":""} ${Ie(D.filename)?"dragging":""} ${(de==null?void 0:de.itemId)===D.filename?de.position==="before"?"drop-before":"drop-after":""}`,children:[c.jsxs("div",{className:`sidebar-section-header${me&&(He==null?void 0:He.wsFilename)===D.filename?" active-within":""}`,"data-section-key":D.filename,"data-ws-drag":D.filename,onPointerDown:Ee=>fe(Ee,{type:"workspace",filename:D.filename},D.title),onClick:()=>!Q&&Se(D.filename),onContextMenu:Ee=>{var Ht;Ee.preventDefault(),Ee.stopPropagation(),vt({x:Ee.clientX,y:Ee.clientY,type:"workspace",wsFilename:D.filename,title:D.title,nodes:ce,autoAccept:((Ht=D.workspace)==null?void 0:Ht.autoAccept)===!0||D.autoAccept===!0})},children:[c.jsx("span",{className:`sidebar-chevron ${me?"collapsed":""}`,children:"▾"}),B===D.filename?c.jsx("input",{className:"sidebar-rename-input",value:K,onChange:Ee=>ne(Ee.target.value),onBlur:()=>{l.handleRenameWorkspace(D.filename,K),W(null)},onKeyDown:Ee=>{Ee.key==="Enter"&&(l.handleRenameWorkspace(D.filename,K),W(null)),Ee.key==="Escape"&&W(null)},autoFocus:!0,onClick:Ee=>Ee.stopPropagation()}):c.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:Ee=>{Ee.stopPropagation(),W(D.filename),ne(D.title)},children:D.title}),(((Be=D.workspace)==null?void 0:Be.autoAccept)===!0||D.autoAccept===!0)&&c.jsx("span",{className:"sidebar-auto-accept-dot",title:"Auto-accept on for this workspace"}),c.jsxs("div",{className:"sidebar-workspace-actions",children:[c.jsx("button",{className:"sidebar-new-btn",onClick:Ee=>{Ee.stopPropagation(),ht({anchor:Ee.target.getBoundingClientRect(),wsFilename:D.filename,containerId:null})},title:"New document",children:"+"}),c.jsx("button",{className:"sidebar-new-btn",onClick:Ee=>{Ee.stopPropagation(),l.handleCreateContainer(D.filename,null)},title:"New container",children:"☐"}),$===D.filename?c.jsxs("span",{className:"sidebar-inline-confirm",onClick:Ee=>Ee.stopPropagation(),children:[c.jsx("button",{onClick:()=>{l.handleDeleteWorkspace(D.filename),P(null)},children:"Yes"}),c.jsx("button",{onClick:()=>P(null),children:"No"})]}):c.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:Ee=>{Ee.stopPropagation(),P(D.filename)},title:"Delete workspace",children:"×"})]})]}),!me&&c.jsxs("div",{className:"sidebar-section-list","data-drop-ws":D.filename,children:[f&&!(h!=null&&h.parentDocId)&&(h==null?void 0:h.wsFilename)===D.filename&&h.containerId===null&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:f})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),ce.filter(Ee=>Ee.type!=="doc"?!0:!(k(Ee.file)||f&&(h==null?void 0:h.wsFilename)===D.filename&&h.containerId===null&&Ee.title===f)).map((Ee,Ht)=>ie(Ee,0,D.filename,null,ce,Ht,se)),ce.length===0&&!f&&c.jsx("div",{className:"sidebar-empty",children:Q?"Drop here to add":"Empty workspace"})]})]},D.filename)}),c.jsx("div",{className:"sidebar-new-workspace",children:c.jsx("button",{onClick:l.handleCreateWorkspace,children:"+ New Workspace"})}),ge&&c.jsx(Bd,{x:ge.x,y:ge.y,filename:ge.wsFilename,title:ge.title,onClose:()=>vt(null),onDuplicate:()=>{},onRename:()=>{ge.type==="workspace"?(W(ge.wsFilename),ne(ge.title)):ge.containerId&&(q(ge.containerId),G(ge.title)),vt(null)},onArchive:()=>{},onDelete:()=>{ge.type==="workspace"?l.handleDeleteWorkspace(ge.wsFilename):ge.containerId&&l.handleDeleteContainer(ge.wsFilename,ge.containerId)},onPluginAction:()=>{},pluginItems:[],folderMode:!0,onNewDoc:D=>{ht({anchor:D.target.getBoundingClientRect(),wsFilename:ge.wsFilename,containerId:ge.type==="container"?ge.containerId:null}),vt(null)},onNewContainer:()=>{l.handleCreateContainer(ge.wsFilename,ge.type==="container"?ge.containerId:null),vt(null)},onAcceptAll:()=>{const D=new Set;Ol(ge.nodes,D),D.size&&je([...D],"accept"),vt(null)},onRejectAll:()=>{const D=new Set;Ol(ge.nodes,D),D.size&&je([...D],"reject"),vt(null)},folderAutoAccept:ge.autoAccept,folderAutoAcceptLabel:ge.type==="workspace"?"for workspace":"for container",onToggleFolderAutoAccept:()=>{fetch("/api/auto-accept/inherit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wsFile:ge.wsFilename,...ge.type==="container"?{containerId:ge.containerId}:{},enabled:!ge.autoAccept})}).catch(()=>{})}}),L&&c.jsx(Bd,{x:L.x,y:L.y,filename:L.filename,title:L.title,onClose:()=>ee(null),onDuplicate:()=>lt(L.filename),onCreateVariant:L.docId?D=>bt(L.filename,L.docId,D):void 0,onRename:()=>{S(L.filename),T(L.title)},onArchive:()=>l.handleArchive(L.filename),onDelete:()=>l.handleDelete(L.filename),onPluginAction:(D,ce)=>Ce(D,ce,L.filename,L.title),pluginItems:re,onSchedulePost:ke?()=>{Ze({filename:L.filename,title:L.title}),ee(null)}:void 0,onViewAnalytics:L.docId&&L.lastSent&&(L.postedUrl||L.isNewsletter)?()=>{L.isNewsletter?xe({docId:L.docId,title:L.title}):L.postedUrl&&window.open(L.postedUrl,"_blank"),ee(null)}:void 0,viewAnalyticsLabel:L.isNewsletter?"View Analytics":L.postedUrl?"View on X":"View Analytics",isApproved:l.getDocTags(L.filename).includes("✓"),onToggleApprove:()=>{l.getDocTags(L.filename).includes("✓")?l.handleRemoveTag(L.filename,"✓"):(l.handleAddTag(L.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAutoAccept:(()=>{var ce;const D=(ce=t.find(me=>me.filename===L.filename))==null?void 0:ce.autoAccept;return D===!0?!0:D===!1?!1:Pd(n,L.filename)})(),onToggleAutoAccept:()=>{var me;const D=(me=t.find(se=>se.filename===L.filename))==null?void 0:me.autoAccept,ce=D===!0?!0:D===!1?!1:Pd(n,L.filename);fetch("/api/auto-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:L.filename,enabled:!ce})}).then(()=>l.fetchDocs()).catch(()=>{})},isAlreadySent:!!L.lastSent,onMarkSent:()=>{const D=L.filename;l.getDocTags(D).includes("✓")&&l.handleRemoveTag(D,"✓"),i(D),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>l.fetchDocs()).catch(()=>{})},100),ee(null)}}),Fe&&c.jsx(BT,{actionLabel:Fe.label,docTitle:Fe.title,onClose:()=>Ge(null),onConfirm:D=>{const ce=re.find(me=>me.action===Fe.action);ce&&Ce(Fe.action,ce,Fe.filename,Fe.title,D),Ge(null)}}),pe&&c.jsx($T,{docId:pe.docId,title:pe.title,onClose:()=>xe(null)}),Re&&c.jsx(Hl,{filename:Re.filename,title:Re.title,onClose:()=>Ze(null)}),gt&&c.jsx(FT,{anchorRect:gt.anchor,onClose:()=>ht(null),onSelect:D=>{ht(null),gt.wsFilename?l.handleCreateInWorkspace(gt.wsFilename,gt.containerId??null,D):D?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:D})}).catch(()=>{}):o()}}),_t&&c.jsx("div",{ref:Le,className:"sidebar-density-dropdown",style:{position:"fixed",left:_t.x,top:_t.y,zIndex:200},children:O$.map(D=>c.jsx("button",{className:`sidebar-density-option ${Dt===D.id?"active":""}`,onClick:()=>ve(D.id),children:D.label},D.id))})]})}function L$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:o,scrollRef:l,searchQuery:d,searchResults:f}){const[h,m]=b.useState(null);if(Ul(l,t,e.length),f!==null)return c.jsx(rf,{results:f,query:d,onSwitchDocument:s});const g=[...t].sort((w,S)=>new Date(S.lastModified).getTime()-new Date(w.lastModified).getTime()),v=[];let x="";for(const w of g){const S=N$(w.lastModified);S!==x&&(v.push({label:S,docs:[]}),x=S),v[v.length-1].docs.push(w)}const k=w=>{for(const S of e){if(!S.workspace)continue;const N=T=>{for(const M of T)if(M.type==="doc"&&M.file===w||M.type==="container"&&N(M.items))return!0;return!1};if(N(S.workspace.root))return S.title}return null};return c.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:l,children:[c.jsxs("div",{className:"tl-header",children:[c.jsx("span",{className:"tl-title",children:"Timeline"}),c.jsx("button",{className:"sidebar-new-btn",onClick:i,title:"New document",children:"+"})]}),v.map(w=>c.jsxs("div",{className:"tl-group",children:[c.jsx("div",{className:"tl-date",children:w.label}),w.docs.map(S=>{const N=k(S.filename);return c.jsxs("div",{className:`tl-item ${S.isActive?"active":""}`,onClick:()=>!S.isActive&&s(S.filename),children:[c.jsx("div",{className:"tl-dot"}),c.jsxs("div",{className:"tl-content",children:[c.jsxs("div",{className:"tl-item-title",children:[c.jsx("span",{children:S.title}),r.filenames.includes(S.filename)&&c.jsx("span",{className:"sidebar-pending-dot"})]}),Ws(S.filename)&&c.jsx("div",{className:"tl-item-context",children:IT(S.filename)}),c.jsxs("div",{className:"tl-item-meta",children:[S.wordCount.toLocaleString()," words · ",ga(S.lastModified)]}),N&&c.jsx("div",{className:"tl-badge",children:N})]}),h===S.filename?c.jsxs("div",{className:"sidebar-confirm-delete",onClick:T=>T.stopPropagation(),children:[c.jsx("span",{children:Ws(S.filename)?"Remove?":"Delete?"}),c.jsx("button",{onClick:()=>{o.handleDelete(S.filename),m(null)},children:"Yes"}),c.jsx("button",{onClick:()=>m(null),children:"No"})]}):c.jsx("button",{className:"sidebar-delete-btn",onClick:T=>{T.stopPropagation(),m(S.filename)},title:Ws(S.filename)?"Remove":"Delete",children:"×"})]},S.filename)})]},w.label)),t.length===0&&c.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function D$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:l,searchResults:d,onSearchChange:f}){const[h,m]=b.useState([]),[g,v]=b.useState(null);Ul(o,t,e.length);const[x,k]=b.useState(null),w=b.useRef(null);b.useEffect(()=>{if(!g)return;const A=L=>{w.current&&!w.current.contains(L.target)&&v(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[g]);const S=(A,L)=>{for(const ee of A)if(ee.type==="container"){if(ee.id===L)return ee;const pe=S(ee.items,L);if(pe)return pe}return null},N=A=>{let L=0;for(const ee of A)ee.type==="doc"?L++:ee.type==="container"&&(L+=N(ee.items));return L},T=A=>{const L=[];for(const ee of A)ee.type==="doc"?L.push(ee.file):ee.type==="container"&&L.push(...T(ee.items));return L},M=b.useMemo(()=>{if(h.length===0)return[];const A=h[h.length-1],L=e.find(pe=>pe.filename===A.wsFilename);if(!(L!=null&&L.workspace))return[];if(A.type==="workspace")return L.workspace.root;const ee=S(L.workspace.root,A.key);return ee?ee.items:[]},[h,e]),_=M.filter(A=>A.type==="container"),R=b.useMemo(()=>{const A=M.filter(L=>L.type==="doc").map(L=>L.file);return t.filter(L=>A.includes(L.filename))},[M,t]),I=A=>{const L=T(A.items);return t.filter(ee=>L.includes(ee.filename))},$=A=>{const L=e.find(pe=>pe.filename===A);if(!(L!=null&&L.workspace))return[];const ee=T(L.workspace.root);return t.filter(pe=>ee.includes(pe.filename))},P=b.useMemo(()=>t.filter(A=>!n.has(A.filename)),[t,n]),z=A=>{m(L=>[...L,A]),v(null)},q=()=>{m(A=>A.slice(0,-1)),v(null)},F=(A,L)=>{if(g===A){v(null);return}const pe=L.currentTarget.getBoundingClientRect();k({top:pe.bottom+4,left:pe.left}),v(A)},G=A=>{s(A),v(null)},B=h.length>1?h[h.length-2].title:"All",W=b.useRef(null),K=b.useRef(null),[ne,V]=b.useState(null),oe=b.useCallback(A=>{const ee=A.currentTarget.getBoundingClientRect();V({top:ee.bottom+4,left:ee.left})},[]);b.useEffect(()=>{if(!d)return;const A=L=>{K.current&&!K.current.contains(L.target)&&W.current&&!W.current.contains(L.target)&&f("")};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[d,f]);const J=()=>{if(!g)return[];if(g==="__unassigned__")return P;if(g==="__level-docs__")return R;const A=e.find(L=>L.filename===g);if(A)return $(A.filename);for(const L of e){if(!L.workspace)continue;const ee=S(L.workspace.root,g);if(ee)return I(ee)}return[]};return c.jsxs("div",{className:"board-scroll",ref:o,children:[c.jsxs("div",{className:"board-search-pill",children:[c.jsxs("svg",{className:"board-search-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"11",cy:"11",r:"8"}),c.jsx("path",{d:"m21 21-4.3-4.3"})]}),c.jsx("input",{ref:W,className:"board-search-input",type:"text",placeholder:"Search...",value:l,onChange:A=>f(A.target.value),onFocus:oe}),l&&c.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),h.length===0?c.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):c.jsxs("button",{className:"board-back",onClick:q,title:`Back to ${B}`,children:["← ",B]}),h.length===0&&c.jsxs(c.Fragment,{children:[P.length>0&&c.jsxs("button",{className:`board-chip ${g==="__unassigned__"?"open":""}`,onClick:A=>F("__unassigned__",A),children:["Documents ",c.jsx("span",{className:"board-chip-count",children:P.length})]}),e.map(A=>{var ee;const L=(ee=A.workspace)==null?void 0:ee.root.some(pe=>pe.type==="container");return c.jsxs("button",{className:`board-chip ${g===A.filename?"open":""}`,onClick:pe=>L?z({type:"workspace",key:A.filename,title:A.title,wsFilename:A.filename}):F(A.filename,pe),children:[A.title," ",c.jsx("span",{className:"board-chip-count",children:A.docCount}),L&&c.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.filename)}),c.jsx("button",{className:"board-chip board-chip-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),h.length>0&&c.jsxs(c.Fragment,{children:[R.length>0&&c.jsxs("button",{className:`board-chip board-chip-docs ${g==="__level-docs__"?"open":""}`,onClick:A=>F("__level-docs__",A),children:["Docs ",c.jsx("span",{className:"board-chip-count",children:R.length})]}),_.map(A=>{const L=A.items.some(ee=>ee.type==="container");return c.jsxs("button",{className:`board-chip ${g===A.id?"open":""}`,onClick:ee=>L?z({type:"container",key:A.id,title:A.name,wsFilename:h[h.length-1].wsFilename}):F(A.id,ee),children:[A.name," ",c.jsx("span",{className:"board-chip-count",children:N(A.items)}),L&&c.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.id)})]}),g&&x&&(()=>{const A=J();return c.jsxs("div",{className:"board-dropdown",ref:w,style:{position:"fixed",top:x.top,left:x.left},children:[A.map(L=>c.jsxs("div",{className:`board-dropdown-item ${L.isActive?"active":""}`,onClick:()=>G(L.filename),children:[c.jsxs("span",{className:"board-dropdown-title",children:[L.title,r.filenames.includes(L.filename)&&c.jsx("span",{className:"board-pending-dot"})]}),c.jsxs("span",{className:"board-dropdown-meta",children:[L.wordCount.toLocaleString()," words · ",ga(L.lastModified)]})]},L.filename)),A.length===0&&c.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),d&&ne&&c.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:K,style:{position:"fixed",top:ne.top,left:ne.left},children:[d.map(A=>c.jsxs("div",{className:`board-dropdown-item ${A.isActive?"active":""}`,onClick:()=>{s(A.filename),f("")},children:[c.jsx("span",{className:"board-dropdown-title",children:A.title}),A.matchType==="tag"&&A.matchedTag&&c.jsxs("span",{className:"board-dropdown-meta",children:["Tag: ",A.matchedTag]}),A.matchType==="content"&&A.snippet&&c.jsx("span",{className:"board-dropdown-meta board-search-snippet",children:A.snippet}),c.jsxs("span",{className:"board-dropdown-meta",children:[A.wordCount.toLocaleString()," words · ",ga(A.lastModified)]})]},A.filename)),d.length===0&&c.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function P$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:l,searchResults:d}){const[f,h]=b.useState([]);if(Ul(o,t,e.length),d!==null)return c.jsx(rf,{results:d,query:l,onSwitchDocument:s});const m=(M,_)=>{for(const R of M)if(R.type==="container"){if(R.id===_)return R;const I=m(R.items,_);if(I)return I}return null},g=M=>{let _=0;for(const R of M)R.type==="doc"?_++:R.type==="container"&&(_+=g(R.items));return _},v=b.useMemo(()=>{if(f.length===0)return[];const M=f[f.length-1],_=e.find(I=>I.filename===M.wsFilename);if(!(_!=null&&_.workspace))return[];if(M.type==="workspace")return _.workspace.root;const R=m(_.workspace.root,M.key);return R?R.items:[]},[f,e]),x=v.filter(M=>M.type==="container"),k=b.useMemo(()=>{if(f.length===0)return t.filter(_=>!n.has(_.filename));const M=v.filter(_=>_.type==="doc").map(_=>_.file);return t.filter(_=>M.includes(_.filename))},[f,v,t,n]),w=M=>h(_=>[..._,M]),S=()=>h(M=>M.slice(0,-1)),N=f.length>1?f[f.length-2].title:"Shelf",T=f.length>0?f[f.length-1].title:"Documents";return c.jsxs("div",{className:"shelf-wrapper",children:[c.jsxs("div",{className:"shelf-spines",ref:o,children:[f.length>0&&c.jsxs("button",{className:"shelf-back",onClick:S,title:`Back to ${N}`,children:[c.jsx("span",{className:"shelf-back-arrow",children:"←"}),c.jsx("span",{className:"shelf-back-label",children:N})]}),f.length===0&&c.jsxs(c.Fragment,{children:[e.map(M=>c.jsxs("div",{className:"shelf-section-spine",onClick:()=>w({type:"workspace",key:M.filename,title:M.title,wsFilename:M.filename}),title:M.title,children:[c.jsx("span",{className:"shelf-section-title",children:M.title}),c.jsx("span",{className:"shelf-section-count",children:M.docCount})]},M.filename)),c.jsx("button",{className:"shelf-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),f.length>0&&x.map(M=>c.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>w({type:"container",key:M.id,title:M.name,wsFilename:f[f.length-1].wsFilename}),title:M.name,children:[c.jsx("span",{className:"shelf-section-title",children:M.name}),c.jsx("span",{className:"shelf-section-count",children:g(M.items)})]},M.id))]}),c.jsxs("div",{className:"shelf-docs",children:[c.jsx("div",{className:"shelf-docs-header",children:T}),c.jsxs("div",{className:"shelf-docs-list",children:[k.map(M=>c.jsxs("div",{className:`shelf-doc-item ${M.isActive?"active":""}`,onClick:()=>s(M.filename),children:[c.jsxs("div",{className:"shelf-doc-title",children:[c.jsx("span",{children:M.title}),r.filenames.includes(M.filename)&&c.jsx("span",{className:"shelf-pending-dot"})]}),c.jsxs("div",{className:"shelf-doc-meta",children:[M.wordCount.toLocaleString()," words · ",ga(M.lastModified)]})]},M.filename)),k.length===0&&c.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}async function Ik(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();if((i=(s=r==null?void 0:r.content)==null?void 0:s[0])!=null&&i.text)try{return JSON.parse(r.content[0].text)}catch{return r.content[0].text}return r}function zT({filename:t,title:e,isActive:n,onSwitchDocument:r,onClose:s}){const[i,o]=b.useState("loading"),[l,d]=b.useState([]),[f,h]=b.useState(null),[m,g]=b.useState(null),[v,x]=b.useState(null);b.useEffect(()=>{Ik("list_blog_sites").then(S=>{if(S.error){g(S.error),o("error");return}const N=S.sites||[];d(N),N.length===0?o("pick"):N.length===1?(h(N[0].id),o("confirm")):o("pick")}).catch(S=>{g((S==null?void 0:S.message)||"Failed to load blog sites"),o("error")})},[]);const k=l.find(S=>S.id===f)||null,w=async()=>{if(k){o("posting"),g(null),n||(r(t),await new Promise(S=>setTimeout(S,350)));try{const S=await Ik("post_to_blog",{site_id:k.id});if(S!=null&&S.error){g(S.error),o("error");return}const N=S.commit?`https://github.com/${k.owner}/${k.repo}/commit/${S.commit}`:void 0;x({message:S.message,file:S.file,commit:S.commit,images_committed:S.images_committed,liveUrl:S.live_url,commitUrl:N,warning:S.warning}),o("done")}catch(S){g((S==null?void 0:S.message)||"Publish failed"),o("error")}}};return c.jsx("div",{className:"post-blog-overlay",onClick:()=>{i!=="posting"&&s()},children:c.jsxs("div",{className:"post-blog-modal",onClick:S=>S.stopPropagation(),children:[c.jsxs("div",{className:"post-blog-modal-header",children:[c.jsx("h3",{children:"Post to Blog"}),c.jsx("button",{className:"post-blog-modal-close",onClick:s,disabled:i==="posting",children:"×"})]}),c.jsx("div",{className:"post-blog-modal-doc",children:e}),i==="loading"&&c.jsx("div",{className:"post-blog-modal-loading",children:"Loading blog sites…"}),i==="pick"&&l.length===0&&c.jsxs("div",{className:"post-blog-modal-empty",children:["No blog sites registered. Add one in ",c.jsx("strong",{children:"Settings → Plugins → GitHub"})," first.",c.jsx("button",{className:"post-blog-modal-done",onClick:s,children:"Close"})]}),i==="pick"&&l.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"post-blog-modal-label",children:"Choose a destination"}),c.jsx("div",{className:"post-blog-modal-sites",children:l.map(S=>c.jsxs("button",{className:`post-blog-modal-site${f===S.id?" post-blog-modal-site--selected":""}`,onClick:()=>{h(S.id),o("confirm")},children:[c.jsx("div",{className:"post-blog-modal-site-label",children:S.label}),c.jsxs("div",{className:"post-blog-modal-site-repo",children:[S.owner,"/",S.repo,"@",S.branch]})]},S.id))})]}),i==="confirm"&&k&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"post-blog-modal-confirm",children:["Publish to ",c.jsxs("strong",{children:[k.owner,"/",k.repo,"@",k.branch]}),"?",c.jsxs("div",{className:"post-blog-modal-target-dir",children:["→ ",k.content_dir]})]}),c.jsxs("div",{className:"post-blog-modal-actions",children:[c.jsx("button",{className:"post-blog-modal-btn post-blog-modal-btn--primary",onClick:w,children:"Publish now"}),l.length>1&&c.jsx("button",{className:"post-blog-modal-btn",onClick:()=>o("pick"),children:"Back"}),c.jsx("button",{className:"post-blog-modal-btn",onClick:s,children:"Cancel"})]})]}),i==="posting"&&c.jsx("div",{className:"post-blog-modal-loading",children:"Publishing…"}),i==="done"&&v&&c.jsxs("div",{className:"post-blog-modal-result post-blog-modal-result--success",children:[c.jsx("div",{children:v.message||"Published"}),v.file&&c.jsx("div",{className:"post-blog-modal-meta",children:v.file}),typeof v.images_committed=="number"&&v.images_committed>0&&c.jsxs("div",{className:"post-blog-modal-meta",children:[v.images_committed," image",v.images_committed===1?"":"s"," committed"]}),v.warning&&c.jsx("div",{className:"post-blog-modal-warning",children:v.warning}),c.jsxs("div",{className:"post-blog-modal-actions",children:[v.liveUrl?c.jsx("button",{className:"post-blog-modal-btn post-blog-modal-btn--primary",onClick:()=>window.open(v.liveUrl,"_blank"),children:"View Post"}):v.commitUrl?c.jsx("button",{className:"post-blog-modal-btn post-blog-modal-btn--primary",onClick:()=>window.open(v.commitUrl,"_blank"),children:"View commit"}):null,c.jsx("button",{className:"post-blog-modal-btn",onClick:s,children:"Done"})]}),v.liveUrl&&v.commitUrl&&c.jsx("button",{className:"post-blog-modal-commit-link",onClick:()=>window.open(v.commitUrl,"_blank"),children:"View commit"})]}),i==="error"&&c.jsxs("div",{className:"post-blog-modal-result post-blog-modal-result--error",children:[c.jsx("div",{children:m||"Publish failed"}),c.jsx("div",{className:"post-blog-modal-actions",children:c.jsx("button",{className:"post-blog-modal-btn",onClick:s,children:"Close"})})]})]})})}const B$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M20 20H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h4l2 2h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2z"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14",opacity:"0.5"})]}),$$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),c.jsx("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]}),F$=()=>c.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),z$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),c.jsx("path",{d:"M7 15l-4-3.5L7 8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),U$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),c.jsx("path",{d:"M3 8V6.5C3 5.67 3.67 5 4.5 5h2C7.33 5 8 5.67 8 6.5V8c0 2-1.5 3-3 3",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),H$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),c.jsx("rect",{x:"2",y:"16",width:"8",height:"7",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),c.jsx("line",{x1:"4",y1:"18.5",x2:"8",y2:"18.5",stroke:"currentColor",strokeWidth:"1",opacity:"0.7"}),c.jsx("line",{x1:"4",y1:"20.5",x2:"7",y2:"20.5",stroke:"currentColor",strokeWidth:"1",opacity:"0.7"})]}),W$=()=>c.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:c.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 0 1-2.063-2.065 2.064 2.064 0 1 1 2.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})}),V$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),c.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),q$=()=>c.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("path",{d:"M2 12h20"}),c.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),Lk=()=>c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})});function K$({type:t}){switch(t){case"tweet":return c.jsx(F$,{});case"reply":return c.jsx(z$,{});case"quote":return c.jsx(U$,{});case"article":return c.jsx(H$,{});case"linkedin":return c.jsx(W$,{});case"newsletter":return c.jsx(V$,{});case"blog":return c.jsx(q$,{});default:return c.jsx($$,{})}}function Fu(t){let e=0;for(const n of t)n.type==="doc"?e++:n.type==="container"&&(e+=Fu(n.items));return e}function tv(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=tv(n.items,e);if(r)return[n.id,...r]}}return null}function Su(t){const e=new Set;return Ol(t,e),[...e]}function UT(t,e,n=0){for(const r of t)if(r.type==="container"){if(r.id===e)return n;const s=UT(r.items,e,n+1);if(s>=0)return s}return-1}function G$(t,e){if(!e)return 12;for(const n of t){if(!n.workspace)continue;const r=UT(n.workspace.root,e);if(r>=0)return 12+(r+1)*16}return 12}function J$({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:o,scrollRef:l,writingTitle:d,writingTarget:f,pendingWriteFilenames:h,searchQuery:m,searchResults:g,onSearchChange:v}){var tt,He,xt;const x=j=>!!h&&h.has(j),[k,w]=b.useState(()=>{try{const j=localStorage.getItem("ow-files-collapsed");return j?new Set(JSON.parse(j)):new Set}catch{return new Set}}),{draggedItem:S,dropIndicator:N,handlePointerDown:T,dropClass:M,isDragging:_,isContainerDropTarget:R}=DT({docs:t,workspaces:e,assignedFiles:n,scrollRef:l,setCollapsedSections:w}),I=j=>!N||N.itemId!==j||N.position==="inside"?void 0:{"--drop-indent":`${G$(e,N.containerId)}px`},{variantsByMaster:$,variantFilenames:P}=b.useMemo(()=>{const j=new Map,U=new Set;for(const ie of t)if(ie.masterDocId){const D=j.get(ie.masterDocId)||[];D.push(ie),j.set(ie.masterDocId,D),U.add(ie.filename)}return{variantsByMaster:j,variantFilenames:U}},[t]),[z,q]=b.useState(null),[F,G]=b.useState(null),[B,W]=b.useState(new Set),[K,ne]=b.useState(null),[V,oe]=b.useState([]),[J,A]=b.useState(!1),[L,ee]=b.useState(null),[pe,xe]=b.useState(null),[re,Ne]=b.useState(null),[ke,ze]=b.useState(null),[Fe,Ge]=b.useState(null),[Re,Ze]=b.useState(null),[gt,ht]=b.useState(new Set);b.useEffect(()=>{ht(new Set)},[r]);const ge=b.useCallback(()=>{fetch("/api/plugins").then(j=>j.json()).then(j=>{const U=[];let ie=!1;for(const D of j.plugins||[]){const ce=D.displayName||void 0;for(const me of D.sidebarMenuItems||[])U.push({...me,pluginDisplayName:ce});D.name==="@openwriter/plugin-publish"&&D.enabled&&(ie=!0)}oe(U),A(ie)}).catch(()=>{})},[]);b.useEffect(()=>{ge()},[ge]),b.useEffect(()=>{const j=()=>ge();return window.addEventListener("ow-plugins-changed",j),()=>window.removeEventListener("ow-plugins-changed",j)},[ge]);const vt=b.useCallback((j,U)=>{if(j.preventDefault(),j.stopPropagation(),B.has(U.filename)&&B.size>1){G({x:j.clientX,y:j.clientY,filename:U.filename,title:U.title,bulkCount:B.size});return}B.size>0&&!B.has(U.filename)&&W(new Set),G({x:j.clientX,y:j.clientY,filename:U.filename,title:U.title,docId:U.docId,lastSent:U.lastSent,postedUrl:U.postedUrl,isNewsletter:U.isNewsletter,contentType:U.contentType,sortRequest:U.sortRequest})},[B]),_t=b.useCallback(j=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:j})}).catch(()=>{})},[]),Et=b.useCallback((j,U,ie,D,ce)=>{if(!PT(U,t.find(me=>me.filename===ie))){if(U.promptForFocus&&ce===void 0){ee({action:j,label:U.label,filename:ie,title:D});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:j,filename:ie,title:D,instructions:ce||"",label:U.label})}).catch(()=>{})}},[t]),Dt=b.useCallback((j,U,ie)=>{for(const D of Su(ie)){const ce=t.find(me=>me.filename===D);fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:j,filename:D,title:(ce==null?void 0:ce.title)||D,instructions:"",label:U.label})}).catch(()=>{})}},[t]),ot=b.useCallback((j,U)=>{ht(ie=>{const D=new Set(ie);for(const ce of j)D.add(ce);return D}),fetch("/api/documents/batch-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:j,action:U})}).catch(()=>{})},[]),Le=j=>{w(U=>{const ie=new Set(U);return ie.has(j)?ie.delete(j):ie.add(j),localStorage.setItem("ow-files-collapsed",JSON.stringify([...ie])),ie})},ve=(j,U,ie,D)=>{q({type:j,key:U,value:ie,wsFilename:D})},te=()=>{if(!z)return;const{type:j,key:U,value:ie,wsFilename:D}=z;j==="doc"?o.handleRename(U,"",ie):j==="workspace"?o.handleRenameWorkspace(U,ie):j==="container"&&D&&o.handleRenameContainer(D,U,ie),q(null)},je=t.find(j=>j.isActive),Q=b.useMemo(()=>{var D;const j=t.find(ce=>ce.isActive);if(!j)return null;const U=j.masterDocId?t.find(ce=>ce.docId===j.masterDocId):void 0,ie=(U==null?void 0:U.filename)??j.filename;for(const ce of e){const me=tv(((D=ce.workspace)==null?void 0:D.root)||[],ie);if(me)return{wsFilename:ce.filename,containerKeys:new Set(me.map(se=>`container-${se}`)),masterDocId:(U==null?void 0:U.docId)??null}}return{wsFilename:null,containerKeys:new Set,masterDocId:(U==null?void 0:U.docId)??null}},[t,e]),de=b.useRef(e);de.current=e;const fe=b.useCallback(j=>{var U;for(const ie of de.current){const D=tv(((U=ie.workspace)==null?void 0:U.root)||[],j);if(D){w(ce=>{const me=[ie.filename,...D.map(he=>`container-${he}`)];if(me.every(he=>!ce.has(he)))return ce;const se=new Set(ce);for(const he of me)se.delete(he);return localStorage.setItem("ow-files-collapsed",JSON.stringify([...se])),se});break}}},[]);Ul(l,t,e.length,fe);const Je=b.useMemo(()=>t.filter(j=>!n.has(j.filename)&&!P.has(j.filename)&&!x(j.filename)),[t,n,P,h]),Ie=b.useMemo(()=>{var D;const j=[],U=ce=>{j.push(ce.filename);const me=ce.docId?$.get(ce.docId):void 0,se=ce.docId&&!k.has(`variants-${ce.docId}`);if(me&&se)for(const he of me)j.push(he.filename)},ie=ce=>{for(const me of ce)if(me.type==="doc"){const se=t.find(he=>he.filename===me.file);se&&!P.has(se.filename)&&U(se)}else k.has(`container-${me.id}`)||ie(me.items)};k.has("docs")||Je.forEach(U);for(const ce of e)k.has(ce.filename)||ie(((D=ce.workspace)==null?void 0:D.root)||[]);return j},[t,e,Je,P,$,k]),it=b.useCallback(()=>{W(new Set)},[]),dt=b.useCallback((j,U)=>{if(S)return;const ie=j.shiftKey,D=j.ctrlKey||j.metaKey;if(ie){const me=K||(je==null?void 0:je.filename)||U,se=Ie.indexOf(me),he=Ie.indexOf(U);if(se<0||he<0){W(new Set([U])),ne(U);return}const[be,Be]=se<he?[se,he]:[he,se];W(new Set(Ie.slice(be,Be+1)));return}if(D){W(me=>{const se=new Set(me);return se.has(U)?se.delete(U):se.add(U),se}),ne(U);return}W(new Set),ne(U);const ce=t.find(me=>me.filename===U);ce&&!ce.isActive&&s(U)},[S,K,je==null?void 0:je.filename,Ie,s,t]);b.useEffect(()=>{if(B.size===0)return;const j=U=>{U.key==="Escape"&&it()};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[B.size,it]);const at=b.useCallback(()=>{for(const j of B)o.handleDelete(j);W(new Set),ne(null)},[B,o]),Ye=b.useCallback(j=>{j.length!==0&&fetch("/api/documents/sort-request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:j})}).then(()=>o.fetchDocs()).catch(()=>{})},[o]),qe=b.useCallback(j=>{fetch("/api/documents/sort-reject",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:j})}).then(()=>o.fetchDocs()).catch(()=>{})},[o]),lt=b.useCallback(j=>{fetch("/api/documents/sort-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:j})}).then(()=>o.fetchDocs()).catch(()=>{})},[o]);if(g!==null)return c.jsx(rf,{results:g,query:m,onSwitchDocument:s,actions:o});const bt=j=>c.jsx("input",{className:"sidebar-rename-input",value:z.value,onChange:U=>q(ie=>ie?{...ie,value:U.target.value}:null),onBlur:j,onKeyDown:U=>{U.key==="Enter"&&j(),U.key==="Escape"&&q(null)},autoFocus:!0,onClick:U=>U.stopPropagation()}),Ce=(j,U,ie,D,ce,me=!1)=>c.jsxs("div",{className:`files-row${j.isActive?" active":""}${j.docId&&(Q==null?void 0:Q.masterDocId)===j.docId&&k.has(`variants-${j.docId}`)?" active-within":""}${B.has(j.filename)?" selected":""} ${_(j.filename)?"dragging":""} ${M(j.filename)}${j.masterDocId?" is-variant":""}`,style:{paddingLeft:U,...I(j.filename)},"data-drag-id":j.filename,"data-drag-type":"doc","data-drag-ws":ie||"__docs__","data-drag-container":D||"",onPointerDown:se=>T(se,{type:"doc",file:j.filename,sourceWs:ie||null},j.title),onClick:se=>dt(se,j.filename),onDoubleClick:()=>ve("doc",j.filename,j.title),onContextMenu:se=>vt(se,j),children:[c.jsx("span",{className:"files-row-icon",children:c.jsx(K$,{type:j.contentType})}),(z==null?void 0:z.type)==="doc"&&z.key===j.filename?bt(te):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"files-row-label",children:j.title}),j.variantType&&c.jsx("span",{className:"files-badge-variant",children:j.variantType}),(j.autoAccept===!0||j.autoAccept!==!1&&me)&&c.jsx("span",{className:"sidebar-auto-accept-dot",title:j.autoAccept===!0?"Auto-accept on":"Auto-accept inherited"}),r.filenames.includes(j.filename)&&!gt.has(j.filename)&&c.jsx("span",{className:"files-badge-pending"}),j.sortRequest&&(j.sortRequest.proposal?c.jsx("span",{className:"files-badge-sort-proposal",title:"Sort proposal ready — right-click to review"}):c.jsx("span",{className:"files-badge-sort-pending",title:"Sort requested"})),o.getDocTags(j.filename).includes("✓")&&c.jsx("span",{className:"files-badge-approved",children:c.jsx(Lk,{})}),j.lastSent&&c.jsx("span",{className:"files-badge-sent",children:c.jsx(Lk,{})}),ce&&c.jsx("span",{className:`files-row-chevron${k.has(`variants-${j.docId}`)?" collapsed":""}`,onClick:se=>{se.stopPropagation(),Le(`variants-${j.docId}`)},children:c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})})]})]},j.filename),Se=(j,U,ie,D,ce=!1)=>{const me=j.docId?$.get(j.docId):void 0,se=!!(me&&me.length>0),he=d&&(f==null?void 0:f.parentDocId)&&f.parentDocId===j.docId,be=se||he,Be=!k.has(`variants-${j.docId}`);return be?c.jsxs("div",{className:"files-variant-group",children:[Ce(j,U,ie,D,se,ce),Be&&(me==null?void 0:me.map(Ee=>Ce(Ee,U+16,ie,D,!1,ce))),he&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:U+16},children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:d})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]})]},`vg-${j.filename}`):Ce(j,U,ie,D,!1,ce)},We=(j,U,ie,D,ce=!1)=>{const me=12+U*16;if(j.type==="doc"){const Tt=t.find(cn=>cn.filename===j.file);return!Tt||P.has(Tt.filename)?null:Se(Tt,me,ie,D,ce)}const se=j,he=`container-${se.id}`,be=k.has(he),Be=Fu(se.items),Ee=se.autoAccept===!0,Ht=Ee||ce;return c.jsxs("div",{className:`${M(se.id)} ${R(se.id)?"files-drop-inside":""}`,children:[c.jsxs("div",{className:`files-row is-container${be&&(Q!=null&&Q.containerKeys.has(he))?" active-within":""} ${_(se.id)?"dragging":""} ${M(se.id)}`,style:{paddingLeft:me,...I(se.id)},"data-drag-id":se.id,"data-drag-type":"container-header","data-drag-ws":ie,"data-drag-parent":D||"","data-section-key":he,onPointerDown:Tt=>T(Tt,{type:"container",id:se.id,sourceWs:ie},se.name),onClick:()=>!S&&Le(he),onDoubleClick:Tt=>{Tt.stopPropagation(),ve("container",se.id,se.name,ie)},onContextMenu:Tt=>{Tt.preventDefault(),Tt.stopPropagation(),Ze({x:Tt.clientX,y:Tt.clientY,type:"container",wsFilename:ie,containerId:se.id,title:se.name,nodes:se.items,autoAccept:Ee})},children:[c.jsx("span",{className:"files-row-icon",children:c.jsx(B$,{})}),(z==null?void 0:z.type)==="container"&&z.key===se.id?bt(te):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"files-row-label",children:se.name}),Ht&&c.jsx("span",{className:"sidebar-auto-accept-dot",title:Ee?"Auto-accept on for this container":"Auto-accept inherited from workspace"}),c.jsx("span",{className:"files-row-count",children:Be})]})]}),c.jsxs("div",{className:`files-children${be?" collapsed":""}`,"data-drop-ws":ie,"data-drop-container":se.id,children:[d&&!(f!=null&&f.parentDocId)&&(f==null?void 0:f.wsFilename)===ie&&f.containerId===se.id&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:12+(U+1)*16},children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:d})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),se.items.filter(Tt=>Tt.type!=="doc"||!x(Tt.file)).map(Tt=>We(Tt,U+1,ie,se.id,Ht))]})]},se.id)};return c.jsxs("div",{className:"files-scroll",ref:l,children:[c.jsxs("div",{className:"files-section",children:[c.jsxs("div",{className:`files-row is-section${k.has("docs")&&Q!==null&&Q.wsFilename===null?" active-within":""}`,"data-section-key":"docs",onClick:()=>Le("docs"),children:[c.jsx("span",{className:`files-row-chevron leading${k.has("docs")?" collapsed":""}`,children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})}),c.jsx("span",{className:"files-row-label",children:"Documents"}),c.jsx("button",{className:"files-section-btn",onClick:j=>{j.stopPropagation(),Ge({anchor:j.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),c.jsxs("div",{className:`files-section-list files-children${k.has("docs")?" collapsed":""}`,"data-drop-ws":"__docs__",children:[d&&!(f!=null&&f.parentDocId)&&(!f||!e.some(j=>j.filename===(f==null?void 0:f.wsFilename)))&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:28},children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:d})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),Je.map(j=>Se(j,28))]})]}),e.map(j=>{var me,se,he;const U=((me=j.workspace)==null?void 0:me.root)||[],ie=k.has(j.filename),D=Fu(U),ce=((se=j.workspace)==null?void 0:se.autoAccept)===!0||j.autoAccept===!0;return c.jsxs("div",{className:`files-section ${_(j.filename)?"dragging":""} ${(N==null?void 0:N.itemId)===j.filename?N.position==="before"?"files-ws-drop-before":"files-ws-drop-after":""}`,children:[c.jsx("div",{className:`files-row is-section${ie&&(Q==null?void 0:Q.wsFilename)===j.filename?" active-within":""}${(N==null?void 0:N.itemId)==="__section__"&&N.wsFilename===j.filename&&N.position==="inside"?" files-ws-drop-target":""}`,"data-section-key":j.filename,"data-ws-drag":j.filename,onPointerDown:be=>T(be,{type:"workspace",filename:j.filename},j.title),onClick:()=>!S&&Le(j.filename),onDoubleClick:be=>{be.stopPropagation(),ve("workspace",j.filename,j.title)},onContextMenu:be=>{var Be;be.preventDefault(),be.stopPropagation(),Ze({x:be.clientX,y:be.clientY,type:"workspace",wsFilename:j.filename,title:j.title,nodes:U,autoAccept:((Be=j.workspace)==null?void 0:Be.autoAccept)===!0||j.autoAccept===!0})},children:(z==null?void 0:z.type)==="workspace"&&z.key===j.filename?c.jsxs(c.Fragment,{children:[c.jsx("span",{className:`files-row-chevron leading${ie?" collapsed":""}`,children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})}),bt(te)]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:`files-row-chevron leading${ie?" collapsed":""}`,children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"6 9 12 15 18 9"})})}),c.jsx("span",{className:"files-row-label",children:j.title}),(((he=j.workspace)==null?void 0:he.autoAccept)===!0||j.autoAccept===!0)&&c.jsx("span",{className:"sidebar-auto-accept-dot",title:"Auto-accept on for this workspace"}),c.jsx("span",{className:"files-row-count",children:D}),c.jsxs("div",{className:"files-section-actions",children:[c.jsx("button",{className:"files-section-btn",onClick:be=>{be.stopPropagation(),Ge({anchor:be.target.getBoundingClientRect(),wsFilename:j.filename,containerId:null})},title:"New document",children:"+"}),c.jsx("button",{className:"files-section-btn",onClick:be=>{be.stopPropagation(),o.handleCreateContainer(j.filename,null)},title:"New container",children:"☐"})]})]})}),c.jsxs("div",{className:`files-section-list files-children${ie?" collapsed":""}`,"data-drop-ws":j.filename,children:[d&&!(f!=null&&f.parentDocId)&&(f==null?void 0:f.wsFilename)===j.filename&&f.containerId===null&&c.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:28},children:[c.jsxs("div",{className:"sidebar-item-title",children:[c.jsx("span",{className:"sidebar-writing-spinner"}),c.jsx("span",{className:"sidebar-item-title-text",children:d})]}),c.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),U.filter(be=>be.type!=="doc"||!x(be.file)).map(be=>We(be,1,j.filename,null,ce))]})]},j.filename)}),c.jsx("div",{className:"files-new-ws",children:c.jsx("button",{onClick:o.handleCreateWorkspace,children:"+ New Workspace"})}),Re&&c.jsx(Bd,{x:Re.x,y:Re.y,filename:Re.wsFilename,title:Re.title,onClose:()=>Ze(null),onDuplicate:()=>{},onRename:()=>{Re.type==="workspace"?ve("workspace",Re.wsFilename,Re.title):Re.containerId&&ve("container",Re.containerId,Re.title,Re.wsFilename),Ze(null)},onArchive:()=>{},onDelete:()=>{Re.type==="workspace"?o.handleDeleteWorkspace(Re.wsFilename):Re.containerId&&o.handleDeleteContainer(Re.wsFilename,Re.containerId,!1)},folderDocCount:Re.type==="container"?Fu(Re.nodes):0,onDeleteWithDocs:Re.type==="container"&&Re.containerId?()=>{o.handleDeleteContainer(Re.wsFilename,Re.containerId,!0)}:void 0,onPluginAction:(j,U)=>Dt(j,U,Re.nodes),pluginItems:V.filter(j=>j.folderCapable),folderMode:!0,onNewDoc:j=>{Ge({anchor:j.target.getBoundingClientRect(),wsFilename:Re.wsFilename,containerId:Re.type==="container"?Re.containerId:null}),Ze(null)},onNewContainer:()=>{o.handleCreateContainer(Re.wsFilename,Re.type==="container"?Re.containerId:null),Ze(null)},onAcceptAll:()=>{const j=Su(Re.nodes);j.length&&ot(j,"accept"),Ze(null)},onRejectAll:()=>{const j=Su(Re.nodes);j.length&&ot(j,"reject"),Ze(null)},folderAutoAccept:Re.autoAccept,folderAutoAcceptLabel:Re.type==="workspace"?"for workspace":"for container",onToggleFolderAutoAccept:()=>{fetch("/api/auto-accept/inherit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wsFile:Re.wsFilename,...Re.type==="container"?{containerId:Re.containerId}:{},enabled:!Re.autoAccept})}).catch(()=>{})},onRequestSortAll:()=>{const j=Su(Re.nodes);j.length&&Ye(j)}}),F&&c.jsx(Bd,{x:F.x,y:F.y,filename:F.filename,title:F.title,bulkCount:F.bulkCount,onBulkDelete:at,onBulkRequestSort:F.bulkCount?()=>Ye([...B]):void 0,onClose:()=>G(null),onDuplicate:()=>_t(F.filename),onCreateVariant:F.docId?j=>{fetch("/api/documents/variant",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:F.filename,masterDocId:F.docId,variantType:j})}).catch(()=>{})}:void 0,onRename:()=>{ve("doc",F.filename,F.title),G(null)},onArchive:()=>o.handleArchive(F.filename),onDelete:()=>o.handleDelete(F.filename),onPluginAction:(j,U)=>Et(j,U,F.filename,F.title),pluginItems:V,onSchedulePost:J?()=>{xe({filename:F.filename,title:F.title}),G(null)}:void 0,onPostNow:F.contentType==="blog"?()=>{const j=(je==null?void 0:je.filename)===F.filename;Ne({filename:F.filename,title:F.title,isActive:j}),G(null)}:void 0,isAlreadyPublished:F.contentType==="blog"&&!!F.postedUrl,onViewAnalytics:F.docId&&F.lastSent&&(F.postedUrl||F.isNewsletter)?()=>{F.isNewsletter?ze({docId:F.docId,title:F.title}):F.postedUrl&&window.open(F.postedUrl,"_blank"),G(null)}:void 0,viewAnalyticsLabel:F.isNewsletter?"View Analytics":F.contentType==="blog"&&F.postedUrl?"View Post":F.postedUrl?"View on X":"View Analytics",isApproved:o.getDocTags(F.filename).includes("✓"),onToggleApprove:()=>{o.getDocTags(F.filename).includes("✓")?o.handleRemoveTag(F.filename,"✓"):(o.handleAddTag(F.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAutoAccept:(()=>{var U;const j=(U=t.find(ie=>ie.filename===F.filename))==null?void 0:U.autoAccept;return j===!0?!0:j===!1?!1:Pd(e,F.filename)})(),onToggleAutoAccept:()=>{var ie;const j=(ie=t.find(D=>D.filename===F.filename))==null?void 0:ie.autoAccept,U=j===!0?!0:j===!1?!1:Pd(e,F.filename);fetch("/api/auto-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:F.filename,enabled:!U})}).then(()=>o.fetchDocs()).catch(()=>{})},isAlreadySent:!!F.lastSent,onMarkSent:()=>{const j=F.filename;o.getDocTags(j).includes("✓")&&o.handleRemoveTag(j,"✓"),s(j),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>o.fetchDocs()).catch(()=>{})},100),G(null)},sortState:F.bulkCount?void 0:(tt=F.sortRequest)!=null&&tt.proposal?"proposal":F.sortRequest?"pending":"none",sortProposalLabel:(()=>{var me;const j=(me=F.sortRequest)==null?void 0:me.proposal;if(!j)return;const U=e.find(se=>se.filename===j.wsFilename),ie=(U==null?void 0:U.title)||j.wsFilename;if(!j.containerId)return ie;const D=se=>{for(const he of se){if(he.type==="container"&&he.id===j.containerId)return he.name;if(he.type==="container"){const be=D(he.items);if(be)return be}}return null},ce=U!=null&&U.workspace?D(U.workspace.root):null;return ce?`${ie} / ${ce}`:ie})(),sortProposalReasoning:(xt=(He=F.sortRequest)==null?void 0:He.proposal)==null?void 0:xt.reasoning,onRequestSort:F.bulkCount?void 0:()=>Ye([F.filename]),onCancelSort:()=>qe(F.filename),onAcceptSortProposal:()=>lt(F.filename),onRejectSortProposal:()=>qe(F.filename)}),L&&c.jsx(BT,{actionLabel:L.label,docTitle:L.title,onClose:()=>ee(null),onConfirm:j=>{const U=V.find(ie=>ie.action===L.action);U&&Et(L.action,U,L.filename,L.title,j),ee(null)}}),ke&&c.jsx($T,{docId:ke.docId,title:ke.title,onClose:()=>ze(null)}),pe&&c.jsx(Hl,{filename:pe.filename,title:pe.title,onClose:()=>xe(null)}),re&&c.jsx(zT,{filename:re.filename,title:re.title,isActive:re.isActive,onSwitchDocument:s,onClose:()=>Ne(null)}),Fe&&c.jsx(FT,{anchorRect:Fe.anchor,onClose:()=>Ge(null),onSelect:j=>{Ge(null),Fe.wsFilename?o.handleCreateInWorkspace(Fe.wsFilename,Fe.containerId??null,j):j?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:j})}).catch(()=>{}):i()}})]})}const Y$=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],X$=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}],HT=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","America/Phoenix","America/Toronto","America/Vancouver","America/Sao_Paulo","America/Mexico_City","Europe/London","Europe/Paris","Europe/Berlin","Europe/Amsterdam","Europe/Rome","Europe/Madrid","Europe/Moscow","Asia/Tokyo","Asia/Shanghai","Asia/Kolkata","Asia/Dubai","Asia/Singapore","Asia/Seoul","Australia/Sydney","Australia/Melbourne","Pacific/Auckland"];function Dk(t){var e;try{const n=new Date,i=((e=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(n).find(l=>l.type==="timeZoneName"))==null?void 0:e.value)||"";return`${t.split("/").pop().replace(/_/g," ")} (${i})`}catch{return t}}function Q$(t){if(t.length>0)return t[0].timezone;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(HT.includes(e))return e}catch{}return"America/New_York"}function Z$({slots:t,onBack:e}){const[n,r]=b.useState(t),[s,i]=b.useState(()=>Q$(t)),[o,l]=b.useState(!1),[d,f]=b.useState("09:00"),[h,m]=b.useState(["default"]),[g,v]=b.useState("any"),[x,k]=b.useState(!1),w=b.useRef(null);b.useEffect(()=>{if(!o)return;function _(R){w.current&&!w.current.contains(R.target)&&l(!1)}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[o]);async function S(_){i(_);const R=[];for(const I of n){const $=await fetch(`/api/scheduler/slots/${I.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:_})});if($.ok){const P=await $.json();R.push(P.slot)}else R.push(I)}R.length>0&&r(R)}async function N(){const _=await fetch("/api/scheduler/slots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:d,days:h.includes("default")?["default"]:h,filter_type:g,timezone:s})});if(_.ok){const R=await _.json();r(I=>[...I,R.slot]),k(!1),f("09:00"),m(["default"]),v("any")}}async function T(_){(await fetch(`/api/scheduler/slots/${_}`,{method:"DELETE"})).ok&&r(I=>I.filter($=>$.id!==_))}function M(_){m(R=>{if(_==="default")return["default"];const I=R.filter($=>$!=="default");if(I.includes(_)){const $=I.filter(P=>P!==_);return $.length===0?["default"]:$}return[...I,_]})}return c.jsxs("div",{className:"sidebar-schedule",children:[c.jsxs("div",{className:"sidebar-schedule-header",children:[c.jsx("button",{className:"sidebar-schedule-btn",onClick:e,title:"Back",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"m15 18-6-6 6-6"})})}),c.jsx("h3",{children:"Slot Settings"}),c.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>k(!x),children:x?"Cancel":"+ Add"})]}),c.jsxs("div",{className:"slot-tz",ref:w,children:[c.jsx("label",{className:"slot-tz-label",children:"Timezone"}),c.jsxs("button",{className:"slot-tz-trigger",onClick:()=>l(!o),children:[c.jsx("span",{children:Dk(s)}),c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:`slot-tz-chevron ${o?"slot-tz-chevron--open":""}`,children:c.jsx("path",{d:"m6 9 6 6 6-6"})})]}),o&&c.jsx("div",{className:"slot-tz-dropdown",children:HT.map(_=>c.jsx("div",{className:`slot-tz-option ${_===s?"active":""}`,onClick:()=>{S(_),l(!1)},children:Dk(_)},_))})]}),x&&c.jsxs("div",{className:"slot-add-form",children:[c.jsxs("div",{className:"slot-add-row",children:[c.jsx("input",{type:"time",className:"slot-input",value:d,onChange:_=>f(_.target.value)}),c.jsx("select",{className:"slot-input",value:g,onChange:_=>v(_.target.value),children:X$.map(_=>c.jsx("option",{value:_.value,children:_.label},_.value))})]}),c.jsxs("div",{className:"slot-add-days",children:[c.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${h.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>M("default"),children:"Every day"}),Y$.map(_=>c.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${h.includes(_.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>M(_.toLowerCase()),children:_},_))]}),c.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active slot-create-btn",onClick:N,children:"Create Slot"})]}),c.jsx("div",{className:"slot-list",children:n.length===0?c.jsxs("div",{className:"schedule-empty",children:[c.jsx("div",{className:"schedule-empty-title",children:"No slots"}),c.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):n.map(_=>c.jsxs("div",{className:"schedule-item slot-item",children:[c.jsx("div",{className:"schedule-item-time slot-item-time",children:e8(_.time)}),c.jsxs("div",{className:"schedule-item-content",children:[c.jsx("div",{className:"schedule-item-text",children:_.days.includes("default")?"Every day":_.days.join(", ")}),c.jsxs("div",{className:"schedule-item-meta",children:[c.jsxs("span",{children:["Filter: ",_.filter_type]}),_.filter_value&&c.jsxs("span",{children:["(",_.filter_value,")"]})]})]}),c.jsx("button",{className:"schedule-item-action schedule-item-action--danger slot-delete-btn",onClick:()=>T(_.id),title:"Delete slot",children:"×"})]},_.id))})]})}function e8(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function t8({onBack:t}){const[e,n]=b.useState([]),[r,s]=b.useState([]),[i,o]=b.useState(null),[l,d]=b.useState(!1),[f,h]=b.useState(!0),m=b.useCallback(async()=>{try{const[S,N]=await Promise.all([fetch("/api/scheduler/autoplugs/goals"),fetch("/api/scheduler/autoplugs/tracking")]);if(S.ok){const T=await S.json();n(T.goals||[])}if(N.ok){const T=await N.json();s(T.tracking||[])}}catch{}h(!1)},[]);b.useEffect(()=>{m()},[m]);const g=async S=>{(await fetch(`/api/scheduler/autoplugs/goals/${S.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!S.enabled})})).ok&&n(T=>T.map(M=>M.id===S.id?{...M,enabled:!M.enabled}:M))},v=async S=>{(await fetch(`/api/scheduler/autoplugs/goals/${S}`,{method:"DELETE"})).ok&&(n(T=>T.filter(M=>M.id!==S)),o(null))},x=async S=>{(await fetch(`/api/scheduler/autoplugs/tracking/${S}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipped:!0})})).ok&&s(T=>T.map(M=>M.id===S?{...M,skipped:!0}:M))},k=e.reduce((S,N)=>N.rule&&N.enabled?Math.min(S,N.rule.threshold):S,1/0),w=k===1/0?50:k;return c.jsxs("div",{className:"sidebar-schedule",children:[c.jsxs("div",{className:"sidebar-schedule-header",children:[c.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"m15 18-6-6 6-6"})})}),c.jsx("h3",{children:"Autoplugs"}),c.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!l),children:l?"Cancel":"+ Add"})]}),l&&c.jsx(r8,{onCreated:S=>{n(N=>[...N,S]),d(!1)}}),f?null:c.jsxs(c.Fragment,{children:[e.length===0?c.jsxs("div",{className:"schedule-empty",children:[c.jsx("div",{className:"schedule-empty-title",children:"No goals"}),c.jsx("div",{className:"schedule-empty-desc",children:"Create a goal to start autoplugging your tweets."})]}):e.map(S=>c.jsxs("div",{children:[c.jsxs("div",{className:"schedule-item",onClick:()=>o(i===S.id?null:S.id),children:[c.jsxs("div",{className:"schedule-item-content",children:[c.jsx("div",{className:"schedule-item-text",children:S.name}),c.jsx("div",{className:"schedule-item-meta",children:n8(S).map((N,T)=>c.jsx("span",{children:N},T))})]}),c.jsx("button",{className:`autoplug-toggle ${S.enabled?"autoplug-toggle--on":"autoplug-toggle--off"}`,onClick:N=>{N.stopPropagation(),g(S)},title:S.enabled?"Disable":"Enable"})]}),i===S.id&&c.jsx(s8,{goal:S,onSaved:N=>{n(T=>T.map(M=>M.id===N.id?N:M))},onDeleted:()=>v(S.id),onRefresh:m})]},S.id)),c.jsx("div",{className:"schedule-day-header",children:"Tracking"}),r.length===0?c.jsxs("div",{className:"schedule-empty",children:[c.jsx("div",{className:"schedule-empty-title",children:"No tracked tweets"}),c.jsx("div",{className:"schedule-empty-desc",children:"Tweets will appear here after posting."})]}):r.map(S=>c.jsxs("div",{className:"schedule-item",children:[c.jsxs("div",{className:"schedule-item-content",children:[c.jsx("div",{className:"schedule-item-text",children:S.original_text||`Tweet ${S.tweet_id}`}),c.jsxs("div",{className:"schedule-item-meta",children:[c.jsx("span",{children:i8(S.posted_at)}),c.jsxs("span",{children:[S.likes," likes"]}),c.jsxs("span",{children:[S.retweets," RTs"]}),S.views>0&&c.jsxs("span",{children:[o8(S.views)," views"]})]}),S.triggered?c.jsxs("div",{className:"autoplug-tracking-triggered",children:[c.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Autoplugged ",S.goal_name?`→ ${S.goal_name}`:""]}):S.skipped?c.jsx("div",{className:"autoplug-tracking-skipped",children:"Skipped"}):c.jsx("div",{className:"autoplug-tracking-bar",children:c.jsx("div",{className:"autoplug-tracking-bar-fill",style:{width:`${Math.min(100,S.likes/w*100)}%`}})})]}),!S.triggered&&!S.skipped&&c.jsx("button",{className:"autoplug-tracking-skip",onClick:()=>x(S.id),title:"Skip autoplug for this tweet",children:"×"})]},S.id))]})]})}function n8(t){const e=[];return t.rule&&(e.push(`${t.rule.threshold}+ ${t.rule.metric}`),e.push(t.rule.mode.charAt(0).toUpperCase()+t.rule.mode.slice(1)),t.rule.delay_minutes>0&&e.push(`${t.rule.delay_minutes}m delay`)),e.push(`${t.pool_count} msg${t.pool_count!==1?"s":""}`),e}function r8({onCreated:t}){const[e,n]=b.useState(""),[r,s]=b.useState(""),[i,o]=b.useState(""),[l,d]=b.useState("likes"),[f,h]=b.useState(50),[m,g]=b.useState(30),[v,x]=b.useState("static"),[k,w]=b.useState(!1),S=async()=>{if(e.trim()){w(!0);try{const N=await fetch("/api/scheduler/autoplugs/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.trim(),link:r.trim()||null,description:i.trim()||null})});if(!N.ok){w(!1);return}const{goal:T}=await N.json();await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:T.id,metric:l,threshold:f,delay_minutes:m,mode:v})});const M=await fetch("/api/scheduler/autoplugs/goals");if(M.ok){const R=((await M.json()).goals||[]).find(I=>I.id===T.id);if(R){t(R);return}}t({...T,rule_count:1,pool_count:0,rule:{metric:l,threshold:f,delay_minutes:m,mode:v,id:""}})}finally{w(!1)}}};return c.jsxs("div",{className:"autoplug-editor",children:[c.jsxs("label",{children:["Name",c.jsx("input",{value:e,onChange:N=>n(N.target.value),placeholder:"Newsletter, Course..."})]}),c.jsxs("label",{children:["Link",c.jsx("input",{value:r,onChange:N=>s(N.target.value),placeholder:"https://..."})]}),c.jsxs("label",{children:["Description (context for LLM)",c.jsx("textarea",{value:i,onChange:N=>o(N.target.value),placeholder:"Weekly engineering insights...",rows:2})]}),c.jsxs("div",{className:"autoplug-editor-row",children:[c.jsx("input",{type:"number",value:f,onChange:N=>h(Number(N.target.value)),min:1}),c.jsxs("select",{value:l,onChange:N=>d(N.target.value),children:[c.jsx("option",{value:"likes",children:"likes"}),c.jsx("option",{value:"retweets",children:"retweets"}),c.jsx("option",{value:"views",children:"views"})]}),c.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),c.jsx("input",{type:"number",value:m,onChange:N=>g(Number(N.target.value)),min:0,className:"autoplug-delay-input"}),c.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),c.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(N=>c.jsx("button",{className:v===N?"active":"",onClick:()=>x(N),children:N==="llm"?"LLM":N.charAt(0).toUpperCase()+N.slice(1)},N))}),c.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active autoplug-create-btn",onClick:S,disabled:k||!e.trim(),children:k?"Creating...":"Create Goal"})]})}function s8({goal:t,onSaved:e,onDeleted:n,onRefresh:r}){var q,F,G,B;const[s,i]=b.useState(t.name),[o,l]=b.useState(t.link||""),[d,f]=b.useState(t.description||""),[h,m]=b.useState(((q=t.rule)==null?void 0:q.metric)||"likes"),[g,v]=b.useState(((F=t.rule)==null?void 0:F.threshold)||50),[x,k]=b.useState(((G=t.rule)==null?void 0:G.delay_minutes)||30),[w,S]=b.useState(((B=t.rule)==null?void 0:B.mode)||"static"),[N,T]=b.useState([]),[M,_]=b.useState(""),[R,I]=b.useState(!1);b.useEffect(()=>{fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`).then(W=>W.json()).then(W=>T(W.pool||[])).catch(()=>{})},[t.id]);const $=async()=>{var W;I(!0);try{await fetch(`/api/scheduler/autoplugs/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,link:o||null,description:d||null})}),(W=t.rule)!=null&&W.id?await fetch(`/api/scheduler/autoplugs/rules/${t.rule.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metric:h,threshold:g,delay_minutes:x,mode:w})}):await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:t.id,metric:h,threshold:g,delay_minutes:x,mode:w})}),r()}finally{I(!1)}},P=async()=>{if(!M.trim())return;const W=await fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:M.trim()})});if(W.ok){const K=await W.json();T(ne=>[...ne,K.message]),_("")}},z=async W=>{(await fetch(`/api/scheduler/autoplugs/pool/${W}`,{method:"DELETE"})).ok&&T(ne=>ne.filter(V=>V.id!==W))};return c.jsxs("div",{className:"autoplug-editor",children:[c.jsxs("label",{children:["Name",c.jsx("input",{value:s,onChange:W=>i(W.target.value)})]}),c.jsxs("label",{children:["Link",c.jsx("input",{value:o,onChange:W=>l(W.target.value),placeholder:"https://..."})]}),c.jsxs("label",{children:["Description",c.jsx("textarea",{value:d,onChange:W=>f(W.target.value),rows:2})]}),c.jsx("div",{className:"autoplug-editor-section-label",children:"Trigger"}),c.jsxs("div",{className:"autoplug-editor-row",children:[c.jsx("input",{type:"number",value:g,onChange:W=>v(Number(W.target.value)),min:1}),c.jsxs("select",{value:h,onChange:W=>m(W.target.value),children:[c.jsx("option",{value:"likes",children:"likes"}),c.jsx("option",{value:"retweets",children:"retweets"}),c.jsx("option",{value:"views",children:"views"})]}),c.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),c.jsx("input",{type:"number",value:x,onChange:W=>k(Number(W.target.value)),min:0,className:"autoplug-delay-input"}),c.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),c.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(W=>c.jsx("button",{className:w===W?"active":"",onClick:()=>S(W),children:W==="llm"?"LLM":W.charAt(0).toUpperCase()+W.slice(1)},W))}),c.jsxs("div",{className:"autoplug-pool-section",children:[c.jsx("div",{className:"autoplug-editor-section-label",children:"Static Pool"}),N.map(W=>c.jsxs("div",{className:"autoplug-pool-item",children:[c.jsx("span",{children:W.content}),c.jsx("button",{onClick:()=>z(W.id),title:"Remove",children:"×"})]},W.id)),c.jsxs("div",{className:"autoplug-pool-add",children:[c.jsx("input",{value:M,onChange:W=>_(W.target.value),placeholder:"Add message... (use {{link}} for link)",onKeyDown:W=>W.key==="Enter"&&P()}),c.jsx("button",{onClick:P,children:"+"})]})]}),(w==="llm"||w==="hybrid")&&c.jsx("div",{className:"autoplug-llm-hint",children:"LLM mode uses Author's Voice to generate contextual replies referencing the original tweet."}),c.jsxs("div",{className:"autoplug-editor-actions",children:[c.jsx("button",{className:"schedule-item-action",onClick:$,disabled:R,children:R?"Saving...":"Save"}),c.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:n,children:"Delete"})]})]})}function i8(t){const e=Date.now()-new Date(t).getTime(),n=Math.floor(e/6e4);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function o8(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function a8({onBack:t}){const[e,n]=b.useState([]),[r,s]=b.useState([]),[i,o]=b.useState(!1),[l,d]=b.useState(!1),[f,h]=b.useState(null),[m,g]=b.useState(!0),v=b.useCallback(async()=>{try{const[w,S]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots"),fetch("/api/scheduler/sync",{method:"POST"})]);if(w.ok){const N=await w.json();n(N.items||[])}if(S.ok){const N=await S.json();s(N.slots||[])}}catch{}g(!1)},[]);b.useEffect(()=>{v()},[v]);const x=async w=>{(await fetch(`/api/scheduler/queue/${w}`,{method:"DELETE"})).ok&&(n(N=>N.filter(T=>T.id!==w)),h(null))};if(l)return c.jsx(t8,{onBack:()=>{d(!1),v()}});if(i)return c.jsx(Z$,{slots:r,onBack:()=>{o(!1),v()}});const k=l8(r,e);return c.jsxs("div",{className:"sidebar-schedule",children:[c.jsxs("div",{className:"sidebar-schedule-header",children:[c.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back to documents",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"m15 18-6-6 6-6"})})}),c.jsx("h3",{children:"Schedule"}),c.jsxs("div",{className:"sidebar-schedule-actions",children:[c.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!0),title:"Autoplugs",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}),c.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>o(!0),title:"Manage slots",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),m?null:r.length===0?c.jsxs("div",{className:"schedule-empty",children:[c.jsx("div",{className:"schedule-empty-title",children:"No time slots"}),c.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):k.map(({label:w,entries:S})=>c.jsxs("div",{className:"schedule-day",children:[c.jsx("div",{className:"schedule-day-header",children:w}),S.map((N,T)=>{var M,_,R,I,$;return N.type==="empty"?c.jsxs("div",{className:"schedule-slot-empty",children:[c.jsx("div",{className:"schedule-item-time",children:Bk(N.time)}),c.jsx("div",{className:"schedule-slot-empty-label",children:((M=N.slot)==null?void 0:M.filter_type)==="any"?"Open slot":`${(_=N.slot)==null?void 0:_.filter_type}: ${((R=N.slot)==null?void 0:R.filter_value)||"any"}`})]},`empty-${T}`):c.jsxs("div",{children:[c.jsxs("div",{className:"schedule-item",onClick:()=>h(f===N.item.id?null:N.item.id),children:[c.jsx("div",{className:"schedule-item-time",children:Bk(N.time)}),c.jsxs("div",{className:"schedule-item-content",children:[c.jsx("div",{className:"schedule-item-text",children:((I=N.item.content)==null?void 0:I.text)||JSON.stringify(N.item.content)}),c.jsxs("div",{className:"schedule-item-meta",children:[c.jsx("span",{className:`schedule-item-status schedule-item-status--${N.item.status}`}),c.jsx("span",{children:N.item.status}),N.item.connection_name&&c.jsx("span",{children:N.item.connection_name}),N.item.provider&&c.jsx("span",{children:N.item.provider})]})]})]}),f===N.item.id&&c.jsxs("div",{className:"schedule-item-expanded",children:[c.jsx("div",{className:"schedule-item-full-text",children:(($=N.item.content)==null?void 0:$.text)||JSON.stringify(N.item.content,null,2)}),c.jsx("div",{className:"schedule-item-actions",children:c.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>x(N.item.id),children:"Cancel"})})]})]},N.item.id)})]},w))]})}function l8(t,e){const n=new Date,r=[];for(let l=0;l<7;l++){const d=new Date(n);d.setDate(d.getDate()+l),d.setHours(0,0,0,0);let f;l===0?f="Today":l===1?f="Tomorrow":f=d.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),r.push({label:f,date:d})}const s=new Map;for(const l of e){const d=new Date(l.scheduled_at),f=`${d.getFullYear()}-${d.getMonth()}-${d.getDate()}-${d.getHours()}-${d.getMinutes()}`;s.set(f,l)}const i=new Set,o=[];for(const{label:l,date:d}of r){const f=[],h=d.getDay(),g=["sun","mon","tue","wed","thu","fri","sat"][h];for(const v of t){if(!(v.days.includes("default")||v.days.includes(g)))continue;const[k,w]=v.time.split(":").map(Number),S=new Date(d);if(S.setHours(k,w,0,0),Pk(d,n)&&S<n)continue;const N=`${S.getFullYear()}-${S.getMonth()}-${S.getDate()}-${k}-${w}`,T=s.get(N);T?(f.push({type:"filled",time:S,item:T,slot:v}),i.add(T.id)):f.push({type:"empty",time:S,slot:v})}for(const v of e){if(i.has(v.id))continue;const x=new Date(v.scheduled_at);Pk(x,d)&&(f.push({type:"filled",time:x,item:v}),i.add(v.id))}f.sort((v,x)=>v.time.getTime()-x.time.getTime()),f.length>0&&o.push({label:l,entries:f})}return o}function Pk(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function Bk(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function c8({onBack:t}){const[e,n]=b.useState([]),[r,s]=b.useState(""),[i,o]=b.useState(null),[l,d]=b.useState(!1),f=b.useRef(null),h=b.useCallback(async()=>{try{const w=await fetch("/api/tasks");if(w.ok){const S=await w.json();n(S.tasks||[])}}catch{}},[]);b.useEffect(()=>{h()},[h]);const m=async()=>{const w=r.trim();if(w){s("");try{const S=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:w})});if(S.ok){const N=await S.json();n(T=>[...T,N.task])}}catch{}}},g=w=>{o(w),fetch(`/api/tasks/${w}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({completed:!0})}).catch(()=>{}),setTimeout(()=>{n(S=>S.filter(N=>N.id!==w)),o(null)},400)},v=async w=>{try{(await fetch(`/api/tasks/${w}`,{method:"DELETE"})).ok&&n(N=>N.filter(T=>T.id!==w))}catch{}},x=()=>{d(!0),setTimeout(()=>{var w;return(w=f.current)==null?void 0:w.focus()},0)},k=e.filter(w=>!w.completed);return c.jsxs("div",{className:"sidebar-tasks",children:[c.jsxs("div",{className:"sidebar-tasks-header",children:[c.jsx("button",{className:"sidebar-tasks-back",onClick:t,title:"Back to documents",children:c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"m15 18-6-6 6-6"})})}),c.jsx("h3",{children:"Tasks"}),c.jsx("button",{className:"sidebar-tasks-add-btn",onClick:x,title:"Add task",children:"+"})]}),k.length===0&&!l?c.jsxs("div",{className:"sidebar-tasks-empty",children:[c.jsx("div",{className:"sidebar-tasks-empty-title",children:"No tasks"}),c.jsx("div",{className:"sidebar-tasks-empty-desc",children:"Add tasks to track your checklist."})]}):c.jsx("div",{className:"sidebar-tasks-list",children:k.map(w=>c.jsxs("div",{className:`sidebar-tasks-item${i===w.id?" completing":""}`,children:[c.jsx("input",{type:"checkbox",className:"sidebar-tasks-checkbox",checked:i===w.id,onChange:()=>g(w.id)}),c.jsx("span",{className:`sidebar-tasks-text${i===w.id?" completed":""}`,children:w.text}),c.jsx("button",{className:"sidebar-tasks-delete",onClick:()=>v(w.id),title:"Remove",children:"×"})]},w.id))}),l&&c.jsx("div",{className:"sidebar-tasks-add",children:c.jsx("input",{ref:f,type:"text",placeholder:"New task...",value:r,onChange:w=>s(w.target.value),onKeyDown:w=>{w.key==="Enter"&&m(),w.key==="Escape"&&(d(!1),s(""))},onBlur:()=>{r.trim()||d(!1)}})})]})}function u8({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:o}){const[l,d]=b.useState(!1),[f,h]=b.useState(!1),[m,g]=b.useState(""),[v,x]=b.useState(null),k=b.useRef(null),w=b.useRef(null);b.useEffect(()=>{if(!l)return;const N=T=>{k.current&&!k.current.contains(T.target)&&(d(!1),h(!1),g(""),x(null))};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]),b.useEffect(()=>{f&&w.current&&w.current.focus()},[f]);const S=()=>{const N=m.trim();N&&(s(N),g(""),h(!1))};return c.jsxs("div",{className:"sidebar-profile-wrapper",ref:k,children:[c.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>d(!l),title:`Profile: ${e}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"8",r:"4"}),c.jsx("path",{d:"M5.5 21a8.38 8.38 0 0 1 13 0"})]})}),l&&c.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(N=>c.jsxs("div",{className:"sidebar-profile-row",children:[v===N?c.jsxs("div",{className:"sidebar-profile-confirm",children:[c.jsx("span",{children:"Delete?"}),c.jsxs("div",{className:"sidebar-inline-confirm",children:[c.jsx("button",{onClick:()=>{i(N),x(null)},children:"Yes"}),c.jsx("button",{onClick:()=>x(null),children:"No"})]})]}):c.jsx(c.Fragment,{children:c.jsxs("button",{className:`sidebar-profile-option ${N===e?"active":""}`,onClick:()=>{N!==e&&r(N),d(!1)},children:[c.jsx("span",{className:"sidebar-profile-check",children:N===e?"✓":""}),c.jsx("span",{children:N})]})}),N!=="Default"&&N!==e&&v!==N&&c.jsx("button",{className:"sidebar-profile-delete-btn",onClick:T=>{T.stopPropagation(),x(N)},title:"Delete profile",children:"×"})]},N)),n.length>0&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"sidebar-profile-divider"}),c.jsx("div",{className:"sidebar-profile-trash-label",children:"Trash"}),n.map(N=>c.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[c.jsx("span",{className:"sidebar-profile-trash-name",children:N}),c.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>o(N),children:"Restore"})]},N))]}),c.jsx("div",{className:"sidebar-profile-divider"}),f?c.jsx("div",{className:"sidebar-profile-add-input",children:c.jsx("input",{ref:w,type:"text",value:m,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&S(),N.key==="Escape"&&(h(!1),g(""))},placeholder:"Profile name..."})}):c.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>h(!0),children:[c.jsx("span",{className:"sidebar-profile-check",children:"+"}),c.jsx("span",{children:"New Profile"})]})]})]})}const WT=200,VT=600,nv=260;function $k({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,docTagsRefreshKey:s,workspacesRefreshKey:i,pendingDocs:o,writingTitle:l,writingTarget:d,pendingWriteFilenames:f,activeFilename:h,onClose:m,width:g,onWidthChange:v,floating:x}){const{docs:k,setDocs:w,workspaces:S,setWorkspaces:N,assignedFiles:T,fetchDocs:M,fetchWorkspaces:_,scrollRef:R,markPendingDelete:I}=C$(r,i),$=_$(M,_,w,N,k,I),P=$d(),z=b.useRef(!1),q=b.useCallback(ot=>{ot.preventDefault(),z.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";let Le=g;const ve=je=>{z.current&&(Le=Math.min(VT,Math.max(WT,je.clientX)),v(Le))},te=()=>{z.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",ve),window.removeEventListener("pointerup",te);try{localStorage.setItem("ow-sidebar-width",String(Le))}catch{}};window.addEventListener("pointermove",ve),window.addEventListener("pointerup",te)},[g,v]),F=b.useCallback(ot=>{w(Le=>Le.map(ve=>({...ve,isActive:ve.filename===ot}))),e(ot)},[w,e]);b.useEffect(()=>{h&&w(ot=>ot.some(Le=>Le.filename===h?!Le.isActive:Le.isActive)?ot.map(Le=>({...Le,isActive:Le.filename===h})):ot)},[h,w,r]);const[G,B]=b.useState(!1),[W,K]=b.useState(!1),[ne,V]=b.useState([]),[oe,J]=b.useState("Default"),A=b.useCallback(async()=>{try{const ot=await fetch("/api/profiles");if(ot.ok){const Le=await ot.json();V(Le.profiles),J(Le.active)}}catch{}},[]);b.useEffect(()=>{A()},[A]);const L=b.useCallback(async ot=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ot})})).ok&&(J(ot),A())}catch{}},[A]),ee=b.useCallback(async ot=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ot})})).ok&&A()}catch{}},[A]),[pe,xe]=b.useState([]),re=b.useCallback(async()=>{try{const ot=await fetch("/api/profiles/trash");if(ot.ok){const Le=await ot.json();xe(Le.profiles)}}catch{}},[]);b.useEffect(()=>{re()},[re]);const Ne=b.useCallback(async ot=>{try{(await fetch(`/api/profiles/${encodeURIComponent(ot)}`,{method:"DELETE"})).ok&&(A(),re())}catch{}},[A,re]),ke=b.useCallback(async ot=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ot})})).ok&&(A(),re())}catch{}},[A,re]),[ze,Fe]=b.useState(""),[Ge,Re]=b.useState(null),Ze=b.useRef(),gt=b.useRef(null),ht=b.useCallback(ot=>{if(Fe(ot),Ze.current&&clearTimeout(Ze.current),!ot.trim()){Re(null);return}Ze.current=setTimeout(async()=>{try{const Le=await fetch(`/api/documents/search?q=${encodeURIComponent(ot.trim())}&archived=true`);Le.ok&&Re(await Le.json())}catch{}},250)},[]);b.useEffect(()=>()=>{Ze.current&&clearTimeout(Ze.current)},[]);const ge={docs:k,archivedDocs:[],workspaces:S,assignedFiles:T,pendingDocs:o,writingTitle:l,writingTarget:d,pendingWriteFilenames:f,onSwitchDocument:F,onCreateDocument:n,actions:$,scrollRef:R,searchQuery:ze,searchResults:Ge,onSearchChange:ht},vt=()=>{switch(P){case"files":return c.jsx(J$,{...ge});case"timeline":return c.jsx(L$,{...ge});case"board":return c.jsx(D$,{...ge});case"shelf":return c.jsx(P$,{...ge});default:return c.jsx(I$,{...ge})}},_t=c.jsxs("div",{className:"sidebar-search",children:[c.jsxs("svg",{className:"sidebar-search-icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"10.5",cy:"10.5",r:"7"}),c.jsx("path",{d:"m20 20-4.5-4.5"})]}),c.jsx("input",{ref:gt,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:ze,onChange:ot=>ht(ot.target.value)}),ze&&c.jsx("button",{className:"sidebar-search-clear",onClick:()=>ht(""),title:"Clear search",children:"×"})]}),Et=t?{width:`${g}px`,minWidth:`${g}px`}:void 0,Dt=t&&!x?c.jsx("div",{className:"sidebar-resize-handle",onPointerDown:q,onDoubleClick:()=>{v(nv);try{localStorage.setItem("ow-sidebar-width",String(nv))}catch{}},title:"Drag to resize · double-click to reset"}):null;return P==="board"?c.jsxs("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,style:Et,children:[vt(),Dt]}):c.jsxs("div",{className:`sidebar ${t?"open":""}`,style:Et,children:[c.jsxs("div",{className:"sidebar-topbar",children:[c.jsxs("div",{className:"sidebar-logo",children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("path",{d:"M17 3a2.83 2.83 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),c.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),c.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),c.jsxs("div",{className:"sidebar-topbar-actions",children:[c.jsx(u8,{profiles:ne,activeProfile:oe,trashedProfiles:pe,onSwitch:L,onCreate:ee,onDelete:Ne,onRestore:ke}),c.jsx("button",{className:`sidebar-collapse-btn${G?" sidebar-collapse-btn--active":""}`,onClick:()=>{B(!G),K(!1)},title:"Schedule",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("line",{x1:"16",x2:"16",y1:"1",y2:"5"}),c.jsx("line",{x1:"8",x2:"8",y1:"1",y2:"5"}),c.jsx("line",{x1:"3",x2:"21",y1:"9",y2:"9"})]})}),c.jsx("button",{className:`sidebar-collapse-btn${W?" sidebar-collapse-btn--active":""}`,onClick:()=>{K(!W),B(!1)},title:"Tasks",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),c.jsx("path",{d:"m9 12 2 2 4-4"})]})}),m&&c.jsx("button",{className:"sidebar-collapse-btn",onClick:m,title:"Close sidebar",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),c.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),W?c.jsx(c8,{onBack:()=>K(!1)}):G?c.jsx(a8,{onBack:()=>B(!1)}):c.jsxs(c.Fragment,{children:[_t,vt()]}),Dt]})}function dy(t,e,n){let r=t.resolve(e);for(;r.depth>0;){const s=r.node(r.depth),i=r.before(r.depth),o=i+s.nodeSize;if(s.childCount===1)e=i,n=o,r=t.resolve(e);else break}return{from:e,to:n}}function d8(t,e){const n=Fn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function f8(t,e){const n=Fn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null,pendingOriginalContent:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run(),!0}function h8(t,e){var o;const n=Fn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="delete")return!0;const i=dy(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function p8(t,e){var o;const n=Fn(t,e);if(!n)return!0;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="insert")return!0;const i=dy(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function m8(t,e){var o,l;const n=Fn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((o=r.attrs)==null?void 0:o.pendingStatus)!=="rewrite")return!0;const i=(l=r.attrs)==null?void 0:l.pendingOriginalContent;if(i)t.chain().deleteRange({from:s,to:s+r.nodeSize}).insertContentAt(s,i).run();else{const d=dy(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(d).run()}return!0}function g8(t,e){var i;const n=Fn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return((i=r.attrs)==null?void 0:i.pendingStatus)!=="delete"||t.chain().command(({tr:o})=>(o.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function v8(t,e){const n=nf(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=Fn(t,r.nodeId);s&&t.chain().command(({tr:i})=>(i.setNodeMarkup(s.pos,void 0,{...s.node.attrs,pendingStatus:null,pendingOriginalContent:null,pendingGroupId:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run()}return!0}function y8(t,e){var l;const n=nf(t,e);if(n.length===0)return!1;const r=(l=n[0].node.attrs)==null?void 0:l.pendingOriginalContent,s=n[0].pos,i=n[n.length-1],o=i.pos+i.node.nodeSize;try{return r&&Array.isArray(r)&&r.length>0?t.chain().deleteRange({from:s,to:o}).insertContentAt(s,r).run():t.chain().deleteRange({from:s,to:o}).run(),!0}catch{return!1}}function qT(t,e){var i,o;const n=Fn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return v8(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return d8(t,e);case"rewrite":return f8(t,e);case"delete":return h8(t,e);default:return!1}}function KT(t,e){var i,o;const n=Fn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return y8(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return p8(t,e);case"rewrite":return m8(t,e);case"delete":return g8(t,e);default:return!1}}function b8(t){const e=GT(t).reverse();for(const n of e)qT(t,n);t.view&&ly(t.view)}function x8(t){const e=GT(t).reverse();for(const n of e)KT(t,n);t.view&&ly(t.view)}function fy(t){const e=[],n=new Set;return t.state.doc.descendants((r,s)=>{var o,l,d;const i=(o=r.attrs)==null?void 0:o.pendingStatus;if(i&&((l=r.attrs)!=null&&l.id)){const f=(d=r.attrs)==null?void 0:d.pendingGroupId;if(f){if(n.has(f))return!0;n.add(f)}e.push({nodeId:r.attrs.id,pos:s,pendingStatus:i,groupId:f,editor:t})}return!0}),e}function Pp(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...fy(n));return e}function GT(t){return fy(t).map(e=>e.nodeId)}function w8(t){let e=0,n=0,r=0;for(const s of t)s.pendingStatus==="insert"?e++:s.pendingStatus==="rewrite"?n++:s.pendingStatus==="delete"&&r++;return{insert:e,rewrite:n,delete:r,total:t.length}}function nl(t,e){if(t.isDestroyed)return;let n=-1;if(t.state.doc.descendants((i,o)=>{var l;return((l=i.attrs)==null?void 0:l.id)===e?(n=o,!1):!0}),n===-1)return;const r=t.view.nodeDOM(n),s=r instanceof HTMLElement?r:r==null?void 0:r.parentElement;if(s){s.scrollIntoView({behavior:"smooth",block:"center"});return}try{const i=t.view.coordsAtPos(n),o=t.view.dom.closest(".editor-container");if(o){const l=o.getBoundingClientRect(),d=i.top-l.top+o.scrollTop-o.clientHeight/2;o.scrollTo({top:d,behavior:"smooth"})}}catch{}}function k8(t){const[e,n]=b.useState([]),[r,s]=b.useState(0),i=b.useRef(),o=b.useRef(new Set),l=b.useCallback(()=>{const S=t.filter(R=>R&&!R.isDestroyed);if(S.length===0){n([]),o.current=new Set;return}const N=Pp(S);n(N);const T=o.current,M=new Set(N.map(R=>R.nodeId));let _=-1;if(T.size>0){for(let R=0;R<N.length;R++)if(!T.has(N[R].nodeId)){_=R;break}}o.current=M,_>=0?(s(_),nl(N[_].editor,N[_].nodeId)):N.length===0?s(0):s(R=>Math.min(R,N.length-1))},[t]);b.useEffect(()=>{const S=t.filter(M=>M&&!M.isDestroyed);if(S.length===0)return;const N=()=>{clearTimeout(i.current),i.current=setTimeout(l,50)};for(const M of S)M.on("transaction",N);l();const T=setTimeout(()=>{const M=Pp(S.filter(_=>!_.isDestroyed));M.length>0&&nl(M[0].editor,M[0].nodeId)},150);return()=>{for(const M of S)M.isDestroyed||M.off("transaction",N);clearTimeout(i.current),clearTimeout(T)}},[t,l]),b.useEffect(()=>{const S=e[r]??null;return lk((S==null?void 0:S.nodeId)??null,(S==null?void 0:S.groupId)??null),S!=null&&S.editor&&!S.editor.isDestroyed&&S.editor.view&&ly(S.editor.view),()=>{lk(null)}},[r,e]);const d=w8(e),f=e[r]??null,h=b.useCallback(()=>{if(e.length===0)return;const S=(r+1)%e.length;s(S),e[S]&&nl(e[S].editor,e[S].nodeId)},[e,r]),m=b.useCallback(()=>{if(e.length===0)return;const S=(r-1+e.length)%e.length;s(S),e[S]&&nl(e[S].editor,e[S].nodeId)},[e,r]),g=b.useCallback(()=>{const S=t.filter(M=>M&&!M.isDestroyed),N=Pp(S);if(N.length===0)return;const T=Math.min(r,N.length-1);nl(N[T].editor,N[T].nodeId)},[t,r]),v=b.useCallback(()=>{f&&(qT(f.editor,f.nodeId),l(),g())},[f,l,g]),x=b.useCallback(()=>{f&&(KT(f.editor,f.nodeId),l(),g())},[f,l,g]),k=b.useCallback(()=>{const S=t.filter(N=>N&&!N.isDestroyed);for(const N of S)b8(N);l()},[t,l]),w=b.useCallback(()=>{const S=t.filter(N=>N&&!N.isDestroyed);for(const N of S)x8(N);l()},[t,l]);return{pendingNodes:e,counts:d,currentNode:f,currentIndex:r,hasPending:d.total>0,goToNext:h,goToPrevious:m,acceptCurrent:v,rejectCurrent:x,acceptAll:k,rejectAll:w,refresh:l}}const JT="ow-review-scope";function S8(){try{return localStorage.getItem(JT)==="workspace"?"workspace":"all"}catch{return"all"}}function E8(t){try{localStorage.setItem(JT,t)}catch{}}function YT(t){if(!t)return[];const e=[];for(const n of t)n.type==="doc"&&n.file&&e.push(n.file),n.type==="container"&&n.items&&e.push(...YT(n.items));return e}function XT(t,e){if(!t)return!1;for(const n of t)if(n.type==="doc"&&n.file===e||n.type==="container"&&n.items&&XT(n.items,e))return!0;return!1}const Ii={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},N8=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...Ii})}),C8=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...Ii})}),_8=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...Ii})}),T8=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...Ii})}),j8=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...Ii})}),M8=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[c.jsx("path",{d:"M1 8.5l3.5 3.5L11 5",stroke:"currentColor",...Ii}),c.jsx("path",{d:"M8 12l.5.5L15 6",stroke:"currentColor",...Ii})]}),Fk=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...Ii})});function QT(t,e,n){const r=Fn(t,e);if(!r)return!1;const{pos:s,node:i}=r,o={type:n.type||i.type.name,attrs:{...n.attrs||{},id:i.attrs.id,pendingStatus:i.attrs.pendingStatus,pendingOriginalContent:i.attrs.pendingOriginalContent,pendingSelectionFrom:i.attrs.pendingSelectionFrom,pendingSelectionTo:i.attrs.pendingSelectionTo,pendingOriginalFrom:i.attrs.pendingOriginalFrom,pendingOriginalTo:i.attrs.pendingOriginalTo},content:n.content};try{return t.chain().command(({tr:l})=>(l.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:s+i.nodeSize}).insertContentAt(s,o).run(),!0}catch{return!1}}function ZT(t,e,n){const r=nf(t,e);if(r.length===0)return!1;const s=r[0].pos,i=r[r.length-1].pos+r[r.length-1].node.nodeSize;try{return t.chain().command(({tr:o})=>(o.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:i}).insertContentAt(s,n).run(),!0}catch{return!1}}function Eu(t,e){if(!ay()||!e)return!1;const n=_5();return C5()&&n&&Array.isArray(n)?ZT(t,e,n):n&&QT(t,e,n),ll(!1),!0}function A8(t,e){return t.indexOf(e)}function R8({editors:t,pendingDocs:e,currentFilename:n,docId:r,pendingTitle:s,onSwitchDocument:i,sendMessage:o,getDocument:l,docVersionRef:d}){const{counts:f,currentNode:h,currentIndex:m,hasPending:g,goToNext:v,goToPrevious:x,acceptCurrent:k,rejectCurrent:w,acceptAll:S,rejectAll:N}=k8(t),[T,M]=b.useState(s?"title":"body");b.useEffect(()=>{s&&T!=="title"&&f.total===0?M("title"):!s&&T==="title"&&M("body")},[s,f.total,T]);const _=!!s,R=f.total+(_?1:0),I=T==="title"?0:(_?1:0)+m,[$,P]=b.useState(!1);b.useEffect(()=>{T!=="title"&&P(!1)},[T]),b.useEffect(()=>{const Le=!!s&&T==="title",ve={docId:r,titleFocused:Le,titleShowOriginal:Le&&$};return window.dispatchEvent(new CustomEvent("ow-pending-review-cursor",{detail:ve})),()=>{window.dispatchEvent(new CustomEvent("ow-pending-review-cursor",{detail:{docId:r,titleFocused:!1,titleShowOriginal:!1}}))}},[r,s,T,$]);const z=b.useCallback(()=>{r&&o({type:"accept-pending-title",docId:r})},[r,o]),q=b.useCallback(()=>{r&&o({type:"reject-pending-title",docId:r})},[r,o]),F=b.useRef(null),G=b.useRef(null),[B,W]=b.useState(()=>S8()),[K,ne]=b.useState([]);b.useEffect(()=>{let Le=!1;async function ve(){try{const Q=await(await fetch("/api/workspaces")).json();if(!Array.isArray(Q))return;const de=await Promise.all(Q.map(async fe=>{try{const Ie=await(await fetch(`/api/workspaces/${encodeURIComponent(fe.filename)}`)).json();return{...fe,workspace:Ie}}catch{return fe}}));Le||ne(de)}catch{}}ve();const te=()=>ve();return window.addEventListener("ow-workspaces-changed",te),()=>{Le=!0,window.removeEventListener("ow-workspaces-changed",te)}},[]);const V=b.useMemo(()=>{var ve;if(K.length===0||!n)return null;const Le=K.find(te=>{var je;return XT((je=te.workspace)==null?void 0:je.root,n)});return Le?new Set(YT((ve=Le.workspace)==null?void 0:ve.root)):null},[K,n]),oe=b.useMemo(()=>B==="all"||!V?e.filenames:e.filenames.filter(Le=>V.has(Le)),[B,e.filenames,V]),J=b.useCallback(Le=>{W(Le),E8(Le)},[]),A=oe.length,L=A8(oe,n),ee=(h==null?void 0:h.pendingStatus)==="rewrite",pe=!!(h!=null&&h.groupId),xe=ee,re=b.useCallback(()=>{var ve,te;const Le=h==null?void 0:h.editor;if(!(!Le||!h||h.pendingStatus!=="rewrite"))if($)G.current&&Eu(G.current,F.current),F.current=null,G.current=null,P(!1);else if(pe&&h.groupId){const je=nf(Le,h.groupId);if(je.length===0)return;const Q=(ve=je[0].node.attrs)==null?void 0:ve.pendingOriginalContent;if(!Q||!Array.isArray(Q))return;const de=je.map(Ie=>Ie.node.toJSON()),fe=Q.map((Ie,it)=>({...Ie,attrs:{...Ie.attrs||{},pendingStatus:"rewrite",pendingGroupId:h.groupId,...it===0?{pendingOriginalContent:Q}:{}}}));if(ll(!0,h.nodeId,de,h.groupId),!ZT(Le,h.groupId,fe)){ll(!1);return}F.current=h.nodeId,G.current=Le,P(!0)}else{const je=Fn(Le,h.nodeId);if(!je)return;const{node:Q}=je,de=(te=Q.attrs)==null?void 0:te.pendingOriginalContent;if(!de)return;const fe=Q.toJSON();if(ll(!0,h.nodeId,fe),!QT(Le,h.nodeId,de)){ll(!1);return}F.current=h.nodeId,G.current=Le,P(!0)}},[h,$,pe]);b.useEffect(()=>{if(!$)return;const Le=F.current,ve=G.current;Le&&ve&&(h==null?void 0:h.nodeId)!==Le&&(Eu(ve,Le),F.current=null,G.current=null,P(!1))},[h==null?void 0:h.nodeId,$]),b.useEffect(()=>{if(t.length!==0)return()=>{ay()&&F.current&&G.current&&(Eu(G.current,F.current),F.current=null,G.current=null)}},[t]);const Ne=b.useCallback(Le=>{if(!n)return;if(!t.some(te=>!te||te.isDestroyed?!1:fy(te).length>0)){const te=l==null?void 0:l();te&&o({type:"doc-update",document:te,filename:n,version:(d==null?void 0:d.current)??0}),o({type:"pending-resolved",filename:n,action:Le})}},[t,n,o,l,d]),ke=b.useCallback(()=>{G.current&&$&&F.current&&(Eu(G.current,F.current),F.current=null,G.current=null,P(!1))},[$]),ze=b.useCallback(()=>{if(T==="title"&&s){z(),f.total>0&&M("body");return}ke(),k(),Ne("accept")},[T,s,z,f.total,ke,k,Ne]),Fe=b.useCallback(()=>{if(T==="title"&&s){q(),f.total>0&&M("body");return}ke(),w(),Ne("reject")},[T,s,q,f.total,ke,w,Ne]),Ge=b.useCallback(()=>{ke(),s&&z(),S(),Ne("accept")},[ke,s,z,S,Ne]);b.useEffect(()=>{const Le=()=>Ge();return window.addEventListener("ow-accept-all",Le),()=>window.removeEventListener("ow-accept-all",Le)},[Ge]);const Re=b.useCallback(()=>{ke(),s&&q(),N(),Ne("reject")},[ke,s,q,N,Ne]),Ze=b.useCallback(()=>{if(!(R<=1)){if(T==="title"){M("body");return}if(_&&m>=f.total-1){v(),M("title");return}v()}},[R,T,_,m,f.total,v]),gt=b.useCallback(()=>{if(!(R<=1)){if(T==="title"){x(),M("body");return}if(_&&m===0){M("title");return}x()}},[R,T,_,m,x]),ht=b.useCallback(()=>{if(A===0||A===1&&L===0)return;const Le=L<=0?A-1:L-1;i(oe[Le])},[A,L,oe,i]),ge=b.useCallback(()=>{if(A===0||A===1&&L===0)return;const Le=L>=A-1?0:L+1;i(oe[Le])},[A,L,oe,i]);b.useEffect(()=>{if(!g&&!s)return;const Le=ve=>{if(!(ve.target instanceof HTMLInputElement||ve.target instanceof HTMLTextAreaElement)&&!(ve.target instanceof HTMLElement&&ve.target.closest("[contenteditable]")))switch(ve.key){case"j":case"ArrowDown":!ve.metaKey&&!ve.ctrlKey&&(ve.preventDefault(),Ze());break;case"k":case"ArrowUp":!ve.metaKey&&!ve.ctrlKey&&(ve.preventDefault(),gt());break;case"h":case"ArrowLeft":!ve.metaKey&&!ve.ctrlKey&&!ve.altKey&&(ve.preventDefault(),ht());break;case"l":case"ArrowRight":!ve.metaKey&&!ve.ctrlKey&&!ve.altKey&&(ve.preventDefault(),ge());break;case"a":!ve.metaKey&&!ve.ctrlKey&&!ve.shiftKey&&(ve.preventDefault(),ze());break;case"r":!ve.metaKey&&!ve.ctrlKey&&(ve.preventDefault(),Fe());break;case"A":ve.shiftKey&&!ve.metaKey&&!ve.ctrlKey&&(ve.preventDefault(),Ge());break;case"R":ve.shiftKey&&!ve.metaKey&&!ve.ctrlKey&&(ve.preventDefault(),Re());break;case"o":!ve.metaKey&&!ve.ctrlKey&&!ve.shiftKey&&(ve.preventDefault(),T==="title"?P(te=>!te):re());break}};return window.addEventListener("keydown",Le),()=>window.removeEventListener("keydown",Le)},[g,s,Ze,gt,ht,ge,ze,Fe,Ge,Re,re]);const vt=L>=0?`${L+1} / ${A}`:`— / ${A}`,_t=e.filenames.length,Et=!V,ot=_t>0?c.jsxs("div",{className:"review-tab__section",children:[c.jsx("div",{className:"review-tab__section-label",children:"Scope"}),c.jsxs("div",{className:"review-tab__toggle",children:[c.jsx("button",{type:"button",className:`review-panel__toggle-btn${B==="all"?" review-panel__toggle-btn--active":""}`,onClick:()=>J("all"),title:"Cycle every pending doc in the profile",children:"All"}),c.jsx("button",{type:"button",className:`review-panel__toggle-btn${B==="workspace"?" review-panel__toggle-btn--active":""}`,onClick:()=>!Et&&J("workspace"),disabled:Et,title:Et?"Current doc is not in a workspace":"Only cycle pending docs in this workspace",children:"Workspace"})]})]}):null;return!g&&!s?c.jsxs("div",{className:"review-tab__empty",children:[c.jsx("div",{className:"review-tab__empty-title",children:"All caught up"}),c.jsx("div",{className:"review-tab__empty-note",children:"No pending agent changes. New writes from agents will land here for review."})]}):c.jsxs("div",{className:"review-tab",children:[ot,A>1&&c.jsxs("div",{className:"review-tab__section",children:[c.jsx("div",{className:"review-tab__section-label",children:"Document"}),c.jsxs("div",{className:"review-tab__row",children:[c.jsx("button",{className:"review-panel__btn",onClick:ht,title:"Previous doc (h)",children:c.jsx(N8,{})}),c.jsx("button",{className:"review-panel__btn",onClick:ge,title:"Next doc (l)",children:c.jsx(C8,{})}),c.jsx("span",{className:"review-panel__counter",children:vt})]})]}),c.jsx("div",{className:"review-tab__section review-tab__section--actions",children:c.jsxs("div",{className:"review-tab__toggle",children:[c.jsx("button",{className:`review-panel__toggle-btn${(xe||T==="title")&&!$?" review-panel__toggle-btn--active":""}`,onClick:()=>{T==="title"?$&&P(!1):xe&&$&&re()},disabled:!xe&&T!=="title",title:"Show modified (o)",children:"Modified"}),c.jsx("button",{className:`review-panel__toggle-btn${(xe||T==="title")&&$?" review-panel__toggle-btn--active":""}`,onClick:()=>{T==="title"?$||P(!0):xe&&!$&&re()},disabled:!xe&&T!=="title",title:"Show original (o)",children:"Original"})]})}),c.jsxs("div",{className:"review-tab__section",children:[c.jsx("div",{className:"review-tab__section-label",children:T==="title"?"Title":"Change"}),c.jsxs("div",{className:"review-tab__row",children:[c.jsx("button",{className:"review-panel__btn",onClick:gt,disabled:R<=1,title:"Previous (k)",children:c.jsx(_8,{})}),c.jsx("button",{className:"review-panel__btn",onClick:Ze,disabled:R<=1,title:"Next (j)",children:c.jsx(T8,{})}),c.jsxs("span",{className:"review-panel__counter",children:[I+1," / ",R]})]})]}),c.jsx("div",{className:"review-tab__section",children:c.jsxs("div",{className:"review-tab__row",children:[c.jsxs("button",{className:"review-tab__judge-btn review-tab__judge-btn--accept",onClick:ze,title:"Accept (a)",children:[c.jsx(j8,{}),c.jsx("span",{children:"Accept"})]}),c.jsxs("button",{className:"review-tab__judge-btn review-tab__judge-btn--reject",onClick:Fe,title:"Reject (r)",children:[c.jsx(Fk,{}),c.jsx("span",{children:"Reject"})]})]})}),c.jsx("div",{className:"review-tab__section",children:c.jsxs("div",{className:"review-tab__row",children:[c.jsxs("button",{className:"review-tab__bulk-btn review-tab__bulk-btn--accept",onClick:Ge,title:"Accept all (Shift+A)",children:[c.jsx(M8,{}),c.jsx("span",{children:"Accept all"})]}),c.jsxs("button",{className:"review-tab__bulk-btn review-tab__bulk-btn--reject",onClick:Re,title:"Reject all (Shift+R)",children:[c.jsx(Fk,{}),c.jsx("span",{children:"Reject all"})]})]})})]})}const O8={"agent-finished":"Agent finished",accept:"Accepted",manual:"Saved"};function I8(t){const e=Date.now()-t,n=Math.floor(e/1e3);if(n<60)return"Just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const i=Math.floor(s/24);return i<7?`${i}d ago`:new Date(t).toLocaleDateString()}function zk(t){return t==="human"?"you":t}function L8({docId:t}){const[e,n]=b.useState([]),[r,s]=b.useState(null),[i,o]=b.useState(!1),l=b.useCallback(()=>{if(!t){n([]);return}fetch(`/api/commits/${t}`).then(h=>h.ok?h.json():{commits:[]}).then(h=>n(Array.isArray(h.commits)?h.commits:[])).catch(()=>n([]))},[t]);b.useEffect(()=>{l()},[l]);const d=b.useCallback(async()=>{if(!t||i)return;const h=window.prompt('Save version — optional note (e.g. "first full draft"):')??void 0;o(!0);try{(await(await fetch("/api/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({docId:t,note:h||void 0})})).json().catch(()=>({}))).committed||window.setTimeout(()=>{},0),l()}catch{}o(!1)},[t,i,l]),f=b.useCallback(async h=>{if(!i){o(!0);try{(await fetch(`/api/versions/${h}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"full"})})).ok&&l()}catch{}o(!1)}},[i,l]);return c.jsxs("div",{className:"versions-tab",children:[c.jsx("div",{className:"versions-tab__actions",children:c.jsx("button",{className:"versions-tab__save-btn",disabled:!t||i,onClick:d,children:"+ Save version"})}),c.jsx("div",{className:"versions-tab__list",children:e.length===0?c.jsx("div",{className:"versions-tab__empty",children:'No versions yet. A version is committed when an agent finishes writing, when you accept changes, or when you hit "Save version."'}):e.map(h=>c.jsxs("div",{className:`commit-row${r===h.ts?" commit-row--expanded":""}`,onClick:()=>s(r===h.ts?null:h.ts),children:[c.jsxs("div",{className:"commit-row__head",children:[c.jsx("span",{className:"commit-row__time",children:I8(h.ts)}),c.jsx("span",{className:"commit-row__authors",children:h.actors.map(m=>c.jsx("span",{className:`commit-badge commit-badge--${m}`,children:zk(m)},m))})]}),c.jsx("div",{className:"commit-row__label",children:h.label}),h.note&&c.jsxs("div",{className:"commit-row__note",children:["“",h.note,"”"]}),r===h.ts&&c.jsxs("div",{className:"commit-row__detail",onClick:m=>m.stopPropagation(),children:[c.jsx("div",{className:"commit-row__trigger",children:O8[h.trigger]??h.trigger}),c.jsx("ul",{className:"commit-row__breakdown",children:Object.keys(h.summary.byActor).map(m=>{const g=h.summary.byActor[m];return c.jsxs("li",{children:[c.jsx("span",{className:`commit-badge commit-badge--${m}`,children:zk(m)}),g.added>0&&c.jsxs("span",{children:[" ",g.added," added"]}),g.edited>0&&c.jsxs("span",{children:[" ",g.edited," edited"]}),g.removed>0&&c.jsxs("span",{children:[" ",g.removed," removed"]})]},m)})}),c.jsx("button",{className:"commit-row__restore",disabled:i||!h.restorable,title:h.restorable?"Restore the document to this version":"Snapshot pruned — cannot restore",onClick:()=>f(h.snapshotTs),children:"Restore this version"})]})]},h.ts))})]})}function D8({docId:t,currentFilename:e,onSwitchDocument:n}){const[r,s]=b.useState(new Map),[i,o]=b.useState([]),[l,d]=b.useState([]),[f,h]=b.useState(!0),[m,g]=b.useState(!1);b.useEffect(()=>{let w=!1;const S=async()=>{try{const M=await(await fetch("/api/documents")).json();if(w)return;const _=new Map;if(Array.isArray(M))for(const R of M)R!=null&&R.docId&&_.set(R.docId,{docId:R.docId,filename:R.filename,title:R.title||R.filename});s(_)}catch{}finally{w||h(!1)}};S();const N=()=>S();return window.addEventListener("ow-documents-changed",N),()=>{w=!0,window.removeEventListener("ow-documents-changed",N)}},[]),b.useEffect(()=>{if(!t){o([]);return}let w=!1;const S=()=>{g(!0),fetch(`/api/backlinks/${t}`).then(T=>T.ok?T.json():[]).then(T=>{w||o(Array.isArray(T)?T:[])}).catch(()=>{w||o([])}).finally(()=>{w||g(!1)})};S();const N=()=>S();return window.addEventListener("ow-metadata-changed",N),()=>{w=!0,window.removeEventListener("ow-metadata-changed",N)}},[t]),b.useEffect(()=>{let w=!1;const S=()=>{fetch("/api/document").then(T=>T.json()).then(T=>{var _;if(w)return;const M=(_=T==null?void 0:T.metadata)==null?void 0:_.references;d(Array.isArray(M)?M:[])}).catch(()=>{w||d([])})};S();const N=()=>S();return window.addEventListener("ow-metadata-changed",N),()=>{w=!0,window.removeEventListener("ow-metadata-changed",N)}},[e,t]);const v=b.useMemo(()=>i.map(w=>{const S=r.get(w.from_doc);return S?{docId:w.from_doc,title:S.title,filename:S.filename,snippet:w.text}:null}).filter(w=>w!==null),[i,r]),x=b.useMemo(()=>l.map(w=>{const S=r.get(w);return S?{docId:w,title:S.title,filename:S.filename}:null}).filter(w=>w!==null),[l,r]);if(!t)return c.jsxs("div",{className:"backlinks-tab__empty",children:[c.jsx("div",{className:"backlinks-tab__empty-title",children:"No document open"}),c.jsx("div",{className:"backlinks-tab__empty-note",children:"Open a doc to see what links to it and what it links out to."})]});const k=f||m;return c.jsxs("div",{className:"backlinks-tab",children:[c.jsxs("div",{className:"backlinks-tab__group",children:[c.jsxs("div",{className:"backlinks-tab__group-label",children:["Inbound ",c.jsx("span",{className:"backlinks-tab__count",children:v.length})]}),k&&v.length===0?c.jsx("div",{className:"backlinks-tab__empty-note backlinks-tab__inline-note",children:"Loading…"}):v.length===0?c.jsx("div",{className:"backlinks-tab__empty-note backlinks-tab__inline-note",children:"No docs link to this one yet."}):v.map(w=>c.jsxs("button",{type:"button",className:"backlinks-tab__entry",onClick:()=>n(w.filename),children:[c.jsx("div",{className:"backlinks-tab__entry-title",children:w.title}),w.snippet&&c.jsx("div",{className:"backlinks-tab__entry-snippet",children:w.snippet})]},w.docId))]}),c.jsxs("div",{className:"backlinks-tab__group",children:[c.jsxs("div",{className:"backlinks-tab__group-label",children:["Outbound ",c.jsx("span",{className:"backlinks-tab__count",children:x.length})]}),x.length===0?c.jsx("div",{className:"backlinks-tab__empty-note backlinks-tab__inline-note",children:"This doc doesn’t reference others yet."}):x.map(w=>c.jsx("button",{type:"button",className:"backlinks-tab__entry",onClick:()=>n(w.filename),children:c.jsx("div",{className:"backlinks-tab__entry-title",children:w.title})},w.docId))]})]})}const P8=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"16 18 22 12 16 6"}),c.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("path",{d:"M14 2v6h6"}),c.jsx("path",{d:"M16 13H8"}),c.jsx("path",{d:"M16 17H8"}),c.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M17 6.1H3"}),c.jsx("path",{d:"M21 12.1H3"}),c.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),c.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"}),c.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function B8(t){const e=n=>{if(n==="pdf"){window.open("/api/export?format=pdf","_blank");return}const r=document.createElement("a");r.href=`/api/export?format=${n}`,r.download="",document.body.appendChild(r),r.click(),document.body.removeChild(r)};return c.jsx("div",{className:"exports-tab",children:c.jsx("div",{className:"exports-tab__list",children:P8.map(n=>c.jsxs("button",{type:"button",className:"exports-tab__item",onClick:()=>e(n.key),children:[c.jsx("span",{className:"exports-tab__item-icon",children:n.icon}),c.jsxs("span",{className:"exports-tab__item-text",children:[c.jsx("span",{className:"exports-tab__item-label",children:n.label}),c.jsx("span",{className:"exports-tab__item-desc",children:n.desc})]})]},n.key))})})}const $8=3e4,F8=500;let ki={entries:[],freshKeys:new Set};const rv=new Set;function e2(t){return`${t.ts}:${t.kind}:${t.headline}`}function z8(){for(const t of rv)t(ki)}function sv(t){ki=t,z8()}function U8(t){return rv.add(t),()=>{rv.delete(t)}}function H8(){return ki}function W8(t){const e=t.detail;e!=null&&e.entries&&sv({entries:e.entries,freshKeys:new Set})}function V8(t){const e=t.detail;if(!(e!=null&&e.event))return;const n=e.event,r=e2(n),s={entries:[n,...ki.entries].slice(0,F8),freshKeys:new Set([...ki.freshKeys,r])};sv(s),window.setTimeout(()=>{if(ki.freshKeys.has(r)){const i=new Set(ki.freshKeys);i.delete(r),sv({...ki,freshKeys:i})}},$8)}typeof window<"u"&&(window.addEventListener("ow-activity-seed",W8),window.addEventListener("ow-activity-event",V8));function q8(){const[t,e]=b.useState(H8);return b.useEffect(()=>U8(e),[]),t}function K8(){const[t,e]=b.useState(()=>({byDocId:new Map,filenameSet:new Set}));return b.useEffect(()=>{let n=!1;const r=()=>{fetch("/api/documents").then(s=>s.json()).then(s=>{if(n||!Array.isArray(s))return;const i=new Map,o=new Set;for(const l of s)l.filename&&o.add(l.filename),l.docId&&l.filename&&i.set(l.docId,l.filename);e({byDocId:i,filenameSet:o})}).catch(()=>{})};return r(),window.addEventListener("ow-documents-changed",r),()=>{n=!0,window.removeEventListener("ow-documents-changed",r)}},[]),t}function G8(t,e){return t.docId?e.byDocId.get(t.docId)??null:t.filename&&e.filenameSet.has(t.filename)?t.filename:null}function J8(t,e){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const s=Math.floor(r/60);if(s<60)return`${s}m ago`;const i=Math.floor(s/60);if(i<24)return`${i}h ago`;const o=Math.floor(i/24);return o<7?`${o}d ago`:new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Y8({onSwitchDocument:t}){const{entries:e,freshKeys:n}=q8(),r=K8(),[s,i]=b.useState(()=>Date.now());b.useEffect(()=>{const l=setInterval(()=>i(Date.now()),3e4);return()=>clearInterval(l)},[]);const o=b.useMemo(()=>X8(e,s),[e,s]);return e.length===0?c.jsxs("div",{className:"activity-tab__empty",children:[c.jsx("div",{className:"activity-tab__empty-title",children:"No activity yet"}),c.jsx("div",{className:"activity-tab__empty-note",children:"Agent actions — writes, enrichment, backlink propagation — will appear here as they happen."})]}):c.jsx("div",{className:"activity-tab",children:o.map(l=>c.jsxs("div",{className:"activity-tab__group",children:[c.jsx("div",{className:"activity-tab__group-label",children:l.label}),l.entries.map(d=>{const f=e2(d),h=n.has(f),m=d.kind==="doc-deleted"?null:G8(d,r),g=m!==null,v=!g,x=v&&d.kind!=="doc-deleted"?"Doc no longer available":void 0,k=()=>{m&&t(m)};return c.jsxs("div",{className:`activity-tab__entry${h?" activity-tab__entry--fresh":""}${g?" activity-tab__entry--clickable":""}${v?" activity-tab__entry--muted":""}`,role:g?"button":void 0,tabIndex:g?0:void 0,title:x,onClick:k,onKeyDown:w=>{g&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),k())},children:[c.jsx("span",{className:`activity-tab__kind-dot activity-tab__kind-dot--${d.kind}`,"aria-hidden":"true"}),c.jsxs("div",{className:"activity-tab__entry-body",children:[c.jsx("div",{className:"activity-tab__headline",children:d.headline}),d.detail&&c.jsx("div",{className:"activity-tab__detail",children:d.detail})]}),c.jsx("div",{className:"activity-tab__ts",title:new Date(d.ts).toLocaleString(),children:J8(d.ts,s)})]},f)})]},l.label))})}function X8(t,e){if(t.length===0)return[];const n=Uk(e),r=n-1440*60*1e3,s=[];let i=null;for(const o of t){const l=Uk(o.ts);let d;l===n?d="Today":l===r?d="Yesterday":d=new Date(o.ts).toLocaleDateString(void 0,{weekday:"long",month:"short",day:"numeric"}),(!i||i.label!==d)&&(i={label:d,entries:[]},s.push(i)),i.entries.push(o)}return s}function Uk(t){const e=new Date(t);return e.setHours(0,0,0,0),e.getTime()}async function Nu(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();if((i=(s=r==null?void 0:r.content)==null?void 0:s[0])!=null&&i.text)try{return JSON.parse(r.content[0].text)}catch{return r.content[0].text}return r}function Q8(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[s,i]=b.useState("closed"),[o,l]=b.useState(""),[d,f]=b.useState(!1),[h,m]=b.useState(null),[g,v]=b.useState(null),[x,k]=b.useState(null),w=b.useCallback(async()=>{r(!0);try{const _=await Nu("list_blog_sites");e((_==null?void 0:_.sites)||[])}finally{r(!1)}},[]);b.useEffect(()=>{w()},[w]);const S=()=>{i("closed"),l(""),m(null),v(null),k(null)},N=async()=>{if(o.trim()){f(!0),m(null);try{const _=await Nu("inspect_blog_repo",{repo_url:o.trim()});if(_.error){m(_.error);return}v({..._,label:_.repo,branch:"main",site_url:_.site_url||"",blog_url_pattern:_.blog_url_pattern||"/blog/{slug}/"}),i("review")}catch(_){m((_==null?void 0:_.message)||"Inspection failed")}finally{f(!1)}}},T=async()=>{if(g){i("saving"),k(null);try{const _=await Nu("add_blog_site",{label:g.label,owner:g.owner,repo:g.repo,branch:g.branch||"main",content_dir:g.content_dir,image_dir:g.image_dir,image_public_prefix:g.image_public_prefix,framework:g.framework,frontmatter_defaults:g.frontmatter_defaults||{},frontmatter_field_map:g.frontmatter_field_map||{},frontmatter_schema:g.frontmatter_schema||[],site_url:g.site_url||"",blog_url_pattern:g.blog_url_pattern||"/blog/{slug}/"});if(_!=null&&_.error){k(_.error),i("review");return}S(),await w()}catch(_){k((_==null?void 0:_.message)||"Save failed"),i("review")}}},M=async _=>{if(!window.confirm(`Remove "${_.label}" (${_.owner}/${_.repo})?
209
-
210
- This only removes the OpenWriter registration. Your GitHub repo is untouched.`))return;const I=await Nu("remove_blog_site",{id:_.id});if(I!=null&&I.error){alert(`Remove failed: ${I.error}`);return}await w()};return c.jsxs("div",{className:"github-plugin-settings",children:[c.jsxs("div",{className:"github-plugin-settings__header",children:[c.jsx("span",{className:"github-plugin-settings__title",children:"Blog repos"}),s==="closed"&&c.jsx("button",{className:"github-plugin-settings__add-btn",onClick:()=>i("url"),children:"+ Add"})]}),n?c.jsx("div",{className:"github-plugin-settings__loading",children:"Loading…"}):t.length===0&&s==="closed"?c.jsxs("div",{className:"github-plugin-settings__empty",children:["Connect a GitHub repo to publish blog posts via local git — no PATs, no Workers. Uses your existing ",c.jsx("code",{children:"gh auth login"}),"."]}):c.jsx("div",{className:"github-plugin-settings__list",children:t.map(_=>c.jsxs("div",{className:"github-plugin-settings__site",children:[c.jsxs("div",{className:"github-plugin-settings__site-info",children:[c.jsxs("div",{className:"github-plugin-settings__site-row1",children:[c.jsx("span",{className:"github-plugin-settings__site-label",children:_.label}),c.jsx("span",{className:`github-plugin-settings__site-framework github-plugin-settings__site-framework--${_.framework}`,children:_.framework})]}),c.jsxs("div",{className:"github-plugin-settings__site-repo",children:[_.owner,"/",_.repo,"@",_.branch]}),c.jsxs("div",{className:"github-plugin-settings__site-dirs",children:[c.jsx("span",{title:"content_dir",children:_.content_dir}),c.jsx("span",{className:"github-plugin-settings__site-sep",children:"·"}),c.jsx("span",{title:"image_public_prefix",children:_.image_public_prefix})]})]}),c.jsx("button",{className:"github-plugin-settings__remove-btn",onClick:()=>M(_),title:"Remove",children:"×"})]},_.id))}),s==="url"&&c.jsxs("div",{className:"github-plugin-settings__form",children:[c.jsx("label",{className:"github-plugin-settings__label",children:"GitHub repo"}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",placeholder:"owner/repo or https://github.com/owner/repo",value:o,onChange:_=>l(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!d&&N()},autoFocus:!0}),h&&c.jsx("div",{className:"github-plugin-settings__error",children:h}),c.jsxs("div",{className:"github-plugin-settings__form-buttons",children:[c.jsx("button",{className:"github-plugin-settings__btn github-plugin-settings__btn--primary",onClick:N,disabled:d||!o.trim(),children:d?"Inspecting…":"Inspect"}),c.jsx("button",{className:"github-plugin-settings__btn",onClick:S,disabled:d,children:"Cancel"})]})]}),(s==="review"||s==="saving")&&g&&c.jsxs("div",{className:"github-plugin-settings__form",children:[c.jsxs("div",{className:"github-plugin-settings__form-meta",children:[c.jsxs("span",{children:["Detected: ",g.framework]}),c.jsx("span",{children:"·"}),c.jsxs("span",{children:[g.markdown_files_found," posts"]}),c.jsx("span",{children:"·"}),c.jsxs("span",{className:`github-plugin-settings__confidence github-plugin-settings__confidence--${g.confidence}`,children:[g.confidence," confidence"]})]}),c.jsx("label",{className:"github-plugin-settings__label",children:"Label"}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.label,onChange:_=>v({...g,label:_.target.value})}),c.jsx("label",{className:"github-plugin-settings__label",children:"Branch"}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.branch,onChange:_=>v({...g,branch:_.target.value})}),c.jsx("label",{className:"github-plugin-settings__label",children:"Content directory"}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.content_dir,onChange:_=>v({...g,content_dir:_.target.value})}),c.jsx("label",{className:"github-plugin-settings__label",children:"Image directory"}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.image_dir,onChange:_=>v({...g,image_dir:_.target.value})}),c.jsx("label",{className:"github-plugin-settings__label",children:"Image public prefix"}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",value:g.image_public_prefix,onChange:_=>v({...g,image_public_prefix:_.target.value})}),c.jsxs("label",{className:"github-plugin-settings__label",children:["Site URL ",c.jsx("span",{className:"github-plugin-settings__hint",children:"— optional, used for the live link after publish"})]}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",placeholder:"https://example.com",value:g.site_url||"",onChange:_=>v({...g,site_url:_.target.value})}),c.jsxs("label",{className:"github-plugin-settings__label",children:["Blog URL pattern ",c.jsxs("span",{className:"github-plugin-settings__hint",children:["— uses ","{slug}"," placeholder"]})]}),c.jsx("input",{className:"github-plugin-settings__input",type:"text",placeholder:"/blog/{slug}/",value:g.blog_url_pattern||"",onChange:_=>v({...g,blog_url_pattern:_.target.value})}),c.jsx("label",{className:"github-plugin-settings__label",children:"Framework"}),c.jsxs("select",{className:"github-plugin-settings__input",value:g.framework,onChange:_=>v({...g,framework:_.target.value}),children:[c.jsx("option",{value:"astro",children:"Astro"}),c.jsx("option",{value:"next",children:"Next"}),c.jsx("option",{value:"jekyll",children:"Jekyll"}),c.jsx("option",{value:"hugo",children:"Hugo"}),c.jsx("option",{value:"unknown",children:"Unknown"})]}),g.frontmatter_schema.length>0&&c.jsxs("div",{className:"github-plugin-settings__schema",children:[c.jsxs("span",{className:"github-plugin-settings__label",children:["Frontmatter keys detected (",g.samples_analyzed," ",g.samples_analyzed===1?"sample":"samples",")"]}),c.jsx("code",{children:g.frontmatter_schema.join(", ")})]}),Object.keys(g.frontmatter_defaults||{}).length>0&&c.jsxs("div",{className:"github-plugin-settings__schema",children:[c.jsx("span",{className:"github-plugin-settings__label",children:"Frontmatter defaults (constants applied to every post)"}),c.jsx("code",{children:Object.entries(g.frontmatter_defaults).map(([_,R])=>c.jsxs("div",{children:[_,": ",typeof R=="string"?R:JSON.stringify(R)]},_))})]}),Object.keys(g.frontmatter_field_map||{}).length>0&&c.jsxs("div",{className:"github-plugin-settings__schema",children:[c.jsx("span",{className:"github-plugin-settings__label",children:"Field name mapping (openwriter → site)"}),c.jsx("code",{children:Object.entries(g.frontmatter_field_map).map(([_,R])=>c.jsxs("div",{children:[_," → ",R]},_))})]}),x&&c.jsx("div",{className:"github-plugin-settings__error",children:x}),c.jsxs("div",{className:"github-plugin-settings__form-buttons",children:[c.jsx("button",{className:"github-plugin-settings__btn github-plugin-settings__btn--primary",onClick:T,disabled:s==="saving"||!g.label.trim(),children:s==="saving"?"Saving…":"Add site"}),c.jsx("button",{className:"github-plugin-settings__btn",onClick:S,disabled:s==="saving",children:"Cancel"})]})]})]})}const Z8={none:"No Plan",free:"No Plan",creator:"Publish — $19/mo",growth:"Publish+Email — $49/mo"},eF=[{plan:"creator",label:"Publish $19/mo"},{plan:"growth",label:"Publish+Email $49/mo"}];function tF(){var d,f;const[t,e]=b.useState(null),[n,r]=b.useState(!0);b.useEffect(()=>{fetch("/api/billing").then(h=>h.json()).then(h=>e(h)).catch(()=>{}).finally(()=>r(!1))},[]);const s=b.useCallback(async h=>{const m=await fetch("/api/billing/checkout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:h})});if(m.ok){const g=await m.json();g.url&&window.open(g.url,"_blank")}},[]),i=b.useCallback(async()=>{const h=await fetch("/api/billing/portal",{method:"POST",headers:{"Content-Type":"application/json"}});if(h.ok){const m=await h.json();m.url&&window.open(m.url,"_blank")}},[]);if(n)return c.jsx("div",{className:"billing-section",children:c.jsx("div",{className:"billing-loading",children:"Loading..."})});if(!(t!=null&&t.authenticated))return null;const o=t.plan||"free",l=eF.filter(h=>{const m=["free","creator","growth"];return m.indexOf(h.plan)>m.indexOf(o)});return c.jsxs("div",{className:"billing-section",children:[c.jsxs("div",{className:"billing-plan",children:[c.jsx("span",{className:"billing-plan-label",children:"Plan"}),c.jsx("span",{className:`billing-plan-badge billing-plan-badge--${o}`,children:Z8[o]||o})]}),((d=t.billing)==null?void 0:d.paymentFailed)&&c.jsx("div",{className:"billing-warning",children:"Payment failed — update card to keep your plan."}),l.length>0&&c.jsx("div",{className:"billing-upgrades",children:l.map(h=>c.jsxs("button",{className:"billing-upgrade-btn",onClick:()=>s(h.plan),children:["Upgrade to ",h.label]},h.plan))}),((f=t.billing)==null?void 0:f.hasPaymentMethod)&&c.jsx("button",{className:"billing-manage-btn",onClick:i,children:"Manage Billing"})]})}const nF=[{label:"Fast",cost:"free"},{label:"Fast+",cost:"$"},{label:"Sonnet",cost:"$$"},{label:"Opus",cost:"$$$"}];function rF(){const[t,e]=b.useState(null),[n,r]=b.useState([]),[s,i]=b.useState(!0),[o,l]=b.useState(!1),d=b.useCallback(()=>{Promise.all([v$(),y$()]).then(([f,h])=>{f!=null&&f.wallet&&e(f.wallet.balanceCents),r(h)}).finally(()=>i(!1))},[]);return b.useEffect(()=>{d()},[d]),b.useEffect(()=>{const f=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",f),()=>document.removeEventListener("visibilitychange",f)},[d]),s?c.jsx("div",{className:"billing-section",children:c.jsx("div",{className:"billing-loading",children:"Loading…"})}):t===null&&n.length===0?null:c.jsxs("div",{className:"billing-section",children:[c.jsxs("div",{className:"billing-plan",children:[c.jsx("span",{className:"billing-plan-label",children:"Balance"}),c.jsx("span",{className:"av-credits-balance",children:t===null?"—":g$(t)})]}),c.jsx("div",{className:"av-credits-legend",children:nF.map(f=>c.jsxs("span",{className:"av-credits-legend-item",children:[c.jsx("span",{className:"av-credits-model",children:f.label}),c.jsx("span",{className:"av-credits-cost",children:f.cost})]},f.label))}),n.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"av-credits-topup-toggle",onClick:()=>l(f=>!f),children:[c.jsx("svg",{className:`plugin-config-chevron${o?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Add balance"]}),o&&c.jsx("div",{className:"billing-upgrades",children:n.map(f=>c.jsxs("button",{className:"billing-upgrade-btn",onClick:()=>RT(f.amountDollars),children:["Add $",f.amountDollars]},f.priceId))})]})]})}function Hk(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function sF({status:t}){return t==="saving"?c.jsx("span",{className:"plugin-config-status plugin-config-status--saving",children:"Saving…"}):t==="saved"?c.jsxs("span",{className:"plugin-config-status plugin-config-status--saved",children:[c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Saved"]}):t==="error"?c.jsxs("span",{className:"plugin-config-status plugin-config-status--error",children:[c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#ef4444",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Failed"]}):null}function iF(t){const[e,n]=b.useState([]),[r,s]=b.useState(null),[i,o]=b.useState(new Set),[l,d]=b.useState({}),f=b.useCallback(()=>{fetch("/api/available-plugins").then(g=>g.json()).then(g=>n(g.plugins||[])).catch(()=>{})},[]);b.useEffect(()=>{f()},[f]),b.useEffect(()=>{const g=()=>f();return window.addEventListener("ow-plugins-changed",g),()=>window.removeEventListener("ow-plugins-changed",g)},[f]);const h=b.useCallback(async(g,v)=>{s(g);try{(await fetch(v?"/api/plugins/disable":"/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})})).ok&&f()}catch{}finally{s(null)}},[f]),m=b.useCallback(async(g,v,x)=>{const k=`${g}:${v}`;d(w=>({...w,[k]:"saving"}));try{const w=await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,config:{[v]:x}})});if(!w.ok)throw new Error(`save failed (${w.status})`);d(S=>({...S,[k]:"saved"})),setTimeout(()=>{d(S=>S[k]==="saved"?{...S,[k]:"idle"}:S)},2e3)}catch{d(w=>({...w,[k]:"error"}))}},[]);return c.jsx("div",{className:"plugins-tab",children:e.length===0?c.jsx("div",{className:"plugin-empty",children:"No plugins found"}):e.map(g=>c.jsxs("div",{className:"plugin-item",children:[c.jsxs("div",{className:"plugin-item-header",children:[c.jsxs("div",{className:"plugin-item-info",children:[c.jsxs("div",{className:"plugin-item-name",children:[Hk(g.name),c.jsxs("span",{className:"plugin-item-version",children:["v",g.version]})]}),g.description&&c.jsx("div",{className:"plugin-item-desc",children:g.description})]}),c.jsxs("label",{className:`plugin-toggle${r===g.name?" loading":""}`,children:[c.jsx("input",{type:"checkbox",checked:g.enabled,disabled:r===g.name,onChange:()=>h(g.name,g.enabled)}),c.jsx("span",{className:"plugin-toggle-track"}),c.jsx("span",{className:"plugin-toggle-thumb"})]})]}),g.enabled&&(()=>{const v=Object.entries(g.configSchema||{}),x=v.filter(([,T])=>T.type==="select"),k=v.filter(([,T])=>T.type!=="select"),w=v.some(([T,M])=>M.required&&!g.config[T]),S=g.name==="@openwriter/plugin-authors-voice"?c.jsx(rF,{}):g.name==="@openwriter/plugin-publish"?c.jsx(tF,{}):g.name==="@openwriter/plugin-github"?c.jsx(Q8,{}):null,N=(T,M)=>{const _=l[`${g.name}:${T}`]||"idle";return c.jsxs("div",{className:"plugin-config-field",children:[c.jsxs("label",{className:"plugin-config-label",children:[M.description||T,c.jsx(sF,{status:_})]}),M.options?c.jsxs("select",{className:"plugin-config-input",defaultValue:g.config[T]||"",onChange:R=>m(g.name,T,R.target.value),children:[!M.required&&!M.options.some(R=>R.value==="")&&c.jsx("option",{value:"",children:"—"}),M.options.map(R=>c.jsx("option",{value:R.value,children:R.label},R.value))]}):c.jsx("input",{className:"plugin-config-input",type:T.toLowerCase().includes("key")||T.toLowerCase().includes("secret")||T.toLowerCase().includes("token")?"password":"text",defaultValue:g.config[T]||"",placeholder:M.env?`$${M.env}`:"",onBlur:R=>m(g.name,T,R.target.value)})]},T)};return v.length===0&&!S?null:c.jsxs("div",{className:"plugin-config-section",children:[w&&c.jsxs("div",{className:"plugin-setup-hint",children:["Ask your agent: “set up ",Hk(g.name),"”"]}),x.length>0&&c.jsx("div",{className:"plugin-config",children:x.map(([T,M])=>N(T,M))}),S,k.length>0&&c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"plugin-config-toggle",onClick:()=>o(T=>{const M=new Set(T);return M.has(g.name)?M.delete(g.name):M.add(g.name),M}),children:[c.jsx("svg",{className:`plugin-config-chevron${i.has(g.name)?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),i.has(g.name)&&c.jsx("div",{className:"plugin-config",children:k.map(([T,M])=>N(T,M))})]})]})})()]},g.name))})}function oF({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=b.useState("form"),[i,o]=b.useState(null),[l,d]=b.useState((t==null?void 0:t.domain)||""),[f,h]=b.useState(""),[m,g]=b.useState((t==null?void 0:t.from_name)||""),[v,x]=b.useState(""),[k,w]=b.useState((t==null?void 0:t.id)||""),[S,N]=b.useState({dns_verified:!1,sender_verified:!1}),T=b.useRef(null),M=b.useRef(null);b.useEffect(()=>{const q=F=>{r!=="submitting"&&r!=="verifying"&&M.current&&!M.current.contains(F.target)&&e()};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[e,r]),b.useEffect(()=>{const q=F=>{F.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[e,r]),b.useEffect(()=>()=>{T.current&&clearInterval(T.current)},[]);async function _(){var q,F;s("submitting"),o(null);try{const B=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:l,from_email:f,from_name:m||void 0,physical_address:v}})})).json(),W=(F=(q=B.content)==null?void 0:q[0])!=null&&F.text?JSON.parse(B.content[0].text):B;if(W.error){o(W.error),s("error");return}const K=W.connectionId||W.connection_id||k;K&&w(K),I(K)}catch(G){o(G.message),s("error")}}async function R(){var q,F;s("submitting"),o(null);try{const B=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:l,from_email:f||void 0,from_name:m||void 0,physical_address:v||void 0}})})).json(),W=(F=(q=B.content)==null?void 0:q[0])!=null&&F.text?JSON.parse(B.content[0].text):B;if(W.error){o(W.error),s("error");return}s("done")}catch(G){o(G.message),s("error")}}function I(q){s("verifying"),T.current=setInterval(async()=>{var F,G;try{const W=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:q}})})).json(),K=(G=(F=W.content)==null?void 0:F[0])!=null&&G.text?JSON.parse(W.content[0].text):W,ne=!!K.dns_verified,V=!!K.sender_verified;N({dns_verified:ne,sender_verified:V}),ne&&V&&(T.current&&clearInterval(T.current),T.current=null,s("done"))}catch{}},5e3)}function $(){k&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:k}})}).catch(()=>{})}const P=!!t,z=l.trim()&&f.trim()&&v.trim();return c.jsx("div",{className:"newsletter-modal-overlay",children:c.jsxs("div",{className:"newsletter-modal newsletter-modal--setup",ref:M,children:[c.jsxs("div",{className:"newsletter-modal__header",children:[c.jsx("h3",{children:P?"Newsletter Settings":"Set Up Newsletter"}),c.jsx("button",{className:"newsletter-modal__close",onClick:e,children:"×"})]}),c.jsxs("div",{className:"newsletter-modal__body",children:[r==="form"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"newsletter-modal__field",children:[c.jsx("label",{className:"newsletter-modal__label",children:"Domain"}),c.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"yourdomain.com",value:l,onChange:q=>d(q.target.value),disabled:P,autoComplete:"off"})]}),c.jsxs("div",{className:"newsletter-modal__field",children:[c.jsx("label",{className:"newsletter-modal__label",children:"From Email"}),c.jsx("input",{className:"newsletter-modal__input",type:"email",placeholder:"newsletter@yourdomain.com",value:f,onChange:q=>h(q.target.value),autoComplete:"off"})]}),c.jsxs("div",{className:"newsletter-modal__field",children:[c.jsxs("label",{className:"newsletter-modal__label",children:["From Name ",c.jsx("span",{className:"newsletter-modal__optional",children:"(optional)"})]}),c.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"Your Name or Brand",value:m,onChange:q=>g(q.target.value),autoComplete:"off"})]}),c.jsxs("div",{className:"newsletter-modal__field",children:[c.jsxs("label",{className:"newsletter-modal__label",children:["Physical Address ",c.jsx("span",{className:"newsletter-modal__required",children:"*"})]}),c.jsx("textarea",{className:"newsletter-modal__input newsletter-modal__textarea",rows:2,placeholder:"123 Main St, City, State 12345",value:v,onChange:q=>x(q.target.value)}),c.jsx("span",{className:"newsletter-modal__hint",children:"Required by CAN-SPAM. Included in email footer."})]}),c.jsxs("div",{className:"newsletter-modal__actions",children:[c.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:P?R:_,disabled:!z,children:P?"Save":"Set Up Domain"})]})]}),r==="submitting"&&c.jsxs("div",{className:"newsletter-modal__status",children:[c.jsx("div",{className:"newsletter-modal__spinner"}),c.jsx("span",{children:P?"Saving...":"Setting up domain..."})]}),r==="verifying"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"newsletter-modal__verify",children:[c.jsx("p",{className:"newsletter-modal__verify-title",children:"Verifying domain setup..."}),c.jsxs("div",{className:"newsletter-modal__verify-checks",children:[c.jsxs("div",{className:`newsletter-modal__verify-item${S.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[S.dns_verified?"✓":c.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),c.jsx("span",{children:"DNS records"})]}),c.jsxs("div",{className:`newsletter-modal__verify-item${S.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[S.sender_verified?"✓":c.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),c.jsx("span",{children:"Sender verification"})]})]}),c.jsx("p",{className:"newsletter-modal__hint",children:"This may take a few minutes. You can close and check back later."})]}),c.jsxs("div",{className:"newsletter-modal__actions",children:[c.jsx("button",{className:"newsletter-modal__btn",onClick:$,children:"Resend Verification"}),c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Close"})]})]}),r==="done"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:P?"Settings saved!":"Newsletter domain configured!"}),c.jsx("div",{className:"newsletter-modal__actions",children:c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Done"})})]}),r==="error"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"newsletter-modal__error",children:i}),c.jsxs("div",{className:"newsletter-modal__actions",children:[c.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s("form"),children:"Try Again"})]})]})]})]})})}const aF={x:[],linkedin:[]};function lF({connectionId:t,provider:e,displayName:n,onClose:r,onSaved:s}){const[i,o]=b.useState("loading"),[l,d]=b.useState({}),[f,h]=b.useState(null),m=b.useRef(null),g=aF[e]||[];b.useEffect(()=>{fetch(`/api/connections/${t}/config`).then(k=>k.json()).then(k=>{d(k.config||{}),o("form")}).catch(k=>{h(k.message),o("error")})},[t]),b.useEffect(()=>{const k=w=>{i!=="saving"&&m.current&&!m.current.contains(w.target)&&r()};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[r,i]),b.useEffect(()=>{const k=w=>{w.key==="Escape"&&i!=="saving"&&r()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[r,i]);async function v(){o("saving"),h(null);try{const k=await fetch(`/api/connections/${t}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),w=await k.json();if(!k.ok)throw new Error(w.error||"Failed to save");o("saved"),s(),setTimeout(r,800)}catch(k){h(k.message),o("error")}}function x(k){switch(k){case"x":return"X (Twitter)";case"linkedin":return"LinkedIn";default:return k}}return c.jsx("div",{className:"conn-config-overlay",children:c.jsxs("div",{className:"conn-config-modal",ref:m,children:[c.jsxs("div",{className:"conn-config-modal__header",children:[c.jsxs("div",{className:"conn-config-modal__title",children:[x(e)," Settings"]}),c.jsx("div",{className:"conn-config-modal__subtitle",children:n})]}),i==="loading"&&c.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[c.jsx("div",{className:"conn-config-spinner"}),c.jsx("span",{children:"Loading configuration..."})]}),(i==="form"||i==="error")&&g.length>0&&c.jsxs("div",{className:"conn-config-modal__body",children:[g.map(k=>c.jsxs("div",{className:"conn-config-field",children:[c.jsxs("label",{className:"conn-config-field__label",children:[k.label,k.readonly&&c.jsx("span",{className:"conn-config-field__badge",children:"read-only"})]}),c.jsx("input",{className:"conn-config-field__input",value:l[k.key]||"",placeholder:k.placeholder,readOnly:k.readonly,onChange:w=>d(S=>({...S,[k.key]:w.target.value}))})]},k.key)),f&&c.jsx("div",{className:"conn-config-modal__error",children:f})]}),(i==="form"||i==="error")&&g.length===0&&c.jsx("div",{className:"conn-config-modal__body conn-config-modal__center",children:c.jsxs("span",{className:"conn-config-modal__empty",children:["No configuration needed for ",x(e),"."]})}),i==="saving"&&c.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[c.jsx("div",{className:"conn-config-spinner"}),c.jsx("span",{children:"Saving..."})]}),i==="saved"&&c.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[c.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),c.jsx("span",{children:"Saved"})]}),c.jsxs("div",{className:"conn-config-modal__footer",children:[c.jsx("button",{className:"conn-config-btn conn-config-btn--secondary",onClick:r,children:i==="saved"?"Close":"Cancel"}),g.length>0&&(i==="form"||i==="error")&&c.jsx("button",{className:"conn-config-btn conn-config-btn--primary",onClick:v,children:"Save"})]})]})})}const cF=[{id:"x",label:"X (Twitter)",oauth:!0},{id:"linkedin",label:"LinkedIn",oauth:!0},{id:"newsletter",label:"Newsletter",oauth:!1}];function Bp(t){switch(t){case"x":return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})});case"linkedin":return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:c.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})});case"newsletter":return c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),c.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});default:return c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("circle",{cx:"12",cy:"12",r:"10"})})}}function uF(t){return t==="active"?"connections-status--active":t==="expired"?"connections-status--expired":t==="revoked"?"connections-status--revoked":"connections-status--pending"}function dF(t){const[e,n]=b.useState([]),[r,s]=b.useState(null),[i,o]=b.useState(null),[l,d]=b.useState(null),[f,h]=b.useState(null),[m,g]=b.useState(null),v=b.useRef(null);async function x(){try{const R=await(await fetch("/api/connections")).json();s(R.authenticated!==!1);const I=(R.connections||[]).filter($=>$&&$.id&&$.provider);return n(I),I}catch{return[]}}b.useEffect(()=>{x()},[]),b.useEffect(()=>()=>{v.current&&clearInterval(v.current)},[]);async function k(_){d(_);try{const R=await fetch(`/api/connections/oauth/${_}/start`,{method:"POST"}),I=await R.json();if(!R.ok||!I.url){d(null);return}window.open(I.url,"_blank","width=600,height=700"),v.current=setInterval(async()=>{try{const P=await(await fetch(`/api/connections/oauth/${_}/status/${I.state}`)).json();if(P.status==="completed"){v.current&&clearInterval(v.current),v.current=null,d(null);const z=await x();if(_==="x"){const q=z.find(F=>F.provider==="x"&&F.status==="active");if(q!=null&&q.display_name){const F=q.display_name.replace("@","");localStorage.setItem("ow-x-handle",F),window.dispatchEvent(new StorageEvent("storage",{key:"ow-x-handle",newValue:F}))}}}else P.status==="failed"&&(v.current&&clearInterval(v.current),v.current=null,d(null))}catch{}},2e3)}catch{d(null)}}async function w(_){try{const R=await fetch(`/api/connections/${_}`,{method:"DELETE"});if(!R.ok){const I=await R.json().catch(()=>({error:"Delete failed"}));console.error("[Connections] Delete failed:",I.error)}}catch(R){console.error("[Connections] Delete error:",R)}o(null),await x()}const S=new Map,N=new Map;for(const _ of e){S.has(_.provider)||S.set(_.provider,_);const R=N.get(_.provider)||[];R.push(_),N.set(_.provider,R)}const T=new Set,M=r===!1;return c.jsxs("div",{className:"connections-tab",children:[m&&c.jsx(lF,{connectionId:m.id,provider:m.provider,displayName:m.display_name,onClose:()=>g(null),onSaved:()=>x()}),f&&c.jsx(oF,{existingConnection:f==="edit"?S.get("newsletter"):null,onClose:()=>h(null),onSaved:()=>x()}),M?c.jsxs("div",{className:"connections-dropdown__upsell",children:[c.jsx("p",{children:"Connect your X, LinkedIn, and other accounts to publish directly from OpenWriter."}),c.jsxs("p",{children:["Set up the ",c.jsx("strong",{children:"Publish"})," plugin to get started."]})]}):c.jsx("div",{className:"connections-dropdown__list",children:cF.flatMap(_=>{const R=T.has(_.id),I=N.get(_.id)||[],$=z=>i===z.id?c.jsxs("div",{className:"connections-dropdown__confirm",children:[c.jsxs("span",{children:["Disconnect ",z.display_name||_.label,"?"]}),c.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[c.jsx("button",{onClick:()=>w(z.id),children:"Yes"}),c.jsx("button",{onClick:()=>o(null),children:"No"})]})]},z.id):c.jsxs("div",{className:"connections-dropdown__item",children:[c.jsx("div",{className:"connections-dropdown__icon",children:Bp(_.id)}),c.jsxs("div",{className:"connections-dropdown__info",children:[c.jsx("div",{className:"connections-dropdown__name",children:z.display_name||z.domain||_.label}),c.jsxs("div",{className:"connections-dropdown__type",children:[c.jsx("span",{className:`connections-status ${uF(z.status)}`}),"Connected"]})]}),c.jsxs("div",{className:"connections-dropdown__actions",children:[c.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>{_.id==="newsletter"?h("edit"):g({id:z.id,provider:_.id,display_name:z.display_name||_.label})},title:"Settings",children:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),c.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>o(z.id),title:"Disconnect",children:"×"})]})]},z.id),P=I.map($);return R?(P.push(c.jsx("div",{className:"connections-dropdown__add-row",children:c.jsx("button",{className:"connections-dropdown__add-btn",onClick:()=>k(_.id),disabled:l!==null,children:l===_.id?"Connecting…":`+ Add ${_.label} repo`})},`${_.id}__add`)),P):I.length>0?P:_.oauth?[c.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[c.jsx("div",{className:"connections-dropdown__icon",children:Bp(_.id)}),c.jsxs("div",{className:"connections-dropdown__info",children:[c.jsx("div",{className:"connections-dropdown__name",children:_.label}),c.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),c.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>k(_.id),disabled:l!==null,children:l===_.id?"Connecting…":"Connect"})]},_.id)]:[c.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[c.jsx("div",{className:"connections-dropdown__icon",children:Bp(_.id)}),c.jsxs("div",{className:"connections-dropdown__info",children:[c.jsx("div",{className:"connections-dropdown__name",children:_.label}),c.jsx("div",{className:"connections-dropdown__type",children:"Built-in · Not configured"})]}),c.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>h("new"),children:"Configure"})]},_.id)]})})]})}const fF={tree:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),files:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]}),timeline:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),c.jsx("circle",{cx:"12",cy:"6",r:"2"}),c.jsx("circle",{cx:"12",cy:"12",r:"2"}),c.jsx("circle",{cx:"12",cy:"18",r:"2"}),c.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),c.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),c.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),c.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),c.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 19V5"}),c.jsx("path",{d:"M8 19V7"}),c.jsx("path",{d:"M12 19V4"}),c.jsx("path",{d:"M16 19V8"}),c.jsx("path",{d:"M20 19V6"}),c.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function hF(t){const[e,n]=b.useState(OE),[r,s]=b.useState(IE),[i,o]=b.useState($d),l=LE(),[d,f]=b.useState(PE),[h,m]=b.useState(BE),g=(N=e,T=r,M=i,_=l,R=d,I=h)=>{$E(N,T,M,_,R,I)},v=N=>{n(N),g(N)},x=()=>{const N=r==="light"?"dark":"light";s(N),g(void 0,N)},k=N=>{o(N),g(void 0,void 0,N),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:N}))},w=N=>{f(N),g(void 0,void 0,void 0,void 0,N)},S=N=>{m(N),g(void 0,void 0,void 0,void 0,void 0,N)};return c.jsxs("div",{className:"appearance-tab",children:[c.jsx("div",{className:"appearance-section",children:c.jsxs("div",{className:"appearance-section-header",children:[c.jsx("span",{className:"appearance-section-title",children:"Mode"}),c.jsxs("button",{className:"appearance-mode-btn",onClick:x,title:r==="light"?"Switch to dark":"Switch to light",children:[r==="light"?c.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"5"}),c.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),c.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),c.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),c.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),c.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),c.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),c.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),c.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):c.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),c.jsx("span",{children:r==="light"?"Light":"Dark"})]})]})}),c.jsxs("div",{className:"appearance-section",children:[c.jsx("div",{className:"appearance-section-header",children:c.jsx("span",{className:"appearance-section-title",children:"Typography"})}),c.jsx("div",{className:"appearance-typeface-grid",children:jE.map(N=>c.jsx("button",{className:`appearance-style-option ${e===N.id?"active":""}`,onClick:()=>v(N.id),title:N.description,children:N.label},N.id))})]}),c.jsxs("div",{className:"appearance-section",children:[c.jsx("div",{className:"appearance-section-header",children:c.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),c.jsx("div",{className:"appearance-typography-grid",children:RE.map(N=>c.jsx("button",{className:`appearance-style-option ${d===N.id?"active":""}`,onClick:()=>w(N.id),children:N.label},N.id))})]}),c.jsxs("div",{className:"appearance-section",children:[c.jsx("div",{className:"appearance-section-header",children:c.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),c.jsx("div",{className:"appearance-style-grid",children:AE.map(N=>c.jsx("button",{className:`appearance-style-option ${h===N.id?"active":""}`,onClick:()=>S(N.id),children:N.label},N.id))})]}),c.jsxs("div",{className:"appearance-section",children:[c.jsx("div",{className:"appearance-section-header",children:c.jsx("span",{className:"appearance-section-title",children:"Layout"})}),c.jsx("div",{className:"appearance-mode-grid",children:ME.map(N=>c.jsxs("button",{className:`appearance-mode-option ${i===N.id?"active":""}`,onClick:()=>k(N.id),children:[fF[N.icon],c.jsx("span",{children:N.label})]},N.id))})]})]})}const t2=[{id:"review",label:"Review",scope:"doc",icon:c.jsx(G5,{}),Component:R8},{id:"activity",label:"Activity",scope:"workspace",icon:c.jsx(Z5,{}),Component:Y8},{id:"backlinks",label:"Backlinks",scope:"doc",icon:c.jsx(X5,{}),Component:D8},{id:"exports",label:"Export",scope:"doc",icon:c.jsx(Q5,{}),Component:B8},{id:"versions",label:"Versions",scope:"doc",icon:c.jsx(J5,{}),Component:L8},{id:"plugins",label:"Plugins",scope:"settings",icon:c.jsx(e$,{}),Component:iF},{id:"connections",label:"Connections",scope:"settings",icon:c.jsx(t$,{}),Component:dF},{id:"appearance",label:"Appearance",scope:"settings",icon:c.jsx(n$,{}),Component:hF}];function pF(t){return t?t2.find(e=>e.id===t)??null:null}let Wk=0;function mF({pendingDocs:t}){const{visible:e,activeTab:n,openTab:r}=Dl(),[s,i]=b.useState(!1),[o,l]=b.useState(!1);return b.useEffect(()=>{const d=t.filenames.length,f=Wk;Wk=d,f===0&&d>0&&r("review")},[t.filenames.length,r]),b.useEffect(()=>{const d=()=>r("review");return window.addEventListener("ow-pending-write-applied",d),()=>window.removeEventListener("ow-pending-write-applied",d)},[r]),b.useEffect(()=>{const d=()=>{if(!(e&&n==="activity")){i(!0),window.setTimeout(()=>i(!1),500);try{localStorage.getItem("ow-bell-hint-seen")||(l(!0),localStorage.setItem("ow-bell-hint-seen","1"),window.setTimeout(()=>l(!1),6e3))}catch{}}};return window.addEventListener("ow-activity-event",d),()=>window.removeEventListener("ow-activity-event",d)},[e,n]),c.jsx("div",{className:"rail-icon-strip",role:"tablist","aria-label":"Right rail tabs",children:t2.map(d=>{const f=e&&n===d.id,h=d.id==="activity";return c.jsxs("button",{type:"button",role:"tab","aria-selected":f,className:["rail-icon-btn",f?"rail-icon-btn--active":"",`rail-icon-btn--scope-${d.scope}`,h&&s?"rail-icon-btn--pulsing":""].filter(Boolean).join(" "),onClick:()=>r(d.id),title:d.label,"aria-label":d.label,children:[d.icon,h&&o&&c.jsxs("div",{className:"rail-icon-hint",role:"tooltip",children:[c.jsx("span",{children:"Agent activity lives here."}),c.jsx("button",{type:"button",className:"rail-icon-hint-close",onClick:m=>{m.stopPropagation(),l(!1)},"aria-label":"Dismiss",children:"×"})]})]},d.id)})})}function gF(t){const{activeTab:e}=Dl(),n=pF(e);return c.jsx("div",{className:"rail-body",role:"tabpanel",children:n?c.jsx(n.Component,{...t}):null})}const vF=()=>c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:c.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"})}),yF=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.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"}),c.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),bF=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.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"}),c.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),xF=()=>c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[c.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"}),c.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function wF({syncStatus:t,onSync:e}){const[n,r]=b.useState(!1),[s,i]=b.useState([]),[o,l]=b.useState(!1),d=b.useRef(null),f=b.useCallback(()=>{if(n){r(!1);return}r(!0),l(!0),fetch("/api/sync/pending").then(h=>h.json()).then(h=>i(h)).catch(()=>i([])).finally(()=>l(!1))},[n]);return b.useEffect(()=>{t.state!=="pending"&&r(!1)},[t.state]),b.useEffect(()=>{if(!n)return;const h=m=>{d.current&&!d.current.contains(m.target)&&r(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]),c.jsxs("div",{className:"sync-btn-group",ref:d,children:[c.jsxs("button",{className:`titlebar-btn sync-btn-state sync-${t.state}`,onClick:e,disabled:t.state==="syncing",title:t.lastSyncTime?`Last synced: ${new Date(t.lastSyncTime).toLocaleString()}`:"Sync to GitHub",children:[t.state==="unconfigured"&&c.jsxs(c.Fragment,{children:[c.jsx(vF,{})," Sync"]}),t.state==="synced"&&c.jsxs(c.Fragment,{children:[c.jsx(yF,{})," Synced"]}),t.state==="pending"&&c.jsxs(c.Fragment,{children:[c.jsx(bF,{})," Sync",t.pendingFiles?` (${t.pendingFiles})`:""]}),t.state==="syncing"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),t.state==="error"&&c.jsxs(c.Fragment,{children:[c.jsx(xF,{})," Retry"]})]}),t.state==="pending"&&t.pendingFiles&&t.pendingFiles>0&&c.jsx("button",{className:"sync-details-btn",onClick:f,title:"View pending changes",children:c.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:c.jsx("path",{d:n?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n&&c.jsxs("div",{className:"sync-pending-dropdown",children:[c.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),o?c.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):s.length===0?c.jsx("div",{className:"sync-pending-loading",children:"No changes"}):c.jsx("div",{className:"sync-pending-list",children:s.map((h,m)=>c.jsxs("div",{className:`sync-pending-item sync-file-${h.status}`,children:[c.jsx("span",{className:"sync-file-badge",children:h.status[0].toUpperCase()}),c.jsx("span",{className:"sync-file-name",children:h.file})]},m))})]})]})}function kF(t){const{syncStatus:e,onSync:n,onToggleToolbar:r,toolbarOpen:s,focusMode:i,onToggleFocusMode:o,heatmapOn:l,onToggleHeatmap:d,heatmapAvailable:f,heatmapTitle:h,...m}=t,{open:g,visible:v,overlay:x,activeTab:k,width:w,setWidth:S,closeRail:N,openTab:T}=Dl(),M=b.useRef(null),_=b.useRef(null),R=b.useRef(i);b.useEffect(()=>{if(i!==R.current)if(R.current=i,i)_.current={open:g,activeTab:k},g&&N();else{const P=_.current;_.current=null,!x&&(P!=null&&P.open)&&P.activeTab&&T(P.activeTab)}},[i]);const I=b.useCallback(P=>{P.preventDefault();const z=P.clientX,q=w,F=B=>{const W=z-B.clientX;S(q+W)},G=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",G)};window.addEventListener("pointermove",F),window.addEventListener("pointerup",G)},[w,S]);b.useEffect(()=>{if(!g)return;const P=z=>{z.key==="Escape"&&M.current&&M.current.contains(document.activeElement)&&(z.preventDefault(),N())};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[g,N]);const $=!v;return c.jsxs("aside",{ref:M,className:`right-rail-column${$?"":" open"}`,style:$?void 0:{width:w,minWidth:w},"aria-label":"Right rail",children:[!x&&!$&&c.jsx("div",{className:"right-rail-resize-handle",onPointerDown:I,"aria-hidden":"true"}),c.jsxs("div",{className:"right-rail-topbar",children:[c.jsxs("div",{className:"right-rail-topbar-actions right-rail-topbar-actions--start",children:[c.jsx("button",{type:"button",className:"right-rail-topbar-btn",onClick:N,title:"Hide rail","aria-label":"Hide rail",children:c.jsx(r$,{})}),c.jsx("button",{type:"button",className:`right-rail-topbar-btn${i?" right-rail-topbar-btn--active":""}`,onClick:o,title:"Focus mode","aria-label":"Focus mode","aria-pressed":i,children:c.jsx(MT,{})}),c.jsx("button",{type:"button",className:`right-rail-topbar-btn${s?" right-rail-topbar-btn--active":""}`,onClick:r,title:"Toggle format toolbar","aria-label":"Toggle format toolbar","aria-pressed":s,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M4 20h16"}),c.jsx("path",{d:"m6 16 6-12 6 12"}),c.jsx("path",{d:"M8 12h8"})]})}),f&&c.jsx("button",{type:"button",className:`right-rail-topbar-btn${l?" right-rail-topbar-btn--active":""}`,onClick:d,title:h,"aria-label":"Voice heatmap (human vs agent)","aria-pressed":l,children:c.jsx(Y5,{})})]}),c.jsx("div",{className:"right-rail-topbar-actions right-rail-topbar-actions--end",children:c.jsx(wF,{syncStatus:e,onSync:n})})]}),c.jsx(mF,{pendingDocs:m.pendingDocs}),c.jsx(gF,{...m})]})}function SF({onClose:t,onSetupComplete:e}){const[n,r]=b.useState("detecting"),[s,i]=b.useState(null),[o,l]=b.useState("gh"),[d,f]=b.useState("openwriter-docs"),[h,m]=b.useState(!0),[g,v]=b.useState(""),[x,k]=b.useState(""),[w,S]=b.useState(""),[N,T]=b.useState("");b.useEffect(()=>{fetch("/api/sync/capabilities").then(_=>_.json()).then(_=>{i(_),_.ghAuthenticated?l("gh"):(_.gitInstalled,l("pat")),r("setup")}).catch(()=>{S("Failed to detect git capabilities"),r("error")})},[]);const M=b.useCallback(async()=>{r("progress"),T(o==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const _={method:o,repoName:d,isPrivate:h};o==="pat"&&(_.pat=g),o==="connect"&&(_.remoteUrl=x,_.pat=g||void 0);const R=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!R.ok){const I=await R.json().catch(()=>({}));throw new Error(I.error||`Setup failed (${R.status})`)}r("done"),e()}catch(_){S(_.message),r("error")}},[o,d,h,g,x,e]);return c.jsx("div",{className:"sync-modal-overlay",onClick:t,children:c.jsxs("div",{className:"sync-modal",onClick:_=>_.stopPropagation(),children:[c.jsxs("div",{className:"sync-modal-header",children:[c.jsx("h2",{children:"Sync to GitHub"}),c.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&c.jsxs("div",{className:"sync-modal-body",children:[c.jsx("div",{className:"sync-spinner"}),c.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&s&&c.jsxs("div",{className:"sync-modal-body",children:[!s.gitInstalled&&c.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",c.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),s.gitInstalled&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"sync-tabs",children:[s.ghAuthenticated&&c.jsx("button",{className:`sync-tab${o==="gh"?" active":""}`,onClick:()=>l("gh"),children:"GitHub CLI"}),c.jsx("button",{className:`sync-tab${o==="pat"?" active":""}`,onClick:()=>l("pat"),children:"Personal Access Token"}),c.jsx("button",{className:`sync-tab${o==="connect"?" active":""}`,onClick:()=>l("connect"),children:"Connect Existing"})]}),o==="gh"&&c.jsxs("div",{className:"sync-form",children:[c.jsxs("label",{children:["Repository name",c.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),c.jsxs("label",{className:"sync-checkbox",children:[c.jsx("input",{type:"checkbox",checked:h,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),o==="pat"&&c.jsxs("div",{className:"sync-form",children:[!s.ghAuthenticated&&!s.ghInstalled&&c.jsxs("p",{className:"sync-hint",children:["Create a ",c.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",c.jsx("code",{children:"repo"})," scope."]}),c.jsxs("label",{children:["Personal Access Token",c.jsx("input",{type:"password",value:g,onChange:_=>v(_.target.value),placeholder:"ghp_..."})]}),c.jsxs("label",{children:["Repository name",c.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),c.jsxs("label",{className:"sync-checkbox",children:[c.jsx("input",{type:"checkbox",checked:h,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),o==="connect"&&c.jsxs("div",{className:"sync-form",children:[c.jsxs("label",{children:["Remote URL",c.jsx("input",{type:"text",value:x,onChange:_=>k(_.target.value),placeholder:"https://github.com/user/repo.git"})]}),c.jsxs("label",{children:["PAT (optional, for private repos)",c.jsx("input",{type:"password",value:g,onChange:_=>v(_.target.value),placeholder:"ghp_..."})]})]}),c.jsxs("div",{className:"sync-modal-actions",children:[c.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),c.jsx("button",{className:"sync-btn primary",onClick:M,disabled:o==="pat"&&!g||o==="connect"&&!x||o!=="connect"&&!d,children:o==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&c.jsxs("div",{className:"sync-modal-body",children:[c.jsx("div",{className:"sync-spinner"}),c.jsx("p",{children:N})]}),n==="done"&&c.jsxs("div",{className:"sync-modal-body",children:[c.jsx("div",{className:"sync-success-icon",children:"✓"}),c.jsx("p",{children:"Successfully synced to GitHub!"}),c.jsx("div",{className:"sync-modal-actions",children:c.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&c.jsxs("div",{className:"sync-modal-body",children:[c.jsx("div",{className:"sync-error-msg",children:w}),c.jsxs("div",{className:"sync-modal-actions",children:[c.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),c.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function EF({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentReloaded:r,onDocumentsChanged:s,onWorkspacesChanged:i,onTitleChanged:o,onPendingDocsChanged:l,onMetadataChanged:d,onSyncStatus:f,onWritingStarted:h,onWritingFinished:m,onIdRewrites:g,onPendingFilenamesChanged:v,getEditorState:x}){const k=b.useRef(null),[w,S]=b.useState(!1),N=b.useRef(0),T=b.useRef(new Set),M=()=>{var A;return(A=ne.current)==null?void 0:A.call(ne,new Set(T.current))},_=b.useRef(t),R=b.useRef(e),I=b.useRef(n),$=b.useRef(s),P=b.useRef(i),z=b.useRef(o),q=b.useRef(l),F=b.useRef(f),G=b.useRef(d),B=b.useRef(h),W=b.useRef(m),K=b.useRef(g),ne=b.useRef(v),V=b.useRef(r),oe=b.useRef(x);_.current=t,R.current=e,I.current=n,$.current=s,P.current=i,z.current=o,q.current=l,G.current=d,F.current=f,B.current=h,W.current=m,K.current=g,ne.current=v,V.current=r,oe.current=x,b.useEffect(()=>{const L=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let ee,pe=!1,xe=1e3;function re(){const ke=new WebSocket(L);k.current=ke,ke.onopen=()=>{S(!0),xe=1e3,pe&&ke.send(JSON.stringify({type:"request-document"})),pe=!0},ke.onmessage=ze=>{var Fe,Ge,Re,Ze,gt,ht,ge,vt,_t,Et,Dt,ot,Le,ve;try{const te=JSON.parse(ze.data);if(te.type==="node-changes"&&te.changes&&((Fe=_.current)==null||Fe.call(_,te.changes),typeof te.version=="number"&&(N.current=te.version)),te.type==="id-rewrites"&&Array.isArray(te.rewrites)&&((Ge=K.current)==null||Ge.call(K,te.rewrites)),te.type==="agent-status"&&((Re=R.current)==null||Re.call(R,!!te.agentConnected)),te.type==="document-switched"&&(N.current=0,(Ze=I.current)==null||Ze.call(I,{document:te.document,title:te.title,filename:te.filename,docId:te.docId,metadata:te.metadata,pendingMetadata:te.pendingMetadata??null}),window.dispatchEvent(new CustomEvent("ow-pending-metadata-changed",{detail:{docId:te.docId,pendingMetadata:te.pendingMetadata??null}}))),te.type==="pending-metadata-changed"&&window.dispatchEvent(new CustomEvent("ow-pending-metadata-changed",{detail:{docId:te.docId,pendingMetadata:te.pendingMetadata??null}})),te.type==="document-reloaded"&&(typeof te.version=="number"&&(N.current=te.version),(gt=V.current)==null||gt.call(V,{document:te.document,title:te.title,filename:te.filename,docId:te.docId,metadata:te.metadata,orphanCount:typeof te.orphanCount=="number"?te.orphanCount:0,staleBaselineCount:typeof te.staleBaselineCount=="number"?te.staleBaselineCount:0})),te.type==="metadata-changed"&&te.metadata&&((ht=G.current)==null||ht.call(G,te.metadata)),te.type==="documents-changed"&&((ge=$.current)==null||ge.call($)),te.type==="workspaces-changed"&&((vt=P.current)==null||vt.call(P)),te.type==="title-changed"&&te.title&&((_t=z.current)==null||_t.call(z,te.title)),te.type==="pending-docs-changed"&&te.pendingDocs&&((Et=q.current)==null||Et.call(q,te.pendingDocs)),te.type==="sync-status"&&((Dt=F.current)==null||Dt.call(F,{state:te.state,lastSyncTime:te.lastSyncTime,pendingFiles:te.pendingFiles,error:te.error})),te.type==="writing-started"&&te.title&&(typeof te.key=="string"&&(T.current.add(te.key),M()),(ot=B.current)==null||ot.call(B,te.title,te.target||null)),te.type==="writing-finished"&&(typeof te.key=="string"&&te.key?T.current.delete(te.key):T.current.clear(),M(),(Le=W.current)==null||Le.call(W)),te.type==="pending-writes-sync"&&Array.isArray(te.writes)&&(T.current=new Set(te.writes.map(je=>je.key).filter(Boolean)),M(),te.writes.length>0)){const je=te.writes.reduce((Q,de)=>Q.startedAt>de.startedAt?Q:de);je!=null&&je.title&&((ve=B.current)==null||ve.call(B,je.title,je.target||null))}if(te.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),te.type==="comments-changed"&&te.filename&&window.dispatchEvent(new CustomEvent("ow-comments-changed",{detail:{filename:te.filename}})),te.type==="documents-changed"&&window.dispatchEvent(new CustomEvent("ow-documents-changed")),te.type==="metadata-changed"&&window.dispatchEvent(new CustomEvent("ow-metadata-changed",{detail:{metadata:te.metadata}})),te.type==="activity-log"&&Array.isArray(te.entries)&&window.dispatchEvent(new CustomEvent("ow-activity-seed",{detail:{entries:te.entries}})),te.type==="activity-event"&&te.event&&window.dispatchEvent(new CustomEvent("ow-activity-event",{detail:{event:te.event}})),te.type==="toast"&&typeof te.message=="string"){const je=te.kind==="error"?"error":"info";ji(te.message,je,typeof te.durationMs=="number"?te.durationMs:je==="error"?9e3:3500)}}catch{}},ke.onclose=()=>{S(!1),ee=setTimeout(re,xe),xe=Math.min(xe*1.5,8e3)},ke.onerror=()=>{ke.close()}}re();function Ne(){var ke;document.visibilityState==="visible"&&((ke=k.current)==null?void 0:ke.readyState)!==WebSocket.OPEN&&(clearTimeout(ee),xe=1e3,re())}return document.addEventListener("visibilitychange",Ne),()=>{clearTimeout(ee),document.removeEventListener("visibilitychange",Ne),k.current&&(k.current.onclose=null,k.current.close())}},[]);const J=b.useCallback(A=>{var L;((L=k.current)==null?void 0:L.readyState)===WebSocket.OPEN&&k.current.send(JSON.stringify(A))},[]);return{connected:w,sendMessage:J,docVersionRef:N}}function NF(t){const[e,n]=b.useState(null),[r,s]=b.useState(!1),[i,o]=b.useState(null),l=b.useRef(void 0);return b.useEffect(()=>{if(!t){n(null),s(!1),o(null),l.current=void 0;return}t!==l.current&&(l.current=t,s(!0),o(null),fetch(`/api/tweet-embed?url=${encodeURIComponent(t)}`).then(d=>d.ok?d.json():d.json().then(f=>Promise.reject(new Error(f.error||`HTTP ${d.status}`)))).then(d=>{n(d),s(!1)}).catch(d=>{o(d.message),s(!1)}))},[t]),{tweet:e,loading:r,error:i}}function CF(t){var r;const e=t.view.dom,n=[];for(const s of e.children){const i=(r=s.innerText)==null?void 0:r.trim();i&&n.push(i)}return n.join(`
211
-
212
- `)}function _F(t){const e=n=>{var r;if(n.type==="image"&&((r=n.attrs)!=null&&r.src))return n.attrs.src;if(n.content)for(const s of n.content){const i=e(s);if(i)return i}return null};return e(t.getJSON())}async function TF(t){try{const e=await fetch(t);if(!e.ok)return null;const n=await e.blob();return n.type==="image/png"?n:new Promise(r=>{const s=new Image,i=URL.createObjectURL(n);s.onload=()=>{const o=document.createElement("canvas");o.width=s.naturalWidth,o.height=s.naturalHeight,o.getContext("2d").drawImage(s,0,0),o.toBlob(l=>{URL.revokeObjectURL(i),r(l)},"image/png")},s.onerror=()=>{URL.revokeObjectURL(i),r(null)},s.src=i})}catch{return null}}function jF(t,e){const[n,r]=b.useState("idle"),s=b.useRef();return{copyText:b.useCallback(async()=>{const o=t.current[e];if(!o)return;const l=CF(o),d=_F(o);if(!(!l&&!d)){try{const f={};if(l&&(f["text/plain"]=new Blob([l],{type:"text/plain"})),d){const h=await TF(d);h&&(f["image/png"]=h)}Object.keys(f).length>0&&await navigator.clipboard.write([new ClipboardItem(f)])}catch{if(l){const f=document.createElement("textarea");f.value=l,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select(),document.execCommand("copy"),document.body.removeChild(f)}}r("copied"),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r("idle"),2e3)}},[t,e]),copyState:n}}function $p(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 MF(t){try{const e=Date.now(),n=new Date(t).getTime(),r=Math.floor((e-n)/1e3);if(r<60)return`${r}s`;const s=Math.floor(r/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return""}}const AF=()=>c.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:c.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"})}),RF=()=>c.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:c.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"})}),OF=()=>c.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:c.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"})}),IF=()=>c.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:c.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"})}),LF=()=>c.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:c.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 n2({tweet:t,nested:e,url:n}){const r=MF(t.createdAt);return c.jsxs("div",{className:`tweet-embed-card${e?" tweet-embed-nested":""}${n?" tweet-embed-card--clickable":""}`,onClick:n?()=>window.open(n,"_blank","noopener,noreferrer"):void 0,role:n?"link":void 0,children:[c.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?c.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):c.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),c.jsxs("div",{className:"tweet-author-info",children:[c.jsx("span",{className:"tweet-author-name",children:t.author.name}),c.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),r&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"tweet-author-separator",children:"·"}),c.jsx("span",{className:"tweet-author-timestamp",children:r})]})]})]}),c.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&c.jsx("div",{className:"tweet-media","data-count":t.media.length,children:t.media.map((s,i)=>s.type==="photo"?c.jsx("img",{className:"tweet-media-img",src:s.url,alt:"",loading:"lazy"},i):s.type==="video"||s.type==="gif"?c.jsx("div",{className:"tweet-media-video-placeholder",children:c.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&c.jsx(n2,{tweet:t.quoteTweet,nested:!0}),!e&&c.jsxs("div",{className:"tweet-actions-row",children:[c.jsxs("span",{className:"tweet-action tweet-action-reply",children:[c.jsx(AF,{}),t.metrics.replies>0&&$p(t.metrics.replies)]}),c.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[c.jsx(RF,{}),t.metrics.retweets>0&&$p(t.metrics.retweets)]}),c.jsxs("span",{className:"tweet-action tweet-action-like",children:[c.jsx(OF,{}),t.metrics.likes>0&&$p(t.metrics.likes)]}),c.jsx("span",{className:"tweet-action tweet-action-bookmark",children:c.jsx(IF,{})}),c.jsx("span",{className:"tweet-action tweet-action-share",children:c.jsx(LF,{})})]})]})}function Vk({tweet:t,url:e}){return c.jsx(n2,{tweet:t,url:e})}function DF({initialContent:t,initialPreviewImages:e,placeholder:n="What is happening?!",onUpdate:r,onReady:s,onFocus:i,onPreviewImagesChange:o}){const[l,d]=b.useState(e||[]),f=b.useRef(e||[]),h=b.useRef(!1),m=b.useRef(s);m.current=s;const g=b.useRef(o);g.current=o;const v=b.useCallback(S=>{var T;const N=S.slice(0,4);f.current=N,d(N),(T=g.current)==null||T.call(g,N)},[]),x=b.useCallback(S=>{if(h.current)return;const N=[],T=[];if(S.state.doc.descendants((I,$)=>{var P;I.type.name==="image"&&((P=I.attrs)!=null&&P.src)&&(N.push(I.attrs.src),T.push({from:$,to:$+I.nodeSize}))}),N.length===0)return;h.current=!0;const{tr:M}=S.state;for(let I=T.length-1;I>=0;I--)M.delete(T[I].from,T[I].to);S.view.dispatch(M);const _=f.current,R=4-_.length;R>0&&v([..._,...N.slice(0,R)]),h.current=!1},[v]),k=t_({extensions:[...gT,ef.configure({placeholder:n})],content:t||"<p></p>",onCreate:({editor:S})=>{x(S)},onUpdate:({editor:S})=>{x(S),r==null||r(S)},onFocus:()=>{i==null||i()},editorProps:{handlePaste:_T,handleDrop:TT}},[t]);b.useEffect(()=>{k&&$5(k.view,{addToPreview:S=>{const N=f.current;N.length>=4||v([...N,S])},getPreviewImages:()=>f.current})},[k,v]),b.useEffect(()=>{if(!k)return;const{state:S}=k.view;if(S.plugins.some(M=>M.key==="pendingDecoration$"))return;const N=wT(),T=S.reconfigure({plugins:[...S.plugins,N]});k.view.updateState(T)},[k]),b.useEffect(()=>{if(!k)return;const{state:S}=k.view;if(S.plugins.some(M=>M.key==="commentDecoration$"))return;const N=ST(),T=S.reconfigure({plugins:[...S.plugins,N]});k.view.updateState(T)},[k]),b.useEffect(()=>{var S;k&&((S=m.current)==null||S.call(m,k))},[k]);const w=b.useCallback(S=>{v(f.current.filter((N,T)=>T!==S))},[v]);return k?c.jsxs(c.Fragment,{children:[c.jsx(Pv,{editor:k}),l.length>0&&c.jsx("div",{className:"tweet-preview-grid","data-count":l.length,children:l.map((S,N)=>c.jsxs("div",{className:"tweet-image-card",children:[c.jsx("img",{className:"tweet-image-card-img",src:S,alt:"",draggable:!1}),c.jsx("button",{className:"tweet-image-card-remove",onClick:()=>w(N),title:"Remove image",children:"×"})]},S))})]}):null}function PF({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),s=n<=20,i=s?30:26,o=2,l=(i-o)/2,d=2*Math.PI*l,f=d*(1-r);let h="var(--x-blue, #1d9bf0)";return n<=0?h="var(--x-red, #f4212e)":n<=20&&(h="var(--x-yellow, #ffd400)"),t===0?null:c.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:i,height:i},children:[c.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[c.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:o}),c.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:h,strokeWidth:o,strokeDasharray:d,strokeDashoffset:f,strokeLinecap:"round",transform:`rotate(-90 ${i/2} ${i/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),s&&c.jsx("span",{className:"tweet-char-number",style:{color:h,fontSize:n<-9||n>9?10:11},children:n})]})}const qk="@openwriter/plugin-x-api",Kk=[{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 BF({onConnected:t,onCancel:e}){const[n,r]=b.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=b.useState(!1),[o,l]=b.useState(""),d=Kk.every(h=>n[h.key].trim()),f=async()=>{i(!0),l("");try{if(!(await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:qk,config:n})})).ok)throw new Error("Failed to save config");const g=await(await fetch("/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:qk})})).json();if(!g.success)throw new Error(g.error||"Failed to enable plugin");const x=await(await fetch("/api/x/status")).json();x.connected?t():l(x.error||"Could not verify X credentials. Check your API keys.")}catch(h){l(h.message||"Connection failed")}finally{i(!1)}};return c.jsxs("div",{className:"x-connect-prompt",children:[c.jsxs("div",{className:"x-connect-header",children:[c.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),c.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:c.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:c.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"})})})]}),c.jsx("div",{className:"x-connect-fields",children:Kk.map(h=>c.jsxs("div",{className:"x-connect-field",children:[c.jsx("label",{className:"x-connect-label",children:h.label}),c.jsx("input",{type:"password",className:"x-connect-input",value:n[h.key],onChange:m=>r(g=>({...g,[h.key]:m.target.value})),placeholder:h.env,spellCheck:!1,autoComplete:"off"})]},h.key))}),o&&c.jsx("div",{className:"x-connect-error",children:o}),c.jsxs("div",{className:"x-connect-actions",children:[c.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),c.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!d||s,children:s?"Connecting...":"Connect"})]})]})}var Gk={},Fp,Jk;function Gs(){return Jk||(Jk=1,Fp=function(t){return typeof t=="object"?t!==null:typeof t=="function"}),Fp}var zp,Yk;function Or(){if(Yk)return zp;Yk=1;var t=Gs();return zp=function(e){if(!t(e))throw TypeError(e+" is not an object!");return e},zp}var Up,Xk;function sf(){return Xk||(Xk=1,Up=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}),Up}var Hp,Qk;function Bi(){if(Qk)return Hp;Qk=1;var t=sf();return Hp=function(e){return Object(t(e))},Hp}var Wp,Zk;function of(){if(Zk)return Wp;Zk=1;var t=Math.ceil,e=Math.floor;return Wp=function(n){return isNaN(n=+n)?0:(n>0?e:t)(n)},Wp}var Vp,e1;function So(){if(e1)return Vp;e1=1;var t=of(),e=Math.min;return Vp=function(n){return n>0?e(t(n),9007199254740991):0},Vp}var qp,t1;function r2(){if(t1)return qp;t1=1;var t=of(),e=sf();return qp=function(n){return function(r,s){var i=String(e(r)),o=t(s),l=i.length,d,f;return o<0||o>=l?n?"":void 0:(d=i.charCodeAt(o),d<55296||d>56319||o+1===l||(f=i.charCodeAt(o+1))<56320||f>57343?n?i.charAt(o):d:n?i.slice(o,o+2):(d-55296<<10)+(f-56320)+65536)}},qp}var Kp,n1;function hy(){if(n1)return Kp;n1=1;var t=r2()(!0);return Kp=function(e,n,r){return n+(r?t(e,n).length:1)},Kp}var Gp,r1;function af(){if(r1)return Gp;r1=1;var t={}.toString;return Gp=function(e){return t.call(e).slice(8,-1)},Gp}var Jp={exports:{}},Yp={exports:{}},Xp={exports:{}},s1;function ya(){if(s1)return Xp.exports;s1=1;var t=Xp.exports={version:"2.6.12"};return typeof __e=="number"&&(__e=t),Xp.exports}var Qp={exports:{}},i1;function Yr(){if(i1)return Qp.exports;i1=1;var t=Qp.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();return typeof __g=="number"&&(__g=t),Qp.exports}var Zp,o1;function lf(){return o1||(o1=1,Zp=!1),Zp}var a1;function cf(){if(a1)return Yp.exports;a1=1;var t=ya(),e=Yr(),n="__core-js_shared__",r=e[n]||(e[n]={});return(Yp.exports=function(s,i){return r[s]||(r[s]=i!==void 0?i:{})})("versions",[]).push({version:t.version,mode:lf()?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"}),Yp.exports}var em,l1;function Wl(){if(l1)return em;l1=1;var t=0,e=Math.random();return em=function(n){return"Symbol(".concat(n===void 0?"":n,")_",(++t+e).toString(36))},em}var c1;function zn(){if(c1)return Jp.exports;c1=1;var t=cf()("wks"),e=Wl(),n=Yr().Symbol,r=typeof n=="function",s=Jp.exports=function(i){return t[i]||(t[i]=r&&n[i]||(r?n:e)("Symbol."+i))};return s.store=t,Jp.exports}var tm,u1;function py(){if(u1)return tm;u1=1;var t=af(),e=zn()("toStringTag"),n=t((function(){return arguments})())=="Arguments",r=function(s,i){try{return s[i]}catch{}};return tm=function(s){var i,o,l;return s===void 0?"Undefined":s===null?"Null":typeof(o=r(i=Object(s),e))=="string"?o:n?t(i):(l=t(i))=="Object"&&typeof i.callee=="function"?"Arguments":l},tm}var nm,d1;function my(){if(d1)return nm;d1=1;var t=py(),e=RegExp.prototype.exec;return nm=function(n,r){var s=n.exec;if(typeof s=="function"){var i=s.call(n,r);if(typeof i!="object")throw new TypeError("RegExp exec method returned something other than an Object or null");return i}if(t(n)!=="RegExp")throw new TypeError("RegExp#exec called on incompatible receiver");return e.call(n,r)},nm}var f1={},rm,h1;function uf(){if(h1)return rm;h1=1;var t=Or();return rm=function(){var e=t(this),n="";return e.global&&(n+="g"),e.ignoreCase&&(n+="i"),e.multiline&&(n+="m"),e.unicode&&(n+="u"),e.sticky&&(n+="y"),n},rm}var sm,p1;function gy(){if(p1)return sm;p1=1;var t=uf(),e=RegExp.prototype.exec,n=String.prototype.replace,r=e,s="lastIndex",i=(function(){var d=/a/,f=/b*/g;return e.call(d,"a"),e.call(f,"a"),d[s]!==0||f[s]!==0})(),o=/()??/.exec("")[1]!==void 0,l=i||o;return l&&(r=function(f){var h=this,m,g,v,x;return o&&(g=new RegExp("^"+h.source+"$(?!\\s)",t.call(h))),i&&(m=h[s]),v=e.call(h,f),i&&v&&(h[s]=h.global?v.index+v[0].length:m),o&&v&&v.length>1&&n.call(v[0],g,function(){for(x=1;x<arguments.length-2;x++)arguments[x]===void 0&&(v[x]=void 0)}),v}),sm=r,sm}var im={},om,m1;function ds(){return m1||(m1=1,om=function(t){try{return!!t()}catch{return!0}}),om}var am,g1;function Xr(){return g1||(g1=1,am=!ds()(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})),am}var lm,v1;function s2(){if(v1)return lm;v1=1;var t=Gs(),e=Yr().document,n=t(e)&&t(e.createElement);return lm=function(r){return n?e.createElement(r):{}},lm}var cm,y1;function i2(){return y1||(y1=1,cm=!Xr()&&!ds()(function(){return Object.defineProperty(s2()("div"),"a",{get:function(){return 7}}).a!=7})),cm}var um,b1;function vy(){if(b1)return um;b1=1;var t=Gs();return um=function(e,n){if(!t(e))return e;var r,s;if(n&&typeof(r=e.toString)=="function"&&!t(s=r.call(e))||typeof(r=e.valueOf)=="function"&&!t(s=r.call(e))||!n&&typeof(r=e.toString)=="function"&&!t(s=r.call(e)))return s;throw TypeError("Can't convert object to primitive value")},um}var x1;function fs(){if(x1)return im;x1=1;var t=Or(),e=i2(),n=vy(),r=Object.defineProperty;return im.f=Xr()?Object.defineProperty:function(i,o,l){if(t(i),o=n(o,!0),t(l),e)try{return r(i,o,l)}catch{}if("get"in l||"set"in l)throw TypeError("Accessors not supported!");return"value"in l&&(i[o]=l.value),i},im}var dm,w1;function Vl(){return w1||(w1=1,dm=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}),dm}var fm,k1;function $i(){if(k1)return fm;k1=1;var t=fs(),e=Vl();return fm=Xr()?function(n,r,s){return t.f(n,r,e(1,s))}:function(n,r,s){return n[r]=s,n},fm}var hm={exports:{}},pm,S1;function Eo(){if(S1)return pm;S1=1;var t={}.hasOwnProperty;return pm=function(e,n){return t.call(e,n)},pm}var mm,E1;function $F(){return E1||(E1=1,mm=cf()("native-function-to-string",Function.toString)),mm}var N1;function Js(){if(N1)return hm.exports;N1=1;var t=Yr(),e=$i(),n=Eo(),r=Wl()("src"),s=$F(),i="toString",o=(""+s).split(i);return ya().inspectSource=function(l){return s.call(l)},(hm.exports=function(l,d,f,h){var m=typeof f=="function";m&&(n(f,"name")||e(f,"name",d)),l[d]!==f&&(m&&(n(f,r)||e(f,r,l[d]?""+l[d]:o.join(String(d)))),l===t?l[d]=f:h?l[d]?l[d]=f:e(l,d,f):(delete l[d],e(l,d,f)))})(Function.prototype,i,function(){return typeof this=="function"&&this[r]||s.call(this)}),hm.exports}var gm,C1;function df(){return C1||(C1=1,gm=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}),gm}var vm,_1;function ff(){if(_1)return vm;_1=1;var t=df();return vm=function(e,n,r){if(t(e),n===void 0)return e;switch(r){case 1:return function(s){return e.call(n,s)};case 2:return function(s,i){return e.call(n,s,i)};case 3:return function(s,i,o){return e.call(n,s,i,o)}}return function(){return e.apply(n,arguments)}},vm}var ym,T1;function Er(){if(T1)return ym;T1=1;var t=Yr(),e=ya(),n=$i(),r=Js(),s=ff(),i="prototype",o=function(l,d,f){var h=l&o.F,m=l&o.G,g=l&o.S,v=l&o.P,x=l&o.B,k=m?t:g?t[d]||(t[d]={}):(t[d]||{})[i],w=m?e:e[d]||(e[d]={}),S=w[i]||(w[i]={}),N,T,M,_;m&&(f=d);for(N in f)T=!h&&k&&k[N]!==void 0,M=(T?k:f)[N],_=x&&T?s(M,t):v&&typeof M=="function"?s(Function.call,M):M,k&&r(k,N,M,l&o.U),w[N]!=M&&n(w,N,_),v&&S[N]!=M&&(S[N]=M)};return t.core=e,o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,o.U=64,o.R=128,ym=o,ym}var j1;function FF(){if(j1)return f1;j1=1;var t=gy();return Er()({target:"RegExp",proto:!0,forced:t!==/./.exec},{exec:t}),f1}var bm,M1;function yy(){if(M1)return bm;M1=1,FF();var t=Js(),e=$i(),n=ds(),r=sf(),s=zn(),i=gy(),o=s("species"),l=!n(function(){var f=/./;return f.exec=function(){var h=[];return h.groups={a:"7"},h},"".replace(f,"$<a>")!=="7"}),d=(function(){var f=/(?:)/,h=f.exec;f.exec=function(){return h.apply(this,arguments)};var m="ab".split(f);return m.length===2&&m[0]==="a"&&m[1]==="b"})();return bm=function(f,h,m){var g=s(f),v=!n(function(){var T={};return T[g]=function(){return 7},""[f](T)!=7}),x=v?!n(function(){var T=!1,M=/a/;return M.exec=function(){return T=!0,null},f==="split"&&(M.constructor={},M.constructor[o]=function(){return M}),M[g](""),!T}):void 0;if(!v||!x||f==="replace"&&!l||f==="split"&&!d){var k=/./[g],w=m(r,g,""[f],function(M,_,R,I,$){return _.exec===i?v&&!$?{done:!0,value:k.call(_,R,I)}:{done:!0,value:M.call(R,_,I)}:{done:!1}}),S=w[0],N=w[1];t(String.prototype,f,S),e(RegExp.prototype,g,h==2?function(T,M){return N.call(T,this,M)}:function(T){return N.call(T,this)})}},bm}var A1;function zF(){if(A1)return Gk;A1=1;var t=Or(),e=Bi(),n=So(),r=of(),s=hy(),i=my(),o=Math.max,l=Math.min,d=Math.floor,f=/\$([$&`']|\d\d?|<[^>]*>)/g,h=/\$([$&`']|\d\d?)/g,m=function(g){return g===void 0?g:String(g)};return yy()("replace",2,function(g,v,x,k){return[function(N,T){var M=g(this),_=N==null?void 0:N[v];return _!==void 0?_.call(N,M,T):x.call(String(M),N,T)},function(S,N){var T=k(x,S,this,N);if(T.done)return T.value;var M=t(S),_=String(this),R=typeof N=="function";R||(N=String(N));var I=M.global;if(I){var $=M.unicode;M.lastIndex=0}for(var P=[];;){var z=i(M,_);if(z===null||(P.push(z),!I))break;var q=String(z[0]);q===""&&(M.lastIndex=s(_,n(M.lastIndex),$))}for(var F="",G=0,B=0;B<P.length;B++){z=P[B];for(var W=String(z[0]),K=o(l(r(z.index),_.length),0),ne=[],V=1;V<z.length;V++)ne.push(m(z[V]));var oe=z.groups;if(R){var J=[W].concat(ne,K,_);oe!==void 0&&J.push(oe);var A=String(N.apply(void 0,J))}else A=w(W,_,K,ne,oe,N);K>=G&&(F+=_.slice(G,K)+A,G=K+W.length)}return F+_.slice(G)}];function w(S,N,T,M,_,R){var I=T+S.length,$=M.length,P=h;return _!==void 0&&(_=e(_),P=f),x.call(R,P,function(z,q){var F;switch(q.charAt(0)){case"$":return"$";case"&":return S;case"`":return N.slice(0,T);case"'":return N.slice(I);case"<":F=_[q.slice(1,-1)];break;default:var G=+q;if(G===0)return z;if(G>$){var B=d(G/10);return B===0?z:B<=$?M[B-1]===void 0?q.charAt(1):M[B-1]+q.charAt(1):z}F=M[G-1]}return F===void 0?"":F})}}),Gk}zF();var R1={},xm,O1;function by(){if(O1)return xm;O1=1;var t=af();return xm=Object("z").propertyIsEnumerable(0)?Object:function(e){return t(e)=="String"?e.split(""):Object(e)},xm}var wm,I1;function No(){if(I1)return wm;I1=1;var t=by(),e=sf();return wm=function(n){return t(e(n))},wm}var km,L1;function UF(){if(L1)return km;L1=1;var t=of(),e=Math.max,n=Math.min;return km=function(r,s){return r=t(r),r<0?e(r+s,0):n(r,s)},km}var Sm,D1;function o2(){if(D1)return Sm;D1=1;var t=No(),e=So(),n=UF();return Sm=function(r){return function(s,i,o){var l=t(s),d=e(l.length),f=n(o,d),h;if(r&&i!=i){for(;d>f;)if(h=l[f++],h!=h)return!0}else for(;d>f;f++)if((r||f in l)&&l[f]===i)return r||f||0;return!r&&-1}},Sm}var Em,P1;function ql(){if(P1)return Em;P1=1;var t=ds();return Em=function(e,n){return!!e&&t(function(){n?e.call(null,function(){},1):e.call(null)})},Em}var B1;function HF(){if(B1)return R1;B1=1;var t=Er(),e=o2()(!1),n=[].indexOf,r=!!n&&1/[1].indexOf(1,-0)<0;return t(t.P+t.F*(r||!ql()(n)),"Array",{indexOf:function(i){return r?n.apply(this,arguments)||0:e(this,i,arguments[1])}}),R1}HF();var WF=/[a-z]{1,6}(?:[._][a-z]{1,2})?/i,a2=/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/,$1={},Nm={},Cm={},F1;function xy(){return F1||(F1=1,Cm.f={}.propertyIsEnumerable),Cm}var z1;function wy(){if(z1)return Nm;z1=1;var t=xy(),e=Vl(),n=No(),r=vy(),s=Eo(),i=i2(),o=Object.getOwnPropertyDescriptor;return Nm.f=Xr()?o:function(d,f){if(d=n(d),f=r(f,!0),i)try{return o(d,f)}catch{}if(s(d,f))return e(!t.f.call(d,f),d[f])},Nm}var _m,U1;function VF(){if(U1)return _m;U1=1;var t=Gs(),e=Or(),n=function(r,s){if(e(r),!t(s)&&s!==null)throw TypeError(s+": can't set as prototype!")};return _m={set:Object.setPrototypeOf||("__proto__"in{}?(function(r,s,i){try{i=ff()(Function.call,wy().f(Object.prototype,"__proto__").set,2),i(r,[]),s=!(r instanceof Array)}catch{s=!0}return function(l,d){return n(l,d),s?l.__proto__=d:i(l,d),l}})({},!1):void 0),check:n},_m}var Tm,H1;function qF(){if(H1)return Tm;H1=1;var t=Gs(),e=VF().set;return Tm=function(n,r,s){var i=r.constructor,o;return i!==s&&typeof i=="function"&&(o=i.prototype)!==s.prototype&&t(o)&&e&&e(n,o),n},Tm}var jm={},Mm,W1;function ky(){if(W1)return Mm;W1=1;var t=cf()("keys"),e=Wl();return Mm=function(n){return t[n]||(t[n]=e(n))},Mm}var Am,V1;function l2(){if(V1)return Am;V1=1;var t=Eo(),e=No(),n=o2()(!1),r=ky()("IE_PROTO");return Am=function(s,i){var o=e(s),l=0,d=[],f;for(f in o)f!=r&&t(o,f)&&d.push(f);for(;i.length>l;)t(o,f=i[l++])&&(~n(d,f)||d.push(f));return d},Am}var Rm,q1;function Sy(){return q1||(q1=1,Rm="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")),Rm}var K1;function hf(){if(K1)return jm;K1=1;var t=l2(),e=Sy().concat("length","prototype");return jm.f=Object.getOwnPropertyNames||function(r){return t(r,e)},jm}var Om,G1;function c2(){if(G1)return Om;G1=1;var t=Gs(),e=af(),n=zn()("match");return Om=function(r){var s;return t(r)&&((s=r[n])!==void 0?!!s:e(r)=="RegExp")},Om}var Im,J1;function KF(){if(J1)return Im;J1=1;var t=Yr(),e=fs(),n=Xr(),r=zn()("species");return Im=function(s){var i=t[s];n&&i&&!i[r]&&e.f(i,r,{configurable:!0,get:function(){return this}})},Im}var Y1;function GF(){if(Y1)return $1;Y1=1;var t=Yr(),e=qF(),n=fs().f,r=hf().f,s=c2(),i=uf(),o=t.RegExp,l=o,d=o.prototype,f=/a/g,h=/a/g,m=new o(f)!==f;if(Xr()&&(!m||ds()(function(){return h[zn()("match")]=!1,o(f)!=f||o(h)==h||o(f,"i")!="/a/i"}))){o=function(w,S){var N=this instanceof o,T=s(w),M=S===void 0;return!N&&T&&w.constructor===o&&M?w:e(m?new l(T&&!M?w.source:w,S):l((T=w instanceof o)?w.source:w,T&&M?i.call(w):S),N?this:d,o)};for(var g=function(k){k in o||n(o,k,{configurable:!0,get:function(){return l[k]},set:function(w){l[k]=w}})},v=r(l),x=0;v.length>x;)g(v[x++]);d.constructor=o,o.prototype=d,Js()(t,"RegExp",o)}return KF()("RegExp"),$1}GF();function Rt(t,e,n){return n=n||"",typeof t!="string"&&(t.global&&n.indexOf("g")<0&&(n+="g"),t.ignoreCase&&n.indexOf("i")<0&&(n+="i"),t.multiline&&n.indexOf("m")<0&&(n+="m"),t=t.source),new RegExp(t.replace(/#\{(\w+)\}/g,function(r,s){var i=e[s]||"";return typeof i!="string"&&(i=i.source),i}),n)}var u2=/\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/;const d2=Rt(/[#{spacesGroup}]/,{spacesGroup:u2});Rt("(^|#{spaces})(\\$)(#{cashtag})(?=$|\\s|[#{punct}])",{cashtag:WF,spaces:d2,punct:a2},"gi");var X1={},Q1;function JF(){if(Q1)return X1;Q1=1;var t=Or(),e=So(),n=hy(),r=my();return yy()("match",1,function(s,i,o,l){return[function(f){var h=s(this),m=f==null?void 0:f[i];return m!==void 0?m.call(f,h):new RegExp(f)[i](String(h))},function(d){var f=l(o,d,this);if(f.done)return f.value;var h=t(d),m=String(this);if(!h.global)return r(h,m);var g=h.unicode;h.lastIndex=0;for(var v=[],x=0,k;(k=r(h,m))!==null;){var w=String(k[0]);v[x]=w,w===""&&(h.lastIndex=n(m,e(h.lastIndex),g)),x++}return x===0?null:v}]}),X1}JF();var f2=/[##]/;Rt(/^(?:#{hashSigns}|:\/\/)/,{hashSigns:f2});var h2=Rt(RegExp("(?:(?:한국|香港|澳門|新加坡|台灣|台湾|中國|中国|გე|ລາວ|ไทย|ලංකා|ഭാരതം|ಭಾರತ|భారత్|சிங்கப்பூர்|இலங்கை|இந்தியா|ଭାରତ|ભારત|ਭਾਰਤ|ভাৰত|ভারত|বাংলা|भारोत|भारतम्|भारत|ڀارت|پاکستان|موريتانيا|مليسيا|مصر|قطر|فلسطين|عمان|عراق|سورية|سودان|تونس|بھارت|بارت|ایران|امارات|المغرب|السعودية|الجزائر|البحرين|الاردن|հայ|қаз|укр|срб|рф|мон|мкд|ею|бел|бг|ευ|ελ|zw|zm|za|yt|ye|ws|wf|vu|vn|vi|vg|ve|vc|va|uz|uy|us|um|uk|ug|ua|tz|tw|tv|tt|tr|tp|to|tn|tm|tl|tk|tj|th|tg|tf|td|tc|sz|sy|sx|sv|su|st|ss|sr|so|sn|sm|sl|sk|sj|si|sh|sg|se|sd|sc|sb|sa|rw|ru|rs|ro|re|qa|py|pw|pt|ps|pr|pn|pm|pl|pk|ph|pg|pf|pe|pa|om|nz|nu|nr|np|no|nl|ni|ng|nf|ne|nc|na|mz|my|mx|mw|mv|mu|mt|ms|mr|mq|mp|mo|mn|mm|ml|mk|mh|mg|mf|me|md|mc|ma|ly|lv|lu|lt|ls|lr|lk|li|lc|lb|la|kz|ky|kw|kr|kp|kn|km|ki|kh|kg|ke|jp|jo|jm|je|it|is|ir|iq|io|in|im|il|ie|id|hu|ht|hr|hn|hm|hk|gy|gw|gu|gt|gs|gr|gq|gp|gn|gm|gl|gi|gh|gg|gf|ge|gd|gb|ga|fr|fo|fm|fk|fj|fi|eu|et|es|er|eh|eg|ee|ec|dz|do|dm|dk|dj|de|cz|cy|cx|cw|cv|cu|cr|co|cn|cm|cl|ck|ci|ch|cg|cf|cd|cc|ca|bz|by|bw|bv|bt|bs|br|bq|bo|bn|bm|bl|bj|bi|bh|bg|bf|be|bd|bb|ba|az|ax|aw|au|at|as|ar|aq|ao|an|am|al|ai|ag|af|ae|ad|ac)(?=[^0-9a-zA-Z@+-]|$))")),p2=/\u202A-\u202E\u061C\u200E\u200F\u2066\u2067\u2068\u2069/,Ey=/\uFFFE\uFEFF\uFFFF/;function YF(t,e){return t.replace(/#\{(\w+)\}/g,function(n,r){return e[r]||""})}var XF=YF("#{punct}#{spacesGroup}#{invalidCharsGroup}#{directionalMarkersGroup}",{punct:a2,spacesGroup:u2,invalidCharsGroup:Ey,directionalMarkersGroup:p2}),m2=Rt(/[^#{invalidDomainChars}]/,{invalidDomainChars:XF}),QF=Rt(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:m2}),g2=Rt(RegExp("(?:(?:삼성|닷컴|닷넷|香格里拉|餐厅|食品|飞利浦|電訊盈科|集团|通販|购物|谷歌|诺基亚|联通|网络|网站|网店|网址|组织机构|移动|珠宝|点看|游戏|淡马锡|机构|書籍|时尚|新闻|政府|政务|招聘|手表|手机|我爱你|慈善|微博|广东|工行|家電|娱乐|天主教|大拿|大众汽车|在线|嘉里大酒店|嘉里|商标|商店|商城|公益|公司|八卦|健康|信息|佛山|企业|中文网|中信|世界|ポイント|ファッション|セール|ストア|コム|グーグル|クラウド|みんな|คอม|संगठन|नेट|कॉम|همراه|موقع|موبايلي|كوم|كاثوليك|عرب|شبكة|بيتك|بازار|العليان|ارامكو|اتصالات|ابوظبي|קום|сайт|рус|орг|онлайн|москва|ком|католик|дети|zuerich|zone|zippo|zip|zero|zara|zappos|yun|youtube|you|yokohama|yoga|yodobashi|yandex|yamaxun|yahoo|yachts|xyz|xxx|xperia|xin|xihuan|xfinity|xerox|xbox|wtf|wtc|wow|world|works|work|woodside|wolterskluwer|wme|winners|wine|windows|win|williamhill|wiki|wien|whoswho|weir|weibo|wedding|wed|website|weber|webcam|weatherchannel|weather|watches|watch|warman|wanggou|wang|walter|walmart|wales|vuelos|voyage|voto|voting|vote|volvo|volkswagen|vodka|vlaanderen|vivo|viva|vistaprint|vista|vision|visa|virgin|vip|vin|villas|viking|vig|video|viajes|vet|versicherung|vermögensberatung|vermögensberater|verisign|ventures|vegas|vanguard|vana|vacations|ups|uol|uno|university|unicom|uconnect|ubs|ubank|tvs|tushu|tunes|tui|tube|trv|trust|travelersinsurance|travelers|travelchannel|travel|training|trading|trade|toys|toyota|town|tours|total|toshiba|toray|top|tools|tokyo|today|tmall|tkmaxx|tjx|tjmaxx|tirol|tires|tips|tiffany|tienda|tickets|tiaa|theatre|theater|thd|teva|tennis|temasek|telefonica|telecity|tel|technology|tech|team|tdk|tci|taxi|tax|tattoo|tatar|tatamotors|target|taobao|talk|taipei|tab|systems|symantec|sydney|swiss|swiftcover|swatch|suzuki|surgery|surf|support|supply|supplies|sucks|style|study|studio|stream|store|storage|stockholm|stcgroup|stc|statoil|statefarm|statebank|starhub|star|staples|stada|srt|srl|spreadbetting|spot|sport|spiegel|space|soy|sony|song|solutions|solar|sohu|software|softbank|social|soccer|sncf|smile|smart|sling|skype|sky|skin|ski|site|singles|sina|silk|shriram|showtime|show|shouji|shopping|shop|shoes|shiksha|shia|shell|shaw|sharp|shangrila|sfr|sexy|sex|sew|seven|ses|services|sener|select|seek|security|secure|seat|search|scot|scor|scjohnson|science|schwarz|schule|school|scholarships|schmidt|schaeffler|scb|sca|sbs|sbi|saxo|save|sas|sarl|sapo|sap|sanofi|sandvikcoromant|sandvik|samsung|samsclub|salon|sale|sakura|safety|safe|saarland|ryukyu|rwe|run|ruhr|rugby|rsvp|room|rogers|rodeo|rocks|rocher|rmit|rip|rio|ril|rightathome|ricoh|richardli|rich|rexroth|reviews|review|restaurant|rest|republican|report|repair|rentals|rent|ren|reliance|reit|reisen|reise|rehab|redumbrella|redstone|red|recipes|realty|realtor|realestate|read|raid|radio|racing|qvc|quest|quebec|qpon|pwc|pub|prudential|pru|protection|property|properties|promo|progressive|prof|productions|prod|pro|prime|press|praxi|pramerica|post|porn|politie|poker|pohl|pnc|plus|plumbing|playstation|play|place|pizza|pioneer|pink|ping|pin|pid|pictures|pictet|pics|piaget|physio|photos|photography|photo|phone|philips|phd|pharmacy|pfizer|pet|pccw|pay|passagens|party|parts|partners|pars|paris|panerai|panasonic|pamperedchef|page|ovh|ott|otsuka|osaka|origins|orientexpress|organic|org|orange|oracle|open|ooo|onyourside|online|onl|ong|one|omega|ollo|oldnavy|olayangroup|olayan|okinawa|office|off|observer|obi|nyc|ntt|nrw|nra|nowtv|nowruz|now|norton|northwesternmutual|nokia|nissay|nissan|ninja|nikon|nike|nico|nhk|ngo|nfl|nexus|nextdirect|next|news|newholland|new|neustar|network|netflix|netbank|net|nec|nba|navy|natura|nationwide|name|nagoya|nadex|nab|mutuelle|mutual|museum|mtr|mtpc|mtn|msd|movistar|movie|mov|motorcycles|moto|moscow|mortgage|mormon|mopar|montblanc|monster|money|monash|mom|moi|moe|moda|mobily|mobile|mobi|mma|mls|mlb|mitsubishi|mit|mint|mini|mil|microsoft|miami|metlife|merckmsd|meo|menu|men|memorial|meme|melbourne|meet|media|med|mckinsey|mcdonalds|mcd|mba|mattel|maserati|marshalls|marriott|markets|marketing|market|map|mango|management|man|makeup|maison|maif|madrid|macys|luxury|luxe|lupin|lundbeck|ltda|ltd|lplfinancial|lpl|love|lotto|lotte|london|lol|loft|locus|locker|loans|loan|llp|llc|lixil|living|live|lipsy|link|linde|lincoln|limo|limited|lilly|like|lighting|lifestyle|lifeinsurance|life|lidl|liaison|lgbt|lexus|lego|legal|lefrak|leclerc|lease|lds|lawyer|law|latrobe|latino|lat|lasalle|lanxess|landrover|land|lancome|lancia|lancaster|lamer|lamborghini|ladbrokes|lacaixa|kyoto|kuokgroup|kred|krd|kpn|kpmg|kosher|komatsu|koeln|kiwi|kitchen|kindle|kinder|kim|kia|kfh|kerryproperties|kerrylogistics|kerryhotels|kddi|kaufen|juniper|juegos|jprs|jpmorgan|joy|jot|joburg|jobs|jnj|jmp|jll|jlc|jio|jewelry|jetzt|jeep|jcp|jcb|java|jaguar|iwc|iveco|itv|itau|istanbul|ist|ismaili|iselect|irish|ipiranga|investments|intuit|international|intel|int|insure|insurance|institute|ink|ing|info|infiniti|industries|inc|immobilien|immo|imdb|imamat|ikano|iinet|ifm|ieee|icu|ice|icbc|ibm|hyundai|hyatt|hughes|htc|hsbc|how|house|hotmail|hotels|hoteles|hot|hosting|host|hospital|horse|honeywell|honda|homesense|homes|homegoods|homedepot|holiday|holdings|hockey|hkt|hiv|hitachi|hisamitsu|hiphop|hgtv|hermes|here|helsinki|help|healthcare|health|hdfcbank|hdfc|hbo|haus|hangout|hamburg|hair|guru|guitars|guide|guge|gucci|guardian|group|grocery|gripe|green|gratis|graphics|grainger|gov|got|gop|google|goog|goodyear|goodhands|goo|golf|goldpoint|gold|godaddy|gmx|gmo|gmbh|gmail|globo|global|gle|glass|glade|giving|gives|gifts|gift|ggee|george|genting|gent|gea|gdn|gbiz|gay|garden|gap|games|game|gallup|gallo|gallery|gal|fyi|futbol|furniture|fund|fun|fujixerox|fujitsu|ftr|frontier|frontdoor|frogans|frl|fresenius|free|fox|foundation|forum|forsale|forex|ford|football|foodnetwork|food|foo|fly|flsmidth|flowers|florist|flir|flights|flickr|fitness|fit|fishing|fish|firmdale|firestone|fire|financial|finance|final|film|fido|fidelity|fiat|ferrero|ferrari|feedback|fedex|fast|fashion|farmers|farm|fans|fan|family|faith|fairwinds|fail|fage|extraspace|express|exposed|expert|exchange|everbank|events|eus|eurovision|etisalat|esurance|estate|esq|erni|ericsson|equipment|epson|epost|enterprises|engineering|engineer|energy|emerck|email|education|edu|edeka|eco|eat|earth|dvr|dvag|durban|dupont|duns|dunlop|duck|dubai|dtv|drive|download|dot|doosan|domains|doha|dog|dodge|doctor|docs|dnp|diy|dish|discover|discount|directory|direct|digital|diet|diamonds|dhl|dev|design|desi|dentist|dental|democrat|delta|deloitte|dell|delivery|degree|deals|dealer|deal|dds|dclk|day|datsun|dating|date|data|dance|dad|dabur|cyou|cymru|cuisinella|csc|cruises|cruise|crs|crown|cricket|creditunion|creditcard|credit|cpa|courses|coupons|coupon|country|corsica|coop|cool|cookingchannel|cooking|contractors|contact|consulting|construction|condos|comsec|computer|compare|company|community|commbank|comcast|com|cologne|college|coffee|codes|coach|clubmed|club|cloud|clothing|clinique|clinic|click|cleaning|claims|cityeats|city|citic|citi|citadel|cisco|circle|cipriani|church|chrysler|chrome|christmas|chloe|chintai|cheap|chat|chase|charity|channel|chanel|cfd|cfa|cern|ceo|center|ceb|cbs|cbre|cbn|cba|catholic|catering|cat|casino|cash|caseih|case|casa|cartier|cars|careers|career|care|cards|caravan|car|capitalone|capital|capetown|canon|cancerresearch|camp|camera|cam|calvinklein|call|cal|cafe|cab|bzh|buzz|buy|business|builders|build|bugatti|budapest|brussels|brother|broker|broadway|bridgestone|bradesco|box|boutique|bot|boston|bostik|bosch|boots|booking|book|boo|bond|bom|bofa|boehringer|boats|bnpparibas|bnl|bmw|bms|blue|bloomberg|blog|blockbuster|blanco|blackfriday|black|biz|bio|bingo|bing|bike|bid|bible|bharti|bet|bestbuy|best|berlin|bentley|beer|beauty|beats|bcn|bcg|bbva|bbt|bbc|bayern|bauhaus|basketball|baseball|bargains|barefoot|barclays|barclaycard|barcelona|bar|bank|band|bananarepublic|banamex|baidu|baby|azure|axa|aws|avianca|autos|auto|author|auspost|audio|audible|audi|auction|attorney|athleta|associates|asia|asda|arte|art|arpa|army|archi|aramco|arab|aquarelle|apple|app|apartments|aol|anz|anquan|android|analytics|amsterdam|amica|amfam|amex|americanfamily|americanexpress|alstom|alsace|ally|allstate|allfinanz|alipay|alibaba|alfaromeo|akdn|airtel|airforce|airbus|aigo|aig|agency|agakhan|africa|afl|afamilycompany|aetna|aero|aeg|adult|ads|adac|actor|active|aco|accountants|accountant|accenture|academy|abudhabi|abogado|able|abc|abbvie|abbott|abb|abarth|aarp|aaa|onion)(?=[^0-9a-zA-Z@+-]|$))")),v2=/(?:xn--[\-0-9a-z]+)/,ZF=Rt(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:m2}),ez=Rt(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/,{validDomainName:QF,validSubdomain:ZF,validGTLD:g2,validCCTLD:h2,validPunycode:v2}),tz=/[0-9]+/,y2=/\u0400-\u04FF/,pf=/\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u024F\u0253\u0254\u0256\u0257\u0259\u025B\u0263\u0268\u026F\u0272\u0289\u028B\u02BB\u0300-\u036F\u1E00-\u1EFF/,b2=Rt(/[a-z#{cyrillicLettersAndMarks}0-9!\*';:=\+,\.\$\/%#\[\]\-\u2013_~@\|&#{latinAccentChars}]/i,{cyrillicLettersAndMarks:y2,latinAccentChars:pf}),x2=Rt("\\((?:#{validGeneralUrlPathChars}+|(?:#{validGeneralUrlPathChars}*\\(#{validGeneralUrlPathChars}+\\)#{validGeneralUrlPathChars}*))\\)",{validGeneralUrlPathChars:b2},"i"),nz=Rt(/[\+\-a-z#{cyrillicLettersAndMarks}0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i,{cyrillicLettersAndMarks:y2,latinAccentChars:pf,validUrlBalancedParens:x2}),rz=Rt("(?:(?:#{validGeneralUrlPathChars}*(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*#{validUrlPathEndingChars})|(?:@#{validGeneralUrlPathChars}+/))",{validGeneralUrlPathChars:b2,validUrlBalancedParens:x2,validUrlPathEndingChars:nz},"i"),sz=Rt(/(?:[^A-Za-z0-9@@$###{invalidCharsGroup}]|[#{directionalMarkersGroup}]|^)/,{invalidCharsGroup:Ey,directionalMarkersGroup:p2}),w2=/[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i,k2=/[a-z0-9\-_&=#\/]/i,Z1=Rt("((#{validUrlPrecedingChars})((https?:\\/\\/)?(#{validDomain})(?::(#{validPortNumber}))?(\\/#{validUrlPath}*)?(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?))",{validUrlPrecedingChars:sz,validDomain:ez,validPortNumber:tz,validUrlPath:rz,validUrlQueryChars:w2,validUrlQueryEndingChars:k2},"gi"),iz=/[-_.\/]$/,eS={},Lm,tS;function oz(){if(tS)return Lm;tS=1;var t=Or(),e=df(),n=zn()("species");return Lm=function(r,s){var i=t(r).constructor,o;return i===void 0||(o=t(i)[n])==null?s:e(o)},Lm}var nS;function az(){if(nS)return eS;nS=1;var t=c2(),e=Or(),n=oz(),r=hy(),s=So(),i=my(),o=gy(),l=ds(),d=Math.min,f=[].push,h="split",m="length",g="lastIndex",v=4294967295,x=!l(function(){});return yy()("split",2,function(k,w,S,N){var T;return"abbc"[h](/(b)*/)[1]=="c"||"test"[h](/(?:)/,-1)[m]!=4||"ab"[h](/(?:ab)*/)[m]!=2||"."[h](/(.?)(.?)/)[m]!=4||"."[h](/()()/)[m]>1||""[h](/.?/)[m]?T=function(M,_){var R=String(this);if(M===void 0&&_===0)return[];if(!t(M))return S.call(R,M,_);for(var I=[],$=(M.ignoreCase?"i":"")+(M.multiline?"m":"")+(M.unicode?"u":"")+(M.sticky?"y":""),P=0,z=_===void 0?v:_>>>0,q=new RegExp(M.source,$+"g"),F,G,B;(F=o.call(q,R))&&(G=q[g],!(G>P&&(I.push(R.slice(P,F.index)),F[m]>1&&F.index<R[m]&&f.apply(I,F.slice(1)),B=F[0][m],P=G,I[m]>=z)));)q[g]===F.index&&q[g]++;return P===R[m]?(B||!q.test(""))&&I.push(""):I.push(R.slice(P)),I[m]>z?I.slice(0,z):I}:"0"[h](void 0,0)[m]?T=function(M,_){return M===void 0&&_===0?[]:S.call(this,M,_)}:T=S,[function(_,R){var I=k(this),$=_==null?void 0:_[w];return $!==void 0?$.call(_,I,R):T.call(String(I),_,R)},function(M,_){var R=N(T,M,this,_,T!==S);if(R.done)return R.value;var I=e(M),$=String(this),P=n(I,RegExp),z=I.unicode,q=(I.ignoreCase?"i":"")+(I.multiline?"m":"")+(I.unicode?"u":"")+(x?"y":"g"),F=new P(x?I:"^(?:"+I.source+")",q),G=_===void 0?v:_>>>0;if(G===0)return[];if($.length===0)return i(F,$)===null?[$]:[];for(var B=0,W=0,K=[];W<$.length;){F.lastIndex=x?W:0;var ne=i(F,x?$:$.slice(W)),V;if(ne===null||(V=d(s(F.lastIndex+(x?0:W)),$.length))===B)W=r($,W,z);else{if(K.push($.slice(B,W)),K.length===G)return K;for(var oe=1;oe<=ne.length-1;oe++)if(K.push(ne[oe]),K.length===G)return K;W=B=V}}return K.push($.slice(B)),K}]}),eS}az();var cl={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var lz=cl.exports,rS;function cz(){return rS||(rS=1,(function(t,e){(function(n){var r=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,i=typeof q0=="object"&&q0;(i.global===i||i.window===i||i.self===i)&&(n=i);var o,l=2147483647,d=36,f=1,h=26,m=38,g=700,v=72,x=128,k="-",w=/^xn--/,S=/[^\x20-\x7E]/,N=/[\x2E\u3002\uFF0E\uFF61]/g,T={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=d-f,_=Math.floor,R=String.fromCharCode,I;function $(J){throw new RangeError(T[J])}function P(J,A){for(var L=J.length,ee=[];L--;)ee[L]=A(J[L]);return ee}function z(J,A){var L=J.split("@"),ee="";L.length>1&&(ee=L[0]+"@",J=L[1]),J=J.replace(N,".");var pe=J.split("."),xe=P(pe,A).join(".");return ee+xe}function q(J){for(var A=[],L=0,ee=J.length,pe,xe;L<ee;)pe=J.charCodeAt(L++),pe>=55296&&pe<=56319&&L<ee?(xe=J.charCodeAt(L++),(xe&64512)==56320?A.push(((pe&1023)<<10)+(xe&1023)+65536):(A.push(pe),L--)):A.push(pe);return A}function F(J){return P(J,function(A){var L="";return A>65535&&(A-=65536,L+=R(A>>>10&1023|55296),A=56320|A&1023),L+=R(A),L}).join("")}function G(J){return J-48<10?J-22:J-65<26?J-65:J-97<26?J-97:d}function B(J,A){return J+22+75*(J<26)-((A!=0)<<5)}function W(J,A,L){var ee=0;for(J=L?_(J/g):J>>1,J+=_(J/A);J>M*h>>1;ee+=d)J=_(J/M);return _(ee+(M+1)*J/(J+m))}function K(J){var A=[],L=J.length,ee,pe=0,xe=x,re=v,Ne,ke,ze,Fe,Ge,Re,Ze,gt,ht;for(Ne=J.lastIndexOf(k),Ne<0&&(Ne=0),ke=0;ke<Ne;++ke)J.charCodeAt(ke)>=128&&$("not-basic"),A.push(J.charCodeAt(ke));for(ze=Ne>0?Ne+1:0;ze<L;){for(Fe=pe,Ge=1,Re=d;ze>=L&&$("invalid-input"),Ze=G(J.charCodeAt(ze++)),(Ze>=d||Ze>_((l-pe)/Ge))&&$("overflow"),pe+=Ze*Ge,gt=Re<=re?f:Re>=re+h?h:Re-re,!(Ze<gt);Re+=d)ht=d-gt,Ge>_(l/ht)&&$("overflow"),Ge*=ht;ee=A.length+1,re=W(pe-Fe,ee,Fe==0),_(pe/ee)>l-xe&&$("overflow"),xe+=_(pe/ee),pe%=ee,A.splice(pe++,0,xe)}return F(A)}function ne(J){var A,L,ee,pe,xe,re,Ne,ke,ze,Fe,Ge,Re=[],Ze,gt,ht,ge;for(J=q(J),Ze=J.length,A=x,L=0,xe=v,re=0;re<Ze;++re)Ge=J[re],Ge<128&&Re.push(R(Ge));for(ee=pe=Re.length,pe&&Re.push(k);ee<Ze;){for(Ne=l,re=0;re<Ze;++re)Ge=J[re],Ge>=A&&Ge<Ne&&(Ne=Ge);for(gt=ee+1,Ne-A>_((l-L)/gt)&&$("overflow"),L+=(Ne-A)*gt,A=Ne,re=0;re<Ze;++re)if(Ge=J[re],Ge<A&&++L>l&&$("overflow"),Ge==A){for(ke=L,ze=d;Fe=ze<=xe?f:ze>=xe+h?h:ze-xe,!(ke<Fe);ze+=d)ge=ke-Fe,ht=d-Fe,Re.push(R(B(Fe+ge%ht,0))),ke=_(ge/ht);Re.push(R(B(ke,0))),xe=W(L,gt,ee==pe),L=0,++ee}++L,++A}return Re.join("")}function V(J){return z(J,function(A){return w.test(A)?K(A.slice(4).toLowerCase()):A})}function oe(J){return z(J,function(A){return S.test(A)?"xn--"+ne(A):A})}if(o={version:"1.4.1",ucs2:{decode:q,encode:F},decode:K,encode:ne,toASCII:oe,toUnicode:V},r&&s)if(t.exports==r)s.exports=o;else for(I in o)o.hasOwnProperty(I)&&(r[I]=o[I]);else n.punycode=o})(lz)})(cl,cl.exports)),cl.exports}var uz=cz();const dz=Il(uz);var S2=Rt(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi,{latinAccentChars:pf,validGTLD:g2,validCCTLD:h2,validPunycode:v2}),fz=63,hz="xn--",pz={toAscii:function(e){if(!(e.substring(0,4)===hz&&!e.match(S2))){for(var n=e.split("."),r=0;r<n.length;r++){var s=n[r],i=dz.toASCII(s);if(i.length<1||i.length>fz)return}return n.join(".")}}},mz=Rt(/^https?:\/\/t\.co\/([a-z0-9]+)(?:\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?/,{validUrlQueryChars:w2,validUrlQueryEndingChars:k2},"i"),gz="https://",vz={extractUrlsWithoutProtocol:!0},yz=4096,bz=40,xz=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vz;if(!e||(n.extractUrlsWithoutProtocol?!e.match(/\./):!e.match(/:/)))return[];for(var r=[],s=function(){var l=RegExp.$2,d=RegExp.$3,f=RegExp.$4,h=RegExp.$5,m=RegExp.$7,g=Z1.lastIndex,v=g-d.length;if(!wz(d,f||gz,h))return"continue";if(f){if(d.match(mz)){var w=RegExp.$1;if(w&&w.length>bz)return"continue";d=RegExp.lastMatch,g=v+d.length}r.push({url:d,indices:[v,g]})}else{if(!n.extractUrlsWithoutProtocol||l.match(iz))return"continue";var x=null,k=0;if(h.replace(S2,function(S){var N=h.indexOf(S,k);k=N+S.length,x={url:S,indices:[v+N,v+k]},r.push(x)}),x==null)return"continue";m&&(x.url=d.replace(h,x.url),x.indices[1]=g)}};Z1.exec(e);)var i=s();return r},wz=function(e,n,r){var s=e.length,i=pz.toAscii(r);return!i||!i.length?!1:(s=s+i.length-r.length,n.length+s<=yz)},sS={},iS;function kz(){if(iS)return sS;iS=1;var t=Er(),e=df(),n=Bi(),r=ds(),s=[].sort,i=[1,2,3];return t(t.P+t.F*(r(function(){i.sort(void 0)})||!r(function(){i.sort(null)})||!ql()(s)),"Array",{sort:function(l){return l===void 0?s.call(n(this)):s.call(n(this),e(l))}}),sS}kz();var E2=/\ud800[\udc00-\udc0b\udc0d-\udc26\udc28-\udc3a\udc3c\udc3d\udc3f-\udc4d\udc50-\udc5d\udc80-\udcfa\uddfd\ude80-\ude9c\udea0-\uded0\udee0\udf00-\udf1f\udf30-\udf40\udf42-\udf49\udf50-\udf7a\udf80-\udf9d\udfa0-\udfc3\udfc8-\udfcf]|\ud801[\udc00-\udc9d\udd00-\udd27\udd30-\udd63\ude00-\udf36\udf40-\udf55\udf60-\udf67]|\ud802[\udc00-\udc05\udc08\udc0a-\udc35\udc37\udc38\udc3c\udc3f-\udc55\udc60-\udc76\udc80-\udc9e\udd00-\udd15\udd20-\udd39\udd80-\uddb7\uddbe\uddbf\ude00-\ude03\ude05\ude06\ude0c-\ude13\ude15-\ude17\ude19-\ude33\ude38-\ude3a\ude3f\ude60-\ude7c\ude80-\ude9c\udec0-\udec7\udec9-\udee6\udf00-\udf35\udf40-\udf55\udf60-\udf72\udf80-\udf91]|\ud803[\udc00-\udc48]|\ud804[\udc00-\udc46\udc7f-\udcba\udcd0-\udce8\udd00-\udd34\udd50-\udd73\udd76\udd80-\uddc4\uddda\ude00-\ude11\ude13-\ude37\udeb0-\udeea\udf01-\udf03\udf05-\udf0c\udf0f\udf10\udf13-\udf28\udf2a-\udf30\udf32\udf33\udf35-\udf39\udf3c-\udf44\udf47\udf48\udf4b-\udf4d\udf57\udf5d-\udf63\udf66-\udf6c\udf70-\udf74]|\ud805[\udc80-\udcc5\udcc7\udd80-\uddb5\uddb8-\uddc0\ude00-\ude40\ude44\ude80-\udeb7]|\ud806[\udca0-\udcdf\udcff\udec0-\udef8]|\ud808[\udc00-\udf98]|\ud80c[\udc00-\udfff]|\ud80d[\udc00-\udc2e]|\ud81a[\udc00-\ude38\ude40-\ude5e\uded0-\udeed\udef0-\udef4\udf00-\udf36\udf40-\udf43\udf63-\udf77\udf7d-\udf8f]|\ud81b[\udf00-\udf44\udf50-\udf7e\udf8f-\udf9f]|\ud82c[\udc00\udc01]|\ud82f[\udc00-\udc6a\udc70-\udc7c\udc80-\udc88\udc90-\udc99\udc9d\udc9e]|\ud834[\udd65-\udd69\udd6d-\udd72\udd7b-\udd82\udd85-\udd8b\uddaa-\uddad\ude42-\ude44]|\ud835[\udc00-\udc54\udc56-\udc9c\udc9e\udc9f\udca2\udca5\udca6\udca9-\udcac\udcae-\udcb9\udcbb\udcbd-\udcc3\udcc5-\udd05\udd07-\udd0a\udd0d-\udd14\udd16-\udd1c\udd1e-\udd39\udd3b-\udd3e\udd40-\udd44\udd46\udd4a-\udd50\udd52-\udea5\udea8-\udec0\udec2-\udeda\udedc-\udefa\udefc-\udf14\udf16-\udf34\udf36-\udf4e\udf50-\udf6e\udf70-\udf88\udf8a-\udfa8\udfaa-\udfc2\udfc4-\udfcb]|\ud83a[\udc00-\udcc4\udcd0-\udcd6]|\ud83b[\ude00-\ude03\ude05-\ude1f\ude21\ude22\ude24\ude27\ude29-\ude32\ude34-\ude37\ude39\ude3b\ude42\ude47\ude49\ude4b\ude4d-\ude4f\ude51\ude52\ude54\ude57\ude59\ude5b\ude5d\ude5f\ude61\ude62\ude64\ude67-\ude6a\ude6c-\ude72\ude74-\ude77\ude79-\ude7c\ude7e\ude80-\ude89\ude8b-\ude9b\udea1-\udea3\udea5-\udea9\udeab-\udebb]|\ud840[\udc00-\udfff]|\ud841[\udc00-\udfff]|\ud842[\udc00-\udfff]|\ud843[\udc00-\udfff]|\ud844[\udc00-\udfff]|\ud845[\udc00-\udfff]|\ud846[\udc00-\udfff]|\ud847[\udc00-\udfff]|\ud848[\udc00-\udfff]|\ud849[\udc00-\udfff]|\ud84a[\udc00-\udfff]|\ud84b[\udc00-\udfff]|\ud84c[\udc00-\udfff]|\ud84d[\udc00-\udfff]|\ud84e[\udc00-\udfff]|\ud84f[\udc00-\udfff]|\ud850[\udc00-\udfff]|\ud851[\udc00-\udfff]|\ud852[\udc00-\udfff]|\ud853[\udc00-\udfff]|\ud854[\udc00-\udfff]|\ud855[\udc00-\udfff]|\ud856[\udc00-\udfff]|\ud857[\udc00-\udfff]|\ud858[\udc00-\udfff]|\ud859[\udc00-\udfff]|\ud85a[\udc00-\udfff]|\ud85b[\udc00-\udfff]|\ud85c[\udc00-\udfff]|\ud85d[\udc00-\udfff]|\ud85e[\udc00-\udfff]|\ud85f[\udc00-\udfff]|\ud860[\udc00-\udfff]|\ud861[\udc00-\udfff]|\ud862[\udc00-\udfff]|\ud863[\udc00-\udfff]|\ud864[\udc00-\udfff]|\ud865[\udc00-\udfff]|\ud866[\udc00-\udfff]|\ud867[\udc00-\udfff]|\ud868[\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|\ud86a[\udc00-\udfff]|\ud86b[\udc00-\udfff]|\ud86c[\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]|\ud87e[\udc00-\ude1d]|\udb40[\udd00-\uddef]/,N2=/A-Za-z\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u052f\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u065f\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06ef\u06fa-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07ca-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0-\u08b2\u08e4-\u0963\u0971-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09f0\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a70-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0c00-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c81-\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0cf1\u0cf2\u0d01-\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u103f\u1050-\u108f\u109a-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16f1-\u16f8\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u180b-\u180d\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191e\u1920-\u192b\u1930-\u193b\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f\u1aa7\u1ab0-\u1abe\u1b00-\u1b4b\u1b6b-\u1b73\u1b80-\u1baf\u1bba-\u1bf3\u1c00-\u1c37\u1c4d-\u1c4f\u1c5a-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1cf8\u1cf9\u1d00-\u1df5\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u20d0-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005\u3006\u302a-\u302f\u3031-\u3035\u303b\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua672\ua674-\ua67d\ua67f-\ua69d\ua69f-\ua6e5\ua6f0\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua7ad\ua7b0\ua7b1\ua7f7-\ua827\ua840-\ua873\ua880-\ua8c4\ua8e0-\ua8f7\ua8fb\ua90a-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf\ua9e0-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa36\uaa40-\uaa4d\uaa60-\uaa76\uaa7a-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab5f\uab64\uab65\uabc0-\uabea\uabec\uabed\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf870-\uf87f\uf882\uf884-\uf89f\uf8b8\uf8c1-\uf8d6\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe2d\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc/,C2=/[\uD800-\uDBFF][\uDC00-\uDFFF]/gm,Sz=Rt(/(?:[#{bmpLetterAndMarks}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}))/,{bmpLetterAndMarks:N2,nonBmpCodePairs:C2,astralLetterAndMarks:E2}),Ez=/\ud801[\udca0-\udca9]|\ud804[\udc66-\udc6f\udcf0-\udcf9\udd36-\udd3f\uddd0-\uddd9\udef0-\udef9]|\ud805[\udcd0-\udcd9\ude50-\ude59\udec0-\udec9]|\ud806[\udce0-\udce9]|\ud81a[\ude60-\ude69\udf50-\udf59]|\ud835[\udfce-\udfff]/,Nz=/0-9\u0660-\u0669\u06f0-\u06f9\u07c0-\u07c9\u0966-\u096f\u09e6-\u09ef\u0a66-\u0a6f\u0ae6-\u0aef\u0b66-\u0b6f\u0be6-\u0bef\u0c66-\u0c6f\u0ce6-\u0cef\u0d66-\u0d6f\u0de6-\u0def\u0e50-\u0e59\u0ed0-\u0ed9\u0f20-\u0f29\u1040-\u1049\u1090-\u1099\u17e0-\u17e9\u1810-\u1819\u1946-\u194f\u19d0-\u19d9\u1a80-\u1a89\u1a90-\u1a99\u1b50-\u1b59\u1bb0-\u1bb9\u1c40-\u1c49\u1c50-\u1c59\ua620-\ua629\ua8d0-\ua8d9\ua900-\ua909\ua9d0-\ua9d9\ua9f0-\ua9f9\uaa50-\uaa59\uabf0-\uabf9\uff10-\uff19/,Cz=/_\u200c\u200d\ua67e\u05be\u05f3\u05f4\uff5e\u301c\u309b\u309c\u30a0\u30fb\u3003\u0f0b\u0f0c\xb7/,_2=Rt(/(?:[#{bmpLetterAndMarks}#{bmpNumerals}#{hashtagSpecialChars}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}|#{astralNumerals}))/,{bmpLetterAndMarks:N2,bmpNumerals:Nz,hashtagSpecialChars:Cz,nonBmpCodePairs:C2,astralLetterAndMarks:E2,astralNumerals:Ez}),_z=/(?:[^\uD800-\uDFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF])/,Tz=Rt(/(?:^|\uFE0E|\uFE0F|$|(?!#{hashtagAlphaNumeric}|&)#{codePoint})/,{codePoint:_z,hashtagAlphaNumeric:_2});Rt(/(#{hashtagBoundary})(#{hashSigns})(?!\uFE0F|\u20E3)(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi,{hashtagBoundary:Tz,hashSigns:f2,hashtagAlphaNumeric:_2,hashtagAlpha:Sz});var Ny=/[@@]/;Rt(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/,{atSigns:Ny,latinAccentChars:pf});var jz=/(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:^|[^a-zA-Z0-9_+~.-])(?:rt|RT|rT|Rt):?)/,Mz=Rt("(#{validMentionPrecedingChars})(#{atSigns})([a-zA-Z0-9_]{1,20})(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?",{validMentionPrecedingChars:jz,atSigns:Ny},"g"),oS={},aS={},lS;function Az(){return lS||(lS=1,Xr()&&/./g.flags!="g"&&fs().f(RegExp.prototype,"flags",{configurable:!0,get:uf()})),aS}var cS;function Rz(){if(cS)return oS;cS=1,Az();var t=Or(),e=uf(),n=Xr(),r="toString",s=/./[r],i=function(o){Js()(RegExp.prototype,r,o,!0)};return ds()(function(){return s.call({source:"a",flags:"b"})!="/a/b"})?i(function(){var l=t(this);return"/".concat(l.source,"/","flags"in l?l.flags:!n&&l instanceof RegExp?e.call(l):void 0)}):s.name!=r&&i(function(){return s.call(this)}),oS}Rz();var uS={},dS;function Oz(){if(dS)return uS;dS=1;var t=Date.prototype,e="Invalid Date",n="toString",r=t[n],s=t.getTime;return new Date(NaN)+""!=e&&Js()(t,n,function(){var o=s.call(this);return o===o?r.call(this):e}),uS}Oz();var fS={},hS;function Iz(){if(hS)return fS;hS=1;var t=py(),e={};return e[zn()("toStringTag")]="z",e+""!="[object z]"&&Js()(Object.prototype,"toString",function(){return"[object "+t(this)+"]"},!0),fS}Iz();const pS={defaults:{version:3,maxWeightedTweetLength:280,scale:100,defaultWeight:200,emojiParsingEnabled:!0,transformedURLLength:23,ranges:[{start:0,end:4351,weight:100},{start:8192,end:8205,weight:100},{start:8208,end:8223,weight:100},{start:8242,end:8247,weight:100}]}};Rt(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/,{atSigns:Ny,spaces:d2});var mS={},Dm,gS;function Cy(){if(gS)return Dm;gS=1;var t=af();return Dm=Array.isArray||function(n){return t(n)=="Array"},Dm}var vS;function Lz(){if(vS)return mS;vS=1;var t=Er();return t(t.S,"Array",{isArray:Cy()}),mS}Lz();var Dz=function(e,n){var r=n.defaultWeight,s=n.ranges,i=r,o=e.charCodeAt(0);if(Array.isArray(s))for(var l=0,d=s.length;l<d;l++){var f=s[l];if(o>=f.start&&o<=f.end){i=f.weight;break}}return i},yS={},Pm,bS;function Pz(){if(bS)return Pm;bS=1;var t=df(),e=Bi(),n=by(),r=So();return Pm=function(s,i,o,l,d){t(i);var f=e(s),h=n(f),m=r(f.length),g=d?m-1:0,v=d?-1:1;if(o<2)for(;;){if(g in h){l=h[g],g+=v;break}if(g+=v,d?g<0:m<=g)throw TypeError("Reduce of empty array with no initial value")}for(;d?g>=0:m>g;g+=v)g in h&&(l=i(l,h[g],g,f));return l},Pm}var xS;function Bz(){if(xS)return yS;xS=1;var t=Er(),e=Pz();return t(t.P+t.F*!ql()([].reduce,!0),"Array",{reduce:function(r){return e(this,r,arguments.length,arguments[1],!1)}}),yS}Bz();var wS={},Bm,kS;function $z(){if(kS)return Bm;kS=1;var t=zn()("unscopables"),e=Array.prototype;return e[t]==null&&$i()(e,t,{}),Bm=function(n){e[t][n]=!0},Bm}var $m,SS;function Fz(){return SS||(SS=1,$m=function(t,e){return{value:e,done:!!t}}),$m}var Fm,ES;function Kl(){return ES||(ES=1,Fm={}),Fm}var zm,NS;function Gl(){if(NS)return zm;NS=1;var t=l2(),e=Sy();return zm=Object.keys||function(r){return t(r,e)},zm}var Um,CS;function T2(){if(CS)return Um;CS=1;var t=fs(),e=Or(),n=Gl();return Um=Xr()?Object.defineProperties:function(s,i){e(s);for(var o=n(i),l=o.length,d=0,f;l>d;)t.f(s,f=o[d++],i[f]);return s},Um}var Hm,_S;function zz(){if(_S)return Hm;_S=1;var t=Yr().document;return Hm=t&&t.documentElement,Hm}var Wm,TS;function j2(){if(TS)return Wm;TS=1;var t=Or(),e=T2(),n=Sy(),r=ky()("IE_PROTO"),s=function(){},i="prototype",o=function(){var l=s2()("iframe"),d=n.length,f="<",h=">",m;for(l.style.display="none",zz().appendChild(l),l.src="javascript:",m=l.contentWindow.document,m.open(),m.write(f+"script"+h+"document.F=Object"+f+"/script"+h),m.close(),o=m.F;d--;)delete o[i][n[d]];return o()};return Wm=Object.create||function(d,f){var h;return d!==null?(s[i]=t(d),h=new s,s[i]=null,h[r]=d):h=o(),f===void 0?h:e(h,f)},Wm}var Vm,jS;function _y(){if(jS)return Vm;jS=1;var t=fs().f,e=Eo(),n=zn()("toStringTag");return Vm=function(r,s,i){r&&!e(r=i?r:r.prototype,n)&&t(r,n,{configurable:!0,value:s})},Vm}var qm,MS;function Uz(){if(MS)return qm;MS=1;var t=j2(),e=Vl(),n=_y(),r={};return $i()(r,zn()("iterator"),function(){return this}),qm=function(s,i,o){s.prototype=t(r,{next:e(1,o)}),n(s,i+" Iterator")},qm}var Km,AS;function Hz(){if(AS)return Km;AS=1;var t=Eo(),e=Bi(),n=ky()("IE_PROTO"),r=Object.prototype;return Km=Object.getPrototypeOf||function(s){return s=e(s),t(s,n)?s[n]:typeof s.constructor=="function"&&s instanceof s.constructor?s.constructor.prototype:s instanceof Object?r:null},Km}var Gm,RS;function M2(){if(RS)return Gm;RS=1;var t=lf(),e=Er(),n=Js(),r=$i(),s=Kl(),i=Uz(),o=_y(),l=Hz(),d=zn()("iterator"),f=!([].keys&&"next"in[].keys()),h="@@iterator",m="keys",g="values",v=function(){return this};return Gm=function(x,k,w,S,N,T,M){i(w,k,S);var _=function(ne){if(!f&&ne in P)return P[ne];switch(ne){case m:return function(){return new w(this,ne)};case g:return function(){return new w(this,ne)}}return function(){return new w(this,ne)}},R=k+" Iterator",I=N==g,$=!1,P=x.prototype,z=P[d]||P[h]||N&&P[N],q=z||_(N),F=N?I?_("entries"):q:void 0,G=k=="Array"&&P.entries||z,B,W,K;if(G&&(K=l(G.call(new x)),K!==Object.prototype&&K.next&&(o(K,R,!0),!t&&typeof K[d]!="function"&&r(K,d,v))),I&&z&&z.name!==g&&($=!0,q=function(){return z.call(this)}),(!t||M)&&(f||$||!P[d])&&r(P,d,q),s[k]=q,s[R]=v,N)if(B={values:I?q:_(g),keys:T?q:_(m),entries:F},M)for(W in B)W in P||n(P,W,B[W]);else e(e.P+e.F*(f||$),k,B);return B},Gm}var Jm,OS;function A2(){if(OS)return Jm;OS=1;var t=$z(),e=Fz(),n=Kl(),r=No();return Jm=M2()(Array,"Array",function(s,i){this._t=r(s),this._i=0,this._k=i},function(){var s=this._t,i=this._k,o=this._i++;return!s||o>=s.length?(this._t=void 0,e(1)):i=="keys"?e(0,o):i=="values"?e(0,s[o]):e(0,[o,s[o]])},"values"),n.Arguments=n.Array,t("keys"),t("values"),t("entries"),Jm}var IS;function Wz(){if(IS)return wS;IS=1;for(var t=A2(),e=Gl(),n=Js(),r=Yr(),s=$i(),i=Kl(),o=zn(),l=o("iterator"),d=o("toStringTag"),f=i.Array,h={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},m=e(h),g=0;g<m.length;g++){var v=m[g],x=h[v],k=r[v],w=k&&k.prototype,S;if(w&&(w[l]||s(w,l,f),w[d]||s(w,d,v),i[v]=f,x))for(S in t)w[S]||n(w,S,t[S],!0)}return wS}Wz();A2();var LS={},Ym,DS;function Vz(){if(DS)return Ym;DS=1;var t=Er(),e=ya(),n=ds();return Ym=function(r,s){var i=(e.Object||{})[r]||Object[r],o={};o[r]=s(i),t(t.S+t.F*n(function(){i(1)}),"Object",o)},Ym}var PS;function qz(){if(PS)return LS;PS=1;var t=Bi(),e=Gl();return Vz()("keys",function(){return function(r){return e(t(r))}}),LS}qz();var Kz=Rt(/[#{invalidCharsGroup}]/,{invalidCharsGroup:Ey});function Gz(t){return Kz.test(t)}var to={},Cu={},BS;function Jz(){return BS||(BS=1,Object.defineProperty(Cu,"__esModule",{value:!0}),Cu.default=/(?:\ud83d[\udc68\udc69])(?:\ud83c[\udffb-\udfff])?\u200d(?:\u2695\ufe0f|\u2696\ufe0f|\u2708\ufe0f|\ud83c[\udf3e\udf73\udf93\udfa4\udfa8\udfeb\udfed]|\ud83d[\udcbb\udcbc\udd27\udd2c\ude80\ude92]|\ud83e[\uddb0-\uddb3])|(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75]|\u26f9)((?:\ud83c[\udffb-\udfff]|\ufe0f)\u200d[\u2640\u2642]\ufe0f)|(?:\ud83c[\udfc3\udfc4\udfca]|\ud83d[\udc6e\udc71\udc73\udc77\udc81\udc82\udc86\udc87\ude45-\ude47\ude4b\ude4d\ude4e\udea3\udeb4-\udeb6]|\ud83e[\udd26\udd35\udd37-\udd39\udd3d\udd3e\uddb8\uddb9\uddd6-\udddd])(?:\ud83c[\udffb-\udfff])?\u200d[\u2640\u2642]\ufe0f|(?:\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d\udc8b\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\u2764\ufe0f\u200d\ud83d\udc68|\ud83d\udc68\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc68\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc68\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\u2764\ufe0f\u200d\ud83d[\udc68\udc69]|\ud83d\udc69\u200d\ud83d\udc66\u200d\ud83d\udc66|\ud83d\udc69\u200d\ud83d\udc67\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83c\udff3\ufe0f\u200d\ud83c\udf08|\ud83c\udff4\u200d\u2620\ufe0f|\ud83d\udc41\u200d\ud83d\udde8|\ud83d\udc68\u200d\ud83d[\udc66\udc67]|\ud83d\udc69\u200d\ud83d[\udc66\udc67]|\ud83d\udc6f\u200d\u2640\ufe0f|\ud83d\udc6f\u200d\u2642\ufe0f|\ud83e\udd3c\u200d\u2640\ufe0f|\ud83e\udd3c\u200d\u2642\ufe0f|\ud83e\uddde\u200d\u2640\ufe0f|\ud83e\uddde\u200d\u2642\ufe0f|\ud83e\udddf\u200d\u2640\ufe0f|\ud83e\udddf\u200d\u2642\ufe0f)|[#*0-9]\ufe0f?\u20e3|(?:[©®\u2122\u265f]\ufe0f)|(?:\ud83c[\udc04\udd70\udd71\udd7e\udd7f\ude02\ude1a\ude2f\ude37\udf21\udf24-\udf2c\udf36\udf7d\udf96\udf97\udf99-\udf9b\udf9e\udf9f\udfcd\udfce\udfd4-\udfdf\udff3\udff5\udff7]|\ud83d[\udc3f\udc41\udcfd\udd49\udd4a\udd6f\udd70\udd73\udd76-\udd79\udd87\udd8a-\udd8d\udda5\udda8\uddb1\uddb2\uddbc\uddc2-\uddc4\uddd1-\uddd3\udddc-\uddde\udde1\udde3\udde8\uddef\uddf3\uddfa\udecb\udecd-\udecf\udee0-\udee5\udee9\udef0\udef3]|[\u203c\u2049\u2139\u2194-\u2199\u21a9\u21aa\u231a\u231b\u2328\u23cf\u23ed-\u23ef\u23f1\u23f2\u23f8-\u23fa\u24c2\u25aa\u25ab\u25b6\u25c0\u25fb-\u25fe\u2600-\u2604\u260e\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262a\u262e\u262f\u2638-\u263a\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267b\u267f\u2692-\u2697\u2699\u269b\u269c\u26a0\u26a1\u26aa\u26ab\u26b0\u26b1\u26bd\u26be\u26c4\u26c5\u26c8\u26cf\u26d1\u26d3\u26d4\u26e9\u26ea\u26f0-\u26f5\u26f8\u26fa\u26fd\u2702\u2708\u2709\u270f\u2712\u2714\u2716\u271d\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u2764\u27a1\u2934\u2935\u2b05-\u2b07\u2b1b\u2b1c\u2b50\u2b55\u3030\u303d\u3297\u3299])(?:\ufe0f|(?!\ufe0e))|(?:(?:\ud83c[\udfcb\udfcc]|\ud83d[\udd74\udd75\udd90]|[\u261d\u26f7\u26f9\u270c\u270d])(?:\ufe0f|(?!\ufe0e))|(?:\ud83c[\udf85\udfc2-\udfc4\udfc7\udfca]|\ud83d[\udc42\udc43\udc46-\udc50\udc66-\udc69\udc6e\udc70-\udc78\udc7c\udc81-\udc83\udc85-\udc87\udcaa\udd7a\udd95\udd96\ude45-\ude47\ude4b-\ude4f\udea3\udeb4-\udeb6\udec0\udecc]|\ud83e[\udd18-\udd1c\udd1e\udd1f\udd26\udd30-\udd39\udd3d\udd3e\uddb5\uddb6\uddb8\uddb9\uddd1-\udddd]|[\u270a\u270b]))(?:\ud83c[\udffb-\udfff])?|(?:\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc73\udb40\udc63\udb40\udc74\udb40\udc7f|\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc77\udb40\udc6c\udb40\udc73\udb40\udc7f|\ud83c\udde6\ud83c[\udde8-\uddec\uddee\uddf1\uddf2\uddf4\uddf6-\uddfa\uddfc\uddfd\uddff]|\ud83c\udde7\ud83c[\udde6\udde7\udde9-\uddef\uddf1-\uddf4\uddf6-\uddf9\uddfb\uddfc\uddfe\uddff]|\ud83c\udde8\ud83c[\udde6\udde8\udde9\uddeb-\uddee\uddf0-\uddf5\uddf7\uddfa-\uddff]|\ud83c\udde9\ud83c[\uddea\uddec\uddef\uddf0\uddf2\uddf4\uddff]|\ud83c\uddea\ud83c[\udde6\udde8\uddea\uddec\udded\uddf7-\uddfa]|\ud83c\uddeb\ud83c[\uddee-\uddf0\uddf2\uddf4\uddf7]|\ud83c\uddec\ud83c[\udde6\udde7\udde9-\uddee\uddf1-\uddf3\uddf5-\uddfa\uddfc\uddfe]|\ud83c\udded\ud83c[\uddf0\uddf2\uddf3\uddf7\uddf9\uddfa]|\ud83c\uddee\ud83c[\udde8-\uddea\uddf1-\uddf4\uddf6-\uddf9]|\ud83c\uddef\ud83c[\uddea\uddf2\uddf4\uddf5]|\ud83c\uddf0\ud83c[\uddea\uddec-\uddee\uddf2\uddf3\uddf5\uddf7\uddfc\uddfe\uddff]|\ud83c\uddf1\ud83c[\udde6-\udde8\uddee\uddf0\uddf7-\uddfb\uddfe]|\ud83c\uddf2\ud83c[\udde6\udde8-\udded\uddf0-\uddff]|\ud83c\uddf3\ud83c[\udde6\udde8\uddea-\uddec\uddee\uddf1\uddf4\uddf5\uddf7\uddfa\uddff]|\ud83c\uddf4\ud83c\uddf2|\ud83c\uddf5\ud83c[\udde6\uddea-\udded\uddf0-\uddf3\uddf7-\uddf9\uddfc\uddfe]|\ud83c\uddf6\ud83c\udde6|\ud83c\uddf7\ud83c[\uddea\uddf4\uddf8\uddfa\uddfc]|\ud83c\uddf8\ud83c[\udde6-\uddea\uddec-\uddf4\uddf7-\uddf9\uddfb\uddfd-\uddff]|\ud83c\uddf9\ud83c[\udde6\udde8\udde9\uddeb-\udded\uddef-\uddf4\uddf7\uddf9\uddfb\uddfc\uddff]|\ud83c\uddfa\ud83c[\udde6\uddec\uddf2\uddf3\uddf8\uddfe\uddff]|\ud83c\uddfb\ud83c[\udde6\udde8\uddea\uddec\uddee\uddf3\uddfa]|\ud83c\uddfc\ud83c[\uddeb\uddf8]|\ud83c\uddfd\ud83c\uddf0|\ud83c\uddfe\ud83c[\uddea\uddf9]|\ud83c\uddff\ud83c[\udde6\uddf2\uddfc]|\ud83c[\udccf\udd8e\udd91-\udd9a\udde6-\uddff\ude01\ude32-\ude36\ude38-\ude3a\ude50\ude51\udf00-\udf20\udf2d-\udf35\udf37-\udf7c\udf7e-\udf84\udf86-\udf93\udfa0-\udfc1\udfc5\udfc6\udfc8\udfc9\udfcf-\udfd3\udfe0-\udff0\udff4\udff8-\udfff]|\ud83d[\udc00-\udc3e\udc40\udc44\udc45\udc51-\udc65\udc6a-\udc6d\udc6f\udc79-\udc7b\udc7d-\udc80\udc84\udc88-\udca9\udcab-\udcfc\udcff-\udd3d\udd4b-\udd4e\udd50-\udd67\udda4\uddfb-\ude44\ude48-\ude4a\ude80-\udea2\udea4-\udeb3\udeb7-\udebf\udec1-\udec5\uded0-\uded2\udeeb\udeec\udef4-\udef9]|\ud83e[\udd10-\udd17\udd1d\udd20-\udd25\udd27-\udd2f\udd3a\udd3c\udd40-\udd45\udd47-\udd70\udd73-\udd76\udd7a\udd7c-\udda2\uddb4\uddb7\uddc0-\uddc2\uddd0\uddde-\uddff]|[\u23e9-\u23ec\u23f0\u23f3\u267e\u26ce\u2705\u2728\u274c\u274e\u2753-\u2755\u2795-\u2797\u27b0\u27bf\ue50a])|\ufe0f/g),Cu}var $S;function Yz(){if($S)return to;$S=1,Object.defineProperty(to,"__esModule",{value:!0}),to.TypeName=void 0,to.parse=s,to.toCodePoints=d;var t=Jz(),e=n(t);function n(f){return f&&f.__esModule?f:{default:f}}var r=to.TypeName="emoji";function s(f,h){var m=h&&h.assetType?h.assetType:"svg",g=h&&h.buildUrl?h.buildUrl:function(S,N){return N==="png"?"https://twemoji.maxcdn.com/2/72x72/"+S+".png":"https://twemoji.maxcdn.com/2/svg/"+S+".svg"},v=[];for(e.default.lastIndex=0;;){var x=e.default.exec(f);if(!x)break;var k=x[0],w=d(l(k)).join("-");v.push({url:w?g(w,m):"",indices:[x.index,e.default.lastIndex],text:k,type:r})}return v}var i=/\uFE0F/g,o="‍",l=function(h){return h.indexOf(o)<0?h.replace(i,""):h};function d(f){for(var h=[],m=0,g=0,v=0;v<f.length;)m=f.charCodeAt(v++),g?(h.push((65536+(g-55296<<10)+(m-56320)).toString(16)),g=0):m>55296&&m<=56319?g=m:h.push(m.toString(16));return h}return to}var Xz=Yz(),Qz=function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:pS.defaults,r=Object.keys(n).length?n:pS.defaults,s=r.defaultWeight,i=r.emojiParsingEnabled,o=r.scale,l=r.maxWeightedTweetLength,d=r.transformedURLLength,f=typeof String.prototype.normalize=="function"?e.normalize():e,h=FS(xz(f)),m=i?FS(Xz.parse(f)):[],g=f.length,v=0,x=0,k=!0,w=0;w<g;w++){if(h[w]){var S=h[w],N=S.url;S.indices,v+=d*o,w+=N.length-1}else if(i&&m[w]){var T=m[w],M=T.text;T.indices,v+=s,w+=M.length-1}else w+=Zz(f,w)?1:0,v+=Dz(f.charAt(w),r);k&&(k=!Gz(f.substring(w,w+1))),k&&v<=l*o&&(x=w)}v=v/o,k=k&&v>0&&v<=l;var _=Math.floor(v/l*1e3),R=e.length-f.length;return x+=R,{weightedLength:v,valid:k,permillage:_,validRangeStart:0,validRangeEnd:x,displayRangeStart:0,displayRangeEnd:e.length>0?e.length-1:0}},FS=function(e){return e.reduce(function(n,r){return n[r.indices[0]]=r,n},{})},Zz=function(e,n){if(n<e.length-1){var r=e.charCodeAt(n),s=e.charCodeAt(n+1);return 55296<=r&&r<=56319&&56320<=s&&s<=57343}return!1},zS={},US;function eU(){if(US)return zS;US=1;var t=Er();return t(t.S+t.F*!Xr(),"Object",{defineProperty:fs().f}),zS}eU();var HS={},WS;function tU(){if(WS)return HS;WS=1;var t=Er();return t(t.S+t.F*!Xr(),"Object",{defineProperties:T2()}),HS}tU();var VS={},Xm={},qS;function Ty(){return qS||(qS=1,Xm.f=Object.getOwnPropertySymbols),Xm}var Qm,KS;function nU(){if(KS)return Qm;KS=1;var t=hf(),e=Ty(),n=Or(),r=Yr().Reflect;return Qm=r&&r.ownKeys||function(i){var o=t.f(n(i)),l=e.f;return l?o.concat(l(i)):o},Qm}var Zm,GS;function R2(){if(GS)return Zm;GS=1;var t=fs(),e=Vl();return Zm=function(n,r,s){r in n?t.f(n,r,e(0,s)):n[r]=s},Zm}var JS;function rU(){if(JS)return VS;JS=1;var t=Er(),e=nU(),n=No(),r=wy(),s=R2();return t(t.S,"Object",{getOwnPropertyDescriptors:function(o){for(var l=n(o),d=r.f,f=e(l),h={},m=0,g,v;f.length>m;)v=d(l,g=f[m++]),v!==void 0&&s(h,g,v);return h}}),VS}rU();var YS={},eg,XS;function sU(){if(XS)return eg;XS=1;var t=Gs(),e=Cy(),n=zn()("species");return eg=function(r){var s;return e(r)&&(s=r.constructor,typeof s=="function"&&(s===Array||e(s.prototype))&&(s=void 0),t(s)&&(s=s[n],s===null&&(s=void 0))),s===void 0?Array:s},eg}var tg,QS;function iU(){if(QS)return tg;QS=1;var t=sU();return tg=function(e,n){return new(t(e))(n)},tg}var ng,ZS;function O2(){if(ZS)return ng;ZS=1;var t=ff(),e=by(),n=Bi(),r=So(),s=iU();return ng=function(i,o){var l=i==1,d=i==2,f=i==3,h=i==4,m=i==6,g=i==5||m,v=o||s;return function(x,k,w){for(var S=n(x),N=e(S),T=t(k,w,3),M=r(N.length),_=0,R=l?v(x,M):d?v(x,0):void 0,I,$;M>_;_++)if((g||_ in N)&&(I=N[_],$=T(I,_,S),i)){if(l)R[_]=$;else if($)switch(i){case 3:return!0;case 5:return I;case 6:return _;case 2:R.push(I)}else if(h)return!1}return m?-1:f||h?h:R}},ng}var eE;function oU(){if(eE)return YS;eE=1;var t=Er(),e=O2()(0),n=ql()([].forEach,!0);return t(t.P+t.F*!n,"Array",{forEach:function(s){return e(this,s,arguments[1])}}),YS}oU();var tE={},nE;function aU(){if(nE)return tE;nE=1;var t=Er(),e=O2()(2);return t(t.P+t.F*!ql()([].filter,!0),"Array",{filter:function(r){return e(this,r,arguments[1])}}),tE}aU();var rE={},rg={exports:{}},sE;function lU(){if(sE)return rg.exports;sE=1;var t=Wl()("meta"),e=Gs(),n=Eo(),r=fs().f,s=0,i=Object.isExtensible||function(){return!0},o=!ds()(function(){return i(Object.preventExtensions({}))}),l=function(g){r(g,t,{value:{i:"O"+ ++s,w:{}}})},d=function(g,v){if(!e(g))return typeof g=="symbol"?g:(typeof g=="string"?"S":"P")+g;if(!n(g,t)){if(!i(g))return"F";if(!v)return"E";l(g)}return g[t].i},f=function(g,v){if(!n(g,t)){if(!i(g))return!0;if(!v)return!1;l(g)}return g[t].w},h=function(g){return o&&m.NEED&&i(g)&&!n(g,t)&&l(g),g},m=rg.exports={KEY:t,NEED:!1,fastKey:d,getWeak:f,onFreeze:h};return rg.exports}var sg={},iE;function I2(){return iE||(iE=1,sg.f=zn()),sg}var ig,oE;function cU(){if(oE)return ig;oE=1;var t=Yr(),e=ya(),n=lf(),r=I2(),s=fs().f;return ig=function(i){var o=e.Symbol||(e.Symbol=n?{}:t.Symbol||{});i.charAt(0)!="_"&&!(i in o)&&s(o,i,{value:r.f(i)})},ig}var og,aE;function uU(){if(aE)return og;aE=1;var t=Gl(),e=Ty(),n=xy();return og=function(r){var s=t(r),i=e.f;if(i)for(var o=i(r),l=n.f,d=0,f;o.length>d;)l.call(r,f=o[d++])&&s.push(f);return s},og}var ag={},lE;function dU(){if(lE)return ag;lE=1;var t=No(),e=hf().f,n={}.toString,r=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],s=function(i){try{return e(i)}catch{return r.slice()}};return ag.f=function(o){return r&&n.call(o)=="[object Window]"?s(o):e(t(o))},ag}var cE;function fU(){if(cE)return rE;cE=1;var t=Yr(),e=Eo(),n=Xr(),r=Er(),s=Js(),i=lU().KEY,o=ds(),l=cf(),d=_y(),f=Wl(),h=zn(),m=I2(),g=cU(),v=uU(),x=Cy(),k=Or(),w=Gs(),S=Bi(),N=No(),T=vy(),M=Vl(),_=j2(),R=dU(),I=wy(),$=Ty(),P=fs(),z=Gl(),q=I.f,F=P.f,G=R.f,B=t.Symbol,W=t.JSON,K=W&&W.stringify,ne="prototype",V=h("_hidden"),oe=h("toPrimitive"),J={}.propertyIsEnumerable,A=l("symbol-registry"),L=l("symbols"),ee=l("op-symbols"),pe=Object[ne],xe=typeof B=="function"&&!!$.f,re=t.QObject,Ne=!re||!re[ne]||!re[ne].findChild,ke=n&&o(function(){return _(F({},"a",{get:function(){return F(this,"a",{value:7}).a}})).a!=7})?function(ve,te,je){var Q=q(pe,te);Q&&delete pe[te],F(ve,te,je),Q&&ve!==pe&&F(pe,te,Q)}:F,ze=function(ve){var te=L[ve]=_(B[ne]);return te._k=ve,te},Fe=xe&&typeof B.iterator=="symbol"?function(ve){return typeof ve=="symbol"}:function(ve){return ve instanceof B},Ge=function(te,je,Q){return te===pe&&Ge(ee,je,Q),k(te),je=T(je,!0),k(Q),e(L,je)?(Q.enumerable?(e(te,V)&&te[V][je]&&(te[V][je]=!1),Q=_(Q,{enumerable:M(0,!1)})):(e(te,V)||F(te,V,M(1,{})),te[V][je]=!0),ke(te,je,Q)):F(te,je,Q)},Re=function(te,je){k(te);for(var Q=v(je=N(je)),de=0,fe=Q.length,Je;fe>de;)Ge(te,Je=Q[de++],je[Je]);return te},Ze=function(te,je){return je===void 0?_(te):Re(_(te),je)},gt=function(te){var je=J.call(this,te=T(te,!0));return this===pe&&e(L,te)&&!e(ee,te)?!1:je||!e(this,te)||!e(L,te)||e(this,V)&&this[V][te]?je:!0},ht=function(te,je){if(te=N(te),je=T(je,!0),!(te===pe&&e(L,je)&&!e(ee,je))){var Q=q(te,je);return Q&&e(L,je)&&!(e(te,V)&&te[V][je])&&(Q.enumerable=!0),Q}},ge=function(te){for(var je=G(N(te)),Q=[],de=0,fe;je.length>de;)!e(L,fe=je[de++])&&fe!=V&&fe!=i&&Q.push(fe);return Q},vt=function(te){for(var je=te===pe,Q=G(je?ee:N(te)),de=[],fe=0,Je;Q.length>fe;)e(L,Je=Q[fe++])&&(!je||e(pe,Je))&&de.push(L[Je]);return de};xe||(B=function(){if(this instanceof B)throw TypeError("Symbol is not a constructor!");var te=f(arguments.length>0?arguments[0]:void 0),je=function(Q){this===pe&&je.call(ee,Q),e(this,V)&&e(this[V],te)&&(this[V][te]=!1),ke(this,te,M(1,Q))};return n&&Ne&&ke(pe,te,{configurable:!0,set:je}),ze(te)},s(B[ne],"toString",function(){return this._k}),I.f=ht,P.f=Ge,hf().f=R.f=ge,xy().f=gt,$.f=vt,n&&!lf()&&s(pe,"propertyIsEnumerable",gt,!0),m.f=function(ve){return ze(h(ve))}),r(r.G+r.W+r.F*!xe,{Symbol:B});for(var _t="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),Et=0;_t.length>Et;)h(_t[Et++]);for(var Dt=z(h.store),ot=0;Dt.length>ot;)g(Dt[ot++]);r(r.S+r.F*!xe,"Symbol",{for:function(ve){return e(A,ve+="")?A[ve]:A[ve]=B(ve)},keyFor:function(te){if(!Fe(te))throw TypeError(te+" is not a symbol!");for(var je in A)if(A[je]===te)return je},useSetter:function(){Ne=!0},useSimple:function(){Ne=!1}}),r(r.S+r.F*!xe,"Object",{create:Ze,defineProperty:Ge,defineProperties:Re,getOwnPropertyDescriptor:ht,getOwnPropertyNames:ge,getOwnPropertySymbols:vt});var Le=o(function(){$.f(1)});return r(r.S+r.F*Le,"Object",{getOwnPropertySymbols:function(te){return $.f(S(te))}}),W&&r(r.S+r.F*(!xe||o(function(){var ve=B();return K([ve])!="[null]"||K({a:ve})!="{}"||K(Object(ve))!="{}"})),"JSON",{stringify:function(te){for(var je=[te],Q=1,de,fe;arguments.length>Q;)je.push(arguments[Q++]);if(fe=de=je[1],!(!w(de)&&te===void 0||Fe(te)))return x(de)||(de=function(Je,Ie){if(typeof fe=="function"&&(Ie=fe.call(this,Je,Ie)),!Fe(Ie))return Ie}),je[1]=de,K.apply(W,je)}}),B[ne][oe]||$i()(B[ne],oe,B[ne].valueOf),d(B,"Symbol"),d(Math,"Math",!0),d(t.JSON,"JSON",!0),rE}fU();Rt(/^#{validMentionOrList}$/,{validMentionOrList:Mz});var L2=/[a-z\u0400-\u04FF0-9\-._~]/i,D2=/(?:%[0-9a-f]{2})/i,P2=/[!$&'()*+,;=]/i,B2=Rt("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:)*",{validateUrlUnreserved:L2,validateUrlPctEncoded:D2,validateUrlSubDelims:P2},"i"),hU=/(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i,pU=/(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i,mU=/(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i,gU=Rt(/(?:(?:#{validateUrlSubDomainSegment}\.)*(?:#{validateUrlDomainSegment}\.)#{validateUrlDomainTld})/i,{validateUrlSubDomainSegment:mU,validateUrlDomainSegment:hU,validateUrlDomainTld:pU}),vU=/(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i,yU=Rt(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i,{validateUrlDecOctet:vU}),bU=/(?:\[[a-f0-9:\.]+\])/i,$2=Rt("(?:#{validateUrlIpv4}|#{validateUrlIpv6})",{validateUrlIpv4:yU,validateUrlIpv6:bU},"i"),xU=Rt("(?:#{validateUrlIp}|#{validateUrlDomain})",{validateUrlIp:$2,validateUrlDomain:gU},"i"),F2=/[0-9]{1,5}/;Rt("(?:(#{validateUrlUserinfo})@)?(#{validateUrlHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:B2,validateUrlHost:xU,validateUrlPort:F2},"i");var jy=Rt("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|[:|@])",{validateUrlUnreserved:L2,validateUrlPctEncoded:D2,validateUrlSubDelims:P2},"i");Rt(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:jy});Rt(/(\/#{validateUrlPchar}*)*/i,{validateUrlPchar:jy});Rt(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:jy});Rt("^(?:([^:/?#]+):\\/\\/)?([^/?#]*)([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$","i");var wU=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,kU=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,SU=/(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,EU=Rt(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i,{validateUrlUnicodeSubDomainSegment:wU,validateUrlUnicodeDomainSegment:kU,validateUrlUnicodeDomainTld:SU}),NU=Rt("(?:#{validateUrlIp}|#{validateUrlUnicodeDomain})",{validateUrlIp:$2,validateUrlUnicodeDomain:EU},"i");Rt("(?:(#{validateUrlUserinfo})@)?(#{validateUrlUnicodeHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:B2,validateUrlUnicodeHost:NU,validateUrlPort:F2},"i");var uE={},dE;function CU(){if(dE)return uE;dE=1;var t=r2()(!0);return M2()(String,"String",function(e){this._t=String(e),this._i=0},function(){var e=this._t,n=this._i,r;return n>=e.length?{value:void 0,done:!0}:(r=t(e,n),this._i+=r.length,{value:r,done:!1})}),uE}CU();var fE={},lg,hE;function _U(){if(hE)return lg;hE=1;var t=Or();return lg=function(e,n,r,s){try{return s?n(t(r)[0],r[1]):n(r)}catch(o){var i=e.return;throw i!==void 0&&t(i.call(e)),o}},lg}var cg,pE;function TU(){if(pE)return cg;pE=1;var t=Kl(),e=zn()("iterator"),n=Array.prototype;return cg=function(r){return r!==void 0&&(t.Array===r||n[e]===r)},cg}var ug,mE;function jU(){if(mE)return ug;mE=1;var t=py(),e=zn()("iterator"),n=Kl();return ug=ya().getIteratorMethod=function(r){if(r!=null)return r[e]||r["@@iterator"]||n[t(r)]},ug}var dg,gE;function MU(){if(gE)return dg;gE=1;var t=zn()("iterator"),e=!1;try{var n=[7][t]();n.return=function(){e=!0},Array.from(n,function(){throw 2})}catch{}return dg=function(r,s){if(!s&&!e)return!1;var i=!1;try{var o=[7],l=o[t]();l.next=function(){return{done:i=!0}},o[t]=function(){return l},r(o)}catch{}return i},dg}var vE;function AU(){if(vE)return fE;vE=1;var t=ff(),e=Er(),n=Bi(),r=_U(),s=TU(),i=So(),o=R2(),l=jU();return e(e.S+e.F*!MU()(function(d){Array.from(d)}),"Array",{from:function(f){var h=n(f),m=typeof this=="function"?this:Array,g=arguments.length,v=g>1?arguments[1]:void 0,x=v!==void 0,k=0,w=l(h),S,N,T,M;if(x&&(v=t(v,g>2?arguments[2]:void 0,2)),w!=null&&!(m==Array&&s(w)))for(M=w.call(h),N=new m;!(T=M.next()).done;k++)o(N,k,x?r(M,v,[T.value,k],!0):T.value);else for(S=i(h.length),N=new m(S);S>k;k++)o(N,k,x?v(h[k],k):h[k]);return N.length=k,N}}),fE}AU();const RU={parseTweet:Qz},{parseTweet:OU}=RU;function yE(t){return OU(t).weightedLength}const bE="ow-x-handle";function IU(){const[t,e]=b.useState(()=>localStorage.getItem(bE)||""),[n,r]=b.useState(!1),[s,i]=b.useState(""),o=b.useRef(null),l=b.useRef(null),d=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(bE,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=o.current)==null?void 0:m.focus()},0)};b.useEffect(()=>{if(!n)return;const m=g=>{l.current&&!l.current.contains(g.target)&&d()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n,s]);const h=t?`https://unavatar.io/twitter/${t}`:"";return c.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:l,children:[t?c.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:h,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):c.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&c.jsx("div",{className:"tweet-handle-popover",children:c.jsx("input",{ref:o,className:"tweet-handle-input",value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&d(),m.key==="Escape"&&r(!1)},placeholder:"your_handle",spellCheck:!1})})]})}const LU={tweet:!0,reply:!0,quote:!1};function xE(){return c.jsxs("div",{className:"tweet-skeleton",children:[c.jsxs("div",{className:"tweet-author-row",children:[c.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),c.jsxs("div",{className:"tweet-author-info",children:[c.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),c.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),c.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),c.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function DU(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function _u(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 Tu(t){var n;if(!t||typeof t=="string"||!t.content)return[];const e=[];for(let r=t.content.length-1;r>=0&&(t.content[r].type==="image"&&((n=t.content[r].attrs)!=null&&n.src));r--)e.unshift(t.content[r].attrs.src);return e}function wE(t,e){if(!t||typeof t=="string"||!t.content||e===0)return t;const n=t.content.slice(0,t.content.length-e);return n.length===0?{type:"doc",content:[{type:"paragraph",content:[]}]}:{...t,content:n}}function ju(t,e){const n=[];let r=0;return t.forEach((s,i)=>{if(!s)return;r>0&&n.push({type:"horizontalRule"});const o=s.getJSON();o.content&&n.push(...o.content);const l=e==null?void 0:e[i];if(l)for(const d of l){const f=crypto.randomUUID().replace(/-/g,"").slice(0,8);n.push({type:"image",attrs:{src:d,id:f}})}r++}),{type:"doc",content:n}}function kE(t,e){const n=[],r=s=>{var i;s.type==="image"&&((i=s.attrs)!=null&&i.src)&&n.push(s.attrs.src),s.content&&s.content.forEach(r)};return r(t.getJSON()),e&&n.push(...e),n.slice(0,4)}function Mu(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tweetContext:t}),keepalive:!0}).catch(()=>{})}function PU({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s,onActiveEditorChange:i,filename:o,title:l,autoplug:d}){var bt;const{tweet:f,loading:h,error:m}=NF(t==null?void 0:t.url),[g,v]=b.useState(()=>_u(e).map(Se=>{const We=Tu(Se);return wE(Se,We.length)})),[x,k]=b.useState(0),w=b.useRef([]),S=b.useRef(null),N=b.useRef(!0),T=b.useRef(!1),M=b.useRef(g.length),[_,R]=b.useState(()=>g.map(()=>0)),[I,$]=b.useState(0),[P,z]=b.useState(0),q=b.useRef(_u(e).map(Ce=>Tu(Ce))),[F,G]=b.useState(()=>_u(e).map(Se=>Tu(Se).length)),[B,W]=b.useState(null),[K,ne]=b.useState(),[V,oe]=b.useState(!1),[J,A]=b.useState("idle"),[L,ee]=b.useState(""),pe=b.useRef(),{copyText:xe,copyState:re}=jF(w,I),[Ne,ke]=b.useState(!1),ze=LU[(t==null?void 0:t.mode)??"tweet"],Fe=!!((bt=t==null?void 0:t.lastPost)!=null&&bt.postedAt),[Ge,Re]=b.useState(!1),[Ze,gt]=b.useState(""),ht=b.useRef(null),ge=b.useRef(null);b.useEffect(()=>{if(!Ge)return;setTimeout(()=>{var Se;return(Se=ht.current)==null?void 0:Se.focus()},0);const Ce=Se=>{ge.current&&!ge.current.contains(Se.target)&&(Re(!1),gt(""))};return document.addEventListener("mousedown",Ce),()=>document.removeEventListener("mousedown",Ce)},[Ge]);const vt=()=>{var tt;const Ce=Ze.trim();if(!(!Ce||Ce.includes("x.com")||Ce.includes("twitter.com")))return;const We=(tt=t==null?void 0:t.lastPost)==null?void 0:tt.postedAt;Mu({lastPost:{postedAt:We??new Date().toISOString(),tweetUrl:Ce||void 0}}),Re(!1),gt("")},_t=()=>{Mu({lastPost:null})},Et=d!==!1,Dt=()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoplug:!Et}),keepalive:!0}).catch(()=>{})};b.useEffect(()=>{let Ce=!1;return(async()=>{try{const Se=await fetch("/api/x/status");if(Ce)return;if(Se.ok){const We=await Se.json();W(We.connected),ne(We.username)}else W(!1)}catch{Ce||W(!1)}})(),()=>{Ce=!0}},[]),b.useEffect(()=>{if(N.current){N.current=!1;return}if(!e||JSON.stringify(e)===S.current)return;const Se=_u(e),We=Se.map(He=>Tu(He)),tt=Se.map((He,xt)=>wE(He,We[xt].length));T.current=!0,M.current=tt.length,w.current=[],q.current=We,v(tt),R(tt.map(()=>0)),G(We.map(He=>He.length)),k(He=>He+1)},[e]);const ot=b.useCallback((Ce,Se)=>{if(w.current[Ce]=Se,R(tt=>{const He=[...tt];return He[Ce]=yE(Se.getText()),He}),T.current)return;const We=ju(w.current,q.current);S.current=JSON.stringify(We),n==null||n(We)},[n]),Le=b.useCallback((Ce,Se)=>{if(w.current[Ce]=Se,R(We=>{const tt=[...We];return tt[Ce]=yE(Se.getText()),tt}),z(We=>We+1),T.current&&w.current.filter(Boolean).length>=M.current){T.current=!1;const tt=ju(w.current,q.current);S.current=JSON.stringify(tt)}Ce===0&&(r==null||r(Se)),s==null||s(w.current.filter(Boolean))},[r,s]),ve=g.length>1;_.reduce((Ce,Se)=>Ce+Se,0);const te=b.useCallback(()=>{const Ce=I+1;v(Se=>[...Se.slice(0,Ce),"<p></p>",...Se.slice(Ce)]),R(Se=>[...Se.slice(0,Ce),0,...Se.slice(Ce)]),q.current.splice(Ce,0,[]),G(Se=>[...Se.slice(0,Ce),0,...Se.slice(Ce)]),$(Ce)},[I]),je=b.useCallback(Ce=>{Ce!==0&&(w.current.splice(Ce,1),q.current.splice(Ce,1),v(Se=>Se.filter((We,tt)=>tt!==Ce)),R(Se=>Se.filter((We,tt)=>tt!==Ce)),G(Se=>Se.filter((We,tt)=>tt!==Ce)),setTimeout(()=>{const Se=ju(w.current,q.current);n==null||n(Se),s==null||s(w.current.filter(Boolean))},0))},[n,s]),Q=!!(t!=null&&t.url),de=(t==null?void 0:t.mode)==="reply",fe=(()=>{const Se=w.current.filter(Boolean).some(tt=>tt.getText().trim()||kE(tt).length>0),We=F.some(tt=>tt>0);return Se||We})(),Je=B&&fe&&J==="idle",Ie=async()=>{if(!B){oe(!0);return}if(Je){A("uploading"),ee("");try{const Ce=[];for(let We=0;We<w.current.length;We++){const tt=w.current[We];if(!tt)continue;const He=tt.getText().trim(),xt=kE(tt,q.current[We]);if(!He&&xt.length===0)continue;const j=[];for(const U of xt){const D=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:U})})).json();if(!D.success)throw new Error(D.error||"Image upload failed");j.push(D.mediaId)}Ce.push({text:He,mediaIds:j})}if(Ce.length===0)return;A("posting");const Se=DU(t==null?void 0:t.url);if(Ce.length===1){const We={};Ce[0].text&&(We.text=Ce[0].text),Ce[0].mediaIds.length>0&&(We.mediaIds=Ce[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&Se?We.replyTo=Se:(t==null?void 0:t.mode)==="quote"&&Se&&(We.quoteTweetId=Se);const He=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(We)})).json();He.success?(Mu({lastPost:{postedAt:new Date().toISOString(),tweetUrl:He.tweetUrl}}),A("success"),pe.current=setTimeout(()=>A("idle"),2500)):(console.error("[TweetCompose] Post error:",He.error),ee(He.error||"Post failed"),A("error"),setTimeout(()=>A("idle"),3e3))}else{const tt={tweets:Ce.map(j=>({text:j.text,...j.mediaIds.length>0?{mediaIds:j.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&Se&&(tt.replyTo=Se);const xt=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(tt)})).json();xt.success?(Mu({lastPost:{postedAt:new Date().toISOString(),tweetUrl:xt.threadUrl}}),A("success"),pe.current=setTimeout(()=>A("idle"),2500)):(ee(xt.error||"Thread post failed"),A("error"),setTimeout(()=>A("idle"),3e3))}}catch(Ce){ee(Ce.message||"Network error"),A("error"),setTimeout(()=>A("idle"),3e3)}}};b.useEffect(()=>()=>{pe.current&&clearTimeout(pe.current)},[]);const it=()=>{W(!0),oe(!1),fetch("/api/x/status").then(Ce=>Ce.json()).then(Ce=>{Ce.username&&ne(Ce.username)}).catch(()=>{})},dt=J==="uploading"?"Uploading...":J==="posting"?"Posting...":J==="success"?"Posted!":J==="error"?"Failed":ve?I===0?"Post Thread":"Post All":"Post",at=g.map((Ce,Se)=>Se===0?de?"Post your reply":"What is happening?!":"Add another tweet"),Ye=Ce=>{var Se;return c.jsxs("div",{className:`tweet-compose-footer${Ce?" tweet-compose-footer--inline":""}`,children:[I===0&&((Se=t==null?void 0:t.lastPost)==null?void 0:Se.postedAt)&&c.jsxs("a",{className:"tweet-posted-status",href:t.lastPost.tweetUrl,target:"_blank",rel:"noopener noreferrer",title:t.lastPost.tweetUrl||"Posted to X",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Posted ",new Date(t.lastPost.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),J==="error"&&L&&c.jsx("span",{className:"tweet-post-error",children:L}),ve&&c.jsxs("span",{className:"tweet-thread-counter",children:[I+1,"/",g.length]}),c.jsx(PF,{count:_[I]||0}),c.jsx("button",{className:"tweet-thread-add",onClick:te,title:"Add another tweet",children:c.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[c.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),c.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),c.jsx("button",{className:`tweet-copy-btn${re==="copied"?" tweet-copy-btn--copied":""}`,disabled:!fe,onClick:xe,title:"Copy tweet text to clipboard",children:re==="copied"?c.jsxs(c.Fragment,{children:[c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:c.jsx("path",{d:"M3 8.5L6.5 12L13 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied!"]}):c.jsxs(c.Fragment,{children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[c.jsx("rect",{x:"5.5",y:"2",width:"8.5",height:"10.5",rx:"1.5",stroke:"currentColor",strokeWidth:"1.5"}),c.jsx("path",{d:"M3.5 5H2.5A1.5 1.5 0 001 6.5V13a1.5 1.5 0 001.5 1.5H9A1.5 1.5 0 0010.5 13v-1",stroke:"currentColor",strokeWidth:"1.5"})]}),"Copy"]})}),I===0&&!ze&&(()=>{var He;const We=((He=t==null?void 0:t.lastPost)==null?void 0:He.tweetUrl)??"",tt=()=>{if(Fe){_t(),Re(!1),gt("");return}gt(We),Re(!0)};return c.jsxs("div",{className:"tweet-mark-sent-wrap",ref:ge,children:[c.jsx("button",{className:`tweet-mark-sent-btn${Fe?" tweet-mark-sent-btn--done":""}`,onClick:tt,title:Fe?We?`Posted — click to unmark (${We})`:"Posted — click to unmark":"Mark as manually posted",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:Fe?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("polyline",{points:"8 12 11 15 16 9",stroke:Fe?"#fff":"currentColor"})]})}),Ge&&(()=>{const xt=Ze.trim(),j=!xt||xt.includes("x.com")||xt.includes("twitter.com");return c.jsxs("div",{className:"tweet-mark-sent-url",children:[c.jsx("input",{ref:ht,type:"text",placeholder:"Paste posted tweet URL...",value:Ze,onChange:U=>gt(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),vt()),U.key==="Escape"&&(Re(!1),gt(""))}}),c.jsx("button",{onClick:vt,disabled:!j,title:xt?"Save URL":"Mark posted without URL",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})})()]})})(),c.jsx("button",{className:`tweet-autoplug-toggle${Et?" tweet-autoplug-toggle--on":""}`,onClick:Dt,title:Et?"Auto-plug ON — engagement autoplugs may reply to this post with your configured promo. Click to opt out.":"Auto-plug OFF — this post is excluded from autoplugs. Click to opt in.",children:Et?"Auto-plug on":"Auto-plug off"}),o&&!Fe&&c.jsx("button",{className:"tweet-schedule-btn",onClick:()=>ke(!0),title:"Schedule post",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("polyline",{points:"12 6 12 12 16 14"})]})}),ze&&c.jsx("button",{className:`tweet-post-btn${Je||!B&&B!==null?" tweet-post-btn--active":""}${J==="success"?" tweet-post-btn--success":""}${J==="error"?" tweet-post-btn--error":""}`,disabled:B?!Je:!1,onClick:Ie,title:B?K?`Post as @${K}`:"Post to X":"Connect X to post",children:dt})]})},qe=Q&&!de,lt=()=>c.jsx("div",{className:"tweet-thread-editors",children:g.map((Ce,Se)=>c.jsxs("div",{className:`tweet-thread-item${Se===I?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[c.jsxs("div",{className:"tweet-thread-item-left",children:[c.jsx(IU,{}),Se<g.length-1&&c.jsx("div",{className:"tweet-thread-line"})]}),c.jsxs("div",{className:"tweet-thread-item-right",children:[Se>0&&c.jsx("button",{className:"tweet-thread-remove",onClick:()=>je(Se),title:"Remove this tweet",children:"×"}),c.jsx("div",{className:`tweet-compose-box${Se===0&&!ve?" tweet-compose-box--standalone":""}`,children:c.jsx(DF,{initialContent:Ce,initialPreviewImages:q.current[Se],placeholder:at[Se],onUpdate:We=>ot(Se,We),onReady:We=>Le(Se,We),onFocus:()=>{$(Se);const We=w.current[Se];We&&(i==null||i(We))},onPreviewImagesChange:We=>{if(q.current[Se]=We,G(tt=>{const He=[...tt];return He[Se]=We.length,He}),!T.current){const tt=ju(w.current,q.current);S.current=JSON.stringify(tt),n==null||n(tt)}}})}),Se===I&&!qe&&Ye(Se<g.length-1)]})]},`${x}-${Se}`))});return c.jsxs("div",{className:"tweet-compose-wrapper",children:[Q&&de&&c.jsxs(c.Fragment,{children:[h&&c.jsx("div",{className:"tweet-context-section",children:c.jsx(xE,{})}),m&&c.jsx("div",{className:"tweet-context-section",children:c.jsxs("div",{className:"tweet-embed-error",children:[c.jsx("span",{children:"Could not load tweet"}),c.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]})}),f&&c.jsxs("div",{className:"tweet-reply-parent-section",children:[c.jsx("div",{className:"tweet-reply-parent-card",children:c.jsx(Vk,{tweet:f,url:t==null?void 0:t.url})}),c.jsxs("div",{className:"tweet-replying-to",children:["Replying to ",c.jsxs("span",{className:"tweet-reply-handle",children:["@",f.author.username]})]})]}),lt()]}),qe&&c.jsxs(c.Fragment,{children:[lt(),c.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[h&&c.jsx(xE,{}),m&&c.jsxs("div",{className:"tweet-embed-error",children:[c.jsx("span",{children:"Could not load tweet"}),c.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]}),f&&c.jsx(Vk,{tweet:f,url:t==null?void 0:t.url})]}),c.jsx("div",{className:"tweet-quote-footer",children:Ye()})]}),!Q&&lt(),V&&c.jsx(BF,{onConnected:it,onCancel:()=>oe(!1)}),Ne&&o&&c.jsx(Hl,{filename:o,title:l||"Untitled",onClose:()=>ke(!1)})]})}function BU(){const[t,e]=b.useState("idle"),n=b.useRef();return{copyAsHtml:b.useCallback(async()=>{const s=document.querySelector(".ProseMirror");if(!s)return;const i=s.cloneNode(!0);i.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(h=>h.remove());let o="";const l=document.querySelector(".article-title-input");l!=null&&l.value&&l.value!=="Untitled"&&(o+=`<h1>${l.value}</h1>
213
- `);const d=o+i.innerHTML,f=$U(i);try{const h=new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})});await navigator.clipboard.write([h])}catch{try{await navigator.clipboard.writeText(f)}catch{const h=document.createElement("textarea");h.value=f,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select(),document.execCommand("copy"),document.body.removeChild(h)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function $U(t){var n;const e=[];for(const r of t.children){const s=(n=r.innerText)==null?void 0:n.trim();s&&e.push(s)}return e.join(`
214
-
215
- `)}function z2(t,e){const n=b.useRef(null),r=b.useCallback(()=>{const o=n.current;o&&(o.style.height="auto",o.style.height=`${o.scrollHeight}px`)},[]);b.useLayoutEffect(()=>{r()},[t,r]);const s=b.useCallback(o=>{e(o.target.value.replace(/[\r\n]+/g," ")),r()},[e,r]),i=b.useCallback(o=>{var l;o.key==="Enter"&&(o.preventDefault(),(l=n.current)==null||l.blur())},[]);return{ref:n,onChange:s,onKeyDown:i}}function U2({pendingTitle:t,docId:e,baseClass:n,children:r}){const[s,i]=b.useState(!1),[o,l]=b.useState(!1);return b.useEffect(()=>{function d(f){const h=f.detail;h&&(e&&h.docId&&h.docId!==e||(i(!!h.titleFocused),l(!!h.titleShowOriginal)))}return window.addEventListener("ow-pending-review-cursor",d),()=>window.removeEventListener("ow-pending-review-cursor",d)},[e]),t?o?c.jsx("div",{className:`${n} ${n}--pending${s?" pending-active pending-active--original":""}`,title:`Showing original title. Toggle back to Modified to see the agent's proposal "${t.to}".`,"aria-label":`Original title ${t.from} (agent proposed ${t.to})`,children:c.jsx("span",{className:"pending-original",children:t.from})}):c.jsx("div",{className:`${n} ${n}--pending${s?" pending-active pending-active--insert":""}`,title:`Agent proposed rename from "${t.from}". Accept or reject in the Review panel.`,"aria-label":`Pending title rename from ${t.from} to ${t.to}`,children:c.jsx("span",{className:"pending-insert",children:t.to})}):c.jsx(c.Fragment,{children:r})}const fg="ow-x-handle",SE="ow-x-name",FU=new Set(["Untitled","New Document","Article"]);function zU({src:t,coverImages:e}){const[n,r]=b.useState(t?"display":"empty"),[s,i]=b.useState(t||""),[o,l]=b.useState(e||(t?[t]:[])),[d,f]=b.useState(""),[h,m]=b.useState(""),g=b.useRef(null);b.useEffect(()=>{t?(i(t),r("display")):e&&e.length>0?(i(e[0]),r("display")):(i(""),r("empty"),f(""),m(""))},[t,e]),b.useEffect(()=>{e&&e.length>0?l(e):l(t?[t]:[])},[e]);const v=s?o.indexOf(s):-1,x=o.length,k=x>1,w=b.useCallback(P=>{const z=o[P];z&&(i(z),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:z,coverImages:o}})}).catch(()=>{}))},[o]),S=b.useCallback(()=>{v>0&&w(v-1)},[v,w]),N=b.useCallback(()=>{v<x-1&&w(v+1)},[v,x,w]),T=b.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const P=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})});if(!P.ok){const q=await P.json().catch(()=>null);m((q==null?void 0:q.error)||`Generation failed (${P.status})`),r("prompt");return}const z=await P.json();if(z.success&&z.src){const q=[...o,z.src];l(q),i(z.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:z.src,coverImages:q}})}).catch(()=>{})}else m(z.error||"Generation failed"),r("prompt")}catch(P){m(P.message||"Network error"),r("prompt")}}},[d,o]),M=P=>{P.key==="Enter"&&T(),P.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var P;return(P=g.current)==null?void 0:P.focus()},0)},R=()=>{const P=o.filter(z=>z!==s);if(l(P),P.length>0){const z=Math.min(v,P.length-1),q=P[z];i(q),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:q,coverImages:P}})}).catch(()=>{})}else i(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},I=()=>{r("prompt"),setTimeout(()=>{var P;return(P=g.current)==null?void 0:P.focus()},0)},$=()=>{const P=document.createElement("a");P.href=s,P.download=`cover-${v+1}.png`,P.click()};return n==="display"&&s?c.jsxs("div",{className:"article-cover article-cover--display",children:[c.jsx("img",{className:"article-cover-img",src:s,alt:"Cover"}),c.jsxs("div",{className:"article-cover-overlay",children:[k&&c.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:S,disabled:v<=0,children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"15 18 9 12 15 6"})})}),c.jsxs("div",{className:"article-cover-overlay-center",children:[c.jsxs("button",{className:"article-cover-overlay-btn",onClick:I,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),c.jsxs("button",{className:"article-cover-overlay-btn",onClick:$,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),c.jsx("polyline",{points:"7 10 12 15 17 10"}),c.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),c.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:R,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),k&&c.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:N,disabled:v>=x-1,children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}),k&&c.jsxs("div",{className:"article-cover-counter",children:[v+1," / ",x]})]})]}):n==="loading"?c.jsxs("div",{className:"article-cover article-cover--loading",children:[c.jsx("div",{className:"article-cover-spinner"}),c.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?c.jsxs("div",{className:"article-cover article-cover--prompt",children:[c.jsxs("div",{className:"article-cover-prompt-row",children:[c.jsx("input",{ref:g,className:"article-cover-prompt-input",value:d,onChange:P=>f(P.target.value),onKeyDown:M,placeholder:"Describe your cover image...",spellCheck:!1}),c.jsx("button",{className:"article-cover-prompt-btn",onClick:T,disabled:!d.trim(),children:"Generate"}),c.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h&&c.jsx("div",{className:"article-cover-error",children:h})]}):c.jsxs("div",{className:"article-cover article-cover--empty",onClick:_,children:[c.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:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("polyline",{points:"21 15 16 10 5 21"})]}),c.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function UU(){const[t,e]=b.useState(()=>localStorage.getItem(fg)||""),[n,r]=b.useState(()=>localStorage.getItem(SE)||""),[s,i]=b.useState(!1),[o,l]=b.useState(""),d=b.useRef(null),f=b.useRef(null),h=()=>{const x=o.replace(/^@/,"").trim();x&&(localStorage.setItem(fg,x),e(x)),i(!1)},m=()=>{l(t),i(!0),setTimeout(()=>{var x;return(x=d.current)==null?void 0:x.focus()},0)};b.useEffect(()=>{if(!s)return;const x=k=>{f.current&&!f.current.contains(k.target)&&h()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[s,o]),b.useEffect(()=>{const x=()=>{e(localStorage.getItem(fg)||""),r(localStorage.getItem(SE)||"")};return window.addEventListener("storage",x),()=>window.removeEventListener("storage",x)},[]);const g=t?`https://unavatar.io/twitter/${t}`:"",v=n||t||"Set your @handle";return c.jsxs("div",{className:"article-byline",ref:f,children:[c.jsxs("div",{className:"article-byline-row",onClick:m,title:t?`@${t} — click to change`:"Set your @handle",children:[t?c.jsx("img",{className:"article-byline-avatar",src:g,alt:`@${t}`}):c.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),c.jsx("span",{className:"article-byline-name",children:v}),t&&c.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),s&&c.jsx("div",{className:"article-byline-popover",children:c.jsx("input",{ref:d,className:"article-byline-input",value:o,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&h(),x.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function HU({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s,lastPost:i,pendingTitle:o,docId:l,autoplug:d}){const{copyAsHtml:f,copyState:h}=BU(),[m,g]=b.useState(i?"done":"idle"),v=FU.has(e||"")?"":e||"",x=z2(v,z=>n==null?void 0:n(z||"Untitled")),[k,w]=b.useState(!1),[S,N]=b.useState(""),T=b.useRef(null),M=b.useRef(null);b.useEffect(()=>{g(i?"done":"idle")},[i]),b.useEffect(()=>{if(!k)return;setTimeout(()=>{var q;return(q=T.current)==null?void 0:q.focus()},0);const z=q=>{M.current&&!M.current.contains(q.target)&&(w(!1),N(""))};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[k]);const _=b.useCallback(()=>{const z=S.trim();if(!(!z||z.includes("x.com")||z.includes("twitter.com")))return;const F=(i==null?void 0:i.postedAt)??new Date().toISOString();fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:z?{postedAt:F,tweetUrl:z}:{postedAt:F}}}),keepalive:!0}).catch(()=>{}),g("done"),w(!1),N("")},[S,i==null?void 0:i.postedAt]),R=b.useCallback(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:null}}),keepalive:!0}).catch(()=>{}),g("idle")},[]),I=d!==!1,$=()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({autoplug:!I}),keepalive:!0}).catch(()=>{})},P=b.useCallback(()=>{if(m==="done"){R(),w(!1),N("");return}N((i==null?void 0:i.tweetUrl)??""),w(!0)},[m,i==null?void 0:i.tweetUrl,R]);return c.jsxs("div",{className:"article-compose-wrapper",children:[c.jsx(zU,{src:r,coverImages:s}),c.jsxs("div",{className:"article-compose-content",children:[c.jsx(U2,{pendingTitle:o,docId:l,baseClass:"article-title-input",children:c.jsx("textarea",{className:"article-title-input",ref:x.ref,value:v,onChange:x.onChange,onKeyDown:x.onKeyDown,placeholder:"Add a title",rows:1,spellCheck:!1})}),c.jsx(UU,{}),c.jsx("div",{className:"article-compose-body",children:t})]}),c.jsxs("div",{className:"article-compose-footer",children:[c.jsxs("div",{className:"article-mark-sent-wrap",ref:M,children:[c.jsx("button",{className:`article-mark-sent-btn${m==="done"?" article-mark-sent-btn--done":""}`,onClick:P,title:m==="done"?i!=null&&i.tweetUrl?`Posted — click to unmark (${i.tweetUrl})`:"Posted — click to unmark":"Mark as manually posted",children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:m==="done"?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("polyline",{points:"8 12 11 15 16 9",stroke:m==="done"?"#fff":"currentColor"})]})}),k&&(()=>{const z=S.trim(),q=!z||z.includes("x.com")||z.includes("twitter.com");return c.jsxs("div",{className:"article-mark-sent-url",children:[c.jsx("input",{ref:T,type:"text",placeholder:"Paste posted tweet URL...",value:S,onChange:F=>N(F.target.value),onKeyDown:F=>{F.key==="Enter"&&(F.preventDefault(),_()),F.key==="Escape"&&(w(!1),N(""))}}),c.jsx("button",{onClick:_,disabled:!q,title:z?"Save URL":"Mark posted without URL",children:c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})})()]}),c.jsx("button",{className:`article-autoplug-toggle${I?" article-autoplug-toggle--on":""}`,onClick:$,title:I?"Auto-plug ON — engagement autoplugs may reply to this post with your configured promo. Click to opt out.":"Auto-plug OFF — this post is excluded from autoplugs. Click to opt in.",children:I?"Auto-plug on":"Auto-plug off"}),m==="done"&&i&&(i.tweetUrl?c.jsxs("a",{className:"article-sent-status",href:i.tweetUrl,target:"_blank",rel:"noopener noreferrer",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}):c.jsxs("span",{className:"article-sent-status",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]})),c.jsx("button",{className:`article-copy-btn${h==="copied"?" article-copy-btn--copied":""}`,onClick:f,children:h==="copied"?c.jsxs(c.Fragment,{children:[c.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):c.jsxs(c.Fragment,{children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),c.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy as HTML"]})})]})]})}const EE=new Set(["Untitled","New Document","Blog"]),WU=[];function VU(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function NE(){return new Date().toISOString().split("T")[0]}function ao(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function qU({src:t,coverImages:e}){const[n,r]=b.useState(t?"display":"empty"),[s,i]=b.useState(t||""),[o,l]=b.useState(e||(t?[t]:[])),[d,f]=b.useState(""),[h,m]=b.useState(""),g=b.useRef(null);b.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),b.useEffect(()=>{e&&e.length>0?l(e):l(t?[t]:[])},[e]);const v=s?o.indexOf(s):-1,x=o.length,k=x>1,w=b.useCallback(P=>{const z=o[P];z&&(i(z),ao({coverImage:z,coverImages:o}))},[o]),S=b.useCallback(()=>{v>0&&w(v-1)},[v,w]),N=b.useCallback(()=>{v<x-1&&w(v+1)},[v,x,w]),T=b.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const P=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})});if(!P.ok){const q=await P.json().catch(()=>null);m((q==null?void 0:q.error)||`Generation failed (${P.status})`),r("prompt");return}const z=await P.json();if(z.success&&z.src){const q=[...o,z.src];l(q),i(z.src),r("display"),f(""),ao({coverImage:z.src,coverImages:q})}else m(z.error||"Generation failed"),r("prompt")}catch(P){m(P.message||"Network error"),r("prompt")}}},[d,o]),M=P=>{P.key==="Enter"&&T(),P.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var P;return(P=g.current)==null?void 0:P.focus()},0)},R=()=>{const P=o.filter(z=>z!==s);if(l(P),P.length>0){const z=Math.min(v,P.length-1),q=P[z];i(q),ao({coverImage:q,coverImages:P})}else i(""),r("empty"),ao({coverImage:void 0,coverImages:void 0})},I=()=>{r("prompt"),setTimeout(()=>{var P;return(P=g.current)==null?void 0:P.focus()},0)},$=()=>{const P=document.createElement("a");P.href=s,P.download=`cover-${v+1}.png`,P.click()};return n==="display"&&s?c.jsxs("div",{className:"blog-cover blog-cover--display",children:[c.jsx("img",{className:"blog-cover-img",src:s,alt:"Cover"}),c.jsxs("div",{className:"blog-cover-overlay",children:[k&&c.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:S,disabled:v<=0,children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"15 18 9 12 15 6"})})}),c.jsxs("div",{className:"blog-cover-overlay-center",children:[c.jsxs("button",{className:"blog-cover-btn",onClick:I,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),c.jsxs("button",{className:"blog-cover-btn",onClick:$,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),c.jsx("polyline",{points:"7 10 12 15 17 10"}),c.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),c.jsxs("button",{className:"blog-cover-btn blog-cover-btn--danger",onClick:R,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),k&&c.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:N,disabled:v>=x-1,children:c.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}),k&&c.jsxs("div",{className:"blog-cover-counter",children:[v+1," / ",x]})]})]}):n==="loading"?c.jsxs("div",{className:"blog-cover blog-cover--loading",children:[c.jsx("div",{className:"blog-cover-spinner"}),c.jsx("span",{className:"blog-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?c.jsxs("div",{className:"blog-cover blog-cover--prompt",children:[c.jsxs("div",{className:"blog-cover-prompt-row",children:[c.jsx("input",{ref:g,className:"blog-cover-prompt-input",value:d,onChange:P=>f(P.target.value),onKeyDown:M,placeholder:"Describe your cover image...",spellCheck:!1}),c.jsx("button",{className:"blog-cover-prompt-btn",onClick:T,disabled:!d.trim(),children:"Generate"}),c.jsx("button",{className:"blog-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h&&c.jsx("div",{className:"blog-cover-error",children:h})]}):c.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:_,children:[c.jsxs("svg",{className:"blog-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),c.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),c.jsx("polyline",{points:"21 15 16 10 5 21"})]}),c.jsx("span",{className:"blog-cover-hint",children:"Add a featured image"})]})}function KU({tags:t,onChange:e}){const[n,r]=b.useState(""),s=b.useRef(null),i=d=>{const f=d.trim().toLowerCase();f&&!t.includes(f)&&e([...t,f]),r("")},o=d=>e(t.filter(f=>f!==d)),l=d=>{(d.key==="Enter"||d.key===",")&&(d.preventDefault(),i(n)),d.key==="Backspace"&&!n&&t.length>0&&o(t[t.length-1])};return c.jsxs("div",{className:"blog-tags",onClick:()=>{var d;return(d=s.current)==null?void 0:d.focus()},children:[t.map(d=>c.jsxs("span",{className:"blog-tag",children:[d,c.jsx("button",{className:"blog-tag-remove",onClick:f=>{f.stopPropagation(),o(d)},children:c.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[c.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),c.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},d)),c.jsx("input",{ref:s,className:"blog-tag-input",value:n,onChange:d=>r(d.target.value),onKeyDown:l,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function GU({children:t,title:e,onTitleChange:n,blogContext:r,filename:s,pendingTitle:i,docId:o}){var oe,J;const l=r||{},d=!!(r!=null&&r.active),f=EE.has(e||"")?"":e||"",h=z2(f,A=>n==null?void 0:n(A||"Untitled")),[m,g]=b.useState(l.description||""),[v,x]=b.useState(l.date||NE()),[k,w]=b.useState(l.author||""),[S,N]=b.useState(l.slug||""),[T,M]=b.useState(!!l.slug),[_,R]=b.useState(!1),[I,$]=b.useState(!1),[P,z]=b.useState(!1),[q,F]=b.useState(!1),G=l.tags||WU,B=l.draft??!1;b.useEffect(()=>{g(l.description||""),x(l.date||NE()),w(l.author||""),N(l.slug||""),M(!!l.slug)},[s]),b.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_blog_sites",arguments:{}})}).then(A=>A.json()).then(A=>{var ee,pe;const L=(pe=(ee=A==null?void 0:A.content)==null?void 0:ee[0])!=null&&pe.text?JSON.parse(A.content[0].text):A;z(Array.isArray(L==null?void 0:L.sites)&&L.sites.length>0)}).catch(()=>{})},[]),b.useEffect(()=>{!T&&e&&!EE.has(e)&&N(VU(e))},[e,T]);const W=b.useCallback(()=>{d&&ao({description:m,date:v,author:k,slug:S})},[d,m,v,k,S]),K=m.length,ne=K>160;return c.jsxs("div",{className:"blog-compose-wrapper",children:[c.jsx(qU,{src:l.coverImage,coverImages:l.coverImages}),c.jsxs("div",{className:"blog-compose-content",children:[((oe=l.lastPublish)==null?void 0:oe.publishedAt)&&c.jsxs("a",{className:"blog-published-status",href:l.lastPublish.publishedUrl,target:"_blank",rel:"noopener noreferrer",title:l.lastPublish.publishedUrl||"Published",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Published ",new Date(l.lastPublish.publishedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),c.jsx(U2,{pendingTitle:i,docId:o,baseClass:"blog-title-input",children:c.jsx("textarea",{className:"blog-title-input",ref:h.ref,value:f,onChange:h.onChange,onKeyDown:h.onKeyDown,placeholder:"Post title",rows:1,spellCheck:!1})}),c.jsxs("div",{className:"blog-description-wrap",children:[c.jsx("textarea",{className:`blog-description-input${ne?" over-limit":""}`,value:m,onChange:A=>g(A.target.value),onBlur:W,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),c.jsxs("span",{className:`blog-description-count${ne?" over-limit":""}`,children:[K,"/160"]})]}),c.jsxs("div",{className:"blog-meta-toggle",onClick:()=>$(A=>!A),children:[c.jsx("svg",{className:`blog-meta-chevron${I?" open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"9 18 15 12 9 6"})}),c.jsx("span",{children:"Metadata"}),B&&c.jsx("span",{className:"blog-draft-badge",children:"Draft"})]}),I&&c.jsxs("div",{className:"blog-meta-fields",children:[c.jsxs("div",{className:"blog-meta-row",children:[c.jsx("label",{className:"blog-meta-label",children:"Date"}),c.jsx("input",{type:"date",className:"blog-meta-input",value:v,onChange:A=>x(A.target.value),onBlur:W})]}),c.jsxs("div",{className:"blog-meta-row",children:[c.jsx("label",{className:"blog-meta-label",children:"Author"}),c.jsx("input",{type:"text",className:"blog-meta-input",value:k,onChange:A=>w(A.target.value),onBlur:W,placeholder:"Author name",spellCheck:!1})]}),c.jsxs("div",{className:"blog-meta-row",children:[c.jsx("label",{className:"blog-meta-label",children:"Slug"}),c.jsx("input",{type:"text",className:"blog-meta-input",value:S,onChange:A=>{M(!0),N(A.target.value)},onBlur:W,placeholder:"auto-generated-from-title",spellCheck:!1})]}),c.jsxs("div",{className:"blog-meta-row",children:[c.jsx("label",{className:"blog-meta-label",children:"Tags"}),c.jsx(KU,{tags:G,onChange:A=>{d&&ao({tags:A})}})]}),c.jsxs("div",{className:"blog-meta-row",children:[c.jsx("label",{className:"blog-meta-label",children:"Draft"}),c.jsx("button",{className:`blog-draft-toggle${B?" active":""}`,onClick:()=>{d&&ao({draft:!B})},children:c.jsx("div",{className:"blog-draft-toggle-knob"})})]})]}),c.jsx("div",{className:"blog-compose-body",children:t})]}),c.jsx("div",{className:"blog-compose-footer",children:s&&c.jsxs("div",{className:"blog-footer-actions",children:[P&&c.jsxs("button",{className:"blog-footer-btn blog-footer-btn--primary",onClick:()=>F(!0),children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})}),(J=l.lastPublish)!=null&&J.publishedUrl?"Republish":"Publish"]}),c.jsxs("button",{className:"blog-footer-btn",onClick:()=>R(!0),children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]})}),_&&s&&c.jsx(Hl,{filename:s,title:e||"Untitled",onClose:()=>R(!1)}),q&&s&&c.jsx(zT,{filename:s,title:e||"Untitled",isActive:!0,onSwitchDocument:()=>{},onClose:()=>F(!1)})]})}function JU({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,o]=b.useState("confirm"),[l,d]=b.useState("html"),[f,h]=b.useState(""),[m,g]=b.useState(null),[v,x]=b.useState(null),[k,w]=b.useState(0),[S,N]=b.useState(null),[T,M]=b.useState(null),[_,R]=b.useState("all"),[I,$]=b.useState([]),[P,z]=b.useState(""),q=b.useRef(null),F=I.find(K=>K.id===P),G=_==="exclude_issue"&&F&&T!=null?Math.max(0,T-F.recipient_count):T;b.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(K=>K.json()).then(K=>{var V,oe;const ne=(oe=(V=K.content)==null?void 0:V[0])!=null&&oe.text?JSON.parse(K.content[0].text):K;ne.count!=null&&M(ne.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(K=>K.json()).then(K=>{var V,oe;const ne=(oe=(V=K.content)==null?void 0:V[0])!=null&&oe.text?JSON.parse(K.content[0].text):K;ne.issues&&$(ne.issues)}).catch(()=>{})},[]);const B=()=>i==="sent"?{sentCount:k,issueId:S,sentAt:new Date().toISOString()}:void 0;b.useEffect(()=>{const K=ne=>{i!=="sending"&&i!=="testing"&&q.current&&!q.current.contains(ne.target)&&s(B())};return document.addEventListener("mousedown",K),()=>document.removeEventListener("mousedown",K)},[s,i,k,S]),b.useEffect(()=>{const K=ne=>{ne.key==="Escape"&&i!=="sending"&&i!=="testing"&&s(B())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[s,i,k,S]);async function W(K){var ne,V;o(K?"testing":"sending"),x(null);try{r&&await r();const oe={subject:e,connectionId:t,format:l};K&&(oe.test_email=K),!K&&_==="exclude_issue"&&P&&(oe.exclude_issue_id=P);const A=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"send_newsletter",arguments:oe})})).json(),L=(V=(ne=A.content)==null?void 0:ne[0])!=null&&V.text?JSON.parse(A.content[0].text):A;if(L.error){x(L.error),o("error");return}if(L.test){g(L.sent_to),o("confirm");return}const ee=L.sent||0,pe=L.issueId||null,xe=new Date().toISOString();w(ee),N(pe),o("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:ee,sentAt:xe,issueId:pe||void 0}}})}).catch(()=>{})}catch(oe){x(oe.message),o("error")}}return c.jsx("div",{className:"newsletter-modal-overlay",children:c.jsxs("div",{className:"newsletter-modal",ref:q,children:[c.jsxs("div",{className:"newsletter-modal__header",children:[c.jsx("h3",{children:"Send Newsletter"}),c.jsx("button",{className:"newsletter-modal__close",onClick:()=>s(B()),children:"×"})]}),c.jsxs("div",{className:"newsletter-modal__body",children:[i==="confirm"&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:"newsletter-modal__confirm-text",style:G==null?{visibility:"hidden"}:void 0,children:['Send "',c.jsx("strong",{children:e}),'" to ',G!=null?G.toLocaleString():0," subscriber",G!==1?"s":"","?"]}),c.jsxs("div",{className:"newsletter-modal__audience",children:[c.jsx("label",{className:"newsletter-modal__label",children:"Audience"}),c.jsxs("select",{className:"newsletter-modal__select",value:_,onChange:K=>{const ne=K.target.value;R(ne),ne==="all"&&z("")},children:[c.jsx("option",{value:"all",children:"All subscribers"}),I.length>0&&c.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),_==="exclude_issue"&&c.jsxs("select",{className:"newsletter-modal__select",value:P,onChange:K=>z(K.target.value),children:[c.jsx("option",{value:"",children:"Select a past issue"}),I.map(K=>c.jsxs("option",{value:K.id,children:[K.subject," (",K.recipient_count," sent)"]},K.id))]})]}),c.jsxs("div",{className:"newsletter-modal__format-toggle",children:[c.jsx("button",{className:`newsletter-modal__format-btn${l==="html"?" active":""}`,onClick:()=>d("html"),children:"HTML"}),c.jsx("button",{className:`newsletter-modal__format-btn${l==="plaintext"?" active":""}`,onClick:()=>d("plaintext"),children:"Plaintext"})]}),c.jsxs("div",{className:"newsletter-modal__test-section",children:[c.jsxs("div",{className:"newsletter-modal__test-row",children:[c.jsx("input",{type:"email",className:"newsletter-modal__test-input",placeholder:"Test email address",value:f,onChange:K=>h(K.target.value),onKeyDown:K=>{K.key==="Enter"&&f.trim()&&W(f.trim())}}),c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>W(f.trim()),children:"Send Test"})]}),m&&c.jsxs("p",{className:"newsletter-modal__test-success",children:["Test sent to ",m]})]}),c.jsxs("div",{className:"newsletter-modal__actions",children:[c.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",disabled:_==="exclude_issue"&&!P,onClick:()=>W(),children:"Send Now"})]})]}),(i==="sending"||i==="testing")&&c.jsxs("div",{className:"newsletter-modal__status",children:[c.jsx("div",{className:"newsletter-modal__spinner"}),c.jsx("span",{children:i==="testing"?"Sending test...":"Sending..."})]}),i==="sent"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:["Sent to ",k," subscriber",k!==1?"s":"","!"]}),c.jsx("div",{className:"newsletter-modal__actions",children:c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:k,issueId:S,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"newsletter-modal__error",children:v}),c.jsxs("div",{className:"newsletter-modal__actions",children:[c.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),c.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>W(),children:"Retry"})]})]})]})]})})}function CE(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function YU({children:t,newsletterContext:e,filename:n,title:r,onTitleChange:s,onBeforeSend:i}){var B;const o=e||{},[l,d]=b.useState(o.subject||""),[f,h]=b.useState(o.previewText||""),[m,g]=b.useState([]),[v,x]=b.useState(null),[k,w]=b.useState(!1),[S,N]=b.useState((B=o.lastSend)!=null&&B.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null),T=b.useRef(null),M=b.useRef(n),_=b.useRef(o.subject||""),R=b.useRef(o.previewText||"");b.useEffect(()=>{var W;if(M.current!==n)d(o.subject||""),h(o.previewText||""),_.current=o.subject||"",R.current=o.previewText||"",M.current=n;else{const K=o.subject||"",ne=o.previewText||"";K!==_.current&&(d(K),_.current=K),ne!==R.current&&(h(ne),R.current=ne)}N((W=o.lastSend)!=null&&W.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null)},[e,n]),b.useEffect(()=>{fetch("/api/connections").then(W=>W.json()).then(W=>{const K=(W.connections||[]).filter(ne=>ne.provider==="newsletter"&&ne.status==="active");g(K)}).catch(()=>{})},[]);const I=!!(e!=null&&e.active),$=b.useRef();b.useEffect(()=>{if($.current&&clearTimeout($.current),!(!s||!l.trim()))return $.current=setTimeout(async()=>{const W=r,K=!W||W==="Untitled",ne=T.current!==null&&W===T.current;if(K||ne){try{await fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{subject:l}})})}catch{}s(l.trim()),T.current=l.trim()}},500),()=>{$.current&&clearTimeout($.current)}},[l,r,s]);const P=b.useCallback(()=>{I&&(_.current=l,R.current=f,CE({subject:l,previewText:f}))},[I,l,f]),z=f.length,q=z>=90,F=z>150,G=()=>{m.length===1&&x(m[0].id),m.length>1&&x(m[0].id)};return c.jsxs("div",{className:"nl-compose-wrapper",children:[S&&c.jsxs("div",{className:"nl-sent-status",children:[c.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:c.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent ",new Date(S.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",S.sentCount," subscriber",S.sentCount!==1?"s":""]}),c.jsxs("div",{className:"nl-compose-content",children:[c.jsx("input",{className:"nl-subject-input",type:"text",value:l,onChange:W=>d(W.target.value),onBlur:P,placeholder:"Subject line (defaults to title if empty)",autoComplete:"off","data-lpignore":"true","data-1p-ignore":!0,spellCheck:!1}),c.jsxs("div",{className:"nl-preview-wrap",children:[c.jsx("textarea",{className:`nl-preview-input${F?" over-limit":""}`,value:f,onChange:W=>h(W.target.value),onBlur:P,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),c.jsxs("span",{className:`nl-preview-count${F?" over-limit":q?" full":""}`,children:[z,"/90"]})]}),c.jsx("div",{className:"nl-compose-body",children:t})]}),n&&c.jsxs("div",{className:"nl-compose-footer",children:[m.length>0&&c.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:G,children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Send"]}),c.jsxs("button",{className:"nl-footer-btn",onClick:()=>w(!0),children:[c.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("circle",{cx:"12",cy:"12",r:"10"}),c.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]}),v&&n&&c.jsx(JU,{connectionId:v,subject:l||r||"Untitled",filename:n,onBeforeSend:i,onClose:W=>{x(null),W&&(N(W),CE({lastSend:{sentCount:W.sentCount,sentAt:W.sentAt,issueId:W.issueId||void 0}}))}}),k&&n&&c.jsx(Hl,{filename:n,title:r||"Untitled",onClose:()=>w(!1)})]})}const _E=600,XU=48;function Au(t){return t!=null&&typeof t=="object"&&Object.keys(t).length>0}function QU(t){const e=typeof(t==null?void 0:t.content_type)=="string"&&t.content_type||typeof(t==null?void 0:t.contentType)=="string"&&t.contentType||"";return e||(Au(t==null?void 0:t.blogContext)?"blog":t!=null&&t.newsletterContext&&(t.newsletterContext.active===!0||Au(t.newsletterContext))?"newsletter":Au(t==null?void 0:t.articleContext)?"article":t!=null&&t.tweetContext?t.tweetContext.mode||"tweet":Au(t==null?void 0:t.linkedinContext)?"linkedin":"document")}function ZU(){var Nr,Ts,An;const t=b.useRef(null),e=b.useRef([]),[n,r]=b.useState(null),[s,i]=b.useState(null),[o,l]=b.useState([]),[d,f]=b.useState("Untitled"),[h,m]=b.useState(null),[g,v]=b.useState(void 0),[x,k]=b.useState(0),[w,S]=b.useState(!0),[N,T]=b.useState(0),[M,_]=b.useState(0),[R,I]=b.useState(0),[$,P]=b.useState({filenames:[],counts:{}}),[z,q]=b.useState({state:"unconfigured"}),[F,G]=b.useState(!1),[B,W]=b.useState({}),[K,ne]=b.useState(!1),[V,oe]=b.useState(null),[J,A]=b.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[L,ee]=b.useState(!1),pe=b.useRef(null),xe=b.useRef(null),[re,Ne]=b.useState(0),[ke,ze]=b.useState(!1),[Fe,Ge]=b.useState(!1),[Re,Ze]=b.useState(()=>{try{const Y=localStorage.getItem("ow-sidebar-width");if(Y){const ye=parseInt(Y,10);if(!isNaN(ye)&&ye>=WT&&ye<=VT)return ye}}catch{}return nv}),{open:gt,width:ht,visible:ge,setOverlay:vt,closeRail:_t}=Dl(),Et=$d()==="board";b.useEffect(()=>{const Y=xe.current;if(!Y)return;Ne(Y.clientWidth);const ye=new ResizeObserver(De=>{for(const wt of De)Ne(wt.contentRect.width)});return ye.observe(Y),()=>ye.disconnect()},[]),b.useEffect(()=>{if(Et||re===0){ze(!1);return}const Y=re-(w?Re:0)-(gt?ht:0);ze(ye=>ye?Y<_E+XU:Y<_E)},[re,w,Re,gt,ht,Et]),b.useLayoutEffect(()=>{vt(ke),Ge(!1)},[ke,vt]),b.useEffect(()=>{if(!ke)return;const Y=ye=>{ye.key==="Escape"&&(Fe||ge)&&(Ge(!1),_t())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[ke,Fe,ge,_t]);const Dt=ke?Fe:w,[ot,Le]=b.useState(null),[ve,te]=b.useState(null),[je,Q]=b.useState(new Set),de=b.useRef(0),fe=b.useRef(null),Je=1500,Ie=b.useCallback((Y,ye)=>{fe.current&&(clearTimeout(fe.current),fe.current=null),de.current=Date.now(),Le(Y),te(ye)},[]),it=b.useCallback(()=>{if(fe.current)return;const Y=Date.now()-de.current,ye=Je-Y;ye<=0?(Le(null),te(null)):fe.current=setTimeout(()=>{fe.current=null,Le(null),te(null)},ye)},[]),[,dt]=b.useState(0),[at,Ye]=b.useState(null),qe=b.useRef(null),lt=b.useRef(null),bt=b.useRef(null),Ce=b.useRef([]),Se=b.useRef(-1),We=b.useRef(null),tt=b.useRef(!1),He=b.useRef(""),[xt,j]=b.useState(""),[U,ie]=b.useState(!1),[D,ce]=b.useState(!1);function me(){const Y=document.querySelector(".editor-container");return(Y==null?void 0:Y.scrollTop)||0}function se(){if(Se.current<0)return;const Y=Ce.current[Se.current];Y&&(Y.scrollTop=me())}const he=QU(B),be=he==="article",Be=he==="blog",Ee=he==="newsletter",Ht=he==="tweet"||he==="reply"||he==="quote";b.useEffect(()=>(be?document.documentElement.setAttribute("data-view","article"):Be?document.documentElement.setAttribute("data-view","blog"):Ee?document.documentElement.setAttribute("data-view","newsletter"):Ht?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[Ht,be,Be,Ee]),b.useEffect(()=>{const Y=()=>dt(ye=>ye+1);return window.addEventListener("ow-sidebar-mode-change",Y),()=>window.removeEventListener("ow-sidebar-mode-change",Y)},[]),b.useEffect(()=>{fetch("/api/document",{cache:"no-store"}).then(Y=>Y.json()).then(Y=>{Y.document&&(v(Y.document),lt.current=Y.document),Y.title&&f(Y.title),Y.metadata&&W(Y.metadata)}).catch(()=>{v(void 0)}),fetch("/api/pending-docs").then(Y=>Y.json()).then(Y=>P(Y)).catch(()=>{}),fetch("/api/sync/status").then(Y=>Y.json()).then(Y=>q(Y)).catch(()=>{})},[]);const Tt=b.useCallback(Y=>{t.current=Y,r(Y),i(null),e.current=[Y],l([Y])},[]),cn=b.useRef([]),xn=b.useCallback(Y=>{if(e.current=Y,l(Y),cn.current.length>0&&Y.length>0){const ye=cn.current;cn.current=[];for(const De of Y)De.isDestroyed||Rp(De,ye)}},[]),Nn=b.useCallback(Y=>{var Wn,ps;const ye=performance.now(),De=window.__lastSwitch;De&&De.filename===Y.filename?(De.tReceive=ye,console.log(`[Switch] RECEIVE filename=${Y.filename} sendToReceive=${(ye-De.tSend).toFixed(1)}ms (server round-trip)`)):console.log(`[Switch] RECEIVE filename=${Y.filename} (no matching CLICK — agent or initial-load switch)`),qe.current&&(clearTimeout(qe.current),qe.current=null);const wt=He.current==="",jt=Y.filename===He.current;He.current=Y.filename,lt.current=Y.document,bt.current=JSON.stringify(Y.document),j(Y.filename),v(Y.document),f(Y.title),W(Y.metadata||{}),m(((Wn=Y.pendingMetadata)==null?void 0:Wn.title)??null),!jt&&!wt&&((ps=Y.metadata)!=null&&ps.tweetContext)&&k(Kt=>Kt+1),De&&De.filename===Y.filename&&requestAnimationFrame(()=>{const Kt=performance.now();De.tCommit=Kt,console.log(`[Switch] COMMIT filename=${Y.filename} receiveToCommit=${(Kt-ye).toFixed(1)}ms totalClickToPaint=${(Kt-De.tClick).toFixed(1)}ms`)});const Zn=We.current??"push";if(We.current=null,Ce.current.length===0?(Ce.current=[{filename:Y.filename,scrollTop:0}],Se.current=0):Zn==="back"?Se.current=Math.max(0,Se.current-1):Zn==="forward"?Se.current=Math.min(Ce.current.length-1,Se.current+1):jt||(Ce.current=Ce.current.slice(0,Se.current+1),Ce.current.push({filename:Y.filename,scrollTop:0}),Se.current=Ce.current.length-1),!tt.current){const Kt=`#${encodeURIComponent(Y.filename)}`,Rn={ow:{filename:Y.filename,navIndex:Se.current}};Ce.current.length===1||jt?window.history.replaceState(Rn,"",Kt):window.history.pushState(Rn,"",Kt)}if(tt.current=!1,Zn==="back"||Zn==="forward"){const Kt=Ce.current[Se.current];Kt&&setTimeout(()=>{const Rn=document.querySelector(".editor-container");Rn&&(Rn.scrollTop=Kt.scrollTop)},50)}ie(Se.current>0),ce(Se.current<Ce.current.length-1)},[]),Ve=b.useCallback(Y=>{qe.current&&(clearTimeout(qe.current),qe.current=null),lt.current=Y.document,bt.current=JSON.stringify(Y.document),v(Y.document),f(Y.title),W(Y.metadata||{}),Ye(ye=>ye?{filename:Y.filename,orphanCount:ye.orphanCount+Y.orphanCount,staleBaselineCount:ye.staleBaselineCount+Y.staleBaselineCount,reloadCount:ye.reloadCount+1}:{filename:Y.filename,orphanCount:Y.orphanCount,staleBaselineCount:Y.staleBaselineCount,reloadCount:1})},[]),Vt=b.useCallback(()=>{T(Y=>Y+1),_(Y=>Y+1)},[]),Un=b.useCallback(()=>{I(Y=>Y+1)},[]),fn=b.useCallback(Y=>{P(Y)},[]),{connected:mr,sendMessage:Xt,docVersionRef:Hn}=EF({onNodeChanges:Y=>{const ye=e.current;if(ye.length<=1){const De=t.current;if(!De)return;Rp(De,Y)}else{if(ye.some(wt=>wt.isDestroyed)){cn.current.push(...Y);return}for(const wt of ye)Rp(wt,Y)}},onDocumentSwitched:Nn,onDocumentReloaded:Ve,onDocumentsChanged:Vt,onWorkspacesChanged:Un,onPendingDocsChanged:fn,onMetadataChanged:Y=>W(Y),onWritingStarted:(Y,ye)=>Ie(Y,ye),onWritingFinished:()=>it(),onIdRewrites:Y=>{const ye=e.current,De=ye.length>0?ye:t.current?[t.current]:[];for(const jt of De)jt.isDestroyed||u$(jt,Y);const wt=lt.current;if(wt&&Array.isArray(Y)&&Y.length>0){const jt=new Map(Y.map(Wn=>[Wn.oldId,Wn.newId])),Zn=Wn=>{var ps;if(Array.isArray(Wn))for(const Kt of Wn){const Rn=(ps=Kt==null?void 0:Kt.attrs)==null?void 0:ps.id;Rn&&jt.has(Rn)&&(Kt.attrs={...Kt.attrs,id:jt.get(Rn)}),Kt!=null&&Kt.content&&Zn(Kt.content)}};Zn(wt.content||[])}},onPendingFilenamesChanged:Y=>Q(Y),onSyncStatus:Y=>q(Y),onTitleChanged:Y=>f(Y),getEditorState:()=>{var ye;const Y=lt.current||((ye=t.current)==null?void 0:ye.getJSON());return Y?{document:Y}:null}}),lr=b.useCallback(()=>{var De;qe.current&&(clearTimeout(qe.current),qe.current=null);const Y=lt.current||((De=t.current)==null?void 0:De.getJSON());if(!Y)return;const ye=JSON.stringify(Y);ye!==bt.current&&(Xt({type:"doc-update",document:Y,filename:He.current,version:Hn.current}),bt.current=ye)},[Xt,Hn]),cr=b.useCallback(async()=>{var ye;const Y=lt.current||((ye=t.current)==null?void 0:ye.getJSON());Y&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:Y,filename:He.current})})},[]);b.useEffect(()=>{const Y=()=>{var jt;qe.current&&(clearTimeout(qe.current),qe.current=null);const De=lt.current||((jt=t.current)==null?void 0:jt.getJSON());if(!De)return;const wt=JSON.stringify({type:"flush",document:De});navigator.sendBeacon("/api/flush",new Blob([wt],{type:"application/json"}))},ye=()=>{document.visibilityState==="hidden"&&Y()};return window.addEventListener("beforeunload",Y),document.addEventListener("visibilitychange",ye),()=>{window.removeEventListener("beforeunload",Y),document.removeEventListener("visibilitychange",ye)}},[]);const _s=b.useCallback(()=>{lr(),Xt({type:"create-document"})},[lr,Xt]),Ir=b.useCallback(Y=>{if(Y===He.current)return;const ye=performance.now();window.__lastSwitch={filename:Y,tClick:ye,tSend:0,tReceive:0,tCommit:0},console.log(`[Switch] CLICK filename=${Y} t=${ye.toFixed(0)}`),se(),We.current="push",lr(),Xt({type:"switch-document",filename:Y});const De=performance.now();window.__lastSwitch.tSend=De,console.log(`[Switch] SEND filename=${Y} clickToSend=${(De-ye).toFixed(1)}ms`)},[lr,Xt]),Bt=b.useRef(null),Lr=b.useCallback(async Y=>{let ye=null;if(Y.docId)try{const De=await fetch("/api/documents").then(wt=>wt.json());if(Array.isArray(De)){const wt=De.find(jt=>jt.docId===Y.docId);wt&&(ye=wt.filename)}}catch{}if(!ye&&Y.filename&&(ye=Y.filename),!ye){console.warn("[link] could not resolve doc: target",Y);return}Y.nodeId||Y.quote?Bt.current={nodeId:Y.nodeId||void 0,quote:Y.quote||void 0}:Bt.current={toTop:!0},Ir(ye),setTimeout(()=>{window.dispatchEvent(new CustomEvent("ow-reveal-active-doc",{detail:{filename:ye}}))},0)},[Ir]);b.useEffect(()=>{const Y=ye=>{const De=ye.detail;De&&Lr(De)};return window.addEventListener("ow-navigate-to-link",Y),()=>window.removeEventListener("ow-navigate-to-link",Y)},[Lr]);const Ys=b.useRef(!1);b.useEffect(()=>{if(Ys.current)return;Ys.current=!0;const Y=window.location.pathname.match(/^\/d\/([a-f0-9]{8})\/?$/);if(!Y)return;const ye=Y[1],De=window.location.hash.match(/^#node=([a-f0-9]{8})$/),wt=De?De[1]:null;Lr({docId:ye,filename:null,nodeId:wt,quote:null})},[Lr]),b.useEffect(()=>{if(!n||!Bt.current)return;const Y=Bt.current;Bt.current=null,setTimeout(()=>{if(Y.toTop){const wt=document.querySelector(".editor-container");wt&&(wt.scrollTop=0);return}let ye=null;if(Y.nodeId&&n.state.doc.descendants((wt,jt)=>{var Zn;return ye!==null?!1:((Zn=wt.attrs)==null?void 0:Zn.id)===Y.nodeId?(ye=jt+1,!1):!0}),ye===null&&Y.quote){const wt=Y.quote;n.state.doc.descendants((jt,Zn)=>{if(ye!==null)return!1;if(jt.isTextblock){const Wn=jt.textContent.indexOf(wt);if(Wn>=0)return ye=Zn+1+Wn,!1}return!0})}if(ye===null)return;n.chain().focus().setTextSelection({from:ye,to:ye}).scrollIntoView().run();const De=n.view.nodeDOM(ye-1);De!=null&&De.classList&&(De.classList.add("scroll-target-flash"),setTimeout(()=>De.classList.remove("scroll-target-flash"),1200))},100)},[n,xt]);const Qr=b.useCallback(()=>{Se.current<=0||window.history.back()},[]),hs=b.useCallback(()=>{Se.current>=Ce.current.length-1||window.history.forward()},[]);b.useEffect(()=>{const Y=ye=>{const De=ye.state&&ye.state.ow;De!=null&&De.filename&&De.filename!==He.current&&(se(),We.current=De.navIndex<Se.current?"back":"forward",tt.current=!0,lr(),Xt({type:"switch-document",filename:De.filename}))};return window.addEventListener("popstate",Y),()=>window.removeEventListener("popstate",Y)},[lr,Xt]);const Ae=b.useCallback(()=>{const Y=He.current,ye=t.current;if(!Y||!ye)return;const De=()=>{const wt=e.current;if(wt.length>1)for(const jt of wt)jt!=null&&jt.view&&pk(jt.view);else ye!=null&&ye.view&&pk(ye.view)};fetch(`/api/comments/${encodeURIComponent(Y)}`).then(wt=>wt.json()).then(wt=>{dk(wt.comments||[]),De()}).catch(()=>{dk([]),De()})},[]);b.useEffect(()=>{Ae()},[xt,n,Ae]),b.useEffect(()=>{const Y=ye=>{const De=ye.detail;(De==null?void 0:De.filename)===He.current&&Ae()};return window.addEventListener("ow-comments-changed",Y),()=>window.removeEventListener("ow-comments-changed",Y)},[Ae]),b.useEffect(()=>{function Y(ye){var jt;const De=ye.detail;if(!De)return;const wt=B==null?void 0:B.docId;wt&&De.docId&&De.docId!==wt||m(((jt=De.pendingMetadata)==null?void 0:jt.title)??null)}return window.addEventListener("ow-pending-metadata-changed",Y),()=>window.removeEventListener("ow-pending-metadata-changed",Y)},[B==null?void 0:B.docId]),b.useEffect(()=>{const Y=B==null?void 0:B.docId;if(!Y){mk([]);return}let ye=!1;return fetch(`/api/backlinks/${Y}`).then(De=>De.ok?De.json():[]).then(De=>{if(ye)return;mk(Array.isArray(De)?De:[]);const wt=e.current.length>0?e.current:n?[n]:[];for(const jt of wt)jt!=null&&jt.view&&I5(jt.view)}).catch(()=>{}),()=>{ye=!0}},[B,n]),b.useEffect(()=>{const Y=B==null?void 0:B.docId;if(!Y){oe(null),vk({});return}let ye=!1;return fetch(`/api/attribution/${Y}`).then(De=>De.ok?De.json():null).then(De=>{if(ye||!De)return;oe({percent:De.percent,nodeOrigins:De.nodeOrigins||{},tracked:!!De.tracked}),vk(De.nodeOrigins||{});const wt=e.current.length>0?e.current:n?[n]:[];for(const jt of wt)jt!=null&&jt.view&&bk(jt.view)}).catch(()=>{}),()=>{ye=!0}},[B,n]),b.useEffect(()=>{P5(K);const Y=e.current.length>0?e.current:n?[n]:[];for(const ye of Y)ye!=null&&ye.view&&bk(ye.view)},[K,n]),b.useEffect(()=>{const Y=ye=>{ye.altKey&&ye.key==="ArrowLeft"&&(ye.preventDefault(),Qr()),ye.altKey&&ye.key==="ArrowRight"&&(ye.preventDefault(),hs())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[Qr,hs]);const nt=b.useCallback(Y=>{lt.current=Y,qe.current&&clearTimeout(qe.current),qe.current=setTimeout(()=>{const ye=lt.current||Y,De=JSON.stringify(ye);De!==bt.current&&(Xt({type:"doc-update",document:ye,filename:He.current,version:Hn.current}),bt.current=De)},1e3)},[Xt,Hn]),Ct=b.useCallback(Y=>{f(Y),Xt({type:"title-update",title:Y})},[Xt]),Mt=b.useCallback(()=>{A(Y=>(localStorage.setItem("ow-toolbar",Y?"hidden":"visible"),!Y))},[]),an=b.useCallback(()=>{ee(Y=>{if(!Y)return pe.current={sidebarOpen:w,showToolbar:J},S(!1),Ge(!1),A(!1),!0;const ye=pe.current;return ye&&(S(ye.sidebarOpen),A(ye.showToolbar),pe.current=null),!1})},[w,J]),nn=b.useCallback(()=>{if(z.state==="unconfigured"){G(!0);return}lr(),Xt({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[z.state,lr,Xt]);return c.jsxs("div",{className:`app${ke?" app--overlay":""}`,ref:xe,children:[!Et&&c.jsx($k,{open:Dt,floating:ke,width:Re,onWidthChange:Ze,onSwitchDocument:Ir,onCreateDocument:_s,refreshKey:N,docTagsRefreshKey:M,workspacesRefreshKey:R,pendingDocs:$,writingTitle:ot,writingTarget:ve,pendingWriteFilenames:je,activeFilename:xt,onClose:()=>ke?Ge(!1):S(!1)}),c.jsxs("div",{className:"app-main",children:[c.jsx(i$,{title:d,onTitleChange:Ct,onToggleSidebar:!Et&&!Dt?()=>ke?Ge(!0):S(!0):void 0,canGoBack:U,canGoForward:D,onGoBack:Qr,onGoForward:hs,editor:n,onToggleToolbar:Mt,toolbarOpen:J,focusMode:L,onToggleFocusMode:an}),J&&n&&c.jsx(K5,{editor:s||n}),Et&&c.jsx($k,{open:!0,width:Re,onWidthChange:Ze,onSwitchDocument:Ir,onCreateDocument:_s,refreshKey:N,docTagsRefreshKey:M,workspacesRefreshKey:R,pendingDocs:$,writingTitle:ot,writingTarget:ve,pendingWriteFilenames:je}),c.jsx(o$,{}),!mr&&c.jsxs("div",{className:"connection-banner",children:[c.jsx("div",{className:"connection-banner-spinner"}),c.jsx("span",{children:"Reconnecting to server..."})]}),(B==null?void 0:B.autoAccept)===!0&&c.jsxs("div",{className:"editor-auto-accept-banner",title:"Agent edits skip the review step. Right-click the doc in the sidebar to turn off.",children:[c.jsx("span",{className:"editor-auto-accept-dot"}),"Auto-accept on — agent edits skip review"]}),at&&c.jsxs("div",{className:"editor-reload-banner",role:"status","aria-live":"polite",children:[c.jsx("span",{className:"editor-reload-dot","aria-hidden":"true"}),c.jsx("span",{children:at.reloadCount>1?`Document reloaded from disk ${at.reloadCount}× since you last looked`:"Document reloaded from disk (external write detected)"}),(at.orphanCount>0||at.staleBaselineCount>0)&&c.jsxs("span",{className:"editor-reload-detail",children:[at.orphanCount>0&&c.jsxs("span",{className:"editor-reload-tag editor-reload-tag--orphan",children:[at.orphanCount," orphan",at.orphanCount===1?"":"s"]}),at.staleBaselineCount>0&&c.jsxs("span",{className:"editor-reload-tag editor-reload-tag--stale",children:[at.staleBaselineCount," stale-baseline"]})]}),c.jsx("button",{type:"button",className:"editor-reload-dismiss",onClick:()=>Ye(null),"aria-label":"Dismiss reload notification",children:"×"})]}),c.jsx("div",{className:"editor-container",children:be?c.jsx(HU,{title:d,onTitleChange:Ct,coverImage:(Nr=B==null?void 0:B.articleContext)==null?void 0:Nr.coverImage,coverImages:(Ts=B==null?void 0:B.articleContext)==null?void 0:Ts.coverImages,lastPost:(An=B==null?void 0:B.articleContext)==null?void 0:An.lastPost,pendingTitle:h,docId:(B==null?void 0:B.docId)||void 0,autoplug:B==null?void 0:B.autoplug,children:c.jsx(xu,{initialContent:g,extensions:k5,onUpdate:nt,onReady:Tt,onLinkClick:Lr})}):Be?c.jsx(GU,{title:d,onTitleChange:Ct,blogContext:B==null?void 0:B.blogContext,filename:xt,pendingTitle:h,docId:(B==null?void 0:B.docId)||void 0,children:c.jsx(xu,{initialContent:g,onUpdate:nt,onReady:Tt,onLinkClick:Lr})}):Ee?c.jsx(YU,{newsletterContext:B==null?void 0:B.newsletterContext,filename:xt,title:d,onTitleChange:Ct,onBeforeSend:cr,children:c.jsx(xu,{initialContent:g,onUpdate:nt,onReady:Tt,onLinkClick:Lr})}):Ht&&(B!=null&&B.tweetContext)?c.jsx(PU,{tweetContext:B.tweetContext,initialContent:g,onUpdate:nt,onEditorReady:Tt,onEditorsChange:xn,onActiveEditorChange:i,filename:xt,title:d,autoplug:B==null?void 0:B.autoplug},x):c.jsx(xu,{initialContent:g,onUpdate:nt,onReady:Tt,onLinkClick:Lr})})]}),ke&&(Fe||ge)&&c.jsx("div",{className:"ow-scrim",onClick:()=>{Ge(!1),_t()},"aria-hidden":"true"}),c.jsx(kF,{editors:o,pendingDocs:$,currentFilename:xt,docId:(B==null?void 0:B.docId)||null,pendingTitle:h,onSwitchDocument:Ir,sendMessage:Xt,getDocument:()=>lt.current,docVersionRef:Hn,syncStatus:z,onSync:nn,onToggleToolbar:Mt,toolbarOpen:J,focusMode:L,onToggleFocusMode:an,heatmapOn:K,onToggleHeatmap:()=>ne(Y=>!Y),heatmapAvailable:!!(B!=null&&B.docId),heatmapTitle:V!=null&&V.tracked?`Voice heatmap — ${V.percent.human}% human · ${V.percent.agent}% agent${V.percent.unknown?` · ${V.percent.unknown}% unknown`:""}`:"Voice heatmap — attribution starts on the next edit"}),c.jsx(x$,{editorRef:t,allEditors:o,documentId:xt}),c.jsx(E$,{documentId:xt}),F&&c.jsx(SF,{onClose:()=>G(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(Y=>Y.json()).then(q).catch(()=>{})}})]})}OM();TM.createRoot(document.getElementById("root")).render(c.jsx(Mi.StrictMode,{children:c.jsx(PM,{children:c.jsx(ZU,{})})}));