openwriter 0.22.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/index-AWIKUHJ_.css +1 -0
- package/dist/client/assets/index-DmHLFNTs.js +212 -0
- package/dist/client/index.html +2 -2
- package/dist/server/activity-log.js +2 -0
- package/dist/server/documents.js +97 -3
- package/dist/server/index.js +159 -4
- package/dist/server/mcp.js +183 -55
- package/dist/server/peek-outline.js +304 -0
- package/dist/server/state.js +128 -0
- package/dist/server/title-from-body.js +125 -0
- package/dist/server/workspaces.js +23 -0
- package/dist/server/ws.js +176 -3
- package/package.json +1 -1
- package/skill/SKILL.md +611 -712
- package/skill/agents/openwriter-enrichment-minion.md +7 -0
- package/skill/docs/setup.md +62 -0
- package/dist/client/assets/index-DFbNF7q0.css +0 -1
- package/dist/client/assets/index-OAhOx_JE.js +0 -212
|
@@ -1,212 +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 jb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function El(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ih={exports:{}},$a={},Lh={exports:{}},Ct={};/**
|
|
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 Ob;function DM(){if(Ob)return Ct;Ob=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(M){return M===null||typeof M!="object"?null:(M=m&&M[m]||M["@@iterator"],typeof M=="function"?M:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,x={};function w(M,I,Z){this.props=M,this.context=I,this.refs=x,this.updater=Z||y}w.prototype.isReactComponent={},w.prototype.setState=function(M,I){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,I,"setState")},w.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function E(){}E.prototype=w.prototype;function C(M,I,Z){this.props=M,this.context=I,this.refs=x,this.updater=Z||y}var A=C.prototype=new E;A.constructor=C,b(A,w.prototype),A.isPureReactComponent=!0;var T=Array.isArray,_=Object.prototype.hasOwnProperty,O={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function B(M,I,Z){var le,ge={},se=null,xe=null;if(I!=null)for(le in I.ref!==void 0&&(xe=I.ref),I.key!==void 0&&(se=""+I.key),I)_.call(I,le)&&!R.hasOwnProperty(le)&&(ge[le]=I[le]);var fe=arguments.length-2;if(fe===1)ge.children=Z;else if(1<fe){for(var De=Array(fe),We=0;We<fe;We++)De[We]=arguments[We+2];ge.children=De}if(M&&M.defaultProps)for(le in fe=M.defaultProps,fe)ge[le]===void 0&&(ge[le]=fe[le]);return{$$typeof:t,type:M,key:se,ref:xe,props:ge,_owner:O.current}}function D(M,I){return{$$typeof:t,type:M.type,key:I,ref:M.ref,props:M.props,_owner:M._owner}}function U(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function Q(M){var I={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(Z){return I[Z]})}var P=/\/+/g;function W(M,I){return typeof M=="object"&&M!==null&&M.key!=null?Q(""+M.key):I.toString(36)}function $(M,I,Z,le,ge){var se=typeof M;(se==="undefined"||se==="boolean")&&(M=null);var xe=!1;if(M===null)xe=!0;else switch(se){case"string":case"number":xe=!0;break;case"object":switch(M.$$typeof){case t:case e:xe=!0}}if(xe)return xe=M,ge=ge(xe),M=le===""?"."+W(xe,0):le,T(ge)?(Z="",M!=null&&(Z=M.replace(P,"$&/")+"/"),$(ge,I,Z,"",function(We){return We})):ge!=null&&(U(ge)&&(ge=D(ge,Z+(!ge.key||xe&&xe.key===ge.key?"":(""+ge.key).replace(P,"$&/")+"/")+M)),I.push(ge)),1;if(xe=0,le=le===""?".":le+":",T(M))for(var fe=0;fe<M.length;fe++){se=M[fe];var De=le+W(se,fe);xe+=$(se,I,Z,De,ge)}else if(De=g(M),typeof De=="function")for(M=De.call(M),fe=0;!(se=M.next()).done;)se=se.value,De=le+W(se,fe++),xe+=$(se,I,Z,De,ge);else if(se==="object")throw I=String(M),Error("Objects are not valid as a React child (found: "+(I==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":I)+"). If you meant to render a collection of children, use an array instead.");return xe}function H(M,I,Z){if(M==null)return M;var le=[],ge=0;return $(M,le,"","",function(se){return I.call(Z,se,ge++)}),le}function J(M){if(M._status===-1){var I=M._result;I=I(),I.then(function(Z){(M._status===0||M._status===-1)&&(M._status=1,M._result=Z)},function(Z){(M._status===0||M._status===-1)&&(M._status=2,M._result=Z)}),M._status===-1&&(M._status=0,M._result=I)}if(M._status===1)return M._result.default;throw M._result}var re={current:null},V={transition:null},ie={ReactCurrentDispatcher:re,ReactCurrentBatchConfig:V,ReactCurrentOwner:O};function z(){throw Error("act(...) is not supported in production builds of React.")}return Ct.Children={map:H,forEach:function(M,I,Z){H(M,function(){I.apply(this,arguments)},Z)},count:function(M){var I=0;return H(M,function(){I++}),I},toArray:function(M){return H(M,function(I){return I})||[]},only:function(M){if(!U(M))throw Error("React.Children.only expected to receive a single React element child.");return M}},Ct.Component=w,Ct.Fragment=n,Ct.Profiler=s,Ct.PureComponent=C,Ct.StrictMode=r,Ct.Suspense=d,Ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ie,Ct.act=z,Ct.cloneElement=function(M,I,Z){if(M==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+M+".");var le=b({},M.props),ge=M.key,se=M.ref,xe=M._owner;if(I!=null){if(I.ref!==void 0&&(se=I.ref,xe=O.current),I.key!==void 0&&(ge=""+I.key),M.type&&M.type.defaultProps)var fe=M.type.defaultProps;for(De in I)_.call(I,De)&&!R.hasOwnProperty(De)&&(le[De]=I[De]===void 0&&fe!==void 0?fe[De]:I[De])}var De=arguments.length-2;if(De===1)le.children=Z;else if(1<De){fe=Array(De);for(var We=0;We<De;We++)fe[We]=arguments[We+2];le.children=fe}return{$$typeof:t,type:M.type,key:ge,ref:se,props:le,_owner:xe}},Ct.createContext=function(M){return M={$$typeof:o,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},M.Provider={$$typeof:i,_context:M},M.Consumer=M},Ct.createElement=B,Ct.createFactory=function(M){var I=B.bind(null,M);return I.type=M,I},Ct.createRef=function(){return{current:null}},Ct.forwardRef=function(M){return{$$typeof:l,render:M}},Ct.isValidElement=U,Ct.lazy=function(M){return{$$typeof:h,_payload:{_status:-1,_result:M},_init:J}},Ct.memo=function(M,I){return{$$typeof:f,type:M,compare:I===void 0?null:I}},Ct.startTransition=function(M){var I=V.transition;V.transition={};try{M()}finally{V.transition=I}},Ct.unstable_act=z,Ct.useCallback=function(M,I){return re.current.useCallback(M,I)},Ct.useContext=function(M){return re.current.useContext(M)},Ct.useDebugValue=function(){},Ct.useDeferredValue=function(M){return re.current.useDeferredValue(M)},Ct.useEffect=function(M,I){return re.current.useEffect(M,I)},Ct.useId=function(){return re.current.useId()},Ct.useImperativeHandle=function(M,I,Z){return re.current.useImperativeHandle(M,I,Z)},Ct.useInsertionEffect=function(M,I){return re.current.useInsertionEffect(M,I)},Ct.useLayoutEffect=function(M,I){return re.current.useLayoutEffect(M,I)},Ct.useMemo=function(M,I){return re.current.useMemo(M,I)},Ct.useReducer=function(M,I,Z){return re.current.useReducer(M,I,Z)},Ct.useRef=function(M){return re.current.useRef(M)},Ct.useState=function(M){return re.current.useState(M)},Ct.useSyncExternalStore=function(M,I,Z){return re.current.useSyncExternalStore(M,I,Z)},Ct.useTransition=function(){return re.current.useTransition()},Ct.version="18.3.1",Ct}var Rb;function Nl(){return Rb||(Rb=1,Lh.exports=DM()),Lh.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 Ib;function PM(){if(Ib)return $a;Ib=1;var t=Nl(),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,y=null;f!==void 0&&(g=""+f),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(y=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:y,props:m,_owner:s.current}}return $a.Fragment=n,$a.jsx=o,$a.jsxs=o,$a}var Lb;function BM(){return Lb||(Lb=1,Ih.exports=PM()),Ih.exports}var u=BM(),k=Nl();const pi=El(k);var $c={},Dh={exports:{}},ur={},Ph={exports:{}},Bh={};/**
|
|
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 Db;function zM(){return Db||(Db=1,(function(t){function e(V,ie){var z=V.length;V.push(ie);e:for(;0<z;){var M=z-1>>>1,I=V[M];if(0<s(I,ie))V[M]=ie,V[z]=I,z=M;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var ie=V[0],z=V.pop();if(z!==ie){V[0]=z;e:for(var M=0,I=V.length,Z=I>>>1;M<Z;){var le=2*(M+1)-1,ge=V[le],se=le+1,xe=V[se];if(0>s(ge,z))se<I&&0>s(xe,ge)?(V[M]=xe,V[se]=z,M=se):(V[M]=ge,V[le]=z,M=le);else if(se<I&&0>s(xe,z))V[M]=xe,V[se]=z,M=se;else break e}}return ie}function s(V,ie){var z=V.sortIndex-ie.sortIndex;return z!==0?z:V.id-ie.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,y=!1,b=!1,x=!1,w=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function A(V){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=V)r(f),ie.sortIndex=ie.expirationTime,e(d,ie);else break;ie=n(f)}}function T(V){if(x=!1,A(V),!b)if(n(d)!==null)b=!0,J(_);else{var ie=n(f);ie!==null&&re(T,ie.startTime-V)}}function _(V,ie){b=!1,x&&(x=!1,E(B),B=-1),y=!0;var z=g;try{for(A(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||V&&!Q());){var M=m.callback;if(typeof M=="function"){m.callback=null,g=m.priorityLevel;var I=M(m.expirationTime<=ie);ie=t.unstable_now(),typeof I=="function"?m.callback=I:m===n(d)&&r(d),A(ie)}else r(d);m=n(d)}if(m!==null)var Z=!0;else{var le=n(f);le!==null&&re(T,le.startTime-ie),Z=!1}return Z}finally{m=null,g=z,y=!1}}var O=!1,R=null,B=-1,D=5,U=-1;function Q(){return!(t.unstable_now()-U<D)}function P(){if(R!==null){var V=t.unstable_now();U=V;var ie=!0;try{ie=R(!0,V)}finally{ie?W():(O=!1,R=null)}}else O=!1}var W;if(typeof C=="function")W=function(){C(P)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,H=$.port2;$.port1.onmessage=P,W=function(){H.postMessage(null)}}else W=function(){w(P,0)};function J(V){R=V,O||(O=!0,W())}function re(V,ie){B=w(function(){V(t.unstable_now())},ie)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(V){V.callback=null},t.unstable_continueExecution=function(){b||y||(b=!0,J(_))},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"):D=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 ie=3;break;default:ie=g}var z=g;g=ie;try{return V()}finally{g=z}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(V,ie){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var z=g;g=V;try{return ie()}finally{g=z}},t.unstable_scheduleCallback=function(V,ie,z){var M=t.unstable_now();switch(typeof z=="object"&&z!==null?(z=z.delay,z=typeof z=="number"&&0<z?M+z:M):z=M,V){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=z+I,V={id:h++,callback:ie,priorityLevel:V,startTime:z,expirationTime:I,sortIndex:-1},z>M?(V.sortIndex=z,e(f,V),n(d)===null&&V===n(f)&&(x?(E(B),B=-1):x=!0,re(T,z-M))):(V.sortIndex=I,e(d,V),b||y||(b=!0,J(_))),V},t.unstable_shouldYield=Q,t.unstable_wrapCallback=function(V){var ie=g;return function(){var z=g;g=ie;try{return V.apply(this,arguments)}finally{g=z}}}})(Bh)),Bh}var Pb;function $M(){return Pb||(Pb=1,Ph.exports=zM()),Ph.exports}/**
|
|
26
|
-
* @license React
|
|
27
|
-
* react-dom.production.min.js
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
-
*
|
|
31
|
-
* This source code is licensed under the MIT license found in the
|
|
32
|
-
* LICENSE file in the root directory of this source tree.
|
|
33
|
-
*/var Bb;function FM(){if(Bb)return ur;Bb=1;var t=Nl(),e=$M();function n(a){for(var c="https://reactjs.org/docs/error-decoder.html?invariant="+a,p=1;p<arguments.length;p++)c+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(a,c){o(a,c),o(a+"Capture",c)}function o(a,c){for(s[a]=c,a=0;a<c.length;a++)r.add(c[a])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),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 y(a,c,p,v){if(p!==null&&p.type===0)return!1;switch(typeof c){case"function":case"symbol":return!0;case"boolean":return v?!1:p!==null?!p.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function b(a,c,p,v){if(c===null||typeof c>"u"||y(a,c,p,v))return!0;if(v)return!1;if(p!==null)switch(p.type){case 3:return!c;case 4:return c===!1;case 5:return isNaN(c);case 6:return isNaN(c)||1>c}return!1}function x(a,c,p,v,S,N,j){this.acceptsBooleans=c===2||c===3||c===4,this.attributeName=v,this.attributeNamespace=S,this.mustUseProperty=p,this.propertyName=a,this.type=c,this.sanitizeURL=N,this.removeEmptyString=j}var w={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){w[a]=new x(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var c=a[0];w[c]=new x(c,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){w[a]=new x(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){w[a]=new x(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 x(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){w[a]=new x(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){w[a]=new x(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){w[a]=new x(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){w[a]=new x(a,5,!1,a.toLowerCase(),null,!1,!1)});var E=/[\-:]([a-z])/g;function C(a){return a[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(a){var c=a.replace(E,C);w[c]=new x(c,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var c=a.replace(E,C);w[c]=new x(c,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var c=a.replace(E,C);w[c]=new x(c,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){w[a]=new x(a,1,!1,a.toLowerCase(),null,!1,!1)}),w.xlinkHref=new x("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){w[a]=new x(a,1,!1,a.toLowerCase(),null,!0,!0)});function A(a,c,p,v){var S=w.hasOwnProperty(c)?w[c]:null;(S!==null?S.type!==0:v||!(2<c.length)||c[0]!=="o"&&c[0]!=="O"||c[1]!=="n"&&c[1]!=="N")&&(b(c,p,S,v)&&(p=null),v||S===null?g(c)&&(p===null?a.removeAttribute(c):a.setAttribute(c,""+p)):S.mustUseProperty?a[S.propertyName]=p===null?S.type===3?!1:"":p:(c=S.attributeName,v=S.attributeNamespace,p===null?a.removeAttribute(c):(S=S.type,p=S===3||S===4&&p===!0?"":""+p,v?a.setAttributeNS(v,c,p):a.setAttribute(c,p))))}var T=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),O=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),Q=Symbol.for("react.context"),P=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),J=Symbol.for("react.lazy"),re=Symbol.for("react.offscreen"),V=Symbol.iterator;function ie(a){return a===null||typeof a!="object"?null:(a=V&&a[V]||a["@@iterator"],typeof a=="function"?a:null)}var z=Object.assign,M;function I(a){if(M===void 0)try{throw Error()}catch(p){var c=p.stack.trim().match(/\n( *(at )?)/);M=c&&c[1]||""}return`
|
|
34
|
-
`+M+a}var Z=!1;function le(a,c){if(!a||Z)return"";Z=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(c)if(c=function(){throw Error()},Object.defineProperty(c.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(c,[])}catch(he){var v=he}Reflect.construct(a,[],c)}else{try{c.call()}catch(he){v=he}a.call(c.prototype)}else{try{throw Error()}catch(he){v=he}a()}}catch(he){if(he&&v&&typeof he.stack=="string"){for(var S=he.stack.split(`
|
|
35
|
-
`),N=v.stack.split(`
|
|
36
|
-
`),j=S.length-1,F=N.length-1;1<=j&&0<=F&&S[j]!==N[F];)F--;for(;1<=j&&0<=F;j--,F--)if(S[j]!==N[F]){if(j!==1||F!==1)do if(j--,F--,0>F||S[j]!==N[F]){var X=`
|
|
37
|
-
`+S[j].replace(" at new "," at ");return a.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",a.displayName)),X}while(1<=j&&0<=F);break}}}finally{Z=!1,Error.prepareStackTrace=p}return(a=a?a.displayName||a.name:"")?I(a):""}function ge(a){switch(a.tag){case 5:return I(a.type);case 16:return I("Lazy");case 13:return I("Suspense");case 19:return I("SuspenseList");case 0:case 2:case 15:return a=le(a.type,!1),a;case 11:return a=le(a.type.render,!1),a;case 1:return a=le(a.type,!0),a;default:return""}}function se(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 R:return"Fragment";case O:return"Portal";case D:return"Profiler";case B:return"StrictMode";case W:return"Suspense";case $:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case Q:return(a.displayName||"Context")+".Consumer";case U:return(a._context.displayName||"Context")+".Provider";case P:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return c=a.displayName||null,c!==null?c:se(a.type)||"Memo";case J:c=a._payload,a=a._init;try{return se(a(c))}catch{}}return null}function xe(a){var c=a.type;switch(a.tag){case 24:return"Cache";case 9:return(c.displayName||"Context")+".Consumer";case 10:return(c._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=c.render,a=a.displayName||a.name||"",c.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return c;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return se(c);case 8:return c===B?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c}return null}function fe(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function De(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function We(a){var c=De(a)?"checked":"value",p=Object.getOwnPropertyDescriptor(a.constructor.prototype,c),v=""+a[c];if(!a.hasOwnProperty(c)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var S=p.get,N=p.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return S.call(this)},set:function(j){v=""+j,N.call(this,j)}}),Object.defineProperty(a,c,{enumerable:p.enumerable}),{getValue:function(){return v},setValue:function(j){v=""+j},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function Qe(a){a._valueTracker||(a._valueTracker=We(a))}function ot(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var p=c.getValue(),v="";return a&&(v=De(a)?a.checked?"true":"false":a.value),a=v,a!==p?(c.setValue(a),!0):!1}function st(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 Ie(a,c){var p=c.checked;return z({},c,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??a._wrapperState.initialChecked})}function dt(a,c){var p=c.defaultValue==null?"":c.defaultValue,v=c.checked!=null?c.checked:c.defaultChecked;p=fe(c.value!=null?c.value:p),a._wrapperState={initialChecked:v,initialValue:p,controlled:c.type==="checkbox"||c.type==="radio"?c.checked!=null:c.value!=null}}function Ge(a,c){c=c.checked,c!=null&&A(a,"checked",c,!1)}function bt(a,c){Ge(a,c);var p=fe(c.value),v=c.type;if(p!=null)v==="number"?(p===0&&a.value===""||a.value!=p)&&(a.value=""+p):a.value!==""+p&&(a.value=""+p);else if(v==="submit"||v==="reset"){a.removeAttribute("value");return}c.hasOwnProperty("value")?$t(a,c.type,p):c.hasOwnProperty("defaultValue")&&$t(a,c.type,fe(c.defaultValue)),c.checked==null&&c.defaultChecked!=null&&(a.defaultChecked=!!c.defaultChecked)}function xt(a,c,p){if(c.hasOwnProperty("value")||c.hasOwnProperty("defaultValue")){var v=c.type;if(!(v!=="submit"&&v!=="reset"||c.value!==void 0&&c.value!==null))return;c=""+a._wrapperState.initialValue,p||c===a.value||(a.value=c),a.defaultValue=c}p=a.name,p!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,p!==""&&(a.name=p)}function $t(a,c,p){(c!=="number"||st(a.ownerDocument)!==a)&&(p==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+p&&(a.defaultValue=""+p))}var Ke=Array.isArray;function pt(a,c,p,v){if(a=a.options,c){c={};for(var S=0;S<p.length;S++)c["$"+p[S]]=!0;for(p=0;p<a.length;p++)S=c.hasOwnProperty("$"+a[p].value),a[p].selected!==S&&(a[p].selected=S),S&&v&&(a[p].defaultSelected=!0)}else{for(p=""+fe(p),c=null,S=0;S<a.length;S++){if(a[S].value===p){a[S].selected=!0,v&&(a[S].defaultSelected=!0);return}c!==null||a[S].disabled||(c=a[S])}c!==null&&(c.selected=!0)}}function Ft(a,c){if(c.dangerouslySetInnerHTML!=null)throw Error(n(91));return z({},c,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function Je(a,c){var p=c.value;if(p==null){if(p=c.children,c=c.defaultValue,p!=null){if(c!=null)throw Error(n(92));if(Ke(p)){if(1<p.length)throw Error(n(93));p=p[0]}c=p}c==null&&(c=""),p=c}a._wrapperState={initialValue:fe(p)}}function Y(a,c){var p=fe(c.value),v=fe(c.defaultValue);p!=null&&(p=""+p,p!==a.value&&(a.value=p),c.defaultValue==null&&a.defaultValue!==p&&(a.defaultValue=p)),v!=null&&(a.defaultValue=""+v)}function pe(a){var c=a.textContent;c===a._wrapperState.initialValue&&c!==""&&c!==null&&(a.value=c)}function G(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 oe(a,c){return a==null||a==="http://www.w3.org/1999/xhtml"?G(c):a==="http://www.w3.org/2000/svg"&&c==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var ue,Fe=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(c,p,v,S){MSApp.execUnsafeLocalFunction(function(){return a(c,p,v,S)})}:a})(function(a,c){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=c;else{for(ue=ue||document.createElement("div"),ue.innerHTML="<svg>"+c.valueOf().toString()+"</svg>",c=ue.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;c.firstChild;)a.appendChild(c.firstChild)}});function Me(a,c){if(c){var p=a.firstChild;if(p&&p===a.lastChild&&p.nodeType===3){p.nodeValue=c;return}}a.textContent=c}var K={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},me=["Webkit","ms","Moz","O"];Object.keys(K).forEach(function(a){me.forEach(function(c){c=c+a.charAt(0).toUpperCase()+a.substring(1),K[c]=K[a]})});function ye(a,c,p){return c==null||typeof c=="boolean"||c===""?"":p||typeof c!="number"||c===0||K.hasOwnProperty(a)&&K[a]?(""+c).trim():c+"px"}function Ce(a,c){a=a.style;for(var p in c)if(c.hasOwnProperty(p)){var v=p.indexOf("--")===0,S=ye(p,c[p],v);p==="float"&&(p="cssFloat"),v?a.setProperty(p,S):a[p]=S}}var Re=z({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 Be(a,c){if(c){if(Re[a]&&(c.children!=null||c.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(c.dangerouslySetInnerHTML!=null){if(c.children!=null)throw Error(n(60));if(typeof c.dangerouslySetInnerHTML!="object"||!("__html"in c.dangerouslySetInnerHTML))throw Error(n(61))}if(c.style!=null&&typeof c.style!="object")throw Error(n(62))}}function Ee(a,c){if(a.indexOf("-")===-1)return typeof c.is=="string";switch(a){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var et=null;function gt(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Tt=null,Jt=null,Mt=null;function q(a){if(a=Na(a)){if(typeof Tt!="function")throw Error(n(280));var c=a.stateNode;c&&(c=tc(c),Tt(a.stateNode,a.type,c))}}function L(a){Jt?Mt?Mt.push(a):Mt=[a]:Jt=a}function te(){if(Jt){var a=Jt,c=Mt;if(Mt=Jt=null,q(a),c)for(a=0;a<c.length;a++)q(c[a])}}function ve(a,c){return a(c)}function Ue(){}var lt=!1;function Ae(a,c,p){if(lt)return a(c,p);lt=!0;try{return ve(a,c,p)}finally{lt=!1,(Jt!==null||Mt!==null)&&(Ue(),te())}}function de(a,c){var p=a.stateNode;if(p===null)return null;var v=tc(p);if(v===null)return null;p=v[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(v=!v.disabled)||(a=a.type,v=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!v;break e;default:a=!1}if(a)return null;if(p&&typeof p!="function")throw Error(n(231,c,typeof p));return p}var _e=!1;if(l)try{var ze={};Object.defineProperty(ze,"passive",{get:function(){_e=!0}}),window.addEventListener("test",ze,ze),window.removeEventListener("test",ze,ze)}catch{_e=!1}function Wt(a,c,p,v,S,N,j,F,X){var he=Array.prototype.slice.call(arguments,3);try{c.apply(p,he)}catch(Se){this.onError(Se)}}var wt=!1,an=null,ft=!1,En=null,ne={onError:function(a){wt=!0,an=a}};function ke(a,c,p,v,S,N,j,F,X){wt=!1,an=null,Wt.apply(ne,arguments)}function $e(a,c,p,v,S,N,j,F,X){if(ke.apply(this,arguments),wt){if(wt){var he=an;wt=!1,an=null}else throw Error(n(198));ft||(ft=!0,En=he)}}function at(a){var c=a,p=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(p=c.return),a=c.return;while(a)}return c.tag===3?p:null}function Nt(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function ln(a){if(at(a)!==a)throw Error(n(188))}function xn(a){var c=a.alternate;if(!c){if(c=at(a),c===null)throw Error(n(188));return c!==a?null:a}for(var p=a,v=c;;){var S=p.return;if(S===null)break;var N=S.alternate;if(N===null){if(v=S.return,v!==null){p=v;continue}break}if(S.child===N.child){for(N=S.child;N;){if(N===p)return ln(S),a;if(N===v)return ln(S),c;N=N.sibling}throw Error(n(188))}if(p.return!==v.return)p=S,v=N;else{for(var j=!1,F=S.child;F;){if(F===p){j=!0,p=S,v=N;break}if(F===v){j=!0,v=S,p=N;break}F=F.sibling}if(!j){for(F=N.child;F;){if(F===p){j=!0,p=N,v=S;break}if(F===v){j=!0,v=N,p=S;break}F=F.sibling}if(!j)throw Error(n(189))}}if(p.alternate!==v)throw Error(n(190))}if(p.tag!==3)throw Error(n(188));return p.stateNode.current===p?a:c}function Zt(a){return a=xn(a),a!==null?tn(a):null}function tn(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var c=tn(a);if(c!==null)return c;a=a.sibling}return null}var Is=e.unstable_scheduleCallback,Br=e.unstable_cancelCallback,Pl=e.unstable_shouldYield,Bl=e.unstable_requestPaint,nn=e.unstable_now,tf=e.unstable_getCurrentPriorityLevel,aa=e.unstable_ImmediatePriority,Si=e.unstable_UserBlockingPriority,uo=e.unstable_NormalPriority,je=e.unstable_LowPriority,tt=e.unstable_IdlePriority,kt=null,_t=null;function gn(a){if(_t&&typeof _t.onCommitFiberRoot=="function")try{_t.onCommitFiberRoot(kt,a,void 0,(a.current.flags&128)===128)}catch{}}var rn=Math.clz32?Math.clz32:Qn,Qr=Math.log,fo=Math.LN2;function Qn(a){return a>>>=0,a===0?32:31-(Qr(a)/fo|0)|0}var Zn=64,Ei=4194304;function Ls(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 Ni(a,c){var p=a.pendingLanes;if(p===0)return 0;var v=0,S=a.suspendedLanes,N=a.pingedLanes,j=p&268435455;if(j!==0){var F=j&~S;F!==0?v=Ls(F):(N&=j,N!==0&&(v=Ls(N)))}else j=p&~S,j!==0?v=Ls(j):N!==0&&(v=Ls(N));if(v===0)return 0;if(c!==0&&c!==v&&(c&S)===0&&(S=v&-v,N=c&-c,S>=N||S===16&&(N&4194240)!==0))return c;if((v&4)!==0&&(v|=p&16),c=a.entangledLanes,c!==0)for(a=a.entanglements,c&=v;0<c;)p=31-rn(c),S=1<<p,v|=a[p],c&=~S;return v}function nf(a,c){switch(a){case 1:case 2:case 4:return c+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function rf(a,c){for(var p=a.suspendedLanes,v=a.pingedLanes,S=a.expirationTimes,N=a.pendingLanes;0<N;){var j=31-rn(N),F=1<<j,X=S[j];X===-1?((F&p)===0||(F&v)!==0)&&(S[j]=nf(F,c)):X<=c&&(a.expiredLanes|=F),N&=~F}}function la(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function zl(){var a=Zn;return Zn<<=1,(Zn&4194240)===0&&(Zn=64),a}function Ds(a){for(var c=[],p=0;31>p;p++)c.push(a);return c}function Ps(a,c,p){a.pendingLanes|=c,c!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,c=31-rn(c),a[c]=p}function kr(a,c){var p=a.pendingLanes&~c;a.pendingLanes=c,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=c,a.mutableReadLanes&=c,a.entangledLanes&=c,c=a.entanglements;var v=a.eventTimes;for(a=a.expirationTimes;0<p;){var S=31-rn(p),N=1<<S;c[S]=0,v[S]=-1,a[S]=-1,p&=~N}}function ca(a,c){var p=a.entangledLanes|=c;for(a=a.entanglements;p;){var v=31-rn(p),S=1<<v;S&c|a[v]&c&&(a[v]|=c),p&=~S}}var Rt=0;function yt(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var ua,vn,Ut,Ci,Zr,_i=!1,Bs=[],Le=null,qe=null,mt=null,At=new Map,cn=new Map,_n=[],sf="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 $l(a,c){switch(a){case"focusin":case"focusout":Le=null;break;case"dragenter":case"dragleave":qe=null;break;case"mouseover":case"mouseout":mt=null;break;case"pointerover":case"pointerout":At.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":cn.delete(c.pointerId)}}function da(a,c,p,v,S,N){return a===null||a.nativeEvent!==N?(a={blockedOn:c,domEventName:p,eventSystemFlags:v,nativeEvent:N,targetContainers:[S]},c!==null&&(c=Na(c),c!==null&&vn(c)),a):(a.eventSystemFlags|=v,c=a.targetContainers,S!==null&&c.indexOf(S)===-1&&c.push(S),a)}function iT(a,c,p,v,S){switch(c){case"focusin":return Le=da(Le,a,c,p,v,S),!0;case"dragenter":return qe=da(qe,a,c,p,v,S),!0;case"mouseover":return mt=da(mt,a,c,p,v,S),!0;case"pointerover":var N=S.pointerId;return At.set(N,da(At.get(N)||null,a,c,p,v,S)),!0;case"gotpointercapture":return N=S.pointerId,cn.set(N,da(cn.get(N)||null,a,c,p,v,S)),!0}return!1}function m0(a){var c=Ti(a.target);if(c!==null){var p=at(c);if(p!==null){if(c=p.tag,c===13){if(c=Nt(p),c!==null){a.blockedOn=c,Zr(a.priority,function(){Ut(p)});return}}else if(c===3&&p.stateNode.current.memoizedState.isDehydrated){a.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}a.blockedOn=null}function Fl(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var p=af(a.domEventName,a.eventSystemFlags,c[0],a.nativeEvent);if(p===null){p=a.nativeEvent;var v=new p.constructor(p.type,p);et=v,p.target.dispatchEvent(v),et=null}else return c=Na(p),c!==null&&vn(c),a.blockedOn=p,!1;c.shift()}return!0}function g0(a,c,p){Fl(a)&&p.delete(c)}function oT(){_i=!1,Le!==null&&Fl(Le)&&(Le=null),qe!==null&&Fl(qe)&&(qe=null),mt!==null&&Fl(mt)&&(mt=null),At.forEach(g0),cn.forEach(g0)}function fa(a,c){a.blockedOn===c&&(a.blockedOn=null,_i||(_i=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,oT)))}function ha(a){function c(S){return fa(S,a)}if(0<Bs.length){fa(Bs[0],a);for(var p=1;p<Bs.length;p++){var v=Bs[p];v.blockedOn===a&&(v.blockedOn=null)}}for(Le!==null&&fa(Le,a),qe!==null&&fa(qe,a),mt!==null&&fa(mt,a),At.forEach(c),cn.forEach(c),p=0;p<_n.length;p++)v=_n[p],v.blockedOn===a&&(v.blockedOn=null);for(;0<_n.length&&(p=_n[0],p.blockedOn===null);)m0(p),p.blockedOn===null&&_n.shift()}var ho=T.ReactCurrentBatchConfig,Ul=!0;function aT(a,c,p,v){var S=Rt,N=ho.transition;ho.transition=null;try{Rt=1,of(a,c,p,v)}finally{Rt=S,ho.transition=N}}function lT(a,c,p,v){var S=Rt,N=ho.transition;ho.transition=null;try{Rt=4,of(a,c,p,v)}finally{Rt=S,ho.transition=N}}function of(a,c,p,v){if(Ul){var S=af(a,c,p,v);if(S===null)Ef(a,c,v,Hl,p),$l(a,v);else if(iT(S,a,c,p,v))v.stopPropagation();else if($l(a,v),c&4&&-1<sf.indexOf(a)){for(;S!==null;){var N=Na(S);if(N!==null&&ua(N),N=af(a,c,p,v),N===null&&Ef(a,c,v,Hl,p),N===S)break;S=N}S!==null&&v.stopPropagation()}else Ef(a,c,v,null,p)}}var Hl=null;function af(a,c,p,v){if(Hl=null,a=gt(v),a=Ti(a),a!==null)if(c=at(a),c===null)a=null;else if(p=c.tag,p===13){if(a=Nt(c),a!==null)return a;a=null}else if(p===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null);return Hl=a,null}function v0(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(tf()){case aa:return 1;case Si:return 4;case uo:case je:return 16;case tt:return 536870912;default:return 16}default:return 16}}var zs=null,lf=null,Wl=null;function y0(){if(Wl)return Wl;var a,c=lf,p=c.length,v,S="value"in zs?zs.value:zs.textContent,N=S.length;for(a=0;a<p&&c[a]===S[a];a++);var j=p-a;for(v=1;v<=j&&c[p-v]===S[N-v];v++);return Wl=S.slice(a,1<v?1-v:void 0)}function ql(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function Vl(){return!0}function b0(){return!1}function pr(a){function c(p,v,S,N,j){this._reactName=p,this._targetInst=S,this.type=v,this.nativeEvent=N,this.target=j,this.currentTarget=null;for(var F in a)a.hasOwnProperty(F)&&(p=a[F],this[F]=p?p(N):N[F]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?Vl:b0,this.isPropagationStopped=b0,this}return z(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Vl)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Vl)},persist:function(){},isPersistent:Vl}),c}var po={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},cf=pr(po),pa=z({},po,{view:0,detail:0}),cT=pr(pa),uf,df,ma,Kl=z({},pa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hf,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!==ma&&(ma&&a.type==="mousemove"?(uf=a.screenX-ma.screenX,df=a.screenY-ma.screenY):df=uf=0,ma=a),uf)},movementY:function(a){return"movementY"in a?a.movementY:df}}),x0=pr(Kl),uT=z({},Kl,{dataTransfer:0}),dT=pr(uT),fT=z({},pa,{relatedTarget:0}),ff=pr(fT),hT=z({},po,{animationName:0,elapsedTime:0,pseudoElement:0}),pT=pr(hT),mT=z({},po,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),gT=pr(mT),vT=z({},po,{data:0}),w0=pr(vT),yT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},bT={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"},xT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function wT(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=xT[a])?!!c[a]:!1}function hf(){return wT}var kT=z({},pa,{key:function(a){if(a.key){var c=yT[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=ql(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?bT[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hf,charCode:function(a){return a.type==="keypress"?ql(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?ql(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),ST=pr(kT),ET=z({},Kl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),k0=pr(ET),NT=z({},pa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hf}),CT=pr(NT),_T=z({},po,{propertyName:0,elapsedTime:0,pseudoElement:0}),TT=pr(_T),MT=z({},Kl,{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}),AT=pr(MT),jT=[9,13,27,32],pf=l&&"CompositionEvent"in window,ga=null;l&&"documentMode"in document&&(ga=document.documentMode);var OT=l&&"TextEvent"in window&&!ga,S0=l&&(!pf||ga&&8<ga&&11>=ga),E0=" ",N0=!1;function C0(a,c){switch(a){case"keyup":return jT.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _0(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var mo=!1;function RT(a,c){switch(a){case"compositionend":return _0(c);case"keypress":return c.which!==32?null:(N0=!0,E0);case"textInput":return a=c.data,a===E0&&N0?null:a;default:return null}}function IT(a,c){if(mo)return a==="compositionend"||!pf&&C0(a,c)?(a=y0(),Wl=lf=zs=null,mo=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return S0&&c.locale!=="ko"?null:c.data;default:return null}}var LT={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 T0(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!LT[a.type]:c==="textarea"}function M0(a,c,p,v){L(v),c=Ql(c,"onChange"),0<c.length&&(p=new cf("onChange","change",null,p,v),a.push({event:p,listeners:c}))}var va=null,ya=null;function DT(a){K0(a,0)}function Gl(a){var c=xo(a);if(ot(c))return a}function PT(a,c){if(a==="change")return c}var A0=!1;if(l){var mf;if(l){var gf="oninput"in document;if(!gf){var j0=document.createElement("div");j0.setAttribute("oninput","return;"),gf=typeof j0.oninput=="function"}mf=gf}else mf=!1;A0=mf&&(!document.documentMode||9<document.documentMode)}function O0(){va&&(va.detachEvent("onpropertychange",R0),ya=va=null)}function R0(a){if(a.propertyName==="value"&&Gl(ya)){var c=[];M0(c,ya,a,gt(a)),Ae(DT,c)}}function BT(a,c,p){a==="focusin"?(O0(),va=c,ya=p,va.attachEvent("onpropertychange",R0)):a==="focusout"&&O0()}function zT(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Gl(ya)}function $T(a,c){if(a==="click")return Gl(c)}function FT(a,c){if(a==="input"||a==="change")return Gl(c)}function UT(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var zr=typeof Object.is=="function"?Object.is:UT;function ba(a,c){if(zr(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var p=Object.keys(a),v=Object.keys(c);if(p.length!==v.length)return!1;for(v=0;v<p.length;v++){var S=p[v];if(!d.call(c,S)||!zr(a[S],c[S]))return!1}return!0}function I0(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function L0(a,c){var p=I0(a);a=0;for(var v;p;){if(p.nodeType===3){if(v=a+p.textContent.length,a<=c&&v>=c)return{node:p,offset:c-a};a=v}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=I0(p)}}function D0(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?D0(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function P0(){for(var a=window,c=st();c instanceof a.HTMLIFrameElement;){try{var p=typeof c.contentWindow.location.href=="string"}catch{p=!1}if(p)a=c.contentWindow;else break;c=st(a.document)}return c}function vf(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}function HT(a){var c=P0(),p=a.focusedElem,v=a.selectionRange;if(c!==p&&p&&p.ownerDocument&&D0(p.ownerDocument.documentElement,p)){if(v!==null&&vf(p)){if(c=v.start,a=v.end,a===void 0&&(a=c),"selectionStart"in p)p.selectionStart=c,p.selectionEnd=Math.min(a,p.value.length);else if(a=(c=p.ownerDocument||document)&&c.defaultView||window,a.getSelection){a=a.getSelection();var S=p.textContent.length,N=Math.min(v.start,S);v=v.end===void 0?N:Math.min(v.end,S),!a.extend&&N>v&&(S=v,v=N,N=S),S=L0(p,N);var j=L0(p,v);S&&j&&(a.rangeCount!==1||a.anchorNode!==S.node||a.anchorOffset!==S.offset||a.focusNode!==j.node||a.focusOffset!==j.offset)&&(c=c.createRange(),c.setStart(S.node,S.offset),a.removeAllRanges(),N>v?(a.addRange(c),a.extend(j.node,j.offset)):(c.setEnd(j.node,j.offset),a.addRange(c)))}}for(c=[],a=p;a=a.parentNode;)a.nodeType===1&&c.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<c.length;p++)a=c[p],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var WT=l&&"documentMode"in document&&11>=document.documentMode,go=null,yf=null,xa=null,bf=!1;function B0(a,c,p){var v=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;bf||go==null||go!==st(v)||(v=go,"selectionStart"in v&&vf(v)?v={start:v.selectionStart,end:v.selectionEnd}:(v=(v.ownerDocument&&v.ownerDocument.defaultView||window).getSelection(),v={anchorNode:v.anchorNode,anchorOffset:v.anchorOffset,focusNode:v.focusNode,focusOffset:v.focusOffset}),xa&&ba(xa,v)||(xa=v,v=Ql(yf,"onSelect"),0<v.length&&(c=new cf("onSelect","select",null,c,p),a.push({event:c,listeners:v}),c.target=go)))}function Jl(a,c){var p={};return p[a.toLowerCase()]=c.toLowerCase(),p["Webkit"+a]="webkit"+c,p["Moz"+a]="moz"+c,p}var vo={animationend:Jl("Animation","AnimationEnd"),animationiteration:Jl("Animation","AnimationIteration"),animationstart:Jl("Animation","AnimationStart"),transitionend:Jl("Transition","TransitionEnd")},xf={},z0={};l&&(z0=document.createElement("div").style,"AnimationEvent"in window||(delete vo.animationend.animation,delete vo.animationiteration.animation,delete vo.animationstart.animation),"TransitionEvent"in window||delete vo.transitionend.transition);function Yl(a){if(xf[a])return xf[a];if(!vo[a])return a;var c=vo[a],p;for(p in c)if(c.hasOwnProperty(p)&&p in z0)return xf[a]=c[p];return a}var $0=Yl("animationend"),F0=Yl("animationiteration"),U0=Yl("animationstart"),H0=Yl("transitionend"),W0=new Map,q0="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 $s(a,c){W0.set(a,c),i(c,[a])}for(var wf=0;wf<q0.length;wf++){var kf=q0[wf],qT=kf.toLowerCase(),VT=kf[0].toUpperCase()+kf.slice(1);$s(qT,"on"+VT)}$s($0,"onAnimationEnd"),$s(F0,"onAnimationIteration"),$s(U0,"onAnimationStart"),$s("dblclick","onDoubleClick"),$s("focusin","onFocus"),$s("focusout","onBlur"),$s(H0,"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 wa="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(" "),KT=new Set("cancel close invalid load scroll toggle".split(" ").concat(wa));function V0(a,c,p){var v=a.type||"unknown-event";a.currentTarget=p,$e(v,c,void 0,a),a.currentTarget=null}function K0(a,c){c=(c&4)!==0;for(var p=0;p<a.length;p++){var v=a[p],S=v.event;v=v.listeners;e:{var N=void 0;if(c)for(var j=v.length-1;0<=j;j--){var F=v[j],X=F.instance,he=F.currentTarget;if(F=F.listener,X!==N&&S.isPropagationStopped())break e;V0(S,F,he),N=X}else for(j=0;j<v.length;j++){if(F=v[j],X=F.instance,he=F.currentTarget,F=F.listener,X!==N&&S.isPropagationStopped())break e;V0(S,F,he),N=X}}}if(ft)throw a=En,ft=!1,En=null,a}function Yt(a,c){var p=c[Af];p===void 0&&(p=c[Af]=new Set);var v=a+"__bubble";p.has(v)||(G0(c,a,2,!1),p.add(v))}function Sf(a,c,p){var v=0;c&&(v|=4),G0(p,a,v,c)}var Xl="_reactListening"+Math.random().toString(36).slice(2);function ka(a){if(!a[Xl]){a[Xl]=!0,r.forEach(function(p){p!=="selectionchange"&&(KT.has(p)||Sf(p,!1,a),Sf(p,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[Xl]||(c[Xl]=!0,Sf("selectionchange",!1,c))}}function G0(a,c,p,v){switch(v0(c)){case 1:var S=aT;break;case 4:S=lT;break;default:S=of}p=S.bind(null,c,p,a),S=void 0,!_e||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(S=!0),v?S!==void 0?a.addEventListener(c,p,{capture:!0,passive:S}):a.addEventListener(c,p,!0):S!==void 0?a.addEventListener(c,p,{passive:S}):a.addEventListener(c,p,!1)}function Ef(a,c,p,v,S){var N=v;if((c&1)===0&&(c&2)===0&&v!==null)e:for(;;){if(v===null)return;var j=v.tag;if(j===3||j===4){var F=v.stateNode.containerInfo;if(F===S||F.nodeType===8&&F.parentNode===S)break;if(j===4)for(j=v.return;j!==null;){var X=j.tag;if((X===3||X===4)&&(X=j.stateNode.containerInfo,X===S||X.nodeType===8&&X.parentNode===S))return;j=j.return}for(;F!==null;){if(j=Ti(F),j===null)return;if(X=j.tag,X===5||X===6){v=N=j;continue e}F=F.parentNode}}v=v.return}Ae(function(){var he=N,Se=gt(p),Ne=[];e:{var we=W0.get(a);if(we!==void 0){var He=cf,Ye=a;switch(a){case"keypress":if(ql(p)===0)break e;case"keydown":case"keyup":He=ST;break;case"focusin":Ye="focus",He=ff;break;case"focusout":Ye="blur",He=ff;break;case"beforeblur":case"afterblur":He=ff;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":He=x0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=dT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=CT;break;case $0:case F0:case U0:He=pT;break;case H0:He=TT;break;case"scroll":He=cT;break;case"wheel":He=AT;break;case"copy":case"cut":case"paste":He=gT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=k0}var Xe=(c&4)!==0,yn=!Xe&&a==="scroll",ae=Xe?we!==null?we+"Capture":null:we;Xe=[];for(var ee=he,ce;ee!==null;){ce=ee;var Oe=ce.stateNode;if(ce.tag===5&&Oe!==null&&(ce=Oe,ae!==null&&(Oe=de(ee,ae),Oe!=null&&Xe.push(Sa(ee,Oe,ce)))),yn)break;ee=ee.return}0<Xe.length&&(we=new He(we,Ye,null,p,Se),Ne.push({event:we,listeners:Xe}))}}if((c&7)===0){e:{if(we=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",we&&p!==et&&(Ye=p.relatedTarget||p.fromElement)&&(Ti(Ye)||Ye[fs]))break e;if((He||we)&&(we=Se.window===Se?Se:(we=Se.ownerDocument)?we.defaultView||we.parentWindow:window,He?(Ye=p.relatedTarget||p.toElement,He=he,Ye=Ye?Ti(Ye):null,Ye!==null&&(yn=at(Ye),Ye!==yn||Ye.tag!==5&&Ye.tag!==6)&&(Ye=null)):(He=null,Ye=he),He!==Ye)){if(Xe=x0,Oe="onMouseLeave",ae="onMouseEnter",ee="mouse",(a==="pointerout"||a==="pointerover")&&(Xe=k0,Oe="onPointerLeave",ae="onPointerEnter",ee="pointer"),yn=He==null?we:xo(He),ce=Ye==null?we:xo(Ye),we=new Xe(Oe,ee+"leave",He,p,Se),we.target=yn,we.relatedTarget=ce,Oe=null,Ti(Se)===he&&(Xe=new Xe(ae,ee+"enter",Ye,p,Se),Xe.target=ce,Xe.relatedTarget=yn,Oe=Xe),yn=Oe,He&&Ye)t:{for(Xe=He,ae=Ye,ee=0,ce=Xe;ce;ce=yo(ce))ee++;for(ce=0,Oe=ae;Oe;Oe=yo(Oe))ce++;for(;0<ee-ce;)Xe=yo(Xe),ee--;for(;0<ce-ee;)ae=yo(ae),ce--;for(;ee--;){if(Xe===ae||ae!==null&&Xe===ae.alternate)break t;Xe=yo(Xe),ae=yo(ae)}Xe=null}else Xe=null;He!==null&&J0(Ne,we,He,Xe,!1),Ye!==null&&yn!==null&&J0(Ne,yn,Ye,Xe,!0)}}e:{if(we=he?xo(he):window,He=we.nodeName&&we.nodeName.toLowerCase(),He==="select"||He==="input"&&we.type==="file")var Ze=PT;else if(T0(we))if(A0)Ze=FT;else{Ze=zT;var ct=BT}else(He=we.nodeName)&&He.toLowerCase()==="input"&&(we.type==="checkbox"||we.type==="radio")&&(Ze=$T);if(Ze&&(Ze=Ze(a,he))){M0(Ne,Ze,p,Se);break e}ct&&ct(a,we,he),a==="focusout"&&(ct=we._wrapperState)&&ct.controlled&&we.type==="number"&&$t(we,"number",we.value)}switch(ct=he?xo(he):window,a){case"focusin":(T0(ct)||ct.contentEditable==="true")&&(go=ct,yf=he,xa=null);break;case"focusout":xa=yf=go=null;break;case"mousedown":bf=!0;break;case"contextmenu":case"mouseup":case"dragend":bf=!1,B0(Ne,p,Se);break;case"selectionchange":if(WT)break;case"keydown":case"keyup":B0(Ne,p,Se)}var ut;if(pf)e:{switch(a){case"compositionstart":var vt="onCompositionStart";break e;case"compositionend":vt="onCompositionEnd";break e;case"compositionupdate":vt="onCompositionUpdate";break e}vt=void 0}else mo?C0(a,p)&&(vt="onCompositionEnd"):a==="keydown"&&p.keyCode===229&&(vt="onCompositionStart");vt&&(S0&&p.locale!=="ko"&&(mo||vt!=="onCompositionStart"?vt==="onCompositionEnd"&&mo&&(ut=y0()):(zs=Se,lf="value"in zs?zs.value:zs.textContent,mo=!0)),ct=Ql(he,vt),0<ct.length&&(vt=new w0(vt,a,null,p,Se),Ne.push({event:vt,listeners:ct}),ut?vt.data=ut:(ut=_0(p),ut!==null&&(vt.data=ut)))),(ut=OT?RT(a,p):IT(a,p))&&(he=Ql(he,"onBeforeInput"),0<he.length&&(Se=new w0("onBeforeInput","beforeinput",null,p,Se),Ne.push({event:Se,listeners:he}),Se.data=ut))}K0(Ne,c)})}function Sa(a,c,p){return{instance:a,listener:c,currentTarget:p}}function Ql(a,c){for(var p=c+"Capture",v=[];a!==null;){var S=a,N=S.stateNode;S.tag===5&&N!==null&&(S=N,N=de(a,p),N!=null&&v.unshift(Sa(a,N,S)),N=de(a,c),N!=null&&v.push(Sa(a,N,S))),a=a.return}return v}function yo(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function J0(a,c,p,v,S){for(var N=c._reactName,j=[];p!==null&&p!==v;){var F=p,X=F.alternate,he=F.stateNode;if(X!==null&&X===v)break;F.tag===5&&he!==null&&(F=he,S?(X=de(p,N),X!=null&&j.unshift(Sa(p,X,F))):S||(X=de(p,N),X!=null&&j.push(Sa(p,X,F)))),p=p.return}j.length!==0&&a.push({event:c,listeners:j})}var GT=/\r\n?/g,JT=/\u0000|\uFFFD/g;function Y0(a){return(typeof a=="string"?a:""+a).replace(GT,`
|
|
38
|
-
`).replace(JT,"")}function Zl(a,c,p){if(c=Y0(c),Y0(a)!==c&&p)throw Error(n(425))}function ec(){}var Nf=null,Cf=null;function _f(a,c){return a==="textarea"||a==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Tf=typeof setTimeout=="function"?setTimeout:void 0,YT=typeof clearTimeout=="function"?clearTimeout:void 0,X0=typeof Promise=="function"?Promise:void 0,XT=typeof queueMicrotask=="function"?queueMicrotask:typeof X0<"u"?function(a){return X0.resolve(null).then(a).catch(QT)}:Tf;function QT(a){setTimeout(function(){throw a})}function Mf(a,c){var p=c,v=0;do{var S=p.nextSibling;if(a.removeChild(p),S&&S.nodeType===8)if(p=S.data,p==="/$"){if(v===0){a.removeChild(S),ha(c);return}v--}else p!=="$"&&p!=="$?"&&p!=="$!"||v++;p=S}while(p);ha(c)}function Fs(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?")break;if(c==="/$")return null}}return a}function Q0(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var p=a.data;if(p==="$"||p==="$!"||p==="$?"){if(c===0)return a;c--}else p==="/$"&&c++}a=a.previousSibling}return null}var bo=Math.random().toString(36).slice(2),es="__reactFiber$"+bo,Ea="__reactProps$"+bo,fs="__reactContainer$"+bo,Af="__reactEvents$"+bo,ZT="__reactListeners$"+bo,eM="__reactHandles$"+bo;function Ti(a){var c=a[es];if(c)return c;for(var p=a.parentNode;p;){if(c=p[fs]||p[es]){if(p=c.alternate,c.child!==null||p!==null&&p.child!==null)for(a=Q0(a);a!==null;){if(p=a[es])return p;a=Q0(a)}return c}a=p,p=a.parentNode}return null}function Na(a){return a=a[es]||a[fs],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function xo(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function tc(a){return a[Ea]||null}var jf=[],wo=-1;function Us(a){return{current:a}}function Xt(a){0>wo||(a.current=jf[wo],jf[wo]=null,wo--)}function Kt(a,c){wo++,jf[wo]=a.current,a.current=c}var Hs={},Wn=Us(Hs),ir=Us(!1),Mi=Hs;function ko(a,c){var p=a.type.contextTypes;if(!p)return Hs;var v=a.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===c)return v.__reactInternalMemoizedMaskedChildContext;var S={},N;for(N in p)S[N]=c[N];return v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=c,a.__reactInternalMemoizedMaskedChildContext=S),S}function or(a){return a=a.childContextTypes,a!=null}function nc(){Xt(ir),Xt(Wn)}function Z0(a,c,p){if(Wn.current!==Hs)throw Error(n(168));Kt(Wn,c),Kt(ir,p)}function ey(a,c,p){var v=a.stateNode;if(c=c.childContextTypes,typeof v.getChildContext!="function")return p;v=v.getChildContext();for(var S in v)if(!(S in c))throw Error(n(108,xe(a)||"Unknown",S));return z({},p,v)}function rc(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Hs,Mi=Wn.current,Kt(Wn,a),Kt(ir,ir.current),!0}function ty(a,c,p){var v=a.stateNode;if(!v)throw Error(n(169));p?(a=ey(a,c,Mi),v.__reactInternalMemoizedMergedChildContext=a,Xt(ir),Xt(Wn),Kt(Wn,a)):Xt(ir),Kt(ir,p)}var hs=null,sc=!1,Of=!1;function ny(a){hs===null?hs=[a]:hs.push(a)}function tM(a){sc=!0,ny(a)}function Ws(){if(!Of&&hs!==null){Of=!0;var a=0,c=Rt;try{var p=hs;for(Rt=1;a<p.length;a++){var v=p[a];do v=v(!0);while(v!==null)}hs=null,sc=!1}catch(S){throw hs!==null&&(hs=hs.slice(a+1)),Is(aa,Ws),S}finally{Rt=c,Of=!1}}return null}var So=[],Eo=0,ic=null,oc=0,Sr=[],Er=0,Ai=null,ps=1,ms="";function ji(a,c){So[Eo++]=oc,So[Eo++]=ic,ic=a,oc=c}function ry(a,c,p){Sr[Er++]=ps,Sr[Er++]=ms,Sr[Er++]=Ai,Ai=a;var v=ps;a=ms;var S=32-rn(v)-1;v&=~(1<<S),p+=1;var N=32-rn(c)+S;if(30<N){var j=S-S%5;N=(v&(1<<j)-1).toString(32),v>>=j,S-=j,ps=1<<32-rn(c)+S|p<<S|v,ms=N+a}else ps=1<<N|p<<S|v,ms=a}function Rf(a){a.return!==null&&(ji(a,1),ry(a,1,0))}function If(a){for(;a===ic;)ic=So[--Eo],So[Eo]=null,oc=So[--Eo],So[Eo]=null;for(;a===Ai;)Ai=Sr[--Er],Sr[Er]=null,ms=Sr[--Er],Sr[Er]=null,ps=Sr[--Er],Sr[Er]=null}var mr=null,gr=null,en=!1,$r=null;function sy(a,c){var p=Tr(5,null,null,0);p.elementType="DELETED",p.stateNode=c,p.return=a,c=a.deletions,c===null?(a.deletions=[p],a.flags|=16):c.push(p)}function iy(a,c){switch(a.tag){case 5:var p=a.type;return c=c.nodeType!==1||p.toLowerCase()!==c.nodeName.toLowerCase()?null:c,c!==null?(a.stateNode=c,mr=a,gr=Fs(c.firstChild),!0):!1;case 6:return c=a.pendingProps===""||c.nodeType!==3?null:c,c!==null?(a.stateNode=c,mr=a,gr=null,!0):!1;case 13:return c=c.nodeType!==8?null:c,c!==null?(p=Ai!==null?{id:ps,overflow:ms}:null,a.memoizedState={dehydrated:c,treeContext:p,retryLane:1073741824},p=Tr(18,null,null,0),p.stateNode=c,p.return=a,a.child=p,mr=a,gr=null,!0):!1;default:return!1}}function Lf(a){return(a.mode&1)!==0&&(a.flags&128)===0}function Df(a){if(en){var c=gr;if(c){var p=c;if(!iy(a,c)){if(Lf(a))throw Error(n(418));c=Fs(p.nextSibling);var v=mr;c&&iy(a,c)?sy(v,p):(a.flags=a.flags&-4097|2,en=!1,mr=a)}}else{if(Lf(a))throw Error(n(418));a.flags=a.flags&-4097|2,en=!1,mr=a}}}function oy(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;mr=a}function ac(a){if(a!==mr)return!1;if(!en)return oy(a),en=!0,!1;var c;if((c=a.tag!==3)&&!(c=a.tag!==5)&&(c=a.type,c=c!=="head"&&c!=="body"&&!_f(a.type,a.memoizedProps)),c&&(c=gr)){if(Lf(a))throw ay(),Error(n(418));for(;c;)sy(a,c),c=Fs(c.nextSibling)}if(oy(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,c=0;a;){if(a.nodeType===8){var p=a.data;if(p==="/$"){if(c===0){gr=Fs(a.nextSibling);break e}c--}else p!=="$"&&p!=="$!"&&p!=="$?"||c++}a=a.nextSibling}gr=null}}else gr=mr?Fs(a.stateNode.nextSibling):null;return!0}function ay(){for(var a=gr;a;)a=Fs(a.nextSibling)}function No(){gr=mr=null,en=!1}function Pf(a){$r===null?$r=[a]:$r.push(a)}var nM=T.ReactCurrentBatchConfig;function Ca(a,c,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 v=p.stateNode}if(!v)throw Error(n(147,a));var S=v,N=""+a;return c!==null&&c.ref!==null&&typeof c.ref=="function"&&c.ref._stringRef===N?c.ref:(c=function(j){var F=S.refs;j===null?delete F[N]:F[N]=j},c._stringRef=N,c)}if(typeof a!="string")throw Error(n(284));if(!p._owner)throw Error(n(290,a))}return a}function lc(a,c){throw a=Object.prototype.toString.call(c),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a))}function ly(a){var c=a._init;return c(a._payload)}function cy(a){function c(ae,ee){if(a){var ce=ae.deletions;ce===null?(ae.deletions=[ee],ae.flags|=16):ce.push(ee)}}function p(ae,ee){if(!a)return null;for(;ee!==null;)c(ae,ee),ee=ee.sibling;return null}function v(ae,ee){for(ae=new Map;ee!==null;)ee.key!==null?ae.set(ee.key,ee):ae.set(ee.index,ee),ee=ee.sibling;return ae}function S(ae,ee){return ae=Qs(ae,ee),ae.index=0,ae.sibling=null,ae}function N(ae,ee,ce){return ae.index=ce,a?(ce=ae.alternate,ce!==null?(ce=ce.index,ce<ee?(ae.flags|=2,ee):ce):(ae.flags|=2,ee)):(ae.flags|=1048576,ee)}function j(ae){return a&&ae.alternate===null&&(ae.flags|=2),ae}function F(ae,ee,ce,Oe){return ee===null||ee.tag!==6?(ee=Th(ce,ae.mode,Oe),ee.return=ae,ee):(ee=S(ee,ce),ee.return=ae,ee)}function X(ae,ee,ce,Oe){var Ze=ce.type;return Ze===R?Se(ae,ee,ce.props.children,Oe,ce.key):ee!==null&&(ee.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===J&&ly(Ze)===ee.type)?(Oe=S(ee,ce.props),Oe.ref=Ca(ae,ee,ce),Oe.return=ae,Oe):(Oe=Oc(ce.type,ce.key,ce.props,null,ae.mode,Oe),Oe.ref=Ca(ae,ee,ce),Oe.return=ae,Oe)}function he(ae,ee,ce,Oe){return ee===null||ee.tag!==4||ee.stateNode.containerInfo!==ce.containerInfo||ee.stateNode.implementation!==ce.implementation?(ee=Mh(ce,ae.mode,Oe),ee.return=ae,ee):(ee=S(ee,ce.children||[]),ee.return=ae,ee)}function Se(ae,ee,ce,Oe,Ze){return ee===null||ee.tag!==7?(ee=zi(ce,ae.mode,Oe,Ze),ee.return=ae,ee):(ee=S(ee,ce),ee.return=ae,ee)}function Ne(ae,ee,ce){if(typeof ee=="string"&&ee!==""||typeof ee=="number")return ee=Th(""+ee,ae.mode,ce),ee.return=ae,ee;if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case _:return ce=Oc(ee.type,ee.key,ee.props,null,ae.mode,ce),ce.ref=Ca(ae,null,ee),ce.return=ae,ce;case O:return ee=Mh(ee,ae.mode,ce),ee.return=ae,ee;case J:var Oe=ee._init;return Ne(ae,Oe(ee._payload),ce)}if(Ke(ee)||ie(ee))return ee=zi(ee,ae.mode,ce,null),ee.return=ae,ee;lc(ae,ee)}return null}function we(ae,ee,ce,Oe){var Ze=ee!==null?ee.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return Ze!==null?null:F(ae,ee,""+ce,Oe);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case _:return ce.key===Ze?X(ae,ee,ce,Oe):null;case O:return ce.key===Ze?he(ae,ee,ce,Oe):null;case J:return Ze=ce._init,we(ae,ee,Ze(ce._payload),Oe)}if(Ke(ce)||ie(ce))return Ze!==null?null:Se(ae,ee,ce,Oe,null);lc(ae,ce)}return null}function He(ae,ee,ce,Oe,Ze){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number")return ae=ae.get(ce)||null,F(ee,ae,""+Oe,Ze);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case _:return ae=ae.get(Oe.key===null?ce:Oe.key)||null,X(ee,ae,Oe,Ze);case O:return ae=ae.get(Oe.key===null?ce:Oe.key)||null,he(ee,ae,Oe,Ze);case J:var ct=Oe._init;return He(ae,ee,ce,ct(Oe._payload),Ze)}if(Ke(Oe)||ie(Oe))return ae=ae.get(ce)||null,Se(ee,ae,Oe,Ze,null);lc(ee,Oe)}return null}function Ye(ae,ee,ce,Oe){for(var Ze=null,ct=null,ut=ee,vt=ee=0,An=null;ut!==null&&vt<ce.length;vt++){ut.index>vt?(An=ut,ut=null):An=ut.sibling;var Dt=we(ae,ut,ce[vt],Oe);if(Dt===null){ut===null&&(ut=An);break}a&&ut&&Dt.alternate===null&&c(ae,ut),ee=N(Dt,ee,vt),ct===null?Ze=Dt:ct.sibling=Dt,ct=Dt,ut=An}if(vt===ce.length)return p(ae,ut),en&&ji(ae,vt),Ze;if(ut===null){for(;vt<ce.length;vt++)ut=Ne(ae,ce[vt],Oe),ut!==null&&(ee=N(ut,ee,vt),ct===null?Ze=ut:ct.sibling=ut,ct=ut);return en&&ji(ae,vt),Ze}for(ut=v(ae,ut);vt<ce.length;vt++)An=He(ut,ae,vt,ce[vt],Oe),An!==null&&(a&&An.alternate!==null&&ut.delete(An.key===null?vt:An.key),ee=N(An,ee,vt),ct===null?Ze=An:ct.sibling=An,ct=An);return a&&ut.forEach(function(Zs){return c(ae,Zs)}),en&&ji(ae,vt),Ze}function Xe(ae,ee,ce,Oe){var Ze=ie(ce);if(typeof Ze!="function")throw Error(n(150));if(ce=Ze.call(ce),ce==null)throw Error(n(151));for(var ct=Ze=null,ut=ee,vt=ee=0,An=null,Dt=ce.next();ut!==null&&!Dt.done;vt++,Dt=ce.next()){ut.index>vt?(An=ut,ut=null):An=ut.sibling;var Zs=we(ae,ut,Dt.value,Oe);if(Zs===null){ut===null&&(ut=An);break}a&&ut&&Zs.alternate===null&&c(ae,ut),ee=N(Zs,ee,vt),ct===null?Ze=Zs:ct.sibling=Zs,ct=Zs,ut=An}if(Dt.done)return p(ae,ut),en&&ji(ae,vt),Ze;if(ut===null){for(;!Dt.done;vt++,Dt=ce.next())Dt=Ne(ae,Dt.value,Oe),Dt!==null&&(ee=N(Dt,ee,vt),ct===null?Ze=Dt:ct.sibling=Dt,ct=Dt);return en&&ji(ae,vt),Ze}for(ut=v(ae,ut);!Dt.done;vt++,Dt=ce.next())Dt=He(ut,ae,vt,Dt.value,Oe),Dt!==null&&(a&&Dt.alternate!==null&&ut.delete(Dt.key===null?vt:Dt.key),ee=N(Dt,ee,vt),ct===null?Ze=Dt:ct.sibling=Dt,ct=Dt);return a&&ut.forEach(function(LM){return c(ae,LM)}),en&&ji(ae,vt),Ze}function yn(ae,ee,ce,Oe){if(typeof ce=="object"&&ce!==null&&ce.type===R&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case _:e:{for(var Ze=ce.key,ct=ee;ct!==null;){if(ct.key===Ze){if(Ze=ce.type,Ze===R){if(ct.tag===7){p(ae,ct.sibling),ee=S(ct,ce.props.children),ee.return=ae,ae=ee;break e}}else if(ct.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===J&&ly(Ze)===ct.type){p(ae,ct.sibling),ee=S(ct,ce.props),ee.ref=Ca(ae,ct,ce),ee.return=ae,ae=ee;break e}p(ae,ct);break}else c(ae,ct);ct=ct.sibling}ce.type===R?(ee=zi(ce.props.children,ae.mode,Oe,ce.key),ee.return=ae,ae=ee):(Oe=Oc(ce.type,ce.key,ce.props,null,ae.mode,Oe),Oe.ref=Ca(ae,ee,ce),Oe.return=ae,ae=Oe)}return j(ae);case O:e:{for(ct=ce.key;ee!==null;){if(ee.key===ct)if(ee.tag===4&&ee.stateNode.containerInfo===ce.containerInfo&&ee.stateNode.implementation===ce.implementation){p(ae,ee.sibling),ee=S(ee,ce.children||[]),ee.return=ae,ae=ee;break e}else{p(ae,ee);break}else c(ae,ee);ee=ee.sibling}ee=Mh(ce,ae.mode,Oe),ee.return=ae,ae=ee}return j(ae);case J:return ct=ce._init,yn(ae,ee,ct(ce._payload),Oe)}if(Ke(ce))return Ye(ae,ee,ce,Oe);if(ie(ce))return Xe(ae,ee,ce,Oe);lc(ae,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ee!==null&&ee.tag===6?(p(ae,ee.sibling),ee=S(ee,ce),ee.return=ae,ae=ee):(p(ae,ee),ee=Th(ce,ae.mode,Oe),ee.return=ae,ae=ee),j(ae)):p(ae,ee)}return yn}var Co=cy(!0),uy=cy(!1),cc=Us(null),uc=null,_o=null,Bf=null;function zf(){Bf=_o=uc=null}function $f(a){var c=cc.current;Xt(cc),a._currentValue=c}function Ff(a,c,p){for(;a!==null;){var v=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,v!==null&&(v.childLanes|=c)):v!==null&&(v.childLanes&c)!==c&&(v.childLanes|=c),a===p)break;a=a.return}}function To(a,c){uc=a,Bf=_o=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&c)!==0&&(ar=!0),a.firstContext=null)}function Nr(a){var c=a._currentValue;if(Bf!==a)if(a={context:a,memoizedValue:c,next:null},_o===null){if(uc===null)throw Error(n(308));_o=a,uc.dependencies={lanes:0,firstContext:a}}else _o=_o.next=a;return c}var Oi=null;function Uf(a){Oi===null?Oi=[a]:Oi.push(a)}function dy(a,c,p,v){var S=c.interleaved;return S===null?(p.next=p,Uf(c)):(p.next=S.next,S.next=p),c.interleaved=p,gs(a,v)}function gs(a,c){a.lanes|=c;var p=a.alternate;for(p!==null&&(p.lanes|=c),p=a,a=a.return;a!==null;)a.childLanes|=c,p=a.alternate,p!==null&&(p.childLanes|=c),p=a,a=a.return;return p.tag===3?p.stateNode:null}var qs=!1;function Hf(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function fy(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function vs(a,c){return{eventTime:a,lane:c,tag:0,payload:null,callback:null,next:null}}function Vs(a,c,p){var v=a.updateQueue;if(v===null)return null;if(v=v.shared,(It&2)!==0){var S=v.pending;return S===null?c.next=c:(c.next=S.next,S.next=c),v.pending=c,gs(a,p)}return S=v.interleaved,S===null?(c.next=c,Uf(v)):(c.next=S.next,S.next=c),v.interleaved=c,gs(a,p)}function dc(a,c,p){if(c=c.updateQueue,c!==null&&(c=c.shared,(p&4194240)!==0)){var v=c.lanes;v&=a.pendingLanes,p|=v,c.lanes=p,ca(a,p)}}function hy(a,c){var p=a.updateQueue,v=a.alternate;if(v!==null&&(v=v.updateQueue,p===v)){var S=null,N=null;if(p=p.firstBaseUpdate,p!==null){do{var j={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};N===null?S=N=j:N=N.next=j,p=p.next}while(p!==null);N===null?S=N=c:N=N.next=c}else S=N=c;p={baseState:v.baseState,firstBaseUpdate:S,lastBaseUpdate:N,shared:v.shared,effects:v.effects},a.updateQueue=p;return}a=p.lastBaseUpdate,a===null?p.firstBaseUpdate=c:a.next=c,p.lastBaseUpdate=c}function fc(a,c,p,v){var S=a.updateQueue;qs=!1;var N=S.firstBaseUpdate,j=S.lastBaseUpdate,F=S.shared.pending;if(F!==null){S.shared.pending=null;var X=F,he=X.next;X.next=null,j===null?N=he:j.next=he,j=X;var Se=a.alternate;Se!==null&&(Se=Se.updateQueue,F=Se.lastBaseUpdate,F!==j&&(F===null?Se.firstBaseUpdate=he:F.next=he,Se.lastBaseUpdate=X))}if(N!==null){var Ne=S.baseState;j=0,Se=he=X=null,F=N;do{var we=F.lane,He=F.eventTime;if((v&we)===we){Se!==null&&(Se=Se.next={eventTime:He,lane:0,tag:F.tag,payload:F.payload,callback:F.callback,next:null});e:{var Ye=a,Xe=F;switch(we=c,He=p,Xe.tag){case 1:if(Ye=Xe.payload,typeof Ye=="function"){Ne=Ye.call(He,Ne,we);break e}Ne=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=Xe.payload,we=typeof Ye=="function"?Ye.call(He,Ne,we):Ye,we==null)break e;Ne=z({},Ne,we);break e;case 2:qs=!0}}F.callback!==null&&F.lane!==0&&(a.flags|=64,we=S.effects,we===null?S.effects=[F]:we.push(F))}else He={eventTime:He,lane:we,tag:F.tag,payload:F.payload,callback:F.callback,next:null},Se===null?(he=Se=He,X=Ne):Se=Se.next=He,j|=we;if(F=F.next,F===null){if(F=S.shared.pending,F===null)break;we=F,F=we.next,we.next=null,S.lastBaseUpdate=we,S.shared.pending=null}}while(!0);if(Se===null&&(X=Ne),S.baseState=X,S.firstBaseUpdate=he,S.lastBaseUpdate=Se,c=S.shared.interleaved,c!==null){S=c;do j|=S.lane,S=S.next;while(S!==c)}else N===null&&(S.shared.lanes=0);Li|=j,a.lanes=j,a.memoizedState=Ne}}function py(a,c,p){if(a=c.effects,c.effects=null,a!==null)for(c=0;c<a.length;c++){var v=a[c],S=v.callback;if(S!==null){if(v.callback=null,v=p,typeof S!="function")throw Error(n(191,S));S.call(v)}}}var _a={},ts=Us(_a),Ta=Us(_a),Ma=Us(_a);function Ri(a){if(a===_a)throw Error(n(174));return a}function Wf(a,c){switch(Kt(Ma,c),Kt(Ta,a),Kt(ts,_a),a=c.nodeType,a){case 9:case 11:c=(c=c.documentElement)?c.namespaceURI:oe(null,"");break;default:a=a===8?c.parentNode:c,c=a.namespaceURI||null,a=a.tagName,c=oe(c,a)}Xt(ts),Kt(ts,c)}function Mo(){Xt(ts),Xt(Ta),Xt(Ma)}function my(a){Ri(Ma.current);var c=Ri(ts.current),p=oe(c,a.type);c!==p&&(Kt(Ta,a),Kt(ts,p))}function qf(a){Ta.current===a&&(Xt(ts),Xt(Ta))}var sn=Us(0);function hc(a){for(var c=a;c!==null;){if(c.tag===13){var p=c.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return c}else if(c.tag===19&&c.memoizedProps.revealOrder!==void 0){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Vf=[];function Kf(){for(var a=0;a<Vf.length;a++)Vf[a]._workInProgressVersionPrimary=null;Vf.length=0}var pc=T.ReactCurrentDispatcher,Gf=T.ReactCurrentBatchConfig,Ii=0,on=null,Nn=null,Tn=null,mc=!1,Aa=!1,ja=0,rM=0;function qn(){throw Error(n(321))}function Jf(a,c){if(c===null)return!1;for(var p=0;p<c.length&&p<a.length;p++)if(!zr(a[p],c[p]))return!1;return!0}function Yf(a,c,p,v,S,N){if(Ii=N,on=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,pc.current=a===null||a.memoizedState===null?aM:lM,a=p(v,S),Aa){N=0;do{if(Aa=!1,ja=0,25<=N)throw Error(n(301));N+=1,Tn=Nn=null,c.updateQueue=null,pc.current=cM,a=p(v,S)}while(Aa)}if(pc.current=yc,c=Nn!==null&&Nn.next!==null,Ii=0,Tn=Nn=on=null,mc=!1,c)throw Error(n(300));return a}function Xf(){var a=ja!==0;return ja=0,a}function ns(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Tn===null?on.memoizedState=Tn=a:Tn=Tn.next=a,Tn}function Cr(){if(Nn===null){var a=on.alternate;a=a!==null?a.memoizedState:null}else a=Nn.next;var c=Tn===null?on.memoizedState:Tn.next;if(c!==null)Tn=c,Nn=a;else{if(a===null)throw Error(n(310));Nn=a,a={memoizedState:Nn.memoizedState,baseState:Nn.baseState,baseQueue:Nn.baseQueue,queue:Nn.queue,next:null},Tn===null?on.memoizedState=Tn=a:Tn=Tn.next=a}return Tn}function Oa(a,c){return typeof c=="function"?c(a):c}function Qf(a){var c=Cr(),p=c.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var v=Nn,S=v.baseQueue,N=p.pending;if(N!==null){if(S!==null){var j=S.next;S.next=N.next,N.next=j}v.baseQueue=S=N,p.pending=null}if(S!==null){N=S.next,v=v.baseState;var F=j=null,X=null,he=N;do{var Se=he.lane;if((Ii&Se)===Se)X!==null&&(X=X.next={lane:0,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null}),v=he.hasEagerState?he.eagerState:a(v,he.action);else{var Ne={lane:Se,action:he.action,hasEagerState:he.hasEagerState,eagerState:he.eagerState,next:null};X===null?(F=X=Ne,j=v):X=X.next=Ne,on.lanes|=Se,Li|=Se}he=he.next}while(he!==null&&he!==N);X===null?j=v:X.next=F,zr(v,c.memoizedState)||(ar=!0),c.memoizedState=v,c.baseState=j,c.baseQueue=X,p.lastRenderedState=v}if(a=p.interleaved,a!==null){S=a;do N=S.lane,on.lanes|=N,Li|=N,S=S.next;while(S!==a)}else S===null&&(p.lanes=0);return[c.memoizedState,p.dispatch]}function Zf(a){var c=Cr(),p=c.queue;if(p===null)throw Error(n(311));p.lastRenderedReducer=a;var v=p.dispatch,S=p.pending,N=c.memoizedState;if(S!==null){p.pending=null;var j=S=S.next;do N=a(N,j.action),j=j.next;while(j!==S);zr(N,c.memoizedState)||(ar=!0),c.memoizedState=N,c.baseQueue===null&&(c.baseState=N),p.lastRenderedState=N}return[N,v]}function gy(){}function vy(a,c){var p=on,v=Cr(),S=c(),N=!zr(v.memoizedState,S);if(N&&(v.memoizedState=S,ar=!0),v=v.queue,eh(xy.bind(null,p,v,a),[a]),v.getSnapshot!==c||N||Tn!==null&&Tn.memoizedState.tag&1){if(p.flags|=2048,Ra(9,by.bind(null,p,v,S,c),void 0,null),Mn===null)throw Error(n(349));(Ii&30)!==0||yy(p,c,S)}return S}function yy(a,c,p){a.flags|=16384,a={getSnapshot:c,value:p},c=on.updateQueue,c===null?(c={lastEffect:null,stores:null},on.updateQueue=c,c.stores=[a]):(p=c.stores,p===null?c.stores=[a]:p.push(a))}function by(a,c,p,v){c.value=p,c.getSnapshot=v,wy(c)&&ky(a)}function xy(a,c,p){return p(function(){wy(c)&&ky(a)})}function wy(a){var c=a.getSnapshot;a=a.value;try{var p=c();return!zr(a,p)}catch{return!0}}function ky(a){var c=gs(a,1);c!==null&&Wr(c,a,1,-1)}function Sy(a){var c=ns();return typeof a=="function"&&(a=a()),c.memoizedState=c.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Oa,lastRenderedState:a},c.queue=a,a=a.dispatch=oM.bind(null,on,a),[c.memoizedState,a]}function Ra(a,c,p,v){return a={tag:a,create:c,destroy:p,deps:v,next:null},c=on.updateQueue,c===null?(c={lastEffect:null,stores:null},on.updateQueue=c,c.lastEffect=a.next=a):(p=c.lastEffect,p===null?c.lastEffect=a.next=a:(v=p.next,p.next=a,a.next=v,c.lastEffect=a)),a}function Ey(){return Cr().memoizedState}function gc(a,c,p,v){var S=ns();on.flags|=a,S.memoizedState=Ra(1|c,p,void 0,v===void 0?null:v)}function vc(a,c,p,v){var S=Cr();v=v===void 0?null:v;var N=void 0;if(Nn!==null){var j=Nn.memoizedState;if(N=j.destroy,v!==null&&Jf(v,j.deps)){S.memoizedState=Ra(c,p,N,v);return}}on.flags|=a,S.memoizedState=Ra(1|c,p,N,v)}function Ny(a,c){return gc(8390656,8,a,c)}function eh(a,c){return vc(2048,8,a,c)}function Cy(a,c){return vc(4,2,a,c)}function _y(a,c){return vc(4,4,a,c)}function Ty(a,c){if(typeof c=="function")return a=a(),c(a),function(){c(null)};if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function My(a,c,p){return p=p!=null?p.concat([a]):null,vc(4,4,Ty.bind(null,c,a),p)}function th(){}function Ay(a,c){var p=Cr();c=c===void 0?null:c;var v=p.memoizedState;return v!==null&&c!==null&&Jf(c,v[1])?v[0]:(p.memoizedState=[a,c],a)}function jy(a,c){var p=Cr();c=c===void 0?null:c;var v=p.memoizedState;return v!==null&&c!==null&&Jf(c,v[1])?v[0]:(a=a(),p.memoizedState=[a,c],a)}function Oy(a,c,p){return(Ii&21)===0?(a.baseState&&(a.baseState=!1,ar=!0),a.memoizedState=p):(zr(p,c)||(p=zl(),on.lanes|=p,Li|=p,a.baseState=!0),c)}function sM(a,c){var p=Rt;Rt=p!==0&&4>p?p:4,a(!0);var v=Gf.transition;Gf.transition={};try{a(!1),c()}finally{Rt=p,Gf.transition=v}}function Ry(){return Cr().memoizedState}function iM(a,c,p){var v=Ys(a);if(p={lane:v,action:p,hasEagerState:!1,eagerState:null,next:null},Iy(a))Ly(c,p);else if(p=dy(a,c,p,v),p!==null){var S=tr();Wr(p,a,v,S),Dy(p,c,v)}}function oM(a,c,p){var v=Ys(a),S={lane:v,action:p,hasEagerState:!1,eagerState:null,next:null};if(Iy(a))Ly(c,S);else{var N=a.alternate;if(a.lanes===0&&(N===null||N.lanes===0)&&(N=c.lastRenderedReducer,N!==null))try{var j=c.lastRenderedState,F=N(j,p);if(S.hasEagerState=!0,S.eagerState=F,zr(F,j)){var X=c.interleaved;X===null?(S.next=S,Uf(c)):(S.next=X.next,X.next=S),c.interleaved=S;return}}catch{}finally{}p=dy(a,c,S,v),p!==null&&(S=tr(),Wr(p,a,v,S),Dy(p,c,v))}}function Iy(a){var c=a.alternate;return a===on||c!==null&&c===on}function Ly(a,c){Aa=mc=!0;var p=a.pending;p===null?c.next=c:(c.next=p.next,p.next=c),a.pending=c}function Dy(a,c,p){if((p&4194240)!==0){var v=c.lanes;v&=a.pendingLanes,p|=v,c.lanes=p,ca(a,p)}}var yc={readContext:Nr,useCallback:qn,useContext:qn,useEffect:qn,useImperativeHandle:qn,useInsertionEffect:qn,useLayoutEffect:qn,useMemo:qn,useReducer:qn,useRef:qn,useState:qn,useDebugValue:qn,useDeferredValue:qn,useTransition:qn,useMutableSource:qn,useSyncExternalStore:qn,useId:qn,unstable_isNewReconciler:!1},aM={readContext:Nr,useCallback:function(a,c){return ns().memoizedState=[a,c===void 0?null:c],a},useContext:Nr,useEffect:Ny,useImperativeHandle:function(a,c,p){return p=p!=null?p.concat([a]):null,gc(4194308,4,Ty.bind(null,c,a),p)},useLayoutEffect:function(a,c){return gc(4194308,4,a,c)},useInsertionEffect:function(a,c){return gc(4,2,a,c)},useMemo:function(a,c){var p=ns();return c=c===void 0?null:c,a=a(),p.memoizedState=[a,c],a},useReducer:function(a,c,p){var v=ns();return c=p!==void 0?p(c):c,v.memoizedState=v.baseState=c,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:c},v.queue=a,a=a.dispatch=iM.bind(null,on,a),[v.memoizedState,a]},useRef:function(a){var c=ns();return a={current:a},c.memoizedState=a},useState:Sy,useDebugValue:th,useDeferredValue:function(a){return ns().memoizedState=a},useTransition:function(){var a=Sy(!1),c=a[0];return a=sM.bind(null,a[1]),ns().memoizedState=a,[c,a]},useMutableSource:function(){},useSyncExternalStore:function(a,c,p){var v=on,S=ns();if(en){if(p===void 0)throw Error(n(407));p=p()}else{if(p=c(),Mn===null)throw Error(n(349));(Ii&30)!==0||yy(v,c,p)}S.memoizedState=p;var N={value:p,getSnapshot:c};return S.queue=N,Ny(xy.bind(null,v,N,a),[a]),v.flags|=2048,Ra(9,by.bind(null,v,N,p,c),void 0,null),p},useId:function(){var a=ns(),c=Mn.identifierPrefix;if(en){var p=ms,v=ps;p=(v&~(1<<32-rn(v)-1)).toString(32)+p,c=":"+c+"R"+p,p=ja++,0<p&&(c+="H"+p.toString(32)),c+=":"}else p=rM++,c=":"+c+"r"+p.toString(32)+":";return a.memoizedState=c},unstable_isNewReconciler:!1},lM={readContext:Nr,useCallback:Ay,useContext:Nr,useEffect:eh,useImperativeHandle:My,useInsertionEffect:Cy,useLayoutEffect:_y,useMemo:jy,useReducer:Qf,useRef:Ey,useState:function(){return Qf(Oa)},useDebugValue:th,useDeferredValue:function(a){var c=Cr();return Oy(c,Nn.memoizedState,a)},useTransition:function(){var a=Qf(Oa)[0],c=Cr().memoizedState;return[a,c]},useMutableSource:gy,useSyncExternalStore:vy,useId:Ry,unstable_isNewReconciler:!1},cM={readContext:Nr,useCallback:Ay,useContext:Nr,useEffect:eh,useImperativeHandle:My,useInsertionEffect:Cy,useLayoutEffect:_y,useMemo:jy,useReducer:Zf,useRef:Ey,useState:function(){return Zf(Oa)},useDebugValue:th,useDeferredValue:function(a){var c=Cr();return Nn===null?c.memoizedState=a:Oy(c,Nn.memoizedState,a)},useTransition:function(){var a=Zf(Oa)[0],c=Cr().memoizedState;return[a,c]},useMutableSource:gy,useSyncExternalStore:vy,useId:Ry,unstable_isNewReconciler:!1};function Fr(a,c){if(a&&a.defaultProps){c=z({},c),a=a.defaultProps;for(var p in a)c[p]===void 0&&(c[p]=a[p]);return c}return c}function nh(a,c,p,v){c=a.memoizedState,p=p(v,c),p=p==null?c:z({},c,p),a.memoizedState=p,a.lanes===0&&(a.updateQueue.baseState=p)}var bc={isMounted:function(a){return(a=a._reactInternals)?at(a)===a:!1},enqueueSetState:function(a,c,p){a=a._reactInternals;var v=tr(),S=Ys(a),N=vs(v,S);N.payload=c,p!=null&&(N.callback=p),c=Vs(a,N,S),c!==null&&(Wr(c,a,S,v),dc(c,a,S))},enqueueReplaceState:function(a,c,p){a=a._reactInternals;var v=tr(),S=Ys(a),N=vs(v,S);N.tag=1,N.payload=c,p!=null&&(N.callback=p),c=Vs(a,N,S),c!==null&&(Wr(c,a,S,v),dc(c,a,S))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var p=tr(),v=Ys(a),S=vs(p,v);S.tag=2,c!=null&&(S.callback=c),c=Vs(a,S,v),c!==null&&(Wr(c,a,v,p),dc(c,a,v))}};function Py(a,c,p,v,S,N,j){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(v,N,j):c.prototype&&c.prototype.isPureReactComponent?!ba(p,v)||!ba(S,N):!0}function By(a,c,p){var v=!1,S=Hs,N=c.contextType;return typeof N=="object"&&N!==null?N=Nr(N):(S=or(c)?Mi:Wn.current,v=c.contextTypes,N=(v=v!=null)?ko(a,S):Hs),c=new c(p,N),a.memoizedState=c.state!==null&&c.state!==void 0?c.state:null,c.updater=bc,a.stateNode=c,c._reactInternals=a,v&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=S,a.__reactInternalMemoizedMaskedChildContext=N),c}function zy(a,c,p,v){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(p,v),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(p,v),c.state!==a&&bc.enqueueReplaceState(c,c.state,null)}function rh(a,c,p,v){var S=a.stateNode;S.props=p,S.state=a.memoizedState,S.refs={},Hf(a);var N=c.contextType;typeof N=="object"&&N!==null?S.context=Nr(N):(N=or(c)?Mi:Wn.current,S.context=ko(a,N)),S.state=a.memoizedState,N=c.getDerivedStateFromProps,typeof N=="function"&&(nh(a,c,N,p),S.state=a.memoizedState),typeof c.getDerivedStateFromProps=="function"||typeof S.getSnapshotBeforeUpdate=="function"||typeof S.UNSAFE_componentWillMount!="function"&&typeof S.componentWillMount!="function"||(c=S.state,typeof S.componentWillMount=="function"&&S.componentWillMount(),typeof S.UNSAFE_componentWillMount=="function"&&S.UNSAFE_componentWillMount(),c!==S.state&&bc.enqueueReplaceState(S,S.state,null),fc(a,p,S,v),S.state=a.memoizedState),typeof S.componentDidMount=="function"&&(a.flags|=4194308)}function Ao(a,c){try{var p="",v=c;do p+=ge(v),v=v.return;while(v);var S=p}catch(N){S=`
|
|
39
|
-
Error generating stack: `+N.message+`
|
|
40
|
-
`+N.stack}return{value:a,source:c,stack:S,digest:null}}function sh(a,c,p){return{value:a,source:null,stack:p??null,digest:c??null}}function ih(a,c){try{console.error(c.value)}catch(p){setTimeout(function(){throw p})}}var uM=typeof WeakMap=="function"?WeakMap:Map;function $y(a,c,p){p=vs(-1,p),p.tag=3,p.payload={element:null};var v=c.value;return p.callback=function(){Cc||(Cc=!0,xh=v),ih(a,c)},p}function Fy(a,c,p){p=vs(-1,p),p.tag=3;var v=a.type.getDerivedStateFromError;if(typeof v=="function"){var S=c.value;p.payload=function(){return v(S)},p.callback=function(){ih(a,c)}}var N=a.stateNode;return N!==null&&typeof N.componentDidCatch=="function"&&(p.callback=function(){ih(a,c),typeof v!="function"&&(Gs===null?Gs=new Set([this]):Gs.add(this));var j=c.stack;this.componentDidCatch(c.value,{componentStack:j!==null?j:""})}),p}function Uy(a,c,p){var v=a.pingCache;if(v===null){v=a.pingCache=new uM;var S=new Set;v.set(c,S)}else S=v.get(c),S===void 0&&(S=new Set,v.set(c,S));S.has(p)||(S.add(p),a=EM.bind(null,a,c,p),c.then(a,a))}function Hy(a){do{var c;if((c=a.tag===13)&&(c=a.memoizedState,c=c!==null?c.dehydrated!==null:!0),c)return a;a=a.return}while(a!==null);return null}function Wy(a,c,p,v,S){return(a.mode&1)===0?(a===c?a.flags|=65536:(a.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(c=vs(-1,1),c.tag=2,Vs(p,c,1))),p.lanes|=1),a):(a.flags|=65536,a.lanes=S,a)}var dM=T.ReactCurrentOwner,ar=!1;function er(a,c,p,v){c.child=a===null?uy(c,null,p,v):Co(c,a.child,p,v)}function qy(a,c,p,v,S){p=p.render;var N=c.ref;return To(c,S),v=Yf(a,c,p,v,N,S),p=Xf(),a!==null&&!ar?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~S,ys(a,c,S)):(en&&p&&Rf(c),c.flags|=1,er(a,c,v,S),c.child)}function Vy(a,c,p,v,S){if(a===null){var N=p.type;return typeof N=="function"&&!_h(N)&&N.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(c.tag=15,c.type=N,Ky(a,c,N,v,S)):(a=Oc(p.type,null,v,c,c.mode,S),a.ref=c.ref,a.return=c,c.child=a)}if(N=a.child,(a.lanes&S)===0){var j=N.memoizedProps;if(p=p.compare,p=p!==null?p:ba,p(j,v)&&a.ref===c.ref)return ys(a,c,S)}return c.flags|=1,a=Qs(N,v),a.ref=c.ref,a.return=c,c.child=a}function Ky(a,c,p,v,S){if(a!==null){var N=a.memoizedProps;if(ba(N,v)&&a.ref===c.ref)if(ar=!1,c.pendingProps=v=N,(a.lanes&S)!==0)(a.flags&131072)!==0&&(ar=!0);else return c.lanes=a.lanes,ys(a,c,S)}return oh(a,c,p,v,S)}function Gy(a,c,p){var v=c.pendingProps,S=v.children,N=a!==null?a.memoizedState:null;if(v.mode==="hidden")if((c.mode&1)===0)c.memoizedState={baseLanes:0,cachePool:null,transitions:null},Kt(Oo,vr),vr|=p;else{if((p&1073741824)===0)return a=N!==null?N.baseLanes|p:p,c.lanes=c.childLanes=1073741824,c.memoizedState={baseLanes:a,cachePool:null,transitions:null},c.updateQueue=null,Kt(Oo,vr),vr|=a,null;c.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=N!==null?N.baseLanes:p,Kt(Oo,vr),vr|=v}else N!==null?(v=N.baseLanes|p,c.memoizedState=null):v=p,Kt(Oo,vr),vr|=v;return er(a,c,S,p),c.child}function Jy(a,c){var p=c.ref;(a===null&&p!==null||a!==null&&a.ref!==p)&&(c.flags|=512,c.flags|=2097152)}function oh(a,c,p,v,S){var N=or(p)?Mi:Wn.current;return N=ko(c,N),To(c,S),p=Yf(a,c,p,v,N,S),v=Xf(),a!==null&&!ar?(c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~S,ys(a,c,S)):(en&&v&&Rf(c),c.flags|=1,er(a,c,p,S),c.child)}function Yy(a,c,p,v,S){if(or(p)){var N=!0;rc(c)}else N=!1;if(To(c,S),c.stateNode===null)wc(a,c),By(c,p,v),rh(c,p,v,S),v=!0;else if(a===null){var j=c.stateNode,F=c.memoizedProps;j.props=F;var X=j.context,he=p.contextType;typeof he=="object"&&he!==null?he=Nr(he):(he=or(p)?Mi:Wn.current,he=ko(c,he));var Se=p.getDerivedStateFromProps,Ne=typeof Se=="function"||typeof j.getSnapshotBeforeUpdate=="function";Ne||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F!==v||X!==he)&&zy(c,j,v,he),qs=!1;var we=c.memoizedState;j.state=we,fc(c,v,j,S),X=c.memoizedState,F!==v||we!==X||ir.current||qs?(typeof Se=="function"&&(nh(c,p,Se,v),X=c.memoizedState),(F=qs||Py(c,p,F,v,we,X,he))?(Ne||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(c.flags|=4194308)):(typeof j.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=v,c.memoizedState=X),j.props=v,j.state=X,j.context=he,v=F):(typeof j.componentDidMount=="function"&&(c.flags|=4194308),v=!1)}else{j=c.stateNode,fy(a,c),F=c.memoizedProps,he=c.type===c.elementType?F:Fr(c.type,F),j.props=he,Ne=c.pendingProps,we=j.context,X=p.contextType,typeof X=="object"&&X!==null?X=Nr(X):(X=or(p)?Mi:Wn.current,X=ko(c,X));var He=p.getDerivedStateFromProps;(Se=typeof He=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F!==Ne||we!==X)&&zy(c,j,v,X),qs=!1,we=c.memoizedState,j.state=we,fc(c,v,j,S);var Ye=c.memoizedState;F!==Ne||we!==Ye||ir.current||qs?(typeof He=="function"&&(nh(c,p,He,v),Ye=c.memoizedState),(he=qs||Py(c,p,he,v,we,Ye,X)||!1)?(Se||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(v,Ye,X),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(v,Ye,X)),typeof j.componentDidUpdate=="function"&&(c.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof j.componentDidUpdate!="function"||F===a.memoizedProps&&we===a.memoizedState||(c.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||F===a.memoizedProps&&we===a.memoizedState||(c.flags|=1024),c.memoizedProps=v,c.memoizedState=Ye),j.props=v,j.state=Ye,j.context=X,v=he):(typeof j.componentDidUpdate!="function"||F===a.memoizedProps&&we===a.memoizedState||(c.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||F===a.memoizedProps&&we===a.memoizedState||(c.flags|=1024),v=!1)}return ah(a,c,p,v,N,S)}function ah(a,c,p,v,S,N){Jy(a,c);var j=(c.flags&128)!==0;if(!v&&!j)return S&&ty(c,p,!1),ys(a,c,N);v=c.stateNode,dM.current=c;var F=j&&typeof p.getDerivedStateFromError!="function"?null:v.render();return c.flags|=1,a!==null&&j?(c.child=Co(c,a.child,null,N),c.child=Co(c,null,F,N)):er(a,c,F,N),c.memoizedState=v.state,S&&ty(c,p,!0),c.child}function Xy(a){var c=a.stateNode;c.pendingContext?Z0(a,c.pendingContext,c.pendingContext!==c.context):c.context&&Z0(a,c.context,!1),Wf(a,c.containerInfo)}function Qy(a,c,p,v,S){return No(),Pf(S),c.flags|=256,er(a,c,p,v),c.child}var lh={dehydrated:null,treeContext:null,retryLane:0};function ch(a){return{baseLanes:a,cachePool:null,transitions:null}}function Zy(a,c,p){var v=c.pendingProps,S=sn.current,N=!1,j=(c.flags&128)!==0,F;if((F=j)||(F=a!==null&&a.memoizedState===null?!1:(S&2)!==0),F?(N=!0,c.flags&=-129):(a===null||a.memoizedState!==null)&&(S|=1),Kt(sn,S&1),a===null)return Df(c),a=c.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((c.mode&1)===0?c.lanes=1:a.data==="$!"?c.lanes=8:c.lanes=1073741824,null):(j=v.children,a=v.fallback,N?(v=c.mode,N=c.child,j={mode:"hidden",children:j},(v&1)===0&&N!==null?(N.childLanes=0,N.pendingProps=j):N=Rc(j,v,0,null),a=zi(a,v,p,null),N.return=c,a.return=c,N.sibling=a,c.child=N,c.child.memoizedState=ch(p),c.memoizedState=lh,a):uh(c,j));if(S=a.memoizedState,S!==null&&(F=S.dehydrated,F!==null))return fM(a,c,j,v,F,S,p);if(N){N=v.fallback,j=c.mode,S=a.child,F=S.sibling;var X={mode:"hidden",children:v.children};return(j&1)===0&&c.child!==S?(v=c.child,v.childLanes=0,v.pendingProps=X,c.deletions=null):(v=Qs(S,X),v.subtreeFlags=S.subtreeFlags&14680064),F!==null?N=Qs(F,N):(N=zi(N,j,p,null),N.flags|=2),N.return=c,v.return=c,v.sibling=N,c.child=v,v=N,N=c.child,j=a.child.memoizedState,j=j===null?ch(p):{baseLanes:j.baseLanes|p,cachePool:null,transitions:j.transitions},N.memoizedState=j,N.childLanes=a.childLanes&~p,c.memoizedState=lh,v}return N=a.child,a=N.sibling,v=Qs(N,{mode:"visible",children:v.children}),(c.mode&1)===0&&(v.lanes=p),v.return=c,v.sibling=null,a!==null&&(p=c.deletions,p===null?(c.deletions=[a],c.flags|=16):p.push(a)),c.child=v,c.memoizedState=null,v}function uh(a,c){return c=Rc({mode:"visible",children:c},a.mode,0,null),c.return=a,a.child=c}function xc(a,c,p,v){return v!==null&&Pf(v),Co(c,a.child,null,p),a=uh(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function fM(a,c,p,v,S,N,j){if(p)return c.flags&256?(c.flags&=-257,v=sh(Error(n(422))),xc(a,c,j,v)):c.memoizedState!==null?(c.child=a.child,c.flags|=128,null):(N=v.fallback,S=c.mode,v=Rc({mode:"visible",children:v.children},S,0,null),N=zi(N,S,j,null),N.flags|=2,v.return=c,N.return=c,v.sibling=N,c.child=v,(c.mode&1)!==0&&Co(c,a.child,null,j),c.child.memoizedState=ch(j),c.memoizedState=lh,N);if((c.mode&1)===0)return xc(a,c,j,null);if(S.data==="$!"){if(v=S.nextSibling&&S.nextSibling.dataset,v)var F=v.dgst;return v=F,N=Error(n(419)),v=sh(N,v,void 0),xc(a,c,j,v)}if(F=(j&a.childLanes)!==0,ar||F){if(v=Mn,v!==null){switch(j&-j){case 4:S=2;break;case 16:S=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:S=32;break;case 536870912:S=268435456;break;default:S=0}S=(S&(v.suspendedLanes|j))!==0?0:S,S!==0&&S!==N.retryLane&&(N.retryLane=S,gs(a,S),Wr(v,a,S,-1))}return Ch(),v=sh(Error(n(421))),xc(a,c,j,v)}return S.data==="$?"?(c.flags|=128,c.child=a.child,c=NM.bind(null,a),S._reactRetry=c,null):(a=N.treeContext,gr=Fs(S.nextSibling),mr=c,en=!0,$r=null,a!==null&&(Sr[Er++]=ps,Sr[Er++]=ms,Sr[Er++]=Ai,ps=a.id,ms=a.overflow,Ai=c),c=uh(c,v.children),c.flags|=4096,c)}function eb(a,c,p){a.lanes|=c;var v=a.alternate;v!==null&&(v.lanes|=c),Ff(a.return,c,p)}function dh(a,c,p,v,S){var N=a.memoizedState;N===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:v,tail:p,tailMode:S}:(N.isBackwards=c,N.rendering=null,N.renderingStartTime=0,N.last=v,N.tail=p,N.tailMode=S)}function tb(a,c,p){var v=c.pendingProps,S=v.revealOrder,N=v.tail;if(er(a,c,v.children,p),v=sn.current,(v&2)!==0)v=v&1|2,c.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&eb(a,p,c);else if(a.tag===19)eb(a,p,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}v&=1}if(Kt(sn,v),(c.mode&1)===0)c.memoizedState=null;else switch(S){case"forwards":for(p=c.child,S=null;p!==null;)a=p.alternate,a!==null&&hc(a)===null&&(S=p),p=p.sibling;p=S,p===null?(S=c.child,c.child=null):(S=p.sibling,p.sibling=null),dh(c,!1,S,p,N);break;case"backwards":for(p=null,S=c.child,c.child=null;S!==null;){if(a=S.alternate,a!==null&&hc(a)===null){c.child=S;break}a=S.sibling,S.sibling=p,p=S,S=a}dh(c,!0,p,null,N);break;case"together":dh(c,!1,null,null,void 0);break;default:c.memoizedState=null}return c.child}function wc(a,c){(c.mode&1)===0&&a!==null&&(a.alternate=null,c.alternate=null,c.flags|=2)}function ys(a,c,p){if(a!==null&&(c.dependencies=a.dependencies),Li|=c.lanes,(p&c.childLanes)===0)return null;if(a!==null&&c.child!==a.child)throw Error(n(153));if(c.child!==null){for(a=c.child,p=Qs(a,a.pendingProps),c.child=p,p.return=c;a.sibling!==null;)a=a.sibling,p=p.sibling=Qs(a,a.pendingProps),p.return=c;p.sibling=null}return c.child}function hM(a,c,p){switch(c.tag){case 3:Xy(c),No();break;case 5:my(c);break;case 1:or(c.type)&&rc(c);break;case 4:Wf(c,c.stateNode.containerInfo);break;case 10:var v=c.type._context,S=c.memoizedProps.value;Kt(cc,v._currentValue),v._currentValue=S;break;case 13:if(v=c.memoizedState,v!==null)return v.dehydrated!==null?(Kt(sn,sn.current&1),c.flags|=128,null):(p&c.child.childLanes)!==0?Zy(a,c,p):(Kt(sn,sn.current&1),a=ys(a,c,p),a!==null?a.sibling:null);Kt(sn,sn.current&1);break;case 19:if(v=(p&c.childLanes)!==0,(a.flags&128)!==0){if(v)return tb(a,c,p);c.flags|=128}if(S=c.memoizedState,S!==null&&(S.rendering=null,S.tail=null,S.lastEffect=null),Kt(sn,sn.current),v)break;return null;case 22:case 23:return c.lanes=0,Gy(a,c,p)}return ys(a,c,p)}var nb,fh,rb,sb;nb=function(a,c){for(var p=c.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===c)break;for(;p.sibling===null;){if(p.return===null||p.return===c)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},fh=function(){},rb=function(a,c,p,v){var S=a.memoizedProps;if(S!==v){a=c.stateNode,Ri(ts.current);var N=null;switch(p){case"input":S=Ie(a,S),v=Ie(a,v),N=[];break;case"select":S=z({},S,{value:void 0}),v=z({},v,{value:void 0}),N=[];break;case"textarea":S=Ft(a,S),v=Ft(a,v),N=[];break;default:typeof S.onClick!="function"&&typeof v.onClick=="function"&&(a.onclick=ec)}Be(p,v);var j;p=null;for(he in S)if(!v.hasOwnProperty(he)&&S.hasOwnProperty(he)&&S[he]!=null)if(he==="style"){var F=S[he];for(j in F)F.hasOwnProperty(j)&&(p||(p={}),p[j]="")}else he!=="dangerouslySetInnerHTML"&&he!=="children"&&he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&he!=="autoFocus"&&(s.hasOwnProperty(he)?N||(N=[]):(N=N||[]).push(he,null));for(he in v){var X=v[he];if(F=S!=null?S[he]:void 0,v.hasOwnProperty(he)&&X!==F&&(X!=null||F!=null))if(he==="style")if(F){for(j in F)!F.hasOwnProperty(j)||X&&X.hasOwnProperty(j)||(p||(p={}),p[j]="");for(j in X)X.hasOwnProperty(j)&&F[j]!==X[j]&&(p||(p={}),p[j]=X[j])}else p||(N||(N=[]),N.push(he,p)),p=X;else he==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,F=F?F.__html:void 0,X!=null&&F!==X&&(N=N||[]).push(he,X)):he==="children"?typeof X!="string"&&typeof X!="number"||(N=N||[]).push(he,""+X):he!=="suppressContentEditableWarning"&&he!=="suppressHydrationWarning"&&(s.hasOwnProperty(he)?(X!=null&&he==="onScroll"&&Yt("scroll",a),N||F===X||(N=[])):(N=N||[]).push(he,X))}p&&(N=N||[]).push("style",p);var he=N;(c.updateQueue=he)&&(c.flags|=4)}},sb=function(a,c,p,v){p!==v&&(c.flags|=4)};function Ia(a,c){if(!en)switch(a.tailMode){case"hidden":c=a.tail;for(var p=null;c!==null;)c.alternate!==null&&(p=c),c=c.sibling;p===null?a.tail=null:p.sibling=null;break;case"collapsed":p=a.tail;for(var v=null;p!==null;)p.alternate!==null&&(v=p),p=p.sibling;v===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:v.sibling=null}}function Vn(a){var c=a.alternate!==null&&a.alternate.child===a.child,p=0,v=0;if(c)for(var S=a.child;S!==null;)p|=S.lanes|S.childLanes,v|=S.subtreeFlags&14680064,v|=S.flags&14680064,S.return=a,S=S.sibling;else for(S=a.child;S!==null;)p|=S.lanes|S.childLanes,v|=S.subtreeFlags,v|=S.flags,S.return=a,S=S.sibling;return a.subtreeFlags|=v,a.childLanes=p,c}function pM(a,c,p){var v=c.pendingProps;switch(If(c),c.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vn(c),null;case 1:return or(c.type)&&nc(),Vn(c),null;case 3:return v=c.stateNode,Mo(),Xt(ir),Xt(Wn),Kf(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(a===null||a.child===null)&&(ac(c)?c.flags|=4:a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,$r!==null&&(Sh($r),$r=null))),fh(a,c),Vn(c),null;case 5:qf(c);var S=Ri(Ma.current);if(p=c.type,a!==null&&c.stateNode!=null)rb(a,c,p,v,S),a.ref!==c.ref&&(c.flags|=512,c.flags|=2097152);else{if(!v){if(c.stateNode===null)throw Error(n(166));return Vn(c),null}if(a=Ri(ts.current),ac(c)){v=c.stateNode,p=c.type;var N=c.memoizedProps;switch(v[es]=c,v[Ea]=N,a=(c.mode&1)!==0,p){case"dialog":Yt("cancel",v),Yt("close",v);break;case"iframe":case"object":case"embed":Yt("load",v);break;case"video":case"audio":for(S=0;S<wa.length;S++)Yt(wa[S],v);break;case"source":Yt("error",v);break;case"img":case"image":case"link":Yt("error",v),Yt("load",v);break;case"details":Yt("toggle",v);break;case"input":dt(v,N),Yt("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!N.multiple},Yt("invalid",v);break;case"textarea":Je(v,N),Yt("invalid",v)}Be(p,N),S=null;for(var j in N)if(N.hasOwnProperty(j)){var F=N[j];j==="children"?typeof F=="string"?v.textContent!==F&&(N.suppressHydrationWarning!==!0&&Zl(v.textContent,F,a),S=["children",F]):typeof F=="number"&&v.textContent!==""+F&&(N.suppressHydrationWarning!==!0&&Zl(v.textContent,F,a),S=["children",""+F]):s.hasOwnProperty(j)&&F!=null&&j==="onScroll"&&Yt("scroll",v)}switch(p){case"input":Qe(v),xt(v,N,!0);break;case"textarea":Qe(v),pe(v);break;case"select":case"option":break;default:typeof N.onClick=="function"&&(v.onclick=ec)}v=S,c.updateQueue=v,v!==null&&(c.flags|=4)}else{j=S.nodeType===9?S:S.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=G(p)),a==="http://www.w3.org/1999/xhtml"?p==="script"?(a=j.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof v.is=="string"?a=j.createElement(p,{is:v.is}):(a=j.createElement(p),p==="select"&&(j=a,v.multiple?j.multiple=!0:v.size&&(j.size=v.size))):a=j.createElementNS(a,p),a[es]=c,a[Ea]=v,nb(a,c,!1,!1),c.stateNode=a;e:{switch(j=Ee(p,v),p){case"dialog":Yt("cancel",a),Yt("close",a),S=v;break;case"iframe":case"object":case"embed":Yt("load",a),S=v;break;case"video":case"audio":for(S=0;S<wa.length;S++)Yt(wa[S],a);S=v;break;case"source":Yt("error",a),S=v;break;case"img":case"image":case"link":Yt("error",a),Yt("load",a),S=v;break;case"details":Yt("toggle",a),S=v;break;case"input":dt(a,v),S=Ie(a,v),Yt("invalid",a);break;case"option":S=v;break;case"select":a._wrapperState={wasMultiple:!!v.multiple},S=z({},v,{value:void 0}),Yt("invalid",a);break;case"textarea":Je(a,v),S=Ft(a,v),Yt("invalid",a);break;default:S=v}Be(p,S),F=S;for(N in F)if(F.hasOwnProperty(N)){var X=F[N];N==="style"?Ce(a,X):N==="dangerouslySetInnerHTML"?(X=X?X.__html:void 0,X!=null&&Fe(a,X)):N==="children"?typeof X=="string"?(p!=="textarea"||X!=="")&&Me(a,X):typeof X=="number"&&Me(a,""+X):N!=="suppressContentEditableWarning"&&N!=="suppressHydrationWarning"&&N!=="autoFocus"&&(s.hasOwnProperty(N)?X!=null&&N==="onScroll"&&Yt("scroll",a):X!=null&&A(a,N,X,j))}switch(p){case"input":Qe(a),xt(a,v,!1);break;case"textarea":Qe(a),pe(a);break;case"option":v.value!=null&&a.setAttribute("value",""+fe(v.value));break;case"select":a.multiple=!!v.multiple,N=v.value,N!=null?pt(a,!!v.multiple,N,!1):v.defaultValue!=null&&pt(a,!!v.multiple,v.defaultValue,!0);break;default:typeof S.onClick=="function"&&(a.onclick=ec)}switch(p){case"button":case"input":case"select":case"textarea":v=!!v.autoFocus;break e;case"img":v=!0;break e;default:v=!1}}v&&(c.flags|=4)}c.ref!==null&&(c.flags|=512,c.flags|=2097152)}return Vn(c),null;case 6:if(a&&c.stateNode!=null)sb(a,c,a.memoizedProps,v);else{if(typeof v!="string"&&c.stateNode===null)throw Error(n(166));if(p=Ri(Ma.current),Ri(ts.current),ac(c)){if(v=c.stateNode,p=c.memoizedProps,v[es]=c,(N=v.nodeValue!==p)&&(a=mr,a!==null))switch(a.tag){case 3:Zl(v.nodeValue,p,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Zl(v.nodeValue,p,(a.mode&1)!==0)}N&&(c.flags|=4)}else v=(p.nodeType===9?p:p.ownerDocument).createTextNode(v),v[es]=c,c.stateNode=v}return Vn(c),null;case 13:if(Xt(sn),v=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(en&&gr!==null&&(c.mode&1)!==0&&(c.flags&128)===0)ay(),No(),c.flags|=98560,N=!1;else if(N=ac(c),v!==null&&v.dehydrated!==null){if(a===null){if(!N)throw Error(n(318));if(N=c.memoizedState,N=N!==null?N.dehydrated:null,!N)throw Error(n(317));N[es]=c}else No(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;Vn(c),N=!1}else $r!==null&&(Sh($r),$r=null),N=!0;if(!N)return c.flags&65536?c:null}return(c.flags&128)!==0?(c.lanes=p,c):(v=v!==null,v!==(a!==null&&a.memoizedState!==null)&&v&&(c.child.flags|=8192,(c.mode&1)!==0&&(a===null||(sn.current&1)!==0?Cn===0&&(Cn=3):Ch())),c.updateQueue!==null&&(c.flags|=4),Vn(c),null);case 4:return Mo(),fh(a,c),a===null&&ka(c.stateNode.containerInfo),Vn(c),null;case 10:return $f(c.type._context),Vn(c),null;case 17:return or(c.type)&&nc(),Vn(c),null;case 19:if(Xt(sn),N=c.memoizedState,N===null)return Vn(c),null;if(v=(c.flags&128)!==0,j=N.rendering,j===null)if(v)Ia(N,!1);else{if(Cn!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(j=hc(a),j!==null){for(c.flags|=128,Ia(N,!1),v=j.updateQueue,v!==null&&(c.updateQueue=v,c.flags|=4),c.subtreeFlags=0,v=p,p=c.child;p!==null;)N=p,a=v,N.flags&=14680066,j=N.alternate,j===null?(N.childLanes=0,N.lanes=a,N.child=null,N.subtreeFlags=0,N.memoizedProps=null,N.memoizedState=null,N.updateQueue=null,N.dependencies=null,N.stateNode=null):(N.childLanes=j.childLanes,N.lanes=j.lanes,N.child=j.child,N.subtreeFlags=0,N.deletions=null,N.memoizedProps=j.memoizedProps,N.memoizedState=j.memoizedState,N.updateQueue=j.updateQueue,N.type=j.type,a=j.dependencies,N.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),p=p.sibling;return Kt(sn,sn.current&1|2),c.child}a=a.sibling}N.tail!==null&&nn()>Ro&&(c.flags|=128,v=!0,Ia(N,!1),c.lanes=4194304)}else{if(!v)if(a=hc(j),a!==null){if(c.flags|=128,v=!0,p=a.updateQueue,p!==null&&(c.updateQueue=p,c.flags|=4),Ia(N,!0),N.tail===null&&N.tailMode==="hidden"&&!j.alternate&&!en)return Vn(c),null}else 2*nn()-N.renderingStartTime>Ro&&p!==1073741824&&(c.flags|=128,v=!0,Ia(N,!1),c.lanes=4194304);N.isBackwards?(j.sibling=c.child,c.child=j):(p=N.last,p!==null?p.sibling=j:c.child=j,N.last=j)}return N.tail!==null?(c=N.tail,N.rendering=c,N.tail=c.sibling,N.renderingStartTime=nn(),c.sibling=null,p=sn.current,Kt(sn,v?p&1|2:p&1),c):(Vn(c),null);case 22:case 23:return Nh(),v=c.memoizedState!==null,a!==null&&a.memoizedState!==null!==v&&(c.flags|=8192),v&&(c.mode&1)!==0?(vr&1073741824)!==0&&(Vn(c),c.subtreeFlags&6&&(c.flags|=8192)):Vn(c),null;case 24:return null;case 25:return null}throw Error(n(156,c.tag))}function mM(a,c){switch(If(c),c.tag){case 1:return or(c.type)&&nc(),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return Mo(),Xt(ir),Xt(Wn),Kf(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 5:return qf(c),null;case 13:if(Xt(sn),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(n(340));No()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Xt(sn),null;case 4:return Mo(),null;case 10:return $f(c.type._context),null;case 22:case 23:return Nh(),null;case 24:return null;default:return null}}var kc=!1,Kn=!1,gM=typeof WeakSet=="function"?WeakSet:Set,Ve=null;function jo(a,c){var p=a.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(v){un(a,c,v)}else p.current=null}function hh(a,c,p){try{p()}catch(v){un(a,c,v)}}var ib=!1;function vM(a,c){if(Nf=Ul,a=P0(),vf(a)){if("selectionStart"in a)var p={start:a.selectionStart,end:a.selectionEnd};else e:{p=(p=a.ownerDocument)&&p.defaultView||window;var v=p.getSelection&&p.getSelection();if(v&&v.rangeCount!==0){p=v.anchorNode;var S=v.anchorOffset,N=v.focusNode;v=v.focusOffset;try{p.nodeType,N.nodeType}catch{p=null;break e}var j=0,F=-1,X=-1,he=0,Se=0,Ne=a,we=null;t:for(;;){for(var He;Ne!==p||S!==0&&Ne.nodeType!==3||(F=j+S),Ne!==N||v!==0&&Ne.nodeType!==3||(X=j+v),Ne.nodeType===3&&(j+=Ne.nodeValue.length),(He=Ne.firstChild)!==null;)we=Ne,Ne=He;for(;;){if(Ne===a)break t;if(we===p&&++he===S&&(F=j),we===N&&++Se===v&&(X=j),(He=Ne.nextSibling)!==null)break;Ne=we,we=Ne.parentNode}Ne=He}p=F===-1||X===-1?null:{start:F,end:X}}else p=null}p=p||{start:0,end:0}}else p=null;for(Cf={focusedElem:a,selectionRange:p},Ul=!1,Ve=c;Ve!==null;)if(c=Ve,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,Ve=a;else for(;Ve!==null;){c=Ve;try{var Ye=c.alternate;if((c.flags&1024)!==0)switch(c.tag){case 0:case 11:case 15:break;case 1:if(Ye!==null){var Xe=Ye.memoizedProps,yn=Ye.memoizedState,ae=c.stateNode,ee=ae.getSnapshotBeforeUpdate(c.elementType===c.type?Xe:Fr(c.type,Xe),yn);ae.__reactInternalSnapshotBeforeUpdate=ee}break;case 3:var ce=c.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Oe){un(c,c.return,Oe)}if(a=c.sibling,a!==null){a.return=c.return,Ve=a;break}Ve=c.return}return Ye=ib,ib=!1,Ye}function La(a,c,p){var v=c.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var S=v=v.next;do{if((S.tag&a)===a){var N=S.destroy;S.destroy=void 0,N!==void 0&&hh(c,p,N)}S=S.next}while(S!==v)}}function Sc(a,c){if(c=c.updateQueue,c=c!==null?c.lastEffect:null,c!==null){var p=c=c.next;do{if((p.tag&a)===a){var v=p.create;p.destroy=v()}p=p.next}while(p!==c)}}function ph(a){var c=a.ref;if(c!==null){var p=a.stateNode;switch(a.tag){case 5:a=p;break;default:a=p}typeof c=="function"?c(a):c.current=a}}function ob(a){var c=a.alternate;c!==null&&(a.alternate=null,ob(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&(delete c[es],delete c[Ea],delete c[Af],delete c[ZT],delete c[eM])),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 ab(a){return a.tag===5||a.tag===3||a.tag===4}function lb(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||ab(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 mh(a,c,p){var v=a.tag;if(v===5||v===6)a=a.stateNode,c?p.nodeType===8?p.parentNode.insertBefore(a,c):p.insertBefore(a,c):(p.nodeType===8?(c=p.parentNode,c.insertBefore(a,p)):(c=p,c.appendChild(a)),p=p._reactRootContainer,p!=null||c.onclick!==null||(c.onclick=ec));else if(v!==4&&(a=a.child,a!==null))for(mh(a,c,p),a=a.sibling;a!==null;)mh(a,c,p),a=a.sibling}function gh(a,c,p){var v=a.tag;if(v===5||v===6)a=a.stateNode,c?p.insertBefore(a,c):p.appendChild(a);else if(v!==4&&(a=a.child,a!==null))for(gh(a,c,p),a=a.sibling;a!==null;)gh(a,c,p),a=a.sibling}var Dn=null,Ur=!1;function Ks(a,c,p){for(p=p.child;p!==null;)cb(a,c,p),p=p.sibling}function cb(a,c,p){if(_t&&typeof _t.onCommitFiberUnmount=="function")try{_t.onCommitFiberUnmount(kt,p)}catch{}switch(p.tag){case 5:Kn||jo(p,c);case 6:var v=Dn,S=Ur;Dn=null,Ks(a,c,p),Dn=v,Ur=S,Dn!==null&&(Ur?(a=Dn,p=p.stateNode,a.nodeType===8?a.parentNode.removeChild(p):a.removeChild(p)):Dn.removeChild(p.stateNode));break;case 18:Dn!==null&&(Ur?(a=Dn,p=p.stateNode,a.nodeType===8?Mf(a.parentNode,p):a.nodeType===1&&Mf(a,p),ha(a)):Mf(Dn,p.stateNode));break;case 4:v=Dn,S=Ur,Dn=p.stateNode.containerInfo,Ur=!0,Ks(a,c,p),Dn=v,Ur=S;break;case 0:case 11:case 14:case 15:if(!Kn&&(v=p.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){S=v=v.next;do{var N=S,j=N.destroy;N=N.tag,j!==void 0&&((N&2)!==0||(N&4)!==0)&&hh(p,c,j),S=S.next}while(S!==v)}Ks(a,c,p);break;case 1:if(!Kn&&(jo(p,c),v=p.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=p.memoizedProps,v.state=p.memoizedState,v.componentWillUnmount()}catch(F){un(p,c,F)}Ks(a,c,p);break;case 21:Ks(a,c,p);break;case 22:p.mode&1?(Kn=(v=Kn)||p.memoizedState!==null,Ks(a,c,p),Kn=v):Ks(a,c,p);break;default:Ks(a,c,p)}}function ub(a){var c=a.updateQueue;if(c!==null){a.updateQueue=null;var p=a.stateNode;p===null&&(p=a.stateNode=new gM),c.forEach(function(v){var S=CM.bind(null,a,v);p.has(v)||(p.add(v),v.then(S,S))})}}function Hr(a,c){var p=c.deletions;if(p!==null)for(var v=0;v<p.length;v++){var S=p[v];try{var N=a,j=c,F=j;e:for(;F!==null;){switch(F.tag){case 5:Dn=F.stateNode,Ur=!1;break e;case 3:Dn=F.stateNode.containerInfo,Ur=!0;break e;case 4:Dn=F.stateNode.containerInfo,Ur=!0;break e}F=F.return}if(Dn===null)throw Error(n(160));cb(N,j,S),Dn=null,Ur=!1;var X=S.alternate;X!==null&&(X.return=null),S.return=null}catch(he){un(S,c,he)}}if(c.subtreeFlags&12854)for(c=c.child;c!==null;)db(c,a),c=c.sibling}function db(a,c){var p=a.alternate,v=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(Hr(c,a),rs(a),v&4){try{La(3,a,a.return),Sc(3,a)}catch(Xe){un(a,a.return,Xe)}try{La(5,a,a.return)}catch(Xe){un(a,a.return,Xe)}}break;case 1:Hr(c,a),rs(a),v&512&&p!==null&&jo(p,p.return);break;case 5:if(Hr(c,a),rs(a),v&512&&p!==null&&jo(p,p.return),a.flags&32){var S=a.stateNode;try{Me(S,"")}catch(Xe){un(a,a.return,Xe)}}if(v&4&&(S=a.stateNode,S!=null)){var N=a.memoizedProps,j=p!==null?p.memoizedProps:N,F=a.type,X=a.updateQueue;if(a.updateQueue=null,X!==null)try{F==="input"&&N.type==="radio"&&N.name!=null&&Ge(S,N),Ee(F,j);var he=Ee(F,N);for(j=0;j<X.length;j+=2){var Se=X[j],Ne=X[j+1];Se==="style"?Ce(S,Ne):Se==="dangerouslySetInnerHTML"?Fe(S,Ne):Se==="children"?Me(S,Ne):A(S,Se,Ne,he)}switch(F){case"input":bt(S,N);break;case"textarea":Y(S,N);break;case"select":var we=S._wrapperState.wasMultiple;S._wrapperState.wasMultiple=!!N.multiple;var He=N.value;He!=null?pt(S,!!N.multiple,He,!1):we!==!!N.multiple&&(N.defaultValue!=null?pt(S,!!N.multiple,N.defaultValue,!0):pt(S,!!N.multiple,N.multiple?[]:"",!1))}S[Ea]=N}catch(Xe){un(a,a.return,Xe)}}break;case 6:if(Hr(c,a),rs(a),v&4){if(a.stateNode===null)throw Error(n(162));S=a.stateNode,N=a.memoizedProps;try{S.nodeValue=N}catch(Xe){un(a,a.return,Xe)}}break;case 3:if(Hr(c,a),rs(a),v&4&&p!==null&&p.memoizedState.isDehydrated)try{ha(c.containerInfo)}catch(Xe){un(a,a.return,Xe)}break;case 4:Hr(c,a),rs(a);break;case 13:Hr(c,a),rs(a),S=a.child,S.flags&8192&&(N=S.memoizedState!==null,S.stateNode.isHidden=N,!N||S.alternate!==null&&S.alternate.memoizedState!==null||(bh=nn())),v&4&&ub(a);break;case 22:if(Se=p!==null&&p.memoizedState!==null,a.mode&1?(Kn=(he=Kn)||Se,Hr(c,a),Kn=he):Hr(c,a),rs(a),v&8192){if(he=a.memoizedState!==null,(a.stateNode.isHidden=he)&&!Se&&(a.mode&1)!==0)for(Ve=a,Se=a.child;Se!==null;){for(Ne=Ve=Se;Ve!==null;){switch(we=Ve,He=we.child,we.tag){case 0:case 11:case 14:case 15:La(4,we,we.return);break;case 1:jo(we,we.return);var Ye=we.stateNode;if(typeof Ye.componentWillUnmount=="function"){v=we,p=we.return;try{c=v,Ye.props=c.memoizedProps,Ye.state=c.memoizedState,Ye.componentWillUnmount()}catch(Xe){un(v,p,Xe)}}break;case 5:jo(we,we.return);break;case 22:if(we.memoizedState!==null){pb(Ne);continue}}He!==null?(He.return=we,Ve=He):pb(Ne)}Se=Se.sibling}e:for(Se=null,Ne=a;;){if(Ne.tag===5){if(Se===null){Se=Ne;try{S=Ne.stateNode,he?(N=S.style,typeof N.setProperty=="function"?N.setProperty("display","none","important"):N.display="none"):(F=Ne.stateNode,X=Ne.memoizedProps.style,j=X!=null&&X.hasOwnProperty("display")?X.display:null,F.style.display=ye("display",j))}catch(Xe){un(a,a.return,Xe)}}}else if(Ne.tag===6){if(Se===null)try{Ne.stateNode.nodeValue=he?"":Ne.memoizedProps}catch(Xe){un(a,a.return,Xe)}}else if((Ne.tag!==22&&Ne.tag!==23||Ne.memoizedState===null||Ne===a)&&Ne.child!==null){Ne.child.return=Ne,Ne=Ne.child;continue}if(Ne===a)break e;for(;Ne.sibling===null;){if(Ne.return===null||Ne.return===a)break e;Se===Ne&&(Se=null),Ne=Ne.return}Se===Ne&&(Se=null),Ne.sibling.return=Ne.return,Ne=Ne.sibling}}break;case 19:Hr(c,a),rs(a),v&4&&ub(a);break;case 21:break;default:Hr(c,a),rs(a)}}function rs(a){var c=a.flags;if(c&2){try{e:{for(var p=a.return;p!==null;){if(ab(p)){var v=p;break e}p=p.return}throw Error(n(160))}switch(v.tag){case 5:var S=v.stateNode;v.flags&32&&(Me(S,""),v.flags&=-33);var N=lb(a);gh(a,N,S);break;case 3:case 4:var j=v.stateNode.containerInfo,F=lb(a);mh(a,F,j);break;default:throw Error(n(161))}}catch(X){un(a,a.return,X)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function yM(a,c,p){Ve=a,fb(a)}function fb(a,c,p){for(var v=(a.mode&1)!==0;Ve!==null;){var S=Ve,N=S.child;if(S.tag===22&&v){var j=S.memoizedState!==null||kc;if(!j){var F=S.alternate,X=F!==null&&F.memoizedState!==null||Kn;F=kc;var he=Kn;if(kc=j,(Kn=X)&&!he)for(Ve=S;Ve!==null;)j=Ve,X=j.child,j.tag===22&&j.memoizedState!==null?mb(S):X!==null?(X.return=j,Ve=X):mb(S);for(;N!==null;)Ve=N,fb(N),N=N.sibling;Ve=S,kc=F,Kn=he}hb(a)}else(S.subtreeFlags&8772)!==0&&N!==null?(N.return=S,Ve=N):hb(a)}}function hb(a){for(;Ve!==null;){var c=Ve;if((c.flags&8772)!==0){var p=c.alternate;try{if((c.flags&8772)!==0)switch(c.tag){case 0:case 11:case 15:Kn||Sc(5,c);break;case 1:var v=c.stateNode;if(c.flags&4&&!Kn)if(p===null)v.componentDidMount();else{var S=c.elementType===c.type?p.memoizedProps:Fr(c.type,p.memoizedProps);v.componentDidUpdate(S,p.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var N=c.updateQueue;N!==null&&py(c,N,v);break;case 3:var j=c.updateQueue;if(j!==null){if(p=null,c.child!==null)switch(c.child.tag){case 5:p=c.child.stateNode;break;case 1:p=c.child.stateNode}py(c,j,p)}break;case 5:var F=c.stateNode;if(p===null&&c.flags&4){p=F;var X=c.memoizedProps;switch(c.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(c.memoizedState===null){var he=c.alternate;if(he!==null){var Se=he.memoizedState;if(Se!==null){var Ne=Se.dehydrated;Ne!==null&&ha(Ne)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Kn||c.flags&512&&ph(c)}catch(we){un(c,c.return,we)}}if(c===a){Ve=null;break}if(p=c.sibling,p!==null){p.return=c.return,Ve=p;break}Ve=c.return}}function pb(a){for(;Ve!==null;){var c=Ve;if(c===a){Ve=null;break}var p=c.sibling;if(p!==null){p.return=c.return,Ve=p;break}Ve=c.return}}function mb(a){for(;Ve!==null;){var c=Ve;try{switch(c.tag){case 0:case 11:case 15:var p=c.return;try{Sc(4,c)}catch(X){un(c,p,X)}break;case 1:var v=c.stateNode;if(typeof v.componentDidMount=="function"){var S=c.return;try{v.componentDidMount()}catch(X){un(c,S,X)}}var N=c.return;try{ph(c)}catch(X){un(c,N,X)}break;case 5:var j=c.return;try{ph(c)}catch(X){un(c,j,X)}}}catch(X){un(c,c.return,X)}if(c===a){Ve=null;break}var F=c.sibling;if(F!==null){F.return=c.return,Ve=F;break}Ve=c.return}}var bM=Math.ceil,Ec=T.ReactCurrentDispatcher,vh=T.ReactCurrentOwner,_r=T.ReactCurrentBatchConfig,It=0,Mn=null,wn=null,Pn=0,vr=0,Oo=Us(0),Cn=0,Da=null,Li=0,Nc=0,yh=0,Pa=null,lr=null,bh=0,Ro=1/0,bs=null,Cc=!1,xh=null,Gs=null,_c=!1,Js=null,Tc=0,Ba=0,wh=null,Mc=-1,Ac=0;function tr(){return(It&6)!==0?nn():Mc!==-1?Mc:Mc=nn()}function Ys(a){return(a.mode&1)===0?1:(It&2)!==0&&Pn!==0?Pn&-Pn:nM.transition!==null?(Ac===0&&(Ac=zl()),Ac):(a=Rt,a!==0||(a=window.event,a=a===void 0?16:v0(a.type)),a)}function Wr(a,c,p,v){if(50<Ba)throw Ba=0,wh=null,Error(n(185));Ps(a,p,v),((It&2)===0||a!==Mn)&&(a===Mn&&((It&2)===0&&(Nc|=p),Cn===4&&Xs(a,Pn)),cr(a,v),p===1&&It===0&&(c.mode&1)===0&&(Ro=nn()+500,sc&&Ws()))}function cr(a,c){var p=a.callbackNode;rf(a,c);var v=Ni(a,a===Mn?Pn:0);if(v===0)p!==null&&Br(p),a.callbackNode=null,a.callbackPriority=0;else if(c=v&-v,a.callbackPriority!==c){if(p!=null&&Br(p),c===1)a.tag===0?tM(vb.bind(null,a)):ny(vb.bind(null,a)),XT(function(){(It&6)===0&&Ws()}),p=null;else{switch(yt(v)){case 1:p=aa;break;case 4:p=Si;break;case 16:p=uo;break;case 536870912:p=tt;break;default:p=uo}p=Nb(p,gb.bind(null,a))}a.callbackPriority=c,a.callbackNode=p}}function gb(a,c){if(Mc=-1,Ac=0,(It&6)!==0)throw Error(n(327));var p=a.callbackNode;if(Io()&&a.callbackNode!==p)return null;var v=Ni(a,a===Mn?Pn:0);if(v===0)return null;if((v&30)!==0||(v&a.expiredLanes)!==0||c)c=jc(a,v);else{c=v;var S=It;It|=2;var N=bb();(Mn!==a||Pn!==c)&&(bs=null,Ro=nn()+500,Pi(a,c));do try{kM();break}catch(F){yb(a,F)}while(!0);zf(),Ec.current=N,It=S,wn!==null?c=0:(Mn=null,Pn=0,c=Cn)}if(c!==0){if(c===2&&(S=la(a),S!==0&&(v=S,c=kh(a,S))),c===1)throw p=Da,Pi(a,0),Xs(a,v),cr(a,nn()),p;if(c===6)Xs(a,v);else{if(S=a.current.alternate,(v&30)===0&&!xM(S)&&(c=jc(a,v),c===2&&(N=la(a),N!==0&&(v=N,c=kh(a,N))),c===1))throw p=Da,Pi(a,0),Xs(a,v),cr(a,nn()),p;switch(a.finishedWork=S,a.finishedLanes=v,c){case 0:case 1:throw Error(n(345));case 2:Bi(a,lr,bs);break;case 3:if(Xs(a,v),(v&130023424)===v&&(c=bh+500-nn(),10<c)){if(Ni(a,0)!==0)break;if(S=a.suspendedLanes,(S&v)!==v){tr(),a.pingedLanes|=a.suspendedLanes&S;break}a.timeoutHandle=Tf(Bi.bind(null,a,lr,bs),c);break}Bi(a,lr,bs);break;case 4:if(Xs(a,v),(v&4194240)===v)break;for(c=a.eventTimes,S=-1;0<v;){var j=31-rn(v);N=1<<j,j=c[j],j>S&&(S=j),v&=~N}if(v=S,v=nn()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*bM(v/1960))-v,10<v){a.timeoutHandle=Tf(Bi.bind(null,a,lr,bs),v);break}Bi(a,lr,bs);break;case 5:Bi(a,lr,bs);break;default:throw Error(n(329))}}}return cr(a,nn()),a.callbackNode===p?gb.bind(null,a):null}function kh(a,c){var p=Pa;return a.current.memoizedState.isDehydrated&&(Pi(a,c).flags|=256),a=jc(a,c),a!==2&&(c=lr,lr=p,c!==null&&Sh(c)),a}function Sh(a){lr===null?lr=a:lr.push.apply(lr,a)}function xM(a){for(var c=a;;){if(c.flags&16384){var p=c.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var v=0;v<p.length;v++){var S=p[v],N=S.getSnapshot;S=S.value;try{if(!zr(N(),S))return!1}catch{return!1}}}if(p=c.child,c.subtreeFlags&16384&&p!==null)p.return=c,c=p;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function Xs(a,c){for(c&=~yh,c&=~Nc,a.suspendedLanes|=c,a.pingedLanes&=~c,a=a.expirationTimes;0<c;){var p=31-rn(c),v=1<<p;a[p]=-1,c&=~v}}function vb(a){if((It&6)!==0)throw Error(n(327));Io();var c=Ni(a,0);if((c&1)===0)return cr(a,nn()),null;var p=jc(a,c);if(a.tag!==0&&p===2){var v=la(a);v!==0&&(c=v,p=kh(a,v))}if(p===1)throw p=Da,Pi(a,0),Xs(a,c),cr(a,nn()),p;if(p===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=c,Bi(a,lr,bs),cr(a,nn()),null}function Eh(a,c){var p=It;It|=1;try{return a(c)}finally{It=p,It===0&&(Ro=nn()+500,sc&&Ws())}}function Di(a){Js!==null&&Js.tag===0&&(It&6)===0&&Io();var c=It;It|=1;var p=_r.transition,v=Rt;try{if(_r.transition=null,Rt=1,a)return a()}finally{Rt=v,_r.transition=p,It=c,(It&6)===0&&Ws()}}function Nh(){vr=Oo.current,Xt(Oo)}function Pi(a,c){a.finishedWork=null,a.finishedLanes=0;var p=a.timeoutHandle;if(p!==-1&&(a.timeoutHandle=-1,YT(p)),wn!==null)for(p=wn.return;p!==null;){var v=p;switch(If(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&nc();break;case 3:Mo(),Xt(ir),Xt(Wn),Kf();break;case 5:qf(v);break;case 4:Mo();break;case 13:Xt(sn);break;case 19:Xt(sn);break;case 10:$f(v.type._context);break;case 22:case 23:Nh()}p=p.return}if(Mn=a,wn=a=Qs(a.current,null),Pn=vr=c,Cn=0,Da=null,yh=Nc=Li=0,lr=Pa=null,Oi!==null){for(c=0;c<Oi.length;c++)if(p=Oi[c],v=p.interleaved,v!==null){p.interleaved=null;var S=v.next,N=p.pending;if(N!==null){var j=N.next;N.next=S,v.next=j}p.pending=v}Oi=null}return a}function yb(a,c){do{var p=wn;try{if(zf(),pc.current=yc,mc){for(var v=on.memoizedState;v!==null;){var S=v.queue;S!==null&&(S.pending=null),v=v.next}mc=!1}if(Ii=0,Tn=Nn=on=null,Aa=!1,ja=0,vh.current=null,p===null||p.return===null){Cn=1,Da=c,wn=null;break}e:{var N=a,j=p.return,F=p,X=c;if(c=Pn,F.flags|=32768,X!==null&&typeof X=="object"&&typeof X.then=="function"){var he=X,Se=F,Ne=Se.tag;if((Se.mode&1)===0&&(Ne===0||Ne===11||Ne===15)){var we=Se.alternate;we?(Se.updateQueue=we.updateQueue,Se.memoizedState=we.memoizedState,Se.lanes=we.lanes):(Se.updateQueue=null,Se.memoizedState=null)}var He=Hy(j);if(He!==null){He.flags&=-257,Wy(He,j,F,N,c),He.mode&1&&Uy(N,he,c),c=He,X=he;var Ye=c.updateQueue;if(Ye===null){var Xe=new Set;Xe.add(X),c.updateQueue=Xe}else Ye.add(X);break e}else{if((c&1)===0){Uy(N,he,c),Ch();break e}X=Error(n(426))}}else if(en&&F.mode&1){var yn=Hy(j);if(yn!==null){(yn.flags&65536)===0&&(yn.flags|=256),Wy(yn,j,F,N,c),Pf(Ao(X,F));break e}}N=X=Ao(X,F),Cn!==4&&(Cn=2),Pa===null?Pa=[N]:Pa.push(N),N=j;do{switch(N.tag){case 3:N.flags|=65536,c&=-c,N.lanes|=c;var ae=$y(N,X,c);hy(N,ae);break e;case 1:F=X;var ee=N.type,ce=N.stateNode;if((N.flags&128)===0&&(typeof ee.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Gs===null||!Gs.has(ce)))){N.flags|=65536,c&=-c,N.lanes|=c;var Oe=Fy(N,F,c);hy(N,Oe);break e}}N=N.return}while(N!==null)}wb(p)}catch(Ze){c=Ze,wn===p&&p!==null&&(wn=p=p.return);continue}break}while(!0)}function bb(){var a=Ec.current;return Ec.current=yc,a===null?yc:a}function Ch(){(Cn===0||Cn===3||Cn===2)&&(Cn=4),Mn===null||(Li&268435455)===0&&(Nc&268435455)===0||Xs(Mn,Pn)}function jc(a,c){var p=It;It|=2;var v=bb();(Mn!==a||Pn!==c)&&(bs=null,Pi(a,c));do try{wM();break}catch(S){yb(a,S)}while(!0);if(zf(),It=p,Ec.current=v,wn!==null)throw Error(n(261));return Mn=null,Pn=0,Cn}function wM(){for(;wn!==null;)xb(wn)}function kM(){for(;wn!==null&&!Pl();)xb(wn)}function xb(a){var c=Eb(a.alternate,a,vr);a.memoizedProps=a.pendingProps,c===null?wb(a):wn=c,vh.current=null}function wb(a){var c=a;do{var p=c.alternate;if(a=c.return,(c.flags&32768)===0){if(p=pM(p,c,vr),p!==null){wn=p;return}}else{if(p=mM(p,c),p!==null){p.flags&=32767,wn=p;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{Cn=6,wn=null;return}}if(c=c.sibling,c!==null){wn=c;return}wn=c=a}while(c!==null);Cn===0&&(Cn=5)}function Bi(a,c,p){var v=Rt,S=_r.transition;try{_r.transition=null,Rt=1,SM(a,c,p,v)}finally{_r.transition=S,Rt=v}return null}function SM(a,c,p,v){do Io();while(Js!==null);if((It&6)!==0)throw Error(n(327));p=a.finishedWork;var S=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 N=p.lanes|p.childLanes;if(kr(a,N),a===Mn&&(wn=Mn=null,Pn=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||_c||(_c=!0,Nb(uo,function(){return Io(),null})),N=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||N){N=_r.transition,_r.transition=null;var j=Rt;Rt=1;var F=It;It|=4,vh.current=null,vM(a,p),db(p,a),HT(Cf),Ul=!!Nf,Cf=Nf=null,a.current=p,yM(p),Bl(),It=F,Rt=j,_r.transition=N}else a.current=p;if(_c&&(_c=!1,Js=a,Tc=S),N=a.pendingLanes,N===0&&(Gs=null),gn(p.stateNode),cr(a,nn()),c!==null)for(v=a.onRecoverableError,p=0;p<c.length;p++)S=c[p],v(S.value,{componentStack:S.stack,digest:S.digest});if(Cc)throw Cc=!1,a=xh,xh=null,a;return(Tc&1)!==0&&a.tag!==0&&Io(),N=a.pendingLanes,(N&1)!==0?a===wh?Ba++:(Ba=0,wh=a):Ba=0,Ws(),null}function Io(){if(Js!==null){var a=yt(Tc),c=_r.transition,p=Rt;try{if(_r.transition=null,Rt=16>a?16:a,Js===null)var v=!1;else{if(a=Js,Js=null,Tc=0,(It&6)!==0)throw Error(n(331));var S=It;for(It|=4,Ve=a.current;Ve!==null;){var N=Ve,j=N.child;if((Ve.flags&16)!==0){var F=N.deletions;if(F!==null){for(var X=0;X<F.length;X++){var he=F[X];for(Ve=he;Ve!==null;){var Se=Ve;switch(Se.tag){case 0:case 11:case 15:La(8,Se,N)}var Ne=Se.child;if(Ne!==null)Ne.return=Se,Ve=Ne;else for(;Ve!==null;){Se=Ve;var we=Se.sibling,He=Se.return;if(ob(Se),Se===he){Ve=null;break}if(we!==null){we.return=He,Ve=we;break}Ve=He}}}var Ye=N.alternate;if(Ye!==null){var Xe=Ye.child;if(Xe!==null){Ye.child=null;do{var yn=Xe.sibling;Xe.sibling=null,Xe=yn}while(Xe!==null)}}Ve=N}}if((N.subtreeFlags&2064)!==0&&j!==null)j.return=N,Ve=j;else e:for(;Ve!==null;){if(N=Ve,(N.flags&2048)!==0)switch(N.tag){case 0:case 11:case 15:La(9,N,N.return)}var ae=N.sibling;if(ae!==null){ae.return=N.return,Ve=ae;break e}Ve=N.return}}var ee=a.current;for(Ve=ee;Ve!==null;){j=Ve;var ce=j.child;if((j.subtreeFlags&2064)!==0&&ce!==null)ce.return=j,Ve=ce;else e:for(j=ee;Ve!==null;){if(F=Ve,(F.flags&2048)!==0)try{switch(F.tag){case 0:case 11:case 15:Sc(9,F)}}catch(Ze){un(F,F.return,Ze)}if(F===j){Ve=null;break e}var Oe=F.sibling;if(Oe!==null){Oe.return=F.return,Ve=Oe;break e}Ve=F.return}}if(It=S,Ws(),_t&&typeof _t.onPostCommitFiberRoot=="function")try{_t.onPostCommitFiberRoot(kt,a)}catch{}v=!0}return v}finally{Rt=p,_r.transition=c}}return!1}function kb(a,c,p){c=Ao(p,c),c=$y(a,c,1),a=Vs(a,c,1),c=tr(),a!==null&&(Ps(a,1,c),cr(a,c))}function un(a,c,p){if(a.tag===3)kb(a,a,p);else for(;c!==null;){if(c.tag===3){kb(c,a,p);break}else if(c.tag===1){var v=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Gs===null||!Gs.has(v))){a=Ao(p,a),a=Fy(c,a,1),c=Vs(c,a,1),a=tr(),c!==null&&(Ps(c,1,a),cr(c,a));break}}c=c.return}}function EM(a,c,p){var v=a.pingCache;v!==null&&v.delete(c),c=tr(),a.pingedLanes|=a.suspendedLanes&p,Mn===a&&(Pn&p)===p&&(Cn===4||Cn===3&&(Pn&130023424)===Pn&&500>nn()-bh?Pi(a,0):yh|=p),cr(a,c)}function Sb(a,c){c===0&&((a.mode&1)===0?c=1:(c=Ei,Ei<<=1,(Ei&130023424)===0&&(Ei=4194304)));var p=tr();a=gs(a,c),a!==null&&(Ps(a,c,p),cr(a,p))}function NM(a){var c=a.memoizedState,p=0;c!==null&&(p=c.retryLane),Sb(a,p)}function CM(a,c){var p=0;switch(a.tag){case 13:var v=a.stateNode,S=a.memoizedState;S!==null&&(p=S.retryLane);break;case 19:v=a.stateNode;break;default:throw Error(n(314))}v!==null&&v.delete(c),Sb(a,p)}var Eb;Eb=function(a,c,p){if(a!==null)if(a.memoizedProps!==c.pendingProps||ir.current)ar=!0;else{if((a.lanes&p)===0&&(c.flags&128)===0)return ar=!1,hM(a,c,p);ar=(a.flags&131072)!==0}else ar=!1,en&&(c.flags&1048576)!==0&&ry(c,oc,c.index);switch(c.lanes=0,c.tag){case 2:var v=c.type;wc(a,c),a=c.pendingProps;var S=ko(c,Wn.current);To(c,p),S=Yf(null,c,v,a,S,p);var N=Xf();return c.flags|=1,typeof S=="object"&&S!==null&&typeof S.render=="function"&&S.$$typeof===void 0?(c.tag=1,c.memoizedState=null,c.updateQueue=null,or(v)?(N=!0,rc(c)):N=!1,c.memoizedState=S.state!==null&&S.state!==void 0?S.state:null,Hf(c),S.updater=bc,c.stateNode=S,S._reactInternals=c,rh(c,v,a,p),c=ah(null,c,v,!0,N,p)):(c.tag=0,en&&N&&Rf(c),er(null,c,S,p),c=c.child),c;case 16:v=c.elementType;e:{switch(wc(a,c),a=c.pendingProps,S=v._init,v=S(v._payload),c.type=v,S=c.tag=TM(v),a=Fr(v,a),S){case 0:c=oh(null,c,v,a,p);break e;case 1:c=Yy(null,c,v,a,p);break e;case 11:c=qy(null,c,v,a,p);break e;case 14:c=Vy(null,c,v,Fr(v.type,a),p);break e}throw Error(n(306,v,""))}return c;case 0:return v=c.type,S=c.pendingProps,S=c.elementType===v?S:Fr(v,S),oh(a,c,v,S,p);case 1:return v=c.type,S=c.pendingProps,S=c.elementType===v?S:Fr(v,S),Yy(a,c,v,S,p);case 3:e:{if(Xy(c),a===null)throw Error(n(387));v=c.pendingProps,N=c.memoizedState,S=N.element,fy(a,c),fc(c,v,null,p);var j=c.memoizedState;if(v=j.element,N.isDehydrated)if(N={element:v,isDehydrated:!1,cache:j.cache,pendingSuspenseBoundaries:j.pendingSuspenseBoundaries,transitions:j.transitions},c.updateQueue.baseState=N,c.memoizedState=N,c.flags&256){S=Ao(Error(n(423)),c),c=Qy(a,c,v,p,S);break e}else if(v!==S){S=Ao(Error(n(424)),c),c=Qy(a,c,v,p,S);break e}else for(gr=Fs(c.stateNode.containerInfo.firstChild),mr=c,en=!0,$r=null,p=uy(c,null,v,p),c.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(No(),v===S){c=ys(a,c,p);break e}er(a,c,v,p)}c=c.child}return c;case 5:return my(c),a===null&&Df(c),v=c.type,S=c.pendingProps,N=a!==null?a.memoizedProps:null,j=S.children,_f(v,S)?j=null:N!==null&&_f(v,N)&&(c.flags|=32),Jy(a,c),er(a,c,j,p),c.child;case 6:return a===null&&Df(c),null;case 13:return Zy(a,c,p);case 4:return Wf(c,c.stateNode.containerInfo),v=c.pendingProps,a===null?c.child=Co(c,null,v,p):er(a,c,v,p),c.child;case 11:return v=c.type,S=c.pendingProps,S=c.elementType===v?S:Fr(v,S),qy(a,c,v,S,p);case 7:return er(a,c,c.pendingProps,p),c.child;case 8:return er(a,c,c.pendingProps.children,p),c.child;case 12:return er(a,c,c.pendingProps.children,p),c.child;case 10:e:{if(v=c.type._context,S=c.pendingProps,N=c.memoizedProps,j=S.value,Kt(cc,v._currentValue),v._currentValue=j,N!==null)if(zr(N.value,j)){if(N.children===S.children&&!ir.current){c=ys(a,c,p);break e}}else for(N=c.child,N!==null&&(N.return=c);N!==null;){var F=N.dependencies;if(F!==null){j=N.child;for(var X=F.firstContext;X!==null;){if(X.context===v){if(N.tag===1){X=vs(-1,p&-p),X.tag=2;var he=N.updateQueue;if(he!==null){he=he.shared;var Se=he.pending;Se===null?X.next=X:(X.next=Se.next,Se.next=X),he.pending=X}}N.lanes|=p,X=N.alternate,X!==null&&(X.lanes|=p),Ff(N.return,p,c),F.lanes|=p;break}X=X.next}}else if(N.tag===10)j=N.type===c.type?null:N.child;else if(N.tag===18){if(j=N.return,j===null)throw Error(n(341));j.lanes|=p,F=j.alternate,F!==null&&(F.lanes|=p),Ff(j,p,c),j=N.sibling}else j=N.child;if(j!==null)j.return=N;else for(j=N;j!==null;){if(j===c){j=null;break}if(N=j.sibling,N!==null){N.return=j.return,j=N;break}j=j.return}N=j}er(a,c,S.children,p),c=c.child}return c;case 9:return S=c.type,v=c.pendingProps.children,To(c,p),S=Nr(S),v=v(S),c.flags|=1,er(a,c,v,p),c.child;case 14:return v=c.type,S=Fr(v,c.pendingProps),S=Fr(v.type,S),Vy(a,c,v,S,p);case 15:return Ky(a,c,c.type,c.pendingProps,p);case 17:return v=c.type,S=c.pendingProps,S=c.elementType===v?S:Fr(v,S),wc(a,c),c.tag=1,or(v)?(a=!0,rc(c)):a=!1,To(c,p),By(c,v,S),rh(c,v,S,p),ah(null,c,v,!0,a,p);case 19:return tb(a,c,p);case 22:return Gy(a,c,p)}throw Error(n(156,c.tag))};function Nb(a,c){return Is(a,c)}function _M(a,c,p,v){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=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Tr(a,c,p,v){return new _M(a,c,p,v)}function _h(a){return a=a.prototype,!(!a||!a.isReactComponent)}function TM(a){if(typeof a=="function")return _h(a)?1:0;if(a!=null){if(a=a.$$typeof,a===P)return 11;if(a===H)return 14}return 2}function Qs(a,c){var p=a.alternate;return p===null?(p=Tr(a.tag,c,a.key,a.mode),p.elementType=a.elementType,p.type=a.type,p.stateNode=a.stateNode,p.alternate=a,a.alternate=p):(p.pendingProps=c,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,c=a.dependencies,p.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},p.sibling=a.sibling,p.index=a.index,p.ref=a.ref,p}function Oc(a,c,p,v,S,N){var j=2;if(v=a,typeof a=="function")_h(a)&&(j=1);else if(typeof a=="string")j=5;else e:switch(a){case R:return zi(p.children,S,N,c);case B:j=8,S|=8;break;case D:return a=Tr(12,p,c,S|2),a.elementType=D,a.lanes=N,a;case W:return a=Tr(13,p,c,S),a.elementType=W,a.lanes=N,a;case $:return a=Tr(19,p,c,S),a.elementType=$,a.lanes=N,a;case re:return Rc(p,S,N,c);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case U:j=10;break e;case Q:j=9;break e;case P:j=11;break e;case H:j=14;break e;case J:j=16,v=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return c=Tr(j,p,c,S),c.elementType=a,c.type=v,c.lanes=N,c}function zi(a,c,p,v){return a=Tr(7,a,v,c),a.lanes=p,a}function Rc(a,c,p,v){return a=Tr(22,a,v,c),a.elementType=re,a.lanes=p,a.stateNode={isHidden:!1},a}function Th(a,c,p){return a=Tr(6,a,null,c),a.lanes=p,a}function Mh(a,c,p){return c=Tr(4,a.children!==null?a.children:[],a.key,c),c.lanes=p,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}function MM(a,c,p,v,S){this.tag=c,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ds(0),this.expirationTimes=Ds(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ds(0),this.identifierPrefix=v,this.onRecoverableError=S,this.mutableSourceEagerHydrationData=null}function Ah(a,c,p,v,S,N,j,F,X){return a=new MM(a,c,p,F,X),c===1?(c=1,N===!0&&(c|=8)):c=0,N=Tr(3,null,null,c),a.current=N,N.stateNode=a,N.memoizedState={element:v,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hf(N),a}function AM(a,c,p){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:v==null?null:""+v,children:a,containerInfo:c,implementation:p}}function Cb(a){if(!a)return Hs;a=a._reactInternals;e:{if(at(a)!==a||a.tag!==1)throw Error(n(170));var c=a;do{switch(c.tag){case 3:c=c.stateNode.context;break e;case 1:if(or(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break e}}c=c.return}while(c!==null);throw Error(n(171))}if(a.tag===1){var p=a.type;if(or(p))return ey(a,p,c)}return c}function _b(a,c,p,v,S,N,j,F,X){return a=Ah(p,v,!0,a,S,N,j,F,X),a.context=Cb(null),p=a.current,v=tr(),S=Ys(p),N=vs(v,S),N.callback=c??null,Vs(p,N,S),a.current.lanes=S,Ps(a,S,v),cr(a,v),a}function Ic(a,c,p,v){var S=c.current,N=tr(),j=Ys(S);return p=Cb(p),c.context===null?c.context=p:c.pendingContext=p,c=vs(N,j),c.payload={element:a},v=v===void 0?null:v,v!==null&&(c.callback=v),a=Vs(S,c,j),a!==null&&(Wr(a,S,j,N),dc(a,S,j)),j}function Lc(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 Tb(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var p=a.retryLane;a.retryLane=p!==0&&p<c?p:c}}function jh(a,c){Tb(a,c),(a=a.alternate)&&Tb(a,c)}function jM(){return null}var Mb=typeof reportError=="function"?reportError:function(a){console.error(a)};function Oh(a){this._internalRoot=a}Dc.prototype.render=Oh.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(n(409));Ic(a,c,null,null)},Dc.prototype.unmount=Oh.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;Di(function(){Ic(null,a,null,null)}),c[fs]=null}};function Dc(a){this._internalRoot=a}Dc.prototype.unstable_scheduleHydration=function(a){if(a){var c=Ci();a={blockedOn:null,target:a,priority:c};for(var p=0;p<_n.length&&c!==0&&c<_n[p].priority;p++);_n.splice(p,0,a),p===0&&m0(a)}};function Rh(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Pc(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function Ab(){}function OM(a,c,p,v,S){if(S){if(typeof v=="function"){var N=v;v=function(){var he=Lc(j);N.call(he)}}var j=_b(c,v,a,0,null,!1,!1,"",Ab);return a._reactRootContainer=j,a[fs]=j.current,ka(a.nodeType===8?a.parentNode:a),Di(),j}for(;S=a.lastChild;)a.removeChild(S);if(typeof v=="function"){var F=v;v=function(){var he=Lc(X);F.call(he)}}var X=Ah(a,0,!1,null,null,!1,!1,"",Ab);return a._reactRootContainer=X,a[fs]=X.current,ka(a.nodeType===8?a.parentNode:a),Di(function(){Ic(c,X,p,v)}),X}function Bc(a,c,p,v,S){var N=p._reactRootContainer;if(N){var j=N;if(typeof S=="function"){var F=S;S=function(){var X=Lc(j);F.call(X)}}Ic(c,j,a,S)}else j=OM(p,c,a,S,v);return Lc(j)}ua=function(a){switch(a.tag){case 3:var c=a.stateNode;if(c.current.memoizedState.isDehydrated){var p=Ls(c.pendingLanes);p!==0&&(ca(c,p|1),cr(c,nn()),(It&6)===0&&(Ro=nn()+500,Ws()))}break;case 13:Di(function(){var v=gs(a,1);if(v!==null){var S=tr();Wr(v,a,1,S)}}),jh(a,1)}},vn=function(a){if(a.tag===13){var c=gs(a,134217728);if(c!==null){var p=tr();Wr(c,a,134217728,p)}jh(a,134217728)}},Ut=function(a){if(a.tag===13){var c=Ys(a),p=gs(a,c);if(p!==null){var v=tr();Wr(p,a,c,v)}jh(a,c)}},Ci=function(){return Rt},Zr=function(a,c){var p=Rt;try{return Rt=a,c()}finally{Rt=p}},Tt=function(a,c,p){switch(c){case"input":if(bt(a,p),c=p.name,p.type==="radio"&&c!=null){for(p=a;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+c)+'][type="radio"]'),c=0;c<p.length;c++){var v=p[c];if(v!==a&&v.form===a.form){var S=tc(v);if(!S)throw Error(n(90));ot(v),bt(v,S)}}}break;case"textarea":Y(a,p);break;case"select":c=p.value,c!=null&&pt(a,!!p.multiple,c,!1)}},ve=Eh,Ue=Di;var RM={usingClientEntryPoint:!1,Events:[Na,xo,tc,L,te,Eh]},za={findFiberByHostInstance:Ti,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},IM={bundleType:za.bundleType,version:za.version,rendererPackageName:za.rendererPackageName,rendererConfig:za.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=Zt(a),a===null?null:a.stateNode},findFiberByHostInstance:za.findFiberByHostInstance||jM,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 zc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zc.isDisabled&&zc.supportsFiber)try{kt=zc.inject(IM),_t=zc}catch{}}return ur.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=RM,ur.createPortal=function(a,c){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Rh(c))throw Error(n(200));return AM(a,c,null,p)},ur.createRoot=function(a,c){if(!Rh(a))throw Error(n(299));var p=!1,v="",S=Mb;return c!=null&&(c.unstable_strictMode===!0&&(p=!0),c.identifierPrefix!==void 0&&(v=c.identifierPrefix),c.onRecoverableError!==void 0&&(S=c.onRecoverableError)),c=Ah(a,1,!1,null,null,p,!1,v,S),a[fs]=c.current,ka(a.nodeType===8?a.parentNode:a),new Oh(c)},ur.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=Zt(c),a=a===null?null:a.stateNode,a},ur.flushSync=function(a){return Di(a)},ur.hydrate=function(a,c,p){if(!Pc(c))throw Error(n(200));return Bc(null,a,c,!0,p)},ur.hydrateRoot=function(a,c,p){if(!Rh(a))throw Error(n(405));var v=p!=null&&p.hydratedSources||null,S=!1,N="",j=Mb;if(p!=null&&(p.unstable_strictMode===!0&&(S=!0),p.identifierPrefix!==void 0&&(N=p.identifierPrefix),p.onRecoverableError!==void 0&&(j=p.onRecoverableError)),c=_b(c,null,a,1,p??null,S,!1,N,j),a[fs]=c.current,ka(a),v)for(a=0;a<v.length;a++)p=v[a],S=p._getVersion,S=S(p._source),c.mutableSourceEagerHydrationData==null?c.mutableSourceEagerHydrationData=[p,S]:c.mutableSourceEagerHydrationData.push(p,S);return new Dc(c)},ur.render=function(a,c,p){if(!Pc(c))throw Error(n(200));return Bc(null,a,c,!1,p)},ur.unmountComponentAtNode=function(a){if(!Pc(a))throw Error(n(40));return a._reactRootContainer?(Di(function(){Bc(null,null,a,!1,function(){a._reactRootContainer=null,a[fs]=null})}),!0):!1},ur.unstable_batchedUpdates=Eh,ur.unstable_renderSubtreeIntoContainer=function(a,c,p,v){if(!Pc(p))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Bc(a,c,p,!1,v)},ur.version="18.3.1-next-f1338f8080-20240426",ur}var zb;function oE(){if(zb)return Dh.exports;zb=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(),Dh.exports=FM(),Dh.exports}var $b;function UM(){if($b)return $c;$b=1;var t=oE();return $c.createRoot=t.createRoot,$c.hydrateRoot=t.hydrateRoot,$c}var HM=UM();const WM=El(HM),aE=[{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"}],lE=[{id:"files",label:"Files",icon:"files"},{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"}],cE=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],uE=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],qM=["full","compact","minimal"],$n={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"},VM={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function KM(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem($n.typeface)){const n=VM[t];n&&localStorage.setItem($n.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem($n.spacing)&&(localStorage.setItem($n.spacing,e),localStorage.removeItem("ow-typography"))}function dE(){const t=localStorage.getItem($n.typeface);return t&&aE.some(e=>e.id===t)?t:"charter"}function fE(){const t=localStorage.getItem($n.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Cd(){const t=localStorage.getItem($n.sidebarMode);return t&&lE.some(e=>e.id===t)?t:"files"}function hE(){return"cards"}function pE(){const t=localStorage.getItem($n.sidebarDensity);return t&&qM.includes(t)?t:"full"}function GM(t){localStorage.setItem($n.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function mE(){const t=localStorage.getItem($n.spacing);return t&&uE.some(e=>e.id===t)?t:"default"}function gE(){const t=localStorage.getItem($n.canvas);return t&&cE.some(e=>e.id===t)?t:"seamless"}function vE(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($n.typeface,t),localStorage.setItem($n.mode,e),localStorage.setItem($n.sidebarMode,n),localStorage.setItem($n.sidebarStyle,r),localStorage.setItem($n.spacing,s),localStorage.setItem($n.canvas,i)}function JM(){KM(),vE(dE(),fE(),Cd(),hE(),mE(),gE()),document.documentElement.setAttribute("data-sidebar-density",pE())}var yE=oE();const YM=El(yE);var zh={exports:{}},$h={};/**
|
|
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 Fb;function XM(){if(Fb)return $h;Fb=1;var t=Nl();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(m,g){var y=g(),b=r({inst:{value:y,getSnapshot:g}}),x=b[0].inst,w=b[1];return i(function(){x.value=y,x.getSnapshot=g,d(x)&&w({inst:x})},[m,y,g]),s(function(){return d(x)&&w({inst:x}),m(function(){d(x)&&w({inst:x})})},[m]),o(y),y}function d(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return $h.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,$h}var Ub;function bE(){return Ub||(Ub=1,zh.exports=XM()),zh.exports}var xE=bE();function zn(t){this.content=t}zn.prototype={constructor:zn,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 zn(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 zn(n)},addToStart:function(t,e){return new zn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new zn(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 zn(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=zn.from(t),t.size?new zn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=zn.from(t),t.size?new zn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=zn.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}};zn.from=function(t){if(t instanceof zn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new zn(e)};function wE(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=wE(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 be{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 be(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 be(r,s)}cutByIndex(e,n){return e==n?be.empty:e==0&&n==this.content.length?this:new be(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 be(s,i)}addToStart(e){return new be([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new be(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 wE(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return kE(this,e,n,r)}findIndex(e){if(e==0)return Fc(0,e);if(e==this.size)return Fc(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?Fc(n+1,i):Fc(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 be.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new be(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return be.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 be(n||e,r)}static from(e){if(!e)return be.empty;if(e instanceof be)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new be([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}be.empty=new be([],0);const Fh={index:0,offset:0};function Fc(t,e){return Fh.index=t,Fh.offset=e,Fh}function Tu(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(!Tu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Tu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Vt=class sg{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&&Tu(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 sg.none;if(e instanceof sg)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Vt.none=[];class Mu extends Error{}class Pe{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=EE(this.content,e+this.openStart,n);return r&&new Pe(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Pe(SE(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 Pe.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 Pe(be.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 Pe(e,r,s)}}Pe.empty=new Pe(be.empty,0,0);function SE(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(SE(i.content,e-s-1,n-s-1)))}function EE(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=EE(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function QM(t,e,n){if(n.openStart>t.depth)throw new Mu("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Mu("Inconsistent open depths");return NE(t,e,n,0)}function NE(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=NE(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 Gi(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ZM(n,t);return Gi(i,_E(t,o,l,e,r))}else return Gi(i,Au(t,e,r))}function CE(t,e){if(!e.type.compatibleContent(t.type))throw new Mu("Cannot join "+e.type.name+" onto "+t.type.name)}function ig(t,e,n){let r=t.node(n);return CE(r,e.node(n)),r}function Ki(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function el(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ki(t.nodeAfter,r),i++));for(let l=i;l<o;l++)Ki(s.child(l),r);e&&e.depth==n&&e.textOffset&&Ki(e.nodeBefore,r)}function Gi(t,e){return t.type.checkContent(e),t.copy(e)}function _E(t,e,n,r,s){let i=t.depth>s&&ig(t,e,s+1),o=r.depth>s&&ig(n,r,s+1),l=[];return el(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(CE(i,o),Ki(Gi(i,_E(t,e,n,r,s+1)),l)):(i&&Ki(Gi(i,Au(t,e,s+1)),l),el(e,n,s,l),o&&Ki(Gi(o,Au(n,r,s+1)),l)),el(r,null,s,l),new be(l)}function Au(t,e,n){let r=[];if(el(null,t,n,r),t.depth>n){let s=ig(t,e,n+1);Ki(Gi(s,Au(t,e,n+1)),r)}return el(e,null,n,r),new be(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(be.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class dl{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 Vt.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 ju(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 dl(n,r,i)}static resolveCached(e,n){let r=Hb.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 Hb.set(e,r=new eA);let s=r.elts[r.i]=dl.resolve(e,n);return r.i=(r.i+1)%tA,s}}class eA{constructor(){this.elts=[],this.i=0}}const tA=12,Hb=new WeakMap;class ju{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 nA=Object.create(null);class Kr{constructor(e,n,r,s=Vt.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||be.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&&Tu(this.attrs,n||e.defaultAttrs||nA)&&Vt.sameSet(this.marks,r||Vt.none)}copy(e=null){return e==this.content?this:new Kr(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Kr(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 Pe.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 Pe(f,s.depth-o,i.depth-o)}replace(e,n,r){return QM(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 dl.resolveCached(this,e)}resolveNoCache(e){return dl.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()+")"),TE(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=be.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=Vt.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(!Vt.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=be.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Kr.prototype.text=void 0;class Ou extends Kr{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):TE(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 Ou(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ou(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 TE(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Qi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new rA(e,n);if(r.next==null)return Qi.empty;let s=ME(r);r.next&&r.err("Unexpected trailing text");let i=uA(cA(s));return dA(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 be.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
|
-
`)}}Qi.empty=new Qi(!0);class rA{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 ME(t){let e=[];do e.push(sA(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function sA(t){let e=[];do e.push(iA(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function iA(t){let e=lA(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=oA(t,e);else break;return e}function Wb(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function oA(t,e){let n=Wb(t),r=n;return t.eat(",")&&(t.next!="}"?r=Wb(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function aA(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 lA(t){if(t.eat("(")){let e=ME(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=aA(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 cA(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 AE(t,e){return e-t}function qb(t,e){let n=[];return r(e),n.sort(AE);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 uA(t){let e=Object.create(null);return n(qb(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]);qb(t,d).forEach(h=>{f||s.push([l,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let i=e[r.join(",")]=new Qi(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(AE);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function dA(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 jE(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 OE(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 RE(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 IE(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new hA(t,r,e[r]);return n}let Vb=class LE{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=IE(e,r.attrs),this.defaultAttrs=jE(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==Qi.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:OE(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Kr(this,this.computeAttrs(e),be.from(n),Vt.setFrom(r))}createChecked(e=null,n,r){return n=be.from(n),this.checkContent(n),new Kr(this,this.computeAttrs(e),n,Vt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=be.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(be.empty,!0);return i?new Kr(this,e,n.append(i),Vt.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){RE(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:Vt.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new LE(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 fA(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 hA{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?fA(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class _d{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=IE(e,s.attrs),this.excluded=null;let i=jE(this.attrs);this.instance=i?new Vt(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Vt(this,OE(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new _d(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){RE(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class DE{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=zn.from(e.nodes),n.marks=zn.from(e.marks||{}),this.nodes=Vb.compile(this.spec.nodes,this),this.marks=_d.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]=Qi.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?Kb(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==""?[]:Kb(this,o.split(" "))}this.nodeFromJSON=s=>Kr.fromJSON(this,s),this.markFromJSON=s=>Vt.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 Vb){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 Ou(r,r.defaultAttrs,e,Vt.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 Kb(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 pA(t){return t.tag!=null}function mA(t){return t.style!=null}let tl=class og{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(pA(s))this.tags.push(s);else if(mA(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 Jb(this,n,!1);return r.addAll(e,Vt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Jb(this,n,!0);return r.addAll(e,Vt.none,n.from,n.to),Pe.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(yA(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=Yb(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=Yb(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new og(e,og.schemaRules(e)))}};const PE={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},gA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},BE={ol:!0,ul:!0},fl=1,ag=2,nl=4;function Gb(t,e,n){return e!=null?(e?fl:0)|(e==="full"?ag:0):t&&t.whitespace=="pre"?fl|ag:n&~nl}class Uc{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=Vt.none,this.match=i||(o&nl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(be.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&fl)){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=be.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(be.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&&!PE.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Jb{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=Gb(null,n.preserveWhitespace,0)|(r?nl:0);s?i=new Uc(s.type,s.attrs,Vt.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Uc(null,null,Vt.none,!0,null,o):i=new Uc(e.schema.topNodeType,null,Vt.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&ag?"full":this.localPreserveWS||(s.options&fl)>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;BE.hasOwnProperty(o)&&this.parser.normalizeLists&&vA(e);let d=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(d?d.ignore:gA.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(PE.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=Vt.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Xb(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=Gb(e,i,o.options);o.options&nl&&o.content.length==0&&(l|=nl);let d=Vt.none;return r=r.filter(f=>(o.type?o.type.allowsMarkType(f.type):Xb(f.type,e))?(d=f.addToSet(d),!1):!0),this.nodes.push(new Uc(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|=fl)}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 vA(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&BE.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function yA(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Yb(t){let e={};for(let n in t)e[n]=t[n];return e}function Xb(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 io{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Uh(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}=bu(Uh(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&&bu(Uh(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return bu(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new io(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Qb(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Qb(e.marks)}}function Qb(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Uh(t){return t.document||window.document}const Zb=new WeakMap;function bA(t){let e=Zb.get(t);return e===void 0&&Zb.set(t,e=xA(t)),e}function xA(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 bu(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=bA(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:y,contentDOM:b}=bu(t,g,n,r);if(d.appendChild(y),b){if(l)throw new RangeError("Multiple content holes");l=b}}}return{dom:d,contentDOM:l}}const zE=65535,$E=Math.pow(2,16);function wA(t,e){return t+e*$E}function ex(t){return t&zE}function kA(t){return(t-(t&zE))/$E}const FE=1,UE=2,xu=4,HE=8;class lg{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&HE)>0}get deletedBefore(){return(this.delInfo&(FE|xu))>0}get deletedAfter(){return(this.delInfo&(UE|xu))>0}get deletedAcross(){return(this.delInfo&xu)>0}}class yr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&yr.empty)return yr.empty}recover(e){let n=0,r=ex(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+kA(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,y=d+s+(g<0?0:h);if(r)return y;let b=e==(n<0?d:m)?null:wA(l/3,e-d),x=e==d?UE:e==m?FE:xu;return(n<0?e!=d:e!=m)&&(x|=HE),new lg(y,x,b)}s+=h-f}return r?e+s:new lg(e+s,0,null)}touches(e,n){let r=0,s=ex(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 yr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?yr.empty:new yr(e<0?[0,-e,0]:[0,0,e])}}yr.empty=new yr([]);class hl{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 hl(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 hl;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 lg(e,s,null)}}const Hh=Object.create(null);class Xn{getMap(){return yr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Hh[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 Hh)throw new RangeError("Duplicate use of step JSON ID "+e);return Hh[e]=n,n.prototype.jsonID=e,n}}class kn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new kn(e,null)}static fail(e){return new kn(null,e)}static fromReplace(e,n,r,s){try{return kn.ok(e.replace(n,r,s))}catch(i){if(i instanceof Mu)return kn.fail(i.message);throw i}}}function Wg(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Wg(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return be.fromArray(r)}class li extends Xn{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 Pe(Wg(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 kn.fromReplace(e,this.from,this.to,i)}invert(){return new Vr(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 li(n.pos,r.pos,this.mark)}merge(e){return e instanceof li&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new li(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 li(n.from,n.to,e.markFromJSON(n.mark))}}Xn.jsonID("addMark",li);class Vr extends Xn{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 Pe(Wg(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return kn.fromReplace(e,this.from,this.to,r)}invert(){return new li(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 Vr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Vr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Vr(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 Vr(n.from,n.to,e.markFromJSON(n.mark))}}Xn.jsonID("removeMark",Vr);class ci extends Xn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return kn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return kn.fromReplace(e,this.pos,this.pos+1,new Pe(be.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 ci(this.pos,n.marks[s]);return new ci(this.pos,this.mark)}}return new Zi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ci(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 ci(n.pos,e.markFromJSON(n.mark))}}Xn.jsonID("addNodeMark",ci);class Zi extends Xn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return kn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return kn.fromReplace(e,this.pos,this.pos+1,new Pe(be.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ci(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Zi(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 Zi(n.pos,e.markFromJSON(n.mark))}}Xn.jsonID("removeNodeMark",Zi);class jn extends Xn{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&cg(e,this.from,this.to)?kn.fail("Structure replace would overwrite content"):kn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new yr([this.from,this.to-this.from,this.slice.size])}invert(e){return new jn(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 jn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof jn)||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?Pe.empty:new Pe(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new jn(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?Pe.empty:new Pe(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new jn(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 jn(n.from,n.to,Pe.fromJSON(e,n.slice),!!n.structure)}}Xn.jsonID("replace",jn);class On extends Xn{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&&(cg(e,this.from,this.gapFrom)||cg(e,this.gapTo,this.to)))return kn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return kn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?kn.fromReplace(e,this.from,this.to,r):kn.fail("Content does not fit in gap")}getMap(){return new yr([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 On(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 On(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 On(n.from,n.to,n.gapFrom,n.gapTo,Pe.fromJSON(e,n.slice),n.insert,!!n.structure)}}Xn.jsonID("replaceAround",On);function cg(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 SA(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),y=Math.min(f+d.nodeSize,n),b=r.addToSet(m);for(let x=0;x<m.length;x++)m[x].isInSet(b)||(o&&o.to==g&&o.mark.eq(m[x])?o.to=y:s.push(o=new Vr(g,y,m[x])));l&&l.to==g?l.to=y:i.push(l=new li(g,y,r))}}),s.forEach(d=>t.step(d)),i.forEach(d=>t.step(d))}function EA(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 _d){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 y=0;y<s.length;y++){let b=s[y];b.step==i-1&&m.eq(s[y].style)&&(g=b)}g?(g.to=f,g.step=i):s.push({style:m,from:Math.max(l,e),to:f,step:i})}}}),s.forEach(o=>t.step(new Vr(o.from,o.to,o.style)))}function qg(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 jn(l,h,Pe.empty));else{r=m;for(let g=0;g<f.marks.length;g++)n.allowsMarkType(f.marks[g].type)||t.step(new Vr(l,h,f.marks[g]));if(s&&f.isText&&n.whitespace!="pre"){let g,y=/\r?\n|\r/g,b;for(;g=y.exec(f.text);)b||(b=new Pe(be.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),o.push(new jn(l+g.index,l+g.index+g[0].length,b))}}l=h}if(!r.validEnd){let d=r.fillBefore(be.empty,!0);t.replace(l,l,new Pe(d,0,0))}for(let d=o.length-1;d>=0;d--)t.step(o[d])}function NA(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function sa(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||!NA(o,l,d))break;l&&(s=1),d<o.childCount&&(i=1)}return null}function CA(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=be.empty,m=0;for(let b=i,x=!1;b>n;b--)x||r.index(b)>0?(x=!0,h=be.from(r.node(b).copy(h)),m++):d--;let g=be.empty,y=0;for(let b=i,x=!1;b>n;b--)x||s.after(b+1)<s.end(b)?(x=!0,g=be.from(s.node(b).copy(g)),y++):f++;t.step(new On(d,f,o,l,new Pe(h.append(g),m,y),h.size-m,!0))}function Vg(t,e,n=null,r=t){let s=_A(t,e),i=s&&TA(r,e);return i?s.map(tx).concat({type:e,attrs:n}).concat(i.map(tx)):null}function tx(t){return{type:t,attrs:null}}function _A(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 TA(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 MA(t,e,n){let r=be.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=be.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new On(s,i,s,i,new Pe(r,0,0),n.length,!0))}function AA(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)&&jA(t.doc,t.mapping.slice(i).map(l),r)){let f=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!b?f=!1:!y&&b&&(f=!0)}f===!1&&qE(t,o,l,i),qg(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 On(m,g,m+1,g-1,new Pe(be.from(r.create(d,null,o.marks)),0,0),1,!0)),f===!0&&WE(t,o,l,i),!1}})}function WE(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 qE(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 jA(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function OA(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 On(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Pe(be.from(o),0,0),1,!0))}function Ms(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 y=m.content.cutByIndex(g,m.childCount),b=r&&r[h+1];b&&(y=y.replaceChild(0,b.type.create(b.attrs)));let x=r&&r[h]||m;if(!m.canReplace(g+1,m.childCount)||!x.type.validContent(y))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 RA(t,e,n=1,r){let s=t.doc.resolve(e),i=be.empty,o=be.empty;for(let l=s.depth,d=s.depth-n,f=n-1;l>d;l--,f--){i=be.from(s.node(l).copy(i));let h=r&&r[f];o=be.from(h?h.type.create(h.attrs,o):s.node(l).copy(o))}t.step(new jn(e,e,new Pe(i.append(o),n,n),!0))}function yi(t,e){let n=t.resolve(e),r=n.index();return VE(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function IA(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 VE(t,e){return!!(t&&e&&!t.isLeaf&&IA(t,e))}function Td(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&&VE(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 LA(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);qE(t,h.node(),h.before(),l)}o.inlineContent&&qg(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 jn(f,d.map(e+n,-1),Pe.empty,!0)),r===!0){let h=t.doc.resolve(f);WE(t,h.node(),h.before(),t.steps.length)}return t}function DA(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 KE(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 Md(t,e,n=e,r=Pe.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return GE(s,i,r)?new jn(e,n,r):new PA(s,i,r).fit()}function GE(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class PA{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=be.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=be.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 Pe(i,o,l);return e>-1?new On(r.pos,e,this.$to.pos,this.$to.end(),d,n):d.size||r.pos!=this.$to.pos?new jn(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=Wh(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(be.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=Wh(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Pe(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=Wh(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Pe(Ka(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Pe(Ka(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 x=0;x<i.length;x++)this.openFrontierNode(i[x]);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 x=0;x<s.childCount;x++)h.push(s.child(x));m=m.matchFragment(s)}let y=l.size+e-(o.content.size-o.openEnd);for(;f<l.childCount;){let x=l.child(f),w=m.matchType(x.type);if(!w)break;f++,(f>1||d==0||x.content.size)&&(m=w,h.push(JE(x.mark(g.allowedMarks(x.marks)),f==1?d:0,f==l.childCount?y:-1)))}let b=f==l.childCount;b||(y=-1),this.placed=Ga(this.placed,n,be.from(h)),this.frontier[n].match=m,b&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let x=0,w=l;x<y;x++){let E=w.lastChild;this.frontier.push({type:E.type,match:E.contentMatchAt(E.childCount)}),w=E.content}this.unplaced=b?e==0?Pe.empty:new Pe(Ka(o.content,e-1,1),e-1,y<0?o.openEnd:e-1):new Pe(Ka(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||!qh(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=qh(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:d,type:f}=this.frontier[l],h=qh(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=Ga(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=Ga(this.placed,this.depth,be.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(be.empty,!0);n.childCount&&(this.placed=Ga(this.placed,this.frontier.length,n))}}function Ka(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ka(t.firstChild.content,e-1,n)))}function Ga(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ga(t.lastChild.content,e-1,n)))}function Wh(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function JE(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,JE(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(be.empty,!0)))),t.copy(r)}function qh(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&&!BA(n,i.content,o)?l:null}function BA(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function zA(t){return t.spec.defining||t.spec.definingForContent}function $A(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(GE(s,i,r))return t.step(new jn(e,n,r));let o=XE(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let g=s.depth,y=s.pos-1;g>0;g--,y--){let b=s.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(g)>-1?l=g:s.before(g)==y&&o.splice(1,0,-g)}let d=o.indexOf(l),f=[],h=r.openStart;for(let g=r.content,y=0;;y++){let b=g.firstChild;if(f.push(b),y==r.openStart)break;g=b.content}for(let g=h-1;g>=0;g--){let y=f[g],b=zA(y.type);if(b&&!y.sameMarkup(s.node(Math.abs(l)-1)))h=g;else if(b||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+h+1)%(r.openStart+1),b=f[y];if(b)for(let x=0;x<o.length;x++){let w=o[(x+d)%o.length],E=!0;w<0&&(E=!1,w=-w);let C=s.node(w-1),A=s.index(w-1);if(C.canReplaceWith(A,A,b.type,b.marks))return t.replace(s.before(w),E?i.after(w):n,new Pe(YE(r.content,0,r.openStart,y),y,r.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=s.before(y),n=i.after(y))}}function YE(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(YE(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(be.empty,!0))}return t}function FA(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=DA(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Pe(be.from(r),0,0))}function UA(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=XE(r,s);for(let o=0;o<i.length;o++){let l=i[o],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 XE(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class Ko extends Xn{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 kn.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 kn.fromReplace(e,this.pos,this.pos+1,new Pe(be.from(s),0,n.isLeaf?0:1))}getMap(){return yr.empty}invert(e){return new Ko(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 Ko(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 Ko(n.pos,n.attr,n.value)}}Xn.jsonID("attr",Ko);class pl extends Xn{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 kn.ok(r)}getMap(){return yr.empty}invert(e){return new pl(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new pl(n.attr,n.value)}}Xn.jsonID("docAttr",pl);let Yo=class extends Error{};Yo=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Yo.prototype=Object.create(Error.prototype);Yo.prototype.constructor=Yo;Yo.prototype.name="TransformError";class Kg{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new hl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Yo(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=Pe.empty){let s=Md(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Pe(be.from(r),0,0))}delete(e,n){return this.replace(e,n,Pe.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return $A(this,e,n,r),this}replaceRangeWith(e,n,r){return FA(this,e,n,r),this}deleteRange(e,n){return UA(this,e,n),this}lift(e,n){return CA(this,e,n),this}join(e,n=1){return LA(this,e,n),this}wrap(e,n){return MA(this,e,n),this}setBlockType(e,n=e,r,s=null){return AA(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return OA(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Ko(e,n,r)),this}setDocAttribute(e,n){return this.step(new pl(e,n)),this}addNodeMark(e,n){return this.step(new ci(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 Vt)n.isInSet(r.marks)&&this.step(new Zi(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Zi(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 RA(this,e,n,r),this}addMark(e,n,r){return SA(this,e,n,r),this}removeMark(e,n,r){return EA(this,e,n,r),this}clearIncompatible(e,n,r){return qg(this,e,n,r),this}}const Vh=Object.create(null);class ht{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new QE(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=Pe.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?Pe.empty:n),l==0&&sx(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),sx(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new it(e):zo(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?zo(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):zo(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 xr(e.node(0))}static atStart(e){return zo(e,e,0,0,1)||new xr(e)}static atEnd(e){return zo(e,e,e.content.size,e.childCount,-1)||new xr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Vh[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 Vh)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vh[e]=n,n.prototype.jsonID=e,n}getBookmark(){return it.between(this.$anchor,this.$head).getBookmark()}}ht.prototype.visible=!0;class QE{constructor(e,n){this.$from=e,this.$to=n}}let nx=!1;function rx(t){!nx&&!t.parent.inlineContent&&(nx=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class it extends ht{constructor(e,n=e){rx(e),rx(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 ht.near(r);let s=e.resolve(n.map(this.anchor));return new it(s.parent.inlineContent?s:r,r)}replace(e,n=Pe.empty){if(super.replace(e,n),n==Pe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof it&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ad(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 it(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=ht.findFrom(n,r,!0)||ht.findFrom(n,-r,!0);if(i)n=i.$head;else return ht.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ht.findFrom(e,-r,!0)||ht.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new it(e,n)}}ht.jsonID("text",it);class Ad{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ad(e.map(this.anchor),e.map(this.head))}resolve(e){return it.between(e.resolve(this.anchor),e.resolve(this.head))}}class rt extends ht{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?ht.near(i):new rt(i)}content(){return new Pe(be.from(this.node),0,0)}eq(e){return e instanceof rt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Gg(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new rt(e.resolve(n.anchor))}static create(e,n){return new rt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}rt.prototype.visible=!1;ht.jsonID("node",rt);class Gg{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Ad(r,r):new Gg(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&rt.isSelectable(r)?new rt(n):ht.near(n)}}class xr extends ht{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Pe.empty){if(n==Pe.empty){e.delete(0,e.doc.content.size);let r=ht.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new xr(e)}map(e){return new xr(e)}eq(e){return e instanceof xr}getBookmark(){return HA}}ht.jsonID("all",xr);const HA={map(){return this},resolve(t){return new xr(t)}};function zo(t,e,n,r,s,i=!1){if(e.inlineContent)return it.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&&rt.isSelectable(l))return rt.create(t,n-(s<0?l.nodeSize:0))}else{let d=zo(t,l,n+s,s<0?l.childCount:0,s,i);if(d)return d}n+=l.nodeSize*s}return null}function sx(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof jn||s instanceof On))return;let i=t.mapping.maps[r],o;i.forEach((l,d,f,h)=>{o==null&&(o=h)}),t.setSelection(ht.near(t.doc.resolve(o),n))}const ix=1,Hc=2,ox=4;class WA extends Kg{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|ix)&~Hc,this.storedMarks=null,this}get selectionSet(){return(this.updated&ix)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hc,this}ensureMarks(e){return Vt.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&Hc)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Hc,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)||Vt.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(ht.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|=ox,this}get scrolledIntoView(){return(this.updated&ox)>0}}function ax(t,e){return!e||!t?t:t.bind(e)}class Ja{constructor(e,n,r){this.name=e,this.init=ax(n.init,r),this.apply=ax(n.apply,r)}}const qA=[new Ja("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ja("selection",{init(t,e){return t.selection||ht.atStart(e.doc)},apply(t){return t.selection}}),new Ja("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ja("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Kh{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=qA.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 Ja(r.key,r.spec.state,r))})}}class Wo{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 Wo(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 WA(this)}static create(e){let n=new Kh(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Wo(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 Kh(this.schema,e.plugins),r=n.fields,s=new Wo(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 Kh(e.schema,e.plugins),i=new Wo(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Kr.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ht.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 ZE(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=ZE(s,e,{})),n[r]=s}return n}class Pt{constructor(e){this.spec=e,this.props={},e.props&&ZE(e.props,this,this.props),this.key=e.key?e.key.key:eN("plugin")}getState(e){return e[this.key]}}const Gh=Object.create(null);function eN(t){return t in Gh?t+"$"+ ++Gh[t]:(Gh[t]=0,t+"$")}class Ht{constructor(e="key"){this.key=eN(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Jg=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function tN(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const nN=(t,e,n)=>{let r=tN(t,n);if(!r)return!1;let s=Yg(r);if(!s){let o=r.blockRange(),l=o&&sa(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&&(Xo(i,"end")||rt.isSelectable(i)))for(let o=r.depth;;o--){let l=Md(t.doc,r.before(o),r.after(o),Pe.empty);if(l&&l.slice.size<l.to-l.from){if(e){let d=t.tr.step(l);d.setSelection(Xo(i,"end")?ht.findFrom(d.doc.resolve(d.mapping.map(s.pos,-1)),-1):rt.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},VA=(t,e,n)=>{let r=tN(t,n);if(!r)return!1;let s=Yg(r);return s?rN(t,s,e):!1},KA=(t,e,n)=>{let r=iN(t,n);if(!r)return!1;let s=Xg(r);return s?rN(t,s,e):!1};function rN(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=Md(t.doc,i,d,Pe.empty);if(!f||f.from!=i||f instanceof jn&&f.slice.size>=d-i)return!1;if(n){let h=t.tr.step(f);h.setSelection(it.create(h.doc,i)),n(h.scrollIntoView())}return!0}function Xo(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 sN=(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=Yg(r)}let o=i&&i.nodeBefore;return!o||!rt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(rt.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function Yg(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 iN(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const oN=(t,e,n)=>{let r=iN(t,n);if(!r)return!1;let s=Xg(r);if(!s)return!1;let i=s.nodeAfter;if(dN(t,s,e,1))return!0;if(r.parent.content.size==0&&(Xo(i,"start")||rt.isSelectable(i))){let o=Md(t.doc,r.before(),r.after(),Pe.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Xo(i,"start")?ht.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):rt.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},aN=(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=Xg(r)}let o=i&&i.nodeAfter;return!o||!rt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(rt.create(t.doc,i.pos)).scrollIntoView()),!0)};function Xg(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 GA=(t,e)=>{let n=t.selection,r=n instanceof rt,s;if(r){if(n.node.isTextblock||!yi(t.doc,n.from))return!1;s=n.from}else if(s=Td(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(rt.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},JA=(t,e)=>{let n=t.selection,r;if(n instanceof rt){if(n.node.isTextblock||!yi(t.doc,n.to))return!1;r=n.to}else if(r=Td(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},YA=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&sa(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},lN=(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 Qg(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 XA=(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=Qg(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(ht.near(d.doc.resolve(l),1)),e(d.scrollIntoView())}return!0},cN=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof xr||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Qg(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(it.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},uN=(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(Ms(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&sa(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function QA(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof rt&&e.selection.node.isBlock)return!r.parentOffset||!Ms(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 y=r.depth;;y--)if(r.node(y).isBlock){d=r.end(y)==r.pos+(r.depth-y),f=r.start(y)==r.pos-(r.depth-y),l=Qg(r.node(y-1).contentMatchAt(r.indexAfter(y-1))),i.unshift(d&&l?{type:l}:null),o=y;break}else{if(y==1)return!1;i.unshift(null)}let h=e.tr;(e.selection instanceof it||e.selection instanceof xr)&&h.deleteSelection();let m=h.mapping.map(r.pos),g=Ms(h.doc,m,i.length,i);if(g||(i[0]=l?{type:l}:null,g=Ms(h.doc,m,i.length,i)),!g)return!1;if(h.split(m,i.length,i),!d&&f&&r.node(o).type!=l){let y=h.mapping.map(r.before(o)),b=h.doc.resolve(y);l&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,l)&&h.setNodeMarkup(h.mapping.map(r.before(o)),l)}return n&&n(h.scrollIntoView()),!0}}const ZA=QA(),ej=(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(rt.create(t.doc,s))),!0)};function tj(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||yi(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&&tj(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 y=e.pos+i.nodeSize,b=be.empty;for(let E=o.length-1;E>=0;E--)b=be.from(o[E].create(null,b));b=be.from(s.copy(b));let x=t.tr.step(new On(e.pos-1,y,e.pos,y,new Pe(b,1,0),o.length,!0)),w=x.doc.resolve(y+2*o.length);w.nodeAfter&&w.nodeAfter.type==s.type&&yi(x.doc,w.pos)&&x.join(w.pos),n(x.scrollIntoView())}return!0}let h=i.type.spec.isolating||r>0&&d?null:ht.findFrom(e,1),m=h&&h.$from.blockRange(h.$to),g=m&&sa(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(f&&Xo(i,"start",!0)&&Xo(s,"end")){let y=s,b=[];for(;b.push(y),!y.isTextblock;)y=y.lastChild;let x=i,w=1;for(;!x.isTextblock;x=x.firstChild)w++;if(y.canReplace(y.childCount,y.childCount,x.content)){if(n){let E=be.empty;for(let A=b.length-1;A>=0;A--)E=be.from(b[A].copy(E));let C=t.tr.step(new On(e.pos-b.length,e.pos+i.nodeSize,e.pos+w,e.pos+i.nodeSize-w,new Pe(E,b.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function fN(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(it.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const nj=fN(-1),rj=fN(1);function sj(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&Vg(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function lx(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 Zg(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Zg(Jg,nN,sN);Zg(Jg,oN,aN);Zg(lN,cN,uN,ZA);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function ij(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 oj(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function oj(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 ju(d,d,e.depth),e.endIndex<e.parent.childCount&&(e=new ju(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Vg(i,n,r,e);return l?(t&&aj(t,e,l,s,n),!0):!1}function aj(t,e,n,r,s){let i=be.empty;for(let h=n.length-1;h>=0;h--)i=be.from(n[h].type.create(n[h].attrs,i));t.step(new On(e.start-(r?2:0),e.end,e.start,e.end,new Pe(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&&Ms(t.doc,d,l)&&(t.split(d,l),d+=2*l),d+=f.child(h).nodeSize;return t}function lj(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?cj(e,n,t,i):uj(e,n,i):!0:!1}}function cj(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new On(i-1,o,i,o,new Pe(be.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ju(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=sa(r);if(l==null)return!1;s.lift(r,l);let d=s.doc.resolve(s.mapping.map(i,-1)-1);return yi(s.doc,d.pos)&&d.nodeBefore.type==d.nodeAfter.type&&s.join(d.pos),e(s.scrollIntoView()),!0}function uj(t,e,n){let r=t.tr,s=n.parent;for(let y=n.end,b=n.endIndex-1,x=n.startIndex;b>x;b--)y-=s.child(b).nodeSize,r.delete(y-1,y+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,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?be.empty:be.from(s))))return!1;let m=i.pos,g=m+o.nodeSize;return r.step(new On(m-(l?1:0),g+(d?1:0),m+1,g-1,new Pe((l?be.empty:be.from(s.copy(be.empty))).append(d?be.empty:be.from(s.copy(be.empty))),l?0:1,d?0:1),l?0:1)),e(r.scrollIntoView()),!0}function dj(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=be.from(f?t.create():null),m=new Pe(be.from(t.create(null,be.from(l.type.create(null,h)))),f?3:1,0),g=i.start,y=i.end;n(e.tr.step(new On(g-(f?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Fn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Qo=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let ug=null;const Ns=function(t,e,n){let r=ug||(ug=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},fj=function(){ug=null},eo=function(t,e,n,r){return n&&(cx(t,e,n,r,-1)||cx(t,e,n,r,1))},hj=/^(img|br|input|textarea|hr)$/i;function cx(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Rr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Cl(t)||hj.test(t.nodeName)||t.contentEditable=="false")return!1;e=Fn(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?Rr(t):0}else return!1}}function Rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function pj(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=Rr(t)}else if(t.parentNode&&!Cl(t))e=Fn(t),t=t.parentNode;else return null}}function mj(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&&!Cl(t))e=Fn(t)+1,t=t.parentNode;else return null}}function gj(t,e,n){for(let r=e==0,s=e==Rr(t);r||s;){if(t==n)return!0;let i=Fn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Rr(t)}}function Cl(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 jd=function(t){return t.focusNode&&eo(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ui(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function vj(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function yj(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Rr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Rr(r.startContainer),r.startOffset)}}}const cs=typeof navigator<"u"?navigator:null,ux=typeof document<"u"?document:null,bi=cs&&cs.userAgent||"",dg=/Edge\/(\d+)/.exec(bi),hN=/MSIE \d/.exec(bi),fg=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(bi),fr=!!(hN||fg||dg),di=hN?document.documentMode:fg?+fg[1]:dg?+dg[1]:0,Ir=!fr&&/gecko\/(\d+)/i.test(bi);Ir&&+(/Firefox\/(\d+)/.exec(bi)||[0,0])[1];const hg=!fr&&/Chrome\/(\d+)/.exec(bi),Hn=!!hg,pN=hg?+hg[1]:0,Jn=!fr&&!!cs&&/Apple Computer/.test(cs.vendor),Zo=Jn&&(/Mobile\/\w+/.test(bi)||!!cs&&cs.maxTouchPoints>2),Or=Zo||(cs?/Mac/.test(cs.platform):!1),mN=cs?/Win/.test(cs.platform):!1,_s=/Android \d/.test(bi),_l=!!ux&&"webkitFontSmoothing"in ux.documentElement.style,bj=_l?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function xj(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 xs(t,e){return typeof t=="number"?t:t[e]}function wj(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 dx(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=Qo(o);continue}let l=o,d=l==i.body,f=d?xj(i):wj(l),h=0,m=0;if(e.top<f.top+xs(r,"top")?m=-(f.top-e.top+xs(s,"top")):e.bottom>f.bottom-xs(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+xs(s,"top")-f.top:e.bottom-f.bottom+xs(s,"bottom")),e.left<f.left+xs(r,"left")?h=-(f.left-e.left+xs(s,"left")):e.right>f.right-xs(r,"right")&&(h=e.right-f.right+xs(s,"right")),h||m)if(d)i.defaultView.scrollBy(h,m);else{let y=l.scrollLeft,b=l.scrollTop;m&&(l.scrollTop+=m),h&&(l.scrollLeft+=h);let x=l.scrollLeft-y,w=l.scrollTop-b;e={left:e.left-x,top:e.top-w,right:e.right-x,bottom:e.bottom-w}}let g=d?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:Qo(o)}}function kj(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:gN(t.dom)}}function gN(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Qo(r));return e}function Sj({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;vN(n,r==0?0:r-e)}function vN(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 Lo=null;function Ej(t){if(t.setActive)return t.setActive();if(Lo)return t.focus(Lo);let e=gN(t);t.focus(Lo==null?{get preventScroll(){return Lo={preventScroll:!0},!0}}:void 0),Lo||(Lo=!1,vN(e,0))}function yN(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=Ns(h).getClientRects();else continue;for(let y=0;y<g.length;y++){let b=g[y];if(b.top<=o&&b.bottom>=l){o=Math.max(b.bottom,o),l=Math.min(b.top,l);let x=b.left>e.left?b.left-e.left:b.right<e.left?e.left-b.right:0;if(x<r){n=h,r=x,s=x&&n.nodeType==3?{left:b.right<e.left?b.right:b.left,top:e.top}:e,h.nodeType==1&&x&&(i=m+(e.left>=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!d&&b.left<=e.left&&b.right>=e.left&&(d=h,f={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(i=m+1)}}return!n&&d&&(n=d,s=f,r=0),n&&n.nodeType==3?Nj(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:yN(n,s)}function Nj(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=ti(r,1);if(o.top!=o.bottom&&ev(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 ev(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Cj(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function _j(t,e,n){let{node:r,offset:s}=yN(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 Tj(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 bN(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(ev(e,f))return bN(o,e,f)}}if((i=(i+1)%r)==s)break}return t}function Mj(t,e){let n=t.dom.ownerDocument,r,s=0,i=yj(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(!ev(e,f)||(o=bN(t.dom,e,f),!o))return null}if(Jn)for(let f=o;r&&f;f=Qo(f))f.draggable&&(r=void 0);if(o=Cj(o,e),r){if(Ir&&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;_l&&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=Tj(t,r,s,e))}l==null&&(l=_j(t,o,e));let d=t.docView.nearestDesc(o,!0);return{pos:l,inside:d?d.posAtStart-d.border:-1}}function fx(t){return t.top<t.bottom||t.left<t.right}function ti(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(fx(r))return r}return Array.prototype.find.call(n,fx)||t.getBoundingClientRect()}const Aj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function xN(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=_l||Ir;if(r.nodeType==3)if(o&&(Aj.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let d=ti(Ns(r,s,s),n);if(Ir&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=ti(Ns(r,s-1,s-1),-1);if(f.top==d.top){let h=ti(Ns(r,s,s+1),-1);if(h.top!=d.top)return Fa(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++,Fa(ti(Ns(r,d,f),h),h<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Rr(r))){let d=r.childNodes[s-1];if(d.nodeType==1)return Jh(d.getBoundingClientRect(),!1)}if(i==null&&s<Rr(r)){let d=r.childNodes[s];if(d.nodeType==1)return Jh(d.getBoundingClientRect(),!0)}return Jh(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Rr(r))){let d=r.childNodes[s-1],f=d.nodeType==3?Ns(d,Rr(d)-(o?0:1)):d.nodeType==1&&(d.nodeName!="BR"||!d.nextSibling)?d:null;if(f)return Fa(ti(f,1),!1)}if(i==null&&s<Rr(r)){let d=r.childNodes[s];for(;d.pmViewDesc&&d.pmViewDesc.ignoreForCoords;)d=d.nextSibling;let f=d?d.nodeType==3?Ns(d,0,o?0:1):d.nodeType==1?d:null:null;if(f)return Fa(ti(f,-1),!0)}return Fa(ti(r.nodeType==3?Ns(r):r,-n),n>=0)}function Fa(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 Jh(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 wN(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 jj(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return wN(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=xN(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=Ns(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 Oj=/[\u0590-\u08ac]/;function Rj(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?!Oj.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:wN(t,e,()=>{let{focusNode:d,focusOffset:f,anchorNode:h,anchorOffset:m}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let y=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:b,focusOffset:x}=t.domSelectionRange(),w=b&&!y.contains(b.nodeType==1?b:b.parentNode)||d==b&&f==x;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 hx=null,px=null,mx=!1;function Ij(t,e,n){return hx==e&&px==n?mx:(hx=e,px=n,mx=n=="up"||n=="down"?jj(t,e,n):Rj(t,e,n))}const Lr=0,gx=1,Hi=2,us=3;class Tl{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Lr,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>Fn(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 SN){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?Fn(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?Fn(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=Fn(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=Fn(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=f}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let y=0,b=0;y<this.children.length;y++){let x=this.children[y],w=b+x.size;if(i>b&&o<w)return x.setSelection(e-b-x.border,n-b-x.border,r,s);b=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((Ir||Jn)&&e==n){let{node:y,offset:b}=l;if(y.nodeType==3){if(m=!!(b&&y.nodeValue[b-1]==`
|
|
54
|
-
`),m&&b==y.nodeValue.length)for(let x=y,w;x;x=x.parentNode){if(w=x.nextSibling){w.nodeName=="BR"&&(l=d={node:w.parentNode,offset:Fn(w)+1});break}let E=x.pmViewDesc;if(E&&E.node&&E.node.isBlock)break}}else{let x=y.childNodes[b-1];m=x&&(x.nodeName=="BR"||x.contentEditable=="false")}}if(Ir&&h.focusNode&&h.focusNode!=d.node&&h.focusNode.nodeType==1){let y=h.focusNode.childNodes[h.focusOffset];y&&y.contentEditable=="false"&&(s=!0)}if(!(s||m&&Jn)&&eo(l.node,l.offset,h.anchorNode,h.anchorOffset)&&eo(d.node,d.offset,h.focusNode,h.focusOffset))return;let g=!1;if((f.extend||e==n)&&!(m&&Ir)){f.collapse(l.node,l.offset);try{e!=n&&f.extend(d.node,d.offset),g=!0}catch{}}if(!g){if(e>n){let b=l;l=d,d=b}let y=document.createRange();y.setEnd(d.node,d.offset),y.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(y)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,d=o-i.border;if(e>=l&&n<=d){this.dirty=e==r||n==o?Hi:gx,e==l&&n==d&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=us:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Hi:us}r=o}this.dirty=Hi}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Hi:gx;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 Tl{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==Lr&&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 Lj extends Tl{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 to extends Tl{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=io.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new to(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&us||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=us&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Lr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Lr}}slice(e,n,r){let s=to.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=mg(i,n,o,r)),e>0&&(i=mg(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 fi extends Tl{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}=io.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=CN(h,r,n),f?d=new Dj(e,n,r,s,h,m||null,g,f,i,o+1):n.isText?new Od(e,n,r,s,h,g,i):new fi(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=()=>be.empty)}return e}matchesNode(e,n,r){return this.dirty==Lr&&e.eq(this.node)&&Ru(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 Bj(this,o&&o.node,e);Fj(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?Vt.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 y;d.findNodeMatch(f,h,m,g)||l&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(y=d.findIndexWithChild(i.node))>-1&&d.updateNodeAt(f,h,m,y,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==Hi)&&(o&&this.protectLocalComposition(e,o),EN(this.contentDOM,this.children,e),Zo&&Uj(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof it)||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=Hj(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 Lj(this,i,n,s);e.input.compositionNodes.push(o),this.children=mg(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==us||!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=Lr}updateOuterDeco(e){if(Ru(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=NN(this.dom,this.nodeDOM,pg(this.outerDeco,this.node,n),pg(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 vx(t,e,n,r,s){CN(r,e,t);let i=new fi(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Od extends fi{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==us||this.dirty!=Lr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Lr||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=Lr,!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 Od(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=us)}get domAtom(){return!1}isText(e){return this.node.text==e}}class SN extends Tl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Lr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Dj extends fi{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==us)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 EN(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=yx(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof to){let d=r?r.previousSibling:t.lastChild;EN(o.contentDOM,o.children,n),r=d?d.nextSibling:t.firstChild}}for(;r;)r=yx(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const rl=function(t){t&&(this.nodeName=t)};rl.prototype=Object.create(null);const Wi=[new rl];function pg(t,e,n){if(t.length==0)return Wi;let r=n?Wi[0]:new rl,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new rl(o.nodeName));for(let l in o){let d=o[l];d!=null&&(n&&s.length==1&&s.push(r=new rl(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 NN(t,e,n,r){if(n==Wi&&r==Wi)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=Wi[0]),s=d}Pj(s,l||Wi[0],o)}return s}function Pj(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 CN(t,e,n){return NN(t,t,Wi,pg(e,n,t.nodeType!=1))}function Ru(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 yx(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Bj{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=zj(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=Lr,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=to.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==us&&o.dom==o.contentDOM&&(o.dirty=Hi),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 fi){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!=us&&Ru(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=Hi,m.updateChildren(s,o+1),m.dirty=Lr),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)||!Ru(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=fi.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=fi.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 to;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Od)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Jn||Hn)&&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 SN(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 zj(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 to)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 $j(t,e){return t.type.side-e.type.side}function Fj(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($j);for(let w=0;w<m.length;w++)n(m[w],f,!!d)}else n(h,f,!!d);let g,y;if(d)y=-1,g=d,d=null;else if(f<t.childCount)y=f,g=t.child(f++);else break;for(let w=0;w<l.length;w++)l[w].to<=i&&l.splice(w--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let b=i+g.nodeSize;if(g.isText){let w=b;o<s.length&&s[o].from<w&&(w=s[o].from);for(let E=0;E<l.length;E++)l[E].to<w&&(w=l[E].to);w<b&&(d=g.cut(w-i),g=g.cut(0,w-i),b=w,y=-1)}else for(;o<s.length&&s[o].to<b;)o++;let x=g.isInline&&!g.isLeaf?l.filter(w=>!w.inline):l.slice();r(g,x,e.forChild(i,g),y),i=b}}function Uj(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 Hj(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 mg(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 tv(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(jd(n)){for(d=o;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&rt.isSelectable(m)&&s.parent&&!(m.isInline&&gj(n.focusNode,n.focusOffset,s.dom))){let g=s.posBefore;f=new rt(o==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let y=0;y<n.rangeCount;y++){let b=n.getRangeAt(y);m=Math.min(m,t.docView.posFromDOM(b.startContainer,b.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(b.endContainer,b.endOffset,-1))}if(m<0)return null;[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=nv(t,h,l,m)}return f}function _N(t){return t.editable?t.hasFocus():MN(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function As(t,e=!1){let n=t.state.selection;if(TN(t,n),!!_N(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Hn){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&eo(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)qj(t);else{let{anchor:r,head:s}=n,i,o;bx&&!(n instanceof it)&&(n.$from.parent.inlineContent||(i=xx(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=xx(t,n.to))),t.docView.setSelection(r,s,t,e),bx&&(i&&wx(i),o&&wx(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Wj(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const bx=Jn||Hn&&pN<63;function xx(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Jn&&s&&s.contentEditable=="false")return Yh(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Yh(s);if(i)return Yh(i)}}function Yh(t){return t.contentEditable="true",Jn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function wx(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Wj(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(()=>{(!_N(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function qj(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Fn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&fr&&di<=11&&(n.disabled=!0,n.disabled=!1)}function TN(t,e){if(e instanceof rt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(kx(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else kx(t)}function kx(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function nv(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||it.between(e,n,r)}function Sx(t){return t.editable&&!t.hasFocus()?!1:MN(t)}function MN(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 Vj(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return eo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function gg(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&&ht.findFrom(i,e)}function ni(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ex(t,e,n){let r=t.state.selection;if(r instanceof it)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 ni(t,new it(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=gg(t.state,e);return s&&s instanceof rt?ni(t,s):!1}else if(!(Or&&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?rt.isSelectable(i)?ni(t,new rt(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):_l?ni(t,new it(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof rt&&r.node.isInline)return ni(t,new it(e>0?r.$to:r.$from));{let s=gg(t.state,e);return s?ni(t,s):!1}}}function Iu(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sl(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Do(t,e){return e<0?Kj(t):Gj(t)}function Kj(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Ir&&n.nodeType==1&&r<Iu(n)&&sl(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(sl(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(AN(n))break;{let l=n.previousSibling;for(;l&&sl(l,-1);)s=n.parentNode,i=Fn(l),l=l.previousSibling;if(l)n=l,r=Iu(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?vg(t,n,r):s&&vg(t,s,i)}function Gj(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Iu(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(sl(l,1))i=n,o=++r;else break}else{if(AN(n))break;{let l=n.nextSibling;for(;l&&sl(l,1);)i=l.parentNode,o=Fn(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Iu(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&vg(t,i,o)}function AN(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Jj(t,e){for(;t&&e==t.childNodes.length&&!Cl(t);)e=Fn(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 Yj(t,e){for(;t&&!e&&!Cl(t);)e=Fn(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 vg(t,e,n){if(e.nodeType!=3){let i,o;(o=Jj(e,n))?(e=o,n=0):(i=Yj(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(jd(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&&As(t)},50)}function Nx(t,e){let n=t.state.doc.resolve(e);if(!(Hn||mN)&&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 Cx(t,e,n){let r=t.state.selection;if(r instanceof it&&!r.empty||n.indexOf("s")>-1||Or&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=gg(t.state,e);if(o&&o instanceof rt)return ni(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof xr?ht.near(o,e):ht.findFrom(o,e);return l?ni(t,l):!1}return!1}function _x(t,e){if(!(t.state.selection instanceof it))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 Tx(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Xj(t){if(!Jn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Tx(t,r,"true"),setTimeout(()=>Tx(t,r,"false"),20)}return!1}function Qj(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Zj(t,e){let n=e.keyCode,r=Qj(e);if(n==8||Or&&n==72&&r=="c")return _x(t,-1)||Do(t,-1);if(n==46&&!e.shiftKey||Or&&n==68&&r=="c")return _x(t,1)||Do(t,1);if(n==13||n==27)return!0;if(n==37||Or&&n==66&&r=="c"){let s=n==37?Nx(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ex(t,s,r)||Do(t,s)}else if(n==39||Or&&n==70&&r=="c"){let s=n==39?Nx(t,t.state.selection.from)=="ltr"?1:-1:1;return Ex(t,s,r)||Do(t,s)}else{if(n==38||Or&&n==80&&r=="c")return Cx(t,-1,r)||Do(t,-1);if(n==40||Or&&n==78&&r=="c")return Xj(t)||Cx(t,1,r)||Do(t,1);if(r==(Or?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function rv(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let y=r.firstChild;n.push(y.type.name,y.attrs!=y.type.defaultAttrs?y.attrs:null),r=y.content}let o=t.someProp("clipboardSerializer")||io.fromSchema(t.state.schema),l=DN(),d=l.createElement("div");d.appendChild(o.serializeFragment(r,{document:l}));let f=d.firstChild,h,m=0;for(;f&&f.nodeType==1&&(h=LN[f.nodeName.toLowerCase()]);){for(let y=h.length-1;y>=0;y--){let b=l.createElement(h[y]);for(;d.firstChild;)b.appendChild(d.firstChild);d.appendChild(b),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",y=>y(e,t))||e.content.textBetween(0,e.content.size,`
|
|
55
|
-
|
|
56
|
-
`);return{dom:d,text:g,slice:e}}function jN(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 Pe(be.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
57
|
-
`))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let m=t.someProp("clipboardTextParser",g=>g(e,s,r,t));if(m)l=m;else{let g=s.marks(),{schema:y}=t.state,b=io.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(x=>{let w=o.appendChild(document.createElement("p"));x&&w.appendChild(b.serializeNode(y.text(x,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=rO(n),_l&&sO(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")||tl.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(d||h),context:s,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!eO.test(g.parentNode.nodeName)?{ignore:!0}:null}})),h)l=iO(Mx(l,+h[1],+h[2]),h[4]);else if(l=Pe.maxOpen(tO(l.content,s),!0),l.openStart||l.openEnd){let m=0,g=0;for(let y=l.content.firstChild;m<l.openStart&&!y.type.spec.isolating;m++,y=y.firstChild);for(let y=l.content.lastChild;g<l.openEnd&&!y.type.spec.isolating;g++,y=y.lastChild);l=Mx(l,m,g)}return t.someProp("transformPasted",m=>{l=m(l,t,d)}),l}const eO=/^(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 tO(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&&RN(d,i,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=IN(o[o.length-1],i.length));let h=ON(l,d);o.push(h),s=s.matchType(h.type),i=d}}),o)return be.from(o)}return t}function ON(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,be.from(t));return t}function RN(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=RN(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(be.from(ON(n,t,s+1))))}}function IN(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,IN(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(be.empty,!0);return t.copy(n.append(r))}function yg(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=yg(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(be.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Mx(t,e,n){return e<t.openStart&&(t=new Pe(yg(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Pe(yg(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const LN={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 Ax=null;function DN(){return Ax||(Ax=document.implementation.createHTMLDocument("title"))}let Xh=null;function nO(t){let e=window.trustedTypes;return e?(Xh||(Xh=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Xh.createHTML(t)):t}function rO(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=DN().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&LN[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=nO(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function sO(t){let e=t.querySelectorAll(Hn?"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 iO(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=be.from(d.create(r[l+1],s)),i++,o++}return new Pe(s,i,o)}const rr={},sr={},oO={touchstart:!0,touchmove:!0};class aO{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 lO(t){for(let e in rr){let n=rr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{uO(t,r)&&!sv(t,r)&&(t.editable||!(r.type in sr))&&n(t,r)},oO[e]?{passive:!0}:void 0)}Jn&&t.dom.addEventListener("input",()=>null),bg(t)}function ui(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function cO(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 bg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>sv(t,r))})}function sv(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function uO(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 dO(t,e){!sv(t,e)&&rr[e.type]&&(t.editable||!(e.type in sr))&&rr[e.type](t,e)}sr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!BN(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(_s&&Hn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Zo&&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,Ui(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Zj(t,n)?n.preventDefault():ui(t,"key")};sr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};sr.keypress=(t,e)=>{let n=e;if(BN(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Or&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof it)||!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 Rd(t){return{left:t.clientX,top:t.clientY}}function fO(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function iv(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 Go(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 hO(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&rt.isSelectable(r)?(Go(t,new rt(n)),!0):!1}function pO(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof rt&&(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(rt.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?(Go(t,rt.create(t.state.doc,s)),!0):!1}function mO(t,e,n,r,s){return iv(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?pO(t,n):hO(t,n))}function gO(t,e,n,r){return iv(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function vO(t,e,n,r){return iv(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||yO(t,n,r)}function yO(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Go(t,it.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)Go(t,it.create(r,l+1,l+1+o.content.size));else if(rt.isSelectable(o))Go(t,rt.create(r,l));else continue;return!0}}function ov(t){return Lu(t)}const PN=Or?"metaKey":"ctrlKey";rr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ov(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&fO(n,t.input.lastClick)&&!n[PN]&&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(Rd(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new bO(t,o,n,!!r)):(i=="doubleClick"?gO:vO)(t,o.pos,o.inside,n)?n.preventDefault():ui(t,"pointer"))};class bO{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[PN],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 rt&&f.from<=o&&f.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ir&&!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)),ui(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(()=>As(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(Rd(e))),this.updateAllowDefault(e),this.allowDefault||!n?ui(this.view,"pointer"):mO(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Jn&&this.mightDrag&&!this.mightDrag.node.isAtom||Hn&&!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)?(Go(this.view,ht.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ui(this.view,"pointer")}move(e){this.updateAllowDefault(e),ui(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)}}rr.touchstart=t=>{t.input.lastTouch=Date.now(),ov(t),ui(t,"pointer")};rr.touchmove=t=>{t.input.lastTouch=Date.now(),ui(t,"pointer")};rr.contextmenu=t=>ov(t);function BN(t,e){return t.composing?!0:Jn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const xO=_s?5e3:-1;sr.compositionstart=sr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof it&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Hn&&mN&&wO(t)))t.markCursor=t.state.storedMarks||n.marks(),Lu(t,!0),t.markCursor=null;else if(Lu(t,!e.selection.empty),Ir&&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}zN(t,xO)};function wO(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"}sr.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++,zN(t,20))};function zN(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Lu(t),e))}function $N(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=SO());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function kO(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=pj(e.focusNode,e.focusOffset),r=mj(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 SO(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Lu(t,e=!1){if(!(_s&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),$N(t),e||t.docView&&t.docView.dirty){let n=tv(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 EO(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 ml=fr&&di<15||Zo&&bj<604;rr.copy=sr.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=ml?null:n.clipboardData,o=r.content(),{dom:l,text:d}=rv(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",d)):EO(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function NO(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function CO(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?gl(t,r.value,null,s,e):gl(t,r.textContent,r.innerHTML,s,e)},50)}function gl(t,e,n,r,s){let i=jN(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",d=>d(t,s,i||Pe.empty)))return!0;if(!i)return!1;let o=NO(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 FN(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," "):""}sr.paste=(t,e)=>{let n=e;if(t.composing&&!_s)return;let r=ml?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&gl(t,FN(r),r.getData("text/html"),s,n)?n.preventDefault():CO(t,n)};class UN{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const _O=Or?"altKey":"ctrlKey";function HN(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[_O]}rr.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(Rd(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof rt?s.to-1:s.to))){if(r&&r.mightDrag)o=rt.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=rt.create(t.state.doc,m.posBefore))}}let l=(o||t.state.selection).content(),{dom:d,text:f,slice:h}=rv(t,l);(!n.dataTransfer.files.length||!Hn||pN>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ml?"Text":"text/html",d.innerHTML),n.dataTransfer.effectAllowed="copyMove",ml||n.dataTransfer.setData("text/plain",f),t.dragging=new UN(h,HN(t,n),o)};rr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};sr.dragover=sr.dragenter=(t,e)=>e.preventDefault();sr.drop=(t,e)=>{try{TO(t,e,t.dragging)}finally{t.dragging=null}};function TO(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Rd(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",y=>{i=y(i,t,!1)}):i=jN(t,FN(e.dataTransfer),ml?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&HN(t,e));if(t.someProp("handleDrop",y=>y(t,e,i||Pe.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?KE(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let d=t.state.tr;if(o){let{node:y}=n;y?y.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&&rt.isSelectable(i.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(i.content.firstChild))d.setSelection(new rt(g));else{let y=d.mapping.map(l);d.mapping.maps[d.mapping.maps.length-1].forEach((b,x,w,E)=>y=E),d.setSelection(nv(t,g,d.doc.resolve(y)))}t.focus(),t.dispatch(d.setMeta("uiEvent","drop"))}rr.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())&&As(t)},20))};rr.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)};rr.beforeinput=(t,e)=>{if(Hn&&_s&&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,Ui(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 sr)rr[t]=sr[t];function vl(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 Du{constructor(e,n){this.toDOM=e,this.spec=n||Ji,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 zt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Du&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&vl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class hi{constructor(e,n){this.attrs=e,this.spec=n||Ji}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 zt(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof hi&&vl(this.attrs,e.attrs)&&vl(this.spec,e.spec)}static is(e){return e.type instanceof hi}destroy(){}}class av{constructor(e,n){this.attrs=e,this.spec=n||Ji}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 zt(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 av&&vl(this.attrs,e.attrs)&&vl(this.spec,e.spec)}destroy(){}}class zt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new zt(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 zt(e,e,new Du(n,r))}static inline(e,n,r,s){return new zt(e,n,new hi(r,s))}static node(e,n,r,s){return new zt(e,n,new av(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof hi}get widget(){return this.type instanceof Du}}const $o=[],Ji={};class jt{constructor(e,n){this.local=e.length?e:$o,this.children=n.length?n:$o}static create(e,n){return n.length?Pu(n,e,0,Ji):Gn}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==Gn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ji)}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?MO(this.children,o||[],e,n,r,s,i):o?new jt(o.sort(Yi),$o):Gn}add(e,n){return n.length?this==Gn?jt.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=qN(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,Pu(h,l,f+1,Ji)),i+=3}});let o=WN(i?VN(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new jt(o.length?this.local.concat(o).sort(Yi):this.local,s||this.children)}remove(e){return e.length==0||this==Gn?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!=Gn?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 jt(s,r):Gn}forChild(e,n){if(this==Gn)return this;if(n.isLeaf)return jt.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 hi){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 jt(s.sort(Yi),$o);return r?new ii([l,r]):l}return r||Gn}eq(e){if(this==e)return!0;if(!(e instanceof jt)||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 lv(this.localsInner(e))}localsInner(e){if(this==Gn)return $o;if(e.inlineContent||!this.local.some(hi.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hi||n.push(this.local[r]);return n}forEachSet(e){e(this)}}jt.empty=new jt([],[]);jt.removeOverlap=lv;const Gn=jt.empty;class ii{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Ji));return ii.from(r)}forChild(e,n){if(n.isLeaf)return jt.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=Gn&&(i instanceof ii?r=r.concat(i.members):r.push(i))}return ii.from(r)}eq(e){if(!(e instanceof ii)||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?lv(r?n:n.sort(Yi)):$o}static from(e){switch(e.length){case 0:return Gn;case 1:return e[0];default:return new ii(e.every(n=>n instanceof jt)?e:e.reduce((n,r)=>n.concat(r instanceof jt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function MO(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,y,b,x)=>{let w=x-b-(y-g);for(let E=0;E<l.length;E+=3){let C=l[E+1];if(C<0||g>C+h-m)continue;let A=l[E]+h-m;y>=A?l[E+1]=g<=A?-2:-1:g>=h&&w&&(l[E]+=w,l[E+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),y=g-s,{index:b,offset:x}=r.content.findIndex(m),w=r.maybeChild(b);if(w&&x==m&&x+w.nodeSize==y){let E=l[f+2].mapInner(n,w,h+1,t[f]+i+1,o);E!=Gn?(l[f]=m,l[f+1]=y,l[f+2]=E):(l[f+1]=-2,d=!0)}else d=!0}if(d){let f=AO(l,t,e,n,s,i,o),h=Pu(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 y=h.children[m];for(;g<l.length&&l[g]<y;)g+=3;l.splice(g,0,h.children[m],h.children[m+1],h.children[m+2])}}return new jt(e.sort(Yi),l)}function WN(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 zt(s.from+e,s.to+e,s.type))}return n}function AO(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 qN(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 VN(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Pu(t,e,n,r){let s=[],i=!1;e.forEach((l,d)=>{let f=qN(t,l,d+n);if(f){i=!0;let h=Pu(f,l,n+d+1,r);h!=Gn&&s.push(d,d+l.nodeSize,h)}});let o=WN(i?VN(t):t,-n).sort(Yi);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 jt(o,s):Gn}function Yi(t,e){return t.from-e.from||t.to-e.to}function lv(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),jx(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),jx(e,s,r.copy(i.from,r.to)));break}}}return e}function jx(t,e,n){for(;e<t.length&&Yi(n,t[e])>0;)e++;t.splice(e,0,n)}function Qh(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Gn&&e.push(r)}),t.cursorWrapper&&e.push(jt.create(t.state.doc,[t.cursorWrapper.deco])),ii.from(e)}const jO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},OO=fr&&di<=11;class RO{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 IO{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new RO,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]);fr&&di<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():Jn&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),OO&&(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,jO)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Sx(this.view)){if(this.suppressingSelectionUpdates)return As(this.view);if(fr&&di<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&eo(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=Qo(i))n.add(i);for(let i=e.anchorNode;i;i=Qo(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Sx(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,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(Ir&&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 y=g.parentNode;y&&y.nodeName=="LI"&&(!m||PO(e,m)!=y)&&g.remove()}}}let f=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&jd(r)&&(f=tv(e))&&f.eq(ht.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,As(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),LO(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,BO(e,d)),this.handleDOMChange(i,o,l,d),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||As(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(fr&&di<=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?Fn(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),d=i&&i.parentNode==e.target?Fn(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 Ox=new WeakMap,Rx=!1;function LO(t){if(!Ox.has(t)&&(Ox.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ir,Rx)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."),Rx=!0}}function Ix(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return eo(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function DO(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Ix(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?Ix(t,n):null}function PO(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 BO(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 zO(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}],jd(d)||f.push({node:d.focusNode,offset:d.focusOffset})),Hn&&t.input.lastKeyCode===8)for(let w=i;w>s;w--){let E=r.childNodes[w-1],C=E.pmViewDesc;if(E.nodeName=="BR"&&!C){i=w;break}if(!C||C.size)break}let m=t.state.doc,g=t.someProp("domParser")||tl.fromSchema(t.state.schema),y=m.resolve(o),b=null,x=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:s,to:i,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:$O,context:y});if(f&&f[0].pos!=null){let w=f[0].pos,E=f[1]&&f[1].pos;E==null&&(E=w),b={anchor:w+o,head:E+o}}return{doc:x,sel:b,from:o,to:l}}function $O(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Jn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Jn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const FO=/^(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 UO(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let R=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,B=tv(t,R);if(B&&!t.state.selection.eq(B)){if(Hn&&_s&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",U=>U(t,Ui(13,"Enter"))))return;let D=t.state.tr.setSelection(B);R=="pointer"?D.setMeta("pointer",!0):R=="key"&&D.scrollIntoView(),i&&D.setMeta("composition",i),t.dispatch(D)}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=zO(t,e,n),h=t.state.doc,m=h.slice(f.from,f.to),g,y;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,y="end"):(g=t.state.selection.from,y="start"),t.input.lastKeyCode=null;let b=qO(m.content,f.doc.content,f.from,g,y);if(b&&t.input.domChangeCount++,(Zo&&t.input.lastIOSEnter>Date.now()-225||_s)&&s.some(R=>R.nodeType==1&&!FO.test(R.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",R=>R(t,Ui(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&d instanceof it&&!d.empty&&d.$head.sameParent(d.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))b={start:d.from,endA:d.to,endB:d.to};else{if(f.sel){let R=Lx(t,t.state.doc,f.sel);if(R&&!R.eq(t.state.selection)){let B=t.state.tr.setSelection(R);i&&B.setMeta("composition",i),t.dispatch(B)}}return}t.state.selection.from<t.state.selection.to&&b.start==b.endB&&t.state.selection instanceof it&&(b.start>t.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?b.start=t.state.selection.from:b.endA<t.state.selection.to&&b.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),fr&&di<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>f.from&&f.doc.textBetween(b.start-f.from-1,b.start-f.from+1)==" "&&(b.start--,b.endA--,b.endB--);let x=f.doc.resolveNoCache(b.start-f.from),w=f.doc.resolveNoCache(b.endB-f.from),E=h.resolve(b.start),C=x.sameParent(w)&&x.parent.inlineContent&&E.end()>=b.endA;if((Zo&&t.input.lastIOSEnter>Date.now()-225&&(!C||s.some(R=>R.nodeName=="DIV"||R.nodeName=="P"))||!C&&x.pos<f.doc.content.size&&(!x.sameParent(w)||!x.parent.inlineContent)&&x.pos<w.pos&&!/\S/.test(f.doc.textBetween(x.pos,w.pos,"","")))&&t.someProp("handleKeyDown",R=>R(t,Ui(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&WO(h,b.start,b.endA,x,w)&&t.someProp("handleKeyDown",R=>R(t,Ui(8,"Backspace")))){_s&&Hn&&t.domObserver.suppressSelectionUpdates();return}Hn&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),_s&&!C&&x.start()!=w.start()&&w.parentOffset==0&&x.depth==w.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==b.endA&&(b.endB-=2,w=f.doc.resolveNoCache(b.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(R){return R(t,Ui(13,"Enter"))})},20));let A=b.start,T=b.endA,_=R=>{let B=R||t.state.tr.replace(A,T,f.doc.slice(b.start-f.from,b.endB-f.from));if(f.sel){let D=Lx(t,B.doc,f.sel);D&&!(Hn&&t.composing&&D.empty&&(b.start!=b.endB||t.input.lastChromeDelete<Date.now()-100)&&(D.head==A||D.head==B.mapping.map(T)-1)||fr&&D.empty&&D.head==A)&&B.setSelection(D)}return i&&B.setMeta("composition",i),B.scrollIntoView()},O;if(C)if(x.pos==w.pos){fr&&di<=11&&x.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>As(t),20));let R=_(t.state.tr.delete(A,T)),B=h.resolve(b.start).marksAcross(h.resolve(b.endA));B&&R.ensureMarks(B),t.dispatch(R)}else if(b.endA==b.endB&&(O=HO(x.parent.content.cut(x.parentOffset,w.parentOffset),E.parent.content.cut(E.parentOffset,b.endA-E.start())))){let R=_(t.state.tr);O.type=="add"?R.addMark(A,T,O.mark):R.removeMark(A,T,O.mark),t.dispatch(R)}else if(x.parent.child(x.index()).isText&&x.index()==w.index()-(w.textOffset?0:1)){let R=x.parent.textBetween(x.parentOffset,w.parentOffset),B=()=>_(t.state.tr.insertText(R,A,T));t.someProp("handleTextInput",D=>D(t,A,T,R,B))||t.dispatch(B())}else t.dispatch(_());else t.dispatch(_())}function Lx(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:nv(t,e.resolve(n.anchor),e.resolve(n.head))}function HO(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(be.from(f).eq(t))return{mark:l,type:o}}function WO(t,e,n,r,s){if(n-e<=s.pos-r.pos||Zh(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Zh(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Zh(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Zh(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function qO(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&&Dx(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&&Dx(t.textBetween(i-1,i+1))&&(i+=d?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Dx(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 KN{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 aO,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Fx),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=zx(this),Bx(this),this.nodeViews=$x(this),this.docView=vx(this.state.doc,Px(this),Qh(this),this.dom,this),this.domObserver=new IO(this,(r,s,i,o)=>UO(this,r,s,i,o)),this.domObserver.start(),lO(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&&bg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fx),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&&($N(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=$x(this);KO(y,this.nodeViews)&&(this.nodeViews=y,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&bg(this),this.editable=zx(this),Bx(this);let d=Qh(this),f=Px(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&&kj(this);if(o){this.domObserver.stop();let y=m&&(fr||Hn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&VO(s.selection,e.selection);if(m){let b=Hn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=kO(this)),(i||!this.docView.update(e.doc,f,d,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=vx(e.doc,f,d,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Vj(this))?As(this,y):(TN(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&&Sj(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 rt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&dx(this,n.getBoundingClientRect(),e)}else dx(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 UN(e.slice,e.move,s<0?void 0:rt.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(fr){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&&Ej(this.dom),As(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 Mj(this,e)}coordsAtPos(e,n=1){return xN(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 Ij(this,n||this.state,e)}pasteHTML(e,n){return gl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return gl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return rv(this,e)}destroy(){this.docView&&(cO(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Qh(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fj())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return dO(this,e)}domSelectionRange(){let e=this.domSelection();return e?Jn&&this.root.nodeType===11&&vj(this.dom.ownerDocument)==this.dom&&DO(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}KN.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Px(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"),[zt.node(0,t.state.doc.content.size,e)]}function Bx(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:zt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function zx(t){return!t.someProp("editable",e=>e(t.state)===!1)}function VO(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 $x(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 KO(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 Fx(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 mi={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:"'"},Bu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},GO=typeof navigator<"u"&&/Mac/.test(navigator.platform),JO=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Un=0;Un<10;Un++)mi[48+Un]=mi[96+Un]=String(Un);for(var Un=1;Un<=24;Un++)mi[Un+111]="F"+Un;for(var Un=65;Un<=90;Un++)mi[Un]=String.fromCharCode(Un+32),Bu[Un]=String.fromCharCode(Un);for(var ep in mi)Bu.hasOwnProperty(ep)||(Bu[ep]=mi[ep]);function YO(t){var e=GO&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||JO&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Bu:mi)[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 XO=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),QO=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))XO?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 eR(t){let e=Object.create(null);for(let n in t)e[ZO(n)]=t[n];return e}function tp(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 tR(t){return new Pt({props:{handleKeyDown:cv(t)}})}function cv(t){let e=eR(t);return function(n,r){let s=YO(r),i,o=e[tp(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[tp(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(QO&&r.ctrlKey&&r.altKey)&&(i=mi[r.keyCode])&&i!=s){let l=e[tp(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var nR=Object.defineProperty,uv=(t,e)=>{for(var n in e)nR(t,n,{get:e[n],enumerable:!0})};function Id(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 Ld=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,(...b)=>{const x=this.buildProps(d,e),w=g(...b)(x);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:Id({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}},GN={};uv(GN,{blur:()=>rR,clearContent:()=>sR,clearNodes:()=>iR,command:()=>oR,createParagraphNear:()=>aR,cut:()=>lR,deleteCurrentNode:()=>cR,deleteNode:()=>uR,deleteRange:()=>dR,deleteSelection:()=>fR,enter:()=>hR,exitCode:()=>pR,extendMarkRange:()=>mR,first:()=>gR,focus:()=>yR,forEach:()=>bR,insertContent:()=>xR,insertContentAt:()=>SR,joinBackward:()=>CR,joinDown:()=>NR,joinForward:()=>_R,joinItemBackward:()=>TR,joinItemForward:()=>MR,joinTextblockBackward:()=>AR,joinTextblockForward:()=>jR,joinUp:()=>ER,keyboardShortcut:()=>RR,lift:()=>IR,liftEmptyBlock:()=>LR,liftListItem:()=>DR,newlineInCode:()=>PR,resetAttributes:()=>BR,scrollIntoView:()=>zR,selectAll:()=>$R,selectNodeBackward:()=>FR,selectNodeForward:()=>UR,selectParentNode:()=>HR,selectTextblockEnd:()=>WR,selectTextblockStart:()=>qR,setContent:()=>VR,setMark:()=>uI,setMeta:()=>dI,setNode:()=>fI,setNodeSelection:()=>hI,setTextDirection:()=>pI,setTextSelection:()=>mI,sinkListItem:()=>gI,splitBlock:()=>vI,splitListItem:()=>yI,toggleList:()=>bI,toggleMark:()=>xI,toggleNode:()=>wI,toggleWrap:()=>kI,undoInputRule:()=>SI,unsetAllMarks:()=>EI,unsetMark:()=>NI,unsetTextDirection:()=>CI,updateAttributes:()=>_I,wrapIn:()=>TI,wrapInList:()=>MI});var rR=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),sR=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),iR=()=>({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)),y=m.blockRange(g);if(!y)return;const b=sa(y);if(l.type.isTextblock){const{defaultType:x}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,x)}(b||b===0)&&e.lift(y,b)})}),!0},oR=t=>e=>t(e),aR=()=>({state:t,dispatch:e})=>cN(t,e),lR=(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 it(r.doc.resolve(Math.max(o-1,0)))),!0},cR=()=>({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 Sn(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 uR=t=>({tr:e,state:n,dispatch:r})=>{const s=Sn(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},dR=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},fR=()=>({state:t,dispatch:e})=>Jg(t,e),hR=()=>({commands:t})=>t.keyboardShortcut("Enter"),pR=()=>({state:t,dispatch:e})=>XA(t,e);function dv(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function zu(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:dv(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function JN(t,e,n={}){return t.find(r=>r.type===e&&zu(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Ux(t,e,n={}){return!!JN(t,e,n)}function fv(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),!JN([...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&&Ux([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;d<t.parent.childCount&&Ux([...t.parent.child(d).marks],e,n);)f+=t.parent.child(d).nodeSize,d+=1;return{from:l,to:f}}function js(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var mR=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=js(t,r.schema),{doc:o,selection:l}=n,{$from:d,from:f,to:h}=l;if(s){const m=fv(d,i,e);if(m&&m.from<=f&&m.to>=h){const g=it.create(o,m.from,m.to);n.setSelection(g)}}return!0},gR=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 YN(t){return t instanceof it}function qi(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function XN(t,e=null){if(!e)return null;const n=ht.atStart(t),r=ht.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?it.create(t,qi(0,s,i),qi(t.content.size,s,i)):it.create(t,qi(e,s,i),qi(e,s,i))}function xg(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function yl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function vR(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var yR=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(yl()||xg())&&r.dom.focus(),vR()&&!yl()&&!xg()&&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&&!YN(n.state.selection))return o(),!0;const l=XN(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},bR=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),xR=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),QN=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&&QN(r)}return t};function Wc(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 QN(n)}function bl(t,e,n){if(t instanceof Kr||t instanceof be)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 be.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),bl("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const d=new DE({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?tl.fromSchema(d).parseSlice(Wc(t),n.parseOptions):tl.fromSchema(d).parse(Wc(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=tl.fromSchema(e);return n.slice?i.parseSlice(Wc(t),n.parseOptions).content:i.parse(Wc(t),n.parseOptions)}return bl("",e,n)}function wR(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof jn||s instanceof On))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,d,f,h)=>{o===0&&(o=h)}),t.setSelection(ht.near(t.doc.resolve(o),n))}var kR=t=>!("type"in t),SR=(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{bl(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(w){d(w)}try{l=bl(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,y=!0;if((kR(l)?l:[l]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,y=y?w.isBlock:!1}),h===m&&y){const{parent:w}=r.doc.resolve(h);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(h-=1,m+=1)}let x;if(g){if(Array.isArray(e))x=e.map(w=>w.text||"").join("");else if(e instanceof be){let w="";e.forEach(E=>{E.text&&(w+=E.text)}),x=w}else typeof e=="object"&&e&&e.text?x=e.text:x=e;r.insertText(x,h,m)}else{x=l;const w=r.doc.resolve(h),E=w.node(),C=w.parentOffset===0,A=E.isText||E.isTextblock,T=E.content.size>0;C&&A&&T&&(h=Math.max(0,h-1)),r.replaceWith(h,m,x)}n.updateSelection&&wR(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:x}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:x})}return!0},ER=()=>({state:t,dispatch:e})=>GA(t,e),NR=()=>({state:t,dispatch:e})=>JA(t,e),CR=()=>({state:t,dispatch:e})=>nN(t,e),_R=()=>({state:t,dispatch:e})=>oN(t,e),TR=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Td(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},MR=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Td(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},AR=()=>({state:t,dispatch:e})=>VA(t,e),jR=()=>({state:t,dispatch:e})=>KA(t,e);function ZN(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function OR(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))yl()||ZN()?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 RR=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=OR(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 gi(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Sn(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),b=Math.min(s,g+m.nodeSize);l.push({node:m,from:y,to:b})});const d=s-r,f=l.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>zu(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=d}var IR=(t,e={})=>({state:n,dispatch:r})=>{const s=Sn(t,n.schema);return gi(n,s,e)?YA(n,r):!1},LR=()=>({state:t,dispatch:e})=>uN(t,e),DR=t=>({state:e,dispatch:n})=>{const r=Sn(t,e.schema);return lj(r)(e,n)},PR=()=>({state:t,dispatch:e})=>lN(t,e);function Dd(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Hx(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 BR=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Dd(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Sn(t,r.schema)),l==="mark"&&(o=js(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,Hx(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(Hx(g.attrs,e))))})})}),d},zR=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),$R=()=>({tr:t,dispatch:e})=>{if(e){const n=new xr(t.doc);t.setSelection(n)}return!0},FR=()=>({state:t,dispatch:e})=>sN(t,e),UR=()=>({state:t,dispatch:e})=>aN(t,e),HR=()=>({state:t,dispatch:e})=>ej(t,e),WR=()=>({state:t,dispatch:e})=>rj(t,e),qR=()=>({state:t,dispatch:e})=>nj(t,e);function wg(t,e,n={},r={}){return bl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var VR=(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=wg(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 eC(t,e){const n=js(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 hv(t,e){const n=new Kg(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function KR(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 $u(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function tC(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function nC(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 Pd(t){return e=>nC(e.$from,t)}function nt(t,e,n){return t.config[e]===void 0&&t.parent?nt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?nt(t.parent,e,n):null}):t.config[e]}function pv(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=nt(e,"addExtensions",n);return r?[e,...pv(r())]:e}).flat(10)}function mv(t,e){const n=io.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function rC(t){return typeof t=="function"}function Bt(t,e=void 0,...n){return rC(t)?e?t.bind(e)(...n):t(...n):t}function GR(t={}){return Object.keys(t).length===0&&t.constructor===Object}function ea(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 sC(t){const e=[],{nodeExtensions:n,markExtensions:r}=ea(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=nt(o,"addGlobalAttributes",l);if(!d)return;d().forEach(h=>{h.types.forEach(m=>{Object.entries(h.attributes).forEach(([g,y])=>{e.push({type:m,name:g,attribute:{...i,...y}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},d=nt(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 Lt(...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(y=>y.trim());f.set(m,g)}),l.forEach(h=>{const[m,g]=h.split(":").map(y=>y.trim());f.set(m,g)}),r[s]=Array.from(f.entries()).map(([h,m])=>`${h}: ${m}`).join("; ")}else r[s]=i}),r},{})}function ta(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)=>Lt(n,r),{})}function JR(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Wx(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):JR(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function qx(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&GR(n)?!1:n!=null))}function Vx(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 YR(t,e){var n;const r=sC(t),{nodeExtensions:s,markExtensions:i}=ea(t),o=(n=s.find(f=>nt(f,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(f=>{const h=r.filter(E=>E.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((E,C)=>{const A=nt(C,"extendNodeSchema",m);return{...E,...A?A(f):{}}},{}),y=qx({...g,content:Bt(nt(f,"content",m)),marks:Bt(nt(f,"marks",m)),group:Bt(nt(f,"group",m)),inline:Bt(nt(f,"inline",m)),atom:Bt(nt(f,"atom",m)),selectable:Bt(nt(f,"selectable",m)),draggable:Bt(nt(f,"draggable",m)),code:Bt(nt(f,"code",m)),whitespace:Bt(nt(f,"whitespace",m)),linebreakReplacement:Bt(nt(f,"linebreakReplacement",m)),defining:Bt(nt(f,"defining",m)),isolating:Bt(nt(f,"isolating",m)),attrs:Object.fromEntries(h.map(Vx))}),b=Bt(nt(f,"parseHTML",m));b&&(y.parseDOM=b.map(E=>Wx(E,h)));const x=nt(f,"renderHTML",m);x&&(y.toDOM=E=>x({node:E,HTMLAttributes:ta(E,h)}));const w=nt(f,"renderText",m);return w&&(y.toText=w),[f.name,y]})),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,E)=>{const C=nt(E,"extendMarkSchema",m);return{...w,...C?C(f):{}}},{}),y=qx({...g,inclusive:Bt(nt(f,"inclusive",m)),excludes:Bt(nt(f,"excludes",m)),group:Bt(nt(f,"group",m)),spanning:Bt(nt(f,"spanning",m)),code:Bt(nt(f,"code",m)),attrs:Object.fromEntries(h.map(Vx))}),b=Bt(nt(f,"parseHTML",m));b&&(y.parseDOM=b.map(w=>Wx(w,h)));const x=nt(f,"renderHTML",m);return x&&(y.toDOM=w=>x({mark:w,HTMLAttributes:ta(w,h)})),[f.name,y]}));return new DE({topNode:o,nodes:l,marks:d})}function XR(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Fu(t){return t.sort((n,r)=>{const s=nt(n,"priority")||100,i=nt(r,"priority")||100;return s>i?-1:s<i?1:0})}function iC(t){const e=Fu(pv(t)),n=XR(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 oC(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 y=o==null?void 0:o[d.type.name];if(y)return h&&(l+=y({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 QR(t,e){const n={from:0,to:t.content.size};return oC(t,n,e)}function aC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ZR(t,e){const n=Sn(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 lC(t,e){const n=Dd(typeof e=="string"?e:e.name,t.schema);return n==="node"?ZR(t,e):n==="mark"?eC(t,e):{}}function eI(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 tI(t){const e=eI(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 gv(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}})})}),tI(r)}function vv(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=fv(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 nI=(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 qc(t,e){return e.nodes[t]||e.marks[t]||null}function wu(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 rI=(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 kg(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?js(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>zu(m.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:m,$to:g})=>{const y=m.pos,b=g.pos;t.doc.nodesBetween(y,b,(x,w)=>{if(!x.isText&&!x.marks.length)return;const E=Math.max(y,w),C=Math.min(b,w+x.nodeSize),A=C-E;o+=A,l.push(...x.marks.map(T=>({mark:T,from:E,to:C})))})}),o===0)return!1;const d=l.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>zu(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 sI(t,e,n={}){if(!e)return gi(t,null,n)||kg(t,null,n);const r=Dd(e,t.schema);return r==="node"?gi(t,e,n):r==="mark"?kg(t,e,n):!1}var iI=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Pd(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)},oI=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Kx(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Gx(t,e){const{nodeExtensions:n}=ea(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=Bt(nt(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Bd(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&&(Bd(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function cC(t){return t instanceof rt}var uC=class dC{constructor(e){this.position=e}static fromJSON(e){return new dC(e.position)}toJSON(){return{position:this.position}}};function aI(t,e){const n=e.mapping.mapResult(t.position);return{position:new uC(n.pos),mapResult:n}}function lI(t){return new uC(t)}function cI(t,e,n){var r;const{selection:s}=e;let i=null;if(YN(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 y=!g||g.type.allowsMarkType(n),b=!!n.isInSet(h.marks)||!h.marks.some(x=>x.type.excludes(n));f=y&&b}return!f}),f})}var uI=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,d=js(t,r.schema);if(s)if(o){const f=eC(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,y)=>{const b=Math.max(y,h),x=Math.min(y+g.nodeSize,m);g.marks.find(E=>E.type===d)?g.marks.forEach(E=>{d===E.type&&n.addMark(b,x,d.create({...E.attrs,...e}))}):n.addMark(b,x,d.create(e))})});return cI(r,n,d)},dI=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),fI=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Sn(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})=>lx(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>lx(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},hI=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=qi(t,0,r.content.size),i=rt.create(r,s);e.setSelection(i)}return!0},pI=(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},mI=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=it.atStart(r).from,l=it.atEnd(r).to,d=qi(s,o,l),f=qi(i,o,l),h=it.create(r,d,f);e.setSelection(h)}return!0},gI=t=>({state:e,dispatch:n})=>{const r=Sn(t,e.schema);return dj(r)(e,n)};function Jx(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 vI=({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=wu(f,l.node().type.name,l.node().attrs);if(i instanceof rt&&i.node.isBlock)return!l.parentOffset||!Ms(o,l.pos)?!1:(r&&(t&&Jx(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:KR(l.node(-1).contentMatchAt(l.indexAfter(-1)));let y=m&&g?[{type:g,attrs:h}]:void 0,b=Ms(e.doc,e.mapping.map(l.pos),1,y);if(!y&&!b&&Ms(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(b=!0,y=g?[{type:g,attrs:h}]:void 0),r){if(b&&(i instanceof it&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,y),g&&!m&&!l.parentOffset&&l.parent.type!==g)){const x=e.mapping.map(l.before()),w=e.doc.resolve(x);l.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&Jx(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return b},yI=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Sn(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 E=be.empty;const C=d.index(-1)?1:d.index(-2)?2:3;for(let B=d.depth-C;B>=d.depth-3;B-=1)E=be.from(d.node(B).copy(E));const A=d.indexAfter(-1)<d.node(-2).childCount?1:d.indexAfter(-2)<d.node(-3).childCount?2:3,T={...wu(g,d.node().type.name,d.node().attrs),...e},_=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;E=E.append(be.from(l.createAndFill(null,_)||void 0));const O=d.before(d.depth-(C-1));n.replace(O,d.after(-A),new Pe(E,4-C,0));let R=-1;n.doc.nodesBetween(O,n.doc.content.size,(B,D)=>{if(R>-1)return!1;B.isTextblock&&B.content.size===0&&(R=D+1)}),R>-1&&n.setSelection(it.near(n.doc.resolve(R))),n.scrollIntoView()}return!0}const y=f.pos===d.end()?m.contentMatchAt(0).defaultType:null,b={...wu(g,m.type.name,m.attrs),...e},x={...wu(g,d.node().type.name,d.node().attrs),...e};n.delete(d.pos,f.pos);const w=y?[{type:l,attrs:b},{type:y,attrs:x}]:[{type:l,attrs:b}];if(!Ms(n.doc,d.pos,2))return!1;if(s){const{selection:E,storedMarks:C}=r,{splittableMarks:A}=i.extensionManager,T=C||E.$to.parentOffset&&E.$from.marks();if(n.split(d.pos,2,w).scrollIntoView(),!T||!s)return!0;const _=T.filter(O=>A.includes(O.type.name));n.ensureMarks(_)}return!0},np=(t,e)=>{const n=Pd(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)&&yi(t.doc,n.pos)&&t.join(n.pos),!0},rp=(t,e)=>{const n=Pd(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)&&yi(t.doc,r)&&t.join(r),!0},bI=(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,y=Sn(t,o.schema),b=Sn(e,o.schema),{selection:x,storedMarks:w}=o,{$from:E,$to:C}=x,A=E.blockRange(C),T=w||x.$to.parentOffset&&x.$from.marks();if(!A)return!1;const _=Pd(O=>Gx(O.type.name,m))(x);if(A.depth>=1&&_&&A.depth-_.depth<=1){if(_.node.type===y)return f.liftListItem(b);if(Gx(_.node.type.name,m)&&y.validContent(_.node.content)&&l)return d().command(()=>(i.setNodeMarkup(_.pos,y),!0)).command(()=>np(i,y)).command(()=>rp(i,y)).run()}return!n||!T||!l?d().command(()=>h().wrapInList(y,r)?!0:f.clearNodes()).wrapInList(y,r).command(()=>np(i,y)).command(()=>rp(i,y)).run():d().command(()=>{const O=h().wrapInList(y,r),R=T.filter(B=>g.includes(B.type.name));return i.ensureMarks(R),O?!0:f.clearNodes()}).wrapInList(y,r).command(()=>np(i,y)).command(()=>rp(i,y)).run()},xI=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=js(t,r.schema);return kg(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},wI=(t,e,n={})=>({state:r,commands:s})=>{const i=Sn(t,r.schema),o=Sn(e,r.schema),l=gi(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})},kI=(t,e={})=>({state:n,commands:r})=>{const s=Sn(t,n.schema);return gi(n,s,e)?r.lift(s):r.wrapIn(s,e)},SI=()=>({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},EI=()=>({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},NI=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,d=js(t,r.schema),{$from:f,empty:h,ranges:m}=l;if(!s)return!0;if(h&&o){let{from:g,to:y}=l;const b=(i=f.marks().find(w=>w.type===d))==null?void 0:i.attrs,x=fv(f,d,b);x&&(g=x.from,y=x.to),n.removeMark(g,y,d)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,d)});return n.removeStoredMark(d),!0},CI=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},_I=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Dd(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Sn(t,r.schema)),l==="mark"&&(o=js(t,r.schema));let d=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let g,y,b,x;n.selection.empty?r.doc.nodesBetween(h,m,(w,E)=>{i&&i===w.type&&(d=!0,b=Math.max(E,h),x=Math.min(E+w.nodeSize,m),g=E,y=w)}):r.doc.nodesBetween(h,m,(w,E)=>{E<h&&i&&i===w.type&&(d=!0,b=Math.max(E,h),x=Math.min(E+w.nodeSize,m),g=E,y=w),E>=h&&E<=m&&(i&&i===w.type&&(d=!0,s&&n.setNodeMarkup(E,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(C=>{if(o===C.type&&(d=!0,s)){const A=Math.max(E,h),T=Math.min(E+w.nodeSize,m);n.addMark(A,T,o.create({...C.attrs,...e}))}}))}),y&&(g!==void 0&&s&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(w=>{o===w.type&&s&&n.addMark(b,x,o.create({...w.attrs,...e}))}))}),d},TI=(t,e={})=>({state:n,dispatch:r})=>{const s=Sn(t,n.schema);return sj(s,e)(n,r)},MI=(t,e={})=>({state:n,dispatch:r})=>{const s=Sn(t,n.schema);return ij(s,e)(n,r)},AI=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={}}},Ml=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},jI=(t,e)=>{if(dv(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 Vc(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=rI(f)+i;return o.forEach(g=>{if(h)return;const y=jI(m,g.find);if(!y)return;const b=d.state.tr,x=Id({state:d.state,transaction:b}),w={from:r-(y[0].length-i.length),to:s},{commands:E,chain:C,can:A}=new Ld({editor:n,state:x});g.handler({state:x,range:w,match:y,commands:E,chain:C,can:A})===null||!b.steps.length||(g.undoable&&b.setMeta(l,{transform:b,from:r,to:s,text:i}),d.dispatch(b),h=!0)}),h}function OI(t){const{editor:e,rules:n}=t,r=new Pt({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(be.from(h),o.schema);const{from:m}=d,g=m+h.length;Vc({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 Vc({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Vc({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?Vc({editor:e,from:o.pos,to:o.pos,text:`
|
|
60
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function RI(t){return Object.prototype.toString.call(t).slice(8,-1)}function Kc(t){return RI(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function fC(t,e){const n={...t};return Kc(t)&&Kc(e)&&Object.keys(e).forEach(r=>{Kc(e[r])&&Kc(t[r])?n[r]=fC(t[r],e[r]):n[r]=e[r]}),n}var yv=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{...Bt(nt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Bt(nt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>fC(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}},Gr=class hC extends yv{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new hC(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 II(t){return typeof t=="number"}var LI=class{constructor(t){this.find=t.find,this.handler=t.handler}},DI=(t,e,n)=>{if(dv(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 PI(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:d,chain:f,can:h}=new Ld({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(y,b)=>{var x,w,E,C,A;if((w=(x=y.type)==null?void 0:x.spec)!=null&&w.code||!(y.isText||y.isTextblock||y.isInline))return;const T=(A=(C=(E=y.content)==null?void 0:E.size)!=null?C:y.nodeSize)!=null?A:0,_=Math.max(r,b),O=Math.min(s,b+T);if(_>=O)return;const R=y.isText?y.text||"":y.textBetween(_-b,O-b,void 0,"");DI(R,i.find,o).forEach(D=>{if(D.index===void 0)return;const U=_+D.index+1,Q=U+D[0].length,P={from:n.tr.mapping.map(U),to:n.tr.mapping.map(Q)},W=i.handler({state:n,range:P,match:D,commands:d,chain:f,can:h,pasteEvent:o,dropEvent:l});m.push(W)})}),m.every(y=>y!==null)}var Gc=null,BI=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function zI(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:y,pasteEvt:b})=>{const x=h.tr,w=Id({state:h,transaction:x});if(!(!PI({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:b,dropEvent:l})||!x.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,x}};return n.map(h=>new Pt({view(m){const g=b=>{var x;r=(x=m.dom.parentElement)!=null&&x.contains(b.target)?m.dom.parentElement:null,r&&(Gc=e)},y=()=>{Gc&&(Gc=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",y),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",y)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(i=r===m.dom.parentElement,l=g,!i){const y=Gc;y!=null&&y.isEditable&&setTimeout(()=>{const b=y.state.selection;b&&y.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(m,g)=>{var y;const b=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,s=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const b=m[0],x=b.getMeta("uiEvent")==="paste"&&!s,w=b.getMeta("uiEvent")==="drop"&&!i,E=b.getMeta("applyPasteRules"),C=!!E;if(!x&&!w&&!C)return;if(C){let{text:_}=E;typeof _=="string"?_=_:_=mv(be.from(_),y.schema);const{from:O}=E,R=O+_.length,B=BI(_);return d({rule:h,state:y,from:O,to:{b:R},pasteEvt:B})}const A=g.doc.content.findDiffStart(y.doc.content),T=g.doc.content.findDiffEnd(y.doc.content);if(!(!II(A)||!T||A===T.b))return d({rule:h,state:y,from:A,to:T,pasteEvt:o})}}))}var zd=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=iC(t),this.schema=YR(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:qc(e.name,this.schema)},r=nt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Fu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:qc(r.name,this.schema)},i=[],o=nt(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&nt(r,"exitable",s)&&(l.ArrowRight=()=>Gr.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,b])=>[y,()=>b({editor:t})]));l={...l,...g}}const d=tR(l);i.push(d);const f=nt(r,"addInputRules",s);if(Kx(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const y=OI({editor:t,rules:g}),b=Array.isArray(y)?y:[y];i.push(...b)}}const h=nt(r,"addPasteRules",s);if(Kx(r,t.options.enablePasteRules)&&h){const g=h();if(g&&g.length){const y=zI({editor:t,rules:g});i.push(...y)}}const m=nt(r,"addProseMirrorPlugins",s);if(m){const g=m();i.push(...g)}return i})}get attributes(){return sC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=ea(this.extensions);return Object.fromEntries(e.filter(n=>!!nt(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:Sn(n.name,this.schema)},i=nt(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(d,f,h,m,g)=>{const y=ta(d,r);return o({node:d,view:f,getPos:h,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:y})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return Fu([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:qc(s.name,this.schema)},o=nt(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=ea(this.extensions);return Object.fromEntries(e.filter(n=>!!nt(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:js(n.name,this.schema)},i=nt(n,"addMarkView",s);if(!i)return[];const o=(l,d,f)=>{const h=ta(l,r);return i()({mark:l,view:d,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{eL(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:qc(e.name,this.schema)};e.type==="mark"&&((n=Bt(nt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=nt(e,"onBeforeCreate",r),i=nt(e,"onCreate",r),o=nt(e,"onUpdate",r),l=nt(e,"onSelectionUpdate",r),d=nt(e,"onTransaction",r),f=nt(e,"onFocus",r),h=nt(e,"onBlur",r),m=nt(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)})}};zd.resolve=iC;zd.sort=Fu;zd.flatten=pv;var $I={};uv($I,{ClipboardTextSerializer:()=>mC,Commands:()=>gC,Delete:()=>vC,Drop:()=>yC,Editable:()=>bC,FocusEvents:()=>wC,Keymap:()=>kC,Paste:()=>SC,Tabindex:()=>EC,TextDirection:()=>NC,focusEventsPluginKey:()=>xC});var Ot=class pC extends yv{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new pC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},mC=Ot.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Pt({key:new Ht("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=aC(n);return oC(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:d})}}})]}}),gC=Ot.create({name:"commands",addCommands(){return{...GN}}}),vC=Ot.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=hv(t.before,[t,...e]);gv(h).forEach(y=>{h.mapping.mapResult(y.oldRange.from).deletedAfter&&h.mapping.mapResult(y.oldRange.to).deletedBefore&&h.before.nodesBetween(y.oldRange.from,y.oldRange.to,(b,x)=>{const w=x+b.nodeSize-2,E=y.oldRange.from<=x&&w<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:x,to:w,newFrom:h.mapping.map(x),newTo:h.mapping.map(w),deletedRange:y.oldRange,newRange:y.newRange,partial:!E,editor:this.editor,transaction:t,combinedTransform:h})})});const g=h.mapping;h.steps.forEach((y,b)=>{var x,w;if(y instanceof Vr){const E=g.slice(b).map(y.from,-1),C=g.slice(b).map(y.to),A=g.invert().map(E,-1),T=g.invert().map(C),_=(x=h.doc.nodeAt(E-1))==null?void 0:x.marks.some(R=>R.eq(y.mark)),O=(w=h.doc.nodeAt(C))==null?void 0:w.marks.some(R=>R.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:A,to:T},newRange:{from:E,to:C},partial:!!(O||_),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()}}),yC=Ot.create({name:"drop",addProseMirrorPlugins(){return[new Pt({key:new Ht("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),bC=Ot.create({name:"editable",addProseMirrorPlugins(){return[new Pt({key:new Ht("editable"),props:{editable:()=>this.editor.options.editable}})]}}),xC=new Ht("focusEvents"),wC=Ot.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Pt({key:xC,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=Ot.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:y}=m,b=m.parent.isTextblock&&g>0?l.doc.resolve(g-1):m,x=b.parent.type.spec.isolating,w=m.pos-m.parentOffset,E=x&&b.parent.childCount===1?w===m.pos:ht.atStart(f).from===g;return!h||!y.type.isTextblock||y.textContent.length||!E||E&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return yl()||ZN()?i:s},addProseMirrorPlugins(){return[new Pt({key:new Ht("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(x=>x.getMeta("composition")))return;const r=t.some(x=>x.docChanged)&&!e.doc.eq(n.doc),s=t.some(x=>x.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,d=ht.atStart(e.doc).from,f=ht.atEnd(e.doc).to;if(i||!(o===d&&l===f)||!Bd(n.doc))return;const g=n.tr,y=Id({state:n,transaction:g}),{commands:b}=new Ld({editor:this.editor,state:y});if(b.clearNodes(),!!g.steps.length)return g}})]}}),SC=Ot.create({name:"paste",addProseMirrorPlugins(){return[new Pt({key:new Ht("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),EC=Ot.create({name:"tabindex",addProseMirrorPlugins(){return[new Pt({key:new Ht("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),NC=Ot.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=ea(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 Pt({key:new Ht("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),FI=class Ya{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 Ya(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 Ya(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 Ya(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 Ya(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)}},UI=`.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 HI(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 WI=class extends AI{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:aI,createMappablePosition:lI},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=XN(e,this.options.autofocus);this.editorState=Wo.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=HI(UI,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=rC(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?[bC,mC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),gC,wC,kC,EC,yC,SC,vC,NC.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 zd(r,this)}createCommandManager(){this.commandManager=new Ld({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=wg(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=wg(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 KN(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 lC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return sI(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 QR(this.state.doc,{blockSeparator:e,textSerializers:{...aC(this.schema),...n}})}get isEmpty(){return Bd(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 FI(e,this)}get $doc(){return this.$pos(0)}};function no(t){return new Ml({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Bt(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(vv(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(x=>x===t.type&&x!==y.mark.type)).filter(y=>y.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 CC(t){return new Ml({find:t.find,handler:({state:e,range:n,match:r})=>{const s=Bt(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 Sg(t){return new Ml({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=Bt(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 pn(t){return new Ml({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 na(t){return new Ml({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=Bt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),d=o.doc.resolve(n.from).blockRange(),f=d&&Vg(d,t.type,i);if(!f)return null;if(o.wrap(d,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:y}=t.editor.extensionManager,b=g||m.$to.parentOffset&&m.$from.marks();if(b){const x=b.filter(w=>y.includes(w.type.name));o.ensureMarks(x)}}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&&yi(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&o.join(n.from-1)},undoable:t.undoable})}var qI=t=>"touches"in t,VI=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,qI(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 KI(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof rt){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 GI={};uv(GI,{createAtomBlockMarkdownSpec:()=>JI,createBlockMarkdownSpec:()=>YI,createInlineMarkdownSpec:()=>ZI,parseAttributes:()=>bv,parseIndentedBlocks:()=>Eg,renderNestedMarkdownContent:()=>wv,serializeAttributes:()=>xv});function bv(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),y=n[g];y&&(e[f]=y.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 xv(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 JI(t){const{nodeName:e,name:n,parseAttributes:r=bv,serializeAttributes:s=xv,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"),y=(m=h.match(g))==null?void 0:m.index;return y!==void 0?y:-1},tokenize(h,m,g){const y=new RegExp(`^:::${d}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),b=h.match(y);if(!b)return;const x=b[1]||"",w=r(x);if(!o.find(C=>!(C in w)))return{type:e,raw:b[0],attributes:w}}},renderMarkdown:h=>{const m=f(h.attrs||{}),g=s(m),y=g?` {${g}}`:"";return`:::${d}${y} :::`}}}function YI(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=bv,serializeAttributes:i=xv,defaultAttributes:o={},content:l="block",allowedAttributes:d}=t,f=n||e,h=m=>{if(!d)return m;const g={};return d.forEach(y=>{y in m&&(g[y]=m[y])}),g};return{parseMarkdown:(m,g)=>{let y;if(r){const x=r(m);y=typeof x=="string"?[{type:"text",text:x}]:x}else l==="block"?y=g.parseChildren(m.tokens||[]):y=g.parseInline(m.tokens||[]);const b={...o,...m.attributes};return g.createNode(e,b,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${f}`,"m"),b=(g=m.match(y))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(m,g,y){var b;const x=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(x);if(!w)return;const[E,C=""]=w,A=s(C);let T=1;const _=E.length;let O="";const R=/^:::([\w-]*)(\s.*)?/gm,B=m.slice(_);for(R.lastIndex=0;;){const D=R.exec(B);if(D===null)break;const U=D.index,Q=D[1];if(!((b=D[2])!=null&&b.endsWith(":::"))){if(Q)T+=1;else if(T-=1,T===0){const P=B.slice(0,U);O=P.trim();const W=m.slice(0,_+U+D[0].length);let $=[];if(O)if(l==="block")for($=y.blockTokens(P),$.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=y.inlineTokens(H.text))});$.length>0;){const H=$[$.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))$.pop();else break}else $=y.inlineTokens(O);return{type:e,raw:W,attributes:A,content:O,tokens:$}}}}}},renderMarkdown:(m,g)=>{const y=h(m.attrs||{}),b=i(y),x=b?` {${b}}`:"",w=g.renderChildren(m.content||[],`
|
|
133
|
-
|
|
134
|
-
`);return`:::${f}${x}
|
|
135
|
-
|
|
136
|
-
${w}
|
|
137
|
-
|
|
138
|
-
:::`}}}function XI(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 QI(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function ZI(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=XI,serializeAttributes:i=QI,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:d}=t,f=n||e,h=g=>{if(!d)return g;const y={};return d.forEach(b=>{const x=typeof b=="string"?b:b.name,w=typeof b=="string"?void 0:b.skipIfDefault;if(x in g){const E=g[x];if(w!==void 0&&E===w)return;y[x]=E}}),y},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const b={...o,...g.attributes};if(l)return y.createNode(e,b);const x=r?r(g):g.content||"";return x?y.createNode(e,b,[y.createTextNode(x)]):y.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=l?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),b=g.match(y),x=b==null?void 0:b.index;return x!==void 0?x:-1},tokenize(g,y,b){const x=l?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(x);if(!w)return;let E="",C="";if(l){const[,T]=w;C=T}else{const[,T,_]=w;C=T,E=_||""}const A=s(C.trim());return{type:e,raw:w[0],content:E.trim(),attributes:A}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(E=>E.type==="text").map(E=>E.text).join(""));const b=h(g.attrs||{}),x=i(b),w=x?` ${x}`:"";return l?`[${f}${w}]`:`[${f}${w}]${y}[/${f}]`}}}function Eg(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],y=g.match(e.itemPattern);if(!y){if(d.length>0)break;if(g.trim()===""){h+=1,f=`${f}${g}
|
|
140
|
-
`;continue}else return}const b=e.extractItemData(y),{indentLevel:x,mainContent:w}=b;f=`${f}${g}
|
|
141
|
-
`;const E=[w];for(h+=1;h<l.length;){const _=l[h];if(_.trim()===""){const R=l.slice(h+1).findIndex(U=>U.trim()!=="");if(R===-1)break;if((((s=(r=l[h+1+R].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>x){E.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)>x)E.push(_),f=`${f}${_}
|
|
143
|
-
`,h+=1;else break}let C;const A=E.slice(1);if(A.length>0){const _=A.map(O=>O.slice(x+m)).join(`
|
|
144
|
-
`);_.trim()&&(e.customNestedParser?C=e.customNestedParser(_):C=n.blockTokens(_))}const T=e.createToken(b,C);d.push(T)}if(d.length!==0)return{items:d,raw:f}}function wv(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 eL(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(y=>{if(y!==o)return!1;m=y}),!m)return;let g=!1;if(Object.keys(n).forEach(y=>{n[y]!==m.attrs[y]&&(g=!0)}),g){const y=t.type.create({...t.attrs,...n});i.removeMark(f,h,t.type),i.addMark(f,h,y)}}),i.docChanged&&e.view.dispatch(i)}var mn=class _C extends yv{constructor(){super(...arguments),this.type="node"}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)}},tL=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 C=this.dom.getBoundingClientRect(),A=h.getBoundingClientRect(),T=(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=A.x-C.x+T,g=A.y-C.y+_}const y=this.dom.cloneNode(!0);try{const C=this.dom.getBoundingClientRect();y.style.width=`${Math.round(C.width)}px`,y.style.height=`${Math.round(C.height)}px`,y.style.boxSizing="border-box",y.style.pointerEvents="none"}catch{}let b=null;try{b=document.createElement("div"),b.style.position="absolute",b.style.top="-9999px",b.style.left="-9999px",b.style.pointerEvents="none",b.appendChild(y),document.body.appendChild(b),(l=t.dataTransfer)==null||l.setDragImage(y,m,g)}finally{b&&setTimeout(()=>{try{b==null||b.remove()}catch{}},0)}const x=this.getPos();if(typeof x!="number")return;const w=rt.create(d.state.doc,x),E=d.state.tr.setSelection(w);d.dispatch(E)}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=rt.isSelectable(this.node),m=t.type==="copy",g=t.type==="paste",y=t.type==="cut",b=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&&b){const x=n.closest("[data-drag-handle]");x&&(this.dom===x||this.dom.contains(x))&&(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||y||b&&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"&&(yl()||xg())&&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 vi(t){return new LI({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=Bt(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(vv(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.from&&o.delete(n.from+h,m),f=n.from+h+l.length,o.addMark(n.from+h,f,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:nL,getOwnPropertySymbols:rL}=Object,{hasOwnProperty:sL}=Object.prototype;function sp(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function Jc(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 iL(t){return t!=null?t[Symbol.toStringTag]:void 0}function Yx(t){return nL(t).concat(rL(t))}const oL=Object.hasOwn||((t,e)=>sL.call(t,e));function oo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const aL="__v",lL="__o",cL="_owner",{getOwnPropertyDescriptor:Xx,keys:Qx}=Object;function uL(t,e){return t.byteLength===e.byteLength&&Uu(new Uint8Array(t),new Uint8Array(e))}function dL(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 fL(t,e){return t.byteLength===e.byteLength&&Uu(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function hL(t,e){return oo(t.getTime(),e.getTime())}function pL(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function mL(t,e){return t===e}function Zx(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,y=l.value;if(n.equals(g[0],y[0],d,m,t,e,n)&&n.equals(g[1],y[1],g[0],y[0],t,e,n)){h=s[m]=!0;break}m++}if(!h)return!1;d++}return!0}const gL=oo;function vL(t,e,n){const r=Qx(t);let s=r.length;if(Qx(e).length!==s)return!1;for(;s-- >0;)if(!TC(t,e,n,r[s]))return!1;return!0}function Ua(t,e,n){const r=Yx(t);let s=r.length;if(Yx(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!TC(t,e,n,i)||(o=Xx(t,i),l=Xx(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function yL(t,e){return oo(t.valueOf(),e.valueOf())}function bL(t,e){return t.source===e.source&&t.flags===e.flags}function e1(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 Uu(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 xL(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 TC(t,e,n,r){return(r===cL||r===lL||r===aL)&&(t.$$typeof||e.$$typeof)?!0:oL(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const wL="[object ArrayBuffer]",kL="[object Arguments]",SL="[object Boolean]",EL="[object DataView]",NL="[object Date]",CL="[object Error]",_L="[object Map]",TL="[object Number]",ML="[object Object]",AL="[object RegExp]",jL="[object Set]",OL="[object String]",RL={"[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},IL="[object URL]",LL=Object.prototype.toString;function DL({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:y,unknownTagComparators:b}){return function(w,E,C){if(w===E)return!0;if(w==null||E==null)return!1;const A=typeof w;if(A!==typeof E)return!1;if(A!=="object")return A==="number"?l(w,E,C):A==="function"?i(w,E,C):!1;const T=w.constructor;if(T!==E.constructor)return!1;if(T===Object)return d(w,E,C);if(Array.isArray(w))return e(w,E,C);if(T===Date)return r(w,E,C);if(T===RegExp)return h(w,E,C);if(T===Map)return o(w,E,C);if(T===Set)return m(w,E,C);const _=LL.call(w);if(_===NL)return r(w,E,C);if(_===AL)return h(w,E,C);if(_===_L)return o(w,E,C);if(_===jL)return m(w,E,C);if(_===ML)return typeof w.then!="function"&&typeof E.then!="function"&&d(w,E,C);if(_===IL)return y(w,E,C);if(_===CL)return s(w,E,C);if(_===kL)return d(w,E,C);if(RL[_])return g(w,E,C);if(_===wL)return t(w,E,C);if(_===EL)return n(w,E,C);if(_===SL||_===TL||_===OL)return f(w,E,C);if(b){let O=b[_];if(!O){const R=iL(w);R&&(O=b[R])}if(O)return O(w,E,C)}return!1}}function PL({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:uL,areArraysEqual:n?Ua:dL,areDataViewsEqual:fL,areDatesEqual:hL,areErrorsEqual:pL,areFunctionsEqual:mL,areMapsEqual:n?sp(Zx,Ua):Zx,areNumbersEqual:gL,areObjectsEqual:n?Ua:vL,arePrimitiveWrappersEqual:yL,areRegExpsEqual:bL,areSetsEqual:n?sp(e1,Ua):e1,areTypedArraysEqual:n?sp(Uu,Ua):Uu,areUrlsEqual:xL,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=Jc(r.areArraysEqual),i=Jc(r.areMapsEqual),o=Jc(r.areObjectsEqual),l=Jc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function BL(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function zL({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 $L=xi();xi({strict:!0});xi({circular:!0});xi({circular:!0,strict:!0});xi({createInternalComparator:()=>oo});xi({strict:!0,createInternalComparator:()=>oo});xi({circular:!0,createInternalComparator:()=>oo});xi({circular:!0,createInternalComparator:()=>oo,strict:!0});function xi(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=PL(t),o=DL(i),l=n?n(o):BL(o);return zL({circular:e,comparator:o,createState:r,equals:l,strict:s})}var ip={exports:{}},op={};/**
|
|
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 t1;function FL(){if(t1)return op;t1=1;var t=Nl(),e=bE();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 op.useSyncExternalStoreWithSelector=function(f,h,m,g,y){var b=i(null);if(b.current===null){var x={hasValue:!1,value:null};b.current=x}else x=b.current;b=l(function(){function E(O){if(!C){if(C=!0,A=O,O=g(O),y!==void 0&&x.hasValue){var R=x.value;if(y(R,O))return T=R}return T=O}if(R=T,r(A,O))return R;var B=g(O);return y!==void 0&&y(R,B)?(A=O,R):(A=O,T=B)}var C=!1,A,T,_=m===void 0?null:m;return[function(){return E(h())},_===null?void 0:function(){return E(_())}]},[h,m,g,y]);var w=s(f,b[0],b[1]);return o(function(){x.hasValue=!0,x.value=w},[w]),d(w),w},op}var n1;function UL(){return n1||(n1=1,ip.exports=FL()),ip.exports}var HL=UL(),WL=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},qL=({contentComponent:t})=>{const e=xE.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return u.jsx(u.Fragment,{children:Object.values(e)})};function VL(){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]:YM.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 KL=class extends pi.Component{constructor(t){var e;super(t),this.editorContentRef=pi.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=VL(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return u.jsxs(u.Fragment,{children:[u.jsx("div",{ref:WL(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&u.jsx(qL,{contentComponent:t.contentComponent})]})}},GL=k.forwardRef((t,e)=>{const n=pi.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return pi.createElement(KL,{key:n,innerRef:e,...t})}),kv=pi.memo(GL),JL=typeof window<"u"?k.useLayoutEffect:k.useEffect,YL=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 XL(t){var e;const[n]=k.useState(()=>new YL(t.editor)),r=HL.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:$L);return JL(()=>n.watch(t.editor),[t.editor,n]),k.useDebugValue(r),r}var QL=!1,Ng=typeof window>"u",ZL=Ng||!!(typeof window<"u"&&window.next),eD=class MC{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?Ng||ZL?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 WI(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?MC.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 AC(t={},e=[]){const n=k.useRef(t);n.current=t;const[r]=k.useState(()=>new eD(n)),s=xE.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return k.useDebugValue(s),k.useEffect(r.onRender(e)),XL({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var jC=k.createContext({editor:null});jC.Consumer;var OC=k.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),tD=()=>k.useContext(OC),nD=pi.forwardRef((t,e)=>{const{onDragStart:n}=tD(),r=t.as||"div";return u.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function r1(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function s1(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function rD(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function sD(t){if(r1(t)||s1(t))return!0;if(rD(t)){const e=t.type;if(e)return r1(e)||s1(e)}return!1}function iD(){try{if(k.version)return parseInt(k.version.split(".")[0],10)>=19}catch{}return!1}var oD=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?yE.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=iD(),i=sD(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=u.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])})}};pi.createContext({markViewContentRef:()=>{}});var aD=class extends tL{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:k.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=k.memo(d=>u.jsx(OC.Provider,{value:r,children:k.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 oD(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=ta(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function lD(t,e){return n=>n.editor.contentComponent?new aD(t,n,e):{}}var Sv=k.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Sv.displayName="TiptapContext";var cD=()=>k.useContext(Sv);function RC({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=k.useMemo(()=>({editor:r}),[r]),i=k.useMemo(()=>({editor:r}),[r]);return u.jsx(jC.Provider,{value:i,children:u.jsx(Sv.Provider,{value:s,children:n})})}RC.displayName="Tiptap";function IC({...t}){const{editor:e}=cD();return u.jsx(kv,{editor:e,...t})}IC.displayName="Tiptap.Content";Object.assign(RC,{Content:IC});var uD=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,dD=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fD=Gr.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",Lt(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[no({find:uD,type:this.type})]},addPasteRules(){return[vi({find:dD,type:this.type})]}}),hD=fD,pD=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,mD=mn.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",Lt(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?``:``},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 VI({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 y=i();y!==void 0&&this.editor.chain().setNodeSelection(y).updateAttributes(this.name,{width:m,height:g}).run()},onUpdate:(m,g,y)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),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[CC({find:pD,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Ev=mD;const gD="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",vD="ελ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",Cg="numeric",_g="ascii",Tg="alpha",il="asciinumeric",Xa="alphanumeric",Mg="domain",LC="emoji",yD="scheme",bD="slashscheme",ap="whitespace";function xD(t,e){return t in e||(e[t]=[]),e[t]}function Vi(t,e,n){e[Cg]&&(e[il]=!0,e[Xa]=!0),e[_g]&&(e[il]=!0,e[Tg]=!0),e[il]&&(e[Xa]=!0),e[Tg]&&(e[Xa]=!0),e[Xa]&&(e[Mg]=!0),e[LC]&&(e[Mg]=!0);for(const r in e){const s=xD(r,n);s.indexOf(t)<0&&s.push(t)}}function wD(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function dr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}dr.groups={};dr.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||dr.groups;let s;return e&&e.j?s=e:(s=new dr(e),n&&r&&Vi(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||dr.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 dr,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new dr,i){if(r)if(o.t&&typeof o.t=="string"){const d=Object.assign(wD(o.t,r),n);Vi(i,d,r)}else n&&Vi(i,n,r);o.t=i}return s.j[t]=o,o}};const St=(t,e,n,r,s)=>t.ta(e,n,r,s),dn=(t,e,n,r,s)=>t.tr(e,n,r,s),i1=(t,e,n,r,s)=>t.ts(e,n,r,s),Te=(t,e,n,r,s)=>t.tt(e,n,r,s),Ss="WORD",Ag="UWORD",DC="ASCIINUMERICAL",PC="ALPHANUMERICAL",xl="LOCALHOST",jg="TLD",Og="UTLD",ku="SCHEME",Fo="SLASH_SCHEME",Nv="NUM",Rg="WS",Cv="NL",ol="OPENBRACE",al="CLOSEBRACE",Hu="OPENBRACKET",Wu="CLOSEBRACKET",qu="OPENPAREN",Vu="CLOSEPAREN",Ku="OPENANGLEBRACKET",Gu="CLOSEANGLEBRACKET",Ju="FULLWIDTHLEFTPAREN",Yu="FULLWIDTHRIGHTPAREN",Xu="LEFTCORNERBRACKET",Qu="RIGHTCORNERBRACKET",Zu="LEFTWHITECORNERBRACKET",ed="RIGHTWHITECORNERBRACKET",td="FULLWIDTHLESSTHAN",nd="FULLWIDTHGREATERTHAN",rd="AMPERSAND",sd="APOSTROPHE",id="ASTERISK",ri="AT",od="BACKSLASH",ad="BACKTICK",ld="CARET",oi="COLON",_v="COMMA",cd="DOLLAR",is="DOT",ud="EQUALS",Tv="EXCLAMATION",jr="HYPHEN",ll="PERCENT",dd="PIPE",fd="PLUS",hd="POUND",cl="QUERY",Mv="QUOTE",BC="FULLWIDTHMIDDLEDOT",Av="SEMI",as="SLASH",ul="TILDE",pd="UNDERSCORE",zC="EMOJI",md="SYM";var $C=Object.freeze({__proto__:null,ALPHANUMERICAL:PC,AMPERSAND:rd,APOSTROPHE:sd,ASCIINUMERICAL:DC,ASTERISK:id,AT:ri,BACKSLASH:od,BACKTICK:ad,CARET:ld,CLOSEANGLEBRACKET:Gu,CLOSEBRACE:al,CLOSEBRACKET:Wu,CLOSEPAREN:Vu,COLON:oi,COMMA:_v,DOLLAR:cd,DOT:is,EMOJI:zC,EQUALS:ud,EXCLAMATION:Tv,FULLWIDTHGREATERTHAN:nd,FULLWIDTHLEFTPAREN:Ju,FULLWIDTHLESSTHAN:td,FULLWIDTHMIDDLEDOT:BC,FULLWIDTHRIGHTPAREN:Yu,HYPHEN:jr,LEFTCORNERBRACKET:Xu,LEFTWHITECORNERBRACKET:Zu,LOCALHOST:xl,NL:Cv,NUM:Nv,OPENANGLEBRACKET:Ku,OPENBRACE:ol,OPENBRACKET:Hu,OPENPAREN:qu,PERCENT:ll,PIPE:dd,PLUS:fd,POUND:hd,QUERY:cl,QUOTE:Mv,RIGHTCORNERBRACKET:Qu,RIGHTWHITECORNERBRACKET:ed,SCHEME:ku,SEMI:Av,SLASH:as,SLASH_SCHEME:Fo,SYM:md,TILDE:ul,TLD:jg,UNDERSCORE:pd,UTLD:Og,UWORD:Ag,WORD:Ss,WS:Rg});const ws=/[a-z]/,Ha=new RegExp("\\p{L}","u"),lp=new RegExp("\\p{Emoji}","u"),ks=/\d/,cp=/\s/,o1="\r",up=`
|
|
156
|
-
`,kD="️",SD="",dp="";let Yc=null,Xc=null;function ED(t=[]){const e={};dr.groups=e;const n=new dr;Yc==null&&(Yc=a1(gD)),Xc==null&&(Xc=a1(vD)),Te(n,"'",sd),Te(n,"{",ol),Te(n,"}",al),Te(n,"[",Hu),Te(n,"]",Wu),Te(n,"(",qu),Te(n,")",Vu),Te(n,"<",Ku),Te(n,">",Gu),Te(n,"(",Ju),Te(n,")",Yu),Te(n,"「",Xu),Te(n,"」",Qu),Te(n,"『",Zu),Te(n,"』",ed),Te(n,"<",td),Te(n,">",nd),Te(n,"&",rd),Te(n,"*",id),Te(n,"@",ri),Te(n,"`",ad),Te(n,"^",ld),Te(n,":",oi),Te(n,",",_v),Te(n,"$",cd),Te(n,".",is),Te(n,"=",ud),Te(n,"!",Tv),Te(n,"-",jr),Te(n,"%",ll),Te(n,"|",dd),Te(n,"+",fd),Te(n,"#",hd),Te(n,"?",cl),Te(n,'"',Mv),Te(n,"/",as),Te(n,";",Av),Te(n,"~",ul),Te(n,"_",pd),Te(n,"\\",od),Te(n,"・",BC);const r=dn(n,ks,Nv,{[Cg]:!0});dn(r,ks,r);const s=dn(r,ws,DC,{[il]:!0}),i=dn(r,Ha,PC,{[Xa]:!0}),o=dn(n,ws,Ss,{[_g]:!0});dn(o,ks,s),dn(o,ws,o),dn(s,ks,s),dn(s,ws,s);const l=dn(n,Ha,Ag,{[Tg]:!0});dn(l,ws),dn(l,ks,i),dn(l,Ha,l),dn(i,ks,i),dn(i,ws),dn(i,Ha,i);const d=Te(n,up,Cv,{[ap]:!0}),f=Te(n,o1,Rg,{[ap]:!0}),h=dn(n,cp,Rg,{[ap]:!0});Te(n,dp,h),Te(f,up,d),Te(f,dp,h),dn(f,cp,h),Te(h,o1),Te(h,up),dn(h,cp,h),Te(h,dp,h);const m=dn(n,lp,zC,{[LC]:!0});Te(m,"#"),dn(m,lp,m),Te(m,kD,m);const g=Te(m,SD);Te(g,"#"),dn(g,lp,m);const y=[[ws,o],[ks,s]],b=[[ws,null],[Ha,l],[ks,i]];for(let x=0;x<Yc.length;x++)ei(n,Yc[x],jg,Ss,y);for(let x=0;x<Xc.length;x++)ei(n,Xc[x],Og,Ag,b);Vi(jg,{tld:!0,ascii:!0},e),Vi(Og,{utld:!0,alpha:!0},e),ei(n,"file",ku,Ss,y),ei(n,"mailto",ku,Ss,y),ei(n,"http",Fo,Ss,y),ei(n,"https",Fo,Ss,y),ei(n,"ftp",Fo,Ss,y),ei(n,"ftps",Fo,Ss,y),Vi(ku,{scheme:!0,ascii:!0},e),Vi(Fo,{slashscheme:!0,ascii:!0},e),t=t.sort((x,w)=>x[0]>w[0]?1:-1);for(let x=0;x<t.length;x++){const w=t[x][0],C=t[x][1]?{[yD]:!0}:{[bD]:!0};w.indexOf("-")>=0?C[Mg]=!0:ws.test(w)?ks.test(w)?C[il]=!0:C[_g]=!0:C[Cg]=!0,i1(n,w,w,C)}return i1(n,"localhost",xl,{ascii:!0}),n.jd=new dr(md),{start:n,tokens:Object.assign({groups:e},$C)}}function FC(t,e){const n=ND(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 ND(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 ei(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 dr(r),i.jr=s.slice(),t.j[d]=i),t=i}return i=new dr(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function a1(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 wl={defaultProtocol:"http",events:null,format:l1,formatHref:l1,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function jv(t,e=null){let n=Object.assign({},wl);t&&(n=Object.assign(n,t instanceof jv?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}jv.prototype={o:wl,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:wl[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function l1(t){return t}function UC(t,e){this.t="token",this.v=t,this.tk=e}UC.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=wl.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),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 $d(t,e){class n extends UC{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 c1=$d("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),u1=$d("text"),CD=$d("nl"),Qc=$d("url",{isLink:!0,toHref(t=wl.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==xl&&t[1].t===oi}}),Mr=t=>new dr(t);function _D({groups:t}){const e=t.domain.concat([rd,id,ri,od,ad,ld,cd,ud,jr,Nv,ll,dd,fd,hd,as,md,ul,pd]),n=[sd,oi,_v,is,Tv,ll,cl,Mv,Av,Ku,Gu,ol,al,Wu,Hu,qu,Vu,Ju,Yu,Xu,Qu,Zu,ed,td,nd],r=[rd,sd,id,od,ad,ld,cd,ud,jr,ol,al,ll,dd,fd,hd,cl,as,md,ul,pd],s=Mr(),i=Te(s,ul);St(i,r,i),St(i,t.domain,i);const o=Mr(),l=Mr(),d=Mr();St(s,t.domain,o),St(s,t.scheme,l),St(s,t.slashscheme,d),St(o,r,i),St(o,t.domain,o);const f=Te(o,ri);Te(i,ri,f),Te(l,ri,f),Te(d,ri,f);const h=Te(i,is);St(h,r,i),St(h,t.domain,i);const m=Mr();St(f,t.domain,m),St(m,t.domain,m);const g=Te(m,is);St(g,t.domain,m);const y=Mr(c1);St(g,t.tld,y),St(g,t.utld,y),Te(f,xl,y);const b=Te(m,jr);Te(b,jr,b),St(b,t.domain,m),St(y,t.domain,m),Te(y,is,g),Te(y,jr,b);const x=Te(y,oi);St(x,t.numeric,c1);const w=Te(o,jr),E=Te(o,is);Te(w,jr,w),St(w,t.domain,o),St(E,r,i),St(E,t.domain,o);const C=Mr(Qc);St(E,t.tld,C),St(E,t.utld,C),St(C,t.domain,o),St(C,r,i),Te(C,is,E),Te(C,jr,w),Te(C,ri,f);const A=Te(C,oi),T=Mr(Qc);St(A,t.numeric,T);const _=Mr(Qc),O=Mr();St(_,e,_),St(_,n,O),St(O,e,_),St(O,n,O),Te(C,as,_),Te(T,as,_);const R=Te(l,oi),B=Te(d,oi),D=Te(B,as),U=Te(D,as);St(l,t.domain,o),Te(l,is,E),Te(l,jr,w),St(d,t.domain,o),Te(d,is,E),Te(d,jr,w),St(R,t.domain,_),Te(R,as,_),Te(R,cl,_),St(U,t.domain,_),St(U,e,_),Te(U,as,_);const Q=[[ol,al],[Hu,Wu],[qu,Vu],[Ku,Gu],[Ju,Yu],[Xu,Qu],[Zu,ed],[td,nd]];for(let P=0;P<Q.length;P++){const[W,$]=Q[P],H=Te(_,W);Te(O,W,H),Te(H,$,_);const J=Mr(Qc);St(H,e,J);const re=Mr();St(H,n),St(J,e,J),St(J,n,re),St(re,e,J),St(re,n,re),Te(J,$,_),Te(re,$,_)}return Te(s,xl,C),Te(s,Cv,CD),{start:s,tokens:$C}}function TD(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(fp(u1,e,o)),o=[]),s-=g,h-=g;const y=m.t,b=n.slice(s-h,s);i.push(fp(y,e,b))}}return o.length>0&&i.push(fp(u1,e,o)),i}function fp(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 MD=typeof console<"u"&&console&&console.warn||(()=>{}),AD="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Qt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function jD(){return dr.groups={},Qt.scanner=null,Qt.parser=null,Qt.tokenQueue=[],Qt.pluginQueue=[],Qt.customSchemes=[],Qt.initialized=!1,Qt}function d1(t,e=!1){if(Qt.initialized&&MD(`linkifyjs: already initialized - will not register custom scheme "${t}" ${AD}`),!/^[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`);Qt.customSchemes.push([t,e])}function OD(){Qt.scanner=ED(Qt.customSchemes);for(let t=0;t<Qt.tokenQueue.length;t++)Qt.tokenQueue[t][1]({scanner:Qt.scanner});Qt.parser=_D(Qt.scanner.tokens);for(let t=0;t<Qt.pluginQueue.length;t++)Qt.pluginQueue[t][1]({scanner:Qt.scanner,parser:Qt.parser});return Qt.initialized=!0,Qt}function Ov(t){return Qt.initialized||OD(),TD(Qt.parser.start,t,FC(Qt.scanner.start,t))}Ov.scan=FC;function HC(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 jv(n),s=Ov(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 Rv="[\0- -\u2029 ]",RD=new RegExp(Rv),ID=new RegExp(`${Rv}$`),LD=new RegExp(Rv,"g");function DD(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function PD(t){return new Pt({key:new Ht("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=hv(n.doc,[...e]);if(gv(l).forEach(({newRange:f})=>{const h=tC(r.doc,f,y=>y.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 y=r.doc.textBetween(f.from,f.to," "," ");if(!ID.test(y))return;m=h[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const y=g.split(RD).filter(Boolean);if(y.length<=0)return!1;const b=y[y.length-1],x=m.pos+g.lastIndexOf(b);if(!b)return!1;const w=Ov(b).map(E=>E.toObject(t.defaultProtocol));if(!DD(w))return!1;w.filter(E=>E.isLink).map(E=>({...E,from:x+E.start+1,to:x+E.end+1})).filter(E=>r.schema.marks.code?!r.doc.rangeHasMark(E.from,E.to,r.schema.marks.code):!0).filter(E=>t.validate(E.value)).filter(E=>t.shouldAutoLink(E.value)).forEach(E=>{vv(E.from,E.to,r.doc).some(C=>C.mark.type===t.type)||o.addMark(E.from,E.to,t.type.create({href:E.href}))})}}),!!o.steps.length)return o}})}function BD(t){return new Pt({key:new Ht("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=lC(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 zD(t){return new Pt({key:new Ht("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=HC(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 $i(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(LD,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var WC=Gr.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"){d1(t);return}d1(t.scheme,t.optionalSlashes)})},onDestroy(){jD()},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)=>!!$i(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=>!!$i(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=>!!$i(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Lt(this.options.HTMLAttributes,t),0]:["a",Lt(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=>!!$i(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=>!!$i(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[vi({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=HC(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!$i(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(PD({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!$i(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(BD({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(zD({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),$D=WC;function FD(t={}){return new Pt({view(e){return new UD(e,t)}})}class UD{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let y=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(y){let b=y.getBoundingClientRect(),x=m?b.bottom:b.top;m&&g&&(x=(x+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*l;r={left:b.left,right:b.right,top:x-w,bottom:x+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,y=m.height/d.offsetHeight;f=m.left-d.scrollLeft*g,h=m.top-d.scrollTop*y}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=KE(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 fn extends ht{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return fn.valid(r)?new fn(r):ht.near(r)}content(){return Pe.empty}eq(e){return e instanceof fn&&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 fn(e.resolve(n.pos))}getBookmark(){return new Iv(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!HD(e)||!WD(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&&fn.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(fn.valid(d))return d}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!rt.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(fn.valid(l))return l}return null}}}fn.prototype.visible=!1;fn.findFrom=fn.findGapCursorFrom;ht.jsonID("gapcursor",fn);class Iv{constructor(e){this.pos=e}map(e){return new Iv(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return fn.valid(n)?new fn(n):ht.near(n)}}function qC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function HD(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||qC(s.type))return!0;if(s.inlineContent)return!1}}return!0}function WD(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||qC(s.type))return!0;if(s.inlineContent)return!1}}return!0}function qD(){return new Pt({props:{decorations:JD,createSelectionBetween(t,e,n){return e.pos==n.pos&&fn.valid(n)?new fn(n):null},handleClick:KD,handleKeyDown:VD,handleDOMEvents:{beforeinput:GD}}})}const VD=cv({ArrowLeft:Zc("horiz",-1),ArrowRight:Zc("horiz",1),ArrowUp:Zc("vert",-1),ArrowDown:Zc("vert",1)});function Zc(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 it){if(!i.endOfTextblock(n)||l.depth==0)return!1;d=!1,l=r.doc.resolve(e>0?l.after():l.before())}let f=fn.findGapCursorFrom(l,e,d);return f?(s&&s(r.tr.setSelection(new fn(f))),!0):!1}}function KD(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!fn.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&rt.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fn(r))),!0)}function GD(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof fn))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=be.empty;for(let o=r.length-1;o>=0;o--)s=be.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Pe(s,0,0));return i.setSelection(it.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function JD(t){if(!(t.selection instanceof fn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",jt.create(t.doc,[zt.widget(t.selection.head,e,{key:"gapcursor"})])}var gd=200,Rn=function(){};Rn.prototype.append=function(e){return e.length?(e=Rn.from(e),!this.length&&e||e.length<gd&&this.leafAppend(e)||this.length<gd&&e.leafPrepend(this)||this.appendInner(e)):this};Rn.prototype.prepend=function(e){return e.length?Rn.from(e).append(this):this};Rn.prototype.appendInner=function(e){return new YD(this,e)};Rn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Rn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Rn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Rn.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)};Rn.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};Rn.from=function(e){return e instanceof Rn?e:e&&e.length?new VC(e):Rn.empty};var VC=(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<=gd)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=gd)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})(Rn);Rn.empty=new VC([]);var YD=(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})(Rn);const XD=500;class qr{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 ls(m.map));let y=m.step.map(s.slice(i)),b;y&&o.maybeStep(y).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],f.push(new ls(b,void 0,void 0,f.length+h.length))),i--,b&&s.appendMap(b,i)}else o.maybeStep(m.step);if(m.selection)return l=s?m.selection.map(s.slice(i)):m.selection,d=new qr(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 ls(e.mapping.maps[h],m,n),y;(y=d&&d.merge(g))&&(g=y,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>ZD&&(l=QD(l,f),o-=f),new qr(l.append(i),o)}remapping(e,n){let r=new hl;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 qr(this.items.append(e.map(n=>new ls(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 y=i.getMirror(--d);if(y==null)return;o=Math.min(o,y);let b=i.maps[y];if(g.step){let x=e.steps[y].invert(e.docs[y]),w=g.selection&&g.selection.map(i.slice(d+1,y));w&&l++,r.push(new ls(b,x,w))}else r.push(new ls(b))},s);let f=[];for(let g=n;g<o;g++)f.push(new ls(i.maps[g]));let h=this.items.slice(0,s).append(f).append(r),m=new qr(h,l);return m.emptyItemCount()>XD&&(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 ls(f.invert(),d,h),g,y=s.length-1;(g=s.length&&s[y].merge(m))?s[y]=g:s.push(m)}}else o.map&&r--},this.items.length,0),new qr(Rn.from(s.reverse()),i)}}qr.empty=new qr(Rn.empty,0);function QD(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class ls{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 ls(n.getMap().invert(),n,this.selection)}}}class si{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const ZD=20;function eP(t,e,n,r){let s=n.getMeta(Xi),i;if(s)return s.historyState;n.getMeta(rP)&&(t=new si(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Xi))return o.getMeta(Xi).redo?new si(t.done.addTransform(n,void 0,r,Su(e)),t.undone,f1(n.mapping.maps),t.prevTime,t.prevComposition):new si(t.done,t.undone.addTransform(n,void 0,r,Su(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||!tP(n,t.prevRanges)),f=o?hp(t.prevRanges,n.mapping):f1(n.mapping.maps);return new si(t.done.addTransform(n,d?e.selection.getBookmark():void 0,r,Su(e)),qr.empty,f,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new si(t.done.rebased(n,i),t.undone.rebased(n,i),hp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new si(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),hp(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function tP(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 f1(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 hp(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 nP(t,e,n){let r=Su(e),s=Xi.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 si(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Xi,{redo:n,historyState:d})}let pp=!1,h1=null;function Su(t){let e=t.plugins;if(h1!=e){pp=!1,h1=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){pp=!0;break}}return pp}const Xi=new Ht("history"),rP=new Ht("closeHistory");function sP(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Pt({key:Xi,state:{init(){return new si(qr.empty,qr.empty,null,0,-1)},apply(e,n,r){return eP(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?GC:r=="historyRedo"?JC:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function KC(t,e){return(n,r)=>{let s=Xi.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=nP(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const GC=KC(!1,!0),JC=KC(!0,!0);Ot.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 Pt({key:new Ht("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 iP=Ot.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[FD(this.options)]}});Ot.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Pt({key:new Ht("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return jt.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(zt.node(f,f+d.nodeSize,{class:this.options.className}))}),jt.create(t,i)}}})]}});var oP=Ot.create({name:"gapCursor",addProseMirrorPlugins(){return[qD()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Bt(nt(t,"allowGapCursor",n)))!=null?e:null}}}),p1="placeholder";function aP(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var lP=Ot.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:p1,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${aP(this.options.dataAttribute)}`:`data-${p1}`;return[new Pt({key:new Ht("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&&Bd(l);if((f||!this.options.showOnlyCurrent)&&h){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=zt.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}),jt.create(e,i)}}})]}});Ot.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Pt({key:new Ht("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||cC(n.selection)||t.view.dragging?null:jt.create(n.doc,[zt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function m1({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var cP=Ot.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ht(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 Pt({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!m1({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!m1({node:o,types:r})}}})]}}),uP=Ot.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>GC(t,e),redo:()=>({state:t,dispatch:e})=>JC(t,e)}},addProseMirrorPlugins(){return[sP(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()}}}),Fd=lP,dP=Gr.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",Lt(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()}}}),fP=dP,hP=Gr.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",Lt(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()}}}),pP=hP;let Ig,Lg;if(typeof WeakMap<"u"){let t=new WeakMap;Ig=e=>t.get(e),Lg=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Ig=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},Lg=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var hn=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 Ig(t)||Lg(t,mP(t))}};function mP(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=gP(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 b=0;;b++){for(;s<r.length&&r[s]!=0;)s++;if(b==m.childCount)break;const x=m.child(b),{colspan:w,rowspan:E,colwidth:C}=x.attrs;for(let A=0;A<E;A++){if(A+f>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:h,n:E-A});break}const T=s+A*e;for(let _=0;_<w;_++){r[T+_]==0?r[T+_]=h:(i||(i=[])).push({type:"collision",row:f,pos:h,n:w-_});const O=C&&C[_];if(O){const R=(T+_)%e*2,B=o[R];B==null||B!=O&&o[R+1]==1?(o[R]=O,o[R+1]=1):B==O&&o[R+1]++}}}s+=w,h+=x.nodeSize}const g=(f+1)*e;let y=0;for(;s<g;)r[s++]==0&&y++;y&&(i||(i=[])).push({type:"missing",row:f,n:y}),h++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new hn(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&&vP(l,o,t),l}function gP(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 vP(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=yP(d)))[f]=h)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function yP(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Yn(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 ai=new Ht("selectingCells");function ro(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 bP(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 Jr(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 Ud(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=ro(e.$head)||xP(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function xP(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 Dg(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function wP(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Lv(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function YC(t,e,n){const r=t.node(-1),s=hn.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 so(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 XC(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 kP(t,e,n){const r=Yn(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 Gt=class Es extends ht{constructor(e,n=e){const r=e.node(-1),s=hn.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 QE(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(Dg(r)&&Dg(s)&&Lv(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Es.rowSelection(r,s):i&&this.isColSelection()?Es.colSelection(r,s):new Es(r,s)}return it.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=hn.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 y=n.findCell(g);let b=e.nodeAt(g);if(!b)throw new RangeError(`No cell with offset ${g} found`);const x=s.left-y.left,w=y.right-s.right;if(x>0||w>0){let E=b.attrs;if(x>0&&(E=so(E,0,x)),w>0&&(E=so(E,E.colspan-w,w)),y.left<s.left){if(b=b.type.createAndFill(E),!b)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(E)}`)}else b=b.type.create(E,b.content)}if(y.top<s.top||y.bottom>s.bottom){const E={...b.attrs,rowspan:Math.min(y.bottom,s.bottom)-Math.max(y.top,s.top)};y.top<s.top?b=b.type.createAndFill(E):b=b.type.create(E,b.content)}f.push(b)}o.push(e.child(d).copy(be.from(f)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Pe(be.from(l),1,1)}replace(e,n=Pe.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?Pe.empty:n)}const i=ht.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Pe(be.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=hn.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=hn.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 Es(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=hn.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 Es&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=hn.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 Es(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Es(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Es(e.resolve(n),e.resolve(r))}getBookmark(){return new SP(this.$anchorCell.pos,this.$headCell.pos)}};Gt.prototype.visible=!1;ht.jsonID("cell",Gt);var SP=class QC{constructor(e,n){this.anchor=e,this.head=n}map(e){return new QC(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&&Lv(n,r)?new Gt(n,r):ht.near(r,1)}};function EP(t){if(!(t.selection instanceof Gt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(zt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),jt.create(t.doc,e)}function NP({$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 CP({$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 _P(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof rt&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Gt.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Gt.rowSelection(l,l)}else if(!n){const l=hn.get(r.node),d=r.from+1,f=d+l.map[l.width*l.height-1];i=Gt.create(s,d+1,f)}}else r instanceof it&&NP(r)?i=it.create(s,r.from):r instanceof it&&CP(r)&&(i=it.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const TP=new Ht("fix-tables");function ZC(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)?ZC(t.child(l),d,n+1,r):d.nodesBetween(0,d.content.size,r,n+1),n+=d.nodeSize}}function e_(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=MP(t,s,i,n))};return e?e.doc!=t.doc&&ZC(e.doc,t.doc,0,r):t.doc.descendants(r),n}function MP(t,e,n,r){const s=hn.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,so(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 y="cell";h.firstChild&&(y=h.firstChild.type.spec.tableRole);const b=[];for(let w=0;w<g;w++){const E=Yn(t.schema)[y].createAndFill();E&&b.push(E)}const x=(d==0||o==d-1)&&l==d?f+1:m-1;r.insert(r.mapping.map(x),b)}f=m}return r.setMeta(TP,{fixTables:!0})}function ds(t){const e=t.selection,n=Ud(t),r=n.node(-1),s=n.start(-1),i=hn.get(r);return{...e instanceof Gt?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function t_(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;kP(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,XC(f.attrs,s-e.colCount(d))),o+=f.attrs.rowspan-1}else{const d=i==null?Yn(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 AP(t,e){if(!Jr(t))return!1;if(e){const n=ds(t);e(t_(t.tr,n,n.left))}return!0}function jP(t,e){if(!Jr(t))return!1;if(e){const n=ds(t);e(t_(t.tr,n,n.right))}return!0}function OP(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,so(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 RP(t,e){if(!Jr(t))return!1;if(e){const n=ds(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;OP(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=hn.get(i)}e(r)}return!0}function IP(t,e,n){var r;const s=Yn(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 n_(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;IP(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?Yn(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,Yn(r.type.schema).row.create(null,o)),t}function LP(t,e){if(!Jr(t))return!1;if(e){const n=ds(t);e(n_(t.tr,n,n.top))}return!0}function DP(t,e){if(!Jr(t))return!1;if(e){const n=ds(t);e(n_(t.tr,n,n.bottom))}return!0}function PP(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),y=g.attrs,b=g.type.create({...y,rowspan:g.attrs.rowspan-1},g.content),x=e.positionAt(s+1,f,n);t.insert(t.mapping.slice(l).map(r+x),b),f+=y.colspan-1}}}}function BP(t,e){if(!Jr(t))return!1;if(e){const n=ds(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;PP(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=hn.get(n.table)}e(r)}return!0}function g1(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function zP({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 v1(t,e){const n=t.selection;if(!(n instanceof Gt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=ds(t),{map:s}=r;if(zP(s,r))return!1;if(e){const i=t.tr,o={};let l=be.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],y=r.table.nodeAt(g);if(!(o[g]||!y))if(o[g]=!0,d==null)d=g,f=y;else{g1(y)||(l=l.append(y.content));const b=i.mapping.map(g+r.tableStart);i.delete(b,b+y.nodeSize)}}if(d==null||f==null)return!0;if(i.setNodeMarkup(d+r.tableStart,null,{...XC(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=g1(f)?d+1:h;i.replaceWith(m+r.tableStart,h+r.tableStart,l)}i.setSelection(new Gt(i.doc.resolve(d+r.tableStart))),e(i)}return!0}function y1(t,e){const n=Yn(t.schema);return $P(({node:r})=>n[r.type.spec.tableRole])(t,e)}function $P(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof Gt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=bP(r.$from),!s)return!1;i=(o=ro(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=ds(e),m=e.tr;for(let y=0;y<h.right-h.left;y++)d.push(f?{...l,colwidth:f&&f[y]?[f[y]]:null}:l);let g;for(let y=h.top;y<h.bottom;y++){let b=h.map.positionAt(y,h.left,h.table);y==h.top&&(b+=s.nodeSize);for(let x=h.left,w=0;x<h.right;x++,w++)x==h.left&&y==h.top||m.insert(g=m.mapping.map(b+h.tableStart,1),t({node:s,row:y,col:x}).createAndFill(d[w]))}m.setNodeMarkup(i,t({node:s,row:h.top,col:h.left}),d[0]),r instanceof Gt&&m.setSelection(new Gt(m.doc.resolve(r.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function FP(t,e){return function(n,r){if(!Jr(n))return!1;const s=Ud(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Gt?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 UP(t){return function(e,n){if(!Jr(e))return!1;if(n){const r=Yn(e.schema),s=ds(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 b1(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function kl(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?UP(t):function(n,r){if(!Jr(n))return!1;if(r){const s=Yn(n.schema),i=ds(n),o=n.tr,l=b1("row",i,s),d=b1("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 y=g+i.tableStart,b=o.doc.nodeAt(y);b&&o.setNodeMarkup(y,m,b.attrs)}),r(o)}return!0}}kl("row",{useDeprecatedLogic:!0});kl("column",{useDeprecatedLogic:!0});const HP=kl("cell",{useDeprecatedLogic:!0});function WP(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 x1(t){return function(e,n){if(!Jr(e))return!1;const r=WP(Ud(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(it.between(s,wP(s))).scrollIntoView())}return!0}}function qP(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 eu(t,e){const n=t.selection;if(!(n instanceof Gt))return!1;if(e){const r=t.tr,s=Yn(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 Pe(s,0,0))}),r.docChanged&&e(r)}return!0}function VP(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=Pg(Yn(o).row,new Pe(f,h,m)).content),l.push(f)}else if(i=="cell"||i=="header_cell")l.push(n||r?Pg(Yn(o).row,new Pe(e,n,r)).content:e);else return null;return KP(o,l)}function KP(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(be.empty),n[s]<r){const i=Yn(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(be.from(o))}return{height:e.length,width:r,rows:e}}function Pg(t,e){const n=t.createAndFill();return new Kg(n).replace(0,n.content.size,e).doc}function GP({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(so(g.attrs,g.attrs.colspan,h+g.attrs.colspan-r),g.content)),f.push(g),h+=g.attrs.colspan;for(let y=1;y<g.attrs.rowspan;y++)i[l+y]=(i[l+y]||0)+g.attrs.colspan}o.push(be.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(be.from(d))}n=i,e=s}return{width:t,height:e,rows:n}}function JP(t,e,n,r,s,i,o){const l=t.doc.type.schema,d=Yn(l);let f,h;if(s>e.width)for(let m=0,g=0;m<e.height;m++){const y=n.child(m);g+=y.nodeSize;const b=[];let x;y.lastChild==null||y.lastChild.type==d.cell?x=f||(f=d.cell.createAndFill()):x=h||(h=d.header_cell.createAndFill());for(let w=e.width;w<s;w++)b.push(x);t.insert(t.mapping.slice(o).map(g-1+r),b)}if(i>e.height){const m=[];for(let b=0,x=(e.height-1)*e.width;b<Math.max(e.width,s);b++){const w=b>=e.width?!1:n.nodeAt(e.map[x+b]).type==d.header_cell;m.push(w?h||(h=d.header_cell.createAndFill()):f||(f=d.cell.createAndFill()))}const g=d.row.create(null,be.from(m)),y=[];for(let b=e.height;b<i;b++)y.push(g);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),y)}return!!(f||h)}function w1(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:y,left:b}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g.attrs,rowspan:o-y}),t.insert(t.mapping.slice(l).map(e.positionAt(o,b,n)),g.type.createAndFill({...g.attrs,rowspan:y+g.attrs.rowspan-o})),f+=g.attrs.colspan-1}}return d}function k1(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),y=e.colCount(m),b=t.mapping.slice(l).map(m+r);t.setNodeMarkup(b,null,so(g.attrs,o-y,g.attrs.colspan-(o-y))),t.insert(b+g.nodeSize,g.type.createAndFill(so(g.attrs,0,o-y))),f+=g.attrs.rowspan-1}}return d}function S1(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=hn.get(i);const{top:l,left:d}=r,f=d+s.width,h=l+s.height,m=t.tr;let g=0;function y(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");o=hn.get(i),g=m.mapping.maps.length}JP(m,o,i,n,f,h,g)&&y(),w1(m,o,i,n,d,f,l,g)&&y(),w1(m,o,i,n,d,f,h,g)&&y(),k1(m,o,i,n,l,h,d,g)&&y(),k1(m,o,i,n,l,h,f,g)&&y();for(let b=l;b<h;b++){const x=o.positionAt(b,d,i),w=o.positionAt(b,f,i);m.replace(m.mapping.slice(g).map(x+n),m.mapping.slice(g).map(w+n),new Pe(s.rows[b-l],0,0))}y(),m.setSelection(new Gt(m.doc.resolve(n+o.positionAt(l,d,i)),m.doc.resolve(n+o.positionAt(h-1,f-1,i)))),e(m)}const YP=cv({ArrowLeft:tu("horiz",-1),ArrowRight:tu("horiz",1),ArrowUp:tu("vert",-1),ArrowDown:tu("vert",1),"Shift-ArrowLeft":nu("horiz",-1),"Shift-ArrowRight":nu("horiz",1),"Shift-ArrowUp":nu("vert",-1),"Shift-ArrowDown":nu("vert",1),Backspace:eu,"Mod-Backspace":eu,Delete:eu,"Mod-Delete":eu});function Eu(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function tu(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Gt)return Eu(n,r,ht.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=r_(s,t,e);if(o==null)return!1;if(t=="horiz")return Eu(n,r,ht.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),d=YC(l,t,e);let f;return d?f=ht.near(d,1):e<0?f=ht.near(n.doc.resolve(l.before(-1)),-1):f=ht.near(n.doc.resolve(l.after(-1)),1),Eu(n,r,f)}}}function nu(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof Gt)o=i;else{const d=r_(s,t,e);if(d==null)return!1;o=new Gt(n.doc.resolve(d))}const l=YC(o.$headCell,t,e);return l?Eu(n,r,new Gt(o.$anchorCell,l)):!1}}function XP(t,e){const n=t.state.doc,r=ro(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Gt(r))),!0):!1}function QP(t,e,n){if(!Jr(t.state))return!1;let r=VP(n);const s=t.state.selection;if(s instanceof Gt){r||(r={width:1,height:1,rows:[be.from(Pg(Yn(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=hn.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=GP(r,l.right-l.left,l.bottom-l.top),S1(t.state,t.dispatch,o,l,r),!0}else if(r){const i=Ud(t.state),o=i.start(-1);return S1(t.state,t.dispatch,o,hn.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function ZP(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=E1(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Gt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=ro(t.state.selection.$anchor))!=null&&((n=mp(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=mp(t,f);const m=ai.getState(t.state)==null;if(!h||!Lv(d,h))if(m)h=d;else return;const g=new Gt(d,h);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(ai,d.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),ai.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ai,-1))}function l(d){const f=d,h=ai.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if(E1(t,f.target)!=r&&(m=mp(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 r_(t,e,n){if(!(t.state.selection instanceof it))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 E1(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function mp(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&&ro(t.state.doc.resolve(r))||ro(t.state.doc.resolve(s))}var e3=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")),Bg(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,Bg(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Bg(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:y,colwidth:b}=f.child(m).attrs;for(let x=0;x<y;x++,g++){const w=s==g?i:b&&b[x],E=w?w+"px":"";if(o+=w||r,w||(l=!1),d)d.style.width!=E&&(d.style.width=E),d=d.nextSibling;else{const C=document.createElement("col");C.style.width=E,e.appendChild(C)}}}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 br=new Ht("tableColumnResizing");function t3({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=e3,lastColumnResizable:s=!0}={}){const i=new Pt({key:br,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=Yn(l.schema).table.name;return r&&f&&(f[h]=(m,g)=>new r(m,n,g)),new n3(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=br.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{r3(o,l,t,s)},mouseleave:o=>{s3(o)},mousedown:(o,l)=>{i3(o,l,e,n)}},decorations:o=>{const l=br.getState(o);if(l&&l.activeHandle>-1)return u3(o,l.activeHandle)},nodeViews:{}}});return i}var n3=class Nu{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(br);if(r&&r.setHandle!=null)return new Nu(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Nu(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Dg(e.doc.resolve(s))||(s=-1),new Nu(s,n.dragging)}return n}};function r3(t,e,n,r){if(!t.editable)return;const s=br.getState(t.state);if(s&&!s.dragging){const i=a3(e.target);let o=-1;if(i){const{left:l,right:d}=i.getBoundingClientRect();e.clientX-l<=n?o=N1(t,e,"left",n):d-e.clientX<=n&&(o=N1(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),d=l.node(-1),f=hn.get(d),h=l.start(-1);if(f.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==f.width-1)return}s_(t,o)}}}function s3(t){if(!t.editable)return;const e=br.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&s_(t,-1)}function i3(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=br.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),d=o3(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(br,{setDragging:{startX:e.clientX,startWidth:d}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",h);const g=br.getState(t.state);g!=null&&g.dragging&&(l3(t,g.activeHandle,C1(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(br,{setDragging:null})))}function h(m){if(!m.which)return f(m);const g=br.getState(t.state);if(g&&g.dragging){const y=C1(g.dragging,m,n);_1(t,g.activeHandle,y,r)}}return _1(t,o.activeHandle,d,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",h),e.preventDefault(),!0}function o3(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 a3(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function N1(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=ro(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const d=hn.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 C1(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function s_(t,e){t.dispatch(t.state.tr.setMeta(br,{setHandle:e}))}function l3(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=hn.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,y=g.colspan==1?0:l-i.colCount(m);if(g.colwidth&&g.colwidth[y]==n)continue;const b=g.colwidth?g.colwidth.slice():c3(g.colspan);b[y]=n,d.setNodeMarkup(o+m,null,{...g,colwidth:b})}d.docChanged&&t.dispatch(d)}function _1(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=hn.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&&Bg(i,d.firstChild,d,r,l,n)}function c3(t){return Array(t).fill(0)}function u3(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return jt.empty;const i=hn.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,y=document.createElement("div");y.className="column-resize-handle",!((d=br.getState(t))===null||d===void 0)&&d.dragging&&n.push(zt.node(o+m,o+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(zt.widget(g,y))}}return jt.create(t.doc,n)}function d3({allowTableNodeSelection:t=!1}={}){return new Pt({key:ai,state:{init(){return null},apply(e,n){const r=e.getMeta(ai);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:EP,handleDOMEvents:{mousedown:ZP},createSelectionBetween(e){return ai.getState(e.state)!=null?e.state.selection:null},handleTripleClick:XP,handleKeyDown:YP,handlePaste:QP},appendTransaction(e,n,r){return _P(r,e_(r,n),t)}})}var i_=mn.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",Lt(this.options.HTMLAttributes,t),0]}}),o_=mn.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",Lt(this.options.HTMLAttributes,t),0]}}),a_=mn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Lt(this.options.HTMLAttributes,t),0]}});function zg(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function T1(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,y=0;g<h.childCount;g+=1){const{colspan:b,colwidth:x}=h.child(g).attrs;for(let w=0;w<b;w+=1,y+=1){const E=s===y?i:x&&x[w],C=E?`${E}px`:"";if(l+=E||r,E||(d=!1),f){if(f.style.width!==C){const[A,T]=zg(r,E);f.style.setProperty(A,T)}f=f.nextSibling}else{const A=document.createElement("col"),[T,_]=zg(r,E);A.style.setProperty(T,_),e.appendChild(A)}}}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 f3=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")),T1(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,T1(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 h3(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let m=0,g=0;m<l.childCount;m+=1){const{colspan:y,colwidth:b}=l.child(m).attrs;for(let x=0;x<y;x+=1,g+=1){const w=n===g?r:b&&b[x];s+=w||e,w||(i=!1);const[E,C]=zg(e,w);o.push(["col",{style:`${E}: ${C}`}])}}const d=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:d,tableMinWidth:f}}function M1(t,e){return t.createAndFill()}function p3(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 m3(t,e,n,r,s){const i=p3(t),o=[],l=[];for(let f=0;f<n;f+=1){const h=M1(i.cell);if(h&&l.push(h),r){const m=M1(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 g3(t){return t instanceof Gt}var ru=({editor:t})=>{const{selection:e}=t.state;if(!g3(e))return!1;let n=0;const r=nC(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},v3="";function y3(t){return(t||"").replace(/\s+/g," ").trim()}function b3(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:v3;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(b=>{const x=[];b.content&&b.content.forEach(w=>{let E="";w.content&&Array.isArray(w.content)&&w.content.length>1?E=w.content.map(_=>e.renderChildren(_)).join(s):E=w.content?e.renderChildren(w.content):"";const C=y3(E),A=w.type==="tableHeader";x.push({text:C,isHeader:A})}),i.push(x)});const o=i.reduce((b,x)=>Math.max(b,x.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(b=>{var x;for(let w=0;w<o;w+=1){const C=(((x=b[w])==null?void 0:x.text)||"").length;C>l[w]&&(l[w]=C),l[w]<3&&(l[w]=3)}});const d=(b,x)=>b+" ".repeat(Math.max(0,x-b.length)),f=i[0],h=f.some(b=>b.isHeader);let m=`
|
|
160
|
-
`;const g=new Array(o).fill(0).map((b,x)=>h&&f[x]&&f[x].text||"");return m+=`| ${g.map((b,x)=>d(b,l[x])).join(" | ")} |
|
|
161
|
-
`,m+=`| ${l.map(b=>"-".repeat(Math.max(3,b))).join(" | ")} |
|
|
162
|
-
`,(h?i.slice(1):i).forEach(b=>{m+=`| ${new Array(o).fill(0).map((x,w)=>d(b[w]&&b[w].text||"",l[w])).join(" | ")} |
|
|
163
|
-
`}),m}var x3=b3,l_=mn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:f3,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}=h3(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",Lt(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)=>x3(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=m3(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(it.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>AP(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>jP(t,e),deleteColumn:()=>({state:t,dispatch:e})=>RP(t,e),addRowBefore:()=>({state:t,dispatch:e})=>LP(t,e),addRowAfter:()=>({state:t,dispatch:e})=>DP(t,e),deleteRow:()=>({state:t,dispatch:e})=>BP(t,e),deleteTable:()=>({state:t,dispatch:e})=>qP(t,e),mergeCells:()=>({state:t,dispatch:e})=>v1(t,e),splitCell:()=>({state:t,dispatch:e})=>y1(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>kl("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>kl("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>HP(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>v1(t,e)?!0:y1(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>FP(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>x1(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>x1(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&e_(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Gt.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:ru,"Mod-Backspace":ru,Delete:ru,"Mod-Delete":ru}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[t3({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],d3({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:Bt(nt(t,"tableRole",e))}}});Ot.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(l_.configure(this.options.table)),this.options.tableCell!==!1&&t.push(i_.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(o_.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(a_.configure(this.options.tableRow)),t}});var w3=Object.defineProperty,k3=(t,e)=>{for(var n in e)w3(t,n,{get:e[n],enumerable:!0})},S3="listItem",A1="textStyle",j1=/^\s*([-+*])\s$/,c_=mn.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",Lt(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(S3,this.editor.getAttributes(A1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=na({find:j1,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=na({find:j1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(A1),editor:this.editor})),[t]}}),u_=mn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Lt(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)=>wv(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)}}}),E3={};k3(E3,{findListItemPos:()=>Al,getNextListDepth:()=>Dv,handleBackspace:()=>$g,handleDelete:()=>Fg,hasListBefore:()=>d_,hasListItemAfter:()=>N3,hasListItemBefore:()=>f_,listItemHasSubList:()=>h_,nextListIsDeeper:()=>p_,nextListIsHigher:()=>m_});var Al=(t,e)=>{const{$from:n}=e.selection,r=Sn(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}},Dv=(t,e)=>{const n=Al(t,e);if(!n)return!1;const[,r]=nI(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))},f_=(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)},h_=(t,e,n)=>{if(!n)return!1;const r=Sn(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},$g=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!gi(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,y)=>{g.type.name===e&&f.push({node:g,pos:y})});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(!gi(t.state,e)||!oI(t.state))return!1;const r=Al(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=h_(e,t.state,i);return f_(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},p_=(t,e)=>{const n=Dv(t,e),r=Al(t,e);return!r||!n?!1:n>r.depth},m_=(t,e)=>{const n=Dv(t,e),r=Al(t,e);return!r||!n?!1:n<r.depth},Fg=(t,e)=>{if(!gi(t.state,e)||!iI(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:p_(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():m_(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},N3=(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)},g_=Ot.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&&Fg(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&&Fg(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&&$g(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&&$g(t,n,r)&&(e=!0)}),e}}}}),O1=/^(\s*)(\d+)\.\s+(.*)$/,C3=/^\s/;function _3(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(O1);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 y=t[m];if(y.match(O1))break;if(y.trim()==="")g.push(y),h+=`
|
|
165
|
-
`,m+=1;else if(y.match(C3))g.push(y),h+=`
|
|
166
|
-
${y.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 v_(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 y=n.blockTokens(h);f.push(...y)}let m=i+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(x=>x.indent)),b=v_(g,y,n);f.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(x=>x.raw).join(`
|
|
170
|
-
`)})}s.push({type:"list_item",raw:o.raw,tokens:f}),i=m}else i+=1}return s}function T3(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 M3="listItem",R1="textStyle",I1=/^(\d+)\.\s$/,y_=mn.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",Lt(this.options.HTMLAttributes,n),0]:["ol",Lt(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?T3(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]=_3(s);if(i.length===0)return;const l=v_(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(M3,this.editor.getAttributes(R1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=na({find:I1,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=na({find:I1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(R1)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),A3=/^\s*(\[([( |x])?\])\s$/,b_=mn.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",Lt(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 wv(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,y;l.ariaLabel=((y=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:y.call(g,m,l.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",m=>m.preventDefault()),l.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:y})=>{const b=n();if(typeof b!="number")return!1;const x=y.doc.nodeAt(b);return y.setNodeMarkup(b,void 0,{...x==null?void 0:x.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,y=ta(m,g),b=new Set(Object.keys(y)),x=this.options.HTMLAttributes;return h.forEach(w=>{b.has(w)||(w in x?s.setAttribute(w,x[w]):s.removeAttribute(w))}),Object.entries(y).forEach(([w,E])=>{E==null?w in x?s.setAttribute(w,x[w]):s.removeAttribute(w):s.setAttribute(w,E)}),h=b,!0}}}},addInputRules(){return[na({find:A3,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),x_=mn.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",Lt(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=Eg(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=Eg(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()}}});Ot.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(c_.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(u_.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(g_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(y_.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(b_.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(x_.configure(this.options.taskList)),t}});var j3=b_,O3=x_,R3=20,w_=(t,e=0)=>{const n=[];return!t.children.length||e>R3||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...w_(r,e+1))}),n},I3=t=>{if(!t.children.length)return;const e=w_(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_=Gr.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&I3(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Lt(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}}}}),L3=Ot.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()}}}),D3=Ot.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()}}}),P3=Ot.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()}}}),B3=Ot.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()}}}),z3=Ot.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()}}});Ot.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(L3.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(D3.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(P3.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(B3.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(z3.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(k_.configure(this.options.textStyle)),t}});var $3=t=>pn({find:/--$/,replace:t??"—"}),F3=t=>pn({find:/\.\.\.$/,replace:t??"…"}),U3=t=>pn({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),H3=t=>pn({find:/"$/,replace:t??"”"}),W3=t=>pn({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),q3=t=>pn({find:/'$/,replace:t??"’"}),V3=t=>pn({find:/<-$/,replace:t??"←"}),K3=t=>pn({find:/->$/,replace:t??"→"}),G3=t=>pn({find:/\(c\)$/,replace:t??"©"}),J3=t=>pn({find:/\(tm\)$/,replace:t??"™"}),Y3=t=>pn({find:/\(sm\)$/,replace:t??"℠"}),X3=t=>pn({find:/\(r\)$/,replace:t??"®"}),Q3=t=>pn({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),Z3=t=>pn({find:/\+\/-$/,replace:t??"±"}),e4=t=>pn({find:/!=$/,replace:t??"≠"}),t4=t=>pn({find:/<<$/,replace:t??"«"}),n4=t=>pn({find:/>>$/,replace:t??"»"}),r4=t=>pn({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),s4=t=>pn({find:/\^2$/,replace:t??"²"}),i4=t=>pn({find:/\^3$/,replace:t??"³"}),o4=t=>pn({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),a4=t=>pn({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),l4=Ot.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($3(this.options.emDash)),this.options.ellipsis!==!1&&t.push(F3(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(U3(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(H3(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(W3(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(q3(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(V3(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(K3(this.options.rightArrow)),this.options.copyright!==!1&&t.push(G3(this.options.copyright)),this.options.trademark!==!1&&t.push(J3(this.options.trademark)),this.options.servicemark!==!1&&t.push(Y3(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(X3(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(Q3(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(Z3(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(e4(this.options.notEqual)),this.options.laquo!==!1&&t.push(t4(this.options.laquo)),this.options.raquo!==!1&&t.push(n4(this.options.raquo)),this.options.multiplication!==!1&&t.push(r4(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(s4(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(i4(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(o4(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(a4(this.options.threeQuarters)),t}}),c4=l4,S_=Gr.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",Lt(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()}}}),u4=S_,Bn=[];for(var gp=0;gp<256;++gp)Bn.push((gp+256).toString(16).slice(1));function d4(t,e=0){return(Bn[t[e+0]]+Bn[t[e+1]]+Bn[t[e+2]]+Bn[t[e+3]]+"-"+Bn[t[e+4]]+Bn[t[e+5]]+"-"+Bn[t[e+6]]+Bn[t[e+7]]+"-"+Bn[t[e+8]]+Bn[t[e+9]]+"-"+Bn[t[e+10]]+Bn[t[e+11]]+Bn[t[e+12]]+Bn[t[e+13]]+Bn[t[e+14]]+Bn[t[e+15]]).toLowerCase()}var su,f4=new Uint8Array(16);function h4(){if(!su&&(su=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!su))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return su(f4)}var p4=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const L1={randomUUID:p4};function m4(t,e,n){if(L1.randomUUID&&!t)return L1.randomUUID();t=t||{};var r=t.random||(t.rng||h4)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,d4(r)}function g4(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 v4=Ot.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>m4(),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:y}=this.options;$u(h,x=>m.includes(x.type.name)&&x.attrs[g]===null).forEach(({node:x,pos:w})=>{f.setNodeMarkup(w,void 0,{...x.attrs,[g]:y({node:x,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 Pt({key:new Ht("uniqueID"),appendTransaction:(n,r,s)=>{const i=n.some(x=>x.docChanged)&&!r.doc.eq(s.doc),o=this.options.filterTransaction&&n.some(x=>{var w,E;return!((E=(w=this.options).filterTransaction)!=null&&E.call(w,x))});if(n.find(x=>x.getMeta("y-sync$"))||!i||o)return;const{tr:d}=s,{types:f,attributeName:h,generateID:m}=this.options,g=hv(r.doc,n),{mapping:y}=g;if(gv(g).forEach(({newRange:x})=>{const w=tC(s.doc,x,C=>f.includes(C.type.name)),E=w.map(({node:C})=>C.attrs[h]).filter(C=>C!==null);w.forEach(({node:C,pos:A},T)=>{var _;const O=(_=d.doc.nodeAt(A))==null?void 0:_.attrs[h];if(O===null){d.setNodeMarkup(A,void 0,{...C.attrs,[h]:m({node:C,pos:A})});return}const R=w[T+1];if(R&&C.content.size===0){const Q=d.doc.nodeAt(R.pos);if(Q!=null&&Q.attrs[h]&&Q.attrs[h]!==O)return;d.setNodeMarkup(R.pos,void 0,{...R.node.attrs,[h]:O}),E[T+1]=O;const P=m({node:C,pos:A});return d.setNodeMarkup(A,void 0,{...C.attrs,[h]:P}),E[T]=P,d}const B=g4(E),{deleted:D}=y.invert().mapResult(A);D&&B.includes(O)&&d.setNodeMarkup(A,void 0,{...C.attrs,[h]:m({node:C,pos:A})})})}),!!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)}),be.from(l)};return e=!1,new Pe(i(n.content),n.openStart,n.openEnd)}}})]}}),Pv=v4,vd=(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]},y4=/^\s*>\s$/,b4=mn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return vd("blockquote",{...Lt(this.options.HTMLAttributes,t),children:vd("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[na({find:y4,type:this.type})]}}),x4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,w4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,k4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,S4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,E4=Gr.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 vd("strong",{...Lt(this.options.HTMLAttributes,t),children:vd("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[no({find:x4,type:this.type}),no({find:k4,type:this.type})]},addPasteRules(){return[vi({find:w4,type:this.type}),vi({find:S4,type:this.type})]}}),N4=/(^|[^`])`([^`]+)`(?!`)$/,C4=/(^|[^`])`([^`]+)`(?!`)/g,_4=Gr.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Lt(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[no({find:N4,type:this.type})]},addPasteRules(){return[vi({find:C4,type:this.type})]}}),vp=4,T4=/^```([a-z]+)?[\s\n]$/,M4=/^~~~([a-z]+)?[\s\n]$/,E_=mn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:vp,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",Lt(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:vp,{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,y=r.doc.textBetween(f,h,`
|
|
182
|
-
`,`
|
|
183
|
-
`).split(`
|
|
184
|
-
`).map(b=>l+b).join(`
|
|
185
|
-
`);return d.replaceWith(f,h,r.schema.text(y)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:vp,{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(),y=r.doc.textBetween(h,m,`
|
|
186
|
-
`,`
|
|
187
|
-
`).split(`
|
|
188
|
-
`);let b=0,x=0;const w=f-h;for(let O=0;O<y.length;O+=1){if(x+y[O].length>=w){b=O;break}x+=y[O].length+1}const C=((d=y[b].match(/^ */))==null?void 0:d[0])||"",A=Math.min(C.length,n);if(A===0)return!0;let T=h;for(let O=0;O<b;O+=1)T+=y[O].length+1;return l.delete(T,T+A),f-T<=A&&l.setSelection(it.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:d,to:f}=s,g=r.doc.textBetween(d,f,`
|
|
189
|
-
`,`
|
|
190
|
-
`).split(`
|
|
191
|
-
`).map(y=>{var b;const x=((b=y.match(/^ */))==null?void 0:b[0])||"",w=Math.min(x.length,n);return y.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(ht.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Sg({find:T4,type:this.type,getAttributes:t=>({language:t[1]})}),Sg({find:M4,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Pt({key:new Ht("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(it.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),A4=E_,j4=mn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
196
|
-
|
|
197
|
-
`):""}),O4=mn.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",Lt(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()}}}),R4=mn.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]}`,Lt(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=>Sg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),I4=mn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Lt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!KI(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return cC(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(it.create(o.doc,d.pos+1)):d.nodeAfter.isBlock?o.setSelection(rt.create(o.doc,d.pos)):o.setSelection(it.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(it.create(o.doc,f+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[CC({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),L4=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,D4=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,P4=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,B4=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,z4=Gr.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",Lt(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[no({find:L4,type:this.type}),no({find:P4,type:this.type})]},addPasteRules(){return[vi({find:D4,type:this.type}),vi({find:B4,type:this.type})]}}),D1=" ",$4=" ",F4=mn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Lt(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===D1||r[0].text===$4)?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?D1:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),U4=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,H4=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,W4=Gr.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",Lt(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[no({find:U4,type:this.type})]},addPasteRules(){return[vi({find:H4,type:this.type})]}}),q4=mn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),V4=Ot.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(E4.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(b4.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(c_.configure(this.options.bulletList)),this.options.code!==!1&&s.push(_4.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(E_.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(j4.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(iP.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(oP.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(O4.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(R4.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(uP.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(I4.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(z4.configure(this.options.italic)),this.options.listItem!==!1&&s.push(u_.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(g_.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(WC.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(y_.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(F4.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(W4.configure(this.options.strike)),this.options.text!==!1&&s.push(q4.configure(this.options.text)),this.options.underline!==!1&&s.push(S_.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(cP.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),Bv=V4,yp,P1;function K4(){if(P1)return yp;P1=1;function t(L){return L instanceof Map?L.clear=L.delete=L.set=function(){throw new Error("map is read-only")}:L instanceof Set&&(L.add=L.clear=L.delete=function(){throw new Error("set is read-only")}),Object.freeze(L),Object.getOwnPropertyNames(L).forEach(te=>{const ve=L[te],Ue=typeof ve;(Ue==="object"||Ue==="function")&&!Object.isFrozen(ve)&&t(ve)}),L}class e{constructor(te){te.data===void 0&&(te.data={}),this.data=te.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(L){return L.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(L,...te){const ve=Object.create(null);for(const Ue in L)ve[Ue]=L[Ue];return te.forEach(function(Ue){for(const lt in Ue)ve[lt]=Ue[lt]}),ve}const s="</span>",i=L=>!!L.scope,o=(L,{prefix:te})=>{if(L.startsWith("language:"))return L.replace("language:","language-");if(L.includes(".")){const ve=L.split(".");return[`${te}${ve.shift()}`,...ve.map((Ue,lt)=>`${Ue}${"_".repeat(lt+1)}`)].join(" ")}return`${te}${L}`};class l{constructor(te,ve){this.buffer="",this.classPrefix=ve.classPrefix,te.walk(this)}addText(te){this.buffer+=n(te)}openNode(te){if(!i(te))return;const ve=o(te.scope,{prefix:this.classPrefix});this.span(ve)}closeNode(te){i(te)&&(this.buffer+=s)}value(){return this.buffer}span(te){this.buffer+=`<span class="${te}">`}}const d=(L={})=>{const te={children:[]};return Object.assign(te,L),te};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(te){this.top.children.push(te)}openNode(te){const ve=d({scope:te});this.add(ve),this.stack.push(ve)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(te){return this.constructor._walk(te,this.rootNode)}static _walk(te,ve){return typeof ve=="string"?te.addText(ve):ve.children&&(te.openNode(ve),ve.children.forEach(Ue=>this._walk(te,Ue)),te.closeNode(ve)),te}static _collapse(te){typeof te!="string"&&te.children&&(te.children.every(ve=>typeof ve=="string")?te.children=[te.children.join("")]:te.children.forEach(ve=>{f._collapse(ve)}))}}class h extends f{constructor(te){super(),this.options=te}addText(te){te!==""&&this.add(te)}startScope(te){this.openNode(te)}endScope(){this.closeNode()}__addSublanguage(te,ve){const Ue=te.root;ve&&(Ue.scope=`language:${ve}`),this.add(Ue)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(L){return L?typeof L=="string"?L:L.source:null}function g(L){return x("(?=",L,")")}function y(L){return x("(?:",L,")*")}function b(L){return x("(?:",L,")?")}function x(...L){return L.map(ve=>m(ve)).join("")}function w(L){const te=L[L.length-1];return typeof te=="object"&&te.constructor===Object?(L.splice(L.length-1,1),te):{}}function E(...L){return"("+(w(L).capture?"":"?:")+L.map(Ue=>m(Ue)).join("|")+")"}function C(L){return new RegExp(L.toString()+"|").exec("").length-1}function A(L,te){const ve=L&&L.exec(te);return ve&&ve.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function _(L,{joinWith:te}){let ve=0;return L.map(Ue=>{ve+=1;const lt=ve;let Ae=m(Ue),de="";for(;Ae.length>0;){const _e=T.exec(Ae);if(!_e){de+=Ae;break}de+=Ae.substring(0,_e.index),Ae=Ae.substring(_e.index+_e[0].length),_e[0][0]==="\\"&&_e[1]?de+="\\"+String(Number(_e[1])+lt):(de+=_e[0],_e[0]==="("&&ve++)}return de}).map(Ue=>`(${Ue})`).join(te)}const O=/\b\B/,R="[a-zA-Z]\\w*",B="[a-zA-Z_]\\w*",D="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Q="\\b(0b[01]+)",P="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",W=(L={})=>{const te=/^#![ ]*\//;return L.binary&&(L.begin=x(te,/.*\b/,L.binary,/\b.*/)),r({scope:"meta",begin:te,end:/$/,relevance:0,"on:begin":(ve,Ue)=>{ve.index!==0&&Ue.ignoreMatch()}},L)},$={begin:"\\\\[\\s\\S]",relevance:0},H={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[$]},J={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[$]},re={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},V=function(L,te,ve={}){const Ue=r({scope:"comment",begin:L,end:te,contains:[]},ve);Ue.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 lt=E("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Ue.contains.push({begin:x(/[ ]+/,"(",lt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ue},ie=V("//","$"),z=V("/\\*","\\*/"),M=V("#","$"),I={scope:"number",begin:D,relevance:0},Z={scope:"number",begin:U,relevance:0},le={scope:"number",begin:Q,relevance:0},ge={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[$,{begin:/\[/,end:/\]/,relevance:0,contains:[$]}]},se={scope:"title",begin:R,relevance:0},xe={scope:"title",begin:B,relevance:0},fe={begin:"\\.\\s*"+B,relevance:0};var We=Object.freeze({__proto__:null,APOS_STRING_MODE:H,BACKSLASH_ESCAPE:$,BINARY_NUMBER_MODE:le,BINARY_NUMBER_RE:Q,COMMENT:V,C_BLOCK_COMMENT_MODE:z,C_LINE_COMMENT_MODE:ie,C_NUMBER_MODE:Z,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(L){return Object.assign(L,{"on:begin":(te,ve)=>{ve.data._beginMatch=te[1]},"on:end":(te,ve)=>{ve.data._beginMatch!==te[1]&&ve.ignoreMatch()}})},HASH_COMMENT_MODE:M,IDENT_RE:R,MATCH_NOTHING_RE:O,METHOD_GUARD:fe,NUMBER_MODE:I,NUMBER_RE:D,PHRASAL_WORDS_MODE:re,QUOTE_STRING_MODE:J,REGEXP_MODE:ge,RE_STARTERS_RE:P,SHEBANG:W,TITLE_MODE:se,UNDERSCORE_IDENT_RE:B,UNDERSCORE_TITLE_MODE:xe});function Qe(L,te){L.input[L.index-1]==="."&&te.ignoreMatch()}function ot(L,te){L.className!==void 0&&(L.scope=L.className,delete L.className)}function st(L,te){te&&L.beginKeywords&&(L.begin="\\b("+L.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",L.__beforeBegin=Qe,L.keywords=L.keywords||L.beginKeywords,delete L.beginKeywords,L.relevance===void 0&&(L.relevance=0))}function Ie(L,te){Array.isArray(L.illegal)&&(L.illegal=E(...L.illegal))}function dt(L,te){if(L.match){if(L.begin||L.end)throw new Error("begin & end are not supported with match");L.begin=L.match,delete L.match}}function Ge(L,te){L.relevance===void 0&&(L.relevance=1)}const bt=(L,te)=>{if(!L.beforeMatch)return;if(L.starts)throw new Error("beforeMatch cannot be used with starts");const ve=Object.assign({},L);Object.keys(L).forEach(Ue=>{delete L[Ue]}),L.keywords=ve.keywords,L.begin=x(ve.beforeMatch,g(ve.begin)),L.starts={relevance:0,contains:[Object.assign(ve,{endsParent:!0})]},L.relevance=0,delete ve.beforeMatch},xt=["of","and","for","in","not","or","if","then","parent","list","value"],$t="keyword";function Ke(L,te,ve=$t){const Ue=Object.create(null);return typeof L=="string"?lt(ve,L.split(" ")):Array.isArray(L)?lt(ve,L):Object.keys(L).forEach(function(Ae){Object.assign(Ue,Ke(L[Ae],te,Ae))}),Ue;function lt(Ae,de){te&&(de=de.map(_e=>_e.toLowerCase())),de.forEach(function(_e){const ze=_e.split("|");Ue[ze[0]]=[Ae,pt(ze[0],ze[1])]})}}function pt(L,te){return te?Number(te):Ft(L)?0:1}function Ft(L){return xt.includes(L.toLowerCase())}const Je={},Y=L=>{console.error(L)},pe=(L,...te)=>{console.log(`WARN: ${L}`,...te)},G=(L,te)=>{Je[`${L}/${te}`]||(console.log(`Deprecated as of ${L}. ${te}`),Je[`${L}/${te}`]=!0)},oe=new Error;function ue(L,te,{key:ve}){let Ue=0;const lt=L[ve],Ae={},de={};for(let _e=1;_e<=te.length;_e++)de[_e+Ue]=lt[_e],Ae[_e+Ue]=!0,Ue+=C(te[_e-1]);L[ve]=de,L[ve]._emit=Ae,L[ve]._multi=!0}function Fe(L){if(Array.isArray(L.begin)){if(L.skip||L.excludeBegin||L.returnBegin)throw Y("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),oe;if(typeof L.beginScope!="object"||L.beginScope===null)throw Y("beginScope must be object"),oe;ue(L,L.begin,{key:"beginScope"}),L.begin=_(L.begin,{joinWith:""})}}function Me(L){if(Array.isArray(L.end)){if(L.skip||L.excludeEnd||L.returnEnd)throw Y("skip, excludeEnd, returnEnd not compatible with endScope: {}"),oe;if(typeof L.endScope!="object"||L.endScope===null)throw Y("endScope must be object"),oe;ue(L,L.end,{key:"endScope"}),L.end=_(L.end,{joinWith:""})}}function K(L){L.scope&&typeof L.scope=="object"&&L.scope!==null&&(L.beginScope=L.scope,delete L.scope)}function me(L){K(L),typeof L.beginScope=="string"&&(L.beginScope={_wrap:L.beginScope}),typeof L.endScope=="string"&&(L.endScope={_wrap:L.endScope}),Fe(L),Me(L)}function ye(L){function te(de,_e){return new RegExp(m(de),"m"+(L.case_insensitive?"i":"")+(L.unicodeRegex?"u":"")+(_e?"g":""))}class ve{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(_e,ze){ze.position=this.position++,this.matchIndexes[this.matchAt]=ze,this.regexes.push([ze,_e]),this.matchAt+=C(_e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const _e=this.regexes.map(ze=>ze[1]);this.matcherRe=te(_(_e,{joinWith:"|"}),!0),this.lastIndex=0}exec(_e){this.matcherRe.lastIndex=this.lastIndex;const ze=this.matcherRe.exec(_e);if(!ze)return null;const Wt=ze.findIndex((an,ft)=>ft>0&&an!==void 0),wt=this.matchIndexes[Wt];return ze.splice(0,Wt),Object.assign(ze,wt)}}class Ue{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(_e){if(this.multiRegexes[_e])return this.multiRegexes[_e];const ze=new ve;return this.rules.slice(_e).forEach(([Wt,wt])=>ze.addRule(Wt,wt)),ze.compile(),this.multiRegexes[_e]=ze,ze}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(_e,ze){this.rules.push([_e,ze]),ze.type==="begin"&&this.count++}exec(_e){const ze=this.getMatcher(this.regexIndex);ze.lastIndex=this.lastIndex;let Wt=ze.exec(_e);if(this.resumingScanAtSamePosition()&&!(Wt&&Wt.index===this.lastIndex)){const wt=this.getMatcher(0);wt.lastIndex=this.lastIndex+1,Wt=wt.exec(_e)}return Wt&&(this.regexIndex+=Wt.position+1,this.regexIndex===this.count&&this.considerAll()),Wt}}function lt(de){const _e=new Ue;return de.contains.forEach(ze=>_e.addRule(ze.begin,{rule:ze,type:"begin"})),de.terminatorEnd&&_e.addRule(de.terminatorEnd,{type:"end"}),de.illegal&&_e.addRule(de.illegal,{type:"illegal"}),_e}function Ae(de,_e){const ze=de;if(de.isCompiled)return ze;[ot,dt,me,bt].forEach(wt=>wt(de,_e)),L.compilerExtensions.forEach(wt=>wt(de,_e)),de.__beforeBegin=null,[st,Ie,Ge].forEach(wt=>wt(de,_e)),de.isCompiled=!0;let Wt=null;return typeof de.keywords=="object"&&de.keywords.$pattern&&(de.keywords=Object.assign({},de.keywords),Wt=de.keywords.$pattern,delete de.keywords.$pattern),Wt=Wt||/\w+/,de.keywords&&(de.keywords=Ke(de.keywords,L.case_insensitive)),ze.keywordPatternRe=te(Wt,!0),_e&&(de.begin||(de.begin=/\B|\b/),ze.beginRe=te(ze.begin),!de.end&&!de.endsWithParent&&(de.end=/\B|\b/),de.end&&(ze.endRe=te(ze.end)),ze.terminatorEnd=m(ze.end)||"",de.endsWithParent&&_e.terminatorEnd&&(ze.terminatorEnd+=(de.end?"|":"")+_e.terminatorEnd)),de.illegal&&(ze.illegalRe=te(de.illegal)),de.contains||(de.contains=[]),de.contains=[].concat(...de.contains.map(function(wt){return Re(wt==="self"?de:wt)})),de.contains.forEach(function(wt){Ae(wt,ze)}),de.starts&&Ae(de.starts,_e),ze.matcher=lt(ze),ze}if(L.compilerExtensions||(L.compilerExtensions=[]),L.contains&&L.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return L.classNameAliases=r(L.classNameAliases||{}),Ae(L)}function Ce(L){return L?L.endsWithParent||Ce(L.starts):!1}function Re(L){return L.variants&&!L.cachedVariants&&(L.cachedVariants=L.variants.map(function(te){return r(L,{variants:null},te)})),L.cachedVariants?L.cachedVariants:Ce(L)?r(L,{starts:L.starts?r(L.starts):null}):Object.isFrozen(L)?r(L):L}var Be="11.11.1";class Ee extends Error{constructor(te,ve){super(te),this.name="HTMLInjectionError",this.html=ve}}const et=n,gt=r,Tt=Symbol("nomatch"),Jt=7,Mt=function(L){const te=Object.create(null),ve=Object.create(null),Ue=[];let lt=!0;const Ae="Could not find the language '{}', did you forget to load/include a language module?",de={disableAutodetect:!0,name:"Plain text",contains:[]};let _e={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function ze(je){return _e.noHighlightRe.test(je)}function Wt(je){let tt=je.className+" ";tt+=je.parentNode?je.parentNode.className:"";const kt=_e.languageDetectRe.exec(tt);if(kt){const _t=Br(kt[1]);return _t||(pe(Ae.replace("{}",kt[1])),pe("Falling back to no-highlight mode for this block.",je)),_t?kt[1]:"no-highlight"}return tt.split(/\s+/).find(_t=>ze(_t)||Br(_t))}function wt(je,tt,kt){let _t="",gn="";typeof tt=="object"?(_t=je,kt=tt.ignoreIllegals,gn=tt.language):(G("10.7.0","highlight(lang, code, ...args) has been deprecated."),G("10.7.0",`Please use highlight(code, options) instead.
|
|
200
|
-
https://github.com/highlightjs/highlight.js/issues/2277`),gn=je,_t=tt),kt===void 0&&(kt=!0);const rn={code:_t,language:gn};Si("before:highlight",rn);const Qr=rn.result?rn.result:an(rn.language,rn.code,kt);return Qr.code=rn.code,Si("after:highlight",Qr),Qr}function an(je,tt,kt,_t){const gn=Object.create(null);function rn(Le,qe){return Le.keywords[qe]}function Qr(){if(!yt.keywords){vn.addText(Ut);return}let Le=0;yt.keywordPatternRe.lastIndex=0;let qe=yt.keywordPatternRe.exec(Ut),mt="";for(;qe;){mt+=Ut.substring(Le,qe.index);const At=kr.case_insensitive?qe[0].toLowerCase():qe[0],cn=rn(yt,At);if(cn){const[_n,sf]=cn;if(vn.addText(mt),mt="",gn[At]=(gn[At]||0)+1,gn[At]<=Jt&&(Ci+=sf),_n.startsWith("_"))mt+=qe[0];else{const $l=kr.classNameAliases[_n]||_n;Zn(qe[0],$l)}}else mt+=qe[0];Le=yt.keywordPatternRe.lastIndex,qe=yt.keywordPatternRe.exec(Ut)}mt+=Ut.substring(Le),vn.addText(mt)}function fo(){if(Ut==="")return;let Le=null;if(typeof yt.subLanguage=="string"){if(!te[yt.subLanguage]){vn.addText(Ut);return}Le=an(yt.subLanguage,Ut,!0,ua[yt.subLanguage]),ua[yt.subLanguage]=Le._top}else Le=En(Ut,yt.subLanguage.length?yt.subLanguage:null);yt.relevance>0&&(Ci+=Le.relevance),vn.__addSublanguage(Le._emitter,Le.language)}function Qn(){yt.subLanguage!=null?fo():Qr(),Ut=""}function Zn(Le,qe){Le!==""&&(vn.startScope(qe),vn.addText(Le),vn.endScope())}function Ei(Le,qe){let mt=1;const At=qe.length-1;for(;mt<=At;){if(!Le._emit[mt]){mt++;continue}const cn=kr.classNameAliases[Le[mt]]||Le[mt],_n=qe[mt];cn?Zn(_n,cn):(Ut=_n,Qr(),Ut=""),mt++}}function Ls(Le,qe){return Le.scope&&typeof Le.scope=="string"&&vn.openNode(kr.classNameAliases[Le.scope]||Le.scope),Le.beginScope&&(Le.beginScope._wrap?(Zn(Ut,kr.classNameAliases[Le.beginScope._wrap]||Le.beginScope._wrap),Ut=""):Le.beginScope._multi&&(Ei(Le.beginScope,qe),Ut="")),yt=Object.create(Le,{parent:{value:yt}}),yt}function Ni(Le,qe,mt){let At=A(Le.endRe,mt);if(At){if(Le["on:end"]){const cn=new e(Le);Le["on:end"](qe,cn),cn.isMatchIgnored&&(At=!1)}if(At){for(;Le.endsParent&&Le.parent;)Le=Le.parent;return Le}}if(Le.endsWithParent)return Ni(Le.parent,qe,mt)}function nf(Le){return yt.matcher.regexIndex===0?(Ut+=Le[0],1):(Bs=!0,0)}function rf(Le){const qe=Le[0],mt=Le.rule,At=new e(mt),cn=[mt.__beforeBegin,mt["on:begin"]];for(const _n of cn)if(_n&&(_n(Le,At),At.isMatchIgnored))return nf(qe);return mt.skip?Ut+=qe:(mt.excludeBegin&&(Ut+=qe),Qn(),!mt.returnBegin&&!mt.excludeBegin&&(Ut=qe)),Ls(mt,Le),mt.returnBegin?0:qe.length}function la(Le){const qe=Le[0],mt=tt.substring(Le.index),At=Ni(yt,Le,mt);if(!At)return Tt;const cn=yt;yt.endScope&&yt.endScope._wrap?(Qn(),Zn(qe,yt.endScope._wrap)):yt.endScope&&yt.endScope._multi?(Qn(),Ei(yt.endScope,Le)):cn.skip?Ut+=qe:(cn.returnEnd||cn.excludeEnd||(Ut+=qe),Qn(),cn.excludeEnd&&(Ut=qe));do yt.scope&&vn.closeNode(),!yt.skip&&!yt.subLanguage&&(Ci+=yt.relevance),yt=yt.parent;while(yt!==At.parent);return At.starts&&Ls(At.starts,Le),cn.returnEnd?0:qe.length}function zl(){const Le=[];for(let qe=yt;qe!==kr;qe=qe.parent)qe.scope&&Le.unshift(qe.scope);Le.forEach(qe=>vn.openNode(qe))}let Ds={};function Ps(Le,qe){const mt=qe&&qe[0];if(Ut+=Le,mt==null)return Qn(),0;if(Ds.type==="begin"&&qe.type==="end"&&Ds.index===qe.index&&mt===""){if(Ut+=tt.slice(qe.index,qe.index+1),!lt){const At=new Error(`0 width match regex (${je})`);throw At.languageName=je,At.badRule=Ds.rule,At}return 1}if(Ds=qe,qe.type==="begin")return rf(qe);if(qe.type==="illegal"&&!kt){const At=new Error('Illegal lexeme "'+mt+'" for mode "'+(yt.scope||"<unnamed>")+'"');throw At.mode=yt,At}else if(qe.type==="end"){const At=la(qe);if(At!==Tt)return At}if(qe.type==="illegal"&&mt==="")return Ut+=`
|
|
201
|
-
`,1;if(_i>1e5&&_i>qe.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ut+=mt,mt.length}const kr=Br(je);if(!kr)throw Y(Ae.replace("{}",je)),new Error('Unknown language: "'+je+'"');const ca=ye(kr);let Rt="",yt=_t||ca;const ua={},vn=new _e.__emitter(_e);zl();let Ut="",Ci=0,Zr=0,_i=0,Bs=!1;try{if(kr.__emitTokens)kr.__emitTokens(tt,vn);else{for(yt.matcher.considerAll();;){_i++,Bs?Bs=!1:yt.matcher.considerAll(),yt.matcher.lastIndex=Zr;const Le=yt.matcher.exec(tt);if(!Le)break;const qe=tt.substring(Zr,Le.index),mt=Ps(qe,Le);Zr=Le.index+mt}Ps(tt.substring(Zr))}return vn.finalize(),Rt=vn.toHTML(),{language:je,value:Rt,relevance:Ci,illegal:!1,_emitter:vn,_top:yt}}catch(Le){if(Le.message&&Le.message.includes("Illegal"))return{language:je,value:et(tt),illegal:!0,relevance:0,_illegalBy:{message:Le.message,index:Zr,context:tt.slice(Zr-100,Zr+100),mode:Le.mode,resultSoFar:Rt},_emitter:vn};if(lt)return{language:je,value:et(tt),illegal:!1,relevance:0,errorRaised:Le,_emitter:vn,_top:yt};throw Le}}function ft(je){const tt={value:et(je),illegal:!1,relevance:0,_top:de,_emitter:new _e.__emitter(_e)};return tt._emitter.addText(je),tt}function En(je,tt){tt=tt||_e.languages||Object.keys(te);const kt=ft(je),_t=tt.filter(Br).filter(Bl).map(Qn=>an(Qn,je,!1));_t.unshift(kt);const gn=_t.sort((Qn,Zn)=>{if(Qn.relevance!==Zn.relevance)return Zn.relevance-Qn.relevance;if(Qn.language&&Zn.language){if(Br(Qn.language).supersetOf===Zn.language)return 1;if(Br(Zn.language).supersetOf===Qn.language)return-1}return 0}),[rn,Qr]=gn,fo=rn;return fo.secondBest=Qr,fo}function ne(je,tt,kt){const _t=tt&&ve[tt]||kt;je.classList.add("hljs"),je.classList.add(`language-${_t}`)}function ke(je){let tt=null;const kt=Wt(je);if(ze(kt))return;if(Si("before:highlightElement",{el:je,language:kt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(_e.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),_e.throwUnescapedHTML))throw new Ee("One of your code blocks includes unescaped HTML.",je.innerHTML);tt=je;const _t=tt.textContent,gn=kt?wt(_t,{language:kt,ignoreIllegals:!0}):En(_t);je.innerHTML=gn.value,je.dataset.highlighted="yes",ne(je,kt,gn.language),je.result={language:gn.language,re:gn.relevance,relevance:gn.relevance},gn.secondBest&&(je.secondBest={language:gn.secondBest.language,relevance:gn.secondBest.relevance}),Si("after:highlightElement",{el:je,result:gn,text:_t})}function $e(je){_e=gt(_e,je)}const at=()=>{xn(),G("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Nt(){xn(),G("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let ln=!1;function xn(){function je(){xn()}if(document.readyState==="loading"){ln||window.addEventListener("DOMContentLoaded",je,!1),ln=!0;return}document.querySelectorAll(_e.cssSelector).forEach(ke)}function Zt(je,tt){let kt=null;try{kt=tt(L)}catch(_t){if(Y("Language definition for '{}' could not be registered.".replace("{}",je)),lt)Y(_t);else throw _t;kt=de}kt.name||(kt.name=je),te[je]=kt,kt.rawDefinition=tt.bind(null,L),kt.aliases&&Pl(kt.aliases,{languageName:je})}function tn(je){delete te[je];for(const tt of Object.keys(ve))ve[tt]===je&&delete ve[tt]}function Is(){return Object.keys(te)}function Br(je){return je=(je||"").toLowerCase(),te[je]||te[ve[je]]}function Pl(je,{languageName:tt}){typeof je=="string"&&(je=[je]),je.forEach(kt=>{ve[kt.toLowerCase()]=tt})}function Bl(je){const tt=Br(je);return tt&&!tt.disableAutodetect}function nn(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=tt=>{je["before:highlightBlock"](Object.assign({block:tt.el},tt))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=tt=>{je["after:highlightBlock"](Object.assign({block:tt.el},tt))})}function tf(je){nn(je),Ue.push(je)}function aa(je){const tt=Ue.indexOf(je);tt!==-1&&Ue.splice(tt,1)}function Si(je,tt){const kt=je;Ue.forEach(function(_t){_t[kt]&&_t[kt](tt)})}function uo(je){return G("10.7.0","highlightBlock will be removed entirely in v12.0"),G("10.7.0","Please use highlightElement now."),ke(je)}Object.assign(L,{highlight:wt,highlightAuto:En,highlightAll:xn,highlightElement:ke,highlightBlock:uo,configure:$e,initHighlighting:at,initHighlightingOnLoad:Nt,registerLanguage:Zt,unregisterLanguage:tn,listLanguages:Is,getLanguage:Br,registerAliases:Pl,autoDetection:Bl,inherit:gt,addPlugin:tf,removePlugin:aa}),L.debugMode=function(){lt=!1},L.safeMode=function(){lt=!0},L.versionString=Be,L.regex={concat:x,lookahead:g,either:E,optional:b,anyNumberOfTimes:y};for(const je in We)typeof We[je]=="object"&&t(We[je]);return Object.assign(L,We),L},q=Mt({});return q.newInstance=()=>Mt({}),yp=q,q.HighlightJS=q,q.default=q,yp}var G4=K4();const N_=El(G4);function C_(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?C_(n.children,r):{text:n.value,classes:r}})}function B1(t){return t.value||t.children||[]}function J4(t){return!!N_.getLanguage(t)}function z1({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return $u(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)||J4(d)||(o=n.registered)!=null&&o.call(n,d))?B1(n.highlight(d,i.node.textContent)):B1(n.highlightAuto(i.node.textContent));C_(h).forEach(m=>{const g=l+m.text.length;if(m.classes.length){const y=zt.inline(l,g,{class:m.classes.join(" ")});s.push(y)}l=g})}),jt.create(t,s)}function Y4(t){return typeof t=="function"}function X4({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>Y4(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new Pt({key:new Ht("lowlight"),state:{init:(s,{doc:i})=>z1({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=$u(o.doc,g=>g.type.name===t),m=$u(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(y=>y.pos>=g.from&&y.pos+y.node.nodeSize<=g.to)))?z1({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 Q4=A4.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))||[],X4({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),Z4=Q4;function e6(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},y=e.optional(s)+t.IDENT_RE+"\\s*\\(",b=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],x=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],E=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],T={type:x,keyword:b,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},_={className:"function.dispatch",relevance:0,keywords:{_hint:E},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},O=[_,m,l,n,t.C_BLOCK_COMMENT_MODE,h,f],R={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:O.concat([{begin:/\(/,end:/\)/,keywords:T,contains:O.concat(["self"]),relevance:0}]),relevance:0},B={className:"function",begin:"("+o+"[\\*&\\s]+)+"+y,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:y,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,l,{begin:/\(/,end:/\)/,keywords:T,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:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(R,B,_,O,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:T,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function t6(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=e6(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 n6(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"],y=t.SHEBANG({binary:`(${g.join("|")})`,relevance:10}),b={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},x=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],w=["true","false"],E={match:/(\/[a-z._-]+)+/},C=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],A=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],T=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],_=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:x,literal:w,built_in:[...C,...A,"set","shopt",...T,..._]},contains:[y,t.SHEBANG(),b,m,i,o,E,l,d,f,h,n]}}function r6(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},y=e.optional(s)+t.IDENT_RE+"\\s*\\(",w={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},E=[m,l,n,t.C_BLOCK_COMMENT_MODE,h,f],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:w,contains:E.concat([{begin:/\(/,end:/\)/,keywords:w,contains:E.concat(["self"]),relevance:0}]),relevance:0},A={begin:"("+o+"[\\*&\\s]+)+"+y,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:w,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:w,relevance:0},{begin:y,returnBegin:!0,contains:[t.inherit(g,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:w,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,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(C,A,E,[m,{begin:t.IDENT_RE+"::",keywords:w},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:m,strings:f,keywords:w}}}function s6(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},y=e.optional(s)+t.IDENT_RE+"\\s*\\(",b=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],x=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],w=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],E=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],T={type:x,keyword:b,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:w},_={className:"function.dispatch",relevance:0,keywords:{_hint:E},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},O=[_,m,l,n,t.C_BLOCK_COMMENT_MODE,h,f],R={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:O.concat([{begin:/\(/,end:/\)/,keywords:T,contains:O.concat(["self"]),relevance:0}]),relevance:0},B={className:"function",begin:"("+o+"[\\*&\\s]+)+"+y,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:y,returnBegin:!0,contains:[g],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,h,l,{begin:/\(/,end:/\)/,keywords:T,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:T,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(R,B,_,O,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:T,contains:["self",l]},{begin:t.IDENT_RE+"::",keywords:T},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function i6(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},y=t.inherit(g,{illegal:/\n/}),b={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,y]},x={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]},w=t.inherit(x,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]});g.contains=[x,b,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.C_BLOCK_COMMENT_MODE],y.contains=[w,b,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const E={variants:[f,x,b,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},C={begin:"<",end:">",contains:[{beginKeywords:"in out"},l]},A=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",T={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},E,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},l,C,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,C,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+A+"\\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,C],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[E,d,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},T]}}const o6=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_-]*/}}),a6=["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"],l6=["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"],c6=[...a6,...l6],u6=["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(),d6=["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(),f6=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),h6=["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 p6(t){const e=t.regex,n=o6(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:":("+d6.join("|")+")"},{begin:":(:)?("+f6.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+h6.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:u6.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+c6.join("|")+")\\b"}]}}function m6(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 g6(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 v6(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 y6(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 Uo="[0-9](_*[0-9])*",iu=`\\.(${Uo})`,ou="[0-9a-fA-F](_*[0-9a-fA-F])*",$1={className:"number",variants:[{begin:`(\\b(${Uo})((${iu})|\\.)?|(${iu}))[eE][+-]?(${Uo})[fFdD]?\\b`},{begin:`\\b(${Uo})((${iu})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${iu})[fFdD]?\\b`},{begin:`\\b(${Uo})[fFdD]\\b`},{begin:`\\b0[xX]((${ou})\\.?|(${ou})?\\.(${ou}))[pP][+-]?(${Uo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${ou})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function __(t,e,n){return n===-1?"":t.replace(e,r=>__(t,e,n-1))}function b6(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+__("(?:<"+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,$1,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},$1,f]}}const F1="[A-Za-z$_][0-9A-Za-z$_]*",x6=["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"],w6=["true","false","null","undefined","NaN","Infinity"],T_=["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"],M_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],A_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],k6=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],S6=[].concat(A_,T_,M_);function E6(t){const e=t.regex,n=(V,{after:ie})=>{const z="</"+V[0].slice(1);return V.input.indexOf(z,ie)!==-1},r=F1,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,ie)=>{const z=V[0].length+V.index,M=V.input[z];if(M==="<"||M===","){ie.ignoreMatch();return}M===">"&&(n(V,{after:z})||ie.ignoreMatch());let I;const Z=V.input.substring(z);if(I=Z.match(/^\s*=/)){ie.ignoreMatch();return}if((I=Z.match(/^\s+extends\s+/))&&I.index===0){ie.ignoreMatch();return}}},l={$pattern:F1,keyword:x6,literal:w6,built_in:S6,"variable.language":k6},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:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},A=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,x,w,{match:/\$\d+/},m];g.contains=A.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(A)});const T=[].concat(C,g.contains),_=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(T)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:_},R={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"}}]},B={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:{_:[...T_,...M_]}},D={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},Q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function P(V){return e.concat("(?!",V.join("|"),")")}const W={match:e.concat(/\b/,P([...A_,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},$={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},J="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",re={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(J)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:B},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),D,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,x,w,C,{match:/\$\d+/},m,B,{scope:"attr",match:r+e.lookahead(":"),relevance:0},re,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:J,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"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},$,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},W,Q,R,H,{match:/\$[(.]/}]}}function N6(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 Ho="[0-9](_*[0-9])*",au=`\\.(${Ho})`,lu="[0-9a-fA-F](_*[0-9a-fA-F])*",C6={className:"number",variants:[{begin:`(\\b(${Ho})((${au})|\\.)?|(${au}))[eE][+-]?(${Ho})[fFdD]?\\b`},{begin:`\\b(${Ho})((${au})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${au})[fFdD]?\\b`},{begin:`\\b(${Ho})[fFdD]\\b`},{begin:`\\b0[xX]((${lu})\\.?|(${lu})?\\.(${lu}))[pP][+-]?(${Ho})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${lu})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function _6(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=C6,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 T6=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_-]*/}}),M6=["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"],A6=["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"],j6=[...M6,...A6],O6=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),j_=["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(),O_=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),R6=["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(),I6=j_.concat(O_).sort().reverse();function L6(t){const e=T6(t),n=I6,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",o=[],l=[],d=function(A){return{className:"string",begin:"~?"+A+".*?"+A}},f=function(A,T,_){return{className:A,begin:T,relevance:_}},h={$pattern:/[a-z-]+/,keyword:r,attribute:O6.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}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(l)},b={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+R6.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:l}}]},x={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}},E={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,y,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+j6.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:":("+j_.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+O_.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:g},{begin:"!important"},e.FUNCTION_DISPATCH]},C={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[E]};return o.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,x,w,C,b,E,y,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function D6(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 P6(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 B6(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 y=[n,d];return[f,h,m,g].forEach(E=>{E.contains=E.contains.concat(y)}),y=y.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,i,f,h,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},s,r,d,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function z6(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 $6(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=(x,w,E="\\1")=>{const C=E==="\\1"?E:e.concat(E,w);return e.concat(e.concat("(?:",x,")"),w,/(?:\\.|[^\\\/])*?/,C,/(?:\\.|[^\\\/])*?/,E,r)},y=(x,w,E)=>e.concat(e.concat("(?:",x,")"),w,/(?:\\.|[^\\\/])*?/,E,r),b=[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:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",e.either(...m,{capture:!0}),/\1/)},{begin:y("m|qr",/\(/,/\)/)},{begin:y("m|qr",/\[/,/\]/)},{begin:y("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,l]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,l,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=b,o.contains=b,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:b}}function F6(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":($,H)=>{H.data._beginMatch=$[1]||$[2]},"on:end":($,H)=>{H.data._beginMatch!==$[1]&&H.ignoreMatch()}},g=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
|
|
203
|
-
]`,b={scope:"string",variants:[h,f,m,g]},x={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},w=["false","null","true"],E=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],C=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],T={keyword:E,literal:($=>{const H=[];return $.forEach(J=>{H.push(J),J.toLowerCase()===J?H.push(J.toUpperCase()):H.push(J.toLowerCase())}),H})(w),built_in:C},_=$=>$.map(H=>H.replace(/\|\d+$/,"")),O={variants:[{match:[/new/,e.concat(y,"+"),e.concat("(?!",_(C).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},R=e.concat(r,"\\b(?!\\()"),B={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),R],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),R],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"}}]},D={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},U={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[D,o,B,t.C_BLOCK_COMMENT_MODE,b,x,O]},Q={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",_(E).join("\\b|"),"|",_(C).join("\\b|"),"\\b)"),r,e.concat(y,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[U]};U.contains.push(Q);const P=[D,B,t.C_BLOCK_COMMENT_MODE,b,x,O],W={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",...P]},...P,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:T,contains:[W,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},l,{scope:"variable.language",match:/\$this\b/},o,Q,B,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},O,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:T,contains:["self",W,o,B,t.C_BLOCK_COMMENT_MODE,b,x]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},b,x]}}function U6(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 H6(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function W6(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])*",y=`(\\b(${g}))?\\.(${g})|\\b(${g})\\.`,b=`\\b|${r.join("|")}`,x={className:"number",relevance:0,variants:[{begin:`(\\b(${g})|(${y}))[eE][+-]?(${g})[jJ]?(?=${b})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${b})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${b})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${b})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${b})`},{begin:`\\b(${g})[jJ](?=${b})`}]},w={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},E={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",d,x,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,x,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[d,x,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,w,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[E]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[x,E,m]}]}}function q6(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function V6(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 K6(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",y="[0-9](_?[0-9])*",b={className:"number",relevance:0,variants:[{begin:`\\b(${g})(\\.(${y}))?([eE][+-]?(${y})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},x={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},O=[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:[x]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},b,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,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=O,x.contains=O;const U=[{begin:/^\s*=>/,starts:{end:"$",contains:O}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:O}}];return f.unshift(d),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(U).concat(f).concat(O)}}function G6(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 J6=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_-]*/}}),Y6=["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"],X6=["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"],Q6=[...Y6,...X6],Z6=["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(),eB=["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(),tB=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),nB=["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 rB(t){const e=J6(t),n=tB,r=eB,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("+Q6.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("+nB.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:Z6.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 sB(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function iB(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"],y=h,b=[...f,...d].filter(_=>!h.includes(_)),x={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},E={match:e.concat(/\b/,e.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function C(_){return e.concat(/\b/,e.either(..._.map(O=>O.replace(/\s+/,"\\s+"))),/\b/)}const A={scope:"keyword",match:C(g),relevance:0};function T(_,{exceptions:O,when:R}={}){const B=R;return O=O||[],_.map(D=>D.match(/\|\d+$/)||O.includes(D)?D:B(D)?`${D}|0`:D)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(b,{when:_=>_.length<3}),literal:i,type:l,built_in:m},contains:[{scope:"type",match:C(o)},A,E,x,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,w]}}function R_(t){return t?typeof t=="string"?t:t.source:null}function Wa(t){return qt("(?=",t,")")}function qt(...t){return t.map(n=>R_(n)).join("")}function oB(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function nr(...t){return"("+(oB(t).capture?"":"?:")+t.map(r=>R_(r)).join("|")+")"}const zv=t=>qt(/\b/,t,/\w$/.test(t)?/\b/:/\B/),aB=["Protocol","Type"].map(zv),U1=["init","self"].map(zv),lB=["Any","Self"],bp=["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"],H1=["false","nil","true"],cB=["assignment","associativity","higherThan","left","lowerThan","none","right"],uB=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],W1=["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"],I_=nr(/[/=\-+!*%<>&|^~?]/,/[\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]/),L_=nr(I_,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),xp=qt(I_,L_,"*"),D_=nr(/[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]/),yd=nr(D_,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ss=qt(D_,yd,"*"),cu=qt(/[A-Z]/,yd,"*"),dB=["attached","autoclosure",qt(/convention\(/,nr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",qt(/objc\(/,ss,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],fB=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function hB(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,nr(...aB,...U1)],className:{2:"keyword"}},i={match:qt(/\./,nr(...bp)),relevance:0},o=bp.filter(Ge=>typeof Ge=="string").concat(["_|0"]),l=bp.filter(Ge=>typeof Ge!="string").concat(lB).map(zv),d={variants:[{className:"keyword",match:nr(...l,...U1)}]},f={$pattern:nr(/\b\w+/,/#\w+/),keyword:o.concat(uB),literal:H1},h=[s,i,d],m={match:qt(/\./,nr(...W1)),relevance:0},g={className:"built_in",match:qt(/\b/,nr(...W1),/(?=\()/)},y=[m,g],b={match:/->/,relevance:0},x={className:"operator",relevance:0,variants:[{match:xp},{match:`\\.(\\.|${L_})+`}]},w=[b,x],E="([0-9]_*)+",C="([0-9a-fA-F]_*)+",A={className:"number",relevance:0,variants:[{match:`\\b(${E})(\\.(${E}))?([eE][+-]?(${E}))?\\b`},{match:`\\b0x(${C})(\\.(${C}))?([pP][+-]?(${E}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(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)/)}),O=(Ge="")=>({className:"subst",label:"interpol",begin:qt(/\\/,Ge,/\(/),end:/\)/}),R=(Ge="")=>({begin:qt(Ge,/"""/),end:qt(/"""/,Ge),contains:[T(Ge),_(Ge),O(Ge)]}),B=(Ge="")=>({begin:qt(Ge,/"/),end:qt(/"/,Ge),contains:[T(Ge),O(Ge)]}),D={className:"string",variants:[R(),R("#"),R("##"),R("###"),B(),B("#"),B("##"),B("###")]},U=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],Q={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:U},P=Ge=>{const bt=qt(Ge,/\//),xt=qt(/\//,Ge);return{begin:bt,end:xt,contains:[...U,{scope:"comment",begin:`#(?!.*${xt})`,end:/$/}]}},W={scope:"regexp",variants:[P("###"),P("##"),P("#"),Q]},$={match:qt(/`/,ss,/`/)},H={className:"variable",match:/\$\d+/},J={className:"variable",match:`\\$${yd}+`},re=[$,H,J],V={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:fB,contains:[...w,A,D]}]}},ie={scope:"keyword",match:qt(/@/,nr(...dB),Wa(nr(/\(/,/\s+/)))},z={scope:"meta",match:qt(/@/,ss)},M=[V,ie,z],I={match:Wa(/\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)/,yd,"+")},{className:"type",match:cu,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:qt(/\s+&\s+/,Wa(cu)),relevance:0}]},Z={begin:/</,end:/>/,keywords:f,contains:[...r,...h,...M,b,I]};I.contains.push(Z);const le={match:qt(ss,/\s*:/),keywords:"_|0",relevance:0},ge={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",le,...r,W,...h,...y,...w,A,D,...re,...M,I]},se={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,I]},xe={begin:nr(Wa(qt(ss,/\s*:/)),Wa(qt(ss,/\s+/,ss,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ss}]},fe={begin:/\(/,end:/\)/,keywords:f,contains:[xe,...r,...h,...w,A,D,...M,I,ge],endsParent:!0,illegal:/["']/},De={match:[/(func|macro)/,/\s+/,nr($.match,ss,xp)],className:{1:"keyword",3:"title.function"},contains:[se,fe,e],illegal:[/\[/,/%/]},We={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[se,fe,e],illegal:/\[|%/},Qe={match:[/operator/,/\s+/,xp],className:{1:"keyword",3:"title"}},ot={begin:[/precedencegroup/,/\s+/,cu],className:{1:"keyword",3:"title"},contains:[I],keywords:[...cB,...H1],end:/}/},st={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Ie={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},dt={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ss,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[se,...h,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:cu},...h],relevance:0}]};for(const Ge of D.variants){const bt=Ge.contains.find($t=>$t.label==="interpol");bt.keywords=f;const xt=[...h,...y,...w,A,D,...re];bt.contains=[...xt,{begin:/\(/,end:/\)/,contains:["self",...xt]}]}return{name:"Swift",keywords:f,contains:[...r,De,We,st,Ie,dt,Qe,ot,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},W,...h,...y,...w,A,D,...re,...M,I,ge]}}const bd="[A-Za-z$_][0-9A-Za-z$_]*",P_=["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"],B_=["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"],$_=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],F_=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],U_=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],H_=[].concat(F_,z_,$_);function pB(t){const e=t.regex,n=(V,{after:ie})=>{const z="</"+V[0].slice(1);return V.input.indexOf(z,ie)!==-1},r=bd,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(V,ie)=>{const z=V[0].length+V.index,M=V.input[z];if(M==="<"||M===","){ie.ignoreMatch();return}M===">"&&(n(V,{after:z})||ie.ignoreMatch());let I;const Z=V.input.substring(z);if(I=Z.match(/^\s*=/)){ie.ignoreMatch();return}if((I=Z.match(/^\s+extends\s+/))&&I.index===0){ie.ignoreMatch();return}}},l={$pattern:bd,keyword:P_,literal:B_,built_in:H_,"variable.language":U_},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:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"xml"}},b={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"css"}},x={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,g],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,g]},C={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},A=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,x,w,{match:/\$\d+/},m];g.contains=A.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(A)});const T=[].concat(C,g.contains),_=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(T)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:_},R={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"}}]},B={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_,...$_]}},D={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},Q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function P(V){return e.concat("(?!",V.join("|"),")")}const W={match:e.concat(/\b/,P([...F_,"super","import"].map(V=>`${V}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},$={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},J="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",re={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(J)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:_,CLASS_REFERENCE:B},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),D,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,y,b,x,w,C,{match:/\$\d+/},m,B,{scope:"attr",match:r+e.lookahead(":"),relevance:0},re,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,t.REGEXP_MODE,{className:"function",begin:J,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"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},$,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},W,Q,R,H,{match:/\$[(.]/}]}}function mB(t){const e=t.regex,n=pB(t),r=bd,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:bd,keyword:P_.concat(d),literal:B_,built_in:H_.concat(s),"variable.language":U_},h={className:"meta",begin:"@"+r},m=(x,w,E)=>{const C=x.contains.findIndex(A=>A.label===w);if(C===-1)throw new Error("can not find mode to replace");x.contains.splice(C,1,E)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const g=n.contains.find(x=>x.scope==="attr"),y=Object.assign({},g,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,g,y]),n.contains=n.contains.concat([h,i,o,y]),m(n,"shebang",t.SHEBANG()),m(n,"use_strict",l);const b=n.contains.find(x=>x.label==="func.def");return b.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function gB(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 vB(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 yB(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 bB(t){const e="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,s]},l=t.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),g={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},b={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},x={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},w=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},g,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},b,x,i,o],E=[...w];return E.pop(),E.push(l),y.contains=E,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}const xB={arduino:t6,bash:n6,c:r6,cpp:s6,csharp:i6,css:p6,diff:m6,go:g6,graphql:v6,ini:y6,java:b6,javascript:E6,json:N6,kotlin:_6,less:L6,lua:D6,makefile:P6,markdown:B6,objectivec:z6,perl:$6,php:F6,"php-template":U6,plaintext:H6,python:W6,"python-repl":q6,r:V6,ruby:K6,rust:G6,scss:rB,shell:sB,sql:iB,swift:hB,typescript:mB,vbnet:gB,wasm:vB,xml:yB,yaml:bB},q1={},wB="hljs-";function kB(t){const e=N_.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||q1,g=typeof m.prefix=="string"?m.prefix:wB;if(!e.getLanguage(d))throw new Error("Unknown language: `"+d+"` is not registered");e.configure({__emitter:SB,classPrefix:g});const y=e.highlight(f,{ignoreIllegals:!0,language:d});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const b=y._emitter.root,x=b.data;return x.language=y.language,x.relevance=y.relevance,b}function r(d,f){const m=(f||q1).subset||s();let g=-1,y=0,b;for(;++g<m.length;){const x=m[g];if(!e.getLanguage(x))continue;const w=n(x,d,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>y&&(y=w.data.relevance,b=w)}return b||{type:"root",children:[],data:{language:void 0,relevance:y}}}function s(){return e.listLanguages()}function i(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 SB{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 EB=new Ht("blurredLoadingNode"),$v=Ot.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 Pt({key:EB,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(zt.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(zt.node(f,f+d.nodeSize,{class:"node-blur-effect"})),!1):!0)}),jt.create(t.doc,n)}}})]}}),Fv=mn.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"}]}}),NB=new Ht("insertionLoadingNode"),uu=new Map,Uv=Ot.create({name:"insertionLoadingNode",addStorage(){return{insertionPoints:{}}},addCommands(){return{showInsertionLoading:(t,e)=>({editor:n})=>(this.storage.insertionPoints={},uu.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,uu.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 Pt({key:NB,props:{decorations:t=>{const e=this.storage.insertionPoints,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;s.active&&n.push(zt.widget(s.position,()=>{const i=uu.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),uu.set(s.id,o),o},{id:`insertion-${s.id}`}))}),jt.create(t.doc,n)}}})]}}),CB=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],Hv=Ot.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:CB,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}}}]}}),_B=mn.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",Lt({class:"footnote-ref"},t)]},addKeyboardShortcuts(){return{"Mod-Shift-f":()=>(W_(this.editor),!0)}}}),TB=mn.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",Lt({class:"footnotes"},t),0]}}),MB=mn.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",Lt({class:"footnote-def"},t),0]}});function W_(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(A=>{(A.type.name==="footnoteReference"||A.type.name==="footnoteDefinition")&&A.attrs.label&&d.add(String(A.attrs.label))});let f=1;for(;d.has(String(f));)f++;const h=String(f);let m=-1,g=null;r.forEach((A,T)=>{A.type.name==="footnoteSection"&&(m=T,g=A)});const y=o.create({label:h},l.create()),b=s.create({label:h}),x=e.selection.to,w=e.tr;w.insert(x,b);let E;if(m>=0&&g){const A=b.nodeSize,_=(x<=m?m+A+g.nodeSize:m+g.nodeSize)-1;w.insert(_,y),E=_+2}else{const A=i.create(null,y),T=w.doc.content.size;w.insert(T,A),E=T+3}const C=Math.min(E,w.doc.content.size);w.setSelection(it.near(w.doc.resolve(C))),w.scrollIntoView(),t.view.dispatch(w),t.view.focus()}function AB({node:t,deleteNode:e}){return u.jsxs(nD,{as:"div",className:"tweet-image-card",draggable:!0,"data-drag-handle":!0,children:[u.jsx("img",{className:"tweet-image-card-img",src:t.attrs.src,alt:t.attrs.alt||"",draggable:!1}),u.jsx("button",{className:"tweet-image-card-remove",onClick:e,title:"Remove image",contentEditable:!1,children:"×"})]})}const jB=Ev.extend({addNodeView(){return lD(AB)}}),OB=kB(xB),Wv=$D.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",Lt(this.options.HTMLAttributes,n),0]}}),RB=[Bv.configure({codeBlock:!1,link:!1,underline:!1}),Z4.configure({lowlight:OB}),Wv.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),k_,u4,hD,fP,pP,O3,j3.configure({nested:!0}),Ev,c4,l_.configure({resizable:!1}),a_,o_,i_,$v,Fv,Uv,Hv,_B,TB,MB,Fd.configure({placeholder:"Start writing..."}),Pv.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)})],IB=[Bv.configure({codeBlock:!1,horizontalRule:!0,heading:{levels:[1,2,3]},link:!1,underline:!1}),Wv.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Ev,$v,Fv,Uv,Hv,Fd.configure({placeholder:"Start writing..."}),Pv.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image","imageLoading","horizontalRule"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],LB=Ot.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()}}}}),q_=[Bv.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),Wv.configure({openOnClick:!1,isAllowedUri:(t,e)=>t.startsWith("doc:")?!0:e.defaultValidate(t),HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),jB,$v,Fv,Uv,Hv,LB,Pv.configure({types:["paragraph","image","imageLoading"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...q_,Fd.configure({placeholder:"What is happening?!"})];function Ar({onClick:t,active:e,disabled:n,title:r,children:s}){return u.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function V1(){return u.jsx("div",{className:"floating-toolbar__divider"})}function DB({editor:t}){const[e,n]=k.useState(!1),[r,s]=k.useState({top:0,left:0}),[,i]=k.useState(0),o=k.useRef(-1),l=k.useRef(-1),d=k.useRef(!1);return k.useEffect(()=>{const f=t.view.dom,h=()=>{d.current=!0},m=()=>{if(!d.current)return;d.current=!1;const{from:g,to:y}=t.state.selection,b=g!==y&&t.state.selection.node;if(g!==y&&!b){const x=t.isActive("codeBlock"),w=!!document.querySelector(".context-menu");if(!x&&!w){o.current=g,l.current=y;const E=t.view.coordsAtPos(g),C=t.view.coordsAtPos(y,1),A=(E.left+C.right)/2;s({top:E.top,left:A}),n(!0)}}};return f.addEventListener("mousedown",h),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",h),document.removeEventListener("mouseup",m)}},[t]),k.useEffect(()=>{const f=()=>{d.current=!1,n(!1),o.current=-1,l.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),k.useEffect(()=>{const f=()=>{const{from:h,to:m}=t.state.selection,g=h===m,y=t.isActive("codeBlock"),b=!!document.querySelector(".context-menu"),x=t.view.hasFocus(),w=!g&&t.state.selection.node;if(g||w||y||b||!x)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 E=t.view.coordsAtPos(h),C=t.view.coordsAtPos(m,1),A=(E.left+C.right)/2;s({top:E.top,left:A})}i(E=>E+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?u.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[u.jsx(Ar,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),u.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),u.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),u.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),u.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),u.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),u.jsx(Ar,{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:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),u.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),u.jsx(V1,{}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"m17 12 3-2v8"})]})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),u.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),u.jsx(V1,{}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M3 12h.01"}),u.jsx("path",{d:"M3 18h.01"}),u.jsx("path",{d:"M3 6h.01"}),u.jsx("path",{d:"M8 12h13"}),u.jsx("path",{d:"M8 18h13"}),u.jsx("path",{d:"M8 6h13"})]})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M11 12h9"}),u.jsx("path",{d:"M11 18h9"}),u.jsx("path",{d:"M11 6h9"}),u.jsx("path",{d:"M4 10V4h1"}),u.jsx("path",{d:"M4 10h2"}),u.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),u.jsx(Ar,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M17 6H3"}),u.jsx("path",{d:"M21 12H8"}),u.jsx("path",{d:"M21 18H8"}),u.jsx("path",{d:"M3 12v6"})]})}),u.jsx(Ar,{onClick:()=>W_(t),title:"Footnote (Ctrl+Shift+F)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 6h12"}),u.jsx("path",{d:"M4 12h12"}),u.jsx("path",{d:"M4 18h8"}),u.jsx("text",{x:"18",y:"9",fontSize:"9",fontWeight:"bold",stroke:"none",fill:"currentColor",children:"N"})]})})]}):null}const PB=new Ht("pendingDecoration");let V_=null,K_=null;function K1(t,e){V_=t,K_=e??null}let xd=!1,G_=null,qv=null,J_=null;function Vv(){return xd}function BB(){return qv}function zB(){return J_}function Qa(t,e,n,r){xd=t,G_=t?e??null:null,qv=t?r??null:null,J_=t?n??null:null}function $B(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function G1(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 J1(t){const e=[];return t.descendants((n,r)=>{var w,E,C,A,T,_,O,R,B;const s=(w=n.attrs)==null?void 0:w.pendingStatus;if(!s)return!0;const i=(E=n.attrs)==null?void 0:E.id,o=(C=n.attrs)==null?void 0:C.pendingGroupId,l=o&&o===K_,f=xd&&i===G_||o&&xd&&o===qv,h=f?(A=n.attrs)==null?void 0:A.pendingOriginalFrom:(T=n.attrs)==null?void 0:T.pendingSelectionFrom,m=f?(_=n.attrs)==null?void 0:_.pendingOriginalTo:(O=n.attrs)==null?void 0:O.pendingSelectionTo,g=h!=null&&m!=null,y=f?"pending-original":$B(s),b=[];(R=n.attrs)!=null&&R.pendingOrphan&&b.push("pending-orphan"),(B=n.attrs)!=null&&B.pendingStaleBaseline&&b.push("pending-stale");const x=y+(b.length?" "+b.join(" "):"");if(g&&n.isTextblock&&x){const D=G1(n,r,h),U=G1(n,r,m);D!==null&&U!==null&&D<U&&e.push(zt.inline(D,U,{class:x}))}else x&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(zt.inline(r+1,r+n.nodeSize-1,{class:x})):e.push(zt.node(r,r+n.nodeSize,{class:x})));if(i&&(i===V_||l)){const D=f?"original":s;e.push(zt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${D}`}))}return!0}),jt.create(t,e)}function Y_(){return new Pt({key:PB,state:{init(t,e){return J1(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?J1(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function Kv(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const FB=new Ht("commentDecoration");let qo=[];function Y1(t){qo=t}function Cu(){return qo}function X_(t){return{class:"ow-comment","data-comment-id":t.id}}function X1(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=Vo(e,n,s),o=Vo(e,n,s+t.text.length);return i===null||o===null||i>=o?null:zt.inline(i,o,X_(t))}function UB(t,e){const n=t.nodeIds,r=t.text.split(`
|
|
204
|
-
`),s=X_(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=Vo(d.node,d.pos,h),g=Vo(d.node,d.pos,h+l.length);m!==null&&g!==null&&m<g&&i.push(zt.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=Vo(d.node,d.pos,m),y=Vo(d.node,d.pos,m+f.length);g!==null&&y!==null&&g<y&&(i.push(zt.inline(g,y,s)),o++)}}return i}function Q1(t){if(qo.length===0)return jt.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 qo)if(i.nodeIds&&i.nodeIds.length>1){const o=UB(i,r);o.length>0&&(n.add(i.id),e.push(...o))}for(const i of qo){if(n.has(i.id))continue;const o=r.get(i.nodeId);if(!o)continue;const l=X1(i,o.node,o.pos);l&&(n.add(i.id),e.push(l))}const s=qo.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=X1(l,i,o);d&&(n.add(l.id),e.push(d))}return!0}),jt.create(t,e)}function Vo(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 Q_(){return new Pt({key:FB,state:{init(t,e){return Q1(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceCommentUpdate")?Q1(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function Z1(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceCommentUpdate",!0);n(r)}const HB=new Ht("backlinkDecoration");let wd=[];function ew(t){wd=Array.isArray(t)?t:[]}function WB(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 tw(t){if(wd.length===0)return jt.empty;const e=WB(wd);if(e.size===0)return jt.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(zt.node(s,s+r.nodeSize,{class:"linked-paragraph","data-backlinks-count":String(o.length),"data-backlinks-node":i})),!0}),jt.create(t,n)}function qB(){return new Pt({key:HB,state:{init(t,e){return tw(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceBacklinkUpdate")?tw(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function VB(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceBacklinkUpdate",!0);n(r)}function KB(t){return wd.filter(e=>e.to_node===t)}const Gv=new WeakMap;function GB(t,e){Gv.set(t,e)}async function Z_(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=Gv.get(e);if(!i||i.getPreviewImages().length>=4)return;i.addToPreview(s)}catch{}}async function JB(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=Gv.get(e);if(!s||s.getPreviewImages().length>=4)return;s.addToPreview(r)}catch{}}function YB(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 e2(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&&Z_(l,t),!0}const r=(i=e.clipboardData)==null?void 0:i.getData("text/html");if(r){const o=YB(r);if(o.length>0){e.preventDefault();for(const l of o)JB(l,t);return!0}}return!1}function t2(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(),Z_(s,t),!0;return!1}const XB=["<!--StartFragment-->","<span"," style="," class="];function QB(t){return XB.some(e=>t.includes(e))||/<p[^>]*>\s*(<br\s*\/?>)?\s*<\/p>/i.test(t)}function ZB(t){var i;if(!QB(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 nw=/^[a-f0-9]{8}$/;function n2(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=nw.test(d)?d:null,n=n.slice(0,o)}const l=nw.test(n);return{docId:l?n:null,filename:l?null:n,nodeId:i,quote:r}}function wp(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 e5(t){const e=n2(t);return e?e.docId||e.filename:null}function du({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=k.useRef(s);i.current=s;const o=AC({extensions:e||RB,content:t||"<p></p>",onUpdate:({editor:d})=>{Vv()||n==null||n(d.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:e2,handleDrop:t2,transformPastedHTML:ZB}},[]),l=k.useRef(t);return k.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]),k.useEffect(()=>{o&&console.log(`[Editor] first mount t=${performance.now().toFixed(0)}`)},[o]),k.useEffect(()=>{if(!o)return;const d=o.view.dom,f=h=>{var x;const m=h.target,g=m.closest("span.doc-link[data-doc]");if(g){const w=g.getAttribute("data-doc"),E=n2(`doc:${w}`);if(!E)return;(x=i.current)==null||x.call(i,E);return}const y=m.closest("a[href]");if(!y)return;const b=y.getAttribute("href")||"";/^(https?:|mailto:|tel:)/i.test(b)&&(h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),window.open(b,"_blank","noopener,noreferrer")))};return d.addEventListener("click",f,!0),()=>d.removeEventListener("click",f,!0)},[o]),k.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="pendingDecoration$"))return;const f=Y_(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),k.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="commentDecoration$"))return;const f=Q_(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),k.useEffect(()=>{if(!o)return;const{state:d}=o.view;if(d.plugins.some(m=>m.key==="backlinkDecoration$"))return;const f=qB(),h=d.reconfigure({plugins:[...d.plugins,f]});o.view.updateState(h)},[o]),k.useEffect(()=>{o&&(r==null||r(o))},[o,r]),o?u.jsxs(u.Fragment,{children:[u.jsx(kv,{editor:o}),u.jsx(DB,{editor:o})]}):null}function bn({onClick:t,active:e,disabled:n,title:r,children:s}){return u.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function Po(){return u.jsx("div",{className:"format-toolbar__divider"})}async function t5(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 n5({editor:t}){const[,e]=k.useState(0),n=k.useRef(null);k.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&&t5(i,t),s.target.value=""};return u.jsxs("div",{className:"format-toolbar",children:[u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(bn,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:u.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8"})})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),u.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),u.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),u.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),u.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),u.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m16 18 6-6-6-6"}),u.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),u.jsx(Po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(bn,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),u.jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m4 5 8 8"}),u.jsx("path",{d:"m12 5-8 8"}),u.jsx("path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m4 19 8-8"}),u.jsx("path",{d:"m12 19-8-8"}),u.jsx("path",{d:"M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})})]}),u.jsx(Po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(bn,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"m17 12 3-2v8"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 12h8"}),u.jsx("path",{d:"M4 18V6"}),u.jsx("path",{d:"M12 18V6"}),u.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),u.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M13 4v16"}),u.jsx("path",{d:"M17 4v16"}),u.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),u.jsx(Po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(bn,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M3 12h.01"}),u.jsx("path",{d:"M3 18h.01"}),u.jsx("path",{d:"M3 6h.01"}),u.jsx("path",{d:"M8 12h13"}),u.jsx("path",{d:"M8 18h13"}),u.jsx("path",{d:"M8 6h13"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M11 12h9"}),u.jsx("path",{d:"M11 18h9"}),u.jsx("path",{d:"M11 6h9"}),u.jsx("path",{d:"M4 10V4h1"}),u.jsx("path",{d:"M4 10h2"}),u.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"m3 17 2 2 4-4"}),u.jsx("path",{d:"m3 7 2 2 4-4"}),u.jsx("path",{d:"M13 6h8"}),u.jsx("path",{d:"M13 12h8"}),u.jsx("path",{d:"M13 18h8"})]})})]}),u.jsx(Po,{}),u.jsx("div",{className:"format-toolbar__group",children:u.jsx(bn,{onClick:()=>{const s=t.getAttributes("link").href||"",i=window.prompt("Link URL:",s);i!==null&&(i===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:i}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),u.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}),u.jsx(Po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(bn,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M17 6H3"}),u.jsx("path",{d:"M21 12H8"}),u.jsx("path",{d:"M21 18H8"}),u.jsx("path",{d:"M3 12v6"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("path",{d:"m10 9-3 3 3 3"}),u.jsx("path",{d:"m14 15 3-3-3-3"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:u.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M5 12h14"})})})]}),u.jsx(Po,{}),u.jsxs("div",{className:"format-toolbar__group",children:[u.jsx(bn,{onClick:()=>{var s;return(s=n.current)==null?void 0:s.click()},title:"Insert Image",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),u.jsx("circle",{cx:"9",cy:"9",r:"2"}),u.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),u.jsx(bn,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:u.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("path",{d:"M12 3v18"}),u.jsx("path",{d:"M3 9h18"}),u.jsx("path",{d:"M3 15h18"})]})})]}),u.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const r5={tree:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),files:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("polyline",{points:"14 2 14 8 20 8"})]}),timeline:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),u.jsx("circle",{cx:"12",cy:"6",r:"2"}),u.jsx("circle",{cx:"12",cy:"12",r:"2"}),u.jsx("circle",{cx:"12",cy:"18",r:"2"}),u.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),u.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),u.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),u.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),u.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 19V5"}),u.jsx("path",{d:"M8 19V7"}),u.jsx("path",{d:"M12 19V4"}),u.jsx("path",{d:"M16 19V8"}),u.jsx("path",{d:"M20 19V6"}),u.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function s5(){const[t,e]=k.useState(!1),[n,r]=k.useState(dE),[s,i]=k.useState(fE),[o,l]=k.useState(Cd),d=hE(),[f,h]=k.useState(mE),[m,g]=k.useState(gE),y=k.useRef(null),b=(T=n,_=s,O=o,R=d,B=f,D=m)=>{vE(T,_,O,R,B,D)},x=T=>{r(T),b(T)},w=()=>{const T=s==="light"?"dark":"light";i(T),b(void 0,T)},E=T=>{l(T),b(void 0,void 0,T),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:T}))},C=T=>{h(T),b(void 0,void 0,void 0,void 0,T)},A=T=>{g(T),b(void 0,void 0,void 0,void 0,void 0,T)};return k.useEffect(()=>{if(!t)return;const T=_=>{y.current&&!y.current.contains(_.target)&&e(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t]),u.jsxs("div",{className:"appearance-wrapper",ref:y,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Appearance",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"}),u.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),u.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]})}),t&&u.jsxs("div",{className:"appearance-dropdown",children:[u.jsx("div",{className:"appearance-section",children:u.jsxs("div",{className:"appearance-section-header",children:[u.jsx("span",{className:"appearance-section-title",children:"Mode"}),u.jsxs("button",{className:"appearance-mode-btn",onClick:w,title:s==="light"?"Switch to dark":"Switch to light",children:[s==="light"?u.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"5"}),u.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),u.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),u.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),u.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),u.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),u.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),u.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),u.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):u.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),u.jsx("span",{children:s==="light"?"Light":"Dark"})]})]})}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Typography"})}),u.jsx("div",{className:"appearance-typeface-grid",children:aE.map(T=>u.jsx("button",{className:`appearance-style-option ${n===T.id?"active":""}`,onClick:()=>x(T.id),title:T.description,children:T.label},T.id))})]}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),u.jsx("div",{className:"appearance-typography-grid",children:uE.map(T=>u.jsx("button",{className:`appearance-style-option ${f===T.id?"active":""}`,onClick:()=>C(T.id),children:T.label},T.id))})]}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),u.jsx("div",{className:"appearance-style-grid",children:cE.map(T=>u.jsx("button",{className:`appearance-style-option ${m===T.id?"active":""}`,onClick:()=>A(T.id),children:T.label},T.id))})]}),u.jsxs("div",{className:"appearance-section",children:[u.jsx("div",{className:"appearance-section-header",children:u.jsx("span",{className:"appearance-section-title",children:"Layout"})}),u.jsx("div",{className:"appearance-mode-grid",children:lE.map(T=>u.jsxs("button",{className:`appearance-mode-option ${o===T.id?"active":""}`,onClick:()=>E(T.id),children:[r5[T.icon],u.jsx("span",{children:T.label})]},T.id))})]})]})]})}const i5={none:"No Plan",free:"No Plan",creator:"Creator — $19/mo",growth:"Growth — $49/mo",publisher:"Publisher — $79/mo"},o5=[{plan:"creator",label:"Creator $19/mo"},{plan:"growth",label:"Growth $49/mo"}];function a5(){var d,f;const[t,e]=k.useState(null),[n,r]=k.useState(!0);k.useEffect(()=>{fetch("/api/billing").then(h=>h.json()).then(h=>e(h)).catch(()=>{}).finally(()=>r(!1))},[]);const s=k.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=k.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 u.jsx("div",{className:"billing-section",children:u.jsx("div",{className:"billing-loading",children:"Loading..."})});if(!(t!=null&&t.authenticated))return null;const o=t.plan||"free",l=o5.filter(h=>{const m=["free","creator","growth","publisher"];return m.indexOf(h.plan)>m.indexOf(o)});return u.jsxs("div",{className:"billing-section",children:[u.jsxs("div",{className:"billing-plan",children:[u.jsx("span",{className:"billing-plan-label",children:"Plan"}),u.jsx("span",{className:`billing-plan-badge billing-plan-badge--${o}`,children:i5[o]||o})]}),((d=t.billing)==null?void 0:d.paymentFailed)&&u.jsx("div",{className:"billing-warning",children:"Payment failed — update card to keep your plan."}),l.length>0&&u.jsx("div",{className:"billing-upgrades",children:l.map(h=>u.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)&&u.jsx("button",{className:"billing-manage-btn",onClick:i,children:"Manage Billing"})]})}function rw(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function l5(){const[t,e]=k.useState(!1),[n,r]=k.useState([]),[s,i]=k.useState(null),[o,l]=k.useState(new Set),d=k.useRef(null),f=k.useCallback(()=>{fetch("/api/available-plugins").then(g=>g.json()).then(g=>r(g.plugins||[])).catch(()=>{})},[]);k.useEffect(()=>{t&&f()},[t,f]),k.useEffect(()=>{const g=()=>f();return window.addEventListener("ow-plugins-changed",g),()=>window.removeEventListener("ow-plugins-changed",g)},[f]),k.useEffect(()=>{if(!t)return;const g=y=>{d.current&&!d.current.contains(y.target)&&e(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[t]);const h=k.useCallback(async(g,y)=>{i(g);try{(await fetch(y?"/api/plugins/disable":"/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g})})).ok&&f()}catch{}finally{i(null)}},[f]),m=k.useCallback((g,y,b)=>{fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,config:{[y]:b}})}).catch(()=>{})},[]);return u.jsxs("div",{className:"plugin-wrapper",ref:d,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Plugins",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12 22v-5"}),u.jsx("path",{d:"M9 8V2"}),u.jsx("path",{d:"M15 8V2"}),u.jsx("path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"})]})}),t&&u.jsxs("div",{className:"plugin-dropdown",children:[u.jsx("div",{className:"plugin-dropdown-header",children:"Plugins"}),n.length===0?u.jsx("div",{className:"plugin-empty",children:"No plugins found"}):n.map(g=>u.jsxs("div",{className:"plugin-item",children:[u.jsxs("div",{className:"plugin-item-header",children:[u.jsxs("div",{className:"plugin-item-info",children:[u.jsxs("div",{className:"plugin-item-name",children:[rw(g.name),u.jsxs("span",{className:"plugin-item-version",children:["v",g.version]})]}),g.description&&u.jsx("div",{className:"plugin-item-desc",children:g.description})]}),u.jsxs("label",{className:`plugin-toggle${s===g.name?" loading":""}`,children:[u.jsx("input",{type:"checkbox",checked:g.enabled,disabled:s===g.name,onChange:()=>h(g.name,g.enabled)}),u.jsx("span",{className:"plugin-toggle-track"}),u.jsx("span",{className:"plugin-toggle-thumb"})]})]}),g.enabled&&g.name==="@openwriter/plugin-publish"&&u.jsx(a5,{}),g.enabled&&Object.keys(g.configSchema).length>0&&(()=>{const y=Object.entries(g.configSchema).some(([b,x])=>x.required&&!g.config[b]);return u.jsxs("div",{className:"plugin-config-section",children:[y&&u.jsxs("div",{className:"plugin-setup-hint",children:["Ask your agent: “set up ",rw(g.name),"”"]}),u.jsxs("button",{className:"plugin-config-toggle",onClick:()=>l(b=>{const x=new Set(b);return x.has(g.name)?x.delete(g.name):x.add(g.name),x}),children:[u.jsx("svg",{className:`plugin-config-chevron${o.has(g.name)?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),o.has(g.name)&&u.jsx("div",{className:"plugin-config",children:Object.entries(g.configSchema).map(([b,x])=>u.jsxs("div",{className:"plugin-config-field",children:[u.jsx("label",{className:"plugin-config-label",children:x.description||b}),u.jsx("input",{className:"plugin-config-input",type:b.toLowerCase().includes("key")||b.toLowerCase().includes("secret")||b.toLowerCase().includes("token")?"password":"text",defaultValue:g.config[b]||"",placeholder:x.env?`$${x.env}`:"",onBlur:w=>m(g.name,b,w.target.value)})]},b))})]})})()]},g.name))]})]})}function c5(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 u5(t){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function d5(){const[t,e]=k.useState(!1),[n,r]=k.useState([]),[s,i]=k.useState(null),[o,l]=k.useState(!1),d=k.useRef(null),f=k.useCallback(()=>{fetch("/api/versions").then(m=>m.json()).then(m=>{r(Array.isArray(m)?m:[]),i(null)}).catch(()=>r([]))},[]);k.useEffect(()=>{t&&f()},[t,f]),k.useEffect(()=>{if(!t)return;const m=g=>{d.current&&!d.current.contains(g.target)&&e(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[t]);const h=k.useCallback(async m=>{if(s!==null){l(!0);try{(await fetch(`/api/versions/${s}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:m})})).ok&&f()}catch{}l(!1)}},[s,f]);return u.jsxs("div",{className:"version-wrapper",ref:d,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Version history",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t&&u.jsxs("div",{className:"version-dropdown",children:[u.jsx("div",{className:"version-dropdown__header",children:"Version History"}),u.jsx("div",{className:"version-dropdown__list",children:n.length===0?u.jsx("div",{className:"version-dropdown__empty",children:"No versions yet. Versions are created automatically when you save."}):n.map(m=>u.jsxs("div",{className:`version-dropdown__item${s===m.timestamp?" version-dropdown__item--selected":""}`,onClick:()=>i(m.timestamp===s?null:m.timestamp),children:[u.jsx("span",{className:"version-dropdown__item-time",children:c5(m.timestamp)}),u.jsxs("span",{className:"version-dropdown__item-meta",children:[m.wordCount.toLocaleString()," words · ",u5(m.size)]})]},m.timestamp))}),n.length>0&&u.jsxs("div",{className:"version-dropdown__footer",children:[u.jsx("button",{className:"version-dropdown__review-btn",disabled:s===null||o,onClick:()=>h("review"),children:"Review"}),u.jsx("button",{className:"version-dropdown__restore-btn",disabled:s===null||o,onClick:()=>h("full"),children:"Restore"})]})]})]})}const f5=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"16 18 22 12 16 6"}),u.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("path",{d:"M14 2v6h6"}),u.jsx("path",{d:"M16 13H8"}),u.jsx("path",{d:"M16 17H8"}),u.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M17 6.1H3"}),u.jsx("path",{d:"M21 12.1H3"}),u.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),u.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),u.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function h5(){const[t,e]=k.useState(!1),n=k.useRef(null);k.useEffect(()=>{if(!t)return;const s=i=>{n.current&&!n.current.contains(i.target)&&e(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[t]);const r=s=>{if(e(!1),s==="pdf"){window.open("/api/export?format=pdf","_blank");return}const i=document.createElement("a");i.href=`/api/export?format=${s}`,i.download="",document.body.appendChild(i),i.click(),document.body.removeChild(i)};return u.jsxs("div",{className:"export-wrapper",ref:n,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Export document",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u.jsx("polyline",{points:"7 10 12 15 17 10"}),u.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),t&&u.jsxs("div",{className:"export-dropdown",children:[u.jsx("div",{className:"export-dropdown__header",children:"Export"}),u.jsx("div",{className:"export-dropdown__list",children:f5.map(s=>u.jsxs("div",{className:"export-dropdown__item",onClick:()=>r(s.key),children:[u.jsx("span",{className:"export-dropdown__item-icon",children:s.icon}),u.jsxs("span",{className:"export-dropdown__item-text",children:[u.jsx("span",{className:"export-dropdown__item-label",children:s.label}),u.jsx("span",{className:"export-dropdown__item-desc",children:s.desc})]})]},s.key))})]})]})}function p5({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=k.useState("form"),[i,o]=k.useState(null),[l,d]=k.useState((t==null?void 0:t.domain)||""),[f,h]=k.useState(""),[m,g]=k.useState((t==null?void 0:t.from_name)||""),[y,b]=k.useState(""),[x,w]=k.useState((t==null?void 0:t.id)||""),[E,C]=k.useState({dns_verified:!1,sender_verified:!1}),A=k.useRef(null),T=k.useRef(null);k.useEffect(()=>{const Q=P=>{r!=="submitting"&&r!=="verifying"&&T.current&&!T.current.contains(P.target)&&e()};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[e,r]),k.useEffect(()=>{const Q=P=>{P.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[e,r]),k.useEffect(()=>()=>{A.current&&clearInterval(A.current)},[]);async function _(){var Q,P;s("submitting"),o(null);try{const $=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:l,from_email:f,from_name:m||void 0,physical_address:y}})})).json(),H=(P=(Q=$.content)==null?void 0:Q[0])!=null&&P.text?JSON.parse($.content[0].text):$;if(H.error){o(H.error),s("error");return}const J=H.connectionId||H.connection_id||x;J&&w(J),R(J)}catch(W){o(W.message),s("error")}}async function O(){var Q,P;s("submitting"),o(null);try{const $=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:l,from_email:f||void 0,from_name:m||void 0,physical_address:y||void 0}})})).json(),H=(P=(Q=$.content)==null?void 0:Q[0])!=null&&P.text?JSON.parse($.content[0].text):$;if(H.error){o(H.error),s("error");return}s("done")}catch(W){o(W.message),s("error")}}function R(Q){s("verifying"),A.current=setInterval(async()=>{var P,W;try{const H=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:Q}})})).json(),J=(W=(P=H.content)==null?void 0:P[0])!=null&&W.text?JSON.parse(H.content[0].text):H,re=!!J.dns_verified,V=!!J.sender_verified;C({dns_verified:re,sender_verified:V}),re&&V&&(A.current&&clearInterval(A.current),A.current=null,s("done"))}catch{}},5e3)}function B(){x&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:x}})}).catch(()=>{})}const D=!!t,U=l.trim()&&f.trim()&&y.trim();return u.jsx("div",{className:"newsletter-modal-overlay",children:u.jsxs("div",{className:"newsletter-modal newsletter-modal--setup",ref:T,children:[u.jsxs("div",{className:"newsletter-modal__header",children:[u.jsx("h3",{children:D?"Newsletter Settings":"Set Up Newsletter"}),u.jsx("button",{className:"newsletter-modal__close",onClick:e,children:"×"})]}),u.jsxs("div",{className:"newsletter-modal__body",children:[r==="form"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsx("label",{className:"newsletter-modal__label",children:"Domain"}),u.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"yourdomain.com",value:l,onChange:Q=>d(Q.target.value),disabled:D,autoComplete:"off"})]}),u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsx("label",{className:"newsletter-modal__label",children:"From Email"}),u.jsx("input",{className:"newsletter-modal__input",type:"email",placeholder:"newsletter@yourdomain.com",value:f,onChange:Q=>h(Q.target.value),autoComplete:"off"})]}),u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsxs("label",{className:"newsletter-modal__label",children:["From Name ",u.jsx("span",{className:"newsletter-modal__optional",children:"(optional)"})]}),u.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"Your Name or Brand",value:m,onChange:Q=>g(Q.target.value),autoComplete:"off"})]}),u.jsxs("div",{className:"newsletter-modal__field",children:[u.jsxs("label",{className:"newsletter-modal__label",children:["Physical Address ",u.jsx("span",{className:"newsletter-modal__required",children:"*"})]}),u.jsx("textarea",{className:"newsletter-modal__input newsletter-modal__textarea",rows:2,placeholder:"123 Main St, City, State 12345",value:y,onChange:Q=>b(Q.target.value)}),u.jsx("span",{className:"newsletter-modal__hint",children:"Required by CAN-SPAM. Included in email footer."})]}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:D?O:_,disabled:!U,children:D?"Save":"Set Up Domain"})]})]}),r==="submitting"&&u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:D?"Saving...":"Setting up domain..."})]}),r==="verifying"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"newsletter-modal__verify",children:[u.jsx("p",{className:"newsletter-modal__verify-title",children:"Verifying domain setup..."}),u.jsxs("div",{className:"newsletter-modal__verify-checks",children:[u.jsxs("div",{className:`newsletter-modal__verify-item${E.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[E.dns_verified?"✓":u.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),u.jsx("span",{children:"DNS records"})]}),u.jsxs("div",{className:`newsletter-modal__verify-item${E.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[E.sender_verified?"✓":u.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),u.jsx("span",{children:"Sender verification"})]})]}),u.jsx("p",{className:"newsletter-modal__hint",children:"This may take a few minutes. You can close and check back later."})]}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:B,children:"Resend Verification"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Close"})]})]}),r==="done"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:D?"Settings saved!":"Newsletter domain configured!"}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Done"})})]}),r==="error"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"newsletter-modal__error",children:i}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s("form"),children:"Try Again"})]})]})]})]})})}const m5={github:[{key:"owner",label:"Owner",placeholder:"username or org",readonly:!0},{key:"repo",label:"Repository",placeholder:"my-blog",readonly:!0},{key:"branch",label:"Branch",placeholder:"main"},{key:"contentDir",label:"Content Directory",placeholder:"src/content/blog",required:!0},{key:"imageDir",label:"Image Directory",placeholder:"public/images/blog"}],x:[],linkedin:[]};function g5({connectionId:t,provider:e,displayName:n,onClose:r,onSaved:s}){const[i,o]=k.useState("loading"),[l,d]=k.useState({}),[f,h]=k.useState(null),m=k.useRef(null),g=m5[e]||[];k.useEffect(()=>{fetch(`/api/connections/${t}/config`).then(x=>x.json()).then(x=>{d(x.config||{}),o("form")}).catch(x=>{h(x.message),o("error")})},[t]),k.useEffect(()=>{const x=w=>{i!=="saving"&&m.current&&!m.current.contains(w.target)&&r()};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[r,i]),k.useEffect(()=>{const x=w=>{w.key==="Escape"&&i!=="saving"&&r()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r,i]);async function y(){o("saving"),h(null);try{const x=await fetch(`/api/connections/${t}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)}),w=await x.json();if(!x.ok)throw new Error(w.error||"Failed to save");o("saved"),s(),setTimeout(r,800)}catch(x){h(x.message),o("error")}}function b(x){switch(x){case"x":return"X (Twitter)";case"linkedin":return"LinkedIn";case"github":return"GitHub";default:return x}}return u.jsx("div",{className:"conn-config-overlay",children:u.jsxs("div",{className:"conn-config-modal",ref:m,children:[u.jsxs("div",{className:"conn-config-modal__header",children:[u.jsxs("div",{className:"conn-config-modal__title",children:[b(e)," Settings"]}),u.jsx("div",{className:"conn-config-modal__subtitle",children:n})]}),i==="loading"&&u.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[u.jsx("div",{className:"conn-config-spinner"}),u.jsx("span",{children:"Loading configuration..."})]}),(i==="form"||i==="error")&&g.length>0&&u.jsxs("div",{className:"conn-config-modal__body",children:[g.map(x=>u.jsxs("div",{className:"conn-config-field",children:[u.jsxs("label",{className:"conn-config-field__label",children:[x.label,x.readonly&&u.jsx("span",{className:"conn-config-field__badge",children:"read-only"})]}),u.jsx("input",{className:"conn-config-field__input",value:l[x.key]||"",placeholder:x.placeholder,readOnly:x.readonly,onChange:w=>d(E=>({...E,[x.key]:w.target.value}))})]},x.key)),f&&u.jsx("div",{className:"conn-config-modal__error",children:f})]}),(i==="form"||i==="error")&&g.length===0&&u.jsx("div",{className:"conn-config-modal__body conn-config-modal__center",children:u.jsxs("span",{className:"conn-config-modal__empty",children:["No configuration needed for ",b(e),"."]})}),i==="saving"&&u.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[u.jsx("div",{className:"conn-config-spinner"}),u.jsx("span",{children:"Saving..."})]}),i==="saved"&&u.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[u.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),u.jsx("span",{children:"Saved"})]}),u.jsxs("div",{className:"conn-config-modal__footer",children:[u.jsx("button",{className:"conn-config-btn conn-config-btn--secondary",onClick:r,children:i==="saved"?"Close":"Cancel"}),g.length>0&&(i==="form"||i==="error")&&u.jsx("button",{className:"conn-config-btn conn-config-btn--primary",onClick:y,children:"Save"})]})]})})}const v5=[{id:"x",label:"X (Twitter)",oauth:!0},{id:"linkedin",label:"LinkedIn",oauth:!0},{id:"github",label:"GitHub",oauth:!0},{id:"newsletter",label:"Newsletter",oauth:!1}];function y5(){const[t,e]=k.useState(!1),[n,r]=k.useState([]),[s,i]=k.useState(null),[o,l]=k.useState(null),[d,f]=k.useState(null),[h,m]=k.useState(null),[g,y]=k.useState(null),b=k.useRef(null),x=k.useRef(null);k.useEffect(()=>{fetch("/api/connections").then(R=>R.json()).then(R=>i(R.authenticated!==!1)).catch(()=>i(!1))},[]),k.useEffect(()=>{if(!t)return;const R=B=>{b.current&&!b.current.contains(B.target)&&(e(!1),l(null))};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[t]),k.useEffect(()=>{t&&w()},[t]),k.useEffect(()=>()=>{x.current&&clearInterval(x.current)},[]);async function w(){try{const B=await(await fetch("/api/connections")).json();i(B.authenticated!==!1);const D=(B.connections||[]).filter(U=>U&&U.id&&U.provider);return r(D),D}catch{return[]}}async function E(R){f(R);try{const B=await fetch(`/api/connections/oauth/${R}/start`,{method:"POST"}),D=await B.json();if(!B.ok||!D.url){f(null);return}window.open(D.url,"_blank","width=600,height=700"),x.current=setInterval(async()=>{try{const Q=await(await fetch(`/api/connections/oauth/${R}/status/${D.state}`)).json();if(Q.status==="completed"){x.current&&clearInterval(x.current),x.current=null,f(null);const P=await w();if(R==="x"){const W=P.find($=>$.provider==="x"&&$.status==="active");if(W!=null&&W.display_name){const $=W.display_name.replace("@","");localStorage.setItem("ow-x-handle",$),window.dispatchEvent(new StorageEvent("storage",{key:"ow-x-handle",newValue:$}))}}}else Q.status==="failed"&&(x.current&&clearInterval(x.current),x.current=null,f(null))}catch{}},2e3)}catch{f(null)}}async function C(R){try{const B=await fetch(`/api/connections/${R}`,{method:"DELETE"});if(!B.ok){const D=await B.json().catch(()=>({error:"Delete failed"}));console.error("[Connections] Delete failed:",D.error)}}catch(B){console.error("[Connections] Delete error:",B)}l(null),await w()}function A(R){return R==="active"?"connections-status--active":R==="expired"?"connections-status--expired":R==="revoked"?"connections-status--revoked":"connections-status--pending"}function T(R){switch(R){case"x":return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:u.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})});case"linkedin":return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:u.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})});case"github":return u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:u.jsx("path",{d:"M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z"})});case"newsletter":return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),u.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});default:return u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),u.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}}const _=new Map;for(const R of n)_.set(R.provider,R);const O=s===!1;return u.jsxs("div",{className:"connections-wrapper",ref:b,children:[u.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}${O?" titlebar-nav-btn--disabled":""}`,onClick:()=>e(!t),title:O?"Connect to the Publish platform to enable connections":"Connections",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"5",r:"3"}),u.jsx("circle",{cx:"5",cy:"19",r:"3"}),u.jsx("circle",{cx:"19",cy:"19",r:"3"}),u.jsx("line",{x1:"12",y1:"8",x2:"5",y2:"16"}),u.jsx("line",{x1:"12",y1:"8",x2:"19",y2:"16"})]})}),g&&u.jsx(g5,{connectionId:g.id,provider:g.provider,displayName:g.display_name,onClose:()=>y(null),onSaved:()=>w()}),h&&u.jsx(p5,{existingConnection:h==="edit"?_.get("newsletter"):null,onClose:()=>m(null),onSaved:()=>w()}),t&&O&&u.jsxs("div",{className:"connections-dropdown",children:[u.jsx("div",{className:"connections-dropdown__header",children:"Connections"}),u.jsxs("div",{className:"connections-dropdown__upsell",children:[u.jsx("p",{children:"Connect your X, LinkedIn, and other accounts to publish directly from OpenWriter."}),u.jsxs("p",{children:["Set up the ",u.jsx("strong",{children:"Publish"})," plugin to get started."]})]})]}),t&&!O&&u.jsxs("div",{className:"connections-dropdown",children:[u.jsx("div",{className:"connections-dropdown__header",children:"Connections"}),u.jsx("div",{className:"connections-dropdown__list",children:v5.map(R=>{const B=_.get(R.id);return B&&o===B.id?u.jsxs("div",{className:"connections-dropdown__confirm",children:[u.jsxs("span",{children:["Disconnect ",R.label,"?"]}),u.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[u.jsx("button",{onClick:()=>C(B.id),children:"Yes"}),u.jsx("button",{onClick:()=>l(null),children:"No"})]})]},R.id):B?u.jsxs("div",{className:"connections-dropdown__item",children:[u.jsx("div",{className:"connections-dropdown__icon",children:T(R.id)}),u.jsxs("div",{className:"connections-dropdown__info",children:[u.jsx("div",{className:"connections-dropdown__name",children:B.display_name||B.domain||R.label}),u.jsxs("div",{className:"connections-dropdown__type",children:[u.jsx("span",{className:`connections-status ${A(B.status)}`}),"Connected"]})]}),u.jsxs("div",{className:"connections-dropdown__actions",children:[u.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>{R.id==="newsletter"?m("edit"):y({id:B.id,provider:R.id,display_name:B.display_name||R.label})},title:"Settings",children:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),u.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),u.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>l(B.id),title:"Disconnect",children:"×"})]})]},R.id):R.oauth?u.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[u.jsx("div",{className:"connections-dropdown__icon",children:T(R.id)}),u.jsxs("div",{className:"connections-dropdown__info",children:[u.jsx("div",{className:"connections-dropdown__name",children:R.label}),u.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),u.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>E(R.id),disabled:d!==null,children:d===R.id?"Connecting…":"Connect"})]},R.id):u.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[u.jsx("div",{className:"connections-dropdown__icon",children:T(R.id)}),u.jsxs("div",{className:"connections-dropdown__info",children:[u.jsx("div",{className:"connections-dropdown__name",children:R.label}),u.jsx("div",{className:"connections-dropdown__type",children:"Built-in · Not configured"})]}),u.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>m("new"),children:"Configure"})]},R.id)})})]})]})}const b5=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:u.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),x5=()=>u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),w5=()=>u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),k5=()=>u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function S5({title:t,onTitleChange:e,syncStatus:n,onSync:r,onToggleSidebar:s,canGoBack:i,canGoForward:o,onGoBack:l,onGoForward:d,editor:f,onToggleToolbar:h,toolbarOpen:m}){const[g,y]=k.useState(!1),[,b]=k.useState(0),x=k.useRef(null),[w,E]=k.useState(!1),[C,A]=k.useState([]),[T,_]=k.useState(!1),O=k.useRef(null),[R,B]=k.useState(null);k.useEffect(()=>{fetch("/api/update-info").then(W=>W.json()).then(W=>{W.updateAvailable&&B({currentVersion:W.currentVersion,latestVersion:W.updateAvailable})}).catch(()=>{})},[]);const D=k.useCallback(()=>{y(!0),setTimeout(()=>{var W;return(W=x.current)==null?void 0:W.select()},0)},[]),U=k.useCallback(()=>{y(!1)},[]),Q=k.useCallback(W=>{W.key==="Enter"&&y(!1),W.key==="Escape"&&y(!1)},[]),P=k.useCallback(()=>{if(w){E(!1);return}E(!0),_(!0),fetch("/api/sync/pending").then(W=>W.json()).then(W=>A(W)).catch(()=>A([])).finally(()=>_(!1))},[w]);return k.useEffect(()=>{n.state!=="pending"&&E(!1)},[n.state]),k.useEffect(()=>{if(!w)return;const W=$=>{O.current&&!O.current.contains($.target)&&E(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[w]),k.useEffect(()=>{if(!f)return;const W=()=>b($=>$+1);return f.on("transaction",W),()=>{f.off("transaction",W)}},[f]),u.jsxs("div",{className:"titlebar",children:[u.jsxs("div",{className:"titlebar-left",children:[s&&u.jsx("button",{className:"titlebar-menu-btn",onClick:s,title:"Open sidebar",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),l&&u.jsx("button",{className:"titlebar-nav-btn",onClick:l,disabled:!i,title:"Go back (Alt+Left)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),d&&u.jsx("button",{className:"titlebar-nav-btn",onClick:d,disabled:!o,title:"Go forward (Alt+Right)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),f&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"titlebar-divider"}),u.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo (Ctrl+Z)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),u.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo (Ctrl+Y)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),u.jsxs("div",{className:"titlebar-center",children:[g?u.jsx("input",{ref:x,className:"titlebar-input",value:t,onChange:W=>e(W.target.value),onBlur:U,onKeyDown:Q,autoFocus:!0}):u.jsx("span",{className:"titlebar-title",onDoubleClick:D,children:t}),R&&u.jsxs("span",{className:"titlebar-update-badge",title:`Update available: v${R.currentVersion} → v${R.latestVersion}
|
|
205
|
-
Run: npm update -g openwriter`,children:["v",R.latestVersion]})]}),u.jsxs("div",{className:"titlebar-right",children:[h&&u.jsx("button",{className:`titlebar-nav-btn${m?" titlebar-nav-btn--active":""}`,onClick:h,title:"Toggle format toolbar",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M4 20h16"}),u.jsx("path",{d:"m6 16 6-12 6 12"}),u.jsx("path",{d:"M8 12h8"})]})}),u.jsx(l5,{}),u.jsx(y5,{}),u.jsx(s5,{}),u.jsx(d5,{}),u.jsx(h5,{}),u.jsxs("div",{className:"sync-btn-group",ref:O,children:[u.jsxs("button",{className:`titlebar-btn sync-btn-state sync-${n.state}`,onClick:r,disabled:n.state==="syncing",title:n.lastSyncTime?`Last synced: ${new Date(n.lastSyncTime).toLocaleString()}`:"Sync to GitHub",children:[n.state==="unconfigured"&&u.jsxs(u.Fragment,{children:[u.jsx(b5,{})," Sync"]}),n.state==="synced"&&u.jsxs(u.Fragment,{children:[u.jsx(x5,{})," Synced"]}),n.state==="pending"&&u.jsxs(u.Fragment,{children:[u.jsx(w5,{})," Sync",n.pendingFiles?` (${n.pendingFiles})`:""]}),n.state==="syncing"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),n.state==="error"&&u.jsxs(u.Fragment,{children:[u.jsx(k5,{})," Retry"]})]}),n.state==="pending"&&n.pendingFiles&&n.pendingFiles>0&&u.jsx("button",{className:"sync-details-btn",onClick:P,title:"View pending changes",children:u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:u.jsx("path",{d:w?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),w&&u.jsxs("div",{className:"sync-pending-dropdown",children:[u.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),T?u.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):C.length===0?u.jsx("div",{className:"sync-pending-loading",children:"No changes"}):u.jsx("div",{className:"sync-pending-list",children:C.map((W,$)=>u.jsxs("div",{className:`sync-pending-item sync-file-${W.status}`,children:[u.jsx("span",{className:"sync-file-badge",children:W.status[0].toUpperCase()}),u.jsx("span",{className:"sync-file-name",children:W.file})]},$))})]})]})]})]})}function In(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 Hd(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 Jo(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function kd(t){return t?Array.isArray(t)?t.map(kd).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>kd(e)).join(""):"":""}const E5=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Sd(t,e){for(const n of t)n.type&&E5.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Sd(n.content,e)}function Ug(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=In(t,e.nodeId);if(!m)return{success:!1,error:`Node ${e.nodeId} not found`};const g=s.map((y,b)=>{var x;return{...y,attrs:{...y.attrs,id:((x=y.attrs)==null?void 0:x.id)||(b===0?e.nodeId:Jo())}}});i||Sd(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(y){return{success:!1,error:`Failed to replace empty node: ${y}`}}}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=In(t,o);if(!d)return{success:!1,error:`Anchor node ${o} not found`};if(!i){const m=kd(n),g=l?d.pos+d.node.nodeSize:0,y=l?d.pos+d.node.nodeSize+5e3:d.pos;let b=null;if(t.state.doc.nodesBetween(g,Math.min(y,t.state.doc.content.size),x=>{var w,E;return((w=x.attrs)==null?void 0:w.pendingStatus)==="insert"&&((E=x.attrs)!=null&&E.id)&&(x.textContent||"")===m?(b=x.attrs.id,!1):!0}),b)return{success:!0,nodeId:b}}const f=s.map(m=>{var g;return{...m,attrs:{...m.attrs,id:((g=m.attrs)==null?void 0:g.id)||Jo()}}});i||Sd(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 Jv(t,e,n,r,s){var w,E,C,A,T,_;const i=In(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,y=((E=d[0])==null?void 0:E.type)==="listItem"&&((_=(T=(A=(C=d[0])==null?void 0:C.content)==null?void 0:A[0])==null?void 0:T.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}:{}}},b=d.slice(1).map(O=>{var R;return{...O,attrs:{...O.attrs,id:((R=O.attrs)==null?void 0:R.id)||Jo()}}});f||Sd(b,"insert");const x=[y,...b];try{return t.chain().command(({tr:O})=>{const R=x.map(B=>t.state.schema.nodeFromJSON(B));return O.replaceWith(l,l+o.nodeSize,R),!0}).run(),{success:!0,nodeId:e}}catch(O){return{success:!1,error:`Failed to rewrite: ${O}`}}}function N5(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=>kd(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=In(t,e[0]),i=In(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=In(t,m);g&&o.push(g.node.toJSON())}const l=s.pos,d=i.pos+i.node.nodeSize,f=Jo()+Jo(),h=n.map((m,g)=>{var y;return{...m,attrs:{...m.attrs,id:((y=m.attrs)==null?void 0:y.id)||Jo(),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 r2(t,e,n){var l;const r=In(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 C5(t,e){const n=e.autoAccept?{autoAccept:!0}:void 0;if(e.operation==="rewrite"&&e.nodeId&&e.content){const r=Jv(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=Ug(t,r,e.content,n);return{success:s.success,error:s.error}}if(e.operation==="delete"&&e.nodeId){const r=r2(t,e.nodeId,n);return{success:r.success,error:r.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function kp(t,e){if(e.length===0)return;if(e.length===1){C5(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=qa(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=qa(r.doc,i.afterNodeId);if(h){const m=h.pos+h.node.nodeSize,g=Math.min(m+5e3,r.doc.content.size);let y=!1;if(r.doc.nodesBetween(m,g,b=>{var x;return y?!1:((x=b.attrs)==null?void 0:x.pendingStatus)==="insert"&&(b.textContent||"")===f?(y=!0,!1):!0}),y)continue}}}if(i.nodeId&&!i.afterNodeId){const f=qa(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=qa(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,be.fromArray(d))}}else if(i.operation==="delete"&&i.nodeId){const l=qa(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 qa(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 _5(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 T5(t,e,n,r){const s=[];if(r==="delete"){for(const o of n)s.push(r2(t,o));return s}if(r==="insert"){const o=n[n.length-1];return o&&e.length>0&&s.push(Ug(t,{nodeId:o},e)),s}if(n.length>1){const o=N5(t,n,e);return s.push(o),s}const i=Jv(t,n[0],e[0]);if(s.push(i),e.length>1){const o=e.slice(1);s.push(Ug(t,{afterNodeId:n[0]},o))}return s}const sw="[[START_SELECTION]]",iw="[[END_SELECTION]]";function M5(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 fu(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=M5(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 A5(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(fu(r[0],n,iw),fu(r[0],e,sw),r):(fu(r[0],e,sw),fu(r[r.length-1],n,iw),r)}function j5(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)}function ow(t,e){return t.docId&&e.includes(t.docId)?!0:e.includes(t.filename)}const O5=[{action:"comment",label:"Comment",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function R5({editorRef:t,allEditors:e,documentId:n}){const[r,s]=k.useState(!1),[i,o]=k.useState({x:0,y:0}),[l,d]=k.useState(!1),[f,h]=k.useState(""),[m,g]=k.useState(!1),[y,b]=k.useState(""),[x,w]=k.useState(!1),[E,C]=k.useState([]),[A,T]=k.useState([]),[_,O]=k.useState(!1),[R,B]=k.useState(""),[D,U]=k.useState([]),[Q,P]=k.useState(!1),[W,$]=k.useState(""),[H,J]=k.useState(null),[re,V]=k.useState(null),[ie,z]=k.useState(null),[M,I]=k.useState(!1),[Z,le]=k.useState(null),[ge,se]=k.useState(null),xe=k.useRef(null),fe=k.useRef(null),De=k.useRef(null),We=k.useCallback(G=>{if(e&&e.length>0){for(const ue of e)if(ue.view.dom.contains(G))return ue}const oe=t.current;return oe&&oe.view.dom.contains(G)?oe:null},[e,t]);k.useLayoutEffect(()=>{const G=xe.current;if(!G||!r)return;const oe=G.getBoundingClientRect(),ue=8;let{x:Fe,y:Me}=i;Me+oe.height+ue>window.innerHeight&&(Me=i.y-oe.height),Fe+oe.width+ue>window.innerWidth&&(Fe=i.x-oe.width),Me<ue&&(Me=ue),Fe<ue&&(Fe=ue),(Fe!==i.x||Me!==i.y)&&o({x:Fe,y:Me})},[r,i]);const Qe=k.useCallback(()=>{fetch("/api/plugins").then(G=>G.json()).then(G=>{const oe=[];for(const ue of G.plugins||[]){const Fe=ue.displayName||void 0;for(const Me of ue.contextMenuItems||[])oe.push({...Me,pluginDisplayName:Fe})}U(oe)}).catch(()=>{})},[]);k.useEffect(()=>{Qe()},[Qe]),k.useEffect(()=>{const G=()=>Qe();return window.addEventListener("ow-plugins-changed",G),()=>window.removeEventListener("ow-plugins-changed",G)},[Qe]),k.useEffect(()=>{const G=oe=>{xe.current&&!xe.current.contains(oe.target)&&(s(!1),g(!1),w(!1),P(!1),$(""),J(null),V(null),le(null))};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[]);const ot=k.useCallback(()=>{const G=De.current||t.current;return G?G.isActive("link"):!1},[t]),st=k.useCallback(()=>{const G=De.current||t.current,oe=fe.current;if(!G||!oe)return!1;const{from:ue,to:Fe}=oe;let Me=!1;return G.state.doc.nodesBetween(ue,Fe,K=>{var me;return(me=K.attrs)!=null&&me.pendingStatus&&(Me=!0),!Me}),Me},[t]),Ie=k.useCallback(()=>{const G=De.current||t.current,oe=fe.current,ue=(oe==null?void 0:oe.from)??0,Fe=(oe==null?void 0:oe.to)??0,Me=ue!==Fe,K=(()=>{if(!G)return!1;try{return G.state.doc.resolve(ue).parent.content.size===0}catch{return!1}})(),me=st(),ye=[];for(const Ce of D)Ce.condition==="has-selection"&&!Me||Ce.condition==="empty-node"&&!K||ye.push({action:Ce.action,label:Ce.label,shortcut:Ce.shortcut,isPlugin:!0,promptForInput:Ce.promptForInput,pluginDisplayName:Ce.pluginDisplayName});for(const Ce of O5)Ce.condition==="has-selection"&&(!Me||me)||ye.push(Ce);if(Me&&ye.push({action:"link",label:"Link to doc",shortcut:"L"}),ot()&&ye.push({action:"unlink",label:"Unlink"}),ie&&ie.entries.length>0&&ye.unshift({action:"see-connections",label:`See connections (${ie.entries.length})`}),Z){const Ce=Z.title?`Go to "${Z.title}"`:"Go to target";ye.unshift({action:"go-to-target",label:Ce})}return ye},[t,ot,D,st,ie,Z]);k.useEffect(()=>{const G=ue=>{var Ce;if(ue.button!==2)return;const Fe=We(ue.target);if(!Fe)return;De.current=Fe;const{from:Me,to:K}=Fe.state.selection,me=[],ye=[];if(Me!==K&&Fe.state.doc.nodesBetween(Me,K,Re=>{Re.isBlock&&Re.type.name!=="doc"&&(me.push(Re.toJSON()),Re.attrs.id&&ye.push(Re.attrs.id))}),me.length===0){const{$from:Re}=Fe.state.selection,Be=Re.parent;Be&&Be.type.name!=="doc"&&(me.push(Be.toJSON()),(Ce=Be.attrs)!=null&&Ce.id&&ye.push(Be.attrs.id))}fe.current={from:Me,to:K,nodes:me,nodeIds:ye}},oe=ue=>{var Be,Ee,et,gt,Tt,Jt;if(!We(ue.target)||ue.shiftKey)return;const Me=(Ee=(Be=ue.target)==null?void 0:Be.closest)==null?void 0:Ee.call(Be,"[data-comment-id]"),K=(Me==null?void 0:Me.getAttribute("data-comment-id"))||null,me=(gt=(et=ue.target)==null?void 0:et.closest)==null?void 0:gt.call(et,".linked-paragraph[data-backlinks-node]"),ye=(me==null?void 0:me.getAttribute("data-backlinks-node"))||null,Ce=(Jt=(Tt=ue.target)==null?void 0:Tt.closest)==null?void 0:Jt.call(Tt,"span.doc-link[data-doc]"),Re=(Ce==null?void 0:Ce.getAttribute("data-doc"))||null;if(ue.preventDefault(),o({x:ue.clientX,y:ue.clientY}),s(!0),g(!1),w(!1),I(!1),P(!1),$(""),J(null),K){const Mt=fe.current;if(!(!!Mt&&Mt.from!==Mt.to)){const L=Cu().find(te=>te.id===K);if(L){V({id:L.id,text:L.text,note:L.note}),z(null);return}}}if(V(null),ye){const Mt=KB(ye);z(Mt.length>0?{nodeId:ye,entries:Mt}:null)}else z(null);if(Re){const Mt=Re.indexOf("?"),q=Mt>=0?Re.slice(0,Mt):Re,[L,te]=q.split("#"),ve=L&&/^[a-f0-9]{8}$/.test(L)?L:null,Ue=te&&/^[a-f0-9]{8}$/.test(te)?te:null;if(ve){const lt=E.find(Ae=>Ae.docId===ve);le({docId:ve,nodeId:Ue,title:(lt==null?void 0:lt.title)||null}),lt||fetch("/api/documents").then(Ae=>Ae.json()).then(Ae=>{if(Array.isArray(Ae)){const de=Ae.map(ze=>({filename:ze.filename,title:ze.title,docId:ze.docId}));C(de);const _e=de.find(ze=>ze.docId===ve);_e&&le(ze=>ze&&ze.docId===ve?{...ze,title:_e.title}:ze)}}).catch(()=>{})}else le(null)}else le(null)};return document.addEventListener("mousedown",G,!0),document.addEventListener("contextmenu",oe),()=>{document.removeEventListener("mousedown",G,!0),document.removeEventListener("contextmenu",oe)}},[We]);const dt=k.useCallback(async(G,oe)=>{var Ee,et,gt,Tt,Jt;const ue=De.current||t.current;if(!ue)return;const Fe=fe.current;if(!Fe||Fe.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",G);return}let{nodes:Me,nodeIds:K}=Fe;const{from:me,to:ye}=Fe;d(!0),s(!1),g(!1);const Ce=`ctx-${Date.now()}`,Re=G.includes(":")?G.split(":").slice(1).join(":"):G,Be=["insert","fill","fill-sentence"].includes(Re);if(Be)ue.commands.showInsertionLoading(Ce,me);else{const Mt=ue.state.doc.resolve(me),q=ue.state.doc.resolve(ye),L=Mt.sameParent(q)&&me!==ye;ue.commands.applyLoadingEffect(Ce,me,ye,L?"selection":"paragraph")}try{const Mt=[],q=[],L=new Set(K);let te=!1;const ve=ue.state.doc;for(let ne=0;ne<ve.childCount;ne++){const ke=ve.child(ne),$e=(Ee=ke.attrs)==null?void 0:Ee.id;if($e&&L.has($e))te=!0;else if(te){const at=ke.textContent.trim();at&&q.push(at)}else{const at=ke.textContent.trim();at&&Mt.push(at)}}let Ue=Me,lt=!1,Ae=0,de=0;const _e=me!==ye?ue.state.doc.resolve(me):null,ze=me!==ye?ue.state.doc.resolve(ye):null;if((_e&&ze?_e.sameParent(ze):!1)&&_e&&Me.length===1){const ne=_e.start(_e.depth);Ae=me-ne,de=ye-ne;const ke=((gt=(et=Me[0])==null?void 0:et.content)==null?void 0:gt.reduce(($e,at)=>{var Nt;return $e+(((Nt=at.text)==null?void 0:Nt.length)||(at.type==="hardBreak"?1:0))},0))??0;(Ae>0||de<ke)&&(Ue=A5(Me,Ae,de),lt=!0)}const wt=ue.state.doc.textContent,an={nodes:Ue,action:Re,nodeIds:K,contextBefore:Mt.slice(-3),contextAfter:q.slice(0,3),fullDocument:wt,documentId:n,debug:!0};lt&&(an.hasSelectionMarkers=!0),oe&&(an.instruction=oe);const ft=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(an)});if(!ft.ok){const ne=await ft.json().catch(()=>({}));console.error("[ContextMenu] API error:",ft.status,ne);return}const En=await ft.json();if(En.success&&En.nodes){let ne=En.nodes;if(ne.length===1&&Array.isArray(ne[0])&&(ne=ne[0]),j5(ne),lt&&ne.length===1&&K.length===1){const ke=ln=>(ln==null?void 0:ln.reduce((xn,Zt)=>{var tn;return xn+(((tn=Zt.text)==null?void 0:tn.length)||(Zt.type==="hardBreak"?1:0))},0))??0,$e=ke((Tt=Me[0])==null?void 0:Tt.content),at=ke((Jt=ne[0])==null?void 0:Jt.content),Nt={selectionFrom:Ae,selectionTo:at-($e-de),originalFrom:Ae,originalTo:de};Jv(ue,K[0],ne[0],Nt)}else T5(ue,ne,K,Re)}else console.warn("[ContextMenu] Unexpected response:",En)}catch(Mt){console.error("[ContextMenu] Plugin action failed:",Mt)}finally{Be?ue.commands.removeInsertionLoading(Ce):ue.commands.removeLoadingEffect(Ce),d(!1)}},[t]),Ge=k.useCallback(async G=>{const oe=De.current||t.current;if(!oe)return;const{$from:ue}=oe.state.selection,Fe=ue.before(ue.depth),Me=ue.after(ue.depth),K=ue.parent.content.size===0;d(!0),s(!1),g(!1),K?oe.chain().focus().deleteRange({from:Fe,to:Me}).insertContentAt(Fe,{type:"imageLoading"}).run():oe.chain().focus().insertContentAt(Me,{type:"imageLoading"}).run();let me=-1;oe.state.doc.descendants((ye,Ce)=>{if(ye.type.name==="imageLoading"&&me===-1)return me=Ce,ye.nodeSize,!1});try{const ye=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:G})}),Ce=await ye.json().catch(()=>({success:!1,error:`Generation failed (${ye.status})`}));if(Ce.success&&Ce.src){let Re=-1,Be=0;if(oe.state.doc.descendants((Ee,et)=>{if(Ee.type.name==="imageLoading"&&Re===-1)return Re=et,Be=Ee.nodeSize,!1}),Re>=0){const{tr:Ee}=oe.state;Ee.replaceWith(Re,Re+Be,oe.schema.nodes.image.create({src:Ce.src,alt:G})),oe.view.dispatch(Ee)}}else{console.error("[ContextMenu] Image generation failed:",Ce.error);let Re=-1,Be=0;if(oe.state.doc.descendants((Ee,et)=>{if(Ee.type.name==="imageLoading"&&Re===-1)return Re=et,Be=Ee.nodeSize,!1}),Re>=0){const{tr:Ee}=oe.state;Ee.delete(Re,Re+Be),oe.view.dispatch(Ee)}}}catch(ye){console.error("[ContextMenu] Image generation failed:",ye);let Ce=-1,Re=0;if(oe.state.doc.descendants((Be,Ee)=>{if(Be.type.name==="imageLoading"&&Ce===-1)return Ce=Ee,Re=Be.nodeSize,!1}),Ce>=0){const{tr:Be}=oe.state;Be.delete(Ce,Ce+Re),oe.view.dispatch(Be)}}finally{d(!1)}},[t]),bt=k.useCallback(G=>{const{action:oe,isPlugin:ue,promptForInput:Fe}=G;if(ue&&Fe){b(oe),g(!0);return}if(ue){if(oe.startsWith("img:"))return;dt(oe);return}if(oe==="comment"){P(!0);return}if(oe==="delete"){const Me=De.current||t.current,K=fe.current;if(Me&&K&&K.nodeIds.length>0){const{tr:me}=Me.state,ye=new Set(K.nodeIds),Ce=[];Me.state.doc.descendants((Re,Be)=>{var Ee;if((Ee=Re.attrs)!=null&&Ee.id&&ye.has(Re.attrs.id))return Ce.push({from:Be,to:Be+Re.nodeSize}),!1});for(const Re of Ce.reverse())me.delete(Re.from,Re.to);Ce.length>0&&Me.view.dispatch(me)}s(!1);return}if(oe==="link"){const Me=De.current||t.current;if(Me){const K=[];Me.state.doc.descendants(me=>{var ye;(ye=me.marks)==null||ye.forEach(Ce=>{var Re,Be;if(Ce.type.name==="link"&&((Be=(Re=Ce.attrs)==null?void 0:Re.href)!=null&&Be.startsWith("doc:"))){const Ee=e5(Ce.attrs.href);Ee&&!K.includes(Ee)&&K.push(Ee)}})}),T(K)}fetch("/api/documents").then(K=>K.json()).then(K=>{Array.isArray(K)&&C(K.map(me=>({filename:me.filename,title:me.title,docId:me.docId}))),O(!1),B(""),w(!0)}).catch(()=>{});return}if(oe==="unlink"){const Me=De.current||t.current;Me&&Me.chain().focus().unsetLink().run(),s(!1);return}if(oe==="see-connections"){fetch("/api/documents").then(Me=>Me.json()).then(Me=>{Array.isArray(Me)&&C(Me.map(K=>({filename:K.filename,title:K.title,docId:K.docId})))}).catch(()=>{}),I(!0);return}if(oe==="go-to-target"){Z&&window.dispatchEvent(new CustomEvent("ow-navigate-to-link",{detail:{docId:Z.docId,nodeId:Z.nodeId,filename:null,quote:null}})),s(!1),le(null);return}},[dt,t,Z]),xt=k.useCallback(()=>{f.trim()&&(y.startsWith("img:")?Ge(f.trim()):dt(y,f.trim()),h(""),b(""))},[dt,Ge,y,f]),$t=k.useCallback(()=>{if(!n)return;if(H){fetch("/api/comments",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,id:H.id,note:W.trim()})}).then(()=>{s(!1),P(!1),$(""),J(null)}).catch(me=>{console.error("[ContextMenu] Comment edit failed:",me)});return}const G=De.current||t.current,oe=fe.current;if(!G||!oe)return;const{from:ue,to:Fe,nodeIds:Me}=oe;if(ue===Fe||Me.length===0)return;const K=G.state.doc.textBetween(ue,Fe,`
|
|
206
|
-
`);K.trim()&&fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:K,note:W.trim(),nodeId:Me[Me.length-1],nodeIds:Me})}).then(()=>{s(!1),P(!1),$("")}).catch(me=>{console.error("[ContextMenu] Comment create failed:",me)})},[t,n,W,H]),Ke=k.useCallback(()=>{re&&(J({id:re.id,text:re.text}),$(re.note),P(!0),V(null))},[re]),pt=k.useCallback(()=>{re&&fetch("/api/comments/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[re.id]})}).then(()=>{s(!1),V(null)}).catch(G=>{console.error("[ContextMenu] Comment resolve failed:",G)})},[re]),Ft=k.useCallback(()=>{re&&fetch("/api/comments",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[re.id]})}).then(()=>{s(!1),V(null)}).catch(G=>{console.error("[ContextMenu] Comment delete failed:",G)})},[re]),Je=k.useCallback((G,oe)=>{const ue=De.current||t.current;if(ue){const Fe=G.docId?wp({docId:G.docId,nodeId:oe==null?void 0:oe.nodeId,quote:oe==null?void 0:oe.quote}):wp({filename:G.filename});ue.chain().focus().setLink({href:Fe}).run()}fetch("/api/auto-tag-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetFile:G.filename})}).catch(()=>{}),s(!1),w(!1),se(null)},[t]),Y=k.useCallback(G=>{if(!G.docId){Je(G);return}se({docId:G.docId,filename:G.filename,title:G.title,paragraphs:[],loading:!0}),fetch(`/api/documents/by-doc-id/${G.docId}/paragraphs`).then(oe=>oe.json()).then(oe=>{se(ue=>ue&&ue.docId===G.docId?{...ue,paragraphs:Array.isArray(oe.paragraphs)?oe.paragraphs:[],loading:!1}:ue)}).catch(()=>{se(oe=>oe&&oe.docId===G.docId?{...oe,paragraphs:[],loading:!1}:oe)})},[Je]),pe=k.useCallback(()=>{const G=R.trim();if(!G)return;const oe=De.current||t.current;oe&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:G})}).then(ue=>ue.json()).then(ue=>{if(ue.filename){const Fe=wp(ue.docId?{docId:ue.docId}:{filename:ue.filename});oe.chain().focus().setLink({href:Fe}).run()}}).catch(()=>{}),s(!1),w(!1),O(!1),B(""))},[t,R]);return r?u.jsx("div",{ref:xe,className:"context-menu",style:{left:i.x,top:i.y},children:l?u.jsx("div",{className:"context-menu-loading",children:"Applying..."}):Q?u.jsxs("div",{className:"context-menu-comment-editor",children:[(()=>{const G=(H==null?void 0:H.text)??(()=>{const oe=De.current||t.current,ue=fe.current;return!oe||!ue||ue.from===ue.to?"":oe.state.doc.textBetween(ue.from,ue.to,`
|
|
207
|
-
`)})();return G?u.jsx("div",{className:"context-menu-comment-quote",children:G}):null})(),u.jsx("textarea",{autoFocus:!0,className:"context-menu-comment-textarea",value:W,onChange:G=>$(G.target.value),onKeyDown:G=>{G.key==="Enter"&&(G.metaKey||G.ctrlKey)&&(G.preventDefault(),$t()),G.key==="Escape"&&(s(!1),P(!1),$(""),J(null))},placeholder:"Note for agent (optional)...",rows:4}),u.jsxs("div",{className:"context-menu-comment-actions",children:[u.jsx("span",{className:"context-menu-comment-hint",children:"⌘↵ to save · Esc to cancel"}),u.jsx("button",{onClick:$t,children:H?"Save":"Comment"})]})]}):re?u.jsxs(u.Fragment,{children:[u.jsx("button",{className:"context-menu-item",onClick:Ke,children:u.jsx("span",{children:"Edit comment"})}),u.jsx("button",{className:"context-menu-item",onClick:pt,children:u.jsx("span",{children:"Resolve comment"})}),u.jsx("button",{className:"context-menu-item",onClick:Ft,children:u.jsx("span",{children:"Delete comment"})})]}):m?u.jsxs("div",{className:"context-menu-custom",children:[u.jsx("input",{autoFocus:!0,value:f,onChange:G=>h(G.target.value),onKeyDown:G=>{G.key==="Enter"&&xt(),G.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),u.jsx("button",{onClick:xt,children:"Apply"})]}):ge?u.jsxs("div",{className:"context-menu-link-picker",children:[u.jsxs("div",{className:"context-menu-link-header",children:[u.jsx("button",{className:"context-menu-link-back",onClick:()=>se(null),title:"Back to doc list",children:"←"}),u.jsxs("span",{children:['Pick paragraph in "',ge.title,'"']})]}),u.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>Je({filename:ge.filename,docId:ge.docId}),children:u.jsx("span",{children:"Link whole doc"})}),u.jsx("div",{className:"context-menu-link-list",children:ge.loading?u.jsx("div",{className:"context-menu-loading",children:"Loading…"}):ge.paragraphs.length===0?u.jsx("div",{className:"context-menu-loading",children:"No paragraphs"}):ge.paragraphs.map(G=>{const oe=G.preview.replace(/…$/,"").slice(0,50),ue=G.type==="heading"?Math.max(0,(G.level||1)-1)*12:12;return u.jsx("button",{className:`context-menu-item context-menu-paragraph-row context-menu-paragraph-row--${G.type}`,style:{paddingLeft:8+ue},onClick:()=>Je({filename:ge.filename,docId:ge.docId},{nodeId:G.nodeId,quote:oe}),children:u.jsx("span",{children:G.preview})},G.nodeId)})})]}):M&&ie?u.jsxs("div",{className:"context-menu-link-picker",children:[u.jsxs("div",{className:"context-menu-link-header",children:["Linked from ",ie.entries.length," ",ie.entries.length===1?"place":"places"]}),u.jsx("div",{className:"context-menu-link-list",children:ie.entries.map((G,oe)=>{const ue=E.find(Me=>Me.docId===G.from_doc),Fe=(ue==null?void 0:ue.title)||G.from_doc;return u.jsxs("button",{className:"context-menu-item",onClick:()=>{window.dispatchEvent(new CustomEvent("ow-navigate-to-link",{detail:{docId:G.from_doc,nodeId:G.from_node,filename:null,quote:null}})),s(!1),I(!1)},children:[u.jsx("span",{children:Fe}),u.jsxs("span",{className:"context-menu-shortcut",children:['"',G.text,'"']})]},`${G.from_doc}-${G.from_node}-${oe}`)})})]}):x?u.jsxs("div",{className:"context-menu-link-picker",children:[u.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),_?u.jsxs("div",{className:"context-menu-custom",children:[u.jsx("input",{autoFocus:!0,value:R,onChange:G=>B(G.target.value),onKeyDown:G=>{G.key==="Enter"&&pe(),G.key==="Escape"&&O(!1)},placeholder:"New document title..."}),u.jsx("button",{onClick:pe,children:"Create"})]}):u.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>O(!0),children:u.jsx("span",{children:"+ New link doc"})}),u.jsxs("div",{className:"context-menu-link-list",children:[A.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),E.filter(G=>ow(G,A)).map(G=>u.jsxs("div",{className:"context-menu-link-row",children:[u.jsx("button",{className:"context-menu-item context-menu-link-row__main",onClick:()=>Je(G),children:u.jsx("span",{children:G.title})}),G.docId&&u.jsx("button",{className:"context-menu-link-row__drill",title:"Pick a paragraph in this doc",onClick:()=>Y(G),children:"▸"})]},`linked-${G.filename}`))]}),u.jsx("div",{className:"context-menu-section-header",children:"All documents"}),E.filter(G=>!ow(G,A)).map(G=>u.jsxs("div",{className:"context-menu-link-row",children:[u.jsx("button",{className:"context-menu-item context-menu-link-row__main",onClick:()=>Je(G),children:u.jsx("span",{children:G.title})}),G.docId&&u.jsx("button",{className:"context-menu-link-row__drill",title:"Pick a paragraph in this doc",onClick:()=>Y(G),children:"▸"})]},G.filename)),E.length===0&&u.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const G=Ie();let oe;return G.map((ue,Fe)=>{const Me=ue.isPlugin&&ue.pluginDisplayName&&ue.pluginDisplayName!==oe,K=oe!==void 0;ue.isPlugin?oe=ue.pluginDisplayName:oe=void 0;const me=!ue.isPlugin&&K;return u.jsxs("span",{children:[Me&&u.jsx("div",{className:"context-menu-section-header",children:ue.pluginDisplayName}),me&&u.jsx("div",{className:"context-menu-divider"}),u.jsxs("button",{className:"context-menu-item",onClick:()=>bt(ue),children:[u.jsx("span",{children:ue.label}),ue.shortcut&&u.jsx("span",{className:"context-menu-shortcut",children:ue.shortcut})]})]},ue.action)})})()}):null}const I5=80,Sp=8,Bo=8,L5=400;function aw(t){return t.nodeIds&&t.nodeIds.length>0?t.nodeIds:[t.nodeId]}function lw(t,e){const n=new Set(e);return t.every(r=>n.has(r))}function D5(t,e){const n=e.find(s=>s.id===t);if(!n)return[];const r=aw(n);return e.filter(s=>{if(s.id===n.id)return!0;const i=aw(s);return lw(i,r)||lw(r,i)}).sort((s,i)=>(s.createdAt||"").localeCompare(i.createdAt||""))}function P5({documentId:t}){const[e,n]=k.useState(null),[r,s]=k.useState({kind:"view"}),[i,o]=k.useState(""),[l,d]=k.useState(0),[f,h]=k.useState({left:0,top:0,placement:"above"}),m=k.useRef(null),g=k.useRef(null),y=k.useRef(null),b=k.useRef(null),x=k.useRef({kind:"view"});k.useEffect(()=>{b.current=e},[e]),k.useEffect(()=>{x.current=r},[r]),k.useEffect(()=>{const W=()=>d($=>$+1);return window.addEventListener("ow-comments-changed",W),()=>window.removeEventListener("ow-comments-changed",W)},[]);const w=k.useCallback(()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)},[]),E=k.useCallback(()=>{w(),y.current=window.setTimeout(()=>{x.current.kind==="view"&&n(null)},I5)},[w]),C=k.useCallback(()=>{w(),n(null),s({kind:"view"}),o("")},[w]),A=k.useMemo(()=>e?D5(e.commentId,Cu()):[],[e,l]);k.useEffect(()=>{e&&A.length===0&&C()},[e,A.length,C]),k.useLayoutEffect(()=>{if(!e)return;const W=m.current;if(!W)return;const $=W.getBoundingClientRect(),{rect:H}=e,J=H.top,re=window.innerHeight-H.bottom,V=J>=$.height+Sp||J>=re?"above":"below",ie=V==="above"?Math.max(Bo,H.top-$.height-Sp):Math.min(window.innerHeight-$.height-Bo,H.bottom+Sp);let z=H.left;z+$.width>window.innerWidth-Bo&&(z=window.innerWidth-$.width-Bo),z<Bo&&(z=Bo),h({left:z,top:ie,placement:V})},[e,r,A.length,l]),k.useEffect(()=>{const W=re=>{var z,M,I;const V=re.target,ie=(z=V==null?void 0:V.closest)==null?void 0:z.call(V,"[data-comment-id]");if(ie){const Z=ie.getAttribute("data-comment-id");if(!Z)return;if(((M=b.current)==null?void 0:M.commentId)===Z){w();return}w(),s({kind:"view"}),o(""),n({commentId:Z,rect:ie.getBoundingClientRect()});return}if((I=m.current)!=null&&I.contains(V)){w();return}b.current&&E()},$=re=>{var ie,z;const V=re.relatedTarget;if(V&&((ie=m.current)!=null&&ie.contains(V))){w();return}V&&((z=V.closest)!=null&&z.call(V,"[data-comment-id]"))||b.current&&E()},H=re=>{if(re.key==="Escape"&&b.current){if(re.preventDefault(),x.current.kind!=="view"){s({kind:"view"}),o("");return}C()}},J=re=>{var V;b.current&&x.current.kind==="view"&&((V=m.current)!=null&&V.contains(re.target)||C())};return document.addEventListener("mouseover",W),document.addEventListener("mouseout",$),document.addEventListener("keydown",H),document.addEventListener("scroll",J,!0),()=>{document.removeEventListener("mouseover",W),document.removeEventListener("mouseout",$),document.removeEventListener("keydown",H),document.removeEventListener("scroll",J,!0),w()}},[w,E,C]),k.useEffect(()=>{var W;r.kind!=="view"&&((W=g.current)==null||W.focus())},[r]);const T=k.useCallback(W=>{const $=Cu().find(H=>H.id===W);$&&(o($.note||""),s({kind:"edit",commentId:W}))},[]),_=k.useCallback(W=>{o(""),s({kind:"compose",parentCommentId:W})},[]),O=k.useCallback(()=>{s({kind:"view"}),o("")},[]),R=k.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(W=>console.error("[CommentPopover] Save failed:",W))},[r,t,i]),B=k.useCallback(()=>{if(r.kind!=="compose"||!t)return;const W=Cu().find($=>$.id===r.parentCommentId);W&&fetch("/api/comments",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:t,text:W.text,note:i.trim(),nodeId:W.nodeId,nodeIds:W.nodeIds})}).then(()=>{s({kind:"view"}),o("")}).catch($=>console.error("[CommentPopover] Create failed:",$))},[r,t,i]),D=k.useCallback(W=>{fetch("/api/comments/resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[W]})}).catch($=>console.error("[CommentPopover] Resolve failed:",$))},[]),U=k.useCallback(W=>{fetch("/api/comments",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:[W]})}).catch($=>console.error("[CommentPopover] Delete failed:",$))},[]);if(!e||A.length===0)return null;const Q=r.kind!=="view",P=r.kind==="compose"?"Adding a new comment on the same range":null;return u.jsx("div",{ref:m,className:`ow-comment-popover ow-comment-popover-${f.placement}`,style:{left:f.left,top:f.top,maxHeight:L5},onMouseEnter:w,onMouseLeave:E,children:Q?u.jsxs(u.Fragment,{children:[P&&u.jsx("div",{className:"ow-comment-popover-empty",children:P}),u.jsx("textarea",{ref:g,className:"ow-comment-popover-textarea",value:i,onChange:W=>o(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.metaKey||W.ctrlKey)&&(W.preventDefault(),r.kind==="edit"?R():r.kind==="compose"&&B()),W.key==="Escape"&&(W.preventDefault(),O())},rows:4,placeholder:"Note for agent (optional)..."}),u.jsxs("div",{className:"ow-comment-popover-actions",children:[u.jsx("span",{className:"ow-comment-popover-hint",children:"⌘↵ to save · Esc to cancel"}),u.jsx("button",{className:"ow-icon-btn",onClick:r.kind==="edit"?R:B,title:"Save",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M20 6 9 17l-5-5"})})})]})]}):u.jsx("div",{className:"ow-comment-popover-stack",children:A.map((W,$)=>u.jsxs("div",{className:`ow-comment-popover-card${$>0?" ow-comment-popover-card-divider":""}`,children:[W.note?u.jsx("div",{className:"ow-comment-popover-text",children:W.note}):u.jsx("div",{className:"ow-comment-popover-empty",children:"No note"}),u.jsxs("div",{className:"ow-comment-popover-actions",children:[u.jsx("button",{className:"ow-icon-btn",onClick:()=>T(W.id),title:"Edit comment",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12 20h9"}),u.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}),u.jsx("button",{className:"ow-icon-btn",onClick:()=>_(W.id),title:"Add another comment on this range",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12 5v14"}),u.jsx("path",{d:"M5 12h14"})]})}),u.jsx("button",{className:"ow-icon-btn",onClick:()=>D(W.id),title:"Resolve (mark addressed)",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M20 6 9 17l-5-5"})})}),u.jsx("button",{className:"ow-icon-btn ow-icon-btn-danger",onClick:()=>U(W.id),title:"Delete (remove permanently)",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M18 6 6 18"}),u.jsx("path",{d:"m6 6 12 12"})]})})]})]},W.id))})})}function Yv(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 B5(t,e){const n=In(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 z5(t,e){const n=In(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 $5(t,e){var o;const n=In(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=Yv(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function F5(t,e){var o;const n=In(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=Yv(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function U5(t,e){var o,l;const n=In(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=Yv(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(d).run()}return!0}function H5(t,e){var i;const n=In(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 W5(t,e){const n=Hd(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=In(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 q5(t,e){var l;const n=Hd(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 s2(t,e){var i,o;const n=In(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return W5(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return B5(t,e);case"rewrite":return z5(t,e);case"delete":return $5(t,e);default:return!1}}function i2(t,e){var i,o;const n=In(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return q5(t,r);switch((o=n.node.attrs)==null?void 0:o.pendingStatus){case"insert":return F5(t,e);case"rewrite":return U5(t,e);case"delete":return H5(t,e);default:return!1}}function V5(t){const e=o2(t).reverse();for(const n of e)s2(t,n);t.view&&Kv(t.view)}function K5(t){const e=o2(t).reverse();for(const n of e)i2(t,n);t.view&&Kv(t.view)}function Xv(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 Ep(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...Xv(n));return e}function o2(t){return Xv(t).map(e=>e.nodeId)}function G5(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 Va(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 J5(t){const[e,n]=k.useState([]),[r,s]=k.useState(0),i=k.useRef(),o=k.useRef(new Set),l=k.useCallback(()=>{const E=t.filter(O=>O&&!O.isDestroyed);if(E.length===0){n([]),o.current=new Set;return}const C=Ep(E);n(C);const A=o.current,T=new Set(C.map(O=>O.nodeId));let _=-1;if(A.size>0){for(let O=0;O<C.length;O++)if(!A.has(C[O].nodeId)){_=O;break}}o.current=T,_>=0?(s(_),Va(C[_].editor,C[_].nodeId)):C.length===0?s(0):s(O=>Math.min(O,C.length-1))},[t]);k.useEffect(()=>{const E=t.filter(T=>T&&!T.isDestroyed);if(E.length===0)return;const C=()=>{clearTimeout(i.current),i.current=setTimeout(l,50)};for(const T of E)T.on("transaction",C);l();const A=setTimeout(()=>{const T=Ep(E.filter(_=>!_.isDestroyed));T.length>0&&Va(T[0].editor,T[0].nodeId)},150);return()=>{for(const T of E)T.isDestroyed||T.off("transaction",C);clearTimeout(i.current),clearTimeout(A)}},[t,l]),k.useEffect(()=>{const E=e[r]??null;return K1((E==null?void 0:E.nodeId)??null,(E==null?void 0:E.groupId)??null),E!=null&&E.editor&&!E.editor.isDestroyed&&E.editor.view&&Kv(E.editor.view),()=>{K1(null)}},[r,e]);const d=G5(e),f=e[r]??null,h=k.useCallback(()=>{if(e.length===0)return;const E=(r+1)%e.length;s(E),e[E]&&Va(e[E].editor,e[E].nodeId)},[e,r]),m=k.useCallback(()=>{if(e.length===0)return;const E=(r-1+e.length)%e.length;s(E),e[E]&&Va(e[E].editor,e[E].nodeId)},[e,r]),g=k.useCallback(()=>{const E=t.filter(T=>T&&!T.isDestroyed),C=Ep(E);if(C.length===0)return;const A=Math.min(r,C.length-1);Va(C[A].editor,C[A].nodeId)},[t,r]),y=k.useCallback(()=>{f&&(s2(f.editor,f.nodeId),l(),g())},[f,l,g]),b=k.useCallback(()=>{f&&(i2(f.editor,f.nodeId),l(),g())},[f,l,g]),x=k.useCallback(()=>{const E=t.filter(C=>C&&!C.isDestroyed);for(const C of E)V5(C);l()},[t,l]),w=k.useCallback(()=>{const E=t.filter(C=>C&&!C.isDestroyed);for(const C of E)K5(C);l()},[t,l]);return{pendingNodes:e,counts:d,currentNode:f,currentIndex:r,hasPending:d.total>0,goToNext:h,goToPrevious:m,acceptCurrent:y,rejectCurrent:b,acceptAll:x,rejectAll:w,refresh:l}}const ia={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},Y5=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...ia})}),X5=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...ia})}),Q5=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...ia})}),Z5=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...ia})}),cw=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...ia})}),uw=()=>u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...ia})});function a2(t,e,n){const r=In(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 l2(t,e,n){const r=Hd(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 hu(t,e){if(!Vv()||!e)return!1;const n=zB(),r=BB();return r&&n&&Array.isArray(n)?l2(t,r,n):n&&a2(t,e,n),Qa(!1),!0}function e8({editors:t,pendingDocs:e,currentFilename:n,onSwitchDocument:r,sendMessage:s,getDocument:i,docVersionRef:o}){const{counts:l,currentNode:d,currentIndex:f,hasPending:h,goToNext:m,goToPrevious:g,acceptCurrent:y,rejectCurrent:b,acceptAll:x,rejectAll:w}=J5(t),[E,C]=k.useState(!1),A=k.useRef(null),T=k.useRef(null),_=e.filenames.length,O=t8(e.filenames,n),R=(d==null?void 0:d.pendingStatus)==="rewrite",B=!!(d!=null&&d.groupId),D=R,U=k.useCallback(()=>{var M,I;const z=d==null?void 0:d.editor;if(!(!z||!d||d.pendingStatus!=="rewrite"))if(E)T.current&&hu(T.current,A.current),A.current=null,T.current=null,C(!1);else if(B&&d.groupId){const Z=Hd(z,d.groupId);if(Z.length===0)return;const le=(M=Z[0].node.attrs)==null?void 0:M.pendingOriginalContent;if(!le||!Array.isArray(le))return;const ge=Z.map(fe=>fe.node.toJSON()),se=le.map((fe,De)=>({...fe,attrs:{...fe.attrs||{},pendingStatus:"rewrite",pendingGroupId:d.groupId,...De===0?{pendingOriginalContent:le}:{}}}));if(Qa(!0,d.nodeId,ge,d.groupId),!l2(z,d.groupId,se)){Qa(!1);return}A.current=d.nodeId,T.current=z,C(!0)}else{const Z=In(z,d.nodeId);if(!Z)return;const{node:le}=Z,ge=(I=le.attrs)==null?void 0:I.pendingOriginalContent;if(!ge)return;const se=le.toJSON();if(Qa(!0,d.nodeId,se),!a2(z,d.nodeId,ge)){Qa(!1);return}A.current=d.nodeId,T.current=z,C(!0)}},[d,E,B]);k.useEffect(()=>{if(!E)return;const z=A.current,M=T.current;z&&M&&(d==null?void 0:d.nodeId)!==z&&(hu(M,z),A.current=null,T.current=null,C(!1))},[d==null?void 0:d.nodeId,E]),k.useEffect(()=>{if(t.length!==0)return()=>{Vv()&&A.current&&T.current&&(hu(T.current,A.current),A.current=null,T.current=null)}},[t]);const Q=k.useCallback(z=>{if(!n)return;if(!t.some(I=>!I||I.isDestroyed?!1:Xv(I).length>0)){const I=i==null?void 0:i();I&&s({type:"doc-update",document:I,filename:n,version:(o==null?void 0:o.current)??0}),s({type:"pending-resolved",filename:n,action:z})}},[t,n,s,i,o]),P=k.useCallback(()=>{T.current&&E&&A.current&&(hu(T.current,A.current),A.current=null,T.current=null,C(!1))},[E]),W=k.useCallback(()=>{P(),y(),Q("accept")},[P,y,Q]),$=k.useCallback(()=>{P(),b(),Q("reject")},[P,b,Q]),H=k.useCallback(()=>{P(),x(),Q("accept")},[P,x,Q]);k.useEffect(()=>{const z=()=>H();return window.addEventListener("ow-accept-all",z),()=>window.removeEventListener("ow-accept-all",z)},[H]);const J=k.useCallback(()=>{P(),w(),Q("reject")},[P,w,Q]),re=k.useCallback(()=>{if(_===0||_===1&&O===0)return;const z=O<=0?_-1:O-1;r(e.filenames[z])},[_,O,e.filenames,r]),V=k.useCallback(()=>{if(_===0||_===1&&O===0)return;const z=O>=_-1?0:O+1;r(e.filenames[z])},[_,O,e.filenames,r]);if(k.useEffect(()=>{if(!h)return;const z=M=>{if(!(M.target instanceof HTMLInputElement||M.target instanceof HTMLTextAreaElement)&&!(M.target instanceof HTMLElement&&M.target.closest("[contenteditable]")))switch(M.key){case"j":case"ArrowDown":!M.metaKey&&!M.ctrlKey&&(M.preventDefault(),m());break;case"k":case"ArrowUp":!M.metaKey&&!M.ctrlKey&&(M.preventDefault(),g());break;case"h":case"ArrowLeft":!M.metaKey&&!M.ctrlKey&&!M.altKey&&(M.preventDefault(),re());break;case"l":case"ArrowRight":!M.metaKey&&!M.ctrlKey&&!M.altKey&&(M.preventDefault(),V());break;case"a":!M.metaKey&&!M.ctrlKey&&!M.shiftKey&&(M.preventDefault(),W());break;case"r":!M.metaKey&&!M.ctrlKey&&(M.preventDefault(),$());break;case"A":M.shiftKey&&!M.metaKey&&!M.ctrlKey&&(M.preventDefault(),H());break;case"R":M.shiftKey&&!M.metaKey&&!M.ctrlKey&&(M.preventDefault(),J());break;case"o":!M.metaKey&&!M.ctrlKey&&!M.shiftKey&&(M.preventDefault(),U());break}};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[h,m,g,re,V,W,$,H,J,U]),!h)return null;const ie=O>=0?O+1:"?";return u.jsxs("div",{className:"review-panel",children:[_>1&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"review-panel__nav",children:[u.jsx("button",{className:"review-panel__btn",onClick:re,title:"Previous doc (h)",children:u.jsx(Y5,{})}),u.jsx("button",{className:"review-panel__btn",onClick:V,title:"Next doc (l)",children:u.jsx(X5,{})}),u.jsxs("span",{className:"review-panel__counter",children:[ie,"/",_]})]}),u.jsx("div",{className:"review-panel__divider"})]}),u.jsxs("div",{className:"review-panel__nav",children:[u.jsx("button",{className:"review-panel__btn",onClick:g,disabled:l.total===0,title:"Previous (k)",children:u.jsx(Q5,{})}),u.jsx("button",{className:"review-panel__btn",onClick:m,disabled:l.total===0,title:"Next (j)",children:u.jsx(Z5,{})}),u.jsxs("span",{className:"review-panel__counter",children:[f+1,"/",l.total]})]}),u.jsx("div",{className:"review-panel__divider"}),u.jsxs("div",{className:"review-panel__toggle",children:[u.jsx("button",{className:`review-panel__toggle-btn${D&&!E?" review-panel__toggle-btn--active":""}`,onClick:()=>D&&E&&U(),disabled:!D,title:"Show modified (o)",children:"Modified"}),u.jsx("button",{className:`review-panel__toggle-btn${D&&E?" review-panel__toggle-btn--active":""}`,onClick:()=>D&&!E&&U(),disabled:!D,title:"Show original (o)",children:"Original"})]}),u.jsx("div",{className:"review-panel__divider"}),u.jsxs("div",{className:"review-panel__actions",children:[u.jsx("button",{className:"review-panel__accept",onClick:W,title:"Accept (a)",children:u.jsx(cw,{})}),u.jsx("button",{className:"review-panel__reject",onClick:$,title:"Reject (r)",children:u.jsx(uw,{})}),u.jsxs("button",{className:"review-panel__accept-all",onClick:H,title:"Accept all (Shift+A)",children:[u.jsx(cw,{}),u.jsx("span",{children:"All"})]}),u.jsxs("button",{className:"review-panel__reject-all",onClick:J,title:"Reject all (Shift+R)",children:[u.jsx(uw,{}),u.jsx("span",{children:"All"})]})]})]})}function t8(t,e){return t.indexOf(e)}function pu(t){return t.type==="doc"?t.file:t.id}function Sl(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&Sl(n.items,e)}function c2(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=c2(s.items,e,n,r||i);if(o!==null)return o}}return null}function Ed(t,e){for(const n of t){const r=n.workspace;if(!r)continue;const s=r.autoAccept===!0;if(c2(r.root,e,s,!1)===!0)return!0}return!1}function ra(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 Ts(t){return/^[A-Z]:[/\\]|^\//.test(t)}function u2(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function n8(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 r8(t,e){const[n,r]=k.useState([]),[s,i]=k.useState([]),o=k.useRef(null),l=k.useRef(new Set),d=k.useCallback(g=>{l.current.add(g)},[]),f=k.useMemo(()=>{const g=new Set;for(const y of s)y.workspace&&Sl(y.workspace.root,g);return g},[s]),h=k.useCallback(()=>{fetch("/api/documents").then(g=>g.json()).then(g=>{if(!Array.isArray(g))return;const y=l.current;if(y.size>0){const x=new Set(g.map(w=>w.filename));for(const w of[...y])x.has(w)||y.delete(w)}const b=y.size>0?g.filter(x=>!y.has(x.filename)):g;r(b)}).catch(()=>{})},[]),m=k.useCallback(()=>{fetch("/api/workspaces").then(g=>g.json()).then(async g=>{if(!Array.isArray(g))return;const y=await Promise.all(g.map(async b=>{try{const w=await(await fetch(`/api/workspaces/${encodeURIComponent(b.filename)}`)).json();return{...b,workspace:w}}catch{return b}}));i(y)}).catch(()=>{})},[]);return k.useEffect(()=>{h()},[h,t]),k.useEffect(()=>{m()},[m,e]),k.useEffect(()=>{const g=requestAnimationFrame(()=>{var b;const y=(b=o.current)==null?void 0:b.querySelector(".sidebar-item.active");y==null||y.scrollIntoView({block:"nearest",behavior:"instant"})});return()=>cancelAnimationFrame(g)},[n]),{docs:n,setDocs:r,workspaces:s,setWorkspaces:i,assignedFiles:f,fetchDocs:h,fetchWorkspaces:m,scrollRef:o,markPendingDelete:d}}function Hg(t,e){return t.filter(n=>!e(n)).map(n=>n.type==="container"?{...n,items:Hg(n.items,e)}:n)}function d2(t,e,n){return t.map(r=>r.type==="container"&&r.id===e?{...r,name:n}:r.type==="container"?{...r,items:d2(r.items,e,n)}:r)}function s8(t,e,n,r,s,i){const o=k.useCallback(_=>{n(O=>O.filter(R=>R.filename!==_)),i==null||i(_),fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>t())},[n,t]),l=k.useCallback(_=>{n(O=>O.filter(R=>R.filename!==_)),fetch(`/api/documents/${encodeURIComponent(_)}/archive`,{method:"POST"}).catch(()=>t())},[n,t]),d=k.useCallback(_=>{n(O=>O.filter(R=>R.filename!==_)),fetch(`/api/documents/${encodeURIComponent(_)}/unarchive`,{method:"POST"}).catch(()=>t())},[n,t]),f=k.useCallback((_,O,R)=>{!R.trim()||R.trim()===O||(n(B=>B.map(D=>D.filename===_?{...D,title:R.trim()}:D)),fetch(`/api/documents/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:R.trim()})}).catch(()=>t()))},[n,t]),h=k.useCallback(_=>{r(O=>O.filter(R=>R.filename!==_)),fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"DELETE"}).catch(()=>e())},[r,e]),m=k.useCallback((_,O)=>{O.trim()&&(r(R=>R.map(B=>B.filename===_?{...B,title:O.trim()}:B)),fetch(`/api/workspaces/${encodeURIComponent(_)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:O.trim()})}).catch(()=>e()))},[r,e]),g=k.useCallback((_,O)=>{r(R=>R.map(B=>B.filename!==_||!B.workspace?B:{...B,docCount:Math.max(0,B.docCount-1),workspace:{...B.workspace,root:Hg(B.workspace.root,D=>D.type==="doc"&&D.file===O)}})),fetch(`/api/workspaces/${encodeURIComponent(_)}/docs/${encodeURIComponent(O)}`,{method:"DELETE"}).catch(()=>e())},[r,e]),y=k.useCallback((_,O,R=!1)=>{r(D=>D.map(U=>U.filename!==_||!U.workspace?U:{...U,workspace:{...U.workspace,root:Hg(U.workspace.root,Q=>Q.type==="container"&&Q.id===O)}}));const B=`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(O)}${R?"?cascade=true":""}`;fetch(B,{method:"DELETE"}).then(()=>{R&&t()}).catch(()=>e())},[r,e,t]),b=k.useCallback((_,O,R)=>{R.trim()&&(r(B=>B.map(D=>D.filename!==_||!D.workspace?D:{...D,workspace:{...D.workspace,root:d2(D.workspace.root,O,R.trim())}})),fetch(`/api/workspaces/${encodeURIComponent(_)}/containers/${encodeURIComponent(O)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R.trim()})}).catch(()=>e()))},[r,e]),x=k.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),w=k.useCallback((_,O,R)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R?{metadata:R}:{})}).then(B=>B.json()).then(B=>{if(B.filename)return fetch(`/api/workspaces/${encodeURIComponent(_)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:B.filename,title:B.title||"Untitled",containerId:O})})}).catch(()=>{})},[]),E=k.useCallback((_,O)=>{fetch(`/api/workspaces/${encodeURIComponent(_)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:O})}).catch(()=>{})},[]),C=k.useCallback(_=>{const O=s.find(R=>R.filename===_);return(O==null?void 0:O.tags)??[]},[s]),A=k.useCallback((_,O)=>{const R=O.trim();R&&(n(B=>B.map(D=>{if(D.filename!==_)return D;const U=D.tags??[];return U.includes(R)?D:{...D,tags:[...U,R]}})),fetch(`/api/doc-tags/${encodeURIComponent(_)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:R})}).catch(()=>{}))},[n]),T=k.useCallback((_,O)=>{n(R=>R.map(B=>{if(B.filename!==_)return B;const D=B.tags??[],U=D.filter(Q=>Q!==O);return U.length===D.length?B:U.length>0?{...B,tags:U}:{...B,tags:void 0}})),fetch(`/api/doc-tags/${encodeURIComponent(_)}/${encodeURIComponent(O)}`,{method:"DELETE"}).catch(()=>{})},[n]);return{fetchDocs:t,handleDelete:o,handleArchive:l,handleUnarchive:d,handleRename:f,handleCreateWorkspace:x,handleDeleteWorkspace:h,handleCreateInWorkspace:w,handleRemoveFromWorkspace:g,handleCreateContainer:E,handleDeleteContainer:y,handleRenameContainer:b,handleRenameWorkspace:m,getDocTags:C,handleAddTag:A,handleRemoveTag:T}}function f2({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,o]=k.useState(null),[l,d]=k.useState(null),f=k.useRef(null),h=k.useRef(null),m=k.useRef(null),g=k.useRef(null),y=k.useRef(null),b=5,x=(U,Q,P)=>P==="before"?Q>0?pu(U[Q-1]):null:pu(U[Q]),w=k.useCallback((U,Q)=>{if(Q===null){const $=t.filter(J=>!n.has(J.filename)).map(J=>({type:"doc",file:J.filename,title:J.title})),H=$.findIndex(J=>pu(J)===U);return H>=0?{siblings:$,index:H,containerId:null}:null}const P=e.find($=>$.filename===Q);if(!(P!=null&&P.workspace))return null;const W=($,H)=>{for(let J=0;J<$.length;J++){if(pu($[J])===U)return{siblings:$,index:J,containerId:H};if($[J].type==="container"){const re=W($[J].items,$[J].id);if(re)return re}}return null};return W(P.workspace.root,null)},[t,n,e]),E=k.useCallback(()=>{o(null),d(null),y.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=""},[]),C=k.useCallback((U,Q)=>{if(!U||!Q)return;if(U.type==="workspace"){const V=Q.itemId;if(V===U.filename)return;const ie=e.map(I=>I.filename),z=ie.indexOf(U.filename);if(z<0)return;ie.splice(z,1);let M=ie.indexOf(V);if(M<0)return;Q.position==="after"&&(M+=1),ie.splice(M,0,U.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:ie})}).catch(()=>{});return}const{wsFilename:P,containerId:W,afterId:$}=Q,H=U.type==="doc"?U.file:U.id,J=U.sourceWs;if(Q.itemId===H)return;if(U.type==="container"){if(P===null&&W===null&&Q.itemId!=="__section__"){const V=Q.itemId,ie=Q.position==="after"?V:(()=>{const z=e.findIndex(M=>M.filename===V);return z>0?e[z-1].filename:null})();fetch("/api/workspaces/promote-container",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:J,containerId:H,afterWorkspaceFilename:ie})}).catch(()=>{});return}if(J!==P&&P){fetch(`/api/workspaces/${encodeURIComponent(P)}/containers/${encodeURIComponent(H)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:J,targetContainerId:W??null,afterIdentifier:$})}).catch(()=>{});return}if(!P)return;fetch(`/api/workspaces/${encodeURIComponent(P)}/docs/${encodeURIComponent(H)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:W??null,afterFile:$})}).catch(()=>{});return}const re=U.file;if(J===null&&P===null){const V=t.filter(Z=>!n.has(Z.filename)).map(Z=>Z.filename),ie=V.indexOf(re);if(ie<0)return;V.splice(ie,1);let z=$?V.indexOf($):-1;z>=0?z+=1:z=0,V.splice(z,0,re);const M=[];let I=0;for(const Z of t)n.has(Z.filename)?M.push(Z.filename):M.push(V[I++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:M})}).catch(()=>{});return}if(J===null&&P!==null){fetch(`/api/workspaces/${encodeURIComponent(P)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:re,title:re.replace(/\.md$/,""),containerId:W??null,afterFile:$})}).catch(()=>{});return}if(J!==null&&P===null){fetch(`/api/workspaces/${encodeURIComponent(J)}/docs/${encodeURIComponent(re)}`,{method:"DELETE"}).catch(()=>{});return}if(J===P&&P!==null){fetch(`/api/workspaces/${encodeURIComponent(P)}/docs/${encodeURIComponent(re)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:W??null,afterFile:$})}).catch(()=>{});return}J!==null&&P!==null&&fetch(`/api/workspaces/${encodeURIComponent(P)}/docs/${encodeURIComponent(re)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:J,containerId:W??null,afterFile:$,title:re.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),A=k.useCallback((U,Q)=>{const P=m.current;P&&(P.style.display="none");const W=document.elementFromPoint(U,Q);if(P&&(P.style.display=""),!W)return null;if((i==null?void 0:i.type)==="workspace"||(i==null?void 0:i.type)==="container"){const Z=W.closest("[data-ws-drag]");if(Z){const le=Z.dataset.wsDrag,ge=Z.getBoundingClientRect(),se=(Q-ge.top)/ge.height;return{itemId:le,position:se<.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 Z=W.closest("[data-ws-drag]");if(Z)return{itemId:"__section__",position:"inside",wsFilename:Z.dataset.wsDrag,containerId:null,afterId:null}}const $=W.closest("[data-drag-id]");if(!$){const Z=W.closest("[data-drop-ws]");return Z?{itemId:"__section__",position:"inside",wsFilename:Z.dataset.dropWs==="__docs__"?null:Z.dataset.dropWs,containerId:Z.dataset.dropContainer||null,afterId:null}:null}const H=$.dataset.dragId,J=$.dataset.dragType,re=$.dataset.dragWs==="__docs__"?null:$.dataset.dragWs,V=$.getBoundingClientRect(),ie=(Q-V.top)/V.height;if(J==="container-header"){const Z=H,le=$.dataset.dragParent||null,ge=w(Z,re);if(!ge)return null;const se=(i==null?void 0:i.type)==="container"?.33:.25;return ie<se?{itemId:Z,position:"before",wsFilename:re,containerId:le,afterId:x(ge.siblings,ge.index,"before")}:ie>1-se?{itemId:Z,position:"after",wsFilename:re,containerId:le,afterId:x(ge.siblings,ge.index,"after")}:{itemId:Z,position:"inside",wsFilename:re,containerId:Z,afterId:null}}const z=$.dataset.dragContainer||null,M=w(H,re);if(!M)return null;const I=ie<.5?"before":"after";return{itemId:H,position:I,wsFilename:re,containerId:z,afterId:x(M.siblings,M.index,I)}},[w,i]),T=k.useCallback(U=>{const Q=r.current;if(!Q)return;const P=Q.getBoundingClientRect(),W=80,$=18;let H=0;if(U<P.top+W?H=-$*Math.max(0,1-(U-P.top)/W):U>P.bottom-W&&(H=$*Math.max(0,1-(P.bottom-U)/W)),h.current&&(cancelAnimationFrame(h.current),h.current=null),H!==0){const J=()=>{Q.scrollTop+=H,h.current=requestAnimationFrame(J)};h.current=requestAnimationFrame(J)}},[r]),_=k.useCallback((U,Q)=>{const P=m.current;P&&(P.style.display="none");const W=document.elementFromPoint(U,Q);P&&(P.style.display="");const $=W==null?void 0:W.closest("[data-section-key]");if(!$){f.current&&(clearTimeout(f.current),f.current=null);return}const H=$.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(J=>{if(!J.has(H))return J;const re=new Set(J);return re.delete(H),re})},500)},[s]);k.useEffect(()=>{if(!i)return;const U=P=>{m.current&&(m.current.style.left=`${P.clientX+12}px`,m.current.style.top=`${P.clientY-8}px`),d(A(P.clientX,P.clientY)),T(P.clientY),_(P.clientX,P.clientY)},Q=P=>{C(i,A(P.clientX,P.clientY)),E()};return window.addEventListener("pointermove",U),window.addEventListener("pointerup",Q),()=>{window.removeEventListener("pointermove",U),window.removeEventListener("pointerup",Q)}},[i,A,C,E,T,_]);const O=k.useCallback((U,Q,P)=>{if(U.button!==0||U.target.closest("input, button, .sidebar-tag-remove, .sidebar-tag-add, .sidebar-container-actions, .sidebar-delete-btn, .sidebar-confirm-delete, .sidebar-inline-confirm"))return;g.current={x:U.clientX,y:U.clientY},y.current=Q;const $=J=>{if(!g.current||!y.current)return;const re=J.clientX-g.current.x,V=J.clientY-g.current.y;if(Math.abs(re)+Math.abs(V)>=b){document.body.style.userSelect="none",window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",H),o(y.current),y.current=null;const ie=document.createElement("div");ie.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);",ie.textContent=P,document.body.appendChild(ie),m.current=ie,ie.style.left=`${J.clientX+12}px`,ie.style.top=`${J.clientY-8}px`}},H=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",H),g.current=null,y.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",$),window.addEventListener("pointerup",H)},[]);return{draggedItem:i,dropIndicator:l,handlePointerDown:O,dropClass:U=>!l||l.itemId!==U?"":l.position==="before"?"drop-before":l.position==="after"?"drop-after":l.position==="inside"?"drop-inside":"",isDragging:U=>i?i.type==="doc"?i.file===U:i.type==="workspace"?i.filename===U:i.id===U:!1,isContainerDropTarget:U=>!l||!i?!1:l.containerId===U}}function i8({items:t,onAction:e,menuRef:n}){const[r,s]=k.useState(null),i=k.useRef(null),o=k.useMemo(()=>{const h=new Map;for(const m of t){const g=m.pluginDisplayName||"_ungrouped",y=h.get(g)||[];y.push(m),h.set(g,y)}return h},[t]),[l,d]=k.useState({});k.useLayoutEffect(()=>{if(!r||!i.current||!n.current)return;const h=n.current.getBoundingClientRect(),m=i.current.getBoundingClientRect(),g=8;let y=h.right-4,b=i.current.offsetTop+h.top-4;y+m.width+g>window.innerWidth&&(y=h.left-m.width+4),b+m.height+g>window.innerHeight&&(b=window.innerHeight-m.height-g),b<g&&(b=g),d({position:"fixed",left:y,top:b})},[r,n]);const f=[];for(const[h,m]of o)if(h!=="_ungrouped"&&m.length>=3)f.push(u.jsxs("span",{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsxs("button",{className:"context-menu-item context-menu-submenu-trigger",onMouseEnter:()=>s(h),onClick:()=>s(r===h?null:h),children:[u.jsx("span",{children:"Transform"}),u.jsx("span",{className:"context-menu-submenu-arrow",children:"▸"})]}),r===h&&u.jsx("div",{ref:i,className:"context-menu context-menu-submenu",style:l,onMouseLeave:()=>s(null),children:m.map(g=>u.jsx("button",{className:"context-menu-item",onClick:()=>e(g),children:u.jsx("span",{children:g.label})},g.action))})]},`sub-${h}`));else{let g=!0;for(const y of m){const b=g&&h!=="_ungrouped";g=!1,f.push(u.jsxs("span",{children:[b&&u.jsx("div",{className:"context-menu-divider"}),b&&u.jsx("div",{className:"context-menu-section-header",children:h}),u.jsx("button",{className:"context-menu-item",onClick:()=>e(y),children:u.jsx("span",{children:y.label})})]},y.action))}}return u.jsx(u.Fragment,{children:f})}function Nd({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onRename:o,onArchive:l,onDelete:d,onPluginAction:f,pluginItems:h,onSchedulePost:m,onViewAnalytics:g,viewAnalyticsLabel:y,onMarkSent:b,isAlreadySent:x,isApproved:w,onToggleApprove:E,isAutoAccept:C,onToggleAutoAccept:A,folderMode:T,onNewDoc:_,onNewContainer:O,onAcceptAll:R,onRejectAll:B,folderAutoAccept:D,onToggleFolderAutoAccept:U,folderAutoAcceptLabel:Q,folderDocCount:P,onDeleteWithDocs:W,bulkCount:$,onBulkDelete:H}){const J=k.useRef(null),[re,V]=k.useState(!1),[ie,z]=k.useState(!1),[M,I]=k.useState({left:t,top:e});k.useLayoutEffect(()=>{const le=J.current;if(!le)return;const ge=le.getBoundingClientRect(),se=8;let xe=t,fe=e;e+ge.height+se>window.innerHeight&&(fe=e-ge.height),t+ge.width+se>window.innerWidth&&(xe=t-ge.width),fe<se&&(fe=se),xe<se&&(xe=se),I({left:xe,top:fe})},[t,e]),k.useEffect(()=>{const le=ge=>{J.current&&!J.current.contains(ge.target)&&s()};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[s]),k.useEffect(()=>{const le=ge=>{ge.key==="Escape"&&s()};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[s]);const Z=k.useCallback(le=>{f(le.action,le),s()},[f,s]);return $&&$>1&&H?u.jsxs("div",{ref:J,className:"context-menu",style:{left:M.left,top:M.top},children:[u.jsxs("div",{className:"context-menu-section-header",children:[$," selected"]}),re?u.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:le=>le.stopPropagation(),children:[u.jsxs("span",{children:["Delete ",$,"?"]}),u.jsx("button",{onClick:()=>{H(),s()},children:"Yes"}),u.jsx("button",{onClick:()=>V(!1),children:"No"})]}):u.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>V(!0),children:u.jsxs("span",{children:["Delete (",$,")"]})})]}):T?u.jsxs("div",{ref:J,className:"context-menu",style:{left:M.left,top:M.top},children:[u.jsx("button",{className:"context-menu-item",onClick:()=>{o(),s()},children:u.jsx("span",{children:"Rename"})}),_&&u.jsx("button",{className:"context-menu-item",onClick:le=>{_(le),s()},children:u.jsx("span",{children:"New Document"})}),O&&u.jsx("button",{className:"context-menu-item",onClick:()=>{O(),s()},children:u.jsx("span",{children:"New Container"})}),(R||B)&&u.jsx("div",{className:"context-menu-divider"}),R&&u.jsx("button",{className:"context-menu-item",onClick:()=>{R(),s()},children:u.jsx("span",{children:"Accept All Changes"})}),B&&u.jsx("button",{className:"context-menu-item",onClick:()=>{B(),s()},children:u.jsx("span",{children:"Reject All Changes"})}),U&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{U(),s()},children:u.jsx("span",{children:D?`Turn off auto-accept${Q?" "+Q:""}`:`Turn on auto-accept${Q?" "+Q:""}`})})]}),u.jsx("div",{className:"context-menu-divider"}),re?P&&P>0&&W?u.jsxs("div",{className:"sidebar-ctx-folder-delete",onClick:le=>le.stopPropagation(),children:[u.jsx("div",{className:"sidebar-ctx-folder-delete-prompt",children:"Delete this folder?"}),u.jsxs("button",{className:"context-menu-item sidebar-ctx-delete-option",onClick:()=>{d(),s()},children:[u.jsx("span",{children:"Folder only"}),u.jsxs("span",{className:"sidebar-ctx-delete-hint",children:[P," doc",P===1?"":"s"," → Documents"]})]}),u.jsxs("button",{className:"context-menu-item sidebar-ctx-delete-option sidebar-ctx-delete",onClick:()=>{W(),s()},children:[u.jsxs("span",{children:["Folder + ",P," doc",P===1?"":"s"]}),u.jsx("span",{className:"sidebar-ctx-delete-hint",children:"permanently deletes files"})]}),u.jsx("button",{className:"context-menu-item sidebar-ctx-delete-cancel",onClick:()=>V(!1),children:u.jsx("span",{children:"Cancel"})})]}):u.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:le=>le.stopPropagation(),children:[u.jsx("span",{children:"Delete?"}),u.jsx("button",{onClick:()=>{d(),s()},children:"Yes"}),u.jsx("button",{onClick:()=>V(!1),children:"No"})]}):u.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>V(!0),children:u.jsx("span",{children:"Delete"})})]}):u.jsxs("div",{ref:J,className:"context-menu",style:{left:M.left,top:M.top},children:[u.jsx("button",{className:"context-menu-item",onClick:()=>{i(),s()},children:u.jsx("span",{children:"Duplicate"})}),u.jsx("button",{className:"context-menu-item",onClick:()=>{o(),s()},children:u.jsx("span",{children:"Rename"})}),ie?u.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:le=>le.stopPropagation(),children:[u.jsx("span",{children:"Archive?"}),u.jsx("button",{onClick:()=>{l(),s()},children:"Yes"}),u.jsx("button",{onClick:()=>z(!1),children:"No"})]}):u.jsx("button",{className:"context-menu-item",onClick:()=>z(!0),children:u.jsx("span",{children:"Archive"})}),re?u.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:le=>le.stopPropagation(),children:[u.jsx("span",{children:Ts(n)?"Remove?":"Delete?"}),u.jsx("button",{onClick:()=>{d(),s()},children:"Yes"}),u.jsx("button",{onClick:()=>V(!1),children:"No"})]}):u.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>V(!0),children:u.jsx("span",{children:Ts(n)?"Remove":"Delete"})}),E&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{E(),s()},children:u.jsx("span",{children:w?"Remove Approval":"Approve"})})]}),A&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{A(),s()},children:u.jsx("span",{children:C?"Turn off auto-accept":"Turn on auto-accept"})})]}),m&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{m(),s()},children:u.jsx("span",{children:"Schedule Post"})})]}),b&&!x&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{b(),s()},children:u.jsx("span",{children:"Mark as Sent"})})]}),g&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"context-menu-divider"}),u.jsx("button",{className:"context-menu-item",onClick:()=>{g(),s()},children:u.jsx("span",{children:y||"View Analytics"})})]}),h.length>0&&u.jsx(i8,{items:h,onAction:Z,menuRef:J})]})}function h2({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=k.useState(""),o=k.useRef(null);k.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]),k.useEffect(()=>{const d=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[r]);const l=k.useCallback(()=>{n(s.trim())},[s,n]);return u.jsx("div",{className:"focus-modal-overlay",onClick:r,children:u.jsxs("div",{className:"focus-modal",onClick:d=>d.stopPropagation(),children:[u.jsxs("div",{className:"focus-modal-header",children:[u.jsx("h2",{children:t}),u.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),u.jsxs("div",{className:"focus-modal-body",children:[u.jsxs("label",{children:['Focus instructions for "',e,'"',u.jsx("textarea",{ref: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()}})]}),u.jsxs("div",{className:"focus-modal-hint",children:[s.length,"/500"]}),u.jsxs("div",{className:"focus-modal-actions",children:[u.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),u.jsx("button",{className:"focus-modal-btn primary",onClick:l,children:"Go"})]})]})]})})}function Np(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(u.jsx("mark",{children:t.slice(o,o+e.length)},o)),i=o+e.length}return n}function dw({r:t,query:e,onClick:n}){return u.jsxs("div",{className:`sidebar-item search-result-item ${t.isActive?"active":""} ${t.isArchived?"search-result-archived":""}`,onClick:n,children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-item-title-text",children:t.matchType==="title"?Np(t.title,e):t.title}),t.isArchived&&u.jsx("span",{className:"search-archived-badge",children:"archived"})]}),t.matchType==="tag"&&t.matchedTag&&u.jsxs("div",{className:"search-result-tag",children:["Tag: ",Np(t.matchedTag,e)]}),t.matchType==="content"&&t.snippet&&u.jsx("div",{className:"search-result-snippet",children:Np(t.snippet,e)}),u.jsxs("div",{className:"sidebar-item-meta",children:[t.wordCount.toLocaleString()," words · ",ra(t.lastModified)]})]})}function Wd({results:t,query:e,onSwitchDocument:n,actions:r}){if(t.length===0)return u.jsx("div",{className:"sidebar-scroll",children:u.jsxs("div",{className:"search-empty",children:['No results for "',e,'"']})});const s=t.filter(o=>!o.isArchived),i=t.filter(o=>o.isArchived);return u.jsx("div",{className:"sidebar-scroll",children:u.jsxs("div",{className:"search-results",children:[s.map(o=>u.jsx(dw,{r:o,query:e,onClick:()=>n(o.filename)},o.filename)),i.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"search-archived-divider",children:u.jsx("span",{children:"Archived"})}),i.map(o=>u.jsx(dw,{r:o,query:e,onClick:()=>r.handleUnarchive(o.filename)},o.filename))]})]})})}async function Cp(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();return(i=(s=r.content)==null?void 0:s[0])!=null&&i.text?JSON.parse(r.content[0].text):r}function _p(t,e){return e?(t/e*100).toFixed(1)+"%":"0%"}function fw(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function hw(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 p2({docId:t,title:e,onClose:n}){const[r,s]=k.useState("loading"),[i,o]=k.useState([]),[l,d]=k.useState(""),[f,h]=k.useState(null),[m,g]=k.useState(null),[y,b]=k.useState("links"),[x,w]=k.useState("all"),[E,C]=k.useState(!1),[A,T]=k.useState(!1),[_,O]=k.useState(""),[R,B]=k.useState(!1),[D,U]=k.useState(null),Q=k.useRef(null);k.useEffect(()=>{let se=!1;return(async()=>{try{const xe=await Cp("list_newsletter_issues",{limit:20});if(se)return;if(!xe.issues||xe.issues.length===0){s("no-data");return}o(xe.issues);const fe=xe.issues[0].id;d(fe)}catch(xe){se||(g(xe.message),s("error"))}})(),()=>{se=!0}},[]),k.useEffect(()=>{if(!l)return;let se=!1;return C(!0),T(!1),U(null),O(""),(async()=>{try{const xe=await Cp("get_newsletter_analytics",{issue_id:l});if(se)return;if(xe.error){g(xe.error),s("error");return}h(xe),s("loaded")}catch(xe){se||(g(xe.message),s("error"))}finally{se||C(!1)}})(),()=>{se=!0}},[l]),k.useEffect(()=>{const se=xe=>{Q.current&&!Q.current.contains(xe.target)&&n()};return document.addEventListener("mousedown",se),()=>document.removeEventListener("mousedown",se)},[n]),k.useEffect(()=>{const se=xe=>{xe.key==="Escape"&&n()};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[n]);const P=f?a8(f.subscriber_events):[],W=(f==null?void 0:f.issue.recipient_count)??0,$=f?f.stats.delivered||W-f.stats.bounces:0,H=f?new Set(f.subscriber_events.filter(se=>{var xe;return se.event_type==="click"&&((xe=se.url)==null?void 0:xe.includes("/newsletter/unsubscribe/"))}).map(se=>se.email)).size:0,J=f?f.stats.unsubscribes||H:0,re=f?f.subscriber_events.filter(se=>se.event_type==="dropped").length:0,V=f?Math.max(0,W-f.stats.unique_opens):0,ie=f!=null&&f.issue.sent_at?Date.now()-new Date(f.issue.sent_at).getTime():0,z=Math.floor(ie/36e5),M=!!(f!=null&&f.issue.resent_at||D),I=se=>{const xe=Math.floor(se/36e5);return xe<1?"just now":xe<24?`${xe}h ago`:`${Math.floor(xe/24)}d ${xe%24}h ago`},Z=async()=>{if(!(!_.trim()||R)){B(!0);try{const se=await Cp("resend_to_unopened",{issue_id:l,subject:_});se.error?(g(se.error),s("error")):(U({sent:se.sent,failed:se.failed}),T(!1))}catch(se){g(se.message),s("error")}finally{B(!1)}}},le=se=>{var xe;return se.event_type==="unsubscribe"||se.event_type==="click"&&!!((xe=se.url)!=null&&xe.includes("/newsletter/unsubscribe/"))},ge=f?o8(f.subscriber_events.filter(se=>x==="all"?!0:x==="unsubscribe"?le(se):se.event_type===x)):[];return u.jsx("div",{className:"newsletter-modal-overlay",children:u.jsxs("div",{className:"na-modal",ref:Q,children:[u.jsxs("div",{className:"na-header",children:[u.jsx("h3",{children:"Newsletter Analytics"}),u.jsx("button",{className:"newsletter-modal__close",onClick:n,children:"×"})]}),r==="loading"&&!f&&u.jsx("div",{className:"na-body",children:u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:"Loading analytics..."})]})}),r==="no-data"&&u.jsxs("div",{className:"na-body",children:[u.jsx("div",{className:"newsletter-modal__status",children:u.jsx("span",{children:"No newsletter sends found yet."})}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="error"&&u.jsxs("div",{className:"na-body",children:[u.jsx("div",{className:"newsletter-modal__error",children:m}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="loaded"&&f&&u.jsxs("div",{className:"na-body",children:[i.length>1&&u.jsx("select",{className:"newsletter-modal__select na-issue-select",value:l,onChange:se=>d(se.target.value),children:i.map(se=>u.jsxs("option",{value:se.id,children:[se.subject," — ",fw(se.sent_at)]},se.id))}),E?u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:"Loading..."})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"na-kpi-row",children:[u.jsxs("div",{className:"na-kpi",children:[u.jsx("div",{className:"na-kpi__value",children:$.toLocaleString()}),u.jsx("div",{className:"na-kpi__label",children:"Delivered"}),u.jsxs("div",{className:"na-kpi__sub",children:[W.toLocaleString()," sent"]})]}),u.jsxs("div",{className:"na-kpi",children:[u.jsx("div",{className:"na-kpi__value",children:_p(f.stats.unique_opens,$)}),u.jsx("div",{className:"na-kpi__label",children:"Open rate"}),u.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_opens.toLocaleString()," opens"]})]}),u.jsxs("div",{className:"na-kpi",children:[u.jsx("div",{className:"na-kpi__value",children:_p(f.stats.unique_clicks,$)}),u.jsx("div",{className:"na-kpi__label",children:"Click rate"}),u.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_clicks.toLocaleString()," clicks"]})]})]}),u.jsxs("div",{className:"na-kpi-row na-kpi-row--secondary",children:[u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:f.stats.bounces}),u.jsx("span",{className:"na-kpi__label--sm",children:"Bounces"})]}),u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:J}),u.jsx("span",{className:"na-kpi__label--sm",children:"Unsubs"})]}),u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:re}),u.jsx("span",{className:"na-kpi__label--sm",children:"Dropped"})]}),f.stats.complaints>0&&u.jsxs("div",{className:"na-kpi na-kpi--sm",children:[u.jsx("span",{className:"na-kpi__value--sm",children:f.stats.complaints}),u.jsx("span",{className:"na-kpi__label--sm",children:"Spam"})]})]}),V>0&&!M&&u.jsx("div",{className:"na-resend",children:A?u.jsxs("div",{className:"na-resend-panel",children:[u.jsxs("div",{className:"na-resend-label-row",children:[u.jsx("span",{className:"na-resend-label",children:"New subject line"}),u.jsxs("span",{className:"na-resend-meta",children:["sent ",I(ie),z<48?" · consider waiting 48h":""]})]}),u.jsx("input",{className:"na-resend-input",type:"text",value:_,onChange:se=>O(se.target.value),placeholder:"Try a different angle"}),u.jsxs("div",{className:"na-resend-actions",children:[u.jsx("button",{className:"na-resend-cancel",onClick:()=>T(!1),children:"Cancel"}),u.jsx("button",{className:"na-resend-send",onClick:Z,disabled:R||!_.trim(),children:R?"Sending...":`Send to ${V.toLocaleString()}`})]})]}):u.jsxs("button",{className:"na-resend-toggle",onClick:()=>{T(!0),O(f.issue.subject)},children:["Resend to ",V.toLocaleString()," non-openers ",u.jsx("span",{style:{float:"right"},children:"›"})]})}),M&&u.jsxs("div",{className:"na-resend-done",children:["Resent ",f.issue.resent_at?I(Date.now()-new Date(f.issue.resent_at).getTime()):"just now",D?` — ${D.sent} sent`:"",f.issue.resend_subject?` — "${f.issue.resend_subject}"`:""]}),u.jsxs("div",{className:"na-tabs",children:[u.jsxs("button",{className:`na-tab${y==="links"?" active":""}`,onClick:()=>b("links"),children:["Links (",P.length,")"]}),u.jsxs("button",{className:`na-tab${y==="activity"?" active":""}`,onClick:()=>b("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),y==="links"&&u.jsx("div",{className:"na-table-wrap",children:P.length===0?u.jsx("div",{className:"na-empty",children:"No link clicks recorded yet."}):u.jsxs("table",{className:"na-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"Link"}),u.jsx("th",{children:"Unique"}),u.jsx("th",{children:"Total"}),u.jsx("th",{children:"CTR"})]})}),u.jsx("tbody",{children:P.map(se=>u.jsxs("tr",{children:[u.jsx("td",{className:"na-table__url",title:se.url,children:u.jsx("a",{href:se.url,target:"_blank",rel:"noopener noreferrer",children:hw(se.url)})}),u.jsx("td",{children:se.uniqueClicks}),u.jsx("td",{children:se.totalClicks}),u.jsx("td",{children:_p(se.uniqueClicks,$)})]},se.url))})]})}),y==="activity"&&u.jsxs("div",{className:"na-activity",children:[u.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(se=>u.jsx("button",{className:`na-filter-btn${x===se?" active":""}`,onClick:()=>w(se),children:se==="all"?"All":se.charAt(0).toUpperCase()+se.slice(1)+"s"},se))}),u.jsxs("div",{className:"na-table-wrap",children:[ge.length===0?u.jsxs("div",{className:"na-empty",children:["No ",x==="all"?"":x+" ","events recorded."]}):u.jsxs("table",{className:"na-table",children:[u.jsx("thead",{children:u.jsxs("tr",{children:[u.jsx("th",{children:"Email"}),u.jsx("th",{children:"Event"}),u.jsx("th",{children:"Detail"}),u.jsx("th",{children:"Time"})]})}),u.jsx("tbody",{children:ge.slice(0,100).map(se=>u.jsxs("tr",{children:[u.jsx("td",{className:"na-table__email",children:se.email}),u.jsxs("td",{children:[u.jsx("span",{className:`na-badge na-badge--${se.event_type}`,children:se.event_type}),se.count>1&&u.jsxs("span",{className:"na-count",children:[se.count,"x"]})]}),u.jsx("td",{className:"na-table__url",children:se.url?u.jsx("a",{href:se.url,target:"_blank",rel:"noopener noreferrer",children:hw(se.url,35)}):"—"}),u.jsx("td",{className:"na-table__time",children:fw(se.latestTimestamp)})]},se.key))})]}),ge.length>100&&u.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",ge.length," events"]})]})]})]})]})]})})}function o8(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 a8(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 l8(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function jl({filename:t,title:e,onClose:n}){const[r,s]=k.useState("queue"),[i,o]=k.useState(null),[l,d]=k.useState(null),[f,h]=k.useState(""),[m,g]=k.useState(!1),[y,b]=k.useState(null),[x,w]=k.useState(null);k.useEffect(()=>{fetch(`/api/documents/${encodeURIComponent(t)}/text`).then(A=>{if(!A.ok)throw new Error("Failed to load document");return A.json()}).then(A=>{d(A.text||""),o(l8(A.meta||{}))}).catch(A=>w(A.message))},[t]);const E=async()=>{var A;if(!(!l||!i)){g(!0);try{const T={content:l,content_type:i,mode:r};r==="custom"&&f&&(T.scheduled_at=new Date(f).toISOString());const _=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T)}),O=await _.json();if(_.ok){const R=(A=O.item)!=null&&A.scheduled_at?new Date(O.item.scheduled_at).toLocaleString():"now";b({success:!0,message:`Scheduled for ${R}`})}else b({success:!1,message:O.error||"Failed to schedule"})}catch(T){b({success:!1,message:T.message})}finally{g(!1)}}},C=i===null&&!x;return u.jsx("div",{className:"schedule-post-overlay",onClick:n,children:u.jsxs("div",{className:"schedule-post-modal",onClick:A=>A.stopPropagation(),children:[u.jsxs("div",{className:"schedule-post-modal-header",children:[u.jsx("h3",{children:"Schedule Post"}),u.jsx("button",{className:"schedule-post-modal-close",onClick:n,children:"×"})]}),u.jsx("div",{className:"schedule-post-modal-doc",children:e}),x?u.jsxs("div",{className:"schedule-post-modal-result error",children:[x,u.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):y?u.jsxs("div",{className:`schedule-post-modal-result ${y.success?"success":"error"}`,children:[y.message,u.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"schedule-post-modal-field",children:[u.jsx("label",{children:"Content Type"}),u.jsx("div",{className:"schedule-post-modal-type",children:C?"...":i})]}),u.jsxs("div",{className:"schedule-post-modal-field",children:[u.jsx("label",{children:"Mode"}),u.jsxs("div",{className:"schedule-post-modal-modes",children:[u.jsx("button",{className:`schedule-post-mode ${r==="queue"?"active":""}`,onClick:()=>s("queue"),children:"Queue Next"}),u.jsx("button",{className:`schedule-post-mode ${r==="now"?"active":""}`,onClick:()=>s("now"),children:"Post Now"}),u.jsx("button",{className:`schedule-post-mode ${r==="custom"?"active":""}`,onClick:()=>s("custom"),children:"Custom Time"})]})]}),r==="custom"&&u.jsxs("div",{className:"schedule-post-modal-field",children:[u.jsx("label",{children:"Date & Time"}),u.jsx("input",{type:"datetime-local",value:f,onChange:A=>h(A.target.value)})]}),u.jsxs("div",{className:"schedule-post-modal-actions",children:[u.jsx("button",{className:"schedule-post-modal-cancel",onClick:n,children:"Cancel"}),u.jsx("button",{className:"schedule-post-modal-submit",onClick:E,disabled:m||C||r==="custom"&&!f,children:m?"Scheduling...":r==="now"?"Post Now":"Schedule"})]})]})]})})}const pw=[{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 m2({anchorRect:t,onSelect:e,onClose:n}){const r=k.useRef(null),[s,i]=k.useState(null),[o,l]=k.useState(""),d=k.useRef(null),[f,h]=k.useState({left:t.left,top:t.bottom+4});k.useLayoutEffect(()=>{const b=r.current;if(!b)return;const x=b.getBoundingClientRect(),w=8;let E=t.left,C=t.bottom+4;C+x.height+w>window.innerHeight&&(C=t.top-x.height-4),E+x.width+w>window.innerWidth&&(E=t.right-x.width),C<w&&(C=w),E<w&&(E=w),h({left:E,top:C})},[t]),k.useEffect(()=>{const b=x=>{r.current&&!r.current.contains(x.target)&&n()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]),k.useEffect(()=>{const b=x=>{x.key==="Escape"&&n()};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[n]),k.useEffect(()=>{s&&setTimeout(()=>{var b;return(b=d.current)==null?void 0:b.focus()},0)},[s]);const m=b=>{if(b.needsUrl){i(b.key),l("");return}e(b.metadata)},g=()=>{if(!s||!o.trim())return;const b=o.trim();if(!b.includes("x.com")&&!b.includes("twitter.com"))return;const x=pw.find(E=>E.key===s);if(!(x!=null&&x.metadata))return;const w=JSON.parse(JSON.stringify(x.metadata));w.tweetContext&&(w.tweetContext.url=b),e(w)},y=o.trim().includes("x.com")||o.trim().includes("twitter.com");return u.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:pw.map(b=>u.jsxs("div",{children:[u.jsx("button",{className:`create-doc-dropdown-item${s===b.key?" active":""}`,onClick:()=>m(b),children:b.label}),s===b.key&&u.jsxs("div",{className:"create-doc-dropdown-url",children:[u.jsx("input",{ref:d,type:"text",placeholder:b.urlPlaceholder,value:o,onChange:x=>l(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),g()),x.key==="Escape"&&(i(null),l(""))}}),u.jsx("button",{onClick:g,disabled:!y,children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},b.key))})}const c8=[{id:"full",label:"Full"},{id:"compact",label:"Compact"},{id:"minimal",label:"Minimal"}];function g2(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=g2(n.items,e);if(r)return[n.id,...r]}}return null}function u8({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:y,onSearchChange:b}){const x=q=>!!m&&m.has(q),[w,E]=k.useState(null),[C,A]=k.useState(""),[T,_]=k.useState(null),[O,R]=k.useState(()=>{try{const q=localStorage.getItem("ow-collapsed-sections");return q?new Set(JSON.parse(q)):new Set}catch{return new Set}}),[B,D]=k.useState(null),[U,Q]=k.useState(null),[P,W]=k.useState(""),[$,H]=k.useState(null),[J,re]=k.useState(""),[V,ie]=k.useState(null),[z,M]=k.useState(""),[I,Z]=k.useState(null),[le,ge]=k.useState(null),[se,xe]=k.useState([]),[fe,De]=k.useState(null),[We,Qe]=k.useState(null),[ot,st]=k.useState(null),[Ie,dt]=k.useState(null),[Ge,bt]=k.useState(null),[xt,$t]=k.useState(pE),Ke=k.useRef(null);k.useEffect(()=>{if(!Ge)return;const q=L=>{Ke.current&&!Ke.current.contains(L.target)&&bt(null)};return document.addEventListener("mousedown",q),()=>document.removeEventListener("mousedown",q)},[Ge]);const pt=q=>{$t(q),GM(q),bt(null)},Ft=q=>{q.preventDefault(),bt({x:q.clientX,y:q.clientY})},Je=k.useCallback((q,L)=>{fetch("/api/documents/batch-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:q,action:L})}).catch(()=>{})},[]),{draggedItem:Y,dropIndicator:pe,handlePointerDown:G,dropClass:oe,isDragging:ue,isContainerDropTarget:Fe}=f2({docs:t,workspaces:n,assignedFiles:r,scrollRef:d,setCollapsedSections:R}),Me=k.useCallback(()=>{fetch("/api/plugins").then(q=>q.json()).then(q=>{const L=[];for(const te of q.plugins||[]){const ve=te.displayName||void 0;for(const Ue of te.sidebarMenuItems||[])L.push({...Ue,pluginDisplayName:ve})}xe(L)}).catch(()=>{})},[]);k.useEffect(()=>{Me()},[Me]),k.useEffect(()=>{const q=()=>Me();return window.addEventListener("ow-plugins-changed",q),()=>window.removeEventListener("ow-plugins-changed",q)},[Me]);const{variantsByMaster:K,variantFilenames:me}=k.useMemo(()=>{const q=new Map,L=new Set;for(const te of t)if(te.masterDocId){const ve=q.get(te.masterDocId)||[];ve.push(te),q.set(te.masterDocId,ve),L.add(te.filename)}return{variantsByMaster:q,variantFilenames:L}},[t]),ye=k.useCallback((q,L)=>{q.preventDefault(),q.stopPropagation(),Z({x:q.clientX,y:q.clientY,filename:L.filename,title:L.title,docId:L.docId,lastSent:L.lastSent,postedUrl:L.postedUrl,isNewsletter:L.isNewsletter})},[]),Ce=k.useCallback(q=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:q})}).catch(()=>{})},[]),Re=k.useCallback((q,L,te,ve,Ue)=>{if(L.promptForFocus&&Ue===void 0){De({action:q,label:L.label,filename:te,title:ve});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:q,filename:te,title:ve,instructions:Ue||"",label:L.label})}).catch(()=>{})},[]),Be=q=>{R(L=>{const te=new Set(L);return te.has(q)?te.delete(q):te.add(q),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...te])),te})},Ee=t.find(q=>q.isActive),et=k.useRef(n);if(et.current=n,k.useEffect(()=>{var q;if(Ee)for(const L of et.current){const te=g2(((q=L.workspace)==null?void 0:q.root)||[],Ee.filename);if(te){R(ve=>{const Ue=[L.filename,...te.map(Ae=>`container-${Ae}`)];if(Ue.every(Ae=>!ve.has(Ae)))return ve;const lt=new Set(ve);for(const Ae of Ue)lt.delete(Ae);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...lt])),lt});break}}},[Ee==null?void 0:Ee.filename]),y!==null)return u.jsx(Wd,{results:y,query:g,onSwitchDocument:i,actions:l});const gt=t.filter(q=>!r.has(q.filename)&&!me.has(q.filename)),Tt=(q,L,te,ve,Ue,lt=!1)=>u.jsxs("div",{className:`sidebar-item ${q.isActive?"active":""} ${ue(q.filename)?"dragging":""} ${oe(q.filename)}`,"data-drag-id":q.filename,"data-drag-type":"doc","data-drag-ws":L||"__docs__","data-drag-container":te||"",onPointerDown:Ae=>G(Ae,{type:"doc",file:q.filename,sourceWs:L||null},q.title),onClick:()=>!q.isActive&&!Y&&i(q.filename),onDoubleClick:()=>{E(q.filename),A(q.title)},onContextMenu:Ae=>ye(Ae,q),children:[w===q.filename?u.jsx("input",{className:"sidebar-rename-input",value:C,onChange:Ae=>A(Ae.target.value),onBlur:()=>{l.handleRename(q.filename,q.title,C),E(null)},onKeyDown:Ae=>{Ae.key==="Enter"&&(l.handleRename(q.filename,q.title,C),E(null)),Ae.key==="Escape"&&E(null)},autoFocus:!0,onClick:Ae=>Ae.stopPropagation()}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-item-title-text",children:q.title}),q.variantType&&u.jsx("span",{className:"files-badge-variant",children:q.variantType}),l.getDocTags(q.filename).includes("✓")&&u.jsx("svg",{className:"sidebar-approved-icon",title:"Approved",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),q.lastSent&&u.jsx("svg",{className:"sidebar-sent-icon",title:"Sent",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),(q.autoAccept===!0||q.autoAccept!==!1&<)&&u.jsx("span",{className:"sidebar-auto-accept-dot",title:q.autoAccept===!0?"Auto-accept on":"Auto-accept inherited"}),s.filenames.includes(q.filename)&&u.jsx("span",{className:"sidebar-pending-dot"})]}),Ts(q.filename)&&u.jsx("div",{className:"sidebar-item-context",children:u2(q.filename)}),u.jsxs("div",{className:"sidebar-item-meta",children:[q.wordCount.toLocaleString()," words · ",ra(q.lastModified)]}),u.jsxs("div",{className:"sidebar-tags",children:[l.getDocTags(q.filename).filter(Ae=>Ae!=="✓").map(Ae=>u.jsxs("span",{className:"sidebar-tag",onClick:de=>de.stopPropagation(),children:[Ae,u.jsx("span",{className:"sidebar-tag-remove",onClick:de=>{de.stopPropagation(),l.handleRemoveTag(q.filename,Ae)},children:"×"})]},Ae)),V===q.filename?u.jsx("input",{className:"sidebar-tag-input",value:z,onChange:Ae=>M(Ae.target.value),onBlur:()=>{z.trim()&&l.handleAddTag(q.filename,z),ie(null)},onKeyDown:Ae=>{Ae.key==="Enter"&&(l.handleAddTag(q.filename,z),ie(null),M("")),Ae.key==="Escape"&&(ie(null),M(""))},autoFocus:!0,onClick:Ae=>Ae.stopPropagation(),placeholder:"tag..."}):u.jsx("button",{className:"sidebar-tag-add",onClick:Ae=>{Ae.stopPropagation(),ie(q.filename),M("")},children:"+"})]})]}),T===q.filename?u.jsxs("div",{className:"sidebar-confirm-delete",onClick:Ae=>Ae.stopPropagation(),children:[u.jsx("span",{children:Ts(q.filename)?"Remove?":"Delete?"}),u.jsx("button",{onClick:()=>{l.handleDelete(q.filename),_(null)},children:"Yes"}),u.jsx("button",{onClick:()=>_(null),children:"No"})]}):u.jsx("button",{className:"sidebar-delete-btn",onClick:Ae=>{Ae.stopPropagation(),_(q.filename)},title:Ts(q.filename)?"Remove document":"Delete document",children:"×"})]},q.filename),Jt=(q,L,te,ve,Ue,lt=!1)=>{const Ae=q.docId?K.get(q.docId):void 0,de=f&&(h==null?void 0:h.parentDocId)&&h.parentDocId===q.docId;if(!(Ae&&Ae.length>0||de))return Tt(q,L,te,ve,Ue,lt);const ze=`variants-${q.docId}`,Wt=!O.has(ze);return u.jsxs("div",{className:"sidebar-variant-group",children:[u.jsxs("div",{className:"sidebar-variant-master",onClick:wt=>{wt.target.closest(".sidebar-variant-chevron")&&(wt.stopPropagation(),Be(ze))},children:[Tt(q,L,te,ve,Ue,lt),u.jsx("span",{className:`sidebar-variant-chevron${Wt?"":" collapsed"}`,children:u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),Wt&&u.jsxs("div",{className:"sidebar-variant-children",children:[Ae==null?void 0:Ae.map((wt,an)=>Tt(wt,L,te,ve,an,lt)),de&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]})]})]},`vg-${q.filename}`)},Mt=(q,L,te,ve,Ue,lt,Ae=!1)=>{if(q.type==="doc"){const ft=t.find(En=>En.filename===q.file);return ft?me.has(ft.filename)?u.jsx(u.Fragment,{}):Jt(ft,te,ve,Ue,lt,Ae):Ts(q.file)?u.jsx("div",{className:"sidebar-item sidebar-unavailable",children:u.jsxs("div",{className:"sidebar-item-title",children:[q.title||q.file," (unavailable)"]})},q.file):u.jsxs("div",{className:"sidebar-item sidebar-missing",children:[u.jsxs("div",{className:"sidebar-item-title",children:[q.title||q.file," (missing)"]}),u.jsx("button",{className:"sidebar-delete-btn",onClick:()=>l.handleRemoveFromWorkspace(te,q.file),title:"Remove",children:"×"})]},q.file)}const de=q,_e=`container-${de.id}`,ze=O.has(_e),Wt=L<=2?`depth-${L}`:"depth-2",wt=de.autoAccept===!0,an=wt||Ae;return u.jsxs("div",{className:`sidebar-container ${Wt} ${ze?"collapsed":""} ${oe(de.id)} ${Fe(de.id)?"drop-inside":""}`,children:[u.jsxs("div",{className:`sidebar-container-header ${(pe==null?void 0:pe.itemId)===de.id&&pe.position==="inside"?"drop-inside":""}`,"data-drag-id":de.id,"data-drag-type":"container-header","data-drag-ws":te,"data-drag-parent":ve||"","data-section-key":_e,onPointerDown:ft=>G(ft,{type:"container",id:de.id,sourceWs:te},de.name),onClick:()=>!Y&&Be(_e),onContextMenu:ft=>{ft.preventDefault(),ft.stopPropagation(),dt({x:ft.clientX,y:ft.clientY,type:"container",wsFilename:te,containerId:de.id,title:de.name,nodes:de.items,autoAccept:wt})},children:[u.jsx("span",{className:`sidebar-chevron ${ze?"collapsed":""}`,children:"▾"}),U===de.id?u.jsx("input",{className:"sidebar-rename-input",value:P,onChange:ft=>W(ft.target.value),onBlur:()=>{l.handleRenameContainer(te,de.id,P),Q(null)},onKeyDown:ft=>{ft.key==="Enter"&&(l.handleRenameContainer(te,de.id,P),Q(null)),ft.key==="Escape"&&Q(null)},autoFocus:!0,onClick:ft=>ft.stopPropagation()}):u.jsx("span",{className:"sidebar-container-name",onDoubleClick:ft=>{ft.stopPropagation(),Q(de.id),W(de.name)},children:de.name}),an&&u.jsx("span",{className:"sidebar-auto-accept-dot",title:wt?"Auto-accept on for this container":"Auto-accept inherited from workspace"}),u.jsxs("div",{className:"sidebar-container-actions",children:[u.jsx("button",{className:"sidebar-new-btn",onClick:ft=>{ft.stopPropagation(),st({anchor:ft.target.getBoundingClientRect(),wsFilename:te,containerId:de.id})},title:"New doc",children:"+"}),L<2&&u.jsx("button",{className:"sidebar-new-btn",onClick:ft=>{ft.stopPropagation(),l.handleCreateContainer(te,de.id)},title:"New sub-container",children:"☐"}),u.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:ft=>{ft.stopPropagation(),l.handleDeleteContainer(te,de.id)},title:"Delete container",children:"×"})]})]}),!ze&&u.jsxs("div",{className:"sidebar-container-list","data-drop-ws":te,"data-drop-container":de.id,children:[f&&!(h!=null&&h.parentDocId)&&(h==null?void 0:h.wsFilename)===te&&h.containerId===de.id&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),de.items.filter(ft=>ft.type!=="doc"?!0:!(x(ft.file)||f&&(h==null?void 0:h.wsFilename)===te&&h.containerId===de.id&&ft.title===f)).map((ft,En)=>Mt(ft,L+1,te,de.id,de.items,En,an)),de.items.length===0&&!f&&u.jsx("div",{className:"sidebar-empty",children:Y?"Drop here":"Empty"})]})]},de.id)};return u.jsxs("div",{className:"sidebar-scroll",ref:d,children:[u.jsxs("div",{className:`sidebar-section sidebar-docs-section ${O.has("docs")?"docs-collapsed":""}`,children:[u.jsxs("div",{className:"sidebar-section-header","data-section-key":"docs",onClick:()=>Be("docs"),onContextMenu:Ft,children:[u.jsx("span",{className:`sidebar-chevron ${O.has("docs")?"collapsed":""}`,children:"▾"}),u.jsx("span",{className:"sidebar-label",children:"Documents"}),u.jsx("button",{className:"sidebar-new-btn",onClick:q=>{q.stopPropagation(),st({anchor:q.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!O.has("docs")&&u.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&!(h!=null&&h.parentDocId)&&(!h||!n.some(q=>q.filename===(h==null?void 0:h.wsFilename)))&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),gt.filter(q=>!x(q.filename)&&(!f||q.title!==f)).map((q,L)=>{const te=gt.map(ve=>({type:"doc",file:ve.filename,title:ve.title}));return Jt(q,void 0,null,te,L)}),gt.length===0&&u.jsx("div",{className:"sidebar-empty",children:Y?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(q=>{var Ue,lt,Ae;const L=((Ue=q.workspace)==null?void 0:Ue.root)||[],te=O.has(q.filename),ve=((lt=q.workspace)==null?void 0:lt.autoAccept)===!0||q.autoAccept===!0;return u.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${te?"ws-collapsed":""} ${ue(q.filename)?"dragging":""} ${(pe==null?void 0:pe.itemId)===q.filename?pe.position==="before"?"drop-before":"drop-after":""}`,children:[u.jsxs("div",{className:"sidebar-section-header","data-section-key":q.filename,"data-ws-drag":q.filename,onPointerDown:de=>G(de,{type:"workspace",filename:q.filename},q.title),onClick:()=>!Y&&Be(q.filename),onContextMenu:de=>{var _e;de.preventDefault(),de.stopPropagation(),dt({x:de.clientX,y:de.clientY,type:"workspace",wsFilename:q.filename,title:q.title,nodes:L,autoAccept:((_e=q.workspace)==null?void 0:_e.autoAccept)===!0||q.autoAccept===!0})},children:[u.jsx("span",{className:`sidebar-chevron ${te?"collapsed":""}`,children:"▾"}),$===q.filename?u.jsx("input",{className:"sidebar-rename-input",value:J,onChange:de=>re(de.target.value),onBlur:()=>{l.handleRenameWorkspace(q.filename,J),H(null)},onKeyDown:de=>{de.key==="Enter"&&(l.handleRenameWorkspace(q.filename,J),H(null)),de.key==="Escape"&&H(null)},autoFocus:!0,onClick:de=>de.stopPropagation()}):u.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:de=>{de.stopPropagation(),H(q.filename),re(q.title)},children:q.title}),(((Ae=q.workspace)==null?void 0:Ae.autoAccept)===!0||q.autoAccept===!0)&&u.jsx("span",{className:"sidebar-auto-accept-dot",title:"Auto-accept on for this workspace"}),u.jsxs("div",{className:"sidebar-workspace-actions",children:[u.jsx("button",{className:"sidebar-new-btn",onClick:de=>{de.stopPropagation(),st({anchor:de.target.getBoundingClientRect(),wsFilename:q.filename,containerId:null})},title:"New document",children:"+"}),u.jsx("button",{className:"sidebar-new-btn",onClick:de=>{de.stopPropagation(),l.handleCreateContainer(q.filename,null)},title:"New container",children:"☐"}),B===q.filename?u.jsxs("span",{className:"sidebar-inline-confirm",onClick:de=>de.stopPropagation(),children:[u.jsx("button",{onClick:()=>{l.handleDeleteWorkspace(q.filename),D(null)},children:"Yes"}),u.jsx("button",{onClick:()=>D(null),children:"No"})]}):u.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:de=>{de.stopPropagation(),D(q.filename)},title:"Delete workspace",children:"×"})]})]}),!te&&u.jsxs("div",{className:"sidebar-section-list","data-drop-ws":q.filename,children:[f&&!(h!=null&&h.parentDocId)&&(h==null?void 0:h.wsFilename)===q.filename&&h.containerId===null&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:f})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),L.filter(de=>de.type!=="doc"?!0:!(x(de.file)||f&&(h==null?void 0:h.wsFilename)===q.filename&&h.containerId===null&&de.title===f)).map((de,_e)=>Mt(de,0,q.filename,null,L,_e,ve)),L.length===0&&!f&&u.jsx("div",{className:"sidebar-empty",children:Y?"Drop here to add":"Empty workspace"})]})]},q.filename)}),u.jsx("div",{className:"sidebar-new-workspace",children:u.jsx("button",{onClick:l.handleCreateWorkspace,children:"+ New Workspace"})}),Ie&&u.jsx(Nd,{x:Ie.x,y:Ie.y,filename:Ie.wsFilename,title:Ie.title,onClose:()=>dt(null),onDuplicate:()=>{},onRename:()=>{Ie.type==="workspace"?(H(Ie.wsFilename),re(Ie.title)):Ie.containerId&&(Q(Ie.containerId),W(Ie.title)),dt(null)},onArchive:()=>{},onDelete:()=>{Ie.type==="workspace"?l.handleDeleteWorkspace(Ie.wsFilename):Ie.containerId&&l.handleDeleteContainer(Ie.wsFilename,Ie.containerId)},onPluginAction:()=>{},pluginItems:[],folderMode:!0,onNewDoc:q=>{st({anchor:q.target.getBoundingClientRect(),wsFilename:Ie.wsFilename,containerId:Ie.type==="container"?Ie.containerId:null}),dt(null)},onNewContainer:()=>{l.handleCreateContainer(Ie.wsFilename,Ie.type==="container"?Ie.containerId:null),dt(null)},onAcceptAll:()=>{const q=new Set;Sl(Ie.nodes,q),q.size&&Je([...q],"accept"),dt(null)},onRejectAll:()=>{const q=new Set;Sl(Ie.nodes,q),q.size&&Je([...q],"reject"),dt(null)},folderAutoAccept:Ie.autoAccept,folderAutoAcceptLabel:Ie.type==="workspace"?"for workspace":"for container",onToggleFolderAutoAccept:()=>{fetch("/api/auto-accept/inherit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wsFile:Ie.wsFilename,...Ie.type==="container"?{containerId:Ie.containerId}:{},enabled:!Ie.autoAccept})}).catch(()=>{})}}),I&&u.jsx(Nd,{x:I.x,y:I.y,filename:I.filename,title:I.title,onClose:()=>Z(null),onDuplicate:()=>Ce(I.filename),onRename:()=>{E(I.filename),A(I.title)},onArchive:()=>l.handleArchive(I.filename),onDelete:()=>l.handleDelete(I.filename),onPluginAction:(q,L)=>Re(q,L,I.filename,I.title),pluginItems:se,onSchedulePost:()=>{Qe({filename:I.filename,title:I.title}),Z(null)},onViewAnalytics:I.docId&&I.lastSent&&(I.postedUrl||I.isNewsletter)?()=>{I.isNewsletter?ge({docId:I.docId,title:I.title}):I.postedUrl&&window.open(I.postedUrl,"_blank"),Z(null)}:void 0,viewAnalyticsLabel:I.isNewsletter?"View Analytics":I.postedUrl?"View on X":"View Analytics",isApproved:l.getDocTags(I.filename).includes("✓"),onToggleApprove:()=>{l.getDocTags(I.filename).includes("✓")?l.handleRemoveTag(I.filename,"✓"):(l.handleAddTag(I.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAutoAccept:(()=>{var L;const q=(L=t.find(te=>te.filename===I.filename))==null?void 0:L.autoAccept;return q===!0?!0:q===!1?!1:Ed(n,I.filename)})(),onToggleAutoAccept:()=>{var te;const q=(te=t.find(ve=>ve.filename===I.filename))==null?void 0:te.autoAccept,L=q===!0?!0:q===!1?!1:Ed(n,I.filename);fetch("/api/auto-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:I.filename,enabled:!L})}).then(()=>l.fetchDocs()).catch(()=>{})},isAlreadySent:!!I.lastSent,onMarkSent:()=>{const q=I.filename;l.getDocTags(q).includes("✓")&&l.handleRemoveTag(q,"✓"),i(q),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>l.fetchDocs()).catch(()=>{})},100),Z(null)}}),fe&&u.jsx(h2,{actionLabel:fe.label,docTitle:fe.title,onClose:()=>De(null),onConfirm:q=>{const L=se.find(te=>te.action===fe.action);L&&Re(fe.action,L,fe.filename,fe.title,q),De(null)}}),le&&u.jsx(p2,{docId:le.docId,title:le.title,onClose:()=>ge(null)}),We&&u.jsx(jl,{filename:We.filename,title:We.title,onClose:()=>Qe(null)}),ot&&u.jsx(m2,{anchorRect:ot.anchor,onClose:()=>st(null),onSelect:q=>{st(null),ot.wsFilename?l.handleCreateInWorkspace(ot.wsFilename,ot.containerId??null,q):q?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:q})}).catch(()=>{}):o()}}),Ge&&u.jsx("div",{ref:Ke,className:"sidebar-density-dropdown",style:{position:"fixed",left:Ge.x,top:Ge.y,zIndex:200},children:c8.map(q=>u.jsx("button",{className:`sidebar-density-option ${xt===q.id?"active":""}`,onClick:()=>pt(q.id),children:q.label},q.id))})]})}function d8({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:o,scrollRef:l,searchQuery:d,searchResults:f}){const[h,m]=k.useState(null);if(f!==null)return u.jsx(Wd,{results:f,query:d,onSwitchDocument:s});const g=[...t].sort((w,E)=>new Date(E.lastModified).getTime()-new Date(w.lastModified).getTime()),y=[];let b="";for(const w of g){const E=n8(w.lastModified);E!==b&&(y.push({label:E,docs:[]}),b=E),y[y.length-1].docs.push(w)}const x=w=>{for(const E of e){if(!E.workspace)continue;const C=A=>{for(const T of A)if(T.type==="doc"&&T.file===w||T.type==="container"&&C(T.items))return!0;return!1};if(C(E.workspace.root))return E.title}return null};return u.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:l,children:[u.jsxs("div",{className:"tl-header",children:[u.jsx("span",{className:"tl-title",children:"Timeline"}),u.jsx("button",{className:"sidebar-new-btn",onClick:i,title:"New document",children:"+"})]}),y.map(w=>u.jsxs("div",{className:"tl-group",children:[u.jsx("div",{className:"tl-date",children:w.label}),w.docs.map(E=>{const C=x(E.filename);return u.jsxs("div",{className:`tl-item ${E.isActive?"active":""}`,onClick:()=>!E.isActive&&s(E.filename),children:[u.jsx("div",{className:"tl-dot"}),u.jsxs("div",{className:"tl-content",children:[u.jsxs("div",{className:"tl-item-title",children:[u.jsx("span",{children:E.title}),r.filenames.includes(E.filename)&&u.jsx("span",{className:"sidebar-pending-dot"})]}),Ts(E.filename)&&u.jsx("div",{className:"tl-item-context",children:u2(E.filename)}),u.jsxs("div",{className:"tl-item-meta",children:[E.wordCount.toLocaleString()," words · ",ra(E.lastModified)]}),C&&u.jsx("div",{className:"tl-badge",children:C})]}),h===E.filename?u.jsxs("div",{className:"sidebar-confirm-delete",onClick:A=>A.stopPropagation(),children:[u.jsx("span",{children:Ts(E.filename)?"Remove?":"Delete?"}),u.jsx("button",{onClick:()=>{o.handleDelete(E.filename),m(null)},children:"Yes"}),u.jsx("button",{onClick:()=>m(null),children:"No"})]}):u.jsx("button",{className:"sidebar-delete-btn",onClick:A=>{A.stopPropagation(),m(E.filename)},title:Ts(E.filename)?"Remove":"Delete",children:"×"})]},E.filename)})]},w.label)),t.length===0&&u.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function f8({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:l,searchResults:d,onSearchChange:f}){const[h,m]=k.useState([]),[g,y]=k.useState(null),[b,x]=k.useState(null),w=k.useRef(null);k.useEffect(()=>{if(!g)return;const M=I=>{w.current&&!w.current.contains(I.target)&&y(null)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[g]);const E=(M,I)=>{for(const Z of M)if(Z.type==="container"){if(Z.id===I)return Z;const le=E(Z.items,I);if(le)return le}return null},C=M=>{let I=0;for(const Z of M)Z.type==="doc"?I++:Z.type==="container"&&(I+=C(Z.items));return I},A=M=>{const I=[];for(const Z of M)Z.type==="doc"?I.push(Z.file):Z.type==="container"&&I.push(...A(Z.items));return I},T=k.useMemo(()=>{if(h.length===0)return[];const M=h[h.length-1],I=e.find(le=>le.filename===M.wsFilename);if(!(I!=null&&I.workspace))return[];if(M.type==="workspace")return I.workspace.root;const Z=E(I.workspace.root,M.key);return Z?Z.items:[]},[h,e]),_=T.filter(M=>M.type==="container"),O=k.useMemo(()=>{const M=T.filter(I=>I.type==="doc").map(I=>I.file);return t.filter(I=>M.includes(I.filename))},[T,t]),R=M=>{const I=A(M.items);return t.filter(Z=>I.includes(Z.filename))},B=M=>{const I=e.find(le=>le.filename===M);if(!(I!=null&&I.workspace))return[];const Z=A(I.workspace.root);return t.filter(le=>Z.includes(le.filename))},D=k.useMemo(()=>t.filter(M=>!n.has(M.filename)),[t,n]),U=M=>{m(I=>[...I,M]),y(null)},Q=()=>{m(M=>M.slice(0,-1)),y(null)},P=(M,I)=>{if(g===M){y(null);return}const le=I.currentTarget.getBoundingClientRect();x({top:le.bottom+4,left:le.left}),y(M)},W=M=>{s(M),y(null)},$=h.length>1?h[h.length-2].title:"All",H=k.useRef(null),J=k.useRef(null),[re,V]=k.useState(null),ie=k.useCallback(M=>{const Z=M.currentTarget.getBoundingClientRect();V({top:Z.bottom+4,left:Z.left})},[]);k.useEffect(()=>{if(!d)return;const M=I=>{J.current&&!J.current.contains(I.target)&&H.current&&!H.current.contains(I.target)&&f("")};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[d,f]);const z=()=>{if(!g)return[];if(g==="__unassigned__")return D;if(g==="__level-docs__")return O;const M=e.find(I=>I.filename===g);if(M)return B(M.filename);for(const I of e){if(!I.workspace)continue;const Z=E(I.workspace.root,g);if(Z)return R(Z)}return[]};return u.jsxs("div",{className:"board-scroll",ref:o,children:[u.jsxs("div",{className:"board-search-pill",children:[u.jsxs("svg",{className:"board-search-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"11",cy:"11",r:"8"}),u.jsx("path",{d:"m21 21-4.3-4.3"})]}),u.jsx("input",{ref:H,className:"board-search-input",type:"text",placeholder:"Search...",value:l,onChange:M=>f(M.target.value),onFocus:ie}),l&&u.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),h.length===0?u.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):u.jsxs("button",{className:"board-back",onClick:Q,title:`Back to ${$}`,children:["← ",$]}),h.length===0&&u.jsxs(u.Fragment,{children:[D.length>0&&u.jsxs("button",{className:`board-chip ${g==="__unassigned__"?"open":""}`,onClick:M=>P("__unassigned__",M),children:["Documents ",u.jsx("span",{className:"board-chip-count",children:D.length})]}),e.map(M=>{var Z;const I=(Z=M.workspace)==null?void 0:Z.root.some(le=>le.type==="container");return u.jsxs("button",{className:`board-chip ${g===M.filename?"open":""}`,onClick:le=>I?U({type:"workspace",key:M.filename,title:M.title,wsFilename:M.filename}):P(M.filename,le),children:[M.title," ",u.jsx("span",{className:"board-chip-count",children:M.docCount}),I&&u.jsx("span",{className:"board-chip-arrow",children:"›"})]},M.filename)}),u.jsx("button",{className:"board-chip board-chip-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),h.length>0&&u.jsxs(u.Fragment,{children:[O.length>0&&u.jsxs("button",{className:`board-chip board-chip-docs ${g==="__level-docs__"?"open":""}`,onClick:M=>P("__level-docs__",M),children:["Docs ",u.jsx("span",{className:"board-chip-count",children:O.length})]}),_.map(M=>{const I=M.items.some(Z=>Z.type==="container");return u.jsxs("button",{className:`board-chip ${g===M.id?"open":""}`,onClick:Z=>I?U({type:"container",key:M.id,title:M.name,wsFilename:h[h.length-1].wsFilename}):P(M.id,Z),children:[M.name," ",u.jsx("span",{className:"board-chip-count",children:C(M.items)}),I&&u.jsx("span",{className:"board-chip-arrow",children:"›"})]},M.id)})]}),g&&b&&(()=>{const M=z();return u.jsxs("div",{className:"board-dropdown",ref:w,style:{position:"fixed",top:b.top,left:b.left},children:[M.map(I=>u.jsxs("div",{className:`board-dropdown-item ${I.isActive?"active":""}`,onClick:()=>W(I.filename),children:[u.jsxs("span",{className:"board-dropdown-title",children:[I.title,r.filenames.includes(I.filename)&&u.jsx("span",{className:"board-pending-dot"})]}),u.jsxs("span",{className:"board-dropdown-meta",children:[I.wordCount.toLocaleString()," words · ",ra(I.lastModified)]})]},I.filename)),M.length===0&&u.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),d&&re&&u.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:J,style:{position:"fixed",top:re.top,left:re.left},children:[d.map(M=>u.jsxs("div",{className:`board-dropdown-item ${M.isActive?"active":""}`,onClick:()=>{s(M.filename),f("")},children:[u.jsx("span",{className:"board-dropdown-title",children:M.title}),M.matchType==="tag"&&M.matchedTag&&u.jsxs("span",{className:"board-dropdown-meta",children:["Tag: ",M.matchedTag]}),M.matchType==="content"&&M.snippet&&u.jsx("span",{className:"board-dropdown-meta board-search-snippet",children:M.snippet}),u.jsxs("span",{className:"board-dropdown-meta",children:[M.wordCount.toLocaleString()," words · ",ra(M.lastModified)]})]},M.filename)),d.length===0&&u.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function h8({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:o,searchQuery:l,searchResults:d}){const[f,h]=k.useState([]);if(d!==null)return u.jsx(Wd,{results:d,query:l,onSwitchDocument:s});const m=(T,_)=>{for(const O of T)if(O.type==="container"){if(O.id===_)return O;const R=m(O.items,_);if(R)return R}return null},g=T=>{let _=0;for(const O of T)O.type==="doc"?_++:O.type==="container"&&(_+=g(O.items));return _},y=k.useMemo(()=>{if(f.length===0)return[];const T=f[f.length-1],_=e.find(R=>R.filename===T.wsFilename);if(!(_!=null&&_.workspace))return[];if(T.type==="workspace")return _.workspace.root;const O=m(_.workspace.root,T.key);return O?O.items:[]},[f,e]),b=y.filter(T=>T.type==="container"),x=k.useMemo(()=>{if(f.length===0)return t.filter(_=>!n.has(_.filename));const T=y.filter(_=>_.type==="doc").map(_=>_.file);return t.filter(_=>T.includes(_.filename))},[f,y,t,n]),w=T=>h(_=>[..._,T]),E=()=>h(T=>T.slice(0,-1)),C=f.length>1?f[f.length-2].title:"Shelf",A=f.length>0?f[f.length-1].title:"Documents";return u.jsxs("div",{className:"shelf-wrapper",children:[u.jsxs("div",{className:"shelf-spines",ref:o,children:[f.length>0&&u.jsxs("button",{className:"shelf-back",onClick:E,title:`Back to ${C}`,children:[u.jsx("span",{className:"shelf-back-arrow",children:"←"}),u.jsx("span",{className:"shelf-back-label",children:C})]}),f.length===0&&u.jsxs(u.Fragment,{children:[e.map(T=>u.jsxs("div",{className:"shelf-section-spine",onClick:()=>w({type:"workspace",key:T.filename,title:T.title,wsFilename:T.filename}),title:T.title,children:[u.jsx("span",{className:"shelf-section-title",children:T.title}),u.jsx("span",{className:"shelf-section-count",children:T.docCount})]},T.filename)),u.jsx("button",{className:"shelf-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),f.length>0&&b.map(T=>u.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>w({type:"container",key:T.id,title:T.name,wsFilename:f[f.length-1].wsFilename}),title:T.name,children:[u.jsx("span",{className:"shelf-section-title",children:T.name}),u.jsx("span",{className:"shelf-section-count",children:g(T.items)})]},T.id))]}),u.jsxs("div",{className:"shelf-docs",children:[u.jsx("div",{className:"shelf-docs-header",children:A}),u.jsxs("div",{className:"shelf-docs-list",children:[x.map(T=>u.jsxs("div",{className:`shelf-doc-item ${T.isActive?"active":""}`,onClick:()=>s(T.filename),children:[u.jsxs("div",{className:"shelf-doc-title",children:[u.jsx("span",{children:T.title}),r.filenames.includes(T.filename)&&u.jsx("span",{className:"shelf-pending-dot"})]}),u.jsxs("div",{className:"shelf-doc-meta",children:[T.wordCount.toLocaleString()," words · ",ra(T.lastModified)]})]},T.filename)),x.length===0&&u.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}const p8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[u.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"}),u.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14",opacity:"0.5"})]}),m8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),u.jsx("polyline",{points:"14 2 14 8 20 8"}),u.jsx("line",{x1:"8",y1:"13",x2:"16",y2:"13"}),u.jsx("line",{x1:"8",y1:"17",x2:"13",y2:"17"})]}),g8=()=>u.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:u.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),v8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[u.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),u.jsx("path",{d:"M7 15l-4-3.5L7 8",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),y8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[u.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),u.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"})]}),b8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:[u.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z",opacity:"0.5"}),u.jsx("rect",{x:"2",y:"16",width:"8",height:"7",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("line",{x1:"4",y1:"18.5",x2:"8",y2:"18.5",stroke:"currentColor",strokeWidth:"1",opacity:"0.7"}),u.jsx("line",{x1:"4",y1:"20.5",x2:"7",y2:"20.5",stroke:"currentColor",strokeWidth:"1",opacity:"0.7"})]}),x8=()=>u.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",stroke:"none",children:u.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.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"})}),w8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),u.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),k8=()=>u.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("path",{d:"M2 12h20"}),u.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),mw=()=>u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})});function S8({type:t}){switch(t){case"tweet":return u.jsx(g8,{});case"reply":return u.jsx(v8,{});case"quote":return u.jsx(y8,{});case"article":return u.jsx(b8,{});case"linkedin":return u.jsx(x8,{});case"newsletter":return u.jsx(w8,{});case"blog":return u.jsx(k8,{});default:return u.jsx(m8,{})}}function _u(t){let e=0;for(const n of t)n.type==="doc"?e++:n.type==="container"&&(e+=_u(n.items));return e}function v2(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=v2(n.items,e);if(r)return[n.id,...r]}}return null}function gw(t){const e=new Set;return Sl(t,e),[...e]}function y2(t,e,n=0){for(const r of t)if(r.type==="container"){if(r.id===e)return n;const s=y2(r.items,e,n+1);if(s>=0)return s}return-1}function E8(t,e){if(!e)return 12;for(const n of t){if(!n.workspace)continue;const r=y2(n.workspace.root,e);if(r>=0)return 12+(r+1)*16}return 12}function N8({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:y}){const b=K=>!!h&&h.has(K),[x,w]=k.useState(()=>{try{const K=localStorage.getItem("ow-files-collapsed");return K?new Set(JSON.parse(K)):new Set}catch{return new Set}}),{draggedItem:E,dropIndicator:C,handlePointerDown:A,dropClass:T,isDragging:_,isContainerDropTarget:O}=f2({docs:t,workspaces:e,assignedFiles:n,scrollRef:l,setCollapsedSections:w}),R=K=>!C||C.itemId!==K||C.position==="inside"?void 0:{"--drop-indent":`${E8(e,C.containerId)}px`},{variantsByMaster:B,variantFilenames:D}=k.useMemo(()=>{const K=new Map,me=new Set;for(const ye of t)if(ye.masterDocId){const Ce=K.get(ye.masterDocId)||[];Ce.push(ye),K.set(ye.masterDocId,Ce),me.add(ye.filename)}return{variantsByMaster:K,variantFilenames:me}},[t]),[U,Q]=k.useState(null),[P,W]=k.useState(null),[$,H]=k.useState(new Set),[J,re]=k.useState(null),[V,ie]=k.useState([]),[z,M]=k.useState(null),[I,Z]=k.useState(null),[le,ge]=k.useState(null),[se,xe]=k.useState(null),[fe,De]=k.useState(null),[We,Qe]=k.useState(new Set);k.useEffect(()=>{Qe(new Set)},[r]);const ot=k.useCallback(()=>{fetch("/api/plugins").then(K=>K.json()).then(K=>{const me=[];for(const ye of K.plugins||[]){const Ce=ye.displayName||void 0;for(const Re of ye.sidebarMenuItems||[])me.push({...Re,pluginDisplayName:Ce})}ie(me)}).catch(()=>{})},[]);k.useEffect(()=>{ot()},[ot]),k.useEffect(()=>{const K=()=>ot();return window.addEventListener("ow-plugins-changed",K),()=>window.removeEventListener("ow-plugins-changed",K)},[ot]);const st=k.useCallback((K,me)=>{if(K.preventDefault(),K.stopPropagation(),$.has(me.filename)&&$.size>1){W({x:K.clientX,y:K.clientY,filename:me.filename,title:me.title,bulkCount:$.size});return}$.size>0&&!$.has(me.filename)&&H(new Set),W({x:K.clientX,y:K.clientY,filename:me.filename,title:me.title,docId:me.docId,lastSent:me.lastSent,postedUrl:me.postedUrl,isNewsletter:me.isNewsletter})},[$]),Ie=k.useCallback(K=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:K})}).catch(()=>{})},[]),dt=k.useCallback((K,me,ye,Ce,Re)=>{if(me.promptForFocus&&Re===void 0){M({action:K,label:me.label,filename:ye,title:Ce});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:K,filename:ye,title:Ce,instructions:Re||"",label:me.label})}).catch(()=>{})},[]),Ge=k.useCallback((K,me)=>{Qe(ye=>{const Ce=new Set(ye);for(const Re of K)Ce.add(Re);return Ce}),fetch("/api/documents/batch-resolve",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filenames:K,action:me})}).catch(()=>{})},[]),bt=K=>{w(me=>{const ye=new Set(me);return ye.has(K)?ye.delete(K):ye.add(K),localStorage.setItem("ow-files-collapsed",JSON.stringify([...ye])),ye})},xt=(K,me,ye,Ce)=>{Q({type:K,key:me,value:ye,wsFilename:Ce})},$t=()=>{if(!U)return;const{type:K,key:me,value:ye,wsFilename:Ce}=U;K==="doc"?o.handleRename(me,"",ye):K==="workspace"?o.handleRenameWorkspace(me,ye):K==="container"&&Ce&&o.handleRenameContainer(Ce,me,ye),Q(null)},Ke=t.find(K=>K.isActive),pt=k.useRef(e);pt.current=e,k.useEffect(()=>{var K;if(Ke)for(const me of pt.current){const ye=v2(((K=me.workspace)==null?void 0:K.root)||[],Ke.filename);if(ye){w(Ce=>{const Re=[me.filename,...ye.map(Ee=>`container-${Ee}`)];if(Re.every(Ee=>!Ce.has(Ee)))return Ce;const Be=new Set(Ce);for(const Ee of Re)Be.delete(Ee);return localStorage.setItem("ow-files-collapsed",JSON.stringify([...Be])),Be});break}}},[Ke==null?void 0:Ke.filename]);const Ft=k.useMemo(()=>t.filter(K=>!n.has(K.filename)&&!D.has(K.filename)&&!b(K.filename)),[t,n,D,h]),Je=k.useMemo(()=>{var Ce;const K=[],me=Re=>{K.push(Re.filename);const Be=Re.docId?B.get(Re.docId):void 0,Ee=Re.docId&&!x.has(`variants-${Re.docId}`);if(Be&&Ee)for(const et of Be)K.push(et.filename)},ye=Re=>{for(const Be of Re)if(Be.type==="doc"){const Ee=t.find(et=>et.filename===Be.file);Ee&&!D.has(Ee.filename)&&me(Ee)}else x.has(`container-${Be.id}`)||ye(Be.items)};x.has("docs")||Ft.forEach(me);for(const Re of e)x.has(Re.filename)||ye(((Ce=Re.workspace)==null?void 0:Ce.root)||[]);return K},[t,e,Ft,D,B,x]),Y=k.useCallback(()=>{H(new Set)},[]),pe=k.useCallback((K,me)=>{if(E)return;const ye=K.shiftKey,Ce=K.ctrlKey||K.metaKey;if(ye){const Be=J||(Ke==null?void 0:Ke.filename)||me,Ee=Je.indexOf(Be),et=Je.indexOf(me);if(Ee<0||et<0){H(new Set([me])),re(me);return}const[gt,Tt]=Ee<et?[Ee,et]:[et,Ee];H(new Set(Je.slice(gt,Tt+1)));return}if(Ce){H(Be=>{const Ee=new Set(Be);return Ee.has(me)?Ee.delete(me):Ee.add(me),Ee}),re(me);return}H(new Set),re(me);const Re=t.find(Be=>Be.filename===me);Re&&!Re.isActive&&s(me)},[E,J,Ke==null?void 0:Ke.filename,Je,s,t]);k.useEffect(()=>{if($.size===0)return;const K=me=>{me.key==="Escape"&&Y()};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[$.size,Y]);const G=k.useCallback(()=>{for(const K of $)o.handleDelete(K);H(new Set),re(null)},[$,o]);if(g!==null)return u.jsx(Wd,{results:g,query:m,onSwitchDocument:s,actions:o});const oe=K=>u.jsx("input",{className:"sidebar-rename-input",value:U.value,onChange:me=>Q(ye=>ye?{...ye,value:me.target.value}:null),onBlur:K,onKeyDown:me=>{me.key==="Enter"&&K(),me.key==="Escape"&&Q(null)},autoFocus:!0,onClick:me=>me.stopPropagation()}),ue=(K,me,ye,Ce,Re,Be=!1)=>u.jsxs("div",{className:`files-row${K.isActive?" active":""}${$.has(K.filename)?" selected":""} ${_(K.filename)?"dragging":""} ${T(K.filename)}${K.masterDocId?" is-variant":""}`,style:{paddingLeft:me,...R(K.filename)},"data-drag-id":K.filename,"data-drag-type":"doc","data-drag-ws":ye||"__docs__","data-drag-container":Ce||"",onPointerDown:Ee=>A(Ee,{type:"doc",file:K.filename,sourceWs:ye||null},K.title),onClick:Ee=>pe(Ee,K.filename),onDoubleClick:()=>xt("doc",K.filename,K.title),onContextMenu:Ee=>st(Ee,K),children:[u.jsx("span",{className:"files-row-icon",children:u.jsx(S8,{type:K.contentType})}),(U==null?void 0:U.type)==="doc"&&U.key===K.filename?oe($t):u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"files-row-label",children:K.title}),K.variantType&&u.jsx("span",{className:"files-badge-variant",children:K.variantType}),(K.autoAccept===!0||K.autoAccept!==!1&&Be)&&u.jsx("span",{className:"sidebar-auto-accept-dot",title:K.autoAccept===!0?"Auto-accept on":"Auto-accept inherited"}),r.filenames.includes(K.filename)&&!We.has(K.filename)&&u.jsx("span",{className:"files-badge-pending"}),o.getDocTags(K.filename).includes("✓")&&u.jsx("span",{className:"files-badge-approved",children:u.jsx(mw,{})}),K.lastSent&&u.jsx("span",{className:"files-badge-sent",children:u.jsx(mw,{})}),Re&&u.jsx("span",{className:`files-row-chevron${x.has(`variants-${K.docId}`)?" collapsed":""}`,onClick:Ee=>{Ee.stopPropagation(),bt(`variants-${K.docId}`)},children:u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"6 9 12 15 18 9"})})})]})]},K.filename),Fe=(K,me,ye,Ce,Re=!1)=>{const Be=K.docId?B.get(K.docId):void 0,Ee=!!(Be&&Be.length>0),et=d&&(f==null?void 0:f.parentDocId)&&f.parentDocId===K.docId,gt=Ee||et,Tt=!x.has(`variants-${K.docId}`);return gt?u.jsxs("div",{className:"files-variant-group",children:[ue(K,me,ye,Ce,Ee,Re),Tt&&(Be==null?void 0:Be.map(Jt=>ue(Jt,me+16,ye,Ce,!1,Re))),et&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:me+16},children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:d})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]})]},`vg-${K.filename}`):ue(K,me,ye,Ce,!1,Re)},Me=(K,me,ye,Ce,Re=!1)=>{const Be=12+me*16;if(K.type==="doc"){const q=t.find(L=>L.filename===K.file);return!q||D.has(q.filename)?null:Fe(q,Be,ye,Ce,Re)}const Ee=K,et=`container-${Ee.id}`,gt=x.has(et),Tt=_u(Ee.items),Jt=Ee.autoAccept===!0,Mt=Jt||Re;return u.jsxs("div",{className:`${T(Ee.id)} ${O(Ee.id)?"files-drop-inside":""}`,children:[u.jsxs("div",{className:`files-row is-container ${_(Ee.id)?"dragging":""} ${T(Ee.id)}`,style:{paddingLeft:Be,...R(Ee.id)},"data-drag-id":Ee.id,"data-drag-type":"container-header","data-drag-ws":ye,"data-drag-parent":Ce||"","data-section-key":et,onPointerDown:q=>A(q,{type:"container",id:Ee.id,sourceWs:ye},Ee.name),onClick:()=>!E&&bt(et),onDoubleClick:q=>{q.stopPropagation(),xt("container",Ee.id,Ee.name,ye)},onContextMenu:q=>{q.preventDefault(),q.stopPropagation(),De({x:q.clientX,y:q.clientY,type:"container",wsFilename:ye,containerId:Ee.id,title:Ee.name,nodes:Ee.items,autoAccept:Jt})},children:[u.jsx("span",{className:"files-row-icon",children:u.jsx(p8,{})}),(U==null?void 0:U.type)==="container"&&U.key===Ee.id?oe($t):u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"files-row-label",children:Ee.name}),Mt&&u.jsx("span",{className:"sidebar-auto-accept-dot",title:Jt?"Auto-accept on for this container":"Auto-accept inherited from workspace"}),u.jsx("span",{className:"files-row-count",children:Tt})]})]}),u.jsxs("div",{className:`files-children${gt?" collapsed":""}`,"data-drop-ws":ye,"data-drop-container":Ee.id,children:[d&&!(f!=null&&f.parentDocId)&&(f==null?void 0:f.wsFilename)===ye&&f.containerId===Ee.id&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:12+(me+1)*16},children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:d})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),Ee.items.filter(q=>q.type!=="doc"||!b(q.file)).map(q=>Me(q,me+1,ye,Ee.id,Mt))]})]},Ee.id)};return u.jsxs("div",{className:"files-scroll",ref:l,children:[u.jsxs("div",{className:"files-section",children:[u.jsxs("div",{className:"files-row is-section","data-section-key":"docs",onClick:()=>bt("docs"),children:[u.jsx("span",{className:`files-row-chevron leading${x.has("docs")?" collapsed":""}`,children:u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"6 9 12 15 18 9"})})}),u.jsx("span",{className:"files-row-label",children:"Documents"}),u.jsx("button",{className:"files-section-btn",onClick:K=>{K.stopPropagation(),xe({anchor:K.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),u.jsxs("div",{className:`files-section-list files-children${x.has("docs")?" collapsed":""}`,"data-drop-ws":"__docs__",children:[d&&!(f!=null&&f.parentDocId)&&(!f||!e.some(K=>K.filename===(f==null?void 0:f.wsFilename)))&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:28},children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:d})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),Ft.map(K=>Fe(K,28))]})]}),e.map(K=>{var Be,Ee,et;const me=((Be=K.workspace)==null?void 0:Be.root)||[],ye=x.has(K.filename),Ce=_u(me),Re=((Ee=K.workspace)==null?void 0:Ee.autoAccept)===!0||K.autoAccept===!0;return u.jsxs("div",{className:`files-section ${_(K.filename)?"dragging":""} ${(C==null?void 0:C.itemId)===K.filename?C.position==="before"?"files-ws-drop-before":"files-ws-drop-after":""}`,children:[u.jsx("div",{className:`files-row is-section${(C==null?void 0:C.itemId)==="__section__"&&C.wsFilename===K.filename&&C.position==="inside"?" files-ws-drop-target":""}`,"data-section-key":K.filename,"data-ws-drag":K.filename,onPointerDown:gt=>A(gt,{type:"workspace",filename:K.filename},K.title),onClick:()=>!E&&bt(K.filename),onDoubleClick:gt=>{gt.stopPropagation(),xt("workspace",K.filename,K.title)},onContextMenu:gt=>{var Tt;gt.preventDefault(),gt.stopPropagation(),De({x:gt.clientX,y:gt.clientY,type:"workspace",wsFilename:K.filename,title:K.title,nodes:me,autoAccept:((Tt=K.workspace)==null?void 0:Tt.autoAccept)===!0||K.autoAccept===!0})},children:(U==null?void 0:U.type)==="workspace"&&U.key===K.filename?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:`files-row-chevron leading${ye?" collapsed":""}`,children:u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"6 9 12 15 18 9"})})}),oe($t)]}):u.jsxs(u.Fragment,{children:[u.jsx("span",{className:`files-row-chevron leading${ye?" collapsed":""}`,children:u.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"6 9 12 15 18 9"})})}),u.jsx("span",{className:"files-row-label",children:K.title}),(((et=K.workspace)==null?void 0:et.autoAccept)===!0||K.autoAccept===!0)&&u.jsx("span",{className:"sidebar-auto-accept-dot",title:"Auto-accept on for this workspace"}),u.jsx("span",{className:"files-row-count",children:Ce}),u.jsxs("div",{className:"files-section-actions",children:[u.jsx("button",{className:"files-section-btn",onClick:gt=>{gt.stopPropagation(),xe({anchor:gt.target.getBoundingClientRect(),wsFilename:K.filename,containerId:null})},title:"New document",children:"+"}),u.jsx("button",{className:"files-section-btn",onClick:gt=>{gt.stopPropagation(),o.handleCreateContainer(K.filename,null)},title:"New container",children:"☐"})]})]})}),u.jsxs("div",{className:`files-section-list files-children${ye?" collapsed":""}`,"data-drop-ws":K.filename,children:[d&&!(f!=null&&f.parentDocId)&&(f==null?void 0:f.wsFilename)===K.filename&&f.containerId===null&&u.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",style:{paddingLeft:28},children:[u.jsxs("div",{className:"sidebar-item-title",children:[u.jsx("span",{className:"sidebar-writing-spinner"}),u.jsx("span",{className:"sidebar-item-title-text",children:d})]}),u.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),me.filter(gt=>gt.type!=="doc"||!b(gt.file)).map(gt=>Me(gt,1,K.filename,null,Re))]})]},K.filename)}),u.jsx("div",{className:"files-new-ws",children:u.jsx("button",{onClick:o.handleCreateWorkspace,children:"+ New Workspace"})}),fe&&u.jsx(Nd,{x:fe.x,y:fe.y,filename:fe.wsFilename,title:fe.title,onClose:()=>De(null),onDuplicate:()=>{},onRename:()=>{fe.type==="workspace"?xt("workspace",fe.wsFilename,fe.title):fe.containerId&&xt("container",fe.containerId,fe.title,fe.wsFilename),De(null)},onArchive:()=>{},onDelete:()=>{fe.type==="workspace"?o.handleDeleteWorkspace(fe.wsFilename):fe.containerId&&o.handleDeleteContainer(fe.wsFilename,fe.containerId,!1)},folderDocCount:fe.type==="container"?_u(fe.nodes):0,onDeleteWithDocs:fe.type==="container"&&fe.containerId?()=>{o.handleDeleteContainer(fe.wsFilename,fe.containerId,!0)}:void 0,onPluginAction:()=>{},pluginItems:[],folderMode:!0,onNewDoc:K=>{xe({anchor:K.target.getBoundingClientRect(),wsFilename:fe.wsFilename,containerId:fe.type==="container"?fe.containerId:null}),De(null)},onNewContainer:()=>{o.handleCreateContainer(fe.wsFilename,fe.type==="container"?fe.containerId:null),De(null)},onAcceptAll:()=>{const K=gw(fe.nodes);K.length&&Ge(K,"accept"),De(null)},onRejectAll:()=>{const K=gw(fe.nodes);K.length&&Ge(K,"reject"),De(null)},folderAutoAccept:fe.autoAccept,folderAutoAcceptLabel:fe.type==="workspace"?"for workspace":"for container",onToggleFolderAutoAccept:()=>{fetch("/api/auto-accept/inherit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({wsFile:fe.wsFilename,...fe.type==="container"?{containerId:fe.containerId}:{},enabled:!fe.autoAccept})}).catch(()=>{})}}),P&&u.jsx(Nd,{x:P.x,y:P.y,filename:P.filename,title:P.title,bulkCount:P.bulkCount,onBulkDelete:G,onClose:()=>W(null),onDuplicate:()=>Ie(P.filename),onRename:()=>{xt("doc",P.filename,P.title),W(null)},onArchive:()=>o.handleArchive(P.filename),onDelete:()=>o.handleDelete(P.filename),onPluginAction:(K,me)=>dt(K,me,P.filename,P.title),pluginItems:V,onSchedulePost:()=>{Z({filename:P.filename,title:P.title}),W(null)},onViewAnalytics:P.docId&&P.lastSent&&(P.postedUrl||P.isNewsletter)?()=>{P.isNewsletter?ge({docId:P.docId,title:P.title}):P.postedUrl&&window.open(P.postedUrl,"_blank"),W(null)}:void 0,viewAnalyticsLabel:P.isNewsletter?"View Analytics":P.postedUrl?"View on X":"View Analytics",isApproved:o.getDocTags(P.filename).includes("✓"),onToggleApprove:()=>{o.getDocTags(P.filename).includes("✓")?o.handleRemoveTag(P.filename,"✓"):(o.handleAddTag(P.filename,"✓"),setTimeout(()=>window.dispatchEvent(new CustomEvent("ow-accept-all")),50))},isAutoAccept:(()=>{var me;const K=(me=t.find(ye=>ye.filename===P.filename))==null?void 0:me.autoAccept;return K===!0?!0:K===!1?!1:Ed(e,P.filename)})(),onToggleAutoAccept:()=>{var ye;const K=(ye=t.find(Ce=>Ce.filename===P.filename))==null?void 0:ye.autoAccept,me=K===!0?!0:K===!1?!1:Ed(e,P.filename);fetch("/api/auto-accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:P.filename,enabled:!me})}).then(()=>o.fetchDocs()).catch(()=>{})},isAlreadySent:!!P.lastSent,onMarkSent:()=>{const K=P.filename;o.getDocTags(K).includes("✓")&&o.handleRemoveTag(K,"✓"),s(K),setTimeout(()=>{fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({manualPost:{postedAt:new Date().toISOString()}})}).then(()=>o.fetchDocs()).catch(()=>{})},100),W(null)}}),z&&u.jsx(h2,{actionLabel:z.label,docTitle:z.title,onClose:()=>M(null),onConfirm:K=>{const me=V.find(ye=>ye.action===z.action);me&&dt(z.action,me,z.filename,z.title,K),M(null)}}),le&&u.jsx(p2,{docId:le.docId,title:le.title,onClose:()=>ge(null)}),I&&u.jsx(jl,{filename:I.filename,title:I.title,onClose:()=>Z(null)}),se&&u.jsx(m2,{anchorRect:se.anchor,onClose:()=>xe(null),onSelect:K=>{xe(null),se.wsFilename?o.handleCreateInWorkspace(se.wsFilename,se.containerId??null,K):K?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:K})}).catch(()=>{}):i()}})]})}const C8=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],_8=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}],b2=["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 vw(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 T8(t){if(t.length>0)return t[0].timezone;try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(b2.includes(e))return e}catch{}return"America/New_York"}function M8({slots:t,onBack:e}){const[n,r]=k.useState(t),[s,i]=k.useState(()=>T8(t)),[o,l]=k.useState(!1),[d,f]=k.useState("09:00"),[h,m]=k.useState(["default"]),[g,y]=k.useState("any"),[b,x]=k.useState(!1),w=k.useRef(null);k.useEffect(()=>{if(!o)return;function _(O){w.current&&!w.current.contains(O.target)&&l(!1)}return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[o]);async function E(_){i(_);const O=[];for(const R of n){const B=await fetch(`/api/scheduler/slots/${R.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:_})});if(B.ok){const D=await B.json();O.push(D.slot)}else O.push(R)}O.length>0&&r(O)}async function C(){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 O=await _.json();r(R=>[...R,O.slot]),x(!1),f("09:00"),m(["default"]),y("any")}}async function A(_){(await fetch(`/api/scheduler/slots/${_}`,{method:"DELETE"})).ok&&r(R=>R.filter(B=>B.id!==_))}function T(_){m(O=>{if(_==="default")return["default"];const R=O.filter(B=>B!=="default");if(R.includes(_)){const B=R.filter(D=>D!==_);return B.length===0?["default"]:B}return[...R,_]})}return u.jsxs("div",{className:"sidebar-schedule",children:[u.jsxs("div",{className:"sidebar-schedule-header",children:[u.jsx("button",{className:"sidebar-schedule-btn",onClick:e,title:"Back",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Slot Settings"}),u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>x(!b),children:b?"Cancel":"+ Add"})]}),u.jsxs("div",{className:"slot-tz",ref:w,children:[u.jsx("label",{className:"slot-tz-label",children:"Timezone"}),u.jsxs("button",{className:"slot-tz-trigger",onClick:()=>l(!o),children:[u.jsx("span",{children:vw(s)}),u.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:u.jsx("path",{d:"m6 9 6 6 6-6"})})]}),o&&u.jsx("div",{className:"slot-tz-dropdown",children:b2.map(_=>u.jsx("div",{className:`slot-tz-option ${_===s?"active":""}`,onClick:()=>{E(_),l(!1)},children:vw(_)},_))})]}),b&&u.jsxs("div",{className:"slot-add-form",children:[u.jsxs("div",{className:"slot-add-row",children:[u.jsx("input",{type:"time",className:"slot-input",value:d,onChange:_=>f(_.target.value)}),u.jsx("select",{className:"slot-input",value:g,onChange:_=>y(_.target.value),children:_8.map(_=>u.jsx("option",{value:_.value,children:_.label},_.value))})]}),u.jsxs("div",{className:"slot-add-days",children:[u.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${h.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>T("default"),children:"Every day"}),C8.map(_=>u.jsx("button",{className:`sidebar-schedule-btn slot-day-btn ${h.includes(_.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>T(_.toLowerCase()),children:_},_))]}),u.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active slot-create-btn",onClick:C,children:"Create Slot"})]}),u.jsx("div",{className:"slot-list",children:n.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No slots"}),u.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):n.map(_=>u.jsxs("div",{className:"schedule-item slot-item",children:[u.jsx("div",{className:"schedule-item-time slot-item-time",children:A8(_.time)}),u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:_.days.includes("default")?"Every day":_.days.join(", ")}),u.jsxs("div",{className:"schedule-item-meta",children:[u.jsxs("span",{children:["Filter: ",_.filter_type]}),_.filter_value&&u.jsxs("span",{children:["(",_.filter_value,")"]})]})]}),u.jsx("button",{className:"schedule-item-action schedule-item-action--danger slot-delete-btn",onClick:()=>A(_.id),title:"Delete slot",children:"×"})]},_.id))})]})}function A8(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function j8({onBack:t}){const[e,n]=k.useState([]),[r,s]=k.useState([]),[i,o]=k.useState(null),[l,d]=k.useState(!1),[f,h]=k.useState(!0),m=k.useCallback(async()=>{try{const[E,C]=await Promise.all([fetch("/api/scheduler/autoplugs/goals"),fetch("/api/scheduler/autoplugs/tracking")]);if(E.ok){const A=await E.json();n(A.goals||[])}if(C.ok){const A=await C.json();s(A.tracking||[])}}catch{}h(!1)},[]);k.useEffect(()=>{m()},[m]);const g=async E=>{(await fetch(`/api/scheduler/autoplugs/goals/${E.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!E.enabled})})).ok&&n(A=>A.map(T=>T.id===E.id?{...T,enabled:!T.enabled}:T))},y=async E=>{(await fetch(`/api/scheduler/autoplugs/goals/${E}`,{method:"DELETE"})).ok&&(n(A=>A.filter(T=>T.id!==E)),o(null))},b=async E=>{(await fetch(`/api/scheduler/autoplugs/tracking/${E}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({skipped:!0})})).ok&&s(A=>A.map(T=>T.id===E?{...T,skipped:!0}:T))},x=e.reduce((E,C)=>C.rule&&C.enabled?Math.min(E,C.rule.threshold):E,1/0),w=x===1/0?50:x;return u.jsxs("div",{className:"sidebar-schedule",children:[u.jsxs("div",{className:"sidebar-schedule-header",children:[u.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Autoplugs"}),u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!l),children:l?"Cancel":"+ Add"})]}),l&&u.jsx(R8,{onCreated:E=>{n(C=>[...C,E]),d(!1)}}),f?null:u.jsxs(u.Fragment,{children:[e.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No goals"}),u.jsx("div",{className:"schedule-empty-desc",children:"Create a goal to start autoplugging your tweets."})]}):e.map(E=>u.jsxs("div",{children:[u.jsxs("div",{className:"schedule-item",onClick:()=>o(i===E.id?null:E.id),children:[u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:E.name}),u.jsx("div",{className:"schedule-item-meta",children:O8(E).map((C,A)=>u.jsx("span",{children:C},A))})]}),u.jsx("button",{className:`autoplug-toggle ${E.enabled?"autoplug-toggle--on":"autoplug-toggle--off"}`,onClick:C=>{C.stopPropagation(),g(E)},title:E.enabled?"Disable":"Enable"})]}),i===E.id&&u.jsx(I8,{goal:E,onSaved:C=>{n(A=>A.map(T=>T.id===C.id?C:T))},onDeleted:()=>y(E.id),onRefresh:m})]},E.id)),u.jsx("div",{className:"schedule-day-header",children:"Tracking"}),r.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No tracked tweets"}),u.jsx("div",{className:"schedule-empty-desc",children:"Tweets will appear here after posting."})]}):r.map(E=>u.jsxs("div",{className:"schedule-item",children:[u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:E.original_text||`Tweet ${E.tweet_id}`}),u.jsxs("div",{className:"schedule-item-meta",children:[u.jsx("span",{children:L8(E.posted_at)}),u.jsxs("span",{children:[E.likes," likes"]}),u.jsxs("span",{children:[E.retweets," RTs"]}),E.views>0&&u.jsxs("span",{children:[D8(E.views)," views"]})]}),E.triggered?u.jsxs("div",{className:"autoplug-tracking-triggered",children:[u.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Autoplugged ",E.goal_name?`→ ${E.goal_name}`:""]}):E.skipped?u.jsx("div",{className:"autoplug-tracking-skipped",children:"Skipped"}):u.jsx("div",{className:"autoplug-tracking-bar",children:u.jsx("div",{className:"autoplug-tracking-bar-fill",style:{width:`${Math.min(100,E.likes/w*100)}%`}})})]}),!E.triggered&&!E.skipped&&u.jsx("button",{className:"autoplug-tracking-skip",onClick:()=>b(E.id),title:"Skip autoplug for this tweet",children:"×"})]},E.id))]})]})}function O8(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]=k.useState(""),[r,s]=k.useState(""),[i,o]=k.useState(""),[l,d]=k.useState("likes"),[f,h]=k.useState(50),[m,g]=k.useState(30),[y,b]=k.useState("static"),[x,w]=k.useState(!1),E=async()=>{if(e.trim()){w(!0);try{const C=await fetch("/api/scheduler/autoplugs/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.trim(),link:r.trim()||null,description:i.trim()||null})});if(!C.ok){w(!1);return}const{goal:A}=await C.json();await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:A.id,metric:l,threshold:f,delay_minutes:m,mode:y})});const T=await fetch("/api/scheduler/autoplugs/goals");if(T.ok){const O=((await T.json()).goals||[]).find(R=>R.id===A.id);if(O){t(O);return}}t({...A,rule_count:1,pool_count:0,rule:{metric:l,threshold:f,delay_minutes:m,mode:y,id:""}})}finally{w(!1)}}};return u.jsxs("div",{className:"autoplug-editor",children:[u.jsxs("label",{children:["Name",u.jsx("input",{value:e,onChange:C=>n(C.target.value),placeholder:"Newsletter, Course..."})]}),u.jsxs("label",{children:["Link",u.jsx("input",{value:r,onChange:C=>s(C.target.value),placeholder:"https://..."})]}),u.jsxs("label",{children:["Description (context for LLM)",u.jsx("textarea",{value:i,onChange:C=>o(C.target.value),placeholder:"Weekly engineering insights...",rows:2})]}),u.jsxs("div",{className:"autoplug-editor-row",children:[u.jsx("input",{type:"number",value:f,onChange:C=>h(Number(C.target.value)),min:1}),u.jsxs("select",{value:l,onChange:C=>d(C.target.value),children:[u.jsx("option",{value:"likes",children:"likes"}),u.jsx("option",{value:"retweets",children:"retweets"}),u.jsx("option",{value:"views",children:"views"})]}),u.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),u.jsx("input",{type:"number",value:m,onChange:C=>g(Number(C.target.value)),min:0,className:"autoplug-delay-input"}),u.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),u.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(C=>u.jsx("button",{className:y===C?"active":"",onClick:()=>b(C),children:C==="llm"?"LLM":C.charAt(0).toUpperCase()+C.slice(1)},C))}),u.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active autoplug-create-btn",onClick:E,disabled:x||!e.trim(),children:x?"Creating...":"Create Goal"})]})}function I8({goal:t,onSaved:e,onDeleted:n,onRefresh:r}){var Q,P,W,$;const[s,i]=k.useState(t.name),[o,l]=k.useState(t.link||""),[d,f]=k.useState(t.description||""),[h,m]=k.useState(((Q=t.rule)==null?void 0:Q.metric)||"likes"),[g,y]=k.useState(((P=t.rule)==null?void 0:P.threshold)||50),[b,x]=k.useState(((W=t.rule)==null?void 0:W.delay_minutes)||30),[w,E]=k.useState((($=t.rule)==null?void 0:$.mode)||"static"),[C,A]=k.useState([]),[T,_]=k.useState(""),[O,R]=k.useState(!1);k.useEffect(()=>{fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`).then(H=>H.json()).then(H=>A(H.pool||[])).catch(()=>{})},[t.id]);const B=async()=>{var H;R(!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})}),(H=t.rule)!=null&&H.id?await fetch(`/api/scheduler/autoplugs/rules/${t.rule.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({metric:h,threshold:g,delay_minutes:b,mode:w})}):await fetch("/api/scheduler/autoplugs/rules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({goal_id:t.id,metric:h,threshold:g,delay_minutes:b,mode:w})}),r()}finally{R(!1)}},D=async()=>{if(!T.trim())return;const H=await fetch(`/api/scheduler/autoplugs/goals/${t.id}/pool`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:T.trim()})});if(H.ok){const J=await H.json();A(re=>[...re,J.message]),_("")}},U=async H=>{(await fetch(`/api/scheduler/autoplugs/pool/${H}`,{method:"DELETE"})).ok&&A(re=>re.filter(V=>V.id!==H))};return u.jsxs("div",{className:"autoplug-editor",children:[u.jsxs("label",{children:["Name",u.jsx("input",{value:s,onChange:H=>i(H.target.value)})]}),u.jsxs("label",{children:["Link",u.jsx("input",{value:o,onChange:H=>l(H.target.value),placeholder:"https://..."})]}),u.jsxs("label",{children:["Description",u.jsx("textarea",{value:d,onChange:H=>f(H.target.value),rows:2})]}),u.jsx("div",{className:"autoplug-editor-section-label",children:"Trigger"}),u.jsxs("div",{className:"autoplug-editor-row",children:[u.jsx("input",{type:"number",value:g,onChange:H=>y(Number(H.target.value)),min:1}),u.jsxs("select",{value:h,onChange:H=>m(H.target.value),children:[u.jsx("option",{value:"likes",children:"likes"}),u.jsx("option",{value:"retweets",children:"retweets"}),u.jsx("option",{value:"views",children:"views"})]}),u.jsx("span",{className:"autoplug-editor-row-label",children:"wait"}),u.jsx("input",{type:"number",value:b,onChange:H=>x(Number(H.target.value)),min:0,className:"autoplug-delay-input"}),u.jsx("span",{className:"autoplug-editor-row-label",children:"min"})]}),u.jsx("div",{className:"autoplug-mode-toggle",children:["static","llm","hybrid"].map(H=>u.jsx("button",{className:w===H?"active":"",onClick:()=>E(H),children:H==="llm"?"LLM":H.charAt(0).toUpperCase()+H.slice(1)},H))}),u.jsxs("div",{className:"autoplug-pool-section",children:[u.jsx("div",{className:"autoplug-editor-section-label",children:"Static Pool"}),C.map(H=>u.jsxs("div",{className:"autoplug-pool-item",children:[u.jsx("span",{children:H.content}),u.jsx("button",{onClick:()=>U(H.id),title:"Remove",children:"×"})]},H.id)),u.jsxs("div",{className:"autoplug-pool-add",children:[u.jsx("input",{value:T,onChange:H=>_(H.target.value),placeholder:"Add message... (use {{link}} for link)",onKeyDown:H=>H.key==="Enter"&&D()}),u.jsx("button",{onClick:D,children:"+"})]})]}),(w==="llm"||w==="hybrid")&&u.jsx("div",{className:"autoplug-llm-hint",children:"LLM mode uses Author's Voice to generate contextual replies referencing the original tweet."}),u.jsxs("div",{className:"autoplug-editor-actions",children:[u.jsx("button",{className:"schedule-item-action",onClick:B,disabled:O,children:O?"Saving...":"Save"}),u.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:n,children:"Delete"})]})]})}function L8(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 D8(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t)}function P8({onBack:t}){const[e,n]=k.useState([]),[r,s]=k.useState([]),[i,o]=k.useState(!1),[l,d]=k.useState(!1),[f,h]=k.useState(null),[m,g]=k.useState(!0),y=k.useCallback(async()=>{try{const[w,E]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots"),fetch("/api/scheduler/sync",{method:"POST"})]);if(w.ok){const C=await w.json();n(C.items||[])}if(E.ok){const C=await E.json();s(C.slots||[])}}catch{}g(!1)},[]);k.useEffect(()=>{y()},[y]);const b=async w=>{(await fetch(`/api/scheduler/queue/${w}`,{method:"DELETE"})).ok&&(n(C=>C.filter(A=>A.id!==w)),h(null))};if(l)return u.jsx(j8,{onBack:()=>{d(!1),y()}});if(i)return u.jsx(M8,{slots:r,onBack:()=>{o(!1),y()}});const x=B8(r,e);return u.jsxs("div",{className:"sidebar-schedule",children:[u.jsxs("div",{className:"sidebar-schedule-header",children:[u.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back to documents",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Schedule"}),u.jsxs("div",{className:"sidebar-schedule-actions",children:[u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>d(!0),title:"Autoplugs",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})})}),u.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>o(!0),title:"Manage slots",children:u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),u.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})]})]}),m?null:r.length===0?u.jsxs("div",{className:"schedule-empty",children:[u.jsx("div",{className:"schedule-empty-title",children:"No time slots"}),u.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):x.map(({label:w,entries:E})=>u.jsxs("div",{className:"schedule-day",children:[u.jsx("div",{className:"schedule-day-header",children:w}),E.map((C,A)=>{var T,_,O,R,B;return C.type==="empty"?u.jsxs("div",{className:"schedule-slot-empty",children:[u.jsx("div",{className:"schedule-item-time",children:bw(C.time)}),u.jsx("div",{className:"schedule-slot-empty-label",children:((T=C.slot)==null?void 0:T.filter_type)==="any"?"Open slot":`${(_=C.slot)==null?void 0:_.filter_type}: ${((O=C.slot)==null?void 0:O.filter_value)||"any"}`})]},`empty-${A}`):u.jsxs("div",{children:[u.jsxs("div",{className:"schedule-item",onClick:()=>h(f===C.item.id?null:C.item.id),children:[u.jsx("div",{className:"schedule-item-time",children:bw(C.time)}),u.jsxs("div",{className:"schedule-item-content",children:[u.jsx("div",{className:"schedule-item-text",children:((R=C.item.content)==null?void 0:R.text)||JSON.stringify(C.item.content)}),u.jsxs("div",{className:"schedule-item-meta",children:[u.jsx("span",{className:`schedule-item-status schedule-item-status--${C.item.status}`}),u.jsx("span",{children:C.item.status}),C.item.connection_name&&u.jsx("span",{children:C.item.connection_name}),C.item.provider&&u.jsx("span",{children:C.item.provider})]})]})]}),f===C.item.id&&u.jsxs("div",{className:"schedule-item-expanded",children:[u.jsx("div",{className:"schedule-item-full-text",children:((B=C.item.content)==null?void 0:B.text)||JSON.stringify(C.item.content,null,2)}),u.jsx("div",{className:"schedule-item-actions",children:u.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>b(C.item.id),children:"Cancel"})})]})]},C.item.id)})]},w))]})}function B8(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 y of t){if(!(y.days.includes("default")||y.days.includes(g)))continue;const[x,w]=y.time.split(":").map(Number),E=new Date(d);if(E.setHours(x,w,0,0),yw(d,n)&&E<n)continue;const C=`${E.getFullYear()}-${E.getMonth()}-${E.getDate()}-${x}-${w}`,A=s.get(C);A?(f.push({type:"filled",time:E,item:A,slot:y}),i.add(A.id)):f.push({type:"empty",time:E,slot:y})}for(const y of e){if(i.has(y.id))continue;const b=new Date(y.scheduled_at);yw(b,d)&&(f.push({type:"filled",time:b,item:y}),i.add(y.id))}f.sort((y,b)=>y.time.getTime()-b.time.getTime()),f.length>0&&o.push({label:l,entries:f})}return o}function yw(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function bw(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function z8({onBack:t}){const[e,n]=k.useState([]),[r,s]=k.useState(""),[i,o]=k.useState(null),[l,d]=k.useState(!1),f=k.useRef(null),h=k.useCallback(async()=>{try{const w=await fetch("/api/tasks");if(w.ok){const E=await w.json();n(E.tasks||[])}}catch{}},[]);k.useEffect(()=>{h()},[h]);const m=async()=>{const w=r.trim();if(w){s("");try{const E=await fetch("/api/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:w})});if(E.ok){const C=await E.json();n(A=>[...A,C.task])}}catch{}}},g=w=>{o(w),fetch(`/api/tasks/${w}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({completed:!0})}).catch(()=>{}),setTimeout(()=>{n(E=>E.filter(C=>C.id!==w)),o(null)},400)},y=async w=>{try{(await fetch(`/api/tasks/${w}`,{method:"DELETE"})).ok&&n(C=>C.filter(A=>A.id!==w))}catch{}},b=()=>{d(!0),setTimeout(()=>{var w;return(w=f.current)==null?void 0:w.focus()},0)},x=e.filter(w=>!w.completed);return u.jsxs("div",{className:"sidebar-tasks",children:[u.jsxs("div",{className:"sidebar-tasks-header",children:[u.jsx("button",{className:"sidebar-tasks-back",onClick:t,title:"Back to documents",children:u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"m15 18-6-6 6-6"})})}),u.jsx("h3",{children:"Tasks"}),u.jsx("button",{className:"sidebar-tasks-add-btn",onClick:b,title:"Add task",children:"+"})]}),x.length===0&&!l?u.jsxs("div",{className:"sidebar-tasks-empty",children:[u.jsx("div",{className:"sidebar-tasks-empty-title",children:"No tasks"}),u.jsx("div",{className:"sidebar-tasks-empty-desc",children:"Add tasks to track your checklist."})]}):u.jsx("div",{className:"sidebar-tasks-list",children:x.map(w=>u.jsxs("div",{className:`sidebar-tasks-item${i===w.id?" completing":""}`,children:[u.jsx("input",{type:"checkbox",className:"sidebar-tasks-checkbox",checked:i===w.id,onChange:()=>g(w.id)}),u.jsx("span",{className:`sidebar-tasks-text${i===w.id?" completed":""}`,children:w.text}),u.jsx("button",{className:"sidebar-tasks-delete",onClick:()=>y(w.id),title:"Remove",children:"×"})]},w.id))}),l&&u.jsx("div",{className:"sidebar-tasks-add",children:u.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 $8({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:o}){const[l,d]=k.useState(!1),[f,h]=k.useState(!1),[m,g]=k.useState(""),[y,b]=k.useState(null),x=k.useRef(null),w=k.useRef(null);k.useEffect(()=>{if(!l)return;const C=A=>{x.current&&!x.current.contains(A.target)&&(d(!1),h(!1),g(""),b(null))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[l]),k.useEffect(()=>{f&&w.current&&w.current.focus()},[f]);const E=()=>{const C=m.trim();C&&(s(C),g(""),h(!1))};return u.jsxs("div",{className:"sidebar-profile-wrapper",ref:x,children:[u.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>d(!l),title:`Profile: ${e}`,children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"8",r:"4"}),u.jsx("path",{d:"M5.5 21a8.38 8.38 0 0 1 13 0"})]})}),l&&u.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(C=>u.jsxs("div",{className:"sidebar-profile-row",children:[y===C?u.jsxs("div",{className:"sidebar-profile-confirm",children:[u.jsx("span",{children:"Delete?"}),u.jsxs("div",{className:"sidebar-inline-confirm",children:[u.jsx("button",{onClick:()=>{i(C),b(null)},children:"Yes"}),u.jsx("button",{onClick:()=>b(null),children:"No"})]})]}):u.jsx(u.Fragment,{children:u.jsxs("button",{className:`sidebar-profile-option ${C===e?"active":""}`,onClick:()=>{C!==e&&r(C),d(!1)},children:[u.jsx("span",{className:"sidebar-profile-check",children:C===e?"✓":""}),u.jsx("span",{children:C})]})}),C!=="Default"&&C!==e&&y!==C&&u.jsx("button",{className:"sidebar-profile-delete-btn",onClick:A=>{A.stopPropagation(),b(C)},title:"Delete profile",children:"×"})]},C)),n.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"sidebar-profile-divider"}),u.jsx("div",{className:"sidebar-profile-trash-label",children:"Trash"}),n.map(C=>u.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[u.jsx("span",{className:"sidebar-profile-trash-name",children:C}),u.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>o(C),children:"Restore"})]},C))]}),u.jsx("div",{className:"sidebar-profile-divider"}),f?u.jsx("div",{className:"sidebar-profile-add-input",children:u.jsx("input",{ref:w,type:"text",value:m,onChange:C=>g(C.target.value),onKeyDown:C=>{C.key==="Enter"&&E(),C.key==="Escape"&&(h(!1),g(""))},placeholder:"Profile name..."})}):u.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>h(!0),children:[u.jsx("span",{className:"sidebar-profile-check",children:"+"}),u.jsx("span",{children:"New Profile"})]})]})]})}const xw=200,ww=600,Tp=260;function kw({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,docTagsRefreshKey:s,workspacesRefreshKey:i,pendingDocs:o,writingTitle:l,writingTarget:d,pendingWriteFilenames:f,onClose:h}){const{docs:m,setDocs:g,workspaces:y,setWorkspaces:b,assignedFiles:x,fetchDocs:w,fetchWorkspaces:E,scrollRef:C,markPendingDelete:A}=r8(r,i),T=s8(w,E,g,b,m,A),_=Cd(),[O,R]=k.useState(()=>{try{const Ke=localStorage.getItem("ow-sidebar-width");if(Ke){const pt=parseInt(Ke,10);if(!isNaN(pt)&&pt>=xw&&pt<=ww)return pt}}catch{}return Tp}),B=k.useRef(!1),D=k.useCallback(Ke=>{Ke.preventDefault(),B.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const pt=Je=>{if(!B.current)return;const Y=Math.min(ww,Math.max(xw,Je.clientX));R(Y)},Ft=()=>{B.current=!1,document.body.style.cursor="",document.body.style.userSelect="",window.removeEventListener("pointermove",pt),window.removeEventListener("pointerup",Ft);try{localStorage.setItem("ow-sidebar-width",String(U.current))}catch{}};window.addEventListener("pointermove",pt),window.addEventListener("pointerup",Ft)},[]),U=k.useRef(O);U.current=O;const Q=k.useCallback(Ke=>{g(pt=>pt.map(Ft=>({...Ft,isActive:Ft.filename===Ke}))),e(Ke)},[g,e]),[P,W]=k.useState(!1),[$,H]=k.useState(!1),[J,re]=k.useState([]),[V,ie]=k.useState("Default"),z=k.useCallback(async()=>{try{const Ke=await fetch("/api/profiles");if(Ke.ok){const pt=await Ke.json();re(pt.profiles),ie(pt.active)}}catch{}},[]);k.useEffect(()=>{z()},[z]);const M=k.useCallback(async Ke=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ke})})).ok&&(ie(Ke),z())}catch{}},[z]),I=k.useCallback(async Ke=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ke})})).ok&&z()}catch{}},[z]),[Z,le]=k.useState([]),ge=k.useCallback(async()=>{try{const Ke=await fetch("/api/profiles/trash");if(Ke.ok){const pt=await Ke.json();le(pt.profiles)}}catch{}},[]);k.useEffect(()=>{ge()},[ge]);const se=k.useCallback(async Ke=>{try{(await fetch(`/api/profiles/${encodeURIComponent(Ke)}`,{method:"DELETE"})).ok&&(z(),ge())}catch{}},[z,ge]),xe=k.useCallback(async Ke=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Ke})})).ok&&(z(),ge())}catch{}},[z,ge]),[fe,De]=k.useState(""),[We,Qe]=k.useState(null),ot=k.useRef(),st=k.useRef(null),Ie=k.useCallback(Ke=>{if(De(Ke),ot.current&&clearTimeout(ot.current),!Ke.trim()){Qe(null);return}ot.current=setTimeout(async()=>{try{const pt=await fetch(`/api/documents/search?q=${encodeURIComponent(Ke.trim())}&archived=true`);pt.ok&&Qe(await pt.json())}catch{}},250)},[]);k.useEffect(()=>()=>{ot.current&&clearTimeout(ot.current)},[]);const dt={docs:m,archivedDocs:[],workspaces:y,assignedFiles:x,pendingDocs:o,writingTitle:l,writingTarget:d,pendingWriteFilenames:f,onSwitchDocument:Q,onCreateDocument:n,actions:T,scrollRef:C,searchQuery:fe,searchResults:We,onSearchChange:Ie},Ge=()=>{switch(_){case"files":return u.jsx(N8,{...dt});case"timeline":return u.jsx(d8,{...dt});case"board":return u.jsx(f8,{...dt});case"shelf":return u.jsx(h8,{...dt});default:return u.jsx(u8,{...dt})}},bt=u.jsxs("div",{className:"sidebar-search",children:[u.jsxs("svg",{className:"sidebar-search-icon",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"10.5",cy:"10.5",r:"7"}),u.jsx("path",{d:"m20 20-4.5-4.5"})]}),u.jsx("input",{ref:st,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:fe,onChange:Ke=>Ie(Ke.target.value)}),fe&&u.jsx("button",{className:"sidebar-search-clear",onClick:()=>Ie(""),title:"Clear search",children:"×"})]}),xt=t?{width:`${O}px`,minWidth:`${O}px`}:void 0,$t=t?u.jsx("div",{className:"sidebar-resize-handle",onPointerDown:D,onDoubleClick:()=>{R(Tp);try{localStorage.setItem("ow-sidebar-width",String(Tp))}catch{}},title:"Drag to resize · double-click to reset"}):null;return _==="board"?u.jsxs("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,style:xt,children:[Ge(),$t]}):u.jsxs("div",{className:`sidebar ${t?"open":""}`,style:xt,children:[u.jsxs("div",{className:"sidebar-topbar",children:[u.jsxs("div",{className:"sidebar-logo",children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("path",{d:"M17 3a2.83 2.83 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),u.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),u.jsxs("div",{className:"sidebar-topbar-actions",children:[u.jsx($8,{profiles:J,activeProfile:V,trashedProfiles:Z,onSwitch:M,onCreate:I,onDelete:se,onRestore:xe}),u.jsx("button",{className:`sidebar-collapse-btn${P?" sidebar-collapse-btn--active":""}`,onClick:()=>{W(!P),H(!1)},title:"Schedule",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("line",{x1:"16",x2:"16",y1:"1",y2:"5"}),u.jsx("line",{x1:"8",x2:"8",y1:"1",y2:"5"}),u.jsx("line",{x1:"3",x2:"21",y1:"9",y2:"9"})]})}),u.jsx("button",{className:`sidebar-collapse-btn${$?" sidebar-collapse-btn--active":""}`,onClick:()=>{H(!$),W(!1)},title:"Tasks",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),u.jsx("path",{d:"m9 12 2 2 4-4"})]})}),h&&u.jsx("button",{className:"sidebar-collapse-btn",onClick:h,title:"Close sidebar",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),u.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),$?u.jsx(z8,{onBack:()=>H(!1)}):P?u.jsx(P8,{onBack:()=>W(!1)}):u.jsxs(u.Fragment,{children:[bt,Ge()]}),$t]})}function F8({onClose:t,onSetupComplete:e}){const[n,r]=k.useState("detecting"),[s,i]=k.useState(null),[o,l]=k.useState("gh"),[d,f]=k.useState("openwriter-docs"),[h,m]=k.useState(!0),[g,y]=k.useState(""),[b,x]=k.useState(""),[w,E]=k.useState(""),[C,A]=k.useState("");k.useEffect(()=>{fetch("/api/sync/capabilities").then(_=>_.json()).then(_=>{i(_),_.ghAuthenticated?l("gh"):(_.gitInstalled,l("pat")),r("setup")}).catch(()=>{E("Failed to detect git capabilities"),r("error")})},[]);const T=k.useCallback(async()=>{r("progress"),A(o==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const _={method:o,repoName:d,isPrivate:h};o==="pat"&&(_.pat=g),o==="connect"&&(_.remoteUrl=b,_.pat=g||void 0);const O=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!O.ok){const R=await O.json().catch(()=>({}));throw new Error(R.error||`Setup failed (${O.status})`)}r("done"),e()}catch(_){E(_.message),r("error")}},[o,d,h,g,b,e]);return u.jsx("div",{className:"sync-modal-overlay",onClick:t,children:u.jsxs("div",{className:"sync-modal",onClick:_=>_.stopPropagation(),children:[u.jsxs("div",{className:"sync-modal-header",children:[u.jsx("h2",{children:"Sync to GitHub"}),u.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-spinner"}),u.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&s&&u.jsxs("div",{className:"sync-modal-body",children:[!s.gitInstalled&&u.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",u.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),s.gitInstalled&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"sync-tabs",children:[s.ghAuthenticated&&u.jsx("button",{className:`sync-tab${o==="gh"?" active":""}`,onClick:()=>l("gh"),children:"GitHub CLI"}),u.jsx("button",{className:`sync-tab${o==="pat"?" active":""}`,onClick:()=>l("pat"),children:"Personal Access Token"}),u.jsx("button",{className:`sync-tab${o==="connect"?" active":""}`,onClick:()=>l("connect"),children:"Connect Existing"})]}),o==="gh"&&u.jsxs("div",{className:"sync-form",children:[u.jsxs("label",{children:["Repository name",u.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),u.jsxs("label",{className:"sync-checkbox",children:[u.jsx("input",{type:"checkbox",checked:h,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),o==="pat"&&u.jsxs("div",{className:"sync-form",children:[!s.ghAuthenticated&&!s.ghInstalled&&u.jsxs("p",{className:"sync-hint",children:["Create a ",u.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",u.jsx("code",{children:"repo"})," scope."]}),u.jsxs("label",{children:["Personal Access Token",u.jsx("input",{type:"password",value:g,onChange:_=>y(_.target.value),placeholder:"ghp_..."})]}),u.jsxs("label",{children:["Repository name",u.jsx("input",{type:"text",value:d,onChange:_=>f(_.target.value),placeholder:"openwriter-docs"})]}),u.jsxs("label",{className:"sync-checkbox",children:[u.jsx("input",{type:"checkbox",checked:h,onChange:_=>m(_.target.checked)}),"Private repository"]})]}),o==="connect"&&u.jsxs("div",{className:"sync-form",children:[u.jsxs("label",{children:["Remote URL",u.jsx("input",{type:"text",value:b,onChange:_=>x(_.target.value),placeholder:"https://github.com/user/repo.git"})]}),u.jsxs("label",{children:["PAT (optional, for private repos)",u.jsx("input",{type:"password",value:g,onChange:_=>y(_.target.value),placeholder:"ghp_..."})]})]}),u.jsxs("div",{className:"sync-modal-actions",children:[u.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),u.jsx("button",{className:"sync-btn primary",onClick:T,disabled:o==="pat"&&!g||o==="connect"&&!b||o!=="connect"&&!d,children:o==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-spinner"}),u.jsx("p",{children:C})]}),n==="done"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-success-icon",children:"✓"}),u.jsx("p",{children:"Successfully synced to GitHub!"}),u.jsx("div",{className:"sync-modal-actions",children:u.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&u.jsxs("div",{className:"sync-modal-body",children:[u.jsx("div",{className:"sync-error-msg",children:w}),u.jsxs("div",{className:"sync-modal-actions",children:[u.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),u.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function U8({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:y,getEditorState:b}){const x=k.useRef(null),[w,E]=k.useState(!1),C=k.useRef(0),A=k.useRef(new Set),T=()=>{var M;return(M=re.current)==null?void 0:M.call(re,new Set(A.current))},_=k.useRef(t),O=k.useRef(e),R=k.useRef(n),B=k.useRef(s),D=k.useRef(i),U=k.useRef(o),Q=k.useRef(l),P=k.useRef(f),W=k.useRef(d),$=k.useRef(h),H=k.useRef(m),J=k.useRef(g),re=k.useRef(y),V=k.useRef(r),ie=k.useRef(b);_.current=t,O.current=e,R.current=n,B.current=s,D.current=i,U.current=o,Q.current=l,W.current=d,P.current=f,$.current=h,H.current=m,J.current=g,re.current=y,V.current=r,ie.current=b,k.useEffect(()=>{const I=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let Z,le=!1,ge=1e3;function se(){const fe=new WebSocket(I);x.current=fe,fe.onopen=()=>{E(!0),ge=1e3,le&&fe.send(JSON.stringify({type:"request-document"})),le=!0},fe.onmessage=De=>{var We,Qe,ot,st,Ie,dt,Ge,bt,xt,$t,Ke,pt,Ft,Je;try{const Y=JSON.parse(De.data);if(Y.type==="node-changes"&&Y.changes&&((We=_.current)==null||We.call(_,Y.changes),typeof Y.version=="number"&&(C.current=Y.version)),Y.type==="id-rewrites"&&Array.isArray(Y.rewrites)&&((Qe=J.current)==null||Qe.call(J,Y.rewrites)),Y.type==="agent-status"&&((ot=O.current)==null||ot.call(O,!!Y.agentConnected)),Y.type==="document-switched"&&(C.current=0,(st=R.current)==null||st.call(R,{document:Y.document,title:Y.title,filename:Y.filename,docId:Y.docId,metadata:Y.metadata})),Y.type==="document-reloaded"&&(typeof Y.version=="number"&&(C.current=Y.version),(Ie=V.current)==null||Ie.call(V,{document:Y.document,title:Y.title,filename:Y.filename,docId:Y.docId,metadata:Y.metadata,orphanCount:typeof Y.orphanCount=="number"?Y.orphanCount:0,staleBaselineCount:typeof Y.staleBaselineCount=="number"?Y.staleBaselineCount:0})),Y.type==="metadata-changed"&&Y.metadata&&((dt=W.current)==null||dt.call(W,Y.metadata)),Y.type==="documents-changed"&&((Ge=B.current)==null||Ge.call(B)),Y.type==="workspaces-changed"&&((bt=D.current)==null||bt.call(D)),Y.type==="title-changed"&&Y.title&&((xt=U.current)==null||xt.call(U,Y.title)),Y.type==="pending-docs-changed"&&Y.pendingDocs&&(($t=Q.current)==null||$t.call(Q,Y.pendingDocs)),Y.type==="sync-status"&&((Ke=P.current)==null||Ke.call(P,{state:Y.state,lastSyncTime:Y.lastSyncTime,pendingFiles:Y.pendingFiles,error:Y.error})),Y.type==="writing-started"&&Y.title&&(typeof Y.key=="string"&&(A.current.add(Y.key),T()),(pt=$.current)==null||pt.call($,Y.title,Y.target||null)),Y.type==="writing-finished"&&(typeof Y.key=="string"&&Y.key?A.current.delete(Y.key):A.current.clear(),T(),(Ft=H.current)==null||Ft.call(H)),Y.type==="pending-writes-sync"&&Array.isArray(Y.writes)&&(A.current=new Set(Y.writes.map(pe=>pe.key).filter(Boolean)),T(),Y.writes.length>0)){const pe=Y.writes.reduce((G,oe)=>G.startedAt>oe.startedAt?G:oe);pe!=null&&pe.title&&((Je=$.current)==null||Je.call($,pe.title,pe.target||null))}Y.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),Y.type==="comments-changed"&&Y.filename&&window.dispatchEvent(new CustomEvent("ow-comments-changed",{detail:{filename:Y.filename}}))}catch{}},fe.onclose=()=>{E(!1),Z=setTimeout(se,ge),ge=Math.min(ge*1.5,8e3)},fe.onerror=()=>{fe.close()}}se();function xe(){var fe;document.visibilityState==="visible"&&((fe=x.current)==null?void 0:fe.readyState)!==WebSocket.OPEN&&(clearTimeout(Z),ge=1e3,se())}return document.addEventListener("visibilitychange",xe),()=>{clearTimeout(Z),document.removeEventListener("visibilitychange",xe),x.current&&(x.current.onclose=null,x.current.close())}},[]);const z=k.useCallback(M=>{var I;((I=x.current)==null?void 0:I.readyState)===WebSocket.OPEN&&x.current.send(JSON.stringify(M))},[]);return{connected:w,sendMessage:z,docVersionRef:C}}function H8(t){const[e,n]=k.useState(null),[r,s]=k.useState(!1),[i,o]=k.useState(null),l=k.useRef(void 0);return k.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 W8(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(`
|
|
208
|
-
|
|
209
|
-
`)}function q8(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 V8(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 K8(t,e){const[n,r]=k.useState("idle"),s=k.useRef();return{copyText:k.useCallback(async()=>{const o=t.current[e];if(!o)return;const l=W8(o),d=q8(o);if(!(!l&&!d)){try{const f={};if(l&&(f["text/plain"]=new Blob([l],{type:"text/plain"})),d){const h=await V8(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 Mp(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 G8(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 J8=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.jsx("path",{fill:"currentColor",d:"M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z"})}),Y8=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.jsx("path",{fill:"currentColor",d:"M4.5 3.88l4.432 4.14-1.364 1.46L5.5 7.55V16c0 1.1.896 2 2 2H13v2H7.5c-2.209 0-4-1.79-4-4V7.55L1.432 9.48.068 8.02 4.5 3.88zM16.5 6H11V4h5.5c2.209 0 4 1.79 4 4v8.45l2.068-1.93 1.364 1.46-4.432 4.14-4.432-4.14 1.364-1.46 2.068 1.93V8c0-1.1-.896-2-2-2z"})}),X8=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.jsx("path",{fill:"currentColor",d:"M16.697 5.5c-1.222-.06-2.679.51-3.89 2.16l-.805 1.09-.806-1.09C9.984 6.01 8.526 5.44 7.304 5.5c-1.243.07-2.349.78-2.91 1.91-.552 1.12-.633 2.78.479 4.82 1.074 1.97 3.257 4.27 7.129 6.61 3.87-2.34 6.052-4.64 7.126-6.61 1.111-2.04 1.03-3.7.477-4.82-.561-1.13-1.666-1.84-2.908-1.91zm4.187 7.69c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z"})}),Q8=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.jsx("path",{fill:"currentColor",d:"M4 4.5C4 3.12 5.119 2 6.5 2h11C18.881 2 20 3.12 20 4.5v18.44l-8-5.71-8 5.71V4.5zM6.5 4c-.276 0-.5.22-.5.5v14.56l6-4.29 6 4.29V4.5c0-.28-.224-.5-.5-.5h-11z"})}),Z8=()=>u.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:u.jsx("path",{fill:"currentColor",d:"M12 2.59l5.7 5.7-1.41 1.42L13 6.41V16h-2V6.41l-3.3 3.3-1.41-1.42L12 2.59zM21 15l-.02 3.51c0 1.38-1.12 2.49-2.5 2.49H5.5C4.11 21 3 19.88 3 18.5V15h2v3.5c0 .28.22.5.5.5h12.98c.28 0 .5-.22.5-.5L19 15h2z"})});function x2({tweet:t,nested:e,url:n}){const r=G8(t.createdAt);return u.jsxs("div",{className:`tweet-embed-card${e?" tweet-embed-nested":""}${n?" tweet-embed-card--clickable":""}`,onClick:n?()=>window.open(n,"_blank","noopener,noreferrer"):void 0,role:n?"link":void 0,children:[u.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?u.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):u.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),u.jsxs("div",{className:"tweet-author-info",children:[u.jsx("span",{className:"tweet-author-name",children:t.author.name}),u.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),r&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"tweet-author-separator",children:"·"}),u.jsx("span",{className:"tweet-author-timestamp",children:r})]})]})]}),u.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&u.jsx("div",{className:"tweet-media","data-count":t.media.length,children:t.media.map((s,i)=>s.type==="photo"?u.jsx("img",{className:"tweet-media-img",src:s.url,alt:"",loading:"lazy"},i):s.type==="video"||s.type==="gif"?u.jsx("div",{className:"tweet-media-video-placeholder",children:u.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&u.jsx(x2,{tweet:t.quoteTweet,nested:!0}),!e&&u.jsxs("div",{className:"tweet-actions-row",children:[u.jsxs("span",{className:"tweet-action tweet-action-reply",children:[u.jsx(J8,{}),t.metrics.replies>0&&Mp(t.metrics.replies)]}),u.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[u.jsx(Y8,{}),t.metrics.retweets>0&&Mp(t.metrics.retweets)]}),u.jsxs("span",{className:"tweet-action tweet-action-like",children:[u.jsx(X8,{}),t.metrics.likes>0&&Mp(t.metrics.likes)]}),u.jsx("span",{className:"tweet-action tweet-action-bookmark",children:u.jsx(Q8,{})}),u.jsx("span",{className:"tweet-action tweet-action-share",children:u.jsx(Z8,{})})]})]})}function Sw({tweet:t,url:e}){return u.jsx(x2,{tweet:t,url:e})}function ez({initialContent:t,initialPreviewImages:e,placeholder:n="What is happening?!",onUpdate:r,onReady:s,onFocus:i,onPreviewImagesChange:o}){const[l,d]=k.useState(e||[]),f=k.useRef(e||[]),h=k.useRef(!1),m=k.useRef(s);m.current=s;const g=k.useRef(o);g.current=o;const y=k.useCallback(E=>{var A;const C=E.slice(0,4);f.current=C,d(C),(A=g.current)==null||A.call(g,C)},[]),b=k.useCallback(E=>{if(h.current)return;const C=[],A=[];if(E.state.doc.descendants((R,B)=>{var D;R.type.name==="image"&&((D=R.attrs)!=null&&D.src)&&(C.push(R.attrs.src),A.push({from:B,to:B+R.nodeSize}))}),C.length===0)return;h.current=!0;const{tr:T}=E.state;for(let R=A.length-1;R>=0;R--)T.delete(A[R].from,A[R].to);E.view.dispatch(T);const _=f.current,O=4-_.length;O>0&&y([..._,...C.slice(0,O)]),h.current=!1},[y]),x=AC({extensions:[...q_,Fd.configure({placeholder:n})],content:t||"<p></p>",onCreate:({editor:E})=>{b(E)},onUpdate:({editor:E})=>{b(E),r==null||r(E)},onFocus:()=>{i==null||i()},editorProps:{handlePaste:e2,handleDrop:t2}},[t]);k.useEffect(()=>{x&&GB(x.view,{addToPreview:E=>{const C=f.current;C.length>=4||y([...C,E])},getPreviewImages:()=>f.current})},[x,y]),k.useEffect(()=>{if(!x)return;const{state:E}=x.view;if(E.plugins.some(T=>T.key==="pendingDecoration$"))return;const C=Y_(),A=E.reconfigure({plugins:[...E.plugins,C]});x.view.updateState(A)},[x]),k.useEffect(()=>{if(!x)return;const{state:E}=x.view;if(E.plugins.some(T=>T.key==="commentDecoration$"))return;const C=Q_(),A=E.reconfigure({plugins:[...E.plugins,C]});x.view.updateState(A)},[x]),k.useEffect(()=>{var E;x&&((E=m.current)==null||E.call(m,x))},[x]);const w=k.useCallback(E=>{y(f.current.filter((C,A)=>A!==E))},[y]);return x?u.jsxs(u.Fragment,{children:[u.jsx(kv,{editor:x}),l.length>0&&u.jsx("div",{className:"tweet-preview-grid","data-count":l.length,children:l.map((E,C)=>u.jsxs("div",{className:"tweet-image-card",children:[u.jsx("img",{className:"tweet-image-card-img",src:E,alt:"",draggable:!1}),u.jsx("button",{className:"tweet-image-card-remove",onClick:()=>w(C),title:"Remove image",children:"×"})]},E))})]}):null}function tz({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:u.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:i,height:i},children:[u.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[u.jsx("circle",{cx:i/2,cy:i/2,r:l,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:o}),u.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&&u.jsx("span",{className:"tweet-char-number",style:{color:h,fontSize:n<-9||n>9?10:11},children:n})]})}const Ew="@openwriter/plugin-x-api",Nw=[{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 nz({onConnected:t,onCancel:e}){const[n,r]=k.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=k.useState(!1),[o,l]=k.useState(""),d=Nw.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:Ew,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:Ew})})).json();if(!g.success)throw new Error(g.error||"Failed to enable plugin");const b=await(await fetch("/api/x/status")).json();b.connected?t():l(b.error||"Could not verify X credentials. Check your API keys.")}catch(h){l(h.message||"Connection failed")}finally{i(!1)}};return u.jsxs("div",{className:"x-connect-prompt",children:[u.jsxs("div",{className:"x-connect-header",children:[u.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),u.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:u.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:u.jsx("path",{fill:"currentColor",d:"M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"})})})]}),u.jsx("div",{className:"x-connect-fields",children:Nw.map(h=>u.jsxs("div",{className:"x-connect-field",children:[u.jsx("label",{className:"x-connect-label",children:h.label}),u.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&&u.jsx("div",{className:"x-connect-error",children:o}),u.jsxs("div",{className:"x-connect-actions",children:[u.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),u.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!d||s,children:s?"Connecting...":"Connect"})]})]})}var Cw={},Ap,_w;function Os(){return _w||(_w=1,Ap=function(t){return typeof t=="object"?t!==null:typeof t=="function"}),Ap}var jp,Tw;function wr(){if(Tw)return jp;Tw=1;var t=Os();return jp=function(e){if(!t(e))throw TypeError(e+" is not an object!");return e},jp}var Op,Mw;function qd(){return Mw||(Mw=1,Op=function(t){if(t==null)throw TypeError("Can't call method on "+t);return t}),Op}var Rp,Aw;function wi(){if(Aw)return Rp;Aw=1;var t=qd();return Rp=function(e){return Object(t(e))},Rp}var Ip,jw;function Vd(){if(jw)return Ip;jw=1;var t=Math.ceil,e=Math.floor;return Ip=function(n){return isNaN(n=+n)?0:(n>0?e:t)(n)},Ip}var Lp,Ow;function ao(){if(Ow)return Lp;Ow=1;var t=Vd(),e=Math.min;return Lp=function(n){return n>0?e(t(n),9007199254740991):0},Lp}var Dp,Rw;function w2(){if(Rw)return Dp;Rw=1;var t=Vd(),e=qd();return Dp=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)}},Dp}var Pp,Iw;function Qv(){if(Iw)return Pp;Iw=1;var t=w2()(!0);return Pp=function(e,n,r){return n+(r?t(e,n).length:1)},Pp}var Bp,Lw;function Kd(){if(Lw)return Bp;Lw=1;var t={}.toString;return Bp=function(e){return t.call(e).slice(8,-1)},Bp}var zp={exports:{}},$p={exports:{}},Fp={exports:{}},Dw;function oa(){if(Dw)return Fp.exports;Dw=1;var t=Fp.exports={version:"2.6.12"};return typeof __e=="number"&&(__e=t),Fp.exports}var Up={exports:{}},Pw;function Dr(){if(Pw)return Up.exports;Pw=1;var t=Up.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();return typeof __g=="number"&&(__g=t),Up.exports}var Hp,Bw;function Gd(){return Bw||(Bw=1,Hp=!1),Hp}var zw;function Jd(){if(zw)return $p.exports;zw=1;var t=oa(),e=Dr(),n="__core-js_shared__",r=e[n]||(e[n]={});return($p.exports=function(s,i){return r[s]||(r[s]=i!==void 0?i:{})})("versions",[]).push({version:t.version,mode:Gd()?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"}),$p.exports}var Wp,$w;function Ol(){if($w)return Wp;$w=1;var t=0,e=Math.random();return Wp=function(n){return"Symbol(".concat(n===void 0?"":n,")_",(++t+e).toString(36))},Wp}var Fw;function Ln(){if(Fw)return zp.exports;Fw=1;var t=Jd()("wks"),e=Ol(),n=Dr().Symbol,r=typeof n=="function",s=zp.exports=function(i){return t[i]||(t[i]=r&&n[i]||(r?n:e)("Symbol."+i))};return s.store=t,zp.exports}var qp,Uw;function Zv(){if(Uw)return qp;Uw=1;var t=Kd(),e=Ln()("toStringTag"),n=t((function(){return arguments})())=="Arguments",r=function(s,i){try{return s[i]}catch{}};return qp=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},qp}var Vp,Hw;function e0(){if(Hw)return Vp;Hw=1;var t=Zv(),e=RegExp.prototype.exec;return Vp=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)},Vp}var Ww={},Kp,qw;function Yd(){if(qw)return Kp;qw=1;var t=wr();return Kp=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},Kp}var Gp,Vw;function t0(){if(Vw)return Gp;Vw=1;var t=Yd(),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,y,b;return o&&(g=new RegExp("^"+h.source+"$(?!\\s)",t.call(h))),i&&(m=h[s]),y=e.call(h,f),i&&y&&(h[s]=h.global?y.index+y[0].length:m),o&&y&&y.length>1&&n.call(y[0],g,function(){for(b=1;b<arguments.length-2;b++)arguments[b]===void 0&&(y[b]=void 0)}),y}),Gp=r,Gp}var Jp={},Yp,Kw;function Yr(){return Kw||(Kw=1,Yp=function(t){try{return!!t()}catch{return!0}}),Yp}var Xp,Gw;function Pr(){return Gw||(Gw=1,Xp=!Yr()(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})),Xp}var Qp,Jw;function k2(){if(Jw)return Qp;Jw=1;var t=Os(),e=Dr().document,n=t(e)&&t(e.createElement);return Qp=function(r){return n?e.createElement(r):{}},Qp}var Zp,Yw;function S2(){return Yw||(Yw=1,Zp=!Pr()&&!Yr()(function(){return Object.defineProperty(k2()("div"),"a",{get:function(){return 7}}).a!=7})),Zp}var em,Xw;function n0(){if(Xw)return em;Xw=1;var t=Os();return em=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")},em}var Qw;function Xr(){if(Qw)return Jp;Qw=1;var t=wr(),e=S2(),n=n0(),r=Object.defineProperty;return Jp.f=Pr()?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},Jp}var tm,Zw;function Rl(){return Zw||(Zw=1,tm=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}),tm}var nm,ek;function ki(){if(ek)return nm;ek=1;var t=Xr(),e=Rl();return nm=Pr()?function(n,r,s){return t.f(n,r,e(1,s))}:function(n,r,s){return n[r]=s,n},nm}var rm={exports:{}},sm,tk;function lo(){if(tk)return sm;tk=1;var t={}.hasOwnProperty;return sm=function(e,n){return t.call(e,n)},sm}var im,nk;function rz(){return nk||(nk=1,im=Jd()("native-function-to-string",Function.toString)),im}var rk;function Rs(){if(rk)return rm.exports;rk=1;var t=Dr(),e=ki(),n=lo(),r=Ol()("src"),s=rz(),i="toString",o=(""+s).split(i);return oa().inspectSource=function(l){return s.call(l)},(rm.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)}),rm.exports}var om,sk;function Xd(){return sk||(sk=1,om=function(t){if(typeof t!="function")throw TypeError(t+" is not a function!");return t}),om}var am,ik;function Qd(){if(ik)return am;ik=1;var t=Xd();return am=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)}},am}var lm,ok;function hr(){if(ok)return lm;ok=1;var t=Dr(),e=oa(),n=ki(),r=Rs(),s=Qd(),i="prototype",o=function(l,d,f){var h=l&o.F,m=l&o.G,g=l&o.S,y=l&o.P,b=l&o.B,x=m?t:g?t[d]||(t[d]={}):(t[d]||{})[i],w=m?e:e[d]||(e[d]={}),E=w[i]||(w[i]={}),C,A,T,_;m&&(f=d);for(C in f)A=!h&&x&&x[C]!==void 0,T=(A?x:f)[C],_=b&&A?s(T,t):y&&typeof T=="function"?s(Function.call,T):T,x&&r(x,C,T,l&o.U),w[C]!=T&&n(w,C,_),y&&E[C]!=T&&(E[C]=T)};return t.core=e,o.F=1,o.G=2,o.S=4,o.P=8,o.B=16,o.W=32,o.U=64,o.R=128,lm=o,lm}var ak;function sz(){if(ak)return Ww;ak=1;var t=t0();return hr()({target:"RegExp",proto:!0,forced:t!==/./.exec},{exec:t}),Ww}var cm,lk;function r0(){if(lk)return cm;lk=1,sz();var t=Rs(),e=ki(),n=Yr(),r=qd(),s=Ln(),i=t0(),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 cm=function(f,h,m){var g=s(f),y=!n(function(){var A={};return A[g]=function(){return 7},""[f](A)!=7}),b=y?!n(function(){var A=!1,T=/a/;return T.exec=function(){return A=!0,null},f==="split"&&(T.constructor={},T.constructor[o]=function(){return T}),T[g](""),!A}):void 0;if(!y||!b||f==="replace"&&!l||f==="split"&&!d){var x=/./[g],w=m(r,g,""[f],function(T,_,O,R,B){return _.exec===i?y&&!B?{done:!0,value:x.call(_,O,R)}:{done:!0,value:T.call(O,_,R)}:{done:!1}}),E=w[0],C=w[1];t(String.prototype,f,E),e(RegExp.prototype,g,h==2?function(A,T){return C.call(A,this,T)}:function(A){return C.call(A,this)})}},cm}var ck;function iz(){if(ck)return Cw;ck=1;var t=wr(),e=wi(),n=ao(),r=Vd(),s=Qv(),i=e0(),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 r0()("replace",2,function(g,y,b,x){return[function(C,A){var T=g(this),_=C==null?void 0:C[y];return _!==void 0?_.call(C,T,A):b.call(String(T),C,A)},function(E,C){var A=x(b,E,this,C);if(A.done)return A.value;var T=t(E),_=String(this),O=typeof C=="function";O||(C=String(C));var R=T.global;if(R){var B=T.unicode;T.lastIndex=0}for(var D=[];;){var U=i(T,_);if(U===null||(D.push(U),!R))break;var Q=String(U[0]);Q===""&&(T.lastIndex=s(_,n(T.lastIndex),B))}for(var P="",W=0,$=0;$<D.length;$++){U=D[$];for(var H=String(U[0]),J=o(l(r(U.index),_.length),0),re=[],V=1;V<U.length;V++)re.push(m(U[V]));var ie=U.groups;if(O){var z=[H].concat(re,J,_);ie!==void 0&&z.push(ie);var M=String(C.apply(void 0,z))}else M=w(H,_,J,re,ie,C);J>=W&&(P+=_.slice(W,J)+M,W=J+H.length)}return P+_.slice(W)}];function w(E,C,A,T,_,O){var R=A+E.length,B=T.length,D=h;return _!==void 0&&(_=e(_),D=f),b.call(O,D,function(U,Q){var P;switch(Q.charAt(0)){case"$":return"$";case"&":return E;case"`":return C.slice(0,A);case"'":return C.slice(R);case"<":P=_[Q.slice(1,-1)];break;default:var W=+Q;if(W===0)return U;if(W>B){var $=d(W/10);return $===0?U:$<=B?T[$-1]===void 0?Q.charAt(1):T[$-1]+Q.charAt(1):U}P=T[W-1]}return P===void 0?"":P})}}),Cw}iz();var uk={},um,dk;function s0(){if(dk)return um;dk=1;var t=Kd();return um=Object("z").propertyIsEnumerable(0)?Object:function(e){return t(e)=="String"?e.split(""):Object(e)},um}var dm,fk;function co(){if(fk)return dm;fk=1;var t=s0(),e=qd();return dm=function(n){return t(e(n))},dm}var fm,hk;function oz(){if(hk)return fm;hk=1;var t=Vd(),e=Math.max,n=Math.min;return fm=function(r,s){return r=t(r),r<0?e(r+s,0):n(r,s)},fm}var hm,pk;function E2(){if(pk)return hm;pk=1;var t=co(),e=ao(),n=oz();return hm=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}},hm}var pm,mk;function Il(){if(mk)return pm;mk=1;var t=Yr();return pm=function(e,n){return!!e&&t(function(){n?e.call(null,function(){},1):e.call(null)})},pm}var gk;function az(){if(gk)return uk;gk=1;var t=hr(),e=E2()(!1),n=[].indexOf,r=!!n&&1/[1].indexOf(1,-0)<0;return t(t.P+t.F*(r||!Il()(n)),"Array",{indexOf:function(i){return r?n.apply(this,arguments)||0:e(this,i,arguments[1])}}),uk}az();var lz=/[a-z]{1,6}(?:[._][a-z]{1,2})?/i,N2=/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$/,vk={},mm={},gm={},yk;function i0(){return yk||(yk=1,gm.f={}.propertyIsEnumerable),gm}var bk;function o0(){if(bk)return mm;bk=1;var t=i0(),e=Rl(),n=co(),r=n0(),s=lo(),i=S2(),o=Object.getOwnPropertyDescriptor;return mm.f=Pr()?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])},mm}var vm,xk;function cz(){if(xk)return vm;xk=1;var t=Os(),e=wr(),n=function(r,s){if(e(r),!t(s)&&s!==null)throw TypeError(s+": can't set as prototype!")};return vm={set:Object.setPrototypeOf||("__proto__"in{}?(function(r,s,i){try{i=Qd()(Function.call,o0().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},vm}var ym,wk;function uz(){if(wk)return ym;wk=1;var t=Os(),e=cz().set;return ym=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},ym}var bm={},xm,kk;function a0(){if(kk)return xm;kk=1;var t=Jd()("keys"),e=Ol();return xm=function(n){return t[n]||(t[n]=e(n))},xm}var wm,Sk;function C2(){if(Sk)return wm;Sk=1;var t=lo(),e=co(),n=E2()(!1),r=a0()("IE_PROTO");return wm=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},wm}var km,Ek;function l0(){return Ek||(Ek=1,km="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")),km}var Nk;function Zd(){if(Nk)return bm;Nk=1;var t=C2(),e=l0().concat("length","prototype");return bm.f=Object.getOwnPropertyNames||function(r){return t(r,e)},bm}var Sm,Ck;function _2(){if(Ck)return Sm;Ck=1;var t=Os(),e=Kd(),n=Ln()("match");return Sm=function(r){var s;return t(r)&&((s=r[n])!==void 0?!!s:e(r)=="RegExp")},Sm}var Em,_k;function dz(){if(_k)return Em;_k=1;var t=Dr(),e=Xr(),n=Pr(),r=Ln()("species");return Em=function(s){var i=t[s];n&&i&&!i[r]&&e.f(i,r,{configurable:!0,get:function(){return this}})},Em}var Tk;function fz(){if(Tk)return vk;Tk=1;var t=Dr(),e=uz(),n=Xr().f,r=Zd().f,s=_2(),i=Yd(),o=t.RegExp,l=o,d=o.prototype,f=/a/g,h=/a/g,m=new o(f)!==f;if(Pr()&&(!m||Yr()(function(){return h[Ln()("match")]=!1,o(f)!=f||o(h)==h||o(f,"i")!="/a/i"}))){o=function(w,E){var C=this instanceof o,A=s(w),T=E===void 0;return!C&&A&&w.constructor===o&&T?w:e(m?new l(A&&!T?w.source:w,E):l((A=w instanceof o)?w.source:w,A&&T?i.call(w):E),C?this:d,o)};for(var g=function(x){x in o||n(o,x,{configurable:!0,get:function(){return l[x]},set:function(w){l[x]=w}})},y=r(l),b=0;y.length>b;)g(y[b++]);d.constructor=o,o.prototype=d,Rs()(t,"RegExp",o)}return dz()("RegExp"),vk}fz();function Et(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 T2=/\x09-\x0D\x20\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000/;const M2=Et(/[#{spacesGroup}]/,{spacesGroup:T2});Et("(^|#{spaces})(\\$)(#{cashtag})(?=$|\\s|[#{punct}])",{cashtag:lz,spaces:M2,punct:N2},"gi");var Mk={},Ak;function hz(){if(Ak)return Mk;Ak=1;var t=wr(),e=ao(),n=Qv(),r=e0();return r0()("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 y=[],b=0,x;(x=r(h,m))!==null;){var w=String(x[0]);y[b]=w,w===""&&(h.lastIndex=n(m,e(h.lastIndex),g)),b++}return b===0?null:y}]}),Mk}hz();var A2=/[##]/;Et(/^(?:#{hashSigns}|:\/\/)/,{hashSigns:A2});var j2=Et(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@+-]|$))")),O2=/\u202A-\u202E\u061C\u200E\u200F\u2066\u2067\u2068\u2069/,c0=/\uFFFE\uFEFF\uFFFF/;function pz(t,e){return t.replace(/#\{(\w+)\}/g,function(n,r){return e[r]||""})}var mz=pz("#{punct}#{spacesGroup}#{invalidCharsGroup}#{directionalMarkersGroup}",{punct:N2,spacesGroup:T2,invalidCharsGroup:c0,directionalMarkersGroup:O2}),R2=Et(/[^#{invalidDomainChars}]/,{invalidDomainChars:mz}),gz=Et(/(?:(?:#{validDomainChars}(?:-|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:R2}),I2=Et(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@+-]|$))")),L2=/(?:xn--[\-0-9a-z]+)/,vz=Et(/(?:(?:#{validDomainChars}(?:[_-]|#{validDomainChars})*)?#{validDomainChars}\.)/,{validDomainChars:R2}),yz=Et(/(?:#{validSubdomain}*#{validDomainName}(?:#{validGTLD}|#{validCCTLD}|#{validPunycode}))/,{validDomainName:gz,validSubdomain:vz,validGTLD:I2,validCCTLD:j2,validPunycode:L2}),bz=/[0-9]+/,D2=/\u0400-\u04FF/,ef=/\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/,P2=Et(/[a-z#{cyrillicLettersAndMarks}0-9!\*';:=\+,\.\$\/%#\[\]\-\u2013_~@\|&#{latinAccentChars}]/i,{cyrillicLettersAndMarks:D2,latinAccentChars:ef}),B2=Et("\\((?:#{validGeneralUrlPathChars}+|(?:#{validGeneralUrlPathChars}*\\(#{validGeneralUrlPathChars}+\\)#{validGeneralUrlPathChars}*))\\)",{validGeneralUrlPathChars:P2},"i"),xz=Et(/[\+\-a-z#{cyrillicLettersAndMarks}0-9=_#\/#{latinAccentChars}]|(?:#{validUrlBalancedParens})/i,{cyrillicLettersAndMarks:D2,latinAccentChars:ef,validUrlBalancedParens:B2}),wz=Et("(?:(?:#{validGeneralUrlPathChars}*(?:#{validUrlBalancedParens}#{validGeneralUrlPathChars}*)*#{validUrlPathEndingChars})|(?:@#{validGeneralUrlPathChars}+/))",{validGeneralUrlPathChars:P2,validUrlBalancedParens:B2,validUrlPathEndingChars:xz},"i"),kz=Et(/(?:[^A-Za-z0-9@@$###{invalidCharsGroup}]|[#{directionalMarkersGroup}]|^)/,{invalidCharsGroup:c0,directionalMarkersGroup:O2}),z2=/[a-z0-9!?\*'@\(\);:&=\+\$\/%#\[\]\-_\.,~|]/i,$2=/[a-z0-9\-_&=#\/]/i,jk=Et("((#{validUrlPrecedingChars})((https?:\\/\\/)?(#{validDomain})(?::(#{validPortNumber}))?(\\/#{validUrlPath}*)?(\\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?))",{validUrlPrecedingChars:kz,validDomain:yz,validPortNumber:bz,validUrlPath:wz,validUrlQueryChars:z2,validUrlQueryEndingChars:$2},"gi"),Sz=/[-_.\/]$/,Ok={},Nm,Rk;function Ez(){if(Rk)return Nm;Rk=1;var t=wr(),e=Xd(),n=Ln()("species");return Nm=function(r,s){var i=t(r).constructor,o;return i===void 0||(o=t(i)[n])==null?s:e(o)},Nm}var Ik;function Nz(){if(Ik)return Ok;Ik=1;var t=_2(),e=wr(),n=Ez(),r=Qv(),s=ao(),i=e0(),o=t0(),l=Yr(),d=Math.min,f=[].push,h="split",m="length",g="lastIndex",y=4294967295,b=!l(function(){});return r0()("split",2,function(x,w,E,C){var A;return"abbc"[h](/(b)*/)[1]=="c"||"test"[h](/(?:)/,-1)[m]!=4||"ab"[h](/(?:ab)*/)[m]!=2||"."[h](/(.?)(.?)/)[m]!=4||"."[h](/()()/)[m]>1||""[h](/.?/)[m]?A=function(T,_){var O=String(this);if(T===void 0&&_===0)return[];if(!t(T))return E.call(O,T,_);for(var R=[],B=(T.ignoreCase?"i":"")+(T.multiline?"m":"")+(T.unicode?"u":"")+(T.sticky?"y":""),D=0,U=_===void 0?y:_>>>0,Q=new RegExp(T.source,B+"g"),P,W,$;(P=o.call(Q,O))&&(W=Q[g],!(W>D&&(R.push(O.slice(D,P.index)),P[m]>1&&P.index<O[m]&&f.apply(R,P.slice(1)),$=P[0][m],D=W,R[m]>=U)));)Q[g]===P.index&&Q[g]++;return D===O[m]?($||!Q.test(""))&&R.push(""):R.push(O.slice(D)),R[m]>U?R.slice(0,U):R}:"0"[h](void 0,0)[m]?A=function(T,_){return T===void 0&&_===0?[]:E.call(this,T,_)}:A=E,[function(_,O){var R=x(this),B=_==null?void 0:_[w];return B!==void 0?B.call(_,R,O):A.call(String(R),_,O)},function(T,_){var O=C(A,T,this,_,A!==E);if(O.done)return O.value;var R=e(T),B=String(this),D=n(R,RegExp),U=R.unicode,Q=(R.ignoreCase?"i":"")+(R.multiline?"m":"")+(R.unicode?"u":"")+(b?"y":"g"),P=new D(b?R:"^(?:"+R.source+")",Q),W=_===void 0?y:_>>>0;if(W===0)return[];if(B.length===0)return i(P,B)===null?[B]:[];for(var $=0,H=0,J=[];H<B.length;){P.lastIndex=b?H:0;var re=i(P,b?B:B.slice(H)),V;if(re===null||(V=d(s(P.lastIndex+(b?0:H)),B.length))===$)H=r(B,H,U);else{if(J.push(B.slice($,H)),J.length===W)return J;for(var ie=1;ie<=re.length-1;ie++)if(J.push(re[ie]),J.length===W)return J;H=$=V}}return J.push(B.slice($)),J}]}),Ok}Nz();var Za={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var Cz=Za.exports,Lk;function _z(){return Lk||(Lk=1,(function(t,e){(function(n){var r=e&&!e.nodeType&&e,s=t&&!t.nodeType&&t,i=typeof jb=="object"&&jb;(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,y=72,b=128,x="-",w=/^xn--/,E=/[^\x20-\x7E]/,C=/[\x2E\u3002\uFF0E\uFF61]/g,A={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},T=d-f,_=Math.floor,O=String.fromCharCode,R;function B(z){throw new RangeError(A[z])}function D(z,M){for(var I=z.length,Z=[];I--;)Z[I]=M(z[I]);return Z}function U(z,M){var I=z.split("@"),Z="";I.length>1&&(Z=I[0]+"@",z=I[1]),z=z.replace(C,".");var le=z.split("."),ge=D(le,M).join(".");return Z+ge}function Q(z){for(var M=[],I=0,Z=z.length,le,ge;I<Z;)le=z.charCodeAt(I++),le>=55296&&le<=56319&&I<Z?(ge=z.charCodeAt(I++),(ge&64512)==56320?M.push(((le&1023)<<10)+(ge&1023)+65536):(M.push(le),I--)):M.push(le);return M}function P(z){return D(z,function(M){var I="";return M>65535&&(M-=65536,I+=O(M>>>10&1023|55296),M=56320|M&1023),I+=O(M),I}).join("")}function W(z){return z-48<10?z-22:z-65<26?z-65:z-97<26?z-97:d}function $(z,M){return z+22+75*(z<26)-((M!=0)<<5)}function H(z,M,I){var Z=0;for(z=I?_(z/g):z>>1,z+=_(z/M);z>T*h>>1;Z+=d)z=_(z/T);return _(Z+(T+1)*z/(z+m))}function J(z){var M=[],I=z.length,Z,le=0,ge=b,se=y,xe,fe,De,We,Qe,ot,st,Ie,dt;for(xe=z.lastIndexOf(x),xe<0&&(xe=0),fe=0;fe<xe;++fe)z.charCodeAt(fe)>=128&&B("not-basic"),M.push(z.charCodeAt(fe));for(De=xe>0?xe+1:0;De<I;){for(We=le,Qe=1,ot=d;De>=I&&B("invalid-input"),st=W(z.charCodeAt(De++)),(st>=d||st>_((l-le)/Qe))&&B("overflow"),le+=st*Qe,Ie=ot<=se?f:ot>=se+h?h:ot-se,!(st<Ie);ot+=d)dt=d-Ie,Qe>_(l/dt)&&B("overflow"),Qe*=dt;Z=M.length+1,se=H(le-We,Z,We==0),_(le/Z)>l-ge&&B("overflow"),ge+=_(le/Z),le%=Z,M.splice(le++,0,ge)}return P(M)}function re(z){var M,I,Z,le,ge,se,xe,fe,De,We,Qe,ot=[],st,Ie,dt,Ge;for(z=Q(z),st=z.length,M=b,I=0,ge=y,se=0;se<st;++se)Qe=z[se],Qe<128&&ot.push(O(Qe));for(Z=le=ot.length,le&&ot.push(x);Z<st;){for(xe=l,se=0;se<st;++se)Qe=z[se],Qe>=M&&Qe<xe&&(xe=Qe);for(Ie=Z+1,xe-M>_((l-I)/Ie)&&B("overflow"),I+=(xe-M)*Ie,M=xe,se=0;se<st;++se)if(Qe=z[se],Qe<M&&++I>l&&B("overflow"),Qe==M){for(fe=I,De=d;We=De<=ge?f:De>=ge+h?h:De-ge,!(fe<We);De+=d)Ge=fe-We,dt=d-We,ot.push(O($(We+Ge%dt,0))),fe=_(Ge/dt);ot.push(O($(fe,0))),ge=H(I,Ie,Z==le),I=0,++Z}++I,++M}return ot.join("")}function V(z){return U(z,function(M){return w.test(M)?J(M.slice(4).toLowerCase()):M})}function ie(z){return U(z,function(M){return E.test(M)?"xn--"+re(M):M})}if(o={version:"1.4.1",ucs2:{decode:Q,encode:P},decode:J,encode:re,toASCII:ie,toUnicode:V},r&&s)if(t.exports==r)s.exports=o;else for(R in o)o.hasOwnProperty(R)&&(r[R]=o[R]);else n.punycode=o})(Cz)})(Za,Za.exports)),Za.exports}var Tz=_z();const Mz=El(Tz);var F2=Et(/(?:(?:[\-a-z0-9#{latinAccentChars}]+)\.)+(?:#{validGTLD}|#{validCCTLD}|#{validPunycode})/gi,{latinAccentChars:ef,validGTLD:I2,validCCTLD:j2,validPunycode:L2}),Az=63,jz="xn--",Oz={toAscii:function(e){if(!(e.substring(0,4)===jz&&!e.match(F2))){for(var n=e.split("."),r=0;r<n.length;r++){var s=n[r],i=Mz.toASCII(s);if(i.length<1||i.length>Az)return}return n.join(".")}}},Rz=Et(/^https?:\/\/t\.co\/([a-z0-9]+)(?:\?#{validUrlQueryChars}*#{validUrlQueryEndingChars})?/,{validUrlQueryChars:z2,validUrlQueryEndingChars:$2},"i"),Iz="https://",Lz={extractUrlsWithoutProtocol:!0},Dz=4096,Pz=40,Bz=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Lz;if(!e||(n.extractUrlsWithoutProtocol?!e.match(/\./):!e.match(/:/)))return[];for(var r=[],s=function(){var l=RegExp.$2,d=RegExp.$3,f=RegExp.$4,h=RegExp.$5,m=RegExp.$7,g=jk.lastIndex,y=g-d.length;if(!zz(d,f||Iz,h))return"continue";if(f){if(d.match(Rz)){var w=RegExp.$1;if(w&&w.length>Pz)return"continue";d=RegExp.lastMatch,g=y+d.length}r.push({url:d,indices:[y,g]})}else{if(!n.extractUrlsWithoutProtocol||l.match(Sz))return"continue";var b=null,x=0;if(h.replace(F2,function(E){var C=h.indexOf(E,x);x=C+E.length,b={url:E,indices:[y+C,y+x]},r.push(b)}),b==null)return"continue";m&&(b.url=d.replace(h,b.url),b.indices[1]=g)}};jk.exec(e);)var i=s();return r},zz=function(e,n,r){var s=e.length,i=Oz.toAscii(r);return!i||!i.length?!1:(s=s+i.length-r.length,n.length+s<=Dz)},Dk={},Pk;function $z(){if(Pk)return Dk;Pk=1;var t=hr(),e=Xd(),n=wi(),r=Yr(),s=[].sort,i=[1,2,3];return t(t.P+t.F*(r(function(){i.sort(void 0)})||!r(function(){i.sort(null)})||!Il()(s)),"Array",{sort:function(l){return l===void 0?s.call(n(this)):s.call(n(this),e(l))}}),Dk}$z();var U2=/\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]/,H2=/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/,W2=/[\uD800-\uDBFF][\uDC00-\uDFFF]/gm,Fz=Et(/(?:[#{bmpLetterAndMarks}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}))/,{bmpLetterAndMarks:H2,nonBmpCodePairs:W2,astralLetterAndMarks:U2}),Uz=/\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]/,Hz=/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/,Wz=/_\u200c\u200d\ua67e\u05be\u05f3\u05f4\uff5e\u301c\u309b\u309c\u30a0\u30fb\u3003\u0f0b\u0f0c\xb7/,q2=Et(/(?:[#{bmpLetterAndMarks}#{bmpNumerals}#{hashtagSpecialChars}]|(?=#{nonBmpCodePairs})(?:#{astralLetterAndMarks}|#{astralNumerals}))/,{bmpLetterAndMarks:H2,bmpNumerals:Hz,hashtagSpecialChars:Wz,nonBmpCodePairs:W2,astralLetterAndMarks:U2,astralNumerals:Uz}),qz=/(?:[^\uD800-\uDFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF])/,Vz=Et(/(?:^|\uFE0E|\uFE0F|$|(?!#{hashtagAlphaNumeric}|&)#{codePoint})/,{codePoint:qz,hashtagAlphaNumeric:q2});Et(/(#{hashtagBoundary})(#{hashSigns})(?!\uFE0F|\u20E3)(#{hashtagAlphaNumeric}*#{hashtagAlpha}#{hashtagAlphaNumeric}*)/gi,{hashtagBoundary:Vz,hashSigns:A2,hashtagAlphaNumeric:q2,hashtagAlpha:Fz});var u0=/[@@]/;Et(/^(?:#{atSigns}|[#{latinAccentChars}]|:\/\/)/,{atSigns:u0,latinAccentChars:ef});var Kz=/(?:^|[^a-zA-Z0-9_!#$%&*@@]|(?:^|[^a-zA-Z0-9_+~.-])(?:rt|RT|rT|Rt):?)/,Gz=Et("(#{validMentionPrecedingChars})(#{atSigns})([a-zA-Z0-9_]{1,20})(/[a-zA-Z][a-zA-Z0-9_-]{0,24})?",{validMentionPrecedingChars:Kz,atSigns:u0},"g"),Bk={},zk={},$k;function Jz(){return $k||($k=1,Pr()&&/./g.flags!="g"&&Xr().f(RegExp.prototype,"flags",{configurable:!0,get:Yd()})),zk}var Fk;function Yz(){if(Fk)return Bk;Fk=1,Jz();var t=wr(),e=Yd(),n=Pr(),r="toString",s=/./[r],i=function(o){Rs()(RegExp.prototype,r,o,!0)};return Yr()(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)}),Bk}Yz();var Uk={},Hk;function Xz(){if(Hk)return Uk;Hk=1;var t=Date.prototype,e="Invalid Date",n="toString",r=t[n],s=t.getTime;return new Date(NaN)+""!=e&&Rs()(t,n,function(){var o=s.call(this);return o===o?r.call(this):e}),Uk}Xz();var Wk={},qk;function Qz(){if(qk)return Wk;qk=1;var t=Zv(),e={};return e[Ln()("toStringTag")]="z",e+""!="[object z]"&&Rs()(Object.prototype,"toString",function(){return"[object "+t(this)+"]"},!0),Wk}Qz();const Vk={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}]}};Et(/^(?:#{spaces})*#{atSigns}([a-zA-Z0-9_]{1,20})/,{atSigns:u0,spaces:M2});var Kk={},Cm,Gk;function d0(){if(Gk)return Cm;Gk=1;var t=Kd();return Cm=Array.isArray||function(n){return t(n)=="Array"},Cm}var Jk;function Zz(){if(Jk)return Kk;Jk=1;var t=hr();return t(t.S,"Array",{isArray:d0()}),Kk}Zz();var e$=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},Yk={},_m,Xk;function t$(){if(Xk)return _m;Xk=1;var t=Xd(),e=wi(),n=s0(),r=ao();return _m=function(s,i,o,l,d){t(i);var f=e(s),h=n(f),m=r(f.length),g=d?m-1:0,y=d?-1:1;if(o<2)for(;;){if(g in h){l=h[g],g+=y;break}if(g+=y,d?g<0:m<=g)throw TypeError("Reduce of empty array with no initial value")}for(;d?g>=0:m>g;g+=y)g in h&&(l=i(l,h[g],g,f));return l},_m}var Qk;function n$(){if(Qk)return Yk;Qk=1;var t=hr(),e=t$();return t(t.P+t.F*!Il()([].reduce,!0),"Array",{reduce:function(r){return e(this,r,arguments.length,arguments[1],!1)}}),Yk}n$();var Zk={},Tm,eS;function r$(){if(eS)return Tm;eS=1;var t=Ln()("unscopables"),e=Array.prototype;return e[t]==null&&ki()(e,t,{}),Tm=function(n){e[t][n]=!0},Tm}var Mm,tS;function s$(){return tS||(tS=1,Mm=function(t,e){return{value:e,done:!!t}}),Mm}var Am,nS;function Ll(){return nS||(nS=1,Am={}),Am}var jm,rS;function Dl(){if(rS)return jm;rS=1;var t=C2(),e=l0();return jm=Object.keys||function(r){return t(r,e)},jm}var Om,sS;function V2(){if(sS)return Om;sS=1;var t=Xr(),e=wr(),n=Dl();return Om=Pr()?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},Om}var Rm,iS;function i$(){if(iS)return Rm;iS=1;var t=Dr().document;return Rm=t&&t.documentElement,Rm}var Im,oS;function K2(){if(oS)return Im;oS=1;var t=wr(),e=V2(),n=l0(),r=a0()("IE_PROTO"),s=function(){},i="prototype",o=function(){var l=k2()("iframe"),d=n.length,f="<",h=">",m;for(l.style.display="none",i$().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 Im=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)},Im}var Lm,aS;function f0(){if(aS)return Lm;aS=1;var t=Xr().f,e=lo(),n=Ln()("toStringTag");return Lm=function(r,s,i){r&&!e(r=i?r:r.prototype,n)&&t(r,n,{configurable:!0,value:s})},Lm}var Dm,lS;function o$(){if(lS)return Dm;lS=1;var t=K2(),e=Rl(),n=f0(),r={};return ki()(r,Ln()("iterator"),function(){return this}),Dm=function(s,i,o){s.prototype=t(r,{next:e(1,o)}),n(s,i+" Iterator")},Dm}var Pm,cS;function a$(){if(cS)return Pm;cS=1;var t=lo(),e=wi(),n=a0()("IE_PROTO"),r=Object.prototype;return Pm=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},Pm}var Bm,uS;function G2(){if(uS)return Bm;uS=1;var t=Gd(),e=hr(),n=Rs(),r=ki(),s=Ll(),i=o$(),o=f0(),l=a$(),d=Ln()("iterator"),f=!([].keys&&"next"in[].keys()),h="@@iterator",m="keys",g="values",y=function(){return this};return Bm=function(b,x,w,E,C,A,T){i(w,x,E);var _=function(re){if(!f&&re in D)return D[re];switch(re){case m:return function(){return new w(this,re)};case g:return function(){return new w(this,re)}}return function(){return new w(this,re)}},O=x+" Iterator",R=C==g,B=!1,D=b.prototype,U=D[d]||D[h]||C&&D[C],Q=U||_(C),P=C?R?_("entries"):Q:void 0,W=x=="Array"&&D.entries||U,$,H,J;if(W&&(J=l(W.call(new b)),J!==Object.prototype&&J.next&&(o(J,O,!0),!t&&typeof J[d]!="function"&&r(J,d,y))),R&&U&&U.name!==g&&(B=!0,Q=function(){return U.call(this)}),(!t||T)&&(f||B||!D[d])&&r(D,d,Q),s[x]=Q,s[O]=y,C)if($={values:R?Q:_(g),keys:A?Q:_(m),entries:P},T)for(H in $)H in D||n(D,H,$[H]);else e(e.P+e.F*(f||B),x,$);return $},Bm}var zm,dS;function J2(){if(dS)return zm;dS=1;var t=r$(),e=s$(),n=Ll(),r=co();return zm=G2()(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"),zm}var fS;function l$(){if(fS)return Zk;fS=1;for(var t=J2(),e=Dl(),n=Rs(),r=Dr(),s=ki(),i=Ll(),o=Ln(),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 y=m[g],b=h[y],x=r[y],w=x&&x.prototype,E;if(w&&(w[l]||s(w,l,f),w[d]||s(w,d,y),i[y]=f,b))for(E in t)w[E]||n(w,E,t[E],!0)}return Zk}l$();J2();var hS={},$m,pS;function c$(){if(pS)return $m;pS=1;var t=hr(),e=oa(),n=Yr();return $m=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)},$m}var mS;function u$(){if(mS)return hS;mS=1;var t=wi(),e=Dl();return c$()("keys",function(){return function(r){return e(t(r))}}),hS}u$();var d$=Et(/[#{invalidCharsGroup}]/,{invalidCharsGroup:c0});function f$(t){return d$.test(t)}var Fi={},mu={},gS;function h$(){return gS||(gS=1,Object.defineProperty(mu,"__esModule",{value:!0}),mu.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),mu}var vS;function p$(){if(vS)return Fi;vS=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.TypeName=void 0,Fi.parse=s,Fi.toCodePoints=d;var t=h$(),e=n(t);function n(f){return f&&f.__esModule?f:{default:f}}var r=Fi.TypeName="emoji";function s(f,h){var m=h&&h.assetType?h.assetType:"svg",g=h&&h.buildUrl?h.buildUrl:function(E,C){return C==="png"?"https://twemoji.maxcdn.com/2/72x72/"+E+".png":"https://twemoji.maxcdn.com/2/svg/"+E+".svg"},y=[];for(e.default.lastIndex=0;;){var b=e.default.exec(f);if(!b)break;var x=b[0],w=d(l(x)).join("-");y.push({url:w?g(w,m):"",indices:[b.index,e.default.lastIndex],text:x,type:r})}return y}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,y=0;y<f.length;)m=f.charCodeAt(y++),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 Fi}var m$=p$(),g$=function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Vk.defaults,r=Object.keys(n).length?n:Vk.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=yS(Bz(f)),m=i?yS(m$.parse(f)):[],g=f.length,y=0,b=0,x=!0,w=0;w<g;w++){if(h[w]){var E=h[w],C=E.url;E.indices,y+=d*o,w+=C.length-1}else if(i&&m[w]){var A=m[w],T=A.text;A.indices,y+=s,w+=T.length-1}else w+=v$(f,w)?1:0,y+=e$(f.charAt(w),r);x&&(x=!f$(f.substring(w,w+1))),x&&y<=l*o&&(b=w)}y=y/o,x=x&&y>0&&y<=l;var _=Math.floor(y/l*1e3),O=e.length-f.length;return b+=O,{weightedLength:y,valid:x,permillage:_,validRangeStart:0,validRangeEnd:b,displayRangeStart:0,displayRangeEnd:e.length>0?e.length-1:0}},yS=function(e){return e.reduce(function(n,r){return n[r.indices[0]]=r,n},{})},v$=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},bS={},xS;function y$(){if(xS)return bS;xS=1;var t=hr();return t(t.S+t.F*!Pr(),"Object",{defineProperty:Xr().f}),bS}y$();var wS={},kS;function b$(){if(kS)return wS;kS=1;var t=hr();return t(t.S+t.F*!Pr(),"Object",{defineProperties:V2()}),wS}b$();var SS={},Fm={},ES;function h0(){return ES||(ES=1,Fm.f=Object.getOwnPropertySymbols),Fm}var Um,NS;function x$(){if(NS)return Um;NS=1;var t=Zd(),e=h0(),n=wr(),r=Dr().Reflect;return Um=r&&r.ownKeys||function(i){var o=t.f(n(i)),l=e.f;return l?o.concat(l(i)):o},Um}var Hm,CS;function Y2(){if(CS)return Hm;CS=1;var t=Xr(),e=Rl();return Hm=function(n,r,s){r in n?t.f(n,r,e(0,s)):n[r]=s},Hm}var _S;function w$(){if(_S)return SS;_S=1;var t=hr(),e=x$(),n=co(),r=o0(),s=Y2();return t(t.S,"Object",{getOwnPropertyDescriptors:function(o){for(var l=n(o),d=r.f,f=e(l),h={},m=0,g,y;f.length>m;)y=d(l,g=f[m++]),y!==void 0&&s(h,g,y);return h}}),SS}w$();var TS={},Wm,MS;function k$(){if(MS)return Wm;MS=1;var t=Os(),e=d0(),n=Ln()("species");return Wm=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},Wm}var qm,AS;function S$(){if(AS)return qm;AS=1;var t=k$();return qm=function(e,n){return new(t(e))(n)},qm}var Vm,jS;function X2(){if(jS)return Vm;jS=1;var t=Qd(),e=s0(),n=wi(),r=ao(),s=S$();return Vm=function(i,o){var l=i==1,d=i==2,f=i==3,h=i==4,m=i==6,g=i==5||m,y=o||s;return function(b,x,w){for(var E=n(b),C=e(E),A=t(x,w,3),T=r(C.length),_=0,O=l?y(b,T):d?y(b,0):void 0,R,B;T>_;_++)if((g||_ in C)&&(R=C[_],B=A(R,_,E),i)){if(l)O[_]=B;else if(B)switch(i){case 3:return!0;case 5:return R;case 6:return _;case 2:O.push(R)}else if(h)return!1}return m?-1:f||h?h:O}},Vm}var OS;function E$(){if(OS)return TS;OS=1;var t=hr(),e=X2()(0),n=Il()([].forEach,!0);return t(t.P+t.F*!n,"Array",{forEach:function(s){return e(this,s,arguments[1])}}),TS}E$();var RS={},IS;function N$(){if(IS)return RS;IS=1;var t=hr(),e=X2()(2);return t(t.P+t.F*!Il()([].filter,!0),"Array",{filter:function(r){return e(this,r,arguments[1])}}),RS}N$();var LS={},Km={exports:{}},DS;function C$(){if(DS)return Km.exports;DS=1;var t=Ol()("meta"),e=Os(),n=lo(),r=Xr().f,s=0,i=Object.isExtensible||function(){return!0},o=!Yr()(function(){return i(Object.preventExtensions({}))}),l=function(g){r(g,t,{value:{i:"O"+ ++s,w:{}}})},d=function(g,y){if(!e(g))return typeof g=="symbol"?g:(typeof g=="string"?"S":"P")+g;if(!n(g,t)){if(!i(g))return"F";if(!y)return"E";l(g)}return g[t].i},f=function(g,y){if(!n(g,t)){if(!i(g))return!0;if(!y)return!1;l(g)}return g[t].w},h=function(g){return o&&m.NEED&&i(g)&&!n(g,t)&&l(g),g},m=Km.exports={KEY:t,NEED:!1,fastKey:d,getWeak:f,onFreeze:h};return Km.exports}var Gm={},PS;function Q2(){return PS||(PS=1,Gm.f=Ln()),Gm}var Jm,BS;function _$(){if(BS)return Jm;BS=1;var t=Dr(),e=oa(),n=Gd(),r=Q2(),s=Xr().f;return Jm=function(i){var o=e.Symbol||(e.Symbol=n?{}:t.Symbol||{});i.charAt(0)!="_"&&!(i in o)&&s(o,i,{value:r.f(i)})},Jm}var Ym,zS;function T$(){if(zS)return Ym;zS=1;var t=Dl(),e=h0(),n=i0();return Ym=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},Ym}var Xm={},$S;function M$(){if($S)return Xm;$S=1;var t=co(),e=Zd().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 Xm.f=function(o){return r&&n.call(o)=="[object Window]"?s(o):e(t(o))},Xm}var FS;function A$(){if(FS)return LS;FS=1;var t=Dr(),e=lo(),n=Pr(),r=hr(),s=Rs(),i=C$().KEY,o=Yr(),l=Jd(),d=f0(),f=Ol(),h=Ln(),m=Q2(),g=_$(),y=T$(),b=d0(),x=wr(),w=Os(),E=wi(),C=co(),A=n0(),T=Rl(),_=K2(),O=M$(),R=o0(),B=h0(),D=Xr(),U=Dl(),Q=R.f,P=D.f,W=O.f,$=t.Symbol,H=t.JSON,J=H&&H.stringify,re="prototype",V=h("_hidden"),ie=h("toPrimitive"),z={}.propertyIsEnumerable,M=l("symbol-registry"),I=l("symbols"),Z=l("op-symbols"),le=Object[re],ge=typeof $=="function"&&!!B.f,se=t.QObject,xe=!se||!se[re]||!se[re].findChild,fe=n&&o(function(){return _(P({},"a",{get:function(){return P(this,"a",{value:7}).a}})).a!=7})?function(Je,Y,pe){var G=Q(le,Y);G&&delete le[Y],P(Je,Y,pe),G&&Je!==le&&P(le,Y,G)}:P,De=function(Je){var Y=I[Je]=_($[re]);return Y._k=Je,Y},We=ge&&typeof $.iterator=="symbol"?function(Je){return typeof Je=="symbol"}:function(Je){return Je instanceof $},Qe=function(Y,pe,G){return Y===le&&Qe(Z,pe,G),x(Y),pe=A(pe,!0),x(G),e(I,pe)?(G.enumerable?(e(Y,V)&&Y[V][pe]&&(Y[V][pe]=!1),G=_(G,{enumerable:T(0,!1)})):(e(Y,V)||P(Y,V,T(1,{})),Y[V][pe]=!0),fe(Y,pe,G)):P(Y,pe,G)},ot=function(Y,pe){x(Y);for(var G=y(pe=C(pe)),oe=0,ue=G.length,Fe;ue>oe;)Qe(Y,Fe=G[oe++],pe[Fe]);return Y},st=function(Y,pe){return pe===void 0?_(Y):ot(_(Y),pe)},Ie=function(Y){var pe=z.call(this,Y=A(Y,!0));return this===le&&e(I,Y)&&!e(Z,Y)?!1:pe||!e(this,Y)||!e(I,Y)||e(this,V)&&this[V][Y]?pe:!0},dt=function(Y,pe){if(Y=C(Y),pe=A(pe,!0),!(Y===le&&e(I,pe)&&!e(Z,pe))){var G=Q(Y,pe);return G&&e(I,pe)&&!(e(Y,V)&&Y[V][pe])&&(G.enumerable=!0),G}},Ge=function(Y){for(var pe=W(C(Y)),G=[],oe=0,ue;pe.length>oe;)!e(I,ue=pe[oe++])&&ue!=V&&ue!=i&&G.push(ue);return G},bt=function(Y){for(var pe=Y===le,G=W(pe?Z:C(Y)),oe=[],ue=0,Fe;G.length>ue;)e(I,Fe=G[ue++])&&(!pe||e(le,Fe))&&oe.push(I[Fe]);return oe};ge||($=function(){if(this instanceof $)throw TypeError("Symbol is not a constructor!");var Y=f(arguments.length>0?arguments[0]:void 0),pe=function(G){this===le&&pe.call(Z,G),e(this,V)&&e(this[V],Y)&&(this[V][Y]=!1),fe(this,Y,T(1,G))};return n&&xe&&fe(le,Y,{configurable:!0,set:pe}),De(Y)},s($[re],"toString",function(){return this._k}),R.f=dt,D.f=Qe,Zd().f=O.f=Ge,i0().f=Ie,B.f=bt,n&&!Gd()&&s(le,"propertyIsEnumerable",Ie,!0),m.f=function(Je){return De(h(Je))}),r(r.G+r.W+r.F*!ge,{Symbol:$});for(var xt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),$t=0;xt.length>$t;)h(xt[$t++]);for(var Ke=U(h.store),pt=0;Ke.length>pt;)g(Ke[pt++]);r(r.S+r.F*!ge,"Symbol",{for:function(Je){return e(M,Je+="")?M[Je]:M[Je]=$(Je)},keyFor:function(Y){if(!We(Y))throw TypeError(Y+" is not a symbol!");for(var pe in M)if(M[pe]===Y)return pe},useSetter:function(){xe=!0},useSimple:function(){xe=!1}}),r(r.S+r.F*!ge,"Object",{create:st,defineProperty:Qe,defineProperties:ot,getOwnPropertyDescriptor:dt,getOwnPropertyNames:Ge,getOwnPropertySymbols:bt});var Ft=o(function(){B.f(1)});return r(r.S+r.F*Ft,"Object",{getOwnPropertySymbols:function(Y){return B.f(E(Y))}}),H&&r(r.S+r.F*(!ge||o(function(){var Je=$();return J([Je])!="[null]"||J({a:Je})!="{}"||J(Object(Je))!="{}"})),"JSON",{stringify:function(Y){for(var pe=[Y],G=1,oe,ue;arguments.length>G;)pe.push(arguments[G++]);if(ue=oe=pe[1],!(!w(oe)&&Y===void 0||We(Y)))return b(oe)||(oe=function(Fe,Me){if(typeof ue=="function"&&(Me=ue.call(this,Fe,Me)),!We(Me))return Me}),pe[1]=oe,J.apply(H,pe)}}),$[re][ie]||ki()($[re],ie,$[re].valueOf),d($,"Symbol"),d(Math,"Math",!0),d(t.JSON,"JSON",!0),LS}A$();Et(/^#{validMentionOrList}$/,{validMentionOrList:Gz});var Z2=/[a-z\u0400-\u04FF0-9\-._~]/i,eT=/(?:%[0-9a-f]{2})/i,tT=/[!$&'()*+,;=]/i,nT=Et("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|:)*",{validateUrlUnreserved:Z2,validateUrlPctEncoded:eT,validateUrlSubDelims:tT},"i"),j$=/(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?)/i,O$=/(?:[a-z](?:[a-z0-9\-]*[a-z0-9])?)/i,R$=/(?:[a-z0-9](?:[a-z0-9_\-]*[a-z0-9])?)/i,I$=Et(/(?:(?:#{validateUrlSubDomainSegment}\.)*(?:#{validateUrlDomainSegment}\.)#{validateUrlDomainTld})/i,{validateUrlSubDomainSegment:R$,validateUrlDomainSegment:j$,validateUrlDomainTld:O$}),L$=/(?:[0-9]|(?:[1-9][0-9])|(?:1[0-9]{2})|(?:2[0-4][0-9])|(?:25[0-5]))/i,D$=Et(/(?:#{validateUrlDecOctet}(?:\.#{validateUrlDecOctet}){3})/i,{validateUrlDecOctet:L$}),P$=/(?:\[[a-f0-9:\.]+\])/i,rT=Et("(?:#{validateUrlIpv4}|#{validateUrlIpv6})",{validateUrlIpv4:D$,validateUrlIpv6:P$},"i"),B$=Et("(?:#{validateUrlIp}|#{validateUrlDomain})",{validateUrlIp:rT,validateUrlDomain:I$},"i"),sT=/[0-9]{1,5}/;Et("(?:(#{validateUrlUserinfo})@)?(#{validateUrlHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:nT,validateUrlHost:B$,validateUrlPort:sT},"i");var p0=Et("(?:#{validateUrlUnreserved}|#{validateUrlPctEncoded}|#{validateUrlSubDelims}|[:|@])",{validateUrlUnreserved:Z2,validateUrlPctEncoded:eT,validateUrlSubDelims:tT},"i");Et(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:p0});Et(/(\/#{validateUrlPchar}*)*/i,{validateUrlPchar:p0});Et(/(#{validateUrlPchar}|\/|\?)*/i,{validateUrlPchar:p0});Et("^(?:([^:/?#]+):\\/\\/)?([^/?#]*)([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$","i");var z$=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9_\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,$$=/(?:(?:[a-z0-9]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,F$=/(?:(?:[a-z]|[^\u0000-\u007f])(?:(?:[a-z0-9\-]|[^\u0000-\u007f])*(?:[a-z0-9]|[^\u0000-\u007f]))?)/i,U$=Et(/(?:(?:#{validateUrlUnicodeSubDomainSegment}\.)*(?:#{validateUrlUnicodeDomainSegment}\.)#{validateUrlUnicodeDomainTld})/i,{validateUrlUnicodeSubDomainSegment:z$,validateUrlUnicodeDomainSegment:$$,validateUrlUnicodeDomainTld:F$}),H$=Et("(?:#{validateUrlIp}|#{validateUrlUnicodeDomain})",{validateUrlIp:rT,validateUrlUnicodeDomain:U$},"i");Et("(?:(#{validateUrlUserinfo})@)?(#{validateUrlUnicodeHost})(?::(#{validateUrlPort}))?",{validateUrlUserinfo:nT,validateUrlUnicodeHost:H$,validateUrlPort:sT},"i");var US={},HS;function W$(){if(HS)return US;HS=1;var t=w2()(!0);return G2()(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})}),US}W$();var WS={},Qm,qS;function q$(){if(qS)return Qm;qS=1;var t=wr();return Qm=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}},Qm}var Zm,VS;function V$(){if(VS)return Zm;VS=1;var t=Ll(),e=Ln()("iterator"),n=Array.prototype;return Zm=function(r){return r!==void 0&&(t.Array===r||n[e]===r)},Zm}var eg,KS;function K$(){if(KS)return eg;KS=1;var t=Zv(),e=Ln()("iterator"),n=Ll();return eg=oa().getIteratorMethod=function(r){if(r!=null)return r[e]||r["@@iterator"]||n[t(r)]},eg}var tg,GS;function G$(){if(GS)return tg;GS=1;var t=Ln()("iterator"),e=!1;try{var n=[7][t]();n.return=function(){e=!0},Array.from(n,function(){throw 2})}catch{}return tg=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},tg}var JS;function J$(){if(JS)return WS;JS=1;var t=Qd(),e=hr(),n=wi(),r=q$(),s=V$(),i=ao(),o=Y2(),l=K$();return e(e.S+e.F*!G$()(function(d){Array.from(d)}),"Array",{from:function(f){var h=n(f),m=typeof this=="function"?this:Array,g=arguments.length,y=g>1?arguments[1]:void 0,b=y!==void 0,x=0,w=l(h),E,C,A,T;if(b&&(y=t(y,g>2?arguments[2]:void 0,2)),w!=null&&!(m==Array&&s(w)))for(T=w.call(h),C=new m;!(A=T.next()).done;x++)o(C,x,b?r(T,y,[A.value,x],!0):A.value);else for(E=i(h.length),C=new m(E);E>x;x++)o(C,x,b?y(h[x],x):h[x]);return C.length=x,C}}),WS}J$();const Y$={parseTweet:g$},{parseTweet:X$}=Y$;function YS(t){return X$(t).weightedLength}const XS="ow-x-handle";function Q$(){const[t,e]=k.useState(()=>localStorage.getItem(XS)||""),[n,r]=k.useState(!1),[s,i]=k.useState(""),o=k.useRef(null),l=k.useRef(null),d=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(XS,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=o.current)==null?void 0:m.focus()},0)};k.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 u.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:l,children:[t?u.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:h,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):u.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&u.jsx("div",{className:"tweet-handle-popover",children:u.jsx("input",{ref: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})})]})}function QS(){return u.jsxs("div",{className:"tweet-skeleton",children:[u.jsxs("div",{className:"tweet-author-row",children:[u.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),u.jsxs("div",{className:"tweet-author-info",children:[u.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),u.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),u.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),u.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function Z$(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function gu(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 vu(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 ZS(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 yu(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 eE(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 ng(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tweetContext:t}),keepalive:!0}).catch(()=>{})}function eF({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s,onActiveEditorChange:i,filename:o,title:l}){const{tweet:d,loading:f,error:h}=H8(t==null?void 0:t.url),[m,g]=k.useState(()=>gu(e).map(pe=>{const G=vu(pe);return ZS(pe,G.length)})),[y,b]=k.useState(0),x=k.useRef([]),w=k.useRef(null),E=k.useRef(!0),C=k.useRef(!1),A=k.useRef(m.length),[T,_]=k.useState(()=>m.map(()=>0)),[O,R]=k.useState(0),[B,D]=k.useState(0),U=k.useRef(gu(e).map(Y=>vu(Y))),[Q,P]=k.useState(()=>gu(e).map(pe=>vu(pe).length)),[W,$]=k.useState(null),[H,J]=k.useState(),[re,V]=k.useState(!1),[ie,z]=k.useState("idle"),[M,I]=k.useState(""),Z=k.useRef(),{copyText:le,copyState:ge}=K8(x,O),[se,xe]=k.useState(!1);k.useEffect(()=>{let Y=!1;return(async()=>{try{const pe=await fetch("/api/x/status");if(Y)return;if(pe.ok){const G=await pe.json();$(G.connected),J(G.username)}else $(!1)}catch{Y||$(!1)}})(),()=>{Y=!0}},[]),k.useEffect(()=>{if(E.current){E.current=!1;return}if(!e||JSON.stringify(e)===w.current)return;const pe=gu(e),G=pe.map(ue=>vu(ue)),oe=pe.map((ue,Fe)=>ZS(ue,G[Fe].length));C.current=!0,A.current=oe.length,x.current=[],U.current=G,g(oe),_(oe.map(()=>0)),P(G.map(ue=>ue.length)),b(ue=>ue+1)},[e]);const fe=k.useCallback((Y,pe)=>{if(x.current[Y]=pe,_(oe=>{const ue=[...oe];return ue[Y]=YS(pe.getText()),ue}),C.current)return;const G=yu(x.current,U.current);w.current=JSON.stringify(G),n==null||n(G)},[n]),De=k.useCallback((Y,pe)=>{if(x.current[Y]=pe,_(G=>{const oe=[...G];return oe[Y]=YS(pe.getText()),oe}),D(G=>G+1),C.current&&x.current.filter(Boolean).length>=A.current){C.current=!1;const oe=yu(x.current,U.current);w.current=JSON.stringify(oe)}Y===0&&(r==null||r(pe)),s==null||s(x.current.filter(Boolean))},[r,s]),We=m.length>1;T.reduce((Y,pe)=>Y+pe,0);const Qe=k.useCallback(()=>{const Y=O+1;g(pe=>[...pe.slice(0,Y),"<p></p>",...pe.slice(Y)]),_(pe=>[...pe.slice(0,Y),0,...pe.slice(Y)]),U.current.splice(Y,0,[]),P(pe=>[...pe.slice(0,Y),0,...pe.slice(Y)]),R(Y)},[O]),ot=k.useCallback(Y=>{Y!==0&&(x.current.splice(Y,1),U.current.splice(Y,1),g(pe=>pe.filter((G,oe)=>oe!==Y)),_(pe=>pe.filter((G,oe)=>oe!==Y)),P(pe=>pe.filter((G,oe)=>oe!==Y)),setTimeout(()=>{const pe=yu(x.current,U.current);n==null||n(pe),s==null||s(x.current.filter(Boolean))},0))},[n,s]),st=!!(t!=null&&t.url),Ie=(t==null?void 0:t.mode)==="reply",dt=(()=>{const pe=x.current.filter(Boolean).some(oe=>oe.getText().trim()||eE(oe).length>0),G=Q.some(oe=>oe>0);return pe||G})(),Ge=W&&dt&&ie==="idle",bt=async()=>{if(!W){V(!0);return}if(Ge){z("uploading"),I("");try{const Y=[];for(let G=0;G<x.current.length;G++){const oe=x.current[G];if(!oe)continue;const ue=oe.getText().trim(),Fe=eE(oe,U.current[G]);if(!ue&&Fe.length===0)continue;const Me=[];for(const K of Fe){const ye=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:K})})).json();if(!ye.success)throw new Error(ye.error||"Image upload failed");Me.push(ye.mediaId)}Y.push({text:ue,mediaIds:Me})}if(Y.length===0)return;z("posting");const pe=Z$(t==null?void 0:t.url);if(Y.length===1){const G={};Y[0].text&&(G.text=Y[0].text),Y[0].mediaIds.length>0&&(G.mediaIds=Y[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&pe?G.replyTo=pe:(t==null?void 0:t.mode)==="quote"&&pe&&(G.quoteTweetId=pe);const ue=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)})).json();ue.success?(ng({lastPost:{postedAt:new Date().toISOString(),tweetUrl:ue.tweetUrl}}),z("success"),Z.current=setTimeout(()=>z("idle"),2500)):(console.error("[TweetCompose] Post error:",ue.error),I(ue.error||"Post failed"),z("error"),setTimeout(()=>z("idle"),3e3))}else{const oe={tweets:Y.map(Me=>({text:Me.text,...Me.mediaIds.length>0?{mediaIds:Me.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&pe&&(oe.replyTo=pe);const Fe=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)})).json();Fe.success?(ng({lastPost:{postedAt:new Date().toISOString(),tweetUrl:Fe.threadUrl}}),z("success"),Z.current=setTimeout(()=>z("idle"),2500)):(I(Fe.error||"Thread post failed"),z("error"),setTimeout(()=>z("idle"),3e3))}}catch(Y){I(Y.message||"Network error"),z("error"),setTimeout(()=>z("idle"),3e3)}}};k.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current)},[]);const xt=()=>{$(!0),V(!1),fetch("/api/x/status").then(Y=>Y.json()).then(Y=>{Y.username&&J(Y.username)}).catch(()=>{})},$t=ie==="uploading"?"Uploading...":ie==="posting"?"Posting...":ie==="success"?"Posted!":ie==="error"?"Failed":We?O===0?"Post Thread":"Post All":"Post",Ke=m.map((Y,pe)=>pe===0?Ie?"Post your reply":"What is happening?!":"Add another tweet"),pt=Y=>{var pe;return u.jsxs("div",{className:`tweet-compose-footer${Y?" tweet-compose-footer--inline":""}`,children:[O===0&&((pe=t==null?void 0:t.lastPost)==null?void 0:pe.postedAt)&&u.jsxs("a",{className:"tweet-posted-status",href:t.lastPost.tweetUrl,target:"_blank",rel:"noopener noreferrer",title:t.lastPost.tweetUrl||"Posted to X",children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Posted ",new Date(t.lastPost.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),ie==="error"&&M&&u.jsx("span",{className:"tweet-post-error",children:M}),We&&u.jsxs("span",{className:"tweet-thread-counter",children:[O+1,"/",m.length]}),u.jsx(tz,{count:T[O]||0}),u.jsx("button",{className:"tweet-thread-add",onClick:Qe,title:"Add another tweet",children:u.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[u.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),u.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),u.jsx("button",{className:`tweet-copy-btn${ge==="copied"?" tweet-copy-btn--copied":""}`,disabled:!dt,onClick:le,title:"Copy tweet text to clipboard",children:ge==="copied"?u.jsxs(u.Fragment,{children:[u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:u.jsx("path",{d:"M3 8.5L6.5 12L13 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied!"]}):u.jsxs(u.Fragment,{children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[u.jsx("rect",{x:"5.5",y:"2",width:"8.5",height:"10.5",rx:"1.5",stroke:"currentColor",strokeWidth:"1.5"}),u.jsx("path",{d:"M3.5 5H2.5A1.5 1.5 0 001 6.5V13a1.5 1.5 0 001.5 1.5H9A1.5 1.5 0 0010.5 13v-1",stroke:"currentColor",strokeWidth:"1.5"})]}),"Copy"]})}),O===0&&(()=>{var oe;const G=!!((oe=t==null?void 0:t.lastPost)!=null&&oe.postedAt);return u.jsx("button",{className:`tweet-mark-sent-btn${G?" tweet-mark-sent-btn--done":""}`,onClick:()=>{G||ng({lastPost:{postedAt:new Date().toISOString()}})},title:G?"Posted":"Mark as manually posted",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:G?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"8 12 11 15 16 9",stroke:G?"#fff":"currentColor"})]})})})(),o&&u.jsx("button",{className:"tweet-schedule-btn",onClick:()=>xe(!0),title:"Schedule post",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]})}),u.jsx("button",{className:`tweet-post-btn${Ge||!W&&W!==null?" tweet-post-btn--active":""}${ie==="success"?" tweet-post-btn--success":""}${ie==="error"?" tweet-post-btn--error":""}`,disabled:W?!Ge:!1,onClick:bt,title:W?H?`Post as @${H}`:"Post to X":"Connect X to post",children:$t})]})},Ft=st&&!Ie,Je=()=>u.jsx("div",{className:"tweet-thread-editors",children:m.map((Y,pe)=>u.jsxs("div",{className:`tweet-thread-item${pe===O?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[u.jsxs("div",{className:"tweet-thread-item-left",children:[u.jsx(Q$,{}),pe<m.length-1&&u.jsx("div",{className:"tweet-thread-line"})]}),u.jsxs("div",{className:"tweet-thread-item-right",children:[pe>0&&u.jsx("button",{className:"tweet-thread-remove",onClick:()=>ot(pe),title:"Remove this tweet",children:"×"}),u.jsx("div",{className:`tweet-compose-box${pe===0&&!We?" tweet-compose-box--standalone":""}`,children:u.jsx(ez,{initialContent:Y,initialPreviewImages:U.current[pe],placeholder:Ke[pe],onUpdate:G=>fe(pe,G),onReady:G=>De(pe,G),onFocus:()=>{R(pe);const G=x.current[pe];G&&(i==null||i(G))},onPreviewImagesChange:G=>{if(U.current[pe]=G,P(oe=>{const ue=[...oe];return ue[pe]=G.length,ue}),!C.current){const oe=yu(x.current,U.current);w.current=JSON.stringify(oe),n==null||n(oe)}}})}),pe===O&&!Ft&&pt(pe<m.length-1)]})]},`${y}-${pe}`))});return u.jsxs("div",{className:"tweet-compose-wrapper",children:[st&&Ie&&u.jsxs(u.Fragment,{children:[f&&u.jsx("div",{className:"tweet-context-section",children:u.jsx(QS,{})}),h&&u.jsx("div",{className:"tweet-context-section",children:u.jsxs("div",{className:"tweet-embed-error",children:[u.jsx("span",{children:"Could not load tweet"}),u.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]})}),d&&u.jsxs("div",{className:"tweet-reply-parent-section",children:[u.jsx("div",{className:"tweet-reply-parent-card",children:u.jsx(Sw,{tweet:d,url:t==null?void 0:t.url})}),u.jsxs("div",{className:"tweet-replying-to",children:["Replying to ",u.jsxs("span",{className:"tweet-reply-handle",children:["@",d.author.username]})]})]}),Je()]}),Ft&&u.jsxs(u.Fragment,{children:[Je(),u.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[f&&u.jsx(QS,{}),h&&u.jsxs("div",{className:"tweet-embed-error",children:[u.jsx("span",{children:"Could not load tweet"}),u.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]}),d&&u.jsx(Sw,{tweet:d,url:t==null?void 0:t.url})]}),u.jsx("div",{className:"tweet-quote-footer",children:pt()})]}),!st&&Je(),re&&u.jsx(nz,{onConnected:xt,onCancel:()=>V(!1)}),se&&o&&u.jsx(jl,{filename:o,title:l||"Untitled",onClose:()=>xe(!1)})]})}function tF(){const[t,e]=k.useState("idle"),n=k.useRef();return{copyAsHtml:k.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>
|
|
210
|
-
`);const d=o+i.innerHTML,f=nF(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 nF(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(`
|
|
211
|
-
|
|
212
|
-
`)}const rg="ow-x-handle",tE="ow-x-name",rF=new Set(["Untitled","New Document","Article"]);function sF({src:t,coverImages:e}){const[n,r]=k.useState(t?"display":"empty"),[s,i]=k.useState(t||""),[o,l]=k.useState(e||(t?[t]:[])),[d,f]=k.useState(""),[h,m]=k.useState(""),g=k.useRef(null);k.useEffect(()=>{t?(i(t),r("display")):e&&e.length>0?(i(e[0]),r("display")):(i(""),r("empty"),f(""),m(""))},[t,e]),k.useEffect(()=>{e&&e.length>0?l(e):l(t?[t]:[])},[e]);const y=s?o.indexOf(s):-1,b=o.length,x=b>1,w=k.useCallback(D=>{const U=o[D];U&&(i(U),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:U,coverImages:o}})}).catch(()=>{}))},[o]),E=k.useCallback(()=>{y>0&&w(y-1)},[y,w]),C=k.useCallback(()=>{y<b-1&&w(y+1)},[y,b,w]),A=k.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const D=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})});if(!D.ok){const Q=await D.json().catch(()=>null);m((Q==null?void 0:Q.error)||`Generation failed (${D.status})`),r("prompt");return}const U=await D.json();if(U.success&&U.src){const Q=[...o,U.src];l(Q),i(U.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:U.src,coverImages:Q}})}).catch(()=>{})}else m(U.error||"Generation failed"),r("prompt")}catch(D){m(D.message||"Network error"),r("prompt")}}},[d,o]),T=D=>{D.key==="Enter"&&A(),D.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var D;return(D=g.current)==null?void 0:D.focus()},0)},O=()=>{const D=o.filter(U=>U!==s);if(l(D),D.length>0){const U=Math.min(y,D.length-1),Q=D[U];i(Q),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:Q,coverImages:D}})}).catch(()=>{})}else i(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},R=()=>{r("prompt"),setTimeout(()=>{var D;return(D=g.current)==null?void 0:D.focus()},0)},B=()=>{const D=document.createElement("a");D.href=s,D.download=`cover-${y+1}.png`,D.click()};return n==="display"&&s?u.jsxs("div",{className:"article-cover article-cover--display",children:[u.jsx("img",{className:"article-cover-img",src:s,alt:"Cover"}),u.jsxs("div",{className:"article-cover-overlay",children:[x&&u.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:E,disabled:y<=0,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"15 18 9 12 15 6"})})}),u.jsxs("div",{className:"article-cover-overlay-center",children:[u.jsxs("button",{className:"article-cover-overlay-btn",onClick:R,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"23 4 23 10 17 10"}),u.jsx("polyline",{points:"1 20 1 14 7 14"}),u.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),u.jsxs("button",{className:"article-cover-overlay-btn",onClick:B,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u.jsx("polyline",{points:"7 10 12 15 17 10"}),u.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),u.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:O,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),x&&u.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:C,disabled:y>=b-1,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})})}),x&&u.jsxs("div",{className:"article-cover-counter",children:[y+1," / ",b]})]})]}):n==="loading"?u.jsxs("div",{className:"article-cover article-cover--loading",children:[u.jsx("div",{className:"article-cover-spinner"}),u.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?u.jsxs("div",{className:"article-cover article-cover--prompt",children:[u.jsxs("div",{className:"article-cover-prompt-row",children:[u.jsx("input",{ref:g,className:"article-cover-prompt-input",value:d,onChange:D=>f(D.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),u.jsx("button",{className:"article-cover-prompt-btn",onClick:A,disabled:!d.trim(),children:"Generate"}),u.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h&&u.jsx("div",{className:"article-cover-error",children:h})]}):u.jsxs("div",{className:"article-cover article-cover--empty",onClick:_,children:[u.jsxs("svg",{className:"article-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),u.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),u.jsx("polyline",{points:"21 15 16 10 5 21"})]}),u.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function iF(){const[t,e]=k.useState(()=>localStorage.getItem(rg)||""),[n,r]=k.useState(()=>localStorage.getItem(tE)||""),[s,i]=k.useState(!1),[o,l]=k.useState(""),d=k.useRef(null),f=k.useRef(null),h=()=>{const b=o.replace(/^@/,"").trim();b&&(localStorage.setItem(rg,b),e(b)),i(!1)},m=()=>{l(t),i(!0),setTimeout(()=>{var b;return(b=d.current)==null?void 0:b.focus()},0)};k.useEffect(()=>{if(!s)return;const b=x=>{f.current&&!f.current.contains(x.target)&&h()};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s,o]),k.useEffect(()=>{const b=()=>{e(localStorage.getItem(rg)||""),r(localStorage.getItem(tE)||"")};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[]);const g=t?`https://unavatar.io/twitter/${t}`:"",y=n||t||"Set your @handle";return u.jsxs("div",{className:"article-byline",ref:f,children:[u.jsxs("div",{className:"article-byline-row",onClick:m,title:t?`@${t} — click to change`:"Set your @handle",children:[t?u.jsx("img",{className:"article-byline-avatar",src:g,alt:`@${t}`}):u.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),u.jsx("span",{className:"article-byline-name",children:y}),t&&u.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),s&&u.jsx("div",{className:"article-byline-popover",children:u.jsx("input",{ref:d,className:"article-byline-input",value:o,onChange:b=>l(b.target.value),onKeyDown:b=>{b.key==="Enter"&&h(),b.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function oF({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s,lastPost:i}){const{copyAsHtml:o,copyState:l}=tF(),[d,f]=k.useState(i?"done":"idle");k.useEffect(()=>{f(i?"done":"idle")},[i]);const h=k.useCallback(()=>{d==="idle"&&(fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{lastPost:{postedAt:new Date().toISOString()}}}),keepalive:!0}).catch(()=>{}),f("done"))},[d]);return u.jsxs("div",{className:"article-compose-wrapper",children:[u.jsx(sF,{src:r,coverImages:s}),u.jsxs("div",{className:"article-compose-content",children:[u.jsx("input",{className:"article-title-input",type:"text",value:rF.has(e||"")?"":e||"",onChange:m=>n==null?void 0:n(m.target.value||"Untitled"),placeholder:"Add a title",spellCheck:!1}),u.jsx(iF,{}),u.jsx("div",{className:"article-compose-body",children:t})]}),u.jsxs("div",{className:"article-compose-footer",children:[u.jsx("button",{className:`article-mark-sent-btn${d==="done"?" article-mark-sent-btn--done":""}`,onClick:d==="done"?void 0:h,title:d==="done"?"Posted":"Mark as manually posted",children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:d==="done"?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"8 12 11 15 16 9",stroke:d==="done"?"#fff":"currentColor"})]})}),d==="done"&&i&&u.jsxs("span",{className:"article-sent-status",children:["Posted ",new Date(i.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})]}),u.jsx("button",{className:`article-copy-btn${l==="copied"?" article-copy-btn--copied":""}`,onClick:o,children:l==="copied"?u.jsxs(u.Fragment,{children:[u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):u.jsxs(u.Fragment,{children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),u.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy as HTML"]})})]})]})}function aF({connectionId:t,repoName:e,title:n,slug:r,onClose:s}){const[i,o]=k.useState("confirm"),[l,d]=k.useState(null),[f,h]=k.useState(null),m=k.useRef(null),g=()=>i==="published"?{publishedAt:new Date().toISOString(),url:f||void 0,repo:e}:void 0;k.useEffect(()=>{const b=x=>{i!=="publishing"&&m.current&&!m.current.contains(x.target)&&s(g())};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[s,i,f]),k.useEffect(()=>{const b=x=>{x.key==="Escape"&&i!=="publishing"&&s(g())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[s,i,f]);async function y(){o("publishing"),d(null);try{const b=await fetch("/api/blog/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:t})}),x=await b.json();if(!b.ok||x.error){d(x.error||`Publish failed (${b.status})`),o("error");return}x.url&&h(x.url),o("published"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:{lastPublish:{publishedAt:new Date().toISOString(),url:x.url||void 0,repo:e}}})}).catch(()=>{})}catch(b){d(b.message),o("error")}}return u.jsx("div",{className:"blog-publish-overlay",children:u.jsxs("div",{className:"blog-publish-modal",ref:m,children:[u.jsxs("div",{className:"blog-publish__header",children:[u.jsx("h3",{children:"Publish to GitHub"}),u.jsx("button",{className:"blog-publish__close",onClick:()=>s(g()),children:"×"})]}),u.jsxs("div",{className:"blog-publish__body",children:[i==="confirm"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"blog-publish__summary",children:[u.jsxs("div",{className:"blog-publish__row",children:[u.jsx("span",{className:"blog-publish__label",children:"Repository"}),u.jsx("span",{className:"blog-publish__value",children:e})]}),u.jsxs("div",{className:"blog-publish__row",children:[u.jsx("span",{className:"blog-publish__label",children:"Title"}),u.jsx("span",{className:"blog-publish__value",children:n})]}),r&&u.jsxs("div",{className:"blog-publish__row",children:[u.jsx("span",{className:"blog-publish__label",children:"Slug"}),u.jsx("span",{className:"blog-publish__value blog-publish__value--mono",children:r})]})]}),u.jsxs("div",{className:"blog-publish__actions",children:[u.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),u.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:y,children:"Publish"})]})]}),i==="publishing"&&u.jsxs("div",{className:"blog-publish__status",children:[u.jsx("div",{className:"blog-publish__spinner"}),u.jsxs("span",{children:["Publishing to ",e,"..."]})]}),i==="published"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"blog-publish__status blog-publish__status--success",children:["Published to ",e,"!"]}),f&&u.jsx("a",{className:"blog-publish__link",href:f,target:"_blank",rel:"noopener noreferrer",children:"View on GitHub"}),u.jsx("div",{className:"blog-publish__actions",children:u.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:()=>s({publishedAt:new Date().toISOString(),url:f||void 0,repo:e}),children:"Done"})})]}),i==="error"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"blog-publish__error",children:l}),u.jsxs("div",{className:"blog-publish__actions",children:[u.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),u.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:y,children:"Retry"})]})]})]})]})})}const nE={font:"sans",width:"standard",spacing:"comfortable"},rE=new Set(["Untitled","New Document","Blog"]);function lF(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function sE(){return new Date().toISOString().split("T")[0]}function Cs(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function cF({src:t,coverImages:e}){const[n,r]=k.useState(t?"display":"empty"),[s,i]=k.useState(t||""),[o,l]=k.useState(e||(t?[t]:[])),[d,f]=k.useState(""),[h,m]=k.useState(""),g=k.useRef(null);k.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),k.useEffect(()=>{e&&e.length>0?l(e):l(t?[t]:[])},[e]);const y=s?o.indexOf(s):-1,b=o.length,x=b>1,w=k.useCallback(D=>{const U=o[D];U&&(i(U),Cs({coverImage:U,coverImages:o}))},[o]),E=k.useCallback(()=>{y>0&&w(y-1)},[y,w]),C=k.useCallback(()=>{y<b-1&&w(y+1)},[y,b,w]),A=k.useCallback(async()=>{if(d.trim()){r("loading"),m("");try{const D=await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:d.trim()})});if(!D.ok){const Q=await D.json().catch(()=>null);m((Q==null?void 0:Q.error)||`Generation failed (${D.status})`),r("prompt");return}const U=await D.json();if(U.success&&U.src){const Q=[...o,U.src];l(Q),i(U.src),r("display"),f(""),Cs({coverImage:U.src,coverImages:Q})}else m(U.error||"Generation failed"),r("prompt")}catch(D){m(D.message||"Network error"),r("prompt")}}},[d,o]),T=D=>{D.key==="Enter"&&A(),D.key==="Escape"&&(r("empty"),f(""),m(""))},_=()=>{r("prompt"),setTimeout(()=>{var D;return(D=g.current)==null?void 0:D.focus()},0)},O=()=>{const D=o.filter(U=>U!==s);if(l(D),D.length>0){const U=Math.min(y,D.length-1),Q=D[U];i(Q),Cs({coverImage:Q,coverImages:D})}else i(""),r("empty"),Cs({coverImage:void 0,coverImages:void 0})},R=()=>{r("prompt"),setTimeout(()=>{var D;return(D=g.current)==null?void 0:D.focus()},0)},B=()=>{const D=document.createElement("a");D.href=s,D.download=`cover-${y+1}.png`,D.click()};return n==="display"&&s?u.jsxs("div",{className:"blog-cover blog-cover--display",children:[u.jsx("img",{className:"blog-cover-img",src:s,alt:"Cover"}),u.jsxs("div",{className:"blog-cover-overlay",children:[x&&u.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:E,disabled:y<=0,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"15 18 9 12 15 6"})})}),u.jsxs("div",{className:"blog-cover-overlay-center",children:[u.jsxs("button",{className:"blog-cover-btn",onClick:R,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("polyline",{points:"23 4 23 10 17 10"}),u.jsx("polyline",{points:"1 20 1 14 7 14"}),u.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),u.jsxs("button",{className:"blog-cover-btn",onClick:B,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),u.jsx("polyline",{points:"7 10 12 15 17 10"}),u.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),u.jsxs("button",{className:"blog-cover-btn blog-cover-btn--danger",onClick:O,children:[u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),x&&u.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:C,disabled:y>=b-1,children:u.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})})}),x&&u.jsxs("div",{className:"blog-cover-counter",children:[y+1," / ",b]})]})]}):n==="loading"?u.jsxs("div",{className:"blog-cover blog-cover--loading",children:[u.jsx("div",{className:"blog-cover-spinner"}),u.jsx("span",{className:"blog-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?u.jsxs("div",{className:"blog-cover blog-cover--prompt",children:[u.jsxs("div",{className:"blog-cover-prompt-row",children:[u.jsx("input",{ref:g,className:"blog-cover-prompt-input",value:d,onChange:D=>f(D.target.value),onKeyDown:T,placeholder:"Describe your cover image...",spellCheck:!1}),u.jsx("button",{className:"blog-cover-prompt-btn",onClick:A,disabled:!d.trim(),children:"Generate"}),u.jsx("button",{className:"blog-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),h&&u.jsx("div",{className:"blog-cover-error",children:h})]}):u.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:_,children:[u.jsxs("svg",{className:"blog-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),u.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),u.jsx("polyline",{points:"21 15 16 10 5 21"})]}),u.jsx("span",{className:"blog-cover-hint",children:"Add a featured image"})]})}function uF({tags:t,onChange:e}){const[n,r]=k.useState(""),s=k.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 u.jsxs("div",{className:"blog-tags",onClick:()=>{var d;return(d=s.current)==null?void 0:d.focus()},children:[t.map(d=>u.jsxs("span",{className:"blog-tag",children:[d,u.jsx("button",{className:"blog-tag-remove",onClick:f=>{f.stopPropagation(),o(d)},children:u.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[u.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},d)),u.jsx("input",{ref:s,className:"blog-tag-input",value:n,onChange:d=>r(d.target.value),onKeyDown:l,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function dF({style:t,onChange:e}){const n=r=>`blog-style-btn${r?" active":""}`;return u.jsxs("div",{className:"blog-style-controls",children:[u.jsxs("div",{className:"blog-style-group",children:[u.jsx("span",{className:"blog-style-label",children:"Font"}),u.jsx("button",{className:n(t.font==="sans"),onClick:()=>e({...t,font:"sans"}),title:"Sans-serif",children:"Aa"}),u.jsx("button",{className:`${n(t.font==="serif")} serif-btn`,onClick:()=>e({...t,font:"serif"}),title:"Serif",children:"Aa"}),u.jsx("button",{className:`${n(t.font==="mono")} mono-btn`,onClick:()=>e({...t,font:"mono"}),title:"Monospace",children:"Aa"})]}),u.jsxs("div",{className:"blog-style-group",children:[u.jsx("span",{className:"blog-style-label",children:"Width"}),u.jsx("button",{className:n(t.width==="narrow"),onClick:()=>e({...t,width:"narrow"}),title:"Narrow (600px)",children:u.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:u.jsx("rect",{x:"4",y:"1",width:"8",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),u.jsx("button",{className:n(t.width==="standard"),onClick:()=>e({...t,width:"standard"}),title:"Standard (720px)",children:u.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:u.jsx("rect",{x:"2",y:"1",width:"12",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),u.jsx("button",{className:n(t.width==="wide"),onClick:()=>e({...t,width:"wide"}),title:"Wide (900px)",children:u.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:u.jsx("rect",{x:"0.5",y:"1",width:"15",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})})]}),u.jsxs("div",{className:"blog-style-group",children:[u.jsx("span",{className:"blog-style-label",children:"Spacing"}),u.jsx("button",{className:n(t.spacing==="compact"),onClick:()=>e({...t,spacing:"compact"}),title:"Compact",children:u.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[u.jsx("line",{x1:"1",y1:"3",x2:"15",y2:"3"}),u.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),u.jsx("line",{x1:"1",y1:"11",x2:"15",y2:"11"})]})}),u.jsx("button",{className:n(t.spacing==="comfortable"),onClick:()=>e({...t,spacing:"comfortable"}),title:"Comfortable",children:u.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[u.jsx("line",{x1:"1",y1:"2",x2:"15",y2:"2"}),u.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),u.jsx("line",{x1:"1",y1:"12",x2:"15",y2:"12"})]})})]})]})}function fF({children:t,title:e,onTitleChange:n,blogContext:r,filename:s}){var ie;const i=r||{},[o,l]=k.useState(i.description||""),[d,f]=k.useState(!1),[h,m]=k.useState(i.date||sE()),[g,y]=k.useState(i.tags||[]),[b,x]=k.useState(i.author||""),[w,E]=k.useState(i.slug||""),[C,A]=k.useState(i.draft??!1),[T,_]=k.useState({...nE,...i.style}),[O,R]=k.useState(!1),[B,D]=k.useState(!!i.slug),[U,Q]=k.useState(null),[P,W]=k.useState(!1);k.useEffect(()=>{fetch("/api/blog/connection").then(z=>z.json()).then(z=>{z.connection&&Q(z.connection)}).catch(()=>{})},[]),k.useEffect(()=>{!B&&e&&!rE.has(e)&&E(lF(e))},[e,B]),k.useEffect(()=>{l(i.description||""),m(i.date||sE()),y(i.tags||[]),x(i.author||""),E(i.slug||""),A(i.draft??!1),_({...nE,...i.style}),D(!!i.slug)},[r]);const $=!!(r!=null&&r.active),H=k.useCallback(()=>{$&&Cs({description:o,date:h,tags:g,author:b,slug:w,draft:C,style:T})},[$,o,h,g,b,w,C,T]);k.useEffect(()=>{$&&Cs({tags:g})},[$,g]),k.useEffect(()=>{$&&Cs({style:T})},[$,T]),k.useEffect(()=>{$&&Cs({draft:C})},[$,C]);const J=o.length,re=J>160,V=["blog-compose-wrapper",`blog--font-${T.font}`,`blog--width-${T.width}`,`blog--spacing-${T.spacing}`].join(" ");return u.jsxs("div",{className:V,children:[u.jsx(cF,{src:i.coverImage,coverImages:i.coverImages}),u.jsxs("div",{className:"blog-compose-content",children:[((ie=i.lastPublish)==null?void 0:ie.publishedAt)&&u.jsxs("a",{className:"blog-published-status",href:i.lastPublish.url,target:"_blank",rel:"noopener noreferrer",title:i.lastPublish.url||`Published to ${i.lastPublish.repo||"GitHub"}`,children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Published ",new Date(i.lastPublish.publishedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),i.lastPublish.repo?` to ${i.lastPublish.repo.split("/").pop()}`:""]}),u.jsx("input",{className:"blog-title-input",type:"text",value:rE.has(e||"")?"":e||"",onChange:z=>n==null?void 0:n(z.target.value||"Untitled"),placeholder:"Post title",spellCheck:!1}),u.jsxs("div",{className:"blog-description-wrap",children:[u.jsx("textarea",{className:`blog-description-input${re?" over-limit":""}`,value:o,onChange:z=>l(z.target.value),onBlur:H,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),u.jsxs("span",{className:`blog-description-count${re?" over-limit":""}`,children:[J,"/160"]})]}),u.jsxs("div",{className:"blog-meta-toggle",onClick:()=>R(z=>!z),children:[u.jsx("svg",{className:`blog-meta-chevron${O?" open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"9 18 15 12 9 6"})}),u.jsx("span",{children:"Metadata"}),C&&u.jsx("span",{className:"blog-draft-badge",children:"Draft"})]}),O&&u.jsxs("div",{className:"blog-meta-fields",children:[u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Date"}),u.jsx("input",{type:"date",className:"blog-meta-input",value:h,onChange:z=>m(z.target.value),onBlur:H})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Author"}),u.jsx("input",{type:"text",className:"blog-meta-input",value:b,onChange:z=>x(z.target.value),onBlur:H,placeholder:"Author name",spellCheck:!1})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Slug"}),u.jsx("input",{type:"text",className:"blog-meta-input",value:w,onChange:z=>{D(!0),E(z.target.value)},onBlur:H,placeholder:"auto-generated-from-title",spellCheck:!1})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Tags"}),u.jsx(uF,{tags:g,onChange:y})]}),u.jsxs("div",{className:"blog-meta-row",children:[u.jsx("label",{className:"blog-meta-label",children:"Draft"}),u.jsx("button",{className:`blog-draft-toggle${C?" active":""}`,onClick:()=>A(z=>!z),children:u.jsx("div",{className:"blog-draft-toggle-knob"})})]})]}),u.jsx("div",{className:"blog-compose-body",children:t})]}),u.jsxs("div",{className:"blog-compose-footer",children:[u.jsx(dF,{style:T,onChange:_}),s&&u.jsxs("div",{className:"blog-footer-actions",children:[U&&u.jsxs("button",{className:"blog-footer-btn blog-footer-btn--primary",onClick:()=>W(!0),children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})}),"Publish"]}),u.jsxs("button",{className:"blog-footer-btn",onClick:()=>f(!0),children:[u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]})]}),d&&s&&u.jsx(jl,{filename:s,title:e||"Untitled",onClose:()=>f(!1)}),P&&U&&u.jsx(aF,{connectionId:U.id,repoName:U.display_name,title:e||"Untitled",slug:w,onClose:z=>{W(!1),z&&Cs({lastPublish:z})}})]})}function hF({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,o]=k.useState("confirm"),[l,d]=k.useState("html"),[f,h]=k.useState(""),[m,g]=k.useState(null),[y,b]=k.useState(null),[x,w]=k.useState(0),[E,C]=k.useState(null),[A,T]=k.useState(null),[_,O]=k.useState("all"),[R,B]=k.useState([]),[D,U]=k.useState(""),Q=k.useRef(null),P=R.find(J=>J.id===D),W=_==="exclude_issue"&&P&&A!=null?Math.max(0,A-P.recipient_count):A;k.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(J=>J.json()).then(J=>{var V,ie;const re=(ie=(V=J.content)==null?void 0:V[0])!=null&&ie.text?JSON.parse(J.content[0].text):J;re.count!=null&&T(re.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(J=>J.json()).then(J=>{var V,ie;const re=(ie=(V=J.content)==null?void 0:V[0])!=null&&ie.text?JSON.parse(J.content[0].text):J;re.issues&&B(re.issues)}).catch(()=>{})},[]);const $=()=>i==="sent"?{sentCount:x,issueId:E,sentAt:new Date().toISOString()}:void 0;k.useEffect(()=>{const J=re=>{i!=="sending"&&i!=="testing"&&Q.current&&!Q.current.contains(re.target)&&s($())};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[s,i,x,E]),k.useEffect(()=>{const J=re=>{re.key==="Escape"&&i!=="sending"&&i!=="testing"&&s($())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[s,i,x,E]);async function H(J){var re,V;o(J?"testing":"sending"),b(null);try{r&&await r();const ie={subject:e,connectionId:t,format:l};J&&(ie.test_email=J),!J&&_==="exclude_issue"&&D&&(ie.exclude_issue_id=D);const M=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"send_newsletter",arguments:ie})})).json(),I=(V=(re=M.content)==null?void 0:re[0])!=null&&V.text?JSON.parse(M.content[0].text):M;if(I.error){b(I.error),o("error");return}if(I.test){g(I.sent_to),o("confirm");return}const Z=I.sent||0,le=I.issueId||null,ge=new Date().toISOString();w(Z),C(le),o("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:Z,sentAt:ge,issueId:le||void 0}}})}).catch(()=>{})}catch(ie){b(ie.message),o("error")}}return u.jsx("div",{className:"newsletter-modal-overlay",children:u.jsxs("div",{className:"newsletter-modal",ref:Q,children:[u.jsxs("div",{className:"newsletter-modal__header",children:[u.jsx("h3",{children:"Send Newsletter"}),u.jsx("button",{className:"newsletter-modal__close",onClick:()=>s($()),children:"×"})]}),u.jsxs("div",{className:"newsletter-modal__body",children:[i==="confirm"&&u.jsxs(u.Fragment,{children:[u.jsxs("p",{className:"newsletter-modal__confirm-text",style:W==null?{visibility:"hidden"}:void 0,children:['Send "',u.jsx("strong",{children:e}),'" to ',W!=null?W.toLocaleString():0," subscriber",W!==1?"s":"","?"]}),u.jsxs("div",{className:"newsletter-modal__audience",children:[u.jsx("label",{className:"newsletter-modal__label",children:"Audience"}),u.jsxs("select",{className:"newsletter-modal__select",value:_,onChange:J=>{const re=J.target.value;O(re),re==="all"&&U("")},children:[u.jsx("option",{value:"all",children:"All subscribers"}),R.length>0&&u.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),_==="exclude_issue"&&u.jsxs("select",{className:"newsletter-modal__select",value:D,onChange:J=>U(J.target.value),children:[u.jsx("option",{value:"",children:"Select a past issue"}),R.map(J=>u.jsxs("option",{value:J.id,children:[J.subject," (",J.recipient_count," sent)"]},J.id))]})]}),u.jsxs("div",{className:"newsletter-modal__format-toggle",children:[u.jsx("button",{className:`newsletter-modal__format-btn${l==="html"?" active":""}`,onClick:()=>d("html"),children:"HTML"}),u.jsx("button",{className:`newsletter-modal__format-btn${l==="plaintext"?" active":""}`,onClick:()=>d("plaintext"),children:"Plaintext"})]}),u.jsxs("div",{className:"newsletter-modal__test-section",children:[u.jsxs("div",{className:"newsletter-modal__test-row",children:[u.jsx("input",{type:"email",className:"newsletter-modal__test-input",placeholder:"Test email address",value:f,onChange:J=>h(J.target.value),onKeyDown:J=>{J.key==="Enter"&&f.trim()&&H(f.trim())}}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>H(f.trim()),children:"Send Test"})]}),m&&u.jsxs("p",{className:"newsletter-modal__test-success",children:["Test sent to ",m]})]}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",disabled:_==="exclude_issue"&&!D,onClick:()=>H(),children:"Send Now"})]})]}),(i==="sending"||i==="testing")&&u.jsxs("div",{className:"newsletter-modal__status",children:[u.jsx("div",{className:"newsletter-modal__spinner"}),u.jsx("span",{children:i==="testing"?"Sending test...":"Sending..."})]}),i==="sent"&&u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:["Sent to ",x," subscriber",x!==1?"s":"","!"]}),u.jsx("div",{className:"newsletter-modal__actions",children:u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:x,issueId:E,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"newsletter-modal__error",children:y}),u.jsxs("div",{className:"newsletter-modal__actions",children:[u.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),u.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>H(),children:"Retry"})]})]})]})]})})}function iE(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function pF({children:t,newsletterContext:e,filename:n,title:r,onTitleChange:s,onBeforeSend:i}){var $;const o=e||{},[l,d]=k.useState(o.subject||""),[f,h]=k.useState(o.previewText||""),[m,g]=k.useState([]),[y,b]=k.useState(null),[x,w]=k.useState(!1),[E,C]=k.useState(($=o.lastSend)!=null&&$.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null),A=k.useRef(null),T=k.useRef(n),_=k.useRef(o.subject||""),O=k.useRef(o.previewText||"");k.useEffect(()=>{var H;if(T.current!==n)d(o.subject||""),h(o.previewText||""),_.current=o.subject||"",O.current=o.previewText||"",T.current=n;else{const J=o.subject||"",re=o.previewText||"";J!==_.current&&(d(J),_.current=J),re!==O.current&&(h(re),O.current=re)}C((H=o.lastSend)!=null&&H.sentAt?{sentCount:o.lastSend.sentCount,issueId:o.lastSend.issueId||null,sentAt:o.lastSend.sentAt}:null)},[e,n]),k.useEffect(()=>{fetch("/api/connections").then(H=>H.json()).then(H=>{const J=(H.connections||[]).filter(re=>re.provider==="newsletter"&&re.status==="active");g(J)}).catch(()=>{})},[]);const R=!!(e!=null&&e.active),B=k.useRef();k.useEffect(()=>{if(B.current&&clearTimeout(B.current),!(!s||!l.trim()))return B.current=setTimeout(async()=>{const H=r,J=!H||H==="Untitled",re=A.current!==null&&H===A.current;if(J||re){try{await fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{subject:l}})})}catch{}s(l.trim()),A.current=l.trim()}},500),()=>{B.current&&clearTimeout(B.current)}},[l,r,s]);const D=k.useCallback(()=>{R&&(_.current=l,O.current=f,iE({subject:l,previewText:f}))},[R,l,f]),U=f.length,Q=U>=90,P=U>150,W=()=>{m.length===1&&b(m[0].id),m.length>1&&b(m[0].id)};return u.jsxs("div",{className:"nl-compose-wrapper",children:[E&&u.jsxs("div",{className:"nl-sent-status",children:[u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:u.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent ",new Date(E.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",E.sentCount," subscriber",E.sentCount!==1?"s":""]}),u.jsxs("div",{className:"nl-compose-content",children:[u.jsx("input",{className:"nl-subject-input",type:"text",value:l,onChange:H=>d(H.target.value),onBlur:D,placeholder:"Subject line (defaults to title if empty)",autoComplete:"off","data-lpignore":"true","data-1p-ignore":!0,spellCheck:!1}),u.jsxs("div",{className:"nl-preview-wrap",children:[u.jsx("textarea",{className:`nl-preview-input${P?" over-limit":""}`,value:f,onChange:H=>h(H.target.value),onBlur:D,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),u.jsxs("span",{className:`nl-preview-count${P?" over-limit":Q?" full":""}`,children:[U,"/90"]})]}),u.jsx("div",{className:"nl-compose-body",children:t})]}),n&&u.jsxs("div",{className:"nl-compose-footer",children:[m.length>0&&u.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:W,children:[u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),u.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Send"]}),u.jsxs("button",{className:"nl-footer-btn",onClick:()=>w(!0),children:[u.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u.jsx("circle",{cx:"12",cy:"12",r:"10"}),u.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]}),y&&n&&u.jsx(hF,{connectionId:y,subject:l||r||"Untitled",filename:n,onBeforeSend:i,onClose:H=>{b(null),H&&(C(H),iE({lastSend:{sentCount:H.sentCount,sentAt:H.sentAt,issueId:H.issueId||void 0}}))}}),x&&n&&u.jsx(jl,{filename:n,title:r||"Untitled",onClose:()=>w(!1)})]})}function mF(t){const e=t==null?void 0:t.articleContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function gF(t){const e=t==null?void 0:t.blogContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function vF(t){const e=t==null?void 0:t.newsletterContext;return e!=null&&typeof e=="object"&&(e.active===!0||Object.keys(e).length>0)}function yF(){var an,ft,En;const t=k.useRef(null),e=k.useRef([]),[n,r]=k.useState(null),[s,i]=k.useState(null),[o,l]=k.useState([]),[d,f]=k.useState("Untitled"),[h,m]=k.useState(void 0),[g,y]=k.useState(0),[b,x]=k.useState(!0),[w,E]=k.useState(0),[C,A]=k.useState(0),[T,_]=k.useState(0),[O,R]=k.useState({filenames:[],counts:{}}),[B,D]=k.useState({state:"unconfigured"}),[U,Q]=k.useState(!1),[P,W]=k.useState({}),[$,H]=k.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[J,re]=k.useState(null),[V,ie]=k.useState(null),[z,M]=k.useState(new Set),I=k.useRef(0),Z=k.useRef(null),le=1500,ge=k.useCallback((ne,ke)=>{Z.current&&(clearTimeout(Z.current),Z.current=null),I.current=Date.now(),re(ne),ie(ke)},[]),se=k.useCallback(()=>{if(Z.current)return;const ne=Date.now()-I.current,ke=le-ne;ke<=0?(re(null),ie(null)):Z.current=setTimeout(()=>{Z.current=null,re(null),ie(null)},ke)},[]),[,xe]=k.useState(0),[fe,De]=k.useState(null),We=k.useRef(null),Qe=k.useRef(null),ot=k.useRef(null),st=k.useRef([]),Ie=k.useRef(-1),dt=k.useRef(null),Ge=k.useRef(!1),bt=k.useRef(""),[xt,$t]=k.useState(""),[Ke,pt]=k.useState(!1),[Ft,Je]=k.useState(!1);function Y(){const ne=document.querySelector(".editor-container");return(ne==null?void 0:ne.scrollTop)||0}function pe(){if(Ie.current<0)return;const ne=st.current[Ie.current];ne&&(ne.scrollTop=Y())}const G=mF(P),oe=gF(P),ue=vF(P);k.useEffect(()=>(G?document.documentElement.setAttribute("data-view","article"):oe?document.documentElement.setAttribute("data-view","blog"):ue?document.documentElement.setAttribute("data-view","newsletter"):P!=null&&P.tweetContext?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[P==null?void 0:P.tweetContext,G,oe,ue]),k.useEffect(()=>{const ne=()=>xe(ke=>ke+1);return window.addEventListener("ow-sidebar-mode-change",ne),()=>window.removeEventListener("ow-sidebar-mode-change",ne)},[]),k.useEffect(()=>{fetch("/api/document",{cache:"no-store"}).then(ne=>ne.json()).then(ne=>{ne.document&&(m(ne.document),Qe.current=ne.document),ne.title&&f(ne.title),ne.metadata&&W(ne.metadata)}).catch(()=>{m(void 0)}),fetch("/api/pending-docs").then(ne=>ne.json()).then(ne=>R(ne)).catch(()=>{}),fetch("/api/sync/status").then(ne=>ne.json()).then(ne=>D(ne)).catch(()=>{})},[]);const Fe=k.useCallback(ne=>{t.current=ne,r(ne),i(null),e.current=[ne],l([ne])},[]),Me=k.useRef([]),K=k.useCallback(ne=>{if(e.current=ne,l(ne),Me.current.length>0&&ne.length>0){const ke=Me.current;Me.current=[];for(const $e of ne)$e.isDestroyed||kp($e,ke)}},[]),me=k.useCallback(ne=>{var xn;const ke=performance.now(),$e=window.__lastSwitch;$e&&$e.filename===ne.filename?($e.tReceive=ke,console.log(`[Switch] RECEIVE filename=${ne.filename} sendToReceive=${(ke-$e.tSend).toFixed(1)}ms (server round-trip)`)):console.log(`[Switch] RECEIVE filename=${ne.filename} (no matching CLICK — agent or initial-load switch)`),We.current&&(clearTimeout(We.current),We.current=null);const at=bt.current==="",Nt=ne.filename===bt.current;bt.current=ne.filename,Qe.current=ne.document,ot.current=JSON.stringify(ne.document),$t(ne.filename),m(ne.document),f(ne.title),W(ne.metadata||{}),!Nt&&!at&&((xn=ne.metadata)!=null&&xn.tweetContext)&&y(Zt=>Zt+1),E(Zt=>Zt+1),$e&&$e.filename===ne.filename&&requestAnimationFrame(()=>{const Zt=performance.now();$e.tCommit=Zt,console.log(`[Switch] COMMIT filename=${ne.filename} receiveToCommit=${(Zt-ke).toFixed(1)}ms totalClickToPaint=${(Zt-$e.tClick).toFixed(1)}ms`)});const ln=dt.current??"push";if(dt.current=null,st.current.length===0?(st.current=[{filename:ne.filename,scrollTop:0}],Ie.current=0):ln==="back"?Ie.current=Math.max(0,Ie.current-1):ln==="forward"?Ie.current=Math.min(st.current.length-1,Ie.current+1):Nt||(st.current=st.current.slice(0,Ie.current+1),st.current.push({filename:ne.filename,scrollTop:0}),Ie.current=st.current.length-1),!Ge.current){const Zt=`#${encodeURIComponent(ne.filename)}`,tn={ow:{filename:ne.filename,navIndex:Ie.current}};st.current.length===1||Nt?window.history.replaceState(tn,"",Zt):window.history.pushState(tn,"",Zt)}if(Ge.current=!1,ln==="back"||ln==="forward"){const Zt=st.current[Ie.current];Zt&&setTimeout(()=>{const tn=document.querySelector(".editor-container");tn&&(tn.scrollTop=Zt.scrollTop)},50)}pt(Ie.current>0),Je(Ie.current<st.current.length-1)},[]),ye=k.useCallback(ne=>{We.current&&(clearTimeout(We.current),We.current=null),Qe.current=ne.document,ot.current=JSON.stringify(ne.document),m(ne.document),f(ne.title),W(ne.metadata||{}),De(ke=>ke?{filename:ne.filename,orphanCount:ke.orphanCount+ne.orphanCount,staleBaselineCount:ke.staleBaselineCount+ne.staleBaselineCount,reloadCount:ke.reloadCount+1}:{filename:ne.filename,orphanCount:ne.orphanCount,staleBaselineCount:ne.staleBaselineCount,reloadCount:1})},[]),Ce=k.useCallback(()=>{E(ne=>ne+1),A(ne=>ne+1)},[]),Re=k.useCallback(()=>{_(ne=>ne+1)},[]),Be=k.useCallback(ne=>{R(ne)},[]),{connected:Ee,sendMessage:et,docVersionRef:gt}=U8({onNodeChanges:ne=>{const ke=e.current;if(ke.length<=1){const $e=t.current;if(!$e)return;kp($e,ne)}else{if(ke.some(at=>at.isDestroyed)){Me.current.push(...ne);return}for(const at of ke)kp(at,ne)}},onDocumentSwitched:me,onDocumentReloaded:ye,onDocumentsChanged:Ce,onWorkspacesChanged:Re,onPendingDocsChanged:Be,onMetadataChanged:ne=>W(ne),onWritingStarted:(ne,ke)=>ge(ne,ke),onWritingFinished:()=>se(),onIdRewrites:ne=>{const ke=e.current,$e=ke.length>0?ke:t.current?[t.current]:[];for(const Nt of $e)Nt.isDestroyed||_5(Nt,ne);const at=Qe.current;if(at&&Array.isArray(ne)&&ne.length>0){const Nt=new Map(ne.map(xn=>[xn.oldId,xn.newId])),ln=xn=>{var Zt;if(Array.isArray(xn))for(const tn of xn){const Is=(Zt=tn==null?void 0:tn.attrs)==null?void 0:Zt.id;Is&&Nt.has(Is)&&(tn.attrs={...tn.attrs,id:Nt.get(Is)}),tn!=null&&tn.content&&ln(tn.content)}};ln(at.content||[])}},onPendingFilenamesChanged:ne=>M(ne),onSyncStatus:ne=>D(ne),onTitleChanged:ne=>f(ne),getEditorState:()=>{var ke;const ne=Qe.current||((ke=t.current)==null?void 0:ke.getJSON());return ne?{document:ne}:null}}),Tt=k.useCallback(()=>{var $e;We.current&&(clearTimeout(We.current),We.current=null);const ne=Qe.current||(($e=t.current)==null?void 0:$e.getJSON());if(!ne)return;const ke=JSON.stringify(ne);ke!==ot.current&&(et({type:"doc-update",document:ne,filename:bt.current,version:gt.current}),ot.current=ke)},[et,gt]),Jt=k.useCallback(async()=>{var ke;const ne=Qe.current||((ke=t.current)==null?void 0:ke.getJSON());ne&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:ne,filename:bt.current})})},[]);k.useEffect(()=>{const ne=()=>{var Nt;We.current&&(clearTimeout(We.current),We.current=null);const $e=Qe.current||((Nt=t.current)==null?void 0:Nt.getJSON());if(!$e)return;const at=JSON.stringify({type:"flush",document:$e});navigator.sendBeacon("/api/flush",new Blob([at],{type:"application/json"}))},ke=()=>{document.visibilityState==="hidden"&&ne()};return window.addEventListener("beforeunload",ne),document.addEventListener("visibilitychange",ke),()=>{window.removeEventListener("beforeunload",ne),document.removeEventListener("visibilitychange",ke)}},[]);const Mt=k.useCallback(()=>{Tt(),et({type:"create-document"})},[Tt,et]),q=k.useCallback(ne=>{if(ne===bt.current)return;const ke=performance.now();window.__lastSwitch={filename:ne,tClick:ke,tSend:0,tReceive:0,tCommit:0},console.log(`[Switch] CLICK filename=${ne} t=${ke.toFixed(0)}`),pe(),dt.current="push",Tt(),et({type:"switch-document",filename:ne});const $e=performance.now();window.__lastSwitch.tSend=$e,console.log(`[Switch] SEND filename=${ne} clickToSend=${($e-ke).toFixed(1)}ms`)},[Tt,et]),L=k.useRef(null),te=k.useCallback(async ne=>{let ke=null;if(ne.docId)try{const $e=await fetch("/api/documents").then(at=>at.json());if(Array.isArray($e)){const at=$e.find(Nt=>Nt.docId===ne.docId);at&&(ke=at.filename)}}catch{}if(!ke&&ne.filename&&(ke=ne.filename),!ke){console.warn("[link] could not resolve doc: target",ne);return}ne.nodeId||ne.quote?L.current={nodeId:ne.nodeId||void 0,quote:ne.quote||void 0}:L.current={toTop:!0},q(ke)},[q]);k.useEffect(()=>{const ne=ke=>{const $e=ke.detail;$e&&te($e)};return window.addEventListener("ow-navigate-to-link",ne),()=>window.removeEventListener("ow-navigate-to-link",ne)},[te]);const ve=k.useRef(!1);k.useEffect(()=>{if(ve.current)return;ve.current=!0;const ne=window.location.pathname.match(/^\/d\/([a-f0-9]{8})\/?$/);if(!ne)return;const ke=ne[1],$e=window.location.hash.match(/^#node=([a-f0-9]{8})$/),at=$e?$e[1]:null;te({docId:ke,filename:null,nodeId:at,quote:null})},[te]),k.useEffect(()=>{if(!n||!L.current)return;const ne=L.current;L.current=null,setTimeout(()=>{if(ne.toTop){const at=document.querySelector(".editor-container");at&&(at.scrollTop=0);return}let ke=null;if(ne.nodeId&&n.state.doc.descendants((at,Nt)=>{var ln;return ke!==null?!1:((ln=at.attrs)==null?void 0:ln.id)===ne.nodeId?(ke=Nt+1,!1):!0}),ke===null&&ne.quote){const at=ne.quote;n.state.doc.descendants((Nt,ln)=>{if(ke!==null)return!1;if(Nt.isTextblock){const xn=Nt.textContent.indexOf(at);if(xn>=0)return ke=ln+1+xn,!1}return!0})}if(ke===null)return;n.chain().focus().setTextSelection({from:ke,to:ke}).scrollIntoView().run();const $e=n.view.nodeDOM(ke-1);$e!=null&&$e.classList&&($e.classList.add("scroll-target-flash"),setTimeout(()=>$e.classList.remove("scroll-target-flash"),1200))},100)},[n,xt]);const Ue=k.useCallback(()=>{Ie.current<=0||window.history.back()},[]),lt=k.useCallback(()=>{Ie.current>=st.current.length-1||window.history.forward()},[]);k.useEffect(()=>{const ne=ke=>{const $e=ke.state&&ke.state.ow;$e!=null&&$e.filename&&$e.filename!==bt.current&&(pe(),dt.current=$e.navIndex<Ie.current?"back":"forward",Ge.current=!0,Tt(),et({type:"switch-document",filename:$e.filename}))};return window.addEventListener("popstate",ne),()=>window.removeEventListener("popstate",ne)},[Tt,et]);const Ae=k.useCallback(()=>{const ne=bt.current,ke=t.current;if(!ne||!ke)return;const $e=()=>{const at=e.current;if(at.length>1)for(const Nt of at)Nt!=null&&Nt.view&&Z1(Nt.view);else ke!=null&&ke.view&&Z1(ke.view)};fetch(`/api/comments/${encodeURIComponent(ne)}`).then(at=>at.json()).then(at=>{Y1(at.comments||[]),$e()}).catch(()=>{Y1([]),$e()})},[]);k.useEffect(()=>{Ae()},[xt,n,Ae]),k.useEffect(()=>{const ne=ke=>{const $e=ke.detail;($e==null?void 0:$e.filename)===bt.current&&Ae()};return window.addEventListener("ow-comments-changed",ne),()=>window.removeEventListener("ow-comments-changed",ne)},[Ae]),k.useEffect(()=>{const ne=P==null?void 0:P.docId;if(!ne){ew([]);return}let ke=!1;return fetch(`/api/backlinks/${ne}`).then($e=>$e.ok?$e.json():[]).then($e=>{if(ke)return;ew(Array.isArray($e)?$e:[]);const at=e.current.length>0?e.current:n?[n]:[];for(const Nt of at)Nt!=null&&Nt.view&&VB(Nt.view)}).catch(()=>{}),()=>{ke=!0}},[P,n]),k.useEffect(()=>{const ne=ke=>{ke.altKey&&ke.key==="ArrowLeft"&&(ke.preventDefault(),Ue()),ke.altKey&&ke.key==="ArrowRight"&&(ke.preventDefault(),lt())};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[Ue,lt]);const de=k.useCallback(ne=>{Qe.current=ne,We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{const ke=Qe.current||ne,$e=JSON.stringify(ke);$e!==ot.current&&(et({type:"doc-update",document:ke,filename:bt.current,version:gt.current}),ot.current=$e)},1e3)},[et,gt]),_e=k.useCallback(ne=>{f(ne),et({type:"title-update",title:ne})},[et]),ze=k.useCallback(()=>{H(ne=>(localStorage.setItem("ow-toolbar",ne?"hidden":"visible"),!ne))},[]),Wt=k.useCallback(()=>{if(B.state==="unconfigured"){Q(!0);return}Tt(),et({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[B.state,Tt,et]),wt=Cd()==="board";return u.jsxs("div",{className:"app",children:[!wt&&u.jsx(kw,{open:b,onSwitchDocument:q,onCreateDocument:Mt,refreshKey:w,docTagsRefreshKey:C,workspacesRefreshKey:T,pendingDocs:O,writingTitle:J,writingTarget:V,pendingWriteFilenames:z,onClose:()=>x(!1)}),u.jsxs("div",{className:"app-main",children:[u.jsx(S5,{title:d,onTitleChange:_e,syncStatus:B,onSync:Wt,onToggleSidebar:!wt&&!b?()=>x(!0):void 0,canGoBack:Ke,canGoForward:Ft,onGoBack:Ue,onGoForward:lt,editor:n,onToggleToolbar:ze,toolbarOpen:$}),$&&n&&u.jsx(n5,{editor:s||n}),wt&&u.jsx(kw,{open:!0,onSwitchDocument:q,onCreateDocument:Mt,refreshKey:w,docTagsRefreshKey:C,workspacesRefreshKey:T,pendingDocs:O,writingTitle:J,writingTarget:V,pendingWriteFilenames:z}),!Ee&&u.jsxs("div",{className:"connection-banner",children:[u.jsx("div",{className:"connection-banner-spinner"}),u.jsx("span",{children:"Reconnecting to server..."})]}),u.jsxs("div",{className:"editor-container",children:[(P==null?void 0:P.autoAccept)===!0&&u.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:[u.jsx("span",{className:"editor-auto-accept-dot"}),"Auto-accept on — agent edits skip review"]}),fe&&u.jsxs("div",{className:"editor-reload-banner",role:"status","aria-live":"polite",children:[u.jsx("span",{className:"editor-reload-dot","aria-hidden":"true"}),u.jsx("span",{children:fe.reloadCount>1?`Document reloaded from disk ${fe.reloadCount}× since you last looked`:"Document reloaded from disk (external write detected)"}),(fe.orphanCount>0||fe.staleBaselineCount>0)&&u.jsxs("span",{className:"editor-reload-detail",children:[fe.orphanCount>0&&u.jsxs("span",{className:"editor-reload-tag editor-reload-tag--orphan",children:[fe.orphanCount," orphan",fe.orphanCount===1?"":"s"]}),fe.staleBaselineCount>0&&u.jsxs("span",{className:"editor-reload-tag editor-reload-tag--stale",children:[fe.staleBaselineCount," stale-baseline"]})]}),u.jsx("button",{type:"button",className:"editor-reload-dismiss",onClick:()=>De(null),"aria-label":"Dismiss reload notification",children:"×"})]}),G?u.jsx(oF,{title:d,onTitleChange:_e,coverImage:(an=P==null?void 0:P.articleContext)==null?void 0:an.coverImage,coverImages:(ft=P==null?void 0:P.articleContext)==null?void 0:ft.coverImages,lastPost:(En=P==null?void 0:P.articleContext)==null?void 0:En.lastPost,children:u.jsx(du,{initialContent:h,extensions:IB,onUpdate:de,onReady:Fe,onLinkClick:te})}):oe?u.jsx(fF,{title:d,onTitleChange:_e,blogContext:P==null?void 0:P.blogContext,filename:xt,children:u.jsx(du,{initialContent:h,onUpdate:de,onReady:Fe,onLinkClick:te})}):ue?u.jsx(pF,{newsletterContext:P==null?void 0:P.newsletterContext,filename:xt,title:d,onTitleChange:_e,onBeforeSend:Jt,children:u.jsx(du,{initialContent:h,onUpdate:de,onReady:Fe,onLinkClick:te})}):P!=null&&P.tweetContext?u.jsx(eF,{tweetContext:P.tweetContext,initialContent:h,onUpdate:de,onEditorReady:Fe,onEditorsChange:K,onActiveEditorChange:i,filename:xt,title:d},g):u.jsx(du,{initialContent:h,onUpdate:de,onReady:Fe,onLinkClick:te})]}),u.jsx(e8,{editors:o,pendingDocs:O,currentFilename:xt,onSwitchDocument:q,sendMessage:et,getDocument:()=>Qe.current,docVersionRef:gt})]}),u.jsx(R5,{editorRef:t,allEditors:o,documentId:xt}),u.jsx(P5,{documentId:xt}),U&&u.jsx(F8,{onClose:()=>Q(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(ne=>ne.json()).then(D).catch(()=>{})}})]})}JM();WM.createRoot(document.getElementById("root")).render(u.jsx(pi.StrictMode,{children:u.jsx(yF,{})}));
|